@skrr-ai/cli 0.1.148 → 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;
@@ -49,8 +49,8 @@ export interface BalanceStatus {
49
49
  * "a new session can start". Part of it may be FROZEN rather than in flight;
50
50
  * see `heldBreakdown`. */
51
51
  heldMicros?: number;
52
- /** Only when asked for (`getBalance({ holds: 'breakdown' })`). */
53
- heldBreakdown?: HeldBreakdown;
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;
54
54
  currency?: string;
55
55
  autoRefillEnabled?: boolean;
56
56
  refillIntervalValue?: number;
@@ -147,8 +147,8 @@ export interface WorkspaceBalance {
147
147
  availableMicros: number;
148
148
  postedBalanceMicros: number;
149
149
  heldMicros: number;
150
- /** Only when asked for (`getWorkspaceBalance(id, { holds: 'breakdown' })`). */
151
- heldBreakdown?: HeldBreakdown;
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;
152
152
  }
153
153
  export declare function getWorkspaceBalance(workspaceId: string, options?: {
154
154
  holds?: 'breakdown';
@@ -176,7 +176,7 @@ export declare function workspaceBalanceLines(balance: Pick<WorkspaceBalance, 'a
176
176
  * The lines that say what a Held figure is made of, indented under it. Empty when the server did not
177
177
  * send a breakdown (an older server ignores the request), so nothing is invented for it.
178
178
  */
179
- export declare function heldBreakdownLines(held: HeldBreakdown | undefined): string[];
179
+ export declare function heldBreakdownLines(held: HeldBreakdown | null | undefined): string[];
180
180
  /**
181
181
  * Render micros as currency. Micros are millionths of a unit, and the balance
182
182
  * that refuses a session is compared against a price — so this rounds to cents
@@ -138,19 +138,26 @@ function workspaceBalanceLines(balance) {
138
138
  * send a breakdown (an older server ignores the request), so nothing is invented for it.
139
139
  */
140
140
  function heldBreakdownLines(held) {
141
- if (!held)
141
+ if (held === undefined)
142
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
+ }
143
150
  const lines = [];
144
151
  if (held.inFlightMicros > 0) {
145
152
  lines.push(` in flight ${formatCreditsWithUsd(held.inFlightMicros)}` +
146
- ` (${held.inFlightCount} running or just ended; clears when they settle)`);
153
+ ` (${held.inFlightCount} hold${held.inFlightCount === 1 ? '' : 's'} on work still running or just ended; clears when it settles)`);
147
154
  }
148
155
  if (held.frozenMicros > 0) {
149
156
  const since = held.oldestFrozenAt
150
157
  ? `, the oldest since ${held.oldestFrozenAt.slice(0, 10)}`
151
158
  : '';
152
159
  lines.push(` frozen ${formatCreditsWithUsd(held.frozenMicros)}` +
153
- ` (${held.frozenCount} turn${held.frozenCount === 1 ? '' : 's'} that ended without settling${since};` +
160
+ ` (${held.frozenCount} hold${held.frozenCount === 1 ? '' : 's'} from work that ended without settling${since};` +
154
161
  ' held until billing clears them)');
155
162
  }
156
163
  if (held.unattributedMicros > 0) {
@@ -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;
@@ -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
+ }
@@ -34,8 +34,21 @@ function sensorLine(row) {
34
34
  `cannot be read just now (${row.sourceReason ?? row.access})`;
35
35
  return `${name} ${why}.`;
36
36
  }
37
- if (!row.observation?.id)
38
- return `${name} is ready, but no signal has ever been received.`;
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
+ }
39
52
  if (row.observation.freshness && row.observation.freshness !== 'fresh') {
40
53
  return `${name}: its last signal (${row.observation.observedAt ?? 'time unknown'}) is stale.`;
41
54
  }
@@ -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
@@ -214,6 +214,7 @@ export interface TriggerFireRecord {
214
214
  outcome?: string;
215
215
  reason?: string;
216
216
  errorMessage?: string;
217
+ errorCode?: string;
217
218
  executionRef?: string;
218
219
  conversationId?: string;
219
220
  durationMs?: number;
@@ -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 = /\/+$/;
@@ -2169,6 +2170,11 @@ function renderFireAudit(fires, log, waiting, options = {}) {
2169
2170
  policyAuditExplanation(fire)?.summary ??
2170
2171
  coalescedAuditExplanation(fire)?.summary ??
2171
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) ??
2172
2178
  (fire.reason ? fireReasonText(fire.reason) : undefined) ??
2173
2179
  fire.errorMessage ??
2174
2180
  '',
@@ -144381,5 +144381,5 @@
144381
144381
  ]
144382
144382
  }
144383
144383
  },
144384
- "version": "0.1.148"
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.148",
3
+ "version": "0.1.149",
4
4
  "description": "Command-line interface for skrr",
5
5
  "license": "ISC",
6
6
  "author": "skrr",