@skrr-ai/cli 0.1.155 → 0.1.157

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 (148) hide show
  1. package/dist/base-command.js +64 -16
  2. package/dist/commands/activity/list.d.ts +13 -0
  3. package/dist/commands/activity/list.js +50 -0
  4. package/dist/commands/activity/show.d.ts +18 -0
  5. package/dist/commands/activity/show.js +125 -0
  6. package/dist/commands/agent/message/send.js +64 -19
  7. package/dist/commands/agents/always-on/held-messages.js +24 -1
  8. package/dist/commands/agents/always-on/status.js +6 -1
  9. package/dist/commands/agents/mini-computer/app/reset.d.ts +13 -0
  10. package/dist/commands/agents/mini-computer/app/reset.js +35 -0
  11. package/dist/commands/agents/mini-computer/app/set.d.ts +16 -0
  12. package/dist/commands/agents/mini-computer/app/set.js +70 -0
  13. package/dist/commands/agents/mini-computer/layout/change.d.ts +14 -0
  14. package/dist/commands/agents/mini-computer/layout/change.js +44 -0
  15. package/dist/commands/agents/mini-computer/layout/folder.d.ts +14 -0
  16. package/dist/commands/agents/mini-computer/layout/folder.js +35 -0
  17. package/dist/commands/agents/mini-computer/layout/move.d.ts +14 -0
  18. package/dist/commands/agents/mini-computer/layout/move.js +32 -0
  19. package/dist/commands/agents/mini-computer/layout/pin.d.ts +14 -0
  20. package/dist/commands/agents/mini-computer/layout/pin.js +35 -0
  21. package/dist/commands/agents/mini-computer/layout/remove.d.ts +13 -0
  22. package/dist/commands/agents/mini-computer/layout/remove.js +27 -0
  23. package/dist/commands/agents/mini-computer/layout/restore.d.ts +13 -0
  24. package/dist/commands/agents/mini-computer/layout/restore.js +27 -0
  25. package/dist/commands/agents/mini-computer/layout/unfolder.d.ts +13 -0
  26. package/dist/commands/agents/mini-computer/layout/unfolder.js +27 -0
  27. package/dist/commands/agents/mini-computer/layout/unpin.d.ts +14 -0
  28. package/dist/commands/agents/mini-computer/layout/unpin.js +34 -0
  29. package/dist/commands/agents/mini-computer/show.d.ts +13 -0
  30. package/dist/commands/agents/mini-computer/show.js +60 -0
  31. package/dist/commands/agents/mini-computer/tasks-view.d.ts +29 -0
  32. package/dist/commands/agents/mini-computer/tasks-view.js +100 -0
  33. package/dist/commands/apps/auto-apply.d.ts +14 -0
  34. package/dist/commands/apps/auto-apply.js +53 -0
  35. package/dist/commands/apps/check.js +4 -1
  36. package/dist/commands/apps/create.js +11 -6
  37. package/dist/commands/apps/data/batch.d.ts +15 -0
  38. package/dist/commands/apps/data/batch.js +59 -0
  39. package/dist/commands/apps/data/collections.d.ts +12 -0
  40. package/dist/commands/apps/data/collections.js +44 -0
  41. package/dist/commands/apps/data/delete.d.ts +15 -0
  42. package/dist/commands/apps/data/delete.js +57 -0
  43. package/dist/commands/apps/data/patch.d.ts +17 -0
  44. package/dist/commands/apps/data/patch.js +70 -0
  45. package/dist/commands/apps/data/put.js +1 -1
  46. package/dist/commands/apps/data/query.js +1 -1
  47. package/dist/commands/apps/installations/diff.d.ts +14 -0
  48. package/dist/commands/apps/installations/diff.js +45 -0
  49. package/dist/commands/apps/installations/events.d.ts +23 -0
  50. package/dist/commands/apps/installations/events.js +104 -0
  51. package/dist/commands/apps/installations/snapshot.d.ts +18 -0
  52. package/dist/commands/apps/installations/snapshot.js +60 -0
  53. package/dist/commands/apps/installations/versions.d.ts +12 -0
  54. package/dist/commands/apps/installations/versions.js +38 -0
  55. package/dist/commands/apps/logs.js +3 -0
  56. package/dist/commands/apps/preview.js +4 -2
  57. package/dist/commands/apps/pull.js +10 -1
  58. package/dist/commands/apps/push.js +36 -12
  59. package/dist/commands/apps/reference.d.ts +26 -0
  60. package/dist/commands/apps/reference.js +56 -0
  61. package/dist/commands/apps/rollback.d.ts +13 -0
  62. package/dist/commands/apps/rollback.js +47 -0
  63. package/dist/commands/apps/version/create.js +5 -0
  64. package/dist/commands/duties/accounting.js +6 -0
  65. package/dist/commands/duties/analytics/detail.js +6 -0
  66. package/dist/commands/duties/analytics/index.js +14 -0
  67. package/dist/commands/duties/analytics/replay.js +6 -0
  68. package/dist/commands/duties/cost.js +6 -0
  69. package/dist/commands/duties/delete.js +22 -19
  70. package/dist/commands/duties/doctor.d.ts +2 -1
  71. package/dist/commands/duties/doctor.js +17 -3
  72. package/dist/commands/duties/goals/link.js +4 -0
  73. package/dist/commands/duties/goals/unlink.js +4 -0
  74. package/dist/commands/duties/lineage.js +6 -1
  75. package/dist/commands/duties/links/list.js +6 -0
  76. package/dist/commands/duties/metrics.js +10 -0
  77. package/dist/commands/duties/observations.js +12 -0
  78. package/dist/commands/duties/operating-review.d.ts +4 -30
  79. package/dist/commands/duties/operating-review.js +28 -141
  80. package/dist/commands/duties/receipt-metrics.js +7 -0
  81. package/dist/commands/duties/receipt.js +7 -0
  82. package/dist/commands/duties/roster.js +14 -8
  83. package/dist/commands/duties/show.js +27 -9
  84. package/dist/commands/duties/status.js +18 -9
  85. package/dist/commands/duties/trigger-status.d.ts +2 -0
  86. package/dist/commands/duties/trigger-status.js +19 -1
  87. package/dist/commands/duties/wake-capabilities.d.ts +2 -0
  88. package/dist/commands/duties/wake-capabilities.js +32 -2
  89. package/dist/commands/followups/act.js +3 -0
  90. package/dist/commands/followups/remind.js +12 -3
  91. package/dist/commands/followups/show.js +6 -0
  92. package/dist/commands/harnesses/quota.js +1 -1
  93. package/dist/commands/spaces/notebook.d.ts +3 -7
  94. package/dist/commands/spaces/notebook.js +32 -8
  95. package/dist/commands/tasks/create.d.ts +2 -2
  96. package/dist/commands/tasks/create.js +3 -3
  97. package/dist/commands/tasks/list.d.ts +3 -41
  98. package/dist/commands/tasks/list.js +5 -53
  99. package/dist/generated/agent-guides.json +424 -101
  100. package/dist/generated/managed-instruction-guides.json +1 -1
  101. package/dist/lib/agent-activity.d.ts +68 -0
  102. package/dist/lib/agent-activity.js +106 -0
  103. package/dist/lib/always-on-runtime.d.ts +9 -0
  104. package/dist/lib/always-on-runtime.js +20 -0
  105. package/dist/lib/api-fetch.d.ts +10 -0
  106. package/dist/lib/api-fetch.js +12 -2
  107. package/dist/lib/appData.d.ts +28 -1
  108. package/dist/lib/appData.js +111 -9
  109. package/dist/lib/appInstallations.d.ts +9 -1
  110. package/dist/lib/appInstallations.js +100 -0
  111. package/dist/lib/apps-command.d.ts +1 -0
  112. package/dist/lib/apps-command.js +11 -0
  113. package/dist/lib/apps.d.ts +12 -0
  114. package/dist/lib/apps.js +28 -1
  115. package/dist/lib/appsAssets.d.ts +17 -0
  116. package/dist/lib/appsAssets.js +15 -0
  117. package/dist/lib/appsCheck.d.ts +1 -0
  118. package/dist/lib/appsCheck.js +1 -0
  119. package/dist/lib/appsFs.d.ts +18 -1
  120. package/dist/lib/appsFs.js +76 -19
  121. package/dist/lib/compasses.js +6 -0
  122. package/dist/lib/duties.d.ts +25 -2
  123. package/dist/lib/duties.js +58 -3
  124. package/dist/lib/duty-analytics.d.ts +2 -0
  125. package/dist/lib/duty-analytics.js +26 -0
  126. package/dist/lib/duty-goal-propagation.d.ts +2 -0
  127. package/dist/lib/duty-goal-propagation.js +18 -0
  128. package/dist/lib/duty-history-source.d.ts +4 -0
  129. package/dist/lib/duty-history-source.js +12 -0
  130. package/dist/lib/duty-ledgers.d.ts +4 -0
  131. package/dist/lib/duty-ledgers.js +4 -0
  132. package/dist/lib/duty-receipt-source.d.ts +4 -0
  133. package/dist/lib/duty-receipt-source.js +19 -0
  134. package/dist/lib/followups.d.ts +20 -0
  135. package/dist/lib/followups.js +10 -0
  136. package/dist/lib/held-messages.d.ts +22 -0
  137. package/dist/lib/held-messages.js +55 -0
  138. package/dist/lib/list-workspace.d.ts +40 -0
  139. package/dist/lib/list-workspace.js +58 -0
  140. package/dist/lib/miniComputer.d.ts +59 -0
  141. package/dist/lib/miniComputer.js +224 -0
  142. package/dist/lib/miniComputerCommand.d.ts +13 -0
  143. package/dist/lib/miniComputerCommand.js +48 -0
  144. package/dist/lib/roles.d.ts +3 -3
  145. package/dist/lib/space-notebook.js +15 -4
  146. package/dist/node_modules/@skrr-ai/data-provider/index.js +10465 -8383
  147. package/oclif.manifest.json +2789 -533
  148. package/package.json +14 -2
