@skrr-ai/cli 0.1.206 → 0.1.208

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 (155) hide show
  1. package/dist/commands/agent/message/resolve.d.ts +31 -0
  2. package/dist/commands/agent/message/resolve.js +111 -0
  3. package/dist/commands/agent/message/send.d.ts +17 -5
  4. package/dist/commands/agent/message/send.js +77 -26
  5. package/dist/commands/agent/request/list.d.ts +15 -0
  6. package/dist/commands/agent/request/list.js +82 -0
  7. package/dist/commands/agent/request/send.d.ts +18 -0
  8. package/dist/commands/agent/request/send.js +56 -0
  9. package/dist/commands/agents/access/approve.d.ts +17 -0
  10. package/dist/commands/agents/access/approve.js +94 -0
  11. package/dist/commands/agents/access/deny.d.ts +10 -0
  12. package/dist/commands/agents/access/deny.js +36 -0
  13. package/dist/commands/agents/access/list.d.ts +10 -0
  14. package/dist/commands/agents/access/list.js +53 -0
  15. package/dist/commands/agents/access/reach.d.ts +13 -0
  16. package/dist/commands/agents/access/reach.js +53 -0
  17. package/dist/commands/agents/access/revoke.d.ts +13 -0
  18. package/dist/commands/agents/access/revoke.js +50 -0
  19. package/dist/commands/agents/import.d.ts +15 -1
  20. package/dist/commands/agents/import.js +211 -23
  21. package/dist/commands/agents/intuitions/accept.d.ts +0 -1
  22. package/dist/commands/agents/intuitions/accept.js +22 -7
  23. package/dist/commands/agents/intuitions/generate.d.ts +0 -1
  24. package/dist/commands/agents/intuitions/generate.js +4 -16
  25. package/dist/commands/agents/intuitions/list.js +9 -3
  26. package/dist/commands/agents/intuitions/resume.d.ts +11 -0
  27. package/dist/commands/agents/intuitions/resume.js +37 -0
  28. package/dist/commands/agents/models.d.ts +11 -0
  29. package/dist/commands/agents/models.js +51 -0
  30. package/dist/commands/agents/shared-memory.d.ts +24 -0
  31. package/dist/commands/agents/shared-memory.js +67 -0
  32. package/dist/commands/agents/visibility.d.ts +1 -0
  33. package/dist/commands/agents/visibility.js +14 -0
  34. package/dist/commands/balance/route-premiums.d.ts +9 -0
  35. package/dist/commands/balance/route-premiums.js +33 -0
  36. package/dist/commands/code/migrate.js +3 -1
  37. package/dist/commands/convos/transcript.d.ts +0 -1
  38. package/dist/commands/convos/transcript.js +0 -1
  39. package/dist/commands/duties/advance-next.js +15 -6
  40. package/dist/commands/followups/show.js +9 -0
  41. package/dist/commands/followups/watch-pr.d.ts +27 -0
  42. package/dist/commands/followups/watch-pr.js +123 -0
  43. package/dist/commands/goals/create.d.ts +1 -0
  44. package/dist/commands/goals/create.js +8 -0
  45. package/dist/commands/goals/creation-receipt.d.ts +10 -0
  46. package/dist/commands/goals/creation-receipt.js +43 -0
  47. package/dist/commands/goals/key-results/create.d.ts +2 -0
  48. package/dist/commands/goals/key-results/create.js +14 -0
  49. package/dist/commands/goals/key-results/creation-receipt.d.ts +13 -0
  50. package/dist/commands/goals/key-results/creation-receipt.js +51 -0
  51. package/dist/commands/harnesses/forget.d.ts +2 -0
  52. package/dist/commands/harnesses/forget.js +31 -0
  53. package/dist/commands/harnesses/removal-receipt.d.ts +11 -0
  54. package/dist/commands/harnesses/removal-receipt.js +32 -0
  55. package/dist/commands/harnesses/removal-review.d.ts +11 -0
  56. package/dist/commands/harnesses/removal-review.js +28 -0
  57. package/dist/commands/memory/consolidation/index.d.ts +20 -0
  58. package/dist/commands/memory/consolidation/index.js +78 -0
  59. package/dist/commands/memory/consolidation/resume.d.ts +14 -0
  60. package/dist/commands/memory/consolidation/resume.js +46 -0
  61. package/dist/commands/memory/consolidation/undo.d.ts +18 -0
  62. package/dist/commands/memory/consolidation/undo.js +60 -0
  63. package/dist/commands/slack/mutes.d.ts +10 -0
  64. package/dist/commands/slack/mutes.js +62 -0
  65. package/dist/commands/slack/unmute.d.ts +12 -0
  66. package/dist/commands/slack/unmute.js +44 -0
  67. package/dist/commands/spaces/loops/release-receipt.d.ts +14 -0
  68. package/dist/commands/spaces/loops/release-receipt.js +48 -0
  69. package/dist/commands/spaces/loops/release.js +1 -1
  70. package/dist/commands/spaces/workflow-templates/archive.d.ts +1 -0
  71. package/dist/commands/spaces/workflow-templates/archive.js +9 -1
  72. package/dist/commands/spaces/workflow-templates/show.js +2 -0
  73. package/dist/commands/spaces/workflow-templates/update.d.ts +1 -0
  74. package/dist/commands/spaces/workflow-templates/update.js +12 -1
  75. package/dist/commands/spaces/workflows/publish.d.ts +1 -0
  76. package/dist/commands/spaces/workflows/publish.js +41 -2
  77. package/dist/commands/tasks/actionability.js +9 -0
  78. package/dist/commands/tasks/ask.d.ts +50 -0
  79. package/dist/commands/tasks/ask.js +190 -0
  80. package/dist/commands/tasks/create.d.ts +2 -0
  81. package/dist/commands/tasks/create.js +19 -6
  82. package/dist/commands/tasks/creation-receipt.d.ts +12 -0
  83. package/dist/commands/tasks/creation-receipt.js +53 -0
  84. package/dist/commands/tasks/delete.d.ts +1 -0
  85. package/dist/commands/tasks/delete.js +22 -4
  86. package/dist/commands/tasks/deletion-receipt.d.ts +12 -0
  87. package/dist/commands/tasks/deletion-receipt.js +37 -0
  88. package/dist/commands/tasks/handover.js +14 -0
  89. package/dist/commands/tasks/input/answer.js +8 -2
  90. package/dist/commands/tasks/input/show.d.ts +26 -0
  91. package/dist/commands/tasks/input/show.js +185 -17
  92. package/dist/commands/tasks/move.d.ts +11 -0
  93. package/dist/commands/tasks/move.js +82 -1
  94. package/dist/commands/tasks/result/submit.js +3 -0
  95. package/dist/commands/tasks/runs.d.ts +4 -1
  96. package/dist/commands/tasks/runs.js +22 -3
  97. package/dist/commands/tasks/show.js +22 -1
  98. package/dist/commands/tasks/update.d.ts +1 -0
  99. package/dist/commands/tasks/update.js +52 -1
  100. package/dist/commands/tasks/updates/add.js +3 -0
  101. package/dist/commands/tasks/wait.d.ts +20 -0
  102. package/dist/commands/tasks/wait.js +102 -1
  103. package/dist/generated/agent-guides.json +501 -92
  104. package/dist/generated/managed-instruction-guides.json +1 -1
  105. package/dist/lib/agent-access-command.d.ts +19 -0
  106. package/dist/lib/agent-access-command.js +44 -0
  107. package/dist/lib/agent-access.d.ts +18 -0
  108. package/dist/lib/agent-access.js +48 -0
  109. package/dist/lib/agent-import/apply.d.ts +50 -0
  110. package/dist/lib/agent-import/apply.js +85 -0
  111. package/dist/lib/agent-import/plan.d.ts +132 -0
  112. package/dist/lib/agent-import/plan.js +504 -0
  113. package/dist/lib/agent-import/reader.d.ts +94 -0
  114. package/dist/lib/agent-import/reader.js +326 -0
  115. package/dist/lib/agent-import/schedule.d.ts +46 -0
  116. package/dist/lib/agent-import/schedule.js +220 -0
  117. package/dist/lib/agent-import/sources.d.ts +124 -0
  118. package/dist/lib/agent-import/sources.js +797 -0
  119. package/dist/lib/execution-target.d.ts +1 -1
  120. package/dist/lib/execution-target.js +4 -0
  121. package/dist/lib/followups.d.ts +61 -0
  122. package/dist/lib/followups.js +39 -0
  123. package/dist/lib/handover-interview.d.ts +18 -0
  124. package/dist/lib/handover-interview.js +53 -0
  125. package/dist/lib/harnesses.d.ts +25 -0
  126. package/dist/lib/harnesses.js +15 -0
  127. package/dist/lib/input-queue.js +2 -1
  128. package/dist/lib/intuition-look.d.ts +10 -0
  129. package/dist/lib/intuition-look.js +64 -0
  130. package/dist/lib/record-output.d.ts +1 -1
  131. package/dist/lib/record-output.js +2 -0
  132. package/dist/lib/request-uuid.d.ts +2 -0
  133. package/dist/lib/request-uuid.js +10 -0
  134. package/dist/lib/skill-import.d.ts +19 -0
  135. package/dist/lib/skill-import.js +34 -0
  136. package/dist/lib/slack-thread-mutes.d.ts +25 -0
  137. package/dist/lib/slack-thread-mutes.js +12 -0
  138. package/dist/lib/task-carriers.d.ts +18 -0
  139. package/dist/lib/task-carriers.js +43 -0
  140. package/dist/lib/task-extras.d.ts +5 -0
  141. package/dist/lib/task-extras.js +5 -0
  142. package/dist/lib/task-recurrence-summary.d.ts +15 -0
  143. package/dist/lib/task-recurrence-summary.js +22 -0
  144. package/dist/lib/task-version.d.ts +44 -0
  145. package/dist/lib/task-version.js +73 -0
  146. package/dist/lib/task-write-attribution.d.ts +7 -0
  147. package/dist/lib/task-write-attribution.js +14 -0
  148. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/turnPacing.d.ts +75 -0
  149. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/turnPacing.js +124 -0
  150. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/turnPacing.d.ts +75 -0
  151. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/turnPacing.js +141 -0
  152. package/dist/node_modules/@skrr-ai/auth-core/package.json +10 -0
  153. package/dist/node_modules/@skrr-ai/data-provider/index.js +13350 -12579
  154. package/oclif.manifest.json +3044 -563
  155. package/package.json +5 -2
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.unowedReviewNotice = unowedReviewNotice;
3
4
  const core_1 = require("@oclif/core");
