agent-passport-system-mcp 3.4.0 → 4.0.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/README.md +2 -2
- package/build/index.d.ts +1 -1
- package/build/index.js +988 -974
- package/package.json +4 -4
package/build/index.js
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
// Start: AGENT_KEY=<pubkey> npx agent-passport-system-mcp
|
|
12
12
|
// or: call the identify tool first
|
|
13
13
|
// ══════════════════════════════════════════════════════════════
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
14
|
+
import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
15
|
+
import { McpServer } from "@modelcontextprotocol/server";
|
|
16
16
|
import { z } from "zod";
|
|
17
17
|
import { readFileSync, writeFileSync, existsSync } from "node:fs";
|
|
18
18
|
import { join, resolve } from "node:path";
|
|
@@ -473,9 +473,14 @@ const TOOL_PROFILES = {
|
|
|
473
473
|
};
|
|
474
474
|
const activeProfile = (process.env.APS_PROFILE || 'full').toLowerCase();
|
|
475
475
|
const profileFilter = TOOL_PROFILES[activeProfile];
|
|
476
|
-
// Wrap server.
|
|
477
|
-
|
|
478
|
-
|
|
476
|
+
// Wrap server.registerTool: profile filtering + try/catch on all handlers.
|
|
477
|
+
// Retargeted from the v1 `.tool` during the 2026-07-28 migration: the codemod
|
|
478
|
+
// rewrote the 150 call sites to registerTool but left this wrapper on `.tool`,
|
|
479
|
+
// which would have silently disabled both profile filtering and the handler
|
|
480
|
+
// try/catch. The wrapper body is unchanged: registerTool(name, config, cb)
|
|
481
|
+
// still carries the handler as its last argument.
|
|
482
|
+
const _origTool = server.registerTool.bind(server);
|
|
483
|
+
server.registerTool = function (name, ...rest) {
|
|
479
484
|
if (name !== 'list_profiles' && activeProfile !== 'full' && profileFilter && !profileFilter.has(name)) {
|
|
480
485
|
return; // filtered out by profile
|
|
481
486
|
}
|
|
@@ -677,7 +682,7 @@ const TOOL_SCOPE_MAP = {
|
|
|
677
682
|
// ═══════════════════════════════════════
|
|
678
683
|
// TOOL: list_profiles
|
|
679
684
|
// ═══════════════════════════════════════
|
|
680
|
-
server.
|
|
685
|
+
server.registerTool("list_profiles", { description: "Show available tool profiles. Set APS_PROFILE env var to limit exposed tools (e.g. APS_PROFILE=data).", inputSchema: z.object({}) }, async () => {
|
|
681
686
|
const lines = Object.entries(TOOL_PROFILES).map(([name, tools]) => `• ${name} (${tools.size} tools): ${Array.from(tools).slice(0, 6).join(', ')}${tools.size > 6 ? '...' : ''}`);
|
|
682
687
|
const essentialSize = TOOL_PROFILES.essential.size;
|
|
683
688
|
return { content: [{ type: "text", text: `📋 Tool Profiles (set APS_PROFILE env var):\n\nActive: ${activeProfile} (${activeProfile === 'full' ? '150' : profileFilter?.size || '150'} tools)\n\nRecommended: essential (${essentialSize} tools) - identity, delegation, enforcement, commerce, reputation.\n\n${lines.join('\n')}\n\n• full (150 tools): All tools exposed (default)` }] };
|
|
@@ -685,9 +690,9 @@ server.tool("list_profiles", "Show available tool profiles. Set APS_PROFILE env
|
|
|
685
690
|
// ═══════════════════════════════════════
|
|
686
691
|
// TOOL: list_tools_for_scope (Primitive #9: Tool Pool Assembly)
|
|
687
692
|
// ═══════════════════════════════════════
|
|
688
|
-
server.
|
|
689
|
-
|
|
690
|
-
}, async ({ scopes }) => {
|
|
693
|
+
server.registerTool("list_tools_for_scope", { description: "List available MCP tools filtered by delegation scope. Pass your delegation scopes to see which tools you can use. Scopes: identity, delegation, principal, reputation, coordination, communication, governance, commerce, data, gateway, network, temporal, attribution, settlement, capability, mutual-auth. Use ['*'] for all tools.", inputSchema: z.object({
|
|
694
|
+
scopes: z.array(z.string()).describe("Your delegation scopes, e.g. ['identity', 'delegation', 'commerce']"),
|
|
695
|
+
}) }, async ({ scopes }) => {
|
|
691
696
|
const allTools = Object.entries(TOOL_SCOPE_MAP);
|
|
692
697
|
const scopeSet = new Set(scopes);
|
|
693
698
|
const filtered = allTools.filter(([_, scope]) => scope === '*' || scopeSet.has(scope) || scopeSet.has('*'));
|
|
@@ -712,11 +717,11 @@ server.tool("list_tools_for_scope", "List available MCP tools filtered by delega
|
|
|
712
717
|
// ═══════════════════════════════════════
|
|
713
718
|
// TOOL: identify
|
|
714
719
|
// ═══════════════════════════════════════
|
|
715
|
-
server.
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
}, async (args) => {
|
|
720
|
+
server.registerTool("identify", { description: "Identify yourself to the coordination server. Sets your role and scopes tools accordingly.", inputSchema: z.object({
|
|
721
|
+
public_key: z.string().describe("Your Ed25519 public key"),
|
|
722
|
+
private_key: z.string().describe("Your Ed25519 private key (for signing)"),
|
|
723
|
+
agent_id: z.string().optional().describe("Your agent ID"),
|
|
724
|
+
}) }, async (args) => {
|
|
720
725
|
recordBehavior('identify');
|
|
721
726
|
state.agentKey = args.public_key;
|
|
722
727
|
state.privateKey = args.private_key;
|
|
@@ -757,7 +762,7 @@ server.tool("identify", "Identify yourself to the coordination server. Sets your
|
|
|
757
762
|
// ═══════════════════════════════════════
|
|
758
763
|
// TOOL: generate_keys
|
|
759
764
|
// ═══════════════════════════════════════
|
|
760
|
-
server.
|
|
765
|
+
server.registerTool("generate_keys", { description: "Generate an Ed25519 keypair for agent identity.", inputSchema: z.object({}) }, async () => {
|
|
761
766
|
const keys = generateKeyPair();
|
|
762
767
|
const isRemote = process.env.MCP_TRANSPORT === 'sse' || process.env.MCP_REMOTE === '1';
|
|
763
768
|
return {
|
|
@@ -777,13 +782,13 @@ server.tool("generate_keys", "Generate an Ed25519 keypair for agent identity.",
|
|
|
777
782
|
// ═══════════════════════════════════════
|
|
778
783
|
// TOOL: issue_passport
|
|
779
784
|
// ═══════════════════════════════════════
|
|
780
|
-
server.
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
}, async (args) => {
|
|
785
|
+
server.registerTool("issue_passport", { description: "Issue a complete agent passport with keys, signed passport, attestation summary, and optional values floor in a single call. The server silently captures Tier 0 observed signals and computes a passport grade (0-3). Use this to onboard any agent — no npm install required.", inputSchema: z.object({
|
|
786
|
+
name: z.string().describe("Agent name (human-readable)"),
|
|
787
|
+
owner: z.string().describe("Owner/principal identifier"),
|
|
788
|
+
mission: z.string().optional().describe("Agent mission description"),
|
|
789
|
+
capabilities: z.array(z.string()).optional().describe("Agent capabilities (e.g., ['research', 'writing'])"),
|
|
790
|
+
attest_to_floor: z.boolean().optional().describe("If true, attests to the default values floor (F-001 through F-008)"),
|
|
791
|
+
}) }, async (args) => {
|
|
787
792
|
const issuanceStart = Date.now();
|
|
788
793
|
// Phase 0: Silent Observation — capture Tier 0 signals before processing
|
|
789
794
|
state.issuanceCount++;
|
|
@@ -884,19 +889,19 @@ server.tool("issue_passport", "Issue a complete agent passport with keys, signed
|
|
|
884
889
|
// ═══════════════════════════════════════
|
|
885
890
|
// TOOL: verify_issuer
|
|
886
891
|
// ═══════════════════════════════════════
|
|
887
|
-
server.
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
signature: z.string(),
|
|
891
|
-
signedAt: z.string(),
|
|
892
|
-
issuerSignature: z.object({
|
|
893
|
-
issuerId: z.string(),
|
|
894
|
-
issuerPublicKey: z.string(),
|
|
892
|
+
server.registerTool("verify_issuer", { description: "Verify that a passport was officially issued by AEOESS. Checks the issuer countersignature against the published AEOESS public key. Returns false for self-signed passports.", inputSchema: z.object({
|
|
893
|
+
passport: z.object({
|
|
894
|
+
passport: z.any(),
|
|
895
895
|
signature: z.string(),
|
|
896
896
|
signedAt: z.string(),
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
897
|
+
issuerSignature: z.object({
|
|
898
|
+
issuerId: z.string(),
|
|
899
|
+
issuerPublicKey: z.string(),
|
|
900
|
+
signature: z.string(),
|
|
901
|
+
signedAt: z.string(),
|
|
902
|
+
}).optional(),
|
|
903
|
+
}).describe("The signed passport object to verify"),
|
|
904
|
+
}) }, async (args) => {
|
|
900
905
|
const sp = args.passport;
|
|
901
906
|
const hasIssuerSig = isIssuerVerified(sp);
|
|
902
907
|
const isValid = hasIssuerSig ? verifyIssuerSignature(sp, AEOESS_ISSUER_PUBLIC_KEY) : false;
|
|
@@ -921,9 +926,9 @@ server.tool("verify_issuer", "Verify that a passport was officially issued by AE
|
|
|
921
926
|
// ═══════════════════════════════════════
|
|
922
927
|
// TOOL: get_passport_grade
|
|
923
928
|
// ═══════════════════════════════════════
|
|
924
|
-
server.
|
|
925
|
-
|
|
926
|
-
}, async (args) => {
|
|
929
|
+
server.registerTool("get_passport_grade", { description: "Query the attestation grade and issuance context for a passport. Returns the passport grade (0-3), flags, and evidence summary. Grade 0 = self-signed, 1 = issuer countersigned, 2 = runtime-bound, 3 = principal-bound. This is the partner-facing trust query.", inputSchema: z.object({
|
|
930
|
+
agent_id: z.string().describe("The agent ID of the passport to query"),
|
|
931
|
+
}) }, async (args) => {
|
|
927
932
|
const context = state.issuanceContexts.get(args.agent_id);
|
|
928
933
|
if (!context) {
|
|
929
934
|
return {
|
|
@@ -966,7 +971,7 @@ server.tool("get_passport_grade", "Query the attestation grade and issuance cont
|
|
|
966
971
|
// ═══════════════════════════════════════
|
|
967
972
|
// TOOL: list_issuance_records
|
|
968
973
|
// ═══════════════════════════════════════
|
|
969
|
-
server.
|
|
974
|
+
server.registerTool("list_issuance_records", { description: "List all stored issuance records with their passport grades. Shows how many passports have been issued in this session and their trust posture. Useful for monitoring issuance patterns.", inputSchema: z.object({}) }, async () => {
|
|
970
975
|
const records = Array.from(state.issuanceContexts.entries()).map(([agentId, ctx]) => ({
|
|
971
976
|
agentId,
|
|
972
977
|
grade: ctx.assessment.passportGrade,
|
|
@@ -994,9 +999,9 @@ server.tool("list_issuance_records", "List all stored issuance records with thei
|
|
|
994
999
|
// ═══════════════════════════════════════
|
|
995
1000
|
// TOOL: get_behavioral_sequence
|
|
996
1001
|
// ═══════════════════════════════════════
|
|
997
|
-
server.
|
|
998
|
-
|
|
999
|
-
}, async (args) => {
|
|
1002
|
+
server.registerTool("get_behavioral_sequence", { description: "Get the post-issuance behavioral sequence for an agent. Shows the first 10 tool calls after passport issuance. Real agents do work. Farming agents extract. This is consilium signal #2.", inputSchema: z.object({
|
|
1003
|
+
agent_id: z.string().describe("The agent ID to query"),
|
|
1004
|
+
}) }, async (args) => {
|
|
1000
1005
|
const sequence = state.postIssuanceBehavior.get(args.agent_id);
|
|
1001
1006
|
if (!sequence || sequence.length === 0) {
|
|
1002
1007
|
return {
|
|
@@ -1038,7 +1043,7 @@ server.tool("get_behavioral_sequence", "Get the post-issuance behavioral sequenc
|
|
|
1038
1043
|
// ═══════════════════════════════════════
|
|
1039
1044
|
// TOOL: get_my_role
|
|
1040
1045
|
// ═══════════════════════════════════════
|
|
1041
|
-
server.
|
|
1046
|
+
server.registerTool("get_my_role", { description: "Get your current role, assigned tasks, and role-specific instructions.", inputSchema: z.object({}) }, async () => {
|
|
1042
1047
|
if (!state.agentRole) {
|
|
1043
1048
|
return {
|
|
1044
1049
|
content: [{
|
|
@@ -1148,25 +1153,25 @@ YOU MUST NOT: Modify deliverables directly. Report issues to the operator.`,
|
|
|
1148
1153
|
// ═══════════════════════════════════════
|
|
1149
1154
|
// OPERATOR TOOLS
|
|
1150
1155
|
// ═══════════════════════════════════════
|
|
1151
|
-
server.
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
}, async (args) => {
|
|
1156
|
+
server.registerTool("create_task_brief", { description: "[OPERATOR] Create a new task with roles, deliverables, and acceptance criteria.", inputSchema: z.object({
|
|
1157
|
+
title: z.string().describe("Task title"),
|
|
1158
|
+
description: z.string().describe("What needs to be done"),
|
|
1159
|
+
roles: z.array(z.object({
|
|
1160
|
+
role: z.string().describe("Role name (researcher, analyst, builder, reviewer, or custom)"),
|
|
1161
|
+
description: z.string().describe("What this role does"),
|
|
1162
|
+
allowed_scopes: z.array(z.string()).describe("What this role CAN do"),
|
|
1163
|
+
forbidden_scopes: z.array(z.string()).describe("What this role CANNOT do"),
|
|
1164
|
+
required_capabilities: z.array(z.string()).optional().describe("Agent must have these capabilities"),
|
|
1165
|
+
})).describe("Roles needed for this task"),
|
|
1166
|
+
deliverables: z.array(z.object({
|
|
1167
|
+
name: z.string(),
|
|
1168
|
+
description: z.string(),
|
|
1169
|
+
format: z.string(),
|
|
1170
|
+
produced_by: z.string().describe("Which role produces this"),
|
|
1171
|
+
})).describe("Expected outputs"),
|
|
1172
|
+
acceptance_criteria: z.array(z.string()).describe("What 'done' looks like"),
|
|
1173
|
+
deadline: z.string().optional().describe("ISO 8601 deadline"),
|
|
1174
|
+
}) }, async (args) => {
|
|
1170
1175
|
const keyErr = requireKey();
|
|
1171
1176
|
if (keyErr)
|
|
1172
1177
|
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
@@ -1212,14 +1217,14 @@ server.tool("create_task_brief", "[OPERATOR] Create a new task with roles, deliv
|
|
|
1212
1217
|
}],
|
|
1213
1218
|
};
|
|
1214
1219
|
});
|
|
1215
|
-
server.
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
}, async (args) => {
|
|
1220
|
+
server.registerTool("assign_agent", { description: "[OPERATOR] Assign an agent to a role in a task. Creates a delegation automatically.", inputSchema: z.object({
|
|
1221
|
+
task_id: z.string().describe("Task ID"),
|
|
1222
|
+
role: z.string().describe("Role to assign"),
|
|
1223
|
+
agent_id: z.string().describe("Agent ID"),
|
|
1224
|
+
agent_public_key: z.string().describe("Agent's Ed25519 public key"),
|
|
1225
|
+
scope: z.array(z.string()).describe("Delegation scopes"),
|
|
1226
|
+
spend_limit: z.number().default(500).describe("Max spend"),
|
|
1227
|
+
}) }, async (args) => {
|
|
1223
1228
|
const keyErr = requireKey();
|
|
1224
1229
|
if (keyErr)
|
|
1225
1230
|
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
@@ -1264,19 +1269,19 @@ server.tool("assign_agent", "[OPERATOR] Assign an agent to a role in a task. Cre
|
|
|
1264
1269
|
}],
|
|
1265
1270
|
};
|
|
1266
1271
|
});
|
|
1267
|
-
server.
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
}, async (args) => {
|
|
1272
|
+
server.registerTool("review_evidence", { description: "[OPERATOR] Review an evidence packet. Score it and approve, rework, or reject.", inputSchema: z.object({
|
|
1273
|
+
task_id: z.string().describe("Task ID"),
|
|
1274
|
+
packet_id: z.string().describe("Evidence packet ID to review"),
|
|
1275
|
+
verdict: z.enum(["approve", "rework", "reject"]).describe("Your verdict"),
|
|
1276
|
+
score: z.number().min(0).max(100).describe("Quality score 0-100"),
|
|
1277
|
+
threshold: z.number().default(70).describe("Minimum passing score"),
|
|
1278
|
+
rationale: z.string().describe("Why this verdict"),
|
|
1279
|
+
issues: z.array(z.object({
|
|
1280
|
+
claim_id: z.string(),
|
|
1281
|
+
issue: z.string(),
|
|
1282
|
+
severity: z.enum(["critical", "major", "minor"]),
|
|
1283
|
+
})).optional().describe("Specific issues found"),
|
|
1284
|
+
}) }, async (args) => {
|
|
1280
1285
|
const keyErr = requireKey();
|
|
1281
1286
|
if (keyErr)
|
|
1282
1287
|
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
@@ -1322,13 +1327,13 @@ server.tool("review_evidence", "[OPERATOR] Review an evidence packet. Score it a
|
|
|
1322
1327
|
return { content: [{ type: "text", text: safeError("Error", e) }], isError: true };
|
|
1323
1328
|
}
|
|
1324
1329
|
});
|
|
1325
|
-
server.
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
}, async (args) => {
|
|
1330
|
+
server.registerTool("handoff_evidence", { description: "[OPERATOR] Transfer approved evidence from researcher to analyst.", inputSchema: z.object({
|
|
1331
|
+
task_id: z.string().describe("Task ID"),
|
|
1332
|
+
packet_id: z.string().describe("Approved evidence packet ID"),
|
|
1333
|
+
review_id: z.string().describe("Review ID that approved it"),
|
|
1334
|
+
to_role: z.string().describe("Destination role (e.g. analyst)"),
|
|
1335
|
+
to_agent_key: z.string().describe("Destination agent's public key"),
|
|
1336
|
+
}) }, async (args) => {
|
|
1332
1337
|
const keyErr = requireKey();
|
|
1333
1338
|
if (keyErr)
|
|
1334
1339
|
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
@@ -1370,11 +1375,11 @@ server.tool("handoff_evidence", "[OPERATOR] Transfer approved evidence from rese
|
|
|
1370
1375
|
return { content: [{ type: "text", text: safeError("Error", e) }], isError: true };
|
|
1371
1376
|
}
|
|
1372
1377
|
});
|
|
1373
|
-
server.
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
}, async (args) => {
|
|
1378
|
+
server.registerTool("complete_task", { description: "[OPERATOR] Close the task unit with final status and retrospective.", inputSchema: z.object({
|
|
1379
|
+
task_id: z.string().describe("Task ID"),
|
|
1380
|
+
status: z.enum(["completed", "failed", "partial"]).describe("Final status"),
|
|
1381
|
+
retrospective: z.string().optional().describe("What went well, what didn't"),
|
|
1382
|
+
}) }, async (args) => {
|
|
1378
1383
|
const keyErr = requireKey();
|
|
1379
1384
|
if (keyErr)
|
|
1380
1385
|
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
@@ -1411,9 +1416,9 @@ server.tool("complete_task", "[OPERATOR] Close the task unit with final status a
|
|
|
1411
1416
|
// ═══════════════════════════════════════
|
|
1412
1417
|
// WORKER TOOLS (any assigned role)
|
|
1413
1418
|
// ═══════════════════════════════════════
|
|
1414
|
-
server.
|
|
1415
|
-
|
|
1416
|
-
}, async (args) => {
|
|
1419
|
+
server.registerTool("accept_assignment", { description: "[ANY ROLE] Accept your task assignment. Confirms you're ready to work.", inputSchema: z.object({
|
|
1420
|
+
task_id: z.string().describe("Task ID to accept"),
|
|
1421
|
+
}) }, async (args) => {
|
|
1417
1422
|
const keyErr = requireKey();
|
|
1418
1423
|
if (keyErr)
|
|
1419
1424
|
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
@@ -1442,18 +1447,18 @@ server.tool("accept_assignment", "[ANY ROLE] Accept your task assignment. Confir
|
|
|
1442
1447
|
}],
|
|
1443
1448
|
};
|
|
1444
1449
|
});
|
|
1445
|
-
server.
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
}, async (args) => {
|
|
1450
|
+
server.registerTool("submit_evidence", { description: "[RESEARCHER] Submit research evidence as a signed packet with citations.", inputSchema: z.object({
|
|
1451
|
+
task_id: z.string().describe("Task ID"),
|
|
1452
|
+
claims: z.array(z.object({
|
|
1453
|
+
dimension: z.string().describe("Evaluation dimension"),
|
|
1454
|
+
subject: z.string().describe("What's being evaluated"),
|
|
1455
|
+
claim: z.string().describe("The factual claim"),
|
|
1456
|
+
quote: z.string().describe("Supporting quote from source (10+ words)"),
|
|
1457
|
+
source_url: z.string().describe("Verifiable source URL"),
|
|
1458
|
+
confidence: z.enum(["high", "medium", "low", "not_found"]).describe("Confidence level"),
|
|
1459
|
+
})).describe("Evidence claims with citations"),
|
|
1460
|
+
methodology: z.string().describe("How you gathered this evidence"),
|
|
1461
|
+
}) }, async (args) => {
|
|
1457
1462
|
recordBehavior('submit_evidence');
|
|
1458
1463
|
const keyErr = requireKey();
|
|
1459
1464
|
if (keyErr)
|
|
@@ -1495,9 +1500,9 @@ server.tool("submit_evidence", "[RESEARCHER] Submit research evidence as a signe
|
|
|
1495
1500
|
}],
|
|
1496
1501
|
};
|
|
1497
1502
|
});
|
|
1498
|
-
server.
|
|
1499
|
-
|
|
1500
|
-
}, async (args) => {
|
|
1503
|
+
server.registerTool("get_evidence", { description: "[ANALYST/BUILDER/REVIEWER] Get evidence that was handed off to you.", inputSchema: z.object({
|
|
1504
|
+
task_id: z.string().describe("Task ID"),
|
|
1505
|
+
}) }, async (args) => {
|
|
1501
1506
|
const unit = state.taskUnits.get(args.task_id);
|
|
1502
1507
|
if (!unit)
|
|
1503
1508
|
return { content: [{ type: "text", text: `Task ${args.task_id} not found.` }], isError: true };
|
|
@@ -1536,14 +1541,14 @@ server.tool("get_evidence", "[ANALYST/BUILDER/REVIEWER] Get evidence that was ha
|
|
|
1536
1541
|
}],
|
|
1537
1542
|
};
|
|
1538
1543
|
});
|
|
1539
|
-
server.
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
}, async (args) => {
|
|
1544
|
+
server.registerTool("submit_deliverable", { description: "[ANALYST/BUILDER] Submit your final output tied to evidence.", inputSchema: z.object({
|
|
1545
|
+
task_id: z.string().describe("Task ID"),
|
|
1546
|
+
spec_id: z.string().describe("Deliverable spec ID from the brief"),
|
|
1547
|
+
content: z.string().describe("The deliverable content"),
|
|
1548
|
+
evidence_packet_ids: z.array(z.string()).describe("Evidence packet IDs used"),
|
|
1549
|
+
citation_count: z.number().describe("Number of citations in output"),
|
|
1550
|
+
gaps_flagged: z.number().describe("Number of gaps explicitly flagged"),
|
|
1551
|
+
}) }, async (args) => {
|
|
1547
1552
|
const keyErr = requireKey();
|
|
1548
1553
|
if (keyErr)
|
|
1549
1554
|
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
@@ -1582,7 +1587,7 @@ server.tool("submit_deliverable", "[ANALYST/BUILDER] Submit your final output ti
|
|
|
1582
1587
|
// ═══════════════════════════════════════
|
|
1583
1588
|
// SHARED TOOLS (any agent)
|
|
1584
1589
|
// ═══════════════════════════════════════
|
|
1585
|
-
server.
|
|
1590
|
+
server.registerTool("list_tasks", { description: "List all tasks in the coordination store.", inputSchema: z.object({}) }, async () => {
|
|
1586
1591
|
const tasks = Array.from(state.taskUnits.entries()).map(([id, unit]) => ({
|
|
1587
1592
|
taskId: id,
|
|
1588
1593
|
title: unit.brief.title,
|
|
@@ -1604,9 +1609,9 @@ server.tool("list_tasks", "List all tasks in the coordination store.", {}, async
|
|
|
1604
1609
|
}],
|
|
1605
1610
|
};
|
|
1606
1611
|
});
|
|
1607
|
-
server.
|
|
1608
|
-
|
|
1609
|
-
}, async (args) => {
|
|
1612
|
+
server.registerTool("get_task_detail", { description: "Get full details of a specific task including all evidence, reviews, and deliverables.", inputSchema: z.object({
|
|
1613
|
+
task_id: z.string().describe("Task ID"),
|
|
1614
|
+
}) }, async (args) => {
|
|
1610
1615
|
const unit = state.taskUnits.get(args.task_id);
|
|
1611
1616
|
if (!unit)
|
|
1612
1617
|
return { content: [{ type: "text", text: `Task ${args.task_id} not found.` }], isError: true };
|
|
@@ -1664,13 +1669,13 @@ server.tool("get_task_detail", "Get full details of a specific task including al
|
|
|
1664
1669
|
// ═══════════════════════════════════════
|
|
1665
1670
|
// DELEGATION TOOLS (Layer 1)
|
|
1666
1671
|
// ═══════════════════════════════════════
|
|
1667
|
-
server.
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
}, async (args) => {
|
|
1672
|
+
server.registerTool("create_delegation", { description: "[OPERATOR] Create a scoped delegation from one agent to another.", inputSchema: z.object({
|
|
1673
|
+
delegated_to: z.string().describe("Public key of the agent receiving delegation"),
|
|
1674
|
+
scope: z.array(z.string()).describe("Scopes to grant (e.g. ['web_search', 'code_execution'])"),
|
|
1675
|
+
spend_limit: z.number().default(500).describe("Maximum spend allowed"),
|
|
1676
|
+
max_depth: z.number().default(1).describe("How many levels of sub-delegation"),
|
|
1677
|
+
expires_in_hours: z.number().default(24).describe("Delegation validity in hours"),
|
|
1678
|
+
}) }, async (args) => {
|
|
1674
1679
|
recordBehavior('create_delegation');
|
|
1675
1680
|
const keyErr = requireKey();
|
|
1676
1681
|
if (keyErr)
|
|
@@ -1715,9 +1720,9 @@ server.tool("create_delegation", "[OPERATOR] Create a scoped delegation from one
|
|
|
1715
1720
|
}],
|
|
1716
1721
|
};
|
|
1717
1722
|
});
|
|
1718
|
-
server.
|
|
1719
|
-
|
|
1720
|
-
}, async (args) => {
|
|
1723
|
+
server.registerTool("verify_delegation", { description: "Verify a delegation's cryptographic signature and validity.", inputSchema: z.object({
|
|
1724
|
+
delegation_id: z.string().describe("Delegation ID to verify"),
|
|
1725
|
+
}) }, async (args) => {
|
|
1721
1726
|
const delegation = state.delegations.get(args.delegation_id);
|
|
1722
1727
|
if (!delegation)
|
|
1723
1728
|
return { content: [{ type: "text", text: `Delegation ${args.delegation_id} not found in session.` }], isError: true };
|
|
@@ -1735,11 +1740,11 @@ server.tool("verify_delegation", "Verify a delegation's cryptographic signature
|
|
|
1735
1740
|
}],
|
|
1736
1741
|
};
|
|
1737
1742
|
});
|
|
1738
|
-
server.
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
}, async (args) => {
|
|
1743
|
+
server.registerTool("revoke_delegation", { description: "[OPERATOR] Revoke a delegation. Optionally cascade to all sub-delegations.", inputSchema: z.object({
|
|
1744
|
+
delegation_id: z.string().describe("Delegation ID to revoke"),
|
|
1745
|
+
reason: z.string().describe("Why the delegation is being revoked"),
|
|
1746
|
+
cascade: z.boolean().default(true).describe("Also revoke all sub-delegations"),
|
|
1747
|
+
}) }, async (args) => {
|
|
1743
1748
|
recordBehavior('revoke_delegation');
|
|
1744
1749
|
const keyErr = requireKey();
|
|
1745
1750
|
if (keyErr)
|
|
@@ -1772,12 +1777,12 @@ server.tool("revoke_delegation", "[OPERATOR] Revoke a delegation. Optionally cas
|
|
|
1772
1777
|
};
|
|
1773
1778
|
}
|
|
1774
1779
|
});
|
|
1775
|
-
server.
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
}, async (args) => {
|
|
1780
|
+
server.registerTool("sub_delegate", { description: "Sub-delegate authority to another agent (must be within your delegation scope and depth).", inputSchema: z.object({
|
|
1781
|
+
parent_delegation_id: z.string().describe("Your delegation ID"),
|
|
1782
|
+
delegated_to: z.string().describe("Public key of the agent receiving sub-delegation"),
|
|
1783
|
+
scope: z.array(z.string()).describe("Scopes to grant (must be subset of parent)"),
|
|
1784
|
+
spend_limit: z.number().describe("Maximum spend (must be <= parent)"),
|
|
1785
|
+
}) }, async (args) => {
|
|
1781
1786
|
const keyErr = requireKey();
|
|
1782
1787
|
if (keyErr)
|
|
1783
1788
|
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
@@ -1818,13 +1823,13 @@ server.tool("sub_delegate", "Sub-delegate authority to another agent (must be wi
|
|
|
1818
1823
|
// ═══════════════════════════════════════
|
|
1819
1824
|
// AGORA TOOLS (Layer 4)
|
|
1820
1825
|
// ═══════════════════════════════════════
|
|
1821
|
-
server.
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
}, async (args) => {
|
|
1826
|
+
server.registerTool("post_agora_message", { description: "Post a signed message to the Agora feed. Anyone can read, everything is signed.", inputSchema: z.object({
|
|
1827
|
+
topic: z.string().describe("Topic channel (e.g. 'coordination', 'governance', 'general')"),
|
|
1828
|
+
type: z.enum(["announcement", "proposal", "discussion", "request", "ack", "vote"]).describe("Message type"),
|
|
1829
|
+
subject: z.string().describe("One-line summary"),
|
|
1830
|
+
content: z.string().describe("Message body (markdown)"),
|
|
1831
|
+
reply_to: z.string().optional().describe("Message ID to reply to (for threading)"),
|
|
1832
|
+
}) }, async (args) => {
|
|
1828
1833
|
const keyErr = requireKey();
|
|
1829
1834
|
if (keyErr)
|
|
1830
1835
|
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
@@ -1854,7 +1859,7 @@ server.tool("post_agora_message", "Post a signed message to the Agora feed. Anyo
|
|
|
1854
1859
|
}],
|
|
1855
1860
|
};
|
|
1856
1861
|
});
|
|
1857
|
-
server.
|
|
1862
|
+
server.registerTool("get_agora_topics", { description: "List all topics in the Agora feed with message counts.", inputSchema: z.object({}) }, async () => {
|
|
1858
1863
|
const topics = getTopics(state.agoraFeed);
|
|
1859
1864
|
return {
|
|
1860
1865
|
content: [{
|
|
@@ -1866,9 +1871,9 @@ server.tool("get_agora_topics", "List all topics in the Agora feed with message
|
|
|
1866
1871
|
}],
|
|
1867
1872
|
};
|
|
1868
1873
|
});
|
|
1869
|
-
server.
|
|
1870
|
-
|
|
1871
|
-
}, async (args) => {
|
|
1874
|
+
server.registerTool("get_agora_thread", { description: "Get a message thread from the Agora feed.", inputSchema: z.object({
|
|
1875
|
+
message_id: z.string().describe("Root message ID to get thread for"),
|
|
1876
|
+
}) }, async (args) => {
|
|
1872
1877
|
const thread = getThread(state.agoraFeed, args.message_id);
|
|
1873
1878
|
return {
|
|
1874
1879
|
content: [{
|
|
@@ -1886,9 +1891,9 @@ server.tool("get_agora_thread", "Get a message thread from the Agora feed.", {
|
|
|
1886
1891
|
}],
|
|
1887
1892
|
};
|
|
1888
1893
|
});
|
|
1889
|
-
server.
|
|
1890
|
-
|
|
1891
|
-
}, async (args) => {
|
|
1894
|
+
server.registerTool("get_agora_by_topic", { description: "Get all messages in a topic.", inputSchema: z.object({
|
|
1895
|
+
topic: z.string().describe("Topic to filter by"),
|
|
1896
|
+
}) }, async (args) => {
|
|
1892
1897
|
const messages = getByTopic(state.agoraFeed, args.topic);
|
|
1893
1898
|
return {
|
|
1894
1899
|
content: [{
|
|
@@ -1908,11 +1913,11 @@ server.tool("get_agora_by_topic", "Get all messages in a topic.", {
|
|
|
1908
1913
|
}],
|
|
1909
1914
|
};
|
|
1910
1915
|
});
|
|
1911
|
-
server.
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
}, async (args) => {
|
|
1916
|
+
server.registerTool("register_agora_agent", { description: "Register an agent in the Agora so their messages can be verified.", inputSchema: z.object({
|
|
1917
|
+
agent_id: z.string().describe("Agent ID"),
|
|
1918
|
+
agent_name: z.string().describe("Display name"),
|
|
1919
|
+
public_key: z.string().describe("Ed25519 public key"),
|
|
1920
|
+
}) }, async (args) => {
|
|
1916
1921
|
registerAgent(state.agoraRegistry, {
|
|
1917
1922
|
agentId: args.agent_id,
|
|
1918
1923
|
agentName: args.agent_name,
|
|
@@ -1931,12 +1936,12 @@ server.tool("register_agora_agent", "Register an agent in the Agora so their mes
|
|
|
1931
1936
|
}],
|
|
1932
1937
|
};
|
|
1933
1938
|
});
|
|
1934
|
-
server.
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
}, async (args) => {
|
|
1939
|
+
server.registerTool("register_agora_public", { description: "Register your agent in the PUBLIC Agora registry at aeoess.com. Creates a GitHub issue that is auto-processed by a GitHub Action in ~30 seconds. Requires GITHUB_TOKEN env var or pass token directly. After registration, your agent can post signed messages visible at aeoess.com/agora.", inputSchema: z.object({
|
|
1940
|
+
token: z.string().optional().describe("GitHub personal access token (or set GITHUB_TOKEN env var)"),
|
|
1941
|
+
runtime: z.string().optional().describe("Agent runtime platform (e.g., 'claude', 'gpt-telegram', 'openclaw-github')"),
|
|
1942
|
+
capabilities: z.array(z.string()).optional().describe("Agent capabilities"),
|
|
1943
|
+
owner: z.string().optional().describe("Who operates this agent"),
|
|
1944
|
+
}) }, async (args) => {
|
|
1940
1945
|
const keyErr = requireKey();
|
|
1941
1946
|
if (keyErr)
|
|
1942
1947
|
return { content: [{ type: "text", text: keyErr }] };
|
|
@@ -2007,14 +2012,14 @@ server.tool("register_agora_public", "Register your agent in the PUBLIC Agora re
|
|
|
2007
2012
|
// ═══════════════════════════════════════
|
|
2008
2013
|
// COMMS TOOLS (Agent-to-Agent Communication)
|
|
2009
2014
|
// ═══════════════════════════════════════
|
|
2010
|
-
server.
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
}, async (args) => {
|
|
2015
|
+
server.registerTool("send_message", { description: "Send a signed message to another agent. Message is written to comms/to-{agent}.json.", inputSchema: z.object({
|
|
2016
|
+
to: z.string().describe("Recipient agent name (e.g., 'aeoess', 'portalx2', 'claude')"),
|
|
2017
|
+
subject: z.string().describe("Message subject"),
|
|
2018
|
+
message: z.string().describe("Message body"),
|
|
2019
|
+
type: z.string().optional().describe("Message type (default: 'message')"),
|
|
2020
|
+
priority: z.string().optional().describe("Priority: low, normal, high, critical"),
|
|
2021
|
+
data: z.record(z.string(), z.unknown()).optional().describe("Structured data payload"),
|
|
2022
|
+
}) }, async (args) => {
|
|
2018
2023
|
const keyErr = requireKey();
|
|
2019
2024
|
if (keyErr)
|
|
2020
2025
|
return { content: [{ type: "text", text: keyErr }] };
|
|
@@ -2053,10 +2058,10 @@ server.tool("send_message", "Send a signed message to another agent. Message is
|
|
|
2053
2058
|
}, null, 2) }],
|
|
2054
2059
|
};
|
|
2055
2060
|
});
|
|
2056
|
-
server.
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
}, async (args) => {
|
|
2061
|
+
server.registerTool("check_messages", { description: "Check messages addressed to you. Reads from comms/to-{your-agent-name}.json.", inputSchema: z.object({
|
|
2062
|
+
unprocessed_only: z.boolean().optional().describe("Only show unprocessed messages (default: true)"),
|
|
2063
|
+
mark_read: z.boolean().optional().describe("Mark returned messages as processed (default: false)"),
|
|
2064
|
+
}) }, async (args) => {
|
|
2060
2065
|
const name = getAgentName();
|
|
2061
2066
|
const filePath = join(COMMS_PATH, `to-${name}.json`);
|
|
2062
2067
|
if (!isPathWithin(filePath, COMMS_PATH)) {
|
|
@@ -2087,13 +2092,13 @@ server.tool("check_messages", "Check messages addressed to you. Reads from comms
|
|
|
2087
2092
|
}, null, 2) }],
|
|
2088
2093
|
};
|
|
2089
2094
|
});
|
|
2090
|
-
server.
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
}, async (args) => {
|
|
2095
|
+
server.registerTool("broadcast", { description: "Send a signed message to all agents via comms/broadcast.json.", inputSchema: z.object({
|
|
2096
|
+
subject: z.string().describe("Message subject"),
|
|
2097
|
+
message: z.string().describe("Message body"),
|
|
2098
|
+
type: z.string().optional().describe("Message type (default: 'broadcast')"),
|
|
2099
|
+
priority: z.string().optional().describe("Priority: low, normal, high, critical"),
|
|
2100
|
+
data: z.record(z.string(), z.unknown()).optional().describe("Structured data payload"),
|
|
2101
|
+
}) }, async (args) => {
|
|
2097
2102
|
const keyErr = requireKey();
|
|
2098
2103
|
if (keyErr)
|
|
2099
2104
|
return { content: [{ type: "text", text: keyErr }] };
|
|
@@ -2120,9 +2125,9 @@ server.tool("broadcast", "Send a signed message to all agents via comms/broadcas
|
|
|
2120
2125
|
}, null, 2) }],
|
|
2121
2126
|
};
|
|
2122
2127
|
});
|
|
2123
|
-
server.
|
|
2124
|
-
|
|
2125
|
-
}, async (args) => {
|
|
2128
|
+
server.registerTool("list_agents", { description: "List registered agents from the agent registry (agora/agents.json).", inputSchema: z.object({
|
|
2129
|
+
status_filter: z.string().optional().describe("Filter by status: active, pending, retired (default: all)"),
|
|
2130
|
+
}) }, async (args) => {
|
|
2126
2131
|
let agents = loadAgentsRegistry();
|
|
2127
2132
|
if (args.status_filter) {
|
|
2128
2133
|
agents = agents.filter(a => a.status === args.status_filter);
|
|
@@ -2141,9 +2146,9 @@ server.tool("list_agents", "List registered agents from the agent registry (agor
|
|
|
2141
2146
|
// ═══════════════════════════════════════
|
|
2142
2147
|
// VALUES / POLICY TOOLS (Layer 2 + 5)
|
|
2143
2148
|
// ═══════════════════════════════════════
|
|
2144
|
-
server.
|
|
2145
|
-
|
|
2146
|
-
}, async (args) => {
|
|
2149
|
+
server.registerTool("load_values_floor", { description: "Load a Values Floor from YAML. Sets the floor principles for policy evaluation.", inputSchema: z.object({
|
|
2150
|
+
yaml: z.string().describe("Values Floor YAML content"),
|
|
2151
|
+
}) }, async (args) => {
|
|
2147
2152
|
try {
|
|
2148
2153
|
const floor = loadFloor(args.yaml);
|
|
2149
2154
|
state.floorYaml = args.yaml;
|
|
@@ -2163,10 +2168,10 @@ server.tool("load_values_floor", "Load a Values Floor from YAML. Sets the floor
|
|
|
2163
2168
|
return { content: [{ type: "text", text: safeError("Failed to load floor", e) }], isError: true };
|
|
2164
2169
|
}
|
|
2165
2170
|
});
|
|
2166
|
-
server.
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
}, async (args) => {
|
|
2171
|
+
server.registerTool("attest_to_floor", { description: "Attest that your agent agrees to abide by the loaded Values Floor.", inputSchema: z.object({
|
|
2172
|
+
floor_version: z.string().describe("Version of the floor to attest to"),
|
|
2173
|
+
extensions: z.array(z.string()).optional().describe("Optional additional extensions"),
|
|
2174
|
+
}) }, async (args) => {
|
|
2170
2175
|
const keyErr = requireKey();
|
|
2171
2176
|
if (keyErr)
|
|
2172
2177
|
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
@@ -2187,15 +2192,15 @@ server.tool("attest_to_floor", "Attest that your agent agrees to abide by the lo
|
|
|
2187
2192
|
}],
|
|
2188
2193
|
};
|
|
2189
2194
|
});
|
|
2190
|
-
server.
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
}, async (args) => {
|
|
2195
|
+
server.registerTool("create_intent", { description: "Declare an intent to perform an action. First step of the 3-signature chain.", inputSchema: z.object({
|
|
2196
|
+
action_type: z.string().describe("What type of action (e.g. 'web_search', 'commerce:checkout')"),
|
|
2197
|
+
target: z.string().describe("What the action operates on"),
|
|
2198
|
+
scope_required: z.string().describe("Which delegation scope is needed"),
|
|
2199
|
+
spend_amount: z.number().optional().describe("Expected spend amount"),
|
|
2200
|
+
spend_currency: z.string().optional().describe("Spend currency (e.g. 'usd')"),
|
|
2201
|
+
context: z.string().optional().describe("Why the agent wants to do this"),
|
|
2202
|
+
delegation_id: z.string().describe("Delegation ID authorizing this action"),
|
|
2203
|
+
}) }, async (args) => {
|
|
2199
2204
|
const keyErr = requireKey();
|
|
2200
2205
|
if (keyErr)
|
|
2201
2206
|
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
@@ -2225,12 +2230,12 @@ server.tool("create_intent", "Declare an intent to perform an action. First step
|
|
|
2225
2230
|
}],
|
|
2226
2231
|
};
|
|
2227
2232
|
});
|
|
2228
|
-
server.
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
}, async (args) => {
|
|
2233
|
+
server.registerTool("evaluate_intent", { description: "[OPERATOR] Evaluate an intent against the Values Floor policy engine. Returns real pass/fail verdict.", inputSchema: z.object({
|
|
2234
|
+
intent_id: z.string().describe("Intent ID from create_intent"),
|
|
2235
|
+
delegation_scope: z.array(z.string()).describe("Delegation scope for context"),
|
|
2236
|
+
delegation_spend_limit: z.number().describe("Delegation spend limit"),
|
|
2237
|
+
delegation_spent: z.number().default(0).describe("Amount already spent"),
|
|
2238
|
+
}) }, async (args) => {
|
|
2234
2239
|
const keyErr = requireKey();
|
|
2235
2240
|
if (keyErr)
|
|
2236
2241
|
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
@@ -2292,13 +2297,13 @@ server.tool("evaluate_intent", "[OPERATOR] Evaluate an intent against the Values
|
|
|
2292
2297
|
// ═══════════════════════════════════════
|
|
2293
2298
|
// COMMERCE TOOLS (Layer 8)
|
|
2294
2299
|
// ═══════════════════════════════════════
|
|
2295
|
-
server.
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
}, async (_args) => {
|
|
2300
|
+
server.registerTool("commerce_preflight", { description: "[moved to gateway in SDK 3.3.0] The 6-gate commerce preflight orchestration moved out of the SDK and MCP into the AEOESS gateway. This tool no longer runs the pipeline locally; it returns a machine-readable deprecation notice pointing to the gateway commerce endpoint. Compose the pure gate predicates from the SDK yourself, or call the gateway.", inputSchema: z.object({
|
|
2301
|
+
merchant_name: z.string().describe("Merchant to purchase from"),
|
|
2302
|
+
amount: z.number().describe("Purchase amount"),
|
|
2303
|
+
currency: z.string().default("usd").describe("Currency code"),
|
|
2304
|
+
delegation_id: z.string().describe("Commerce delegation ID"),
|
|
2305
|
+
agent_id: z.string().describe("Agent making the purchase"),
|
|
2306
|
+
}) }, async (_args) => {
|
|
2302
2307
|
recordBehavior('commerce_preflight');
|
|
2303
2308
|
// commercePreflight() became a throw-only migration stub in agent-passport-system 3.3.0
|
|
2304
2309
|
// (the orchestrator moved to the gateway). Rather than let that stub throw, return a clean,
|
|
@@ -2317,11 +2322,11 @@ server.tool("commerce_preflight", "[moved to gateway in SDK 3.3.0] The 6-gate co
|
|
|
2317
2322
|
isError: true,
|
|
2318
2323
|
};
|
|
2319
2324
|
});
|
|
2320
|
-
server.
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
}, async (args) => {
|
|
2325
|
+
server.registerTool("get_commerce_spend", { description: "Get spend analytics for a commerce delegation.", inputSchema: z.object({
|
|
2326
|
+
agent_id: z.string().describe("Agent ID"),
|
|
2327
|
+
delegation_id: z.string().describe("Commerce delegation ID"),
|
|
2328
|
+
spend_limit: z.number().describe("Total allowed spend"),
|
|
2329
|
+
}) }, async (args) => {
|
|
2325
2330
|
// Report spend recorded on the session delegation instead of always reporting 0. Caveat:
|
|
2326
2331
|
// nothing in the MCP yet increments sessionDel.spentAmount (a metering record path is a
|
|
2327
2332
|
// decision flagged for Tima), so this reflects whatever the session state holds.
|
|
@@ -2342,14 +2347,14 @@ server.tool("get_commerce_spend", "Get spend analytics for a commerce delegation
|
|
|
2342
2347
|
}],
|
|
2343
2348
|
};
|
|
2344
2349
|
});
|
|
2345
|
-
server.
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
}, async (args) => {
|
|
2350
|
+
server.registerTool("request_human_approval", { description: "Request human approval for a high-value purchase.", inputSchema: z.object({
|
|
2351
|
+
agent_id: z.string().describe("Agent requesting approval"),
|
|
2352
|
+
merchant: z.string().describe("Merchant name"),
|
|
2353
|
+
amount: z.number().describe("Purchase amount"),
|
|
2354
|
+
currency: z.string().default("usd").describe("Currency"),
|
|
2355
|
+
reason: z.string().describe("Why this purchase is needed"),
|
|
2356
|
+
expires_minutes: z.number().default(30).describe("Minutes until approval expires"),
|
|
2357
|
+
}) }, async (args) => {
|
|
2353
2358
|
const approval = requestHumanApproval({
|
|
2354
2359
|
agentId: args.agent_id,
|
|
2355
2360
|
delegationId: 'pending',
|
|
@@ -2374,34 +2379,34 @@ server.tool("request_human_approval", "Request human approval for a high-value p
|
|
|
2374
2379
|
// ═══════════════════════════════════════
|
|
2375
2380
|
// AGENT CONTEXT — Enforcement Middleware
|
|
2376
2381
|
// ═══════════════════════════════════════
|
|
2377
|
-
server.
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
}, async (_args) => movedToGateway("create_agent_context"));
|
|
2384
|
-
server.
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
}, async (_args) => movedToGateway("execute_with_context"));
|
|
2390
|
-
server.
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
}, async (_args) => movedToGateway("complete_action"));
|
|
2382
|
+
server.registerTool("create_agent_context", { description: "[deprecated in v3.0.0 — use gateway.aeoess.com REST API] Create an enforcement context that automatically runs every action through the 3-signature policy chain.", inputSchema: z.object({
|
|
2383
|
+
name: z.string().describe("Agent name"),
|
|
2384
|
+
mission: z.string().describe("Agent mission statement"),
|
|
2385
|
+
enforcement: z.enum(["auto", "manual", "strict"]).default("auto").describe("Enforcement level"),
|
|
2386
|
+
delegated_scopes: z.array(z.string()).default([]).describe("Scopes to delegate"),
|
|
2387
|
+
spend_limit: z.number().default(1000).describe("Maximum spend allowed"),
|
|
2388
|
+
}) }, async (_args) => movedToGateway("create_agent_context"));
|
|
2389
|
+
server.registerTool("execute_with_context", { description: "[deprecated in v3.0.0 — use gateway.aeoess.com REST API] Execute an action through the enforcement context.", inputSchema: z.object({
|
|
2390
|
+
action_type: z.string().describe("Action type (e.g. 'api:fetch', 'data:write', 'commerce:checkout')"),
|
|
2391
|
+
target: z.string().describe("Target of the action (e.g. URL, file path, resource ID)"),
|
|
2392
|
+
scope: z.string().describe("Required scope for this action (must match a delegated scope)"),
|
|
2393
|
+
estimated_spend: z.number().optional().describe("Estimated spend for commerce actions"),
|
|
2394
|
+
}) }, async (_args) => movedToGateway("execute_with_context"));
|
|
2395
|
+
server.registerTool("complete_action", { description: "[deprecated in v3.0.0 — use gateway.aeoess.com REST API] Complete a permitted action and get the full 3-signature proof chain.", inputSchema: z.object({
|
|
2396
|
+
intent_id: z.string().describe("Intent ID from execute_with_context result"),
|
|
2397
|
+
status: z.enum(["success", "failure", "partial"]).describe("Outcome of the action"),
|
|
2398
|
+
summary: z.string().describe("Brief description of what was accomplished"),
|
|
2399
|
+
}) }, async (_args) => movedToGateway("complete_action"));
|
|
2395
2400
|
// ═══════════════════════════════════════
|
|
2396
2401
|
// PRINCIPAL IDENTITY TOOLS
|
|
2397
2402
|
// ═══════════════════════════════════════
|
|
2398
|
-
server.
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
}, async (args) => {
|
|
2403
|
+
server.registerTool("create_principal", { description: "Create a principal identity (human or org behind agents). Gets its own Ed25519 keypair.", inputSchema: z.object({
|
|
2404
|
+
display_name: z.string().describe("Human-readable name (e.g. 'Tima', 'Acme Corp')"),
|
|
2405
|
+
domain: z.string().optional().describe("Verifiable domain (e.g. 'aeoess.com')"),
|
|
2406
|
+
jurisdiction: z.string().optional().describe("Legal jurisdiction (e.g. 'US', 'EU')"),
|
|
2407
|
+
contact_channel: z.string().optional().describe("Contact method (e.g. 'telegram:@aeoess')"),
|
|
2408
|
+
disclosure_level: z.enum(["public", "verified-only", "minimal"]).default("public").describe("How much identity to reveal"),
|
|
2409
|
+
}) }, async (args) => {
|
|
2405
2410
|
const { principal, keyPair } = createPrincipalIdentity({
|
|
2406
2411
|
displayName: args.display_name,
|
|
2407
2412
|
domain: args.domain,
|
|
@@ -2427,13 +2432,13 @@ server.tool("create_principal", "Create a principal identity (human or org behin
|
|
|
2427
2432
|
}],
|
|
2428
2433
|
};
|
|
2429
2434
|
});
|
|
2430
|
-
server.
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
}, async (args) => {
|
|
2435
|
+
server.registerTool("endorse_agent", { description: "Endorse an agent as a principal. Creates a cryptographic chain: principal → agent.", inputSchema: z.object({
|
|
2436
|
+
agent_id: z.string().describe("Agent ID to endorse"),
|
|
2437
|
+
agent_public_key: z.string().describe("Agent's Ed25519 public key"),
|
|
2438
|
+
scope: z.array(z.string()).describe("What the agent can do on principal's behalf"),
|
|
2439
|
+
relationship: z.enum(["creator", "operator", "employer", "sponsor"]).describe("How principal relates to agent"),
|
|
2440
|
+
expires_in_days: z.number().default(365).describe("Days until endorsement expires"),
|
|
2441
|
+
}) }, async (args) => {
|
|
2437
2442
|
recordBehavior('endorse_agent');
|
|
2438
2443
|
// Consilium signal #5: endorsement latency. T+200ms = automation. T+3h = human.
|
|
2439
2444
|
const issuedAt = state.issuanceTimestamps.get(args.agent_id);
|
|
@@ -2471,9 +2476,9 @@ server.tool("endorse_agent", "Endorse an agent as a principal. Creates a cryptog
|
|
|
2471
2476
|
}],
|
|
2472
2477
|
};
|
|
2473
2478
|
});
|
|
2474
|
-
server.
|
|
2475
|
-
|
|
2476
|
-
}, async (args) => {
|
|
2479
|
+
server.registerTool("verify_endorsement", { description: "Verify a principal's endorsement of an agent. Checks cryptographic signature.", inputSchema: z.object({
|
|
2480
|
+
endorsement_id: z.string().describe("Endorsement ID to verify"),
|
|
2481
|
+
}) }, async (args) => {
|
|
2477
2482
|
const endorsement = state.endorsements.get(args.endorsement_id);
|
|
2478
2483
|
if (!endorsement) {
|
|
2479
2484
|
return { content: [{ type: "text", text: `Endorsement ${args.endorsement_id} not found in session.` }], isError: true };
|
|
@@ -2493,10 +2498,10 @@ server.tool("verify_endorsement", "Verify a principal's endorsement of an agent.
|
|
|
2493
2498
|
}],
|
|
2494
2499
|
};
|
|
2495
2500
|
});
|
|
2496
|
-
server.
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
}, async (args) => {
|
|
2501
|
+
server.registerTool("revoke_endorsement", { description: "Revoke a principal's endorsement of an agent. 'I no longer authorize this agent.'", inputSchema: z.object({
|
|
2502
|
+
endorsement_id: z.string().describe("Endorsement ID to revoke"),
|
|
2503
|
+
reason: z.string().describe("Why the endorsement is being revoked"),
|
|
2504
|
+
}) }, async (args) => {
|
|
2500
2505
|
const endorsement = state.endorsements.get(args.endorsement_id);
|
|
2501
2506
|
if (!endorsement) {
|
|
2502
2507
|
return { content: [{ type: "text", text: `Endorsement ${args.endorsement_id} not found.` }], isError: true };
|
|
@@ -2519,9 +2524,9 @@ server.tool("revoke_endorsement", "Revoke a principal's endorsement of an agent.
|
|
|
2519
2524
|
}],
|
|
2520
2525
|
};
|
|
2521
2526
|
});
|
|
2522
|
-
server.
|
|
2523
|
-
|
|
2524
|
-
}, async (args) => {
|
|
2527
|
+
server.registerTool("create_disclosure", { description: "Create a selective disclosure of principal identity. Controls how much info is revealed.", inputSchema: z.object({
|
|
2528
|
+
level: z.enum(["public", "verified-only", "minimal"]).describe("Disclosure level: public (everything), verified-only (id+key+domain), minimal (hash+DID only)"),
|
|
2529
|
+
}) }, async (args) => {
|
|
2525
2530
|
if (!state.principal || !state.principalPrivateKey) {
|
|
2526
2531
|
return { content: [{ type: "text", text: 'No principal identity. Call create_principal first.' }], isError: true };
|
|
2527
2532
|
}
|
|
@@ -2539,7 +2544,7 @@ server.tool("create_disclosure", "Create a selective disclosure of principal ide
|
|
|
2539
2544
|
}],
|
|
2540
2545
|
};
|
|
2541
2546
|
});
|
|
2542
|
-
server.
|
|
2547
|
+
server.registerTool("get_fleet_status", { description: "Get status of all agents endorsed by the current principal.", inputSchema: z.object({}) }, async () => {
|
|
2543
2548
|
if (!state.fleet) {
|
|
2544
2549
|
return { content: [{ type: "text", text: 'No fleet. Call create_principal first.' }], isError: true };
|
|
2545
2550
|
}
|
|
@@ -2559,11 +2564,11 @@ function resolveTier(score, demotionCount = 0) {
|
|
|
2559
2564
|
const def = resolveAuthorityTier(score, demotionCount, DEFAULT_TIERS);
|
|
2560
2565
|
return { ...def, origin: 'earned', demotionCount };
|
|
2561
2566
|
}
|
|
2562
|
-
server.
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
}, async ({ agentId, principalId, scope }) => {
|
|
2567
|
+
server.registerTool("resolve_authority", { description: "Compute effective reputation score and authority tier for an agent in a given scope. Returns tier name, autonomy level, spend limit, and effective score.", inputSchema: z.object({
|
|
2568
|
+
agentId: z.string().describe("Agent ID to check"),
|
|
2569
|
+
principalId: z.string().describe("Principal who delegated authority"),
|
|
2570
|
+
scope: z.string().describe("Scope to check reputation in (e.g. 'code_execution', 'commerce')"),
|
|
2571
|
+
}) }, async ({ agentId, principalId, scope }) => {
|
|
2567
2572
|
const key = `${principalId}:${agentId}:${scope}`;
|
|
2568
2573
|
let rep = state.reputations.get(key);
|
|
2569
2574
|
if (!rep) {
|
|
@@ -2588,14 +2593,14 @@ server.tool("resolve_authority", "Compute effective reputation score and authori
|
|
|
2588
2593
|
}],
|
|
2589
2594
|
};
|
|
2590
2595
|
});
|
|
2591
|
-
server.
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
}, async ({ agentId, principalId, scope, requestedAutonomy, requestedSpend, requestedDepth }) => {
|
|
2596
|
+
server.registerTool("check_tier", { description: "Check if an agent's earned tier permits an action at a given autonomy level and spend amount. Returns null if permitted, or escalation details if tier is insufficient.", inputSchema: z.object({
|
|
2597
|
+
agentId: z.string().describe("Agent ID"),
|
|
2598
|
+
principalId: z.string().describe("Principal ID"),
|
|
2599
|
+
scope: z.string().describe("Reputation scope"),
|
|
2600
|
+
requestedAutonomy: z.number().optional().describe("Requested autonomy level (1-5)"),
|
|
2601
|
+
requestedSpend: z.number().optional().describe("Requested spend amount in dollars"),
|
|
2602
|
+
requestedDepth: z.number().optional().describe("Requested delegation depth"),
|
|
2603
|
+
}) }, async ({ agentId, principalId, scope, requestedAutonomy, requestedSpend, requestedDepth }) => {
|
|
2599
2604
|
const key = `${principalId}:${agentId}:${scope}`;
|
|
2600
2605
|
let rep = state.reputations.get(key);
|
|
2601
2606
|
if (!rep) {
|
|
@@ -2630,15 +2635,15 @@ server.tool("check_tier", "Check if an agent's earned tier permits an action at
|
|
|
2630
2635
|
}],
|
|
2631
2636
|
};
|
|
2632
2637
|
});
|
|
2633
|
-
server.
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
}, async ({ agentId, principalId, scope, toTier, verdict, reasoning, probationDays }) => {
|
|
2638
|
+
server.registerTool("review_promotion", { description: "Create a signed promotion review for another agent. Reviewer must have 'earned' origin and tier above target. Returns signed review artifact.", inputSchema: z.object({
|
|
2639
|
+
agentId: z.string().describe("Agent being reviewed for promotion"),
|
|
2640
|
+
principalId: z.string().describe("Principal who delegated to the agent"),
|
|
2641
|
+
scope: z.string().describe("Scope of the promotion"),
|
|
2642
|
+
toTier: z.number().describe("Target tier level (0-4)"),
|
|
2643
|
+
verdict: z.enum(['promoted', 'denied']).describe("Promotion verdict"),
|
|
2644
|
+
reasoning: z.string().describe("Explanation for the verdict"),
|
|
2645
|
+
probationDays: z.number().optional().describe("Probation period in days (default: 7)"),
|
|
2646
|
+
}) }, async ({ agentId, principalId, scope, toTier, verdict, reasoning, probationDays }) => {
|
|
2642
2647
|
if (!state.privateKey || !state.agentId) {
|
|
2643
2648
|
return { content: [{ type: "text", text: 'Identity required. Call identify or set AGENT_KEY first.' }], isError: true };
|
|
2644
2649
|
}
|
|
@@ -2697,13 +2702,13 @@ server.tool("review_promotion", "Create a signed promotion review for another ag
|
|
|
2697
2702
|
return { content: [{ type: "text", text: safeError("Promotion review failed", err) }], isError: true };
|
|
2698
2703
|
}
|
|
2699
2704
|
});
|
|
2700
|
-
server.
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
}, async ({ agentId, principalId, scope, success, evidenceClass }) => {
|
|
2705
|
+
server.registerTool("update_reputation", { description: "Update an agent's reputation after a task result. Success increases mu and decreases sigma; failure does the opposite. Higher evidence class = larger effect.", inputSchema: z.object({
|
|
2706
|
+
agentId: z.string().describe("Agent whose reputation to update"),
|
|
2707
|
+
principalId: z.string().describe("Principal ID"),
|
|
2708
|
+
scope: z.string().describe("Reputation scope"),
|
|
2709
|
+
success: z.boolean().describe("Whether the task succeeded"),
|
|
2710
|
+
evidenceClass: z.enum(['trivial', 'standard', 'complex', 'critical']).describe("Complexity of the task"),
|
|
2711
|
+
}) }, async ({ agentId, principalId, scope, success, evidenceClass }) => {
|
|
2707
2712
|
const key = `${principalId}:${agentId}:${scope}`;
|
|
2708
2713
|
let rep = state.reputations.get(key);
|
|
2709
2714
|
if (!rep) {
|
|
@@ -2728,7 +2733,7 @@ server.tool("update_reputation", "Update an agent's reputation after a task resu
|
|
|
2728
2733
|
}],
|
|
2729
2734
|
};
|
|
2730
2735
|
});
|
|
2731
|
-
server.
|
|
2736
|
+
server.registerTool("get_promotion_history", { description: "Get the promotion review history for this session.", inputSchema: z.object({}) }, async () => {
|
|
2732
2737
|
return {
|
|
2733
2738
|
content: [{
|
|
2734
2739
|
type: "text",
|
|
@@ -2746,28 +2751,28 @@ server.tool("get_promotion_history", "Get the promotion review history for this
|
|
|
2746
2751
|
// was built on (delegation verification, policy evaluation, replay nonces)
|
|
2747
2752
|
// remain in the SDK — rebuild a gateway locally from those, or use the
|
|
2748
2753
|
// hosted gateway at gateway.aeoess.com.
|
|
2749
|
-
server.
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
}, async (_args) => movedToGateway("create_gateway"));
|
|
2754
|
-
server.
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
}, async (_args) => movedToGateway("gateway_process_tool_call"));
|
|
2763
|
-
server.
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
}, async (_args) => movedToGateway("gateway_approve"));
|
|
2770
|
-
server.
|
|
2754
|
+
server.registerTool("create_gateway", { description: "[deprecated in v3.0.0 — use gateway.aeoess.com REST API] Create a ProxyGateway enforcement boundary.", inputSchema: z.object({
|
|
2755
|
+
gatewayId: z.string().optional().describe("Custom gateway ID"),
|
|
2756
|
+
approvalTTLSeconds: z.number().optional().describe("Two-phase approval timeout"),
|
|
2757
|
+
maxPendingPerAgent: z.number().optional().describe("Max pending approvals per agent"),
|
|
2758
|
+
}) }, async (_args) => movedToGateway("create_gateway"));
|
|
2759
|
+
server.registerTool("gateway_process_tool_call", { description: "[deprecated in v3.0.0 — use gateway.aeoess.com REST API] Process a tool call through the gateway enforcement boundary.", inputSchema: z.object({
|
|
2760
|
+
agentId: z.string(),
|
|
2761
|
+
tool: z.string(),
|
|
2762
|
+
params: z.record(z.string(), z.unknown()).optional(),
|
|
2763
|
+
scopeRequired: z.string(),
|
|
2764
|
+
spendAmount: z.number().optional(),
|
|
2765
|
+
spendCurrency: z.string().optional(),
|
|
2766
|
+
context: z.string().optional(),
|
|
2767
|
+
}) }, async (_args) => movedToGateway("gateway_process_tool_call"));
|
|
2768
|
+
server.registerTool("gateway_approve", { description: "[deprecated in v3.0.0 — use gateway.aeoess.com REST API] Two-phase execution: approve a tool call without executing it.", inputSchema: z.object({
|
|
2769
|
+
agentId: z.string(),
|
|
2770
|
+
tool: z.string(),
|
|
2771
|
+
params: z.record(z.string(), z.unknown()).optional(),
|
|
2772
|
+
scopeRequired: z.string(),
|
|
2773
|
+
context: z.string().optional(),
|
|
2774
|
+
}) }, async (_args) => movedToGateway("gateway_approve"));
|
|
2775
|
+
server.registerTool("gateway_stats", { description: "[deprecated in v3.0.0 — use gateway.aeoess.com REST API] Get gateway statistics.", inputSchema: z.object({}) }, async (_args) => movedToGateway("gateway_stats"));
|
|
2771
2776
|
// ═══════════════════════════════════════
|
|
2772
2777
|
// Intent Network (Agent-Mediated Matching)
|
|
2773
2778
|
// Calls the hosted API at api.aeoess.com
|
|
@@ -2783,11 +2788,11 @@ async function intentApiFetch(path, opts) {
|
|
|
2783
2788
|
// publish_intent_card removed in v3.0.0: createIntentCard was gateway-side
|
|
2784
2789
|
// signing glue. Cards are still publishable directly via the Intent Network
|
|
2785
2790
|
// REST API at api.aeoess.com/api/cards — sign with your agent private key.
|
|
2786
|
-
server.
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
}, async (args) => {
|
|
2791
|
+
server.registerTool("search_matches", { description: "Search the Intent Network for people relevant to you. Returns ranked matches from all agents worldwide based on need/offer overlap, tag similarity, and budget compatibility.", inputSchema: z.object({
|
|
2792
|
+
min_score: z.number().optional().describe("Minimum relevance score 0-1 (default: 0.1)"),
|
|
2793
|
+
max_results: z.number().optional().describe("Maximum results to return (default: 10)"),
|
|
2794
|
+
category_filter: z.string().optional().describe("Only match within this category"),
|
|
2795
|
+
}) }, async (args) => {
|
|
2791
2796
|
const keyErr = requireKey();
|
|
2792
2797
|
if (keyErr)
|
|
2793
2798
|
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
@@ -2828,7 +2833,7 @@ server.tool("search_matches", "Search the Intent Network for people relevant to
|
|
|
2828
2833
|
return { content: [{ type: "text", text: safeError("API error", e) }], isError: true };
|
|
2829
2834
|
}
|
|
2830
2835
|
});
|
|
2831
|
-
server.
|
|
2836
|
+
server.registerTool("get_digest", { description: "Get a personalized digest from the Intent Network: relevant matches, pending intro requests, and incoming intros. The killer feature — 'what matters to me right now?'", inputSchema: z.object({}) }, async () => {
|
|
2832
2837
|
const agentId = state.agentId || 'anonymous';
|
|
2833
2838
|
try {
|
|
2834
2839
|
const digest = await intentApiFetch(`/api/digest/${agentId}`);
|
|
@@ -2867,12 +2872,12 @@ server.tool("get_digest", "Get a personalized digest from the Intent Network: re
|
|
|
2867
2872
|
return { content: [{ type: "text", text: safeError("API error", e) }], isError: true };
|
|
2868
2873
|
}
|
|
2869
2874
|
});
|
|
2870
|
-
server.
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
}, async (args) => {
|
|
2875
|
+
server.registerTool("request_intro", { description: "Request an introduction to another agent's human based on a match. Both sides must approve before real information crosses.", inputSchema: z.object({
|
|
2876
|
+
match_id: z.string().describe("Match ID from search_matches"),
|
|
2877
|
+
target_card_id: z.string().describe("Card ID of the agent you want an intro to"),
|
|
2878
|
+
message: z.string().describe("Brief message explaining why this intro would be valuable"),
|
|
2879
|
+
disclose_fields: z.array(z.string()).optional().describe("Fields you're willing to share (e.g. ['needs', 'offers', 'openTo'])"),
|
|
2880
|
+
}) }, async (args) => {
|
|
2876
2881
|
const keyErr = requireKey();
|
|
2877
2882
|
if (keyErr)
|
|
2878
2883
|
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
@@ -2908,12 +2913,12 @@ server.tool("request_intro", "Request an introduction to another agent's human b
|
|
|
2908
2913
|
return { content: [{ type: "text", text: safeError("Intro request failed", e) }], isError: true };
|
|
2909
2914
|
}
|
|
2910
2915
|
});
|
|
2911
|
-
server.
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
}, async (args) => {
|
|
2916
|
+
server.registerTool("respond_to_intro", { description: "Respond to an introduction request. Approve to share your disclosed information, or decline.", inputSchema: z.object({
|
|
2917
|
+
intro_id: z.string().describe("Intro request ID"),
|
|
2918
|
+
approved: z.boolean().describe("Whether to approve the introduction"),
|
|
2919
|
+
message: z.string().optional().describe("Optional response message"),
|
|
2920
|
+
disclose_fields: z.array(z.string()).optional().describe("Fields you're willing to share back"),
|
|
2921
|
+
}) }, async (args) => {
|
|
2917
2922
|
const keyErr = requireKey();
|
|
2918
2923
|
if (keyErr)
|
|
2919
2924
|
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
@@ -2950,9 +2955,9 @@ server.tool("respond_to_intro", "Respond to an introduction request. Approve to
|
|
|
2950
2955
|
return { content: [{ type: "text", text: safeError("Intro response failed", e) }], isError: true };
|
|
2951
2956
|
}
|
|
2952
2957
|
});
|
|
2953
|
-
server.
|
|
2954
|
-
|
|
2955
|
-
}, async (args) => {
|
|
2958
|
+
server.registerTool("remove_intent_card", { description: "Remove your IntentCard from the Intent Network. Use when your needs or offers have changed.", inputSchema: z.object({
|
|
2959
|
+
card_id: z.string().describe("Card ID to remove"),
|
|
2960
|
+
}) }, async (args) => {
|
|
2956
2961
|
const keyErr = requireKey();
|
|
2957
2962
|
if (keyErr)
|
|
2958
2963
|
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
@@ -2983,12 +2988,12 @@ server.tool("remove_intent_card", "Remove your IntentCard from the Intent Networ
|
|
|
2983
2988
|
// ═══════════════════════════════════════
|
|
2984
2989
|
// v2: Constitutional Governance Tools
|
|
2985
2990
|
// ═══════════════════════════════════════
|
|
2986
|
-
server.
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
}, async (args) => {
|
|
2991
|
+
server.registerTool("create_policy_context", { description: "Create a v2 PolicyContext with mandatory sunset. Every v2 object requires one.", inputSchema: z.object({
|
|
2992
|
+
policy_version: z.string().default("2.0.0"),
|
|
2993
|
+
values_floor_version: z.string().default("1.0.0"),
|
|
2994
|
+
trust_epoch: z.number().default(1),
|
|
2995
|
+
valid_until: z.string().describe("ISO 8601 expiration (mandatory, max 180 days)"),
|
|
2996
|
+
}) }, async (args) => {
|
|
2992
2997
|
const keyErr = requireKey();
|
|
2993
2998
|
if (keyErr)
|
|
2994
2999
|
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
@@ -3006,12 +3011,12 @@ server.tool("create_policy_context", "Create a v2 PolicyContext with mandatory s
|
|
|
3006
3011
|
return { content: [{ type: "text", text: safeError("PolicyContext creation failed", e) }], isError: true };
|
|
3007
3012
|
}
|
|
3008
3013
|
});
|
|
3009
|
-
server.
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
}, async (args) => {
|
|
3014
|
+
server.registerTool("create_v2_delegation", { description: "Create a v2 delegation with versioning, mandatory sunset, and PolicyContext binding.", inputSchema: z.object({
|
|
3015
|
+
delegatee: z.string().describe("Public key of the agent receiving authority"),
|
|
3016
|
+
scope_categories: z.array(z.string()).describe("Action categories (e.g., ['analysis', 'communication'])"),
|
|
3017
|
+
valid_until: z.string().describe("ISO 8601 expiration"),
|
|
3018
|
+
trust_epoch: z.number().default(1),
|
|
3019
|
+
}) }, async (args) => {
|
|
3015
3020
|
const keyErr = requireKey();
|
|
3016
3021
|
if (keyErr)
|
|
3017
3022
|
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
@@ -3032,15 +3037,15 @@ server.tool("create_v2_delegation", "Create a v2 delegation with versioning, man
|
|
|
3032
3037
|
return { content: [{ type: "text", text: safeError("v2 delegation failed", e) }], isError: true };
|
|
3033
3038
|
}
|
|
3034
3039
|
});
|
|
3035
|
-
server.
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
}, async (args) => {
|
|
3040
|
+
server.registerTool("supersede_v2_delegation", { description: "Supersede a v2 delegation. Scope narrowing needs justification. Scope expansion also needs independent reviewer.", inputSchema: z.object({
|
|
3041
|
+
original_delegation_id: z.string(),
|
|
3042
|
+
new_scope_categories: z.array(z.string()),
|
|
3043
|
+
justification: z.string(),
|
|
3044
|
+
valid_until: z.string(),
|
|
3045
|
+
trust_epoch: z.number().default(1),
|
|
3046
|
+
expansion_reviewer: z.string().optional().describe("Required if scope expands"),
|
|
3047
|
+
expansion_reviewer_private_key: z.string().optional(),
|
|
3048
|
+
}) }, async (args) => {
|
|
3044
3049
|
const keyErr = requireKey();
|
|
3045
3050
|
if (keyErr)
|
|
3046
3051
|
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
@@ -3064,15 +3069,15 @@ server.tool("supersede_v2_delegation", "Supersede a v2 delegation. Scope narrowi
|
|
|
3064
3069
|
return { content: [{ type: "text", text: safeError("Supersession failed", e) }], isError: true };
|
|
3065
3070
|
}
|
|
3066
3071
|
});
|
|
3067
|
-
server.
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
}, async (args) => {
|
|
3072
|
+
server.registerTool("create_outcome_record", { description: "Register an action outcome (agent perspective). Part of three-way reporting.", inputSchema: z.object({
|
|
3073
|
+
action_id: z.string(), declared_intent: z.string(),
|
|
3074
|
+
semantic_uncertainty: z.enum(["low", "medium", "high", "critical"]),
|
|
3075
|
+
observed_outcome: z.string(),
|
|
3076
|
+
outcome_class: z.enum(["success", "partial_success", "failure", "unintended_effect", "unknown"]),
|
|
3077
|
+
divergence_score: z.number().min(0).max(1),
|
|
3078
|
+
valid_until: z.string(),
|
|
3079
|
+
trust_epoch: z.number().default(1),
|
|
3080
|
+
}) }, async (args) => {
|
|
3076
3081
|
const keyErr = requireKey();
|
|
3077
3082
|
if (keyErr)
|
|
3078
3083
|
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
@@ -3098,11 +3103,11 @@ server.tool("create_outcome_record", "Register an action outcome (agent perspect
|
|
|
3098
3103
|
return { content: [{ type: "text", text: safeError("Outcome registration failed", e) }], isError: true };
|
|
3099
3104
|
}
|
|
3100
3105
|
});
|
|
3101
|
-
server.
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
}, async (args) => {
|
|
3106
|
+
server.registerTool("add_principal_report", { description: "Add principal's perspective to an outcome record. Enables three-way divergence reporting.", inputSchema: z.object({
|
|
3107
|
+
outcome_id: z.string(), observed_outcome: z.string(),
|
|
3108
|
+
outcome_class: z.enum(["success", "partial_success", "failure", "unintended_effect", "unknown"]),
|
|
3109
|
+
divergence_score: z.number().min(0).max(1),
|
|
3110
|
+
}) }, async (args) => {
|
|
3106
3111
|
const keyErr = requireKey();
|
|
3107
3112
|
if (keyErr)
|
|
3108
3113
|
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
@@ -3120,16 +3125,16 @@ server.tool("add_principal_report", "Add principal's perspective to an outcome r
|
|
|
3120
3125
|
return { content: [{ type: "text", text: safeError("Principal report failed", e) }], isError: true };
|
|
3121
3126
|
}
|
|
3122
3127
|
});
|
|
3123
|
-
server.
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
}, async (args) => {
|
|
3128
|
+
server.registerTool("define_emergency_pathway", { description: "Define a pre-authorized emergency pathway at delegation time. Only the delegator can define these.", inputSchema: z.object({
|
|
3129
|
+
delegation_ref: z.string(), description: z.string(),
|
|
3130
|
+
trigger_field: z.string(), trigger_operator: z.enum(["eq", "neq", "gt", "lt", "gte", "lte"]),
|
|
3131
|
+
trigger_value: z.union([z.string(), z.number(), z.boolean()]),
|
|
3132
|
+
expanded_scope_categories: z.array(z.string()),
|
|
3133
|
+
max_duration: z.string().default("PT1H"),
|
|
3134
|
+
review_deadline: z.string().default("PT24H"),
|
|
3135
|
+
review_authority: z.string(),
|
|
3136
|
+
valid_until: z.string(), trust_epoch: z.number().default(1),
|
|
3137
|
+
}) }, async (args) => {
|
|
3133
3138
|
const keyErr = requireKey();
|
|
3134
3139
|
if (keyErr)
|
|
3135
3140
|
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
@@ -3153,11 +3158,11 @@ server.tool("define_emergency_pathway", "Define a pre-authorized emergency pathw
|
|
|
3153
3158
|
return { content: [{ type: "text", text: safeError("Emergency pathway failed", e) }], isError: true };
|
|
3154
3159
|
}
|
|
3155
3160
|
});
|
|
3156
|
-
server.
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
}, async (args) => {
|
|
3161
|
+
server.registerTool("activate_emergency", { description: "Activate a pre-authorized emergency pathway with evidence.", inputSchema: z.object({
|
|
3162
|
+
pathway_id: z.string(),
|
|
3163
|
+
trigger_evidence: z.string().describe("Evidence that trigger conditions are met"),
|
|
3164
|
+
valid_until: z.string(), trust_epoch: z.number().default(1),
|
|
3165
|
+
}) }, async (args) => {
|
|
3161
3166
|
const keyErr = requireKey();
|
|
3162
3167
|
if (keyErr)
|
|
3163
3168
|
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
@@ -3184,14 +3189,14 @@ server.tool("activate_emergency", "Activate a pre-authorized emergency pathway w
|
|
|
3184
3189
|
// remains in the SDK for direct use.
|
|
3185
3190
|
// request_migration removed in v3.0.0: requestV2Migration / approveV2Migration /
|
|
3186
3191
|
// executeV2Migration were gateway-side migration orchestration.
|
|
3187
|
-
server.
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
}, async (args) => {
|
|
3192
|
+
server.registerTool("create_artifact_provenance", { description: "Tag an agent-generated artifact with provenance metadata (content hash, risk class, authoring agent).", inputSchema: z.object({
|
|
3193
|
+
delegation_ref: z.string(), intended_use: z.string(),
|
|
3194
|
+
risk_class: z.enum(["low", "medium", "high", "critical"]),
|
|
3195
|
+
requires_human_execution: z.boolean().default(false),
|
|
3196
|
+
content: z.string().describe("The artifact content (used for hash, not stored)"),
|
|
3197
|
+
artifact_type: z.string().describe("e.g. email_draft, code_script, database_query"),
|
|
3198
|
+
valid_until: z.string(), trust_epoch: z.number().default(1),
|
|
3199
|
+
}) }, async (args) => {
|
|
3195
3200
|
const keyErr = requireKey();
|
|
3196
3201
|
if (keyErr)
|
|
3197
3202
|
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
@@ -3223,18 +3228,18 @@ server.tool("create_artifact_provenance", "Tag an agent-generated artifact with
|
|
|
3223
3228
|
// ═══════════════════════════════════════
|
|
3224
3229
|
// Data Governance Tools (Modules 36A, 38, 39)
|
|
3225
3230
|
// ═══════════════════════════════════════
|
|
3226
|
-
server.
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
}, async (p) => {
|
|
3231
|
+
server.registerTool("register_data_source", { description: "Register a data source with terms for agent access. Returns a signed SourceReceipt.", inputSchema: z.object({
|
|
3232
|
+
contentDescriptor: z.string().describe("Human-readable description of the data"),
|
|
3233
|
+
contentCommitment: z.string().describe("SHA-256 hash of the data content"),
|
|
3234
|
+
contentType: z.enum(["document", "structured_data", "media", "user_input", "model_context"]).describe("Type of data"),
|
|
3235
|
+
allowedPurposes: z.array(z.string()).describe("Allowed purposes: read, analyze, summarize, generate, recommend, train, embed, redistribute, commercial"),
|
|
3236
|
+
requireAttribution: z.boolean().default(true),
|
|
3237
|
+
compensationType: z.enum(["none", "attribution_only", "per_access", "negotiate"]).default("none"),
|
|
3238
|
+
compensationAmount: z.number().optional().describe("Amount per access (for per_access type)"),
|
|
3239
|
+
compensationCurrency: z.string().default("usd"),
|
|
3240
|
+
maxAccessCount: z.number().optional().describe("Max total accesses allowed"),
|
|
3241
|
+
derivativePolicy: z.enum(["unrestricted", "same_terms", "attribution_required", "no_derivatives"]).default("attribution_required"),
|
|
3242
|
+
}) }, async (p) => {
|
|
3238
3243
|
if (!state.agentKey || !state.privateKey)
|
|
3239
3244
|
return { content: [{ type: "text", text: "❌ Not identified. Call identify first." }] };
|
|
3240
3245
|
const comp = p.compensationType === 'per_access'
|
|
@@ -3264,21 +3269,21 @@ server.tool("register_data_source", "Register a data source with terms for agent
|
|
|
3264
3269
|
state.sourceReceipts.set(receipt.sourceReceiptId, receipt);
|
|
3265
3270
|
return { content: [{ type: "text", text: `✅ Data source registered.\n\nSource Receipt ID: ${receipt.sourceReceiptId}\nDescriptor: ${p.contentDescriptor}\nAllowed purposes: ${p.allowedPurposes.join(', ')}\nCompensation: ${p.compensationType}${p.compensationAmount ? ' $' + p.compensationAmount : ''}\nMax accesses: ${p.maxAccessCount || 'unlimited'}\nDerivative policy: ${p.derivativePolicy}` }] };
|
|
3266
3271
|
});
|
|
3267
|
-
server.
|
|
3268
|
-
|
|
3269
|
-
}, async (_args) => movedToGateway("create_data_enforcement_gate"));
|
|
3270
|
-
server.
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
}, async (_args) => movedToGateway("query_contributions"));
|
|
3277
|
-
server.
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
}, async (_args) => movedToGateway("generate_settlement"));
|
|
3272
|
+
server.registerTool("create_data_enforcement_gate", { description: "[deprecated in v3.0.0 — use gateway.aeoess.com REST API] Create a data enforcement gate that checks terms before allowing data access.", inputSchema: z.object({
|
|
3273
|
+
mode: z.enum(["enforce", "audit", "off"]).default("enforce").describe("Enforcement mode"),
|
|
3274
|
+
}) }, async (_args) => movedToGateway("create_data_enforcement_gate"));
|
|
3275
|
+
server.registerTool("query_contributions", { description: "[deprecated in v3.0.0 — use gateway.aeoess.com REST API] Query the data contribution ledger.", inputSchema: z.object({
|
|
3276
|
+
sourceReceiptId: z.string().optional(),
|
|
3277
|
+
agentId: z.string().optional(),
|
|
3278
|
+
principalId: z.string().optional(),
|
|
3279
|
+
purpose: z.string().optional(),
|
|
3280
|
+
minAccessCount: z.number().optional(),
|
|
3281
|
+
}) }, async (_args) => movedToGateway("query_contributions"));
|
|
3282
|
+
server.registerTool("generate_settlement", { description: "[deprecated in v3.0.0 — use gateway.aeoess.com REST API] Generate a Merkle-committed, signed settlement record for a period.", inputSchema: z.object({
|
|
3283
|
+
startDate: z.string().describe("Period start (YYYY-MM-DD)"),
|
|
3284
|
+
endDate: z.string().describe("Period end (YYYY-MM-DD)"),
|
|
3285
|
+
periodLabel: z.string().describe("Label (e.g. '2026-Q1', '2026-03')"),
|
|
3286
|
+
}) }, async (_args) => movedToGateway("generate_settlement"));
|
|
3282
3287
|
// Removed in v3.0.0 (moved to gateway product — no stub to keep tool count bounded):
|
|
3283
3288
|
// check_data_access (DataEnforcementGate.checkAccess)
|
|
3284
3289
|
// get_source_metrics (cross-agent ledger aggregation)
|
|
@@ -3292,22 +3297,22 @@ server.tool("generate_settlement", "[deprecated in v3.0.0 — use gateway.aeoess
|
|
|
3292
3297
|
// ═══════════════════════════════════════
|
|
3293
3298
|
// Data Lifecycle Governance Tools
|
|
3294
3299
|
// ═══════════════════════════════════════
|
|
3295
|
-
server.
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
}, async (p) => {
|
|
3300
|
+
server.registerTool("create_derivation_receipt", { description: "Create a signed derivation receipt tracking how data was transformed. Multi-hop lineage with break markers.", inputSchema: z.object({
|
|
3301
|
+
derivativeId: z.string().describe("Unique ID for the derivative artifact"),
|
|
3302
|
+
derivativeType: z.string().describe("Type: rag_chunk, embedding, summary, model_weights, synthetic_derivative, etc."),
|
|
3303
|
+
parentArtifacts: z.array(z.object({
|
|
3304
|
+
artifactId: z.string(),
|
|
3305
|
+
artifactType: z.string(),
|
|
3306
|
+
sourceId: z.string().optional(),
|
|
3307
|
+
transformFromParent: z.string().optional(),
|
|
3308
|
+
})).describe("Parent artifacts this was derived from"),
|
|
3309
|
+
transformClass: z.string().describe("Transform type: copy, subset, summary, embedding, aggregation, synthetic, model_training"),
|
|
3310
|
+
lineageConfidence: z.enum(["complete", "partial", "asserted", "inferred", "broken_external", "unverifiable"]),
|
|
3311
|
+
externalBoundaryBreak: z.boolean().optional().describe("True if data left the system and returned"),
|
|
3312
|
+
breakReason: z.string().optional(),
|
|
3313
|
+
isSyntheticDerivative: z.boolean().optional(),
|
|
3314
|
+
upstreamObligationsRetained: z.boolean().optional(),
|
|
3315
|
+
}) }, async (p) => {
|
|
3311
3316
|
const receipt = createDerivationReceipt({
|
|
3312
3317
|
...p,
|
|
3313
3318
|
agentId: state.agentId || 'unknown',
|
|
@@ -3316,17 +3321,17 @@ server.tool("create_derivation_receipt", "Create a signed derivation receipt tra
|
|
|
3316
3321
|
state.derivationStore.set(receipt.derivativeId, receipt);
|
|
3317
3322
|
return { content: [{ type: "text", text: `✅ Derivation receipt created.\n\nID: ${receipt.receiptId}\nDerivative: ${receipt.derivativeId}\nType: ${receipt.derivativeType}\nTransform: ${receipt.transformClass}\nConfidence: ${receipt.lineageConfidence}\nBoundary break: ${receipt.externalBoundaryBreak}\nSynthetic: ${receipt.isSyntheticDerivative || false}\nParents: ${receipt.parentArtifacts.length}` }] };
|
|
3318
3323
|
});
|
|
3319
|
-
server.
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
}, async (p) => {
|
|
3324
|
+
server.registerTool("resolve_lineage", { description: "Resolve the full derivation chain for an artifact. Multi-hop with cycle detection.", inputSchema: z.object({
|
|
3325
|
+
derivativeId: z.string().describe("ID of the derivative to trace"),
|
|
3326
|
+
maxDepth: z.number().optional().describe("Max chain depth (default: 10)"),
|
|
3327
|
+
}) }, async (p) => {
|
|
3323
3328
|
const result = resolveExtendedLineage(p.derivativeId, state.derivationStore, p.maxDepth);
|
|
3324
3329
|
const chainStr = result.chain.map((r, i) => ` ${i + 1}. ${r.derivativeId} (${r.transformClass}, ${r.lineageConfidence})`).join('\n');
|
|
3325
3330
|
return { content: [{ type: "text", text: `🔗 Lineage for: ${p.derivativeId}\n\nDepth: ${result.depth}\nConfidence: ${result.confidence}\nHas breaks: ${result.hasBreaks}\n\nChain:\n${chainStr || ' (empty)'}` }] };
|
|
3326
3331
|
});
|
|
3327
|
-
server.
|
|
3328
|
-
|
|
3329
|
-
}, async (p) => {
|
|
3332
|
+
server.registerTool("evaluate_revocation_impact", { description: "Evaluate what happens when a data source revokes consent. Propagates obligations through derivation chains.", inputSchema: z.object({
|
|
3333
|
+
sourceId: z.string().describe("Source ID that is revoking consent"),
|
|
3334
|
+
}) }, async (p) => {
|
|
3330
3335
|
const result = evaluateRevocationImpact({
|
|
3331
3336
|
sourceId: p.sourceId,
|
|
3332
3337
|
receiptStore: state.derivationStore,
|
|
@@ -3335,57 +3340,57 @@ server.tool("evaluate_revocation_impact", "Evaluate what happens when a data sou
|
|
|
3335
3340
|
const lines = result.affectedArtifacts.map(a => ` • ${a.artifactId} (${a.artifactType}): ${a.obligation} — ${a.reason}`);
|
|
3336
3341
|
return { content: [{ type: "text", text: `⚠️ Revocation Impact: ${p.sourceId}\n\nObligation ID: ${result.obligationId}\nTotal affected: ${result.totalAffected}\n\nAffected artifacts:\n${lines.join('\n') || ' (none)'}` }] };
|
|
3337
3342
|
});
|
|
3338
|
-
server.
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
}, async (p) => {
|
|
3343
|
+
server.registerTool("create_decision_lineage_receipt", { description: "Create a Decision Lineage Receipt — traces which data sources influenced a decision. Right-to-explanation primitive.", inputSchema: z.object({
|
|
3344
|
+
decisionArtifactId: z.string(),
|
|
3345
|
+
decisionType: z.string().describe("E.g. loan_approval, content_moderation, risk_assessment"),
|
|
3346
|
+
contributingSources: z.array(z.object({
|
|
3347
|
+
sourceId: z.string(),
|
|
3348
|
+
accessReceiptId: z.string(),
|
|
3349
|
+
derivationDepth: z.number(),
|
|
3350
|
+
transformPath: z.array(z.string()),
|
|
3351
|
+
termsVersionAtAccess: z.string(),
|
|
3352
|
+
lineageConfidence: z.enum(["complete", "partial", "asserted", "inferred", "broken_external", "unverifiable"]),
|
|
3353
|
+
compensationStatus: z.enum(["settled", "pending", "disputed", "revoked"]),
|
|
3354
|
+
})),
|
|
3355
|
+
lineageCompleteness: z.enum(["complete", "partial", "asserted", "broken_external"]),
|
|
3356
|
+
transformChain: z.array(z.string()).optional(),
|
|
3357
|
+
governingPurpose: z.string().optional(),
|
|
3358
|
+
explanation: z.string().optional(),
|
|
3359
|
+
}) }, async (p) => {
|
|
3355
3360
|
const receipt = createDecisionLineageReceipt({
|
|
3356
3361
|
...p,
|
|
3357
3362
|
privateKey: state.privateKey,
|
|
3358
3363
|
});
|
|
3359
3364
|
return { content: [{ type: "text", text: `✅ Decision Lineage Receipt created.\n\nID: ${receipt.receiptId}\nDecision: ${receipt.decisionArtifactId}\nType: ${p.decisionType}\nSources: ${receipt.contributingSources.length}\nCompleteness: ${receipt.lineageCompleteness}\nPurpose: ${receipt.governingPurpose || 'N/A'}\nExplanation: ${receipt.explanation || 'N/A'}` }] };
|
|
3360
3365
|
});
|
|
3361
|
-
server.
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
}, async (p) => {
|
|
3366
|
+
server.registerTool("check_purpose_permitted", { description: "Check if a purpose is permitted under source terms. Supports wildcards (research:*) and hierarchical matching.", inputSchema: z.object({
|
|
3367
|
+
purpose: z.string().describe("Purpose to check (e.g. research:academic, training:model)"),
|
|
3368
|
+
allowedPurposes: z.array(z.string()).describe("Purposes allowed by the source terms"),
|
|
3369
|
+
}) }, async (p) => {
|
|
3365
3370
|
const permitted = isPurposePermitted(p.purpose, p.allowedPurposes);
|
|
3366
3371
|
const category = purposeCategory(p.purpose);
|
|
3367
3372
|
return { content: [{ type: "text", text: `${permitted ? '✅' : '❌'} Purpose "${p.purpose}" (category: ${category}) is ${permitted ? 'PERMITTED' : 'NOT PERMITTED'}\n\nAllowed: [${p.allowedPurposes.join(', ')}]` }] };
|
|
3368
3373
|
});
|
|
3369
|
-
server.
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
}, async (p) => {
|
|
3374
|
+
server.registerTool("check_retention_expired", { description: "Check if data retention has expired based on TTL policy.", inputSchema: z.object({
|
|
3375
|
+
accessedAt: z.string().describe("ISO timestamp of when data was accessed"),
|
|
3376
|
+
maxRetentionMs: z.number().nullable().describe("Max retention in ms (null = no limit)"),
|
|
3377
|
+
accessType: z.enum(["ephemeral", "persistent"]).optional(),
|
|
3378
|
+
}) }, async (p) => {
|
|
3374
3379
|
const policy = { maxRetentionMs: p.maxRetentionMs, onExpiry: 'delete' };
|
|
3375
3380
|
const expired = isRetentionExpired(p.accessedAt, policy, p.accessType);
|
|
3376
3381
|
return { content: [{ type: "text", text: `${expired ? '⚠️ EXPIRED' : '✅ VALID'} — Retention check for access at ${p.accessedAt}\n\nMax retention: ${p.maxRetentionMs ? `${p.maxRetentionMs / 3600000}h` : 'unlimited'}\nAccess type: ${p.accessType || 'default'}` }] };
|
|
3377
3382
|
});
|
|
3378
|
-
server.
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
}, async (p) => {
|
|
3383
|
+
server.registerTool("check_aggregate_constraints", { description: "Check if a data access would violate aggregate rate limits.", inputSchema: z.object({
|
|
3384
|
+
maxAccessesPerWindow: z.number().optional(),
|
|
3385
|
+
windowMs: z.number().optional(),
|
|
3386
|
+
burstLimit: z.number().optional(),
|
|
3387
|
+
currentAccessCount: z.number(),
|
|
3388
|
+
currentRecordCount: z.number(),
|
|
3389
|
+
windowStartMs: z.number(),
|
|
3390
|
+
lastAccessMs: z.number(),
|
|
3391
|
+
sourceId: z.string(),
|
|
3392
|
+
agentId: z.string(),
|
|
3393
|
+
}) }, async (p) => {
|
|
3389
3394
|
const constraint = {
|
|
3390
3395
|
maxAccessesPerWindow: p.maxAccessesPerWindow,
|
|
3391
3396
|
windowMs: p.windowMs,
|
|
@@ -3401,13 +3406,13 @@ server.tool("check_aggregate_constraints", "Check if a data access would violate
|
|
|
3401
3406
|
const result = checkAggregateConstraints(constraint, log);
|
|
3402
3407
|
return { content: [{ type: "text", text: `${result.permitted ? '✅ PERMITTED' : '❌ BLOCKED'} — Aggregate check\n\n${result.reason || 'Within limits'}` }] };
|
|
3403
3408
|
});
|
|
3404
|
-
server.
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
}, async (p) => {
|
|
3409
|
+
server.registerTool("check_jurisdiction_transfer", { description: "Check if a data transfer is permitted under jurisdiction constraints (EU_ONLY, GDPR_ADEQUATE_ONLY, NO_CROSS_BORDER).", inputSchema: z.object({
|
|
3410
|
+
sourceJurisdiction: z.string().describe("ISO 3166-1 alpha-2 code"),
|
|
3411
|
+
targetJurisdiction: z.string().describe("ISO 3166-1 alpha-2 code"),
|
|
3412
|
+
processingRestrictions: z.array(z.string()).optional(),
|
|
3413
|
+
transferConstraints: z.array(z.string()).optional(),
|
|
3414
|
+
purpose: z.string(),
|
|
3415
|
+
}) }, async (p) => {
|
|
3411
3416
|
const envelope = {
|
|
3412
3417
|
sourceJurisdiction: p.sourceJurisdiction,
|
|
3413
3418
|
processingRestrictions: p.processingRestrictions,
|
|
@@ -3416,34 +3421,34 @@ server.tool("check_jurisdiction_transfer", "Check if a data transfer is permitte
|
|
|
3416
3421
|
const result = isTransferPermitted(envelope, p.targetJurisdiction, p.purpose);
|
|
3417
3422
|
return { content: [{ type: "text", text: `${result.permitted ? '✅ PERMITTED' : '❌ BLOCKED'} — Transfer ${p.sourceJurisdiction} → ${p.targetJurisdiction}\n\n${result.reason || 'No restrictions apply'}` }] };
|
|
3418
3423
|
});
|
|
3419
|
-
server.
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
}, async (p) => {
|
|
3424
|
+
server.registerTool("compute_governance_taint", { description: "Compute governance taint level for an artifact based on its derivation chain and revoked sources.", inputSchema: z.object({
|
|
3425
|
+
artifactId: z.string(),
|
|
3426
|
+
revokedSources: z.array(z.string()).optional().describe("Source IDs that have been revoked"),
|
|
3427
|
+
}) }, async (p) => {
|
|
3423
3428
|
const revokedSet = new Set(p.revokedSources || []);
|
|
3424
3429
|
const taint = computeGovernanceTaint(p.artifactId, state.derivationStore, revokedSet);
|
|
3425
3430
|
return { content: [{ type: "text", text: `🏷️ Governance Taint: ${p.artifactId}\n\nLevel: ${taint.taintLevel}\nSources: [${taint.sources.join(', ')}]\nReason: ${taint.reason}\nClearable: ${taint.clearable}\n${taint.clearCondition ? `Condition: ${taint.clearCondition}` : ''}` }] };
|
|
3426
3431
|
});
|
|
3427
|
-
server.
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
}, async (p) => {
|
|
3432
|
+
server.registerTool("file_data_dispute", { description: "File a dispute against a data artifact. The protocol records disputes — resolution is external.", inputSchema: z.object({
|
|
3433
|
+
artifactId: z.string(),
|
|
3434
|
+
disputeType: z.enum(["unauthorized_access", "terms_violation", "compensation_dispute", "revocation_dispute", "lineage_dispute"]),
|
|
3435
|
+
filedBy: z.string(),
|
|
3436
|
+
evidence: z.array(z.string()).describe("Evidence artifact IDs"),
|
|
3437
|
+
}) }, async (p) => {
|
|
3433
3438
|
const dispute = fileDispute({
|
|
3434
3439
|
...p,
|
|
3435
3440
|
privateKey: state.privateKey,
|
|
3436
3441
|
});
|
|
3437
3442
|
return { content: [{ type: "text", text: `⚖️ Dispute filed.\n\nID: ${dispute.disputeId}\nType: ${dispute.disputeType}\nStatus: ${dispute.status}\nArtifact: ${dispute.artifactId}\nEvidence: ${dispute.evidence.length} items` }] };
|
|
3438
3443
|
});
|
|
3439
|
-
server.
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
}, async (p) => {
|
|
3444
|
+
server.registerTool("check_combination_permitted", { description: "Check if combining data from two sources is permitted. Prevents prohibited inferences (HIPAA, COPPA, GDPR Art 9).", inputSchema: z.object({
|
|
3445
|
+
forbiddenSourceClasses: z.array(z.string()).optional(),
|
|
3446
|
+
forbiddenSourceIds: z.array(z.string()).optional(),
|
|
3447
|
+
reason: z.string(),
|
|
3448
|
+
regulatoryBasis: z.string().optional(),
|
|
3449
|
+
otherSourceId: z.string(),
|
|
3450
|
+
otherSourceClasses: z.array(z.string()).optional(),
|
|
3451
|
+
}) }, async (p) => {
|
|
3447
3452
|
const constraints = [{
|
|
3448
3453
|
forbiddenSourceClasses: p.forbiddenSourceClasses,
|
|
3449
3454
|
forbiddenSourceIds: p.forbiddenSourceIds,
|
|
@@ -3453,15 +3458,15 @@ server.tool("check_combination_permitted", "Check if combining data from two sou
|
|
|
3453
3458
|
const result = checkCombinationPermitted(constraints, p.otherSourceId, p.otherSourceClasses);
|
|
3454
3459
|
return { content: [{ type: "text", text: `${result.permitted ? '✅ PERMITTED' : '❌ BLOCKED'} — Combination check\n\n${result.violations.length ? result.violations.join('\n') : 'No violations'}` }] };
|
|
3455
3460
|
});
|
|
3456
|
-
server.
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
}, async (p) => {
|
|
3461
|
+
server.registerTool("create_access_snapshot", { description: "Create an immutable access snapshot — freezes terms, jurisdiction, and constraints at moment of access. Anti-rug-pull.", inputSchema: z.object({
|
|
3462
|
+
accessReceiptId: z.string(),
|
|
3463
|
+
sourceId: z.string(),
|
|
3464
|
+
termsVersion: z.string(),
|
|
3465
|
+
compensationRate: z.number(),
|
|
3466
|
+
currency: z.string(),
|
|
3467
|
+
allowedPurposes: z.array(z.string()),
|
|
3468
|
+
sourceJurisdiction: z.string().optional(),
|
|
3469
|
+
}) }, async (p) => {
|
|
3465
3470
|
const pinnedTerms = {
|
|
3466
3471
|
termsVersion: p.termsVersion,
|
|
3467
3472
|
pinnedAt: new Date().toISOString(),
|
|
@@ -3478,49 +3483,49 @@ server.tool("create_access_snapshot", "Create an immutable access snapshot — f
|
|
|
3478
3483
|
});
|
|
3479
3484
|
return { content: [{ type: "text", text: `📸 Access snapshot created.\n\nID: ${snap.snapshotId}\nSource: ${snap.sourceId}\nTerms hash: ${snap.termsHash}\nRate: ${snap.pinnedTerms.compensationRate} ${snap.pinnedTerms.currency}\nPurposes: [${snap.pinnedTerms.allowedPurposes.join(', ')}]` }] };
|
|
3480
3485
|
});
|
|
3481
|
-
server.
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
}, async (p) => {
|
|
3486
|
+
server.registerTool("detect_purpose_drift", { description: "Detect when data purpose drifts through a workflow (e.g. research → commercial).", inputSchema: z.object({
|
|
3487
|
+
originalPurpose: z.string(),
|
|
3488
|
+
currentPurpose: z.string(),
|
|
3489
|
+
intermediateSteps: z.array(z.string()).optional(),
|
|
3490
|
+
allowedPurposes: z.array(z.string()),
|
|
3491
|
+
}) }, async (p) => {
|
|
3487
3492
|
const result = detectPurposeDrift(p);
|
|
3488
3493
|
return { content: [{ type: "text", text: `${result.severity === 'none' ? '✅' : result.severity === 'violation' ? '❌' : '⚠️'} Purpose Drift: ${result.severity}\n\nOriginal: ${result.originalPurpose}\nCurrent: ${result.currentPurpose}\nDrift: ${result.driftDetected}\nPath: ${result.driftPath.join(' → ')}\n${result.explanation}` }] };
|
|
3489
3494
|
});
|
|
3490
|
-
server.
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
}, async (p) => {
|
|
3495
|
+
server.registerTool("resolve_rights_propagation", { description: "Resolve what rights propagate when data is transformed.", inputSchema: z.object({
|
|
3496
|
+
transformClass: z.string(),
|
|
3497
|
+
sourceDefaultPropagation: z.string().optional().describe("Source-defined default: inherit_full, compensation_only, etc."),
|
|
3498
|
+
}) }, async (p) => {
|
|
3494
3499
|
const sourceRule = p.sourceDefaultPropagation
|
|
3495
3500
|
? { defaultPropagation: p.sourceDefaultPropagation }
|
|
3496
3501
|
: undefined;
|
|
3497
3502
|
const result = resolveRightsPropagation(p.transformClass, sourceRule);
|
|
3498
3503
|
return { content: [{ type: "text", text: `📋 Rights Propagation: ${p.transformClass} → ${result}\n\n${p.sourceDefaultPropagation ? `Source override: ${p.sourceDefaultPropagation}` : `Default: ${DEFAULT_RIGHTS_PROPAGATION[p.transformClass] || 'inherit_partial'}`}` }] };
|
|
3499
3504
|
});
|
|
3500
|
-
server.
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
}, async (p) => {
|
|
3505
|
+
server.registerTool("declare_reidentification_risk", { description: "Declare re-identification risk for transformed or synthetic data.", inputSchema: z.object({
|
|
3506
|
+
risk: z.enum(["none_declared", "low", "medium", "high", "unknown", "mitigated"]),
|
|
3507
|
+
assessmentMethod: z.string().optional(),
|
|
3508
|
+
mitigationsApplied: z.array(z.string()).optional(),
|
|
3509
|
+
assessedBy: z.string(),
|
|
3510
|
+
}) }, async (p) => {
|
|
3506
3511
|
const decl = declareReidentificationRisk(p);
|
|
3507
3512
|
return { content: [{ type: "text", text: `🔒 Re-identification Risk Declaration\n\nRisk: ${decl.risk}\nMethod: ${decl.assessmentMethod || 'N/A'}\nMitigations: ${decl.mitigationsApplied?.join(', ') || 'none'}\nAssessed by: ${decl.assessedBy}\nAt: ${decl.assessedAt}` }] };
|
|
3508
3513
|
});
|
|
3509
3514
|
// ═══════════════════════════════════════
|
|
3510
3515
|
// Governance Block (HTML-embedded governance)
|
|
3511
3516
|
// ═══════════════════════════════════════
|
|
3512
|
-
server.
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
}, async (p) => {
|
|
3517
|
+
server.registerTool("generate_governance_block", { description: "Generate a cryptographically signed governance block for embedding in HTML pages. Includes terms, revocation policy, and content hash.", inputSchema: z.object({
|
|
3518
|
+
content: z.string().describe("Article/page content to hash and govern"),
|
|
3519
|
+
publicKey: z.string().describe("Publisher's Ed25519 public key (hex)"),
|
|
3520
|
+
privateKey: z.string().describe("Publisher's Ed25519 private key (hex)"),
|
|
3521
|
+
inference: z.enum(["permitted", "prohibited", "compensation_required", "attribution_required"]).optional(),
|
|
3522
|
+
training: z.enum(["permitted", "prohibited", "compensation_required", "attribution_required"]).optional(),
|
|
3523
|
+
redistribution: z.enum(["permitted", "prohibited", "compensation_required", "attribution_required"]).optional(),
|
|
3524
|
+
derivative: z.enum(["permitted", "prohibited", "compensation_required", "attribution_required"]).optional(),
|
|
3525
|
+
caching: z.enum(["permitted", "prohibited", "compensation_required", "attribution_required"]).optional(),
|
|
3526
|
+
license_url: z.string().optional(),
|
|
3527
|
+
terms_version: z.string().optional(),
|
|
3528
|
+
}) }, async (p) => {
|
|
3524
3529
|
const { block, html, meta } = embedGovernance({
|
|
3525
3530
|
content: p.content,
|
|
3526
3531
|
publicKey: p.publicKey,
|
|
@@ -3533,28 +3538,28 @@ server.tool("generate_governance_block", "Generate a cryptographically signed go
|
|
|
3533
3538
|
});
|
|
3534
3539
|
return { content: [{ type: "text", text: `📋 Governance Block Generated\n\nDID: ${block.source_did}\nContent Hash: ${block.content_hash}\nTerms: inference=${p.inference || 'not set'}, training=${p.training || 'not set'}\n\n--- HTML EMBED (script tag) ---\n${html}\n\n--- META EMBED (base64) ---\n${meta}` }] };
|
|
3535
3540
|
});
|
|
3536
|
-
server.
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
}, async (p) => {
|
|
3541
|
+
server.registerTool("verify_governance_block", { description: "Verify a governance block's signature, content hash, and DID consistency against the original content.", inputSchema: z.object({
|
|
3542
|
+
block: z.string().describe("Governance block JSON string"),
|
|
3543
|
+
content: z.string().describe("Original content to verify against"),
|
|
3544
|
+
publicKey: z.string().describe("Publisher's Ed25519 public key (hex)"),
|
|
3545
|
+
}) }, async (p) => {
|
|
3541
3546
|
const parsed = JSON.parse(p.block);
|
|
3542
3547
|
const result = verifyGovernanceBlock(parsed, p.content, p.publicKey);
|
|
3543
3548
|
return { content: [{ type: "text", text: `🔍 Governance Block Verification\n\nValid: ${result.valid ? '✅' : '❌'}\nSignature: ${result.signatureValid ? '✅' : '❌'}\nContent Hash: ${result.contentHashValid ? '✅' : '❌'}\nDID Consistent: ${result.didConsistent ? '✅' : '❌'}${result.errors.length > 0 ? '\n\nErrors:\n' + result.errors.join('\n') : ''}` }] };
|
|
3544
3549
|
});
|
|
3545
|
-
server.
|
|
3546
|
-
|
|
3547
|
-
}, async (p) => {
|
|
3550
|
+
server.registerTool("parse_governance_block_html", { description: "Extract a governance block from an HTML page. Looks for APS governance script tags or meta tags.", inputSchema: z.object({
|
|
3551
|
+
html: z.string().describe("HTML content to parse"),
|
|
3552
|
+
}) }, async (p) => {
|
|
3548
3553
|
const block = parseGovernanceBlockFromHTML(p.html);
|
|
3549
3554
|
if (!block) {
|
|
3550
3555
|
return { content: [{ type: "text", text: "No governance block found in HTML." }] };
|
|
3551
3556
|
}
|
|
3552
3557
|
return { content: [{ type: "text", text: `📋 Governance Block Found\n\nDID: ${block.source_did}\nContent Hash: ${block.content_hash}\nPublished: ${block.published_at}\nTerms: ${JSON.stringify(block.terms, null, 2)}\nRevocation Policy: ${JSON.stringify(block.revocation_policy, null, 2)}` }] };
|
|
3553
3558
|
});
|
|
3554
|
-
server.
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
}, async (p) => {
|
|
3559
|
+
server.registerTool("check_usage_permitted", { description: "Check if a specific usage type is permitted under a governance block's terms.", inputSchema: z.object({
|
|
3560
|
+
block: z.string().describe("Governance block JSON string"),
|
|
3561
|
+
usage: z.enum(["inference", "training", "redistribution", "derivative", "caching"]),
|
|
3562
|
+
}) }, async (p) => {
|
|
3558
3563
|
const parsed = JSON.parse(p.block);
|
|
3559
3564
|
const result = isUsagePermitted(parsed, p.usage);
|
|
3560
3565
|
return { content: [{ type: "text", text: `${result.permitted ? '✅' : '❌'} Usage "${p.usage}": ${result.condition}` }] };
|
|
@@ -3562,17 +3567,17 @@ server.tool("check_usage_permitted", "Check if a specific usage type is permitte
|
|
|
3562
3567
|
// ═══════════════════════════════════════
|
|
3563
3568
|
// aps.txt + HTTP Headers + Chained Blocks
|
|
3564
3569
|
// ═══════════════════════════════════════
|
|
3565
|
-
server.
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
}, async (p) => {
|
|
3570
|
+
server.registerTool("generate_aps_txt", { description: "Generate a signed aps.txt file for site-wide governance. Like robots.txt but cryptographically signed with terms, revocation endpoint, and MCP upgrade path.", inputSchema: z.object({
|
|
3571
|
+
domain: z.string().describe("Domain this declaration covers (e.g. theagenttimes.com)"),
|
|
3572
|
+
publisherName: z.string().describe("Human-readable publisher name"),
|
|
3573
|
+
publicKey: z.string().describe("Publisher's Ed25519 public key (hex)"),
|
|
3574
|
+
privateKey: z.string().describe("Publisher's Ed25519 private key (hex)"),
|
|
3575
|
+
inference: z.enum(["permitted", "prohibited", "compensation_required", "attribution_required"]).optional(),
|
|
3576
|
+
training: z.enum(["permitted", "prohibited", "compensation_required", "attribution_required"]).optional(),
|
|
3577
|
+
redistribution: z.enum(["permitted", "prohibited", "compensation_required", "attribution_required"]).optional(),
|
|
3578
|
+
mcpEndpoint: z.string().optional(),
|
|
3579
|
+
revocationEndpoint: z.string().optional(),
|
|
3580
|
+
}) }, async (p) => {
|
|
3576
3581
|
const doc = generateApsTxt({
|
|
3577
3582
|
domain: p.domain, publisherName: p.publisherName,
|
|
3578
3583
|
publicKey: p.publicKey, privateKey: p.privateKey,
|
|
@@ -3582,31 +3587,31 @@ server.tool("generate_aps_txt", "Generate a signed aps.txt file for site-wide go
|
|
|
3582
3587
|
const serialized = JSON.stringify(doc, null, 2);
|
|
3583
3588
|
return { content: [{ type: "text", text: `📄 aps.txt Generated\n\nDomain: ${doc.domain}\nDID: ${doc.publisher_did}\nMCP: ${doc.mcp_endpoint || 'none'}\n\nServe at: ${p.domain}/.well-known/aps.txt\n\n${serialized}` }] };
|
|
3584
3589
|
});
|
|
3585
|
-
server.
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
}, async (p) => {
|
|
3590
|
+
server.registerTool("verify_aps_txt", { description: "Verify a signed aps.txt file — checks signature and DID consistency.", inputSchema: z.object({
|
|
3591
|
+
content: z.string().describe("aps.txt JSON content"),
|
|
3592
|
+
publicKey: z.string().describe("Publisher's Ed25519 public key (hex)"),
|
|
3593
|
+
}) }, async (p) => {
|
|
3589
3594
|
const doc = JSON.parse(p.content);
|
|
3590
3595
|
const result = verifyApsTxt(doc, p.publicKey);
|
|
3591
3596
|
return { content: [{ type: "text", text: `${result.valid ? '✅' : '❌'} aps.txt Verification: ${result.valid ? 'VALID' : 'INVALID'}${result.errors.length ? '\nErrors: ' + result.errors.join('; ') : ''}` }] };
|
|
3592
3597
|
});
|
|
3593
|
-
server.
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
}, async (p) => {
|
|
3598
|
+
server.registerTool("resolve_path_terms", { description: "Resolve governance terms for a specific URL path using aps.txt path overrides.", inputSchema: z.object({
|
|
3599
|
+
apsTxt: z.string().describe("aps.txt JSON content"),
|
|
3600
|
+
path: z.string().describe("URL path to resolve (e.g. /blog/my-article)"),
|
|
3601
|
+
}) }, async (p) => {
|
|
3597
3602
|
const doc = JSON.parse(p.apsTxt);
|
|
3598
3603
|
const terms = resolveTermsForPath(doc, p.path);
|
|
3599
3604
|
return { content: [{ type: "text", text: `📋 Terms for "${p.path}":\n${JSON.stringify(terms, null, 2)}` }] };
|
|
3600
3605
|
});
|
|
3601
|
-
server.
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
}, async (p) => {
|
|
3606
|
+
server.registerTool("create_chained_governance_block", { description: "Create a governance block for derivative content that references the original publisher's block. Preserves the chain of provenance.", inputSchema: z.object({
|
|
3607
|
+
content: z.string().describe("Derivative content"),
|
|
3608
|
+
publicKey: z.string().describe("Derivative agent's Ed25519 public key (hex)"),
|
|
3609
|
+
privateKey: z.string().describe("Derivative agent's Ed25519 private key (hex)"),
|
|
3610
|
+
parentBlock: z.string().describe("Original governance block JSON string"),
|
|
3611
|
+
derivationType: z.string().describe("Type: summary, embedding, rag_chunk, translation, etc."),
|
|
3612
|
+
inference: z.enum(["permitted", "prohibited", "compensation_required", "attribution_required"]).optional(),
|
|
3613
|
+
training: z.enum(["permitted", "prohibited", "compensation_required", "attribution_required"]).optional(),
|
|
3614
|
+
}) }, async (p) => {
|
|
3610
3615
|
const parent = JSON.parse(p.parentBlock);
|
|
3611
3616
|
const chained = createChainedGovernanceBlock({
|
|
3612
3617
|
content: p.content, publicKey: p.publicKey, privateKey: p.privateKey,
|
|
@@ -3618,15 +3623,15 @@ server.tool("create_chained_governance_block", "Create a governance block for de
|
|
|
3618
3623
|
// ═══════════════════════════════════════
|
|
3619
3624
|
// Governance Consumer (agent-side 360 loop)
|
|
3620
3625
|
// ═══════════════════════════════════════
|
|
3621
|
-
server.
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
}, async (p) => {
|
|
3626
|
+
server.registerTool("governance_360", { description: "Execute the full governance 360 loop on HTML content: extract governance block → verify signature + content hash → check usage terms → create signed access receipt. This is what an agent calls on every page it reads.", inputSchema: z.object({
|
|
3627
|
+
html: z.string().describe("Full HTML of the page"),
|
|
3628
|
+
contentBody: z.string().describe("Article text content (for hash verification)"),
|
|
3629
|
+
publisherPublicKey: z.string().describe("Publisher's Ed25519 public key (hex)"),
|
|
3630
|
+
agentPublicKey: z.string().describe("Your agent's Ed25519 public key (hex)"),
|
|
3631
|
+
agentPrivateKey: z.string().describe("Your agent's Ed25519 private key (hex)"),
|
|
3632
|
+
intendedUsage: z.enum(["inference", "training", "redistribution", "derivative", "caching"]),
|
|
3633
|
+
sourceUrl: z.string().describe("URL of the page"),
|
|
3634
|
+
}) }, async (p) => {
|
|
3630
3635
|
const result = governanceLoop360({
|
|
3631
3636
|
html: p.html, contentBody: p.contentBody,
|
|
3632
3637
|
publisherPublicKey: p.publisherPublicKey,
|
|
@@ -3635,13 +3640,13 @@ server.tool("governance_360", "Execute the full governance 360 loop on HTML cont
|
|
|
3635
3640
|
});
|
|
3636
3641
|
return { content: [{ type: "text", text: `🔄 Governance 360 Loop\n\n${result.summary}\n\n${result.receipt ? `Receipt ID: ${result.receipt.receiptId}\nAccessed: ${result.receipt.accessed_at}` : 'No receipt (ungoverned content)'}` }] };
|
|
3637
3642
|
});
|
|
3638
|
-
server.
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
}, async (p) => {
|
|
3643
|
+
server.registerTool("create_access_receipt", { description: "Create a signed access receipt — cryptographic proof that your agent consumed content under specific terms. The receipt captures terms and revocation policy at access time.", inputSchema: z.object({
|
|
3644
|
+
agentPublicKey: z.string().describe("Your agent's Ed25519 public key (hex)"),
|
|
3645
|
+
agentPrivateKey: z.string().describe("Your agent's Ed25519 private key (hex)"),
|
|
3646
|
+
block: z.string().describe("Governance block JSON string"),
|
|
3647
|
+
sourceUrl: z.string().describe("URL where content was accessed"),
|
|
3648
|
+
intendedUsage: z.string().describe("How you intend to use this content"),
|
|
3649
|
+
}) }, async (p) => {
|
|
3645
3650
|
const parsed = JSON.parse(p.block);
|
|
3646
3651
|
const receipt = createAccessReceipt({
|
|
3647
3652
|
agentPublicKey: p.agentPublicKey, agentPrivateKey: p.agentPrivateKey,
|
|
@@ -3653,25 +3658,25 @@ server.tool("create_access_receipt", "Create a signed access receipt — cryptog
|
|
|
3653
3658
|
// ═══════════════════════════════════════
|
|
3654
3659
|
// Rome-Complete: Charter & Institutional Governance
|
|
3655
3660
|
// ═══════════════════════════════════════
|
|
3656
|
-
server.
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
}, async (args) => {
|
|
3661
|
+
server.registerTool("create_charter", { description: "Create a new institutional charter — the constitutional root of an organization. Defines offices, amendment rules, dissolution policy.", inputSchema: z.object({
|
|
3662
|
+
name: z.string().describe("Institution name"),
|
|
3663
|
+
offices: z.array(z.object({
|
|
3664
|
+
officeId: z.string(),
|
|
3665
|
+
name: z.string(),
|
|
3666
|
+
holderPublicKey: z.string().describe("Ed25519 public key of initial holder"),
|
|
3667
|
+
allowedScopes: z.array(z.string()).default(["*"]),
|
|
3668
|
+
maxSpendPerAction: z.number().default(1000),
|
|
3669
|
+
maxDelegationDepth: z.number().default(3),
|
|
3670
|
+
successionOrder: z.array(z.string()).default([]),
|
|
3671
|
+
incompatibleOffices: z.array(z.string()).optional(),
|
|
3672
|
+
})).describe("Offices to create"),
|
|
3673
|
+
amendment_board_keys: z.array(z.string()).describe("Ed25519 public keys eligible for amendment voting"),
|
|
3674
|
+
amendment_required_sigs: z.number().describe("Signatures required for amendment"),
|
|
3675
|
+
dissolution_grace_seconds: z.number().default(86400),
|
|
3676
|
+
founder_private_key: z.string().describe("Founder's Ed25519 private key"),
|
|
3677
|
+
founder_public_key: z.string().describe("Founder's Ed25519 public key"),
|
|
3678
|
+
founder_role: z.string().default("board"),
|
|
3679
|
+
}) }, async (args) => {
|
|
3675
3680
|
const offices = args.offices.map(o => ({
|
|
3676
3681
|
officeId: o.officeId,
|
|
3677
3682
|
name: o.name,
|
|
@@ -3707,7 +3712,7 @@ server.tool("create_charter", "Create a new institutional charter — the consti
|
|
|
3707
3712
|
state.charters.set(charter.charterId, charter);
|
|
3708
3713
|
return { content: [{ type: "text", text: `🏛️ Charter Created\n\nID: ${charter.charterId}\nName: ${charter.name}\nVersion: ${charter.version}\nOffices: ${charter.offices.map(o => o.name).join(', ')}\nSignatures: ${charter.foundingSignatures.length}` }] };
|
|
3709
3714
|
});
|
|
3710
|
-
server.
|
|
3715
|
+
server.registerTool("verify_charter", { description: "Verify a charter's integrity: content hash, signatures, office consistency, incompatibility.", inputSchema: z.object({ charter_id: z.string().describe("Charter ID to verify") }) }, async (args) => {
|
|
3711
3716
|
const charter = state.charters.get(args.charter_id);
|
|
3712
3717
|
if (!charter)
|
|
3713
3718
|
return { content: [{ type: "text", text: `❌ Charter ${args.charter_id} not found` }] };
|
|
@@ -3715,13 +3720,13 @@ server.tool("verify_charter", "Verify a charter's integrity: content hash, signa
|
|
|
3715
3720
|
const status = result.valid ? '✅ VALID' : '❌ INVALID';
|
|
3716
3721
|
return { content: [{ type: "text", text: `${status}\n\nContent integrity: ${result.contentIntegrity}\nSignatures valid: ${result.signaturesValid}\nQuorum met: ${result.quorumMet}\nNot dissolved: ${result.notDissolved}\nOffices valid: ${result.officesValid}\nIncompatibility clean: ${result.incompatibilityClean}${result.errors.length ? '\n\nErrors:\n' + result.errors.join('\n') : ''}` }] };
|
|
3717
3722
|
});
|
|
3718
|
-
server.
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
}, async (args) => {
|
|
3723
|
+
server.registerTool("sign_charter", { description: "Add a founding signature to a charter.", inputSchema: z.object({
|
|
3724
|
+
charter_id: z.string(),
|
|
3725
|
+
signer_private_key: z.string(),
|
|
3726
|
+
signer_public_key: z.string(),
|
|
3727
|
+
signer_role: z.string().default("board"),
|
|
3728
|
+
resigner_private_key: z.string().describe("Key to re-sign the outer charter envelope"),
|
|
3729
|
+
}) }, async (args) => {
|
|
3725
3730
|
const charter = state.charters.get(args.charter_id);
|
|
3726
3731
|
if (!charter)
|
|
3727
3732
|
return { content: [{ type: "text", text: `❌ Charter ${args.charter_id} not found` }] };
|
|
@@ -3729,15 +3734,15 @@ server.tool("sign_charter", "Add a founding signature to a charter.", {
|
|
|
3729
3734
|
state.charters.set(signed.charterId, signed);
|
|
3730
3735
|
return { content: [{ type: "text", text: `✅ Signature added to ${signed.charterId}\n\nTotal signatures: ${signed.foundingSignatures.length}\nNew signer role: ${args.signer_role}` }] };
|
|
3731
3736
|
});
|
|
3732
|
-
server.
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
}, async (args) => {
|
|
3737
|
+
server.registerTool("evaluate_threshold", { description: "Evaluate whether signatures meet a multi-class threshold policy (Consilium Q5).", inputSchema: z.object({
|
|
3738
|
+
charter_id: z.string().describe("Charter whose amendment policy to evaluate against"),
|
|
3739
|
+
signatures: z.array(z.object({
|
|
3740
|
+
publicKey: z.string(),
|
|
3741
|
+
keyClass: z.string(),
|
|
3742
|
+
signedAt: z.string().default(new Date().toISOString()),
|
|
3743
|
+
signature: z.string().default(""),
|
|
3744
|
+
})),
|
|
3745
|
+
}) }, async (args) => {
|
|
3741
3746
|
const charter = state.charters.get(args.charter_id);
|
|
3742
3747
|
if (!charter)
|
|
3743
3748
|
return { content: [{ type: "text", text: `❌ Charter ${args.charter_id} not found` }] };
|
|
@@ -3745,24 +3750,24 @@ server.tool("evaluate_threshold", "Evaluate whether signatures meet a multi-clas
|
|
|
3745
3750
|
const classLines = result.classStatus.map(c => ` ${c.role}: ${c.collected}/${c.required} ${c.satisfied ? '✅' : '❌'}`).join('\n');
|
|
3746
3751
|
return { content: [{ type: "text", text: `${result.met ? '✅ THRESHOLD MET' : '❌ THRESHOLD NOT MET'}\n\nClasses:\n${classLines}\n\nTotal: ${result.totalValidSignatures}/${result.totalRequired}${result.errors.length ? '\n\nIssues:\n' + result.errors.join('\n') : ''}` }] };
|
|
3747
3752
|
});
|
|
3748
|
-
server.
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
}, async (args) => {
|
|
3753
|
+
server.registerTool("create_approval_request", { description: "Create a multi-party approval request for charter amendments, office transfers, etc.", inputSchema: z.object({
|
|
3754
|
+
policy_id: z.string(),
|
|
3755
|
+
subject: z.string().describe("What is being approved (e.g. amendment ID)"),
|
|
3756
|
+
subject_type: z.enum(['charter_amendment', 'delegation', 'office_transfer', 'dissolution', 'escrow_release', 'dispute_resolution']),
|
|
3757
|
+
requested_by: z.string(),
|
|
3758
|
+
timeout_seconds: z.number().default(86400),
|
|
3759
|
+
}) }, async (args) => {
|
|
3755
3760
|
const req = createApprovalRequest(args.policy_id, args.subject, args.subject_type, args.requested_by, args.timeout_seconds);
|
|
3756
3761
|
state.approvalRequests.set(req.requestId, req);
|
|
3757
3762
|
return { content: [{ type: "text", text: `📋 Approval Request Created\n\nID: ${req.requestId}\nSubject: ${req.subject} (${req.subjectType})\nStatus: ${req.status}\nExpires: ${req.expiresAt}` }] };
|
|
3758
3763
|
});
|
|
3759
|
-
server.
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
}, async (args) => {
|
|
3764
|
+
server.registerTool("add_approval_signature", { description: "Add a signature to an approval request.", inputSchema: z.object({
|
|
3765
|
+
request_id: z.string(),
|
|
3766
|
+
signer_private_key: z.string(),
|
|
3767
|
+
signer_public_key: z.string(),
|
|
3768
|
+
key_class: z.string().default("board"),
|
|
3769
|
+
office_id: z.string().optional(),
|
|
3770
|
+
}) }, async (args) => {
|
|
3766
3771
|
const req = state.approvalRequests.get(args.request_id);
|
|
3767
3772
|
if (!req)
|
|
3768
3773
|
return { content: [{ type: "text", text: `❌ Request ${args.request_id} not found` }] };
|
|
@@ -3770,28 +3775,28 @@ server.tool("add_approval_signature", "Add a signature to an approval request.",
|
|
|
3770
3775
|
state.approvalRequests.set(updated.requestId, updated);
|
|
3771
3776
|
return { content: [{ type: "text", text: `✅ Signature added\n\nRequest: ${updated.requestId}\nTotal signatures: ${updated.signatures.length}\nStatus: ${updated.status}` }] };
|
|
3772
3777
|
});
|
|
3773
|
-
server.
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
}, async (args) => {
|
|
3778
|
+
server.registerTool("create_hybrid_timestamp", { description: "Create a gateway-issued hybrid timestamp (Consilium Q1: HLC + NTP uncertainty).", inputSchema: z.object({
|
|
3779
|
+
gateway_id: z.string().describe("Gateway issuing the timestamp"),
|
|
3780
|
+
drift_ms: z.number().default(50).describe("NTP drift bound in milliseconds"),
|
|
3781
|
+
}) }, async (args) => {
|
|
3777
3782
|
const ts = createHybridTimestamp(args.gateway_id, args.drift_ms);
|
|
3778
3783
|
return { content: [{ type: "text", text: `⏱️ Hybrid Timestamp\n\nLogical time: ${ts.logicalTime}\nWall clock earliest: ${new Date(ts.wallClockEarliest).toISOString()}\nWall clock latest: ${new Date(ts.wallClockLatest).toISOString()}\nGateway: ${ts.gatewayId}\nUncertainty: ±${args.drift_ms}ms` }] };
|
|
3779
3784
|
});
|
|
3780
|
-
server.
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
}, async (args) => {
|
|
3785
|
+
server.registerTool("compare_timestamps", { description: "Compare two hybrid timestamps to determine ordering.", inputSchema: z.object({
|
|
3786
|
+
a: z.object({ logicalTime: z.number(), wallClockEarliest: z.number(), wallClockLatest: z.number(), gatewayId: z.string() }),
|
|
3787
|
+
b: z.object({ logicalTime: z.number(), wallClockEarliest: z.number(), wallClockLatest: z.number(), gatewayId: z.string() }),
|
|
3788
|
+
}) }, async (args) => {
|
|
3784
3789
|
const order = compareTimestamps(args.a, args.b);
|
|
3785
3790
|
return { content: [{ type: "text", text: `⏱️ Temporal Ordering: ${order}\n\nA: logical=${args.a.logicalTime} wall=[${args.a.wallClockEarliest},${args.a.wallClockLatest}] gw=${args.a.gatewayId}\nB: logical=${args.b.logicalTime} wall=[${args.b.wallClockEarliest},${args.b.wallClockLatest}] gw=${args.b.gatewayId}` }] };
|
|
3786
3791
|
});
|
|
3787
|
-
server.
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
}, async (args) => {
|
|
3792
|
+
server.registerTool("validate_temporal_rights", { description: "Validate a TemporalRights object — check validity window, grace period, supersession, challenge window.", inputSchema: z.object({
|
|
3793
|
+
valid_from: z.string().describe("ISO datetime"),
|
|
3794
|
+
valid_until: z.string().describe("ISO datetime"),
|
|
3795
|
+
challenge_until: z.string().optional(),
|
|
3796
|
+
grace_until: z.string().optional(),
|
|
3797
|
+
superseded_at: z.string().optional(),
|
|
3798
|
+
effective_at: z.string().optional(),
|
|
3799
|
+
}) }, async (args) => {
|
|
3795
3800
|
const result = validateTemporalRights({
|
|
3796
3801
|
validFrom: args.valid_from, validUntil: args.valid_until,
|
|
3797
3802
|
challengeUntil: args.challenge_until, graceUntil: args.grace_until,
|
|
@@ -3799,19 +3804,19 @@ server.tool("validate_temporal_rights", "Validate a TemporalRights object — ch
|
|
|
3799
3804
|
});
|
|
3800
3805
|
return { content: [{ type: "text", text: `⏱️ Temporal Validation\n\nValid: ${result.valid}\nIn grace: ${result.inGracePeriod}\nSuperseded: ${result.superseded}\nChallenge open: ${result.challengeWindowOpen}\nEffective: ${result.effective}${result.errors.length ? '\n\nIssues:\n' + result.errors.join('\n') : ''}` }] };
|
|
3801
3806
|
});
|
|
3802
|
-
server.
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
}, async (args) => {
|
|
3807
|
+
server.registerTool("create_reserve_attestation", { description: "Create a signed reserve attestation proving a delegation has actual funds (GPT #15).", inputSchema: z.object({
|
|
3808
|
+
delegation_id: z.string(),
|
|
3809
|
+
assurance_class: z.enum(['unbacked', 'self_attested', 'gateway_attested', 'escrow_backed', 'externally_attested']),
|
|
3810
|
+
amount: z.number(),
|
|
3811
|
+
currency: z.string().default("USD"),
|
|
3812
|
+
attestation_basis: z.enum(['api_balance_check', 'bank_statement', 'escrow_lock', 'self_declaration']),
|
|
3813
|
+
false_attestation_penalty: z.enum(['reputation_slash', 'bond_forfeit', 'dispute_eligible', 'none']).default('reputation_slash'),
|
|
3814
|
+
attester_private_key: z.string(),
|
|
3815
|
+
attester_public_key: z.string(),
|
|
3816
|
+
charter_anchor: z.string().optional(),
|
|
3817
|
+
office_id: z.string().optional(),
|
|
3818
|
+
ttl_seconds: z.number().default(86400),
|
|
3819
|
+
}) }, async (args) => {
|
|
3815
3820
|
const att = createReserveAttestation({
|
|
3816
3821
|
delegationId: args.delegation_id, assuranceClass: args.assurance_class,
|
|
3817
3822
|
amount: args.amount, currency: args.currency,
|
|
@@ -3821,29 +3826,29 @@ server.tool("create_reserve_attestation", "Create a signed reserve attestation p
|
|
|
3821
3826
|
});
|
|
3822
3827
|
return { content: [{ type: "text", text: `💰 Reserve Attestation Created\n\nID: ${att.attestationId}\nDelegation: ${att.delegationId}\nAssurance: ${att.assuranceClass}\nAmount: ${att.attestedAmount.value} ${att.attestedAmount.currency}\nExpires: ${att.expiresAt}` }] };
|
|
3823
3828
|
});
|
|
3824
|
-
server.
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
}, async (args) => {
|
|
3829
|
+
server.registerTool("vouch_reputation", { description: "Create a vouched reputation for cross-gateway portability (WS-3). Signed summary — no receipt history exposed.", inputSchema: z.object({
|
|
3830
|
+
agent_id: z.string(),
|
|
3831
|
+
tier: z.number(),
|
|
3832
|
+
diversity_score: z.number(),
|
|
3833
|
+
gateway_private_key: z.string(),
|
|
3834
|
+
gateway_id: z.string(),
|
|
3835
|
+
ttl_seconds: z.number().default(2592000).describe("Default 30 days"),
|
|
3836
|
+
}) }, async (args) => {
|
|
3832
3837
|
const rep = vouchReputation({
|
|
3833
3838
|
agentId: args.agent_id, tier: args.tier, diversityScore: args.diversity_score,
|
|
3834
3839
|
gatewayPrivateKey: args.gateway_private_key, gatewayId: args.gateway_id, ttlSeconds: args.ttl_seconds,
|
|
3835
3840
|
});
|
|
3836
3841
|
return { content: [{ type: "text", text: `🌐 Vouched Reputation Created\n\nAgent: ${rep.agentId}\nTier: ${rep.attestedTier}\nDiversity: ${rep.attestedDiversityScore}\nGateway: ${rep.originGatewayId}\nExpires: ${rep.expiresAt}` }] };
|
|
3837
3842
|
});
|
|
3838
|
-
server.
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
}, async (args) => {
|
|
3843
|
+
server.registerTool("apply_reputation_downgrade", { description: "Apply import policy downgrade to a foreign vouched reputation.", inputSchema: z.object({
|
|
3844
|
+
agent_id: z.string(),
|
|
3845
|
+
origin_gateway_id: z.string(),
|
|
3846
|
+
attested_tier: z.number(),
|
|
3847
|
+
attested_diversity_score: z.number(),
|
|
3848
|
+
accept_from: z.array(z.string()).describe("Gateway IDs accepted by import policy"),
|
|
3849
|
+
downgrade_ratio: z.number().default(0.5),
|
|
3850
|
+
foreign_default_tier: z.number().default(0),
|
|
3851
|
+
}) }, async (args) => {
|
|
3847
3852
|
const rep = { agentId: args.agent_id, originGatewayId: args.origin_gateway_id, attestedTier: args.attested_tier, attestedDiversityScore: args.attested_diversity_score, attestedAt: new Date().toISOString(), expiresAt: new Date(Date.now() + 86400000).toISOString(), originGatewaySignature: '' };
|
|
3848
3853
|
const policy = {
|
|
3849
3854
|
receipts: { acceptFrom: args.accept_from, requireWitness: true },
|
|
@@ -3859,12 +3864,12 @@ server.tool("apply_reputation_downgrade", "Apply import policy downgrade to a fo
|
|
|
3859
3864
|
// ═══════════════════════════════════════
|
|
3860
3865
|
// v1.33.0 — action_ref + freshness + evidence-based grade
|
|
3861
3866
|
// ═══════════════════════════════════════
|
|
3862
|
-
server.
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
}, async (args) => {
|
|
3867
|
+
server.registerTool("compute_action_ref", { description: "Compute content-addressed request identity (SHA-256 of agentId + actionType + scope + normalized timestamp). Two receipts with the same action_ref describe the same request.", inputSchema: z.object({
|
|
3868
|
+
agent_id: z.string(),
|
|
3869
|
+
action_type: z.string(),
|
|
3870
|
+
scope_required: z.array(z.string()),
|
|
3871
|
+
timestamp: z.string().optional().describe("ISO 8601 timestamp; defaults to now"),
|
|
3872
|
+
}) }, async (args) => {
|
|
3868
3873
|
const intent = {
|
|
3869
3874
|
agentId: args.agent_id,
|
|
3870
3875
|
action: { type: args.action_type, scopeRequired: args.scope_required },
|
|
@@ -3873,13 +3878,13 @@ server.tool("compute_action_ref", "Compute content-addressed request identity (S
|
|
|
3873
3878
|
const ref = computeActionRef(intent);
|
|
3874
3879
|
return { content: [{ type: "text", text: `🔗 action_ref: ${ref}\n\nAgent: ${args.agent_id}\nType: ${args.action_type}\nScope: ${args.scope_required.join(', ')}\nTimestamp: ${intent.createdAt}` }] };
|
|
3875
3880
|
});
|
|
3876
|
-
server.
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
}, async (args) => {
|
|
3881
|
+
server.registerTool("is_evidence_fresh", { description: "Check whether typed attestation evidence is still fresh. rotating: ttl required; snapshot: maxAge optional; static: always fresh.", inputSchema: z.object({
|
|
3882
|
+
type: z.enum(['rotating', 'snapshot', 'static']),
|
|
3883
|
+
valid_at: z.string().describe("ISO 8601 timestamp evidence was produced"),
|
|
3884
|
+
ttl: z.number().optional().describe("Seconds (required for rotating)"),
|
|
3885
|
+
max_age: z.number().optional().describe("Seconds (optional for snapshot)"),
|
|
3886
|
+
now: z.string().optional().describe("ISO 8601 override for current time"),
|
|
3887
|
+
}) }, async (args) => {
|
|
3883
3888
|
const freshness = { type: args.type, validAt: args.valid_at };
|
|
3884
3889
|
if (args.ttl !== undefined)
|
|
3885
3890
|
freshness.ttl = args.ttl;
|
|
@@ -3890,12 +3895,12 @@ server.tool("is_evidence_fresh", "Check whether typed attestation evidence is st
|
|
|
3890
3895
|
const ageSec = computeEvidenceAge(freshness, nowDate);
|
|
3891
3896
|
return { content: [{ type: "text", text: `${fresh ? '✅' : '❌'} Evidence fresh: ${fresh}\n\nType: ${args.type}\nValid at: ${args.valid_at}\nAge: ${ageSec}s${args.ttl !== undefined ? `\nTTL: ${args.ttl}s` : ''}${args.max_age !== undefined ? `\nMax age: ${args.max_age}s` : ''}` }] };
|
|
3892
3897
|
});
|
|
3893
|
-
server.
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
}, async (args) => {
|
|
3898
|
+
server.registerTool("classify_evidence_quality", { description: "Classify attestation evidence quality (none / issuer_vouched / infrastructure / principal_bound) and return the corresponding grade (0-3).", inputSchema: z.object({
|
|
3899
|
+
method: z.string().optional().describe("Attestation method (e.g. 'spiffe')"),
|
|
3900
|
+
has_issuer_signature: z.boolean().optional(),
|
|
3901
|
+
has_principal_binding: z.boolean().optional(),
|
|
3902
|
+
evidence: z.record(z.string(), z.any()).optional().describe("Evidence object (checked for known infrastructure keys)"),
|
|
3903
|
+
}) }, async (args) => {
|
|
3899
3904
|
const quality = classifyEvidenceQuality({
|
|
3900
3905
|
method: args.method,
|
|
3901
3906
|
hasIssuerSignature: args.has_issuer_signature,
|
|
@@ -3908,13 +3913,13 @@ server.tool("classify_evidence_quality", "Classify attestation evidence quality
|
|
|
3908
3913
|
// ═══════════════════════════════════════
|
|
3909
3914
|
// Key Rotation — DID Document + Identity Continuity
|
|
3910
3915
|
// ═══════════════════════════════════════
|
|
3911
|
-
server.
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
}, async (args) => {
|
|
3916
|
+
server.registerTool("rotate_key", { description: "Rotate an agent's Ed25519 key. Planned mode: configurable overlap (default 24h). Emergency mode: immediate old-key retirement. Returns updated DID document, rotation state, and revocation results.", inputSchema: z.object({
|
|
3917
|
+
mode: z.enum(['planned', 'emergency']),
|
|
3918
|
+
old_private_key: z.string().describe("Hex-encoded private key being rotated FROM"),
|
|
3919
|
+
agent_name: z.string().optional().describe("Agent name for the passport (default: current session)"),
|
|
3920
|
+
activation_delay_hours: z.number().optional().describe("Planned mode overlap hours (default: 24)"),
|
|
3921
|
+
delegation_ids_to_revoke: z.array(z.string()).optional().describe("Delegation IDs to cascade-revoke during rotation"),
|
|
3922
|
+
}) }, async (args) => {
|
|
3918
3923
|
const { generateKeyPair } = await import("agent-passport-system");
|
|
3919
3924
|
const oldPublicKey = (await import("agent-passport-system")).publicKeyFromPrivate(args.old_private_key);
|
|
3920
3925
|
const newKeyPair = generateKeyPair();
|
|
@@ -3931,9 +3936,9 @@ server.tool("rotate_key", "Rotate an agent's Ed25519 key. Planned mode: configur
|
|
|
3931
3936
|
const result = rotateAndInvalidate(doc, args.old_private_key, newKeyPair, args.delegation_ids_to_revoke || [], { mode: args.mode, activationDelayMs: delayMs });
|
|
3932
3937
|
return { content: [{ type: "text", text: `🔑 Key Rotation (${args.mode})\n\nState: ${result.rotationState}\nOld key: ${oldPublicKey.slice(0, 16)}...\nNew key: ${newKeyPair.publicKey.slice(0, 16)}...\nNew private key: ${newKeyPair.privateKey}\nDID: ${result.didDocument.id}\nRotation log entries: ${result.didDocument.rotationLog.length}\nRevocations: ${result.revocationResults.length} (${result.revocationResults.filter(r => !r.error).length} succeeded)\n\nActivation time: ${result.didDocument.pendingRotation?.activationTime || 'immediate'}` }] };
|
|
3933
3938
|
});
|
|
3934
|
-
server.
|
|
3935
|
-
|
|
3936
|
-
}, async (args) => {
|
|
3939
|
+
server.registerTool("verify_rotation_chain", { description: "Verify all rotation signatures in a DID document's rotation log. Returns true if the full chain is cryptographically valid.", inputSchema: z.object({
|
|
3940
|
+
did_document: z.any().describe("RotatableDIDDocument JSON object with rotationLog"),
|
|
3941
|
+
}) }, async (args) => {
|
|
3937
3942
|
const doc = args.did_document;
|
|
3938
3943
|
if (!doc || !Array.isArray(doc.rotationLog)) {
|
|
3939
3944
|
return { content: [{ type: "text", text: `❌ Invalid DID document: missing rotationLog array` }] };
|
|
@@ -3941,10 +3946,10 @@ server.tool("verify_rotation_chain", "Verify all rotation signatures in a DID do
|
|
|
3941
3946
|
const valid = verifyRotationChain(doc);
|
|
3942
3947
|
return { content: [{ type: "text", text: `${valid ? '✅' : '❌'} Rotation chain valid: ${valid}\n\nEntries verified: ${doc.rotationLog.length}\nDID: ${doc.id || 'unknown'}` }] };
|
|
3943
3948
|
});
|
|
3944
|
-
server.
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
}, async (args) => {
|
|
3949
|
+
server.registerTool("is_key_active", { description: "Check if a public key is currently authorized for active operations in a DID document. SDK convenience check; gateway enforcement is authoritative.", inputSchema: z.object({
|
|
3950
|
+
did_document: z.any().describe("RotatableDIDDocument JSON object"),
|
|
3951
|
+
public_key: z.string().describe("Hex-encoded Ed25519 public key to check"),
|
|
3952
|
+
}) }, async (args) => {
|
|
3948
3953
|
const doc = args.did_document;
|
|
3949
3954
|
if (!doc || !Array.isArray(doc.verificationMethod)) {
|
|
3950
3955
|
return { content: [{ type: "text", text: `❌ Invalid DID document: missing verificationMethod` }] };
|
|
@@ -3957,17 +3962,17 @@ server.tool("is_key_active", "Check if a public key is currently authorized for
|
|
|
3957
3962
|
// HumanEscalationFlag. Representation, commitment, escalation boundaries.
|
|
3958
3963
|
// ═══════════════════════════════════════════════════════════════
|
|
3959
3964
|
// ── AttributionConsent (representation boundary) ────────────────
|
|
3960
|
-
server.
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
}, async (args) => {
|
|
3965
|
+
server.registerTool("aps_create_attribution_receipt", { description: "Representation boundary: build a citer-signed AttributionReceipt attributing a claim to a third-party principal. The receipt is not yet valid — the cited principal must sign consent via aps_sign_attribution_consent before checkArtifactCitations accepts it.", inputSchema: z.object({
|
|
3966
|
+
citer: z.string().describe("DID/public key of the citing agent"),
|
|
3967
|
+
citer_public_key: z.string().describe("Hex public key of citer"),
|
|
3968
|
+
citer_private_key: z.string().describe("Hex private key of citer"),
|
|
3969
|
+
cited_principal: z.string().describe("DID/public key of the cited principal"),
|
|
3970
|
+
cited_principal_public_key: z.string().describe("Hex public key of cited principal"),
|
|
3971
|
+
citation_content: z.string().describe("The quoted or paraphrased claim"),
|
|
3972
|
+
binding_context: z.string().describe("ID of the binding artifact this citation is scoped to"),
|
|
3973
|
+
gateway_id: z.string().optional().describe("Gateway id for timestamping (default: 'mcp')"),
|
|
3974
|
+
ttl_ms: z.number().optional().describe("Receipt TTL in ms (default: 24h)"),
|
|
3975
|
+
}) }, async (args) => {
|
|
3971
3976
|
try {
|
|
3972
3977
|
const gw = args.gateway_id ?? 'mcp';
|
|
3973
3978
|
const ttl = args.ttl_ms ?? 24 * 3600_000;
|
|
@@ -3991,10 +3996,10 @@ server.tool("aps_create_attribution_receipt", "Representation boundary: build a
|
|
|
3991
3996
|
return { content: [{ type: "text", text: safeError("createAttributionReceipt failed", e) }], isError: true };
|
|
3992
3997
|
}
|
|
3993
3998
|
});
|
|
3994
|
-
server.
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
}, async (args) => {
|
|
3999
|
+
server.registerTool("aps_sign_attribution_consent", { description: "Representation boundary: the cited principal adds their consent signature to an AttributionReceipt. Without this signature, verifyAttributionConsent and checkArtifactCitations reject the receipt.", inputSchema: z.object({
|
|
4000
|
+
receipt: z.any().describe("AttributionReceipt JSON from aps_create_attribution_receipt"),
|
|
4001
|
+
cited_principal_private_key: z.string().describe("Hex private key of cited principal"),
|
|
4002
|
+
}) }, async (args) => {
|
|
3998
4003
|
try {
|
|
3999
4004
|
const signed = signAttributionConsent(args.receipt, args.cited_principal_private_key);
|
|
4000
4005
|
return { content: [{ type: "text", text: JSON.stringify(signed, null, 2) }] };
|
|
@@ -4003,41 +4008,41 @@ server.tool("aps_sign_attribution_consent", "Representation boundary: the cited
|
|
|
4003
4008
|
return { content: [{ type: "text", text: safeError("signAttributionConsent failed", e) }], isError: true };
|
|
4004
4009
|
}
|
|
4005
4010
|
});
|
|
4006
|
-
server.
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
}, async (args) => {
|
|
4011
|
+
server.registerTool("aps_verify_attribution_consent", { description: "Representation boundary: verify an AttributionReceipt end-to-end (id, citer signature, consent signature, expiry). Returns {valid, reason?}.", inputSchema: z.object({
|
|
4012
|
+
receipt: z.any().describe("AttributionReceipt JSON"),
|
|
4013
|
+
now: z.any().optional().describe("Optional HybridTimestamp to pin the evaluation moment"),
|
|
4014
|
+
}) }, async (args) => {
|
|
4010
4015
|
const result = verifyAttributionConsent(args.receipt, args.now);
|
|
4011
4016
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
4012
4017
|
});
|
|
4013
|
-
server.
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
}, async (args) => {
|
|
4018
|
+
server.registerTool("aps_check_artifact_citations", { description: "Representation boundary: gate a binding artifact's citations. Each citation must resolve to a provided, signed, unexpired receipt whose content + principal match, with per-artifact replay protection.", inputSchema: z.object({
|
|
4019
|
+
artifact: z.any().describe("CitingArtifact with optional citations[] array"),
|
|
4020
|
+
receipts: z.array(z.any()).describe("AttributionReceipts backing each citation"),
|
|
4021
|
+
binding_context: z.string().optional().describe("Require receipts to be scoped to this binding context"),
|
|
4022
|
+
}) }, async (args) => {
|
|
4018
4023
|
const opts = {};
|
|
4019
4024
|
if (args.binding_context)
|
|
4020
4025
|
opts.binding_context = args.binding_context;
|
|
4021
4026
|
const result = checkArtifactCitations(args.artifact, args.receipts, opts);
|
|
4022
4027
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
4023
4028
|
});
|
|
4024
|
-
server.
|
|
4025
|
-
|
|
4026
|
-
}, async (args) => {
|
|
4029
|
+
server.registerTool("aps_attribution_receipt_id", { description: "Representation boundary helper: compute the canonical sha256 id of an AttributionReceipt's unsigned core. Verifiers use this to detect id tampering.", inputSchema: z.object({
|
|
4030
|
+
receipt: z.any().describe("AttributionReceipt JSON (signatures ignored)"),
|
|
4031
|
+
}) }, async (args) => {
|
|
4027
4032
|
const { createHash } = await import('crypto');
|
|
4028
4033
|
const core = receiptCore(args.receipt);
|
|
4029
4034
|
const id = createHash('sha256').update(core).digest('hex');
|
|
4030
4035
|
return { content: [{ type: "text", text: JSON.stringify({ id, core_bytes: core.length }, null, 2) }] };
|
|
4031
4036
|
});
|
|
4032
4037
|
// ── ProvisionalStatement (commitment boundary) ──────────────────
|
|
4033
|
-
server.
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
}, async (args) => {
|
|
4038
|
+
server.registerTool("aps_create_provisional", { description: "Commitment boundary: emit a provisional statement for agent-to-agent negotiation. Default is non-binding until a PromotionEvent satisfies a PromotionPolicy. Dead-man expiry auto-withdraws.", inputSchema: z.object({
|
|
4039
|
+
author: z.string().describe("AgentDID/public key of the emitting agent"),
|
|
4040
|
+
author_principal: z.string().describe("PrincipalDID behind the author"),
|
|
4041
|
+
content: z.string().describe("Statement content (offer, position, claim)"),
|
|
4042
|
+
author_private_key: z.string().describe("Hex private key of author for signing"),
|
|
4043
|
+
gateway_id: z.string().optional().describe("Gateway id for timestamping (default: 'mcp')"),
|
|
4044
|
+
dead_man_ms: z.number().optional().describe("Dead-man expiry relative to now (ms). If elapsed without promotion/withdrawal, statement auto-withdraws."),
|
|
4045
|
+
}) }, async (args) => {
|
|
4041
4046
|
try {
|
|
4042
4047
|
const gw = args.gateway_id ?? 'mcp';
|
|
4043
4048
|
let dead_man_expires_at;
|
|
@@ -4061,11 +4066,11 @@ server.tool("aps_create_provisional", "Commitment boundary: emit a provisional s
|
|
|
4061
4066
|
return { content: [{ type: "text", text: safeError("createProvisional failed", e) }], isError: true };
|
|
4062
4067
|
}
|
|
4063
4068
|
});
|
|
4064
|
-
server.
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
}, async (args) => {
|
|
4069
|
+
server.registerTool("aps_promote_statement", { description: "Commitment boundary: promote a provisional statement to binding by attaching a PromotionEvent that satisfies the PromotionPolicy (m-of-n principal signatures). dead_man_elapsed cannot promote — it auto-withdraws via the dead-man path.", inputSchema: z.object({
|
|
4070
|
+
statement: z.any().describe("ProvisionalStatement from aps_create_provisional"),
|
|
4071
|
+
promotion_event: z.any().describe("PromotionEvent with kind, promoted_at, promoter, promoter_signature, policy_reference"),
|
|
4072
|
+
policy: z.any().describe("PromotionPolicy {id, required_signers, threshold, max_time_to_promote}"),
|
|
4073
|
+
}) }, async (args) => {
|
|
4069
4074
|
try {
|
|
4070
4075
|
const promoted = promoteStatement(args.statement, args.promotion_event, args.policy);
|
|
4071
4076
|
return { content: [{ type: "text", text: JSON.stringify({ promoted, is_binding: isBinding(promoted) }, null, 2) }] };
|
|
@@ -4074,18 +4079,18 @@ server.tool("aps_promote_statement", "Commitment boundary: promote a provisional
|
|
|
4074
4079
|
return { content: [{ type: "text", text: safeError("promoteStatement failed", e) }], isError: true };
|
|
4075
4080
|
}
|
|
4076
4081
|
});
|
|
4077
|
-
server.
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
}, async (args) => {
|
|
4082
|
+
server.registerTool("aps_verify_promotion", { description: "Commitment boundary: verify that a promoted statement's PromotionEvent cryptographically satisfies the PromotionPolicy (policy_reference match, promoter in required_signers, threshold, signature, max_time_to_promote, author-signature tamper check).", inputSchema: z.object({
|
|
4083
|
+
statement: z.any().describe("Promoted ProvisionalStatement"),
|
|
4084
|
+
policy: z.any().describe("PromotionPolicy to check against"),
|
|
4085
|
+
}) }, async (args) => {
|
|
4081
4086
|
const result = verifyPromotion(args.statement, args.policy);
|
|
4082
4087
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
4083
4088
|
});
|
|
4084
|
-
server.
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
}, async (args) => {
|
|
4089
|
+
server.registerTool("aps_withdraw_provisional", { description: "Commitment boundary: author withdraws their own provisional statement. Already-promoted statements cannot be withdrawn. Caller must supply the author's signature over the withdrawal payload (canonicalize({action:'withdraw', statement_id})).", inputSchema: z.object({
|
|
4090
|
+
statement: z.any().describe("ProvisionalStatement to withdraw"),
|
|
4091
|
+
author_signature: z.string().optional().describe("Hex Ed25519 signature. If omitted, provide author_private_key and the tool will sign for you."),
|
|
4092
|
+
author_private_key: z.string().optional().describe("If provided, tool signs the withdrawal payload with this key."),
|
|
4093
|
+
}) }, async (args) => {
|
|
4089
4094
|
try {
|
|
4090
4095
|
let sig = args.author_signature;
|
|
4091
4096
|
if (!sig) {
|
|
@@ -4103,12 +4108,12 @@ server.tool("aps_withdraw_provisional", "Commitment boundary: author withdraws t
|
|
|
4103
4108
|
}
|
|
4104
4109
|
});
|
|
4105
4110
|
// ── HumanEscalationFlag (escalation boundary) ───────────────────
|
|
4106
|
-
server.
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
}, async (args) => {
|
|
4111
|
+
server.registerTool("aps_check_escalation_required", { description: "Escalation boundary: check whether an action on a v2 delegation requires owner confirmation before execution. Returns {required, requirement?, reason?}. Use aps_record_owner_confirmation to clear the flag when required.", inputSchema: z.object({
|
|
4112
|
+
delegation: z.any().describe("V2Delegation with optional scope.escalation_requirements"),
|
|
4113
|
+
action_class: z.string().describe("Action class (e.g. 'org_creation', 'spend_above_threshold')"),
|
|
4114
|
+
action_details: z.any().optional().describe("Structured details; hashed for audit"),
|
|
4115
|
+
session_id: z.string().optional().describe("Session id (required for per_session scope)"),
|
|
4116
|
+
}) }, async (args) => {
|
|
4112
4117
|
const check = checkEscalationRequired(args.delegation, {
|
|
4113
4118
|
action_class: args.action_class,
|
|
4114
4119
|
action_details: args.action_details ?? {},
|
|
@@ -4116,13 +4121,13 @@ server.tool("aps_check_escalation_required", "Escalation boundary: check whether
|
|
|
4116
4121
|
});
|
|
4117
4122
|
return { content: [{ type: "text", text: JSON.stringify(check, null, 2) }] };
|
|
4118
4123
|
});
|
|
4119
|
-
server.
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
}, async (args) => {
|
|
4124
|
+
server.registerTool("aps_record_owner_confirmation", { description: "Escalation boundary: owner signs an OwnerConfirmation authorizing a flagged action. Builds the ConfirmationRequest and signs it in a single call. The confirmation is bound to action_details via hash and scoped (per_action / per_session / time_window).", inputSchema: z.object({
|
|
4125
|
+
delegation: z.any().describe("V2Delegation with escalation_requirements for this action class"),
|
|
4126
|
+
action_class: z.string().describe("Action class being confirmed"),
|
|
4127
|
+
action_details: z.any().describe("Structured action details — hashed and bound to the confirmation"),
|
|
4128
|
+
session_id: z.string().optional().describe("Session id (required for per_session scope)"),
|
|
4129
|
+
owner_private_key: z.string().describe("Hex private key of the delegation's owner (delegator)"),
|
|
4130
|
+
}) }, async (args) => {
|
|
4126
4131
|
try {
|
|
4127
4132
|
const request = requestOwnerConfirmation(args.delegation, {
|
|
4128
4133
|
action_class: args.action_class,
|
|
@@ -4145,23 +4150,23 @@ server.tool("aps_record_owner_confirmation", "Escalation boundary: owner signs a
|
|
|
4145
4150
|
// Spec: ATTRIBUTION-PRIMITIVE-v1.1.md. One signed object per action with
|
|
4146
4151
|
// four axis projections (D, P, G, C) that verify independently.
|
|
4147
4152
|
// ═══════════════════════════════════════
|
|
4148
|
-
server.
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
}, async (args) => {
|
|
4153
|
+
server.registerTool("aps_construct_attribution_primitive", { description: "Build and sign a four-axis AttributionPrimitive for an action. Axes: D (data sources), P (protocol modules), G (delegation chain), C (compute providers). Returns the complete signed object.", inputSchema: z.object({
|
|
4154
|
+
action: z.object({
|
|
4155
|
+
agentId: z.string(),
|
|
4156
|
+
actionType: z.string(),
|
|
4157
|
+
params: z.record(z.string(), z.any()),
|
|
4158
|
+
nonce: z.string(),
|
|
4159
|
+
}).describe("Action identity tuple; the action_ref is derived as sha256(canonical(this))"),
|
|
4160
|
+
axes: z.object({
|
|
4161
|
+
D: z.array(z.any()),
|
|
4162
|
+
P: z.array(z.any()),
|
|
4163
|
+
G: z.array(z.any()),
|
|
4164
|
+
C: z.array(z.any()),
|
|
4165
|
+
}).describe("Four-axis content. See spec §1.2 for entry shapes per axis."),
|
|
4166
|
+
issuer: z.string().describe("Issuer DID (gateway or agent producing the receipt)"),
|
|
4167
|
+
issuer_private_key: z.string().describe("Ed25519 private key hex that signs the envelope"),
|
|
4168
|
+
timestamp: z.string().optional().describe("ISO-8601 UTC with ms precision + Z (§2.5). Defaults to now()."),
|
|
4169
|
+
}) }, async (args) => {
|
|
4165
4170
|
try {
|
|
4166
4171
|
const primitive = constructAttributionPrimitive({
|
|
4167
4172
|
action: args.action,
|
|
@@ -4176,10 +4181,10 @@ server.tool("aps_construct_attribution_primitive", "Build and sign a four-axis A
|
|
|
4176
4181
|
return { content: [{ type: "text", text: safeError("constructAttributionPrimitive failed", e) }], isError: true };
|
|
4177
4182
|
}
|
|
4178
4183
|
});
|
|
4179
|
-
server.
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
}, async (args) => {
|
|
4184
|
+
server.registerTool("aps_project_attribution", { description: "Extract a single-axis projection from an AttributionPrimitive. The projection carries the axis content plus a two-hop Merkle path that lets a downstream verifier reconstruct the signed root without seeing the other three axes. axis: 'D' | 'P' | 'G' | 'C'.", inputSchema: z.object({
|
|
4185
|
+
primitive: z.any().describe("An AttributionPrimitive (from aps_construct_attribution_primitive)"),
|
|
4186
|
+
axis: z.enum(["D", "P", "G", "C"]).describe("Axis to project"),
|
|
4187
|
+
}) }, async (args) => {
|
|
4183
4188
|
try {
|
|
4184
4189
|
const projection = projectAttribution(args.primitive, args.axis);
|
|
4185
4190
|
return { content: [{ type: "text", text: JSON.stringify(projection, null, 2) }] };
|
|
@@ -4188,10 +4193,10 @@ server.tool("aps_project_attribution", "Extract a single-axis projection from an
|
|
|
4188
4193
|
return { content: [{ type: "text", text: safeError("projectAttribution failed", e) }], isError: true };
|
|
4189
4194
|
}
|
|
4190
4195
|
});
|
|
4191
|
-
server.
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
}, async (args) => {
|
|
4196
|
+
server.registerTool("aps_verify_attribution_projection", { description: "Verify a single-axis AttributionProjection under the issuer's Ed25519 public key. Returns {valid: true} or {valid: false, reason: 'INVALID_AXIS_TAG'|'MERKLE_MISMATCH'|'SIGNATURE_INVALID'|'MALFORMED'}. Verification is purely local — no other axes required.", inputSchema: z.object({
|
|
4197
|
+
projection: z.any().describe("An AttributionProjection (from aps_project_attribution)"),
|
|
4198
|
+
issuer_public_key: z.string().describe("Issuer Ed25519 public key hex"),
|
|
4199
|
+
}) }, async (args) => {
|
|
4195
4200
|
try {
|
|
4196
4201
|
const result = verifyAttributionProjection(args.projection, args.issuer_public_key);
|
|
4197
4202
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
@@ -4200,10 +4205,10 @@ server.tool("aps_verify_attribution_projection", "Verify a single-axis Attributi
|
|
|
4200
4205
|
return { content: [{ type: "text", text: safeError("verifyAttributionProjection failed", e) }], isError: true };
|
|
4201
4206
|
}
|
|
4202
4207
|
});
|
|
4203
|
-
server.
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
}, async (args) => {
|
|
4208
|
+
server.registerTool("aps_verify_attribution_primitive", { description: "End-to-end verify of a full AttributionPrimitive: constructs projections for all four axes and verifies each one. Useful as a post-construction sanity check or for verifying a primitive received from a peer.", inputSchema: z.object({
|
|
4209
|
+
primitive: z.any().describe("An AttributionPrimitive"),
|
|
4210
|
+
issuer_public_key: z.string().describe("Issuer Ed25519 public key hex"),
|
|
4211
|
+
}) }, async (args) => {
|
|
4207
4212
|
try {
|
|
4208
4213
|
const result = verifyAttributionPrimitive(args.primitive, args.issuer_public_key);
|
|
4209
4214
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
@@ -4212,10 +4217,10 @@ server.tool("aps_verify_attribution_primitive", "End-to-end verify of a full Att
|
|
|
4212
4217
|
return { content: [{ type: "text", text: safeError("verifyAttributionPrimitive failed", e) }], isError: true };
|
|
4213
4218
|
}
|
|
4214
4219
|
});
|
|
4215
|
-
server.
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
}, async (args) => {
|
|
4220
|
+
server.registerTool("aps_check_projection_consistency", { description: "Cross-projection consistency check (§2.4): given two projections, confirm they originate from the same signed receipt. Returns {same_receipt: true} or {same_receipt: false, reason: 'DIFFERENT_ACTIONS'|'DIFFERENT_RECEIPTS'|'DIFFERENT_SIGNATURES'|'METADATA_MISMATCH'}.", inputSchema: z.object({
|
|
4221
|
+
projection_a: z.any().describe("First AttributionProjection"),
|
|
4222
|
+
projection_b: z.any().describe("Second AttributionProjection"),
|
|
4223
|
+
}) }, async (args) => {
|
|
4219
4224
|
try {
|
|
4220
4225
|
const result = checkProjectionConsistency(args.projection_a, args.projection_b);
|
|
4221
4226
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
@@ -4224,12 +4229,12 @@ server.tool("aps_check_projection_consistency", "Cross-projection consistency ch
|
|
|
4224
4229
|
return { content: [{ type: "text", text: safeError("checkProjectionConsistency failed", e) }], isError: true };
|
|
4225
4230
|
}
|
|
4226
4231
|
});
|
|
4227
|
-
server.
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
}, async (args) => {
|
|
4232
|
+
server.registerTool("aps_compute_attribution_action_ref", { description: "Derive the action_ref (hex sha256) for an action tuple. action_ref is the content-addressed anchor that all four axis projections bind to. Useful for indexing primitives by action without constructing the full primitive.", inputSchema: z.object({
|
|
4233
|
+
agentId: z.string(),
|
|
4234
|
+
actionType: z.string(),
|
|
4235
|
+
params: z.record(z.string(), z.any()),
|
|
4236
|
+
nonce: z.string(),
|
|
4237
|
+
}) }, async (args) => {
|
|
4233
4238
|
try {
|
|
4234
4239
|
const action_ref = computeAttributionActionRef({
|
|
4235
4240
|
agentId: args.agentId,
|
|
@@ -4249,19 +4254,19 @@ server.tool("aps_compute_attribution_action_ref", "Derive the action_ref (hex sh
|
|
|
4249
4254
|
// compute canonical D/C axis weights from raw per-source / per-provider records,
|
|
4250
4255
|
// then hand the resulting axis entries to aps_construct_attribution_primitive.
|
|
4251
4256
|
// ═══════════════════════════════════════
|
|
4252
|
-
server.
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
}, async (args) => {
|
|
4257
|
+
server.registerTool("aps_compute_data_axis_weights", { description: "Compute the D-axis fractional weight vector from a list of AccessReceipt records with role, timestamp, and content length. Returns canonical DataAxisEntry[] with 6-digit decimal contribution_weight strings that sum to ~1.0 and feed directly into aps_construct_attribution_primitive. Empty input → empty array; all-zero raw weights → error. Weights = role × recency_decay × length_weight, normalized per spec BUILD-B §'The D-axis formula'. Parameter names match the SDK: `sources`, `action_timestamp`, optional `profile`.", inputSchema: z.object({
|
|
4258
|
+
sources: z.array(z.object({
|
|
4259
|
+
source_did: z.string(),
|
|
4260
|
+
access_receipt_hash: z.string(),
|
|
4261
|
+
role: z.enum([
|
|
4262
|
+
'primary_source', 'supporting_evidence', 'context_only', 'background_retrieval',
|
|
4263
|
+
]),
|
|
4264
|
+
timestamp: z.string().describe("ISO-8601 UTC with millisecond precision + Z (t_source)"),
|
|
4265
|
+
content_length: z.number().nonnegative().describe("Tokens"),
|
|
4266
|
+
})).describe("Per-source records with retrieval metadata"),
|
|
4267
|
+
action_timestamp: z.string().describe("ISO-8601 UTC ms when the action ran (t_action)"),
|
|
4268
|
+
profile: z.any().optional().describe("Optional WeightProfile override; defaults to DEFAULT_WEIGHT_PROFILE"),
|
|
4269
|
+
}) }, async (args) => {
|
|
4265
4270
|
try {
|
|
4266
4271
|
const entries = computeDataAxisWeights(args.sources, {
|
|
4267
4272
|
action_timestamp: args.action_timestamp,
|
|
@@ -4273,15 +4278,15 @@ server.tool("aps_compute_data_axis_weights", "Compute the D-axis fractional weig
|
|
|
4273
4278
|
return { content: [{ type: "text", text: safeError("computeDataAxisWeights failed", e) }], isError: true };
|
|
4274
4279
|
}
|
|
4275
4280
|
});
|
|
4276
|
-
server.
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
}, async (args) => {
|
|
4281
|
+
server.registerTool("aps_compute_compute_axis_weights", { description: "Compute the C-axis fractional weight vector from a list of inference billing records (prompt_tokens, completion_tokens). Returns canonical ComputeAxisEntry[] with 6-digit decimal compute_share strings that sum to ~1.0 and feed directly into aps_construct_attribution_primitive. Weights = prompt_tokens + completion_tokens × COMPLETION_MULTIPLIER (default 3.0), normalized per spec BUILD-B §'The C-axis formula'. Parameter names match the SDK: `providers`, optional `profile`.", inputSchema: z.object({
|
|
4282
|
+
providers: z.array(z.object({
|
|
4283
|
+
provider_did: z.string(),
|
|
4284
|
+
hardware_attestation_hash: z.string(),
|
|
4285
|
+
prompt_tokens: z.number().nonnegative(),
|
|
4286
|
+
completion_tokens: z.number().nonnegative(),
|
|
4287
|
+
})).describe("Per-provider billing records"),
|
|
4288
|
+
profile: z.any().optional().describe("Optional WeightProfile override; defaults to DEFAULT_WEIGHT_PROFILE"),
|
|
4289
|
+
}) }, async (args) => {
|
|
4285
4290
|
try {
|
|
4286
4291
|
const entries = computeComputeAxisWeights(args.providers, { profile: args.profile });
|
|
4287
4292
|
return { content: [{ type: "text", text: JSON.stringify(entries, null, 2) }] };
|
|
@@ -4306,13 +4311,13 @@ const SettlementPeriodSchema = z.object({
|
|
|
4306
4311
|
t1: z.string().describe("Period end (canonical ISO-8601 UTC ms + Z). Exclusive."),
|
|
4307
4312
|
period_id: z.string().describe("Gateway-scoped period identifier"),
|
|
4308
4313
|
});
|
|
4309
|
-
server.
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
}, async (args) => {
|
|
4314
|
+
server.registerTool("aps_aggregate_settlement", { description: "Aggregate a batch of Attribution Primitives over a half-open settlement period [t0, t1) into a signed SettlementRecord. Each axis (D, P, G, C) produces a per-contributor total with a balanced-Merkle commitment. Residual buckets pool sub-threshold contributors per Build A §4.1. Output is a fully signed record ready for third-party verification. Spec: BUILD-C-SETTLEMENT-PIPELINE.md.", inputSchema: z.object({
|
|
4315
|
+
receipts: z.array(z.any()).describe("Array of AttributionPrimitives to aggregate"),
|
|
4316
|
+
period: SettlementPeriodSchema,
|
|
4317
|
+
gateway_did: z.string().describe("Gateway DID that signs the record"),
|
|
4318
|
+
gateway_private_key: z.string().describe("Ed25519 gateway private key (hex)"),
|
|
4319
|
+
issued_at: z.string().optional().describe("Override issued_at (canonical ISO-8601 UTC ms + Z); defaults to now"),
|
|
4320
|
+
}) }, async (args) => {
|
|
4316
4321
|
try {
|
|
4317
4322
|
const unsigned = aggregateAttributionPrimitives(args.receipts, args.period, {
|
|
4318
4323
|
gateway_did: args.gateway_did,
|
|
@@ -4326,11 +4331,11 @@ server.tool("aps_aggregate_settlement", "Aggregate a batch of Attribution Primit
|
|
|
4326
4331
|
return { content: [{ type: "text", text: safeError("aggregateSettlement failed", e) }], isError: true };
|
|
4327
4332
|
}
|
|
4328
4333
|
});
|
|
4329
|
-
server.
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
}, async (args) => {
|
|
4334
|
+
server.registerTool("aps_verify_settlement", { description: "Verify a signed SettlementRecord under S1-S5 (signature, Merkle roots, conservation, residual shape, optional input-receipts cross-check). S3 conservation is the strongest invariant: a gateway cannot inflate or suppress any contributor's share without breaking it. Returns {valid: true} or {valid: false, reason, detail}. Pass inputReceipts to also recompute input_receipts_hash.", inputSchema: z.object({
|
|
4335
|
+
record: z.any().describe("A signed SettlementRecord"),
|
|
4336
|
+
gateway_public_key: z.string().describe("Gateway Ed25519 public key hex"),
|
|
4337
|
+
input_receipts: z.array(z.any()).optional().describe("Optional — the input Attribution Primitives that fed the settlement. When supplied, S5 cross-checks input_receipts_hash and verifies each receipt individually."),
|
|
4338
|
+
}) }, async (args) => {
|
|
4334
4339
|
try {
|
|
4335
4340
|
const result = verifySettlementRecord(args.record, {
|
|
4336
4341
|
gatewayPublicKeyHex: args.gateway_public_key,
|
|
@@ -4342,11 +4347,11 @@ server.tool("aps_verify_settlement", "Verify a signed SettlementRecord under S1-
|
|
|
4342
4347
|
return { content: [{ type: "text", text: safeError("verifySettlement failed", e) }], isError: true };
|
|
4343
4348
|
}
|
|
4344
4349
|
});
|
|
4345
|
-
server.
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
}, async (args) => {
|
|
4350
|
+
server.registerTool("aps_build_contributor_query", { description: "Build a contributor-query response: given a signed SettlementRecord and a contributor DID, return per-axis (total_weight, contribution_count, merkle_path, axis_root) plus the full signed record so a third party can verify the contributor's share end-to-end without trusting the gateway beyond its public key. Returns null if the contributor has no share in the period.", inputSchema: z.object({
|
|
4351
|
+
record: z.any().describe("A signed SettlementRecord"),
|
|
4352
|
+
contributor_did: z.string().describe("Contributor DID (data source, compute provider, governance signer, or protocol module identifier)"),
|
|
4353
|
+
gateway_jwks: z.string().optional().describe("Advisory JWKS URL; not part of the signed material"),
|
|
4354
|
+
}) }, async (args) => {
|
|
4350
4355
|
try {
|
|
4351
4356
|
const response = buildContributorQueryResponse(args.record, args.contributor_did, {
|
|
4352
4357
|
gateway_jwks: args.gateway_jwks,
|
|
@@ -4362,21 +4367,21 @@ server.tool("aps_build_contributor_query", "Build a contributor-query response:
|
|
|
4362
4367
|
// ═══════════════════════════════════════
|
|
4363
4368
|
// Mutual Authentication v1 tools (SDK v2.2.0)
|
|
4364
4369
|
// ═══════════════════════════════════════
|
|
4365
|
-
server.
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
}, async (args) => {
|
|
4370
|
+
server.registerTool("mutualAuthBuildCertificate", { description: "Build and sign a mutual-auth certificate identifying an agent or information system. Returns the signed MutualAuthCertificate object ready to carry into a handshake. The issuer's Ed25519 private key (hex) signs over the canonical (JCS) form.", inputSchema: z.object({
|
|
4371
|
+
role: z.enum(["agent", "information_system"]).describe("Role of the subject this cert identifies"),
|
|
4372
|
+
subject_id: z.string().describe("Stable subject identifier (e.g., agent DID, IS endpoint URL)"),
|
|
4373
|
+
subject_pubkey_hex: z.string().describe("Ed25519 public key (hex) of the subject"),
|
|
4374
|
+
issuer_id: z.string().describe("Issuer identifier"),
|
|
4375
|
+
issuer_role: z.enum(["agent", "information_system", "trust_anchor"]).describe("Role of the issuer"),
|
|
4376
|
+
issuer_pubkey_hex: z.string().describe("Ed25519 public key (hex) of the issuer"),
|
|
4377
|
+
issuer_privkey_hex: z.string().describe("Ed25519 private key (hex) of the issuer — used to sign"),
|
|
4378
|
+
binding: z.string().describe("For an agent: the APS agent_id. For an IS: the resource domain (e.g., mcp://api.bank.com)"),
|
|
4379
|
+
not_before: z.number().describe("Earliest valid time (unix ms)"),
|
|
4380
|
+
not_after: z.number().describe("Latest valid time (unix ms)"),
|
|
4381
|
+
supported_versions: z.array(z.string()).describe("Protocol versions supported, highest first (e.g., ['1.0'])"),
|
|
4382
|
+
attestation_grade: z.union([z.literal(0), z.literal(1), z.literal(2), z.literal(3)]).optional().describe("For agents: APS attestation grade 0-3"),
|
|
4383
|
+
capabilities: z.array(z.string()).optional().describe("Optional capability tags"),
|
|
4384
|
+
}) }, async (args) => {
|
|
4380
4385
|
try {
|
|
4381
4386
|
const unsigned = buildCertificate({
|
|
4382
4387
|
role: args.role,
|
|
@@ -4403,15 +4408,15 @@ server.tool("mutualAuthBuildCertificate", "Build and sign a mutual-auth certific
|
|
|
4403
4408
|
return { content: [{ type: "text", text: safeError("mutualAuthBuildCertificate failed", e) }], isError: true };
|
|
4404
4409
|
}
|
|
4405
4410
|
});
|
|
4406
|
-
server.
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
}, async (args) => {
|
|
4411
|
+
server.registerTool("mutualAuthVerifyAttest", { description: "Verify a MutualAuthAttest against policy and trust anchors. Runs all 10 verification checks: signature, version negotiation, nonce match, timestamp freshness, certificate validity, issuer anchor check, binding constraints, downgrade detection, attestation grade policy, capability policy. Returns ok:true on success or a failure reason on rejection.", inputSchema: z.object({
|
|
4412
|
+
attest: z.any().describe("MutualAuthAttest to verify"),
|
|
4413
|
+
expected_peer_nonce_b64: z.string().describe("The nonce the peer sent in their prior hello or attest"),
|
|
4414
|
+
expected_own_nonce_b64: z.string().describe("The nonce we sent in our own prior hello or attest"),
|
|
4415
|
+
policy: z.any().describe("MutualAuthPolicy (accepted_versions, min_agent_grade, required_capabilities, max_clock_skew_ms, max_session_ms)"),
|
|
4416
|
+
trust_anchors: z.array(z.any()).describe("TrustAnchor[] — local trusted roots"),
|
|
4417
|
+
revoked_anchor_ids: z.array(z.string()).optional().describe("IDs of anchors revoked since the bundle was issued"),
|
|
4418
|
+
now_ms: z.number().optional().describe("Current unix ms — defaults to Date.now()"),
|
|
4419
|
+
}) }, async (args) => {
|
|
4415
4420
|
try {
|
|
4416
4421
|
const res = verifyAttest({
|
|
4417
4422
|
attest: args.attest,
|
|
@@ -4430,12 +4435,12 @@ server.tool("mutualAuthVerifyAttest", "Verify a MutualAuthAttest against policy
|
|
|
4430
4435
|
return { content: [{ type: "text", text: safeError("mutualAuthVerifyAttest failed", e) }], isError: true };
|
|
4431
4436
|
}
|
|
4432
4437
|
});
|
|
4433
|
-
server.
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
}, async (args) => {
|
|
4438
|
+
server.registerTool("mutualAuthDeriveSession", { description: "Derive the shared mutual-auth session record from both sides' Attests. Both parties MUST compute identical session_id given identical inputs (canonical JCS + sha256 of chosen_version, both cert ids, both nonces). Returns a MutualAuthSession with session_id + both certificates + expiry bounds, or failure reason.", inputSchema: z.object({
|
|
4439
|
+
agent_attest: z.any().describe("The agent's MutualAuthAttest"),
|
|
4440
|
+
is_attest: z.any().describe("The information system's MutualAuthAttest"),
|
|
4441
|
+
policy: z.any().describe("MutualAuthPolicy"),
|
|
4442
|
+
now_ms: z.number().optional().describe("Current unix ms — defaults to Date.now()"),
|
|
4443
|
+
}) }, async (args) => {
|
|
4439
4444
|
try {
|
|
4440
4445
|
const res = deriveSession(args.agent_attest, args.is_attest, args.policy, args.now_ms ?? Date.now());
|
|
4441
4446
|
return {
|
|
@@ -4446,11 +4451,11 @@ server.tool("mutualAuthDeriveSession", "Derive the shared mutual-auth session re
|
|
|
4446
4451
|
return { content: [{ type: "text", text: safeError("mutualAuthDeriveSession failed", e) }], isError: true };
|
|
4447
4452
|
}
|
|
4448
4453
|
});
|
|
4449
|
-
server.
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
}, async (args) => {
|
|
4454
|
+
server.registerTool("mutualAuthVerifyTrustBundle", { description: "Verify a TrustAnchorBundle signature and freshness. Caller supplies the list of trusted publisher public keys (root configuration). Returns ok:true on success or failure reason (untrusted_publisher, signature_invalid, bundle_expired, not_yet_valid).", inputSchema: z.object({
|
|
4455
|
+
bundle: z.any().describe("TrustAnchorBundle to verify"),
|
|
4456
|
+
trusted_publisher_pubkeys_hex: z.array(z.string()).describe("List of Ed25519 pubkeys (hex) authorized to publish bundles"),
|
|
4457
|
+
now_ms: z.number().optional().describe("Current unix ms — defaults to Date.now()"),
|
|
4458
|
+
}) }, async (args) => {
|
|
4454
4459
|
try {
|
|
4455
4460
|
const res = verifyBundle(args.bundle, args.trusted_publisher_pubkeys_hex, args.now_ms ?? Date.now());
|
|
4456
4461
|
return {
|
|
@@ -4471,23 +4476,23 @@ server.tool("mutualAuthVerifyTrustBundle", "Verify a TrustAnchorBundle signature
|
|
|
4471
4476
|
// expose the four protocol roles (sink, subject, gateway) so any caller
|
|
4472
4477
|
// can drive the cycle end-to-end against this single process.
|
|
4473
4478
|
// ═══════════════════════════════════════════════════════════════
|
|
4474
|
-
server.
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
}, async (args) => {
|
|
4479
|
+
server.registerTool("aps_capability_issue_challenge", { description: "v0.1 capability-token sink challenge (M1). Sink issues a signed canonical action statement. Returns the SinkChallenge and its challenge_hash. Used to bind the gateway's later policy evaluation to a specific action the sink authored. Search keywords: capability token, sink challenge, M1.", inputSchema: z.object({
|
|
4480
|
+
sink_id: z.string().describe("DID of the sink issuing the challenge"),
|
|
4481
|
+
subject_id: z.string().describe("DID of the subject the challenge is addressed to"),
|
|
4482
|
+
action: z.object({
|
|
4483
|
+
kind: z.string(),
|
|
4484
|
+
target: z.string(),
|
|
4485
|
+
parameters: z.record(z.string(), z.any()),
|
|
4486
|
+
resource_version: z.string(),
|
|
4487
|
+
}).describe("Canonical action statement"),
|
|
4488
|
+
sink_private_key: z.string().describe("Sink Ed25519 private key (hex)"),
|
|
4489
|
+
sink_public_key: z.string().describe("Sink Ed25519 public key (hex)"),
|
|
4490
|
+
validity_seconds: z.number().int().positive().optional(),
|
|
4491
|
+
required_policy_freshness: z.object({
|
|
4492
|
+
max_age_seconds: z.number().int().nonnegative(),
|
|
4493
|
+
beacon_hash_required: z.boolean(),
|
|
4494
|
+
}).optional(),
|
|
4495
|
+
}) }, async (args) => {
|
|
4491
4496
|
try {
|
|
4492
4497
|
const sinkKey = {
|
|
4493
4498
|
publicKey: args.sink_public_key,
|
|
@@ -4513,23 +4518,23 @@ server.tool("aps_capability_issue_challenge", "v0.1 capability-token sink challe
|
|
|
4513
4518
|
return { content: [{ type: "text", text: safeError("aps_capability_issue_challenge failed", e) }], isError: true };
|
|
4514
4519
|
}
|
|
4515
4520
|
});
|
|
4516
|
-
server.
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
}, async (args) => {
|
|
4521
|
+
server.registerTool("aps_capability_evaluate_authority", { description: "v0.1 capability-token authority evaluation request (M2). Subject signs a request carrying the sink's M1, the delegation chain, and a revealed authority-token preimage. The gateway consumes this to decide permit/deny. Search keywords: capability token, authority evaluation, M2.", inputSchema: z.object({
|
|
4522
|
+
challenge: z.any().describe("SinkChallenge object from M1"),
|
|
4523
|
+
delegation_chain: z.array(z.any()).describe("v2.x delegation envelopes"),
|
|
4524
|
+
authority_token: z.object({
|
|
4525
|
+
token_preimage: z.string(),
|
|
4526
|
+
merkle_proof: z.array(z.string()),
|
|
4527
|
+
scope_class: z.string(),
|
|
4528
|
+
}),
|
|
4529
|
+
freshness_beacon: z.object({
|
|
4530
|
+
delegator_id: z.string(),
|
|
4531
|
+
beacon_timestamp: z.string(),
|
|
4532
|
+
beacon_signature: z.string(),
|
|
4533
|
+
}),
|
|
4534
|
+
subject_private_key: z.string().describe("Subject Ed25519 private key (hex)"),
|
|
4535
|
+
subject_public_key: z.string().describe("Subject Ed25519 public key (hex)"),
|
|
4536
|
+
delegation_chain_root: z.string().optional().describe("Override; otherwise computed from chain"),
|
|
4537
|
+
}) }, async (args) => {
|
|
4533
4538
|
try {
|
|
4534
4539
|
const subjectKey = {
|
|
4535
4540
|
publicKey: args.subject_public_key,
|
|
@@ -4551,14 +4556,14 @@ server.tool("aps_capability_evaluate_authority", "v0.1 capability-token authorit
|
|
|
4551
4556
|
return { content: [{ type: "text", text: safeError("aps_capability_evaluate_authority failed", e) }], isError: true };
|
|
4552
4557
|
}
|
|
4553
4558
|
});
|
|
4554
|
-
server.
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
}, async (args) => {
|
|
4559
|
+
server.registerTool("aps_capability_mint_receipt", { description: "v0.1 capability-token gateway receipt (M3). Gateway signs a permit or deny over the sink's exact challenge_hash. Echoes the M2 delegation_chain_root so the sink can verify the gateway saw the same chain the subject committed to. Search keywords: capability token, challenge receipt, gateway receipt, M3.", inputSchema: z.object({
|
|
4560
|
+
request: z.any().describe("AuthorityEvaluationRequest from M2"),
|
|
4561
|
+
decision: z.enum(["permit", "deny"]),
|
|
4562
|
+
deny_reason: z.string().optional(),
|
|
4563
|
+
policy_digest: z.string().describe("SHA-256 of the policy bundle used in evaluation"),
|
|
4564
|
+
gateway_private_key: z.string(),
|
|
4565
|
+
gateway_public_key: z.string(),
|
|
4566
|
+
}) }, async (args) => {
|
|
4562
4567
|
try {
|
|
4563
4568
|
const gatewayKey = {
|
|
4564
4569
|
publicKey: args.gateway_public_key,
|
|
@@ -4579,19 +4584,19 @@ server.tool("aps_capability_mint_receipt", "v0.1 capability-token gateway receip
|
|
|
4579
4584
|
return { content: [{ type: "text", text: safeError("aps_capability_mint_receipt failed", e) }], isError: true };
|
|
4580
4585
|
}
|
|
4581
4586
|
});
|
|
4582
|
-
server.
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
}, async (args) => {
|
|
4587
|
+
server.registerTool("aps_capability_sign_effect", { description: "v0.1 capability-token sink effect receipt (M4). Sink consumes the token preimage from the gateway's M3 (rejecting on nullifier replay), executes the action, and signs an EffectReceipt binding the consumed token to the result. The (M1, M3, M4) tuple is the full attestation record. Search keywords: capability token, effect receipt, M4, sink attestation.", inputSchema: z.object({
|
|
4588
|
+
challenge: z.any().describe("Original SinkChallenge from M1 (for binding verification)"),
|
|
4589
|
+
challenge_receipt: z.any().describe("ChallengeReceipt from M3"),
|
|
4590
|
+
effect: z.object({
|
|
4591
|
+
executed_at: z.string(),
|
|
4592
|
+
outcome: z.enum(["success", "failure", "partial"]),
|
|
4593
|
+
result_digest: z.string(),
|
|
4594
|
+
}),
|
|
4595
|
+
sink_private_key: z.string(),
|
|
4596
|
+
sink_public_key: z.string(),
|
|
4597
|
+
gateway_public_key: z.string().describe("Used to verify M3 before consuming the token"),
|
|
4598
|
+
expected_delegation_chain_root: z.string().optional().describe("If omitted, falls back to the receipt's own root"),
|
|
4599
|
+
}) }, async (args) => {
|
|
4595
4600
|
try {
|
|
4596
4601
|
const sinkKey = {
|
|
4597
4602
|
publicKey: args.sink_public_key,
|
|
@@ -4649,7 +4654,7 @@ server.tool("aps_capability_sign_effect", "v0.1 capability-token sink effect rec
|
|
|
4649
4654
|
return { content: [{ type: "text", text: safeError("aps_capability_sign_effect failed", e) }], isError: true };
|
|
4650
4655
|
}
|
|
4651
4656
|
});
|
|
4652
|
-
server.
|
|
4657
|
+
server.registerPrompt("coordination_role", { description: "Get instructions for your assigned coordination role", argsSchema: z.object({}) }, async () => {
|
|
4653
4658
|
const role = state.agentRole || 'default';
|
|
4654
4659
|
const instructions = ROLE_PROMPTS[role] || ROLE_PROMPTS['default'];
|
|
4655
4660
|
return {
|
|
@@ -4681,8 +4686,17 @@ async function main() {
|
|
|
4681
4686
|
const roleInfo = state.agentRole
|
|
4682
4687
|
? ` | Role: ${state.agentRole}`
|
|
4683
4688
|
: ' | No role (call identify or set AGENT_KEY)';
|
|
4684
|
-
|
|
4685
|
-
|
|
4689
|
+
// serveStdio serves both the 2025 and 2026-07-28 eras from one entry. The
|
|
4690
|
+
// default legacy posture on stdio is 'serve': the connection is pinned to an
|
|
4691
|
+
// instance from this factory on its opening request.
|
|
4692
|
+
//
|
|
4693
|
+
// The factory returns the module's single `server`. Every registration in
|
|
4694
|
+
// this file is a module-scope call against that instance, so there is no
|
|
4695
|
+
// second instance to hand out. That is safe here because one stdio process
|
|
4696
|
+
// serves exactly one connection: the factory was measured being invoked once
|
|
4697
|
+
// per process for a 2025 initialize, a modern server/discover opening, and a
|
|
4698
|
+
// modern tools/call opening alike.
|
|
4699
|
+
serveStdio(() => server);
|
|
4686
4700
|
console.error(`Agent Passport MCP Server v2.0 running${roleInfo}`);
|
|
4687
4701
|
console.error(`Tasks loaded: ${state.taskUnits.size} | Agora messages: ${state.agoraFeed.messages.length}`);
|
|
4688
4702
|
}
|