@skrr-ai/cli 0.1.163 → 0.1.165
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/dist/base-command.d.ts +14 -1
- package/dist/base-command.js +190 -58
- package/dist/commands/agent/message/send.d.ts +1 -0
- package/dist/commands/agent/message/send.js +3 -0
- package/dist/commands/agents/mini-computer/app/set.js +1 -1
- package/dist/commands/agents/mini-computer/show.js +7 -1
- package/dist/commands/agents/mini-computer/tasks-view.js +1 -1
- package/dist/commands/agents/supervision.d.ts +25 -0
- package/dist/commands/agents/supervision.js +129 -0
- package/dist/commands/apps/check.js +3 -8
- package/dist/commands/apps/data/batch.d.ts +1 -0
- package/dist/commands/apps/data/batch.js +19 -2
- package/dist/commands/apps/data/delete.d.ts +1 -0
- package/dist/commands/apps/data/delete.js +14 -2
- package/dist/commands/apps/data/patch.d.ts +1 -0
- package/dist/commands/apps/data/patch.js +11 -2
- package/dist/commands/apps/data/put.d.ts +1 -0
- package/dist/commands/apps/data/put.js +17 -3
- package/dist/commands/apps/install.js +7 -2
- package/dist/commands/apps/installations/compatibility.d.ts +13 -0
- package/dist/commands/apps/installations/compatibility.js +60 -0
- package/dist/commands/apps/installations/show.js +9 -3
- package/dist/commands/apps/installations/snapshot.js +5 -2
- package/dist/commands/apps/operations/check.d.ts +16 -0
- package/dist/commands/apps/operations/check.js +127 -0
- package/dist/commands/apps/publish/propose.js +33 -4
- package/dist/commands/apps/reconsent.js +7 -1
- package/dist/commands/apps/reference.d.ts +4 -2
- package/dist/commands/apps/reference.js +7 -4
- package/dist/commands/apps/rollback.d.ts +9 -0
- package/dist/commands/apps/rollback.js +81 -2
- package/dist/commands/apps/upgrade.d.ts +8 -0
- package/dist/commands/apps/upgrade.js +67 -2
- package/dist/commands/apps/version/cat.d.ts +22 -0
- package/dist/commands/apps/version/cat.js +220 -0
- package/dist/commands/apps/version/show.js +3 -1
- package/dist/commands/commerce/incidents/release.d.ts +24 -0
- package/dist/commands/commerce/incidents/release.js +46 -0
- package/dist/commands/duties/action-proposal.js +19 -11
- package/dist/commands/duties/cadence-decisions.js +7 -0
- package/dist/commands/duties/cases.js +12 -1
- package/dist/commands/duties/hypotheses.js +10 -3
- package/dist/commands/duties/observations.d.ts +4 -0
- package/dist/commands/duties/observations.js +14 -3
- package/dist/commands/duties/trigger-status.js +2 -2
- package/dist/commands/duties/wake-capabilities.js +12 -6
- package/dist/commands/outbox/list.d.ts +11 -4
- package/dist/commands/outbox/list.js +56 -9
- package/dist/commands/outbox/retry.d.ts +8 -2
- package/dist/commands/outbox/retry.js +76 -16
- package/dist/commands/outbox/show.d.ts +20 -0
- package/dist/commands/outbox/show.js +83 -0
- package/dist/commands/proposals/list.js +13 -9
- package/dist/commands/requests/show.d.ts +12 -0
- package/dist/commands/requests/show.js +42 -23
- package/dist/commands/spaces/deletion/cancel.d.ts +21 -0
- package/dist/commands/spaces/deletion/cancel.js +70 -0
- package/dist/commands/spaces/workflows/run.js +12 -0
- package/dist/commands/widgets/check.d.ts +9 -0
- package/dist/commands/widgets/check.js +16 -3
- package/dist/generated/agent-guides.json +17 -17
- package/dist/lib/api-fetch.d.ts +5 -0
- package/dist/lib/api-fetch.js +53 -21
- package/dist/lib/appCompatibility.d.ts +31 -0
- package/dist/lib/appCompatibility.js +66 -0
- package/dist/lib/appData.d.ts +46 -4
- package/dist/lib/appData.js +156 -31
- package/dist/lib/appInstallations.d.ts +32 -5
- package/dist/lib/appInstallations.js +218 -34
- package/dist/lib/appVersionFile.d.ts +82 -0
- package/dist/lib/appVersionFile.js +195 -0
- package/dist/lib/apps-command.d.ts +14 -3
- package/dist/lib/apps-command.js +68 -60
- package/dist/lib/appsCheck.js +31 -6
- package/dist/lib/chat-supervision.d.ts +21 -0
- package/dist/lib/chat-supervision.js +37 -0
- package/dist/lib/commerce.d.ts +6 -0
- package/dist/lib/commerce.js +9 -0
- package/dist/lib/duties.d.ts +19 -1
- package/dist/lib/duties.js +21 -3
- package/dist/lib/json-output.d.ts +2 -0
- package/dist/lib/json-output.js +8 -4
- package/dist/lib/miniComputer.d.ts +1 -0
- package/dist/lib/miniComputer.js +7 -2
- package/dist/lib/miniComputerCommand.js +4 -1
- package/dist/lib/node-adapter.d.ts +2 -0
- package/dist/lib/node-adapter.js +35 -8
- package/dist/lib/outbox.d.ts +110 -1
- package/dist/lib/outbox.js +261 -35
- package/dist/lib/roles.d.ts +1 -1
- package/dist/lib/space-deletion-cancel.d.ts +47 -0
- package/dist/lib/space-deletion-cancel.js +141 -0
- package/dist/lib/widgetCheck.js +30 -4
- package/dist/lib/widgetStaticScan.d.ts +24 -9
- package/dist/lib/widgetStaticScan.js +207 -192
- package/dist/lib/write-outcome.d.ts +74 -0
- package/dist/lib/write-outcome.js +176 -0
- package/dist/node_modules/@skrr-ai/data-provider/APP_HTML_PARSER_LICENSES.txt +36 -0
- package/dist/node_modules/@skrr-ai/data-provider/index.js +20204 -15169
- package/oclif.manifest.json +2143 -25
- package/package.json +10 -3
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
5
|
+
const base_command_1 = require("../../../base-command");
|
|
6
|
+
const apps_command_1 = require("../../../lib/apps-command");
|
|
7
|
+
const appData_1 = require("../../../lib/appData");
|
|
8
|
+
/** What the receipt of a write applied, as lines a terminal can show (every value is the server's, so it is written out safely). */
|
|
9
|
+
function describeApplied(applied) {
|
|
10
|
+
if ('results' in applied) {
|
|
11
|
+
return applied.results.map((step) => `${step.op} ${(0, appData_1.safeForTerminal)(step.collection)}/${(0, appData_1.safeForTerminal)(step.id)} (rev ${step.rev}${step.created ? ', created' : ''}${step.deleted ? ', deleted' : ''})`);
|
|
12
|
+
}
|
|
13
|
+
if ('deleted' in applied) {
|
|
14
|
+
return [
|
|
15
|
+
`deleted ${(0, appData_1.safeForTerminal)(applied.collection)}/${(0, appData_1.safeForTerminal)(applied.id)} (it was at rev ${applied.rev})`,
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
if ('collection' in applied) {
|
|
19
|
+
return [
|
|
20
|
+
`wrote ${(0, appData_1.safeForTerminal)(applied.collection)}/${(0, appData_1.safeForTerminal)(applied.id)} (rev ${applied.rev}, ${applied.created ? 'created' : 'replaced'}) at ${(0, appData_1.safeForTerminal)(applied.updatedAt)}`,
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
return [`settings of version ${(0, appData_1.safeForTerminal)(applied.versionId)}`];
|
|
24
|
+
}
|
|
25
|
+
class AppsOperationsCheck extends apps_command_1.AppsCommand {
|
|
26
|
+
static description = 'Ask the server what became of a write to an installed app\'s data that you sent with an idempotency key and lost the answer to. The server answers "completed" (with what it applied: the collection, the document ids and revisions, for a batch every step, including the IDs it named) when it kept a receipt of that write for YOU, or "unknown" when it did not. "unknown" is NEVER "not applied": it only means no receipt is on record (the write may never have arrived, may have been refused, may still be running, may have run where no receipt is kept, or the receipt may have expired after 24 hours). It writes nothing. The key is sent in a header and never appears in a URL. `apps data put | patch | delete | batch` print the key when the outcome of a write is unknown; a write you sent yourself with --idempotency-key is asked about the same way. Only the person who made the write can find its receipt.';
|
|
27
|
+
static examples = [
|
|
28
|
+
'<%= config.bin %> apps operations check appi_abc put goals main --key skrr-data:3f2b8c1e-7d44-4b1a-9a52-0c6e1d2f9a10',
|
|
29
|
+
'<%= config.bin %> apps operations check appi_abc batch --key my-nightly-import-2026-11-10 --json',
|
|
30
|
+
];
|
|
31
|
+
static args = {
|
|
32
|
+
installation: core_1.Args.string({
|
|
33
|
+
description: 'The installation id (appi_...)',
|
|
34
|
+
required: true,
|
|
35
|
+
ignoreStdin: true,
|
|
36
|
+
}),
|
|
37
|
+
op: core_1.Args.string({
|
|
38
|
+
description: 'Which write it was',
|
|
39
|
+
required: true,
|
|
40
|
+
options: ['put', 'patch', 'delete', 'batch'],
|
|
41
|
+
ignoreStdin: true,
|
|
42
|
+
}),
|
|
43
|
+
collection: core_1.Args.string({
|
|
44
|
+
description: 'The collection the write named (put, patch and delete; not batch)',
|
|
45
|
+
required: false,
|
|
46
|
+
ignoreStdin: true,
|
|
47
|
+
}),
|
|
48
|
+
id: core_1.Args.string({
|
|
49
|
+
description: 'The document id the write named (put, patch and delete; not batch)',
|
|
50
|
+
required: false,
|
|
51
|
+
ignoreStdin: true,
|
|
52
|
+
}),
|
|
53
|
+
};
|
|
54
|
+
static flags = {
|
|
55
|
+
json: core_1.Flags.boolean({ description: 'Output the answer as JSON' }),
|
|
56
|
+
key: core_1.Flags.string({
|
|
57
|
+
description: 'The idempotency key the write was sent with',
|
|
58
|
+
required: true,
|
|
59
|
+
}),
|
|
60
|
+
};
|
|
61
|
+
async run() {
|
|
62
|
+
this.requireAuth();
|
|
63
|
+
const { args, flags } = await this.parse(AppsOperationsCheck);
|
|
64
|
+
try {
|
|
65
|
+
const key = (0, appData_1.checkIdempotencyKey)(flags.key);
|
|
66
|
+
const named = {
|
|
67
|
+
op: args.op,
|
|
68
|
+
...(args.collection === undefined ? {} : { collection: args.collection }),
|
|
69
|
+
...(args.id === undefined ? {} : { id: args.id }),
|
|
70
|
+
};
|
|
71
|
+
const target = (0, data_provider_1.parseAppOperationTarget)(named);
|
|
72
|
+
if (!target || target.op === 'settings') {
|
|
73
|
+
throw new appData_1.AppDataInputError('APP_DATA_SOURCE', args.op === 'batch'
|
|
74
|
+
? 'A batch names no collection or document id.'
|
|
75
|
+
: 'put, patch and delete name the collection and the document id: `apps operations check <installation> put <collection> <id> --key <key>`.');
|
|
76
|
+
}
|
|
77
|
+
const raw = await data_provider_1.dataService.getAppInstallationOperationByKey(args.installation, target, key);
|
|
78
|
+
const read = (0, data_provider_1.parseAppOperationRead)(raw);
|
|
79
|
+
// An answer that is not an operation read, or is about another installation, tells this client nothing: say so, claim nothing.
|
|
80
|
+
if (read === null || read.installationId !== args.installation) {
|
|
81
|
+
return this.failWithCliError({
|
|
82
|
+
message: 'The server answered, but not with an operation this client understands. Nothing is known about the write; read the affected data before deciding what to do.',
|
|
83
|
+
code: 'APP_OPERATION_UNREADABLE',
|
|
84
|
+
exit: 1,
|
|
85
|
+
retryable: false,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
if (read.state === 'unknown') {
|
|
89
|
+
return this.failWithCliError({
|
|
90
|
+
message: 'No receipt is on record for this write for you. That is NOT the same as "not applied": the write may never have arrived, may have been refused, may still be running, may have run on a server that keeps no receipts, or its receipt may have expired (they are kept for 24 hours). Read the affected data and revisions before deciding what to do.',
|
|
91
|
+
code: 'APP_OPERATION_UNKNOWN',
|
|
92
|
+
exit: 5,
|
|
93
|
+
retryable: false,
|
|
94
|
+
details: {
|
|
95
|
+
state: 'unknown',
|
|
96
|
+
installationId: read.installationId,
|
|
97
|
+
target: (0, data_provider_1.appOperationTargetQuery)(target),
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
if (flags.json) {
|
|
102
|
+
this.printJsonResult(read);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
this.log(`completed: the server kept a receipt of this write${read.recordedAt ? ` (recorded ${(0, appData_1.safeForTerminal)(read.recordedAt)})` : ''}`);
|
|
106
|
+
for (const line of describeApplied(read.applied))
|
|
107
|
+
this.log(line);
|
|
108
|
+
this.logToStderr(`operation ${read.operationId} (a reference for support)`);
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
if (error instanceof Error &&
|
|
112
|
+
((0, base_command_1.isOclifExitError)(error) ||
|
|
113
|
+
typeof error.oclif?.exit === 'number'))
|
|
114
|
+
throw error;
|
|
115
|
+
if (error instanceof appData_1.AppDataInputError) {
|
|
116
|
+
return this.failWithCliError({
|
|
117
|
+
message: error.message,
|
|
118
|
+
code: error.code,
|
|
119
|
+
exit: 2,
|
|
120
|
+
retryable: false,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return this.failInstallation(error, { subject: args.installation });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.default = AppsOperationsCheck;
|
|
@@ -4,7 +4,7 @@ const core_1 = require("@oclif/core");
|
|
|
4
4
|
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
5
5
|
const apps_command_1 = require("../../../lib/apps-command");
|
|
6
6
|
class AppsPublishPropose extends apps_command_1.AppsCommand {
|
|
7
|
-
static description =
|
|
7
|
+
static description = 'Record a publication request. It does not select a destination workspace, and workspace publication is not available yet; approval cannot publish the app.';
|
|
8
8
|
static examples = [
|
|
9
9
|
'<%= config.bin %> apps publish propose appv_... --visibility workspace --reason "ready for the team"',
|
|
10
10
|
];
|
|
@@ -18,7 +18,7 @@ class AppsPublishPropose extends apps_command_1.AppsCommand {
|
|
|
18
18
|
static flags = {
|
|
19
19
|
json: core_1.Flags.boolean({ description: 'Output the proposal as JSON' }),
|
|
20
20
|
visibility: core_1.Flags.string({
|
|
21
|
-
description: '
|
|
21
|
+
description: 'Proposal visibility label (workspace); does not select a destination workspace',
|
|
22
22
|
required: true,
|
|
23
23
|
}),
|
|
24
24
|
reason: core_1.Flags.string({ description: 'Why, in a sentence (the owner reads it)' }),
|
|
@@ -32,10 +32,39 @@ class AppsPublishPropose extends apps_command_1.AppsCommand {
|
|
|
32
32
|
...(flags.reason === undefined ? {} : { reason: flags.reason }),
|
|
33
33
|
});
|
|
34
34
|
if (flags.json) {
|
|
35
|
-
this.printJsonResult(
|
|
35
|
+
this.printJsonResult({
|
|
36
|
+
...result,
|
|
37
|
+
publication: result.publication ?? {
|
|
38
|
+
workspace: 'unknown',
|
|
39
|
+
destinationSelection: 'unknown',
|
|
40
|
+
approvalPublishes: null,
|
|
41
|
+
},
|
|
42
|
+
requestScope: result.requestScope ?? { kind: 'unknown' },
|
|
43
|
+
});
|
|
36
44
|
return;
|
|
37
45
|
}
|
|
38
|
-
this.log(`request ${result.requestId}
|
|
46
|
+
this.log(`request ${result.requestId} was recorded.`);
|
|
47
|
+
if (result.publication?.workspace === 'unavailable' &&
|
|
48
|
+
result.publication.destinationSelection === 'unavailable' &&
|
|
49
|
+
result.publication.approvalPublishes === false) {
|
|
50
|
+
this.log('This proposal does not select a destination workspace; workspace publication is not available yet.');
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
this.log('This server did not report a recognized publication status. This CLI cannot confirm whether a destination was selected or approval publishes the app.');
|
|
54
|
+
}
|
|
55
|
+
const scope = result.requestScope;
|
|
56
|
+
if (scope?.kind === 'workspace') {
|
|
57
|
+
this.log(`Request workspace: ${scope.workspaceId} (this is not a publication destination).`);
|
|
58
|
+
this.log(`Inspect it with \`${this.config.bin} requests show ${result.requestId} --workspace ${scope.workspaceId}\`.`);
|
|
59
|
+
}
|
|
60
|
+
else if (scope?.kind === 'unscoped') {
|
|
61
|
+
this.log('Request scope: unscoped.');
|
|
62
|
+
this.log(`Inspect it in an unscoped session with \`${this.config.bin} requests show ${result.requestId}\`.`);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
this.log('Request scope: unknown on this server.');
|
|
66
|
+
this.log(`Inspect \`${this.config.bin} requests show ${result.requestId}\` using the request's actual scope.`);
|
|
67
|
+
}
|
|
39
68
|
}
|
|
40
69
|
catch (error) {
|
|
41
70
|
this.failApps(error);
|
|
@@ -24,8 +24,14 @@ class AppsReconsent extends apps_command_1.AppsCommand {
|
|
|
24
24
|
async run() {
|
|
25
25
|
this.requireAuth();
|
|
26
26
|
const { args, flags } = await this.parse(AppsReconsent);
|
|
27
|
+
// what a refusal's words may say about this approval: the installation, and the version it runs when it is read
|
|
28
|
+
const refused = {
|
|
29
|
+
action: 'reconsent',
|
|
30
|
+
subject: args.installation,
|
|
31
|
+
};
|
|
27
32
|
try {
|
|
28
33
|
const current = await data_provider_1.dataService.getAppInstallation(args.installation);
|
|
34
|
+
refused.versionId = current.installation.versionId;
|
|
29
35
|
const shown = await data_provider_1.dataService.getAppGrantDisclosure({
|
|
30
36
|
versionId: current.installation.versionId,
|
|
31
37
|
installationId: current.installation.id,
|
|
@@ -66,7 +72,7 @@ class AppsReconsent extends apps_command_1.AppsCommand {
|
|
|
66
72
|
this.log(`approved ${result.installation.id}: it is ${result.installation.availability} now`);
|
|
67
73
|
}
|
|
68
74
|
catch (error) {
|
|
69
|
-
this.failInstallation(error);
|
|
75
|
+
this.failInstallation(error, refused);
|
|
70
76
|
}
|
|
71
77
|
}
|
|
72
78
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
2
|
/**
|
|
3
|
-
* `skrr apps reference [topic]`: the reference for writing an App, the
|
|
4
|
-
*
|
|
3
|
+
* `skrr apps reference [topic]`: the reference for writing an App, the one the Apps MCP's `app_reference` tool answers,
|
|
4
|
+
* for a harness that has the CLI and no MCP server. It is the same text said for the CLI (`surface: 'cli'`): where the
|
|
5
|
+
* MCP text names a tool (`app_check`) this one names the command that does the same (`skrr apps check`), because a
|
|
6
|
+
* harness here has no such tool to call.
|
|
5
7
|
*
|
|
6
8
|
* It extends `Command`, not `BaseCommand`, for the reason `apps check` does: it prints text built from the contract
|
|
7
9
|
* (`appReferenceText`, `@skrr-ai/data-provider`), so it needs no sign-in and no network, and it reaches no API. The text
|
|
@@ -4,8 +4,10 @@ const core_1 = require("@oclif/core");
|
|
|
4
4
|
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
5
5
|
const json_output_1 = require("../../lib/json-output");
|
|
6
6
|
/**
|
|
7
|
-
* `skrr apps reference [topic]`: the reference for writing an App, the
|
|
8
|
-
*
|
|
7
|
+
* `skrr apps reference [topic]`: the reference for writing an App, the one the Apps MCP's `app_reference` tool answers,
|
|
8
|
+
* for a harness that has the CLI and no MCP server. It is the same text said for the CLI (`surface: 'cli'`): where the
|
|
9
|
+
* MCP text names a tool (`app_check`) this one names the command that does the same (`skrr apps check`), because a
|
|
10
|
+
* harness here has no such tool to call.
|
|
9
11
|
*
|
|
10
12
|
* It extends `Command`, not `BaseCommand`, for the reason `apps check` does: it prints text built from the contract
|
|
11
13
|
* (`appReferenceText`, `@skrr-ai/data-provider`), so it needs no sign-in and no network, and it reaches no API. The text
|
|
@@ -13,10 +15,11 @@ const json_output_1 = require("../../lib/json-output");
|
|
|
13
15
|
* harness reads here is what `apps check` will hold its package to.
|
|
14
16
|
*/
|
|
15
17
|
class AppsReference extends core_1.Command {
|
|
16
|
-
static description = "Print the reference for writing an App, generated from the platform contract: app.json keys, the window API (window.skrr.app), scheduled jobs, app data, and the window's page (ES modules, the libraries it may import with their versions, the --skrr-* theme tokens, the first-party UI kit). With no topic you get a one-page index. Needs no sign-in.";
|
|
18
|
+
static description = "Print the reference for writing an App, generated from the platform contract: app.json keys, the window API (window.skrr.app), scheduled jobs, app data, background service declarations, and the window's page (ES modules, the libraries it may import with their versions, the --skrr-* theme tokens, the first-party UI kit). With no topic you get a one-page index. Needs no sign-in.";
|
|
17
19
|
static examples = [
|
|
18
20
|
'<%= config.bin %> apps reference',
|
|
19
21
|
'<%= config.bin %> apps reference frame',
|
|
22
|
+
'<%= config.bin %> apps reference service',
|
|
20
23
|
'<%= config.bin %> apps reference sdk --json',
|
|
21
24
|
];
|
|
22
25
|
static args = {
|
|
@@ -45,7 +48,7 @@ class AppsReference extends core_1.Command {
|
|
|
45
48
|
exit: 2,
|
|
46
49
|
});
|
|
47
50
|
}
|
|
48
|
-
const answer = (0, data_provider_1.appReferenceText)(topic);
|
|
51
|
+
const answer = (0, data_provider_1.appReferenceText)(topic, { surface: 'cli' });
|
|
49
52
|
if (flags.json) {
|
|
50
53
|
this.printJson({ topic: answer.topic, text: answer.text });
|
|
51
54
|
return;
|
|
@@ -7,7 +7,16 @@ export default class AppsRollback extends AppsCommand {
|
|
|
7
7
|
};
|
|
8
8
|
static flags: {
|
|
9
9
|
'expected-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
'expected-target': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
'check-data': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
13
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
14
|
};
|
|
12
15
|
run(): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* `--check-data`: find the version a rollback would go to (the one named, else the server's current rollback target), check the data
|
|
18
|
+
* against it, print the result, and decide whether to go on (see `apps upgrade`). Returns the version checked, or `undefined` when
|
|
19
|
+
* there is nothing to go back to (the rollback then says so itself, as it always did).
|
|
20
|
+
*/
|
|
21
|
+
private checkDataFirst;
|
|
13
22
|
}
|
|
@@ -3,12 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
4
|
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
5
5
|
const apps_command_1 = require("../../lib/apps-command");
|
|
6
|
+
const appCompatibility_1 = require("../../lib/appCompatibility");
|
|
6
7
|
const appInstallations_1 = require("../../lib/appInstallations");
|
|
8
|
+
const drain_stdio_1 = require("../../lib/drain-stdio");
|
|
7
9
|
class AppsRollback extends apps_command_1.AppsCommand {
|
|
8
|
-
static description = 'Put an installation back on the version it ran before the current one, in one call. It works for you and for your agent, and it never widens what you approved: if the earlier version needs an approval you have since changed, the installation says it needs your approval again. Repeating it goes back one more step.';
|
|
10
|
+
static description = 'Put an installation back on the version it ran before the current one, in one call. It works for you and for your agent, and it never widens what you approved: if the earlier version needs an approval you have since changed, the installation says it needs your approval again. Repeating it goes back one more step. With --check-data it first checks whether the installation’s stored data fits the data schemas of the version it would go back to (`apps installations compatibility`) and prints the result; if the data is incompatible or could not be proven compatible it stops before moving, unless you add --yes. The server never refuses a rollback because of that check; getting back to what ran before is always yours to do.';
|
|
9
11
|
static examples = [
|
|
10
12
|
'<%= config.bin %> apps rollback appi_abc',
|
|
11
13
|
'<%= config.bin %> apps rollback appi_abc --expected-version appv_current',
|
|
14
|
+
'<%= config.bin %> apps rollback appi_abc --expected-version appv_current --expected-target appv_previous',
|
|
15
|
+
'<%= config.bin %> apps rollback appi_abc --check-data',
|
|
16
|
+
'<%= config.bin %> apps rollback appi_abc --check-data --yes',
|
|
12
17
|
];
|
|
13
18
|
static args = {
|
|
14
19
|
installation: core_1.Args.string({
|
|
@@ -19,16 +24,42 @@ class AppsRollback extends apps_command_1.AppsCommand {
|
|
|
19
24
|
};
|
|
20
25
|
static flags = {
|
|
21
26
|
'expected-version': core_1.Flags.string({
|
|
22
|
-
description: 'Proceed only if this version (appv_...) is still installed.
|
|
27
|
+
description: 'Proceed only if this version (appv_...) is still installed. On its own this does not pin the version the rollback goes back to: use --expected-target for that.',
|
|
28
|
+
}),
|
|
29
|
+
'expected-target': core_1.Flags.string({
|
|
30
|
+
description: 'Proceed only if the version this would go back to is this one (appv_...), as `apps installations versions` showed it. The server works the target out from the installation history when the request arrives; if it is a different version, nothing is moved.',
|
|
31
|
+
}),
|
|
32
|
+
'check-data': core_1.Flags.boolean({
|
|
33
|
+
description: 'First check the installation’s stored data against the schemas of the version this would go back to, and print the result. Compatible: go back. Incompatible or unknown: stop (exit 1 or 5) unless --yes. The version checked is the one moved to (it is sent as --expected-target)',
|
|
34
|
+
default: false,
|
|
35
|
+
}),
|
|
36
|
+
yes: core_1.Flags.boolean({
|
|
37
|
+
description: 'With --check-data: go back even though the check found the data incompatible or could not prove it compatible. It changes no data',
|
|
38
|
+
default: false,
|
|
23
39
|
}),
|
|
24
40
|
json: core_1.Flags.boolean({ description: 'Output the installation as JSON' }),
|
|
25
41
|
};
|
|
26
42
|
async run() {
|
|
27
43
|
this.requireAuth();
|
|
28
44
|
const { args, flags } = await this.parse(AppsRollback);
|
|
45
|
+
if (flags.yes && !flags['check-data']) {
|
|
46
|
+
return this.failWithCliError({
|
|
47
|
+
message: '--yes only answers the question --check-data asks. Use `--check-data --yes`, or leave --yes out. Nothing was changed.',
|
|
48
|
+
code: 'APP_FLAG_INVALID',
|
|
49
|
+
exit: 2,
|
|
50
|
+
retryable: false,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
// the version the check was about is the version the rollback must go to, so the check cannot be about one and the move another
|
|
54
|
+
const checkedTarget = flags['check-data']
|
|
55
|
+
? await this.checkDataFirst(args.installation, flags['expected-target'], flags.yes, flags.json)
|
|
56
|
+
: undefined;
|
|
29
57
|
try {
|
|
30
58
|
const result = await data_provider_1.dataService.rollbackAppInstallation(args.installation, {
|
|
31
59
|
...(flags['expected-version'] ? { expectedVersionId: flags['expected-version'] } : {}),
|
|
60
|
+
...(flags['expected-target'] || checkedTarget
|
|
61
|
+
? { expectedTargetVersionId: flags['expected-target'] ?? checkedTarget }
|
|
62
|
+
: {}),
|
|
32
63
|
});
|
|
33
64
|
if (flags.json) {
|
|
34
65
|
this.printJsonResult(result);
|
|
@@ -43,5 +74,53 @@ class AppsRollback extends apps_command_1.AppsCommand {
|
|
|
43
74
|
this.failInstallation(error, { subject: args.installation });
|
|
44
75
|
}
|
|
45
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* `--check-data`: find the version a rollback would go to (the one named, else the server's current rollback target), check the data
|
|
79
|
+
* against it, print the result, and decide whether to go on (see `apps upgrade`). Returns the version checked, or `undefined` when
|
|
80
|
+
* there is nothing to go back to (the rollback then says so itself, as it always did).
|
|
81
|
+
*/
|
|
82
|
+
async checkDataFirst(installation, named, yes, json) {
|
|
83
|
+
let target = named;
|
|
84
|
+
let view = null;
|
|
85
|
+
try {
|
|
86
|
+
if (target === undefined) {
|
|
87
|
+
target = (await data_provider_1.dataService.getAppInstallationVersions(installation)).rollback?.versionId;
|
|
88
|
+
}
|
|
89
|
+
if (target === undefined) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
view = await (0, appCompatibility_1.fetchCompatibility)(installation, target);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
return this.failInstallation(error, { subject: installation });
|
|
96
|
+
}
|
|
97
|
+
if (view === null) {
|
|
98
|
+
return this.failWithCliError({
|
|
99
|
+
message: `${appCompatibility_1.COMPATIBILITY_UNREADABLE_MESSAGE} Nothing was changed.`,
|
|
100
|
+
code: 'APP_COMPATIBILITY_UNREADABLE',
|
|
101
|
+
exit: 5,
|
|
102
|
+
retryable: false,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
for (const line of (0, appCompatibility_1.formatCompatibility)(view)) {
|
|
106
|
+
if (json)
|
|
107
|
+
this.logToStderr(line);
|
|
108
|
+
else
|
|
109
|
+
this.log(line);
|
|
110
|
+
}
|
|
111
|
+
if (view.verdict === 'compatible' || yes) {
|
|
112
|
+
if (view.verdict !== 'compatible') {
|
|
113
|
+
this.logToStderr('Going back anyway, as you asked (--yes). No data is changed by a move.');
|
|
114
|
+
}
|
|
115
|
+
return target;
|
|
116
|
+
}
|
|
117
|
+
// `target` may come from the server: it is put in a command to copy only when it is a plain id
|
|
118
|
+
const pinned = /^appv_[A-Za-z0-9_-]{1,60}(?![\s\S])/.test(target ?? '')
|
|
119
|
+
? ` --expected-target ${target}`
|
|
120
|
+
: '';
|
|
121
|
+
this.logToStderr(`Not moved. To go back anyway: \`${this.config.bin} apps rollback ${installation}${pinned} --check-data --yes\`. To go back without the check, leave out --check-data.`);
|
|
122
|
+
await (0, drain_stdio_1.drainStdio)();
|
|
123
|
+
return this.exit((0, appCompatibility_1.compatibilityExit)(view));
|
|
124
|
+
}
|
|
46
125
|
}
|
|
47
126
|
exports.default = AppsRollback;
|
|
@@ -9,6 +9,14 @@ export default class AppsUpgrade extends AppsCommand {
|
|
|
9
9
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
10
|
version: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
11
|
'expected-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
'check-data': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
14
|
};
|
|
13
15
|
run(): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* `--check-data`: ask, print, and decide whether to go on. Only a `compatible` answer goes on by itself; anything else stops, with the
|
|
18
|
+
* exit the check has (1 incompatible, 5 unknown, which an unreadable answer is), unless the person said --yes. A check that cannot be run
|
|
19
|
+
* (a request that fails) stops too: the person asked for the check and does not have it. Nothing is written by the check.
|
|
20
|
+
*/
|
|
21
|
+
private checkDataFirst;
|
|
14
22
|
}
|
|
@@ -3,12 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
4
|
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
5
5
|
const apps_command_1 = require("../../lib/apps-command");
|
|
6
|
+
const appCompatibility_1 = require("../../lib/appCompatibility");
|
|
6
7
|
const appInstallations_1 = require("../../lib/appInstallations");
|
|
8
|
+
const drain_stdio_1 = require("../../lib/drain-stdio");
|
|
7
9
|
class AppsUpgrade extends apps_command_1.AppsCommand {
|
|
8
|
-
static description = 'Move an installation to another version of its app (a newer one, or an older one to roll back). It never widens what was approved: a version that asks for more lands as needing your approval again, and does not run until you give it (`apps reconsent`).';
|
|
10
|
+
static description = 'Move an installation to another version of its app (a newer one, or an older one to roll back). It never widens what was approved: a version that asks for more lands as needing your approval again, and does not run until you give it (`apps reconsent`). With --check-data it first checks whether the installation’s stored data fits the data schemas that version declares (`apps installations compatibility`) and prints the result; if the data is incompatible or could not be proven compatible it stops before moving, unless you add --yes. The server never refuses a move because of that check; the choice is yours.';
|
|
9
11
|
static examples = [
|
|
10
12
|
'<%= config.bin %> apps upgrade appi_abc --version appv_xyz',
|
|
11
13
|
'<%= config.bin %> apps upgrade appi_abc --version appv_xyz --expected-version appv_old',
|
|
14
|
+
'<%= config.bin %> apps upgrade appi_abc --version appv_xyz --check-data',
|
|
15
|
+
'<%= config.bin %> apps upgrade appi_abc --version appv_xyz --check-data --yes',
|
|
12
16
|
];
|
|
13
17
|
static args = {
|
|
14
18
|
installation: core_1.Args.string({
|
|
@@ -23,10 +27,29 @@ class AppsUpgrade extends apps_command_1.AppsCommand {
|
|
|
23
27
|
'expected-version': core_1.Flags.string({
|
|
24
28
|
description: 'Move only if it still runs this version (appv_...); otherwise nothing changes',
|
|
25
29
|
}),
|
|
30
|
+
'check-data': core_1.Flags.boolean({
|
|
31
|
+
description: 'First check the installation’s stored data against that version’s declared schemas and print the result. Compatible: move. Incompatible or unknown: stop (exit 1 or 5) unless --yes',
|
|
32
|
+
default: false,
|
|
33
|
+
}),
|
|
34
|
+
yes: core_1.Flags.boolean({
|
|
35
|
+
description: 'With --check-data: move even though the check found the data incompatible or could not prove it compatible. It changes no data; `apps rollback` goes back',
|
|
36
|
+
default: false,
|
|
37
|
+
}),
|
|
26
38
|
};
|
|
27
39
|
async run() {
|
|
28
40
|
this.requireAuth();
|
|
29
41
|
const { args, flags } = await this.parse(AppsUpgrade);
|
|
42
|
+
if (flags.yes && !flags['check-data']) {
|
|
43
|
+
return this.failWithCliError({
|
|
44
|
+
message: '--yes only answers the question --check-data asks. Use `--check-data --yes`, or leave --yes out. Nothing was changed.',
|
|
45
|
+
code: 'APP_FLAG_INVALID',
|
|
46
|
+
exit: 2,
|
|
47
|
+
retryable: false,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (flags['check-data']) {
|
|
51
|
+
await this.checkDataFirst(args.installation, flags.version, flags.yes, flags.json);
|
|
52
|
+
}
|
|
30
53
|
try {
|
|
31
54
|
const result = await data_provider_1.dataService.activateAppInstallationVersion(args.installation, {
|
|
32
55
|
versionId: flags.version,
|
|
@@ -42,8 +65,50 @@ class AppsUpgrade extends apps_command_1.AppsCommand {
|
|
|
42
65
|
}
|
|
43
66
|
}
|
|
44
67
|
catch (error) {
|
|
45
|
-
this.failInstallation(error
|
|
68
|
+
this.failInstallation(error, {
|
|
69
|
+
action: 'upgrade',
|
|
70
|
+
subject: args.installation,
|
|
71
|
+
versionId: flags.version,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* `--check-data`: ask, print, and decide whether to go on. Only a `compatible` answer goes on by itself; anything else stops, with the
|
|
77
|
+
* exit the check has (1 incompatible, 5 unknown, which an unreadable answer is), unless the person said --yes. A check that cannot be run
|
|
78
|
+
* (a request that fails) stops too: the person asked for the check and does not have it. Nothing is written by the check.
|
|
79
|
+
*/
|
|
80
|
+
async checkDataFirst(installation, versionId, yes, json) {
|
|
81
|
+
let view;
|
|
82
|
+
try {
|
|
83
|
+
view = await (0, appCompatibility_1.fetchCompatibility)(installation, versionId);
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
return this.failInstallation(error, { action: 'upgrade', subject: installation, versionId });
|
|
87
|
+
}
|
|
88
|
+
if (view === null) {
|
|
89
|
+
return this.failWithCliError({
|
|
90
|
+
message: `${appCompatibility_1.COMPATIBILITY_UNREADABLE_MESSAGE} Nothing was changed.`,
|
|
91
|
+
code: 'APP_COMPATIBILITY_UNREADABLE',
|
|
92
|
+
exit: 5,
|
|
93
|
+
retryable: false,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
// The check is printed on STDERR with --json, so stdout stays one JSON document (the installation, as it always was).
|
|
97
|
+
for (const line of (0, appCompatibility_1.formatCompatibility)(view)) {
|
|
98
|
+
if (json)
|
|
99
|
+
this.logToStderr(line);
|
|
100
|
+
else
|
|
101
|
+
this.log(line);
|
|
102
|
+
}
|
|
103
|
+
if (view.verdict === 'compatible' || yes) {
|
|
104
|
+
if (view.verdict !== 'compatible') {
|
|
105
|
+
this.logToStderr('Moving anyway, as you asked (--yes). No data is changed by a move.');
|
|
106
|
+
}
|
|
107
|
+
return;
|
|
46
108
|
}
|
|
109
|
+
this.logToStderr(`Not moved. To move anyway: \`${this.config.bin} apps upgrade ${installation} --version ${versionId} --check-data --yes\`. To move without the check, leave out --check-data.`);
|
|
110
|
+
await (0, drain_stdio_1.drainStdio)();
|
|
111
|
+
return this.exit((0, appCompatibility_1.compatibilityExit)(view));
|
|
47
112
|
}
|
|
48
113
|
}
|
|
49
114
|
exports.default = AppsUpgrade;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AppsCommand } from '../../../lib/apps-command';
|
|
2
|
+
export default class AppsVersionCat extends AppsCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
version: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
path: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
8
|
+
};
|
|
9
|
+
static flags: {
|
|
10
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
out: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
raw: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
offset: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
limit: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
};
|
|
17
|
+
run(): Promise<void>;
|
|
18
|
+
/** What was checked, on stderr so stdout stays the file. */
|
|
19
|
+
private note;
|
|
20
|
+
/** Say what went wrong, in this command's terms where it has them. Never returns. */
|
|
21
|
+
private failVersionFile;
|
|
22
|
+
}
|