@skrr-ai/cli 0.1.202 → 0.1.206

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 (71) hide show
  1. package/bin/dev-fallback.js +47 -29
  2. package/bin/dev.cjs +6 -0
  3. package/dist/base-command.js +1 -1
  4. package/dist/commands/agent/message/context.d.ts +3 -0
  5. package/dist/commands/agent/message/context.js +33 -1
  6. package/dist/commands/agent/message/no-reply.d.ts +17 -0
  7. package/dist/commands/agent/message/no-reply.js +54 -0
  8. package/dist/commands/agent/message/retract.d.ts +24 -0
  9. package/dist/commands/agent/message/retract.js +167 -0
  10. package/dist/commands/agent/message/send.d.ts +53 -3
  11. package/dist/commands/agent/message/send.js +148 -4
  12. package/dist/commands/agents/chat.d.ts +12 -0
  13. package/dist/commands/agents/chat.js +258 -25
  14. package/dist/commands/agents/manager/status.d.ts +9 -0
  15. package/dist/commands/agents/manager/status.js +84 -0
  16. package/dist/commands/agents/queue/clear.d.ts +13 -0
  17. package/dist/commands/agents/queue/clear.js +31 -0
  18. package/dist/commands/agents/queue/list.d.ts +10 -0
  19. package/dist/commands/agents/queue/list.js +34 -0
  20. package/dist/commands/agents/queue/move.d.ts +16 -0
  21. package/dist/commands/agents/queue/move.js +33 -0
  22. package/dist/commands/agents/queue/pause.d.ts +7 -0
  23. package/dist/commands/agents/queue/pause.js +24 -0
  24. package/dist/commands/agents/queue/resume.d.ts +7 -0
  25. package/dist/commands/agents/queue/resume.js +24 -0
  26. package/dist/commands/agents/queue/steer.d.ts +14 -0
  27. package/dist/commands/agents/queue/steer.js +38 -0
  28. package/dist/commands/agents/queue/withdraw.d.ts +10 -0
  29. package/dist/commands/agents/queue/withdraw.js +27 -0
  30. package/dist/commands/agents/supervision.d.ts +1 -0
  31. package/dist/commands/agents/supervision.js +28 -9
  32. package/dist/commands/convos/transcript.d.ts +48 -0
  33. package/dist/commands/convos/transcript.js +461 -0
  34. package/dist/commands/duties/advance-next.d.ts +17 -0
  35. package/dist/commands/duties/advance-next.js +122 -0
  36. package/dist/commands/duties/pack/plan.js +45 -0
  37. package/dist/commands/duties/preflight.d.ts +1 -0
  38. package/dist/commands/duties/preflight.js +18 -2
  39. package/dist/commands/spaces/auto-executor/preview.js +6 -2
  40. package/dist/commands/spaces/charter/revise.d.ts +16 -0
  41. package/dist/commands/spaces/charter/revise.js +84 -0
  42. package/dist/commands/spaces/skills/propose.d.ts +1 -0
  43. package/dist/commands/spaces/skills/propose.js +5 -0
  44. package/dist/commands/tasks/create.js +16 -1
  45. package/dist/commands/tasks/result/show.js +6 -3
  46. package/dist/commands/tasks/start.d.ts +3 -0
  47. package/dist/commands/tasks/start.js +12 -1
  48. package/dist/commands/triggers/capabilities.js +14 -4
  49. package/dist/generated/agent-guides.json +258 -24
  50. package/dist/lib/agent-chat-queue-command.d.ts +29 -0
  51. package/dist/lib/agent-chat-queue-command.js +75 -0
  52. package/dist/lib/agent-chat-queue.d.ts +77 -0
  53. package/dist/lib/agent-chat-queue.js +245 -0
  54. package/dist/lib/agent-chat-start.d.ts +101 -0
  55. package/dist/lib/agent-chat-start.js +151 -6
  56. package/dist/lib/duties.d.ts +5 -1
  57. package/dist/lib/duties.js +16 -5
  58. package/dist/lib/duty-product.js +6 -0
  59. package/dist/lib/input-queue.d.ts +18 -0
  60. package/dist/lib/input-queue.js +59 -0
  61. package/dist/lib/message-intent.d.ts +26 -3
  62. package/dist/lib/message-intent.js +7 -1
  63. package/dist/lib/task-runtime-headers.d.ts +5 -0
  64. package/dist/lib/task-runtime-headers.js +28 -8
  65. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarness.d.ts +16 -15
  66. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarness.js +0 -22
  67. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarness.d.ts +16 -15
  68. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarness.js +0 -22
  69. package/dist/node_modules/@skrr-ai/data-provider/index.js +11690 -11370
  70. package/oclif.manifest.json +1635 -332
  71. package/package.json +10 -4
