@heddleagent/execution-host-client 6.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +305 -0
- package/dist/authority/index.d.ts +3 -0
- package/dist/authority/index.d.ts.map +1 -0
- package/dist/authority/index.js +2 -0
- package/dist/authority/index.js.map +1 -0
- package/dist/authority/jose-execution-authority.d.ts +14 -0
- package/dist/authority/jose-execution-authority.d.ts.map +1 -0
- package/dist/authority/jose-execution-authority.js +266 -0
- package/dist/authority/jose-execution-authority.js.map +1 -0
- package/dist/authority/types.d.ts +63 -0
- package/dist/authority/types.d.ts.map +1 -0
- package/dist/authority/types.js +2 -0
- package/dist/authority/types.js.map +1 -0
- package/dist/contracts/index.d.ts +163 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +149 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/conversation/durable-hosted-conversation-turn-service.d.ts +23 -0
- package/dist/conversation/durable-hosted-conversation-turn-service.d.ts.map +1 -0
- package/dist/conversation/durable-hosted-conversation-turn-service.js +273 -0
- package/dist/conversation/durable-hosted-conversation-turn-service.js.map +1 -0
- package/dist/conversation/hosted-conversation-turn-service.d.ts +17 -0
- package/dist/conversation/hosted-conversation-turn-service.d.ts.map +1 -0
- package/dist/conversation/hosted-conversation-turn-service.js +60 -0
- package/dist/conversation/hosted-conversation-turn-service.js.map +1 -0
- package/dist/conversation/index.d.ts +7 -0
- package/dist/conversation/index.d.ts.map +1 -0
- package/dist/conversation/index.js +5 -0
- package/dist/conversation/index.js.map +1 -0
- package/dist/conversation/lifecycle-types.d.ts +208 -0
- package/dist/conversation/lifecycle-types.d.ts.map +1 -0
- package/dist/conversation/lifecycle-types.js +92 -0
- package/dist/conversation/lifecycle-types.js.map +1 -0
- package/dist/conversation/types.d.ts +35 -0
- package/dist/conversation/types.d.ts.map +1 -0
- package/dist/conversation/types.js +11 -0
- package/dist/conversation/types.js.map +1 -0
- package/dist/http-sse/direct-http-execution-host.d.ts +12 -0
- package/dist/http-sse/direct-http-execution-host.d.ts.map +1 -0
- package/dist/http-sse/direct-http-execution-host.js +279 -0
- package/dist/http-sse/direct-http-execution-host.js.map +1 -0
- package/dist/http-sse/errors.d.ts +19 -0
- package/dist/http-sse/errors.d.ts.map +1 -0
- package/dist/http-sse/errors.js +29 -0
- package/dist/http-sse/errors.js.map +1 -0
- package/dist/http-sse/index.d.ts +4 -0
- package/dist/http-sse/index.d.ts.map +1 -0
- package/dist/http-sse/index.js +3 -0
- package/dist/http-sse/index.js.map +1 -0
- package/dist/http-sse/types.d.ts +20 -0
- package/dist/http-sse/types.d.ts.map +1 -0
- package/dist/http-sse/types.js +2 -0
- package/dist/http-sse/types.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/errors.d.ts +11 -0
- package/dist/mcp/errors.d.ts.map +1 -0
- package/dist/mcp/errors.js +15 -0
- package/dist/mcp/errors.js.map +1 -0
- package/dist/mcp/index.d.ts +5 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +3 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/jwt-capability-verifier.d.ts +12 -0
- package/dist/mcp/jwt-capability-verifier.d.ts.map +1 -0
- package/dist/mcp/jwt-capability-verifier.js +136 -0
- package/dist/mcp/jwt-capability-verifier.js.map +1 -0
- package/dist/mcp/node/index.d.ts +4 -0
- package/dist/mcp/node/index.d.ts.map +1 -0
- package/dist/mcp/node/index.js +3 -0
- package/dist/mcp/node/index.js.map +1 -0
- package/dist/mcp/node/json-toolset.d.ts +23 -0
- package/dist/mcp/node/json-toolset.d.ts.map +1 -0
- package/dist/mcp/node/json-toolset.js +94 -0
- package/dist/mcp/node/json-toolset.js.map +1 -0
- package/dist/mcp/node/streamable-http-mcp-service.d.ts +18 -0
- package/dist/mcp/node/streamable-http-mcp-service.d.ts.map +1 -0
- package/dist/mcp/node/streamable-http-mcp-service.js +229 -0
- package/dist/mcp/node/streamable-http-mcp-service.js.map +1 -0
- package/dist/mcp/node/types.d.ts +53 -0
- package/dist/mcp/node/types.d.ts.map +1 -0
- package/dist/mcp/node/types.js +2 -0
- package/dist/mcp/node/types.js.map +1 -0
- package/dist/mcp/types.d.ts +37 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +2 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/node/authority-key.d.ts +14 -0
- package/dist/node/authority-key.d.ts.map +1 -0
- package/dist/node/authority-key.js +89 -0
- package/dist/node/authority-key.js.map +1 -0
- package/dist/node/direct-credentials.d.ts +21 -0
- package/dist/node/direct-credentials.d.ts.map +1 -0
- package/dist/node/direct-credentials.js +47 -0
- package/dist/node/direct-credentials.js.map +1 -0
- package/dist/node/http-service.d.ts +21 -0
- package/dist/node/http-service.d.ts.map +1 -0
- package/dist/node/http-service.js +389 -0
- package/dist/node/http-service.js.map +1 -0
- package/dist/node/index.d.ts +6 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +4 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/types.d.ts +52 -0
- package/dist/node/types.d.ts.map +1 -0
- package/dist/node/types.js +2 -0
- package/dist/node/types.js.map +1 -0
- package/dist/testing/event-stream.d.ts +17 -0
- package/dist/testing/event-stream.d.ts.map +1 -0
- package/dist/testing/event-stream.js +83 -0
- package/dist/testing/event-stream.js.map +1 -0
- package/dist/testing/hosted-conversation-turn-store-conformance.d.ts +17 -0
- package/dist/testing/hosted-conversation-turn-store-conformance.d.ts.map +1 -0
- package/dist/testing/hosted-conversation-turn-store-conformance.js +137 -0
- package/dist/testing/hosted-conversation-turn-store-conformance.js.map +1 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +3 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/invocation.d.ts +20 -0
- package/dist/testing/invocation.d.ts.map +1 -0
- package/dist/testing/invocation.js +39 -0
- package/dist/testing/invocation.js.map +1 -0
- package/dist/testing/local-execution-host-contract-fixture.d.ts +21 -0
- package/dist/testing/local-execution-host-contract-fixture.d.ts.map +1 -0
- package/dist/testing/local-execution-host-contract-fixture.js +197 -0
- package/dist/testing/local-execution-host-contract-fixture.js.map +1 -0
- package/dist/testing/request.d.ts +10 -0
- package/dist/testing/request.d.ts.map +1 -0
- package/dist/testing/request.js +140 -0
- package/dist/testing/request.js.map +1 -0
- package/dist/testing/types.d.ts +42 -0
- package/dist/testing/types.d.ts.map +1 -0
- package/dist/testing/types.js +2 -0
- package/dist/testing/types.js.map +1 -0
- package/package.json +92 -0
- package/spec/v1/README.md +101 -0
- package/spec/v1/durable-hosted-conversation-lifecycle.md +139 -0
- package/spec/v1/fixtures/ambiguous-eof.sse +9 -0
- package/spec/v1/fixtures/authority.json +70 -0
- package/spec/v1/fixtures/cancelled.sse +9 -0
- package/spec/v1/fixtures/durable-conversation-lifecycle.json +890 -0
- package/spec/v1/fixtures/invalid-request-extra-field.json +8 -0
- package/spec/v1/fixtures/invalid-sequence-gap.sse +9 -0
- package/spec/v1/fixtures/manifest.json +53 -0
- package/spec/v1/fixtures/valid-request.json +7 -0
- package/spec/v1/fixtures/valid-result.sse +13 -0
- package/spec/v1/openapi.json +896 -0
- package/spec/v1/schema-bundle.json +1286 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jose-execution-authority.js","sourceRoot":"","sources":["../../src/authority/jose-execution-authority.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,WAAW,EACX,OAAO,EACP,aAAa,EACb,SAAS,GAIV,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B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,\n type JSONWebKeySet,\n} from 'jose';\nimport { z } from 'zod';\nimport {\n CONVERSATION_TURN_WORKFLOW,\n EXECUTION_ASSERTION_TYPE,\n EXECUTION_CONTRACT_VERSION,\n ExecutionScopeSchema,\n JwtAudienceSchema,\n JwtIssuerSchema,\n MCP_CAPABILITY_TYPE,\n McpAllowedToolsSchema,\n McpServerIdSchema,\n OpaqueIdSchema,\n RuntimeSessionIdSchema,\n type ExecutionScope,\n} from '../contracts/index.js';\nimport type {\n ExecutionAuthority,\n ExecutionAuthorityConfig,\n ExecutionAuthorityIssueInput,\n ExecutionAuthorityKeyPair,\n IssuedExecutionAuthority,\n IssuedExecutionAuthorityMetadata,\n JoseExecutionAuthorityOptions,\n} from './types.js';\n\nconst SIGNING_ALGORITHM = 'ES256';\nconst ExecutionAuthorityMcpConfigSchema = z.object({\n audience: JwtAudienceSchema,\n serverId: McpServerIdSchema,\n ttlSeconds: z.number().int().min(1).max(15 * 60),\n}).strict();\nconst ExecutionAuthorityConfigSchema = z.object({\n issuer: JwtIssuerSchema,\n adopterId: OpaqueIdSchema,\n executionAudience: JwtAudienceSchema,\n keyId: OpaqueIdSchema,\n executionTtlSeconds: z.number().int().min(1).max(15 * 60),\n mcp: ExecutionAuthorityMcpConfigSchema.optional(),\n}).strict().superRefine((config, context) => {\n if (!config.mcp) {\n return;\n }\n if (config.executionAudience === config.mcp.audience) {\n context.addIssue({\n code: 'custom',\n path: ['mcp', 'audience'],\n message: 'must be distinct from the execution audience',\n });\n }\n if (config.mcp.ttlSeconds < config.executionTtlSeconds) {\n context.addIssue({\n code: 'custom',\n path: ['mcp', 'ttlSeconds'],\n message: 'must not expire before execution admission authority',\n });\n }\n});\nconst ExecutionIssueScopeSchema = ExecutionScopeSchema.omit({ adopterId: true });\nconst ExecutionAuthorityIssueInputSchema = z.object({\n scope: ExecutionIssueScopeSchema,\n runtimeSessionId: RuntimeSessionIdSchema,\n invocationId: OpaqueIdSchema,\n workflow: z.literal(CONVERSATION_TURN_WORKFLOW),\n mcp: z.object({\n allowedTools: McpAllowedToolsSchema,\n }).strict().optional(),\n}).strict();\nconst PublicP256JwkSchema = z.object({\n kty: z.literal('EC'),\n crv: z.literal('P-256'),\n x: z.string().regex(/^[A-Za-z0-9_-]+$/),\n y: z.string().regex(/^[A-Za-z0-9_-]+$/),\n}).passthrough().superRefine((jwk, context) => {\n const privateFields = ['d', 'p', 'q', 'dp', 'dq', 'qi', 'oth', 'k'];\n if (privateFields.some((field) => field in jwk)) {\n context.addIssue({\n code: 'custom',\n message: 'must not contain private key material',\n });\n }\n});\n\n/**\n * ES256 reference adapter for issuing one invocation's admission assertion and\n * optional product-MCP capability.\n */\nexport class JoseExecutionAuthority implements ExecutionAuthority {\n readonly #config: z.infer<typeof ExecutionAuthorityConfigSchema>;\n readonly #privateKey: CryptoKey;\n readonly #publicJwk: Readonly<JWK>;\n readonly #now: () => Date;\n readonly #createCapabilityId: () => string;\n\n private constructor(\n config: ExecutionAuthorityConfig,\n key: { privateKey: CryptoKey; publicJwk: JWK },\n options: JoseExecutionAuthorityOptions,\n ) {\n this.#config = deepFreezeConfig(ExecutionAuthorityConfigSchema.parse(config));\n assertPrivateSigningKey(key.privateKey);\n this.#privateKey = key.privateKey;\n this.#publicJwk = projectPublicJwk(key.publicJwk, this.#config.keyId);\n this.#now = options.now ?? (() => new Date());\n this.#createCapabilityId = options.createCapabilityId ?? randomUUID;\n }\n\n static async create(\n config: ExecutionAuthorityConfig,\n keyPair: ExecutionAuthorityKeyPair,\n options: JoseExecutionAuthorityOptions = {},\n ): Promise<JoseExecutionAuthority> {\n assertPrivateSigningKey(keyPair.privateKey);\n assertPublicVerificationKey(keyPair.publicKey);\n await assertMatchingKeyPair(keyPair);\n return new JoseExecutionAuthority(\n config,\n {\n privateKey: keyPair.privateKey,\n publicJwk: await exportJWK(keyPair.publicKey),\n },\n options,\n );\n }\n\n async issue(\n input: ExecutionAuthorityIssueInput,\n ): Promise<IssuedExecutionAuthority> {\n const authority = ExecutionAuthorityIssueInputSchema.parse(input);\n if (authority.mcp && !this.#config.mcp) {\n throw new Error(\n 'Execution authority cannot issue an MCP capability without MCP deployment configuration.',\n );\n }\n\n const issuedAt = toEpochSeconds(this.#now());\n const executionExpiresAt = issuedAt + this.#config.executionTtlSeconds;\n const executionAssertion = await this.#signExecutionAssertion(\n authority,\n issuedAt,\n executionExpiresAt,\n );\n\n const mcp = authority.mcp && this.#config.mcp\n ? await this.#issueMcpCapability(\n { ...authority, mcp: authority.mcp },\n issuedAt,\n )\n : undefined;\n\n return new ProtectedIssuedExecutionAuthority(\n executionAssertion,\n mcp?.assertion,\n freezeIssuedMetadata({\n scope: {\n adopterId: this.#config.adopterId,\n ...authority.scope,\n },\n runtimeSessionId: authority.runtimeSessionId,\n invocationId: authority.invocationId,\n workflow: authority.workflow,\n issuedAt: toIsoTimestamp(issuedAt),\n executionExpiresAt: toIsoTimestamp(executionExpiresAt),\n ...(mcp ? { mcp: mcp.metadata } : {}),\n }),\n );\n }\n\n publicJwks(): JSONWebKeySet {\n return { keys: [{ ...this.#publicJwk }] };\n }\n\n #signExecutionAssertion(\n input: z.infer<typeof ExecutionAuthorityIssueInputSchema>,\n issuedAt: number,\n expiresAt: number,\n ): Promise<string> {\n return new SignJWT({\n contractVersion: EXECUTION_CONTRACT_VERSION,\n adopterId: this.#config.adopterId,\n tenantId: input.scope.tenantId,\n productSessionId: input.scope.productSessionId,\n runtimeSessionId: input.runtimeSessionId,\n workflow: input.workflow,\n })\n .setProtectedHeader({\n alg: SIGNING_ALGORITHM,\n kid: this.#config.keyId,\n typ: EXECUTION_ASSERTION_TYPE,\n })\n .setIssuer(this.#config.issuer)\n .setAudience(this.#config.executionAudience)\n .setSubject(input.scope.subjectId)\n .setJti(input.invocationId)\n .setIssuedAt(issuedAt)\n .setExpirationTime(expiresAt)\n .sign(this.#privateKey);\n }\n\n async #issueMcpCapability(\n input: z.infer<typeof ExecutionAuthorityIssueInputSchema> & {\n mcp: { allowedTools: string[] };\n },\n issuedAt: number,\n ): Promise<{\n assertion: string;\n metadata: NonNullable<IssuedExecutionAuthorityMetadata['mcp']>;\n }> {\n const mcpConfig = this.#config.mcp!;\n const capabilityId = OpaqueIdSchema.parse(this.#createCapabilityId());\n if (capabilityId === input.invocationId) {\n throw new Error(\n 'MCP capability identity must be distinct from the invocation identity.',\n );\n }\n const expiresAt = issuedAt + mcpConfig.ttlSeconds;\n const assertion = await new SignJWT({\n contractVersion: EXECUTION_CONTRACT_VERSION,\n adopterId: this.#config.adopterId,\n tenantId: input.scope.tenantId,\n productSessionId: input.scope.productSessionId,\n runtimeSessionId: input.runtimeSessionId,\n invocationId: input.invocationId,\n workflow: input.workflow,\n serverId: mcpConfig.serverId,\n allowedTools: [...input.mcp.allowedTools],\n })\n .setProtectedHeader({\n alg: SIGNING_ALGORITHM,\n kid: this.#config.keyId,\n typ: MCP_CAPABILITY_TYPE,\n })\n .setIssuer(this.#config.issuer)\n .setAudience(mcpConfig.audience)\n .setSubject(input.scope.subjectId)\n .setJti(capabilityId)\n .setIssuedAt(issuedAt)\n .setExpirationTime(expiresAt)\n .sign(this.#privateKey);\n\n return {\n assertion,\n metadata: {\n capabilityId,\n serverId: mcpConfig.serverId,\n allowedTools: Object.freeze([...input.mcp.allowedTools]),\n expiresAt: toIsoTimestamp(expiresAt),\n },\n };\n }\n}\n\nclass ProtectedIssuedExecutionAuthority implements IssuedExecutionAuthority {\n readonly metadata: IssuedExecutionAuthorityMetadata;\n readonly #executionAssertion: string;\n readonly #mcpCapability: string | undefined;\n\n constructor(\n executionAssertion: string,\n mcpCapability: string | undefined,\n metadata: IssuedExecutionAuthorityMetadata,\n ) {\n this.#executionAssertion = executionAssertion;\n this.#mcpCapability = mcpCapability;\n this.metadata = metadata;\n }\n\n executionAssertion(): string {\n return this.#executionAssertion;\n }\n\n mcpCapability(): string | undefined {\n return this.#mcpCapability;\n }\n\n toJSON(): IssuedExecutionAuthorityMetadata {\n return this.metadata;\n }\n}\n\nfunction projectPublicJwk(jwk: JWK, keyId: string): Readonly<JWK> {\n const parsed = PublicP256JwkSchema.parse(jwk);\n return Object.freeze({\n kty: parsed.kty,\n crv: parsed.crv,\n x: parsed.x,\n y: parsed.y,\n alg: SIGNING_ALGORITHM,\n kid: keyId,\n use: 'sig',\n });\n}\n\nfunction assertPrivateSigningKey(key: CryptoKey): void {\n const algorithm = key.algorithm as { name: string; namedCurve?: string };\n const accepted = key.type === 'private'\n && algorithm.name === 'ECDSA'\n && algorithm.namedCurve === 'P-256'\n && key.usages.includes('sign');\n if (!accepted) {\n throw new Error(\n 'Execution authority requires an ES256 private signing key.',\n );\n }\n}\n\nfunction assertPublicVerificationKey(key: CryptoKey): void {\n const algorithm = key.algorithm as { name: string; namedCurve?: string };\n const accepted = key.type === 'public'\n && algorithm.name === 'ECDSA'\n && algorithm.namedCurve === 'P-256'\n && key.usages.includes('verify');\n if (!accepted) {\n throw new Error(\n 'Execution authority requires an ES256 public verification key.',\n );\n }\n}\n\nasync function assertMatchingKeyPair(\n keyPair: ExecutionAuthorityKeyPair,\n): Promise<void> {\n try {\n const probe = await new CompactSign(\n new TextEncoder().encode('heddle-adopter-execution-authority-key-pair'),\n )\n .setProtectedHeader({ alg: SIGNING_ALGORITHM })\n .sign(keyPair.privateKey);\n await compactVerify(probe, keyPair.publicKey, {\n algorithms: [SIGNING_ALGORITHM],\n });\n } catch {\n throw new Error('Execution authority signing keys do not match.');\n }\n}\n\nfunction toEpochSeconds(value: Date): number {\n const seconds = Math.floor(value.getTime() / 1_000);\n if (!Number.isSafeInteger(seconds) || seconds < 0) {\n throw new Error('Execution authority could not resolve a valid issue time.');\n }\n return seconds;\n}\n\nfunction toIsoTimestamp(epochSeconds: number): string {\n return new Date(epochSeconds * 1_000).toISOString();\n}\n\nfunction deepFreezeConfig(\n config: z.infer<typeof ExecutionAuthorityConfigSchema>,\n): z.infer<typeof ExecutionAuthorityConfigSchema> {\n const mcp = config.mcp ? Object.freeze({ ...config.mcp }) : undefined;\n return Object.freeze({ ...config, ...(mcp ? { mcp } : {}) });\n}\n\nfunction freezeIssuedMetadata(\n metadata: IssuedExecutionAuthorityMetadata,\n): IssuedExecutionAuthorityMetadata {\n const scope: ExecutionScope = Object.freeze({ ...metadata.scope });\n const mcp = metadata.mcp\n ? Object.freeze({\n ...metadata.mcp,\n allowedTools: Object.freeze([...metadata.mcp.allowedTools]),\n })\n : undefined;\n return Object.freeze({ ...metadata, scope, ...(mcp ? { mcp } : {}) });\n}\n"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { CryptoKey, JSONWebKeySet } from 'jose';
|
|
2
|
+
import type { ExecutionScope, HostedExecutionWorkflow } from '../contracts/index.js';
|
|
3
|
+
export type ExecutionAuthorityMcpConfig = {
|
|
4
|
+
audience: string;
|
|
5
|
+
serverId: string;
|
|
6
|
+
ttlSeconds: number;
|
|
7
|
+
};
|
|
8
|
+
export type ExecutionAuthorityConfig = {
|
|
9
|
+
issuer: string;
|
|
10
|
+
adopterId: string;
|
|
11
|
+
executionAudience: string;
|
|
12
|
+
keyId: string;
|
|
13
|
+
executionTtlSeconds: number;
|
|
14
|
+
mcp?: ExecutionAuthorityMcpConfig;
|
|
15
|
+
};
|
|
16
|
+
export type ExecutionAuthorityIssueInput = {
|
|
17
|
+
scope: Omit<ExecutionScope, 'adopterId'>;
|
|
18
|
+
runtimeSessionId: string;
|
|
19
|
+
invocationId: string;
|
|
20
|
+
workflow: HostedExecutionWorkflow;
|
|
21
|
+
mcp?: {
|
|
22
|
+
allowedTools: readonly string[];
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export type IssuedMcpCapabilityMetadata = {
|
|
26
|
+
capabilityId: string;
|
|
27
|
+
serverId: string;
|
|
28
|
+
allowedTools: readonly string[];
|
|
29
|
+
expiresAt: string;
|
|
30
|
+
};
|
|
31
|
+
export type IssuedExecutionAuthorityMetadata = {
|
|
32
|
+
scope: ExecutionScope;
|
|
33
|
+
runtimeSessionId: string;
|
|
34
|
+
invocationId: string;
|
|
35
|
+
workflow: HostedExecutionWorkflow;
|
|
36
|
+
issuedAt: string;
|
|
37
|
+
executionExpiresAt: string;
|
|
38
|
+
mcp?: IssuedMcpCapabilityMetadata;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Short-lived credentials are available only through explicit accessors.
|
|
42
|
+
* JSON serialization contains credential-free metadata. Identifiers can still
|
|
43
|
+
* be product data and remain subject to the adopter's logging policy.
|
|
44
|
+
*/
|
|
45
|
+
export interface IssuedExecutionAuthority {
|
|
46
|
+
readonly metadata: IssuedExecutionAuthorityMetadata;
|
|
47
|
+
executionAssertion(): string;
|
|
48
|
+
mcpCapability(): string | undefined;
|
|
49
|
+
toJSON(): IssuedExecutionAuthorityMetadata;
|
|
50
|
+
}
|
|
51
|
+
export interface ExecutionAuthority {
|
|
52
|
+
issue(input: ExecutionAuthorityIssueInput): Promise<IssuedExecutionAuthority>;
|
|
53
|
+
publicJwks(): JSONWebKeySet;
|
|
54
|
+
}
|
|
55
|
+
export type ExecutionAuthorityKeyPair = {
|
|
56
|
+
privateKey: CryptoKey;
|
|
57
|
+
publicKey: CryptoKey;
|
|
58
|
+
};
|
|
59
|
+
export type JoseExecutionAuthorityOptions = {
|
|
60
|
+
now?: () => Date;
|
|
61
|
+
createCapabilityId?: () => string;
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/authority/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AACrD,OAAO,KAAK,EACV,cAAc,EACd,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;A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4B,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAC9E,UAAU,IAAI,aAAa,CAAC;CAC7B;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,UAAU,EAAE,SAAS,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IACjB,kBAAkB,CAAC,EAAE,MAAM,MAAM,CAAC;CACnC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/authority/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CryptoKey, JSONWebKeySet } from 'jose';\nimport type {\n ExecutionScope,\n HostedExecutionWorkflow,\n} from '../contracts/index.js';\n\nexport type ExecutionAuthorityMcpConfig = {\n audience: string;\n serverId: string;\n ttlSeconds: number;\n};\n\nexport type ExecutionAuthorityConfig = {\n issuer: string;\n adopterId: string;\n executionAudience: string;\n keyId: string;\n executionTtlSeconds: number;\n mcp?: ExecutionAuthorityMcpConfig;\n};\n\nexport type ExecutionAuthorityIssueInput = {\n scope: Omit<ExecutionScope, 'adopterId'>;\n runtimeSessionId: string;\n invocationId: string;\n workflow: HostedExecutionWorkflow;\n mcp?: {\n allowedTools: readonly string[];\n };\n};\n\nexport type IssuedMcpCapabilityMetadata = {\n capabilityId: string;\n serverId: string;\n allowedTools: readonly string[];\n expiresAt: string;\n};\n\nexport type IssuedExecutionAuthorityMetadata = {\n scope: ExecutionScope;\n runtimeSessionId: string;\n invocationId: string;\n workflow: HostedExecutionWorkflow;\n issuedAt: string;\n executionExpiresAt: string;\n mcp?: IssuedMcpCapabilityMetadata;\n};\n\n/**\n * Short-lived credentials are available only through explicit accessors.\n * JSON serialization contains credential-free metadata. Identifiers can still\n * be product data and remain subject to the adopter's logging policy.\n */\nexport interface IssuedExecutionAuthority {\n readonly metadata: IssuedExecutionAuthorityMetadata;\n executionAssertion(): string;\n mcpCapability(): string | undefined;\n toJSON(): IssuedExecutionAuthorityMetadata;\n}\n\nexport interface ExecutionAuthority {\n issue(input: ExecutionAuthorityIssueInput): Promise<IssuedExecutionAuthority>;\n publicJwks(): JSONWebKeySet;\n}\n\nexport type ExecutionAuthorityKeyPair = {\n privateKey: CryptoKey;\n publicKey: CryptoKey;\n};\n\nexport type JoseExecutionAuthorityOptions = {\n now?: () => Date;\n createCapabilityId?: () => string;\n};\n"]}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const EXECUTION_CONTRACT_VERSION: 1;
|
|
3
|
+
export declare const CONVERSATION_TURN_WORKFLOW: "conversation-turn";
|
|
4
|
+
export declare const EXECUTION_ASSERTION_TYPE: "heddle-execution+jwt";
|
|
5
|
+
export declare const MCP_CAPABILITY_TYPE: "heddle-mcp-capability+jwt";
|
|
6
|
+
export declare const AGENTCORE_RUNTIME_SESSION_HEADER: "x-amzn-bedrock-agentcore-runtime-session-id";
|
|
7
|
+
export declare const EXECUTION_HOST_LOCAL_TOKEN_HEADER: "x-heddle-execution-host-local-token";
|
|
8
|
+
export declare const EXECUTION_ASSERTION_HEADER: "x-heddle-execution-host-assertion";
|
|
9
|
+
export declare const MCP_CAPABILITY_HEADER: "x-heddle-execution-host-mcp-capability";
|
|
10
|
+
export declare const MODEL_API_KEY_HEADER: "x-heddle-execution-host-model-api-key";
|
|
11
|
+
export declare const OpaqueIdSchema: z.ZodString;
|
|
12
|
+
export declare const JwtIssuerSchema: z.ZodURL;
|
|
13
|
+
export declare const JwtAudienceSchema: z.ZodString;
|
|
14
|
+
export declare const RuntimeSessionIdSchema: z.ZodString;
|
|
15
|
+
export declare const TimestampSchema: z.ZodISODateTime;
|
|
16
|
+
export declare const McpServerIdSchema: z.ZodString;
|
|
17
|
+
export declare const McpToolNameSchema: z.ZodString;
|
|
18
|
+
export declare const McpAllowedToolsSchema: z.ZodArray<z.ZodString>;
|
|
19
|
+
export declare const ExecutionScopeSchema: z.ZodObject<{
|
|
20
|
+
adopterId: z.ZodString;
|
|
21
|
+
tenantId: z.ZodString;
|
|
22
|
+
subjectId: z.ZodString;
|
|
23
|
+
productSessionId: z.ZodString;
|
|
24
|
+
}, z.core.$strict>;
|
|
25
|
+
export declare const ExecutionHostConversationTurnRequestSchema: z.ZodObject<{
|
|
26
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
27
|
+
kind: z.ZodLiteral<"conversation-turn">;
|
|
28
|
+
invocationId: z.ZodString;
|
|
29
|
+
prompt: z.ZodString;
|
|
30
|
+
deadlineAt: z.ZodOptional<z.ZodISODateTime>;
|
|
31
|
+
}, z.core.$strict>;
|
|
32
|
+
export declare const RuntimePublicResultSchema: z.ZodObject<{
|
|
33
|
+
outcome: z.ZodEnum<{
|
|
34
|
+
error: "error";
|
|
35
|
+
done: "done";
|
|
36
|
+
max_steps: "max_steps";
|
|
37
|
+
interrupted: "interrupted";
|
|
38
|
+
}>;
|
|
39
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
40
|
+
failure: z.ZodOptional<z.ZodObject<{
|
|
41
|
+
source: z.ZodLiteral<"model">;
|
|
42
|
+
code: z.ZodEnum<{
|
|
43
|
+
unknown: "unknown";
|
|
44
|
+
authentication: "authentication";
|
|
45
|
+
permission: "permission";
|
|
46
|
+
quota: "quota";
|
|
47
|
+
rate_limit: "rate_limit";
|
|
48
|
+
context_window: "context_window";
|
|
49
|
+
request: "request";
|
|
50
|
+
transport: "transport";
|
|
51
|
+
empty_response: "empty_response";
|
|
52
|
+
}>;
|
|
53
|
+
}, z.core.$strict>>;
|
|
54
|
+
}, z.core.$strict>;
|
|
55
|
+
export declare const ExecutionHostStreamEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
56
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
57
|
+
invocationId: z.ZodString;
|
|
58
|
+
runId: z.ZodString;
|
|
59
|
+
timestamp: z.ZodISODateTime;
|
|
60
|
+
sequence: z.ZodLiteral<0>;
|
|
61
|
+
kind: z.ZodLiteral<"accepted">;
|
|
62
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
63
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
64
|
+
invocationId: z.ZodString;
|
|
65
|
+
runId: z.ZodString;
|
|
66
|
+
sequence: z.ZodNumber;
|
|
67
|
+
timestamp: z.ZodISODateTime;
|
|
68
|
+
kind: z.ZodLiteral<"activity">;
|
|
69
|
+
activity: z.ZodUnknown;
|
|
70
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
71
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
72
|
+
invocationId: z.ZodString;
|
|
73
|
+
runId: z.ZodString;
|
|
74
|
+
sequence: z.ZodNumber;
|
|
75
|
+
timestamp: z.ZodISODateTime;
|
|
76
|
+
kind: z.ZodLiteral<"result">;
|
|
77
|
+
result: z.ZodObject<{
|
|
78
|
+
outcome: z.ZodEnum<{
|
|
79
|
+
error: "error";
|
|
80
|
+
done: "done";
|
|
81
|
+
max_steps: "max_steps";
|
|
82
|
+
interrupted: "interrupted";
|
|
83
|
+
}>;
|
|
84
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
85
|
+
failure: z.ZodOptional<z.ZodObject<{
|
|
86
|
+
source: z.ZodLiteral<"model">;
|
|
87
|
+
code: z.ZodEnum<{
|
|
88
|
+
unknown: "unknown";
|
|
89
|
+
authentication: "authentication";
|
|
90
|
+
permission: "permission";
|
|
91
|
+
quota: "quota";
|
|
92
|
+
rate_limit: "rate_limit";
|
|
93
|
+
context_window: "context_window";
|
|
94
|
+
request: "request";
|
|
95
|
+
transport: "transport";
|
|
96
|
+
empty_response: "empty_response";
|
|
97
|
+
}>;
|
|
98
|
+
}, z.core.$strict>>;
|
|
99
|
+
}, z.core.$strict>;
|
|
100
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
101
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
102
|
+
invocationId: z.ZodString;
|
|
103
|
+
runId: z.ZodString;
|
|
104
|
+
sequence: z.ZodNumber;
|
|
105
|
+
timestamp: z.ZodISODateTime;
|
|
106
|
+
kind: z.ZodLiteral<"cancelled">;
|
|
107
|
+
reason: z.ZodString;
|
|
108
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
109
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
110
|
+
invocationId: z.ZodString;
|
|
111
|
+
runId: z.ZodString;
|
|
112
|
+
sequence: z.ZodNumber;
|
|
113
|
+
timestamp: z.ZodISODateTime;
|
|
114
|
+
kind: z.ZodLiteral<"error">;
|
|
115
|
+
error: z.ZodObject<{
|
|
116
|
+
code: z.ZodString;
|
|
117
|
+
message: z.ZodString;
|
|
118
|
+
}, z.core.$strict>;
|
|
119
|
+
}, z.core.$strict>], "kind">;
|
|
120
|
+
export declare const ExecutionAssertionClaimsSchema: z.ZodObject<{
|
|
121
|
+
iss: z.ZodURL;
|
|
122
|
+
aud: z.ZodString;
|
|
123
|
+
contractVersion: z.ZodLiteral<1>;
|
|
124
|
+
adopterId: z.ZodString;
|
|
125
|
+
tenantId: z.ZodString;
|
|
126
|
+
productSessionId: z.ZodString;
|
|
127
|
+
runtimeSessionId: z.ZodString;
|
|
128
|
+
workflow: z.ZodLiteral<"conversation-turn">;
|
|
129
|
+
sub: z.ZodString;
|
|
130
|
+
jti: z.ZodString;
|
|
131
|
+
iat: z.ZodNumber;
|
|
132
|
+
exp: z.ZodNumber;
|
|
133
|
+
}, z.core.$loose>;
|
|
134
|
+
export declare const McpCapabilityClaimsSchema: z.ZodObject<{
|
|
135
|
+
iss: z.ZodURL;
|
|
136
|
+
aud: z.ZodString;
|
|
137
|
+
contractVersion: z.ZodLiteral<1>;
|
|
138
|
+
adopterId: z.ZodString;
|
|
139
|
+
tenantId: z.ZodString;
|
|
140
|
+
productSessionId: z.ZodString;
|
|
141
|
+
runtimeSessionId: z.ZodString;
|
|
142
|
+
invocationId: z.ZodString;
|
|
143
|
+
workflow: z.ZodLiteral<"conversation-turn">;
|
|
144
|
+
serverId: z.ZodString;
|
|
145
|
+
allowedTools: z.ZodArray<z.ZodString>;
|
|
146
|
+
sub: z.ZodString;
|
|
147
|
+
jti: z.ZodString;
|
|
148
|
+
iat: z.ZodNumber;
|
|
149
|
+
exp: z.ZodNumber;
|
|
150
|
+
}, z.core.$loose>;
|
|
151
|
+
export type ExecutionScope = z.infer<typeof ExecutionScopeSchema>;
|
|
152
|
+
export type ExecutionHostConversationTurnRequest = z.infer<typeof ExecutionHostConversationTurnRequestSchema>;
|
|
153
|
+
export type RuntimePublicResult = z.infer<typeof RuntimePublicResultSchema>;
|
|
154
|
+
export type ExecutionHostStreamEvent = z.infer<typeof ExecutionHostStreamEventSchema>;
|
|
155
|
+
export type ExecutionHostTerminalEvent = Extract<ExecutionHostStreamEvent, {
|
|
156
|
+
kind: 'result' | 'cancelled' | 'error';
|
|
157
|
+
}>;
|
|
158
|
+
export type ExecutionAssertionClaims = z.infer<typeof ExecutionAssertionClaimsSchema>;
|
|
159
|
+
export type McpCapabilityClaims = z.infer<typeof McpCapabilityClaimsSchema>;
|
|
160
|
+
export type HostedExecutionWorkflow = typeof CONVERSATION_TURN_WORKFLOW;
|
|
161
|
+
export declare function isExecutionHostTerminalEvent(event: ExecutionHostStreamEvent): event is ExecutionHostTerminalEvent;
|
|
162
|
+
export declare function isSafeWebUrl(url: URL): boolean;
|
|
163
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,0BAA0B,EAAG,CAAU,CAAC;AACrD,eAAO,MAAM,0BAA0B,EAAG,mBAA4B,CAAC;AACvE,eAAO,MAAM,wBAAwB,EAAG,sBAA+B,CAAC;AACxE,eAAO,MAAM,mBAAmB,EAAG,2BAAoC,CAAC;AAEx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AG,CAAC,CAAC,KAAK,CAC5C,OAAO,8BAA8B,CACtC,CAAC;AACF,MAAM,MAAM,0BAA0B,GAAG,OAAO,CAC9C,wBAAwB,EACxB;IAAE,IAAI,EAAE,QAAQ,GAAG,WAAW,GAAG,OAAO,CAAA;CAAE,CAC3C,CAAC;AACF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,8BAA8B,CACtC,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC5E,MAAM,MAAM,uBAAuB,GAAG,OAAO,0BAA0B,CAAC;AAExE,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,wBAAwB,GAC9B,KAAK,IAAI,0BAA0B,CAIrC;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAO9C"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const EXECUTION_CONTRACT_VERSION = 1;
|
|
3
|
+
export const CONVERSATION_TURN_WORKFLOW = 'conversation-turn';
|
|
4
|
+
export const EXECUTION_ASSERTION_TYPE = 'heddle-execution+jwt';
|
|
5
|
+
export const MCP_CAPABILITY_TYPE = 'heddle-mcp-capability+jwt';
|
|
6
|
+
export const AGENTCORE_RUNTIME_SESSION_HEADER = 'x-amzn-bedrock-agentcore-runtime-session-id';
|
|
7
|
+
export const EXECUTION_HOST_LOCAL_TOKEN_HEADER = 'x-heddle-execution-host-local-token';
|
|
8
|
+
export const EXECUTION_ASSERTION_HEADER = 'x-heddle-execution-host-assertion';
|
|
9
|
+
export const MCP_CAPABILITY_HEADER = 'x-heddle-execution-host-mcp-capability';
|
|
10
|
+
export const MODEL_API_KEY_HEADER = 'x-heddle-execution-host-model-api-key';
|
|
11
|
+
export const OpaqueIdSchema = z
|
|
12
|
+
.string()
|
|
13
|
+
.min(1)
|
|
14
|
+
.max(128)
|
|
15
|
+
.regex(/^[A-Za-z0-9][A-Za-z0-9._:@-]*$/, 'must be an opaque, path-free identifier');
|
|
16
|
+
export const JwtIssuerSchema = z.url().refine((value) => isSafeWebUrl(new URL(value)), 'must use HTTPS or loopback HTTP and contain no credentials, query, or fragment');
|
|
17
|
+
export const JwtAudienceSchema = z.string().min(1).max(512);
|
|
18
|
+
export const RuntimeSessionIdSchema = z
|
|
19
|
+
.string()
|
|
20
|
+
.min(33)
|
|
21
|
+
.max(256)
|
|
22
|
+
.refine((value) => value === value.trim(), 'must not contain outer whitespace');
|
|
23
|
+
export const TimestampSchema = z.iso.datetime({ offset: true });
|
|
24
|
+
export const McpServerIdSchema = z
|
|
25
|
+
.string()
|
|
26
|
+
.min(1)
|
|
27
|
+
.max(64)
|
|
28
|
+
.regex(/^[A-Za-z0-9_-]+$/, 'must be a Heddle-compatible MCP server identifier');
|
|
29
|
+
export const McpToolNameSchema = z
|
|
30
|
+
.string()
|
|
31
|
+
.min(1)
|
|
32
|
+
.max(64)
|
|
33
|
+
.regex(/^[A-Za-z][A-Za-z0-9_]*$/, 'must be a collision-free MCP tool name');
|
|
34
|
+
export const McpAllowedToolsSchema = z
|
|
35
|
+
.array(McpToolNameSchema)
|
|
36
|
+
.min(1)
|
|
37
|
+
.max(16)
|
|
38
|
+
.refine((tools) => new Set(tools).size === tools.length, {
|
|
39
|
+
message: 'must contain unique MCP tool names',
|
|
40
|
+
})
|
|
41
|
+
.refine((tools) => tools.reduce((characterCount, toolName) => characterCount + toolName.length, 0) <= 512, { message: 'contains too many aggregate tool-name characters' });
|
|
42
|
+
export const ExecutionScopeSchema = z.object({
|
|
43
|
+
adopterId: OpaqueIdSchema,
|
|
44
|
+
tenantId: OpaqueIdSchema,
|
|
45
|
+
subjectId: OpaqueIdSchema,
|
|
46
|
+
productSessionId: OpaqueIdSchema,
|
|
47
|
+
}).strict();
|
|
48
|
+
export const ExecutionHostConversationTurnRequestSchema = z.object({
|
|
49
|
+
schemaVersion: z.literal(EXECUTION_CONTRACT_VERSION),
|
|
50
|
+
kind: z.literal(CONVERSATION_TURN_WORKFLOW),
|
|
51
|
+
invocationId: OpaqueIdSchema,
|
|
52
|
+
prompt: z.string().trim().min(1).max(200_000),
|
|
53
|
+
deadlineAt: TimestampSchema.optional(),
|
|
54
|
+
}).strict();
|
|
55
|
+
export const RuntimePublicResultSchema = z.object({
|
|
56
|
+
outcome: z.enum(['done', 'max_steps', 'error', 'interrupted']),
|
|
57
|
+
summary: z.string().optional(),
|
|
58
|
+
failure: z.object({
|
|
59
|
+
source: z.literal('model'),
|
|
60
|
+
code: z.enum([
|
|
61
|
+
'authentication',
|
|
62
|
+
'permission',
|
|
63
|
+
'quota',
|
|
64
|
+
'rate_limit',
|
|
65
|
+
'context_window',
|
|
66
|
+
'request',
|
|
67
|
+
'transport',
|
|
68
|
+
'empty_response',
|
|
69
|
+
'unknown',
|
|
70
|
+
]),
|
|
71
|
+
}).strict().optional(),
|
|
72
|
+
}).strict();
|
|
73
|
+
const StreamEnvelopeSchema = z.object({
|
|
74
|
+
schemaVersion: z.literal(EXECUTION_CONTRACT_VERSION),
|
|
75
|
+
invocationId: OpaqueIdSchema,
|
|
76
|
+
runId: OpaqueIdSchema,
|
|
77
|
+
sequence: z.number().int().nonnegative(),
|
|
78
|
+
timestamp: TimestampSchema,
|
|
79
|
+
});
|
|
80
|
+
export const ExecutionHostStreamEventSchema = z.discriminatedUnion('kind', [
|
|
81
|
+
StreamEnvelopeSchema.extend({
|
|
82
|
+
sequence: z.literal(0),
|
|
83
|
+
kind: z.literal('accepted'),
|
|
84
|
+
}).strict(),
|
|
85
|
+
StreamEnvelopeSchema.extend({
|
|
86
|
+
kind: z.literal('activity'),
|
|
87
|
+
activity: z.unknown(),
|
|
88
|
+
}).strict(),
|
|
89
|
+
StreamEnvelopeSchema.extend({
|
|
90
|
+
kind: z.literal('result'),
|
|
91
|
+
result: RuntimePublicResultSchema,
|
|
92
|
+
}).strict(),
|
|
93
|
+
StreamEnvelopeSchema.extend({
|
|
94
|
+
kind: z.literal('cancelled'),
|
|
95
|
+
reason: z.string(),
|
|
96
|
+
}).strict(),
|
|
97
|
+
StreamEnvelopeSchema.extend({
|
|
98
|
+
kind: z.literal('error'),
|
|
99
|
+
error: z.object({
|
|
100
|
+
code: z.string().min(1).max(128).regex(/^[a-z0-9_]+$/),
|
|
101
|
+
message: z.string().min(1).max(1_600),
|
|
102
|
+
}).strict(),
|
|
103
|
+
}).strict(),
|
|
104
|
+
]);
|
|
105
|
+
export const ExecutionAssertionClaimsSchema = z.object({
|
|
106
|
+
iss: JwtIssuerSchema,
|
|
107
|
+
aud: JwtAudienceSchema,
|
|
108
|
+
contractVersion: z.literal(EXECUTION_CONTRACT_VERSION),
|
|
109
|
+
adopterId: OpaqueIdSchema,
|
|
110
|
+
tenantId: OpaqueIdSchema,
|
|
111
|
+
productSessionId: OpaqueIdSchema,
|
|
112
|
+
runtimeSessionId: RuntimeSessionIdSchema,
|
|
113
|
+
workflow: z.literal(CONVERSATION_TURN_WORKFLOW),
|
|
114
|
+
sub: OpaqueIdSchema,
|
|
115
|
+
jti: OpaqueIdSchema,
|
|
116
|
+
iat: z.number().int().nonnegative(),
|
|
117
|
+
exp: z.number().int().positive(),
|
|
118
|
+
}).passthrough();
|
|
119
|
+
export const McpCapabilityClaimsSchema = z.object({
|
|
120
|
+
iss: JwtIssuerSchema,
|
|
121
|
+
aud: JwtAudienceSchema,
|
|
122
|
+
contractVersion: z.literal(EXECUTION_CONTRACT_VERSION),
|
|
123
|
+
adopterId: OpaqueIdSchema,
|
|
124
|
+
tenantId: OpaqueIdSchema,
|
|
125
|
+
productSessionId: OpaqueIdSchema,
|
|
126
|
+
runtimeSessionId: RuntimeSessionIdSchema,
|
|
127
|
+
invocationId: OpaqueIdSchema,
|
|
128
|
+
workflow: z.literal(CONVERSATION_TURN_WORKFLOW),
|
|
129
|
+
serverId: McpServerIdSchema,
|
|
130
|
+
allowedTools: McpAllowedToolsSchema,
|
|
131
|
+
sub: OpaqueIdSchema,
|
|
132
|
+
jti: OpaqueIdSchema,
|
|
133
|
+
iat: z.number().int().nonnegative(),
|
|
134
|
+
exp: z.number().int().positive(),
|
|
135
|
+
}).passthrough();
|
|
136
|
+
export function isExecutionHostTerminalEvent(event) {
|
|
137
|
+
return event.kind === 'result'
|
|
138
|
+
|| event.kind === 'cancelled'
|
|
139
|
+
|| event.kind === 'error';
|
|
140
|
+
}
|
|
141
|
+
export function isSafeWebUrl(url) {
|
|
142
|
+
const loopback = ['127.0.0.1', '[::1]', 'localhost'].includes(url.hostname);
|
|
143
|
+
return (url.protocol === 'https:' || (url.protocol === 'http:' && loopback))
|
|
144
|
+
&& !url.username
|
|
145
|
+
&& !url.password
|
|
146
|
+
&& !url.search
|
|
147
|
+
&& !url.hash;
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAU,CAAC;AACrD,MAAM,CAAC,MAAM,0BAA0B,GAAG,mBAA4B,CAAC;AACvE,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAA+B,CAAC;AACxE,MAAM,CAAC,MAAM,mBAAmB,GAAG,2BAAoC,CAAC;AAExE,MAAM,CAAC,MAAM,gCAAgC,GAC3C,6CAAsD,CAAC;AACzD,MAAM,CAAC,MAAM,iCAAiC,GAC5C,qCAA8C,CAAC;AACjD,MAAM,CAAC,MAAM,0BAA0B,GACrC,mCAA4C,CAAC;AAC/C,MAAM,CAAC,MAAM,qBAAqB,GAChC,wCAAiD,CAAC;AACpD,MAAM,CAAC,MAAM,oBAAoB,GAC/B,uCAAgD,CAAC;AAEnD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC;KAC5B,MAAM,EAAE;KACR,GAAG,CAA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conversation-turn' as const;\nexport const EXECUTION_ASSERTION_TYPE = 'heddle-execution+jwt' as const;\nexport const MCP_CAPABILITY_TYPE = 'heddle-mcp-capability+jwt' as const;\n\nexport const AGENTCORE_RUNTIME_SESSION_HEADER =\n 'x-amzn-bedrock-agentcore-runtime-session-id' as const;\nexport const EXECUTION_HOST_LOCAL_TOKEN_HEADER =\n 'x-heddle-execution-host-local-token' as const;\nexport const EXECUTION_ASSERTION_HEADER =\n 'x-heddle-execution-host-assertion' as const;\nexport const MCP_CAPABILITY_HEADER =\n 'x-heddle-execution-host-mcp-capability' as const;\nexport const MODEL_API_KEY_HEADER =\n 'x-heddle-execution-host-model-api-key' as const;\n\nexport const OpaqueIdSchema = z\n .string()\n .min(1)\n .max(128)\n .regex(\n /^[A-Za-z0-9][A-Za-z0-9._:@-]*$/,\n 'must be an opaque, path-free identifier',\n );\n\nexport const JwtIssuerSchema = z.url().refine(\n (value) => isSafeWebUrl(new URL(value)),\n 'must use HTTPS or loopback HTTP and contain no credentials, query, or fragment',\n);\n\nexport const JwtAudienceSchema = z.string().min(1).max(512);\n\nexport const RuntimeSessionIdSchema = z\n .string()\n .min(33)\n .max(256)\n .refine((value) => value === value.trim(), 'must not contain outer whitespace');\n\nexport const TimestampSchema = z.iso.datetime({ offset: true });\n\nexport const McpServerIdSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(\n /^[A-Za-z0-9_-]+$/,\n 'must be a Heddle-compatible MCP server identifier',\n );\n\nexport const McpToolNameSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(\n /^[A-Za-z][A-Za-z0-9_]*$/,\n 'must be a collision-free MCP tool name',\n );\n\nexport const McpAllowedToolsSchema = z\n .array(McpToolNameSchema)\n .min(1)\n .max(16)\n .refine((tools) => new Set(tools).size === tools.length, {\n message: 'must contain unique MCP tool names',\n })\n .refine(\n (tools) => tools.reduce(\n (characterCount, toolName) => characterCount + toolName.length,\n 0,\n ) <= 512,\n { message: 'contains too many aggregate tool-name characters' },\n );\n\nexport const ExecutionScopeSchema = z.object({\n adopterId: OpaqueIdSchema,\n tenantId: OpaqueIdSchema,\n subjectId: OpaqueIdSchema,\n productSessionId: OpaqueIdSchema,\n}).strict();\n\nexport const ExecutionHostConversationTurnRequestSchema = z.object({\n schemaVersion: z.literal(EXECUTION_CONTRACT_VERSION),\n kind: z.literal(CONVERSATION_TURN_WORKFLOW),\n invocationId: OpaqueIdSchema,\n prompt: z.string().trim().min(1).max(200_000),\n deadlineAt: TimestampSchema.optional(),\n}).strict();\n\nexport const RuntimePublicResultSchema = z.object({\n outcome: z.enum(['done', 'max_steps', 'error', 'interrupted']),\n summary: z.string().optional(),\n failure: z.object({\n source: z.literal('model'),\n code: z.enum([\n 'authentication',\n 'permission',\n 'quota',\n 'rate_limit',\n 'context_window',\n 'request',\n 'transport',\n 'empty_response',\n 'unknown',\n ]),\n }).strict().optional(),\n}).strict();\n\nconst StreamEnvelopeSchema = z.object({\n schemaVersion: z.literal(EXECUTION_CONTRACT_VERSION),\n invocationId: OpaqueIdSchema,\n runId: OpaqueIdSchema,\n sequence: z.number().int().nonnegative(),\n timestamp: TimestampSchema,\n});\n\nexport const ExecutionHostStreamEventSchema = z.discriminatedUnion('kind', [\n StreamEnvelopeSchema.extend({\n sequence: z.literal(0),\n kind: z.literal('accepted'),\n }).strict(),\n StreamEnvelopeSchema.extend({\n kind: z.literal('activity'),\n activity: z.unknown(),\n }).strict(),\n StreamEnvelopeSchema.extend({\n kind: z.literal('result'),\n result: RuntimePublicResultSchema,\n }).strict(),\n StreamEnvelopeSchema.extend({\n kind: z.literal('cancelled'),\n reason: z.string(),\n }).strict(),\n StreamEnvelopeSchema.extend({\n kind: z.literal('error'),\n error: z.object({\n code: z.string().min(1).max(128).regex(/^[a-z0-9_]+$/),\n message: z.string().min(1).max(1_600),\n }).strict(),\n }).strict(),\n]);\n\nexport const ExecutionAssertionClaimsSchema = z.object({\n iss: JwtIssuerSchema,\n aud: JwtAudienceSchema,\n contractVersion: z.literal(EXECUTION_CONTRACT_VERSION),\n adopterId: OpaqueIdSchema,\n tenantId: OpaqueIdSchema,\n productSessionId: OpaqueIdSchema,\n runtimeSessionId: RuntimeSessionIdSchema,\n workflow: z.literal(CONVERSATION_TURN_WORKFLOW),\n sub: OpaqueIdSchema,\n jti: OpaqueIdSchema,\n iat: z.number().int().nonnegative(),\n exp: z.number().int().positive(),\n}).passthrough();\n\nexport const McpCapabilityClaimsSchema = z.object({\n iss: JwtIssuerSchema,\n aud: JwtAudienceSchema,\n contractVersion: z.literal(EXECUTION_CONTRACT_VERSION),\n adopterId: OpaqueIdSchema,\n tenantId: OpaqueIdSchema,\n productSessionId: OpaqueIdSchema,\n runtimeSessionId: RuntimeSessionIdSchema,\n invocationId: OpaqueIdSchema,\n workflow: z.literal(CONVERSATION_TURN_WORKFLOW),\n serverId: McpServerIdSchema,\n allowedTools: McpAllowedToolsSchema,\n sub: OpaqueIdSchema,\n jti: OpaqueIdSchema,\n iat: z.number().int().nonnegative(),\n exp: z.number().int().positive(),\n}).passthrough();\n\nexport type ExecutionScope = z.infer<typeof ExecutionScopeSchema>;\nexport type ExecutionHostConversationTurnRequest = z.infer<\n typeof ExecutionHostConversationTurnRequestSchema\n>;\nexport type RuntimePublicResult = z.infer<typeof RuntimePublicResultSchema>;\nexport type ExecutionHostStreamEvent = z.infer<\n typeof ExecutionHostStreamEventSchema\n>;\nexport type ExecutionHostTerminalEvent = Extract<\n ExecutionHostStreamEvent,\n { kind: 'result' | 'cancelled' | 'error' }\n>;\nexport type ExecutionAssertionClaims = z.infer<\n typeof ExecutionAssertionClaimsSchema\n>;\nexport type McpCapabilityClaims = z.infer<typeof McpCapabilityClaimsSchema>;\nexport type HostedExecutionWorkflow = typeof CONVERSATION_TURN_WORKFLOW;\n\nexport function isExecutionHostTerminalEvent(\n event: ExecutionHostStreamEvent,\n): event is ExecutionHostTerminalEvent {\n return event.kind === 'result'\n || event.kind === 'cancelled'\n || event.kind === 'error';\n}\n\nexport function isSafeWebUrl(url: URL): boolean {\n const loopback = ['127.0.0.1', '[::1]', 'localhost'].includes(url.hostname);\n return (url.protocol === 'https:' || (url.protocol === 'http:' && loopback))\n && !url.username\n && !url.password\n && !url.search\n && !url.hash;\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ExecutionHostTerminalEvent } from '../contracts/index.js';
|
|
2
|
+
import { type DurableHostedConversationTurnServiceConfig, type DurableHostedConversationTurnServiceOptions, type HostedConversationPersistenceScope, type HostedConversationTerminalProjection, type HostedConversationTurnLifecycleStore, type HostedConversationTurnReconciliationOptions } from './lifecycle-types.js';
|
|
3
|
+
import type { HostedConversationTurnRunner } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Applies one reusable durable lifecycle around an Execution Host turn.
|
|
6
|
+
*
|
|
7
|
+
* Requested state is written before execution starts. Accepted and terminal
|
|
8
|
+
* writes complete before their corresponding public events are released. A
|
|
9
|
+
* persistence failure therefore fails closed instead of acknowledging state
|
|
10
|
+
* that the adopter cannot later recover.
|
|
11
|
+
*/
|
|
12
|
+
export declare class DurableHostedConversationTurnService implements HostedConversationTurnRunner {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(config: DurableHostedConversationTurnServiceConfig, options?: DurableHostedConversationTurnServiceOptions);
|
|
15
|
+
streamTurn(rawInput: Parameters<HostedConversationTurnRunner['streamTurn']>[0]): ReturnType<HostedConversationTurnRunner['streamTurn']>;
|
|
16
|
+
/** Reconciles only expired open turns within one already-authorized scope. */
|
|
17
|
+
interruptExpiredTurns(scope: HostedConversationPersistenceScope): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export declare function interruptExpiredHostedConversationTurns(store: HostedConversationTurnLifecycleStore, scope: HostedConversationPersistenceScope, options?: HostedConversationTurnReconciliationOptions): Promise<void>;
|
|
20
|
+
export declare function projectHostedConversationTerminalEvent(event: ExecutionHostTerminalEvent, options?: {
|
|
21
|
+
maxSummaryCharacters?: number;
|
|
22
|
+
}): HostedConversationTerminalProjection;
|
|
23
|
+
//# sourceMappingURL=durable-hosted-conversation-turn-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"durable-hosted-conversation-turn-service.d.ts","sourceRoot":"","sources":["../../src/conversation/durable-hosted-conversation-turn-service.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,0BAA0B,EAChC,MAAM,uBAAuB,CAAC;AAO/B,OAAO,EAKL,KAAK,0CAA0C,EAC/C,KAAK,2CAA2C,EAEhD,KAAK,kCAAkC,EACvC,KAAK,oCAAoC,EAEzC,KAAK,oCAAoC,EACzC,KAAK,2CAA2C,EACjD,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,4BAA4B,EAC7B,MAAM,YAAY,CAAC;AAsBpB;;;;;;;GAOG;AACH,qBAAa,oCACb,YAAW,4BAA4B;;gBAQnC,MAAM,EAAE,0CAA0C,EAClD,OAAO,GAAE,2CAAgD;IAepD,UAAU,CACf,QAAQ,EAAE,UAAU,CAAC,4BAA4B,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,GAClE,UAAU,CAAC,4BAA4B,CAAC,YAAY,CAAC,CAAC;IA4GzD,8EAA8E;IAC9E,qBAAqB,CACnB,KAAK,EAAE,kCAAkC,GACxC,OAAO,CAAC,IAAI,CAAC;CAMjB;AAED,wBAAgB,uCAAuC,CACrD,KAAK,EAAE,oCAAoC,EAC3C,KAAK,EAAE,kCAAkC,EACzC,OAAO,GAAE,2CAAgD,GACxD,OAAO,CAAC,IAAI,CAAC,CAiBf;AAED,wBAAgB,sCAAsC,CACpD,KAAK,EAAE,0BAA0B,EACjC,OAAO,GAAE;IAAE,oBAAoB,CAAC,EAAE,MAAM,CAAA;CAAO,GAC9C,oCAAoC,CAQtC"}
|