@skrr-ai/cli 0.1.164 → 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 (88) 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/show.js +9 -3
  21. package/dist/commands/apps/installations/snapshot.js +5 -2
  22. package/dist/commands/apps/operations/check.d.ts +16 -0
  23. package/dist/commands/apps/operations/check.js +127 -0
  24. package/dist/commands/apps/publish/propose.js +33 -4
  25. package/dist/commands/apps/reconsent.js +7 -1
  26. package/dist/commands/apps/reference.d.ts +4 -2
  27. package/dist/commands/apps/reference.js +7 -4
  28. package/dist/commands/apps/rollback.d.ts +9 -0
  29. package/dist/commands/apps/rollback.js +81 -2
  30. package/dist/commands/apps/upgrade.d.ts +8 -0
  31. package/dist/commands/apps/upgrade.js +67 -2
  32. package/dist/commands/apps/version/cat.d.ts +22 -0
  33. package/dist/commands/apps/version/cat.js +220 -0
  34. package/dist/commands/apps/version/show.js +3 -1
  35. package/dist/commands/commerce/incidents/release.d.ts +24 -0
  36. package/dist/commands/commerce/incidents/release.js +46 -0
  37. package/dist/commands/duties/cases.js +12 -1
  38. package/dist/commands/duties/hypotheses.js +10 -3
  39. package/dist/commands/duties/observations.d.ts +4 -0
  40. package/dist/commands/duties/observations.js +14 -3
  41. package/dist/commands/outbox/list.d.ts +11 -4
  42. package/dist/commands/outbox/list.js +56 -9
  43. package/dist/commands/outbox/retry.d.ts +8 -2
  44. package/dist/commands/outbox/retry.js +76 -16
  45. package/dist/commands/outbox/show.d.ts +20 -0
  46. package/dist/commands/outbox/show.js +83 -0
  47. package/dist/commands/proposals/list.js +13 -9
  48. package/dist/commands/requests/show.d.ts +12 -0
  49. package/dist/commands/requests/show.js +42 -23
  50. package/dist/commands/spaces/deletion/cancel.d.ts +21 -0
  51. package/dist/commands/spaces/deletion/cancel.js +70 -0
  52. package/dist/commands/spaces/workflows/run.js +12 -0
  53. package/dist/commands/widgets/check.d.ts +9 -0
  54. package/dist/commands/widgets/check.js +16 -3
  55. package/dist/generated/agent-guides.json +17 -17
  56. package/dist/lib/api-fetch.d.ts +5 -0
  57. package/dist/lib/api-fetch.js +53 -21
  58. package/dist/lib/appCompatibility.d.ts +31 -0
  59. package/dist/lib/appCompatibility.js +66 -0
  60. package/dist/lib/appData.d.ts +46 -4
  61. package/dist/lib/appData.js +156 -31
  62. package/dist/lib/appInstallations.d.ts +32 -5
  63. package/dist/lib/appInstallations.js +197 -34
  64. package/dist/lib/appVersionFile.d.ts +82 -0
  65. package/dist/lib/appVersionFile.js +195 -0
  66. package/dist/lib/apps-command.d.ts +14 -3
  67. package/dist/lib/apps-command.js +68 -60
  68. package/dist/lib/appsCheck.js +16 -2
  69. package/dist/lib/commerce.d.ts +6 -0
  70. package/dist/lib/commerce.js +9 -0
  71. package/dist/lib/duties.d.ts +15 -1
  72. package/dist/lib/duties.js +21 -3
  73. package/dist/lib/json-output.d.ts +2 -0
  74. package/dist/lib/json-output.js +8 -4
  75. package/dist/lib/node-adapter.d.ts +2 -0
  76. package/dist/lib/node-adapter.js +35 -8
  77. package/dist/lib/outbox.d.ts +110 -1
  78. package/dist/lib/outbox.js +261 -35
  79. package/dist/lib/space-deletion-cancel.d.ts +47 -0
  80. package/dist/lib/space-deletion-cancel.js +141 -0
  81. package/dist/lib/widgetCheck.js +1 -1
  82. package/dist/lib/widgetStaticScan.d.ts +11 -5
  83. package/dist/lib/widgetStaticScan.js +73 -165
  84. package/dist/lib/write-outcome.d.ts +74 -0
  85. package/dist/lib/write-outcome.js +176 -0
  86. package/dist/node_modules/@skrr-ai/data-provider/index.js +11839 -11318
  87. package/oclif.manifest.json +1940 -16
  88. package/package.json +9 -3
