@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
package/README.md
CHANGED
|
@@ -900,6 +900,19 @@ When stdin is not a TTY (piped input, CI), the command refuses to prompt and
|
|
|
900
900
|
exits with code 7 unless `--yes` is passed. This prevents hangs in
|
|
901
901
|
non-interactive environments.
|
|
902
902
|
|
|
903
|
+
### `sky spaces deletion cancel <id>`
|
|
904
|
+
|
|
905
|
+
Cancel a Space deletion that is waiting to finish, so the Space is kept. Needs
|
|
906
|
+
delete access, does not prompt (it is the direction that preserves data), and
|
|
907
|
+
exits 0 with "No deletion is pending" when there is nothing to cancel. Only a
|
|
908
|
+
signed-in person can run it: an access token (`SKRR_TOKEN`) is refused with
|
|
909
|
+
`PAT_ROUTE_NOT_ALLOWED`, so automation cannot undo a deletion a person ordered.
|
|
910
|
+
|
|
911
|
+
```bash
|
|
912
|
+
sky spaces deletion cancel <space-id>
|
|
913
|
+
sky spaces deletion cancel <space-id> --json
|
|
914
|
+
```
|
|
915
|
+
|
|
903
916
|
### `sky spaces archive <id>` / `sky spaces unarchive <id>`
|
|
904
917
|
|
|
905
918
|
Reversible alternative to `spaces delete`. Archives the space (setting
|
package/dist/base-command.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { type CliConfig } from './lib/config';
|
|
|
9
9
|
import { type AuthResolutionDiagnostic } from './lib/auth-diagnostics';
|
|
10
10
|
import { type CompletionCacheScope } from './lib/completion-index';
|
|
11
11
|
import { type OutboxMethod } from './lib/outbox';
|
|
12
|
+
import { type FailedRequest } from './lib/write-outcome';
|
|
12
13
|
import { type CredentialProvenance, type ResolvedCredential } from './lib/credential-resolver';
|
|
13
14
|
import { type BrokerRefusalDescription } from './lib/daemonBrokerRefusal';
|
|
14
15
|
import { type TaskResourceReferenceCache } from './lib/task-resource-references';
|
|
@@ -35,7 +36,19 @@ export declare abstract class BaseCommand extends Command {
|
|
|
35
36
|
* acquiring unrelated account authority. Human invocations are unaffected.
|
|
36
37
|
*/
|
|
37
38
|
static autonomousCredentialPolicy: 'delegated' | 'bound-session';
|
|
39
|
+
/**
|
|
40
|
+
* What a managed command may do when the daemon cannot mint the delegated credential it asked for.
|
|
41
|
+
* `none` fails, as always. `bound-session-when-daemon-brokered` keeps the bound session credential
|
|
42
|
+
* only when the daemon has flagged this session for its own message broker
|
|
43
|
+
* (OVERSKY_OFFLINE_MESSAGE_SUBMIT_VIA_DAEMON=1): that route is WAL-first and needs no cloud
|
|
44
|
+
* credential, so a machine that is cut off from the server can still hand the message to the daemon
|
|
45
|
+
* (OSK-23049). It never widens authority: the session credential is what the command was given.
|
|
46
|
+
*/
|
|
47
|
+
static autonomousCredentialFallback: 'none' | 'bound-session-when-daemon-brokered';
|
|
38
48
|
static sessionReadPolicy?: 'memory-history-v1';
|
|
49
|
+
/** Report a refused delegated credential and exit; `failWithCliError` throws. */
|
|
50
|
+
private failDelegatedCredentialUnavailable;
|
|
51
|
+
private mayKeepBoundSessionCredential;
|
|
39
52
|
/** Add the owning agent's web detail link without overwriting resource URLs. */
|
|
40
53
|
protected withAgentContext<T>(agentId: string, value: T): T & {
|
|
41
54
|
agentUrl: string | null;
|
|
@@ -668,7 +681,7 @@ export declare function isTypedServerRefusal(body: Record<string, unknown> | nul
|
|
|
668
681
|
* stays in the outage branch: it says nothing a reader could act on.
|
|
669
682
|
*/
|
|
670
683
|
export declare function isApplicationCodedUnavailable(status: number | undefined, body: Record<string, unknown> | null): boolean;
|
|
671
|
-
export declare function isRetryableFailure(status: number | undefined, body: Record<string, unknown> | null): boolean;
|
|
684
|
+
export declare function isRetryableFailure(status: number | undefined, body: Record<string, unknown> | null, request?: FailedRequest): boolean;
|
|
672
685
|
/**
|
|
673
686
|
* The human text of an API error body (OSK-16986). The server's error envelope guarantees
|
|
674
687
|
* `message`; the legacy `error` string and the nested `{ error: { message } }` (`/v1`) are read
|
package/dist/base-command.js
CHANGED
|
@@ -62,6 +62,7 @@ const workspace_header_1 = require("./lib/workspace-header");
|
|
|
62
62
|
const cli_id_1 = require("./lib/cli-id");
|
|
63
63
|
const keychain_2 = require("./lib/keychain");
|
|
64
64
|
const outbox_1 = require("./lib/outbox");
|
|
65
|
+
const write_outcome_1 = require("./lib/write-outcome");
|
|
65
66
|
const node_adapter_1 = require("./lib/node-adapter");
|
|
66
67
|
const memory_history_session_1 = require("./lib/memory-history-session");
|
|
67
68
|
const migrate_1 = require("./lib/migrate");
|
|
@@ -82,6 +83,10 @@ const task_resource_references_1 = require("./lib/task-resource-references");
|
|
|
82
83
|
const tasks_1 = require("./lib/tasks");
|
|
83
84
|
const RESOLVE_TASK_RESOURCE_REFERENCES_RE = /^[\da-f-]{36}$/i;
|
|
84
85
|
const RESOLVE_TASK_RESOURCE_REFERENCES_RE_2 = /^[\da-f]{24}$/i;
|
|
86
|
+
/** Control, combining and invisible characters, escaped in the unsaved-recovery text so it prints inertly. */
|
|
87
|
+
/* eslint-disable no-misleading-character-class -- the point of the pattern is to match combining and invisible characters */
|
|
88
|
+
const RECOVERY_INVISIBLE_CHARS = /[\u007f-\u009f\u00ad\u034f\u061c\u115f\u1160\u17b4\u17b5\u180b-\u180e\u200b-\u200f\u2028-\u202e\u2060-\u206f\u2800\u3164\ufe00-\ufe0f\ufeff\uffa0\ufff9-\ufffb\u{1d173}-\u{1d17a}\u{e0000}-\u{e03ff}]/gu;
|
|
89
|
+
/* eslint-enable no-misleading-character-class */
|
|
85
90
|
const HANDLE_API_ERROR_RE = /\s*Run `[^`]+` to sign in again\.$/;
|
|
86
91
|
const HAS_REMEDY_LINE_RE = /^\s*→/m;
|
|
87
92
|
const UNSUPPORTED_FLAG_REMEDY_FOR_MESSAGE_RE = /Nonexistent flag[s]?:?\s*(-{1,2}[\w-]+)/i;
|
|
@@ -152,7 +157,56 @@ class BaseCommand extends core_1.Command {
|
|
|
152
157
|
* acquiring unrelated account authority. Human invocations are unaffected.
|
|
153
158
|
*/
|
|
154
159
|
static autonomousCredentialPolicy = 'delegated';
|
|
160
|
+
/**
|
|
161
|
+
* What a managed command may do when the daemon cannot mint the delegated credential it asked for.
|
|
162
|
+
* `none` fails, as always. `bound-session-when-daemon-brokered` keeps the bound session credential
|
|
163
|
+
* only when the daemon has flagged this session for its own message broker
|
|
164
|
+
* (OVERSKY_OFFLINE_MESSAGE_SUBMIT_VIA_DAEMON=1): that route is WAL-first and needs no cloud
|
|
165
|
+
* credential, so a machine that is cut off from the server can still hand the message to the daemon
|
|
166
|
+
* (OSK-23049). It never widens authority: the session credential is what the command was given.
|
|
167
|
+
*/
|
|
168
|
+
static autonomousCredentialFallback = 'none';
|
|
155
169
|
static sessionReadPolicy;
|
|
170
|
+
/** Report a refused delegated credential and exit; `failWithCliError` throws. */
|
|
171
|
+
failDelegatedCredentialUnavailable(err) {
|
|
172
|
+
// OSK-15990 — a refusal only a new daemon sign-in repairs (e.g.
|
|
173
|
+
// DEVICE_PROOF_PIN_MISMATCH) is NOT retryable: exit 75 told every
|
|
174
|
+
// caller to loop on it. Say so, and say what to run.
|
|
175
|
+
// Matched by name, not instanceof: specs mock `./lib/delegated-cli`
|
|
176
|
+
// down to one or two functions, and a missing class would throw here.
|
|
177
|
+
if (err?.name === 'DelegatedCliUnavailableError') {
|
|
178
|
+
const e = err;
|
|
179
|
+
const remedy = e.remedy && !e.message.includes(e.remedy) ? ` Fix: ${e.remedy}` : '';
|
|
180
|
+
this.failWithCliError({
|
|
181
|
+
message: `Daemon delegated skrr credential is unavailable: ${e.message}${remedy}`,
|
|
182
|
+
code: 'DELEGATED_CLI_CREDENTIAL_UNAVAILABLE',
|
|
183
|
+
// 75 (EX_TEMPFAIL) only when waiting can help; 77 (EX_NOPERM) when
|
|
184
|
+
// the daemon must be signed in again first.
|
|
185
|
+
exit: e.retryable ? 75 : 77,
|
|
186
|
+
retryable: e.retryable,
|
|
187
|
+
details: {
|
|
188
|
+
...(e.upstreamStatus !== undefined ? { upstreamStatus: e.upstreamStatus } : {}),
|
|
189
|
+
...(e.upstreamCode ? { upstreamCode: e.upstreamCode } : {}),
|
|
190
|
+
...(e.upstreamReason ? { upstreamReason: e.upstreamReason } : {}),
|
|
191
|
+
...(e.retryAt ? { retryAt: e.retryAt } : {}),
|
|
192
|
+
...(e.remedy ? { remedy: e.remedy } : {}),
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
this.failWithCliError({
|
|
197
|
+
message: `Daemon delegated skrr credential is unavailable: ${err.message}`,
|
|
198
|
+
code: 'DELEGATED_CLI_CREDENTIAL_UNAVAILABLE',
|
|
199
|
+
exit: 75,
|
|
200
|
+
retryable: true,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
mayKeepBoundSessionCredential(err, haveBoundSessionCredential) {
|
|
204
|
+
return (haveBoundSessionCredential &&
|
|
205
|
+
this.constructor.autonomousCredentialFallback ===
|
|
206
|
+
'bound-session-when-daemon-brokered' &&
|
|
207
|
+
process.env.OVERSKY_OFFLINE_MESSAGE_SUBMIT_VIA_DAEMON === '1' &&
|
|
208
|
+
err?.name === 'DelegatedCliUnavailableError');
|
|
209
|
+
}
|
|
156
210
|
/** Add the owning agent's web detail link without overwriting resource URLs. */
|
|
157
211
|
withAgentContext(agentId, value) {
|
|
158
212
|
const agentUrl = (0, web_url_1.agentUrlFrom)(this.cliConfig.baseURL, { id: agentId });
|
|
@@ -392,51 +446,35 @@ class BaseCommand extends core_1.Command {
|
|
|
392
446
|
// time with the exit signal as its cause: two JSON documents on stdout and a message ending
|
|
393
447
|
// in `EEXIT: 75` (OSK-23475).
|
|
394
448
|
let delegatedCredential;
|
|
449
|
+
let keepBoundSession = false;
|
|
395
450
|
try {
|
|
396
451
|
delegatedCredential = await (0, delegated_cli_1.fetchDelegatedCliCredential)();
|
|
397
452
|
}
|
|
398
453
|
catch (err) {
|
|
399
|
-
// OSK-
|
|
400
|
-
//
|
|
401
|
-
//
|
|
402
|
-
//
|
|
403
|
-
//
|
|
404
|
-
if (err?.
|
|
405
|
-
|
|
406
|
-
|
|
454
|
+
// OSK-23049 — a session the daemon flagged for its own message broker does not need the cloud
|
|
455
|
+
// credential to hand a message over, so a refused mint keeps the bound session credential for a
|
|
456
|
+
// command that declared it. Everything else reports the refusal exactly as before.
|
|
457
|
+
// `resolveTrustedAutonomousCredential` answers an object with `token: null` when the session token is
|
|
458
|
+
// missing (so the command fails closed), which is truthy: ask for the token itself.
|
|
459
|
+
if (this.mayKeepBoundSessionCredential(err, Boolean(autonomousCredential?.token))) {
|
|
460
|
+
keepBoundSession = true;
|
|
461
|
+
}
|
|
462
|
+
else {
|
|
463
|
+
this.failDelegatedCredentialUnavailable(err);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
if (!keepBoundSession) {
|
|
467
|
+
if (!delegatedCredential) {
|
|
407
468
|
this.failWithCliError({
|
|
408
|
-
message:
|
|
469
|
+
message: 'Daemon delegated skrr credential is unavailable.',
|
|
409
470
|
code: 'DELEGATED_CLI_CREDENTIAL_UNAVAILABLE',
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
exit: e.retryable ? 75 : 77,
|
|
413
|
-
retryable: e.retryable,
|
|
414
|
-
details: {
|
|
415
|
-
...(e.upstreamStatus !== undefined ? { upstreamStatus: e.upstreamStatus } : {}),
|
|
416
|
-
...(e.upstreamCode ? { upstreamCode: e.upstreamCode } : {}),
|
|
417
|
-
...(e.upstreamReason ? { upstreamReason: e.upstreamReason } : {}),
|
|
418
|
-
...(e.retryAt ? { retryAt: e.retryAt } : {}),
|
|
419
|
-
...(e.remedy ? { remedy: e.remedy } : {}),
|
|
420
|
-
},
|
|
471
|
+
exit: 75,
|
|
472
|
+
retryable: true,
|
|
421
473
|
});
|
|
422
474
|
}
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
code: 'DELEGATED_CLI_CREDENTIAL_UNAVAILABLE',
|
|
426
|
-
exit: 75,
|
|
427
|
-
retryable: true,
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
if (!delegatedCredential) {
|
|
431
|
-
this.failWithCliError({
|
|
432
|
-
message: 'Daemon delegated skrr credential is unavailable.',
|
|
433
|
-
code: 'DELEGATED_CLI_CREDENTIAL_UNAVAILABLE',
|
|
434
|
-
exit: 75,
|
|
435
|
-
retryable: true,
|
|
436
|
-
});
|
|
475
|
+
autonomousCredential = delegatedCredential;
|
|
476
|
+
this.credentialProvenance = { kind: 'daemon-delegated' };
|
|
437
477
|
}
|
|
438
|
-
autonomousCredential = delegatedCredential;
|
|
439
|
-
this.credentialProvenance = { kind: 'daemon-delegated' };
|
|
440
478
|
}
|
|
441
479
|
if (autonomousCredential) {
|
|
442
480
|
// Parse for normal oclif flag validation, but intentionally ignore both
|
|
@@ -1561,6 +1599,13 @@ class BaseCommand extends core_1.Command {
|
|
|
1561
1599
|
this.lastRetryAfterMs = e.retryAfterMs;
|
|
1562
1600
|
const body = parseErrorBody(e.body);
|
|
1563
1601
|
const bodyCode = refusalCodeOf(body);
|
|
1602
|
+
// A write the server may have applied and no route receipt will recognise a repeat of (OSK-24076). Not for a server
|
|
1603
|
+
// that states its own verdict (`retryable`), a typed 5xx refusal, or a 502/503/504 it wrote with a code: those answer.
|
|
1604
|
+
const unknownWrite = typeof body?.retryable !== 'boolean' &&
|
|
1605
|
+
!isTypedServerRefusal(body) &&
|
|
1606
|
+
!isApplicationCodedUnavailable(e.status, body)
|
|
1607
|
+
? (0, write_outcome_1.unknownWriteOf)(e, body)
|
|
1608
|
+
: null;
|
|
1564
1609
|
// A body path the person never typed is read back as the flag that wrote it (OSK-15313).
|
|
1565
1610
|
// The server answers every error with `message` (OSK-16986); `errorBodyMessage` keeps the
|
|
1566
1611
|
// older `error` string and the nested `/v1` shape as fallbacks for a server without it.
|
|
@@ -1640,6 +1685,16 @@ class BaseCommand extends core_1.Command {
|
|
|
1640
1685
|
details: envelopeDetails(body),
|
|
1641
1686
|
});
|
|
1642
1687
|
}
|
|
1688
|
+
else if (bodyCode === 'DUTY_REFLECTION_APPROVAL_UNVERIFIED') {
|
|
1689
|
+
this.failWithCliError({
|
|
1690
|
+
message: say('Approving a Reflection recommendation is unavailable because its Duty source cannot be verified. You can still reject it.'),
|
|
1691
|
+
code: bodyCode,
|
|
1692
|
+
status: e.status,
|
|
1693
|
+
exit: 1,
|
|
1694
|
+
retryable: false,
|
|
1695
|
+
details: envelopeDetails(body),
|
|
1696
|
+
});
|
|
1697
|
+
}
|
|
1643
1698
|
else if (bodyCode === 'DUTY_REFLECTION_SOURCE_UNVERIFIED') {
|
|
1644
1699
|
this.failWithCliError({
|
|
1645
1700
|
message: say('Reflection history and decisions are unavailable because the original Duty source cannot be verified.'),
|
|
@@ -1781,6 +1836,44 @@ class BaseCommand extends core_1.Command {
|
|
|
1781
1836
|
details: envelopeDetails(body),
|
|
1782
1837
|
});
|
|
1783
1838
|
}
|
|
1839
|
+
else if (unknownWrite) {
|
|
1840
|
+
// The branch the write contract adds (OSK-24076): 408, 425, a 5xx, no answer, or a failure tagged `after_write`, for
|
|
1841
|
+
// a write on a route that keeps no receipt. It is neither "failed" nor "retry". A route that DOES keep a receipt,
|
|
1842
|
+
// and a request that never left, keep the branches below.
|
|
1843
|
+
// A gateway status may also mean the platform is down. That note is about the platform, not about this write, and
|
|
1844
|
+
// it was recorded for these statuses before; a dropped connection never was, since it can be this machine's own.
|
|
1845
|
+
// An edge 504 page is not proof of an outage either (OSK-8700), as before.
|
|
1846
|
+
const edgeTimeoutPage = e.status === 504 &&
|
|
1847
|
+
!body &&
|
|
1848
|
+
(0, edge_error_page_1.describeEdgeErrorPage)({ status: e.status, body: e.body, method: e.method }) !== null;
|
|
1849
|
+
if (typeof e.status === 'number' && (0, outbox_1.isOutageFailure)(e) && !edgeTimeoutPage) {
|
|
1850
|
+
this.noteControlPlaneOutage(e.status);
|
|
1851
|
+
}
|
|
1852
|
+
const requestId = stringProp(body, 'requestId') || e.requestId;
|
|
1853
|
+
const originalCode = bodyCode && /^[A-Za-z0-9._:-]{1,128}$/.test(bodyCode) ? bodyCode : undefined;
|
|
1854
|
+
this.failWithCliError({
|
|
1855
|
+
message: say((0, write_outcome_1.describeUnknownWrite)({
|
|
1856
|
+
baseURL: this.cliConfig.baseURL,
|
|
1857
|
+
unknown: unknownWrite,
|
|
1858
|
+
...(e.status ? { status: e.status } : {}),
|
|
1859
|
+
...(bodyMessage && !isRedactedServerMessage(bodyMessage)
|
|
1860
|
+
? { serverMessage: bodyMessage }
|
|
1861
|
+
: {}),
|
|
1862
|
+
...(requestId ? { requestId } : {}),
|
|
1863
|
+
})),
|
|
1864
|
+
code: write_outcome_1.WRITE_OUTCOME_UNKNOWN_CODE,
|
|
1865
|
+
...(e.status ? { status: e.status } : {}),
|
|
1866
|
+
exit: 5,
|
|
1867
|
+
retryable: false,
|
|
1868
|
+
details: {
|
|
1869
|
+
outcome: 'unknown',
|
|
1870
|
+
reason: unknownWrite.outcome.reason,
|
|
1871
|
+
method: (unknownWrite.request.method ?? '').toUpperCase(),
|
|
1872
|
+
...(originalCode ? { originalCode } : {}),
|
|
1873
|
+
},
|
|
1874
|
+
...(requestId ? { requestId } : {}),
|
|
1875
|
+
});
|
|
1876
|
+
}
|
|
1784
1877
|
else if (e.status === 401) {
|
|
1785
1878
|
// ADD-CLI6 — bare mode follows the `EX_TEMPFAIL` (75) convention
|
|
1786
1879
|
// for needs-reauth, matching the daemon's `bare-mode.ts:117`.
|
|
@@ -1968,7 +2061,7 @@ class BaseCommand extends core_1.Command {
|
|
|
1968
2061
|
code: bodyCode || `HTTP_${e.status}`,
|
|
1969
2062
|
status: e.status,
|
|
1970
2063
|
exit: 1,
|
|
1971
|
-
retryable: isRetryableFailure(e.status, body),
|
|
2064
|
+
retryable: isRetryableFailure(e.status, body, (0, write_outcome_1.requestOfError)(e)),
|
|
1972
2065
|
details: envelopeDetails(body),
|
|
1973
2066
|
requestId: stringProp(body, 'requestId') || e.requestId,
|
|
1974
2067
|
});
|
|
@@ -1990,17 +2083,24 @@ class BaseCommand extends core_1.Command {
|
|
|
1990
2083
|
// No incident is recorded: one route refusing in its own words is not
|
|
1991
2084
|
// evidence the control plane is failing. `isOutageFailure` is left
|
|
1992
2085
|
// alone because it also decides whether the outbox queues a write.
|
|
1993
|
-
const retryable = isRetryableFailure(e.status, body);
|
|
2086
|
+
const retryable = isRetryableFailure(e.status, body, (0, write_outcome_1.requestOfError)(e));
|
|
1994
2087
|
const authored = bodyMessage && !isRedactedServerMessage(bodyMessage) ? bodyMessage : '';
|
|
1995
2088
|
const requestId = stringProp(body, 'requestId') || e.requestId;
|
|
2089
|
+
let retryAdvice = 'Retrying the same request will not help until that condition changes.';
|
|
2090
|
+
if (retryable) {
|
|
2091
|
+
retryAdvice = 'Retrying may succeed once that condition clears.';
|
|
2092
|
+
}
|
|
2093
|
+
else if (writeWithoutReceipt(e, body)) {
|
|
2094
|
+
// `retryable` is false because a repeat could apply the write twice, not because it cannot succeed (OSK-24076).
|
|
2095
|
+
retryAdvice =
|
|
2096
|
+
'The response does not say whether the change was made: check the current state before trying again.';
|
|
2097
|
+
}
|
|
1996
2098
|
this.failWithCliError({
|
|
1997
2099
|
message: say(`${this.cliConfig.baseURL} refused this request (HTTP ${e.status}, ${bodyCode})` +
|
|
1998
2100
|
`${authored ? `: ${authored}` : '.'} ` +
|
|
1999
2101
|
'The API answered this itself, so the request did not time out at the gateway. ' +
|
|
2000
2102
|
(authored ? '' : 'It did not say why in this response. ') +
|
|
2001
|
-
|
|
2002
|
-
? 'Retrying may succeed once that condition clears.'
|
|
2003
|
-
: 'Retrying the same request will not help until that condition changes.') +
|
|
2103
|
+
retryAdvice +
|
|
2004
2104
|
(requestId && !authored
|
|
2005
2105
|
? ` Request id ${requestId} — quote it when reporting this.`
|
|
2006
2106
|
: '')),
|
|
@@ -2073,7 +2173,7 @@ class BaseCommand extends core_1.Command {
|
|
|
2073
2173
|
code: bodyCode || `HTTP_${e.status}`,
|
|
2074
2174
|
status: e.status,
|
|
2075
2175
|
exit: 1,
|
|
2076
|
-
retryable: isRetryableFailure(e.status, body),
|
|
2176
|
+
retryable: isRetryableFailure(e.status, body, (0, write_outcome_1.requestOfError)(e)),
|
|
2077
2177
|
details: envelopeDetails(body),
|
|
2078
2178
|
});
|
|
2079
2179
|
}
|
|
@@ -2083,7 +2183,7 @@ class BaseCommand extends core_1.Command {
|
|
|
2083
2183
|
code: bodyCode || e.code || (e.status ? `HTTP_${e.status}` : 'CLI_ERROR'),
|
|
2084
2184
|
status: e.status,
|
|
2085
2185
|
exit: 1,
|
|
2086
|
-
retryable: isRetryableFailure(e.status, body),
|
|
2186
|
+
retryable: isRetryableFailure(e.status, body, (0, write_outcome_1.requestOfError)(e)),
|
|
2087
2187
|
details: envelopeDetails(body),
|
|
2088
2188
|
});
|
|
2089
2189
|
}
|
|
@@ -2136,8 +2236,10 @@ class BaseCommand extends core_1.Command {
|
|
|
2136
2236
|
// read the WIDE predicate: a 401 here is precisely the case where an
|
|
2137
2237
|
// authored payload was being dropped, because `outbox` only ever queued on
|
|
2138
2238
|
// `status >= 500`.
|
|
2139
|
-
|
|
2140
|
-
|
|
2239
|
+
const request = { method: write.method, path: (0, write_outcome_1.requestPathOf)(write.url) };
|
|
2240
|
+
if (!(0, outbox_1.isRetryableWrite)(err, request)) {
|
|
2241
|
+
// The error names the request when the transport threw it. A caller's own error may not: say which write this was.
|
|
2242
|
+
this.handleApiError((0, write_outcome_1.stampRequest)(err, write.method, write.url));
|
|
2141
2243
|
}
|
|
2142
2244
|
const e = err;
|
|
2143
2245
|
// ...but the incident note stays on the NARROW one, so an expired token
|
|
@@ -2145,6 +2247,13 @@ class BaseCommand extends core_1.Command {
|
|
|
2145
2247
|
if ((0, outbox_1.isOutageFailure)(err))
|
|
2146
2248
|
this.noteControlPlaneOutage(e.status);
|
|
2147
2249
|
const workspaceId = process.env.OVERSKY_SESSION_WORKSPACE_ID?.trim() || process.env.OVERSKY_WORKSPACE_ID?.trim();
|
|
2250
|
+
// OSK-23807 — record where and as whom this write was authored (no secret),
|
|
2251
|
+
// so `outbox retry` can refuse to send it anywhere else.
|
|
2252
|
+
const binding = (0, outbox_1.outboxBindingFor)({
|
|
2253
|
+
baseURL: this.cliConfig?.baseURL,
|
|
2254
|
+
token: this.resolvedCredential?.token,
|
|
2255
|
+
profile: (0, keychain_2.getActiveProfile)(),
|
|
2256
|
+
});
|
|
2148
2257
|
let queuedId;
|
|
2149
2258
|
try {
|
|
2150
2259
|
const entry = (0, outbox_1.enqueueWrite)({
|
|
@@ -2155,6 +2264,7 @@ class BaseCommand extends core_1.Command {
|
|
|
2155
2264
|
url: write.url,
|
|
2156
2265
|
body: write.body,
|
|
2157
2266
|
...(workspaceId ? { workspaceId } : {}),
|
|
2267
|
+
...(binding ?? {}),
|
|
2158
2268
|
reason: {
|
|
2159
2269
|
...(e.status !== undefined ? { status: e.status } : {}),
|
|
2160
2270
|
...(e.code ? { code: e.code } : {}),
|
|
@@ -2175,18 +2285,23 @@ class BaseCommand extends core_1.Command {
|
|
|
2175
2285
|
if (!url.username && !url.password && !url.search && !url.hash)
|
|
2176
2286
|
server = url.toString();
|
|
2177
2287
|
}
|
|
2178
|
-
catch {
|
|
2288
|
+
catch {
|
|
2289
|
+
/* A malformed server is not a reliable recovery target. */
|
|
2290
|
+
}
|
|
2179
2291
|
const recovery = {
|
|
2180
2292
|
configuredServer: server,
|
|
2181
2293
|
currentWorkspaceId: (0, workspace_header_1.withWorkspaceHeader)({})['X-Workspace-Id'] ?? null,
|
|
2182
|
-
actualTarget: 'unknown',
|
|
2183
|
-
|
|
2294
|
+
actualTarget: 'unknown',
|
|
2295
|
+
actor: 'unverified',
|
|
2296
|
+
command: write.command,
|
|
2297
|
+
method: write.method,
|
|
2184
2298
|
path: write.url.startsWith('/') && !write.url.startsWith('//') && !/[?#]/.test(write.url)
|
|
2185
|
-
? write.url
|
|
2186
|
-
|
|
2299
|
+
? write.url
|
|
2300
|
+
: null,
|
|
2301
|
+
idempotencyKey: write.idempotencyKey,
|
|
2302
|
+
body: write.body,
|
|
2187
2303
|
};
|
|
2188
|
-
const recoveryText = (JSON.stringify(recovery, null, 2) ?? 'null')
|
|
2189
|
-
.replace(/[\u007f-\u009f\u00ad\u034f\u061c\u115f\u1160\u17b4\u17b5\u180b-\u180e\u200b-\u200f\u2028-\u202e\u2060-\u206f\u2800\u3164\ufe00-\ufe0f\ufeff\uffa0\ufff9-\ufffb\u{1d173}-\u{1d17a}\u{e0000}-\u{e03ff}]/gu, (char) => {
|
|
2304
|
+
const recoveryText = (JSON.stringify(recovery, null, 2) ?? 'null').replace(RECOVERY_INVISIBLE_CHARS, (char) => {
|
|
2190
2305
|
const code = char.codePointAt(0) ?? 0;
|
|
2191
2306
|
if (code <= 0xffff)
|
|
2192
2307
|
return `\\u${code.toString(16).padStart(4, '0')}`;
|
|
@@ -2200,13 +2315,15 @@ class BaseCommand extends core_1.Command {
|
|
|
2200
2315
|
await (0, drain_stdio_1.drainStdio)();
|
|
2201
2316
|
}
|
|
2202
2317
|
this.failWithCliError({
|
|
2203
|
-
message: (full
|
|
2204
|
-
`The local outbox
|
|
2318
|
+
message: (full
|
|
2319
|
+
? `The local outbox is full; this write was not saved in the queue. `
|
|
2320
|
+
: `The local outbox could not confirm that this write was saved. `) +
|
|
2205
2321
|
`The server may already have applied it. Reconcile the original request before trying again. ` +
|
|
2206
2322
|
`The actual target and actor are not verified. ` +
|
|
2207
2323
|
`Inspect existing entries with \`${this.config.bin} outbox list\`. ` +
|
|
2208
|
-
(this.wantsJsonOutput()
|
|
2209
|
-
'Keep the unsaved recovery details
|
|
2324
|
+
(this.wantsJsonOutput()
|
|
2325
|
+
? 'Keep the unsaved recovery details in this response; they may contain private data.'
|
|
2326
|
+
: 'Keep the unsaved recovery details printed above.'),
|
|
2210
2327
|
code: full ? 'OUTBOX_FULL' : 'OUTBOX_UNAVAILABLE',
|
|
2211
2328
|
status: e.status,
|
|
2212
2329
|
exit: 5,
|
|
@@ -2237,7 +2354,8 @@ class BaseCommand extends core_1.Command {
|
|
|
2237
2354
|
// OSK-12474 — the daemon was asked for a hand-off and refused; say why.
|
|
2238
2355
|
(brokerRefusal ? ` ${brokerRefusal.headline}` : '');
|
|
2239
2356
|
this.failWithCliError({
|
|
2240
|
-
message: `Authentication failed${statusSuffix}. ${why}
|
|
2357
|
+
message: `Authentication failed${statusSuffix}. ${why} Sign in again with \`${this.config.bin} login\`. ` +
|
|
2358
|
+
`Your ${write.summary} was saved locally as ${queuedId}; ` +
|
|
2241
2359
|
`the original outcome and context need reconciliation. Automatic replay is paused. Inspect \`${this.config.bin} outbox list --json\` before taking further action.`,
|
|
2242
2360
|
code: refusal?.code || 'AUTHENTICATION_FAILED',
|
|
2243
2361
|
status: e.status,
|
|
@@ -2906,15 +3024,29 @@ const REDACTED_SERVER_MESSAGE = 'An unexpected error occurred.';
|
|
|
2906
3024
|
function isRedactedServerMessage(message) {
|
|
2907
3025
|
return message.trim() === REDACTED_SERVER_MESSAGE;
|
|
2908
3026
|
}
|
|
2909
|
-
function isRetryableFailure(status, body) {
|
|
3027
|
+
function isRetryableFailure(status, body, request) {
|
|
2910
3028
|
const declared = body?.retryable;
|
|
2911
3029
|
if (typeof declared === 'boolean')
|
|
2912
3030
|
return declared;
|
|
2913
3031
|
const code = refusalCodeOf(body);
|
|
2914
3032
|
if (code && TERMINAL_ERROR_CODES.has(code))
|
|
2915
3033
|
return false;
|
|
3034
|
+
// A WRITE that timed out or failed on the server is retried automatically only if the route keeps a receipt for its key
|
|
3035
|
+
// (OSK-24076). Naming the request is what makes it a write; a caller that does not name it is asking about a read, or
|
|
3036
|
+
// about a status alone, and gets the answer the status gives.
|
|
3037
|
+
if ((0, write_outcome_1.isKnownWrite)(request) && (0, write_outcome_1.isAmbiguousStatus)(status)) {
|
|
3038
|
+
return (0, write_outcome_1.classifyRequestOutcome)({ request, status, body }).retryable;
|
|
3039
|
+
}
|
|
2916
3040
|
return status === 408 || status === 425 || status === 429 || !!(status && status >= 500);
|
|
2917
3041
|
}
|
|
3042
|
+
/**
|
|
3043
|
+
* A write on a route that keeps no replay receipt, whose failure the server did not give a verdict on. Its `retryable` is
|
|
3044
|
+
* false because a repeat could apply it twice (OSK-24076), not because retrying cannot succeed, and the words say which.
|
|
3045
|
+
*/
|
|
3046
|
+
function writeWithoutReceipt(err, body) {
|
|
3047
|
+
const request = (0, write_outcome_1.requestOfError)(err);
|
|
3048
|
+
return (typeof body?.retryable !== 'boolean' && (0, write_outcome_1.isKnownWrite)(request) && !(0, write_outcome_1.requestHasReceipt)(request));
|
|
3049
|
+
}
|
|
2918
3050
|
/** True when a message already carries this CLI's `→` remedy line. */
|
|
2919
3051
|
function hasRemedyLine(message) {
|
|
2920
3052
|
return HAS_REMEDY_LINE_RE.test(message);
|
|
@@ -75,6 +75,7 @@ export type CanonicalIntentEnvelope = {
|
|
|
75
75
|
* a compromised producer cannot elevate itself into a session principal.
|
|
76
76
|
*/
|
|
77
77
|
export default class AgentMessageSend extends BaseCommand {
|
|
78
|
+
static autonomousCredentialFallback: "bound-session-when-daemon-brokered";
|
|
78
79
|
private attemptedMessageKey?;
|
|
79
80
|
private partialSequence?;
|
|
80
81
|
protected failWithCliError(input: {
|
|
@@ -80,6 +80,9 @@ const PROTOCOL_VERSION = 1;
|
|
|
80
80
|
* a compromised producer cannot elevate itself into a session principal.
|
|
81
81
|
*/
|
|
82
82
|
class AgentMessageSend extends base_command_1.BaseCommand {
|
|
83
|
+
// OSK-23049: inside a daemon-flagged autonomous session the message goes to the daemon's own WAL-first broker,
|
|
84
|
+
// so a machine cut off from the server must not fail before it gets there on a refused credential mint.
|
|
85
|
+
static autonomousCredentialFallback = 'bound-session-when-daemon-brokered';
|
|
83
86
|
attemptedMessageKey;
|
|
84
87
|
partialSequence;
|
|
85
88
|
failWithCliError(input) {
|
|
@@ -30,7 +30,7 @@ class AgentsMiniComputerAppSet extends miniComputerCommand_1.MiniComputerCommand
|
|
|
30
30
|
exactlyOne: ['config', 'file'],
|
|
31
31
|
}),
|
|
32
32
|
'expected-rev': core_1.Flags.integer({
|
|
33
|
-
description: 'Only write if the app is at this revision (0:
|
|
33
|
+
description: 'Only write if the app is at this revision (0: nothing is stored now, which does not show whether it was configured before an older reset)',
|
|
34
34
|
min: 0,
|
|
35
35
|
}),
|
|
36
36
|
};
|
|
@@ -42,7 +42,13 @@ class AgentsMiniComputerShow extends miniComputerCommand_1.MiniComputerCommand {
|
|
|
42
42
|
if (flags.json) {
|
|
43
43
|
const read = (0, data_provider_1.parseMiniComputerLayoutRead)(layout);
|
|
44
44
|
const layoutSummary = read ? (0, data_provider_1.describeMiniComputerLayout)(read.layout) : null;
|
|
45
|
-
this.log(this.agentJson(args.agentId, {
|
|
45
|
+
this.log(this.agentJson(args.agentId, {
|
|
46
|
+
apps: apps.apps, layout, layoutSummary,
|
|
47
|
+
...(read && read.proposals.length > 0 ? {
|
|
48
|
+
review: { surface: 'agent_mini_computer_home', interactiveSessionRequired: true,
|
|
49
|
+
actions: ['apply', 'dismiss'], instructions: miniComputer_1.MINI_COMPUTER_REVIEW_GUIDANCE },
|
|
50
|
+
} : {}),
|
|
51
|
+
}));
|
|
46
52
|
return;
|
|
47
53
|
}
|
|
48
54
|
if (apps.apps.length === 0)
|
|
@@ -56,7 +56,7 @@ class AgentsMiniComputerTasksView extends miniComputerCommand_1.MiniComputerComm
|
|
|
56
56
|
after: core_1.Flags.string({ description: 'Window start, yyyy-mm-dd, inclusive' }),
|
|
57
57
|
before: core_1.Flags.string({ description: 'Window end, yyyy-mm-dd, inclusive' }),
|
|
58
58
|
'expected-rev': core_1.Flags.integer({
|
|
59
|
-
description: 'Only write or reset if Tasks is at this revision (0:
|
|
59
|
+
description: 'Only write or reset if Tasks is at this revision (0: nothing is stored now, which does not show whether it was configured before an older reset)',
|
|
60
60
|
min: 0,
|
|
61
61
|
}),
|
|
62
62
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command';
|
|
2
|
+
export default class AgentSupervision extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static args: {
|
|
5
|
+
id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
6
|
+
action: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static examples: string[];
|
|
9
|
+
static flags: {
|
|
10
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
watch: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
cursor: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
'request-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
revision: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
mode: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
'plan-revision': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
'source-revision': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
root: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
at: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
+
condition: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
+
reason: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
|
+
'recheck-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
|
+
};
|
|
24
|
+
run(): Promise<void>;
|
|
25
|
+
}
|