@skrr-ai/cli 0.1.142 → 0.1.144

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 (156) hide show
  1. package/README.md +8 -0
  2. package/dist/base-command.d.ts +4 -2
  3. package/dist/base-command.js +46 -13
  4. package/dist/commands/agenda/trigger/create.js +4 -2
  5. package/dist/commands/agenda/trigger/list.js +7 -7
  6. package/dist/commands/agent/message/approve.d.ts +17 -0
  7. package/dist/commands/agent/message/approve.js +72 -0
  8. package/dist/commands/agent/message/decline.d.ts +17 -0
  9. package/dist/commands/agent/message/decline.js +72 -0
  10. package/dist/commands/agent/message/pending.d.ts +18 -0
  11. package/dist/commands/agent/message/pending.js +79 -0
  12. package/dist/commands/agents/always-on/disable.js +9 -1
  13. package/dist/commands/agents/always-on/enable.js +9 -1
  14. package/dist/commands/agents/always-on/status.js +14 -1
  15. package/dist/commands/agents/create.js +10 -1
  16. package/dist/commands/agents/delete.d.ts +51 -0
  17. package/dist/commands/agents/delete.js +163 -2
  18. package/dist/commands/agents/intuitions/list.js +1 -1
  19. package/dist/commands/agents/plan-day.d.ts +39 -7
  20. package/dist/commands/agents/plan-day.js +254 -65
  21. package/dist/commands/agents/proactive-audit.d.ts +22 -0
  22. package/dist/commands/agents/proactive-audit.js +86 -0
  23. package/dist/commands/agents/schedule-overview.d.ts +7 -0
  24. package/dist/commands/agents/schedule-overview.js +43 -5
  25. package/dist/commands/agents/schedule-trace.js +30 -19
  26. package/dist/commands/agents/spawn.d.ts +51 -0
  27. package/dist/commands/agents/spawn.js +212 -9
  28. package/dist/commands/agents/todos/cancel.js +3 -0
  29. package/dist/commands/agents/todos/edit.js +1 -1
  30. package/dist/commands/agents/todos/list.d.ts +5 -0
  31. package/dist/commands/agents/todos/list.js +19 -5
  32. package/dist/commands/agents/triggers/create.js +1 -1
  33. package/dist/commands/agents/triggers/policy.js +7 -0
  34. package/dist/commands/agents/triggers/update.js +1 -1
  35. package/dist/commands/commitments/create.js +13 -3
  36. package/dist/commands/commitments/preflight.js +31 -5
  37. package/dist/commands/daemon/index.js +1 -0
  38. package/dist/commands/daemon/logs.d.ts +8 -1
  39. package/dist/commands/daemon/logs.js +32 -22
  40. package/dist/commands/daemon/profile.d.ts +15 -0
  41. package/dist/commands/daemon/profile.js +51 -0
  42. package/dist/commands/goals/briefing/status.js +1 -1
  43. package/dist/commands/initiatives/worker/deactivate.d.ts +23 -0
  44. package/dist/commands/initiatives/worker/deactivate.js +78 -0
  45. package/dist/commands/login.js +8 -2
  46. package/dist/commands/logout.d.ts +20 -0
  47. package/dist/commands/logout.js +110 -5
  48. package/dist/commands/machines/profiles/disconnect.d.ts +23 -0
  49. package/dist/commands/machines/profiles/disconnect.js +102 -0
  50. package/dist/commands/machines/profiles/index.d.ts +15 -0
  51. package/dist/commands/machines/profiles/index.js +33 -0
  52. package/dist/commands/machines/profiles/label.d.ts +24 -0
  53. package/dist/commands/machines/profiles/label.js +85 -0
  54. package/dist/commands/machines/profiles/list.d.ts +16 -0
  55. package/dist/commands/machines/profiles/list.js +87 -0
  56. package/dist/commands/memory/maintain.js +16 -2
  57. package/dist/commands/profiles/list.js +17 -2
  58. package/dist/commands/spaces/delete.js +6 -1
  59. package/dist/commands/spaces/workflows/archive.js +6 -1
  60. package/dist/commands/spaces/workflows/publish.js +3 -1
  61. package/dist/commands/spaces/workflows/run.d.ts +1 -0
  62. package/dist/commands/spaces/workflows/run.js +17 -1
  63. package/dist/commands/spaces/workflows/triggers/create.js +3 -1
  64. package/dist/commands/tasks/workflow-context.js +3 -1
  65. package/dist/commands/triggers/authorization.js +1 -1
  66. package/dist/commands/triggers/capabilities.js +17 -1
  67. package/dist/commands/triggers/create.d.ts +2 -0
  68. package/dist/commands/triggers/create.js +23 -7
  69. package/dist/commands/triggers/fire-detail.js +12 -3
  70. package/dist/commands/triggers/list.d.ts +1 -0
  71. package/dist/commands/triggers/list.js +13 -1
  72. package/dist/commands/triggers/preflight.js +18 -0
  73. package/dist/commands/triggers/prune.js +9 -5
  74. package/dist/commands/triggers/update.js +13 -4
  75. package/dist/generated/agent-guides.json +35 -35
  76. package/dist/lib/agent-guides.js +1 -1
  77. package/dist/lib/agent-proactive-baseline.d.ts +6 -0
  78. package/dist/lib/agent-proactive-baseline.js +32 -3
  79. package/dist/lib/always-on-command-result.d.ts +18 -0
  80. package/dist/lib/always-on-command-result.js +52 -0
  81. package/dist/lib/always-on-runtime.d.ts +31 -0
  82. package/dist/lib/always-on-runtime.js +39 -0
  83. package/dist/lib/auth-diagnostics.d.ts +10 -1
  84. package/dist/lib/auth-diagnostics.js +16 -8
  85. package/dist/lib/commitments.d.ts +16 -9
  86. package/dist/lib/commitments.js +65 -4
  87. package/dist/lib/compasses.js +5 -0
  88. package/dist/lib/daemon-binding.js +6 -3
  89. package/dist/lib/daemon-command-hint.d.ts +10 -5
  90. package/dist/lib/daemon-command-hint.js +11 -6
  91. package/dist/lib/daemon-setup.js +9 -3
  92. package/dist/lib/daemonBroker.d.ts +7 -0
  93. package/dist/lib/daemonBroker.js +5 -0
  94. package/dist/lib/daemonHandoff.d.ts +2 -0
  95. package/dist/lib/daemonHandoff.js +16 -3
  96. package/dist/lib/daemonIslandProfile.d.ts +19 -0
  97. package/dist/lib/daemonIslandProfile.js +41 -0
  98. package/dist/lib/drain-stdio.d.ts +22 -0
  99. package/dist/lib/drain-stdio.js +46 -0
  100. package/dist/lib/format.d.ts +32 -0
  101. package/dist/lib/format.js +105 -1
  102. package/dist/lib/initiatives-worker.d.ts +25 -0
  103. package/dist/lib/initiatives-worker.js +13 -0
  104. package/dist/lib/keychain.d.ts +22 -1
  105. package/dist/lib/keychain.js +40 -1
  106. package/dist/lib/local-daemon-readiness.js +4 -6
  107. package/dist/lib/local-skills.js +4 -1
  108. package/dist/lib/login.d.ts +7 -0
  109. package/dist/lib/login.js +5 -0
  110. package/dist/lib/machines.d.ts +68 -0
  111. package/dist/lib/machines.js +67 -0
  112. package/dist/lib/proactive-audit.d.ts +52 -0
  113. package/dist/lib/proactive-audit.js +67 -0
  114. package/dist/lib/proactiveApi.d.ts +23 -0
  115. package/dist/lib/refresh.d.ts +20 -6
  116. package/dist/lib/refresh.js +27 -9
  117. package/dist/lib/roles.d.ts +1 -1
  118. package/dist/lib/runtime-start-verification.js +3 -6
  119. package/dist/lib/schedule.d.ts +189 -9
  120. package/dist/lib/schedule.js +283 -22
  121. package/dist/lib/triggers.d.ts +134 -3
  122. package/dist/lib/triggers.js +370 -17
  123. package/dist/lib/workflow-node-control.js +8 -0
  124. package/dist/lib/workflow-run-view.js +9 -0
  125. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/configRoot.d.ts +12 -0
  126. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/configRoot.js +10 -2
  127. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/deviceIdentityBridge.d.ts +8 -0
  128. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/deviceIdentityBridge.js +22 -0
  129. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/executorStopReceiptV2.d.ts +133 -0
  130. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/executorStopReceiptV2.js +180 -0
  131. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.d.ts +5 -3
  132. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.js +50 -0
  133. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profilePorts.d.ts +137 -0
  134. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profilePorts.js +328 -0
  135. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profileSelection.d.ts +63 -0
  136. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profileSelection.js +174 -0
  137. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/refresh.d.ts +22 -0
  138. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/refresh.js +15 -4
  139. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/configRoot.d.ts +12 -0
  140. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/configRoot.js +14 -0
  141. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/deviceIdentityBridge.d.ts +8 -0
  142. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/deviceIdentityBridge.js +27 -0
  143. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/executorStopReceiptV2.d.ts +133 -0
  144. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/executorStopReceiptV2.js +183 -0
  145. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.d.ts +5 -3
  146. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.js +11 -3
  147. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profilePorts.d.ts +137 -0
  148. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profilePorts.js +333 -0
  149. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profileSelection.d.ts +63 -0
  150. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profileSelection.js +212 -0
  151. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/refresh.d.ts +22 -0
  152. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/refresh.js +22 -4
  153. package/dist/node_modules/@skrr-ai/auth-core/package.json +11 -1
  154. package/dist/node_modules/@skrr-ai/data-provider/index.js +7446 -7378
  155. package/oclif.manifest.json +844 -47
  156. package/package.json +1 -1
