@skrr-ai/cli 0.1.161 → 0.1.163
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base-command.d.ts +5 -2
- package/dist/base-command.js +96 -39
- package/dist/commands/activity/list.d.ts +7 -0
- package/dist/commands/activity/list.js +17 -0
- package/dist/commands/activity/scan-older.d.ts +2 -2
- package/dist/commands/activity/scan-older.js +6 -5
- package/dist/commands/activity/show.d.ts +0 -2
- package/dist/commands/activity/show.js +21 -42
- package/dist/commands/agents/always-on/release-run.d.ts +3 -3
- package/dist/commands/agents/always-on/release-run.js +5 -6
- package/dist/commands/agents/mini-computer/app/reset.d.ts +1 -0
- package/dist/commands/agents/mini-computer/app/reset.js +5 -2
- package/dist/commands/agents/mini-computer/app/set.js +1 -1
- package/dist/commands/agents/mini-computer/show.js +4 -2
- package/dist/commands/agents/mini-computer/tasks-view.js +2 -2
- package/dist/commands/agents/triggers/replay.js +1 -1
- package/dist/commands/agents/triggers/runs.d.ts +2 -3
- package/dist/commands/agents/triggers/runs.js +4 -5
- package/dist/commands/apps/auto-apply.js +31 -10
- package/dist/commands/apps/check.js +8 -0
- package/dist/commands/apps/data/batch.js +16 -5
- package/dist/commands/apps/data/collections.js +1 -1
- package/dist/commands/apps/data/delete.js +12 -4
- package/dist/commands/apps/data/patch.js +11 -4
- package/dist/commands/apps/data/put.js +13 -6
- package/dist/commands/apps/data/query.js +3 -3
- package/dist/commands/apps/install.js +24 -7
- package/dist/commands/apps/installations/events.d.ts +1 -0
- package/dist/commands/apps/installations/events.js +63 -10
- package/dist/commands/apps/installations/show.js +26 -5
- package/dist/commands/apps/installations/snapshot.js +1 -1
- package/dist/commands/apps/installations/versions.js +25 -9
- package/dist/commands/apps/logs.js +4 -1
- package/dist/commands/apps/push.js +10 -2
- package/dist/commands/apps/reconsent.js +7 -1
- package/dist/commands/apps/rollback.js +2 -2
- package/dist/commands/apps/settings/set.js +81 -4
- package/dist/commands/apps/settings/show.js +38 -7
- package/dist/commands/balance/usage/breakdown.d.ts +1 -1
- package/dist/commands/balance/usage/breakdown.js +4 -4
- package/dist/commands/balance/usage/events.d.ts +1 -1
- package/dist/commands/balance/usage/events.js +4 -4
- package/dist/commands/duties/status.js +20 -15
- package/dist/commands/goals/create.js +18 -1
- package/dist/commands/outbox/drop.js +21 -15
- package/dist/commands/outbox/list.d.ts +2 -1
- package/dist/commands/outbox/list.js +20 -11
- package/dist/commands/outbox/retry.d.ts +8 -11
- package/dist/commands/outbox/retry.js +135 -92
- package/dist/commands/spaces/create.js +1 -1
- package/dist/commands/tasks/comments/add.js +1 -1
- package/dist/commands/triggers/audit.js +3 -5
- package/dist/commands/triggers/fire-detail.js +7 -1
- package/dist/commands/triggers/preflight.js +15 -10
- package/dist/commands/triggers/replay.js +1 -1
- package/dist/commands/triggers/runs.d.ts +2 -4
- package/dist/commands/triggers/runs.js +3 -5
- package/dist/generated/agent-guides.json +19 -19
- package/dist/lib/agent-activity.d.ts +21 -1
- package/dist/lib/agent-activity.js +98 -29
- package/dist/lib/api-fetch.d.ts +2 -0
- package/dist/lib/api-fetch.js +5 -5
- package/dist/lib/appData.d.ts +43 -5
- package/dist/lib/appData.js +117 -25
- package/dist/lib/appInstallations.d.ts +5 -5
- package/dist/lib/appInstallations.js +211 -74
- package/dist/lib/appSettings.d.ts +2 -0
- package/dist/lib/appSettings.js +36 -3
- package/dist/lib/apps-command.d.ts +9 -0
- package/dist/lib/apps-command.js +191 -7
- package/dist/lib/appsCheck.js +29 -3
- package/dist/lib/appsFs.d.ts +1 -1
- package/dist/lib/balance.d.ts +5 -5
- package/dist/lib/balance.js +4 -4
- package/dist/lib/dedicated-power.js +4 -3
- package/dist/lib/json-output.d.ts +4 -0
- package/dist/lib/json-output.js +38 -0
- package/dist/lib/miniComputer.js +9 -2
- package/dist/lib/node-adapter.js +35 -2
- package/dist/lib/outbox.d.ts +20 -5
- package/dist/lib/outbox.js +233 -76
- package/dist/lib/rate-limit-retry.d.ts +3 -2
- package/dist/lib/rate-limit-retry.js +3 -2
- package/dist/lib/roles.d.ts +1 -1
- package/dist/lib/triggers.d.ts +3 -0
- package/dist/lib/triggers.js +10 -0
- package/dist/lib/widgetStaticScan.d.ts +3 -1
- package/dist/lib/widgetStaticScan.js +182 -47
- package/dist/node_modules/@skrr-ai/data-provider/index.js +10442 -9507
- package/oclif.manifest.json +138 -45
- package/package.json +4 -3
|
@@ -6,7 +6,7 @@ import { type OutboxEntry } from '../../lib/outbox';
|
|
|
6
6
|
* sign-in — and a list that described every entry as "the API was unavailable"
|
|
7
7
|
* sent a signed-out reader to wait for an outage that was not happening.
|
|
8
8
|
*/
|
|
9
|
-
export declare function queuedBecause(entry: Pick<OutboxEntry, 'reason'>): {
|
|
9
|
+
export declare function queuedBecause(entry: Pick<OutboxEntry, 'reason' | 'replay'>): {
|
|
10
10
|
label: string;
|
|
11
11
|
kind: 'auth' | 'throttled' | 'unavailable' | 'other';
|
|
12
12
|
};
|
|
@@ -14,6 +14,7 @@ export declare function outboxListSnapshot(profile?: string): {
|
|
|
14
14
|
queued: OutboxEntry[];
|
|
15
15
|
incident: import("../../lib/outbox").IncidentState | null;
|
|
16
16
|
incidentActive: boolean;
|
|
17
|
+
originalContext: "unverified" | "not_applicable";
|
|
17
18
|
};
|
|
18
19
|
/**
|
|
19
20
|
* `skrr outbox list` — what is queued, and why.
|
|
@@ -15,6 +15,10 @@ const outbox_1 = require("../../lib/outbox");
|
|
|
15
15
|
* sent a signed-out reader to wait for an outage that was not happening.
|
|
16
16
|
*/
|
|
17
17
|
function queuedBecause(entry) {
|
|
18
|
+
if (entry.replay?.state === 'sending')
|
|
19
|
+
return { label: 'outcome unknown', kind: 'other' };
|
|
20
|
+
if (entry.replay?.state === 'result_recorded')
|
|
21
|
+
return { label: 'result recorded', kind: 'other' };
|
|
18
22
|
const status = entry.reason?.status;
|
|
19
23
|
if (status === 401)
|
|
20
24
|
return { label: 'sign-in refused (401)', kind: 'auth' };
|
|
@@ -32,6 +36,7 @@ function outboxListSnapshot(profile) {
|
|
|
32
36
|
queued,
|
|
33
37
|
incident,
|
|
34
38
|
incidentActive: Boolean(incident && (0, outbox_1.isIncidentActive)(profile)),
|
|
39
|
+
originalContext: queued.length > 0 ? 'unverified' : 'not_applicable',
|
|
35
40
|
};
|
|
36
41
|
}
|
|
37
42
|
/**
|
|
@@ -54,13 +59,13 @@ class OutboxList extends base_command_1.BaseCommand {
|
|
|
54
59
|
async run() {
|
|
55
60
|
const { flags } = await this.parse(OutboxList);
|
|
56
61
|
const profile = (0, keychain_1.getActiveProfile)();
|
|
57
|
-
const { queued: entries, incident, incidentActive } = outboxListSnapshot(profile);
|
|
62
|
+
const { queued: entries, incident, incidentActive, originalContext } = outboxListSnapshot(profile);
|
|
58
63
|
if (flags.json) {
|
|
59
|
-
this.printJsonResult((0, list_output_1.listResult)({ queued: entries, incident, incidentActive }, 'queued'));
|
|
64
|
+
this.printJsonResult((0, list_output_1.listResult)({ queued: entries, incident, incidentActive, originalContext }, 'queued'));
|
|
60
65
|
return;
|
|
61
66
|
}
|
|
62
67
|
if (incident && incidentActive) {
|
|
63
|
-
this.log(`
|
|
68
|
+
this.log(`Local incident observation: configured server ${incident.baseURL}; failure recorded at ${incident.lastOutageAt}` +
|
|
64
69
|
`${incident.status ? ` (HTTP ${incident.status})` : ''}, ` +
|
|
65
70
|
`${incident.consecutive} consecutive failure(s).`);
|
|
66
71
|
this.log('');
|
|
@@ -68,15 +73,17 @@ class OutboxList extends base_command_1.BaseCommand {
|
|
|
68
73
|
else if (incident && entries.some((e) => queuedBecause(e).kind === 'unavailable')) {
|
|
69
74
|
// A past incident is context only for entries an outage put here. Beside
|
|
70
75
|
// a queue of sign-in refusals it reads as the explanation, and is not.
|
|
71
|
-
this.log(`Last
|
|
76
|
+
this.log(`Last local incident observation: configured server ${incident.baseURL}; failure recorded at ${incident.lastOutageAt}` +
|
|
72
77
|
`${incident.status ? ` (HTTP ${incident.status})` : ''}. ` +
|
|
73
78
|
'No current outage is confirmed.');
|
|
74
79
|
this.log('');
|
|
75
80
|
}
|
|
76
81
|
if (entries.length === 0) {
|
|
77
|
-
this.log('Nothing
|
|
82
|
+
this.log('Nothing is currently queued.');
|
|
78
83
|
return;
|
|
79
84
|
}
|
|
85
|
+
this.log('These records do not prove their original server, account, and workspace. Automatic replay is paused; inspect the JSON and reconcile the original result and target before taking further action.');
|
|
86
|
+
this.log('');
|
|
80
87
|
(0, format_1.renderTable)(entries.map((e) => ({
|
|
81
88
|
id: e.id,
|
|
82
89
|
queued: e.queuedAt,
|
|
@@ -94,21 +101,23 @@ class OutboxList extends base_command_1.BaseCommand {
|
|
|
94
101
|
{ key: 'why', header: 'WHY', maxWidth: 24 },
|
|
95
102
|
{ key: 'attempts', header: 'TRIES' },
|
|
96
103
|
], (line) => this.log(line));
|
|
104
|
+
if (entries.some((e) => e.replay)) {
|
|
105
|
+
this.log('');
|
|
106
|
+
this.log('Started entries are not replayed again. Inspect their original target and result before deciding how to handle them.');
|
|
107
|
+
}
|
|
97
108
|
const exhausted = entries.filter((e) => e.attempts >= outbox_1.MAX_REPLAY_ATTEMPTS);
|
|
98
109
|
if (exhausted.length > 0) {
|
|
99
110
|
this.log('');
|
|
100
|
-
this.log(`${exhausted.length} entry(ies) hit the ${outbox_1.MAX_REPLAY_ATTEMPTS}-attempt cap
|
|
101
|
-
'
|
|
111
|
+
this.log(`${exhausted.length} entry(ies) hit the ${outbox_1.MAX_REPLAY_ATTEMPTS}-attempt cap. ` +
|
|
112
|
+
'Automatic replay is paused; inspect their records and reconcile the original results.');
|
|
102
113
|
}
|
|
103
114
|
const authQueued = entries.filter((e) => queuedBecause(e).kind === 'auth').length;
|
|
104
115
|
if (authQueued > 0) {
|
|
105
116
|
this.log('');
|
|
106
|
-
this.log(`${authQueued} entry(ies) were queued
|
|
107
|
-
`it was down. Sign in with \`${this.config.bin} login\` first; a replay before that is ` +
|
|
108
|
-
'refused the same way.');
|
|
117
|
+
this.log(`${authQueued} entry(ies) were queued after a sign-in refusal. Signing in now does not prove which account originally made the request.`);
|
|
109
118
|
}
|
|
110
119
|
this.log('');
|
|
111
|
-
this.log(`
|
|
120
|
+
this.log(`Inspect: ${this.config.bin} outbox list --json`);
|
|
112
121
|
this.log(`Discard: ${this.config.bin} outbox drop <id>`);
|
|
113
122
|
}
|
|
114
123
|
}
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import { BaseCommand } from '../../base-command';
|
|
2
2
|
/**
|
|
3
|
-
* `skrr outbox retry` —
|
|
3
|
+
* `skrr outbox retry` — inspect queued writes for safe replay.
|
|
4
|
+
* Existing records lack verified original context, so replay is paused.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* second one. That property is what makes an automatic-looking retry acceptable
|
|
9
|
-
* at all — without it this command would be a duplicate-content generator.
|
|
6
|
+
* A queued request can already have reached the server. Its key prevents a
|
|
7
|
+
* duplicate only when that endpoint actually enforces durable idempotency;
|
|
8
|
+
* the client cannot infer that guarantee from a key alone.
|
|
10
9
|
*
|
|
11
10
|
* Outcomes are kept distinct on purpose:
|
|
12
|
-
* - sent —
|
|
13
|
-
* - refused —
|
|
14
|
-
*
|
|
15
|
-
* not lost silently.
|
|
16
|
-
* - deferred — still an outage. The entry stays, its attempt count rises.
|
|
11
|
+
* - sent — a recognizable result was recorded; the local entry is kept.
|
|
12
|
+
* - refused — retained in the output shape for older consumers.
|
|
13
|
+
* - deferred — no confirmed success. The entry stays for reconciliation.
|
|
17
14
|
*/
|
|
18
15
|
export default class OutboxRetry extends BaseCommand {
|
|
19
16
|
static description: string;
|
|
@@ -5,24 +5,36 @@ const base_command_1 = require("../../base-command");
|
|
|
5
5
|
const api_fetch_1 = require("../../lib/api-fetch");
|
|
6
6
|
const keychain_1 = require("../../lib/keychain");
|
|
7
7
|
const outbox_1 = require("../../lib/outbox");
|
|
8
|
+
/** Only the two supported queued commands have a success shape we can read. */
|
|
9
|
+
function replayResultId(entry, value) {
|
|
10
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
11
|
+
return null;
|
|
12
|
+
const result = value;
|
|
13
|
+
if (result.ok === false)
|
|
14
|
+
return null;
|
|
15
|
+
const id = result.id ?? result._id;
|
|
16
|
+
if (typeof id !== 'string' || !id.trim())
|
|
17
|
+
return null;
|
|
18
|
+
const supported = entry.method === 'post' &&
|
|
19
|
+
((entry.command === 'spaces create' && entry.url === '/api/spaces') ||
|
|
20
|
+
(entry.command === 'tasks comments add' && /^\/api\/tasks\/[^/]+\/comments$/.test(entry.url)));
|
|
21
|
+
return supported ? id : null;
|
|
22
|
+
}
|
|
8
23
|
/**
|
|
9
|
-
* `skrr outbox retry` —
|
|
24
|
+
* `skrr outbox retry` — inspect queued writes for safe replay.
|
|
25
|
+
* Existing records lack verified original context, so replay is paused.
|
|
10
26
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* second one. That property is what makes an automatic-looking retry acceptable
|
|
15
|
-
* at all — without it this command would be a duplicate-content generator.
|
|
27
|
+
* A queued request can already have reached the server. Its key prevents a
|
|
28
|
+
* duplicate only when that endpoint actually enforces durable idempotency;
|
|
29
|
+
* the client cannot infer that guarantee from a key alone.
|
|
16
30
|
*
|
|
17
31
|
* Outcomes are kept distinct on purpose:
|
|
18
|
-
* - sent —
|
|
19
|
-
* - refused —
|
|
20
|
-
*
|
|
21
|
-
* not lost silently.
|
|
22
|
-
* - deferred — still an outage. The entry stays, its attempt count rises.
|
|
32
|
+
* - sent — a recognizable result was recorded; the local entry is kept.
|
|
33
|
+
* - refused — retained in the output shape for older consumers.
|
|
34
|
+
* - deferred — no confirmed success. The entry stays for reconciliation.
|
|
23
35
|
*/
|
|
24
36
|
class OutboxRetry extends base_command_1.BaseCommand {
|
|
25
|
-
static description = '
|
|
37
|
+
static description = 'Inspect whether queued writes can be replayed safely';
|
|
26
38
|
static examples = [
|
|
27
39
|
'<%= config.bin %> outbox retry',
|
|
28
40
|
'<%= config.bin %> outbox retry <id>',
|
|
@@ -31,105 +43,135 @@ class OutboxRetry extends base_command_1.BaseCommand {
|
|
|
31
43
|
static args = {
|
|
32
44
|
id: core_1.Args.string({
|
|
33
45
|
ignoreStdin: true,
|
|
34
|
-
description: '
|
|
46
|
+
description: 'Inspect only this queued write',
|
|
35
47
|
required: false,
|
|
36
48
|
}),
|
|
37
49
|
};
|
|
38
50
|
static flags = {
|
|
39
51
|
json: core_1.Flags.boolean({ description: 'Output as JSON' }),
|
|
40
52
|
force: core_1.Flags.boolean({
|
|
41
|
-
description: `Include entries that
|
|
53
|
+
description: `Include entries that hit the ${outbox_1.MAX_REPLAY_ATTEMPTS}-attempt cap; does not bypass the replay pause`,
|
|
42
54
|
}),
|
|
43
55
|
};
|
|
44
56
|
async run() {
|
|
45
|
-
this.requireAuth();
|
|
46
57
|
const { args, flags } = await this.parse(OutboxRetry);
|
|
47
58
|
const profile = (0, keychain_1.getActiveProfile)();
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
const releaseReplay = await (0, outbox_1.lockOutboxReplay)(profile);
|
|
60
|
+
try {
|
|
61
|
+
const all = (0, outbox_1.listReplayWrites)(profile);
|
|
62
|
+
const review = all.filter((e) => (!args.id || e.id === args.id) && e.replay !== undefined)
|
|
63
|
+
.map((e) => ({ id: e.id, state: e.replay.state, resultId: e.replay.resultId }));
|
|
64
|
+
const unverified = all.filter((e) => (!args.id || e.id === args.id) && e.replay === undefined);
|
|
65
|
+
const targets = all.filter((e) => {
|
|
66
|
+
if (args.id && e.id !== args.id)
|
|
67
|
+
return false;
|
|
68
|
+
if (e.replay !== undefined)
|
|
69
|
+
return false;
|
|
70
|
+
if (!flags.force && e.attempts >= outbox_1.MAX_REPLAY_ATTEMPTS)
|
|
71
|
+
return false;
|
|
72
|
+
return true;
|
|
73
|
+
});
|
|
74
|
+
// Existing entries do not bind an authenticated actor, deployment, and
|
|
75
|
+
// workspace to the original request. A current profile or credential is
|
|
76
|
+
// not evidence of that original context. Keep them for manual review;
|
|
77
|
+
// --force only concerns the attempt cap and must not bypass this guard.
|
|
78
|
+
if (unverified.length > 0) {
|
|
79
|
+
this.failWithCliError({
|
|
80
|
+
code: 'OUTBOX_CONTEXT_UNVERIFIED',
|
|
81
|
+
message: `These queued writes do not prove their original server, account, and workspace. Nothing was sent. Inspect \`${this.config.bin} outbox list --json\`, then reconcile the original result and target before taking any further action. The local records remain.`,
|
|
82
|
+
exit: 1,
|
|
83
|
+
retryable: false,
|
|
84
|
+
details: { unverifiedIds: unverified.map((entry) => entry.id), reason: 'original_context_unverified' },
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
if (targets.length === 0) {
|
|
88
|
+
const msg = review.length > 0
|
|
89
|
+
? 'These entries already have a replay record. Inspect and reconcile them; they were not sent again.'
|
|
90
|
+
: args.id
|
|
91
|
+
? `No queued write ${args.id} eligible for replay.`
|
|
92
|
+
: 'Nothing to replay.';
|
|
93
|
+
if (flags.json) {
|
|
94
|
+
this.log(JSON.stringify({ sent: [], refused: [], deferred: [], review, message: msg }, null, 2));
|
|
95
|
+
if (review.some((item) => item.state === 'sending'))
|
|
96
|
+
this.exit(5);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
this.log(msg);
|
|
100
|
+
if (review.some((item) => item.state === 'sending'))
|
|
101
|
+
this.exit(5);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
this.requireAuth();
|
|
105
|
+
const sent = [];
|
|
106
|
+
const refused = [];
|
|
107
|
+
const deferred = [];
|
|
108
|
+
// Oldest first — the order they were authored in. Independent writes, so
|
|
109
|
+
// this is presentation, not a transactional guarantee (see outbox.ts).
|
|
110
|
+
for (const entry of targets) {
|
|
111
|
+
let claim;
|
|
112
|
+
try {
|
|
113
|
+
claim = (0, outbox_1.claimOutboxReplay)(entry.id, profile);
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
deferred.push({ id: entry.id, error: 'Could not persist replay state. No further entries were sent; inspect the queue and reconcile previous results.' });
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
if (!claim) {
|
|
120
|
+
deferred.push({ id: entry.id, error: 'The entry changed before it could be claimed; inspect it before retrying.' });
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
const result = await this.send(claim);
|
|
125
|
+
const resultId = replayResultId(claim, result);
|
|
126
|
+
if (!resultId) {
|
|
127
|
+
throw new Error('The server did not return a recognizable result; the write may have been applied.');
|
|
128
|
+
}
|
|
129
|
+
(0, outbox_1.acknowledgeOutboxReplay)(claim, resultId, profile);
|
|
130
|
+
sent.push(entry.id);
|
|
131
|
+
// Incident telemetry must not change a successfully sent write into a
|
|
132
|
+
// refusal or a deferred retry if recording the recovery fails.
|
|
133
|
+
try {
|
|
134
|
+
(0, outbox_1.recordRecovery)({ baseURL: this.cliConfig.baseURL }, profile);
|
|
135
|
+
}
|
|
136
|
+
catch { /* best effort */ }
|
|
137
|
+
}
|
|
138
|
+
catch (err) {
|
|
139
|
+
const e = err;
|
|
140
|
+
// A response, disconnect or parse failure need not prove whether the
|
|
141
|
+
// write ran. Keep the only local copy for the person to reconcile.
|
|
142
|
+
deferred.push({ id: entry.id, error: e.message || 'outcome unknown' });
|
|
143
|
+
// Do not widen uncertainty by sending more entries after an error.
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
60
147
|
if (flags.json) {
|
|
61
|
-
this.log(JSON.stringify({ sent
|
|
148
|
+
this.log(JSON.stringify({ sent, refused, deferred, review }, null, 2));
|
|
149
|
+
if (deferred.length > 0 || refused.length > 0 || review.some((item) => item.state === 'sending'))
|
|
150
|
+
this.exit(5);
|
|
62
151
|
return;
|
|
63
152
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const targetIds = new Set(targets.map((t) => t.id));
|
|
72
|
-
// Oldest first — the order they were authored in. Independent writes, so
|
|
73
|
-
// this is presentation, not a transactional guarantee (see outbox.ts).
|
|
74
|
-
for (const entry of targets) {
|
|
75
|
-
try {
|
|
76
|
-
await this.send(entry);
|
|
77
|
-
sent.push(entry.id);
|
|
78
|
-
(0, outbox_1.recordRecovery)({ baseURL: this.cliConfig.baseURL }, profile);
|
|
153
|
+
if (sent.length > 0)
|
|
154
|
+
this.log(`Recorded ${sent.length} result(s). Their local entries remain for inspection.`);
|
|
155
|
+
for (const r of refused) {
|
|
156
|
+
this.log('');
|
|
157
|
+
this.log(`Refused (removed from the queue): ${r.id} — ${r.error}`);
|
|
158
|
+
this.log('Your content, so it is not lost:');
|
|
159
|
+
this.log(JSON.stringify(r.body, null, 2));
|
|
79
160
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
//
|
|
85
|
-
// `isRetryableWrite`, not `isOutageFailure`: an entry queued because
|
|
86
|
-
// the credential had expired must survive a replay that hits the same
|
|
87
|
-
// 401, or the queue would drop exactly the writes it was created to
|
|
88
|
-
// protect the moment a user replayed before re-authenticating. Both
|
|
89
|
-
// ends of the queue read this ONE function, so they cannot disagree
|
|
90
|
-
// about what stays.
|
|
91
|
-
deferred.push({ id: entry.id, error: e.message || 'service unavailable' });
|
|
92
|
-
keep.push({
|
|
93
|
-
...entry,
|
|
94
|
-
attempts: entry.attempts + 1,
|
|
95
|
-
lastAttemptAt: new Date().toISOString(),
|
|
96
|
-
lastError: e.message || 'service unavailable',
|
|
97
|
-
});
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
// A refusal. Retrying a 4xx just refuses again, so stop carrying it —
|
|
101
|
-
// but echo the payload so the user's content is not lost silently.
|
|
102
|
-
refused.push({
|
|
103
|
-
id: entry.id,
|
|
104
|
-
error: `${e.status ? `HTTP ${e.status}: ` : ''}${e.message || 'refused'}`,
|
|
105
|
-
body: entry.body,
|
|
106
|
-
});
|
|
161
|
+
if (deferred.length > 0) {
|
|
162
|
+
this.log('');
|
|
163
|
+
this.log(`${deferred.length} still queued. A request may have reached the server; ` +
|
|
164
|
+
'inspect its result and context before deciding whether to retry.');
|
|
107
165
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (flags.json) {
|
|
113
|
-
this.log(JSON.stringify({ sent, refused, deferred }, null, 2));
|
|
114
|
-
if (deferred.length > 0 || refused.length > 0)
|
|
166
|
+
if (review.length > 0) {
|
|
167
|
+
this.log(`${review.length} previously started or recorded entry(ies) were not sent again. Inspect them with \`${this.config.bin} outbox list --json\`.`);
|
|
168
|
+
}
|
|
169
|
+
if (deferred.length > 0 || refused.length > 0 || review.some((item) => item.state === 'sending'))
|
|
115
170
|
this.exit(5);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
if (sent.length > 0)
|
|
119
|
-
this.log(`Sent ${sent.length} queued write(s).`);
|
|
120
|
-
for (const r of refused) {
|
|
121
|
-
this.log('');
|
|
122
|
-
this.log(`Refused (removed from the queue): ${r.id} — ${r.error}`);
|
|
123
|
-
this.log('Your content, so it is not lost:');
|
|
124
|
-
this.log(JSON.stringify(r.body, null, 2));
|
|
125
171
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
this.log(`${deferred.length} still queued — the service is not accepting writes yet. ` +
|
|
129
|
-
`Run \`${this.config.bin} outbox retry\` again once it recovers.`);
|
|
172
|
+
finally {
|
|
173
|
+
await releaseReplay();
|
|
130
174
|
}
|
|
131
|
-
if (deferred.length > 0 || refused.length > 0)
|
|
132
|
-
this.exit(5);
|
|
133
175
|
}
|
|
134
176
|
/**
|
|
135
177
|
* Dispatch one entry on the verb it was queued with.
|
|
@@ -143,6 +185,7 @@ class OutboxRetry extends base_command_1.BaseCommand {
|
|
|
143
185
|
async send(entry) {
|
|
144
186
|
return (0, api_fetch_1.apiFetch)(entry.url, {
|
|
145
187
|
method: entry.method.toUpperCase(),
|
|
188
|
+
singleAttempt: true,
|
|
146
189
|
...(entry.method === 'delete' ? {} : { body: entry.body }),
|
|
147
190
|
headers: {
|
|
148
191
|
'X-Idempotency-Key': entry.idempotencyKey,
|
|
@@ -152,7 +152,7 @@ class SpacesCreate extends base_command_1.BaseCommand {
|
|
|
152
152
|
// worse than the lost write. `requestIdempotency` on POST /api/spaces
|
|
153
153
|
// collapses the replay onto the original, and the key is derived from
|
|
154
154
|
// the payload so a genuinely different Space still creates.
|
|
155
|
-
this.queueWriteOrFail(err, {
|
|
155
|
+
await this.queueWriteOrFail(err, {
|
|
156
156
|
command: 'spaces create',
|
|
157
157
|
summary: `Space "${String(payload.title)}"`,
|
|
158
158
|
method: 'post',
|
|
@@ -226,7 +226,7 @@ class TasksCommentsAdd extends base_command_1.BaseCommand {
|
|
|
226
226
|
// writing, not just a retry. Queue it durably instead (OSK-2806). The
|
|
227
227
|
// key is kept from the original attempt, so replaying this queued intent
|
|
228
228
|
// collapses server-side rather than posting it twice.
|
|
229
|
-
this.queueWriteOrFail(err, {
|
|
229
|
+
await this.queueWriteOrFail(err, {
|
|
230
230
|
command: 'tasks comments add',
|
|
231
231
|
summary: `comment on task ${taskRef}`,
|
|
232
232
|
method: 'post',
|
|
@@ -7,9 +7,7 @@ class TriggersAudit extends base_command_1.BaseCommand {
|
|
|
7
7
|
static description = 'List fire audit records for a trigger, or owner-wide fire history with filters';
|
|
8
8
|
static examples = [
|
|
9
9
|
'<%= config.bin %> triggers audit <trigger-id>',
|
|
10
|
-
'<%= config.bin %> triggers audit --agent <agent-id> --limit 50',
|
|
11
10
|
'<%= config.bin %> triggers audit --scope agent --outcome failed --json',
|
|
12
|
-
'<%= config.bin %> triggers audit <trigger-id> --outcome skipped --reason debounced',
|
|
13
11
|
'<%= config.bin %> triggers audit <trigger-id> --limit 50 --json',
|
|
14
12
|
];
|
|
15
13
|
static args = {
|
|
@@ -23,12 +21,12 @@ class TriggersAudit extends base_command_1.BaseCommand {
|
|
|
23
21
|
limit: core_1.Flags.integer({ description: 'Maximum rows to return', default: 20 }),
|
|
24
22
|
before: core_1.Flags.string({ description: 'Pagination cursor/date for older rows' }),
|
|
25
23
|
trigger: core_1.Flags.string({ description: 'Trigger ID filter for owner-wide audit history' }),
|
|
26
|
-
agent: core_1.Flags.string({ description: 'Agent ID filter
|
|
24
|
+
agent: core_1.Flags.string({ description: 'Agent ID filter (currently refused: historical identity is unverified)' }),
|
|
27
25
|
scope: core_1.Flags.string({ description: 'Scope kind filter for owner-wide audit history' }),
|
|
28
26
|
outcome: core_1.Flags.string({
|
|
29
|
-
description: 'Exact outcome field (succeeded, failed, skipped, ...);
|
|
27
|
+
description: 'Exact outcome field (succeeded, failed, skipped, ...); the debounced alias is currently refused',
|
|
30
28
|
}),
|
|
31
|
-
reason: core_1.Flags.string({ description: '
|
|
29
|
+
reason: core_1.Flags.string({ description: 'Reason filter (currently refused: historical source identity is unverified)' }),
|
|
32
30
|
source: core_1.Flags.string({
|
|
33
31
|
description: 'Source filter (schedule, once, event, manual, webhook, replay, ...); an unknown value is refused with the full list',
|
|
34
32
|
}),
|
|
@@ -20,6 +20,12 @@ function describeFireAuditDetail(detail, fireId, triggerId) {
|
|
|
20
20
|
`Outcome: ${String(detail.outcome ?? '-')}`,
|
|
21
21
|
`Source: ${String(detail.source ?? '-')}`,
|
|
22
22
|
];
|
|
23
|
+
const projectionMetadata = detail.metadata;
|
|
24
|
+
if (detail.publicProjection === 'source_unverified' ||
|
|
25
|
+
projectionMetadata?.replayBlockedReason === 'event_not_authorized')
|
|
26
|
+
lines.push('Lineage: historical physical Trigger identity is unverified; this is a restricted summary.');
|
|
27
|
+
if (projectionMetadata?.replayBlockedReason === 'source_identity_unverified')
|
|
28
|
+
lines.push(`Replay: ${(0, triggers_1.unverifiedReplayExplanation)()}`);
|
|
23
29
|
const reason = text(detail.reason);
|
|
24
30
|
const message = text(detail.errorMessage);
|
|
25
31
|
if (reason)
|
|
@@ -87,7 +93,7 @@ function describeFireAuditDetail(detail, fireId, triggerId) {
|
|
|
87
93
|
return lines;
|
|
88
94
|
}
|
|
89
95
|
class TriggersFireDetail extends base_command_1.BaseCommand {
|
|
90
|
-
static description = 'Show
|
|
96
|
+
static description = 'Show the authorized restricted summary for one trigger fire';
|
|
91
97
|
static examples = [
|
|
92
98
|
'<%= config.bin %> triggers fire-detail <trigger-id> <fire-id>',
|
|
93
99
|
'<%= config.bin %> triggers fire-detail <trigger-id> <fire-id> --json',
|
|
@@ -35,7 +35,7 @@ class TriggersPreflight extends base_command_1.BaseCommand {
|
|
|
35
35
|
id: core_1.Args.string({ description: 'Trigger ID', required: true, ignoreStdin: true }),
|
|
36
36
|
};
|
|
37
37
|
static flags = {
|
|
38
|
-
json: core_1.Flags.boolean({ description: 'Output as JSON' }),
|
|
38
|
+
json: core_1.Flags.boolean({ description: 'Output the server response as JSON; use exit status for the effective verdict (2 means uncertain)' }),
|
|
39
39
|
'sample-event': core_1.Flags.string({
|
|
40
40
|
description: 'Path to a JSON event payload (or "-" for stdin) to exercise event filters and payload variables',
|
|
41
41
|
}),
|
|
@@ -67,7 +67,8 @@ class TriggersPreflight extends base_command_1.BaseCommand {
|
|
|
67
67
|
}
|
|
68
68
|
// Preserve machine-readable output while still communicating the verdict
|
|
69
69
|
// through the process contract.
|
|
70
|
-
const
|
|
70
|
+
const legacyResponse = report.decisionVersion !== 2;
|
|
71
|
+
const exitCode = preflightExitCode(legacyResponse ? null : report.wouldFire);
|
|
71
72
|
if (exitCode !== 0)
|
|
72
73
|
process.exitCode = exitCode;
|
|
73
74
|
if (flags.json) {
|
|
@@ -76,13 +77,17 @@ class TriggersPreflight extends base_command_1.BaseCommand {
|
|
|
76
77
|
}
|
|
77
78
|
// Three outcomes, not two — `suggest` (would run, but as an inbox card) is
|
|
78
79
|
// the most common real answer and must not read as either pass or fail.
|
|
79
|
-
const verdict =
|
|
80
|
-
? '
|
|
81
|
-
: report.wouldFire ===
|
|
82
|
-
? '
|
|
83
|
-
: report.
|
|
84
|
-
? '
|
|
85
|
-
:
|
|
80
|
+
const verdict = legacyResponse
|
|
81
|
+
? 'OUTCOME UNCERTAIN — this server did not report an ordered Trigger claim protocol check'
|
|
82
|
+
: report.wouldFire === true
|
|
83
|
+
? 'CHECKS PASSED — could run if the executing server has the same configuration'
|
|
84
|
+
: report.wouldFire === null
|
|
85
|
+
? 'INDETERMINATE — needs a live event or live state'
|
|
86
|
+
: (report.blockedBy
|
|
87
|
+
? report.gates.find((g) => g.name === report.blockedBy)
|
|
88
|
+
: report.gates.find((g) => g.verdict === 'block' || g.verdict === 'suggest'))?.verdict === 'suggest'
|
|
89
|
+
? 'MAY SUGGEST — an inbox card instead of an autonomous run'
|
|
90
|
+
: 'BLOCKED ON CHECKED SERVER — this check would stop before running';
|
|
86
91
|
// Name the RELATIONSHIP, and use the reason the gate already carries.
|
|
87
92
|
// `blockedBy` is a gate NAME, and rendering it bare produced
|
|
88
93
|
// `WOULD NOT RUN (enabled)` for a disabled trigger — which reads as
|
|
@@ -92,7 +97,7 @@ class TriggersPreflight extends base_command_1.BaseCommand {
|
|
|
92
97
|
const blocker = report.blockedBy
|
|
93
98
|
? report.gates.find((g) => g.name === report.blockedBy && g.verdict === 'block')
|
|
94
99
|
: undefined;
|
|
95
|
-
const because = report.blockedBy
|
|
100
|
+
const because = report.blockedBy && !legacyResponse
|
|
96
101
|
? ` — blocked by ${report.blockedBy}${blocker?.reason ? `: ${blocker.reason}` : ''}`
|
|
97
102
|
: '';
|
|
98
103
|
this.log(`${verdict}${because}`);
|
|
@@ -5,7 +5,7 @@ const base_command_1 = require("../../base-command");
|
|
|
5
5
|
const prompt_1 = require("../../lib/prompt");
|
|
6
6
|
const triggers_1 = require("../../lib/triggers");
|
|
7
7
|
class TriggersReplay extends base_command_1.BaseCommand {
|
|
8
|
-
static description = '
|
|
8
|
+
static description = 'Request historical trigger replay (currently refused when source identity is unverified)';
|
|
9
9
|
static examples = [
|
|
10
10
|
'<%= config.bin %> triggers replay <trigger-id> <fire-id>',
|
|
11
11
|
'<%= config.bin %> triggers replay <trigger-id> <fire-id> --from-json replay-options.json --json',
|
|
@@ -3,10 +3,8 @@ import { BaseCommand } from '../../base-command';
|
|
|
3
3
|
* Legacy per-agent run history — backs the `AgentTriggerRun` collection that
|
|
4
4
|
* pre-dates the universal `TriggerFireRecord` audit log.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* it covers every outcome (coalesced, debounced, capped, rate_limited, etc.)
|
|
9
|
-
* that the legacy table does not record.
|
|
6
|
+
* The route currently refuses historical Agent-scoped records because their
|
|
7
|
+
* physical Agent identity was not recorded. The trigger audit is restricted.
|
|
10
8
|
*/
|
|
11
9
|
export default class TriggersRuns extends BaseCommand {
|
|
12
10
|
static description: string;
|
|
@@ -7,13 +7,11 @@ const triggers_1 = require("../../lib/triggers");
|
|
|
7
7
|
* Legacy per-agent run history — backs the `AgentTriggerRun` collection that
|
|
8
8
|
* pre-dates the universal `TriggerFireRecord` audit log.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* it covers every outcome (coalesced, debounced, capped, rate_limited, etc.)
|
|
13
|
-
* that the legacy table does not record.
|
|
10
|
+
* The route currently refuses historical Agent-scoped records because their
|
|
11
|
+
* physical Agent identity was not recorded. The trigger audit is restricted.
|
|
14
12
|
*/
|
|
15
13
|
class TriggersRuns extends base_command_1.BaseCommand {
|
|
16
|
-
static description = '
|
|
14
|
+
static description = 'Request legacy Agent trigger history (currently unavailable without physical source identity)';
|
|
17
15
|
static examples = [
|
|
18
16
|
'<%= config.bin %> triggers runs <trigger-id> --agent <agent-id>',
|
|
19
17
|
'<%= config.bin %> triggers runs <trigger-id> --agent <agent-id> --limit 50 --json',
|