@heddleagent/execution-host-client 6.4.0 → 6.6.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 (125) hide show
  1. package/README.md +51 -4
  2. package/dist/adopter/contracts.d.ts +13 -0
  3. package/dist/adopter/contracts.d.ts.map +1 -0
  4. package/dist/adopter/contracts.js +13 -0
  5. package/dist/adopter/contracts.js.map +1 -0
  6. package/dist/adopter/hosted-conversation-client.d.ts +20 -0
  7. package/dist/adopter/hosted-conversation-client.d.ts.map +1 -0
  8. package/dist/adopter/hosted-conversation-client.js +103 -0
  9. package/dist/adopter/hosted-conversation-client.js.map +1 -0
  10. package/dist/adopter/index.d.ts +5 -0
  11. package/dist/adopter/index.d.ts.map +1 -0
  12. package/dist/adopter/index.js +3 -0
  13. package/dist/adopter/index.js.map +1 -0
  14. package/dist/adopter/types.d.ts +14 -0
  15. package/dist/adopter/types.d.ts.map +1 -0
  16. package/dist/adopter/types.js +2 -0
  17. package/dist/adopter/types.js.map +1 -0
  18. package/dist/agentcore/agentcore-execution-host.d.ts.map +1 -1
  19. package/dist/agentcore/agentcore-execution-host.js +7 -4
  20. package/dist/agentcore/agentcore-execution-host.js.map +1 -1
  21. package/dist/agentcore/index.d.ts +2 -0
  22. package/dist/agentcore/index.d.ts.map +1 -1
  23. package/dist/agentcore/index.js +1 -0
  24. package/dist/agentcore/index.js.map +1 -1
  25. package/dist/agentcore/schemas.d.ts +11 -0
  26. package/dist/agentcore/schemas.d.ts.map +1 -0
  27. package/dist/agentcore/schemas.js +12 -0
  28. package/dist/agentcore/schemas.js.map +1 -0
  29. package/dist/agentcore/types.d.ts +2 -4
  30. package/dist/agentcore/types.d.ts.map +1 -1
  31. package/dist/agentcore/types.js.map +1 -1
  32. package/dist/coordinator/contracts.d.ts +367 -2
  33. package/dist/coordinator/contracts.d.ts.map +1 -1
  34. package/dist/coordinator/contracts.js +72 -2
  35. package/dist/coordinator/contracts.js.map +1 -1
  36. package/dist/coordinator/hosted-heartbeat-coordinator-client.d.ts +6 -2
  37. package/dist/coordinator/hosted-heartbeat-coordinator-client.d.ts.map +1 -1
  38. package/dist/coordinator/hosted-heartbeat-coordinator-client.js +21 -1
  39. package/dist/coordinator/hosted-heartbeat-coordinator-client.js.map +1 -1
  40. package/dist/coordinator/index.d.ts +2 -2
  41. package/dist/coordinator/index.d.ts.map +1 -1
  42. package/dist/coordinator/index.js +1 -1
  43. package/dist/coordinator/index.js.map +1 -1
  44. package/dist/coordinator/types.d.ts +7 -3
  45. package/dist/coordinator/types.d.ts.map +1 -1
  46. package/dist/coordinator/types.js.map +1 -1
  47. package/dist/host/errors.d.ts +23 -0
  48. package/dist/host/errors.d.ts.map +1 -0
  49. package/dist/host/errors.js +32 -0
  50. package/dist/host/errors.js.map +1 -0
  51. package/dist/host/index.d.ts +8 -0
  52. package/dist/host/index.d.ts.map +1 -0
  53. package/dist/host/index.js +7 -0
  54. package/dist/host/index.js.map +1 -0
  55. package/dist/host/jwt-execution-host-mcp-capability-verifier.d.ts +8 -0
  56. package/dist/host/jwt-execution-host-mcp-capability-verifier.d.ts.map +1 -0
  57. package/dist/host/jwt-execution-host-mcp-capability-verifier.js +86 -0
  58. package/dist/host/jwt-execution-host-mcp-capability-verifier.js.map +1 -0
  59. package/dist/host/jwt-execution-identity-verifier.d.ts +8 -0
  60. package/dist/host/jwt-execution-identity-verifier.d.ts.map +1 -0
  61. package/dist/host/jwt-execution-identity-verifier.js +76 -0
  62. package/dist/host/jwt-execution-identity-verifier.js.map +1 -0
  63. package/dist/host/runtime-session/errors.d.ts +21 -0
  64. package/dist/host/runtime-session/errors.d.ts.map +1 -0
  65. package/dist/host/runtime-session/errors.js +21 -0
  66. package/dist/host/runtime-session/errors.js.map +1 -0
  67. package/dist/host/runtime-session/index.d.ts +9 -0
  68. package/dist/host/runtime-session/index.d.ts.map +1 -0
  69. package/dist/host/runtime-session/index.js +5 -0
  70. package/dist/host/runtime-session/index.js.map +1 -0
  71. package/dist/host/runtime-session/scope-binding.d.ts +17 -0
  72. package/dist/host/runtime-session/scope-binding.d.ts.map +1 -0
  73. package/dist/host/runtime-session/scope-binding.js +37 -0
  74. package/dist/host/runtime-session/scope-binding.js.map +1 -0
  75. package/dist/host/runtime-session/service.d.ts +38 -0
  76. package/dist/host/runtime-session/service.d.ts.map +1 -0
  77. package/dist/host/runtime-session/service.js +177 -0
  78. package/dist/host/runtime-session/service.js.map +1 -0
  79. package/dist/host/runtime-session/status.d.ts +17 -0
  80. package/dist/host/runtime-session/status.d.ts.map +1 -0
  81. package/dist/host/runtime-session/status.js +33 -0
  82. package/dist/host/runtime-session/status.js.map +1 -0
  83. package/dist/host/runtime-session/types.d.ts +61 -0
  84. package/dist/host/runtime-session/types.d.ts.map +1 -0
  85. package/dist/host/runtime-session/types.js +2 -0
  86. package/dist/host/runtime-session/types.js.map +1 -0
  87. package/dist/host/schemas.d.ts +37 -0
  88. package/dist/host/schemas.d.ts.map +1 -0
  89. package/dist/host/schemas.js +24 -0
  90. package/dist/host/schemas.js.map +1 -0
  91. package/dist/host/types.d.ts +62 -0
  92. package/dist/host/types.d.ts.map +1 -0
  93. package/dist/host/types.js +7 -0
  94. package/dist/host/types.js.map +1 -0
  95. package/dist/http-sse/direct-http-execution-host.d.ts.map +1 -1
  96. package/dist/http-sse/direct-http-execution-host.js +10 -177
  97. package/dist/http-sse/direct-http-execution-host.js.map +1 -1
  98. package/dist/index.d.ts +1 -0
  99. package/dist/index.d.ts.map +1 -1
  100. package/dist/index.js +1 -0
  101. package/dist/index.js.map +1 -1
  102. package/dist/internal/execution-host-event-stream.d.ts +18 -0
  103. package/dist/internal/execution-host-event-stream.d.ts.map +1 -0
  104. package/dist/internal/execution-host-event-stream.js +141 -0
  105. package/dist/internal/execution-host-event-stream.js.map +1 -0
  106. package/dist/internal/http-response.d.ts +4 -0
  107. package/dist/internal/http-response.d.ts.map +1 -0
  108. package/dist/internal/http-response.js +57 -0
  109. package/dist/internal/http-response.js.map +1 -0
  110. package/dist/internal/jwt-verification.d.ts +5 -0
  111. package/dist/internal/jwt-verification.d.ts.map +1 -0
  112. package/dist/internal/jwt-verification.js +25 -0
  113. package/dist/internal/jwt-verification.js.map +1 -0
  114. package/dist/mcp/jwt-capability-verifier.d.ts.map +1 -1
  115. package/dist/mcp/jwt-capability-verifier.js +6 -25
  116. package/dist/mcp/jwt-capability-verifier.js.map +1 -1
  117. package/dist/node/http-service.d.ts +0 -2
  118. package/dist/node/http-service.d.ts.map +1 -1
  119. package/dist/node/http-service.js +1 -2
  120. package/dist/node/http-service.js.map +1 -1
  121. package/dist/node/index.d.ts +2 -1
  122. package/dist/node/index.d.ts.map +1 -1
  123. package/dist/node/index.js +2 -1
  124. package/dist/node/index.js.map +1 -1
  125. package/package.json +10 -2