4
5
  const data_provider_1 = require("@skrr-ai/data-provider");
5
6
  const api_fetch_1 = require("../../lib/api-fetch");
@@ -8,10 +9,27 @@ const workflow_state_hint_1 = require("../../lib/workflow-state-hint");
8
9
  const unsupported_managed_task_write_1 = require("../../lib/unsupported-managed-task-write");
9
10
  const session_task_write_1 = require("../../lib/session-task-write");
10
11
  const base_command_1 = require("../../base-command");
12
+ const task_version_1 = require("../../lib/task-version");
11
13
  const task_closure_1 = require("../../lib/task-closure");
12
14
  const web_url_1 = require("../../lib/web-url");
13
15
  const task_resolver_1 = require("../../lib/task-resolver");
14
16
  const projects_1 = require("../../lib/projects");
17
+ /**
18
+ * The notice for a Task moved into review that no Review is owed for.
19
+ *
20
+ * Review is where a Review the Task's own `reviewPolicy` requires is waited
21
+ * for. Under `none` (the default) nobody owes one, so a Task parked there
22
+ * waits on a person who was never asked: thousands sat in review that way
23
+ * (OSK-33196). The move still lands; this says what it means, at the moment
24
+ * an agent made it.
25
+ */
26
+ function unowedReviewNotice(task, bin) {
27
+ const t = (task ?? {});
28
+ if (t.statusType !== 'review' || t.reviewPolicy === 'required')
29
+ return null;
30
+ return ('Nobody owes this Task a Review: its reviewPolicy is not `required`, so it waits in review ' +
31
+ `for a person who was never asked. Close finished work with \`${bin} tasks complete\`.`);
32
+ }
15
33
  /**
16
34
  * `tasks move` is the documented way to change a task's status. The data
17
35
  * provider's `TaskUpdateParams` (used by `tasks update`) does not expose a
@@ -32,6 +50,7 @@ class TasksMove extends base_command_1.BaseCommand {
32
50
  '<%= config.bin %> tasks move <task-id> --status cancelled --json',
33
51
  '<%= config.bin %> tasks move <task-id> --project <project-id>',
34
52
  '<%= config.bin %> tasks move <task-id> --project none',
53
+ '<%= config.bin %> tasks move <task-id> --status done --expected-version 4',
35
54
  ];
36
55
  static args = {
37
56
  id: core_1.Args.string({
@@ -59,6 +78,10 @@ class TasksMove extends base_command_1.BaseCommand {
59
78
  force: core_1.Flags.boolean({
60
79
  description: "Close past an owner-declared required Review as a non-owner; the override is recorded on the task's resolution",
61
80
  }),
81
+ 'expected-version': core_1.Flags.integer({
82
+ min: 0,
83
+ description: task_version_1.EXPECTED_VERSION_FLAG_HELP,
84
+ }),
62
85
  };
63
86
  async run() {
64
87
  this.requireAuth();
@@ -97,6 +120,19 @@ class TasksMove extends base_command_1.BaseCommand {
97
120
  retryable: false,
98
121
  });
99
122
  }
123
+ const expectedVersion = flags['expected-version'];
124
+ // The fence covers the status move. A project change is a second write
125
+ // that the version-checked path cannot carry, and fencing half of one
126
+ // command would leave the other half unchecked without saying so.
127
+ if (expectedVersion !== undefined && projectId !== undefined) {
128
+ this.failWithCliError({
129
+ message: '--expected-version checks a status move, not a project change. Move the status with ' +
130
+ '--expected-version, then change the project in its own `tasks move --project` command.',
131
+ code: task_version_1.TASK_VERSION_FENCE_UNSUPPORTED,
132
+ exit: 2,
133
+ retryable: false,
134
+ });
135
+ }
100
136
  if (typeof projectId === 'string') {
101
137
  const placement = { projectId };
102
138
  await this.resolveTaskResourceReferences(placement, { taskId: taskRef });
@@ -106,6 +142,9 @@ class TasksMove extends base_command_1.BaseCommand {
106
142
  // server validates and applies these optional hold details after resolving
107
143
  // the state; a client must not guess from a display name.
108
144
  let updated;
145
+ // The server's tip when the move parked the Task with nothing to bring it back (REST answers it
146
+ // on the task as `_carrierGuidance`, the session door beside it as `carrierGuidance`).
147
+ let carrierGuidance;
109
148
  try {
110
149
  if (flags.status) {
111
150
  const sessionWrite = await (0, session_task_write_1.sessionTaskWrite)('move', taskRef);
@@ -118,9 +157,11 @@ class TasksMove extends base_command_1.BaseCommand {
118
157
  ...(flags.reason ? { reason: flags.reason } : {}),
119
158
  ...(flags['resolution-actor'] ? { resolutionActor: flags['resolution-actor'] } : {}),
120
159
  ...(flags.force ? { force: true } : {}),
160
+ ...(expectedVersion !== undefined ? { expectedVersion } : {}),
121
161
  },
122
162
  }));
123
163
  updated = res.task;
164
+ carrierGuidance = res.carrierGuidance;
124
165
  }
125
166
  else {
126
167
  updated = await data_provider_1.dataService.moveTask({
@@ -129,7 +170,10 @@ class TasksMove extends base_command_1.BaseCommand {
129
170
  reason: flags.reason,
130
171
  resolutionActor: flags['resolution-actor'],
131
172
  force: flags.force === true ? true : undefined,
173
+ expectedVersion,
132
174
  });
175
+ carrierGuidance = updated
176
+ ?._carrierGuidance;
133
177
  }
134
178
  // Held for approval by the Space write policy: nothing moved, and the
135
179
  // project change below is not sent on top of a held move.
@@ -148,6 +192,27 @@ class TasksMove extends base_command_1.BaseCommand {
148
192
  }
149
193
  }
150
194
  catch (err) {
195
+ const conflict = (0, task_version_1.taskVersionConflictOf)(err);
196
+ if (conflict) {
197
+ this.failWithCliError({
198
+ message: (0, task_version_1.describeTaskVersionConflict)({
199
+ // What the person typed, so the command they are told to run is
200
+ // the one they would have written.
201
+ taskRef: taskIdentity.id,
202
+ expectedVersion: conflict.expectedVersion ?? expectedVersion,
203
+ currentVersion: conflict.currentVersion,
204
+ bin: this.config.bin,
205
+ }),
206
+ code: task_version_1.TASK_VERSION_CONFLICT_CODE,
207
+ status: 409,
208
+ exit: 1,
209
+ retryable: false,
210
+ details: {
211
+ expectedVersion: conflict.expectedVersion ?? expectedVersion,
212
+ currentVersion: conflict.currentVersion,
213
+ },
214
+ });
215
+ }
151
216
  const unknownState = (0, workflow_state_hint_1.describeUnknownWorkflowState)((0, http_error_1.httpBodyOf)(err), this.config.bin);
152
217
  if (unknownState) {
153
218
  this.failWithCliError({
@@ -159,8 +224,15 @@ class TasksMove extends base_command_1.BaseCommand {
159
224
  }
160
225
  this.handleApiError(err);
161
226
  }
227
+ const reviewNotice = flags.status ? unowedReviewNotice(updated, this.config.bin) : null;
162
228
  if (flags.json) {
163
- this.printJsonOperation((0, web_url_1.withTaskUrl)(this.cliConfig.baseURL, updated), {
229
+ // stderr, so the JSON on stdout stays one document.
230
+ if (reviewNotice)
231
+ this.logToStderr(reviewNotice);
232
+ this.printJsonOperation((0, web_url_1.withTaskUrl)(this.cliConfig.baseURL, {
233
+ ...updated,
234
+ ...(carrierGuidance ? { _carrierGuidance: carrierGuidance } : {}),
235
+ }), {
164
236
  resource: { kind: 'task', id: updated?.id },
165
237
  task: { id: updated?.id },
166
238
  });
@@ -198,6 +270,15 @@ class TasksMove extends base_command_1.BaseCommand {
198
270
  for (const sentence of (0, task_closure_1.closureSnapshotLines)(resolutionClosure)) {
199
271
  this.log(` ${sentence}`);
200
272
  }
273
+ if (reviewNotice)
274
+ this.log(` ${reviewNotice}`);
275
+ // Advisory only: the move above committed. Printed so a person or an Agent that parked the Task
276
+ // sees, before it walks away, that nothing will bring it back, and how to arm something that will.
277
+ if (carrierGuidance?.code === 'no_carrier') {
278
+ this.log(` ${carrierGuidance.message}`);
279
+ for (const command of carrierGuidance.commands)
280
+ this.log(` ${command}`);
281
+ }
201
282
  }
202
283
  /**
203
284
  * Name the project the receipt lands in, resolving its title from the task's
@@ -202,6 +202,9 @@ class TasksResultSubmit extends base_command_1.BaseCommand {
202
202
  }, outcome)) {
203
203
  this.log(line);
204
204
  }
205
+ const started = (0, task_write_attribution_1.taskStartedLine)(result, task.id);
206
+ if (started)
207
+ this.log(started);
205
208
  for (const line of (0, task_closure_1.closureReport)(result.closure, { closing: false }))
206
209
  this.log(line);
207
210
  if (url)
@@ -48,7 +48,10 @@ export declare function runNeedsFailureReason(run: Record<string, unknown>): boo
48
48
  * `actedRunId` means the offer was taken and names the
49
49
  * continuation run.
50
50
  *
51
- * Both are absent on a server that predates them, so this returns null and the
51
+ * `handoverInterview` — on a continuation, the previous owner's handover notes
52
+ * or why there are none (§4.8); appended to the marker.
53
+ *
54
+ * All are absent on a server that predates them, so this returns null and the
52
55
  * column below is rendered only when at least one row carries a marker — a
53
56
  * healthy list against an older deployment pays and shows nothing.
54
57
  */
