@myagentroam/agent 0.9.141 → 0.9.142

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 (230) hide show
  1. package/dist/agent-core/host/contracts.d.ts +64 -0
  2. package/dist/{host → agent-core/host}/local-agent-host.d.ts +6 -5
  3. package/dist/{host → agent-core/host}/local-agent-host.js +4 -4
  4. package/dist/{model → agent-core/model}/contracts.d.ts +2 -16
  5. package/dist/agent-core/model/recovery.d.ts +4 -0
  6. package/dist/agent-core/model/recovery.js +71 -0
  7. package/dist/{prompts → agent-core/prompts}/core.d.ts +3 -13
  8. package/dist/{prompts → agent-core/prompts}/index.d.ts +1 -1
  9. package/dist/{prompts → agent-core/prompts}/modes.d.ts +1 -1
  10. package/dist/{prompts → agent-core/prompts}/resources.d.ts +1 -1
  11. package/dist/{runtime/compact.d.ts → agent-core/runtime/compaction/history.d.ts} +2 -23
  12. package/dist/{runtime/compact.js → agent-core/runtime/compaction/history.js} +2 -92
  13. package/dist/agent-core/runtime/compaction/operation.d.ts +22 -0
  14. package/dist/agent-core/runtime/compaction/operation.js +91 -0
  15. package/dist/agent-core/runtime/context/contracts.d.ts +12 -0
  16. package/dist/{runtime/environment-context.d.ts → agent-core/runtime/context/environment.d.ts} +2 -2
  17. package/dist/{runtime/environment-context.js → agent-core/runtime/context/environment.js} +1 -1
  18. package/dist/{runtime/context-gc-runtime.d.ts → agent-core/runtime/context/gc-runtime.d.ts} +4 -4
  19. package/dist/{runtime/context-gc-runtime.js → agent-core/runtime/context/gc-runtime.js} +3 -3
  20. package/dist/{runtime/context-gc-tokens.d.ts → agent-core/runtime/context/gc-tokens.d.ts} +2 -2
  21. package/dist/{runtime/context-gc-tokens.js → agent-core/runtime/context/gc-tokens.js} +3 -3
  22. package/dist/{runtime/context-gc.d.ts → agent-core/runtime/context/gc.d.ts} +3 -3
  23. package/dist/{runtime/context-gc.js → agent-core/runtime/context/gc.js} +6 -6
  24. package/dist/{runtime → agent-core/runtime/context}/instructions.d.ts +1 -1
  25. package/dist/{runtime → agent-core/runtime/context}/instructions.js +1 -1
  26. package/dist/{runtime → agent-core/runtime/context}/normalize.d.ts +1 -1
  27. package/dist/{runtime/context-projection.d.ts → agent-core/runtime/context/projection.d.ts} +3 -3
  28. package/dist/{runtime/context-projection.js → agent-core/runtime/context/projection.js} +4 -4
  29. package/dist/agent-core/runtime/context/request-budget.d.ts +6 -0
  30. package/dist/agent-core/runtime/context/request-budget.js +22 -0
  31. package/dist/agent-core/runtime/context/restore.d.ts +15 -0
  32. package/dist/agent-core/runtime/context/restore.js +85 -0
  33. package/dist/agent-core/runtime/context/usage.d.ts +18 -0
  34. package/dist/agent-core/runtime/context/usage.js +138 -0
  35. package/dist/agent-core/runtime/context/world-state.d.ts +35 -0
  36. package/dist/agent-core/runtime/context/world-state.js +133 -0
  37. package/dist/agent-core/runtime/contracts.d.ts +37 -0
  38. package/dist/agent-core/runtime/event-projection.d.ts +5 -0
  39. package/dist/agent-core/runtime/event-projection.js +17 -0
  40. package/dist/agent-core/runtime/events.d.ts +142 -0
  41. package/dist/agent-core/runtime/execution.d.ts +50 -0
  42. package/dist/agent-core/runtime/execution.js +393 -0
  43. package/dist/{runtime → agent-core/runtime}/rollout-budget.d.ts +1 -1
  44. package/dist/agent-core/sdk/agent.js +209 -0
  45. package/dist/agent-core/sdk/model-runtime.d.ts +13 -0
  46. package/dist/agent-core/sdk/model-runtime.js +63 -0
  47. package/dist/agent-core/sdk/session-title.d.ts +3 -0
  48. package/dist/agent-core/sdk/session-title.js +42 -0
  49. package/dist/agent-core/sdk/session.d.ts +62 -0
  50. package/dist/agent-core/sdk/session.js +1147 -0
  51. package/dist/agent-core/sdk/subagent-backend.d.ts +3 -0
  52. package/dist/agent-core/sdk/subagent-backend.js +46 -0
  53. package/dist/agent-core/sdk/types.d.ts +56 -0
  54. package/dist/{session → agent-core/session}/catalog.d.ts +2 -1
  55. package/dist/{session → agent-core/session}/context-gc-checkpoint.js +1 -1
  56. package/dist/{session → agent-core/session}/jsonl-store.d.ts +2 -2
  57. package/dist/{session → agent-core/session}/jsonl-store.js +1 -1
  58. package/dist/agent-core/subagent/contracts.d.ts +91 -0
  59. package/dist/agent-core/subagent/contracts.js +1 -0
  60. package/dist/agent-core/subagent/scheduler.d.ts +117 -0
  61. package/dist/{subagent → agent-core/subagent}/session-controller.d.ts +3 -2
  62. package/dist/agent-core/tools/agent/agent-cancel.d.ts +7 -0
  63. package/dist/{tools → agent-core/tools/agent}/agent-cancel.js +1 -1
  64. package/dist/agent-core/tools/agent/agent-message.d.ts +7 -0
  65. package/dist/{tools → agent-core/tools/agent}/agent-message.js +2 -2
  66. package/dist/{tools → agent-core/tools/agent}/agent-start.d.ts +3 -3
  67. package/dist/{tools → agent-core/tools/agent}/agent-start.js +3 -3
  68. package/dist/agent-core/tools/agent/agent-wait.d.ts +7 -0
  69. package/dist/{tools → agent-core/tools/agent}/agent-wait.js +2 -2
  70. package/dist/{tools → agent-core/tools/agent}/question.d.ts +2 -2
  71. package/dist/{tools → agent-core/tools/agent}/question.js +2 -2
  72. package/dist/{tools → agent-core/tools/agent}/skill.d.ts +2 -2
  73. package/dist/{tools → agent-core/tools/agent}/skill.js +2 -2
  74. package/dist/{tools → agent-core/tools/agent}/todo-read.d.ts +2 -2
  75. package/dist/{tools → agent-core/tools/agent}/todo-write.d.ts +2 -2
  76. package/dist/{tools → agent-core/tools/agent}/todo-write.js +2 -2
  77. package/dist/{tools → agent-core/tools/agent}/todo.d.ts +2 -9
  78. package/dist/{tools → agent-core/tools/agent}/todo.js +1 -1
  79. package/dist/{tools → agent-core/tools}/code-mode/cells.d.ts +1 -1
  80. package/dist/{tools → agent-core/tools}/code-mode/dispatch.d.ts +2 -4
  81. package/dist/{tools → agent-core/tools}/code-mode/dispatch.js +5 -4
  82. package/dist/{tools → agent-core/tools}/code-mode/engine.d.ts +1 -1
  83. package/dist/agent-core/tools/code-mode/engine.js +1 -0
  84. package/dist/{tools/code-mode.d.ts → agent-core/tools/code-mode/index.d.ts} +7 -7
  85. package/dist/{tools/code-mode.js → agent-core/tools/code-mode/index.js} +14 -15
  86. package/dist/{tools → agent-core/tools}/code-mode/state.d.ts +2 -13
  87. package/dist/agent-core/tools/code-mode/worker.d.ts +1 -0
  88. package/dist/agent-core/tools/contracts.d.ts +168 -0
  89. package/dist/agent-core/tools/contracts.js +1 -0
  90. package/dist/agent-core/tools/execution.d.ts +34 -0
  91. package/dist/agent-core/tools/execution.js +102 -0
  92. package/dist/agent-core/tools/local/apply-patch.d.ts +19 -0
  93. package/dist/{tools → agent-core/tools/local}/apply-patch.js +8 -2
  94. package/dist/{tools → agent-core/tools/local}/exec.d.ts +5 -17
  95. package/dist/{tools → agent-core/tools/local}/exec.js +4 -4
  96. package/dist/{tools → agent-core/tools/local}/read.d.ts +7 -15
  97. package/dist/{tools → agent-core/tools/local}/read.js +185 -2
  98. package/dist/{tools/local-registry.d.ts → agent-core/tools/local/registry.d.ts} +5 -5
  99. package/dist/agent-core/tools/local/registry.js +101 -0
  100. package/dist/{tools → agent-core/tools/local}/view-image.d.ts +4 -9
  101. package/dist/{tools → agent-core/tools/local}/view-image.js +2 -2
  102. package/dist/agent-core/tools/local/web-fetch.d.ts +4 -0
  103. package/dist/agent-core/tools/local/web-fetch.js +85 -0
  104. package/dist/agent-core/tools/local/web-search.d.ts +7 -0
  105. package/dist/agent-core/tools/local/web-search.js +34 -0
  106. package/dist/{tools/local-workspace-tools.js → agent-core/tools/local/workspace-tools.js} +1 -1
  107. package/dist/{sdk/mcp-catalog.d.ts → agent-core/tools/mcp/catalog.d.ts} +1 -2
  108. package/dist/{sdk/mcp-catalog.js → agent-core/tools/mcp/catalog.js} +1 -1
  109. package/dist/agent-core/tools/mcp/history.d.ts +4 -0
  110. package/dist/agent-core/tools/mcp/history.js +33 -0
  111. package/dist/{tools → agent-core/tools/mcp}/tool-search.d.ts +3 -3
  112. package/dist/{tools → agent-core/tools/mcp}/tool-search.js +4 -4
  113. package/dist/agent-core/tools/output-projection.d.ts +14 -0
  114. package/dist/agent-core/tools/output-projection.js +189 -0
  115. package/dist/{tools → agent-core/tools}/registry.d.ts +1 -1
  116. package/dist/agent-core/tools/registry.js +47 -0
  117. package/dist/{tools → agent-core/tools}/runtime-context.d.ts +8 -7
  118. package/dist/agent-core/tools/runtime-context.js +1 -0
  119. package/dist/{tools → agent-core/tools}/runtime.d.ts +1 -1
  120. package/dist/cli/codex-auth-file.d.ts +1 -1
  121. package/dist/cli/codex-auth-file.js +2 -2
  122. package/dist/cli/main.js +9 -9
  123. package/dist/index.d.ts +17 -15
  124. package/dist/index.js +8 -8
  125. package/dist/sandbox/linux/bubblewrap-sandbox-executor.d.ts +1 -1
  126. package/dist/sandbox/linux/bubblewrap-sandbox-executor.js +1 -1
  127. package/package.json +3 -3
  128. package/dist/host/contracts.d.ts +0 -21
  129. package/dist/sdk/agent.js +0 -2548
  130. package/dist/sdk/types.d.ts +0 -349
  131. package/dist/subagent/scheduler.d.ts +0 -206
  132. package/dist/tools/agent-cancel.d.ts +0 -7
  133. package/dist/tools/agent-message.d.ts +0 -7
  134. package/dist/tools/agent-wait.d.ts +0 -7
  135. package/dist/tools/apply-patch.d.ts +0 -32
  136. package/dist/tools/local-registry.js +0 -373
  137. package/dist/tools/registry.js +0 -47
  138. package/dist/tools/web-fetch.d.ts +0 -2
  139. package/dist/tools/web-fetch.js +0 -12
  140. package/dist/tools/web-search.d.ts +0 -2
  141. package/dist/tools/web-search.js +0 -15
  142. package/dist/{error.d.ts → agent-core/error.d.ts} +0 -0
  143. package/dist/{error.js → agent-core/error.js} +0 -0
  144. package/dist/{host → agent-core/host}/contracts.js +0 -0
  145. package/dist/{host → agent-core/host}/local-process-executor.d.ts +0 -0
  146. package/dist/{host → agent-core/host}/local-process-executor.js +0 -0
  147. package/dist/{host → agent-core/host}/network.d.ts +0 -0
  148. package/dist/{host → agent-core/host}/network.js +0 -0
  149. package/dist/{model → agent-core/model}/anthropic-messages.d.ts +0 -0
  150. package/dist/{model → agent-core/model}/anthropic-messages.js +0 -0
  151. package/dist/{model → agent-core/model}/anthropic-thinking.d.ts +0 -0
  152. package/dist/{model → agent-core/model}/anthropic-thinking.js +0 -0
  153. package/dist/{model → agent-core/model}/catalog-file.d.ts +0 -0
  154. package/dist/{model → agent-core/model}/catalog-file.js +0 -0
  155. package/dist/{model → agent-core/model}/configuration.d.ts +0 -0
  156. package/dist/{model → agent-core/model}/configuration.js +0 -0
  157. package/dist/{model → agent-core/model}/contracts.js +0 -0
  158. package/dist/{model → agent-core/model}/http.d.ts +0 -0
  159. package/dist/{model → agent-core/model}/http.js +0 -0
  160. package/dist/{model → agent-core/model}/openai-responses.d.ts +0 -0
  161. package/dist/{model → agent-core/model}/openai-responses.js +0 -0
  162. package/dist/{model → agent-core/model}/runtime-credential.d.ts +0 -0
  163. package/dist/{model → agent-core/model}/runtime-credential.js +0 -0
  164. package/dist/{model → agent-core/model}/sse.d.ts +0 -0
  165. package/dist/{model → agent-core/model}/sse.js +0 -0
  166. package/dist/{model → agent-core/model}/transport-test.d.ts +0 -0
  167. package/dist/{model → agent-core/model}/transport-test.js +0 -0
  168. package/dist/{prompts → agent-core/prompts}/compact.d.ts +0 -0
  169. package/dist/{prompts → agent-core/prompts}/compact.js +0 -0
  170. package/dist/{prompts → agent-core/prompts}/core.js +0 -0
  171. package/dist/{prompts → agent-core/prompts}/execution-budget.d.ts +0 -0
  172. package/dist/{prompts → agent-core/prompts}/execution-budget.js +0 -0
  173. package/dist/{prompts → agent-core/prompts}/index.js +0 -0
  174. package/dist/{prompts → agent-core/prompts}/modes.js +0 -0
  175. package/dist/{prompts → agent-core/prompts}/output.d.ts +0 -0
  176. package/dist/{prompts → agent-core/prompts}/output.js +0 -0
  177. package/dist/{prompts → agent-core/prompts}/resources.js +0 -0
  178. package/dist/{prompts → agent-core/prompts}/subagent.d.ts +0 -0
  179. package/dist/{prompts → agent-core/prompts}/subagent.js +0 -0
  180. package/dist/{prompts → agent-core/prompts}/title.d.ts +0 -0
  181. package/dist/{prompts → agent-core/prompts}/title.js +0 -0
  182. package/dist/{prompts → agent-core/prompts}/workflow.d.ts +0 -0
  183. package/dist/{prompts → agent-core/prompts}/workflow.js +0 -0
  184. package/dist/{runtime → agent-core/runtime}/async-queue.d.ts +0 -0
  185. package/dist/{runtime → agent-core/runtime}/async-queue.js +0 -0
  186. package/dist/{sdk/types.js → agent-core/runtime/context/contracts.js} +0 -0
  187. package/dist/{runtime → agent-core/runtime/context}/normalize.js +0 -0
  188. package/dist/{session/types.js → agent-core/runtime/contracts.js} +0 -0
  189. package/dist/{tools/code-mode/engine.js → agent-core/runtime/events.js} +0 -0
  190. package/dist/{runtime → agent-core/runtime}/execution-policy.d.ts +0 -0
  191. package/dist/{runtime → agent-core/runtime}/execution-policy.js +0 -0
  192. package/dist/{runtime → agent-core/runtime}/plan-output.d.ts +0 -0
  193. package/dist/{runtime → agent-core/runtime}/plan-output.js +0 -0
  194. package/dist/{runtime → agent-core/runtime}/rollout-budget.js +0 -0
  195. package/dist/{runtime → agent-core/runtime}/token-budget.d.ts +0 -0
  196. package/dist/{runtime → agent-core/runtime}/token-budget.js +0 -0
  197. package/dist/{sdk → agent-core/sdk}/agent.d.ts +0 -0
  198. package/dist/{tools/code-mode/worker.d.ts → agent-core/sdk/types.js} +0 -0
  199. package/dist/{session → agent-core/session}/catalog.js +0 -0
  200. package/dist/{session → agent-core/session}/context-gc-checkpoint.d.ts +0 -0
  201. package/dist/{session → agent-core/session}/context-gc-replacements.d.ts +0 -0
  202. package/dist/{session → agent-core/session}/context-gc-replacements.js +0 -0
  203. package/dist/{session → agent-core/session}/context-gc-subagent.d.ts +0 -0
  204. package/dist/{session → agent-core/session}/context-gc-subagent.js +0 -0
  205. package/dist/{session → agent-core/session}/transaction-recovery.d.ts +0 -0
  206. package/dist/{session → agent-core/session}/transaction-recovery.js +0 -0
  207. package/dist/{session → agent-core/session}/types.d.ts +0 -0
  208. package/dist/{tools/runtime-context.js → agent-core/session/types.js} +0 -0
  209. package/dist/{subagent → agent-core/subagent}/scheduler.js +0 -0
  210. package/dist/{subagent → agent-core/subagent}/session-controller.js +0 -0
  211. package/dist/{tools → agent-core/tools/agent}/todo-read.js +0 -0
  212. package/dist/{tools → agent-core/tools}/callers.d.ts +0 -0
  213. package/dist/{tools → agent-core/tools}/callers.js +0 -0
  214. package/dist/{tools → agent-core/tools}/code-mode/cells.js +1 -1
  215. /package/dist/{tools → agent-core/tools}/code-mode/quickjs-engine.d.ts +0 -0
  216. /package/dist/{tools → agent-core/tools}/code-mode/quickjs-engine.js +0 -0
  217. /package/dist/{tools → agent-core/tools}/code-mode/state.js +0 -0
  218. /package/dist/{tools → agent-core/tools}/code-mode/text-output.d.ts +0 -0
  219. /package/dist/{tools → agent-core/tools}/code-mode/text-output.js +0 -0
  220. /package/dist/{tools → agent-core/tools}/code-mode/worker.js +0 -0
  221. /package/dist/{tools → agent-core/tools}/execution-limits.d.ts +0 -0
  222. /package/dist/{tools → agent-core/tools}/execution-limits.js +0 -0
  223. /package/dist/{tools → agent-core/tools/local}/read-context.d.ts +0 -0
  224. /package/dist/{tools → agent-core/tools/local}/read-context.js +0 -0
  225. /package/dist/{tools/local-workspace-tools.d.ts → agent-core/tools/local/workspace-tools.d.ts} +0 -0
  226. /package/dist/{tools → agent-core/tools}/runtime.js +0 -0
  227. /package/dist/{tools → agent-core/tools}/scheduler.d.ts +0 -0
  228. /package/dist/{tools → agent-core/tools}/scheduler.js +0 -0
  229. /package/dist/{tools → agent-core/tools}/shared/path-resolver.d.ts +0 -0
  230. /package/dist/{tools → agent-core/tools}/shared/path-resolver.js +0 -0
