@kya-os/mcp-i-runtime 1.1.0 → 1.2.1

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.
Files changed (63) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/config.d.ts +5 -7
  3. package/dist/config.d.ts.map +1 -1
  4. package/dist/config.js +4 -6
  5. package/dist/config.js.map +1 -1
  6. package/dist/index.d.ts +3 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +20 -2
  9. package/dist/index.js.map +1 -1
  10. package/dist/runtime/audit-logger.d.ts +6 -28
  11. package/dist/runtime/audit-logger.d.ts.map +1 -1
  12. package/dist/runtime/audit-logger.js +5 -3
  13. package/dist/runtime/audit-logger.js.map +1 -1
  14. package/dist/runtime/audit.d.ts +132 -0
  15. package/dist/runtime/audit.d.ts.map +1 -0
  16. package/dist/runtime/audit.js +424 -0
  17. package/dist/runtime/audit.js.map +1 -0
  18. package/dist/runtime/base.d.ts +9 -48
  19. package/dist/runtime/base.d.ts.map +1 -1
  20. package/dist/runtime/base.js +109 -89
  21. package/dist/runtime/base.js.map +1 -1
  22. package/dist/services/auth-type-satisfies.d.ts +93 -0
  23. package/dist/services/auth-type-satisfies.d.ts.map +1 -0
  24. package/dist/services/auth-type-satisfies.js +127 -0
  25. package/dist/services/auth-type-satisfies.js.map +1 -0
  26. package/dist/services/oauth-config.service.d.ts.map +1 -1
  27. package/dist/services/oauth-config.service.js +29 -0
  28. package/dist/services/oauth-config.service.js.map +1 -1
  29. package/dist/services/tool-context-builder.d.ts +6 -1
  30. package/dist/services/tool-context-builder.d.ts.map +1 -1
  31. package/dist/services/tool-context-builder.js +35 -3
  32. package/dist/services/tool-context-builder.js.map +1 -1
  33. package/package.json +7 -3
  34. package/src/__tests__/config/provider-runtime-config.test.ts +2 -9
  35. package/src/__tests__/config.test.ts +12 -11
  36. package/src/__tests__/integration/full-flow.test.ts +0 -5
  37. package/src/__tests__/integration.test.ts +2 -6
  38. package/src/__tests__/runtime/audit.test.ts +327 -0
  39. package/src/__tests__/runtime/base-extensions.test.ts +0 -46
  40. package/src/__tests__/runtime/base.test.ts +71 -102
  41. package/src/__tests__/runtime/delegation-flow.test.ts +0 -4
  42. package/src/__tests__/runtime/process-tool-call-security.test.ts +5 -11
  43. package/src/__tests__/runtime/proof-client-did.test.ts +0 -4
  44. package/src/__tests__/runtime/provider-selection.test.ts +0 -2
  45. package/src/__tests__/runtime/route-interception.test.ts +7 -4
  46. package/src/__tests__/runtime/tool-protection-enforcement.test.ts +23 -31
  47. package/src/__tests__/services/tool-protection-merged-config.test.ts +0 -40
  48. package/src/config/__tests__/merged-config.spec.ts +0 -26
  49. package/src/config.ts +9 -10
  50. package/src/index.ts +32 -2
  51. package/src/runtime/__tests__/audit-logger-compat.test.ts +15 -0
  52. package/src/runtime/audit-logger.ts +6 -29
  53. package/src/runtime/audit.ts +598 -0
  54. package/src/runtime/base.ts +154 -99
  55. package/src/services/__tests__/auth-type-satisfies.test.ts +232 -0
  56. package/src/services/__tests__/oauth-config.service.test.ts +66 -0
  57. package/src/services/__tests__/proof-verifier.integration.test.ts +1 -1
  58. package/src/services/__tests__/proof-verifier.test.ts +6 -3
  59. package/src/services/__tests__/tool-context-builder-authtype.test.ts +167 -0
  60. package/src/services/auth-type-satisfies.ts +134 -0
  61. package/src/services/oauth-config.service.ts +44 -1
  62. package/src/services/tool-context-builder.ts +64 -18
  63. package/src/__tests__/runtime/audit-logger.test.ts +0 -154
