@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,34 @@
1
+ import { type UserPrincipal } from "@sixb/core";
2
+ import type { AgentMessageRecord, AgentThreadRecord } from "@sixb/core/storage";
3
+ /** What the model reads of who writes in a conversation. Nothing of it is stored or shown. */
4
+ export interface ConversationAuthors {
5
+ /** Who takes part, for the newest user message only; absent in a one-person conversation. */
6
+ readonly section?: string;
7
+ /** The `<sixb_author>` closing each retained user message, by message id. */
8
+ readonly byMessageId: ReadonlyMap<string, string>;
9
+ }
10
+ /**
11
+ * A thread with the participants who can read it now: the people the model is told about, with
12
+ * their display names as the turn read them (`AgentTurnContext.readers` and `names`).
13
+ */
14
+ export interface ConversationReaders {
15
+ readonly thread: AgentThreadRecord;
16
+ readonly participants: readonly UserPrincipal[];
17
+ readonly names: Readonly<Record<string, string>>;
18
+ }
19
+ /**
20
+ * Who wrote each retained user message, when the thread has participants or several people wrote
21
+ * in it; nothing in a conversation its owner holds alone, so its messages do not change.
22
+ *
23
+ * Each message's author derives from stored data, so a turn replays the bytes the previous one
24
+ * sent. They change only when someone renames their account. The section naming who takes part
25
+ * rides on the newest user message: on the next turn only that message, the history's tail, loses
26
+ * it.
27
+ */
28
+ export declare function conversationAuthors(input: {
29
+ readonly conversation: ConversationReaders;
30
+ readonly messages: readonly AgentMessageRecord[];
31
+ }): ConversationAuthors;
32
+ /** Everything the authors add to the model input, for its token estimate. */
33
+ export declare function conversationAuthorsText(authors: ConversationAuthors): string;
34
+ //# sourceMappingURL=message-authors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-authors.d.ts","sourceRoot":"","sources":["../src/message-authors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,aAAa,EAAE,MAAM,YAAY,CAAA;AAChF,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAO/E,8FAA8F;AAC9F,MAAM,WAAW,mBAAmB;IAClC,6FAA6F;IAC7F,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,6EAA6E;IAC7E,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAClD;AAID;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAA;IAClC,QAAQ,CAAC,YAAY,EAAE,SAAS,aAAa,EAAE,CAAA;IAC/C,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CACjD;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IACzC,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAA;IAC1C,QAAQ,CAAC,QAAQ,EAAE,SAAS,kBAAkB,EAAE,CAAA;CACjD,GAAG,mBAAmB,CA+BtB;AAED,6EAA6E;AAC7E,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAE5E"}
@@ -0,0 +1,8 @@
1
+ import type { AgentTurnHistory } from "@sixb/core/internal/agents";
2
+ /**
3
+ * The `<sixb_current_time>` closing each retained user message: when it was sent, in the time zone
4
+ * of the run that answered it (the project's when that run captured none). Stored data only, so
5
+ * every later run replays the same bytes and the history stays a cacheable prefix.
6
+ */
7
+ export declare function userMessageTimes(history: AgentTurnHistory, projectTimeZone: string): ReadonlyMap<string, string>;
8
+ //# sourceMappingURL=message-times.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-times.d.ts","sourceRoot":"","sources":["../src/message-times.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAGlE;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,gBAAgB,EACzB,eAAe,EAAE,MAAM,GACtB,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAS7B"}
@@ -0,0 +1,55 @@
1
+ import type { AgentMessagePart, JsonValue } from "@sixb/core";
2
+ import { type AgentToolCall, type AgentToolCallFile, type AgentToolCallOptions, type AgentToolCallResult, type AgentToolSpec } from "@sixb/core/internal/agents";
3
+ import type { ModelAssistantPart, ModelStep, ModelTool } from "@sixb/core/models";
4
+ import type { AgentToolModelOutput } from "./tools/result-output";
5
+ export type AgentErrorDetails = {
6
+ readonly threadId: string;
7
+ readonly runId: string;
8
+ } | {
9
+ readonly parentRunId: string;
10
+ readonly runId: string;
11
+ } | {
12
+ readonly workflowId: string;
13
+ readonly agentStepId: string;
14
+ readonly runId: string;
15
+ } | {
16
+ readonly agentStepId: string;
17
+ readonly workflowId: string;
18
+ readonly workflowRunId: string;
19
+ readonly nodeRunId: string;
20
+ };
21
+ /** How a run calls a project tool: through its session, or for a workflow step in the worker. */
22
+ export type AgentToolCaller = (call: AgentToolCall, options: AgentToolCallOptions) => Promise<AgentToolCallResult>;
23
+ interface ProjectModelToolsInput {
24
+ readonly specs: readonly AgentToolSpec[];
25
+ readonly runId: string;
26
+ readonly callTool: AgentToolCaller;
27
+ /** The bytes the run's file budget has left, which a call's files may take. */
28
+ readonly fileBytesLeft: () => number;
29
+ /** Copy the files a call stored into the sandbox, before the model reads its output. */
30
+ readonly installFiles: (input: {
31
+ readonly toolName: string;
32
+ readonly files: readonly AgentToolCallFile[];
33
+ readonly signal: AbortSignal;
34
+ }) => Promise<void>;
35
+ readonly toolResultToModelOutput: (input: {
36
+ readonly output: JsonValue;
37
+ readonly signal: AbortSignal;
38
+ readonly toolCallId: string;
39
+ }) => AgentToolModelOutput | Promise<AgentToolModelOutput>;
40
+ readonly errorDetails?: AgentErrorDetails;
41
+ }
42
+ /**
43
+ * The project's tools as the model is offered them. A call runs where the project is, through
44
+ * `callTool`, which checks its input against the tool's schema; the files it stored are copied into
45
+ * the sandbox before the model reads its output.
46
+ */
47
+ export declare function projectModelTools(input: ProjectModelToolsInput): readonly ModelTool[];
48
+ /** Project validated model-loop steps into Sixb's durable trace contract. */
49
+ export declare function agentTraceFromModelSteps(steps: readonly ModelStep[], errorDetails?: AgentErrorDetails): readonly AgentMessagePart[];
50
+ /** Convert an aborted model loop, retaining only coherent content from its in-flight step. */
51
+ export declare function agentTraceFromPartialModelLoop(steps: readonly ModelStep[], partialContent: readonly ModelAssistantPart[], errorDetails?: AgentErrorDetails): readonly AgentMessagePart[];
52
+ /** Expose only failures that the tool author explicitly marked as safe for the model and storage. */
53
+ export declare function agentToolErrorText(error: unknown): string;
54
+ export {};
55
+ //# sourceMappingURL=model-adapters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-adapters.d.ts","sourceRoot":"","sources":["../src/model-adapters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE7D,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EAExB,KAAK,aAAa,EACnB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,KAAK,EACV,kBAAkB,EAClB,SAAS,EACT,SAAS,EAEV,MAAM,mBAAmB,CAAA;AAE1B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAEjE,MAAM,MAAM,iBAAiB,GACzB;IAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACxD;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACrF;IACE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAC3B,CAAA;AAEL,iGAAiG;AACjG,MAAM,MAAM,eAAe,GAAG,CAC5B,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,oBAAoB,KAC1B,O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E,CAO7B;AAqFD,qGAAqG;AACrG,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEzD"}
@@ -0,0 +1,16 @@
1
+ import type { LanguageModelTier } from "@sixb/core";
2
+ /**
3
+ * One language model on one line, as the prompt lists the models the Agent can ask or delegate
4
+ * to: under its tier, else as a list item, then its name, what the caller adds about it, and its
5
+ * description.
6
+ */
7
+ export declare function renderModelLine(input: {
8
+ readonly tier?: LanguageModelTier;
9
+ /** How the caller names the model, such as the reference a command takes. */
10
+ readonly reference: string;
11
+ readonly name?: string;
12
+ /** Written as given between the name and the description, such as `(default; tools)`. */
13
+ readonly details?: string;
14
+ readonly description?: string;
15
+ }): string;
16
+ //# sourceMappingURL=model-lines.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-lines.d.ts","sourceRoot":"","sources":["../src/model-lines.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE;IACrC,QAAQ,CAAC,IAAI,CAAC,EAAE,iBAAiB,CAAA;IACjC,6EAA6E;IAC7E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,yFAAyF;IACzF,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAC9B,GAAG,MAAM,CAOT"}
@@ -0,0 +1,15 @@
1
+ import type { AuthorizablePrincipal } from "@sixb/core";
2
+ /** Who an Agent run works for, as its prompt names them. */
3
+ export type AgentRequester = {
4
+ readonly type: "user";
5
+ readonly id: string;
6
+ readonly displayName?: string;
7
+ } | {
8
+ readonly type: "serviceAccount";
9
+ };
10
+ /**
11
+ * The requester of an Agent execution: the user, with their display name as the run read it when
12
+ * it started, or a service account. A renamed user is named correctly from the next run.
13
+ */
14
+ export declare function agentRequester(requestedBy: AuthorizablePrincipal | undefined, names: Readonly<Record<string, string>>): AgentRequester | undefined;
15
+ //# sourceMappingURL=requester.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requester.d.ts","sourceRoot":"","sources":["../src/requester.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAEvD,4DAA4D;AAC5D,MAAM,MAAM,cAAc,GACtB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7E;IAAE,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAA;AAEvC;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,qBAAqB,GAAG,SAAS,EAC9C,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACtC,cAAc,GAAG,SAAS,CAM5B"}
@@ -0,0 +1,63 @@
1
+ import { type AgentRunSession } from "@sixb/core/internal/agents";
2
+ import { type AgentRunRecord, type ConversationAgentRunRecord } from "@sixb/core/storage";
3
+ import type { ResolvedAgentExecutionPlan } from "./execution-plan";
4
+ import { type ConversationReaders } from "./message-authors";
5
+ import type { LoadedAgentThreadModelContext } from "./thread-context";
6
+ import { type AgentTurnRuntime } from "./turn-runtime";
7
+ import type { AgentTurnContext } from "./types";
8
+ export interface RunAgentTurnInput {
9
+ /** The worker's stable execution context (storage, tools and stream sink). */
10
+ readonly context: AgentTurnContext;
11
+ readonly plan: ResolvedAgentExecutionPlan;
12
+ /** The run this delivery reserved or reclaimed with its execution token. */
13
+ readonly run: ConversationAgentRunRecord;
14
+ /** The run's session: its finish, and every other write, are fenced by its execution token. */
15
+ readonly session: AgentRunSession;
16
+ /** The worker's shutdown signal. */
17
+ readonly signal: AbortSignal;
18
+ /**
19
+ * The worker's own stop, when `signal` also carries a user cancel. A turn it ends first is
20
+ * recorded with `finishReason: "interrupted"` so the user can resume it.
21
+ */
22
+ readonly stopSignal?: AbortSignal;
23
+ /** Shared with preflight when this turn performed compaction. */
24
+ readonly runtime?: AgentTurnRuntime;
25
+ /** The thread and who can read it now; without it the model is told nothing of its people. */
26
+ readonly conversation?: ConversationReaders;
27
+ /** The history the turn runs on: as it started, or as its compaction left it. */
28
+ readonly threadContext: LoadedAgentThreadModelContext;
29
+ /** What the turn's children ask it, and the work it waits for, when it can delegate. */
30
+ readonly children?: TurnChildren;
31
+ }
32
+ /**
33
+ * How a turn hears the questions its children ask, leaves them waiting when it ends, and waits for
34
+ * those still at work when it pauses.
35
+ */
36
+ export interface TurnChildren {
37
+ /** Read after the conversation: children of earlier turns still waiting on their question. */
38
+ readonly waiting?: string;
39
+ /** The questions the model has not read yet, read in one more step when it answers. */
40
+ unread(): Promise<string | undefined>;
41
+ /**
42
+ * Before the turn records its end: each child still waiting on its question pauses on it, and
43
+ * the turn waits until it has. Only then can its end cancel the others.
44
+ */
45
+ defer(signal: AbortSignal): Promise<void>;
46
+ /**
47
+ * Before a pausing turn records its end: wait until none of its children is at work. Its end
48
+ * cancels those still at work; one that holds a call pauses by itself.
49
+ */
50
+ settle(signal: AbortSignal): Promise<void>;
51
+ }
52
+ /** Drive one provider-neutral model/tool turn to completion and persist it. */
53
+ export declare function runAgentTurn(input: RunAgentTurnInput): Promise<AgentRunRecord>;
54
+ /**
55
+ * Whether the turn holds a call for its requester, as `runs.finish` checks before it pauses: one
56
+ * waiting, or decided and not reported to the model yet, its children's included.
57
+ */
58
+ /**
59
+ * Whether the worker's stop, rather than the user's, ended the turn. Whichever fired first wins:
60
+ * the combined turn signal carries the reason of the first source that aborted it.
61
+ */
62
+ export declare function stoppedByWorker(turnSignal: AbortSignal, stopSignal?: AbortSignal): boolean;
63
+ //# sourceMappingURL=run-agent-turn.d.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9F,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,uFAAuF;IACvF,MAAM,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IACrC;;;OAGG;IACH,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACzC;;;OAGG;IACH,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC3C;AAED,+EAA+E;AAC/E,wBAAsB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC,CAwMpF;AAED;;;GAGG;AAEH;;;GAGG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,WAAW,EAAE,UAAU,CAAC,EAAE,WAAW,GAAG,OAAO,CAE1F"}
@@ -0,0 +1,77 @@
1
+ import { type AgentRunSession } from "@sixb/core/internal/agents";
2
+ import type { AgentRunRecord, AgentThreadRecord, ExecutionRecord, SubagentRunRecord } from "@sixb/core/storage";
3
+ import type { AgentRunFailure } from "./failure";
4
+ import type { FamilyMailbox } from "./family-mailbox";
5
+ import { type OpenRunSandbox } from "./run-environment";
6
+ import type { AgentExecutionContext, AgentRunSettings } from "./types";
7
+ /** What a runner lends the children it runs. */
8
+ export interface ChildRunnerHost {
9
+ /** What every run of the project shares. */
10
+ readonly settings: AgentRunSettings;
11
+ /** How many children run here at once, across every turn; the rest wait their turn queued. */
12
+ readonly capacity: number;
13
+ /**
14
+ * Claim a queued child, retrying while `stop` holds: nothing redelivers a child, and its parent
15
+ * waits on it. Null when it can't be claimed, such as once its parent ended.
16
+ */
17
+ claim(run: SubagentRunRecord, claim: {
18
+ readonly leaseExpiresAt: string;
19
+ readonly stop: AbortSignal;
20
+ }): Promise<AgentRunSession<SubagentRunRecord> | null>;
21
+ /** The sandbox the child works in, opened when it first needs one. */
22
+ openSandbox(child: {
23
+ readonly session: AgentRunSession<SubagentRunRecord>;
24
+ readonly context: AgentExecutionContext;
25
+ readonly execution: ExecutionRecord;
26
+ readonly thread: AgentThreadRecord;
27
+ }): OpenRunSandbox;
28
+ /** A sandbox teardown that outlives the child: the runner waits for it before it stops. */
29
+ onDetachedTeardown(teardown: Promise<void>): void;
30
+ /** A child that failed: the runner reports it, once its end is recorded. */
31
+ reportFailure?(error: unknown, run: AgentRunRecord, failure: AgentRunFailure): void;
32
+ /** Runs the child's preparation, which calls no model. Runs it once when absent. */
33
+ prepare?<T>(prepare: () => Promise<T>, signal: AbortSignal): Promise<T>;
34
+ }
35
+ /** What a child runs under: its parent turn's. */
36
+ export interface ChildParent {
37
+ /** The runner's own stop: its process stopping, or its hold on the parent lost. */
38
+ readonly signal: AbortSignal;
39
+ /** When the parent's lease runs out, which the child is claimed until. */
40
+ leaseExpiresAt(): string;
41
+ /** Holds the child's lease beside its parent's, from now until the returned release. */
42
+ holdLease(session: AgentRunSession<SubagentRunRecord>): Promise<() => void>;
43
+ /** The turn's mailbox, through which they talk. */
44
+ readonly family: FamilyMailbox;
45
+ }
46
+ /**
47
+ * Runs the children of a runner's turns. A child holds its own run, session, token and sandbox,
48
+ * but no lease of its own: its parent's renewals renew it, and a runner that stops takes its
49
+ * children with it. A child left running once its parent ended is ended when its lease lapses.
50
+ */
51
+ export declare class ChildRunner {
52
+ private readonly host;
53
+ /** Children running here, by run id: a child already running is never started twice. */
54
+ private readonly running;
55
+ /** Children holding one of the runner's slots, and those waiting for one, first come first. */
56
+ private active;
57
+ private readonly waiting;
58
+ constructor(host: ChildRunnerHost);
59
+ /** Run a child, in this process. It records the child's fate itself and never rejects. */
60
+ start(run: SubagentRunRecord, parent: ChildParent): void;
61
+ /**
62
+ * Stop a parent's children still running here, and wait for them to record it. The parent's
63
+ * lease, which renews theirs, must hold until this returns.
64
+ */
65
+ stopChildrenOf(parentRunId: string): Promise<void>;
66
+ /** Wait for every child running here, for a runner that stops. */
67
+ drain(): Promise<void>;
68
+ private run;
69
+ /** Wait for one of the runner's child slots: false once the child stops first. */
70
+ private takeSlot;
71
+ /** A slot a child let go of passes to the child waiting longest. */
72
+ private releaseSlot;
73
+ private runClaimed;
74
+ /** Everything a child needs before its first model call, read through its session. */
75
+ private prepare;
76
+ }
77
+ //# sourceMappingURL=run-child.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-child.d.ts","sourceRoot":"","sources":["../src/run-child.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,eAAe,EAErB,MAAM,4BAA4B,CAAA;AAInC,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EAClB,MAAM,oBAAoB,CAAA;AAK3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAGrD,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAA;AAK1B,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAKtE,gDAAgD;AAChD,MAAM,WAAW,eAAe;IAC9B,4CAA4C;IAC5C,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAA;IACnC,8FAA8F;IAC9F,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB;;;OAGG;IACH,KAAK,CACH,GAAG,EAAE,iBAAiB,EACtB,KAAK,EAAE;QAAE,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;KAAE,GACrE,OAAO,CAAC,eAAe,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC,CAAA;IACrD,sEAAsE;IACtE,WAAW,CAAC,KAAK,EAAE;QACjB,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,iBAAiB,CAAC,CAAA;QACpD,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAA;QACvC,QAAQ,CAAC,SAAS,EAAE,eAAe,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AAC,IAAI,CAAC;YAId,GAAG;IAkBjB,kFAAkF;IAClF,OAAO,CAAC,QAAQ;IAoBhB,oEAAoE;IACpE,OAAO,CAAC,WAAW;YAML,UAAU;IA6FxB,sFAAsF;YACxE,OAAO;CA2CtB"}
@@ -0,0 +1,42 @@
1
+ import { type AgentRunSession } from "@sixb/core/internal/agents";
2
+ import type { AgentRunRecord, AgentThreadRecord, ConversationAgentRunRecord, ExecutionRecord, SubagentRunRecord } from "@sixb/core/storage";
3
+ import type { AgentRunFailure } from "./failure";
4
+ import type { FamilyMailbox } from "./family-mailbox";
5
+ import { type OpenRunSandbox } from "./run-environment";
6
+ import type { AgentExecutionContext, AgentRunSettings } from "./types";
7
+ /** What a runner lends the turns it runs. */
8
+ export interface ConversationTurnRunner {
9
+ /** What every run of the project shares. */
10
+ readonly settings: AgentRunSettings;
11
+ /** The sandbox the turn works in, opened when it first needs one. */
12
+ openSandbox(turn: {
13
+ readonly session: AgentRunSession<ConversationAgentRunRecord>;
14
+ readonly context: AgentExecutionContext;
15
+ readonly execution: ExecutionRecord;
16
+ readonly thread: AgentThreadRecord | null;
17
+ }): OpenRunSandbox;
18
+ /** Run a child the turn spawned or continues, beside the turn, on the turn's mailbox. */
19
+ startChild(run: SubagentRunRecord, family: FamilyMailbox): void;
20
+ /** A sandbox teardown that outlives the turn: the runner waits for it before it stops. */
21
+ onDetachedTeardown(teardown: Promise<void>): void;
22
+ /** A turn that failed: the runner reports it, once its end is recorded. */
23
+ reportFailure?(error: unknown, run: AgentRunRecord, failure: AgentRunFailure): void;
24
+ /**
25
+ * Runs the turn's preparation, which reads and resolves and calls no model: the worker retries a
26
+ * storage blip in place. Runs it once when absent.
27
+ */
28
+ prepare?<T>(prepare: () => Promise<T>): Promise<T>;
29
+ }
30
+ /**
31
+ * Run a claimed conversation turn and record how it ended. Returns once its end is recorded, or
32
+ * at once when its runner lost the run. Throws {@link AgentFinalizationError} when its end could
33
+ * not be recorded, and rethrows its failure when `signal` stopped it, for the runner to release
34
+ * the run rather than call it done.
35
+ */
36
+ export declare function runConversationTurn(input: {
37
+ readonly session: AgentRunSession<ConversationAgentRunRecord>;
38
+ readonly runner: ConversationTurnRunner;
39
+ /** The runner's own stop: its process stopping, or its hold on the run lost. */
40
+ readonly signal: AbortSignal;
41
+ }): Promise<void>;
42
+ //# sourceMappingURL=run-conversation-turn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-conversation-turn.d.ts","sourceRoot":"","sources":["../src/run-conversation-turn.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,eAAe,EAErB,MAAM,4BAA4B,CAAA;AAInC,OAAO,KAAK,EACV,cAAc,EAEd,iBAAiB,EACjB,0BAA0B,EAC1B,eAAe,EACf,iBAAiB,EAClB,MAAM,oBAAoB,CAAA;AAI3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAGrD,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAA;AAI1B,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAMtE,6CAA6C;AAC7C,MAAM,WAAW,sBAAsB;IACrC,4CAA4C;IAC5C,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAA;IACnC,qEAAqE;IACrE,WAAW,CAAC,IAAI,EAAE;QAChB,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,0BAA0B,CAAC,CAAA;QAC7D,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAA;QACvC,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAA;QACnC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAA;KAC1C,GAAG,cAAc,CAAA;IAClB,yFAAyF;IACzF,UAAU,CAAC,GAAG,EAAE,iBAAiB,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAAA;IAC/D,0FAA0F;IAC1F,kBAAkB,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IACjD,2EAA2E;IAC3E,aAAa,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,OAAO,EAAE,eAAe,GAAG,IAAI,CAAA;IACnF;;;OAGG;IACH,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;CACnD;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE;IAC/C,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,0BAA0B,CAAC,CAAA;IAC7D,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAA;IACvC,gFAAgF;IAChF,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;CAC7B,GAAG,OAAO,CAAC,IAAI,CAAC,CA0GhB"}
@@ -0,0 +1,22 @@
1
+ import type { SandboxRequestCredential } from "@sixb/core";
2
+ /** The token the run's commands call the API with, valid while this execution owns the run. */
3
+ export declare function runTokenFor(input: {
4
+ readonly projectId: string;
5
+ readonly runId: string;
6
+ readonly executionToken?: string;
7
+ }): string;
8
+ /**
9
+ * The token a runner over HTTP reaches its run's session with. It is the runner's alone: the run's
10
+ * commands get the run token, which the session refuses.
11
+ */
12
+ export declare function runnerTokenFor(input: {
13
+ readonly projectId: string;
14
+ readonly runId: string;
15
+ readonly executionToken?: string;
16
+ }): string;
17
+ /**
18
+ * The run token as a request credential: on a provider that adds credentials outside the guest,
19
+ * every call to the API under `apiBaseUrl` gets it, and the run's commands never hold it.
20
+ */
21
+ export declare function runApiCredential(apiBaseUrl: string, runToken: string): SandboxRequestCredential;
22
+ //# sourceMappingURL=run-credential.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-credential.d.ts","sourceRoot":"","sources":["../src/run-credential.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAA;AAG1D,+FAA+F;AAC/F,wBAAgB,WAAW,CAAC,KAAK,EAAE;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CACjC,GAAG,MAAM,CAWT;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE;IACpC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CACjC,GAAG,MAAM,CAWT;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,wBAAwB,CAQ/F"}
@@ -0,0 +1,115 @@
1
+ import type { Principal } from "@sixb/core";
2
+ import { type AgentRunSession, type AgentTurnHistory } from "@sixb/core/internal/agents";
3
+ import type { WorkflowIOSnapshot } from "@sixb/core/internal/workflows";
4
+ import type { ModelTool } from "@sixb/core/models";
5
+ import type { AgentThreadRecord, ConversationAgentRunRecord, SubagentRunRecord, WorkflowAgentNodeRunRecord } from "@sixb/core/storage";
6
+ import type { AgentContextBudget } from "./context-budget";
7
+ import type { ResolvedAgentExecutionPlan } from "./execution-plan";
8
+ import type { ConversationReaders } from "./message-authors";
9
+ import { type AgentErrorDetails, type AgentToolCaller } from "./model-adapters";
10
+ import type { BeforeFinalizeOptions, RunSandbox } from "./run-sandbox";
11
+ import type { SubagentHistory } from "./subagent-continuation";
12
+ import { type LoadedAgentThreadModelContext } from "./thread-context";
13
+ import type { AgentTurnRuntime } from "./turn-runtime";
14
+ import type { AgentExecutionContext, AgentRunFiles, AgentTurnContext } from "./types";
15
+ export interface AgentExecutionEnvironment {
16
+ readonly turnContext: AgentTurnContext;
17
+ /** The run's sandbox and file budget, for the files a parent and its children hand each other. */
18
+ readonly runFiles: AgentRunFiles;
19
+ /** Confirm preservation before recording success, cancellation or failure. Idempotent. */
20
+ beforeFinalize(options?: BeforeFinalizeOptions): Promise<void>;
21
+ dispose(): Promise<void>;
22
+ }
23
+ export interface ConversationAgentExecutionEnvironment extends AgentExecutionEnvironment {
24
+ /** The history the turn runs on: as it started, or as its compaction left it. */
25
+ readonly threadContext: LoadedAgentThreadModelContext;
26
+ }
27
+ /**
28
+ * How a runner gives a run its environment: a cloud sandbox, or a folder on a computer. The runner
29
+ * closes over whatever it opens it from (a factory, the thread's recipe, the run's credentials).
30
+ */
31
+ export type OpenRunSandbox = (lifecycle: {
32
+ /** Stops provisioning: cancellation, lost ownership, or shutdown. */
33
+ readonly signal: AbortSignal;
34
+ /** Ends the run when its environment can no longer serve it, such as lost source credentials. */
35
+ readonly onFailure: (error: Error) => void;
36
+ }) => Promise<OpenedRunSandbox>;
37
+ export interface OpenedRunSandbox {
38
+ readonly sandbox: RunSandbox;
39
+ /** The workspace the run's paused attempt left: it holds that attempt's files already. */
40
+ readonly resumed?: boolean;
41
+ }
42
+ interface CreateAgentEnvironmentInput {
43
+ readonly context: AgentExecutionContext;
44
+ readonly plan: ResolvedAgentExecutionPlan;
45
+ /** The run's environment, opened by its runner. */
46
+ readonly openSandbox: OpenRunSandbox;
47
+ readonly signal?: AbortSignal;
48
+ /**
49
+ * Sink for a sandbox teardown that outlives dispose() (the model answered before the boot
50
+ * finished, so dispose returns without stalling on it). The worker registers these so a graceful
51
+ * stop() can drain them instead of leaving orphaned machines being torn down.
52
+ */
53
+ readonly onDetachedTeardown?: (teardown: Promise<void>) => void;
54
+ }
55
+ export interface CreateConversationAgentEnvironmentInput extends CreateAgentEnvironmentInput {
56
+ /** The turn's session: its workspace, conversation and checkpoint go through it. */
57
+ readonly session: AgentRunSession;
58
+ readonly thread?: AgentThreadRecord | null;
59
+ /** Who asked for the turn: what it publishes is theirs, in an artifact the thread's owner owns. */
60
+ readonly requestedBy?: Principal;
61
+ /** Who can read the thread now: in a shared one, who wrote what counts toward the estimate. */
62
+ readonly conversation?: ConversationReaders;
63
+ /** Others were added to the thread, so it reaches the project's memory alone. */
64
+ readonly shared?: boolean;
65
+ /** Run preflight only after current sandbox access has been resolved. */
66
+ readonly preflight?: {
67
+ readonly budget: AgentContextBudget;
68
+ readonly runtime: AgentTurnRuntime;
69
+ };
70
+ readonly run: ConversationAgentRunRecord;
71
+ /** The conversation's history as the turn started (`AgentTurnContext.history`). */
72
+ readonly history: AgentTurnHistory;
73
+ /** Framework-owned tools of the conversational Agent: delegation. */
74
+ readonly frameworkTools?: readonly ModelTool[];
75
+ }
76
+ export interface CreateSubagentEnvironmentInput extends CreateAgentEnvironmentInput {
77
+ /** The child's session: its workspace goes through it. */
78
+ readonly session: AgentRunSession;
79
+ readonly run: SubagentRunRecord;
80
+ /** The child's own thread: memory is read as of its creation. */
81
+ readonly thread: AgentThreadRecord;
82
+ /** The conversation: what the child publishes lands there. Absent, it publishes nothing. */
83
+ readonly conversation?: AgentThreadRecord | null;
84
+ /** Who asked for the parent turn: what the child publishes is theirs. */
85
+ readonly requestedBy?: Principal;
86
+ /** Its thread's messages, whose files are projected again, and the paused run it continues. */
87
+ readonly history: SubagentHistory;
88
+ /** Framework-owned tools of a child: `ask_parent`. */
89
+ readonly frameworkTools?: readonly ModelTool[];
90
+ }
91
+ export interface CreateWorkflowAgentNodeEnvironmentInput extends CreateAgentEnvironmentInput {
92
+ readonly run: WorkflowAgentNodeRunRecord;
93
+ readonly workflowId: string;
94
+ readonly stepId: string;
95
+ readonly nodeInput: WorkflowIOSnapshot;
96
+ readonly errorDetails: AgentErrorDetails;
97
+ /** How the step calls a project tool: it runs in the cloud, so in the worker's process. */
98
+ readonly callTool: AgentToolCaller;
99
+ }
100
+ /** Prepare conversation history and attachments, then start the shared agent environment. */
101
+ export declare function createConversationAgentEnvironment(input: CreateConversationAgentEnvironmentInput): Promise<ConversationAgentExecutionEnvironment>;
102
+ /**
103
+ * Build an isolated environment for one headless child Agent. It knows the project as its parent
104
+ * does (ontology docs, memory to read), holds the files its parent handed over at their paths, and
105
+ * publishes into its conversation, as its own run.
106
+ *
107
+ * On a provider that resumes sandboxes, its thread keeps its workspace while it pauses: the run
108
+ * that continues it finds every file where it was. Elsewhere, or once those files were lost, it
109
+ * starts blank, with the handed files and what the paused run left in `out/` given back.
110
+ */
111
+ export declare function createSubagentEnvironment(input: CreateSubagentEnvironmentInput): Promise<AgentExecutionEnvironment>;
112
+ /** Build the same tool/sandbox environment for a fresh, headless workflow task. */
113
+ export declare function createWorkflowAgentNodeEnvironment(input: CreateWorkflowAgentNodeEnvironmentInput): Promise<AgentExecutionEnvironment>;
114
+ export {};
115
+ //# sourceMappingURL=run-environment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-environment.d.ts","sourceRoot":"","sources":["../src/run-environment.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,gBAAgB,EAGtB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,KAAK,EACV,iBAAiB,EACjB,0BAA0B,EAC1B,iBAAiB,EACjB,0BAA0B,EAC3B,MAAM,oBAAoB,CAAA;AAiB3B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAI1D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAAqB,MAAM,kBAAkB,CAAA;AAClG,OAAO,KAAK,E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AC,WAAW,CAAC,EAAE,SAAS,CAAA;IAChC,+FAA+F;IAC/F,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAA;IACjC,sDAAsD;IACtD,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,SAAS,EAAE,CAAA;CAC/C;AAED,MAAM,WAAW,uCAAwC,SAAQ,2BAA2B;IAC1F,QAAQ,CAAC,GAAG,EAAE,0BAA0B,CAAA;IACxC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAA;IACtC,QAAQ,CAAC,YAAY,EAAE,iBAAiB,CAAA;IACxC,2FAA2F;IAC3F,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAA;CACnC;AAED,6FAA6F;AAC7F,wBAAsB,kCAAkC,CACtD,KAAK,EAAE,uCAAuC,GAC7C,OAAO,CAAC,qCAAqC,CAAC,CAoGhD;AAED;;;;;;;;GAQG;AACH,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,8BAA8B,GACpC,OAAO,CAAC,yBAAyB,CAAC,CAgBpC;AA0ED,mFAAmF;AACnF,wBAAsB,kCAAkC,CACtD,KAAK,EAAE,uCAAuC,GAC7C,OAAO,CAAC,yBAAyB,CAAC,CAkDpC"}
@@ -0,0 +1,15 @@
1
+ import { type AgentRunSession } from "@sixb/core/internal/agents";
2
+ import type { AgentRunRecord, AppendAgentMessageInput } from "@sixb/core/storage";
3
+ import { type AgentRunFailure } from "./failure";
4
+ /**
5
+ * End a run that failed or stopped, with what it did kept in the same transaction. Returns
6
+ * nothing when the run is no longer this session's; throws {@link AgentFinalizationError} when
7
+ * storage stays unavailable, so the job is redelivered rather than acknowledged.
8
+ */
9
+ export declare function recordFate(session: AgentRunSession, status: "failed" | "cancelled", error: unknown, messages?: readonly AppendAgentMessageInput[]): Promise<{
10
+ readonly run: AgentRunRecord;
11
+ readonly failure: AgentRunFailure;
12
+ } | undefined>;
13
+ /** What a run's failure names: its run, and its thread or its parent. */
14
+ export declare function agentRunFailureDetails(run: AgentRunRecord): Readonly<Record<string, string>>;
15
+ //# sourceMappingURL=run-fate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-fate.d.ts","sourceRoot":"","sources":["../src/run-fate.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EAErB,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AACjF,OAAO,EAAE,KAAK,eAAe,EAA2B,MAAM,WAAW,CAAA;AAEzE;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,QAAQ,GAAG,WAAW,EAC9B,KAAK,EAAE,OAAO,EACd,QAAQ,CAAC,EAAE,SAAS,uBAAuB,EAAE,GAC5C,OAAO,CAAC;IAAE,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAA;CAAE,GAAG,SAAS,CAAC,CAyB1F;AAED,yEAAyE;AACzE,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAI5F"}
@@ -0,0 +1,60 @@
1
+ import type { Sandbox } from "@sixb/core";
2
+ import type { AgentWorkspacePromptContext } from "./agent-prompt";
3
+ /**
4
+ * Where a provider's sandbox keeps a run's files: in its working directory, which a Git checkout
5
+ * excludes (see `prepareWorkspaceRunFiles`).
6
+ */
7
+ export { SANDBOX_CONTEXT_DIRECTORY } from "@sixb/core/internal/agents";
8
+ /** The sandbox a run works in, with what the system prompt may say about it. */
9
+ export interface AcquiredRunSandbox {
10
+ readonly sandbox: Sandbox;
11
+ /** The workspace's environment; provisioning adds the run's. */
12
+ readonly env?: Readonly<Record<string, string>>;
13
+ /** Facts about a prepared workspace; absent for a blank sandbox. */
14
+ readonly promptContext?: AgentWorkspacePromptContext;
15
+ /** When the workspace was recreated and its earlier files were lost. */
16
+ readonly resetAt?: string;
17
+ }
18
+ /**
19
+ * How one run obtains its sandbox and gives it back. Every run kind goes through this lifecycle,
20
+ * with one of two behaviors:
21
+ *
22
+ * - ephemeral (`ephemeralRunSandbox`): created for this run, blank or prepared from a recipe, and
23
+ * destroyed when the run releases it;
24
+ * - persistent (`persistentRunSandbox`): a thread's workspace, resumed for this run and saved by
25
+ * `beforeFinalize`. It has no `release`: only a sub-agent run that ends without pausing
26
+ * destroys it.
27
+ *
28
+ * Acquisition may happen before `acquire()`: a thread's workspace is acquired before compaction,
29
+ * so `acquire()` only hands it over. Preservation belongs to `beforeFinalize`, never `release`.
30
+ */
31
+ export interface RunSandbox {
32
+ /**
33
+ * Whether the first model call waits for acquisition. A workspace the prompt describes must
34
+ * exist first; a blank sandbox boots concurrently and tools wait for it only when used.
35
+ */
36
+ readonly waitBeforeModel: boolean;
37
+ /**
38
+ * Where the run's files go, known before acquisition so the prompt can name them. As the agent
39
+ * names it: relative to the working directory, or absolute.
40
+ */
41
+ readonly contextDirectory: string;
42
+ /** Called once, when the run environment starts. */
43
+ acquire(): Promise<AcquiredRunSandbox>;
44
+ /**
45
+ * Give back an acquired sandbox, after the run or a failed provisioning. Absent when the run
46
+ * has nothing to give back, so teardown never waits on it.
47
+ */
48
+ release?(acquired: AcquiredRunSandbox): Promise<void>;
49
+ /** Confirm preservation before the run's terminal write. Idempotent: the first call decides. */
50
+ beforeFinalize?(options?: BeforeFinalizeOptions): Promise<void>;
51
+ }
52
+ /** How a run's end leaves its thread's workspace. */
53
+ export interface BeforeFinalizeOptions {
54
+ /**
55
+ * The run leaves nothing its thread goes on from, as a sub-agent run that answered, failed or
56
+ * was stopped: destroy its workspace instead of saving it.
57
+ */
58
+ readonly discard?: boolean;
59
+ }
60
+ //# sourceMappingURL=run-sandbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-sandbox.d.ts","sourceRoot":"","sources":["../src/run-sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAA;AAEjE;;;GAGG;AACH,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAA;AAEtE,gFAAgF;AAChF,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,gEAAgE;IAChE,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IAC/C,oEAAoE;IACpE,QAAQ,CAAC,aAAa,CAAC,EAAE,2BAA2B,CAAA;IACpD,wEAAwE;IACxE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;IACjC;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,oDAAoD;IACpD,OAAO,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAAA;IACtC;;;OAGG;IACH,OAAO,CAAC,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACrD,gGAAgG;IAChG,cAAc,CAAC,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAChE;AAED,qDAAqD;AACrD,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAC3B"}