@@ -0,0 +1,3 @@
1
+ import type { JsonlSessionStore } from '../session/jsonl-store.js';
2
+ import type { SubagentSessionControllerBackend } from '../subagent/session-controller.js';
3
+ export declare function createSubagentBackend(store: JsonlSessionStore, workspace: string): SubagentSessionControllerBackend;
@@ -0,0 +1,46 @@
1
+ import { MarAgentError } from '../error.js';
2
+ export function createSubagentBackend(store, workspace) {
3
+ return {
4
+ createSession: async (input) => {
5
+ const session = await store.createSession({
6
+ workspace,
7
+ title: input.title,
8
+ source: input.source
9
+ });
10
+ return { id: session.id };
11
+ },
12
+ deleteSession: async (sessionId) => {
13
+ await store.delete(sessionId);
14
+ },
15
+ listChildren: async (parentSessionId) => {
16
+ const sessions = await store.listSubagentChildren(parentSessionId);
17
+ return Promise.all(sessions.map(async (session) => ({
18
+ id: session.id,
19
+ createdAt: session.createdAt,
20
+ lastActivityAt: session.lastActivityAt,
21
+ source: session.source,
22
+ records: await store.read(session.id)
23
+ })));
24
+ },
25
+ loadChild: async (parentSessionId, childSessionId) => {
26
+ let session;
27
+ try {
28
+ session = await store.getSession(childSessionId);
29
+ }
30
+ catch (error) {
31
+ if (error instanceof MarAgentError && error.code === 'MAR_AGENT_SESSION_NOT_FOUND')
32
+ return undefined;
33
+ throw error;
34
+ }
35
+ if (session.source.type !== 'subagent' || session.source.parentSessionId !== parentSessionId)
36
+ return undefined;
37
+ return {
38
+ id: session.id,
39
+ createdAt: session.createdAt,
40
+ lastActivityAt: session.lastActivityAt,
41
+ source: session.source,
42
+ records: await store.read(session.id)
43
+ };
44
+ }
45
+ };
46
+ }
@@ -0,0 +1,56 @@
1
+ import type { MarAgentHost } from '../host/contracts.js';
2
+ import type { MarAgentModelConfiguration } from '../model/configuration.js';
3
+ import type { ExecutionResult, RolloutBudgetOptions, RunInput } from '../runtime/contracts.js';
4
+ import type { MarAgentEvent } from '../runtime/events.js';
5
+ import type { MarAgentSessionPage, MarAgentSessionSummary } from '../session/catalog.js';
6
+ import type { SessionListInput, SessionSource } from '../session/types.js';
7
+ export interface CreateSessionInput {
8
+ workspace: string;
9
+ title?: string;
10
+ }
11
+ export type { HostExecutionExtensions, HostSessionResourceSnapshot, HostSkill, MarAgentHost } from '../host/contracts.js';
12
+ export type { AccessMode, ExecutionMode, ExecutionResult, MarAgentImageMetadata, RolloutBudgetOptions, RunInput, RunInputImage } from '../runtime/contracts.js';
13
+ export type { MarAgentEvent, MarAgentEventBase } from '../runtime/events.js';
14
+ export type { CodeCellEventData, MarAgentToolArtifact, MarAgentToolImageArtifact, McpCatalogTool, McpToolCallContext, McpToolCatalog, McpToolCatalogContext, ToolCall, ToolExecutionContext, ToolExecutionResult } from '../tools/contracts.js';
15
+ /** A live execution exposes streamed events separately from its terminal result. */
16
+ export interface ExecutionHandle extends AsyncIterable<MarAgentEvent> {
17
+ readonly executionId: string;
18
+ result(): Promise<ExecutionResult>;
19
+ /** Signals abort; await result() to observe the terminal status and cleanup. */
20
+ cancel(): void;
21
+ }
22
+ /** A persisted Session permits one active main execution at a time. */
23
+ export interface MarAgentSession {
24
+ readonly id: string;
25
+ run(input: RunInput): ExecutionHandle;
26
+ plan(input: RunInput): ExecutionHandle;
27
+ compact(input?: Partial<RunInput>): ExecutionHandle;
28
+ cancel(executionId: string): Promise<void>;
29
+ }
30
+ export interface MarAgent {
31
+ createSession(input: CreateSessionInput): Promise<MarAgentSession>;
32
+ openSession(sessionId: string): Promise<MarAgentSession>;
33
+ listSessions(input?: SessionListInput): Promise<MarAgentSessionPage>;
34
+ clearSession(sessionId: string): Promise<void>;
35
+ /** Rebinds future main executions only; running subagents keep their captured model providers. */
36
+ reconfigureModels(input: {
37
+ readonly models: readonly MarAgentModelConfiguration[];
38
+ readonly defaultModelId?: string;
39
+ }): Promise<void>;
40
+ deleteSession(sessionId: string): Promise<void>;
41
+ /** Cancels active executions, then closes SDK-owned providers, the Host and the Session store. */
42
+ dispose(): Promise<void>;
43
+ }
44
+ export interface CreateMarAgentOptions {
45
+ mode: 'normal' | 'node';
46
+ host: MarAgentHost;
47
+ models: readonly MarAgentModelConfiguration[];
48
+ defaultModelId?: string;
49
+ systemInstruction?: string;
50
+ workspaceMapping?: {
51
+ readonly logicalPath: string;
52
+ readonly physicalPath: string;
53
+ };
54
+ rolloutBudget?: false | RolloutBudgetOptions;
55
+ }
56
+ export type { MarAgentSessionSummary, SessionListInput, SessionSource };
@@ -1,5 +1,6 @@
1
+ import type { MarAgentImageMetadata } from '../runtime/contracts.js';
2
+ import type { MarAgentEvent } from '../runtime/events.js';
1
3
  import type { SessionListInput, SessionSource } from './types.js';
