@sixb/agent 0.0.0-stage → 0.1.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 (219) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +31 -2
  3. package/dist/abort.d.ts +6 -0
  4. package/dist/abort.d.ts.map +1 -0
  5. package/dist/agent-prompt.d.ts +120 -0
  6. package/dist/agent-prompt.d.ts.map +1 -0
  7. package/dist/agent-runtime/errors.d.ts +13 -0
  8. package/dist/agent-runtime/errors.d.ts.map +1 -0
  9. package/dist/agent-runtime/preflight.d.ts +18 -0
  10. package/dist/agent-runtime/preflight.d.ts.map +1 -0
  11. package/dist/agent-runtime/profile.d.ts +14 -0
  12. package/dist/agent-runtime/profile.d.ts.map +1 -0
  13. package/dist/artifacts/layout-check/layout-check.d.ts +87 -0
  14. package/dist/artifacts/layout-check/layout-check.d.ts.map +1 -0
  15. package/dist/artifacts/materialize.d.ts +115 -0
  16. package/dist/artifacts/materialize.d.ts.map +1 -0
  17. package/dist/artifacts/publish-tool.d.ts +86 -0
  18. package/dist/artifacts/publish-tool.d.ts.map +1 -0
  19. package/dist/ask-parent-tool.d.ts +36 -0
  20. package/dist/ask-parent-tool.d.ts.map +1 -0
  21. package/dist/attachments.d.ts +68 -0
  22. package/dist/attachments.d.ts.map +1 -0
  23. package/dist/child-files.d.ts +96 -0
  24. package/dist/child-files.d.ts.map +1 -0
  25. package/dist/child-questions.d.ts +24 -0
  26. package/dist/child-questions.d.ts.map +1 -0
  27. package/dist/computer-runner.d.ts +65 -0
  28. package/dist/computer-runner.d.ts.map +1 -0
  29. package/dist/context-budget.d.ts +28 -0
  30. package/dist/context-budget.d.ts.map +1 -0
  31. package/dist/context-compaction.d.ts +48 -0
  32. package/dist/context-compaction.d.ts.map +1 -0
  33. package/dist/conversation-memory.d.ts +21 -0
  34. package/dist/conversation-memory.d.ts.map +1 -0
  35. package/dist/errors.d.ts +46 -0
  36. package/dist/errors.d.ts.map +1 -0
  37. package/dist/execution-plan.d.ts +34 -0
  38. package/dist/execution-plan.d.ts.map +1 -0
  39. package/dist/failure.d.ts +14 -0
  40. package/dist/failure.d.ts.map +1 -0
  41. package/dist/family-mailbox.d.ts +60 -0
  42. package/dist/family-mailbox.d.ts.map +1 -0
  43. package/dist/file-ref.d.ts +6 -0
  44. package/dist/file-ref.d.ts.map +1 -0
  45. package/dist/image-attachments.d.ts +34 -0
  46. package/dist/image-attachments.d.ts.map +1 -0
  47. package/dist/index.d.ts +35 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +12168 -0
  50. package/dist/index.js.map +65 -0
  51. package/dist/message-authors.d.ts +34 -0
  52. package/dist/message-authors.d.ts.map +1 -0
  53. package/dist/message-times.d.ts +8 -0
  54. package/dist/message-times.d.ts.map +1 -0
  55. package/dist/model-adapters.d.ts +55 -0
  56. package/dist/model-adapters.d.ts.map +1 -0
  57. package/dist/model-lines.d.ts +16 -0
  58. package/dist/model-lines.d.ts.map +1 -0
  59. package/dist/requester.d.ts +15 -0
  60. package/dist/requester.d.ts.map +1 -0
  61. package/dist/run-agent-turn.d.ts +63 -0
  62. package/dist/run-agent-turn.d.ts.map +1 -0
  63. package/dist/run-child.d.ts +77 -0
  64. package/dist/run-child.d.ts.map +1 -0
  65. package/dist/run-conversation-turn.d.ts +42 -0
  66. package/dist/run-conversation-turn.d.ts.map +1 -0
  67. package/dist/run-credential.d.ts +22 -0
  68. package/dist/run-credential.d.ts.map +1 -0
  69. package/dist/run-environment.d.ts +115 -0
  70. package/dist/run-environment.d.ts.map +1 -0
  71. package/dist/run-fate.d.ts +15 -0
  72. package/dist/run-fate.d.ts.map +1 -0
  73. package/dist/run-sandbox.d.ts +60 -0
  74. package/dist/run-sandbox.d.ts.map +1 -0
  75. package/dist/run-subagent.d.ts +51 -0
  76. package/dist/run-subagent.d.ts.map +1 -0
  77. package/dist/run-workflow-agent-node.d.ts +41 -0
  78. package/dist/run-workflow-agent-node.d.ts.map +1 -0
  79. package/dist/sandbox-api-context.d.ts +34 -0
  80. package/dist/sandbox-api-context.d.ts.map +1 -0
  81. package/dist/sandbox-file-registry.d.ts +9 -0
  82. package/dist/sandbox-file-registry.d.ts.map +1 -0
  83. package/dist/sandbox-files.d.ts +71 -0
  84. package/dist/sandbox-files.d.ts.map +1 -0
  85. package/dist/sandbox-handle.d.ts +15 -0
  86. package/dist/sandbox-handle.d.ts.map +1 -0
  87. package/dist/sandbox-readiness.d.ts +8 -0
  88. package/dist/sandbox-readiness.d.ts.map +1 -0
  89. package/dist/skills/built-in.d.ts +15 -0
  90. package/dist/skills/built-in.d.ts.map +1 -0
  91. package/dist/subagent-continuation.d.ts +27 -0
  92. package/dist/subagent-continuation.d.ts.map +1 -0
  93. package/dist/subagent-inbox.d.ts +53 -0
  94. package/dist/subagent-inbox.d.ts.map +1 -0
  95. package/dist/subagent-tools.d.ts +282 -0
  96. package/dist/subagent-tools.d.ts.map +1 -0
  97. package/dist/thread-context.d.ts +12 -0
  98. package/dist/thread-context.d.ts.map +1 -0
  99. package/dist/tools/attachments.d.ts +11 -0
  100. package/dist/tools/attachments.d.ts.map +1 -0
  101. package/dist/tools/bash.d.ts +60 -0
  102. package/dist/tools/bash.d.ts.map +1 -0
  103. package/dist/tools/model-spec.d.ts +4 -0
  104. package/dist/tools/model-spec.d.ts.map +1 -0
  105. package/dist/tools/read.d.ts +43 -0
  106. package/dist/tools/read.d.ts.map +1 -0
  107. package/dist/tools/result-media.d.ts +22 -0
  108. package/dist/tools/result-media.d.ts.map +1 -0
  109. package/dist/tools/result-output.d.ts +18 -0
  110. package/dist/tools/result-output.d.ts.map +1 -0
  111. package/dist/tools/tool-files.d.ts +59 -0
  112. package/dist/tools/tool-files.d.ts.map +1 -0
  113. package/dist/tools/view-file.d.ts +40 -0
  114. package/dist/tools/view-file.d.ts.map +1 -0
  115. package/dist/tsconfig.json +5 -0
  116. package/dist/turn-runtime.d.ts +19 -0
  117. package/dist/turn-runtime.d.ts.map +1 -0
  118. package/dist/types.d.ts +76 -0
  119. package/dist/types.d.ts.map +1 -0
  120. package/dist/workflow-input-attachments.d.ts +18 -0
  121. package/dist/workflow-input-attachments.d.ts.map +1 -0
  122. package/package.json +59 -4
  123. package/src/abort.ts +40 -0
  124. package/src/agent-prompt.ts +758 -0
  125. package/src/agent-runtime/errors.ts +44 -0
  126. package/src/agent-runtime/preflight.ts +314 -0
  127. package/src/agent-runtime/profile.ts +23 -0
  128. package/src/artifacts/layout-check/check.cjs +478 -0
  129. package/src/artifacts/layout-check/layout-check.ts +460 -0
  130. package/src/artifacts/materialize.ts +380 -0
  131. package/src/artifacts/publish-tool.ts +700 -0
  132. package/src/ask-parent-tool.ts +100 -0
  133. package/src/attachments.ts +850 -0
  134. package/src/child-files.ts +540 -0
  135. package/src/child-questions.ts +42 -0
  136. package/src/computer-runner.ts +284 -0
  137. package/src/context-budget.ts +161 -0
  138. package/src/context-compaction.ts +529 -0
  139. package/src/conversation-memory.ts +45 -0
  140. package/src/errors.ts +85 -0
  141. package/src/execution-plan.ts +50 -0
  142. package/src/failure.ts +71 -0
  143. package/src/family-mailbox.ts +189 -0
  144. package/src/file-ref.ts +18 -0
  145. package/src/image-attachments.ts +322 -0
  146. package/src/index.ts +54 -0
  147. package/src/message-authors.ts +77 -0
  148. package/src/message-times.ts +21 -0
  149. package/src/model-adapters.ts +227 -0
  150. package/src/model-lines.ts +28 -0
  151. package/src/requester.ts +21 -0
  152. package/src/run-agent-turn.ts +347 -0
  153. package/src/run-child.ts +319 -0
  154. package/src/run-conversation-turn.ts +257 -0
  155. package/src/run-credential.ts +55 -0
  156. package/src/run-environment.ts +769 -0
  157. package/src/run-fate.ts +51 -0
  158. package/src/run-sandbox.ts +63 -0
  159. package/src/run-subagent.ts +347 -0
  160. package/src/run-workflow-agent-node.ts +270 -0
  161. package/src/sandbox-api-context.ts +234 -0
  162. package/src/sandbox-file-registry.ts +26 -0
  163. package/src/sandbox-files.ts +326 -0
  164. package/src/sandbox-handle.ts +19 -0
  165. package/src/sandbox-readiness.ts +22 -0
  166. package/src/skills/built-in.ts +183 -0
  167. package/src/skills/sixb-artifacts/SKILL.md +95 -0
  168. package/src/skills/sixb-artifacts/canvas.md +104 -0
  169. package/src/skills/sixb-artifacts/document.md +63 -0
  170. package/src/skills/sixb-artifacts/examples/canvas/onboarding-flow/boards/first-job.html +42 -0
  171. package/src/skills/sixb-artifacts/examples/canvas/onboarding-flow/boards/region.html +29 -0
  172. package/src/skills/sixb-artifacts/examples/canvas/onboarding-flow/boards/shared.css +35 -0
  173. package/src/skills/sixb-artifacts/examples/canvas/onboarding-flow/boards/welcome.html +31 -0
  174. package/src/skills/sixb-artifacts/examples/canvas/onboarding-flow/canvas.json +107 -0
  175. package/src/skills/sixb-artifacts/examples/canvas/retro/canvas.json +158 -0
  176. package/src/skills/sixb-artifacts/examples/document/incident-report/document.md +35 -0
  177. package/src/skills/sixb-artifacts/examples/document/operations-review/document.md +41 -0
  178. package/src/skills/sixb-artifacts/examples/document/operations-review/figures/restorations.svg +1 -0
  179. package/src/skills/sixb-artifacts/examples/page/collections-desk/index.html +169 -0
  180. package/src/skills/sixb-artifacts/examples/page/collections-desk/queries/overdue.json +13 -0
  181. package/src/skills/sixb-artifacts/examples/page/dispatch-board/data/dispatch.json +234 -0
  182. package/src/skills/sixb-artifacts/examples/page/dispatch-board/index.html +245 -0
  183. package/src/skills/sixb-artifacts/examples/page/fleet-planner/data/plan.json +53 -0
  184. package/src/skills/sixb-artifacts/examples/page/fleet-planner/index.html +462 -0
  185. package/src/skills/sixb-artifacts/examples/page/service-explorer/data/service.json +276 -0
  186. package/src/skills/sixb-artifacts/examples/page/service-explorer/index.html +549 -0
  187. package/src/skills/sixb-artifacts/examples/sheet/overdue-invoices/queries/overdue.json +13 -0
  188. package/src/skills/sixb-artifacts/examples/sheet/overdue-invoices/workbook.json +30 -0
  189. package/src/skills/sixb-artifacts/examples/sheet/parts-inventory/sheets/Inventory.csv +13 -0
  190. package/src/skills/sixb-artifacts/examples/sheet/parts-inventory/sheets/Spend.csv +6 -0
  191. package/src/skills/sixb-artifacts/examples/sheet/parts-inventory/workbook.json +47 -0
  192. package/src/skills/sixb-artifacts/examples/sheet/service-metrics/sheets/Quarters.csv +5 -0
  193. package/src/skills/sixb-artifacts/examples/sheet/service-metrics/sheets/Regions.csv +5 -0
  194. package/src/skills/sixb-artifacts/examples/sheet/service-metrics/workbook.json +78 -0
  195. package/src/skills/sixb-artifacts/examples/slides/launch-plan/index.html +63 -0
  196. package/src/skills/sixb-artifacts/examples/slides/q3-review/index.html +133 -0
  197. package/src/skills/sixb-artifacts/file.md +17 -0
  198. package/src/skills/sixb-artifacts/page.md +215 -0
  199. package/src/skills/sixb-artifacts/queries.md +66 -0
  200. package/src/skills/sixb-artifacts/references.md +68 -0
  201. package/src/skills/sixb-artifacts/sheet.md +223 -0
  202. package/src/skills/sixb-artifacts/slides.md +137 -0
  203. package/src/skills/sixb-memory/SKILL.md +68 -0
  204. package/src/skills/text-assets.d.ts +25 -0
  205. package/src/subagent-continuation.ts +51 -0
  206. package/src/subagent-inbox.ts +101 -0
  207. package/src/subagent-tools.ts +1609 -0
  208. package/src/thread-context.ts +25 -0
  209. package/src/tools/attachments.ts +28 -0
  210. package/src/tools/bash.ts +217 -0
  211. package/src/tools/model-spec.ts +22 -0
  212. package/src/tools/read.ts +262 -0
  213. package/src/tools/result-media.ts +147 -0
  214. package/src/tools/result-output.ts +44 -0
  215. package/src/tools/tool-files.ts +204 -0
  216. package/src/tools/view-file.ts +155 -0
  217. package/src/turn-runtime.ts +33 -0
  218. package/src/types.ts +79 -0
  219. package/src/workflow-input-attachments.ts +140 -0
