@skrr-ai/cli 0.1.231 → 0.1.233

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/README.md +42 -4
  2. package/bin/dev.cjs +4 -1
  3. package/bin/run.js +0 -15
  4. package/dist/base-command.d.ts +6 -11
  5. package/dist/base-command.js +34 -43
  6. package/dist/commands/agenda/plan.d.ts +2 -1
  7. package/dist/commands/agenda/plan.js +18 -4
  8. package/dist/commands/agent/message/context.d.ts +2 -0
  9. package/dist/commands/agent/message/context.js +18 -3
  10. package/dist/commands/agent/message/list.d.ts +22 -0
  11. package/dist/commands/agent/message/list.js +66 -0
  12. package/dist/commands/agent/message/send.d.ts +1 -1
  13. package/dist/commands/agent/message/send.js +1 -3
  14. package/dist/commands/agent/message/show.d.ts +14 -0
  15. package/dist/commands/agent/message/show.js +39 -0
  16. package/dist/commands/agents/chat.d.ts +4 -0
  17. package/dist/commands/agents/chat.js +79 -17
  18. package/dist/commands/agents/eval/list.d.ts +4 -0
  19. package/dist/commands/agents/eval/list.js +33 -0
  20. package/dist/commands/agents/eval/show.d.ts +1 -0
  21. package/dist/commands/agents/eval/show.js +19 -0
  22. package/dist/commands/agents/intuitions/generate.js +1 -1
  23. package/dist/commands/agents/intuitions/list.js +1 -1
  24. package/dist/commands/agents/permissions/policy.js +25 -2
  25. package/dist/commands/agents/spawn.js +61 -24
  26. package/dist/commands/agents/triggers/fire.js +1 -1
  27. package/dist/commands/agents/triggers/runs.js +3 -0
  28. package/dist/commands/code/acp.js +1 -1
  29. package/dist/commands/code/handover.d.ts +3 -3
  30. package/dist/commands/code/handover.js +12 -12
  31. package/dist/commands/code/index.d.ts +3 -8
  32. package/dist/commands/code/index.js +15 -21
  33. package/dist/commands/code/jobs/approve.d.ts +1 -11
  34. package/dist/commands/code/jobs/approve.js +3 -15
  35. package/dist/commands/code/jobs/cancel.js +3 -2
  36. package/dist/commands/code/jobs/index.js +1 -1
  37. package/dist/commands/code/jobs/list.js +4 -11
  38. package/dist/commands/code/jobs/run.js +13 -7
  39. package/dist/commands/code/jobs/show.js +52 -6
  40. package/dist/commands/code/run.js +1 -1
  41. package/dist/commands/commands.d.ts +1 -0
  42. package/dist/commands/commands.js +5 -1
  43. package/dist/commands/context.d.ts +1 -0
  44. package/dist/commands/context.js +1 -0
  45. package/dist/commands/duties/catalog/add.d.ts +18 -0
  46. package/dist/commands/duties/catalog/add.js +52 -0
  47. package/dist/commands/duties/catalog/index.d.ts +18 -0
  48. package/dist/commands/duties/catalog/index.js +88 -0
  49. package/dist/commands/duties/receipt.js +56 -1
  50. package/dist/commands/goals/plan-now.d.ts +5 -3
  51. package/dist/commands/goals/plan-now.js +21 -16
  52. package/dist/commands/goals/planner-compare.js +5 -3
  53. package/dist/commands/instructions/discovery.d.ts +10 -0
  54. package/dist/commands/instructions/discovery.js +74 -0
  55. package/dist/commands/runs/admission.d.ts +12 -0
  56. package/dist/commands/runs/admission.js +66 -0
  57. package/dist/commands/runs/events.d.ts +16 -0
  58. package/dist/commands/runs/events.js +89 -0
  59. package/dist/commands/runs/list.d.ts +27 -0
  60. package/dist/commands/runs/list.js +151 -0
  61. package/dist/commands/runs/show.d.ts +14 -0
  62. package/dist/commands/runs/show.js +273 -0
  63. package/dist/commands/runs/stop.d.ts +15 -0
  64. package/dist/commands/runs/stop.js +105 -0
  65. package/dist/commands/runs/transcript.d.ts +19 -0
  66. package/dist/commands/runs/transcript.js +178 -0
  67. package/dist/commands/tasks/attachments/download.d.ts +1 -0
  68. package/dist/commands/tasks/attachments/download.js +6 -4
  69. package/dist/commands/tasks/attachments/source.d.ts +6 -0
  70. package/dist/commands/tasks/attachments/source.js +18 -0
  71. package/dist/commands/tasks/chat/exchange.d.ts +0 -14
  72. package/dist/commands/tasks/chat/exchange.js +8 -39
  73. package/dist/commands/tasks/chat/reply-run.d.ts +15 -0
  74. package/dist/commands/tasks/chat/reply-run.js +69 -0
  75. package/dist/commands/tasks/complete.js +1 -1
  76. package/dist/commands/tasks/lifecycle/transition.d.ts +1 -0
  77. package/dist/commands/tasks/lifecycle/transition.js +51 -13
  78. package/dist/commands/tasks/operations/show.js +5 -0
  79. package/dist/commands/tasks/result/submit.js +4 -2
  80. package/dist/commands/tasks/retry.js +25 -16
  81. package/dist/commands/tasks/runs.js +7 -0
  82. package/dist/commands/tasks/start-receipt.js +8 -8
  83. package/dist/commands/tasks/start.js +12 -1
  84. package/dist/commands/triggers/audit.js +3 -1
  85. package/dist/commands/triggers/fire-detail.js +4 -1
  86. package/dist/commands/triggers/fire.js +1 -1
  87. package/dist/commands/usage.d.ts +1 -0
  88. package/dist/commands/usage.js +1 -0
  89. package/dist/generated/agent-guides.json +350 -777
  90. package/dist/help.d.ts +2 -7
  91. package/dist/help.js +13 -7
  92. package/dist/hooks/init.js +10 -0
  93. package/dist/lib/agent-chat-queue.d.ts +2 -1
  94. package/dist/lib/agent-chat-queue.js +26 -21
  95. package/dist/lib/agent-evals.d.ts +1 -1
  96. package/dist/lib/agent-evals.js +13 -3
  97. package/dist/lib/agent-guides.d.ts +3 -5
  98. package/dist/lib/agent-guides.js +12 -13
  99. package/dist/lib/agent-runs.d.ts +101 -0
  100. package/dist/lib/agent-runs.js +350 -0
  101. package/dist/lib/agentic-stream.d.ts +13 -1
  102. package/dist/lib/agentic-stream.js +165 -81
  103. package/dist/lib/api-fetch.d.ts +4 -2
  104. package/dist/lib/api-fetch.js +11 -5
  105. package/dist/lib/code-handover.d.ts +2 -3
  106. package/dist/lib/code-handover.js +4 -6
  107. package/dist/lib/command-manifest.d.ts +1 -6
  108. package/dist/lib/command-manifest.js +86 -13
  109. package/dist/lib/communication-history.d.ts +27 -0
  110. package/dist/lib/communication-history.js +45 -0
  111. package/dist/lib/config.d.ts +2 -3
  112. package/dist/lib/config.js +2 -3
  113. package/dist/lib/duties.d.ts +5 -1
  114. package/dist/lib/duties.js +4 -0
  115. package/dist/lib/execution-history.d.ts +34 -0
  116. package/dist/lib/execution-history.js +7 -0
  117. package/dist/lib/first-party-harness-broker.d.ts +1 -1
  118. package/dist/lib/first-party-harness-broker.js +3 -5
  119. package/dist/lib/format.d.ts +1 -0
  120. package/dist/lib/format.js +18 -0
  121. package/dist/lib/guide-pointer.d.ts +5 -1
  122. package/dist/lib/guide-pointer.js +21 -2
  123. package/dist/lib/hosted-job-status.d.ts +4 -0
  124. package/dist/lib/hosted-job-status.js +19 -0
  125. package/dist/lib/inbound-messages.d.ts +2 -0
  126. package/dist/lib/inbound-messages.js +5 -0
  127. package/dist/lib/intuition-look.js +20 -4
  128. package/dist/lib/memory-history-session.d.ts +8 -4
  129. package/dist/lib/memory-history-session.js +30 -23
  130. package/dist/lib/roles.d.ts +2 -2
  131. package/dist/lib/schedule.d.ts +4 -0
  132. package/dist/lib/schedule.js +4 -3
  133. package/dist/lib/task-agent-run.d.ts +4 -0
  134. package/dist/lib/task-agent-run.js +15 -0
  135. package/dist/lib/task-execution.d.ts +1 -1
  136. package/dist/lib/task-execution.js +3 -19
  137. package/dist/lib/task-extras.d.ts +11 -1
  138. package/dist/lib/task-extras.js +15 -1
  139. package/dist/lib/task-transcript.js +3 -8
  140. package/dist/lib/triggers.d.ts +5 -36
  141. package/dist/lib/triggers.js +48 -33
  142. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonWire.d.ts +9 -0
  143. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonWire.js +40 -3
  144. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/harnessCommand.d.ts +37 -0
  145. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/harnessCommand.js +59 -0
  146. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/toolApprovalSignature.d.ts +62 -0
  147. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/toolApprovalSignature.js +56 -0
  148. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonWire.d.ts +9 -0
  149. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonWire.js +34 -3
  150. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/harnessCommand.d.ts +37 -0
  151. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/harnessCommand.js +57 -0
  152. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/toolApprovalSignature.d.ts +62 -0
  153. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/toolApprovalSignature.js +51 -0
  154. package/dist/node_modules/@skrr-ai/auth-core/package.json +10 -0
  155. package/dist/node_modules/@skrr-ai/data-provider/index.js +12259 -12160
  156. package/docs/v1/quickstart.md +18 -0
  157. package/oclif.manifest.json +3405 -2112
  158. package/package.json +6 -2
  159. package/skills/skrr/SKILL.md +14 -0
  160. package/dist/commands/triggers/runs.d.ts +0 -22
  161. package/dist/commands/triggers/runs.js +0 -58
