@skrr-ai/cli 0.1.232 → 0.1.233

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +29 -13
  2. package/bin/dev.cjs +0 -1
  3. package/bin/run.js +0 -15
  4. package/dist/base-command.d.ts +6 -1
  5. package/dist/base-command.js +24 -4
  6. package/dist/commands/agenda/plan.d.ts +2 -1
  7. package/dist/commands/agenda/plan.js +18 -4
  8. package/dist/commands/agents/chat.d.ts +2 -0
  9. package/dist/commands/agents/chat.js +59 -13
  10. package/dist/commands/agents/eval/list.d.ts +4 -0
  11. package/dist/commands/agents/eval/list.js +33 -0
  12. package/dist/commands/agents/permissions/policy.js +25 -2
  13. package/dist/commands/agents/spawn.js +61 -24
  14. package/dist/commands/agents/triggers/fire.js +1 -1
  15. package/dist/commands/agents/triggers/runs.js +3 -0
  16. package/dist/commands/code/jobs/approve.d.ts +1 -11
  17. package/dist/commands/code/jobs/approve.js +3 -15
  18. package/dist/commands/code/jobs/cancel.js +3 -2
  19. package/dist/commands/code/jobs/index.js +1 -1
  20. package/dist/commands/code/jobs/list.js +4 -11
  21. package/dist/commands/code/jobs/run.js +13 -7
  22. package/dist/commands/code/jobs/show.js +51 -6
  23. package/dist/commands/commands.d.ts +1 -0
  24. package/dist/commands/commands.js +5 -1
  25. package/dist/commands/context.d.ts +1 -0
  26. package/dist/commands/context.js +1 -0
  27. package/dist/commands/duties/catalog/add.d.ts +18 -0
  28. package/dist/commands/duties/catalog/add.js +52 -0
  29. package/dist/commands/duties/catalog/index.d.ts +18 -0
  30. package/dist/commands/duties/catalog/index.js +88 -0
  31. package/dist/commands/duties/receipt.js +56 -1
  32. package/dist/commands/goals/planner-compare.js +5 -3
  33. package/dist/commands/instructions/discovery.d.ts +10 -0
  34. package/dist/commands/instructions/discovery.js +74 -0
  35. package/dist/commands/runs/admission.d.ts +12 -0
  36. package/dist/commands/runs/admission.js +66 -0
  37. package/dist/commands/runs/events.d.ts +2 -0
  38. package/dist/commands/runs/events.js +40 -10
  39. package/dist/commands/runs/list.d.ts +7 -1
  40. package/dist/commands/runs/list.js +81 -17
  41. package/dist/commands/runs/show.d.ts +1 -0
  42. package/dist/commands/runs/show.js +225 -15
  43. package/dist/commands/runs/stop.d.ts +1 -0
  44. package/dist/commands/runs/stop.js +34 -7
  45. package/dist/commands/runs/transcript.d.ts +2 -0
  46. package/dist/commands/runs/transcript.js +102 -17
  47. package/dist/commands/tasks/attachments/download.d.ts +1 -0
  48. package/dist/commands/tasks/attachments/download.js +6 -4
  49. package/dist/commands/tasks/attachments/source.d.ts +6 -0
  50. package/dist/commands/tasks/attachments/source.js +18 -0
  51. package/dist/commands/tasks/chat/exchange.d.ts +0 -14
  52. package/dist/commands/tasks/chat/exchange.js +8 -39
  53. package/dist/commands/tasks/chat/reply-run.d.ts +15 -0
  54. package/dist/commands/tasks/chat/reply-run.js +69 -0
  55. package/dist/commands/tasks/complete.js +1 -1
  56. package/dist/commands/tasks/lifecycle/transition.d.ts +1 -0
  57. package/dist/commands/tasks/lifecycle/transition.js +51 -13
  58. package/dist/commands/tasks/operations/show.js +5 -0
  59. package/dist/commands/tasks/result/submit.js +4 -2
  60. package/dist/commands/tasks/retry.js +25 -16
  61. package/dist/commands/triggers/audit.js +3 -1
  62. package/dist/commands/triggers/fire-detail.js +4 -1
  63. package/dist/commands/triggers/fire.js +1 -1
  64. package/dist/commands/usage.d.ts +1 -0
  65. package/dist/commands/usage.js +1 -0
  66. package/dist/generated/agent-guides.json +64 -712
  67. package/dist/help.d.ts +2 -7
  68. package/dist/help.js +13 -7
  69. package/dist/hooks/init.js +10 -0
  70. package/dist/lib/agent-evals.d.ts +1 -1
  71. package/dist/lib/agent-evals.js +13 -3
  72. package/dist/lib/agent-guides.d.ts +3 -5
  73. package/dist/lib/agent-guides.js +12 -13
  74. package/dist/lib/agent-runs.d.ts +69 -9
  75. package/dist/lib/agent-runs.js +208 -35
  76. package/dist/lib/agentic-stream.d.ts +12 -0
  77. package/dist/lib/agentic-stream.js +163 -79
  78. package/dist/lib/api-fetch.d.ts +2 -0
  79. package/dist/lib/api-fetch.js +6 -1
  80. package/dist/lib/command-manifest.d.ts +1 -6
  81. package/dist/lib/command-manifest.js +86 -13
  82. package/dist/lib/config.d.ts +2 -3
  83. package/dist/lib/config.js +2 -3
  84. package/dist/lib/duties.d.ts +5 -1
  85. package/dist/lib/duties.js +4 -0
  86. package/dist/lib/execution-history.d.ts +3 -0
  87. package/dist/lib/format.d.ts +1 -0
  88. package/dist/lib/format.js +18 -0
  89. package/dist/lib/guide-pointer.d.ts +5 -1
  90. package/dist/lib/guide-pointer.js +21 -2
  91. package/dist/lib/hosted-job-status.d.ts +4 -0
  92. package/dist/lib/hosted-job-status.js +19 -0
  93. package/dist/lib/inbound-messages.d.ts +1 -0
  94. package/dist/lib/inbound-messages.js +2 -0
  95. package/dist/lib/roles.d.ts +2 -2
  96. package/dist/lib/schedule.d.ts +4 -0
  97. package/dist/lib/schedule.js +4 -3
  98. package/dist/lib/task-execution.d.ts +1 -1
  99. package/dist/lib/task-execution.js +3 -19
  100. package/dist/lib/task-extras.d.ts +11 -1
  101. package/dist/lib/task-extras.js +15 -1
  102. package/dist/lib/task-transcript.js +3 -8
  103. package/dist/lib/triggers.d.ts +5 -36
  104. package/dist/lib/triggers.js +48 -33
  105. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonWire.js +5 -1
  106. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/harnessCommand.d.ts +37 -0
  107. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/harnessCommand.js +59 -0
  108. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonWire.js +5 -1
  109. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/harnessCommand.d.ts +37 -0
  110. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/harnessCommand.js +57 -0
  111. package/dist/node_modules/@skrr-ai/auth-core/package.json +10 -0
  112. package/dist/node_modules/@skrr-ai/data-provider/index.js +12261 -12172
  113. package/docs/v1/quickstart.md +18 -0
  114. package/oclif.manifest.json +2505 -629
  115. package/package.json +3 -2
  116. package/skills/skrr/SKILL.md +14 -0
  117. package/dist/commands/triggers/runs.d.ts +0 -22
  118. package/dist/commands/triggers/runs.js +0 -58
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const auth_core_1 = require("@skrr-ai/auth-core");
3
4
  const node_util_1 = require("node:util");
