@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
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VersionFileInputError = exports.VersionFileNotListedError = exports.VersionFileIntegrityError = exports.VERSION_FILE_INTEGRITY_EXIT = exports.VERSION_FILE_INTEGRITY_CODE = exports.VERSION_FILE_READ_MAX_BYTES = void 0;
4
+ exports.readVersionFile = readVersionFile;
5
+ exports.isBinary = isBinary;
6
+ exports.escapeForTerminal = escapeForTerminal;
7
+ /**
8
+ * `skrr apps version cat`: read the full text of a file of a FROZEN version, and prove it is the file the version's hash covers.
9
+ *
10
+ * A reviewer is asked to approve a version by its `bundleHash`. `apps version show` lists the files with their sizes and
11
+ * digests, but a digest is not something a person can read; `apps file cat` reads the MUTABLE draft, which may have moved
12
+ * since. This reads the version, a slice at a time, and refuses to hand over anything it has not checked itself:
13
+ *
14
+ * 1. the version's file list must hash to its `bundleHash` (`appBundlePreimage`), so the digests below are the ones the
15
+ * version's identity, and any consent bound to it, rests on;
16
+ * 2. the path must be one of those files, exactly;
17
+ * 3. every slice must name the same version, bundle, path, digest and size as that record, start where the last one ended,
18
+ * be exactly as long as was asked for (or what is left), and hash to the `chunkSha256` it states;
19
+ * 4. when the whole file was read, all the slices joined must hash to the record's `sha256` and be `size` bytes long.
20
+ *
21
+ * The server verifies the stored bytes against the same record before it serves a slice (`AppAuthoring/versionFile.js`); this
22
+ * does not take its word for it. Nothing here writes: the caller gets the bytes only after every check has passed, because a
23
+ * file that fails on its last slice has already been half printed by anything that streams. The bytes are bounded (a package
24
+ * file is at most a few hundred KB), so holding them costs nothing, and the bound is enforced so that a server that claims
25
+ * more cannot make a terminal command hold it.
26
+ *
27
+ * A read that starts after byte 0, or stops before the end (`--offset`, `--limit`), cannot check the file's digest; it says so
28
+ * (`wholeFileVerified: false`) and still checks every slice it did read.
29
+ */
30
+ const node_crypto_1 = require("node:crypto");
31
+ const data_provider_1 = require("@skrr-ai/data-provider");
32
+ const json_output_1 = require("./json-output");
33
+ /** The most a read will hold. A package file is far smaller (`APP_DRAFT_LIMITS`); a server that says otherwise is not believed. */
34
+ exports.VERSION_FILE_READ_MAX_BYTES = 8 * 1024 * 1024;
35
+ /** The machine code and exit under which a mismatch is reported. A distinct exit: a harness must not read "6" as an ordinary failure. */
36
+ exports.VERSION_FILE_INTEGRITY_CODE = 'APP_VERSION_FILE_INTEGRITY';
37
+ exports.VERSION_FILE_INTEGRITY_EXIT = 6;
38
+ /** The bytes are not provably the version's. Carries what disagreed; never the bytes. */
39
+ class VersionFileIntegrityError extends Error {
40
+ kind;
41
+ details;
42
+ constructor(kind, message, details = {}) {
43
+ super(message);
44
+ this.kind = kind;
45
+ this.details = details;
46
+ this.name = 'VersionFileIntegrityError';
47
+ }
48
+ }
49
+ exports.VersionFileIntegrityError = VersionFileIntegrityError;
50
+ /** The path is not one the version lists. Carries a bounded sample of the ones it does. */
51
+ class VersionFileNotListedError extends Error {
52
+ path;
53
+ listed;
54
+ constructor(path, listed) {
55
+ super(`This version lists no file at "${path}".`);
56
+ this.path = path;
57
+ this.listed = listed;
58
+ this.name = 'VersionFileNotListedError';
59
+ }
60
+ }
61
+ exports.VersionFileNotListedError = VersionFileNotListedError;
62
+ /** The caller asked for something that cannot be read (an offset past the end, a file past what the CLI will hold). */
63
+ class VersionFileInputError extends Error {
64
+ code;
65
+ constructor(code, message) {
66
+ super(message);
67
+ this.code = code;
68
+ this.name = 'VersionFileInputError';
69
+ }
70
+ }
71
+ exports.VersionFileInputError = VersionFileInputError;
72
+ const sha256Hex = (bytes) => (0, node_crypto_1.createHash)('sha256').update(bytes).digest('hex');
73
+ /** Base64 as `Buffer.from` would decode it, or null when the text is not canonical base64 (`Buffer` skips what it does not know). */
74
+ function strictBase64(text) {
75
+ if (typeof text !== 'string')
76
+ return null;
77
+ const bytes = Buffer.from(text, 'base64');
78
+ return bytes.toString('base64') === text ? bytes : null;
79
+ }
80
+ /**
81
+ * Read `path` of `versionId` from `offset` for at most `limit` bytes (to the end when absent), checking everything the file
82
+ * header lists, and return the bytes only if all of it held. Throws {@link VersionFileIntegrityError},
83
+ * {@link VersionFileNotListedError} or {@link VersionFileInputError}; anything else is the API's own failure and is the
84
+ * caller's to say.
85
+ */
86
+ async function readVersionFile(reader, input) {
87
+ const { versionId, path } = input;
88
+ const offset = input.offset ?? 0;
89
+ const { version } = await reader.getVersion(versionId);
90
+ // 1. the list the digests come from is the list the version's identity covers
91
+ let preimage;
92
+ try {
93
+ preimage = (0, data_provider_1.appBundlePreimage)(version.files);
94
+ }
95
+ catch {
96
+ throw new VersionFileIntegrityError('bundle_hash', "The version's file list cannot be hashed, so its digests cannot be tied to its bundle hash.");
97
+ }
98
+ if (sha256Hex(Buffer.from(preimage, 'utf8')) !== version.bundleHash) {
99
+ throw new VersionFileIntegrityError('bundle_hash', "The version's file list does not hash to its bundle hash, so its file digests are not the ones the version is identified by.", { bundleHash: version.bundleHash });
100
+ }
101
+ // 2. exactly one of those files
102
+ const record = version.files.find((file) => file.path === path);
103
+ if (!record) {
104
+ throw new VersionFileNotListedError(path, version.files.map((file) => file.path).slice(0, 50));
105
+ }
106
+ const total = record.size;
107
+ if (total > exports.VERSION_FILE_READ_MAX_BYTES) {
108
+ throw new VersionFileInputError('APP_VERSION_FILE_TOO_LARGE', `"${path}" is ${total} bytes; this command holds at most ${exports.VERSION_FILE_READ_MAX_BYTES} bytes of a file. A package file is far smaller, so the version's record is not believed.`);
109
+ }
110
+ if (offset > total) {
111
+ throw new VersionFileInputError('APP_VERSION_FILE_OFFSET', `--offset ${offset} is past the end of "${path}", which is ${total} bytes.`);
112
+ }
113
+ const end = input.limit === undefined ? total : Math.min(total, offset + input.limit);
114
+ // 3. every slice, against the record
115
+ const parts = [];
116
+ const whole = offset === 0 ? (0, node_crypto_1.createHash)('sha256') : null;
117
+ let at = offset;
118
+ let chunks = 0;
119
+ for (;;) {
120
+ // an empty window (an empty file, or an offset at the end) still asks once, so the server vouches for the file it is empty of
121
+ const want = Math.max(1, Math.min(data_provider_1.APP_VERSION_FILE_LIMITS.chunkBytesMax, end - at));
122
+ const expectedLength = Math.min(want, total - at);
123
+ const chunk = await reader.readChunk(versionId, { path, offset: at, limit: want });
124
+ chunks += 1;
125
+ if (chunk.versionId !== versionId ||
126
+ chunk.bundleHash !== version.bundleHash ||
127
+ chunk.path !== path ||
128
+ chunk.fileSha256 !== record.sha256 ||
129
+ chunk.total !== record.size) {
130
+ throw new VersionFileIntegrityError('record', `A slice of "${path}" does not name the version, path, digest and size the version recorded.`, { at });
131
+ }
132
+ const reachesEnd = at + expectedLength >= total;
133
+ if (chunk.offset !== at ||
134
+ chunk.length !== expectedLength ||
135
+ chunk.done !== reachesEnd ||
136
+ chunk.nextOffset !== (reachesEnd ? null : at + expectedLength)) {
137
+ throw new VersionFileIntegrityError('continuity', `A slice of "${path}" is not the one asked for at byte ${at}.`, { at });
138
+ }
139
+ const bytes = strictBase64(chunk.contentBase64);
140
+ if (bytes === null || bytes.length !== chunk.length || sha256Hex(bytes) !== chunk.chunkSha256) {
141
+ throw new VersionFileIntegrityError('chunk_digest', `The slice of "${path}" at byte ${at} is not the bytes its digest names.`, { at });
142
+ }
143
+ parts.push(bytes);
144
+ whole?.update(bytes);
145
+ at += bytes.length;
146
+ if (at >= end)
147
+ break;
148
+ }
149
+ // 4. the whole file, when the whole file was read
150
+ const joined = Buffer.concat(parts);
151
+ const wholeFile = offset === 0 && at === total;
152
+ if (wholeFile && (joined.length !== record.size || whole?.digest('hex') !== record.sha256)) {
153
+ throw new VersionFileIntegrityError('file_digest', `The slices of "${path}" joined are not the ${record.size} bytes with the digest this version recorded.`, { expectedBytes: record.size, readBytes: joined.length });
154
+ }
155
+ return {
156
+ versionId,
157
+ bundleHash: version.bundleHash,
158
+ path,
159
+ offset,
160
+ length: joined.length,
161
+ total,
162
+ fileSha256: record.sha256,
163
+ chunks,
164
+ wholeFileVerified: wholeFile,
165
+ bytes: joined,
166
+ };
167
+ }
168
+ /** True when these bytes cannot be shown as text: a NUL, or not valid UTF-8. */
169
+ function isBinary(bytes) {
170
+ if (bytes.includes(0))
171
+ return true;
172
+ try {
173
+ new TextDecoder('utf-8', { fatal: true }).decode(bytes);
174
+ return false;
175
+ }
176
+ catch {
177
+ return true;
178
+ }
179
+ }
180
+ /**
181
+ * What a terminal would act on rather than show: C0 controls other than newline, tab and a carriage return that belongs to
182
+ * a CRLF; DEL and C1; and the invisible and direction-changing characters (zero-width, bidi overrides and isolates, line and
183
+ * paragraph separators, the byte-order mark, tag characters). The last group is what makes reviewed code differ from the
184
+ * code a compiler reads ("Trojan Source"), and an escape sequence is what lets a file repaint a reviewer's screen.
185
+ */
186
+ const TERMINAL_UNSAFE = new RegExp(`[\\u0000-\\u0008\\u000b\\u000c\\u000e-\\u001f]|\\r(?!\\n)|${json_output_1.JSON_TERMINAL_CONTROLS.source}`, 'gu');
187
+ /** The text with every unsafe character shown as `\u{hex}`, and how many there were. The bytes are not changed by `--raw` or `--out`. */
188
+ function escapeForTerminal(text) {
189
+ let escaped = 0;
190
+ const out = text.replace(TERMINAL_UNSAFE, (char) => {
191
+ escaped += 1;
192
+ return `\\u{${char.codePointAt(0).toString(16)}}`;
193
+ });
194
+ return { text: out, escaped };
195
+ }
@@ -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
  ? {}