@@ -1,4 +1,5 @@
1
1
  import { BaseCommand } from '../base-command';
2
+ import type { InstallationConflictContext } from './appInstallations';
2
3
  /**
3
4
  * The base of every `skrr apps` command that talks to the API.
4
5
  *
@@ -11,6 +12,12 @@ import { BaseCommand } from '../base-command';
11
12
  export declare abstract class AppsCommand extends BaseCommand {
12
13
  /** A successful response was already received; do not turn a synchronous output failure into a request failure. */
13
14
  protected failConfirmedDataOutput(): never;
15
+ /**
16
+ * Say, on STDERR, the operation a confirmed write left (step 4b): its reference, and whether this run wrote anything. Stdout is what it
17
+ * always was. The reference is a support reference and nothing else: it changes neither what the write was nor what to do next, and an
18
+ * answer without one is simply a write no receipt exists for.
19
+ */
20
+ protected logOperationReference(result: unknown): void;
14
21
  /** The id of the app the person named (an id or a slug). */
15
22
  protected appId(ref: string): Promise<string>;
16
23
  /**
@@ -18,10 +25,12 @@ export declare abstract class AppsCommand extends BaseCommand {
18
25
  * are answers with a next step (a bundle that moved while the person decided, data that would be deleted),
19
26
  * so they come under their own machine code and exit, and a refusal that is not one of them is the base
20
27
  * command's. Never returns.
28
+ *
29
+ * `context` is what the command knows and the refusal's words may use: the installation it was about (`subject`), the
30
+ * version it was installing, moving to or approving, what it was doing, and who an install was for. A command that
31
+ * passes less gets words that say less, never a command with an argument missing (`InstallationConflictContext`).
21
32
  */
22
- protected failInstallation(error: unknown, { subject }?: {
23
- subject?: string;
24
- }): never;
33
+ protected failInstallation(error: unknown, context?: InstallationConflictContext): never;
25
34
  /**
26
35
  * Say what went wrong with a call to the PERSON channel (`apps data put | query`): a document that was not given or
27
36
  * is not JSON (before anything was sent), a refusal from the contract's closed set, or a conflict, which is an
@@ -40,6 +49,8 @@ export declare abstract class AppsCommand extends BaseCommand {
40
49
  collection?: unknown;
41
50
  id?: unknown;
42
51
  }>;
52
+ /** The key the write was sent with: when the outcome is unknown, it is what a person asks the server by. */
53
+ idempotencyKey?: string;
43
54
  }): never;
