@skrr-ai/cli 0.1.163 → 0.1.165

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 (102) hide show
  1. package/README.md +13 -0
  2. package/dist/base-command.d.ts +14 -1
  3. package/dist/base-command.js +190 -58
  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/show.js +7 -1
  8. package/dist/commands/agents/mini-computer/tasks-view.js +1 -1
  9. package/dist/commands/agents/supervision.d.ts +25 -0
  10. package/dist/commands/agents/supervision.js +129 -0
  11. package/dist/commands/apps/check.js +3 -8
  12. package/dist/commands/apps/data/batch.d.ts +1 -0
  13. package/dist/commands/apps/data/batch.js +19 -2
  14. package/dist/commands/apps/data/delete.d.ts +1 -0
  15. package/dist/commands/apps/data/delete.js +14 -2
  16. package/dist/commands/apps/data/patch.d.ts +1 -0
  17. package/dist/commands/apps/data/patch.js +11 -2
  18. package/dist/commands/apps/data/put.d.ts +1 -0
  19. package/dist/commands/apps/data/put.js +17 -3
  20. package/dist/commands/apps/install.js +7 -2
  21. package/dist/commands/apps/installations/compatibility.d.ts +13 -0
  22. package/dist/commands/apps/installations/compatibility.js +60 -0
  23. package/dist/commands/apps/installations/show.js +9 -3
  24. package/dist/commands/apps/installations/snapshot.js +5 -2
  25. package/dist/commands/apps/operations/check.d.ts +16 -0
  26. package/dist/commands/apps/operations/check.js +127 -0
  27. package/dist/commands/apps/publish/propose.js +33 -4
  28. package/dist/commands/apps/reconsent.js +7 -1
  29. package/dist/commands/apps/reference.d.ts +4 -2
  30. package/dist/commands/apps/reference.js +7 -4
  31. package/dist/commands/apps/rollback.d.ts +9 -0
  32. package/dist/commands/apps/rollback.js +81 -2
  33. package/dist/commands/apps/upgrade.d.ts +8 -0
  34. package/dist/commands/apps/upgrade.js +67 -2
  35. package/dist/commands/apps/version/cat.d.ts +22 -0
  36. package/dist/commands/apps/version/cat.js +220 -0
  37. package/dist/commands/apps/version/show.js +3 -1
  38. package/dist/commands/commerce/incidents/release.d.ts +24 -0
  39. package/dist/commands/commerce/incidents/release.js +46 -0
  40. package/dist/commands/duties/action-proposal.js +19 -11
  41. package/dist/commands/duties/cadence-decisions.js +7 -0
  42. package/dist/commands/duties/cases.js +12 -1
  43. package/dist/commands/duties/hypotheses.js +10 -3
  44. package/dist/commands/duties/observations.d.ts +4 -0
  45. package/dist/commands/duties/observations.js +14 -3
  46. package/dist/commands/duties/trigger-status.js +2 -2
  47. package/dist/commands/duties/wake-capabilities.js +12 -6
  48. package/dist/commands/outbox/list.d.ts +11 -4
  49. package/dist/commands/outbox/list.js +56 -9
  50. package/dist/commands/outbox/retry.d.ts +8 -2
  51. package/dist/commands/outbox/retry.js +76 -16
  52. package/dist/commands/outbox/show.d.ts +20 -0
  53. package/dist/commands/outbox/show.js +83 -0
  54. package/dist/commands/proposals/list.js +13 -9
  55. package/dist/commands/requests/show.d.ts +12 -0
  56. package/dist/commands/requests/show.js +42 -23
  57. package/dist/commands/spaces/deletion/cancel.d.ts +21 -0
  58. package/dist/commands/spaces/deletion/cancel.js +70 -0
  59. package/dist/commands/spaces/workflows/run.js +12 -0
  60. package/dist/commands/widgets/check.d.ts +9 -0
  61. package/dist/commands/widgets/check.js +16 -3
  62. package/dist/generated/agent-guides.json +17 -17
  63. package/dist/lib/api-fetch.d.ts +5 -0
  64. package/dist/lib/api-fetch.js +53 -21
  65. package/dist/lib/appCompatibility.d.ts +31 -0
  66. package/dist/lib/appCompatibility.js +66 -0
  67. package/dist/lib/appData.d.ts +46 -4
  68. package/dist/lib/appData.js +156 -31
  69. package/dist/lib/appInstallations.d.ts +32 -5
  70. package/dist/lib/appInstallations.js +218 -34
  71. package/dist/lib/appVersionFile.d.ts +82 -0
  72. package/dist/lib/appVersionFile.js +195 -0
  73. package/dist/lib/apps-command.d.ts +14 -3
  74. package/dist/lib/apps-command.js +68 -60
  75. package/dist/lib/appsCheck.js +31 -6
  76. package/dist/lib/chat-supervision.d.ts +21 -0
  77. package/dist/lib/chat-supervision.js +37 -0
  78. package/dist/lib/commerce.d.ts +6 -0
  79. package/dist/lib/commerce.js +9 -0
  80. package/dist/lib/duties.d.ts +19 -1
  81. package/dist/lib/duties.js +21 -3
  82. package/dist/lib/json-output.d.ts +2 -0
  83. package/dist/lib/json-output.js +8 -4
  84. package/dist/lib/miniComputer.d.ts +1 -0
  85. package/dist/lib/miniComputer.js +7 -2
  86. package/dist/lib/miniComputerCommand.js +4 -1
  87. package/dist/lib/node-adapter.d.ts +2 -0
  88. package/dist/lib/node-adapter.js +35 -8
  89. package/dist/lib/outbox.d.ts +110 -1
  90. package/dist/lib/outbox.js +261 -35
  91. package/dist/lib/roles.d.ts +1 -1
  92. package/dist/lib/space-deletion-cancel.d.ts +47 -0
  93. package/dist/lib/space-deletion-cancel.js +141 -0
  94. package/dist/lib/widgetCheck.js +30 -4
  95. package/dist/lib/widgetStaticScan.d.ts +24 -9
  96. package/dist/lib/widgetStaticScan.js +207 -192
  97. package/dist/lib/write-outcome.d.ts +74 -0
  98. package/dist/lib/write-outcome.js +176 -0
  99. package/dist/node_modules/@skrr-ai/data-provider/APP_HTML_PARSER_LICENSES.txt +36 -0
  100. package/dist/node_modules/@skrr-ai/data-provider/index.js +20204 -15169
  101. package/oclif.manifest.json +2143 -25
  102. package/package.json +10 -3
