agent-passport-system-mcp 2.26.0 → 3.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 +5 -5
- package/build/index.js +180 -738
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -12,13 +12,13 @@ Enforcement and accountability layer for AI agents. Bring your own identity. 20
|
|
|
12
12
|
APS_PROFILE=essential npx agent-passport-system-mcp
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
`essential` is the default profile — the
|
|
15
|
+
`essential` is the default profile — the 20 tools 90% of integrations need. Set `APS_PROFILE=full` for all 154 tools.
|
|
16
16
|
|
|
17
17
|
Available profiles: essential (default), identity, governance, coordination, commerce, data, gateway, comms, minimal, full.
|
|
18
18
|
|
|
19
19
|
> **For AI agents:** visit [aeoess.com/llms.txt](https://aeoess.com/llms.txt) for machine-readable documentation or [llms-full.txt](https://aeoess.com/llms-full.txt) for the complete technical reference. MCP discovery: [.well-known/mcp.json](https://aeoess.com/.well-known/mcp.json).
|
|
20
20
|
|
|
21
|
-
Works with any MCP client: Claude Desktop, Claude Code, Cursor, Windsurf, and more. Full surface area under `APS_PROFILE=full`:
|
|
21
|
+
Works with any MCP client: Claude Desktop, Claude Code, Cursor, Windsurf, and more. Full surface area under `APS_PROFILE=full`: 154 tools across 123 modules (84 core + 39 v2 constitutional governance). Independently cited by [PDR in Production (Nanook & Gerundium, UBC)](https://doi.org/10.5281/zenodo.19323172).
|
|
22
22
|
|
|
23
23
|
## Quick Start
|
|
24
24
|
|
|
@@ -69,7 +69,7 @@ Or for remote SSE:
|
|
|
69
69
|
```
|
|
70
70
|
</details>
|
|
71
71
|
|
|
72
|
-
## Tools (
|
|
72
|
+
## Tools (154)
|
|
73
73
|
|
|
74
74
|
### Identity (Layer 1) — 5 tools
|
|
75
75
|
|
|
@@ -216,8 +216,8 @@ Layer 1 — Agent Passport Protocol (Ed25519 identity)
|
|
|
216
216
|
|
|
217
217
|
## Links
|
|
218
218
|
|
|
219
|
-
- npm SDK: [agent-passport-system](https://www.npmjs.com/package/agent-passport-system) (
|
|
220
|
-
- Python SDK: [agent-passport-system](https://pypi.org/project/agent-passport-system/) (v0.
|
|
219
|
+
- npm SDK: [agent-passport-system](https://www.npmjs.com/package/agent-passport-system) (v2.0.0, 2326 tests)
|
|
220
|
+
- Python SDK: [agent-passport-system](https://pypi.org/project/agent-passport-system/) (v0.15.0)
|
|
221
221
|
- Paper (Protocol): [doi.org/10.5281/zenodo.18749779](https://doi.org/10.5281/zenodo.18749779)
|
|
222
222
|
- Paper (Faceted Narrowing): [doi.org/10.5281/zenodo.19260073](https://doi.org/10.5281/zenodo.19260073)
|
|
223
223
|
- Paper (Behavioral Derivation Rights): [doi.org/10.5281/zenodo.19476002](https://doi.org/10.5281/zenodo.19476002)
|
package/build/index.js
CHANGED
|
@@ -18,9 +18,7 @@ import { readFileSync, writeFileSync, existsSync } from "node:fs";
|
|
|
18
18
|
import { join, resolve } from "node:path";
|
|
19
19
|
import {
|
|
20
20
|
// Identity + Crypto
|
|
21
|
-
joinSocialContract, generateKeyPair,
|
|
22
|
-
// Agent Context (enforcement middleware)
|
|
23
|
-
createAgentContext,
|
|
21
|
+
joinSocialContract, generateKeyPair, sign, countersignPassport, verifyIssuerSignature, isIssuerVerified,
|
|
24
22
|
// Coordination (Layer 6)
|
|
25
23
|
createTaskBrief, assignTask, acceptTask, submitEvidence, reviewEvidence, handoffEvidence, submitDeliverable, completeTask, createTaskUnit, getTaskStatus, validateTaskUnit,
|
|
26
24
|
// Delegation (Layer 1)
|
|
@@ -30,35 +28,28 @@ createAgoraMessage, createFeed, appendToFeed, getThread, getByTopic, getTopics,
|
|
|
30
28
|
// Values/Policy (Layer 2 + 5)
|
|
31
29
|
loadFloor, attestFloor, createActionIntent, evaluateIntent, FloorValidatorV1,
|
|
32
30
|
// Commerce (Layer 8)
|
|
33
|
-
commercePreflight, createCommerceDelegation, getSpendSummary, requestHumanApproval,
|
|
31
|
+
commercePreflight, createCommerceDelegation, getSpendSummary, requestHumanApproval,
|
|
34
32
|
// Principal Identity
|
|
35
33
|
createPrincipalIdentity, endorseAgent, verifyEndorsement, revokeEndorsement, createDisclosure, createFleet, addToFleet, getFleetStatus, revokeFromFleet,
|
|
36
34
|
// Reputation-Gated Authority (Layer 9)
|
|
37
|
-
computeEffectiveScore, createScopedReputation, resolveAuthorityTier, checkTierForIntent, advisoryTierPrecheck, createPromotionReview, updateReputationFromResult, DEFAULT_TIERS,
|
|
38
|
-
// Intent Network (Agent-Mediated Matching) — card creation only, API handles persistence
|
|
39
|
-
createIntentCard,
|
|
35
|
+
computeEffectiveScore, createScopedReputation, resolveAuthorityTier, checkTierForIntent, advisoryTierPrecheck, createPromotionReview, updateReputationFromResult, DEFAULT_TIERS,
|
|
40
36
|
// v2: Constitutional Governance Extensions
|
|
41
37
|
createPolicyContext, createArtifactProvenance,
|
|
42
38
|
// v2: Delegation Versioning
|
|
43
39
|
createV2Delegation, supersedeV2Delegation,
|
|
44
40
|
// v2: Outcome Registration
|
|
45
41
|
createV2OutcomeRecord, addV2PrincipalReport, getV2EffectiveDivergence,
|
|
46
|
-
// v2: Anomaly Detection
|
|
47
|
-
recordV2Action, checkV2FirstMaxAuthority, computeV2ConcentrationMetrics,
|
|
48
42
|
// v2: Emergency Pathways
|
|
49
|
-
defineV2EmergencyPathway, activateV2Emergency,
|
|
50
|
-
// v2: Migration
|
|
51
|
-
requestV2Migration,
|
|
52
|
-
// v2: Attestation
|
|
53
|
-
createV2Attestation, assessV2AttestationQuality, } from "agent-passport-system";
|
|
43
|
+
defineV2EmergencyPathway, activateV2Emergency, } from "agent-passport-system";
|
|
54
44
|
// Agent Attestation Architecture (Phase 1 — Consilium Build)
|
|
55
45
|
import { createIssuanceContext, bindAttestation, createEmptyEvidenceRecord, PASSPORT_GRADE_LABELS,
|
|
56
46
|
// v1.33.0 — action_ref + freshness + evidence-based grade
|
|
57
47
|
computeActionRef, isEvidenceFresh, computeEvidenceAge, classifyEvidenceQuality, evidenceQualityToGrade,
|
|
58
48
|
// key rotation
|
|
59
49
|
createDIDDocument, verifyRotationChain, isKeyActive, rotateAndInvalidate, } from "agent-passport-system";
|
|
60
|
-
// Data Governance (Modules 36A, 38, 39
|
|
61
|
-
|
|
50
|
+
// Data Governance (Modules 36A, 38, 39 — protocol primitives only;
|
|
51
|
+
// ContributionLedger/DataEnforcementGate/settlement generation moved to gateway.)
|
|
52
|
+
import { registerSelfAttestedSource, } from "agent-passport-system";
|
|
62
53
|
// Data Lifecycle Governance (Modules 43+)
|
|
63
54
|
import { createDerivationReceipt, resolveExtendedLineage, evaluateRevocationImpact, createDecisionLineageReceipt, isPurposePermitted, purposeCategory, isRetentionExpired, checkAggregateConstraints, isTransferPermitted, computeGovernanceTaint, fileDispute, checkCombinationPermitted, createAccessSnapshot, resolveRightsPropagation, DEFAULT_RIGHTS_PROPAGATION, detectPurposeDrift, declareReidentificationRisk, verifyGovernanceBlock, parseGovernanceBlockFromHTML, isUsagePermitted, embedGovernance, generateApsTxt, verifyApsTxt, resolveTermsForPath, createChainedGovernanceBlock, createAccessReceipt, governanceLoop360, } from "agent-passport-system";
|
|
64
55
|
// Rome-Complete: Charter, Approval, Time, Reserve, Federation
|
|
@@ -68,7 +59,9 @@ createAttributionReceipt, signAttributionConsent, verifyAttributionConsent, chec
|
|
|
68
59
|
// Attribution Primitive (unified four-axis signed Merkle receipt)
|
|
69
60
|
computeAttributionActionRef, constructAttributionPrimitive, projectAttribution, verifyAttributionProjection, verifyAttributionPrimitive, checkProjectionConsistency,
|
|
70
61
|
// Attribution Weights (Build B — fractional D/C axis weight formulas)
|
|
71
|
-
computeDataAxisWeights, computeComputeAxisWeights, DEFAULT_WEIGHT_PROFILE,
|
|
62
|
+
computeDataAxisWeights, computeComputeAxisWeights, DEFAULT_WEIGHT_PROFILE,
|
|
63
|
+
// Attribution Settlement (Build C — per-period signed settlement record)
|
|
64
|
+
aggregateAttributionPrimitives, buildContributorQueryResponse, signSettlementRecord, verifySettlementRecord, } from "agent-passport-system";
|
|
72
65
|
// ═══════════════════════════════════════
|
|
73
66
|
// State Management
|
|
74
67
|
// ═══════════════════════════════════════
|
|
@@ -142,7 +135,6 @@ const state = {
|
|
|
142
135
|
floorYaml: null,
|
|
143
136
|
commerceSpendLog: [],
|
|
144
137
|
intents: new Map(),
|
|
145
|
-
agentContext: null,
|
|
146
138
|
floor: null,
|
|
147
139
|
pendingActions: new Map(),
|
|
148
140
|
principal: null,
|
|
@@ -151,12 +143,7 @@ const state = {
|
|
|
151
143
|
fleet: null,
|
|
152
144
|
reputations: new Map(),
|
|
153
145
|
promotionHistory: [],
|
|
154
|
-
gateway: null,
|
|
155
|
-
gatewayKeys: null,
|
|
156
|
-
dataEnforcementGate: null,
|
|
157
|
-
contributionLedger: createContributionLedger(),
|
|
158
146
|
sourceReceipts: new Map(),
|
|
159
|
-
trainingLedger: createTrainingLedger(),
|
|
160
147
|
derivationStore: new Map(),
|
|
161
148
|
sessionAgent: null,
|
|
162
149
|
charters: new Map(),
|
|
@@ -318,28 +305,11 @@ function persistAgoraFeed() {
|
|
|
318
305
|
// Non-fatal: coordination still works even if persistence fails
|
|
319
306
|
}
|
|
320
307
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
const result = coordinationToAgora({
|
|
327
|
-
event,
|
|
328
|
-
taskId,
|
|
329
|
-
agentId: state.agentId || 'anonymous',
|
|
330
|
-
agentName: getAgentName(),
|
|
331
|
-
publicKey: state.agentKey,
|
|
332
|
-
privateKey: state.privateKey,
|
|
333
|
-
feed: state.agoraFeed,
|
|
334
|
-
registry: state.agoraRegistry,
|
|
335
|
-
detail,
|
|
336
|
-
});
|
|
337
|
-
state.agoraFeed = result.feed;
|
|
338
|
-
persistAgoraFeed();
|
|
339
|
-
}
|
|
340
|
-
catch {
|
|
341
|
-
// Non-fatal: coordination still works even if Agora post fails
|
|
342
|
-
}
|
|
308
|
+
// Coordination→Agora bridge moved to gateway in v3.0.0.
|
|
309
|
+
// Task-lifecycle events still happen locally; cross-agent broadcast is a
|
|
310
|
+
// gateway concern now.
|
|
311
|
+
function emitAgoraEvent(_event, _taskId, _detail) {
|
|
312
|
+
// No-op in protocol-only MCP. Gateway callers handle Agora propagation.
|
|
343
313
|
}
|
|
344
314
|
function loadAgentsRegistry() {
|
|
345
315
|
if (!existsSync(AGENTS_PATH))
|
|
@@ -363,6 +333,26 @@ async function signMessage(content) {
|
|
|
363
333
|
}
|
|
364
334
|
}
|
|
365
335
|
// ═══════════════════════════════════════
|
|
336
|
+
// Gateway Deprecation Helper (v3.0.0)
|
|
337
|
+
// ═══════════════════════════════════════
|
|
338
|
+
// Tools that required product-layer code (ProxyGateway, DataEnforcementGate,
|
|
339
|
+
// ContributionLedger, AgentContext) now live in the private gateway product.
|
|
340
|
+
// Stubs preserve discoverability so callers learn where to migrate.
|
|
341
|
+
function movedToGateway(toolName) {
|
|
342
|
+
return {
|
|
343
|
+
content: [{
|
|
344
|
+
type: "text",
|
|
345
|
+
text: JSON.stringify({
|
|
346
|
+
error: `[deprecated in MCP v3.0.0] This tool (${toolName}) was removed because it required product-layer code that now lives in the private gateway. Use the gateway.aeoess.com REST API for this functionality, or stay on agent-passport-system-mcp@2.27.0 (pins to agent-passport-system@^1.46.0) if you need the old tools.`,
|
|
347
|
+
migration: "https://gateway.aeoess.com/docs",
|
|
348
|
+
deprecated_in: "3.0.0",
|
|
349
|
+
last_working_mcp: "2.27.0",
|
|
350
|
+
}),
|
|
351
|
+
}],
|
|
352
|
+
isError: true,
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
// ═══════════════════════════════════════
|
|
366
356
|
// Server Setup
|
|
367
357
|
// ═══════════════════════════════════════
|
|
368
358
|
const server = new McpServer({
|
|
@@ -395,9 +385,9 @@ const TOOL_PROFILES = {
|
|
|
395
385
|
'create_delegation', 'verify_delegation', 'revoke_delegation',
|
|
396
386
|
'create_charter', 'sign_charter', 'verify_charter',
|
|
397
387
|
'evaluate_threshold', 'create_approval_request', 'add_approval_signature',
|
|
398
|
-
'
|
|
399
|
-
'
|
|
400
|
-
'
|
|
388
|
+
'create_outcome_record', 'add_principal_report',
|
|
389
|
+
'activate_emergency', 'define_emergency_pathway',
|
|
390
|
+
'create_artifact_provenance', 'create_policy_context',
|
|
401
391
|
'generate_governance_block', 'verify_governance_block',
|
|
402
392
|
'parse_governance_block_html', 'governance_360',
|
|
403
393
|
'generate_aps_txt', 'verify_aps_txt', 'resolve_path_terms',
|
|
@@ -416,10 +406,8 @@ const TOOL_PROFILES = {
|
|
|
416
406
|
]),
|
|
417
407
|
data: new Set([
|
|
418
408
|
'identify', 'generate_keys', 'create_principal',
|
|
419
|
-
'register_data_source', 'create_data_enforcement_gate',
|
|
420
|
-
'query_contributions', '
|
|
421
|
-
'generate_settlement', 'generate_compliance_report',
|
|
422
|
-
'record_training_use', 'get_model_data_sources',
|
|
409
|
+
'register_data_source', 'create_data_enforcement_gate',
|
|
410
|
+
'query_contributions', 'generate_settlement',
|
|
423
411
|
'create_access_receipt', 'create_access_snapshot',
|
|
424
412
|
'create_derivation_receipt', 'create_decision_lineage_receipt',
|
|
425
413
|
'resolve_lineage', 'evaluate_revocation_impact',
|
|
@@ -431,8 +419,8 @@ const TOOL_PROFILES = {
|
|
|
431
419
|
]),
|
|
432
420
|
gateway: new Set([
|
|
433
421
|
'identify', 'generate_keys', 'create_principal',
|
|
434
|
-
'create_gateway',
|
|
435
|
-
'gateway_process_tool_call', 'gateway_approve',
|
|
422
|
+
'create_gateway',
|
|
423
|
+
'gateway_process_tool_call', 'gateway_approve',
|
|
436
424
|
'gateway_stats', 'create_delegation', 'load_values_floor', 'attest_to_floor',
|
|
437
425
|
'create_hybrid_timestamp', 'compare_timestamps', 'validate_temporal_rights',
|
|
438
426
|
'create_reserve_attestation', 'vouch_reputation', 'apply_reputation_downgrade',
|
|
@@ -443,7 +431,7 @@ const TOOL_PROFILES = {
|
|
|
443
431
|
'post_agora_message', 'get_agora_topics', 'get_agora_thread',
|
|
444
432
|
'get_agora_by_topic', 'register_agora_agent',
|
|
445
433
|
'send_message', 'check_messages', 'broadcast', 'list_agents',
|
|
446
|
-
'
|
|
434
|
+
'remove_intent_card', 'search_matches',
|
|
447
435
|
'request_intro', 'respond_to_intro', 'get_digest',
|
|
448
436
|
'register_agora_public',
|
|
449
437
|
]),
|
|
@@ -571,13 +559,10 @@ const TOOL_SCOPE_MAP = {
|
|
|
571
559
|
'execute_with_context': 'governance',
|
|
572
560
|
'complete_action': 'governance',
|
|
573
561
|
'create_policy_context': 'governance',
|
|
574
|
-
'create_attestation': 'governance',
|
|
575
562
|
'create_outcome_record': 'governance',
|
|
576
563
|
'add_principal_report': 'governance',
|
|
577
|
-
'check_anomaly': 'governance',
|
|
578
564
|
'define_emergency_pathway': 'governance',
|
|
579
565
|
'activate_emergency': 'governance',
|
|
580
|
-
'request_migration': 'governance',
|
|
581
566
|
'create_artifact_provenance': 'governance',
|
|
582
567
|
'create_charter': 'governance',
|
|
583
568
|
'verify_charter': 'governance',
|
|
@@ -601,14 +586,8 @@ const TOOL_SCOPE_MAP = {
|
|
|
601
586
|
// Data tools → 'data'
|
|
602
587
|
'register_data_source': 'data',
|
|
603
588
|
'create_data_enforcement_gate': 'data',
|
|
604
|
-
'check_data_access': 'data',
|
|
605
589
|
'query_contributions': 'data',
|
|
606
|
-
'get_source_metrics': 'data',
|
|
607
|
-
'get_agent_data_footprint': 'data',
|
|
608
590
|
'generate_settlement': 'data',
|
|
609
|
-
'generate_compliance_report': 'data',
|
|
610
|
-
'record_training_use': 'data',
|
|
611
|
-
'get_model_data_sources': 'data',
|
|
612
591
|
'create_access_receipt': 'data',
|
|
613
592
|
'create_access_snapshot': 'data',
|
|
614
593
|
'create_derivation_receipt': 'data',
|
|
@@ -627,13 +606,10 @@ const TOOL_SCOPE_MAP = {
|
|
|
627
606
|
'check_usage_permitted': 'data',
|
|
628
607
|
// Gateway tools → 'gateway'
|
|
629
608
|
'create_gateway': 'gateway',
|
|
630
|
-
'register_gateway_agent': 'gateway',
|
|
631
609
|
'gateway_process_tool_call': 'gateway',
|
|
632
610
|
'gateway_approve': 'gateway',
|
|
633
|
-
'gateway_execute_approval': 'gateway',
|
|
634
611
|
'gateway_stats': 'gateway',
|
|
635
612
|
// Network tools → 'network'
|
|
636
|
-
'publish_intent_card': 'network',
|
|
637
613
|
'search_matches': 'network',
|
|
638
614
|
'get_digest': 'network',
|
|
639
615
|
'request_intro': 'network',
|
|
@@ -668,6 +644,11 @@ const TOOL_SCOPE_MAP = {
|
|
|
668
644
|
// not in the essential profile.
|
|
669
645
|
'aps_compute_data_axis_weights': 'attribution',
|
|
670
646
|
'aps_compute_compute_axis_weights': 'attribution',
|
|
647
|
+
// Attribution Settlement (Build C) — new 'settlement' scope, not in
|
|
648
|
+
// essentials profile. Integration-layer tools only.
|
|
649
|
+
'aps_aggregate_settlement': 'settlement',
|
|
650
|
+
'aps_verify_settlement': 'settlement',
|
|
651
|
+
'aps_build_contributor_query': 'settlement',
|
|
671
652
|
};
|
|
672
653
|
// ═══════════════════════════════════════
|
|
673
654
|
// TOOL: list_profiles
|
|
@@ -1006,7 +987,7 @@ server.tool("get_behavioral_sequence", "Get the post-issuance behavioral sequenc
|
|
|
1006
987
|
}
|
|
1007
988
|
// Classify the behavioral pattern
|
|
1008
989
|
const toolNames = sequence.map(s => s.tool);
|
|
1009
|
-
const hasWork = toolNames.some(t => ['submit_evidence', '
|
|
990
|
+
const hasWork = toolNames.some(t => ['submit_evidence', 'create_agora_message', 'submit_deliverable'].includes(t));
|
|
1010
991
|
const hasExtraction = toolNames.some(t => ['commerce_preflight', 'create_checkout'].includes(t));
|
|
1011
992
|
const pattern = hasWork ? 'productive' : hasExtraction ? 'extractive' : 'neutral';
|
|
1012
993
|
return {
|
|
@@ -2302,7 +2283,7 @@ server.tool("commerce_preflight", "Run preflight checks before a purchase. Valid
|
|
|
2302
2283
|
const actualSpendLimit = sessionDel?.spendLimit ?? 1000;
|
|
2303
2284
|
const hasCommerceScope = sessionDel
|
|
2304
2285
|
? sessionDel.scope.some((s) => s === 'commerce' || s === 'commerce:checkout' || s.startsWith('commerce'))
|
|
2305
|
-
:
|
|
2286
|
+
: false; // no delegation → no commerce scope (agent-context fallback removed with gateway move)
|
|
2306
2287
|
// Use session agent if available (created by identify), fallback to throwaway
|
|
2307
2288
|
const agent = state.sessionAgent || joinSocialContract({
|
|
2308
2289
|
name: args.agent_id,
|
|
@@ -2387,161 +2368,24 @@ server.tool("request_human_approval", "Request human approval for a high-value p
|
|
|
2387
2368
|
// ═══════════════════════════════════════
|
|
2388
2369
|
// AGENT CONTEXT — Enforcement Middleware
|
|
2389
2370
|
// ═══════════════════════════════════════
|
|
2390
|
-
server.tool("create_agent_context", "Create an enforcement context that automatically runs every action through the 3-signature policy chain.
|
|
2371
|
+
server.tool("create_agent_context", "[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.", {
|
|
2391
2372
|
name: z.string().describe("Agent name"),
|
|
2392
2373
|
mission: z.string().describe("Agent mission statement"),
|
|
2393
|
-
enforcement: z.enum(["auto", "manual", "strict"]).default("auto").describe("Enforcement level
|
|
2394
|
-
delegated_scopes: z.array(z.string()).default([]).describe("Scopes to delegate
|
|
2374
|
+
enforcement: z.enum(["auto", "manual", "strict"]).default("auto").describe("Enforcement level"),
|
|
2375
|
+
delegated_scopes: z.array(z.string()).default([]).describe("Scopes to delegate"),
|
|
2395
2376
|
spend_limit: z.number().default(1000).describe("Maximum spend allowed"),
|
|
2396
|
-
}, async (
|
|
2397
|
-
|
|
2398
|
-
if (keyErr)
|
|
2399
|
-
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
2400
|
-
if (!state.floorYaml) {
|
|
2401
|
-
return { content: [{ type: "text", text: 'No floor loaded. Use load_values_floor first.' }], isError: true };
|
|
2402
|
-
}
|
|
2403
|
-
try {
|
|
2404
|
-
const floor = loadFloor(state.floorYaml);
|
|
2405
|
-
// Create the agent with floor attestation
|
|
2406
|
-
const agent = joinSocialContract({
|
|
2407
|
-
name: args.name,
|
|
2408
|
-
mission: args.mission,
|
|
2409
|
-
owner: 'mcp-session',
|
|
2410
|
-
capabilities: args.delegated_scopes,
|
|
2411
|
-
platform: 'node',
|
|
2412
|
-
models: ['mcp'],
|
|
2413
|
-
floor,
|
|
2414
|
-
});
|
|
2415
|
-
// Create the enforced context
|
|
2416
|
-
const ctx = createAgentContext(agent, floor, {
|
|
2417
|
-
enforcement: args.enforcement,
|
|
2418
|
-
});
|
|
2419
|
-
// Add delegation if scopes provided
|
|
2420
|
-
if (args.delegated_scopes.length > 0) {
|
|
2421
|
-
const principal = joinSocialContract({
|
|
2422
|
-
name: 'mcp-principal',
|
|
2423
|
-
mission: 'MCP session principal',
|
|
2424
|
-
owner: 'human',
|
|
2425
|
-
capabilities: ['admin'],
|
|
2426
|
-
platform: 'node',
|
|
2427
|
-
models: ['mcp'],
|
|
2428
|
-
floor,
|
|
2429
|
-
});
|
|
2430
|
-
const del = delegate({
|
|
2431
|
-
from: principal,
|
|
2432
|
-
toPublicKey: agent.publicKey,
|
|
2433
|
-
scope: args.delegated_scopes,
|
|
2434
|
-
spendLimit: args.spend_limit,
|
|
2435
|
-
maxDepth: 3,
|
|
2436
|
-
expiresInHours: 24,
|
|
2437
|
-
});
|
|
2438
|
-
ctx.addDelegation(del);
|
|
2439
|
-
}
|
|
2440
|
-
state.agentContext = ctx;
|
|
2441
|
-
state.floor = floor;
|
|
2442
|
-
// F-4 fix: also register in state.agents so gateway and other tools can find this agent
|
|
2443
|
-
state.agents.set(agent.agentId, agent);
|
|
2444
|
-
return {
|
|
2445
|
-
content: [{
|
|
2446
|
-
type: "text",
|
|
2447
|
-
text: JSON.stringify({
|
|
2448
|
-
created: true,
|
|
2449
|
-
enforcement: args.enforcement,
|
|
2450
|
-
agentId: agent.agentId,
|
|
2451
|
-
scopes: args.delegated_scopes,
|
|
2452
|
-
spendLimit: args.spend_limit,
|
|
2453
|
-
note: `Agent Context active (${args.enforcement} mode). Use execute_with_context to run actions through the 3-signature chain.`,
|
|
2454
|
-
}, null, 2),
|
|
2455
|
-
}],
|
|
2456
|
-
};
|
|
2457
|
-
}
|
|
2458
|
-
catch (e) {
|
|
2459
|
-
return { content: [{ type: "text", text: safeError("Failed to create context", e) }], isError: true };
|
|
2460
|
-
}
|
|
2461
|
-
});
|
|
2462
|
-
server.tool("execute_with_context", "Execute an action through the enforcement context. Automatically runs the 3-signature chain: creates intent (sig 1), evaluates against floor + delegation (sig 2), returns verdict. Action is DENIED if outside delegated scope.", {
|
|
2377
|
+
}, async (_args) => movedToGateway("create_agent_context"));
|
|
2378
|
+
server.tool("execute_with_context", "[deprecated in v3.0.0 — use gateway.aeoess.com REST API] Execute an action through the enforcement context.", {
|
|
2463
2379
|
action_type: z.string().describe("Action type (e.g. 'api:fetch', 'data:write', 'commerce:checkout')"),
|
|
2464
2380
|
target: z.string().describe("Target of the action (e.g. URL, file path, resource ID)"),
|
|
2465
2381
|
scope: z.string().describe("Required scope for this action (must match a delegated scope)"),
|
|
2466
2382
|
estimated_spend: z.number().optional().describe("Estimated spend for commerce actions"),
|
|
2467
|
-
}, async (
|
|
2468
|
-
|
|
2469
|
-
return { content: [{ type: "text", text: 'No agent context. Use create_agent_context first.' }], isError: true };
|
|
2470
|
-
}
|
|
2471
|
-
try {
|
|
2472
|
-
const result = state.agentContext.execute({
|
|
2473
|
-
type: args.action_type,
|
|
2474
|
-
target: args.target,
|
|
2475
|
-
scope: args.scope,
|
|
2476
|
-
spend: args.estimated_spend ? { amount: args.estimated_spend, currency: 'USD' } : undefined,
|
|
2477
|
-
});
|
|
2478
|
-
// Store for later completion
|
|
2479
|
-
if (result.permitted && result.intent) {
|
|
2480
|
-
state.pendingActions.set(result.intent.intentId, result);
|
|
2481
|
-
}
|
|
2482
|
-
return {
|
|
2483
|
-
content: [{
|
|
2484
|
-
type: "text",
|
|
2485
|
-
text: JSON.stringify({
|
|
2486
|
-
permitted: result.permitted,
|
|
2487
|
-
verdict: result.verdict,
|
|
2488
|
-
intentId: result.intent?.intentId,
|
|
2489
|
-
evaluatorId: result.decision?.evaluatorId,
|
|
2490
|
-
reason: result.reason,
|
|
2491
|
-
stats: state.agentContext.stats,
|
|
2492
|
-
note: result.permitted
|
|
2493
|
-
? `Action PERMITTED. Call complete_action with intent_id="${result.intent.intentId}" when done.`
|
|
2494
|
-
: `Action DENIED: ${result.reason}`,
|
|
2495
|
-
}, null, 2),
|
|
2496
|
-
}],
|
|
2497
|
-
};
|
|
2498
|
-
}
|
|
2499
|
-
catch (e) {
|
|
2500
|
-
return { content: [{ type: "text", text: safeError("Execute failed", e) }], isError: true };
|
|
2501
|
-
}
|
|
2502
|
-
});
|
|
2503
|
-
server.tool("complete_action", "Complete a permitted action and get the full 3-signature proof chain (intent + decision + receipt + policy receipt). Call this after successfully executing the action.", {
|
|
2383
|
+
}, async (_args) => movedToGateway("execute_with_context"));
|
|
2384
|
+
server.tool("complete_action", "[deprecated in v3.0.0 — use gateway.aeoess.com REST API] Complete a permitted action and get the full 3-signature proof chain.", {
|
|
2504
2385
|
intent_id: z.string().describe("Intent ID from execute_with_context result"),
|
|
2505
2386
|
status: z.enum(["success", "failure", "partial"]).describe("Outcome of the action"),
|
|
2506
2387
|
summary: z.string().describe("Brief description of what was accomplished"),
|
|
2507
|
-
}, async (
|
|
2508
|
-
if (!state.agentContext) {
|
|
2509
|
-
return { content: [{ type: "text", text: 'No agent context. Use create_agent_context first.' }], isError: true };
|
|
2510
|
-
}
|
|
2511
|
-
// Find the pending execute result
|
|
2512
|
-
const executeResult = state.pendingActions.get(args.intent_id);
|
|
2513
|
-
if (!executeResult) {
|
|
2514
|
-
return { content: [{ type: "text", text: `No pending action found for intent ${args.intent_id}. Was it permitted?` }], isError: true };
|
|
2515
|
-
}
|
|
2516
|
-
try {
|
|
2517
|
-
const completed = state.agentContext.complete(executeResult, {
|
|
2518
|
-
status: args.status,
|
|
2519
|
-
summary: args.summary,
|
|
2520
|
-
});
|
|
2521
|
-
// Clean up
|
|
2522
|
-
state.pendingActions.delete(args.intent_id);
|
|
2523
|
-
return {
|
|
2524
|
-
content: [{
|
|
2525
|
-
type: "text",
|
|
2526
|
-
text: JSON.stringify({
|
|
2527
|
-
completed: true,
|
|
2528
|
-
receiptId: completed.receipt.receiptId,
|
|
2529
|
-
policyReceiptId: completed.policyReceipt?.receiptId,
|
|
2530
|
-
signatures: {
|
|
2531
|
-
intent: '✓ (agent declared intent)',
|
|
2532
|
-
decision: '✓ (policy engine evaluated)',
|
|
2533
|
-
receipt: '✓ (execution recorded)',
|
|
2534
|
-
},
|
|
2535
|
-
stats: state.agentContext.stats,
|
|
2536
|
-
auditTrail: state.agentContext.auditLog.length + ' entries',
|
|
2537
|
-
}, null, 2),
|
|
2538
|
-
}],
|
|
2539
|
-
};
|
|
2540
|
-
}
|
|
2541
|
-
catch (e) {
|
|
2542
|
-
return { content: [{ type: "text", text: safeError("Complete failed", e) }], isError: true };
|
|
2543
|
-
}
|
|
2544
|
-
});
|
|
2388
|
+
}, async (_args) => movedToGateway("complete_action"));
|
|
2545
2389
|
// ═══════════════════════════════════════
|
|
2546
2390
|
// PRINCIPAL IDENTITY TOOLS
|
|
2547
2391
|
// ═══════════════════════════════════════
|
|
@@ -2890,226 +2734,34 @@ server.tool("get_promotion_history", "Get the promotion review history for this
|
|
|
2890
2734
|
};
|
|
2891
2735
|
});
|
|
2892
2736
|
// ═══════════════════════════════════════
|
|
2893
|
-
// Proxy Gateway (
|
|
2737
|
+
// Proxy Gateway (moved to gateway product in v3.0.0)
|
|
2894
2738
|
// ═══════════════════════════════════════
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
content: [{
|
|
2922
|
-
type: "text",
|
|
2923
|
-
text: JSON.stringify({
|
|
2924
|
-
created: true,
|
|
2925
|
-
gatewayId: id,
|
|
2926
|
-
publicKey: keys.publicKey,
|
|
2927
|
-
approvalTTLSeconds: config.approvalTTLSeconds,
|
|
2928
|
-
maxPendingPerAgent: config.maxPendingPerAgent,
|
|
2929
|
-
note: "Gateway ready. Register agents with register_gateway_agent, then process calls with gateway_process_tool_call.",
|
|
2930
|
-
}, null, 2),
|
|
2931
|
-
}],
|
|
2932
|
-
};
|
|
2933
|
-
});
|
|
2934
|
-
server.tool("register_gateway_agent", "Register an agent with the gateway. The agent must have a valid passport and floor attestation. Delegations define what scopes the agent can use through the gateway.", {
|
|
2935
|
-
agentId: z.string().describe("Agent ID to register"),
|
|
2936
|
-
}, async ({ agentId }) => {
|
|
2937
|
-
if (!state.gateway) {
|
|
2938
|
-
return { content: [{ type: "text", text: "Error: Create gateway first (create_gateway)" }] };
|
|
2939
|
-
}
|
|
2940
|
-
// F-4 fix: check both state.agents AND state.agentContext for agent data
|
|
2941
|
-
let agent = state.agents.get(agentId);
|
|
2942
|
-
if (!agent && state.agentContext && state.agentId === agentId) {
|
|
2943
|
-
// Agent was created via create_agent_context, bridge to gateway
|
|
2944
|
-
const ctx = state.agentContext;
|
|
2945
|
-
agent = {
|
|
2946
|
-
passport: ctx.agent?.passport || ctx.passport,
|
|
2947
|
-
publicKey: state.agentKey,
|
|
2948
|
-
agentId: state.agentId,
|
|
2949
|
-
attestation: ctx.agent?.attestation || ctx.attestation,
|
|
2950
|
-
};
|
|
2951
|
-
}
|
|
2952
|
-
if (!agent) {
|
|
2953
|
-
return { content: [{ type: "text", text: `Error: Agent "${agentId}" not found in session. Join social contract or create_agent_context first.` }] };
|
|
2954
|
-
}
|
|
2955
|
-
const agentDelegations = Array.from(state.delegations.values()).filter(d => d.delegatedTo === agent.publicKey);
|
|
2956
|
-
if (agentDelegations.length === 0) {
|
|
2957
|
-
return { content: [{ type: "text", text: `Error: No delegations found for agent "${agentId}". Create a delegation first.` }] };
|
|
2958
|
-
}
|
|
2959
|
-
if (!agent.attestation) {
|
|
2960
|
-
return { content: [{ type: "text", text: `Error: Agent "${agentId}" has no floor attestation. Attest to floor first.` }] };
|
|
2961
|
-
}
|
|
2962
|
-
state.gateway.registerAgent(agent.passport, agent.attestation, agentDelegations);
|
|
2963
|
-
return {
|
|
2964
|
-
content: [{
|
|
2965
|
-
type: "text",
|
|
2966
|
-
text: JSON.stringify({
|
|
2967
|
-
registered: true,
|
|
2968
|
-
agentId,
|
|
2969
|
-
delegationCount: agentDelegations.length,
|
|
2970
|
-
scopes: agentDelegations.flatMap(d => d.scope),
|
|
2971
|
-
}, null, 2),
|
|
2972
|
-
}],
|
|
2973
|
-
};
|
|
2974
|
-
});
|
|
2975
|
-
server.tool("gateway_process_tool_call", "Process a tool call through the gateway enforcement boundary. Validates identity, delegation, policy, and replay protection in a single atomic operation. Returns execution result with full 3-signature proof chain.", {
|
|
2976
|
-
agentId: z.string().describe("ID of the requesting agent"),
|
|
2977
|
-
tool: z.string().describe("Tool name to execute"),
|
|
2978
|
-
params: z.record(z.unknown()).optional().describe("Tool parameters"),
|
|
2979
|
-
scopeRequired: z.string().describe("Delegation scope needed for this tool"),
|
|
2980
|
-
spendAmount: z.number().optional().describe("Spend amount if commerce action"),
|
|
2981
|
-
spendCurrency: z.string().optional().describe("Currency code (e.g. USD)"),
|
|
2982
|
-
context: z.string().optional().describe("Human-readable context for audit"),
|
|
2983
|
-
}, async ({ agentId, tool, params, scopeRequired, spendAmount, spendCurrency, context }) => {
|
|
2984
|
-
if (!state.gateway) {
|
|
2985
|
-
return { content: [{ type: "text", text: "Error: Create gateway first (create_gateway)" }] };
|
|
2986
|
-
}
|
|
2987
|
-
const agent = state.agents.get(agentId);
|
|
2988
|
-
if (!agent) {
|
|
2989
|
-
return { content: [{ type: "text", text: `Error: Agent "${agentId}" not found in session.` }] };
|
|
2990
|
-
}
|
|
2991
|
-
const { canonicalize } = await import("agent-passport-system");
|
|
2992
|
-
const requestId = `mcp-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
2993
|
-
const payload = canonicalize({ requestId, agentId, tool, params: params || {}, scopeRequired, spend: spendAmount ? { amount: spendAmount, currency: spendCurrency || 'USD' } : undefined });
|
|
2994
|
-
const request = {
|
|
2995
|
-
requestId,
|
|
2996
|
-
agentId,
|
|
2997
|
-
agentPublicKey: agent.publicKey,
|
|
2998
|
-
signature: sign(payload, agent.keyPair.privateKey),
|
|
2999
|
-
tool,
|
|
3000
|
-
params: params || {},
|
|
3001
|
-
scopeRequired,
|
|
3002
|
-
spend: spendAmount ? { amount: spendAmount, currency: spendCurrency || 'USD' } : undefined,
|
|
3003
|
-
context,
|
|
3004
|
-
};
|
|
3005
|
-
const result = await state.gateway.processToolCall(request);
|
|
3006
|
-
return {
|
|
3007
|
-
content: [{
|
|
3008
|
-
type: "text",
|
|
3009
|
-
text: JSON.stringify({
|
|
3010
|
-
executed: result.executed,
|
|
3011
|
-
requestId: result.requestId,
|
|
3012
|
-
result: result.result ?? undefined,
|
|
3013
|
-
denialReason: result.denialReason ?? undefined,
|
|
3014
|
-
toolError: result.toolError ?? undefined,
|
|
3015
|
-
...(result.decision && { verdict: result.decision.verdict, reason: result.decision.reason }),
|
|
3016
|
-
...(result.proof && {
|
|
3017
|
-
proof: {
|
|
3018
|
-
hasRequestSignature: !!result.proof.requestSignature,
|
|
3019
|
-
hasDecisionSignature: !!result.proof.decisionSignature,
|
|
3020
|
-
hasReceiptSignature: !!result.proof.receiptSignature,
|
|
3021
|
-
policyReceiptId: result.proof.policyReceipt?.policyReceiptId,
|
|
3022
|
-
},
|
|
3023
|
-
}),
|
|
3024
|
-
...(result.receipt && {
|
|
3025
|
-
receipt: {
|
|
3026
|
-
receiptId: result.receipt.receiptId,
|
|
3027
|
-
agentId: result.receipt.agentId,
|
|
3028
|
-
action: result.receipt.action,
|
|
3029
|
-
},
|
|
3030
|
-
}),
|
|
3031
|
-
}, null, 2),
|
|
3032
|
-
}],
|
|
3033
|
-
};
|
|
3034
|
-
});
|
|
3035
|
-
server.tool("gateway_approve", "Two-phase execution: approve a tool call without executing it. Returns an approval ID that can be executed later with gateway_execute_approval. Useful for human-in-the-loop workflows.", {
|
|
3036
|
-
agentId: z.string().describe("ID of the requesting agent"),
|
|
3037
|
-
tool: z.string().describe("Tool name to approve"),
|
|
3038
|
-
params: z.record(z.unknown()).optional().describe("Tool parameters"),
|
|
3039
|
-
scopeRequired: z.string().describe("Delegation scope needed"),
|
|
3040
|
-
context: z.string().optional().describe("Human-readable context"),
|
|
3041
|
-
}, async ({ agentId, tool, params, scopeRequired, context }) => {
|
|
3042
|
-
if (!state.gateway) {
|
|
3043
|
-
return { content: [{ type: "text", text: "Error: Create gateway first (create_gateway)" }] };
|
|
3044
|
-
}
|
|
3045
|
-
const agent = state.agents.get(agentId);
|
|
3046
|
-
if (!agent) {
|
|
3047
|
-
return { content: [{ type: "text", text: `Error: Agent "${agentId}" not found in session.` }] };
|
|
3048
|
-
}
|
|
3049
|
-
const { canonicalize } = await import("agent-passport-system");
|
|
3050
|
-
const requestId = `mcp-approve-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
3051
|
-
const payload = canonicalize({ requestId, agentId, tool, params: params || {}, scopeRequired, spend: undefined });
|
|
3052
|
-
const request = {
|
|
3053
|
-
requestId,
|
|
3054
|
-
agentId,
|
|
3055
|
-
agentPublicKey: agent.publicKey,
|
|
3056
|
-
signature: sign(payload, agent.keyPair.privateKey),
|
|
3057
|
-
tool,
|
|
3058
|
-
params: params || {},
|
|
3059
|
-
scopeRequired,
|
|
3060
|
-
context,
|
|
3061
|
-
};
|
|
3062
|
-
const result = state.gateway.approve(request);
|
|
3063
|
-
return {
|
|
3064
|
-
content: [{
|
|
3065
|
-
type: "text",
|
|
3066
|
-
text: JSON.stringify({
|
|
3067
|
-
approved: result.approved,
|
|
3068
|
-
...(result.approval && {
|
|
3069
|
-
approvalId: result.approval.approvalId,
|
|
3070
|
-
expiresAt: result.approval.expiresAt,
|
|
3071
|
-
nonce: result.approval.nonce,
|
|
3072
|
-
}),
|
|
3073
|
-
...(result.denial && { denial: result.denial }),
|
|
3074
|
-
}, null, 2),
|
|
3075
|
-
}],
|
|
3076
|
-
};
|
|
3077
|
-
});
|
|
3078
|
-
server.tool("gateway_execute_approval", "Execute a previously approved tool call. Rechecks delegation validity before execution — if delegation was revoked since approval, execution is denied.", {
|
|
3079
|
-
approvalId: z.string().describe("Approval ID from gateway_approve"),
|
|
3080
|
-
}, async ({ approvalId }) => {
|
|
3081
|
-
if (!state.gateway) {
|
|
3082
|
-
return { content: [{ type: "text", text: "Error: Create gateway first (create_gateway)" }] };
|
|
3083
|
-
}
|
|
3084
|
-
const result = await state.gateway.executeApproval(approvalId);
|
|
3085
|
-
return {
|
|
3086
|
-
content: [{
|
|
3087
|
-
type: "text",
|
|
3088
|
-
text: JSON.stringify({
|
|
3089
|
-
executed: result.executed,
|
|
3090
|
-
requestId: result.requestId,
|
|
3091
|
-
result: result.result ?? undefined,
|
|
3092
|
-
denialReason: result.denialReason ?? undefined,
|
|
3093
|
-
...(result.proof && {
|
|
3094
|
-
proof: {
|
|
3095
|
-
policyReceiptId: result.proof.policyReceipt?.policyReceiptId,
|
|
3096
|
-
},
|
|
3097
|
-
}),
|
|
3098
|
-
}, null, 2),
|
|
3099
|
-
}],
|
|
3100
|
-
};
|
|
3101
|
-
});
|
|
3102
|
-
server.tool("gateway_stats", "Get gateway statistics: total requests, permits, denials, replay attempts blocked, active agents, and pending approvals.", {}, async () => {
|
|
3103
|
-
if (!state.gateway) {
|
|
3104
|
-
return { content: [{ type: "text", text: "Error: Create gateway first (create_gateway)" }] };
|
|
3105
|
-
}
|
|
3106
|
-
return {
|
|
3107
|
-
content: [{
|
|
3108
|
-
type: "text",
|
|
3109
|
-
text: JSON.stringify(state.gateway.getStats(), null, 2),
|
|
3110
|
-
}],
|
|
3111
|
-
};
|
|
3112
|
-
});
|
|
2739
|
+
// ProxyGateway is a product-layer enforcement runtime. The primitives it
|
|
2740
|
+
// was built on (delegation verification, policy evaluation, replay nonces)
|
|
2741
|
+
// remain in the SDK — rebuild a gateway locally from those, or use the
|
|
2742
|
+
// hosted gateway at gateway.aeoess.com.
|
|
2743
|
+
server.tool("create_gateway", "[deprecated in v3.0.0 — use gateway.aeoess.com REST API] Create a ProxyGateway enforcement boundary.", {
|
|
2744
|
+
gatewayId: z.string().optional().describe("Custom gateway ID"),
|
|
2745
|
+
approvalTTLSeconds: z.number().optional().describe("Two-phase approval timeout"),
|
|
2746
|
+
maxPendingPerAgent: z.number().optional().describe("Max pending approvals per agent"),
|
|
2747
|
+
}, async (_args) => movedToGateway("create_gateway"));
|
|
2748
|
+
server.tool("gateway_process_tool_call", "[deprecated in v3.0.0 — use gateway.aeoess.com REST API] Process a tool call through the gateway enforcement boundary.", {
|
|
2749
|
+
agentId: z.string(),
|
|
2750
|
+
tool: z.string(),
|
|
2751
|
+
params: z.record(z.unknown()).optional(),
|
|
2752
|
+
scopeRequired: z.string(),
|
|
2753
|
+
spendAmount: z.number().optional(),
|
|
2754
|
+
spendCurrency: z.string().optional(),
|
|
2755
|
+
context: z.string().optional(),
|
|
2756
|
+
}, async (_args) => movedToGateway("gateway_process_tool_call"));
|
|
2757
|
+
server.tool("gateway_approve", "[deprecated in v3.0.0 — use gateway.aeoess.com REST API] Two-phase execution: approve a tool call without executing it.", {
|
|
2758
|
+
agentId: z.string(),
|
|
2759
|
+
tool: z.string(),
|
|
2760
|
+
params: z.record(z.unknown()).optional(),
|
|
2761
|
+
scopeRequired: z.string(),
|
|
2762
|
+
context: z.string().optional(),
|
|
2763
|
+
}, async (_args) => movedToGateway("gateway_approve"));
|
|
2764
|
+
server.tool("gateway_stats", "[deprecated in v3.0.0 — use gateway.aeoess.com REST API] Get gateway statistics.", {}, async (_args) => movedToGateway("gateway_stats"));
|
|
3113
2765
|
// ═══════════════════════════════════════
|
|
3114
2766
|
// Intent Network (Agent-Mediated Matching)
|
|
3115
2767
|
// Calls the hosted API at api.aeoess.com
|
|
@@ -3122,83 +2774,9 @@ async function intentApiFetch(path, opts) {
|
|
|
3122
2774
|
});
|
|
3123
2775
|
return res.json();
|
|
3124
2776
|
}
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
category: z.string().describe("Category (e.g. 'engineering', 'design', 'funding')"),
|
|
3129
|
-
description: z.string().describe("What is needed"),
|
|
3130
|
-
priority: z.enum(["critical", "high", "medium", "low"]).default("medium"),
|
|
3131
|
-
tags: z.array(z.string()).optional(),
|
|
3132
|
-
budget_amount: z.number().optional(),
|
|
3133
|
-
budget_currency: z.string().optional(),
|
|
3134
|
-
})).optional().describe("What the human needs"),
|
|
3135
|
-
offers: z.array(z.object({
|
|
3136
|
-
category: z.string().describe("Category of what's offered"),
|
|
3137
|
-
description: z.string().describe("What is offered"),
|
|
3138
|
-
priority: z.enum(["critical", "high", "medium", "low"]).default("medium"),
|
|
3139
|
-
tags: z.array(z.string()).optional(),
|
|
3140
|
-
budget_amount: z.number().optional(),
|
|
3141
|
-
budget_currency: z.string().optional(),
|
|
3142
|
-
})).optional().describe("What the human offers"),
|
|
3143
|
-
open_to: z.array(z.string()).optional().describe("Categories open to (e.g. ['introductions', 'partnerships'])"),
|
|
3144
|
-
not_open_to: z.array(z.string()).optional().describe("Categories explicitly not open to"),
|
|
3145
|
-
approval_required: z.array(z.string()).optional().describe("What needs human approval before sharing"),
|
|
3146
|
-
visibility: z.enum(["public", "verified", "minimal"]).default("public"),
|
|
3147
|
-
ttl_hours: z.number().default(24).describe("Hours until card expires"),
|
|
3148
|
-
}, async (args) => {
|
|
3149
|
-
recordBehavior('publish_intent_card');
|
|
3150
|
-
const keyErr = requireKey();
|
|
3151
|
-
if (keyErr)
|
|
3152
|
-
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
3153
|
-
const mapItem = (item) => ({
|
|
3154
|
-
category: item.category,
|
|
3155
|
-
description: item.description,
|
|
3156
|
-
priority: item.priority || 'medium',
|
|
3157
|
-
tags: item.tags || [],
|
|
3158
|
-
budget: item.budget_amount ? { amount: item.budget_amount, currency: item.budget_currency || 'USD' } : undefined,
|
|
3159
|
-
visibility: 'public',
|
|
3160
|
-
});
|
|
3161
|
-
const card = createIntentCard({
|
|
3162
|
-
agentId: state.agentId || 'anonymous',
|
|
3163
|
-
principalAlias: args.principal_alias,
|
|
3164
|
-
publicKey: state.agentKey,
|
|
3165
|
-
privateKey: state.privateKey,
|
|
3166
|
-
needs: (args.needs || []).map(mapItem),
|
|
3167
|
-
offers: (args.offers || []).map(mapItem),
|
|
3168
|
-
openTo: args.open_to || [],
|
|
3169
|
-
notOpenTo: args.not_open_to || [],
|
|
3170
|
-
approvalRequired: args.approval_required || [],
|
|
3171
|
-
ttlSeconds: (args.ttl_hours || 24) * 3600,
|
|
3172
|
-
});
|
|
3173
|
-
try {
|
|
3174
|
-
const result = await intentApiFetch('/api/cards', {
|
|
3175
|
-
method: 'POST',
|
|
3176
|
-
body: JSON.stringify({ ...card, publicKey: state.agentKey, signature: card.signature }),
|
|
3177
|
-
});
|
|
3178
|
-
if (result.error) {
|
|
3179
|
-
return { content: [{ type: "text", text: `Failed to publish: ${result.error}` }], isError: true };
|
|
3180
|
-
}
|
|
3181
|
-
return {
|
|
3182
|
-
content: [{
|
|
3183
|
-
type: "text",
|
|
3184
|
-
text: JSON.stringify({
|
|
3185
|
-
published: true,
|
|
3186
|
-
cardId: result.cardId,
|
|
3187
|
-
agentId: card.agentId,
|
|
3188
|
-
principalAlias: card.principalAlias,
|
|
3189
|
-
needs: card.needs.length,
|
|
3190
|
-
offers: card.offers.length,
|
|
3191
|
-
expiresAt: result.expiresAt,
|
|
3192
|
-
networkSize: result.networkSize,
|
|
3193
|
-
note: 'Card published to Intent Network (api.aeoess.com). Other agents worldwide can now discover matches.',
|
|
3194
|
-
}, null, 2),
|
|
3195
|
-
}],
|
|
3196
|
-
};
|
|
3197
|
-
}
|
|
3198
|
-
catch (e) {
|
|
3199
|
-
return { content: [{ type: "text", text: safeError("API error", e) }], isError: true };
|
|
3200
|
-
}
|
|
3201
|
-
});
|
|
2777
|
+
// publish_intent_card removed in v3.0.0: createIntentCard was gateway-side
|
|
2778
|
+
// signing glue. Cards are still publishable directly via the Intent Network
|
|
2779
|
+
// REST API at api.aeoess.com/api/cards — sign with your agent private key.
|
|
3202
2780
|
server.tool("search_matches", "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.", {
|
|
3203
2781
|
min_score: z.number().optional().describe("Minimum relevance score 0-1 (default: 0.1)"),
|
|
3204
2782
|
max_results: z.number().optional().describe("Maximum results to return (default: 10)"),
|
|
@@ -3274,7 +2852,7 @@ server.tool("get_digest", "Get a personalized digest from the Intent Network: re
|
|
|
3274
2852
|
message: intro.message,
|
|
3275
2853
|
status: intro.status,
|
|
3276
2854
|
})),
|
|
3277
|
-
note: !digest.hasCard ? 'No card published yet.
|
|
2855
|
+
note: !digest.hasCard ? 'No card published yet. POST to api.aeoess.com/api/cards to join the network (publish_intent_card tool removed in v3.0.0).' : undefined,
|
|
3278
2856
|
}, null, 2),
|
|
3279
2857
|
}],
|
|
3280
2858
|
};
|
|
@@ -3594,73 +3172,12 @@ server.tool("activate_emergency", "Activate a pre-authorized emergency pathway w
|
|
|
3594
3172
|
return { content: [{ type: "text", text: safeError("Emergency activation failed", e) }], isError: true };
|
|
3595
3173
|
}
|
|
3596
3174
|
});
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
confidence: z.number().min(0).max(1),
|
|
3604
|
-
semantic_uncertainty: z.enum(["low", "medium", "high", "critical"]),
|
|
3605
|
-
required: z.boolean().default(true),
|
|
3606
|
-
valid_until: z.string(), trust_epoch: z.number().default(1),
|
|
3607
|
-
}, async (args) => {
|
|
3608
|
-
const keyErr = requireKey();
|
|
3609
|
-
if (keyErr)
|
|
3610
|
-
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
3611
|
-
try {
|
|
3612
|
-
const ctx = createPolicyContext({
|
|
3613
|
-
policy_version: "2.0.0", values_floor_version: "1.0.0",
|
|
3614
|
-
trust_epoch: args.trust_epoch, issuer_id: state.agentKey,
|
|
3615
|
-
valid_until: args.valid_until,
|
|
3616
|
-
});
|
|
3617
|
-
const att = createV2Attestation({
|
|
3618
|
-
action_id: args.action_id, agent_id: state.agentKey,
|
|
3619
|
-
delegation_ref: args.delegation_ref,
|
|
3620
|
-
context_understanding: args.context_understanding,
|
|
3621
|
-
factors_considered: args.factors_considered,
|
|
3622
|
-
alternatives_rejected: args.alternatives_rejected,
|
|
3623
|
-
expected_outcome: args.expected_outcome,
|
|
3624
|
-
confidence: args.confidence,
|
|
3625
|
-
semantic_uncertainty: args.semantic_uncertainty,
|
|
3626
|
-
required: args.required, policy_context: ctx,
|
|
3627
|
-
agent_private_key: state.privateKey,
|
|
3628
|
-
});
|
|
3629
|
-
const quality = assessV2AttestationQuality(att);
|
|
3630
|
-
return { content: [{ type: "text", text: JSON.stringify({ attestation: att, quality }, null, 2) }] };
|
|
3631
|
-
}
|
|
3632
|
-
catch (e) {
|
|
3633
|
-
return { content: [{ type: "text", text: safeError("Attestation failed", e) }], isError: true };
|
|
3634
|
-
}
|
|
3635
|
-
});
|
|
3636
|
-
server.tool("request_migration", "Request fork-and-sunset migration when current delegation scope is insufficient.", {
|
|
3637
|
-
source_delegation: z.string(),
|
|
3638
|
-
limitation: z.string().describe("What the agent cannot do under current scope"),
|
|
3639
|
-
requested_scope_change: z.string(),
|
|
3640
|
-
justification: z.string(),
|
|
3641
|
-
valid_until: z.string(), trust_epoch: z.number().default(1),
|
|
3642
|
-
}, async (args) => {
|
|
3643
|
-
const keyErr = requireKey();
|
|
3644
|
-
if (keyErr)
|
|
3645
|
-
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
3646
|
-
try {
|
|
3647
|
-
const ctx = createPolicyContext({
|
|
3648
|
-
policy_version: "2.0.0", values_floor_version: "1.0.0",
|
|
3649
|
-
trust_epoch: args.trust_epoch, issuer_id: state.agentKey,
|
|
3650
|
-
valid_until: args.valid_until,
|
|
3651
|
-
});
|
|
3652
|
-
const req = requestV2Migration({
|
|
3653
|
-
source_agent: state.agentKey, source_delegation: args.source_delegation,
|
|
3654
|
-
limitation: args.limitation, requested_scope_change: args.requested_scope_change,
|
|
3655
|
-
justification: args.justification, agent_private_key: state.privateKey,
|
|
3656
|
-
policy_context: ctx,
|
|
3657
|
-
});
|
|
3658
|
-
return { content: [{ type: "text", text: JSON.stringify(req, null, 2) }] };
|
|
3659
|
-
}
|
|
3660
|
-
catch (e) {
|
|
3661
|
-
return { content: [{ type: "text", text: safeError("Migration request failed", e) }], isError: true };
|
|
3662
|
-
}
|
|
3663
|
-
});
|
|
3175
|
+
// create_attestation (contextual attestation lifecycle) removed in v3.0.0:
|
|
3176
|
+
// createV2Attestation / getV2AgentAttestationQualityAvg / clearV2AttestationStore
|
|
3177
|
+
// were gateway-side lifecycle helpers. The primitive assessV2AttestationQuality
|
|
3178
|
+
// remains in the SDK for direct use.
|
|
3179
|
+
// request_migration removed in v3.0.0: requestV2Migration / approveV2Migration /
|
|
3180
|
+
// executeV2Migration were gateway-side migration orchestration.
|
|
3664
3181
|
server.tool("create_artifact_provenance", "Tag an agent-generated artifact with provenance metadata (content hash, risk class, authoring agent).", {
|
|
3665
3182
|
delegation_ref: z.string(), intended_use: z.string(),
|
|
3666
3183
|
risk_class: z.enum(["low", "medium", "high", "critical"]),
|
|
@@ -3693,39 +3210,10 @@ server.tool("create_artifact_provenance", "Tag an agent-generated artifact with
|
|
|
3693
3210
|
return { content: [{ type: "text", text: safeError("Provenance failed", e) }], isError: true };
|
|
3694
3211
|
}
|
|
3695
3212
|
});
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
delegation_ref: z.string(),
|
|
3701
|
-
was_delegated: z.boolean().default(false),
|
|
3702
|
-
complexity: z.number().min(0).max(1).default(0.5),
|
|
3703
|
-
}, async (args) => {
|
|
3704
|
-
const keyErr = requireKey();
|
|
3705
|
-
if (keyErr)
|
|
3706
|
-
return { content: [{ type: "text", text: keyErr }], isError: true };
|
|
3707
|
-
try {
|
|
3708
|
-
const record = {
|
|
3709
|
-
action_id: args.action_id, agent_id: state.agentKey,
|
|
3710
|
-
authority_level: args.authority_level,
|
|
3711
|
-
semantic_uncertainty: args.semantic_uncertainty,
|
|
3712
|
-
risk_class: args.risk_class,
|
|
3713
|
-
delegation_ref: args.delegation_ref,
|
|
3714
|
-
was_delegated: args.was_delegated,
|
|
3715
|
-
complexity: args.complexity,
|
|
3716
|
-
timestamp: new Date().toISOString(),
|
|
3717
|
-
};
|
|
3718
|
-
recordV2Action(record);
|
|
3719
|
-
const anomaly = checkV2FirstMaxAuthority(record);
|
|
3720
|
-
const concentration = computeV2ConcentrationMetrics(state.agentKey);
|
|
3721
|
-
return { content: [{ type: "text", text: JSON.stringify({
|
|
3722
|
-
action_recorded: true, anomaly_flag: anomaly, concentration,
|
|
3723
|
-
}, null, 2) }] };
|
|
3724
|
-
}
|
|
3725
|
-
catch (e) {
|
|
3726
|
-
return { content: [{ type: "text", text: safeError("Anomaly check failed", e) }], isError: true };
|
|
3727
|
-
}
|
|
3728
|
-
});
|
|
3213
|
+
// check_anomaly removed in v3.0.0: anomaly detection is a cross-session
|
|
3214
|
+
// product capability (recordV2Action / checkV2FirstMaxAuthority /
|
|
3215
|
+
// computeV2ConcentrationMetrics). The gateway maintains the per-agent action
|
|
3216
|
+
// history; MCP tools operate per-session and cannot supply meaningful trends.
|
|
3729
3217
|
// ═══════════════════════════════════════
|
|
3730
3218
|
// Data Governance Tools (Modules 36A, 38, 39)
|
|
3731
3219
|
// ═══════════════════════════════════════
|
|
@@ -3770,142 +3258,31 @@ server.tool("register_data_source", "Register a data source with terms for agent
|
|
|
3770
3258
|
state.sourceReceipts.set(receipt.sourceReceiptId, receipt);
|
|
3771
3259
|
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}` }] };
|
|
3772
3260
|
});
|
|
3773
|
-
server.tool("create_data_enforcement_gate", "Create a data enforcement gate that checks terms before allowing data access.
|
|
3261
|
+
server.tool("create_data_enforcement_gate", "[deprecated in v3.0.0 — use gateway.aeoess.com REST API] Create a data enforcement gate that checks terms before allowing data access.", {
|
|
3774
3262
|
mode: z.enum(["enforce", "audit", "off"]).default("enforce").describe("Enforcement mode"),
|
|
3775
|
-
}, async (
|
|
3776
|
-
|
|
3777
|
-
state.dataEnforcementGate = new DataEnforcementGate({
|
|
3778
|
-
gatewayId: 'gw_data_' + Date.now().toString(36),
|
|
3779
|
-
gatewayPublicKey: kp.publicKey,
|
|
3780
|
-
gatewayPrivateKey: kp.privateKey,
|
|
3781
|
-
mode: p.mode,
|
|
3782
|
-
}, state.contributionLedger);
|
|
3783
|
-
// Register all known sources
|
|
3784
|
-
for (const [id, receipt] of state.sourceReceipts) {
|
|
3785
|
-
state.dataEnforcementGate.registerSource(receipt, receipt.contentDescriptor);
|
|
3786
|
-
}
|
|
3787
|
-
return { content: [{ type: "text", text: `✅ Data enforcement gate created.\n\nMode: ${p.mode}\nRegistered sources: ${state.sourceReceipts.size}\nContribution ledger: active` }] };
|
|
3788
|
-
});
|
|
3789
|
-
server.tool("check_data_access", "Check if an agent can access a data source through the enforcement gate. Generates receipt and feeds contribution ledger.", {
|
|
3790
|
-
sourceReceiptId: z.string().describe("Source receipt ID to access"),
|
|
3791
|
-
declaredPurpose: z.enum(["read", "analyze", "summarize", "generate", "recommend", "train", "embed", "redistribute", "commercial"]).describe("Declared purpose"),
|
|
3792
|
-
accessMethod: z.enum(["api_call", "file_read", "database_query", "web_fetch", "memory_retrieval", "embedding_lookup", "stream", "human_provided"]).default("api_call"),
|
|
3793
|
-
}, async (p) => {
|
|
3794
|
-
if (!state.dataEnforcementGate)
|
|
3795
|
-
return { content: [{ type: "text", text: "❌ No enforcement gate. Call create_data_enforcement_gate first." }] };
|
|
3796
|
-
if (!state.agentKey)
|
|
3797
|
-
return { content: [{ type: "text", text: "❌ Not identified." }] };
|
|
3798
|
-
const decision = state.dataEnforcementGate.checkAccess({
|
|
3799
|
-
agentId: state.agentId || 'unknown',
|
|
3800
|
-
agentPublicKey: state.agentKey,
|
|
3801
|
-
principalId: state.principal?.principalId || 'unknown',
|
|
3802
|
-
sourceReceiptId: p.sourceReceiptId,
|
|
3803
|
-
declaredPurpose: p.declaredPurpose,
|
|
3804
|
-
accessMethod: p.accessMethod,
|
|
3805
|
-
accessScope: 'data:' + p.declaredPurpose,
|
|
3806
|
-
executionFrameId: 'frame_' + Date.now().toString(36),
|
|
3807
|
-
});
|
|
3808
|
-
const status = decision.allowed ? '✅ Access ALLOWED' : '❌ Access DENIED';
|
|
3809
|
-
let text = `${status}\n\nSource: ${p.sourceReceiptId}\nPurpose: ${p.declaredPurpose}`;
|
|
3810
|
-
if (decision.hardViolations.length)
|
|
3811
|
-
text += `\nViolations: ${decision.hardViolations.join('; ')}`;
|
|
3812
|
-
if (decision.advisoryWarnings.length)
|
|
3813
|
-
text += `\nWarnings: ${decision.advisoryWarnings.join('; ')}`;
|
|
3814
|
-
if (decision.receipt)
|
|
3815
|
-
text += `\nReceipt ID: ${decision.receipt.accessReceiptId}`;
|
|
3816
|
-
if (decision.accessesRemaining !== undefined)
|
|
3817
|
-
text += `\nAccesses remaining: ${decision.accessesRemaining}`;
|
|
3818
|
-
return { content: [{ type: "text", text }] };
|
|
3819
|
-
});
|
|
3820
|
-
server.tool("query_contributions", "Query the data contribution ledger. Filter by source, agent, principal, purpose, or time range.", {
|
|
3263
|
+
}, async (_args) => movedToGateway("create_data_enforcement_gate"));
|
|
3264
|
+
server.tool("query_contributions", "[deprecated in v3.0.0 — use gateway.aeoess.com REST API] Query the data contribution ledger.", {
|
|
3821
3265
|
sourceReceiptId: z.string().optional(),
|
|
3822
3266
|
agentId: z.string().optional(),
|
|
3823
3267
|
principalId: z.string().optional(),
|
|
3824
3268
|
purpose: z.string().optional(),
|
|
3825
3269
|
minAccessCount: z.number().optional(),
|
|
3826
|
-
}, async (
|
|
3827
|
-
|
|
3828
|
-
if (records.length === 0)
|
|
3829
|
-
return { content: [{ type: "text", text: "No contributions found matching query." }] };
|
|
3830
|
-
const lines = records.map(r => `• ${r.sourceDescriptor || r.sourceReceiptId}: ${r.accessCount} accesses by ${r.agentId}, purposes: ${r.purposes.join('/')}, owed: $${r.compensationAccrued.totalOwed.toFixed(4)}`);
|
|
3831
|
-
return { content: [{ type: "text", text: `📊 ${records.length} contribution records:\n\n${lines.join('\n')}` }] };
|
|
3832
|
-
});
|
|
3833
|
-
server.tool("get_source_metrics", "Get aggregate metrics for a data source: total accesses, unique agents, compensation owed.", {
|
|
3834
|
-
sourceReceiptId: z.string().describe("Source receipt ID"),
|
|
3835
|
-
}, async (p) => {
|
|
3836
|
-
const metrics = getSourceMetrics(state.contributionLedger, p.sourceReceiptId);
|
|
3837
|
-
if (!metrics)
|
|
3838
|
-
return { content: [{ type: "text", text: "No data found for this source." }] };
|
|
3839
|
-
return { content: [{ type: "text", text: `📊 Source Metrics: ${metrics.sourceDescriptor}\n\nTotal accesses: ${metrics.totalAccesses}\nUnique agents: ${metrics.uniqueAgents}\nUnique principals: ${metrics.uniquePrincipals}\nCompensation owed: $${metrics.compensationOwed.totalOwed.toFixed(4)} ${metrics.compensationOwed.currency}\nPurpose breakdown: ${JSON.stringify(metrics.purposeBreakdown)}\nTop agents: ${metrics.topAgents.map(a => `${a.agentId} (${a.accessCount})`).join(', ')}` }] };
|
|
3840
|
-
});
|
|
3841
|
-
server.tool("get_agent_data_footprint", "Show every data source an agent has accessed, with compensation status.", {
|
|
3842
|
-
agentId: z.string().describe("Agent ID to check"),
|
|
3843
|
-
}, async (p) => {
|
|
3844
|
-
const footprint = getAgentDataFootprint(state.contributionLedger, p.agentId);
|
|
3845
|
-
if (!footprint)
|
|
3846
|
-
return { content: [{ type: "text", text: "No data access found for this agent." }] };
|
|
3847
|
-
const sources = footprint.sourcesAccessed.map(s => `• ${s.sourceDescriptor || s.sourceReceiptId}: ${s.accessCount} accesses, purposes: ${s.purposes.join('/')}, status: ${s.compensationStatus}`);
|
|
3848
|
-
return { content: [{ type: "text", text: `🔍 Agent Data Footprint: ${p.agentId}\n\nTotal sources: ${footprint.totalSources}\nTotal accesses: ${footprint.totalAccesses}\nTotal compensation accrued: $${footprint.totalCompensationAccrued.toFixed(4)} ${footprint.currency}\n\nSources:\n${sources.join('\n')}` }] };
|
|
3849
|
-
});
|
|
3850
|
-
server.tool("generate_settlement", "Generate a Merkle-committed, signed settlement record for a period. Shows what's owed to each data source.", {
|
|
3270
|
+
}, async (_args) => movedToGateway("query_contributions"));
|
|
3271
|
+
server.tool("generate_settlement", "[deprecated in v3.0.0 — use gateway.aeoess.com REST API] Generate a Merkle-committed, signed settlement record for a period.", {
|
|
3851
3272
|
startDate: z.string().describe("Period start (YYYY-MM-DD)"),
|
|
3852
3273
|
endDate: z.string().describe("Period end (YYYY-MM-DD)"),
|
|
3853
3274
|
periodLabel: z.string().describe("Label (e.g. '2026-Q1', '2026-03')"),
|
|
3854
|
-
}, async (
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
periodLabel: z.string().describe("Label"),
|
|
3866
|
-
agentId: z.string().optional().describe("Filter by agent"),
|
|
3867
|
-
principalId: z.string().optional().describe("Filter by principal"),
|
|
3868
|
-
}, async (p) => {
|
|
3869
|
-
const kp = generateKeyPair();
|
|
3870
|
-
const report = generateDataComplianceReport(state.contributionLedger, { startDate: p.startDate, endDate: p.endDate, periodLabel: p.periodLabel }, p.reportType, kp.privateKey, { agentId: p.agentId, principalId: p.principalId });
|
|
3871
|
-
return { content: [{ type: "text", text: `📋 Compliance Report: ${report.reportId}\n\nType: ${p.reportType}\nPeriod: ${p.periodLabel}\nTotal data accesses: ${report.summary.totalDataAccesses}\nUnique data sources: ${report.summary.uniqueDataSources}\nPurpose breakdown: ${JSON.stringify(report.summary.purposeBreakdown)}\nCompensation: $${report.summary.compensationSummary.total.toFixed(4)} (pending: $${report.summary.compensationSummary.pending.toFixed(4)})\nTerms violations: ${report.summary.termsViolations}\nAdvisory warnings: ${report.summary.advisoryWarnings}\nSigned: ✅` }] };
|
|
3872
|
-
});
|
|
3873
|
-
server.tool("record_training_use", "Record that agent output derived from data sources was used for training/fine-tuning/embedding. Creates a signed training attribution receipt.", {
|
|
3874
|
-
trainingUseType: z.enum(["fine_tune", "lora_adapter", "embedding", "rag_index", "distillation", "evaluation", "synthetic_data"]).describe("Type of training use"),
|
|
3875
|
-
modelId: z.string().describe("Model being trained"),
|
|
3876
|
-
sourceAccessReceiptIds: z.array(z.string()).describe("Access receipt IDs of source data used"),
|
|
3877
|
-
outputContentHash: z.string().describe("SHA-256 of the output used for training"),
|
|
3878
|
-
contributionWeights: z.record(z.number()).optional().describe("Fractional weights per source (sum to 1.0)"),
|
|
3879
|
-
datasetSize: z.number().optional().describe("Number of training examples"),
|
|
3880
|
-
}, async (p) => {
|
|
3881
|
-
if (!state.agentKey || !state.privateKey)
|
|
3882
|
-
return { content: [{ type: "text", text: "❌ Not identified." }] };
|
|
3883
|
-
const receipt = createTrainingAttribution({
|
|
3884
|
-
trainingUseType: p.trainingUseType,
|
|
3885
|
-
modelId: p.modelId,
|
|
3886
|
-
trainerId: state.agentId || 'unknown',
|
|
3887
|
-
trainerPublicKey: state.agentKey,
|
|
3888
|
-
trainerPrivateKey: state.privateKey,
|
|
3889
|
-
sourceAccessReceiptIds: p.sourceAccessReceiptIds,
|
|
3890
|
-
executionFrameId: 'frame_train_' + Date.now().toString(36),
|
|
3891
|
-
outputContentHash: p.outputContentHash,
|
|
3892
|
-
inputDataHashes: p.sourceAccessReceiptIds.map(id => id), // simplified
|
|
3893
|
-
contributionWeights: p.contributionWeights,
|
|
3894
|
-
datasetSize: p.datasetSize,
|
|
3895
|
-
});
|
|
3896
|
-
recordTrainingAttribution(state.trainingLedger, receipt);
|
|
3897
|
-
const v = verifyTrainingAttribution(receipt);
|
|
3898
|
-
return { content: [{ type: "text", text: `✅ Training attribution recorded.\n\nReceipt: ${receipt.trainingReceiptId}\nType: ${p.trainingUseType}\nModel: ${p.modelId}\nSources: ${p.sourceAccessReceiptIds.length}\nDataset size: ${p.datasetSize || 'N/A'}\nWeights: ${p.contributionWeights ? JSON.stringify(p.contributionWeights) : 'equal'}\nVerification: ${v.valid ? '✅' : '❌'}` }] };
|
|
3899
|
-
});
|
|
3900
|
-
server.tool("get_model_data_sources", "Show which data sources contributed to a model's training, with fractional weights.", {
|
|
3901
|
-
modelId: z.string().describe("Model ID to check"),
|
|
3902
|
-
}, async (p) => {
|
|
3903
|
-
const sources = getModelDataSources(state.trainingLedger, p.modelId);
|
|
3904
|
-
if (sources.length === 0)
|
|
3905
|
-
return { content: [{ type: "text", text: "No training data found for this model." }] };
|
|
3906
|
-
const lines = sources.map(s => `• ${s.accessReceiptId}: weight ${s.weight.toFixed(4)}, type: ${s.trainingUseType}`);
|
|
3907
|
-
return { content: [{ type: "text", text: `🧠 Model Training Sources: ${p.modelId}\n\n${sources.length} data sources contributed:\n${lines.join('\n')}` }] };
|
|
3908
|
-
});
|
|
3275
|
+
}, async (_args) => movedToGateway("generate_settlement"));
|
|
3276
|
+
// Removed in v3.0.0 (moved to gateway product — no stub to keep tool count bounded):
|
|
3277
|
+
// check_data_access (DataEnforcementGate.checkAccess)
|
|
3278
|
+
// get_source_metrics (cross-agent ledger aggregation)
|
|
3279
|
+
// get_agent_data_footprint (cross-agent ledger aggregation)
|
|
3280
|
+
// generate_compliance_report (generateDataComplianceReport)
|
|
3281
|
+
// record_training_use (createTrainingAttribution + ledger)
|
|
3282
|
+
// get_model_data_sources (training ledger aggregation)
|
|
3283
|
+
// All of these required ContributionLedger / TrainingAttributionLedger
|
|
3284
|
+
// (ledger classes are gateway-product). The underlying primitives
|
|
3285
|
+
// (access receipts, settlement signing) remain in the SDK at aps_* tools.
|
|
3909
3286
|
// ═══════════════════════════════════════
|
|
3910
3287
|
// Data Lifecycle Governance Tools
|
|
3911
3288
|
// ═══════════════════════════════════════
|
|
@@ -4911,6 +4288,71 @@ server.tool("aps_compute_compute_axis_weights", "Compute the C-axis fractional w
|
|
|
4911
4288
|
// from the compiled bundle — consumers of the two tools above will want
|
|
4912
4289
|
// to introspect the defaults.
|
|
4913
4290
|
void DEFAULT_WEIGHT_PROFILE;
|
|
4291
|
+
// ═══════════════════════════════════════
|
|
4292
|
+
// Attribution Settlement — Build C per-period settlement record.
|
|
4293
|
+
// Spec: BUILD-C-SETTLEMENT-PIPELINE.md. Aggregates a stream of
|
|
4294
|
+
// AttributionPrimitives over [t0, t1) into one signed record per axis
|
|
4295
|
+
// with a balanced-Merkle commitment. Settlement is evidence, not
|
|
4296
|
+
// payment — economic conversion is gateway-private.
|
|
4297
|
+
// ═══════════════════════════════════════
|
|
4298
|
+
const SettlementPeriodSchema = z.object({
|
|
4299
|
+
t0: z.string().describe("Period start (canonical ISO-8601 UTC ms + Z). Inclusive."),
|
|
4300
|
+
t1: z.string().describe("Period end (canonical ISO-8601 UTC ms + Z). Exclusive."),
|
|
4301
|
+
period_id: z.string().describe("Gateway-scoped period identifier"),
|
|
4302
|
+
});
|
|
4303
|
+
server.tool("aps_aggregate_settlement", "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.", {
|
|
4304
|
+
receipts: z.array(z.any()).describe("Array of AttributionPrimitives to aggregate"),
|
|
4305
|
+
period: SettlementPeriodSchema,
|
|
4306
|
+
gateway_did: z.string().describe("Gateway DID that signs the record"),
|
|
4307
|
+
gateway_private_key: z.string().describe("Ed25519 gateway private key (hex)"),
|
|
4308
|
+
issued_at: z.string().optional().describe("Override issued_at (canonical ISO-8601 UTC ms + Z); defaults to now"),
|
|
4309
|
+
}, async (args) => {
|
|
4310
|
+
try {
|
|
4311
|
+
const unsigned = aggregateAttributionPrimitives(args.receipts, args.period, {
|
|
4312
|
+
gateway_did: args.gateway_did,
|
|
4313
|
+
issued_at: args.issued_at,
|
|
4314
|
+
});
|
|
4315
|
+
const signature = signSettlementRecord(unsigned, args.gateway_private_key);
|
|
4316
|
+
const record = { ...unsigned, signature };
|
|
4317
|
+
return { content: [{ type: "text", text: JSON.stringify(record, null, 2) }] };
|
|
4318
|
+
}
|
|
4319
|
+
catch (e) {
|
|
4320
|
+
return { content: [{ type: "text", text: safeError("aggregateSettlement failed", e) }], isError: true };
|
|
4321
|
+
}
|
|
4322
|
+
});
|
|
4323
|
+
server.tool("aps_verify_settlement", "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.", {
|
|
4324
|
+
record: z.any().describe("A signed SettlementRecord"),
|
|
4325
|
+
gateway_public_key: z.string().describe("Gateway Ed25519 public key hex"),
|
|
4326
|
+
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."),
|
|
4327
|
+
}, async (args) => {
|
|
4328
|
+
try {
|
|
4329
|
+
const result = verifySettlementRecord(args.record, {
|
|
4330
|
+
gatewayPublicKeyHex: args.gateway_public_key,
|
|
4331
|
+
inputReceipts: args.input_receipts,
|
|
4332
|
+
});
|
|
4333
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
4334
|
+
}
|
|
4335
|
+
catch (e) {
|
|
4336
|
+
return { content: [{ type: "text", text: safeError("verifySettlement failed", e) }], isError: true };
|
|
4337
|
+
}
|
|
4338
|
+
});
|
|
4339
|
+
server.tool("aps_build_contributor_query", "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.", {
|
|
4340
|
+
record: z.any().describe("A signed SettlementRecord"),
|
|
4341
|
+
contributor_did: z.string().describe("Contributor DID (data source, compute provider, governance signer, or protocol module identifier)"),
|
|
4342
|
+
gateway_jwks: z.string().optional().describe("Advisory JWKS URL; not part of the signed material"),
|
|
4343
|
+
}, async (args) => {
|
|
4344
|
+
try {
|
|
4345
|
+
const response = buildContributorQueryResponse(args.record, args.contributor_did, {
|
|
4346
|
+
gateway_jwks: args.gateway_jwks,
|
|
4347
|
+
});
|
|
4348
|
+
return {
|
|
4349
|
+
content: [{ type: "text", text: JSON.stringify(response, null, 2) }],
|
|
4350
|
+
};
|
|
4351
|
+
}
|
|
4352
|
+
catch (e) {
|
|
4353
|
+
return { content: [{ type: "text", text: safeError("buildContributorQuery failed", e) }], isError: true };
|
|
4354
|
+
}
|
|
4355
|
+
});
|
|
4914
4356
|
server.prompt("coordination_role", "Get instructions for your assigned coordination role", {}, async () => {
|
|
4915
4357
|
const role = state.agentRole || 'default';
|
|
4916
4358
|
const instructions = ROLE_PROMPTS[role] || ROLE_PROMPTS['default'];
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-passport-system-mcp",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"mcpName": "io.github.aeoess/agent-passport-mcp",
|
|
5
|
-
"description": "MCP server for the Agent Passport System —
|
|
5
|
+
"description": "MCP server for the Agent Passport System — protocol-layer tools only. 142 tools (132 protocol + 10 gateway deprecation stubs). Identity, delegation, reputation, attestation, coordination, commerce, attribution primitive, attribution settlement. Tracks SDK v2.0.0. For gateway-runtime tools (ProxyGateway, AgentContext, DataEnforcementGate), use gateway.aeoess.com REST API or pin to v2.27.0.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
8
|
"agent-passport-system-mcp": "./build/bin.js",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"homepage": "https://github.com/aeoess/agent-passport-mcp",
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
53
|
-
"agent-passport-system": "^
|
|
53
|
+
"agent-passport-system": "^2.0.0-beta.0",
|
|
54
54
|
"zod": "^3.25.76"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|