@@ -83,6 +83,9 @@ function scanSandbox(sections, options) {
83
83
  ...(found.fix ? { fix: found.fix } : {}),
84
84
  })),
85
85
  inlineScripts: scan.inlineScripts,
86
+ inlineModules: scan.inlineModules,
87
+ inlineHandlers: scan.inlineHandlers,
88
+ inlineCoverageComplete: scan.inlineCoverageComplete,
86
89
  };
87
90
  }
88
91
  /** Check a package that is already in memory. */
@@ -91,6 +94,7 @@ function checkLocalFiles(files, options = {}) {
91
94
  ...(options.expectedId === undefined ? {} : { expectedId: options.expectedId }),
92
95
  ...(options.assetBytes === undefined ? {} : { assetBytes: options.assetBytes }),
93
96
  checkScriptSyntax: compileScript,
97
+ checkModuleSyntax: widgetStaticScan_1.checkModuleSyntax,
94
98
  scanSandbox,
95
99
  });
96
100
  }
@@ -124,8 +128,16 @@ function placeOf(issue) {
124
128
  // in the full JSON report; errors are always shown individually.
125
129
  function warningDisplayKey(issue) {
126
130
  return JSON.stringify([
127
- issue.source, issue.code, issue.path, issue.at, issue.message, issue.fix,
128
- issue.heuristic, issue.tier, issue.unanalyzable, issue.evidence,
131
+ issue.source,
132
+ issue.code,
133
+ issue.path,
134
+ issue.at,
135
+ issue.message,
136
+ issue.fix,
137
+ issue.heuristic,
138
+ issue.tier,
139
+ issue.unanalyzable,
140
+ issue.evidence,
129
141
  ]);
130
142
  }
131
143
  /** The report as lines for a terminal: the verdict, then each finding with where it is and what to do. */
@@ -151,7 +163,7 @@ function formatAppCheckReport(report) {
151
163
  if (security) {
152
164
  lines.push(storeLine(report));
153
165
  if (!security.scan.complete) {
154
- 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).`);
155
167
  }
156
168
  if (security.disabledRules.length > 0) {
157
169
  lines.push(`policy: ${security.disabledRules.length} rule(s) switched off: ${security.disabledRules.join(', ')}`);
@@ -168,8 +180,8 @@ function formatAppCheckReport(report) {
168
180
  }
169
181
  for (const issue of report.issues) {
170
182
  const key = issue.severity === 'warn' ? warningDisplayKey(issue) : undefined;
171
- const count = key === undefined ? 0 : warningCounts.get(key) ?? 0;
172
- const shown = key === undefined ? 0 : warningsShown.get(key) ?? 0;
183
+ const count = key === undefined ? 0 : (warningCounts.get(key) ?? 0);
184
+ const shown = key === undefined ? 0 : (warningsShown.get(key) ?? 0);
173
185
  if (count > 5 && shown >= 3)
174
186
  continue;
175
187
  if (key !== undefined)
@@ -188,7 +200,20 @@ function formatAppCheckReport(report) {
188
200
  if (issue.fix)
189
201
  lines.push(` fix: ${issue.fix}`);
190
202
  if (count > 5 && shown === 2) {
191
- 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`);
192
217
  }
193
218
  }
