@skrr-ai/cli 0.1.207 → 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 (111) 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/shared-memory.d.ts +24 -0
  29. package/dist/commands/agents/shared-memory.js +67 -0
  30. package/dist/commands/agents/visibility.d.ts +1 -0
  31. package/dist/commands/agents/visibility.js +14 -0
  32. package/dist/commands/code/migrate.js +3 -1
  33. package/dist/commands/duties/advance-next.js +15 -6
  34. package/dist/commands/followups/show.js +9 -0
  35. package/dist/commands/followups/watch-pr.d.ts +27 -0
  36. package/dist/commands/followups/watch-pr.js +123 -0
  37. package/dist/commands/memory/consolidation/index.d.ts +20 -0
  38. package/dist/commands/memory/consolidation/index.js +78 -0
  39. package/dist/commands/memory/consolidation/resume.d.ts +14 -0
  40. package/dist/commands/memory/consolidation/resume.js +46 -0
  41. package/dist/commands/memory/consolidation/undo.d.ts +18 -0
  42. package/dist/commands/memory/consolidation/undo.js +60 -0
  43. package/dist/commands/slack/mutes.d.ts +10 -0
  44. package/dist/commands/slack/mutes.js +62 -0
  45. package/dist/commands/slack/unmute.d.ts +12 -0
  46. package/dist/commands/slack/unmute.js +44 -0
  47. package/dist/commands/tasks/actionability.js +9 -0
  48. package/dist/commands/tasks/ask.d.ts +50 -0
  49. package/dist/commands/tasks/ask.js +190 -0
  50. package/dist/commands/tasks/handover.js +14 -0
  51. package/dist/commands/tasks/input/answer.js +8 -2
  52. package/dist/commands/tasks/input/show.d.ts +26 -0
  53. package/dist/commands/tasks/input/show.js +185 -17
  54. package/dist/commands/tasks/move.d.ts +11 -0
  55. package/dist/commands/tasks/move.js +82 -1
  56. package/dist/commands/tasks/result/submit.js +3 -0
  57. package/dist/commands/tasks/runs.d.ts +4 -1
  58. package/dist/commands/tasks/runs.js +22 -3
  59. package/dist/commands/tasks/show.js +22 -1
  60. package/dist/commands/tasks/update.d.ts +1 -0
  61. package/dist/commands/tasks/update.js +52 -1
  62. package/dist/commands/tasks/updates/add.js +3 -0
  63. package/dist/commands/tasks/wait.d.ts +20 -0
  64. package/dist/commands/tasks/wait.js +102 -1
  65. package/dist/generated/agent-guides.json +501 -92
  66. package/dist/generated/managed-instruction-guides.json +1 -1
  67. package/dist/lib/agent-access-command.d.ts +19 -0
  68. package/dist/lib/agent-access-command.js +44 -0
  69. package/dist/lib/agent-access.d.ts +18 -0
  70. package/dist/lib/agent-access.js +48 -0
  71. package/dist/lib/agent-import/apply.d.ts +50 -0
  72. package/dist/lib/agent-import/apply.js +85 -0
  73. package/dist/lib/agent-import/plan.d.ts +132 -0
  74. package/dist/lib/agent-import/plan.js +504 -0
  75. package/dist/lib/agent-import/reader.d.ts +94 -0
  76. package/dist/lib/agent-import/reader.js +326 -0
  77. package/dist/lib/agent-import/schedule.d.ts +46 -0
  78. package/dist/lib/agent-import/schedule.js +220 -0
  79. package/dist/lib/agent-import/sources.d.ts +124 -0
  80. package/dist/lib/agent-import/sources.js +797 -0
  81. package/dist/lib/followups.d.ts +61 -0
  82. package/dist/lib/followups.js +39 -0
  83. package/dist/lib/handover-interview.d.ts +18 -0
  84. package/dist/lib/handover-interview.js +53 -0
  85. package/dist/lib/input-queue.js +2 -1
  86. package/dist/lib/intuition-look.d.ts +10 -0
  87. package/dist/lib/intuition-look.js +64 -0
  88. package/dist/lib/record-output.d.ts +1 -1
  89. package/dist/lib/record-output.js +2 -0
  90. package/dist/lib/skill-import.d.ts +19 -0
  91. package/dist/lib/skill-import.js +34 -0
  92. package/dist/lib/slack-thread-mutes.d.ts +25 -0
  93. package/dist/lib/slack-thread-mutes.js +12 -0
  94. package/dist/lib/task-carriers.d.ts +18 -0
  95. package/dist/lib/task-carriers.js +43 -0
  96. package/dist/lib/task-extras.d.ts +5 -0
  97. package/dist/lib/task-extras.js +5 -0
  98. package/dist/lib/task-recurrence-summary.d.ts +15 -0
  99. package/dist/lib/task-recurrence-summary.js +22 -0
  100. package/dist/lib/task-version.d.ts +44 -0
  101. package/dist/lib/task-version.js +73 -0
  102. package/dist/lib/task-write-attribution.d.ts +7 -0
  103. package/dist/lib/task-write-attribution.js +14 -0
  104. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/turnPacing.d.ts +75 -0
  105. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/turnPacing.js +124 -0
  106. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/turnPacing.d.ts +75 -0
  107. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/turnPacing.js +141 -0
  108. package/dist/node_modules/@skrr-ai/auth-core/package.json +10 -0
  109. package/dist/node_modules/@skrr-ai/data-provider/index.js +13323 -12577
  110. package/oclif.manifest.json +1787 -107
  111. package/package.json +5 -2
