@heddleagent/execution-host-client 6.5.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 +7 -6
- package/dist/adopter/contracts.d.ts +13 -0
- package/dist/adopter/contracts.d.ts.map +1 -0
- package/dist/adopter/contracts.js +13 -0
- package/dist/adopter/contracts.js.map +1 -0
- package/dist/adopter/hosted-conversation-client.d.ts +20 -0
- package/dist/adopter/hosted-conversation-client.d.ts.map +1 -0
- package/dist/adopter/hosted-conversation-client.js +103 -0
- package/dist/adopter/hosted-conversation-client.js.map +1 -0
- package/dist/adopter/index.d.ts +5 -0
- package/dist/adopter/index.d.ts.map +1 -0
- package/dist/adopter/index.js +3 -0
- package/dist/adopter/index.js.map +1 -0
- package/dist/adopter/types.d.ts +14 -0
- package/dist/adopter/types.d.ts.map +1 -0
- package/dist/adopter/types.js +2 -0
- package/dist/adopter/types.js.map +1 -0
- package/dist/agentcore/agentcore-execution-host.d.ts.map +1 -1
- package/dist/agentcore/agentcore-execution-host.js +7 -4
- package/dist/agentcore/agentcore-execution-host.js.map +1 -1
- package/dist/agentcore/index.d.ts +2 -0
- package/dist/agentcore/index.d.ts.map +1 -1
- package/dist/agentcore/index.js +1 -0
- package/dist/agentcore/index.js.map +1 -1
- package/dist/agentcore/schemas.d.ts +11 -0
- package/dist/agentcore/schemas.d.ts.map +1 -0
- package/dist/agentcore/schemas.js +12 -0
- package/dist/agentcore/schemas.js.map +1 -0
- package/dist/agentcore/types.d.ts +2 -4
- package/dist/agentcore/types.d.ts.map +1 -1
- package/dist/agentcore/types.js.map +1 -1
- package/dist/coordinator/contracts.d.ts +367 -2
- package/dist/coordinator/contracts.d.ts.map +1 -1
- package/dist/coordinator/contracts.js +72 -2
- package/dist/coordinator/contracts.js.map +1 -1
- package/dist/coordinator/hosted-heartbeat-coordinator-client.d.ts +6 -2
- package/dist/coordinator/hosted-heartbeat-coordinator-client.d.ts.map +1 -1
- package/dist/coordinator/hosted-heartbeat-coordinator-client.js +21 -1
- package/dist/coordinator/hosted-heartbeat-coordinator-client.js.map +1 -1
- package/dist/coordinator/index.d.ts +2 -2
- package/dist/coordinator/index.d.ts.map +1 -1
- package/dist/coordinator/index.js +1 -1
- package/dist/coordinator/index.js.map +1 -1
- package/dist/coordinator/types.d.ts +7 -3
- package/dist/coordinator/types.d.ts.map +1 -1
- package/dist/coordinator/types.js.map +1 -1
- package/dist/host/index.d.ts +1 -0
- package/dist/host/index.d.ts.map +1 -1
- package/dist/host/index.js +1 -0
- package/dist/host/index.js.map +1 -1
- package/dist/host/runtime-session/errors.d.ts +21 -0
- package/dist/host/runtime-session/errors.d.ts.map +1 -0
- package/dist/host/runtime-session/errors.js +21 -0
- package/dist/host/runtime-session/errors.js.map +1 -0
- package/dist/host/runtime-session/index.d.ts +9 -0
- package/dist/host/runtime-session/index.d.ts.map +1 -0
- package/dist/host/runtime-session/index.js +5 -0
- package/dist/host/runtime-session/index.js.map +1 -0
- package/dist/host/runtime-session/scope-binding.d.ts +17 -0
- package/dist/host/runtime-session/scope-binding.d.ts.map +1 -0
- package/dist/host/runtime-session/scope-binding.js +37 -0
- package/dist/host/runtime-session/scope-binding.js.map +1 -0
- package/dist/host/runtime-session/service.d.ts +38 -0
- package/dist/host/runtime-session/service.d.ts.map +1 -0
- package/dist/host/runtime-session/service.js +177 -0
- package/dist/host/runtime-session/service.js.map +1 -0
- package/dist/host/runtime-session/status.d.ts +17 -0
- package/dist/host/runtime-session/status.d.ts.map +1 -0
- package/dist/host/runtime-session/status.js +33 -0
- package/dist/host/runtime-session/status.js.map +1 -0
- package/dist/host/runtime-session/types.d.ts +61 -0
- package/dist/host/runtime-session/types.d.ts.map +1 -0
- package/dist/host/runtime-session/types.js +2 -0
- package/dist/host/runtime-session/types.js.map +1 -0
- package/dist/http-sse/direct-http-execution-host.d.ts.map +1 -1
- package/dist/http-sse/direct-http-execution-host.js +10 -177
- package/dist/http-sse/direct-http-execution-host.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/execution-host-event-stream.d.ts +18 -0
- package/dist/internal/execution-host-event-stream.d.ts.map +1 -0
- package/dist/internal/execution-host-event-stream.js +141 -0
- package/dist/internal/execution-host-event-stream.js.map +1 -0
- package/dist/internal/http-response.d.ts +4 -0
- package/dist/internal/http-response.d.ts.map +1 -0
- package/dist/internal/http-response.js +57 -0
- package/dist/internal/http-response.js.map +1 -0
- package/dist/node/http-service.d.ts +0 -2
- package/dist/node/http-service.d.ts.map +1 -1
- package/dist/node/http-service.js +1 -2
- package/dist/node/http-service.js.map +1 -1
- package/dist/node/index.d.ts +2 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +2 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# `@heddleagent/execution-host-client`
|
|
2
2
|
|
|
3
|
-
`@heddleagent/execution-host-client` is the
|
|
4
|
-
|
|
3
|
+
`@heddleagent/execution-host-client` is the integration SDK for products that
|
|
4
|
+
invoke a separately deployed Heddle Execution Host. It lets an
|
|
5
5
|
adopter keep its own language stack, authentication, database, product policy,
|
|
6
6
|
MCP tools, and UI while reusing the security-sensitive v1 contract machinery.
|
|
7
7
|
|
|
8
|
-
> **Current availability:** `6.
|
|
9
|
-
>
|
|
8
|
+
> **Current availability:** `6.6.0` is the latest published version as of
|
|
9
|
+
> 2026-08-25; repository source may be ahead of that release. The former
|
|
10
10
|
> `@roackb2/heddle-adopter@5.13.0` coordinate is deprecated and remains
|
|
11
11
|
> installable only for existing consumers. Heddle does not currently distribute
|
|
12
12
|
> the compatible Execution Host implementation or offer a hosted service. The
|
|
@@ -28,6 +28,7 @@ modular AWS SDK for its AgentCore transport and the official MCP SDK, plus
|
|
|
28
28
|
|
|
29
29
|
| Import | Reusable responsibility |
|
|
30
30
|
| --- | --- |
|
|
31
|
+
| `@heddleagent/execution-host-client/adopter` | Browser-safe authenticated hosted-conversation client, canonical adopter paths, bounded public errors, and strict ordered SSE settlement |
|
|
31
32
|
| `@heddleagent/execution-host-client/contracts` | Runtime-validated v1 request, stream, identity, capability, and header contracts |
|
|
32
33
|
| `@heddleagent/execution-host-client/authority` | ES256 execution assertion and optional MCP capability issuance plus public JWKS projection |
|
|
33
34
|
| `@heddleagent/execution-host-client/conversation` | Turn orchestration across authority, model credentials, optional MCP policy, an `ExecutionHost`, and an optional adopter-implemented durable lifecycle store |
|
|
@@ -37,8 +38,8 @@ modular AWS SDK for its AgentCore transport and the official MCP SDK, plus
|
|
|
37
38
|
| `@heddleagent/execution-host-client/mcp` | Independent capability verification at the adopter's MCP edge |
|
|
38
39
|
| `@heddleagent/execution-host-client/mcp/node` | Stateless official-SDK Streamable HTTP lifecycle around adopter-defined toolsets |
|
|
39
40
|
| `@heddleagent/execution-host-client/http-sse` | Transport-neutral conversation and heartbeat ports plus the strict direct-development HTTP/SSE client |
|
|
40
|
-
| `@heddleagent/execution-host-client/agentcore` |
|
|
41
|
-
| `@heddleagent/execution-host-client/host` | Invocation-bound
|
|
41
|
+
| `@heddleagent/execution-host-client/agentcore` | Canonical AgentCore deployment-target validation plus the official AWS AgentCore/SigV4 implementation of the conversation and heartbeat ports |
|
|
42
|
+
| `@heddleagent/execution-host-client/host` | Invocation-bound authority verification plus provider-neutral Runtime-session scope binding, admission, deadlines, cancellation, status, and workflow dispatch shared by compatible Execution Host implementations |
|
|
42
43
|
| `@heddleagent/execution-host-client/testing` | Node-only loopback v1 fixture plus durable-turn store conformance for real adapters |
|
|
43
44
|
| `@heddleagent/execution-host-client/node` | Optional Node JWKS/conversation HTTP edge plus safe local signing-key helpers |
|
|
44
45
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const DEFAULT_ADOPTER_JWKS_PATH = "/.well-known/jwks.json";
|
|
3
|
+
export declare const DEFAULT_ADOPTER_CONVERSATION_TURNS_PATH = "/hosted-execution/conversation-turns";
|
|
4
|
+
export declare const HostedConversationRequestSchema: z.ZodObject<{
|
|
5
|
+
prompt: z.ZodString;
|
|
6
|
+
}, z.core.$strict>;
|
|
7
|
+
export declare const HostedConversationPublicErrorSchema: z.ZodObject<{
|
|
8
|
+
error: z.ZodObject<{
|
|
9
|
+
message: z.ZodString;
|
|
10
|
+
}, z.core.$strict>;
|
|
11
|
+
}, z.core.$strict>;
|
|
12
|
+
export type HostedConversationRequest = z.infer<typeof HostedConversationRequestSchema>;
|
|
13
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src/adopter/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,yBAAyB,2BAA2B,CAAC;AAClE,eAAO,MAAM,uCAAuC,yCACZ,CAAC;AAEzC,eAAO,MAAM,+BAA+B;;kBAEjC,CAAC;AAEZ,eAAO,MAAM,mCAAmC;;;;kBAIrC,CAAC;AAEZ,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,+BAA+B,CACvC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ExecutionHostConversationTurnRequestSchema } from '../contracts/index.js';
|
|
3
|
+
export const DEFAULT_ADOPTER_JWKS_PATH = '/.well-known/jwks.json';
|
|
4
|
+
export const DEFAULT_ADOPTER_CONVERSATION_TURNS_PATH = '/hosted-execution/conversation-turns';
|
|
5
|
+
export const HostedConversationRequestSchema = z.object({
|
|
6
|
+
prompt: ExecutionHostConversationTurnRequestSchema.shape.prompt,
|
|
7
|
+
}).strict();
|
|
8
|
+
export const HostedConversationPublicErrorSchema = z.object({
|
|
9
|
+
error: z.object({
|
|
10
|
+
message: z.string().min(1).max(1_600),
|
|
11
|
+
}).strict(),
|
|
12
|
+
}).strict();
|
|
13
|
+
//# sourceMappingURL=contracts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../src/adopter/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,0CAA0C,EAAE,MAAM,uBAAuB,CAAC;AAEnF,MAAM,CAAC,MAAM,yBAAyB,GAAG,wBAAwB,CAAC;AAClE,MAAM,CAAC,MAAM,uCAAuC,GAClD,sCAAsC,CAAC;AAEzC,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,CAAC,MAAM,CAAC;IACtD,MAAM,EAAE,0CAA0C,CAAC,KAAK,CAAC,MAAM;CAChE,CAAC,CAAC,MAAM,EAAE,CAAC;AAEZ,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1D,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;KACtC,CAAC,CAAC,MAAM,EAAE;CACZ,CAAC,CAAC,MAAM,EAAE,CAAC","sourcesContent":["import { z } from 'zod';\nimport { ExecutionHostConversationTurnRequestSchema } from '../contracts/index.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\nexport const HostedConversationRequestSchema = z.object({\n prompt: ExecutionHostConversationTurnRequestSchema.shape.prompt,\n}).strict();\n\nexport const HostedConversationPublicErrorSchema = z.object({\n error: z.object({\n message: z.string().min(1).max(1_600),\n }).strict(),\n}).strict();\n\nexport type HostedConversationRequest = z.infer<\n typeof HostedConversationRequestSchema\n>;\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ExecutionHostStreamEvent } from '../contracts/index.js';
|
|
2
|
+
import type { HostedConversationClientConfig, HostedConversationClientTurnInput, HostedConversationStreamClient } from './types.js';
|
|
3
|
+
export declare class HostedConversationClientError extends Error {
|
|
4
|
+
readonly status?: number | undefined;
|
|
5
|
+
readonly name = "HostedConversationClientError";
|
|
6
|
+
constructor(message: string, status?: number | undefined, options?: ErrorOptions);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Browser-safe client for an adopter's authenticated hosted-conversation edge.
|
|
10
|
+
*
|
|
11
|
+
* Product code supplies its user token. Heddle owns the request shape,
|
|
12
|
+
* redirect refusal, bounded public errors, ordered SSE validation, truthful
|
|
13
|
+
* terminal settlement, cancellation, and ambiguous-interruption semantics.
|
|
14
|
+
*/
|
|
15
|
+
export declare class HostedConversationClient implements HostedConversationStreamClient {
|
|
16
|
+
#private;
|
|
17
|
+
constructor(config?: HostedConversationClientConfig);
|
|
18
|
+
streamTurn(rawInput: HostedConversationClientTurnInput): AsyncIterable<ExecutionHostStreamEvent>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=hosted-conversation-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-conversation-client.d.ts","sourceRoot":"","sources":["../../src/adopter/hosted-conversation-client.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,wBAAwB,EAC9B,MAAM,uBAAuB,CAAC;AAW/B,OAAO,KAAK,EACV,8BAA8B,EAC9B,iCAAiC,EACjC,8BAA8B,EAC/B,MAAM,YAAY,CAAC;AAQpB,qBAAa,6BAA8B,SAAQ,KAAK;IAKpD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM;IAJ1B,QAAQ,CAAC,IAAI,mCAAmC;gBAG9C,OAAO,EAAE,MAAM,EACN,MAAM,CAAC,EAAE,MAAM,YAAA,EACxB,OAAO,CAAC,EAAE,YAAY;CAIzB;AAED;;;;;;GAMG;AACH,qBAAa,wBACb,YAAW,8BAA8B;;gBAI3B,MAAM,GAAE,8BAAmC;IAOhD,UAAU,CACf,QAAQ,EAAE,iCAAiC,GAC1C,aAAa,CAAC,wBAAwB,CAAC;CAiD3C"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ExecutionHostStreamEventSchema, isExecutionHostTerminalEvent, isSafeWebUrl, } from '../contracts/index.js';
|
|
3
|
+
import { readExecutionHostEventStream, toExecutionHostTransportError, } from '../internal/execution-host-event-stream.js';
|
|
4
|
+
import { readBoundedJsonResponse } from '../internal/http-response.js';
|
|
5
|
+
import { DEFAULT_ADOPTER_CONVERSATION_TURNS_PATH, HostedConversationPublicErrorSchema, HostedConversationRequestSchema, } from './contracts.js';
|
|
6
|
+
const MAX_ERROR_BODY_BYTES = 16_384;
|
|
7
|
+
const AccessTokenSchema = z.string().trim().min(1).max(4_096).regex(/^\S+$/, 'accessToken must not contain whitespace');
|
|
8
|
+
export class HostedConversationClientError extends Error {
|
|
9
|
+
status;
|
|
10
|
+
name = 'HostedConversationClientError';
|
|
11
|
+
constructor(message, status, options) {
|
|
12
|
+
super(message, options);
|
|
13
|
+
this.status = status;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Browser-safe client for an adopter's authenticated hosted-conversation edge.
|
|
18
|
+
*
|
|
19
|
+
* Product code supplies its user token. Heddle owns the request shape,
|
|
20
|
+
* redirect refusal, bounded public errors, ordered SSE validation, truthful
|
|
21
|
+
* terminal settlement, cancellation, and ambiguous-interruption semantics.
|
|
22
|
+
*/
|
|
23
|
+
export class HostedConversationClient {
|
|
24
|
+
#endpoint;
|
|
25
|
+
#fetch;
|
|
26
|
+
constructor(config = {}) {
|
|
27
|
+
this.#endpoint = parseEndpoint(config.endpoint ?? DEFAULT_ADOPTER_CONVERSATION_TURNS_PATH);
|
|
28
|
+
this.#fetch = config.fetch ?? globalThis.fetch.bind(globalThis);
|
|
29
|
+
}
|
|
30
|
+
async *streamTurn(rawInput) {
|
|
31
|
+
const request = HostedConversationRequestSchema.parse({
|
|
32
|
+
prompt: rawInput.prompt,
|
|
33
|
+
});
|
|
34
|
+
const accessToken = AccessTokenSchema.parse(rawInput.accessToken);
|
|
35
|
+
if (rawInput.signal?.aborted) {
|
|
36
|
+
throw toExecutionHostTransportError(rawInput.signal.reason, rawInput.signal);
|
|
37
|
+
}
|
|
38
|
+
let response;
|
|
39
|
+
try {
|
|
40
|
+
response = await this.#fetch(this.#endpoint, {
|
|
41
|
+
method: 'POST',
|
|
42
|
+
redirect: 'error',
|
|
43
|
+
signal: rawInput.signal,
|
|
44
|
+
headers: {
|
|
45
|
+
Accept: 'text/event-stream',
|
|
46
|
+
Authorization: `Bearer ${accessToken}`,
|
|
47
|
+
'Content-Type': 'application/json',
|
|
48
|
+
},
|
|
49
|
+
body: JSON.stringify(request),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
if (rawInput.signal?.aborted) {
|
|
54
|
+
throw toExecutionHostTransportError(error, rawInput.signal);
|
|
55
|
+
}
|
|
56
|
+
throw new HostedConversationClientError('Hosted conversation endpoint could not be reached.', undefined, { cause: error });
|
|
57
|
+
}
|
|
58
|
+
if (!response.ok) {
|
|
59
|
+
throw new HostedConversationClientError(await readPublicError(response), response.status);
|
|
60
|
+
}
|
|
61
|
+
yield* readExecutionHostEventStream({
|
|
62
|
+
response,
|
|
63
|
+
schema: ExecutionHostStreamEventSchema,
|
|
64
|
+
isTerminal: isExecutionHostTerminalEvent,
|
|
65
|
+
signal: rawInput.signal,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async function readPublicError(response) {
|
|
70
|
+
const parsed = HostedConversationPublicErrorSchema.safeParse(await readBoundedJsonResponse(response, MAX_ERROR_BODY_BYTES));
|
|
71
|
+
return parsed.success
|
|
72
|
+
? parsed.data.error.message
|
|
73
|
+
: fallbackError(response.status);
|
|
74
|
+
}
|
|
75
|
+
function fallbackError(status) {
|
|
76
|
+
return status === 401
|
|
77
|
+
? 'Hosted conversation authorization was not accepted.'
|
|
78
|
+
: 'Hosted conversation could not be started.';
|
|
79
|
+
}
|
|
80
|
+
function parseEndpoint(value) {
|
|
81
|
+
if (value instanceof URL) {
|
|
82
|
+
return parseAbsoluteEndpoint(new URL(value));
|
|
83
|
+
}
|
|
84
|
+
const normalized = value.trim();
|
|
85
|
+
if (!normalized) {
|
|
86
|
+
throw new HostedConversationClientError('Hosted conversation endpoint cannot be empty.');
|
|
87
|
+
}
|
|
88
|
+
if (normalized.startsWith('/')) {
|
|
89
|
+
const relative = new URL(normalized, 'https://adopter.invalid');
|
|
90
|
+
if (relative.search || relative.hash || relative.pathname !== normalized) {
|
|
91
|
+
throw new HostedConversationClientError('Hosted conversation endpoint must be a path without query or fragment.');
|
|
92
|
+
}
|
|
93
|
+
return relative.pathname;
|
|
94
|
+
}
|
|
95
|
+
return parseAbsoluteEndpoint(new URL(normalized));
|
|
96
|
+
}
|
|
97
|
+
function parseAbsoluteEndpoint(url) {
|
|
98
|
+
if (!isSafeWebUrl(url)) {
|
|
99
|
+
throw new HostedConversationClientError('Hosted conversation endpoint must use HTTPS or loopback HTTP without credentials, query, or fragment.');
|
|
100
|
+
}
|
|
101
|
+
return url;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=hosted-conversation-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-conversation-client.js","sourceRoot":"","sources":["../../src/adopter/hosted-conversation-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,8BAA8B,EAC9B,4BAA4B,EAC5B,YAAY,GAEb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,4CAA4C,CAAC;AACpD,OAAO,EA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ExecutionHostStreamEventSchema,\n isExecutionHostTerminalEvent,\n isSafeWebUrl,\n type ExecutionHostStreamEvent,\n} from '../contracts/index.js';\nimport {\n readExecutionHostEventStream,\n toExecutionHostTransportError,\n} from '../internal/execution-host-event-stream.js';\nimport { readBoundedJsonResponse } from '../internal/http-response.js';\nimport {\n DEFAULT_ADOPTER_CONVERSATION_TURNS_PATH,\n HostedConversationPublicErrorSchema,\n HostedConversationRequestSchema,\n} from './contracts.js';\nimport type {\n HostedConversationClientConfig,\n HostedConversationClientTurnInput,\n HostedConversationStreamClient,\n} from './types.js';\n\nconst MAX_ERROR_BODY_BYTES = 16_384;\nconst AccessTokenSchema = z.string().trim().min(1).max(4_096).regex(\n /^\\S+$/,\n 'accessToken must not contain whitespace',\n);\n\nexport class HostedConversationClientError extends Error {\n readonly name = 'HostedConversationClientError';\n\n constructor(\n message: string,\n readonly status?: number,\n options?: ErrorOptions,\n ) {\n super(message, options);\n }\n}\n\n/**\n * Browser-safe client for an adopter's authenticated hosted-conversation edge.\n *\n * Product code supplies its user token. Heddle owns the request shape,\n * redirect refusal, bounded public errors, ordered SSE validation, truthful\n * terminal settlement, cancellation, and ambiguous-interruption semantics.\n */\nexport class HostedConversationClient\nimplements HostedConversationStreamClient {\n readonly #endpoint: string | URL;\n readonly #fetch: typeof globalThis.fetch;\n\n constructor(config: HostedConversationClientConfig = {}) {\n this.#endpoint = parseEndpoint(\n config.endpoint ?? DEFAULT_ADOPTER_CONVERSATION_TURNS_PATH,\n );\n this.#fetch = config.fetch ?? globalThis.fetch.bind(globalThis);\n }\n\n async *streamTurn(\n rawInput: HostedConversationClientTurnInput,\n ): AsyncIterable<ExecutionHostStreamEvent> {\n const request = HostedConversationRequestSchema.parse({\n prompt: rawInput.prompt,\n });\n const accessToken = AccessTokenSchema.parse(rawInput.accessToken);\n if (rawInput.signal?.aborted) {\n throw toExecutionHostTransportError(\n rawInput.signal.reason,\n rawInput.signal,\n );\n }\n\n let response: Response;\n try {\n response = await this.#fetch(this.#endpoint, {\n method: 'POST',\n redirect: 'error',\n signal: rawInput.signal,\n headers: {\n Accept: 'text/event-stream',\n Authorization: `Bearer ${accessToken}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(request),\n });\n } catch (error) {\n if (rawInput.signal?.aborted) {\n throw toExecutionHostTransportError(error, rawInput.signal);\n }\n throw new HostedConversationClientError(\n 'Hosted conversation endpoint could not be reached.',\n undefined,\n { cause: error },\n );\n }\n\n if (!response.ok) {\n throw new HostedConversationClientError(\n await readPublicError(response),\n response.status,\n );\n }\n yield* readExecutionHostEventStream({\n response,\n schema: ExecutionHostStreamEventSchema,\n isTerminal: isExecutionHostTerminalEvent,\n signal: rawInput.signal,\n });\n }\n}\n\nasync function readPublicError(response: Response): Promise<string> {\n const parsed = HostedConversationPublicErrorSchema.safeParse(\n await readBoundedJsonResponse(response, MAX_ERROR_BODY_BYTES),\n );\n return parsed.success\n ? parsed.data.error.message\n : fallbackError(response.status);\n}\n\nfunction fallbackError(status: number): string {\n return status === 401\n ? 'Hosted conversation authorization was not accepted.'\n : 'Hosted conversation could not be started.';\n}\n\nfunction parseEndpoint(value: string | URL): string | URL {\n if (value instanceof URL) {\n return parseAbsoluteEndpoint(new URL(value));\n }\n const normalized = value.trim();\n if (!normalized) {\n throw new HostedConversationClientError(\n 'Hosted conversation endpoint cannot be empty.',\n );\n }\n if (normalized.startsWith('/')) {\n const relative = new URL(normalized, 'https://adopter.invalid');\n if (relative.search || relative.hash || relative.pathname !== normalized) {\n throw new HostedConversationClientError(\n 'Hosted conversation endpoint must be a path without query or fragment.',\n );\n }\n return relative.pathname;\n }\n return parseAbsoluteEndpoint(new URL(normalized));\n}\n\nfunction parseAbsoluteEndpoint(url: URL): URL {\n if (!isSafeWebUrl(url)) {\n throw new HostedConversationClientError(\n 'Hosted conversation endpoint must use HTTPS or loopback HTTP without credentials, query, or fragment.',\n );\n }\n return url;\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { DEFAULT_ADOPTER_CONVERSATION_TURNS_PATH, DEFAULT_ADOPTER_JWKS_PATH, HostedConversationPublicErrorSchema, HostedConversationRequestSchema, } from './contracts.js';
|
|
2
|
+
export { HostedConversationClient, HostedConversationClientError, } from './hosted-conversation-client.js';
|
|
3
|
+
export type { HostedConversationClientConfig, HostedConversationClientTurnInput, HostedConversationStreamClient, } from './types.js';
|
|
4
|
+
export type { HostedConversationRequest } from './contracts.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adopter/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uCAAuC,EACvC,yBAAyB,EACzB,mCAAmC,EACnC,+BAA+B,GAChC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,wBAAwB,EACxB,6BAA6B,GAC9B,MAAM,iCAAiC,CAAC;AACzC,YAAY,EACV,8BAA8B,EAC9B,iCAAiC,EACjC,8BAA8B,GAC/B,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { DEFAULT_ADOPTER_CONVERSATION_TURNS_PATH, DEFAULT_ADOPTER_JWKS_PATH, HostedConversationPublicErrorSchema, HostedConversationRequestSchema, } from './contracts.js';
|
|
2
|
+
export { HostedConversationClient, HostedConversationClientError, } from './hosted-conversation-client.js';
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adopter/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uCAAuC,EACvC,yBAAyB,EACzB,mCAAmC,EACnC,+BAA+B,GAChC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,wBAAwB,EACxB,6BAA6B,GAC9B,MAAM,iCAAiC,CAAC","sourcesContent":["export {\n DEFAULT_ADOPTER_CONVERSATION_TURNS_PATH,\n DEFAULT_ADOPTER_JWKS_PATH,\n HostedConversationPublicErrorSchema,\n HostedConversationRequestSchema,\n} from './contracts.js';\nexport {\n HostedConversationClient,\n HostedConversationClientError,\n} from './hosted-conversation-client.js';\nexport type {\n HostedConversationClientConfig,\n HostedConversationClientTurnInput,\n HostedConversationStreamClient,\n} from './types.js';\nexport type { HostedConversationRequest } from './contracts.js';\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ExecutionHostStreamEvent } from '../contracts/index.js';
|
|
2
|
+
export type HostedConversationClientConfig = {
|
|
3
|
+
endpoint?: string | URL;
|
|
4
|
+
fetch?: typeof globalThis.fetch;
|
|
5
|
+
};
|
|
6
|
+
export type HostedConversationClientTurnInput = {
|
|
7
|
+
prompt: string;
|
|
8
|
+
accessToken: string;
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
};
|
|
11
|
+
export interface HostedConversationStreamClient {
|
|
12
|
+
streamTurn(input: HostedConversationClientTurnInput): AsyncIterable<ExecutionHostStreamEvent>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/adopter/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEtE,MAAM,MAAM,8BAA8B,GAAG;IAC3C,QAAQ,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,MAAM,WAAW,8BAA8B;IAC7C,UAAU,CACR,KAAK,EAAE,iCAAiC,GACvC,aAAa,CAAC,wBAAwB,CAAC,CAAC;CAC5C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/adopter/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ExecutionHostStreamEvent } from '../contracts/index.js';\n\nexport type HostedConversationClientConfig = {\n endpoint?: string | URL;\n fetch?: typeof globalThis.fetch;\n};\n\nexport type HostedConversationClientTurnInput = {\n prompt: string;\n accessToken: string;\n signal?: AbortSignal;\n};\n\nexport interface HostedConversationStreamClient {\n streamTurn(\n input: HostedConversationClientTurnInput,\n ): AsyncIterable<ExecutionHostStreamEvent>;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentcore-execution-host.d.ts","sourceRoot":"","sources":["../../src/agentcore/agentcore-execution-host.ts"],"names":[],"mappings":"AAMA,OAAO,EAML,KAAK,iCAAiC,EACtC,KAAK,wBAAwB,EAC9B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,6BAA6B,EAClC,KAAK,0BAA0B,EAC/B,KAAK,sBAAsB,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,4BAA4B,EAE7B,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"agentcore-execution-host.d.ts","sourceRoot":"","sources":["../../src/agentcore/agentcore-execution-host.ts"],"names":[],"mappings":"AAMA,OAAO,EAML,KAAK,iCAAiC,EACtC,KAAK,wBAAwB,EAC9B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,6BAA6B,EAClC,KAAK,0BAA0B,EAC/B,KAAK,sBAAsB,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,4BAA4B,EAE7B,MAAM,YAAY,CAAC;AAqBpB;;;GAGG;AACH,qBAAa,sBACb,YAAW,aAAa,EAAE,sBAAsB;;gBAMlC,MAAM,EAAE,4BAA4B;IAkBhD,sBAAsB,CACpB,KAAK,EAAE,6BAA6B,GACnC,aAAa,CAAC,wBAAwB,CAAC;IAK1C,mBAAmB,CACjB,KAAK,EAAE,0BAA0B,GAChC,aAAa,CAAC,iCAAiC,CAAC;IAKnD,KAAK,IAAI,IAAI;CAiEd;AAsGD,eAAO,MAAM,gCAAgC,mIAIlC,CAAC;AAEZ,eAAO,MAAM,+BAA+B,kDAEjC,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { BedrockAgentCoreClient, InvokeAgentRuntimeCommand, } from '@aws-sdk/cli
|
|
|
2
2
|
import { HttpRequest } from '@smithy/protocol-http';
|
|
3
3
|
import { AGENTCORE_RUNTIME_SESSION_HEADER, EXECUTION_ASSERTION_HEADER, EXECUTION_HOST_LOCAL_TOKEN_HEADER, MCP_CAPABILITY_HEADER, MODEL_API_KEY_HEADER, } from '../contracts/index.js';
|
|
4
4
|
import { DirectHttpExecutionHost, } from '../http-sse/index.js';
|
|
5
|
+
import { AgentCoreExecutionTargetSchema } from './schemas.js';
|
|
5
6
|
const CONTENT_TYPE = 'application/json';
|
|
6
7
|
const ACCEPT = 'text/event-stream';
|
|
7
8
|
const MIN_RUNTIME_SESSION_ID_LENGTH = 33;
|
|
@@ -29,10 +30,12 @@ export class AgentCoreExecutionHost {
|
|
|
29
30
|
#qualifier;
|
|
30
31
|
#wire;
|
|
31
32
|
constructor(config) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
this.#
|
|
35
|
-
|
|
33
|
+
const { client, ...rawTarget } = config;
|
|
34
|
+
const target = AgentCoreExecutionTargetSchema.parse(rawTarget);
|
|
35
|
+
this.#runtimeArn = target.runtimeArn;
|
|
36
|
+
this.#qualifier = target.qualifier;
|
|
37
|
+
this.#client = client ?? new BedrockAgentCoreClient({
|
|
38
|
+
region: target.region,
|
|
36
39
|
// Invocation settlement is ambiguous after a transport interruption.
|
|
37
40
|
// Product policy, not the AWS client, decides whether a turn may retry.
|
|
38
41
|
maxAttempts: 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentcore-execution-host.js","sourceRoot":"","sources":["../../src/agentcore/agentcore-execution-host.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,yBAAyB,GAE1B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EACL,gCAAgC,EAChC,0BAA0B,EAC1B,iCAAiC,EACjC,qBAAqB,EACrB,oBAAoB,GAGrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,uBAAuB,GAKxB,MAAM,sBAAsB,CAAC;AAM9B,MAAM,YAAY,GAAG,kBAAkB,CAAC;AACxC,MAAM,MAAM,GAAG,mBAAmB,CAAC;AACnC,MAAM,6BAA6B,GAAG,EAAE,CAAC;AACzC,MAAM,6BAA6B,GAAG,GAAG,CAAC;AAC1C,MAAM,0BAA0B,GAAG,iCAAiC,CAAC;AACrE,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,mCAAmC,CAAC,CAAC;AACrE,MAAM,yBAAyB,GAAG,wCAAwC,CAAC;AAC3E,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAiB;IAClD,CAAC,uBAAuB,EAAE,eAAe,CAAC;IAC1C,CAAC,yBAAyB,EAAE,kBAAkB,CAAC;IAC/C,CAAC,2BAA2B,EAAE,mBAAmB,CAAC;IAClD,CAAC,4BAA4B,EAAE,kBAAkB,CAAC;IAClD,CAAC,oBAAoB,EAAE,sBAAsB,CAAC;IAC9C,CAAC,+BAA+B,EAAE,gBAAgB,CAAC;IACnD,CAAC,qBAAqB,EAAE,WAAW,CAAC;IACpC,CAAC,qBAAqB,EAAE,iBAAiB,CAAC;CAC3C,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,OAAO,sBAAsB;IAExB,OAAO,CAAyB;IAChC,WAAW,CAAS;IACpB,UAAU,CAAU;IACpB,KAAK,CAA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AM,CAAC;IAC3D,iCAAiC;CACzB,CAAC,CAAC","sourcesContent":["import {\n BedrockAgentCoreClient,\n InvokeAgentRuntimeCommand,\n type InvokeAgentRuntimeCommandOutput,\n} from '@aws-sdk/client-bedrock-agentcore';\nimport { HttpRequest } from '@smithy/protocol-http';\nimport {\n AGENTCORE_RUNTIME_SESSION_HEADER,\n EXECUTION_ASSERTION_HEADER,\n EXECUTION_HOST_LOCAL_TOKEN_HEADER,\n MCP_CAPABILITY_HEADER,\n MODEL_API_KEY_HEADER,\n type ExecutionHostHeartbeatStreamEvent,\n type ExecutionHostStreamEvent,\n} from '../contracts/index.js';\nimport {\n DirectHttpExecutionHost,\n type ExecutionHost,\n type ExecutionHostConversationTurn,\n type ExecutionHostHeartbeatTask,\n type HeartbeatExecutionHost,\n} from '../http-sse/index.js';\nimport type {\n AgentCoreExecutionHostConfig,\n AgentCoreRuntimeClient,\n} from './types.js';\n\nconst CONTENT_TYPE = 'application/json';\nconst ACCEPT = 'text/event-stream';\nconst MIN_RUNTIME_SESSION_ID_LENGTH = 33;\nconst MAX_RUNTIME_SESSION_ID_LENGTH = 256;\nconst RUNTIME_SESSION_ID_PATTERN = /^[A-Za-z0-9](?:-*[A-Za-z0-9])+$/;\nconst WIRE_BRIDGE_URL = new URL('http://127.0.0.1/agentcore-bridge');\nconst NON_FORWARDED_LOCAL_TOKEN = 'agentcore-bridge-token-never-forwarded';\nconst SERVICE_ERROR_CODES = new Map<string, string>([\n ['AccessDeniedException', 'access_denied'],\n ['InternalServerException', 'runtime_internal'],\n ['ResourceNotFoundException', 'runtime_not_found'],\n ['RetryableConflictException', 'runtime_conflict'],\n ['RuntimeClientError', 'runtime_client_error'],\n ['ServiceQuotaExceededException', 'quota_exceeded'],\n ['ThrottlingException', 'throttled'],\n ['ValidationException', 'invalid_request'],\n]);\n\n/**\n * Invokes one compatible Heddle Execution Host through AWS AgentCore while\n * reusing the package's strict request and SSE protocol validation.\n */\nexport class AgentCoreExecutionHost\nimplements ExecutionHost, HeartbeatExecutionHost {\n readonly #client: AgentCoreRuntimeClient;\n readonly #runtimeArn: string;\n readonly #qualifier?: string;\n readonly #wire: DirectHttpExecutionHost;\n\n constructor(config: AgentCoreExecutionHostConfig) {\n this.#runtimeArn = config.runtimeArn;\n this.#qualifier = config.qualifier;\n this.#client = config.client ?? new BedrockAgentCoreClient({\n region: config.region,\n // Invocation settlement is ambiguous after a transport interruption.\n // Product policy, not the AWS client, decides whether a turn may retry.\n maxAttempts: 1,\n });\n this.#wire = new DirectHttpExecutionHost({\n baseUrl: WIRE_BRIDGE_URL,\n localToken: NON_FORWARDED_LOCAL_TOKEN,\n fetch: (_input, init) => this.#invoke(init),\n });\n }\n\n streamConversationTurn(\n input: ExecutionHostConversationTurn,\n ): AsyncIterable<ExecutionHostStreamEvent> {\n assertAgentCoreRuntimeSessionId(input.runtimeSessionId);\n return this.#wire.streamConversationTurn(input);\n }\n\n streamHeartbeatTask(\n input: ExecutionHostHeartbeatTask,\n ): AsyncIterable<ExecutionHostHeartbeatStreamEvent> {\n assertAgentCoreRuntimeSessionId(input.runtimeSessionId);\n return this.#wire.streamHeartbeatTask(input);\n }\n\n close(): void {\n this.#client.destroy?.();\n }\n\n async #invoke(init?: RequestInit): Promise<Response> {\n if (init?.method !== 'POST' || typeof init.body !== 'string') {\n throw new Error('AgentCore wire bridge received an invalid request.');\n }\n const headers = new Headers(init.headers);\n const runtimeSessionId = requireHeader(\n headers,\n AGENTCORE_RUNTIME_SESSION_HEADER,\n );\n const customHeaders = Object.fromEntries([\n [\n EXECUTION_ASSERTION_HEADER,\n requireHeader(headers, EXECUTION_ASSERTION_HEADER),\n ],\n [MODEL_API_KEY_HEADER, requireHeader(headers, MODEL_API_KEY_HEADER)],\n ...(headers.has(MCP_CAPABILITY_HEADER)\n ? [[MCP_CAPABILITY_HEADER, headers.get(MCP_CAPABILITY_HEADER)!]]\n : []),\n ]);\n const command = new InvokeAgentRuntimeCommand({\n agentRuntimeArn: this.#runtimeArn,\n runtimeSessionId,\n qualifier: this.#qualifier,\n contentType: CONTENT_TYPE,\n accept: ACCEPT,\n payload: new TextEncoder().encode(init.body),\n });\n addSignedCustomHeaders(command, customHeaders);\n const signal = init.signal ?? undefined;\n\n try {\n const output = await this.#client.send(command, { abortSignal: signal });\n return new Response(\n output.response ? toReadableStream(output.response) : null,\n {\n status: output.statusCode ?? output.$metadata.httpStatusCode ?? 200,\n headers: {\n 'content-type': output.contentType ?? 'application/octet-stream',\n },\n },\n );\n } catch (error) {\n if (signal?.aborted) {\n throw error;\n }\n const status = readServiceStatus(error);\n if (!status) {\n throw error;\n }\n const code = SERVICE_ERROR_CODES.get(readErrorName(error)) ?? 'unknown';\n return new Response(JSON.stringify({\n error: {\n code,\n message: 'AgentCore rejected the invocation.',\n },\n }), {\n status,\n headers: { 'content-type': CONTENT_TYPE },\n });\n }\n }\n}\n\nfunction assertAgentCoreRuntimeSessionId(value: string): void {\n if (\n value.length < MIN_RUNTIME_SESSION_ID_LENGTH\n || value.length > MAX_RUNTIME_SESSION_ID_LENGTH\n || !RUNTIME_SESSION_ID_PATTERN.test(value)\n ) {\n throw new Error('AgentCore runtime session ID is not provider-compatible.');\n }\n}\n\nfunction addSignedCustomHeaders(\n command: InvokeAgentRuntimeCommand,\n headers: Readonly<Record<string, string>>,\n): void {\n command.middlewareStack.add(\n (next) => async (args) => {\n if (!HttpRequest.isInstance(args.request)) {\n throw new Error('AgentCore invocation did not produce an HTTP request.');\n }\n Object.assign(args.request.headers, headers);\n return await next(args);\n },\n {\n step: 'build',\n priority: 'low',\n name: 'heddleAgentCoreCustomHeaders',\n },\n );\n}\n\nfunction requireHeader(headers: Headers, name: string): string {\n const value = headers.get(name);\n if (!value) {\n throw new Error('AgentCore wire bridge omitted required authority.');\n }\n return value;\n}\n\nfunction toReadableStream(\n source: NonNullable<InvokeAgentRuntimeCommandOutput['response']>,\n): ReadableStream<Uint8Array> {\n if (source instanceof Blob) {\n return source.stream();\n }\n if (source instanceof ReadableStream) {\n return source;\n }\n if (!isAsyncIterable(source)) {\n throw new Error('AgentCore returned an unsupported stream type.');\n }\n const iterator = source[Symbol.asyncIterator]();\n return new ReadableStream<Uint8Array>({\n async pull(controller) {\n try {\n const item = await iterator.next();\n if (item.done) {\n controller.close();\n return;\n }\n if (!(item.value instanceof Uint8Array)) {\n throw new Error('AgentCore returned a non-binary stream chunk.');\n }\n controller.enqueue(item.value);\n } catch (error) {\n controller.error(error);\n }\n },\n async cancel() {\n await iterator.return?.();\n },\n });\n}\n\nfunction isAsyncIterable(\n value: unknown,\n): value is AsyncIterable<Uint8Array> {\n return Boolean(\n value\n && typeof value === 'object'\n && Symbol.asyncIterator in value\n && typeof value[Symbol.asyncIterator] === 'function',\n );\n}\n\nfunction readServiceStatus(error: unknown): number | undefined {\n if (!error || typeof error !== 'object' || !('$metadata' in error)) {\n return undefined;\n }\n const metadata = (error as { $metadata?: { httpStatusCode?: unknown } })\n .$metadata;\n const status = metadata?.httpStatusCode;\n return typeof status === 'number' && status >= 400 && status <= 599\n ? status\n : undefined;\n}\n\nfunction readErrorName(error: unknown): string {\n return error instanceof Error ? error.name : '';\n}\n\nexport const AGENTCORE_FORWARDED_HEADER_NAMES = Object.freeze([\n EXECUTION_ASSERTION_HEADER,\n MCP_CAPABILITY_HEADER,\n MODEL_API_KEY_HEADER,\n] as const);\n\nexport const AGENTCORE_EXCLUDED_HEADER_NAMES = Object.freeze([\n EXECUTION_HOST_LOCAL_TOKEN_HEADER,\n] as const);\n"]}
|
|
1
|
+
{"version":3,"file":"agentcore-execution-host.js","sourceRoot":"","sources":["../../src/agentcore/agentcore-execution-host.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,yBAAyB,GAE1B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EACL,gCAAgC,EAChC,0BAA0B,EAC1B,iCAAiC,EACjC,qBAAqB,EACrB,oBAAoB,GAGrB,MA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AAC,MAAM;YACV,MAAM,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;QAC5B,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,SAAS,eAAe,CACtB,KAAc;IAEd,OAAO,OAAO,CACZ,KAAK;WACF,OAAO,KAAK,KAAK,QAAQ;WACzB,MAAM,CAAC,aAAa,IAAI,KAAK;WAC7B,OAAO,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,UAAU,CACrD,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,WAAW,IAAI,KAAK,CAAC,EAAE,CAAC;QACnE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,QAAQ,GAAI,KAAsD;SACrE,SAAS,CAAC;IACb,MAAM,MAAM,GAAG,QAAQ,EAAE,cAAc,CAAC;IACxC,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG;QACjE,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AAClD,CAAC;AAED,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5D,0BAA0B;IAC1B,qBAAqB;IACrB,oBAAoB;CACZ,CAAC,CAAC;AAEZ,MAAM,CAAC,MAAM,+BAA+B,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3D,iCAAiC;CACzB,CAAC,CAAC","sourcesContent":["import {\n BedrockAgentCoreClient,\n InvokeAgentRuntimeCommand,\n type InvokeAgentRuntimeCommandOutput,\n} from '@aws-sdk/client-bedrock-agentcore';\nimport { HttpRequest } from '@smithy/protocol-http';\nimport {\n AGENTCORE_RUNTIME_SESSION_HEADER,\n EXECUTION_ASSERTION_HEADER,\n EXECUTION_HOST_LOCAL_TOKEN_HEADER,\n MCP_CAPABILITY_HEADER,\n MODEL_API_KEY_HEADER,\n type ExecutionHostHeartbeatStreamEvent,\n type ExecutionHostStreamEvent,\n} from '../contracts/index.js';\nimport {\n DirectHttpExecutionHost,\n type ExecutionHost,\n type ExecutionHostConversationTurn,\n type ExecutionHostHeartbeatTask,\n type HeartbeatExecutionHost,\n} from '../http-sse/index.js';\nimport type {\n AgentCoreExecutionHostConfig,\n AgentCoreRuntimeClient,\n} from './types.js';\nimport { AgentCoreExecutionTargetSchema } from './schemas.js';\n\nconst CONTENT_TYPE = 'application/json';\nconst ACCEPT = 'text/event-stream';\nconst MIN_RUNTIME_SESSION_ID_LENGTH = 33;\nconst MAX_RUNTIME_SESSION_ID_LENGTH = 256;\nconst RUNTIME_SESSION_ID_PATTERN = /^[A-Za-z0-9](?:-*[A-Za-z0-9])+$/;\nconst WIRE_BRIDGE_URL = new URL('http://127.0.0.1/agentcore-bridge');\nconst NON_FORWARDED_LOCAL_TOKEN = 'agentcore-bridge-token-never-forwarded';\nconst SERVICE_ERROR_CODES = new Map<string, string>([\n ['AccessDeniedException', 'access_denied'],\n ['InternalServerException', 'runtime_internal'],\n ['ResourceNotFoundException', 'runtime_not_found'],\n ['RetryableConflictException', 'runtime_conflict'],\n ['RuntimeClientError', 'runtime_client_error'],\n ['ServiceQuotaExceededException', 'quota_exceeded'],\n ['ThrottlingException', 'throttled'],\n ['ValidationException', 'invalid_request'],\n]);\n\n/**\n * Invokes one compatible Heddle Execution Host through AWS AgentCore while\n * reusing the package's strict request and SSE protocol validation.\n */\nexport class AgentCoreExecutionHost\nimplements ExecutionHost, HeartbeatExecutionHost {\n readonly #client: AgentCoreRuntimeClient;\n readonly #runtimeArn: string;\n readonly #qualifier?: string;\n readonly #wire: DirectHttpExecutionHost;\n\n constructor(config: AgentCoreExecutionHostConfig) {\n const { client, ...rawTarget } = config;\n const target = AgentCoreExecutionTargetSchema.parse(rawTarget);\n this.#runtimeArn = target.runtimeArn;\n this.#qualifier = target.qualifier;\n this.#client = client ?? new BedrockAgentCoreClient({\n region: target.region,\n // Invocation settlement is ambiguous after a transport interruption.\n // Product policy, not the AWS client, decides whether a turn may retry.\n maxAttempts: 1,\n });\n this.#wire = new DirectHttpExecutionHost({\n baseUrl: WIRE_BRIDGE_URL,\n localToken: NON_FORWARDED_LOCAL_TOKEN,\n fetch: (_input, init) => this.#invoke(init),\n });\n }\n\n streamConversationTurn(\n input: ExecutionHostConversationTurn,\n ): AsyncIterable<ExecutionHostStreamEvent> {\n assertAgentCoreRuntimeSessionId(input.runtimeSessionId);\n return this.#wire.streamConversationTurn(input);\n }\n\n streamHeartbeatTask(\n input: ExecutionHostHeartbeatTask,\n ): AsyncIterable<ExecutionHostHeartbeatStreamEvent> {\n assertAgentCoreRuntimeSessionId(input.runtimeSessionId);\n return this.#wire.streamHeartbeatTask(input);\n }\n\n close(): void {\n this.#client.destroy?.();\n }\n\n async #invoke(init?: RequestInit): Promise<Response> {\n if (init?.method !== 'POST' || typeof init.body !== 'string') {\n throw new Error('AgentCore wire bridge received an invalid request.');\n }\n const headers = new Headers(init.headers);\n const runtimeSessionId = requireHeader(\n headers,\n AGENTCORE_RUNTIME_SESSION_HEADER,\n );\n const customHeaders = Object.fromEntries([\n [\n EXECUTION_ASSERTION_HEADER,\n requireHeader(headers, EXECUTION_ASSERTION_HEADER),\n ],\n [MODEL_API_KEY_HEADER, requireHeader(headers, MODEL_API_KEY_HEADER)],\n ...(headers.has(MCP_CAPABILITY_HEADER)\n ? [[MCP_CAPABILITY_HEADER, headers.get(MCP_CAPABILITY_HEADER)!]]\n : []),\n ]);\n const command = new InvokeAgentRuntimeCommand({\n agentRuntimeArn: this.#runtimeArn,\n runtimeSessionId,\n qualifier: this.#qualifier,\n contentType: CONTENT_TYPE,\n accept: ACCEPT,\n payload: new TextEncoder().encode(init.body),\n });\n addSignedCustomHeaders(command, customHeaders);\n const signal = init.signal ?? undefined;\n\n try {\n const output = await this.#client.send(command, { abortSignal: signal });\n return new Response(\n output.response ? toReadableStream(output.response) : null,\n {\n status: output.statusCode ?? output.$metadata.httpStatusCode ?? 200,\n headers: {\n 'content-type': output.contentType ?? 'application/octet-stream',\n },\n },\n );\n } catch (error) {\n if (signal?.aborted) {\n throw error;\n }\n const status = readServiceStatus(error);\n if (!status) {\n throw error;\n }\n const code = SERVICE_ERROR_CODES.get(readErrorName(error)) ?? 'unknown';\n return new Response(JSON.stringify({\n error: {\n code,\n message: 'AgentCore rejected the invocation.',\n },\n }), {\n status,\n headers: { 'content-type': CONTENT_TYPE },\n });\n }\n }\n}\n\nfunction assertAgentCoreRuntimeSessionId(value: string): void {\n if (\n value.length < MIN_RUNTIME_SESSION_ID_LENGTH\n || value.length > MAX_RUNTIME_SESSION_ID_LENGTH\n || !RUNTIME_SESSION_ID_PATTERN.test(value)\n ) {\n throw new Error('AgentCore runtime session ID is not provider-compatible.');\n }\n}\n\nfunction addSignedCustomHeaders(\n command: InvokeAgentRuntimeCommand,\n headers: Readonly<Record<string, string>>,\n): void {\n command.middlewareStack.add(\n (next) => async (args) => {\n if (!HttpRequest.isInstance(args.request)) {\n throw new Error('AgentCore invocation did not produce an HTTP request.');\n }\n Object.assign(args.request.headers, headers);\n return await next(args);\n },\n {\n step: 'build',\n priority: 'low',\n name: 'heddleAgentCoreCustomHeaders',\n },\n );\n}\n\nfunction requireHeader(headers: Headers, name: string): string {\n const value = headers.get(name);\n if (!value) {\n throw new Error('AgentCore wire bridge omitted required authority.');\n }\n return value;\n}\n\nfunction toReadableStream(\n source: NonNullable<InvokeAgentRuntimeCommandOutput['response']>,\n): ReadableStream<Uint8Array> {\n if (source instanceof Blob) {\n return source.stream();\n }\n if (source instanceof ReadableStream) {\n return source;\n }\n if (!isAsyncIterable(source)) {\n throw new Error('AgentCore returned an unsupported stream type.');\n }\n const iterator = source[Symbol.asyncIterator]();\n return new ReadableStream<Uint8Array>({\n async pull(controller) {\n try {\n const item = await iterator.next();\n if (item.done) {\n controller.close();\n return;\n }\n if (!(item.value instanceof Uint8Array)) {\n throw new Error('AgentCore returned a non-binary stream chunk.');\n }\n controller.enqueue(item.value);\n } catch (error) {\n controller.error(error);\n }\n },\n async cancel() {\n await iterator.return?.();\n },\n });\n}\n\nfunction isAsyncIterable(\n value: unknown,\n): value is AsyncIterable<Uint8Array> {\n return Boolean(\n value\n && typeof value === 'object'\n && Symbol.asyncIterator in value\n && typeof value[Symbol.asyncIterator] === 'function',\n );\n}\n\nfunction readServiceStatus(error: unknown): number | undefined {\n if (!error || typeof error !== 'object' || !('$metadata' in error)) {\n return undefined;\n }\n const metadata = (error as { $metadata?: { httpStatusCode?: unknown } })\n .$metadata;\n const status = metadata?.httpStatusCode;\n return typeof status === 'number' && status >= 400 && status <= 599\n ? status\n : undefined;\n}\n\nfunction readErrorName(error: unknown): string {\n return error instanceof Error ? error.name : '';\n}\n\nexport const AGENTCORE_FORWARDED_HEADER_NAMES = Object.freeze([\n EXECUTION_ASSERTION_HEADER,\n MCP_CAPABILITY_HEADER,\n MODEL_API_KEY_HEADER,\n] as const);\n\nexport const AGENTCORE_EXCLUDED_HEADER_NAMES = Object.freeze([\n EXECUTION_HOST_LOCAL_TOKEN_HEADER,\n] as const);\n"]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { AGENTCORE_EXCLUDED_HEADER_NAMES, AGENTCORE_FORWARDED_HEADER_NAMES, AgentCoreExecutionHost, } from './agentcore-execution-host.js';
|
|
2
|
+
export { AgentCoreExecutionTargetSchema, AgentCoreQualifierSchema, AgentCoreRegionSchema, AgentCoreRuntimeArnSchema, } from './schemas.js';
|
|
3
|
+
export type { AgentCoreExecutionTarget } from './schemas.js';
|
|
2
4
|
export type { AgentCoreExecutionHostConfig, AgentCoreRuntimeClient, } from './types.js';
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agentcore/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAC/B,gCAAgC,EAChC,sBAAsB,GACvB,MAAM,+BAA+B,CAAC;AACvC,YAAY,EACV,4BAA4B,EAC5B,sBAAsB,GACvB,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agentcore/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAC/B,gCAAgC,EAChC,sBAAsB,GACvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,8BAA8B,EAC9B,wBAAwB,EACxB,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAC7D,YAAY,EACV,4BAA4B,EAC5B,sBAAsB,GACvB,MAAM,YAAY,CAAC"}
|
package/dist/agentcore/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { AGENTCORE_EXCLUDED_HEADER_NAMES, AGENTCORE_FORWARDED_HEADER_NAMES, AgentCoreExecutionHost, } from './agentcore-execution-host.js';
|
|
2
|
+
export { AgentCoreExecutionTargetSchema, AgentCoreQualifierSchema, AgentCoreRegionSchema, AgentCoreRuntimeArnSchema, } from './schemas.js';
|
|
2
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agentcore/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAC/B,gCAAgC,EAChC,sBAAsB,GACvB,MAAM,+BAA+B,CAAC","sourcesContent":["export {\n AGENTCORE_EXCLUDED_HEADER_NAMES,\n AGENTCORE_FORWARDED_HEADER_NAMES,\n AgentCoreExecutionHost,\n} from './agentcore-execution-host.js';\nexport type {\n AgentCoreExecutionHostConfig,\n AgentCoreRuntimeClient,\n} from './types.js';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agentcore/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAC/B,gCAAgC,EAChC,sBAAsB,GACvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,8BAA8B,EAC9B,wBAAwB,EACxB,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,cAAc,CAAC","sourcesContent":["export {\n AGENTCORE_EXCLUDED_HEADER_NAMES,\n AGENTCORE_FORWARDED_HEADER_NAMES,\n AgentCoreExecutionHost,\n} from './agentcore-execution-host.js';\nexport {\n AgentCoreExecutionTargetSchema,\n AgentCoreQualifierSchema,\n AgentCoreRegionSchema,\n AgentCoreRuntimeArnSchema,\n} from './schemas.js';\nexport type { AgentCoreExecutionTarget } from './schemas.js';\nexport type {\n AgentCoreExecutionHostConfig,\n AgentCoreRuntimeClient,\n} from './types.js';\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const AgentCoreRegionSchema: z.ZodString;
|
|
3
|
+
export declare const AgentCoreRuntimeArnSchema: z.ZodString;
|
|
4
|
+
export declare const AgentCoreQualifierSchema: z.ZodString;
|
|
5
|
+
export declare const AgentCoreExecutionTargetSchema: z.ZodObject<{
|
|
6
|
+
region: z.ZodString;
|
|
7
|
+
runtimeArn: z.ZodString;
|
|
8
|
+
qualifier: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, z.core.$strict>;
|
|
10
|
+
export type AgentCoreExecutionTarget = z.infer<typeof AgentCoreExecutionTargetSchema>;
|
|
11
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/agentcore/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,qBAAqB,aAGjC,CAAC;AAEF,eAAO,MAAM,yBAAyB,aAInC,CAAC;AAEJ,eAAO,MAAM,wBAAwB,aAIlC,CAAC;AAEJ,eAAO,MAAM,8BAA8B;;;;kBAIhC,CAAC;AAEZ,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,8BAA8B,CACtC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const AgentCoreRegionSchema = z.string().trim().min(1).max(64).regex(/^[a-z]{2}(?:-[a-z0-9]+)+-\d+$/, 'must be an AWS region identifier');
|
|
3
|
+
export const AgentCoreRuntimeArnSchema = z.string().trim().min(20).max(2_048)
|
|
4
|
+
.regex(/^arn:[a-z0-9-]+:bedrock-agentcore:[a-z0-9-]+:\d{12}:runtime\/[A-Za-z0-9_-]+$/, 'must be an AgentCore Runtime ARN');
|
|
5
|
+
export const AgentCoreQualifierSchema = z.string().trim().min(1).max(64)
|
|
6
|
+
.regex(/^[A-Za-z0-9][A-Za-z0-9_-]*$/, 'must be an AgentCore endpoint qualifier');
|
|
7
|
+
export const AgentCoreExecutionTargetSchema = z.object({
|
|
8
|
+
region: AgentCoreRegionSchema,
|
|
9
|
+
runtimeArn: AgentCoreRuntimeArnSchema,
|
|
10
|
+
qualifier: AgentCoreQualifierSchema.optional(),
|
|
11
|
+
}).strict();
|
|
12
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/agentcore/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,KAAK,CACzE,+BAA+B,EAC/B,kCAAkC,CACnC,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;KAC1E,KAAK,CACJ,8EAA8E,EAC9E,kCAAkC,CACnC,CAAC;AAEJ,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;KACrE,KAAK,CACJ,6BAA6B,EAC7B,yCAAyC,CAC1C,CAAC;AAEJ,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,CAAC,MAAM,CAAC;IACrD,MAAM,EAAE,qBAAqB;IAC7B,UAAU,EAAE,yBAAyB;IACrC,SAAS,EAAE,wBAAwB,CAAC,QAAQ,EAAE;CAC/C,CAAC,CAAC,MAAM,EAAE,CAAC","sourcesContent":["import { z } from 'zod';\n\nexport const AgentCoreRegionSchema = z.string().trim().min(1).max(64).regex(\n /^[a-z]{2}(?:-[a-z0-9]+)+-\\d+$/,\n 'must be an AWS region identifier',\n);\n\nexport const AgentCoreRuntimeArnSchema = z.string().trim().min(20).max(2_048)\n .regex(\n /^arn:[a-z0-9-]+:bedrock-agentcore:[a-z0-9-]+:\\d{12}:runtime\\/[A-Za-z0-9_-]+$/,\n 'must be an AgentCore Runtime ARN',\n );\n\nexport const AgentCoreQualifierSchema = z.string().trim().min(1).max(64)\n .regex(\n /^[A-Za-z0-9][A-Za-z0-9_-]*$/,\n 'must be an AgentCore endpoint qualifier',\n );\n\nexport const AgentCoreExecutionTargetSchema = z.object({\n region: AgentCoreRegionSchema,\n runtimeArn: AgentCoreRuntimeArnSchema,\n qualifier: AgentCoreQualifierSchema.optional(),\n}).strict();\n\nexport type AgentCoreExecutionTarget = z.infer<\n typeof AgentCoreExecutionTargetSchema\n>;\n"]}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import type { InvokeAgentRuntimeCommand, InvokeAgentRuntimeCommandOutput } from '@aws-sdk/client-bedrock-agentcore';
|
|
2
|
+
import type { AgentCoreExecutionTarget } from './schemas.js';
|
|
2
3
|
export interface AgentCoreRuntimeClient {
|
|
3
4
|
send(command: InvokeAgentRuntimeCommand, options?: {
|
|
4
5
|
abortSignal?: AbortSignal;
|
|
5
6
|
}): Promise<InvokeAgentRuntimeCommandOutput>;
|
|
6
7
|
destroy?(): void;
|
|
7
8
|
}
|
|
8
|
-
export type AgentCoreExecutionHostConfig = {
|
|
9
|
-
region: string;
|
|
10
|
-
runtimeArn: string;
|
|
11
|
-
qualifier?: string;
|
|
9
|
+
export type AgentCoreExecutionHostConfig = AgentCoreExecutionTarget & {
|
|
12
10
|
client?: AgentCoreRuntimeClient;
|
|
13
11
|
};
|
|
14
12
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/agentcore/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,+BAA+B,EAChC,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/agentcore/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,+BAA+B,EAChC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAE7D,MAAM,WAAW,sBAAsB;IACrC,IAAI,CACF,OAAO,EAAE,yBAAyB,EAClC,OAAO,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,WAAW,CAAA;KAAE,GACtC,OAAO,CAAC,+BAA+B,CAAC,CAAC;IAC5C,OAAO,CAAC,IAAI,IAAI,CAAC;CAClB;AAED,MAAM,MAAM,4BAA4B,GAAG,wBAAwB,GAAG;IACpE,MAAM,CAAC,EAAE,sBAAsB,CAAC;CACjC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/agentcore/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n InvokeAgentRuntimeCommand,\n InvokeAgentRuntimeCommandOutput,\n} from '@aws-sdk/client-bedrock-agentcore';\n\nexport interface AgentCoreRuntimeClient {\n send(\n command: InvokeAgentRuntimeCommand,\n options?: { abortSignal?: AbortSignal },\n ): Promise<InvokeAgentRuntimeCommandOutput>;\n destroy?(): void;\n}\n\nexport type AgentCoreExecutionHostConfig = {\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/agentcore/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n InvokeAgentRuntimeCommand,\n InvokeAgentRuntimeCommandOutput,\n} from '@aws-sdk/client-bedrock-agentcore';\nimport type { AgentCoreExecutionTarget } from './schemas.js';\n\nexport interface AgentCoreRuntimeClient {\n send(\n command: InvokeAgentRuntimeCommand,\n options?: { abortSignal?: AbortSignal },\n ): Promise<InvokeAgentRuntimeCommandOutput>;\n destroy?(): void;\n}\n\nexport type AgentCoreExecutionHostConfig = AgentCoreExecutionTarget & {\n client?: AgentCoreRuntimeClient;\n};\n"]}
|