@skrr-ai/cli 0.1.199 → 0.1.202

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 (62) hide show
  1. package/dist/commands/agents/always-on/recovery-close.d.ts +3 -4
  2. package/dist/commands/agents/always-on/recovery-close.js +5 -5
  3. package/dist/commands/agents/always-on/recovery-review.d.ts +1 -1
  4. package/dist/commands/agents/always-on/recovery-review.js +4 -3
  5. package/dist/commands/agents/create.d.ts +4 -2
  6. package/dist/commands/agents/create.js +29 -4
  7. package/dist/commands/duties/check-now.d.ts +1 -0
  8. package/dist/commands/duties/check-now.js +17 -1
  9. package/dist/commands/duties/create.js +95 -9
  10. package/dist/commands/duties/observations.d.ts +1 -0
  11. package/dist/commands/duties/observations.js +12 -3
  12. package/dist/commands/duties/operating-review.js +34 -2
  13. package/dist/commands/duties/pack/plan.d.ts +1 -0
  14. package/dist/commands/duties/pack/plan.js +30 -0
  15. package/dist/commands/duties/plan.d.ts +1 -0
  16. package/dist/commands/duties/plan.js +24 -0
  17. package/dist/commands/duties/preflight.d.ts +3 -3
  18. package/dist/commands/duties/preflight.js +36 -12
  19. package/dist/commands/duties/receipt.d.ts +1 -0
  20. package/dist/commands/duties/receipt.js +35 -11
  21. package/dist/commands/duties/roster.js +29 -6
  22. package/dist/commands/duties/status.js +19 -11
  23. package/dist/commands/duties/update.js +1 -1
  24. package/dist/commands/goals/create.js +1 -1
  25. package/dist/commands/goals/key-results/create.js +1 -1
  26. package/dist/commands/machines/computer-adoption.js +1 -1
  27. package/dist/commands/machines/dedicated/audit.js +1 -1
  28. package/dist/commands/machines/dedicated/catalog.js +1 -1
  29. package/dist/commands/machines/dedicated/current.js +1 -1
  30. package/dist/commands/machines/dedicated/git-status.js +1 -1
  31. package/dist/commands/machines/dedicated/health-check.js +1 -1
  32. package/dist/commands/machines/dedicated/logs.js +1 -1
  33. package/dist/commands/machines/dedicated/price-book.js +1 -1
  34. package/dist/commands/machines/dedicated/sign-in-status.js +1 -1
  35. package/dist/commands/machines/dedicated/stat.js +1 -1
  36. package/dist/commands/machines/services/ls.js +1 -1
  37. package/dist/commands/machines/shared.js +1 -1
  38. package/dist/commands/machines/shares.js +1 -1
  39. package/dist/commands/tasks/result/show.d.ts +1 -0
  40. package/dist/commands/tasks/result/show.js +19 -1
  41. package/dist/commands/triggers/capabilities.js +11 -2
  42. package/dist/commands/triggers/create.d.ts +1 -1
  43. package/dist/commands/triggers/create.js +15 -6
  44. package/dist/commands/triggers/fire-detail.js +7 -0
  45. package/dist/generated/agent-guides.json +36 -36
  46. package/dist/lib/daemon-setup.js +1 -1
  47. package/dist/lib/duties.d.ts +7 -5
  48. package/dist/lib/duties.js +32 -19
  49. package/dist/lib/duty-loop-status.d.ts +2 -0
  50. package/dist/lib/duty-loop-status.js +26 -1
  51. package/dist/lib/duty-product.js +52 -3
  52. package/dist/lib/task-runtime-headers.d.ts +2 -0
  53. package/dist/lib/task-runtime-headers.js +26 -9
  54. package/dist/lib/tasks.js +11 -3
  55. package/dist/lib/usage-discovery.js +2 -2
  56. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/dutyExecutionContract.d.ts +3 -1
  57. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/dutyExecutionContract.js +6 -2
  58. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/dutyExecutionContract.d.ts +3 -1
  59. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/dutyExecutionContract.js +6 -4
  60. package/dist/node_modules/@skrr-ai/data-provider/index.js +10384 -10375
  61. package/oclif.manifest.json +54 -11
  62. package/package.json +5 -2
@@ -1,6 +1,6 @@
1
1
  import { BaseCommand } from '../../../base-command';
2
2
  /**
3
- * `skrr agents always-on recovery-close <agent-id> <run-id> --hold <hold-ref>` — the Agent owner closes ONE held Duty
3
+ * `skrr agents always-on recovery-close <agent-id> <run-id> --hold <hold-ref>` — closes one held Duty
4
4
  * result, via `POST /api/agents/:id/always-on/runs/:runId/result-recovery/close` (OSK-23548).
5
5
  *
6
6
  * A Duty result whose custody is uncertain is held for review, and the held Run stops its Duty's later Checks until a
@@ -13,9 +13,8 @@ import { BaseCommand } from '../../../base-command';
13
13
  * ref then names the boundary, and the close records which effect classes its receipts had settled.
14
14
  *
15
15
  * `--hold` is the ref `recovery-review <agent-id> <run-id>` prints. It binds the close to the hold you read: if the Run
16
- * was held again since, the server refuses. The server also requires you to be the Agent's owner signed in as a person
17
- * (`skrr login`; a personal access token never reaches the route), that you can see the review, and that the machine
18
- * that ran the turn confirmed it stopped. Nothing about who you are is taken from the command line.
16
+ * was held again since, the server refuses. Use `skrr login` as the Agent owner or as a workspace member with edit
17
+ * access to the Agent for a verified shared Duty result. The close also requires proof that the executor stopped.
19
18
  */
