@superdurable/dex-agents 0.4.0 → 0.5.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.
Files changed (132) hide show
  1. package/README.md +506 -52
  2. package/dist/src/agent-context-compaction.d.ts +1 -1
  3. package/dist/src/agent-framework-runner.d.ts +122 -11
  4. package/dist/src/agent-framework-runner.js +4 -0
  5. package/dist/src/agent-framework-runner.js.map +1 -1
  6. package/dist/src/agent-local-directory-media-store.d.ts +111 -0
  7. package/dist/src/agent-local-directory-media-store.js +417 -0
  8. package/dist/src/agent-local-directory-media-store.js.map +1 -0
  9. package/dist/src/agent-media.d.ts +279 -0
  10. package/dist/src/agent-media.js +457 -0
  11. package/dist/src/agent-media.js.map +1 -0
  12. package/dist/src/agent-session-codecs.d.ts +3 -1
  13. package/dist/src/agent-session-codecs.js +45 -4
  14. package/dist/src/agent-session-codecs.js.map +1 -1
  15. package/dist/src/agent-session-failure.d.ts +4 -2
  16. package/dist/src/agent-session-failure.js +6 -2
  17. package/dist/src/agent-session-failure.js.map +1 -1
  18. package/dist/src/agent-session-flow-graph.d.ts +46 -0
  19. package/dist/src/agent-session-flow-graph.js +51 -0
  20. package/dist/src/agent-session-flow-graph.js.map +1 -1
  21. package/dist/src/agent-session-flow.d.ts +5 -3
  22. package/dist/src/agent-session-flow.js +10 -1
  23. package/dist/src/agent-session-flow.js.map +1 -1
  24. package/dist/src/agent-session-start.d.ts +1 -1
  25. package/dist/src/agent-session-start.js +2 -2
  26. package/dist/src/agent-session-start.js.map +1 -1
  27. package/dist/src/agent-session-steps.d.ts +2 -0
  28. package/dist/src/agent-session-steps.js +52 -3
  29. package/dist/src/agent-session-steps.js.map +1 -1
  30. package/dist/src/agent-session-tracer.js +1 -1
  31. package/dist/src/agent-session-tracer.js.map +1 -1
  32. package/dist/src/agent-session-transitions.d.ts +2 -0
  33. package/dist/src/agent-session-transitions.js +21 -1
  34. package/dist/src/agent-session-transitions.js.map +1 -1
  35. package/dist/src/agent-session-values.d.ts +76 -1
  36. package/dist/src/agent-session-values.js.map +1 -1
  37. package/dist/src/agent-session-wait-steps.js +14 -2
  38. package/dist/src/agent-session-wait-steps.js.map +1 -1
  39. package/dist/src/ai-sdk/ai-sdk-model-client.d.ts +15 -3
  40. package/dist/src/ai-sdk/ai-sdk-model-client.js +36 -7
  41. package/dist/src/ai-sdk/ai-sdk-model-client.js.map +1 -1
  42. package/dist/src/ai-sdk/index.d.ts +1 -1
  43. package/dist/src/ai-sdk/index.js +1 -1
  44. package/dist/src/ai-sdk/index.js.map +1 -1
  45. package/dist/src/{stepwise → builtin-loop}/agent-definition.d.ts +120 -5
  46. package/dist/src/builtin-loop/agent-definition.js.map +1 -0
  47. package/dist/src/builtin-loop/builtin-agent-session-flow.d.ts +69 -0
  48. package/dist/src/{stepwise/stepwise-agent-session-flow.js → builtin-loop/builtin-agent-session-flow.js} +15 -9
  49. package/dist/src/builtin-loop/builtin-agent-session-flow.js.map +1 -0
  50. package/dist/src/{stepwise/stepwise-agent-runner.d.ts → builtin-loop/builtin-loop-agent-runner.d.ts} +72 -14
  51. package/dist/src/{stepwise/stepwise-agent-runner.js → builtin-loop/builtin-loop-agent-runner.js} +284 -41
  52. package/dist/src/builtin-loop/builtin-loop-agent-runner.js.map +1 -0
  53. package/dist/src/{stepwise/stepwise-input-items.d.ts → builtin-loop/builtin-loop-input-items.d.ts} +7 -3
  54. package/dist/src/{stepwise/stepwise-input-items.js → builtin-loop/builtin-loop-input-items.js} +57 -10
  55. package/dist/src/builtin-loop/builtin-loop-input-items.js.map +1 -0
  56. package/dist/src/builtin-loop/function-tool.d.ts +282 -0
  57. package/dist/src/{stepwise → builtin-loop}/function-tool.js +63 -3
  58. package/dist/src/builtin-loop/function-tool.js.map +1 -0
  59. package/dist/src/builtin-loop/index.d.ts +8 -0
  60. package/dist/src/builtin-loop/index.js +13 -0
  61. package/dist/src/builtin-loop/index.js.map +1 -0
  62. package/dist/src/builtin-loop/json-schema-validation.js.map +1 -0
  63. package/dist/src/{stepwise → builtin-loop}/model-client.d.ts +36 -7
  64. package/dist/src/builtin-loop/model-client.js.map +1 -0
  65. package/dist/src/{stepwise → builtin-loop}/scripted-model-client.d.ts +8 -5
  66. package/dist/src/{stepwise → builtin-loop}/scripted-model-client.js +8 -5
  67. package/dist/src/builtin-loop/scripted-model-client.js.map +1 -0
  68. package/dist/src/{stepwise → builtin-loop}/tool-source.d.ts +2 -2
  69. package/dist/src/builtin-loop/tool-source.js.map +1 -0
  70. package/dist/src/connectors/connector-input-schema.js +1 -1
  71. package/dist/src/connectors/connector-input-schema.js.map +1 -1
  72. package/dist/src/connectors/connector-step-context.d.ts +19 -2
  73. package/dist/src/connectors/connector-step-context.js +61 -5
  74. package/dist/src/connectors/connector-step-context.js.map +1 -1
  75. package/dist/src/connectors/connector-tool-source.d.ts +61 -13
  76. package/dist/src/connectors/connector-tool-source.js +111 -24
  77. package/dist/src/connectors/connector-tool-source.js.map +1 -1
  78. package/dist/src/index.d.ts +6 -4
  79. package/dist/src/index.js +3 -1
  80. package/dist/src/index.js.map +1 -1
  81. package/dist/src/mcp/index.d.ts +1 -0
  82. package/dist/src/mcp/index.js +1 -0
  83. package/dist/src/mcp/index.js.map +1 -1
  84. package/dist/src/mcp/mcp-dex-conventions.d.ts +57 -0
  85. package/dist/src/mcp/mcp-dex-conventions.js +90 -0
  86. package/dist/src/mcp/mcp-dex-conventions.js.map +1 -0
  87. package/dist/src/mcp/mcp-image-content.d.ts +20 -0
  88. package/dist/src/mcp/mcp-image-content.js +82 -0
  89. package/dist/src/mcp/mcp-image-content.js.map +1 -0
  90. package/dist/src/mcp/mcp-tool-source.d.ts +178 -17
  91. package/dist/src/mcp/mcp-tool-source.js +237 -34
  92. package/dist/src/mcp/mcp-tool-source.js.map +1 -1
  93. package/dist/src/s3/index.d.ts +1 -0
  94. package/dist/src/s3/index.js +9 -0
  95. package/dist/src/s3/index.js.map +1 -0
  96. package/dist/src/s3/s3-media-store.d.ts +138 -0
  97. package/dist/src/s3/s3-media-store.js +255 -0
  98. package/dist/src/s3/s3-media-store.js.map +1 -0
  99. package/dist/src/stepwise/index.d.ts +41 -8
  100. package/dist/src/stepwise/index.js +35 -5
  101. package/dist/src/stepwise/index.js.map +1 -1
  102. package/dist/src/testing/agent-session-test-client.d.ts +6 -3
  103. package/dist/src/testing/agent-session-test-client.js +10 -3
  104. package/dist/src/testing/agent-session-test-client.js.map +1 -1
  105. package/dist/src/testing/scripted-model-client.d.ts +1 -1
  106. package/dist/src/testing/scripted-model-client.js +2 -2
  107. package/dist/src/testing/scripted-model-client.js.map +1 -1
  108. package/dist/src/tool-source-router.d.ts +3 -3
  109. package/dist/src/tool-source-router.js +2 -2
  110. package/dist/src/ui-stream/agent-event-json.d.ts +2 -1
  111. package/dist/src/ui-stream/agent-event-json.js +3 -1
  112. package/dist/src/ui-stream/agent-event-json.js.map +1 -1
  113. package/dist/src/ui-stream/agent-ui-messages.d.ts +11 -3
  114. package/dist/src/ui-stream/agent-ui-messages.js +29 -5
  115. package/dist/src/ui-stream/agent-ui-messages.js.map +1 -1
  116. package/package.json +16 -3
  117. package/dist/src/stepwise/agent-definition.js.map +0 -1
  118. package/dist/src/stepwise/function-tool.d.ts +0 -130
  119. package/dist/src/stepwise/function-tool.js.map +0 -1
  120. package/dist/src/stepwise/json-schema-validation.js.map +0 -1
  121. package/dist/src/stepwise/model-client.js.map +0 -1
  122. package/dist/src/stepwise/scripted-model-client.js.map +0 -1
  123. package/dist/src/stepwise/stepwise-agent-runner.js.map +0 -1
  124. package/dist/src/stepwise/stepwise-agent-session-flow.d.ts +0 -35
  125. package/dist/src/stepwise/stepwise-agent-session-flow.js.map +0 -1
  126. package/dist/src/stepwise/stepwise-input-items.js.map +0 -1
  127. package/dist/src/stepwise/tool-source.js.map +0 -1
  128. /package/dist/src/{stepwise → builtin-loop}/agent-definition.js +0 -0
  129. /package/dist/src/{stepwise → builtin-loop}/json-schema-validation.d.ts +0 -0
  130. /package/dist/src/{stepwise → builtin-loop}/json-schema-validation.js +0 -0
  131. /package/dist/src/{stepwise → builtin-loop}/model-client.js +0 -0
  132. /package/dist/src/{stepwise → builtin-loop}/tool-source.js +0 -0
