@kya-os/mcp-i 1.11.1 → 1.12.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 +8 -7
- package/dist/365.js +1 -0
- package/dist/runtime/160.js +1 -0
- package/dist/runtime/adapter-express.js +3 -3
- package/dist/runtime/adapter-nextjs.js +3 -3
- package/dist/runtime/http.js +3 -3
- package/dist/runtime/index.d.ts +1 -2
- package/dist/runtime/index.js +3 -10
- package/dist/runtime/mcpi-runtime-wrapper.js +1 -8
- package/dist/runtime/mcpi-runtime.d.ts +4 -12
- package/dist/runtime/mcpi-runtime.js +38 -31
- package/dist/runtime/stdio.js +3 -3
- package/dist/runtime/utils/time.d.ts +1 -1
- package/dist/runtime/utils/time.js +1 -1
- package/package.json +5 -5
- package/dist/342.js +0 -1
- package/dist/runtime/337.js +0 -1
- package/dist/runtime/audit.d.ts +0 -430
- package/dist/runtime/audit.js +0 -439
package/dist/runtime/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* XMCP-I Runtime - Main Exports
|
|
3
3
|
*
|
|
4
4
|
* Identity-aware MCP runtime with proof generation, session management,
|
|
5
|
-
* audit
|
|
5
|
+
* canonical audit trails, and well-known endpoints.
|
|
6
6
|
*/
|
|
7
7
|
export { MCPINodeRuntimeWrapper, MCPINodeRuntimeWrapper as MCPIRuntime, // Backward compatibility alias
|
|
8
8
|
createMCPIRuntime } from "./mcpi-runtime-wrapper";
|
|
@@ -10,7 +10,6 @@ export { RuntimeFactory, RUNTIME_ERRORS, type MCPIRuntimeConfig, type RuntimeEnv
|
|
|
10
10
|
export { IdentityManager, defaultIdentityManager, ensureIdentity, IDENTITY_ERRORS, type AgentIdentity, type DevIdentityFile, type ProdEnvironment, type RuntimeIdentityManagerConfig, } from "./identity";
|
|
11
11
|
export { SessionManager, defaultSessionManager, createHandshakeRequest, validateHandshakeFormat, type SessionConfig, type HandshakeResult, } from "./session";
|
|
12
12
|
export { ProofGenerator, createProofResponse, extractCanonicalData, type ToolRequest, type ToolResponse, type ProofOptions, } from "./proof";
|
|
13
|
-
export { AuditLogger, defaultAuditLogger, logKeyRotationAudit, parseAuditLine, validateAuditRecord, type AuditConfig, type AuditContext, type AuditEventContext, type KeyRotationAuditContext, } from "./audit";
|
|
14
13
|
export { WellKnownManager, createWellKnownHandler, validateDIDDocument, validateAgentDocument, extractDIDFromPath, type DIDDocument, type VerificationMethod, type ServiceEndpoint, type AgentDocument, type WellKnownConfig, type WellKnownHandler, } from "./well-known";
|
|
15
14
|
export { DebugManager, createDebugEndpoint, type DebugVerificationResult, type DebugPageData, } from "./debug";
|
|
16
15
|
export { DemoManager, createDemoManager, DemoConsole, formatVerifyLink, type DemoConfig, } from "./demo";
|
package/dist/runtime/index.js
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* XMCP-I Runtime - Main Exports
|
|
4
4
|
*
|
|
5
5
|
* Identity-aware MCP runtime with proof generation, session management,
|
|
6
|
-
* audit
|
|
6
|
+
* canonical audit trails, and well-known endpoints.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.ToolProtectionResolver = exports.MemoryDelegationVerifier = exports.AgentShieldAPIDelegationVerifier = exports.CloudflareKVDelegationVerifier = exports.createProofBatchQueue = exports.AgentShieldProofDestination = exports.KTAProofDestination = exports.ProofBatchQueue = exports.ensureOutboundIdentityBridge = exports.CloudflareKVResumeTokenStore = exports.createResumeTokenStore = exports.MemoryResumeTokenStore = exports.hasSensitiveScopes = exports.verifyOrHints = exports.extractScopes = exports.validateDelegation = exports.checkScopes = exports.createDelegationVerifier = exports.formatVerifyLink = exports.DemoConsole = exports.createDemoManager = exports.DemoManager = exports.createDebugEndpoint = exports.DebugManager = exports.extractDIDFromPath = exports.validateAgentDocument = exports.validateDIDDocument = exports.createWellKnownHandler = exports.WellKnownManager = exports.
|
|
10
|
-
exports.getToolProtection = exports.isToolProtected =
|
|
9
|
+
exports.toolProtectionRegistry = exports.AgentShieldToolProtectionSource = exports.FileToolProtectionSource = exports.InlineToolProtectionSource = exports.createToolProtectionResolver = exports.ToolProtectionResolver = exports.MemoryDelegationVerifier = exports.AgentShieldAPIDelegationVerifier = exports.CloudflareKVDelegationVerifier = exports.createProofBatchQueue = exports.AgentShieldProofDestination = exports.KTAProofDestination = exports.ProofBatchQueue = exports.ensureOutboundIdentityBridge = exports.CloudflareKVResumeTokenStore = exports.createResumeTokenStore = exports.MemoryResumeTokenStore = exports.hasSensitiveScopes = exports.verifyOrHints = exports.extractScopes = exports.validateDelegation = exports.checkScopes = exports.createDelegationVerifier = exports.formatVerifyLink = exports.DemoConsole = exports.createDemoManager = exports.DemoManager = exports.createDebugEndpoint = exports.DebugManager = exports.extractDIDFromPath = exports.validateAgentDocument = exports.validateDIDDocument = exports.createWellKnownHandler = exports.WellKnownManager = exports.extractCanonicalData = exports.createProofResponse = exports.ProofGenerator = exports.validateHandshakeFormat = exports.createHandshakeRequest = exports.defaultSessionManager = exports.SessionManager = exports.IDENTITY_ERRORS = exports.ensureIdentity = exports.defaultIdentityManager = exports.IdentityManager = exports.RUNTIME_ERRORS = exports.RuntimeFactory = exports.createMCPIRuntime = exports.MCPIRuntime = exports.MCPINodeRuntimeWrapper = void 0;
|
|
10
|
+
exports.getToolProtection = exports.isToolProtected = void 0;
|
|
11
11
|
// Main runtime - Node.js implementation with providers
|
|
12
12
|
var mcpi_runtime_wrapper_1 = require("./mcpi-runtime-wrapper");
|
|
13
13
|
Object.defineProperty(exports, "MCPINodeRuntimeWrapper", { enumerable: true, get: function () { return mcpi_runtime_wrapper_1.MCPINodeRuntimeWrapper; } });
|
|
@@ -34,13 +34,6 @@ var proof_1 = require("./proof");
|
|
|
34
34
|
Object.defineProperty(exports, "ProofGenerator", { enumerable: true, get: function () { return proof_1.ProofGenerator; } });
|
|
35
35
|
Object.defineProperty(exports, "createProofResponse", { enumerable: true, get: function () { return proof_1.createProofResponse; } });
|
|
36
36
|
Object.defineProperty(exports, "extractCanonicalData", { enumerable: true, get: function () { return proof_1.extractCanonicalData; } });
|
|
37
|
-
// Audit logging
|
|
38
|
-
var audit_1 = require("./audit");
|
|
39
|
-
Object.defineProperty(exports, "AuditLogger", { enumerable: true, get: function () { return audit_1.AuditLogger; } });
|
|
40
|
-
Object.defineProperty(exports, "defaultAuditLogger", { enumerable: true, get: function () { return audit_1.defaultAuditLogger; } });
|
|
41
|
-
Object.defineProperty(exports, "logKeyRotationAudit", { enumerable: true, get: function () { return audit_1.logKeyRotationAudit; } });
|
|
42
|
-
Object.defineProperty(exports, "parseAuditLine", { enumerable: true, get: function () { return audit_1.parseAuditLine; } });
|
|
43
|
-
Object.defineProperty(exports, "validateAuditRecord", { enumerable: true, get: function () { return audit_1.validateAuditRecord; } });
|
|
44
37
|
// Well-known endpoints
|
|
45
38
|
var well_known_1 = require("./well-known");
|
|
46
39
|
Object.defineProperty(exports, "WellKnownManager", { enumerable: true, get: function () { return well_known_1.WellKnownManager; } });
|
|
@@ -37,14 +37,7 @@ function createProvidersFromConfig(config) {
|
|
|
37
37
|
timestampSkewSeconds: config.session?.timestampSkewSeconds || 120,
|
|
38
38
|
ttlMinutes: config.session?.sessionTtlMinutes || 30,
|
|
39
39
|
},
|
|
40
|
-
|
|
41
|
-
? {
|
|
42
|
-
enabled: config.audit.enabled !== false,
|
|
43
|
-
logFunction: config.audit.logFunction,
|
|
44
|
-
includePayloads: config.audit.includePayloads,
|
|
45
|
-
includeProofHashes: config.audit.includeProofHashes,
|
|
46
|
-
}
|
|
47
|
-
: undefined,
|
|
40
|
+
auditTrail: config.auditTrail,
|
|
48
41
|
wellKnown: config.wellKnown
|
|
49
42
|
? {
|
|
50
43
|
enabled: true,
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { SessionContext, HandshakeRequest } from "@kya-os/contracts/handshake";
|
|
8
8
|
import { ToolRequest, ToolResponse } from "./proof";
|
|
9
|
+
import { type RuntimeAuditConfig } from "@kya-os/mcp-i-runtime";
|
|
9
10
|
import { WellKnownConfig } from "./well-known";
|
|
10
11
|
import { DemoManager } from "./demo";
|
|
11
12
|
import { DelegationVerifierConfig } from "./delegation-verifier";
|
|
@@ -39,12 +40,8 @@ export interface MCPIRuntimeConfig {
|
|
|
39
40
|
sessionTtlMinutes?: number;
|
|
40
41
|
absoluteSessionLifetime?: number;
|
|
41
42
|
};
|
|
42
|
-
audit
|
|
43
|
-
|
|
44
|
-
logFunction?: (record: string) => void;
|
|
45
|
-
includePayloads?: boolean;
|
|
46
|
-
includeProofHashes?: boolean;
|
|
47
|
-
};
|
|
43
|
+
/** Canonical KYA-OS audit trail. */
|
|
44
|
+
auditTrail?: RuntimeAuditConfig;
|
|
48
45
|
proofing?: {
|
|
49
46
|
/** Enable proof generation and submission */
|
|
50
47
|
enabled?: boolean;
|
|
@@ -128,7 +125,6 @@ export interface MCPIRuntimeConfig {
|
|
|
128
125
|
export declare class MCPIRuntime {
|
|
129
126
|
private identityManager;
|
|
130
127
|
private sessionManager;
|
|
131
|
-
private auditLogger;
|
|
132
128
|
private wellKnownManager?;
|
|
133
129
|
private debugManager?;
|
|
134
130
|
private demoManager?;
|
|
@@ -196,11 +192,7 @@ export declare class MCPIRuntime {
|
|
|
196
192
|
};
|
|
197
193
|
audit: {
|
|
198
194
|
enabled: boolean;
|
|
199
|
-
|
|
200
|
-
includePayloads: boolean;
|
|
201
|
-
totalRecordsLogged: number;
|
|
202
|
-
currentLogSize: number;
|
|
203
|
-
lastRotationTime: number;
|
|
195
|
+
profile: import("@kya-os/mcp", { with: { "resolution-mode": "import" } }).AuditAssuranceProfile;
|
|
204
196
|
};
|
|
205
197
|
runtime: {
|
|
206
198
|
initialized: boolean;
|
|
@@ -11,7 +11,7 @@ exports.createMCPIRuntime = createMCPIRuntime;
|
|
|
11
11
|
const identity_1 = require("./identity");
|
|
12
12
|
const session_1 = require("./session");
|
|
13
13
|
const proof_1 = require("./proof");
|
|
14
|
-
const
|
|
14
|
+
const mcp_i_runtime_1 = require("@kya-os/mcp-i-runtime");
|
|
15
15
|
const well_known_1 = require("./well-known");
|
|
16
16
|
const debug_1 = require("./debug");
|
|
17
17
|
const demo_1 = require("./demo");
|
|
@@ -34,7 +34,6 @@ const mcp_i_core_1 = require("@kya-os/mcp-i-core");
|
|
|
34
34
|
class MCPIRuntime {
|
|
35
35
|
identityManager;
|
|
36
36
|
sessionManager;
|
|
37
|
-
auditLogger;
|
|
38
37
|
wellKnownManager;
|
|
39
38
|
debugManager;
|
|
40
39
|
demoManager;
|
|
@@ -52,8 +51,6 @@ class MCPIRuntime {
|
|
|
52
51
|
});
|
|
53
52
|
// Initialize session manager
|
|
54
53
|
this.sessionManager = new session_1.SessionManager(config.session);
|
|
55
|
-
// Initialize audit logger
|
|
56
|
-
this.auditLogger = new audit_1.AuditLogger(config.audit);
|
|
57
54
|
// Initialize resume token store (NEW - Phase 1).
|
|
58
55
|
// Durable stores (e.g. Cloudflare KV) are selected from config so a token
|
|
59
56
|
// minted at consent time survives cold starts / restarts / multi-instance
|
|
@@ -229,6 +226,16 @@ class MCPIRuntime {
|
|
|
229
226
|
});
|
|
230
227
|
}
|
|
231
228
|
}
|
|
229
|
+
const auditInvocation = this.config.auditTrail
|
|
230
|
+
? await (0, mcp_i_runtime_1.beginRuntimeToolAudit)(this.config.auditTrail, {
|
|
231
|
+
toolName: request.method,
|
|
232
|
+
args: request.params,
|
|
233
|
+
session: {
|
|
234
|
+
...session,
|
|
235
|
+
id: session.sessionId,
|
|
236
|
+
},
|
|
237
|
+
})
|
|
238
|
+
: undefined;
|
|
232
239
|
// Capture before async boundary — TS narrowing doesn't survive across async callbacks
|
|
233
240
|
const cachedIdentity = this.cachedIdentity;
|
|
234
241
|
return (0, request_context_1.runWithContext)({ session: session ?? undefined }, async () => {
|
|
@@ -251,29 +258,30 @@ class MCPIRuntime {
|
|
|
251
258
|
if (this.debugManager && response.meta?.proof) {
|
|
252
259
|
this.debugManager.updateDebugState(response.meta.proof, session);
|
|
253
260
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
261
|
+
if (!auditInvocation || !this.config.auditTrail)
|
|
262
|
+
return response;
|
|
263
|
+
try {
|
|
264
|
+
const terminal = await auditInvocation.terminal((0, mcp_i_runtime_1.terminalForToolResult)(response));
|
|
265
|
+
return (0, mcp_i_runtime_1.attachRuntimeAuditMetadata)(response, this.config.auditTrail.sourceId, auditInvocation.context.invocationId, auditInvocation.results(terminal));
|
|
266
|
+
}
|
|
267
|
+
catch (auditError) {
|
|
268
|
+
console.error("[MCP-I] Failed to record successful tool audit terminal", {
|
|
269
|
+
error: auditError instanceof Error ? auditError.message : String(auditError),
|
|
270
|
+
});
|
|
271
|
+
return (0, mcp_i_runtime_1.attachRuntimeAuditMetadata)(response, this.config.auditTrail.sourceId, auditInvocation.context.invocationId, auditInvocation.results(), true);
|
|
272
|
+
}
|
|
265
273
|
}
|
|
266
274
|
catch (error) {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
275
|
+
if (auditInvocation) {
|
|
276
|
+
try {
|
|
277
|
+
await auditInvocation.terminal((0, mcp_i_runtime_1.terminalForToolError)(error));
|
|
278
|
+
}
|
|
279
|
+
catch (auditError) {
|
|
280
|
+
console.error("[MCP-I] Failed to record terminal tool audit event", {
|
|
281
|
+
error: auditError instanceof Error ? auditError.message : String(auditError),
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
}
|
|
277
285
|
throw error;
|
|
278
286
|
}
|
|
279
287
|
}); // end runWithContext
|
|
@@ -330,7 +338,10 @@ class MCPIRuntime {
|
|
|
330
338
|
environment: this.config.identity?.environment || "development",
|
|
331
339
|
},
|
|
332
340
|
session: this.sessionManager.getStats(),
|
|
333
|
-
audit:
|
|
341
|
+
audit: {
|
|
342
|
+
enabled: this.config.auditTrail !== undefined,
|
|
343
|
+
profile: this.config.auditTrail?.trail.capabilities?.profile ?? "AAP-0",
|
|
344
|
+
},
|
|
334
345
|
runtime: {
|
|
335
346
|
initialized: !!this.cachedIdentity,
|
|
336
347
|
wellKnownEnabled: !!this.wellKnownManager,
|
|
@@ -342,7 +353,6 @@ class MCPIRuntime {
|
|
|
342
353
|
*/
|
|
343
354
|
async cleanup() {
|
|
344
355
|
await this.sessionManager.cleanup();
|
|
345
|
-
this.auditLogger.clearSessionLog();
|
|
346
356
|
}
|
|
347
357
|
/**
|
|
348
358
|
* Check runtime environment compatibility
|
|
@@ -445,7 +455,7 @@ exports.RuntimeFactory = {
|
|
|
445
455
|
...overrides.demo,
|
|
446
456
|
},
|
|
447
457
|
session: overrides.session,
|
|
448
|
-
|
|
458
|
+
auditTrail: overrides.auditTrail,
|
|
449
459
|
};
|
|
450
460
|
return createMCPIRuntime(config);
|
|
451
461
|
},
|
|
@@ -480,9 +490,6 @@ exports.RuntimeFactory = {
|
|
|
480
490
|
environment: "development",
|
|
481
491
|
devIdentityPath: ".test-mcp-i/identity.json",
|
|
482
492
|
},
|
|
483
|
-
audit: {
|
|
484
|
-
enabled: false, // Disable audit logging in tests
|
|
485
|
-
},
|
|
486
493
|
runtime: {
|
|
487
494
|
showVerifyLink: false,
|
|
488
495
|
},
|