@qwen-code/arena-agent 0.0.6 → 0.0.7-preview.0

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 (57) hide show
  1. package/.env.example +12 -19
  2. package/README.md +26 -133
  3. package/dist/agent.d.ts +3 -9
  4. package/dist/agent.js +108 -246
  5. package/dist/agent.js.map +1 -1
  6. package/dist/cli.js +12 -51
  7. package/dist/cli.js.map +1 -1
  8. package/dist/config.d.ts +1 -6
  9. package/dist/config.js +2 -28
  10. package/dist/config.js.map +1 -1
  11. package/dist/fetch-page.js +7 -18
  12. package/dist/fetch-page.js.map +1 -1
  13. package/dist/history.d.ts +3 -3
  14. package/dist/history.js +4 -4
  15. package/dist/history.js.map +1 -1
  16. package/dist/mock.js +9 -25
  17. package/dist/mock.js.map +1 -1
  18. package/dist/prompts.d.ts +4 -0
  19. package/dist/prompts.js +57 -0
  20. package/dist/prompts.js.map +1 -0
  21. package/dist/protocol.d.ts +2 -4
  22. package/dist/protocol.js +1 -17
  23. package/dist/protocol.js.map +1 -1
  24. package/dist/provider.d.ts +0 -4
  25. package/dist/provider.js +11 -169
  26. package/dist/provider.js.map +1 -1
  27. package/dist/repo.d.ts +4 -0
  28. package/dist/repo.js +84 -0
  29. package/dist/repo.js.map +1 -0
  30. package/dist/server.js +184 -26
  31. package/dist/server.js.map +1 -1
  32. package/dist/spec.d.ts +11 -6
  33. package/dist/spec.js +74 -123
  34. package/dist/spec.js.map +1 -1
  35. package/dist/tools.d.ts +2 -5
  36. package/dist/tools.js +237 -134
  37. package/dist/tools.js.map +1 -1
  38. package/dist/tui.js +18 -53
  39. package/dist/tui.js.map +1 -1
  40. package/dist/types.d.ts +24 -25
  41. package/dist/web/app.js +3 -2
  42. package/dist/web/app.js.map +1 -1
  43. package/docs/SDK.md +521 -0
  44. package/package.json +5 -4
  45. package/spec/tools.json +418 -0
  46. package/dist/anthropic.d.ts +0 -16
  47. package/dist/anthropic.js +0 -391
  48. package/dist/anthropic.js.map +0 -1
  49. package/dist/attachments.d.ts +0 -29
  50. package/dist/attachments.js +0 -222
  51. package/dist/attachments.js.map +0 -1
  52. package/dist/canonical-data.d.ts +0 -2
  53. package/dist/canonical-data.js +0 -4
  54. package/dist/canonical-data.js.map +0 -1
  55. package/dist/compaction.d.ts +0 -16
  56. package/dist/compaction.js +0 -182
  57. package/dist/compaction.js.map +0 -1
package/dist/agent.js CHANGED
@@ -1,9 +1,8 @@
1
1
  import crypto from "node:crypto";
2
- import { setTimeout as delay } from "node:timers/promises";
3
- import { compactMessagesIfNeeded } from "./compaction.js";
4
2
  import { MockModelClient } from "./mock.js";
5
3
  import { HttpModelClient } from "./provider.js";
6
- import { initialMessages, interruptedUserMessage, isCanonicalSystemMessage, } from "./spec.js";
4
+ import { detectRepoContext } from "./repo.js";
5
+ import { defaultClientContext, initialMessages, interruptedUserMessage, isCanonicalSystemMessage, repoContextFromSystemMessage, repoSystemMessage, toolDefinitions, } from "./spec.js";
7
6
  import { ToolExecutor } from "./tools.js";