@@ -5,16 +5,20 @@
5
5
  // See the LICENSE file in the repository root.
6
6
  //
7
7
  // SPDX-License-Identifier: LicenseRef-Sustainable-Use-1.0
8
- import { outcomeUnknownToolResult } from "../agent-session-values.js";
9
- /** Returns the session message that stores one item; `frameworkItem` is the item's compact snake_case JSON. */
10
- export function toStepwiseFrameworkMessage(item) {
8
+ import { outcomeUnknownToolResult, } from "../agent-session-values.js";
9
+ /**
10
+ * Returns the session message that stores one item; `frameworkItem` is the item's compact snake_case JSON. A user
11
+ * text or tool result item with images adds an `images` list of references; a tool result message also shows them
12
+ * in `images`.
13
+ */
14
+ export function toBuiltinLoopFrameworkMessage(item) {
11
15
  switch (item.type) {
12
16
  case "user_text":
13
17
  return {
14
18
  ...emptyProjection,
15
19
  role: "user",
16
20
  text: item.text,
17
- frameworkItem: JSON.stringify({ type: "user_text", text: item.text }),
21
+ frameworkItem: JSON.stringify({ type: "user_text", text: item.text, ...encodeImages(item.images) }),
18
22
  };
19
23
  case "tool_result":
20
24
  return {
@@ -28,7 +32,9 @@ export function toStepwiseFrameworkMessage(item) {
28
32
  tool_call_id: item.toolCallId,
29
33
  tool_name: item.toolName,
30
34
  output: item.output,
35
+ ...encodeImages(item.images),
31
36
  }),
37
+ ...((item.images ?? []).length === 0 ? {} : { images: item.images }),
32
38
  };
33
39
  case "model_output": {
34
40
  const singleToolCall = item.toolCalls.length === 1 ? item.toolCalls[0] : undefined;
@@ -55,13 +61,13 @@ export function toStepwiseFrameworkMessage(item) {
55
61
  }
56
62
  }
57
63
  }
58
- /** Reads the Stepwise item stored in one session message. */
64
+ /** Reads the built-in loop item stored in one session message. */
59
65
  export function readStoredModelInputItem(message) {
60
66
  try {
61
67
  return decodeModelInputItem(JSON.parse(message.frameworkItem));
62
68
  }
63
69
  catch (error) {
64
- throw new TypeError(`message ${message.sequence} is not a Stepwise item`, { cause: error });
70
+ throw new TypeError(`message ${message.sequence} is not a built-in loop item`, { cause: error });
65
71
  }
66
72
  }
67
73
  /**
@@ -109,16 +115,17 @@ function createOutcomeUnknownResult(toolCall) {
109
115
  };
110
116
  }
111
117
  function decodeModelInputItem(value) {
112
- const record = requireRecord(value, "Stepwise item");
118
+ const record = requireRecord(value, "built-in loop item");
113
119
  switch (record["type"]) {
114
120
  case "user_text":
115
- return { type: "user_text", text: requireString(record, "text") };
121
+ return { type: "user_text", text: requireString(record, "text"), ...decodeImages(record) };
116
122
  case "tool_result":
117
123
  return {
118
124
  type: "tool_result",
119
125
  toolCallId: requireString(record, "tool_call_id"),
120
126
  toolName: requireString(record, "tool_name"),
121
127
  output: requireString(record, "output"),
128
+ ...decodeImages(record),
122
129
  };
123
130
  case "model_output": {
124
131
  const text = record["text"] ?? null;
@@ -146,8 +153,48 @@ function decodeModelInputItem(value) {
146
153
  };
147
154
  }
148
155
  default:
149
- throw new TypeError(`unknown Stepwise item type ${JSON.stringify(record["type"])}`);
156
+ throw new TypeError(`unknown built-in loop item type ${JSON.stringify(record["type"])}`);
157
+ }
158
+ }
159
+ /** An item without images keeps the bytes it had before images existed. */
160
+ function encodeImages(images) {
161
+ if (images === undefined || images.length === 0) {
162
+ return {};
163
+ }
164
+ return {
165
+ images: images.map((image) => ({
166
+ type: image.type,
167
+ uri: image.uri,
168
+ mime_type: image.mimeType,
169
+ sha256: image.sha256,
170
+ size_bytes: image.sizeBytes,
171
+ })),
172
+ };
173
+ }
174
+ function decodeImages(record) {
175
+ const images = record["images"] ?? [];
176
+ if (!Array.isArray(images)) {
177
+ throw new TypeError("images must be an array");
178
+ }
179
+ if (images.length === 0) {
180
+ return {};
150
181
  }
182
+ return {
183
+ images: images.map((image) => {
184
+ const imageRecord = requireRecord(image, "images item");
185
+ const sizeBytes = imageRecord["size_bytes"];
186
+ if (typeof sizeBytes !== "number") {
187
+ throw new TypeError("size_bytes must be a number");
188
+ }
189
+ return {
190
+ type: "image",
191
+ uri: requireString(imageRecord, "uri"),
192
+ mimeType: requireString(imageRecord, "mime_type"),
193
+ sha256: requireString(imageRecord, "sha256"),
194
+ sizeBytes,
195
+ };
196
+ }),
197
+ };
151
198
  }
152
199
  const emptyProjection = {
153
200
  text: null,
@@ -169,4 +216,4 @@ function requireString(record, field) {
169
216
  }
170
217
  return value;
171
218
  }
172
- //# sourceMappingURL=stepwise-input-items.js.map
219
+ //# sourceMappingURL=builtin-loop-input-items.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builtin-loop-input-items.js","sourceRoot":"","sources":["../../../src/builtin-loop/builtin-loop-input-items.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAE1D,OAAO,EACL,wBAAwB,GAIzB,MAAM,4BAA4B,CAAC;AAGpC;;;;GAIG;AACH,MAAM,UAAU,6BAA6B,CAAC,IAAoB;IAChE,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,WAAW;YACd,OAAO;gBACL,GAAG,eAAe;gBAClB,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;aACpG,CAAC;QACJ,KAAK,aAAa;YAChB,OAAO;gBACL,GAAG,eAAe;gBAClB,IAAI,EAAE,MAAM;gBACZ,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,UAAU,EAAE,IAAI,CAAC,MAAM;gBACvB,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC;oBAC5B,IAAI,EAAE,aAAa;oBAC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C;AAEX,SAAS,aAAa,CAAC,KAAc,EAAE,QAAgB;IACrD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,SAAS,CAAC,GAAG,QAAQ,wBAAwB,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,KAA0C,CAAC;AACpD,CAAC;AAED,SAAS,aAAa,CAAC,MAAyC,EAAE,KAAa;IAC7E,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,IAAI,SAAS,CAAC,GAAG,KAAK,mBAAmB,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,282 @@
1
+ import type { AgentEventWriter } from "../agent-framework-runner.js";
2
+ import type { MediaStore } from "../agent-media.js";
3
+ import type { AgentImageReference, QuestionAnswer, ToolEffect } from "../agent-session-values.js";
4
+ /**
5
+ * A value that {@link FunctionToolDefinition.prepareArguments} may return: any value except a Promise or another
6
+ * object with a `then` method, because the conversion must be synchronous.
7
+ *
8
+ * Return an object for arguments that can pass the schema check. Any other value fails the call with
9
+ * `expected a JSON object`. An argument named `then` is allowed when its value is JSON, such as a string;
10
+ * only a function there is refused. To return the decoded arguments unchanged, narrow them first, such as
11
+ * with `args as object`.
12
+ * @since 0.5.0
13
+ */
14
+ export type PreparedToolArguments = string | number | boolean | null | readonly unknown[] | {
15
+ readonly then?: PreparedToolArgumentThenValue;
16
+ readonly [key: string]: unknown;
17
+ } | (object & {
18
+ readonly then?: PreparedToolArgumentThenValue;
19
+ });
20
+ /** JSON values that an argument named `then` may hold; a function there would make the arguments a thenable. */
21
+ type PreparedToolArgumentThenValue = string | number | boolean | null | readonly unknown[] | Readonly<Record<string, unknown>>;
22
+ /**
23
+ * What a function tool receives besides its arguments, for one run of one tool call.
24
+ *
25
+ * Pass {@link idempotencyKey} to services that deduplicate requests: it is the same on every attempt
26
+ * of the call, so an `idempotent_write` retried by `CallTool` is applied once.
27
+ */
28
+ export interface ToolCallContext {
29
+ /** Flow ID, which is the session ID. */
30
+ readonly flowId: string;
31
+ /** Turn that requested the call. */
32
+ readonly turnId: string;
33
+ /** Model tool call ID. */
34
+ readonly toolCallId: string;
35
+ /** Stable key `<flowId>/<turnId>/<toolCallId>`, identical on every attempt of the call. */
36
+ readonly idempotencyKey: string;
37
+ /** One-based attempt of the tool Step; `read` and `idempotent_write` calls get up to three. */
38
+ readonly attempt: number;
39
+ /**
40
+ * Effect of this call after the tool policies are applied.
41
+ *
42
+ * It is the effect stored on the call, which chose `CallTool` or `CallSingleAttemptTool` and the default
43
+ * approval. It can differ from {@link FunctionToolDefinition.effect} when a policy in
44
+ * {@link AgentDefinition.toolPolicies} or a session policy overrides it.
45
+ *
46
+ * The runner always sets it. It is `undefined` only in a context built by hand, such as in a unit test.
47
+ * Treat `undefined` as an unknown effect, and handle the call as a write whose outcome may be unknown.
48
+ *
49
+ * Use it in a wrapper that turns errors into {@link ToolExecutionError}. `non_idempotent_write` and
50
+ * `unclassified` calls run once in `CallSingleAttemptTool`. For them, and for an unknown effect, let an error
51
+ * whose outcome is unknown propagate, so the session records `outcome_unknown` and never repeats the call.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * execute: async (args, context) => {
56
+ * try {
57
+ * return await client.send(args);
58
+ * } catch (error) {
59
+ * if (context.effect !== "read" && context.effect !== "idempotent_write") throw error;
60
+ * throw new ToolExecutionError(String(error));
61
+ * }
62
+ * },
63
+ * ```
64
+ * @since 0.5.0
65
+ */
66
+ readonly effect?: ToolEffect;
67
+ /** Events writer bound to the turn and attempt, for progress text. */
68
+ readonly events: AgentEventWriter;
69
+ /** Signal aborted when Dex cancels the attempt; pass it to network calls. */
70
+ readonly cancellationSignal: AbortSignal;
71
+ /** Absolute deadline of the current attempt, or `undefined`. */
72
+ readonly deadline: Date | undefined;
73
+ /**
74
+ * Answers to the questions this call asked by returning {@link ToolInputRequested}, oldest first;
75
+ * empty on the first run.
76
+ */
77
+ readonly inputAnswers: readonly QuestionAnswer[];
78
+ /** `continuation` of the call's last {@link ToolInputRequested}, or `null`. */
79
+ readonly inputContinuation: string | null;
80
+ /**
81
+ * The store that holds the session's images, the one the runner was built with, or `undefined` when it has none.
82
+ *
83
+ * Upload image bytes with `putImage` and return the references with {@link functionToolResult}. See
84
+ * {@link functionToolResult} for an example.
85
+ * @since 0.5.0
86
+ */
87
+ readonly mediaStore?: MediaStore;
88
+ /**
89
+ * Records a heartbeat. The session already records one every 20 seconds while the tool runs.
90
+ * @returns A Promise that resolves when the Worker accepted the heartbeat.
91
+ */
92
+ heartbeat(): Promise<void>;
93
+ }
94
+ /**
95
+ * Text and images that a function tool returns. Create it with {@link functionToolResult}.
96
+ *
97
+ * Only an object that {@link functionToolResult} created is a result with images. Any other object with the same
98
+ * fields, such as a copy or a literal, is serialized as JSON like every other tool result.
99
+ * @since 0.5.0
100
+ */
101
+ export interface FunctionToolResult {
102
+ /** Tool output text the model sees. */
103
+ readonly output: string;
104
+ /**
105
+ * Images the model sees after {@link output}, uploaded with `MediaStore.putImage`, at most
106
+ * `maxImagesPerMessage`. Omit it for none.
107
+ */
108
+ readonly images?: readonly AgentImageReference[];
109
+ }
110
+ /**
111
+ * Creates a function tool result with text and images.
112
+ *
113
+ * Return it from {@link FunctionToolDefinition.execute} to show the model images with the output. Upload each
114
+ * image's bytes with {@link ToolCallContext.mediaStore} inside the call, then return the references. A retried
115
+ * attempt uploads the same bytes to the same object, so uploading again is safe.
116
+ *
117
+ * The runner returns the result as a `ToolExecutionResult` with the same output and images, so the session checks
118
+ * the images exactly as it checks a tool source's images. More than `maxImagesPerMessage` images, or a reference
119
+ * that `validateImageReference` refuses, fails the attempt with `ImageValidationError`. A failed attempt of a
120
+ * `read` or `idempotent_write` tool retries; a failed single-attempt call records `outcome_unknown`. Images from a
121
+ * runner without a media store throw `ToolExecutionError` instead, because no retry could show them: the session
122
+ * records `failed` once and the model sees the error text. A result without images is the same as returning
123
+ * `output` as a string. Return the object it creates: a copy is serialized as JSON.
124
+ *
125
+ * @example
126
+ * ```ts
127
+ * const takeScreenshot = functionTool<Record<string, never>>({
128
+ * name: "take_screenshot",
129
+ * description: "Take a screenshot of the screen.",
130
+ * parameters: { type: "object", properties: {} },
131
+ * effect: "read",
132
+ * execute: async (_args, context) => {
133
+ * if (context.mediaStore === undefined) {
134
+ * return "Screenshots need a media store.";
135
+ * }
136
+ * const reference = await context.mediaStore.putImage(await screen.capturePng());
137
+ * return functionToolResult({ output: "Took a screenshot.", images: [reference] });
138
+ * },
139
+ * });
140
+ * ```
141
+ * @param result - The output text and, optionally, the image references.
142
+ * @returns The frozen result, to return from `execute`.
143
+ * @throws {TypeError} When `output` is not a string or `images` is not an array.
144
+ * @since 0.5.0
145
+ */
146
+ export declare function functionToolResult(result: {
147
+ readonly output: string;
148
+ readonly images?: readonly AgentImageReference[];
149
+ }): FunctionToolResult;
150
+ export declare function isFunctionToolResult(value: unknown): value is FunctionToolResult;
151
+ /** Definition passed to {@link functionTool}. */
152
+ export interface FunctionToolDefinition<Arguments> {
153
+ /** Tool name as the model calls it: 1 to 64 letters, digits, `_`, or `-`, unique within the agent. */
154
+ readonly name: string;
155
+ /** Description for the model; say what the tool does and when to use it. */
156
+ readonly description: string;
157
+ /**
158
+ * JSON Schema of the arguments, with `type` `"object"`. The runner checks the model's arguments
159
+ * against it before {@link execute} runs, as the Python core does: `type`, `enum`, `anyOf`,
160
+ * `properties`, `required`, `additionalProperties`, `items`, `minimum`, and `maximum` are checked, and
161
+ * other keywords are only shown to the model.
162
+ */
163
+ readonly parameters: Readonly<Record<string, unknown>>;
164
+ /** Side-effect class; it picks `CallTool` or `CallSingleAttemptTool` and the default approval. */
165
+ readonly effect: ToolEffect;
166
+ /**
167
+ * Whether every call waits for `resolve_interrupt` before it runs. Defaults to `true` for
168
+ * `non_idempotent_write` and `unclassified` and to `false` otherwise. A tool policy in
169
+ * {@link AgentDefinition.toolPolicies} overrides it.
170
+ */
171
+ readonly requiresApproval?: boolean;
172
+ /**
173
+ * Converts the model's arguments before the {@link parameters} check, such as an argument shape that an
174
+ * earlier version of the tool accepted.
175
+ *
176
+ * The runner calls it with the arguments decoded from JSON, which may be any JSON value. It checks the
177
+ * returned value against {@link parameters} and passes it to {@link execute}. A throw fails the call like
178
+ * a schema violation: the model sees `invalid arguments for <tool>: <message>`, and {@link execute} does not
179
+ * run. Absent, the decoded arguments are checked unchanged.
180
+ *
181
+ * It must be synchronous and deterministic, and it must have no side effects. Every attempt converts the
182
+ * stored arguments again. A Promise or another object with a `then` method fails the call with
183
+ * `invalid arguments for <tool>: argument conversion must be synchronous`. The stored tool call, the approval
184
+ * interrupt, and the transcript keep the model's original arguments.
185
+ *
186
+ * @example
187
+ * ```ts
188
+ * // Version 1 took { id }; version 2 takes { order_id }.
189
+ * prepareArguments: (args) => {
190
+ * const record = args as Record<string, unknown>;
191
+ * return "id" in record && !("order_id" in record) ? { order_id: record["id"] } : record;
192
+ * },
193
+ * ```
194
+ * @param args - The model's arguments, decoded from JSON.
195
+ * @returns The arguments to check against {@link parameters}.
196
+ * @since 0.5.0
197
+ */
198
+ readonly prepareArguments?: (args: unknown) => PreparedToolArguments;
199
+ /**
200
+ * Runs the tool once, inside its own tool Step.
201
+ *
202
+ * A `string` result is the output the model sees. A {@link FunctionToolResult} from {@link functionToolResult}
203
+ * shows the model its output and images. A {@link ToolInputRequested} result asks the user a
204
+ * question; return it only before the tool took any effect, and the tool runs again with the answer in
205
+ * {@link ToolCallContext.inputAnswers}. Any other result is serialized as JSON, with the separators
206
+ * of Python's `json.dumps`. Throw `ToolExecutionError` for a failure the model should see; any other
207
+ * error fails the attempt, as {@link ToolExecutionError} describes.
208
+ *
209
+ * Changed in 0.5.0: a {@link FunctionToolResult} result shows the model its images.
210
+ * @param args - Arguments that passed the {@link parameters} check.
211
+ * @param context - Idempotency key, attempt, events, and heartbeat of this run.
212
+ * @returns The tool result.
213
+ */
214
+ readonly execute: (args: Arguments, context: ToolCallContext) => unknown;
215
+ }
216
+ /** A tool implemented by a plain function, created by {@link functionTool}. */
217
+ export interface FunctionTool {
218
+ /** Discriminator. */
219
+ readonly kind: "function_tool";
220
+ /** Tool name. */
221
+ readonly name: string;
222
+ /** Description for the model. */
223
+ readonly description: string;
224
+ /** JSON Schema of the arguments. */
225
+ readonly parameters: Readonly<Record<string, unknown>>;
226
+ /** Side-effect class. */
227
+ readonly effect: ToolEffect;
228
+ /** Approval override, or `undefined` for the effect's default. */
229
+ readonly requiresApproval: boolean | undefined;
230
+ /**
231
+ * Converts the model's decoded arguments before the schema check, or `undefined` to check them unchanged.
232
+ * See {@link FunctionToolDefinition.prepareArguments}.
233
+ * @param args - The model's arguments, decoded from JSON.
234
+ * @returns The arguments to check against {@link parameters}.
235
+ * @since 0.5.0
236
+ */
237
+ readonly prepareArguments?: (args: unknown) => PreparedToolArguments;
238
+ /**
239
+ * Runs the tool with checked arguments.
240
+ * @param args - Arguments that passed the schema check.
241
+ * @param context - Context of this run.
242
+ * @returns A Promise of the tool result.
243
+ */
244
+ execute(args: unknown, context: ToolCallContext): Promise<unknown>;
245
+ }
246
+ /**
247
+ * Creates a function tool for a built-in loop agent.
248
+ *
249
+ * Every function tool declares its effect, which picks the tool Step and the default approval exactly
250
+ * as for adapter tools. Each call runs in its own Step, so a crash repeats at most a `read` or
251
+ * `idempotent_write` call and never repeats a `non_idempotent_write` call.
252
+ *
253
+ * @example
254
+ * ```ts
255
+ * const lookupOrder = functionTool<{ order_id: string }>({
256
+ * name: "lookup_order",
257
+ * description: "Look up an order by its ID.",
258
+ * parameters: { type: "object", properties: { order_id: { type: "string" } }, required: ["order_id"] },
259
+ * effect: "read",
260
+ * execute: async ({ order_id }) => orders.get(order_id),
261
+ * });
262
+ * const refundOrder = functionTool<{ order_id: string; amount_cents: number }>({
263
+ * name: "refund_order",
264
+ * description: "Refund part of an order.",
265
+ * parameters: {
266
+ * type: "object",
267
+ * properties: { order_id: { type: "string" }, amount_cents: { type: "integer", minimum: 1 } },
268
+ * required: ["order_id", "amount_cents"],
269
+ * },
270
+ * effect: "non_idempotent_write",
271
+ * execute: async ({ order_id, amount_cents }, context) =>
272
+ * payments.refund(order_id, amount_cents, { idempotencyKey: context.idempotencyKey }),
273
+ * });
274
+ * ```
275
+ * @typeParam Arguments - Type of the checked arguments; it is not checked against the schema.
276
+ * @param definition - Name, description, schema, effect, approval, argument conversion, and implementation.
277
+ * @returns The tool, to pass in {@link AgentDefinition.tools}.
278
+ * @throws {TypeError} When the name, description, schema, effect, argument conversion, or implementation is
279
+ * invalid.
280
+ */
281
+ export declare function functionTool<Arguments = Record<string, unknown>>(definition: FunctionToolDefinition<Arguments>): FunctionTool;
282
+ export {};
@@ -7,8 +7,63 @@
7
7
  // SPDX-License-Identifier: LicenseRef-Sustainable-Use-1.0
8
8
  const toolNamePattern = /^[A-Za-z0-9_-]{1,64}$/;
9
9
  const toolEffects = ["read", "idempotent_write", "non_idempotent_write", "unclassified"];
10
+ // Identity, not fields, marks a result, so a tool's plain JSON with the same keys stays JSON.
11
+ const createdFunctionToolResults = new WeakSet();
10
12
  /**
11
- * Creates a function tool for a Stepwise agent.
13
+ * Creates a function tool result with text and images.
14
+ *
15
+ * Return it from {@link FunctionToolDefinition.execute} to show the model images with the output. Upload each
16
+ * image's bytes with {@link ToolCallContext.mediaStore} inside the call, then return the references. A retried
17
+ * attempt uploads the same bytes to the same object, so uploading again is safe.
18
+ *
19
+ * The runner returns the result as a `ToolExecutionResult` with the same output and images, so the session checks
20
+ * the images exactly as it checks a tool source's images. More than `maxImagesPerMessage` images, or a reference
21
+ * that `validateImageReference` refuses, fails the attempt with `ImageValidationError`. A failed attempt of a
22
+ * `read` or `idempotent_write` tool retries; a failed single-attempt call records `outcome_unknown`. Images from a
23
+ * runner without a media store throw `ToolExecutionError` instead, because no retry could show them: the session
24
+ * records `failed` once and the model sees the error text. A result without images is the same as returning
25
+ * `output` as a string. Return the object it creates: a copy is serialized as JSON.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * const takeScreenshot = functionTool<Record<string, never>>({
30
+ * name: "take_screenshot",
31
+ * description: "Take a screenshot of the screen.",
32
+ * parameters: { type: "object", properties: {} },
33
+ * effect: "read",
34
+ * execute: async (_args, context) => {
35
+ * if (context.mediaStore === undefined) {
36
+ * return "Screenshots need a media store.";
37
+ * }
38
+ * const reference = await context.mediaStore.putImage(await screen.capturePng());
39
+ * return functionToolResult({ output: "Took a screenshot.", images: [reference] });
40
+ * },
41
+ * });
42
+ * ```
43
+ * @param result - The output text and, optionally, the image references.
44
+ * @returns The frozen result, to return from `execute`.
45
+ * @throws {TypeError} When `output` is not a string or `images` is not an array.
46
+ * @since 0.5.0
47
+ */
48
+ export function functionToolResult(result) {
49
+ if (typeof result?.output !== "string") {
50
+ throw new TypeError("function tool result output must be a string");
51
+ }
52
+ if (result.images !== undefined && !Array.isArray(result.images)) {
53
+ throw new TypeError("function tool result images must be an array");
54
+ }
55
+ const created = Object.freeze({
56
+ output: result.output,
57
+ ...(result.images === undefined ? {} : { images: result.images }),
58
+ });
59
+ createdFunctionToolResults.add(created);
60
+ return created;
61
+ }
62
+ export function isFunctionToolResult(value) {
63
+ return typeof value === "object" && value !== null && createdFunctionToolResults.has(value);
64
+ }
65
+ /**
66
+ * Creates a function tool for a built-in loop agent.
12
67
  *
13
68
  * Every function tool declares its effect, which picks the tool Step and the default approval exactly
14
69
  * as for adapter tools. Each call runs in its own Step, so a crash repeats at most a `read` or
@@ -37,9 +92,10 @@ const toolEffects = ["read", "idempotent_write", "non_idempotent_write", "unclas
37
92
  * });
38
93
  * ```
39
94
  * @typeParam Arguments - Type of the checked arguments; it is not checked against the schema.
40
- * @param definition - Name, description, schema, effect, approval, and implementation.
95
+ * @param definition - Name, description, schema, effect, approval, argument conversion, and implementation.
41
96
  * @returns The tool, to pass in {@link AgentDefinition.tools}.
42
- * @throws {TypeError} When the name, description, schema, effect, or implementation is invalid.
97
+ * @throws {TypeError} When the name, description, schema, effect, argument conversion, or implementation is
98
+ * invalid.
43
99
  */
44
100
  export function functionTool(definition) {
45
101
  if (typeof definition?.name !== "string" || !toolNamePattern.test(definition.name)) {
@@ -61,6 +117,9 @@ export function functionTool(definition) {
61
117
  if (typeof definition.execute !== "function") {
62
118
  throw new TypeError(`function tool ${definition.name} needs an execute function`);
63
119
  }
120
+ if (definition.prepareArguments !== undefined && typeof definition.prepareArguments !== "function") {
121
+ throw new TypeError(`function tool ${definition.name} prepareArguments must be a function`);
122
+ }
64
123
  const execute = definition.execute;
65
124
  return Object.freeze({
66
125
  kind: "function_tool",
@@ -69,6 +128,7 @@ export function functionTool(definition) {
69
128
  parameters,
70
129
  effect: definition.effect,
71
130
  requiresApproval: definition.requiresApproval,
131
+ ...(definition.prepareArguments === undefined ? {} : { prepareArguments: definition.prepareArguments }),
72
132
  execute: async (args, context) => await execute(args, context),
73
133
  });
74
134
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function-tool.js","sourceRoot":"","sources":["../../../src/builtin-loop/function-tool.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAM1D,MAAM,eAAe,GAAG,uBAAuB,CAAC;AAChD,MAAM,WAAW,GAA0B,CAAC,MAAM,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,cAAc,CAAC,CAAC;AAChH,8FAA8F;AAC9F,MAAM,0BAA0B,GAAG,IAAI,OAAO,EAAU,CAAC;AAwHzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAGlC;IACC,IAAI,OAAO,MAAM,EAAE,MAAM,KAAK,QAAQ,EAAE,CAAC;QACvC,MAAM,IAAI,SAAS,CAAC,8CAA8C,CAAC,CAAC;IAC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C,gBAAgB;QAC7C,GAAG,CAAC,UAAU,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,EAAE,CAAC;QACvG,OAAO,EAAE,KAAK,EAAE,IAAa,EAAE,OAAwB,EAAE,EAAE,CAAC,MAAM,OAAO,CAAC,IAAiB,EAAE,OAAO,CAAC;KACtG,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,8 @@
1
+ export { type AgentDefinition, type InstructionContext, type PlanningToolChoice, type ContinueTurn, type TurnContinuation, type TurnContinuationContext, } from "./agent-definition.js";
2
+ export { functionTool, functionToolResult, type FunctionTool, type FunctionToolDefinition, type FunctionToolResult, type PreparedToolArguments, type ToolCallContext, } from "./function-tool.js";
3
+ export { type ModelClient, type ModelInputItem, type ModelOutputItem, type ModelOutputWriter, type ModelRequest, type ModelRequestMetadata, type ModelResponse, type ModelSettings, type ModelToolCall, type ModelToolChoice, type ModelToolDefinition, type ModelToolResultItem, type ModelUserTextItem, } from "./model-client.js";
4
+ export { ScriptedModelClient, defaultMaxRecordedRequests, scriptedModelApi, scriptedModelProvider, type ScriptedModelReply, type ScriptedModelResponder, type ScriptedToolCall, } from "./scripted-model-client.js";
5
+ export { createBuiltinAgentSessionFlow, type BuiltinAgentSessionFlowOptions } from "./builtin-agent-session-flow.js";
6
+ export { buildContextSummaryNote, buildContextSummaryOmissionNote, contextSummaryInstructions, contextSummaryNoteHeader, contextSummaryRequest, } from "../agent-context-compaction.js";
7
+ export { BuiltinLoopAgentRunner, defaultToolSourceListingTimeoutMs, maxConsecutiveTurnContinuations, } from "./builtin-loop-agent-runner.js";
8
+ export { type SourceToolDefinition, type ToolSource } from "./tool-source.js";
@@ -0,0 +1,13 @@
1
+ // Copyright (c) 2026 Super Durable, Inc.
2
+ //
3
+ // Licensed under the Sustainable Use License 1.0.
4
+ // You may not use this file except in compliance with the License.
5
+ // See the LICENSE file in the repository root.
6
+ //
7
+ // SPDX-License-Identifier: LicenseRef-Sustainable-Use-1.0
8
+ export { functionTool, functionToolResult, } from "./function-tool.js";
9
+ export { ScriptedModelClient, defaultMaxRecordedRequests, scriptedModelApi, scriptedModelProvider, } from "./scripted-model-client.js";
10
+ export { createBuiltinAgentSessionFlow } from "./builtin-agent-session-flow.js";
11
+ export { buildContextSummaryNote, buildContextSummaryOmissionNote, contextSummaryInstructions, contextSummaryNoteHeader, contextSummaryRequest, } from "../agent-context-compaction.js";
12
+ export { BuiltinLoopAgentRunner, defaultToolSourceListingTimeoutMs, maxConsecutiveTurnContinuations, } from "./builtin-loop-agent-runner.js";
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/builtin-loop/index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAU1D,OAAO,EACL,YAAY,EACZ,kBAAkB,GAMnB,MAAM,oBAAoB,CAAC;AAgB5B,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,gBAAgB,EAChB,qBAAqB,GAItB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,6BAA6B,EAAuC,MAAM,iCAAiC,CAAC;AACrH,OAAO,EACL,uBAAuB,EACvB,+BAA+B,EAC/B,0BAA0B,EAC1B,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,sBAAsB,EACtB,iCAAiC,EACjC,+BAA+B,GAChC,MAAM,gCAAgC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-schema-validation.js","sourceRoot":"","sources":["../../../src/builtin-loop/json-schema-validation.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAM1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