@openagents-org/agent-launcher 0.2.222 → 0.2.224

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openagents-org/agent-launcher",
3
- "version": "0.2.222",
3
+ "version": "0.2.224",
4
4
  "description": "OpenAgents Launcher — install, configure, and run AI coding agents from your terminal",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -15,10 +15,35 @@
15
15
 
16
16
  const { redactSecrets } = require('./utils');
17
17
 
18
- /** Build the argv tail (everything after the binary) for one headless run. */
19
- function buildAgyArgv({ prompt, model, conversationId, skipResume = false } = {}) {
18
+ /**
19
+ * Longest prompt passed as `-p <prompt>`. Past it the prompt goes over stdin
20
+ * (agyStdinMessage). Windows caps a whole command line at 32,767 characters
21
+ * and Node fails the spawn itself with ENAMETOOLONG — the system prompt plus a
22
+ * large pinned glossary got there with a one-word message. Linux caps a single
23
+ * argument at 128 KiB. Both limits are left headroom for quoting and the rest
24
+ * of the argv.
25
+ */
26
+ function agyPromptFitsArgv(prompt, platform = process.platform) {
27
+ const limit = platform === 'win32' ? 24000 : 100000;
28
+ return String(prompt || '').length <= limit;
29
+ }
30
+
31
+ /**
32
+ * The stdin line for a prompt sent with `--input-format stream-json` — the
33
+ * only stdin input headless agy accepts (plain-text stdin is not read, and a
34
+ * `-p` prompt is dropped in this mode). antigravity.google/docs/cli/headless
35
+ */
36
+ function agyStdinMessage(prompt) {
37
+ return `${JSON.stringify({ event: 'user', message: { content: String(prompt || '') } })}\n`;
38
+ }
39
+
40
+ /**
41
+ * Build the argv tail (everything after the binary) for one headless run.
42
+ * `viaStdin` leaves the prompt out: the caller writes agyStdinMessage(prompt).
43
+ */
44
+ function buildAgyArgv({ prompt, model, conversationId, skipResume = false, viaStdin = false } = {}) {
20
45
  const args = [
21
- '-p', prompt || '',
46
+ ...(viaStdin ? ['--input-format', 'stream-json'] : ['-p', prompt || '']),
22
47
  // Counterpart of gemini's `-y`: headless runs have no interactive
23
48
  // approval prompt, and a soft-denied tool call silently degrades the
24
49
  // answer. The daemon is the approval boundary here, same as every other
@@ -297,6 +322,8 @@ function agyBinaryCandidates({ home, isWindows, localAppData } = {}) {
297
322
  }
298
323
 
299
324
  module.exports = {
325
+ agyPromptFitsArgv,
326
+ agyStdinMessage,
300
327
  buildAgyArgv,
301
328
  parseAgyEvent,
302
329
  toolPreview,
@@ -28,6 +28,8 @@ const { whereBinary } = require('../paths');
28
28
  const { formatAttachmentsForPrompt, SESSION_DEFAULT_RE, generateSessionTitle } = require('./utils');
29
29
  const { buildClaudeSystemPrompt } = require('./workspace-prompt');
30
30
  const {
31
+ agyPromptFitsArgv,
32
+ agyStdinMessage,
31
33
  buildAgyArgv,
32
34
  parseAgyEvent,
33
35
  AgyRunState,
@@ -175,13 +177,16 @@ class AntigravityAdapter extends BaseAdapter {
175
177
  const env = this.agentEnv || process.env;
176
178
  const model = (env.ANTIGRAVITY_MODEL || env.AGY_MODEL || '').trim();
177
179
 
180
+ // Too long for a command line: send it over stdin instead.
181
+ const viaStdin = !agyPromptFitsArgv(fullPrompt);
178
182
  const args = buildAgyArgv({
179
183
  prompt: fullPrompt,
180
184
  model,
181
185
  conversationId: this._channelConversations[channelName],
182
186
  skipResume,
187
+ viaStdin,
183
188
  });
184
- return { cmd: [agyBin, ...args] };
189
+ return { cmd: [agyBin, ...args], stdinPrompt: viaStdin ? fullPrompt : null };
185
190
  }
186
191
 
187
192
  async _handleMessage(msg) {
@@ -225,6 +230,7 @@ class AntigravityAdapter extends BaseAdapter {
225
230
  await this.sendStatus(msgChannel, 'thinking...');
226
231
 
227
232
  let cmd;
233
+ let stdinPrompt = null;
228
234
  const cleanEnv = { ...(this.agentEnv || process.env) };
229
235
 
230
236
  let _shouldRetry = false;
@@ -232,6 +238,7 @@ class AntigravityAdapter extends BaseAdapter {
232
238
  try {
233
239
  const built = this._buildAgyCmd(content, msgChannel, { skipResume: attempt > 0 });
234
240
  cmd = built.cmd;
241
+ stdinPrompt = built.stdinPrompt;
235
242
  } catch (e) {
236
243
  await this.sendError(msgChannel, e.message);
237
244
  return;
@@ -242,13 +249,21 @@ class AntigravityAdapter extends BaseAdapter {
242
249
 
243
250
  try {
244
251
  const proc = spawn(cmd[0], cmd.slice(1), {
245
- stdio: ['ignore', 'pipe', 'pipe'],
252
+ stdio: [stdinPrompt ? 'pipe' : 'ignore', 'pipe', 'pipe'],
246
253
  env: cleanEnv,
247
254
  cwd: this.workingDir,
248
255
  detached: !IS_WINDOWS,
249
256
  windowsHide: true,
250
257
  });
251
258
  this._channelProcesses[msgChannel] = proc;
259
+ // One turn, then EOF. Streaming input is a multi-turn mode; should
260
+ // agy keep running after its result anyway, the run is over then and
261
+ // it is stopped (see processLine), which is not a failure.
262
+ let stoppedAfterResult = false;
263
+ if (stdinPrompt && proc.stdin) {
264
+ proc.stdin.on('error', () => {});
265
+ proc.stdin.end(agyStdinMessage(stdinPrompt));
266
+ }
252
267
 
253
268
  const run = new AgyRunState();
254
269
  let stderrBuf = '';
@@ -301,11 +316,19 @@ class AntigravityAdapter extends BaseAdapter {
301
316
  try { await this.sendStatus(msgChannel, `${action.name} › ${action.preview}`); } catch {}
302
317
  }
303
318
  // 'result' is read from `run` after exit.
319
+ if (action.type === 'result' && stdinPrompt) {
320
+ setTimeout(() => {
321
+ if (proc.exitCode !== null || proc.signalCode !== null) return;
322
+ stoppedAfterResult = true;
323
+ this._stopProcess(proc).catch(() => {});
324
+ }, 5000).unref();
325
+ }
304
326
  }
305
327
  };
306
328
 
307
- proc.on('exit', async (code) => {
329
+ proc.on('exit', async (exitCode) => {
308
330
  if (timeoutTimer) clearInterval(timeoutTimer);
331
+ const code = stoppedAfterResult ? 0 : exitCode;
309
332
 
310
333
  try { await _pendingLines; } catch {}
311
334
 
@@ -71,6 +71,8 @@ const FAILURE_MESSAGES = {
71
71
  provider_not_configured: 'CodeArts Agent has no usable model provider. Check CODEARTS_MODEL, then retry.',
72
72
  model_not_found: "This account can't use the configured model. Pick one from the model list in this agent's configuration (or run `codearts models`), set CODEARTS_MODEL, then retry.",
73
73
  rate_limited: 'The model service is rate-limiting requests. Wait a moment and retry.',
74
+ quota_exhausted: 'The model service account has run out of balance or credit. Top it up, or give this agent a key with credit, then retry.',
75
+ request_too_large: 'The model service refused the request as too large — the conversation or its attachments exceed what it accepts. Start a new thread or send less, then retry.',
74
76
  network_error: 'CodeArts Agent could not reach Huawei Cloud (network or service error). Retry shortly.',
75
77
  provider_server_error: 'The model service returned a server error. Retry shortly.',
76
78
  timeout: 'CodeArts Agent timed out before producing a reply. Retry; if it persists, check the model configuration.',
@@ -444,6 +444,22 @@ function classifyCodeBuddyRun({ result = null, code = null, signal = null, stder
444
444
  const detail = result.errors[0]
445
445
  || result.errorsInfo.map((e) => e.details).find(Boolean)
446
446
  || '';
447
+ // `400 model [default-model] service info not found … Currently supported
448
+ // models: …` — the account has nothing behind that model id or alias, and
449
+ // every run fails until the agent names one it does have. Seen in the
450
+ // field on the bare `default-model` alias; the CLI's list of models is
451
+ // kept (it is the answer), the request ids are not.
452
+ const missing = /model \[([^\]]+)\] service info not found/i.exec(String(detail));
453
+ if (missing) {
454
+ const supported = /currently supported models?[^::]*[::]\s*([\s\S]*)/i.exec(String(detail));
455
+ return {
456
+ kind: 'model_unavailable',
457
+ ok: false,
458
+ userMessage: `This CodeBuddy account has no model behind "${missing[1]}". ` +
459
+ 'Set CODEBUDDY_MODEL in this agent\'s configuration to a model the account offers' +
460
+ (supported ? `: ${truncate(redactSecrets(supported[1].trim()), 300)}` : ', then retry.'),
461
+ };
462
+ }
447
463
  return {
448
464
  kind: 'run_error',
449
465
  ok: false,
@@ -953,6 +953,14 @@ class CodexAdapter extends BaseAdapter {
953
953
  'at an endpoint that supports the full Responses API, or edit the agent and set Agent capabilities to ' +
954
954
  '"Chat only · Chat Completions API" (it then answers without running tools on this device).';
955
955
  }
956
+ // A model the user's ChatGPT plan doesn't include for Codex. Seen in the
957
+ // field with several model names picked in the workspace; every run
958
+ // fails the same way until another model is chosen.
959
+ if (/not supported when using Codex with a ChatGPT account/i.test(detail)) {
960
+ return `${detail}\n\nThis model is not available to Codex on your ChatGPT plan. ` +
961
+ 'Pick another model for this agent (the model menu in the thread, or the agent\'s settings), ' +
962
+ 'or leave the model empty to use the account default.';
963
+ }
956
964
  // Ahead of the network check: a model that needs a newer Codex can
957
965
  // arrive with connection warnings in stderr, and the upgrade is the fix.
958
966
  if (/requires a newer version|upgrade to the latest (app|version)/i.test(detail)) {
@@ -83,6 +83,8 @@ const FAILURE_MESSAGES = {
83
83
  provider_not_configured: "MiMo Code has no usable model provider. Check this agent's base URL and model, then retry.",
84
84
  model_not_found: 'The configured model was not found or this key cannot use it. Pick one from the model list in this agent\'s configuration, then retry.',
85
85
  rate_limited: 'The model service is rate-limiting requests. Wait a moment and retry.',
86
+ quota_exhausted: 'The model service account has run out of balance or credit. Top it up, or give this agent a key with credit, then retry.',
87
+ request_too_large: 'The model service refused the request as too large — the conversation or its attachments exceed what it accepts. Start a new thread or send less, then retry.',
86
88
  network_error: 'MiMo Code could not reach the model service (network or service error). Retry shortly.',
87
89
  provider_server_error: 'The model service returned a server error. Retry shortly.',
88
90
  timeout: 'MiMo Code went quiet for too long and was stopped. If the model service keeps failing, MiMo retries without saying so — check the base URL and model, then retry.',
@@ -82,6 +82,8 @@ const FAILURE_MESSAGES = {
82
82
  provider_not_configured: 'OpenCode has no usable provider configured. Configure a provider and model, then retry.',
83
83
  model_not_found: 'The configured model was not found or is not accessible. Check the model name and your access, then retry.',
84
84
  rate_limited: 'The provider is rate-limiting requests. Wait a moment and retry.',
85
+ quota_exhausted: "The provider account has run out of balance or credit. Top it up, or give this agent a key with credit, then retry.",
86
+ request_too_large: 'The provider refused the request as too large — the conversation or its attachments exceed what it accepts. Start a new thread or send less, then retry.',
85
87
  network_error: 'OpenCode could not reach the provider (network or service error). Retry shortly.',
86
88
  provider_server_error: 'The provider returned a server error. Retry shortly.',
87
89
  timeout: 'OpenCode timed out before producing a reply. Retry; if it persists, check the model and provider configuration.',
@@ -1403,17 +1405,23 @@ class OpenCodeAdapter extends BaseAdapter {
1403
1405
  // as "produced output this version could not parse", which said nothing
1404
1406
  // about reinstalling.
1405
1407
  category = 'unsupported_version';
1406
- } else if (has(/\b(401|403)\b/) || has(/unauthor|invalid api key|invalid_api_key|authentication|auth(entication)? failed|forbidden|invalid token|no api key|missing api key|permission denied/)) {
1408
+ } else if (has(/\b(401|403)\b/) || has(/unauthor|invalid api key|invalid_api_key|invalid or revoked api key|api key (?:has been |was )?revoked|authentication|auth(entication)? failed|forbidden|invalid token|no api key|missing api key|permission denied/)) {
1407
1409
  category = 'auth_failed';
1410
+ } else if (has(/\b402\b|insufficient (?:balance|credits?|funds)|insufficient_quota|out of credits?|payment required|余额不足|欠费|arrearage/)) {
1411
+ // A spent account, not a busy one: waiting does not fix it. Seen in the
1412
+ // field as "Insufficient balance" under "undetermined reason".
1413
+ category = 'quota_exhausted';
1408
1414
  } else if (has(/\b429\b/) || has(/rate.?limit|too many requests|quota|overloaded/)) {
1409
1415
  category = 'rate_limited';
1416
+ } else if (has(/\b413\b|request entity too large|payload too large|failed to buffer the request body|length limit exceeded|context(?:_| )length(?:_| )exceeded|maximum context length/)) {
1417
+ category = 'request_too_large';
1410
1418
  } else if (has(/model.*(not found|does not exist|unknown|invalid|unsupported)|no such model|unknown model|invalid model|model_not_found|\b404\b/)) {
1411
1419
  category = 'model_not_found';
1412
1420
  } else if (has(/no provider|provider not configured|not configured|no model configured|no providers|missing provider/)) {
1413
1421
  category = 'provider_not_configured';
1414
1422
  } else if (has(/econnrefused|enotfound|etimedout|eai_again|network|fetch failed|socket hang|connection (refused|reset|error)|getaddrinfo|\bdns\b/)) {
1415
1423
  category = 'network_error';
1416
- } else if (has(/\b5\d\d\b|server error|internal server|bad gateway|service unavailable|gateway timeout/)) {
1424
+ } else if (has(/\b5\d\d\b|server error|internal server|bad gateway|service unavailable|gateway timeout|server is busy|system is busy|系统繁忙|服务繁忙|đang bận/)) {
1417
1425
  category = 'provider_server_error';
1418
1426
  } else if (has(/timeout|timed out/)) {
1419
1427
  category = 'timeout';
@@ -468,6 +468,14 @@ function buildApiSkillsPrompt({ endpoint, workspaceId, token, agentName, channel
468
468
  `\`${curl} -s -X POST -H "${h}" -H "Content-Type: application/json"` +
469
469
  ` ${baseUrl}/v1/browser/tabs/{tab_id}/press_key` +
470
470
  ` -d '{"key":"Enter","source":"openagents:${agentName}","channel":"${channelName}"}'\`\n\n` +
471
+ '**Upload a file or image** into the page (no file dialog needed). First open the site\'s upload UI ' +
472
+ '(e.g. Medium "+" → Image) so its file input exists, then attach a workspace file by `file_id` ' +
473
+ '(upload it to Files first) or inline bytes with `name` + `data_base64`. Max 5 files / 10 MiB:\n' +
474
+ `\`${curl} -s -X POST -H "${h}" -H "Content-Type: application/json"` +
475
+ ` ${baseUrl}/v1/browser/tabs/{tab_id}/upload` +
476
+ ` -d '{"selector":"input[type=file]","files":[{"file_id":"FILE_ID"}],"source":"openagents:${agentName}","channel":"${channelName}"}'\`\n` +
477
+ 'The site sees a normal file pick and may upload immediately; check the page afterwards. ' +
478
+ 'Use this instead of clipboard paste or image-URL import, which fail in the cloud browser.\n\n' +
471
479
  '**Run JavaScript** in the page (returns the result):\n' +
472
480
  `\`${curl} -s -X POST -H "${h}" -H "Content-Type: application/json"` +
473
481
  ` ${baseUrl}/v1/browser/tabs/{tab_id}/evaluate` +
package/src/mcp-server.js CHANGED
@@ -227,6 +227,21 @@ function buildToolDefs(disabledModules) {
227
227
  required: ['tab_id', 'selector', 'text'],
228
228
  },
229
229
  },
230
+ {
231
+ name: 'workspace_browser_upload',
232
+ description: 'Upload a file or image into a page\'s file input (no file dialog needed). Open the site\'s upload UI first (e.g. Medium "+" → Image) so the input exists. Give a local file path, or a workspace file_id. Max 5 files / 10 MiB. The site may upload immediately; check the page afterwards.',
233
+ inputSchema: {
234
+ type: 'object',
235
+ properties: {
236
+ tab_id: { type: 'string', description: 'Tab ID' },
237
+ path: { type: 'string', description: 'Path of a local file on this machine to upload' },
238
+ file_id: { type: 'string', description: 'ID of a workspace shared file to upload (alternative to path)' },
239
+ selector: { type: 'string', description: 'CSS selector of the file input (default input[type=file])' },
240
+ frame_selector: { type: 'string', description: 'Optional CSS selector of an iframe containing the input' },
241
+ },
242
+ required: ['tab_id'],
243
+ },
244
+ },
230
245
  {
231
246
  name: 'workspace_browser_screenshot',
232
247
  description: 'Take a screenshot of a browser tab. Returns a base64 PNG image.',
@@ -908,6 +923,24 @@ class McpServer {
908
923
  return text(`Typed into ${args.selector}: ${args.text.slice(0, 50)}${args.text.length > 50 ? '...' : ''}`);
909
924
  }
910
925
 
926
+ case 'workspace_browser_upload': {
927
+ let file;
928
+ if (args.path) {
929
+ const fs = require('fs');
930
+ const pathMod = require('path');
931
+ file = { name: pathMod.basename(args.path), data_base64: fs.readFileSync(args.path).toString('base64') };
932
+ } else if (args.file_id) {
933
+ file = { file_id: args.file_id };
934
+ } else {
935
+ return text('Provide either path (local file) or file_id (workspace file).');
936
+ }
937
+ const r = await this.ws.browserUpload(this.workspaceId, this.token, args.tab_id, [file], {
938
+ selector: args.selector || 'input[type=file]', frame_selector: args.frame_selector,
939
+ source: `openagents:${this.agentName}`, channel: this.channelName,
940
+ });
941
+ return text(`Attached ${(r.files || []).join(', ') || 'file'} to ${args.selector || 'input[type=file]'} (${r.status || 'attached'}). Check the page to confirm the site accepted it.`);
942
+ }
943
+
911
944
  case 'workspace_browser_screenshot': {
912
945
  const buf = await this.ws.browserScreenshot(this.workspaceId, this.token, args.tab_id, { source: `openagents:${this.agentName}`, channel: this.channelName });
913
946
  const b64 = Buffer.isBuffer(buf) ? buf.toString('base64') : buf;
@@ -883,6 +883,17 @@ class WorkspaceClient {
883
883
  * Get screenshot via GET /v1/browser/tabs/{tabId}/screenshot.
884
884
  * @returns {Buffer}
885
885
  */
886
+ /**
887
+ * Attach files to a file input via POST /v1/browser/tabs/{tabId}/upload.
888
+ * @param {Array<{file_id?: string, name?: string, mime_type?: string, data_base64?: string}>} files
889
+ */
890
+ async browserUpload(workspaceId, token, tabId, files, { selector = 'input[type=file]', frame_selector, source, channel } = {}) {
891
+ const body = { selector, files, source, channel };
892
+ if (frame_selector) body.frame_selector = frame_selector;
893
+ const data = await this._post(`/v1/browser/tabs/${tabId}/upload`, body, this._wsHeaders(token));
894
+ return data.data || data;
895
+ }
896
+
886
897
  async browserScreenshot(workspaceId, token, tabId, { source, channel } = {}) {
887
898
  const query = new URLSearchParams();
888
899
  if (source) query.set('source', source);