@@ -0,0 +1,461 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CONTINUATION_STATE_WORDS = exports.TRANSCRIPT_SOURCE_WORDS = exports.CONTEXT_BREAK_WORDS = void 0;
4
+ exports.describeContext = describeContext;
5
+ exports.boundaryLine = boundaryLine;
6
+ exports.usageSummary = usageSummary;
7
+ exports.processSummary = processSummary;
8
+ exports.formatTranscriptItem = formatTranscriptItem;
9
+ exports.formatTurnBody = formatTurnBody;
10
+ const core_1 = require("@oclif/core");
11
+ const data_provider_1 = require("@skrr-ai/data-provider");
12
+ const base_command_1 = require("../../base-command");
13
+ const WHITESPACE_RE = /\s+/g;
14
+ const TEXT_CLIP = 300;
15
+ const ENVELOPE_CLIP = 160;
16
+ /**
17
+ * What each break reason says on a boundary line. Exhaustive by type: a reason added to
18
+ * `CONTEXT_BREAK_REASONS` does not compile here until it has words.
19
+ */
20
+ exports.CONTEXT_BREAK_WORDS = {
21
+ first_turn: 'the first turn of this conversation',
22
+ config_changed: "the agent's configuration changed",
23
+ release_changed: 'the agent moved to another release',
24
+ harness_changed: 'the turn ran on another harness',
25
+ machine_changed: 'the session moved to another machine',
26
+ reanchored: 're-anchored to keep the context small',
27
+ cleared_after_failure: 'the previous session was cleared after a failure',
28
+ resume_failed: 'the previous session could not be resumed',
29
+ not_resumable: 'this kind of turn does not resume a session',
30
+ };
31
+ /** What each transcript source says in a turn header. Exhaustive by type. */
32
+ exports.TRANSCRIPT_SOURCE_WORDS = {
33
+ live: 'still running',
34
+ archive: 'full archive',
35
+ compacted: 'compacted copy only',
36
+ content: 'cloud content parts',
37
+ none: 'nothing was kept',
38
+ imported: 'imported history',
39
+ };
40
+ /**
41
+ * Where a continuation sent to an imported session is, as its receipt says. Exhaustive by type.
42
+ * (An imported session is read only with a first-party app's session; a CLI token is refused.)
43
+ */
44
+ exports.CONTINUATION_STATE_WORDS = {
45
+ preparing: 'sent from here, still being prepared',
46
+ unknown: 'sent from here, outcome not confirmed',
47
+ settled: 'sent from here, ended on the source computer',
48
+ not_submitted: 'sent from here, not submitted',
49
+ };
50
+ const oneLine = (text) => text.replace(WHITESPACE_RE, ' ').trim();
51
+ const clip = (text, max) => (text.length > max ? `${text.slice(0, max)}…` : text);
52
+ const when = (value) => {
53
+ if (!value)
54
+ return '';
55
+ const date = new Date(value);
56
+ return Number.isNaN(date.getTime()) ? value : date.toISOString();
57
+ };
58
+ /** A row's time and the gap after it, or nothing: an imported event may record no time. */
59
+ const stamp = (value) => (value ? `${when(value)} ` : '');
60
+ function formatBytes(bytes) {
61
+ if (bytes < 1024)
62
+ return `${bytes} B`;
63
+ if (bytes < 1024 * 1024)
64
+ return `${(bytes / 1024).toFixed(1)} KiB`;
65
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MiB`;
66
+ }
67
+ /**
68
+ * A recorded duration in words. Only `usage.durationMs` is one: a row's `updatedAt` moves with
69
+ * any later write to it (an archive pointer, a retraction), so it is not when the turn ended.
70
+ */
71
+ function formatDuration(ms) {
72
+ if (ms === undefined || !Number.isFinite(ms) || ms < 0)
73
+ return null;
74
+ if (ms < 1000)
75
+ return `${ms}ms`;
76
+ const seconds = Math.round(ms / 1000);
77
+ if (seconds < 60)
78
+ return `${seconds}s`;
79
+ const minutes = Math.floor(seconds / 60);
80
+ return `${minutes}m${String(seconds % 60).padStart(2, '0')}s`;
81
+ }
82
+ /** Whether the harness context continued into this turn, in words. Never guesses "continued". */
83
+ function describeContext(turn) {
84
+ const lineage = turn.contextLineage;
85
+ if (!lineage)
86
+ return 'not recorded';
87
+ if (lineage.continued)
88
+ return 'continued';
89
+ return lineage.breakReason
90
+ ? `new session: ${exports.CONTEXT_BREAK_WORDS[lineage.breakReason]}`
91
+ : 'new session: no reason was recorded';
92
+ }
93
+ /** The line drawn above a turn whose harness context did not continue, or null. */
94
+ function boundaryLine(turn) {
95
+ if (turn.contextLineage?.continued !== false)
96
+ return null;
97
+ return `──── ${describeContext(turn)} ────`;
98
+ }
99
+ const COUNT_FORMAT = new Intl.NumberFormat('en-US');
100
+ /**
101
+ * What the turn recorded of its usage, in one line, or null when it recorded nothing. Only the
102
+ * fields the server sent: an absent one was not recorded and is not printed as zero.
103
+ */
104
+ function contextLine(usage) {
105
+ if (usage.contextTokens === undefined)
106
+ return null;
107
+ const window = usage.contextWindow !== undefined ? ` of ${COUNT_FORMAT.format(usage.contextWindow)}` : '';
108
+ return `${COUNT_FORMAT.format(usage.contextTokens)}${window} context`;
109
+ }
110
+ function usageSummary(usage) {
111
+ if (!usage)
112
+ return null;
113
+ const parts = [
114
+ usage.inputTokens !== undefined ? `${COUNT_FORMAT.format(usage.inputTokens)} in` : null,
115
+ usage.outputTokens !== undefined ? `${COUNT_FORMAT.format(usage.outputTokens)} out` : null,
116
+ usage.cacheReadTokens !== undefined
117
+ ? `${COUNT_FORMAT.format(usage.cacheReadTokens)} cache read`
118
+ : null,
119
+ usage.cacheWriteTokens !== undefined
120
+ ? `${COUNT_FORMAT.format(usage.cacheWriteTokens)} cache write`
121
+ : null,
122
+ usage.numTurns !== undefined ? `${usage.numTurns} model call(s)` : null,
123
+ contextLine(usage),
124
+ // The harness's running estimate for the whole session, never this turn's cost or a charge.
125
+ usage.sessionCostUsd !== undefined
126
+ ? `session cost so far $${usage.sessionCostUsd.toFixed(4)} (estimate)`
127
+ : null,
128
+ usage.model ?? null,
129
+ ].filter(Boolean);
130
+ return parts.length ? parts.join(', ') : null;
131
+ }
132
+ /** The turn's process in one line: where it is kept, how much, and what was lost. */
133
+ function processSummary(turn) {
134
+ const { transcript } = turn;
135
+ const parts = [exports.TRANSCRIPT_SOURCE_WORDS[transcript.source]];
136
+ const archive = transcript.archive;
137
+ if (archive) {
138
+ if (archive.envelopeCount !== undefined)
139
+ parts.push(`${archive.envelopeCount} events`);
140
+ if (archive.bytes !== undefined)
141
+ parts.push(formatBytes(archive.bytes));
142
+ if (archive.truncated)
143
+ parts.push('truncated');
144
+ else if (archive.clipped)
145
+ parts.push('some outputs clipped');
146
+ else if (archive.complete === false)
147
+ parts.push('incomplete');
148
+ }
149
+ else if (transcript.compactedBytes !== undefined) {
150
+ parts.push(formatBytes(transcript.compactedBytes));
151
+ }
152
+ for (const loss of transcript.losses ?? []) {
153
+ const classes = loss.classes.length ? loss.classes.join(', ') : 'events';
154
+ parts.push(`lost ${classes} (${loss.reason})`);
155
+ }
156
+ return parts.join(', ');
157
+ }
158
+ /**
159
+ * Who wrote a row the person did not type, in the words the web view uses. Exhaustive, so a new
160
+ * origin in the contract fails to compile here until it has a label.
161
+ */
162
+ const USER_MESSAGE_ORIGIN_LABELS = {
163
+ widget: 'sent by a widget on your click',
164
+ task_start: "the Task's instructions, sent when it was started",
165
+ recovery: 'sent automatically to continue an interrupted turn',
166
+ heartbeat: 'heartbeat check-in, sent automatically',
167
+ subagent: 'sent by the Agent that delegated this work',
168
+ activity: 'sent automatically for new group or Space activity',
169
+ automatic: 'sent automatically',
170
+ };
171
+ function userMessageLines(item) {
172
+ const marks = [
173
+ item.steeredInto ? `steered into turn ${item.steeredInto}` : null,
174
+ item.hidden ? 'hidden in Main Chat' : null,
175
+ item.files?.length ? `${item.files.length} file(s)` : null,
176
+ ].filter(Boolean);
177
+ // A row a widget, the platform or another Agent wrote is not the person speaking.
178
+ const who = item.origin ? `[${USER_MESSAGE_ORIGIN_LABELS[item.origin]}]` : 'you';
179
+ const other = (item.importedBlocks ?? []).filter((block) => block.kind !== 'text').length;
180
+ if (other)
181
+ marks.push(`${other} other block(s)`);
182
+ const lines = [`${stamp(item.createdAt)}${who}${marks.length ? ` (${marks.join('; ')})` : ''}`];
183
+ const text = clip(oneLine(item.text), TEXT_CLIP);
184
+ if (text)
185
+ lines.push(` ${text}`);
186
+ return lines;
187
+ }
188
+ function turnLines(item) {
189
+ const lines = [];
190
+ const boundary = boundaryLine(item);
191
+ if (boundary)
192
+ lines.push(boundary);
193
+ let status = 'finished';
194
+ if (item.unfinished)
195
+ status = 'running';
196
+ if (item.failure)
197
+ status = 'failed';
198
+ // An imported session records no turn state; a continuation's is its receipt's.
199
+ if (item.localSession)
200
+ status = item.localSession.continuation ? 'continuation' : 'imported';
201
+ const duration = item.unfinished ? null : formatDuration(item.usage?.durationMs);
202
+ let who = item.agentId ? `agent ${item.agentId}` : 'agent';
203
+ if (item.localSession)
204
+ who = item.localSession.provider;
205
+ lines.push(`${stamp(item.createdAt)}turn ${item.messageId} ${who} ${status}${duration ? ` in ${duration}` : ''}`);
206
+ if (item.failure) {
207
+ const type = item.failure.type ? ` (${item.failure.type})` : '';
208
+ lines.push(` failed: ${item.failure.reason ?? 'no reason was recorded'}${type}`);
209
+ }
210
+ const reply = clip(oneLine(item.text ?? ''), TEXT_CLIP);
211
+ if (reply)
212
+ lines.push(` reply: ${reply}`);
213
+ const continuation = item.localSession?.continuation;
214
+ if (continuation) {
215
+ const reason = continuation.reason ? ` (${continuation.reason})` : '';
216
+ lines.push(` continuation: ${exports.CONTINUATION_STATE_WORDS[continuation.state] ?? continuation.state}${reason}`);
217
+ if (continuation.liveOutput) {
218
+ lines.push(` live preview: ${clip(oneLine(continuation.liveOutput.text), TEXT_CLIP)}`);
219
+ }
220
+ }
221
+ lines.push(` process: ${processSummary(item)}`);
222
+ const usage = usageSummary(item.usage);
223
+ if (usage)
224
+ lines.push(` usage: ${usage}`);
225
+ // An imported turn is one stretch of the source's own session, which records no lineage.
226
+ if (!item.localSession)
227
+ lines.push(` context: ${describeContext(item)}`);
228
+ return lines;
229
+ }
230
+ function agentMessageLines(item) {
231
+ const who = item.agentId ? `agent ${item.agentId}` : 'agent';
232
+ const marks = [
233
+ item.turn
234
+ ? `sent during turn ${item.turn.messageId}${item.turn.seq !== undefined ? ` at step ${item.turn.seq}` : ''}${item.turn.sentDuring === 'grace' ? ', just after it ended' : ''}`
235
+ : 'sent on its own',
236
+ item.retracted ? 'retracted' : null,
237
+ ].filter(Boolean);
238
+ const lines = [`${when(item.createdAt)} ${who} → you (${marks.join('; ')})`];
239
+ const text = clip(oneLine(item.text), TEXT_CLIP);
240
+ if (text)
241
+ lines.push(` ${text}`);
242
+ return lines;
243
+ }
244
+ /** The lines `skrr convos transcript` prints for one item. */
245
+ function formatTranscriptItem(item) {
246
+ switch (item.kind) {
247
+ case 'user_message':
248
+ return userMessageLines(item);
249
+ case 'turn':
250
+ return turnLines(item);
251
+ case 'agent_message':
252
+ return agentMessageLines(item);
253
+ }
254
+ }
255
+ function envelopeSummary(envelope) {
256
+ const ev = envelope.ev;
257
+ const kind = typeof ev?.t === 'string' ? ev.t : 'event';
258
+ const text = (value) => clip(oneLine(typeof value === 'string' ? value : ''), ENVELOPE_CLIP);
259
+ switch (kind) {
260
+ case 'text':
261
+ return `${ev.thinking ? 'thinking' : 'text'}: ${text(ev.text)}`;
262
+ case 'service':
263
+ return `service: ${text(ev.text)}`;
264
+ case 'steer':
265
+ return `steer: ${text(ev.text)}`;
266
+ case 'tool-call-start':
267
+ return `tool ${String(ev.name ?? '')}: ${text(ev.title || ev.description)}`;
268
+ case 'tool-call-end':
269
+ return `tool done${ev.status ? ` (${String(ev.status)})` : ''}`;
270
+ case 'turn-end':
271
+ return `turn end: ${String(ev.status ?? '')}`;
272
+ default:
273
+ return kind;
274
+ }
275
+ }
276
+ /** The lines printed for one turn's whole body. */
277
+ /** One imported event's blocks in a line: its text, tool calls and results as the source stored them. */
278
+ function importedEventSummary(event) {
279
+ return event.blocks
280
+ .map((block) => {
281
+ if (block.kind === 'text')
282
+ return block.text;
283
+ if (block.kind === 'tool_call')
284
+ return `tool ${block.name}: ${block.input}`;
285
+ if (block.kind === 'tool_result') {
286
+ return `${block.failed ? 'tool error' : 'tool output'}: ${block.text}`;
287
+ }
288
+ return `(${block.sourceType}, not shown)`;
289
+ })
290
+ .join(' ');
291
+ }
292
+ function formatTurnBody(body) {
293
+ const lines = [
294
+ `turn ${body.messageId} process: ${exports.TRANSCRIPT_SOURCE_WORDS[body.source]}, ${body.total} ${body.source === 'content' ? 'content part(s)' : 'event(s)'}`,
295
+ ];
296
+ const archive = body.archive;
297
+ if (archive) {
298
+ const notes = [
299
+ archive.complete ? 'complete' : 'incomplete',
300
+ archive.truncated
301
+ ? `truncated: ${archive.droppedEnvelopes} event(s), ${formatBytes(archive.droppedBytes)} dropped`
302
+ : null,
303
+ archive.clips.length ? `${archive.clips.length} output(s) clipped` : null,
304
+ ].filter(Boolean);
305
+ lines.push(` archive: ${notes.join('; ')}`);
306
+ }
307
+ for (const loss of body.losses ?? []) {
308
+ const range = loss.fromSeq !== undefined ? ` (steps ${loss.fromSeq}–${loss.toSeq ?? loss.fromSeq})` : '';
309
+ lines.push(` lost: ${loss.classes.join(', ') || 'events'}, ${loss.reason}${range}`);
310
+ }
311
+ for (const envelope of body.envelopes ?? []) {
312
+ const seq = envelope.__seq;
313
+ lines.push(` ${seq !== undefined ? `#${seq} ` : ''}${envelope.role} ${envelopeSummary(envelope)}`);
314
+ }
315
+ // An imported turn's events, numbered by their place in the turn (the page's offset counts).
316
+ for (const [index, event] of (body.events ?? []).entries()) {
317
+ lines.push(` #${body.offset + index + 1} ${event.role} ${clip(oneLine(importedEventSummary(event)), ENVELOPE_CLIP)}`);
318
+ }
319
+ for (const part of body.content ?? []) {
320
+ const record = (part ?? {});
321
+ const type = typeof record.type === 'string' ? record.type : 'part';
322
+ const text = typeof record.text === 'string' ? `: ${clip(oneLine(record.text), ENVELOPE_CLIP)}` : '';
323
+ lines.push(` ${type}${text}`);
324
+ }
325
+ if (body.source === 'live') {
326
+ lines.push(` (still running: this is what ${data_provider_1.BRAND.displayName} holds so far)`);
327
+ }
328
+ return lines;
329
+ }
330
+ /**
331
+ * `skrr convos transcript` — a conversation's whole session, as a conversation (G11, D12).
332
+ *
333
+ * The same items Session Details shows: the person's messages (follow-ups and steers included,
334
+ * and those Main Chat hides), each turn with where its process is kept, and every message the
335
+ * agent sent. A line marks each place the harness context did not continue. `--turn` prints one
336
+ * turn's whole process, paging through it.
337
+ */
338
+ class ConvosTranscript extends base_command_1.BaseCommand {
339
+ static description = "Read a conversation's whole session: messages, turns and the agent's messages";
340
+ static examples = [
341
+ '<%= config.bin %> convos transcript <conversationId>',
342
+ '<%= config.bin %> convos transcript <conversationId> --limit 20 --cursor <nextCursor>',
343
+ '<%= config.bin %> convos transcript <conversationId> --around latest --limit 20',
344
+ '<%= config.bin %> convos transcript <conversationId> --around <messageId>',
345
+ '<%= config.bin %> convos transcript <conversationId> --turn <messageId>',
346
+ '<%= config.bin %> convos transcript <conversationId> --json',
347
+ ];
348
+ static args = {
349
+ id: core_1.Args.string({ description: 'Conversation ID', required: true, ignoreStdin: true }),
350
+ };
351
+ static flags = {
352
+ json: core_1.Flags.boolean({ description: 'Print the API response as JSON' }),
353
+ turn: core_1.Flags.string({ description: "Print one turn's whole process (the turn's messageId)" }),
354
+ limit: core_1.Flags.integer({
355
+ description: `Items per page (1-${data_provider_1.TURN_TRANSCRIPT_LIMITS.pageMaxItems}). Omit to read the whole session.`,
356
+ }),
357
+ cursor: core_1.Flags.string({
358
+ description: "Cursor from a previous page's nextCursor (newer) or prevCursor (older)",
359
+ exclusive: ['around'],
360
+ }),
361
+ around: core_1.Flags.string({
362
+ description: 'Read one page around an item: `latest` for the newest page, or an item messageId',
363
+ exclusive: ['cursor'],
364
+ }),
365
+ };
366
+ async run() {
367
+ this.requireAuth();
368
+ const { args, flags } = await this.parse(ConvosTranscript);
369
+ if (flags.turn) {
370
+ await this.printTurn(args.id, flags.turn, flags.json);
371
+ return;
372
+ }
373
+ if (flags.limit !== undefined &&
374
+ (flags.limit < 1 || flags.limit > data_provider_1.TURN_TRANSCRIPT_LIMITS.pageMaxItems)) {
375
+ this.error(`--limit must be between 1 and ${data_provider_1.TURN_TRANSCRIPT_LIMITS.pageMaxItems}.`);
376
+ }
377
+ // Without --limit or --around, read on (newer) to the end; otherwise one page.
378
+ const readOn = flags.limit === undefined && flags.around === undefined;
379
+ const pages = [];
380
+ let params = {
381
+ ...(flags.around ? { around: flags.around } : { cursor: flags.cursor ?? null }),
382
+ limit: flags.limit ?? data_provider_1.TURN_TRANSCRIPT_LIMITS.pageMaxItems,
383
+ };
384
+ try {
385
+ for (;;) {
386
+ const page = await data_provider_1.dataService.getConversationTranscript(args.id, params);
387
+ pages.push(page);
388
+ if (!readOn || !page.nextCursor)
389
+ break;
390
+ params = { cursor: page.nextCursor, limit: params.limit };
391
+ }
392
+ }
393
+ catch (err) {
394
+ this.handleApiError(err);
395
+ }
396
+ const first = pages[0];
397
+ const last = pages[pages.length - 1];
398
+ const result = {
399
+ conversationId: last?.conversationId ?? args.id,
400
+ items: pages.flatMap((page) => page.items),
401
+ nextCursor: last?.nextCursor ?? null,
402
+ prevCursor: first?.prevCursor ?? null,
403
+ ...(last?.previousConversationId !== undefined
404
+ ? { previousConversationId: last.previousConversationId }
405
+ : {}),
406
+ };
407
+ if (flags.json) {
408
+ this.log(JSON.stringify(result, null, 2));
409
+ return;
410
+ }
411
+ if (result.items.length === 0) {
412
+ this.log('Nothing in this session yet.');
413
+ }
414
+ for (const item of result.items) {
415
+ for (const line of formatTranscriptItem(item))
416
+ this.log(line);
417
+ }
418
+ const turns = result.items.filter((item) => item.kind === 'turn').length;
419
+ this.log(`\n${result.items.length} item(s), ${turns} turn(s)`);
420
+ if (result.prevCursor)
421
+ this.log(`older: --cursor ${result.prevCursor}`);
422
+ if (result.nextCursor)
423
+ this.log(`newer: --cursor ${result.nextCursor}`);
424
+ if (result.previousConversationId) {
425
+ this.log(`earlier in this chat: skrr convos transcript ${result.previousConversationId}`);
426
+ }
427
+ }
428
+ async printTurn(conversationId, messageId, json) {
429
+ const pages = [];
430
+ let offset = 0;
431
+ try {
432
+ while (offset !== null) {
433
+ const page = await data_provider_1.dataService.getConversationTranscriptTurn(conversationId, messageId, {
434
+ offset,
435
+ limit: data_provider_1.TURN_TRANSCRIPT_LIMITS.turnPageMaxEnvelopes,
436
+ });
437
+ pages.push(page);
438
+ offset = page.nextOffset !== null && page.nextOffset > offset ? page.nextOffset : null;
439
+ }
440
+ }
441
+ catch (err) {
442
+ this.handleApiError(err);
443
+ }
444
+ const first = pages[0];
445
+ const body = {
446
+ ...first,
447
+ offset: 0,
448
+ nextOffset: null,
449
+ ...(first.envelopes ? { envelopes: pages.flatMap((page) => page.envelopes ?? []) } : {}),
450
+ ...(first.content ? { content: pages.flatMap((page) => page.content ?? []) } : {}),
451
+ ...(first.events ? { events: pages.flatMap((page) => page.events ?? []) } : {}),
452
+ };
453
+ if (json) {
454
+ this.log(JSON.stringify(body, null, 2));
455
+ return;
456
+ }
457
+ for (const line of formatTurnBody(body))
458
+ this.log(line);
459
+ }
460
+ }
461
+ exports.default = ConvosTranscript;
@@ -0,0 +1,17 @@
1
+ import { BaseCommand } from '../../base-command';
2
+ export default class DutiesAdvanceNext extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ at: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ confirm: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ fresh: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
+ 'request-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ cancel: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
+ };
16
+ run(): Promise<void>;
17
+ }
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const node_crypto_1 = require("node:crypto");
4
+ const core_1 = require("@oclif/core");
5
+ const base_command_1 = require("../../base-command");
6
+ const duties_1 = require("../../lib/duties");
7
+ const web_url_1 = require("../../lib/web-url");
8
+ class DutiesAdvanceNext extends base_command_1.BaseCommand {
9
+ static description = 'Move one scheduled Duty check earlier and keep the regular cadence';
10
+ static examples = [
11
+ '<%= config.bin %> duties advance-next <duty-id> --at 2026-12-01T04:30:00Z',
12
+ '<%= config.bin %> duties advance-next <duty-id> --at 2026-12-01T04:30:00Z --fresh --confirm',
13
+ '<%= config.bin %> duties advance-next <duty-id> --cancel <advance-id>',
14
+ ];
15
+ static args = {
16
+ id: core_1.Args.string({ description: 'Duty ID', required: true, ignoreStdin: true }),
17
+ };
18
+ static flags = {
19
+ at: core_1.Flags.string({ description: 'Earlier time in ISO 8601 with a timezone' }),
20
+ confirm: core_1.Flags.boolean({ description: 'Schedule the earlier check after checking the current slot' }),
21
+ fresh: core_1.Flags.boolean({ description: 'Request a refresh of declared Agent observations for this Check' }),
22
+ 'request-id': core_1.Flags.string({ description: 'UUID to reuse when retrying a confirmed request' }),
23
+ cancel: core_1.Flags.string({ description: 'Cancel a pending advance by its ID' }),
24
+ json: core_1.Flags.boolean({ description: 'Output as JSON' }),
25
+ };
26
+ async run() {
27
+ this.requireAuth();
28
+ const { args: { id }, flags } = await this.parse(DutiesAdvanceNext);
29
+ if (flags.cancel && (flags.at || flags.confirm || flags.fresh || flags['request-id'])) {
30
+ this.error('Use --cancel by itself.');
31
+ }
32
+ if (((flags.confirm || flags.fresh) && !flags.at) ||
33
+ (flags['request-id'] && !flags.confirm)) {
34
+ this.error('Provide --at with --confirm or --fresh. Use --request-id with --confirm.');
35
+ }
36
+ let result;
37
+ try {
38
+ if (flags.cancel) {
39
+ result = await duties_1.dutyApi.cancelNextCheckAdvance(id, flags.cancel);
40
+ }
41
+ else if (flags['request-id'] && flags.at) {
42
+ const existing = await duties_1.dutyApi.nextCheckAdvance(id);
43
+ if (existing.current?.id !== flags['request-id']) {
44
+ this.error('This request is no longer current. Preview the schedule to start a new advance.');
45
+ }
46
+ if (Date.parse(existing.current.at) !== Date.parse(flags.at) ||
47
+ Boolean(existing.current.verificationVersion) !== Boolean(flags.fresh)) {
48
+ this.error('This request ID already names another change.');
49
+ }
50
+ result = existing;
51
+ }
52
+ else {
53
+ result = await duties_1.dutyApi.nextCheckAdvance(id, flags.at);
54
+ }
55
+ if (result.proposal && flags.fresh && !result.allowsFresh) {
56
+ this.error('Enable a declared Agent observation before requesting fresh evidence.');
57
+ }
58
+ if (flags.confirm && result.proposal) {
59
+ const { at, originalAt, scheduleVersion, previousAdvance } = result.proposal;
60
+ const accepted = await duties_1.dutyApi.advanceNextCheck(id, {
61
+ id: flags['request-id'] || (0, node_crypto_1.randomUUID)(),
62
+ at,
63
+ originalAt,
64
+ scheduleVersion,
65
+ previousAdvance,
66
+ dutyVersion: result.dutyVersion,
67
+ fresh: flags.fresh,
68
+ });
69
+ result = { ...accepted, allowance: result.allowance };
70
+ }
71
+ }
72
+ catch (error) {
73
+ this.handleApiError(error);
74
+ }
75
+ const url = (0, web_url_1.dutyUrlFrom)(this.cliConfig.baseURL, { id });
76
+ if (flags.json) {
77
+ this.log(JSON.stringify({ ...result, url }, null, 2));
78
+ return;
79
+ }
80
+ if (result.proposal) {
81
+ this.log(`Earlier check ${result.proposal.at}`);
82
+ this.log(`Original slot ${result.proposal.originalAt}`);
83
+ this.log(`Following regular check ${result.proposal.nextRegularAt}`);
84
+ this.log(flags.fresh
85
+ ? 'Evidence Fresh declared Agent observations'
86
+ : 'Evidence Use the Duty’s configured evidence');
87
+ }
88
+ if (result.current) {
89
+ const { status, id: advanceId, at, originalAt, occurrenceId, checkId, reason } = result.current;
90
+ this.log(`Advance ${status} (${advanceId})`);
91
+ this.log(`Earlier check ${at}`);
92
+ this.log(`Original slot ${originalAt}`);
93
+ if (result.current.verificationVersion)
94
+ this.log('Evidence Fresh declared Agent observations');
95
+ if (occurrenceId)
96
+ this.log(`Occurrence ${occurrenceId}`);
97
+ if (checkId && url) {
98
+ const receipt = new URL(url);
99
+ receipt.searchParams.set('view', 'activity');
100
+ receipt.searchParams.set('checkId', checkId);
101
+ this.log(`Check receipt ${receipt.toString()}`);
102
+ }
103
+ if (result.current.handoff === 'coalesced' && !checkId) {
104
+ this.log('The wake is recorded for a Duty Check.');
105
+ }
106
+ if (result.current.handoff === 'check_unconfirmed') {
107
+ this.log('The scheduler has a terminal result. A Duty Check receipt is unavailable.');
108
+ }
109
+ if (reason)
110
+ this.log(`Reason ${reason}`);
111
+ }
112
+ else if (!result.proposal) {
113
+ this.log('There is no earlier check scheduled.');
114
+ }
115
+ if (result.allowance?.runsToday != null && result.allowance.maxRunsPerDay != null) {
116
+ this.log(`Agent Runs used today ${result.allowance.runsToday}/${result.allowance.maxRunsPerDay}`);
117
+ }
118
+ if (url)
119
+ this.log(url);
120
+ }
121
+ }
122
+ exports.default = DutiesAdvanceNext;
@@ -7,6 +7,19 @@ const data_provider_1 = require("@skrr-ai/data-provider");
7
7
  const base_command_1 = require("../../../base-command");
