openlifa.openas
importopenas: actors, effects, grants and the run envelope --- an OpenLifa specification and its C++ modules
import openas.sdk;
模組名讀自上游 src/sdk.cppm 裡的 `export module` 宣告。
mcpp add openlifa.openas@0.2.1
用法
來自本倉庫自己的測試專案 —— CI 真的編譯並執行過,不是為了網站寫的。
import std;
import openas;
import openas.conformance;
int main() {
const auto alice = openas::parse("person:alice");
if (!alice) return 1;
const auto agent = openas::delegate(*alice, openas::Kind::agent, "claude");
if (openas::format(agent) != "agent:claude;via=person:alice") return 2;
const openas::Verb drop{.name = "notes.delete", .summary = "Delete a note", .effect = openas::Effect::irreversible,
.options = {{.name = "yes", .flag = true}}, .answers = {"yes"}};
const auto grant = openas::parse_grant("agent:claude;via=person:alice=irreversible@notes.*");
if (!grant) return 3;
if (openas::decide(drop, agent, false, {}, {}) != openas::Decision::ask) return 4;
if (openas::decide(drop, agent, false, {}, {&*grant, 1}) != openas::Decision::run) return 5;
if (!openas::conformance::check(std::span<const openas::Verb>(&drop, 1)).ok()) return 6;
std::println("openas {}: {}", openas::version, openas::format(*grant));
return 0;
}
tests/examples/openlifa.openas/tests/consume.cpp · 專案 tests/examples/openlifa.openas
建置 · 上游資訊清單
- modules
openas.sdk- targets
openas (lib)- manifest version
0.2.1- 來源
https://raw.githubusercontent.com/openlifa/openas/0.2.1/mcpp.toml