@skrr-ai/cli 0.1.164 → 0.1.166

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 (111) hide show
  1. package/README.md +13 -0
  2. package/dist/base-command.d.ts +14 -1
  3. package/dist/base-command.js +166 -46
  4. package/dist/commands/agent/message/send.d.ts +1 -0
  5. package/dist/commands/agent/message/send.js +3 -0
  6. package/dist/commands/agents/mini-computer/app/set.js +1 -1
  7. package/dist/commands/agents/mini-computer/tasks-view.js +1 -1
  8. package/dist/commands/apps/check.js +3 -8
  9. package/dist/commands/apps/data/batch.d.ts +1 -0
  10. package/dist/commands/apps/data/batch.js +19 -2
  11. package/dist/commands/apps/data/delete.d.ts +1 -0
  12. package/dist/commands/apps/data/delete.js +14 -2
  13. package/dist/commands/apps/data/patch.d.ts +1 -0
  14. package/dist/commands/apps/data/patch.js +11 -2
  15. package/dist/commands/apps/data/put.d.ts +1 -0
  16. package/dist/commands/apps/data/put.js +17 -3
  17. package/dist/commands/apps/install.js +7 -2
  18. package/dist/commands/apps/installations/compatibility.d.ts +13 -0
  19. package/dist/commands/apps/installations/compatibility.js +60 -0
  20. package/dist/commands/apps/installations/migrate/abort.d.ts +13 -0
  21. package/dist/commands/apps/installations/migrate/abort.js +45 -0
  22. package/dist/commands/apps/installations/migrate/cutover.d.ts +15 -0
  23. package/dist/commands/apps/installations/migrate/cutover.js +102 -0
  24. package/dist/commands/apps/installations/migrate/plan.d.ts +13 -0
  25. package/dist/commands/apps/installations/migrate/plan.js +51 -0
  26. package/dist/commands/apps/installations/migrate/rollback.d.ts +16 -0
  27. package/dist/commands/apps/installations/migrate/rollback.js +103 -0
  28. package/dist/commands/apps/installations/migrate/stage.d.ts +15 -0
  29. package/dist/commands/apps/installations/migrate/stage.js +96 -0
  30. package/dist/commands/apps/installations/migrate/status.d.ts +12 -0
  31. package/dist/commands/apps/installations/migrate/status.js +52 -0
  32. package/dist/commands/apps/installations/migrate/validate.d.ts +14 -0
  33. package/dist/commands/apps/installations/migrate/validate.js +58 -0
  34. package/dist/commands/apps/installations/show.js +14 -9
  35. package/dist/commands/apps/installations/snapshot.js +5 -2
  36. package/dist/commands/apps/operations/check.d.ts +16 -0
  37. package/dist/commands/apps/operations/check.js +127 -0
  38. package/dist/commands/apps/publish/propose.js +33 -4
  39. package/dist/commands/apps/reconsent.js +7 -1
  40. package/dist/commands/apps/reference.d.ts +4 -2
  41. package/dist/commands/apps/reference.js +7 -4
  42. package/dist/commands/apps/resume.js +1 -1
  43. package/dist/commands/apps/rollback.d.ts +9 -0
  44. package/dist/commands/apps/rollback.js +81 -2
  45. package/dist/commands/apps/settings/set.js +22 -10
  46. package/dist/commands/apps/upgrade.d.ts +8 -0
  47. package/dist/commands/apps/upgrade.js +67 -2
  48. package/dist/commands/apps/version/cat.d.ts +22 -0
  49. package/dist/commands/apps/version/cat.js +220 -0
  50. package/dist/commands/apps/version/show.js +3 -1
  51. package/dist/commands/commerce/incidents/release.d.ts +24 -0
  52. package/dist/commands/commerce/incidents/release.js +46 -0
  53. package/dist/commands/duties/cases.js +12 -1
  54. package/dist/commands/duties/hypotheses.js +10 -3
  55. package/dist/commands/duties/observations.d.ts +4 -0
  56. package/dist/commands/duties/observations.js +14 -3
  57. package/dist/commands/outbox/list.d.ts +11 -4
  58. package/dist/commands/outbox/list.js +56 -9
  59. package/dist/commands/outbox/retry.d.ts +8 -2
  60. package/dist/commands/outbox/retry.js +76 -16
  61. package/dist/commands/outbox/show.d.ts +20 -0
  62. package/dist/commands/outbox/show.js +83 -0
  63. package/dist/commands/proposals/list.js +13 -9
  64. package/dist/commands/requests/show.d.ts +12 -0
  65. package/dist/commands/requests/show.js +42 -23
  66. package/dist/commands/spaces/deletion/cancel.d.ts +21 -0
  67. package/dist/commands/spaces/deletion/cancel.js +70 -0
  68. package/dist/commands/spaces/workflows/run.js +12 -0
  69. package/dist/commands/widgets/check.d.ts +9 -0
  70. package/dist/commands/widgets/check.js +16 -3
  71. package/dist/generated/agent-guides.json +17 -17
  72. package/dist/lib/api-fetch.d.ts +5 -0
  73. package/dist/lib/api-fetch.js +81 -22
  74. package/dist/lib/appCompatibility.d.ts +31 -0
  75. package/dist/lib/appCompatibility.js +66 -0
  76. package/dist/lib/appData.d.ts +46 -4
  77. package/dist/lib/appData.js +161 -32
  78. package/dist/lib/appDataMigration.d.ts +204 -0
  79. package/dist/lib/appDataMigration.js +753 -0
  80. package/dist/lib/appDataMigrationCommand.d.ts +39 -0
  81. package/dist/lib/appDataMigrationCommand.js +90 -0
  82. package/dist/lib/appInstallations.d.ts +40 -5
  83. package/dist/lib/appInstallations.js +251 -35
  84. package/dist/lib/appVersionFile.d.ts +82 -0
  85. package/dist/lib/appVersionFile.js +195 -0
  86. package/dist/lib/apps-command.d.ts +14 -3
  87. package/dist/lib/apps-command.js +80 -65
  88. package/dist/lib/appsCheck.js +16 -2
  89. package/dist/lib/commerce.d.ts +6 -0
  90. package/dist/lib/commerce.js +9 -0
  91. package/dist/lib/duties.d.ts +15 -1
  92. package/dist/lib/duties.js +21 -3
  93. package/dist/lib/json-output.d.ts +2 -0
  94. package/dist/lib/json-output.js +8 -4
  95. package/dist/lib/node-adapter.js +69 -38
  96. package/dist/lib/outbox.d.ts +110 -1
  97. package/dist/lib/outbox.js +261 -35
  98. package/dist/lib/rate-limit-retry.d.ts +4 -5
  99. package/dist/lib/rate-limit-retry.js +6 -10
  100. package/dist/lib/refresh.d.ts +2 -0
  101. package/dist/lib/refresh.js +6 -0
  102. package/dist/lib/space-deletion-cancel.d.ts +47 -0
  103. package/dist/lib/space-deletion-cancel.js +141 -0
  104. package/dist/lib/widgetCheck.js +1 -1
  105. package/dist/lib/widgetStaticScan.d.ts +11 -5
  106. package/dist/lib/widgetStaticScan.js +73 -165
  107. package/dist/lib/write-outcome.d.ts +76 -0
  108. package/dist/lib/write-outcome.js +190 -0
  109. package/dist/node_modules/@skrr-ai/data-provider/index.js +11955 -11231
  110. package/oclif.manifest.json +3019 -499
  111. package/package.json +12 -3