package/README.md CHANGED
@@ -679,6 +679,14 @@ sky agents plan-day <agent-id> --regenerate "prioritize the Q2 launch" \
679
679
  --hours-start 09:00 --hours-end 17:00 # a fresh plan with a working-hours window
680
680
  ```
681
681
 
682
+ Generating a plan can take minutes, and the request that started it can end (a
683
+ gateway timeout) while the server keeps going. The server records each request
684
+ per agent-day, so `plan-day` and `schedule-trace` report what it knows: that a
685
+ plan is being generated (and since when), that the last attempt failed (and
686
+ why), or that a request went quiet and may have been interrupted. While a plan
687
+ is being generated, `--approve`, `--dismiss` and `--regenerate` are refused and
688
+ a bare `plan-day` waits for it instead of starting a second one.
689
+
682
690
  ### `sky agents schedule-overview <id>` — full-visibility view
683
691
 
684
692
  One call for everything an agent needs when it wakes to think: its
@@ -587,8 +587,10 @@ export declare function describeGitHubUnavailable(): string;
587
587
  *
588
588
  * `GET /api/tasks` answers 503 with this code when its one aggregate is cut off at `maxTimeMS`,
589
589
  * which an unscoped list over every accessible Space reaches because no index serves its sort
590
- * across the access filter. Lead with the server's `cause`/`remedy`, falling back to the CLI's
591
- * own sentence: the 5xx redaction boundary generalizes a bare message in production.
590
+ * across the access filter. A list the caller already narrowed can reach it too, and then the
591
+ * server says the delay is its own and sets `retryable: true` (OSK-22297). Lead with the
592
+ * server's `cause`/`remedy`, falling back to the CLI's own sentence for the case `retryable`
593
+ * names: the 5xx redaction boundary generalizes a bare message in production.
592
594
  *
593
595
  * Exported for tests.
594
596
  */
@@ -72,6 +72,7 @@ const refresh_1 = require("./lib/refresh");
72
72
  const auth_storage_1 = require("./lib/auth-storage");
73
73
  const web_url_1 = require("./lib/web-url");
74
74
  const edge_error_page_1 = require("./lib/edge-error-page");
75
+ const drain_stdio_1 = require("./lib/drain-stdio");
75
76
  const step_up_1 = require("./lib/step-up");
76
77
  const delegated_cli_1 = require("./lib/delegated-cli");
77
78
  const dedicated_guest_1 = require("./lib/dedicated-guest");
@@ -333,7 +334,17 @@ class BaseCommand extends core_1.Command {
333
334
  // `preAction` hook; oclif has no equivalent that beats `init()`, so this
334
335
  // scans argv itself. The flag is still declared in `baseFlags` above, which
335
336
  // is what puts it in `--help` and keeps oclif from rejecting it.
336
- (0, keychain_2.setActiveProfile)((0, keychain_2.resolveProfileFromArgv)(this.argv) ?? process.env.OVERSKY_PROFILE ?? '');
337
+ //
338
+ // The rule is the daemon's, read from one function (OSK-22299):
339
+ // --profile > OVERSKY_PROFILE > <root>/profile.lock > default. The CLI used
340
+ // to skip the lock, so after `skrrd profile use work` the two binaries
341
+ // acted on different profiles from the same shell.
342
+ try {
343
+ (0, keychain_2.selectActiveProfile)((0, keychain_2.resolveProfileFromArgv)(this.argv));
344
+ }
345
+ catch (err) {
346
+ this.error(err.message, { exit: 64 });
347
+ }
337
348
  // A daemon-stamped autonomous process is a separate principal, not a
338
349
  // convenient place to inherit the user's CLI login. Resolve this before
339
350
  // touching migration, Keychain/file auth, refresh, or daemon auto-broker
@@ -1348,6 +1359,7 @@ class BaseCommand extends core_1.Command {
1348
1359
  managedRuntime: this.authManagedRuntime,
1349
1360
  baseURL: this.cliConfig?.baseURL,
1350
1361
  bin: this.config?.bin ?? 'skrr',
1362
+ profile: (0, keychain_2.getActiveProfileSelection)(),
1351
1363
  });
1352
1364
  }
1353
1365
  async catch(err) {
@@ -1359,6 +1371,12 @@ class BaseCommand extends core_1.Command {
1359
1371
  process.exitCode = err.oclif?.exit ?? 1;
1360
1372
  return;
1361
1373
  }
1374
+ // Every other `this.exit(n)` is a command that printed its own result and
1375
+ // then chose its status (`triggers fire --strict --json`, `widgets check`,
1376
+ // `search all`, ...). It still reaches that immediate exit, so hand what
1377
+ // it printed to the OS first or a piped reader gets 64 KiB of it
1378
+ // (OSK-22165).
1379
+ await (0, drain_stdio_1.drainStdio)();
1362
1380
  return super.catch(err);
1363
1381
  }
1364
1382
  // Canonical Task Model v1 removed several `tasks complete` flags outright,
@@ -1431,6 +1449,9 @@ class BaseCommand extends core_1.Command {
1431
1449
  if (!err.message.includes(line))
1432
1450
  err.message = `${err.message}\n\n${line}`;
1433
1451
  }
1452
+ // `super.catch` rethrows into oclif's `handle`, which exits immediately:
1453
+ // anything the command printed before failing must leave the process first.
1454
+ await (0, drain_stdio_1.drainStdio)();
1434
1455
  return super.catch(err);
1435
1456
  }
1436
1457
  error(input, options = {}) {
@@ -1582,16 +1603,20 @@ class BaseCommand extends core_1.Command {
1582
1603
  });
1583
1604
  }
1584
1605
  else if (bodyCode === 'TASK_LIST_TIMEOUT') {
1585
- // The list was too broad for the database's time limit — a 503 the API sent on purpose,
1586
- // with the narrower question to ask. The outage branch below would say skrr is down,
1587
- // record an incident, and tell an agent to retry the very query that cannot finish
1588
- // (OSK-21284).
1606
+ // The database cut the list off at its time limit — a 503 the API sent on purpose. For an
1607
+ // unscoped list that means too broad a question, and the body names the narrower one: the
1608
+ // outage branch below would say skrr is down, record an incident, and tell an agent to
1609
+ // retry the very query that cannot finish (OSK-21284). For a list the caller already
1610
+ // narrowed the server says the delay is its own and sets `retryable: true` (OSK-22297);
1611
+ // retrying IS the remedy then, so that verdict and the retryable exit code follow the body.
1612
+ // Neither is an outage, so neither records an incident.
1613
+ const retryable = body?.retryable === true;
1589
1614
  this.failWithCliError({
1590
1615
  message: say(describeTaskListTimeout(body, this.config.bin)),
1591
1616
  code: bodyCode,
1592
1617
  status: e.status,
1593
- exit: 1,
1594
- retryable: false,
1618
+ exit: retryable ? 5 : 1,
1619
+ retryable,
1595
1620
  details: envelopeDetails(body),
1596
1621
  });
1597
1622
  }
@@ -2451,18 +2476,26 @@ function describeGitHubUnavailable() {
2451
2476
  *
2452
2477
  * `GET /api/tasks` answers 503 with this code when its one aggregate is cut off at `maxTimeMS`,
2453
2478
  * which an unscoped list over every accessible Space reaches because no index serves its sort
2454
- * across the access filter. Lead with the server's `cause`/`remedy`, falling back to the CLI's
2455
- * own sentence: the 5xx redaction boundary generalizes a bare message in production.
2479
+ * across the access filter. A list the caller already narrowed can reach it too, and then the
2480
+ * server says the delay is its own and sets `retryable: true` (OSK-22297). Lead with the
2481
+ * server's `cause`/`remedy`, falling back to the CLI's own sentence for the case `retryable`
2482
+ * names: the 5xx redaction boundary generalizes a bare message in production.
2456
2483
  *
2457
2484
  * Exported for tests.
2458
2485
  */
2459
2486
  function describeTaskListTimeout(body, bin = 'skrr') {
2487
+ const retryable = body?.retryable === true;
2460
2488
  const cause = stringProp(body, 'cause') ||
2461
- 'The task list took too long: it spans every task you can see across all your workspaces and ' +
2462
- 'Spaces, and the database could not return the newest page within its time limit.';
2489
+ (retryable
2490
+ ? 'The task list took too long: the database did not return the page within its time limit, ' +
2491
+ 'and the delay is not in the request.'
2492
+ : 'The task list took too long: it spans every task you can see across all your workspaces and ' +
2493
+ 'Spaces, and the database could not return the newest page within its time limit.');
2463
2494
  const remedy = stringProp(body, 'remedy') ||
2464
- `Name where to look: a workspace (\`${bin} workspaces use <workspace-id>\`, or \`--workspace <workspace-id>\`) ` +
2465
- `or a Space (\`${bin} tasks list --space <space-id>\`).`;
2495
+ (retryable
2496
+ ? 'Try again in a moment with the same request.'
2497
+ : `Name where to look: a workspace (\`${bin} workspaces use <workspace-id>\`, or \`--workspace <workspace-id>\`) ` +
2498
+ `or a Space (\`${bin} tasks list --space <space-id>\`).`);
2466
2499
  return `${cause}\n → ${remedy}`;
2467
2500
  }