@@ -0,0 +1,273 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const auth_core_1 = require("@skrr-ai/auth-core");
4
+ const core_1 = require("@oclif/core");
5
+ const base_command_1 = require("../../base-command");
6
+ const agent_runs_1 = require("../../lib/agent-runs");
7
+ const communication_history_1 = require("../../lib/communication-history");
8
+ const execution_history_1 = require("../../lib/execution-history");
9
+ const format_1 = require("../../lib/format");
10
+ const keychain_1 = require("../../lib/keychain");
11
+ const search_display_1 = require("../../lib/search-display");
12
+ const shell_quote_1 = require("../../lib/shell-quote");
13
+ function lifecycleText(lifecycle) {
14
+ if (!lifecycle)
15
+ return '';
16
+ const { status, startedAt, finishedAt } = lifecycle;
17
+ return [
18
+ '', status.replaceAll('_', ' '),
19
+ ...(startedAt ? [`started ${(0, format_1.localTime)(startedAt)}`] : []),
20
+ ...(finishedAt ? [`${status === 'not_started' ? 'confirmed' : 'finished'} ${(0, format_1.localTime)(finishedAt)}`] : []),
21
+ ].join(' · ');
22
+ }
23
+ const runtimeWaitLabel = {
24
+ offline: 'The runtime is offline.',
25
+ unavailable: 'Waiting for an available runtime.',
26
+ unbound: 'Waiting for a runtime to be assigned.',
27
+ capability_missing: 'Waiting for a runtime with the required capability.',
28
+ admission_failed: 'Waiting for an available runtime.',
29
+ lookup_failed: 'Waiting for an available runtime.',
30
+ waiting_for_machine: 'Waiting for the runtime to start.',
31
+ maintenance: 'New work is paused on this runtime.',
32
+ placement_unconfirmed: 'Hosted machine provisioning is unconfirmed.',
33
+ daemon_readiness_unconfirmed: 'The hosted machine was created. Daemon readiness is unconfirmed.',
34
+ dispatch_unconfirmed: 'The queue has not confirmed receipt of this run.',
35
+ capacity: 'Waiting for execution capacity.',
36
+ };
37
+ function runtimeWaitText(wait) {
38
+ if (!wait)
39
+ return [];
40
+ const lines = [];
41
+ if (wait.remedy === 'update_daemon')
42
+ lines.push('Update the skrr daemon on the selected machine so this run can start.');
43
+ else if (wait.missingCapability === 'session_managed_attempt_v1') {
44
+ lines.push('Waiting for a daemon that supports managed execution.');
45
+ }
46
+ else if (wait.missingCapability === 'duty_execution_contract_v3_ephemeral') {
47
+ lines.push('Waiting for a worker that supports Duty sandboxes.');
48
+ }
49
+ else {
50
+ const label = runtimeWaitLabel[wait.reason];
51
+ if (typeof label === 'string')
52
+ lines.push(label);
53
+ }
54
+ if (wait.deadlineAt)
55
+ lines.push(`Wait deadline: ${(0, format_1.localTime)(wait.deadlineAt)}`);
56
+ return lines;
57
+ }
58
+ function continuityText(attempt) {
59
+ const lines = [];
60
+ if (attempt.sessionContext === 'resumed')
61
+ lines.push('Session context resumed.');
62
+ else if (attempt.sessionContext === 'fresh')
63
+ lines.push('New session context.');
64
+ if (attempt.workspaceVolume === 'restored_snapshot_mounted') {
65
+ lines.push('The host mounted its workspace volume from a verified snapshot.');
66
+ lines.push('Working files and original-process continuity are unverified.');
67
+ }
68
+ else if (attempt.sessionContext === 'resumed') {
69
+ lines.push('Workspace restore and original-process continuity are unverified.');
70
+ }
71
+ return lines;
72
+ }
73
+ const placementLabel = { auto: 'Automatic placement', cloud: 'Cloud', local: 'Local' };
74
+ const modelLabel = { auto: 'Automatic model', configured: 'Configured model', harness_default: 'Harness default model' };
75
+ const backendLabel = {
76
+ server_sdk: 'Cloud SDK',
77
+ server_direct: 'Direct API',
78
+ hosted_codex: 'Cloud Codex',
79
+ hosted_first_party: 'Cloud Skrr Code',
80
+ hosted_pi: 'Cloud Pi',
81
+ };
82
+ function configurationText(configuration) {
83
+ if (!configuration)
84
+ return '';
85
+ const { definition, releaseNumber, executionEnvironment, modelMode, configuredModel, fallbackUsed } = configuration;
86
+ const definitionLabel = definition === 'agent_release'
87
+ ? typeof releaseNumber === 'number' && Number.isSafeInteger(releaseNumber) && releaseNumber > 0
88
+ ? `Agent release ${releaseNumber}`
89
+ : 'Agent release'
90
+ : definition === 'live_agent' ? 'Live Agent settings'
91
+ : definition === 'harness_profile' ? 'Harness profile' : undefined;
92
+ return [
93
+ definitionLabel,
94
+ executionEnvironment && placementLabel[executionEnvironment],
95
+ configuredModel && modelMode === 'configured'
96
+ ? 'Configured model: ' + (0, search_display_1.searchDisplayText)(configuredModel)
97
+ : modelMode && modelLabel[modelMode],
98
+ fallbackUsed === true && 'Fallback used',
99
+ ].filter(Boolean).join(' · ');
100
+ }
101
+ function timestampLines(timestamps) {
102
+ return timestamps.flatMap(([label, value]) => value && Number.isFinite(Date.parse(value)) ? [`${label}: ${(0, format_1.localTime)(value)}`] : []);
103
+ }
104
+ function timingText(timing) {
105
+ if (!timing)
106
+ return [];
107
+ const lines = timestampLines([
108
+ ['Queued', timing.queuedAt],
109
+ ['Queue deadline', timing.queueDeadlineAt],
110
+ ['Queue expired before claim', timing.queueExpiredAt],
111
+ ['First observed start', timing.startedAt],
112
+ ['Finished', timing.finishedAt === timing.queueExpiredAt ? undefined : timing.finishedAt],
113
+ ['Run deadline', timing.runDeadlineAt],
114
+ ]);
115
+ const { activeElapsedMs, activeTimeCoverage, wallTimeLimitMs } = timing;
116
+ if (typeof wallTimeLimitMs === 'number' && Number.isSafeInteger(wallTimeLimitMs) && wallTimeLimitMs > 0) {
117
+ lines.push(`Wall-clock limit from first claim: ${(0, format_1.formatDurationMs)(wallTimeLimitMs)}`);
118
+ }
119
+ if (typeof activeElapsedMs === 'number' && Number.isFinite(activeElapsedMs) && activeElapsedMs >= 0) {
120
+ const partial = activeTimeCoverage === 'partial' ? ' (partial evidence)' : '';
121
+ lines.push(`Recorded active time: ${(0, format_1.formatDurationMs)(activeElapsedMs)}${partial}`);
122
+ }
123
+ return lines;
124
+ }
125
+ function executionText(attempt) {
126
+ const lines = timestampLines([
127
+ ['Start authorization expires', attempt.timing?.startBy],
128
+ ['Attempt deadline', attempt.timing?.deadlineAt],
129
+ ]);
130
+ const dispatch = configurationText(attempt.configuration);
131
+ if (dispatch)
132
+ lines.push(`Dispatch configuration: ${dispatch}`);
133
+ const backend = attempt.observedRuntimeFamily && backendLabel[attempt.observedRuntimeFamily];
134
+ if (backend)
135
+ lines.push(`Observed backend: ${backend}`);
136
+ for (const execution of attempt.executions ?? []) {
137
+ const { executionEnvironment, machineProduct, fallbackUsed, observedModels } = execution;
138
+ const environment = placementLabel[executionEnvironment];
139
+ if (!environment)
140
+ continue;
141
+ const machine = machineProduct ? (0, search_display_1.searchDisplayText)(machineProduct) : '';
142
+ const placement = machine && executionEnvironment === 'auto'
143
+ ? `${machine} · Cloud inference`
144
+ : [environment, machine].filter(Boolean).join(' · ');
145
+ const models = (observedModels ?? []).filter((model) => typeof model === 'string')
146
+ .map(search_display_1.searchDisplayText).filter(Boolean);
147
+ lines.push(`Observed placement: ${placement}${fallbackUsed ? ' · Fallback used' : ''}`);
148
+ lines.push(models.length ? `Reported models: ${models.join(', ')}` : 'Reported models: unknown');
149
+ }
150
+ return lines;
151
+ }
152
+ const channelDeliveryLabel = {
153
+ silent: 'no reply sent',
154
+ accepted: 'accepted by provider',
155
+ delivered: 'delivered',
156
+ failed: 'failed',
157
+ pending: 'pending',
158
+ unconfirmed: 'unconfirmed',
159
+ };
160
+ function outcomeText(run) {
161
+ const lines = [];
162
+ if (run.source === 'channel' && run.delivery && Object.hasOwn(channelDeliveryLabel, run.delivery)) {
163
+ lines.push(`Channel delivery: ${channelDeliveryLabel[run.delivery]}`);
164
+ if (run.delivery === 'unconfirmed')
165
+ lines.push('Check the channel for the reply.');
166
+ }
167
+ if (run.businessResult) {
168
+ const { application, notifications } = run.businessResult;
169
+ lines.push(`Result application: ${application.replaceAll('_', ' ')}`);
170
+ const counts = ['delivered', 'pending', 'not_delivered', 'unconfirmed'].flatMap((state) => {
171
+ const count = notifications?.[state];
172
+ return typeof count === 'number' && Number.isSafeInteger(count) && count > 0
173
+ ? [`${count} ${state.replaceAll('_', ' ')}`]
174
+ : [];
175
+ });
176
+ if (counts.length)
177
+ lines.push(`Notification delivery: ${counts.join(' · ')}`);
178
+ }
179
+ const owed = run.humanInput?.items.filter(({ audience, state }) => audience === 'viewer' && state === 'pending') ?? [];
180
+ if (owed.length) {
181
+ const counts = ['approval', 'question', 'intervention'].flatMap((kind) => {
182
+ const count = owed.filter((item) => item.kind === kind).length;
183
+ return count ? [`${count} ${kind}${count === 1 ? '' : 's'}`] : [];
184
+ });
185
+ if (counts.length)
186
+ lines.push(`Your pending input: ${counts.join(' · ')}`);
187
+ }
188
+ return lines;
189
+ }
190
+ class RunsShow extends base_command_1.BaseCommand {
191
+ static autonomousCredentialPolicy = 'bound-session';
192
+ static description = 'Show a canonical Agent Run and its execution attempts';
193
+ static examples = ['<%= config.bin %> runs show <run-id>', '<%= config.bin %> runs show <run-id> --json'];
194
+ static args = { runId: agent_runs_1.runIdArgument };
195
+ static flags = {
196
+ json: core_1.Flags.boolean({ description: 'Output as JSON' }),
197
+ personal: core_1.Flags.boolean({
198
+ description: 'Inspect only in personal scope, ignoring the saved workspace.',
199
+ exclusive: ['workspace'],
200
+ }),
201
+ };
202
+ async run() {
203
+ const { args, flags } = await this.parse(RunsShow);
204
+ const session = (0, communication_history_1.resolveHistorySession)(() => this.requireAuth());
205
+ try {
206
+ if (session) {
207
+ const run = await (0, execution_history_1.readExecutionHistory)(session.sessionId, 'show', { runId: args.runId });
208
+ if (flags.json)
209
+ this.log(JSON.stringify(run, null, 2));
210
+ else {
211
+ this.log([run.id, run.source, run.status, (0, format_1.localTime)(run.acceptedAt)].join(' · '));
212
+ for (const line of runtimeWaitText(run.runtimeWait))
213
+ this.log(line);
214
+ for (const attempt of run.attempts) {
215
+ this.log(`Attempt ${attempt.number} ${attempt.id} (${attempt.executor})${lifecycleText(attempt.lifecycle)}`);
216
+ }
217
+ if (run.coverage === 'partial')
218
+ this.log('Attempt history coverage is partial.');
219
+ }
220
+ return;
221
+ }
222
+ const run = await (0, agent_runs_1.readAgentRun)(args.runId, { personal: flags.personal });
223
+ const { snapshot } = run;
224
+ if (flags.json) {
225
+ this.log(JSON.stringify(run, null, 2));
226
+ return;
227
+ }
228
+ this.log(`Run ${run.id}`);
229
+ this.log(`Source: ${run.source}`);
230
+ const origin = (0, agent_runs_1.chatCopyOrigin)(run);
231
+ if (origin) {
232
+ const scope = origin.workspaceId ? ['--workspace', origin.workspaceId] : ['--personal'];
233
+ const command = (0, shell_quote_1.shellQuoteArgv)([
234
+ this.config.bin, 'runs', 'transcript', origin.runId, '--attempt', origin.attemptId,
235
+ ...scope, ...(0, auth_core_1.explicitProfileArgs)((0, keychain_1.profileForChildProcess)()),
236
+ ]);
237
+ const label = origin.kind === 'fork' ? 'Fork source transcript' : 'Handover source transcript';
238
+ this.log(`${label} ${command}`);
239
+ }
240
+ const status = run.status ?? snapshot?.status;
241
+ if (status)
242
+ this.log(`Status: ${status}`);
243
+ if (run.snapshotAvailability === 'unavailable')
244
+ this.log('Live lifecycle snapshot is temporarily unavailable.');
245
+ if (status === 'timed_out' && run.endReason === 'preparation_deadline_before_attempt') {
246
+ this.log('Preparation timed out before execution began. No execution transcript was created.');
247
+ }
248
+ this.log(`Accepted: ${(0, format_1.localTime)(run.acceptedAt)}`);
249
+ for (const line of runtimeWaitText(run.runtimeWait))
250
+ this.log(line);
251
+ for (const line of outcomeText(run))
252
+ this.log(line);
253
+ const configuration = configurationText(run.configuration);
254
+ if (configuration)
255
+ this.log(`Admitted configuration: ${configuration}`);
256
+ for (const line of timingText(run.timing))
257
+ this.log(line);
258
+ if (snapshot?.activeAttemptId)
259
+ this.log(`Active Attempt: ${snapshot.activeAttemptId}`);
260
+ for (const attempt of run.attempts) {
261
+ this.log(`Attempt ${attempt.number}: ${attempt.id} (${attempt.executor})${lifecycleText(attempt.lifecycle)}`);
262
+ for (const line of executionText(attempt))
263
+ this.log(` ${line}`);
264
+ for (const line of continuityText(attempt))
265
+ this.log(` ${line}`);
266
+ }
267
+ }
268
+ catch (error) {
269
+ this.handleApiError(error);
270
+ }
271
+ }
272
+ }
273
+ exports.default = RunsShow;
@@ -0,0 +1,15 @@
1
+ import { BaseCommand } from '../../base-command';
2
+ export default class RunsStop extends BaseCommand {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ runId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ static flags: {
9
+ attempt: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ queued: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ personal: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
+ };
14
+ run(): Promise<void>;
15
+ }
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const auth_core_1 = require("@skrr-ai/auth-core");
4
+ const core_1 = require("@oclif/core");
5
+ const base_command_1 = require("../../base-command");
6
+ const agent_runs_1 = require("../../lib/agent-runs");
7
+ const http_error_1 = require("../../lib/http-error");
8
+ const keychain_1 = require("../../lib/keychain");
9
+ const shell_quote_1 = require("../../lib/shell-quote");
10
+ class RunsStop extends base_command_1.BaseCommand {
11
+ static description = 'Request Stop for a canonical Agent Run or recover an exact Stop receipt';
12
+ static examples = [
13
+ '<%= config.bin %> runs stop <run-id>',
14
+ '<%= config.bin %> runs stop <run-id> --attempt <attempt-id> --json',
15
+ '<%= config.bin %> runs stop <run-id> --queued --json',
16
+ '<%= config.bin %> runs stop <run-id> --personal',
17
+ ];
18
+ static args = { runId: agent_runs_1.runIdArgument };
19
+ static flags = {
20
+ attempt: core_1.Flags.string({
21
+ description: 'Stop this exact Attempt or recover its Stop receipt',
22
+ exclusive: ['queued'],
23
+ parse: async (input) => (0, agent_runs_1.exactAttemptId)(input),
24
+ }),
25
+ queued: core_1.Flags.boolean({
26
+ description: 'Stop before any Attempt has started or recover that queued Stop receipt',
27
+ exclusive: ['attempt'],
28
+ }),
29
+ personal: core_1.Flags.boolean({
30
+ description: 'Request or recover Stop in personal scope, ignoring the saved workspace.',
31
+ exclusive: ['workspace'],
32
+ }),
33
+ json: core_1.Flags.boolean({ description: 'Output as JSON' }),
34
+ };
35
+ async run() {
36
+ this.requireAuth();
37
+ const { args, flags } = await this.parse(RunsStop);
38
+ const profile = (0, auth_core_1.explicitProfileArgs)((0, keychain_1.profileForChildProcess)());
39
+ try {
40
+ const { personal, queued, attempt } = flags;
41
+ const result = await (0, agent_runs_1.stopAgentRun)(args.runId, queued ? null : attempt, { personal });
42
+ if (result.kind === 'already-ended') {
43
+ if (flags.json) {
44
+ this.log(JSON.stringify({ runId: result.runId, status: result.status, alreadyEnded: true }, null, 2));
45
+ }
46
+ else {
47
+ this.log(`Run ${result.runId} has already ended (${result.status}).`);
48
+ }
49
+ return;
50
+ }
51
+ const { receipt } = result;
52
+ if (flags.json) {
53
+ this.log(JSON.stringify(receipt, null, 2));
54
+ }
55
+ else if (receipt.status === 'cancelled') {
56
+ this.log(`Run ${receipt.runId} is cancelled.`);
57
+ }
58
+ else {
59
+ this.log(`Stop requested for Run ${receipt.runId}. The runtime has yet to confirm it stopped.`);
60
+ }
61
+ }
62
+ catch (error) {
63
+ if (error instanceof agent_runs_1.RunStopUnconfirmedError) {
64
+ const target = error.expectedAttemptId === null ? ['--queued'] : ['--attempt', error.expectedAttemptId];
65
+ const scope = error.workspaceId ? ['--workspace', error.workspaceId] : ['--personal'];
66
+ const command = (0, shell_quote_1.shellQuoteArgv)([this.config.bin, 'runs', 'stop', args.runId, ...target, ...scope, ...profile]);
67
+ this.failWithCliError({
68
+ code: 'AGENT_RUN_STOP_OUTCOME_UNKNOWN',
69
+ message: `Stop was not confirmed. Retry the same target with ${command}.`,
70
+ status: (0, http_error_1.httpStatusOf)(error.cause),
71
+ exit: 1,
72
+ retryable: false,
73
+ details: {
74
+ expectedAttemptId: error.expectedAttemptId,
75
+ ...(error.workspaceId ? { workspaceId: error.workspaceId } : {}),
76
+ command,
77
+ },
78
+ });
79
+ }
80
+ if (error instanceof agent_runs_1.RunStopConflictError) {
81
+ const { expectedAttemptId, workspaceId } = error;
82
+ const scope = workspaceId ? ['--workspace', workspaceId] : ['--personal'];
83
+ const inspect = [this.config.bin, 'runs', 'show', args.runId, ...scope, ...profile];
84
+ const command = (0, shell_quote_1.shellQuoteArgv)(inspect);
85
+ const target = expectedAttemptId ? `Attempt ${expectedAttemptId}` : 'the queued Run';
86
+ this.failWithCliError({
87
+ code: 'AGENT_RUN_STOP_CONFLICT',
88
+ message: `Stop was not accepted for ${target}. Check ${command} before requesting Stop again.`,
89
+ status: 409,
90
+ exit: 1,
91
+ retryable: false,
92
+ details: {
93
+ runId: args.runId,
94
+ expectedAttemptId,
95
+ ...(workspaceId ? { workspaceId } : {}),
96
+ command,
97
+ inspection: { argv: [...inspect, '--json'] },
98
+ },
99
+ });
100
+ }
101
+ this.handleApiError(error);
102
+ }
103
+ }
104
+ }
105
+ exports.default = RunsStop;
@@ -0,0 +1,19 @@
1
+ import { BaseCommand } from '../../base-command';
2
+ export default class RunsTranscript extends BaseCommand {
3
+ static autonomousCredentialPolicy: "bound-session";
4
+ static description: string;
5
+ static examples: string[];
6
+ static args: {
7
+ runId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
8
+ };
9
+ static flags: {
10
+ attempt: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
11
+ offset: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ after: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ cursor: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ limit: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
+ personal: import("@oclif/core/interfaces").BooleanFlag<boolean>;
17
+ };
18
+ run(): Promise<void>;
19
+ }
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const auth_core_1 = require("@skrr-ai/auth-core");
4
+ const node_util_1 = require("node:util");
5
+ const core_1 = require("@oclif/core");
6
+ const data_provider_1 = require("@skrr-ai/data-provider");
7
+ const base_command_1 = require("../../base-command");
8
+ const agent_runs_1 = require("../../lib/agent-runs");
9
+ const communication_history_1 = require("../../lib/communication-history");
10
+ const execution_history_1 = require("../../lib/execution-history");
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");
14
+ const availability = {
15
+ available: 'Transcript available',
16
+ partial: 'Partial transcript',
17
+ unverified: 'Transcript source unverified',
18
+ unavailable: 'Transcript unavailable',
19
+ };
20
+ function terminalText(value) {
21
+ return (0, node_util_1.stripVTControlCharacters)(value.replace(/\r\n?/g, '\n'))
22
+ .replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/g, '');
23
+ }
24
+ class RunsTranscript extends base_command_1.BaseCommand {
25
+ static autonomousCredentialPolicy = 'bound-session';
26
+ static description = 'Read the transcript of an exact Agent Run Attempt';
27
+ static examples = [
28
+ '<%= config.bin %> runs transcript <run-id> --attempt <attempt-id>',
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>',
31
+ ];
32
+ static args = { runId: agent_runs_1.runIdArgument };
33
+ static flags = {
34
+ attempt: agent_runs_1.attemptIdFlag,
35
+ offset: core_1.Flags.integer({
36
+ description: 'Start at this offset (default 0). Use the next offset returned by the previous page.',
37
+ min: 0,
38
+ max: Number.MAX_SAFE_INTEGER,
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
+ },
49
+ }),
50
+ cursor: core_1.Flags.string({ description: 'Read the next older window in an Agent session' }),
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 }),
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
+ }),
57
+ };
58
+ async run() {
59
+ const { args: { runId }, flags } = await this.parse(RunsTranscript);
60
+ const session = (0, communication_history_1.resolveHistorySession)(() => this.requireAuth());
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
+ });
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
+ ];
79
+ try {
80
+ if (session) {
81
+ const page = await (0, execution_history_1.readExecutionHistory)(session.sessionId, 'transcript', { runId, attempt, limit, cursor });
82
+ if (flags.json)
83
+ this.log(JSON.stringify(page, null, 2));
84
+ else {
85
+ for (const row of page.items)
86
+ this.log(terminalText([row.at, row.name ?? row.kind, row.outcome, row.text].filter(Boolean).join(' · ')));
87
+ if (page.coverage === 'partial')
88
+ this.log('Transcript coverage is partial.');
89
+ if (page.nextCursor)
90
+ this.log(`Earlier window Repeat with --cursor ${(0, search_display_1.shellSearchCursor)(page.nextCursor)}.`);
91
+ }
92
+ return;
93
+ }
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
+ }
104
+ if (flags.json) {
105
+ this.log(JSON.stringify(continuation
106
+ ? { ...page, continuation: { argv: [...continuation.argv, '--json'] } }
107
+ : page, null, 2));
108
+ return;
109
+ }
110
+ this.log(`Run ${runId}`);
111
+ this.log(`Attempt ${attempt}`);
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);
119
+ if (!body)
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');
126
+ for (const row of (0, data_provider_1.buildEnvelopeRows)(body.envelopes ?? [])) {
127
+ if (row.kind === 'answer') {
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
+ }
154
+ }
155
+ const count = (body.envelopes?.length ?? 0) + (body.content?.length ?? 0) + (body.events?.length ?? 0);
156
+ this.log(`${count} ${count === 1 ? 'item' : 'items'} on this page. Use --json to read the full page.`);
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)}`);
161
+ }
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
+ }
174
+ this.handleApiError(error);
175
+ }
176
+ }
177
+ }
178
+ exports.default = RunsTranscript;
@@ -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;