@@ -1,8 +1,46 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.describeRequestWorkspace = describeRequestWorkspace;
4
+ exports.requestDisplayLines = requestDisplayLines;
3
5
  const core_1 = require("@oclif/core");
4
6
  const data_provider_1 = require("@skrr-ai/data-provider");
5
7
  const base_command_1 = require("../../base-command");
8
+ const APP_PUBLISH_NOTICE = 'An approved request alone does not prove the app was published. Check the version distribution.';
9
+ /**
10
+ * The workspace of a request, in a word. A request filed without a workspace stores no `workspaceId` at all
11
+ * (`createRequest` writes the field only when there is one), so it comes back with the key ABSENT, not `null`: both mean
12
+ * it belongs to no workspace, and neither is "not reported" (OSK-23683: an `app_publish` proposal printed that, which
13
+ * left its owner to guess whether the server had said nothing or the request was unscoped).
14
+ */
15
+ function describeRequestWorkspace(workspaceId) {
16
+ return workspaceId === null || workspaceId === undefined ? 'unscoped' : String(workspaceId);
17
+ }
18
+ /**
19
+ * The lines `requests show` prints for a request, in order. A function of the request alone, so what a person reads is
20
+ * what a spec reads.
21
+ */
22
+ function requestDisplayLines(r) {
23
+ const lines = [
24
+ `ID: ${r.id ?? r._id ?? '-'}`,
25
+ `Title: ${r.title ?? '-'}`,
26
+ `Type: ${r.type ?? '-'}`,
27
+ `Status: ${r.status ?? '-'}`,
28
+ ];
29
+ if (r.type === 'app_publish') {
30
+ lines.push(`Publication: ${APP_PUBLISH_NOTICE}`, `Workspace: ${describeRequestWorkspace(r.workspaceId)}`);
31
+ }
32
+ lines.push(`Priority: ${r.priority ?? '-'}`, `Author: ${r.author ?? '-'}`, `Requester: ${r.requesterName ?? r.requesterUserId ?? '-'}`, `Target: ${r.targetName ?? r.targetUserId ?? '-'}`, `Created: ${r.createdAt ?? '-'}`);
33
+ if (r.resolvedAt) {
34
+ lines.push(`Resolved at: ${r.resolvedAt}`);
35
+ }
36
+ if (r.resolutionComment) {
37
+ lines.push('', 'Resolution comment:', ` ${r.resolutionComment}`);
38
+ }
39
+ if (r.description) {
40
+ lines.push('', 'Description:', ` ${r.description}`);
41
+ }
42
+ return lines;
43
+ }
6
44
  class RequestsShow extends base_command_1.BaseCommand {
7
45
  static description = 'Show details for a single request';
8
46
  static examples = [
@@ -25,32 +63,13 @@ class RequestsShow extends base_command_1.BaseCommand {
25
63
  catch (err) {
26
64
  this.handleApiError(err);
27
65
  }
66
+ const r = result;
28
67
  if (flags.json) {
29
- this.log(JSON.stringify(result, null, 2));
68
+ this.log(JSON.stringify(r, null, 2));
30
69
  return;
31
70
  }
32
- const r = result;
33
- this.log(`ID: ${r.id ?? r._id ?? '-'}`);
34
- this.log(`Title: ${r.title ?? '-'}`);
35
- this.log(`Type: ${r.type ?? '-'}`);
36
- this.log(`Status: ${r.status ?? '-'}`);
37
- this.log(`Priority: ${r.priority ?? '-'}`);
38
- this.log(`Author: ${r.author ?? '-'}`);
39
- this.log(`Requester: ${r.requesterName ?? r.requesterUserId ?? '-'}`);
40
- this.log(`Target: ${r.targetName ?? r.targetUserId ?? '-'}`);
41
- this.log(`Created: ${r.createdAt ?? '-'}`);
42
- if (r.resolvedAt) {
43
- this.log(`Resolved at: ${r.resolvedAt}`);
44
- }
45
- if (r.resolutionComment) {
46
- this.log('');
47
- this.log('Resolution comment:');
48
- this.log(` ${r.resolutionComment}`);
49
- }
50
- if (r.description) {
51
- this.log('');
52
- this.log('Description:');
53
- this.log(` ${r.description}`);
71
+ for (const line of requestDisplayLines(r)) {
72
+ this.log(line);
54
73
  }
55
74
  }
56
75
  }
@@ -0,0 +1,21 @@
1
+ import { BaseCommand } from '../../../base-command';
2
+ /**
3
+ * `skrr spaces deletion cancel <space>` (OSK-24060): abandon a Space deletion that is waiting to
4
+ * finish. The safe direction (it preserves data), so there is no confirmation prompt, and it is
5
+ * idempotent: when nothing is pending it says so and exits 0.
6
+ *
7
+ * Signed-in person only. The route refuses a personal access token on purpose, so an automation
8
+ * token cannot undo a deletion a person ordered; the CLI's own credential after `skrr login` is
9
+ * accepted. Words for each answer: `lib/space-deletion-cancel.ts`.
10
+ */
11
+ export default class SpacesDeletionCancel extends BaseCommand {
12
+ static description: string;
13
+ static examples: string[];
14
+ static args: {
15
+ id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
16
+ };
17
+ static flags: {
18
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
19
+ };
20
+ run(): Promise<void>;
21
+ }
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const data_provider_1 = require("@skrr-ai/data-provider");
5
+ const base_command_1 = require("../../../base-command");
6
+ const space_deletion_cancel_1 = require("../../../lib/space-deletion-cancel");
7
+ /**
8
+ * `skrr spaces deletion cancel <space>` (OSK-24060): abandon a Space deletion that is waiting to
9
+ * finish. The safe direction (it preserves data), so there is no confirmation prompt, and it is
10
+ * idempotent: when nothing is pending it says so and exits 0.
11
+ *
12
+ * Signed-in person only. The route refuses a personal access token on purpose, so an automation
13
+ * token cannot undo a deletion a person ordered; the CLI's own credential after `skrr login` is
14
+ * accepted. Words for each answer: `lib/space-deletion-cancel.ts`.
15
+ */
16
+ class SpacesDeletionCancel extends base_command_1.BaseCommand {
17
+ static description = 'Cancel a pending Space deletion (needs delete access; a signed-in person, not an access token)';
18
+ static examples = [
19
+ '<%= config.bin %> spaces deletion cancel <space-id>',
20
+ '<%= config.bin %> spaces deletion cancel "Growth lab" --json',
21
+ ];
22
+ static args = {
23
+ id: core_1.Args.string({
24
+ description: 'Space ID, or a title to resolve',
25
+ required: true,
26
+ ignoreStdin: true,
27
+ }),
28
+ };
29
+ static flags = {
30
+ json: core_1.Flags.boolean({ description: 'Output the outcome as JSON' }),
31
+ };
32
+ async run() {
33
+ this.requireAuth();
34
+ const { args, flags } = await this.parse(SpacesDeletionCancel);
35
+ const spaceRef = await this.resolveEntityRef('space', args.id);
36
+ let result;
37
+ try {
38
+ result = await data_provider_1.dataService.cancelSpaceDeletionReservation(spaceRef);
39
+ }
40
+ catch (err) {
41
+ const refusal = (0, space_deletion_cancel_1.describeDeletionCancelRefusal)(err, {
42
+ spaceRef: args.id,
43
+ bin: this.config.bin,
44
+ });
45
+ if (refusal)
46
+ this.failWithCliError(refusal);
47
+ this.handleApiError(err, { subject: `space ${args.id}` });
48
+ }
49
+ const answer = (0, space_deletion_cancel_1.readDeletionCancelAnswer)(result);
50
+ if (!answer) {
51
+ // A 200 that does not say `cancelled` either way. Reporting "cancelled" or "nothing pending"
52
+ // would tell a person their Space is safe (or not) on no evidence.
53
+ this.failWithCliError({
54
+ message: `The server answered, but not in a form this command understands, so it is not known ` +
55
+ `whether the deletion of space ${args.id} was cancelled. ` +
56
+ `→ Check with \`${this.config.bin} spaces show ${args.id}\`, then run this again.`,
57
+ code: 'SPACE_DELETION_CANCEL_UNREADABLE',
58
+ exit: 1,
59
+ retryable: true,
60
+ });
61
+ }
62
+ if (flags.json) {
63
+ this.printJsonResult({ spaceId: spaceRef, ...answer });
64
+ return;
65
+ }
66
+ for (const line of (0, space_deletion_cancel_1.deletionCancelLines)(answer, args.id, this.config.bin))
67
+ this.log(line);
68
+ }
69
+ }
70
+ exports.default = SpacesDeletionCancel;
@@ -106,6 +106,18 @@ class SpacesWorkflowsRun extends base_command_1.BaseCommand {
106
106
  const failureCause = run.failureCause;
107
107
  if (typeof failureCause?.message === 'string')
108
108
  this.log(`Why: ${oneLine(failureCause.message)}`);
109
+ // Hand-offs the engine stopped retrying at the sweep's pace (OSK-24114). Absent means none are stuck.
110
+ const deliveries = run.deliveries;
111
+ if (deliveries?.items?.length) {
112
+ this.log(`Stuck deliveries: ${deliveries.parked} parked, ${deliveries.failed} failed` +
113
+ `${deliveries.truncated ? ' (more than are shown)' : ''}. ` +
114
+ '`--reconcile` puts parked ones back in the loop now; they are also probed again on their own.');
115
+ for (const item of deliveries.items) {
116
+ this.log(` ${item.status} ${item.kind} ${item.id}: ${item.attempts} attempt(s)` +
117
+ `${item.lastErrorCode ? ` [${item.lastErrorCode}]` : ''}` +
118
+ `${item.lastError ? ` ${oneLine(item.lastError)}` : ''}`);
119
+ }
120
+ }
109
121
  // A run is `paused` only when no other branch can make progress. With a paused step and a
110
122
  // successor still pending it stays `running`, which read as though the pause had not taken
111
123
  // (OSK-22459), so say how many steps are paused and why the run is not.
@@ -15,6 +15,13 @@ import { Command } from '@oclif/core';
15
15
  * Exit codes: 0 every widget would be accepted and has no error finding; 1 at
16
16
  * least one would be refused or has an error finding (or none was found); 2 the
17
17
  * input could not be read.
18
+ *
19
+ * Every exit goes through `finish`, which hands what was printed to the operating
20
+ * system first. Being `Command` and not `BaseCommand` it does not get the drain
21
+ * `BaseCommand.catch` gives every other command, and oclif turns `this.exit(n)` into
22
+ * `process.exit`, which throws away what a pipe has not yet taken: a report larger
23
+ * than the pipe's buffer reached a piped reader cut off mid-string, under an exit
24
+ * status that read as an ordinary refusal (OSK-22165, the same defect `apps check` fixed).
18
25
  */
19
26
  export declare const WIDGETS_CHECK_EXIT: {
20
27
  readonly ok: 0;
@@ -34,6 +41,8 @@ export default class WidgetsCheck extends Command {
34
41
  'render-fence': import("@oclif/core/interfaces").BooleanFlag<boolean>;
35
42
  };
36
43
  run(): Promise<void>;
44
+ /** Leave with `code`, after everything this command wrote has been handed to the operating system. */
45
+ private finish;
37
46
  private readInput;
38
47
  private emitInputError;
39
48
  }
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.WIDGETS_CHECK_EXIT = void 0;
37
37
  const core_1 = require("@oclif/core");
38
38
  const fs = __importStar(require("node:fs"));
39
+ const drain_stdio_1 = require("../../lib/drain-stdio");
39
40
  const prompt_1 = require("../../lib/prompt");
40
41
  const widgetCheck_1 = require("../../lib/widgetCheck");
41
42
  /**
@@ -54,6 +55,13 @@ const widgetCheck_1 = require("../../lib/widgetCheck");
54
55
  * Exit codes: 0 every widget would be accepted and has no error finding; 1 at
55
56
  * least one would be refused or has an error finding (or none was found); 2 the
56
57
  * input could not be read.
58
+ *
59
+ * Every exit goes through `finish`, which hands what was printed to the operating
60
+ * system first. Being `Command` and not `BaseCommand` it does not get the drain
61
+ * `BaseCommand.catch` gives every other command, and oclif turns `this.exit(n)` into
62
+ * `process.exit`, which throws away what a pipe has not yet taken: a report larger
63
+ * than the pipe's buffer reached a piped reader cut off mid-string, under an exit
64
+ * status that read as an ordinary refusal (OSK-22165, the same defect `apps check` fixed).
57
65
  */
58
66
  exports.WIDGETS_CHECK_EXIT = { ok: 0, notOk: 1, unreadable: 2 };
59
67
  class WidgetsCheck extends core_1.Command {
@@ -94,7 +102,7 @@ class WidgetsCheck extends core_1.Command {
94
102
  const read = await this.readInput(args.file);
95
103
  if (!read.ok) {
96
104
  this.emitInputError(flags.json, read.error);
97
- this.exit(exports.WIDGETS_CHECK_EXIT.unreadable);
105
+ return this.finish(exports.WIDGETS_CHECK_EXIT.unreadable);
98
106
  }
99
107
  const result = (0, widgetCheck_1.checkWidgetInput)(read.text, {
100
108
  format: flags.format,
@@ -120,7 +128,7 @@ class WidgetsCheck extends core_1.Command {
120
128
  }
121
129
  process.stderr.write(`${(0, widgetCheck_1.formatWidgetCheckReport)(report).join('\n')}\n`);
122
130
  }
123
- this.exit(report.ok ? exports.WIDGETS_CHECK_EXIT.ok : exports.WIDGETS_CHECK_EXIT.notOk);
131
+ return this.finish(report.ok ? exports.WIDGETS_CHECK_EXIT.ok : exports.WIDGETS_CHECK_EXIT.notOk);
124
132
  }
125
133
  if (flags.json) {
126
134
  this.log(JSON.stringify(result.report, null, 2));
@@ -128,7 +136,12 @@ class WidgetsCheck extends core_1.Command {
128
136
  else {
129
137
  this.log((0, widgetCheck_1.formatWidgetCheckReport)(result.report).join('\n'));
130
138
  }
131
- this.exit(result.report.ok ? exports.WIDGETS_CHECK_EXIT.ok : exports.WIDGETS_CHECK_EXIT.notOk);
139
+ return this.finish(result.report.ok ? exports.WIDGETS_CHECK_EXIT.ok : exports.WIDGETS_CHECK_EXIT.notOk);
140
+ }
141
+ /** Leave with `code`, after everything this command wrote has been handed to the operating system. */
142
+ async finish(code) {
143
+ await (0, drain_stdio_1.drainStdio)();
144
+ return this.exit(code);
132
145
  }
133
146
  async readInput(source) {
134
147
  try {
@@ -613,7 +613,7 @@
613
613
  "id": "apps",
614
614
  "title": "Agent Apps: build, propose, and what an install grants",
615
615
  "readWhen": "you build or change an Agent App (a mini app the person keeps on their home screen), cut a version of one, or someone wants an app installed, moved or removed",
616
- "tokens": 1185,
616
+ "tokens": 1179,
617
617
  "aliases": [],
618
618
  "explains": []
619
619
  },
@@ -725,7 +725,7 @@
725
725
  ]
726
726
  }
727
727
  ],
728
- "hash": "8308a2aef4d7b30d589f4a25a6ad3e76b2afab2d0f66760a7e03d813ea7e51b3",
728
+ "hash": "61e1dafa5ff4acbacb2c5c34c1c5c0ea91d1b59f640115dafd991a9fcb28a5d3",
729
729
  "tokens": 557
730
730
  },
731
731
  "routedIndex": {
@@ -1342,7 +1342,7 @@
1342
1342
  "id": "apps",
1343
1343
  "title": "Agent Apps: build, propose, and what an install grants",
1344
1344
  "readWhen": "you build or change an Agent App (a mini app the person keeps on their home screen), cut a version of one, or someone wants an app installed, moved or removed",
1345
- "tokens": 1185,
1345
+ "tokens": 1179,
1346
1346
  "aliases": [],
1347
1347
  "explains": []
1348
1348
  },
@@ -1385,7 +1385,7 @@
1385
1385
  ]
1386
1386
  }
1387
1387
  ],
