@skrr-ai/cli 0.1.151 → 0.1.153

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 (76) hide show
  1. package/dist/commands/agent/message/send.d.ts +3 -1
  2. package/dist/commands/agent/message/send.js +52 -1
  3. package/dist/commands/agents/always-on/held-messages.d.ts +22 -0
  4. package/dist/commands/agents/always-on/held-messages.js +62 -0
  5. package/dist/commands/agents/always-on/release-run.d.ts +37 -0
  6. package/dist/commands/agents/always-on/release-run.js +92 -0
  7. package/dist/commands/agents/always-on/status.js +5 -0
  8. package/dist/commands/agents/chat.d.ts +3 -0
  9. package/dist/commands/agents/chat.js +27 -0
  10. package/dist/commands/agents/plan-day.d.ts +3 -0
  11. package/dist/commands/agents/plan-day.js +31 -8
  12. package/dist/commands/agents/show.d.ts +3 -0
  13. package/dist/commands/agents/show.js +59 -3
  14. package/dist/commands/agents/triggers/list.js +2 -1
  15. package/dist/commands/balance/usage/breakdown.d.ts +1 -1
  16. package/dist/commands/balance/usage/breakdown.js +22 -6
  17. package/dist/commands/balance/usage/events.d.ts +3 -2
  18. package/dist/commands/balance/usage/events.js +34 -7
  19. package/dist/commands/duties/create.js +24 -9
  20. package/dist/commands/duties/export.js +2 -1
  21. package/dist/commands/duties/observation/summary.js +25 -3
  22. package/dist/commands/duties/preflight.js +17 -0
  23. package/dist/commands/duties/update.d.ts +1 -0
  24. package/dist/commands/duties/update.js +87 -66
  25. package/dist/commands/goals/plan-now.js +1 -0
  26. package/dist/commands/goals/planner-compare.js +11 -0
  27. package/dist/commands/harnesses/list.d.ts +2 -1
  28. package/dist/commands/harnesses/list.js +7 -5
  29. package/dist/commands/harnesses/models.js +1 -1
  30. package/dist/commands/harnesses/quota.d.ts +9 -11
  31. package/dist/commands/harnesses/quota.js +83 -18
  32. package/dist/commands/harnesses/show.js +1 -1
  33. package/dist/commands/harnesses/usage.d.ts +19 -0
  34. package/dist/commands/harnesses/usage.js +27 -7
  35. package/dist/commands/memory/topics/create.js +4 -1
  36. package/dist/commands/tokens/create.d.ts +3 -4
  37. package/dist/commands/tokens/create.js +20 -7
  38. package/dist/commands/triggers/fire-detail.js +19 -0
  39. package/dist/commands/triggers/preflight.js +9 -2
  40. package/dist/generated/agent-guides.json +35 -35
  41. package/dist/lib/agent-model-check.js +3 -1
  42. package/dist/lib/agentic-stream.js +6 -7
  43. package/dist/lib/balance.d.ts +5 -2
  44. package/dist/lib/balance.js +26 -0
  45. package/dist/lib/config.d.ts +1 -1
  46. package/dist/lib/config.js +1 -0
  47. package/dist/lib/duties.d.ts +5 -0
  48. package/dist/lib/duties.js +75 -1
  49. package/dist/lib/duty-event-wakes.js +6 -3
  50. package/dist/lib/duty-loop-status.js +26 -2
  51. package/dist/lib/duty-product.js +4 -1
  52. package/dist/lib/harness-labels.d.ts +1 -0
  53. package/dist/lib/harness-labels.js +4 -0
  54. package/dist/lib/harnesses.d.ts +35 -0
  55. package/dist/lib/harnesses.js +8 -0
  56. package/dist/lib/held-messages.d.ts +11 -0
  57. package/dist/lib/held-messages.js +93 -0
  58. package/dist/lib/machines.d.ts +2 -1
  59. package/dist/lib/machines.js +2 -2
  60. package/dist/lib/message-intent.d.ts +15 -0
  61. package/dist/lib/publicEndpoints.generated.d.ts +4 -0
  62. package/dist/lib/publicEndpoints.generated.js +4 -0
  63. package/dist/lib/roles.d.ts +1 -1
  64. package/dist/lib/schedule.d.ts +1 -0
  65. package/dist/lib/schedule.js +4 -4
  66. package/dist/lib/triggers.d.ts +15 -3
  67. package/dist/lib/triggers.js +57 -6
  68. package/dist/lib/update-check.d.ts +1 -1
  69. package/dist/lib/update-check.js +21 -10
  70. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/dutyExecutionContract.d.ts +1 -1
  71. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/dutyExecutionContract.js +1 -1
  72. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/dutyExecutionContract.d.ts +1 -1
  73. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/dutyExecutionContract.js +1 -1
  74. package/dist/node_modules/@skrr-ai/data-provider/index.js +7609 -7567
  75. package/oclif.manifest.json +229 -17
  76. package/package.json +4 -3
@@ -171,9 +171,15 @@ function formatLoopSummary(status) {
171
171
  : row.completeness === 'partial'
172
172
  ? 'PARTIAL read'
173
173
  : 'needs attention';
174
- return `${row.source} ${access}${row.reason ? ` (${row.reason})` : ''}`;
174
+ const reason = row.source === 'tasks' && row.reason === 'no_linked_work'
175
+ ? 'no linked tasks were visible at the last check'
176
+ : row.reason;
177
+ return `${row.source} ${access}${reason ? ` (${reason})` : ''}`;
175
178
  });