@@ -520,6 +520,10 @@ export declare const dutyApi: {
520
520
  }) => Promise<DutyListPage>;
521
521
  cadenceDecisions: (id: string, limit?: number) => Promise<{
522
522
  data: unknown[];
523
+ sourcePolicy?: {
524
+ status?: string;
525
+ reason?: string;
526
+ };
523
527
  }>;
524
528
  /**
525
529
  * What the NEXT check would decide, computed without taking it.
@@ -1220,8 +1224,22 @@ export declare function renderDutyMetrics(response: ReadModelRecord, log: (line:
1220
1224
  * cost census predates the current rule is visible in the table.
1221
1225
  */
1222
1226
  export declare function costRuleCell(projection: Record<string, unknown> | null | undefined, closed?: boolean): string;
1227
+ /**
1228
+ * Whether a response is a bound-only history (OSK-23203, A30 phase 3) and whether it left anything out. The server
1229
+ * marks it `sourcePolicy.reason = 'bound_to_this_duty_document'` and says `coverage.someHidden` without a count.
1230
+ * `null` means the response is not a bound-only history at all.
1231
+ */
1232
+ export declare function boundHistoryCoverage(value: unknown): {
1233
+ someHidden: boolean;
1234
+ } | null;
1235
+ /** What the server says about a bound-only Case list: only Cases tied to this Duty document are shown. */
1236
+ export declare const BOUND_CASES_NOTE = "Only cases tied to this Duty document are shown. Other cases carry this Duty\u2019s id but cannot be tied to it (an earlier Duty with the same id, or recorded before the link existed), so they are left out.";
1237
+ /** What the server says about a bound-only hypothesis list: only claims first recorded for this Duty document are shown. */
1238
+ export declare const BOUND_HYPOTHESES_NOTE = "Only hypotheses first recorded for this Duty document are shown. Others carry this Duty\u2019s id but cannot be tied to it (an earlier Duty with the same id, or recorded before the link existed), so they are left out.";
1223
1239
  /** Human view for the case list — one row per durable problem case. */
