@skrr-ai/cli 0.1.164 → 0.1.165

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/README.md +13 -0
  2. package/dist/base-command.d.ts +14 -1
  3. package/dist/base-command.js +166 -46
  4. package/dist/commands/agent/message/send.d.ts +1 -0
  5. package/dist/commands/agent/message/send.js +3 -0
  6. package/dist/commands/agents/mini-computer/app/set.js +1 -1
  7. package/dist/commands/agents/mini-computer/tasks-view.js +1 -1
  8. package/dist/commands/apps/check.js +3 -8
  9. package/dist/commands/apps/data/batch.d.ts +1 -0
  10. package/dist/commands/apps/data/batch.js +19 -2
  11. package/dist/commands/apps/data/delete.d.ts +1 -0
  12. package/dist/commands/apps/data/delete.js +14 -2
  13. package/dist/commands/apps/data/patch.d.ts +1 -0
  14. package/dist/commands/apps/data/patch.js +11 -2
  15. package/dist/commands/apps/data/put.d.ts +1 -0
  16. package/dist/commands/apps/data/put.js +17 -3
  17. package/dist/commands/apps/install.js +7 -2
  18. package/dist/commands/apps/installations/compatibility.d.ts +13 -0
  19. package/dist/commands/apps/installations/compatibility.js +60 -0
  20. package/dist/commands/apps/installations/show.js +9 -3
  21. package/dist/commands/apps/installations/snapshot.js +5 -2
  22. package/dist/commands/apps/operations/check.d.ts +16 -0
  23. package/dist/commands/apps/operations/check.js +127 -0
  24. package/dist/commands/apps/publish/propose.js +33 -4
  25. package/dist/commands/apps/reconsent.js +7 -1
  26. package/dist/commands/apps/reference.d.ts +4 -2
  27. package/dist/commands/apps/reference.js +7 -4
  28. package/dist/commands/apps/rollback.d.ts +9 -0
  29. package/dist/commands/apps/rollback.js +81 -2
  30. package/dist/commands/apps/upgrade.d.ts +8 -0
  31. package/dist/commands/apps/upgrade.js +67 -2
  32. package/dist/commands/apps/version/cat.d.ts +22 -0
  33. package/dist/commands/apps/version/cat.js +220 -0
  34. package/dist/commands/apps/version/show.js +3 -1
  35. package/dist/commands/commerce/incidents/release.d.ts +24 -0
  36. package/dist/commands/commerce/incidents/release.js +46 -0
  37. package/dist/commands/duties/cases.js +12 -1
  38. package/dist/commands/duties/hypotheses.js +10 -3
  39. package/dist/commands/duties/observations.d.ts +4 -0
  40. package/dist/commands/duties/observations.js +14 -3
  41. package/dist/commands/outbox/list.d.ts +11 -4
  42. package/dist/commands/outbox/list.js +56 -9
  43. package/dist/commands/outbox/retry.d.ts +8 -2
  44. package/dist/commands/outbox/retry.js +76 -16
  45. package/dist/commands/outbox/show.d.ts +20 -0
  46. package/dist/commands/outbox/show.js +83 -0
  47. package/dist/commands/proposals/list.js +13 -9
  48. package/dist/commands/requests/show.d.ts +12 -0
  49. package/dist/commands/requests/show.js +42 -23
  50. package/dist/commands/spaces/deletion/cancel.d.ts +21 -0
  51. package/dist/commands/spaces/deletion/cancel.js +70 -0
  52. package/dist/commands/spaces/workflows/run.js +12 -0
  53. package/dist/commands/widgets/check.d.ts +9 -0
  54. package/dist/commands/widgets/check.js +16 -3
  55. package/dist/generated/agent-guides.json +17 -17
  56. package/dist/lib/api-fetch.d.ts +5 -0
  57. package/dist/lib/api-fetch.js +53 -21
  58. package/dist/lib/appCompatibility.d.ts +31 -0
  59. package/dist/lib/appCompatibility.js +66 -0
  60. package/dist/lib/appData.d.ts +46 -4
  61. package/dist/lib/appData.js +156 -31
  62. package/dist/lib/appInstallations.d.ts +32 -5
  63. package/dist/lib/appInstallations.js +197 -34
  64. package/dist/lib/appVersionFile.d.ts +82 -0
  65. package/dist/lib/appVersionFile.js +195 -0
  66. package/dist/lib/apps-command.d.ts +14 -3
  67. package/dist/lib/apps-command.js +68 -60
  68. package/dist/lib/appsCheck.js +16 -2
  69. package/dist/lib/commerce.d.ts +6 -0
  70. package/dist/lib/commerce.js +9 -0
  71. package/dist/lib/duties.d.ts +15 -1
  72. package/dist/lib/duties.js +21 -3
  73. package/dist/lib/json-output.d.ts +2 -0
  74. package/dist/lib/json-output.js +8 -4
  75. package/dist/lib/node-adapter.d.ts +2 -0
  76. package/dist/lib/node-adapter.js +35 -8
  77. package/dist/lib/outbox.d.ts +110 -1
  78. package/dist/lib/outbox.js +261 -35
  79. package/dist/lib/space-deletion-cancel.d.ts +47 -0
  80. package/dist/lib/space-deletion-cancel.js +141 -0
  81. package/dist/lib/widgetCheck.js +1 -1
  82. package/dist/lib/widgetStaticScan.d.ts +11 -5
  83. package/dist/lib/widgetStaticScan.js +73 -165
  84. package/dist/lib/write-outcome.d.ts +74 -0
  85. package/dist/lib/write-outcome.js +176 -0
  86. package/dist/node_modules/@skrr-ai/data-provider/index.js +11839 -11318
  87. package/oclif.manifest.json +1940 -16
  88. package/package.json +9 -3