@@ -1,38 +1,206 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.humanInputOptionsLine = humanInputOptionsLine;
4
+ exports.humanInputContextLines = humanInputContextLines;
5
+ exports.humanInputOptionDescriptionLines = humanInputOptionDescriptionLines;
6
+ exports.parseWaitTimeoutMs = parseWaitTimeoutMs;
7
+ exports.humanInputAnswerLines = humanInputAnswerLines;
3
8
  const core_1 = require("@oclif/core");
4
9
  const data_provider_1 = require("@skrr-ai/data-provider");
5
10
  const base_command_1 = require("../../../base-command");
11
+ const task_execution_1 = require("../../../lib/task-execution");
12
+ const WAIT_DURATION_RE = /^(\d+)\s*(s|m|h)?$/i;
13
+ /**
14
+ * A question's options as one line, the asker's recommendation marked. Marked,
15
+ * never chosen: the person (or the agent answering for them) still picks.
16
+ */
17
+ function humanInputOptionsLine(question) {
18
+ if (!question.options?.length)
19
+ return null;
20
+ return question.options
21
+ .map((option, position) => position === question.recommendedIndex ? `${option} (recommended)` : option)
22
+ .join(', ');
23
+ }
24
+ /**
25
+ * A question's background, under the question it explains: each of its lines
26
+ * indented by `indent`, so a context of several lines stays one block.
27
+ */
28
+ function humanInputContextLines(question, indent) {
29
+ if (!question.context?.trim())
30
+ return [];
31
+ return question.context
32
+ .trim()
33
+ .split(/\r?\n/)
34
+ .map((line) => `${indent}${line}`);
35
+ }
36
+ /**
37
+ * What each option means, one line per described option, under the options
38
+ * line and indented by `indent`: `Annual: billed once a year`. An option with
39
+ * no description gets no line.
40
+ */
41
+ function humanInputOptionDescriptionLines(question, indent) {
42
+ if (!question.options?.length || !question.optionDescriptions?.length)
43
+ return [];
44
+ return question.options.flatMap((option, position) => {
45
+ const description = question.optionDescriptions?.[position]?.replace(/\s+/g, ' ').trim();
46
+ return description ? [`${indent}${option}: ${description}`] : [];
47
+ });
48
+ }
49
+ /** `--timeout` for `--wait`: 90s, 10m, 2h (a bare number is seconds). */
50
+ function parseWaitTimeoutMs(value) {
51
+ if (value === undefined)
52
+ return null;
53
+ const match = value.trim().match(WAIT_DURATION_RE);
54
+ if (!match)
55
+ throw new Error(`--timeout takes a length such as 90s, 10m, 2h: ${value}`);
56
+ const unit = (match[2] || 's').toLowerCase();
57
+ return Number(match[1]) * (unit === 'h' ? 3_600_000 : unit === 'm' ? 60_000 : 1000);
58
+ }
59
+ /** Each answer as the asker reads it, beside the question it answers. */
60
+ function humanInputAnswerLines(request) {
61
+ const lines = [];
62
+ for (const [index, question] of request.questions.entries()) {
63
+ lines.push(`${index + 1}. ${question.header ? `${question.header}: ` : ''}${question.prompt}`);
64
+ lines.push(...humanInputContextLines(question, ' '));
65
+ const options = humanInputOptionsLine(question);
66
+ if (options)
67
+ lines.push(` Options: ${options}`);
68
+ lines.push(...humanInputOptionDescriptionLines(question, ' '));
69
+ const answer = request.answers?.find((a) => a.questionId === question.questionId);
70
+ if (answer) {
71
+ const value = [
72
+ ...(answer.selectedOptions || []),
73
+ ...(answer.freeText ? [answer.freeText] : []),
74
+ ]
75
+ .filter(Boolean)
76
+ .join(', ');
77
+ lines.push(` Answer: ${value}`);
78
+ }
79
+ }
80
+ return lines;
81
+ }
82
+ /** Seconds between reads while `--wait` polls the request. */
83
+ const DEFAULT_WAIT_INTERVAL_SECONDS = 5;
6
84
  class TasksInputShow extends base_command_1.BaseCommand {
7
- static description = 'Show the open Human-input request for a task';
85
+ static description = 'Show a Human-input request for a task: the open one, or one by id in any state with its answer (--request), waiting for it to be answered (--wait)';
86
+ static examples = [
87
+ '<%= config.bin %> tasks input show OSK-42',
88
+ '<%= config.bin %> tasks input show OSK-42 --request thi_... --wait --timeout 30m',
89
+ ];
8
90
  static args = {
9
91
  id: core_1.Args.string({ description: 'Task ID/ref', required: true, ignoreStdin: true }),
10
92
  };
11
- static flags = { json: core_1.Flags.boolean({ description: 'Output as JSON' }) };
93
+ static flags = {
94
+ json: core_1.Flags.boolean({ description: 'Output as JSON' }),
95
+ request: core_1.Flags.string({
96
+ description: 'A request by id, in any state, with its answer once there is one',
97
+ }),
98
+ wait: core_1.Flags.boolean({
99
+ description: 'Wait until the request is no longer open (answered, expired or dismissed); with no --request, the current open one',
100
+ }),
101
+ timeout: core_1.Flags.string({
102
+ description: 'With --wait, stop waiting after 90s, 10m, 2h (default: until it closes)',
103
+ dependsOn: ['wait'],
104
+ }),
105
+ // No `default:` here. oclif fills a flag's default in BEFORE it checks `dependsOn`,
106
+ // so a defaulted `--interval` always "depends on --wait" and refused every plain
107
+ // read (`tasks input show <task> --json` exited 2). The default lives in run().
108
+ interval: core_1.Flags.integer({
109
+ description: `With --wait, seconds between reads (default: ${DEFAULT_WAIT_INTERVAL_SECONDS})`,
110
+ dependsOn: ['wait'],
111
+ }),
112
+ };
12
113
  async run() {
13
114
  this.requireAuth();
14
115
  const { args, flags } = await this.parse(TasksInputShow);
15
116
  const taskId = await this.resolveTaskReference(args.id);
16
- let response;
117
+ if (!flags.request && !flags.wait) {
118
+ let response;
119
+ try {
120
+ response = await data_provider_1.dataService.getTaskHumanInput(taskId);
121
+ }
122
+ catch (err) {
123
+ this.handleApiError(err);
124
+ }
125
+ if (flags.json) {
126
+ this.log(JSON.stringify(response, null, 2));
127
+ return;
128
+ }
129
+ if (!response.data) {
130
+ this.log('No open Human-input request.');
131
+ return;
132
+ }
133
+ this.log(`Request: ${response.data.requestId}`);
134
+ for (const line of humanInputAnswerLines(response.data))
135
+ this.log(line);
136
+ return;
137
+ }
138
+ let timeoutMs = null;
17
139
  try {
18
- response = await data_provider_1.dataService.getTaskHumanInput(taskId);
140
+ timeoutMs = parseWaitTimeoutMs(flags.timeout);
19
141
  }
20
142
  catch (err) {
21
- this.handleApiError(err);
143
+ this.failWithCliError({
144
+ message: err.message,
145
+ code: 'TASK_HUMAN_INPUT_WAIT_TIMEOUT_INVALID',
146
+ exit: 2,
147
+ retryable: false,
148
+ });
22
149
  }
23
- if (flags.json) {
24
- this.log(JSON.stringify(response, null, 2));
25
- return;
26
- }
27
- if (!response.data) {
28
- this.log('No open Human-input request.');
29
- return;
150
+ let requestId = flags.request;
151
+ if (!requestId) {
152
+ // --wait on the current question: take its id now, so the answer can be
153
+ // read after it stops being the open one.
154
+ try {
155
+ requestId = (await data_provider_1.dataService.getTaskHumanInput(taskId)).data?.requestId;
156
+ }
157
+ catch (err) {
158
+ this.handleApiError(err);
159
+ }
160
+ if (!requestId)
161
+ this.error('No open Human-input request exists for this task', { exit: 4 });
30
162
  }
31
- this.log(`Request: ${response.data.requestId}`);
32
- for (const [index, question] of response.data.questions.entries()) {
33
- this.log(`${index + 1}. ${question.header ? `${question.header}: ` : ''}${question.prompt}`);
34
- if (question.options?.length)
35
- this.log(` Options: ${question.options.join(', ')}`);
163
+ const startedAt = Date.now();
164
+ const intervalMs = Math.max(1, flags.interval ?? DEFAULT_WAIT_INTERVAL_SECONDS) * 1000;
165
+ let announced = false;
166
+ while (true) {
167
+ let request;
168
+ try {
169
+ request = (await data_provider_1.dataService.getTaskHumanInputRequest(taskId, requestId)).data;
170
+ }
171
+ catch (err) {
172
+ this.handleApiError(err);
173
+ }
174
+ if (!request)
175
+ this.error(`No Human-input request ${requestId} on this task`, { exit: 4 });
176
+ const open = request.status === 'open';
177
+ if (!flags.wait || !open) {
178
+ if (flags.json)
179
+ this.log(JSON.stringify({ data: request }, null, 2));
180
+ else {
181
+ this.log(`Request: ${request.requestId} (${request.status})`);
182
+ for (const line of humanInputAnswerLines(request))
183
+ this.log(line);
184
+ }
185
+ // Waiting ends in one of three ways, and only an answer is the one
186
+ // the waiter asked for.
187
+ if (flags.wait && request.status !== 'answered')
188
+ this.exit(1);
189
+ return;
190
+ }
191
+ if (timeoutMs !== null && Date.now() - startedAt >= timeoutMs) {
192
+ this.failWithCliError({
193
+ message: `Request ${requestId} is still open after ${flags.timeout}.`,
194
+ code: 'TASK_HUMAN_INPUT_WAIT_TIMEOUT',
195
+ exit: 124,
196
+ retryable: true,
197
+ });
198
+ }
199
+ if (!announced && !flags.json) {
200
+ this.log(`Waiting for an answer to ${requestId}...`);
201
+ announced = true;
202
+ }
203
+ await (0, task_execution_1.sleep)(intervalMs);
36
204
  }
37
205
  }
38
206
  }
@@ -1,4 +1,14 @@
1
1
  import { BaseCommand } from '../../base-command';
2
+ /**
3
+ * The notice for a Task moved into review that no Review is owed for.
4
+ *
5
+ * Review is where a Review the Task's own `reviewPolicy` requires is waited
6
+ * for. Under `none` (the default) nobody owes one, so a Task parked there
7
+ * waits on a person who was never asked: thousands sat in review that way
8
+ * (OSK-33196). The move still lands; this says what it means, at the moment
9
+ * an agent made it.
10
+ */
11
+ export declare function unowedReviewNotice(task: unknown, bin: string): string | null;
2
12
  /**
3
13
  * `tasks move` is the documented way to change a task's status. The data
4
14
  * provider's `TaskUpdateParams` (used by `tasks update`) does not expose a
@@ -22,6 +32,7 @@ export default class TasksMove extends BaseCommand {
22
32
  reason: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
23
33
  'resolution-actor': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
24
34
  force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
35
+ 'expected-version': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
25
36
  };
26
37
  run(): Promise<void>;
27
38
  /**
@@ -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;