@@ -89,9 +89,6 @@ describe("processToolCall Security", () => {
89
89
  timestampSkewSeconds: 120,
90
90
  ttlMinutes: 30,
91
91
  },
92
- audit: {
93
- enabled: false,
94
- },
95
92
  toolProtectionService: mockToolProtectionService,
96
93
  };
97
94
 
@@ -212,7 +209,6 @@ describe("processToolCall Security", () => {
212
209
  const consoleSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
213
210
 
214
211
  // Enable audit to trigger logging
215
- config.audit = { enabled: true };
216
212
  runtime = new MCPIRuntimeBase(config);
217
213
  (runtime as any).accessControlService = mockAccessControlService;
218
214
  await runtime.initialize();
@@ -506,11 +502,10 @@ describe("processToolCall Security", () => {
506
502
  });
507
503
 
508
504
  describe("Access Control Service Not Configured", () => {
509
- it("should log warning and allow execution when AccessControlService not available", async () => {
505
+ it("logs and fails closed when AccessControlService is unavailable", async () => {
510
506
  const consoleSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
511
507
 
512
508
  // Enable audit for logging
513
- config.audit = { enabled: true };
514
509
  runtime = new MCPIRuntimeBase(config);
515
510
  // Don't inject accessControlService
516
511
  (runtime as any).accessControlService = undefined;
@@ -525,17 +520,16 @@ describe("processToolCall Security", () => {
525
520
 
526
521
  const toolHandler = vi.fn().mockResolvedValue({ result: "success" });
527
522
 
528
- // Should allow with warning (graceful degradation)
529
- await runtime.processToolCall(
523
+ await expect(runtime.processToolCall(
530
524
  "protected-tool",
531
525
  { arg: "value" },
532
526
  toolHandler,
533
527
  session
534
- );
528
+ )).rejects.toThrow(DelegationRequiredError);
535
529
 
536
- expect(toolHandler).toHaveBeenCalled();
530
+ expect(toolHandler).not.toHaveBeenCalled();
537
531
  expect(consoleSpy).toHaveBeenCalledWith(
538
- expect.stringContaining("AccessControlApiService not configured"),
532
+ expect.stringContaining("Delegation verifier unavailable"),
539
533
  expect.any(Object)
540
534
  );
541
535
 
@@ -24,9 +24,6 @@ describe('MCPIRuntimeBase - Proof Client DID', () => {
24
24
  timestampSkewSeconds: 120,
25
25
  ttlMinutes: 30
26
26
  },
27
- audit: {
28
- enabled: false
29
- }
30
27
  };
31
28
  runtime = new MCPIRuntimeBase(config);
32
29
  await runtime.initialize();
@@ -373,4 +370,3 @@ describe('MCPIRuntimeBase - Proof Client DID', () => {
373
370
  });
374
371
  });
375
372
  });
376
-
@@ -44,7 +44,6 @@ describe("Provider Selection in Consent URLs", () => {
44
44
 
45
45
  config = {
46
46
  ...mockProviders,
47
- audit: { enabled: false },
48
47
  toolProtectionService: mockToolProtectionService as any,
49
48
  clock: new MockClockProvider(),
50
49
  };
@@ -289,4 +288,3 @@ describe("Provider Selection in Consent URLs", () => {
289
288
  });
290
289
  });
291
290
  });
292
-
@@ -33,12 +33,16 @@ describe('MCPIRuntimeBase - Route Interception', () => {
33
33
  timestampSkewSeconds: 120,
34
34
  ttlMinutes: 30
35
35
  },
36
- audit: {
37
- enabled: false
38
- },
39
36
  toolProtectionService: mockToolProtectionService as any
40
37
  };
41
38
  runtime = new MCPIRuntimeBase(config);
39
+ (runtime as any).accessControlService = {
40
+ verifyDelegation: vi.fn().mockResolvedValue({
41
+ data: {
42
+ valid: true,
43
+ },
44
+ }),
45
+ };
42
46
  await runtime.initialize();
43
47
  });
44
48
 
@@ -667,4 +671,3 @@ describe('MCPIRuntimeBase - Route Interception', () => {
667
671
  });
668
672
  });
