@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
@@ -8,6 +8,11 @@ const schedule_1 = require("../../../lib/schedule");
8
8
  * `skrr agents todos list <agent-id>` — the agent's To-Do day plan (the
9
9
  * ToDoPanel feed). To-Dos are time-boxed work blocks (manual or Smart-Schedule
10
10
  * generated). Defaults to today; `--date` steps to another day.
11
+ *
12
+ * "Today" and the day's edges are in ONE named timezone: `--timezone`, or this
13
+ * machine's, the same default `plan-day` and `schedule-trace` use. It used to be
14
+ * UTC, so at 17:15 in Vancouver `--date 2026-11-02` listed a UTC day that ended
15
+ * at 16:00 local and printed "No to-dos." for tonight's to-do (OSK-22398).
11
16
  */
12
17
  class AgentsTodosList extends base_command_1.BaseCommand {
13
18
  static description = "List an agent's to-dos for a day";
@@ -21,15 +26,24 @@ class AgentsTodosList extends base_command_1.BaseCommand {
21
26
  };
22
27
  static flags = {
23
28
  json: core_1.Flags.boolean({ description: 'Output as JSON' }),
24
- date: core_1.Flags.string({ description: 'Day to list (YYYY-MM-DD). Defaults to today in the selected timezone.' }),
25
- timezone: core_1.Flags.string({ description: 'IANA timezone for the day (defaults to UTC)' }),
29
+ date: core_1.Flags.string({
30
+ description: 'Day to list (YYYY-MM-DD). Defaults to today in the selected timezone.',
31
+ }),
32
+ timezone: core_1.Flags.string({
33
+ description: "IANA timezone for the day and for the times shown (defaults to this machine's timezone, as in plan-day and schedule-trace)",
34
+ }),
26
35
  };
27
36
  async run() {
28
37
  this.requireAuth();
29
38
  const { args, flags } = await this.parse(AgentsTodosList);
39
+ const timezone = (0, schedule_1.resolveDayTimeZone)(flags.timezone);
40
+ if (!timezone) {
41
+ this.error(`Invalid IANA timezone: ${flags.timezone}`, { exit: 1 });
42
+ }
43
+ const date = flags.date ?? (0, schedule_1.scheduleTraceToday)(new Date(), timezone);
30
44
  let response;
31
45
  try {
32
- response = await schedule_1.scheduleApi.listTodos(args.id, flags.date, flags.timezone);
46
+ response = await schedule_1.scheduleApi.listTodos(args.id, date, timezone);
33
47
  }
34
48
  catch (err) {
35
49
  this.handleApiError(err);
@@ -38,8 +52,8 @@ class AgentsTodosList extends base_command_1.BaseCommand {
38
52
  this.printJsonResult((0, list_output_1.listResult)(response, 'todos'));
39
53
  return;
40
54
  }
41
- this.log(`Day timezone: ${flags.timezone || 'UTC'}`);
42
- (0, schedule_1.renderTodoList)(response.todos ?? [], (line) => this.log(line));
55
+ this.log(`Day: ${date} in ${(0, schedule_1.describeTimeZone)(timezone)}`);
56
+ (0, schedule_1.renderTodoList)(response.todos ?? [], (line) => this.log(line), timezone);
43
57
  }
44
58
  }
45
59
  exports.default = AgentsTodosList;
@@ -36,7 +36,7 @@ class AgentsTriggersCreate extends base_command_1.BaseCommand {
36
36
  label: core_1.Flags.string({ description: 'Human-readable trigger label' }),
37
37
  enabled: core_1.Flags.boolean({ description: 'Create enabled or disabled', allowNo: true }),
38
38
  mode: core_1.Flags.string({
39
- description: 'Execution mode (default send_message)',
39
+ description: `${triggers_1.TRIGGER_MODE_FLAG_DESCRIPTION} Default: send_message.`,
40
40
  options: [...triggers_1.TRIGGER_EXECUTOR_MODES],
41
41
  }),
42
42
  prompt: core_1.Flags.string({ description: 'Prompt template sent when the trigger fires' }),
@@ -122,6 +122,13 @@ class AgentsTriggersPolicy extends base_command_1.BaseCommand {
122
122
  }
123
123
  const policy = (response.policy ?? response) || {};
124
124
  const counts = response.counts ?? {};
125
+ // `configured` is false when nobody chose this policy: the platform default, or a quiet-start
126
+ // row seeded at creation. The numbers below then read like a deliberate choice, and for an
127
+ // Agent with no stored policy they are NOT the seeded ones (24/day, 10/h against 2/day, 1/h)
128
+ // (OSK-22354).
129
+ if (policy.configured === false) {
130
+ this.log('Note: nobody has set this policy: these are the platform defaults (or the quiet start seeded at creation), not a choice.');
131
+ }
125
132
  this.log(`Mode: ${String(policy.mode ?? '-')}`);
126
133
  this.log(`Allowed kinds: ${Array.isArray(policy.allowedKinds) ? policy.allowedKinds.join(', ') : '-'}`);
127
134
  this.log(`Max fires/day: ${String(policy.maxFiresPerDay ?? '-')}`);
@@ -28,7 +28,7 @@ class AgentsTriggersUpdate extends base_command_1.BaseCommand {
28
28
  }),
29
29
  label: core_1.Flags.string({ description: 'Human-readable trigger label' }),
30
30
  enabled: core_1.Flags.boolean({ description: 'Enable or disable the trigger', allowNo: true }),
31
- mode: core_1.Flags.string({ description: 'Execution mode', options: [...triggers_1.TRIGGER_EXECUTOR_MODES] }),
31
+ mode: core_1.Flags.string({ description: triggers_1.TRIGGER_MODE_FLAG_DESCRIPTION, options: [...triggers_1.TRIGGER_EXECUTOR_MODES] }),
32
32
  prompt: core_1.Flags.string({ description: 'Prompt template sent when the trigger fires' }),
33
33
  'builtin-action': core_1.Flags.string({
34
34
  description: 'Typed builtinAction JSON object for mode=builtin_action',
@@ -17,12 +17,22 @@ const commitment_product_1 = require("../../lib/commitment-product");
17
17
  const commitments_1 = require("../../lib/commitments");
18
18
  const DEFAULT_EVENT_DRIVEN_BACKSTOP_MS = 24 * 60 * 60 * 1000;
19
19
  const DEFAULT_EVENT_SOURCES = new Set(['github', 'slack', 'email', 'calendar']);
20
+ /**
21
+ * Every GitHub event a Commitment's watched source can receive: the server's own list
22
+ * (`GITHUB_EVENT_DELIVERY_PERMISSION` in CommitmentTriggerBindings). The selector offered seven of
23
+ * the ten, so `workflow_run_failed`, `workflow_run_succeeded` and `pull_request_synchronized` —
24
+ * all in the event catalog — were refused locally with no word on whether Commitments support them
25
+ * (OSK-21683). They do.
26
+ */
20
27
  const GITHUB_EVENT_OPTIONS = [
21
28
  'pull_request_opened',
22
29
  'pull_request_merged',
30
+ 'pull_request_synchronized',
23
31
  'review_requested',
24
32
  'check_run_failed',
25
33
  'check_run_succeeded',
34
+ 'workflow_run_failed',
35
+ 'workflow_run_succeeded',
26
36
  'issue_opened',
27
37
  'comment_created',
28
38
  ];
@@ -338,7 +348,7 @@ JSON
338
348
  options: [...commitments_1.COMMITMENT_WATCHED_SOURCES],
339
349
  }),
340
350
  'github-event': core_1.Flags.string({
341
- description: 'GitHub event to watch (repeatable; implies --watch github). Use check_run_failed for CI remediation.',
351
+ description: 'GitHub event to watch (repeatable; implies --watch github). Use check_run_failed for one failing check, workflow_run_failed or workflow_run_succeeded for a whole workflow.',
342
352
  multiple: true,
343
353
  options: [...GITHUB_EVENT_OPTIONS],
344
354
  }),
@@ -361,10 +371,10 @@ JSON
361
371
  multiple: true,
362
372
  }),
