@skrr-ai/cli 0.1.193 → 0.1.195

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.
@@ -53,7 +53,8 @@ class HostedMachinesList extends base_command_1.BaseCommand {
53
53
  }
54
54
  const rows = sessions.map((session) => ({
55
55
  id: (0, hosted_machines_1.hostedMachineId)(session),
56
- status: (0, hosted_machines_1.hostedMachineStatus)(session),
56
+ // The cap pauses a box and keeps its files; the table says which pause it was.
57
+ status: (0, hosted_machines_1.isSpendCapPaused)(session) ? 'paused (monthly cap)' : (0, hosted_machines_1.hostedMachineStatus)(session),
57
58
  name: (0, hosted_machines_1.hostedMachineDisplayName)(session),
58
59
  agent: session.agentId ? String(session.agentId) : '-',
59
60
  lease: session.machineLeaseId ? String(session.machineLeaseId) : '-',
@@ -69,11 +70,12 @@ class HostedMachinesList extends base_command_1.BaseCommand {
69
70
  { key: 'repos', header: 'REPOS', maxWidth: 36 },
70
71
  { key: 'preview', header: 'PREVIEW', maxWidth: 48 },
71
72
  ], (line) => this.log(line));
72
- // A machine the platform ended says why under the table, so a cap
73
- // termination never reads as an owner's own (OSK-24471).
74
- const ended = sessions.filter((session) => (0, hosted_machines_1.hostedMachineStatus)(session) === 'terminated' && session.terminationReason);
75
- for (const session of ended) {
76
- const why = (0, hosted_machines_1.hostedMachineLifecycleLines)(session).find((line) => line.startsWith('Why: '));
73
+ // A machine the platform ended, or the monthly cap paused, says why under
74
+ // the table, so neither reads as an owner's own (OSK-24471).
75
+ const explained = sessions.filter((session) => ((0, hosted_machines_1.hostedMachineStatus)(session) === 'terminated' && session.terminationReason) ||
76
+ (0, hosted_machines_1.isSpendCapPaused)(session));
77
+ for (const session of explained) {
78
+ const why = (0, hosted_machines_1.hostedMachineLifecycleLines)(session, { bin: this.config.bin }).find((line) => line.startsWith('Why: '));
77
79
  if (why) {
78
80
  this.log('');
79
81
  this.log(`${(0, hosted_machines_1.hostedMachineId)(session)}: ${why.slice('Why: '.length)}`);
@@ -71,8 +71,9 @@ class HostedMachinesStatus extends base_command_1.BaseCommand {
71
71
  printStatus(session) {
72
72
  this.log(`ID: ${(0, hosted_machines_1.hostedMachineId)(session)}`);
73
73
  this.log(`Status: ${(0, hosted_machines_1.hostedMachineStatus)(session)}`);
74
- for (const line of (0, hosted_machines_1.hostedMachineLifecycleLines)(session))
74
+ for (const line of (0, hosted_machines_1.hostedMachineLifecycleLines)(session, { bin: this.config.bin })) {
75
75
  this.log(line);
76
+ }
76
77
  this.log(`Name: ${(0, hosted_machines_1.hostedMachineDisplayName)(session)}`);
77
78
  this.log(`Agent: ${session.agentId || '-'}`);
78
79
  this.log(`Conversation: ${session.conversationId || '-'}`);
@@ -98,15 +98,16 @@ class TasksStart extends base_command_1.BaseCommand {
98
98
  code: 'TASK_START_PREVIEW_UNSUPPORTED', exit: 2, retryable: false,
99
99
  });
100
100
  }
101
+ const blocked = (0, task_admission_1.isAdmissionBlocked)(preview.executionAdmission);
101
102
  if (flags.json)
102
- this.printJsonResult(preview, { ok: preview.executionAdmission.state !== 'blocked' });
103
+ this.printJsonResult(preview, { ok: !blocked });
103
104
  else {
104
105
  this.log(`Execution preview for ${preview.taskId}:`);
105
106
  for (const line of (0, task_admission_1.admissionLines)(preview.executionAdmission))
106
107
  this.log(line);
107
108
  this.log('No Run was created. Starting later rechecks current prerequisites.');
108
109
  }
109
- if (preview.executionAdmission.state === 'blocked')
110
+ if (blocked)
110
111
  this.exit(1);
111
112
  return;
112
113
  }
@@ -2003,9 +2003,13 @@ function scorecardQualifier(coverage) {
2003
2003
  }
2004
2004
  function renderProactivenessScorecard(scorecard, log) {
2005
2005
  const coverage = record(scorecard.coverage);
2006
+ log('');
2007
+ if (coverage?.reason === 'historical_duty_relationship_unverified') {
2008
+ log('Proactiveness unavailable. Historical links to this Duty could not be verified, so trace coverage is partial.');
2009
+ return;
2010
+ }
2006
2011
  const metrics = record(scorecard.metrics) || {};
2007
2012
  const metricCoverage = record(scorecard.metricCoverage) || {};
2008
- log('');
2009
2013
  log(coverage?.partialWindow === true || record(scorecard.window)?.partial === true
2010
2014
  ? 'Proactiveness (this page only — not the whole window)'
2011
2015
  : 'Proactiveness');
@@ -12,7 +12,7 @@ function eventWakeLines(caps) {
12
12
  lines.push('Event wakes:');
13
13
  lines.push(` requested: ${caps.requested ? 'yes' : 'no'}`);
14
14
  lines.push(` configured sources: ${(caps.configuredSources ?? []).join(', ') || 'none'}`);
15
- lines.push(` eligible in current plan: ${(caps.eligibleSources ?? []).join(', ') || 'none'}`);
15
+ lines.push(` sources planned at the current status and cadence: ${(caps.eligibleSources ?? []).join(', ') || 'none'}`);
16
16
  lines.push(` materialized sources: ${(caps.materializedSources ?? []).join(', ') || 'none'}`);
17
17
  const wakeableWhenActive = caps.wakeableWhenActive ?? [];
18
18
  const eventless = caps.eventlessSources ?? [];
@@ -20,7 +20,8 @@ function eventWakeLines(caps) {
20
20
  // The server told the causes apart (OSK-22595): a source that would wake once it is active on an
21
21
  // event_plus_interval cadence is not the same as one that produces no events.
22
22
  if (wakeableWhenActive.length) {
23
- lines.push(` bindings possible when active on event_plus_interval: ${wakeableWhenActive.join(', ')} (preflight checks readiness; this does not prove event delivery)`);
23
+ lines.push(` sources planned if active with event_plus_interval: ${wakeableWhenActive.join(', ')} ` +
24
+ '(`skrr duties preflight <id>` lists projected events and readiness; delivery is unverified)');
24
25
  }
25
26
  if (eventless.length) {
26
27
  lines.push(` no event bindings for the current source configuration: ${eventless.join(', ')}` +
@@ -38,6 +38,8 @@ export interface HostedMachineSession {
38
38
  terminatedAt?: string | null;
39
39
  /** Why the PLATFORM ended it, when it did: the monthly cap, a lost plan (OSK-24471). */
40
40
  terminationReason?: string | null;
41
+ /** When the monthly cap paused it, files kept and nothing billed (OSK-24471). */
42
+ spendCapPausedAt?: string | null;
41
43
  createdAt?: string | null;
42
44
  updatedAt?: string | null;
43
45
  error?: {
@@ -92,6 +94,7 @@ export interface HostedMachineListJson {
92
94
  retentionExpiresAt?: string;
93
95
  terminatedAt?: string;
94
96
  terminationReason?: string;
97
+ spendCapPausedAt?: string;
95
98
  }>;
96
99
  }
97
100
  export declare function curateHostedMachineList(response: HostedMachineListResponse): HostedMachineListJson;
@@ -182,7 +185,11 @@ export declare function hostedMachineRepoSummary(session: HostedMachineSession |
182
185
  * line, from the shared copy (`describeHostedMachineEnd`), so `status`, `list`
183
186
  * and a refused `resume` say the same thing (OSK-24471). Empty for a live one.
184
187
  */
185
- export declare function hostedMachineLifecycleLines(session: HostedMachineSession | undefined | null): string[];
188
+ export declare function hostedMachineLifecycleLines(session: HostedMachineSession | undefined | null, context?: {
189
+ bin?: string;
190
+ }): string[];
191
+ /** Whether the monthly cap paused this machine and still holds it (OSK-24471). */
192
+ export declare function isSpendCapPaused(session: HostedMachineSession | undefined | null): boolean;
186
193
  export declare function hostedMachineErrorSummary(session: HostedMachineSession | undefined | null): string;
187
194
  /**
188
195
  * Whether tenant code on this machine can read the daemon's credentials
@@ -8,6 +8,7 @@ exports.hostedMachineStatus = hostedMachineStatus;
8
8
  exports.hostedMachineDisplayName = hostedMachineDisplayName;
9
9
  exports.hostedMachineRepoSummary = hostedMachineRepoSummary;
10
10
  exports.hostedMachineLifecycleLines = hostedMachineLifecycleLines;
11
+ exports.isSpendCapPaused = isSpendCapPaused;
11
12
  exports.hostedMachineErrorSummary = hostedMachineErrorSummary;
12
13
  exports.hostedMachineIsolationSummary = hostedMachineIsolationSummary;
13
14
  exports.hostedMachineProgressSummary = hostedMachineProgressSummary;
@@ -62,6 +63,7 @@ function curateHostedMachineList(response) {
62
63
  'retentionExpiresAt',
63
64
  'terminatedAt',
64
65
  'terminationReason',
66
+ 'spendCapPausedAt',
65
67
  ]) {
66
68
  if (typeof session[key] === 'string' && session[key])
67
69
  row[key] = session[key];
@@ -125,8 +127,22 @@ function hostedMachineRepoSummary(session) {
125
127
  * line, from the shared copy (`describeHostedMachineEnd`), so `status`, `list`
126
128
  * and a refused `resume` say the same thing (OSK-24471). Empty for a live one.
127
129
  */
128
- function hostedMachineLifecycleLines(session) {
130
+ function hostedMachineLifecycleLines(session, context = {}) {
129
131
  const status = hostedMachineStatus(session);
132
+ if (status === 'paused' && isSpendCapPaused(session)) {
133
+ // Paused by the monthly cap: why, that nothing is billed, and how it comes
134
+ // back, with the real lease in the command (OSK-24471).
135
+ const lines = [`Paused by: the monthly spending cap, at ${session.spendCapPausedAt}`];
136
+ if (typeof session?.retentionExpiresAt === 'string') {
137
+ lines.push(`Files kept until: ${session.retentionExpiresAt}`);
138
+ }
139
+ lines.push(`Why: ${(0, data_provider_1.describeHostedMachineCapPause)({
140
+ retentionExpiresAt: session?.retentionExpiresAt ?? null,
141
+ machineLeaseId: typeof session?.machineLeaseId === 'string' ? session.machineLeaseId : null,
142
+ bin: context.bin || 'skrr',
143
+ })}`);
144
+ return lines;
145
+ }
130
146
  if (status === 'paused' && typeof session?.retentionExpiresAt === 'string') {
131
147
  return [`Files kept until: ${session.retentionExpiresAt}`];
132
148
  }
@@ -142,6 +158,12 @@ function hostedMachineLifecycleLines(session) {
142
158
  }
143
159
  return lines;
144
160
  }
161
+ /** Whether the monthly cap paused this machine and still holds it (OSK-24471). */
162
+ function isSpendCapPaused(session) {
163
+ return (hostedMachineStatus(session) === 'paused' &&
164
+ typeof session?.spendCapPausedAt === 'string' &&
165
+ session.spendCapPausedAt.length > 0);
166
+ }
145
167
  function hostedMachineErrorSummary(session) {
146
168
  const error = session?.error;
147
169
  if (!error)
@@ -224,6 +246,15 @@ function formatHostedMachineApiError(err, context = {}) {
224
246
  // A monthly-cap refusal carries its figures in `details`; print them, and say
225
247
  // this is not the plan or the credits (OSK-11946). The dedicated CLI has done
226
248
  // the figures since OSK-9552; the hosted one dropped them.
249
+ // A resume refused at the cap: the box is paused with its files kept, so say
250
+ // until when, and name ITS lease in the command (OSK-24471).
251
+ const capResume = message ? capResumeRefusalDetails(err.body) : null;
252
+ if (capResume) {
253
+ return [
254
+ (0, data_provider_1.describeHostedMachineCapResumeRefusal)({ ...capResume, bin: context.bin || 'skrr' }),
255
+ machine_spend_cap_1.MONTHLY_CAP_IS_SEPARATE,
256
+ ].join(' ');
257
+ }
227
258
  if (message && (0, machine_spend_cap_1.isMonthlyCapRefusal)(err.body)) {
228
259
  const figures = (0, machine_spend_cap_1.describeMonthlyCapFigures)(err.body);
229
260
  return [
@@ -246,6 +277,39 @@ function formatHostedMachineApiError(err, context = {}) {
246
277
  const registration = describeRegistrationTimeoutDetails(err.body);
247
278
  return message && registration ? `${message} ${registration}` : message;
248
279
  }
280
+ /**
281
+ * The facts of a resume the monthly cap refused, or null for any other refusal.
282
+ * The server sends `retentionExpiresAt` with a cap refusal only from the resume
283
+ * of a paused machine, so a refused start keeps its own message.
284
+ */
285
+ function capResumeRefusalDetails(body) {
286
+ if (!(0, machine_spend_cap_1.isMonthlyCapRefusal)(body))
287
+ return null;
288
+ let details;
289
+ try {
290
+ const parsed = JSON.parse(body);
291
+ details =
292
+ parsed.details && typeof parsed.details === 'object' && !Array.isArray(parsed.details)
293
+ ? parsed.details
294
+ : undefined;
295
+ }
296
+ catch {
297
+ return null;
298
+ }
299
+ if (!details || typeof details.retentionExpiresAt !== 'string')
300
+ return null;
301
+ const cents = (key) => typeof details[key] === 'number' && Number.isFinite(details[key])
302
+ ? details[key]
303
+ : null;
304
+ const text = (key) => typeof details[key] === 'string' ? details[key] : null;
305
+ return {
306
+ limitCents: cents('limitCents'),
307
+ spendCents: cents('projectedCents') ?? cents('currentSpendCents'),
308
+ retentionExpiresAt: text('retentionExpiresAt'),
309
+ monthResetsAt: text('monthResetsAt'),
310
+ machineLeaseId: text('machineLeaseId'),
311
+ };
312
+ }
249
313
  function hostedMachineEndedRefusal(body) {
250
314
  try {
251
315
  return JSON.parse(body).code === 'MACHINE_ENDED';
@@ -1,6 +1,7 @@
1
1
  /** The server owns admission; this is a display projection, never a permission grant. */
2
2
  import type { TaskExecutionAdmission } from '@skrr-ai/data-provider';
3
3
  export type { TaskExecutionAdmission } from '@skrr-ai/data-provider';
4
+ export declare function isAdmissionBlocked(value: TaskExecutionAdmission): boolean;
4
5
  export declare function admissionLines(value: TaskExecutionAdmission | null | undefined): string[];
5
6
  export declare function isAdmissionPreview(value: unknown): value is {
6
7
  dryRun: true;
@@ -1,12 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAdmissionBlocked = isAdmissionBlocked;
3
4
  exports.admissionLines = admissionLines;
4
5
  exports.isAdmissionPreview = isAdmissionPreview;
6
+ function isAdmissionBlocked(value) {
7
+ return value.state === 'blocked' || value.ordinarySessionStartGate === 'disabled';
8
+ }
5
9
  function admissionLines(value) {
6
10
  if (!value)
7
11
  return ['Execution admission: not reported by this server.'];
8
12
  const lines = [`Approval prerequisites: ${value.state}.`];
9
13
  const observation = value.runtimePolicyObservation;
14
+ if (value.ordinarySessionStartGate === 'disabled') {
15
+ lines.push('The selected daemon reported that ordinary session starts are disabled.', 'The daemon owner can enable session starts on that machine with skrr daemon config --profile <profile> --mode claude_session=auto. Use the selected profile, or choose another runtime.');
16
+ }
17
+ else if (value.ordinarySessionStartGate === 'enabled') {
18
+ lines.push('The selected daemon reported that ordinary session starts are enabled.');
19
+ }
20
+ else if (value.ordinarySessionStartGate === 'unknown') {
21
+ lines.push('The selected daemon did not report whether ordinary session starts are enabled.');
22
+ }
10
23
  if (value.permission) {
11
24
  lines.push(!value.permission.mode &&
12
25
  value.permission.source === 'daemon' &&
@@ -53,5 +66,7 @@ function isAdmissionPreview(value) {
53
66
  typeof row.taskId === 'string' &&
54
67
  Boolean(admission &&
55
68
  ['ready', 'blocked', 'unknown'].includes(String(admission.state)) &&
56
- admission.scope === 'approval_prerequisites'));
69
+ admission.scope === 'approval_prerequisites' &&
70
+ (admission.ordinarySessionStartGate === undefined ||
71
+ ['enabled', 'disabled', 'unknown'].includes(admission.ordinarySessionStartGate))));
57
72
  }
@@ -107,12 +107,13 @@ async function readTaskPreflight(taskId, reads) {
107
107
  // start-preview. Equal numbers would not prove the reads shared a snapshot.
108
108
  const workflowBlocked = workflow.status === 'observed' &&
109
109
  !workflow.value.actionability.allowedActions.some((action) => action.action === 'start_task');
110
- const executionBlocked = execution.status === 'observed' && execution.value.executionAdmission.state === 'blocked';
110
+ const executionBlocked = execution.status === 'observed' && (0, task_admission_1.isAdmissionBlocked)(execution.value.executionAdmission);
111
111
  const summary = workflowBlocked || executionBlocked
112
112
  ? 'blocked'
113
113
  : workflow.status === 'unavailable' ||
114
114
  execution.status === 'unavailable' ||
115
- execution.value.executionAdmission.state !== 'ready'
115
+ execution.value.executionAdmission.state !== 'ready' ||
116
+ execution.value.executionAdmission.ordinarySessionStartGate === 'unknown'
116
117
  ? 'unknown'
117
118
  : 'eligible_to_attempt';
118
119
  return {
@@ -33,6 +33,7 @@ export declare function parseHarnessPermissionControls(value: unknown): HarnessP
33
33
  /** Last-reported local configuration and adapter protocol, never authority. */
34
34
  export interface HarnessSessionPolicyReport {
35
35
  version: 1;
36
+ ordinarySessionStarts?: 'enabled' | 'disabled';
36
37
  configuredDefault: {
37
38
  provider: 'claude';
38
39
  engine: 'sdk' | 'cli';
@@ -90,7 +90,13 @@ function parseHarnessSessionPolicyReport(value) {
90
90
  ])
91
91
  });
92
92
  }
93
- return Object.freeze({ version: 1, configuredDefault, taskCommandApproval });
93
+ const ordinarySessionStarts = row.ordinarySessionStarts;
94
+ return Object.freeze({
95
+ version: 1,
96
+ configuredDefault,
97
+ taskCommandApproval,
98
+ ...ordinarySessionStarts === "enabled" || ordinarySessionStarts === "disabled" ? { ordinarySessionStarts } : {}
99
+ });
94
100
  } catch {
95
101
  return null;
96
102
  }
@@ -33,6 +33,7 @@ export declare function parseHarnessPermissionControls(value: unknown): HarnessP
33
33
  /** Last-reported local configuration and adapter protocol, never authority. */
34
34
  export interface HarnessSessionPolicyReport {
35
35
  version: 1;
36
+ ordinarySessionStarts?: 'enabled' | 'disabled';
36
37
  configuredDefault: {
37
38
  provider: 'claude';
38
39
  engine: 'sdk' | 'cli';
@@ -95,7 +95,15 @@ export function parseHarnessSessionPolicyReport(value) {
95
95
  ]),
96
96
  });
97
97
  }
98
- return Object.freeze({ version: 1, configuredDefault, taskCommandApproval });
98
+ const ordinarySessionStarts = row.ordinarySessionStarts;
99
+ return Object.freeze({
100
+ version: 1,
101
+ configuredDefault,
102
+ taskCommandApproval,
103
+ ...(ordinarySessionStarts === 'enabled' || ordinarySessionStarts === 'disabled'
104
+ ? { ordinarySessionStarts }
105
+ : {}),
106
+ });
99
107
  }
100
108
  catch {
101
109
  return null;