@@ -0,0 +1,74 @@
1
+ /**
2
+ * The CLI's side of the shared write-outcome contract (OSK-24076, step 2).
3
+ *
4
+ * `classifyWriteOutcome` (`@skrr-ai/data-provider`) says what a failed write is: confirmed, rejected, or unknown, and whether
5
+ * the same request may be sent again on its own. This file is where the CLI feeds it, so the generic error path, the outbox
6
+ * and `skrr apps data` ask ONE question the same way:
7
+ *
8
+ * - `routeHasReceipt` comes from the registry of routes the SERVER mounts `requestIdempotency` on
9
+ * (`routeHasReplayReceipt`), never from the header the client sent or a URL pattern written here;
10
+ * - a write with no declared receipt that gets a 408, 425, a 5xx or no answer is UNKNOWN and NOT retryable. The message
11
+ * says so and says to look at the current state first.
12
+ *
13
+ * Reads, and writes on a route that does keep a receipt, retry as they did. A 400/403/404/409/422 refusal, a 401 and a 429
14
+ * are not decided here: they keep the classification their callers already gave them.
15
+ */
16
+ import { type WriteOutcome, type WriteRefusalContract } from '@skrr-ai/data-provider';
17
+ /** The error code of a write whose outcome is unknown. One code for the generic path, in the `*_OUTCOME_UNKNOWN` style. */
18
+ export declare const WRITE_OUTCOME_UNKNOWN_CODE = "WRITE_OUTCOME_UNKNOWN";
19
+ /** Which request failed. The adapter and `apiFetch` stamp `method` and `requestPath` on every error they throw. */
20
+ export interface FailedRequest {
21
+ method?: string;
22
+ /** The path of the request URL, with no origin and no query. */
23
+ path?: string;
24
+ }
25
+ /** The path of a request URL (absolute or relative), with no query or fragment; undefined when there is none. */
26
+ export declare function requestPathOf(url: unknown): string | undefined;
27
+ /** The request an error was thrown for: what the transport stamped on it. */
28
+ export declare function requestOfError(err: unknown): FailedRequest;
29
+ /** Stamp the request on an error that does not carry it yet (a transport error has neither). Returns the same error. */
30
+ export declare function stampRequest<E>(err: E, method: string, url: unknown): E;
31
+ /** A request known to be a write: it names a method, and the method is not a read. */
32
+ export declare function isKnownWrite(request: FailedRequest | undefined): request is FailedRequest;
33
+ /** Does the server keep a replay receipt for this request? False unless the registry says so. */
34
+ export declare function requestHasReceipt(request: FailedRequest | undefined): boolean;
35
+ /**
36
+ * Did the request provably never leave this machine? A refused connection or a failed name lookup sends no bytes, so
37
+ * "nothing happened" is a fact there, not a guess. A timeout or a reset is not: the server may have read the request.
38
+ */
39
+ export declare function requestNeverSent(err: unknown): boolean;
40
+ /** The shared classification of a finished request. The `routeHasReceipt` is the server's, from the registry. */
41
+ export declare function classifyRequestOutcome(input: {
42
+ request: FailedRequest;
43
+ status?: number | null;
44
+ body?: unknown;
45
+ transportError?: boolean;
46
+ bodyConfirms?: boolean;
47
+ /** The route's typed refusals, when the caller has the contract (see `WriteRefusalContract`). */
48
+ refusals?: WriteRefusalContract;
49
+ }): WriteOutcome;
50
+ /** The statuses whose meaning for a write the owner decided: nothing says the write did not run. */
51
+ export declare function isAmbiguousStatus(status: number | undefined): boolean;
52
+ export interface UnknownWrite {
53
+ outcome: WriteOutcome;
54
+ request: FailedRequest;
55
+ /** No HTTP answer at all. */
56
+ transport: boolean;
57
+ }
58
+ /**
59
+ * Is this failure a write whose outcome is unknown AND that must not be retried on its own?
60
+ *
61
+ * Yes only for a write the CLI can name, on a route without a server receipt, that failed the way the contract calls
62
+ * unknown and the owner's rule covers: 408, 425, a 5xx, no answer, or a failure the server tagged `after_write`. Everything
63
+ * else returns null and takes the path it always took: a request that never left, a read, a write on a route that keeps a
64
+ * receipt, a refusal, a 401, a 429.
65
+ */
66
+ export declare function unknownWriteOf(err: unknown, body: unknown): UnknownWrite | null;
67
+ /** What the person is told. Names no path: a path can carry a credential. */
68
+ export declare function describeUnknownWrite(input: {
69
+ baseURL: string;
70
+ unknown: UnknownWrite;
71
+ status?: number;
72
+ serverMessage?: string;
73
+ requestId?: string;
74
+ }): string;
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WRITE_OUTCOME_UNKNOWN_CODE = void 0;
4
+ exports.requestPathOf = requestPathOf;
5
+ exports.requestOfError = requestOfError;
6
+ exports.stampRequest = stampRequest;
7
+ exports.isKnownWrite = isKnownWrite;
8
+ exports.requestHasReceipt = requestHasReceipt;
9
+ exports.requestNeverSent = requestNeverSent;
10
+ exports.classifyRequestOutcome = classifyRequestOutcome;
11
+ exports.isAmbiguousStatus = isAmbiguousStatus;
12
+ exports.unknownWriteOf = unknownWriteOf;
13
+ exports.describeUnknownWrite = describeUnknownWrite;
14
+ /**
15
+ * The CLI's side of the shared write-outcome contract (OSK-24076, step 2).
16
+ *
17
+ * `classifyWriteOutcome` (`@skrr-ai/data-provider`) says what a failed write is: confirmed, rejected, or unknown, and whether
18
+ * the same request may be sent again on its own. This file is where the CLI feeds it, so the generic error path, the outbox
19
+ * and `skrr apps data` ask ONE question the same way:
20
+ *
21
+ * - `routeHasReceipt` comes from the registry of routes the SERVER mounts `requestIdempotency` on
22
+ * (`routeHasReplayReceipt`), never from the header the client sent or a URL pattern written here;
23
+ * - a write with no declared receipt that gets a 408, 425, a 5xx or no answer is UNKNOWN and NOT retryable. The message
24
+ * says so and says to look at the current state first.
25
+ *
26
+ * Reads, and writes on a route that does keep a receipt, retry as they did. A 400/403/404/409/422 refusal, a 401 and a 429
27
+ * are not decided here: they keep the classification their callers already gave them.
28
+ */
29
+ const data_provider_1 = require("@skrr-ai/data-provider");
30
+ /** The error code of a write whose outcome is unknown. One code for the generic path, in the `*_OUTCOME_UNKNOWN` style. */
31
+ exports.WRITE_OUTCOME_UNKNOWN_CODE = 'WRITE_OUTCOME_UNKNOWN';
32
+ const READ_METHODS = ['GET', 'HEAD', 'OPTIONS'];
33
+ /** The path of a request URL (absolute or relative), with no query or fragment; undefined when there is none. */
34
+ function requestPathOf(url) {
35
+ if (typeof url !== 'string' || url.trim() === '')
36
+ return undefined;
37
+ try {
38
+ return new URL(url, 'http://placeholder.invalid').pathname;
39
+ }
40
+ catch {
41
+ return undefined;
42
+ }
43
+ }
44
+ /** The request an error was thrown for: what the transport stamped on it. */
45
+ function requestOfError(err) {
46
+ const e = err;
47
+ return {
48
+ ...(typeof e?.method === 'string' && e.method.trim() ? { method: e.method } : {}),
49
+ ...(typeof e?.requestPath === 'string' && e.requestPath ? { path: e.requestPath } : {}),
50
+ };
51
+ }
52
+ /** Stamp the request on an error that does not carry it yet (a transport error has neither). Returns the same error. */
53
+ function stampRequest(err, method, url) {
54
+ if (err !== null && typeof err === 'object') {
55
+ const target = err;
56
+ try {
57
+ if (typeof target.method !== 'string')
58
+ target.method = method.toUpperCase();
59
+ if (typeof target.requestPath !== 'string') {
60
+ const path = requestPathOf(url);
61
+ if (path !== undefined)
62
+ target.requestPath = path;
63
+ }
64
+ }
65
+ catch {
66
+ /* a frozen error: the caller loses the stamp, never the error */
67
+ }
68
+ }
69
+ return err;
70
+ }
71
+ /** A request known to be a write: it names a method, and the method is not a read. */
72
+ function isKnownWrite(request) {
73
+ const method = request?.method?.trim().toUpperCase();
74
+ return Boolean(method) && !READ_METHODS.includes(method);
75
+ }
76
+ /** Does the server keep a replay receipt for this request? False unless the registry says so. */
77
+ function requestHasReceipt(request) {
78
+ return (0, data_provider_1.routeHasReplayReceipt)(request?.method, request?.path);
79
+ }
80
+ const NEVER_SENT_CODES = ['ECONNREFUSED', 'ENOTFOUND', 'EAI_AGAIN'];
81
+ /**
82
+ * Did the request provably never leave this machine? A refused connection or a failed name lookup sends no bytes, so
83
+ * "nothing happened" is a fact there, not a guess. A timeout or a reset is not: the server may have read the request.
84
+ */
85
+ function requestNeverSent(err) {
86
+ const seen = [];
87
+ const check = (value, depth) => {
88
+ if (value === null || typeof value !== 'object' || depth > 3 || seen.includes(value)) {
89
+ return false;
90
+ }
91
+ seen.push(value);
92
+ const v = value;
93
+ if (typeof v.code === 'string' && NEVER_SENT_CODES.includes(v.code))
94
+ return true;
95
+ if (typeof v.message === 'string' &&
96
+ NEVER_SENT_CODES.some((code) => v.message.includes(code))) {
97
+ return true;
98
+ }
99
+ if (Array.isArray(v.errors) &&
100
+ v.errors.length > 0 &&
101
+ v.errors.every((x) => check(x, depth + 1))) {
102
+ return true;
103
+ }
104
+ return check(v.cause, depth + 1);
105
+ };
106
+ return check(err, 0);
107
+ }
108
+ /** The shared classification of a finished request. The `routeHasReceipt` is the server's, from the registry. */
109
+ function classifyRequestOutcome(input) {
110
+ return (0, data_provider_1.classifyWriteOutcome)({
111
+ method: input.request.method ?? '',
112
+ status: input.status,
113
+ body: input.body,
114
+ transportError: input.transportError,
115
+ bodyConfirms: input.bodyConfirms,
116
+ refusals: input.refusals,
117
+ routeHasReceipt: requestHasReceipt(input.request),
118
+ });
119
+ }
120
+ /** The statuses whose meaning for a write the owner decided: nothing says the write did not run. */
121
+ function isAmbiguousStatus(status) {
122
+ return status === 408 || status === 425 || (typeof status === 'number' && status >= 500);
123
+ }
124
+ /**
125
+ * Is this failure a write whose outcome is unknown AND that must not be retried on its own?
126
+ *
127
+ * Yes only for a write the CLI can name, on a route without a server receipt, that failed the way the contract calls
128
+ * unknown and the owner's rule covers: 408, 425, a 5xx, no answer, or a failure the server tagged `after_write`. Everything
129
+ * else returns null and takes the path it always took: a request that never left, a read, a write on a route that keeps a
130
+ * receipt, a refusal, a 401, a 429.
131
+ */
132
+ function unknownWriteOf(err, body) {
133
+ const e = err;
134
+ const request = requestOfError(err);
135
+ if (!isKnownWrite(request))
136
+ return null;
137
+ const status = typeof e?.status === 'number' && e.status > 0 ? e.status : undefined;
138
+ const transport = status === undefined;
139
+ // Only the failures the contract calls unknown get this far. An answer the server gave (a 400, 403, 404, 409, 422, a 401,
140
+ // a 429, a redirect) is not asked about here at all, so its classification cannot change with the registry.
141
+ const phase = body?.phase;
142
+ const taggedAfterWrite = typeof phase === 'string' && phase === data_provider_1.WRITE_FAILURE_PHASE_AFTER_WRITE;
143
+ if (!transport && !isAmbiguousStatus(status) && !taggedAfterWrite)
144
+ return null;
145
+ if (transport && requestNeverSent(err))
146
+ return null;
147
+ const outcome = classifyRequestOutcome({ request, status, body, transportError: transport });
148
+ if (outcome.kind !== 'unknown' || outcome.retryable)
149
+ return null;
150
+ const covered = outcome.reason === 'timeout' ||
151
+ outcome.reason === 'server_error' ||
152
+ outcome.reason === 'transport_error' ||
153
+ outcome.reason === 'after_write';
154
+ return covered ? { outcome, request, transport } : null;
155
+ }
156
+ /** What the person is told. Names no path: a path can carry a credential. */
157
+ function describeUnknownWrite(input) {
158
+ const method = (input.unknown.request.method ?? 'write').toUpperCase();
159
+ const reason = input.unknown.outcome.reason;
160
+ const said = input.serverMessage ? ` It said: ${input.serverMessage}` : '';
161
+ let head;
162
+ if (reason === 'after_write') {
163
+ head = `The server reports that this ${method} request failed after its change was made.`;
164
+ }
165
+ else if (input.unknown.transport) {
166
+ head = `This ${method} request to ${input.baseURL} got no answer.`;
167
+ }
168
+ else {
169
+ head = `${input.baseURL} answered HTTP ${input.status} to this ${method} request.`;
170
+ }
171
+ // A gateway that gave up waiting (504) or a server that timed out reading (408) says nothing about the work: it may still be going.
172
+ const stillRunning = input.status === 504 || input.status === 408 ? ' It may still be running.' : '';
173
+ return (`${head}${input.unknown.transport ? '' : said} It may have been applied before the failure, so its outcome is unknown.${stillRunning} ` +
174
+ 'Check the current state of what it changes before trying again: sending it again without checking can apply it twice.' +
175
+ (input.requestId ? ` Request id ${input.requestId} — quote it when reporting this.` : ''));
176
+ }