@@ -14,6 +14,7 @@ const auth_core_1 = require("@skrr-ai/auth-core");
14
14
  const data_provider_1 = require("@skrr-ai/data-provider");
15
15
  const base_command_1 = require("../../base-command");
16
16
  const format_1 = require("../../lib/format");
17
+ const handover_interview_1 = require("../../lib/handover-interview");
17
18
  const activity_1 = require("./activity");
18
19
  /**
19
20
  * OSK-4836 — say WHERE a run executed. A named daemon wins over the environment
@@ -60,7 +61,10 @@ function formatRunAttempt(ref) {
60
61
  ? String(attempt.generation)
61
62
  : null;
62
63
  const identity = [kind, runId].filter(Boolean).join(':');
63
- const counters = [number ? `attempt ${number}` : null, generation ? `generation ${generation}` : null]
64
+ const counters = [
65
+ number ? `attempt ${number}` : null,
66
+ generation ? `generation ${generation}` : null,
67
+ ]
64
68
  .filter(Boolean)
65
69
  .join(', ');
66
70
  return [identity || null, counters || null].filter(Boolean).join(' · ') || null;
@@ -139,7 +143,10 @@ function runNeedsFailureReason(run) {
139
143
  * `actedRunId` means the offer was taken and names the
140
144
  * continuation run.
141
145
  *
142
- * Both are absent on a server that predates them, so this returns null and the
146
+ * `handoverInterview` — on a continuation, the previous owner's handover notes
147
+ * or why there are none (§4.8); appended to the marker.
148
+ *
149
+ * All are absent on a server that predates them, so this returns null and the
143
150
  * column below is rendered only when at least one row carries a marker — a
144
151
  * healthy list against an older deployment pays and shows nothing.
145
152
  */
