@orangecheck/agent-core 2.3.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -17,7 +17,12 @@ var REGISTERED_SCOPES = {
17
17
  "ln:send": { keys: ["max_sats", "node", "max_fee_sats"] },
18
18
  "mcp:invoke": { keys: ["server", "tool", "max_invocations"] },
19
19
  // oc-pledge-protocol SPEC §7.3.
20
- "pledge:create": { keys: ["max_bond_sats", "mechanism", "counterparty"] }
20
+ "pledge:create": { keys: ["max_bond_sats", "mechanism", "counterparty"] },
21
+ // The agent-stack adapters (agent-anthropic, -openai, -vercel, -langgraph).
22
+ "anthropic:tool": { keys: ["name"] },
23
+ "openai:function": { keys: ["name"] },
24
+ "vercel:tool": { keys: ["verb"] },
25
+ "langgraph:tool": { keys: ["verb"] }
21
26
  };
22
27
  var NUMERIC_KEYS = /* @__PURE__ */ new Set([
23
28
  "max_bytes",
@@ -685,8 +690,7 @@ async function verifyAction(input) {
685
690
  if (h === null || hash === null) {
686
691
  return err("E_MALFORMED", "confirmed OTS proof missing block_height or block_hash");
687
692
  }
688
- const verified = actionAnchor !== null;
689
- anchor = { status: "confirmed", blockHeight: h, blockHash: hash, verified };
693
+ anchor = actionAnchor !== null ? { status: "confirmed", blockHeight: h, blockHash: hash, verified: true } : { status: "claimed", blockHeight: h, blockHash: hash, verified: false };
690
694
  }
691
695
  return {
692
696
  ok: true,
@@ -1097,6 +1101,18 @@ async function verifyFederationDelegation(input) {
1097
1101
  }
1098
1102
  const quorum = await checkFederationQuorum(env.principal, env.sig, env.id, input);
1099
1103
  if (!quorum.ok) return quorum;
1104
+ if (!input.skipRevocationCheck && !input.revocations) {
1105
+ return fail(
1106
+ "E_MALFORMED",
1107
+ "verifyFederationDelegation requires `revocations` (fetch kind-30085 by #delegation) or an explicit skipRevocationCheck:true to state that revocation is not being checked"
1108
+ );
1109
+ }
1110
+ for (const rev of input.revocations ?? []) {
1111
+ if (rev?.delegation_id !== env.id) continue;
1112
+ const rr = await verifyRevocationOf(env, rev, input);
1113
+ if (!rr.ok) continue;
1114
+ return fail("E_REVOKED", `delegation ${env.id} was revoked by ${rev.id}`);
1115
+ }
1100
1116
  if (!input.skipTemporalCheck) {
1101
1117
  const now = input.now ?? /* @__PURE__ */ new Date();
1102
1118
  const issued = new Date(env.issued_at);
@@ -1107,6 +1123,42 @@ async function verifyFederationDelegation(input) {
1107
1123
  }
1108
1124
  return { ok: true, id: env.id, canonicalMessage: delegationCanonicalMessage(canonInput) };
1109
1125
  }
1126
+ async function verifyRevocationOf(d, rev, input) {
1127
+ if (rev.signer?.alg === "federation") {
1128
+ return verifyFederationRevocation({
1129
+ envelope: rev,
1130
+ delegation: d,
1131
+ verifyBip322: input.verifyBip322,
1132
+ skipSignatureVerification: input.skipSignatureVerification
1133
+ });
1134
+ }
1135
+ const v1 = rev;
1136
+ const holders = d.revocation?.holders ?? ["principal"];
1137
+ if (!Array.isArray(holders) || !holders.includes("agent")) {
1138
+ return fail("E_REVOKER_UNAUTHORIZED", "only the federation may revoke this delegation");
1139
+ }
1140
+ if (v1.kind !== "agent-revocation" || v1.signer?.address !== d.agent.address) {
1141
+ return fail("E_REVOKER_UNAUTHORIZED", "a single-address revocation must be signed by the agent");
1142
+ }
1143
+ if (typeof v1.reason !== "string" || !ISO_UTC.test(v1.signed_at ?? "")) {
1144
+ return fail("E_MALFORMED", "revocation reason / signed_at invalid");
1145
+ }
1146
+ const canonInput = {
1147
+ address: v1.signer.address,
1148
+ delegation_id: v1.delegation_id,
1149
+ reason: v1.reason,
1150
+ signed_at: v1.signed_at
1151
+ };
1152
+ const id = computeRevocationId(canonInput);
1153
+ if (id !== v1.id) return fail("E_BAD_ID", `reconstructed id (${id}) != revocation.id (${v1.id})`);
1154
+ if (!input.skipSignatureVerification) {
1155
+ if (!input.verifyBip322) return fail("E_BAD_SIG", "no BIP-322 verifier supplied");
1156
+ if (typeof v1.sig?.value !== "string" || !await input.verifyBip322(v1.id, v1.sig.value, v1.signer.address)) {
1157
+ return fail("E_BAD_SIG", "revocation BIP-322 signature did not verify");
1158
+ }
1159
+ }
1160
+ return { ok: true, id: v1.id, canonicalMessage: revocationCanonicalMessage(canonInput) };
1161
+ }
1110
1162
  async function verifyFederationRevocation(input) {
1111
1163
  const env = input.envelope;
1112
1164
  if (env?.kind !== "agent-revocation") return fail("E_MALFORMED", 'kind must be "agent-revocation"');