@agledger/mcp-server 1.4.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/errors.d.ts +6 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +8 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +6 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +71 -76
- package/dist/server.js.map +1 -1
- package/dist/tool-scopes.js +3 -2
- package/dist/tool-scopes.js.map +1 -1
- package/dist/tools/a2a.d.ts.map +1 -1
- package/dist/tools/a2a.js +22 -222
- package/dist/tools/a2a.js.map +1 -1
- package/dist/tools/agent-mandates.d.ts.map +1 -1
- package/dist/tools/agent-mandates.js +11 -75
- package/dist/tools/agent-mandates.js.map +1 -1
- package/dist/tools/agents-refs.d.ts.map +1 -1
- package/dist/tools/agents-refs.js +10 -61
- package/dist/tools/agents-refs.js.map +1 -1
- package/dist/tools/capabilities.d.ts.map +1 -1
- package/dist/tools/capabilities.js +3 -15
- package/dist/tools/capabilities.js.map +1 -1
- package/dist/tools/code-mode.d.ts.map +1 -1
- package/dist/tools/code-mode.js +4 -35
- package/dist/tools/code-mode.js.map +1 -1
- package/dist/tools/compliance.d.ts.map +1 -1
- package/dist/tools/compliance.js +4 -13
- package/dist/tools/compliance.js.map +1 -1
- package/dist/tools/dashboard.d.ts.map +1 -1
- package/dist/tools/dashboard.js +4 -13
- package/dist/tools/dashboard.js.map +1 -1
- package/dist/tools/disputes.d.ts.map +1 -1
- package/dist/tools/disputes.js +5 -37
- package/dist/tools/disputes.js.map +1 -1
- package/dist/tools/enterprises.d.ts.map +1 -1
- package/dist/tools/enterprises.js +7 -39
- package/dist/tools/enterprises.js.map +1 -1
- package/dist/tools/events.d.ts.map +1 -1
- package/dist/tools/events.js +2 -20
- package/dist/tools/events.js.map +1 -1
- package/dist/tools/federation-admin.d.ts.map +1 -1
- package/dist/tools/federation-admin.js +25 -257
- package/dist/tools/federation-admin.js.map +1 -1
- package/dist/tools/federation.d.ts.map +1 -1
- package/dist/tools/federation.js +21 -198
- package/dist/tools/federation.js.map +1 -1
- package/dist/tools/health.d.ts.map +1 -1
- package/dist/tools/health.js +2 -14
- package/dist/tools/health.js.map +1 -1
- package/dist/tools/mandates.d.ts.map +1 -1
- package/dist/tools/mandates.js +11 -83
- package/dist/tools/mandates.js.map +1 -1
- package/dist/tools/openclaw.d.ts.map +1 -1
- package/dist/tools/openclaw.js +6 -33
- package/dist/tools/openclaw.js.map +1 -1
- package/dist/tools/receipts.d.ts.map +1 -1
- package/dist/tools/receipts.js +5 -96
- package/dist/tools/receipts.js.map +1 -1
- package/dist/tools/reputation.d.ts.map +1 -1
- package/dist/tools/reputation.js +4 -13
- package/dist/tools/reputation.js.map +1 -1
- package/dist/tools/schemas.d.ts.map +1 -1
- package/dist/tools/schemas.js +34 -159
- package/dist/tools/schemas.js.map +1 -1
- package/dist/tools/verification-keys.d.ts.map +1 -1
- package/dist/tools/verification-keys.js +2 -23
- package/dist/tools/verification-keys.js.map +1 -1
- package/dist/tools/verification.d.ts.map +1 -1
- package/dist/tools/verification.js +3 -28
- package/dist/tools/verification.js.map +1 -1
- package/package.json +1 -1
- package/src/errors.ts +9 -0
- package/src/index.ts +1 -3
- package/src/server.ts +77 -71
- package/src/tool-scopes.ts +3 -3
- package/src/tools/a2a.ts +22 -235
- package/src/tools/agent-mandates.ts +11 -77
- package/src/tools/agents-refs.ts +10 -65
- package/src/tools/capabilities.ts +3 -16
- package/src/tools/compliance.ts +4 -13
- package/src/tools/dashboard.ts +4 -13
- package/src/tools/disputes.ts +5 -38
- package/src/tools/enterprises.ts +7 -39
- package/src/tools/events.ts +2 -21
- package/src/tools/federation-admin.ts +25 -282
- package/src/tools/federation.ts +21 -218
- package/src/tools/health.ts +2 -15
- package/src/tools/mandates.ts +11 -85
- package/src/tools/openclaw.ts +6 -52
- package/src/tools/receipts.ts +5 -97
- package/src/tools/reputation.ts +4 -13
- package/src/tools/schemas.ts +34 -166
- package/src/tools/verification-keys.ts +2 -25
- package/src/tools/verification.ts +3 -30
- package/tests/conformance.test.ts +197 -0
- package/tests/conformance.ts +65 -0
- package/tests/harness.ts +55 -0
- package/tests/mock-client.ts +71 -0
- package/tests/profiles.test.ts +120 -0
- package/tests/resources/contract-types.test.ts +82 -0
- package/tests/tools/a2a.test.ts +213 -0
- package/tests/tools/agent-mandates.test.ts +196 -0
- package/tests/tools/agents-refs.test.ts +190 -0
- package/tests/tools/capabilities.test.ts +80 -0
- package/tests/tools/compliance.test.ts +123 -0
- package/tests/tools/dashboard.test.ts +111 -0
- package/tests/tools/disputes.test.ts +123 -0
- package/tests/tools/enterprises.test.ts +171 -0
- package/tests/tools/events.test.ts +56 -0
- package/tests/tools/federation-admin.test.ts +468 -0
- package/tests/tools/federation.test.ts +522 -0
- package/tests/tools/health.test.ts +56 -0
- package/tests/tools/mandates.test.ts +143 -0
- package/tests/tools/openclaw.test.ts +148 -0
- package/tests/tools/receipts.test.ts +157 -0
- package/tests/tools/reputation.test.ts +108 -0
- package/tests/tools/schemas.test.ts +374 -0
- package/tests/tools/verification-keys.test.ts +56 -0
- package/tests/tools/verification.test.ts +64 -0
- package/src/tools/code-mode.ts +0 -461
- package/tests/code-mode-manifest.test.ts +0 -144
- package/tests/enterprises.test.ts +0 -96
- package/tests/schemas.test.ts +0 -531
package/src/tools/code-mode.ts
DELETED
|
@@ -1,461 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
-
import type { AgledgerClient } from '@agledger/sdk';
|
|
4
|
-
import { AgledgerApiError } from '@agledger/sdk';
|
|
5
|
-
import { apiErrorResult } from '../errors.js';
|
|
6
|
-
import { toolMeta } from '../tool-scopes.js';
|
|
7
|
-
|
|
8
|
-
const RESOURCE_MANIFEST: Record<string, string> = {
|
|
9
|
-
mandates: `## client.mandates
|
|
10
|
-
- create(params: CreateMandateParams): Promise<Mandate>
|
|
11
|
-
- createAgent(params: CreateAgentMandateParams): Promise<Mandate>
|
|
12
|
-
- get(id: string): Promise<Mandate>
|
|
13
|
-
- list(params: ListMandatesParams): Promise<Page<Mandate>>
|
|
14
|
-
- listAll(params: ListMandatesParams): AsyncGenerator<Mandate>
|
|
15
|
-
- search(params: SearchMandatesParams): Promise<Page<Mandate>>
|
|
16
|
-
- update(id: string, params: UpdateMandateParams): Promise<Mandate>
|
|
17
|
-
- transition(id: string, action: MandateTransitionAction, reason?: string): Promise<Mandate>
|
|
18
|
-
- cancel(id: string, reason?: string): Promise<Mandate>
|
|
19
|
-
- accept(id: string): Promise<Mandate>
|
|
20
|
-
- reject(id: string, reason?: string): Promise<Mandate>
|
|
21
|
-
- counterPropose(id: string, params: CounterProposeParams): Promise<Mandate>
|
|
22
|
-
- acceptCounter(id: string): Promise<Mandate>
|
|
23
|
-
- getChain(id: string): Promise<Mandate[]>
|
|
24
|
-
- getSubMandates(id: string): Promise<Page<Mandate>>
|
|
25
|
-
- delegate(id: string, params: DelegateMandateParams): Promise<Mandate>
|
|
26
|
-
- bulkCreate(mandates: CreateMandateParams[]): Promise<BulkCreateResult>
|
|
27
|
-
- getAudit(id: string): Promise<AuditChain>
|
|
28
|
-
- listAsPrincipal(): Promise<Page<Mandate>>
|
|
29
|
-
- listProposals(): Promise<Page<Mandate>>
|
|
30
|
-
- requestRevision(id: string, reason?: string): Promise<Mandate>
|
|
31
|
-
- createAndActivate(params: CreateMandateParams): Promise<Mandate>
|
|
32
|
-
- reportOutcome(id: string, params: ReportOutcomeParams): Promise<OutcomeResult>
|
|
33
|
-
- getSummary(params?: { enterpriseId?: string }): Promise<MandateStatusSummary>
|
|
34
|
-
- getGraph(id: string): Promise<Record<string, unknown>>
|
|
35
|
-
- batchGet(ids: string[]): Promise<Mandate[]>
|
|
36
|
-
- getValidTransitions(mandate: Mandate): readonly string[] (client-side, no API call)`,
|
|
37
|
-
|
|
38
|
-
receipts: `## client.receipts
|
|
39
|
-
- submit(mandateId: string, params: SubmitReceiptParams): Promise<Receipt>
|
|
40
|
-
- get(mandateId: string, receiptId: string): Promise<Receipt>
|
|
41
|
-
- list(mandateId: string, params?: ListParams): Promise<Page<Receipt>>
|
|
42
|
-
- listAll(mandateId: string, params?: ListParams): AsyncGenerator<Receipt>`,
|
|
43
|
-
|
|
44
|
-
verification: `## client.verification
|
|
45
|
-
- verify(mandateId: string, receiptIds?: string[]): Promise<VerificationResult>
|
|
46
|
-
- getStatus(mandateId: string): Promise<VerificationStatus>`,
|
|
47
|
-
|
|
48
|
-
disputes: `## client.disputes
|
|
49
|
-
- create(mandateId: string, params: CreateDisputeParams): Promise<Dispute>
|
|
50
|
-
- get(mandateId: string): Promise<DisputeResponse>
|
|
51
|
-
- escalate(mandateId: string): Promise<Dispute>
|
|
52
|
-
- submitEvidence(mandateId: string, params: { evidenceType: EvidenceType; payload: Record<string, unknown> }): Promise<Record<string, unknown>>`,
|
|
53
|
-
|
|
54
|
-
webhooks: `## client.webhooks
|
|
55
|
-
- create(params: CreateWebhookParams): Promise<Webhook>
|
|
56
|
-
- list(params?: ListWebhooksParams): Promise<Page<Webhook>>
|
|
57
|
-
- get(webhookId: string): Promise<Webhook>
|
|
58
|
-
- update(webhookId: string, params: Partial<CreateWebhookParams>): Promise<Webhook>
|
|
59
|
-
- delete(webhookId: string): Promise<void>
|
|
60
|
-
- pause(webhookId: string): Promise<Webhook>
|
|
61
|
-
- resume(webhookId: string): Promise<Webhook>
|
|
62
|
-
- rotate(webhookId: string): Promise<Webhook>
|
|
63
|
-
- ping(webhookId: string): Promise<WebhookTestResult>
|
|
64
|
-
- listDeliveries(webhookId: string, params?: ListParams & { status?: string }): Promise<Page<WebhookDelivery>>
|
|
65
|
-
- listDlq(webhookId: string, params?: ListParams): Promise<Page<WebhookDlqEntry>>
|
|
66
|
-
- retryAllDlq(webhookId: string): Promise<{ retried: number }>
|
|
67
|
-
- retryDlq(webhookId: string, dlqId: string): Promise<Record<string, unknown>>`,
|
|
68
|
-
|
|
69
|
-
reputation: `## client.reputation
|
|
70
|
-
- getAgent(agentId: string): Promise<Page<ReputationScore>>
|
|
71
|
-
- getByContractType(agentId: string, contractType: string): Promise<ReputationScore>
|
|
72
|
-
- getHistory(agentId: string, params?: ListParams & { from?: string; to?: string; contractType?: string; outcome?: 'PASS' | 'FAIL' }): Promise<Page<ReputationHistoryEntry>>`,
|
|
73
|
-
|
|
74
|
-
events: `## client.events
|
|
75
|
-
- list(params: { since: string; order?: 'asc' | 'desc' } & ListParams): Promise<Page<AgledgerEvent>>
|
|
76
|
-
- listAll(params: { since: string; order?: 'asc' | 'desc' } & ListParams): AsyncGenerator<AgledgerEvent>
|
|
77
|
-
- getAuditChain(mandateId: string): Promise<AuditChain>`,
|
|
78
|
-
|
|
79
|
-
schemas: `## client.schemas
|
|
80
|
-
- list(params?: { enterpriseId?: string }): Promise<Page<ContractType>>
|
|
81
|
-
- get(contractType: string): Promise<ContractSchema>
|
|
82
|
-
- delete(contractType: string): Promise<void>
|
|
83
|
-
- getRules(contractType: string): Promise<{ contractType; syncRuleIds; asyncRuleIds }>
|
|
84
|
-
- validateReceipt(contractType: string, evidence: Record<string, unknown>): Promise<SchemaValidationResult>
|
|
85
|
-
- getMetaSchema(): Promise<MetaSchema>
|
|
86
|
-
- getTemplate(contractType: string): Promise<SchemaTemplate>
|
|
87
|
-
- getBlankTemplate(): Promise<SchemaTemplate>
|
|
88
|
-
- getVersions(contractType: string): Promise<SchemaVersionDetail[]>
|
|
89
|
-
- getVersion(contractType: string, version: number): Promise<SchemaVersionDetail>
|
|
90
|
-
- diff(contractType: string, from: number, to: number): Promise<SchemaDiffResult>
|
|
91
|
-
- preview(input: SchemaPreviewInput): Promise<SchemaPreviewResult>
|
|
92
|
-
- checkCompatibility(contractType: string, schemas: { mandateSchema; receiptSchema }): Promise<SchemaCompatibilityResult>
|
|
93
|
-
- register(input: RegisterSchemaParams): Promise<SchemaVersionDetail>
|
|
94
|
-
- updateVersion(contractType: string, version: number, params: UpdateSchemaVersionParams): Promise<SchemaVersionDetail>
|
|
95
|
-
- exportSchema(contractType: string, opts?: ExportSchemaOptions): Promise<SchemaExportResult>
|
|
96
|
-
- importSchema(payload: SchemaImportPayload, opts?: ImportSchemaOptions): Promise<SchemaImportResult>
|
|
97
|
-
- previewImport(payload: SchemaImportPayload, opts?: ImportSchemaOptions): Promise<SchemaImportDryRunResult>`,
|
|
98
|
-
|
|
99
|
-
dashboard: `## client.dashboard
|
|
100
|
-
- getSummary(): Promise<DashboardSummary>
|
|
101
|
-
- getMetrics(params?: DashboardMetricsParams): Promise<DashboardMetrics>
|
|
102
|
-
- listAgents(params?: DashboardAgentParams): Promise<Page<DashboardAgent>>
|
|
103
|
-
- getAlerts(params?: ListParams): Promise<Page<DashboardAlert>>
|
|
104
|
-
- getDisputes(params?: ListParams): Promise<Page<Record<string, unknown>>>
|
|
105
|
-
- getAuditTrail(params?: ListParams): Promise<Page<Record<string, unknown>>>`,
|
|
106
|
-
|
|
107
|
-
compliance: `## client.compliance
|
|
108
|
-
- export(params: ExportComplianceParams): Promise<ComplianceExport>
|
|
109
|
-
- getExportStatus(exportId: string): Promise<ComplianceExport>
|
|
110
|
-
- downloadExport(exportId: string): Promise<Record<string, unknown>>
|
|
111
|
-
- waitForExport(exportId: string, opts?: { pollIntervalMs?; timeoutMs?; signal? }): Promise<ComplianceExport>
|
|
112
|
-
- createAssessment(mandateId: string, params: CreateAiImpactAssessmentParams): Promise<AiImpactAssessment>
|
|
113
|
-
- getAssessment(mandateId: string): Promise<AiImpactAssessment>
|
|
114
|
-
- getEuAiActReport(params?: { from?; to? }): Promise<EuAiActReport>
|
|
115
|
-
- getEnterpriseReport(params?: { from?; to?; format? }): Promise<Record<string, unknown>>
|
|
116
|
-
- analyzeAudit(mandateId: string): Promise<Record<string, unknown>>
|
|
117
|
-
- createRecord(mandateId: string, params: CreateComplianceRecordParams): Promise<ComplianceRecord>
|
|
118
|
-
- listRecords(mandateId: string, params?: ListParams): Promise<Page<ComplianceRecord>>
|
|
119
|
-
- getRecord(mandateId: string, recordId: string): Promise<ComplianceRecord>
|
|
120
|
-
- exportMandate(mandateId: string, params?: { format?: 'json' | 'csv' | 'ndjson' }): Promise<MandateAuditExport>
|
|
121
|
-
- stream(params: AuditStreamParams): Promise<AuditStreamResult>
|
|
122
|
-
- streamAll(params: AuditStreamParams): AsyncGenerator<Record<string, unknown>>`,
|
|
123
|
-
|
|
124
|
-
registration: `## client.registration
|
|
125
|
-
- getMe(): Promise<AccountProfile>
|
|
126
|
-
- register(params: RegisterParams): Promise<RegisterResult>
|
|
127
|
-
- registerEnterprise(params: { name: string; email?: string }): Promise<RegisterResult>
|
|
128
|
-
- registerAgent(params: { name: string; email?: string; agentCardUrl?: string; enterpriseId?: string }): Promise<RegisterResult>
|
|
129
|
-
- verifyAgentCard(agentCardUrl: string): Promise<Record<string, unknown>>
|
|
130
|
-
- rotateApiKey(): Promise<{ apiKey: string }>
|
|
131
|
-
- verifyEmail(token: string): Promise<{ sandboxMode: boolean; status: string }>
|
|
132
|
-
- sendVerificationEmail(email: string): Promise<{ sandboxMode: boolean; status: string }>`,
|
|
133
|
-
|
|
134
|
-
health: `## client.health
|
|
135
|
-
- check(): Promise<HealthResponse>
|
|
136
|
-
- status(): Promise<StatusResponse>
|
|
137
|
-
- conformance(): Promise<ConformanceResponse>`,
|
|
138
|
-
|
|
139
|
-
proxy: `## client.proxy
|
|
140
|
-
Unified resource with sub-resources for governance sidecar proxy operations.
|
|
141
|
-
- syncSession(params: SyncSessionParams): Promise<SyncSessionResult>
|
|
142
|
-
|
|
143
|
-
### client.proxy.sessions
|
|
144
|
-
- create(params: CreateSessionParams): Promise<ProxySession>
|
|
145
|
-
- get(sessionId: string): Promise<ProxySession>
|
|
146
|
-
- list(params?: ListParams): Promise<Page<ProxySession>>
|
|
147
|
-
- sync(params: SyncSessionParams): Promise<SyncSessionResult>
|
|
148
|
-
|
|
149
|
-
### client.proxy.toolCalls
|
|
150
|
-
- ingest(sessionId: string, items: ToolCallBatchItem[]): Promise<BatchResult<ProxyToolCall>>
|
|
151
|
-
- list(sessionId: string, params?: ListParams): Promise<Page<ProxyToolCall>>
|
|
152
|
-
|
|
153
|
-
### client.proxy.sidecarMandates
|
|
154
|
-
- ingest(sessionId: string, items: SidecarMandateBatchItem[]): Promise<BatchResult<ProxySidecarMandate>>
|
|
155
|
-
- list(params?: ListParams & { sessionId?: string }): Promise<Page<ProxySidecarMandate>>
|
|
156
|
-
- listBySession(sessionId: string, params?: ListParams): Promise<Page<ProxySidecarMandate>>
|
|
157
|
-
- update(id: string, params: UpdateSidecarMandateParams): Promise<ProxySidecarMandate>
|
|
158
|
-
- formalize(id: string, formalizedMandateId: string): Promise<ProxySidecarMandate>
|
|
159
|
-
- dismiss(id: string): Promise<ProxySidecarMandate>
|
|
160
|
-
|
|
161
|
-
### client.proxy.sidecarReceipts
|
|
162
|
-
- ingest(sessionId: string, items: SidecarReceiptBatchItem[]): Promise<BatchResult<ProxySidecarReceipt>>
|
|
163
|
-
- listBySession(sessionId: string, params?: ListParams): Promise<Page<ProxySidecarReceipt>>
|
|
164
|
-
|
|
165
|
-
### client.proxy.toolCatalog
|
|
166
|
-
- ingest(sessionId: string, items: ToolCatalogBatchItem[]): Promise<BatchResult<ProxyToolCatalogEntry>>
|
|
167
|
-
- list(sessionId: string): Promise<Page<ProxyToolCatalogEntry>>
|
|
168
|
-
|
|
169
|
-
### client.proxy.analytics
|
|
170
|
-
- getSession(sessionId: string): Promise<SessionAnalytics>
|
|
171
|
-
- getSummary(params?: { from?; to? }): Promise<AnalyticsSummary>
|
|
172
|
-
- getMandateSummary(sessionId: string): Promise<MandateSummary>
|
|
173
|
-
- getAlignment(sessionId: string): Promise<AlignmentAnalysis>`,
|
|
174
|
-
|
|
175
|
-
admin: `## client.admin
|
|
176
|
-
Platform-level administration. Requires platform API key.
|
|
177
|
-
- listEnterprises(params?: ListParams): Promise<Page<AdminEnterprise>>
|
|
178
|
-
- createEnterprise(params: CreateEnterpriseParams): Promise<AdminEnterprise>
|
|
179
|
-
- listAgents(params?: ListParams): Promise<Page<AdminAgent>>
|
|
180
|
-
- createAgent(params: CreateAgentParams): Promise<AdminAgent>
|
|
181
|
-
- updateTrustLevel(accountId: string, params: UpdateTrustLevelParams): Promise<Record<string, unknown>>
|
|
182
|
-
- deactivateAccount(accountId: string, params: { accountType: 'enterprise' | 'agent'; reason?: string }): Promise<Record<string, unknown>>
|
|
183
|
-
- setCapabilities(agentId: string, params: SetCapabilitiesParams): Promise<Record<string, unknown>>
|
|
184
|
-
- getFleetCapabilities(): Promise<Page<{ agentId; capabilities }>>
|
|
185
|
-
- getEnterpriseConfig(enterpriseId: string): Promise<EnterpriseConfig>
|
|
186
|
-
- replaceEnterpriseConfig(enterpriseId: string, params: SetEnterpriseConfigParams): Promise<EnterpriseConfig>
|
|
187
|
-
- updateEnterpriseConfig(enterpriseId: string, params: SetEnterpriseConfigParams): Promise<EnterpriseConfig>
|
|
188
|
-
- listApiKeys(params?: ListParams): Promise<Page<AdminApiKey>>
|
|
189
|
-
- createApiKey(params: CreateApiKeyParams): Promise<CreateApiKeyResult>
|
|
190
|
-
- toggleApiKey(keyId: string, isActive: boolean): Promise<AdminApiKey>
|
|
191
|
-
- bulkRevokeApiKeys(keyIds: string[]): Promise<{ revoked: number }>
|
|
192
|
-
- getLicense(): Promise<LicenseInfo>
|
|
193
|
-
- listMandates(params?: QueryAdminMandatesParams): Promise<Page<Record<string, unknown>>>
|
|
194
|
-
- listDlq(params?: ListParams): Promise<Page<WebhookDlqEntry>>
|
|
195
|
-
- retryDlq(dlqId: string): Promise<Record<string, unknown>>
|
|
196
|
-
- retryAllDlq(): Promise<{ retried: number }>
|
|
197
|
-
- getSystemHealth(): Promise<SystemHealth>
|
|
198
|
-
- listRateLimitExemptions(): Promise<Page<string>>
|
|
199
|
-
- setRateLimitExemption(ip: string): Promise<{ ip; exempt }>
|
|
200
|
-
- deleteRateLimitExemption(ip: string): Promise<{ ip; exempt }>
|
|
201
|
-
- getWebhookHealth(params?: ListParams): Promise<Page<Record<string, unknown>>>
|
|
202
|
-
- updateCircuitBreaker(webhookId: string, params: UpdateCircuitBreakerParams): Promise<CircuitBreakerResult>
|
|
203
|
-
- listVaultSigningKeys(): Promise<VaultSigningKey[]>
|
|
204
|
-
- rotateVaultSigningKey(): Promise<VaultSigningKey>
|
|
205
|
-
- listVaultAnchors(): Promise<VaultAnchor[]>
|
|
206
|
-
- verifyVaultAnchors(): Promise<VaultAnchorVerifyResult>
|
|
207
|
-
- startVaultScan(): Promise<VaultScanJob>
|
|
208
|
-
- getVaultScanStatus(jobId: string): Promise<VaultScanJob>
|
|
209
|
-
- flushAuthCache(): Promise<{ flushed: boolean }>
|
|
210
|
-
- getAuthCacheStats(): Promise<AuthCacheStats>
|
|
211
|
-
- flushSchemaCache(): Promise<{ flushed: boolean }>
|
|
212
|
-
- listOwnerRateLimitExemptions(): Promise<Record<string, unknown>[]>
|
|
213
|
-
- setOwnerRateLimitExemption(ownerId: string): Promise<Record<string, unknown>>
|
|
214
|
-
- deleteOwnerRateLimitExemption(ownerId: string): Promise<Record<string, unknown>>`,
|
|
215
|
-
|
|
216
|
-
a2a: `## client.a2a
|
|
217
|
-
Agent-to-Agent protocol (A2A). JSON-RPC 2.0 dispatch.
|
|
218
|
-
- getAgentCard(): Promise<AgentCard>
|
|
219
|
-
- dispatch(request: JsonRpcRequest): Promise<JsonRpcResponse>
|
|
220
|
-
- call(method: string, params?: Record<string, unknown>): Promise<JsonRpcResponse>`,
|
|
221
|
-
|
|
222
|
-
capabilities: `## client.capabilities
|
|
223
|
-
- get(agentId: string): Promise<{ agentId; capabilities: ContractType[] }>
|
|
224
|
-
- set(agentId: string, params: SetCapabilitiesParams): Promise<{ agentId; capabilities: ContractType[] }> (PUT — replaces all)`,
|
|
225
|
-
|
|
226
|
-
notarize: `## client.notarize
|
|
227
|
-
Agent-to-agent agreement notarization (OpenClaw flow).
|
|
228
|
-
- createMandate(params: NotarizeMandateParams): Promise<NotarizeMandateResult>
|
|
229
|
-
- getMandate(id: string): Promise<NotarizedMandate>
|
|
230
|
-
- getHistory(id: string): Promise<NotarizeHistory>
|
|
231
|
-
- acceptMandate(id: string): Promise<NotarizedMandate>
|
|
232
|
-
- counterPropose(id: string, params: NotarizeCounterProposeParams): Promise<NotarizeMandateResult>
|
|
233
|
-
- submitReceipt(id: string, params: NotarizeReceiptParams): Promise<NotarizeReceiptResult>
|
|
234
|
-
- renderVerdict(id: string, params: NotarizeVerdictParams): Promise<NotarizedMandate>
|
|
235
|
-
- verify(params: NotarizeVerifyParams): Promise<NotarizeVerifyResult>`,
|
|
236
|
-
|
|
237
|
-
enterprises: `## client.enterprises
|
|
238
|
-
Enterprise agent approval registry.
|
|
239
|
-
- approveAgent(enterpriseId: string, agentId: string, params?: ApproveAgentParams): Promise<EnterpriseAgentRecord>
|
|
240
|
-
- revokeAgent(enterpriseId: string, agentId: string, params?: RevokeAgentParams): Promise<void>
|
|
241
|
-
- updateAgentStatus(enterpriseId: string, agentId: string, params: UpdateAgentStatusParams): Promise<EnterpriseAgentRecord>
|
|
242
|
-
- bulkApprove(enterpriseId: string, params: BulkApproveAgentParams): Promise<BulkApproveResult>
|
|
243
|
-
- listAgents(enterpriseId: string, params?: ListEnterpriseAgentsParams): Promise<Page<EnterpriseAgentRecord>>
|
|
244
|
-
- getAgent(enterpriseId: string, agentId: string): Promise<EnterpriseAgentRecord>
|
|
245
|
-
`,
|
|
246
|
-
|
|
247
|
-
projects: `## client.projects
|
|
248
|
-
- create(params: CreateProjectParams): Promise<Project>
|
|
249
|
-
- list(params?: ListParams): Promise<Page<Project>>
|
|
250
|
-
- get(projectId: string): Promise<Project>
|
|
251
|
-
- update(projectId: string, params: UpdateProjectParams): Promise<Project>
|
|
252
|
-
- delete(projectId: string): Promise<void>`,
|
|
253
|
-
|
|
254
|
-
federation: `## client.federation
|
|
255
|
-
Gateway-facing federation operations. Most methods require a bearer token from register().
|
|
256
|
-
- register(params: RegisterGatewayParams): Promise<RegisterGatewayResult> (no auth header)
|
|
257
|
-
- heartbeat(params: HeartbeatParams): Promise<HeartbeatResult>
|
|
258
|
-
- registerAgent(params: RegisterFederatedAgentParams): Promise<{ registered: boolean }>
|
|
259
|
-
- listAgents(params?: ListFederatedAgentsParams): Promise<Page<FederationAgent>>
|
|
260
|
-
- submitStateTransition(params: SubmitStateTransitionParams): Promise<StateTransitionResult>
|
|
261
|
-
- relaySignal(params: RelaySignalParams): Promise<SignalRelayResult>
|
|
262
|
-
- rotateKey(gatewayId: string, params: RotateGatewayKeyParams): Promise<{ rotated: boolean }>
|
|
263
|
-
- revoke(gatewayId: string, params: RevokeGatewayParams): Promise<{ revoked; revokedAt }> (no auth header)
|
|
264
|
-
- catchUp(params: FederationCatchUpParams): Promise<{ data: FederationAuditEntry[]; hasMore }>
|
|
265
|
-
- stream(params?: { since?: string }): Promise<Record<string, unknown>>
|
|
266
|
-
- publishSchema(contractType: string, params: SchemaPublishParams): Promise<ContractSchema>
|
|
267
|
-
- confirmSchemaPublish(contractType: string, params: SchemaConfirmParams): Promise<ContractSchema>
|
|
268
|
-
- listContractTypes(): Promise<ContractSchema[]>
|
|
269
|
-
- getContractType(contractType: string): Promise<ContractSchema>
|
|
270
|
-
- getMandateCriteria(mandateId: string): Promise<FederationMandateCriteria>
|
|
271
|
-
- submitMandateCriteria(mandateId: string, params: SubmitMandateCriteriaParams): Promise<FederationMandateCriteria>
|
|
272
|
-
- contributeReputation(params: ContributeReputationParams): Promise<{ contributed: boolean }>
|
|
273
|
-
- getAgentReputation(agentId: string): Promise<FederationAgentReputation>
|
|
274
|
-
- broadcastRevocations(params: RevocationBroadcastParams): Promise<{ broadcast: boolean }>
|
|
275
|
-
- syncAgentDirectory(params: AgentDirectorySyncParams): Promise<{ synced: boolean }>`,
|
|
276
|
-
|
|
277
|
-
federationAdmin: `## client.federationAdmin
|
|
278
|
-
Platform admin operations for federation. Requires admin:system scope.
|
|
279
|
-
- createRegistrationToken(params?: CreateRegistrationTokenParams): Promise<FederationRegistrationToken>
|
|
280
|
-
- listGateways(params?: ListFederationGatewaysParams): Promise<Page<FederationGateway>>
|
|
281
|
-
- revokeGateway(gatewayId: string, params: AdminRevokeGatewayParams): Promise<{ revoked; nextSteps }>
|
|
282
|
-
- queryMandates(params?: QueryFederationMandatesParams): Promise<Page<FederationMandate>>
|
|
283
|
-
- getAuditLog(params?: FederationAuditLogParams): Promise<Page<FederationAuditEntry>>
|
|
284
|
-
- getHealth(): Promise<FederationHealthSummary>
|
|
285
|
-
- resetSequence(gatewayId: string, params?: ResetSequenceParams): Promise<{ reset; nextSteps }>
|
|
286
|
-
- listDlq(params?: ListOutboundDlqParams): Promise<Page<FederationDlqEntry>>
|
|
287
|
-
- retryDlq(dlqId: string): Promise<{ retried; nextSteps }>
|
|
288
|
-
- deleteDlq(dlqId: string): Promise<{ deleted: boolean }>
|
|
289
|
-
- rotateHubKey(): Promise<HubSigningKey>
|
|
290
|
-
- listHubKeys(): Promise<HubSigningKey[]>
|
|
291
|
-
- activateHubKey(keyId: string): Promise<HubSigningKey>
|
|
292
|
-
- expireHubKey(keyId: string): Promise<HubSigningKey>
|
|
293
|
-
- registerPeer(params: PeerRegistrationParams): Promise<FederationPeer>
|
|
294
|
-
- listPeers(): Promise<Page<FederationPeer>>
|
|
295
|
-
- getPeer(hubId: string): Promise<FederationPeer>
|
|
296
|
-
- revokePeer(hubId: string): Promise<{ revoked: boolean }>
|
|
297
|
-
- resyncPeer(hubId: string): Promise<{ synced: boolean }>
|
|
298
|
-
- createPeeringToken(): Promise<PeeringToken>
|
|
299
|
-
- deleteSchemaVersion(contractType: string, version: string): Promise<{ deleted: boolean }>
|
|
300
|
-
- listReputationContributions(agentId: string): Promise<ReputationContribution[]>
|
|
301
|
-
- resetReputation(agentId: string): Promise<{ reset: boolean }>
|
|
302
|
-
- getMandateCriteriaStatus(mandateId: string): Promise<MandateCriteriaStatus>`,
|
|
303
|
-
|
|
304
|
-
agents: `## client.agents
|
|
305
|
-
Agent identity management.
|
|
306
|
-
- get(agentId: string): Promise<AgentProfile>
|
|
307
|
-
- update(agentId: string, params: UpdateAgentParams): Promise<AgentProfile>
|
|
308
|
-
- addReferences(agentId: string, references: Record<string, unknown>[]): Promise<Record<string, unknown>>
|
|
309
|
-
- getReferences(agentId: string): Promise<Record<string, unknown>>`,
|
|
310
|
-
|
|
311
|
-
references: `## client.references
|
|
312
|
-
Reverse lookup for external references.
|
|
313
|
-
- lookup(params: { system: string; refType: string; refId: string }): Promise<ReferenceLookupResult>
|
|
314
|
-
- addMandateReferences(mandateId: string, references: Record<string, unknown>[]): Promise<Record<string, unknown>>
|
|
315
|
-
- getMandateReferences(mandateId: string): Promise<Record<string, unknown>>`,
|
|
316
|
-
|
|
317
|
-
verificationKeys: `## client.verificationKeys
|
|
318
|
-
Public vault signing keys for independent audit chain verification. No auth required.
|
|
319
|
-
- list(): Promise<VerificationKeysResponse> — returns { data: VerificationKey[], canonicalization, hashAlgorithm, signatureAlgorithm }`,
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
const RESOURCE_NAMES = Object.keys(RESOURCE_MANIFEST);
|
|
323
|
-
|
|
324
|
-
function buildFullManifest(): string {
|
|
325
|
-
const header = `# AGLedger SDK — Resource Manifest
|
|
326
|
-
24 resources, ~200 methods. Use \`sdk_execute\` to call any method.
|
|
327
|
-
The \`client\` variable is a pre-configured AgledgerClient instance.
|
|
328
|
-
|
|
329
|
-
**Pagination**: \`list()\` returns \`Page<T>\` with \`.data\`, \`.total\`, \`.hasMore\`, \`.cursor\`. Use \`listAll()\` for auto-paginating async iterators.
|
|
330
|
-
**Options**: All methods accept an optional trailing \`RequestOptions\` parameter (timeout, idempotencyKey, authOverride).
|
|
331
|
-
**Errors**: SDK throws typed errors — \`AgledgerApiError\`, \`AuthenticationError\`, \`PermissionError\`, \`NotFoundError\`, \`RateLimitError\`, etc.
|
|
332
|
-
|
|
333
|
-
---
|
|
334
|
-
|
|
335
|
-
`;
|
|
336
|
-
return header + RESOURCE_NAMES.map((name) => RESOURCE_MANIFEST[name]).join('\n\n');
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
const FULL_MANIFEST = buildFullManifest();
|
|
340
|
-
|
|
341
|
-
export function registerCodeModeTools(mcp: McpServer, client: AgledgerClient): void {
|
|
342
|
-
mcp.registerTool(
|
|
343
|
-
'sdk_execute',
|
|
344
|
-
{
|
|
345
|
-
title: 'Execute SDK Code',
|
|
346
|
-
description: `Execute TypeScript/JavaScript code against the AGLedger SDK client. The \`client\` variable is a pre-configured AgledgerClient instance with all 23 resources available.
|
|
347
|
-
|
|
348
|
-
Example usage:
|
|
349
|
-
- \`const mandate = await client.mandates.get("mnd-abc123"); return mandate;\`
|
|
350
|
-
- \`const page = await client.mandates.list({ status: "ACTIVE", limit: 10 }); return page.data;\`
|
|
351
|
-
- \`await client.mandates.transition("mnd-abc123", { action: "register" }); return "done";\`
|
|
352
|
-
|
|
353
|
-
The code runs in an async context — use \`await\` freely. Return a value to see it in the response. Use \`sdk_describe\` first to discover available resources and method signatures.
|
|
354
|
-
|
|
355
|
-
Available resources: ${RESOURCE_NAMES.join(', ')}.
|
|
356
|
-
|
|
357
|
-
SECURITY: This tool executes code in the MCP server process. It is intended for trusted agents only — the caller has the same access as the API key. Do not expose this tool to untrusted clients. A 30-second timeout prevents runaway execution.`,
|
|
358
|
-
inputSchema: {
|
|
359
|
-
code: z.string().describe('TypeScript/JavaScript code to execute. Use `client` to access the SDK. Return a value to see results.'),
|
|
360
|
-
},
|
|
361
|
-
outputSchema: z.object({
|
|
362
|
-
result: z.unknown().describe('The return value of the executed code'),
|
|
363
|
-
executionTimeMs: z.number().describe('Execution time in milliseconds'),
|
|
364
|
-
}),
|
|
365
|
-
annotations: {
|
|
366
|
-
readOnlyHint: false,
|
|
367
|
-
destructiveHint: true,
|
|
368
|
-
idempotentHint: false,
|
|
369
|
-
openWorldHint: true,
|
|
370
|
-
},
|
|
371
|
-
_meta: toolMeta('sdk_execute'),
|
|
372
|
-
},
|
|
373
|
-
async (args) => {
|
|
374
|
-
const TIMEOUT_MS = 30_000;
|
|
375
|
-
const start = Date.now();
|
|
376
|
-
try {
|
|
377
|
-
// Use AsyncFunction constructor to support top-level await
|
|
378
|
-
// NOTE: This executes in the same process as the MCP server — the caller
|
|
379
|
-
// (agent) is already trusted with the API key. The timeout prevents runaway
|
|
380
|
-
// code from hanging the server. For untrusted execution, use a sandbox.
|
|
381
|
-
const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor;
|
|
382
|
-
const fn = new AsyncFunction('client', args.code);
|
|
383
|
-
const timeout = new Promise((_, reject) =>
|
|
384
|
-
setTimeout(() => reject(new Error(`Execution timed out after ${TIMEOUT_MS}ms`)), TIMEOUT_MS),
|
|
385
|
-
);
|
|
386
|
-
const result = await Promise.race([fn(client), timeout]);
|
|
387
|
-
const executionTimeMs = Date.now() - start;
|
|
388
|
-
let serialized: string;
|
|
389
|
-
try {
|
|
390
|
-
serialized = JSON.stringify(result, null, 2) ?? 'undefined';
|
|
391
|
-
} catch {
|
|
392
|
-
serialized = '[Result contains circular references]';
|
|
393
|
-
}
|
|
394
|
-
return {
|
|
395
|
-
content: [{ type: 'text', text: `Execution completed in ${executionTimeMs}ms.\n\n${serialized}` }],
|
|
396
|
-
structuredContent: { result, executionTimeMs },
|
|
397
|
-
};
|
|
398
|
-
} catch (err) {
|
|
399
|
-
const executionTimeMs = Date.now() - start;
|
|
400
|
-
if (err instanceof AgledgerApiError) {
|
|
401
|
-
return apiErrorResult(err);
|
|
402
|
-
}
|
|
403
|
-
return {
|
|
404
|
-
content: [{ type: 'text', text: `Execution error after ${executionTimeMs}ms: ${err instanceof Error ? err.message : String(err)}` }],
|
|
405
|
-
isError: true,
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
|
-
},
|
|
409
|
-
);
|
|
410
|
-
|
|
411
|
-
mcp.registerTool(
|
|
412
|
-
'sdk_describe',
|
|
413
|
-
{
|
|
414
|
-
title: 'Describe SDK Resources',
|
|
415
|
-
description: `Returns the AGLedger SDK resource manifest — all 23 resources with method signatures, parameters, and return types. Use this to discover what code to write for \`sdk_execute\`.
|
|
416
|
-
|
|
417
|
-
Pass a \`resource\` name (e.g., "mandates", "federation") for detailed info on one resource, or omit it for the full manifest.
|
|
418
|
-
|
|
419
|
-
Available resources: ${RESOURCE_NAMES.join(', ')}.`,
|
|
420
|
-
inputSchema: {
|
|
421
|
-
resource: z.string().optional().describe('Resource name to describe (e.g., "mandates", "federation"). Omit for full manifest.'),
|
|
422
|
-
},
|
|
423
|
-
outputSchema: z.object({
|
|
424
|
-
manifest: z.string().describe('SDK resource manifest with method signatures'),
|
|
425
|
-
resourceCount: z.number().describe('Number of resources described'),
|
|
426
|
-
}),
|
|
427
|
-
annotations: {
|
|
428
|
-
readOnlyHint: true,
|
|
429
|
-
destructiveHint: false,
|
|
430
|
-
idempotentHint: true,
|
|
431
|
-
openWorldHint: false,
|
|
432
|
-
},
|
|
433
|
-
_meta: toolMeta('sdk_describe'),
|
|
434
|
-
},
|
|
435
|
-
async (args) => {
|
|
436
|
-
if (args.resource) {
|
|
437
|
-
const name = args.resource.toLowerCase().replace(/[-_\s]/g, '');
|
|
438
|
-
// Try exact match first, then normalized match
|
|
439
|
-
const key = RESOURCE_NAMES.find(
|
|
440
|
-
(k) => k === args.resource || k.toLowerCase().replace(/[-_\s]/g, '') === name,
|
|
441
|
-
);
|
|
442
|
-
if (!key) {
|
|
443
|
-
return {
|
|
444
|
-
content: [{ type: 'text', text: `Unknown resource "${args.resource}". Available: ${RESOURCE_NAMES.join(', ')}` }],
|
|
445
|
-
isError: true,
|
|
446
|
-
};
|
|
447
|
-
}
|
|
448
|
-
const manifest = RESOURCE_MANIFEST[key];
|
|
449
|
-
return {
|
|
450
|
-
content: [{ type: 'text', text: manifest }],
|
|
451
|
-
structuredContent: { manifest, resourceCount: 1 },
|
|
452
|
-
};
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
return {
|
|
456
|
-
content: [{ type: 'text', text: FULL_MANIFEST }],
|
|
457
|
-
structuredContent: { manifest: FULL_MANIFEST, resourceCount: RESOURCE_NAMES.length },
|
|
458
|
-
};
|
|
459
|
-
},
|
|
460
|
-
);
|
|
461
|
-
}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RESOURCE_MANIFEST drift test
|
|
3
|
-
*
|
|
4
|
-
* Verifies that the RESOURCE_MANIFEST in code-mode.ts stays in sync with the
|
|
5
|
-
* actual AgledgerClient resource properties. If a resource is added to or
|
|
6
|
-
* removed from the SDK client, this test will fail until the manifest is updated.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { describe, it, expect } from 'vitest';
|
|
10
|
-
import { readFileSync } from 'node:fs';
|
|
11
|
-
import { resolve, dirname } from 'node:path';
|
|
12
|
-
import { fileURLToPath } from 'node:url';
|
|
13
|
-
|
|
14
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
15
|
-
|
|
16
|
-
// ---------------------------------------------------------------------------
|
|
17
|
-
// Extract resource names from the SDK client source
|
|
18
|
-
// ---------------------------------------------------------------------------
|
|
19
|
-
|
|
20
|
-
function getClientResourceNames(): string[] {
|
|
21
|
-
const clientPath = resolve(__dirname, '../../../agledger-sdk/src/client.ts');
|
|
22
|
-
const source = readFileSync(clientPath, 'utf8');
|
|
23
|
-
|
|
24
|
-
// Match "readonly <name>: <Type>Resource" property declarations
|
|
25
|
-
const pattern = /^\s+readonly\s+(\w+)\s*:\s+\w+Resource/gm;
|
|
26
|
-
const names: string[] = [];
|
|
27
|
-
let match: RegExpExecArray | null;
|
|
28
|
-
while ((match = pattern.exec(source)) !== null) {
|
|
29
|
-
names.push(match[1]);
|
|
30
|
-
}
|
|
31
|
-
return names.sort();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// ---------------------------------------------------------------------------
|
|
35
|
-
// Extract resource names from the RESOURCE_MANIFEST in code-mode.ts
|
|
36
|
-
// ---------------------------------------------------------------------------
|
|
37
|
-
|
|
38
|
-
function getManifestResourceNames(): string[] {
|
|
39
|
-
const codePath = resolve(__dirname, '../src/tools/code-mode.ts');
|
|
40
|
-
const source = readFileSync(codePath, 'utf8');
|
|
41
|
-
|
|
42
|
-
// The manifest is defined as: const RESOURCE_MANIFEST: Record<string, string> = { key: `...`, ... };
|
|
43
|
-
// Extract the keys by finding the block between the opening { and closing };
|
|
44
|
-
const startMarker = 'const RESOURCE_MANIFEST: Record<string, string> = {';
|
|
45
|
-
const startIdx = source.indexOf(startMarker);
|
|
46
|
-
if (startIdx === -1) {
|
|
47
|
-
throw new Error('Could not find RESOURCE_MANIFEST in code-mode.ts');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Find matching closing brace by counting depth
|
|
51
|
-
let depth = 0;
|
|
52
|
-
let inString = false;
|
|
53
|
-
let stringChar = '';
|
|
54
|
-
let endIdx = -1;
|
|
55
|
-
|
|
56
|
-
for (let i = startIdx + startMarker.length - 1; i < source.length; i++) {
|
|
57
|
-
const ch = source[i];
|
|
58
|
-
const prev = i > 0 ? source[i - 1] : '';
|
|
59
|
-
|
|
60
|
-
if (inString) {
|
|
61
|
-
if (ch === stringChar && prev !== '\\') {
|
|
62
|
-
inString = false;
|
|
63
|
-
}
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (ch === '`' || ch === '"' || ch === "'") {
|
|
68
|
-
inString = true;
|
|
69
|
-
stringChar = ch;
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (ch === '{') depth++;
|
|
74
|
-
if (ch === '}') {
|
|
75
|
-
depth--;
|
|
76
|
-
if (depth === 0) {
|
|
77
|
-
endIdx = i;
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (endIdx === -1) {
|
|
84
|
-
throw new Error('Could not parse RESOURCE_MANIFEST block');
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const block = source.slice(startIdx + startMarker.length, endIdx);
|
|
88
|
-
|
|
89
|
-
// Extract top-level keys: lines matching " <key>: `" at the start
|
|
90
|
-
const keyPattern = /^\s+(\w+)\s*:\s*`/gm;
|
|
91
|
-
const names: string[] = [];
|
|
92
|
-
let m: RegExpExecArray | null;
|
|
93
|
-
while ((m = keyPattern.exec(block)) !== null) {
|
|
94
|
-
names.push(m[1]);
|
|
95
|
-
}
|
|
96
|
-
return names.sort();
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// ---------------------------------------------------------------------------
|
|
100
|
-
// Tests
|
|
101
|
-
// ---------------------------------------------------------------------------
|
|
102
|
-
|
|
103
|
-
describe('RESOURCE_MANIFEST ↔ SDK Client drift', () => {
|
|
104
|
-
const clientResources = getClientResourceNames();
|
|
105
|
-
const manifestResources = getManifestResourceNames();
|
|
106
|
-
|
|
107
|
-
it('SDK client has at least one resource', () => {
|
|
108
|
-
expect(clientResources.length).toBeGreaterThan(0);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('RESOURCE_MANIFEST has at least one resource', () => {
|
|
112
|
-
expect(manifestResources.length).toBeGreaterThan(0);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it('every SDK resource is present in RESOURCE_MANIFEST', () => {
|
|
116
|
-
const missing = clientResources.filter((r) => !manifestResources.includes(r));
|
|
117
|
-
if (missing.length > 0) {
|
|
118
|
-
expect.fail(
|
|
119
|
-
`${missing.length} SDK resource(s) missing from RESOURCE_MANIFEST in code-mode.ts:\n` +
|
|
120
|
-
missing.map((r) => ` - ${r}`).join('\n') +
|
|
121
|
-
'\n\nFix: add entries to RESOURCE_MANIFEST for these resources.',
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it('every RESOURCE_MANIFEST entry corresponds to an SDK resource', () => {
|
|
127
|
-
const extra = manifestResources.filter((r) => !clientResources.includes(r));
|
|
128
|
-
if (extra.length > 0) {
|
|
129
|
-
expect.fail(
|
|
130
|
-
`${extra.length} RESOURCE_MANIFEST entry/entries have no corresponding SDK resource:\n` +
|
|
131
|
-
extra.map((r) => ` - ${r}`).join('\n') +
|
|
132
|
-
'\n\nFix: remove stale entries from RESOURCE_MANIFEST, or add missing resources to the SDK client.',
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it('resource counts match exactly', () => {
|
|
138
|
-
expect(manifestResources.length).toBe(clientResources.length);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it('resource names match exactly (sorted)', () => {
|
|
142
|
-
expect(manifestResources).toEqual(clientResources);
|
|
143
|
-
});
|
|
144
|
-
});
|