@skrr-ai/cli 0.1.155 → 0.1.157
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/show.d.ts +18 -0
- package/dist/commands/activity/show.js +125 -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 +68 -0
- package/dist/lib/agent-activity.js +106 -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 +2789 -533
- package/package.json +14 -2
|
@@ -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
|
package/dist/lib/appsFs.js
CHANGED
|
@@ -34,7 +34,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.APPS_FS_FLAGS = exports.APPS_FS_FILE_MAX_BYTES = exports.AppsFsError = void 0;
|
|
37
|
+
exports.isBinaryAssetPath = isBinaryAssetPath;
|
|
37
38
|
exports.readRegularTextFile = readRegularTextFile;
|
|
39
|
+
exports.readRegularBytes = readRegularBytes;
|
|
38
40
|
exports.readPackageDir = readPackageDir;
|
|
39
41
|
exports.remoteTreeProblems = remoteTreeProblems;
|
|
40
42
|
exports.writePackageDir = writePackageDir;
|
|
@@ -64,8 +66,10 @@ exports.readStdinText = readStdinText;
|
|
|
64
66
|
* hang forever or return forever).
|
|
65
67
|
* - Sizes are checked from the metadata BEFORE a byte is read, then again on what was read.
|
|
66
68
|
* - Bytes are decoded as strict UTF-8 and kept exactly (`ignoreBOM`), because a version's hash is over
|
|
67
|
-
* the bytes. A file that is not text is refused here
|
|
68
|
-
*
|
|
69
|
+
* the bytes. A file that is not text is refused here, EXCEPT an image or a font the platform serves
|
|
70
|
+
* (png, jpg, jpeg, webp, gif, woff2): those are read as bytes, under every rule above, at most 256 KiB, and
|
|
71
|
+
* kept as bytes with the digest the draft will name them by (a lossy decode would store something other than
|
|
72
|
+
* what the person has).
|
|
69
73
|
* - What the SERVER sends back (a pull) is as untrusted as a cloned repository: every path is judged
|
|
70
74
|
* by the contract's grammar again, the whole set is judged for collisions, and nothing is written
|
|
71
75
|
* until all of it is acceptable. Directories are made one component at a time, each looked at with
|
|
@@ -78,6 +82,7 @@ exports.readStdinText = readStdinText;
|
|
|
78
82
|
* concurrent attacker on one's own machine. On Windows `O_NOFOLLOW` does not exist, and the `lstat` checks
|
|
79
83
|
* are what is left.
|
|
80
84
|
*/
|
|
85
|
+
const node_crypto_1 = require("node:crypto");
|
|
81
86
|
const fs = __importStar(require("node:fs"));
|
|
82
87
|
const path = __importStar(require("node:path"));
|
|
83
88
|
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
@@ -99,6 +104,14 @@ const O_NOFOLLOW = fs.constants.O_NOFOLLOW ?? 0;
|
|
|
99
104
|
const O_DIRECTORY = fs.constants.O_DIRECTORY ?? 0;
|
|
100
105
|
/** Directories that are never part of a package and are walked past, not into. */
|
|
101
106
|
const SKIPPED_DIRECTORIES = new Set(['node_modules']);
|
|
107
|
+
/**
|
|
108
|
+
* 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
|
|
109
|
+
* is text and goes with the text files.
|
|
110
|
+
*/
|
|
111
|
+
function isBinaryAssetPath(relative) {
|
|
112
|
+
const type = (0, data_provider_1.appFrameFileTypeOf)(relative);
|
|
113
|
+
return (type !== null && type.kind !== 'module' && type.bytes !== undefined && type.bytes !== 'svg');
|
|
114
|
+
}
|
|
102
115
|
function describeLink(absolute) {
|
|
103
116
|
try {
|
|
104
117
|
return ` (it points at ${fs.readlinkSync(absolute)})`;
|
|
@@ -128,6 +141,23 @@ function errorText(error) {
|
|
|
128
141
|
* Returns its text. `label` is what the file is called in a message.
|
|
129
142
|
*/
|
|
130
143
|
function readRegularTextFile(absolute, label, hooks = {}) {
|
|
144
|
+
const buffer = readRegularBytes(absolute, label, hooks, {
|
|
145
|
+
maxBytes: exports.APPS_FS_FILE_MAX_BYTES,
|
|
146
|
+
tooLarge: (size) => `${label} is ${size} bytes; a text file of at most ${data_provider_1.APP_DRAFT_LIMITS.fileMaxChars} characters is at most ${exports.APPS_FS_FILE_MAX_BYTES}.`,
|
|
147
|
+
});
|
|
148
|
+
try {
|
|
149
|
+
// `ignoreBOM: true` keeps a leading BOM as a character, so the text encodes back to the same bytes.
|
|
150
|
+
return new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(buffer);
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
throw new AppsFsError('not_text', label, `${label} is not UTF-8 text: a draft holds text files, and this one would be stored as something other than what is on disk.`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Read ONE regular file's bytes under every rule of the file comment (no link followed, `O_NOFOLLOW`, the thing opened is the
|
|
158
|
+
* thing looked at, a size checked before a byte is read and again after). `options.tooLarge` words the refusal for the caller.
|
|
159
|
+
*/
|
|
160
|
+
function readRegularBytes(absolute, label, hooks, options) {
|
|
131
161
|
const before = lstatOrNull(absolute);
|
|
132
162
|
if (!before) {
|
|
133
163
|
throw new AppsFsError('unreadable', label, `${label} does not exist.`);
|
|
@@ -138,8 +168,8 @@ function readRegularTextFile(absolute, label, hooks = {}) {
|
|
|
138
168
|
if (!before.isFile()) {
|
|
139
169
|
throw new AppsFsError('not_regular', label, `${label} is not a regular file.`);
|
|
140
170
|
}
|
|
141
|
-
if (before.size >
|
|
142
|
-
throw new AppsFsError('too_large', label,
|
|
171
|
+
if (before.size > options.maxBytes) {
|
|
172
|
+
throw new AppsFsError('too_large', label, options.tooLarge(before.size));
|
|
143
173
|
}
|
|
144
174
|
hooks.betweenLookAndOpen?.();
|
|
145
175
|
let fd;
|
|
@@ -165,7 +195,7 @@ function readRegularTextFile(absolute, label, hooks = {}) {
|
|
|
165
195
|
(opened.ino !== before.ino || opened.dev !== before.dev)) {
|
|
166
196
|
throw new AppsFsError('symlink', label, `${label} was replaced while it was being read.`);
|
|
167
197
|
}
|
|
168
|
-
if (opened.size >
|
|
198
|
+
if (opened.size > options.maxBytes) {
|
|
169
199
|
throw new AppsFsError('too_large', label, `${label} is larger than a package file may be.`);
|
|
170
200
|
}
|
|
171
201
|
const buffer = Buffer.alloc(opened.size);
|
|
@@ -176,13 +206,7 @@ function readRegularTextFile(absolute, label, hooks = {}) {
|
|
|
176
206
|
break;
|
|
177
207
|
read += n;
|
|
178
208
|
}
|
|
179
|
-
|
|
180
|
-
// `ignoreBOM: true` keeps a leading BOM as a character, so the text encodes back to the same bytes.
|
|
181
|
-
return new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(buffer.subarray(0, read));
|
|
182
|
-
}
|
|
183
|
-
catch {
|
|
184
|
-
throw new AppsFsError('not_text', label, `${label} is not UTF-8 text: a draft holds text files, and this one would be stored as something other than what is on disk.`);
|
|
185
|
-
}
|
|
209
|
+
return buffer.subarray(0, read);
|
|
186
210
|
}
|
|
187
211
|
finally {
|
|
188
212
|
fs.closeSync(fd);
|
|
@@ -214,6 +238,7 @@ function readPackageDir(rootInput) {
|
|
|
214
238
|
throw new AppsFsError('not_directory', rootInput, `${rootInput} is not a directory.`);
|
|
215
239
|
}
|
|
216
240
|
const files = [];
|
|
241
|
+
const assetBytes = Object.create(null);
|
|
217
242
|
const skipped = [];
|
|
218
243
|
const walk = (relative, depth) => {
|
|
219
244
|
const absolute = relative === '' ? root : path.join(root, ...relative.split('/'));
|
|
@@ -255,17 +280,34 @@ function readPackageDir(rootInput) {
|
|
|
255
280
|
if (files.length >= data_provider_1.APP_DRAFT_LIMITS.filesMax) {
|
|
256
281
|
throw new AppsFsError('too_many', childRelative, `A package holds at most ${data_provider_1.APP_DRAFT_LIMITS.filesMax} files; this directory has more. Leave out what is not part of the app.`);
|
|
257
282
|
}
|
|
258
|
-
|
|
283
|
+
// An image or a font that is bytes is read as bytes, under the same rules; everything else is text.
|
|
284
|
+
const asBytes = isBinaryAssetPath(childRelative);
|
|
285
|
+
const content = asBytes ? null : readRegularTextFile(childAbsolute, childRelative);
|
|
286
|
+
const bytes = asBytes
|
|
287
|
+
? readRegularBytes(childAbsolute, childRelative, {}, {
|
|
288
|
+
maxBytes: data_provider_1.APP_FRAME_FILE_LIMITS.assetBytesMax,
|
|
289
|
+
tooLarge: (size) => `${childRelative} is ${size} bytes; an image or a font is at most ${data_provider_1.APP_FRAME_FILE_LIMITS.assetBytesMax} (256 KiB).`,
|
|
290
|
+
})
|
|
291
|
+
: null;
|
|
259
292
|
// After the read: the real location of what was read is inside the root.
|
|
260
293
|
const real = fs.realpathSync(childAbsolute);
|
|
261
294
|
if (real !== path.join(root, ...childRelative.split('/'))) {
|
|
262
295
|
throw new AppsFsError('outside_root', childRelative, `${childRelative} is not where it appears to be (${real}).`);
|
|
263
296
|
}
|
|
264
|
-
|
|
297
|
+
if (bytes !== null) {
|
|
298
|
+
assetBytes[childRelative] = bytes;
|
|
299
|
+
files.push({
|
|
300
|
+
path: childRelative,
|
|
301
|
+
assetSha256: (0, node_crypto_1.createHash)('sha256').update(bytes).digest('hex'),
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
files.push({ path: childRelative, content: content });
|
|
306
|
+
}
|
|
265
307
|
}
|
|
266
308
|
};
|
|
267
309
|
walk('', 1);
|
|
268
|
-
return { root, files, skipped };
|
|
310
|
+
return { root, files, assetBytes, skipped };
|
|
269
311
|
}
|
|
270
312
|
/** The problems of a set of paths a server sent, judged as strangers' input. */
|
|
271
313
|
function remoteTreeProblems(files) {
|
|
@@ -276,14 +318,27 @@ function remoteTreeProblems(files) {
|
|
|
276
318
|
* acceptable; an existing file is replaced only with `force`, and a link is never written through or
|
|
277
319
|
* replaced.
|
|
278
320
|
*/
|
|
279
|
-
function writePackageDir(rootInput, files, { force = false } = {}) {
|
|
321
|
+
function writePackageDir(rootInput, files, { force = false, assetBytes = {}, } = {}) {
|
|
280
322
|
const problems = remoteTreeProblems(files);
|
|
281
323
|
if (problems.length > 0) {
|
|
282
324
|
throw new AppsFsError('bad_path', problems[0].path, `Refusing to write: ${problems[0].message}`);
|
|
283
325
|
}
|
|
284
326
|
for (const file of files) {
|
|
285
|
-
if (typeof file.content
|
|
286
|
-
|
|
327
|
+
if (typeof file.content === 'string') {
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
330
|
+
// A file the server holds as bytes is written only when its bytes came with it AND hash to the address the server named: the
|
|
331
|
+
// answer is a stranger's input like everything else it sends back.
|
|
332
|
+
const bytes = Object.prototype.hasOwnProperty.call(assetBytes, file.path)
|
|
333
|
+
? assetBytes[file.path]
|
|
334
|
+
: undefined;
|
|
335
|
+
if (typeof file.assetSha256 !== 'string' ||
|
|
336
|
+
bytes === undefined ||
|
|
337
|
+
!isBinaryAssetPath(file.path)) {
|
|
338
|
+
throw new AppsFsError('not_text', file.path, `${file.path} is not a text file; this command writes text files, and the images and fonts it was given the bytes of.`);
|
|
339
|
+
}
|
|
340
|
+
if ((0, node_crypto_1.createHash)('sha256').update(bytes).digest('hex') !== file.assetSha256) {
|
|
341
|
+
throw new AppsFsError('unreadable', file.path, `The bytes received for ${file.path} do not hash to the address the server gave, so nothing was written.`);
|
|
287
342
|
}
|
|
288
343
|
}
|
|
289
344
|
const typed = path.resolve(rootInput);
|
|
@@ -342,7 +397,9 @@ function writePackageDir(rootInput, files, { force = false } = {}) {
|
|
|
342
397
|
throw new AppsFsError('unreadable', file.path, `Could not create ${file.path}: ${errorText(error)}`);
|
|
343
398
|
}
|
|
344
399
|
try {
|
|
345
|
-
const bytes =
|
|
400
|
+
const bytes = typeof file.content === 'string'
|
|
401
|
+
? Buffer.from(file.content, 'utf8')
|
|
402
|
+
: Buffer.from(assetBytes[file.path]);
|
|
346
403
|
let offset = 0;
|
|
347
404
|
while (offset < bytes.length) {
|
|
348
405
|
offset += fs.writeSync(fd, bytes, offset);
|
package/dist/lib/compasses.js
CHANGED
|
@@ -309,6 +309,12 @@ function renderEffectivePolicy(policy, log) {
|
|
|
309
309
|
log(' nothing set');
|
|
310
310
|
for (const line of communication)
|
|
311
311
|
log(` ${line}`);
|
|
312
|
+
// These hours are read where the platform composes a message for the agent (Duty checks and
|
|
313
|
+
// wakes). A message the agent sends itself from a session never evaluates them (OSK-23468), and
|
|
314
|
+
// printing the window alone read as if it did.
|
|
315
|
+
if (record(record(policy.communication).quietHours).enabled === true) {
|
|
316
|
+
log(' Note: the communication quiet hours hold messages the platform composes for this agent (Duty checks and wakes). A message the agent sends itself with `skrr agent message send` is not held by them.');
|
|
317
|
+
}
|
|
312
318
|
log(`Authority: ${scalar(policy.authority ?? 'unknown')}`);
|
|
313
319
|
const bySource = new Map();
|
|
314
320
|
for (const [path, entry] of Object.entries(record(policy.fieldProvenance))) {
|
package/dist/lib/duties.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export { DUTY_WATCHED_SOURCES, DUTY_TEMPLATE_IDS, DUTY_CADENCE_MODES, DUTY_CADEN
|
|
|
24
24
|
export type { DutyCheck, DutyChecksResponse, Duty, DutyActionProposal, DutyListResponse, DutyPlanResponse, DutyStatusResponse, DutyWorkLink, };
|
|
25
25
|
/** Derived from the installed compatibility vocabulary so the CLI remains
|
|
26
26
|
* safe even while data-provider and CLI packages roll out separately. */
|
|
27
|
-
export declare const DUTY_AUTHORABLE_CADENCE_MODES: ("manual" | "
|
|
27
|
+
export declare const DUTY_AUTHORABLE_CADENCE_MODES: ("manual" | "interval" | "daily" | "event_plus_interval")[];
|
|
28
28
|
/**
|
|
29
29
|
* Where a Duty's autonomous runs do their work. Re-exported for the same
|
|
30
30
|
* reason as the ladder above: the vocabulary is the server's, and a picker that
|
|
@@ -52,6 +52,10 @@ export type DutyListPage = {
|
|
|
52
52
|
data: unknown[];
|
|
53
53
|
has_more?: boolean;
|
|
54
54
|
next_cursor?: string | null;
|
|
55
|
+
coverage?: {
|
|
56
|
+
status?: string;
|
|
57
|
+
reason?: string;
|
|
58
|
+
};
|
|
55
59
|
};
|
|
56
60
|
export type DutyPreflightReport = {
|
|
57
61
|
verdict: 'ready' | 'needs_review' | 'blocked';
|
|
@@ -747,6 +751,14 @@ export type EventWakeCapabilities = {
|
|
|
747
751
|
};
|
|
748
752
|
/** Shape of `GET /:id/wake-capabilities`. */
|
|
749
753
|
export interface DutyWakeCapabilities {
|
|
754
|
+
sourcePolicy?: {
|
|
755
|
+
status?: string;
|
|
756
|
+
reason?: string;
|
|
757
|
+
};
|
|
758
|
+
standingEventWakesSourcePolicy?: {
|
|
759
|
+
status?: string;
|
|
760
|
+
reason?: string;
|
|
761
|
+
};
|
|
750
762
|
eligibleCapabilities: Array<{
|
|
751
763
|
id: string;
|
|
752
764
|
kind?: string;
|
|
@@ -768,6 +780,10 @@ export interface DutyWakeCapabilities {
|
|
|
768
780
|
* statement", never "nothing is bound".
|
|
769
781
|
*/
|
|
770
782
|
standingEventWakes?: {
|
|
783
|
+
sourcePolicy?: {
|
|
784
|
+
status?: string;
|
|
785
|
+
reason?: string;
|
|
786
|
+
};
|
|
771
787
|
dutyStatus: string;
|
|
772
788
|
cadenceMode?: string;
|
|
773
789
|
eventCapabilities: EventWakeCapabilities;
|
|
@@ -1020,7 +1036,7 @@ export declare function withLiveAssessment(duty: DutyView, operatingState?: {
|
|
|
1020
1036
|
assessment?: unknown;
|
|
1021
1037
|
executorBlocked?: unknown;
|
|
1022
1038
|
firstActionableBlocker?: unknown;
|
|
1023
|
-
} | null): DutyView;
|
|
1039
|
+
} | null, historyUnavailable?: boolean): DutyView;
|
|
1024
1040
|
/**
|
|
1025
1041
|
* The first line of `duties update` text output. An update that changed
|
|
1026
1042
|
* nothing says so and names the version it left alone (OSK-16199); a server
|
|
@@ -1187,6 +1203,13 @@ export declare function renderDutyObservations(response: ReadModelRecord, log: (
|
|
|
1187
1203
|
export declare function renderDutyHypotheses(response: ReadModelRecord, log: (line: string) => void, options?: {
|
|
1188
1204
|
emptyMessage?: string;
|
|
1189
1205
|
}): void;
|
|
1206
|
+
/** Old servers could associate work by logical ID without proving its source.
|
|
1207
|
+
* Never render or print those rows unless the server explicitly declares that
|
|
1208
|
+
* the source is supported. This also protects JSON output during mixed rollout.
|
|
1209
|
+
*/
|
|
1210
|
+
export declare function safeDutyLineage(lineage: ReadModelRecord, dutyId?: string): ReadModelRecord;
|
|
1211
|
+
/** Recognize the explicit server refusal across both CLI HTTP transports. */
|
|
1212
|
+
export declare function isDutyLineageUnavailable(error: unknown): boolean;
|
|
1190
1213
|
/** Human view for the duty → work lineage projection. */
|
|
1191
1214
|
export declare function renderDutyLineage(lineage: ReadModelRecord, log: (line: string) => void): void;
|
|
1192
1215
|
/** Human view for daily control-loop metrics. */
|