176
179
  lines.push(`sources: ${!watching.length ? 'none declared' : trouble.length ? trouble.join('; ') : 'all readable'}`);
180
+ for (const wait of waitingRuns(status)) {
181
+ lines.push(`waiting: ${runCount(wait.count)}: ${wait.summary}${wait.fix ? ` — ${wait.fix}` : ''}`);
182
+ }
177
183
  lines.push(`today: ${runs(status)} runs · spend ${spend(status)}`);
178
184
  if (status.readErrors?.length) {
179
185
  lines.push(`unread: ${status.readErrors.join(', ')} could not be read; treat the above as unknown`);
@@ -211,6 +217,9 @@ function formatDutyLoopStatus(status) {
211
217
  if (!watching.length)
212
218
  lines.push(' nothing declared');
213
219
  for (const row of watching) {
220
+ const reason = row.source === 'tasks' && row.reason === 'no_linked_work'
221
+ ? 'no linked tasks were visible at the last check'
222
+ : row.reason;
214
223
  const access = row.access === 'readable'
215
224
  ? row.completeness === 'partial'
216
225
  ? 'readable, PARTIAL read'
@@ -218,7 +227,7 @@ function formatDutyLoopStatus(status) {
218
227
  : row.access === 'blocked'
219
228
  ? 'CANNOT READ'
220
229
  : 'not known';
221
- lines.push(` ${row.source}${row.scope ? ` (${row.scope})` : ''}: ${access}${row.reason ? ` — ${row.reason}` : ''}`);
230
+ lines.push(` ${row.source}${row.scope ? ` (${row.scope})` : ''}: ${access}${reason ? ` — ${reason}` : ''}`);
222
231
  // Optional contract field; read defensively across package builds.
223
232
  const limitations = row.limitations;
224
233
  if (Array.isArray(limitations) && limitations.length) {
@@ -236,6 +245,21 @@ function formatDutyLoopStatus(status) {
236
245
  }
237
246
  }
238
247
  lines.push(` Open loops: ${count(status.pendingWork?.openLoops)} Pending runs: ${count(status.pendingWork?.pendingRuns)}`);
248
+ // Why the pending runs that have not started are waiting (OSK-23175): a count alone read as healthy.
249
+ for (const wait of waitingRuns(status)) {
250
+ lines.push(` Waiting: ${runCount(wait.count)}: ${wait.summary}`);
251
+ lines.push(` ${wait.detail}`);
252
+ if (wait.fix)
253
+ lines.push(` Fix: ${wait.fix}`);
254
+ }
239
255
  lines.push(` Runs today: ${runs(status)} Spend today: ${spend(status)}`);
240
256
  return lines;
241
257
  }
258
+ /** The server's grouped reasons for runs that have not started. Empty from a server that sends none. */
259
+ function waitingRuns(status) {
260
+ const waiting = status.pendingWork?.waiting;
261
+ return Array.isArray(waiting) ? waiting : [];
262
+ }
263
+ function runCount(n) {
264
+ return `${n} run${n === 1 ? '' : 's'}`;
265
+ }
@@ -53,7 +53,10 @@ function renderExecutionReceipt(receipt, log, verbose = false) {
53
53
  }
54
54
  for (const phase of receipt.phases) {
55
55
  const mark = { done: '✓', working: '→', waiting: '…', failed: '×', skipped: '–' }[phase.status];
56
- log(` ${mark} ${phase.phase[0].toUpperCase() + phase.phase.slice(1)}: ${phase.summary}${phase.at ? ` · ${phase.at}` : ''}`);
56
+ const label = phase.phase === 'observed' && receipt.checkKind === 'follow_through'
57
+ ? 'Check'
58
+ : phase.phase[0].toUpperCase() + phase.phase.slice(1);
59
+ log(` ${mark} ${label}: ${phase.summary}${phase.at ? ` · ${phase.at}` : ''}`);
57
60
  for (const evidence of phase.evidence) {
58
61
  const location = evidence.url || evidence.path;
59
62
  if (location)
@@ -20,6 +20,7 @@
20
20
  export declare const NO_CODING_AGENT_PROVIDER_LABEL = "none";
21
21
  export declare function harnessStatusLabel(row: {
22
22
  status?: string | null;
23
+ presenceStatus?: string | null;
23
24
  superseded?: boolean | null;
24
25
  }): string;
25
26
  export declare function isNoCodingAgentProvider(provider: string | null | undefined): boolean;
@@ -30,6 +30,10 @@ exports.NO_CODING_AGENT_PROVIDER_LABEL = 'none';
30
30
  function harnessStatusLabel(row) {
31
31
  if (row.superseded)
32
32
  return 'superseded';
33
+ if (row.presenceStatus === 'unknown')
34
+ return 'unknown';
35
+ if (row.presenceStatus === 'unconfirmed')
36
+ return 'unconfirmed';
33
37
  return typeof row.status === 'string' && row.status.length > 0 ? row.status : 'unknown';
34
38
  }
35
39
  function isNoCodingAgentProvider(provider) {
@@ -51,6 +51,8 @@ export interface Harness {
51
51
  sharedName?: string;
52
52
  aliased?: boolean;
53
53
  status?: string;
54
+ /** Whether this server could observe the local daemon's socket. */
55
+ presenceStatus?: 'connected' | 'unconfirmed' | 'unknown';
54
56
  /**
55
57
  * A later registration on the same machine replaced this row. Sent by both
56
58
  * the list and the single-row routes; human output shows it instead of the
@@ -217,6 +219,39 @@ export declare function getRuntimeMonthlySpend(): Promise<{
217
219
  export declare function listQuotaAccounts(): Promise<{
218
220
  accounts: QuotaAccountSummary[];
219
221
  }>;
222
+ export interface CurrentQuotaReport {
223
+ version: 1;
224
+ scope: 'recent_quota_observations';
225
+ provider: 'claude' | 'codex';
226
+ observedAt: number;
227
+ sampleFrom: number;
228
+ sampleLimit: number;
229
+ limitations: string[];
230
+ truncated: boolean;
231
+ account: {
232
+ externalAccountId: string;
233
+ accountLabel: string | null;
234
+ planTier: string | null;
235
+ daemonId: string | null;
236
+ lastSeenAt: number;
237
+ } | null;
238
+ readings: Array<{
239
+ capturedAt: number;
240
+ limitType: string;
241
+ scopeKey: string;
242
+ utilization: number;
243
+ resetsAt: number | null;
244
+ rateLimited: boolean;
245
+ windowSeconds: number | null;
246
+ stale: boolean;
247
+ resetState: 'unknown' | 'elapsed' | 'upcoming';
248
+ }>;
249
+ }
250
+ /** Recent, bounded observations; never falls back to the full history endpoint. */
251
+ export declare function getCurrentQuota(params: {
252
+ provider: 'claude' | 'codex';
253
+ externalAccountId?: string;
254
+ }): Promise<CurrentQuotaReport>;
220
255
  /**
221
256
  * One account's reading series plus the spend buckets over the same horizon.
222
257
  *
@@ -10,6 +10,7 @@ exports.getHarnessUsage = getHarnessUsage;
10
10
  exports.getAllHarnessUsage = getAllHarnessUsage;
11
11
  exports.getRuntimeMonthlySpend = getRuntimeMonthlySpend;
12
12
  exports.listQuotaAccounts = listQuotaAccounts;
13
+ exports.getCurrentQuota = getCurrentQuota;
13
14
  exports.getQuotaHistory = getQuotaHistory;
14
15
  exports.updateHarness = updateHarness;
15
16
  exports.forgetHarness = forgetHarness;
@@ -135,6 +136,13 @@ async function getRuntimeMonthlySpend() {
135
136
  async function listQuotaAccounts() {
136
137
  return (0, api_fetch_1.apiFetch)('/api/harnesses/quota/accounts');
137
138
  }
139
+ /** Recent, bounded observations; never falls back to the full history endpoint. */
140
+ async function getCurrentQuota(params) {
141
+ const query = new URLSearchParams({ provider: params.provider });
142
+ if (params.externalAccountId)
143
+ query.set('externalAccountId', params.externalAccountId);
144
+ return (0, api_fetch_1.apiFetch)('/api/harnesses/quota/current?' + query.toString());
145
+ }
138
146
  /**
139
147
  * One account's reading series plus the spend buckets over the same horizon.
140
148
  *
@@ -0,0 +1,11 @@
1
+ import type { HeldOwnerMessages } from '@skrr-ai/data-provider';
2
+ /** The sentence for a reason code, or an explicit "unrecognised" line carrying the code. */
3
+ export declare function heldReasonLabel(reason: string): string;
4
+ /**
5
+ * Accept a response only if it has the documented shape. A body that merely LOOKS empty (a proxy
6
+ * page, a server that answers a different contract) must not render as "no held messages": that is
7
+ * the one reading that would reassure about exactly the thing this command exists to show.
8
+ */
9
+ export declare function parseHeldOwnerMessages(value: unknown): HeldOwnerMessages | null;
10
+ /** Human-readable output, one block per message. Pure, so the command's wording is testable. */
11
+ export declare function heldMessageLines(agentId: string, result: HeldOwnerMessages): string[];
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.heldReasonLabel = heldReasonLabel;
4
+ exports.parseHeldOwnerMessages = parseHeldOwnerMessages;
5
+ exports.heldMessageLines = heldMessageLines;
6
+ /**
7
+ * Presentation of `GET /api/agents/:id/always-on/held-messages` for `skrr agents always-on
8
+ * held-messages`.
9
+ *
10
+ * What the endpoint is: the CURRENT OWNER's session app-DMs that the delivery policy is holding for
11
+ * one agent in one workspace. It returns metadata only (an id, when it was submitted, when the hold
12
+ * expires, and a neutral reason code). Message text is never returned: the service withholds it
13
+ * until the message's source lineage has a revocation-safe authorization and deletion contract.
14
+ *
15
+ * What it is NOT: the `ask_first` queue. Those are `skrr agent message pending|approve|decline`.
16
+ * A held message here follows the delivery policy and there is no manual release, so nothing in
17
+ * this output points at one.
18
+ */
19
+ /**
20
+ * English labels for the reason codes the service emits (`HeldOwnerMessageService` `REASONS`, plus
21
+ * its `policy_hold` default). The web keeps its own copy in client i18n (`HELD_REASON_KEYS`) because
22
+ * it is localised; the CLI is English-only, so this is a second copy of the sentences and not of the
23
+ * vocabulary. A code missing from this map is printed AS ITSELF and never relabelled as a known one,
24
+ * so the server gaining a reason degrades to showing the raw code and not to a wrong sentence.
25
+ */
26
+ const HELD_REASON_LABELS = {
27
+ policy_hold: 'Held by delivery policy',
28
+ destination_not_allowed: 'This destination is not allowed by the delivery policy',
29
+ delivery_mode_off: 'Message delivery is off',
30
+ delivery_mode_suggestions_only: 'The delivery policy allows suggestions only',
31
+ delivery_policy_unavailable: 'The delivery policy could not be checked',
32
+ prior_delivery_pending: 'An earlier message is still pending',
33
+ quiet_hours: 'Held during quiet hours',
34
+ do_not_disturb: 'Held while Do Not Disturb is active',
35
+ rate_limit: 'Held by an attention rate limit',
36
+ check_unavailable: 'A delivery check was unavailable',
37
+ };
38
+ /** The sentence for a reason code, or an explicit "unrecognised" line carrying the code. */
39
+ function heldReasonLabel(reason) {
40
+ return HELD_REASON_LABELS[reason] ?? `Unrecognised reason: ${reason}`;
41
+ }
42
+ const isNonEmptyString = (value) => typeof value === 'string' && value.length > 0;
43
+ /**
44
+ * Accept a response only if it has the documented shape. A body that merely LOOKS empty (a proxy
45
+ * page, a server that answers a different contract) must not render as "no held messages": that is
46
+ * the one reading that would reassure about exactly the thing this command exists to show.
47
+ */
48
+ function parseHeldOwnerMessages(value) {
49
+ if (!value || typeof value !== 'object')
50
+ return null;
51
+ const body = value;
52
+ if (!Array.isArray(body.messages) || !isNonEmptyString(body.observedAt))
53
+ return null;
54
+ if (body.nextCursor !== undefined && !isNonEmptyString(body.nextCursor))
55
+ return null;
56
+ for (const message of body.messages) {
57
+ if (!message || typeof message !== 'object')
58
+ return null;
59
+ const row = message;
60
+ if (!isNonEmptyString(row.id) || !isNonEmptyString(row.reason))
61
+ return null;
62
+ if (!isNonEmptyString(row.submittedAt))
63
+ return null;
64
+ if (row.expiresAt !== undefined && !isNonEmptyString(row.expiresAt))
65
+ return null;
66
+ }
67
+ return body;
68
+ }
69
+ /** Human-readable output, one block per message. Pure, so the command's wording is testable. */
70
+ function heldMessageLines(agentId, result) {
71
+ const lines = [];
72
+ lines.push(`Agent: ${agentId}`);
73
+ lines.push(`Checked: ${result.observedAt} (delivery status can change)`);
74
+ lines.push(result.messages.length === 0
75
+ ? 'Held: none'
76
+ : `Held: ${result.messages.length} shown${result.nextCursor ? ', more available' : ''}`);
77
+ for (const message of result.messages) {
78
+ lines.push('');
79
+ lines.push(` ${message.id}`);
80
+ lines.push(` Reason: ${message.reason} - ${heldReasonLabel(message.reason)}`);
81
+ lines.push(` Submitted: ${message.submittedAt}`);
82
+ if (message.expiresAt) {
83
+ lines.push(` Expires: ${message.expiresAt} (not a promised release time)`);
84
+ }
85
+ }
86
+ lines.push('');
87
+ // Said on every output, empty included: "none" on its own reads as "nothing is held anywhere".
88
+ lines.push('Scope: your held session messages for this agent in this workspace; other held message types are not shown.');
89
+ lines.push('Message text is not returned. These messages follow your delivery policy; there is no manual release.');
90
+ if (result.nextCursor)
91
+ lines.push(`next page: --cursor ${result.nextCursor}`);
92
+ return lines;
93
+ }
@@ -39,6 +39,7 @@ import type { DaemonContactState, DaemonMaintenanceSummary, MachineIcon, Machine
39
39
  */
40
40
  export type MachineIdentityKind = 'runtime-lease' | 'machine-uuid' | 'stable-daemon' | 'daemon' | 'virtual-product' | 'harness';
41
41
  export interface MachineHarnessRow {
42
+ presenceStatus?: 'connected' | 'unconfirmed' | 'unknown';
42
43
  id: string;
43
44
  name: string;
44
45
  provider: string;
@@ -218,7 +219,7 @@ export interface MachineDaemonSummary {
218
219
  * `stale` when some are recorded online but none has been heard from lately,
219
220
  * `offline` otherwise.
220
221
  */
221
- status: 'online' | 'reconnecting' | 'stale' | 'offline';
222
+ status: 'online' | 'reconnecting' | 'stale' | 'unconfirmed' | 'unknown' | 'offline';
222
223
  lastSeenAt: string | null;
223
224
  harnessCount: number;
224
225
  /** Of those, how many a newer registration of the same provider replaced. */
@@ -45,7 +45,7 @@ function machineStateLabel(machine) {
45
45
  // (OSK-16442).
46
46
  if (machine.status === 'degraded') {
47
47
  const contact = machine.contact?.state;
48
- if (contact === 'stale' || contact === 'reconnecting')
48
+ if (contact === 'stale' || contact === 'reconnecting' || contact === 'unconfirmed' || contact === 'unknown')
49
49
  return data_provider_1.DAEMON_CONTACT_WORDS[contact];
50
50
  }
51
51
  if (machine.status !== 'offline')
@@ -144,7 +144,7 @@ function newerStamp(a, b) {
144
144
  return a;
145
145
  return new Date(b).getTime() > new Date(a).getTime() ? b : a;
146
146
  }
147
- const RANK = { online: 0, reconnecting: 1, stale: 2, offline: 3 };
147
+ const RANK = { online: 0, reconnecting: 1, unconfirmed: 2, unknown: 3, stale: 4, offline: 5 };
148
148
  /** The profile a harness row belongs to: the server's field, else the one its legacy daemon id names. */
149
149
  function harnessProfileOf(row) {
150
150
  if (row.profile)
@@ -103,8 +103,23 @@ export type CanonicalMessageIntentResponse = {
103
103
  * output that a priority was lowered (OSK-22368). Absent from an older server.
104
104
  */
105
105
  presentation?: Pick<CommunicationPresentation, 'kind' | 'attention' | 'attentionRequested'>;
106
+ /**
107
+ * Whether One Voice counted this delivered message against the owner's shared attention budget, so
108
+ * the platform's heuristic producers back off (OSK-22367). Present on a delivered response only;
109
+ * absent from an older server.
110
+ */
111
+ oneVoice?: OneVoiceOutcome;
106
112
  [key: string]: unknown;
107
113
  };
114
+ /**
115
+ * `reason` is open on purpose: a newer server may name a reason this CLI has no wording for, and it
116
+ * is shown as sent rather than dropped.
117
+ */
118
+ export type OneVoiceOutcome = {
119
+ counted: boolean;
120
+ reason?: 'interactive_session' | 'not_owner_attention_destination' | 'accounting_failed' | string;
121
+ lease?: 'claimed' | 'contended' | 'unavailable';
122
+ };
108
123
  export type AgentSessionMessageContext = {
109
124
  token: string;
110
125
  sessionId: string | null;
@@ -7,4 +7,8 @@ export declare const OVERSKY_ENVIRONMENT_ENDPOINTS: Readonly<{
7
7
  readonly appUrl: "https://oversky.dev";
8
8
  readonly realtimeUrl: "https://api.oversky.dev";
9
9
  }>;
10
+ readonly preprod: Readonly<{
11
+ readonly appUrl: "https://skrr.io";
12
+ readonly realtimeUrl: "https://api.skrr.io";
13
+ }>;
10
14
  }>;
@@ -12,4 +12,8 @@ exports.OVERSKY_ENVIRONMENT_ENDPOINTS = Object.freeze({
12
12
  "appUrl": "https://oversky.dev",
13
13
  "realtimeUrl": "https://api.oversky.dev"
14
14
  }),
15
+ preprod: Object.freeze({
16
+ "appUrl": "https://skrr.io",
17
+ "realtimeUrl": "https://api.skrr.io"
18
+ }),
15
19
  });
@@ -53,7 +53,7 @@ export declare const roleApi: {
53
53
  config?: Record<string, unknown> | undefined;
54
54
  }[];
55
55
  sources: {
56
- source: "space" | "tasks" | "memory" | "daemon" | "email" | "goal" | "files" | "local" | "browser" | "conversations" | "slack" | "agent_initiatives" | "github" | "messages" | "calendar" | "docs" | "metrics" | "agent_run" | "documents" | "product_metrics" | "business_metrics" | "state_monitor" | "monitor";
56
+ source: "space" | "tasks" | "memory" | "daemon" | "email" | "goal" | "files" | "local" | "browser" | "conversations" | "slack" | "agent_initiatives" | "messages" | "github" | "calendar" | "docs" | "metrics" | "agent_run" | "documents" | "product_metrics" | "business_metrics" | "state_monitor" | "monitor";
57
57
  enabled: boolean;
58
58
  config?: Record<string, unknown> | undefined;
59
59
  }[];
@@ -106,6 +106,7 @@ export interface SmartScheduleProposal {
106
106
  contextSummary: {
107
107
  spaceName?: string;
108
108
  taskScope?: 'lead_space' | 'no_lead_space' | 'unavailable';
109
+ taskScopeGuidance?: string;
109
110
  goalCount: number;
110
111
  openTaskCount: number;
111
112
  truncated: boolean;
@@ -390,13 +390,13 @@ function renderProposal(proposal, log) {
390
390
  const ctx = proposal.contextSummary;
391
391
  log(`Context: ${ctx.openTaskCount} open task(s), ${ctx.goalCount} goal(s)` +
392
392
  `${ctx.spaceName ? ` · ${ctx.spaceName}` : ''}${ctx.truncated ? ' (truncated)' : ''}`);
393
- const taskScope = ctx.taskScope === 'lead_space'
394
- ? 'Tasks were checked only in the lead Space; assigned tasks in other Spaces were not checked.'
393
+ const taskScope = ctx.taskScopeGuidance || (ctx.taskScope === 'lead_space'
394
+ ? 'Tasks were checked only in the selected lead Space; unscoped tasks and tasks in other Spaces were not checked.'
395
395
  : ctx.taskScope === 'no_lead_space'
396
- ? 'No lead Space was found; assigned tasks in other Spaces were not checked.'
396
+ ? 'No lead Space was found, so no tasks were checked, including tasks assigned to this Agent. Make the Agent the lead of a Space and place the tasks there before planning again.'
397
397
  : ctx.taskScope === 'unavailable'
398
398
  ? 'Task context was unavailable; the count may be incomplete.'
399
- : 'Task search scope was not recorded for this proposal.';
399
+ : 'Task search scope was not recorded for this proposal.');
400
400
  log(`Task scope: ${taskScope}`);
401
401
  if (proposal.expiresAt) {
402
402
  const expires = (0, format_1.zonedTime)(proposal.expiresAt, zone);
@@ -1,4 +1,4 @@
1
- import { type EmbeddedActionRef, type TriggerIntentUnsupportedItem, type TriggerPreflightReport, type TriggerSensorConfig } from '@skrr-ai/data-provider';
1
+ import { type EmbeddedActionRef, type FireRunClaimRefusal, type TriggerIntentUnsupportedItem, type TriggerPreflightReport, type TriggerSensorConfig } from '@skrr-ai/data-provider';
2
2
  export declare const TRIGGER_KINDS: readonly ["schedule", "once", "event", "stochastic", "self_scheduled", "on_demand", "form", "chat_message"];
3
3
  /**
4
4
  * The scope kinds the trigger endpoints accept. NOT a list of its own: `@skrr-ai/data-provider` owns it
@@ -219,6 +219,11 @@ export interface TriggerFireRecord {
219
219
  conversationId?: string;
220
220
  durationMs?: number;
221
221
  finalizedAt?: string;
222
+ /**
223
+ * Fire-detail read only: the durable Run is still queued behind a refused claim (for example
224
+ * waiting for the previous executor's stop receipt). Absent is not proof that nothing holds it.
225
+ */
226
+ claimRefusal?: FireRunClaimRefusal;
222
227
  metadata?: {
223
228
  recordKind?: string;
224
229
  afterOccurrenceId?: string;
@@ -715,8 +720,8 @@ export declare function claimsAwaitingStartLine(limits?: SchedulerLimits | null)
715
720
  * Human phrasing for a trigger's enabled state (OSK-4886).
716
721
  *
717
722
  * `Enabled: yes` never used the vocabulary the create flow does — a trigger is
718
- * "armed" when it will fire and "inert" until enabled — so a freshly-created
719
- * trigger did not plainly confirm it is live.
723
+ * "armed" when enabled and "inert" until enabled. Execution still depends
724
+ * on live gates which this stored trigger summary cannot establish.
720
725
  */
721
726
  export declare function armedStateLabel(enabled: boolean | undefined, lastResult?: string | null,
722
727
  /**
@@ -847,6 +852,13 @@ export declare function coalescedAuditExplanation(fire: {
847
852
  summary: string;
848
853
  detail: string;
849
854
  } | null;
855
+ /**
856
+ * One sentence on a scheduled fire that started long after the scheduler claimed it, or null when it
857
+ * started promptly or the record carries no timing (OSK-22613). `metadata.startLag` is the
858
+ * scheduler's own stage breakdown; this only reads it. "Most of that" is said only when the longest
859
+ * stage really is at least half of the span.
860
+ */
861
+ export declare function scheduleStartLagSentence(metadata: unknown, thresholdMs?: number): string | null;
850
862
  /** One sentence saying whether the fire left an inbox card, or null for a fire that predates the record. */
851
863
  export declare function policyCardSentence(policyCard: unknown): string | null;
852
864
  export declare function policyAuditExplanation(fire: {
@@ -70,6 +70,7 @@ exports.windowVerdictLines = windowVerdictLines;
70
70
  exports.lastResultLabel = lastResultLabel;
71
71
  exports.clockSkipAuditExplanation = clockSkipAuditExplanation;
72
72
  exports.coalescedAuditExplanation = coalescedAuditExplanation;
73
+ exports.scheduleStartLagSentence = scheduleStartLagSentence;
73
74
  exports.policyCardSentence = policyCardSentence;
74
75
  exports.policyAuditExplanation = policyAuditExplanation;
75
76
  exports.fireReasonText = fireReasonText;
@@ -1095,10 +1096,16 @@ function formatFireInZone(iso, timeZone) {
1095
1096
  }
1096
1097
  }
1097
1098
  function nextFireLines(schedule) {
1098
- if (!schedule?.nextFires?.length)
1099
+ if (!schedule)
1099
1100
  return [];
1101
+ const lines = [];
1102
+ if (schedule.nextFireAt) {
1103
+ lines.push(`Stored due time: ${formatFireInZone(schedule.nextFireAt, schedule.timezone)}`);
1104
+ }
1105
+ if (!schedule.nextFires?.length)
1106
+ return lines;
1100
1107
  const windows = new Map((schedule.nextFireWindows ?? []).map((entry) => [entry.at, entry]));
1101
- const lines = [`Next fires (${schedule.timezone}):`];
1108
+ lines.push(`Projected schedule slots (${schedule.timezone}):`);
1102
1109
  for (const at of schedule.nextFires) {
1103
1110
  const window = windows.get(at);
1104
1111
  const mark = window && !window.runs
@@ -1467,8 +1474,8 @@ function claimsAwaitingStartLine(limits) {
1467
1474
  * Human phrasing for a trigger's enabled state (OSK-4886).
1468
1475
  *
1469
1476
  * `Enabled: yes` never used the vocabulary the create flow does — a trigger is
1470
- * "armed" when it will fire and "inert" until enabled — so a freshly-created
1471
- * trigger did not plainly confirm it is live.
1477
+ * "armed" when enabled and "inert" until enabled. Execution still depends
1478
+ * on live gates which this stored trigger summary cannot establish.
1472
1479
  */
1473
1480
  function armedStateLabel(enabled, lastResult,
1474
1481
  /**
@@ -1503,6 +1510,8 @@ windowVerdict) {
1503
1510
  }
1504
1511
  if (enabled === false)
1505
1512
  return 'no — inert until enabled';
1513
+ if (enabled !== true)
1514
+ return 'unknown — enabled state was not reported (see `skrr triggers preflight <id>`)';
1506
1515
  if (schedulerLimits?.state === 'reached')
1507
1516
  return `no — ${schedulerLimitSentence(schedulerLimits)}`;
1508
1517
  if (windowVerdict?.state === 'blocks_all') {
@@ -1511,13 +1520,13 @@ windowVerdict) {
1511
1520
  if (windowVerdict?.state === 'blocks_next') {
1512
1521
  return `yes — but its next run falls ${windowVerdict.reason === 'outside_working_hours' ? 'outside its working hours' : 'inside its quiet hours'} and will be skipped`;
1513
1522
  }
1514
- // "Will fire" is the row's intent. A platform-managed row whose owner is fenced (Always-On off) ticks on
1523
+ // A platform-managed row whose owner is fenced (Always-On off) ticks on
1515
1524
  // schedule and is skipped every time, and the same screen's `Fires:` line says so; the first line a reader
1516
1525
  // meets must not say the opposite (dogfood df-261031-duty-authoring, OSK-21103).
1517
1526
  const skipped = typeof lastResult === 'string' ? ARMED_STATE_LABEL_RE.exec(lastResult) : null;
1518
1527
  return skipped
1519
1528
  ? `yes — but its last tick was skipped (${skipped[1]}), so it did not run`
1520
- : 'yes — will fire';
1529
+ : 'yes — enabled; execution depends on current gates (see `skrr triggers preflight <id>`)';
1521
1530
  }
1522
1531
  /**
1523
1532
  * Human phrasing for an effect trigger's write mode (OSK-4886).
@@ -2105,6 +2114,48 @@ const POLICY_CARD_REASONS = {
2105
2114
  initiative_policy_source_off: 'this source is switched off for the Agent',
2106
2115
  initiative_policy_channel_off: 'this channel is switched off for the Agent',
2107
2116
  };
2117
+ /** What each claim-to-start stage means to a person (the vocabulary is `SCHEDULE_START_LAG_STAGES`). */
2118
+ const START_LAG_STAGE_PHRASES = {
2119
+ prior_attempt_wait: 'earlier hand-off attempts and their retry delays',
2120
+ dispatch_queue_wait: 'waiting for a free dispatcher slot',
2121
+ dispatch_pool_wait: 'waiting for a runner inside one dispatcher pass',
2122
+ handoff_to_start: 'the hand-off to the executor',
2123
+ };
2124
+ /**
2125
+ * One sentence on a scheduled fire that started long after the scheduler claimed it, or null when it
2126
+ * started promptly or the record carries no timing (OSK-22613). `metadata.startLag` is the
2127
+ * scheduler's own stage breakdown; this only reads it. "Most of that" is said only when the longest
2128
+ * stage really is at least half of the span.
2129
+ */
2130
+ function scheduleStartLagSentence(metadata, thresholdMs = data_provider_1.SCHEDULE_START_LAG_WARN_DEFAULT_MS) {
2131
+ if (!metadata || typeof metadata !== 'object' || Array.isArray(metadata))
2132
+ return null;
2133
+ const lag = metadata.startLag;
2134
+ if (!lag || typeof lag !== 'object' || Array.isArray(lag))
2135
+ return null;
2136
+ const { claimToStartMs, stagesMs } = lag;
2137
+ if (typeof claimToStartMs !== 'number' || !Number.isFinite(claimToStartMs))
2138
+ return null;
2139
+ if (claimToStartMs <= thresholdMs)
2140
+ return null;
2141
+ const spans = stagesMs && typeof stagesMs === 'object' && !Array.isArray(stagesMs)
2142
+ ? stagesMs
2143
+ : {};
2144
+ let dominant;
2145
+ let dominantMs = 0;
2146
+ for (const stage of data_provider_1.SCHEDULE_START_LAG_STAGES) {
2147
+ const ms = spans[stage];
2148
+ if (typeof ms === 'number' && Number.isFinite(ms) && ms > dominantMs) {
2149
+ dominant = stage;
2150
+ dominantMs = ms;
2151
+ }
2152
+ }
2153
+ const head = `Started ${(0, format_1.formatElapsed)(claimToStartMs / 1000)} after it was claimed`;
2154
+ if (!dominant)
2155
+ return `${head}.`;
2156
+ const lead = dominantMs * 2 >= claimToStartMs ? 'most of that was' : 'the longest part was';
2157
+ return `${head}; ${lead} ${START_LAG_STAGE_PHRASES[dominant]} (${(0, format_1.formatElapsed)(dominantMs / 1000)}).`;
2158
+ }
2108
2159
  /** One sentence saying whether the fire left an inbox card, or null for a fire that predates the record. */
2109
2160
  function policyCardSentence(policyCard) {
2110
2161
  if (!policyCard || typeof policyCard !== 'object' || Array.isArray(policyCard))
@@ -81,7 +81,7 @@ export declare function resolveCliPackageDir(argv?: readonly string[]): string |
81
81
  * `dist` and no `src`.
82
82
  */
83
83
  export declare function classifyCliInstall(env: NodeJS.ProcessEnv, argv: readonly string[], npmGlobalRoot: string | null, probeWritable?: boolean): CliInstallDescriptor;
84
- export declare function cliUpdateCommand(owner: CliInstallKind, npmPrefix?: string): string;
84
+ export declare function cliUpdateCommand(owner: CliInstallKind, npmPrefix?: string, offeredVersion?: string | null): string;
85
85
  export declare function buildNudgeLine(currentVersion: string, latest: string | null, _npmPackage: string | null, installKind?: CliInstallKind, npmPrefix?: string): string | null;
86
86
  export type CliUpdateAction = {
87
87
  type: 'nudge';
@@ -287,12 +287,17 @@ async function resolveNpmGlobalRoot(env = process.env) {
287
287
  return null;
288
288
  }
289
289
  }
290
- function cliUpdateCommand(owner, npmPrefix) {
290
+ function cliUpdateCommand(owner, npmPrefix, offeredVersion) {
291
+ // The offered version comes from remote metadata or a local cache. Only put
292
+ // an exact, shell-safe npm version into an executable suggestion.
293
+ const version = offeredVersion && /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(offeredVersion)
294
+ ? offeredVersion
295
+ : 'latest';
291
296
  switch (owner) {
292
297
  case 'npm-global':
293
298
  return npmPrefix
294
- ? `npm install --global --prefix '${npmPrefix.replace(CLI_UPDATE_COMMAND_RE, "'\\''")}' ${CLI_PACKAGE}@latest`
295
- : `npm install -g ${CLI_PACKAGE}@latest`;
299
+ ? `npm install --global --prefix '${npmPrefix.replace(CLI_UPDATE_COMMAND_RE, "'\\''")}' ${CLI_PACKAGE}@${version}`
300
+ : `npm install -g ${CLI_PACKAGE}@${version}`;
296
301
  case 'npm-local':
297
302
  return `Use npm in the project that owns ${CLI_PACKAGE}`;
298
303
  case 'dev':
@@ -310,8 +315,7 @@ function cliUpdateCommand(owner, npmPrefix) {
310
315
  function buildNudgeLine(currentVersion, latest, _npmPackage, installKind = 'npm-global', npmPrefix) {
311
316
  if (!latest || !isOlderVersion(currentVersion, latest))
312
317
  return null;
313
- const command = installKind === 'npm-global' && !npmPrefix
314
- ? `npm update -g ${CLI_PACKAGE}` : cliUpdateCommand(installKind, npmPrefix);
318
+ const command = cliUpdateCommand(installKind, npmPrefix, latest);
315
319
  const context = installKind === 'dev'
316
320
  ? ' to rebuild your checkout'
317
321
  : '';
@@ -349,7 +353,7 @@ function decideCliUpdateAction(args) {
349
353
  if (attempt?.status === 'failed')
350
354
  return {
351
355
  type: 'nudge',
352
- line: `[skrr] CLI update to ${cache.latest} failed. Inspect \`skrr update --status\` or run \`${cliUpdateCommand(install.kind, install.npmPrefix)}\`.\n`,
356
+ line: `[skrr] CLI update to ${cache.latest} failed. Inspect \`skrr update --status\` or run \`${cliUpdateCommand(install.kind, install.npmPrefix, cache.latest)}\`.\n`,
353
357
  };
354
358
  }
355
359
  const line = buildNudgeLine(currentVersion, cache.latest, CLI_PACKAGE, install.kind, install.npmPrefix);
@@ -453,7 +457,7 @@ function readCliUpdateStatus(opts) {
453
457
  else if ((lastAttempt?.status === 'queued' || lastAttempt?.status === 'running') &&
454
458
  installedVersion !== lastAttempt.version)
455
459
  state = 'pending';
456
- else if (lastAttempt?.status === 'failed' && newer)
460
+ else if (lastAttempt?.status === 'failed' && newer && lastAttempt.version === offeredVersion)
457
461
  state = 'failed';
458
462
  else if (installedVersion && isOlderVersion(opts.currentVersion, installedVersion))
459
463
  state = 'restart-pending';
@@ -488,11 +492,18 @@ function readCliUpdateStatus(opts) {
488
492
  state,
489
493
  autoUpdateAllowed: autoUpdateReason === null,
490
494
  autoUpdateReason,
491
- command: cliUpdateCommand(install.kind, install.npmPrefix),
495
+ command: cliUpdateCommand(install.kind, install.npmPrefix, offeredVersion),
492
496
  lastCheckAt: matchingCache?.lastCheckAt ?? null,
493
497
  lastAttempt,
494
498
  logPath: path.join(directory, 'update.log'),
495
- message: lastAttempt?.message,
499
+ // Receipts remain history. Do not present an unrelated failure as the
500
+ // current status, or an older success as a newer uninstalled offer.
501
+ message: (lastAttempt?.status === 'failed' && offeredVersion &&
502
+ (lastAttempt.version !== offeredVersion || !newer)) ||
503
+ (state === 'update-available' && lastAttempt?.status === 'succeeded' &&
504
+ offeredVersion && lastAttempt.version !== offeredVersion)
505
+ ? undefined
506
+ : lastAttempt?.message,
496
507
  };
497
508
  }
498
509
  /** Bounded discovery, also usable without a daemon, account, or TTY. */
@@ -613,7 +624,7 @@ async function performCliUpdate(opts) {
613
624
  env.SKRR_CLI_UPDATE_SESSION_UNAVAILABLE === '1') {
614
625
  return {
615
626
  ...status,
616
- message: `This CLI is owned by ${install.kind}${install.kind === 'npm-global' ? ' in a shared or external prefix' : ''}. ${cliUpdateCommand(install.kind, install.npmPrefix)}.`,
627
+ message: `This CLI is owned by ${install.kind}${install.kind === 'npm-global' ? ' in a shared or external prefix' : ''}. ${cliUpdateCommand(install.kind, install.npmPrefix, status.offeredVersion)}.`,
617
628
  };
618
629
  }
619
630
  const recoverableAttempt = status.lastAttempt && ['queued', 'running'].includes(status.lastAttempt.status);
@@ -33,7 +33,7 @@ export interface DutyExecutionContract {
33
33
  headSha: string;
34
34
  baseCommit: string;
35
35
  runtime: {
36
- kind: 'local_daemon' | 'hosted_machine';
36
+ kind: 'local_daemon' | 'hosted_machine' | 'agent_worker';
37
37
  id: string;
38
38
  };
39
39
  };