4
5
  const core_1 = require("@oclif/core");
5
6
  const data_provider_1 = require("@skrr-ai/data-provider");
@@ -8,6 +9,8 @@ const agent_runs_1 = require("../../lib/agent-runs");
8
9
  const communication_history_1 = require("../../lib/communication-history");
9
10
  const execution_history_1 = require("../../lib/execution-history");
10
11
  const search_display_1 = require("../../lib/search-display");
12
+ const keychain_1 = require("../../lib/keychain");
13
+ const shell_quote_1 = require("../../lib/shell-quote");
11
14
  const availability = {
12
15
  available: 'Transcript available',
13
16
  partial: 'Partial transcript',
@@ -24,6 +27,7 @@ class RunsTranscript extends base_command_1.BaseCommand {
24
27
  static examples = [
25
28
  '<%= config.bin %> runs transcript <run-id> --attempt <attempt-id>',
26
29
  '<%= config.bin %> runs transcript <run-id> --attempt <attempt-id> --offset 50 --json',
30
+ '<%= config.bin %> runs transcript <run-id> --attempt <attempt-id> --after=<resume-cursor>',
27
31
  ];
28
32
  static args = { runId: agent_runs_1.runIdArgument };
29
33
  static flags = {
@@ -32,19 +36,46 @@ class RunsTranscript extends base_command_1.BaseCommand {
32
36
  description: 'Start at this offset (default 0). Use the next offset returned by the previous page.',
33
37
  min: 0,
34
38
  max: Number.MAX_SAFE_INTEGER,
35
- exclusive: ['cursor'],
39
+ exclusive: ['after', 'cursor'],
40
+ }),
41
+ after: core_1.Flags.string({
42
+ description: 'Continue forward from the resume cursor returned for this exact Attempt',
43
+ exclusive: ['offset', 'cursor'],
44
+ parse: async (value) => {
45
+ if (!(0, search_display_1.isPrintableSearchCursor)(value))
46
+ throw new Error('Expected a printable transcript resume cursor.');
47
+ return value;
48
+ },
36
49
  }),
37
50
  cursor: core_1.Flags.string({ description: 'Read the next older window in an Agent session' }),
38
51
  limit: core_1.Flags.integer({ description: 'Maximum items (1–100 for people, 1–8 for Agent sessions, default 6 for sessions)', min: 1, max: 100 }),
39
- json: core_1.Flags.boolean({ description: 'Output the transcript page as JSON' }),
52
+ json: core_1.Flags.boolean({ description: 'Output the transcript page and any continuation argv as JSON' }),
53
+ personal: core_1.Flags.boolean({
54
+ description: 'Read only in personal scope, ignoring the saved workspace.',
55
+ exclusive: ['workspace'],
56
+ }),
40
57
  };
41
58
  async run() {
42
59
  const { args: { runId }, flags } = await this.parse(RunsTranscript);
43
60
  const session = (0, communication_history_1.resolveHistorySession)(() => this.requireAuth());
44
- const { attempt, offset, limit, cursor } = flags;
45
- if ((session && offset !== undefined) || (!session && cursor !== undefined)) {
46
- this.failWithCliError({ code: 'HISTORY_FILTER_CONFLICT', message: 'Use --cursor in a bound Agent session and --offset in a human session.', exit: 2, retryable: false });
61
+ const { attempt, offset, after, limit, cursor, personal } = flags;
62
+ if ((session && (offset !== undefined || after !== undefined || personal)) || (!session && cursor !== undefined)) {
63
+ this.failWithCliError({
64
+ code: 'HISTORY_FILTER_CONFLICT',
65
+ message: session && personal
66
+ ? 'A bound Agent session uses its own workspace scope.'
67
+ : 'Use --cursor in a bound Agent session. Use --after or --offset in a human session.',
68
+ exit: 2,
69
+ retryable: false,
70
+ });
47
71
  }
72
+ const transcriptArgv = (workspaceId, position = []) => [
73
+ this.config.bin, 'runs', 'transcript', runId, '--attempt', attempt,
74
+ ...position,
75
+ ...(limit === undefined ? [] : ['--limit', String(limit)]),
76
+ ...(0, agent_runs_1.runReadScopeArgs)(workspaceId),
77
+ ...(0, auth_core_1.explicitProfileArgs)((0, keychain_1.profileForChildProcess)()),
78
+ ];
48
79
  try {
49
80
  if (session) {
50
81
  const page = await (0, execution_history_1.readExecutionHistory)(session.sessionId, 'transcript', { runId, attempt, limit, cursor });
@@ -60,32 +91,86 @@ class RunsTranscript extends base_command_1.BaseCommand {
60
91
  }
61
92
  return;
62
93
  }
63
- const page = await (0, agent_runs_1.readAgentRunTranscript)(runId, flags);
94
+ const { page, workspaceId } = await (0, agent_runs_1.readAgentRunTranscript)(runId, flags);
95
+ const { body } = page;
96
+ let continuation;
97
+ if (typeof body?.resumeCursor === 'string' && (0, search_display_1.isPrintableSearchCursor)(body.resumeCursor)) {
98
+ continuation = { label: 'Resume forward', argv: transcriptArgv(workspaceId, [`--after=${body.resumeCursor}`]) };
99
+ }
100
+ else if (after === undefined && typeof body?.nextOffset === 'number' &&
101
+ Number.isSafeInteger(body.nextOffset) && body.nextOffset > (offset ?? 0)) {
102
+ continuation = { label: 'Next page', argv: transcriptArgv(workspaceId, ['--offset', String(body.nextOffset)]) };
103
+ }
64
104
  if (flags.json) {
65
- this.log(JSON.stringify(page, null, 2));
105
+ this.log(JSON.stringify(continuation
106
+ ? { ...page, continuation: { argv: [...continuation.argv, '--json'] } }
107
+ : page, null, 2));
66
108
  return;
67
109
  }
68
110
  this.log(`Run ${runId}`);
69
111
  this.log(`Attempt ${attempt}`);
70
- this.log(page.availability === 'partial' && page.coverage === 'result_only'
71
- ? 'Saved result only'
72
- : availability[page.availability]);
73
- const { body } = page;
112
+ let status = availability[page.availability];
113
+ if (page.availability === 'partial' && page.coverage === 'result_only')
114
+ status = 'Saved result only';
115
+ if (page.availability === 'unavailable' && page.unavailableReason === 'recorded_without_reply') {
116
+ status = 'This Duty recorded its result without publishing a reply.';
117
+ }
118
+ this.log(status);
74
119
  if (!body)
75
120
  return;
121
+ // Hosted Job Attempt pages may return the exact envelopes without a kind.
122
+ const envelopePage = page.kind === 'envelopes' || (page.kind === undefined && body.source === undefined && body.content === undefined &&
123
+ body.events === undefined && Array.isArray(body.envelopes));
124
+ const showFailures = envelopePage &&
125
+ (page.availability === 'available' || page.availability === 'partial');
76
126
  for (const row of (0, data_provider_1.buildEnvelopeRows)(body.envelopes ?? [])) {
77
- if (row.kind === 'answer')
127
+ if (row.kind === 'answer') {
78
128
  this.log(terminalText(row.text));
129
+ continue;
130
+ }
131
+ if (!showFailures || row.kind !== 'delegated')
132
+ continue;
133
+ const envelope = row.render.at(-1);
134
+ const event = envelope?.ev;
135
+ if (envelope?.role !== 'agent' || envelope.subagent || event?.t !== 'turn-end' ||
136
+ event.status !== 'failed' || typeof event.error !== 'string')
137
+ continue;
138
+ const reason = terminalText(event.error);
139
+ if (reason.trim())
140
+ this.log(`Failure reason ${reason}`);
141
+ }
142
+ if (page.kind === 'conversation' && body.source === 'imported' &&
143
+ (page.availability === 'available' || page.availability === 'partial') &&
144
+ Array.isArray(body.events)) {
145
+ for (const event of body.events) {
146
+ if (event?.role !== 'assistant' || !Array.isArray(event.blocks))
147
+ continue;
148
+ for (const block of event.blocks) {
149
+ if (block?.kind === 'text' && typeof block.text === 'string') {
150
+ this.log(terminalText(block.text));
151
+ }
152
+ }
153
+ }
79
154
  }
80
155
  const count = (body.envelopes?.length ?? 0) + (body.content?.length ?? 0) + (body.events?.length ?? 0);
81
156
  this.log(`${count} ${count === 1 ? 'item' : 'items'} on this page. Use --json to read the full page.`);
82
- const next = body.nextOffset;
83
- if (typeof next === 'number' && Number.isSafeInteger(next) && next > (offset ?? 0)) {
84
- const pageSize = limit === undefined ? '' : ` --limit ${limit}`;
85
- this.log(`Next page ${this.config.bin} runs transcript ${runId} --attempt ${attempt} --offset ${next}${pageSize}`);
86
- }
157
+ if (body.resumePending)
158
+ this.log('Some later transcript items are still unverified.');
159
+ if (continuation)
160
+ this.log(`${continuation.label} ${(0, shell_quote_1.shellQuoteArgv)(continuation.argv)}`);
87
161
  }
88
162
  catch (error) {
163
+ if (error instanceof agent_runs_1.RunTranscriptCursorInvalidError) {
164
+ const command = (0, shell_quote_1.shellQuoteArgv)(transcriptArgv(error.workspaceId));
165
+ this.failWithCliError({
166
+ code: 'INVALID_RUN_TRANSCRIPT_CURSOR',
167
+ message: `The transcript cursor expired or is no longer valid. Review the same Attempt from its first page with ${command}.`,
168
+ status: 400,
169
+ exit: 1,
170
+ retryable: false,
171
+ details: { command, ...(error.workspaceId ? { workspaceId: error.workspaceId } : {}) },
172
+ });
173
+ }
89
174
  this.handleApiError(error);
90
175
  }
91
176
  }
@@ -10,5 +10,6 @@ export default class TasksAttachmentsDownload extends BaseCommand {
10
10
  out: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
11
11
  json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
12
  };
13
+ protected readAttachment(taskId: string, attachmentId: string): Promise<Uint8Array>;
13
14
  run(): Promise<void>;
14
15
  }
@@ -56,6 +56,9 @@ class TasksAttachmentsDownload extends base_command_1.BaseCommand {
56
56
  description: 'Print {path, bytes} as JSON after writing a file (not valid with --out -)',
57
57
  }),