@@ -0,0 +1,282 @@
1
+ import { type AgentReasoning, type LanguageModelRef, type LanguageModelTier } from "@sixb/core";
2
+ import { type AgentChildApprovalAwaiting, type AgentRunDelegation, type AgentRunSession } from "@sixb/core/internal/agents";
3
+ import { type ModelTool } from "@sixb/core/models";
4
+ import type { ConversationAgentRunRecord, SubagentRunRecord } from "@sixb/core/storage";
5
+ import { type InstalledChildFile } from "./child-files";
6
+ import { type QuestionRef } from "./child-questions";
7
+ import { FamilyMailbox } from "./family-mailbox";
8
+ import type { TurnChildren } from "./run-agent-turn";
9
+ import type { AgentRunFiles, AgentRunSettings } from "./types";
10
+ /**
11
+ * How long a wait for children goes without reading their runs when nothing woke it. A child's
12
+ * question and its end wake it at once, through the turn's mailbox; this bounds an end recorded
13
+ * outside the runner, which nothing here hears: an API cancel of a child still queued, or a repair
14
+ * pass ending one whose own end could not be recorded. Five seconds keeps such a wait short beside
15
+ * the minutes a child works, and a wait reads storage 12 times a minute.
16
+ */
17
+ export declare const CHILD_WAIT_RECHECK_MS = 5000;
18
+ /**
19
+ * How often a wait reads a run another turn's mailbox hears, which nothing wakes it for: a child
20
+ * of an earlier turn, or of an earlier attempt of this resume, still stopping. Both are rare and
21
+ * short, so a short poll costs little.
22
+ */
23
+ export declare const OTHER_TURN_RECHECK_MS = 250;
24
+ export interface SpawnSubagentInput {
25
+ readonly key: string;
26
+ readonly task: string;
27
+ readonly model?: LanguageModelRef | LanguageModelTier;
28
+ readonly reasoning?: AgentReasoning;
29
+ /** Files and directories in the parent's sandbox, copied into the child's at the same paths. */
30
+ readonly files?: readonly string[];
31
+ }
32
+ export interface SpawnSubagentOutput {
33
+ readonly runId: string;
34
+ readonly status: SubagentRunRecord["status"];
35
+ readonly model: LanguageModelRef;
36
+ }
37
+ export interface MessageSubagentInput {
38
+ readonly key: string;
39
+ readonly text: string;
40
+ }
41
+ export interface MessageSubagentOutput {
42
+ readonly runId: string;
43
+ readonly status: "queued" | "running";
44
+ /**
45
+ * When the child reads it: before its first step while it is queued, else before its next.
46
+ * `answer`: it answers the question the child waits on, now or, once it continues, first.
47
+ */
48
+ readonly delivery: "first-step" | "next-step" | "answer";
49
+ /** The child of an earlier turn, paused on its question, that this answer continues. */
50
+ readonly continues?: string;
51
+ }
52
+ /** A message the parent sent a child this turn. */
53
+ interface SentMessage {
54
+ readonly id: string;
55
+ readonly text: string;
56
+ }
57
+ export interface WaitForSubagentsInput {
58
+ readonly runIds: readonly string[];
59
+ }
60
+ export interface WaitedSubagentResult {
61
+ readonly runId: string;
62
+ /**
63
+ * `queued` or `running`: the turn is about to end, so the Agent answers without it.
64
+ * `awaiting_approval`: it paused on calls that wait for the user, and continues once they decide,
65
+ * unless a new message sets the calls aside or the turn is stopped instead.
66
+ */
67
+ readonly status: SubagentRunRecord["status"] | "awaiting_approval" | "awaiting_answer";
68
+ readonly text?: string;
69
+ /** The question it waits on: answer it with `message_agent` and its key. */
70
+ readonly question?: QuestionRef;
71
+ readonly error?: {
72
+ readonly code: string;
73
+ readonly message: string;
74
+ };
75
+ /** Calls it made that wait for the user's approval. */
76
+ readonly awaitingApproval?: readonly AgentChildApprovalAwaiting[];
77
+ /**
78
+ * What it wrote under `out/`, by path there, and where each is in the parent's sandbox this
79
+ * turn. The first result that lists them holds them as files, which later turns find in
80
+ * `$SIXB_ATTACHMENTS` by their `logicalPath`, `<key>/<path>`.
81
+ */
82
+ readonly files?: readonly {
83
+ readonly path: string;
84
+ readonly sandboxPath: string;
85
+ readonly sizeBytes: number;
86
+ readonly mediaType?: string;
87
+ }[];
88
+ /** Why its files are not listed: they did not come back, could not be copied, or wait. */
89
+ readonly filesNote?: string;
90
+ /** What this turn sent it that it has not read: a paused child reads it if it continues. */
91
+ readonly unread?: readonly SentMessage[];
92
+ /**
93
+ * What it answered before a message of yours came, which its `text`, written after, replaces.
94
+ * Set when it answered again.
95
+ */
96
+ readonly earlierAnswer?: string;
97
+ /** Why its `text` does not account for your last message, when it did not answer again. */
98
+ readonly answerNote?: string;
99
+ }
100
+ /** A question a child waits on, with the key to answer it by. */
101
+ export interface WaitedQuestion extends QuestionRef {
102
+ readonly key: string;
103
+ readonly runId: string;
104
+ }
105
+ export interface WaitForSubagentsOutput {
106
+ readonly results: readonly WaitedSubagentResult[];
107
+ /** Every question a child of this turn waits on: `wait_agent` returns as soon as one comes. */
108
+ readonly questions?: readonly WaitedQuestion[];
109
+ /** The files no earlier result held, in the order of `results`. */
110
+ readonly files: readonly InstalledChildFile[];
111
+ /** Why what the children published is not all in `$SIXB_ARTIFACTS`. */
112
+ readonly artifactsError?: string;
113
+ }
114
+ /** What a turn offers the children it spawns. */
115
+ export interface TurnDelegation {
116
+ /** The project's language models, from the turn's plan. */
117
+ readonly models: AgentRunDelegation;
118
+ /** The project tools each child gets. */
119
+ readonly toolNames: readonly string[];
120
+ }
121
+ /** Run-scoped boundary used by the parent Agent's framework-owned delegation tools. */
122
+ export declare class SubagentCoordinator {
123
+ #private;
124
+ /** What the turn offers its children: the project's language models, and its tools. */
125
+ private readonly delegation;
126
+ private readonly context;
127
+ private readonly parentRun;
128
+ /** The turn's session, through which it reaches its children's runs. */
129
+ private readonly session;
130
+ /**
131
+ * Run a child this turn spawned or continues, in the turn's own runner, on the turn's mailbox:
132
+ * it claims the child's run, opens its session and environment, and records its fate.
133
+ * Starting a run already running is a no-op.
134
+ */
135
+ private readonly startChild;
136
+ private readonly models;
137
+ constructor(
138
+ /** What the turn offers its children: the project's language models, and its tools. */
139
+ delegation: TurnDelegation, context: AgentRunSettings, parentRun: ConversationAgentRunRecord,
140
+ /** The turn's session, through which it reaches its children's runs. */
141
+ session: AgentRunSession,
142
+ /**
143
+ * Run a child this turn spawned or continues, in the turn's own runner, on the turn's mailbox:
144
+ * it claims the child's run, opens its session and environment, and records its fate.
145
+ * Starting a run already running is a no-op.
146
+ */
147
+ startChild: (run: SubagentRunRecord, family: FamilyMailbox) => void);
148
+ /** The turn ended: it sends its children nothing more. */
149
+ close(): void;
150
+ /**
151
+ * How the turn hears its children's questions: those of earlier turns' children still paused on
152
+ * one, read after the conversation; those it has not read, before its answer ends it; and the
153
+ * pause, before its end, of each child still waiting on one. And how a pausing turn waits for
154
+ * those still at work.
155
+ */
156
+ turnChildren(): Promise<TurnChildren>;
157
+ /** The parent's environment, started after its tools are defined and before any of them runs. */
158
+ attach(runFiles: AgentRunFiles): void;
159
+ /**
160
+ * When this turn resumes a paused one, continue each child that paused on its held calls: the
161
+ * next run of its thread, under this turn and the same key, with the paused child's model, task
162
+ * and files, and this turn's mode. The outcomes of its calls start the run. Admitting
163
+ * it again finds it, so a retry of this turn, under its own id, admits its own.
164
+ */
165
+ continuePausedChildren(signal: AbortSignal): Promise<void>;
166
+ /**
167
+ * Remove from a paused child's thread what the runs after its pause did under an earlier attempt
168
+ * of this resume, which failed: this turn continues the paused child again, as a retried turn
169
+ * replays from its trigger. A run still stopping is waited for: its lease ends it if nothing else
170
+ * does.
171
+ */
172
+ private clearDeadAttempts;
173
+ /**
174
+ * The children this turn continues: those its trigger, a resume, reported as continuing, as the
175
+ * model reads it. The approvals, not the message, say which calls are the child's and that this
176
+ * message reported them, and the child must still be paused on them.
177
+ */
178
+ private pausedChildrenToContinue;
179
+ createTools(): Promise<readonly ModelTool[]>;
180
+ /**
181
+ * Send a child a message, through the turn's mailbox. Its id names this turn, the model call and
182
+ * the tool call in it, so a replay of the call is the same message and the child reads it once,
183
+ * while two calls never share one, whatever ids the provider gives its tool calls.
184
+ */
185
+ message(input: MessageSubagentInput, callId: string, signal: AbortSignal): Promise<MessageSubagentOutput>;
186
+ /** The latest child under `key` of this conversation's turns, this one's included. */
187
+ private latestChildUnder;
188
+ /**
189
+ * The child paused on its question that a message under `key` would continue: the latest run of
190
+ * the latest thread under the key, or, past the continuations of it that failed or were stopped,
191
+ * the run they continued, so their failure does not hide the question. A later spawn under the
192
+ * key replaces it.
193
+ */
194
+ private pausedOnQuestion;
195
+ /** Whether a continuation went on with its parent's answer, as its trigger says. */
196
+ private continuesAfterAnswer;
197
+ private subagentRun;
198
+ /**
199
+ * The children of this conversation still paused on their question, each with it: one indexed
200
+ * read, which finds none in a conversation that has none, then one per key that has some.
201
+ */
202
+ waitingQuestions(): Promise<readonly WaitedQuestion[]>;
203
+ /**
204
+ * Continue a child paused on its question, as a child of this turn under the same key, with this
205
+ * message as the answer it reads first. Admissions go one at a time, so a second answer in the
206
+ * same step finds the first one's continuation and is refused.
207
+ */
208
+ private answerPaused;
209
+ /**
210
+ * The question a child paused on, from its thread: the last message of the run that paused, its
211
+ * work since its last delivery. Only one `awaiting_answer` has one.
212
+ */
213
+ private deferredQuestionOf;
214
+ /**
215
+ * The questions of the turn's children still at work that the model has not read, marked read:
216
+ * its answer would otherwise end the turn without them.
217
+ */
218
+ unreadQuestions(): Promise<readonly WaitedQuestion[]>;
219
+ /**
220
+ * Before the turn records its end, while it still runs: tell each child still waiting on its
221
+ * question that the turn ends without an answer, then wait for each to pause on it. The turn's end cancels the children still at work, so a child it told and that has not
222
+ * paused yet would be stopped; while the turn runs, the repair pass leaves its children alone.
223
+ */
224
+ deferOpenQuestions(signal: AbortSignal): Promise<void>;
225
+ /**
226
+ * Wait until none of the turn's children is queued or running: a pausing turn's end cancels those
227
+ * still at work, and one that holds a call pauses by itself meanwhile.
228
+ */
229
+ settleChildren(signal: AbortSignal): Promise<void>;
230
+ /** The open questions of the turn's children still at work, each with the child's key. */
231
+ private askingChildren;
232
+ spawn(input: SpawnSubagentInput, signal: AbortSignal): Promise<SpawnSubagentOutput>;
233
+ private admitInTurn;
234
+ /**
235
+ * What admission will answer, read before the files the child is handed: the child already
236
+ * spawned with this key, else nothing once checked that the turn may spawn another.
237
+ */
238
+ private admissionOf;
239
+ /**
240
+ * The run of this turn that continues `paused` in its thread: its model, task and files, this
241
+ * turn's mode, and a trigger of what it goes on with (the outcomes of its calls, or
242
+ * its parent's answer), what came back to its sandbox and when it continues.
243
+ */
244
+ private continuationOf;
245
+ /** A child asks no less than its turn, dates as its requester does, and ends with the turn. */
246
+ private childSpec;
247
+ /**
248
+ * Admit a child of this turn. A spawned child works in a thread of its own, which starts with its
249
+ * task and its files; a continuation goes into its thread with the outcomes it continues with.
250
+ */
251
+ private admit;
252
+ wait(input: WaitForSubagentsInput, signal: AbortSignal): Promise<WaitForSubagentsOutput>;
253
+ /**
254
+ * What became of what this turn sent an ended child, from its thread, which holds each message
255
+ * it read: those it did not read, and, when one came as it answered, the answer it gave before.
256
+ * A failed child's failure is what the parent acts on.
257
+ */
258
+ private messagesTo;
259
+ /**
260
+ * The run a child of an earlier turn is waited for as: its thread's latest, the one that continues
261
+ * it when this turn resumes its pause; else `runId` itself.
262
+ */
263
+ private continuedChildId;
264
+ /** Which parents of these children are earlier turns of this turn's conversation. */
265
+ private earlierTurnsOf;
266
+ /**
267
+ * Copy what each finished child wrote under `out/` into the parent's sandbox, once, and install
268
+ * what the children published in its `$SIXB_ARTIFACTS`, as the parent's own. A result holds at
269
+ * most the attachment limits of new files, a child's whole or not at all; a child that does not
270
+ * fit, or whose files cannot be copied, says so, and its files come with a later wait.
271
+ */
272
+ private deliverFiles;
273
+ private runFiles;
274
+ private resolveModel;
275
+ }
276
+ /**
277
+ * Built from each model's configured definition, never from its provider catalog: the guide is in
278
+ * every turn's tools, so it stays the same for the process and catalog I/O cannot fail a turn.
279
+ */
280
+ export declare function renderSubagentModelGuide(models: AgentRunDelegation): string;
281
+ export {};
282
+ //# sourceMappingURL=subagent-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subagent-tools.d.ts","sourceRoot":"","sources":["../src/subagent-tools.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,cAAc,EAGnB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,KAAK,0BAA0B,EAG/B,KAAK,kBAAkB,EAEvB,KAAK,eAAe,EAQrB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EAML,KAAK,SAAS,EACf,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EACV,0BAA0B,EAE1B,iBAAiB,EAElB,MAAM,oBAAoB,CAAA;AAK3B,OAAO,EAGL,KAAK,kBAAkB,EAIxB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAsB,KAAK,WAAW,EAAwB,MAAM,mBAAmB,CAAA;AAC9F,OAAO,EAAwB,aAAa,EA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C,sBAAsB,CAAC;IAwE9F;;;;OAIG;YACW,UAAU;IAuBxB;;;OAGG;YACW,gBAAgB;IAS9B,qFAAqF;YACvE,cAAc;IAoB5B;;;;;OAKG;YACW,YAAY;IAiF1B,OAAO,CAAC,QAAQ;IAOhB,OAAO,CAAC,YAAY;CAuBrB;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CA0C3E"}
@@ -0,0 +1,12 @@
1
+ import { type AgentThreadModelContextMessage, type AgentTurnHistory } from "@sixb/core/internal/agents";
2
+ import type { AgentContextCheckpointRecord, AgentMessageRecord } from "@sixb/core/storage";
3
+ export interface LoadedAgentThreadModelContext {
4
+ readonly checkpoint: AgentContextCheckpointRecord | null;
5
+ readonly retainedMessages: readonly AgentMessageRecord[];
6
+ readonly modelMessages: readonly AgentThreadModelContextMessage[];
7
+ /** The history it was built from, as the session answered it. */
8
+ readonly history: AgentTurnHistory;
9
+ }
10
+ /** The retained tail with its checkpoint, projected for the model. */
11
+ export declare function agentThreadModelContext(history: AgentTurnHistory): LoadedAgentThreadModelContext;
12
+ //# sourceMappingURL=thread-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thread-context.d.ts","sourceRoot":"","sources":["../src/thread-context.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,8BAA8B,EACnC,KAAK,gBAAgB,EAEtB,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAE1F,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,UAAU,EAAE,4BAA4B,GAAG,IAAI,CAAA;IACxD,QAAQ,CAAC,gBAAgB,EAAE,SAAS,kBAAkB,EAAE,CAAA;IACxD,QAAQ,CAAC,aAAa,EAAE,SAAS,8BAA8B,EAAE,CAAA;IACjE,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAA;CACnC;AAED,sEAAsE;AACtE,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,gBAAgB,GAAG,6BAA6B,CAQhG"}
@@ -0,0 +1,11 @@
1
+ import { type AgentToolAttachments } from "@sixb/core";
2
+ import type { AgentRunFileStore } from "@sixb/core/internal/agents";
3
+ import type { WorkflowIOSnapshot } from "@sixb/core/internal/workflows";
4
+ type AttachmentBlobStorage = Pick<AgentRunFileStore, "stat" | "open">;
5
+ /** A workflow AI task's attachments: the files of its input, by their path such as `input.pdf`. */
6
+ export declare function workflowInputToolAttachments(input: {
7
+ readonly input: WorkflowIOSnapshot;
8
+ readonly blobStorage: AttachmentBlobStorage;
9
+ }): AgentToolAttachments;
10
+ export {};
11
+ //# sourceMappingURL=attachments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachments.d.ts","sourceRoot":"","sources":["../../src/tools/attachments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAwB,MAAM,YAAY,CAAA;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAEnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAGvE,KAAK,qBAAqB,GAAG,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAAC,CAAA;AAErE,mGAAmG;AACnG,wBAAgB,4BAA4B,CAAC,KAAK,EAAE;IAClD,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAA;IAClC,QAAQ,CAAC,WAAW,EAAE,qBAAqB,CAAA;CAC5C,GAAG,oBAAoB,CASvB"}
@@ -0,0 +1,60 @@
1
+ import type { CommandResult } from "@sixb/core";
2
+ import type { ModelTool } from "@sixb/core/models";
3
+ import type { AgentSandboxHandle } from "../sandbox-handle";
4
+ export declare const BASH_TOOL_SPEC: {
5
+ readonly name: "bash";
6
+ readonly description: "Run a Bash command in the agent run sandbox.";
7
+ readonly inputSchema: {
8
+ type: string;
9
+ properties: {
10
+ command: {
11
+ type: string;
12
+ };
13
+ cwd: {
14
+ type: string;
15
+ description: string;
16
+ };
17
+ timeoutMs: {
18
+ type: string;
19
+ };
20
+ };
21
+ required: string[];
22
+ additionalProperties: false;
23
+ };
24
+ };
25
+ interface BashToolInput {
26
+ readonly command: string;
27
+ readonly cwd?: string;
28
+ readonly timeoutMs?: number;
29
+ }
30
+ export interface BashToolOutput extends CommandResult {
31
+ readonly stdoutTruncated: boolean;
32
+ readonly stderrTruncated: boolean;
33
+ }
34
+ /**
35
+ * Build the bash tool from a resolver that yields the sandbox on demand. The
36
+ * resolver is awaited on the first command, not at tool-construction time, so
37
+ * sandbox creation can run concurrently with the model's first response instead
38
+ * of blocking the turn. A resolver rejection surfaces as a failed command.
39
+ */
40
+ export declare function createBashTool(resolveSandbox: () => Promise<AgentSandboxHandle>): ModelTool<BashToolInput>;
41
+ interface TruncateResult {
42
+ readonly text: string;
43
+ readonly truncated: boolean;
44
+ }
45
+ /**
46
+ * Fit a command's stdout under `maxChars`, preferring to keep it valid JSON.
47
+ *
48
+ * The agent's commands (and any `jq` pretty-printing it adds) mostly produce JSON API responses. We
49
+ * compress in the order the field recommends — reformat first, drop data only if we must:
50
+ * 1. Under budget already → leave it untouched.
51
+ * 2. Valid JSON → re-serialize compact; whitespace alone often brings it under budget with zero
52
+ * data loss (compact JSON is also fewer tokens and no worse for model comprehension).
53
+ * 3. Still oversized JSON array → keep the largest whole-element prefix that fits, as a bare array
54
+ * (same shape the caller expects, still valid JSON, just fewer rows).
55
+ * 4. Oversized JSON object → return a valid JSON preview that tells the agent to narrow the call.
56
+ * 5. Oversized non-JSON → middle-truncate the text.
57
+ */
58
+ export declare function compressStdout(text: string, maxChars: number): TruncateResult;
59
+ export {};
60
+ //# sourceMappingURL=bash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../src/tools/bash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,KAAK,EAAyB,SAAS,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAM3D,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;CAiBjB,CAAA;AAEV,UAAU,aAAa;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;IACjC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;CAClC;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,cAAc,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,GAChD,SAAS,CAAC,aAAa,CAAC,CAgB1B;AAkDD,UAAU,cAAc;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAC5B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,CAe7E"}
@@ -0,0 +1,4 @@
1
+ import type { AgentToolSpec } from "@sixb/core/internal/agents";
2
+ /** Describe exactly the tools a conversational model receives, without starting its sandbox. */
3
+ export declare function agentModelToolSpecs(projectTools: readonly AgentToolSpec[]): readonly AgentToolSpec[];
4
+ //# sourceMappingURL=model-spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-spec.d.ts","sourceRoot":"","sources":["../../src/tools/model-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAS/D,gGAAgG;AAChG,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,SAAS,aAAa,EAAE,GACrC,SAAS,aAAa,EAAE,CAS1B"}
@@ -0,0 +1,43 @@
1
+ import type { ModelTool } from "@sixb/core/models";
2
+ import { type AgentSandboxHandle } from "../sandbox-handle";
3
+ export declare const READ_TOOL_SPEC: {
4
+ readonly name: "read";
5
+ readonly description: "Read a UTF-8 text file relative to the sandbox working directory. Returns at most 2,000 lines or 50 KiB and includes nextOffset when more content remains. Prefer this over bash for reading files.";
6
+ readonly inputSchema: {
7
+ type: string;
8
+ properties: {
9
+ path: {
10
+ type: string;
11
+ description: string;
12
+ };
13
+ offset: {
14
+ type: string;
15
+ minimum: number;
16
+ description: string;
17
+ };
18
+ limit: {
19
+ type: string;
20
+ minimum: number;
21
+ description: string;
22
+ };
23
+ };
24
+ required: string[];
25
+ additionalProperties: false;
26
+ };
27
+ };
28
+ export interface ReadToolInput {
29
+ readonly path: string;
30
+ readonly offset?: number;
31
+ readonly limit?: number;
32
+ }
33
+ export interface ReadToolOutput {
34
+ readonly path: string;
35
+ readonly content: string;
36
+ readonly startLine: number;
37
+ readonly endLine: number;
38
+ readonly truncated: boolean;
39
+ readonly nextOffset?: number;
40
+ }
41
+ /** Build the bounded UTF-8 file reader from the run's lazy sandbox resolver. */
42
+ export declare function createReadTool(resolveSandbox: () => Promise<AgentSandboxHandle>): ModelTool<ReadToolInput>;
43
+ //# sourceMappingURL=read.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/tools/read.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAyB,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAGzE,OAAO,EAAE,KAAK,kBAAkB,EAAe,MAAM,mBAAmB,CAAA;AAOxE,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;CAsBjB,CAAA;AAEV,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAC7B;AAED,gFAAgF;AAChF,wBAAgB,cAAc,CAC5B,cAAc,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,GAChD,SAAS,CAAC,aAAa,CAAC,CAqD1B"}
@@ -0,0 +1,22 @@
1
+ import type { FileRef, JsonValue } from "@sixb/core";
2
+ import type { AgentRunFileStore, PrepareModelStepInput, PrepareModelStepResult } from "@sixb/core/internal/agents";
3
+ import { prepareAgentToolFileProjection } from "../attachments";
4
+ import { type AgentToolModelOutput } from "./result-output";
5
+ /** Move tool-created images into an ephemeral user message without changing their durable result. */
6
+ export declare class AgentToolResultMediaBridge {
7
+ #private;
8
+ private readonly input;
9
+ constructor(input: {
10
+ readonly blobStorage: AgentRunFileStore;
11
+ readonly sandboxPathForFileRef?: (fileRef: FileRef) => string | undefined;
12
+ /** Test seam; production uses the bounded attachment projector. */
13
+ readonly projectFile?: typeof prepareAgentToolFileProjection;
14
+ });
15
+ toModelOutput(input: {
16
+ readonly output: JsonValue;
17
+ readonly signal: AbortSignal;
18
+ readonly toolCallId: string;
19
+ }): Promise<AgentToolModelOutput>;
20
+ readonly prepareStep: ({ messages, model, signal: stepSignal, }: PrepareModelStepInput) => Promise<PrepareModelStepResult | undefined>;
21
+ }
22
+ //# sourceMappingURL=result-media.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result-media.d.ts","sourceRoot":"","sources":["../../src/tools/result-media.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,KAAK,EACV,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EAA6B,8BAA8B,EAAE,MAAM,gBAAgB,CAAA;AAE1F,OAAO,EAAE,KAAK,oBAAoB,EAAgC,MAAM,iBAAiB,CAAA;AAWzF,qGAAqG;AACrG,qBAAa,0BAA0B;;IAInC,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE;QACtB,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAA;QACvC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,CAAA;QACzE,mEAAmE;QACnE,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,8BAA8B,CAAA;KAC7D;IAGG,aAAa,CAAC,KAAK,EAAE;QACzB,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAA;QAC1B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;QAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;KAC5B,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA0BjC,QAAQ,CAAC,WAAW,GAAU,0CAI3B,qBAAqB,KAAG,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC,CA4DrE;CACF"}
@@ -0,0 +1,18 @@
1
+ import type { FileRef, JsonValue } from "@sixb/core";
2
+ import { type AgentRunFileStore } from "@sixb/core/internal/agents";
3
+ export type AgentToolModelOutput = {
4
+ readonly type: "text";
5
+ readonly value: string;
6
+ } | {
7
+ readonly type: "json";
8
+ readonly value: JsonValue;
9
+ };
10
+ /** Convert a durable Sixb tool result into bounded, provider-safe model-facing output. */
11
+ export declare function agentToolResultToModelOutput(input: {
12
+ readonly output: JsonValue;
13
+ readonly blobStorage: AgentRunFileStore;
14
+ readonly signal?: AbortSignal;
15
+ readonly sandboxPathForFileRef?: (fileRef: FileRef) => string | undefined;
16
+ readonly imageOmissionNote?: string;
17
+ }): Promise<AgentToolModelOutput>;
18
+ //# sourceMappingURL=result-output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result-output.d.ts","sourceRoot":"","sources":["../../src/tools/result-output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,EAAE,KAAK,iBAAiB,EAAqB,MAAM,4BAA4B,CAAA;AAGtF,MAAM,MAAM,oBAAoB,GAC5B;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjD;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAA;AAExD,0FAA0F;AAC1F,wBAAsB,4BAA4B,CAAC,KAAK,EAAE;IACxD,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAA;IAC1B,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAA;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;IAC7B,QAAQ,CAAC,qBAAqB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,CAAA;IACzE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CACpC,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA4BhC"}
@@ -0,0 +1,59 @@
1
+ import type { AgentToolFile, AgentToolFiles } from "@sixb/core";
2
+ import { AGENT_FILE_MAX_BYTES, type AgentRunFileStore, type AgentToolCallFile } from "@sixb/core/internal/agents";
3
+ import type { AgentSandboxHandle } from "../sandbox-handle";
4
+ export { AGENT_FILE_MAX_BYTES };
5
+ interface CreateAgentToolFilesInput {
6
+ readonly toolName: string;
7
+ readonly toolCallId: string;
8
+ readonly signal: AbortSignal;
9
+ readonly blobStorage: AgentRunFileStore;
10
+ readonly resolveSandbox: () => Promise<AgentSandboxHandle>;
11
+ readonly onPublished?: (file: AgentToolFile) => void;
12
+ /** Shared across every tool call in one run so parallel publishers cannot oversubscribe it. */
13
+ readonly budget?: AgentFileBudget;
14
+ /** Test seam; production allows {@link AGENT_FILE_MAX_BYTES}. */
15
+ readonly fileMaxBytes?: number;
16
+ }
17
+ /** Atomic byte budget shared by every file publisher in one agent run. */
18
+ export declare class AgentFileBudget {
19
+ #private;
20
+ readonly maxBytes: number;
21
+ constructor(maxBytes?: number);
22
+ get reservedBytes(): number;
23
+ reserve(bytes: number, toolName: string): AgentFileReservation;
24
+ add(bytes: number, toolName: string): void;
25
+ release(bytes: number): void;
26
+ /** Counts content's bytes when no reservation holds the same digest yet, and nothing after. */
27
+ holdContent(digest: string, sizeBytes: number, toolName: string): void;
28
+ releaseContent(digest: string): void;
29
+ }
30
+ declare class AgentFileReservation {
31
+ #private;
32
+ private readonly budget;
33
+ private readonly toolName;
34
+ constructor(budget: AgentFileBudget, bytes: number, toolName: string);
35
+ add(bytes: number): void;
36
+ /** Reserves bytes whose SHA-256 is `digest`, unless the run already counts the same content. */
37
+ addContent(digest: string, sizeBytes: number): void;
38
+ release(): void;
39
+ }
40
+ /**
41
+ * The file publisher of one of the harness's own tool calls: each file is stored as a project
42
+ * tool's is, counted against the run's budget, and copied into the sandbox at its path.
43
+ */
44
+ export declare function createAgentToolFiles(input: CreateAgentToolFilesInput): AgentToolFiles;
45
+ /**
46
+ * Copy the files a project tool stored into the sandbox, at the paths it was told, each counted
47
+ * against the run's budget as the harness's own tools' files are. The call stored no more than the
48
+ * budget had left when it started.
49
+ */
50
+ export declare function installAgentToolFiles(input: {
51
+ readonly toolName: string;
52
+ readonly files: readonly AgentToolCallFile[];
53
+ readonly blobStorage: AgentRunFileStore;
54
+ readonly resolveSandbox: () => Promise<AgentSandboxHandle>;
55
+ readonly budget: AgentFileBudget;
56
+ readonly signal: AbortSignal;
57
+ readonly onPublished?: (file: AgentToolFile) => void;
58
+ }): Promise<void>;
59
+ //# sourceMappingURL=tool-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-files.d.ts","sourceRoot":"","sources":["../../src/tools/tool-files.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAyB,cAAc,EAAE,MAAM,YAAY,CAAA;AAEtF,OAAO,EACL,oBAAoB,EACpB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EAEvB,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,oBAAoB,EAAE,CAAA;AAG/B,UAAU,yBAAyB;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;IAC5B,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAA;IACvC,QAAQ,CAAC,cAAc,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAAA;IAC1D,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAA;IACpD,+FAA+F;IAC/F,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAA;IACjC,iEAAiE;IACjE,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAC/B;AAED,0EAA0E;AAC1E,qBAAa,eAAe;;IAQd,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,SAAwB;IAMrD,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,oBAAoB;IAQ9D,GAAG,CAAC,KAAK,EAAE,MAAM,EA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ModelTool } from "@sixb/core/models";
3
+ import type { PreparedAgentAttachmentContext } from "../attachments";
4
+ import type { AgentSandboxFileRegistry } from "../sandbox-file-registry";
5
+ import type { AgentSandboxHandle } from "../sandbox-handle";
6
+ import type { AgentToolModelOutput } from "./result-output";
7
+ export declare const VIEW_FILE_TOOL_SPEC: {
8
+ readonly name: "view_file";
9
+ readonly description: "Inspect a file in the current run sandbox. Use this for historical attachments and files created by bash. Paths must stay inside the working directory or the run's context directory. Images are prepared for visual input when supported; other formats return bounded text or metadata.";
10
+ readonly inputSchema: {
11
+ type: string;
12
+ properties: {
13
+ path: {
14
+ type: string;
15
+ minLength: number;
16
+ };
17
+ };
18
+ required: string[];
19
+ additionalProperties: false;
20
+ };
21
+ };
22
+ interface ViewFileInput {
23
+ readonly path: string;
24
+ }
25
+ export declare function createViewFileTool(input: {
26
+ readonly resolveSandbox: () => Promise<AgentSandboxHandle>;
27
+ readonly attachments: PreparedAgentAttachmentContext;
28
+ readonly registry: AgentSandboxFileRegistry;
29
+ readonly filesForToolCall: (options: {
30
+ readonly toolCallId: string;
31
+ readonly signal: AbortSignal;
32
+ }) => AgentToolFiles;
33
+ readonly toolResultToModelOutput: (input: {
34
+ readonly output: JsonValue;
35
+ readonly signal: AbortSignal;
36
+ readonly toolCallId: string;
37
+ }) => AgentToolModelOutput | Promise<AgentToolModelOutput>;
38
+ }): ModelTool<ViewFileInput>;
39
+ export {};
40
+ //# sourceMappingURL=view-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view-file.d.ts","sourceRoot":"","sources":["../../src/tools/view-file.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAW,SAAS,EAAE,MAAM,YAAY,CAAA;AAGpE,OAAO,KAAK,EAAc,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC9D,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,gBAAgB,CAAA;AAEpE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AAExE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAK3D,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;CAUtB,CAAA;AAEV,UAAU,aAAa;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IACxC,QAAQ,CAAC,cAAc,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAAA;IAC1D,QAAQ,CAAC,WAAW,EAAE,8BAA8B,CAAA;IACpD,QAAQ,CAAC,QAAQ,EAAE,wBAAwB,CAAA;IAC3C,QAAQ,CAAC,gBAAgB,EAAE,CAAC,OAAO,EAAE;QACnC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;QAC3B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;KAC7B,KAAK,cAAc,CAAA;IACpB,QAAQ,CAAC,uBAAuB,EAAE,CAAC,KAAK,EAAE;QACxC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAA;QAC1B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;QAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;KAC5B,KAAK,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;CAC3D,GAAG,SAAS,CAAC,aAAa,CAAC,CAiD3B"}
@@ -0,0 +1,5 @@
1
+ // Written by scripts/build-package.ts, and published on purpose.
2
+ // Bun applies the nearest tsconfig paths map to every import it resolves, node_modules
3
+ // included. An empty map here keeps a consumer's aliases from sending a module in this
4
+ // directory back into a second copy of its own source.
5
+ { "compilerOptions": { "paths": {} } }
@@ -0,0 +1,19 @@
1
+ export interface AgentTurnRuntime {
2
+ /** Worker shutdown, queue-lease loss, and user cancellation. */
3
+ readonly sourceSignal: AbortSignal;
4
+ /** The run's signal: `sourceSignal`, and the run's end. */
5
+ readonly signal: AbortSignal;
6
+ /** Surface lost ownership or cancellation before another durable action. */
7
+ readonly assertCanContinue: () => void;
8
+ /** End the run: aborts `signal`, so a tool call that outlived it stops calling models. */
9
+ dispose(): void;
10
+ }
11
+ /**
12
+ * The run's signal, shared by its compaction and its answer. A run has no time or step limit: it
13
+ * ends when the model answers, when it is cancelled, or when its runner loses it. Its model records
14
+ * each call itself, so a call that could not be admitted or recorded fails where it was made.
15
+ */
16
+ export declare function createAgentTurnRuntime(input: {
17
+ readonly signal: AbortSignal;
18
+ }): AgentTurnRuntime;
19
+ //# sourceMappingURL=turn-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turn-runtime.d.ts","sourceRoot":"","sources":["../src/turn-runtime.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC/B,gEAAgE;IAChE,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAA;IAClC,2DAA2D;IAC3D,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;IAC5B,4EAA4E;IAC5E,QAAQ,CAAC,iBAAiB,EAAE,MAAM,IAAI,CAAA;IACtC,0FAA0F;IAC1F,OAAO,IAAI,IAAI,CAAA;CAChB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAAE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;CAAE,GAAG,gBAAgB,CAchG"}