@myagentroam/agent 0.9.140 → 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.
- package/dist/agent-core/host/contracts.d.ts +64 -0
- package/dist/{host → agent-core/host}/local-agent-host.d.ts +6 -5
- package/dist/{host → agent-core/host}/local-agent-host.js +4 -4
- package/dist/{model → agent-core/model}/anthropic-messages.js +24 -7
- package/dist/{model → agent-core/model}/contracts.d.ts +6 -16
- package/dist/{model → agent-core/model}/openai-responses.js +28 -10
- package/dist/agent-core/model/recovery.d.ts +4 -0
- package/dist/agent-core/model/recovery.js +71 -0
- package/dist/{model → agent-core/model}/sse.d.ts +2 -0
- package/dist/{model → agent-core/model}/sse.js +11 -1
- package/dist/{prompts → agent-core/prompts}/core.d.ts +3 -13
- package/dist/{prompts → agent-core/prompts}/index.d.ts +1 -1
- package/dist/{prompts → agent-core/prompts}/modes.d.ts +1 -1
- package/dist/{prompts → agent-core/prompts}/resources.d.ts +1 -1
- package/dist/{runtime/compact.d.ts → agent-core/runtime/compaction/history.d.ts} +2 -23
- package/dist/{runtime/compact.js → agent-core/runtime/compaction/history.js} +2 -92
- package/dist/agent-core/runtime/compaction/operation.d.ts +22 -0
- package/dist/agent-core/runtime/compaction/operation.js +91 -0
- package/dist/agent-core/runtime/context/contracts.d.ts +12 -0
- package/dist/{runtime/environment-context.d.ts → agent-core/runtime/context/environment.d.ts} +2 -2
- package/dist/{runtime/environment-context.js → agent-core/runtime/context/environment.js} +1 -1
- package/dist/{runtime/context-gc-runtime.d.ts → agent-core/runtime/context/gc-runtime.d.ts} +4 -4
- package/dist/{runtime/context-gc-runtime.js → agent-core/runtime/context/gc-runtime.js} +3 -3
- package/dist/{runtime/context-gc-tokens.d.ts → agent-core/runtime/context/gc-tokens.d.ts} +2 -2
- package/dist/{runtime/context-gc-tokens.js → agent-core/runtime/context/gc-tokens.js} +3 -3
- package/dist/{runtime/context-gc.d.ts → agent-core/runtime/context/gc.d.ts} +3 -3
- package/dist/{runtime/context-gc.js → agent-core/runtime/context/gc.js} +6 -6
- package/dist/{runtime → agent-core/runtime/context}/instructions.d.ts +1 -1
- package/dist/{runtime → agent-core/runtime/context}/instructions.js +1 -1
- package/dist/{runtime → agent-core/runtime/context}/normalize.d.ts +1 -1
- package/dist/{runtime/context-projection.d.ts → agent-core/runtime/context/projection.d.ts} +3 -3
- package/dist/{runtime/context-projection.js → agent-core/runtime/context/projection.js} +4 -4
- package/dist/agent-core/runtime/context/request-budget.d.ts +6 -0
- package/dist/agent-core/runtime/context/request-budget.js +22 -0
- package/dist/agent-core/runtime/context/restore.d.ts +15 -0
- package/dist/agent-core/runtime/context/restore.js +85 -0
- package/dist/agent-core/runtime/context/usage.d.ts +18 -0
- package/dist/agent-core/runtime/context/usage.js +138 -0
- package/dist/agent-core/runtime/context/world-state.d.ts +35 -0
- package/dist/agent-core/runtime/context/world-state.js +133 -0
- package/dist/agent-core/runtime/contracts.d.ts +37 -0
- package/dist/agent-core/runtime/event-projection.d.ts +5 -0
- package/dist/agent-core/runtime/event-projection.js +17 -0
- package/dist/agent-core/runtime/events.d.ts +142 -0
- package/dist/agent-core/runtime/execution.d.ts +50 -0
- package/dist/agent-core/runtime/execution.js +393 -0
- package/dist/{runtime → agent-core/runtime}/rollout-budget.d.ts +1 -1
- package/dist/agent-core/sdk/agent.js +209 -0
- package/dist/agent-core/sdk/model-runtime.d.ts +13 -0
- package/dist/agent-core/sdk/model-runtime.js +63 -0
- package/dist/agent-core/sdk/session-title.d.ts +3 -0
- package/dist/agent-core/sdk/session-title.js +42 -0
- package/dist/agent-core/sdk/session.d.ts +62 -0
- package/dist/agent-core/sdk/session.js +1147 -0
- package/dist/agent-core/sdk/subagent-backend.d.ts +3 -0
- package/dist/agent-core/sdk/subagent-backend.js +46 -0
- package/dist/agent-core/sdk/types.d.ts +56 -0
- package/dist/{session → agent-core/session}/catalog.d.ts +2 -1
- package/dist/{session → agent-core/session}/context-gc-checkpoint.js +1 -1
- package/dist/{session → agent-core/session}/jsonl-store.d.ts +2 -2
- package/dist/{session → agent-core/session}/jsonl-store.js +1 -1
- package/dist/agent-core/subagent/contracts.d.ts +91 -0
- package/dist/agent-core/subagent/contracts.js +1 -0
- package/dist/agent-core/subagent/scheduler.d.ts +117 -0
- package/dist/{subagent → agent-core/subagent}/session-controller.d.ts +3 -2
- package/dist/agent-core/tools/agent/agent-cancel.d.ts +7 -0
- package/dist/{tools → agent-core/tools/agent}/agent-cancel.js +1 -1
- package/dist/agent-core/tools/agent/agent-message.d.ts +7 -0
- package/dist/{tools → agent-core/tools/agent}/agent-message.js +2 -2
- package/dist/{tools → agent-core/tools/agent}/agent-start.d.ts +3 -3
- package/dist/{tools → agent-core/tools/agent}/agent-start.js +3 -3
- package/dist/agent-core/tools/agent/agent-wait.d.ts +7 -0
- package/dist/{tools → agent-core/tools/agent}/agent-wait.js +2 -2
- package/dist/{tools → agent-core/tools/agent}/question.d.ts +2 -2
- package/dist/{tools → agent-core/tools/agent}/question.js +2 -2
- package/dist/{tools → agent-core/tools/agent}/skill.d.ts +2 -2
- package/dist/{tools → agent-core/tools/agent}/skill.js +2 -2
- package/dist/{tools → agent-core/tools/agent}/todo-read.d.ts +2 -2
- package/dist/{tools → agent-core/tools/agent}/todo-write.d.ts +2 -2
- package/dist/{tools → agent-core/tools/agent}/todo-write.js +2 -2
- package/dist/{tools → agent-core/tools/agent}/todo.d.ts +2 -9
- package/dist/{tools → agent-core/tools/agent}/todo.js +1 -1
- package/dist/{tools → agent-core/tools}/code-mode/cells.d.ts +1 -1
- package/dist/{tools → agent-core/tools}/code-mode/dispatch.d.ts +2 -4
- package/dist/{tools → agent-core/tools}/code-mode/dispatch.js +5 -4
- package/dist/{tools → agent-core/tools}/code-mode/engine.d.ts +1 -1
- package/dist/agent-core/tools/code-mode/engine.js +1 -0
- package/dist/{tools/code-mode.d.ts → agent-core/tools/code-mode/index.d.ts} +7 -7
- package/dist/{tools/code-mode.js → agent-core/tools/code-mode/index.js} +15 -16
- package/dist/{tools → agent-core/tools}/code-mode/quickjs-engine.js +12 -2
- package/dist/{tools → agent-core/tools}/code-mode/state.d.ts +2 -13
- package/dist/agent-core/tools/code-mode/worker.d.ts +1 -0
- package/dist/agent-core/tools/contracts.d.ts +168 -0
- package/dist/agent-core/tools/contracts.js +1 -0
- package/dist/agent-core/tools/execution.d.ts +34 -0
- package/dist/agent-core/tools/execution.js +102 -0
- package/dist/agent-core/tools/local/apply-patch.d.ts +19 -0
- package/dist/{tools → agent-core/tools/local}/apply-patch.js +8 -2
- package/dist/{tools → agent-core/tools/local}/exec.d.ts +5 -17
- package/dist/{tools → agent-core/tools/local}/exec.js +4 -4
- package/dist/{tools → agent-core/tools/local}/read.d.ts +7 -15
- package/dist/{tools → agent-core/tools/local}/read.js +185 -2
- package/dist/{tools/local-registry.d.ts → agent-core/tools/local/registry.d.ts} +5 -5
- package/dist/agent-core/tools/local/registry.js +101 -0
- package/dist/{tools → agent-core/tools/local}/view-image.d.ts +4 -9
- package/dist/{tools → agent-core/tools/local}/view-image.js +2 -2
- package/dist/agent-core/tools/local/web-fetch.d.ts +4 -0
- package/dist/agent-core/tools/local/web-fetch.js +85 -0
- package/dist/agent-core/tools/local/web-search.d.ts +7 -0
- package/dist/agent-core/tools/local/web-search.js +34 -0
- package/dist/{tools/local-workspace-tools.js → agent-core/tools/local/workspace-tools.js} +1 -1
- package/dist/{sdk/mcp-catalog.d.ts → agent-core/tools/mcp/catalog.d.ts} +1 -2
- package/dist/{sdk/mcp-catalog.js → agent-core/tools/mcp/catalog.js} +1 -1
- package/dist/agent-core/tools/mcp/history.d.ts +4 -0
- package/dist/agent-core/tools/mcp/history.js +33 -0
- package/dist/{tools → agent-core/tools/mcp}/tool-search.d.ts +3 -3
- package/dist/{tools → agent-core/tools/mcp}/tool-search.js +4 -4
- package/dist/agent-core/tools/output-projection.d.ts +14 -0
- package/dist/agent-core/tools/output-projection.js +189 -0
- package/dist/{tools → agent-core/tools}/registry.d.ts +1 -1
- package/dist/agent-core/tools/registry.js +47 -0
- package/dist/{tools → agent-core/tools}/runtime-context.d.ts +8 -7
- package/dist/agent-core/tools/runtime-context.js +1 -0
- package/dist/{tools → agent-core/tools}/runtime.d.ts +1 -1
- package/dist/cli/codex-auth-file.d.ts +1 -1
- package/dist/cli/codex-auth-file.js +2 -2
- package/dist/cli/main.js +9 -9
- package/dist/index.d.ts +17 -15
- package/dist/index.js +8 -8
- package/dist/sandbox/linux/bubblewrap-sandbox-executor.d.ts +1 -1
- package/dist/sandbox/linux/bubblewrap-sandbox-executor.js +1 -1
- package/package.json +3 -3
- package/dist/host/contracts.d.ts +0 -21
- package/dist/sdk/agent.js +0 -2524
- package/dist/sdk/types.d.ts +0 -349
- package/dist/subagent/scheduler.d.ts +0 -206
- package/dist/tools/agent-cancel.d.ts +0 -7
- package/dist/tools/agent-message.d.ts +0 -7
- package/dist/tools/agent-wait.d.ts +0 -7
- package/dist/tools/apply-patch.d.ts +0 -32
- package/dist/tools/local-registry.js +0 -373
- package/dist/tools/registry.js +0 -47
- package/dist/tools/web-fetch.d.ts +0 -2
- package/dist/tools/web-fetch.js +0 -12
- package/dist/tools/web-search.d.ts +0 -2
- package/dist/tools/web-search.js +0 -15
- package/dist/{error.d.ts → agent-core/error.d.ts} +0 -0
- package/dist/{error.js → agent-core/error.js} +0 -0
- package/dist/{host → agent-core/host}/contracts.js +0 -0
- package/dist/{host → agent-core/host}/local-process-executor.d.ts +0 -0
- package/dist/{host → agent-core/host}/local-process-executor.js +0 -0
- package/dist/{host → agent-core/host}/network.d.ts +0 -0
- package/dist/{host → agent-core/host}/network.js +0 -0
- package/dist/{model → agent-core/model}/anthropic-messages.d.ts +0 -0
- package/dist/{model → agent-core/model}/anthropic-thinking.d.ts +0 -0
- package/dist/{model → agent-core/model}/anthropic-thinking.js +0 -0
- package/dist/{model → agent-core/model}/catalog-file.d.ts +0 -0
- package/dist/{model → agent-core/model}/catalog-file.js +0 -0
- package/dist/{model → agent-core/model}/configuration.d.ts +0 -0
- package/dist/{model → agent-core/model}/configuration.js +0 -0
- package/dist/{model → agent-core/model}/contracts.js +0 -0
- package/dist/{model → agent-core/model}/http.d.ts +0 -0
- package/dist/{model → agent-core/model}/http.js +0 -0
- package/dist/{model → agent-core/model}/openai-responses.d.ts +0 -0
- package/dist/{model → agent-core/model}/runtime-credential.d.ts +0 -0
- package/dist/{model → agent-core/model}/runtime-credential.js +0 -0
- package/dist/{model → agent-core/model}/transport-test.d.ts +0 -0
- package/dist/{model → agent-core/model}/transport-test.js +0 -0
- package/dist/{prompts → agent-core/prompts}/compact.d.ts +0 -0
- package/dist/{prompts → agent-core/prompts}/compact.js +0 -0
- package/dist/{prompts → agent-core/prompts}/core.js +0 -0
- package/dist/{prompts → agent-core/prompts}/execution-budget.d.ts +0 -0
- package/dist/{prompts → agent-core/prompts}/execution-budget.js +0 -0
- package/dist/{prompts → agent-core/prompts}/index.js +0 -0
- package/dist/{prompts → agent-core/prompts}/modes.js +0 -0
- package/dist/{prompts → agent-core/prompts}/output.d.ts +0 -0
- package/dist/{prompts → agent-core/prompts}/output.js +0 -0
- package/dist/{prompts → agent-core/prompts}/resources.js +0 -0
- package/dist/{prompts → agent-core/prompts}/subagent.d.ts +0 -0
- package/dist/{prompts → agent-core/prompts}/subagent.js +0 -0
- package/dist/{prompts → agent-core/prompts}/title.d.ts +0 -0
- package/dist/{prompts → agent-core/prompts}/title.js +0 -0
- package/dist/{prompts → agent-core/prompts}/workflow.d.ts +0 -0
- package/dist/{prompts → agent-core/prompts}/workflow.js +0 -0
- package/dist/{runtime → agent-core/runtime}/async-queue.d.ts +0 -0
- package/dist/{runtime → agent-core/runtime}/async-queue.js +0 -0
- package/dist/{sdk/types.js → agent-core/runtime/context/contracts.js} +0 -0
- package/dist/{runtime → agent-core/runtime/context}/normalize.js +0 -0
- package/dist/{session/types.js → agent-core/runtime/contracts.js} +0 -0
- package/dist/{tools/code-mode/engine.js → agent-core/runtime/events.js} +0 -0
- package/dist/{runtime → agent-core/runtime}/execution-policy.d.ts +0 -0
- package/dist/{runtime → agent-core/runtime}/execution-policy.js +0 -0
- package/dist/{runtime → agent-core/runtime}/plan-output.d.ts +0 -0
- package/dist/{runtime → agent-core/runtime}/plan-output.js +0 -0
- package/dist/{runtime → agent-core/runtime}/rollout-budget.js +0 -0
- package/dist/{runtime → agent-core/runtime}/token-budget.d.ts +0 -0
- package/dist/{runtime → agent-core/runtime}/token-budget.js +0 -0
- package/dist/{sdk → agent-core/sdk}/agent.d.ts +0 -0
- package/dist/{tools/code-mode/worker.d.ts → agent-core/sdk/types.js} +0 -0
- package/dist/{session → agent-core/session}/catalog.js +0 -0
- package/dist/{session → agent-core/session}/context-gc-checkpoint.d.ts +0 -0
- package/dist/{session → agent-core/session}/context-gc-replacements.d.ts +0 -0
- package/dist/{session → agent-core/session}/context-gc-replacements.js +0 -0
- package/dist/{session → agent-core/session}/context-gc-subagent.d.ts +0 -0
- package/dist/{session → agent-core/session}/context-gc-subagent.js +0 -0
- package/dist/{session → agent-core/session}/transaction-recovery.d.ts +0 -0
- package/dist/{session → agent-core/session}/transaction-recovery.js +0 -0
- package/dist/{session → agent-core/session}/types.d.ts +0 -0
- package/dist/{tools/runtime-context.js → agent-core/session/types.js} +0 -0
- package/dist/{subagent → agent-core/subagent}/scheduler.js +0 -0
- package/dist/{subagent → agent-core/subagent}/session-controller.js +0 -0
- package/dist/{tools → agent-core/tools/agent}/todo-read.js +0 -0
- package/dist/{tools → agent-core/tools}/callers.d.ts +0 -0
- package/dist/{tools → agent-core/tools}/callers.js +0 -0
- package/dist/{tools → agent-core/tools}/code-mode/cells.js +1 -1
- /package/dist/{tools → agent-core/tools}/code-mode/quickjs-engine.d.ts +0 -0
- /package/dist/{tools → agent-core/tools}/code-mode/state.js +0 -0
- /package/dist/{tools → agent-core/tools}/code-mode/text-output.d.ts +0 -0
- /package/dist/{tools → agent-core/tools}/code-mode/text-output.js +0 -0
- /package/dist/{tools → agent-core/tools}/code-mode/worker.js +0 -0
- /package/dist/{tools → agent-core/tools}/execution-limits.d.ts +0 -0
- /package/dist/{tools → agent-core/tools}/execution-limits.js +0 -0
- /package/dist/{tools → agent-core/tools/local}/read-context.d.ts +0 -0
- /package/dist/{tools → agent-core/tools/local}/read-context.js +0 -0
- /package/dist/{tools/local-workspace-tools.d.ts → agent-core/tools/local/workspace-tools.d.ts} +0 -0
- /package/dist/{tools → agent-core/tools}/runtime.js +0 -0
- /package/dist/{tools → agent-core/tools}/scheduler.d.ts +0 -0
- /package/dist/{tools → agent-core/tools}/scheduler.js +0 -0
- /package/dist/{tools → agent-core/tools}/shared/path-resolver.d.ts +0 -0
- /package/dist/{tools → agent-core/tools}/shared/path-resolver.js +0 -0
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import { createRequire } from 'node:module';
|
|
3
|
-
import { pathToFileURL } from 'node:url';
|
|
4
2
|
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
5
4
|
import { dirname, sep } from 'node:path';
|
|
6
|
-
import { fileURLToPath } from 'node:url';
|
|
7
5
|
import { StringDecoder } from 'node:string_decoder';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
7
|
+
import { MarAgentError, describeMarAgentError } from '../../error.js';
|
|
8
|
+
import { directLocalProcessExecutor, signalProcessTree } from '../../host/local-process-executor.js';
|
|
9
|
+
import { allowsDirectTool, allowsToolCaller } from '../callers.js';
|
|
10
|
+
import { CodeCells } from './cells.js';
|
|
11
|
+
import { parseCodeModeStateMutations } from './state.js';
|
|
12
|
+
import { BoundedTextOutput, renderCapturedText } from './text-output.js';
|
|
13
|
+
import { TOOL_EXECUTION_LIMITS as limits } from '../execution-limits.js';
|
|
14
|
+
import { createToolCallScheduler } from '../scheduler.js';
|
|
15
|
+
import { detectImageMime } from '../local/view-image.js';
|
|
17
16
|
export const codeModeToolDefinition = {
|
|
18
17
|
name: 'code_exec',
|
|
19
18
|
description: `Run JavaScript to orchestrate or compose tool calls.
|
|
@@ -30,7 +29,7 @@ Tool calls:
|
|
|
30
29
|
- skill, tool_search, question, code_exec, code_exec_wait and direct-only tools cannot be called here. Load Skills directly and read their instructions before the next tool call. Use direct tool_search before a later code cell for deferred tools; the current cell's tools do not change.
|
|
31
30
|
|
|
32
31
|
Built-in namespaces:
|
|
33
|
-
- out.text(value): void emits text. Strings and scalar values are stringified; JSON-compatible objects/arrays are serialized as compact JSON. Excess ordinary text is truncated with omission metadata, without stopping later code or tools. Cyclic or unsupported object values fail. Only explicitly emitted output reaches the model.
|
|
32
|
+
- out.text(value): void emits text. Strings and scalar values are stringified; JSON-compatible objects/arrays are serialized as compact JSON. Structured image objects (image/* mimeType and string dataBase64, or native MCP type:image with string data) are recursively summarized without their Base64 payload; originals remain unchanged. Ordinary strings remain unchanged. This does not emit pixels: use out.image(result.images[0]) for images. Prefer result.data or result.content over the whole image result. Excess ordinary text is truncated with omission metadata, without stopping later code or tools. Cyclic or unsupported object values fail. Only explicitly emitted output reaches the model.
|
|
34
33
|
- out.image(value: {mimeType:string,dataBase64:string}): void emits one returned image; for example out.image(result.images[0]) when that image exists and the model supports images. It does not accept a path, URL, or result.content.
|
|
35
34
|
- state.get(key), state.has(key), state.set(key, value), state.delete(key) access bounded session JSON state. Mutations commit atomically only when the cell succeeds; failed or cancelled cells discard them.
|
|
36
35
|
- catalog.tools() returns a read-only snapshot of the tools callable in this cell, including name, description, inputSchema and inputMode. It does not discover or authorize additional tools.
|
|
@@ -154,10 +153,10 @@ function defaultEngineFactory() {
|
|
|
154
153
|
return root.includes(`${sep}.pnpm${sep}`) ? dirname(dirname(root)) : root;
|
|
155
154
|
};
|
|
156
155
|
return {
|
|
157
|
-
moduleUrl: new URL('./
|
|
156
|
+
moduleUrl: new URL('./quickjs-engine.js', import.meta.url).href,
|
|
158
157
|
runtimeDirectories: [
|
|
159
158
|
...new Set([
|
|
160
|
-
fileURLToPath(new URL('
|
|
159
|
+
fileURLToPath(new URL('.', import.meta.url)),
|
|
161
160
|
dependencyRoot(core),
|
|
162
161
|
dependencyRoot(variant),
|
|
163
162
|
dependencyRoot(ffi)
|
|
@@ -255,7 +254,7 @@ export class CodeModeTool {
|
|
|
255
254
|
`--max-old-space-size=${limits.codeHeapMegabytes}`,
|
|
256
255
|
'--input-type=module',
|
|
257
256
|
'--eval',
|
|
258
|
-
await readFile(new URL('./
|
|
257
|
+
await readFile(new URL('./worker.js', import.meta.url), 'utf8')
|
|
259
258
|
],
|
|
260
259
|
cwd,
|
|
261
260
|
shell: false,
|
|
@@ -527,13 +527,23 @@ function streamText(value, emit) {
|
|
|
527
527
|
else {
|
|
528
528
|
emit('{');
|
|
529
529
|
let first = true;
|
|
530
|
-
|
|
530
|
+
const names = Object.keys(item);
|
|
531
|
+
// Special-case view_image and native MCP image objects: text omits Base64; out.image keeps pixels.
|
|
532
|
+
const imagePayload = names.includes('mimeType') &&
|
|
533
|
+
typeof item.mimeType === 'string' &&
|
|
534
|
+
item.mimeType.startsWith('image/');
|
|
535
|
+
for (const name of names) {
|
|
531
536
|
if (!first)
|
|
532
537
|
emit(',');
|
|
533
538
|
first = false;
|
|
534
539
|
chunks(name, true);
|
|
535
540
|
emit(':');
|
|
536
|
-
|
|
541
|
+
const field = item[name];
|
|
542
|
+
write(imagePayload &&
|
|
543
|
+
(name === 'dataBase64' || (name === 'data' && item.type === 'image')) &&
|
|
544
|
+
typeof field === 'string'
|
|
545
|
+
? '[image payload omitted; use out.image]'
|
|
546
|
+
: field, name);
|
|
537
547
|
}
|
|
538
548
|
emit('}');
|
|
539
549
|
}
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
readonly value: unknown;
|
|
4
|
-
}
|
|
5
|
-
export type CodeModeStateMutation = {
|
|
6
|
-
readonly operation: 'set';
|
|
7
|
-
readonly key: string;
|
|
8
|
-
readonly value: unknown;
|
|
9
|
-
} | {
|
|
10
|
-
readonly operation: 'delete';
|
|
11
|
-
readonly key: string;
|
|
12
|
-
};
|
|
1
|
+
import type { CodeModeStateEntry, CodeModeStateMutation } from '../contracts.js';
|
|
2
|
+
export type { CodeModeStateEntry, CodeModeStateMutation } from '../contracts.js';
|
|
13
3
|
type StateRecord = {
|
|
14
4
|
readonly type: string;
|
|
15
5
|
readonly payload: unknown;
|
|
@@ -17,4 +7,3 @@ type StateRecord = {
|
|
|
17
7
|
export declare function parseCodeModeStateMutations(value: unknown): CodeModeStateMutation[];
|
|
18
8
|
export declare function restoreCodeModeState(records: readonly StateRecord[]): CodeModeStateEntry[];
|
|
19
9
|
export declare function applyCodeModeStateMutations(entries: readonly CodeModeStateEntry[], mutations: readonly CodeModeStateMutation[]): CodeModeStateEntry[];
|
|
20
|
-
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import type { ExecutionMode } from '../runtime/contracts.js';
|
|
2
|
+
export type ToolCaller = 'direct' | 'programmatic';
|
|
3
|
+
export interface ClientToolDefinition {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
inputSchema: Record<string, unknown>;
|
|
7
|
+
/** Runtime-only provider lowering hint; unsupported adapters fall back to a normal function tool. */
|
|
8
|
+
nativeType?: 'tool_search';
|
|
9
|
+
/** Runtime-only result contract; never forwarded as an upstream tool field. */
|
|
10
|
+
outputSchema?: Record<string, unknown>;
|
|
11
|
+
/** Runtime-only policy. MCP defaults to both callers; other tools default to direct only. */
|
|
12
|
+
allowedCallers?: readonly ToolCaller[];
|
|
13
|
+
inputMode?: 'json' | 'freeform';
|
|
14
|
+
parallelSafety?: 'safe' | 'serial';
|
|
15
|
+
/** Runtime-only Agent catalog scope; never forwarded as an upstream tool field. */
|
|
16
|
+
agentScope?: 'ROOT_AND_SUBAGENTS' | 'ROOT_ONLY';
|
|
17
|
+
}
|
|
18
|
+
export interface ToolCall {
|
|
19
|
+
name: string;
|
|
20
|
+
arguments: unknown;
|
|
21
|
+
callId?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ToolExecutionContext {
|
|
24
|
+
mode: ExecutionMode;
|
|
25
|
+
signal: AbortSignal;
|
|
26
|
+
sessionId: string;
|
|
27
|
+
executionId: string;
|
|
28
|
+
recentImages?: readonly {
|
|
29
|
+
readonly mimeType: string;
|
|
30
|
+
readonly data: Buffer;
|
|
31
|
+
}[];
|
|
32
|
+
codeMode?: {
|
|
33
|
+
retainSession?(): Promise<() => Promise<void>>;
|
|
34
|
+
onSettled?(result: CodeCellEventData): Promise<void>;
|
|
35
|
+
supportsImages?: boolean;
|
|
36
|
+
tools: readonly ClientToolDefinition[];
|
|
37
|
+
state?: readonly CodeModeStateEntry[];
|
|
38
|
+
commitState?(mutations: readonly CodeModeStateMutation[]): Promise<readonly CodeModeStateEntry[]>;
|
|
39
|
+
invoke(call: ToolCall, signal: AbortSignal): Promise<ToolExecutionResult>;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export interface McpToolCatalogContext extends Pick<ToolExecutionContext, 'sessionId' | 'executionId'> {
|
|
43
|
+
executionScopeId?: string;
|
|
44
|
+
claimExecutionScope?: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface McpToolCatalog {
|
|
47
|
+
readonly revision: string;
|
|
48
|
+
readonly servers: readonly {
|
|
49
|
+
readonly id: string;
|
|
50
|
+
readonly name: string;
|
|
51
|
+
readonly description?: string;
|
|
52
|
+
readonly instructions?: string;
|
|
53
|
+
}[];
|
|
54
|
+
readonly tools: readonly McpCatalogTool[];
|
|
55
|
+
}
|
|
56
|
+
export interface McpCatalogTool {
|
|
57
|
+
readonly definition: ClientToolDefinition;
|
|
58
|
+
readonly serverId: string;
|
|
59
|
+
readonly rawName: string;
|
|
60
|
+
readonly sourceIdentity: string;
|
|
61
|
+
readonly definitionRevision: string;
|
|
62
|
+
readonly lifetime: 'session' | 'execution';
|
|
63
|
+
readonly exposure: 'direct' | 'deferred';
|
|
64
|
+
/** Untrusted MCP hints; never an authorization or parallel-safety decision. */
|
|
65
|
+
readonly annotations?: Readonly<Record<string, unknown>>;
|
|
66
|
+
}
|
|
67
|
+
export interface McpToolCallContext extends Pick<ToolExecutionContext, 'sessionId' | 'executionId'> {
|
|
68
|
+
readonly mode?: ExecutionMode;
|
|
69
|
+
readonly expectedTool?: {
|
|
70
|
+
readonly sourceIdentity: string;
|
|
71
|
+
readonly definitionRevision: string;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export interface MarAgentToolImageArtifact {
|
|
75
|
+
kind: 'image';
|
|
76
|
+
name: string;
|
|
77
|
+
mimeType: 'image/png';
|
|
78
|
+
byteSize: number;
|
|
79
|
+
sha256: string;
|
|
80
|
+
fileName: string;
|
|
81
|
+
}
|
|
82
|
+
export type MarAgentToolArtifact = MarAgentToolImageArtifact;
|
|
83
|
+
export interface ToolExecutionResult {
|
|
84
|
+
content: string;
|
|
85
|
+
data?: unknown;
|
|
86
|
+
/** Runtime-only definitions used to encode a Tool Search output. */
|
|
87
|
+
toolSearchTools?: readonly ClientToolDefinition[];
|
|
88
|
+
truncated?: boolean;
|
|
89
|
+
images?: readonly {
|
|
90
|
+
mimeType: string;
|
|
91
|
+
dataBase64: string;
|
|
92
|
+
}[];
|
|
93
|
+
artifacts?: readonly MarAgentToolArtifact[];
|
|
94
|
+
}
|
|
95
|
+
export interface CodeCellEventData {
|
|
96
|
+
cellId: string;
|
|
97
|
+
status: 'running' | 'completed' | 'failed' | 'cancelled';
|
|
98
|
+
cached?: boolean;
|
|
99
|
+
}
|
|
100
|
+
export interface ExecResult {
|
|
101
|
+
status: 'running' | 'completed' | 'cancelled';
|
|
102
|
+
processId?: string;
|
|
103
|
+
stdout: string;
|
|
104
|
+
stderr: string;
|
|
105
|
+
exitCode?: number | null;
|
|
106
|
+
truncated: boolean;
|
|
107
|
+
stdoutBytes: number;
|
|
108
|
+
stderrBytes: number;
|
|
109
|
+
stdoutDroppedBytes: number;
|
|
110
|
+
stderrDroppedBytes: number;
|
|
111
|
+
/** A terminal snapshot replay rather than new process output. */
|
|
112
|
+
cached?: boolean;
|
|
113
|
+
}
|
|
114
|
+
export interface ApplyPatchFileResult {
|
|
115
|
+
path: string;
|
|
116
|
+
targetPath?: string;
|
|
117
|
+
operation: 'added' | 'modified' | 'deleted' | 'moved';
|
|
118
|
+
addedLines: number;
|
|
119
|
+
deletedLines: number;
|
|
120
|
+
}
|
|
121
|
+
export interface ApplyPatchResult {
|
|
122
|
+
files: ApplyPatchFileResult[];
|
|
123
|
+
totals: {
|
|
124
|
+
files: number;
|
|
125
|
+
addedLines: number;
|
|
126
|
+
deletedLines: number;
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
export interface ReadEventData {
|
|
130
|
+
mode: 'batch';
|
|
131
|
+
results: Array<{
|
|
132
|
+
path: string;
|
|
133
|
+
startLine?: number;
|
|
134
|
+
endLine?: number;
|
|
135
|
+
error?: {
|
|
136
|
+
code: string;
|
|
137
|
+
message: string;
|
|
138
|
+
};
|
|
139
|
+
}>;
|
|
140
|
+
truncated: boolean;
|
|
141
|
+
}
|
|
142
|
+
export interface ViewImageResult {
|
|
143
|
+
path: string;
|
|
144
|
+
mimeType: 'image/png' | 'image/jpeg' | 'image/webp';
|
|
145
|
+
bytes: number;
|
|
146
|
+
sha256: string;
|
|
147
|
+
}
|
|
148
|
+
export interface TodoItem {
|
|
149
|
+
id: string;
|
|
150
|
+
step: string;
|
|
151
|
+
status: 'pending' | 'in_progress' | 'completed';
|
|
152
|
+
}
|
|
153
|
+
export interface TodoSnapshot {
|
|
154
|
+
revision: number;
|
|
155
|
+
items: TodoItem[];
|
|
156
|
+
}
|
|
157
|
+
export interface CodeModeStateEntry {
|
|
158
|
+
readonly key: string;
|
|
159
|
+
readonly value: unknown;
|
|
160
|
+
}
|
|
161
|
+
export type CodeModeStateMutation = {
|
|
162
|
+
readonly operation: 'set';
|
|
163
|
+
readonly key: string;
|
|
164
|
+
readonly value: unknown;
|
|
165
|
+
} | {
|
|
166
|
+
readonly operation: 'delete';
|
|
167
|
+
readonly key: string;
|
|
168
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ModelEvent } from '../model/contracts.js';
|
|
2
|
+
import type { EventPayload } from '../runtime/events.js';
|
|
3
|
+
import type { ClientToolDefinition, McpToolCallContext, ToolExecutionContext, ToolExecutionResult } from './contracts.js';
|
|
4
|
+
import type { ToolRuntimeContext, ToolRuntimeImage } from './runtime-context.js';
|
|
5
|
+
import { type createSessionToolScheduler } from './scheduler.js';
|
|
6
|
+
export type ClientToolCall = Extract<ModelEvent, {
|
|
7
|
+
type: 'client_tool.call';
|
|
8
|
+
}>;
|
|
9
|
+
export type ExecutedToolCall = {
|
|
10
|
+
call: ClientToolCall;
|
|
11
|
+
content: string;
|
|
12
|
+
images?: ToolExecutionResult['images'];
|
|
13
|
+
} & ({
|
|
14
|
+
failed: false;
|
|
15
|
+
output: ToolExecutionResult;
|
|
16
|
+
} | {
|
|
17
|
+
failed: true;
|
|
18
|
+
error: unknown;
|
|
19
|
+
});
|
|
20
|
+
/** One immutable model round's catalog; execution resources remain owned by the SDK/Host. */
|
|
21
|
+
export interface RoundToolScope {
|
|
22
|
+
readonly context: Omit<ToolRuntimeContext, 'codeMode' | 'expectedMcpTool' | 'searchMcpTools' | 'recentImages'>;
|
|
23
|
+
readonly tools: readonly ClientToolDefinition[];
|
|
24
|
+
readonly expectations: ReadonlyMap<string, McpToolCallContext['expectedTool']>;
|
|
25
|
+
readonly extensionToolNames: ReadonlySet<string>;
|
|
26
|
+
readonly schedule: ReturnType<typeof createSessionToolScheduler>;
|
|
27
|
+
readonly emit: (event: EventPayload) => Promise<void>;
|
|
28
|
+
readonly searchMcpTools: NonNullable<ToolRuntimeContext['searchMcpTools']>;
|
|
29
|
+
readonly recentImages: () => ToolRuntimeImage[];
|
|
30
|
+
readonly captureCodeContext: () => Omit<ToolRuntimeContext, 'signal' | 'codeMode' | 'expectedMcpTool' | 'searchMcpTools'>;
|
|
31
|
+
readonly codeModeContext: (call: ClientToolCall) => Promise<Omit<NonNullable<ToolExecutionContext['codeMode']>, 'invoke'>>;
|
|
32
|
+
}
|
|
33
|
+
/** Complete every call in model order even if individual execution fails. */
|
|
34
|
+
export declare function executeRoundTools(calls: readonly ClientToolCall[], scope: RoundToolScope): Promise<ExecutedToolCall[]>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { MarAgentError, describeMarAgentError } from '../error.js';
|
|
2
|
+
import { AGENT_EXECUTION_POLICY } from '../runtime/execution-policy.js';
|
|
3
|
+
import { allowsToolCaller } from './callers.js';
|
|
4
|
+
import { CodeCellExecutionError } from './code-mode/cells.js';
|
|
5
|
+
import { createCodeToolDispatch } from './code-mode/dispatch.js';
|
|
6
|
+
import { boundedModelToolOutput, structuredToolArtifacts, structuredToolEventData } from './output-projection.js';
|
|
7
|
+
import { executeRegisteredTool } from './runtime.js';
|
|
8
|
+
import { scheduleToolCallBatch } from './scheduler.js';
|
|
9
|
+
/** Complete every call in model order even if individual execution fails. */
|
|
10
|
+
export async function executeRoundTools(calls, scope) {
|
|
11
|
+
const executeCall = async (call, signal = scope.context.signal, caller = 'direct', parentCallId) => {
|
|
12
|
+
await scope.emit({
|
|
13
|
+
type: 'tool.started',
|
|
14
|
+
toolName: call.name,
|
|
15
|
+
callId: call.callId,
|
|
16
|
+
...(parentCallId === undefined ? {} : { parentCallId }),
|
|
17
|
+
input: call.arguments
|
|
18
|
+
});
|
|
19
|
+
try {
|
|
20
|
+
if (call.argumentError)
|
|
21
|
+
throw new MarAgentError('MAR_AGENT_TOOL_INPUT_INVALID', call.argumentError);
|
|
22
|
+
if (!scope.tools.some((tool) => tool.name === call.name && allowsToolCaller(tool, caller)))
|
|
23
|
+
throw new MarAgentError('MAR_AGENT_TOOL_NOT_AVAILABLE', 'Tool is unavailable in this execution.');
|
|
24
|
+
const codeMode = await scope.codeModeContext(call);
|
|
25
|
+
const runTool = () => {
|
|
26
|
+
signal.throwIfAborted();
|
|
27
|
+
return executeRegisteredTool(call.name, call.arguments, call.callId, {
|
|
28
|
+
...scope.context,
|
|
29
|
+
...(scope.expectations.get(call.name)
|
|
30
|
+
? { expectedMcpTool: scope.expectations.get(call.name) }
|
|
31
|
+
: {}),
|
|
32
|
+
searchMcpTools: scope.searchMcpTools,
|
|
33
|
+
signal,
|
|
34
|
+
codeMode: {
|
|
35
|
+
...codeMode,
|
|
36
|
+
invoke: createCodeToolDispatch({
|
|
37
|
+
context: scope.captureCodeContext(),
|
|
38
|
+
tools: scope.tools,
|
|
39
|
+
expectations: scope.expectations,
|
|
40
|
+
parentCallId: call.callId,
|
|
41
|
+
schedule: scope.schedule,
|
|
42
|
+
emit: scope.emit
|
|
43
|
+
})
|
|
44
|
+
},
|
|
45
|
+
...(scope.extensionToolNames.has(call.name) ? { recentImages: scope.recentImages() } : {})
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
const output = call.name === 'code_exec' || call.name === 'code_exec_wait'
|
|
49
|
+
? await runTool()
|
|
50
|
+
: await scope.schedule(scope.tools.find((tool) => tool.name === call.name), runTool);
|
|
51
|
+
const modelOutput = boundedModelToolOutput(call.name, output.content, output.data);
|
|
52
|
+
const eventSummary = output.content.slice(0, AGENT_EXECUTION_POLICY.toolEventSummaryCharacters);
|
|
53
|
+
const structuredData = structuredToolEventData(call.name, output.data);
|
|
54
|
+
const artifacts = structuredToolArtifacts(output.artifacts);
|
|
55
|
+
await scope.emit({
|
|
56
|
+
type: 'tool.completed',
|
|
57
|
+
toolName: call.name,
|
|
58
|
+
callId: call.callId,
|
|
59
|
+
...(parentCallId === undefined ? {} : { parentCallId }),
|
|
60
|
+
summary: eventSummary,
|
|
61
|
+
truncated: output.truncated === true ||
|
|
62
|
+
modelOutput.truncated ||
|
|
63
|
+
eventSummary.length < output.content.length,
|
|
64
|
+
...(artifacts === undefined ? {} : { artifacts }),
|
|
65
|
+
...(structuredData === undefined ? {} : { data: structuredData })
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
call,
|
|
69
|
+
output,
|
|
70
|
+
content: modelOutput.content,
|
|
71
|
+
...(output.images?.length ? { images: output.images } : {}),
|
|
72
|
+
failed: false
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
const diagnostic = describeMarAgentError(error, 'MAR_AGENT_HOST_OPERATION_FAILED');
|
|
77
|
+
const partial = error instanceof CodeCellExecutionError ? error.result : undefined;
|
|
78
|
+
await scope.emit({
|
|
79
|
+
type: 'tool.failed',
|
|
80
|
+
toolName: call.name,
|
|
81
|
+
callId: call.callId,
|
|
82
|
+
...(parentCallId === undefined ? {} : { parentCallId }),
|
|
83
|
+
code: diagnostic.code,
|
|
84
|
+
message: diagnostic.message
|
|
85
|
+
});
|
|
86
|
+
return {
|
|
87
|
+
call,
|
|
88
|
+
content: partial === undefined
|
|
89
|
+
? JSON.stringify({
|
|
90
|
+
error: diagnostic.code,
|
|
91
|
+
message: diagnostic.message,
|
|
92
|
+
...(error instanceof MarAgentError && error.retryable ? { retryable: true } : {})
|
|
93
|
+
})
|
|
94
|
+
: boundedModelToolOutput(call.name, partial.content, partial.data).content,
|
|
95
|
+
...(partial?.images?.length ? { images: partial.images } : {}),
|
|
96
|
+
failed: true,
|
|
97
|
+
error
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
return scheduleToolCallBatch(calls, scope.tools, executeCall);
|
|
102
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ClientToolDefinition } from '../../model/contracts.js';
|
|
2
|
+
import type { ApplyPatchResult } from '../contracts.js';
|
|
3
|
+
import { WorkspacePathResolver } from '../shared/path-resolver.js';
|
|
4
|
+
export type { ApplyPatchFileResult, ApplyPatchResult } from '../contracts.js';
|
|
5
|
+
export declare const applyPatchToolDefinition: ClientToolDefinition;
|
|
6
|
+
export declare function applyPatchToolInput(input: unknown): string;
|
|
7
|
+
interface PatchFileOperations {
|
|
8
|
+
rename(source: string, target: string): Promise<void>;
|
|
9
|
+
rm(path: string, options?: {
|
|
10
|
+
force?: boolean;
|
|
11
|
+
recursive?: boolean;
|
|
12
|
+
}): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export declare class ApplyPatchTool {
|
|
15
|
+
#private;
|
|
16
|
+
private readonly paths;
|
|
17
|
+
constructor(paths: WorkspacePathResolver, operations?: Partial<PatchFileOperations>);
|
|
18
|
+
execute(patch: string): Promise<ApplyPatchResult>;
|
|
19
|
+
}
|
|
@@ -2,8 +2,8 @@ import { randomUUID } from 'node:crypto';
|
|
|
2
2
|
import { chmod, lstat, mkdir, readFile, rename, rm, rmdir, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { dirname, isAbsolute, parse, resolve } from 'node:path';
|
|
4
4
|
import { TextDecoder } from 'node:util';
|
|
5
|
-
import { MarAgentError } from '
|
|
6
|
-
import { TOOL_EXECUTION_LIMITS } from '
|
|
5
|
+
import { MarAgentError } from '../../error.js';
|
|
6
|
+
import { TOOL_EXECUTION_LIMITS } from '../execution-limits.js';
|
|
7
7
|
export const applyPatchToolDefinition = {
|
|
8
8
|
name: 'apply_patch',
|
|
9
9
|
allowedCallers: ['direct', 'programmatic'],
|
|
@@ -53,6 +53,12 @@ export const applyPatchToolDefinition = {
|
|
|
53
53
|
additionalProperties: false
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
|
+
export function applyPatchToolInput(input) {
|
|
57
|
+
const patch = typeof input === 'string' ? input : input?.patch;
|
|
58
|
+
if (typeof patch !== 'string')
|
|
59
|
+
throw new MarAgentError('MAR_AGENT_TOOL_INPUT_INVALID', 'Patch is required.');
|
|
60
|
+
return patch;
|
|
61
|
+
}
|
|
56
62
|
const defaultFileOperations = { rename, rm };
|
|
57
63
|
const utf8Decoder = new TextDecoder('utf-8', { fatal: true });
|
|
58
64
|
export class ApplyPatchTool {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { type LocalProcessExecutor } from '../../host/local-process-executor.js';
|
|
2
|
+
import type { ClientToolDefinition } from '../../model/contracts.js';
|
|
3
|
+
import type { ExecResult } from '../contracts.js';
|
|
4
|
+
import { WorkspacePathResolver } from '../shared/path-resolver.js';
|
|
5
|
+
export type { ExecResult } from '../contracts.js';
|
|
4
6
|
export type ExecInput = {
|
|
5
7
|
action?: 'start';
|
|
6
8
|
command: string;
|
|
@@ -19,20 +21,6 @@ export type ExecInput = {
|
|
|
19
21
|
action: 'cancel';
|
|
20
22
|
processId: string;
|
|
21
23
|
};
|
|
22
|
-
export interface ExecResult {
|
|
23
|
-
status: 'running' | 'completed' | 'cancelled';
|
|
24
|
-
processId?: string;
|
|
25
|
-
stdout: string;
|
|
26
|
-
stderr: string;
|
|
27
|
-
exitCode?: number | null;
|
|
28
|
-
truncated: boolean;
|
|
29
|
-
stdoutBytes: number;
|
|
30
|
-
stderrBytes: number;
|
|
31
|
-
stdoutDroppedBytes: number;
|
|
32
|
-
stderrDroppedBytes: number;
|
|
33
|
-
/** A terminal snapshot replay rather than new process output. */
|
|
34
|
-
cached?: boolean;
|
|
35
|
-
}
|
|
36
24
|
export declare const execToolDefinition: ClientToolDefinition;
|
|
37
25
|
export declare const execWaitToolDefinition: ClientToolDefinition;
|
|
38
26
|
/** Validate the public entry points before delegating to the single process manager. */
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { directLocalProcessExecutor, signalProcessTree } from '../host/local-process-executor.js';
|
|
2
1
|
import { randomUUID } from 'node:crypto';
|
|
3
2
|
import { StringDecoder } from 'node:string_decoder';
|
|
4
|
-
import { MarAgentError } from '
|
|
5
|
-
import {
|
|
3
|
+
import { MarAgentError } from '../../error.js';
|
|
4
|
+
import { directLocalProcessExecutor, signalProcessTree } from '../../host/local-process-executor.js';
|
|
5
|
+
import { TOOL_EXECUTION_LIMITS } from '../execution-limits.js';
|
|
6
6
|
export const execToolDefinition = {
|
|
7
7
|
name: 'exec',
|
|
8
8
|
allowedCallers: ['direct', 'programmatic'],
|
|
9
9
|
parallelSafety: 'safe',
|
|
10
|
-
description: 'Start a platform-native command, script, or program in workspace/default cwd. Returns a stable processId, status, bounded stdout/stderr, cumulative byte counts, dropped-byte counts, exitCode and truncated. A completed status does not imply exitCode 0; inspect stderr/exitCode. For subsequent waiting, stdin writes or cancellation,
|
|
10
|
+
description: 'Start a platform-native command, script, or program in workspace/default cwd. Returns a stable processId, status, bounded stdout/stderr, cumulative byte counts, dropped-byte counts, exitCode and truncated. A completed status does not imply exitCode 0; inspect stderr/exitCode. For subsequent waiting, stdin writes or cancellation, call exec_wait directly with processId, not exec. Truncation does not stop the process. Cancelling the initial wait does not terminate the process.',
|
|
11
11
|
outputSchema: {
|
|
12
12
|
type: 'object',
|
|
13
13
|
required: ['content', 'data'],
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { ClientToolDefinition } from '
|
|
2
|
-
import { WorkspacePathResolver } from '
|
|
1
|
+
import type { ClientToolDefinition } from '../../model/contracts.js';
|
|
2
|
+
import { WorkspacePathResolver } from '../shared/path-resolver.js';
|
|
3
|
+
export type { ReadEventData } from '../contracts.js';
|
|
3
4
|
export declare const readToolDefinition: ClientToolDefinition;
|
|
4
5
|
export interface ReadRequest {
|
|
5
6
|
path: string;
|
|
@@ -30,22 +31,13 @@ export interface BatchReadResult {
|
|
|
30
31
|
results: Array<ReadResult | ReadErrorResult>;
|
|
31
32
|
truncated: boolean;
|
|
32
33
|
}
|
|
33
|
-
export interface ReadEventData {
|
|
34
|
-
mode: 'batch';
|
|
35
|
-
results: Array<{
|
|
36
|
-
path: string;
|
|
37
|
-
startLine?: number;
|
|
38
|
-
endLine?: number;
|
|
39
|
-
error?: {
|
|
40
|
-
code: string;
|
|
41
|
-
message: string;
|
|
42
|
-
};
|
|
43
|
-
}>;
|
|
44
|
-
truncated: boolean;
|
|
45
|
-
}
|
|
46
34
|
export declare class ReadTool {
|
|
47
35
|
#private;
|
|
48
36
|
private readonly paths;
|
|
49
37
|
constructor(paths: WorkspacePathResolver);
|
|
50
38
|
execute(arguments_: unknown, signal?: AbortSignal): Promise<BatchReadResult>;
|
|
51
39
|
}
|
|
40
|
+
export declare function formatBatchReadOutput(results: Array<ReadResult | ReadErrorResult>): {
|
|
41
|
+
content: string;
|
|
42
|
+
truncated: boolean;
|
|
43
|
+
};
|