@@ -0,0 +1,37 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { RuntimeScopeMismatchError } from './errors.js';
3
+ /** Defense in depth if a host process is reused across execution scopes. */
4
+ export class RuntimeScopeBindingService {
5
+ bound;
6
+ bind(input) {
7
+ const candidate = RuntimeScopeBindingService.toBoundScope(input);
8
+ if (!this.bound) {
9
+ this.bound = candidate;
10
+ return candidate;
11
+ }
12
+ if (this.bound.scopeKey !== candidate.scopeKey) {
13
+ throw new RuntimeScopeMismatchError('This runtime process is already bound to a different execution scope.');
14
+ }
15
+ return this.bound;
16
+ }
17
+ current() {
18
+ return this.bound;
19
+ }
20
+ static toBoundScope(binding) {
21
+ const scopeKey = createHash('sha256')
22
+ .update(JSON.stringify([
23
+ binding.runtimeSessionId,
24
+ binding.adopterId,
25
+ binding.tenantId,
26
+ binding.subjectId,
27
+ binding.productSessionId,
28
+ ]))
29
+ .digest('hex');
30
+ return {
31
+ binding: { ...binding },
32
+ scopeKey,
33
+ executionSessionId: `runtime-${scopeKey}`,
34
+ };
35
+ }
36
+ }
37
+ //# sourceMappingURL=scope-binding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope-binding.js","sourceRoot":"","sources":["../../../src/host/runtime-session/scope-binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAYxD,4EAA4E;AAC5E,MAAM,OAAO,0BAA0B;IAC7B,KAAK,CAAqB;IAElC,IAAI,CAAC,KAA0B;QAC7B,MAAM,SAAS,GAAG,0BAA0B,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QACjE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;YACvB,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC,QAAQ,EAAE,CAAC;YAC/C,MAAM,IAAI,yBAAyB,CACjC,uEAAuE,CACxE,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAEO,MAAM,CAAC,YAAY,CAAC,OAA4B;QACtD,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;aAClC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;YACrB,OAAO,CAAC,gBAAgB;YACxB,OAAO,CAAC,SAAS;YACjB,OAAO,CAAC,QAAQ;YAChB,OAAO,CAAC,SAAS;YACjB,OAAO,CAAC,gBAAgB;SACzB,CAAC,CAAC;aACF,MAAM,CAAC,KAAK,CAAC,CAAC;QAEjB,OAAO;YACL,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE;YACvB,QAAQ;YACR,kBAAkB,EAAE,WAAW,QAAQ,EAAE;SAC1C,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { createHash } from 'node:crypto';\nimport type { ExecutionScope } from '../../contracts/index.js';\nimport { RuntimeScopeMismatchError } from './errors.js';\n\nexport type RuntimeScopeBinding = ExecutionScope & {\n runtimeSessionId: string;\n};\n\nexport type BoundRuntimeScope = {\n binding: RuntimeScopeBinding;\n scopeKey: string;\n executionSessionId: string;\n};\n\n/** Defense in depth if a host process is reused across execution scopes. */\nexport class RuntimeScopeBindingService {\n private bound?: BoundRuntimeScope;\n\n bind(input: RuntimeScopeBinding): BoundRuntimeScope {\n const candidate = RuntimeScopeBindingService.toBoundScope(input);\n if (!this.bound) {\n this.bound = candidate;\n return candidate;\n }\n\n if (this.bound.scopeKey !== candidate.scopeKey) {\n throw new RuntimeScopeMismatchError(\n 'This runtime process is already bound to a different execution scope.',\n );\n }\n\n return this.bound;\n }\n\n current(): BoundRuntimeScope | undefined {\n return this.bound;\n }\n\n private static toBoundScope(binding: RuntimeScopeBinding): BoundRuntimeScope {\n const scopeKey = createHash('sha256')\n .update(JSON.stringify([\n binding.runtimeSessionId,\n binding.adopterId,\n binding.tenantId,\n binding.subjectId,\n binding.productSessionId,\n ]))\n .digest('hex');\n\n return {\n binding: { ...binding },\n scopeKey,\n executionSessionId: `runtime-${scopeKey}`,\n };\n }\n}\n"]}
@@ -0,0 +1,38 @@
1
+ import type { VerifiedExecutionHostMcpCapability, VerifiedExecutionIdentity } from '../types.js';
2
+ import { RuntimeScopeBindingService, type BoundRuntimeScope } from './scope-binding.js';
3
+ import { RuntimeSessionStatusService, type RuntimeSessionStatusSnapshot } from './status.js';
4
+ import type { RuntimeInvocationHandle, RuntimeInvocationRequest, RuntimeSessionConfig, RuntimeWorkflowExecutors } from './types.js';
5
+ /** Coordinates one process-bound Runtime session without owning product data. */
6
+ export declare class RuntimeSessionService {
7
+ private active?;
8
+ private starting?;
9
+ private readonly recentCompletedInvocationIds;
10
+ private readonly recentCompletedInvocationOrder;
11
+ private readonly config;
12
+ private readonly executors;
13
+ private readonly binding;
14
+ private readonly status;
15
+ private readonly now;
16
+ constructor(options: {
17
+ config: RuntimeSessionConfig;
18
+ executors: RuntimeWorkflowExecutors;
19
+ binding?: RuntimeScopeBindingService;
20
+ status?: RuntimeSessionStatusService;
21
+ now?: () => Date;
22
+ });
23
+ readStatus(): RuntimeSessionStatusSnapshot;
24
+ start(input: {
25
+ identity: VerifiedExecutionIdentity;
26
+ invocation: RuntimeInvocationRequest;
27
+ modelApiKey: string;
28
+ mcpCapability?: VerifiedExecutionHostMcpCapability;
29
+ callerSignal: AbortSignal;
30
+ }): Promise<RuntimeInvocationHandle>;
31
+ shutdown(): Promise<void>;
32
+ boundScope(): BoundRuntimeScope | undefined;
33
+ private resolveDeadline;
34
+ private settle;
35
+ private rememberCompletedInvocation;
36
+ private startExecution;
37
+ }
38
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/host/runtime-session/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kCAAkC,EAClC,yBAAyB,EAC1B,MAAM,aAAa,CAAC;AAMrB,OAAO,EACL,0BAA0B,EAC1B,KAAK,iBAAiB,EACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,2BAA2B,EAC3B,KAAK,4BAA4B,EAClC,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAGV,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AAiBpB,iFAAiF;AACjF,qBAAa,qBAAqB;IAChC,OAAO,CAAC,MAAM,CAAC,CAAmB;IAClC,OAAO,CAAC,QAAQ,CAAC,CAAqB;IACtC,OAAO,CAAC,QAAQ,CAAC,4BAA4B,CAAqB;IAClE,OAAO,CAAC,QAAQ,CAAC,8BAA8B,CAAgB;IAC/D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuB;IAC9C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA2B;IACrD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IACrD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8B;IACrD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAa;gBAErB,OAAO,EAAE;QACnB,MAAM,EAAE,oBAAoB,CAAC;QAC7B,SAAS,EAAE,wBAAwB,CAAC;QACpC,OAAO,CAAC,EAAE,0BAA0B,CAAC;QACrC,MAAM,CAAC,EAAE,2BAA2B,CAAC;QACrC,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;KAClB;IAcD,UAAU,IAAI,4BAA4B;IAIpC,KAAK,CAAC,KAAK,EAAE;QACjB,QAAQ,EAAE,yBAAyB,CAAC;QACpC,UAAU,EAAE,wBAAwB,CAAC;QACrC,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,kCAAkC,CAAC;QACnD,YAAY,EAAE,WAAW,CAAC;KAC3B,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAmG9B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB/B,UAAU,IAAI,iBAAiB,GAAG,SAAS;IAI3C,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,MAAM;IAWd,OAAO,CAAC,2BAA2B;IAYnC,OAAO,CAAC,cAAc;CAcvB"}
@@ -0,0 +1,177 @@
1
+ import { RuntimeBusyError, RuntimeDeadlineError, RuntimeDuplicateInvocationError, } from './errors.js';
2
+ import { RuntimeScopeBindingService, } from './scope-binding.js';
3
+ import { RuntimeSessionStatusService, } from './status.js';
4
+ const RECENT_INVOCATION_LIMIT = 128;
5
+ /** Coordinates one process-bound Runtime session without owning product data. */
6
+ export class RuntimeSessionService {
7
+ active;
8
+ starting;
9
+ recentCompletedInvocationIds = new Set();
10
+ recentCompletedInvocationOrder = [];
11
+ config;
12
+ executors;
13
+ binding;
14
+ status;
15
+ now;
16
+ constructor(options) {
17
+ if (!Number.isSafeInteger(options.config.maxInvocationMs)
18
+ || options.config.maxInvocationMs <= 0) {
19
+ throw new Error('maxInvocationMs must be a positive safe integer.');
20
+ }
21
+ this.config = options.config;
22
+ this.executors = options.executors;
23
+ this.binding = options.binding ?? new RuntimeScopeBindingService();
24
+ this.now = options.now ?? (() => new Date());
25
+ this.status = options.status ?? new RuntimeSessionStatusService(this.now);
26
+ }
27
+ readStatus() {
28
+ return this.status.read();
29
+ }
30
+ async start(input) {
31
+ const deadline = this.resolveDeadline(input.invocation.deadlineAt);
32
+ const binding = this.binding.bind({
33
+ runtimeSessionId: input.identity.runtimeSessionId,
34
+ ...input.identity.scope,
35
+ });
36
+ if (this.active || this.starting) {
37
+ throw new RuntimeBusyError('This runtime session already has an active invocation.');
38
+ }
39
+ if (this.recentCompletedInvocationIds.has(input.identity.invocationId)) {
40
+ throw new RuntimeDuplicateInvocationError('This recent invocation identifier already completed in the current runtime process.');
41
+ }
42
+ const controller = new AbortController();
43
+ const abortFromCaller = () => controller.abort(input.callerSignal.reason);
44
+ input.callerSignal.addEventListener('abort', abortFromCaller, { once: true });
45
+ if (input.callerSignal.aborted) {
46
+ abortFromCaller();
47
+ }
48
+ const deadlineTimer = setTimeout(() => controller.abort(new RuntimeDeadlineError('The runtime invocation deadline elapsed.')), deadline.getTime() - this.now().getTime());
49
+ deadlineTimer.unref();
50
+ this.status.markExecuting();
51
+ const executionInput = {
52
+ scopeKey: binding.scopeKey,
53
+ executionSessionId: binding.executionSessionId,
54
+ request: input.invocation,
55
+ modelApiKey: input.modelApiKey,
56
+ mcpCapability: input.mcpCapability,
57
+ abortSignal: controller.signal,
58
+ };
59
+ const startPromise = Promise.resolve().then(() => this.startExecution(executionInput));
60
+ const starting = {
61
+ controller,
62
+ promise: startPromise,
63
+ };
64
+ this.starting = starting;
65
+ let run;
66
+ try {
67
+ run = await startPromise;
68
+ }
69
+ catch (error) {
70
+ clearTimeout(deadlineTimer);
71
+ input.callerSignal.removeEventListener('abort', abortFromCaller);
72
+ this.status.markIdle();
73
+ throw error;
74
+ }
75
+ finally {
76
+ if (this.starting === starting) {
77
+ this.starting = undefined;
78
+ }
79
+ }
80
+ const active = {
81
+ invocationId: input.identity.invocationId,
82
+ run,
83
+ controller,
84
+ deadlineTimer,
85
+ removeCallerAbortListener: () => input.callerSignal.removeEventListener('abort', abortFromCaller),
86
+ };
87
+ this.active = active;
88
+ controller.signal.addEventListener('abort', () => run.cancel(), {
89
+ once: true,
90
+ });
91
+ if (controller.signal.aborted) {
92
+ run.cancel();
93
+ }
94
+ const result = run.result.finally(() => this.settle(active));
95
+ result.catch(() => undefined);
96
+ return {
97
+ runId: run.runId,
98
+ acceptedAt: this.now().toISOString(),
99
+ // The execution signal cancels the agent, but the event subscription
100
+ // remains open for the executor's truthful cancelled terminal.
101
+ events: () => run.events(),
102
+ cancel: () => {
103
+ const wasActive = !controller.signal.aborted;
104
+ controller.abort();
105
+ return wasActive;
106
+ },
107
+ result,
108
+ };
109
+ }
110
+ async shutdown() {
111
+ const starting = this.starting;
112
+ if (starting) {
113
+ starting.controller.abort(new Error('Runtime is shutting down.'));
114
+ const run = await starting.promise.catch(() => undefined);
115
+ if (run) {
116
+ run.cancel();
117
+ await run.result.catch(() => undefined);
118
+ }
119
+ }
120
+ const active = this.active;
121
+ if (!active) {
122
+ return;
123
+ }
124
+ active.controller.abort(new Error('Runtime is shutting down.'));
125
+ active.run.cancel();
126
+ await active.run.result.catch(() => undefined);
127
+ }
128
+ boundScope() {
129
+ return this.binding.current();
130
+ }
131
+ resolveDeadline(deadlineAt) {
132
+ const now = this.now();
133
+ const maximum = new Date(now.getTime() + this.config.maxInvocationMs);
134
+ if (!deadlineAt) {
135
+ return maximum;
136
+ }
137
+ const requested = new Date(deadlineAt);
138
+ if (requested.getTime() <= now.getTime()) {
139
+ throw new RuntimeDeadlineError('The runtime invocation deadline has already elapsed.');
140
+ }
141
+ return requested.getTime() < maximum.getTime() ? requested : maximum;
142
+ }
143
+ settle(active) {
144
+ if (this.active !== active) {
145
+ return;
146
+ }
147
+ clearTimeout(active.deadlineTimer);
148
+ active.removeCallerAbortListener();
149
+ this.active = undefined;
150
+ this.rememberCompletedInvocation(active.invocationId);
151
+ this.status.markIdle();
152
+ }
153
+ rememberCompletedInvocation(invocationId) {
154
+ this.recentCompletedInvocationIds.add(invocationId);
155
+ this.recentCompletedInvocationOrder.push(invocationId);
156
+ if (this.recentCompletedInvocationOrder.length <= RECENT_INVOCATION_LIMIT) {
157
+ return;
158
+ }
159
+ const oldest = this.recentCompletedInvocationOrder.shift();
160
+ if (oldest) {
161
+ this.recentCompletedInvocationIds.delete(oldest);
162
+ }
163
+ }
164
+ startExecution(input) {
165
+ if (input.request.kind === 'conversation-turn') {
166
+ return this.executors.conversationTurn.start({
167
+ ...input,
168
+ request: input.request,
169
+ });
170
+ }
171
+ return this.executors.heartbeatTask.start({
172
+ ...input,
173
+ request: input.request,
174
+ });
175
+ }
176
+ }
177
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/host/runtime-session/service.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,+BAA+B,GAChC,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,0BAA0B,GAE3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,2BAA2B,GAE5B,MAAM,aAAa,CAAC;AAUrB,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAepC,iFAAiF;AACjF,MAAM,OAAO,qBAAqB;IACxB,MAAM,CAAoB;IAC1B,QAAQ,CAAsB;IACrB,4BAA4B,GAAG,IAAI,GAAG,EAAU,CAAC;IACjD,8BAA8B,GAAa,EAAE,CAAC;IAC9C,MAAM,CAAuB;IAC7B,SAAS,CAA2B;IACpC,OAAO,CAA6B;IACpC,MAAM,CAA8B;IACpC,GAAG,CAAa;IAEjC,YAAY,OAMX;QACC,IACE,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC;eAClD,OAAO,CAAC,MAAM,CAAC,eAAe,IAAI,CAAC,EACtC,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACtE,CAAC;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,CAAC,IAAI,KAAK,mBAAmB,EAAE,CAAC;YAC/C,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,KAAK,CAAC;gBAC3C,GAAG,KAAK;gBACR,OAAO,EAAE,KAAK,CAAC,OAAO;aACvB,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,KAAK,CAAC;YACxC,GAAG,KAAK;YACR,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import type {\n VerifiedExecutionHostMcpCapability,\n VerifiedExecutionIdentity,\n} from '../types.js';\nimport {\n RuntimeBusyError,\n RuntimeDeadlineError,\n RuntimeDuplicateInvocationError,\n} from './errors.js';\nimport {\n RuntimeScopeBindingService,\n type BoundRuntimeScope,\n} from './scope-binding.js';\nimport {\n RuntimeSessionStatusService,\n type RuntimeSessionStatusSnapshot,\n} from './status.js';\nimport type {\n RuntimeExecutionHandle,\n RuntimeExecutionInput,\n RuntimeInvocationHandle,\n RuntimeInvocationRequest,\n RuntimeSessionConfig,\n RuntimeWorkflowExecutors,\n} from './types.js';\n\nconst RECENT_INVOCATION_LIMIT = 128;\n\ntype ActiveInvocation = {\n invocationId: string;\n run: RuntimeExecutionHandle;\n controller: AbortController;\n deadlineTimer: ReturnType<typeof setTimeout>;\n removeCallerAbortListener: () => void;\n};\n\ntype StartingInvocation = {\n controller: AbortController;\n promise: Promise<RuntimeExecutionHandle>;\n};\n\n/** Coordinates one process-bound Runtime session without owning product data. */\nexport class RuntimeSessionService {\n private active?: ActiveInvocation;\n private starting?: StartingInvocation;\n private readonly recentCompletedInvocationIds = new Set<string>();\n private readonly recentCompletedInvocationOrder: string[] = [];\n private readonly config: RuntimeSessionConfig;\n private readonly executors: RuntimeWorkflowExecutors;\n private readonly binding: RuntimeScopeBindingService;\n private readonly status: RuntimeSessionStatusService;\n private readonly now: () => Date;\n\n constructor(options: {\n config: RuntimeSessionConfig;\n executors: RuntimeWorkflowExecutors;\n binding?: RuntimeScopeBindingService;\n status?: RuntimeSessionStatusService;\n now?: () => Date;\n }) {\n if (\n !Number.isSafeInteger(options.config.maxInvocationMs)\n || options.config.maxInvocationMs <= 0\n ) {\n throw new Error('maxInvocationMs must be a positive safe integer.');\n }\n this.config = options.config;\n this.executors = options.executors;\n this.binding = options.binding ?? new RuntimeScopeBindingService();\n this.now = options.now ?? (() => new Date());\n this.status = options.status ?? new RuntimeSessionStatusService(this.now);\n }\n\n readStatus(): RuntimeSessionStatusSnapshot {\n return this.status.read();\n }\n\n async start(input: {\n identity: VerifiedExecutionIdentity;\n invocation: RuntimeInvocationRequest;\n modelApiKey: string;\n mcpCapability?: VerifiedExecutionHostMcpCapability;\n callerSignal: AbortSignal;\n }): Promise<RuntimeInvocationHandle> {\n const deadline = this.resolveDeadline(input.invocation.deadlineAt);\n const binding = this.binding.bind({\n runtimeSessionId: input.identity.runtimeSessionId,\n ...input.identity.scope,\n });\n\n if (this.active || this.starting) {\n throw new RuntimeBusyError(\n 'This runtime session already has an active invocation.',\n );\n }\n if (this.recentCompletedInvocationIds.has(input.identity.invocationId)) {\n throw new RuntimeDuplicateInvocationError(\n 'This recent invocation identifier already completed in the current runtime process.',\n );\n }\n\n const controller = new AbortController();\n const abortFromCaller = () => controller.abort(input.callerSignal.reason);\n input.callerSignal.addEventListener('abort', abortFromCaller, { once: true });\n if (input.callerSignal.aborted) {\n abortFromCaller();\n }\n\n const deadlineTimer = setTimeout(\n () => controller.abort(\n new RuntimeDeadlineError('The runtime invocation deadline elapsed.'),\n ),\n deadline.getTime() - this.now().getTime(),\n );\n deadlineTimer.unref();\n\n this.status.markExecuting();\n const executionInput = {\n scopeKey: binding.scopeKey,\n executionSessionId: binding.executionSessionId,\n request: input.invocation,\n modelApiKey: input.modelApiKey,\n mcpCapability: input.mcpCapability,\n abortSignal: controller.signal,\n } satisfies RuntimeExecutionInput;\n const startPromise = Promise.resolve().then(\n () => this.startExecution(executionInput),\n );\n const starting: StartingInvocation = {\n controller,\n promise: startPromise,\n };\n this.starting = starting;\n\n let run: RuntimeExecutionHandle;\n try {\n run = await startPromise;\n } catch (error) {\n clearTimeout(deadlineTimer);\n input.callerSignal.removeEventListener('abort', abortFromCaller);\n this.status.markIdle();\n throw error;\n } finally {\n if (this.starting === starting) {\n this.starting = undefined;\n }\n }\n\n const active: ActiveInvocation = {\n invocationId: input.identity.invocationId,\n run,\n controller,\n deadlineTimer,\n removeCallerAbortListener: () =>\n input.callerSignal.removeEventListener('abort', abortFromCaller),\n };\n this.active = active;\n controller.signal.addEventListener('abort', () => run.cancel(), {\n once: true,\n });\n if (controller.signal.aborted) {\n run.cancel();\n }\n\n const result = run.result.finally(() => this.settle(active));\n result.catch(() => undefined);\n\n return {\n runId: run.runId,\n acceptedAt: this.now().toISOString(),\n // The execution signal cancels the agent, but the event subscription\n // remains open for the executor's truthful cancelled terminal.\n events: () => run.events(),\n cancel: () => {\n const wasActive = !controller.signal.aborted;\n controller.abort();\n return wasActive;\n },\n result,\n };\n }\n\n async shutdown(): Promise<void> {\n const starting = this.starting;\n if (starting) {\n starting.controller.abort(new Error('Runtime is shutting down.'));\n const run = await starting.promise.catch(() => undefined);\n if (run) {\n run.cancel();\n await run.result.catch(() => undefined);\n }\n }\n\n const active = this.active;\n if (!active) {\n return;\n }\n active.controller.abort(new Error('Runtime is shutting down.'));\n active.run.cancel();\n await active.run.result.catch(() => undefined);\n }\n\n boundScope(): BoundRuntimeScope | undefined {\n return this.binding.current();\n }\n\n private resolveDeadline(deadlineAt?: string): Date {\n const now = this.now();\n const maximum = new Date(now.getTime() + this.config.maxInvocationMs);\n if (!deadlineAt) {\n return maximum;\n }\n\n const requested = new Date(deadlineAt);\n if (requested.getTime() <= now.getTime()) {\n throw new RuntimeDeadlineError(\n 'The runtime invocation deadline has already elapsed.',\n );\n }\n return requested.getTime() < maximum.getTime() ? requested : maximum;\n }\n\n private settle(active: ActiveInvocation): void {\n if (this.active !== active) {\n return;\n }\n clearTimeout(active.deadlineTimer);\n active.removeCallerAbortListener();\n this.active = undefined;\n this.rememberCompletedInvocation(active.invocationId);\n this.status.markIdle();\n }\n\n private rememberCompletedInvocation(invocationId: string): void {\n this.recentCompletedInvocationIds.add(invocationId);\n this.recentCompletedInvocationOrder.push(invocationId);\n if (this.recentCompletedInvocationOrder.length <= RECENT_INVOCATION_LIMIT) {\n return;\n }\n const oldest = this.recentCompletedInvocationOrder.shift();\n if (oldest) {\n this.recentCompletedInvocationIds.delete(oldest);\n }\n }\n\n private startExecution(\n input: RuntimeExecutionInput,\n ): Promise<RuntimeExecutionHandle> {\n if (input.request.kind === 'conversation-turn') {\n return this.executors.conversationTurn.start({\n ...input,\n request: input.request,\n });\n }\n return this.executors.heartbeatTask.start({\n ...input,\n request: input.request,\n });\n }\n}\n"]}
@@ -0,0 +1,17 @@
1
+ export type RuntimeSessionStatusSnapshot = {
2
+ state: 'idle' | 'executing';
3
+ changedAtUnixSeconds: number;
4
+ };
5
+ /** Tracks process-local execution status without provider-specific vocabulary. */
6
+ export declare class RuntimeSessionStatusService {
7
+ private readonly now;
8
+ private state;
9
+ private changedAtUnixSeconds;
10
+ constructor(now?: () => Date);
11
+ markExecuting(): void;
12
+ markIdle(): void;
13
+ read(): RuntimeSessionStatusSnapshot;
14
+ private transition;
15
+ private currentUnixSeconds;
16
+ }
17
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/host/runtime-session/status.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,4BAA4B,GAAG;IACzC,KAAK,EAAE,MAAM,GAAG,WAAW,CAAC;IAC5B,oBAAoB,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,kFAAkF;AAClF,qBAAa,2BAA2B;IAI1B,OAAO,CAAC,QAAQ,CAAC,GAAG;IAHhC,OAAO,CAAC,KAAK,CAAiD;IAC9D,OAAO,CAAC,oBAAoB,CAAS;gBAER,GAAG,GAAE,MAAM,IAAuB;IAI/D,aAAa,IAAI,IAAI;IAIrB,QAAQ,IAAI,IAAI;IAIhB,IAAI,IAAI,4BAA4B;IAOpC,OAAO,CAAC,UAAU;IAQlB,OAAO,CAAC,kBAAkB;CAG3B"}
@@ -0,0 +1,33 @@
1
+ /** Tracks process-local execution status without provider-specific vocabulary. */
2
+ export class RuntimeSessionStatusService {
3
+ now;
4
+ state = 'idle';
5
+ changedAtUnixSeconds;
6
+ constructor(now = () => new Date()) {
7
+ this.now = now;
8
+ this.changedAtUnixSeconds = this.currentUnixSeconds();
9
+ }
10
+ markExecuting() {
11
+ this.transition('executing');
12
+ }
13
+ markIdle() {
14
+ this.transition('idle');
15
+ }
16
+ read() {
17
+ return {
18
+ state: this.state,
19
+ changedAtUnixSeconds: this.changedAtUnixSeconds,
20
+ };
21
+ }
22
+ transition(next) {
23
+ if (this.state === next) {
24
+ return;
25
+ }
26
+ this.state = next;
27
+ this.changedAtUnixSeconds = this.currentUnixSeconds();
28
+ }
29
+ currentUnixSeconds() {
30
+ return Math.floor(this.now().getTime() / 1_000);
31
+ }
32
+ }
33
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/host/runtime-session/status.ts"],"names":[],"mappings":"AAKA,kFAAkF;AAClF,MAAM,OAAO,2BAA2B;IAIT;IAHrB,KAAK,GAA0C,MAAM,CAAC;IACtD,oBAAoB,CAAS;IAErC,YAA6B,MAAkB,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE;QAAlC,QAAG,GAAH,GAAG,CAA+B;QAC7D,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;IACxD,CAAC;IAED,aAAa;QACX,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC/B,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,IAAI;QACF,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,oBAAoB,EAAE,IAAI,CAAC,oBAAoB;SAChD,CAAC;IACJ,CAAC;IAEO,UAAU,CAAC,IAA2C;QAC5D,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YACxB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;IACxD,CAAC;IAEO,kBAAkB;QACxB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,CAAC;IAClD,CAAC;CACF","sourcesContent":["export type RuntimeSessionStatusSnapshot = {\n state: 'idle' | 'executing';\n changedAtUnixSeconds: number;\n};\n\n/** Tracks process-local execution status without provider-specific vocabulary. */\nexport class RuntimeSessionStatusService {\n private state: RuntimeSessionStatusSnapshot['state'] = 'idle';\n private changedAtUnixSeconds: number;\n\n constructor(private readonly now: () => Date = () => new Date()) {\n this.changedAtUnixSeconds = this.currentUnixSeconds();\n }\n\n markExecuting(): void {\n this.transition('executing');\n }\n\n markIdle(): void {\n this.transition('idle');\n }\n\n read(): RuntimeSessionStatusSnapshot {\n return {\n state: this.state,\n changedAtUnixSeconds: this.changedAtUnixSeconds,\n };\n }\n\n private transition(next: RuntimeSessionStatusSnapshot['state']): void {\n if (this.state === next) {\n return;\n }\n this.state = next;\n this.changedAtUnixSeconds = this.currentUnixSeconds();\n }\n\n private currentUnixSeconds(): number {\n return Math.floor(this.now().getTime() / 1_000);\n }\n}\n"]}
@@ -0,0 +1,61 @@
1
+ import type { ExecutionHostConversationTurnRequest, ExecutionHostHeartbeatTaskRequest, RuntimePublicResult } from '../../contracts/index.js';
2
+ import type { VerifiedExecutionHostMcpCapability } from '../types.js';
3
+ type RuntimeExecutionStreamEnvelope = {
4
+ runId: string;
5
+ sequence: number;
6
+ timestamp: string;
7
+ };
8
+ /** Ordered execution events exposed by any workflow executor. */
9
+ export type RuntimeExecutionStreamItem<Result = unknown> = (RuntimeExecutionStreamEnvelope & {
10
+ kind: 'activity';
11
+ activity: unknown;
12
+ }) | (RuntimeExecutionStreamEnvelope & {
13
+ kind: 'result';
14
+ result: Result;
15
+ }) | (RuntimeExecutionStreamEnvelope & {
16
+ kind: 'cancelled';
17
+ reason: string;
18
+ }) | (RuntimeExecutionStreamEnvelope & {
19
+ kind: 'error';
20
+ error: {
21
+ code: string;
22
+ message: string;
23
+ };
24
+ });
25
+ export type RuntimeInvocationRequest = ExecutionHostConversationTurnRequest | ExecutionHostHeartbeatTaskRequest;
26
+ export type RuntimeExecutionInput<Request extends RuntimeInvocationRequest = RuntimeInvocationRequest> = {
27
+ scopeKey: string;
28
+ executionSessionId: string;
29
+ request: Request;
30
+ modelApiKey: string;
31
+ mcpCapability?: VerifiedExecutionHostMcpCapability;
32
+ abortSignal: AbortSignal;
33
+ };
34
+ export type RuntimeExecutionHandle<Result = unknown> = {
35
+ runId: string;
36
+ result: Promise<Result>;
37
+ events(options?: {
38
+ signal?: AbortSignal;
39
+ }): AsyncIterable<RuntimeExecutionStreamItem<Result>>;
40
+ cancel(): boolean;
41
+ };
42
+ /** Outbound execution port for one provider-neutral workflow. */
43
+ export type RuntimeWorkflowExecutor<Request extends RuntimeInvocationRequest, Result> = {
44
+ start(input: RuntimeExecutionInput<Request>): Promise<RuntimeExecutionHandle<Result>>;
45
+ };
46
+ export type RuntimeWorkflowExecutors<HeartbeatResult = unknown> = {
47
+ conversationTurn: RuntimeWorkflowExecutor<ExecutionHostConversationTurnRequest, RuntimePublicResult>;
48
+ heartbeatTask: RuntimeWorkflowExecutor<ExecutionHostHeartbeatTaskRequest, HeartbeatResult>;
49
+ };
50
+ export type RuntimeInvocationHandle<Result = unknown> = {
51
+ runId: string;
52
+ acceptedAt: string;
53
+ events(): AsyncIterable<RuntimeExecutionStreamItem<Result>>;
54
+ cancel(): boolean;
55
+ result: Promise<Result>;
56
+ };
57
+ export type RuntimeSessionConfig = {
58
+ maxInvocationMs: number;
59
+ };
60
+ export {};
61
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/host/runtime-session/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oCAAoC,EACpC,iCAAiC,EACjC,mBAAmB,EACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,aAAa,CAAC;AAEtE,KAAK,8BAA8B,GAAG;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,iEAAiE;AACjE,MAAM,MAAM,0BAA0B,CAAC,MAAM,GAAG,OAAO,IACnD,CAAC,8BAA8B,GAAG;IAClC,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC,GACA,CAAC,8BAA8B,GAAG;IAClC,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,GACA,CAAC,8BAA8B,GAAG;IAClC,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,GACA,CAAC,8BAA8B,GAAG;IAClC,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1C,CAAC,CAAC;AAEL,MAAM,MAAM,wBAAwB,GAChC,oCAAoC,GACpC,iCAAiC,CAAC;AAEtC,MAAM,MAAM,qBAAqB,CAC/B,OAAO,SAAS,wBAAwB,GAAG,wBAAwB,IACjE;IACF,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,OAAO,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
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/host/runtime-session/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ExecutionHostConversationTurnRequest,\n ExecutionHostHeartbeatTaskRequest,\n RuntimePublicResult,\n} from '../../contracts/index.js';\nimport type { VerifiedExecutionHostMcpCapability } from '../types.js';\n\ntype RuntimeExecutionStreamEnvelope = {\n runId: string;\n sequence: number;\n timestamp: string;\n};\n\n/** Ordered execution events exposed by any workflow executor. */\nexport type RuntimeExecutionStreamItem<Result = unknown> =\n | (RuntimeExecutionStreamEnvelope & {\n kind: 'activity';\n activity: unknown;\n })\n | (RuntimeExecutionStreamEnvelope & {\n kind: 'result';\n result: Result;\n })\n | (RuntimeExecutionStreamEnvelope & {\n kind: 'cancelled';\n reason: string;\n })\n | (RuntimeExecutionStreamEnvelope & {\n kind: 'error';\n error: { code: string; message: string };\n });\n\nexport type RuntimeInvocationRequest =\n | ExecutionHostConversationTurnRequest\n | ExecutionHostHeartbeatTaskRequest;\n\nexport type RuntimeExecutionInput<\n Request extends RuntimeInvocationRequest = RuntimeInvocationRequest,\n> = {\n scopeKey: string;\n executionSessionId: string;\n request: Request;\n modelApiKey: string;\n mcpCapability?: VerifiedExecutionHostMcpCapability;\n abortSignal: AbortSignal;\n};\n\nexport type RuntimeExecutionHandle<Result = unknown> = {\n runId: string;\n result: Promise<Result>;\n events(options?: {\n signal?: AbortSignal;\n }): AsyncIterable<RuntimeExecutionStreamItem<Result>>;\n cancel(): boolean;\n};\n\n/** Outbound execution port for one provider-neutral workflow. */\nexport type RuntimeWorkflowExecutor<\n Request extends RuntimeInvocationRequest,\n Result,\n> = {\n start(\n input: RuntimeExecutionInput<Request>,\n ): Promise<RuntimeExecutionHandle<Result>>;\n};\n\nexport type RuntimeWorkflowExecutors<HeartbeatResult = unknown> = {\n conversationTurn: RuntimeWorkflowExecutor<\n ExecutionHostConversationTurnRequest,\n RuntimePublicResult\n >;\n heartbeatTask: RuntimeWorkflowExecutor<\n ExecutionHostHeartbeatTaskRequest,\n HeartbeatResult\n >;\n};\n\nexport type RuntimeInvocationHandle<Result = unknown> = {\n runId: string;\n acceptedAt: string;\n events(): AsyncIterable<RuntimeExecutionStreamItem<Result>>;\n cancel(): boolean;\n result: Promise<Result>;\n};\n\nexport type RuntimeSessionConfig = {\n maxInvocationMs: number;\n};\n"]}
@@ -0,0 +1,37 @@
1
+ import { z } from 'zod';
2
+ export declare const ExecutionHostJwtAlgorithmsSchema: z.ZodPipe<z.ZodArray<z.ZodEnum<{
3
+ ES256: "ES256";
4
+ RS256: "RS256";
5
+ PS256: "PS256";
6
+ EdDSA: "EdDSA";
7
+ }>>, z.ZodTransform<readonly ("ES256" | "RS256" | "PS256" | "EdDSA")[], ("ES256" | "RS256" | "PS256" | "EdDSA")[]>>;
8
+ export declare const JwtExecutionIdentityVerifierConfigSchema: z.ZodObject<{
9
+ executionIssuer: z.ZodURL;
10
+ executionAudience: z.ZodString;
11
+ executionJwksUrl: z.ZodCustom<URL, URL>;
12
+ executionJwtAlgorithms: z.ZodPipe<z.ZodArray<z.ZodEnum<{
13
+ ES256: "ES256";
14
+ RS256: "RS256";
15
+ PS256: "PS256";
16
+ EdDSA: "EdDSA";
17
+ }>>, z.ZodTransform<readonly ("ES256" | "RS256" | "PS256" | "EdDSA")[], ("ES256" | "RS256" | "PS256" | "EdDSA")[]>>;
18
+ trustedAdopterId: z.ZodString;
19
+ maxAssertionAgeSeconds: z.ZodNumber;
20
+ assertionClockToleranceSeconds: z.ZodNumber;
21
+ }, z.core.$strict>;
22
+ export declare const JwtExecutionHostMcpCapabilityVerifierConfigSchema: z.ZodObject<{
23
+ issuer: z.ZodURL;
24
+ audience: z.ZodString;
25
+ jwksUrl: z.ZodCustom<URL, URL>;
26
+ jwtAlgorithms: z.ZodPipe<z.ZodArray<z.ZodEnum<{
27
+ ES256: "ES256";
28
+ RS256: "RS256";
29
+ PS256: "PS256";
30
+ EdDSA: "EdDSA";
31
+ }>>, z.ZodTransform<readonly ("ES256" | "RS256" | "PS256" | "EdDSA")[], ("ES256" | "RS256" | "PS256" | "EdDSA")[]>>;
32
+ trustedAdopterId: z.ZodString;
33
+ serverId: z.ZodString;
34
+ maxCapabilityAgeSeconds: z.ZodNumber;
35
+ clockToleranceSeconds: z.ZodNumber;
36
+ }, z.core.$strict>;
37
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/host/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,eAAO,MAAM,gCAAgC;;;;;mHAI5C,CAAC;AAEF,eAAO,MAAM,wCAAwC;;;;;;;;;;;;;kBAW1C,CAAC;AAEZ,eAAO,MAAM,iDAAiD;;;;;;;;;;;;;;kBAYnD,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+ import { JwtAudienceSchema, JwtIssuerSchema, McpServerIdSchema, OpaqueIdSchema, isSafeWebUrl, } from '../contracts/index.js';
3
+ import { EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS } from './types.js';
4
+ export const ExecutionHostJwtAlgorithmsSchema = z.array(z.enum(EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS)).min(1).max(EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS.length).transform((algorithms) => Object.freeze([...new Set(algorithms)]));
5
+ export const JwtExecutionIdentityVerifierConfigSchema = z.object({
6
+ executionIssuer: JwtIssuerSchema,
7
+ executionAudience: JwtAudienceSchema,
8
+ executionJwksUrl: z.instanceof(URL).refine(isSafeWebUrl, 'must use HTTPS or loopback HTTP and contain no credentials, query, or fragment'),
9
+ executionJwtAlgorithms: ExecutionHostJwtAlgorithmsSchema,
10
+ trustedAdopterId: OpaqueIdSchema,
11
+ maxAssertionAgeSeconds: z.number().int().min(1).max(15 * 60),
12
+ assertionClockToleranceSeconds: z.number().int().min(0).max(60),
13
+ }).strict();
14
+ export const JwtExecutionHostMcpCapabilityVerifierConfigSchema = z.object({
15
+ issuer: JwtIssuerSchema,
16
+ audience: JwtAudienceSchema,
17
+ jwksUrl: z.instanceof(URL).refine(isSafeWebUrl, 'must use HTTPS or loopback HTTP and contain no credentials, query, or fragment'),
18
+ jwtAlgorithms: ExecutionHostJwtAlgorithmsSchema,
19
+ trustedAdopterId: OpaqueIdSchema,
20
+ serverId: McpServerIdSchema,
21
+ maxCapabilityAgeSeconds: z.number().int().min(1).max(15 * 60),
22
+ clockToleranceSeconds: z.number().int().min(0).max(60),
23
+ }).strict();
24
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/host/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,YAAY,GACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,uCAAuC,EAAE,MAAM,YAAY,CAAC;AAErE,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,KAAK,CACrD,CAAC,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAChD,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,uCAAuC,CAAC,MAAM,CAAC,CAAC,SAAS,CACpE,CAAC,UAAU,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CACxD,CAAC;AAEF,MAAM,CAAC,MAAM,wCAAwC,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/D,eAAe,EAAE,eAAe;IAChC,iBAAiB,EAAE,iBAAiB;IACpC,gBAAgB,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,CACxC,YAAY,EACZ,gFAAgF,CACjF;IACD,sBAAsB,EAAE,gCAAgC;IACxD,gBAAgB,EAAE,cAAc;IAChC,sBAAsB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC;IAC5D,8BAA8B,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;CAChE,CAAC,CAAC,MAAM,EAAE,CAAC;AAEZ,MAAM,CAAC,MAAM,iDAAiD,GAAG,CAAC,CAAC,MAAM,CAAC;IACxE,MAAM,EAAE,eAAe;IACvB,QAAQ,EAAE,iBAAiB;IAC3B,OAAO,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,CAC/B,YAAY,EACZ,gFAAgF,CACjF;IACD,aAAa,EAAE,gCAAgC;IAC/C,gBAAgB,EAAE,cAAc;IAChC,QAAQ,EAAE,iBAAiB;IAC3B,uBAAuB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC;IAC7D,qBAAqB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;CACvD,CAAC,CAAC,MAAM,EAAE,CAAC","sourcesContent":["import { z } from 'zod';\nimport {\n JwtAudienceSchema,\n JwtIssuerSchema,\n McpServerIdSchema,\n OpaqueIdSchema,\n isSafeWebUrl,\n} from '../contracts/index.js';\nimport { EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS } from './types.js';\n\nexport const ExecutionHostJwtAlgorithmsSchema = z.array(\n z.enum(EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS),\n).min(1).max(EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS.length).transform(\n (algorithms) => Object.freeze([...new Set(algorithms)]),\n);\n\nexport const JwtExecutionIdentityVerifierConfigSchema = z.object({\n executionIssuer: JwtIssuerSchema,\n executionAudience: JwtAudienceSchema,\n executionJwksUrl: z.instanceof(URL).refine(\n isSafeWebUrl,\n 'must use HTTPS or loopback HTTP and contain no credentials, query, or fragment',\n ),\n executionJwtAlgorithms: ExecutionHostJwtAlgorithmsSchema,\n trustedAdopterId: OpaqueIdSchema,\n maxAssertionAgeSeconds: z.number().int().min(1).max(15 * 60),\n assertionClockToleranceSeconds: z.number().int().min(0).max(60),\n}).strict();\n\nexport const JwtExecutionHostMcpCapabilityVerifierConfigSchema = z.object({\n issuer: JwtIssuerSchema,\n audience: JwtAudienceSchema,\n jwksUrl: z.instanceof(URL).refine(\n isSafeWebUrl,\n 'must use HTTPS or loopback HTTP and contain no credentials, query, or fragment',\n ),\n jwtAlgorithms: ExecutionHostJwtAlgorithmsSchema,\n trustedAdopterId: OpaqueIdSchema,\n serverId: McpServerIdSchema,\n maxCapabilityAgeSeconds: z.number().int().min(1).max(15 * 60),\n clockToleranceSeconds: z.number().int().min(0).max(60),\n}).strict();\n"]}
@@ -0,0 +1,62 @@
1
+ import type { JWTVerifyGetKey } from 'jose';
2
+ import type { ExecutionScope, HostedExecutionWorkflow } from '../contracts/index.js';
3
+ export declare const EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS: readonly ["RS256", "PS256", "ES256", "EdDSA"];
4
+ export type ExecutionHostJwtAlgorithm = typeof EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS[number];
5
+ /** Authority established from one signed assertion and its request binding. */
6
+ export type VerifiedExecutionIdentity = Readonly<{
7
+ scope: Readonly<ExecutionScope>;
8
+ runtimeSessionId: string;
9
+ invocationId: string;
10
+ workflow: HostedExecutionWorkflow;
11
+ issuedAt: string;
12
+ expiresAt: string;
13
+ }>;
14
+ export type ExecutionIdentityVerificationRequest = Readonly<{
15
+ assertion: string;
16
+ runtimeSessionId: string;
17
+ invocationId: string;
18
+ workflow: HostedExecutionWorkflow;
19
+ }>;
20
+ export interface ExecutionIdentityVerifier {
21
+ verify(request: ExecutionIdentityVerificationRequest): Promise<VerifiedExecutionIdentity>;
22
+ }
23
+ export type JwtExecutionIdentityVerifierConfig = Readonly<{
24
+ executionIssuer: string;
25
+ executionAudience: string;
26
+ executionJwksUrl: URL;
27
+ executionJwtAlgorithms: readonly ExecutionHostJwtAlgorithm[];
28
+ trustedAdopterId: string;
29
+ maxAssertionAgeSeconds: number;
30
+ assertionClockToleranceSeconds: number;
31
+ }>;
32
+ /** Opaque MCP bearer whose claims match the independently verified execution. */
33
+ export type VerifiedExecutionHostMcpCapability = Readonly<{
34
+ assertion: string;
35
+ capabilityId: string;
36
+ serverId: string;
37
+ allowedTools: readonly string[];
38
+ issuedAt: string;
39
+ expiresAt: string;
40
+ }>;
41
+ export type ExecutionHostMcpCapabilityVerificationRequest = Readonly<{
42
+ assertion: string;
43
+ identity: VerifiedExecutionIdentity;
44
+ }>;
45
+ export interface ExecutionHostMcpCapabilityVerifier {
46
+ verify(request: ExecutionHostMcpCapabilityVerificationRequest): Promise<VerifiedExecutionHostMcpCapability>;
47
+ }
48
+ export type JwtExecutionHostMcpCapabilityVerifierConfig = Readonly<{
49
+ issuer: string;
50
+ audience: string;
51
+ jwksUrl: URL;
52
+ jwtAlgorithms: readonly ExecutionHostJwtAlgorithm[];
53
+ trustedAdopterId: string;
54
+ serverId: string;
55
+ maxCapabilityAgeSeconds: number;
56
+ clockToleranceSeconds: number;
57
+ }>;
58
+ export type ExecutionHostJwtVerifierOptions = Readonly<{
59
+ keyResolver?: JWTVerifyGetKey;
60
+ now?: () => Date;
61
+ }>;
62
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/host/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,e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B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC,CAAC;AAEH,MAAM,MAAM,6CAA6C,GAAG,QAAQ,CAAC;IACnE,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,yBAAyB,CAAC;CACrC,CAAC,CAAC;AAEH,MAAM,WAAW,kCAAkC;IACjD,MAAM,CACJ,OAAO,EAAE,6CAA6C,GACrD,OAAO,CAAC,kCAAkC,CAAC,CAAC;CAChD;AAED,MAAM,MAAM,2CAA2C,GAAG,QAAQ,CAAC;IACjE,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,GAAG,CAAC;IACb,aAAa,EAAE,SAAS,yBAAyB,EAAE,CAAC;IACpD,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,uBAAuB,EAAE,MAAM,CAAC;IAChC,qBAAqB,EAAE,MAAM,CAAC;CAC/B,CAAC,CAAC;AAEH,MAAM,MAAM,+BAA+B,GAAG,QAAQ,CAAC;IACrD,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAClB,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export const EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS = [
2
+ 'RS256',
3
+ 'PS256',
4
+ 'ES256',
5
+ 'EdDSA',
6
+ ];
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/host/types.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,uCAAuC,GAAG;IACrD,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;CACC,CAAC","sourcesContent":["import type { JWTVerifyGetKey } from 'jose';\nimport type {\n ExecutionScope,\n HostedExecutionWorkflow,\n} from '../contracts/index.js';\n\nexport const EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS = [\n 'RS256',\n 'PS256',\n 'ES256',\n 'EdDSA',\n] as const;\n\nexport type ExecutionHostJwtAlgorithm =\n typeof EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS[number];\n\n/** Authority established from one signed assertion and its request binding. */\nexport type VerifiedExecutionIdentity = Readonly<{\n scope: Readonly<ExecutionScope>;\n runtimeSessionId: string;\n invocationId: string;\n workflow: HostedExecutionWorkflow;\n issuedAt: string;\n expiresAt: string;\n}>;\n\nexport type ExecutionIdentityVerificationRequest = Readonly<{\n assertion: string;\n runtimeSessionId: string;\n invocationId: string;\n workflow: HostedExecutionWorkflow;\n}>;\n\nexport interface ExecutionIdentityVerifier {\n verify(\n request: ExecutionIdentityVerificationRequest,\n ): Promise<VerifiedExecutionIdentity>;\n}\n\nexport type JwtExecutionIdentityVerifierConfig = Readonly<{\n executionIssuer: string;\n executionAudience: string;\n executionJwksUrl: URL;\n executionJwtAlgorithms: readonly ExecutionHostJwtAlgorithm[];\n trustedAdopterId: string;\n maxAssertionAgeSeconds: number;\n assertionClockToleranceSeconds: number;\n}>;\n\n/** Opaque MCP bearer whose claims match the independently verified execution. */\nexport type VerifiedExecutionHostMcpCapability = Readonly<{\n assertion: string;\n capabilityId: string;\n serverId: string;\n allowedTools: readonly string[];\n issuedAt: string;\n expiresAt: string;\n}>;\n\nexport type ExecutionHostMcpCapabilityVerificationRequest = Readonly<{\n assertion: string;\n identity: VerifiedExecutionIdentity;\n}>;\n\nexport interface ExecutionHostMcpCapabilityVerifier {\n verify(\n request: ExecutionHostMcpCapabilityVerificationRequest,\n ): Promise<VerifiedExecutionHostMcpCapability>;\n}\n\nexport type JwtExecutionHostMcpCapabilityVerifierConfig = Readonly<{\n issuer: string;\n audience: string;\n jwksUrl: URL;\n jwtAlgorithms: readonly ExecutionHostJwtAlgorithm[];\n trustedAdopterId: string;\n serverId: string;\n maxCapabilityAgeSeconds: number;\n clockToleranceSeconds: number;\n}>;\n\nexport type ExecutionHostJwtVerifierOptions = Readonly<{\n keyResolver?: JWTVerifyGetKey;\n now?: () => Date;\n}>;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"direct-http-execution-host.d.ts","sourceRoot":"","sources":["../../src/http-sse/direct-http-execution-host.ts"],"names":[],"mappings":"AAEA,OAAO,EAmBL,KAAK,iCAAiC,EACtC,KAAK,wBAAwB,EAC9B,MAAM,uBAAuB,CAAC;AAO/B,OAAO,KAAK,EACV,6BAA6B,EAC7B,aAAa,EACb,6BAA6B,EAC7B,0BAA0B,EAC1B,sBAAsB,EACvB,MAAM,YAAY,CAAC;AAkCpB;;;GAGG;AACH,qBAAa,uBACb,YAAW,aAAa,EAAE,sBAAsB;;gBAKlC,MAAM,EAAE,6BAA6B;IAO1C,sBAAsB,CAC3B,QAAQ,EAAE,6BAA6B,GACtC,aAAa,CAAC,wBAAwB,CAAC;IAoBnC,mBAAmB,CACxB,QAAQ,EAAE,0BAA0B,GACnC,aAAa,CAAC,iCAAiC,CAAC;CAwJpD"}
1
+ {"version":3,"file":"direct-http-execution-host.d.ts","sourceRoot":"","sources":["../../src/http-sse/direct-http-execution-host.ts"],"names":[],"mappings":"AACA,OAAO,EAmBL,KAAK,iCAAiC,EACtC,KAAK,wBAAwB,EAC9B,MAAM,uBAAuB,CAAC;AAK/B,OAAO,KAAK,EACV,6BAA6B,EAC7B,aAAa,EACb,6BAA6B,EAC7B,0BAA0B,EAC1B,sBAAsB,EACvB,MAAM,YAAY,CAAC;AAqCpB;;;GAGG;AACH,qBAAa,uBACb,YAAW,aAAa,EAAE,sBAAsB;;gBAKlC,MAAM,EAAE,6BAA6B;IAO1C,sBAAsB,CAC3B,QAAQ,EAAE,6BAA6B,GACtC,aAAa,CAAC,wBAAwB,CAAC;IAoBnC,mBAAmB,CACxB,QAAQ,EAAE,0BAA0B,GACnC,aAAa,CAAC,iCAAiC,CAAC;CAmEpD"}