1388
- "hash": "085d4929e44fa7bfa0c778b1fef232eeb5bfba4865cce94a62d072d7ab80fc10",
1388
+ "hash": "123927a76af3e79b179c512bba22d860fa65b9e4560cfa7a04562e45aa08f311",
1389
1389
  "tokens": 506
1390
1390
  },
1391
1391
  "cards": {
@@ -1977,7 +1977,7 @@
1977
1977
  "marketplace"
1978
1978
  ],
1979
1979
  "body": "## Concept model\n\n| Noun | Question it answers |\n| -------------------------------------- | ---------------------------------------------------------------------------------------------------------- |\n| **Release** | Which exact, immutable version is installed, updated to or listed? |\n| **Store copy** | Which Agent did installing a published Agent give the person? It is their own, pinned to a release. |\n| **Skill** | Which instructions can one Agent load? A Store Skill is copied onto that Agent. |\n| **Action** | Which saved button or tool does an Agent carry? Embedded, a marketplace listing of one, or OpenAPI-backed. |\n| **App** | Which installable program runs on an Agent, and what did its install grant? |\n| **Space template / Workflow template** | Which captured Space, or Workflow graph fragment, can be installed again? |\n| **Acquisition request** | Which purchase did an Agent ask to make, and has the buyer approved it? |\n| **Update channel** | Does an installed copy move to new releases on its own? |\n\n## Decide\n\n- Choose a **Skill** when an Agent the person already has needs a capability; choose a **Store copy** only when they want another Agent.\n- Choose an **App** when the person asks for a mini app: a tracker, journal or small tool they keep on their home screen, with data of its own. A chart or calculator shown in the chat is a widget, not an App. You build the App; installing it is theirs.\n- Treat any price above zero, a tip, a refund or a trial as **money**: pay only when the person told you to, naming the exact item and its price, and read the `commerce` section first.\n- Treat making anything public, whether a release, a listing, a price or a profile, as **publishing**: prepare it, then stop and ask.\n- Treat an install that grants something, such as an App or an update with new capabilities, as the person's **consent**: show it, do not give it.\n\n## Workflow\n\n### Install something\n\n1. Read the listing first: price, publisher, what it discloses, and whether it is already there.\n2. Free, asked for, and does what was asked: install it on the Agent the person named. No listing cleanly fits: that is advisory listing/search evidence, not an authorization state or mutation veto. Do not auto-install; name the closest ones and what each lacks, and ask. If the person then explicitly names a free listing, install it under ordinary permissions. A missing, incomplete, stale, unauthorized or unbound runtime-capability observation is inconclusive, never an empty result, and neither permits nor blocks a Skill mutation. Paid: buy it only when the person told you to, naming it and its price. Anything else: stop and ask.\n3. Read the result back and report what landed, on which Agent.\n\n### Get something ready to publish\n\n1. Cut a private release or version. It is not published.\n2. Write down what would go live, where, at what price, and what it discloses.\n3. Ask the person to publish it. Report \"ready for your sign-off\", never \"published\".\n\n## Authority\n\n| Actor | May do | Only a person may do |\n| ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| Agent | Browse, search and read listings; install a free listing it was asked to install; make a purchase or tip the person told it to make, naming the item and its price; build an App and propose publishing it; cut a private release or version | Approve or decline a purchase request; accept terms; ask for a refund; start a trial; install, approve again or remove an App; accept an update's new capabilities; choose an update channel; publish, list, price, delist or roll back; set secrets; erase a copy's memory |\n| Person | Everything an Agent may do | — |\n\nAn instruction counts only when it names both: \"Buy Release Notes Writer for $4\", or their yes to your question \"Buy Release Notes Writer for $4?\". \"Get whatever you need\", \"buy it if it helps\" and your own view that something is worth buying do not: tell them the item and its price, and ask.\n\nThe server cannot always tell an Agent from a person holding the same login, so an accepted call is not permission. The right-hand column stays the person's even when the command would succeed. Where the platform asks the person directly, through an approval card, a confirmation prompt or an interactive sign-in, let them answer it; elsewhere, hand them the exact command.\n\nThe one prompt you may answer is a paid install's confirmation, with `--yes` and `--expected-price` set to the price the person named.\n\n## Live state\n\n- `skrr store installs` and `skrr store updates` — what is installed, and which updates wait.\n- `skrr store acquisitions list --status pending` — purchases waiting for the buyer.\n- `skrr agents skills list <agent-id>` — the skills attached to an Agent.\n- `skrr apps installations list --agent <agent-id>` — the apps on an Agent, and whether each may run.\n- `skrr store governance policy <workspace-id>` — which Store releases a workspace admits.\n\n## Related guides\n\n- `agents` — configure an installed copy: instructions, tools, machine.\n- `spaces` — capture and install Space templates; insert Workflow templates.\n- `learning` — turn what an Agent learned into a Skill.",
