@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/README.md
CHANGED
|
@@ -679,6 +679,14 @@ sky agents plan-day <agent-id> --regenerate "prioritize the Q2 launch" \
|
|
|
679
679
|
--hours-start 09:00 --hours-end 17:00 # a fresh plan with a working-hours window
|
|
680
680
|
```
|
|
681
681
|
|
|
682
|
+
Generating a plan can take minutes, and the request that started it can end (a
|
|
683
|
+
gateway timeout) while the server keeps going. The server records each request
|
|
684
|
+
per agent-day, so `plan-day` and `schedule-trace` report what it knows: that a
|
|
685
|
+
plan is being generated (and since when), that the last attempt failed (and
|
|
686
|
+
why), or that a request went quiet and may have been interrupted. While a plan
|
|
687
|
+
is being generated, `--approve`, `--dismiss` and `--regenerate` are refused and
|
|
688
|
+
a bare `plan-day` waits for it instead of starting a second one.
|
|
689
|
+
|
|
682
690
|
### `sky agents schedule-overview <id>` — full-visibility view
|
|
683
691
|
|
|
684
692
|
One call for everything an agent needs when it wakes to think: its
|
|
@@ -17,7 +17,9 @@ const base_command_1 = require("../../../base-command");
|
|
|
17
17
|
* agenda MCP server's hardened defaults (`DEFAULT_SCHEDULE_MAX_FIRES_PER_DAY`).
|
|
18
18
|
*/
|
|
19
19
|
class AgendaTriggerCreate extends base_command_1.BaseCommand {
|
|
20
|
-
static description = 'Register a future automatic agent run via the AgentTrigger subsystem. Mirrors the agenda_create_trigger MCP tool.'
|
|
20
|
+
static description = 'Register a future automatic agent run via the AgentTrigger subsystem. Mirrors the agenda_create_trigger MCP tool. ' +
|
|
21
|
+
'Every run is a model turn. For a daily time, a one-time run or a deterministic action with no model turn ' +
|
|
22
|
+
'(for example creating a task), use `skrr triggers create`.';
|
|
21
23
|
static examples = [
|
|
22
24
|
"<%= config.bin %> agenda trigger create <agent-id> --kind schedule --cron '0 9 * * MON' --label 'Weekly briefing' --prompt 'Summarize last week and plan this week.'",
|
|
23
25
|
"<%= config.bin %> agenda trigger create <agent-id> --kind self_scheduled --delay-minutes 240 --label 'Follow up' --prompt 'Check back on the Q2 launch task.'",
|
|
@@ -45,7 +47,7 @@ class AgendaTriggerCreate extends base_command_1.BaseCommand {
|
|
|
45
47
|
description: "5-field cron expression — required when --kind=schedule (e.g. '0 9 * * MON')",
|
|
46
48
|
}),
|
|
47
49
|
timezone: core_1.Flags.string({
|
|
48
|
-
description: 'IANA timezone
|
|
50
|
+
description: 'IANA timezone the cron is read in, for example America/Los_Angeles. Defaults to UTC, so "0 9 * * *" is 09:00 UTC when this is left out. Only used with --kind=schedule.',
|
|
49
51
|
}),
|
|
50
52
|
'delay-minutes': core_1.Flags.integer({
|
|
51
53
|
description: 'Minutes from now to fire — required when --kind=self_scheduled. ' +
|
|
@@ -104,16 +104,16 @@ class AgendaTriggerList extends base_command_1.BaseCommand {
|
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
106
|
const rows = items.map((t) => {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
// The same answer `triggers list` gives: a disabled trigger has no next run (its stored
|
|
108
|
+
// `nextRunAt` is where it WOULD run), so one list no longer says it will run while the other
|
|
109
|
+
// says it will not (OSK-22493).
|
|
110
|
+
const next = (0, triggers_1.nextRunLabel)(t);
|
|
111
111
|
const fires = t.audit?.fireCount ?? 0;
|
|
112
112
|
return {
|
|
113
113
|
id: String(t.id ?? '-'),
|
|
114
114
|
kind: String(t.kind ?? '-'),
|
|
115
115
|
enabled: t.enabled === false ? 'no' : 'yes',
|
|
116
|
-
label: String(t.label ?? '-')
|
|
116
|
+
label: String(t.label ?? '-'),
|
|
117
117
|
next: String(next).slice(0, 25),
|
|
118
118
|
fires: String(fires),
|
|
119
119
|
source: (0, agent_trigger_listing_1.sourceLabel)(t, isUnconfirmedTurnCapture(t)),
|
|
@@ -123,8 +123,8 @@ class AgendaTriggerList extends base_command_1.BaseCommand {
|
|
|
123
123
|
{ key: 'id', header: 'TRIGGER ID' },
|
|
124
124
|
{ key: 'kind', header: 'KIND' },
|
|
125
125
|
{ key: 'enabled', header: 'ON' },
|
|
126
|
-
{ key: 'label', header: 'LABEL' },
|
|
127
|
-
{ key: 'next', header: 'NEXT
|
|
126
|
+
{ key: 'label', header: 'LABEL', maxWidth: 40, truncate: 'middle' },
|
|
127
|
+
{ key: 'next', header: 'NEXT/LAST' },
|
|
128
128
|
{ key: 'fires', header: 'FIRES' },
|
|
129
129
|
{ key: 'source', header: 'SOURCE' },
|
|
130
130
|
], (line) => this.log(line));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base-command';
|
|
2
|
+
/**
|
|
3
|
+
* Approve an Agent's message that is waiting for your approval, and deliver it
|
|
4
|
+
* Only a person can decide: the server refuses an Agent or automation credential (OSK-22364).
|
|
5
|
+
*/
|
|
6
|
+
export default class AgentMessageApprove extends BaseCommand {
|
|
7
|
+
static description: string;
|
|
8
|
+
static examples: string[];
|
|
9
|
+
static args: {
|
|
10
|
+
intent: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
11
|
+
};
|
|
12
|
+
static flags: {
|
|
13
|
+
agent: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
};
|
|
16
|
+
run(): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
5
|
+
const base_command_1 = require("../../../base-command");
|
|
6
|
+
const agent_resolver_1 = require("../../../lib/agent-resolver");
|
|
7
|
+
const message_intent_1 = require("../../../lib/message-intent");
|
|
8
|
+
/**
|
|
9
|
+
* Approve an Agent's message that is waiting for your approval, and deliver it
|
|
10
|
+
* Only a person can decide: the server refuses an Agent or automation credential (OSK-22364).
|
|
11
|
+
*/
|
|
12
|
+
class AgentMessageApprove extends base_command_1.BaseCommand {
|
|
13
|
+
static description = "Approve an Agent's message that is waiting for your approval, and deliver it";
|
|
14
|
+
static examples = [
|
|
15
|
+
'<%= config.bin %> agent message pending --agent <agent-id>',
|
|
16
|
+
'<%= config.bin %> agent message approve <intent-id> --agent <agent-id>',
|
|
17
|
+
];
|
|
18
|
+
static args = {
|
|
19
|
+
intent: core_1.Args.string({ description: 'Intent ID from `agent message pending`', required: true }),
|
|
20
|
+
};
|
|
21
|
+
static flags = {
|
|
22
|
+
agent: core_1.Flags.string({ description: 'Agent ID', required: false }),
|
|
23
|
+
json: core_1.Flags.boolean({ description: 'Output as JSON' }),
|
|
24
|
+
};
|
|
25
|
+
async run() {
|
|
26
|
+
const { args, flags } = await this.parse(AgentMessageApprove);
|
|
27
|
+
const sessionContext = (0, message_intent_1.resolveMessageCommandSessionContext)({
|
|
28
|
+
requireHumanAuth: () => this.requireAuth(),
|
|
29
|
+
});
|
|
30
|
+
if (sessionContext) {
|
|
31
|
+
this.failWithCliError({
|
|
32
|
+
message: 'Only a person can see and decide on messages waiting for approval, not an Agent session.',
|
|
33
|
+
code: 'HUMAN_APPROVAL_REQUIRED',
|
|
34
|
+
exit: 2,
|
|
35
|
+
retryable: false,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
let agentId;
|
|
39
|
+
try {
|
|
40
|
+
const explicitAgentId = (0, agent_resolver_1.mergeExplicitAgentInputs)([
|
|
41
|
+
{ label: '--agent', value: flags.agent },
|
|
42
|
+
]);
|
|
43
|
+
agentId = (await (0, agent_resolver_1.resolveAgentIdentity)(explicitAgentId)).id;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
const failure = (0, agent_resolver_1.agentResolutionFailure)(error);
|
|
47
|
+
this.failWithCliError({
|
|
48
|
+
message: failure.message,
|
|
49
|
+
code: failure.code,
|
|
50
|
+
exit: 2,
|
|
51
|
+
retryable: false,
|
|
52
|
+
details: failure.suggestion ? { suggestion: failure.suggestion } : undefined,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const result = await data_provider_1.dataService.decideAgentDmIntent(agentId, args.intent, 'approve');
|
|
57
|
+
if (flags.json) {
|
|
58
|
+
this.log(JSON.stringify(result, null, 2));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (result.duplicate) {
|
|
62
|
+
this.log(`Nothing to do: that message is already ${result.status}.`);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this.log(`Approved: ${result.intentId} is now ${result.status}${result.reason ? ` (${result.reason})` : ''}.`);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
this.handleApiError(error);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.default = AgentMessageApprove;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base-command';
|
|
2
|
+
/**
|
|
3
|
+
* Decline an Agent's message that is waiting for your approval, and cancel it
|
|
4
|
+
* Only a person can decide: the server refuses an Agent or automation credential (OSK-22364).
|
|
5
|
+
*/
|
|
6
|
+
export default class AgentMessageDecline extends BaseCommand {
|
|
7
|
+
static description: string;
|
|
8
|
+
static examples: string[];
|
|
9
|
+
static args: {
|
|
10
|
+
intent: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
11
|
+
};
|
|
12
|
+
static flags: {
|
|
13
|
+
agent: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
};
|
|
16
|
+
run(): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
5
|
+
const base_command_1 = require("../../../base-command");
|
|
6
|
+
const agent_resolver_1 = require("../../../lib/agent-resolver");
|
|
7
|
+
const message_intent_1 = require("../../../lib/message-intent");
|
|
8
|
+
/**
|
|
9
|
+
* Decline an Agent's message that is waiting for your approval, and cancel it
|
|
10
|
+
* Only a person can decide: the server refuses an Agent or automation credential (OSK-22364).
|
|
11
|
+
*/
|
|
12
|
+
class AgentMessageDecline extends base_command_1.BaseCommand {
|
|
13
|
+
static description = "Decline an Agent's message that is waiting for your approval, and cancel it";
|
|
14
|
+
static examples = [
|
|
15
|
+
'<%= config.bin %> agent message pending --agent <agent-id>',
|
|
16
|
+
'<%= config.bin %> agent message decline <intent-id> --agent <agent-id>',
|
|
17
|
+
];
|
|
18
|
+
static args = {
|
|
19
|
+
intent: core_1.Args.string({ description: 'Intent ID from `agent message pending`', required: true }),
|
|
20
|
+
};
|
|
21
|
+
static flags = {
|
|
22
|
+
agent: core_1.Flags.string({ description: 'Agent ID', required: false }),
|
|
23
|
+
json: core_1.Flags.boolean({ description: 'Output as JSON' }),
|
|
24
|
+
};
|
|
25
|
+
async run() {
|
|
26
|
+
const { args, flags } = await this.parse(AgentMessageDecline);
|
|
27
|
+
const sessionContext = (0, message_intent_1.resolveMessageCommandSessionContext)({
|
|
28
|
+
requireHumanAuth: () => this.requireAuth(),
|
|
29
|
+
});
|
|
30
|
+
if (sessionContext) {
|
|
31
|
+
this.failWithCliError({
|
|
32
|
+
message: 'Only a person can see and decide on messages waiting for approval, not an Agent session.',
|
|
33
|
+
code: 'HUMAN_APPROVAL_REQUIRED',
|
|
34
|
+
exit: 2,
|
|
35
|
+
retryable: false,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
let agentId;
|
|
39
|
+
try {
|
|
40
|
+
const explicitAgentId = (0, agent_resolver_1.mergeExplicitAgentInputs)([
|
|
41
|
+
{ label: '--agent', value: flags.agent },
|
|
42
|
+
]);
|
|
43
|
+
agentId = (await (0, agent_resolver_1.resolveAgentIdentity)(explicitAgentId)).id;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
const failure = (0, agent_resolver_1.agentResolutionFailure)(error);
|
|
47
|
+
this.failWithCliError({
|
|
48
|
+
message: failure.message,
|
|
49
|
+
code: failure.code,
|
|
50
|
+
exit: 2,
|
|
51
|
+
retryable: false,
|
|
52
|
+
details: failure.suggestion ? { suggestion: failure.suggestion } : undefined,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const result = await data_provider_1.dataService.decideAgentDmIntent(agentId, args.intent, 'decline');
|
|
57
|
+
if (flags.json) {
|
|
58
|
+
this.log(JSON.stringify(result, null, 2));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (result.duplicate) {
|
|
62
|
+
this.log(`Nothing to do: that message is already ${result.status}.`);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this.log(`Declined: ${result.intentId} is now ${result.status}${result.reason ? ` (${result.reason})` : ''}.`);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
this.handleApiError(error);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.default = AgentMessageDecline;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base-command';
|
|
2
|
+
/**
|
|
3
|
+
* The owner's view of an Agent's own messages that are waiting on `ask_first`. Without this the
|
|
4
|
+
* Gateway held them and told nobody (OSK-22364): `skrr agent message send` answered
|
|
5
|
+
* `approval_required`, and the message expired six hours later.
|
|
6
|
+
*/
|
|
7
|
+
export default class AgentMessagePending extends BaseCommand {
|
|
8
|
+
static description: string;
|
|
9
|
+
static examples: string[];
|
|
10
|
+
static args: {
|
|
11
|
+
agent: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
12
|
+
};
|
|
13
|
+
static flags: {
|
|
14
|
+
agent: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
};
|
|
17
|
+
run(): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
5
|
+
const base_command_1 = require("../../../base-command");
|
|
6
|
+
const agent_resolver_1 = require("../../../lib/agent-resolver");
|
|
7
|
+
const message_intent_1 = require("../../../lib/message-intent");
|
|
8
|
+
/**
|
|
9
|
+
* The owner's view of an Agent's own messages that are waiting on `ask_first`. Without this the
|
|
10
|
+
* Gateway held them and told nobody (OSK-22364): `skrr agent message send` answered
|
|
11
|
+
* `approval_required`, and the message expired six hours later.
|
|
12
|
+
*/
|
|
13
|
+
class AgentMessagePending extends base_command_1.BaseCommand {
|
|
14
|
+
static description = "List an Agent's own messages that are waiting for your approval because it is set to ask first";
|
|
15
|
+
static examples = [
|
|
16
|
+
'<%= config.bin %> agent message pending --agent <agent-id>',
|
|
17
|
+
'<%= config.bin %> agent message approve <intent-id> --agent <agent-id>',
|
|
18
|
+
];
|
|
19
|
+
static args = {
|
|
20
|
+
agent: core_1.Args.string({ description: 'Agent ID', required: false, ignoreStdin: true }),
|
|
21
|
+
};
|
|
22
|
+
static flags = {
|
|
23
|
+
agent: core_1.Flags.string({ description: 'Agent ID' }),
|
|
24
|
+
json: core_1.Flags.boolean({ description: 'Output as JSON' }),
|
|
25
|
+
};
|
|
26
|
+
async run() {
|
|
27
|
+
const { args, flags } = await this.parse(AgentMessagePending);
|
|
28
|
+
const sessionContext = (0, message_intent_1.resolveMessageCommandSessionContext)({
|
|
29
|
+
requireHumanAuth: () => this.requireAuth(),
|
|
30
|
+
});
|
|
31
|
+
if (sessionContext) {
|
|
32
|
+
this.failWithCliError({
|
|
33
|
+
message: 'Only a person can see and decide on messages waiting for approval, not an Agent session.',
|
|
34
|
+
code: 'HUMAN_APPROVAL_REQUIRED',
|
|
35
|
+
exit: 2,
|
|
36
|
+
retryable: false,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
let agentId;
|
|
40
|
+
try {
|
|
41
|
+
const explicitAgentId = (0, agent_resolver_1.mergeExplicitAgentInputs)([
|
|
42
|
+
{ label: 'agent argument', value: args.agent },
|
|
43
|
+
{ label: '--agent', value: flags.agent },
|
|
44
|
+
]);
|
|
45
|
+
agentId = (await (0, agent_resolver_1.resolveAgentIdentity)(explicitAgentId)).id;
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
const failure = (0, agent_resolver_1.agentResolutionFailure)(error);
|
|
49
|
+
this.failWithCliError({
|
|
50
|
+
message: failure.message,
|
|
51
|
+
code: failure.code,
|
|
52
|
+
exit: 2,
|
|
53
|
+
retryable: false,
|
|
54
|
+
details: failure.suggestion ? { suggestion: failure.suggestion } : undefined,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const result = await data_provider_1.dataService.listAgentDmPendingIntents(agentId);
|
|
59
|
+
if (flags.json) {
|
|
60
|
+
this.log(JSON.stringify(result, null, 2));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (!result.items.length) {
|
|
64
|
+
this.log('Nothing is waiting for your approval.');
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
for (const item of result.items) {
|
|
68
|
+
const expires = item.expiresAt ? ` · expires ${item.expiresAt}` : '';
|
|
69
|
+
this.log(`${item.intentId} [${item.kind ?? 'message'}]${expires}`);
|
|
70
|
+
this.log(` ${item.preview}`);
|
|
71
|
+
}
|
|
72
|
+
this.log(`\nApprove one with: skrr agent message approve <intent-id> --agent ${agentId} (or decline).`);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
this.handleApiError(error);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.default = AgentMessagePending;
|
|
@@ -22,6 +22,43 @@ export declare function agentErasureReport(response: DeleteAgentResponse | undef
|
|
|
22
22
|
* (OSK-22342).
|
|
23
23
|
*/
|
|
24
24
|
export declare function agentRetainedReport(response: DeleteAgentResponse | undefined, bin?: string): string[];
|
|
25
|
+
/**
|
|
26
|
+
* How long to keep reading an agent whose deletion the server accepted but had not finished. The
|
|
27
|
+
* slowest deletions seen under load ran a little over two minutes in all, and the server answers
|
|
28
|
+
* the request about 45 s in.
|
|
29
|
+
*/
|
|
30
|
+
export declare const DELETION_SETTLE_TIMEOUT_MS = 180000;
|
|
31
|
+
/**
|
|
32
|
+
* `409 AGENT_DELETE_IN_PROGRESS`: another request holds the delete lease for this agent. That is the
|
|
33
|
+
* deletion this command is after, running (or abandoned and not yet expired), not a failure to
|
|
34
|
+
* delete.
|
|
35
|
+
*/
|
|
36
|
+
export declare function isDeleteInProgressRefusal(err: unknown): boolean;
|
|
37
|
+
export type DeletionSettlement = {
|
|
38
|
+
/**
|
|
39
|
+
* - `gone` — the agent now reads as not found.
|
|
40
|
+
* - `present` — it still reads, so the deletion has not committed (or failed).
|
|
41
|
+
* - `unreadable` — it could not be read at all in the time given.
|
|
42
|
+
*/
|
|
43
|
+
state: 'gone' | 'present' | 'unreadable';
|
|
44
|
+
waitedMs: number;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Reads the agent until it is not found, or until `timeoutMs` has passed. A failed read is not
|
|
48
|
+
* a verdict: the server may be busy, which is why the deletion is slow, so it is tried again.
|
|
49
|
+
*/
|
|
50
|
+
export declare function waitForAgentGone(agentId: string, options?: {
|
|
51
|
+
timeoutMs?: number;
|
|
52
|
+
intervalMs?: number;
|
|
53
|
+
read?: (agentId: string) => Promise<unknown>;
|
|
54
|
+
sleep?: (ms: number) => Promise<void>;
|
|
55
|
+
now?: () => number;
|
|
56
|
+
onWait?: (waitedMs: number) => void;
|
|
57
|
+
}): Promise<DeletionSettlement>;
|
|
58
|
+
/** What to print once a deletion that outlived its request is seen to be finished. */
|
|
59
|
+
export declare function agentDeletionSettledReport(agentId: string, waitedMs: number): string[];
|
|
60
|
+
/** What to say when the agent still reads after the wait. */
|
|
61
|
+
export declare function agentDeletionUnsettledMessage(agentId: string, waitedMs: number, bin?: string): string;
|
|
25
62
|
export default class AgentsDelete extends BaseCommand {
|
|
26
63
|
static description: string;
|
|
27
64
|
static examples: string[];
|
|
@@ -30,11 +67,19 @@ export default class AgentsDelete extends BaseCommand {
|
|
|
30
67
|
};
|
|
31
68
|
static flags: {
|
|
32
69
|
yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
70
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
33
71
|
};
|
|
34
72
|
/**
|
|
35
73
|
* Which of the two the request is about to do, so the prompt can say so. A
|
|
36
74
|
* failed read is not a reason to refuse: the delete reports its own error.
|
|
37
75
|
*/
|
|
38
76
|
private predictRemoval;
|
|
77
|
+
/**
|
|
78
|
+
* The server did not finish the deletion inside the time a request may wait (it answered `202`),
|
|
79
|
+
* or another request already holds this agent's delete lease. Either way a deletion is running
|
|
80
|
+
* that this command did not see finish, so read the agent until it is gone instead of reporting
|
|
81
|
+
* the hold as a failure of a delete that is succeeding (OSK-21713, OSK-21788).
|
|
82
|
+
*/
|
|
83
|
+
private settleRunningDeletion;
|
|
39
84
|
run(): Promise<void>;
|
|
40
85
|
}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DELETION_SETTLE_TIMEOUT_MS = void 0;
|
|
3
4
|
exports.agentRemovalQuestion = agentRemovalQuestion;
|
|
4
5
|
exports.agentRemovalReport = agentRemovalReport;
|
|
5
6
|
exports.agentErasureReport = agentErasureReport;
|
|
6
7
|
exports.agentRetainedReport = agentRetainedReport;
|
|
8
|
+
exports.isDeleteInProgressRefusal = isDeleteInProgressRefusal;
|
|
9
|
+
exports.waitForAgentGone = waitForAgentGone;
|
|
10
|
+
exports.agentDeletionSettledReport = agentDeletionSettledReport;
|
|
11
|
+
exports.agentDeletionUnsettledMessage = agentDeletionUnsettledMessage;
|
|
7
12
|
const core_1 = require("@oclif/core");
|
|
8
13
|
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
9
14
|
const base_command_1 = require("../../base-command");
|
|
15
|
+
const http_error_1 = require("../../lib/http-error");
|
|
10
16
|
const prompt_1 = require("../../lib/prompt");
|
|
11
17
|
/**
|
|
12
18
|
* The confirmation question. Deleting an agent installed from the store only
|
|
@@ -74,17 +80,80 @@ function agentRetainedReport(response, bin = 'skrr') {
|
|
|
74
80
|
` Archive or reassign them with \`${bin} goals archive <goal-id>\` and \`${bin} tasks\`.`,
|
|
75
81
|
];
|
|
76
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* How long to keep reading an agent whose deletion the server accepted but had not finished. The
|
|
85
|
+
* slowest deletions seen under load ran a little over two minutes in all, and the server answers
|
|
86
|
+
* the request about 45 s in.
|
|
87
|
+
*/
|
|
88
|
+
exports.DELETION_SETTLE_TIMEOUT_MS = 180_000;
|
|
89
|
+
const DELETION_SETTLE_INTERVAL_MS = 3_000;
|
|
90
|
+
/**
|
|
91
|
+
* `409 AGENT_DELETE_IN_PROGRESS`: another request holds the delete lease for this agent. That is the
|
|
92
|
+
* deletion this command is after, running (or abandoned and not yet expired), not a failure to
|
|
93
|
+
* delete.
|
|
94
|
+
*/
|
|
95
|
+
function isDeleteInProgressRefusal(err) {
|
|
96
|
+
return (0, http_error_1.httpBodyOf)(err)?.code === 'AGENT_DELETE_IN_PROGRESS';
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Reads the agent until it is not found, or until `timeoutMs` has passed. A failed read is not
|
|
100
|
+
* a verdict: the server may be busy, which is why the deletion is slow, so it is tried again.
|
|
101
|
+
*/
|
|
102
|
+
async function waitForAgentGone(agentId, options = {}) {
|
|
103
|
+
const timeoutMs = options.timeoutMs ?? exports.DELETION_SETTLE_TIMEOUT_MS;
|
|
104
|
+
const intervalMs = options.intervalMs ?? DELETION_SETTLE_INTERVAL_MS;
|
|
105
|
+
const read = options.read ?? ((id) => data_provider_1.dataService.getAgentById({ agent_id: id }));
|
|
106
|
+
const sleep = options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
107
|
+
const now = options.now ?? Date.now;
|
|
108
|
+
const startedAt = now();
|
|
109
|
+
let state = 'unreadable';
|
|
110
|
+
for (;;) {
|
|
111
|
+
try {
|
|
112
|
+
await read(agentId);
|
|
113
|
+
state = 'present';
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
if ((0, http_error_1.isHttpNotFound)(err))
|
|
117
|
+
return { state: 'gone', waitedMs: now() - startedAt };
|
|
118
|
+
}
|
|
119
|
+
const waitedMs = now() - startedAt;
|
|
120
|
+
if (waitedMs >= timeoutMs)
|
|
121
|
+
return { state, waitedMs };
|
|
122
|
+
options.onWait?.(waitedMs);
|
|
123
|
+
await sleep(Math.min(intervalMs, timeoutMs - waitedMs));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/** What to print once a deletion that outlived its request is seen to be finished. */
|
|
127
|
+
function agentDeletionSettledReport(agentId, waitedMs) {
|
|
128
|
+
return [
|
|
129
|
+
`Deleted agent ${agentId}`,
|
|
130
|
+
`The deletion finished ${Math.round(waitedMs / 1000)}s after the server answered the request, so no erasure receipt came back with it.`,
|
|
131
|
+
'Personal Context erasure: not confirmed. The agent is gone; that does not confirm that data derived from it has been erased.',
|
|
132
|
+
];
|
|
133
|
+
}
|
|
134
|
+
/** What to say when the agent still reads after the wait. */
|
|
135
|
+
function agentDeletionUnsettledMessage(agentId, waitedMs, bin = 'skrr') {
|
|
136
|
+
return [
|
|
137
|
+
`Agent ${agentId} is still there after ${Math.round(waitedMs / 1000)}s. The server has not finished deleting it: a deletion may still be running, or an earlier one's hold may not have expired yet.`,
|
|
138
|
+
`Read it with \`${bin} agents show ${agentId}\`; it reads as not found once it is gone.`,
|
|
139
|
+
`Running \`${bin} agents delete ${agentId}\` again is safe: while the first deletion is running it is refused as already in progress, and if the first one failed it starts a new attempt.`,
|
|
140
|
+
].join('\n');
|
|
141
|
+
}
|
|
77
142
|
class AgentsDelete extends base_command_1.BaseCommand {
|
|
78
143
|
static description = 'Delete an agent you created (irreversible), or uninstall one installed from the store (reinstalling restores it)';
|
|
79
144
|
static examples = [
|
|
80
145
|
'<%= config.bin %> agents delete <agent-id>',
|
|
81
146
|
'<%= config.bin %> agents delete <agent-id> --yes',
|
|
147
|
+
'<%= config.bin %> agents delete <agent-id> --yes --json',
|
|
82
148
|
];
|
|
83
149
|
static args = {
|
|
84
150
|
id: core_1.Args.string({ description: 'Agent ID', required: true, ignoreStdin: true }),
|
|
85
151
|
};
|
|
86
152
|
static flags = {
|
|
87
153
|
yes: core_1.Flags.boolean({ char: 'y', description: 'Skip confirmation prompt' }),
|
|
154
|
+
json: core_1.Flags.boolean({
|
|
155
|
+
description: "Output the receipt as JSON: what was done (`removal`) and the server's own erasure and retained-work report. Pair with --yes in scripts.",
|
|
156
|
+
}),
|
|
88
157
|
};
|
|
89
158
|
/**
|
|
90
159
|
* Which of the two the request is about to do, so the prompt can say so. A
|
|
@@ -98,6 +167,58 @@ class AgentsDelete extends base_command_1.BaseCommand {
|
|
|
98
167
|
return null;
|
|
99
168
|
}
|
|
100
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* The server did not finish the deletion inside the time a request may wait (it answered `202`),
|
|
172
|
+
* or another request already holds this agent's delete lease. Either way a deletion is running
|
|
173
|
+
* that this command did not see finish, so read the agent until it is gone instead of reporting
|
|
174
|
+
* the hold as a failure of a delete that is succeeding (OSK-21713, OSK-21788).
|
|
175
|
+
*/
|
|
176
|
+
async settleRunningDeletion(agentId, alreadyRunning, json) {
|
|
177
|
+
if (!json) {
|
|
178
|
+
this.log(alreadyRunning
|
|
179
|
+
? `A deletion of agent ${agentId} is already running on the server. Waiting for it to finish...`
|
|
180
|
+
: `Deleting agent ${agentId} is taking longer than a request may wait, so it continues on the server. Waiting for it to finish...`);
|
|
181
|
+
}
|
|
182
|
+
let lastReported = 0;
|
|
183
|
+
const settled = await waitForAgentGone(agentId, {
|
|
184
|
+
onWait: (waitedMs) => {
|
|
185
|
+
if (json || waitedMs - lastReported < 30_000)
|
|
186
|
+
return;
|
|
187
|
+
lastReported = waitedMs;
|
|
188
|
+
this.log(`Still deleting after ${Math.round(waitedMs / 1000)}s...`);
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
if (settled.state === 'gone') {
|
|
192
|
+
if (json) {
|
|
193
|
+
// No erasure object: the receipt belonged to the request that started the deletion, which
|
|
194
|
+
// had already been answered. A script must not read its absence as erased.
|
|
195
|
+
this.printJsonResult({
|
|
196
|
+
agentId,
|
|
197
|
+
removal: 'deleted',
|
|
198
|
+
deletion: 'finished_after_response',
|
|
199
|
+
waitedMs: settled.waitedMs,
|
|
200
|
+
erasureReceipt: 'unavailable',
|
|
201
|
+
});
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
for (const line of agentDeletionSettledReport(agentId, settled.waitedMs))
|
|
205
|
+
this.log(line);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
if (json) {
|
|
209
|
+
this.printJsonResult({
|
|
210
|
+
agentId,
|
|
211
|
+
removal: null,
|
|
212
|
+
deletion: 'running',
|
|
213
|
+
agentReadable: settled.state === 'present',
|
|
214
|
+
waitedMs: settled.waitedMs,
|
|
215
|
+
}, { ok: false });
|
|
216
|
+
this.exit(1);
|
|
217
|
+
}
|
|
218
|
+
this.error(agentDeletionUnsettledMessage(agentId, settled.waitedMs, this.config.bin), {
|
|
219
|
+
exit: 1,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
101
222
|
async run() {
|
|
102
223
|
this.requireAuth();
|
|
103
224
|
const { args, flags } = await this.parse(AgentsDelete);
|
|
@@ -114,15 +235,31 @@ class AgentsDelete extends base_command_1.BaseCommand {
|
|
|
114
235
|
throw err;
|
|
115
236
|
}
|
|
116
237
|
if (!ok) {
|
|
117
|
-
|
|
238
|
+
if (flags.json)
|
|
239
|
+
this.printJsonResult({ agentId: args.id, cancelled: true }, { ok: false });
|
|
240
|
+
else
|
|
241
|
+
this.log('Cancelled.');
|
|
118
242
|
return;
|
|
119
243
|
}
|
|
120
244
|
let response;
|
|
245
|
+
let alreadyRunning = false;
|
|
121
246
|
try {
|
|
122
247
|
response = await data_provider_1.dataService.deleteAgent({ agent_id: args.id });
|
|
123
248
|
}
|
|
124
249
|
catch (err) {
|
|
125
|
-
|
|
250
|
+
if (!isDeleteInProgressRefusal(err))
|
|
251
|
+
this.handleApiError(err);
|
|
252
|
+
alreadyRunning = true;
|
|
253
|
+
}
|
|
254
|
+
if (alreadyRunning || (0, data_provider_1.agentDeletionPending)(response)) {
|
|
255
|
+
await this.settleRunningDeletion(args.id, alreadyRunning, Boolean(flags.json));
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
if (flags.json) {
|
|
259
|
+
// The server's own report, unabridged: a script needs the erasure state and the retained
|
|
260
|
+
// work as data, not as the sentences a person reads below.
|
|
261
|
+
this.printJsonResult({ agentId: args.id, removal: (0, data_provider_1.agentRemovalKind)(response), ...response });
|
|
262
|
+
return;
|
|
126
263
|
}
|
|
127
264
|
this.log(agentRemovalReport(args.id, response));
|
|
128
265
|
for (const line of agentErasureReport(response))
|