1224
- export declare function renderDutyCases(response: ReadModelRecord, log: (line: string) => void): void;
1240
+ export declare function renderDutyCases(response: ReadModelRecord, log: (line: string) => void, options?: {
1241
+ emptyMessage?: string;
1242
+ }): void;
1225
1243
  /**
1226
1244
  * Human view for one case — a bounded digest, never the raw document.
1227
1245
  *
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DUTY_CLI_EVALUATORS = exports.DUTY_CREATE_KEYS = exports.DUTY_REMEDIATION_ACTIONS = exports.DUTY_FEEDBACK_KINDS = exports.dutyApi = exports.dutyPackApi = exports.MAX_DUTY_INTERVAL_MS = exports.MIN_DUTY_INTERVAL_MS = exports.DUTY_EXECUTION_ISOLATION_MODES = exports.DUTY_AUTHORABLE_CADENCE_MODES = exports.DUTY_KIND_VALUES = exports.DUTY_STATUSES = exports.DUTY_CADENCE_MAX_TIMES = exports.DUTY_CADENCE_TIME_PATTERN = exports.DUTY_CADENCE_MODES = exports.DUTY_TEMPLATE_IDS = exports.DUTY_WATCHED_SOURCES = void 0;
3
+ exports.BOUND_HYPOTHESES_NOTE = exports.BOUND_CASES_NOTE = exports.DUTY_CLI_EVALUATORS = exports.DUTY_CREATE_KEYS = exports.DUTY_REMEDIATION_ACTIONS = exports.DUTY_FEEDBACK_KINDS = exports.dutyApi = exports.dutyPackApi = exports.MAX_DUTY_INTERVAL_MS = exports.MIN_DUTY_INTERVAL_MS = exports.DUTY_EXECUTION_ISOLATION_MODES = exports.DUTY_AUTHORABLE_CADENCE_MODES = exports.DUTY_KIND_VALUES = exports.DUTY_STATUSES = exports.DUTY_CADENCE_MAX_TIMES = exports.DUTY_CADENCE_TIME_PATTERN = exports.DUTY_CADENCE_MODES = exports.DUTY_TEMPLATE_IDS = exports.DUTY_WATCHED_SOURCES = void 0;
4
4
  exports.activationRefusalLines = activationRefusalLines;
5
5
  exports.gateRefusesActivation = gateRefusesActivation;
6
6
  exports.permissionLines = permissionLines;
@@ -59,6 +59,7 @@ exports.isDutyLineageUnavailable = isDutyLineageUnavailable;
59
59
  exports.renderDutyLineage = renderDutyLineage;
60
60
  exports.renderDutyMetrics = renderDutyMetrics;
61
61
  exports.costRuleCell = costRuleCell;
62
+ exports.boundHistoryCoverage = boundHistoryCoverage;
62
63
  exports.renderDutyCases = renderDutyCases;
63
64
  exports.renderDutyCaseDetail = renderDutyCaseDetail;
64
65
  exports.renderDutyRemediationProposals = renderDutyRemediationProposals;
@@ -2571,8 +2572,25 @@ function costRuleCell(projection, closed = Boolean(projection)) {
2571
2572
  return '-';
2572
2573
  return projection.current === false ? `v${version} (older)` : `v${version}`;
2573
2574
  }
2575
+ /**
2576
+ * Whether a response is a bound-only history (OSK-23203, A30 phase 3) and whether it left anything out. The server
2577
+ * marks it `sourcePolicy.reason = 'bound_to_this_duty_document'` and says `coverage.someHidden` without a count.
2578
+ * `null` means the response is not a bound-only history at all.
2579
+ */
2580
+ function boundHistoryCoverage(value) {
2581
+ if (!value || typeof value !== 'object')
2582
+ return null;
2583
+ const v = value;
2584
+ if (v.sourcePolicy?.reason !== 'bound_to_this_duty_document')
2585
+ return null;
2586
+ return { someHidden: v.coverage?.someHidden === true };
2587
+ }
2588
+ /** What the server says about a bound-only Case list: only Cases tied to this Duty document are shown. */
2589
+ exports.BOUND_CASES_NOTE = 'Only cases tied to this Duty document are shown. Other cases carry this Duty’s id but cannot be tied to it (an earlier Duty with the same id, or recorded before the link existed), so they are left out.';
2590
+ /** What the server says about a bound-only hypothesis list: only claims first recorded for this Duty document are shown. */
2591
+ exports.BOUND_HYPOTHESES_NOTE = 'Only hypotheses first recorded for this Duty document are shown. Others carry this Duty’s id but cannot be tied to it (an earlier Duty with the same id, or recorded before the link existed), so they are left out.';
2574
2592
  /** Human view for the case list — one row per durable problem case. */