8
8
  const prompt_1 = require("../../../lib/prompt");
9
9
  const duties_1 = require("../../../lib/duties");
10
+ function formatVerificationDuration(ms) {
11
+ if (ms > 0) {
12
+ if (ms % 86_400_000 === 0)
13
+ return `${ms / 86_400_000}d`;
14
+ if (ms % 3_600_000 === 0)
15
+ return `${ms / 3_600_000}h`;
16
+ if (ms % 60_000 === 0)
17
+ return `${ms / 60_000}m`;
18
+ if (ms % 1000 === 0)
19
+ return `${ms / 1000}s`;
20
+ }
21
+ return `${ms}ms`;
22
+ }
10
23
  function formatPlanPreview(duty) {
11
24
  if (!duty)
12
25
  return [];
@@ -19,6 +32,38 @@ function formatPlanPreview(duty) {
19
32
  lines.push(`Outcome ${duty.target.outcome}`);
20
33
  if (duty.cadence?.mode)
21
34
  lines.push(`Checks ${(0, duties_1.cadenceLabel)(duty)}`);
35
+ const policy = duty.evaluationPolicy;
36
+ if (policy) {
37
+ const verification = [];
38
+ if (policy.delayMs != null) {
39
+ verification.push(`Initial delay ${formatVerificationDuration(policy.delayMs)}`);
40
+ }
41
+ if (policy.settleDelayMs != null) {
42
+ verification.push(`settling delay ${formatVerificationDuration(policy.settleDelayMs)}`);
43
+ }
44
+ if (policy.maxAttempts != null) {
45
+ verification.push(`up to ${policy.maxAttempts} ${policy.maxAttempts === 1 ? 'attempt' : 'attempts'}`);
46
+ }
47
+ if (verification.length)
48
+ lines.push(`Verification ${verification.join(' · ')}`);
49
+ const evidence = [];
50
+ if (policy.windowMs != null) {
51
+ evidence.push(policy.windowMs === 0
52
+ ? 'No fixed observation window'
53
+ : `Observation window ${formatVerificationDuration(policy.windowMs)}`);
54
+ }
55
+ const freshness = [...new Set([...(policy.criteria || []), ...(policy.guardrails || [])]
56
+ .map((criterion) => criterion.minimumFreshnessMs)
57
+ .filter((value) => typeof value === 'number'))].map(formatVerificationDuration);
58
+ if (freshness.length === 1) {
59
+ evidence.push(`collected within ${freshness[0]} of verification`);
60
+ }
61
+ else if (freshness.length > 1) {
62
+ evidence.push(`collection age limits vary by criterion (${freshness.join(', ')})`);
63
+ }
64
+ if (evidence.length)
65
+ lines.push(`Evidence ${evidence.join(' · ')}`);
66
+ }
22
67
  if (duty.delivery?.mode) {
23
68
  const mode = duty.delivery.mode.replaceAll('_', ' ');
24
69
  const destinations = [...new Set((duty.reports || [])
@@ -34,6 +34,7 @@ type PreflightGate = DutyPreflightReport['gates'][number];
34
34
  export declare function nextRunsLines(report: {
35
35
  verdict?: string;
36
36
  nextRuns?: string[];
37
+ nextRunsSource?: DutyPreflightReport['nextRunsSource'];
37
38
  }, projectedActivation?: boolean): string[];
38
39
  /**
39
40
  * The first line of a preflight. `Ready to run` is a statement about activation (no blocking gate),