669
673
  });
670
-
@@ -43,11 +43,6 @@ describe("MCPIRuntimeBase - Tool Protection Enforcement", () => {
43
43
  timestampSkewSeconds: 120,
44
44
  ttlMinutes: 30,
45
45
  },
46
- audit: {
47
- enabled: true,
48
- logFunction: vi.fn(),
49
- includePayloads: true,
50
- },
51
46
  toolProtectionService: mockToolProtectionService as any,
52
47
  };
53
48
  runtime = new MCPIRuntimeBase(config);
@@ -306,7 +301,7 @@ describe("MCPIRuntimeBase - Tool Protection Enforcement", () => {
306
301
  expect(mockHandler).not.toHaveBeenCalled();
307
302
  });
308
303
 
309
- it("should allow tool execution when access control service not configured (graceful degradation)", async () => {
304
+ it("fails closed when access control service is not configured", async () => {
310
305
  mockToolProtectionService.checkToolProtection.mockResolvedValue({
311
306
  requiresDelegation: true,
312
307
  requiredScopes: ["files:write"],
@@ -320,16 +315,14 @@ describe("MCPIRuntimeBase - Tool Protection Enforcement", () => {
320
315
  delegationToken: "valid-delegation-token",
321
316
  };
322
317
 
323
- // Should allow execution with warning (graceful degradation)
324
- const result = await runtime.processToolCall(
318
+ await expect(runtime.processToolCall(
325
319
  "protectedTool",
326
320
  { arg: "value" },
327
321
  mockHandler,
328
322
  sessionWithDelegation
329
- );
323
+ )).rejects.toThrow(DelegationRequiredError);
330
324
 
331
- expect(mockHandler).toHaveBeenCalledWith({ arg: "value" });
332
- expect(result).toEqual({ result: "success" });
325
+ expect(mockHandler).not.toHaveBeenCalled();
333
326
  });
334
327
 
335
328
  describe("user_identifier validation", () => {
@@ -748,7 +741,7 @@ describe("MCPIRuntimeBase - Tool Protection Enforcement", () => {
748
741
  });
749
742
  });
750
743
 
751
- describe("audit logging", () => {
744
+ describe("development diagnostics", () => {
752
745
  const mockHandler = vi.fn().mockResolvedValue({ result: "success" });
753
746
  const session = {
754
747
  id: "session123",
@@ -756,8 +749,9 @@ describe("MCPIRuntimeBase - Tool Protection Enforcement", () => {
756
749
  nonce: "test-nonce",
757
750
  };
758
751
 
759
- it("should log tool protection check when audit enabled", async () => {
752
+ it("should label tool execution as a diagnostic", async () => {
760
753
  mockToolProtectionService.checkToolProtection.mockResolvedValue(null);
754
+ const diagnostic = vi.spyOn(console, "error").mockImplementation(() => {});
761
755
 
762
756
  await runtime.processToolCall(
763
757
  "testTool",
@@ -766,20 +760,20 @@ describe("MCPIRuntimeBase - Tool Protection Enforcement", () => {
766
760
  session
767
761
  );
768
762
 
769
- expect(config.audit!.logFunction).toHaveBeenCalled();
770
- const logCalls = (config.audit!.logFunction as any).mock.calls;
771
- const protectionLogCall = logCalls.find((call: any[]) => {
763
+ const protectionLogCall = diagnostic.mock.calls.find((call: any[]) => {
772
764
  try {
773
- const log = JSON.parse(call[0]);
765
+ if (call[0] !== "[MCP-I diagnostic]") return false;
766
+ const log = JSON.parse(call[1]);
774
767
  return log.event === "tool_executed";
775
768
  } catch {
776
769
  return false;
777
770
  }
778
771
  });
779
772
  expect(protectionLogCall).toBeDefined();
773
+ diagnostic.mockRestore();
780
774
  });
781
775
 
782
- it("should log blocked tool call when audit enabled", async () => {
776
+ it("should emit a development warning for a blocked tool call", async () => {
783
777
  mockToolProtectionService.checkToolProtection.mockResolvedValue({
784
778
  requiresDelegation: true,
785
779
  requiredScopes: ["files:write"],
@@ -808,37 +802,35 @@ describe("MCPIRuntimeBase - Tool Protection Enforcement", () => {
808
802
  consoleWarnSpy.mockRestore();
809
803
  });
810
804
 
811
- it("should not log when audit disabled", async () => {
812
- const auditLogFn = vi.fn();
813
- const configNoAudit = {
805
+ it("should suppress diagnostic tool output in production", async () => {
806
+ const diagnostic = vi.spyOn(console, "error").mockImplementation(() => {});
807
+ const productionConfig = {
814
808
  ...config,
815
- audit: {
816
- enabled: false,
817
- logFunction: auditLogFn,
818
- },
809
+ environment: "production" as const,
819
810
  };
820
- const runtimeNoAudit = new MCPIRuntimeBase(configNoAudit);
821
- await runtimeNoAudit.initialize();
811
+ const productionRuntime = new MCPIRuntimeBase(productionConfig);
812
+ await productionRuntime.initialize();
822
813
 
823
814
  mockToolProtectionService.checkToolProtection.mockResolvedValue(null);
824
815
 
825
- await runtimeNoAudit.processToolCall(
816
+ await productionRuntime.processToolCall(
826
817
  "testTool",
827
818
  { arg: "value" },
828
819
  mockHandler,
829
820
  session
830
821
  );
831
822
 
832
- // Should not call log function for tool execution (initialization may still log)
833
- const toolExecutionLogs = auditLogFn.mock.calls.filter((call: any[]) => {
823
+ const toolExecutionLogs = diagnostic.mock.calls.filter((call: any[]) => {
834
824
  try {
835
- const log = JSON.parse(call[0]);
825
+ if (call[0] !== "[MCP-I diagnostic]") return false;
826
+ const log = JSON.parse(call[1]);
836
827
  return log.event === "tool_executed";
837
828
  } catch {
838
829
  return false;
839
830
  }
840
831
  });
841
832
  expect(toolExecutionLogs.length).toBe(0);
833
+ diagnostic.mockRestore();
842
834
  });
843
835
  });
844
836
 
@@ -90,11 +90,6 @@ describe("ToolProtectionService - Merged Config API", () => {
90
90
  },
91
91
  },
92
92
  },
93
- audit: {
94
- enabled: true,
95
- includeProofHashes: true,
96
- includePayloads: false,
97
- },
98
93
  session: { timestampSkewSeconds: 120, ttlMinutes: 30 },
99
94
  platform: { type: "cloudflare" },
100
95
  metadata: {
@@ -176,11 +171,6 @@ describe("ToolProtectionService - Merged Config API", () => {
176
171
  },
177
172
  },
178
173
  },
179
- audit: {
180
- enabled: false,
181
- includeProofHashes: false,
182
- includePayloads: false,
183
- },
184
174
  session: { timestampSkewSeconds: 120, ttlMinutes: 30 },
185
175
  platform: { type: "node" },
186
176
  metadata: {
@@ -236,11 +226,6 @@ describe("ToolProtectionService - Merged Config API", () => {
236
226
  source: "agentshield",
237
227
  tools: {}, // No tools discovered yet
238
228
  },
239
- audit: {
240
- enabled: false,
241
- includeProofHashes: false,
242
- includePayloads: false,
243
- },
244
229
  session: { timestampSkewSeconds: 120, ttlMinutes: 30 },
245
230
  platform: { type: "node" },
246
231
  metadata: {
@@ -304,11 +289,6 @@ describe("ToolProtectionService - Merged Config API", () => {
304
289
  },
305
290
  },
306
291
  },
307
- audit: {
308
- enabled: false,
309
- includeProofHashes: false,
310
- includePayloads: false,
311
- },
312
292
  session: { timestampSkewSeconds: 120, ttlMinutes: 30 },
313
293
  platform: { type: "cloudflare" },
314
294
  metadata: {
@@ -376,11 +356,6 @@ describe("ToolProtectionService - Merged Config API", () => {
376
356
  greet: { requiresDelegation: false, requiredScopes: [] },
377
357
  },
378
358
  },
379
- audit: {
380
- enabled: false,
381
- includeProofHashes: false,
382
- includePayloads: false,
383
- },
384
359
  session: { timestampSkewSeconds: 120, ttlMinutes: 30 },
385
360
  platform: { type: "node" },
386
361
  metadata: {
@@ -475,11 +450,6 @@ describe("ToolProtectionService - Merged Config API", () => {
475
450
  source: "agentshield",
476
451
  // No tools field - old format
477
452
  },
478
- audit: {
479
- enabled: false,
480
- includeProofHashes: false,
481
- includePayloads: false,
482
- },
483
453
  session: { timestampSkewSeconds: 120, ttlMinutes: 30 },
484
454
  platform: { type: "node" },
485
455
  metadata: {
@@ -552,11 +522,6 @@ describe("ToolProtectionService - Merged Config API", () => {
552
522
  },
553
523
  },
554
524
  },
555
- audit: {
556
- enabled: false,
557
- includeProofHashes: false,
558
- includePayloads: false,
559
- },
560
525
  session: { timestampSkewSeconds: 120, ttlMinutes: 30 },
561
526
  platform: { type: "node" },
562
527
  metadata: {
@@ -617,11 +582,6 @@ describe("ToolProtectionService - Merged Config API", () => {
617
582
  },
618
583
  },
619
584
  },
620
- audit: {
621
- enabled: false,
622
- includeProofHashes: false,
623
- includePayloads: false,
624
- },
625
585
  session: { timestampSkewSeconds: 120, ttlMinutes: 30 },
626
586
  platform: { type: "node" },
627
587
  metadata: {
@@ -65,11 +65,6 @@ describe('fetchRemoteConfig - Merged Config Format', () => {
65
65
  }
66
66
  }
67
67
  },
68
- audit: {
69
- enabled: true,
70
- includeProofHashes: true,
71
- includePayloads: false
72
- },
73
68
  session: {
74
69
  timestampSkewSeconds: 120,
75
70
  ttlMinutes: 30
@@ -140,11 +135,6 @@ describe('fetchRemoteConfig - Merged Config Format', () => {
140
135
  source: 'agentshield',
141
136
  tools: {} // Empty - no tools discovered yet
142
137
  },
143
- audit: {
144
- enabled: false,
145
- includeProofHashes: false,
146
- includePayloads: false
147
- },
148
138
  session: {
149
139
  timestampSkewSeconds: 120,
150
140
  ttlMinutes: 30
@@ -205,11 +195,6 @@ describe('fetchRemoteConfig - Merged Config Format', () => {
205
195
  source: 'agentshield'
206
196
  // No tools field - old format
207
197
  },
208
- audit: {
209
- enabled: false,
210
- includeProofHashes: false,
211
- includePayloads: false
212
- },
213
198
  session: {
214
199
  timestampSkewSeconds: 120,
215
200
  ttlMinutes: 30
@@ -275,11 +260,6 @@ describe('fetchRemoteConfig - Merged Config Format', () => {
275
260
  greet: { requiresDelegation: true, requiredScopes: ['greeting:write'] }
276
261
  }
277
262
  },
278
- audit: {
279
- enabled: false,
280
- includeProofHashes: false,
281
- includePayloads: false
282
- },
283
263
  session: {
284
264
  timestampSkewSeconds: 120,
285
265
  ttlMinutes: 30
@@ -358,11 +338,6 @@ describe('fetchRemoteConfig - Merged Config Format', () => {
358
338
  greet: { requiresDelegation: true, requiredScopes: ['greeting:write'] }
359
339
  }
360
340
  },
361
- audit: {
362
- enabled: false,
363
- includeProofHashes: false,
364
- includePayloads: false
365
- },
366
341
  session: {
367
342
  timestampSkewSeconds: 120,
368
343
  ttlMinutes: 30
@@ -442,4 +417,3 @@ describe('fetchRemoteConfig - Merged Config Format', () => {
442
417
  });
443
418
  });
444
419
  });
445
-
package/src/config.ts CHANGED
@@ -25,6 +25,7 @@ import type {
25
25
  } from './providers/base';
26
26
 
27
27
  import type { ToolProtectionService } from './services/tool-protection.service';
28
+ import type { RuntimeAuditConfig } from './runtime/audit';
28
29
 
29
30
  /**
30
31
  * Provider-based runtime configuration
@@ -35,6 +36,9 @@ import type { ToolProtectionService } from './services/tool-protection.service';
35
36
  * for Node.js, Cloudflare Workers, and other environments.
36
37
  */
37
38
  export interface ProviderRuntimeConfig extends MCPIBaseConfig {
39
+ /** Canonical KYA-OS audit trail integration. */
40
+ auditTrail?: RuntimeAuditConfig;
41
+
38
42
  /**
39
43
  * Cryptographic operations provider
40
44
  * Handles signing, verification, and key generation
@@ -204,14 +208,9 @@ export class ProviderRuntimeConfigBuilder {
204
208
  return this;
205
209
  }
206
210
 
207
- /**
208
- * Enable audit features
209
- */
210
- withAudit(audit: {
211
- enabled: boolean;
212
- includeProofHashes?: boolean;
213
- }): this {
214
- this.config.audit = audit;
211
+ /** Configure the canonical KYA-OS audit trail. */
212
+ withAuditTrail(auditTrail: RuntimeAuditConfig | undefined): this {
213
+ this.config.auditTrail = auditTrail;
215
214
  return this;
216
215
  }
217
216
 
@@ -306,7 +305,7 @@ export function createProviderRuntimeConfig(
306
305
  enabled: false,
307
306
  verifier: { type: 'memory' }
308
307
  })
309
- .withAudit(options?.audit || { enabled: false })
308
+ .withAuditTrail(options?.auditTrail)
310
309
  .withWellKnown(options?.wellKnown || { enabled: true })
311
310
  .build();
312
- }
311
+ }
package/src/index.ts CHANGED
@@ -48,8 +48,29 @@ export {
48
48
  // C4 (#2918) 3c envelope flip — DelegationRequiredError → needs_authorization mapper.
49
49
  export { toNeedsAuthorization } from "./runtime/needs-authorization";
50
50
 
51
- // Audit Logger Interface
52
- export type { IAuditLogger } from "./runtime/audit-logger";
51
+ // Canonical KYA-OS audit trail integration
52
+ export {
53
+ RuntimeToolAuditInvocation,
54
+ attachRuntimeAuditMetadata,
55
+ beginRuntimeToolAudit,
56
+ createHmacRuntimeAuditContextFactory,
57
+ recordRuntimeConsentAudit,
58
+ recordRuntimeDelegationAudit,
59
+ terminalForToolError,
60
+ terminalForToolResult,
61
+ } from "./runtime/audit";
62
+ export type {
63
+ HmacRuntimeAuditContextOptions,
64
+ RuntimeAuditCallContext,
65
+ RuntimeAuditConfig,
66
+ RuntimeAuditContextFactory,
67
+ RuntimeAuditToolInput,
68
+ RuntimeAuditTrailPort,
69
+ RuntimeConsentAuditInput,
70
+ RuntimeDelegationAuditInput,
71
+ RuntimeToolTerminal,
72
+ RuntimeToolTerminalPhase,
73
+ } from "./runtime/audit";
53
74
 
54
75
  // Utilities
55
76
  export * from "./utils";
@@ -117,6 +138,15 @@ export { ToolContextBuilder } from "./services/tool-context-builder";
117
138
 
118
139
  export type { ToolContextBuilderConfig } from "./services/tool-context-builder";
119
140
 
141
+ // Auth-type satisfaction check (security fix: consent-approve auth-gate, Task B3)
142
+ // Consumed by the delegation-enforcement gates in agent.ts and
143
+ // tool-context-builder.ts to reject a delegation whose authorization type does
144
+ // not satisfy the tool's required type.
145
+ export {
146
+ authTypeSatisfies,
147
+ normalizeAuthType,
148
+ } from "./services/auth-type-satisfies";
149
+
120
150
  // OAuth Provider Registry (Phase 2)
121
151
  export { OAuthProviderRegistry } from "./services/oauth-provider-registry";
122
152
 
@@ -0,0 +1,15 @@
1
+ import { describe, expectTypeOf, it } from "vitest";
2
+
3
+ import type { AuditContext, AuditEventContext } from "@kya-os/contracts/audit";
4
+ import type { IAuditLogger } from "../audit-logger.js";
5
+
6
+ describe("legacy audit logger compatibility", () => {
7
+ it("keeps the published type-only interface during the minor train", () => {
8
+ expectTypeOf<IAuditLogger["logAuditRecord"]>().toEqualTypeOf<
9
+ (context: AuditContext) => Promise<void>
10
+ >();
11
+ expectTypeOf<IAuditLogger["logEvent"]>().toEqualTypeOf<
12
+ (context: AuditEventContext) => Promise<void>
13
+ >();
14
+ });
15
+ });
@@ -1,39 +1,16 @@
1
1
  /**
2
- * Audit Logger Interface
2
+ * Legacy diagnostic-audit logger interface.
3
3
  *
4
- * Platform-agnostic interface for audit logging in the MCP-I framework.
5
- * Implementations should be provided by platform-specific packages.
4
+ * @deprecated New integrations must implement `RuntimeAuditTrailPort` from
5
+ * `@kya-os/mcp-i-runtime/runtime/audit` and use the canonical protocol from
6
+ * `@kya-os/mcp/audit`. This type-only shim preserves the published import path
7
+ * without retaining a second audit implementation.
6
8
  */
7
9
 
8
10
  import type { AuditContext, AuditEventContext } from "@kya-os/contracts/audit";
9
11
 
10
- /**
11
- * Interface for audit logging implementations
12
- *
13
- * This interface is platform-agnostic and can be implemented by:
14
- * - Node.js implementations (using Node.js crypto)
15
- * - Cloudflare Workers implementations (using Web Crypto API)
16
- * - Other platform-specific implementations
17
- */
12
+ /** @deprecated Implement `RuntimeAuditTrailPort` for canonical audit events. */
18
13
  export interface IAuditLogger {
19
- /**
20
- * Log an audit record (with session deduplication)
21
- *
22
- * This method logs audit records using the frozen audit.v1 format.
23
- * Only the first call per session is logged (deduplication).
24
- *
25
- * @param context - Audit context with identity, session, hashes, and verification status
26
- */
27
14
  logAuditRecord(context: AuditContext): Promise<void>;
28
-
29
- /**
30
- * Log an event (without session deduplication)
31
- *
32
- * This method logs events using the frozen audit.v1 format.
33
- * Unlike logAuditRecord(), this always logs the event, allowing
34
- * multiple events per session (e.g., consent events).
35
- *
36
- * @param context - Event context with eventType, identity, session, and optional eventData
37
- */
38
15
  logEvent(context: AuditEventContext): Promise<void>;
39
16
  }