20
19
  export default class AgentsAlwaysOnRecoveryClose extends BaseCommand {
21
20
  static description: string;
@@ -4,7 +4,7 @@ const core_1 = require("@oclif/core");
4
4
  const data_provider_1 = require("@skrr-ai/data-provider");
5
5
  const base_command_1 = require("../../../base-command");
6
6
  /**
7
- * `skrr agents always-on recovery-close <agent-id> <run-id> --hold <hold-ref>` — the Agent owner closes ONE held Duty
7
+ * `skrr agents always-on recovery-close <agent-id> <run-id> --hold <hold-ref>` — closes one held Duty
8
8
  * result, via `POST /api/agents/:id/always-on/runs/:runId/result-recovery/close` (OSK-23548).
9
9
  *
10
10
  * A Duty result whose custody is uncertain is held for review, and the held Run stops its Duty's later Checks until a
@@ -17,12 +17,12 @@ const base_command_1 = require("../../../base-command");
17
17
  * ref then names the boundary, and the close records which effect classes its receipts had settled.
18
18
  *
19
19
  * `--hold` is the ref `recovery-review <agent-id> <run-id>` prints. It binds the close to the hold you read: if the Run
20
- * was held again since, the server refuses. The server also requires you to be the Agent's owner signed in as a person
21
- * (`skrr login`; a personal access token never reaches the route), that you can see the review, and that the machine
22
- * that ran the turn confirmed it stopped. Nothing about who you are is taken from the command line.
20
+ * was held again since, the server refuses. Use `skrr login` as the Agent owner or as a workspace member with edit
21
+ * access to the Agent for a verified shared Duty result. The close also requires proof that the executor stopped.
23
22
  */
24
23
  class AgentsAlwaysOnRecoveryClose extends base_command_1.BaseCommand {
25
- static description = 'Close one held Duty result as the Agent owner: the Run ends cancelled, nothing more of its result is applied, and the Duty re-decides at its next Check. Effects without a receipt stay unknown';
24
+ static description = 'Close one held Duty result. The Run ends cancelled and no further result effects are applied. The Duty re-decides at its next Check. Effects without a receipt stay unknown.\n\n' +
25
+ 'Use skrr login. Workspace members with edit access to the Agent can close verified results for shared Duties. The Agent owner handles personal and unverified results. The executor must be confirmed stopped.';
26
26
  static examples = [
27
27
  '<%= config.bin %> agents always-on recovery-close <agent-id> <run-id> --hold <hold-ref>',
28
28
  '<%= config.bin %> agents always-on recovery-close <agent-id> <run-id> --hold <hold-ref> --json',
@@ -12,7 +12,7 @@ export declare const UNKNOWN_CODE_HINT = "this CLI does not know it; update the
12
12
  /** A code as this CLI prints it: verbatim, and marked when it is not one of `known`. */
13
13
  export declare function recoveryCode(value: unknown, known: readonly string[]): string;
14
14
  /**
15
- * Read-only. The server independently verifies owner and source authorization.
15
+ * Read-only. The server independently verifies review access and source authorization.
16
16
  *
17
17
  * With a run id it reads ONE review (`GET .../runs/:runId/result-recovery`). Without one it lists the Agent's held
18
18
  * results (`GET .../result-recoveries`), which is the only way to find a run id to open. The list is one positional
@@ -39,14 +39,15 @@ function recoveryCode(value, known) {
39
39
  return known.includes(value) ? value : `${value} (${exports.UNKNOWN_CODE_HINT})`;
40
40
  }
41
41
  /**
42
- * Read-only. The server independently verifies owner and source authorization.
42
+ * Read-only. The server independently verifies review access and source authorization.
43
43
  *
44
44
  * With a run id it reads ONE review (`GET .../runs/:runId/result-recovery`). Without one it lists the Agent's held
45
45
  * results (`GET .../result-recoveries`), which is the only way to find a run id to open. The list is one positional
46
46
  * away from the read rather than a sibling command because it answers the same question for every Run instead of one.
47
47
  */
48
48
  class AgentsAlwaysOnRecoveryReview extends base_command_1.BaseCommand {
49
- static description = "Read Duty Run recovery evidence as the Agent owner; without a run id, list the Agent's held results";
49
+ static description = "Read Duty Run recovery evidence. Without a run id, list the Agent's held results you can access.\n\n" +
50
+ 'Workspace members with edit access to the Agent can review verified results for shared Duties. The Agent owner handles personal and unverified results.';
50
51
  static examples = [
51
52
  '<%= config.bin %> agents always-on recovery-review <agent-id>',
52
53
  '<%= config.bin %> agents always-on recovery-review <agent-id> --cursor <nextCursor>',
@@ -119,7 +120,7 @@ class AgentsAlwaysOnRecoveryReview extends base_command_1.BaseCommand {
119
120
  (0, http_error_1.httpBodyOf)(error)?.code === 'invalid_cursor') {
120
121
  this.failWithCliError({
121
122
  message: 'The server did not accept that cursor. A cursor expires after 15 minutes and works only for the Agent ' +
122
- 'and owner it was issued to.\n' +
123
+ 'and account it was issued to.\n' +
123
124
  `→ Start the list again: skrr agents always-on recovery-review ${agentId}`,
124
125
  code: 'RECOVERY_REVIEW_CURSOR_INVALID',
125
126
  status: 400,
@@ -71,8 +71,9 @@ export declare function unappliedPayloadKeys(sent: Record<string, unknown>, crea
71
71
  * to claim a platform role that they had misspelled something.
72
72
  */
73
73
  export declare function unappliedPayloadKeysWarning(keys: readonly string[]): string;
74
- export declare function initialAutonomyReceipt(created: unknown, requested: unknown): boolean | 'unconfirmed';
75
- export declare function backgroundLoopLines(agentId: string, relationshipLoopsSkipped: boolean, initialAlwaysOn?: boolean | 'unconfirmed'): string[];
74
+ type InitialAutonomyReceipt = boolean | 'pending' | 'inactive' | 'activation_unconfirmed' | 'unconfirmed';
75
+ export declare function initialAutonomyReceipt(created: unknown, requested: unknown): InitialAutonomyReceipt;
76
+ export declare function backgroundLoopLines(agentId: string, relationshipLoopsSkipped: boolean, initialAlwaysOn?: InitialAutonomyReceipt): string[];
76
77
  /**
77
78
  * The flags `--from-spec` may be combined with: placement and identity for the
78
79
  * NEW row, which a spec document deliberately cannot carry (where an agent runs
@@ -148,3 +149,4 @@ export default class AgentsCreate extends BaseCommand {
148
149
  */
149
150
  private createFromSpec;
150
151
  }
152
+ export {};
@@ -126,10 +126,19 @@ function unappliedPayloadKeysWarning(keys) {
126
126
  `or only the server sets ${one ? 'it' : 'them'}. \`skrr agents show <id> --json\` shows what the agent stores.`);
127
127
  }
128
128
  function initialAutonomyReceipt(created, requested) {
129
- if (requested !== false)
130
- return true;
131
- const provisioning = created && typeof created === 'object'
132
- ? created.proactiveProvisioning : null;
129
+ const agent = created && typeof created === 'object' ? created : null;
130
+ const provisioning = agent?.proactiveProvisioning;
131
+ if (requested !== false) {
132
+ if (agent?.isAlwaysOn === true)
133
+ return true;
134
+ const status = provisioning && typeof provisioning === 'object'
135
+ ? provisioning.status : undefined;
136
+ if (status === 'pending')
137
+ return 'pending';
138
+ if (status === 'failed' || agent?.isAlwaysOn === false)
139
+ return 'inactive';
140
+ return 'activation_unconfirmed';
141
+ }
133
142
  return provisioning && typeof provisioning === 'object' &&
134
143
  provisioning.initialAlwaysOn === false ? false : 'unconfirmed';
135
144
  }
@@ -139,6 +148,22 @@ function backgroundLoopLines(agentId, relationshipLoopsSkipped, initialAlwaysOn
139
148
  'Passive creation was requested, but the server did not acknowledge it. Autonomous state is unconfirmed.',
140
149
  ` skrr agents show ${agentId} --json # inspect actual runtime state`,
141
150
  ];
151
+ if (initialAlwaysOn === 'pending')
152
+ return [
153
+ 'Always-On setup is pending. Autonomous work starts after activation.',
154
+ ` skrr agents always-on status ${agentId} # check activation`,
155
+ ` skrr agents always-on disable ${agentId} # stop activation`,
156
+ ];
157
+ if (initialAlwaysOn === 'inactive')
158
+ return [
159
+ 'Always-On is off. Setup has not activated autonomous work.',
160
+ ` skrr agents always-on status ${agentId} # check activation`,
161
+ ];
162
+ if (initialAlwaysOn === 'activation_unconfirmed')
163
+ return [
164
+ 'Always-On activation is unconfirmed.',
165
+ ` skrr agents always-on status ${agentId} # check activation`,
166
+ ];
142
167
  if (!initialAlwaysOn)
143
168
  return [
144
169
  // Plain words for what exists: a policy, a Compass and the daily self-reflection
@@ -25,6 +25,7 @@ export default class DutiesCheckNow extends BaseCommand {
25
25
  };
26
26
  static flags: {
27
27
  json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
28
+ 'verify-version': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
28
29
  };
29
30
  run(): Promise<void>;
30
31
  }
@@ -48,8 +48,13 @@ function describeNotQueuedReason(reason, id, bin = 'skrr') {
48
48
  return sentence(`Nothing was queued: this Duty is ${reason.slice('duty_'.length)}, so it no longer runs.`);
49
49
  case 'duty_deleted':
50
50
  return sentence('Nothing was queued: this Duty was deleted.');
51
+ case 'duty_version_changed':
52
+ return sentence(`The Duty changed before the request was queued. Read its current version with \`${bin} duties show ${id}\`.`);
53
+ case 'duty_verification_not_reserved':
54
+ return sentence('Another Check took this turn. Request verification again after it finishes.');
51
55
  case 'duty_check_not_reserved':
52
56
  return sentence('Nothing was queued: the platform did not reserve a new check for it just now. Try again shortly.');
57
+ case 'active_check':
53
58
  case 'reservation_exists':
54
59
  // Two requests at once: one reserves the check, the other meets that reservation.
55
60
  return sentence(`Nothing new was queued: a check for this Duty is already queued or running. See it with \`${bin} duties checks ${id}\`.`);
@@ -72,19 +77,24 @@ class DutiesCheckNow extends base_command_1.BaseCommand {
72
77
  static examples = [
73
78
  '<%= config.bin %> duties check-now <duty-id>',
74
79
  '<%= config.bin %> duties check-now <duty-id> --json',
80
+ '<%= config.bin %> duties check-now <duty-id> --verify-version 3',
75
81
  ];
76
82
  static args = {
77
83
  id: core_1.Args.string({ description: 'Duty ID', required: true, ignoreStdin: true }),
78
84
  };
79
85
  static flags = {
80
86
  json: core_1.Flags.boolean({ description: 'Output as JSON' }),
87
+ 'verify-version': core_1.Flags.integer({
88
+ min: 1,
89
+ description: 'Request fresh declared observations for this exact Duty version using its existing execution limits',
90
+ }),
81
91
  };
82
92
  async run() {
83
93
  this.requireAuth();
84
94
  const { args, flags } = await this.parse(DutiesCheckNow);
85
95
  let result;
86
96
  try {
87
- result = await duties_1.dutyApi.checkNow(args.id);
97
+ result = await duties_1.dutyApi.checkNow(args.id, flags['verify-version']);
88
98
  }
89
99
  catch (err) {
90
100
  this.handleApiError(err);
@@ -96,6 +106,12 @@ class DutiesCheckNow extends base_command_1.BaseCommand {
96
106
  const status = String(result.status ?? 'unknown');
97
107
  const checkId = result.checkId ? String(result.checkId) : null;
98
108
  this.log(`Check ${status}${checkId ? ` — ${checkId}` : ''}`);
109
+ const verifyVersion = flags['verify-version'];
110
+ if (status === 'queued' && verifyVersion !== undefined) {
111
+ this.log(result.verifyVersion === verifyVersion
112
+ ? `Observation verification queued for Duty version ${verifyVersion}.`
113
+ : 'The server queued a regular Check. Version verification was not confirmed.');
114
+ }
99
115
  if (status !== 'queued') {
100
116
  const sentence = describeNotQueuedReason(result.reason, args.id, this.config.bin);
101
117
  if (sentence)
@@ -220,6 +220,34 @@ function activationBlockers(body) {
220
220
  }
221
221
  return blockers;
222
222
  }
223
+ async function activateCreatedDuty(id, version) {
224
+ const reconcileRetryDelays = [1000, 2000, 3000, 4000];
225
+ for (let attempt = 0;; attempt++) {
226
+ try {
227
+ return attempt === 0 ? await duties_1.dutyApi.resume(id) : await duties_1.dutyApi.resume(id, version);
228
+ }
229
+ catch (error) {
230
+ const delay = reconcileRetryDelays[attempt];
231
+ const { code, body } = (0, base_command_1.apiRefusal)(error);
232
+ const rawBlockers = record(body?.diagnostic)?.blockers;
233
+ const blockers = activationBlockers(body);
234
+ if (delay === undefined ||
235
+ (code ?? body?.error) !== 'DUTY_ACTIVATION_BLOCKED' ||
236
+ !Array.isArray(rawBlockers) ||
237
+ !blockers.length ||
238
+ blockers.length !== rawBlockers.length ||
239
+ blockers.some(({ gate, reason }) => gate !== 'always_on' || reason !== 'reconcile_pending') ||
240
+ typeof version !== 'number' ||
241
+ !Number.isSafeInteger(version) ||
242
+ version < 1) {
243
+ throw error;
244
+ }
245
+ // Creation can start an Always-On reconciliation. Retry only that
246
+ // refusal, against the same draft, so an owner edit or stop wins.
247
+ await new Promise((resolve) => setTimeout(resolve, delay));
248
+ }
249
+ }
250
+ }
223
251
  function dutyActivationRefusal(err, { id, bin }) {
224
252
  const refusal = (0, base_command_1.apiRefusal)(err);
225
253
  // `resume` answers with every blocking gate, but only the first is in the message. Fixing it
@@ -340,8 +368,8 @@ JSON
340
368
  }),
341
369
  activate: core_1.Flags.boolean({
342
370
  description: 'Turn the duty on right after creating it — the same resume + Preflight boundary ' +
343
- "as `duties resume`. A refused activation keeps the draft and reports the refusal's " +
344
- 'code, reason and fix, and exits nonzero. Use the returned ID to resume it instead of creating another.',
371
+ "as `duties resume`. A refusal reports its code, reason and fix, and exits nonzero. " +
372
+ 'If a new draft was saved, use its returned ID to resume it.',
345
373
  }),
346
374
  deadline: core_1.Flags.string({ description: 'ISO-8601 deadline for an `achieve` duty' }),
347
375
  criterion: core_1.Flags.string({
@@ -579,23 +607,77 @@ JSON
579
607
  exit: 1,
580
608
  });
581
609
  }
582
- // Creation is authoring only. Activation is a separate resume boundary
583
- // that runs the current preflight; JSON imports cannot bypass it.
584
610
  payload.status = 'draft';
611
+ delete payload.activate;
585
612
  let duty;
586
613
  try {
587
- duty = await duties_1.dutyApi.create(payload);
614
+ duty = await duties_1.dutyApi.create(flags.activate ? { ...payload, activate: true } : payload);
588
615
  }
589
616
  catch (err) {
590
- this.handleApiError(err);
617
+ const { body } = (0, base_command_1.apiRefusal)(err);
618
+ const details = body?.details;
619
+ const olderServer = flags.activate &&
620
+ Array.isArray(details) &&
621
+ details.some((issue) => issue?.code === 'unrecognized_keys' &&
622
+ Array.isArray(issue.keys) &&
623
+ issue.keys.includes('activate'));
624
+ if (!olderServer)
625
+ this.handleApiError(err);
626
+ try {
627
+ duty = await duties_1.dutyApi.create(payload);
628
+ }
629
+ catch (fallbackError) {
630
+ this.handleApiError(fallbackError);
631
+ }
591
632
  }
592
633
  // `--activate` is the same resume + Preflight boundary `duties
593
634
  // resume` runs, composed onto the create so the caller gets one answer.
594
635
  // A refusal is reported on the result — never thrown over the draft's id.
595
636
  let activation = null;
596
- if (flags.activate) {
637
+ const start = duty?.directStart;
638
+ const requestedController = record(record(payload.policy)?.cadenceController);
639
+ const existingController = duty?.policy?.cadenceController;
640
+ const mismatchedSetting = start?.state === 'existing' && duty?.status === 'active'
641
+ ? ['mode', 'riskProfile'].find((setting) => typeof requestedController?.[setting] === 'string' &&
642
+ requestedController[setting] !== existingController?.[setting])
643
+ : undefined;
644
+ if (flags.activate && mismatchedSetting) {
645
+ const label = mismatchedSetting === 'mode' ? 'mode' : 'risk profile';
646
+ const current = existingController?.[mismatchedSetting] ?? 'unreported';
647
+ const requested = requestedController?.[mismatchedSetting];
648
+ activation = {
649
+ activated: false,
650
+ refusal: {
651
+ code: 'DUTY_EXISTING_CADENCE_POLICY_MISMATCH',
652
+ reason: `The existing active Duty has cadence controller ${label} ${current}. This request asked for ${requested}.`,
653
+ fix: `Create a separate draft without --activate, then run \`${this.config.bin} duties resume <new-duty-id>\`.`,
654
+ },
655
+ };
656
+ }
657
+ else if (flags.activate && start) {
658
+ activation =
659
+ duty?.status === 'active'
660
+ ? { activated: true }
661
+ : {
662
+ activated: false,
663
+ refusal: start.state === 'not_started'
664
+ ? {
665
+ code: start.code,
666
+ reason: start.reason,
667
+ fix: (0, data_provider_1.describeDutyActivationFix)(start.code, {
668
+ turnOn: `run \`${this.config.bin} duties resume ${duty?.id}\``,
669
+ }),
670
+ }
671
+ : {
672
+ code: 'DUTY_ALREADY_EXISTS',
673
+ reason: `Existing Duty is ${duty?.status}.`,
674
+ fix: `Review it with \`${this.config.bin} duties show ${duty?.id}\`.`,
675
+ },
676
+ };
677
+ }
678
+ else if (flags.activate) {
597
679
  try {
598
- duty = await duties_1.dutyApi.resume(String(duty.id));
680
+ duty = await activateCreatedDuty(String(duty.id), duty.version);
599
681
  activation = { activated: true };
600
682
  }
601
683
  catch (err) {
@@ -632,7 +714,11 @@ JSON
632
714
  }), null, 2));
633
715
  return;
634
716
  }
635
- this.log(activation?.activated ? 'Created and activated duty:' : 'Created duty:');
717
+ this.log(start?.state === 'existing'
718
+ ? 'Existing duty:'
719
+ : activation?.activated
720
+ ? 'Created and activated duty:'
721
+ : 'Created duty:');
636
722
  (0, duties_1.renderDutySummary)(duty, (line) => this.log(line));
637
723
  (0, duties_1.renderDutyWriteWarnings)(warnings, (line) => this.warn(line));
638
724
  if (activation && !activation.activated) {
@@ -32,6 +32,7 @@ export default class DutiesObservations extends BaseCommand {
32
32
  };
33
33
  static flags: {
34
34
  json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
35
+ check: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
35
36
  latest: import("@oclif/core/interfaces").BooleanFlag<boolean>;
36
37
  key: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
37
38
  window: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
@@ -81,6 +81,7 @@ class DutiesObservations extends base_command_1.BaseCommand {
81
81
  'cap on how much an Agent-reported reading is worth, not a measurement.';
82
82
  static examples = [
83
83
  '<%= config.bin %> duties observations obj_abc123',
84
+ '<%= config.bin %> duties observations obj_abc123 --check objchk_abc123 --json',
84
85
  '<%= config.bin %> duties observations obj_abc123 --declared-only --changed-only',
85
86
  '<%= config.bin %> duties observations obj_abc123 --since 2026-08-01 --limit 100 --json',
86
87
  ];
@@ -89,6 +90,7 @@ class DutiesObservations extends base_command_1.BaseCommand {
89
90
  };
90
91
  static flags = {
91
92
  json: core_1.Flags.boolean({ description: 'Output as JSON' }),
93
+ check: core_1.Flags.string({ description: 'Only readings recorded by this Duty Check' }),
92
94
  latest: core_1.Flags.boolean({
93
95
  description: 'Latest recorded attempt per current declared key (not history)',
94
96
  }),
@@ -118,12 +120,17 @@ class DutiesObservations extends base_command_1.BaseCommand {
118
120
  async run() {
119
121
  this.requireAuth();
120
122
  const { args, flags } = await this.parse(DutiesObservations);
121
- if (flags.latest && (flags.window || flags.cursor || flags['changed-only'] || flags.since))
122
- this.error('--latest cannot be combined with --window, --cursor, --changed-only, or --since');
123
+ if (flags.latest &&
124
+ (flags.check || flags.window || flags.cursor || flags['changed-only'] || flags.since))
125
+ this.error('--latest cannot be combined with --check, --window, --cursor, --changed-only, or --since');
123
126
  let response;
124
127
  if (flags.window) {
125
128
  try {
126
- if (flags['declared-only'] || flags['changed-only'] || flags.since || flags.cursor)
129
+ if (flags.check ||
130
+ flags['declared-only'] ||
131
+ flags['changed-only'] ||
132
+ flags.since ||
133
+ flags.cursor)
127
134
  this.error('--window cannot be combined with list filters');
128
135
  const query = {
129
136
  key: flags.key,
@@ -154,6 +161,7 @@ class DutiesObservations extends base_command_1.BaseCommand {
154
161
  this.error('--key requires --window');
155
162
  try {
156
163
  response = await duties_1.dutyApi.observations(args.dutyId, {
164
+ ...(flags.check ? { checkId: flags.check } : {}),
157
165
  limit: flags.limit,
158
166
  latest: flags.latest || undefined,
159
167
  declaredOnly: flags['declared-only'] || undefined,
@@ -177,6 +185,7 @@ class DutiesObservations extends base_command_1.BaseCommand {
177
185
  // facts; a filter that empties the list must not claim the first
178
186
  // (OSK-10953).
179
187
  const filters = [
188
+ flags.check ? `--check ${flags.check}` : null,
180
189
  flags.latest ? '--latest' : null,
181
190
  flags['declared-only'] ? '--declared-only' : null,
182
191
  flags['changed-only'] ? '--changed-only' : null,
@@ -6,10 +6,18 @@ const core_1 = require("@oclif/core");
6
6
  const base_command_1 = require("../../base-command");
7
7
  const duties_1 = require("../../lib/duties");
8
8
  const DUTY_RE = /^obj_/;
9
+ function verifiedPortfolio(review) {
10
+ const portfolio = review.currentPortfolio;
11
+ return portfolio?.sourcePolicy?.status === 'partial' &&
12
+ portfolio.sourcePolicy.reason === 'physical_agent_current_contracts_only' &&
13
+ Array.isArray(portfolio.duties) && Array.isArray(portfolio.recentRuns)
14
+ ? portfolio : undefined;
15
+ }
9
16
  /** Old servers cannot prove historical Duties belong to this physical Agent. */
10
17
  function sanitizeOperatingReview(review) {
11
18
  return {
12
19
  ...review,
20
+ currentPortfolio: verifiedPortfolio(review),
13
21
  reflectionDuty: null,
14
22
  systemDuties: null,
15
23
  portfolio: null,
@@ -22,11 +30,35 @@ function sanitizeOperatingReview(review) {
22
30
  }
23
31
  /** Report unavailable rather than implying that there were no Duties or questions. */
24
32
  function formatOperatingReview(review) {
25
- return [
33
+ const lines = [
26
34
  `Agent ${review.agentId}`,
27
35
  `Always-On is ${review.alwaysOn === true ? 'ON' : review.alwaysOn === false ? 'OFF' : 'unknown'}.`,
28
- 'Duty portfolio, loop details, proposals and open questions are unavailable because their sources cannot be verified.',
29
36
  ];
37
+ const portfolio = verifiedPortfolio(review);
38
+ if (!portfolio) {
39
+ return [...lines, 'Duty portfolio, loop details, proposals and open questions are unavailable because their sources cannot be verified.'];
40
+ }
41
+ lines.push('Verified current Duties');
42
+ if (!portfolio.duties.length)
43
+ lines.push('No current Duty contracts could be verified.');
44
+ for (const duty of portfolio.duties) {
45
+ lines.push(`- ${duty.title} (${duty.id}) · ${duty.status} · version ${duty.version}`);
46
+ }
47
+ if (portfolio.truncated)
48
+ lines.push('More verified current Duties are outside this review.');
49
+ for (const check of portfolio.recentReflectionChecks ?? []) {
50
+ lines.push(`- Reflection Check · ${check.status} · ${check.path}`);
51
+ }
52
+ lines.push('Recent verified Runs');
53
+ if (!portfolio.recentRuns.length)
54
+ lines.push('No recent Runs could be verified. A new Check can record fresh evidence.');
55
+ const titleById = new Map(portfolio.duties.map(({ id, title }) => [id, title]));
56
+ for (const run of portfolio.recentRuns) {
57
+ const status = (run.peerVerificationStatus || run.status).replaceAll('_', ' ');
58
+ lines.push(`- ${titleById.get(run.dutyId) || run.dutyId} · ${status} · ${run.path}`);
59
+ }
60
+ lines.push('Proposal and open-question history is unavailable.');
61
+ return lines;
30
62
  }
31
63
  class DutiesOperatingReview extends base_command_1.BaseCommand {
32
64
  static description = 'Read an agent’s system-managed duty operating review';
@@ -1,5 +1,6 @@
1
1
  import { BaseCommand } from '../../../base-command';
2
2
  import { type DutyPackPlanResponse } from '../../../lib/duties';
3
+ export declare function formatPlanPreview(duty: DutyPackPlanResponse['duty']): string[];
3
4
  /**
4
5
  * Lines for what the plan says will stop the loop from ever being activated. `bind` would still
5
6
  * write a draft, so a reader who sees only "Nothing was created" must also see this.
@@ -1,10 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatPlanPreview = formatPlanPreview;
3
4
  exports.formatReadiness = formatReadiness;
4
5
  const core_1 = require("@oclif/core");
6
+ const data_provider_1 = require("@skrr-ai/data-provider");
5
7
  const base_command_1 = require("../../../base-command");
6
8
  const prompt_1 = require("../../../lib/prompt");
7
9
  const duties_1 = require("../../../lib/duties");
10
+ function formatPlanPreview(duty) {
11
+ if (!duty)
12
+ return [];
13
+ const lines = [];
14
+ if (duty.title)
15
+ lines.push(`Duty ${duty.title}`);
16
+ if (duty.subject?.id)
17
+ lines.push(`Scope ${duty.subject.type} ${duty.subject.id}`);
18
+ if (duty.target?.outcome)
19
+ lines.push(`Outcome ${duty.target.outcome}`);
20
+ if (duty.cadence?.mode)
21
+ lines.push(`Checks ${(0, duties_1.cadenceLabel)(duty)}`);
22
+ if (duty.delivery?.mode) {
23
+ const mode = duty.delivery.mode.replaceAll('_', ' ');
24
+ const destinations = [...new Set((duty.reports || [])
25
+ .filter((report) => report.enabled !== false && report.destination)
26
+ .map((report) => data_provider_1.DUTY_DESTINATION_REGISTRY[report.destination]?.label ?? report.destination))];
27
+ lines.push(`Delivery ${mode}${destinations.length ? ` to ${destinations.join(', ')}` : ''}`);
28
+ }
29
+ return lines;
30
+ }
8
31
  /**
9
32
  * Lines for what the plan says will stop the loop from ever being activated. `bind` would still
10
33
  * write a draft, so a reader who sees only "Nothing was created" must also see this.
@@ -125,8 +148,15 @@ class DutiesPackPlan extends base_command_1.BaseCommand {
125
148
  const holder = placement.holder === 'space_lead' ? ' (the Space lead)' : '';
126
149
  this.log(`Space loop: ${placement.spaceId}, held by ${placement.agentId}${holder}`);
127
150
  }
151
+ else if (result.duty?.agentId) {
152
+ this.log(`Holder ${result.duty.agentId}`);
153
+ }
154
+ for (const line of formatPlanPreview(result.duty))
155
+ this.log(line);
128
156
  for (const line of formatReadiness(result.readiness))
129
157
  this.log(line);
158
+ if (result.duty)
159
+ this.log('\nUse --json to read the full plan, including its instructions.');
130
160
  this.log('\nTo bind the Duty, pass the same Pack inputs to `skrr duties pack bind` with `--plan-digest`.');
131
161
  }
132
162
  }
@@ -44,6 +44,7 @@ export default class DutiesPlan extends BaseCommand {
44
44
  role: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
45
45
  'work-context': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
46
46
  timezone: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
47
+ 'personal-inference': import("@oclif/core/interfaces").BooleanFlag<boolean>;
47
48
  };
48
49
  run(): Promise<void>;
49
50
  }
@@ -5,6 +5,13 @@ exports.planTimezoneLines = planTimezoneLines;
5
5
  const core_1 = require("@oclif/core");
6
6
  const base_command_1 = require("../../base-command");
7
7
  const duties_1 = require("../../lib/duties");
8
+ const DRAFT_PLACEMENT_REFUSALS = new Set([
9
+ 'DUTY_PLANNER_RUNTIME_UNSUPPORTED',
10
+ 'DUTY_PLANNER_CAPABILITY_UNVERIFIED',
11
+ 'DUTY_PLANNER_TARGET_OFFLINE',
12
+ 'DUTY_PLANNER_TARGET_CONSENT_REQUIRED',
13
+ 'DUTY_PLANNER_TARGET_UNAVAILABLE',
14
+ ]);
8
15
  /**
9
16
  * `skrr duties plan` — draft a duty contract from one sentence.
10
17
  *
@@ -71,6 +78,7 @@ class DutiesPlan extends base_command_1.BaseCommand {
71
78
  static examples = [
72
79
  '<%= config.bin %> duties plan --agent <agent-id> --sentence "Make sure every candidate hears back within 48 hours"',
73
80
  '<%= config.bin %> duties plan --agent <agent-id> --sentence "Keep the hiring loop tight" --template hiring_follow_through',
81
+ '<%= config.bin %> duties plan --agent <agent-id> --sentence "Watch the support queue" --personal-inference',
74
82
  '<%= config.bin %> duties plan --agent <agent-id> --sentence "..." --json > proposal.json',
75
83
  ];
76
84
  static flags = {
@@ -88,6 +96,9 @@ class DutiesPlan extends base_command_1.BaseCommand {
88
96
  role: core_1.Flags.string({ description: 'Your role, to bias the draft' }),
89
97
  'work-context': core_1.Flags.string({ description: 'Extra context about the work' }),
90
98
  timezone: core_1.Flags.string({ description: 'IANA timezone for cadence/deadline reasoning' }),
99
+ 'personal-inference': core_1.Flags.boolean({
100
+ description: 'Draft using your saved inference settings. Hosted targets may use managed allowance.',
101
+ }),
91
102
  };
92
103
  async run() {
93
104
  this.requireAuth();
@@ -102,9 +113,16 @@ class DutiesPlan extends base_command_1.BaseCommand {
102
113
  ...(flags.role ? { role: flags.role } : {}),
103
114
  ...(flags['work-context'] ? { workContext: flags['work-context'] } : {}),
104
115
  ...(flags.timezone ? { timezone: flags.timezone } : {}),
116
+ ...(flags['personal-inference'] ? { inferencePlacement: 'personal' } : {}),
105
117
  });
106
118
  }
107
119
  catch (err) {
120
+ if (!flags.json && !flags['personal-inference']) {
121
+ const { code } = (0, base_command_1.apiRefusal)(err);
122
+ if (DRAFT_PLACEMENT_REFUSALS.has(code ?? '')) {
123
+ this.warn('Add --personal-inference to draft with your saved inference settings. The selected Agent still runs the Duty.');
124
+ }
125
+ }
108
126
  this.handleApiError(err);
109
127
  }
110
128
  if (flags.json) {
@@ -147,6 +165,12 @@ class DutiesPlan extends base_command_1.BaseCommand {
147
165
  }
148
166
  for (const line of planTimezoneLines(response.proposal, flags.timezone))
149
167
  this.log(line);
168
+ if (response.notificationPreview) {
169
+ this.log('');
170
+ this.log('Example outcomes');
171
+ this.log(` Notify ${response.notificationPreview.notify}`);
172
+ this.log(` Quiet ${response.notificationPreview.quiet}`);
173
+ }
150
174
  this.log('');
151
175
  this.log('Proposed contract:');
152
176
  this.log(JSON.stringify(response.proposal, null, 2));
@@ -34,7 +34,7 @@ type PreflightGate = DutyPreflightReport['gates'][number];
34
34
  export declare function nextRunsLines(report: {
35
35
  verdict?: string;
36
36
  nextRuns?: string[];
37
- }): string[];
37
+ }, projectedActivation?: boolean): string[];
38
38
  /**
39
39
  * The first line of a preflight. `Ready to run` is a statement about activation (no blocking gate),
40
40
  * and it sat directly above a spend-gate warning that the daily Run budget is 0, i.e. that no agent
@@ -42,8 +42,8 @@ export declare function nextRunsLines(report: {
42
42
  * not stop the sensing lane, so refusing activation would be wrong for a Duty that only
43
43
  * observes. The headline carries the caveat instead of contradicting the gate below it.
44
44
  */
45
- export declare function preflightHeadline(report: Pick<DutyPreflightReport, 'verdict' | 'gates' | 'activation' | 'sourcePolicy'>, persisted: boolean): string;
46
- export declare function preflightGateLines(gate: PreflightGate, verbose?: boolean, refusesActivation?: boolean): string[];
45
+ export declare function preflightHeadline(report: Pick<DutyPreflightReport, 'verdict' | 'gates' | 'activation' | 'sourcePolicy' | 'permissions'>, persisted: boolean): string;
46
+ export declare function preflightGateLines(gate: PreflightGate, verbose?: boolean, refusesActivation?: boolean, unsavedDraft?: boolean): string[];
47
47
  /**
48
48
  * The `Attention:` footer, and under it the settings behind the verdict (OSK-21120).
49
49
  *