@asteroidai/cli 1.9.191 → 1.9.219

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/dist/asteroid.js CHANGED
@@ -374,7 +374,7 @@ var COMMANDS = [
374
374
  command: "catalog get",
375
375
  tool: "catalog_get",
376
376
  title: "Get catalog",
377
- description: "The organization's agent catalog: categories, portals and the templates it is entitled to. `accessLevel` is `granted` (can instantiate) or `viewable` (locked); `catalog_template_add` grants a `viewable` one. `organizationId` defaults to the caller's one organization. Template definitions are omitted; read one with `catalog_template_get`.",
377
+ description: "The organization's agent catalog: categories, portals and every live template. `accessLevel` is `granted` (can instantiate a `runnable` template) or `viewable` (locked). A template the organization has not added is `viewable`; `catalog_template_add` grants it. Portals whose `portalType` is `mock` are stand-in sites with sample data that Asteroid hosts: their templates are `granted` to every organization, need no credentials and touch nothing real. Offer them for a demo or when the user has no access to the real portal yet, and prefer a real portal's template otherwise. `organizationId` defaults to the caller's one organization. Template definitions are omitted; read one with `catalog_template_get`.",
378
378
  method: "GET",
379
379
  path: "/agents/v2/catalog",
380
380
  args: [],
@@ -387,7 +387,7 @@ var COMMANDS = [
387
387
  command: "catalog template add",
388
388
  tool: "catalog_template_add",
389
389
  title: "Add catalog template",
390
- description: "Add a catalog template to an organization at `accessLevel` `granted`, so `catalog_template_instantiate` can clone it. Also adds the skills of the template's portal. Needs a Startup plan or above. Adding one the organization already has is a no-op. `organizationId` defaults to the caller's one organization.",
390
+ description: "Add a catalog template to an organization at `accessLevel` `granted`, so `catalog_template_instantiate` can clone it. Also adds the skills of the template's portal. A template that is not `runnable` (see `catalog_template_get`) returns 400 and uses no grant. Needs a Startup plan or above. Adding one the organization already has is a no-op. `organizationId` defaults to the caller's one organization.",
391
391
  method: "POST",
392
392
  path: "/agents/v2/catalog/templates/{templateId}/add",
393
393
  args: [
@@ -407,7 +407,7 @@ var COMMANDS = [
407
407
  command: "catalog template get",
408
408
  tool: "catalog_template_get",
409
409
  title: "Get catalog template",
410
- description: "One catalog template, with `runnable`, its `inputs`, the portal's credential fields and the organization's `accessLevel`. Set `includeWorkflowDefinition` to also get the template's rules, nodes and transitions as a read-only reference when building or editing a workflow; on an organization-scoped read it needs `accessLevel` `granted`. To get an editable copy, use `catalog_template_instantiate`. `organizationId` defaults to the caller's one organization.",
410
+ description: "One live catalog template, with `runnable`, its `inputs`, the portal's credential fields and the organization's `accessLevel`. A template the organization has not added is `viewable`. Set `includeWorkflowDefinition` to also get the template's rules, nodes and transitions as a read-only reference when building or editing a workflow; on an organization-scoped read it needs `accessLevel` `granted`. To get an editable copy, use `catalog_template_instantiate`. `organizationId` defaults to the caller's one organization.",
411
411
  method: "GET",
412
412
  path: "/agents/v2/catalog/templates/{templateId}",
413
413
  args: [
@@ -435,7 +435,7 @@ var COMMANDS = [
435
435
  command: "catalog template instantiate",
436
436
  tool: "catalog_template_instantiate",
437
437
  title: "Instantiate catalog template",
438
- description: "Create a new workflow in the organization from a catalog template. Needs `accessLevel` `granted`: add the template with `catalog_template_add` first. Pass `credentials` (keyed by the portal's credential field keys) to create a profile, or `agentProfileId` to reuse one, or neither for a bare clone. Returns the workflow ID, its version ID and any profile ID. `organizationId` defaults to the caller's one organization.",
438
+ description: "Create a new workflow in the organization from a catalog template. Needs `accessLevel` `granted`: add the template with `catalog_template_add` first; a template on a `mock` portal is already granted. Pass `credentials` (keyed by the portal's credential field keys) to create a profile, or `agentProfileId` to reuse one, or neither for a bare clone. Returns the workflow ID, its version ID and any profile ID. `organizationId` defaults to the caller's one organization.",
439
439
  method: "POST",
440
440
  path: "/agents/v2/catalog/templates/{templateId}/instantiate",
441
441
  args: [
@@ -2245,8 +2245,8 @@ var COMMANDS = [
2245
2245
  {
2246
2246
  command: "execution sync",
2247
2247
  tool: "execution_sync",
2248
- title: "Wait for an execution to finish",
2249
- description: "Wait up to `timeoutSeconds` (1-25, default 25) for a running execution to finish. Returns the terminal `status` and `executionResult` when it finishes in time. Otherwise returns the current status: call it again to keep waiting. A paused or `awaiting_confirmation` execution returns at once, since it needs a person. Use it after `workflow_execute_post`, or after `workflow_execute_sync_post` timed out, instead of polling `execution_get`.",
2248
+ title: "Wait for an execution's status to change",
2249
+ description: "Wait up to `timeoutSeconds` (1-25, default 25) for an execution's status to change. Returns as soon as the status differs from the one it had when the call began. A `paused`, `paused_by_agent` or `awaiting_confirmation` execution returns at once, since it needs a person. `returnReason` says why it returned: `ended` (with `executionResult` when the run recorded one), `needs_person`, `status_change` or `timed_out`. After `status_change` or `timed_out`, call it again to keep following the run. On `awaiting_confirmation`, `awaitingConfirmation.nodeName` names the node the run holds at: get the user's go-ahead, then approve with `execution_resume`. Use it after `workflow_execute_post`, or after `workflow_execute_sync_post` timed out, instead of polling `execution_get`.",
2250
2250
  method: "GET",
2251
2251
  path: "/agents/v2/executions/{executionId}/sync",
2252
2252
  args: [
@@ -2263,7 +2263,7 @@ var COMMANDS = [
2263
2263
  flag: "timeout-seconds",
2264
2264
  type: "integer",
2265
2265
  required: false,
2266
- description: "Seconds to wait for the execution to finish before returning 202. Defaults to 25."
2266
+ description: "Seconds to wait for a change before returning 202. Defaults to 25."
2267
2267
  }
2268
2268
  ],
2269
2269
  binary: false,
@@ -6563,71 +6563,53 @@ function statusOf(error) {
6563
6563
 
6564
6564
  // src/sync/execution-wait.ts
6565
6565
  var WAIT_TIMEOUT_SECONDS = 600;
6566
- var WAIT_INTERVAL_SECONDS = 15;
6567
6566
  var MAX_WAIT_TIMEOUT_SECONDS = 3600;
6568
- var MAX_WAIT_INTERVAL_SECONDS = 120;
6569
- var TERMINAL = /* @__PURE__ */ new Set(["completed", "cancelled", "failed"]);
6570
- function isTerminalExecutionStatus(status) {
6571
- return TERMINAL.has(status);
6572
- }
6573
6567
  var SYNC_TIMEOUT_SECONDS = 25;
6574
- function pause(ms) {
6575
- return new Promise((resolve2) => setTimeout(resolve2, ms));
6576
- }
6577
- async function readStatus(sync, executionId2, timeoutMs) {
6578
- if (timeoutMs <= 0)
6579
- return await sync.remote.json(
6580
- get(`/agents/v2/executions/${executionId2}`)
6581
- );
6568
+ async function syncExecution(sync, executionId2, timeoutMs) {
6582
6569
  const timeoutSeconds = Math.min(
6583
6570
  SYNC_TIMEOUT_SECONDS,
6584
6571
  Math.max(1, Math.ceil(timeoutMs / 1e3))
6585
6572
  );
6586
- const response = await sync.remote.json(
6573
+ return await sync.remote.json(
6587
6574
  get(`/agents/v2/executions/${executionId2}/sync`, {
6588
6575
  timeoutSeconds: String(timeoutSeconds)
6589
6576
  })
6590
6577
  );
6591
- return {
6592
- id: response.executionId,
6593
- status: response.status,
6594
- executionResult: response.executionResult
6595
- };
6596
6578
  }
6597
6579
  async function waitForExecution(sync, options) {
6598
6580
  const timeoutMs = (options.timeoutSeconds ?? WAIT_TIMEOUT_SECONDS) * 1e3;
6599
- const intervalMs = (options.intervalSeconds ?? WAIT_INTERVAL_SECONDS) * 1e3;
6600
6581
  const now = options.now ?? Date.now;
6601
- const sleep = options.sleep ?? pause;
6602
6582
  const started = now();
6603
- let polls = 0;
6604
- for (; ; ) {
6605
- const called = now();
6606
- const execution = await readStatus(
6583
+ for (let polls = 1; ; polls++) {
6584
+ const execution = await syncExecution(
6607
6585
  sync,
6608
6586
  options.executionId,
6609
- timeoutMs - (called - started)
6587
+ timeoutMs - (now() - started)
6610
6588
  );
6611
- polls++;
6612
6589
  const elapsed = now() - started;
6613
- const waitedSeconds = Math.round(elapsed / 1e3);
6614
- if (isTerminalExecutionStatus(execution.status))
6615
- return { execution, terminal: true, waitedSeconds, polls };
6616
- const remaining = timeoutMs - elapsed;
6617
- if (remaining <= 0)
6618
- return { execution, terminal: false, waitedSeconds, polls };
6619
- const early = intervalMs - (now() - called);
6620
- if (early > 0) await sleep(Math.min(early, remaining));
6590
+ if (execution.returnReason !== "timed_out" || elapsed >= timeoutMs)
6591
+ return { execution, waitedSeconds: Math.round(elapsed / 1e3), polls };
6621
6592
  }
6622
6593
  }
6623
6594
  function formatExecutionWait(result) {
6624
6595
  const { execution } = result;
6625
- if (!result.terminal) {
6626
- return `Execution ${execution.id} still ${execution.status} after ${result.waitedSeconds}s. Wait again, or read what it has so far with \`asteroid execution pull ${execution.id}\`.`;
6596
+ const id = execution.executionId;
6597
+ const hold = execution.awaitingConfirmation;
6598
+ if (hold)
6599
+ return `Execution ${id} ${execution.status} at node "${hold.nodeName}". Approve it with \`asteroid execution resume ${id}\` once the user agrees.`;
6600
+ switch (execution.returnReason) {
6601
+ case "ended": {
6602
+ const line2 = `Execution ${id} ${execution.status}.`;
6603
+ const outcome = execution.executionResult;
6604
+ return outcome ? `${line2} Result: ${outcome.outcome}: ${outcome.reasoning}` : line2;
6605
+ }
6606
+ case "needs_person":
6607
+ return `Execution ${id} ${execution.status} and needs a person. Read why with \`asteroid execution activities ${id} --order desc\`.`;
6608
+ case "status_change":
6609
+ return `Execution ${id} is now ${execution.status}. Wait again to follow it.`;
6610
+ default:
6611
+ return `Execution ${id} still ${execution.status} after ${result.waitedSeconds}s. Wait again, or read what it has so far with \`asteroid execution pull ${id}\`.`;
6627
6612
  }
6628
- const line2 = `Execution ${execution.id} ${execution.status}.`;
6629
- const outcome = execution.executionResult;
6630
- return outcome ? `${line2} Result: ${outcome.outcome}: ${outcome.reasoning}` : line2;
6631
6613
  }
6632
6614
 
6633
6615
  // src/sync/commands.ts
@@ -6686,8 +6668,8 @@ var SYNC_COMMANDS = [
6686
6668
  ...local,
6687
6669
  command: "execution wait",
6688
6670
  tool: "execution_wait",
6689
- title: "Wait for an execution to end",
6690
- description: "Poll an execution until it is completed, failed or cancelled, then print its status and, when the run produced one, its result. When the timeout passes first, print the status it still has, so you can wait again.",
6671
+ title: "Wait for an execution's status to change",
6672
+ description: "Call `execution sync` until it reports a reason to stop, then print the status. It returns as soon as the run's status changes, at once when the run has ended or needs a person, and otherwise at the timeout, when it prints the status the run still has so you can wait again. On `awaiting_confirmation` it names the node the run holds at when the API reports one, and otherwise points to `asteroid execution activities`. Approve it with `asteroid execution resume <execution-id>` once the user agrees.",
6691
6673
  readOnly: true,
6692
6674
  args: [executionId],
6693
6675
  query: [
@@ -6695,11 +6677,6 @@ var SYNC_COMMANDS = [
6695
6677
  "timeout",
6696
6678
  "integer",
6697
6679
  `Give up after this many seconds, ${WAIT_TIMEOUT_SECONDS} unless set, ${MAX_WAIT_TIMEOUT_SECONDS} at most.`
6698
- ),
6699
- option(
6700
- "interval",
6701
- "integer",
6702
- `Poll every this many seconds, ${WAIT_INTERVAL_SECONDS} unless set, ${MAX_WAIT_INTERVAL_SECONDS} at most.`
6703
6680
  )
6704
6681
  ]
6705
6682
  },
@@ -7226,6 +7203,8 @@ function defineCommands(root, options, dotted2 = /* @__PURE__ */ new Map(), onIn
7226
7203
  if (notes.length > 0) leaf.addHelpText("after", `
7227
7204
  ${notes.join("\n")}`);
7228
7205
  leafOptions(leaf, command);
7206
+ for (const [flags, text3] of options.extraOptions?.(command) ?? [])
7207
+ leaf.option(flags, text3);
7229
7208
  leaf.action((...args) => {
7230
7209
  const cmd = args.at(-1);
7231
7210
  let positionals = cmd.args;
@@ -7756,7 +7735,7 @@ var ApiError = class extends Error {
7756
7735
  status;
7757
7736
  body;
7758
7737
  };
7759
- var VERSION = "1.9.191";
7738
+ var VERSION = "1.9.219";
7760
7739
  function problem(status, body, fallback) {
7761
7740
  if (body && typeof body === "object") {
7762
7741
  const record2 = body;
@@ -9712,8 +9691,7 @@ function bounded(parsed, name, min, max) {
9712
9691
  function executionWaitOptions(parsed) {
9713
9692
  return {
9714
9693
  executionId: parsed.positionals[0],
9715
- timeoutSeconds: bounded(parsed, "timeout", 0, MAX_WAIT_TIMEOUT_SECONDS),
9716
- intervalSeconds: bounded(parsed, "interval", 1, MAX_WAIT_INTERVAL_SECONDS)
9694
+ timeoutSeconds: bounded(parsed, "timeout", 0, MAX_WAIT_TIMEOUT_SECONDS)
9717
9695
  };
9718
9696
  }
9719
9697
  function given(value2, name) {
package/dist/core.js CHANGED
@@ -395,7 +395,7 @@ var COMMANDS = [
395
395
  command: "catalog get",
396
396
  tool: "catalog_get",
397
397
  title: "Get catalog",
398
- description: "The organization's agent catalog: categories, portals and the templates it is entitled to. `accessLevel` is `granted` (can instantiate) or `viewable` (locked); `catalog_template_add` grants a `viewable` one. `organizationId` defaults to the caller's one organization. Template definitions are omitted; read one with `catalog_template_get`.",
398
+ description: "The organization's agent catalog: categories, portals and every live template. `accessLevel` is `granted` (can instantiate a `runnable` template) or `viewable` (locked). A template the organization has not added is `viewable`; `catalog_template_add` grants it. Portals whose `portalType` is `mock` are stand-in sites with sample data that Asteroid hosts: their templates are `granted` to every organization, need no credentials and touch nothing real. Offer them for a demo or when the user has no access to the real portal yet, and prefer a real portal's template otherwise. `organizationId` defaults to the caller's one organization. Template definitions are omitted; read one with `catalog_template_get`.",
399
399
  method: "GET",
400
400
  path: "/agents/v2/catalog",
401
401
  args: [],
@@ -408,7 +408,7 @@ var COMMANDS = [
408
408
  command: "catalog template add",
409
409
  tool: "catalog_template_add",
410
410
  title: "Add catalog template",
411
- description: "Add a catalog template to an organization at `accessLevel` `granted`, so `catalog_template_instantiate` can clone it. Also adds the skills of the template's portal. Needs a Startup plan or above. Adding one the organization already has is a no-op. `organizationId` defaults to the caller's one organization.",
411
+ description: "Add a catalog template to an organization at `accessLevel` `granted`, so `catalog_template_instantiate` can clone it. Also adds the skills of the template's portal. A template that is not `runnable` (see `catalog_template_get`) returns 400 and uses no grant. Needs a Startup plan or above. Adding one the organization already has is a no-op. `organizationId` defaults to the caller's one organization.",
412
412
  method: "POST",
413
413
  path: "/agents/v2/catalog/templates/{templateId}/add",
414
414
  args: [
@@ -428,7 +428,7 @@ var COMMANDS = [
428
428
  command: "catalog template get",
429
429
  tool: "catalog_template_get",
430
430
  title: "Get catalog template",
431
- description: "One catalog template, with `runnable`, its `inputs`, the portal's credential fields and the organization's `accessLevel`. Set `includeWorkflowDefinition` to also get the template's rules, nodes and transitions as a read-only reference when building or editing a workflow; on an organization-scoped read it needs `accessLevel` `granted`. To get an editable copy, use `catalog_template_instantiate`. `organizationId` defaults to the caller's one organization.",
431
+ description: "One live catalog template, with `runnable`, its `inputs`, the portal's credential fields and the organization's `accessLevel`. A template the organization has not added is `viewable`. Set `includeWorkflowDefinition` to also get the template's rules, nodes and transitions as a read-only reference when building or editing a workflow; on an organization-scoped read it needs `accessLevel` `granted`. To get an editable copy, use `catalog_template_instantiate`. `organizationId` defaults to the caller's one organization.",
432
432
  method: "GET",
433
433
  path: "/agents/v2/catalog/templates/{templateId}",
434
434
  args: [
@@ -456,7 +456,7 @@ var COMMANDS = [
456
456
  command: "catalog template instantiate",
457
457
  tool: "catalog_template_instantiate",
458
458
  title: "Instantiate catalog template",
459
- description: "Create a new workflow in the organization from a catalog template. Needs `accessLevel` `granted`: add the template with `catalog_template_add` first. Pass `credentials` (keyed by the portal's credential field keys) to create a profile, or `agentProfileId` to reuse one, or neither for a bare clone. Returns the workflow ID, its version ID and any profile ID. `organizationId` defaults to the caller's one organization.",
459
+ description: "Create a new workflow in the organization from a catalog template. Needs `accessLevel` `granted`: add the template with `catalog_template_add` first; a template on a `mock` portal is already granted. Pass `credentials` (keyed by the portal's credential field keys) to create a profile, or `agentProfileId` to reuse one, or neither for a bare clone. Returns the workflow ID, its version ID and any profile ID. `organizationId` defaults to the caller's one organization.",
460
460
  method: "POST",
461
461
  path: "/agents/v2/catalog/templates/{templateId}/instantiate",
462
462
  args: [
@@ -2266,8 +2266,8 @@ var COMMANDS = [
2266
2266
  {
2267
2267
  command: "execution sync",
2268
2268
  tool: "execution_sync",
2269
- title: "Wait for an execution to finish",
2270
- description: "Wait up to `timeoutSeconds` (1-25, default 25) for a running execution to finish. Returns the terminal `status` and `executionResult` when it finishes in time. Otherwise returns the current status: call it again to keep waiting. A paused or `awaiting_confirmation` execution returns at once, since it needs a person. Use it after `workflow_execute_post`, or after `workflow_execute_sync_post` timed out, instead of polling `execution_get`.",
2269
+ title: "Wait for an execution's status to change",
2270
+ description: "Wait up to `timeoutSeconds` (1-25, default 25) for an execution's status to change. Returns as soon as the status differs from the one it had when the call began. A `paused`, `paused_by_agent` or `awaiting_confirmation` execution returns at once, since it needs a person. `returnReason` says why it returned: `ended` (with `executionResult` when the run recorded one), `needs_person`, `status_change` or `timed_out`. After `status_change` or `timed_out`, call it again to keep following the run. On `awaiting_confirmation`, `awaitingConfirmation.nodeName` names the node the run holds at: get the user's go-ahead, then approve with `execution_resume`. Use it after `workflow_execute_post`, or after `workflow_execute_sync_post` timed out, instead of polling `execution_get`.",
2271
2271
  method: "GET",
2272
2272
  path: "/agents/v2/executions/{executionId}/sync",
2273
2273
  args: [
@@ -2284,7 +2284,7 @@ var COMMANDS = [
2284
2284
  flag: "timeout-seconds",
2285
2285
  type: "integer",
2286
2286
  required: false,
2287
- description: "Seconds to wait for the execution to finish before returning 202. Defaults to 25."
2287
+ description: "Seconds to wait for a change before returning 202. Defaults to 25."
2288
2288
  }
2289
2289
  ],
2290
2290
  binary: false,
@@ -6968,6 +6968,8 @@ function defineCommands(root, options, dotted2 = /* @__PURE__ */ new Map(), onIn
6968
6968
  if (notes.length > 0) leaf.addHelpText("after", `
6969
6969
  ${notes.join("\n")}`);
6970
6970
  leafOptions(leaf, command);
6971
+ for (const [flags, text2] of options.extraOptions?.(command) ?? [])
6972
+ leaf.option(flags, text2);
6971
6973
  leaf.action((...args) => {
6972
6974
  const cmd = args.at(-1);
6973
6975
  let positionals = cmd.args;
@@ -7286,71 +7288,53 @@ function statusOf(error) {
7286
7288
 
7287
7289
  // src/sync/execution-wait.ts
7288
7290
  var WAIT_TIMEOUT_SECONDS = 600;
7289
- var WAIT_INTERVAL_SECONDS = 15;
7290
7291
  var MAX_WAIT_TIMEOUT_SECONDS = 3600;
7291
- var MAX_WAIT_INTERVAL_SECONDS = 120;
7292
- var TERMINAL = /* @__PURE__ */ new Set(["completed", "cancelled", "failed"]);
7293
- function isTerminalExecutionStatus(status) {
7294
- return TERMINAL.has(status);
7295
- }
7296
7292
  var SYNC_TIMEOUT_SECONDS = 25;
7297
- function pause(ms) {
7298
- return new Promise((resolve2) => setTimeout(resolve2, ms));
7299
- }
7300
- async function readStatus(sync, executionId2, timeoutMs) {
7301
- if (timeoutMs <= 0)
7302
- return await sync.remote.json(
7303
- get(`/agents/v2/executions/${executionId2}`)
7304
- );
7293
+ async function syncExecution(sync, executionId2, timeoutMs) {
7305
7294
  const timeoutSeconds = Math.min(
7306
7295
  SYNC_TIMEOUT_SECONDS,
7307
7296
  Math.max(1, Math.ceil(timeoutMs / 1e3))
7308
7297
  );
7309
- const response = await sync.remote.json(
7298
+ return await sync.remote.json(
7310
7299
  get(`/agents/v2/executions/${executionId2}/sync`, {
7311
7300
  timeoutSeconds: String(timeoutSeconds)
7312
7301
  })
7313
7302
  );
7314
- return {
7315
- id: response.executionId,
7316
- status: response.status,
7317
- executionResult: response.executionResult
7318
- };
7319
7303
  }
7320
7304
  async function waitForExecution(sync, options) {
7321
7305
  const timeoutMs = (options.timeoutSeconds ?? WAIT_TIMEOUT_SECONDS) * 1e3;
7322
- const intervalMs = (options.intervalSeconds ?? WAIT_INTERVAL_SECONDS) * 1e3;
7323
7306
  const now = options.now ?? Date.now;
7324
- const sleep = options.sleep ?? pause;
7325
7307
  const started = now();
7326
- let polls = 0;
7327
- for (; ; ) {
7328
- const called = now();
7329
- const execution = await readStatus(
7308
+ for (let polls = 1; ; polls++) {
7309
+ const execution = await syncExecution(
7330
7310
  sync,
7331
7311
  options.executionId,
7332
- timeoutMs - (called - started)
7312
+ timeoutMs - (now() - started)
7333
7313
  );
7334
- polls++;
7335
7314
  const elapsed = now() - started;
7336
- const waitedSeconds = Math.round(elapsed / 1e3);
7337
- if (isTerminalExecutionStatus(execution.status))
7338
- return { execution, terminal: true, waitedSeconds, polls };
7339
- const remaining = timeoutMs - elapsed;
7340
- if (remaining <= 0)
7341
- return { execution, terminal: false, waitedSeconds, polls };
7342
- const early = intervalMs - (now() - called);
7343
- if (early > 0) await sleep(Math.min(early, remaining));
7315
+ if (execution.returnReason !== "timed_out" || elapsed >= timeoutMs)
7316
+ return { execution, waitedSeconds: Math.round(elapsed / 1e3), polls };
7344
7317
  }
7345
7318
  }
7346
7319
  function formatExecutionWait(result) {
7347
7320
  const { execution } = result;
7348
- if (!result.terminal) {
7349
- return `Execution ${execution.id} still ${execution.status} after ${result.waitedSeconds}s. Wait again, or read what it has so far with \`asteroid execution pull ${execution.id}\`.`;
7321
+ const id = execution.executionId;
7322
+ const hold = execution.awaitingConfirmation;
7323
+ if (hold)
7324
+ return `Execution ${id} ${execution.status} at node "${hold.nodeName}". Approve it with \`asteroid execution resume ${id}\` once the user agrees.`;
7325
+ switch (execution.returnReason) {
7326
+ case "ended": {
7327
+ const line2 = `Execution ${id} ${execution.status}.`;
7328
+ const outcome = execution.executionResult;
7329
+ return outcome ? `${line2} Result: ${outcome.outcome}: ${outcome.reasoning}` : line2;
7330
+ }
7331
+ case "needs_person":
7332
+ return `Execution ${id} ${execution.status} and needs a person. Read why with \`asteroid execution activities ${id} --order desc\`.`;
7333
+ case "status_change":
7334
+ return `Execution ${id} is now ${execution.status}. Wait again to follow it.`;
7335
+ default:
7336
+ return `Execution ${id} still ${execution.status} after ${result.waitedSeconds}s. Wait again, or read what it has so far with \`asteroid execution pull ${id}\`.`;
7350
7337
  }
7351
- const line2 = `Execution ${execution.id} ${execution.status}.`;
7352
- const outcome = execution.executionResult;
7353
- return outcome ? `${line2} Result: ${outcome.outcome}: ${outcome.reasoning}` : line2;
7354
7338
  }
7355
7339
 
7356
7340
  // src/sync/commands.ts
@@ -7409,8 +7393,8 @@ var SYNC_COMMANDS = [
7409
7393
  ...local,
7410
7394
  command: "execution wait",
7411
7395
  tool: "execution_wait",
7412
- title: "Wait for an execution to end",
7413
- description: "Poll an execution until it is completed, failed or cancelled, then print its status and, when the run produced one, its result. When the timeout passes first, print the status it still has, so you can wait again.",
7396
+ title: "Wait for an execution's status to change",
7397
+ description: "Call `execution sync` until it reports a reason to stop, then print the status. It returns as soon as the run's status changes, at once when the run has ended or needs a person, and otherwise at the timeout, when it prints the status the run still has so you can wait again. On `awaiting_confirmation` it names the node the run holds at when the API reports one, and otherwise points to `asteroid execution activities`. Approve it with `asteroid execution resume <execution-id>` once the user agrees.",
7414
7398
  readOnly: true,
7415
7399
  args: [executionId],
7416
7400
  query: [
@@ -7418,11 +7402,6 @@ var SYNC_COMMANDS = [
7418
7402
  "timeout",
7419
7403
  "integer",
7420
7404
  `Give up after this many seconds, ${WAIT_TIMEOUT_SECONDS} unless set, ${MAX_WAIT_TIMEOUT_SECONDS} at most.`
7421
- ),
7422
- option(
7423
- "interval",
7424
- "integer",
7425
- `Poll every this many seconds, ${WAIT_INTERVAL_SECONDS} unless set, ${MAX_WAIT_INTERVAL_SECONDS} at most.`
7426
7405
  )
7427
7406
  ]
7428
7407
  },
@@ -8355,8 +8334,7 @@ function bounded(parsed, name, min, max) {
8355
8334
  function executionWaitOptions(parsed) {
8356
8335
  return {
8357
8336
  executionId: parsed.positionals[0],
8358
- timeoutSeconds: bounded(parsed, "timeout", 0, MAX_WAIT_TIMEOUT_SECONDS),
8359
- intervalSeconds: bounded(parsed, "interval", 1, MAX_WAIT_INTERVAL_SECONDS)
8337
+ timeoutSeconds: bounded(parsed, "timeout", 0, MAX_WAIT_TIMEOUT_SECONDS)
8360
8338
  };
8361
8339
  }
8362
8340
  function given(value2, name) {
@@ -8486,7 +8464,6 @@ export {
8486
8464
  formatWorkflowPush,
8487
8465
  headFilesRequest,
8488
8466
  insightFileId,
8489
- isTerminalExecutionStatus,
8490
8467
  leadingWords,
8491
8468
  loadManifest,
8492
8469
  matchCommand,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asteroidai/cli",
3
- "version": "1.9.191",
3
+ "version": "1.9.219",
4
4
  "description": "The asteroid command-line interface for the Asteroid platform.",
5
5
  "type": "module",
6
6
  "license": "MIT",