@skrr-ai/cli 0.1.155 → 0.1.158
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.
- package/dist/base-command.js +64 -16
- package/dist/commands/activity/list.d.ts +13 -0
- package/dist/commands/activity/list.js +50 -0
- package/dist/commands/activity/scan-older.d.ts +23 -0
- package/dist/commands/activity/scan-older.js +74 -0
- package/dist/commands/activity/show.d.ts +27 -0
- package/dist/commands/activity/show.js +228 -0
- package/dist/commands/agent/message/send.js +64 -19
- package/dist/commands/agents/always-on/held-messages.js +24 -1
- package/dist/commands/agents/always-on/status.js +6 -1
- package/dist/commands/agents/mini-computer/app/reset.d.ts +13 -0
- package/dist/commands/agents/mini-computer/app/reset.js +35 -0
- package/dist/commands/agents/mini-computer/app/set.d.ts +16 -0
- package/dist/commands/agents/mini-computer/app/set.js +70 -0
- package/dist/commands/agents/mini-computer/layout/change.d.ts +14 -0
- package/dist/commands/agents/mini-computer/layout/change.js +44 -0
- package/dist/commands/agents/mini-computer/layout/folder.d.ts +14 -0
- package/dist/commands/agents/mini-computer/layout/folder.js +35 -0
- package/dist/commands/agents/mini-computer/layout/move.d.ts +14 -0
- package/dist/commands/agents/mini-computer/layout/move.js +32 -0
- package/dist/commands/agents/mini-computer/layout/pin.d.ts +14 -0
- package/dist/commands/agents/mini-computer/layout/pin.js +35 -0
- package/dist/commands/agents/mini-computer/layout/remove.d.ts +13 -0
- package/dist/commands/agents/mini-computer/layout/remove.js +27 -0
- package/dist/commands/agents/mini-computer/layout/restore.d.ts +13 -0
- package/dist/commands/agents/mini-computer/layout/restore.js +27 -0
- package/dist/commands/agents/mini-computer/layout/unfolder.d.ts +13 -0
- package/dist/commands/agents/mini-computer/layout/unfolder.js +27 -0
- package/dist/commands/agents/mini-computer/layout/unpin.d.ts +14 -0
- package/dist/commands/agents/mini-computer/layout/unpin.js +34 -0
- package/dist/commands/agents/mini-computer/show.d.ts +13 -0
- package/dist/commands/agents/mini-computer/show.js +60 -0
- package/dist/commands/agents/mini-computer/tasks-view.d.ts +29 -0
- package/dist/commands/agents/mini-computer/tasks-view.js +100 -0
- package/dist/commands/apps/auto-apply.d.ts +14 -0
- package/dist/commands/apps/auto-apply.js +53 -0
- package/dist/commands/apps/check.js +4 -1
- package/dist/commands/apps/create.js +11 -6
- package/dist/commands/apps/data/batch.d.ts +15 -0
- package/dist/commands/apps/data/batch.js +59 -0
- package/dist/commands/apps/data/collections.d.ts +12 -0
- package/dist/commands/apps/data/collections.js +44 -0
- package/dist/commands/apps/data/delete.d.ts +15 -0
- package/dist/commands/apps/data/delete.js +57 -0
- package/dist/commands/apps/data/patch.d.ts +17 -0
- package/dist/commands/apps/data/patch.js +70 -0
- package/dist/commands/apps/data/put.js +1 -1
- package/dist/commands/apps/data/query.js +1 -1
- package/dist/commands/apps/installations/diff.d.ts +14 -0
- package/dist/commands/apps/installations/diff.js +45 -0
- package/dist/commands/apps/installations/events.d.ts +23 -0
- package/dist/commands/apps/installations/events.js +104 -0
- package/dist/commands/apps/installations/snapshot.d.ts +18 -0
- package/dist/commands/apps/installations/snapshot.js +60 -0
- package/dist/commands/apps/installations/versions.d.ts +12 -0
- package/dist/commands/apps/installations/versions.js +38 -0
- package/dist/commands/apps/logs.js +3 -0
- package/dist/commands/apps/preview.js +4 -2
- package/dist/commands/apps/pull.js +10 -1
- package/dist/commands/apps/push.js +36 -12
- package/dist/commands/apps/reference.d.ts +26 -0
- package/dist/commands/apps/reference.js +56 -0
- package/dist/commands/apps/rollback.d.ts +13 -0
- package/dist/commands/apps/rollback.js +47 -0
- package/dist/commands/apps/version/create.js +5 -0
- package/dist/commands/duties/accounting.js +6 -0
- package/dist/commands/duties/analytics/detail.js +6 -0
- package/dist/commands/duties/analytics/index.js +14 -0
- package/dist/commands/duties/analytics/replay.js +6 -0
- package/dist/commands/duties/cost.js +6 -0
- package/dist/commands/duties/delete.js +22 -19
- package/dist/commands/duties/doctor.d.ts +2 -1
- package/dist/commands/duties/doctor.js +17 -3
- package/dist/commands/duties/goals/link.js +4 -0
- package/dist/commands/duties/goals/unlink.js +4 -0
- package/dist/commands/duties/lineage.js +6 -1
- package/dist/commands/duties/links/list.js +6 -0
- package/dist/commands/duties/metrics.js +10 -0
- package/dist/commands/duties/observations.js +12 -0
- package/dist/commands/duties/operating-review.d.ts +4 -30
- package/dist/commands/duties/operating-review.js +28 -141
- package/dist/commands/duties/receipt-metrics.js +7 -0
- package/dist/commands/duties/receipt.js +7 -0
- package/dist/commands/duties/roster.js +14 -8
- package/dist/commands/duties/show.js +27 -9
- package/dist/commands/duties/status.js +18 -9
- package/dist/commands/duties/trigger-status.d.ts +2 -0
- package/dist/commands/duties/trigger-status.js +19 -1
- package/dist/commands/duties/wake-capabilities.d.ts +2 -0
- package/dist/commands/duties/wake-capabilities.js +32 -2
- package/dist/commands/followups/act.js +3 -0
- package/dist/commands/followups/remind.js +12 -3
- package/dist/commands/followups/show.js +6 -0
- package/dist/commands/harnesses/quota.js +1 -1
- package/dist/commands/spaces/notebook.d.ts +3 -7
- package/dist/commands/spaces/notebook.js +32 -8
- package/dist/commands/tasks/create.d.ts +2 -2
- package/dist/commands/tasks/create.js +3 -3
- package/dist/commands/tasks/list.d.ts +3 -41
- package/dist/commands/tasks/list.js +5 -53
- package/dist/generated/agent-guides.json +424 -101
- package/dist/generated/managed-instruction-guides.json +1 -1
- package/dist/lib/agent-activity.d.ts +153 -0
- package/dist/lib/agent-activity.js +241 -0
- package/dist/lib/always-on-runtime.d.ts +9 -0
- package/dist/lib/always-on-runtime.js +20 -0
- package/dist/lib/api-fetch.d.ts +10 -0
- package/dist/lib/api-fetch.js +12 -2
- package/dist/lib/appData.d.ts +28 -1
- package/dist/lib/appData.js +111 -9
- package/dist/lib/appInstallations.d.ts +9 -1
- package/dist/lib/appInstallations.js +100 -0
- package/dist/lib/apps-command.d.ts +1 -0
- package/dist/lib/apps-command.js +11 -0
- package/dist/lib/apps.d.ts +12 -0
- package/dist/lib/apps.js +28 -1
- package/dist/lib/appsAssets.d.ts +17 -0
- package/dist/lib/appsAssets.js +15 -0
- package/dist/lib/appsCheck.d.ts +1 -0
- package/dist/lib/appsCheck.js +1 -0
- package/dist/lib/appsFs.d.ts +18 -1
- package/dist/lib/appsFs.js +76 -19
- package/dist/lib/compasses.js +6 -0
- package/dist/lib/duties.d.ts +25 -2
- package/dist/lib/duties.js +58 -3
- package/dist/lib/duty-analytics.d.ts +2 -0
- package/dist/lib/duty-analytics.js +26 -0
- package/dist/lib/duty-goal-propagation.d.ts +2 -0
- package/dist/lib/duty-goal-propagation.js +18 -0
- package/dist/lib/duty-history-source.d.ts +4 -0
- package/dist/lib/duty-history-source.js +12 -0
- package/dist/lib/duty-ledgers.d.ts +4 -0
- package/dist/lib/duty-ledgers.js +4 -0
- package/dist/lib/duty-receipt-source.d.ts +4 -0
- package/dist/lib/duty-receipt-source.js +19 -0
- package/dist/lib/followups.d.ts +20 -0
- package/dist/lib/followups.js +10 -0
- package/dist/lib/held-messages.d.ts +22 -0
- package/dist/lib/held-messages.js +55 -0
- package/dist/lib/list-workspace.d.ts +40 -0
- package/dist/lib/list-workspace.js +58 -0
- package/dist/lib/miniComputer.d.ts +59 -0
- package/dist/lib/miniComputer.js +224 -0
- package/dist/lib/miniComputerCommand.d.ts +13 -0
- package/dist/lib/miniComputerCommand.js +48 -0
- package/dist/lib/roles.d.ts +3 -3
- package/dist/lib/space-notebook.js +15 -4
- package/dist/node_modules/@skrr-ai/data-provider/index.js +10465 -8383
- package/oclif.manifest.json +2849 -462
- package/package.json +14 -2
package/dist/lib/appData.js
CHANGED
|
@@ -8,9 +8,12 @@ exports.personDataFailureExit = personDataFailureExit;
|
|
|
8
8
|
exports.personDataFailureRetryable = personDataFailureRetryable;
|
|
9
9
|
exports.describePersonDataRefusal = describePersonDataRefusal;
|
|
10
10
|
exports.describePersonDataConflict = describePersonDataConflict;
|
|
11
|
+
exports.readPatchInput = readPatchInput;
|
|
12
|
+
exports.readBatchInput = readBatchInput;
|
|
11
13
|
exports.safeForTerminal = safeForTerminal;
|
|
12
14
|
exports.formatDocument = formatDocument;
|
|
13
15
|
exports.formatQueryResult = formatQueryResult;
|
|
16
|
+
exports.formatCollections = formatCollections;
|
|
14
17
|
/**
|
|
15
18
|
* `skrr apps data put | query`: what the commands that write and read an installed app's OWN documents, as the
|
|
16
19
|
* signed-in person, share. The domain lib of the person channel; the authoring loop's is `lib/apps.ts` and the
|
|
@@ -137,6 +140,7 @@ function readPersonDataFailure(error) {
|
|
|
137
140
|
conflict,
|
|
138
141
|
...status,
|
|
139
142
|
...(typeof body.currentRev === 'number' ? { currentRev: body.currentRev } : {}),
|
|
143
|
+
...(typeof body.index === 'number' ? { index: body.index } : {}),
|
|
140
144
|
};
|
|
141
145
|
}
|
|
142
146
|
const code = data_provider_1.APP_PERSON_DATA_REFUSALS.includes(body.code)
|
|
@@ -180,9 +184,9 @@ function personDataFailureRetryable(failure) {
|
|
|
180
184
|
return failure.kind === 'refusal' && (failure.code === 'rate' || failure.code === 'unavailable');
|
|
181
185
|
}
|
|
182
186
|
const REFUSAL_WORDS = {
|
|
183
|
-
human_only: (bin) => `Only a signed-in person can
|
|
187
|
+
human_only: (bin) => `Only a signed-in person, or an Agent's credential on a machine (the one the platform gives a harness it launched, or a Hosted Machine's own sign-in), can use an app's data this way. This credential is neither (an access token). Sign in as yourself with \`${bin} login\`.`,
|
|
184
188
|
not_found: () => 'There is no such installation that you can see.',
|
|
185
|
-
not_granted: () => '
|
|
189
|
+
not_granted: () => 'This credential may not write this collection here. The running version must list it in capabilities.store and name the writer you are in its write list ("person" for a signed-in person, "agent" for an Agent\'s credential), and the person who installed the app must have approved that. Nothing was written.',
|
|
186
190
|
forbidden_by_viewer: () => 'You do not have permission to do this on the agent this app is installed on (writing needs edit access, reading needs view access). Nothing was written.',
|
|
187
191
|
grant_stale: (bin) => `This app changed since it was approved. Approve it again with \`${bin} apps reconsent <installation>\` and try again.`,
|
|
188
192
|
schema: () => 'The request does not fit this operation (the collection name, the document id, the document, or a query parameter). Nothing was written.',
|
|
@@ -204,28 +208,98 @@ function describePersonDataRefusal(failure, bin) {
|
|
|
204
208
|
*/
|
|
205
209
|
function describePersonDataConflict(failure, target, bin) {
|
|
206
210
|
const read = `${bin} apps data query ${target.installation} ${target.collection} --id ${target.id}`;
|
|
211
|
+
const verb = target.verb ?? 'put';
|
|
212
|
+
const where = verb === 'batch'
|
|
213
|
+
? `write number ${failure.index ?? '(unknown)'} of the batch`
|
|
214
|
+
: `${target.collection}/${target.id}`;
|
|
215
|
+
const nothing = verb === 'batch' ? 'Nothing in the batch was written.' : '';
|
|
207
216
|
switch (failure.conflict) {
|
|
208
217
|
case 'rev_mismatch':
|
|
209
218
|
return [
|
|
210
|
-
`Not written: ${
|
|
211
|
-
`→ Read it again (\`${read}\`), merge, and retry with --expected-rev ${failure.currentRev ?? '<its revision>'}.`,
|
|
219
|
+
`Not ${verb === 'delete' ? 'deleted' : 'written'}: ${where} is at revision ${failure.currentRev ?? '(unknown)'}, not the one you named. ${nothing}`.trim(),
|
|
220
|
+
`→ Read it again (\`${read}\`), ${verb === 'delete' ? 'check it is still the one you mean' : 'merge'}, and retry with --expected-rev ${failure.currentRev ?? '<its revision>'}.`,
|
|
212
221
|
].join('\n');
|
|
213
222
|
case 'exists':
|
|
214
223
|
return [
|
|
215
|
-
`Not written: ${
|
|
224
|
+
`Not written: ${where} already exists${failure.currentRev === undefined ? '' : ` (revision ${failure.currentRev})`}, and --expected-rev 0 only creates. ${nothing}`.trim(),
|
|
216
225
|
`→ Read it (\`${read}\`) and replace it with --expected-rev ${failure.currentRev ?? '<its revision>'}, or leave --expected-rev out to overwrite whatever is there.`,
|
|
217
226
|
].join('\n');
|
|
218
227
|
case 'not_found':
|
|
219
|
-
return
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
228
|
+
return verb === 'put' || verb === 'batch'
|
|
229
|
+
? [
|
|
230
|
+
`Not written: there is no document ${where} to replace. ${nothing}`.trim(),
|
|
231
|
+
`→ Create it with --expected-rev 0, or leave --expected-rev out.`,
|
|
232
|
+
].join('\n')
|
|
233
|
+
: [
|
|
234
|
+
`Not ${verb === 'delete' ? 'deleted' : 'changed'}: there is no document ${target.collection}/${target.id}.`,
|
|
235
|
+
verb === 'patch'
|
|
236
|
+
? `→ A patch changes a document that exists; create it with \`${bin} apps data put\`.`
|
|
237
|
+
: `→ It may already be gone (\`${read}\`).`,
|
|
238
|
+
].join('\n');
|
|
223
239
|
default: {
|
|
224
240
|
const never = failure.conflict;
|
|
225
241
|
return String(never);
|
|
226
242
|
}
|
|
227
243
|
}
|
|
228
244
|
}
|
|
245
|
+
// ── patch and batch input ───────────────────────────────────────────────────
|
|
246
|
+
/** The `set` of a patch (a JSON object of path -> value) and the `unset` paths. What a path may be is the server's parser's to say. */
|
|
247
|
+
function readPatchInput(input) {
|
|
248
|
+
if (input.set === undefined && (input.unset === undefined || input.unset.length === 0)) {
|
|
249
|
+
throw new AppDataInputError('APP_DATA_SOURCE', 'Give --set, --unset, or both.');
|
|
250
|
+
}
|
|
251
|
+
let set;
|
|
252
|
+
if (input.set !== undefined) {
|
|
253
|
+
let parsed;
|
|
254
|
+
try {
|
|
255
|
+
parsed = JSON.parse(input.set);
|
|
256
|
+
}
|
|
257
|
+
catch {
|
|
258
|
+
throw new AppDataInputError('APP_DATA_NOT_JSON', '--set is not JSON.');
|
|
259
|
+
}
|
|
260
|
+
const object = asPlainObject(parsed);
|
|
261
|
+
if (!object) {
|
|
262
|
+
throw new AppDataInputError('APP_DATA_NOT_OBJECT', '--set must be a JSON object of path to value, for example \'{"stats.streak": 4}\'.');
|
|
263
|
+
}
|
|
264
|
+
set = object;
|
|
265
|
+
}
|
|
266
|
+
return {
|
|
267
|
+
...(set === undefined ? {} : { set }),
|
|
268
|
+
...(input.unset === undefined || input.unset.length === 0 ? {} : { unset: input.unset }),
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* The writes of a batch, from exactly one of `--writes`, `--from-file` and `--stdin`: a JSON list, or `{ "writes": [...] }`.
|
|
273
|
+
* Each write is `{ op: "put" | "patch" | "delete", collection, ... }`; the server's parser says what each may hold.
|
|
274
|
+
*/
|
|
275
|
+
async function readBatchInput(input) {
|
|
276
|
+
const given = [input.writes !== undefined, input.fromFile !== undefined, input.stdin === true];
|
|
277
|
+
if (given.filter(Boolean).length !== 1) {
|
|
278
|
+
throw new AppDataInputError('APP_DATA_SOURCE', 'Give the writes with exactly one of --writes, --from-file or --stdin.');
|
|
279
|
+
}
|
|
280
|
+
let text;
|
|
281
|
+
if (input.writes !== undefined) {
|
|
282
|
+
text = input.writes;
|
|
283
|
+
}
|
|
284
|
+
else if (input.fromFile !== undefined) {
|
|
285
|
+
text = (0, appsFs_1.readRegularTextFile)(input.fromFile, input.fromFile);
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
text = await (0, appsFs_1.readStdinText)();
|
|
289
|
+
}
|
|
290
|
+
let parsed;
|
|
291
|
+
try {
|
|
292
|
+
parsed = JSON.parse(text);
|
|
293
|
+
}
|
|
294
|
+
catch {
|
|
295
|
+
throw new AppDataInputError('APP_DATA_NOT_JSON', 'The writes are not JSON.');
|
|
296
|
+
}
|
|
297
|
+
const list = Array.isArray(parsed) ? parsed : asPlainObject(parsed)?.writes;
|
|
298
|
+
if (!Array.isArray(list) || list.some((entry) => asPlainObject(entry) === null)) {
|
|
299
|
+
throw new AppDataInputError('APP_DATA_NOT_OBJECT', 'The writes must be a JSON list of objects, or { "writes": [ ... ] }, each { "op": "put" | "patch" | "delete", "collection": ..., ... }.');
|
|
300
|
+
}
|
|
301
|
+
return { writes: list };
|
|
302
|
+
}
|
|
229
303
|
// ── a document, drawn for a terminal ────────────────────────────────────────
|
|
230
304
|
/**
|
|
231
305
|
* Text that came from an app's data, safe to print: a control character, a C1 control, a line or paragraph separator,
|
|
@@ -272,3 +346,31 @@ function formatQueryResult(result, target, bin) {
|
|
|
272
346
|
}
|
|
273
347
|
/** The limit the reference and this help text share, so a number is never typed twice. */
|
|
274
348
|
exports.PERSON_DATA_QUERY_LIMIT_MAX = data_provider_1.APP_STORE_LIMITS.queryLimitMax;
|
|
349
|
+
// ── what an installation's data holds ───────────────────────────────────────
|
|
350
|
+
/**
|
|
351
|
+
* The catalog of an installation's collections as lines for a terminal. Every name and description is the app author's
|
|
352
|
+
* words, so each goes through {@link safeForTerminal}; the catalog's notice (they are not instructions) ends it.
|
|
353
|
+
*/
|
|
354
|
+
function formatCollections(catalog) {
|
|
355
|
+
const lines = [];
|
|
356
|
+
const { installation } = catalog;
|
|
357
|
+
lines.push(`${safeForTerminal(installation.name ?? installation.id)} (${installation.id}, ${installation.state}${installation.usable ? '' : ', the data tools refuse it right now'})`);
|
|
358
|
+
if (catalog.collections.length === 0) {
|
|
359
|
+
lines.push(' no collections');
|
|
360
|
+
}
|
|
361
|
+
for (const collection of catalog.collections) {
|
|
362
|
+
const writers = collection.writers.join(', ');
|
|
363
|
+
lines.push(` ${safeForTerminal(collection.name)} ${collection.documents} document${collection.documents === 1 ? '' : 's'} written by: ${writers}${collection.agentMayWrite ? ' (an agent may write it)' : ''}${collection.inStore ? '' : ' (not read by the window)'}`);
|
|
364
|
+
if (collection.description) {
|
|
365
|
+
lines.push(` ${safeForTerminal(collection.description)}`);
|
|
366
|
+
}
|
|
367
|
+
if (collection.schema) {
|
|
368
|
+
const fields = collection.schema.fields
|
|
369
|
+
.map((field) => `${safeForTerminal(field.name)}${field.required ? '*' : ''}: ${safeForTerminal(field.type)}`)
|
|
370
|
+
.join(', ');
|
|
371
|
+
lines.push(` fields: ${fields || '(none named)'}${collection.schema.moreFields > 0 ? `, +${collection.schema.moreFields} more` : ''}${collection.schema.closed ? ' (other fields are refused)' : ''}`);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
lines.push(safeForTerminal(catalog.notice));
|
|
375
|
+
return lines;
|
|
376
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AppDisclosureCheck, AppDisclosureFacts, AppHostUnsuitable, AppInstallationJobState, AppInstallationListItem, AppOperatorUnmet } from '@skrr-ai/data-provider';
|
|
1
|
+
import type { AppInstallationVersionsView, AppVersionDiff, AppDisclosureCheck, AppDisclosureFacts, AppHostUnsuitable, AppInstallationJobState, AppInstallationListItem, AppOperatorUnmet } from '@skrr-ai/data-provider';
|
|
2
2
|
import type { AppsRefusal } from './apps';
|
|
3
3
|
/**
|
|
4
4
|
* The words for an availability the contract names. One this CLI does not know (a server newer than the CLI) is said
|
|
@@ -115,3 +115,11 @@ export declare const REPORT_REFUSAL_CODES: Record<string, string>;
|
|
|
115
115
|
export declare function describeReportRefusal(refusal: AppsRefusal, bin: string): string | null;
|
|
116
116
|
/** The exit of a refusal that says "that is not there for you": the same one an unknown app gets. */
|
|
117
117
|
export declare function installationRefusalExit(conflict: string): number;
|
|
118
|
+
/**
|
|
119
|
+
* What the versions view says, as lines a person reads: which version runs, what is waiting and what it needs, the opt-in
|
|
120
|
+
* and where a rollback goes. `needs_reconsent` is said as "asks for more than you approved", never as a verdict on the
|
|
121
|
+
* version, and nothing here says an automatic check makes a version safe.
|
|
122
|
+
*/
|
|
123
|
+
export declare function formatInstallationVersions(view: AppInstallationVersionsView, bin: string): string[];
|
|
124
|
+
/** A diff between two versions, as lines: the capability and job changes first (they are what needs deciding), then the files. */
|
|
125
|
+
export declare function formatVersionDiff(diff: AppVersionDiff): string[];
|
|
@@ -23,6 +23,8 @@ exports.formatUserLayout = formatUserLayout;
|
|
|
23
23
|
exports.readLayoutRefusal = readLayoutRefusal;
|
|
24
24
|
exports.describeReportRefusal = describeReportRefusal;
|
|
25
25
|
exports.installationRefusalExit = installationRefusalExit;
|
|
26
|
+
exports.formatInstallationVersions = formatInstallationVersions;
|
|
27
|
+
exports.formatVersionDiff = formatVersionDiff;
|
|
26
28
|
/**
|
|
27
29
|
* `skrr apps install | installations | reconsent | upgrade | suspend | resume | uninstall | disclosure`: what
|
|
28
30
|
* the installation commands share. The second half of the domain lib of the Agent App commands; the first,
|
|
@@ -119,6 +121,12 @@ const CONSENT_MARK = {
|
|
|
119
121
|
function mark(consent) {
|
|
120
122
|
return CONSENT_MARK[consent] ?? '';
|
|
121
123
|
}
|
|
124
|
+
/** What each item of the `host` capability says (the contract's `APP_HOST_ITEMS`); an item a newer server sent is named, not dropped. */
|
|
125
|
+
const HOST_ITEM_WORDS = {
|
|
126
|
+
notify: 'ask the host to show notices from it in your notification centre (it sends nothing to anyone)',
|
|
127
|
+
badge: 'ask the host to put a number on its icon',
|
|
128
|
+
open_app: 'ask the host to open another of your apps from it',
|
|
129
|
+
};
|
|
122
130
|
const ISOLATION_WORDS = {
|
|
123
131
|
none: 'no isolation beyond the machine it runs on',
|
|
124
132
|
gvisor: 'inside a gVisor sandbox',
|
|
@@ -143,6 +151,10 @@ function describeSchedule(schedule) {
|
|
|
143
151
|
return `every day at ${reading.times.join(' and ')}`;
|
|
144
152
|
case 'every':
|
|
145
153
|
return `every ${reading.count === 1 ? reading.unit.replace(DESCRIBE_SCHEDULE_RE, '') : `${reading.count} ${reading.unit}`}`;
|
|
154
|
+
case 'event':
|
|
155
|
+
return reading.source === 'webhook'
|
|
156
|
+
? `when the app's "${reading.name}" webhook delivers an event (not on a clock)`
|
|
157
|
+
: `when a person or the app changes "${reading.name}" (never when your agent does; not on a clock)`;
|
|
146
158
|
case 'configured':
|
|
147
159
|
return "on a schedule set in the app's settings";
|
|
148
160
|
default:
|
|
@@ -365,6 +377,8 @@ function itemLines(item) {
|
|
|
365
377
|
return item.tools.map((tool) => `call the tool "${tool.name}"${tool.connector ? ` (your ${tool.connector} connection)` : ''}${mark(tool.consent)}`);
|
|
366
378
|
case 'http':
|
|
367
379
|
return item.origins.map((origin) => `have ${data_provider_1.BRAND.displayName} contact ${origin.origin} for it (the app's page has no network of its own); this stops working if the app's code changes, until you approve again${mark(origin.consent)}`);
|
|
380
|
+
case 'host':
|
|
381
|
+
return item.items.map((entry) => `${HOST_ITEM_WORDS[entry.item] ?? `use "${entry.item}"`}${mark(entry.consent)}`);
|
|
368
382
|
case 'act':
|
|
369
383
|
return item.effects.map((effect) => `ask to "${effect.effect}"; it only asks, and a person releases each one under their own name${mark(effect.consent)}`);
|
|
370
384
|
case 'webhooks':
|
|
@@ -805,6 +819,7 @@ const CONFLICT_WORDS = {
|
|
|
805
819
|
principal_scope_unserved: (refusal) => `This app asks for ${describeScopeIssues(refusal.unserved)}, which cannot work for the place it would be installed (an app installed on a person reaches that person's own data, never an agent's or a space's, and has no agent to run it yet).${needsOperator(refusal.unserved)
|
|
806
820
|
? ' An app that needs an agent to run it can, for now, only be installed on one of your agents.'
|
|
807
821
|
: ''} Nothing was installed.`,
|
|
822
|
+
no_previous_version: () => 'This installation has never been moved onto the version it runs, so there is no earlier version to go back to. Nothing was changed.',
|
|
808
823
|
job_schedule_invalid: (refusal, bin) => {
|
|
809
824
|
const issues = Array.isArray(refusal.issues)
|
|
810
825
|
? refusal.issues.length
|
|
@@ -963,3 +978,88 @@ function installationRefusalExit(conflict) {
|
|
|
963
978
|
? 1
|
|
964
979
|
: 4;
|
|
965
980
|
}
|
|
981
|
+
// ── an installation's versions: running, waiting, the opt-in, the way back ────────────────────────────────────────────
|
|
982
|
+
/** Why a version that needs no new approval was still not applied by the opt-in, in a clause. */
|
|
983
|
+
const AUTO_APPLY_HOLD_WORDS = {
|
|
984
|
+
installation_suspended: 'the installation is paused',
|
|
985
|
+
cut_by_another_person: "another person made it, and the opt-in is for your own agents' versions (apply it yourself if you trust it)",
|
|
986
|
+
version_not_installable: 'the version was rejected or withdrawn',
|
|
987
|
+
principal_scope_unserved: 'it declares something this installation cannot serve',
|
|
988
|
+
};
|
|
989
|
+
/**
|
|
990
|
+
* What the versions view says, as lines a person reads: which version runs, what is waiting and what it needs, the opt-in
|
|
991
|
+
* and where a rollback goes. `needs_reconsent` is said as "asks for more than you approved", never as a verdict on the
|
|
992
|
+
* version, and nothing here says an automatic check makes a version safe.
|
|
993
|
+
*/
|
|
994
|
+
function formatInstallationVersions(view, bin) {
|
|
995
|
+
const lines = [];
|
|
996
|
+
lines.push(`${view.installationId} runs v${view.current.version} (${view.current.versionId})`);
|
|
997
|
+
lines.push(view.autoApply.enabled
|
|
998
|
+
? "automatic updates: on (a new version that asks for nothing you haven't approved takes effect by itself)"
|
|
999
|
+
: 'automatic updates: off (a new version waits for you to apply it)');
|
|
1000
|
+
if (!view.viewer.canManage) {
|
|
1001
|
+
lines.push('You can see which version runs. Applying, going back and the history are for people who can edit this installation.');
|
|
1002
|
+
return lines;
|
|
1003
|
+
}
|
|
1004
|
+
if (view.pending) {
|
|
1005
|
+
const pending = view.pending;
|
|
1006
|
+
lines.push(`waiting: v${pending.version} (${pending.versionId})${pending.changelog ? ` - ${(0, data_provider_1.plainAppLabel)(pending.changelog, 120)}` : ''}`);
|
|
1007
|
+
if (pending.status === 'needs_reconsent') {
|
|
1008
|
+
lines.push(' it asks for more than you approved, so it does not run until you approve it:');
|
|
1009
|
+
for (const line of describeGrantReasons(pending.reasons.map((reason) => reason.kind))) {
|
|
1010
|
+
lines.push(` ${line}`);
|
|
1011
|
+
}
|
|
1012
|
+
lines.push(` Review: \`${bin} apps disclosure ${pending.versionId} --installation ${view.installationId}\`; apply: \`${bin} apps upgrade ${view.installationId} --version ${pending.versionId}\`, then \`${bin} apps reconsent ${view.installationId} --yes\`.`);
|
|
1013
|
+
}
|
|
1014
|
+
else if (pending.heldBecause) {
|
|
1015
|
+
lines.push(` it asks for nothing new, but was not applied by itself: ${AUTO_APPLY_HOLD_WORDS[pending.heldBecause]}.`);
|
|
1016
|
+
lines.push(` Apply it with \`${bin} apps upgrade ${view.installationId} --version ${pending.versionId}\`.`);
|
|
1017
|
+
}
|
|
1018
|
+
else {
|
|
1019
|
+
lines.push(` it asks for nothing you haven't approved. Apply it with \`${bin} apps upgrade ${view.installationId} --version ${pending.versionId}\`${view.autoApply.enabled ? '' : `, or turn on automatic updates with \`${bin} apps auto-apply ${view.installationId} on\``}.`);
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
else {
|
|
1023
|
+
lines.push('waiting: nothing (it runs the newest version)');
|
|
1024
|
+
}
|
|
1025
|
+
lines.push(view.rollback
|
|
1026
|
+
? `going back: v${view.rollback.version} (${view.rollback.versionId}) with \`${bin} apps rollback ${view.installationId}\``
|
|
1027
|
+
: 'going back: nothing to go back to');
|
|
1028
|
+
for (const move of view.history.slice(-5)) {
|
|
1029
|
+
lines.push(` ${move.at} ${move.cause}${move.by === 'policy' ? ' (by the platform, on your opt-in)' : ` (${move.by})`} ${move.from} -> ${move.to}`);
|
|
1030
|
+
}
|
|
1031
|
+
return lines;
|
|
1032
|
+
}
|
|
1033
|
+
/** A diff between two versions, as lines: the capability and job changes first (they are what needs deciding), then the files. */
|
|
1034
|
+
function formatVersionDiff(diff) {
|
|
1035
|
+
const lines = [`v${diff.from.version} -> v${diff.to.version}`];
|
|
1036
|
+
for (const change of diff.capabilities) {
|
|
1037
|
+
for (const item of change.added)
|
|
1038
|
+
lines.push(`+ ${change.key}: ${(0, data_provider_1.plainAppLabel)(item, 120)}`);
|
|
1039
|
+
for (const item of change.removed)
|
|
1040
|
+
lines.push(`- ${change.key}: ${(0, data_provider_1.plainAppLabel)(item, 120)}`);
|
|
1041
|
+
}
|
|
1042
|
+
for (const pair of diff.storeWriters.added)
|
|
1043
|
+
lines.push(`+ who may write: ${pair}`);
|
|
1044
|
+
for (const pair of diff.storeWriters.removed)
|
|
1045
|
+
lines.push(`- who may write: ${pair}`);
|
|
1046
|
+
for (const job of diff.jobs.added)
|
|
1047
|
+
lines.push(`+ job ${job.id}: ${(0, data_provider_1.plainAppLabel)(job.title, 80)} (${job.schedule ?? 'no schedule'})`);
|
|
1048
|
+
for (const job of diff.jobs.removed)
|
|
1049
|
+
lines.push(`- job ${job.id}: ${(0, data_provider_1.plainAppLabel)(job.title, 80)}`);
|
|
1050
|
+
for (const job of diff.jobs.changed)
|
|
1051
|
+
lines.push(`~ job ${job.id}: ${(0, data_provider_1.plainAppLabel)(job.title, 80)} changed (${(job.what ?? []).join(', ')})`);
|
|
1052
|
+
for (const file of diff.files) {
|
|
1053
|
+
const counts = file.added === undefined ? '' : ` (+${file.added} -${file.removed})`;
|
|
1054
|
+
lines.push(`${file.change} ${file.path}${counts}${file.omitted ? ` [lines not shown: ${file.omitted}]` : ''}`);
|
|
1055
|
+
for (const hunk of file.hunks ?? []) {
|
|
1056
|
+
lines.push(` @@ -${hunk.oldStart} +${hunk.newStart} @@`);
|
|
1057
|
+
for (const line of hunk.lines) {
|
|
1058
|
+
lines.push(` ${line.op === 'add' ? '+' : line.op === 'remove' ? '-' : ' '}${line.text}`);
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
if (diff.filesOmitted > 0)
|
|
1063
|
+
lines.push(`... and ${diff.filesOmitted} more changed files not listed`);
|
|
1064
|
+
return lines;
|
|
1065
|
+
}
|
|
@@ -30,6 +30,7 @@ export declare abstract class AppsCommand extends BaseCommand {
|
|
|
30
30
|
installation: string;
|
|
31
31
|
collection: string;
|
|
32
32
|
id?: string;
|
|
33
|
+
verb?: 'put' | 'patch' | 'delete' | 'batch';
|
|
33
34
|
}): never;
|
|
34
35
|
/**
|
|
35
36
|
* Say what went wrong with a REPORT: the refusals only a report makes (a reason the Store does not take, a
|
package/dist/lib/apps-command.js
CHANGED
|
@@ -144,6 +144,17 @@ class AppsCommand extends base_command_1.BaseCommand {
|
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
const refusal = (0, apps_1.readAppsRefusal)(error);
|
|
147
|
+
if (refusal && (0, apps_1.isUploadBudgetRefusal)(refusal)) {
|
|
148
|
+
// the account's daily allowance of new image and font bytes: a wait of hours, so not retryable now (the harness is told when)
|
|
149
|
+
return this.failWithCliError({
|
|
150
|
+
message: (0, apps_1.describeAppsRefusal)(refusal, this.config.bin),
|
|
151
|
+
code: apps_1.APP_UPLOAD_BUDGET_CODE,
|
|
152
|
+
...(refusal.status === undefined ? {} : { status: refusal.status }),
|
|
153
|
+
exit: 1,
|
|
154
|
+
retryable: false,
|
|
155
|
+
details: refusal.retryAfterMs === undefined ? {} : { retryAfterMs: refusal.retryAfterMs },
|
|
156
|
+
});
|
|
157
|
+
}
|
|
147
158
|
if (refusal && refusal.error && apps_1.APPS_REFUSAL_CODES[refusal.error]) {
|
|
148
159
|
return this.failWithCliError({
|
|
149
160
|
message: (0, apps_1.describeAppsRefusal)(refusal, this.config.bin),
|
package/dist/lib/apps.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface AppsRefusal {
|
|
|
21
21
|
check?: AppCheckReport;
|
|
22
22
|
/** An installation call's refusal (`appInstallations.ts`): the reason a `forbidden` carries, and what a conflict names. */
|
|
23
23
|
reason?: string;
|
|
24
|
+
/** On a `rate`: how long until the allowance turns, in milliseconds (the upload door's daily allowance of new bytes). */
|
|
25
|
+
retryAfterMs?: number;
|
|
24
26
|
docCount?: number;
|
|
25
27
|
installationId?: string;
|
|
26
28
|
current?: {
|
|
@@ -37,6 +39,16 @@ export interface AppsRefusal {
|
|
|
37
39
|
export declare function readAppsRefusal(error: unknown): AppsRefusal | null;
|
|
38
40
|
/** Refusals this CLI reads itself, with the machine code it exits under. Everything else is the base command's. */
|
|
39
41
|
export declare const APPS_REFUSAL_CODES: Record<string, string>;
|
|
42
|
+
/**
|
|
43
|
+
* The upload door's daily allowance of NEW image and font bytes is spent (`apps push`). The server says it as a `rate` refusal whose
|
|
44
|
+
* `reason` is this; a `rate` with no such reason is the write limiter's ("too many requests") and stays the base command's. It is
|
|
45
|
+
* its own machine code because the answer is different: not "back off for a second" but "not until the allowance turns", and a
|
|
46
|
+
* harness must not retry it in a loop. The reason is the API's own literal (`Apps/AppAuthoring/assetUploadBudget.js`); a spec in the
|
|
47
|
+
* API reads this file to hold the two together.
|
|
48
|
+
*/
|
|
49
|
+
export declare const APP_UPLOAD_BUDGET_REASON = "upload_budget";
|
|
50
|
+
export declare const APP_UPLOAD_BUDGET_CODE = "APP_UPLOAD_BUDGET";
|
|
51
|
+
export declare function isUploadBudgetRefusal(refusal: AppsRefusal): boolean;
|
|
40
52
|
/** The words for a refusal: what it was, the revision to retry from, each problem, what to do. */
|
|
41
53
|
export declare function describeAppsRefusal(refusal: AppsRefusal, bin: string): string;
|
|
42
54
|
/** A table row of the apps a person can edit. */
|
package/dist/lib/apps.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.APPS_REFUSAL_CODES = exports.AppRefError = void 0;
|
|
3
|
+
exports.APP_UPLOAD_BUDGET_CODE = exports.APP_UPLOAD_BUDGET_REASON = exports.APPS_REFUSAL_CODES = exports.AppRefError = void 0;
|
|
4
4
|
exports.resolveAppRef = resolveAppRef;
|
|
5
5
|
exports.readAppsRefusal = readAppsRefusal;
|
|
6
|
+
exports.isUploadBudgetRefusal = isUploadBudgetRefusal;
|
|
6
7
|
exports.describeAppsRefusal = describeAppsRefusal;
|
|
7
8
|
exports.formatAppRow = formatAppRow;
|
|
8
9
|
exports.formatEntryLine = formatEntryLine;
|
|
@@ -72,6 +73,9 @@ function readAppsRefusal(error) {
|
|
|
72
73
|
? { check: body.check }
|
|
73
74
|
: {}),
|
|
74
75
|
...(typeof body.reason === 'string' ? { reason: body.reason } : {}),
|
|
76
|
+
...(typeof body.retryAfterMs === 'number' && Number.isFinite(body.retryAfterMs)
|
|
77
|
+
? { retryAfterMs: body.retryAfterMs }
|
|
78
|
+
: {}),
|
|
75
79
|
...(typeof body.docCount === 'number' ? { docCount: body.docCount } : {}),
|
|
76
80
|
...(typeof body.installationId === 'string' ? { installationId: body.installationId } : {}),
|
|
77
81
|
...(body.current && typeof body.current === 'object'
|
|
@@ -101,6 +105,26 @@ exports.APPS_REFUSAL_CODES = {
|
|
|
101
105
|
// the installation calls (`appInstallations.ts`): installing, approving again, moving, pausing, removing
|
|
102
106
|
...appInstallations_1.INSTALLATION_REFUSAL_CODES,
|
|
103
107
|
};
|
|
108
|
+
/**
|
|
109
|
+
* The upload door's daily allowance of NEW image and font bytes is spent (`apps push`). The server says it as a `rate` refusal whose
|
|
110
|
+
* `reason` is this; a `rate` with no such reason is the write limiter's ("too many requests") and stays the base command's. It is
|
|
111
|
+
* its own machine code because the answer is different: not "back off for a second" but "not until the allowance turns", and a
|
|
112
|
+
* harness must not retry it in a loop. The reason is the API's own literal (`Apps/AppAuthoring/assetUploadBudget.js`); a spec in the
|
|
113
|
+
* API reads this file to hold the two together.
|
|
114
|
+
*/
|
|
115
|
+
exports.APP_UPLOAD_BUDGET_REASON = 'upload_budget';
|
|
116
|
+
exports.APP_UPLOAD_BUDGET_CODE = 'APP_UPLOAD_BUDGET';
|
|
117
|
+
function isUploadBudgetRefusal(refusal) {
|
|
118
|
+
return refusal.error === 'rate' && refusal.reason === exports.APP_UPLOAD_BUDGET_REASON;
|
|
119
|
+
}
|
|
120
|
+
/** A wait as a person says it: "5 minutes", "7 hours". Rounds up, so it is never shorter than the wait. */
|
|
121
|
+
function describeWait(ms) {
|
|
122
|
+
const minutes = Math.max(1, Math.ceil(ms / 60_000));
|
|
123
|
+
if (minutes < 90) {
|
|
124
|
+
return `${minutes} ${minutes === 1 ? 'minute' : 'minutes'}`;
|
|
125
|
+
}
|
|
126
|
+
return `${Math.ceil(minutes / 60)} hours`;
|
|
127
|
+
}
|
|
104
128
|
/** The words for a refusal: what it was, the revision to retry from, each problem, what to do. */
|
|
105
129
|
function describeAppsRefusal(refusal, bin) {
|
|
106
130
|
const installation = (0, appInstallations_1.describeInstallationConflict)(refusal, bin);
|
|
@@ -114,6 +138,9 @@ function describeAppsRefusal(refusal, bin) {
|
|
|
114
138
|
if (refusal.error === 'preview_superseded' || refusal.error === 'preview_expired') {
|
|
115
139
|
lines.push(`→ Open a new preview: \`${bin} apps preview <app>\`.`);
|
|
116
140
|
}
|
|
141
|
+
if (isUploadBudgetRefusal(refusal)) {
|
|
142
|
+
lines.push(`→ ${refusal.retryAfterMs === undefined ? 'Try again later' : `Try again in about ${describeWait(refusal.retryAfterMs)}`}. Files already sent stay in the draft: read its revision again (\`${bin} apps file ls <app>\` shows \`rev\`) and run the push again, and it sends only what the draft does not hold.`);
|
|
143
|
+
}
|
|
117
144
|
for (const problem of (refusal.problems ?? []).slice(0, 10)) {
|
|
118
145
|
lines.push(` - ${problem.path ? `${problem.path}: ` : ''}${problem.message}`);
|
|
119
146
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `skrr apps push | pull`: the bytes of an app's images and fonts. The domain lib for the one door that carries bytes
|
|
3
|
+
* (Dynamic Agent Apps, D7): everything else in `skrr apps` is JSON through `dataService`, and the request layer behind that is JSON
|
|
4
|
+
* only, so a file's bytes go through `apiFetch` (`rawBody` to send them, `responseAs: 'bytes'` to read them). This lib owns the URL,
|
|
5
|
+
* as the other `apiFetch` libs do, and `domain-api-parity.spec.ts` reads it from here.
|
|
6
|
+
*
|
|
7
|
+
* What it trusts, and what it does not: the server's answer to a download is a stranger's input like everything else a pull
|
|
8
|
+
* receives, so the caller (`writePackageDir`) hashes the bytes against the address the server's tree gave before it writes a file.
|
|
9
|
+
*/
|
|
10
|
+
import type { AppAssetUploadResult } from '@skrr-ai/data-provider';
|
|
11
|
+
/** Store `bytes` as the file at `path` of the draft, if the draft is still at `expectedRev` (a compare-and-set, like every write). */
|
|
12
|
+
export declare function uploadAppDraftAsset(appId: string, params: {
|
|
13
|
+
path: string;
|
|
14
|
+
expectedRev: number;
|
|
15
|
+
}, bytes: Uint8Array): Promise<AppAssetUploadResult>;
|
|
16
|
+
/** The bytes of the image or font at `path` of the draft. */
|
|
17
|
+
export declare function downloadAppDraftAsset(appId: string, path: string): Promise<Buffer>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uploadAppDraftAsset = uploadAppDraftAsset;
|
|
4
|
+
exports.downloadAppDraftAsset = downloadAppDraftAsset;
|
|
5
|
+
const api_fetch_1 = require("./api-fetch");
|
|
6
|
+
const triggers_1 = require("./triggers");
|
|
7
|
+
/** Store `bytes` as the file at `path` of the draft, if the draft is still at `expectedRev` (a compare-and-set, like every write). */
|
|
8
|
+
function uploadAppDraftAsset(appId, params, bytes) {
|
|
9
|
+
return (0, api_fetch_1.apiFetch)((0, triggers_1.withQuery)(`/api/apps/drafts/${encodeURIComponent(appId)}/assets`, params), { method: 'PUT', rawBody: bytes });
|
|
10
|
+
}
|
|
11
|
+
/** The bytes of the image or font at `path` of the draft. */
|
|
12
|
+
async function downloadAppDraftAsset(appId, path) {
|
|
13
|
+
const bytes = await (0, api_fetch_1.apiFetch)((0, triggers_1.withQuery)(`/api/apps/drafts/${encodeURIComponent(appId)}/assets`, { path }), { method: 'GET', responseAs: 'bytes' });
|
|
14
|
+
return Buffer.from(bytes);
|
|
15
|
+
}
|
package/dist/lib/appsCheck.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare function compileScript(source: string): {
|
|
|
7
7
|
/** Check a package that is already in memory. */
|
|
8
8
|
export declare function checkLocalFiles(files: readonly AppDraftFile[], options?: {
|
|
9
9
|
expectedId?: string;
|
|
10
|
+
assetBytes?: Readonly<Record<string, Uint8Array>>;
|
|
10
11
|
}): AppCheckReport;
|
|
11
12
|
/** The report as lines for a terminal: the verdict, then each finding with where it is and what to do. */
|
|
12
13
|
export declare function formatAppCheckReport(report: AppCheckReport): string[];
|
package/dist/lib/appsCheck.js
CHANGED
|
@@ -89,6 +89,7 @@ function scanSandbox(sections) {
|
|
|
89
89
|
function checkLocalFiles(files, options = {}) {
|
|
90
90
|
return (0, data_provider_1.checkAppPackage)(files, {
|
|
91
91
|
...(options.expectedId === undefined ? {} : { expectedId: options.expectedId }),
|
|
92
|
+
...(options.assetBytes === undefined ? {} : { assetBytes: options.assetBytes }),
|
|
92
93
|
checkScriptSyntax: compileScript,
|
|
93
94
|
scanSandbox,
|
|
94
95
|
});
|
package/dist/lib/appsFs.d.ts
CHANGED
|
@@ -9,10 +9,18 @@ export declare class AppsFsError extends Error {
|
|
|
9
9
|
}
|
|
10
10
|
/** UTF-8 is at most four bytes a character: the largest file a text of the limit's length can be. */
|
|
11
11
|
export declare const APPS_FS_FILE_MAX_BYTES: number;
|
|
12
|
+
/**
|
|
13
|
+
* Is `relative` an image or a font that is BYTES (a PNG, JPEG, WebP, GIF or WOFF2)? Those are read and written as bytes; an SVG
|
|
14
|
+
* is text and goes with the text files.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isBinaryAssetPath(relative: string): boolean;
|
|
12
17
|
export interface LocalPackage {
|
|
13
18
|
/** The root, resolved once. */
|
|
14
19
|
root: string;
|
|
20
|
+
/** Text files (`content`) and the images and fonts that are bytes (`assetSha256`, the digest of the bytes in `assetBytes`). */
|
|
15
21
|
files: AppDraftFile[];
|
|
22
|
+
/** The bytes of the files that hold bytes, by package path. */
|
|
23
|
+
assetBytes: Record<string, Buffer>;
|
|
16
24
|
/** What was left out on purpose: a name that starts with ".", `node_modules`. Never a link, never a file. */
|
|
17
25
|
skipped: string[];
|
|
18
26
|
}
|
|
@@ -25,6 +33,14 @@ export interface ReadHooks {
|
|
|
25
33
|
* Returns its text. `label` is what the file is called in a message.
|
|
26
34
|
*/
|
|
27
35
|
export declare function readRegularTextFile(absolute: string, label: string, hooks?: ReadHooks): string;
|
|
36
|
+
/**
|
|
37
|
+
* Read ONE regular file's bytes under every rule of the file comment (no link followed, `O_NOFOLLOW`, the thing opened is the
|
|
38
|
+
* thing looked at, a size checked before a byte is read and again after). `options.tooLarge` words the refusal for the caller.
|
|
39
|
+
*/
|
|
40
|
+
export declare function readRegularBytes(absolute: string, label: string, hooks: ReadHooks, options: {
|
|
41
|
+
maxBytes: number;
|
|
42
|
+
tooLarge: (size: number) => string;
|
|
43
|
+
}): Buffer;
|
|
28
44
|
/**
|
|
29
45
|
* Read a package directory: every regular file under `root`, as text, with its package path.
|
|
30
46
|
*
|
|
@@ -44,8 +60,9 @@ export declare function remoteTreeProblems(files: readonly AppDraftFile[]): AppP
|
|
|
44
60
|
* acceptable; an existing file is replaced only with `force`, and a link is never written through or
|
|
45
61
|
* replaced.
|
|
46
62
|
*/
|
|
47
|
-
export declare function writePackageDir(rootInput: string, files: readonly AppDraftFile[], { force }?: {
|
|
63
|
+
export declare function writePackageDir(rootInput: string, files: readonly AppDraftFile[], { force, assetBytes, }?: {
|
|
48
64
|
force?: boolean;
|
|
65
|
+
assetBytes?: Readonly<Record<string, Uint8Array>>;
|
|
49
66
|
}): WriteResult;
|
|
50
67
|
/**
|
|
51
68
|
* Text from stdin, bounded: a pipe that never ends is read until the limit and then refused, not until
|