44
55
  /**
45
56
  * Say what went wrong with a REPORT: the refusals only a report makes (a reason the Store does not take, a
@@ -2,11 +2,22 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AppsCommand = void 0;
4
4
  const data_provider_1 = require("@skrr-ai/data-provider");
5
+ const write_outcome_1 = require("./write-outcome");
5
6
  const base_command_1 = require("../base-command");
6
7
  const apps_1 = require("./apps");
7
8
  const appInstallations_1 = require("./appInstallations");
8
9
  const appsFs_1 = require("./appsFs");
9
10
  const appData_1 = require("./appData");
11
+ /**
12
+ * The refusals the person-data write route sends BEFORE it writes, with the status it sends each at: the route's own table,
13
+ * plus the store's `conflict` answer. `unavailable` is left out on purpose: it proves nothing unless it also says the
14
+ * installation is paused, so `failPersonData` adds it, at the statuses a pause is sent with, only for that body.
15
+ */
16
+ const { unavailable: _notAContractRefusal, ...PERSON_DATA_CONTRACT_REFUSALS } = data_provider_1.APP_PERSON_DATA_REFUSAL_STATUS;
17
+ const PERSON_DATA_WRITE_REFUSALS = {
18
+ ...PERSON_DATA_CONTRACT_REFUSALS,
19
+ conflict: 409,
20
+ };
10
21
  /**
11
22
  * The base of every `skrr apps` command that talks to the API.
12
23
  *
@@ -29,6 +40,17 @@ class AppsCommand extends base_command_1.BaseCommand {
29
40
  // an arbitrary output exception. BaseCommand drains pending stdio before handling this exit.
30
41
  return this.exit(1);
31
42
  }
43
+ /**
44
+ * Say, on STDERR, the operation a confirmed write left (step 4b): its reference, and whether this run wrote anything. Stdout is what it
45
+ * always was. The reference is a support reference and nothing else: it changes neither what the write was nor what to do next, and an
46
+ * answer without one is simply a write no receipt exists for.
47
+ */
48
+ logOperationReference(result) {
49
+ const reference = (0, appData_1.readOperationReference)(result);
50
+ if (reference) {
51
+ this.logToStderr((0, appData_1.describeOperationReference)(reference));
52
+ }
53
+ }
32
54
  /** The id of the app the person named (an id or a slug). */
