@skrr-ai/cli 0.1.20 → 0.1.22
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/commands/commitments/action-proposals/decide.js +22 -5
- package/dist/commands/commitments/action-proposals/execute.js +7 -3
- package/dist/commands/commitments/action-proposals.js +6 -4
- package/dist/commands/commitments/create.d.ts +1 -0
- package/dist/commands/commitments/create.js +19 -5
- package/dist/lib/commitment-product.js +9 -0
- package/dist/lib/commitments.d.ts +6 -1
- package/dist/lib/commitments.js +34 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/refreshClassification.js +9 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/refreshClassification.js +9 -2
- package/dist/node_modules/@skrr-ai/data-provider/index.js +13 -5
- package/oclif.manifest.json +7124 -7108
- package/package.json +1 -1
|
@@ -4,10 +4,14 @@ const core_1 = require("@oclif/core");
|
|
|
4
4
|
const base_command_1 = require("../../../base-command");
|
|
5
5
|
const commitments_1 = require("../../../lib/commitments");
|
|
6
6
|
class CommitmentsActionProposalsDecide extends base_command_1.BaseCommand {
|
|
7
|
-
static description = 'Approve & run, or reject, one frozen
|
|
7
|
+
static description = 'Approve & run, or reject, one frozen Action Bundle';
|
|
8
8
|
static args = {
|
|
9
9
|
commitmentId: core_1.Args.string({ description: 'Commitment ID', required: true, ignoreStdin: true }),
|
|
10
|
-
proposalId: core_1.Args.string({
|
|
10
|
+
proposalId: core_1.Args.string({
|
|
11
|
+
description: 'Action Proposal ID',
|
|
12
|
+
required: true,
|
|
13
|
+
ignoreStdin: true,
|
|
14
|
+
}),
|
|
11
15
|
};
|
|
12
16
|
static flags = {
|
|
13
17
|
json: core_1.Flags.boolean({ description: 'Output the decision and execution receipts as JSON' }),
|
|
@@ -19,7 +23,20 @@ class CommitmentsActionProposalsDecide extends base_command_1.BaseCommand {
|
|
|
19
23
|
const decision = flags.decision;
|
|
20
24
|
let result;
|
|
21
25
|
try {
|
|
22
|
-
const
|
|
26
|
+
const listed = await commitments_1.commitmentApi.actionProposals(args.commitmentId, { limit: 200 });
|
|
27
|
+
const proposal = listed.data.find((item) => item.id === args.proposalId);
|
|
28
|
+
if (!proposal)
|
|
29
|
+
this.error('Action Bundle not found.');
|
|
30
|
+
if (Number(proposal.bundleVersion) >= 2 && !proposal.snapshotDigest) {
|
|
31
|
+
this.error('Action Bundle has no review digest and cannot be decided safely.');
|
|
32
|
+
}
|
|
33
|
+
if (!flags.json && proposal.snapshotDigest) {
|
|
34
|
+
this.log(`Action Bundle digest: ${proposal.snapshotDigest}`);
|
|
35
|
+
}
|
|
36
|
+
const decided = await commitments_1.commitmentApi.decideActionProposal(args.commitmentId, args.proposalId, decision, {
|
|
37
|
+
snapshotDigest: proposal.snapshotDigest,
|
|
38
|
+
bundleVersion: proposal.bundleVersion,
|
|
39
|
+
});
|
|
23
40
|
const execution = decision === 'approve' && decided.status === 'approved'
|
|
24
41
|
? await commitments_1.commitmentApi.executeActionProposal(args.commitmentId, args.proposalId)
|
|
25
42
|
: undefined;
|
|
@@ -31,10 +48,10 @@ class CommitmentsActionProposalsDecide extends base_command_1.BaseCommand {
|
|
|
31
48
|
if (flags.json)
|
|
32
49
|
this.log(JSON.stringify(result, null, 2));
|
|
33
50
|
else if (decision === 'approve') {
|
|
34
|
-
this.log('
|
|
51
|
+
this.log('Action Bundle approved and handed to the durable executor.');
|
|
35
52
|
}
|
|
36
53
|
else {
|
|
37
|
-
this.log('
|
|
54
|
+
this.log('Action Bundle rejected.');
|
|
38
55
|
}
|
|
39
56
|
}
|
|
40
57
|
}
|
|
@@ -4,10 +4,14 @@ const core_1 = require("@oclif/core");
|
|
|
4
4
|
const base_command_1 = require("../../../base-command");
|
|
5
5
|
const commitments_1 = require("../../../lib/commitments");
|
|
6
6
|
class CommitmentsActionProposalsExecute extends base_command_1.BaseCommand {
|
|
7
|
-
static description = 'Nudge an approved
|
|
7
|
+
static description = 'Nudge an approved Action Bundle now (recovery continues automatically)';
|
|
8
8
|
static args = {
|
|
9
9
|
commitmentId: core_1.Args.string({ description: 'Commitment ID', required: true, ignoreStdin: true }),
|
|
10
|
-
proposalId: core_1.Args.string({
|
|
10
|
+
proposalId: core_1.Args.string({
|
|
11
|
+
description: 'Action Proposal ID',
|
|
12
|
+
required: true,
|
|
13
|
+
ignoreStdin: true,
|
|
14
|
+
}),
|
|
11
15
|
};
|
|
12
16
|
static flags = { json: core_1.Flags.boolean({ description: 'Output as JSON' }) };
|
|
13
17
|
async run() {
|
|
@@ -23,7 +27,7 @@ class CommitmentsActionProposalsExecute extends base_command_1.BaseCommand {
|
|
|
23
27
|
if (flags.json)
|
|
24
28
|
this.log(JSON.stringify(result, null, 2));
|
|
25
29
|
else
|
|
26
|
-
this.log(`
|
|
30
|
+
this.log(`Action Bundle is ${String(result.status || 'queued')}.`);
|
|
27
31
|
}
|
|
28
32
|
}
|
|
29
33
|
exports.default = CommitmentsActionProposalsExecute;
|
|
@@ -5,7 +5,7 @@ const base_command_1 = require("../../base-command");
|
|
|
5
5
|
const commitments_1 = require("../../lib/commitments");
|
|
6
6
|
const format_1 = require("../../lib/format");
|
|
7
7
|
class CommitmentsActionProposals extends base_command_1.BaseCommand {
|
|
8
|
-
static description = 'List frozen
|
|
8
|
+
static description = 'List frozen Action Bundles and their recovery state';
|
|
9
9
|
static args = {
|
|
10
10
|
id: core_1.Args.string({ description: 'Commitment ID', required: true, ignoreStdin: true }),
|
|
11
11
|
};
|
|
@@ -35,18 +35,20 @@ class CommitmentsActionProposals extends base_command_1.BaseCommand {
|
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
37
|
if (!response.data.length) {
|
|
38
|
-
this.log('No prepared
|
|
38
|
+
this.log('No prepared Action Bundles.');
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
(0, format_1.renderTable)(response.data.map((proposal) => ({
|
|
42
42
|
id: proposal.id,
|
|
43
|
-
|
|
43
|
+
actions: String(proposal.actionSnapshots?.length || 1),
|
|
44
|
+
digest: proposal.snapshotDigest || 'legacy',
|
|
44
45
|
status: proposal.status,
|
|
45
46
|
attempt: `${proposal.attempt || 0}/${proposal.maxAttempts || 3}`,
|
|
46
47
|
expires: proposal.expiresAt || '—',
|
|
47
48
|
})), [
|
|
48
49
|
{ key: 'id', header: 'PROPOSAL', verbatim: true },
|
|
49
|
-
{ key: '
|
|
50
|
+
{ key: 'actions', header: 'ACTIONS' },
|
|
51
|
+
{ key: 'digest', header: 'DIGEST', maxWidth: 64, verbatim: true },
|
|
50
52
|
{ key: 'status', header: 'STATUS' },
|
|
51
53
|
{ key: 'attempt', header: 'ATTEMPT' },
|
|
52
54
|
{ key: 'expires', header: 'EXPIRES', maxWidth: 28 },
|
|
@@ -62,6 +62,7 @@ export default class CommitmentsCreate extends BaseCommand {
|
|
|
62
62
|
measure: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
63
63
|
source: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
64
64
|
watch: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
65
|
+
'github-event': import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
65
66
|
'metric-key': import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
66
67
|
'watch-space': import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
67
68
|
'watch-monitor': import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
@@ -13,6 +13,15 @@ const commitment_product_1 = require("../../lib/commitment-product");
|
|
|
13
13
|
const commitments_1 = require("../../lib/commitments");
|
|
14
14
|
const DEFAULT_EVENT_DRIVEN_BACKSTOP_MS = 24 * 60 * 60 * 1000;
|
|
15
15
|
const DEFAULT_EVENT_SOURCES = new Set(['github', 'slack', 'email', 'calendar']);
|
|
16
|
+
const GITHUB_EVENT_OPTIONS = [
|
|
17
|
+
'pull_request_opened',
|
|
18
|
+
'pull_request_merged',
|
|
19
|
+
'review_requested',
|
|
20
|
+
'check_run_failed',
|
|
21
|
+
'check_run_succeeded',
|
|
22
|
+
'issue_opened',
|
|
23
|
+
'comment_created',
|
|
24
|
+
];
|
|
16
25
|
function record(value) {
|
|
17
26
|
return value && typeof value === 'object' && !Array.isArray(value)
|
|
18
27
|
? value
|
|
@@ -66,7 +75,7 @@ function hasEventCapableWatchedSource(payload) {
|
|
|
66
75
|
return Array.isArray(config?.events) ? hasStructurallyValidExplicitEvent(config) : true;
|
|
67
76
|
}
|
|
68
77
|
if (source === 'tasks') {
|
|
69
|
-
return
|
|
78
|
+
return goalId || configuredId(config, 'taskId', 'goalId', 'keyResultId');
|
|
70
79
|
}
|
|
71
80
|
if (source === 'goal') {
|
|
72
81
|
return goalId || configuredId(config, 'goalId', 'keyResultId');
|
|
@@ -113,9 +122,7 @@ function createCadenceFromFlags({ eventDriven, cadence: cadenceInput, cadenceMod
|
|
|
113
122
|
}
|
|
114
123
|
return {
|
|
115
124
|
mode: 'event_plus_interval',
|
|
116
|
-
intervalMs: cadenceInput
|
|
117
|
-
? (0, commitments_1.parseIntervalToMs)(cadenceInput)
|
|
118
|
-
: DEFAULT_EVENT_DRIVEN_BACKSTOP_MS,
|
|
125
|
+
intervalMs: cadenceInput ? (0, commitments_1.parseIntervalToMs)(cadenceInput) : DEFAULT_EVENT_DRIVEN_BACKSTOP_MS,
|
|
119
126
|
...(timezone ? { timezone } : {}),
|
|
120
127
|
};
|
|
121
128
|
}
|
|
@@ -180,7 +187,7 @@ class CommitmentsCreate extends base_command_1.BaseCommand {
|
|
|
180
187
|
'<%= config.bin %> commitments create --agent <agent-id> --title "SLA" --outcome "p95 under 200ms" --criterion "p95 latency confirmed" --evaluator metric --measure <measure-id>',
|
|
181
188
|
'<%= config.bin %> commitments create --agent <agent-id> --title "AWS cost watch" --outcome "Cost regressions are investigated" --agent-directive-file ./aws-cost-policy.md',
|
|
182
189
|
'<%= config.bin %> commitments create --from-json commitment.json --json',
|
|
183
|
-
'<%= config.bin %> commitments create --agent <agent-id> --title "Keep CI healthy" --outcome "Failed checks are repaired" --watch github --event-driven --mode execute --delivery draft-pr --repo owner/repo --base main --status draft',
|
|
190
|
+
'<%= config.bin %> commitments create --agent <agent-id> --title "Keep CI healthy" --outcome "Failed checks are repaired" --watch github --github-event check_run_failed --event-driven --mode execute --delivery draft-pr --repo owner/repo --base main --status draft',
|
|
184
191
|
];
|
|
185
192
|
static flags = {
|
|
186
193
|
json: core_1.Flags.boolean({ description: 'Output the created commitment as JSON' }),
|
|
@@ -228,6 +235,11 @@ class CommitmentsCreate extends base_command_1.BaseCommand {
|
|
|
228
235
|
multiple: true,
|
|
229
236
|
options: [...commitments_1.COMMITMENT_WATCHED_SOURCES],
|
|
230
237
|
}),
|
|
238
|
+
'github-event': core_1.Flags.string({
|
|
239
|
+
description: 'GitHub event to watch (repeatable; implies --watch github). Use check_run_failed for CI remediation.',
|
|
240
|
+
multiple: true,
|
|
241
|
+
options: [...GITHUB_EVENT_OPTIONS],
|
|
242
|
+
}),
|
|
231
243
|
'metric-key': core_1.Flags.string({
|
|
232
244
|
description: 'Metric key to read when --watch metrics is used (repeatable)',
|
|
233
245
|
multiple: true,
|
|
@@ -360,6 +372,8 @@ class CommitmentsCreate extends base_command_1.BaseCommand {
|
|
|
360
372
|
metricKey: (0, triggers_1.splitRepeated)(flags['metric-key']),
|
|
361
373
|
spaceIds: resolvedSpaceIds,
|
|
362
374
|
monitorIds: (0, triggers_1.splitRepeated)(flags['watch-monitor']),
|
|
375
|
+
githubEvents: (0, triggers_1.splitRepeated)(flags['github-event']),
|
|
376
|
+
githubRepository: flags.repo,
|
|
363
377
|
});
|
|
364
378
|
if (built)
|
|
365
379
|
payload.watchedSources = built;
|
|
@@ -63,6 +63,10 @@ function deliveryForProductMode(mode, delivery) {
|
|
|
63
63
|
function renderExecutionReceipt(receipt, log, verbose = false) {
|
|
64
64
|
log(receipt.summary);
|
|
65
65
|
log(`Mode: ${productModeLabel(receipt.mode)}`);
|
|
66
|
+
if (receipt.runtime) {
|
|
67
|
+
const identity = receipt.runtime.name || receipt.runtime.id || 'the selected runtime';
|
|
68
|
+
log(`Runtime: ${identity}${receipt.runtime.kind ? ` · ${receipt.runtime.kind}` : ''}${receipt.runtime.provider ? ` · ${receipt.runtime.provider}` : ''}`);
|
|
69
|
+
}
|
|
66
70
|
for (const phase of receipt.phases) {
|
|
67
71
|
const mark = { done: '✓', working: '→', waiting: '…', failed: '×', skipped: '–' }[phase.status];
|
|
68
72
|
log(` ${mark} ${phase.phase[0].toUpperCase() + phase.phase.slice(1)}: ${phase.summary}${phase.at ? ` · ${phase.at}` : ''}`);
|
|
@@ -73,6 +77,11 @@ function renderExecutionReceipt(receipt, log, verbose = false) {
|
|
|
73
77
|
}
|
|
74
78
|
if (receipt.nextActor)
|
|
75
79
|
log(`Next: ${receipt.nextActor.label || receipt.nextActor.kind}${receipt.nextActor.reason ? ` — ${receipt.nextActor.reason}` : ''}`);
|
|
80
|
+
if (receipt.blocker) {
|
|
81
|
+
log(`Blocker: ${receipt.blocker.code}`);
|
|
82
|
+
for (const evidenceRef of receipt.blocker.evidenceRefs || [])
|
|
83
|
+
log(` Evidence: ${evidenceRef}`);
|
|
84
|
+
}
|
|
76
85
|
if (verbose)
|
|
77
86
|
log(`Diagnostics:\n${JSON.stringify({ id: receipt.id, revision: receipt.revision, evidence: receipt.evidence, diagnostics: receipt.diagnostics }, null, 2)}`);
|
|
78
87
|
}
|
|
@@ -270,7 +270,10 @@ export declare const commitmentApi: {
|
|
|
270
270
|
* commitment and knows what should be done had no way to say so.
|
|
271
271
|
*/
|
|
272
272
|
proposeActionProposal: (id: string, body: Record<string, unknown>) => Promise<Record<string, unknown>>;
|
|
273
|
-
decideActionProposal: (id: string, proposalId: string, decision: "approve" | "reject"
|
|
273
|
+
decideActionProposal: (id: string, proposalId: string, decision: "approve" | "reject", snapshot?: {
|
|
274
|
+
snapshotDigest?: string;
|
|
275
|
+
bundleVersion?: number;
|
|
276
|
+
}) => Promise<Record<string, unknown>>;
|
|
274
277
|
executeActionProposal: (id: string, proposalId: string) => Promise<Record<string, unknown>>;
|
|
275
278
|
preflight: (id: string, nextRunCount?: number) => Promise<CommitmentPreflightReport>;
|
|
276
279
|
effectivePolicy: (id: string) => Promise<Record<string, unknown>>;
|
|
@@ -446,6 +449,8 @@ export declare function parseIntervalToMs(input: string): number;
|
|
|
446
449
|
export type WatchFlagInputs = {
|
|
447
450
|
watch?: string[];
|
|
448
451
|
metricKey?: string[];
|
|
452
|
+
githubEvents?: string[];
|
|
453
|
+
githubRepository?: string;
|
|
449
454
|
/** Already resolved to canonical space ids by the caller. */
|
|
450
455
|
spaceIds?: string[];
|
|
451
456
|
monitorIds?: string[];
|
package/dist/lib/commitments.js
CHANGED
|
@@ -166,8 +166,10 @@ exports.commitmentApi = {
|
|
|
166
166
|
* commitment and knows what should be done had no way to say so.
|
|
167
167
|
*/
|
|
168
168
|
proposeActionProposal: (id, body) => data_provider_1.request.post(`${base(id)}/action-proposals`, body),
|
|
169
|
-
decideActionProposal: (id, proposalId, decision) => data_provider_1.request.post(`${base(id)}/action-proposals/${encodeURIComponent(proposalId)}/decision`, {
|
|
169
|
+
decideActionProposal: (id, proposalId, decision, snapshot) => data_provider_1.request.post(`${base(id)}/action-proposals/${encodeURIComponent(proposalId)}/decision`, {
|
|
170
170
|
decision,
|
|
171
|
+
...(snapshot?.snapshotDigest ? { snapshotDigest: snapshot.snapshotDigest } : {}),
|
|
172
|
+
...(snapshot?.bundleVersion ? { bundleVersion: snapshot.bundleVersion } : {}),
|
|
171
173
|
}),
|
|
172
174
|
executeActionProposal: (id, proposalId) => data_provider_1.request.post(`${base(id)}/action-proposals/${encodeURIComponent(proposalId)}/execute`, {}),
|
|
173
175
|
preflight: (id, nextRunCount) => data_provider_1.request.post(`${base(id)}/preflight`, {
|
|
@@ -436,11 +438,17 @@ function buildWatchedSources(inputs) {
|
|
|
436
438
|
const metricKeys = (inputs.metricKey ?? []).filter(Boolean);
|
|
437
439
|
const spaceIds = (inputs.spaceIds ?? []).filter(Boolean);
|
|
438
440
|
const monitorIds = (inputs.monitorIds ?? []).filter(Boolean);
|
|
441
|
+
const githubEvents = (inputs.githubEvents ?? []).filter(Boolean);
|
|
442
|
+
const githubRepository = String(inputs.githubRepository || '')
|
|
443
|
+
.trim()
|
|
444
|
+
.toLowerCase();
|
|
439
445
|
const effective = new Set(watched);
|
|
440
446
|
if (spaceIds.length)
|
|
441
447
|
effective.add('space');
|
|
442
448
|
if (monitorIds.length)
|
|
443
449
|
effective.add('monitor');
|
|
450
|
+
if (githubEvents.length)
|
|
451
|
+
effective.add('github');
|
|
444
452
|
if (effective.has('space') && spaceIds.length === 0) {
|
|
445
453
|
throw new Error('--watch space needs at least one --watch-space <space-id-or-ref>. ' +
|
|
446
454
|
'The `space` source requires a scope id, which the enum on its own cannot carry.');
|
|
@@ -464,7 +472,7 @@ function buildWatchedSources(inputs) {
|
|
|
464
472
|
seen.add(s);
|
|
465
473
|
}
|
|
466
474
|
}
|
|
467
|
-
for (const implied of ['space', 'monitor']) {
|
|
475
|
+
for (const implied of ['space', 'monitor', 'github']) {
|
|
468
476
|
if (effective.has(implied) && !seen.has(implied)) {
|
|
469
477
|
orderedSources.push(implied);
|
|
470
478
|
seen.add(implied);
|
|
@@ -485,6 +493,30 @@ function buildWatchedSources(inputs) {
|
|
|
485
493
|
else if (source === 'metrics' && metricKeys.length) {
|
|
486
494
|
rows.push({ source, enabled: true, config: { metricKeys } });
|
|
487
495
|
}
|
|
496
|
+
else if (source === 'github' && (githubEvents.length || githubRepository)) {
|
|
497
|
+
rows.push({
|
|
498
|
+
source,
|
|
499
|
+
enabled: true,
|
|
500
|
+
config: {
|
|
501
|
+
...(githubRepository ? { repository: githubRepository } : {}),
|
|
502
|
+
...(githubEvents.length
|
|
503
|
+
? {
|
|
504
|
+
events: githubEvents.map((eventType) => ({
|
|
505
|
+
entityType: 'github',
|
|
506
|
+
eventType,
|
|
507
|
+
...(githubRepository
|
|
508
|
+
? {
|
|
509
|
+
filterField: 'repoFullName',
|
|
510
|
+
filterMode: 'equals',
|
|
511
|
+
filterValue: githubRepository,
|
|
512
|
+
}
|
|
513
|
+
: {}),
|
|
514
|
+
})),
|
|
515
|
+
}
|
|
516
|
+
: {}),
|
|
517
|
+
},
|
|
518
|
+
});
|
|
519
|
+
}
|
|
488
520
|
else {
|
|
489
521
|
rows.push({ source, enabled: true });
|
|
490
522
|
}
|
|
@@ -22,8 +22,9 @@ Object.defineProperty(exports, "PermanentAuthFailure", { enumerable: true, get:
|
|
|
22
22
|
Object.defineProperty(exports, "TransientAuthFailure", { enumerable: true, get: function () { return types_js_1.TransientAuthFailure; } });
|
|
23
23
|
/**
|
|
24
24
|
* Maps server-supplied error codes to the canonical PermanentAuthReason values
|
|
25
|
-
* exported from types.ts.
|
|
26
|
-
*
|
|
25
|
+
* exported from types.ts. `REFRESH_MISSING` is a server protocol code rather
|
|
26
|
+
* than a user-facing reason; it maps to `REFRESH_INVALID` because an identical
|
|
27
|
+
* retry cannot gain the credential the server says was absent.
|
|
27
28
|
*/
|
|
28
29
|
const PERMANENT_CODE_SET = new Set([
|
|
29
30
|
'REFRESH_INVALID',
|
|
@@ -63,6 +64,12 @@ function classifyRefreshResponse(status, body) {
|
|
|
63
64
|
}
|
|
64
65
|
// 401 — auth failure; check for known permanent code
|
|
65
66
|
if (status === 401) {
|
|
67
|
+
if (body?.code === 'REFRESH_MISSING') {
|
|
68
|
+
return {
|
|
69
|
+
kind: 'failure',
|
|
70
|
+
failure: new types_js_1.PermanentAuthFailure('REFRESH_INVALID', body.message ?? 'Refresh token missing'),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
66
73
|
const code = body?.code;
|
|
67
74
|
if (code && PERMANENT_CODE_SET.has(code)) {
|
|
68
75
|
return {
|
|
@@ -23,8 +23,9 @@ import { PermanentAuthFailure, TransientAuthFailure } from './types.js';
|
|
|
23
23
|
export { PermanentAuthFailure, TransientAuthFailure };
|
|
24
24
|
/**
|
|
25
25
|
* Maps server-supplied error codes to the canonical PermanentAuthReason values
|
|
26
|
-
* exported from types.ts.
|
|
27
|
-
*
|
|
26
|
+
* exported from types.ts. `REFRESH_MISSING` is a server protocol code rather
|
|
27
|
+
* than a user-facing reason; it maps to `REFRESH_INVALID` because an identical
|
|
28
|
+
* retry cannot gain the credential the server says was absent.
|
|
28
29
|
*/
|
|
29
30
|
const PERMANENT_CODE_SET = new Set([
|
|
30
31
|
'REFRESH_INVALID',
|
|
@@ -64,6 +65,12 @@ export function classifyRefreshResponse(status, body) {
|
|
|
64
65
|
}
|
|
65
66
|
// 401 — auth failure; check for known permanent code
|
|
66
67
|
if (status === 401) {
|
|
68
|
+
if (body?.code === 'REFRESH_MISSING') {
|
|
69
|
+
return {
|
|
70
|
+
kind: 'failure',
|
|
71
|
+
failure: new PermanentAuthFailure('REFRESH_INVALID', body.message ?? 'Refresh token missing'),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
67
74
|
const code = body?.code;
|
|
68
75
|
if (code && PERMANENT_CODE_SET.has(code)) {
|
|
69
76
|
return {
|
|
@@ -41007,6 +41007,7 @@ function vk() {
|
|
|
41007
41007
|
mk(null);
|
|
41008
41008
|
}
|
|
41009
41009
|
function hk(e2, t2) {
|
|
41010
|
+
if (401 === e2 && "REFRESH_MISSING" === (null == t2 ? void 0 : t2.code)) return "permanent";
|
|
41010
41011
|
var n2 = o.classifyRefreshResponse(e2, t2);
|
|
41011
41012
|
if ("success" === n2.kind) return "transient";
|
|
41012
41013
|
if (n2.failure instanceof o.PermanentAuthFailure) {
|
|
@@ -41816,10 +41817,10 @@ var Nk = Object.freeze({ __proto__: null, acceptAgentIntuition: function(e2, t2,
|
|
|
41816
41817
|
return "".concat(_o(e3), "/").concat(encodeURIComponent(t3), "/").concat(n3);
|
|
41817
41818
|
})(e2, t2, n2), o2);
|
|
41818
41819
|
}, decideCommitmentActionProposal: function(e2) {
|
|
41819
|
-
var t2 = e2.commitmentId, n2 = e2.proposalId, o2 = e2.decision;
|
|
41820
|
+
var t2 = e2.commitmentId, n2 = e2.proposalId, o2 = e2.decision, r2 = e2.snapshotDigest, a2 = e2.bundleVersion;
|
|
41820
41821
|
return Sk.post((function(e3, t3) {
|
|
41821
41822
|
return "".concat(Zr(e3), "/").concat(encodeURIComponent(t3), "/decision");
|
|
41822
|
-
})(t2, n2), { decision: o2 });
|
|
41823
|
+
})(t2, n2), f(f({ decision: o2 }, r2 ? { snapshotDigest: r2 } : {}), a2 ? { bundleVersion: a2 } : {}));
|
|
41823
41824
|
}, decideCommitmentAutonomyRequest: function(e2) {
|
|
41824
41825
|
var t2 = e2.commitmentId, n2 = e2.requestId, o2 = e2.data;
|
|
41825
41826
|
return Sk.post((function(e3, t3) {
|
|
@@ -42476,6 +42477,10 @@ var Nk = Object.freeze({ __proto__: null, acceptAgentIntuition: function(e2, t2,
|
|
|
42476
42477
|
var t2 = "".concat(ta(), "/distribution");
|
|
42477
42478
|
return e3 ? "".concat(t2).concat(en(e3)) : t2;
|
|
42478
42479
|
})(e2));
|
|
42480
|
+
}, getCommitmentExecutionReceiptQuarterlyMetrics: function(e2, t2, n2) {
|
|
42481
|
+
return Sk.get((function(e3, t3, n3) {
|
|
42482
|
+
return "".concat(Kr(e3), "/receipt-metrics/quarterly").concat(en({ year: t3, quarter: n3 }));
|
|
42483
|
+
})(e2, t2, n2));
|
|
42479
42484
|
}, getCommitmentHeldSurfaces: function(e2) {
|
|
42480
42485
|
return Sk.get((function(e3) {
|
|
42481
42486
|
return "".concat(ta(), "/held-surfaces").concat(e3 ? "?commitmentId=".concat(e3) : "");
|
|
@@ -46620,6 +46625,9 @@ exports.ACCEPTED_AGENT_TRIGGER_FIRE_OUTCOMES = ["succeeded", "in_progress", "awa
|
|
|
46620
46625
|
}).map(function(e3) {
|
|
46621
46626
|
return { band: e3, projects: n2.get(e3) };
|
|
46622
46627
|
});
|
|
46628
|
+
}, exports.hasAuthTokenHeader = function() {
|
|
46629
|
+
var e2 = n.defaults.headers.common.Authorization;
|
|
46630
|
+
return "string" == typeof e2 && e2.length > 0;
|
|
46623
46631
|
}, exports.hasCycle = _d, exports.hasMessageEmbeds = function(e2) {
|
|
46624
46632
|
return mf(e2).length > 0;
|
|
46625
46633
|
}, exports.hasPermissions = function(e2, t2) {
|
|
@@ -47646,7 +47654,8 @@ exports.ACCEPTED_AGENT_TRIGGER_FIRE_OUTCOMES = ["succeeded", "in_progress", "awa
|
|
|
47646
47654
|
return n2 && "object" == typeof n2 && (("preset" !== n2.type || wy(n2.id)) && ("preset" === n2.type || "asset" === n2.type || "image" === n2.type)) ? { mode: "fixed", ref: n2 } : Ny;
|
|
47647
47655
|
}
|
|
47648
47656
|
return "random" === t2.mode ? "all" === t2.scope || "mine" === t2.scope ? { mode: "random", scope: t2.scope } : "category" === t2.scope && _y(t2.category) ? { mode: "random", scope: "category", category: t2.category } : Ny : Ny;
|
|
47649
|
-
}
|
|
47657
|
+
};
|
|
47658
|
+
exports.resolveAgentAvatarRef = function(e2) {
|
|
47650
47659
|
if (null == e2) return Py;
|
|
47651
47660
|
if ("string" == typeof e2) return e2.trim() ? { type: "image", filepath: e2, source: "" } : Py;
|
|
47652
47661
|
if ("object" != typeof e2) return Py;
|
|
@@ -47662,8 +47671,7 @@ exports.ACCEPTED_AGENT_TRIGGER_FIRE_OUTCOMES = ["succeeded", "in_progress", "awa
|
|
|
47662
47671
|
return "string" == typeof t2.filepath && t2.filepath.trim() ? { type: "image", filepath: t2.filepath, source: "string" == typeof t2.source ? t2.source : "" } : Py;
|
|
47663
47672
|
}
|
|
47664
47673
|
return "string" == typeof t2.filepath && t2.filepath.trim() ? { type: "image", filepath: t2.filepath, source: "string" == typeof t2.source ? t2.source : "" } : Py;
|
|
47665
|
-
}
|
|
47666
|
-
exports.resolveAgentSceneBackgroundPreset = Ty, exports.resolveAgentToneMode = function(e2) {
|
|
47674
|
+
}, exports.resolveAgentSceneBackgroundPreset = Ty, exports.resolveAgentToneMode = function(e2) {
|
|
47667
47675
|
var t2 = null == e2 ? void 0 : e2.toneMode;
|
|
47668
47676
|
return "inherit" === t2 || "none" === t2 || "explicit" === t2 ? t2 : (null == e2 ? void 0 : e2.toneId) ? "explicit" : "inherit";
|
|
47669
47677
|
}, exports.resolveAutonomyCeiling = function(e2) {
|