58
58
  };
59
+ async readAttachment(taskId, attachmentId) {
60
+ return new Uint8Array(await data_provider_1.dataService.downloadTaskAttachment(taskId, attachmentId));
61
+ }
59
62
  async run() {
60
63
  this.requireAuth();
61
64
  const { args, flags } = await this.parse(TasksAttachmentsDownload);
@@ -65,16 +68,15 @@ class TasksAttachmentsDownload extends base_command_1.BaseCommand {
65
68
  exit: 2,
66
69
  });
67
70
  }
68
- let buffer;
71
+ let bytes;
69
72
  try {
70
- buffer = await data_provider_1.dataService.downloadTaskAttachment(taskRef, args.attachmentId);
73
+ bytes = await this.readAttachment(taskRef, args.attachmentId);
71
74
  }
72
75
  catch (err) {
73
76
  this.handleApiError(err);
74
77
  }
75
- if (!buffer)
78
+ if (!bytes)
76
79
  return;
77
- const bytes = Buffer.from(buffer);
78
80
  if (flags.out === '-') {
79
81
  process.stdout.write(bytes);
80
82
  }
@@ -0,0 +1,6 @@
1
+ import TasksAttachmentsDownload from './download';
2
+ export default class TasksAttachmentsSource extends TasksAttachmentsDownload {
3
+ static description: string;
4
+ static examples: string[];
5
+ protected readAttachment(taskId: string, attachmentId: string): Promise<Uint8Array>;
6
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const task_extras_1 = require("../../../lib/task-extras");
7
+ const download_1 = __importDefault(require("./download"));
8
+ class TasksAttachmentsSource extends download_1.default {
9
+ static description = 'Read the authenticated source bytes of a task attachment';
10
+ static examples = [
11
+ '<%= config.bin %> tasks attachments source <task-id> <attachment-id> --out ./source.txt',
12
+ '<%= config.bin %> tasks attachments source <task-id> <attachment-id> --out -',
13
+ ];
14
+ readAttachment(taskId, attachmentId) {
15
+ return (0, task_extras_1.readTaskAttachmentSource)(taskId, attachmentId);
16
+ }
17
+ }
18
+ exports.default = TasksAttachmentsSource;
@@ -1,16 +1,4 @@
1
1
  import { BaseCommand } from '../../../base-command';
2
- /**
3
- * `skrr tasks chat exchange <task-id> <exchange-id> --close-input|--cancel|--interrupt`
4
- *
5
- * The three ways an in-flight exchange can be steered, and they are genuinely
6
- * different:
7
- *
8
- * --close-input stop collecting more user messages into this exchange; the
9
- * agent responds to what it already has.
10
- * --interrupt inject --text into the RUNNING response; the server refuses an
11
- * interrupt that carries no text.
12
- * --cancel terminate the exchange.
13
- */
14
2
  export default class TasksChatExchange extends BaseCommand {
15
3
  static description: string;
16
4
  static examples: string[];
@@ -21,9 +9,7 @@ export default class TasksChatExchange extends BaseCommand {
21
9
  static flags: {
22
10
  json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
23
11
  'close-input': import("@oclif/core/interfaces").BooleanFlag<boolean>;
24
- interrupt: import("@oclif/core/interfaces").BooleanFlag<boolean>;
25
12
  cancel: import("@oclif/core/interfaces").BooleanFlag<boolean>;
26
- text: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
27
13
  reason: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
28
14
  'command-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
29
15
  };
@@ -4,25 +4,12 @@ const node_crypto_1 = require("node:crypto");
4
4
  const core_1 = require("@oclif/core");
5
5
  const base_command_1 = require("../../../base-command");
6
6
  const task_extras_1 = require("../../../lib/task-extras");
7
- /**
8
- * `skrr tasks chat exchange <task-id> <exchange-id> --close-input|--cancel|--interrupt`
9
- *
10
- * The three ways an in-flight exchange can be steered, and they are genuinely
11
- * different:
12
- *
13
- * --close-input stop collecting more user messages into this exchange; the
14
- * agent responds to what it already has.
15
- * --interrupt inject --text into the RUNNING response; the server refuses an
16
- * interrupt that carries no text.
17
- * --cancel terminate the exchange.
18
- */
19
7
  class TasksChatExchange extends base_command_1.BaseCommand {
20
- static description = 'Close input on, interrupt, or cancel a task chat exchange';
8
+ static description = 'Close input on or cancel a task chat exchange. ' +
9
+ 'Send new text with `tasks chat send` or `tasks continue`. Stop the current run with `tasks interrupt`.';
21
10
  static examples = [
22
11
  '<%= config.bin %> tasks chat exchange task_abc ex_123 --close-input',
23
- '<%= config.bin %> tasks chat exchange task_abc ex_123 --interrupt --text "stop, wrong file; use src/a.ts"',
24
12
  '<%= config.bin %> tasks chat exchange task_abc ex_123 --cancel --reason "wrong file"',
25
- '<%= config.bin %> tasks chat exchange task_abc ex_123 --cancel',
26
13
  ];
27
14
  static args = {
28
15
  id: core_1.Args.string({ ignoreStdin: true, description: 'Task ID', required: true }),
@@ -32,22 +19,14 @@ class TasksChatExchange extends base_command_1.BaseCommand {
32
19
  json: core_1.Flags.boolean({ description: 'Output as JSON' }),
33
20
  'close-input': core_1.Flags.boolean({
34
21
  description: 'Stop collecting input; respond to what is already there',
35
- exclusive: ['cancel', 'interrupt'],
36
- }),
37
- interrupt: core_1.Flags.boolean({
38
- description: 'Inject --text into the running response',
39
- exclusive: ['cancel', 'close-input'],
22
+ exclusive: ['cancel'],
40
23
  }),
41
24
  cancel: core_1.Flags.boolean({
42
25
  description: 'Terminate the exchange',
43
- exclusive: ['interrupt', 'close-input'],
44
- }),
45
- text: core_1.Flags.string({
46
- description: 'What to tell the running response (required with --interrupt)',
47
- dependsOn: ['interrupt'],
26
+ exclusive: ['close-input'],
48
27
  }),
49
28
  reason: core_1.Flags.string({
50
- description: 'Why the exchange is cancelled (--cancel only; the other two record none)',
29
+ description: 'Why the exchange is cancelled (--cancel only)',
51
30
  dependsOn: ['cancel'],
52
31
  }),
53
32
  'command-id': core_1.Flags.string({
@@ -57,11 +36,8 @@ class TasksChatExchange extends base_command_1.BaseCommand {
57
36
  async run() {
58
37
  this.requireAuth();
59
38
  const { args, flags } = await this.parse(TasksChatExchange);
60
- if (!flags['close-input'] && !flags.interrupt && !flags.cancel) {
61
- this.error('Pass --close-input, --interrupt, or --cancel.');
62
- }
63
- if (flags.interrupt && !flags.text?.trim()) {
64
- this.error('--interrupt needs --text: the server injects it into the running response.');
39
+ if (!flags['close-input'] && !flags.cancel) {
40
+ this.error('Pass --close-input or --cancel.');
65
41
  }
66
42
  const taskId = await this.resolveTaskReference(args.id);
67
43
  // Every mutation on this surface requires an actor-scoped command id; the
@@ -70,15 +46,12 @@ class TasksChatExchange extends base_command_1.BaseCommand {
70
46
  const commandId = flags['command-id'] ?? `cli-${(0, node_crypto_1.randomUUID)()}`;
71
47
  const body = {
72
48
  commandId,
73
- ...(flags.interrupt ? { text: flags.text } : {}),
74
49
  ...(flags.cancel && flags.reason ? { reason: flags.reason } : {}),
75
50
  };
76
51
  let result;
77
52
  try {
78
53
  if (flags['close-input'])
79
54
  result = await task_extras_1.taskChatApi.closeInput(taskId, args.exchangeId, body);
80
- else if (flags.interrupt)
81
- result = await task_extras_1.taskChatApi.interruptExchange(taskId, args.exchangeId, body);
82
55
  else
83
56
  result = await task_extras_1.taskChatApi.cancelExchange(taskId, args.exchangeId, body);
84
57
  }
@@ -89,11 +62,7 @@ class TasksChatExchange extends base_command_1.BaseCommand {
89
62
  this.log(JSON.stringify(result, null, 2));
90
63
  return;
91
64
  }
92
- const verb = flags['close-input']
93
- ? 'input closed'
94
- : flags.interrupt
95
- ? 'interrupted'
96
- : 'cancelled';
65
+ const verb = flags['close-input'] ? 'input closed' : 'cancelled';
97
66
  this.log(`${args.exchangeId} ${verb}.`);
98
67
  }
99
68
  }
@@ -0,0 +1,15 @@
1
+ import { BaseCommand } from '../../../base-command';
2
+ export default class TasksChatReplyRun 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
+ conversationId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
8
+ messageId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
9
+ };
10
+ static flags: {
11
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
+ personal: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
+ };
14
+ run(): Promise<void>;
15
+ }
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const auth_core_1 = require("@skrr-ai/auth-core");
5
+ const base_command_1 = require("../../../base-command");
6
+ const agent_runs_1 = require("../../../lib/agent-runs");
7
+ const keychain_1 = require("../../../lib/keychain");
8
+ const shell_quote_1 = require("../../../lib/shell-quote");
9
+ const task_extras_1 = require("../../../lib/task-extras");
10
+ class TasksChatReplyRun extends base_command_1.BaseCommand {
11
+ static description = 'Find the exact Run and Attempt that produced a Task Chat reply';
12
+ static examples = [
13
+ '<%= config.bin %> tasks chat reply-run <task-id> <conversation-id> <reply-message-id>',
14
+ '<%= config.bin %> tasks chat reply-run <task-id> <conversation-id> <reply-message-id> --personal --json',
15
+ ];
16
+ static args = {
17
+ id: core_1.Args.string({ description: 'Task ID', required: true, ignoreStdin: true }),
18
+ conversationId: core_1.Args.string({ description: 'Task Chat conversation ID', required: true, ignoreStdin: true }),
19
+ messageId: core_1.Args.string({ description: 'Assistant reply message ID', required: true, ignoreStdin: true }),
20
+ };
21
+ static flags = {
22
+ json: core_1.Flags.boolean({ description: 'Output as JSON with an inspection argument array' }),
23
+ personal: core_1.Flags.boolean({
24
+ description: 'Read a personal Task reply, ignoring the saved workspace.',
25
+ exclusive: ['workspace'],
26
+ }),
27
+ };
28
+ async run() {
29
+ const { args, flags } = await this.parse(TasksChatReplyRun);
30
+ this.requireAuth();
31
+ const taskId = await this.resolveTaskReference(args.id, flags.personal ? task_extras_1.listPersonalTaskTitleCandidates : undefined);
32
+ try {
33
+ const reference = await task_extras_1.taskChatApi.replyRun(taskId, args.conversationId, args.messageId, flags.personal ? { workspaceScope: 'personal' } : undefined);
34
+ const runId = (0, agent_runs_1.canonicalRunId)(reference?.id);
35
+ if (!runId || typeof reference.attemptId !== 'string') {
36
+ throw new Error('The server did not provide a canonical Task Chat reply Run and Attempt.');
37
+ }
38
+ const attemptId = (0, agent_runs_1.exactAttemptId)(reference.attemptId);
39
+ const workspaceId = reference.runHistoryWorkspaceId;
40
+ if (flags.personal && workspaceId !== null) {
41
+ throw new Error('The server did not confirm that this Task Chat reply belongs to personal scope.');
42
+ }
43
+ const scope = workspaceId === null ? ['--personal'] :
44
+ typeof workspaceId === 'string' && workspaceId.trim() ? ['--workspace', workspaceId] : null;
45
+ const inspection = scope && [
46
+ this.config.bin, 'runs', 'show', runId, ...scope, ...(0, auth_core_1.explicitProfileArgs)((0, keychain_1.profileForChildProcess)()),
47
+ ];
48
+ if (flags.json) {
49
+ this.printJsonResult({
50
+ id: runId,
51
+ attemptId,
52
+ ...(inspection ? {
53
+ runHistoryWorkspaceId: workspaceId,
54
+ inspection: { argv: [...inspection, '--json'] },
55
+ } : {}),
56
+ });
57
+ return;
58
+ }
59
+ this.log(`Run ${runId}`);
60
+ this.log(`Attempt ${attemptId}`);
61
+ if (inspection)
62
+ this.log(`Run History ${(0, shell_quote_1.shellQuoteArgv)(inspection)}`);
63
+ }
64
+ catch (error) {
65
+ this.handleApiError(error);
66
+ }
67
+ }
68
+ }
69
+ exports.default = TasksChatReplyRun;
@@ -60,7 +60,7 @@ function describePendingReview({ statusType, taskId, resultId, bin, advisories,
60
60
  }
61
61
  class TasksComplete extends base_command_1.BaseCommand {
62
62
  static autonomousCredentialPolicy = 'bound-session';
63
- static description = 'Submit one versioned Result and advance the Task workflow';
63
+ static description = 'Submit a versioned Result and advance the Task workflow, including required independent review';
64
64
  static examples = [
65
65
  '<%= config.bin %> tasks complete <task> --summary "Implemented and verified the fix" --deliverable <resource-link-id>',
66
66
  '<%= config.bin %> tasks complete <task> --summary "Do not ship" --conclusion-type release_recommendation --conclusion-json \'{"posture":"no_ship"}\'',
@@ -1,5 +1,6 @@
1
1
  import { BaseCommand } from '../../../base-command';
2
2
  export default class TasksLifecycleTransition extends BaseCommand {
3
+ static autonomousCredentialPolicy: "scoped-task-operation";
3
4
  static description: string;
4
5
  static args: {
5
6
  id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
@@ -3,9 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
4
  const data_provider_1 = require("@skrr-ai/data-provider");
5
5
  const base_command_1 = require("../../../base-command");
6
+ const api_fetch_1 = require("../../../lib/api-fetch");
7
+ const credential_resolver_1 = require("../../../lib/credential-resolver");
6
8
  const task_lifecycle_output_1 = require("../../../lib/task-lifecycle-output");
9
+ const task_ref_resolver_1 = require("../../../lib/task-ref-resolver");
7
10
  const prompt_1 = require("../../../lib/prompt");
11
+ const session_task_endpoints_1 = require("../../../lib/session-task-endpoints");
8
12
  class TasksLifecycleTransition extends base_command_1.BaseCommand {
13
+ static autonomousCredentialPolicy = 'scoped-task-operation';
9
14
  static description = 'Apply a declared lifecycle transition — records effects and advances the stage';
10
15
  static args = {
11
16
  id: core_1.Args.string({ required: true, ignoreStdin: true, description: 'Task ID' }),
@@ -30,7 +35,6 @@ class TasksLifecycleTransition extends base_command_1.BaseCommand {
30
35
  async run() {
31
36
  this.requireAuth();
32
37
  const { args, flags } = await this.parse(TasksLifecycleTransition);
33
- const taskId = await this.resolveTaskReference(args.id);
34
38
  let payload;
35
39
  if (flags.payload) {
36
40
  try {
@@ -45,6 +49,31 @@ class TasksLifecycleTransition extends base_command_1.BaseCommand {
45
49
  this.error('--payload must be a JSON object.', { exit: 2 });
46
50
  }
47
51
  }
52
+ const credential = process.env.OVERSKY_SCOPED_TASK_OPERATIONS === '1'
53
+ ? (0, credential_resolver_1.resolveTrustedAutonomousCredential)()
54
+ : null;
55
+ const sessionId = process.env.OVERSKY_SESSION_ID?.trim();
56
+ if (credential && (!credential.token?.startsWith('agst_') || !sessionId)) {
57
+ this.failWithCliError({
58
+ message: 'Lifecycle transitions require this runtime’s bound Task session credential.',
59
+ code: 'SESSION_TASK_CREDENTIAL_MISSING',
60
+ exit: 2,
61
+ retryable: false,
62
+ });
63
+ }
64
+ const scoped = credential && sessionId ? { credential, sessionId } : null;
65
+ const boundTask = scoped
66
+ ? await (0, api_fetch_1.apiFetch)(`/api/agentic/sessions/${encodeURIComponent(scoped.sessionId)}/task`, { credential: scoped.credential }).catch((error) => this.handleApiError(error))
67
+ : null;
68
+ if (scoped && (!boundTask?.id || !(0, session_task_endpoints_1.requestMatchesBoundTask)(boundTask, args.id))) {
69
+ this.failWithCliError({
70
+ message: `This session cannot transition the requested Task ${args.id}.`,
71
+ code: 'SESSION_SCOPE_TASK_MISMATCH',
72
+ exit: 2,
73
+ retryable: false,
74
+ });
75
+ }
76
+ const taskId = boundTask?.id ?? await this.resolveTaskReference(args.id);
48
77
  /*
49
78
  * The fence only protects the interval it is given.
50
79
  *
@@ -64,32 +93,41 @@ class TasksLifecycleTransition extends base_command_1.BaseCommand {
64
93
  */
65
94
  let expectedRevision = flags['expected-revision'];
66
95
  if (expectedRevision === undefined) {
67
- let current;
96
+ let lifecycle;
68
97
  try {
69
- current = await data_provider_1.dataService.getTaskLifecycle(taskId);
98
+ lifecycle = scoped ? boundTask?.lifecycle : (await data_provider_1.dataService.getTaskLifecycle(taskId)).lifecycle;
70
99
  }
71
100
  catch (error) {
72
101
  this.handleApiError(error);
73
102
  }
74
- if (!current.lifecycle) {
103
+ if (!lifecycle) {
75
104
  this.error('No lifecycle is attached to this Task.', { exit: 2 });
76
105
  }
77
- expectedRevision = current.lifecycle.revision;
106
+ expectedRevision = lifecycle.revision;
78
107
  if (!flags.json) {
79
108
  this.log(`Fencing on revision ${expectedRevision}, read just now — not the revision you saw. ` +
80
109
  'Pass --expected-revision <n> to fence on the state you decided against.');
81
110
  }
82
111
  }
83
- const idempotencyKey = flags['idempotency-key'] ?? `cli-lifecycle:${taskId}:${args.transition}:r${expectedRevision}`;
112
+ // A reference keeps its original receipt key when a retry uses a scoped credential.
113
+ const receiptTaskRef = scoped ? ((0, task_ref_resolver_1.directTaskRef)(args.id) ?? taskId) : taskId;
114
+ const idempotencyKey = flags['idempotency-key'] ?? `cli-lifecycle:${receiptTaskRef}:${args.transition}:r${expectedRevision}`;
115
+ const body = {
116
+ transitionId: args.transition,
117
+ idempotencyKey,
118
+ expectedRevision,
119
+ ...(payload ? { payload } : {}),
120
+ };
84
121
  let response;
85
122
  try {
86
- response = await data_provider_1.dataService.transitionTaskLifecycle({
87
- taskId,
88
- transitionId: args.transition,
89
- idempotencyKey,
90
- expectedRevision,
91
- ...(payload ? { payload } : {}),
92
- });
123
+ response = scoped
124
+ ? await (0, api_fetch_1.apiFetch)(`/api/tasks/${encodeURIComponent(taskId)}/lifecycle/transitions`, {
125
+ credential: scoped.credential,
126
+ method: 'POST',
127
+ headers: { 'X-Oversky-Session-Id': scoped.sessionId },
128
+ body,
129
+ })
130
+ : await data_provider_1.dataService.transitionTaskLifecycle({ taskId, ...body });
93
131
  }
94
132
  catch (error) {
95
133
  this.handleApiError(error);
@@ -89,6 +89,11 @@ class TasksOperationsShow extends base_command_1.BaseCommand {
89
89
  }
90
90
  if (operation.provenance.code)
91
91
  this.log(`Observation: ${operation.provenance.code}`);
92
+ if (operation.intent === 'retry' && operation.state === 'refused' && operation.terminal &&
93
+ operation.provenance.code === 'TASK_RETRY_HANDOFF_CHANGED') {
94
+ this.log('The status transition was saved. The Task changed before dispatch, so no Run was admitted for this retry. Use execution-state for the current Task.');
95
+ return;
96
+ }
92
97
  this.log(operation.recovery.disposition === 'do_not_resend'
93
98
  ? 'This operation is not confirmed. Do not resend it; inspect the same operation or execution state.'
94
99
  : 'This is inspect-only. Use execution-state for current execution authority.');
@@ -23,7 +23,7 @@ function parseJson(value, label) {
23
23
  }
24
24
  class TasksResultSubmit extends base_command_1.BaseCommand {
25
25
  static autonomousCredentialPolicy = 'bound-session';
26
- static description = 'Submit the Task Result; this does not self-accept it or turn a domain conclusion into a Review';
26
+ static description = 'Record a Task Result. To finish work and advance the Task into any required Review, use tasks complete';
27
27
  static examples = [
28
28
  '<%= config.bin %> tasks result submit <task> --summary "NO-SHIP until Gates A-D pass" --conclusion-type release_recommendation --conclusion-json \'{"posture":"no_ship"}\'',
29
29
  ];
@@ -33,7 +33,9 @@ class TasksResultSubmit extends base_command_1.BaseCommand {
33
33
  static flags = {
34
34
  task: core_1.Flags.string({ description: 'Task id; overrides runtime context' }),
35
35
  summary: core_1.Flags.string({ required: true, description: 'The answer in one readable paragraph' }),
36
- 'request-completion': core_1.Flags.boolean({ description: 'Request workflow completion after the active Task Run ends' }),
36
+ 'request-completion': core_1.Flags.boolean({
37
+ description: 'Request workflow completion after the Run ends. Use from the current Agent work Run once the full Task is finished.',
38
+ }),
37
39
  body: core_1.Flags.string({ description: 'Long-form Result body' }),
38
40
  'conclusion-type': core_1.Flags.string({ description: 'Domain conclusion type' }),
39
41
  'conclusion-json': core_1.Flags.string({ description: 'JSON value for the domain conclusion' }),