@@ -152,7 +159,8 @@ function runHandoverMarker(run) {
152
159
  typeof from.runId === 'string'
153
160
  ? ` ← ${String(from.runId)}`
154
161
  : '';
155
- return `handover${fromRun}`;
162
+ const interview = (0, handover_interview_1.handoverInterviewMarker)(run.handoverInterview);
163
+ return `handover${fromRun}${interview ? ` · ${interview}` : ''}`;
156
164
  }
157
165
  const offer = run.handoverOffer;
158
166
  if (offer && typeof offer === 'object') {
@@ -308,6 +316,17 @@ class TasksRuns extends base_command_1.BaseCommand {
308
316
  ...(showCleanup ? [{ key: 'cleanup', header: 'CLEANUP', maxWidth: 42 }] : []),
309
317
  ...(showHandover ? [{ key: 'handover', header: 'HANDOVER' }] : []),
310
318
  ], (line) => this.log(line));
319
+ // The previous owner's notes on each continuation, under the table: the column
320
+ // says where each interview stands, this says what the previous agent said.
321
+ for (const run of items) {
322
+ const lines = (0, handover_interview_1.renderHandoverInterview)(run.handoverInterview, { indent: ' ' });
323
+ if (!lines.length)
324
+ continue;
325
+ this.log('');
326
+ this.log(`Handover notes for ${String(run.runId ?? run.id ?? run._id ?? '-')}:`);
327
+ for (const line of lines)
328
+ this.log(line);
329
+ }
311
330
  // Only once something failed: a healthy list pays nothing for this.
