@heddleagent/execution-host-client 6.4.0 → 6.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -4
- 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/errors.d.ts +23 -0
- package/dist/host/errors.d.ts.map +1 -0
- package/dist/host/errors.js +32 -0
- package/dist/host/errors.js.map +1 -0
- package/dist/host/index.d.ts +8 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +7 -0
- package/dist/host/index.js.map +1 -0
- package/dist/host/jwt-execution-host-mcp-capability-verifier.d.ts +8 -0
- package/dist/host/jwt-execution-host-mcp-capability-verifier.d.ts.map +1 -0
- package/dist/host/jwt-execution-host-mcp-capability-verifier.js +86 -0
- package/dist/host/jwt-execution-host-mcp-capability-verifier.js.map +1 -0
- package/dist/host/jwt-execution-identity-verifier.d.ts +8 -0
- package/dist/host/jwt-execution-identity-verifier.d.ts.map +1 -0
- package/dist/host/jwt-execution-identity-verifier.js +76 -0
- package/dist/host/jwt-execution-identity-verifier.js.map +1 -0
- 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/host/schemas.d.ts +37 -0
- package/dist/host/schemas.d.ts.map +1 -0
- package/dist/host/schemas.js +24 -0
- package/dist/host/schemas.js.map +1 -0
- package/dist/host/types.d.ts +62 -0
- package/dist/host/types.d.ts.map +1 -0
- package/dist/host/types.js +7 -0
- package/dist/host/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/internal/jwt-verification.d.ts +5 -0
- package/dist/internal/jwt-verification.d.ts.map +1 -0
- package/dist/internal/jwt-verification.js +25 -0
- package/dist/internal/jwt-verification.js.map +1 -0
- package/dist/mcp/jwt-capability-verifier.d.ts.map +1 -1
- package/dist/mcp/jwt-capability-verifier.js +6 -25
- package/dist/mcp/jwt-capability-verifier.js.map +1 -1
- 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 +10 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt-verification.js","sourceRoot":"","sources":["../../src/internal/jwt-verification.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,MAAM,GAEP,MAAM,MAAM,CAAC;AAEd,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC;IACxC,WAAW,EAAE,EAAE,GAAG,MAAM;IACxB,gBAAgB,EAAE,MAAM;IACxB,eAAe,EAAE,KAAK;CACvB,CAAC,CAAC;AAEH,MAAM,2BAA2B,GAAG,IAAI,GAAG,CAA6C;IACtF,CAAC,kBAAkB,EAAE,eAAe,CAAC;IACrC,CAAC,iBAAiB,EAAE,eAAe,CAAC;IACpC,CAAC,kBAAkB,EAAE,eAAe,CAAC;IACrC,CAAC,iCAAiC,EAAE,eAAe,CAAC;IACpD,CAAC,kBAAkB,EAAE,cAAc,CAAC;CACrC,CAAC,CAAC;AAOH,MAAM,UAAU,oBAAoB,CAAC,OAAY;IAC/C,OAAO,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,yCAAyC,CACvD,KAAc;IAEd,IAAI,KAAK,YAAY,SAAS,EAAE,CAAC;QAC/B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,KAAK,YAAY,MAAM,CAAC,SAAS;QACtC,CAAC,CAAC,2BAA2B,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;QAC7C,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC","sourcesContent":["import {\n createRemoteJWKSet,\n errors,\n type JWTVerifyGetKey,\n} from 'jose';\n\nconst REMOTE_JWKS_OPTIONS = Object.freeze({\n cacheMaxAge: 10 * 60_000,\n cooldownDuration: 30_000,\n timeoutDuration: 3_000,\n});\n\nconst UNAVAILABLE_JOSE_CATEGORIES = new Map<string, JwtVerificationUnavailableCategory>([\n ['ERR_JOSE_GENERIC', 'jwks_response'],\n ['ERR_JWK_INVALID', 'jwks_response'],\n ['ERR_JWKS_INVALID', 'jwks_response'],\n ['ERR_JWKS_MULTIPLE_MATCHING_KEYS', 'jwks_response'],\n ['ERR_JWKS_TIMEOUT', 'jwks_timeout'],\n]);\n\nexport type JwtVerificationUnavailableCategory =\n | 'network'\n | 'jwks_response'\n | 'jwks_timeout';\n\nexport function createJwtKeyResolver(jwksUrl: URL): JWTVerifyGetKey {\n return createRemoteJWKSet(jwksUrl, REMOTE_JWKS_OPTIONS);\n}\n\nexport function resolveJwtVerificationUnavailableCategory(\n error: unknown,\n): JwtVerificationUnavailableCategory | undefined {\n if (error instanceof TypeError) {\n return 'network';\n }\n return error instanceof errors.JOSEError\n ? UNAVAILABLE_JOSE_CATEGORIES.get(error.code)\n : undefined;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt-capability-verifier.d.ts","sourceRoot":"","sources":["../../src/mcp/jwt-capability-verifier.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EACV,8BAA8B,EAC9B,+BAA+B,EAC/B,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAqBpB;;;GAGG;AACH,qBAAa,wBAAwB,CAAC,SAAS,SAAS,MAAM,CAC9D,YAAW,qBAAqB,CAAC,SAAS,CAAC;;gBAOvC,MAAM,EAAE,8BAA8B,CAAC,SAAS,CAAC,EACjD,OAAO,GAAE,+BAAoC;
|
|
1
|
+
{"version":3,"file":"jwt-capability-verifier.d.ts","sourceRoot":"","sources":["../../src/mcp/jwt-capability-verifier.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EACV,8BAA8B,EAC9B,+BAA+B,EAC/B,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAqBpB;;;GAGG;AACH,qBAAa,wBAAwB,CAAC,SAAS,SAAS,MAAM,CAC9D,YAAW,qBAAqB,CAAC,SAAS,CAAC;;gBAOvC,MAAM,EAAE,8BAA8B,CAAC,SAAS,CAAC,EACjD,OAAO,GAAE,+BAAoC;IAczC,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;CAkF3E;AAED,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,qBAAqB,EACjC,GAAG,OAAa,GACf,IAAI,CAKN"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jwtVerify } from 'jose';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { JwtAudienceSchema, JwtIssuerSchema, MCP_CAPABILITY_TYPE, McpAllowedToolsSchema, McpCapabilityClaimsSchema, McpServerIdSchema, OpaqueIdSchema, isSafeWebUrl, } from '../contracts/index.js';
|
|
4
4
|
import { McpCapabilityUnavailableError, McpCapabilityVerificationError, } from './errors.js';
|
|
5
|
+
import { createJwtKeyResolver, resolveJwtVerificationUnavailableCategory, } from '../internal/jwt-verification.js';
|
|
5
6
|
const CapabilityAssertionSchema = z.string().min(32).max(4_096);
|
|
6
7
|
const ConfigSchema = z.object({
|
|
7
8
|
issuer: JwtIssuerSchema,
|
|
@@ -30,11 +31,8 @@ export class JwtMcpCapabilityVerifier {
|
|
|
30
31
|
supportedTools: Object.freeze([...parsed.supportedTools]),
|
|
31
32
|
});
|
|
32
33
|
this.#supportedTools = new Set(this.#config.supportedTools);
|
|
33
|
-
this.#keyResolver = options.keyResolver
|
|
34
|
-
|
|
35
|
-
cooldownDuration: 30_000,
|
|
36
|
-
timeoutDuration: 3_000,
|
|
37
|
-
});
|
|
34
|
+
this.#keyResolver = options.keyResolver
|
|
35
|
+
?? createJwtKeyResolver(this.#config.jwksUrl);
|
|
38
36
|
this.#now = options.now ?? (() => new Date());
|
|
39
37
|
}
|
|
40
38
|
async verify(assertion) {
|
|
@@ -76,9 +74,9 @@ export class JwtMcpCapabilityVerifier {
|
|
|
76
74
|
|| error instanceof McpCapabilityUnavailableError) {
|
|
77
75
|
throw error;
|
|
78
76
|
}
|
|
79
|
-
const unavailableCategory =
|
|
77
|
+
const unavailableCategory = resolveJwtVerificationUnavailableCategory(error);
|
|
80
78
|
if (unavailableCategory) {
|
|
81
|
-
throw new McpCapabilityUnavailableError(unavailableCategory);
|
|
79
|
+
throw new McpCapabilityUnavailableError(unavailableCategory === 'network' ? 'network' : 'jwks');
|
|
82
80
|
}
|
|
83
81
|
throw new McpCapabilityVerificationError();
|
|
84
82
|
}
|
|
@@ -116,21 +114,4 @@ function freezeVerifiedCapability(capability) {
|
|
|
116
114
|
scope: Object.freeze({ ...capability.scope }),
|
|
117
115
|
});
|
|
118
116
|
}
|
|
119
|
-
const UNAVAILABLE_JOSE_CODES = new Set([
|
|
120
|
-
'ERR_JOSE_GENERIC',
|
|
121
|
-
'ERR_JWK_INVALID',
|
|
122
|
-
'ERR_JWKS_INVALID',
|
|
123
|
-
'ERR_JWKS_MULTIPLE_MATCHING_KEYS',
|
|
124
|
-
'ERR_JWKS_TIMEOUT',
|
|
125
|
-
]);
|
|
126
|
-
function resolveUnavailableCategory(error) {
|
|
127
|
-
if (error instanceof TypeError) {
|
|
128
|
-
return 'network';
|
|
129
|
-
}
|
|
130
|
-
if (error instanceof errors.JOSEError
|
|
131
|
-
&& UNAVAILABLE_JOSE_CODES.has(error.code)) {
|
|
132
|
-
return 'jwks';
|
|
133
|
-
}
|
|
134
|
-
return undefined;
|
|
135
|
-
}
|
|
136
117
|
//# sourceMappingURL=jwt-capability-verifier.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt-capability-verifier.js","sourceRoot":"","sources":["../../src/mcp/jwt-capability-verifier.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,MAAM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C;QACnB,GAAG,UAAU;QACb,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;QACzD,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,UAAU,CAAC,KAAK,EAAE,CAAC;KAC9C,CAAC,CAAC;AACL,CAAC;AAED,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;IACrC,kBAAkB;IAClB,iBAAiB;IACjB,kBAAkB;IAClB,iCAAiC;IACjC,kBAAkB;CACnB,CAAC,CAAC;AAEH,SAAS,0BAA0B,CACjC,KAAc;IAEd,IAAI,KAAK,YAAY,SAAS,EAAE,CAAC;QAC/B,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IACE,KAAK,YAAY,MAAM,CAAC,SAAS;WAC9B,sBAAsB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EACzC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import {\n createRemoteJWKSet,\n errors,\n jwtVerify,\n} from 'jose';\nimport { z } from 'zod';\nimport {\n JwtAudienceSchema,\n JwtIssuerSchema,\n MCP_CAPABILITY_TYPE,\n McpAllowedToolsSchema,\n McpCapabilityClaimsSchema,\n McpServerIdSchema,\n OpaqueIdSchema,\n isSafeWebUrl,\n} from '../contracts/index.js';\nimport {\n McpCapabilityUnavailableError,\n McpCapabilityVerificationError,\n} from './errors.js';\nimport type {\n JwtMcpCapabilityVerifierConfig,\n JwtMcpCapabilityVerifierOptions,\n McpCapabilityVerifier,\n VerifiedMcpCapability,\n} from './types.js';\n\nconst CapabilityAssertionSchema = z.string().min(32).max(4_096);\nconst ConfigSchema = z.object({\n issuer: JwtIssuerSchema,\n audience: JwtAudienceSchema,\n jwksUrl: z.instanceof(URL).refine(\n isSafeWebUrl,\n 'must use HTTPS or loopback HTTP and contain no credentials, query, or fragment',\n ),\n trustedAdopterId: OpaqueIdSchema,\n serverId: McpServerIdSchema,\n supportedTools: McpAllowedToolsSchema,\n maxCapabilityAgeSeconds: z.number().int().min(1).max(15 * 60),\n clockToleranceSeconds: z.number().int().min(0).max(60).default(5),\n}).strict();\n\ntype ParsedConfig = Omit<z.infer<typeof ConfigSchema>, 'supportedTools'> & {\n supportedTools: readonly string[];\n};\n\n/**\n * Independently verifies an adopter-signed capability at the adopter's MCP\n * edge. Execution Host verification is defense in depth, not forwarded trust.\n */\nexport class JwtMcpCapabilityVerifier<TToolName extends string>\nimplements McpCapabilityVerifier<TToolName> {\n readonly #config: Readonly<ParsedConfig>;\n readonly #supportedTools: ReadonlySet<string>;\n readonly #keyResolver: NonNullable<JwtMcpCapabilityVerifierOptions['keyResolver']>;\n readonly #now: () => Date;\n\n constructor(\n config: JwtMcpCapabilityVerifierConfig<TToolName>,\n options: JwtMcpCapabilityVerifierOptions = {},\n ) {\n const parsed = ConfigSchema.parse(config);\n this.#config = Object.freeze({\n ...parsed,\n jwksUrl: new URL(parsed.jwksUrl),\n supportedTools: Object.freeze([...parsed.supportedTools]),\n });\n this.#supportedTools = new Set(this.#config.supportedTools);\n this.#keyResolver = options.keyResolver ?? createRemoteJWKSet(\n this.#config.jwksUrl,\n {\n cacheMaxAge: 10 * 60_000,\n cooldownDuration: 30_000,\n timeoutDuration: 3_000,\n },\n );\n this.#now = options.now ?? (() => new Date());\n }\n\n async verify(assertion: string): Promise<VerifiedMcpCapability<TToolName>> {\n try {\n const compactJwt = CapabilityAssertionSchema.parse(assertion);\n const { payload } = await jwtVerify(compactJwt, this.#keyResolver, {\n algorithms: ['ES256'],\n audience: this.#config.audience,\n clockTolerance: this.#config.clockToleranceSeconds,\n currentDate: this.#now(),\n issuer: this.#config.issuer,\n maxTokenAge: this.#config.maxCapabilityAgeSeconds,\n requiredClaims: ['exp', 'iat', 'jti', 'sub'],\n typ: MCP_CAPABILITY_TYPE,\n });\n const claims = McpCapabilityClaimsSchema.parse(payload);\n this.#assertDeploymentBinding(claims);\n this.#assertBoundedLifetime(claims);\n this.#assertSupportedTools(claims.allowedTools);\n\n return freezeVerifiedCapability({\n capabilityId: claims.jti,\n serverId: claims.serverId,\n allowedTools: claims.allowedTools as TToolName[],\n scope: {\n adopterId: claims.adopterId,\n tenantId: claims.tenantId,\n subjectId: claims.sub,\n productSessionId: claims.productSessionId,\n runtimeSessionId: claims.runtimeSessionId,\n invocationId: claims.invocationId,\n workflow: claims.workflow,\n },\n issuedAt: new Date(claims.iat * 1_000).toISOString(),\n expiresAt: new Date(claims.exp * 1_000).toISOString(),\n });\n } catch (error) {\n if (\n error instanceof McpCapabilityVerificationError\n || error instanceof McpCapabilityUnavailableError\n ) {\n throw error;\n }\n const unavailableCategory = resolveUnavailableCategory(error);\n if (unavailableCategory) {\n throw new McpCapabilityUnavailableError(unavailableCategory);\n }\n throw new McpCapabilityVerificationError();\n }\n }\n\n #assertDeploymentBinding(\n claims: z.infer<typeof McpCapabilityClaimsSchema>,\n ): void {\n if (\n claims.adopterId !== this.#config.trustedAdopterId\n || claims.serverId !== this.#config.serverId\n || claims.jti === claims.invocationId\n ) {\n throw new McpCapabilityVerificationError();\n }\n }\n\n #assertBoundedLifetime(\n claims: z.infer<typeof McpCapabilityClaimsSchema>,\n ): void {\n const lifetimeSeconds = claims.exp - claims.iat;\n if (\n lifetimeSeconds <= 0\n || lifetimeSeconds > this.#config.maxCapabilityAgeSeconds\n ) {\n throw new McpCapabilityVerificationError();\n }\n }\n\n #assertSupportedTools(tools: readonly string[]): void {\n if (!tools.every((tool) => this.#supportedTools.has(tool))) {\n throw new McpCapabilityVerificationError();\n }\n }\n}\n\nexport function assertMcpCapabilityActive(\n capability: VerifiedMcpCapability,\n now = new Date(),\n): void {\n const expiresAt = Date.parse(capability.expiresAt);\n if (!Number.isFinite(expiresAt) || now.getTime() >= expiresAt) {\n throw new McpCapabilityVerificationError();\n }\n}\n\nfunction freezeVerifiedCapability<TToolName extends string>(\n capability: VerifiedMcpCapability<TToolName>,\n): VerifiedMcpCapability<TToolName> {\n return Object.freeze({\n ...capability,\n allowedTools: Object.freeze([...capability.allowedTools]),\n scope: Object.freeze({ ...capability.scope }),\n });\n}\n\nconst UNAVAILABLE_JOSE_CODES = new Set([\n 'ERR_JOSE_GENERIC',\n 'ERR_JWK_INVALID',\n 'ERR_JWKS_INVALID',\n 'ERR_JWKS_MULTIPLE_MATCHING_KEYS',\n 'ERR_JWKS_TIMEOUT',\n]);\n\nfunction resolveUnavailableCategory(\n error: unknown,\n): 'network' | 'jwks' | undefined {\n if (error instanceof TypeError) {\n return 'network';\n }\n if (\n error instanceof errors.JOSEError\n && UNAVAILABLE_JOSE_CODES.has(error.code)\n ) {\n return 'jwks';\n }\n return undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"jwt-capability-verifier.js","sourceRoot":"","sources":["../../src/mcp/jwt-capability-verifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,yBAAyB,EACzB,iBAAiB,EACjB,cAAc,EACd,YAAY,GACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,6BAA6B,EAC7B,8BAA8B,GAC/B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,oBAAoB,EACpB,yCAAyC,GAC1C,MAAM,iCAAiC,CAAC;AAQzC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAChE,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,MAAM,EAAE,eAAe;IACvB,QAAQ,EAAE,iBAAiB;IAC3B,OAAO,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,CAC/B,YAAY,EACZ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IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YAC3D,MAAM,IAAI,8BAA8B,EAAE,CAAC;QAC7C,CAAC;IACH,CAAC;CACF;AAED,MAAM,UAAU,yBAAyB,CACvC,UAAiC,EACjC,GAAG,GAAG,IAAI,IAAI,EAAE;IAEhB,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACnD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,IAAI,SAAS,EAAE,CAAC;QAC9D,MAAM,IAAI,8BAA8B,EAAE,CAAC;IAC7C,CAAC;AACH,CAAC;AAED,SAAS,wBAAwB,CAC/B,UAA4C;IAE5C,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,GAAG,UAAU;QACb,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;QACzD,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,UAAU,CAAC,KAAK,EAAE,CAAC;KAC9C,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { jwtVerify } from 'jose';\nimport { z } from 'zod';\nimport {\n JwtAudienceSchema,\n JwtIssuerSchema,\n MCP_CAPABILITY_TYPE,\n McpAllowedToolsSchema,\n McpCapabilityClaimsSchema,\n McpServerIdSchema,\n OpaqueIdSchema,\n isSafeWebUrl,\n} from '../contracts/index.js';\nimport {\n McpCapabilityUnavailableError,\n McpCapabilityVerificationError,\n} from './errors.js';\nimport {\n createJwtKeyResolver,\n resolveJwtVerificationUnavailableCategory,\n} from '../internal/jwt-verification.js';\nimport type {\n JwtMcpCapabilityVerifierConfig,\n JwtMcpCapabilityVerifierOptions,\n McpCapabilityVerifier,\n VerifiedMcpCapability,\n} from './types.js';\n\nconst CapabilityAssertionSchema = z.string().min(32).max(4_096);\nconst ConfigSchema = z.object({\n issuer: JwtIssuerSchema,\n audience: JwtAudienceSchema,\n jwksUrl: z.instanceof(URL).refine(\n isSafeWebUrl,\n 'must use HTTPS or loopback HTTP and contain no credentials, query, or fragment',\n ),\n trustedAdopterId: OpaqueIdSchema,\n serverId: McpServerIdSchema,\n supportedTools: McpAllowedToolsSchema,\n maxCapabilityAgeSeconds: z.number().int().min(1).max(15 * 60),\n clockToleranceSeconds: z.number().int().min(0).max(60).default(5),\n}).strict();\n\ntype ParsedConfig = Omit<z.infer<typeof ConfigSchema>, 'supportedTools'> & {\n supportedTools: readonly string[];\n};\n\n/**\n * Independently verifies an adopter-signed capability at the adopter's MCP\n * edge. Execution Host verification is defense in depth, not forwarded trust.\n */\nexport class JwtMcpCapabilityVerifier<TToolName extends string>\nimplements McpCapabilityVerifier<TToolName> {\n readonly #config: Readonly<ParsedConfig>;\n readonly #supportedTools: ReadonlySet<string>;\n readonly #keyResolver: NonNullable<JwtMcpCapabilityVerifierOptions['keyResolver']>;\n readonly #now: () => Date;\n\n constructor(\n config: JwtMcpCapabilityVerifierConfig<TToolName>,\n options: JwtMcpCapabilityVerifierOptions = {},\n ) {\n const parsed = ConfigSchema.parse(config);\n this.#config = Object.freeze({\n ...parsed,\n jwksUrl: new URL(parsed.jwksUrl),\n supportedTools: Object.freeze([...parsed.supportedTools]),\n });\n this.#supportedTools = new Set(this.#config.supportedTools);\n this.#keyResolver = options.keyResolver\n ?? createJwtKeyResolver(this.#config.jwksUrl);\n this.#now = options.now ?? (() => new Date());\n }\n\n async verify(assertion: string): Promise<VerifiedMcpCapability<TToolName>> {\n try {\n const compactJwt = CapabilityAssertionSchema.parse(assertion);\n const { payload } = await jwtVerify(compactJwt, this.#keyResolver, {\n algorithms: ['ES256'],\n audience: this.#config.audience,\n clockTolerance: this.#config.clockToleranceSeconds,\n currentDate: this.#now(),\n issuer: this.#config.issuer,\n maxTokenAge: this.#config.maxCapabilityAgeSeconds,\n requiredClaims: ['exp', 'iat', 'jti', 'sub'],\n typ: MCP_CAPABILITY_TYPE,\n });\n const claims = McpCapabilityClaimsSchema.parse(payload);\n this.#assertDeploymentBinding(claims);\n this.#assertBoundedLifetime(claims);\n this.#assertSupportedTools(claims.allowedTools);\n\n return freezeVerifiedCapability({\n capabilityId: claims.jti,\n serverId: claims.serverId,\n allowedTools: claims.allowedTools as TToolName[],\n scope: {\n adopterId: claims.adopterId,\n tenantId: claims.tenantId,\n subjectId: claims.sub,\n productSessionId: claims.productSessionId,\n runtimeSessionId: claims.runtimeSessionId,\n invocationId: claims.invocationId,\n workflow: claims.workflow,\n },\n issuedAt: new Date(claims.iat * 1_000).toISOString(),\n expiresAt: new Date(claims.exp * 1_000).toISOString(),\n });\n } catch (error) {\n if (\n error instanceof McpCapabilityVerificationError\n || error instanceof McpCapabilityUnavailableError\n ) {\n throw error;\n }\n const unavailableCategory = resolveJwtVerificationUnavailableCategory(\n error,\n );\n if (unavailableCategory) {\n throw new McpCapabilityUnavailableError(\n unavailableCategory === 'network' ? 'network' : 'jwks',\n );\n }\n throw new McpCapabilityVerificationError();\n }\n }\n\n #assertDeploymentBinding(\n claims: z.infer<typeof McpCapabilityClaimsSchema>,\n ): void {\n if (\n claims.adopterId !== this.#config.trustedAdopterId\n || claims.serverId !== this.#config.serverId\n || claims.jti === claims.invocationId\n ) {\n throw new McpCapabilityVerificationError();\n }\n }\n\n #assertBoundedLifetime(\n claims: z.infer<typeof McpCapabilityClaimsSchema>,\n ): void {\n const lifetimeSeconds = claims.exp - claims.iat;\n if (\n lifetimeSeconds <= 0\n || lifetimeSeconds > this.#config.maxCapabilityAgeSeconds\n ) {\n throw new McpCapabilityVerificationError();\n }\n }\n\n #assertSupportedTools(tools: readonly string[]): void {\n if (!tools.every((tool) => this.#supportedTools.has(tool))) {\n throw new McpCapabilityVerificationError();\n }\n }\n}\n\nexport function assertMcpCapabilityActive(\n capability: VerifiedMcpCapability,\n now = new Date(),\n): void {\n const expiresAt = Date.parse(capability.expiresAt);\n if (!Number.isFinite(expiresAt) || now.getTime() >= expiresAt) {\n throw new McpCapabilityVerificationError();\n }\n}\n\nfunction freezeVerifiedCapability<TToolName extends string>(\n capability: VerifiedMcpCapability<TToolName>,\n): VerifiedMcpCapability<TToolName> {\n return Object.freeze({\n ...capability,\n allowedTools: Object.freeze([...capability.allowedTools]),\n scope: Object.freeze({ ...capability.scope }),\n });\n}\n"]}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
2
|
import type { NodeExecutionAdopterHttpHandler, NodeExecutionAdopterHttpServiceConfig } from './types.js';
|
|
3
|
-
export declare const DEFAULT_ADOPTER_JWKS_PATH = "/.well-known/jwks.json";
|
|
4
|
-
export declare const DEFAULT_ADOPTER_CONVERSATION_TURNS_PATH = "/hosted-execution/conversation-turns";
|
|
5
3
|
/**
|
|
6
4
|
* Standard Node HTTP edge for adopter-side JWKS and hosted conversations.
|
|
7
5
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-service.d.ts","sourceRoot":"","sources":["../../src/node/http-service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACf,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"http-service.d.ts","sourceRoot":"","sources":["../../src/node/http-service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACf,MAAM,WAAW,CAAC;AAkBnB,OAAO,KAAK,EAEV,+BAA+B,EAE/B,qCAAqC,EAEtC,MAAM,YAAY,CAAC;AAgBpB;;;;;;;GAOG;AACH,qBAAa,+BAA+B,CAAC,SAAS,CACtD,YAAW,+BAA+B;;gBAwB5B,MAAM,EAAE,qCAAqC,CAAC,SAAS,CAAC;IAkBpE,MAAM,CAAC,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,cAAc,GAAG,OAAO;IAanE,UAAU,CAAC,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,cAAc,GAAG,IAAI;IAwBpE,sBAAsB,CACpB,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,cAAc,GACvB,IAAI;IA0CP,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAmJvB"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { once } from 'node:events';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
+
import { DEFAULT_ADOPTER_CONVERSATION_TURNS_PATH, DEFAULT_ADOPTER_JWKS_PATH, } from '../adopter/index.js';
|
|
3
4
|
import { ExecutionHostStreamEventSchema } from '../contracts/index.js';
|
|
4
5
|
import { ExecutionHostInvocationCancelledError } from '../http-sse/index.js';
|
|
5
6
|
import { NodeHttpPathSchema, NodeHttpRequestError, errorType, readJsonBody, readPathname, takeAuthorization, writeJson, writeJsonError, } from './http-utils.js';
|
|
6
|
-
export const DEFAULT_ADOPTER_JWKS_PATH = '/.well-known/jwks.json';
|
|
7
|
-
export const DEFAULT_ADOPTER_CONVERSATION_TURNS_PATH = '/hosted-execution/conversation-turns';
|
|
8
7
|
const DEFAULT_MAX_BODY_BYTES = 64 * 1_024;
|
|
9
8
|
const DEFAULT_MAX_PROMPT_CHARACTERS = 20_000;
|
|
10
9
|
const PublicErrorSchema = z.object({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-service.js","sourceRoot":"","sources":["../../src/node/http-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAKnC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,qCAAqC,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,iBA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CAAC;AAED,SAAS,uBAAuB,CAAC,QAAwB;IACvD,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE;QACtB,eAAe,EAAE,UAAU;QAC3B,cAAc,EAAE,kCAAkC;QAClD,UAAU,EAAE,YAAY;QACxB,mBAAmB,EAAE,IAAI;QACzB,wBAAwB,EAAE,SAAS;KACpC,CAAC,CAAC;AACL,CAAC;AAED,KAAK,UAAU,aAAa,CAC1B,QAAwB,EACxB,KAAqD,EACrD,MAAmB;IAEnB,MAAM,KAAK,GAAG;QACZ,UAAU,KAAK,CAAC,IAAI,EAAE;QACtB,OAAO,KAAK,CAAC,QAAQ,EAAE;QACvB,SAAS,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;QAChC,EAAE;QACF,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACb,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC","sourcesContent":["import { once } from 'node:events';\nimport type {\n IncomingMessage,\n ServerResponse,\n} from 'node:http';\nimport { z } from 'zod';\nimport { ExecutionHostStreamEventSchema } from '../contracts/index.js';\nimport { ExecutionHostInvocationCancelledError } from '../http-sse/index.js';\nimport {\n NodeHttpPathSchema,\n NodeHttpRequestError,\n errorType,\n readJsonBody,\n readPathname,\n takeAuthorization,\n writeJson,\n writeJsonError,\n} from './http-utils.js';\nimport type {\n NodeExecutionAdopterFailure,\n NodeExecutionAdopterHttpHandler,\n NodeExecutionAdopterHttpPaths,\n NodeExecutionAdopterHttpServiceConfig,\n NodeExecutionAdopterPublicError,\n} from './types.js';\n\nexport const DEFAULT_ADOPTER_JWKS_PATH = '/.well-known/jwks.json';\nexport const DEFAULT_ADOPTER_CONVERSATION_TURNS_PATH =\n '/hosted-execution/conversation-turns';\n\nconst DEFAULT_MAX_BODY_BYTES = 64 * 1_024;\nconst DEFAULT_MAX_PROMPT_CHARACTERS = 20_000;\nconst PublicErrorSchema = z.object({\n statusCode: z.number().int().min(400).max(599),\n message: z.string().min(1).max(1_600),\n}).strict();\n\ntype ActiveConversation = {\n abortController: AbortController;\n request: IncomingMessage;\n response: ServerResponse;\n pending: Promise<void>;\n};\n\n/**\n * Standard Node HTTP edge for adopter-side JWKS and hosted conversations.\n *\n * The service owns bounded parsing, credential-header scrubbing, SSE framing,\n * disconnect cancellation, safe failures, and graceful shutdown. Product\n * authentication, authorization, identity selection, and persistence stay in\n * adopter callbacks.\n */\nexport class NodeExecutionAdopterHttpService<Principal>\nimplements NodeExecutionAdopterHttpHandler {\n readonly #authority: NodeExecutionAdopterHttpServiceConfig<Principal>[\n 'authority'\n ];\n readonly #authenticator: NodeExecutionAdopterHttpServiceConfig<Principal>[\n 'authenticator'\n ];\n readonly #conversations: NodeExecutionAdopterHttpServiceConfig<\n Principal\n >['conversations'];\n readonly #projectError: NodeExecutionAdopterHttpServiceConfig<Principal>[\n 'projectError'\n ];\n readonly #reportFailure: NodeExecutionAdopterHttpServiceConfig<Principal>[\n 'reportFailure'\n ];\n readonly #paths: Readonly<NodeExecutionAdopterHttpPaths>;\n readonly #maxBodyBytes: number;\n readonly #maxPromptCharacters: number;\n readonly #jwksMaxAgeSeconds: number;\n readonly #activeConversations = new Set<ActiveConversation>();\n #closed = false;\n #closePromise: Promise<void> | undefined;\n\n constructor(config: NodeExecutionAdopterHttpServiceConfig<Principal>) {\n this.#authority = config.authority;\n this.#authenticator = config.authenticator;\n this.#conversations = config.conversations;\n this.#projectError = config.projectError;\n this.#reportFailure = config.reportFailure;\n this.#paths = parsePaths(config.paths);\n this.#maxBodyBytes = z.number().int().min(1).max(1_048_576).parse(\n config.maxBodyBytes ?? DEFAULT_MAX_BODY_BYTES,\n );\n this.#maxPromptCharacters = z.number().int().min(1).max(200_000).parse(\n config.maxPromptCharacters ?? DEFAULT_MAX_PROMPT_CHARACTERS,\n );\n this.#jwksMaxAgeSeconds = z.number().int().min(0).max(86_400).parse(\n config.jwksMaxAgeSeconds ?? 60,\n );\n }\n\n handle(request: IncomingMessage, response: ServerResponse): boolean {\n const pathname = readPathname(request.url);\n if (pathname === this.#paths.jwks) {\n this.handleJwks(request, response);\n return true;\n }\n if (pathname === this.#paths.conversationTurns) {\n this.handleConversationTurn(request, response);\n return true;\n }\n return false;\n }\n\n handleJwks(request: IncomingMessage, response: ServerResponse): void {\n request.resume();\n if (this.#closed) {\n writeJsonError(response, 503, 'Hosted execution is unavailable.');\n return;\n }\n if (request.method !== 'GET') {\n writeJsonError(response, 405, 'Method not allowed.');\n return;\n }\n try {\n writeJson(response, 200, this.#authority.publicJwks(), {\n 'Cache-Control': `public, max-age=${this.#jwksMaxAgeSeconds}`,\n });\n } catch (error) {\n this.#report({\n phase: 'jwks',\n errorType: errorType(error),\n streamAccepted: false,\n });\n writeJsonError(response, 500, 'Verification keys are unavailable.');\n }\n }\n\n handleConversationTurn(\n request: IncomingMessage,\n response: ServerResponse,\n ): void {\n if (this.#closed) {\n request.resume();\n writeJsonError(response, 503, 'Hosted execution is unavailable.');\n return;\n }\n\n const abortController = new AbortController();\n const abort = () => abortController.abort(\n new Error('The owning adopter HTTP request closed.'),\n );\n request.once('aborted', abort);\n response.once('close', abort);\n const active: ActiveConversation = {\n abortController,\n request,\n response,\n pending: Promise.resolve(),\n };\n active.pending = this.#serveConversation(\n request,\n response,\n abortController.signal,\n ).catch((error) => {\n this.#report({\n phase: 'conversation',\n errorType: errorType(error),\n streamAccepted: response.headersSent,\n });\n if (!response.headersSent) {\n writeJsonError(response, 500, 'Hosted execution request failed.');\n } else if (!response.destroyed && !response.writableEnded) {\n response.end();\n }\n }).finally(() => {\n request.removeListener('aborted', abort);\n response.removeListener('close', abort);\n this.#activeConversations.delete(active);\n });\n this.#activeConversations.add(active);\n }\n\n close(): Promise<void> {\n if (!this.#closePromise) {\n this.#closed = true;\n this.#closePromise = this.#closeActiveConversations();\n }\n return this.#closePromise;\n }\n\n async #closeActiveConversations(): Promise<void> {\n const active = [...this.#activeConversations];\n active.forEach(({ abortController, request, response }) => {\n abortController.abort(new Error('The adopter HTTP service is stopping.'));\n request.destroy();\n response.destroy();\n });\n await Promise.allSettled(active.map(({ pending }) => pending));\n }\n\n async #serveConversation(\n request: IncomingMessage,\n response: ServerResponse,\n signal: AbortSignal,\n ): Promise<void> {\n let authorization: string | undefined;\n try {\n authorization = takeAuthorization(request);\n if (request.method !== 'POST') {\n request.resume();\n writeJsonError(response, 405, 'Method not allowed.');\n return;\n }\n } catch (error) {\n request.resume();\n writeJsonError(\n response,\n error instanceof NodeHttpRequestError ? error.statusCode : 400,\n 'Invalid conversation request.',\n );\n return;\n }\n\n let principal: Principal | undefined;\n try {\n principal = await this.#authenticator.authenticate({\n authorization,\n remoteAddress: request.socket.remoteAddress,\n signal,\n });\n } catch (error) {\n this.#report({\n phase: 'authentication',\n errorType: errorType(error),\n streamAccepted: false,\n });\n request.resume();\n writeJsonError(response, 500, 'Authentication could not be completed.');\n return;\n }\n if (!principal) {\n request.resume();\n writeJsonError(response, 401, 'Authentication is required.', {\n 'WWW-Authenticate': 'Bearer',\n });\n return;\n }\n\n let prompt: string;\n try {\n const body = await readJsonBody(request, this.#maxBodyBytes, signal);\n prompt = z.object({\n prompt: z.string().trim().min(1).max(this.#maxPromptCharacters),\n }).strict().parse(body).prompt;\n } catch (error) {\n const statusCode = error instanceof NodeHttpRequestError\n ? error.statusCode\n : 400;\n writeJsonError(response, statusCode, 'Invalid conversation request.');\n return;\n }\n\n let streamed = false;\n try {\n for await (const rawEvent of this.#conversations.streamTurn({\n principal,\n prompt,\n signal,\n })) {\n const event = ExecutionHostStreamEventSchema.parse(rawEvent);\n if (!streamed) {\n writeEventStreamHeaders(response);\n streamed = true;\n }\n await writeSseEvent(response, event, signal);\n }\n if (!streamed) {\n writeJsonError(response, 502, 'Execution Host returned no events.');\n return;\n }\n response.end();\n } catch (error) {\n const publicError = !streamed ? this.#project(error) : undefined;\n if (publicError) {\n writeJsonError(response, publicError.statusCode, publicError.message);\n return;\n }\n if (\n error instanceof ExecutionHostInvocationCancelledError\n || signal.aborted\n ) {\n if (!response.headersSent && !response.destroyed) {\n writeJsonError(response, 499, 'Hosted conversation was cancelled.');\n }\n return;\n }\n this.#report({\n phase: 'conversation',\n errorType: errorType(error),\n streamAccepted: streamed,\n });\n if (!response.headersSent) {\n writeJsonError(response, 502, 'Execution Host conversation failed.');\n } else if (!response.destroyed && !response.writableEnded) {\n // A post-acceptance failure deliberately ends without a terminal event.\n response.end();\n }\n }\n }\n\n #project(error: unknown): NodeExecutionAdopterPublicError | undefined {\n if (!this.#projectError) {\n return undefined;\n }\n try {\n const projected = this.#projectError(error);\n return projected ? PublicErrorSchema.parse(projected) : undefined;\n } catch {\n return undefined;\n }\n }\n\n #report(failure: NodeExecutionAdopterFailure): void {\n try {\n this.#reportFailure?.(Object.freeze({ ...failure }));\n } catch {\n // Observability must not change request settlement.\n }\n }\n}\n\nfunction parsePaths(\n paths: Partial<NodeExecutionAdopterHttpPaths> | undefined,\n): Readonly<NodeExecutionAdopterHttpPaths> {\n const parsed = {\n jwks: NodeHttpPathSchema.parse(paths?.jwks ?? DEFAULT_ADOPTER_JWKS_PATH),\n conversationTurns: NodeHttpPathSchema.parse(\n paths?.conversationTurns ?? DEFAULT_ADOPTER_CONVERSATION_TURNS_PATH,\n ),\n };\n if (parsed.jwks === parsed.conversationTurns) {\n throw new Error('Adopter HTTP paths must be distinct.');\n }\n return Object.freeze(parsed);\n}\n\nfunction writeEventStreamHeaders(response: ServerResponse): void {\n response.writeHead(200, {\n 'Cache-Control': 'no-store',\n 'Content-Type': 'text/event-stream; charset=utf-8',\n Connection: 'keep-alive',\n 'X-Accel-Buffering': 'no',\n 'X-Content-Type-Options': 'nosniff',\n });\n}\n\nasync function writeSseEvent(\n response: ServerResponse,\n event: z.infer<typeof ExecutionHostStreamEventSchema>,\n signal: AbortSignal,\n): Promise<void> {\n const frame = [\n `event: ${event.kind}`,\n `id: ${event.sequence}`,\n `data: ${JSON.stringify(event)}`,\n '',\n '',\n ].join('\\n');\n if (!response.write(frame)) {\n await once(response, 'drain', { signal });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"http-service.js","sourceRoot":"","sources":["../../src/node/http-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAKnC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,uCAAuC,EACvC,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,qCAAqC,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,cAAc,GACf,MAAM,iBAAiB,CAAC;AASzB,MAAM,sBAAsB,GAAG,EAAE,GAAG,KAAK,CAAC;AAC1C,MAAM,6BAA6B,GAAG,MAAM,CAAC;AAC7C,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAC9C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;CACtC,CAAC,CAAC,MAAM,EAAE,CAAC;AASZ;;;;;;;GAOG;AACH,MAAM,OAAO,+BAA+B;IAEjC,UAAU,CAEjB;IACO,cAAc,CAErB;IACO,cAAc,CAEJ;IACV,aAAa,CAEpB;IACO,cAAc,CAErB;IACO,MAAM,CAA0C;IAChD,aAAa,CAAS;IACtB,oBAAoB,CAAS;IAC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nimport { z } from 'zod';\nimport {\n DEFAULT_ADOPTER_CONVERSATION_TURNS_PATH,\n DEFAULT_ADOPTER_JWKS_PATH,\n} from '../adopter/index.js';\nimport { ExecutionHostStreamEventSchema } from '../contracts/index.js';\nimport { ExecutionHostInvocationCancelledError } from '../http-sse/index.js';\nimport {\n NodeHttpPathSchema,\n NodeHttpRequestError,\n errorType,\n readJsonBody,\n readPathname,\n takeAuthorization,\n writeJson,\n writeJsonError,\n} from './http-utils.js';\nimport type {\n NodeExecutionAdopterFailure,\n NodeExecutionAdopterHttpHandler,\n NodeExecutionAdopterHttpPaths,\n NodeExecutionAdopterHttpServiceConfig,\n NodeExecutionAdopterPublicError,\n} from './types.js';\n\nconst DEFAULT_MAX_BODY_BYTES = 64 * 1_024;\nconst DEFAULT_MAX_PROMPT_CHARACTERS = 20_000;\nconst PublicErrorSchema = z.object({\n statusCode: z.number().int().min(400).max(599),\n message: z.string().min(1).max(1_600),\n}).strict();\n\ntype ActiveConversation = {\n abortController: AbortController;\n request: IncomingMessage;\n response: ServerResponse;\n pending: Promise<void>;\n};\n\n/**\n * Standard Node HTTP edge for adopter-side JWKS and hosted conversations.\n *\n * The service owns bounded parsing, credential-header scrubbing, SSE framing,\n * disconnect cancellation, safe failures, and graceful shutdown. Product\n * authentication, authorization, identity selection, and persistence stay in\n * adopter callbacks.\n */\nexport class NodeExecutionAdopterHttpService<Principal>\nimplements NodeExecutionAdopterHttpHandler {\n readonly #authority: NodeExecutionAdopterHttpServiceConfig<Principal>[\n 'authority'\n ];\n readonly #authenticator: NodeExecutionAdopterHttpServiceConfig<Principal>[\n 'authenticator'\n ];\n readonly #conversations: NodeExecutionAdopterHttpServiceConfig<\n Principal\n >['conversations'];\n readonly #projectError: NodeExecutionAdopterHttpServiceConfig<Principal>[\n 'projectError'\n ];\n readonly #reportFailure: NodeExecutionAdopterHttpServiceConfig<Principal>[\n 'reportFailure'\n ];\n readonly #paths: Readonly<NodeExecutionAdopterHttpPaths>;\n readonly #maxBodyBytes: number;\n readonly #maxPromptCharacters: number;\n readonly #jwksMaxAgeSeconds: number;\n readonly #activeConversations = new Set<ActiveConversation>();\n #closed = false;\n #closePromise: Promise<void> | undefined;\n\n constructor(config: NodeExecutionAdopterHttpServiceConfig<Principal>) {\n this.#authority = config.authority;\n this.#authenticator = config.authenticator;\n this.#conversations = config.conversations;\n this.#projectError = config.projectError;\n this.#reportFailure = config.reportFailure;\n this.#paths = parsePaths(config.paths);\n this.#maxBodyBytes = z.number().int().min(1).max(1_048_576).parse(\n config.maxBodyBytes ?? DEFAULT_MAX_BODY_BYTES,\n );\n this.#maxPromptCharacters = z.number().int().min(1).max(200_000).parse(\n config.maxPromptCharacters ?? DEFAULT_MAX_PROMPT_CHARACTERS,\n );\n this.#jwksMaxAgeSeconds = z.number().int().min(0).max(86_400).parse(\n config.jwksMaxAgeSeconds ?? 60,\n );\n }\n\n handle(request: IncomingMessage, response: ServerResponse): boolean {\n const pathname = readPathname(request.url);\n if (pathname === this.#paths.jwks) {\n this.handleJwks(request, response);\n return true;\n }\n if (pathname === this.#paths.conversationTurns) {\n this.handleConversationTurn(request, response);\n return true;\n }\n return false;\n }\n\n handleJwks(request: IncomingMessage, response: ServerResponse): void {\n request.resume();\n if (this.#closed) {\n writeJsonError(response, 503, 'Hosted execution is unavailable.');\n return;\n }\n if (request.method !== 'GET') {\n writeJsonError(response, 405, 'Method not allowed.');\n return;\n }\n try {\n writeJson(response, 200, this.#authority.publicJwks(), {\n 'Cache-Control': `public, max-age=${this.#jwksMaxAgeSeconds}`,\n });\n } catch (error) {\n this.#report({\n phase: 'jwks',\n errorType: errorType(error),\n streamAccepted: false,\n });\n writeJsonError(response, 500, 'Verification keys are unavailable.');\n }\n }\n\n handleConversationTurn(\n request: IncomingMessage,\n response: ServerResponse,\n ): void {\n if (this.#closed) {\n request.resume();\n writeJsonError(response, 503, 'Hosted execution is unavailable.');\n return;\n }\n\n const abortController = new AbortController();\n const abort = () => abortController.abort(\n new Error('The owning adopter HTTP request closed.'),\n );\n request.once('aborted', abort);\n response.once('close', abort);\n const active: ActiveConversation = {\n abortController,\n request,\n response,\n pending: Promise.resolve(),\n };\n active.pending = this.#serveConversation(\n request,\n response,\n abortController.signal,\n ).catch((error) => {\n this.#report({\n phase: 'conversation',\n errorType: errorType(error),\n streamAccepted: response.headersSent,\n });\n if (!response.headersSent) {\n writeJsonError(response, 500, 'Hosted execution request failed.');\n } else if (!response.destroyed && !response.writableEnded) {\n response.end();\n }\n }).finally(() => {\n request.removeListener('aborted', abort);\n response.removeListener('close', abort);\n this.#activeConversations.delete(active);\n });\n this.#activeConversations.add(active);\n }\n\n close(): Promise<void> {\n if (!this.#closePromise) {\n this.#closed = true;\n this.#closePromise = this.#closeActiveConversations();\n }\n return this.#closePromise;\n }\n\n async #closeActiveConversations(): Promise<void> {\n const active = [...this.#activeConversations];\n active.forEach(({ abortController, request, response }) => {\n abortController.abort(new Error('The adopter HTTP service is stopping.'));\n request.destroy();\n response.destroy();\n });\n await Promise.allSettled(active.map(({ pending }) => pending));\n }\n\n async #serveConversation(\n request: IncomingMessage,\n response: ServerResponse,\n signal: AbortSignal,\n ): Promise<void> {\n let authorization: string | undefined;\n try {\n authorization = takeAuthorization(request);\n if (request.method !== 'POST') {\n request.resume();\n writeJsonError(response, 405, 'Method not allowed.');\n return;\n }\n } catch (error) {\n request.resume();\n writeJsonError(\n response,\n error instanceof NodeHttpRequestError ? error.statusCode : 400,\n 'Invalid conversation request.',\n );\n return;\n }\n\n let principal: Principal | undefined;\n try {\n principal = await this.#authenticator.authenticate({\n authorization,\n remoteAddress: request.socket.remoteAddress,\n signal,\n });\n } catch (error) {\n this.#report({\n phase: 'authentication',\n errorType: errorType(error),\n streamAccepted: false,\n });\n request.resume();\n writeJsonError(response, 500, 'Authentication could not be completed.');\n return;\n }\n if (!principal) {\n request.resume();\n writeJsonError(response, 401, 'Authentication is required.', {\n 'WWW-Authenticate': 'Bearer',\n });\n return;\n }\n\n let prompt: string;\n try {\n const body = await readJsonBody(request, this.#maxBodyBytes, signal);\n prompt = z.object({\n prompt: z.string().trim().min(1).max(this.#maxPromptCharacters),\n }).strict().parse(body).prompt;\n } catch (error) {\n const statusCode = error instanceof NodeHttpRequestError\n ? error.statusCode\n : 400;\n writeJsonError(response, statusCode, 'Invalid conversation request.');\n return;\n }\n\n let streamed = false;\n try {\n for await (const rawEvent of this.#conversations.streamTurn({\n principal,\n prompt,\n signal,\n })) {\n const event = ExecutionHostStreamEventSchema.parse(rawEvent);\n if (!streamed) {\n writeEventStreamHeaders(response);\n streamed = true;\n }\n await writeSseEvent(response, event, signal);\n }\n if (!streamed) {\n writeJsonError(response, 502, 'Execution Host returned no events.');\n return;\n }\n response.end();\n } catch (error) {\n const publicError = !streamed ? this.#project(error) : undefined;\n if (publicError) {\n writeJsonError(response, publicError.statusCode, publicError.message);\n return;\n }\n if (\n error instanceof ExecutionHostInvocationCancelledError\n || signal.aborted\n ) {\n if (!response.headersSent && !response.destroyed) {\n writeJsonError(response, 499, 'Hosted conversation was cancelled.');\n }\n return;\n }\n this.#report({\n phase: 'conversation',\n errorType: errorType(error),\n streamAccepted: streamed,\n });\n if (!response.headersSent) {\n writeJsonError(response, 502, 'Execution Host conversation failed.');\n } else if (!response.destroyed && !response.writableEnded) {\n // A post-acceptance failure deliberately ends without a terminal event.\n response.end();\n }\n }\n }\n\n #project(error: unknown): NodeExecutionAdopterPublicError | undefined {\n if (!this.#projectError) {\n return undefined;\n }\n try {\n const projected = this.#projectError(error);\n return projected ? PublicErrorSchema.parse(projected) : undefined;\n } catch {\n return undefined;\n }\n }\n\n #report(failure: NodeExecutionAdopterFailure): void {\n try {\n this.#reportFailure?.(Object.freeze({ ...failure }));\n } catch {\n // Observability must not change request settlement.\n }\n }\n}\n\nfunction parsePaths(\n paths: Partial<NodeExecutionAdopterHttpPaths> | undefined,\n): Readonly<NodeExecutionAdopterHttpPaths> {\n const parsed = {\n jwks: NodeHttpPathSchema.parse(paths?.jwks ?? DEFAULT_ADOPTER_JWKS_PATH),\n conversationTurns: NodeHttpPathSchema.parse(\n paths?.conversationTurns ?? DEFAULT_ADOPTER_CONVERSATION_TURNS_PATH,\n ),\n };\n if (parsed.jwks === parsed.conversationTurns) {\n throw new Error('Adopter HTTP paths must be distinct.');\n }\n return Object.freeze(parsed);\n}\n\nfunction writeEventStreamHeaders(response: ServerResponse): void {\n response.writeHead(200, {\n 'Cache-Control': 'no-store',\n 'Content-Type': 'text/event-stream; charset=utf-8',\n Connection: 'keep-alive',\n 'X-Accel-Buffering': 'no',\n 'X-Content-Type-Options': 'nosniff',\n });\n}\n\nasync function writeSseEvent(\n response: ServerResponse,\n event: z.infer<typeof ExecutionHostStreamEventSchema>,\n signal: AbortSignal,\n): Promise<void> {\n const frame = [\n `event: ${event.kind}`,\n `id: ${event.sequence}`,\n `data: ${JSON.stringify(event)}`,\n '',\n '',\n ].join('\\n');\n if (!response.write(frame)) {\n await once(response, 'drain', { signal });\n }\n}\n"]}
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { ExecutionAuthorityKeyFileError, generateEphemeralExecutionAuthorityKeyPair, generateExecutionAuthorityKeyFile, loadExecutionAuthorityKeyPairFromFile, } from './authority-key.js';
|
|
2
2
|
export { DirectExecutionHostCredentials } from './direct-credentials.js';
|
|
3
3
|
export type { DirectExecutionHostCredentialEnvironmentNames, } from './direct-credentials.js';
|
|
4
|
-
export { DEFAULT_ADOPTER_CONVERSATION_TURNS_PATH, DEFAULT_ADOPTER_JWKS_PATH,
|
|
4
|
+
export { DEFAULT_ADOPTER_CONVERSATION_TURNS_PATH, DEFAULT_ADOPTER_JWKS_PATH, } from '../adopter/index.js';
|
|
5
|
+
export { NodeExecutionAdopterHttpService, } from './http-service.js';
|
|
5
6
|
export type { NodeExecutionAdopterAuthenticationInput, NodeExecutionAdopterAuthenticator, NodeExecutionAdopterConversationInput, NodeExecutionAdopterConversationService, NodeExecutionAdopterFailure, NodeExecutionAdopterHttpHandler, NodeExecutionAdopterHttpPaths, NodeExecutionAdopterHttpServiceConfig, NodeExecutionAdopterPublicError, } from './types.js';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAC9B,0CAA0C,EAC1C,iCAAiC,EACjC,qCAAqC,GACtC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AACzE,YAAY,EACV,6CAA6C,GAC9C,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,uCAAuC,EACvC,yBAAyB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAC9B,0CAA0C,EAC1C,iCAAiC,EACjC,qCAAqC,GACtC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AACzE,YAAY,EACV,6CAA6C,GAC9C,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,uCAAuC,EACvC,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,+BAA+B,GAChC,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,uCAAuC,EACvC,iCAAiC,EACjC,qCAAqC,EACrC,uCAAuC,EACvC,2BAA2B,EAC3B,+BAA+B,EAC/B,6BAA6B,EAC7B,qCAAqC,EACrC,+BAA+B,GAChC,MAAM,YAAY,CAAC"}
|
package/dist/node/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { ExecutionAuthorityKeyFileError, generateEphemeralExecutionAuthorityKeyPair, generateExecutionAuthorityKeyFile, loadExecutionAuthorityKeyPairFromFile, } from './authority-key.js';
|
|
2
2
|
export { DirectExecutionHostCredentials } from './direct-credentials.js';
|
|
3
|
-
export { DEFAULT_ADOPTER_CONVERSATION_TURNS_PATH, DEFAULT_ADOPTER_JWKS_PATH,
|
|
3
|
+
export { DEFAULT_ADOPTER_CONVERSATION_TURNS_PATH, DEFAULT_ADOPTER_JWKS_PATH, } from '../adopter/index.js';
|
|
4
|
+
export { NodeExecutionAdopterHttpService, } from './http-service.js';
|
|
4
5
|
//# sourceMappingURL=index.js.map
|
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAC9B,0CAA0C,EAC1C,iCAAiC,EACjC,qCAAqC,GACtC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AAIzE,OAAO,EACL,uCAAuC,EACvC,yBAAyB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAC9B,0CAA0C,EAC1C,iCAAiC,EACjC,qCAAqC,GACtC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AAIzE,OAAO,EACL,uCAAuC,EACvC,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,+BAA+B,GAChC,MAAM,mBAAmB,CAAC","sourcesContent":["export {\n ExecutionAuthorityKeyFileError,\n generateEphemeralExecutionAuthorityKeyPair,\n generateExecutionAuthorityKeyFile,\n loadExecutionAuthorityKeyPairFromFile,\n} from './authority-key.js';\nexport { DirectExecutionHostCredentials } from './direct-credentials.js';\nexport type {\n DirectExecutionHostCredentialEnvironmentNames,\n} from './direct-credentials.js';\nexport {\n DEFAULT_ADOPTER_CONVERSATION_TURNS_PATH,\n DEFAULT_ADOPTER_JWKS_PATH,\n} from '../adopter/index.js';\nexport {\n NodeExecutionAdopterHttpService,\n} from './http-service.js';\nexport type {\n NodeExecutionAdopterAuthenticationInput,\n NodeExecutionAdopterAuthenticator,\n NodeExecutionAdopterConversationInput,\n NodeExecutionAdopterConversationService,\n NodeExecutionAdopterFailure,\n NodeExecutionAdopterHttpHandler,\n NodeExecutionAdopterHttpPaths,\n NodeExecutionAdopterHttpServiceConfig,\n NodeExecutionAdopterPublicError,\n} from './types.js';\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heddleagent/execution-host-client",
|
|
3
|
-
"version": "6.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "6.6.0",
|
|
4
|
+
"description": "Contracts, execution authority, lifecycle services, and adopter clients for compatible Heddle Execution Hosts",
|
|
5
5
|
"author": "Jay / Fienna Liang <roackb2@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -38,6 +38,10 @@
|
|
|
38
38
|
"types": "./dist/authority/index.d.ts",
|
|
39
39
|
"import": "./dist/authority/index.js"
|
|
40
40
|
},
|
|
41
|
+
"./adopter": {
|
|
42
|
+
"types": "./dist/adopter/index.d.ts",
|
|
43
|
+
"import": "./dist/adopter/index.js"
|
|
44
|
+
},
|
|
41
45
|
"./conversation": {
|
|
42
46
|
"types": "./dist/conversation/index.d.ts",
|
|
43
47
|
"import": "./dist/conversation/index.js"
|
|
@@ -70,6 +74,10 @@
|
|
|
70
74
|
"types": "./dist/agentcore/index.d.ts",
|
|
71
75
|
"import": "./dist/agentcore/index.js"
|
|
72
76
|
},
|
|
77
|
+
"./host": {
|
|
78
|
+
"types": "./dist/host/index.d.ts",
|
|
79
|
+
"import": "./dist/host/index.js"
|
|
80
|
+
},
|
|
73
81
|
"./testing": {
|
|
74
82
|
"types": "./dist/testing/index.d.ts",
|
|
75
83
|
"import": "./dist/testing/index.js"
|