@skrr-ai/cli 0.1.144 → 0.1.145
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 +7 -0
- package/dist/commands/agenda/plan.js +17 -0
- package/dist/commands/agent/message/approve.js +2 -4
- package/dist/commands/agent/message/decline.js +2 -4
- package/dist/commands/agent/message/pending.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 +6 -0
- package/dist/commands/agents/schedule-trace.js +12 -2
- package/dist/commands/agents/spawn.d.ts +36 -1
- package/dist/commands/agents/spawn.js +172 -3
- 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/generated/agent-guides.json +19 -19
- package/dist/lib/agentic-stream.d.ts +7 -0
- package/dist/lib/agentic-stream.js +22 -0
- 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 +15 -0
- package/dist/lib/format.js +31 -0
- package/dist/lib/planOutcome.d.ts +51 -0
- package/dist/lib/planOutcome.js +88 -0
- package/dist/lib/proactiveApi.d.ts +62 -0
- package/dist/lib/proactiveApi.js +10 -1
- package/dist/lib/schedule.d.ts +25 -1
- package/dist/lib/schedule.js +37 -2
- package/dist/lib/triggers.d.ts +5 -0
- package/dist/lib/triggers.js +13 -2
- package/dist/node_modules/@skrr-ai/data-provider/index.js +4664 -4661
- package/oclif.manifest.json +33 -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,11 @@
|
|
|
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;
|
|
2
9
|
/**
|
|
3
10
|
* `skrr agenda plan <agent-id>` — kick off a one-shot Agenda Planning turn
|
|
4
11
|
* for an agent. The server-side controller resolves the agent's persistent
|
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.describeQueuedProgress = describeQueuedProgress;
|
|
3
4
|
const core_1 = require("@oclif/core");
|
|
4
5
|
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
5
6
|
const base_command_1 = require("../../base-command");
|
|
6
7
|
const api_fetch_1 = require("../../lib/api-fetch");
|
|
7
8
|
const agentic_stream_1 = require("../../lib/agentic-stream");
|
|
8
9
|
const chat_1 = require("../agents/chat");
|
|
10
|
+
/**
|
|
11
|
+
* The first thing a following terminal says after the runtime line. The turn is
|
|
12
|
+
* accepted but the worker takes about thirty seconds to start it, and until the
|
|
13
|
+
* stream reports `run.started` nothing else prints, which reads as a hang
|
|
14
|
+
* (OSK-22554). Names the cloud worker when that is where the turn is queued.
|
|
15
|
+
*/
|
|
16
|
+
function describeQueuedProgress(runtime) {
|
|
17
|
+
const plan = runtime && typeof runtime === 'object'
|
|
18
|
+
? runtime.executionPlan
|
|
19
|
+
: null;
|
|
20
|
+
const selected = plan && typeof plan === 'object' ? plan.selectedKind : null;
|
|
21
|
+
return selected === 'agent-worker'
|
|
22
|
+
? 'Queued on the cloud worker, starting…'
|
|
23
|
+
: 'Queued, waiting for the agent runtime to start…';
|
|
24
|
+
}
|
|
9
25
|
function describeRuntime(runtime) {
|
|
10
26
|
if (typeof runtime === 'string')
|
|
11
27
|
return runtime;
|
|
@@ -86,6 +102,7 @@ class AgendaPlan extends base_command_1.BaseCommand {
|
|
|
86
102
|
this.log('The turn is running detached. It may wait for permission; inspect it in the app or conversation ' + response.conversationId + '.');
|
|
87
103
|
return;
|
|
88
104
|
}
|
|
105
|
+
this.log(describeQueuedProgress(response.runtime));
|
|
89
106
|
const readMessages = async () => {
|
|
90
107
|
const messages = await data_provider_1.dataService.getMessagesByConvoId(response.conversationId);
|
|
91
108
|
return Array.isArray(messages) ? messages : [];
|
|
@@ -37,9 +37,7 @@ class AgentMessageApprove extends base_command_1.BaseCommand {
|
|
|
37
37
|
}
|
|
38
38
|
let agentId;
|
|
39
39
|
try {
|
|
40
|
-
const explicitAgentId = (0, agent_resolver_1.mergeExplicitAgentInputs)([
|
|
41
|
-
{ label: '--agent', value: flags.agent },
|
|
42
|
-
]);
|
|
40
|
+
const explicitAgentId = (0, agent_resolver_1.mergeExplicitAgentInputs)([{ label: '--agent', value: flags.agent }]);
|
|
43
41
|
agentId = (await (0, agent_resolver_1.resolveAgentIdentity)(explicitAgentId)).id;
|
|
44
42
|
}
|
|
45
43
|
catch (error) {
|
|
@@ -55,7 +53,7 @@ class AgentMessageApprove extends base_command_1.BaseCommand {
|
|
|
55
53
|
try {
|
|
56
54
|
const result = await data_provider_1.dataService.decideAgentDmIntent(agentId, args.intent, 'approve');
|
|
57
55
|
if (flags.json) {
|
|
58
|
-
this.
|
|
56
|
+
this.printJsonResult(result);
|
|
59
57
|
return;
|
|
60
58
|
}
|
|
61
59
|
if (result.duplicate) {
|
|
@@ -37,9 +37,7 @@ class AgentMessageDecline extends base_command_1.BaseCommand {
|
|
|
37
37
|
}
|
|
38
38
|
let agentId;
|
|
39
39
|
try {
|
|
40
|
-
const explicitAgentId = (0, agent_resolver_1.mergeExplicitAgentInputs)([
|
|
41
|
-
{ label: '--agent', value: flags.agent },
|
|
42
|
-
]);
|
|
40
|
+
const explicitAgentId = (0, agent_resolver_1.mergeExplicitAgentInputs)([{ label: '--agent', value: flags.agent }]);
|
|
43
41
|
agentId = (await (0, agent_resolver_1.resolveAgentIdentity)(explicitAgentId)).id;
|
|
44
42
|
}
|
|
45
43
|
catch (error) {
|
|
@@ -55,7 +53,7 @@ class AgentMessageDecline extends base_command_1.BaseCommand {
|
|
|
55
53
|
try {
|
|
56
54
|
const result = await data_provider_1.dataService.decideAgentDmIntent(agentId, args.intent, 'decline');
|
|
57
55
|
if (flags.json) {
|
|
58
|
-
this.
|
|
56
|
+
this.printJsonResult(result);
|
|
59
57
|
return;
|
|
60
58
|
}
|
|
61
59
|
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) {
|
|
@@ -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']);
|
|
@@ -151,6 +152,11 @@ 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('');
|
|
@@ -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 ProactiveAgentSpec, type ApplyProactiveAgentResponse } from '../../lib/proactiveApi';
|
|
3
3
|
export type ProactiveInstallReadiness = {
|
|
4
4
|
status: 'ready' | 'degraded';
|
|
5
5
|
message: string;
|
|
@@ -49,6 +49,16 @@ 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
|
+
/** What `--minimal` / `--without` say when the server cannot honour them. */
|
|
61
|
+
export declare const DECLINE_UNSUPPORTED_MESSAGE = "This server does not support --minimal/--without yet; nothing was opted out.";
|
|
52
62
|
/** A value as one POSIX shell word, so a printed command can be pasted as it is. */
|
|
53
63
|
export declare function shellQuote(value: string): string;
|
|
54
64
|
/**
|
|
@@ -95,12 +105,37 @@ export default class AgentsSpawn extends BaseCommand {
|
|
|
95
105
|
'spec-hash': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
96
106
|
'from-spec': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
97
107
|
'print-spec-template': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
108
|
+
minimal: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
109
|
+
without: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
98
110
|
'agent-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
99
111
|
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
100
112
|
message: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
101
113
|
timezone: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
102
114
|
};
|
|
103
115
|
run(): Promise<void>;
|
|
116
|
+
/** `--minimal` / `--without`, as the request body carries them. */
|
|
117
|
+
private declineOptions;
|
|
118
|
+
/**
|
|
119
|
+
* The install plan for a spec, or null when this server cannot answer. The preview is a read; an
|
|
120
|
+
* older server has no such route, and the spec preview beside it still stands. A 400 is the
|
|
121
|
+
* answer (a refused option or spec), not a missing plan, so it is rethrown.
|
|
122
|
+
*/
|
|
123
|
+
private readInstallPlan;
|
|
124
|
+
private printInstallPlan;
|
|
125
|
+
/**
|
|
126
|
+
* Refuse BEFORE creating anything when `--minimal` / `--without` were asked for and this server
|
|
127
|
+
* cannot honour them. A server that predates the options ignores them, applies every default and
|
|
128
|
+
* answers 200, which looked exactly like a successful opt-out (OSK-22586). The preview route is
|
|
129
|
+
* read-only and arrived with the options, so a server that answers it also applies them; a 404
|
|
130
|
+
* means it does not. Any other failure is thrown as it is: the apply is not attempted either way.
|
|
131
|
+
*/
|
|
132
|
+
private assertServerDeclinesDefaults;
|
|
133
|
+
/**
|
|
134
|
+
* After the apply: the server must say it applied the options. Covers a rolling deploy where the
|
|
135
|
+
* preview was answered by a new instance and the apply by an old one. The Agent then exists with
|
|
136
|
+
* every default, so the error names it.
|
|
137
|
+
*/
|
|
138
|
+
private assertDeclinesApplied;
|
|
104
139
|
private runFromSpec;
|
|
105
140
|
private runFromSentence;
|
|
106
141
|
private runRecommendationAction;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SPEC_FORMAT_HELP = exports.SPEC_TEMPLATE = void 0;
|
|
3
|
+
exports.DECLINE_UNSUPPORTED_MESSAGE = exports.SPEC_FORMAT_HELP = exports.SPEC_TEMPLATE = void 0;
|
|
4
4
|
exports.workerPolicyWindowLines = workerPolicyWindowLines;
|
|
5
5
|
exports.specWithEffectiveWindowFlags = specWithEffectiveWindowFlags;
|
|
6
|
+
exports.installPlanLines = installPlanLines;
|
|
6
7
|
exports.shellQuote = shellQuote;
|
|
7
8
|
exports.initializeSummary = initializeSummary;
|
|
8
9
|
exports.proactiveInstallReadiness = proactiveInstallReadiness;
|
|
@@ -10,6 +11,7 @@ const core_1 = require("@oclif/core");
|
|
|
10
11
|
const base_command_1 = require("../../base-command");
|
|
11
12
|
const prompt_1 = require("../../lib/prompt");
|
|
12
13
|
const format_1 = require("../../lib/format");
|
|
14
|
+
const http_error_1 = require("../../lib/http-error");
|
|
13
15
|
const web_url_1 = require("../../lib/web-url");
|
|
14
16
|
const proactiveApi_1 = require("../../lib/proactiveApi");
|
|
15
17
|
function workerPolicyWindowLines(policy) {
|
|
@@ -84,6 +86,39 @@ exports.SPEC_FORMAT_HELP = [
|
|
|
84
86
|
'- orchestrator (installed when systems has orchestrator): mode review or auto, executePlan true or false, workingHours { start, end, timezone }.',
|
|
85
87
|
'- Optional: commitments (at most 3), initialize { goals, tasks, jobs }, compass, autonomyPosture.',
|
|
86
88
|
].join('\n');
|
|
89
|
+
/**
|
|
90
|
+
* The install plan as lines: every object a spec will install, marked `requested` (the spec names
|
|
91
|
+
* it) or `default` (the platform adds it, and why). A spec for one watcher installed ten systems and
|
|
92
|
+
* the plan and the receipt named one (OSK-22417). A default the target runtime cannot run is marked
|
|
93
|
+
* `will be blocked` with the reason, and a declined one `declined`, so what is NOT installed is as
|
|
94
|
+
* visible as what is.
|
|
95
|
+
*/
|
|
96
|
+
function installPlanLines(items, bin) {
|
|
97
|
+
if (!items.length)
|
|
98
|
+
return [];
|
|
99
|
+
const lines = ['Will be installed:'];
|
|
100
|
+
for (const item of items) {
|
|
101
|
+
const mark = item.status === 'declined'
|
|
102
|
+
? 'declined'
|
|
103
|
+
: item.status === 'will_be_blocked'
|
|
104
|
+
? 'will be blocked'
|
|
105
|
+
: item.origin;
|
|
106
|
+
const note = item.status === 'declined'
|
|
107
|
+
? item.reason ?? 'declined'
|
|
108
|
+
: item.status === 'will_be_blocked'
|
|
109
|
+
? `${item.reason ?? 'blocked'}: ${item.detail ?? 'the runtime cannot run it'}`
|
|
110
|
+
: item.origin === 'default'
|
|
111
|
+
? item.why
|
|
112
|
+
: '';
|
|
113
|
+
lines.push(` ${mark.padEnd(15)} ${item.label}${note ? ` - ${note}` : ''}`);
|
|
114
|
+
}
|
|
115
|
+
if (items.some((item) => item.origin === 'default' && item.status !== 'declined')) {
|
|
116
|
+
lines.push(`Decline defaults with \`${bin} agents spawn ... --without <name>\` (${proactiveApi_1.DECLINABLE_DEFAULTS.join(', ')}) or --minimal.`);
|
|
117
|
+
}
|
|
118
|
+
return lines;
|
|
119
|
+
}
|
|
120
|
+
/** What `--minimal` / `--without` say when the server cannot honour them. */
|
|
121
|
+
exports.DECLINE_UNSUPPORTED_MESSAGE = 'This server does not support --minimal/--without yet; nothing was opted out.';
|
|
87
122
|
/** A value as one POSIX shell word, so a printed command can be pasted as it is. */
|
|
88
123
|
function shellQuote(value) {
|
|
89
124
|
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
@@ -264,6 +299,8 @@ class AgentsSpawn extends base_command_1.BaseCommand {
|
|
|
264
299
|
'<%= config.bin %> agents spawn --apply-recommendation par_123 --spec-hash <reviewed-hash>',
|
|
265
300
|
'<%= config.bin %> agents spawn --print-spec-template > spec.json',
|
|
266
301
|
'<%= config.bin %> agents spawn --from-spec spec.json --approve',
|
|
302
|
+
'<%= config.bin %> agents spawn --from-spec spec.json --minimal --approve',
|
|
303
|
+
'<%= config.bin %> agents spawn --from-spec spec.json --without memory_watcher --without relationship_loops --approve',
|
|
267
304
|
];
|
|
268
305
|
static args = {
|
|
269
306
|
sentence: core_1.Args.string({
|
|
@@ -294,6 +331,14 @@ class AgentsSpawn extends base_command_1.BaseCommand {
|
|
|
294
331
|
'print-spec-template': core_1.Flags.boolean({
|
|
295
332
|
description: 'Print a valid spec JSON to edit and pass to --from-spec, and exit (creates nothing)',
|
|
296
333
|
}),
|
|
334
|
+
minimal: core_1.Flags.boolean({
|
|
335
|
+
description: 'Install only what the spec asks for: decline every default the platform would add (the memory and task/goal scans, the initiative follow-through loop, the four relationship loops). The plan lists each default first',
|
|
336
|
+
}),
|
|
337
|
+
without: core_1.Flags.string({
|
|
338
|
+
description: `Decline one default by name; repeatable. One of: ${proactiveApi_1.DECLINABLE_DEFAULTS.join(', ')}. Refused when the spec itself asks for it`,
|
|
339
|
+
options: [...proactiveApi_1.DECLINABLE_DEFAULTS],
|
|
340
|
+
multiple: true,
|
|
341
|
+
}),
|
|
297
342
|
'agent-id': core_1.Flags.string({
|
|
298
343
|
description: 'Apply onto an existing agent instead of creating a new one (convergent re-run)',
|
|
299
344
|
}),
|
|
@@ -314,6 +359,12 @@ class AgentsSpawn extends base_command_1.BaseCommand {
|
|
|
314
359
|
return;
|
|
315
360
|
}
|
|
316
361
|
this.requireAuth();
|
|
362
|
+
// A recommendation is approved and applied as reviewed, with no way to decline a default;
|
|
363
|
+
// refusing here is better than a --minimal that silently installs everything.
|
|
364
|
+
if ((flags.minimal || (flags.without ?? []).length > 0) &&
|
|
365
|
+
(flags['approve-recommendation'] || flags['apply-recommendation'] || flags.recommend)) {
|
|
366
|
+
this.error('--minimal and --without apply to --from-spec and to a sentence, not to a recommendation. Apply the spec directly instead.', { exit: 1 });
|
|
367
|
+
}
|
|
317
368
|
if (flags.recommend && flags['from-spec']) {
|
|
318
369
|
this.error('--recommend cannot be combined with --from-spec. Use a sentence with --recommend, or review the spec and apply it with --from-spec and --approve.', { exit: 1 });
|
|
319
370
|
}
|
|
@@ -337,6 +388,86 @@ class AgentsSpawn extends base_command_1.BaseCommand {
|
|
|
337
388
|
this.handleApiError(err);
|
|
338
389
|
}
|
|
339
390
|
}
|
|
391
|
+
/** `--minimal` / `--without`, as the request body carries them. */
|
|
392
|
+
declineOptions(flags) {
|
|
393
|
+
return {
|
|
394
|
+
...(flags.minimal ? { minimal: true } : {}),
|
|
395
|
+
...((flags.without ?? []).length > 0 ? { without: flags.without } : {}),
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* The install plan for a spec, or null when this server cannot answer. The preview is a read; an
|
|
400
|
+
* older server has no such route, and the spec preview beside it still stands. A 400 is the
|
|
401
|
+
* answer (a refused option or spec), not a missing plan, so it is rethrown.
|
|
402
|
+
*/
|
|
403
|
+
async readInstallPlan(spec, flags, fromReviewedSpec) {
|
|
404
|
+
try {
|
|
405
|
+
const preview = await proactiveApi_1.proactiveApi.previewProactiveAgentSpec({
|
|
406
|
+
spec,
|
|
407
|
+
...(flags['agent-id'] ? { agentId: flags['agent-id'] } : {}),
|
|
408
|
+
...(flags.timezone ? { timezone: flags.timezone } : {}),
|
|
409
|
+
fromReviewedSpec,
|
|
410
|
+
...this.declineOptions(flags),
|
|
411
|
+
});
|
|
412
|
+
return preview.items;
|
|
413
|
+
}
|
|
414
|
+
catch (err) {
|
|
415
|
+
if ((0, http_error_1.httpStatusOf)(err) === 400)
|
|
416
|
+
throw err;
|
|
417
|
+
return null;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
async printInstallPlan(spec, flags, fromReviewedSpec) {
|
|
421
|
+
const items = await this.readInstallPlan(spec, flags, fromReviewedSpec);
|
|
422
|
+
this.log('');
|
|
423
|
+
if (!items) {
|
|
424
|
+
this.log('(The install plan could not be read from this server; the spec above is what you reviewed.)');
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
for (const line of installPlanLines(items, this.config.bin))
|
|
428
|
+
this.log(line);
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Refuse BEFORE creating anything when `--minimal` / `--without` were asked for and this server
|
|
432
|
+
* cannot honour them. A server that predates the options ignores them, applies every default and
|
|
433
|
+
* answers 200, which looked exactly like a successful opt-out (OSK-22586). The preview route is
|
|
434
|
+
* read-only and arrived with the options, so a server that answers it also applies them; a 404
|
|
435
|
+
* means it does not. Any other failure is thrown as it is: the apply is not attempted either way.
|
|
436
|
+
*/
|
|
437
|
+
async assertServerDeclinesDefaults(spec, flags, fromReviewedSpec) {
|
|
438
|
+
if (!flags.minimal && (flags.without ?? []).length === 0)
|
|
439
|
+
return;
|
|
440
|
+
try {
|
|
441
|
+
const preview = await proactiveApi_1.proactiveApi.previewProactiveAgentSpec({
|
|
442
|
+
spec,
|
|
443
|
+
...(flags['agent-id'] ? { agentId: flags['agent-id'] } : {}),
|
|
444
|
+
...(flags.timezone ? { timezone: flags.timezone } : {}),
|
|
445
|
+
fromReviewedSpec,
|
|
446
|
+
...this.declineOptions(flags),
|
|
447
|
+
});
|
|
448
|
+
if (preview && Array.isArray(preview.items) && preview.options)
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
catch (err) {
|
|
452
|
+
const status = (0, http_error_1.httpStatusOf)(err);
|
|
453
|
+
if (status !== 404 && status !== 405 && status !== 501)
|
|
454
|
+
throw err;
|
|
455
|
+
}
|
|
456
|
+
this.error(exports.DECLINE_UNSUPPORTED_MESSAGE, { exit: 1 });
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* After the apply: the server must say it applied the options. Covers a rolling deploy where the
|
|
460
|
+
* preview was answered by a new instance and the apply by an old one. The Agent then exists with
|
|
461
|
+
* every default, so the error names it.
|
|
462
|
+
*/
|
|
463
|
+
assertDeclinesApplied(result, flags) {
|
|
464
|
+
if (!flags.minimal && (flags.without ?? []).length === 0)
|
|
465
|
+
return;
|
|
466
|
+
if (result.installOptions)
|
|
467
|
+
return;
|
|
468
|
+
this.error(`${exports.DECLINE_UNSUPPORTED_MESSAGE} The Agent ${result.agentId} was created with every default; ` +
|
|
469
|
+
`see what it holds with \`${this.config.bin} agents triggers list ${result.agentId}\`.`, { exit: 1 });
|
|
470
|
+
}
|
|
340
471
|
async runFromSpec(flags) {
|
|
341
472
|
const body = await (0, prompt_1.readJsonBody)(flags['from-spec']);
|
|
342
473
|
const spec = (body.spec ?? body);
|
|
@@ -346,17 +477,21 @@ class AgentsSpawn extends base_command_1.BaseCommand {
|
|
|
346
477
|
return;
|
|
347
478
|
}
|
|
348
479
|
this.renderSpec(spec);
|
|
480
|
+
await this.printInstallPlan(spec, flags, true);
|
|
349
481
|
this.log('');
|
|
350
482
|
this.log('This is a spec preview — re-run with --approve to create the agent.');
|
|
351
483
|
return;
|
|
352
484
|
}
|
|
485
|
+
await this.assertServerDeclinesDefaults(spec, flags, true);
|
|
353
486
|
const result = await proactiveApi_1.proactiveApi.applyProactiveAgentSpec({
|
|
354
487
|
spec,
|
|
355
488
|
...(flags['agent-id'] ? { agentId: flags['agent-id'] } : {}),
|
|
356
489
|
...(flags.timezone ? { timezone: flags.timezone } : {}),
|
|
357
490
|
fromReviewedSpec: true,
|
|
491
|
+
...this.declineOptions(flags),
|
|
358
492
|
});
|
|
359
493
|
this.renderApplyResult(result, flags.json, Boolean(flags['agent-id']));
|
|
494
|
+
this.assertDeclinesApplied(result, flags);
|
|
360
495
|
}
|
|
361
496
|
async runFromSentence(sentence, flags) {
|
|
362
497
|
const history = (flags.message ?? []).map((content) => ({
|
|
@@ -406,7 +541,12 @@ class AgentsSpawn extends base_command_1.BaseCommand {
|
|
|
406
541
|
const spec = plan.spec;
|
|
407
542
|
if (!flags.approve) {
|
|
408
543
|
if (flags.json) {
|
|
409
|
-
this.
|
|
544
|
+
const installPlan = await this.readInstallPlan(spec, flags, false);
|
|
545
|
+
this.printJsonResult({
|
|
546
|
+
...plan,
|
|
547
|
+
spec: specWithEffectiveWindowFlags(spec),
|
|
548
|
+
...(installPlan ? { installPlan } : {}),
|
|
549
|
+
});
|
|
410
550
|
return;
|
|
411
551
|
}
|
|
412
552
|
// The planner's own sentence about the plan (and any note about a value it
|
|
@@ -416,12 +556,15 @@ class AgentsSpawn extends base_command_1.BaseCommand {
|
|
|
416
556
|
this.log('');
|
|
417
557
|
}
|
|
418
558
|
this.renderSpec(spec);
|
|
559
|
+
await this.printInstallPlan(spec, flags, false);
|
|
419
560
|
this.log('');
|
|
420
561
|
this.log('This is a draft — nothing has been created.');
|
|
421
562
|
const repeat = [
|
|
422
563
|
shellQuote(sentence),
|
|
423
564
|
...(flags.name ? ['--name', shellQuote(flags.name)] : []),
|
|
424
565
|
...(flags.timezone ? ['--timezone', shellQuote(flags.timezone)] : []),
|
|
566
|
+
...(flags.minimal ? ['--minimal'] : []),
|
|
567
|
+
...(flags.without ?? []).flatMap((name) => ['--without', name]),
|
|
425
568
|
'--approve',
|
|
426
569
|
].join(' ');
|
|
427
570
|
this.log(` Create it: ${this.config.bin} agents spawn ${repeat}`);
|
|
@@ -430,13 +573,16 @@ class AgentsSpawn extends base_command_1.BaseCommand {
|
|
|
430
573
|
this.log(' --from-spec spec.json --approve');
|
|
431
574
|
return;
|
|
432
575
|
}
|
|
576
|
+
await this.assertServerDeclinesDefaults(spec, flags, false);
|
|
433
577
|
const result = await proactiveApi_1.proactiveApi.applyProactiveAgentSpec({
|
|
434
578
|
spec,
|
|
435
579
|
...(flags['agent-id'] ? { agentId: flags['agent-id'] } : {}),
|
|
436
580
|
...(flags.timezone ? { timezone: flags.timezone } : {}),
|
|
437
581
|
fromReviewedSpec: false,
|
|
582
|
+
...this.declineOptions(flags),
|
|
438
583
|
});
|
|
439
584
|
this.renderApplyResult(result, flags.json, Boolean(flags['agent-id']));
|
|
585
|
+
this.assertDeclinesApplied(result, flags);
|
|
440
586
|
}
|
|
441
587
|
async runRecommendationAction(flags) {
|
|
442
588
|
if (flags['apply-recommendation'] && !flags['spec-hash']?.trim()) {
|
|
@@ -581,7 +727,13 @@ class AgentsSpawn extends base_command_1.BaseCommand {
|
|
|
581
727
|
}
|
|
582
728
|
const compass = result.installed.compass;
|
|
583
729
|
if (compass) {
|
|
584
|
-
this.log(` compass: ${compass.skipped
|
|
730
|
+
this.log(` compass: ${compass.skipped === 'compass_unchanged'
|
|
731
|
+
? 'already in place (unchanged)'
|
|
732
|
+
: compass.skipped
|
|
733
|
+
? `kept the existing one (${compass.skipped})`
|
|
734
|
+
: compass.ok
|
|
735
|
+
? 'installed'
|
|
736
|
+
: 'failed'}`);
|
|
585
737
|
}
|
|
586
738
|
const seeded = initializeSummary(result.installed.initialize);
|
|
587
739
|
if (seeded)
|
|
@@ -596,6 +748,23 @@ class AgentsSpawn extends base_command_1.BaseCommand {
|
|
|
596
748
|
const state = watcher.enabled == null ? 'unknown' : watcher.enabled ? 'enabled' : 'disabled';
|
|
597
749
|
this.log(` ${watcher.source}: ${state}` + (watcher.triggerId ? ` (${watcher.triggerId})` : ''));
|
|
598
750
|
}
|
|
751
|
+
// Everything that now exists on the Agent, read back: the creation-time seed and the baseline
|
|
752
|
+
// watchers are not in the lines above, which is how a one-watcher spec read as one (OSK-22417).
|
|
753
|
+
const inventory = result.installed.inventory;
|
|
754
|
+
if (inventory?.triggers?.length) {
|
|
755
|
+
this.log(' triggers on this agent:');
|
|
756
|
+
for (const trigger of inventory.triggers) {
|
|
757
|
+
this.log(` ${trigger.origin.padEnd(9)} ${trigger.label ?? trigger.source ?? '(unnamed)'}` +
|
|
758
|
+
` - ${trigger.enabled ? 'enabled' : 'disabled'} (${trigger.id})`);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
if (inventory?.commitments?.length) {
|
|
762
|
+
this.log(' system commitments on this agent:');
|
|
763
|
+
for (const commitment of inventory.commitments) {
|
|
764
|
+
this.log(` ${commitment.systemRole ?? commitment.title ?? '(unnamed)'}` +
|
|
765
|
+
` - ${commitment.status ?? 'unknown'} (${commitment.id})`);
|
|
766
|
+
}
|
|
767
|
+
}
|
|
599
768
|
if (result.warnings.length > 0) {
|
|
600
769
|
this.log(' warnings:');
|
|
601
770
|
for (const warning of result.warnings) {
|