2468
2501
  /**
@@ -17,7 +17,9 @@ const base_command_1 = require("../../../base-command");
17
17
  * agenda MCP server's hardened defaults (`DEFAULT_SCHEDULE_MAX_FIRES_PER_DAY`).
18
18
  */
19
19
  class AgendaTriggerCreate extends base_command_1.BaseCommand {
20
- static description = 'Register a future automatic agent run via the AgentTrigger subsystem. Mirrors the agenda_create_trigger MCP tool.';
20
+ static description = 'Register a future automatic agent run via the AgentTrigger subsystem. Mirrors the agenda_create_trigger MCP tool. ' +
21
+ 'Every run is a model turn. For a daily time, a one-time run or a deterministic action with no model turn ' +
22
+ '(for example creating a task), use `skrr triggers create`.';
21
23
  static examples = [
22
24
  "<%= config.bin %> agenda trigger create <agent-id> --kind schedule --cron '0 9 * * MON' --label 'Weekly briefing' --prompt 'Summarize last week and plan this week.'",
23
25
  "<%= config.bin %> agenda trigger create <agent-id> --kind self_scheduled --delay-minutes 240 --label 'Follow up' --prompt 'Check back on the Q2 launch task.'",
@@ -45,7 +47,7 @@ class AgendaTriggerCreate extends base_command_1.BaseCommand {
45
47
  description: "5-field cron expression — required when --kind=schedule (e.g. '0 9 * * MON')",
46
48
  }),
47
49
  timezone: core_1.Flags.string({
48
- description: 'IANA timezone for the cron (defaults to UTC). Only used with --kind=schedule.',
50
+ description: 'IANA timezone the cron is read in, for example America/Los_Angeles. Defaults to UTC, so "0 9 * * *" is 09:00 UTC when this is left out. Only used with --kind=schedule.',
49
51
  }),
50
52
  'delay-minutes': core_1.Flags.integer({
51
53
  description: 'Minutes from now to fire — required when --kind=self_scheduled. ' +
@@ -104,16 +104,16 @@ class AgendaTriggerList extends base_command_1.BaseCommand {
104
104
  return;
105
105
  }
106
106
  const rows = items.map((t) => {
107
- const next = t.schedule?.nextRunAt ??
108
- t.selfScheduled?.nextRunAt ??
109
- (0, triggers_1.onceDueAt)(t) ??
110
- '-';
107
+ // The same answer `triggers list` gives: a disabled trigger has no next run (its stored
108
+ // `nextRunAt` is where it WOULD run), so one list no longer says it will run while the other
109
+ // says it will not (OSK-22493).
110
+ const next = (0, triggers_1.nextRunLabel)(t);
111
111
  const fires = t.audit?.fireCount ?? 0;
112
112
  return {
113
113
  id: String(t.id ?? '-'),
114
114
  kind: String(t.kind ?? '-'),
115
115
  enabled: t.enabled === false ? 'no' : 'yes',
116
- label: String(t.label ?? '-').slice(0, 40),
116
+ label: String(t.label ?? '-'),
117
117
  next: String(next).slice(0, 25),
118
118
  fires: String(fires),
119
119
  source: (0, agent_trigger_listing_1.sourceLabel)(t, isUnconfirmedTurnCapture(t)),
@@ -123,8 +123,8 @@ class AgendaTriggerList extends base_command_1.BaseCommand {
123
123
  { key: 'id', header: 'TRIGGER ID' },
124
124
  { key: 'kind', header: 'KIND' },
125
125
  { key: 'enabled', header: 'ON' },
126
- { key: 'label', header: 'LABEL' },
127
- { key: 'next', header: 'NEXT RUN' },
126
+ { key: 'label', header: 'LABEL', maxWidth: 40, truncate: 'middle' },
127
+ { key: 'next', header: 'NEXT/LAST' },
128
128
  { key: 'fires', header: 'FIRES' },
129
129
  { key: 'source', header: 'SOURCE' },
130
130
  ], (line) => this.log(line));
@@ -0,0 +1,17 @@
1
+ import { BaseCommand } from '../../../base-command';
2
+ /**
3
+ * Approve an Agent's message that is waiting for your approval, and deliver it
4
+ * Only a person can decide: the server refuses an Agent or automation credential (OSK-22364).
5
+ */
6
+ export default class AgentMessageApprove extends BaseCommand {
7
+ static description: string;
8
+ static examples: string[];
9
+ static args: {
10
+ intent: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
11
+ };
12
+ static flags: {
13
+ agent: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
+ };
16
+ run(): Promise<void>;
17
+ }
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const data_provider_1 = require("@skrr-ai/data-provider");
5
+ const base_command_1 = require("../../../base-command");
6
+ const agent_resolver_1 = require("../../../lib/agent-resolver");
7
+ const message_intent_1 = require("../../../lib/message-intent");
8
+ /**
9
+ * Approve an Agent's message that is waiting for your approval, and deliver it
10
+ * Only a person can decide: the server refuses an Agent or automation credential (OSK-22364).
11
+ */
12
+ class AgentMessageApprove extends base_command_1.BaseCommand {
13
+ static description = "Approve an Agent's message that is waiting for your approval, and deliver it";
14
+ static examples = [
15
+ '<%= config.bin %> agent message pending --agent <agent-id>',
16
+ '<%= config.bin %> agent message approve <intent-id> --agent <agent-id>',
17
+ ];
18
+ static args = {
19
+ intent: core_1.Args.string({ description: 'Intent ID from `agent message pending`', required: true }),
20
+ };
21
+ static flags = {
22
+ agent: core_1.Flags.string({ description: 'Agent ID', required: false }),
23
+ json: core_1.Flags.boolean({ description: 'Output as JSON' }),
24
+ };
25
+ async run() {
26
+ const { args, flags } = await this.parse(AgentMessageApprove);
27
+ const sessionContext = (0, message_intent_1.resolveMessageCommandSessionContext)({
28
+ requireHumanAuth: () => this.requireAuth(),
29
+ });
30
+ if (sessionContext) {
31
+ this.failWithCliError({
32
+ message: 'Only a person can see and decide on messages waiting for approval, not an Agent session.',
33
+ code: 'HUMAN_APPROVAL_REQUIRED',
34
+ exit: 2,
35
+ retryable: false,
36
+ });
37
+ }
38
+ let agentId;
39
+ try {
40
+ const explicitAgentId = (0, agent_resolver_1.mergeExplicitAgentInputs)([
41
+ { label: '--agent', value: flags.agent },
42
+ ]);
43
+ agentId = (await (0, agent_resolver_1.resolveAgentIdentity)(explicitAgentId)).id;
44
+ }
45
+ catch (error) {
46
+ const failure = (0, agent_resolver_1.agentResolutionFailure)(error);
47
+ this.failWithCliError({
48
+ message: failure.message,
49
+ code: failure.code,
50
+ exit: 2,
51
+ retryable: false,
52
+ details: failure.suggestion ? { suggestion: failure.suggestion } : undefined,
53
+ });
54
+ }
55
+ try {
56
+ const result = await data_provider_1.dataService.decideAgentDmIntent(agentId, args.intent, 'approve');
57
+ if (flags.json) {
58
+ this.log(JSON.stringify(result, null, 2));
59
+ return;
60
+ }
61
+ if (result.duplicate) {
62
+ this.log(`Nothing to do: that message is already ${result.status}.`);
63
+ return;
64
+ }
65
+ this.log(`Approved: ${result.intentId} is now ${result.status}${result.reason ? ` (${result.reason})` : ''}.`);
66
+ }
67
+ catch (error) {
68
+ this.handleApiError(error);
69
+ }
70
+ }
71
+ }
72
+ exports.default = AgentMessageApprove;
@@ -0,0 +1,17 @@
1
+ import { BaseCommand } from '../../../base-command';
2
+ /**
3
+ * Decline an Agent's message that is waiting for your approval, and cancel it
4
+ * Only a person can decide: the server refuses an Agent or automation credential (OSK-22364).
5
+ */
6
+ export default class AgentMessageDecline extends BaseCommand {
7
+ static description: string;
8
+ static examples: string[];
9
+ static args: {
10
+ intent: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
11
+ };
12
+ static flags: {
13
+ agent: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
+ };
16
+ run(): Promise<void>;
17
+ }
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const data_provider_1 = require("@skrr-ai/data-provider");
5
+ const base_command_1 = require("../../../base-command");
6
+ const agent_resolver_1 = require("../../../lib/agent-resolver");
7
+ const message_intent_1 = require("../../../lib/message-intent");
8
+ /**
9
+ * Decline an Agent's message that is waiting for your approval, and cancel it
10
+ * Only a person can decide: the server refuses an Agent or automation credential (OSK-22364).
11
+ */
12
+ class AgentMessageDecline extends base_command_1.BaseCommand {
13
+ static description = "Decline an Agent's message that is waiting for your approval, and cancel it";
14
+ static examples = [
15
+ '<%= config.bin %> agent message pending --agent <agent-id>',
16
+ '<%= config.bin %> agent message decline <intent-id> --agent <agent-id>',
17
+ ];
18
+ static args = {
19
+ intent: core_1.Args.string({ description: 'Intent ID from `agent message pending`', required: true }),
20
+ };
21
+ static flags = {
22
+ agent: core_1.Flags.string({ description: 'Agent ID', required: false }),
23
+ json: core_1.Flags.boolean({ description: 'Output as JSON' }),
24
+ };
25
+ async run() {
26
+ const { args, flags } = await this.parse(AgentMessageDecline);
27
+ const sessionContext = (0, message_intent_1.resolveMessageCommandSessionContext)({
28
+ requireHumanAuth: () => this.requireAuth(),
29
+ });
30
+ if (sessionContext) {
31
+ this.failWithCliError({
32
+ message: 'Only a person can see and decide on messages waiting for approval, not an Agent session.',
33
+ code: 'HUMAN_APPROVAL_REQUIRED',
34
+ exit: 2,
35
+ retryable: false,
36
+ });
37
+ }
38
+ let agentId;
39
+ try {
40
+ const explicitAgentId = (0, agent_resolver_1.mergeExplicitAgentInputs)([
41
+ { label: '--agent', value: flags.agent },
42
+ ]);
43
+ agentId = (await (0, agent_resolver_1.resolveAgentIdentity)(explicitAgentId)).id;
44
+ }
45
+ catch (error) {
46
+ const failure = (0, agent_resolver_1.agentResolutionFailure)(error);
47
+ this.failWithCliError({
48
+ message: failure.message,
49
+ code: failure.code,
50
+ exit: 2,
51
+ retryable: false,
52
+ details: failure.suggestion ? { suggestion: failure.suggestion } : undefined,
53
+ });
54
+ }
55
+ try {
56
+ const result = await data_provider_1.dataService.decideAgentDmIntent(agentId, args.intent, 'decline');
57
+ if (flags.json) {
58
+ this.log(JSON.stringify(result, null, 2));
59
+ return;
60
+ }
61
+ if (result.duplicate) {
62
+ this.log(`Nothing to do: that message is already ${result.status}.`);
63
+ return;
64
+ }
65
+ this.log(`Declined: ${result.intentId} is now ${result.status}${result.reason ? ` (${result.reason})` : ''}.`);
66
+ }
67
+ catch (error) {
68
+ this.handleApiError(error);
69
+ }
70
+ }
71
+ }
72
+ exports.default = AgentMessageDecline;
@@ -0,0 +1,18 @@
1
+ import { BaseCommand } from '../../../base-command';
2
+ /**
3
+ * The owner's view of an Agent's own messages that are waiting on `ask_first`. Without this the
4
+ * Gateway held them and told nobody (OSK-22364): `skrr agent message send` answered
5
+ * `approval_required`, and the message expired six hours later.
6
+ */
7
+ export default class AgentMessagePending extends BaseCommand {
8
+ static description: string;
9
+ static examples: string[];
10
+ static args: {
11
+ agent: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
12
+ };
13
+ static flags: {
14
+ agent: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
+ };
17
+ run(): Promise<void>;
18
+ }
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const data_provider_1 = require("@skrr-ai/data-provider");
5
+ const base_command_1 = require("../../../base-command");
6
+ const agent_resolver_1 = require("../../../lib/agent-resolver");
7
+ const message_intent_1 = require("../../../lib/message-intent");
8
+ /**
9
+ * The owner's view of an Agent's own messages that are waiting on `ask_first`. Without this the
10
+ * Gateway held them and told nobody (OSK-22364): `skrr agent message send` answered
11
+ * `approval_required`, and the message expired six hours later.
12
+ */
13
+ class AgentMessagePending extends base_command_1.BaseCommand {
14
+ static description = "List an Agent's own messages that are waiting for your approval because it is set to ask first";
15
+ static examples = [
16
+ '<%= config.bin %> agent message pending --agent <agent-id>',
17
+ '<%= config.bin %> agent message approve <intent-id> --agent <agent-id>',
18
+ ];
19
+ static args = {
20
+ agent: core_1.Args.string({ description: 'Agent ID', required: false, ignoreStdin: true }),
21
+ };
22
+ static flags = {
23
+ agent: core_1.Flags.string({ description: 'Agent ID' }),
24
+ json: core_1.Flags.boolean({ description: 'Output as JSON' }),
25
+ };
26
+ async run() {
27
+ const { args, flags } = await this.parse(AgentMessagePending);
28
+ const sessionContext = (0, message_intent_1.resolveMessageCommandSessionContext)({
29
+ requireHumanAuth: () => this.requireAuth(),
30
+ });
31
+ if (sessionContext) {
32
+ this.failWithCliError({
33
+ message: 'Only a person can see and decide on messages waiting for approval, not an Agent session.',
34
+ code: 'HUMAN_APPROVAL_REQUIRED',
35
+ exit: 2,
36
+ retryable: false,
37
+ });
38
+ }
39
+ let agentId;
40
+ try {
41
+ const explicitAgentId = (0, agent_resolver_1.mergeExplicitAgentInputs)([
42
+ { label: 'agent argument', value: args.agent },
43
+ { label: '--agent', value: flags.agent },
44
+ ]);
45
+ agentId = (await (0, agent_resolver_1.resolveAgentIdentity)(explicitAgentId)).id;
46
+ }
47
+ catch (error) {
48
+ const failure = (0, agent_resolver_1.agentResolutionFailure)(error);
49
+ this.failWithCliError({
50
+ message: failure.message,
51
+ code: failure.code,
52
+ exit: 2,
53
+ retryable: false,
54
+ details: failure.suggestion ? { suggestion: failure.suggestion } : undefined,
55
+ });
56
+ }
57
+ try {
58
+ const result = await data_provider_1.dataService.listAgentDmPendingIntents(agentId);
59
+ if (flags.json) {
60
+ this.log(JSON.stringify(result, null, 2));
61
+ return;
62
+ }
63
+ if (!result.items.length) {
64
+ this.log('Nothing is waiting for your approval.');
65
+ return;
66
+ }
67
+ for (const item of result.items) {
68
+ const expires = item.expiresAt ? ` · expires ${item.expiresAt}` : '';
69
+ this.log(`${item.intentId} [${item.kind ?? 'message'}]${expires}`);
70
+ this.log(` ${item.preview}`);
71
+ }
72
+ this.log(`\nApprove one with: skrr agent message approve <intent-id> --agent ${agentId} (or decline).`);
73
+ }
74
+ catch (error) {
75
+ this.handleApiError(error);
76
+ }
77
+ }
78
+ }
79
+ exports.default = AgentMessagePending;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
4
  const data_provider_1 = require("@skrr-ai/data-provider");
5
5
  const base_command_1 = require("../../../base-command");
6
+ const always_on_command_result_1 = require("../../../lib/always-on-command-result");
6
7
  /**
7
8
  * `skrr agents always-on disable <agent-id>` — flip the desired Boolean to off
8
9
  * via the single control endpoint (`PUT /api/agents/:id/always-on`).
@@ -44,11 +45,18 @@ class AgentsAlwaysOnDisable extends base_command_1.BaseCommand {
44
45
  catch (err) {
45
46
  this.handleApiError(err);
46
47
  }
48
+ const result = (0, always_on_command_result_1.alwaysOnCommandResult)(false, status);
47
49
  if (flags.json) {
48
50
  this.log(JSON.stringify(status, null, 2));
51
+ // The envelope carries `desiredEnabled` and `controlCommand`; the exit
52
+ // code says whether the Agent ended off, so a script need not parse it.
53
+ if (!result.matched)
54
+ this.exit(1);
49
55
  return;
50
56
  }
51
- this.log(`Always-On disabled — generation=${status.generation} operational=${status.operationalState}`);
57
+ this.log(result.line);
58
+ if (!result.matched)
59
+ this.exit(1);
52
60
  if (status.operationalState === 'cancelling') {
53
61
  this.log('Note: active Runs are still draining. Re-run `always-on status` to observe the transition to `off`.');
54
62
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
4
  const data_provider_1 = require("@skrr-ai/data-provider");
5
5
  const base_command_1 = require("../../../base-command");
6
+ const always_on_command_result_1 = require("../../../lib/always-on-command-result");
6
7
  /**
7
8
  * `skrr agents always-on enable <agent-id>` — flip the desired Boolean to on
8
9
  * via the single control endpoint (`PUT /api/agents/:id/always-on`).
@@ -52,11 +53,18 @@ class AgentsAlwaysOnEnable extends base_command_1.BaseCommand {
52
53
  catch (err) {
53
54
  this.handleApiError(err);
54
55
  }
56
+ const result = (0, always_on_command_result_1.alwaysOnCommandResult)(true, status);
55
57
  if (flags.json) {
56
58
  this.log(JSON.stringify(status, null, 2));
59
+ // The envelope carries `desiredEnabled` and `controlCommand`; the exit
60
+ // code says whether the Agent ended on, so a script need not parse it.
61
+ if (!result.matched)
62
+ this.exit(1);
57
63
  return;
58
64
  }
59
- this.log(`Always-On enabled — generation=${status.generation} operational=${status.operationalState}`);
65
+ this.log(result.line);
66
+ if (!result.matched)
67
+ this.exit(1);
60
68
  if (status.operationalState === 'needs_setup') {
61
69
  this.log('Note: no Commitment or managed producer lane exists yet. Create a Commitment (or convert a legacy heartbeat) so the runtime has something to fire.');
62
70
  }
@@ -4,6 +4,7 @@ const core_1 = require("@oclif/core");
4
4
  const data_provider_1 = require("@skrr-ai/data-provider");
5
5
  const base_command_1 = require("../../../base-command");
6
6
  const agent_proactive_baseline_1 = require("../../../lib/agent-proactive-baseline");
7
+ const always_on_runtime_1 = require("../../../lib/always-on-runtime");
7
8
  /**
8
9
  * `skrr agents always-on status <agent-id>` — read the composed generation-aware
9
10
  * Always-On status envelope via the single control endpoint
@@ -36,6 +37,16 @@ class AgentsAlwaysOnStatus extends base_command_1.BaseCommand {
36
37
  catch (err) {
37
38
  this.handleApiError(err);
38
39
  }
40
+ // The envelope says what the platform means to fire, not whether the machine
41
+ // that work runs on is reachable (OSK-22347). Read it from the Agent, as the
42
+ // web does; a failed read is `unknown`, never a silently absent line.
43
+ let runtime;
44
+ try {
45
+ runtime = (0, always_on_runtime_1.runtimeFromAgent)(await data_provider_1.dataService.getAgentById({ agent_id: args.id }));
46
+ }
47
+ catch {
48
+ runtime = always_on_runtime_1.RUNTIME_READ_FAILED;
49
+ }
39
50
  // This endpoint authorizes and resolves by Agent ID. Its messaging scope is
40
51
  // built from the Agent's own workspace, which can differ from the global
41
52
  // workspace header supplied by the caller.
@@ -52,7 +63,7 @@ class AgentsAlwaysOnStatus extends base_command_1.BaseCommand {
52
63
  }
53
64
  : null;
54
65
  if (flags.json) {
55
- this.log(JSON.stringify(workspaceSelection ? { ...status, workspaceSelection } : status, null, 2));
66
+ this.log(JSON.stringify({ ...status, agentRuntime: runtime, ...(workspaceSelection ? { workspaceSelection } : {}) }, null, 2));
56
67
  return;
57
68
  }
58
69
  this.log(`Agent: ${args.id}`);
@@ -65,6 +76,8 @@ class AgentsAlwaysOnStatus extends base_command_1.BaseCommand {
65
76
  this.log(`Desired: ${status.desiredEnabled ? 'on' : 'off'}`);
66
77
  this.log(`Generation: ${status.generation}`);
67
78
  this.log(`Operational: ${status.operationalState}`);
79
+ for (const line of (0, always_on_runtime_1.runtimeLines)(runtime, status.desiredEnabled))
80
+ this.log(line);
68
81
  this.log(`Reconcile: ${status.reconcile.status}` +
69
82
  (status.reconcile.lastError ? ` (${status.reconcile.lastError})` : ''));
70
83
  this.log(`Managed triggers: ${status.reconcile.managedTriggerCount}` +
@@ -138,17 +138,26 @@ function backgroundLoopLines(agentId, relationshipLoopsSkipped, initialAlwaysOn
138
138
  ];
139
139
  if (!initialAlwaysOn)
140
140
  return [
141
- 'Passive creation acknowledged. Legacy task/memory scans were omitted. Explicit chats still run; Always-On can enable the seeded managed portfolio later.',
141
+ // Plain words for what exists: a policy, a Compass and the daily self-reflection
142
+ // check are seeded even for a passive Agent, and nothing runs until Always-On is on
143
+ // (OSK-22360; "legacy scans" and "managed portfolio" were internal terms).
144
+ 'Passive creation acknowledged: Always-On is off, so nothing runs on its own yet. A policy, a Compass and a daily self-reflection check were seeded, and the scheduled task/goal and memory scans were omitted. Explicit chats still run; Always-On can switch the seeded loops on later.',
142
145
  ` skrr agents always-on enable ${agentId} # start autonomous work later`,
143
146
  ];
147
+ const alwaysOnLines = [
148
+ 'Always-On: on. This agent starts working on its own as soon as it is set up.',
149
+ ` skrr agents always-on disable ${agentId} # turn it off`,
150
+ ];
144
151
  if (relationshipLoopsSkipped) {
145
152
  return [
153
+ ...alwaysOnLines,
146
154
  'Background loops: relationship portfolio skipped (--no-relationship-loops). ' +
147
155
  'Self-reflection is still seeded and runs on its own cadence.',
148
156
  ` skrr commitments list --agent ${agentId} --include-system # what it still runs`,
149
157
  ];
150
158
  }
151
159
  return [
160
+ ...alwaysOnLines,
152
161
  'Background loops: this agent is being enrolled in system-managed commitments — ' +
153
162
  'self-reflection, conversation continuity, relationship pulse, commitment incubator ' +
154
163
  'and open-loop closer. They run on their own cadence, unprompted, and are hidden ' +