@skrr-ai/cli 0.1.144 → 0.1.146
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 +5 -0
- package/dist/commands/agenda/plan.d.ts +21 -0
- package/dist/commands/agenda/plan.js +46 -0
- package/dist/commands/agent/message/approve.js +7 -5
- package/dist/commands/agent/message/decline.js +7 -5
- package/dist/commands/agent/message/pending.js +1 -1
- package/dist/commands/agents/always-on/enable.js +1 -1
- package/dist/commands/agents/plan-day.d.ts +11 -0
- package/dist/commands/agents/plan-day.js +41 -2
- package/dist/commands/agents/schedule-overview.js +15 -10
- package/dist/commands/agents/schedule-trace.js +12 -2
- package/dist/commands/agents/spawn.d.ts +73 -1
- package/dist/commands/agents/spawn.js +274 -5
- package/dist/commands/agents/triggers/fire.js +20 -0
- package/dist/commands/agents/upcoming.d.ts +1 -0
- package/dist/commands/agents/upcoming.js +18 -7
- package/dist/commands/commitments/create.js +1 -1
- package/dist/commands/commitments/update.js +1 -1
- package/dist/commands/spaces/workflow-templates/insert.js +4 -0
- package/dist/commands/store/show.js +22 -0
- package/dist/commands/triggers/audit.js +1 -1
- package/dist/commands/triggers/fire.js +19 -0
- package/dist/generated/agent-guides.json +19 -19
- package/dist/lib/agentic-stream.d.ts +28 -0
- package/dist/lib/agentic-stream.js +89 -1
- package/dist/lib/commitments.js +13 -1
- package/dist/lib/compasses.js +1 -1
- package/dist/lib/dedicated-power.js +10 -3
- package/dist/lib/format.d.ts +20 -0
- package/dist/lib/format.js +47 -0
- package/dist/lib/planOutcome.d.ts +51 -0
- package/dist/lib/planOutcome.js +88 -0
- package/dist/lib/proactiveApi.d.ts +100 -1
- package/dist/lib/proactiveApi.js +27 -2
- package/dist/lib/schedule.d.ts +40 -1
- package/dist/lib/schedule.js +51 -2
- package/dist/lib/triggers.d.ts +134 -3
- package/dist/lib/triggers.js +260 -21
- package/dist/node_modules/@skrr-ai/auth-core/package.json +1 -1
- package/dist/node_modules/@skrr-ai/data-provider/index.js +4677 -4673
- package/oclif.manifest.json +40 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -687,6 +687,11 @@ why), or that a request went quiet and may have been interrupted. While a plan
|
|
|
687
687
|
is being generated, `--approve`, `--dismiss` and `--regenerate` are refused and
|
|
688
688
|
a bare `plan-day` waits for it instead of starting a second one.
|
|
689
689
|
|
|
690
|
+
A plan takes about a minute, longer than the edge lets one request wait. `plan-day`
|
|
691
|
+
therefore sends `Prefer: respond-async`: once the server has claimed the day it
|
|
692
|
+
answers 202 with the request it recorded and keeps planning, and the command
|
|
693
|
+
follows that request until it succeeds, fails (with the reason) or goes quiet.
|
|
694
|
+
|
|
690
695
|
### `sky agents schedule-overview <id>` — full-visibility view
|
|
691
696
|
|
|
692
697
|
One call for everything an agent needs when it wakes to think: its
|
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
import { BaseCommand } from '../../base-command';
|
|
2
|
+
/**
|
|
3
|
+
* The first thing a following terminal says after the runtime line. The turn is
|
|
4
|
+
* accepted but the worker takes about thirty seconds to start it, and until the
|
|
5
|
+
* stream reports `run.started` nothing else prints, which reads as a hang
|
|
6
|
+
* (OSK-22554). Names the cloud worker when that is where the turn is queued.
|
|
7
|
+
*/
|
|
8
|
+
export declare function describeQueuedProgress(runtime: unknown): string;
|
|
9
|
+
/**
|
|
10
|
+
* Why a followed Agenda turn failed, in words.
|
|
11
|
+
*
|
|
12
|
+
* The stream's terminal event does not always carry the reason: a turn the platform refused (a
|
|
13
|
+
* workspace out of credit) or that lost a write wrote it on the response message only, and the
|
|
14
|
+
* command exited 1 with nothing printed (OSK-22639). The terminal event's own sentence wins; the
|
|
15
|
+
* stored message is the second witness; a failure with neither says so rather than staying silent.
|
|
16
|
+
*/
|
|
17
|
+
export declare function describeAgendaFailure(input: {
|
|
18
|
+
lastEvent: Record<string, unknown> | null | undefined;
|
|
19
|
+
readMessages: () => Promise<Array<Record<string, unknown>>>;
|
|
20
|
+
responseMessageId?: string;
|
|
21
|
+
conversationId: string;
|
|
22
|
+
}): Promise<string>;
|
|
2
23
|
/**
|
|
3
24
|
* `skrr agenda plan <agent-id>` — kick off a one-shot Agenda Planning turn
|
|
4
25
|
* for an agent. The server-side controller resolves the agent's persistent
|
|
@@ -1,11 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.describeQueuedProgress = describeQueuedProgress;
|
|
4
|
+
exports.describeAgendaFailure = describeAgendaFailure;
|
|
3
5
|
const core_1 = require("@oclif/core");
|
|
4
6
|
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
5
7
|
const base_command_1 = require("../../base-command");
|
|
6
8
|
const api_fetch_1 = require("../../lib/api-fetch");
|
|
7
9
|
const agentic_stream_1 = require("../../lib/agentic-stream");
|
|
8
10
|
const chat_1 = require("../agents/chat");
|
|
11
|
+
/**
|
|
12
|
+
* The first thing a following terminal says after the runtime line. The turn is
|
|
13
|
+
* accepted but the worker takes about thirty seconds to start it, and until the
|
|
14
|
+
* stream reports `run.started` nothing else prints, which reads as a hang
|
|
15
|
+
* (OSK-22554). Names the cloud worker when that is where the turn is queued.
|
|
16
|
+
*/
|
|
17
|
+
function describeQueuedProgress(runtime) {
|
|
18
|
+
const plan = runtime && typeof runtime === 'object'
|
|
19
|
+
? runtime.executionPlan
|
|
20
|
+
: null;
|
|
21
|
+
const selected = plan && typeof plan === 'object' ? plan.selectedKind : null;
|
|
22
|
+
return selected === 'agent-worker'
|
|
23
|
+
? 'Queued on the cloud worker, starting…'
|
|
24
|
+
: 'Queued, waiting for the agent runtime to start…';
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Why a followed Agenda turn failed, in words.
|
|
28
|
+
*
|
|
29
|
+
* The stream's terminal event does not always carry the reason: a turn the platform refused (a
|
|
30
|
+
* workspace out of credit) or that lost a write wrote it on the response message only, and the
|
|
31
|
+
* command exited 1 with nothing printed (OSK-22639). The terminal event's own sentence wins; the
|
|
32
|
+
* stored message is the second witness; a failure with neither says so rather than staying silent.
|
|
33
|
+
*/
|
|
34
|
+
async function describeAgendaFailure(input) {
|
|
35
|
+
let reason = (0, agentic_stream_1.terminalFailureMessage)(input.lastEvent);
|
|
36
|
+
if (!reason) {
|
|
37
|
+
try {
|
|
38
|
+
const recorded = (0, chat_1.reconcileTerminalFromMessages)(await input.readMessages(), input.responseMessageId);
|
|
39
|
+
if (recorded?.status === 'failed' && recorded.error)
|
|
40
|
+
reason = recorded.error;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// The record could not be read; the line below still says the turn failed.
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return `Agenda planning failed: ${reason ?? 'the run ended in failure and recorded no reason.'} Conversation ${input.conversationId}.`;
|
|
47
|
+
}
|
|
9
48
|
function describeRuntime(runtime) {
|
|
10
49
|
if (typeof runtime === 'string')
|
|
11
50
|
return runtime;
|
|
@@ -86,6 +125,7 @@ class AgendaPlan extends base_command_1.BaseCommand {
|
|
|
86
125
|
this.log('The turn is running detached. It may wait for permission; inspect it in the app or conversation ' + response.conversationId + '.');
|
|
87
126
|
return;
|
|
88
127
|
}
|
|
128
|
+
this.log(describeQueuedProgress(response.runtime));
|
|
89
129
|
const readMessages = async () => {
|
|
90
130
|
const messages = await data_provider_1.dataService.getMessagesByConvoId(response.conversationId);
|
|
91
131
|
return Array.isArray(messages) ? messages : [];
|
|
@@ -155,6 +195,12 @@ class AgendaPlan extends base_command_1.BaseCommand {
|
|
|
155
195
|
process.exitCode = interruptedBy === 'SIGTERM' ? 143 : interruptedBy === 'SIGHUP' ? 129 : interruptedBy ? 130 : 75;
|
|
156
196
|
}
|
|
157
197
|
else if (result.status === 'failed') {
|
|
198
|
+
process.stderr.write(`\n${await describeAgendaFailure({
|
|
199
|
+
lastEvent: result.lastEvent,
|
|
200
|
+
readMessages,
|
|
201
|
+
responseMessageId: response.responseMessageId,
|
|
202
|
+
conversationId: response.conversationId,
|
|
203
|
+
})}\n`);
|
|
158
204
|
process.exitCode = 1;
|
|
159
205
|
}
|
|
160
206
|
else if (result.status === 'aborted' && interruptedBy !== 'SIGHUP') {
|
|
@@ -16,7 +16,11 @@ class AgentMessageApprove extends base_command_1.BaseCommand {
|
|
|
16
16
|
'<%= config.bin %> agent message approve <intent-id> --agent <agent-id>',
|
|
17
17
|
];
|
|
18
18
|
static args = {
|
|
19
|
-
intent: core_1.Args.string({
|
|
19
|
+
intent: core_1.Args.string({
|
|
20
|
+
description: 'Intent ID from `agent message pending`',
|
|
21
|
+
required: true,
|
|
22
|
+
ignoreStdin: true,
|
|
23
|
+
}),
|
|
20
24
|
};
|
|
21
25
|
static flags = {
|
|
22
26
|
agent: core_1.Flags.string({ description: 'Agent ID', required: false }),
|
|
@@ -37,9 +41,7 @@ class AgentMessageApprove extends base_command_1.BaseCommand {
|
|
|
37
41
|
}
|
|
38
42
|
let agentId;
|
|
39
43
|
try {
|
|
40
|
-
const explicitAgentId = (0, agent_resolver_1.mergeExplicitAgentInputs)([
|
|
41
|
-
{ label: '--agent', value: flags.agent },
|
|
42
|
-
]);
|
|
44
|
+
const explicitAgentId = (0, agent_resolver_1.mergeExplicitAgentInputs)([{ label: '--agent', value: flags.agent }]);
|
|
43
45
|
agentId = (await (0, agent_resolver_1.resolveAgentIdentity)(explicitAgentId)).id;
|
|
44
46
|
}
|
|
45
47
|
catch (error) {
|
|
@@ -55,7 +57,7 @@ class AgentMessageApprove extends base_command_1.BaseCommand {
|
|
|
55
57
|
try {
|
|
56
58
|
const result = await data_provider_1.dataService.decideAgentDmIntent(agentId, args.intent, 'approve');
|
|
57
59
|
if (flags.json) {
|
|
58
|
-
this.
|
|
60
|
+
this.printJsonResult(result);
|
|
59
61
|
return;
|
|
60
62
|
}
|
|
61
63
|
if (result.duplicate) {
|
|
@@ -16,7 +16,11 @@ class AgentMessageDecline extends base_command_1.BaseCommand {
|
|
|
16
16
|
'<%= config.bin %> agent message decline <intent-id> --agent <agent-id>',
|
|
17
17
|
];
|
|
18
18
|
static args = {
|
|
19
|
-
intent: core_1.Args.string({
|
|
19
|
+
intent: core_1.Args.string({
|
|
20
|
+
description: 'Intent ID from `agent message pending`',
|
|
21
|
+
required: true,
|
|
22
|
+
ignoreStdin: true,
|
|
23
|
+
}),
|
|
20
24
|
};
|
|
21
25
|
static flags = {
|
|
22
26
|
agent: core_1.Flags.string({ description: 'Agent ID', required: false }),
|
|
@@ -37,9 +41,7 @@ class AgentMessageDecline extends base_command_1.BaseCommand {
|
|
|
37
41
|
}
|
|
38
42
|
let agentId;
|
|
39
43
|
try {
|
|
40
|
-
const explicitAgentId = (0, agent_resolver_1.mergeExplicitAgentInputs)([
|
|
41
|
-
{ label: '--agent', value: flags.agent },
|
|
42
|
-
]);
|
|
44
|
+
const explicitAgentId = (0, agent_resolver_1.mergeExplicitAgentInputs)([{ label: '--agent', value: flags.agent }]);
|
|
43
45
|
agentId = (await (0, agent_resolver_1.resolveAgentIdentity)(explicitAgentId)).id;
|
|
44
46
|
}
|
|
45
47
|
catch (error) {
|
|
@@ -55,7 +57,7 @@ class AgentMessageDecline extends base_command_1.BaseCommand {
|
|
|
55
57
|
try {
|
|
56
58
|
const result = await data_provider_1.dataService.decideAgentDmIntent(agentId, args.intent, 'decline');
|
|
57
59
|
if (flags.json) {
|
|
58
|
-
this.
|
|
60
|
+
this.printJsonResult(result);
|
|
59
61
|
return;
|
|
60
62
|
}
|
|
61
63
|
if (result.duplicate) {
|
|
@@ -57,7 +57,7 @@ class AgentMessagePending extends base_command_1.BaseCommand {
|
|
|
57
57
|
try {
|
|
58
58
|
const result = await data_provider_1.dataService.listAgentDmPendingIntents(agentId);
|
|
59
59
|
if (flags.json) {
|
|
60
|
-
this.
|
|
60
|
+
this.printJsonResult(result);
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
63
|
if (!result.items.length) {
|
|
@@ -66,7 +66,7 @@ class AgentsAlwaysOnEnable extends base_command_1.BaseCommand {
|
|
|
66
66
|
if (!result.matched)
|
|
67
67
|
this.exit(1);
|
|
68
68
|
if (status.operationalState === 'needs_setup') {
|
|
69
|
-
this.log('Note: no Commitment or managed producer lane exists yet. Create a Commitment (or convert a
|
|
69
|
+
this.log('Note: no Commitment or managed producer lane exists yet. Create a Commitment (or convert a standalone check-in) so the runtime has something to fire.');
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
}
|
|
@@ -65,6 +65,8 @@ export default class AgentsPlanDay extends BaseCommand {
|
|
|
65
65
|
*/
|
|
66
66
|
private static readonly TIMEOUT_STATUSES;
|
|
67
67
|
private static readonly POLL_INTERVAL_MS;
|
|
68
|
+
/** Following a request the server named: it is known to be recorded, so ask more often. */
|
|
69
|
+
private static readonly FOLLOW_INTERVAL_MS;
|
|
68
70
|
/** Without a plan-request record (older server) the wait is the old, bounded guess. */
|
|
69
71
|
private static readonly LEGACY_POLL_ATTEMPTS;
|
|
70
72
|
/** The longest a planner may run is ~12 min; wait that plus a margin, never forever. */
|
|
@@ -79,12 +81,21 @@ export default class AgentsPlanDay extends BaseCommand {
|
|
|
79
81
|
* - `ours`: the request our POST started, whose response was lost. We only
|
|
80
82
|
* know the id of whatever was on record BEFORE posting, so a record that is
|
|
81
83
|
* missing or unchanged means the server never saw our request start.
|
|
84
|
+
* - `accepted`: the request the server named in a 202. It is known to be
|
|
85
|
+
* recorded, so a read that does not show it yet predates it and is ignored.
|
|
82
86
|
*
|
|
83
87
|
* Returns instead of throwing for the three "no draft" endings so the caller
|
|
84
88
|
* decides what each means; a request that FAILED throws with the reason,
|
|
85
89
|
* because that is the one answer the person has been missing.
|
|
86
90
|
*/
|
|
87
91
|
private awaitPlanRequest;
|
|
92
|
+
/**
|
|
93
|
+
* The server answered 202: it claimed the plan day and is still planning. That is
|
|
94
|
+
* neither a plan nor a failure, so follow the request it named until it settles.
|
|
95
|
+
* A request that FAILED throws with the reason (inside the wait); every other
|
|
96
|
+
* ending without a draft is reported here, because the person asked for a plan.
|
|
97
|
+
*/
|
|
98
|
+
private followAcceptedPlan;
|
|
88
99
|
/**
|
|
89
100
|
* After a timed-out propose, collect the draft the server persisted anyway.
|
|
90
101
|
* Returns null when the failure was not a timeout, or when nothing landed —
|
|
@@ -167,6 +167,8 @@ class AgentsPlanDay extends base_command_1.BaseCommand {
|
|
|
167
167
|
*/
|
|
168
168
|
static TIMEOUT_STATUSES = new Set([408, 502, 504, 524]);
|
|
169
169
|
static POLL_INTERVAL_MS = 15_000;
|
|
170
|
+
/** Following a request the server named: it is known to be recorded, so ask more often. */
|
|
171
|
+
static FOLLOW_INTERVAL_MS = 5_000;
|
|
170
172
|
/** Without a plan-request record (older server) the wait is the old, bounded guess. */
|
|
171
173
|
static LEGACY_POLL_ATTEMPTS = 12;
|
|
172
174
|
/** The longest a planner may run is ~12 min; wait that plus a margin, never forever. */
|
|
@@ -181,17 +183,19 @@ class AgentsPlanDay extends base_command_1.BaseCommand {
|
|
|
181
183
|
* - `ours`: the request our POST started, whose response was lost. We only
|
|
182
184
|
* know the id of whatever was on record BEFORE posting, so a record that is
|
|
183
185
|
* missing or unchanged means the server never saw our request start.
|
|
186
|
+
* - `accepted`: the request the server named in a 202. It is known to be
|
|
187
|
+
* recorded, so a read that does not show it yet predates it and is ignored.
|
|
184
188
|
*
|
|
185
189
|
* Returns instead of throwing for the three "no draft" endings so the caller
|
|
186
190
|
* decides what each means; a request that FAILED throws with the reason,
|
|
187
191
|
* because that is the one answer the person has been missing.
|
|
188
192
|
*/
|
|
189
|
-
async awaitPlanRequest(agentId, target, json) {
|
|
193
|
+
async awaitPlanRequest(agentId, target, json, intervalMs = AgentsPlanDay.POLL_INTERVAL_MS) {
|
|
190
194
|
const startedAt = Date.now();
|
|
191
195
|
let legacyPolls = 0;
|
|
192
196
|
let lagPolls = 0;
|
|
193
197
|
while (Date.now() - startedAt < AgentsPlanDay.MAX_WAIT_MS) {
|
|
194
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
198
|
+
await new Promise((resolve) => setTimeout(resolve, intervalMs));
|
|
195
199
|
let state;
|
|
196
200
|
try {
|
|
197
201
|
state = await this.fetchPendingState(agentId);
|
|
@@ -212,6 +216,10 @@ class AgentsPlanDay extends base_command_1.BaseCommand {
|
|
|
212
216
|
}
|
|
213
217
|
if (request?.holds)
|
|
214
218
|
continue;
|
|
219
|
+
if (target.kind === 'accepted' &&
|
|
220
|
+
(0, schedule_1.acceptedPlanVerdict)(request, target.accepted) === 'waiting') {
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
215
223
|
if (target.kind === 'ours' && (!request || request.requestId === target.baselineRequestId)) {
|
|
216
224
|
return { outcome: 'unrecorded' };
|
|
217
225
|
}
|
|
@@ -241,6 +249,34 @@ class AgentsPlanDay extends base_command_1.BaseCommand {
|
|
|
241
249
|
}
|
|
242
250
|
return { outcome: 'gave_up' };
|
|
243
251
|
}
|
|
252
|
+
/**
|
|
253
|
+
* The server answered 202: it claimed the plan day and is still planning. That is
|
|
254
|
+
* neither a plan nor a failure, so follow the request it named until it settles.
|
|
255
|
+
* A request that FAILED throws with the reason (inside the wait); every other
|
|
256
|
+
* ending without a draft is reported here, because the person asked for a plan.
|
|
257
|
+
*/
|
|
258
|
+
async followAcceptedPlan(agentId, accepted, json) {
|
|
259
|
+
const day = accepted.planRequest?.planDate;
|
|
260
|
+
// stderr, so `--json` stdout stays a single parseable document.
|
|
261
|
+
this.warn(`The plan${day ? ` for ${day}` : ''} is being generated on the server ` +
|
|
262
|
+
'(it takes longer than one request may wait). Waiting for it to finish.');
|
|
263
|
+
const waited = await this.awaitPlanRequest(agentId, { kind: 'accepted', accepted: accepted.planRequest }, json, AgentsPlanDay.FOLLOW_INTERVAL_MS);
|
|
264
|
+
if (waited.outcome === 'proposal')
|
|
265
|
+
return waited.proposal;
|
|
266
|
+
const interrupted = waited.outcome === 'unknown';
|
|
267
|
+
return this.failWithCliError({
|
|
268
|
+
message: interrupted
|
|
269
|
+
? `The planning request for ${agentId} stopped reporting and may have been interrupted. ` +
|
|
270
|
+
`Run \`${this.config.bin} agents plan-day ${agentId}\` to check for a draft or plan again; ` +
|
|
271
|
+
'if it was still running, a second draft may appear.'
|
|
272
|
+
: `The plan for ${agentId} was not ready within the wait. ` +
|
|
273
|
+
`Check \`${this.config.bin} agents plan-day ${agentId}\` again before planning another.`,
|
|
274
|
+
code: interrupted ? 'SMART_SCHEDULE_PLAN_INTERRUPTED' : 'SMART_SCHEDULE_PLAN_NOT_READY',
|
|
275
|
+
exit: 1,
|
|
276
|
+
retryable: true,
|
|
277
|
+
details: { agentId, planRequest: accepted.planRequest },
|
|
278
|
+
});
|
|
279
|
+
}
|
|
244
280
|
/**
|
|
245
281
|
* After a timed-out propose, collect the draft the server persisted anyway.
|
|
246
282
|
* Returns null when the failure was not a timeout, or when nothing landed —
|
|
@@ -374,6 +410,9 @@ class AgentsPlanDay extends base_command_1.BaseCommand {
|
|
|
374
410
|
throw err;
|
|
375
411
|
proposal = recovered;
|
|
376
412
|
}
|
|
413
|
+
if (!proposal && (0, schedule_1.isPlanAccepted)(generated)) {
|
|
414
|
+
proposal = await this.followAcceptedPlan(agentId, generated, flags.json);
|
|
415
|
+
}
|
|
377
416
|
if (!proposal) {
|
|
378
417
|
proposal = this.requireProposal(generated, agentId, 'propose');
|
|
379
418
|
}
|
|
@@ -12,6 +12,7 @@ const base_command_1 = require("../../base-command");
|
|
|
12
12
|
const format_1 = require("../../lib/format");
|
|
13
13
|
const triggers_1 = require("../../lib/triggers");
|
|
14
14
|
const schedule_1 = require("../../lib/schedule");
|
|
15
|
+
const planOutcome_1 = require("../../lib/planOutcome");
|
|
15
16
|
const reflection_1 = require("../../lib/reflection");
|
|
16
17
|
/** Board statuses that mean "still open / not done" for the tasks section. */
|
|
17
18
|
const OPEN_TASK_STATUSES = new Set(['backlog', 'todo', 'in_progress', 'in_review', 'blocked']);
|
|
@@ -108,19 +109,19 @@ class AgentsScheduleOverview extends base_command_1.BaseCommand {
|
|
|
108
109
|
if (note)
|
|
109
110
|
this.log(note);
|
|
110
111
|
}
|
|
111
|
-
// FUTURE.
|
|
112
|
+
// FUTURE. One named zone for every time below, as `agents upcoming` does (OSK-22643).
|
|
112
113
|
this.log('');
|
|
113
|
-
this.log(`■ Upcoming (next ${flags['horizon-days']}d)`);
|
|
114
|
+
this.log(`■ Upcoming (next ${flags['horizon-days']}d, times in ${(0, schedule_1.describeTimeZone)(todayZone)})`);
|
|
114
115
|
reportError(upcomingR, (line) => this.log(` ${line}`));
|
|
115
116
|
if (upcoming.length === 0) {
|
|
116
117
|
this.log(' Nothing upcoming.');
|
|
117
118
|
}
|
|
118
119
|
else {
|
|
119
120
|
(0, format_1.renderTable)(upcoming.map((item) => ({
|
|
120
|
-
when: formatStamp(item.fireAt),
|
|
121
|
+
when: formatStamp(item.fireAt, todayZone),
|
|
121
122
|
kind: item.kind,
|
|
122
|
-
title: titleOf(item),
|
|
123
|
-
detail: detailOf(item),
|
|
123
|
+
title: (0, format_1.localizeIsoInstants)(titleOf(item), todayZone),
|
|
124
|
+
detail: (0, format_1.localizeIsoInstants)(detailOf(item), todayZone),
|
|
124
125
|
})), [
|
|
125
126
|
{ key: 'when', header: 'WHEN', maxWidth: 26 },
|
|
126
127
|
{ key: 'kind', header: 'KIND', maxWidth: 14 },
|
|
@@ -151,12 +152,17 @@ class AgentsScheduleOverview extends base_command_1.BaseCommand {
|
|
|
151
152
|
if (unknown > 0) {
|
|
152
153
|
this.log(` ${unknown} of these could not be resolved and are withheld fail-closed.`);
|
|
153
154
|
}
|
|
155
|
+
// The rows under "Upcoming" passed the fence the withheld ones failed, so say so (OSK-22406).
|
|
156
|
+
const alwaysOnNote = (0, planOutcome_1.alwaysOnUpcomingNote)(blockedUpcoming, upcoming.length);
|
|
157
|
+
if (alwaysOnNote) {
|
|
158
|
+
this.log(` ${alwaysOnNote}`);
|
|
159
|
+
}
|
|
154
160
|
}
|
|
155
161
|
// PAST.
|
|
156
162
|
this.log('');
|
|
157
163
|
this.log('■ Recent fires');
|
|
158
164
|
reportError(firesR, (line) => this.log(` ${line}`));
|
|
159
|
-
(0, triggers_1.renderFireAudit)(fires, (line) => this.log(line));
|
|
165
|
+
(0, triggers_1.renderFireAudit)(fires, (line) => this.log(line), undefined, { timeZone: todayZone });
|
|
160
166
|
// Open tasks assigned to this agent.
|
|
161
167
|
this.log('');
|
|
162
168
|
this.log('■ Open tasks (assigned to this agent)');
|
|
@@ -169,7 +175,7 @@ class AgentsScheduleOverview extends base_command_1.BaseCommand {
|
|
|
169
175
|
ref: String(t.identifier ?? (t.taskNumber ? `#${t.taskNumber}` : '-')),
|
|
170
176
|
title: String(t.title ?? '-'),
|
|
171
177
|
status: String(t.status ?? '-'),
|
|
172
|
-
when: t.scheduledFor ? formatStamp(String(t.scheduledFor)) : '-',
|
|
178
|
+
when: t.scheduledFor ? formatStamp(String(t.scheduledFor), todayZone) : '-',
|
|
173
179
|
id: String(t.id ?? t._id ?? '-'),
|
|
174
180
|
})), [
|
|
175
181
|
{ key: 'ref', header: 'REF' },
|
|
@@ -283,11 +289,10 @@ function collectErrors(results) {
|
|
|
283
289
|
}
|
|
284
290
|
return Object.keys(errors).length > 0 ? errors : undefined;
|
|
285
291
|
}
|
|
286
|
-
function formatStamp(iso) {
|
|
292
|
+
function formatStamp(iso, zone) {
|
|
287
293
|
if (!iso)
|
|
288
294
|
return '-';
|
|
289
|
-
|
|
290
|
-
return Number.isNaN(d.getTime()) ? iso : d.toISOString();
|
|
295
|
+
return (0, format_1.zonedTime)(iso, zone, { seconds: false });
|
|
291
296
|
}
|
|
292
297
|
function titleOf(item) {
|
|
293
298
|
if (item.kind === 'message')
|
|
@@ -4,6 +4,7 @@ const core_1 = require("@oclif/core");
|
|
|
4
4
|
const base_command_1 = require("../../base-command");
|
|
5
5
|
const format_1 = require("../../lib/format");
|
|
6
6
|
const schedule_1 = require("../../lib/schedule");
|
|
7
|
+
const planOutcome_1 = require("../../lib/planOutcome");
|
|
7
8
|
/**
|
|
8
9
|
* `skrr agents schedule-trace <agent-id>` — WHY the agent's day looks like this.
|
|
9
10
|
*
|
|
@@ -82,7 +83,7 @@ class AgentsScheduleTrace extends base_command_1.BaseCommand {
|
|
|
82
83
|
this.log(` last change ${(0, format_1.zonedTime)(summary.latestChangeAt, zone)}`);
|
|
83
84
|
}
|
|
84
85
|
if (summary.latestChangeSummary) {
|
|
85
|
-
this.log(` latest ${summary.latestChangeSummary}`);
|
|
86
|
+
this.log(` latest ${(0, format_1.localizeIsoInstants)(summary.latestChangeSummary, zone)}`);
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
89
|
// Whether a plan is being generated for this day, or the last attempt failed
|
|
@@ -93,6 +94,12 @@ class AgentsScheduleTrace extends base_command_1.BaseCommand {
|
|
|
93
94
|
this.log(` planning ${planning}`);
|
|
94
95
|
}
|
|
95
96
|
const events = trace.events ?? [];
|
|
97
|
+
// "Why no plan?" first: the newest planning fire's recorded outcome, before the event table
|
|
98
|
+
// that only says a watcher "Completed" (OSK-22395).
|
|
99
|
+
const latestOutcome = (0, planOutcome_1.latestPlanOutcomeLine)(events);
|
|
100
|
+
if (latestOutcome) {
|
|
101
|
+
this.log(` plan outcome ${latestOutcome}`);
|
|
102
|
+
}
|
|
96
103
|
this.log('');
|
|
97
104
|
if (events.length === 0) {
|
|
98
105
|
// An empty trace is a real answer — nothing touched this day's schedule —
|
|
@@ -116,7 +123,9 @@ class AgentsScheduleTrace extends base_command_1.BaseCommand {
|
|
|
116
123
|
source: (0, format_1.formatCell)(e.source),
|
|
117
124
|
type: (0, format_1.formatCell)(e.type),
|
|
118
125
|
status: (0, format_1.formatCell)(e.status),
|
|
119
|
-
|
|
126
|
+
// The server writes these sentences and some embed a UTC instant; the
|
|
127
|
+
// rest of the table is in the trace's zone (OSK-22588).
|
|
128
|
+
summary: (0, format_1.localizeIsoInstants)((0, format_1.formatCell)(e.summary ?? e.reason), zone),
|
|
120
129
|
})), [
|
|
121
130
|
{ key: 'when', header: 'WHEN' },
|
|
122
131
|
{ key: 'source', header: 'SOURCE' },
|
|
@@ -125,6 +134,7 @@ class AgentsScheduleTrace extends base_command_1.BaseCommand {
|
|
|
125
134
|
{ key: 'summary', header: 'SUMMARY', maxWidth: 48 },
|
|
126
135
|
], (line) => this.log(line));
|
|
127
136
|
(0, schedule_1.renderTodoPolicyTraceDetails)(events, (line) => this.log(line));
|
|
137
|
+
(0, planOutcome_1.renderPlanOutcomeTraceDetails)(events, (line) => this.log(line), (at) => (0, format_1.zonedTime)(at, zone));
|
|
128
138
|
// Which collection each column came from — the trace reconciles four
|
|
129
139
|
// sources and the reader should be able to go check one.
|
|
130
140
|
if (trace.sourcePolicy) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseCommand } from '../../base-command';
|
|
2
|
-
import { type ProactiveAgentSpec, type ApplyProactiveAgentResponse } from '../../lib/proactiveApi';
|
|
2
|
+
import { type InstallPlanItem, type SpawnOperation, type ProactiveAgentSpec, type ApplyProactiveAgentResponse } from '../../lib/proactiveApi';
|
|
3
3
|
export type ProactiveInstallReadiness = {
|
|
4
4
|
status: 'ready' | 'degraded';
|
|
5
5
|
message: string;
|
|
@@ -49,6 +49,45 @@ export declare const SPEC_TEMPLATE: {
|
|
|
49
49
|
};
|
|
50
50
|
/** What the template's fields mean and which values they take, for `agents spawn --help`. */
|
|
51
51
|
export declare const SPEC_FORMAT_HELP: string;
|
|
52
|
+
/**
|
|
53
|
+
* The install plan as lines: every object a spec will install, marked `requested` (the spec names
|
|
54
|
+
* it) or `default` (the platform adds it, and why). A spec for one watcher installed ten systems and
|
|
55
|
+
* the plan and the receipt named one (OSK-22417). A default the target runtime cannot run is marked
|
|
56
|
+
* `will be blocked` with the reason, and a declined one `declined`, so what is NOT installed is as
|
|
57
|
+
* visible as what is.
|
|
58
|
+
*/
|
|
59
|
+
export declare function installPlanLines(items: InstallPlanItem[], bin: string): string[];
|
|
60
|
+
export declare const SPAWN_FOLLOW_POLL_MS = 3000;
|
|
61
|
+
/** Longer than an install has taken; past it the CLI says where to read the receipt instead. */
|
|
62
|
+
export declare const SPAWN_FOLLOW_MAX_WAIT_MS: number;
|
|
63
|
+
export type SpawnFollowOutcome = {
|
|
64
|
+
kind: 'done';
|
|
65
|
+
result: NonNullable<SpawnOperation['result']>;
|
|
66
|
+
} | {
|
|
67
|
+
kind: 'failed';
|
|
68
|
+
message: string;
|
|
69
|
+
code?: string;
|
|
70
|
+
} | {
|
|
71
|
+
kind: 'quiet';
|
|
72
|
+
} | {
|
|
73
|
+
kind: 'timeout';
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Follow a spawn the server answered 202 for until it reports a receipt or a failure. The install is
|
|
77
|
+
* not cut short by the edge's 60 s any more, but its receipt used to be lost with the 504 (OSK-22623).
|
|
78
|
+
* A read that fails (a 5xx, the network) is waited through; a 4xx other than "not yet" is the answer.
|
|
79
|
+
*/
|
|
80
|
+
export declare function followSpawnOperation(options: {
|
|
81
|
+
operationId: string;
|
|
82
|
+
read?: (operationId: string) => Promise<SpawnOperation | undefined>;
|
|
83
|
+
sleep?: (ms: number) => Promise<void>;
|
|
84
|
+
now?: () => number;
|
|
85
|
+
pollMs?: number;
|
|
86
|
+
maxWaitMs?: number;
|
|
87
|
+
onWaiting?: (elapsedMs: number) => void;
|
|
88
|
+
}): Promise<SpawnFollowOutcome>;
|
|
89
|
+
/** What `--minimal` / `--without` say when the server cannot honour them. */
|
|
90
|
+
export declare const DECLINE_UNSUPPORTED_MESSAGE = "This server does not support --minimal/--without yet; nothing was opted out.";
|
|
52
91
|
/** A value as one POSIX shell word, so a printed command can be pasted as it is. */
|
|
53
92
|
export declare function shellQuote(value: string): string;
|
|
54
93
|
/**
|
|
@@ -94,13 +133,46 @@ export default class AgentsSpawn extends BaseCommand {
|
|
|
94
133
|
'apply-recommendation': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
95
134
|
'spec-hash': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
96
135
|
'from-spec': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
136
|
+
follow: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
97
137
|
'print-spec-template': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
138
|
+
minimal: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
139
|
+
without: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
98
140
|
'agent-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
99
141
|
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
100
142
|
message: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
101
143
|
timezone: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
102
144
|
};
|
|
103
145
|
run(): Promise<void>;
|
|
146
|
+
/** `--minimal` / `--without`, as the request body carries them. */
|
|
147
|
+
private declineOptions;
|
|
148
|
+
/**
|
|
149
|
+
* The install plan for a spec, or null when this server cannot answer. The preview is a read; an
|
|
150
|
+
* older server has no such route, and the spec preview beside it still stands. A 400 is the
|
|
151
|
+
* answer (a refused option or spec), not a missing plan, so it is rethrown.
|
|
152
|
+
*/
|
|
153
|
+
private readInstallPlan;
|
|
154
|
+
private printInstallPlan;
|
|
155
|
+
/**
|
|
156
|
+
* An apply answer in hand: a receipt passes through; a `202` is followed to its receipt. An install
|
|
157
|
+
* takes longer than the edge allows, and the CLI used to print a 504 for one that completed with its
|
|
158
|
+
* receipt lost (OSK-22623).
|
|
159
|
+
*/
|
|
160
|
+
private resolveApplyAnswer;
|
|
161
|
+
private followToReceipt;
|
|
162
|
+
/**
|
|
163
|
+
* Refuse BEFORE creating anything when `--minimal` / `--without` were asked for and this server
|
|
164
|
+
* cannot honour them. A server that predates the options ignores them, applies every default and
|
|
165
|
+
* answers 200, which looked exactly like a successful opt-out (OSK-22586). The preview route is
|
|
166
|
+
* read-only and arrived with the options, so a server that answers it also applies them; a 404
|
|
167
|
+
* means it does not. Any other failure is thrown as it is: the apply is not attempted either way.
|
|
168
|
+
*/
|
|
169
|
+
private assertServerDeclinesDefaults;
|
|
170
|
+
/**
|
|
171
|
+
* After the apply: the server must say it applied the options. Covers a rolling deploy where the
|
|
172
|
+
* preview was answered by a new instance and the apply by an old one. The Agent then exists with
|
|
173
|
+
* every default, so the error names it.
|
|
174
|
+
*/
|
|
175
|
+
private assertDeclinesApplied;
|
|
104
176
|
private runFromSpec;
|
|
105
177
|
private runFromSentence;
|
|
106
178
|
private runRecommendationAction;
|