33
55
  async appId(ref) {
34
56
  try {
@@ -51,11 +73,16 @@ class AppsCommand extends base_command_1.BaseCommand {
51
73
  * are answers with a next step (a bundle that moved while the person decided, data that would be deleted),
52
74
  * so they come under their own machine code and exit, and a refusal that is not one of them is the base
53
75
  * command's. Never returns.
76
+ *
77
+ * `context` is what the command knows and the refusal's words may use: the installation it was about (`subject`), the
78
+ * version it was installing, moving to or approving, what it was doing, and who an install was for. A command that
79
+ * passes less gets words that say less, never a command with an argument missing (`InstallationConflictContext`).
54
80
  */
55
- failInstallation(error, { subject } = {}) {
81
+ failInstallation(error, context = {}) {
82
+ const { subject } = context;
56
83
  const refusal = (0, apps_1.readAppsRefusal)(error);
57
84
  if (refusal && (0, data_provider_1.isAppInstallationConflict)(refusal.error)) {
58
- const words = (0, appInstallations_1.describeInstallationConflict)(refusal, this.config.bin, subject);
85
+ const words = (0, appInstallations_1.describeInstallationConflict)(refusal, this.config.bin, context);
59
86
  if (words !== null) {
60
87
  return this.failWithCliError({
61
88
  message: words,
@@ -107,26 +134,24 @@ class AppsCommand extends base_command_1.BaseCommand {
107
134
  const paused = parsedFailure?.kind === 'refusal' &&
108
135
  parsedFailure.code === 'unavailable' &&
109
136
  parsedFailure.reason === 'installation_suspended';
110
- const confirmedPause = paused && (responseStatus === 403 || responseStatus === 503);
111
- const knownForbidden = parsedFailure?.kind === 'refusal' &&
112
- ['human_only', 'not_granted', 'forbidden_by_viewer'].includes(parsedFailure.code);
113
- // The route's per-operation limit refuses before any write runs, so a 429 carrying the contract's
114
- // `rate` body is a definite "not applied". Any other 429 proves nothing and stays unknown.
115
- const confirmedRate = parsedFailure?.kind === 'refusal' && parsedFailure.code === 'rate' && responseStatus === 429;
116
137
  const sentWrite = Boolean(target.verb) && target.requestStarted;
117
- // An unrecognized body or a recognizable body with a different HTTP status is not a confirmed app-data response.
118
- // Both sides use the shared contract. A conflict is an answer, not a refusal, and uses 409.
119
- const expectedStatus = parsedFailure?.kind === 'conflict'
120
- ? 409
121
- : parsedFailure?.kind === 'refusal'
122
- ? data_provider_1.APP_PERSON_DATA_REFUSAL_STATUS[parsedFailure.code]
123
- : undefined;
124
- const mismatchedFailure = sentWrite &&
125
- typeof responseStatus === 'number' &&
126
- responseStatus >= 400 &&
127
- responseStatus <= 599 &&
128
- !confirmedPause &&
129
- expectedStatus !== responseStatus;
138
+ // Which responses prove the write was NOT applied is the shared contract's table, not this method's: a typed refusal
139
+ // counts only at the status its route promises, a 401, 408, 425, 5xx or bare 429 never does, and no answer at all is
140
+ // unknown (`classifyWriteOutcome`, OSK-24076). What is this command's own is the route's list of refusals, below.
141
+ // The route's per-operation limit refuses before any write runs, so a 429 carrying the `rate` body is a definite
142
+ // "not applied". A pause is a definite "not applied" only when it says so, at the statuses the route sends it with.
143
+ const sent = (0, write_outcome_1.requestOfError)(error);
144
+ const outcome = (0, write_outcome_1.classifyRequestOutcome)({
145
+ request: { method: sentWrite ? sent.method || 'PUT' : 'GET', path: sent.path },
146
+ status: typeof responseStatus === 'number' ? responseStatus : undefined,
147
+ body: error?.body,
148
+ transportError: sentWrite && (responseStatus === undefined || responseStatus === 0),
149
+ refusals: paused
150
+ ? { ...PERSON_DATA_WRITE_REFUSALS, unavailable: [403, 503] }
151
+ : PERSON_DATA_WRITE_REFUSALS,
152
+ // A 2xx the transport could not read as JSON is not the confirmation it looks like.
153
+ bodyConfirms: responseCode !== 'NON_JSON_RESPONSE',
154
+ });
130
155
  // A batch conflict identifies one submitted operation. An absent or out-of-range index cannot
131
156
  // establish which request the response describes, so do not claim that nothing was written.
132
157
  const invalidBatchConflict = sentWrite &&
@@ -137,28 +162,17 @@ class AppsCommand extends base_command_1.BaseCommand {
137
162
  parsedFailure.index < 0 ||
138
163
  parsedFailure.index >= target.batchTargets.length);
139
164
  const unconfirmedResponse = invalidBatchConflict ||
140
- (sentWrite && (responseStatus === undefined || responseStatus === 0)) ||
141
- (typeof responseStatus === 'number' &&
142
- ((responseStatus >= 300 && responseStatus <= 399) ||
143
- mismatchedFailure ||
144
- (sentWrite &&
145
- (responseStatus === 401 ||
146
- responseStatus === 408 ||
147
- responseStatus === 425 ||
148
- (responseStatus === 429 && !confirmedRate) ||
149
- (!confirmedPause &&
150
- ((responseStatus >= 500 && responseStatus <= 599) ||
151
- (responseStatus === 403 && !knownForbidden))))) ||
152
- (responseStatus >= 200 &&
153
- responseStatus <= 299 &&
154
- responseCode === 'NON_JSON_RESPONSE')));
165
+ (sentWrite
166
+ ? // A refusal this command cannot read as one of its own (`readPersonDataFailure`) proves nothing either.
167
+ outcome.kind === 'unknown' || (outcome.kind === 'rejected' && parsedFailure === null)
168
+ : // Not a write: only a redirect, or a 2xx that is not the JSON it should be, is unconfirmed.
169
+ outcome.reason === 'redirect' || outcome.reason === 'unconfirmed_response');
155
170
  const failure = unconfirmedResponse ? null : parsedFailure;
156
171
  if (failure === null ||
157
172
  (failure.kind === 'refusal' && (failure.code === 'unavailable' || failure.code === 'rate'))) {
158
173
  const e = error;
159
174
  const status = typeof e?.status === 'number' ? e.status : undefined;
160
175
  const code = typeof e?.code === 'string' ? e.code : '';
161
- const message = typeof e?.message === 'string' ? e.message : '';
162
176
  let body;
163
177
  try {
164
178
  const parsed = typeof e?.body === 'string' ? JSON.parse(e.body) : undefined;
@@ -189,25 +203,12 @@ class AppsCommand extends base_command_1.BaseCommand {
189
203
  },
190
204
  });
191
205
  }
206
+ // `unconfirmedResponse` is the table above. Beyond it, only what is not an HTTP status: an error this command's own
207
+ // reader raised for a body it could not use.
192
208
  const uncertain = unconfirmedResponse ||
193
- status === 0 ||
194
- status === 401 ||
195
- status === 408 ||
196
- status === 425 ||
197
- (status === 429 && !confirmedRate) ||
198
- (status !== undefined && status >= 300 && status <= 399) ||
199
- (status === 403 &&
200
- (failure === null ||
201
- (failure.kind === 'refusal' &&
202
- (failure.code === 'rate' || failure.code === 'unavailable')))) ||
203
- (status !== undefined && status >= 500 && status <= 599) ||
204
209
  code === 'APP_DATA_UNCONFIRMED_RESPONSE' ||
205
210
  code === 'NON_JSON_RESPONSE' ||
206
- e?.name === 'SyntaxError' ||
207
- (status === undefined &&
208
- (e?.name === 'AbortError' ||
209
- /^(ECONN|EPIPE|ETIMEDOUT|UND_ERR_)/.test(code) ||
210
- /fetch failed|network error/i.test(message)));
211
+ e?.name === 'SyntaxError';
211
212
  if (target.verb && target.requestStarted && uncertain) {
212
213
  const originalCode = safe(code) ?? safe(body?.code);
213
214
  const retryAfterMs = parsedFailure?.kind === 'refusal' &&
@@ -225,6 +226,16 @@ class AppsCommand extends base_command_1.BaseCommand {
225
226
  message: (target.verb === 'batch' && target.batchHasGeneratedIds
226
227
  ? 'The batch may have reached the server, but its outcome is unknown. One or more puts had no ID; if applied, their server-generated IDs may be impossible to identify from this response. Matching document content alone does not prove which write happened. Do not resend blindly; reconcile the batch and any concurrent changes before deciding what to do.'
227
228
  : 'The write may have reached the server, but its outcome is unknown. Read the affected data and revisions before deciding what to do; for a batch, check each affected document. Reconcile concurrent changes before writing again.') +
229
+ (target.idempotencyKey
230
+ ? (0, appData_1.describeKeyedUnknown)({
231
+ bin: this.config.bin,
232
+ installation: target.installation,
233
+ verb: target.verb,
234
+ collection: target.collection,
235
+ id: target.id,
236
+ key: target.idempotencyKey,
237
+ })
238
+ : '') +
228
239
  (status === 401 ? ' A 401 response was received; check your sign-in separately.' : ''),
229
240
  ...(status === undefined || status === 0 ? {} : { status }),
230
241
  ...(requestId ? { requestId } : {}),
@@ -233,6 +244,7 @@ class AppsCommand extends base_command_1.BaseCommand {
233
244
  details: {
234
245
  outcome: 'unknown',
235
246
  operation: target.verb,
247
+ ...(target.idempotencyKey ? { idempotencyKey: target.idempotencyKey } : {}),
236
248
  ...(target.verb === 'batch' && target.batchHasGeneratedIds
237
249
  ? { generatedIdsMayBeUnknown: true }
238
250
  : {}),
@@ -269,18 +281,14 @@ class AppsCommand extends base_command_1.BaseCommand {
269
281
  ...(failure.retryAfterMs === undefined &&
270
282
  failure.index === undefined &&
271
283
  failure.code !== 'unavailable' &&
272
- !(target.operation === 'query' &&
273
- typeof data_provider_1.APP_STORE_CURSOR_INVALID_REASON === 'string' &&
274
- failure.reason === data_provider_1.APP_STORE_CURSOR_INVALID_REASON)
284
+ !(target.operation === 'query' && (0, appData_1.cursorRefusalReason)(failure.reason) !== undefined)
275
285
  ? {}
276
286
  : {
277
287
  details: {
278
288
  ...(failure.retryAfterMs === undefined ? {} : { retryAfterMs: failure.retryAfterMs }),
279
289
  ...(failure.index === undefined ? {} : { index: failure.index }),
280
- ...(target.operation === 'query' &&
281
- typeof data_provider_1.APP_STORE_CURSOR_INVALID_REASON === 'string' &&
282
- failure.reason === data_provider_1.APP_STORE_CURSOR_INVALID_REASON
283
- ? { reason: data_provider_1.APP_STORE_CURSOR_INVALID_REASON }
290
+ ...(target.operation === 'query' && (0, appData_1.cursorRefusalReason)(failure.reason) !== undefined
291
+ ? { reason: (0, appData_1.cursorRefusalReason)(failure.reason) }
284
292
  : {}),
285
293
  ...(failure.code !== 'unavailable'
286
294
  ? {}
@@ -84,6 +84,7 @@ function scanSandbox(sections, options) {
84
84
  })),
85
85
  inlineScripts: scan.inlineScripts,
86
86
  inlineModules: scan.inlineModules,
87
+ inlineHandlers: scan.inlineHandlers,
87
88
  inlineCoverageComplete: scan.inlineCoverageComplete,
88
89
  };
89
90
  }
@@ -162,7 +163,7 @@ function formatAppCheckReport(report) {
162
163
  if (security) {
163
164
  lines.push(storeLine(report));
164
165
  if (!security.scan.complete) {
165
- lines.push(`scan: stopped before the end (${security.scan.filesSkipped} of ${security.scan.filesScanned + security.scan.filesSkipped} files not read in full).`);
166
+ lines.push(`scan: did not read everything (${security.scan.filesSkipped} of ${security.scan.filesScanned + security.scan.filesSkipped} files not read in full).`);
166
167
  }
167
168
  if (security.disabledRules.length > 0) {
168
169
  lines.push(`policy: ${security.disabledRules.length} rule(s) switched off: ${security.disabledRules.join(', ')}`);
@@ -199,7 +200,20 @@ function formatAppCheckReport(report) {
199
200
  if (issue.fix)
200
201
  lines.push(` fix: ${issue.fix}`);
201
202
  if (count > 5 && shown === 2) {
202
- lines.push(` ${count - 3} more matching warning${count - 3 === 1 ? '' : 's'}. Run with --json to see every occurrence.`);
203
+ lines.push(` ${count - 3} more matching warning${count - 3 === 1 ? '' : 's'}. Run with --json to see every one the report lists.`);
204
+ }
205
+ }
206
+ // What the check itself left off: one code repeated in one file past the report's bound. The counts above are exact; this is
207
+ // where the missing lines went, and it reads from the report as it is, so a capped report prints the same way.
208
+ const omitted = report.omitted;
209
+ if (omitted && omitted.count > 0) {
210
+ lines.push('', `${omitted.count} more finding${omitted.count === 1 ? ' is' : 's are'} counted and not listed (the report keeps the first ${omitted.limit} of a code in a file):`);
211
+ for (const group of omitted.groups) {
212
+ lines.push(` ${group.omitted} more ${group.code}${group.path ? ` ${group.path}` : ''}${group.errors > 0 ? ` (${group.errors} of them error${group.errors === 1 ? '' : 's'})` : ''}`);
213
+ }
214
+ const named = omitted.groups.reduce((total, group) => total + group.omitted, 0);
215
+ if (named < omitted.count) {
216
+ lines.push(` ${omitted.count - named} more in other files`);
203
217
  }
204
218
  }
205
219
  if (security) {
@@ -66,6 +66,12 @@ export declare function listMarketplaceIncidentAudit(kind: string, incidentId: s
66
66
  export declare function resolveIntegrityIncident(incidentId: string, body: Record<string, unknown>): Promise<unknown>;
67
67
  /** `POST /admin/marketplace/fulfillment-reconciliations/:id/retry` — run it again. */
68
68
  export declare function retryFulfillmentReconciliation(reconciliationId: string, body?: Record<string, unknown>): Promise<unknown>;
69
+ /**
70
+ * `POST /admin/marketplace/fulfillment-reconciliations/:id/release-hold` — record a decision
71
+ * to release a refund that a replacement Agent holding the install's id has been holding, and
72
+ * run it. The actor is the authenticated admin; the body carries the reason and evidence.
73
+ */
74
+ export declare function releaseFulfillmentReplacementHold(reconciliationId: string, body: Record<string, unknown>): Promise<unknown>;
69
75
  /** `POST /admin/products` — create a product. Body is the server's schema. */
70
76
  export declare function createCommerceProduct(body: Record<string, unknown>): Promise<unknown>;
71
77
  /** `POST /admin/offers` — create an offer VERSION. Body is the server's schema. */
@@ -8,6 +8,7 @@ exports.getMarketplaceIncident = getMarketplaceIncident;
8
8
  exports.listMarketplaceIncidentAudit = listMarketplaceIncidentAudit;
9
9
  exports.resolveIntegrityIncident = resolveIntegrityIncident;
10
10
  exports.retryFulfillmentReconciliation = retryFulfillmentReconciliation;
11
+ exports.releaseFulfillmentReplacementHold = releaseFulfillmentReplacementHold;
11
12
  exports.createCommerceProduct = createCommerceProduct;
12
13
  exports.createCommerceOfferVersion = createCommerceOfferVersion;
13
14
  exports.validateCommerceOffer = validateCommerceOffer;
@@ -81,6 +82,14 @@ async function resolveIntegrityIncident(incidentId, body) {
81
82
  async function retryFulfillmentReconciliation(reconciliationId, body = {}) {
82
83
  return (0, api_fetch_1.apiFetch)(`/api/commerce/admin/marketplace/fulfillment-reconciliations/${encodeURIComponent(reconciliationId)}/retry`, { method: 'POST', body });
83
84
  }
85
+ /**
86
+ * `POST /admin/marketplace/fulfillment-reconciliations/:id/release-hold` — record a decision
87
+ * to release a refund that a replacement Agent holding the install's id has been holding, and
88
+ * run it. The actor is the authenticated admin; the body carries the reason and evidence.
89
+ */
90
+ async function releaseFulfillmentReplacementHold(reconciliationId, body) {
91
+ return (0, api_fetch_1.apiFetch)(`/api/commerce/admin/marketplace/fulfillment-reconciliations/${encodeURIComponent(reconciliationId)}/release-hold`, { method: 'POST', body });
92
+ }
84
93
  /** `POST /admin/products` — create a product. Body is the server's schema. */
85
94
  async function createCommerceProduct(body) {
86
95
  return (0, api_fetch_1.apiFetch)('/api/commerce/admin/products', { method: 'POST', body });
@@ -1224,8 +1224,22 @@ export declare function renderDutyMetrics(response: ReadModelRecord, log: (line:
1224
1224
  * cost census predates the current rule is visible in the table.
1225
1225
  */
1226
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.";
1227
1239
  /** Human view for the case list — one row per durable problem case. */
1228
- 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;
1229
1243
  /**
1230
1244
  * Human view for one case — a bounded digest, never the raw document.
1231
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
  }
@@ -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,