agentfootprint 11.4.0 → 12.0.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/CAPABILITIES.md +3 -1
- package/dist/adapters/code/agentcore.js +295 -214
- package/dist/adapters/code/agentcore.js.map +1 -1
- package/dist/adapters/code/agentcoreClient.js +178 -0
- package/dist/adapters/code/agentcoreClient.js.map +1 -0
- package/dist/adapters/code/agentcoreWire.js +348 -0
- package/dist/adapters/code/agentcoreWire.js.map +1 -0
- package/dist/adapters/code/fileName.js +100 -0
- package/dist/adapters/code/fileName.js.map +1 -0
- package/dist/adapters/code/local.js +529 -183
- package/dist/adapters/code/local.js.map +1 -1
- package/dist/adapters/code/output.js +140 -0
- package/dist/adapters/code/output.js.map +1 -0
- package/dist/adapters/mcp/agentcoreRuntime/invoke.js +7 -6
- package/dist/adapters/mcp/agentcoreRuntime/invoke.js.map +1 -1
- package/dist/adapters/mcp/agentcoreRuntime/sessionBusy.js +36 -2
- package/dist/adapters/mcp/agentcoreRuntime/sessionBusy.js.map +1 -1
- package/dist/adapters/mcp/agentcoreRuntime/transport.js +3 -1
- package/dist/adapters/mcp/agentcoreRuntime/transport.js.map +1 -1
- package/dist/core/codeRunnerTool.js +52 -7
- package/dist/core/codeRunnerTool.js.map +1 -1
- package/dist/doors/providers.js.map +1 -1
- package/dist/esm/adapters/code/agentcore.d.ts +65 -68
- package/dist/esm/adapters/code/agentcore.js +293 -212
- package/dist/esm/adapters/code/agentcore.js.map +1 -1
- package/dist/esm/adapters/code/agentcoreClient.d.ts +193 -0
- package/dist/esm/adapters/code/agentcoreClient.js +173 -0
- package/dist/esm/adapters/code/agentcoreClient.js.map +1 -0
- package/dist/esm/adapters/code/agentcoreWire.d.ts +119 -0
- package/dist/esm/adapters/code/agentcoreWire.js +334 -0
- package/dist/esm/adapters/code/agentcoreWire.js.map +1 -0
- package/dist/esm/adapters/code/fileName.d.ts +43 -0
- package/dist/esm/adapters/code/fileName.js +96 -0
- package/dist/esm/adapters/code/fileName.js.map +1 -0
- package/dist/esm/adapters/code/local.d.ts +91 -12
- package/dist/esm/adapters/code/local.js +528 -182
- package/dist/esm/adapters/code/local.js.map +1 -1
- package/dist/esm/adapters/code/output.d.ts +70 -0
- package/dist/esm/adapters/code/output.js +129 -0
- package/dist/esm/adapters/code/output.js.map +1 -0
- package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.d.ts +7 -6
- package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.js +7 -6
- package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.js.map +1 -1
- package/dist/esm/adapters/mcp/agentcoreRuntime/sessionBusy.d.ts +32 -1
- package/dist/esm/adapters/mcp/agentcoreRuntime/sessionBusy.js +35 -1
- package/dist/esm/adapters/mcp/agentcoreRuntime/sessionBusy.js.map +1 -1
- package/dist/esm/adapters/mcp/agentcoreRuntime/transport.js +4 -2
- package/dist/esm/adapters/mcp/agentcoreRuntime/transport.js.map +1 -1
- package/dist/esm/core/codeRunnerTool.d.ts +15 -3
- package/dist/esm/core/codeRunnerTool.js +52 -7
- package/dist/esm/core/codeRunnerTool.js.map +1 -1
- package/dist/esm/doors/providers.d.ts +1 -1
- package/dist/esm/doors/providers.js.map +1 -1
- package/dist/esm/events/payloads.d.ts +144 -29
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/mcp/callLifetime.d.ts +57 -14
- package/dist/esm/mcp/callLifetime.js +67 -19
- package/dist/esm/mcp/callLifetime.js.map +1 -1
- package/dist/esm/mcp/callMarker.d.ts +43 -0
- package/dist/esm/mcp/callMarker.js +69 -0
- package/dist/esm/mcp/callMarker.js.map +1 -0
- package/dist/esm/mcp/connectionRefusals.js +7 -0
- package/dist/esm/mcp/connectionRefusals.js.map +1 -1
- package/dist/esm/mcp/index.d.ts +2 -0
- package/dist/esm/mcp/index.js +3 -0
- package/dist/esm/mcp/index.js.map +1 -1
- package/dist/esm/mcp/mcpClient.js +93 -26
- package/dist/esm/mcp/mcpClient.js.map +1 -1
- package/dist/esm/mcp/replay.d.ts +291 -0
- package/dist/esm/mcp/replay.js +405 -0
- package/dist/esm/mcp/replay.js.map +1 -0
- package/dist/esm/mcp/replayUnavailable.d.ts +68 -0
- package/dist/esm/mcp/replayUnavailable.js +87 -0
- package/dist/esm/mcp/replayUnavailable.js.map +1 -0
- package/dist/esm/mcp/requestLedger.d.ts +115 -32
- package/dist/esm/mcp/requestLedger.js +193 -52
- package/dist/esm/mcp/requestLedger.js.map +1 -1
- package/dist/esm/mcp/seriesEvidence.d.ts +73 -15
- package/dist/esm/mcp/seriesEvidence.js +114 -21
- package/dist/esm/mcp/seriesEvidence.js.map +1 -1
- package/dist/esm/mcp/throttleRetry.d.ts +86 -42
- package/dist/esm/mcp/throttleRetry.js +158 -50
- package/dist/esm/mcp/throttleRetry.js.map +1 -1
- package/dist/esm/mcp/toolResult.d.ts +6 -0
- package/dist/esm/mcp/toolResult.js +15 -0
- package/dist/esm/mcp/toolResult.js.map +1 -1
- package/dist/esm/mcp/types.d.ts +73 -8
- package/dist/esm/provider-contract/codeSandbox.d.ts +89 -0
- package/dist/esm/provider-contract/codeSandbox.js +119 -0
- package/dist/esm/provider-contract/codeSandbox.js.map +1 -0
- package/dist/esm/provider-contract/sessionExpired.d.ts +31 -0
- package/dist/esm/provider-contract/sessionExpired.js +40 -0
- package/dist/esm/provider-contract/sessionExpired.js.map +1 -0
- package/dist/esm/provider-contract/types.d.ts +166 -17
- package/dist/esm/provider-contract/types.js +9 -0
- package/dist/esm/provider-contract/types.js.map +1 -1
- package/dist/esm/redaction/knownStrings.js +16 -0
- package/dist/esm/redaction/knownStrings.js.map +1 -1
- package/dist/esm/tool-providers/index.d.ts +2 -2
- package/dist/esm/tool-providers/index.js +4 -0
- package/dist/esm/tool-providers/index.js.map +1 -1
- package/dist/esm/tools/requestEvidence.js +60 -0
- package/dist/esm/tools/requestEvidence.js.map +1 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/mcp/callLifetime.js +66 -18
- package/dist/mcp/callLifetime.js.map +1 -1
- package/dist/mcp/callMarker.js +74 -0
- package/dist/mcp/callMarker.js.map +1 -0
- package/dist/mcp/connectionRefusals.js +7 -0
- package/dist/mcp/connectionRefusals.js.map +1 -1
- package/dist/mcp/index.js +5 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/mcpClient.js +91 -24
- package/dist/mcp/mcpClient.js.map +1 -1
- package/dist/mcp/replay.js +415 -0
- package/dist/mcp/replay.js.map +1 -0
- package/dist/mcp/replayUnavailable.js +92 -0
- package/dist/mcp/replayUnavailable.js.map +1 -0
- package/dist/mcp/requestLedger.js +193 -52
- package/dist/mcp/requestLedger.js.map +1 -1
- package/dist/mcp/seriesEvidence.js +116 -22
- package/dist/mcp/seriesEvidence.js.map +1 -1
- package/dist/mcp/throttleRetry.js +160 -51
- package/dist/mcp/throttleRetry.js.map +1 -1
- package/dist/mcp/toolResult.js +17 -1
- package/dist/mcp/toolResult.js.map +1 -1
- package/dist/provider-contract/codeSandbox.js +125 -0
- package/dist/provider-contract/codeSandbox.js.map +1 -0
- package/dist/provider-contract/sessionExpired.js +44 -0
- package/dist/provider-contract/sessionExpired.js.map +1 -0
- package/dist/provider-contract/types.js +12 -1
- package/dist/provider-contract/types.js.map +1 -1
- package/dist/redaction/knownStrings.js +16 -0
- package/dist/redaction/knownStrings.js.map +1 -1
- package/dist/tool-providers/index.js +5 -1
- package/dist/tool-providers/index.js.map +1 -1
- package/dist/tools/requestEvidence.js +60 -0
- package/dist/tools/requestEvidence.js.map +1 -1
- package/dist/types/adapters/code/agentcore.d.ts +65 -68
- package/dist/types/adapters/code/agentcore.d.ts.map +1 -1
- package/dist/types/adapters/code/agentcoreClient.d.ts +194 -0
- package/dist/types/adapters/code/agentcoreClient.d.ts.map +1 -0
- package/dist/types/adapters/code/agentcoreWire.d.ts +120 -0
- package/dist/types/adapters/code/agentcoreWire.d.ts.map +1 -0
- package/dist/types/adapters/code/fileName.d.ts +44 -0
- package/dist/types/adapters/code/fileName.d.ts.map +1 -0
- package/dist/types/adapters/code/local.d.ts +91 -12
- package/dist/types/adapters/code/local.d.ts.map +1 -1
- package/dist/types/adapters/code/output.d.ts +71 -0
- package/dist/types/adapters/code/output.d.ts.map +1 -0
- package/dist/types/adapters/mcp/agentcoreRuntime/invoke.d.ts +7 -6
- package/dist/types/adapters/mcp/agentcoreRuntime/invoke.d.ts.map +1 -1
- package/dist/types/adapters/mcp/agentcoreRuntime/sessionBusy.d.ts +32 -1
- package/dist/types/adapters/mcp/agentcoreRuntime/sessionBusy.d.ts.map +1 -1
- package/dist/types/adapters/mcp/agentcoreRuntime/transport.d.ts.map +1 -1
- package/dist/types/core/codeRunnerTool.d.ts +15 -3
- package/dist/types/core/codeRunnerTool.d.ts.map +1 -1
- package/dist/types/doors/providers.d.ts +1 -1
- package/dist/types/doors/providers.d.ts.map +1 -1
- package/dist/types/events/payloads.d.ts +144 -29
- package/dist/types/events/payloads.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/mcp/callLifetime.d.ts +57 -14
- package/dist/types/mcp/callLifetime.d.ts.map +1 -1
- package/dist/types/mcp/callMarker.d.ts +44 -0
- package/dist/types/mcp/callMarker.d.ts.map +1 -0
- package/dist/types/mcp/index.d.ts +2 -0
- package/dist/types/mcp/index.d.ts.map +1 -1
- package/dist/types/mcp/mcpClient.d.ts.map +1 -1
- package/dist/types/mcp/replay.d.ts +292 -0
- package/dist/types/mcp/replay.d.ts.map +1 -0
- package/dist/types/mcp/replayUnavailable.d.ts +69 -0
- package/dist/types/mcp/replayUnavailable.d.ts.map +1 -0
- package/dist/types/mcp/requestLedger.d.ts +115 -32
- package/dist/types/mcp/requestLedger.d.ts.map +1 -1
- package/dist/types/mcp/seriesEvidence.d.ts +73 -15
- package/dist/types/mcp/seriesEvidence.d.ts.map +1 -1
- package/dist/types/mcp/throttleRetry.d.ts +86 -42
- package/dist/types/mcp/throttleRetry.d.ts.map +1 -1
- package/dist/types/mcp/toolResult.d.ts +6 -0
- package/dist/types/mcp/toolResult.d.ts.map +1 -1
- package/dist/types/mcp/types.d.ts +73 -8
- package/dist/types/mcp/types.d.ts.map +1 -1
- package/dist/types/provider-contract/codeSandbox.d.ts +90 -0
- package/dist/types/provider-contract/codeSandbox.d.ts.map +1 -0
- package/dist/types/provider-contract/sessionExpired.d.ts +32 -0
- package/dist/types/provider-contract/sessionExpired.d.ts.map +1 -0
- package/dist/types/provider-contract/types.d.ts +166 -17
- package/dist/types/provider-contract/types.d.ts.map +1 -1
- package/dist/types/redaction/knownStrings.d.ts.map +1 -1
- package/dist/types/tool-providers/index.d.ts +2 -2
- package/dist/types/tool-providers/index.d.ts.map +1 -1
- package/dist/types/tools/requestEvidence.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The AgentCore Code Interpreter client seam: the operation-semantic surface
|
|
3
|
+
* `agentCoreCodeRunner` calls, and its ONE mapping onto the real SDK.
|
|
4
|
+
*
|
|
5
|
+
* Two things this file owns and nothing else does:
|
|
6
|
+
*
|
|
7
|
+
* • the COMMAND FORM — a bare `@aws-sdk/client-*` client is command-based:
|
|
8
|
+
* `client.send(new SomeCommand(input))`, never a method on the client
|
|
9
|
+
* (the 9.4.0 law; `BedrockAgentCoreClient.prototype.startCodeInterpreterSession`
|
|
10
|
+
* is `undefined`, the shortcut exists only on the aggregated client);
|
|
11
|
+
* • the DRAIN of `InvokeCodeInterpreterResponse.stream`, an event stream
|
|
12
|
+
* whose members are `{ result }` or a modelled EXCEPTION.
|
|
13
|
+
*
|
|
14
|
+
* The request and response shapes below were read off a real install of
|
|
15
|
+
* `@aws-sdk/client-bedrock-agentcore` 3.1159.0 (`InvokeCodeInterpreterRequest`,
|
|
16
|
+
* `ToolArguments`, `InputContentBlock`, `CodeInterpreterResult`,
|
|
17
|
+
* `ResourceContent`, `ToolResultStructuredContent`) and are pinned against
|
|
18
|
+
* transcribed copies of those types in
|
|
19
|
+
* `test/type-regressions/AgentCoreCodeInterpreter.sdk.test.ts`.
|
|
20
|
+
*
|
|
21
|
+
* Pattern: Adapter (GoF) + lazy peer-dep load — the SDK is required only when
|
|
22
|
+
* a session first starts (or never, if you inject `_client` / `_sdk`).
|
|
23
|
+
*/
|
|
24
|
+
/** The operation-semantic surface `agentCoreCodeRunner` calls. Inject your own as `_client`. */
|
|
25
|
+
export interface AgentCoreCodeClientLike {
|
|
26
|
+
startSession(input: {
|
|
27
|
+
readonly codeInterpreterIdentifier: string;
|
|
28
|
+
readonly name?: string;
|
|
29
|
+
readonly sessionTimeoutSeconds?: number;
|
|
30
|
+
}): Promise<{
|
|
31
|
+
readonly sessionId?: string;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* One `InvokeCodeInterpreter` call, its event stream already drained.
|
|
35
|
+
*
|
|
36
|
+
* `options.abortSignal` cancels the request where the client can; the
|
|
37
|
+
* adapter also stops WAITING when it fires, so a client that ignores it
|
|
38
|
+
* cannot hold a caller open.
|
|
39
|
+
*/
|
|
40
|
+
invoke(input: AgentCoreInvokeInput, options?: {
|
|
41
|
+
readonly abortSignal?: AbortSignal;
|
|
42
|
+
}): Promise<AgentCoreInvokeAnswer>;
|
|
43
|
+
stopSession(input: {
|
|
44
|
+
readonly codeInterpreterIdentifier: string;
|
|
45
|
+
readonly sessionId: string;
|
|
46
|
+
}): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
/** Which interpreter, and which of its sessions, one invoke goes to. */
|
|
49
|
+
export interface AgentCoreInvokeTarget {
|
|
50
|
+
readonly codeInterpreterIdentifier: string;
|
|
51
|
+
readonly sessionId: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* One file for `writeFiles` — AgentCore's `InputContentBlock`: TEXT for a
|
|
55
|
+
* string, BYTES for a `Uint8Array`, never both, and never bytes smuggled
|
|
56
|
+
* through text as base64.
|
|
57
|
+
*/
|
|
58
|
+
export type AgentCoreFileContent = {
|
|
59
|
+
readonly path: string;
|
|
60
|
+
readonly text: string;
|
|
61
|
+
readonly blob?: never;
|
|
62
|
+
} | {
|
|
63
|
+
readonly path: string;
|
|
64
|
+
readonly blob: Uint8Array;
|
|
65
|
+
readonly text?: never;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* One `InvokeCodeInterpreter` request: the four of the service's tool names
|
|
69
|
+
* this adapter sends, each with exactly the arguments AgentCore takes for it.
|
|
70
|
+
*/
|
|
71
|
+
export type AgentCoreInvokeInput = AgentCoreInvokeTarget & ({
|
|
72
|
+
readonly name: 'executeCode';
|
|
73
|
+
readonly arguments: {
|
|
74
|
+
readonly code: string;
|
|
75
|
+
readonly language?: string;
|
|
76
|
+
};
|
|
77
|
+
} | {
|
|
78
|
+
readonly name: 'executeCommand';
|
|
79
|
+
readonly arguments: {
|
|
80
|
+
readonly command: string;
|
|
81
|
+
};
|
|
82
|
+
} | {
|
|
83
|
+
readonly name: 'writeFiles';
|
|
84
|
+
readonly arguments: {
|
|
85
|
+
readonly content: readonly AgentCoreFileContent[];
|
|
86
|
+
};
|
|
87
|
+
} | {
|
|
88
|
+
readonly name: 'readFiles';
|
|
89
|
+
readonly arguments: {
|
|
90
|
+
readonly paths: readonly string[];
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
/** What `invoke` reports back, already drained of its event stream — only what the service sent. */
|
|
94
|
+
export interface AgentCoreInvokeAnswer {
|
|
95
|
+
readonly stdout: string;
|
|
96
|
+
readonly stderr: string;
|
|
97
|
+
/** The exit status the service reported; absent when no result carried one. */
|
|
98
|
+
readonly exitCode?: number;
|
|
99
|
+
/**
|
|
100
|
+
* The service's own error flag: `true` when any result was flagged, `false`
|
|
101
|
+
* when results said `false` and none said `true`, ABSENT when no result
|
|
102
|
+
* carried the flag at all. Absent is not `false`.
|
|
103
|
+
*/
|
|
104
|
+
readonly isError?: boolean;
|
|
105
|
+
/** Every embedded resource the answer carried, in order — what `readFiles`
|
|
106
|
+
* answers with. Absent when there were none. */
|
|
107
|
+
readonly resources?: readonly AgentCoreResource[];
|
|
108
|
+
}
|
|
109
|
+
/** One embedded resource (AgentCore's `ResourceContent`), as the service sent it. */
|
|
110
|
+
export interface AgentCoreResource {
|
|
111
|
+
readonly uri?: string;
|
|
112
|
+
readonly mimeType?: string;
|
|
113
|
+
readonly text?: string;
|
|
114
|
+
readonly blob?: Uint8Array;
|
|
115
|
+
}
|
|
116
|
+
/** The slice of `@aws-sdk/client-bedrock-agentcore` this shim touches. */
|
|
117
|
+
export interface BedrockAgentCoreCodeSdkModule {
|
|
118
|
+
readonly BedrockAgentCoreClient?: new (config: {
|
|
119
|
+
region?: string;
|
|
120
|
+
}) => {
|
|
121
|
+
send(cmd: unknown, options?: {
|
|
122
|
+
abortSignal?: AbortSignal;
|
|
123
|
+
}): Promise<unknown>;
|
|
124
|
+
};
|
|
125
|
+
readonly StartCodeInterpreterSessionCommand?: new (input: unknown) => unknown;
|
|
126
|
+
readonly InvokeCodeInterpreterCommand?: new (input: unknown) => unknown;
|
|
127
|
+
readonly StopCodeInterpreterSessionCommand?: new (input: unknown) => unknown;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Map {@link AgentCoreCodeClientLike} onto the real SDK commands.
|
|
131
|
+
*/
|
|
132
|
+
export declare function createCodeClient(options: {
|
|
133
|
+
readonly region?: string;
|
|
134
|
+
readonly _sdk?: BedrockAgentCoreCodeSdkModule;
|
|
135
|
+
}): AgentCoreCodeClientLike;
|
|
136
|
+
/** One event off `InvokeCodeInterpreterResponse.stream` — the fields this adapter reads. */
|
|
137
|
+
export interface CodeInterpreterStreamOutputLike {
|
|
138
|
+
readonly result?: {
|
|
139
|
+
readonly content?: readonly {
|
|
140
|
+
readonly type?: string;
|
|
141
|
+
readonly text?: string;
|
|
142
|
+
readonly name?: string;
|
|
143
|
+
readonly resource?: AgentCoreResource;
|
|
144
|
+
}[];
|
|
145
|
+
readonly structuredContent?: {
|
|
146
|
+
readonly stdout?: string;
|
|
147
|
+
readonly stderr?: string;
|
|
148
|
+
readonly exitCode?: number;
|
|
149
|
+
};
|
|
150
|
+
readonly isError?: boolean;
|
|
151
|
+
};
|
|
152
|
+
readonly accessDeniedException?: {
|
|
153
|
+
readonly message?: string;
|
|
154
|
+
};
|
|
155
|
+
readonly conflictException?: {
|
|
156
|
+
readonly message?: string;
|
|
157
|
+
};
|
|
158
|
+
readonly internalServerException?: {
|
|
159
|
+
readonly message?: string;
|
|
160
|
+
};
|
|
161
|
+
readonly resourceNotFoundException?: {
|
|
162
|
+
readonly message?: string;
|
|
163
|
+
};
|
|
164
|
+
readonly serviceQuotaExceededException?: {
|
|
165
|
+
readonly message?: string;
|
|
166
|
+
};
|
|
167
|
+
readonly throttlingException?: {
|
|
168
|
+
readonly message?: string;
|
|
169
|
+
};
|
|
170
|
+
readonly validationException?: {
|
|
171
|
+
readonly message?: string;
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/** Every modelled error member of the stream union, in SDK spelling. */
|
|
175
|
+
export declare const STREAM_ERROR_MEMBERS: readonly ["accessDeniedException", "conflictException", "internalServerException", "resourceNotFoundException", "serviceQuotaExceededException", "throttlingException", "validationException"];
|
|
176
|
+
/**
|
|
177
|
+
* Drain the event stream into one answer.
|
|
178
|
+
*
|
|
179
|
+
* An ERROR MEMBER RAISES. This is the honesty line for this adapter: the SDK
|
|
180
|
+
* models seven failure shapes as ordinary members of the stream union, so an
|
|
181
|
+
* `AccessDeniedException` arrives as a value, not a rejection. Folding it in
|
|
182
|
+
* as empty output would report a clean run in which the code "printed
|
|
183
|
+
* nothing" — a silent success, at the exact moment an operator most needs the
|
|
184
|
+
* word "AccessDenied".
|
|
185
|
+
*
|
|
186
|
+
* Nothing is filled in that the stream did not carry: no exit status, no
|
|
187
|
+
* error flag. And a file operation whose stream ended with no result at all
|
|
188
|
+
* (`requireResult`) is a broken call, not an empty answer.
|
|
189
|
+
*/
|
|
190
|
+
export declare function drainStream(stream: AsyncIterable<CodeInterpreterStreamOutputLike> | undefined, options: {
|
|
191
|
+
readonly requireResult: boolean;
|
|
192
|
+
readonly signal?: AbortSignal;
|
|
193
|
+
}): Promise<AgentCoreInvokeAnswer>;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The AgentCore Code Interpreter client seam: the operation-semantic surface
|
|
3
|
+
* `agentCoreCodeRunner` calls, and its ONE mapping onto the real SDK.
|
|
4
|
+
*
|
|
5
|
+
* Two things this file owns and nothing else does:
|
|
6
|
+
*
|
|
7
|
+
* • the COMMAND FORM — a bare `@aws-sdk/client-*` client is command-based:
|
|
8
|
+
* `client.send(new SomeCommand(input))`, never a method on the client
|
|
9
|
+
* (the 9.4.0 law; `BedrockAgentCoreClient.prototype.startCodeInterpreterSession`
|
|
10
|
+
* is `undefined`, the shortcut exists only on the aggregated client);
|
|
11
|
+
* • the DRAIN of `InvokeCodeInterpreterResponse.stream`, an event stream
|
|
12
|
+
* whose members are `{ result }` or a modelled EXCEPTION.
|
|
13
|
+
*
|
|
14
|
+
* The request and response shapes below were read off a real install of
|
|
15
|
+
* `@aws-sdk/client-bedrock-agentcore` 3.1159.0 (`InvokeCodeInterpreterRequest`,
|
|
16
|
+
* `ToolArguments`, `InputContentBlock`, `CodeInterpreterResult`,
|
|
17
|
+
* `ResourceContent`, `ToolResultStructuredContent`) and are pinned against
|
|
18
|
+
* transcribed copies of those types in
|
|
19
|
+
* `test/type-regressions/AgentCoreCodeInterpreter.sdk.test.ts`.
|
|
20
|
+
*
|
|
21
|
+
* Pattern: Adapter (GoF) + lazy peer-dep load — the SDK is required only when
|
|
22
|
+
* a session first starts (or never, if you inject `_client` / `_sdk`).
|
|
23
|
+
*/
|
|
24
|
+
import { abortableIterable } from '../../lib/abort.js';
|
|
25
|
+
import { lazyRequire } from '../../lib/lazyRequire.js';
|
|
26
|
+
/** The tool names whose answer is only an answer if it carried a result. */
|
|
27
|
+
const RESULT_REQUIRED = new Set([
|
|
28
|
+
'writeFiles',
|
|
29
|
+
'readFiles',
|
|
30
|
+
]);
|
|
31
|
+
/**
|
|
32
|
+
* Map {@link AgentCoreCodeClientLike} onto the real SDK commands.
|
|
33
|
+
*/
|
|
34
|
+
export function createCodeClient(options) {
|
|
35
|
+
let mod;
|
|
36
|
+
if (options._sdk) {
|
|
37
|
+
mod = options._sdk;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
try {
|
|
41
|
+
// Lazy peer-dep: only loaded when no _client/_sdk is injected and start() runs.
|
|
42
|
+
mod = lazyRequire('@aws-sdk/client-bedrock-agentcore');
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
throw new Error('agentCoreCodeRunner requires the `@aws-sdk/client-bedrock-agentcore` peer dependency.\n' +
|
|
46
|
+
' Install: npm install @aws-sdk/client-bedrock-agentcore\n' +
|
|
47
|
+
' Or pass `_client` for a pre-built or mock client.\n' +
|
|
48
|
+
' For a local dev loop with no AWS at all, use `localCodeRunner()`.');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (!mod.BedrockAgentCoreClient) {
|
|
52
|
+
throw new Error('agentCoreCodeRunner: `@aws-sdk/client-bedrock-agentcore` is installed but ' +
|
|
53
|
+
'`BedrockAgentCoreClient` was not found. Update the SDK.');
|
|
54
|
+
}
|
|
55
|
+
const sdk = new mod.BedrockAgentCoreClient({ ...(options.region && { region: options.region }) });
|
|
56
|
+
const send = async (Ctor, name, input, abortSignal) => {
|
|
57
|
+
if (!Ctor) {
|
|
58
|
+
throw new Error(`agentCoreCodeRunner: \`@aws-sdk/client-bedrock-agentcore\` is missing ${name}. ` +
|
|
59
|
+
'Upgrade the SDK, or pass `_client` with your own mapping.');
|
|
60
|
+
}
|
|
61
|
+
return abortSignal ? sdk.send(new Ctor(input), { abortSignal }) : sdk.send(new Ctor(input));
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
async startSession(input) {
|
|
65
|
+
const r = (await send(mod.StartCodeInterpreterSessionCommand, 'StartCodeInterpreterSessionCommand', input));
|
|
66
|
+
return { ...(r?.sessionId !== undefined && { sessionId: r.sessionId }) };
|
|
67
|
+
},
|
|
68
|
+
async invoke(input, invokeOptions) {
|
|
69
|
+
const abortSignal = invokeOptions?.abortSignal;
|
|
70
|
+
const r = (await send(mod.InvokeCodeInterpreterCommand, 'InvokeCodeInterpreterCommand', input, abortSignal));
|
|
71
|
+
return drainStream(r?.stream, {
|
|
72
|
+
requireResult: RESULT_REQUIRED.has(input.name),
|
|
73
|
+
...(abortSignal && { signal: abortSignal }),
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
async stopSession(input) {
|
|
77
|
+
await send(mod.StopCodeInterpreterSessionCommand, 'StopCodeInterpreterSessionCommand', input);
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/** Every modelled error member of the stream union, in SDK spelling. */
|
|
82
|
+
export const STREAM_ERROR_MEMBERS = [
|
|
83
|
+
'accessDeniedException',
|
|
84
|
+
'conflictException',
|
|
85
|
+
'internalServerException',
|
|
86
|
+
'resourceNotFoundException',
|
|
87
|
+
'serviceQuotaExceededException',
|
|
88
|
+
'throttlingException',
|
|
89
|
+
'validationException',
|
|
90
|
+
];
|
|
91
|
+
/**
|
|
92
|
+
* Drain the event stream into one answer.
|
|
93
|
+
*
|
|
94
|
+
* An ERROR MEMBER RAISES. This is the honesty line for this adapter: the SDK
|
|
95
|
+
* models seven failure shapes as ordinary members of the stream union, so an
|
|
96
|
+
* `AccessDeniedException` arrives as a value, not a rejection. Folding it in
|
|
97
|
+
* as empty output would report a clean run in which the code "printed
|
|
98
|
+
* nothing" — a silent success, at the exact moment an operator most needs the
|
|
99
|
+
* word "AccessDenied".
|
|
100
|
+
*
|
|
101
|
+
* Nothing is filled in that the stream did not carry: no exit status, no
|
|
102
|
+
* error flag. And a file operation whose stream ended with no result at all
|
|
103
|
+
* (`requireResult`) is a broken call, not an empty answer.
|
|
104
|
+
*/
|
|
105
|
+
export async function drainStream(stream, options) {
|
|
106
|
+
if (!stream) {
|
|
107
|
+
throw new Error('agentCoreCodeRunner: InvokeCodeInterpreter returned no stream. The response carries ' +
|
|
108
|
+
'its payload as an event stream (`response.stream`), so an absent one is a broken ' +
|
|
109
|
+
'call, not an empty result.');
|
|
110
|
+
}
|
|
111
|
+
let stdout = '';
|
|
112
|
+
let stderr = '';
|
|
113
|
+
let exitCode;
|
|
114
|
+
let isError;
|
|
115
|
+
let results = 0;
|
|
116
|
+
const resources = [];
|
|
117
|
+
for await (const event of abortableIterable(stream, options.signal)) {
|
|
118
|
+
for (const member of STREAM_ERROR_MEMBERS) {
|
|
119
|
+
const raised = event[member];
|
|
120
|
+
if (raised) {
|
|
121
|
+
const error = new Error(`agentCoreCodeRunner: ${member} from InvokeCodeInterpreter — ` +
|
|
122
|
+
`${raised.message ?? 'no message supplied'}`);
|
|
123
|
+
error.name = member.charAt(0).toUpperCase() + member.slice(1);
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const result = event.result;
|
|
128
|
+
if (!result)
|
|
129
|
+
continue;
|
|
130
|
+
results += 1;
|
|
131
|
+
if (result.isError === true)
|
|
132
|
+
isError = true;
|
|
133
|
+
else if (result.isError === false && isError === undefined)
|
|
134
|
+
isError = false;
|
|
135
|
+
for (const block of result.content ?? []) {
|
|
136
|
+
if (block.resource !== undefined && block.resource !== null)
|
|
137
|
+
resources.push(block.resource);
|
|
138
|
+
}
|
|
139
|
+
const structured = result.structuredContent;
|
|
140
|
+
if (structured) {
|
|
141
|
+
if (structured.stdout !== undefined)
|
|
142
|
+
stdout += structured.stdout;
|
|
143
|
+
if (structured.stderr !== undefined)
|
|
144
|
+
stderr += structured.stderr;
|
|
145
|
+
if (structured.exitCode !== undefined)
|
|
146
|
+
exitCode = structured.exitCode;
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
// Fallback: a response that filled only the typed content blocks. Text
|
|
150
|
+
// blocks are the readable half; a binary/resource block is described by
|
|
151
|
+
// name rather than inlined, because inlining it is the bug this port exists
|
|
152
|
+
// to prevent.
|
|
153
|
+
for (const block of result.content ?? []) {
|
|
154
|
+
if (block.text !== undefined)
|
|
155
|
+
stdout += block.text;
|
|
156
|
+
else if (block.name !== undefined)
|
|
157
|
+
stdout += `[${block.type ?? 'resource'}: ${block.name}]`;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (options.requireResult && results === 0) {
|
|
162
|
+
throw new Error('agentCoreCodeRunner: InvokeCodeInterpreter answered a file operation with no result. ' +
|
|
163
|
+
'Nothing confirmed it, so it is not reported as done.');
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
stdout,
|
|
167
|
+
stderr,
|
|
168
|
+
...(exitCode !== undefined && { exitCode }),
|
|
169
|
+
...(isError !== undefined && { isError }),
|
|
170
|
+
...(resources.length > 0 && { resources }),
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=agentcoreClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentcoreClient.js","sourceRoot":"","sources":["../../../../src/adapters/code/agentcoreClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AA8FvD,4EAA4E;AAC5E,MAAM,eAAe,GAA8C,IAAI,GAAG,CAAC;IACzE,YAAY;IACZ,WAAW;CACZ,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAGhC;IACC,IAAI,GAAkC,CAAC;IACvC,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;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IAAI,UAAU,CAAC,MAAM,KAAK,SAAS;gBAAE,MAAM,IAAI,UAAU,CAAC,MAAM,CAAC;YACjE,IAAI,UAAU,CAAC,QAAQ,KAAK,SAAS;gBAAE,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC;QACxE,CAAC;aAAM,CAAC;YACN,uEAAuE;YACvE,wEAAwE;YACxE,4EAA4E;YAC5E,cAAc;YACd,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;gBACzC,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;oBAAE,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC;qBAC9C,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;oBAAE,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,IAAI,UAAU,KAAK,KAAK,CAAC,IAAI,GAAG,CAAC;YAC9F,CAAC;QACH,CAAC;IACH,CAAC;IACD,IAAI,OAAO,CAAC,aAAa,IAAI,OAAO,KAAK,CAAC,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CACb,uFAAuF;YACrF,sDAAsD,CACzD,CAAC;IACJ,CAAC;IACD,OAAO;QACL,MAAM;QACN,MAAM;QACN,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAE,QAAQ,EAAE,CAAC;QAC3C,GAAG,CAAC,OAAO,KAAK,SAAS,IAAI,EAAE,OAAO,EAAE,CAAC;QACzC,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;KAC3C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What `agentCoreCodeRunner` has to know about AgentCore's wire, as pure
|
|
3
|
+
* functions: how big a request is, how a returned file is paired with the
|
|
4
|
+
* path asked for, how the staged-input manifest reaches a runtime that has no
|
|
5
|
+
* environment parameter, and which service errors mean the session is gone.
|
|
6
|
+
*
|
|
7
|
+
* Kept apart from the session so each rule is one small function with its
|
|
8
|
+
* own test, and so the session reads as the sequence it is.
|
|
9
|
+
*/
|
|
10
|
+
import type { CodeFile } from '../../provider-contract/types.js';
|
|
11
|
+
import type { AgentCoreFileContent, AgentCoreInvokeAnswer, AgentCoreInvokeInput } from './agentcoreClient.js';
|
|
12
|
+
/**
|
|
13
|
+
* AgentCore's per-call limit for `InvokeCodeInterpreter`: "Max payload size —
|
|
14
|
+
* 100 MB — Maximum size for request/response payloads", not adjustable
|
|
15
|
+
* (AgentCore Code Interpreter service quotas).
|
|
16
|
+
*
|
|
17
|
+
* The service does not say whether that MB is 10^6 or 2^20 bytes, so the
|
|
18
|
+
* adapter holds a request to the SMALLER reading: a request it sends is never
|
|
19
|
+
* one the limit could refuse on size, and one between the two readings is
|
|
20
|
+
* refused here by name rather than by the service in words nobody can act on.
|
|
21
|
+
*/
|
|
22
|
+
export declare const AGENTCORE_MAX_REQUEST_BYTES = 100000000;
|
|
23
|
+
/**
|
|
24
|
+
* The size, in bytes, of the JSON body one `writeFiles` request sends —
|
|
25
|
+
* computed, not built: text as its JSON-escaped UTF-8, bytes as base64 (how
|
|
26
|
+
* the JSON protocol carries a blob), plus the envelope. Building the body to
|
|
27
|
+
* measure it would hold a second copy of up to a hundred megabytes.
|
|
28
|
+
*/
|
|
29
|
+
export declare function writeFilesRequestBytes(content: readonly AgentCoreFileContent[]): number;
|
|
30
|
+
/** Bytes of `JSON.stringify(text)` encoded as UTF-8, quotes included, without building it. */
|
|
31
|
+
export declare function jsonStringBytes(text: string): number;
|
|
32
|
+
/** One `writeFiles` entry for a payload: TEXT for a string, BYTES for bytes. */
|
|
33
|
+
export declare function fileContent(path: string, data: string | Uint8Array): AgentCoreFileContent;
|
|
34
|
+
/**
|
|
35
|
+
* The one file a `readFiles` answer returned for `path` — or a refusal.
|
|
36
|
+
*
|
|
37
|
+
* Paired by the URI the SERVICE put on the file, never by position: a file
|
|
38
|
+
* with no URI, or a URI naming another path, fails closed, and so does an
|
|
39
|
+
* answer carrying several files for one path. Text or bytes is read off which
|
|
40
|
+
* field the service filled — never off the file's name — and an entry with
|
|
41
|
+
* both, or neither, is refused. A file over `maxBytes` is refused whole.
|
|
42
|
+
*/
|
|
43
|
+
export declare function pairReadFile(path: string, answer: AgentCoreInvokeAnswer, maxBytes: number): CodeFile;
|
|
44
|
+
/**
|
|
45
|
+
* Does `uri` name `path`? ONE declared form, read ONE way (RFC 8089's file
|
|
46
|
+
* URI, RFC 3986's path syntax): `file:///` followed by a path whose segments
|
|
47
|
+
* are percent-encoded.
|
|
48
|
+
*
|
|
49
|
+
* - A raw `?` or `#` starts a query or a fragment, which is never part of a
|
|
50
|
+
* file name, so a URI carrying one is refused outright. A name that really
|
|
51
|
+
* contains `?` or `#` arrives as `%3F` / `%23`.
|
|
52
|
+
* - Each segment is decoded on its own. An invalid escape refuses the URI, and
|
|
53
|
+
* a decoded `/` (an encoded `%2F`) is a character inside one name, so it can
|
|
54
|
+
* never stand in for the separator.
|
|
55
|
+
* - Only the decoded path is compared. There is no second, raw reading to fall
|
|
56
|
+
* back on when the first does not match.
|
|
57
|
+
*/
|
|
58
|
+
export declare function uriNames(uri: string, path: string): boolean;
|
|
59
|
+
/** Where staged inputs land, relative to the session's working directory. */
|
|
60
|
+
export declare const STAGED_INPUTS_DIR = "af-staged-inputs";
|
|
61
|
+
/** The line the manifest setup prints once the variable is set. */
|
|
62
|
+
export declare const MANIFEST_SET_MARKER = "af-staged-inputs-set";
|
|
63
|
+
/** The runtimes whose environment the adapter knows how to set. */
|
|
64
|
+
export type ManifestRuntime = 'python' | 'javascript' | 'typescript';
|
|
65
|
+
/**
|
|
66
|
+
* Which runtime a language names, for the manifest setup. `undefined` (no
|
|
67
|
+
* language sent) is the service's default runtime, Python; a language this
|
|
68
|
+
* adapter does not know is `undefined` — and refused, never guessed.
|
|
69
|
+
*/
|
|
70
|
+
export declare function manifestRuntime(language: string | undefined): ManifestRuntime | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* The code that sets {@link STAGED_INPUTS_ENV} inside one runtime of the
|
|
73
|
+
* session, then prints {@link MANIFEST_SET_MARKER}.
|
|
74
|
+
*
|
|
75
|
+
* WHY A SEPARATE CALL. `executeCode` takes no environment, and prepending a
|
|
76
|
+
* line to the caller's code would shift every line number its traceback
|
|
77
|
+
* reports and break a Python `from __future__` import. The session's runtime
|
|
78
|
+
* keeps its state between executions, so the variable is set once per
|
|
79
|
+
* runtime and manifest, by this code, before the caller's code runs.
|
|
80
|
+
*
|
|
81
|
+
* The value is the manifest JSON as a JSON string literal, which is a valid
|
|
82
|
+
* string literal in Python and in JavaScript alike.
|
|
83
|
+
*/
|
|
84
|
+
export declare function manifestSetupCode(runtime: ManifestRuntime, manifestJson: string): string;
|
|
85
|
+
/**
|
|
86
|
+
* `command`, with {@link STAGED_INPUTS_ENV} exported ahead of it.
|
|
87
|
+
*
|
|
88
|
+
* A command is its own shell process, so a variable set in a code runtime
|
|
89
|
+
* never reaches it; this line does, every time, and needs no state. The value
|
|
90
|
+
* is single-quoted, the one shell quoting with no expansions inside it.
|
|
91
|
+
*/
|
|
92
|
+
export declare function withManifestExport(command: string, manifestJson: string): string;
|
|
93
|
+
/**
|
|
94
|
+
* What a service error says about the session: `'session'` when it means the
|
|
95
|
+
* session itself is gone, `'file-or-session'` when it could mean that or a
|
|
96
|
+
* missing file, `undefined` otherwise.
|
|
97
|
+
*
|
|
98
|
+
* - A modelled exception — a `ValidationException` above all — whose words
|
|
99
|
+
* name a session and say it is "not active" or "inactive": `'session'`.
|
|
100
|
+
* - A `ResourceNotFoundException`, thrown by the SDK or carried on the stream:
|
|
101
|
+
* on a call that addresses nothing but the session (code, a command, a
|
|
102
|
+
* write) the missing resource is the session, so `'session'`. A READ also
|
|
103
|
+
* names a file, and AgentCore does not say which resource was missing, so
|
|
104
|
+
* `'file-or-session'` — never taken as proof the session is gone.
|
|
105
|
+
*/
|
|
106
|
+
export declare function sessionExpiryEvidence(err: unknown, tool: AgentCoreInvokeInput['name']): 'session' | 'file-or-session' | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* A modelled service exception from a file or command call, rewritten in
|
|
109
|
+
* fixed words that name the exception and the call — or `undefined` for any
|
|
110
|
+
* other error, which passes through as it is.
|
|
111
|
+
*
|
|
112
|
+
* The service's own message is NOT repeated: a validation message can quote
|
|
113
|
+
* what was sent, and what was sent here is a path, a command or a file's
|
|
114
|
+
* bytes. The exception's name is kept as the error's `name`, so a caller
|
|
115
|
+
* branches on it exactly as on the SDK's own error.
|
|
116
|
+
*/
|
|
117
|
+
export declare function serviceRefusal(err: unknown, tool: AgentCoreInvokeInput['name']): Error | undefined;
|
|
118
|
+
/** The `name` an error carries — an SDK exception's class name — or `''`. */
|
|
119
|
+
export declare function errorNameOf(err: unknown): string;
|