2575
- function renderDutyCases(response, log) {
2593
+ function renderDutyCases(response, log, options = {}) {
2576
2594
  const data = records(response.data);
2577
2595
  renderRows(data.map((item) => ({
2578
2596
  id: text(item.id),
@@ -2592,7 +2610,7 @@ function renderDutyCases(response, log) {
2592
2610
  { key: 'hypotheses', header: 'HYPO', maxWidth: 6 },
2593
2611
  { key: 'receipts', header: 'RCPTS', maxWidth: 6 },
2594
2612
  { key: 'last', header: 'LAST OBSERVED', maxWidth: 24 },
2595
- ], 'No cases recorded.', log);
2613
+ ], options.emptyMessage ?? 'No cases recorded.', log);
2596
2614
  }
2597
2615
  /**
2598
2616
  * Human view for one case — a bounded digest, never the raw document.
@@ -17,6 +17,8 @@
17
17
  * identifier would turn a cosmetic cleanup into data loss.
18
18
  */
19
19
  type Json = unknown;
20
+ /** The characters a terminal would act on rather than show, which JSON output escapes (and `apps version cat` builds on). */
21
+ export declare const JSON_TERMINAL_CONTROLS: RegExp;
20
22
  /** Escape terminal controls in serialized JSON without changing its parsed value. */
21
23
  export declare function escapeJsonForTerminal(text: string): string;
22
24
  /**
@@ -18,17 +18,21 @@
18
18
  * identifier would turn a cosmetic cleanup into data loss.
19
19
  */
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.JSON_TERMINAL_CONTROLS = void 0;
21
22
  exports.escapeJsonForTerminal = escapeJsonForTerminal;
22
23
  exports.stripStorageFields = stripStorageFields;
23
24
  exports.stripAppDataQueryMetadata = stripAppDataQueryMetadata;
24
25
  exports.stripStorageFieldsFromText = stripStorageFieldsFromText;
25
26
  exports.withOk = withOk;
26
27
  exports.withCliOperation = withCliOperation;
27
- const JSON_TERMINAL_CONTROLS = /[\u007f-\u009f\u00ad\u034f\u061c\u115f\u1160\u17b4\u17b5\u180b-\u180e\u200b-\u200f\u2028-\u202e\u2060-\u206f\u2800\u3164\ufe00-\ufe0f\ufeff\uffa0\ufff9-\ufffb\u{1d173}-\u{1d17a}\u{e0000}-\u{e03ff}]/gu;
28
+ /** The characters a terminal would act on rather than show, which JSON output escapes (and `apps version cat` builds on). */
29
+ exports.JSON_TERMINAL_CONTROLS =
30
+ // eslint-disable-next-line no-misleading-character-class -- the point of the pattern is to match combining and invisible characters (a pre-existing finding, annotated because this file is now also staged for `apps version cat`)
31
+ /[\u007f-\u009f\u00ad\u034f\u061c\u115f\u1160\u17b4\u17b5\u180b-\u180e\u200b-\u200f\u2028-\u202e\u2060-\u206f\u2800\u3164\ufe00-\ufe0f\ufeff\uffa0\ufff9-\ufffb\u{1d173}-\u{1d17a}\u{e0000}-\u{e03ff}]/gu;
28
32
  /** Escape terminal controls in serialized JSON without changing its parsed value. */
29
33
  function escapeJsonForTerminal(text) {
30
34
  const head = text.trimStart()[0];
31
- if ((head !== '{' && head !== '[' && head !== '"') || text.search(JSON_TERMINAL_CONTROLS) === -1)
35
+ if ((head !== '{' && head !== '[' && head !== '"') || text.search(exports.JSON_TERMINAL_CONTROLS) === -1)
32
36
  return text;
33
37
  // Prose printed by a command in JSON mode is not necessarily a JSON document.
34
38
  try {
@@ -38,7 +42,7 @@ function escapeJsonForTerminal(text) {
38
42
  return text;
39
43
  }
40
44
  // Do not escape C0: a serialized JSON string has already escaped it, while indentation uses newlines.
41
- return text.replace(JSON_TERMINAL_CONTROLS, (char) => Array.from({ length: char.length }, (_, index) => `\\u${char.charCodeAt(index).toString(16).padStart(4, '0')}`).join(''));
45
+ return text.replace(exports.JSON_TERMINAL_CONTROLS, (char) => Array.from({ length: char.length }, (_, index) => `\\u${char.charCodeAt(index).toString(16).padStart(4, '0')}`).join(''));
42
46
  }
43
47
  function usableId(value) {
44
48
  return (typeof value === 'string' && value.length > 0) || typeof value === 'number';
@@ -177,7 +181,7 @@ function withCliOperation(value, options) {
177
181
  ...(options.replayed !== undefined ? { replayed: options.replayed } : {}),
178
182
  writeState: options.mode !== 'execute'
179
183
  ? 'not_attempted'
180
- : options.writeState ?? (outcome === 'succeeded' ? 'confirmed' : 'unknown'),
184
+ : (options.writeState ?? (outcome === 'succeeded' ? 'confirmed' : 'unknown')),
181
185
  },
182
186
  };
183
187
  }
@@ -51,6 +51,7 @@ export declare const TASKS_VIEW_DATE_FIELDS: readonly import("@skrr-ai/data-prov
51
51
  export declare const TASKS_VIEW_DATE_PRESETS: readonly import("@skrr-ai/data-provider").DateFilterPreset[];
52
52
  /** One app's slot, in lines. */
53
53
  export declare function formatMiniAppConfig(raw: unknown): string[];
54
+ export declare const MINI_COMPUTER_REVIEW_GUIDANCE = "Review: sign in as the same person in a first-party app, open the Agent page with edit access, and go to Mini Computer Home. Suggestions appear one at a time; CLI credentials cannot decide them. Choose Apply or Dismiss on the suggestion.";
54
55
  /** The layout a person sees, in lines: the dock, the home grid, the folders, what is hidden, and what waits. */
55
56
  export declare function formatMiniComputerLayout(raw: unknown): string[];
56
57
  /** What a change answered, in lines for the Agent that asked. */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TASKS_VIEW_DATE_PRESETS = exports.TASKS_VIEW_DATE_FIELDS = exports.MINI_COMPUTER_REFUSAL_CODES = void 0;
3
+ exports.MINI_COMPUTER_REVIEW_GUIDANCE = exports.TASKS_VIEW_DATE_PRESETS = exports.TASKS_VIEW_DATE_FIELDS = exports.MINI_COMPUTER_REFUSAL_CODES = void 0;
4
4
  exports.readMiniComputerRefusal = readMiniComputerRefusal;
5
5
  exports.describeMiniComputerRefusal = describeMiniComputerRefusal;
6
6
  exports.tasksConfigFromFlags = tasksConfigFromFlags;
@@ -184,6 +184,9 @@ function formatMiniAppConfig(raw) {
184
184
  lines.push(` ${JSON.stringify(entry.config)}`);
185
185
  return lines;
186
186
  }
187
+ /** Review requires the person's first-party session, never a CLI approval. */
188
+ const MINI_COMPUTER_REVIEW_LOCATION = 'Review: sign in as the same person in a first-party app, open the Agent page with edit access, and go to Mini Computer Home. Suggestions appear one at a time; CLI credentials cannot decide them.';
189
+ exports.MINI_COMPUTER_REVIEW_GUIDANCE = `${MINI_COMPUTER_REVIEW_LOCATION} Choose Apply or Dismiss on the suggestion.`;
187
190
  /** The layout a person sees, in lines: the dock, the home grid, the folders, what is hidden, and what waits. */
188
191
  function formatMiniComputerLayout(raw) {
189
192
  const read = (0, data_provider_1.parseMiniComputerLayoutRead)(raw);
@@ -208,6 +211,8 @@ function formatMiniComputerLayout(raw) {
208
211
  for (const proposal of read.proposals) {
209
212
  lines.push(`Waiting for the person: ${proposal.summary.join('; ')}`);
210
213
  }
214
+ if (read.proposals.length > 0)
215
+ lines.push(exports.MINI_COMPUTER_REVIEW_GUIDANCE);
211
216
  const latest = read.changes[0];
212
217
  if (latest)
213
218
  lines.push(`Latest change: ${latest.summary.join('; ')}${latest.undoable ? ' (can be undone)' : ''}`);
@@ -219,7 +224,7 @@ function formatLayoutChangeResult(result) {
219
224
  ? result.summary.map((line) => ` ${line}`)
220
225
  : [' (no change: it already looks like that)'];
221
226
  const heading = { applied: 'Applied', proposed: 'Proposed', noop: 'Unchanged' }[result.outcome];
222
- return [`${heading}:`, ...lines, result.note];
227
+ return [`${heading}:`, ...lines, result.note, ...(result.outcome === 'proposed' ? [MINI_COMPUTER_REVIEW_LOCATION] : [])];
223
228
  }
224
229
  /** Operations from `--ops` or `--file` JSON text. Returns the raw array for the server to validate. */
225
230
  function parseOpsText(text) {
@@ -33,7 +33,10 @@ class MiniComputerCommand extends base_command_1.BaseCommand {
33
33
  try {
34
34
  const result = await data_provider_1.dataService.changeMiniComputerLayout(agentId, { ops });
35
35
  if (json) {
36
- this.log(this.agentJson(agentId, result));
36
+ this.log(this.agentJson(agentId, result.outcome === 'proposed'
37
+ ? { ...result, review: { surface: 'agent_mini_computer_home', interactiveSessionRequired: true,
38
+ actions: ['apply', 'dismiss'], instructions: miniComputer_1.MINI_COMPUTER_REVIEW_GUIDANCE } }
39
+ : result));
37
40
  return;
38
41
  }
39
42
  for (const line of (0, miniComputer_1.formatLayoutChangeResult)(result))
@@ -1,6 +1,8 @@
1
1
  import { type HttpAdapter } from '@skrr-ai/data-provider';
2
2
  import { type ResolvedCredential } from '@skrr-ai/auth-core';
3
3
  import './auth-core-init';
4
+ export declare const APP_DATA_PATH_RE: RegExp;
5
+ export declare const APP_SETTINGS_PATH_RE: RegExp;
4
6
  /**
5
7
  * node-adapter.ts — Node-native HttpAdapter for @skrr-ai/data-provider.
6
8
  *
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.APP_SETTINGS_PATH_RE = exports.APP_DATA_PATH_RE = void 0;
3
4
  exports.setAdapterCredentialOverride = setAdapterCredentialOverride;
4
5
  exports.clearAdapterCredentialOverride = clearAdapterCredentialOverride;
5
6
  exports.getAdapterCredentialOverride = getAdapterCredentialOverride;
@@ -20,14 +21,15 @@ const task_runtime_headers_1 = require("./task-runtime-headers");
20
21
  const non_json_response_1 = require("./non-json-response");
21
22
  require("./auth-core-init");
22
23
  const rate_limit_retry_1 = require("./rate-limit-retry");
24
+ const write_outcome_1 = require("./write-outcome");
23
25
  const RESOLVE_URL_RE = /^https?:\/\//i;
24
26
  const RESOLVE_URL_RE_2 = /\/+$/;
25
27
  // These routes do not yet have a server-side idempotency receipt. A generated
26
28
  // request key alone cannot make an arbitrary gateway response safe to replay.
27
29
  // A deployment can mount the API beneath a path prefix; a match at any
28
30
  // segment is deliberately conservative even for a different origin.
29
- const APP_DATA_PATH_RE = /\/api\/apps\/installations\/[^/]+\/data(?:\/|$)/;
30
- const APP_SETTINGS_PATH_RE = /\/api\/apps\/installations\/[^/]+\/settings\/?$/;
31
+ exports.APP_DATA_PATH_RE = /\/api\/apps\/installations\/[^/]+\/data(?:\/|$)/;
32
+ exports.APP_SETTINGS_PATH_RE = /\/api\/apps\/installations\/[^/]+\/settings\/?$/;
31
33
  // ---------------------------------------------------------------------
32
34
  // Per-process credential override — set by BaseCommand.init().
33
35
  // Pulled out of the closure so test harnesses or long-lived callers
@@ -173,7 +175,7 @@ function createNodeAdapter(opts = {}) {
173
175
  if (method === 'GET')
174
176
  return false;
175
177
  try {
176
- return APP_DATA_PATH_RE.test(new URL(url).pathname);
178
+ return exports.APP_DATA_PATH_RE.test(new URL(url).pathname);
177
179
  }
178
180
  catch {
179
181
  return false;
@@ -183,7 +185,7 @@ function createNodeAdapter(opts = {}) {
183
185
  if (method !== 'PUT')
184
186
  return false;
185
187
  try {
186
- return APP_SETTINGS_PATH_RE.test(new URL(url).pathname);
188
+ return exports.APP_SETTINGS_PATH_RE.test(new URL(url).pathname);
187
189
  }
188
190
  catch {
189
191
  return false;
@@ -220,9 +222,28 @@ function createNodeAdapter(opts = {}) {
220
222
  const appDataWrite = isAppDataWrite(method, finalUrl);
221
223
  const appSettingsWrite = isAppSettingsWrite(method, finalUrl);
222
224
  const noReplay = options?._disableAuthReplay === true;
223
- const { response, retryAfterMs } = await (0, rate_limit_retry_1.fetchWithRateLimitRetry)(() => fetch(finalUrl, { method, headers, body: finalBody, ...(signal ? { signal } : {}),
224
- ...(appDataWrite || appSettingsWrite || noReplay ? { redirect: 'manual' } : (0, task_runtime_headers_1.taskRuntimeRedirectOptions)(headers)) }), { method, headers, ...(appDataWrite || appSettingsWrite || noReplay
225
- ? { maxRetries: 0 } : {}) });
225
+ let fetched;
226
+ try {
227
+ fetched = await (0, rate_limit_retry_1.fetchWithRateLimitRetry)(() => fetch(finalUrl, {
228
+ method,
229
+ headers,
230
+ body: finalBody,
231
+ ...(signal ? { signal } : {}),
232
+ ...(appDataWrite || appSettingsWrite || noReplay
233
+ ? { redirect: 'manual' }
234
+ : (0, task_runtime_headers_1.taskRuntimeRedirectOptions)(headers)),
235
+ }), {
236
+ method,
237
+ headers,
238
+ ...(appDataWrite || appSettingsWrite || noReplay ? { maxRetries: 0 } : {}),
239
+ });
240
+ }
241
+ catch (transportError) {
242
+ // No answer came back. The error says nothing of what was asked, and whether the write may be sent again depends
243
+ // on which route it was (OSK-24076): stamp the method and path so the error path can ask the registry.
244
+ throw (0, write_outcome_1.stampRequest)(transportError, method, finalUrl);
245
+ }
246
+ const { response, retryAfterMs } = fetched;
226
247
  lastRetryAfterMs = retryAfterMs;
227
248
  return response;
228
249
  }
@@ -380,7 +401,11 @@ function createNodeAdapter(opts = {}) {
380
401
  let res = await rawRequest(method, url, body, options, isFormData);
381
402
  // Never retry auth endpoints themselves — prevents refresh recursion
382
403
  // and lets login/logout/refresh surface their real errors.
383
- if (res.status === 401 && !appDataWrite && !appSettingsWrite && options?._disableAuthReplay !== true && !url.includes('/api/auth/')) {
404
+ if (res.status === 401 &&
405
+ !appDataWrite &&
406
+ !appSettingsWrite &&
407
+ options?._disableAuthReplay !== true &&
408
+ !url.includes('/api/auth/')) {
384
409
  const refreshed = await refresh();
385
410
  if (refreshed) {
386
411
  res = await rawRequest(method, url, body, options, isFormData);
@@ -416,6 +441,8 @@ function createNodeAdapter(opts = {}) {
416
441
  err.status = res.status;
417
442
  err.body = text;
418
443
  err.method = method;
444
+ // Which route answered, so a 5xx on a write can be judged against the routes that keep a server receipt (OSK-24076).
445
+ err.requestPath = (0, write_outcome_1.requestPathOf)(url);
419
446
  // The server stamps every response with the id it logs against
420
447
  // (`requestLogger`). Carrying it means a refused call can be found in
421
448
  // the logs instead of guessed at: with several clients on one account,
@@ -14,6 +14,18 @@ export interface OutboxEntry {
14
14
  body: unknown;
15
15
  /** Workspace active when the write was authored, preserved for replay. */
16
16
  workspaceId?: string;
17
+ /**
18
+ * The deployment this write was queued against, as `scheme://host[:port]`
19
+ * (OSK-23807). Absent on entries queued before origin binding, which cannot
20
+ * prove where they were meant to go and so stay paused as unverified.
21
+ */
22
+ origin?: string;
23
+ /**
24
+ * Who the CLI believed it was acting as, with no secret in it: `user:<id>`
25
+ * when the credential carries an id claim, else `profile:<name>`. Present
26
+ * together with `origin`, or not at all.
27
+ */
28
+ account?: string;
17
29
  /** ISO timestamp of the enqueue. */
18
30
  queuedAt: string;
19
31
  /** Why it could not be sent — the outage evidence, for triage. */
@@ -45,7 +57,104 @@ export interface OutboxEntry {
45
57
  */
46
58
  export declare const MAX_REPLAY_ATTEMPTS = 10;
47
59
  export declare function isOutageFailure(err: unknown): boolean;
48
- export declare function isRetryableWrite(err: unknown): boolean;
60
+ /**
61
+ * ── What may be queued without knowing it did not happen (OSK-24076) ────────
62
+ *
63
+ * A write is queued to be sent again, and sending it again is only safe when the
64
+ * first attempt either did not happen or will be recognised. A 408, a 425, a 5xx
65
+ * and a dead connection prove neither: the server may have applied the write
66
+ * before it failed. Those are queued ONLY for a route the server keeps a replay
67
+ * receipt for (`request`, checked against the registry of routes that mount
68
+ * `requestIdempotency`); on any other route the outcome is unknown, and a repeat
69
+ * could apply it twice, so the write is not queued and the failure is reported.
70
+ *
71
+ * Three kinds of failure do not depend on the route and keep their answer:
72
+ * 401 and 429 as before: could not authenticate right now, throttled.
73
+ * a refused connection or a failed name lookup the request never left, so
74
+ * nothing happened and queueing it is safe.
75
+ *
76
+ * `request` is the write that failed. Left out, the route is unknown and so has
77
+ * no receipt: the default for a write is that nothing will recognise a repeat.
78
+ */
79
+ export declare function isRetryableWrite(err: unknown, request?: {
80
+ method?: string;
81
+ path?: string;
82
+ }): boolean;
83
+ /**
84
+ * `scheme://host[:port]` of an API base URL, or null when it names no HTTP(S)
85
+ * server. Case, default ports, credentials, path, query and fragment are
86
+ * dropped, so `HTTPS://Skrr.AI:443/api/` and `https://skrr.ai` are one origin.
87
+ */
88
+ export declare function normalizeOutboxOrigin(baseURL: string | null | undefined): string | null;
89
+ /**
90
+ * The account label for a credential: `user:<id>` from the access token's `id`
91
+ * claim, else `profile:<name>`, which is all an opaque credential (a personal
92
+ * access token, a CI token) lets the CLI know without asking the server.
93
+ */
94
+ export declare function outboxAccountFor(token: string | null | undefined, profile?: string): string;
95
+ export interface OutboxBinding {
96
+ origin: string;
97
+ account: string;
98
+ }
99
+ /**
100
+ * What to record on an entry being queued now, or null when the configured
101
+ * server is not an HTTP(S) origin. A null binding still queues the write so the
102
+ * content survives; it just stays paused as unverified, like an older entry.
103
+ */
104
+ export declare function outboxBindingFor(input: {
105
+ baseURL: string | null | undefined;
106
+ token: string | null | undefined;
107
+ profile?: string;
108
+ }): OutboxBinding | null;
109
+ /** Does this entry record both where and as whom it was queued? */
110
+ export declare function isOutboxBound(entry: Pick<OutboxEntry, 'origin' | 'account'>): entry is {
111
+ origin: string;
112
+ account: string;
113
+ };
114
+ /** The context a replay sent from this process would run in. */
115
+ export interface ReplayContext {
116
+ /** Null when the configured server is not an HTTP(S) origin. */
117
+ origin: string | null;
118
+ account: string;
119
+ }
120
+ export declare function currentReplayContext(input: {
121
+ baseURL: string | null | undefined;
122
+ token: string | null | undefined;
123
+ profile?: string;
124
+ }): ReplayContext;
125
+ export interface ReplayContextFinding {
126
+ field: 'server' | 'account' | 'workspace';
127
+ recorded: string;
128
+ current: string;
129
+ }
130
+ export type ReplayContextVerdict =
131
+ /** Queued before origin binding: nothing proves where it was meant to go. */
132
+ {
133
+ state: 'unverified';
134
+ } | {
135
+ state: 'match';
136
+ } | {
137
+ state: 'mismatch';
138
+ findings: ReplayContextFinding[];
139
+ };
140
+ /**
141
+ * May this entry be replayed from `current`?
142
+ *
143
+ * The workspace is not read from `current`: it is whatever `apiFetch` would put
144
+ * on the request, which is the entry's own header when it recorded one and the
145
+ * ambient workspace otherwise (an Agent session replaces even the recorded one).
146
+ * An entry queued with no workspace that is replayed while one is selected would
147
+ * land somewhere it was never authored for.
148
+ */
149
+ export declare function assessReplayContext(entry: OutboxEntry, current: ReplayContext, env?: Record<string, string | undefined>): ReplayContextVerdict;
150
+ /**
151
+ * A recorded value, safe to print. The file is the user's and can be edited or
152
+ * damaged, so a control or format character is shown as a visible `\uXXXX`
153
+ * rather than drawn.
154
+ */
155
+ export declare function printableOutboxField(value: string): string;
156
+ /** "recorded server https://a, current server https://b; recorded account ..." */
157
+ export declare function describeReplayFindings(findings: readonly ReplayContextFinding[]): string;
49
158
  /** One replay at a time; unlike the short queue lock, this spans network calls. */
50
159
  export declare function lockOutboxReplay(profile?: string): Promise<() => Promise<void>>;
51
160
  export declare class OutboxFullError extends Error {