@kya-os/mcp-i-runtime 1.1.0 → 1.2.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.
Files changed (51) 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 +2 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +13 -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/oauth-config.service.d.ts.map +1 -1
  23. package/dist/services/oauth-config.service.js +29 -0
  24. package/dist/services/oauth-config.service.js.map +1 -1
  25. package/package.json +7 -3
  26. package/src/__tests__/config/provider-runtime-config.test.ts +2 -9
  27. package/src/__tests__/config.test.ts +12 -11
  28. package/src/__tests__/integration/full-flow.test.ts +0 -5
  29. package/src/__tests__/integration.test.ts +2 -6
  30. package/src/__tests__/runtime/audit.test.ts +327 -0
  31. package/src/__tests__/runtime/base-extensions.test.ts +0 -46
  32. package/src/__tests__/runtime/base.test.ts +71 -102
  33. package/src/__tests__/runtime/delegation-flow.test.ts +0 -4
  34. package/src/__tests__/runtime/process-tool-call-security.test.ts +5 -11
  35. package/src/__tests__/runtime/proof-client-did.test.ts +0 -4
  36. package/src/__tests__/runtime/provider-selection.test.ts +0 -2
  37. package/src/__tests__/runtime/route-interception.test.ts +7 -4
  38. package/src/__tests__/runtime/tool-protection-enforcement.test.ts +23 -31
  39. package/src/__tests__/services/tool-protection-merged-config.test.ts +0 -40
  40. package/src/config/__tests__/merged-config.spec.ts +0 -26
  41. package/src/config.ts +9 -10
  42. package/src/index.ts +23 -2
  43. package/src/runtime/__tests__/audit-logger-compat.test.ts +15 -0
  44. package/src/runtime/audit-logger.ts +6 -29
  45. package/src/runtime/audit.ts +598 -0
  46. package/src/runtime/base.ts +154 -99
  47. package/src/services/__tests__/oauth-config.service.test.ts +66 -0
  48. package/src/services/__tests__/proof-verifier.integration.test.ts +1 -1
  49. package/src/services/__tests__/proof-verifier.test.ts +6 -3
  50. package/src/services/oauth-config.service.ts +44 -1
  51. package/src/__tests__/runtime/audit-logger.test.ts +0 -154
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";
@@ -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
  }