@heddleagent/execution-host-client 6.5.0 → 6.6.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.
- package/README.md +17 -10
- package/dist/adopter/contracts.d.ts +13 -0
- package/dist/adopter/contracts.d.ts.map +1 -0
- package/dist/adopter/contracts.js +13 -0
- package/dist/adopter/contracts.js.map +1 -0
- package/dist/adopter/hosted-conversation-client.d.ts +20 -0
- package/dist/adopter/hosted-conversation-client.d.ts.map +1 -0
- package/dist/adopter/hosted-conversation-client.js +103 -0
- package/dist/adopter/hosted-conversation-client.js.map +1 -0
- package/dist/adopter/index.d.ts +5 -0
- package/dist/adopter/index.d.ts.map +1 -0
- package/dist/adopter/index.js +3 -0
- package/dist/adopter/index.js.map +1 -0
- package/dist/adopter/types.d.ts +14 -0
- package/dist/adopter/types.d.ts.map +1 -0
- package/dist/adopter/types.js +2 -0
- package/dist/adopter/types.js.map +1 -0
- package/dist/agentcore/agentcore-execution-host.d.ts.map +1 -1
- package/dist/agentcore/agentcore-execution-host.js +7 -4
- package/dist/agentcore/agentcore-execution-host.js.map +1 -1
- package/dist/agentcore/index.d.ts +2 -0
- package/dist/agentcore/index.d.ts.map +1 -1
- package/dist/agentcore/index.js +1 -0
- package/dist/agentcore/index.js.map +1 -1
- package/dist/agentcore/schemas.d.ts +11 -0
- package/dist/agentcore/schemas.d.ts.map +1 -0
- package/dist/agentcore/schemas.js +12 -0
- package/dist/agentcore/schemas.js.map +1 -0
- package/dist/agentcore/types.d.ts +2 -4
- package/dist/agentcore/types.d.ts.map +1 -1
- package/dist/agentcore/types.js.map +1 -1
- package/dist/coordinator/contracts.d.ts +367 -2
- package/dist/coordinator/contracts.d.ts.map +1 -1
- package/dist/coordinator/contracts.js +72 -2
- package/dist/coordinator/contracts.js.map +1 -1
- package/dist/coordinator/hosted-heartbeat-coordinator-client.d.ts +6 -2
- package/dist/coordinator/hosted-heartbeat-coordinator-client.d.ts.map +1 -1
- package/dist/coordinator/hosted-heartbeat-coordinator-client.js +21 -1
- package/dist/coordinator/hosted-heartbeat-coordinator-client.js.map +1 -1
- package/dist/coordinator/index.d.ts +2 -2
- package/dist/coordinator/index.d.ts.map +1 -1
- package/dist/coordinator/index.js +1 -1
- package/dist/coordinator/index.js.map +1 -1
- package/dist/coordinator/types.d.ts +7 -3
- package/dist/coordinator/types.d.ts.map +1 -1
- package/dist/coordinator/types.js.map +1 -1
- package/dist/host/index.d.ts +1 -0
- package/dist/host/index.d.ts.map +1 -1
- package/dist/host/index.js +1 -0
- package/dist/host/index.js.map +1 -1
- package/dist/host/runtime-session/errors.d.ts +21 -0
- package/dist/host/runtime-session/errors.d.ts.map +1 -0
- package/dist/host/runtime-session/errors.js +21 -0
- package/dist/host/runtime-session/errors.js.map +1 -0
- package/dist/host/runtime-session/index.d.ts +9 -0
- package/dist/host/runtime-session/index.d.ts.map +1 -0
- package/dist/host/runtime-session/index.js +5 -0
- package/dist/host/runtime-session/index.js.map +1 -0
- package/dist/host/runtime-session/scope-binding.d.ts +17 -0
- package/dist/host/runtime-session/scope-binding.d.ts.map +1 -0
- package/dist/host/runtime-session/scope-binding.js +37 -0
- package/dist/host/runtime-session/scope-binding.js.map +1 -0
- package/dist/host/runtime-session/service.d.ts +38 -0
- package/dist/host/runtime-session/service.d.ts.map +1 -0
- package/dist/host/runtime-session/service.js +177 -0
- package/dist/host/runtime-session/service.js.map +1 -0
- package/dist/host/runtime-session/status.d.ts +17 -0
- package/dist/host/runtime-session/status.d.ts.map +1 -0
- package/dist/host/runtime-session/status.js +33 -0
- package/dist/host/runtime-session/status.js.map +1 -0
- package/dist/host/runtime-session/types.d.ts +61 -0
- package/dist/host/runtime-session/types.d.ts.map +1 -0
- package/dist/host/runtime-session/types.js +2 -0
- package/dist/host/runtime-session/types.js.map +1 -0
- package/dist/http-sse/direct-http-execution-host.d.ts.map +1 -1
- package/dist/http-sse/direct-http-execution-host.js +10 -177
- package/dist/http-sse/direct-http-execution-host.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/execution-host-event-stream.d.ts +18 -0
- package/dist/internal/execution-host-event-stream.d.ts.map +1 -0
- package/dist/internal/execution-host-event-stream.js +141 -0
- package/dist/internal/execution-host-event-stream.js.map +1 -0
- package/dist/internal/http-response.d.ts +4 -0
- package/dist/internal/http-response.d.ts.map +1 -0
- package/dist/internal/http-response.js +57 -0
- package/dist/internal/http-response.js.map +1 -0
- package/dist/node/http-service.d.ts +0 -2
- package/dist/node/http-service.d.ts.map +1 -1
- package/dist/node/http-service.js +1 -2
- package/dist/node/http-service.js.map +1 -1
- package/dist/node/index.d.ts +2 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +2 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +22 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-heartbeat-coordinator-client.js","sourceRoot":"","sources":["../../src/coordinator/hosted-heartbeat-coordinator-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,cAAc,EACd,YAAY,GACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,kCAAkC,EAClC,yCAAyC,EACzC,wCAAwC,
|
|
1
|
+
{"version":3,"file":"hosted-heartbeat-coordinator-client.js","sourceRoot":"","sources":["../../src/coordinator/hosted-heartbeat-coordinator-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,cAAc,EACd,YAAY,GACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,kCAAkC,EAClC,6CAA6C,EAC7C,0CAA0C,EAC1C,yCAAyC,EACzC,wCAAwC,EACxC,wCAAwC,GAKzC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iCAAiC,EAAE,MAAM,oBAAo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Q,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE;YAC/D,GAAG,IAAI;YACP,OAAO;YACP,QAAQ,EAAE,OAAO;SAClB,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,sCAAsC,CAC9C,IAAI,CAAC,MAAM,IAAI,KAAK,EACpB,IAAI,EACJ,QAAQ,CAAC,MAAM,CAChB,CAAC;QACJ,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF","sourcesContent":["import { z } from 'zod';\nimport {\n OpaqueIdSchema,\n isSafeWebUrl,\n} from '../contracts/index.js';\nimport {\n HOSTED_HEARTBEAT_COORDINATOR_PATHS,\n HostedHeartbeatCoordinatorStateResponseSchema,\n HostedHeartbeatCoordinatorTaskDetailSchema,\n HostedHeartbeatCoordinatorTaskInputSchema,\n HostedHeartbeatCoordinatorTaskListSchema,\n HostedHeartbeatCoordinatorTaskViewSchema,\n type HostedHeartbeatCoordinatorTaskInput,\n type HostedHeartbeatCoordinatorState,\n type HostedHeartbeatCoordinatorTaskDetail,\n type HostedHeartbeatCoordinatorTaskView,\n} from './contracts.js';\nimport { HostedHeartbeatServiceTokenSchema } from './service-token.js';\nimport type {\n HostedHeartbeatCoordinatorClientConfig,\n HostedHeartbeatCoordinatorTaskApi,\n} from './types.js';\n\nconst SafeBaseUrlSchema = z.custom<URL>(\n (value) => value instanceof URL && isSafeWebUrl(value),\n 'baseUrl must be a safe HTTPS or loopback HTTP URL',\n);\n\nexport class HostedHeartbeatCoordinatorRequestError extends Error {\n readonly name = 'HostedHeartbeatCoordinatorRequestError';\n\n constructor(\n readonly method: string,\n readonly path: string,\n readonly status: number,\n ) {\n super(`Heddle Coordinator ${method} ${path} failed with status ${status}.`);\n }\n}\n\n/** Authenticated desired-task and admission client for a Heddle Coordinator. */\nexport class HostedHeartbeatCoordinatorClient\nimplements HostedHeartbeatCoordinatorTaskApi {\n readonly #baseUrl: URL;\n readonly #authorization: string;\n readonly #fetch: typeof globalThis.fetch;\n\n constructor(config: HostedHeartbeatCoordinatorClientConfig) {\n this.#baseUrl = new URL(SafeBaseUrlSchema.parse(config.baseUrl));\n this.#authorization = `Bearer ${\n HostedHeartbeatServiceTokenSchema.parse(config.apiToken)\n }`;\n this.#fetch = config.fetch ?? globalThis.fetch;\n }\n\n async readState(\n signal?: AbortSignal,\n ): Promise<HostedHeartbeatCoordinatorState> {\n const response = await this.#request(\n HOSTED_HEARTBEAT_COORDINATOR_PATHS.state,\n { method: 'GET', signal },\n );\n return HostedHeartbeatCoordinatorStateResponseSchema.parse(\n await response.json(),\n ).state;\n }\n\n async listTasks(\n signal?: AbortSignal,\n ): Promise<HostedHeartbeatCoordinatorTaskView[]> {\n const response = await this.#request(\n HOSTED_HEARTBEAT_COORDINATOR_PATHS.tasks,\n { method: 'GET', signal },\n );\n return HostedHeartbeatCoordinatorTaskListSchema.parse(\n await response.json(),\n ).tasks;\n }\n\n async readTask(\n rawTaskId: string,\n signal?: AbortSignal,\n ): Promise<HostedHeartbeatCoordinatorTaskDetail> {\n const response = await this.#request(\n this.#taskPath(OpaqueIdSchema.parse(rawTaskId)),\n { method: 'GET', signal },\n );\n return HostedHeartbeatCoordinatorTaskDetailSchema.parse(\n await response.json(),\n );\n }\n\n async upsertTask(\n rawTaskId: string,\n rawTask: HostedHeartbeatCoordinatorTaskInput,\n signal?: AbortSignal,\n ): Promise<void> {\n const taskId = OpaqueIdSchema.parse(rawTaskId);\n const task = HostedHeartbeatCoordinatorTaskInputSchema.parse(rawTask);\n await this.#request(this.#taskPath(taskId), {\n method: 'PUT',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(task),\n signal,\n });\n }\n\n async deleteTask(rawTaskId: string, signal?: AbortSignal): Promise<void> {\n await this.#request(this.#taskPath(OpaqueIdSchema.parse(rawTaskId)), {\n method: 'DELETE',\n signal,\n });\n }\n\n async triggerTask(\n rawTaskId: string,\n signal?: AbortSignal,\n ): Promise<HostedHeartbeatCoordinatorTaskView> {\n const taskId = OpaqueIdSchema.parse(rawTaskId);\n const path = `${this.#taskPath(taskId)}/trigger`;\n const response = await this.#request(path, { method: 'POST', signal });\n return HostedHeartbeatCoordinatorTaskViewSchema.parse(\n await response.json(),\n );\n }\n\n async pause(signal?: AbortSignal): Promise<void> {\n await this.#request(HOSTED_HEARTBEAT_COORDINATOR_PATHS.pause, {\n method: 'POST',\n signal,\n });\n }\n\n async resume(signal?: AbortSignal): Promise<void> {\n await this.#request(HOSTED_HEARTBEAT_COORDINATOR_PATHS.resume, {\n method: 'POST',\n signal,\n });\n }\n\n async drain(signal?: AbortSignal): Promise<void> {\n await this.#request(HOSTED_HEARTBEAT_COORDINATOR_PATHS.drain, {\n method: 'POST',\n signal,\n });\n }\n\n #taskPath(taskId: string): string {\n return `${HOSTED_HEARTBEAT_COORDINATOR_PATHS.tasks}/${\n encodeURIComponent(taskId)\n }`;\n }\n\n async #request(path: string, init: RequestInit): Promise<Response> {\n const headers = new Headers(init.headers);\n headers.set('authorization', this.#authorization);\n const response = await this.#fetch(new URL(path, this.#baseUrl), {\n ...init,\n headers,\n redirect: 'error',\n });\n if (!response.ok) {\n throw new HostedHeartbeatCoordinatorRequestError(\n init.method ?? 'GET',\n path,\n response.status,\n );\n }\n return response;\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { HOSTED_HEARTBEAT_COORDINATOR_PATHS, HOSTED_HEARTBEAT_DELEGATIONS_PATH, HostedHeartbeatCoordinatorTaskInputSchema, HostedHeartbeatCoordinatorTaskListSchema,
|
|
2
|
-
export type { HostedHeartbeatCoordinatorTaskInput,
|
|
1
|
+
export { HOSTED_HEARTBEAT_COORDINATOR_PATHS, HOSTED_HEARTBEAT_DELEGATIONS_PATH, HostedHeartbeatCoordinatorRunViewSchema, HostedHeartbeatCoordinatorStateResponseSchema, HostedHeartbeatCoordinatorStateSchema, HostedHeartbeatCoordinatorTaskDetailSchema, HostedHeartbeatCoordinatorTaskInputSchema, HostedHeartbeatCoordinatorTaskListSchema, HostedHeartbeatCoordinatorTaskResultSchema, HostedHeartbeatCoordinatorTaskStatusSchema, HostedHeartbeatCoordinatorTaskViewSchema, HostedHeartbeatDelegationAuthorizationSchema, HostedHeartbeatDelegationRequestSchema, HostedHeartbeatDelegationSchema, HostedHeartbeatDesiredTaskCatalogSchema, HostedHeartbeatDesiredTaskSchema, } from './contracts.js';
|
|
2
|
+
export type { HostedHeartbeatCoordinatorTaskInput, HostedHeartbeatCoordinatorRunView, HostedHeartbeatCoordinatorState, HostedHeartbeatCoordinatorTaskDetail, HostedHeartbeatCoordinatorTaskView, HostedHeartbeatDelegation, HostedHeartbeatDelegationAuthorization, HostedHeartbeatDelegationRequest, HostedHeartbeatDesiredTask, HostedHeartbeatDesiredTaskCatalog, } from './contracts.js';
|
|
3
3
|
export { HostedHeartbeatCoordinatorClient, HostedHeartbeatCoordinatorRequestError, } from './hosted-heartbeat-coordinator-client.js';
|
|
4
4
|
export { HostedHeartbeatDelegatedExecutionTransport, HostedHeartbeatDelegationClient, HostedHeartbeatDelegationRequestError, } from './hosted-heartbeat-delegation-client.js';
|
|
5
5
|
export { HostedHeartbeatDelegationRejectedError, HostedHeartbeatDelegationService, } from './hosted-heartbeat-delegation-service.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/coordinator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kCAAkC,EAClC,iCAAiC,EACjC,yCAAyC,EACzC,wCAAwC,EACxC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/coordinator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kCAAkC,EAClC,iCAAiC,EACjC,uCAAuC,EACvC,6CAA6C,EAC7C,qCAAqC,EACrC,0CAA0C,EAC1C,yCAAyC,EACzC,wCAAwC,EACxC,0CAA0C,EAC1C,0CAA0C,EAC1C,wCAAwC,EACxC,4CAA4C,EAC5C,sCAAsC,EACtC,+BAA+B,EAC/B,uCAAuC,EACvC,gCAAgC,GACjC,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,mCAAmC,EACnC,iCAAiC,EACjC,+BAA+B,EAC/B,oCAAoC,EACpC,kCAAkC,EAClC,yBAAyB,EACzB,sCAAsC,EACtC,gCAAgC,EAChC,0BAA0B,EAC1B,iCAAiC,GAClC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,gCAAgC,EAChC,sCAAsC,GACvC,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACL,0CAA0C,EAC1C,+BAA+B,EAC/B,qCAAqC,GACtC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,sCAAsC,EACtC,gCAAgC,GACjC,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,YAAY,EACV,sCAAsC,EACtC,iCAAiC,EACjC,gDAAgD,EAChD,8CAA8C,EAC9C,2CAA2C,EAC3C,mCAAmC,EACnC,qCAAqC,EACrC,+BAA+B,EAC/B,sCAAsC,EACtC,mCAAmC,EACnC,iCAAiC,EACjC,sCAAsC,GACvC,MAAM,YAAY,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { HOSTED_HEARTBEAT_COORDINATOR_PATHS, HOSTED_HEARTBEAT_DELEGATIONS_PATH, HostedHeartbeatCoordinatorTaskInputSchema, HostedHeartbeatCoordinatorTaskListSchema,
|
|
1
|
+
export { HOSTED_HEARTBEAT_COORDINATOR_PATHS, HOSTED_HEARTBEAT_DELEGATIONS_PATH, HostedHeartbeatCoordinatorRunViewSchema, HostedHeartbeatCoordinatorStateResponseSchema, HostedHeartbeatCoordinatorStateSchema, HostedHeartbeatCoordinatorTaskDetailSchema, HostedHeartbeatCoordinatorTaskInputSchema, HostedHeartbeatCoordinatorTaskListSchema, HostedHeartbeatCoordinatorTaskResultSchema, HostedHeartbeatCoordinatorTaskStatusSchema, HostedHeartbeatCoordinatorTaskViewSchema, HostedHeartbeatDelegationAuthorizationSchema, HostedHeartbeatDelegationRequestSchema, HostedHeartbeatDelegationSchema, HostedHeartbeatDesiredTaskCatalogSchema, HostedHeartbeatDesiredTaskSchema, } from './contracts.js';
|
|
2
2
|
export { HostedHeartbeatCoordinatorClient, HostedHeartbeatCoordinatorRequestError, } from './hosted-heartbeat-coordinator-client.js';
|
|
3
3
|
export { HostedHeartbeatDelegatedExecutionTransport, HostedHeartbeatDelegationClient, HostedHeartbeatDelegationRequestError, } from './hosted-heartbeat-delegation-client.js';
|
|
4
4
|
export { HostedHeartbeatDelegationRejectedError, HostedHeartbeatDelegationService, } from './hosted-heartbeat-delegation-service.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/coordinator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kCAAkC,EAClC,iCAAiC,EACjC,yCAAyC,EACzC,wCAAwC,EACxC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/coordinator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kCAAkC,EAClC,iCAAiC,EACjC,uCAAuC,EACvC,6CAA6C,EAC7C,qCAAqC,EACrC,0CAA0C,EAC1C,yCAAyC,EACzC,wCAAwC,EACxC,0CAA0C,EAC1C,0CAA0C,EAC1C,wCAAwC,EACxC,4CAA4C,EAC5C,sCAAsC,EACtC,+BAA+B,EAC/B,uCAAuC,EACvC,gCAAgC,GACjC,MAAM,gBAAgB,CAAC;AAaxB,OAAO,EACL,gCAAgC,EAChC,sCAAsC,GACvC,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACL,0CAA0C,EAC1C,+BAA+B,EAC/B,qCAAqC,GACtC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACL,sCAAsC,EACtC,gCAAgC,GACjC,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["export {\n HOSTED_HEARTBEAT_COORDINATOR_PATHS,\n HOSTED_HEARTBEAT_DELEGATIONS_PATH,\n HostedHeartbeatCoordinatorRunViewSchema,\n HostedHeartbeatCoordinatorStateResponseSchema,\n HostedHeartbeatCoordinatorStateSchema,\n HostedHeartbeatCoordinatorTaskDetailSchema,\n HostedHeartbeatCoordinatorTaskInputSchema,\n HostedHeartbeatCoordinatorTaskListSchema,\n HostedHeartbeatCoordinatorTaskResultSchema,\n HostedHeartbeatCoordinatorTaskStatusSchema,\n HostedHeartbeatCoordinatorTaskViewSchema,\n HostedHeartbeatDelegationAuthorizationSchema,\n HostedHeartbeatDelegationRequestSchema,\n HostedHeartbeatDelegationSchema,\n HostedHeartbeatDesiredTaskCatalogSchema,\n HostedHeartbeatDesiredTaskSchema,\n} from './contracts.js';\nexport type {\n HostedHeartbeatCoordinatorTaskInput,\n HostedHeartbeatCoordinatorRunView,\n HostedHeartbeatCoordinatorState,\n HostedHeartbeatCoordinatorTaskDetail,\n HostedHeartbeatCoordinatorTaskView,\n HostedHeartbeatDelegation,\n HostedHeartbeatDelegationAuthorization,\n HostedHeartbeatDelegationRequest,\n HostedHeartbeatDesiredTask,\n HostedHeartbeatDesiredTaskCatalog,\n} from './contracts.js';\nexport {\n HostedHeartbeatCoordinatorClient,\n HostedHeartbeatCoordinatorRequestError,\n} from './hosted-heartbeat-coordinator-client.js';\nexport {\n HostedHeartbeatDelegatedExecutionTransport,\n HostedHeartbeatDelegationClient,\n HostedHeartbeatDelegationRequestError,\n} from './hosted-heartbeat-delegation-client.js';\nexport {\n HostedHeartbeatDelegationRejectedError,\n HostedHeartbeatDelegationService,\n} from './hosted-heartbeat-delegation-service.js';\nexport { HostedHeartbeatTaskReconciler } from './hosted-heartbeat-task-reconciler.js';\nexport { createHostedRuntimeSessionId } from './runtime-session.js';\nexport type {\n HostedHeartbeatCoordinatorClientConfig,\n HostedHeartbeatCoordinatorTaskApi,\n HostedHeartbeatDelegatedExecutionTransportConfig,\n HostedHeartbeatDelegatedExecutionTransportPort,\n HostedHeartbeatDelegationAuthorizationInput,\n HostedHeartbeatDelegationAuthorizer,\n HostedHeartbeatDelegationClientConfig,\n HostedHeartbeatDelegationIssuer,\n HostedHeartbeatDelegationServiceConfig,\n HostedHeartbeatTaskReconcilerConfig,\n HostedHeartbeatTaskReconciliation,\n HostedHeartbeatTaskReconciliationInput,\n} from './types.js';\n"]}
|
|
@@ -2,18 +2,22 @@ import type { ExecutionAuthorityIssuer } from '../authority/index.js';
|
|
|
2
2
|
import type { HostedModelCredentialProvider } from '../conversation/index.js';
|
|
3
3
|
import type { HostedHeartbeatAgentExecutionTransportInput } from '../heartbeat/index.js';
|
|
4
4
|
import type { HeartbeatExecutionHost } from '../http-sse/index.js';
|
|
5
|
-
import type { HostedHeartbeatCoordinatorTaskInput,
|
|
5
|
+
import type { HostedHeartbeatCoordinatorTaskInput, HostedHeartbeatCoordinatorState, HostedHeartbeatCoordinatorTaskDetail, HostedHeartbeatCoordinatorTaskView, HostedHeartbeatDelegation, HostedHeartbeatDelegationAuthorization, HostedHeartbeatDelegationRequest, HostedHeartbeatDesiredTask } from './contracts.js';
|
|
6
6
|
export type HostedHeartbeatCoordinatorClientConfig = {
|
|
7
7
|
baseUrl: URL;
|
|
8
8
|
apiToken: string;
|
|
9
9
|
fetch?: typeof globalThis.fetch;
|
|
10
10
|
};
|
|
11
11
|
export interface HostedHeartbeatCoordinatorTaskApi {
|
|
12
|
-
|
|
12
|
+
readState(signal?: AbortSignal): Promise<HostedHeartbeatCoordinatorState>;
|
|
13
|
+
listTasks(signal?: AbortSignal): Promise<HostedHeartbeatCoordinatorTaskView[]>;
|
|
14
|
+
readTask(taskId: string, signal?: AbortSignal): Promise<HostedHeartbeatCoordinatorTaskDetail>;
|
|
13
15
|
upsertTask(taskId: string, task: HostedHeartbeatCoordinatorTaskInput, signal?: AbortSignal): Promise<void>;
|
|
16
|
+
triggerTask(taskId: string, signal?: AbortSignal): Promise<HostedHeartbeatCoordinatorTaskView>;
|
|
14
17
|
deleteTask(taskId: string, signal?: AbortSignal): Promise<void>;
|
|
15
18
|
pause(signal?: AbortSignal): Promise<void>;
|
|
16
19
|
resume(signal?: AbortSignal): Promise<void>;
|
|
20
|
+
drain(signal?: AbortSignal): Promise<void>;
|
|
17
21
|
}
|
|
18
22
|
export type HostedHeartbeatTaskReconciliationInput = {
|
|
19
23
|
desiredTasks: readonly HostedHeartbeatDesiredTask[];
|
|
@@ -26,7 +30,7 @@ export type HostedHeartbeatTaskReconciliation = {
|
|
|
26
30
|
resumed: boolean;
|
|
27
31
|
};
|
|
28
32
|
export type HostedHeartbeatTaskReconcilerConfig = {
|
|
29
|
-
coordinator: HostedHeartbeatCoordinatorTaskApi
|
|
33
|
+
coordinator: Pick<HostedHeartbeatCoordinatorTaskApi, 'listTasks' | 'upsertTask' | 'deleteTask' | 'pause' | 'resume'>;
|
|
30
34
|
};
|
|
31
35
|
export type HostedHeartbeatDelegationAuthorizationInput = {
|
|
32
36
|
taskId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/coordinator/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,6BAA6B,EAC9B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,2CAA2C,EAC5C,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EACV,mCAAmC,EACnC,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../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ACvC,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,yBAAyB,CAAC,CAAC;CACvC;AAED,MAAM,MAAM,qCAAqC,GAAG;IAClD,OAAO,EAAE,GAAG,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,gDAAgD,GAAG;IAC7D,WAAW,EAAE,+BAA+B,CAAC;IAC7C,aAAa,EAAE,sBAAsB,CAAC;IACtC,gBAAgB,EAAE,6BAA6B,CAAC;CACjD,CAAC;AAEF,MAAM,WAAW,8CAA8C;IAC7D,OAAO,CACL,KAAK,EAAE,2CAA2C,GACjD,OAAO,CAAC,OAAO,CAAC,CAAC;CACrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/coordinator/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ExecutionAuthorityIssuer,\n} from '../authority/index.js';\nimport type {\n HostedModelCredentialProvider,\n} from '../conversation/index.js';\nimport type {\n HostedHeartbeatAgentExecutionTransportInput,\n} from '../heartbeat/index.js';\nimport type { HeartbeatExecutionHost } from '../http-sse/index.js';\nimport type {\n HostedHeartbeatCoordinatorTaskInput,\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/coordinator/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ExecutionAuthorityIssuer,\n} from '../authority/index.js';\nimport type {\n HostedModelCredentialProvider,\n} from '../conversation/index.js';\nimport type {\n HostedHeartbeatAgentExecutionTransportInput,\n} from '../heartbeat/index.js';\nimport type { HeartbeatExecutionHost } from '../http-sse/index.js';\nimport type {\n HostedHeartbeatCoordinatorTaskInput,\n HostedHeartbeatCoordinatorState,\n HostedHeartbeatCoordinatorTaskDetail,\n HostedHeartbeatCoordinatorTaskView,\n HostedHeartbeatDelegation,\n HostedHeartbeatDelegationAuthorization,\n HostedHeartbeatDelegationRequest,\n HostedHeartbeatDesiredTask,\n} from './contracts.js';\n\nexport type HostedHeartbeatCoordinatorClientConfig = {\n baseUrl: URL;\n apiToken: string;\n fetch?: typeof globalThis.fetch;\n};\n\nexport interface HostedHeartbeatCoordinatorTaskApi {\n readState(signal?: AbortSignal): Promise<HostedHeartbeatCoordinatorState>;\n listTasks(\n signal?: AbortSignal,\n ): Promise<HostedHeartbeatCoordinatorTaskView[]>;\n readTask(\n taskId: string,\n signal?: AbortSignal,\n ): Promise<HostedHeartbeatCoordinatorTaskDetail>;\n upsertTask(\n taskId: string,\n task: HostedHeartbeatCoordinatorTaskInput,\n signal?: AbortSignal,\n ): Promise<void>;\n triggerTask(\n taskId: string,\n signal?: AbortSignal,\n ): Promise<HostedHeartbeatCoordinatorTaskView>;\n deleteTask(taskId: string, signal?: AbortSignal): Promise<void>;\n pause(signal?: AbortSignal): Promise<void>;\n resume(signal?: AbortSignal): Promise<void>;\n drain(signal?: AbortSignal): Promise<void>;\n}\n\nexport type HostedHeartbeatTaskReconciliationInput = {\n desiredTasks: readonly HostedHeartbeatDesiredTask[];\n resume: boolean;\n signal?: AbortSignal;\n};\n\nexport type HostedHeartbeatTaskReconciliation = {\n deleted: number;\n upserted: number;\n resumed: boolean;\n};\n\nexport type HostedHeartbeatTaskReconcilerConfig = {\n coordinator: Pick<\n HostedHeartbeatCoordinatorTaskApi,\n 'listTasks' | 'upsertTask' | 'deleteTask' | 'pause' | 'resume'\n >;\n};\n\nexport type HostedHeartbeatDelegationAuthorizationInput = {\n taskId: string;\n executionId: string;\n signal: AbortSignal;\n};\n\nexport interface HostedHeartbeatDelegationAuthorizer {\n authorize(\n input: HostedHeartbeatDelegationAuthorizationInput,\n ): HostedHeartbeatDelegationAuthorization\n | undefined\n | Promise<HostedHeartbeatDelegationAuthorization | undefined>;\n}\n\nexport type HostedHeartbeatDelegationServiceConfig = {\n authority: ExecutionAuthorityIssuer;\n authorizer: HostedHeartbeatDelegationAuthorizer;\n runtimeSessionNamespace: string;\n maxExecutionMs: number;\n now?: () => Date;\n};\n\nexport interface HostedHeartbeatDelegationIssuer {\n issue(\n input: HostedHeartbeatDelegationRequest,\n signal?: AbortSignal,\n ): Promise<HostedHeartbeatDelegation>;\n}\n\nexport type HostedHeartbeatDelegationClientConfig = {\n baseUrl: URL;\n apiToken: string;\n fetch?: typeof globalThis.fetch;\n path?: string;\n};\n\nexport type HostedHeartbeatDelegatedExecutionTransportConfig = {\n delegations: HostedHeartbeatDelegationIssuer;\n executionHost: HeartbeatExecutionHost;\n modelCredentials: HostedModelCredentialProvider;\n};\n\nexport interface HostedHeartbeatDelegatedExecutionTransportPort {\n execute(\n input: HostedHeartbeatAgentExecutionTransportInput,\n ): Promise<unknown>;\n}\n"]}
|
package/dist/host/index.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ export { JwtExecutionHostMcpCapabilityVerifier } from './jwt-execution-host-mcp-
|
|
|
4
4
|
export { ExecutionHostJwtAlgorithmsSchema, JwtExecutionHostMcpCapabilityVerifierConfigSchema, JwtExecutionIdentityVerifierConfigSchema, } from './schemas.js';
|
|
5
5
|
export { EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS, } from './types.js';
|
|
6
6
|
export type { ExecutionHostJwtAlgorithm, ExecutionHostJwtVerifierOptions, ExecutionHostMcpCapabilityVerificationRequest, ExecutionHostMcpCapabilityVerifier, ExecutionIdentityVerificationRequest, ExecutionIdentityVerifier, JwtExecutionHostMcpCapabilityVerifierConfig, JwtExecutionIdentityVerifierConfig, VerifiedExecutionHostMcpCapability, VerifiedExecutionIdentity, } from './types.js';
|
|
7
|
+
export * from './runtime-session/index.js';
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/host/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0CAA0C,EAC1C,2CAA2C,EAC3C,iCAAiC,EACjC,kCAAkC,EAClC,yCAAyC,GAC1C,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,qCAAqC,EAAE,MAAM,iDAAiD,CAAC;AACxG,OAAO,EACL,gCAAgC,EAChC,iDAAiD,EACjD,wCAAwC,GACzC,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,uCAAuC,GACxC,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,yBAAyB,EACzB,+BAA+B,EAC/B,6CAA6C,EAC7C,kCAAkC,EAClC,oCAAoC,EACpC,yBAAyB,EACzB,2CAA2C,EAC3C,kCAAkC,EAClC,kCAAkC,EAClC,yBAAyB,GAC1B,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0CAA0C,EAC1C,2CAA2C,EAC3C,iCAAiC,EACjC,kCAAkC,EAClC,yCAAyC,GAC1C,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,qCAAqC,EAAE,MAAM,iDAAiD,CAAC;AACxG,OAAO,EACL,gCAAgC,EAChC,iDAAiD,EACjD,wCAAwC,GACzC,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,uCAAuC,GACxC,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,yBAAyB,EACzB,+BAA+B,EAC/B,6CAA6C,EAC7C,kCAAkC,EAClC,oCAAoC,EACpC,yBAAyB,EACzB,2CAA2C,EAC3C,kCAAkC,EAClC,kCAAkC,EAClC,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AACpB,cAAc,4BAA4B,CAAC"}
|
package/dist/host/index.js
CHANGED
|
@@ -3,4 +3,5 @@ export { JwtExecutionIdentityVerifier } from './jwt-execution-identity-verifier.
|
|
|
3
3
|
export { JwtExecutionHostMcpCapabilityVerifier } from './jwt-execution-host-mcp-capability-verifier.js';
|
|
4
4
|
export { ExecutionHostJwtAlgorithmsSchema, JwtExecutionHostMcpCapabilityVerifierConfigSchema, JwtExecutionIdentityVerifierConfigSchema, } from './schemas.js';
|
|
5
5
|
export { EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS, } from './types.js';
|
|
6
|
+
export * from './runtime-session/index.js';
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
package/dist/host/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0CAA0C,EAC1C,2CAA2C,EAC3C,iCAAiC,EACjC,kCAAkC,EAClC,yCAAyC,GAC1C,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,qCAAqC,EAAE,MAAM,iDAAiD,CAAC;AACxG,OAAO,EACL,gCAAgC,EAChC,iDAAiD,EACjD,wCAAwC,GACzC,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,uCAAuC,GACxC,MAAM,YAAY,CAAC","sourcesContent":["export {\n ExecutionHostMcpCapabilityUnavailableError,\n ExecutionHostMcpCapabilityVerificationError,\n ExecutionIdentityUnavailableError,\n ExecutionIdentityVerificationError,\n UnexpectedExecutionHostMcpCapabilityError,\n} from './errors.js';\nexport { JwtExecutionIdentityVerifier } from './jwt-execution-identity-verifier.js';\nexport { JwtExecutionHostMcpCapabilityVerifier } from './jwt-execution-host-mcp-capability-verifier.js';\nexport {\n ExecutionHostJwtAlgorithmsSchema,\n JwtExecutionHostMcpCapabilityVerifierConfigSchema,\n JwtExecutionIdentityVerifierConfigSchema,\n} from './schemas.js';\nexport {\n EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS,\n} from './types.js';\nexport type {\n ExecutionHostJwtAlgorithm,\n ExecutionHostJwtVerifierOptions,\n ExecutionHostMcpCapabilityVerificationRequest,\n ExecutionHostMcpCapabilityVerifier,\n ExecutionIdentityVerificationRequest,\n ExecutionIdentityVerifier,\n JwtExecutionHostMcpCapabilityVerifierConfig,\n JwtExecutionIdentityVerifierConfig,\n VerifiedExecutionHostMcpCapability,\n VerifiedExecutionIdentity,\n} from './types.js';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0CAA0C,EAC1C,2CAA2C,EAC3C,iCAAiC,EACjC,kCAAkC,EAClC,yCAAyC,GAC1C,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,qCAAqC,EAAE,MAAM,iDAAiD,CAAC;AACxG,OAAO,EACL,gCAAgC,EAChC,iDAAiD,EACjD,wCAAwC,GACzC,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,uCAAuC,GACxC,MAAM,YAAY,CAAC;AAapB,cAAc,4BAA4B,CAAC","sourcesContent":["export {\n ExecutionHostMcpCapabilityUnavailableError,\n ExecutionHostMcpCapabilityVerificationError,\n ExecutionIdentityUnavailableError,\n ExecutionIdentityVerificationError,\n UnexpectedExecutionHostMcpCapabilityError,\n} from './errors.js';\nexport { JwtExecutionIdentityVerifier } from './jwt-execution-identity-verifier.js';\nexport { JwtExecutionHostMcpCapabilityVerifier } from './jwt-execution-host-mcp-capability-verifier.js';\nexport {\n ExecutionHostJwtAlgorithmsSchema,\n JwtExecutionHostMcpCapabilityVerifierConfigSchema,\n JwtExecutionIdentityVerifierConfigSchema,\n} from './schemas.js';\nexport {\n EXECUTION_HOST_SUPPORTED_JWT_ALGORITHMS,\n} from './types.js';\nexport type {\n ExecutionHostJwtAlgorithm,\n ExecutionHostJwtVerifierOptions,\n ExecutionHostMcpCapabilityVerificationRequest,\n ExecutionHostMcpCapabilityVerifier,\n ExecutionIdentityVerificationRequest,\n ExecutionIdentityVerifier,\n JwtExecutionHostMcpCapabilityVerifierConfig,\n JwtExecutionIdentityVerifierConfig,\n VerifiedExecutionHostMcpCapability,\n VerifiedExecutionIdentity,\n} from './types.js';\nexport * from './runtime-session/index.js';\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare class RuntimeExecutionPreparationError extends Error {
|
|
2
|
+
readonly category: RuntimeExecutionPreparationCategory;
|
|
3
|
+
readonly name = "RuntimeExecutionPreparationError";
|
|
4
|
+
constructor(category: RuntimeExecutionPreparationCategory, options?: {
|
|
5
|
+
cause?: unknown;
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
export type RuntimeExecutionPreparationCategory = 'authority' | 'configuration' | 'contract' | 'dependency';
|
|
9
|
+
export declare class RuntimeBusyError extends Error {
|
|
10
|
+
readonly name = "RuntimeBusyError";
|
|
11
|
+
}
|
|
12
|
+
export declare class RuntimeDuplicateInvocationError extends Error {
|
|
13
|
+
readonly name = "RuntimeDuplicateInvocationError";
|
|
14
|
+
}
|
|
15
|
+
export declare class RuntimeDeadlineError extends Error {
|
|
16
|
+
readonly name = "RuntimeDeadlineError";
|
|
17
|
+
}
|
|
18
|
+
export declare class RuntimeScopeMismatchError extends Error {
|
|
19
|
+
readonly name = "RuntimeScopeMismatchError";
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/host/runtime-session/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,gCAAiC,SAAQ,KAAK;IAIvD,QAAQ,CAAC,QAAQ,EAAE,mCAAmC;IAHxD,QAAQ,CAAC,IAAI,sCAAsC;gBAGxC,QAAQ,EAAE,mCAAmC,EACtD,OAAO,GAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO;CAIpC;AAED,MAAM,MAAM,mCAAmC,GAC3C,WAAW,GACX,eAAe,GACf,UAAU,GACV,YAAY,CAAC;AAEjB,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,IAAI,sBAAsB;CACpC;AAED,qBAAa,+BAAgC,SAAQ,KAAK;IACxD,QAAQ,CAAC,IAAI,qCAAqC;CACnD;AAED,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,IAAI,0BAA0B;CACxC;AAED,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,QAAQ,CAAC,IAAI,+BAA+B;CAC7C"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export class RuntimeExecutionPreparationError extends Error {
|
|
2
|
+
category;
|
|
3
|
+
name = 'RuntimeExecutionPreparationError';
|
|
4
|
+
constructor(category, options = {}) {
|
|
5
|
+
super('The agent execution dependency could not be prepared.', options);
|
|
6
|
+
this.category = category;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export class RuntimeBusyError extends Error {
|
|
10
|
+
name = 'RuntimeBusyError';
|
|
11
|
+
}
|
|
12
|
+
export class RuntimeDuplicateInvocationError extends Error {
|
|
13
|
+
name = 'RuntimeDuplicateInvocationError';
|
|
14
|
+
}
|
|
15
|
+
export class RuntimeDeadlineError extends Error {
|
|
16
|
+
name = 'RuntimeDeadlineError';
|
|
17
|
+
}
|
|
18
|
+
export class RuntimeScopeMismatchError extends Error {
|
|
19
|
+
name = 'RuntimeScopeMismatchError';
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/host/runtime-session/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,gCAAiC,SAAQ,KAAK;IAI9C;IAHF,IAAI,GAAG,kCAAkC,CAAC;IAEnD,YACW,QAA6C,EACtD,UAA+B,EAAE;QAEjC,KAAK,CAAC,uDAAuD,EAAE,OAAO,CAAC,CAAC;QAH/D,aAAQ,GAAR,QAAQ,CAAqC;IAIxD,CAAC;CACF;AAQD,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAChC,IAAI,GAAG,kBAAkB,CAAC;CACpC;AAED,MAAM,OAAO,+BAAgC,SAAQ,KAAK;IAC/C,IAAI,GAAG,iCAAiC,CAAC;CACnD;AAED,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACpC,IAAI,GAAG,sBAAsB,CAAC;CACxC;AAED,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IACzC,IAAI,GAAG,2BAA2B,CAAC;CAC7C","sourcesContent":["export class RuntimeExecutionPreparationError extends Error {\n readonly name = 'RuntimeExecutionPreparationError';\n\n constructor(\n readonly category: RuntimeExecutionPreparationCategory,\n options: { cause?: unknown } = {},\n ) {\n super('The agent execution dependency could not be prepared.', options);\n }\n}\n\nexport type RuntimeExecutionPreparationCategory =\n | 'authority'\n | 'configuration'\n | 'contract'\n | 'dependency';\n\nexport class RuntimeBusyError extends Error {\n readonly name = 'RuntimeBusyError';\n}\n\nexport class RuntimeDuplicateInvocationError extends Error {\n readonly name = 'RuntimeDuplicateInvocationError';\n}\n\nexport class RuntimeDeadlineError extends Error {\n readonly name = 'RuntimeDeadlineError';\n}\n\nexport class RuntimeScopeMismatchError extends Error {\n readonly name = 'RuntimeScopeMismatchError';\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { RuntimeBusyError, RuntimeDeadlineError, RuntimeDuplicateInvocationError, RuntimeExecutionPreparationError, RuntimeScopeMismatchError, } from './errors.js';
|
|
2
|
+
export type { RuntimeExecutionPreparationCategory, } from './errors.js';
|
|
3
|
+
export { RuntimeScopeBindingService, } from './scope-binding.js';
|
|
4
|
+
export type { BoundRuntimeScope, RuntimeScopeBinding, } from './scope-binding.js';
|
|
5
|
+
export { RuntimeSessionService } from './service.js';
|
|
6
|
+
export { RuntimeSessionStatusService } from './status.js';
|
|
7
|
+
export type { RuntimeSessionStatusSnapshot } from './status.js';
|
|
8
|
+
export type { RuntimeExecutionHandle, RuntimeExecutionInput, RuntimeExecutionStreamItem, RuntimeInvocationHandle, RuntimeInvocationRequest, RuntimeSessionConfig, RuntimeWorkflowExecutor, RuntimeWorkflowExecutors, } from './types.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/host/runtime-session/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,+BAA+B,EAC/B,gCAAgC,EAChC,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,mCAAmC,GACpC,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,0BAA0B,GAC3B,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC1D,YAAY,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAChE,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,0BAA0B,EAC1B,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { RuntimeBusyError, RuntimeDeadlineError, RuntimeDuplicateInvocationError, RuntimeExecutionPreparationError, RuntimeScopeMismatchError, } from './errors.js';
|
|
2
|
+
export { RuntimeScopeBindingService, } from './scope-binding.js';
|
|
3
|
+
export { RuntimeSessionService } from './service.js';
|
|
4
|
+
export { RuntimeSessionStatusService } from './status.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/host/runtime-session/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,+BAA+B,EAC/B,gCAAgC,EAChC,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AAIrB,OAAO,EACL,0BAA0B,GAC3B,MAAM,oBAAoB,CAAC;AAK5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export {\n RuntimeBusyError,\n RuntimeDeadlineError,\n RuntimeDuplicateInvocationError,\n RuntimeExecutionPreparationError,\n RuntimeScopeMismatchError,\n} from './errors.js';\nexport type {\n RuntimeExecutionPreparationCategory,\n} from './errors.js';\nexport {\n RuntimeScopeBindingService,\n} from './scope-binding.js';\nexport type {\n BoundRuntimeScope,\n RuntimeScopeBinding,\n} from './scope-binding.js';\nexport { RuntimeSessionService } from './service.js';\nexport { RuntimeSessionStatusService } from './status.js';\nexport type { RuntimeSessionStatusSnapshot } from './status.js';\nexport type {\n RuntimeExecutionHandle,\n RuntimeExecutionInput,\n RuntimeExecutionStreamItem,\n RuntimeInvocationHandle,\n RuntimeInvocationRequest,\n RuntimeSessionConfig,\n RuntimeWorkflowExecutor,\n RuntimeWorkflowExecutors,\n} from './types.js';\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ExecutionScope } from '../../contracts/index.js';
|
|
2
|
+
export type RuntimeScopeBinding = ExecutionScope & {
|
|
3
|
+
runtimeSessionId: string;
|
|
4
|
+
};
|
|
5
|
+
export type BoundRuntimeScope = {
|
|
6
|
+
binding: RuntimeScopeBinding;
|
|
7
|
+
scopeKey: string;
|
|
8
|
+
executionSessionId: string;
|
|
9
|
+
};
|
|
10
|
+
/** Defense in depth if a host process is reused across execution scopes. */
|
|
11
|
+
export declare class RuntimeScopeBindingService {
|
|
12
|
+
private bound?;
|
|
13
|
+
bind(input: RuntimeScopeBinding): BoundRuntimeScope;
|
|
14
|
+
current(): BoundRuntimeScope | undefined;
|
|
15
|
+
private static toBoundScope;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=scope-binding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope-binding.d.ts","sourceRoot":"","sources":["../../../src/host/runtime-session/scope-binding.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG/D,MAAM,MAAM,mBAAmB,GAAG,cAAc,GAAG;IACjD,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,mBAAmB,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,4EAA4E;AAC5E,qBAAa,0BAA0B;IACrC,OAAO,CAAC,KAAK,CAAC,CAAoB;IAElC,IAAI,CAAC,KAAK,EAAE,mBAAmB,GAAG,iBAAiB;IAgBnD,OAAO,IAAI,iBAAiB,GAAG,SAAS;IAIxC,OAAO,CAAC,MAAM,CAAC,YAAY;CAiB5B"}
|
|
@@ -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.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AAa,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;QACD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,IAAI,0BAA0B,EAAE,CAAC;QACnE,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,GA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AAC;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
|