@myagentroam/agent 0.9.146 → 0.9.148

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.
@@ -48,17 +48,18 @@ export async function createMarAgentWithAdapter(options) {
48
48
  activeAdapters.add(adapter);
49
49
  return activeAdapters;
50
50
  };
51
+ const settings = {
52
+ ...(options.workspaceMapping === undefined
53
+ ? {}
54
+ : { workspaceMapping: options.workspaceMapping }),
55
+ ...(options.systemInstruction === undefined
56
+ ? {}
57
+ : { systemInstruction: options.systemInstruction })
58
+ };
51
59
  const openSession = createSessionOpener({
52
60
  host: options.host,
53
61
  description,
54
- settings: {
55
- ...(options.workspaceMapping === undefined
56
- ? {}
57
- : { workspaceMapping: options.workspaceMapping }),
58
- ...(options.systemInstruction === undefined
59
- ? {}
60
- : { systemInstruction: options.systemInstruction })
61
- },
62
+ settings,
62
63
  store,
63
64
  registry: {
64
65
  active,
@@ -95,6 +96,14 @@ export async function createMarAgentWithAdapter(options) {
95
96
  await options.host.disposeSessionResources?.(id);
96
97
  await store.clearSession(id);
97
98
  },
99
+ setSystemInstruction: (systemInstruction) => {
100
+ if (disposed)
101
+ throw new MarAgentError('MAR_AGENT_DISPOSED', 'Agent is disposed.');
102
+ if (systemInstruction === undefined)
103
+ delete settings.systemInstruction;
104
+ else
105
+ settings.systemInstruction = systemInstruction;
106
+ },
98
107
  reconfigureModels: async (input) => {
99
108
  if (disposed)
100
109
  throw new MarAgentError('MAR_AGENT_DISPOSED', 'Agent is disposed.');
@@ -109,6 +109,7 @@ export function createSessionOpener(services) {
109
109
  ...currentLocalTimeContext()
110
110
  };
111
111
  const { models: executionModels, defaultModelId: executionDefaultModelId, generation: executionModelGeneration } = services.modelState();
112
+ const executionSystemInstruction = settings.systemInstruction;
112
113
  const manualCompactionId = mode === 'compact' ? randomUUID() : undefined;
113
114
  active.set(`${sessionId}:${executionId}`, controller);
114
115
  const mailbox = [...(internal.initialMailbox ?? [])];
@@ -564,7 +565,7 @@ export function createSessionOpener(services) {
564
565
  .map((tool) => tool.name),
565
566
  highDensityCompaction: selectedModel.highDensityCompaction,
566
567
  extension: [
567
- settings.systemInstruction,
568
+ executionSystemInstruction,
568
569
  instructionContext?.skillCatalog,
569
570
  sessionSource.type === 'subagent' ? childSubagentInstruction : undefined
570
571
  ]
@@ -37,6 +37,8 @@ export interface MarAgent {
37
37
  }>;
38
38
  setSessionTitle(sessionId: string, title: string, input?: SessionTitleUpdateInput): Promise<boolean>;
39
39
  clearSession(sessionId: string): Promise<void>;
40
+ /** Updates future execution snapshots only; undefined clears the Host instruction extension. */
41
+ setSystemInstruction(systemInstruction?: string): void;
40
42
  /** Rebinds future main executions only; running subagents keep their captured model providers. */
41
43
  reconfigureModels(input: {
42
44
  readonly models: readonly MarAgentModelConfiguration[];
@@ -18,7 +18,10 @@ export const codeModeToolDefinition = {
18
18
  name: 'code_exec',
19
19
  description: `Run JavaScript to orchestrate or compose tool calls.
20
20
  - Code Mode Only: call the programmatic tools listed below through tools.NAME inside this tool, including single-tool operations. They are omitted from the top-level tool list. Direct-only tools remain separate model tools and cannot be called here.
21
- - Use bounded combinations, parallel independent calls, and filtering of large intermediate results to reduce model round trips.
21
+ - Run independent calls concurrently with Promise.all; await sequentially when data, side effects, or failure handling require ordering.
22
+ - Complete known, bounded steps and deterministic result processing in code when this avoids a model round trip. Return to the model when interpretation or a new decision is needed; do not invent extra work to fill a cell.
23
+ - Observe only evidence needed for the next decision or verification: use observe.result for original results, observe.text for derived values, and observe.image for image values. Preserve source and failure details needed for reasoning; keep other intermediate data in the cell.
24
+ - Single-tool cells are valid. Keep loops and retries bounded, and do not blindly replay operations with side effects.
22
25
  - Evaluates source in a fresh restricted ECMAScript runtime with top-level await and Promise.all. It is not Node.js or a browser. JavaScript globals do not survive between cells; bounded JSON state is available through state.
23
26
  - Accepts raw JavaScript source text, not JSON, quoted strings, or markdown code fences. Responses uses the source directly; Anthropic uses the code field of its tool input object. In either case, do not quote or fence the source again.
24
27
  - 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; use tools.exec_wait afterward to wait, write stdin or cancel.
@@ -31,7 +34,7 @@ Tool calls:
31
34
 
32
35
  Built-in namespaces:
33
36
  - observe.result(result): void registers an unmodified complete tools.NAME result or caught tool error as a trusted tool_result, using the original text and all images without repeating program data. Non-original, copied or modified values are rejected. This selects evidence for the next model response, not a log and not a new model call. Prefer observe.result for inspecting tool results.
34
- - observe.text(value): void registers bounded text/JSON values. observe.image(value): void registers one image value using the existing capability, MIME, byte and count limits. Both accept original tool results for compatibility and use the same complete tool_result observation path; they do not select part of an original result. Extracted single images, copies and computed summaries are value observations, never trusted tool results. Observations are returned in registration order. Only explicitly observed evidence reaches the model; registration does not prove inspection. Sources and types are runtime-assigned. No out or callable observe(value) alias exists.
37
+ - observe.text(value): void registers bounded text/JSON values. observe.image(value): void registers one image value using the existing capability, MIME and byte limits. Both accept original tool results for compatibility and use the same complete tool_result observation path; they do not select part of an original result. Extracted single images, copies and computed summaries are value observations, never trusted tool results. Observations are returned in registration order. Only explicitly observed evidence reaches the model; registration does not prove inspection. Sources and types are runtime-assigned. No out or callable observe(value) alias exists.
35
38
  - 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
39
  - 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.
37
40
  - await cell.sleep(ms) performs a cancellable Host-side delay up to 30000 ms and remains subject to the cell deadline.
@@ -353,8 +356,6 @@ export class CodeModeTool {
353
356
  const addImage = (raw) => {
354
357
  if (!context.codeMode?.supportsImages)
355
358
  throw new MarAgentError('MAR_AGENT_INPUT_CAPABILITY_UNSUPPORTED', 'The current model cannot receive image observations.');
356
- if (images.length >= 5)
357
- throw new MarAgentError('MAR_AGENT_TOOL_OUTPUT_LIMIT', 'Code Mode emitted too many images.');
358
359
  const image = parseImage(raw);
359
360
  const index = images.length;
360
361
  images.push(image);
@@ -439,8 +440,6 @@ export class CodeModeTool {
439
440
  if (!context.codeMode?.supportsImages)
440
441
  throw new MarAgentError('MAR_AGENT_INPUT_CAPABILITY_UNSUPPORTED', 'The current Code Mode context does not support image output.');
441
442
  const image = parseImage(frame.value);
442
- if (images.length >= 5)
443
- throw new MarAgentError('MAR_AGENT_TOOL_OUTPUT_LIMIT', 'Code Mode emitted too many images.');
444
443
  images.push(image);
445
444
  output?.image(image);
446
445
  appendObservation({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myagentroam/agent",
3
- "version": "0.9.146",
3
+ "version": "0.9.148",
4
4
  "description": "Embeddable MAR coding agent SDK and CLI.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",