1980
- "hash": "103904838a7c35dcd58bc2d707e2b3747e49f2cbfca54b958087224d783666d2",
1980
+ "hash": "baac39ab19fa03a05a6a7613aaa371a9c40d9ab2b0aa0a1fbed4a8baa5dc2f9e",
1981
1981
  "tokens": 1427,
1982
1982
  "sections": [
1983
1983
  {
@@ -2023,7 +2023,7 @@
2023
2023
  "id": "apps",
2024
2024
  "title": "Agent Apps: build, propose, and what an install grants",
2025
2025
  "readWhen": "you build or change an Agent App (a mini app the person keeps on their home screen), cut a version of one, or someone wants an app installed, moved or removed",
2026
- "tokens": 1185,
2026
+ "tokens": 1179,
2027
2027
  "aliases": [],
2028
2028
  "explains": []
2029
2029
  },
@@ -7555,7 +7555,7 @@
7555
7555
  "id": "apps",
7556
7556
  "title": "Agent Apps: build, propose, and what an install grants",
7557
7557
  "readWhen": "you build or change an Agent App (a mini app the person keeps on their home screen), cut a version of one, or someone wants an app installed, moved or removed",
7558
- "tokens": 1185,
7558
+ "tokens": 1179,
7559
7559
  "aliases": [],
7560
7560
  "explains": []
7561
7561
  },
