@myagentroam/agent 0.11.69 → 0.11.70

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.
@@ -32,6 +32,7 @@ export function formatExecResult(result) {
32
32
  export const execToolDefinition = {
33
33
  name: 'exec',
34
34
  allowedCallers: ['direct', 'programmatic'],
35
+ codeModeExposure: 'both',
35
36
  parallelSafety: 'safe',
36
37
  description: 'Start a platform-native command, script, or program in workspace/default cwd. Returns a stable processId (p_ plus 12 lowercase hex characters), 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. waitOutcome distinguishes snapshot, completion, and timeout. A foreground wait may return interrupted with reason=steer; the process keeps running.',
37
38
  outputSchema: {
@@ -6,7 +6,6 @@ import { createReadStream } from 'node:fs';
6
6
  import { lstat, open } from 'node:fs/promises';
7
7
  import { TextDecoder } from 'node:util';
8
8
  import { AgentError } from '../../error.js';
9
- import { toolEventSummary } from '../../runtime/event-projection.js';
10
9
  import { TOOL_EXECUTION_LIMITS } from '../execution-limits.js';
11
10
  export const readToolDefinition = {
12
11
  name: 'read',
@@ -89,47 +88,57 @@ export const readToolDefinition = {
89
88
  /** Produce public text and offsets together, independently of model-visible markup. */
90
89
  export function formatReadEventOutput(results) {
91
90
  let source = '';
92
- const projected = [];
93
- for (const item of results.slice(0, TOOL_EXECUTION_LIMITS.readMaxBatchItems)) {
91
+ const items = results
92
+ .slice(0, TOOL_EXECUTION_LIMITS.readMaxBatchItems)
93
+ .map((item) => {
94
94
  const path = item.path.slice(0, 4096).replace(/[\uD800-\uDBFF]$/u, '');
95
- source += `${source ? '\n\n' : ''}${path}\n`;
96
95
  if ('error' in item) {
97
96
  const error = {
98
97
  code: item.error.code.slice(0, 80),
99
98
  message: item.error.message.slice(0, 1000)
100
99
  };
101
- source += `${error.code}: ${error.message}`;
102
- projected.push({ path, error });
100
+ return { body: `${error.code}: ${error.message}`, result: { path, error } };
103
101
  }
104
- else {
105
- const start = source.length;
106
- source += item.text;
107
- projected.push({
102
+ return {
103
+ body: item.text,
104
+ result: {
108
105
  path,
109
106
  startLine: item.startLine,
110
107
  ...(item.endLine === undefined ? {} : { endLine: item.endLine }),
111
- ...(item.text.length === 0 ? { empty: true } : {}),
112
- contentRange: { start, end: source.length }
113
- });
114
- }
115
- }
116
- const preview = toolEventSummary(source);
117
- const retained = preview.retainedLength;
118
- for (const item of projected) {
119
- const range = item.contentRange;
120
- if (!range)
121
- continue;
122
- if (range.start > retained || (range.start === retained && range.end > range.start)) {
123
- delete item.contentRange;
124
- }
125
- else {
126
- range.end = Math.min(range.end, retained);
127
- }
108
+ ...(item.text.length === 0 ? { empty: true } : {})
109
+ }
110
+ };
111
+ });
112
+ const maximum = AGENT_EXECUTION_POLICY.toolEventSummaryCharacters;
113
+ const completeLength = items.reduce((length, { body, result }) => length + result.path.length + 1 + body.length, Math.max(0, items.length - 1) * 2);
114
+ let truncated = items.length < results.length;
115
+ const projected = [];
116
+ for (const [index, { body, result }] of items.entries()) {
117
+ const path = result.path;
118
+ const separator = index === 0 ? '' : '\n\n';
119
+ const remaining = items.length - index;
120
+ const budget = completeLength <= maximum
121
+ ? maximum - source.length - separator.length
122
+ : Math.floor((maximum - source.length - separator.length - 2 * (remaining - 1)) / remaining);
123
+ // Keep full paths in metadata; long display labels must leave room for each body.
124
+ const pathBudget = Math.max(Math.floor(budget / 2), budget - body.length - 1);
125
+ const label = path.length <= pathBudget
126
+ ? path
127
+ : `${path.slice(0, pathBudget - 3).replace(/[\uD800-\uDBFF]$/u, '')}...`;
128
+ const preview = body.slice(0, budget - label.length - 1).replace(/[\uD800-\uDBFF]$/u, '');
129
+ truncated ||= label.length < path.length || preview.length < body.length;
130
+ source += `${separator}${label}\n`;
131
+ const start = source.length;
132
+ source += preview;
133
+ if (!result.error)
134
+ result.contentRange = { start, end: source.length };
135
+ projected.push(result);
128
136
  }
129
137
  return {
130
138
  source,
131
- ...preview,
132
- data: { mode: 'batch', results: projected, truncated: preview.truncated }
139
+ summary: source,
140
+ truncated,
141
+ data: { mode: 'batch', results: projected, truncated }
133
142
  };
134
143
  }
135
144
  export class ReadTool {
@@ -174,6 +174,8 @@ export function publicCodeObservations(values, data) {
174
174
  export function publicOutputTruncation(toolName, data) {
175
175
  if (!isRecord(data))
176
176
  return undefined;
177
+ if (toolName === 'read' && data.mode === 'batch' && data.truncated === true)
178
+ return 'SOURCE';
177
179
  if (toolName === 'code_exec' || toolName === 'code_exec_wait') {
178
180
  if (data.outputSourceTruncated === true)
179
181
  return 'SOURCE';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myagentroam/agent",
3
- "version": "0.11.69",
3
+ "version": "0.11.70",
4
4
  "description": "Embeddable MAR coding agent SDK and CLI.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",