@@ -18,7 +18,7 @@ const prompt_1 = require("../../lib/prompt");
18
18
  * Refused for system-managed loops, which the platform re-creates anyway.
19
19
  */
20
20
  class DutiesDelete extends base_command_1.BaseCommand {
21
- static description = 'Delete a duty (soft — its history stays readable; pause or archive an active one first)';
21
+ static description = 'Delete a duty (soft — pause or archive an active one first)';
22
22
  static examples = [
23
23
  '<%= config.bin %> duties delete <duty-id>',
24
24
  '<%= config.bin %> duties delete <duty-id> --reason "scratch probe"',
@@ -31,20 +31,31 @@ class DutiesDelete extends base_command_1.BaseCommand {
31
31
  reason: core_1.Flags.string({ description: 'Why it was deleted (recorded on the boundary ledger)' }),
32
32
  yes: core_1.Flags.boolean({ char: 'y', description: 'Skip confirmation prompt' }),
33
33
  'stop-open-work': core_1.Flags.boolean({
34
- description: 'Cancel the open Tasks this Duty produced. Without it they KEEP RUNNING — deleting the producer has never stopped the product.',
34
+ description: 'Automatic task cancellation is unavailable',
35
35
  allowNo: true,
36
+ hidden: true,
36
37
  }),
37
38
  };
38
39
  async run() {
39
40
  this.requireAuth();
40
41
  const { args, flags } = await this.parse(DutiesDelete);
42
+ if (flags['stop-open-work'] === true) {
43
+ this.error('Automatic task cancellation is unavailable. Stop tasks individually before deleting the Duty.', { exit: 1 });
44
+ }
41
45
  let preview = null;
42
46
  try {
43
47
  preview = (await duties_1.dutyApi.deletionPreview(args.id));
44
48
  }
45
49
  catch {
46
- // An older server has no preview route. Proceed — the delete itself
47
- // still refuses to guess when there is open work.
50
+ // Without a verified preview contract, older servers may also perform
51
+ // unscoped deletion. Never make that destructive request blindly.
52
+ }
53
+ const previewIsScoped = preview?.sourcePolicy?.status === 'partial' &&
54
+ preview.sourcePolicy.reason === 'actor_scope_only' &&
55
+ Number.isSafeInteger(preview.openTaskCount) &&
56
+ preview.openTaskCount >= 0;
57
+ if (!previewIsScoped) {
58
+ this.error('Cannot verify the Duty deletion scope. Retry when the preview is available or upgrade the server before deleting.', { exit: 1 });
48
59
  }
49
60
  // The API refuses to delete an active Duty, and rightly so. But a
50
61
  // deliberate step is not the same as a dead end: the person has already
@@ -52,17 +63,9 @@ class DutiesDelete extends base_command_1.BaseCommand {
52
63
  // than a second command they have to go and find. Same rule the web
53
64
  // dialog applies, so the two surfaces cannot drift.
54
65
  const mustPauseFirst = preview?.requiresStopFirst === true;
55
- const openTasks = Number(preview?.openTaskCount || 0);
56
- if (openTasks > 0 && flags['stop-open-work'] === undefined) {
57
- this.error(`${args.id} has ${openTasks} open task(s), and deleting it does NOT stop them.\n` +
58
- ` skrr duties delete ${args.id} --stop-open-work # cancel them too\n` +
59
- ` skrr duties delete ${args.id} --no-stop-open-work # leave them running`, { exit: 1 });
60
- }
61
- const fate = openTasks === 0
62
- ? 'Its checks, runs and cases stay readable.'
63
- : flags['stop-open-work']
64
- ? `Its ${openTasks} open task(s) will be CANCELLED.`
65
- : `Its ${openTasks} open task(s) will KEEP RUNNING.`;
66
+ const openTasks = preview.openTaskCount;
67
+ const fate = `The preview found ${openTasks} open task(s) in your account and this Duty's workspace. ` +
68
+ 'Other related work is not covered. Deleting the Duty will not automatically stop tasks.';
66
69
  const verb = mustPauseFirst ? 'Pause and delete' : 'Delete';
67
70
  let confirmed;
68
71
  try {
@@ -93,7 +96,7 @@ class DutiesDelete extends base_command_1.BaseCommand {
93
96
  let result;
94
97
  try {
95
98
  result = await duties_1.dutyApi.remove(args.id, flags.reason, {
96
- stopOpenWork: flags['stop-open-work'],
99
+ stopOpenWork: false,
97
100
  });
98
101
  }
99
102
  catch (err) {
@@ -111,11 +114,11 @@ class DutiesDelete extends base_command_1.BaseCommand {
111
114
  // Lead with what still ACTS. What remains readable is reassurance; what
112
115
  // remains running is the fact the reader needs.
113
116
  if (work.openTasksStopped)
114
- this.log(` ${work.openTasksStopped} open task(s) cancelled.`);
117
+ this.log(` ${work.openTasksStopped} open task(s) in your scope cancelled.`);
115
118
  if (work.openTasksLeftRunning) {
116
- this.log(` ${work.openTasksLeftRunning} open task(s) are STILL RUNNING.`);
119
+ this.log(` ${work.openTasksLeftRunning} open task(s) in your scope were not cancelled.`);
117
120
  }
118
- this.log(' Its checks, runs and cases remain readable.');
121
+ this.log(' The work preview covered only your account and this Duty’s workspace; other related work may remain.');
119
122
  this.log(` Restore it with: skrr duties restore ${String(duty.id ?? args.id)}`);
120
123
  }
121
124
  }
@@ -2,7 +2,8 @@ import { BaseCommand } from '../../base-command';
2
2
  export declare function doctorVerdict(input: {
3
3
  duty?: Record<string, unknown>;
4
4
  preflight?: Record<string, unknown>;
5
- operatingState?: Record<string, unknown>;
5
+ operatingState?: Record<string, unknown> | null;
6
+ historyUnavailable?: boolean;
6
7
  }): {
7
8
  verdict: string;
8
9
  next: string;
@@ -10,6 +10,14 @@ const DOCTOR_VERDICT_RE = /^status_([a-z_]+)$/;
10
10
  function doctorVerdict(input) {
11
11
  const duty = input.duty || {};
12
12
  const preflight = input.preflight || {};
13
+ // An unavailable history cannot substantiate the stored Duty assessment.
14
+ // Do not let a previously healthy assessment masquerade as current evidence.
15
+ if (input.historyUnavailable === true || input.operatingState === null) {
16
+ return {
17
+ verdict: 'unknown',
18
+ next: 'Duty history cannot be attributed to this Duty, so its operating health is unavailable',
19
+ };
20
+ }
13
21
  const operatingState = input.operatingState || {};
14
22
  const blocker = operatingState.firstActionableBlocker;
15
23
  if (blocker?.code) {
@@ -115,13 +123,19 @@ class DutiesDoctor extends base_command_1.BaseCommand {
115
123
  this.handleApiError(error);
116
124
  return;
117
125
  }
118
- const operatingState = (shown.operatingState || {});
119
- const diagnosis = doctorVerdict({ duty, operatingState });
126
+ const sourceOperatingState = shown.operatingState;
127
+ const operatingState = sourceOperatingState || {};
128
+ const diagnosis = doctorVerdict({
129
+ duty,
130
+ operatingState: sourceOperatingState,
131
+ historyUnavailable: shown.historyUnavailable === true,
132
+ });
120
133
  const report = {
121
134
  ...diagnosis,
122
135
  duty,
123
136
  abilities: shown.abilities,
124
- operatingState,
137
+ operatingState: sourceOperatingState,
138
+ historyUnavailable: shown.historyUnavailable,
125
139
  observedAt: new Date().toISOString(),
126
140
  };
127
141
  if (!flags.json && operatingState.knowledge) {
@@ -3,6 +3,7 @@ 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
+ const duty_goal_propagation_1 = require("../../../lib/duty-goal-propagation");
6
7
  /**
7
8
  * `skrr duties goals link <duty-id> <goal-id>`
8
9
  *
@@ -36,6 +37,9 @@ class DutiesGoalsLink extends base_command_1.BaseCommand {
36
37
  return;
37
38
  }
38
39
  this.log(`Linked goal ${args.goalId} → duty ${args.dutyId}.`);
40
+ const notice = (0, duty_goal_propagation_1.dutyGoalPropagationNotice)(result, 'link');
41
+ if (notice)
42
+ this.log(notice);
39
43
  }
40
44
  }
41
45
  exports.default = DutiesGoalsLink;
@@ -3,6 +3,7 @@ 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
+ const duty_goal_propagation_1 = require("../../../lib/duty-goal-propagation");
6
7
  /**
7
8
  * `skrr duties goals unlink <duty-id> <goal-id>`
8
9
  *
@@ -32,6 +33,9 @@ class DutiesGoalsUnlink extends base_command_1.BaseCommand {
32
33
  return;
33
34
  }
34
35
  this.log(`Unlinked goal ${args.goalId} from duty ${args.dutyId}.`);
36
+ const notice = (0, duty_goal_propagation_1.dutyGoalPropagationNotice)(result, 'unlink');
37
+ if (notice)
38
+ this.log(notice);
35
39
  }
36
40
  }
37
41
  exports.default = DutiesGoalsUnlink;
@@ -28,9 +28,14 @@ class DutiesLineage extends base_command_1.BaseCommand {
28
28
  const { args, flags } = await this.parse(DutiesLineage);
29
29
  let lineage;
30
30
  try {
31
- lineage = await duties_1.dutyApi.workLineage(args.dutyId, flags.limit);
31
+ lineage = (0, duties_1.safeDutyLineage)(await duties_1.dutyApi.workLineage(args.dutyId, flags.limit), args.dutyId);
32
32
  }
33
33
  catch (err) {
34
+ if ((0, duties_1.isDutyLineageUnavailable)(err)) {
35
+ this.error('Work lineage is unavailable because historical source identity cannot be verified.', {
36
+ code: 'DUTY_WORK_LINEAGE_SOURCE_UNVERIFIED',
37
+ });
38
+ }
34
39
  this.handleApiError(err);
35
40
  }
36
41
  if (flags.json) {
@@ -25,6 +25,12 @@ class DutiesLinksList extends base_command_1.BaseCommand {
25
25
  catch (error) {
26
26
  this.handleApiError(error);
27
27
  }
28
+ const sourcePolicy = result?.sourcePolicy;
29
+ if (sourcePolicy?.status !== 'supported') {
30
+ this.error('Linked work is unavailable while source access cannot be verified.', {
31
+ code: 'DUTY_WORK_LINK_SOURCE_UNVERIFIED',
32
+ });
33
+ }
28
34
  if (flags.json) {
29
35
  this.printJsonResult((0, list_output_1.listResult)(result));
30
36
  return;
@@ -3,6 +3,7 @@ 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
+ const duty_history_source_1 = require("../../lib/duty-history-source");
6
7
  /**
7
8
  * `skrr duties metrics <id>` — per-day rollups of the control loop.
8
9
  *
@@ -39,6 +40,15 @@ class DutiesMetrics extends base_command_1.BaseCommand {
39
40
  catch (err) {
40
41
  this.handleApiError(err);
41
42
  }
43
+ // Older servers can return rows selected by the logical Duty ID alone.
44
+ // Those rows cannot be attributed to the currently authorized physical
45
+ // Duty after a same-ID recreation. Require an explicit source policy even
46
+ // during a mixed-version rollout, before rendering either text or JSON.
47
+ if (!(0, duty_history_source_1.hasVerifiedDutyHistorySource)(response)) {
48
+ this.error('Duty metric history is unavailable because its source identity cannot be verified.', {
49
+ exit: 1,
50
+ });
51
+ }
42
52
  if (flags.json) {
43
53
  this.log(JSON.stringify(response, null, 2));
44
54
  return;
@@ -7,6 +7,14 @@ const data_provider_1 = require("@skrr-ai/data-provider");
7
7
  const base_command_1 = require("../../base-command");
8
8
  const duties_1 = require("../../lib/duties");
9
9
  const TIMESTAMP_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/;
10
+ /** Legacy responses cannot prove that historical observations belong to this
11
+ * physical Duty. Never print rows or aggregate values without a source policy. */
12
+ function hasVerifiedSource(value) {
13
+ if (!value || typeof value !== 'object')
14
+ return false;
15
+ const policy = value.sourcePolicy;
16
+ return policy?.status === 'supported' || policy?.status === 'partial';
17
+ }
10
18
  /** Explicit ISO FROM/TO intervals avoid local-time or rolling-window ambiguity. */
11
19
  function parseObservationWindow(value) {
12
20
  const parts = value.split('/');
@@ -130,6 +138,8 @@ class DutiesObservations extends base_command_1.BaseCommand {
130
138
  catch (err) {
131
139
  this.handleApiError(err);
132
140
  }
141
+ if (!hasVerifiedSource(response))
142
+ this.error('Duty observation history is unavailable because its source cannot be verified.');
133
143
  if (flags.json)
134
144
  this.printJsonResult(response);
135
145
  else
@@ -151,6 +161,8 @@ class DutiesObservations extends base_command_1.BaseCommand {
151
161
  catch (err) {
152
162
  this.handleApiError(err);
153
163
  }
164
+ if (!hasVerifiedSource(response))
165
+ this.error('Duty observation history is unavailable because its source cannot be verified.');
154
166
  if (flags.json) {
155
167
  // One JSON document and nothing else: has_more / next_cursor are in it
156
168
  // (OSK-21118).
@@ -1,33 +1,8 @@
1
- import type { DutyLoopStatus } from '@skrr-ai/data-provider';
2
1
  import { BaseCommand } from '../../base-command';
3
- type SystemDutyRow = {
4
- id?: string;
5
- systemRole?: string;
6
- status?: string;
7
- lastCheckedAt?: string;
8
- lastMaterialChangeAt?: string;
9
- lastUserNudgedAt?: string;
10
- maxUserNudgesPerDay?: number;
11
- };
12
- /**
13
- * What "no open questions" means, said only as far as it is true. "It has not told you anything is
14
- * missing" read as reassurance under an Always-On-OFF header and loops that had never checked
15
- * (OSK-15438): an Agent that cannot run cannot have asked.
16
- */
17
- export declare function noQuestionsSentence(alwaysOn: boolean, roles: SystemDutyRow[]): string;
18
- /**
19
- * What the roster said about this Agent's loops, or why it could not be read. The review's own rows
20
- * carry only the stored lifecycle status; whether a loop is armed, when it next wakes, why it last
21
- * stopped and whether it can read its sources come from the roster (OSK-15438, OSK-15412).
22
- */
23
- export type OperatingReviewLoops = {
24
- rows: Map<string, DutyLoopStatus>;
25
- truncated: boolean;
26
- } | {
27
- error: string;
28
- };
29
- /** The review as text. Pure, so the whole output can be pinned. */
30
- export declare function formatOperatingReview(review: Record<string, unknown>, loops: OperatingReviewLoops): string[];
2
+ /** Old servers cannot prove historical Duties belong to this physical Agent. */
3
+ export declare function sanitizeOperatingReview(review: Record<string, unknown>): Record<string, unknown>;
4
+ /** Report unavailable rather than implying that there were no Duties or questions. */
5
+ export declare function formatOperatingReview(review: Record<string, unknown>): string[];
31
6
  export default class DutiesOperatingReview extends BaseCommand {
32
7
  static description: string;
33
8
  static args: {
@@ -38,4 +13,3 @@ export default class DutiesOperatingReview extends BaseCommand {
38
13
  };
39
14
  run(): Promise<void>;
40
15
  }
41
- export {};
@@ -1,119 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.noQuestionsSentence = noQuestionsSentence;
3
+ exports.sanitizeOperatingReview = sanitizeOperatingReview;
4
4
  exports.formatOperatingReview = formatOperatingReview;
5
5
  const core_1 = require("@oclif/core");
6
6
  const base_command_1 = require("../../base-command");
7
- const duty_loop_status_1 = require("../../lib/duty-loop-status");
8
7
  const duties_1 = require("../../lib/duties");
9
- const RUN_RE = /^obj_/;
10
- /** What each silent loop is for, in the owner's terms rather than the role key. */
11
- const ROLE_PURPOSE = {
12
- conversation_continuity: 'remembers what we are working on',
13
- relationship_pulse: 'asks when your priorities change',
14
- duty_incubator: 'proposes work worth committing to',
15
- open_loop_closer: 'chases promises to an outcome',
16
- agent_reflection: 'reviews its own effectiveness',
17
- };
18
- function ago(value) {
19
- if (!value)
20
- return 'never';
21
- const then = new Date(value).getTime();
22
- if (Number.isNaN(then))
23
- return 'never';
24
- const mins = Math.max(0, Math.round((Date.now() - then) / 60000));
25
- if (mins < 60)
26
- return `${mins}m ago`;
27
- if (mins < 60 * 24)
28
- return `${Math.round(mins / 60)}h ago`;
29
- return `${Math.round(mins / (60 * 24))}d ago`;
8
+ const DUTY_RE = /^obj_/;
9
+ /** Old servers cannot prove historical Duties belong to this physical Agent. */
10
+ function sanitizeOperatingReview(review) {
11
+ return {
12
+ ...review,
13
+ reflectionDuty: null,
14
+ systemDuties: null,
15
+ portfolio: null,
16
+ proposals: null,
17
+ metrics: null,
18
+ openQuestions: null,
19
+ historySourcePolicy: { status: 'unsupported', reason: 'source_unverified' },
20
+ dutySourcePolicy: { status: 'unsupported', reason: 'source_unverified' },
21
+ };
30
22
  }
31
- /**
32
- * What "no open questions" means, said only as far as it is true. "It has not told you anything is
33
- * missing" read as reassurance under an Always-On-OFF header and loops that had never checked
34
- * (OSK-15438): an Agent that cannot run cannot have asked.
35
- */
36
- function noQuestionsSentence(alwaysOn, roles) {
37
- if (!alwaysOn) {
38
- return 'None recorded. Its background loops are not running (Always-On is off), so it has had no chance to ask.';
39
- }
40
- const checked = roles.some((role) => role.status === 'active' && role.lastCheckedAt);
41
- return checked
42
- ? 'None. It has not told you anything is missing.'
43
- : 'None recorded yet. None of its loops has checked, so this says nothing about whether anything is missing.';
44
- }
45
- /** The review as text. Pure, so the whole output can be pinned. */
46
- function formatOperatingReview(review, loops) {
47
- const lines = [];
48
- const roles = review.systemDuties || [];
49
- const alwaysOn = review.alwaysOn === true;
50
- const questions = review.openQuestions || [];
51
- const portfolio = review.portfolio || {};
52
- const metrics = review.metrics || {};
53
- lines.push(`Agent ${review.agentId}`);
54
- lines.push('');
55
- // A loop's own status says `active`, but a system-managed loop is only
56
- // given a scheduling trigger while the Agent is Always-On. Printing
57
- // `active` beside "last checked never" without saying that read as
58
- // "nothing has happened yet" rather than "this cannot happen", and nothing
59
- // led the owner to the switch that decides it.
60
- if (!alwaysOn) {
61
- lines.push('Always-On is OFF — these loops are provisioned but will not run.');
62
- lines.push(` skrr agents always-on enable ${review.agentId}`);
63
- lines.push('');
64
- }
65
- lines.push('Background loops');
66
- if (roles.length === 0) {
67
- lines.push(' (none provisioned)');
68
- }
69
- if ('error' in loops) {
70
- // "Cannot see" must not read as "nothing to report": say what is missing and what it hides.
71
- lines.push(` Loop detail unavailable (${loops.error}). The states below are the stored lifecycle only; ` +
72
- 'they do not say whether a loop is armed, what it can read, or why it last stopped.');
73
- }
74
- for (const role of roles) {
75
- const key = role.systemRole || '?';
76
- const purpose = ROLE_PURPOSE[key] ? ` — ${ROLE_PURPOSE[key]}` : '';
77
- const contact = role.maxUserNudgesPerDay && role.maxUserNudgesPerDay > 0
78
- ? `may contact you ${role.maxUserNudgesPerDay}/day`
79
- : 'never contacts you';
80
- // `idle` replaces `active` only. A paused loop is paused for its own
81
- // reason — Relationship Pulse ships paused as a separate consent
82
- // decision — and collapsing that into `idle` would hide a distinction
83
- // the owner needs when they do turn Always-On on.
84
- const state = !alwaysOn && role.status === 'active' ? 'idle' : role.status || '?';
85
- lines.push(` ${state.padEnd(7)} ${key}${purpose}`);
86
- lines.push(` last checked ${ago(role.lastCheckedAt)} · ${contact}`);
87
- if ('rows' in loops) {
88
- const row = role.id ? loops.rows.get(role.id) : undefined;
89
- if (row) {
90
- for (const line of (0, duty_loop_status_1.formatLoopSummary)(row))
91
- lines.push(` ${line}`);
92
- }
93
- else {
94
- lines.push(` loop detail: not in the roster read${loops.truncated ? ' (the roster is bounded and this Agent holds more)' : ''}; run \`skrr duties status ${role.id ?? '<id>'}\``);
95
- }
96
- }
97
- }
98
- lines.push('');
99
- lines.push(`Open questions from this agent (${questions.length})`);
100
- if (questions.length === 0) {
101
- lines.push(` ${noQuestionsSentence(alwaysOn, roles)}`);
102
- }
103
- for (const q of questions) {
104
- lines.push(` • ${q.question}`);
105
- if (q.whyItMatters)
106
- lines.push(` why: ${q.whyItMatters}`);
107
- lines.push(` asked ${ago(q.askedAt)}`);
108
- }
109
- lines.push('');
110
- const drafts = portfolio.draftDutyCount ?? 0;
111
- lines.push(`Business duties: ${portfolio.activeDutyCount ?? 0} active, ${portfolio.pausedDutyCount ?? 0} paused${drafts > 0 ? `, ${drafts} draft` : ''}`);
112
- if (typeof metrics.awaitingApproval === 'number') {
113
- lines.push(`Proposals awaiting your approval: ${metrics.awaitingApproval}`);
114
- }
115
- lines.push(`Every duty it holds, loop by loop: skrr duties roster --agent ${review.agentId}`);
116
- return lines;
23
+ /** Report unavailable rather than implying that there were no Duties or questions. */
24
+ function formatOperatingReview(review) {
25
+ return [
26
+ `Agent ${review.agentId}`,
27
+ `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
+ ];
117
30
  }
118
31
  class DutiesOperatingReview extends base_command_1.BaseCommand {
119
32
  static description = 'Read an agent’s system-managed duty operating review';
@@ -124,50 +37,24 @@ class DutiesOperatingReview extends base_command_1.BaseCommand {
124
37
  async run() {
125
38
  this.requireAuth();
126
39
  const { args, flags } = await this.parse(DutiesOperatingReview);
127
- // A Duty id here answered "Agent not found" without saying an Agent id was wanted.
128
- if (RUN_RE.test(args.agentId)) {
40
+ if (DUTY_RE.test(args.agentId)) {
129
41
  this.error(`${args.agentId} is a Duty id; operating-review takes an Agent id. ` +
130
42
  `Use \`skrr duties status ${args.agentId}\` for one Duty.`, { exit: 1 });
131
43
  }
132
44
  let result;
133
45
  try {
134
- result = await duties_1.dutyApi.operatingReview(args.agentId);
46
+ result = sanitizeOperatingReview(await duties_1.dutyApi.operatingReview(args.agentId));
135
47
  }
136
48
  catch (error) {
137
49
  this.handleApiError(error);
138
50
  }
139
- // The roster is a second read; its failure must not take the review down with it, and must not
140
- // pass for "nothing to report" either.
141
- let loops;
142
- try {
143
- const roster = await duties_1.dutyApi.roster(args.agentId);
144
- loops = {
145
- rows: new Map((Array.isArray(roster.duties) ? roster.duties : []).map((row) => [
146
- row.dutyId,
147
- row,
148
- ])),
149
- truncated: roster.truncated === true,
150
- };
151
- }
152
- catch (error) {
153
- loops = { error: error instanceof Error ? error.message : String(error) };
154
- }
51
+ // Roster is also keyed by a logical Agent id, so do not fetch and present
52
+ // its Duty history until that relationship has physical identity proof.
155
53
  if (flags.json) {
156
- const review = result;
157
- const roles = review.systemDuties || [];
158
- this.log(JSON.stringify('error' in loops
159
- ? { ...review, loopStatusError: loops.error }
160
- : {
161
- ...review,
162
- loopStatus: roles
163
- .map((role) => (role.id ? loops.rows.get(role.id) : undefined))
164
- .filter((row) => row !== undefined),
165
- }, null, 2));
54
+ this.log(JSON.stringify(result, null, 2));
166
55
  return;
167
56
  }
168
- // Without this the command printed raw JSON in both modes, which is why the
169
- // meta loops read as machinery rather than as something an owner supervises.
170
- for (const line of formatOperatingReview(result, loops))
57
+ for (const line of formatOperatingReview(result))
171
58
  this.log(line);
172
59
  }
173
60
  }
@@ -5,6 +5,7 @@ const core_1 = require("@oclif/core");
5
5
  const base_command_1 = require("../../base-command");
6
6
  const duties_1 = require("../../lib/duties");
7
7
  const duty_product_1 = require("../../lib/duty-product");
8
+ const duty_receipt_source_1 = require("../../lib/duty-receipt-source");
8
9
  /**
9
10
  * The quarter to report when the caller names none.
10
11
  *
@@ -66,11 +67,17 @@ class DutiesReceiptMetrics extends base_command_1.BaseCommand {
66
67
  const quarter = flags.quarter ?? fallback.quarter;
67
68
  try {
68
69
  const response = await duties_1.dutyApi.receiptQuarterlyMetrics(args.id, year, quarter);
70
+ if (!(0, duty_receipt_source_1.hasVerifiedReceiptSource)(response)) {
71
+ this.error(duty_receipt_source_1.RECEIPT_UNAVAILABLE_MESSAGE, { code: duty_receipt_source_1.RECEIPT_SOURCE_UNVERIFIED });
72
+ }
69
73
  if (flags.json)
70
74
  return this.log(JSON.stringify(response, null, 2));
71
75
  (0, duty_product_1.renderExecutionReceiptQuarterlyMetrics)(response, (line) => this.log(line), flags.verbose);
72
76
  }
73
77
  catch (error) {
78
+ if ((0, duty_receipt_source_1.isReceiptSourceUnverified)(error)) {
79
+ this.error(duty_receipt_source_1.RECEIPT_UNAVAILABLE_MESSAGE, { code: duty_receipt_source_1.RECEIPT_SOURCE_UNVERIFIED });
80
+ }
74
81
  this.handleApiError(error);
75
82
  }
76
83
  }
@@ -4,6 +4,7 @@ const core_1 = require("@oclif/core");
4
4
  const base_command_1 = require("../../base-command");
5
5
  const duties_1 = require("../../lib/duties");
6
6
  const duty_product_1 = require("../../lib/duty-product");
7
+ const duty_receipt_source_1 = require("../../lib/duty-receipt-source");
7
8
  class DutiesReceipt extends base_command_1.BaseCommand {
8
9
  static description = 'Explain what happened from the event through work, delivery, and verification';
9
10
  static examples = [
@@ -33,6 +34,9 @@ class DutiesReceipt extends base_command_1.BaseCommand {
33
34
  checkId: flags.check,
34
35
  runId: flags.run,
35
36
  });
37
+ if (!(0, duty_receipt_source_1.hasVerifiedReceiptSource)(result)) {
38
+ this.error(duty_receipt_source_1.RECEIPT_UNAVAILABLE_MESSAGE, { code: duty_receipt_source_1.RECEIPT_SOURCE_UNVERIFIED });
39
+ }
36
40
  if (flags.json)
37
41
  return this.log(JSON.stringify(result, null, 2));
38
42
  if (!result.receipts.length)
@@ -41,6 +45,9 @@ class DutiesReceipt extends base_command_1.BaseCommand {
41
45
  (0, duty_product_1.renderExecutionReceipt)(receipt, (line) => this.log(line), flags.verbose);
42
46
  }
43
47
  catch (error) {
48
+ if ((0, duty_receipt_source_1.isReceiptSourceUnverified)(error)) {
49
+ this.error(duty_receipt_source_1.RECEIPT_UNAVAILABLE_MESSAGE, { code: duty_receipt_source_1.RECEIPT_SOURCE_UNVERIFIED });
50
+ }
44
51
  this.handleApiError(error);
45
52
  }
46
53
  }
@@ -3,7 +3,6 @@ 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
- const duty_loop_status_1 = require("../../lib/duty-loop-status");
7
6
  /**
8
7
  * Every Duty one agent holds — system roles included — with whether its
9
8
  * loop is actually installed and working: what it watches, when it next wakes,
@@ -23,17 +22,24 @@ class DutiesRoster extends base_command_1.BaseCommand {
23
22
  this.requireAuth();
24
23
  const { flags } = await this.parse(DutiesRoster);
25
24
  try {
26
- const roster = await duties_1.dutyApi.roster(flags.agent);
27
- if (flags.json) {
28
- this.log(JSON.stringify(roster, null, 2));
29
- return;
30
- }
31
- for (const line of (0, duty_loop_status_1.formatDutyRoster)(roster))
32
- this.log(line);
25
+ // A successful old-server response can include history joined by
26
+ // logical ID. Do not expose those rows, including in --json.
27
+ await duties_1.dutyApi.roster(flags.agent);
33
28
  }
34
29
  catch (err) {
30
+ const code = err
31
+ ?.response?.data;
32
+ if (code?.error === 'DUTY_ROSTER_SOURCE_UNVERIFIED' ||
33
+ code?.code === 'DUTY_ROSTER_SOURCE_UNVERIFIED') {
34
+ this.error('Duty roster is unavailable because its historical source identity cannot be verified.', {
35
+ code: 'DUTY_ROSTER_SOURCE_UNVERIFIED',
36
+ });
37
+ }
35
38
  this.handleApiError(err);
36
39
  }
40
+ this.error('Duty roster is unavailable because its historical source identity cannot be verified.', {
41
+ code: 'DUTY_ROSTER_SOURCE_UNVERIFIED',
42
+ });
37
43
  }
38
44
  }
39
45
  exports.default = DutiesRoster;