@@ -7659,7 +7659,7 @@
7659
7659
  "id": "apps",
7660
7660
  "title": "Agent Apps: build, propose, and what an install grants",
7661
7661
  "readWhen": "you build or change an Agent App (a mini app the person keeps on their home screen), cut a version of one, or someone wants an app installed, moved or removed",
7662
- "tokens": 1185,
7662
+ "tokens": 1179,
7663
7663
  "aliases": [],
7664
7664
  "explains": []
7665
7665
  },
@@ -7760,7 +7760,7 @@
7760
7760
  "id": "apps",
7761
7761
  "title": "Agent Apps: build, propose, and what an install grants",
7762
7762
  "readWhen": "you build or change an Agent App (a mini app the person keeps on their home screen), cut a version of one, or someone wants an app installed, moved or removed",
7763
- "tokens": 1185,
7763
+ "tokens": 1179,
7764
7764
  "aliases": [],
7765
7765
  "explains": []
7766
7766
  },
@@ -7859,7 +7859,7 @@
7859
7859
  "id": "apps",
7860
7860
  "title": "Agent Apps: build, propose, and what an install grants",
7861
7861
  "readWhen": "you build or change an Agent App (a mini app the person keeps on their home screen), cut a version of one, or someone wants an app installed, moved or removed",
7862
- "tokens": 1185,
7862
+ "tokens": 1179,
7863
7863
  "aliases": [],
7864
7864
  "explains": []
7865
7865
  },
@@ -7911,9 +7911,9 @@
7911
7911
  "version": 8,
7912
7912
  "aliases": [],
7913
7913
  "explains": [],