312
331
  if (!unexplained)
313
332
  return;
@@ -12,6 +12,7 @@ exports.recurrenceArmFailureLines = recurrenceArmFailureLines;
12
12
  exports.taskFailureLines = taskFailureLines;
13
13
  const core_1 = require("@oclif/core");
14
14
  const data_provider_1 = require("@skrr-ai/data-provider");
15
+ const task_carriers_1 = require("../../lib/task-carriers");
15
16
  const api_fetch_1 = require("../../lib/api-fetch");
16
17
  const session_task_endpoints_1 = require("../../lib/session-task-endpoints");
17
18
  const base_command_1 = require("../../base-command");
@@ -27,6 +28,7 @@ const task_recurrence_outcome_1 = require("../../lib/task-recurrence-outcome");
27
28
  const task_recurrence_summary_1 = require("../../lib/task-recurrence-summary");
28
29
  const task_operations_1 = require("../../lib/task-operations");
29
30
  const record_output_1 = require("../../lib/record-output");
31
+ const task_version_1 = require("../../lib/task-version");
30
32
  /**
31
33
  * Where to look next — as COMMANDS, not as facts about the task.
32
34
  *
@@ -442,7 +444,15 @@ class TasksShow extends base_command_1.BaseCommand {
442
444
  (typeof t.taskNumber === 'number' || typeof t.taskNumber === 'string'
443
445
  ? `#${t.taskNumber}`
444
446
  : undefined);
445
- this.printJsonResult((0, record_output_1.shapeRecordResponse)({ ...t, ...(ref ? { ref } : {}), ...(url ? { url } : {}), completion }, { resource: 'task', fields: flags.fields, compact: flags.compact }));
447
+ this.printJsonResult((0, record_output_1.shapeRecordResponse)({
448
+ ...t,
449
+ ...(ref ? { ref } : {}),
450
+ ...(url ? { url } : {}),
451
+ // Absent means never version-checked, which the server reads as 0, so
452
+ // the value a caller passes back as --expected-version is always here.
453
+ version: (0, task_version_1.taskVersionOf)(t),
454
+ completion,
455
+ }, { resource: 'task', fields: flags.fields, compact: flags.compact }));
446
456
  return;
447
457
  }
448
458
  for (const line of (0, record_output_1.textModeRecordProjectionNotes)(flags))
@@ -475,6 +485,10 @@ class TasksShow extends base_command_1.BaseCommand {
475
485
  if (url)
476
486
  this.log(`URL: ${url}`);
477
487
  this.log(`Status: ${t.status ?? '-'}`);
488
+ // The read a version-checked write is fenced on. Printed with the flag that
489
+ // uses it, because a number on its own does not say what it is for.
490
+ const version = (0, task_version_1.taskVersionOf)(t);
491
+ this.log(`Version: ${version} (update only from this read: --expected-version ${version})`);
478
492
  // Immediately under Status, because "failed" is the row that raises the
479
493
  // question and this is the answer to it.
480
494
  for (const line of taskFailureLines(t, this.config.bin))
@@ -654,6 +668,13 @@ class TasksShow extends base_command_1.BaseCommand {
654
668
  ? 'Workflow: ended · no next executor'
655
669
  : `Next action: ${actionability.nextActor ?? '-'} · ${actionability.state ?? '-'} · ${actionability.reasonCode ?? '-'}`);
656
670
  this.log(`Why: ${actionability.reason ?? '-'}`);
671
+ for (const line of (0, task_carriers_1.taskCarrierLines)(actionability, {
672
+ taskRef: String(t.identifier || t.id || ''),
673
+ bin: this.config.bin,
674
+ width: 13,
675
+ })) {
676
+ this.log(line);
677
+ }
657
678
  for (const line of nextStepLines(t, this.config.bin))
658
679
  this.log(line);
659
680
  await this.printBlockerDetail(t, actionability);
@@ -68,6 +68,7 @@ export default class TasksUpdate extends BaseCommand {
68
68
  'label-id': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
69
69
  'repair-release-pins': import("@oclif/core/interfaces").BooleanFlag<boolean>;
70
70
  'working-directory': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
71
+ 'expected-version': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
71
72
  worktree: import("@oclif/core/interfaces").BooleanFlag<boolean>;
72
73
  };
73
74
  run(): Promise<void>;
@@ -11,6 +11,7 @@ const task_resolver_1 = require("../../lib/task-resolver");
11
11
  const tasks_2 = require("../../lib/tasks");
12
12
  const create_1 = require("./create");
13
13
  const label_ref_1 = require("../../lib/label-ref");
14
+ const task_version_1 = require("../../lib/task-version");
14
15
  class TasksUpdate extends base_command_1.BaseCommand {
15
16
  static description = 'Update an existing task (partial patch). Status and PROJECT changes go through ' +
16
17
  '`tasks move` — see `--goal` / `--space` below.';
@@ -24,6 +25,7 @@ class TasksUpdate extends base_command_1.BaseCommand {
24
25
  '<%= config.bin %> tasks update <task-id> --add-assignee-user "Frank Du"',
25
26
  '<%= config.bin %> tasks update <task-id> --add-blocked-by <blocker-task-id>',
26
27
  '<%= config.bin %> tasks update <task-id> --from-json patch.json',
28
+ '<%= config.bin %> tasks update <task-id> --title "New title" --expected-version 4',
27
29
  ];
28
30
  static args = {
29
31
  id: core_1.Args.string({
@@ -212,6 +214,10 @@ class TasksUpdate extends base_command_1.BaseCommand {
212
214
  'the daemon\'s filesystem. Overrides the agent\'s default. Pass "none" to ' +
213
215
  'clear back to inheriting the agent default.',
214
216
  }),
217
+ 'expected-version': core_1.Flags.integer({
218
+ min: 0,
219
+ description: task_version_1.EXPECTED_VERSION_FLAG_HELP,
220
+ }),
215
221
  worktree: core_1.Flags.boolean({
216
222
  allowNo: true,
217
223
  description: "Isolate this task's autonomous runs in a git worktree (--worktree) or force " +
@@ -462,6 +468,10 @@ class TasksUpdate extends base_command_1.BaseCommand {
462
468
  // A mutation option, not a field — `undefined` unless explicitly asked
463
469
  // for, so it never counts toward the "nothing to update" check below.
464
470
  repairReleasePins: flags['repair-release-pins'] ? true : undefined,
471
+ // The version fence. A number here (from the flag or --from-json) sends
472
+ // the update down the server's optimistic-lock path, which is checked
473
+ // below for what it can carry.
474
+ expectedVersion: flags['expected-version'],
465
475
  });
466
476
  (0, tasks_2.applyExplicitTaskUnassignment)(payload, flags.unassigned === true);
467
477
  const payloadKeys = Object.keys(payload);
@@ -502,6 +512,26 @@ class TasksUpdate extends base_command_1.BaseCommand {
502
512
  retryable: false,
503
513
  });
504
514
  }
515
+ const expectedVersion = typeof payload.expectedVersion === 'number' ? payload.expectedVersion : undefined;
516
+ if (expectedVersion !== undefined) {
517
+ if (Object.keys(payload).every((key) => key === 'expectedVersion')) {
518
+ this.failWithCliError({
519
+ message: 'Nothing to update. Pass at least one flag (e.g. --title) or --from-json.',
520
+ code: 'EMPTY_TASK_UPDATE',
521
+ exit: 1,
522
+ retryable: false,
523
+ });
524
+ }
525
+ const fenceRefusal = (0, task_version_1.taskVersionFenceRefusal)(payload);
526
+ if (fenceRefusal) {
527
+ this.failWithCliError({
528
+ message: fenceRefusal,
529
+ code: task_version_1.TASK_VERSION_FENCE_UNSUPPORTED,
530
+ exit: 2,
531
+ retryable: false,
532
+ });
533
+ }
534
+ }
505
535
  // Names/emails resolve against the space the task will be in AFTER this
506
536
  // update (`payload.spaceId` when the update also moves it), falling back
507
537
  // to the task's current space. Fetching the task is skipped entirely when
@@ -529,6 +559,27 @@ class TasksUpdate extends base_command_1.BaseCommand {
529
559
  });
530
560
  }
531
561
  catch (err) {
562
+ const conflict = (0, task_version_1.taskVersionConflictOf)(err);
563
+ if (conflict) {
564
+ this.failWithCliError({
565
+ message: (0, task_version_1.describeTaskVersionConflict)({
566
+ // What the person typed, so the command they are told to run is
567
+ // the one they would have written.
568
+ taskRef: taskIdentity.id,
569
+ expectedVersion: conflict.expectedVersion ?? expectedVersion,
570
+ currentVersion: conflict.currentVersion,
571
+ bin: this.config.bin,
572
+ }),
573
+ code: task_version_1.TASK_VERSION_CONFLICT_CODE,
574
+ status: 409,
575
+ exit: 1,
576
+ retryable: false,
577
+ details: {
578
+ expectedVersion: conflict.expectedVersion ?? expectedVersion,
579
+ currentVersion: conflict.currentVersion,
580
+ },
581
+ });
582
+ }
532
583
  // The server's refusal says "detach the goal with goalId: null", which is
533
584
  // not something a CLI user can type. Name the id sent and `--goal none`.
534
585
  const goalId = payload.goalId;
@@ -570,7 +621,7 @@ class TasksUpdate extends base_command_1.BaseCommand {
570
621
  const label = `${t.id ?? t._id ?? taskRef}${ref ? ` (${ref})` : ''}`;
571
622
  // The server's own answer about the estimate (OSK-16476): a no-op says so, never "Updated".
572
623
  const unchanged = (0, task_economics_1.estimateUnchangedLine)(payload.economics, t);
573
- const onlyEstimate = payloadKeys.every((key) => key === 'economics' || payload[key] === undefined);
624
+ const onlyEstimate = payloadKeys.every((key) => key === 'economics' || key === 'expectedVersion' || payload[key] === undefined);
574
625
  if (unchanged && onlyEstimate) {
575
626
  this.log(`Task ${label}: ${unchanged}`);
576
627
  return;
@@ -218,6 +218,9 @@ class TasksUpdatesAdd extends base_command_1.BaseCommand {
218
218
  }, outcome)) {
219
219
  this.log(line);
220
220
  }
221
+ const started = (0, task_write_attribution_1.taskStartedLine)(result, task.id);
222
+ if (started)
223
+ this.log(started);
221
224
  }
222
225
  }
223
226
  exports.default = TasksUpdatesAdd;
@@ -1,5 +1,7 @@
1
1
  import { BaseCommand } from '../../base-command';
2
+ import { type FollowUpRow } from '../../lib/followups';
2
3
  export default class TasksWait extends BaseCommand {
4
+ static summary: string;
3
5
  static description: string;
4
6
  static examples: string[];
5
7
  static args: {
@@ -14,6 +16,24 @@ export default class TasksWait extends BaseCommand {
14
16
  'fail-on': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
15
17
  interval: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
16
18
  timeout: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
+ on: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
+ where: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
21
+ deadline: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
22
+ agent: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
23
+ why: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
24
+ 'max-fix-attempts': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
25
+ 'reset-attempts': import("@oclif/core/interfaces").BooleanFlag<boolean>;
17
26
  };
18
27
  run(): Promise<void>;
28
+ private armWait;
29
+ }
30
+ export interface TaskWaitResponse {
31
+ task?: {
32
+ id?: string;
33
+ identifier?: string;
34
+ status?: string;
35
+ };
36
+ followup?: FollowUpRow | null;
37
+ reused?: boolean;
38
+ alreadyBlocked?: boolean;
19
39
  }
@@ -1,17 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
+ const data_provider_1 = require("@skrr-ai/data-provider");
4
5
  const base_command_1 = require("../../base-command");
5
6
  const task_resolver_1 = require("../../lib/task-resolver");
7
+ const task_extras_1 = require("../../lib/task-extras");
8
+ const tasks_1 = require("../../lib/tasks");
9
+ const followups_1 = require("../../lib/followups");
6
10
  const task_execution_1 = require("../../lib/task-execution");
7
11
  const PARSE_DURATION_MS_RE = /^(\d+)(ms|s|m|h)?$/i;
8
12
  class TasksWait extends base_command_1.BaseCommand {
9
- static description = 'Wait for task executions to reach a target status';
13
+ static summary = 'Block a task on a pull request or events, or wait for tasks to reach a status';
14
+ static description = [
15
+ 'With --on, this arms a wait and blocks the task on it in one call: the task moves to blocked with the wait recorded as what it waits on, and moves back when the wait wakes its agent. --on owner/repo#n watches that pull request to the end (CI on its head, a conflict, a review, the merge or a close; fix attempts held by the server, as `skrr followups watch-pr`). --on <entity.event> (repeatable) wakes on the first of those events, filtered with --where field=value.',
16
+ 'Without --on, this polls until the tasks reach a target status (--until), for scripts.',
17
+ ].join('\n\n');
10
18
  static examples = [
11
19
  '<%= config.bin %> tasks wait <task-id> --until done',
12
20
  '<%= config.bin %> tasks wait --until done',
13
21
  '<%= config.bin %> tasks wait <task-id> --task <other-task-id> --until terminal',
14
22
  '<%= config.bin %> tasks wait <root-task-id> --descendants --timeout 30m',
23
+ '<%= config.bin %> tasks wait OSK-42 --on acme/api#17',
24
+ '<%= config.bin %> tasks wait OSK-42 --on github.pull_request_merged --on github.pull_request_closed --where prNumber=17 --deadline 2d',
15
25
  ];
16
26
  static args = {
17
27
  id: core_1.Args.string({
@@ -37,6 +47,26 @@ class TasksWait extends base_command_1.BaseCommand {
37
47
  }),
38
48
  interval: core_1.Flags.integer({ description: 'Polling interval in seconds', default: 5 }),
39
49
  timeout: core_1.Flags.string({ description: 'Timeout such as 30s, 10m, 2h' }),
50
+ on: core_1.Flags.string({
51
+ description: 'Block the task until this happens: a pull request (owner/repo#n or its URL), or an event <entity.event> (repeatable; the first to arrive wakes the agent)',
52
+ multiple: true,
53
+ }),
54
+ where: core_1.Flags.string({
55
+ description: 'With --on <event>: the event field that must equal a value, field=value (such as prNumber=17)',
56
+ }),
57
+ deadline: core_1.Flags.string({
58
+ description: 'With --on: when the wait stops if nothing arrived, 10m to 7d (default 6h)',
59
+ }),
60
+ agent: core_1.Flags.string({
61
+ description: "With --on: the agent the wait wakes (default: the session's agent, else the task's assignee)",
62
+ }),
63
+ why: core_1.Flags.string({ description: 'With --on: why the task waits, in one line' }),
64
+ 'max-fix-attempts': core_1.Flags.integer({
65
+ description: `With --on <pr>: set the fix-attempt budget (1-${data_provider_1.PULL_REQUEST_WATCH_MAX_FIX_ATTEMPTS}). The owner's to set`,
66
+ }),
67
+ 'reset-attempts': core_1.Flags.boolean({
68
+ description: "With --on <pr>: start the fix-attempt count again. The owner's to set",
69
+ }),
40
70
  };
41
71
  async run() {
42
72
  this.requireAuth();
@@ -56,6 +86,21 @@ class TasksWait extends base_command_1.BaseCommand {
56
86
  });
57
87
  }
58
88
  const taskRef = await this.resolveEntityRef('task', taskIdentity.id);
89
+ // What the person typed, for the sentences; the resolved id for the request.
90
+ const shownRef = args.id || taskRef;
91
+ if (flags.on?.length) {
92
+ await this.armWait(taskRef, shownRef, flags);
93
+ return;
94
+ }
95
+ const onlyWithOn = ['where', 'deadline', 'agent', 'why', 'max-fix-attempts', 'reset-attempts'].filter((name) => flags[name] !== undefined && flags[name] !== false);
96
+ if (onlyWithOn.length) {
97
+ this.failWithCliError({
98
+ message: `--${onlyWithOn[0]} belongs to a wait on something: add --on <owner/repo#n> or --on <entity.event>, for example \`skrr tasks wait ${shownRef} --on acme/api#17\`.`,
99
+ code: 'TASK_WAIT_ON_REQUIRED',
100
+ exit: 2,
101
+ retryable: false,
102
+ });
103
+ }
59
104
  const failOn = (0, task_execution_1.parseStatusSet)(flags['fail-on'], task_execution_1.DEFAULT_FAIL_STATUSES);
60
105
  let timeoutMs = null;
61
106
  try {
@@ -118,8 +163,64 @@ class TasksWait extends base_command_1.BaseCommand {
118
163
  await (0, task_execution_1.sleep)(intervalMs);
119
164
  }
120
165
  }
166
+ async armWait(taskRef, shownRef, flags) {
167
+ const polling = POLLING_FLAGS.find((flag) => this.argv.some((token) => token === flag || token.startsWith(`${flag}=`)));
168
+ if (polling) {
169
+ this.failWithCliError({
170
+ message: `${polling} polls for a status and cannot be combined with --on, which arms a wait and returns at once. Run \`skrr tasks wait ${shownRef} --on ${flags.on[0]}\` alone, or drop --on to poll.`,
171
+ code: 'TASK_WAIT_MIXED_FORMS',
172
+ exit: 2,
173
+ retryable: false,
174
+ });
175
+ }
176
+ const sessionAgent = (0, tasks_1.boundSessionAgentId)();
177
+ let response;
178
+ try {
179
+ response = (await task_extras_1.taskLookupApi.waitOn(taskRef, {
180
+ on: flags.on,
181
+ producer: sessionAgent ? 'agent_in_turn' : 'user_explicit',
182
+ ...(flags.agent || sessionAgent ? { agentId: flags.agent || sessionAgent } : {}),
183
+ ...(flags.where ? { where: flags.where } : {}),
184
+ ...(flags.deadline ? { deadline: flags.deadline } : {}),
185
+ ...(flags.why ? { why: flags.why } : {}),
186
+ ...(flags['max-fix-attempts'] !== undefined
187
+ ? { maxFixAttempts: flags['max-fix-attempts'] }
188
+ : {}),
189
+ ...(flags['reset-attempts'] ? { resetAttempts: true } : {}),
190
+ }));
191
+ }
192
+ catch (err) {
193
+ this.handleApiError(err);
194
+ return;
195
+ }
196
+ if (flags.json) {
197
+ this.log(JSON.stringify(response, null, 2));
198
+ return;
199
+ }
200
+ for (const line of armedWaitLines(shownRef, response))
201
+ this.log(line);
202
+ }
121
203
  }
122
204
  exports.default = TasksWait;
205
+ /** Polling flags that mean nothing to an armed wait, which returns at once. */
206
+ const POLLING_FLAGS = [
207
+ '--until',
208
+ '--fail-on',
209
+ '--interval',
210
+ '--timeout',
211
+ '--task',
212
+ '--descendants',
213
+ '--children-only',
214
+ ];
215
+ function armedWaitLines(taskRef, response) {
216
+ const row = response.followup;
217
+ const what = row ? ((0, followups_1.pullRequestLine)(row) ?? row.why ?? 'the wait') : 'the wait';
218
+ return [
219
+ `${response.reused ? 'Already waiting' : 'Blocked'}: ${response.task?.identifier ?? taskRef} is ${response.task?.status ?? 'blocked'} until ${what}${row?.deadlineAt ? `, or until ${row.deadlineAt}` : ''}.`,
220
+ `Wait ${row?.id ?? '—'} wakes the agent once and moves the task back; \`skrr followups show ${row?.id ?? '<id>'}\` says what woke it, or why it stopped.`,
221
+ ...(row && (0, followups_1.stopReasonLine)(row) ? [(0, followups_1.stopReasonLine)(row)] : []),
222
+ ];
223
+ }
123
224
  function formatProgress(snapshot) {
124
225
  const statuses = Object.entries(snapshot.counts)
125
226
  .sort(([a], [b]) => a.localeCompare(b))