@skrr-ai/cli 0.1.231 → 0.1.233

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 (161) hide show
  1. package/README.md +42 -4
  2. package/bin/dev.cjs +4 -1
  3. package/bin/run.js +0 -15
  4. package/dist/base-command.d.ts +6 -11
  5. package/dist/base-command.js +34 -43
  6. package/dist/commands/agenda/plan.d.ts +2 -1
  7. package/dist/commands/agenda/plan.js +18 -4
  8. package/dist/commands/agent/message/context.d.ts +2 -0
  9. package/dist/commands/agent/message/context.js +18 -3
  10. package/dist/commands/agent/message/list.d.ts +22 -0
  11. package/dist/commands/agent/message/list.js +66 -0
  12. package/dist/commands/agent/message/send.d.ts +1 -1
  13. package/dist/commands/agent/message/send.js +1 -3
  14. package/dist/commands/agent/message/show.d.ts +14 -0
  15. package/dist/commands/agent/message/show.js +39 -0
  16. package/dist/commands/agents/chat.d.ts +4 -0
  17. package/dist/commands/agents/chat.js +79 -17
  18. package/dist/commands/agents/eval/list.d.ts +4 -0
  19. package/dist/commands/agents/eval/list.js +33 -0
  20. package/dist/commands/agents/eval/show.d.ts +1 -0
  21. package/dist/commands/agents/eval/show.js +19 -0
  22. package/dist/commands/agents/intuitions/generate.js +1 -1
  23. package/dist/commands/agents/intuitions/list.js +1 -1
  24. package/dist/commands/agents/permissions/policy.js +25 -2
  25. package/dist/commands/agents/spawn.js +61 -24
  26. package/dist/commands/agents/triggers/fire.js +1 -1
  27. package/dist/commands/agents/triggers/runs.js +3 -0
  28. package/dist/commands/code/acp.js +1 -1
  29. package/dist/commands/code/handover.d.ts +3 -3
  30. package/dist/commands/code/handover.js +12 -12
  31. package/dist/commands/code/index.d.ts +3 -8
  32. package/dist/commands/code/index.js +15 -21
  33. package/dist/commands/code/jobs/approve.d.ts +1 -11
  34. package/dist/commands/code/jobs/approve.js +3 -15
  35. package/dist/commands/code/jobs/cancel.js +3 -2
  36. package/dist/commands/code/jobs/index.js +1 -1
  37. package/dist/commands/code/jobs/list.js +4 -11
  38. package/dist/commands/code/jobs/run.js +13 -7
  39. package/dist/commands/code/jobs/show.js +52 -6
  40. package/dist/commands/code/run.js +1 -1
  41. package/dist/commands/commands.d.ts +1 -0
  42. package/dist/commands/commands.js +5 -1
  43. package/dist/commands/context.d.ts +1 -0
  44. package/dist/commands/context.js +1 -0
  45. package/dist/commands/duties/catalog/add.d.ts +18 -0
  46. package/dist/commands/duties/catalog/add.js +52 -0
  47. package/dist/commands/duties/catalog/index.d.ts +18 -0
  48. package/dist/commands/duties/catalog/index.js +88 -0
  49. package/dist/commands/duties/receipt.js +56 -1
  50. package/dist/commands/goals/plan-now.d.ts +5 -3
  51. package/dist/commands/goals/plan-now.js +21 -16
  52. package/dist/commands/goals/planner-compare.js +5 -3
  53. package/dist/commands/instructions/discovery.d.ts +10 -0
  54. package/dist/commands/instructions/discovery.js +74 -0
  55. package/dist/commands/runs/admission.d.ts +12 -0
  56. package/dist/commands/runs/admission.js +66 -0
  57. package/dist/commands/runs/events.d.ts +16 -0
  58. package/dist/commands/runs/events.js +89 -0
  59. package/dist/commands/runs/list.d.ts +27 -0
  60. package/dist/commands/runs/list.js +151 -0
  61. package/dist/commands/runs/show.d.ts +14 -0
  62. package/dist/commands/runs/show.js +273 -0
  63. package/dist/commands/runs/stop.d.ts +15 -0
  64. package/dist/commands/runs/stop.js +105 -0
  65. package/dist/commands/runs/transcript.d.ts +19 -0
  66. package/dist/commands/runs/transcript.js +178 -0
  67. package/dist/commands/tasks/attachments/download.d.ts +1 -0
  68. package/dist/commands/tasks/attachments/download.js +6 -4
  69. package/dist/commands/tasks/attachments/source.d.ts +6 -0
  70. package/dist/commands/tasks/attachments/source.js +18 -0
  71. package/dist/commands/tasks/chat/exchange.d.ts +0 -14
  72. package/dist/commands/tasks/chat/exchange.js +8 -39
  73. package/dist/commands/tasks/chat/reply-run.d.ts +15 -0
  74. package/dist/commands/tasks/chat/reply-run.js +69 -0
  75. package/dist/commands/tasks/complete.js +1 -1
  76. package/dist/commands/tasks/lifecycle/transition.d.ts +1 -0
  77. package/dist/commands/tasks/lifecycle/transition.js +51 -13
  78. package/dist/commands/tasks/operations/show.js +5 -0
  79. package/dist/commands/tasks/result/submit.js +4 -2
  80. package/dist/commands/tasks/retry.js +25 -16
  81. package/dist/commands/tasks/runs.js +7 -0
  82. package/dist/commands/tasks/start-receipt.js +8 -8
  83. package/dist/commands/tasks/start.js +12 -1
  84. package/dist/commands/triggers/audit.js +3 -1
  85. package/dist/commands/triggers/fire-detail.js +4 -1
  86. package/dist/commands/triggers/fire.js +1 -1
  87. package/dist/commands/usage.d.ts +1 -0
  88. package/dist/commands/usage.js +1 -0
  89. package/dist/generated/agent-guides.json +350 -777
  90. package/dist/help.d.ts +2 -7
  91. package/dist/help.js +13 -7
  92. package/dist/hooks/init.js +10 -0
  93. package/dist/lib/agent-chat-queue.d.ts +2 -1
  94. package/dist/lib/agent-chat-queue.js +26 -21
  95. package/dist/lib/agent-evals.d.ts +1 -1
  96. package/dist/lib/agent-evals.js +13 -3
  97. package/dist/lib/agent-guides.d.ts +3 -5
  98. package/dist/lib/agent-guides.js +12 -13
  99. package/dist/lib/agent-runs.d.ts +101 -0
  100. package/dist/lib/agent-runs.js +350 -0
  101. package/dist/lib/agentic-stream.d.ts +13 -1
  102. package/dist/lib/agentic-stream.js +165 -81
  103. package/dist/lib/api-fetch.d.ts +4 -2
  104. package/dist/lib/api-fetch.js +11 -5
  105. package/dist/lib/code-handover.d.ts +2 -3
  106. package/dist/lib/code-handover.js +4 -6
  107. package/dist/lib/command-manifest.d.ts +1 -6
  108. package/dist/lib/command-manifest.js +86 -13
  109. package/dist/lib/communication-history.d.ts +27 -0
  110. package/dist/lib/communication-history.js +45 -0
  111. package/dist/lib/config.d.ts +2 -3
  112. package/dist/lib/config.js +2 -3
  113. package/dist/lib/duties.d.ts +5 -1
  114. package/dist/lib/duties.js +4 -0
  115. package/dist/lib/execution-history.d.ts +34 -0
  116. package/dist/lib/execution-history.js +7 -0
  117. package/dist/lib/first-party-harness-broker.d.ts +1 -1
  118. package/dist/lib/first-party-harness-broker.js +3 -5
  119. package/dist/lib/format.d.ts +1 -0
  120. package/dist/lib/format.js +18 -0
  121. package/dist/lib/guide-pointer.d.ts +5 -1
  122. package/dist/lib/guide-pointer.js +21 -2
  123. package/dist/lib/hosted-job-status.d.ts +4 -0
  124. package/dist/lib/hosted-job-status.js +19 -0
  125. package/dist/lib/inbound-messages.d.ts +2 -0
  126. package/dist/lib/inbound-messages.js +5 -0
  127. package/dist/lib/intuition-look.js +20 -4
  128. package/dist/lib/memory-history-session.d.ts +8 -4
  129. package/dist/lib/memory-history-session.js +30 -23
  130. package/dist/lib/roles.d.ts +2 -2
  131. package/dist/lib/schedule.d.ts +4 -0
  132. package/dist/lib/schedule.js +4 -3
  133. package/dist/lib/task-agent-run.d.ts +4 -0
  134. package/dist/lib/task-agent-run.js +15 -0
  135. package/dist/lib/task-execution.d.ts +1 -1
  136. package/dist/lib/task-execution.js +3 -19
  137. package/dist/lib/task-extras.d.ts +11 -1
  138. package/dist/lib/task-extras.js +15 -1
  139. package/dist/lib/task-transcript.js +3 -8
  140. package/dist/lib/triggers.d.ts +5 -36
  141. package/dist/lib/triggers.js +48 -33
  142. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonWire.d.ts +9 -0
  143. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonWire.js +40 -3
  144. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/harnessCommand.d.ts +37 -0
  145. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/harnessCommand.js +59 -0
  146. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/toolApprovalSignature.d.ts +62 -0
  147. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/toolApprovalSignature.js +56 -0
  148. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonWire.d.ts +9 -0
  149. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonWire.js +34 -3
  150. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/harnessCommand.d.ts +37 -0
  151. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/harnessCommand.js +57 -0
  152. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/toolApprovalSignature.d.ts +62 -0
  153. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/toolApprovalSignature.js +51 -0
  154. package/dist/node_modules/@skrr-ai/auth-core/package.json +10 -0
  155. package/dist/node_modules/@skrr-ai/data-provider/index.js +12259 -12160
  156. package/docs/v1/quickstart.md +18 -0
  157. package/oclif.manifest.json +3405 -2112
  158. package/package.json +6 -2
  159. package/skills/skrr/SKILL.md +14 -0
  160. package/dist/commands/triggers/runs.d.ts +0 -22
  161. package/dist/commands/triggers/runs.js +0 -58