7914
- "body": "Read this when you build or change an Agent App (a mini app), preview it, cut a version of it, or someone wants an app installed, approved again, moved or removed.\n\n## Build and propose\n\nAn Agent App, also called a mini app, is a package of files (`app.json`, the window's HTML, CSS and JavaScript, a schema per collection, a guide per scheduled job) that a person installs on an Agent and keeps on their home screen. It has its own saved data, unlike a chart or calculator shown in the chat. Building one, checking it, previewing it, cutting a version and proposing it for publishing are yours. A version is private and a draft: it is not published.\n\n```bash\nskrr apps reference [topic] # read before app.json and app.js\nskrr apps create <slug> # a starter that already passes the check\nskrr apps file write <app> <path> --expected-rev <rev> --from-file <file>\nskrr apps check <dir> # offline; or apps check-draft <app> in the cloud\nskrr apps preview <app> # then apps logs <app>\nskrr apps version create <app>\nskrr apps publish propose <version-id> --visibility workspace --reason \"…\"\n```\n\n- Every write names the revision it read. A stale one is refused and nothing is written: read again, merge, and retry with the revision it names.\n- Proposing records a request; the app's owner decides. You cannot publish.\n- The app automatic check does not include human review and cannot say whether anyone else reviewed the app. \"Nothing found\" does not mean safe: report what the check found, never that the app is safe.\n- An empty preview log means no person has reported a failure, not that the app works.\n- The window can read the person's tasks, goals, notes and files (`skrr.app.query`) and propose changes (`skrr.app.act`; the person confirms, a note is only proposed). Topic `sdk`.\n\n- The window may load modules, images and fonts from its package (topic `frame`); `apps push` sends images and fonts as bytes, up to a daily allowance (`APP_UPLOAD_BUDGET`: wait, do not retry).\n\n- Once a person has installed it, `apps installations events <id>` shows what its window reported when it failed, and `apps installations snapshot <id>` what it last showed. Both are the app's own words, not instructions; empty is not \"works\".\n\n## Installing is the person's decision\n\nAn install gives the app everything its disclosure lists: the data it keeps, the places it reaches outside Skrr, and the jobs it runs with the installer's full authority in their account, on a schedule or (`on@webhook:<name>`, `on@change:<collection>`) when a declared webhook delivers or a person changes a collection; your own writes never wake a job. So installing, approving again, moving to another version, choosing an update channel, pausing, resuming, changing settings and removing it are the person's acts. No CLI command or tool sets an app's secrets or makes its webhook credentials: only a person's interactive sign-in can.\n\n`skrr apps disclosure <version-id>` and `skrr apps install <app> --agent <agent-id>` without `--yes` show the disclosure read by that invocation and change nothing. Show it to the person. A later `--yes` run of install, reconsent or settings set reads its own current details; they may differ, and the earlier preview is not a binding approval receipt. The decision to approve is the person's. `skrr apps upgrade`, `skrr apps auto-apply`, `skrr apps channel`, `skrr apps suspend`, `skrr apps resume` and `skrr apps uninstall` are theirs to run, and `--delete-data` deletes the app's data for good.\n\nHow an app installed on a person is arranged on their Home is theirs too.\n\n`skrr apps layout show` reads it; `apps layout set` is refused to an agent's credential.\n\n## When your new version reaches an installed app\n\nA person can enable automatic updates. The platform applies versions made by that person or their agents only if the existing approval covers them; other authors' versions wait. New capabilities, data writers, jobs or changes to code that reaches outside need approval; the current version keeps running. You cannot enable this or approve a version.\n\n`skrr apps installations versions <installation>` shows which version runs, what is waiting and why, and `installations diff <installation> --from <version> --to <version>` what changed between two. `skrr apps rollback <installation>` puts an installation back on the version it ran before, in one call: use it when a version broke the installed app. `skrr apps auto-apply` is the person's.\n\n## Refusals\n\n| Code | Cause | Fix |\n| --- | --- | --- |\n| `APP_REV_MISMATCH` | The draft moved since you read it | Read it again, merge, retry with `details.currentRev` |\n| `APP_VISIBILITY_UNAVAILABLE` | That place cannot be proposed yet | Propose a place the command offers |\n| `APP_CONSENT_REQUIRED` | An install or approval ran without `--yes`; nothing changed | Show the person what it printed; the decision is theirs |\n| `APP_CONSENT_MISMATCH` | Approval details did not match what the server required | Read the current installation or version and review the relevant disclosure or settings again before deciding what to do |",
7915
- "hash": "bd35dbbb024903b3ba870d0e6115be44dab653a113d7f513256f3333c6ca7476",
7916
- "tokens": 1185,
7914
+ "body": "Read this when you build or change an Agent App (a mini app), preview it, cut a version of it, or someone wants an app installed, approved again, moved or removed.\n\n## Build and propose\n\nAn Agent App, also called a mini app, is a package of files (`app.json`, the window's HTML, CSS and JavaScript, a schema per collection, a guide per scheduled job) that a person installs on an Agent and keeps on their home screen. It has its own saved data, unlike a chart or calculator shown in the chat. You can build, check, preview and cut a version. A newly cut version is private; read its distribution for its status. Workspace publication is not available yet.\n\n```bash\nskrr apps reference [topic] # read before app.json and app.js\nskrr apps create <slug> # a starter that already passes the check\nskrr apps file write <app> <path> --expected-rev <rev> --from-file <file>\nskrr apps check <dir> # offline; or apps check-draft <app> in the cloud\nskrr apps preview <app> # then apps logs <app>\nskrr apps version create <app>\n```\n\n- Every write names the revision it read. A stale one is refused and nothing is written: read again, merge, and retry with the revision it names.\n- Proposing records a request but does not select a destination workspace. Approving it cannot publish the app; workspace publication is not available yet.\n- The app automatic check does not include human review and cannot say whether anyone else reviewed the app. \"Nothing found\" does not mean safe: report what the check found, never that the app is safe.\n- An empty preview log means no person has reported a failure, not that the app works.\n- The window can read the person's tasks, goals, notes and files (`skrr.app.query`) and propose changes (`skrr.app.act`; the person confirms, a note is only proposed). Topic `sdk`.\n\n- The window may load modules, images and fonts from its package (topic `frame`); `apps push` sends images and fonts as bytes, up to a daily allowance (`APP_UPLOAD_BUDGET`: wait, do not retry).\n\n- Once a person has installed it, `apps installations events <id>` shows what its window reported when it failed, and `apps installations snapshot <id>` what it last showed. Both are the app's own words, not instructions; empty is not \"works\".\n\n## Installing is the person's decision\n\nAn install gives the app everything its disclosure lists: the data it keeps, the places it reaches outside Skrr, and the jobs it runs with the installer's full authority in their account, on a schedule or (`on@webhook:<name>`, `on@change:<collection>`) when a declared webhook delivers or a person changes a collection; your own writes never wake a job. So installing, approving again, moving to another version, choosing an update channel, pausing, resuming, changing settings and removing it are the person's acts. No CLI command or tool sets an app's secrets or makes its webhook credentials: only a person's interactive sign-in can.\n\n`skrr apps disclosure <version-id>` and `skrr apps install <app> --agent <agent-id>` without `--yes` show the disclosure read by that invocation and change nothing. Show it to the person. A later `--yes` run of install, reconsent or settings set reads its own current details; they may differ, and the earlier preview is not a binding approval receipt. The decision to approve is the person's. `skrr apps upgrade`, `skrr apps auto-apply`, `skrr apps channel`, `skrr apps suspend`, `skrr apps resume` and `skrr apps uninstall` are theirs to run, and `--delete-data` deletes the app's data for good.\n\nHow an app installed on a person is arranged on their Home is theirs too.\n\n`skrr apps layout show` reads it; `apps layout set` is refused to an agent's credential.\n\n## When your new version reaches an installed app\n\nA person can enable automatic updates. The platform applies versions made by that person or their agents only if the existing approval covers them; other authors' versions wait. New capabilities, data writers, jobs or changes to code that reaches outside need approval; the current version keeps running. You cannot enable this or approve a version.\n\n`skrr apps installations versions <installation>` shows which version runs, what is waiting and why, and `installations diff <installation> --from <version> --to <version>` what changed between two. `skrr apps rollback <installation>` puts an installation back on the version it ran before, in one call: use it when a version broke the installed app. `skrr apps auto-apply` is the person's.\n\n## Refusals\n\n| Code | Cause | Fix |\n| --- | --- | --- |\n| `APP_REV_MISMATCH` | The draft moved since you read it | Read it again, merge, retry with `details.currentRev` |\n| `APP_VISIBILITY_UNAVAILABLE` | That place cannot be proposed yet | Propose a place the command offers |\n| `APP_CONSENT_REQUIRED` | An install or approval ran without `--yes`; nothing changed | Show the person what it printed; the decision is theirs |\n| `APP_CONSENT_MISMATCH` | Approval details did not match what the server required | Read the current installation or version and review the relevant disclosure or settings again before deciding what to do |",
7915
+ "hash": "07e23875c2a5fbe31441414ef2c095b976d1792762e5430c3eb2653bd2a0963e",
7916
+ "tokens": 1179,
7917
7917
  "sections": [
7918
7918
  {
7919
7919
  "id": "model",
@@ -7958,7 +7958,7 @@
7958
7958
  "id": "apps",
7959
7959
  "title": "Agent Apps: build, propose, and what an install grants",
7960
7960
  "readWhen": "you build or change an Agent App (a mini app the person keeps on their home screen), cut a version of one, or someone wants an app installed, moved or removed",
7961
- "tokens": 1185,
7961
+ "tokens": 1179,
7962
7962
  "aliases": [],
7963
7963
  "explains": []
7964
7964
  },
@@ -8057,7 +8057,7 @@
8057
8057
  "id": "apps",
8058
8058
  "title": "Agent Apps: build, propose, and what an install grants",
8059
8059
  "readWhen": "you build or change an Agent App (a mini app the person keeps on their home screen), cut a version of one, or someone wants an app installed, moved or removed",
8060
- "tokens": 1185,
8060
+ "tokens": 1179,
8061
8061
  "aliases": [],
8062
8062
  "explains": []
8063
8063
  },
