@myagentroam/agent 0.15.29 → 0.15.31
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/prompts/index.d.ts +1 -1
- package/dist/prompts/index.js +7 -3
- package/dist/prompts/reasoning.d.ts +1 -0
- package/dist/prompts/reasoning.js +7 -0
- package/dist/runtime/context/contextual-blocks.js +1 -1
- package/dist/sdk/execution-model-context.js +3 -5
- package/dist/tools/code-mode/index.js +15 -39
- package/dist/tools/code-mode/quickjs-engine.js +2 -26
- package/package.json +1 -1
- package/dist/prompts/workflow.d.ts +0 -1
- package/dist/prompts/workflow.js +0 -29
package/dist/prompts/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ExecutionMode } from '../runtime/contracts.js';
|
|
2
2
|
import { type PromptPart } from './prompt-sections.js';
|
|
3
|
-
export declare const MAR_AGENT_PROMPT_VERSION = "1.
|
|
3
|
+
export declare const MAR_AGENT_PROMPT_VERSION = "1.87";
|
|
4
4
|
interface SystemPromptInput {
|
|
5
5
|
mode: ExecutionMode;
|
|
6
6
|
platform: string;
|
package/dist/prompts/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { THOUGHT_TOOL_NAME } from '../runtime/context/thought-contract.js';
|
|
1
2
|
import { renderPromptSections } from './prompt-sections.js';
|
|
2
3
|
import { compactionPrompt } from './compact.js';
|
|
3
4
|
import { environmentPrompt, identityPrompt, instructionPriorityPrompt, progressCommunicationPrompt, securityPrompt } from './core.js';
|
|
4
5
|
import { modePrompt } from './modes.js';
|
|
5
|
-
import {
|
|
6
|
-
export const MAR_AGENT_PROMPT_VERSION = '1.
|
|
6
|
+
import { reasoningPrompt } from './reasoning.js';
|
|
7
|
+
export const MAR_AGENT_PROMPT_VERSION = '1.87';
|
|
7
8
|
export function buildSystemPrompt(input) {
|
|
8
9
|
return renderPromptSections(buildSystemPromptSections(input));
|
|
9
10
|
}
|
|
@@ -14,7 +15,10 @@ export function buildSystemPromptSections(input) {
|
|
|
14
15
|
['instruction-priority', instructionPriorityPrompt],
|
|
15
16
|
['safety', securityPrompt],
|
|
16
17
|
['environment-rules', environmentPrompt(input)],
|
|
17
|
-
[
|
|
18
|
+
[
|
|
19
|
+
'reasoning',
|
|
20
|
+
(input.directTools ?? input.tools).includes(THOUGHT_TOOL_NAME) ? reasoningPrompt : ''
|
|
21
|
+
],
|
|
18
22
|
['interaction', input.mode === 'compact' ? null : progressCommunicationPrompt],
|
|
19
23
|
[
|
|
20
24
|
'mode',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const reasoningPrompt = "<reasoning>\nDuring extended reasoning, earlier insights may be lost if left unrecorded.\n\nWhen you reach a conclusion useful for later reasoning - such as confirming a hypothesis, ruling out an approach, or making a decision - use `thought` to record it and its key evidence before moving on.\n\nSkip trivial observations. Do not repeat conclusions already recorded with their supporting evidence.\n</reasoning>";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const reasoningPrompt = `<reasoning>
|
|
2
|
+
During extended reasoning, earlier insights may be lost if left unrecorded.
|
|
3
|
+
|
|
4
|
+
When you reach a conclusion useful for later reasoning - such as confirming a hypothesis, ruling out an approach, or making a decision - use \`thought\` to record it and its key evidence before moving on.
|
|
5
|
+
|
|
6
|
+
Skip trivial observations. Do not repeat conclusions already recorded with their supporting evidence.
|
|
7
|
+
</reasoning>`;
|
|
@@ -23,7 +23,7 @@ export function contextualBlock(part, kind, operation = 'replace') {
|
|
|
23
23
|
const CORE_IDS = new Set(['core:identity', 'core:instruction-priority', 'core:safety']);
|
|
24
24
|
const SDK_CONTEXTUAL_IDS = new Set([
|
|
25
25
|
'core:environment-rules',
|
|
26
|
-
'core:
|
|
26
|
+
'core:reasoning',
|
|
27
27
|
'core:interaction',
|
|
28
28
|
'core:mode',
|
|
29
29
|
'core:compaction',
|
|
@@ -121,12 +121,10 @@ export function createExecutionModelContext(ports) {
|
|
|
121
121
|
// Compact can run before normal prompt composition after an upgrade.
|
|
122
122
|
// Revoke retired SDK instructions before either path projects the world state.
|
|
123
123
|
if (worldState.promptSnapshot !== undefined) {
|
|
124
|
+
const isRetiredSdkPrompt = (part) => part.source === 'sdk' && (part.id === 'core:long-running' || part.id === 'core:tools');
|
|
124
125
|
// A manual Compact's instruction anchor may precede the last Run's prompt blocks.
|
|
125
|
-
const retiredPromptAnchor = worldState.entries.reduce((anchor, entry) => entry.block
|
|
126
|
-
|
|
127
|
-
: anchor, instructionInsertIndex);
|
|
128
|
-
const migrated = updatePromptWorldState(worldState, retiredPromptAnchor, worldState.promptSnapshot.filter((part) => part.id !== 'core:skill-catalog' &&
|
|
129
|
-
!(part.id === 'core:long-running' && part.source === 'sdk')));
|
|
126
|
+
const retiredPromptAnchor = worldState.entries.reduce((anchor, entry) => entry.block && isRetiredSdkPrompt(entry.block) ? Math.max(anchor, entry.index) : anchor, instructionInsertIndex);
|
|
127
|
+
const migrated = updatePromptWorldState(worldState, retiredPromptAnchor, worldState.promptSnapshot.filter((part) => part.id !== 'core:skill-catalog' && !isRetiredSdkPrompt(part)));
|
|
130
128
|
if (migrated !== worldState)
|
|
131
129
|
await commitWorldState(migrated);
|
|
132
130
|
}
|
|
@@ -23,49 +23,28 @@ import { structuredToolFailureData } from '../output-projection.js';
|
|
|
23
23
|
import { failedToolResultExtensions } from '../result-extensions.js';
|
|
24
24
|
export const codeModeToolDefinition = {
|
|
25
25
|
name: 'code_exec',
|
|
26
|
-
description: `Run JavaScript
|
|
27
|
-
- Code Mode Only by default: call the programmatic tools listed below through tools.NAME, including single-tool operations. Tools exposed in both places may also be called directly.
|
|
26
|
+
description: `Run JavaScript with programmatic tools.
|
|
28
27
|
- Evaluates source in a fresh restricted ECMAScript runtime with top-level await. It is not Node.js or a browser. JavaScript globals do not survive between cells; bounded JSON state is available through state.
|
|
29
|
-
-
|
|
30
|
-
- Use only standard ECMAScript built-ins and the explicitly documented tools, observe, state, catalog and cell namespaces. Do not use Node.js, browser or Web APIs. Module imports, filesystem and network APIs are unavailable. Obtain external capabilities only through available tools. Use tools.exec to start managed processes when permitted; follow exec_wait's calling guidance for process control.
|
|
28
|
+
- Provides standard ECMAScript built-ins and frozen tools, observe, state and cell bindings. Module imports, filesystem and network APIs are unavailable in the guest.
|
|
31
29
|
|
|
32
30
|
Tool calls:
|
|
33
|
-
- tools.NAME(input) returns
|
|
34
|
-
- Results use the MAR envelope: { content?: string, data?: unknown, images?: Array<{mimeType:string,dataBase64:string,url?:string,urlExpiresAt?:number}>, truncated?: boolean }. Redundant JSON content is omitted when it exactly renders data; independent text remains in content.
|
|
35
|
-
-
|
|
36
|
-
- Tool errors reject with code/message
|
|
31
|
+
- tools.NAME(input) returns an awaitable. Pass a JavaScript value matching the tool's inputSchema. Only parameterless tools accept an omitted argument.
|
|
32
|
+
- Results use the MAR envelope: { content?: string, data?: unknown, images?: Array<{mimeType:string,dataBase64:string,url?:string,urlExpiresAt?:number}>, truncated?: boolean }. Redundant JSON content is omitted when it exactly renders data; independent rendered text remains in content.
|
|
33
|
+
- A cell cannot finish successfully with unconsumed tool calls or pending operations. Runtime preserves safe/serial barriers and Host checks.
|
|
34
|
+
- Tool execution errors reject with code/message, except nested Auto deny, which skips only that call and resolves with data.error/data.message. A failed cell preserves already emitted output alongside its status and error; completed tool effects are not rolled back.
|
|
37
35
|
- Direct-only tools cannot be called here. When available, tools.tool_search discovers deferred tools for the next model request; the current cell's tools do not change.
|
|
38
36
|
|
|
39
37
|
Built-in namespaces:
|
|
40
|
-
- observe.result(result): void registers
|
|
41
|
-
- observe.text(value): void registers text/JSON values. observe.
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
- await cell.
|
|
38
|
+
- observe.result(result): void registers the unmodified result of await tools.NAME(input), or a caught tool error, as a tool_result observation. Copies and modified values are rejected. The model sees the tool's normal output, which may omit fields from data. Example: \`observe.result(r);\` for an unchanged tool result.
|
|
39
|
+
- observe.text(value): void registers text/JSON values. Example: \`observe.text(excerpt);\` for a source excerpt labeled with its path and line numbers.
|
|
40
|
+
- observe.image(value): void registers one image object. Example: \`observe.image(image);\` where image is one object from r.images. Image observations require a model that supports image input.
|
|
41
|
+
- Observations are returned in registration order; registering one does not trigger a new model request. JavaScript return values are not emitted as observations. No out or callable observe(value) alias exists.
|
|
42
|
+
- state.get(key), state.has(key), state.set(key, value), state.delete(key) access bounded session state with nonempty string keys and JSON values. get returns a JSON copy or undefined if the key is missing. Writes are visible in the current cell and commit atomically only on success; failed or cancelled cells discard them.
|
|
43
|
+
- await cell.sleep(ms) performs a cancellable delay; ms is an integer from 0 to ${limits.codeSleepMaxMs}.
|
|
44
|
+
- cell.yield_control(): void lets the outer wait return with accumulated output while the cell continues running.
|
|
46
45
|
- Optionally start source with // @options: {"yieldMs": ${limits.codeDefaultYieldMs}}. yieldMs defaults to ${limits.codeDefaultYieldMs} ms and controls this call's wait window (0..${limits.codeMaxYieldMs}), not nested tool timeouts or wait windows. A running result includes cellId (c_ plus 12 lowercase hex characters); use direct code_exec_wait for new output, completion or termination.
|
|
47
46
|
- waitOutcome separates snapshot, completion, timeout, and yield from the cell status. A foreground steer returns interrupted with reason=steer without stopping the cell or its internal tool waits.
|
|
48
|
-
- Registered cells are Session warm resources: ending or cancelling the model Execution cancels its wait, not the cell.
|
|
49
|
-
- tools, observe, state, catalog and cell are frozen bindings. Do not shadow their names.
|
|
50
|
-
|
|
51
|
-
Examples (copy the JavaScript source, not the fences; use only tools available in the current directory):
|
|
52
|
-
Independent reads, observing the original tool results:
|
|
53
|
-
\`\`\`js
|
|
54
|
-
const [a, b] = await Promise.all([
|
|
55
|
-
tools.read({ reads: [{ path: "a.txt" }] }),
|
|
56
|
-
tools.read({ reads: [{ path: "b.txt" }] })
|
|
57
|
-
]);
|
|
58
|
-
observe.result(a);
|
|
59
|
-
observe.result(b);
|
|
60
|
-
\`\`\`
|
|
61
|
-
Inspect before a dependent edit; successful await needs no invented success flag:
|
|
62
|
-
\`\`\`js
|
|
63
|
-
const inspected = await tools.read({ reads: [{ path: "source.txt" }] });
|
|
64
|
-
const sourceText = inspected.data.results[0].text;
|
|
65
|
-
if (!sourceText?.includes("original=1")) throw new Error("Unexpected source");
|
|
66
|
-
const patched = await tools.apply_patch({ input: "*** Begin Patch\\n*** Update File: source.txt\\n@@\\n original=1\\n+updated=2\\n*** End Patch" });
|
|
67
|
-
observe.result(patched);
|
|
68
|
-
\`\`\``,
|
|
47
|
+
- Registered cells are Session warm resources: ending or cancelling the model Execution cancels its wait, not the cell. Host cleanup or explicit termination stops the cell.`,
|
|
69
48
|
inputMode: 'freeform',
|
|
70
49
|
inputSchema: {
|
|
71
50
|
type: 'object',
|
|
@@ -116,10 +95,7 @@ export function projectCodeModeTools(tools, residentTools = tools) {
|
|
|
116
95
|
if (!codeModeEnabled)
|
|
117
96
|
return direct;
|
|
118
97
|
const programmatic = orderToolDefinitions(residentTools.filter((tool) => allowsToolCaller(tool, 'programmatic')));
|
|
119
|
-
const directory = JSON.stringify(
|
|
120
|
-
callableNames: programmatic.map((tool) => tool.name),
|
|
121
|
-
tools: programmatic.map(projectProgrammaticTool)
|
|
122
|
-
});
|
|
98
|
+
const directory = JSON.stringify(programmatic.map(projectProgrammaticTool));
|
|
123
99
|
if (Buffer.byteLength(directory) > 48 * 1024)
|
|
124
100
|
throw new AgentError('MAR_AGENT_TOOL_EXPOSURE_LIMIT', 'Programmatic tool directory is too large.');
|
|
125
101
|
return direct.map((tool) => tool.name === 'code_exec'
|
|
@@ -158,13 +158,6 @@ export async function createCodeModeEngine(options) {
|
|
|
158
158
|
try { return walk(value); } catch { return ''; }
|
|
159
159
|
};
|
|
160
160
|
})();
|
|
161
|
-
globalThis.__deepFreeze = function deepFreeze(value) {
|
|
162
|
-
if (value && typeof value === 'object' && !Object.isFrozen(value)) {
|
|
163
|
-
for (const item of Object.values(value)) deepFreeze(item);
|
|
164
|
-
Object.freeze(value);
|
|
165
|
-
}
|
|
166
|
-
return value;
|
|
167
|
-
};
|
|
168
161
|
`);
|
|
169
162
|
if (setup.error)
|
|
170
163
|
fail(setup.error);
|
|
@@ -186,7 +179,6 @@ export async function createCodeModeEngine(options) {
|
|
|
186
179
|
value.value.dispose();
|
|
187
180
|
}
|
|
188
181
|
};
|
|
189
|
-
const deepFreeze = vm.getProp(vm.global, '__deepFreeze');
|
|
190
182
|
const parse = (value) => {
|
|
191
183
|
const handle = vm.newString(JSON.stringify(value));
|
|
192
184
|
try {
|
|
@@ -235,6 +227,7 @@ export async function createCodeModeEngine(options) {
|
|
|
235
227
|
return guestError('MAR_AGENT_TOOL_OUTPUT_LIMIT', 'Code Mode state is too large.');
|
|
236
228
|
};
|
|
237
229
|
const tools = vm.newObject();
|
|
230
|
+
// The internal snapshot still determines which tools may omit their argument.
|
|
238
231
|
const parameterlessTools = new Set(input.catalog.filter(isParameterlessTool).map((tool) => tool.name));
|
|
239
232
|
let toolCallSequence = 0;
|
|
240
233
|
for (const name of input.tools) {
|
|
@@ -460,21 +453,6 @@ export async function createCodeModeEngine(options) {
|
|
|
460
453
|
});
|
|
461
454
|
vm.setProp(vm.global, 'state', stateObject);
|
|
462
455
|
stateObject.dispose();
|
|
463
|
-
const catalog = vm.newObject();
|
|
464
|
-
method(catalog, 'tools', () => {
|
|
465
|
-
const value = parse(input.catalog.map(({ name, description, inputSchema }) => ({
|
|
466
|
-
name,
|
|
467
|
-
description,
|
|
468
|
-
inputSchema
|
|
469
|
-
})));
|
|
470
|
-
const frozen = callGuest(deepFreeze, vm.undefined, value);
|
|
471
|
-
value.dispose();
|
|
472
|
-
if (frozen.error)
|
|
473
|
-
return { error: frozen.error };
|
|
474
|
-
return frozen.value;
|
|
475
|
-
});
|
|
476
|
-
vm.setProp(vm.global, 'catalog', catalog);
|
|
477
|
-
catalog.dispose();
|
|
478
456
|
const cell = vm.newObject();
|
|
479
457
|
method(cell, 'yield_control', () => {
|
|
480
458
|
input.onYield();
|
|
@@ -545,7 +523,7 @@ export async function createCodeModeEngine(options) {
|
|
|
545
523
|
{ code: 'MAR_AGENT_TOOL_NOT_AVAILABLE' }); };
|
|
546
524
|
return target[name];
|
|
547
525
|
}});
|
|
548
|
-
for (const name of ['tools', 'observe', 'state', '
|
|
526
|
+
for (const name of ['tools', 'observe', 'state', 'cell']) {
|
|
549
527
|
const value = globalThis[name];
|
|
550
528
|
Object.freeze(value);
|
|
551
529
|
Object.defineProperty(globalThis, name, {
|
|
@@ -556,7 +534,6 @@ export async function createCodeModeEngine(options) {
|
|
|
556
534
|
delete globalThis.__serialize;
|
|
557
535
|
delete globalThis.__text;
|
|
558
536
|
delete globalThis.__snapshot;
|
|
559
|
-
delete globalThis.__deepFreeze;
|
|
560
537
|
delete globalThis.__consumeToolCall;
|
|
561
538
|
`);
|
|
562
539
|
if (lock.error)
|
|
@@ -614,7 +591,6 @@ export async function createCodeModeEngine(options) {
|
|
|
614
591
|
snapshotFunction.dispose();
|
|
615
592
|
for (const origin of origins)
|
|
616
593
|
origin.handle.dispose();
|
|
617
|
-
deepFreeze.dispose();
|
|
618
594
|
}
|
|
619
595
|
},
|
|
620
596
|
async dispose() {
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function toolUsagePrompt(tools: readonly string[], directTools?: readonly string[]): string;
|
package/dist/prompts/workflow.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { THOUGHT_TOOL_NAME } from '../runtime/context/thought-contract.js';
|
|
2
|
-
export function toolUsagePrompt(tools, directTools = tools) {
|
|
3
|
-
const names = new Set(tools);
|
|
4
|
-
const clauses = [
|
|
5
|
-
`# Tools and execution\nAvailable client tools: ${directTools.join(', ')}.`,
|
|
6
|
-
'Use the tool descriptions and schemas for calling conventions, limits, results, and recovery. Respect dependencies and side effects when combining operations.'
|
|
7
|
-
];
|
|
8
|
-
if (names.has('code_exec')) {
|
|
9
|
-
const direct = new Set(directTools);
|
|
10
|
-
const programmatic = tools.filter((name) => !direct.has(name));
|
|
11
|
-
if (programmatic.length > 0)
|
|
12
|
-
clauses.push(`Code Mode Only: ${programmatic.join(', ')} are callable only as tools.NAME inside code_exec.`);
|
|
13
|
-
clauses.push('Tools exposed in both modes may use either permitted entry point; direct-only controls remain direct.');
|
|
14
|
-
}
|
|
15
|
-
if (names.has('exec'))
|
|
16
|
-
clauses.push('You can use the built-in rg through exec to search file contents or rg --files to list file paths.');
|
|
17
|
-
const execution = clauses.join(' ');
|
|
18
|
-
if (!directTools.includes(THOUGHT_TOOL_NAME))
|
|
19
|
-
return execution;
|
|
20
|
-
return `${execution}
|
|
21
|
-
|
|
22
|
-
<reasoning>
|
|
23
|
-
During extended reasoning, earlier insights may be lost if left unrecorded.
|
|
24
|
-
|
|
25
|
-
When you reach a conclusion useful for later reasoning - such as confirming a hypothesis, ruling out an approach, or making a decision - use \`thought\` to record it and its key evidence before moving on.
|
|
26
|
-
|
|
27
|
-
Skip trivial observations. Do not repeat conclusions already recorded with their supporting evidence.
|
|
28
|
-
</reasoning>`;
|
|
29
|
-
}
|