@strands-agents/sdk 1.10.0 → 1.11.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.
Files changed (99) hide show
  1. package/README.md +1 -1
  2. package/dist/src/agent/agent.d.ts +22 -42
  3. package/dist/src/agent/agent.d.ts.map +1 -1
  4. package/dist/src/agent/agent.js +72 -425
  5. package/dist/src/agent/agent.js.map +1 -1
  6. package/dist/src/context-manager/modes/agentic/agentic-context.d.ts +2 -2
  7. package/dist/src/experimental/vended-tools/stop/index.d.ts +8 -0
  8. package/dist/src/experimental/vended-tools/stop/index.d.ts.map +1 -0
  9. package/dist/src/experimental/vended-tools/stop/index.js +6 -0
  10. package/dist/src/experimental/vended-tools/stop/index.js.map +1 -0
  11. package/dist/src/experimental/vended-tools/stop/stop.d.ts +51 -0
  12. package/dist/src/experimental/vended-tools/stop/stop.d.ts.map +1 -0
  13. package/dist/src/experimental/vended-tools/stop/stop.js +89 -0
  14. package/dist/src/experimental/vended-tools/stop/stop.js.map +1 -0
  15. package/dist/src/experimental/vended-tools/stop/types.d.ts +54 -0
  16. package/dist/src/experimental/vended-tools/stop/types.d.ts.map +1 -0
  17. package/dist/src/experimental/vended-tools/stop/types.js +58 -0
  18. package/dist/src/experimental/vended-tools/stop/types.js.map +1 -0
  19. package/dist/src/hooks/events.d.ts +5 -4
  20. package/dist/src/hooks/events.d.ts.map +1 -1
  21. package/dist/src/hooks/events.js +3 -3
  22. package/dist/src/hooks/events.js.map +1 -1
  23. package/dist/src/index.d.ts +2 -0
  24. package/dist/src/index.d.ts.map +1 -1
  25. package/dist/src/index.js +3 -0
  26. package/dist/src/index.js.map +1 -1
  27. package/dist/src/index.node.d.ts.map +1 -1
  28. package/dist/src/index.node.js +2 -6
  29. package/dist/src/index.node.js.map +1 -1
  30. package/dist/src/middleware/interrupt.d.ts +18 -0
  31. package/dist/src/middleware/interrupt.d.ts.map +1 -0
  32. package/dist/src/middleware/interrupt.js +33 -0
  33. package/dist/src/middleware/interrupt.js.map +1 -0
  34. package/dist/src/models/openai/errors.d.ts.map +1 -1
  35. package/dist/src/models/openai/errors.js +1 -0
  36. package/dist/src/models/openai/errors.js.map +1 -1
  37. package/dist/src/models/openai/mantle.d.ts +2 -1
  38. package/dist/src/models/openai/mantle.d.ts.map +1 -1
  39. package/dist/src/models/openai/mantle.js +24 -3
  40. package/dist/src/models/openai/mantle.js.map +1 -1
  41. package/dist/src/models/openai/responses-adapter.d.ts.map +1 -1
  42. package/dist/src/models/openai/responses-adapter.js +41 -9
  43. package/dist/src/models/openai/responses-adapter.js.map +1 -1
  44. package/dist/src/models/vercel.d.ts.map +1 -1
  45. package/dist/src/models/vercel.js +28 -1
  46. package/dist/src/models/vercel.js.map +1 -1
  47. package/dist/src/register-node-defaults.d.ts +3 -0
  48. package/dist/src/register-node-defaults.d.ts.map +1 -0
  49. package/dist/src/register-node-defaults.js +10 -0
  50. package/dist/src/register-node-defaults.js.map +1 -0
  51. package/dist/src/sandbox/register-node-defaults.d.ts +3 -0
  52. package/dist/src/sandbox/register-node-defaults.d.ts.map +1 -0
  53. package/dist/src/sandbox/register-node-defaults.js +8 -0
  54. package/dist/src/sandbox/register-node-defaults.js.map +1 -0
  55. package/dist/src/session/session-manager.d.ts +3 -2
  56. package/dist/src/session/session-manager.d.ts.map +1 -1
  57. package/dist/src/session/session-manager.js +2 -2
  58. package/dist/src/session/session-manager.js.map +1 -1
  59. package/dist/src/tools/executors/concurrent.d.ts +32 -0
  60. package/dist/src/tools/executors/concurrent.d.ts.map +1 -0
  61. package/dist/src/tools/executors/concurrent.js +128 -0
  62. package/dist/src/tools/executors/concurrent.js.map +1 -0
  63. package/dist/src/tools/executors/executor.d.ts +62 -0
  64. package/dist/src/tools/executors/executor.d.ts.map +1 -0
  65. package/dist/src/tools/executors/executor.js +193 -0
  66. package/dist/src/tools/executors/executor.js.map +1 -0
  67. package/dist/src/tools/executors/sequential.d.ts +30 -0
  68. package/dist/src/tools/executors/sequential.d.ts.map +1 -0
  69. package/dist/src/tools/executors/sequential.js +67 -0
  70. package/dist/src/tools/executors/sequential.js.map +1 -0
  71. package/dist/src/tsconfig.tsbuildinfo +1 -1
  72. package/dist/src/vended-memory-stores/test-memory-store/store.d.ts +32 -24
  73. package/dist/src/vended-memory-stores/test-memory-store/store.d.ts.map +1 -1
  74. package/dist/src/vended-memory-stores/test-memory-store/store.js +84 -91
  75. package/dist/src/vended-memory-stores/test-memory-store/store.js.map +1 -1
  76. package/dist/src/vended-plugins/context-offloader/storage.d.ts.map +1 -1
  77. package/dist/src/vended-plugins/context-offloader/storage.js +4 -0
  78. package/dist/src/vended-plugins/context-offloader/storage.js.map +1 -1
  79. package/dist/src/vended-tools/index.d.ts +2 -1
  80. package/dist/src/vended-tools/index.d.ts.map +1 -1
  81. package/dist/src/vended-tools/index.js +2 -1
  82. package/dist/src/vended-tools/index.js.map +1 -1
  83. package/dist/src/vended-tools/sleep/index.d.ts +9 -0
  84. package/dist/src/vended-tools/sleep/index.d.ts.map +1 -0
  85. package/dist/src/vended-tools/sleep/index.js +7 -0
  86. package/dist/src/vended-tools/sleep/index.js.map +1 -0
  87. package/dist/src/vended-tools/sleep/make-sleep.d.ts +48 -0
  88. package/dist/src/vended-tools/sleep/make-sleep.d.ts.map +1 -0
  89. package/dist/src/vended-tools/sleep/make-sleep.js +81 -0
  90. package/dist/src/vended-tools/sleep/make-sleep.js.map +1 -0
  91. package/dist/src/vended-tools/sleep/sleep.d.ts +19 -0
  92. package/dist/src/vended-tools/sleep/sleep.d.ts.map +1 -0
  93. package/dist/src/vended-tools/sleep/sleep.js +20 -0
  94. package/dist/src/vended-tools/sleep/sleep.js.map +1 -0
  95. package/dist/src/vended-tools/sleep/types.d.ts +31 -0
  96. package/dist/src/vended-tools/sleep/types.d.ts.map +1 -0
  97. package/dist/src/vended-tools/sleep/types.js +22 -0
  98. package/dist/src/vended-tools/sleep/types.js.map +1 -0
  99. package/package.json +9 -1
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Sleep tool factory: pauses execution for a bounded, cooperative duration.
3
+ *
4
+ * The returned tool honors the invocation's `AbortSignal` (from
5
+ * `context.agent.cancelSignal`), so cancelling the agent aborts the sleep
6
+ * immediately rather than waiting for the full duration.
7
+ */
8
+ import { tool } from '../../tools/tool-factory.js';
9
+ import { z } from 'zod';
10
+ import { DEFAULT_MAX_DURATION, sleepDescription } from './types.js';
11
+ /**
12
+ * Creates a sleep tool with a configurable maximum duration.
13
+ *
14
+ * The returned tool pauses for the requested number of seconds. It attaches a
15
+ * one-shot listener to `context.agent.cancelSignal` so that cancellation of
16
+ * the enclosing agent invocation immediately aborts the sleep with an
17
+ * `AbortError`.
18
+ *
19
+ * @param options - Configuration options.
20
+ * @returns A tool that pauses execution for the requested duration.
21
+ * @throws Error if `maxDuration` is not a finite, positive number.
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * const shortSleep = makeSleep({ maxDuration: 5 })
26
+ * const agent = new Agent({ tools: [shortSleep] })
27
+ * ```
28
+ */
29
+ export function makeSleep(options = {}) {
30
+ const maxDuration = options.maxDuration ?? DEFAULT_MAX_DURATION;
31
+ if (typeof maxDuration !== 'number' || !Number.isFinite(maxDuration) || maxDuration <= 0) {
32
+ throw new Error(`maxDuration must be a positive, finite number, got ${String(maxDuration)}`);
33
+ }
34
+ const inputSchema = z.object({
35
+ duration: z
36
+ .number()
37
+ .finite('duration must be a finite number')
38
+ .nonnegative('duration must be non-negative')
39
+ .max(maxDuration, `duration exceeds maximum of ${maxDuration} seconds`)
40
+ .describe(`Seconds to pause. Must be finite, non-negative, and no larger than ${maxDuration}.`),
41
+ });
42
+ return tool({
43
+ name: options.name ?? 'sleep',
44
+ description: options.description ?? sleepDescription(maxDuration),
45
+ inputSchema,
46
+ callback: async (input, context) => {
47
+ const { duration } = input;
48
+ const cancelSignal = context?.agent.cancelSignal;
49
+ if (cancelSignal?.aborted) {
50
+ throw cancelSignal.reason ?? new DOMException('Sleep cancelled before it started', 'AbortError');
51
+ }
52
+ await new Promise((resolve, reject) => {
53
+ function cleanup() {
54
+ if (cancelSignal) {
55
+ cancelSignal.removeEventListener('abort', onAbort);
56
+ }
57
+ }
58
+ function onAbort() {
59
+ globalThis.clearTimeout(timer);
60
+ cleanup();
61
+ reject(cancelSignal?.reason ?? new DOMException('Sleep cancelled', 'AbortError'));
62
+ }
63
+ const timer = globalThis.setTimeout(() => {
64
+ cleanup();
65
+ resolve();
66
+ }, duration * 1000);
67
+ if (cancelSignal) {
68
+ cancelSignal.addEventListener('abort', onAbort, { once: true });
69
+ // Re-check after attaching: the signal may have aborted between the
70
+ // pre-flight check and here, and abort listeners do not fire for
71
+ // events dispatched before they were added.
72
+ if (cancelSignal.aborted) {
73
+ onAbort();
74
+ }
75
+ }
76
+ });
77
+ return `Slept for ${duration} seconds`;
78
+ },
79
+ });
80
+ }
81
+ //# sourceMappingURL=make-sleep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"make-sleep.js","sourceRoot":"","sources":["../../../../src/vended-tools/sleep/make-sleep.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAA;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAqBnE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,SAAS,CAAC,UAA4B,EAAE;IACtD,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,oBAAoB,CAAA;IAC/D,IAAI,OAAO,WAAW,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,WAAW,IAAI,CAAC,EAAE,CAAC;QACzF,MAAM,IAAI,KAAK,CAAC,sDAAsD,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;IAC9F,CAAC;IAED,MAAM,WAAW,GAAG,CAAC,CAAC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X,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC,CAAA;gBAEnB,IAAI,YAAY,EAAE,CAAC;oBACjB,YAAY,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;oBAC/D,oEAAoE;oBACpE,iEAAiE;oBACjE,4CAA4C;oBAC5C,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;wBACzB,OAAO,EAAE,CAAA;oBACX,CAAC;gBACH,CAAC;YACH,CAAC,CAAC,CAAA;YAEF,OAAO,aAAa,QAAQ,UAAU,CAAA;QACxC,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Default sleep tool with the built-in maximum duration.
3
+ */
4
+ /**
5
+ * Default sleep tool. Pauses execution for up to 60 seconds and aborts
6
+ * immediately when the agent invocation is cancelled.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // With an agent
11
+ * const agent = new Agent({ tools: [sleep] })
12
+ * await agent.invoke('Wait 2 seconds, then continue')
13
+ *
14
+ * // Direct usage
15
+ * await sleep.invoke({ duration: 0.5 })
16
+ * ```
17
+ */
18
+ export declare const sleep: import("../../index.js").InvokableTool<import("./types.js").SleepInput, import("../../index.js").JSONValue>;
19
+ //# sourceMappingURL=sleep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../../../src/vended-tools/sleep/sleep.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,KAAK,6GAAc,CAAA"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Default sleep tool with the built-in maximum duration.
3
+ */
4
+ import { makeSleep } from './make-sleep.js';
5
+ /**
6
+ * Default sleep tool. Pauses execution for up to 60 seconds and aborts
7
+ * immediately when the agent invocation is cancelled.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * // With an agent
12
+ * const agent = new Agent({ tools: [sleep] })
13
+ * await agent.invoke('Wait 2 seconds, then continue')
14
+ *
15
+ * // Direct usage
16
+ * await sleep.invoke({ duration: 0.5 })
17
+ * ```
18
+ */
19
+ export const sleep = makeSleep();
20
+ //# sourceMappingURL=sleep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sleep.js","sourceRoot":"","sources":["../../../../src/vended-tools/sleep/sleep.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,EAAE,CAAA"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Type definitions and constants for the sleep tool.
3
+ */
4
+ /**
5
+ * Default upper bound on `duration` (seconds) accepted by `makeSleep`.
6
+ */
7
+ export declare const DEFAULT_MAX_DURATION = 60;
8
+ /**
9
+ * Build the model-facing description with the configured maximum interpolated
10
+ * so the model knows the exact ceiling.
11
+ */
12
+ export declare function sleepDescription(maxDuration: number): string;
13
+ /**
14
+ * Description for the default sleep tool (60-second cap).
15
+ */
16
+ export declare const SLEEP_DESCRIPTION: string;
17
+ /**
18
+ * Input parameters accepted by the sleep tool.
19
+ *
20
+ * The Zod schema in `make-sleep.ts` is the single source of truth for the
21
+ * validated input shape (it also enforces the configured maximum); this type
22
+ * describes the pre-refinement shape callers can pass directly.
23
+ */
24
+ export interface SleepInput {
25
+ /**
26
+ * Seconds to pause. Must be a finite, non-negative number and no larger than
27
+ * the tool's configured maximum.
28
+ */
29
+ duration: number;
30
+ }
31
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/vended-tools/sleep/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,oBAAoB,KAAK,CAAA;AAEtC;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAO5D;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAAyC,CAAA;AAEvE;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAA;CACjB"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Type definitions and constants for the sleep tool.
3
+ */
4
+ /**
5
+ * Default upper bound on `duration` (seconds) accepted by `makeSleep`.
6
+ */
7
+ export const DEFAULT_MAX_DURATION = 60;
8
+ /**
9
+ * Build the model-facing description with the configured maximum interpolated
10
+ * so the model knows the exact ceiling.
11
+ */
12
+ export function sleepDescription(maxDuration) {
13
+ return (`Pauses execution for a specified number of seconds (max ${maxDuration}). ` +
14
+ 'Cooperative and cancellable: the sleep aborts immediately when the agent ' +
15
+ 'invocation is cancelled. Rejects negative, NaN, infinite, or non-numeric ' +
16
+ `durations, and durations above ${maxDuration}.`);
17
+ }
18
+ /**
19
+ * Description for the default sleep tool (60-second cap).
20
+ */
21
+ export const SLEEP_DESCRIPTION = sleepDescription(DEFAULT_MAX_DURATION);
22
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/vended-tools/sleep/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAA;AAEtC;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,WAAmB;IAClD,OAAO,CACL,2DAA2D,WAAW,KAAK;QAC3E,2EAA2E;QAC3E,2EAA2E;QAC3E,kCAAkC,WAAW,GAAG,CACjD,CAAA;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,oBAAoB,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strands-agents/sdk",
3
- "version": "1.10.0",
3
+ "version": "1.11.1",
4
4
  "description": "TypeScript SDK for Strands Agents framework",
5
5
  "main": "dist/src/index.js",
6
6
  "module": "dist/src/index.js",
@@ -68,6 +68,14 @@
68
68
  "types": "./dist/src/vended-tools/bash/index.d.ts",
69
69
  "default": "./dist/src/vended-tools/bash/index.js"
70
70
  },
71
+ "./vended-tools/sleep": {
72
+ "types": "./dist/src/vended-tools/sleep/index.d.ts",
73
+ "default": "./dist/src/vended-tools/sleep/index.js"
74
+ },
75
+ "./experimental/vended-tools/stop": {
76
+ "types": "./dist/src/experimental/vended-tools/stop/index.d.ts",
77
+ "default": "./dist/src/experimental/vended-tools/stop/index.js"
78
+ },
71
79
  "./a2a": {
72
80
  "types": "./dist/src/a2a/index.d.ts",
73
81
  "default": "./dist/src/a2a/index.js"