8
7
  function parseToolResult(content) {
9
8
  try {
@@ -13,76 +12,6 @@ function parseToolResult(content) {
13
12
  return {};
14
13
  }
15
14
  }
16
- // Network faults that abort an in-flight stream (a dropped socket, a reset, a
17
- // DNS blip). undici surfaces these mid-stream as `TypeError: fetch failed` or
18
- // `TypeError: terminated`; some are also reachable via an errno-style code on
19
- // the error or its cause.
20
- const retryableStreamCodes = new Set([
21
- "ECONNRESET",
22
- "ECONNREFUSED",
23
- "ECONNABORTED",
24
- "EPIPE",
25
- "ETIMEDOUT",
26
- "ENETUNREACH",
27
- "ENETDOWN",
28
- "EHOSTUNREACH",
29
- "EAI_AGAIN",
30
- "UND_ERR_SOCKET",
31
- "UND_ERR_CONNECT_TIMEOUT",
32
- "UND_ERR_HEADERS_TIMEOUT",
33
- "UND_ERR_BODY_TIMEOUT",
34
- "ARENA_STREAM_IDLE_TIMEOUT",
35
- ]);
36
- function describeError(error) {
37
- return error instanceof Error ? error.message : String(error);
38
- }
39
- function errorCode(error) {
40
- const direct = error?.code;
41
- if (typeof direct === "string")
42
- return direct;
43
- const cause = error?.cause?.code;
44
- return typeof cause === "string" ? cause : undefined;
45
- }
46
- function isRetryableStreamError(error) {
47
- if (error instanceof TypeError)
48
- return true;
49
- const code = errorCode(error);
50
- return code !== undefined && retryableStreamCodes.has(code);
51
- }
52
- function completeInterruptedToolCalls(messages) {
53
- const completed = [];
54
- let pending = [];
55
- const flushPending = () => {
56
- for (const call of pending) {
57
- completed.push({
58
- role: "tool",
59
- tool_call_id: call.id,
60
- content: JSON.stringify({
61
- status: "error",
62
- tool: call.function.name,
63
- error: "tool result was not recorded because the previous process stopped",
64
- interrupted: true,
65
- }),
66
- });
67
- }
68
- pending = [];
69
- };
70
- for (const message of messages) {
71
- if (pending.length && message.role !== "tool")
72
- flushPending();
73
- completed.push(message);
74
- if (message.role === "assistant") {
75
- pending = [...(message.tool_calls || [])];
76
- }
77
- else if (message.role === "tool") {
78
- const index = pending.findIndex((call) => call.id === message.tool_call_id);
79
- if (index !== -1)
80
- pending.splice(index, 1);
81
- }
82
- }
83
- flushPending();
84
- return completed;
85
- }
86
15
  class PartialAssistantTurnError extends Error {
87
16
  cause;
88
17
  assistant;
@@ -93,12 +22,19 @@ class PartialAssistantTurnError extends Error {
93
22
  this.name = "PartialAssistantTurnError";
94
23
  }
95
24
  }
25
+ // Mode is fixed at the first turn: resume reads it back from the history's
26
+ // system message, so a mid-session clone or detached HEAD cannot flip it.
27
+ // Exported so the replay script checks the same decision instead of redoing it.
28
+ export function resolveRepoContext(workspace, history) {
29
+ return history?.length
30
+ ? repoContextFromSystemMessage(history[0])
31
+ : detectRepoContext(workspace);
32
+ }
96
33
  export class Agent {
97
34
  config;
98
35
  sink;
99
36
  options;
100
37
  client;
101
- tools;
102
38
  sessionId;
103
39
  constructor(config, sink, options = {}) {
104
40
  this.config = config;
@@ -109,12 +45,6 @@ export class Agent {
109
45
  (config.model.startsWith("mock/")
110
46
  ? new MockModelClient()
111
47
  : new HttpModelClient(config));
112
- this.tools =
113
- options.tools ||
114
- new ToolExecutor(config, {
115
- signal: options.signal,
116
- workspaceContext: options.workspaceContext,
117
- });
118
48
  this.sessionId =
119
49
  options.sessionId || crypto.randomUUID().replaceAll("-", "");
120
50
  }
@@ -124,35 +54,35 @@ export class Agent {
124
54
  const userMessage = runOptions.interrupted
125
55
  ? interruptedUserMessage(baseUserMessage)
126
56
  : structuredClone(baseUserMessage);
57
+ const clientContext = this.options.clientContext || defaultClientContext();
58
+ const repoContext = resolveRepoContext(this.config.workspace, history);
59
+ const tools = new ToolExecutor(this.config, {
60
+ signal: this.options.signal,
61
+ askUserHandler: this.options.askUserHandler,
62
+ });
127
63
  const messages = history?.length
128
- ? completeInterruptedToolCalls(structuredClone(history))
129
- : initialMessages(prompt, this.options.clientContext, this.options.workspaceContext);
64
+ ? structuredClone(history)
65
+ : initialMessages(prompt, clientContext, repoContext);
130
66
  if (history?.length) {
131
- if (!isCanonicalSystemMessage(messages[0], this.options.workspaceContext)) {
132
- if (this.options.workspaceContext &&
133
- isCanonicalSystemMessage(messages[0])) {
134
- messages[0] = initialMessages("", this.options.clientContext, this.options.workspaceContext)[0];
135
- }
136
- else {
137
- throw new Error("history does not match the current workspace runtime context");
138
- }
67
+ // repo 模式下 canonical 的判据是用 history 里的仓库变量重新生成的
68
+ // 那条 system message,通用模式落回 fixture。
69
+ const expected = repoContext
70
+ ? repoSystemMessage(clientContext, repoContext)
71
+ : undefined;
72
+ if (!isCanonicalSystemMessage(messages[0], expected)) {
73
+ throw new Error("history does not start with the canonical system message");
139
74
  }
140
75
  messages.push(userMessage);
141
76
  }
142
77
  else {
143
78
  messages[1] = userMessage;
144
79
  }
145
- await this.maybeCompact(messages);
146
80
  this.sink.start(this.sessionId, messages);
147
81
  try {
148
- await this.checkpoint(messages);
149
- for (let step = 1;; step += 1) {
82
+ for (let step = 1; step <= this.config.maxSteps; step += 1) {
150
83
  if (this.options.signal?.aborted) {
151
84
  throw this.options.signal.reason || new Error("operation cancelled");
152
85
  }
153
- if (step > 1 && (await this.maybeCompact(messages))) {
154
- await this.checkpoint(messages);
155
- }
156
86
  this.sink.modelStart(this.sessionId, step);
157
87
  let assistant;
158
88
  try {
@@ -163,17 +93,15 @@ export class Agent {
163
93
  if (error.assistant) {
164
94
  messages.push(error.assistant);
165
95
  this.sink.message(this.sessionId, error.assistant, messages);
166
- await this.checkpoint(messages);
167
96
  }
168
97
  throw error.cause;
169
98
  }
170
99
  throw error;
171
100
  }
172
101
  const finishReason = assistant.tool_calls?.length ? "tool_calls" : "stop";
173
- this.sink.modelComplete(this.sessionId, step, finishReason, assistant.usage);
102
+ this.sink.modelComplete(this.sessionId, step, finishReason);
174
103
  messages.push(assistant);
175
104
  this.sink.message(this.sessionId, assistant, messages);
176
- await this.checkpoint(messages);
177
105
  if (!assistant.tool_calls?.length) {
178
106
  return this.sink.result(this.sessionId, "success", messages);
179
107
  }
@@ -182,7 +110,7 @@ export class Agent {
182
110
  const toolCallId = String(call.id || "");
183
111
  const toolName = String(call.function?.name || "tool");
184
112
  this.sink.toolStart(this.sessionId, toolCallId, toolName);
185
- const toolMessage = await this.tools.execute(call);
113
+ const toolMessage = await tools.execute(call);
186
114
  const toolResult = parseToolResult(toolMessage.content);
187
115
  const skippedAskUser = toolName === "ask_user" && toolResult.skipped === true;
188
116
  if (this.options.signal?.aborted && !skippedAskUser) {
@@ -191,15 +119,13 @@ export class Agent {
191
119
  messages.push(toolMessage);
192
120
  completedToolCallIds.push(toolCallId);
193
121
  this.sink.message(this.sessionId, toolMessage, messages);
194
- await this.checkpoint(messages);
195
122
  this.sink.toolComplete(this.sessionId, toolCallId, toolName);
196
123
  if (toolName === "ask_user") {
197
124
  if (toolResult.status === "needs_input") {
198
- const visualMessage = this.tools.takeVisualMessage(completedToolCallIds);
125
+ const visualMessage = tools.takeVisualMessage(completedToolCallIds);
199
126
  if (visualMessage) {
200
127
  messages.push(visualMessage);
201
128
  this.sink.message(this.sessionId, visualMessage, messages);
202
- await this.checkpoint(messages);
203
129
  }
204
130
  const questions = Array.isArray(toolResult.questions)
205
131
  ? toolResult.questions
@@ -212,169 +138,105 @@ export class Agent {
212
138
  throw this.options.signal.reason || new Error("operation cancelled");
213
139
  }
214
140
  }
215
- const visualMessage = this.tools.takeVisualMessage(completedToolCallIds);
141
+ const visualMessage = tools.takeVisualMessage(completedToolCallIds);
216
142
  if (visualMessage) {
217
143
  messages.push(visualMessage);
218
144
  this.sink.message(this.sessionId, visualMessage, messages);
219
- await this.checkpoint(messages);
220
145
  }
221
146
  }
147
+ return this.sink.result(this.sessionId, "error", messages, "agent exceeded ARENA_MAX_STEPS");
222
148
  }
223
149
  catch (error) {
224
150
  const message = error instanceof Error ? error.message : String(error);
225
151
  return this.sink.result(this.sessionId, "error", messages, message);
226
152
  }
227
153
  }
228
- async checkpoint(messages) {
229
- await this.options.onCheckpoint?.(messages);
230
- }
231
- async maybeCompact(messages) {
232
- try {
233
- const result = await compactMessagesIfNeeded(messages, this.tools.availableTools(), this.client, this.config.model, {
234
- contextWindow: this.config.contextWindow,
235
- triggerRatio: this.config.contextCompactionRatio,
236
- summaryMaxTokens: this.config.compactionSummaryMaxTokens,
237
- }, this.options.signal);
238
- if (result.compacted) {
239
- // The summary request's tokens belong to no history message (the
240
- // summarized prefix is replaced), so the event stream is the only
241
- // place its usage can be accounted for.
242
- this.sink.compaction(this.sessionId, result.usage);
243
- }
244
- return result.compacted;
245
- }
246
- catch {
247
- // Compaction is protective rather than task-critical. If its dedicated
248
- // summary request fails, keep the original history and let the normal
249
- // model request (and its retry policy) decide whether it still fits.
250
- return false;
251
- }
252
- }
253
154
  async assistantTurn(messages) {
254
- // A mid-stream network fault loses only the tokens produced so far, not the
255
- // conversation: the request is idempotent, so the whole turn is re-issued
256
- // from scratch. Accumulators live inside the loop and reset each attempt, so
257
- // the assistant message written to history reflects one clean completion.
258
- const maxRetries = Math.max(0, Math.floor(this.config.modelMaxRetries ?? 5));
259
- for (let attempt = 0;; attempt += 1) {
260
- const contentParts = [];
261
- const reasoningParts = [];
262
- const calls = new Map();
263
- let usage;
264
- let reasoningDetails;
265
- try {
266
- const stream = this.client.stream({
267
- model: this.config.model,
268
- messages: structuredClone(messages),
269
- tools: this.tools.availableTools(),
270
- toolChoice: this.config.toolChoice,
271
- temperature: this.config.temperature,
272
- maxTokens: this.config.maxTokens,
273
- enableThinking: this.config.enableThinking,
274
- thinkingBudget: this.config.thinkingBudget,
275
- signal: this.options.signal,
276
- });
277
- for await (const chunk of stream) {
278
- // With stream_options.include_usage the usage arrives on the final
279
- // chunk; providers that report it cumulatively are covered by
280
- // letting the last non-empty value win.
281
- if (chunk.usage)
282
- usage = chunk.usage;
283
- if (chunk.reasoning_details?.length) {
284
- reasoningDetails = chunk.reasoning_details;
285
- }
286
- const delta = chunk.choices?.[0]?.delta || {};
287
- if (delta.content) {
288
- const content = String(delta.content);
289
- contentParts.push(content);
290
- this.sink.delta(this.sessionId, { content });
155
+ const contentParts = [];
156
+ const reasoningParts = [];
157
+ const calls = new Map();
158
+ const stream = this.client.stream({
159
+ model: this.config.model,
160
+ messages: structuredClone(messages),
161
+ tools: toolDefinitions(),
162
+ toolChoice: this.config.toolChoice,
163
+ temperature: this.config.temperature,
164
+ maxTokens: this.config.maxTokens,
165
+ enableThinking: this.config.enableThinking,
166
+ thinkingBudget: this.config.thinkingBudget,
167
+ preserveThinking: this.config.preserveThinking,
168
+ signal: this.options.signal,
169
+ });
170
+ try {
171
+ for await (const chunk of stream) {
172
+ const delta = chunk.choices?.[0]?.delta || {};
173
+ if (delta.content) {
174
+ const content = String(delta.content);
175
+ contentParts.push(content);
176
+ this.sink.delta(this.sessionId, { content });
177
+ }
178
+ const reasoning = delta.reasoning_content || delta.reasoning;
179
+ if (reasoning) {
180
+ const value = String(reasoning);
181
+ reasoningParts.push(value);
182
+ this.sink.delta(this.sessionId, { reasoning_content: value });
183
+ }
184
+ for (const [position, fragment] of (delta.tool_calls || []).entries()) {
185
+ const index = Number(fragment.index ?? position);
186
+ const call = calls.get(index) ||
187
+ {
188
+ id: "",
189
+ type: "function",
190
+ function: { name: "", arguments: "" },
191
+ };
192
+ if (fragment.id)
193
+ call.id += String(fragment.id);
194
+ if (fragment.function?.name) {
195
+ call.function.name += String(fragment.function.name);
291
196
  }
292
- const reasoning = delta.reasoning_content || delta.reasoning;
293
- if (reasoning) {
294
- const value = String(reasoning);
295
- reasoningParts.push(value);
296
- this.sink.delta(this.sessionId, { reasoning_content: value });
197
+ if (fragment.function?.arguments) {
198
+ call.function.arguments += String(fragment.function.arguments);
297
199
  }
298
- for (const [position, fragment] of (delta.tool_calls || []).entries()) {
299
- const index = Number(fragment.index ?? position);
300
- const call = calls.get(index) ||
200
+ calls.set(index, call);
201
+ this.sink.delta(this.sessionId, {
202
+ tool_calls: [
301
203
  {
302
- id: "",
303
- type: "function",
304
- function: { name: "", arguments: "" },
305
- };
306
- if (fragment.id)
307
- call.id += String(fragment.id);
308
- if (fragment.function?.name) {
309
- call.function.name += String(fragment.function.name);
310
- }
311
- if (fragment.function?.arguments) {
312
- call.function.arguments += String(fragment.function.arguments);
313
- }
314
- calls.set(index, call);
315
- this.sink.delta(this.sessionId, {
316
- tool_calls: [
317
- {
318
- index,
319
- id: String(fragment.id || ""),
320
- type: String(fragment.type || ""),
321
- function: {
322
- name: String(fragment.function?.name || ""),
323
- arguments: String(fragment.function?.arguments || ""),
324
- },
204
+ index,
205
+ id: String(fragment.id || ""),
206
+ type: String(fragment.type || ""),
207
+ function: {
208
+ name: String(fragment.function?.name || ""),
209
+ arguments: String(fragment.function?.arguments || ""),
325
210
  },
326
- ],
327
- });
328
- }
211
+ },
212
+ ],
213
+ });
329
214
  }
330
215
  }
331
- catch (error) {
332
- // A user cancellation is not a transient fault: skip the retry, but
333
- // still fall through so any partial output is preserved in history.
334
- const aborted = Boolean(this.options.signal?.aborted);
335
- if (!aborted && isRetryableStreamError(error) && attempt < maxRetries) {
336
- this.sink.modelRetry(this.sessionId, attempt + 1, describeError(error));
337
- await this.retryBackoff(attempt);
338
- continue;
216
+ }
217
+ catch (error) {
218
+ const content = contentParts.join("");
219
+ const reasoningContent = reasoningParts.join("");
220
+ const partial = content || reasoningContent
221
+ ? {
222
+ role: "assistant",
223
+ content,
224
+ reasoning_content: reasoningContent,
339
225
  }
340
- const content = contentParts.join("");
341
- const reasoningContent = reasoningParts.join("");
342
- const partial = content || reasoningContent
343
- ? {
344
- role: "assistant",
345
- content,
346
- reasoning_content: reasoningContent,
347
- ...(usage ? { usage } : {}),
348
- ...(reasoningDetails ? { reasoning_details: reasoningDetails } : {}),
349
- }
350
- : undefined;
351
- throw new PartialAssistantTurnError(error, partial);
352
- }
353
- const assistant = {
354
- role: "assistant",
355
- content: contentParts.join(""),
356
- reasoning_content: reasoningParts.join(""),
357
- };
358
- if (usage)
359
- assistant.usage = usage;
360
- if (reasoningDetails)
361
- assistant.reasoning_details = reasoningDetails;
362
- if (calls.size) {
363
- assistant.tool_calls = [...calls.entries()]
364
- .sort(([left], [right]) => left - right)
365
- .map(([, call]) => call);
366
- }
367
- return assistant;
226
+ : undefined;
227
+ throw new PartialAssistantTurnError(error, partial);
368
228
  }
369
- }
370
- async retryBackoff(attempt) {
371
- const base = Math.max(0, this.config.modelRetryBaseMs ?? 1000);
372
- const maximum = Math.max(0, this.config.modelRetryMaxMs ?? 30000);
373
- const exponential = Math.min(maximum, base * 2 ** Math.min(attempt, 30));
374
- const wait = Math.floor(exponential * Math.random());
375
- if (wait <= 0)
376
- return;
377
- await delay(wait, undefined, { signal: this.options.signal });
229
+ const assistant = {
230
+ role: "assistant",
231
+ content: contentParts.join(""),
232
+ reasoning_content: reasoningParts.join(""),
233
+ };
234
+ if (calls.size) {
235
+ assistant.tool_calls = [...calls.entries()]
236
+ .sort(([left], [right]) => left - right)
237
+ .map(([, call]) => call);
238
+ }
239
+ return assistant;
378
240
  }
379
241
  }
380
242
  export function finalText(result) {
package/dist/agent.js.map CHANGED
@@ -1 +1 @@
1
- {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OAAO,CAAC;QACzB,CAAC;IACH,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
package/dist/cli.js CHANGED
@@ -3,7 +3,6 @@ import crypto from "node:crypto";
3
3
  import path from "node:path";
4
4
  import dotenv from "dotenv";
5
5
  import { Agent, finalText } from "./agent.js";
6
- import { attachmentUserMessage, maxAttachmentBytesPerMessage, maxAttachmentsPerMessage, stageAttachment, } from "./attachments.js";
7
6
  import { configFromEnv } from "./config.js";
8
7
  import { loadStoredHistory, saveStoredHistory, storedHistoryPath, } from "./history.js";
9
8
  import { EventSink } from "./protocol.js";
@@ -11,9 +10,9 @@ import { startServer } from "./server.js";
11
10
  import { defaultClientContext } from "./spec.js";
12
11
  import { runTui } from "./tui.js";
13
12
  const version = "0.2.0";
14
- function nextValue(argumentsList, index, name, allowDash = false) {
13
+ function nextValue(argumentsList, index, name) {
15
14
  const value = argumentsList[index + 1];
16
- if (!value || (!allowDash && value.startsWith("-"))) {
15
+ if (!value || value.startsWith("-")) {
17
16
  throw new Error(`${name} requires a value`);
18
17
  }
19
18
  return value;
@@ -23,16 +22,11 @@ function parsePromptOptions(argumentsList) {
23
22
  prompt: "",
24
23
  output: "text",
25
24
  workspace: process.cwd(),
26
- attachments: [],
27
25
  };
28
26
  for (let index = 0; index < argumentsList.length; index += 1) {
29
27
  const argument = argumentsList[index];
30
28
  if (argument === "-p" || argument === "--prompt") {
31
- options.prompt = nextValue(argumentsList, index, argument, true);
32
- index += 1;
33
- }
34
- else if (argument === "--attach" || argument === "--image") {
35
- options.attachments.push(nextValue(argumentsList, index, argument));
29
+ options.prompt = nextValue(argumentsList, index, argument);
36
30
  index += 1;
37
31
  }
38
32
  else if (argument === "--output") {
@@ -64,13 +58,9 @@ function parsePromptOptions(argumentsList) {
64
58
  process.exit(0);
65
59
  }
66
60
  else if (argument === "-h" || argument === "--help") {
67
- console.log("Usage: arena -p <prompt> [--attach path|url ...] [--output text|json|stream-json] [--workspace path] [--session-id id|--history-file path]\n" +
61
+ console.log("Usage: arena -p <prompt> [--output text|json|stream-json] [--workspace path] [--session-id id|--history-file path]\n" +
68
62
  " arena tui [--workspace path] [--model name] [--session-id id|--history-file path]\n" +
69
- " arena serve [--host 127.0.0.1] [--port 3000] [--workspace path]\n" +
70
- "\n" +
71
- " --attach (alias --image) saves a local file or downloaded URL into the\n" +
72
- " workspace uploads/ directory and attaches it to the prompt; images are\n" +
73
- " also sent to the model as image content. Repeat the flag for multiple files.");
63
+ " arena serve [--host 127.0.0.1] [--port 3000] [--workspace path]");
74
64
  process.exit(0);
75
65
  }
76
66
  else {
@@ -171,15 +161,6 @@ function confinedHistoryPath(workspace, value) {
171
161
  }
172
162
  async function runPrompt(options) {
173
163
  const workspace = path.resolve(options.workspace);
174
- // Same runtime context as the TUI: the system prompt and tool schemas
175
- // reflect the actual workspace paths, so TUI and headless runs of one
176
- // session are interchangeable. Headless has no viewer, so present_file is
177
- // withheld just like in the TUI.
178
- const workspaceContext = {
179
- root: workspace,
180
- cwd: workspace,
181
- presentFile: false,
182
- };
183
164
  dotenv.config({
184
165
  path: path.join(workspace, ".env"),
185
166
  override: false,
@@ -190,40 +171,20 @@ async function runPrompt(options) {
190
171
  config.model = options.model;
191
172
  const sink = new EventSink({ format: options.output });
192
173
  const sessionId = options.sessionId || crypto.randomUUID();
193
- const sessionHistoryPath = storedHistoryPath(config.stateRoot, config.tenantId, sessionId);
174
+ const sessionHistoryPath = storedHistoryPath(workspace, config.tenantId, sessionId);
194
175
  const suppliedHistoryPath = options.historyFile
195
176
  ? confinedHistoryPath(workspace, options.historyFile)
196
177
  : undefined;
197
178
  const history = await loadStoredHistory(suppliedHistoryPath || sessionHistoryPath);
198
- let userMessage;
199
- if (options.attachments.length) {
200
- if (options.attachments.length > maxAttachmentsPerMessage) {
201
- throw new Error(`a message may include at most ${maxAttachmentsPerMessage} attachments`);
202
- }
203
- const attachments = [];
204
- for (const source of options.attachments) {
205
- attachments.push(await stageAttachment(workspace, source));
206
- }
207
- const totalBytes = attachments.reduce((total, attachment) => total + attachment.size, 0);
208
- if (totalBytes > maxAttachmentBytesPerMessage) {
209
- throw new Error(`message attachments exceed ${maxAttachmentBytesPerMessage} bytes`);
210
- }
211
- userMessage = attachmentUserMessage(options.prompt, attachments);
212
- }
213
- const persistHistory = async (messages) => {
214
- await saveStoredHistory(sessionHistoryPath, messages);
215
- if (suppliedHistoryPath &&
216
- path.resolve(suppliedHistoryPath) !== path.resolve(sessionHistoryPath)) {
217
- await saveStoredHistory(suppliedHistoryPath, messages);
218
- }
219
- };
220
179
  const result = await new Agent(config, sink, {
221
180
  sessionId,
222
181
  clientContext: defaultClientContext(),
223
- workspaceContext,
224
- onCheckpoint: persistHistory,
225
- }).run(options.prompt, history, { userMessage });
226
- await persistHistory(result.messages);
182
+ }).run(options.prompt, history);
183
+ await saveStoredHistory(sessionHistoryPath, result.messages);
184
+ if (suppliedHistoryPath &&
185
+ path.resolve(suppliedHistoryPath) !== path.resolve(sessionHistoryPath)) {
186
+ await saveStoredHistory(suppliedHistoryPath, result.messages);
187
+ }
227
188
  if (options.output === "json") {
228
189
  console.log(JSON.stringify(result));
229
190
  }