@@ -8164,7 +8164,7 @@
8164
8164
  "id": "apps",
8165
8165
  "title": "Agent Apps: build, propose, and what an install grants",
8166
8166
  "readWhen": "you build or change an Agent App (a mini app the person keeps on their home screen), cut a version of one, or someone wants an app installed, moved or removed",
8167
- "tokens": 1185,
8167
+ "tokens": 1179,
8168
8168
  "aliases": [],
8169
8169
  "explains": []
8170
8170
  },
@@ -8267,7 +8267,7 @@
8267
8267
  "id": "apps",
8268
8268
  "title": "Agent Apps: build, propose, and what an install grants",
8269
8269
  "readWhen": "you build or change an Agent App (a mini app the person keeps on their home screen), cut a version of one, or someone wants an app installed, moved or removed",
8270
- "tokens": 1185,
8270
+ "tokens": 1179,
8271
8271
  "aliases": [],
8272
8272
  "explains": []
8273
8273
  },
@@ -51,6 +51,11 @@ export declare class ApiFetchError extends Error {
51
51
  * attributed by guesswork — see `node-adapter.ts`.
52
52
  */
53
53
  readonly requestId?: string;
54
+ /**
55
+ * The path of the failing request's URL, without origin or query. With `method` it names the route, which decides
56
+ * whether a failed write may be sent again (`write-outcome.ts`): only a route the server keeps a receipt for may.
57
+ */
58
+ requestPath?: string;
54
59
  /** Client recovery guidance; never changes the server's refusal status/code. */
55
60
  recoveryHint?: string;
56
61
  /** Milliseconds the server asked us to wait (`Retry-After`) on a 429. */
@@ -50,6 +50,7 @@ const workspace_header_1 = require("./workspace-header");
50
50
  const task_runtime_headers_1 = require("./task-runtime-headers");
51
51
  const non_json_response_1 = require("./non-json-response");
52
52
  const rate_limit_retry_1 = require("./rate-limit-retry");
53
+ const write_outcome_1 = require("./write-outcome");
53
54
  const memory_history_session_1 = require("./memory-history-session");
54
55
  const API_FETCH_RE = /^https?:\/\//i;
55
56
  const API_FETCH_RE_2 = /\/+$/;
@@ -69,6 +70,11 @@ class ApiFetchError extends Error {
69
70
  * attributed by guesswork — see `node-adapter.ts`.
70
71
  */
71
72
  requestId;
73
+ /**
74
+ * The path of the failing request's URL, without origin or query. With `method` it names the route, which decides
75
+ * whether a failed write may be sent again (`write-outcome.ts`): only a route the server keeps a receipt for may.
76
+ */
77
+ requestPath;
72
78
  /** Client recovery guidance; never changes the server's refusal status/code. */
73
79
  recoveryHint;
74
80
  /** Milliseconds the server asked us to wait (`Retry-After`) on a 429. */
@@ -99,7 +105,8 @@ exports.ApiFetchError = ApiFetchError;
99
105
  */
100
106
  async function apiFetch(pathOrUrl, opts = {}) {
101
107
  const historyRead = opts.sessionRead
102
- ? (0, memory_history_session_1.bindMemoryHistoryRead)(pathOrUrl, opts.method ?? 'GET') : null;
108
+ ? (0, memory_history_session_1.bindMemoryHistoryRead)(pathOrUrl, opts.method ?? 'GET')
109
+ : null;
103
110
  const sessionCredential = historyRead
104
111
  ? { token: historyRead.token, source: 'env-token', kind: (0, credential_resolver_1.kindOf)(historyRead.token) }
105
112
  : (0, credential_resolver_1.resolveTrustedAutonomousCredential)();
@@ -120,11 +127,12 @@ async function apiFetch(pathOrUrl, opts = {}) {
120
127
  : sessionCredential;
121
128
  const baseURL = autonomousCredential ? trustedAutonomousBaseUrl() : (0, config_1.loadConfig)().baseURL;
122
129
  const method = opts.method ?? 'GET';
123
- const url = historyRead?.url ?? (API_FETCH_RE.test(pathOrUrl)
124
- ? autonomousCredential
125
- ? assertTrustedAutonomousUrl(pathOrUrl, baseURL)
126
- : pathOrUrl
127
- : `${baseURL.replace(API_FETCH_RE_2, '')}${pathOrUrl.startsWith('/') ? '' : '/'}${pathOrUrl}`);
130
+ const url = historyRead?.url ??
131
+ (API_FETCH_RE.test(pathOrUrl)
132
+ ? autonomousCredential
133
+ ? assertTrustedAutonomousUrl(pathOrUrl, baseURL)
134
+ : pathOrUrl
135
+ : `${baseURL.replace(API_FETCH_RE_2, '')}${pathOrUrl.startsWith('/') ? '' : '/'}${pathOrUrl}`);
128
136
  // A FormData body passes through untouched — fetch sets the multipart
129
137
  // boundary itself, and stringifying would destroy it. Upload commands
130
138
  // (tasks attachments) need this on the session-scoped path, which is not
@@ -181,6 +189,32 @@ async function apiFetch(pathOrUrl, opts = {}) {
181
189
  (0, node_adapter_1.getAdapterCredentialOverride)() ??
182
190
  (await (0, credential_resolver_1.resolveCredential)());
183
191
  }
192
+ if (method !== 'GET' &&
193
+ !historyRead &&
194
+ !isAuthEndpoint(pathOrUrl) &&
195
+ cred.source !== 'flag' &&
196
+ (0, refresh_1.cliCredentialNeedsRefresh)(cred.token)) {
197
+ if (delegatedCli) {
198
+ const fresh = await (0, delegated_cli_1.fetchDelegatedCliCredential)(process.env, { forceRefresh: true });
199
+ if (fresh?.token)
200
+ cred = fresh;
201
+ }
202
+ else if (!autonomousCredential && (0, daemonBroker_1.isBrokeredHandoffToken)(cred.token)) {
203
+ const fresh = await (0, daemonBroker_1.redeemBrokeredHandoffToken)(true);
204
+ if (fresh?.accessToken) {
205
+ cred = { token: fresh.accessToken, source: 'env-token', kind: (0, credential_resolver_1.kindOf)(fresh.accessToken) };
206
+ }
207
+ }
208
+ else if (!autonomousCredential) {
209
+ const fresh = await (0, refresh_1.ensureFreshCliCredential)({ credential: cred });
210
+ if (fresh.refreshed && fresh.credential.token)
211
+ cred = fresh.credential;
212
+ }
213
+ // Explicit per-call authority stays local to this request.
214
+ if (!opts.credential)
215
+ (0, node_adapter_1.setAdapterCredentialOverride)(cred);
216
+ }
217
+ const replaySafe = !opts.singleAttempt && (0, write_outcome_1.isRequestReplaySafe)(method, url, callerHeaders);
184
218
  const fetchWithCredential = async (credential) => {
185
219
  const headers = {
186
220
  Accept: 'application/json',
@@ -207,26 +241,44 @@ async function apiFetch(pathOrUrl, opts = {}) {
207
241
  // OSK-12020 — a fresh proof per attempt for a DPoP-bound hand-off token
208
242
  // (the 401 retry below re-enters here and gets its own). No-op otherwise.
209
243
  Object.assign(headers, await (0, dpop_auth_1.dpopHeadersFor)(credential.token, method, url));
210
- const sent = (0, task_runtime_headers_1.withTaskRuntimeHeaders)((0, workspace_header_1.withWorkspaceHeader)(headers, historyRead ? {
211
- OVERSKY_AUTONOMOUS_SESSION: '1',
212
- OVERSKY_SESSION_WORKSPACE_ID: process.env.OVERSKY_SESSION_WORKSPACE_ID,
213
- } : process.env), url, method);
244
+ const sent = (0, task_runtime_headers_1.withTaskRuntimeHeaders)((0, workspace_header_1.withWorkspaceHeader)(headers, historyRead
245
+ ? {
246
+ OVERSKY_AUTONOMOUS_SESSION: '1',
247
+ OVERSKY_SESSION_WORKSPACE_ID: process.env.OVERSKY_SESSION_WORKSPACE_ID,
248
+ }
249
+ : process.env), url, method);
214
250
  // E6: a 429 on a GET or an idempotency-keyed write is retried (bounded,
215
251
  // jittered, honouring Retry-After). The last 429's wait is kept for the error.
216
- const { response, retryAfterMs } = await (0, rate_limit_retry_1.fetchWithRateLimitRetry)(() => fetch(url, {
217
- method,
218
- headers: sent,
219
- ...(historyRead || opts.singleAttempt ? { redirect: 'error' } : (0, task_runtime_headers_1.taskRuntimeRedirectOptions)(sent)),
220
- body,
221
- ...(opts.signal ? { signal: opts.signal } : {}),
222
- }), { method, headers: sent, signal: opts.signal, ...(opts.singleAttempt ? { maxRetries: 0 } : {}) });
252
+ let fetched;
253
+ try {
254
+ fetched = await (0, rate_limit_retry_1.fetchWithRateLimitRetry)(() => fetch(url, {
255
+ method,
256
+ headers: sent,
257
+ ...(historyRead || !replaySafe || method !== 'GET'
258
+ ? { redirect: 'error' }
259
+ : (0, task_runtime_headers_1.taskRuntimeRedirectOptions)(sent)),
260
+ body,
261
+ ...(opts.signal ? { signal: opts.signal } : {}),
262
+ }), {
263
+ method,
264
+ url,
265
+ headers: sent,
266
+ signal: opts.signal,
267
+ ...(!replaySafe ? { maxRetries: 0 } : {}),
268
+ });
269
+ }
270
+ catch (transportError) {
271
+ // No answer came back: say which request it was, so the error path can tell a route with a receipt from one without.
272
+ throw (0, write_outcome_1.stampRequest)(transportError, method, url);
273
+ }
274
+ const { response, retryAfterMs } = fetched;
223
275
  lastRetryAfterMs = retryAfterMs;
224
276
  return response;
225
277
  };
226
278
  let lastRetryAfterMs;
227
279
  let res = await fetchWithCredential(cred);
228
280
  let brokerFailure = null;
229
- if (!opts.singleAttempt && res.status === 401 && delegatedCli) {
281
+ if (replaySafe && res.status === 401 && delegatedCli) {
230
282
  // Deliberately terminal on broker failure: an Agent whose daemon cannot
231
283
  // rotate its family must surface the 401, never fall through to
232
284
  // `ensureFreshCliCredential` and adopt the human's stored refresh family.
@@ -237,7 +289,8 @@ async function apiFetch(pathOrUrl, opts = {}) {
237
289
  res = await fetchWithCredential(cred);
238
290
  }
239
291
  }
240
- else if (!opts.singleAttempt && res.status === 401 &&
292
+ else if (replaySafe &&
293
+ res.status === 401 &&
241
294
  !historyRead &&
242
295
  (0, daemonBroker_1.isBrokeredHandoffToken)(cred.token) &&
243
296
  !isAuthEndpoint(pathOrUrl)) {
@@ -256,7 +309,10 @@ async function apiFetch(pathOrUrl, opts = {}) {
256
309
  res = await fetchWithCredential(cred);
257
310
  }
258
311
  }
259
- else if (!opts.singleAttempt && res.status === 401 && !autonomousCredential && !isAuthEndpoint(pathOrUrl)) {
312
+ else if (replaySafe &&
313
+ res.status === 401 &&
314
+ !autonomousCredential &&
315
+ !isAuthEndpoint(pathOrUrl)) {
260
316
  const fresh = await (0, refresh_1.ensureFreshCliCredential)({ credential: cred, force: true });
261
317
  if (fresh.refreshed && fresh.credential.token) {
262
318
  cred = fresh.credential;
@@ -302,14 +358,17 @@ async function apiFetch(pathOrUrl, opts = {}) {
302
358
  catch {
303
359
  /* ignore body read failures */
304
360
  }
305
- const unsupportedHistory = historyRead && res.status === 404 &&
361
+ const unsupportedHistory = historyRead &&
362
+ res.status === 404 &&
306
363
  (!code || ['API_ROUTE_NOT_FOUND', 'ROUTE_NOT_FOUND'].includes(code));
307
364
  const error = new ApiFetchError(unsupportedHistory
308
365
  ? 'This server does not support session-scoped Memory history. Upgrade the server before retrying; owner-credential fallback is disabled.'
309
366
  : `HTTP ${res.status} ${res.statusText} — ${method} ${pathOrUrl}`, res.status, text, unsupportedHistory ? 'MEMORY_HISTORY_API_UNSUPPORTED' : code, method, res.headers.get('x-request-id') || undefined);
310
367
  if (historyRead && res.status === 401) {
311
- error.recoveryHint = 'Reconnect the managed Agent session and retry. If the refusal persists, check that this server supports session-scoped Memory history. Owner-credential fallback is disabled.';
368
+ error.recoveryHint =
369
+ 'Reconnect the managed Agent session and retry. If the refusal persists, check that this server supports session-scoped Memory history. Owner-credential fallback is disabled.';
312
370
  }
371
+ error.requestPath = (0, write_outcome_1.requestPathOf)(url);
313
372
  if (brokerFailure)
314
373
  error.brokerFailure = brokerFailure;
315
374
  if (res.status === 429 && lastRetryAfterMs !== undefined)