@skrr-ai/cli 0.1.143 → 0.1.144
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 +8 -0
- package/dist/commands/agenda/trigger/create.js +4 -2
- package/dist/commands/agenda/trigger/list.js +7 -7
- package/dist/commands/agent/message/approve.d.ts +17 -0
- package/dist/commands/agent/message/approve.js +72 -0
- package/dist/commands/agent/message/decline.d.ts +17 -0
- package/dist/commands/agent/message/decline.js +72 -0
- package/dist/commands/agent/message/pending.d.ts +18 -0
- package/dist/commands/agent/message/pending.js +79 -0
- package/dist/commands/agents/delete.d.ts +45 -0
- package/dist/commands/agents/delete.js +139 -2
- package/dist/commands/agents/plan-day.d.ts +39 -7
- package/dist/commands/agents/plan-day.js +254 -65
- package/dist/commands/agents/proactive-audit.d.ts +22 -0
- package/dist/commands/agents/proactive-audit.js +86 -0
- package/dist/commands/agents/schedule-overview.d.ts +7 -0
- package/dist/commands/agents/schedule-overview.js +43 -5
- package/dist/commands/agents/schedule-trace.js +30 -19
- package/dist/commands/agents/spawn.d.ts +42 -0
- package/dist/commands/agents/spawn.js +91 -4
- package/dist/commands/agents/todos/list.d.ts +5 -0
- package/dist/commands/agents/todos/list.js +19 -5
- package/dist/commands/agents/triggers/create.js +1 -1
- package/dist/commands/agents/triggers/update.js +1 -1
- package/dist/commands/commitments/create.js +13 -3
- package/dist/commands/commitments/preflight.js +14 -3
- package/dist/commands/initiatives/worker/deactivate.d.ts +23 -0
- package/dist/commands/initiatives/worker/deactivate.js +78 -0
- package/dist/commands/login.js +8 -2
- package/dist/commands/logout.d.ts +20 -0
- package/dist/commands/logout.js +110 -5
- package/dist/commands/memory/maintain.js +16 -2
- package/dist/commands/spaces/delete.js +6 -1
- package/dist/commands/spaces/workflows/archive.js +6 -1
- package/dist/commands/spaces/workflows/publish.js +3 -1
- package/dist/commands/spaces/workflows/run.d.ts +1 -0
- package/dist/commands/spaces/workflows/run.js +17 -1
- package/dist/commands/spaces/workflows/triggers/create.js +3 -1
- package/dist/commands/tasks/workflow-context.js +3 -1
- package/dist/commands/triggers/capabilities.js +17 -1
- package/dist/commands/triggers/create.d.ts +2 -0
- package/dist/commands/triggers/create.js +23 -7
- package/dist/commands/triggers/fire-detail.js +12 -3
- package/dist/commands/triggers/list.d.ts +1 -0
- package/dist/commands/triggers/list.js +13 -1
- package/dist/commands/triggers/preflight.js +18 -0
- package/dist/commands/triggers/prune.js +9 -5
- package/dist/commands/triggers/update.js +13 -4
- package/dist/generated/agent-guides.json +35 -35
- package/dist/lib/agent-proactive-baseline.js +7 -1
- package/dist/lib/commitments.d.ts +16 -9
- package/dist/lib/commitments.js +65 -4
- package/dist/lib/daemon-setup.js +9 -3
- package/dist/lib/daemonBroker.d.ts +7 -0
- package/dist/lib/daemonBroker.js +5 -0
- package/dist/lib/daemonHandoff.d.ts +2 -0
- package/dist/lib/daemonHandoff.js +10 -1
- package/dist/lib/daemonIslandProfile.d.ts +19 -0
- package/dist/lib/daemonIslandProfile.js +41 -0
- package/dist/lib/format.d.ts +32 -0
- package/dist/lib/format.js +105 -1
- package/dist/lib/initiatives-worker.d.ts +25 -0
- package/dist/lib/initiatives-worker.js +13 -0
- package/dist/lib/login.d.ts +7 -0
- package/dist/lib/login.js +5 -0
- package/dist/lib/proactive-audit.d.ts +52 -0
- package/dist/lib/proactive-audit.js +67 -0
- package/dist/lib/proactiveApi.d.ts +9 -0
- package/dist/lib/refresh.d.ts +20 -6
- package/dist/lib/refresh.js +27 -9
- package/dist/lib/roles.d.ts +1 -1
- package/dist/lib/schedule.d.ts +189 -9
- package/dist/lib/schedule.js +283 -22
- package/dist/lib/triggers.d.ts +134 -3
- package/dist/lib/triggers.js +370 -17
- package/dist/lib/workflow-node-control.js +8 -0
- package/dist/lib/workflow-run-view.js +9 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.d.ts +1 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.js +2 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/refresh.d.ts +22 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/refresh.js +15 -4
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.d.ts +1 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.js +1 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/refresh.d.ts +22 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/refresh.js +22 -4
- package/dist/node_modules/@skrr-ai/data-provider/index.js +4779 -4741
- package/oclif.manifest.json +494 -26
- package/package.json +1 -1
package/dist/lib/triggers.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.triggerApi = exports.AgentTriggerScopeError = exports.TRIGGER_MODE_REQUIRED_FLAGS = exports.TRIGGER_CREATE_FIELD_FLAGS = exports.FLAG_OWNER_KINDS = exports.SCOPE_IMPLIED_REF_KEY = exports.TRIGGER_EVENT_CATALOG = exports.TRIGGER_EVENT_ENTITY_TYPES = exports.TRIGGER_CHAT_AUTH_MODES = exports.TRIGGER_CHAT_RESPONSE_MODES = exports.TRIGGER_CHAT_MODES = exports.TRIGGER_FORM_RESPONSE_MODES = exports.TRIGGER_CONCURRENCY_POLICIES = exports.TRIGGER_EVENT_FILTER_MODES = exports.TRIGGER_EXECUTOR_MODES = exports.TRIGGER_SCOPE_KINDS = exports.TRIGGER_KINDS = void 0;
|
|
3
|
+
exports.triggerApi = exports.TRIGGER_LIMIT_CEILING = exports.TRIGGER_MODE_FLAG_DESCRIPTION = exports.TRIGGER_WINDOW_FLAG_HELP = exports.AgentTriggerScopeError = exports.TRIGGER_MODE_REQUIRED_FLAGS = exports.TRIGGER_CREATE_FIELD_FLAGS = exports.FLAG_OWNER_KINDS = exports.SCOPE_IMPLIED_REF_KEY = exports.TRIGGER_EVENT_CATALOG = exports.TRIGGER_EVENT_ENTITY_TYPES = exports.TRIGGER_CHAT_AUTH_MODES = exports.TRIGGER_CHAT_RESPONSE_MODES = exports.TRIGGER_CHAT_MODES = exports.TRIGGER_FORM_RESPONSE_MODES = exports.TRIGGER_CONCURRENCY_POLICIES = exports.TRIGGER_EVENT_FILTER_MODES = exports.TRIGGER_EXECUTOR_MODES = exports.TRIGGER_SCOPE_KINDS = exports.TRIGGER_KINDS = void 0;
|
|
4
4
|
exports.validateEventReference = validateEventReference;
|
|
5
5
|
exports.validateEventFilter = validateEventFilter;
|
|
6
6
|
exports.serverEventCatalogIncludes = serverEventCatalogIncludes;
|
|
7
7
|
exports.parseKeyValueFlags = parseKeyValueFlags;
|
|
8
|
+
exports.refEntitiesFromRefFlags = refEntitiesFromRefFlags;
|
|
8
9
|
exports.parseJsonObject = parseJsonObject;
|
|
9
10
|
exports.parseJsonArray = parseJsonArray;
|
|
10
11
|
exports.buildBuiltinActionPayload = buildBuiltinActionPayload;
|
|
@@ -46,16 +47,25 @@ exports.degradedMarker = degradedMarker;
|
|
|
46
47
|
exports.sensorHealthLines = sensorHealthLines;
|
|
47
48
|
exports.renderTriggerList = renderTriggerList;
|
|
48
49
|
exports.formatDuplicateSubscriptionWarning = formatDuplicateSubscriptionWarning;
|
|
50
|
+
exports.windowAuthoringAdvice = windowAuthoringAdvice;
|
|
51
|
+
exports.schedulerLimitSentence = schedulerLimitSentence;
|
|
49
52
|
exports.armedStateLabel = armedStateLabel;
|
|
50
53
|
exports.writeModeLabel = writeModeLabel;
|
|
51
54
|
exports.webhookIngestUrl = webhookIngestUrl;
|
|
52
55
|
exports.toolsRefusedHintLines = toolsRefusedHintLines;
|
|
53
56
|
exports.fireRefusalLines = fireRefusalLines;
|
|
57
|
+
exports.executorModeEffect = executorModeEffect;
|
|
58
|
+
exports.debounceSummaryLine = debounceSummaryLine;
|
|
59
|
+
exports.scheduleSummaryLine = scheduleSummaryLine;
|
|
60
|
+
exports.builtinActionLine = builtinActionLine;
|
|
54
61
|
exports.renderTriggerSummary = renderTriggerSummary;
|
|
55
62
|
exports.renderLegacyRuns = renderLegacyRuns;
|
|
56
|
-
exports.
|
|
63
|
+
exports.clockSkipAuditExplanation = clockSkipAuditExplanation;
|
|
64
|
+
exports.coalescedAuditExplanation = coalescedAuditExplanation;
|
|
65
|
+
exports.policyCardSentence = policyCardSentence;
|
|
57
66
|
exports.policyAuditExplanation = policyAuditExplanation;
|
|
58
67
|
exports.renderFireAudit = renderFireAudit;
|
|
68
|
+
exports.describeTriggerBudget = describeTriggerBudget;
|
|
59
69
|
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
60
70
|
const node_fs_1 = require("node:fs");
|
|
61
71
|
const format_1 = require("./format");
|
|
@@ -382,6 +392,30 @@ function parseKeyValueFlags(values, flagName, scopeKind) {
|
|
|
382
392
|
}
|
|
383
393
|
return refs;
|
|
384
394
|
}
|
|
395
|
+
/**
|
|
396
|
+
* The entity kind a `--ref <key>=<id>` names, for the filter a list takes. `triggers create` takes
|
|
397
|
+
* `--ref agentId=abc`; `triggers list` took only `--ref-entity agent:abc`, so the one spelling that
|
|
398
|
+
* created the trigger was refused by the command that finds it (OSK-22493).
|
|
399
|
+
*/
|
|
400
|
+
const REF_KEY_ENTITY_KIND = {
|
|
401
|
+
agentId: 'agent',
|
|
402
|
+
goalId: 'goal',
|
|
403
|
+
taskId: 'task',
|
|
404
|
+
spaceId: 'space',
|
|
405
|
+
groupChatId: 'groupChat',
|
|
406
|
+
};
|
|
407
|
+
/** `--ref agentId=abc` as the `agent:abc` the list filter takes. Throws for a key that filters nothing. */
|
|
408
|
+
function refEntitiesFromRefFlags(values) {
|
|
409
|
+
const refs = parseKeyValueFlags(values, '--ref');
|
|
410
|
+
return Object.entries(refs).map(([key, id]) => {
|
|
411
|
+
const kind = REF_KEY_ENTITY_KIND[key];
|
|
412
|
+
if (!kind) {
|
|
413
|
+
throw new Error(`--ref ${key}=... cannot filter a list. Use ${Object.keys(REF_KEY_ENTITY_KIND).join(', ')}, ` +
|
|
414
|
+
'or --ref-entity <kind>:<id>.');
|
|
415
|
+
}
|
|
416
|
+
return `${kind}:${id}`;
|
|
417
|
+
});
|
|
418
|
+
}
|
|
385
419
|
function parseJsonObject(raw, flagName) {
|
|
386
420
|
if (raw === undefined)
|
|
387
421
|
return undefined;
|
|
@@ -800,7 +834,15 @@ exports.TRIGGER_CREATE_FIELD_FLAGS = Object.freeze({
|
|
|
800
834
|
'execution.dispatch': '--dispatch',
|
|
801
835
|
'execution.references': '--reference',
|
|
802
836
|
'execution.workingHours': '--working-hours',
|
|
837
|
+
'execution.workingHours.enabled': '--working-hours',
|
|
838
|
+
'execution.workingHours.start': '--working-hours',
|
|
839
|
+
'execution.workingHours.end': '--working-hours',
|
|
840
|
+
'execution.workingHours.timezone': '--working-hours',
|
|
803
841
|
'execution.quietHours': '--quiet-hours',
|
|
842
|
+
'execution.quietHours.enabled': '--quiet-hours',
|
|
843
|
+
'execution.quietHours.start': '--quiet-hours',
|
|
844
|
+
'execution.quietHours.end': '--quiet-hours',
|
|
845
|
+
'execution.quietHours.timezone': '--quiet-hours',
|
|
804
846
|
});
|
|
805
847
|
/**
|
|
806
848
|
* Flags an execution mode cannot work without, refused before the request is sent. The inverse
|
|
@@ -1125,6 +1167,10 @@ function armedLabel(trigger) {
|
|
|
1125
1167
|
if (trigger.kind === 'once' && trigger.once && trigger.once.firedAt) {
|
|
1126
1168
|
return 'spent';
|
|
1127
1169
|
}
|
|
1170
|
+
// Enabled and synced, but the scheduler has used the run limit it was given: it drops every slot
|
|
1171
|
+
// (OSK-22526). Only a read that asked for the limits can say so; absent is unknown, not fine.
|
|
1172
|
+
if (trigger.schedulerLimits?.state === 'reached')
|
|
1173
|
+
return 'limit';
|
|
1128
1174
|
return 'yes';
|
|
1129
1175
|
}
|
|
1130
1176
|
/**
|
|
@@ -1194,7 +1240,7 @@ function renderTriggerList(triggers, log) {
|
|
|
1194
1240
|
{ key: 'enabled', header: 'ARMED' },
|
|
1195
1241
|
{ key: 'scope', header: 'SCOPE', maxWidth: 42 },
|
|
1196
1242
|
{ key: 'next', header: 'NEXT/LAST', maxWidth: 24 },
|
|
1197
|
-
{ key: 'label', header: 'LABEL', maxWidth:
|
|
1243
|
+
{ key: 'label', header: 'LABEL', maxWidth: 40, truncate: 'middle' },
|
|
1198
1244
|
], log);
|
|
1199
1245
|
const degraded = triggers.filter((t) => degradedMarker(t) === ' (degraded)');
|
|
1200
1246
|
if (degraded.length > 0) {
|
|
@@ -1246,6 +1292,42 @@ function formatDuplicateSubscriptionWarning(trigger) {
|
|
|
1246
1292
|
lines,
|
|
1247
1293
|
};
|
|
1248
1294
|
}
|
|
1295
|
+
/** The `warnings[]` codes a create or update answers about a working / quiet window it just saved. */
|
|
1296
|
+
const WINDOW_ADVICE_CODES = new Set(['window_timezone_defaulted', 'quiet_window_empty']);
|
|
1297
|
+
/**
|
|
1298
|
+
* Advice about a window the trigger was just saved with, one sentence each, or none. The window was
|
|
1299
|
+
* accepted; these say how it will be read (in UTC when it names no zone, as an empty quiet window that
|
|
1300
|
+
* suppresses nothing), so a person finds out now and not from the first skipped fire (OSK-22530).
|
|
1301
|
+
*/
|
|
1302
|
+
function windowAuthoringAdvice(trigger) {
|
|
1303
|
+
const warnings = trigger?.warnings;
|
|
1304
|
+
if (!Array.isArray(warnings))
|
|
1305
|
+
return [];
|
|
1306
|
+
return warnings.flatMap((warning) => {
|
|
1307
|
+
const { code, message } = (warning ?? {});
|
|
1308
|
+
return typeof code === 'string' && WINDOW_ADVICE_CODES.has(code) && typeof message === 'string'
|
|
1309
|
+
? [message]
|
|
1310
|
+
: [];
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
/** What `--working-hours` / `--quiet-hours` take, for their `--help`. */
|
|
1314
|
+
exports.TRIGGER_WINDOW_FLAG_HELP = 'JSON object {"enabled":true,"start":"09:00","end":"17:00","timezone":"America/Vancouver"}. "enabled" is required for the window to apply, and with no "timezone" it is read in UTC, not in the trigger\'s own zone.';
|
|
1315
|
+
/**
|
|
1316
|
+
* Why a schedule whose own counters look healthy will not run, in the scheduler's numbers. The
|
|
1317
|
+
* scheduler charges a limit when it claims a slot, so it can hold more than the trigger counts; once
|
|
1318
|
+
* the limit is reached it drops every later slot without running or recording it (OSK-22526).
|
|
1319
|
+
*/
|
|
1320
|
+
function schedulerLimitSentence(limits) {
|
|
1321
|
+
const lifetime = limits.reason === 'max_runs_reached';
|
|
1322
|
+
const used = lifetime
|
|
1323
|
+
? `${limits.claimedTotal ?? '?'} of ${limits.maxRuns ?? '?'} runs (--max-runs)`
|
|
1324
|
+
: `${limits.claimedToday ?? '?'} of ${limits.maxPerDay ?? '?'} runs today (--max-fires-per-day)`;
|
|
1325
|
+
const counted = lifetime
|
|
1326
|
+
? `${limits.triggerFireCount ?? 0} succeeded`
|
|
1327
|
+
: `${limits.triggerFiresToday ?? 0} counted today`;
|
|
1328
|
+
return (`the scheduler has used ${used} (the trigger itself has ${counted}), so it skips every slot` +
|
|
1329
|
+
`${lifetime ? '' : ' until the day rolls over'}; see \`skrr triggers preflight\``);
|
|
1330
|
+
}
|
|
1249
1331
|
/**
|
|
1250
1332
|
* Human phrasing for a trigger's enabled state (OSK-4886).
|
|
1251
1333
|
*
|
|
@@ -1255,7 +1337,9 @@ function formatDuplicateSubscriptionWarning(trigger) {
|
|
|
1255
1337
|
*/
|
|
1256
1338
|
function armedStateLabel(enabled, lastResult,
|
|
1257
1339
|
/** Pass for a `once` trigger: how often its single fire ran. A spent one-shot is not waiting to be enabled (OSK-21509). */
|
|
1258
|
-
oneShot
|
|
1340
|
+
oneShot,
|
|
1341
|
+
/** The server's reading of the scheduler's run limits: a reached limit means no slot will run (OSK-22526). */
|
|
1342
|
+
schedulerLimits) {
|
|
1259
1343
|
if (enabled === false && oneShot && (oneShot.fires ?? 0) > 0) {
|
|
1260
1344
|
return 'no — already fired (a one-shot trigger is spent once it fires)';
|
|
1261
1345
|
}
|
|
@@ -1264,6 +1348,8 @@ oneShot) {
|
|
|
1264
1348
|
}
|
|
1265
1349
|
if (enabled === false)
|
|
1266
1350
|
return 'no — inert until enabled';
|
|
1351
|
+
if (schedulerLimits?.state === 'reached')
|
|
1352
|
+
return `no — ${schedulerLimitSentence(schedulerLimits)}`;
|
|
1267
1353
|
// "Will fire" is the row's intent. A platform-managed row whose owner is fenced (Always-On off) ticks on
|
|
1268
1354
|
// schedule and is skipped every time, and the same screen's `Fires:` line says so; the first line a reader
|
|
1269
1355
|
// meets must not say the opposite (dogfood df-261031-commitment-authoring, OSK-21103).
|
|
@@ -1365,12 +1451,147 @@ function fireRefusalLines(metadata) {
|
|
|
1365
1451
|
}
|
|
1366
1452
|
return lines;
|
|
1367
1453
|
}
|
|
1454
|
+
/**
|
|
1455
|
+
* What an executor mode DOES, in words. The name alone said nothing about side effects: `run_only`
|
|
1456
|
+
* read as if it ran nothing, so a person testing a disabled sensor trigger could not tell that firing
|
|
1457
|
+
* it starts an Agent turn (OSK-21766). Only the modes an author normally chooses are described; an
|
|
1458
|
+
* unlisted mode simply has no effect line rather than a guess.
|
|
1459
|
+
*/
|
|
1460
|
+
const EXECUTOR_MODE_EFFECTS = {
|
|
1461
|
+
send_message: 'runs an Agent turn and posts its reply to the destination chat',
|
|
1462
|
+
run_only: 'runs an Agent turn and posts nothing visible; it still uses the Agent’s model budget',
|
|
1463
|
+
builtin_action: 'runs a deterministic action with no Agent turn and no model cost; the Action line says which (types: `skrr triggers actions`)',
|
|
1464
|
+
};
|
|
1465
|
+
/** The `--mode` flag's help, shared so create and update never describe the modes differently. */
|
|
1466
|
+
exports.TRIGGER_MODE_FLAG_DESCRIPTION = 'Execution mode. send_message runs an Agent turn and posts its reply to the destination chat; run_only runs an Agent turn and posts nothing visible (it still uses the Agent’s model budget).';
|
|
1467
|
+
function executorModeEffect(mode) {
|
|
1468
|
+
return typeof mode === 'string' ? EXECUTOR_MODE_EFFECTS[mode] : undefined;
|
|
1469
|
+
}
|
|
1470
|
+
/** `30s`, `2m` — the window, short enough to sit in a one-line summary. */
|
|
1471
|
+
function debounceSpan(ms) {
|
|
1472
|
+
const seconds = Math.round(ms / 1000);
|
|
1473
|
+
if (seconds >= 60 && seconds % 60 === 0)
|
|
1474
|
+
return `${seconds / 60}m`;
|
|
1475
|
+
return `${seconds}s`;
|
|
1476
|
+
}
|
|
1477
|
+
/**
|
|
1478
|
+
* The text of the `Debounce:` line of `triggers show`. An event trigger carries a trigger-wide debounce (30s unless
|
|
1479
|
+
* set), and neither its size nor its meaning was shown anywhere but raw JSON: a person deciding whether
|
|
1480
|
+
* two close events both fire could not tell that the second is skipped, not queued, whatever its
|
|
1481
|
+
* subject (OSK-21756). Undefined when there is nothing to say.
|
|
1482
|
+
*/
|
|
1483
|
+
function debounceSummaryLine(trigger) {
|
|
1484
|
+
if (trigger.kind !== 'event')
|
|
1485
|
+
return undefined;
|
|
1486
|
+
// A Commitment wake coalesces in the wake ledger; TriggerEngine never debounces those fires.
|
|
1487
|
+
if (trigger.scope?.kind === 'commitment_watcher' || trigger.execution?.mode === 'commitment_reflection') {
|
|
1488
|
+
return undefined;
|
|
1489
|
+
}
|
|
1490
|
+
const ms = trigger.event?.debounceMs;
|
|
1491
|
+
if (typeof ms !== 'number' || !Number.isFinite(ms) || ms <= 0) {
|
|
1492
|
+
return 'none — every matching event can fire';
|
|
1493
|
+
}
|
|
1494
|
+
return `${debounceSpan(ms)}, trigger-wide — a matching event within ${debounceSpan(ms)} of the last fire is skipped, not queued`;
|
|
1495
|
+
}
|
|
1496
|
+
/** The machine's own IANA zone, or undefined where the runtime cannot say. */
|
|
1497
|
+
function machineTimeZone() {
|
|
1498
|
+
try {
|
|
1499
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone || undefined;
|
|
1500
|
+
}
|
|
1501
|
+
catch {
|
|
1502
|
+
return undefined;
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
/** `01:30 PST`: the wall clock of an instant in a zone, or undefined for a zone this runtime does not know. */
|
|
1506
|
+
function clockInZone(iso, timeZone) {
|
|
1507
|
+
const date = new Date(iso);
|
|
1508
|
+
if (Number.isNaN(date.getTime()))
|
|
1509
|
+
return undefined;
|
|
1510
|
+
try {
|
|
1511
|
+
return new Intl.DateTimeFormat('en-US', {
|
|
1512
|
+
timeZone,
|
|
1513
|
+
hour: '2-digit',
|
|
1514
|
+
minute: '2-digit',
|
|
1515
|
+
hourCycle: 'h23',
|
|
1516
|
+
timeZoneName: 'short',
|
|
1517
|
+
}).format(date);
|
|
1518
|
+
}
|
|
1519
|
+
catch {
|
|
1520
|
+
return undefined;
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
/**
|
|
1524
|
+
* When a schedule or one-shot trigger runs, in the zone it runs in (OSK-22487).
|
|
1525
|
+
*
|
|
1526
|
+
* `triggers create` and `triggers show` printed the kind, the mode and `Fires: 0 succeeded` and nothing
|
|
1527
|
+
* about WHEN, so a schedule made without `--timezone` (which stores UTC) looked the same as one made
|
|
1528
|
+
* for the person's own morning, eight hours apart. The zone is stated always, and the same instant is
|
|
1529
|
+
* restated on this machine's clock when the two differ, so "09:30" cannot be mistaken for local time.
|
|
1530
|
+
* A disabled trigger's next occurrence is labelled as conditional: nothing will run until it is enabled.
|
|
1531
|
+
*
|
|
1532
|
+
* Undefined for a kind with no clock (event, on_demand, ...). `machineZone` is a parameter so the text
|
|
1533
|
+
* is deterministic under test.
|
|
1534
|
+
*/
|
|
1535
|
+
function scheduleSummaryLine(trigger, machineZone = machineTimeZone()) {
|
|
1536
|
+
let cadence;
|
|
1537
|
+
let nextIso;
|
|
1538
|
+
let zone = 'UTC';
|
|
1539
|
+
if (trigger.kind === 'schedule') {
|
|
1540
|
+
const schedule = (trigger.schedule ?? {});
|
|
1541
|
+
if (typeof schedule.timezone === 'string' && schedule.timezone)
|
|
1542
|
+
zone = schedule.timezone;
|
|
1543
|
+
if (Array.isArray(schedule.times) && schedule.times.length > 0) {
|
|
1544
|
+
cadence = `daily at ${schedule.times.join(', ')} ${zone}`;
|
|
1545
|
+
}
|
|
1546
|
+
else if (typeof schedule.cronExpression === 'string' && schedule.cronExpression) {
|
|
1547
|
+
cadence = `cron "${schedule.cronExpression}" in ${zone}`;
|
|
1548
|
+
}
|
|
1549
|
+
else if (typeof schedule.intervalMs === 'number' && schedule.intervalMs > 0) {
|
|
1550
|
+
const minutes = Math.round(schedule.intervalMs / 60_000);
|
|
1551
|
+
cadence = `every ${minutes === 1 ? 'minute' : `${minutes} minutes`}`;
|
|
1552
|
+
}
|
|
1553
|
+
if (schedule.nextRunAt)
|
|
1554
|
+
nextIso = String(schedule.nextRunAt);
|
|
1555
|
+
}
|
|
1556
|
+
else if (trigger.kind === 'once') {
|
|
1557
|
+
const once = (trigger.once ?? {});
|
|
1558
|
+
const runAt = once.runAt ?? once.at;
|
|
1559
|
+
if (runAt) {
|
|
1560
|
+
nextIso = String(runAt);
|
|
1561
|
+
cadence = 'one-time run';
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
if (!cadence)
|
|
1565
|
+
return undefined;
|
|
1566
|
+
// An interval has no wall-clock time to be mistaken for local time.
|
|
1567
|
+
const hasClock = !cadence.startsWith('every ');
|
|
1568
|
+
const parts = [cadence];
|
|
1569
|
+
if (nextIso) {
|
|
1570
|
+
const there = hasClock && machineZone && machineZone !== zone ? clockInZone(nextIso, machineZone) : undefined;
|
|
1571
|
+
const when = trigger.enabled === false ? `next ${nextIso} if enabled` : `next ${nextIso}`;
|
|
1572
|
+
parts.push(there ? `${when} (${there} on this machine)` : when);
|
|
1573
|
+
}
|
|
1574
|
+
return parts.join('; ');
|
|
1575
|
+
}
|
|
1576
|
+
/** What a builtin_action trigger does, from its stored action: the type and its config. */
|
|
1577
|
+
function builtinActionLine(trigger) {
|
|
1578
|
+
if (trigger.execution?.mode !== 'builtin_action')
|
|
1579
|
+
return undefined;
|
|
1580
|
+
const action = trigger.execution.builtinAction;
|
|
1581
|
+
if (typeof action?.builtinType !== 'string')
|
|
1582
|
+
return undefined;
|
|
1583
|
+
const config = action.config && typeof action.config === 'object' && Object.keys(action.config).length > 0
|
|
1584
|
+
? JSON.stringify(action.config)
|
|
1585
|
+
: '';
|
|
1586
|
+
const shown = config.length > 160 ? `${config.slice(0, 160)}…` : config;
|
|
1587
|
+
return `${action.builtinType}${shown ? ` ${shown}` : ''}`;
|
|
1588
|
+
}
|
|
1368
1589
|
function renderTriggerSummary(trigger, log, options = {}) {
|
|
1369
1590
|
log(`ID: ${trigger.id ?? '-'}`);
|
|
1370
1591
|
log(`Kind: ${trigger.kind ?? '-'}`);
|
|
1371
1592
|
log(`Armed: ${armedStateLabel(trigger.enabled, trigger.audit?.lastResult, trigger.kind === 'once'
|
|
1372
1593
|
? { fires: trigger.audit?.fireCount, failures: trigger.audit?.failureCount }
|
|
1373
|
-
: undefined)}`);
|
|
1594
|
+
: undefined, trigger.schedulerLimits)}`);
|
|
1374
1595
|
log(`Scope: ${scopeLabel(trigger)}`);
|
|
1375
1596
|
/*
|
|
1376
1597
|
* Say when the row is not yours to change.
|
|
@@ -1396,6 +1617,18 @@ function renderTriggerSummary(trigger, log, options = {}) {
|
|
|
1396
1617
|
log(`Label: ${trigger.label}`);
|
|
1397
1618
|
if (trigger.execution?.mode)
|
|
1398
1619
|
log(`Mode: ${String(trigger.execution.mode)}`);
|
|
1620
|
+
const modeEffect = executorModeEffect(trigger.execution?.mode);
|
|
1621
|
+
if (modeEffect)
|
|
1622
|
+
log(`Effect: ${modeEffect}`);
|
|
1623
|
+
const action = builtinActionLine(trigger);
|
|
1624
|
+
if (action)
|
|
1625
|
+
log(`Action: ${action}`);
|
|
1626
|
+
const schedule = scheduleSummaryLine(trigger);
|
|
1627
|
+
if (schedule)
|
|
1628
|
+
log(`Schedule: ${schedule}`);
|
|
1629
|
+
const debounceText = debounceSummaryLine(trigger);
|
|
1630
|
+
if (debounceText)
|
|
1631
|
+
log(`Debounce: ${debounceText}`);
|
|
1399
1632
|
const sensor = trigger.execution?.mode === 'sensor_poll' ? trigger.execution.sensor : undefined;
|
|
1400
1633
|
if (sensor?.measureSink) {
|
|
1401
1634
|
log(`Measure: ${sensor.measureSink.measureId} — platform fetched, unconfirmed`);
|
|
@@ -1451,7 +1684,10 @@ function renderTriggerSummary(trigger, log, options = {}) {
|
|
|
1451
1684
|
if (next !== '-') {
|
|
1452
1685
|
// `nextRunLabel` falls back to the last fire when nothing is scheduled; say which it is.
|
|
1453
1686
|
const upcoming = Boolean(scheduledRunAt(trigger));
|
|
1454
|
-
|
|
1687
|
+
// A slot the scheduler will drop is not a run to wait for (OSK-22526).
|
|
1688
|
+
const dropped = upcoming && trigger.schedulerLimits?.state === 'reached';
|
|
1689
|
+
log(`${upcoming ? (dropped ? 'Next slot:' : 'Next run:') : 'Last run:'}${next.length > 0 ? ` ${next}` : ''}` +
|
|
1690
|
+
`${dropped ? ' (will be skipped: the scheduler\'s run limit is reached)' : ''}`);
|
|
1455
1691
|
}
|
|
1456
1692
|
/*
|
|
1457
1693
|
* What actually happened when it fired.
|
|
@@ -1526,28 +1762,131 @@ function renderLegacyRuns(runs, log) {
|
|
|
1526
1762
|
{ key: 'conversation', header: 'CONVO', maxWidth: 24 },
|
|
1527
1763
|
], log);
|
|
1528
1764
|
}
|
|
1529
|
-
/**
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1765
|
+
/**
|
|
1766
|
+
* What a window-skipped fire's record says about the window, as one clause, or null when the record
|
|
1767
|
+
* kept none (it predates the field, or the platform scheduler recorded the skip).
|
|
1768
|
+
*/
|
|
1769
|
+
function skippedWindowClause(window, kind) {
|
|
1770
|
+
if (!window || window.kind !== kind || !window.start || !window.end)
|
|
1533
1771
|
return null;
|
|
1534
|
-
|
|
1772
|
+
const zone = window.timezone || 'UTC';
|
|
1773
|
+
const label = kind === 'working_hours' ? 'working hours' : 'quiet hours';
|
|
1774
|
+
const judged = window.localTime
|
|
1775
|
+
? `It was judged at ${window.localTime} ${zone}`
|
|
1776
|
+
: `It was judged at ${window.evaluatedAt ?? 'the time it came due'}`;
|
|
1777
|
+
const relation = kind === 'working_hours' ? 'outside' : 'inside';
|
|
1778
|
+
const defaulted = window.timezoneDefaulted
|
|
1779
|
+
? ' The window sets no timezone, so it is read in UTC.'
|
|
1780
|
+
: '';
|
|
1781
|
+
return `${judged}, ${relation} the trigger's ${label} ${window.start}-${window.end} ${zone}.${defaulted}`;
|
|
1782
|
+
}
|
|
1783
|
+
/**
|
|
1784
|
+
* Why a fire was skipped by a working or quiet window, in words. Both trigger-level windows (Gate 5)
|
|
1785
|
+
* consume the occurrence: a one-shot is spent, a recurring schedule carries on to its next slot, and
|
|
1786
|
+
* nothing is retried. The Agent's own quiet hours (`initiative_policy_quiet_hours`) are a separate
|
|
1787
|
+
* policy that can hold a one-shot, so that wording stays hedged.
|
|
1788
|
+
*/
|
|
1789
|
+
function clockSkipAuditExplanation(fire) {
|
|
1790
|
+
const reason = fire.reason || fire.outcome;
|
|
1791
|
+
if (reason === 'initiative_policy_quiet_hours') {
|
|
1792
|
+
if (fire.source === 'once') {
|
|
1793
|
+
return {
|
|
1794
|
+
summary: 'One-shot skipped: quiet hours',
|
|
1795
|
+
detail: 'This skipped occurrence will not retry automatically. Check the trigger state; if the one-shot is spent, schedule a new one outside quiet hours.',
|
|
1796
|
+
};
|
|
1797
|
+
}
|
|
1535
1798
|
return {
|
|
1536
|
-
summary: '
|
|
1537
|
-
detail: '
|
|
1799
|
+
summary: 'Skipped: Agent quiet hours',
|
|
1800
|
+
detail: 'The Agent quiet hours covered this occurrence, so it did not run. It is not retried; a recurring schedule carries on to its next slot.',
|
|
1538
1801
|
};
|
|
1539
1802
|
}
|
|
1803
|
+
if (reason !== 'outside_working_hours' && reason !== 'inside_quiet_hours')
|
|
1804
|
+
return null;
|
|
1805
|
+
const working = reason === 'outside_working_hours';
|
|
1806
|
+
const kind = working ? 'working_hours' : 'quiet_hours';
|
|
1807
|
+
const oneShot = fire.source === 'once';
|
|
1808
|
+
const recurring = fire.source === 'schedule';
|
|
1809
|
+
const record = fire.metadata?.window;
|
|
1810
|
+
const window = skippedWindowClause(record, kind) ??
|
|
1811
|
+
`This occurrence landed ${working ? 'outside the working hours' : 'inside the quiet hours'} set on this trigger. The record did not keep the window; \`skrr triggers show <id> --json\` shows what it is now.`;
|
|
1812
|
+
const outcome = oneShot
|
|
1813
|
+
? `A one-shot has a single occurrence, so it is spent and will not retry. To run it, create a new one ${working ? 'inside the working hours' : 'outside the quiet hours'}.`
|
|
1814
|
+
: recurring
|
|
1815
|
+
? 'The schedule does not retry this slot; it carries on, and its next occurrence is checked against the window again.'
|
|
1816
|
+
: 'It was dropped, not queued, and will not retry automatically.';
|
|
1817
|
+
return {
|
|
1818
|
+
summary: `${oneShot ? 'One-shot skipped' : 'Skipped'}: ${working ? 'outside working hours' : 'quiet hours'}`,
|
|
1819
|
+
detail: `${window} ${outcome}`,
|
|
1820
|
+
};
|
|
1821
|
+
}
|
|
1822
|
+
/**
|
|
1823
|
+
* Why a coalesced occurrence did not run. `coalesced` with reason `in_flight` is the concurrency lane
|
|
1824
|
+
* (gate 7) finding an earlier fire still holding it: this occurrence was dropped, not queued, and an
|
|
1825
|
+
* occurrence that was dropped is consumed, so it is not retried (OSK-22509). The raw code alone read
|
|
1826
|
+
* as a fire that was still in progress.
|
|
1827
|
+
*/
|
|
1828
|
+
function coalescedAuditExplanation(fire) {
|
|
1829
|
+
if (fire.outcome !== 'coalesced')
|
|
1830
|
+
return null;
|
|
1540
1831
|
return {
|
|
1541
|
-
summary: '
|
|
1542
|
-
detail: '
|
|
1832
|
+
summary: 'Not run: lane already busy',
|
|
1833
|
+
detail: 'An earlier fire under the same concurrency lane was still running when this occurrence came due, so it was dropped, not queued, and will not retry automatically. `skrr triggers preflight <id> --json` shows the lane (concurrencyKey); a trigger that stores no key coalesces only against itself.',
|
|
1543
1834
|
};
|
|
1544
1835
|
}
|
|
1836
|
+
/** Why no new inbox card was written, by the code the server records. Unknown codes are shown as they are. */
|
|
1837
|
+
const POLICY_CARD_REASONS = {
|
|
1838
|
+
policy_mode_has_no_card: 'this autonomy mode does not make inbox suggestions',
|
|
1839
|
+
scope_not_agent: 'the trigger is not scoped to an Agent',
|
|
1840
|
+
agent_unresolved: 'the trigger names no Agent',
|
|
1841
|
+
creation_error: 'creating it failed',
|
|
1842
|
+
card_not_visible: 'it was saved but cannot be shown to its owner',
|
|
1843
|
+
not_recorded: 'the suggestion service did not say why',
|
|
1844
|
+
relevance_gate: 'the relevance check judged it not worth surfacing',
|
|
1845
|
+
payload_gate: 'it carried nothing to act on',
|
|
1846
|
+
dedupe: 'this occurrence already has one',
|
|
1847
|
+
initiative_policy_cooldown: 'an earlier suggestion from this trigger is still open',
|
|
1848
|
+
initiative_policy_source_cooldown: 'an earlier suggestion from this source is still open',
|
|
1849
|
+
initiative_policy_channel_cooldown: 'an earlier suggestion from this channel is still open',
|
|
1850
|
+
initiative_policy_cross_worker_duplicate: 'another Agent already raised the same thing',
|
|
1851
|
+
initiative_policy_hard_stop: 'the Agent hard stop is on',
|
|
1852
|
+
initiative_policy_off: 'the Agent initiative policy is off',
|
|
1853
|
+
initiative_policy_quiet_hours: 'it landed inside the Agent quiet hours',
|
|
1854
|
+
initiative_policy_outside_working_hours: 'it landed outside the Agent working hours',
|
|
1855
|
+
initiative_policy_daily_card_cap: 'the Agent daily limit on inbox suggestions was reached',
|
|
1856
|
+
initiative_policy_source_daily_card_cap: 'the daily limit for this source was reached',
|
|
1857
|
+
initiative_policy_channel_daily_card_cap: 'the daily limit for this channel was reached',
|
|
1858
|
+
initiative_policy_suppressed: 'a suppression rule on the Agent matches it',
|
|
1859
|
+
initiative_policy_dismiss_cooldown: 'a similar suggestion was dismissed recently',
|
|
1860
|
+
initiative_policy_source_off: 'this source is switched off for the Agent',
|
|
1861
|
+
initiative_policy_channel_off: 'this channel is switched off for the Agent',
|
|
1862
|
+
};
|
|
1863
|
+
/** One sentence saying whether the fire left an inbox card, or null for a fire that predates the record. */
|
|
1864
|
+
function policyCardSentence(policyCard) {
|
|
1865
|
+
if (!policyCard || typeof policyCard !== 'object' || Array.isArray(policyCard))
|
|
1866
|
+
return null;
|
|
1867
|
+
const card = policyCard;
|
|
1868
|
+
const id = typeof card.initiativeId === 'string' && card.initiativeId ? ` (${card.initiativeId})` : '';
|
|
1869
|
+
if (card.created === true)
|
|
1870
|
+
return `An inbox suggestion was created${id}.`;
|
|
1871
|
+
const why = typeof card.reason === 'string' && card.reason
|
|
1872
|
+
? (POLICY_CARD_REASONS[card.reason] ?? card.reason)
|
|
1873
|
+
: null;
|
|
1874
|
+
if (card.existing === true) {
|
|
1875
|
+
return `No new inbox suggestion: an earlier one${id} covers this${why ? ` (${why})` : ''}.`;
|
|
1876
|
+
}
|
|
1877
|
+
if (card.created === false)
|
|
1878
|
+
return `No inbox suggestion was created${why ? `: ${why}` : ''}.`;
|
|
1879
|
+
return null;
|
|
1880
|
+
}
|
|
1545
1881
|
function policyAuditExplanation(fire) {
|
|
1546
1882
|
if (fire.outcome !== 'skipped' || fire.reason !== 'initiative_policy_suggestions_only')
|
|
1547
1883
|
return null;
|
|
1884
|
+
const metadata = fire.metadata;
|
|
1885
|
+
// A fire from before the server recorded the card cannot say; the old hedge stays for those.
|
|
1886
|
+
const card = policyCardSentence(metadata?.policyCard) ?? 'An inbox suggestion is not guaranteed.';
|
|
1548
1887
|
return {
|
|
1549
1888
|
summary: 'Skipped: suggestions-only policy',
|
|
1550
|
-
detail:
|
|
1889
|
+
detail: `The Agent policy prevented autonomous execution. Review the trigger preflight and Agent policy. ${card}`,
|
|
1551
1890
|
};
|
|
1552
1891
|
}
|
|
1553
1892
|
function renderFireAudit(fires, log) {
|
|
@@ -1562,7 +1901,7 @@ function renderFireAudit(fires, log) {
|
|
|
1562
1901
|
source: fire.source ?? '-',
|
|
1563
1902
|
reason: fire.metadata?.recordKind === 'schedule_end_marker'
|
|
1564
1903
|
? 'Schedule ended after prior fire'
|
|
1565
|
-
:
|
|
1904
|
+
: clockSkipAuditExplanation(fire)?.summary ?? policyAuditExplanation(fire)?.summary ?? coalescedAuditExplanation(fire)?.summary ?? fire.reason ?? fire.errorMessage ?? '',
|
|
1566
1905
|
duration: fire.durationMs === undefined ? '-' : `${fire.durationMs}ms`,
|
|
1567
1906
|
replay: fire.metadata?.replayable === true || fire.metadata?.replayContext
|
|
1568
1907
|
? 'yes'
|
|
@@ -1579,6 +1918,20 @@ function renderFireAudit(fires, log) {
|
|
|
1579
1918
|
{ key: 'reason', header: 'REASON', maxWidth: 40 },
|
|
1580
1919
|
], log);
|
|
1581
1920
|
}
|
|
1921
|
+
/**
|
|
1922
|
+
* The largest finite trigger limit the server accepts. An owner with no cap of
|
|
1923
|
+
* their own resolves to exactly this, so a limit at or above it means "no limit"
|
|
1924
|
+
* and printing it as a number reads as a budget (OSK-22402). A server new enough
|
|
1925
|
+
* to say `unlimited` is believed; an older one is judged by the value.
|
|
1926
|
+
*/
|
|
1927
|
+
exports.TRIGGER_LIMIT_CEILING = 100_000_000;
|
|
1928
|
+
/** `used / limit (free free)`, or `used / unlimited` when there is no cap. */
|
|
1929
|
+
function describeTriggerBudget(budget) {
|
|
1930
|
+
const unlimited = budget.unlimited ?? budget.limit >= exports.TRIGGER_LIMIT_CEILING;
|
|
1931
|
+
return unlimited
|
|
1932
|
+
? `${budget.used} / unlimited`
|
|
1933
|
+
: `${budget.used} / ${budget.limit} (${budget.free} free)`;
|
|
1934
|
+
}
|
|
1582
1935
|
exports.triggerApi = {
|
|
1583
1936
|
create: (body) => data_provider_1.request.post('/api/triggers', body),
|
|
1584
1937
|
list: (path) => data_provider_1.request.get(path),
|
|
@@ -16,6 +16,14 @@ function nodeCancellationFromSnapshot(spaceId, runId, nodeKey, snapshot, reason)
|
|
|
16
16
|
throw new Error('Use a saved canonical run snapshot for this exact Space and workflow run.');
|
|
17
17
|
}
|
|
18
18
|
const selected = snapshot.nodes.filter((node) => record(node) && node.nodeKey === nodeKey);
|
|
19
|
+
// A mistyped node key used to surface as "must contain one exact node attempt", which blames
|
|
20
|
+
// the file the user just saved (OSK-22460). Say the key is not in it, and which keys are.
|
|
21
|
+
if (selected.length === 0) {
|
|
22
|
+
const keys = snapshot.nodes
|
|
23
|
+
.filter((node) => record(node) && typeof node.nodeKey === 'string')
|
|
24
|
+
.map((node) => String(node.nodeKey));
|
|
25
|
+
throw new Error(`Node "${nodeKey}" is not in this run snapshot.${keys.length ? ` Its nodes are: ${keys.join(', ')}.` : ''}`);
|
|
26
|
+
}
|
|
19
27
|
const node = selected[0];
|
|
20
28
|
if (selected.length !== 1 || !record(node) || !id(node.id) || node.workflowRunId !== runId
|
|
21
29
|
|| !integer(node.iteration) || !integer(node.planGeneration) || !id(node.nodeType)) {
|
|
@@ -61,6 +61,15 @@ function describeNodeDetail(node, attention = '') {
|
|
|
61
61
|
const loop = describeLoopProgress(node);
|
|
62
62
|
if (loop)
|
|
63
63
|
parts.push(loop);
|
|
64
|
+
// The text view left a skipped step and a condition's chosen branch blank, so a run that ended
|
|
65
|
+
// `succeeded` with half its graph unrun looked unexplained; only --json said why (OSK-22461).
|
|
66
|
+
const extra = node;
|
|
67
|
+
if (node.status === 'skipped' && typeof extra.output?.reason === 'string') {
|
|
68
|
+
parts.push(`skipped: ${extra.output.reason.replace(/_/g, ' ')}`);
|
|
69
|
+
}
|
|
70
|
+
if (extra.nodeType === 'condition' && node.status === 'succeeded' && typeof extra.outcome === 'string') {
|
|
71
|
+
parts.push(`took "${extra.outcome}"`);
|
|
72
|
+
}
|
|
64
73
|
return printable(parts.join('; '));
|
|
65
74
|
}
|
|
66
75
|
/**
|
|
@@ -13,7 +13,7 @@ export { decodeJwtExpiry, decodeJwtPayload } from './jwtUtils.js';
|
|
|
13
13
|
export { isAuthExpiredSseEvent, handleMidStreamAuthExpiry, type ParsedSseLike, type AuthExpiredCallbacks, type HandleMidStreamAuthExpiryResult, } from './authExpiredDetector.js';
|
|
14
14
|
export { formatReauthMessage, reauthCommand, EXIT_NEEDS_REAUTH, type AuthFailureReason, } from './messages.js';
|
|
15
15
|
export { classifyRefreshResponse, type RefreshResponseShape, type ClassifiedRefreshResult, type ClassifiedRefreshSuccess, type ClassifiedRefreshFailure, } from './refreshClassification.js';
|
|
16
|
-
export { refreshDaemonToken, revokeDaemonRefreshSession, withAuthLock, persistReauthState, needsReauthState, clearReauthState, installLockExitHandlers, __refreshDiagnostics, __resetUnknown401StreaksForTest, UNKNOWN_401_BUDGET, } from './refresh.js';
|
|
16
|
+
export { refreshDaemonToken, revokeDaemonRefreshSession, revokeDaemonRefreshSessionReported, type RefreshRevokeResult, withAuthLock, persistReauthState, needsReauthState, clearReauthState, installLockExitHandlers, __refreshDiagnostics, __resetUnknown401StreaksForTest, UNKNOWN_401_BUDGET, } from './refresh.js';
|
|
17
17
|
export { createRefreshScheduler, type RefreshScheduler, type RefreshSchedulerOptions, } from './refreshScheduler.js';
|
|
18
18
|
export { readAuthFromFd, __setFdReaderForTest, type FdAuthPayload } from './fdToken.js';
|
|
19
19
|
export { CredentialResolver, CREDENTIAL_PRECEDENCE, __resetCredentialResolverForTest, invalidateAuthHelperCache, classifyTokenKind, CI_TOKEN_PREFIX, PERSONAL_ACCESS_TOKEN_PREFIX, isStaticTokenKind, AuthHelperUntrustedError, AuthHelperUnavailableError, type CredentialSource, type CredentialStoreMode, type CredentialResolverOptions, type ResolvedCredential, type TokenKind, type HelperTrustDecision, type AuthHelperBlockedInfo, type AuthHelperSentinelInfo, } from './credentialResolver.js';
|
|
@@ -329,6 +329,7 @@ __export(index_exports, {
|
|
|
329
329
|
resolveProfileStateFile: () => import_profileStateDir.resolveProfileStateFile,
|
|
330
330
|
rethrowIfLiveStateRefusal: () => import_liveState.rethrowIfLiveStateRefusal,
|
|
331
331
|
revokeDaemonRefreshSession: () => import_refresh.revokeDaemonRefreshSession,
|
|
332
|
+
revokeDaemonRefreshSessionReported: () => import_refresh.revokeDaemonRefreshSessionReported,
|
|
332
333
|
runHeadersHelper: () => import_headers_helper.runHeadersHelper,
|
|
333
334
|
safeEqual: () => import_pkce.safeEqual,
|
|
334
335
|
sanitizeSpawnEnv: () => import_spawnEnv.sanitizeSpawnEnv,
|
|
@@ -725,6 +726,7 @@ var import_independentMachineReservation = require("./independentMachineReservat
|
|
|
725
726
|
resolveProfileStateFile,
|
|
726
727
|
rethrowIfLiveStateRefusal,
|
|
727
728
|
revokeDaemonRefreshSession,
|
|
729
|
+
revokeDaemonRefreshSessionReported,
|
|
728
730
|
runHeadersHelper,
|
|
729
731
|
safeEqual,
|
|
730
732
|
sanitizeSpawnEnv,
|
|
@@ -270,6 +270,28 @@ export declare function refreshDaemonToken(serverUrl: string, currentRefreshToke
|
|
|
270
270
|
* replay attempt while keeping back-compat with un-upgraded servers.
|
|
271
271
|
*/
|
|
272
272
|
export declare function revokeDaemonRefreshSession(serverUrl: string, refreshToken: string): Promise<void>;
|
|
273
|
+
/**
|
|
274
|
+
* What became of a revoke request. The server never says whether the presented
|
|
275
|
+
* token existed, so `accepted` is the strongest claim available: the server
|
|
276
|
+
* took the request, and a live session behind that token is now revoked.
|
|
277
|
+
* `refused` and `unreachable` mean the session, if there is one, is still live.
|
|
278
|
+
*/
|
|
279
|
+
export type RefreshRevokeResult = {
|
|
280
|
+
outcome: 'accepted';
|
|
281
|
+
} | {
|
|
282
|
+
outcome: 'refused';
|
|
283
|
+
status: number;
|
|
284
|
+
} | {
|
|
285
|
+
outcome: 'unreachable';
|
|
286
|
+
detail: string;
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* `revokeDaemonRefreshSession` with its outcome reported instead of swallowed,
|
|
290
|
+
* for a caller that must not tell a person "signed out" when the server never
|
|
291
|
+
* heard (OSK-22307: `skrr logout` did exactly that). Same request, same body,
|
|
292
|
+
* same 5-second bound; it never throws.
|
|
293
|
+
*/
|
|
294
|
+
export declare function revokeDaemonRefreshSessionReported(serverUrl: string, refreshToken: string): Promise<RefreshRevokeResult>;
|
|
273
295
|
export declare function persistReauthState(state: ReauthState): void;
|
|
274
296
|
export declare function needsReauthState(): {
|
|
275
297
|
needed: boolean;
|
|
@@ -40,6 +40,7 @@ __export(refresh_exports, {
|
|
|
40
40
|
persistReauthState: () => persistReauthState,
|
|
41
41
|
refreshDaemonToken: () => refreshDaemonToken,
|
|
42
42
|
revokeDaemonRefreshSession: () => revokeDaemonRefreshSession,
|
|
43
|
+
revokeDaemonRefreshSessionReported: () => revokeDaemonRefreshSessionReported,
|
|
43
44
|
withAuthLock: () => withAuthLock
|
|
44
45
|
});
|
|
45
46
|
module.exports = __toCommonJS(refresh_exports);
|
|
@@ -245,7 +246,17 @@ async function refreshDaemonToken(serverUrl, currentRefreshToken, daemonId, opti
|
|
|
245
246
|
async function revokeDaemonRefreshSession(serverUrl, refreshToken) {
|
|
246
247
|
if (!refreshToken)
|
|
247
248
|
return;
|
|
249
|
+
const result = await revokeDaemonRefreshSessionReported(serverUrl, refreshToken);
|
|
248
250
|
const log = (0, import_runtime.getAuthLogger)();
|
|
251
|
+
if (result.outcome === "refused") {
|
|
252
|
+
log.debug(`[auth/refresh] revoke returned ${result.status}`);
|
|
253
|
+
} else if (result.outcome === "unreachable") {
|
|
254
|
+
log.debug(`[auth/refresh] revoke network error: ${result.detail}`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
async function revokeDaemonRefreshSessionReported(serverUrl, refreshToken) {
|
|
258
|
+
if (!refreshToken)
|
|
259
|
+
return { outcome: "unreachable", detail: "no refresh token to present" };
|
|
249
260
|
const url = `${serverUrl.replace(/\/+$/, "")}/api/daemons/token/revoke`;
|
|
250
261
|
const controller = new AbortController();
|
|
251
262
|
const timer = setTimeout(() => controller.abort(), 5e3);
|
|
@@ -258,11 +269,10 @@ async function revokeDaemonRefreshSession(serverUrl, refreshToken) {
|
|
|
258
269
|
signal: controller.signal
|
|
259
270
|
});
|
|
260
271
|
(0, import_runtime.notifyResponseObserver)(res);
|
|
261
|
-
|
|
262
|
-
log.debug(`[auth/refresh] revoke returned ${res.status}`);
|
|
263
|
-
}
|
|
272
|
+
return res.ok ? { outcome: "accepted" } : { outcome: "refused", status: res.status };
|
|
264
273
|
} catch (err) {
|
|
265
|
-
|
|
274
|
+
const detail = controller.signal.aborted ? "no answer within 5 seconds" : err?.message || String(err);
|
|
275
|
+
return { outcome: "unreachable", detail };
|
|
266
276
|
} finally {
|
|
267
277
|
clearTimeout(timer);
|
|
268
278
|
}
|
|
@@ -553,5 +563,6 @@ function clearReauthState() {
|
|
|
553
563
|
persistReauthState,
|
|
554
564
|
refreshDaemonToken,
|
|
555
565
|
revokeDaemonRefreshSession,
|
|
566
|
+
revokeDaemonRefreshSessionReported,
|
|
556
567
|
withAuthLock
|
|
557
568
|
});
|