363
373
  cadence: core_1.Flags.string({
364
- description: 'Check interval, e.g. "15m", "6h", "30d" (1m..365d). Defaults to interval mode; with --event-driven, this is the timed backstop.',
374
+ description: 'Check interval, e.g. "15m", "6h", "30d" (1m..365d). Defaults to interval mode; with --event-driven, this is the recovery interval: a missed event is not replayed, the next interval re-checks current state.',
365
375
  }),
366
376
  'event-driven': core_1.Flags.boolean({
367
- description: 'Wake on matching watched-source events, with a timed backstop from --cadence (default 24h). Requires an event-capable watched source and cannot be combined with a different --cadence-mode.',
377
+ description: 'Wake on matching watched-source events, so checks come sooner than --cadence (default 24h). An event can be missed and is not replayed; every interval the Commitment re-checks current state instead. Requires an event-capable watched source and cannot be combined with a different --cadence-mode.',
368
378
  }),
369
379
  'cadence-mode': core_1.Flags.string({
370
380
  description: 'Advanced cadence mode (default: interval when --cadence is set, else manual). Prefer --event-driven for event_plus_interval with a 24h default backstop.',
@@ -59,8 +59,23 @@ function preflightHeadline(report, persisted) {
59
59
  return `${label}: A capability or configuration check is still needed`;
60
60
  const reasons = report.gates?.find((gate) => gate.id === 'budget_bounds')?.detail?.reasons;
61
61
  const noActionRuns = Array.isArray(reasons) && reasons.includes('action_runs_zero');
62
- return noActionRuns
63
- ? `${label}: Ready to run, but its daily Run budget is 0, so no agent turn will start`
62
+ // `Ready to run` is a statement about activation. Two advisory gates also say whether
63
+ // anything it produces can reach a person, and a headline that ignores them reads as
64
+ // "ready" over a Commitment that can neither deliver nor contact (OSK-22338, OSK-22352).
65
+ // A quiet-hours or interval hold is a chosen, self-clearing quiet and stays out of it.
66
+ const gateById = (id) => report.gates?.find((gate) => gate.id === id);
67
+ const caveats = [];
68
+ if (noActionRuns)
69
+ caveats.push('its daily Run budget is 0, so no agent turn will start');
70
+ if (gateById('endpoint')?.verdict === 'block') {
71
+ caveats.push('no connected endpoint can deliver its reports');
72
+ }
73
+ const attention = gateById('attention');
74
+ if (attention?.verdict === 'block' && attention.reason === 'policy_nudge_muted') {
75
+ caveats.push('its daily nudge limit is 0, so it never contacts you');
76
+ }
77
+ return caveats.length
78
+ ? `${label}: Ready to run, but ${caveats.join(', and ')}`
64
79
  : `${label}: Ready to run`;
65
80
  }
66
81
  function preflightGateLines(gate, verbose = false, refusesActivation = false) {
@@ -219,7 +234,7 @@ class CommitmentsPreflight extends base_command_1.BaseCommand {
219
234
  description: 'Unsaved Commitment create body file, or - for stdin',
220
235
  }),
221
236
  'event-fixture': core_1.Flags.string({
222
- description: 'Optional event fixture JSON file, or - for stdin',
237
+ description: 'Event context JSON file, or - for stdin; previews context, not event matching',
223
238
  }),
224
239
  };
225
240
  async run() {
@@ -236,7 +251,10 @@ class CommitmentsPreflight extends base_command_1.BaseCommand {
236
251
  let policy = null;
237
252
  try {
238
253
  if (args.id) {
239
- report = await commitments_1.commitmentApi.preflight(args.id, flags.next);
254
+ const eventFixture = flags['event-fixture']
255
+ ? await (0, prompt_1.readJsonBody)(flags['event-fixture'])
256
+ : undefined;
257
+ report = await commitments_1.commitmentApi.preflight(args.id, flags.next, eventFixture);
240
258
  try {
241
259
  policy =
242
260
  (await commitments_1.commitmentApi.get(args.id))?.commitment?.policy ?? null;
@@ -268,11 +286,19 @@ class CommitmentsPreflight extends base_command_1.BaseCommand {
268
286
  this.handleApiError(err);
269
287
  return;
270
288
  }
289
+ const fixtureContext = report.renderedPlan?.eventContext;
290
+ const fixtureNote = flags['event-fixture']
291
+ ? fixtureContext?.fixtureNote || (fixtureContext?.available
292
+ ? 'The fixture appears in preview context; event matching was not verified.'
293
+ : 'The server did not confirm that it used the supplied fixture; event matching was not verified.')
294
+ : undefined;
271
295
  if (flags.json) {
272
- this.log(JSON.stringify(report, null, 2));
296
+ this.log(JSON.stringify(fixtureNote ? { ...report, eventFixturePreview: fixtureNote } : report, null, 2));
273
297
  return;
274
298
  }
275
299
  this.log(preflightHeadline(report, Boolean(args.id)));
300
+ if (fixtureNote)
301
+ this.log(`Event fixture: ${fixtureNote}`);
276
302
  for (const line of (0, commitments_1.activationRefusalLines)(report.activation))
277
303
  this.log(line);
278
304
  // Whose permissions the run will use (OSK-11975), before the gates, so an
@@ -54,6 +54,7 @@ class Daemon extends core_1.Command {
54
54
  this.log(' skrr daemon recover-offline-queue — restore recoverable offline WALs');
55
55
  this.log(' skrr daemon usage — show local Claude Code and Codex usage limits');
56
56
  this.log(' skrr daemon byok — manage local BYOK Keychain credentials');
57
+ this.log(' skrr daemon profile — list, select, clean up, remove and restore profiles');
57
58
  this.log('');
58
59
  // These three are registered as aliases of top-level commands, which oclif
59
60
  // does not list under the topic. They are the commands you reach for during
@@ -57,7 +57,14 @@ export declare function resolveLegacyDaemonLogPath(flags: Pick<DaemonLogsFlags,
57
57
  home?: string;
58
58
  env?: NodeJS.ProcessEnv;
59
59
  }): string;
60
- /** The profile `logs` addresses: --profile, then the profile environment variable, then the pin. */
60
+ /**
61
+ * The profile `logs` addresses, by the rule `skrr` and `skrrd` share
62
+ * (`resolveProfileSelection`: --profile, then OVERSKY_PROFILE, then the pin).
63
+ *
64
+ * One deliberate difference: a value outside the profile grammar is skipped
65
+ * rather than refused, because this only chooses a file to read and the forwarded
66
+ * `skrrd logs` refuses the same value itself. It is never joined into a path.
67
+ */
61
68
  export declare function resolveDaemonLogsProfile(flags: Pick<DaemonLogsFlags, 'profile'>, options?: {
62
69
  home?: string;
63
70
  env?: NodeJS.ProcessEnv;
@@ -31,9 +31,9 @@ const node_fs_1 = require("node:fs");
31
31
  const node_os_1 = require("node:os");
32
32
  const node_path_1 = __importDefault(require("node:path"));
33
33
  const node_events_1 = require("node:events");
34
+ const auth_core_1 = require("@skrr-ai/auth-core");
34
35
  const exec_runtime_binary_1 = require("../../lib/exec-runtime-binary");
35
36
  const MAX_FALLBACK_LOG_BYTES = 1024 * 1024;
36
- const PROFILE_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
37
37
  /**
38
38
  * Older daemons already kept logs in this profile-scoped location, even
39
39
  * though they did not yet expose `oversky logs`. Keep the compatibility path
@@ -82,31 +82,41 @@ function describeLogAge(mtimeMs, now = Date.now()) {
82
82
  };
83
83
  }
84
84
  function resolveLegacyDaemonLogPath(flags, options = {}) {
85
- const home = options.home ?? (0, node_os_1.homedir)();
86
- return node_path_1.default.join(home, '.skrr', 'profiles', resolveDaemonLogsProfile(flags, options), 'logs', flags.stderr ? 'daemon.err.log' : 'daemon.log');
85
+ return node_path_1.default.join((0, auth_core_1.resolveConfigRoot)(daemonLogsEnv(options)), 'profiles', resolveDaemonLogsProfile(flags, options), 'logs', flags.stderr ? 'daemon.err.log' : 'daemon.log');
87
86
  }
88
- /** The profile `logs` addresses: --profile, then the profile environment variable, then the pin. */
89
- function resolveDaemonLogsProfile(flags, options = {}) {
90
- const home = options.home ?? (0, node_os_1.homedir)();
87
+ /**
88
+ * The environment the log lookup resolves the skrr root from. A test (or a
89
+ * caller) that names `home` means `<home>/.skrr` unless the root has been
90
+ * pointed elsewhere explicitly, which is the daemon's own rule for its log
91
+ * directory (`<root>/profiles/<profile>/logs`). This used to join `~/.skrr` by
92
+ * hand and so read the wrong directory under `SKRR_CONFIG_DIR`.
93
+ */
94
+ function daemonLogsEnv(options) {
91
95
  const env = options.env ?? process.env;
92
- // An explicit --profile outranks the environment, as it does everywhere else.
96
+ if (!options.home || (0, auth_core_1.isConfigRootOverridden)(env))
97
+ return env;
98
+ return (0, auth_core_1.withConfigRoot)(env, node_path_1.default.join(options.home, '.skrr'));
99
+ }
100
+ /**
101
+ * The profile `logs` addresses, by the rule `skrr` and `skrrd` share
102
+ * (`resolveProfileSelection`: --profile, then OVERSKY_PROFILE, then the pin).
103
+ *
104
+ * One deliberate difference: a value outside the profile grammar is skipped
105
+ * rather than refused, because this only chooses a file to read and the forwarded
106
+ * `skrrd logs` refuses the same value itself. It is never joined into a path.
107
+ */
108
+ function resolveDaemonLogsProfile(flags, options = {}) {
109
+ const env = daemonLogsEnv(options);
93
110
  const fromFlag = flags.profile?.trim();
94
- const fromEnv = env.OVERSKY_PROFILE?.trim();
95
- let profile = fromFlag && PROFILE_NAME.test(fromFlag)
96
- ? fromFlag
97
- : fromEnv && PROFILE_NAME.test(fromEnv)
98
- ? fromEnv
99
- : undefined;
100
- if (!profile) {
101
- try {
102
- const pinned = (0, node_fs_1.readFileSync)(node_path_1.default.join(home, '.skrr', 'profile.lock'), 'utf8').trim();
103
- profile = PROFILE_NAME.test(pinned) ? pinned : undefined;
104
- }
105
- catch {
106
- // An absent/corrupt sticky selector must match the daemon's default.
107
- }
111
+ if (fromFlag && (0, auth_core_1.isValidProfileName)(fromFlag))
112
+ return fromFlag;
113
+ try {
114
+ return (0, auth_core_1.resolveProfileSelection)({ env }).profile;
115
+ }
116
+ catch {
117
+ // An invalid OVERSKY_PROFILE: fall to the pin, as the old reader did.
118
+ return (0, auth_core_1.readProfileLock)(env) ?? auth_core_1.DEFAULT_PROFILE;
108
119
  }
109
- return profile ?? 'default';
110
120
  }
111
121
  /**
112
122
  * Read the installed launchd definition's log destinations (OSK-15993). The
@@ -0,0 +1,15 @@
1
+ import { Command } from '@oclif/core';
2
+ /**
3
+ * `skrr daemon profile <subverb> ...` forwards to `skrrd profile`, which owns the
4
+ * profile root: list, current, create, use, clear, doctor, cleanup, trash, restore,
5
+ * purge-trash and remove (OSK-22307). The runtime's recovery hints name this
6
+ * spelling when they were printed through `skrr daemon`, so it has to exist.
7
+ */
8
+ export default class DaemonProfile extends Command {
9
+ static aliases: string[];
10
+ static summary: string;
11
+ static description: string;
12
+ static strict: boolean;
13
+ static examples: string[];
14
+ run(): Promise<void>;
15
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const exec_runtime_binary_1 = require("../../lib/exec-runtime-binary");
5
+ /**
6
+ * `skrr daemon profile <subverb> ...` forwards to `skrrd profile`, which owns the
7
+ * profile root: list, current, create, use, clear, doctor, cleanup, trash, restore,
8
+ * purge-trash and remove (OSK-22307). The runtime's recovery hints name this
9
+ * spelling when they were printed through `skrr daemon`, so it has to exist.
10
+ */
11
+ class DaemonProfile extends core_1.Command {
12
+ // `skrr daemons <sub>` — the plural is advertised as an alias for the
13
+ // whole topic, and without a per-command alias only the bare topic
14
+ // resolved: every subcommand under it failed.
15
+ static aliases = ['daemons:profile'];
16
+ static summary = 'Manage background service profiles: list, create, select, clean up, remove and restore them';
17
+ static description = (0, exec_runtime_binary_1.forwardedFlagsNote)('profile');
18
+ // Positional subverbs (`remove work`) and their flags are skrrd's; with strict off,
19
+ // oclif also stops folding `profile remove` into a command id.
20
+ static strict = false;
21
+ static examples = [
22
+ '<%= config.bin %> daemon profile list',
23
+ '<%= config.bin %> daemon profile remove work',
24
+ '<%= config.bin %> daemon profile remove work --apply',
25
+ '<%= config.bin %> daemon profile trash',
26
+ '<%= config.bin %> daemon profile restore <trash-name>',
27
+ ];
28
+ async run() {
29
+ // `this.argv`, NOT `this.parse()`: `strict = false` relaxes POSITIONAL arity
30
+ // and oclif still rejects any flag this command has not declared, which
31
+ // would make `--apply` and `--json` unreachable (OSK-296).
32
+ const argv = this.argv;
33
+ try {
34
+ // A runtime from before `profile` existed treats an unknown verb as `start`,
35
+ // which collides with a running daemon's singleton. Its help starts nothing.
36
+ if ((await (0, exec_runtime_binary_1.runtimeBinarySupportsSubcommand)('profile')) === false) {
37
+ this.error('The installed skrr background service is older than this skrr CLI and has no ' +
38
+ '`profile` command. Update it with `skrr daemon update`, then rerun this command.', { exit: 2 });
39
+ }
40
+ this.exit(await (0, exec_runtime_binary_1.execRuntimeBinary)(['profile', ...argv]));
41
+ }
42
+ catch (error) {
43
+ if (error.message === 'runtime-binary-not-installed') {
44
+ this.log((0, exec_runtime_binary_1.notInstalledMessage)());
45
+ this.exit(127);
46
+ }
47
+ throw error;
48
+ }
49
+ }
50
+ }
51
+ exports.default = DaemonProfile;
@@ -17,7 +17,7 @@ class GoalsBriefingStatus extends base_command_1.BaseCommand {
17
17
  this.handleApiError(err);
18
18
  }
19
19
  if (flags.json) {
20
- this.log(JSON.stringify(status, null, 2));
20
+ this.printJsonResult(status);
21
21
  return;
22
22
  }
23
23
  this.log(`Morning briefing: ${status.enabled ? 'enabled' : 'disabled'}`);
@@ -0,0 +1,23 @@
1
+ import { BaseCommand } from '../../../base-command';
2
+ /**
3
+ * `skrr initiatives worker deactivate <agent-id>` — stop the agent's WORKER: every one of its
4
+ * worker watchers (task/goal, follow-through, memory, ...) is disabled and its initiative policy
5
+ * goes to `off`. The agent itself is kept.
6
+ *
7
+ * A worker watcher is owned by the platform, so `agents triggers delete` refuses one with
8
+ * PRODUCER_OWNED_TRIGGER; this is the command that refusal names (OSK-22423).
9
+ */
10
+ export default class InitiativesWorkerDeactivate extends BaseCommand {
11
+ static description: string;
12
+ static examples: string[];
13
+ static args: {
14
+ agent: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
15
+ };
16
+ static flags: {
17
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
18
+ yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
19
+ 'keep-initiatives': import("@oclif/core/interfaces").BooleanFlag<boolean>;
20
+ reason: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
21
+ };
22
+ run(): Promise<void>;
23
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const base_command_1 = require("../../../base-command");
5
+ const prompt_1 = require("../../../lib/prompt");
6
+ const initiatives_worker_1 = require("../../../lib/initiatives-worker");
7
+ /**
8
+ * `skrr initiatives worker deactivate <agent-id>` — stop the agent's WORKER: every one of its
9
+ * worker watchers (task/goal, follow-through, memory, ...) is disabled and its initiative policy
10
+ * goes to `off`. The agent itself is kept.
11
+ *
12
+ * A worker watcher is owned by the platform, so `agents triggers delete` refuses one with
13
+ * PRODUCER_OWNED_TRIGGER; this is the command that refusal names (OSK-22423).
14
+ */
15
+ class InitiativesWorkerDeactivate extends base_command_1.BaseCommand {
16
+ static description = "Stop an agent's worker: disable all its worker watchers and turn its initiative policy off (the agent is kept)";
17
+ static examples = [
18
+ '<%= config.bin %> initiatives worker deactivate <agent-id>',
19
+ '<%= config.bin %> initiatives worker deactivate <agent-id> --keep-initiatives --yes',
20
+ ];
21
+ static args = {
22
+ agent: core_1.Args.string({ ignoreStdin: true, description: 'Agent ID', required: true }),
23
+ };
24
+ static flags = {
25
+ json: core_1.Flags.boolean({ description: 'Output as JSON' }),
26
+ yes: core_1.Flags.boolean({ char: 'y', description: 'Skip the confirmation prompt' }),
27
+ 'keep-initiatives': core_1.Flags.boolean({
28
+ description: 'Leave the agent\'s open initiatives as they are (by default they are closed)',
29
+ }),
30
+ reason: core_1.Flags.string({ description: 'Why (recorded on the change)' }),
31
+ };
32
+ async run() {
33
+ this.requireAuth();
34
+ const { args, flags } = await this.parse(InitiativesWorkerDeactivate);
35
+ let confirmed;
36
+ try {
37
+ confirmed = await (0, prompt_1.confirmDestructive)(`Disable every worker watcher of ${args.agent} and turn its initiative policy off` +
38
+ `${flags['keep-initiatives'] ? '' : ', closing its open initiatives'}?`, flags.yes);
39
+ }
40
+ catch (err) {
41
+ if (err.exit === 7)
42
+ this.error(err.message, { exit: 7 });
43
+ throw err;
44
+ }
45
+ if (!confirmed) {
46
+ this.log('Cancelled.');
47
+ return;
48
+ }
49
+ let result;
50
+ try {
51
+ result = await initiatives_worker_1.initiativesWorkerApi.deactivate({
52
+ agentId: args.agent,
53
+ ...(flags.reason ? { reason: flags.reason } : {}),
54
+ ...(flags['keep-initiatives'] ? { closeOpenInitiatives: false } : {}),
55
+ });
56
+ }
57
+ catch (err) {
58
+ this.handleApiError(err);
59
+ }
60
+ if (flags.json) {
61
+ this.printJsonResult(result);
62
+ return;
63
+ }
64
+ this.log(`Worker stopped for ${result.agentId}.`);
65
+ for (const item of result.schedules ?? []) {
66
+ if (item.skipped || !item.schedule)
67
+ continue;
68
+ this.log(` ${item.kind}: ${item.schedule.enabled === false ? 'disabled' : 'unchanged'}` +
69
+ `${item.schedule.triggerId ? ` (${item.schedule.triggerId})` : ''}`);
70
+ }
71
+ const closure = result.initiativeClosure;
72
+ if (closure && !closure.skipped) {
73
+ this.log(` initiatives closed: ${closure.modified ?? 0} of ${closure.matched ?? 0}`);
74
+ }
75
+ this.log('The watchers stay listed, disabled. They are not deleted.');
76
+ }
77
+ }
78
+ exports.default = InitiativesWorkerDeactivate;
@@ -248,7 +248,10 @@ class Login extends base_command_1.BaseCommand {
248
248
  // and a failure here must not fail it or discard what the user just earned.
249
249
  // It degrades to exactly the old behaviour, with a hint naming the command
250
250
  // that finishes the job.
251
- let handoff = await (0, daemonHandoff_1.handOffToLocalDaemon)(process.env, { loginFlow: result.flow });
251
+ let handoff = await (0, daemonHandoff_1.handOffToLocalDaemon)(process.env, {
252
+ loginFlow: result.flow,
253
+ brokerProfile: result.brokerProfile,
254
+ });
252
255
  // Nothing to hand a credential TO. This is the first moment we can fix
253
256
  // that correctly — installing the daemon binds it to a deployment and a
254
257
  // profile, and until this login there was no session to take them from.
@@ -264,7 +267,10 @@ class Login extends base_command_1.BaseCommand {
264
267
  if (setup.status === 'installed') {
265
268
  // Re-run rather than duplicating the mint here: it is the same act
266
269
  // it always was, and now it has somewhere to land.
267
- handoff = await (0, daemonHandoff_1.handOffToLocalDaemon)(process.env, { loginFlow: result.flow });
270
+ handoff = await (0, daemonHandoff_1.handOffToLocalDaemon)(process.env, {
271
+ loginFlow: result.flow,
272
+ brokerProfile: result.brokerProfile,
273
+ });
268
274
  }
269
275
  else if (setup.status === 'failed') {
270
276
  this.log(`Could not set up the background service: ${setup.detail}.`);
@@ -1,15 +1,35 @@
1
1
  import { BaseCommand } from '../base-command';
2
+ import { type CliSessionRevokeResult } from '../lib/refresh';
2
3
  export declare function shouldSkipLocalLogout(input: {
3
4
  hasAnyStoredToken: boolean;
4
5
  hasUsableLocalToken: boolean;
5
6
  hasUnreadableEncryptedToken: boolean;
6
7
  allDevices: boolean;
7
8
  }): boolean;
9
+ /**
10
+ * Why the sign-in this logout removed is still a live session on the server,
11
+ * or null when the server took the revoke, or there was no session to revoke.
12
+ *
13
+ * Logout clears the local credential whatever the server says, so a person can
14
+ * always sign out of a computer. It used to say "Signed out." either way, and a
15
+ * session the server never heard about stayed usable with nothing to show for
16
+ * it (OSK-22307: a profile whose files `skrrd profile remove` had moved could
17
+ * not decrypt its CLI credential, so nothing was sent).
18
+ */
19
+ export declare function unrevokedSessionReason(input: {
20
+ revoke: CliSessionRevokeResult;
21
+ hasUnreadableEncryptedToken: boolean;
22
+ hasAnyStoredToken: boolean;
23
+ serverUrl: string;
24
+ }): string | null;
25
+ /** How to end a session this computer could not revoke, from a profile still signed in. */
26
+ export declare function unrevokedSessionRemedy(cliId: string | undefined): string;
8
27
  export default class Logout extends BaseCommand {
9
28
  static description: string;
10
29
  static flags: {
11
30
  'all-devices': import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
31
  yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
32
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
33
  };
14
34
  run(): Promise<void>;
15
35
  /**