@@ -27,7 +27,9 @@ function workerPolicyWindowLines(policy) {
27
27
  continue;
28
28
  const state = window.enabled === undefined
29
29
  ? 'disabled; enabled not specified'
30
- : window.enabled ? 'enabled' : 'disabled';
30
+ : window.enabled
31
+ ? 'enabled'
32
+ : 'disabled';
31
33
  lines.push(` ${label}: ${window.start}–${window.end} ${window.timezone ?? '(no zone recorded)'} (${state})`);
32
34
  }
33
35
  return lines;
@@ -37,8 +39,14 @@ function specWithEffectiveWindowFlags(spec) {
37
39
  const policy = spec.worker?.policy;
38
40
  if (!spec.worker || !policy)
39
41
  return spec;
40
- const workingHours = policy.workingHours && { ...policy.workingHours, enabled: policy.workingHours.enabled ?? false };
41
- const quietHours = policy.quietHours && { ...policy.quietHours, enabled: policy.quietHours.enabled ?? false };
42
+ const workingHours = policy.workingHours && {
43
+ ...policy.workingHours,
44
+ enabled: policy.workingHours.enabled ?? false,
45
+ };
46
+ const quietHours = policy.quietHours && {
47
+ ...policy.quietHours,
48
+ enabled: policy.quietHours.enabled ?? false,
49
+ };
42
50
  return {
43
51
  ...spec,
44
52
  worker: {
@@ -69,7 +77,12 @@ exports.SPEC_TEMPLATE = {
69
77
  watchers: [{ source: 'task_goal_watcher', intervalMinutes: 60 }],
70
78
  policy: {
71
79
  mode: 'ask_first',
72
- workingHours: { enabled: true, start: '09:00', end: '18:00', timezone: 'America/Los_Angeles' },
80
+ workingHours: {
81
+ enabled: true,
82
+ start: '09:00',
83
+ end: '18:00',
84
+ timezone: 'America/Los_Angeles',
85
+ },
73
86
  },
74
87
  },
75
88
  orchestrator: {
@@ -107,7 +120,7 @@ function installPlanLines(items, bin) {
107
120
  ? 'will be blocked'
108
121
  : item.origin;
109
122
  const note = item.status === 'declined'
110
- ? item.reason ?? 'declined'
123
+ ? (item.reason ?? 'declined')
111
124
  : item.status === 'will_be_blocked'
112
125
  ? `${item.reason ?? 'blocked'}: ${item.detail ?? 'the runtime cannot run it'}`
113
126
  : item.origin === 'default'
@@ -180,11 +193,19 @@ function initializeSummary(initialize) {
180
193
  const goals = initialize.goals.filter((item) => item.ok);
181
194
  const tasks = initialize.tasks.filter((item) => item.ok);
182
195
  const jobs = initialize.jobs.filter((item) => item.ok);
183
- const failed = initialize.goals.length + initialize.tasks.length + initialize.jobs.length -
184
- goals.length - tasks.length - jobs.length;
196
+ const failed = initialize.goals.length +
197
+ initialize.tasks.length +
198
+ initialize.jobs.length -
199
+ goals.length -
200
+ tasks.length -
201
+ jobs.length;
185
202
  if (!goals.length && !tasks.length && !jobs.length && !failed)
186
203
  return null;
187
- const parts = [noun(goals.length, 'goal'), noun(tasks.length, 'task'), noun(jobs.length, 'scheduled job')];
204
+ const parts = [
205
+ noun(goals.length, 'goal'),
206
+ noun(tasks.length, 'task'),
207
+ noun(jobs.length, 'scheduled job'),
208
+ ];
188
209
  const existing = [...goals, ...tasks].filter((item) => item.existing).length;
189
210
  return (parts.join(', ') +
190
211
  (existing ? ` (${existing} already existed)` : '') +
@@ -214,8 +235,11 @@ function proactiveInstallReadiness(result, bin) {
214
235
  // A Duty the owner deleted is reported, not repaired: it was not recreated on
215
236
  // purpose, and a repair command that names its id is a dead end (OSK-22381).
216
237
  const deleted = (result.installed.duties || []).filter((duty) => duty.status === 'deleted');
217
- const affected = (result.installed.duties || []).filter((duty) => duty.status !== 'deleted' && (duty.status !== 'active' || result.warnings.some((warning) => warning.step === `duty.${duty.title}`)));
218
- if (deleted.length && !affected.length &&
238
+ const affected = (result.installed.duties || []).filter((duty) => duty.status !== 'deleted' &&
239
+ (duty.status !== 'active' ||
240
+ result.warnings.some((warning) => warning.step === `duty.${duty.title}`)));
241
+ if (deleted.length &&
242
+ !affected.length &&
219
243
  result.warnings.every((warning) => warning.code === 'duty_deleted_not_recreated')) {
220
244
  return {
221
245
  status: 'degraded',
@@ -230,9 +254,10 @@ function proactiveInstallReadiness(result, bin) {
230
254
  // stopped activation was a gate that clears by itself. Say so and name the
231
255
  // command that finishes the job; `duties preflight` is a dry run that
232
256
  // never mentions resume (OSK-22351).
233
- const stillStarting = affected.length > 0 && affected.every((duty) => duty.status === 'draft' &&
234
- (duty.activationBlockedBy || []).length > 0 &&
235
- (duty.activationBlockedBy || []).every((entry) => entry.gate === 'always_on' && entry.reason === 'reconcile_pending'));
257
+ const stillStarting = affected.length > 0 &&
258
+ affected.every((duty) => duty.status === 'draft' &&
259
+ (duty.activationBlockedBy || []).length > 0 &&
260
+ (duty.activationBlockedBy || []).every((entry) => entry.gate === 'always_on' && entry.reason === 'reconcile_pending'));
236
261
  if (stillStarting && ids.length) {
237
262
  return {
238
263
  status: 'degraded',
@@ -266,7 +291,9 @@ function proactiveInstallReadiness(result, bin) {
266
291
  : 'A requested Duty needs attention. Review the setup warnings and inspect the Agent’s existing Duties before deciding what to do next.',
267
292
  ...(ids.length === 1
268
293
  ? { repairCommand: `${bin} duties preflight ${ids[0]}` }
269
- : safeAgentId ? { repairCommand: `${bin} duties list --agent ${safeAgentId}` } : {}),
294
+ : safeAgentId
295
+ ? { repairCommand: `${bin} duties list --agent ${safeAgentId}` }
296
+ : {}),
270
297
  };
271
298
  }
272
299
  if (result.warnings.some((warning) => ['job_preserved_disabled', 'job_already_fired', 'job_state_unavailable'].includes(warning.code))) {
@@ -307,9 +334,7 @@ function proactiveInstallReadiness(result, bin) {
307
334
  status: 'degraded',
308
335
  message: 'What the spec asked for is installed. Part of the new Agent\u2019s own setup did not finish; ' +
309
336
  'the warning below says which part and why. Re-running the spec does not change that.',
310
- ...(inspectAgent
311
- ? { repairCommand: `${bin} duties operating-review ${inspectAgent}` }
312
- : {}),
337
+ ...(inspectAgent ? { repairCommand: `${bin} duties operating-review ${inspectAgent}` } : {}),
313
338
  };
314
339
  }
315
340
  // A full trigger budget must not make a new persona-only Agent look broken
@@ -349,7 +374,8 @@ function proactiveInstallReadiness(result, bin) {
349
374
  * `--from-spec` for an exact, reviewed install (which may carry higher autonomy).
350
375
  */
351
376
  class AgentsSpawn extends base_command_1.BaseCommand {
352
- static description = 'Spawn a complete proactive agent from one sentence (plan → review → approve)\n\n' + exports.SPEC_FORMAT_HELP;
377
+ static description = 'Spawn a complete proactive agent from one sentence (plan → review → approve)\n\n' +
378
+ exports.SPEC_FORMAT_HELP;
353
379
  static examples = [
354
380
  '<%= config.bin %> agents spawn "watch my Slack and flag urgent unanswered messages"',
355
381
  '<%= config.bin %> agents spawn "plan my day every morning, working hours 9-6" --approve',
@@ -395,7 +421,7 @@ class AgentsSpawn extends base_command_1.BaseCommand {
395
421
  description: 'Print a valid spec JSON to edit and pass to --from-spec, and exit (creates nothing)',
396
422
  }),
397
423
  minimal: core_1.Flags.boolean({
398
- description: 'Install only what the spec asks for: decline every default the platform would add (the memory and task/goal scans, the initiative follow-through loop, the four relationship loops). The plan lists each default first',
424
+ description: 'Install only what the spec asks for: decline every default the platform would add (the memory and task/goal scans, the initiative follow-through loop, the five default loops). The plan lists each default first',
399
425
  }),
400
426
  without: core_1.Flags.string({
401
427
  description: `Decline one default by name; repeatable. One of: ${proactiveApi_1.DECLINABLE_DEFAULTS.join(', ')}. Refused when the spec itself asks for it`,
@@ -754,7 +780,8 @@ class AgentsSpawn extends base_command_1.BaseCommand {
754
780
  // these; the text plan showed none of them, so "Create it" created a goal, tasks
755
781
  // and a scheduled job the reader had never been shown (OSK-22349, OSK-22358).
756
782
  const initialize = spec.initialize;
757
- if (initialize && (initialize.goals?.length || initialize.tasks?.length || initialize.jobs?.length)) {
783
+ if (initialize &&
784
+ (initialize.goals?.length || initialize.tasks?.length || initialize.jobs?.length)) {
758
785
  this.log('');
759
786
  this.log('It will also create:');
760
787
  for (const goal of initialize.goals || [])
@@ -765,7 +792,9 @@ class AgentsSpawn extends base_command_1.BaseCommand {
765
792
  for (const job of initialize.jobs || []) {
766
793
  const when = job.cron
767
794
  ? `cron ${job.cron}`
768
- : job.runAtIso ? `once at ${job.runAtIso}` : 'no schedule';
795
+ : job.runAtIso
796
+ ? `once at ${job.runAtIso}`
797
+ : 'no schedule';
769
798
  this.log(` job: ${job.label} — ${when}${job.timezone ? ` ${job.timezone}` : ''}`);
770
799
  }
771
800
  }
@@ -808,7 +837,11 @@ class AgentsSpawn extends base_command_1.BaseCommand {
808
837
  for (const schedule of o.schedules || []) {
809
838
  const state = !schedule.triggerId
810
839
  ? 'not scheduled'
811
- : schedule.enabled === null ? 'unknown' : schedule.enabled ? 'enabled' : 'disabled';
840
+ : schedule.enabled === null
841
+ ? 'unknown'
842
+ : schedule.enabled
843
+ ? 'enabled'
844
+ : 'disabled';
812
845
  this.log(` ${schedule.kind}: ${state}` +
813
846
  (schedule.triggerId ? ` (${schedule.triggerId})` : '') +
814
847
  (schedule.reason ? ` — ${schedule.reason}` : ''));
@@ -833,8 +866,12 @@ class AgentsSpawn extends base_command_1.BaseCommand {
833
866
  const alwaysOn = result.installed.alwaysOn;
834
867
  if (alwaysOn) {
835
868
  const state = alwaysOn.desiredEnabled === undefined
836
- ? alwaysOn.ok ? 'set' : 'failed'
837
- : alwaysOn.desiredEnabled ? 'on' : 'off';
869
+ ? alwaysOn.ok
870
+ ? 'set'
871
+ : 'failed'
872
+ : alwaysOn.desiredEnabled
873
+ ? 'on'
874
+ : 'off';
838
875
  this.log(` always-on: ${state}${alwaysOn.operationalState ? ` (${alwaysOn.operationalState})` : ''}`);
839
876
  }
840
877
  const compass = result.installed.compass;
@@ -81,7 +81,7 @@ class AgentsTriggersFire extends base_command_1.BaseCommand {
81
81
  return;
82
82
  }
83
83
  this.log(`Fire requested: outcome=${String(result.outcome ?? '-')} reason=${String(result.reason ?? '-')}`);
84
- for (const line of (0, triggers_1.describeFireDetail)(result))
84
+ for (const line of (0, triggers_1.describeFireDetail)(result, this.config.bin))
85
85
  this.log(line);
86
86
  const note = (0, triggers_1.describeScheduledFire)(result);
87
87
  if (note)
@@ -50,6 +50,9 @@ class AgentsTriggersRuns extends base_command_1.BaseCommand {
50
50
  this.log(`Duration: ${detail.durationMs}ms`);
51
51
  if (detail.conversationId)
52
52
  this.log(`Conversation: ${detail.conversationId}`);
53
+ const runCommand = (0, triggers_1.fireRunHistoryCommand)(detail.agentRun, this.config.bin);
54
+ if (runCommand)
55
+ this.log(`Run History: ${runCommand}`);
53
56
  return;
54
57
  }
55
58
  const path = (0, triggers_1.withQuery)(`/api/triggers/${encodeURIComponent(args.triggerId)}/audit`, {
@@ -35,7 +35,7 @@ class CodeAcp extends core_1.Command {
35
35
  // The unit tests did not catch it because they cover `buildEngineArgs`, which
36
36
  // always forwarded verbatim. The args never reached it.
37
37
  //
38
- // OSK-3892 — and NO `{ managed: true }` here, deliberately. The daemon that
38
+ // OSK-3892 — and no `brokerInference` here. The daemon that
39
39
  // drives this command already brokers inference for the session: it admits the
40
40
  // lease, hosts the loopback broker, and injects the relay env. A second broker
41
41
  // in this process would double-wrap the relay and mint a second lease against
@@ -7,10 +7,10 @@ import { BaseCommand } from '../../base-command';
7
7
  *
8
8
  * The interactive session's transcript lives inside the engine, which
9
9
  * is a separately released binary (`resolveEngine` in `lib/first-party-harness.ts`), and
10
- * the server holds none of it: a managed session calls
10
+ * the server holds none of it: a local engine with managed inference calls
11
11
  * `/api/agentic/sessions/:id/inference/{admit,release}` and the token endpoints,
12
- * never `/ingest`. So neither this CLI nor the API can read what was said. The
13
- * brief therefore comes from the human, and the rest from git.
12
+ * never `/ingest`. The brief comes from the human and the workspace context
13
+ * comes from git. An explicit transcript export can supply more context.
14
14
  *
15
15
  * ── Why it dispatches a Cloud Coding task ──────────────────────────────────
16
16
  *
@@ -16,10 +16,10 @@ const first_party_harness_1 = require("../../lib/first-party-harness");
16
16
  *
17
17
  * The interactive session's transcript lives inside the engine, which
18
18
  * is a separately released binary (`resolveEngine` in `lib/first-party-harness.ts`), and
19
- * the server holds none of it: a managed session calls
19
+ * the server holds none of it: a local engine with managed inference calls
20
20
  * `/api/agentic/sessions/:id/inference/{admit,release}` and the token endpoints,
21
- * never `/ingest`. So neither this CLI nor the API can read what was said. The
22
- * brief therefore comes from the human, and the rest from git.
21
+ * never `/ingest`. The brief comes from the human and the workspace context
22
+ * comes from git. An explicit transcript export can supply more context.
23
23
  *
24
24
  * ── Why it dispatches a Cloud Coding task ──────────────────────────────────
25
25
  *
@@ -47,8 +47,7 @@ const first_party_harness_1 = require("../../lib/first-party-harness");
47
47
  * the pull request. This refuses by default and says what to do.
48
48
  */
49
49
  class CodeHandover extends base_command_1.BaseCommand {
50
- static description = 'Hand the work in this directory to an agent on a cloud runtime ' +
51
- '(--carry-session also carries the engine session transcript, when the engine supports export)';
50
+ static description = 'Start a new cloud Run for the work in this directory. Use --carry-session to include the local transcript as context.';
52
51
  static examples = [
53
52
  '<%= config.bin %> code handover --to "Frontend Agent" --brief "finish the bundle-size fix"',
54
53
  '<%= config.bin %> code handover --to agent_abc --brief "continue the parser refactor" --base main',
@@ -170,14 +169,13 @@ class CodeHandover extends base_command_1.BaseCommand {
170
169
  ` ${failure.detail}\n` +
171
170
  ' Re-run without --carry-session to hand over the situation only, or upgrade the engine.');
172
171
  }
173
- const envelope = (0, code_handover_1.parseSessionExportEnvelope)(stdout);
172
+ const envelope = (0, code_handover_1.parseSessionExportEnvelope)(stdout, sessionId);
174
173
  if (!envelope) {
175
174
  // Exit 0 but no contract envelope is a deviation, not a success: the
176
175
  // one shape this side may depend on (C2) did not arrive, so attaching
177
176
  // the output anyway would be guessing with someone else's session.
178
- this.error('The engine ran `session export` but did not produce the contract envelope ' +
179
- '({version, sessionId, messages[], truncated}) — this build predates or deviates from ' +
180
- 'the export contract, so nothing was attached.');
177
+ this.error('The engine returned an invalid transcript for the requested session. ' +
178
+ 'Check the session ID and engine version before starting the cloud job.');
181
179
  }
182
180
  // The endpoint's prompt cap is 50000 chars; the transcript gets what the
183
181
  // brief and the git context leave behind.
@@ -261,11 +259,13 @@ class CodeHandover extends base_command_1.BaseCommand {
261
259
  this.log(JSON.stringify(result, null, 2));
262
260
  return;
263
261
  }
264
- const task = result?.task ?? {};
262
+ const task = result?.task;
265
263
  this.log(`Handed over to ${target.name ?? target.id}`);
266
264
  this.log(` repo ${repoFullName}@${branch}`);
267
- this.log(` task ${String(task.id ?? '?')} (${String(task.status ?? 'queued')})`);
268
- const url = task.previewUrl ?? task.prUrl;
265
+ this.log(` task ${task?.id ?? '?'} (${task?.status ?? 'queued'})`);
266
+ if (task?.runId)
267
+ this.log(` run ${task.runId}`);
268
+ const url = task?.previewUrl ?? task?.prUrl;
269
269
  if (url)
270
270
  this.log(` ${String(url)}`);
271
271
  if (sessionExport) {
@@ -29,15 +29,10 @@ export default class Code extends Command {
29
29
  * engine is not installed, and `77`, the account was refused before the engine
30
30
  * could start (OSK-8822).
31
31
  *
32
- * ── Why `managed` is opt-IN per command ────────────────────────────────────
33
- *
34
- * `skrr code acp` must NOT take the managed path: the daemon that drives it already
35
- * brokers inference, and a second broker would double-wrap the relay. Opting in
36
- * per command rather than defaulting on means a future `skrr code <something>` can
37
- * only acquire a lease if someone decided it should — the failure mode of the
38
- * other arrangement is a new subcommand silently spending money.
32
+ * The standalone TUI and headless engine acquire inference leases for the local
33
+ * process. The daemon's ACP launch already has its own broker and execution authority.
39
34
  */
40
35
  export declare function forwardToEngine(cmd: Command, subcommand: string | null, passthrough: string[], options?: {
41
- managed?: boolean;
36
+ brokerInference?: boolean;
42
37
  projectPolicy?: 'tui' | 'headless';
43
38
  }): Promise<void>;
@@ -32,7 +32,7 @@ class Code extends core_1.Command {
32
32
  static description = 'Everything after ' +
33
33
  `\`code\` is forwarded to the engine unchanged, so engine flags are not listed here — ` +
34
34
  `run \`${auth_core_1.FIRST_PARTY_HARNESS.command} run --help\` for this wrapper, or the engine's own help for its ` +
35
- `flags. This wrapper consumes three flags itself: ${first_party_harness_managed_1.SKRR_AGENT_FLAG}, ` +
35
+ `flags. This wrapper consumes three flags itself: ${first_party_harness_managed_1.SKRR_AGENT_FLAG} (choose the agent for inference billing), ` +
36
36
  `${first_party_harness_project_trust_1.TRUST_PROJECT_FLAG} (load this project's own configuration — plugins, tools, MCP ` +
37
37
  `servers, permissions — which is otherwise NOT loaded until you trust the project; ` +
38
38
  `the TUI asks once when a project ships any), and ${first_party_harness_project_trust_1.ENGINE_PERMISSIONS_FLAG} (let your ` +
@@ -62,7 +62,7 @@ class Code extends core_1.Command {
62
62
  //
63
63
  // The unit tests did not catch it because they cover `buildEngineArgs`, which
64
64
  // always forwarded verbatim. The args never reached it.
65
- await forwardToEngine(this, null, this.argv, { managed: true, projectPolicy: 'tui' });
65
+ await forwardToEngine(this, null, this.argv, { brokerInference: true, projectPolicy: 'tui' });
66
66
  }
67
67
  }
68
68
  exports.default = Code;
@@ -78,13 +78,8 @@ exports.default = Code;
78
78
  * engine is not installed, and `77`, the account was refused before the engine
79
79
  * could start (OSK-8822).
80
80
  *
81
- * ── Why `managed` is opt-IN per command ────────────────────────────────────
82
- *
83
- * `skrr code acp` must NOT take the managed path: the daemon that drives it already
84
- * brokers inference, and a second broker would double-wrap the relay. Opting in
85
- * per command rather than defaulting on means a future `skrr code <something>` can
86
- * only acquire a lease if someone decided it should — the failure mode of the
87
- * other arrangement is a new subcommand silently spending money.
81
+ * The standalone TUI and headless engine acquire inference leases for the local
82
+ * process. The daemon's ACP launch already has its own broker and execution authority.
88
83
  */
89
84
  async function forwardToEngine(cmd, subcommand, passthrough, options = {}) {
90
85
  // Unconditional: the engine must never see a flag it does not declare, whether
@@ -98,9 +93,8 @@ async function forwardToEngine(cmd, subcommand, passthrough, options = {}) {
98
93
  if (subcommand === null && options.projectPolicy === 'tui') {
99
94
  await (0, first_party_harness_startup_update_1.maybeOfferCodeUpdate)({ argv: engineArgv, say });
100
95
  }
101
- if (agentRef && !options.managed) {
102
- say(`${first_party_harness_managed_1.SKRR_AGENT_FLAG} has no effect here — this command does not host a managed ` +
103
- 'session. It was removed from the arguments passed to the engine.');
96
+ if (agentRef && !options.brokerInference) {
97
+ say(`${first_party_harness_managed_1.SKRR_AGENT_FLAG} has no effect here. The launcher supplies this command's inference configuration.`);
104
98
  }
105
99
  // OSK-11958 — the project's own configuration can run code on this machine
106
100
  // and loosen permissions, so it is not loaded until the person trusts the
@@ -127,9 +121,9 @@ async function forwardToEngine(cmd, subcommand, passthrough, options = {}) {
127
121
  say(notice);
128
122
  // Code forwards engine flags verbatim and does not extend BaseCommand. Resolve
129
123
  // the same env or locked profile before the broker reads the saved credential.
130
- if (options.managed)
124
+ if (options.brokerInference)
131
125
  (0, keychain_1.selectActiveProfile)(null);
132
- const managed = options.managed
126
+ const inference = options.brokerInference
133
127
  ? (0, first_party_harness_broker_1.createManagedEngineHooks)({
134
128
  subcommand,
135
129
  passthrough: engineArgv,
@@ -138,15 +132,15 @@ async function forwardToEngine(cmd, subcommand, passthrough, options = {}) {
138
132
  })
139
133
  : null;
140
134
  try {
141
- const code = await (0, first_party_harness_1.execEngine)((0, first_party_harness_1.buildEngineArgs)(subcommand, engineArgv), process.env, managed
135
+ const code = await (0, first_party_harness_1.execEngine)((0, first_party_harness_1.buildEngineArgs)(subcommand, engineArgv), process.env, inference
142
136
  ? {
143
- prepare: managed.prepare,
144
- cleanup: managed.cleanup,
145
- finalizeArgs: managed.finalizeArgs,
137
+ prepare: inference.prepare,
138
+ cleanup: inference.cleanup,
139
+ finalizeArgs: inference.finalizeArgs,
146
140
  // Not `() => true`: this command only ATTEMPTS acquisition, and a
147
141
  // skipped or failed attempt is a genuine BYOK run whose credential is
148
142
  // the ambient one. Only the hooks know which happened.
149
- credentialMode: managed.credentialMode,
143
+ credentialMode: inference.credentialMode,
150
144
  policyEnv: policy?.env,
151
145
  }
152
146
  : { policyEnv: policy?.env });
@@ -156,8 +150,8 @@ async function forwardToEngine(cmd, subcommand, passthrough, options = {}) {
156
150
  // the user can act on. The prepare-time warning already diagnosed this;
157
151
  // say it again where the failure lands, because a warning scrolled past
158
152
  // is not a diagnosis at the point of failure (OSK-11949).
159
- if (managed?.unprovisionedByok()) {
160
- say('No managed session and no provider credential reached the engine — if ' +
153
+ if (inference?.unprovisionedByok()) {
154
+ say('The engine started without an inference lease or a provider credential. If ' +
161
155
  'the failure above is an authentication or server error, sign in with ' +
162
156
  '`skrr login` or set OPENROUTER_API_KEY and retry.');
163
157
  }
@@ -1,16 +1,6 @@
1
1
  import { BaseCommand } from '../../../base-command';
2
2
  /**
3
- * `skrr code jobs approve` — land the pull request a job opened.
4
- *
5
- * OSK-7789 listed six verbs on `/api/cloud-coding` and one CLI binding. Four of
6
- * the missing five are now bound; this is the last, and it is the one that
7
- * FINISHES the work. Without it a headless operator could start a job, watch
8
- * it, and stop it — and still had to open a browser to get the result merged,
9
- * which is the same shape as the create-only path the finding was about.
10
- *
11
- * Only a repository-backed job has a pull request. `code jobs run` is bare
12
- * compute with no repo, so there is nothing here to approve, and the refusal
13
- * says which command produces one rather than reporting a bare 4xx.
3
+ * Approve opening the pull request for a repository-backed job awaiting review.
14
4
  */
15
5
  export default class CodeJobsApprove extends BaseCommand {
16
6
  static description: string;
@@ -4,20 +4,10 @@ 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
  /**
7
- * `skrr code jobs approve` — land the pull request a job opened.
8
- *
9
- * OSK-7789 listed six verbs on `/api/cloud-coding` and one CLI binding. Four of
10
- * the missing five are now bound; this is the last, and it is the one that
11
- * FINISHES the work. Without it a headless operator could start a job, watch
12
- * it, and stop it — and still had to open a browser to get the result merged,
13
- * which is the same shape as the create-only path the finding was about.
14
- *
15
- * Only a repository-backed job has a pull request. `code jobs run` is bare
16
- * compute with no repo, so there is nothing here to approve, and the refusal
17
- * says which command produces one rather than reporting a bare 4xx.
7
+ * Approve opening the pull request for a repository-backed job awaiting review.
18
8
  */
19
9
  class CodeJobsApprove extends base_command_1.BaseCommand {
20
- static description = 'Approve and merge the pull request a Hosted Job Machine job opened';
10
+ static description = 'Approve opening the pull request for a Hosted Job Machine job';
21
11
  static examples = [
22
12
  '<%= config.bin %> code jobs approve <job-id>',
23
13
  '<%= config.bin %> code jobs approve <job-id> --json',
@@ -41,9 +31,7 @@ class CodeJobsApprove extends base_command_1.BaseCommand {
41
31
  this.log(JSON.stringify(task, null, 2));
42
32
  return;
43
33
  }
44
- // The SERVER's status, never the one we asked for — approving races a
45
- // branch someone merged by hand, and printing an outcome we did not observe
46
- // is how a CLI starts inventing them.
34
+ // Approval and GitHub delivery can settle separately.
47
35
  this.log(`Job ${task?.id ?? args.job} is now ${task?.status ?? 'unknown'}.`);
48
36
  if (task?.prUrl)
49
37
  this.log(` ${String(task.prUrl)}`);
@@ -3,8 +3,9 @@ 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 hosted_job_status_1 = require("../../../lib/hosted-job-status");
6
7
  class CodeJobsCancel extends base_command_1.BaseCommand {
7
- static description = 'Stop a Hosted Job Machine job, and its billing';
8
+ static description = 'Request a stop for a Hosted Job Machine job';
8
9
  static examples = [
9
10
  '<%= config.bin %> code jobs cancel <job-id>',
10
11
  '<%= config.bin %> code jobs cancel <job-id> --json',
@@ -31,7 +32,7 @@ class CodeJobsCancel extends base_command_1.BaseCommand {
31
32
  // Report the status the SERVER came back with, never the one we asked for.
32
33
  // Cancel races a job that is already finishing, and printing "cancelled"
33
34
  // over a `completed` row would be the CLI inventing an outcome.
34
- this.log(`Job ${task?.id ?? args.job} is now ${task?.status ?? 'unknown'}.`);
35
+ this.log(`Job ${task?.id ?? args.job} is now ${(0, hosted_job_status_1.hostedJobDisplayStatus)(task) ?? 'unknown'}.`);
35
36
  if (task?.prUrl)
36
37
  this.log(` ${String(task.prUrl)}`);
37
38
  }
@@ -29,7 +29,7 @@ class CodeJobs extends core_1.Command {
29
29
  this.log(' skrr code jobs list list your jobs, newest first');
30
30
  this.log(' skrr code jobs show show one job and its timeline');
31
31
  this.log(' skrr code jobs cancel stop a job and its billing');
32
- this.log(' skrr code jobs approve land the pull request a repo job opened');
32
+ this.log(' skrr code jobs approve approve opening the pull request for a repo job');
33
33
  this.log('');
34
34
  this.log('`run` needs no repository. For a job that clones a repo and opens a');
35
35
  this.log('pull request, use `skrr code handover`.');
@@ -5,8 +5,7 @@ const core_1 = require("@oclif/core");
5
5
  const data_provider_1 = require("@skrr-ai/data-provider");
6
6
  const base_command_1 = require("../../../base-command");
7
7
  const format_1 = require("../../../lib/format");
8
- /** Terminal states — a job here is no longer holding a machine or billing. */
9
- const TERMINAL = new Set(['completed', 'failed', 'cancelled', 'timed_out']);
8
+ const hosted_job_status_1 = require("../../../lib/hosted-job-status");
10
9
  /** Cents are the server's unit for money everywhere else; jobs report dollars. */
11
10
  function costCell(task) {
12
11
  const raw = task.costUsd;
@@ -26,12 +25,8 @@ class CodeJobsList extends base_command_1.BaseCommand {
26
25
  status: core_1.Flags.string({
27
26
  description: 'Filter by one exact status (e.g. running, failed, completed)',
28
27
  }),
29
- // The question an operator actually opens this with is "what is costing me
30
- // money right now", and the server has no such filter -- it takes one exact
31
- // status. Filtering client-side is honest here because the page is already
32
- // bounded by --limit.
33
28
  active: core_1.Flags.boolean({
34
- description: 'Show only jobs that are still running (and still billing)',
29
+ description: 'Show in-progress jobs in the returned page',
35
30
  default: false,
36
31
  exclusive: ['status'],
37
32
  }),
@@ -55,17 +50,15 @@ class CodeJobsList extends base_command_1.BaseCommand {
55
50
  this.handleApiError(err);
56
51
  }
57
52
  if (flags.active) {
58
- tasks = tasks.filter((t) => !TERMINAL.has(String(t.status)));
53
+ tasks = tasks.filter((task) => (0, hosted_job_status_1.isHostedJobInProgress)(task.status));
59
54
  }
60
55
  if (flags.json) {
61
56
  this.printJsonResult((0, list_output_1.listResult)({ ...response, data: tasks }));
62
57
  return;
63
58
  }
64
59
  if (tasks.length === 0) {
65
- // Say what empty MEANS. With --active it is the reassuring answer, not an
66
- // empty query: nothing is running, so nothing is being billed.
67
60
  this.log(flags.active
68
- ? 'No jobs running — nothing is holding a Hosted Job Machine, and nothing is accruing.'
61
+ ? 'No in-progress jobs in the returned page.'
69
62
  : 'No jobs. Start one with `skrr code jobs run`, or `skrr code handover`\n' +
70
63
  'for a job that clones a repository and opens a pull request.');
71
64
  return;
@@ -6,6 +6,7 @@ const node_crypto_1 = require("node:crypto");
6
6
  const data_provider_1 = require("@skrr-ai/data-provider");
7
7
  const base_command_1 = require("../../../base-command");
8
8
  const code_handover_1 = require("../../../lib/code-handover");
9
+ const hosted_job_status_1 = require("../../../lib/hosted-job-status");
9
10
  const TERMINAL = new Set(['completed', 'failed', 'cancelled', 'timed_out']);
10
11
  /**
11
12
  * `skrr code jobs run` — one-shot managed compute with no repository.
@@ -114,7 +115,7 @@ class CodeJobsRun extends base_command_1.BaseCommand {
114
115
  }
115
116
  const deadline = Date.now() + flags.timeout * 60_000;
116
117
  let current = task;
117
- while (!TERMINAL.has(String(current?.status)) && Date.now() < deadline) {
118
+ while (!TERMINAL.has((0, hosted_job_status_1.hostedJobDisplayStatus)(current) ?? '') && Date.now() < deadline) {
118
119
  await this.sleep(Math.max(1, flags.interval) * 1000);
119
120
  try {
120
121
  current = (await data_provider_1.dataService.getCloudCodingTask(jobId))?.task;
@@ -127,15 +128,20 @@ class CodeJobsRun extends base_command_1.BaseCommand {
127
128
  this.log(JSON.stringify(current, null, 2));
128
129
  return;
129
130
  }
130
- if (!TERMINAL.has(String(current?.status))) {
131
- // A timed-out WAIT is not a timed-out job. The job is still running and
132
- // still billing, so say which of the two happened and how to stop it.
133
- this.log(`Still ${current?.status ?? 'running'} after ${flags.timeout}m — the job continues.`);
131
+ const status = (0, hosted_job_status_1.hostedJobDisplayStatus)(current);
132
+ if (!TERMINAL.has(status ?? '')) {
133
+ if (status === 'stop_requested') {
134
+ this.log(`Stop requested for Job ${jobId}. Confirmation is still pending.`);
135
+ }
136
+ else {
137
+ this.log(`Still ${status ?? 'running'} after ${flags.timeout}m — the job continues.`);
138
+ }
134
139
  this.log(` ${this.config.bin} code jobs show ${jobId}`);
135
- this.log(` ${this.config.bin} code jobs cancel ${jobId}`);
140
+ if (status !== 'stop_requested')
141
+ this.log(` ${this.config.bin} code jobs cancel ${jobId}`);
136
142
  return;
137
143
  }
138
- this.log(`Job ${jobId} ${current?.status}`);
144
+ this.log(`Job ${jobId} ${status}`);
139
145
  const result = current?.result;
140
146
  if (result?.text) {
141
147
  this.log('');