@myagentroam/agent 0.9.64 → 0.9.65

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 (2) hide show
  1. package/dist/cli/main.js +13 -9
  2. package/package.json +1 -1
package/dist/cli/main.js CHANGED
@@ -226,8 +226,7 @@ async function main() {
226
226
  stdout.write(HELP);
227
227
  return;
228
228
  }
229
- const command = arguments_[0];
230
- if (command === 'models') {
229
+ if (arguments_[0] === 'models') {
231
230
  await modelsCommand(home, arguments_, codexAuthFile);
232
231
  return;
233
232
  }
@@ -240,6 +239,7 @@ async function main() {
240
239
  : parseReasoningEffort(reasoningEffortOption, '--reasoning-effort');
241
240
  const access = (takeOption(arguments_, '--access') ?? 'on-request');
242
241
  const format = takeOption(arguments_, '--format') ?? 'text';
242
+ const command = arguments_[0];
243
243
  if (access !== 'on-request' && access !== 'full-access')
244
244
  throw new MarAgentError('MAR_AGENT_CLI_ARGUMENT_INVALID', 'Access must be on-request or full-access.');
245
245
  const selectedModel = catalog.models.find((model) => model.id === modelId && model.enabled);
@@ -249,14 +249,18 @@ async function main() {
249
249
  throw new MarAgentError('MAR_AGENT_CLI_ARGUMENT_INVALID', `Reasoning effort "${reasoningEffort}" is not supported by model "${selectedModel.id}".`);
250
250
  const interactive = command !== 'run';
251
251
  let prompt = command === 'run' ? arguments_.slice(1).join(' ') : '';
252
- const terminal = createInterface({ input: stdin, output: stdout });
252
+ // `run` does not need stdin until an approval or question occurs. Create
253
+ // readline lazily so a closed or pseudo-TTY stream in an external harness
254
+ // cannot fail the execution before its first model request.
255
+ let terminal;
256
+ const requireTerminal = () => (terminal ??= createInterface({ input: stdin, output: stdout }));
253
257
  const host = new LocalAgentHost({
254
258
  homeDirectory: home,
255
259
  workspace,
256
260
  approve: async (call) => {
257
261
  if (!stdin.isTTY)
258
262
  return 'denied';
259
- const answer = await terminal.question(`Approve ${call.name}? [y/N] `);
263
+ const answer = await requireTerminal().question(`Approve ${call.name}? [y/N] `);
260
264
  return /^y(es)?$/i.test(answer.trim()) ? 'approved' : 'denied';
261
265
  },
262
266
  question: async (request) => {
@@ -266,7 +270,7 @@ async function main() {
266
270
  for (const question of request.questions) {
267
271
  const value = question;
268
272
  const id = typeof value.id === 'string' ? value.id : String(Object.keys(answers).length);
269
- answers[id] = await terminal.question(`${typeof value.question === 'string' ? value.question : JSON.stringify(question)} `);
273
+ answers[id] = await requireTerminal().question(`${typeof value.question === 'string' ? value.question : JSON.stringify(question)} `);
270
274
  }
271
275
  return answers;
272
276
  }
@@ -298,7 +302,7 @@ async function main() {
298
302
  const listed = (await agent.listSessions());
299
303
  for (const item of listed.sessions ?? [])
300
304
  stdout.write(`${item.id}\t${item.title}\t${item.lastActivityAt}\n`);
301
- resumeId = (await terminal.question('Session ID: ')).trim();
305
+ resumeId = (await requireTerminal().question('Session ID: ')).trim();
302
306
  if (!resumeId)
303
307
  throw new MarAgentError('MAR_AGENT_CLI_ARGUMENT_INVALID', 'Session id is required.');
304
308
  }
@@ -314,7 +318,7 @@ async function main() {
314
318
  if (activeHandle)
315
319
  activeHandle.cancel();
316
320
  else
317
- terminal.close();
321
+ terminal?.close();
318
322
  process.exitCode = 130;
319
323
  if (interrupts > 1)
320
324
  activeHandle?.cancel();
@@ -323,7 +327,7 @@ async function main() {
323
327
  try {
324
328
  do {
325
329
  if (interactive)
326
- prompt = await terminal.question('> ');
330
+ prompt = await requireTerminal().question('> ');
327
331
  if (!prompt.trim())
328
332
  break;
329
333
  const invocation = parseExecutionInvocation(prompt);
@@ -360,7 +364,7 @@ async function main() {
360
364
  }
361
365
  }
362
366
  finally {
363
- terminal.close();
367
+ terminal?.close();
364
368
  await agent.dispose();
365
369
  }
366
370
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myagentroam/agent",
3
- "version": "0.9.64",
3
+ "version": "0.9.65",
4
4
  "description": "Embeddable MAR coding agent SDK and CLI.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",