@skrr-ai/cli 0.1.151 → 0.1.152

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 (49) hide show
  1. package/dist/commands/agents/chat.d.ts +3 -0
  2. package/dist/commands/agents/chat.js +27 -0
  3. package/dist/commands/agents/plan-day.d.ts +3 -0
  4. package/dist/commands/agents/plan-day.js +31 -8
  5. package/dist/commands/agents/show.d.ts +3 -0
  6. package/dist/commands/agents/show.js +59 -3
  7. package/dist/commands/agents/triggers/list.js +2 -1
  8. package/dist/commands/balance/usage/breakdown.d.ts +1 -1
  9. package/dist/commands/balance/usage/breakdown.js +22 -6
  10. package/dist/commands/balance/usage/events.d.ts +3 -2
  11. package/dist/commands/balance/usage/events.js +34 -7
  12. package/dist/commands/duties/observation/summary.js +25 -3
  13. package/dist/commands/goals/plan-now.js +1 -0
  14. package/dist/commands/goals/planner-compare.js +11 -0
  15. package/dist/commands/harnesses/list.d.ts +2 -1
  16. package/dist/commands/harnesses/list.js +7 -5
  17. package/dist/commands/harnesses/models.js +1 -1
  18. package/dist/commands/harnesses/quota.d.ts +9 -11
  19. package/dist/commands/harnesses/quota.js +83 -18
  20. package/dist/commands/harnesses/show.js +1 -1
  21. package/dist/commands/harnesses/usage.d.ts +19 -0
  22. package/dist/commands/harnesses/usage.js +27 -7
  23. package/dist/commands/memory/topics/create.js +4 -1
  24. package/dist/commands/tokens/create.d.ts +3 -4
  25. package/dist/commands/tokens/create.js +20 -7
  26. package/dist/commands/triggers/preflight.js +9 -2
  27. package/dist/lib/agent-model-check.js +3 -1
  28. package/dist/lib/agentic-stream.js +6 -7
  29. package/dist/lib/balance.d.ts +5 -2
  30. package/dist/lib/balance.js +26 -0
  31. package/dist/lib/config.d.ts +1 -1
  32. package/dist/lib/config.js +1 -0
  33. package/dist/lib/harness-labels.d.ts +1 -0
  34. package/dist/lib/harness-labels.js +4 -0
  35. package/dist/lib/harnesses.d.ts +35 -0
  36. package/dist/lib/harnesses.js +8 -0
  37. package/dist/lib/machines.d.ts +2 -1
  38. package/dist/lib/machines.js +2 -2
  39. package/dist/lib/publicEndpoints.generated.d.ts +4 -0
  40. package/dist/lib/publicEndpoints.generated.js +4 -0
  41. package/dist/lib/schedule.d.ts +1 -0
  42. package/dist/lib/schedule.js +4 -4
  43. package/dist/lib/triggers.d.ts +2 -2
  44. package/dist/lib/triggers.js +14 -6
  45. package/dist/lib/update-check.d.ts +1 -1
  46. package/dist/lib/update-check.js +12 -8
  47. package/dist/node_modules/@skrr-ai/data-provider/index.js +7367 -7365
  48. package/oclif.manifest.json +39 -16
  49. package/package.json +1 -1
