@skrr-ai/cli 0.1.147 → 0.1.149

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.
@@ -54,6 +54,9 @@ class AgentsTodosList extends base_command_1.BaseCommand {
54
54
  }
55
55
  this.log(`Day: ${date} in ${(0, schedule_1.describeTimeZone)(timezone)}`);
56
56
  (0, schedule_1.renderTodoList)(response.todos ?? [], (line) => this.log(line), timezone);
57
+ const hint = (0, schedule_1.failedTodoHint)(response.todos ?? [], args.id, this.config.bin);
58
+ if (hint)
59
+ this.log(hint);
57
60
  }
58
61
  }
59
62
  exports.default = AgentsTodosList;
@@ -126,9 +126,19 @@ class AgentsTriggersPolicy extends base_command_1.BaseCommand {
126
126
  // row seeded at creation. The numbers below then read like a deliberate choice, and for an
127
127
  // Agent with no stored policy they are NOT the seeded ones (24/day, 10/h against 2/day, 1/h)
128
128
  // (OSK-22354).
129
- if (policy.configured === false) {
129
+ // The hard stop is the kill switch: every fire of this Agent's triggers is blocked while it is on. The
130
+ // text view printed the policy's numbers and never said so, beside a note that nobody had set the
131
+ // policy, so an Agent that was stopped read as a default one (OSK-22659). It leads the output, and a
132
+ // stop somebody set means the policy is not 'nobody's choice'.
133
+ const hardStop = policy.hardStop;
134
+ const stopped = hardStop?.enabled === true;
135
+ if (stopped) {
136
+ this.log(`HARD STOP: ON${hardStop?.scope ? ` (${hardStop.scope})` : ''} — every fire of this Agent's triggers is blocked${hardStop?.reason ? `: ${hardStop.reason}` : ''}${hardStop?.activatedAt ? ` (since ${hardStop.activatedAt})` : ''}`);
137
+ }
138
+ if (policy.configured === false && !stopped) {
130
139
  this.log('Note: nobody has set this policy: these are the platform defaults (or the quiet start seeded at creation), not a choice.');
131
140
  }
141
+ this.log(`Hard stop: ${stopped ? 'on' : 'off'}`);
132
142
  this.log(`Mode: ${String(policy.mode ?? '-')}`);
133
143
  this.log(`Allowed kinds: ${Array.isArray(policy.allowedKinds) ? policy.allowedKinds.join(', ') : '-'}`);
134
144
  this.log(`Max fires/day: ${String(policy.maxFiresPerDay ?? '-')}`);
@@ -75,6 +75,8 @@ function renderSessionBillingAccount(target, balance, log, bin = 'skrr') {
75
75
  log(' Held is reserved for hosted sessions, including turns that ended without settling; ' +
76
76
  `\`${bin} balance statement --workspace ${target.workspaceId}\` lists the \`hold\` and ` +
77
77
  '`exception` entries.');
78
+ for (const line of (0, balance_1.heldBreakdownLines)(balance.heldBreakdown))
79
+ log(line);
78
80
  }
79
81
  if (balance.availableMicros <= 0) {
80
82
  log(' WARNING: nothing available — managed sessions billed here are refused for credit, ' +
@@ -178,7 +180,7 @@ class BalanceShow extends base_command_1.BaseCommand {
178
180
  }
179
181
  let balance;
180
182
  try {
181
- balance = await (0, balance_1.getBalance)();
183
+ balance = await (0, balance_1.getBalance)({ holds: 'breakdown' });
182
184
  }
183
185
  catch (err) {
184
186
  this.handleApiError(err);
@@ -189,7 +191,9 @@ class BalanceShow extends base_command_1.BaseCommand {
189
191
  let sessionBalance = null;
190
192
  if (sessionTarget) {
191
193
  try {
192
- sessionBalance = await (0, balance_1.getWorkspaceBalance)(sessionTarget.workspaceId);
194
+ sessionBalance = await (0, balance_1.getWorkspaceBalance)(sessionTarget.workspaceId, {
195
+ holds: 'breakdown',
196
+ });
193
197
  }
194
198
  catch {
195
199
  sessionBalance = null;
@@ -241,6 +245,8 @@ class BalanceShow extends base_command_1.BaseCommand {
241
245
  this.log(' that ends without settling stays held until billing releases');
242
246
  this.log(' it. See the `hold` and `exception` entries in');
243
247
  this.log(' `skrr balance statement`)');
248
+ for (const line of (0, balance_1.heldBreakdownLines)(balance.heldBreakdown))
249
+ this.log(line);
244
250
  }
245
251
  if (balance.balanceSource === 'legacy') {
246
252
  // The unified account is missing for this user, so the figure above is
@@ -396,7 +402,7 @@ class BalanceShow extends base_command_1.BaseCommand {
396
402
  async showWorkspaceBalance(workspaceId, asJson) {
397
403
  let balance;
398
404
  try {
399
- balance = await (0, balance_1.getWorkspaceBalance)(workspaceId);
405
+ balance = await (0, balance_1.getWorkspaceBalance)(workspaceId, { holds: 'breakdown' });
400
406
  }
401
407
  catch (err) {
402
408
  // A 403 here is a real answer, not a glitch: membership is what grants
@@ -436,6 +442,8 @@ class BalanceShow extends base_command_1.BaseCommand {
436
442
  for (const line of (0, balance_1.workspaceBalanceLines)(balance)) {
437
443
  this.log(line);
438
444
  }
445
+ for (const line of (0, balance_1.heldBreakdownLines)(balance.heldBreakdown))
446
+ this.log(line);
439
447
  this.log('');
440
448
  this.log('This is the account a session carrying this workspace bills against —');
441
449
  this.log('the balance named by "this session needs more credit than this');
@@ -116,8 +116,12 @@ function preflightGateLines(gate, verbose = false, refusesActivation = false) {
116
116
  // question.
117
117
  const advisoryBlock = gate.verdict === 'block' && gate.admission === 'advisory' && !refusesActivation;
118
118
  const stopsActivationOnly = gate.verdict === 'block' && gate.admission === 'advisory' && refusesActivation;
119
+ // A deleted Sensor is the one advisory block that must not read lower than a silent one (`warn`):
120
+ // it is the more serious state (OSK-22592).
119
121
  const mark = advisoryBlock
120
- ? 'info'
122
+ ? gate.id === 'sensor_bindings'
123
+ ? 'warn'
124
+ : 'info'
121
125
  : gate.verdict === 'pass'
122
126
  ? 'ok'
123
127
  : gate.verdict === 'block'
@@ -13,6 +13,8 @@ export declare function wakePolicyHeadline(_result?: unknown): string;
13
13
  * on Always-On, the upstream installation and leftover rows, which only the facts carry.
14
14
  */
15
15
  export declare function wakePolicyLines(result?: CommitmentWakeCapabilities): string[];
16
+ /** Why an eligible capability is not offered, in words a person can act on (OSK-22591). */
17
+ export declare function describeUnavailable(reason?: string): string;
16
18
  /**
17
19
  * `skrr commitments wake-capabilities <id>` — which wakes an Agent may pick.
18
20
  *
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.wakePolicyHeadline = wakePolicyHeadline;
4
4
  exports.wakePolicyLines = wakePolicyLines;
5
+ exports.describeUnavailable = describeUnavailable;
5
6
  const core_1 = require("@oclif/core");
6
7
  const base_command_1 = require("../../base-command");
7
8
  const commitments_1 = require("../../lib/commitments");
@@ -44,6 +45,17 @@ function wakePolicyLines(result) {
44
45
  }
45
46
  return lines;
46
47
  }
48
+ /** Why an eligible capability is not offered, in words a person can act on (OSK-22591). */
49
+ function describeUnavailable(reason) {
50
+ switch (reason) {
51
+ case 'sensor_not_found':
52
+ return 'the attached sensor no longer exists. Attach a working sensor or detach this one.';
53
+ case 'sensor_disabled':
54
+ return 'the attached sensor is disabled. Enable it or detach it.';
55
+ default:
56
+ return `the attached sensor cannot deliver (${reason ?? 'unknown reason'}).`;
57
+ }
58
+ }
47
59
  /**
48
60
  * `skrr commitments wake-capabilities <id>` — which wakes an Agent may pick.
49
61
  *
@@ -109,6 +121,10 @@ class CommitmentsWakeCapabilities extends base_command_1.BaseCommand {
109
121
  { key: 'source', header: 'SOURCE' },
110
122
  { key: 'offered', header: 'OFFERED' },
111
123
  ], (line) => this.log(line));
124
+ // A capability can be eligible (still attached) and not offered because what it needs is gone.
125
+ for (const item of result.unavailableCapabilities ?? []) {
126
+ this.log(`Not offered: ${item.id} — ${describeUnavailable(item.reason)}`);
127
+ }
112
128
  }
113
129
  }
114
130
  exports.default = CommitmentsWakeCapabilities;
@@ -46,8 +46,11 @@ export interface BalanceStatus {
46
46
  availableMicros?: number;
47
47
  postedBalanceMicros?: number;
48
48
  /** Committed to work in flight: the gap between "there is a balance" and
49
- * "a new session can start". */
49
+ * "a new session can start". Part of it may be FROZEN rather than in flight;
50
+ * see `heldBreakdown`. */
50
51
  heldMicros?: number;
52
+ /** Only when asked for (`getBalance({ holds: 'breakdown' })`); `null` when the server tried and could not read the holds in time. */
53
+ heldBreakdown?: HeldBreakdown | null;
51
54
  currency?: string;
52
55
  autoRefillEnabled?: boolean;
53
56
  refillIntervalValue?: number;
@@ -59,6 +62,22 @@ export interface BalanceStatus {
59
62
  periodTokensUsed?: number;
60
63
  periodStartDate?: string;
61
64
  }
65
+ /**
66
+ * What `heldMicros` is made of, from `?holds=breakdown`. Held money is reserved for hosted
67
+ * turns. A turn that is running clears on its own; one that ended without settling is FROZEN: its
68
+ * hold expired into an exception, which billing keeps held until it is cleared
69
+ * (docs/runbooks/billing-exceptions.md). Both used to read as "sessions in flight" (OSK-22651).
70
+ */
71
+ export interface HeldBreakdown {
72
+ inFlightMicros: number;
73
+ inFlightCount: number;
74
+ frozenMicros: number;
75
+ frozenCount: number;
76
+ /** When the oldest frozen hold froze, or null when none is. */
77
+ oldestFrozenAt: string | null;
78
+ /** Held in the counter but accounted for by no hold row. */
79
+ unattributedMicros: number;
80
+ }
62
81
  export interface BalanceTransaction {
63
82
  tokenType?: string;
64
83
  context?: string;
@@ -77,7 +96,9 @@ export interface BalanceHistory {
77
96
  hasNextPage: boolean;
78
97
  }
79
98
  /** The account's current credits, limit and period usage. */
80
- export declare function getBalance(): Promise<BalanceStatus>;
99
+ export declare function getBalance(options?: {
100
+ holds?: 'breakdown';
101
+ }): Promise<BalanceStatus>;
81
102
  export declare function getSkyCodeUsage(workspaceId?: string): Promise<TSkyCodeUsageSnapshot>;
82
103
  /** The personal Sky Code subscription, distinct from published agent-service subscriptions. */
83
104
  export declare function getSkyCodeSubscription(): Promise<TSubscription>;
@@ -126,8 +147,12 @@ export interface WorkspaceBalance {
126
147
  availableMicros: number;
127
148
  postedBalanceMicros: number;
128
149
  heldMicros: number;
150
+ /** Only when asked for (`getWorkspaceBalance(id, { holds: 'breakdown' })`); `null` when the server tried and could not read the holds in time. */
151
+ heldBreakdown?: HeldBreakdown | null;
129
152
  }
130
- export declare function getWorkspaceBalance(workspaceId: string): Promise<WorkspaceBalance>;
153
+ export declare function getWorkspaceBalance(workspaceId: string, options?: {
154
+ holds?: 'breakdown';
155
+ }): Promise<WorkspaceBalance>;
131
156
  /**
132
157
  * The heading for a workspace balance, naming the workspace the reader is
133
158
  * looking at. It printed the raw id alone — "workspace 038b2251-…" — even
@@ -147,6 +172,11 @@ export declare function workspaceBalanceHeading(workspaceId: string, name: strin
147
172
  * surface exactly.
148
173
  */
149
174
  export declare function workspaceBalanceLines(balance: Pick<WorkspaceBalance, 'availableMicros' | 'postedBalanceMicros' | 'heldMicros'>): string[];
175
+ /**
176
+ * The lines that say what a Held figure is made of, indented under it. Empty when the server did not
177
+ * send a breakdown (an older server ignores the request), so nothing is invented for it.
178
+ */
179
+ export declare function heldBreakdownLines(held: HeldBreakdown | null | undefined): string[];
150
180
  /**
151
181
  * Render micros as currency. Micros are millionths of a unit, and the balance
152
182
  * that refuses a session is compared against a price — so this rounds to cents
@@ -12,6 +12,7 @@ exports.formatCredits = formatCredits;
12
12
  exports.getWorkspaceBalance = getWorkspaceBalance;
13
13
  exports.workspaceBalanceHeading = workspaceBalanceHeading;
14
14
  exports.workspaceBalanceLines = workspaceBalanceLines;
15
+ exports.heldBreakdownLines = heldBreakdownLines;
15
16
  exports.formatMicros = formatMicros;
16
17
  exports.getBalanceStatement = getBalanceStatement;
17
18
  exports.getWorkspaceBalanceStatement = getWorkspaceBalanceStatement;
@@ -25,8 +26,9 @@ const DESCRIBE_CHARGE_RE = /([a-z0-9])([A-Z])/g;
25
26
  const DESCRIBE_CHARGE_RE_2 = /[_-]+/g;
26
27
  const DESCRIBE_CHARGE_RE_3 = /^./;
27
28
  /** The account's current credits, limit and period usage. */
28
- async function getBalance() {
29
- return (0, api_fetch_1.apiFetch)('/api/balance');
29
+ async function getBalance(options = {}) {
30
+ // Opt-in: the default call is the cheap one every other reader makes.
31
+ return (0, api_fetch_1.apiFetch)(options.holds === 'breakdown' ? '/api/balance?holds=breakdown' : '/api/balance');
30
32
  }
31
33
  async function getSkyCodeUsage(workspaceId) {
32
34
  const path = workspaceId
@@ -96,8 +98,9 @@ function formatCredits(value) {
96
98
  }
97
99
  return Math.round(value).toLocaleString('en-US');
98
100
  }
99
- async function getWorkspaceBalance(workspaceId) {
100
- return (0, api_fetch_1.apiFetch)(`/api/workspaces/${encodeURIComponent(workspaceId)}/billing/balance`);
101
+ async function getWorkspaceBalance(workspaceId, options = {}) {
102
+ const path = `/api/workspaces/${encodeURIComponent(workspaceId)}/billing/balance`;
103
+ return (0, api_fetch_1.apiFetch)(options.holds === 'breakdown' ? `${path}?holds=breakdown` : path);
101
104
  }
102
105
  /**
103
106
  * The heading for a workspace balance, naming the workspace the reader is
@@ -130,6 +133,39 @@ function workspaceBalanceLines(balance) {
130
133
  ` Posted: ${formatCreditsWithUsd(balance.postedBalanceMicros)}`,
131
134
  ];
132
135
  }
136
+ /**
137
+ * The lines that say what a Held figure is made of, indented under it. Empty when the server did not
138
+ * send a breakdown (an older server ignores the request), so nothing is invented for it.
139
+ */
140
+ function heldBreakdownLines(held) {
141
+ if (held === undefined)
142
+ return [];
143
+ // Asked for and not available (the server gave up reading thousands of holds in time): say so,
144
+ // because silence is also what an older server looks like.
145
+ if (held === null) {
146
+ return [
147
+ ' (the in-flight / frozen split is unavailable right now; retry in a moment)',
148
+ ];
149
+ }
150
+ const lines = [];
151
+ if (held.inFlightMicros > 0) {
152
+ lines.push(` in flight ${formatCreditsWithUsd(held.inFlightMicros)}` +
153
+ ` (${held.inFlightCount} hold${held.inFlightCount === 1 ? '' : 's'} on work still running or just ended; clears when it settles)`);
154
+ }
155
+ if (held.frozenMicros > 0) {
156
+ const since = held.oldestFrozenAt
157
+ ? `, the oldest since ${held.oldestFrozenAt.slice(0, 10)}`
158
+ : '';
159
+ lines.push(` frozen ${formatCreditsWithUsd(held.frozenMicros)}` +
160
+ ` (${held.frozenCount} hold${held.frozenCount === 1 ? '' : 's'} from work that ended without settling${since};` +
161
+ ' held until billing clears them)');
162
+ }
163
+ if (held.unattributedMicros > 0) {
164
+ lines.push(` other ${formatCreditsWithUsd(held.unattributedMicros)}` +
165
+ ' (in the held total, not tied to a hold)');
166
+ }
167
+ return lines;
168
+ }
133
169
  /**
134
170
  * Render micros as currency. Micros are millionths of a unit, and the balance
135
171
  * that refuses a session is compared against a price — so this rounds to cents
@@ -14,7 +14,19 @@ function eventWakeLines(caps) {
14
14
  lines.push(` configured sources: ${(caps.configuredSources ?? []).join(', ') || 'none'}`);
15
15
  lines.push(` eligible sources: ${(caps.eligibleSources ?? []).join(', ') || 'none'}`);
16
16
  lines.push(` materialized sources: ${(caps.materializedSources ?? []).join(', ') || 'none'}`);
17
- if ((caps.dormantSources ?? []).length) {
17
+ const wakeableWhenActive = caps.wakeableWhenActive ?? [];
18
+ const eventless = caps.eventlessSources ?? [];
19
+ if (wakeableWhenActive.length || eventless.length) {
20
+ // The server told the causes apart (OSK-22595): a source that would wake once it is active on an
21
+ // event_plus_interval cadence is not the same as one that produces no events.
22
+ if (wakeableWhenActive.length) {
23
+ lines.push(` would wake once active on event_plus_interval: ${wakeableWhenActive.join(', ')} (no event wake is planned for them yet)`);
24
+ }
25
+ if (eventless.length) {
26
+ lines.push(` no events exist for: ${eventless.join(', ')} (see \`skrr triggers event-catalog\`; they can be read by a check but never wake it)`);
27
+ }
28
+ }
29
+ else if ((caps.dormantSources ?? []).length) {
18
30
  lines.push(` dormant sources: ${caps.dormantSources.join(', ')} (configured, but no event wake is planned for them)`);
19
31
  }
20
32
  if ((caps.unroutableSources ?? []).length) {
@@ -713,6 +713,10 @@ export type EventWakeCapabilities = {
713
713
  eligibleSources?: string[];
714
714
  materializedSources?: string[];
715
715
  dormantSources?: string[];
716
+ /** Dormant sources whose events could wake it once it is active on event_plus_interval (OSK-22595). */
717
+ wakeableWhenActive?: string[];
718
+ /** Dormant sources that produce no events at all. */
719
+ eventlessSources?: string[];
716
720
  unroutableSources?: {
717
721
  source?: string;
718
722
  reason?: string;
@@ -753,6 +757,11 @@ export interface CommitmentWakeCapabilities {
753
757
  kind?: string;
754
758
  source?: string;
755
759
  }>;
760
+ /** Eligible capabilities the server withheld, with why: an attached sensor that no longer exists (OSK-22591). */
761
+ unavailableCapabilities?: Array<{
762
+ id: string;
763
+ reason?: string;
764
+ }>;
756
765
  /**
757
766
  * The event-wake facts `trigger-status` reports, verbatim, plus the Agent's own enabled event
758
767
  * waits. Absent from a server that predates it, or when the status could not be read: "no
@@ -1147,6 +1147,16 @@ function describeExecutorBlocked(commitment) {
1147
1147
  : reason || 'blocked';
1148
1148
  return `${label}${until ? ` until ${until}` : ''}`;
1149
1149
  }
1150
+ /**
1151
+ * A Run waiting for a stopped machine cannot be checked for the one thing that
1152
+ * fails it after the start: its working directory must sit inside a Git
1153
+ * repository with a commit, or the daemon refuses the Run with
1154
+ * `EXECUTION_ISOLATION_UNAVAILABLE`. Activation Preflight asks a daemon that is
1155
+ * online and answers `indeterminate` for one that is stopped, so the person who
1156
+ * pays for the start learned of it only afterwards (OSK-22386). The sentence is
1157
+ * conditional on purpose: a runtime with its own sandbox workspace is fine.
1158
+ */
1159
+ const STOPPED_MACHINE_ISOLATION_NOTE = ' If its working directory is not inside a git repository with a commit, each Run is refused (EXECUTION_ISOLATION_UNAVAILABLE); that cannot be checked while the machine is stopped.';
1150
1160
  /**
1151
1161
  * What happens next to a stopped Dedicated machine, said only as far as the
1152
1162
  * server told us (OSK-22392). `wake: 'owner'` is a `manual` power policy:
@@ -1155,11 +1165,12 @@ function describeExecutorBlocked(commitment) {
1155
1165
  * honest sentence makes no promise.
1156
1166
  */
1157
1167
  function describeStoppedMachine(wake) {
1158
- if (wake === 'owner')
1159
- return 'executor machine is stopped and its power policy is manual, so it waits until you start it';
1160
- if (wake === 'automatic')
1161
- return 'executor machine is stopped and will be started for the work';
1162
- return 'executor machine is stopped';
1168
+ const base = wake === 'owner'
1169
+ ? 'executor machine is stopped and its power policy is manual, so it waits until you start it'
1170
+ : wake === 'automatic'
1171
+ ? 'executor machine is stopped and will be started for the work'
1172
+ : 'executor machine is stopped';
1173
+ return `${base}.${STOPPED_MACHINE_ISOLATION_NOTE}`;
1163
1174
  }
1164
1175
  /**
1165
1176
  * The Operation line's wording for a Commitment that is not running because of its lifecycle.
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Why a scheduled run FAILED, in words (OSK-22666).
3
+ *
4
+ * The record carries the cause (`errorCode`, and a sentence for it), but the text surfaces printed the
5
+ * status alone, or the generic code the executor wrote (`scheduled_agent_chat_threw`), so a To-Do refused
6
+ * for lack of credit read as `failed` with nothing to do about it. A balance refusal names whose balance
7
+ * and the command that shows it; any other failure prints the sentence the record gives, and a failure
8
+ * with no sentence returns undefined rather than a guess.
9
+ */
10
+ export declare function failedRunCause(input: {
11
+ errorCode?: string;
12
+ message?: string;
13
+ /** For a narrow table cell: the cause alone, with no next step (the trace carries the full sentence). */
14
+ short?: boolean;
15
+ }): string | undefined;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.failedRunCause = failedRunCause;
4
+ /**
5
+ * Why a scheduled run FAILED, in words (OSK-22666).
6
+ *
7
+ * The record carries the cause (`errorCode`, and a sentence for it), but the text surfaces printed the
8
+ * status alone, or the generic code the executor wrote (`scheduled_agent_chat_threw`), so a To-Do refused
9
+ * for lack of credit read as `failed` with nothing to do about it. A balance refusal names whose balance
10
+ * and the command that shows it; any other failure prints the sentence the record gives, and a failure
11
+ * with no sentence returns undefined rather than a guess.
12
+ */
13
+ function failedRunCause(input) {
14
+ if (input.errorCode === 'UNIFIED_BILLING_INSUFFICIENT_BALANCE') {
15
+ if (input.short)
16
+ return 'Workspace has no available credit';
17
+ return ('The workspace this agent runs in has no available balance for this run. Add credit there, ' +
18
+ 'or check it with `skrr balance show`, then schedule it again.');
19
+ }
20
+ const message = typeof input.message === 'string' ? input.message.trim() : '';
21
+ return message || undefined;
22
+ }
@@ -42,7 +42,8 @@ function renderIngressList(rows, log) {
42
42
  rate: `${r.rateLimit.maxPerMinute}/min`,
43
43
  state: r.enabled ? 'enabled' : 'disabled',
44
44
  })), [
45
- { key: 'label', header: 'LABEL', maxWidth: 26 },
45
+ // Labels share a run tag and differ at the end, so clip the middle (OSK-22596).
46
+ { key: 'label', header: 'LABEL', maxWidth: 26, truncate: 'middle' },
46
47
  { key: 'type', header: 'EVENT TYPE', maxWidth: 24 },
47
48
  { key: 'published', header: 'PUBLISHED', maxWidth: 10 },
48
49
  { key: 'rejected', header: 'REJECTED', maxWidth: 9 },
@@ -19,6 +19,41 @@ const SOURCE_REFUSAL_WORDS = {
19
19
  source_access_revoked: 'access refused',
20
20
  source_access_unavailable: 'access could not be checked just now',
21
21
  };
22
+ /** What an attached Sensor's refusal means, in words (OSK-22592, OSK-22593). */
23
+ const SENSOR_REFUSAL_WORDS = {
24
+ sensor_not_found: 'no longer exists, so this Commitment cannot see events from it. Attach a working sensor or remove the reference',
25
+ sensor_disabled: 'is disabled, so it delivers nothing. Enable it or remove the reference',
26
+ sensor_not_observer: 'is not an observing sensor, so it cannot wake this Commitment',
27
+ sensor_workspace_scope_missing_or_mismatched: 'belongs to a different workspace than this Commitment',
28
+ };
29
+ /** One sentence per attached Sensor that is not delivering, or null when it is. */
30
+ function sensorLine(row) {
31
+ const name = `${row.kind ?? 'sensor'} ${row.refId ?? '(unnamed)'}`;
32
+ if (row.access && row.access !== 'authorized') {
33
+ const why = SENSOR_REFUSAL_WORDS[row.sourceReason ?? ''] ??
34
+ `cannot be read just now (${row.sourceReason ?? row.access})`;
35
+ return `${name} ${why}.`;
36
+ }
37
+ // Rotating the secret fails every sender still on the old one, and the signal that last arrived (if any)
38
+ // came before it, so nothing says the sensor is blind now (OSK-22594).
39
+ const rotatedAt = row.secretRotatedAt;
40
+ const heardAfterRotation = rotatedAt && row.observation?.observedAt
41
+ ? Date.parse(row.observation.observedAt) > Date.parse(rotatedAt)
42
+ : false;
43
+ const rotationNote = rotatedAt && !heardAfterRotation
44
+ ? ` Its secret was rotated ${rotatedAt}; senders still using the old secret are rejected.`
45
+ : '';
46
+ if (!row.observation?.id) {
47
+ return `${name} is ready, but no signal has ever been received.${rotationNote}`;
48
+ }
49
+ if (rotationNote && row.observation.freshness === 'fresh') {
50
+ return `${name}: its last signal came before its secret was rotated.${rotationNote}`;
51
+ }
52
+ if (row.observation.freshness && row.observation.freshness !== 'fresh') {
53
+ return `${name}: its last signal (${row.observation.observedAt ?? 'time unknown'}) is stale.`;
54
+ }
55
+ return null;
56
+ }
22
57
  /** The refusal as `code: words`, or the bare code when it is not one this knows. */
23
58
  function sourceRefusalWords(code) {
24
59
  const words = SOURCE_REFUSAL_WORDS[code];
@@ -68,6 +103,15 @@ function gateExplanationLines(gate) {
68
103
  const rows = Array.isArray(gate.detail?.sources) ? gate.detail.sources : [];
69
104
  return rows.filter((row) => row.access && row.access !== 'authorized').map(sourceRefusalLine);
70
105
  }
106
+ // Its reason is a bare code, and the per-sensor facts (gone, disabled, never signalled) are in the
107
+ // detail: a deleted Sensor printed `info sensor_not_found` and a silent one printed nothing.
108
+ if (gate.id === 'sensor_bindings') {
109
+ const rows = Array.isArray(gate.detail?.sensors) ? gate.detail.sensors : [];
110
+ const lines = rows.map(sensorLine).filter((line) => Boolean(line));
111
+ if (gate.reason === 'sensor_wake_binding_missing')
112
+ lines.push('No wake binding exists for it yet.');
113
+ return lines;
114
+ }
71
115
  if (gate.id === 'access' && gate.reason === 'capability_access_unverified') {
72
116
  return [
73
117
  'No access beyond an identity check is verified as available yet (see “Where access comes from” below).',
@@ -268,6 +268,7 @@ export interface ScheduleTraceEvent {
268
268
  reason?: string;
269
269
  detail?: {
270
270
  reasonCode?: string;
271
+ errorCode?: string;
271
272
  };
272
273
  }
273
274
  export interface ScheduleTrace {
@@ -394,8 +395,10 @@ export declare function todoPolicyBlockMessage(reason?: string): string | undefi
394
395
  * person needs, which is that "pending" here no longer means "not yet".
395
396
  */
396
397
  export declare function todoLateMessage(todo: Pick<Todo, 'status' | 'late'>): string | undefined;
397
- /** Print explanations alongside the trace rows that recorded policy blocks. */
398
+ /** Print explanations alongside the trace rows that recorded policy blocks and failed runs. */
398
399
  export declare function renderTodoPolicyTraceDetails(events: ScheduleTraceEvent[], log: (line: string) => void): void;
400
+ /** The line under a To-Do list that has failed rows: the list says `failed`, the trace says why. */
401
+ export declare function failedTodoHint(todos: Array<Pick<Todo, 'status'>>, agentId?: string, bin?: string): string | undefined;
399
402
  /**
400
403
  * Render a To-Do list as a table. `timeZone` names the zone the WHEN column is
401
404
  * shown in (and is labelled on every row); omitted, rows keep the raw UTC
@@ -15,6 +15,7 @@ exports.describePlanRequest = describePlanRequest;
15
15
  exports.todoPolicyBlockMessage = todoPolicyBlockMessage;
16
16
  exports.todoLateMessage = todoLateMessage;
17
17
  exports.renderTodoPolicyTraceDetails = renderTodoPolicyTraceDetails;
18
+ exports.failedTodoHint = failedTodoHint;
18
19
  exports.renderTodoList = renderTodoList;
19
20
  exports.renderCapacityWarning = renderCapacityWarning;
20
21
  exports.renderReplacementPreview = renderReplacementPreview;
@@ -46,6 +47,7 @@ exports.formatStamp = formatStamp;
46
47
  const data_provider_1 = require("@skrr-ai/data-provider");
47
48
  const format_1 = require("./format");
48
49
  const triggers_1 = require("./triggers");
50
+ const failedRunCause_1 = require("./failedRunCause");
49
51
  const RENDER_PROPOSAL_RE = / 00:00:00 /;
50
52
  function isPlanAccepted(value) {
51
53
  return (Boolean(value) &&
@@ -255,16 +257,30 @@ function todoLateMessage(todo) {
255
257
  return undefined;
256
258
  return `${todo.late.message} (${(0, format_1.formatElapsed)(todo.late.bySeconds)} past its time)`;
257
259
  }
258
- /** Print explanations alongside the trace rows that recorded policy blocks. */
260
+ /** Print explanations alongside the trace rows that recorded policy blocks and failed runs. */
259
261
  function renderTodoPolicyTraceDetails(events, log) {
260
262
  for (const event of events) {
261
- const message = event.type === 'todo_execution_failed'
263
+ const label = event.id ?? event.summary ?? 'To-Do';
264
+ const policy = event.type === 'todo_execution_failed'
262
265
  ? todoPolicyBlockMessage(event.detail?.reasonCode ?? event.reason)
263
266
  : undefined;
264
- if (message)
265
- log(` ${event.id ?? event.summary ?? 'To-Do'}: ${message}`);
267
+ if (policy) {
268
+ log(` ${label}: ${policy}`);
269
+ continue;
270
+ }
271
+ if (event.status === 'failed') {
272
+ const cause = (0, failedRunCause_1.failedRunCause)({ errorCode: event.detail?.errorCode, message: event.reason });
273
+ if (cause && cause !== event.summary)
274
+ log(` ${label}: ${cause}`);
275
+ }
266
276
  }
267
277
  }
278
+ /** The line under a To-Do list that has failed rows: the list says `failed`, the trace says why. */
279
+ function failedTodoHint(todos, agentId, bin = 'skrr') {
280
+ if (!todos.some((todo) => todo.status === 'failed'))
281
+ return undefined;
282
+ return `A failed to-do's cause is in the trace: ${bin} agents schedule-trace ${agentId ?? '<agent-id>'}`;
283
+ }
268
284
  /**
269
285
  * Render a To-Do list as a table. `timeZone` names the zone the WHEN column is
270
286
  * shown in (and is labelled on every row); omitted, rows keep the raw UTC
@@ -158,6 +158,8 @@ export interface TriggerDefinition {
158
158
  status?: string;
159
159
  lastError?: string;
160
160
  lastErrorAt?: string;
161
+ /** A process that cannot register schedules asked for this one; not a failure (OSK-22570). */
162
+ deferredAt?: string;
161
163
  };
162
164
  /**
163
165
  * Server-DERIVED: maintained by a managed producer, so the mutation routes
@@ -212,6 +214,7 @@ export interface TriggerFireRecord {
212
214
  outcome?: string;
213
215
  reason?: string;
214
216
  errorMessage?: string;
217
+ errorCode?: string;
215
218
  executionRef?: string;
216
219
  conversationId?: string;
217
220
  durationMs?: number;
@@ -645,6 +648,10 @@ export declare function nextRunLabel(trigger: TriggerDefinition): string;
645
648
  * and nothing on the agent, trigger or schedule surfaces reported it — so
646
649
  * an operator looking at an enabled trigger had no reason to doubt it
647
650
  * (OSK-7727).
651
+ * `syncing` — `enabled: true`, `unscheduled`, with `deferredAt` and NO `lastError`. A process that
652
+ * cannot register a schedule (the worker that finishes a durable heartbeat) asked the scheduler
653
+ * leader to; nothing has failed. It reads as a state, not as `!unscheduled`, which tells an operator a
654
+ * healthy decision is a fault (OSK-22570). With a `lastError` it is a failure again.
648
655
  * `spent` — a `once` trigger that has fired. It has no next occurrence, so
649
656
  * `enabled` and "will fire again" diverge forever after the single fire; an
650
657
  * agent that has been used for a while accumulates a growing list of
@@ -80,6 +80,7 @@ const node_fs_1 = require("node:fs");
80
80
  const http_error_1 = require("./http-error");
81
81
  const format_1 = require("./format");
82
82
  const planOutcome_1 = require("./planOutcome");
83
+ const failedRunCause_1 = require("./failedRunCause");
83
84
  const PARSE_JSON_ARRAY_RE = /^[[{]/;
84
85
  const ARMED_STATE_LABEL_RE = /^skipped:(.+)$/;
85
86
  const WEBHOOK_INGEST_URL_RE = /\/+$/;
@@ -1254,6 +1255,10 @@ function nextRunLabel(trigger) {
1254
1255
  * and nothing on the agent, trigger or schedule surfaces reported it — so
1255
1256
  * an operator looking at an enabled trigger had no reason to doubt it
1256
1257
  * (OSK-7727).
1258
+ * `syncing` — `enabled: true`, `unscheduled`, with `deferredAt` and NO `lastError`. A process that
1259
+ * cannot register a schedule (the worker that finishes a durable heartbeat) asked the scheduler
1260
+ * leader to; nothing has failed. It reads as a state, not as `!unscheduled`, which tells an operator a
1261
+ * healthy decision is a fault (OSK-22570). With a `lastError` it is a failure again.
1257
1262
  * `spent` — a `once` trigger that has fired. It has no next occurrence, so
1258
1263
  * `enabled` and "will fire again" diverge forever after the single fire; an
1259
1264
  * agent that has been used for a while accumulates a growing list of
@@ -1264,6 +1269,11 @@ function armedLabel(trigger) {
1264
1269
  if (trigger.enabled === false)
1265
1270
  return 'no';
1266
1271
  const sync = trigger.scheduleSync?.status;
1272
+ if (sync === 'unscheduled' &&
1273
+ trigger.scheduleSync?.deferredAt &&
1274
+ !trigger.scheduleSync.lastError) {
1275
+ return 'syncing';
1276
+ }
1267
1277
  if (sync && sync !== 'ok')
1268
1278
  return `!${sync}`;
1269
1279
  if (trigger.kind === 'once' && trigger.once && trigger.once.firedAt) {
@@ -2160,6 +2170,11 @@ function renderFireAudit(fires, log, waiting, options = {}) {
2160
2170
  policyAuditExplanation(fire)?.summary ??
2161
2171
  coalescedAuditExplanation(fire)?.summary ??
2162
2172
  (0, planOutcome_1.fireAuditPlanOutcomeSummary)(fire) ??
2173
+ // A failed run's executor code (`scheduled_agent_chat_threw`) names where it failed, not why;
2174
+ // the record's own cause is the part a person can act on (OSK-22666).
2175
+ (fire.outcome === 'failed'
2176
+ ? (0, failedRunCause_1.failedRunCause)({ errorCode: fire.errorCode, message: fire.errorMessage, short: true })
2177
+ : undefined) ??
2163
2178
  (fire.reason ? fireReasonText(fire.reason) : undefined) ??
2164
2179
  fire.errorMessage ??
2165
2180
  '',
@@ -144381,5 +144381,5 @@
144381
144381
  ]
144382
144382
  }
144383
144383
  },
144384
- "version": "0.1.147"
144384
+ "version": "0.1.149"
144385
144385
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skrr-ai/cli",
3
- "version": "0.1.147",
3
+ "version": "0.1.149",
4
4
  "description": "Command-line interface for skrr",
5
5
  "license": "ISC",
6
6
  "author": "skrr",