2
- import type { MarAgentEvent, MarAgentImageMetadata } from '../sdk/types.js';
3
4
  export interface MarAgentSessionSummary {
4
5
  id: string;
5
6
  title: string;
@@ -1,7 +1,7 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { posix, win32 } from 'node:path';
3
3
  import { isDeepStrictEqual } from 'node:util';
4
- import { parseReadContextOutput } from '../tools/read-context.js';
4
+ import { parseReadContextOutput } from '../tools/local/read-context.js';
5
5
  import { codeCellCompletionSequence, contextGcApplyPatchInputReplacement, contextGcCodeModeInputReplacement, contextGcCodeModeOutputReplacement, contextGcExecInputReplacement, contextGcExecOutputReplacement, contextGcPatchResultFromCompletedPayload, contextGcStaleReadReplacement, contextGcWebOutputReplacement, normalizeContextGcCodeModeInput, normalizeContextGcExecResult } from './context-gc-replacements.js';
6
6
  import { contextGcSubagentNeedsRetainedPriorFinal, contextGcSubagentOutputReplacement, contextGcSubagentSnapshotIsPreciselyCovered, contextGcSubagentSnapshotIsSuperseded, normalizeContextGcSubagentSnapshot } from './context-gc-subagent.js';
7
7
  export const CONTEXT_GC_CHECKPOINT_VERSION = 1;
@@ -1,7 +1,7 @@
1
1
  import type { ModelUsage } from '../model/contracts.js';
2
- import type { EnvironmentContextState } from '../prompts/core.js';
2
+ import type { EnvironmentContextState } from '../runtime/context/contracts.js';
3
3
  import { type CodeModeStateEntry } from '../tools/code-mode/state.js';
4
- import { type TodoSnapshot } from '../tools/todo.js';
4
+ import { type TodoSnapshot } from '../tools/agent/todo.js';
5
5
  import { type ContextGcCheckpointDraft } from './context-gc-checkpoint.js';
6
6
  import type { SessionListInput, SessionSource } from './types.js';
7
7
  export type { SessionListInput, SessionSource } from './types.js';
@@ -6,7 +6,7 @@ import { setTimeout as delay } from 'node:timers/promises';
6
6
  import { isDeepStrictEqual } from 'node:util';
7
7
  import { MarAgentError } from '../error.js';
8
8
  import { applyCodeModeStateMutations, parseCodeModeStateMutations, restoreCodeModeState } from '../tools/code-mode/state.js';
9
- import { todoItemsFromSnapshot } from '../tools/todo.js';
9
+ import { todoItemsFromSnapshot } from '../tools/agent/todo.js';
10
10
  import { contextGcBaseFromRecords, contextGcBaseSequence, contextGcMinimumUsageGrowth, contextGcSourceProjectionHash, latestValidContextGcCheckpoint, normalizeContextGcReplacements, parseContextGcCheckpoint, sameContextGcBase, validateContextGcCheckpoint } from './context-gc-checkpoint.js';
11
11
  import { beginSessionStorageTransaction, isUnjournaledTransactionFile, recoverSessionStorageTransaction } from './transaction-recovery.js';
12
12
  const MAX_SEGMENT_BYTES = 16 * 1024 * 1024;
@@ -0,0 +1,91 @@
1
+ import type { MarAgentReasoningEffort } from '../model/configuration.js';
2
+ export interface SubagentTaskInput {
3
+ description: string;
4
+ prompt: string;
5
+ role: 'general-purpose' | 'explore';
6
+ modelId?: string;
7
+ reasoningEffort?: MarAgentReasoningEffort;
8
+ background?: boolean;
9
+ parentSubagentId?: string;
10
+ }
11
+ export interface SubagentTaskResult {
12
+ summary: string;
13
+ changedFiles: string[];
14
+ verification: string[];
15
+ evidence: Array<{
16
+ path: string;
17
+ startLine?: number;
18
+ endLine?: number;
19
+ }>;
20
+ }
21
+ export interface SubagentLatestMessage {
22
+ itemId: string;
23
+ turnId: string;
24
+ phase: 'commentary' | 'final_answer';
25
+ text: string;
26
+ timestamp: string;
27
+ truncated: boolean;
28
+ }
29
+ export type SubagentLatestActivity = {
30
+ kind: 'message';
31
+ timestamp: string;
32
+ phase: 'commentary' | 'final_answer';
33
+ } | {
34
+ kind: 'tool';
35
+ timestamp: string;
36
+ toolName: string;
37
+ status: 'started' | 'completed' | 'failed';
38
+ };
39
+ export interface SubagentTaskSnapshot extends Record<string, unknown> {
40
+ agentId: string;
41
+ description: string;
42
+ status: 'queued' | 'running' | 'completed' | 'failed' | 'cancelled' | 'interrupted';
43
+ modelId?: string;
44
+ modelName?: string;
45
+ reasoningEffort?: MarAgentReasoningEffort;
46
+ latestMessage?: SubagentLatestMessage;
47
+ latestActivity?: SubagentLatestActivity;
48
+ summary?: string;
49
+ changedFiles?: string[];
50
+ verification?: string[];
51
+ evidence?: Array<{
52
+ path: string;
53
+ startLine?: number;
54
+ endLine?: number;
55
+ }>;
56
+ errorCode?: string;
57
+ errorMessage?: string;
58
+ messageId?: string;
59
+ turnId?: string;
60
+ deliveryStatus?: 'accepted' | 'applied' | 'cancelled' | 'failed';
61
+ waitOutcome?: SubagentWaitOutcome;
62
+ }
63
+ export type SubagentWaitFor = 'completion' | 'message';
64
+ export type SubagentWaitOutcome = 'snapshot' | 'message' | 'completion' | 'timeout';
65
+ export interface SubagentMessageOptions {
66
+ delivery?: 'append' | 'replace';
67
+ signal?: AbortSignal;
68
+ }
69
+ export interface SubagentRunOptions {
70
+ signal?: AbortSignal;
71
+ onCreated?: (task: SubagentTaskSnapshot) => Promise<void> | void;
72
+ }
73
+ export interface SubagentOutputOptions {
74
+ waitMs?: number;
75
+ waitFor?: SubagentWaitFor;
76
+ signal?: AbortSignal;
77
+ }
78
+ export interface SubagentController {
79
+ beginExecution?(runner: (task: SubagentTaskInput, signal: AbortSignal) => Promise<SubagentTaskResult>): void;
80
+ run(input: SubagentTaskInput, options?: SubagentRunOptions): Promise<SubagentTaskSnapshot>;
81
+ output(agentId: string, options?: SubagentOutputOptions): Promise<SubagentTaskSnapshot>;
82
+ outputAny(options?: SubagentOutputOptions): Promise<SubagentTaskSnapshot>;
83
+ message(agentId: string, message: string, options?: SubagentMessageOptions): Promise<SubagentTaskSnapshot>;
84
+ cancel(agentId: string): Promise<SubagentTaskSnapshot>;
85
+ listSessionResources(): readonly {
86
+ agentId: string;
87
+ status: SubagentTaskSnapshot['status'];
88
+ description: string;
89
+ }[];
90
+ dispose(): Promise<void>;
91
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,117 @@
1
+ import type { SubagentController, SubagentOutputOptions, SubagentRunOptions, SubagentTaskInput, SubagentTaskResult, SubagentTaskSnapshot } from './contracts.js';
2
+ export type { SubagentController, SubagentLatestActivity, SubagentLatestMessage, SubagentMessageOptions, SubagentOutputOptions, SubagentRunOptions, SubagentTaskInput, SubagentTaskResult, SubagentTaskSnapshot, SubagentWaitFor, SubagentWaitOutcome } from './contracts.js';
3
+ export declare class SubagentScheduler implements SubagentController {
4
+ #private;
5
+ readonly limits: {
6
+ maxTasks: number;
7
+ maxConcurrent: number;
8
+ };
9
+ constructor(runner: (task: SubagentTaskInput, signal: AbortSignal) => Promise<SubagentTaskResult>, limits?: {
10
+ maxTasks: number;
11
+ maxConcurrent: number;
12
+ });
13
+ beginExecution(runner: (task: SubagentTaskInput, signal: AbortSignal) => Promise<SubagentTaskResult>): void;
14
+ run(input: SubagentTaskInput, options?: SubagentRunOptions): Promise<SubagentTaskSnapshot>;
15
+ output(agentId: string, options?: SubagentOutputOptions): Promise<{
16
+ waitOutcome: "snapshot";
17
+ agentId: string;
18
+ description: string;
19
+ status: "queued" | "running" | "completed" | "failed" | "cancelled" | "interrupted";
20
+ modelId?: string;
21
+ modelName?: string;
22
+ reasoningEffort?: import("../model/configuration.js").MarAgentReasoningEffort;
23
+ latestMessage?: import("./contracts.js").SubagentLatestMessage;
24
+ latestActivity?: import("./contracts.js").SubagentLatestActivity;
25
+ summary?: string;
26
+ changedFiles?: string[];
27
+ verification?: string[];
28
+ evidence?: Array<{
29
+ path: string;
30
+ startLine?: number;
31
+ endLine?: number;
32
+ }>;
33
+ errorCode?: string;
34
+ errorMessage?: string;
35
+ messageId?: string;
36
+ turnId?: string;
37
+ deliveryStatus?: "accepted" | "applied" | "cancelled" | "failed";
38
+ } | {
39
+ waitOutcome: "completion" | "timeout";
40
+ agentId: string;
41
+ description: string;
42
+ status: "queued" | "running" | "completed" | "failed" | "cancelled" | "interrupted";
43
+ modelId?: string;
44
+ modelName?: string;
45
+ reasoningEffort?: import("../model/configuration.js").MarAgentReasoningEffort;
46
+ latestMessage?: import("./contracts.js").SubagentLatestMessage;
47
+ latestActivity?: import("./contracts.js").SubagentLatestActivity;
48
+ summary?: string;
49
+ changedFiles?: string[];
50
+ verification?: string[];
51
+ evidence?: Array<{
52
+ path: string;
53
+ startLine?: number;
54
+ endLine?: number;
55
+ }>;
56
+ errorCode?: string;
57
+ errorMessage?: string;
58
+ messageId?: string;
59
+ turnId?: string;
60
+ deliveryStatus?: "accepted" | "applied" | "cancelled" | "failed";
61
+ }>;
62
+ outputAny(options?: SubagentOutputOptions): Promise<{
63
+ waitOutcome: "snapshot";
64
+ agentId: string;
65
+ description: string;
66
+ status: "queued" | "running" | "completed" | "failed" | "cancelled" | "interrupted";
67
+ modelId?: string;
68
+ modelName?: string;
69
+ reasoningEffort?: import("../model/configuration.js").MarAgentReasoningEffort;
70
+ latestMessage?: import("./contracts.js").SubagentLatestMessage;
71
+ latestActivity?: import("./contracts.js").SubagentLatestActivity;
72
+ summary?: string;
73
+ changedFiles?: string[];
74
+ verification?: string[];
75
+ evidence?: Array<{
76
+ path: string;
77
+ startLine?: number;
78
+ endLine?: number;
79
+ }>;
80
+ errorCode?: string;
81
+ errorMessage?: string;
82
+ messageId?: string;
83
+ turnId?: string;
84
+ deliveryStatus?: "accepted" | "applied" | "cancelled" | "failed";
85
+ } | {
86
+ waitOutcome: "completion" | "timeout";
87
+ agentId: string;
88
+ description: string;
89
+ status: "queued" | "running" | "completed" | "failed" | "cancelled" | "interrupted";
90
+ modelId?: string;
91
+ modelName?: string;
92
+ reasoningEffort?: import("../model/configuration.js").MarAgentReasoningEffort;
93
+ latestMessage?: import("./contracts.js").SubagentLatestMessage;
94
+ latestActivity?: import("./contracts.js").SubagentLatestActivity;
95
+ summary?: string;
96
+ changedFiles?: string[];
97
+ verification?: string[];
98
+ evidence?: Array<{
99
+ path: string;
100
+ startLine?: number;
101
+ endLine?: number;
102
+ }>;
103
+ errorCode?: string;
104
+ errorMessage?: string;
105
+ messageId?: string;
106
+ turnId?: string;
107
+ deliveryStatus?: "accepted" | "applied" | "cancelled" | "failed";
108
+ }>;
109
+ cancel(agentId: string): Promise<SubagentTaskSnapshot>;
110
+ message(_agentId: string, _message: string): Promise<SubagentTaskSnapshot>;
111
+ listSessionResources(): {
112
+ agentId: string;
113
+ status: "completed" | "failed" | "cancelled" | "running" | "queued";
114
+ description: string;
115
+ }[];
116
+ dispose(): Promise<void>;
117
+ }
@@ -1,5 +1,6 @@
1
1
  import type { MarAgentReasoningEffort } from '../model/configuration.js';
2
- import type { MarAgentEvent, ExecutionResult } from '../sdk/types.js';
2
+ import type { ExecutionResult } from '../runtime/contracts.js';
3
+ import type { MarAgentEvent } from '../runtime/events.js';
3
4
  import type { SessionRecord, SessionSource } from '../session/jsonl-store.js';
4
5
  import type { SubagentController, SubagentMessageOptions, SubagentOutputOptions, SubagentRunOptions, SubagentTaskInput, SubagentTaskSnapshot } from './scheduler.js';
5
6
  export interface SubagentModelOption {
@@ -93,7 +94,7 @@ export declare class SubagentSessionController implements SubagentController {
93
94
  cancel(agentId: string): Promise<SubagentTaskSnapshot>;
94
95
  listSessionResources(): {
95
96
  agentId: string;
96
- status: "completed" | "cancelled" | "running" | "queued" | "failed" | "interrupted";
97
+ status: "completed" | "failed" | "cancelled" | "running" | "queued" | "interrupted";
97
98
  description: string;
98
99
  }[];
99
100
  dispose(): Promise<void>;
@@ -0,0 +1,7 @@
1
+ import type { ClientToolDefinition } from '../../model/contracts.js';
2
+ import type { ToolRuntimeContext } from '../runtime-context.js';
3
+ export declare const agentCancelToolDefinition: ClientToolDefinition;
4
+ export declare function executeAgentCancel(arguments_: unknown, context: ToolRuntimeContext): Promise<{
5
+ content: string;
6
+ data: import("../../subagent/contracts.js").SubagentTaskSnapshot;
7
+ }>;
@@ -1,4 +1,4 @@
1
- import { MarAgentError } from '../error.js';
1
+ import { MarAgentError } from '../../error.js';
2
2
  export const agentCancelToolDefinition = {
3
3
  name: 'agent_cancel',
4
4
  allowedCallers: ['direct', 'programmatic'],
@@ -0,0 +1,7 @@
1
+ import type { ClientToolDefinition } from '../../model/contracts.js';
2
+ import type { ToolRuntimeContext } from '../runtime-context.js';
3
+ export declare const agentMessageToolDefinition: ClientToolDefinition;
4
+ export declare function executeAgentMessage(arguments_: unknown, context: ToolRuntimeContext): Promise<{
5
+ content: string;
6
+ data: import("../../subagent/contracts.js").SubagentTaskSnapshot;
7
+ }>;
@@ -1,5 +1,5 @@
1
- import { MarAgentError } from '../error.js';
2
- import { TOOL_EXECUTION_LIMITS } from './execution-limits.js';
1
+ import { MarAgentError } from '../../error.js';
2
+ import { TOOL_EXECUTION_LIMITS } from '../execution-limits.js';
3
3
  export const agentMessageToolDefinition = {
4
4
  name: 'agent_message',
5
5
  allowedCallers: ['direct', 'programmatic'],
@@ -1,5 +1,5 @@
1
- import type { ClientToolDefinition } from '../model/contracts.js';
2
- import type { ToolRuntimeContext } from './runtime-context.js';
1
+ import type { ClientToolDefinition } from '../../model/contracts.js';
2
+ import type { ToolRuntimeContext } from '../runtime-context.js';
3
3
  export declare const agentStartToolDefinition: ClientToolDefinition;
4
4
  export declare function agentStartToolDefinitionWithModels(models: readonly {
5
5
  readonly id: string;
@@ -8,5 +8,5 @@ export declare function agentStartToolDefinitionWithModels(models: readonly {
8
8
  }[]): ClientToolDefinition;
9
9
  export declare function executeAgentStart(arguments_: unknown, context: ToolRuntimeContext): Promise<{
10
10
  content: string;
11
- data: import("../subagent/scheduler.js").SubagentTaskSnapshot;
11
+ data: import("../../subagent/contracts.js").SubagentTaskSnapshot;
12
12
  }>;
@@ -1,6 +1,6 @@
1
- import { MarAgentError } from '../error.js';
2
- import { marAgentReasoningEffortSchema } from '../model/configuration.js';
3
- import { TOOL_EXECUTION_LIMITS } from './execution-limits.js';
1
+ import { MarAgentError } from '../../error.js';
2
+ import { marAgentReasoningEffortSchema } from '../../model/configuration.js';
3
+ import { TOOL_EXECUTION_LIMITS } from '../execution-limits.js';
4
4
  export const agentStartToolDefinition = {
5
5
  name: 'agent_start',
6
6
  allowedCallers: ['direct', 'programmatic'],
@@ -0,0 +1,7 @@
1
+ import type { ClientToolDefinition } from '../../model/contracts.js';
2
+ import type { ToolRuntimeContext } from '../runtime-context.js';
3
+ export declare const agentWaitToolDefinition: ClientToolDefinition;
4
+ export declare function executeAgentWait(arguments_: unknown, context: ToolRuntimeContext): Promise<{
5
+ content: string;
6
+ data: import("../../subagent/contracts.js").SubagentTaskSnapshot;
7
+ }>;
@@ -1,5 +1,5 @@
1
- import { MarAgentError } from '../error.js';
2
- import { TOOL_EXECUTION_LIMITS } from './execution-limits.js';
1
+ import { MarAgentError } from '../../error.js';
2
+ import { TOOL_EXECUTION_LIMITS } from '../execution-limits.js';
3
3
  export const agentWaitToolDefinition = {
4
4
  name: 'agent_wait',
5
5
  allowedCallers: ['direct', 'programmatic'],
@@ -1,5 +1,5 @@
1
- import type { ClientToolDefinition } from '../model/contracts.js';
2
- import type { ToolRuntimeContext } from './runtime-context.js';
1
+ import type { ClientToolDefinition } from '../../model/contracts.js';
2
+ import type { ToolRuntimeContext } from '../runtime-context.js';
3
3
  export declare const questionToolDefinition: ClientToolDefinition;
4
4
  export declare function executeQuestion(arguments_: unknown, context: ToolRuntimeContext): Promise<{
5
5
  content: string;
@@ -1,6 +1,6 @@
1
1
  import { randomUUID } from 'node:crypto';
2
- import { MarAgentError } from '../error.js';
3
- import { TOOL_EXECUTION_LIMITS } from './execution-limits.js';
2
+ import { MarAgentError } from '../../error.js';
3
+ import { TOOL_EXECUTION_LIMITS } from '../execution-limits.js';
4
4
  export const questionToolDefinition = {
5
5
  name: 'question',
6
6
  allowedCallers: ['direct'],
@@ -1,5 +1,5 @@
1
- import type { ClientToolDefinition } from '../model/contracts.js';
2
- import type { ToolRuntimeContext } from './runtime-context.js';
1
+ import type { ClientToolDefinition } from '../../model/contracts.js';
2
+ import type { ToolRuntimeContext } from '../runtime-context.js';
3
3
  export declare const skillToolDefinition: ClientToolDefinition;
4
4
  export declare function executeSkill(arguments_: unknown, context: ToolRuntimeContext): Promise<{
5
5
  content: string;
@@ -1,5 +1,5 @@
1
- import { MarAgentError } from '../error.js';
2
- import { agentSkillSource, loadAgentSkill } from '../runtime/instructions.js';
1
+ import { MarAgentError } from '../../error.js';
2
+ import { agentSkillSource, loadAgentSkill } from '../../runtime/context/instructions.js';
3
3
  export const skillToolDefinition = {
4
4
  name: 'skill',
5
5
  allowedCallers: ['direct'],
@@ -1,5 +1,5 @@
1
- import type { ClientToolDefinition } from '../model/contracts.js';
2
- import type { ToolRuntimeContext } from './runtime-context.js';
1
+ import type { ClientToolDefinition } from '../../model/contracts.js';
2
+ import type { ToolRuntimeContext } from '../runtime-context.js';
3
3
  export declare const todoReadToolDefinition: ClientToolDefinition;
4
4
  export declare function executeTodoRead(context: ToolRuntimeContext): Promise<{
5
5
  content: string;
@@ -1,5 +1,5 @@
1
- import type { ClientToolDefinition } from '../model/contracts.js';
2
- import type { ToolRuntimeContext } from './runtime-context.js';
1
+ import type { ClientToolDefinition } from '../../model/contracts.js';
2
+ import type { ToolRuntimeContext } from '../runtime-context.js';
3
3
  export declare const todoWriteToolDefinition: ClientToolDefinition;
4
4
  export declare function executeTodoWrite(arguments_: unknown, context: ToolRuntimeContext): Promise<{
5
5
  content: string;
@@ -1,5 +1,5 @@
1
- import { MarAgentError } from '../error.js';
2
- import { TOOL_EXECUTION_LIMITS } from './execution-limits.js';
1
+ import { MarAgentError } from '../../error.js';
2
+ import { TOOL_EXECUTION_LIMITS } from '../execution-limits.js';
3
3
  export const todoWriteToolDefinition = {
4
4
  name: 'todo_write',
5
5
  allowedCallers: ['direct', 'programmatic'],
@@ -1,12 +1,5 @@
1
- export interface TodoItem {
2
- id: string;
3
- step: string;
4
- status: 'pending' | 'in_progress' | 'completed';
5
- }
6
- export interface TodoSnapshot {
7
- revision: number;
8
- items: TodoItem[];
9
- }
1
+ import type { TodoItem, TodoSnapshot } from '../contracts.js';
2
+ export type { TodoItem, TodoSnapshot } from '../contracts.js';
10
3
  export declare class TodoStore {
11
4
  #private;
12
5
  static restore(snapshot: TodoSnapshot): TodoStore;
@@ -1,4 +1,4 @@
1
- import { MarAgentError } from '../error.js';
1
+ import { MarAgentError } from '../../error.js';
2
2
  export class TodoStore {
3
3
  #revision = 0;
4
4
  #items = [];
@@ -1,5 +1,5 @@
1
1
  import { MarAgentError } from '../../error.js';
2
- import type { ToolExecutionContext, ToolExecutionResult } from '../../sdk/types.js';
2
+ import type { ToolExecutionContext, ToolExecutionResult } from '../contracts.js';
3
3
  export interface CellOutput {
4
4
  text(value: string, originalBytes?: number): void;
5
5
  image(value: NonNullable<ToolExecutionResult['images']>[number]): void;
@@ -1,5 +1,6 @@
1
1
  import type { ClientToolDefinition } from '../../model/contracts.js';
2
- import type { MarAgentEvent, ToolCall, ToolExecutionResult, McpToolCallContext } from '../../sdk/types.js';
2
+ import type { MarAgentEvent } from '../../runtime/events.js';
3
+ import type { McpToolCallContext, ToolCall, ToolExecutionResult } from '../contracts.js';
3
4
  import type { ToolRuntimeContext } from '../runtime-context.js';
4
5
  import type { createSessionToolScheduler } from '../scheduler.js';
5
6
  type ToolEvent = Extract<MarAgentEvent, {
@@ -14,8 +15,5 @@ export declare function createCodeToolDispatch(input: {
14
15
  parentCallId: string;
15
16
  schedule: ReturnType<typeof createSessionToolScheduler>;
16
17
  emit: (event: Payload) => Promise<void>;
17
- projectData: (name: string, data: unknown) => Extract<ToolEvent, {
18
- type: 'tool.completed';
19
- }>['data'];
20
18
  }): (call: ToolCall, signal: AbortSignal) => Promise<ToolExecutionResult>;
21
19
  export {};
@@ -1,9 +1,10 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import { MarAgentError, describeMarAgentError } from '../../error.js';
3
- import { executeRegisteredTool } from '../runtime.js';
4
- import { allowsToolCaller } from '../callers.js';
5
- import { truncateModelText } from '../../runtime/token-budget.js';
6
3
  import { AGENT_EXECUTION_POLICY } from '../../runtime/execution-policy.js';
4
+ import { truncateModelText } from '../../runtime/token-budget.js';
5
+ import { allowsToolCaller } from '../callers.js';
6
+ import { structuredToolEventData } from '../output-projection.js';
7
+ import { executeRegisteredTool } from '../runtime.js';
7
8
  /** Capture only the cell's immutable dispatch identity, never the model loop or its AbortSignal. */
8
9
  export function createCodeToolDispatch(input) {
9
10
  const definitions = new Map(input.tools.map((tool) => [tool.name, tool]));
@@ -24,7 +25,7 @@ export function createCodeToolDispatch(input) {
24
25
  ...(expected ? { expectedMcpTool: expected } : {})
25
26
  });
26
27
  const bounded = truncateModelText(result.content, AGENT_EXECUTION_POLICY.modelToolOutputTokens);
27
- const data = input.projectData(call.name, result.data);
28
+ const data = structuredToolEventData(call.name, result.data);
28
29
  const summary = result.content.slice(0, AGENT_EXECUTION_POLICY.toolEventSummaryCharacters);
29
30
  await input.emit({
30
31
  type: 'tool.completed',
@@ -1,4 +1,4 @@
1
- import type { ToolCall, ToolExecutionResult } from '../../sdk/types.js';
1
+ import type { ToolCall, ToolExecutionResult } from '../contracts.js';
2
2
  import type { CodeModeStateEntry, CodeModeStateMutation } from './state.js';
3
3
  export type ProgrammaticToolResult = Omit<ToolExecutionResult, 'content'> & {
4
4
  content?: string;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,9 +1,9 @@
1
- import { type LocalProcessExecutor } from '../host/local-process-executor.js';
2
- import type { ClientToolDefinition, ModelMessage } from '../model/contracts.js';
3
- import type { ToolExecutionContext, ToolExecutionResult } from '../sdk/types.js';
4
- import { WorkspacePathResolver } from './shared/path-resolver.js';
5
- import type { CodeModeEngineFactory } from './code-mode/engine.js';
6
- import { type CellOutput } from './code-mode/cells.js';
1
+ import { type LocalProcessExecutor } from '../../host/local-process-executor.js';
2
+ import type { ClientToolDefinition, ModelMessage } from '../../model/contracts.js';
3
+ import { type CellOutput } from './cells.js';
4
+ import type { CodeModeEngineFactory } from './engine.js';
5
+ import type { ToolExecutionContext, ToolExecutionResult } from '../contracts.js';
6
+ import { WorkspacePathResolver } from '../shared/path-resolver.js';
7
7
  export declare const codeModeToolDefinition: ClientToolDefinition;
8
8
  export declare const codeExecWaitToolDefinition: ClientToolDefinition;
9
9
  /** Deferred definitions travel in search results, not in the stable Code Mode description. */
@@ -20,7 +20,7 @@ export declare class CodeModeTool {
20
20
  wait(value: unknown, context: ToolExecutionContext): Promise<ToolExecutionResult>;
21
21
  listSessionResources(sessionId: string): {
22
22
  cellId: string;
23
- status: "completed" | "cancelled" | "running" | "failed";
23
+ status: "completed" | "failed" | "cancelled" | "running";
24
24
  executionId: string;
25
25
  }[];
26
26
  constructor(paths: WorkspacePathResolver, environment?: NodeJS.ProcessEnv, executor?: LocalProcessExecutor, engineFactory?: CodeModeEngineFactory);