194
219
  if (security) {
@@ -0,0 +1,21 @@
1
+ import { CHAT_RECHECK_CONDITIONS } from '@skrr-ai/data-provider';
2
+ import type { ChatRecheckCondition, ChatRecheckProposal, ChatSupervisionControl } from '@skrr-ai/data-provider';
3
+ export declare const chatSupervisionPath: (agentId: string, suffix?: string) => string;
4
+ export declare const chatRecheckPath: (agentId: string, watchId: string) => string;
5
+ /** All authority and current revisions are checked server-side. No CLI cache,
6
+ * ambient workspace, runtime header or response text is an execution grant. */
7
+ export declare function requestChatRecheck(agentId: string, watchId: string, input: ChatRecheckProposal): Promise<unknown>;
8
+ export declare function cancelChatRecheck(agentId: string, watchId: string, input: {
9
+ expectedPlanRevision: number;
10
+ expectedRecheckId: string;
11
+ }): Promise<unknown>;
12
+ export { CHAT_RECHECK_CONDITIONS };
13
+ export type { ChatRecheckCondition };
14
+ /** These are owner controls. Authenticated runtime actors remain subject to
15
+ * the API's owner provenance gate; this transport supplies no impersonation. */
16
+ export declare function setChatSupervision(agentId: string, input: ChatSupervisionControl): Promise<unknown>;
17
+ export declare function setChatSupervisionEnrollment(agentId: string, watchId: string, input: {
18
+ enrollment: 'active' | 'excluded';
19
+ expectedPlanRevision: number;
20
+ }): Promise<unknown>;
21
+ export declare function requestChatInspection(agentId: string): Promise<unknown>;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CHAT_RECHECK_CONDITIONS = exports.chatRecheckPath = exports.chatSupervisionPath = void 0;
4
+ exports.requestChatRecheck = requestChatRecheck;
5
+ exports.cancelChatRecheck = cancelChatRecheck;
6
+ exports.setChatSupervision = setChatSupervision;
7
+ exports.setChatSupervisionEnrollment = setChatSupervisionEnrollment;
8
+ exports.requestChatInspection = requestChatInspection;
9
+ const data_provider_1 = require("@skrr-ai/data-provider");
10
+ Object.defineProperty(exports, "CHAT_RECHECK_CONDITIONS", { enumerable: true, get: function () { return data_provider_1.CHAT_RECHECK_CONDITIONS; } });
11
+ const api_fetch_1 = require("./api-fetch");
12
+ const chatSupervisionPath = (agentId, suffix = '') => `/api/agents/${encodeURIComponent(agentId)}/dm/supervision${suffix}`;
13
+ exports.chatSupervisionPath = chatSupervisionPath;
14
+ const chatRecheckPath = (agentId, watchId) => (0, exports.chatSupervisionPath)(agentId, `/chats/${encodeURIComponent(watchId)}/recheck`);
15
+ exports.chatRecheckPath = chatRecheckPath;
16
+ /** All authority and current revisions are checked server-side. No CLI cache,
17
+ * ambient workspace, runtime header or response text is an execution grant. */
18
+ function requestChatRecheck(agentId, watchId, input) {
19
+ return (0, api_fetch_1.apiFetch)((0, exports.chatRecheckPath)(agentId, watchId), { method: 'POST', body: input });
20
+ }
21
+ function cancelChatRecheck(agentId, watchId, input) {
22
+ return (0, api_fetch_1.apiFetch)((0, exports.chatRecheckPath)(agentId, watchId), { method: 'DELETE', body: input });
23
+ }
24
+ /** These are owner controls. Authenticated runtime actors remain subject to
25
+ * the API's owner provenance gate; this transport supplies no impersonation. */
26
+ function setChatSupervision(agentId, input) {
27
+ return (0, api_fetch_1.apiFetch)((0, exports.chatSupervisionPath)(agentId), { method: 'PUT', body: input });
28
+ }
29
+ function setChatSupervisionEnrollment(agentId, watchId, input) {
30
+ return (0, api_fetch_1.apiFetch)((0, exports.chatSupervisionPath)(agentId, `/chats/${encodeURIComponent(watchId)}`), {
31
+ method: 'PUT',
32
+ body: input,
33
+ });
34
+ }
35
+ function requestChatInspection(agentId) {
36
+ return (0, api_fetch_1.apiFetch)((0, exports.chatSupervisionPath)(agentId, '/inspect'), { method: 'POST', body: {} });
37
+ }
@@ -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 });