@strands-agents/sdk 1.17.0 → 1.19.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 +4 -1
- package/dist/src/agent/agent-metadata.d.ts +12 -0
- package/dist/src/agent/agent-metadata.d.ts.map +1 -0
- package/dist/src/agent/agent-metadata.js +2 -0
- package/dist/src/agent/agent-metadata.js.map +1 -0
- package/dist/src/agent/agent.d.ts +14 -29
- package/dist/src/agent/agent.d.ts.map +1 -1
- package/dist/src/agent/agent.js +29 -62
- package/dist/src/agent/agent.js.map +1 -1
- package/dist/src/background-tasks/background-tasks.d.ts.map +1 -1
- package/dist/src/background-tasks/background-tasks.js +13 -10
- package/dist/src/background-tasks/background-tasks.js.map +1 -1
- package/dist/src/context-manager/context-manager.d.ts +27 -4
- package/dist/src/context-manager/context-manager.d.ts.map +1 -1
- package/dist/src/context-manager/context-manager.js +59 -13
- package/dist/src/context-manager/context-manager.js.map +1 -1
- package/dist/src/context-manager/methods/summarize.d.ts +6 -0
- package/dist/src/context-manager/methods/summarize.d.ts.map +1 -1
- package/dist/src/context-manager/methods/summarize.js +9 -0
- package/dist/src/context-manager/methods/summarize.js.map +1 -1
- package/dist/src/context-manager/presets.d.ts +42 -0
- package/dist/src/context-manager/presets.d.ts.map +1 -0
- package/dist/src/context-manager/presets.js +71 -0
- package/dist/src/context-manager/presets.js.map +1 -0
- package/dist/src/context-manager/retrieval-tool.d.ts.map +1 -1
- package/dist/src/context-manager/retrieval-tool.js +19 -1
- package/dist/src/context-manager/retrieval-tool.js.map +1 -1
- package/dist/src/context-manager/stash.d.ts.map +1 -1
- package/dist/src/context-manager/stash.js +10 -7
- package/dist/src/context-manager/stash.js.map +1 -1
- package/dist/src/context-manager/strategies/offload/base.d.ts +13 -7
- package/dist/src/context-manager/strategies/offload/base.d.ts.map +1 -1
- package/dist/src/context-manager/strategies/offload/base.js +46 -16
- package/dist/src/context-manager/strategies/offload/base.js.map +1 -1
- package/dist/src/context-manager/strategies/offload/summarize.d.ts.map +1 -1
- package/dist/src/context-manager/strategies/offload/summarize.js +11 -12
- package/dist/src/context-manager/strategies/offload/summarize.js.map +1 -1
- package/dist/src/context-manager/strategies/offload/truncate.d.ts.map +1 -1
- package/dist/src/context-manager/strategies/offload/truncate.js +4 -11
- package/dist/src/context-manager/strategies/offload/truncate.js.map +1 -1
- package/dist/src/context-manager/types.d.ts +11 -1
- package/dist/src/context-manager/types.d.ts.map +1 -1
- package/dist/src/conversation-manager/compression/context-compression.d.ts +13 -1
- package/dist/src/conversation-manager/compression/context-compression.d.ts.map +1 -1
- package/dist/src/conversation-manager/compression/context-compression.js +32 -5
- package/dist/src/conversation-manager/compression/context-compression.js.map +1 -1
- package/dist/src/index.d.ts +8 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/interventions/registry.d.ts.map +1 -1
- package/dist/src/interventions/registry.js +5 -0
- package/dist/src/interventions/registry.js.map +1 -1
- package/dist/src/models/anthropic.d.ts +30 -0
- package/dist/src/models/anthropic.d.ts.map +1 -1
- package/dist/src/models/anthropic.js +338 -126
- package/dist/src/models/anthropic.js.map +1 -1
- package/dist/src/models/bedrock.d.ts +10 -0
- package/dist/src/models/bedrock.d.ts.map +1 -1
- package/dist/src/models/bedrock.js +25 -15
- package/dist/src/models/bedrock.js.map +1 -1
- package/dist/src/models/defaults.d.ts.map +1 -1
- package/dist/src/models/defaults.js +1 -0
- package/dist/src/models/defaults.js.map +1 -1
- package/dist/src/models/model.d.ts +12 -2
- package/dist/src/models/model.d.ts.map +1 -1
- package/dist/src/models/model.js +6 -1
- package/dist/src/models/model.js.map +1 -1
- package/dist/src/models/openai/cache.d.ts +11 -2
- package/dist/src/models/openai/cache.d.ts.map +1 -1
- package/dist/src/models/openai/cache.js +32 -6
- package/dist/src/models/openai/cache.js.map +1 -1
- package/dist/src/models/openai/chat-adapter.d.ts.map +1 -1
- package/dist/src/models/openai/chat-adapter.js +10 -4
- package/dist/src/models/openai/chat-adapter.js.map +1 -1
- package/dist/src/models/openai/mantle.js +1 -1
- package/dist/src/models/openai/mantle.js.map +1 -1
- package/dist/src/models/openai/responses-adapter.js +1 -1
- package/dist/src/models/openai/responses-adapter.js.map +1 -1
- package/dist/src/plugins/plugin.d.ts +1 -1
- package/dist/src/plugins/registry.js +1 -1
- package/dist/src/plugins/registry.js.map +1 -1
- package/dist/src/retry/model-retry-strategy.js +16 -3
- package/dist/src/retry/model-retry-strategy.js.map +1 -1
- package/dist/src/sandbox/errors.d.ts +5 -1
- package/dist/src/sandbox/errors.d.ts.map +1 -1
- package/dist/src/sandbox/errors.js +7 -1
- package/dist/src/sandbox/errors.js.map +1 -1
- package/dist/src/sandbox/stream-process.d.ts.map +1 -1
- package/dist/src/sandbox/stream-process.js +6 -1
- package/dist/src/sandbox/stream-process.js.map +1 -1
- package/dist/src/storage/in-memory-storage.d.ts +7 -0
- package/dist/src/storage/in-memory-storage.d.ts.map +1 -1
- package/dist/src/storage/in-memory-storage.js +16 -1
- package/dist/src/storage/in-memory-storage.js.map +1 -1
- package/dist/src/storage/local-file-storage.d.ts +9 -2
- package/dist/src/storage/local-file-storage.d.ts.map +1 -1
- package/dist/src/storage/local-file-storage.js +17 -4
- package/dist/src/storage/local-file-storage.js.map +1 -1
- package/dist/src/storage/s3-storage.d.ts +4 -0
- package/dist/src/storage/s3-storage.d.ts.map +1 -1
- package/dist/src/storage/s3-storage.js +8 -0
- package/dist/src/storage/s3-storage.js.map +1 -1
- package/dist/src/storage/search/qmd.d.ts +10 -6
- package/dist/src/storage/search/qmd.d.ts.map +1 -1
- package/dist/src/storage/search/qmd.js +4 -6
- package/dist/src/storage/search/qmd.js.map +1 -1
- package/dist/src/storage/search/types.d.ts +14 -2
- package/dist/src/storage/search/types.d.ts.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/src/types/agent.d.ts +7 -3
- package/dist/src/types/agent.d.ts.map +1 -1
- package/dist/src/types/agent.js +6 -0
- package/dist/src/types/agent.js.map +1 -1
- package/dist/src/vended-plugins/context-offloader/search.d.ts.map +1 -1
- package/dist/src/vended-plugins/context-offloader/search.js +4 -2
- package/dist/src/vended-plugins/context-offloader/search.js.map +1 -1
- package/dist/src/vended-tools/handoff-to-user/handoff-to-user.d.ts +28 -0
- package/dist/src/vended-tools/handoff-to-user/handoff-to-user.d.ts.map +1 -0
- package/dist/src/vended-tools/handoff-to-user/handoff-to-user.js +45 -0
- package/dist/src/vended-tools/handoff-to-user/handoff-to-user.js.map +1 -0
- package/dist/src/vended-tools/handoff-to-user/index.d.ts +8 -0
- package/dist/src/vended-tools/handoff-to-user/index.d.ts.map +1 -0
- package/dist/src/vended-tools/handoff-to-user/index.js +6 -0
- package/dist/src/vended-tools/handoff-to-user/index.js.map +1 -0
- package/dist/src/vended-tools/handoff-to-user/types.d.ts +18 -0
- package/dist/src/vended-tools/handoff-to-user/types.d.ts.map +1 -0
- package/dist/src/vended-tools/handoff-to-user/types.js +11 -0
- package/dist/src/vended-tools/handoff-to-user/types.js.map +1 -0
- package/dist/src/vended-tools/index.d.ts +14 -3
- package/dist/src/vended-tools/index.d.ts.map +1 -1
- package/dist/src/vended-tools/index.js +14 -3
- package/dist/src/vended-tools/index.js.map +1 -1
- package/dist/src/vended-tools/notebook/index.d.ts +2 -1
- package/dist/src/vended-tools/notebook/index.d.ts.map +1 -1
- package/dist/src/vended-tools/notebook/index.js +1 -1
- package/dist/src/vended-tools/notebook/index.js.map +1 -1
- package/dist/src/vended-tools/notebook/notebook.d.ts +38 -8
- package/dist/src/vended-tools/notebook/notebook.d.ts.map +1 -1
- package/dist/src/vended-tools/notebook/notebook.js +130 -79
- package/dist/src/vended-tools/notebook/notebook.js.map +1 -1
- package/dist/src/vended-tools/shell/make-shell.d.ts.map +1 -1
- package/dist/src/vended-tools/shell/make-shell.js +7 -3
- package/dist/src/vended-tools/shell/make-shell.js.map +1 -1
- package/dist/src/vended-tools/shell/types.d.ts +10 -5
- package/dist/src/vended-tools/shell/types.d.ts.map +1 -1
- package/dist/src/vended-tools/shell/types.js +7 -2
- package/dist/src/vended-tools/shell/types.js.map +1 -1
- package/dist/src/vended-tools/web-fetch/extract.d.ts +23 -0
- package/dist/src/vended-tools/web-fetch/extract.d.ts.map +1 -0
- package/dist/src/vended-tools/web-fetch/extract.js +130 -0
- package/dist/src/vended-tools/web-fetch/extract.js.map +1 -0
- package/dist/src/vended-tools/web-fetch/index.d.ts +9 -0
- package/dist/src/vended-tools/web-fetch/index.d.ts.map +1 -0
- package/dist/src/vended-tools/web-fetch/index.js +7 -0
- package/dist/src/vended-tools/web-fetch/index.js.map +1 -0
- package/dist/src/vended-tools/web-fetch/types.d.ts +40 -0
- package/dist/src/vended-tools/web-fetch/types.d.ts.map +1 -0
- package/dist/src/vended-tools/web-fetch/types.js +8 -0
- package/dist/src/vended-tools/web-fetch/types.js.map +1 -0
- package/dist/src/vended-tools/web-fetch/web-fetch.d.ts +14 -0
- package/dist/src/vended-tools/web-fetch/web-fetch.d.ts.map +1 -0
- package/dist/src/vended-tools/web-fetch/web-fetch.js +175 -0
- package/dist/src/vended-tools/web-fetch/web-fetch.js.map +1 -0
- package/package.json +24 -4
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const WEB_FETCH_DESCRIPTION_MARKDOWN = 'Fetches an HTTP(S) URL and returns its content as clean markdown. ' +
|
|
2
|
+
'HTML pages are converted to markdown with scripts, styles, and noise stripped; ' +
|
|
3
|
+
'other content types are returned as-is.';
|
|
4
|
+
export const WEB_FETCH_DESCRIPTION_AGENTIC = 'Fetches an HTTP(S) URL and answers a prompt about its content. ' +
|
|
5
|
+
'The analyst processes the page directly so the full content never enters ' +
|
|
6
|
+
"the main agent's context. " +
|
|
7
|
+
'The prompt parameter is required.';
|
|
8
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/vended-tools/web-fetch/types.ts"],"names":[],"mappings":"AAoBA,MAAM,CAAC,MAAM,8BAA8B,GACzC,oEAAoE;IACpE,iFAAiF;IACjF,yCAAyC,CAAA;AAE3C,MAAM,CAAC,MAAM,6BAA6B,GACxC,iEAAiE;IACjE,2EAA2E;IAC3E,4BAA4B;IAC5B,mCAAmC,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { tool } from '../../tools/tool-factory.js';
|
|
2
|
+
import { type MakeWebFetchOptions } from './types.js';
|
|
3
|
+
export declare const DEFAULT_MAX_BYTES: number;
|
|
4
|
+
export declare const DEFAULT_MAX_CONTENT_CHARS = 50000;
|
|
5
|
+
/**
|
|
6
|
+
* Create a web fetch tool. The exported {@link webFetch} is a default instance
|
|
7
|
+
* with conservative limits; use this factory to tune them.
|
|
8
|
+
*/
|
|
9
|
+
export declare function makeWebFetch(options?: MakeWebFetchOptions): ReturnType<typeof tool>;
|
|
10
|
+
/**
|
|
11
|
+
* Default web fetch tool (agentic mode). See {@link makeWebFetch} to tune limits or switch modes.
|
|
12
|
+
*/
|
|
13
|
+
export declare const webFetch: import("../../index.js").InvokableTool<unknown, import("../../index.js").JSONValue>;
|
|
14
|
+
//# sourceMappingURL=web-fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-fetch.d.ts","sourceRoot":"","sources":["../../../../src/vended-tools/web-fetch/web-fetch.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAA;AAElD,OAAO,EAAE,KAAK,mBAAmB,EAAiE,MAAM,YAAY,CAAA;AAEpH,eAAO,MAAM,iBAAiB,QAAkB,CAAA;AAChD,eAAO,MAAM,yBAAyB,QAAS,CAAA;AA4B/C;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAiFvF;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,qFAAiB,CAAA"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Agent } from '../../agent/agent.js';
|
|
3
|
+
import { tool } from '../../tools/tool-factory.js';
|
|
4
|
+
import { htmlToMarkdown } from './extract.js';
|
|
5
|
+
import { WEB_FETCH_DESCRIPTION_MARKDOWN, WEB_FETCH_DESCRIPTION_AGENTIC } from './types.js';
|
|
6
|
+
export const DEFAULT_MAX_BYTES = 5 * 1024 * 1024; // 5 MiB
|
|
7
|
+
export const DEFAULT_MAX_CONTENT_CHARS = 50_000;
|
|
8
|
+
const _HEADERS = {
|
|
9
|
+
'User-Agent': 'strands-agents-web-fetch/1.0',
|
|
10
|
+
Accept: 'text/html,application/xhtml+xml;q=0.9,*/*;q=0.8',
|
|
11
|
+
};
|
|
12
|
+
const _ANALYST_PROMPT = 'You answer a request about a single fetched web page. Use only the provided ' +
|
|
13
|
+
'content; if it does not contain the answer, say so plainly. Be concise and ' +
|
|
14
|
+
'factual, and preserve concrete details (names, numbers, quotes, links) ' +
|
|
15
|
+
'relevant to the request.';
|
|
16
|
+
/**
|
|
17
|
+
* Zod schema for markdown mode web fetch input validation.
|
|
18
|
+
*/
|
|
19
|
+
const webFetchMarkdownInputSchema = z.object({
|
|
20
|
+
url: z.string().describe('URL to fetch. Must be http:// or https://.'),
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Zod schema for agentic mode web fetch input validation.
|
|
24
|
+
*/
|
|
25
|
+
const webFetchAgenticInputSchema = z.object({
|
|
26
|
+
url: z.string().describe('URL to fetch. Must be http:// or https://.'),
|
|
27
|
+
prompt: z.string().describe('Question or instruction about the page content.'),
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Create a web fetch tool. The exported {@link webFetch} is a default instance
|
|
31
|
+
* with conservative limits; use this factory to tune them.
|
|
32
|
+
*/
|
|
33
|
+
export function makeWebFetch(options = {}) {
|
|
34
|
+
const { mode = 'agentic', model: analystModel } = options;
|
|
35
|
+
const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
|
|
36
|
+
const maxContentChars = options.maxContentChars ?? DEFAULT_MAX_CONTENT_CHARS;
|
|
37
|
+
if (maxBytes <= 0) {
|
|
38
|
+
throw new Error(`maxBytes must be a positive number, got ${maxBytes}`);
|
|
39
|
+
}
|
|
40
|
+
if (maxContentChars <= 0) {
|
|
41
|
+
throw new Error(`maxContentChars must be a positive number, got ${maxContentChars}`);
|
|
42
|
+
}
|
|
43
|
+
const name = options.name ?? 'web_fetch';
|
|
44
|
+
const description = options.description ?? (mode === 'markdown' ? WEB_FETCH_DESCRIPTION_MARKDOWN : WEB_FETCH_DESCRIPTION_AGENTIC);
|
|
45
|
+
const markdownTool = tool({
|
|
46
|
+
name,
|
|
47
|
+
description,
|
|
48
|
+
inputSchema: webFetchMarkdownInputSchema,
|
|
49
|
+
callback: async (input, context) => {
|
|
50
|
+
const { url } = input;
|
|
51
|
+
const signal = context?.cancelSignal ?? null;
|
|
52
|
+
const [contentType, raw] = await fetchOnce(url, maxBytes, signal);
|
|
53
|
+
const isMarkup = contentType.toLowerCase().includes('html') || contentType.toLowerCase().includes('xml');
|
|
54
|
+
let content = isMarkup ? await htmlToMarkdown(raw) : raw;
|
|
55
|
+
if (content.length > maxContentChars) {
|
|
56
|
+
content = content.slice(0, maxContentChars) + '\n\n[content truncated]';
|
|
57
|
+
}
|
|
58
|
+
return content;
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
const agenticTool = tool({
|
|
62
|
+
name,
|
|
63
|
+
description,
|
|
64
|
+
inputSchema: webFetchAgenticInputSchema,
|
|
65
|
+
callback: async (input, context) => {
|
|
66
|
+
const { url, prompt } = input;
|
|
67
|
+
if (!prompt.trim()) {
|
|
68
|
+
throw new Error('web_fetch: agentic mode requires a non-empty prompt.');
|
|
69
|
+
}
|
|
70
|
+
const effectiveModel = analystModel ?? context?.agent.model;
|
|
71
|
+
if (!effectiveModel) {
|
|
72
|
+
throw new Error('web_fetch: agentic mode requires a model. ' + 'Pass model to makeWebFetch or call the tool from an agent.');
|
|
73
|
+
}
|
|
74
|
+
const signal = context?.cancelSignal ?? null;
|
|
75
|
+
const invokeOptions = context?.cancelSignal ? { cancelSignal: context.cancelSignal } : {};
|
|
76
|
+
const [contentType, raw] = await fetchOnce(url, maxBytes, signal);
|
|
77
|
+
const isMarkup = contentType.toLowerCase().includes('html') || contentType.toLowerCase().includes('xml');
|
|
78
|
+
let content = isMarkup ? await htmlToMarkdown(raw) : raw;
|
|
79
|
+
if (content.length > maxContentChars) {
|
|
80
|
+
content = content.slice(0, maxContentChars) + '\n\n[content truncated]';
|
|
81
|
+
}
|
|
82
|
+
// Fresh agent per call — no history from one fetch bleeds into the next.
|
|
83
|
+
const analyst = new Agent({ model: effectiveModel, systemPrompt: _ANALYST_PROMPT, printer: false });
|
|
84
|
+
const invokePrompt = `URL: ${url}\n\nRequest: ${prompt}\n\n--- Content ---\n${content}`;
|
|
85
|
+
try {
|
|
86
|
+
const result = await analyst.invoke(invokePrompt, invokeOptions);
|
|
87
|
+
return result.lastMessage.content
|
|
88
|
+
.filter((block) => block.type === 'textBlock')
|
|
89
|
+
.map((block) => block.text)
|
|
90
|
+
.join('');
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
throw new Error(`url=<${url}> | web fetch analyst failed: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
return mode === 'markdown' ? markdownTool : agenticTool;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Default web fetch tool (agentic mode). See {@link makeWebFetch} to tune limits or switch modes.
|
|
101
|
+
*/
|
|
102
|
+
export const webFetch = makeWebFetch();
|
|
103
|
+
// ---- Internals ----
|
|
104
|
+
async function fetchOnce(url, maxBytes, signal) {
|
|
105
|
+
// Validate scheme before hitting the network
|
|
106
|
+
if (!URL.canParse(url)) {
|
|
107
|
+
throw new Error(`url=<${url}> | fetch failed: invalid URL`);
|
|
108
|
+
}
|
|
109
|
+
const { protocol } = new URL(url);
|
|
110
|
+
if (protocol !== 'http:' && protocol !== 'https:') {
|
|
111
|
+
throw new Error(`url=<${url}> | fetch failed: only http and https URLs are supported`);
|
|
112
|
+
}
|
|
113
|
+
let response;
|
|
114
|
+
try {
|
|
115
|
+
response = await globalThis.fetch(url, { method: 'GET', headers: _HEADERS, signal });
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
119
|
+
throw new Error('Web fetch tool request cancelled', { cause: error });
|
|
120
|
+
}
|
|
121
|
+
throw new Error(`url=<${url}> | fetch failed: ${error instanceof Error ? error.message : String(error)}`, {
|
|
122
|
+
cause: error,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
if (!response.ok) {
|
|
126
|
+
await response.body?.cancel();
|
|
127
|
+
throw new Error(`HTTP ${response.status} ${response.statusText}: GET ${url}`);
|
|
128
|
+
}
|
|
129
|
+
// Stream the body and enforce the size cap on decompressed bytes as they arrive.
|
|
130
|
+
if (!response.body) {
|
|
131
|
+
return [response.headers.get('content-type') ?? '', ''];
|
|
132
|
+
}
|
|
133
|
+
const contentType = response.headers.get('content-type') ?? '';
|
|
134
|
+
const charset = _parseCharset(contentType);
|
|
135
|
+
const reader = response.body.getReader();
|
|
136
|
+
const decoder = new TextDecoder(charset);
|
|
137
|
+
const chunks = [];
|
|
138
|
+
let total = 0;
|
|
139
|
+
try {
|
|
140
|
+
while (true) {
|
|
141
|
+
const { done, value } = await reader.read();
|
|
142
|
+
if (done)
|
|
143
|
+
break;
|
|
144
|
+
total += value.byteLength;
|
|
145
|
+
if (total > maxBytes) {
|
|
146
|
+
throw new Error(`Response body exceeded max_bytes=${maxBytes}. Refusing to buffer more.`);
|
|
147
|
+
}
|
|
148
|
+
chunks.push(decoder.decode(value, { stream: true }));
|
|
149
|
+
}
|
|
150
|
+
chunks.push(decoder.decode());
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
154
|
+
throw new Error('Web fetch tool request cancelled', { cause: error });
|
|
155
|
+
}
|
|
156
|
+
throw error;
|
|
157
|
+
}
|
|
158
|
+
finally {
|
|
159
|
+
reader.cancel().catch(() => { });
|
|
160
|
+
reader.releaseLock();
|
|
161
|
+
}
|
|
162
|
+
return [contentType, chunks.join('')];
|
|
163
|
+
}
|
|
164
|
+
function _parseCharset(contentType) {
|
|
165
|
+
const match = contentType.match(/charset=(?:"([^"]+)"|'([^']+)'|([^;\s]+))/i);
|
|
166
|
+
const charset = (match?.[1] ?? match?.[2] ?? match?.[3] ?? 'utf-8').toLowerCase();
|
|
167
|
+
try {
|
|
168
|
+
new TextDecoder(charset);
|
|
169
|
+
return charset;
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
return 'utf-8';
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=web-fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-fetch.js","sourceRoot":"","sources":["../../../../src/vended-tools/web-fetch/web-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAA4B,8BAA8B,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAA;AAEpH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAA,CAAC,QAAQ;AACzD,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAA;AAE/C,MAAM,QAAQ,GAAG;IACf,YAAY,EAAE,8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,CAAA;IACjF,IAAI,CAAC;QACH,IAAI,WAAW,CAAC,OAAO,CAAC,CAAA;QACxB,OAAO,OAAO,CAAA;IAChB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAA;IAChB,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strands-agents/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0",
|
|
4
4
|
"description": "TypeScript SDK for Strands Agents framework",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"module": "dist/src/index.js",
|
|
@@ -64,6 +64,10 @@
|
|
|
64
64
|
"types": "./dist/src/vended-tools/file-editor/index.d.ts",
|
|
65
65
|
"default": "./dist/src/vended-tools/file-editor/index.js"
|
|
66
66
|
},
|
|
67
|
+
"./vended-tools/handoff-to-user": {
|
|
68
|
+
"types": "./dist/src/vended-tools/handoff-to-user/index.d.ts",
|
|
69
|
+
"default": "./dist/src/vended-tools/handoff-to-user/index.js"
|
|
70
|
+
},
|
|
67
71
|
"./vended-tools/http-request": {
|
|
68
72
|
"types": "./dist/src/vended-tools/http-request/index.d.ts",
|
|
69
73
|
"default": "./dist/src/vended-tools/http-request/index.js"
|
|
@@ -84,6 +88,10 @@
|
|
|
84
88
|
"types": "./dist/src/experimental/vended-tools/stop/index.d.ts",
|
|
85
89
|
"default": "./dist/src/experimental/vended-tools/stop/index.js"
|
|
86
90
|
},
|
|
91
|
+
"./vended-tools/web-fetch": {
|
|
92
|
+
"types": "./dist/src/vended-tools/web-fetch/index.d.ts",
|
|
93
|
+
"default": "./dist/src/vended-tools/web-fetch/index.js"
|
|
94
|
+
},
|
|
87
95
|
"./a2a": {
|
|
88
96
|
"types": "./dist/src/a2a/index.d.ts",
|
|
89
97
|
"default": "./dist/src/a2a/index.js"
|
|
@@ -162,6 +170,12 @@
|
|
|
162
170
|
"default": "./dist/src/storage/search/qmd.js"
|
|
163
171
|
}
|
|
164
172
|
},
|
|
173
|
+
"./storage/search/bm25": {
|
|
174
|
+
"node": {
|
|
175
|
+
"types": "./dist/src/storage/search/qmd.d.ts",
|
|
176
|
+
"default": "./dist/src/storage/search/qmd.js"
|
|
177
|
+
}
|
|
178
|
+
},
|
|
165
179
|
"./sandbox": {
|
|
166
180
|
"types": "./dist/src/sandbox/index.d.ts",
|
|
167
181
|
"default": "./dist/src/sandbox/index.js"
|
|
@@ -239,6 +253,7 @@
|
|
|
239
253
|
"@smithy/types": "^4.15.1",
|
|
240
254
|
"@types/express": "^5.0.6",
|
|
241
255
|
"@types/node": "^25.9.4",
|
|
256
|
+
"@types/turndown": "^5.0.6",
|
|
242
257
|
"@typescript-eslint/eslint-plugin": "^8.62.1",
|
|
243
258
|
"@typescript-eslint/parser": "^8.0.0",
|
|
244
259
|
"@vitest/browser": "^4.1.10",
|
|
@@ -250,6 +265,7 @@
|
|
|
250
265
|
"openai": "^6.45.0",
|
|
251
266
|
"playwright": "^1.61.0",
|
|
252
267
|
"tsx": "^4.22.5",
|
|
268
|
+
"turndown": "^7.2.4",
|
|
253
269
|
"typescript": "^6.0.3",
|
|
254
270
|
"vitest": "^4.1.10"
|
|
255
271
|
},
|
|
@@ -265,11 +281,11 @@
|
|
|
265
281
|
},
|
|
266
282
|
"homepage": "https://github.com/strands-agents/harness-sdk#readme",
|
|
267
283
|
"dependencies": {
|
|
268
|
-
"@smithy/fetch-http-handler": "^5.
|
|
269
|
-
"@aws-sdk/client-bedrock-runtime": "^3.
|
|
284
|
+
"@smithy/fetch-http-handler": "^5.8.0",
|
|
285
|
+
"@aws-sdk/client-bedrock-runtime": "^3.1132.0",
|
|
270
286
|
"@types/json-schema": "^7.0.15",
|
|
271
287
|
"uuid": "^14.0.2",
|
|
272
|
-
"yaml": "^2.
|
|
288
|
+
"yaml": "^2.9.1"
|
|
273
289
|
},
|
|
274
290
|
"peerDependencies": {
|
|
275
291
|
"@a2a-js/sdk": "^0.3.10",
|
|
@@ -294,6 +310,7 @@
|
|
|
294
310
|
"@tobilu/qmd": "^2.8.0",
|
|
295
311
|
"express": "^5.1.0",
|
|
296
312
|
"openai": "^6.45.0",
|
|
313
|
+
"turndown": "^7.2.4",
|
|
297
314
|
"zod": "^4.1.12"
|
|
298
315
|
},
|
|
299
316
|
"peerDependenciesMeta": {
|
|
@@ -356,6 +373,9 @@
|
|
|
356
373
|
},
|
|
357
374
|
"@tobilu/qmd": {
|
|
358
375
|
"optional": true
|
|
376
|
+
},
|
|
377
|
+
"turndown": {
|
|
378
|
+
"optional": true
|
|
359
379
|
}
|
|
360
380
|
},
|
|
361
381
|
"overrides": {
|