@@ -208,12 +208,15 @@ export declare function noOutputFailureMessage(input: {
208
208
  * the generic sentence.
209
209
  */
210
210
  export declare function agentRunFailureMessage(result: Pick<AgenticStreamResult, 'lastEvent'>): string;
211
+ /** The acceptance response is a plan, not proof of the eventual executor. */
212
+ export declare function admittedRouting(runtime: unknown): Record<string, unknown> | undefined;
211
213
  export declare function noStreamJsonPayload(input: {
212
214
  result: AgenticStreamResult;
213
215
  conversationId?: string;
214
216
  agentId: string;
215
217
  baseURL: string;
216
218
  threadRootMessageId?: string;
219
+ admittedRuntime?: unknown;
217
220
  }): Record<string, unknown>;
218
221
  /**
219
222
  * OSK-4854 — the human header printed `Streaming agent <id> (<uuid>)` with the
@@ -14,6 +14,7 @@ exports.interruptAction = interruptAction;
14
14
  exports.inspectTurnCommand = inspectTurnCommand;
15
15
  exports.noOutputFailureMessage = noOutputFailureMessage;
16
16
  exports.agentRunFailureMessage = agentRunFailureMessage;
17
+ exports.admittedRouting = admittedRouting;
17
18
  exports.noStreamJsonPayload = noStreamJsonPayload;
18
19
  exports.chatStreamHeaderLines = chatStreamHeaderLines;
19
20
  exports.daemonPinFields = daemonPinFields;
@@ -325,8 +326,25 @@ function noOutputFailureMessage(input) {
325
326
  function agentRunFailureMessage(result) {
326
327
  return (0, agentic_stream_1.terminalFailureMessage)(result.lastEvent) ?? 'Agent run failed';
327
328
  }
329
+ /** The acceptance response is a plan, not proof of the eventual executor. */
330
+ function admittedRouting(runtime) {
331
+ if (!runtime || typeof runtime !== 'object' || Array.isArray(runtime))
332
+ return undefined;
333
+ const plan = runtime.executionPlan;
334
+ if (!plan || typeof plan !== 'object' || Array.isArray(plan))
335
+ return undefined;
336
+ const { selectedKind, selectedExecutionSelector, fallbackUsed } = plan;
337
+ const routing = {
338
+ ...(typeof selectedKind === 'string' && selectedKind ? { selectedKind } : {}),
339
+ ...(typeof selectedExecutionSelector === 'string' && selectedExecutionSelector
340
+ ? { selectedExecutionSelector } : {}),
341
+ ...(typeof fallbackUsed === 'boolean' ? { fallbackUsed } : {}),
342
+ };
343
+ return Object.keys(routing).length ? routing : undefined;
344
+ }
328
345
  function noStreamJsonPayload(input) {
329
346
  const { result, conversationId, agentId, baseURL, threadRootMessageId } = input;
347
+ const routing = admittedRouting(input.admittedRuntime);
330
348
  return {
331
349
  mode: 'no-stream',
332
350
  executed: true,
@@ -345,6 +363,13 @@ function noStreamJsonPayload(input) {
345
363
  }
346
364
  : {}),
347
365
  response: result.text,
366
+ ...(routing ? { admittedRouting: routing } : {}),
367
+ // A terminal worker result can name its producer after dispatch. This is
368
+ // distinct from the initial routing plan and from billing settlement.
369
+ ...(result.lastEvent?.executionAttribution &&
370
+ typeof result.lastEvent.executionAttribution === 'object'
371
+ ? { executionAttribution: result.lastEvent.executionAttribution }
372
+ : {}),
348
373
  // The model a local harness reported running (OSK-12111). Absent on a
349
374
  // cloud turn and on a harness that reports none.
350
375
  ...(typeof result.lastEvent?.harnessModel === 'string' && result.lastEvent.harnessModel
@@ -854,6 +879,7 @@ class AgentsChat extends base_command_1.BaseCommand {
854
879
  conversationId: started.conversationId,
855
880
  ...(flags['thread-root'] ? { threadRootMessageId: flags['thread-root'] } : {}),
856
881
  responseMessageId: started.responseMessageId,
882
+ ...(admittedRouting(started.runtime) ? { admittedRouting: admittedRouting(started.runtime) } : {}),
857
883
  // OSK-13599 — where the turn runs and who chose it, when the server
858
884
  // says (`request` | `agent_home`); absent against an older server.
859
885
  ...(workspaceDefault === 'supported'
@@ -1100,6 +1126,7 @@ class AgentsChat extends base_command_1.BaseCommand {
1100
1126
  // A real executed turn — the metadata says so, unlike `--quick`.
1101
1127
  this.log(JSON.stringify(noStreamJsonPayload({
1102
1128
  result,
1129
+ admittedRuntime: started.runtime,
1103
1130
  conversationId: started.conversationId,
1104
1131
  agentId: args.agentId,
1105
1132
  baseURL: this.cliConfig.baseURL,
@@ -1,4 +1,7 @@
1
1
  import { BaseCommand } from '../../base-command';
2
+ import { type SmartSchedulePlanRequest } from '../../lib/schedule';
3
+ /** Keep historical failures distinct from a newly requested plan. */
4
+ export declare function previousPlanNotice(request: SmartSchedulePlanRequest, regenerating: boolean): string;
2
5
  /**
3
6
  * `skrr agents plan-day <agent-id>` — Smart Schedule ("Plan my day").
4
7
  *
@@ -1,9 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.previousPlanNotice = previousPlanNotice;
3
4
  const core_1 = require("@oclif/core");
4
5
  const base_command_1 = require("../../base-command");
5
6
  const format_1 = require("../../lib/format");
6
7
  const schedule_1 = require("../../lib/schedule");
8
+ /** Keep historical failures distinct from a newly requested plan. */
9
+ function previousPlanNotice(request, regenerating) {
10
+ if (!regenerating)
11
+ return (0, schedule_1.describePlanRequest)(request) ?? '';
12
+ if (request.state === 'unknown') {
13
+ return 'An earlier planning attempt did not report a result and may still finish. A new request could produce a second draft.';
14
+ }
15
+ return 'A previous planning attempt failed. The new request may have a different result.';
16
+ }
7
17
  /**
8
18
  * `skrr agents plan-day <agent-id>` — Smart Schedule ("Plan my day").
9
19
  *
@@ -26,7 +36,7 @@ const schedule_1 = require("../../lib/schedule");
26
36
  * `todos list` use, so one agent-day is one zone across the commands.
27
37
  */
28
38
  class AgentsPlanDay extends base_command_1.BaseCommand {
29
- static description = "Smart Schedule an agent's day: propose a plan, then approve or dismiss it";
39
+ static description = "Smart Schedule an agent's day: propose a plan, then approve or dismiss it. Tasks are checked only in a Space led by the agent; unscoped tasks are not checked. After a failed or unknown request, use --regenerate to explicitly request another plan.";
30
40
  static examples = [
31
41
  '<%= config.bin %> agents plan-day <agent-id>',
32
42
  '<%= config.bin %> agents plan-day <agent-id> --approve',
@@ -230,7 +240,7 @@ class AgentsPlanDay extends base_command_1.BaseCommand {
230
240
  message: (0, schedule_1.describePlanRequest)(request) ?? 'The planning request failed.',
231
241
  code: 'SMART_SCHEDULE_PLAN_FAILED',
232
242
  exit: 1,
233
- retryable: true,
243
+ retryable: !['INFERENCE_CREDENTIAL_UNAVAILABLE', 'INFERENCE_TARGET_UNAVAILABLE'].includes(request.failure?.code ?? ''),
234
244
  details: { agentId, planRequest: request },
235
245
  });
236
246
  }
@@ -342,9 +352,13 @@ class AgentsPlanDay extends base_command_1.BaseCommand {
342
352
  proposal = waited.proposal;
343
353
  }
344
354
  else if (waited.outcome === 'unknown') {
345
- this.warn('That request stopped reporting and may have been interrupted, so it no longer blocks planning.');
346
- before = { ...before, planRequest: null };
347
- proposal = before.proposal;
355
+ this.failWithCliError({
356
+ message: `The earlier request stopped reporting and may still finish. Check \`${this.config.bin} agents schedule-trace ${agentId}\` before explicitly requesting a new plan with \`--regenerate "..."\`.`,
357
+ code: 'SMART_SCHEDULE_PREVIOUS_OUTCOME_UNKNOWN',
358
+ exit: 1,
359
+ retryable: false,
360
+ details: { agentId, planRequest: before.planRequest },
361
+ });
348
362
  }
349
363
  else {
350
364
  this.failWithCliError({
@@ -361,12 +375,21 @@ class AgentsPlanDay extends base_command_1.BaseCommand {
361
375
  // Recover a pending draft unless the caller explicitly wants a fresh one.
362
376
  proposal = before?.proposal ?? null;
363
377
  }
364
- // A planning attempt that FAILED is history the person should see, but not a
365
- // reason to refuse: they asked to plan, and the next attempt may work.
378
+ // A bare read after failure must not silently start another billable run.
379
+ // Explicit regeneration remains available after the user checks the outcome.
366
380
  let priorAttempt = null;
367
381
  if (before?.planRequest?.state === 'failed' || before?.planRequest?.state === 'unknown') {
368
382
  priorAttempt = before.planRequest;
369
- this.warn((0, schedule_1.describePlanRequest)(priorAttempt) ?? '');
383
+ if (!proposal && flags.regenerate === undefined) {
384
+ this.failWithCliError({
385
+ message: `${(0, schedule_1.describePlanRequest)(priorAttempt) ?? 'The previous planning request did not complete.'} To request another plan, explicitly run \`${this.config.bin} agents plan-day ${agentId} --regenerate "..."\`.`,
386
+ code: 'SMART_SCHEDULE_PREVIOUS_REQUEST_NOT_COMPLETED',
387
+ exit: 1,
388
+ retryable: false,
389
+ details: { agentId, planRequest: priorAttempt },
390
+ });
391
+ }
392
+ this.warn(previousPlanNotice(priorAttempt, flags.regenerate !== undefined));
370
393
  }
371
394
  const showingPending = proposal !== null;
372
395
  if (!proposal) {
@@ -22,9 +22,12 @@ export declare function agentToneLine(agent: {
22
22
  * resolution, and says that is all it knows.
23
23
  */
24
24
  export declare function agentPermissionLines(agent: Record<string, unknown>, harness: string): string[];
25
+ export declare function agentHarnessStatus(status: unknown, presence: unknown): string | null;
25
26
  /** Text rendering is deliberately based on the server projection, with a
26
27
  * storage-shape fallback while all stored policies are migrated. */
27
28
  export declare function agentExecutionOrderLines(agent: Record<string, unknown>): string[];
29
+ /** Saved policy, not a prediction of availability, authorization or cost. */
30
+ export declare function agentFallbackPolicyLines(agent: Record<string, unknown>): string[];
28
31
  export default class AgentsShow extends BaseCommand {
29
32
  static description: string;
30
33
  static examples: string[];
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.agentToneLine = agentToneLine;
4
4
  exports.agentPermissionLines = agentPermissionLines;
5
+ exports.agentHarnessStatus = agentHarnessStatus;
5
6
  exports.agentExecutionOrderLines = agentExecutionOrderLines;
7
+ exports.agentFallbackPolicyLines = agentFallbackPolicyLines;
6
8
  const core_1 = require("@oclif/core");
7
9
  const data_provider_1 = require("@skrr-ai/data-provider");
8
10
  const base_command_1 = require("../../base-command");
@@ -83,6 +85,13 @@ function agentPermissionLines(agent, harness) {
83
85
  lines.push(`${pad}A turn's own mode (\`agents chat --permission-mode\`) overrides this for that turn.`);
84
86
  return lines;
85
87
  }
88
+ function agentHarnessStatus(status, presence) {
89
+ if (presence === 'unconfirmed')
90
+ return 'connection to this server unconfirmed';
91
+ if (presence === 'unknown')
92
+ return 'connection status unknown';
93
+ return typeof status === 'string' && status ? status : null;
94
+ }
86
95
  /** Text rendering is deliberately based on the server projection, with a
87
96
  * storage-shape fallback while all stored policies are migrated. */
88
97
  function agentExecutionOrderLines(agent) {
@@ -120,8 +129,15 @@ function agentExecutionOrderLines(agent) {
120
129
  ...entries.map((entry, index) => {
121
130
  const position = Number.isInteger(entry.position) ? entry.position : index + 1;
122
131
  const target = typeof entry.name === 'string' && entry.name ? entry.name : entry.selector;
132
+ // The name is not a unique registration. Keep the configured selector
133
+ // visible even when the server resolves a friendly display name.
134
+ const selector = typeof entry.selector === 'string' && entry.selector &&
135
+ entry.selector !== target && !isSynthetic(entry)
136
+ ? ` [selector: ${entry.selector}]`
137
+ : '';
123
138
  const label = typeof entry.label === 'string' && entry.label ? ` — ${entry.label}` : '';
124
- const status = typeof entry.status === 'string' ? ` (${entry.status})` : '';
139
+ const statusLabel = agentHarnessStatus(entry.status, entry.presenceStatus);
140
+ const status = statusLabel ? ` (${statusLabel})` : '';
125
141
  // An UNRESOLVABLE target used to render as an absence — no name, no
126
142
  // `(online)`/`(offline)` marker — on a line that otherwise looks like a
127
143
  // normal one. `attach-harness` accepts an id that resolves to nothing
@@ -137,7 +153,7 @@ function agentExecutionOrderLines(agent) {
137
153
  !isSynthetic(entry)
138
154
  ? ' [!] no such harness — nothing is registered under this id'
139
155
  : '';
140
- return ` ${position}. ${target || '(invalid target)'}${status}${label}${unresolvable}`;
156
+ return ` ${position}. ${target || '(invalid target)'}${status}${selector}${label}${unresolvable}`;
141
157
  }),
142
158
  ];
143
159
  }
@@ -150,6 +166,42 @@ function isSynthetic(entry) {
150
166
  const selector = typeof entry.selector === 'string' ? entry.selector : '';
151
167
  return selector.startsWith('__oversky_') || selector.startsWith('sbs_');
152
168
  }
169
+ /** Saved policy, not a prediction of availability, authorization or cost. */
170
+ function agentFallbackPolicyLines(agent) {
171
+ const policy = agent.executionPolicy;
172
+ if (!policy || policy.mode !== 'ordered' || !Array.isArray(policy.targets)) {
173
+ return ['Fallback policy: not available in this response'];
174
+ }
175
+ const targets = policy.targets.filter((value) => Boolean(value && typeof value === 'object') && value.enabled !== false);
176
+ const defaults = agent.executionPolicyDefaults;
177
+ const savedConsent = typeof policy.handoverConsent === 'string' &&
178
+ ['ask', 'configured', 'permissive'].includes(policy.handoverConsent) ? policy.handoverConsent : null;
179
+ const defaultConsent = typeof defaults?.handoverConsent === 'string' ? defaults.handoverConsent : null;
180
+ const effectiveConsent = savedConsent || defaultConsent;
181
+ const consent = savedConsent || (defaultConsent ? `${defaultConsent} (server default)` : 'not explicitly saved (server default unavailable)');
182
+ const lines = [
183
+ 'Fallback policy (saved configuration; actual routing can differ):',
184
+ ` Handover consent: ${consent}`,
185
+ ];
186
+ if (effectiveConsent === 'configured')
187
+ lines.push(' Configured managed fallbacks may run; Hosted Machine also needs its acknowledgement.');
188
+ else if (effectiveConsent === 'ask')
189
+ lines.push(' Managed fallback requires approval before it can run.');
190
+ else if (effectiveConsent === 'permissive')
191
+ lines.push(' Managed fallbacks may run without a per-target acknowledgement.');
192
+ targets.forEach((target, index) => {
193
+ const selector = target.harnessId || target.machineSessionId || target.kind || '(invalid target)';
194
+ const advance = Array.isArray(target.advanceOn)
195
+ ? target.advanceOn.filter((value) => typeof value === 'string' && Boolean(value)).join(', ') || 'none'
196
+ : Array.isArray(defaults?.advanceOn) && defaults.advanceOn.every((value) => typeof value === 'string')
197
+ ? `${defaults.advanceOn.join(', ') || 'none'} (server default)`
198
+ : 'not explicitly saved (server default unavailable)';
199
+ lines.push(` ${index + 1}. ${String(selector)} — advance on: ${advance}`);
200
+ if (target.kind === 'hosted-machine')
201
+ lines.push(` Hosted Machine managed usage acknowledgement: ${target.managedUsageConsent === true ? 'yes' : target.managedUsageConsent === false ? 'no' : 'not explicitly saved'}`);
202
+ });
203
+ return lines;
204
+ }
153
205
  class AgentsShow extends base_command_1.BaseCommand {
154
206
  static description = 'Show details for a single agent';
155
207
  static examples = [
@@ -213,8 +265,12 @@ class AgentsShow extends base_command_1.BaseCommand {
213
265
  : 'unlimited'}`);
214
266
  for (const line of agentExecutionOrderLines(a))
215
267
  this.log(line);
268
+ if (flags.expanded)
269
+ for (const line of agentFallbackPolicyLines(a))
270
+ this.log(line);
216
271
  if (a.harnessName || a.harnessProvider || a.harnessStatus) {
217
- this.log(`Harness: ${a.harnessName ?? (typeof a.harnessProvider === 'string' ? (0, harness_provider_input_1.canonicalHarnessInput)(a.harnessProvider) : a.harnessProvider) ?? '-'}${a.harnessStatus ? ` (${a.harnessStatus})` : ''}`);
272
+ const harnessStatus = agentHarnessStatus(a.harnessStatus, a.harnessPresenceStatus);
273
+ this.log(`Harness: ${a.harnessName ?? (typeof a.harnessProvider === 'string' ? (0, harness_provider_input_1.canonicalHarnessInput)(a.harnessProvider) : a.harnessProvider) ?? '-'}${harnessStatus ? ` (${harnessStatus})` : ''}`);
218
274
  // On a harness, the HARNESS decides what runs and which permission modes
219
275
  // exist — `Provider` is only the cloud model contract, so an agent read
220
276
  // as "anthropic" while running Codex (OSK-12071). And the mode itself was
@@ -19,7 +19,7 @@ const triggers_1 = require("../../../lib/triggers");
19
19
  * `skrr triggers <verb> <trigger-id>` for those (the ids printed below).
20
20
  */
21
21
  class AgentsTriggersList extends base_command_1.BaseCommand {
22
- static description = 'List the universal triggers scoped to an agent';
22
+ static description = 'List directly Agent-scoped triggers; search other scopes that reference the Agent with `skrr triggers list --ref agentId=<agent-id>`';
23
23
  static examples = [
24
24
  '<%= config.bin %> agents triggers list <agent-id>',
25
25
  '<%= config.bin %> agents triggers list <agent-id> --kind schedule --enabled',
@@ -57,6 +57,7 @@ class AgentsTriggersList extends base_command_1.BaseCommand {
57
57
  this.printJsonResult((0, list_output_1.listResult)(response, 'triggers'));
58
58
  return;
59
59
  }
60
+ this.log('Showing only directly Agent-scoped triggers. To search other scopes that reference this Agent, use `skrr triggers list --ref agentId=<agent-id>`.');
60
61
  (0, triggers_1.renderTriggerList)(response.triggers ?? [], (line) => this.log(line));
61
62
  }
62
63
  }
@@ -11,4 +11,4 @@ export default class BalanceUsageBreakdown extends BaseCommand {
11
11
  };
12
12
  run(): Promise<void>;
13
13
  }
14
- export declare function renderSkyCodeUsageBreakdown(breakdown: TSkyCodeUsageBreakdown, log: (line: string) => void): void;
14
+ export declare function renderSkyCodeUsageBreakdown(breakdown: TSkyCodeUsageBreakdown, log: (line: string) => void, agentNames?: ReadonlyMap<string, string>): void;
@@ -11,13 +11,13 @@ class BalanceUsageBreakdown extends base_command_1.BaseCommand {
11
11
  '<%= config.bin %> balance usage breakdown',
12
12
  '<%= config.bin %> balance usage breakdown --json',
13
13
  '<%= config.bin %> balance usage breakdown --workspace <workspace-id>',
14
- '<%= config.bin %> balance usage breakdown --from 2026-09-01 --to 2026-09-15',
14
+ '<%= config.bin %> balance usage breakdown --from 2026-09-01 --to 2026-09-01T23:59:59.999Z',
15
15
  '<%= config.bin %> balance usage breakdown --product-family sky-code-api',
16
16
  ];
17
17
  static flags = {
18
18
  json: core_1.Flags.boolean({ description: 'Output as JSON' }),
19
- from: core_1.Flags.string({ description: 'Inclusive ISO start time; defaults to 30 days ago' }),
20
- to: core_1.Flags.string({ description: 'Inclusive ISO end time; defaults to now' }),
19
+ from: core_1.Flags.string({ description: 'Inclusive ISO start time; YYYY-MM-DD means midnight UTC; defaults to 30 days before end' }),
20
+ to: core_1.Flags.string({ description: 'Inclusive ISO end time; YYYY-MM-DD means midnight UTC, not end of day; defaults to now' }),
21
21
  'product-family': core_1.Flags.string({
22
22
  description: 'Restrict to one product family (e.g. sky-code-api for PAYG spend)',
23
23
  }),
@@ -41,11 +41,21 @@ class BalanceUsageBreakdown extends base_command_1.BaseCommand {
41
41
  this.log(JSON.stringify(breakdown, null, 2));
42
42
  return;
43
43
  }
44
- renderSkyCodeUsageBreakdown(breakdown, (line) => this.log(line));
44
+ let agentNames = new Map();
45
+ let lookupFailed = false;
46
+ try {
47
+ agentNames = await (0, balance_1.getUsageAgentNames)(breakdown.byAgent.flatMap((row) => row.agentId ? [row.agentId] : []), workspaceId);
48
+ }
49
+ catch {
50
+ lookupFailed = true;
51
+ }
52
+ renderSkyCodeUsageBreakdown(breakdown, (line) => this.log(line), agentNames);
53
+ if (lookupFailed)
54
+ this.log(' Agent names unavailable; showing recorded IDs.');
45
55
  }
46
56
  }
47
57
  exports.default = BalanceUsageBreakdown;
48
- function renderSkyCodeUsageBreakdown(breakdown, log) {
58
+ function renderSkyCodeUsageBreakdown(breakdown, log, agentNames = new Map()) {
49
59
  log(`${auth_core_1.FIRST_PARTY_HARNESS.displayName} usage breakdown · ${breakdown.ownerType} ${breakdown.ownerId}`);
50
60
  log(` Window ${breakdown.from} to ${breakdown.to}`);
51
61
  log(` Total ${(0, balance_1.formatCreditsWithUsd)(breakdown.total.usageMicros)} across ${breakdown.total.events} settled authorization${breakdown.total.events === 1 ? '' : 's'}`);
@@ -62,7 +72,13 @@ function renderSkyCodeUsageBreakdown(breakdown, log) {
62
72
  ...row,
63
73
  label: [row.provider, row.model].filter(Boolean).join('/') || 'unknown',
64
74
  })));
75
+ section('By configured transport (authorizations may overlap; not a provider invoice)', (breakdown.byConfiguredTransport ?? []).map((row) => ({
76
+ ...row, label: row.transportProvider ?? 'unknown',
77
+ })));
65
78
  section('By surface', breakdown.bySurface.map((row) => ({ ...row, label: row.surface ?? 'unknown' })));
66
- section('By agent', breakdown.byAgent.map((row) => ({ ...row, label: row.agentId ?? 'unattributed' })));
79
+ section('By recorded source (application attribution, not a provider invoice)', (breakdown.bySource ?? []).map((row) => ({ ...row, label: row.sourceType ?? 'unknown' })));
80
+ section('By agent', breakdown.byAgent.map((row) => ({ ...row, label: row.agentId
81
+ ? agentNames.has(row.agentId) ? `${agentNames.get(row.agentId)} (${row.agentId})` : row.agentId
82
+ : 'unattributed' })));
67
83
  section('By member', breakdown.byMember.map((row) => ({ ...row, label: row.memberUserId ?? 'unattributed' })));
68
84
  }
@@ -1,4 +1,4 @@
1
- import type { TSkyCodeUsageEvents } from '@skrr-ai/data-provider';
1
+ import type { TSkyCodeUsageEvents, TSkyCodeUsageSettlements } from '@skrr-ai/data-provider';
2
2
  import { BaseCommand } from '../../../base-command';
3
3
  export default class BalanceUsageEvents extends BaseCommand {
4
4
  static description: string;
@@ -9,7 +9,8 @@ export default class BalanceUsageEvents extends BaseCommand {
9
9
  to: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
10
  cursor: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
11
  limit: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
12
+ 'legacy-charges': import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
13
  };
13
14
  run(): Promise<void>;
14
15
  }
15
- export declare function renderSkyCodeUsageEvents(events: TSkyCodeUsageEvents, log: (line: string) => void): void;
16
+ export declare function renderSkyCodeUsageEvents(events: TSkyCodeUsageEvents | TSkyCodeUsageSettlements, log: (line: string) => void): void;
@@ -6,19 +6,20 @@ const auth_core_1 = require("@skrr-ai/auth-core");
6
6
  const base_command_1 = require("../../../base-command");
7
7
  const balance_1 = require("../../../lib/balance");
8
8
  class BalanceUsageEvents extends base_command_1.BaseCommand {
9
- static description = `List the ${auth_core_1.FIRST_PARTY_HARNESS.displayName} charges and run/session attribution behind aggregate allowance usage`;
9
+ static description = `List settled ${auth_core_1.FIRST_PARTY_HARNESS.displayName} usage and its run/session attribution`;
10
10
  static examples = [
11
11
  '<%= config.bin %> balance usage events',
12
12
  '<%= config.bin %> balance usage events --limit 20 --json',
13
13
  '<%= config.bin %> balance usage events --workspace <workspace-id>',
14
- '<%= config.bin %> balance usage events --from 2026-09-01 --to 2026-09-15',
14
+ '<%= config.bin %> balance usage events --from 2026-09-01 --to 2026-09-01T23:59:59.999Z',
15
15
  ];
16
16
  static flags = {
17
17
  json: core_1.Flags.boolean({ description: 'Output as JSON' }),
18
- from: core_1.Flags.string({ description: 'Inclusive ISO start time; defaults to 30 days ago' }),
19
- to: core_1.Flags.string({ description: 'Inclusive ISO end time; defaults to now' }),
18
+ from: core_1.Flags.string({ description: 'Inclusive ISO start time; YYYY-MM-DD means midnight UTC; defaults to 30 days before end' }),
19
+ to: core_1.Flags.string({ description: 'Inclusive ISO end time; YYYY-MM-DD means midnight UTC, not end of day; defaults to now' }),
20
20
  cursor: core_1.Flags.string({ description: 'Opaque cursor returned by the previous page' }),
21
21
  limit: core_1.Flags.integer({ description: 'Rows to return (1-200)', min: 1, max: 200, default: 50 }),
22
+ 'legacy-charges': core_1.Flags.boolean({ description: 'Show legacy service-charge records; status is not shown and totals overlap settlements' }),
22
23
  };
23
24
  async run() {
24
25
  this.requireAuth();
@@ -31,13 +32,16 @@ class BalanceUsageEvents extends base_command_1.BaseCommand {
31
32
  to: flags.to,
32
33
  cursor: flags.cursor,
33
34
  limit: flags.limit,
35
+ ...(!flags['legacy-charges'] ? { view: 'settlements' } : {}),
34
36
  });
35
37
  }
36
38
  catch (error) {
37
39
  this.handleApiError(error);
38
40
  }
39
41
  if (flags.json) {
40
- this.log(JSON.stringify(events, null, 2));
42
+ this.log(JSON.stringify(events?.version === 1 && !flags['legacy-charges']
43
+ ? { ...events, scopeWarning: 'This server only returned legacy service-charge records; their status and included allowance usage are not shown.' }
44
+ : events, null, 2));
41
45
  return;
42
46
  }
43
47
  renderSkyCodeUsageEvents(events, (line) => this.log(line));
@@ -47,6 +51,12 @@ exports.default = BalanceUsageEvents;
47
51
  function renderSkyCodeUsageEvents(events, log) {
48
52
  log(`${auth_core_1.FIRST_PARTY_HARNESS.displayName} usage events · ${events.ownerType} ${events.ownerId}`);
49
53
  log(` Window ${events.from} to ${events.to}`);
54
+ if (events.version === 1) {
55
+ log(' Legacy service-charge records only; status and final payment are not shown. Included allowance usage is not shown. Do not add this view to settlement totals.');
56
+ }
57
+ else {
58
+ log(' Settled authorizations; legacy service-charge records are a separate overlapping view.');
59
+ }
50
60
  if (events.items.length === 0) {
51
61
  log(' No usage events in this window.');
52
62
  return;
@@ -61,8 +71,25 @@ function renderSkyCodeUsageEvents(events, log) {
61
71
  ]
62
72
  .filter(Boolean)
63
73
  .join(' · ');
64
- log(` ${item.createdAt} ${(0, balance_1.formatMicros)(item.amountMicros)} ${providerModel}`);
65
- log(` ${incurredBy || 'No run/session attribution'} · charge ${item.chargeId}`);
74
+ if (events.version === 2 && 'authorizationId' in item) {
75
+ const usage = item.usageMicros == null ? 'usage unknown' : `${item.usageMicros} customer_usage_micros`;
76
+ const balance = item.balanceMicros == null ? 'balance unknown' : `${(0, balance_1.formatMicros)(item.balanceMicros)} ${item.postpaid ? 'postpaid accrued' : 'balance'}`;
77
+ log(` ${item.settledAt} ${usage} · ${balance} ${providerModel}`);
78
+ log(` ${incurredBy || 'No run/session attribution'} · ${item.sourceType || 'source unknown'} · authorization ${item.authorizationId}`);
79
+ const extra = [item.sourceId ? `source ${item.sourceId}` : null,
80
+ item.dutyId ? `duty ${item.dutyId}` : null,
81
+ item.memberUserId ? `member ${item.memberUserId}` : null,
82
+ item.parentAuthorizationId ? `parent authorization ${item.parentAuthorizationId}` : null].filter(Boolean);
83
+ if (extra.length)
84
+ log(` ${extra.join(' · ')}`);
85
+ if (item.entitlementUsageMicros != null || item.degradedUsageMicros != null) {
86
+ log(` Included allowance ${item.entitlementUsageMicros ?? 'unknown'} · degraded allowance ${item.degradedUsageMicros ?? 'unknown'} customer_usage_micros`);
87
+ }
88
+ }
89
+ else if ('chargeId' in item) {
90
+ log(` ${item.createdAt} ${(0, balance_1.formatMicros)(item.amountMicros)} ${providerModel}`);
91
+ log(` ${incurredBy || 'No run/session attribution'} · charge ${item.chargeId}`);
92
+ }
66
93
  }
67
94
  if (events.nextCursor) {
68
95
  log(` Next cursor: ${events.nextCursor}`);
@@ -3,6 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
4
  const base_command_1 = require("../../../base-command");
5
5
  const duties_1 = require("../../../lib/duties");
6
+ function record(value) {
7
+ return value && typeof value === 'object' && !Array.isArray(value)
8
+ ? value : {};
9
+ }
10
+ function completeness(value) {
11
+ return value === true ? 'complete' : value === false ? 'incomplete' : 'unknown';
12
+ }
6
13
  class DutiesObservationSummary extends base_command_1.BaseCommand {
7
14
  static description = 'Read the bounded portfolio observation projection without performing new source checks';
8
15
  static flags = {
@@ -18,10 +25,25 @@ class DutiesObservationSummary extends base_command_1.BaseCommand {
18
25
  this.log(JSON.stringify(summary, null, 2));
19
26
  return;
20
27
  }
28
+ const queryCoverage = record(summary.coverage);
29
+ const observation = record(summary.observationCoverage);
30
+ const counts = record(queryCoverage.counts);
31
+ const nextWake = record(summary.nextWake);
32
+ this.log(`Scope: bounded view of eligible active Duties in the current workspace${flags.agent ? ' for the selected Agent' : ''}; paused, completed and some system-managed Duties are excluded.`);
21
33
  this.log(`Portfolio observation: ${summary.state ?? 'unknown'}`);
22
- this.log(`Checked at: ${summary.checkedAt ?? 'unavailable'}`);
23
- this.log(`Coverage: ${JSON.stringify(summary.coverage ?? {})}`);
24
- this.log(`Next wake: ${JSON.stringify(summary.nextWake ?? {})}`);
34
+ this.log(`Latest successful observation: ${summary.checkedAt ?? 'unavailable'}`);
35
+ this.log(`Active Duties read: ${typeof counts.responsibilities === 'number' ? counts.responsibilities : 'unknown'}`);
36
+ this.log(`Query coverage: ${completeness(queryCoverage.complete)}${queryCoverage.reason ? ` (${queryCoverage.reason})` : ''}`);
37
+ if (Array.isArray(queryCoverage.errors)) {
38
+ for (const error of queryCoverage.errors)
39
+ this.log(`Query error: ${JSON.stringify(error)}`);
40
+ }
41
+ this.log(`Observation coverage: ${observation.status ?? 'unknown'} (${completeness(observation.complete)})`);
42
+ this.log(`Next wake: ${nextWake.at ?? nextWake.status ?? 'unknown'}${nextWake.at && nextWake.status ? ` (${nextWake.status})` : ''}`);
43
+ if (nextWake.dutyId)
44
+ this.log(`Wake Duty: ${nextWake.dutyId}`);
45
+ if (nextWake.source)
46
+ this.log(`Wake source: ${nextWake.source}`);
25
47
  }
26
48
  catch (error) {
27
49
  this.handleApiError(error);
@@ -195,6 +195,7 @@ class GoalsPlanNow extends base_command_1.BaseCommand {
195
195
  this.log(` backfilled: ${r.backfilledCount} existing task(s) tagged to the space.`);
196
196
  }
197
197
  this.log(` Watch \`${this.config.bin} goals tasks ${args.id}\` for what it creates.`);
198
+ this.log(` Check \`${this.config.bin} goals planner-compare ${args.id}\` for the latest planner failure.`);
198
199
  return;
199
200
  }
200
201
  if (plannerTickDidNotRun(r)) {
@@ -50,6 +50,17 @@ function comparisonLines(result) {
50
50
  lines.push(`${pad('Planner ticks held')}${String(result.goalPlanner.ticks).padEnd(column)}${result.goalLoop.ticks}`);
51
51
  const plannerTurns = Object.values(result.goalPlanner.notes).reduce((a, b) => a + b, 0);
52
52
  lines.push(`${pad('Turns')}${countsLine(plannerTurns, result.goalPlanner.notes).padEnd(column)}${countsLine(result.goalLoop.turns.total, result.goalLoop.turns.byStatus)}`);
53
+ const failure = result.goalPlanner.latestFailure;
54
+ if (failure) {
55
+ const detail = failure.code === 'INFERENCE_TARGET_UNAVAILABLE'
56
+ ? 'The configured inference target was unavailable. Check the Agent harness and daemon connection, then retry.'
57
+ : failure.code === 'INFERENCE_AGENT_UNAVAILABLE'
58
+ ? 'The configured Agent is unavailable. Check the Goal owner Agent, then retry.'
59
+ : failure.code === 'INFERENCE_OUTCOME_UNKNOWN'
60
+ ? 'The inference outcome is unknown. Check for existing results before retrying.'
61
+ : 'The planner failed; the cause was not recorded. Check the planner logs.';
62
+ lines.push(`Latest planner failure (${failure.at}): ${detail}`);
63
+ }
53
64
  lines.push(`${pad('Tasks created')}${String(result.goalPlanner.created).padEnd(column)}${result.goalLoop.tasksCreated}`);
54
65
  lines.push(`${pad('Tasks refined')}${String(result.goalPlanner.refined).padEnd(column)}not counted`);
55
66
  lines.push(`${pad('Key results judged')}${'never'.padEnd(column)}${result.goalLoop.keyResultJudgments}`);
@@ -13,6 +13,7 @@ export type HarnessRow = {
13
13
  name?: string;
14
14
  model?: string;
15
15
  status?: string;
16
+ presenceStatus?: 'connected' | 'unconfirmed' | 'unknown';
16
17
  harnessLocation?: string;
17
18
  lastSeenAt?: string;
18
19
  metadata?: {
@@ -125,7 +126,7 @@ export type HarnessSelection = {
125
126
  * machine replaced; the filter accepted only online|offline, so the one value
126
127
  * that says "never coming back" could be read and never selected.
127
128
  */
128
- export declare const HARNESS_STATUS_FILTERS: readonly ["online", "offline", "superseded"];
129
+ export declare const HARNESS_STATUS_FILTERS: readonly ["online", "offline", "unconfirmed", "unknown", "superseded"];
129
130
  /**
130
131
  * The status to ask the SERVER for. Only `online` narrows there.
131
132
  *
@@ -130,7 +130,7 @@ const MANAGED_REGISTRATION_SOURCES = new Set([
130
130
  * machine replaced; the filter accepted only online|offline, so the one value
131
131
  * that says "never coming back" could be read and never selected.
132
132
  */
133
- exports.HARNESS_STATUS_FILTERS = ['online', 'offline', 'superseded'];
133
+ exports.HARNESS_STATUS_FILTERS = ['online', 'offline', 'unconfirmed', 'unknown', 'superseded'];
134
134
  /**
135
135
  * The status to ask the SERVER for. Only `online` narrows there.
136
136
  *
@@ -225,7 +225,9 @@ function selectHarnessRows(rows, options) {
225
225
  });
226
226
  }
227
227
  const sorted = [...filtered].sort(compareHarnessRows);
228
- const shown = options.onlineOnly ? sorted.filter((r) => r.status === 'online') : sorted;
228
+ const shown = options.onlineOnly
229
+ ? sorted.filter((r) => r.status === 'online' && (!r.presenceStatus || r.presenceStatus === 'connected'))
230
+ : sorted;
229
231
  const limited = options.limit != null && options.limit > 0 ? shown.slice(0, options.limit) : shown;
230
232
  return {
231
233
  visible: limited,
@@ -268,7 +270,7 @@ function buildHarnessesJson(selection, filters, defaults = {}, readiness) {
268
270
  hiddenByLocal: selection.hiddenByLocal,
269
271
  hiddenByLimit: selection.hiddenByLimit,
270
272
  hiddenSuperseded: selection.hiddenSuperseded,
271
- online: selection.visible.filter((r) => r.status === 'online').length,
273
+ online: selection.visible.filter((r) => r.status === 'online' && (!r.presenceStatus || r.presenceStatus === 'connected')).length,
272
274
  },
273
275
  };
274
276
  }
@@ -347,8 +349,8 @@ function canonicalHarnessRows(rows) {
347
349
  }
348
350
  /** Online first, then most-recently-seen first — the row you want is row 1. */
349
351
  function compareHarnessRows(a, b) {
350
- const aOffline = a.status === 'online' ? 0 : 1;
351
- const bOffline = b.status === 'online' ? 0 : 1;
352
+ const aOffline = a.status === 'online' && (!a.presenceStatus || a.presenceStatus === 'connected') ? 0 : 1;
353
+ const bOffline = b.status === 'online' && (!b.presenceStatus || b.presenceStatus === 'connected') ? 0 : 1;
352
354
  if (aOffline !== bOffline)
353
355
  return aOffline - bOffline;
354
356
  return lastSeenMs(b) - lastSeenMs(a);
@@ -54,7 +54,7 @@ function curatedReasonClause(report) {
54
54
  case 'no_live_catalog_for_harness':
55
55
  return `${provider} has no way to list its own models, so this list is the catalog`;
56
56
  case 'daemon_offline':
57
- return `the machine running ${provider} is offline, so its live model list could not be read`;
57
+ return `this server has no live connection to the ${provider} daemon, so its model list could not be read`;
58
58
  case 'live_catalog_unsupported':
59
59
  return `the daemon on that machine does not offer a live model list — update it to get one`;
60
60
  case 'live_probe_failed':