agentfootprint 11.5.0 → 12.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CAPABILITIES.md +1 -0
- 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/answer-account/templates.js +12 -6
- package/dist/answer-account/templates.js.map +1 -1
- package/dist/answer-validation/types.js.map +1 -1
- package/dist/core/agent/assessment/assess.js +94 -32
- package/dist/core/agent/assessment/assess.js.map +1 -1
- package/dist/core/agent/assessment/reasons.js +2 -2
- package/dist/core/agent/assessment/reasons.js.map +1 -1
- package/dist/core/agent/assessment/sources.js +61 -23
- package/dist/core/agent/assessment/sources.js.map +1 -1
- package/dist/core/agent/negativeClaims/delivery.js +10 -1
- package/dist/core/agent/negativeClaims/delivery.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/answer-account/templates.d.ts +1 -1
- package/dist/esm/answer-account/templates.js +12 -6
- package/dist/esm/answer-account/templates.js.map +1 -1
- package/dist/esm/answer-validation/types.d.ts +10 -0
- package/dist/esm/answer-validation/types.js.map +1 -1
- package/dist/esm/core/agent/assessment/assess.d.ts +6 -3
- package/dist/esm/core/agent/assessment/assess.js +95 -33
- package/dist/esm/core/agent/assessment/assess.js.map +1 -1
- package/dist/esm/core/agent/assessment/reasons.js +2 -2
- package/dist/esm/core/agent/assessment/reasons.js.map +1 -1
- package/dist/esm/core/agent/assessment/sources.d.ts +26 -1
- package/dist/esm/core/agent/assessment/sources.js +59 -22
- package/dist/esm/core/agent/assessment/sources.js.map +1 -1
- package/dist/esm/core/agent/assessment/types.d.ts +3 -1
- package/dist/esm/core/agent/negativeClaims/delivery.d.ts +9 -1
- package/dist/esm/core/agent/negativeClaims/delivery.js +10 -1
- package/dist/esm/core/agent/negativeClaims/delivery.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 +16 -2
- package/dist/esm/identity/types.d.ts +12 -0
- package/dist/esm/identity/types.js.map +1 -1
- package/dist/esm/identity/withCredentialRetry.d.ts +5 -0
- package/dist/esm/identity/withCredentialRetry.js +16 -3
- package/dist/esm/identity/withCredentialRetry.js.map +1 -1
- 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/lib/boundedJson.d.ts +27 -0
- package/dist/esm/lib/boundedJson.js +33 -0
- package/dist/esm/lib/boundedJson.js.map +1 -1
- package/dist/esm/mcp/gatewayTransport.d.ts +8 -0
- package/dist/esm/mcp/gatewayTransport.js +35 -2
- package/dist/esm/mcp/gatewayTransport.js.map +1 -1
- package/dist/esm/mcp/replay.d.ts +21 -13
- package/dist/esm/mcp/replay.js +14 -10
- package/dist/esm/mcp/replay.js.map +1 -1
- package/dist/esm/mcp/replayUnavailable.d.ts +21 -8
- package/dist/esm/mcp/replayUnavailable.js +21 -8
- package/dist/esm/mcp/replayUnavailable.js.map +1 -1
- package/dist/esm/mcp/throttleRetry.d.ts +5 -5
- package/dist/esm/mcp/throttleRetry.js +5 -5
- package/dist/esm/mcp/types.d.ts +13 -10
- 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 +3 -0
- package/dist/esm/redaction/knownStrings.js.map +1 -1
- package/dist/identity/types.js.map +1 -1
- package/dist/identity/withCredentialRetry.js +16 -3
- package/dist/identity/withCredentialRetry.js.map +1 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/boundedJson.js +35 -1
- package/dist/lib/boundedJson.js.map +1 -1
- package/dist/mcp/gatewayTransport.js +35 -2
- package/dist/mcp/gatewayTransport.js.map +1 -1
- package/dist/mcp/replay.js +14 -10
- package/dist/mcp/replay.js.map +1 -1
- package/dist/mcp/replayUnavailable.js +21 -8
- package/dist/mcp/replayUnavailable.js.map +1 -1
- package/dist/mcp/throttleRetry.js +5 -5
- 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 +3 -0
- package/dist/redaction/knownStrings.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/answer-account/templates.d.ts +1 -1
- package/dist/types/answer-account/templates.d.ts.map +1 -1
- package/dist/types/answer-validation/types.d.ts +10 -0
- package/dist/types/answer-validation/types.d.ts.map +1 -1
- package/dist/types/core/agent/assessment/assess.d.ts +6 -3
- package/dist/types/core/agent/assessment/assess.d.ts.map +1 -1
- package/dist/types/core/agent/assessment/reasons.d.ts.map +1 -1
- package/dist/types/core/agent/assessment/sources.d.ts +26 -1
- package/dist/types/core/agent/assessment/sources.d.ts.map +1 -1
- package/dist/types/core/agent/assessment/types.d.ts +3 -1
- package/dist/types/core/agent/assessment/types.d.ts.map +1 -1
- package/dist/types/core/agent/negativeClaims/delivery.d.ts +9 -1
- package/dist/types/core/agent/negativeClaims/delivery.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 +16 -2
- package/dist/types/events/payloads.d.ts.map +1 -1
- package/dist/types/identity/types.d.ts +12 -0
- package/dist/types/identity/types.d.ts.map +1 -1
- package/dist/types/identity/withCredentialRetry.d.ts +5 -0
- package/dist/types/identity/withCredentialRetry.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/lib/boundedJson.d.ts +27 -0
- package/dist/types/lib/boundedJson.d.ts.map +1 -1
- package/dist/types/mcp/gatewayTransport.d.ts +8 -0
- package/dist/types/mcp/gatewayTransport.d.ts.map +1 -1
- package/dist/types/mcp/replay.d.ts +21 -13
- package/dist/types/mcp/replay.d.ts.map +1 -1
- package/dist/types/mcp/replayUnavailable.d.ts +21 -8
- package/dist/types/mcp/replayUnavailable.d.ts.map +1 -1
- package/dist/types/mcp/throttleRetry.d.ts +5 -5
- package/dist/types/mcp/types.d.ts +13 -10
- 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/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentcore.js","sourceRoot":"","sources":["../../../src/adapters/code/agentcore.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"agentcore.js","sourceRoot":"","sources":["../../../src/adapters/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;IAClD,OAAO,IAAI,KAAK,2BAA2B,IAAI,IAAI,KAAK,qBAAqB,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The AgentCore Code Interpreter client seam: the operation-semantic surface
|
|
4
|
+
* `agentCoreCodeRunner` calls, and its ONE mapping onto the real SDK.
|
|
5
|
+
*
|
|
6
|
+
* Two things this file owns and nothing else does:
|
|
7
|
+
*
|
|
8
|
+
* • the COMMAND FORM — a bare `@aws-sdk/client-*` client is command-based:
|
|
9
|
+
* `client.send(new SomeCommand(input))`, never a method on the client
|
|
10
|
+
* (the 9.4.0 law; `BedrockAgentCoreClient.prototype.startCodeInterpreterSession`
|
|
11
|
+
* is `undefined`, the shortcut exists only on the aggregated client);
|
|
12
|
+
* • the DRAIN of `InvokeCodeInterpreterResponse.stream`, an event stream
|
|
13
|
+
* whose members are `{ result }` or a modelled EXCEPTION.
|
|
14
|
+
*
|
|
15
|
+
* The request and response shapes below were read off a real install of
|
|
16
|
+
* `@aws-sdk/client-bedrock-agentcore` 3.1159.0 (`InvokeCodeInterpreterRequest`,
|
|
17
|
+
* `ToolArguments`, `InputContentBlock`, `CodeInterpreterResult`,
|
|
18
|
+
* `ResourceContent`, `ToolResultStructuredContent`) and are pinned against
|
|
19
|
+
* transcribed copies of those types in
|
|
20
|
+
* `test/type-regressions/AgentCoreCodeInterpreter.sdk.test.ts`.
|
|
21
|
+
*
|
|
22
|
+
* Pattern: Adapter (GoF) + lazy peer-dep load — the SDK is required only when
|
|
23
|
+
* a session first starts (or never, if you inject `_client` / `_sdk`).
|
|
24
|
+
*/
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.drainStream = exports.STREAM_ERROR_MEMBERS = exports.createCodeClient = void 0;
|
|
27
|
+
const abort_js_1 = require("../../lib/abort.js");
|
|
28
|
+
const lazyRequire_js_1 = require("../../lib/lazyRequire.js");
|
|
29
|
+
/** The tool names whose answer is only an answer if it carried a result. */
|
|
30
|
+
const RESULT_REQUIRED = new Set([
|
|
31
|
+
'writeFiles',
|
|
32
|
+
'readFiles',
|
|
33
|
+
]);
|
|
34
|
+
/**
|
|
35
|
+
* Map {@link AgentCoreCodeClientLike} onto the real SDK commands.
|
|
36
|
+
*/
|
|
37
|
+
function createCodeClient(options) {
|
|
38
|
+
let mod;
|
|
39
|
+
if (options._sdk) {
|
|
40
|
+
mod = options._sdk;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
try {
|
|
44
|
+
// Lazy peer-dep: only loaded when no _client/_sdk is injected and start() runs.
|
|
45
|
+
mod = (0, lazyRequire_js_1.lazyRequire)('@aws-sdk/client-bedrock-agentcore');
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
throw new Error('agentCoreCodeRunner requires the `@aws-sdk/client-bedrock-agentcore` peer dependency.\n' +
|
|
49
|
+
' Install: npm install @aws-sdk/client-bedrock-agentcore\n' +
|
|
50
|
+
' Or pass `_client` for a pre-built or mock client.\n' +
|
|
51
|
+
' For a local dev loop with no AWS at all, use `localCodeRunner()`.');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (!mod.BedrockAgentCoreClient) {
|
|
55
|
+
throw new Error('agentCoreCodeRunner: `@aws-sdk/client-bedrock-agentcore` is installed but ' +
|
|
56
|
+
'`BedrockAgentCoreClient` was not found. Update the SDK.');
|
|
57
|
+
}
|
|
58
|
+
const sdk = new mod.BedrockAgentCoreClient({ ...(options.region && { region: options.region }) });
|
|
59
|
+
const send = async (Ctor, name, input, abortSignal) => {
|
|
60
|
+
if (!Ctor) {
|
|
61
|
+
throw new Error(`agentCoreCodeRunner: \`@aws-sdk/client-bedrock-agentcore\` is missing ${name}. ` +
|
|
62
|
+
'Upgrade the SDK, or pass `_client` with your own mapping.');
|
|
63
|
+
}
|
|
64
|
+
return abortSignal ? sdk.send(new Ctor(input), { abortSignal }) : sdk.send(new Ctor(input));
|
|
65
|
+
};
|
|
66
|
+
return {
|
|
67
|
+
async startSession(input) {
|
|
68
|
+
const r = (await send(mod.StartCodeInterpreterSessionCommand, 'StartCodeInterpreterSessionCommand', input));
|
|
69
|
+
return { ...(r?.sessionId !== undefined && { sessionId: r.sessionId }) };
|
|
70
|
+
},
|
|
71
|
+
async invoke(input, invokeOptions) {
|
|
72
|
+
const abortSignal = invokeOptions?.abortSignal;
|
|
73
|
+
const r = (await send(mod.InvokeCodeInterpreterCommand, 'InvokeCodeInterpreterCommand', input, abortSignal));
|
|
74
|
+
return drainStream(r?.stream, {
|
|
75
|
+
requireResult: RESULT_REQUIRED.has(input.name),
|
|
76
|
+
...(abortSignal && { signal: abortSignal }),
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
async stopSession(input) {
|
|
80
|
+
await send(mod.StopCodeInterpreterSessionCommand, 'StopCodeInterpreterSessionCommand', input);
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
exports.createCodeClient = createCodeClient;
|
|
85
|
+
/** Every modelled error member of the stream union, in SDK spelling. */
|
|
86
|
+
exports.STREAM_ERROR_MEMBERS = [
|
|
87
|
+
'accessDeniedException',
|
|
88
|
+
'conflictException',
|
|
89
|
+
'internalServerException',
|
|
90
|
+
'resourceNotFoundException',
|
|
91
|
+
'serviceQuotaExceededException',
|
|
92
|
+
'throttlingException',
|
|
93
|
+
'validationException',
|
|
94
|
+
];
|
|
95
|
+
/**
|
|
96
|
+
* Drain the event stream into one answer.
|
|
97
|
+
*
|
|
98
|
+
* An ERROR MEMBER RAISES. This is the honesty line for this adapter: the SDK
|
|
99
|
+
* models seven failure shapes as ordinary members of the stream union, so an
|
|
100
|
+
* `AccessDeniedException` arrives as a value, not a rejection. Folding it in
|
|
101
|
+
* as empty output would report a clean run in which the code "printed
|
|
102
|
+
* nothing" — a silent success, at the exact moment an operator most needs the
|
|
103
|
+
* word "AccessDenied".
|
|
104
|
+
*
|
|
105
|
+
* Nothing is filled in that the stream did not carry: no exit status, no
|
|
106
|
+
* error flag. And a file operation whose stream ended with no result at all
|
|
107
|
+
* (`requireResult`) is a broken call, not an empty answer.
|
|
108
|
+
*/
|
|
109
|
+
async function drainStream(stream, options) {
|
|
110
|
+
if (!stream) {
|
|
111
|
+
throw new Error('agentCoreCodeRunner: InvokeCodeInterpreter returned no stream. The response carries ' +
|
|
112
|
+
'its payload as an event stream (`response.stream`), so an absent one is a broken ' +
|
|
113
|
+
'call, not an empty result.');
|
|
114
|
+
}
|
|
115
|
+
let stdout = '';
|
|
116
|
+
let stderr = '';
|
|
117
|
+
let exitCode;
|
|
118
|
+
let isError;
|
|
119
|
+
let results = 0;
|
|
120
|
+
const resources = [];
|
|
121
|
+
for await (const event of (0, abort_js_1.abortableIterable)(stream, options.signal)) {
|
|
122
|
+
for (const member of exports.STREAM_ERROR_MEMBERS) {
|
|
123
|
+
const raised = event[member];
|
|
124
|
+
if (raised) {
|
|
125
|
+
const error = new Error(`agentCoreCodeRunner: ${member} from InvokeCodeInterpreter — ` +
|
|
126
|
+
`${raised.message ?? 'no message supplied'}`);
|
|
127
|
+
error.name = member.charAt(0).toUpperCase() + member.slice(1);
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const result = event.result;
|
|
132
|
+
if (!result)
|
|
133
|
+
continue;
|
|
134
|
+
results += 1;
|
|
135
|
+
if (result.isError === true)
|
|
136
|
+
isError = true;
|
|
137
|
+
else if (result.isError === false && isError === undefined)
|
|
138
|
+
isError = false;
|
|
139
|
+
for (const block of result.content ?? []) {
|
|
140
|
+
if (block.resource !== undefined && block.resource !== null)
|
|
141
|
+
resources.push(block.resource);
|
|
142
|
+
}
|
|
143
|
+
const structured = result.structuredContent;
|
|
144
|
+
if (structured) {
|
|
145
|
+
if (structured.stdout !== undefined)
|
|
146
|
+
stdout += structured.stdout;
|
|
147
|
+
if (structured.stderr !== undefined)
|
|
148
|
+
stderr += structured.stderr;
|
|
149
|
+
if (structured.exitCode !== undefined)
|
|
150
|
+
exitCode = structured.exitCode;
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
// Fallback: a response that filled only the typed content blocks. Text
|
|
154
|
+
// blocks are the readable half; a binary/resource block is described by
|
|
155
|
+
// name rather than inlined, because inlining it is the bug this port exists
|
|
156
|
+
// to prevent.
|
|
157
|
+
for (const block of result.content ?? []) {
|
|
158
|
+
if (block.text !== undefined)
|
|
159
|
+
stdout += block.text;
|
|
160
|
+
else if (block.name !== undefined)
|
|
161
|
+
stdout += `[${block.type ?? 'resource'}: ${block.name}]`;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (options.requireResult && results === 0) {
|
|
166
|
+
throw new Error('agentCoreCodeRunner: InvokeCodeInterpreter answered a file operation with no result. ' +
|
|
167
|
+
'Nothing confirmed it, so it is not reported as done.');
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
stdout,
|
|
171
|
+
stderr,
|
|
172
|
+
...(exitCode !== undefined && { exitCode }),
|
|
173
|
+
...(isError !== undefined && { isError }),
|
|
174
|
+
...(resources.length > 0 && { resources }),
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
exports.drainStream = drainStream;
|
|
178
|
+
//# 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,iDAAuD;AACvD,6DAAuD;AA8FvD,4EAA4E;AAC5E,MAAM,eAAe,GAA8C,IAAI,GAAG,CAAC;IACzE,YAAY;IACZ,WAAW;CACZ,CAAC,CAAC;AAEH;;GAEG;AACH,SAAgB,gBAAgB,CAAC,OAGhC;IACC,IAAI,GAAkC,CAAC;IACvC,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,GAAG,GAAG,O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U,CAAC,MAAM,CAAC;YACjE,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;AAlED,kCAkEC"}
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* What `agentCoreCodeRunner` has to know about AgentCore's wire, as pure
|
|
4
|
+
* functions: how big a request is, how a returned file is paired with the
|
|
5
|
+
* path asked for, how the staged-input manifest reaches a runtime that has no
|
|
6
|
+
* environment parameter, and which service errors mean the session is gone.
|
|
7
|
+
*
|
|
8
|
+
* Kept apart from the session so each rule is one small function with its
|
|
9
|
+
* own test, and so the session reads as the sequence it is.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.errorNameOf = exports.serviceRefusal = exports.sessionExpiryEvidence = exports.withManifestExport = exports.manifestSetupCode = exports.manifestRuntime = exports.MANIFEST_SET_MARKER = exports.STAGED_INPUTS_DIR = exports.uriNames = exports.pairReadFile = exports.fileContent = exports.jsonStringBytes = exports.writeFilesRequestBytes = exports.AGENTCORE_MAX_REQUEST_BYTES = void 0;
|
|
13
|
+
const types_js_1 = require("../../provider-contract/types.js");
|
|
14
|
+
const codeSandbox_js_1 = require("../../provider-contract/codeSandbox.js");
|
|
15
|
+
const output_js_1 = require("./output.js");
|
|
16
|
+
// ── Request size ─────────────────────────────────────────────────────────
|
|
17
|
+
/**
|
|
18
|
+
* AgentCore's per-call limit for `InvokeCodeInterpreter`: "Max payload size —
|
|
19
|
+
* 100 MB — Maximum size for request/response payloads", not adjustable
|
|
20
|
+
* (AgentCore Code Interpreter service quotas).
|
|
21
|
+
*
|
|
22
|
+
* The service does not say whether that MB is 10^6 or 2^20 bytes, so the
|
|
23
|
+
* adapter holds a request to the SMALLER reading: a request it sends is never
|
|
24
|
+
* one the limit could refuse on size, and one between the two readings is
|
|
25
|
+
* refused here by name rather than by the service in words nobody can act on.
|
|
26
|
+
*/
|
|
27
|
+
exports.AGENTCORE_MAX_REQUEST_BYTES = 100_000_000;
|
|
28
|
+
/** `{"arguments":{"content":[` … `]},"name":"writeFiles"}` around the entries. */
|
|
29
|
+
const WRITE_FILES_ENVELOPE_BYTES = JSON.stringify({
|
|
30
|
+
arguments: { content: [] },
|
|
31
|
+
name: 'writeFiles',
|
|
32
|
+
}).length;
|
|
33
|
+
/**
|
|
34
|
+
* The size, in bytes, of the JSON body one `writeFiles` request sends —
|
|
35
|
+
* computed, not built: text as its JSON-escaped UTF-8, bytes as base64 (how
|
|
36
|
+
* the JSON protocol carries a blob), plus the envelope. Building the body to
|
|
37
|
+
* measure it would hold a second copy of up to a hundred megabytes.
|
|
38
|
+
*/
|
|
39
|
+
function writeFilesRequestBytes(content) {
|
|
40
|
+
let bytes = WRITE_FILES_ENVELOPE_BYTES + Math.max(content.length - 1, 0); // the commas
|
|
41
|
+
for (const entry of content) {
|
|
42
|
+
bytes += '{"path":'.length + jsonStringBytes(entry.path) + '}'.length;
|
|
43
|
+
if (entry.text !== undefined)
|
|
44
|
+
bytes += ',"text":'.length + jsonStringBytes(entry.text);
|
|
45
|
+
else
|
|
46
|
+
bytes += ',"blob":'.length + 2 + base64Length(entry.blob.byteLength);
|
|
47
|
+
}
|
|
48
|
+
return bytes;
|
|
49
|
+
}
|
|
50
|
+
exports.writeFilesRequestBytes = writeFilesRequestBytes;
|
|
51
|
+
/** Bytes of `JSON.stringify(text)` encoded as UTF-8, quotes included, without building it. */
|
|
52
|
+
function jsonStringBytes(text) {
|
|
53
|
+
let bytes = 2;
|
|
54
|
+
for (let i = 0; i < text.length; i++) {
|
|
55
|
+
const unit = text.charCodeAt(i);
|
|
56
|
+
if (unit === 0x22 || unit === 0x5c)
|
|
57
|
+
bytes += 2; // \" and \\
|
|
58
|
+
else if (unit < 0x20)
|
|
59
|
+
bytes += SHORT_ESCAPES.has(unit) ? 2 : 6; // \n … or \u00XX
|
|
60
|
+
else if (unit < 0x80)
|
|
61
|
+
bytes += 1;
|
|
62
|
+
else if (unit < 0x800)
|
|
63
|
+
bytes += 2;
|
|
64
|
+
else if ((0, output_js_1.isHighSurrogate)(unit) && (0, output_js_1.isLowSurrogate)(text.charCodeAt(i + 1))) {
|
|
65
|
+
bytes += 4;
|
|
66
|
+
i++;
|
|
67
|
+
}
|
|
68
|
+
else if ((0, output_js_1.isHighSurrogate)(unit) || (0, output_js_1.isLowSurrogate)(unit))
|
|
69
|
+
bytes += 6; // a lone half: \udXXX
|
|
70
|
+
else
|
|
71
|
+
bytes += 3;
|
|
72
|
+
}
|
|
73
|
+
return bytes;
|
|
74
|
+
}
|
|
75
|
+
exports.jsonStringBytes = jsonStringBytes;
|
|
76
|
+
/** Control characters JSON writes as a two-character escape: \b \t \n \f \r. */
|
|
77
|
+
const SHORT_ESCAPES = new Set([0x08, 0x09, 0x0a, 0x0c, 0x0d]);
|
|
78
|
+
function base64Length(bytes) {
|
|
79
|
+
return 4 * Math.ceil(bytes / 3);
|
|
80
|
+
}
|
|
81
|
+
/** One `writeFiles` entry for a payload: TEXT for a string, BYTES for bytes. */
|
|
82
|
+
function fileContent(path, data) {
|
|
83
|
+
return typeof data === 'string' ? { path, text: data } : { path, blob: data };
|
|
84
|
+
}
|
|
85
|
+
exports.fileContent = fileContent;
|
|
86
|
+
// ── Reading a file back ──────────────────────────────────────────────────
|
|
87
|
+
/** How AgentCore names a file it returns: `file:///` + the path asked for,
|
|
88
|
+
* percent-encoded (read from a published real `readFiles` answer:
|
|
89
|
+
* `report.csv` → `file:///report.csv`; the shape is not in AWS's docs). */
|
|
90
|
+
const FILE_URI_PREFIX = 'file:///';
|
|
91
|
+
/**
|
|
92
|
+
* The one file a `readFiles` answer returned for `path` — or a refusal.
|
|
93
|
+
*
|
|
94
|
+
* Paired by the URI the SERVICE put on the file, never by position: a file
|
|
95
|
+
* with no URI, or a URI naming another path, fails closed, and so does an
|
|
96
|
+
* answer carrying several files for one path. Text or bytes is read off which
|
|
97
|
+
* field the service filled — never off the file's name — and an entry with
|
|
98
|
+
* both, or neither, is refused. A file over `maxBytes` is refused whole.
|
|
99
|
+
*/
|
|
100
|
+
function pairReadFile(path, answer, maxBytes) {
|
|
101
|
+
const refuse = (reason, why) => {
|
|
102
|
+
throw new codeSandbox_js_1.CodeSandboxError(reason, `agentCoreCodeRunner: reading '${path}' — ${why}`, { path });
|
|
103
|
+
};
|
|
104
|
+
if (answer.isError === true) {
|
|
105
|
+
refuse('file-not-returned', 'the service flagged its answer as an error, so no file came back. Its words are not ' +
|
|
106
|
+
'repeated here.');
|
|
107
|
+
}
|
|
108
|
+
const resources = answer.resources ?? [];
|
|
109
|
+
if (resources.length === 0)
|
|
110
|
+
refuse('file-not-returned', 'the answer held no file.');
|
|
111
|
+
for (const resource of resources) {
|
|
112
|
+
if (typeof resource.uri !== 'string' || resource.uri.length === 0) {
|
|
113
|
+
refuse('uri-missing', 'a file came back without a URI, so it cannot be paired with the path asked for.');
|
|
114
|
+
}
|
|
115
|
+
if (hasQueryOrFragment(resource.uri)) {
|
|
116
|
+
refuse('uri-mismatch', 'a file came back under a URI with a query or fragment, which is not part of any file ' +
|
|
117
|
+
'name (a literal ? or # in a name arrives as %3F or %23).');
|
|
118
|
+
}
|
|
119
|
+
if (!uriNames(resource.uri, path)) {
|
|
120
|
+
refuse('uri-mismatch', 'a file came back under a URI that names another path.');
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (resources.length > 1)
|
|
124
|
+
refuse('content-ambiguous', `${resources.length} files came back for one path.`);
|
|
125
|
+
const resource = resources[0];
|
|
126
|
+
const hasText = resource.text !== undefined && resource.text !== null;
|
|
127
|
+
const hasBlob = resource.blob !== undefined && resource.blob !== null;
|
|
128
|
+
if (hasText === hasBlob) {
|
|
129
|
+
refuse('content-ambiguous', hasText
|
|
130
|
+
? 'the file came back as both text and bytes.'
|
|
131
|
+
: 'the file came back with neither text nor bytes.');
|
|
132
|
+
}
|
|
133
|
+
if (hasText && typeof resource.text !== 'string')
|
|
134
|
+
refuse('content-ambiguous', 'its text is not a string.');
|
|
135
|
+
if (hasBlob && !isBytes(resource.blob))
|
|
136
|
+
refuse('content-ambiguous', 'its bytes are not bytes.');
|
|
137
|
+
const data = hasText ? resource.text : resource.blob;
|
|
138
|
+
const bytes = (0, output_js_1.payloadBytes)(data);
|
|
139
|
+
if (bytes > maxBytes) {
|
|
140
|
+
throw new codeSandbox_js_1.CodeSandboxError('file-too-large', `agentCoreCodeRunner: '${path}' is ${bytes} bytes and this read allows ${maxBytes}. ` +
|
|
141
|
+
'Nothing was returned — a file is never handed back cut.', { path, bytes, limit: maxBytes });
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
path,
|
|
145
|
+
data,
|
|
146
|
+
bytes,
|
|
147
|
+
...(typeof resource.mimeType === 'string' &&
|
|
148
|
+
resource.mimeType.length > 0 && {
|
|
149
|
+
mediaType: resource.mimeType,
|
|
150
|
+
}),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
exports.pairReadFile = pairReadFile;
|
|
154
|
+
/**
|
|
155
|
+
* Does `uri` name `path`? ONE declared form, read ONE way (RFC 8089's file
|
|
156
|
+
* URI, RFC 3986's path syntax): `file:///` followed by a path whose segments
|
|
157
|
+
* are percent-encoded.
|
|
158
|
+
*
|
|
159
|
+
* - A raw `?` or `#` starts a query or a fragment, which is never part of a
|
|
160
|
+
* file name, so a URI carrying one is refused outright. A name that really
|
|
161
|
+
* contains `?` or `#` arrives as `%3F` / `%23`.
|
|
162
|
+
* - Each segment is decoded on its own. An invalid escape refuses the URI, and
|
|
163
|
+
* a decoded `/` (an encoded `%2F`) is a character inside one name, so it can
|
|
164
|
+
* never stand in for the separator.
|
|
165
|
+
* - Only the decoded path is compared. There is no second, raw reading to fall
|
|
166
|
+
* back on when the first does not match.
|
|
167
|
+
*/
|
|
168
|
+
function uriNames(uri, path) {
|
|
169
|
+
if (!uri.startsWith(FILE_URI_PREFIX))
|
|
170
|
+
return false;
|
|
171
|
+
const named = uri.slice(FILE_URI_PREFIX.length);
|
|
172
|
+
if (hasQueryOrFragment(named))
|
|
173
|
+
return false;
|
|
174
|
+
const segments = [];
|
|
175
|
+
for (const encoded of named.split('/')) {
|
|
176
|
+
let segment;
|
|
177
|
+
try {
|
|
178
|
+
segment = decodeURIComponent(encoded);
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
if (segment.includes('/'))
|
|
184
|
+
return false;
|
|
185
|
+
segments.push(segment);
|
|
186
|
+
}
|
|
187
|
+
return segments.join('/') === path;
|
|
188
|
+
}
|
|
189
|
+
exports.uriNames = uriNames;
|
|
190
|
+
/** A raw `?` or `#` in a URI: a query or a fragment component. */
|
|
191
|
+
function hasQueryOrFragment(uriTail) {
|
|
192
|
+
return uriTail.includes('?') || uriTail.includes('#');
|
|
193
|
+
}
|
|
194
|
+
function isBytes(value) {
|
|
195
|
+
return (value instanceof Uint8Array || Object.prototype.toString.call(value) === '[object Uint8Array]');
|
|
196
|
+
}
|
|
197
|
+
// ── The staged-input manifest ────────────────────────────────────────────
|
|
198
|
+
/** Where staged inputs land, relative to the session's working directory. */
|
|
199
|
+
exports.STAGED_INPUTS_DIR = 'af-staged-inputs';
|
|
200
|
+
/** The line the manifest setup prints once the variable is set. */
|
|
201
|
+
exports.MANIFEST_SET_MARKER = 'af-staged-inputs-set';
|
|
202
|
+
/**
|
|
203
|
+
* Which runtime a language names, for the manifest setup. `undefined` (no
|
|
204
|
+
* language sent) is the service's default runtime, Python; a language this
|
|
205
|
+
* adapter does not know is `undefined` — and refused, never guessed.
|
|
206
|
+
*/
|
|
207
|
+
function manifestRuntime(language) {
|
|
208
|
+
if (language === undefined || language === '')
|
|
209
|
+
return 'python';
|
|
210
|
+
const lower = language.toLowerCase();
|
|
211
|
+
if (lower === 'python' || lower === 'python3' || lower === 'py')
|
|
212
|
+
return 'python';
|
|
213
|
+
if (lower === 'javascript' || lower === 'js' || lower === 'node')
|
|
214
|
+
return 'javascript';
|
|
215
|
+
if (lower === 'typescript' || lower === 'ts')
|
|
216
|
+
return 'typescript';
|
|
217
|
+
return undefined;
|
|
218
|
+
}
|
|
219
|
+
exports.manifestRuntime = manifestRuntime;
|
|
220
|
+
/**
|
|
221
|
+
* The code that sets {@link STAGED_INPUTS_ENV} inside one runtime of the
|
|
222
|
+
* session, then prints {@link MANIFEST_SET_MARKER}.
|
|
223
|
+
*
|
|
224
|
+
* WHY A SEPARATE CALL. `executeCode` takes no environment, and prepending a
|
|
225
|
+
* line to the caller's code would shift every line number its traceback
|
|
226
|
+
* reports and break a Python `from __future__` import. The session's runtime
|
|
227
|
+
* keeps its state between executions, so the variable is set once per
|
|
228
|
+
* runtime and manifest, by this code, before the caller's code runs.
|
|
229
|
+
*
|
|
230
|
+
* The value is the manifest JSON as a JSON string literal, which is a valid
|
|
231
|
+
* string literal in Python and in JavaScript alike.
|
|
232
|
+
*/
|
|
233
|
+
function manifestSetupCode(runtime, manifestJson) {
|
|
234
|
+
const value = JSON.stringify(manifestJson);
|
|
235
|
+
const name = JSON.stringify(types_js_1.STAGED_INPUTS_ENV);
|
|
236
|
+
const marker = JSON.stringify(exports.MANIFEST_SET_MARKER);
|
|
237
|
+
if (runtime === 'python') {
|
|
238
|
+
return [
|
|
239
|
+
'import os as _af_os',
|
|
240
|
+
`_af_os.environ[${name}] = ${value}`,
|
|
241
|
+
'del _af_os',
|
|
242
|
+
`print(${marker})`,
|
|
243
|
+
].join('\n');
|
|
244
|
+
}
|
|
245
|
+
return [
|
|
246
|
+
'{',
|
|
247
|
+
runtime === 'typescript'
|
|
248
|
+
? ' const _afHost: any = globalThis;'
|
|
249
|
+
: ' const _afHost = globalThis;',
|
|
250
|
+
` const _afValue = ${value};`,
|
|
251
|
+
' if (_afHost.process && _afHost.process.env) {',
|
|
252
|
+
` _afHost.process.env[${name}] = _afValue;`,
|
|
253
|
+
' } else {',
|
|
254
|
+
` _afHost.Deno.env.set(${name}, _afValue);`,
|
|
255
|
+
' }',
|
|
256
|
+
` console.log(${marker});`,
|
|
257
|
+
'}',
|
|
258
|
+
].join('\n');
|
|
259
|
+
}
|
|
260
|
+
exports.manifestSetupCode = manifestSetupCode;
|
|
261
|
+
/**
|
|
262
|
+
* `command`, with {@link STAGED_INPUTS_ENV} exported ahead of it.
|
|
263
|
+
*
|
|
264
|
+
* A command is its own shell process, so a variable set in a code runtime
|
|
265
|
+
* never reaches it; this line does, every time, and needs no state. The value
|
|
266
|
+
* is single-quoted, the one shell quoting with no expansions inside it.
|
|
267
|
+
*/
|
|
268
|
+
function withManifestExport(command, manifestJson) {
|
|
269
|
+
return `export ${types_js_1.STAGED_INPUTS_ENV}=${shellQuoted(manifestJson)}\n${command}`;
|
|
270
|
+
}
|
|
271
|
+
exports.withManifestExport = withManifestExport;
|
|
272
|
+
function shellQuoted(text) {
|
|
273
|
+
return `'${text.split("'").join(`'\\''`)}'`;
|
|
274
|
+
}
|
|
275
|
+
// ── Service errors ───────────────────────────────────────────────────────
|
|
276
|
+
/** The exceptions AgentCore models for `InvokeCodeInterpreter`, by class name. */
|
|
277
|
+
const MODELLED_EXCEPTIONS = new Set([
|
|
278
|
+
'AccessDeniedException',
|
|
279
|
+
'ConflictException',
|
|
280
|
+
'InternalServerException',
|
|
281
|
+
'ResourceNotFoundException',
|
|
282
|
+
'ServiceQuotaExceededException',
|
|
283
|
+
'ThrottlingException',
|
|
284
|
+
'ValidationException',
|
|
285
|
+
]);
|
|
286
|
+
/** Words a service uses for a session that is gone — both halves required, so
|
|
287
|
+
* a validation message that merely echoes a request containing "inactive"
|
|
288
|
+
* is not read as a dead session. */
|
|
289
|
+
const SAYS_INACTIVE = /\bnot active\b|\binactive\b/i;
|
|
290
|
+
const NAMES_A_SESSION = /\bsession\b/i;
|
|
291
|
+
/**
|
|
292
|
+
* What a service error says about the session: `'session'` when it means the
|
|
293
|
+
* session itself is gone, `'file-or-session'` when it could mean that or a
|
|
294
|
+
* missing file, `undefined` otherwise.
|
|
295
|
+
*
|
|
296
|
+
* - A modelled exception — a `ValidationException` above all — whose words
|
|
297
|
+
* name a session and say it is "not active" or "inactive": `'session'`.
|
|
298
|
+
* - A `ResourceNotFoundException`, thrown by the SDK or carried on the stream:
|
|
299
|
+
* on a call that addresses nothing but the session (code, a command, a
|
|
300
|
+
* write) the missing resource is the session, so `'session'`. A READ also
|
|
301
|
+
* names a file, and AgentCore does not say which resource was missing, so
|
|
302
|
+
* `'file-or-session'` — never taken as proof the session is gone.
|
|
303
|
+
*/
|
|
304
|
+
function sessionExpiryEvidence(err, tool) {
|
|
305
|
+
const name = errorNameOf(err);
|
|
306
|
+
const message = errorMessage(err);
|
|
307
|
+
if (MODELLED_EXCEPTIONS.has(name) &&
|
|
308
|
+
SAYS_INACTIVE.test(message) &&
|
|
309
|
+
NAMES_A_SESSION.test(message)) {
|
|
310
|
+
return 'session';
|
|
311
|
+
}
|
|
312
|
+
if (name === 'ResourceNotFoundException') {
|
|
313
|
+
return tool === 'readFiles' ? 'file-or-session' : 'session';
|
|
314
|
+
}
|
|
315
|
+
return undefined;
|
|
316
|
+
}
|
|
317
|
+
exports.sessionExpiryEvidence = sessionExpiryEvidence;
|
|
318
|
+
/**
|
|
319
|
+
* A modelled service exception from a file or command call, rewritten in
|
|
320
|
+
* fixed words that name the exception and the call — or `undefined` for any
|
|
321
|
+
* other error, which passes through as it is.
|
|
322
|
+
*
|
|
323
|
+
* The service's own message is NOT repeated: a validation message can quote
|
|
324
|
+
* what was sent, and what was sent here is a path, a command or a file's
|
|
325
|
+
* bytes. The exception's name is kept as the error's `name`, so a caller
|
|
326
|
+
* branches on it exactly as on the SDK's own error.
|
|
327
|
+
*/
|
|
328
|
+
function serviceRefusal(err, tool) {
|
|
329
|
+
const name = errorNameOf(err);
|
|
330
|
+
if (!MODELLED_EXCEPTIONS.has(name))
|
|
331
|
+
return undefined;
|
|
332
|
+
const refusal = new Error(`agentCoreCodeRunner: the service refused ${tool} (${name}). Its message is not repeated ` +
|
|
333
|
+
'here, because it can quote what was sent.');
|
|
334
|
+
refusal.name = name;
|
|
335
|
+
return refusal;
|
|
336
|
+
}
|
|
337
|
+
exports.serviceRefusal = serviceRefusal;
|
|
338
|
+
/** The `name` an error carries — an SDK exception's class name — or `''`. */
|
|
339
|
+
function errorNameOf(err) {
|
|
340
|
+
const name = err?.name;
|
|
341
|
+
return typeof name === 'string' ? name : '';
|
|
342
|
+
}
|
|
343
|
+
exports.errorNameOf = errorNameOf;
|
|
344
|
+
function errorMessage(err) {
|
|
345
|
+
const message = err?.message;
|
|
346
|
+
return typeof message === 'string' ? message : '';
|
|
347
|
+
}
|
|
348
|
+
//# sourceMappingURL=agentcoreWire.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentcoreWire.js","sourceRoot":"","sources":["../../../src/adapters/code/agentcoreWire.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,+DAAqE;AAErE,2EAA0E;AAM1E,2CAA4E;AAE5E,4EAA4E;AAE5E;;;;;;;;;GASG;AACU,QAAA,2BAA2B,GAAG,WAAW,CAAC;AAEvD,kFAAkF;AAClF,MAAM,0BAA0B,GAAG,IAAI,CAAC,SAAS,CAAC;IAChD,SAAS,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;IAC1B,IAAI,EAAE,YAAY;CACnB,CAAC,CAAC,MAAM,CAAC;AAEV;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,OAAwC;IAC7E,IAAI,KAAK,GAAG,0BAA0B,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,aAAa;IACvF,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,KAAK,IAAI,UAAU,CAAC,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC;QACtE,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;YAAE,KAAK,IAAI,UAAU,CAAC,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;;YAClF,KAAK,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AARD,wDAQC;AAED,8FAA8F;AAC9F,SAAgB,eAAe,CAAC,IAAY;IAC1C,IAAI,KAAK,GA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