@skrr-ai/cli 0.1.231 → 0.1.232
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 +22 -0
- package/bin/dev.cjs +4 -0
- package/dist/base-command.d.ts +0 -10
- package/dist/base-command.js +10 -39
- package/dist/commands/agent/message/context.d.ts +2 -0
- package/dist/commands/agent/message/context.js +18 -3
- package/dist/commands/agent/message/list.d.ts +22 -0
- package/dist/commands/agent/message/list.js +66 -0
- package/dist/commands/agent/message/send.d.ts +1 -1
- package/dist/commands/agent/message/send.js +1 -3
- package/dist/commands/agent/message/show.d.ts +14 -0
- package/dist/commands/agent/message/show.js +39 -0
- package/dist/commands/agents/chat.d.ts +2 -0
- package/dist/commands/agents/chat.js +20 -4
- package/dist/commands/agents/eval/show.d.ts +1 -0
- package/dist/commands/agents/eval/show.js +19 -0
- package/dist/commands/agents/intuitions/generate.js +1 -1
- package/dist/commands/agents/intuitions/list.js +1 -1
- package/dist/commands/code/acp.js +1 -1
- package/dist/commands/code/handover.d.ts +3 -3
- package/dist/commands/code/handover.js +12 -12
- package/dist/commands/code/index.d.ts +3 -8
- package/dist/commands/code/index.js +15 -21
- package/dist/commands/code/jobs/show.js +1 -0
- package/dist/commands/code/run.js +1 -1
- package/dist/commands/goals/plan-now.d.ts +5 -3
- package/dist/commands/goals/plan-now.js +21 -16
- package/dist/commands/runs/events.d.ts +14 -0
- package/dist/commands/runs/events.js +59 -0
- package/dist/commands/runs/list.d.ts +21 -0
- package/dist/commands/runs/list.js +87 -0
- package/dist/commands/runs/show.d.ts +13 -0
- package/dist/commands/runs/show.js +63 -0
- package/dist/commands/runs/stop.d.ts +14 -0
- package/dist/commands/runs/stop.js +78 -0
- package/dist/commands/runs/transcript.d.ts +17 -0
- package/dist/commands/runs/transcript.js +93 -0
- package/dist/commands/tasks/runs.js +7 -0
- package/dist/commands/tasks/start-receipt.js +8 -8
- package/dist/commands/tasks/start.js +12 -1
- package/dist/generated/agent-guides.json +226 -5
- package/dist/lib/agent-chat-queue.d.ts +2 -1
- package/dist/lib/agent-chat-queue.js +26 -21
- package/dist/lib/agent-runs.d.ts +41 -0
- package/dist/lib/agent-runs.js +177 -0
- package/dist/lib/agentic-stream.d.ts +1 -1
- package/dist/lib/agentic-stream.js +2 -2
- package/dist/lib/api-fetch.d.ts +2 -2
- package/dist/lib/api-fetch.js +5 -4
- package/dist/lib/code-handover.d.ts +2 -3
- package/dist/lib/code-handover.js +4 -6
- package/dist/lib/communication-history.d.ts +27 -0
- package/dist/lib/communication-history.js +45 -0
- package/dist/lib/execution-history.d.ts +31 -0
- package/dist/lib/execution-history.js +7 -0
- package/dist/lib/first-party-harness-broker.d.ts +1 -1
- package/dist/lib/first-party-harness-broker.js +3 -5
- package/dist/lib/inbound-messages.d.ts +1 -0
- package/dist/lib/inbound-messages.js +3 -0
- package/dist/lib/intuition-look.js +20 -4
- package/dist/lib/memory-history-session.d.ts +8 -4
- package/dist/lib/memory-history-session.js +30 -23
- package/dist/lib/task-agent-run.d.ts +4 -0
- package/dist/lib/task-agent-run.js +15 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonWire.d.ts +9 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonWire.js +35 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/toolApprovalSignature.d.ts +62 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/toolApprovalSignature.js +56 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonWire.d.ts +9 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonWire.js +29 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/toolApprovalSignature.d.ts +62 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/toolApprovalSignature.js +51 -0
- package/dist/node_modules/@skrr-ai/data-provider/index.js +10997 -10987
- package/oclif.manifest.json +1065 -1648
- package/package.json +5 -2
|
@@ -16,10 +16,10 @@ const first_party_harness_1 = require("../../lib/first-party-harness");
|
|
|
16
16
|
*
|
|
17
17
|
* The interactive session's transcript lives inside the engine, which
|
|
18
18
|
* is a separately released binary (`resolveEngine` in `lib/first-party-harness.ts`), and
|
|
19
|
-
* the server holds none of it: a managed
|
|
19
|
+
* the server holds none of it: a local engine with managed inference calls
|
|
20
20
|
* `/api/agentic/sessions/:id/inference/{admit,release}` and the token endpoints,
|
|
21
|
-
* never `/ingest`.
|
|
22
|
-
*
|
|
21
|
+
* never `/ingest`. The brief comes from the human and the workspace context
|
|
22
|
+
* comes from git. An explicit transcript export can supply more context.
|
|
23
23
|
*
|
|
24
24
|
* ── Why it dispatches a Cloud Coding task ──────────────────────────────────
|
|
25
25
|
*
|
|
@@ -47,8 +47,7 @@ const first_party_harness_1 = require("../../lib/first-party-harness");
|
|
|
47
47
|
* the pull request. This refuses by default and says what to do.
|
|
48
48
|
*/
|
|
49
49
|
class CodeHandover extends base_command_1.BaseCommand {
|
|
50
|
-
static description = '
|
|
51
|
-
'(--carry-session also carries the engine session transcript, when the engine supports export)';
|
|
50
|
+
static description = 'Start a new cloud Run for the work in this directory. Use --carry-session to include the local transcript as context.';
|
|
52
51
|
static examples = [
|
|
53
52
|
'<%= config.bin %> code handover --to "Frontend Agent" --brief "finish the bundle-size fix"',
|
|
54
53
|
'<%= config.bin %> code handover --to agent_abc --brief "continue the parser refactor" --base main',
|
|
@@ -170,14 +169,13 @@ class CodeHandover extends base_command_1.BaseCommand {
|
|
|
170
169
|
` ${failure.detail}\n` +
|
|
171
170
|
' Re-run without --carry-session to hand over the situation only, or upgrade the engine.');
|
|
172
171
|
}
|
|
173
|
-
const envelope = (0, code_handover_1.parseSessionExportEnvelope)(stdout);
|
|
172
|
+
const envelope = (0, code_handover_1.parseSessionExportEnvelope)(stdout, sessionId);
|
|
174
173
|
if (!envelope) {
|
|
175
174
|
// Exit 0 but no contract envelope is a deviation, not a success: the
|
|
176
175
|
// one shape this side may depend on (C2) did not arrive, so attaching
|
|
177
176
|
// the output anyway would be guessing with someone else's session.
|
|
178
|
-
this.error('The engine
|
|
179
|
-
'
|
|
180
|
-
'the export contract, so nothing was attached.');
|
|
177
|
+
this.error('The engine returned an invalid transcript for the requested session. ' +
|
|
178
|
+
'Check the session ID and engine version before starting the cloud job.');
|
|
181
179
|
}
|
|
182
180
|
// The endpoint's prompt cap is 50000 chars; the transcript gets what the
|
|
183
181
|
// brief and the git context leave behind.
|
|
@@ -261,11 +259,13 @@ class CodeHandover extends base_command_1.BaseCommand {
|
|
|
261
259
|
this.log(JSON.stringify(result, null, 2));
|
|
262
260
|
return;
|
|
263
261
|
}
|
|
264
|
-
const task = result?.task
|
|
262
|
+
const task = result?.task;
|
|
265
263
|
this.log(`Handed over to ${target.name ?? target.id}`);
|
|
266
264
|
this.log(` repo ${repoFullName}@${branch}`);
|
|
267
|
-
this.log(` task ${
|
|
268
|
-
|
|
265
|
+
this.log(` task ${task?.id ?? '?'} (${task?.status ?? 'queued'})`);
|
|
266
|
+
if (task?.runId)
|
|
267
|
+
this.log(` run ${task.runId}`);
|
|
268
|
+
const url = task?.previewUrl ?? task?.prUrl;
|
|
269
269
|
if (url)
|
|
270
270
|
this.log(` ${String(url)}`);
|
|
271
271
|
if (sessionExport) {
|
|
@@ -29,15 +29,10 @@ export default class Code extends Command {
|
|
|
29
29
|
* engine is not installed, and `77`, the account was refused before the engine
|
|
30
30
|
* could start (OSK-8822).
|
|
31
31
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* `skrr code acp` must NOT take the managed path: the daemon that drives it already
|
|
35
|
-
* brokers inference, and a second broker would double-wrap the relay. Opting in
|
|
36
|
-
* per command rather than defaulting on means a future `skrr code <something>` can
|
|
37
|
-
* only acquire a lease if someone decided it should — the failure mode of the
|
|
38
|
-
* other arrangement is a new subcommand silently spending money.
|
|
32
|
+
* The standalone TUI and headless engine acquire inference leases for the local
|
|
33
|
+
* process. The daemon's ACP launch already has its own broker and execution authority.
|
|
39
34
|
*/
|
|
40
35
|
export declare function forwardToEngine(cmd: Command, subcommand: string | null, passthrough: string[], options?: {
|
|
41
|
-
|
|
36
|
+
brokerInference?: boolean;
|
|
42
37
|
projectPolicy?: 'tui' | 'headless';
|
|
43
38
|
}): Promise<void>;
|
|
@@ -32,7 +32,7 @@ class Code extends core_1.Command {
|
|
|
32
32
|
static description = 'Everything after ' +
|
|
33
33
|
`\`code\` is forwarded to the engine unchanged, so engine flags are not listed here — ` +
|
|
34
34
|
`run \`${auth_core_1.FIRST_PARTY_HARNESS.command} run --help\` for this wrapper, or the engine's own help for its ` +
|
|
35
|
-
`flags. This wrapper consumes three flags itself: ${first_party_harness_managed_1.SKRR_AGENT_FLAG}, ` +
|
|
35
|
+
`flags. This wrapper consumes three flags itself: ${first_party_harness_managed_1.SKRR_AGENT_FLAG} (choose the agent for inference billing), ` +
|
|
36
36
|
`${first_party_harness_project_trust_1.TRUST_PROJECT_FLAG} (load this project's own configuration — plugins, tools, MCP ` +
|
|
37
37
|
`servers, permissions — which is otherwise NOT loaded until you trust the project; ` +
|
|
38
38
|
`the TUI asks once when a project ships any), and ${first_party_harness_project_trust_1.ENGINE_PERMISSIONS_FLAG} (let your ` +
|
|
@@ -62,7 +62,7 @@ class Code extends core_1.Command {
|
|
|
62
62
|
//
|
|
63
63
|
// The unit tests did not catch it because they cover `buildEngineArgs`, which
|
|
64
64
|
// always forwarded verbatim. The args never reached it.
|
|
65
|
-
await forwardToEngine(this, null, this.argv, {
|
|
65
|
+
await forwardToEngine(this, null, this.argv, { brokerInference: true, projectPolicy: 'tui' });
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
exports.default = Code;
|
|
@@ -78,13 +78,8 @@ exports.default = Code;
|
|
|
78
78
|
* engine is not installed, and `77`, the account was refused before the engine
|
|
79
79
|
* could start (OSK-8822).
|
|
80
80
|
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* `skrr code acp` must NOT take the managed path: the daemon that drives it already
|
|
84
|
-
* brokers inference, and a second broker would double-wrap the relay. Opting in
|
|
85
|
-
* per command rather than defaulting on means a future `skrr code <something>` can
|
|
86
|
-
* only acquire a lease if someone decided it should — the failure mode of the
|
|
87
|
-
* other arrangement is a new subcommand silently spending money.
|
|
81
|
+
* The standalone TUI and headless engine acquire inference leases for the local
|
|
82
|
+
* process. The daemon's ACP launch already has its own broker and execution authority.
|
|
88
83
|
*/
|
|
89
84
|
async function forwardToEngine(cmd, subcommand, passthrough, options = {}) {
|
|
90
85
|
// Unconditional: the engine must never see a flag it does not declare, whether
|
|
@@ -98,9 +93,8 @@ async function forwardToEngine(cmd, subcommand, passthrough, options = {}) {
|
|
|
98
93
|
if (subcommand === null && options.projectPolicy === 'tui') {
|
|
99
94
|
await (0, first_party_harness_startup_update_1.maybeOfferCodeUpdate)({ argv: engineArgv, say });
|
|
100
95
|
}
|
|
101
|
-
if (agentRef && !options.
|
|
102
|
-
say(`${first_party_harness_managed_1.SKRR_AGENT_FLAG} has no effect here
|
|
103
|
-
'session. It was removed from the arguments passed to the engine.');
|
|
96
|
+
if (agentRef && !options.brokerInference) {
|
|
97
|
+
say(`${first_party_harness_managed_1.SKRR_AGENT_FLAG} has no effect here. The launcher supplies this command's inference configuration.`);
|
|
104
98
|
}
|
|
105
99
|
// OSK-11958 — the project's own configuration can run code on this machine
|
|
106
100
|
// and loosen permissions, so it is not loaded until the person trusts the
|
|
@@ -127,9 +121,9 @@ async function forwardToEngine(cmd, subcommand, passthrough, options = {}) {
|
|
|
127
121
|
say(notice);
|
|
128
122
|
// Code forwards engine flags verbatim and does not extend BaseCommand. Resolve
|
|
129
123
|
// the same env or locked profile before the broker reads the saved credential.
|
|
130
|
-
if (options.
|
|
124
|
+
if (options.brokerInference)
|
|
131
125
|
(0, keychain_1.selectActiveProfile)(null);
|
|
132
|
-
const
|
|
126
|
+
const inference = options.brokerInference
|
|
133
127
|
? (0, first_party_harness_broker_1.createManagedEngineHooks)({
|
|
134
128
|
subcommand,
|
|
135
129
|
passthrough: engineArgv,
|
|
@@ -138,15 +132,15 @@ async function forwardToEngine(cmd, subcommand, passthrough, options = {}) {
|
|
|
138
132
|
})
|
|
139
133
|
: null;
|
|
140
134
|
try {
|
|
141
|
-
const code = await (0, first_party_harness_1.execEngine)((0, first_party_harness_1.buildEngineArgs)(subcommand, engineArgv), process.env,
|
|
135
|
+
const code = await (0, first_party_harness_1.execEngine)((0, first_party_harness_1.buildEngineArgs)(subcommand, engineArgv), process.env, inference
|
|
142
136
|
? {
|
|
143
|
-
prepare:
|
|
144
|
-
cleanup:
|
|
145
|
-
finalizeArgs:
|
|
137
|
+
prepare: inference.prepare,
|
|
138
|
+
cleanup: inference.cleanup,
|
|
139
|
+
finalizeArgs: inference.finalizeArgs,
|
|
146
140
|
// Not `() => true`: this command only ATTEMPTS acquisition, and a
|
|
147
141
|
// skipped or failed attempt is a genuine BYOK run whose credential is
|
|
148
142
|
// the ambient one. Only the hooks know which happened.
|
|
149
|
-
credentialMode:
|
|
143
|
+
credentialMode: inference.credentialMode,
|
|
150
144
|
policyEnv: policy?.env,
|
|
151
145
|
}
|
|
152
146
|
: { policyEnv: policy?.env });
|
|
@@ -156,8 +150,8 @@ async function forwardToEngine(cmd, subcommand, passthrough, options = {}) {
|
|
|
156
150
|
// the user can act on. The prepare-time warning already diagnosed this;
|
|
157
151
|
// say it again where the failure lands, because a warning scrolled past
|
|
158
152
|
// is not a diagnosis at the point of failure (OSK-11949).
|
|
159
|
-
if (
|
|
160
|
-
say('
|
|
153
|
+
if (inference?.unprovisionedByok()) {
|
|
154
|
+
say('The engine started without an inference lease or a provider credential. If ' +
|
|
161
155
|
'the failure above is an authentication or server error, sign in with ' +
|
|
162
156
|
'`skrr login` or set OPENROUTER_API_KEY and retry.');
|
|
163
157
|
}
|
|
@@ -40,6 +40,7 @@ class CodeJobsShow extends base_command_1.BaseCommand {
|
|
|
40
40
|
this.log(`${label.padEnd(14)}${String(value)}`);
|
|
41
41
|
};
|
|
42
42
|
line('ID:', task.id);
|
|
43
|
+
line('Agent Run:', task.runId);
|
|
43
44
|
line('Status:', task.status);
|
|
44
45
|
line('Agent:', task.agentId);
|
|
45
46
|
if (task.repoFullName) {
|
|
@@ -35,7 +35,7 @@ class CodeRun extends core_1.Command {
|
|
|
35
35
|
// `headless`: project configuration is gated exactly as for the TUI, but
|
|
36
36
|
// nobody is asked and the engine keeps its own permission config — an `ask`
|
|
37
37
|
// default would be auto-rejected by a headless run (OSK-11958).
|
|
38
|
-
await (0, index_1.forwardToEngine)(this, 'run', this.argv, {
|
|
38
|
+
await (0, index_1.forwardToEngine)(this, 'run', this.argv, { brokerInference: true, projectPolicy: 'headless' });
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
exports.default = CodeRun;
|
|
@@ -42,14 +42,15 @@ export declare function isPlannerRequestTimeout(err: unknown): boolean;
|
|
|
42
42
|
* dangerous half, because it invites a retry of a non-idempotent, task-creating,
|
|
43
43
|
* billable operation.
|
|
44
44
|
*
|
|
45
|
-
* A
|
|
46
|
-
*
|
|
47
|
-
* that CAN answer it.
|
|
45
|
+
* A timeout leaves the result unknown. Repeating the original command with
|
|
46
|
+
* its key can recover the same planner tick.
|
|
48
47
|
*/
|
|
49
48
|
export declare function plannerTimeoutMessage(opts: {
|
|
50
49
|
goalId: string;
|
|
51
50
|
status: number;
|
|
52
51
|
bin: string;
|
|
52
|
+
spaceId?: string;
|
|
53
|
+
idempotencyKey: string;
|
|
53
54
|
}): string;
|
|
54
55
|
/**
|
|
55
56
|
* `skrr goals plan-now <goal-id>` — run a single planner tick immediately,
|
|
@@ -75,6 +76,7 @@ export default class GoalsPlanNow extends BaseCommand {
|
|
|
75
76
|
};
|
|
76
77
|
static flags: {
|
|
77
78
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
79
|
+
'idempotency-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
78
80
|
space: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
79
81
|
};
|
|
80
82
|
run(): Promise<void>;
|
|
@@ -5,6 +5,7 @@ exports.plannerTickDidNotRun = plannerTickDidNotRun;
|
|
|
5
5
|
exports.plannerTickAccepted = plannerTickAccepted;
|
|
6
6
|
exports.isPlannerRequestTimeout = isPlannerRequestTimeout;
|
|
7
7
|
exports.plannerTimeoutMessage = plannerTimeoutMessage;
|
|
8
|
+
const node_crypto_1 = require("node:crypto");
|
|
8
9
|
const core_1 = require("@oclif/core");
|
|
9
10
|
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
10
11
|
const base_command_1 = require("../../base-command");
|
|
@@ -119,18 +120,17 @@ function isPlannerRequestTimeout(err) {
|
|
|
119
120
|
* dangerous half, because it invites a retry of a non-idempotent, task-creating,
|
|
120
121
|
* billable operation.
|
|
121
122
|
*
|
|
122
|
-
* A
|
|
123
|
-
*
|
|
124
|
-
* that CAN answer it.
|
|
123
|
+
* A timeout leaves the result unknown. Repeating the original command with
|
|
124
|
+
* its key can recover the same planner tick.
|
|
125
125
|
*/
|
|
126
126
|
function plannerTimeoutMessage(opts) {
|
|
127
|
-
const { goalId, status, bin } = opts;
|
|
127
|
+
const { goalId, status, bin, spaceId, idempotencyKey } = opts;
|
|
128
|
+
const original = `${bin} goals plan-now ${goalId} --idempotency-key ${idempotencyKey}` +
|
|
129
|
+
(spaceId ? ` --space ${spaceId}` : '');
|
|
128
130
|
return (`The planner tick for goal ${goalId} outlived this request (HTTP ${status}). ` +
|
|
129
|
-
'
|
|
130
|
-
|
|
131
|
-
`
|
|
132
|
-
`running — or \`${bin} goals tasks ${goalId}\` to see what it produced. ` +
|
|
133
|
-
'Do not retry blindly: a second tick is a second billable agent run.');
|
|
131
|
+
'The tick may still be running and creating tasks. ' +
|
|
132
|
+
`Retry this request with \`${original}\`. ` +
|
|
133
|
+
`Use \`${bin} goals tasks ${goalId}\` to see the goal's tasks.`);
|
|
134
134
|
}
|
|
135
135
|
/**
|
|
136
136
|
* `skrr goals plan-now <goal-id>` — run a single planner tick immediately,
|
|
@@ -160,6 +160,7 @@ class GoalsPlanNow extends base_command_1.BaseCommand {
|
|
|
160
160
|
};
|
|
161
161
|
static flags = {
|
|
162
162
|
json: core_1.Flags.boolean({ description: 'Output the planner result as JSON' }),
|
|
163
|
+
'idempotency-key': core_1.Flags.string({ description: 'Reuse the key from the original plan request' }),
|
|
163
164
|
space: core_1.Flags.string({
|
|
164
165
|
description: "Scope created tasks to this space (also backfills spaceId on the goal's existing tasks)",
|
|
165
166
|
}),
|
|
@@ -167,16 +168,19 @@ class GoalsPlanNow extends base_command_1.BaseCommand {
|
|
|
167
168
|
async run() {
|
|
168
169
|
this.requireAuth();
|
|
169
170
|
const { args, flags } = await this.parse(GoalsPlanNow);
|
|
171
|
+
const idempotencyKey = flags['idempotency-key'] ?? `goal-plan:${(0, node_crypto_1.randomUUID)()}`;
|
|
170
172
|
// A tick is an LLM run; minutes of silence is normal and used to be
|
|
171
173
|
// indistinguishable from a hung command. stderr, so `--json` stdout stays a
|
|
172
174
|
// single parseable document.
|
|
173
175
|
this.logToStderr(`Running one planner tick for goal ${args.id}. This is a live agent turn and can take minutes.`);
|
|
174
176
|
let result;
|
|
175
177
|
try {
|
|
176
|
-
result = await data_provider_1.dataService.planGoalNow(args.id, flags.space ? { spaceId: flags.space } : {}
|
|
178
|
+
result = await data_provider_1.dataService.planGoalNow(args.id, flags.space ? { spaceId: flags.space } : {}, {
|
|
179
|
+
idempotencyKey,
|
|
180
|
+
});
|
|
177
181
|
}
|
|
178
182
|
catch (err) {
|
|
179
|
-
this.failIfRequestTimedOut(err, args.id);
|
|
183
|
+
this.failIfRequestTimedOut(err, args.id, idempotencyKey, flags.space);
|
|
180
184
|
this.handleApiError(err);
|
|
181
185
|
}
|
|
182
186
|
const r = result;
|
|
@@ -191,6 +195,8 @@ class GoalsPlanNow extends base_command_1.BaseCommand {
|
|
|
191
195
|
return;
|
|
192
196
|
}
|
|
193
197
|
this.log(`Planner tick accepted for goal ${args.id} — running in the background.`);
|
|
198
|
+
if (r.tickId)
|
|
199
|
+
this.log(` tick: ${r.tickId}`);
|
|
194
200
|
if (r.backfilledCount) {
|
|
195
201
|
this.log(` backfilled: ${r.backfilledCount} existing task(s) tagged to the space.`);
|
|
196
202
|
}
|
|
@@ -243,18 +249,17 @@ class GoalsPlanNow extends base_command_1.BaseCommand {
|
|
|
243
249
|
}
|
|
244
250
|
}
|
|
245
251
|
/** A gateway timeout on THIS request, reported as what it is. */
|
|
246
|
-
failIfRequestTimedOut(err, goalId) {
|
|
252
|
+
failIfRequestTimedOut(err, goalId, idempotencyKey, spaceId) {
|
|
247
253
|
if (!isPlannerRequestTimeout(err))
|
|
248
254
|
return;
|
|
249
255
|
const status = err.status;
|
|
250
256
|
this.failWithCliError({
|
|
251
|
-
message: plannerTimeoutMessage({ goalId, status, bin: this.config.bin }),
|
|
257
|
+
message: plannerTimeoutMessage({ goalId, status, bin: this.config.bin, spaceId, idempotencyKey }),
|
|
252
258
|
code: 'PLANNER_TICK_TIMED_OUT',
|
|
253
259
|
status,
|
|
254
260
|
exit: 5,
|
|
255
|
-
|
|
256
|
-
//
|
|
257
|
-
// this as "safe to send again".
|
|
261
|
+
details: { idempotencyKey },
|
|
262
|
+
// Automatically invoking the command again could mint a fresh key.
|
|
258
263
|
retryable: false,
|
|
259
264
|
});
|
|
260
265
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command';
|
|
2
|
+
export default class RunsEvents extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
runId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
cursor: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
limit: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
};
|
|
13
|
+
run(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_command_1 = require("../../base-command");
|
|
5
|
+
const agent_runs_1 = require("../../lib/agent-runs");
|
|
6
|
+
const http_error_1 = require("../../lib/http-error");
|
|
7
|
+
class RunsEvents extends base_command_1.BaseCommand {
|
|
8
|
+
static description = 'Read the current Run snapshot or replay lifecycle events after a cursor';
|
|
9
|
+
static examples = [
|
|
10
|
+
'<%= config.bin %> runs events <run-id>',
|
|
11
|
+
'<%= config.bin %> runs events <run-id> --cursor <cursor> --json',
|
|
12
|
+
];
|
|
13
|
+
static args = { runId: agent_runs_1.runIdArgument };
|
|
14
|
+
static flags = {
|
|
15
|
+
cursor: core_1.Flags.string({ description: 'Resume from the cursor returned by an earlier read' }),
|
|
16
|
+
limit: core_1.Flags.integer({ description: 'Maximum events in a replay page (1–100)', min: 1, max: 100 }),
|
|
17
|
+
json: core_1.Flags.boolean({ description: 'Output as JSON' }),
|
|
18
|
+
};
|
|
19
|
+
async run() {
|
|
20
|
+
this.requireAuth();
|
|
21
|
+
const { args, flags } = await this.parse(RunsEvents);
|
|
22
|
+
try {
|
|
23
|
+
const page = await (0, agent_runs_1.readAgentRunEvents)(args.runId, flags);
|
|
24
|
+
if (flags.json) {
|
|
25
|
+
this.log(JSON.stringify(page, null, 2));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
this.log(`Run ${page.runId}`);
|
|
29
|
+
if (page.snapshot) {
|
|
30
|
+
this.log(`Status: ${page.snapshot.status} (sequence ${page.snapshot.sequence})`);
|
|
31
|
+
if (page.snapshot.activeAttemptId) {
|
|
32
|
+
this.log(`Active Attempt: ${page.snapshot.activeAttemptId}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
for (const event of page.events) {
|
|
36
|
+
const context = [event.status, event.attemptId].filter(Boolean).join(' · ');
|
|
37
|
+
this.log(`${event.sequence} ${event.observedAt} ${event.type}${context ? ` (${context})` : ''}`);
|
|
38
|
+
}
|
|
39
|
+
if (!page.snapshot && !page.events.length)
|
|
40
|
+
this.log('No new events.');
|
|
41
|
+
if (page.hasMore)
|
|
42
|
+
this.log('More events are available.');
|
|
43
|
+
this.log(`Cursor: ${page.cursor}`);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
if ((0, http_error_1.httpStatusOf)(error) === 410) {
|
|
47
|
+
this.failWithCliError({
|
|
48
|
+
code: 'RUN_HISTORY_EVENT_CURSOR_STALE',
|
|
49
|
+
message: `The event cursor expired or is no longer valid. Get a fresh snapshot with ${this.config.bin} runs events ${args.runId}.`,
|
|
50
|
+
status: 410,
|
|
51
|
+
exit: 1,
|
|
52
|
+
retryable: false,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
this.handleApiError(error);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.default = RunsEvents;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command';
|
|
2
|
+
export default class RunsList extends BaseCommand {
|
|
3
|
+
static autonomousCredentialPolicy: "bound-session";
|
|
4
|
+
static description: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static flags: {
|
|
7
|
+
task: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
cursor: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
limit: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
from: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
to: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
since: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
timezone: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
agent: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
conversation: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
source: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
status: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
};
|
|
20
|
+
run(): Promise<void>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
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_runs_1 = require("../../lib/agent-runs");
|
|
7
|
+
const communication_history_1 = require("../../lib/communication-history");
|
|
8
|
+
const execution_history_1 = require("../../lib/execution-history");
|
|
9
|
+
const format_1 = require("../../lib/format");
|
|
10
|
+
const http_error_1 = require("../../lib/http-error");
|
|
11
|
+
const search_display_1 = require("../../lib/search-display");
|
|
12
|
+
class RunsList extends base_command_1.BaseCommand {
|
|
13
|
+
static autonomousCredentialPolicy = 'bound-session';
|
|
14
|
+
static description = 'List Agent Runs you can discover in Run History';
|
|
15
|
+
static examples = [
|
|
16
|
+
'<%= config.bin %> runs list --agent <agent-id>',
|
|
17
|
+
'<%= config.bin %> runs list --agent <agent-id> --source duty --json',
|
|
18
|
+
'<%= config.bin %> runs list --agent <agent-id> --status failed',
|
|
19
|
+
'<%= config.bin %> runs list --source native --conversation <conversation-id>',
|
|
20
|
+
'<%= config.bin %> runs list --source hosted_job',
|
|
21
|
+
'<%= config.bin %> runs list --since 7d --status failed --json',
|
|
22
|
+
];
|
|
23
|
+
static flags = {
|
|
24
|
+
agent: core_1.Flags.string({ description: 'Agent ID for an Agent-scoped list', exclusive: ['conversation'] }),
|
|
25
|
+
conversation: core_1.Flags.string({ description: 'Conversation ID for source chat or native' }),
|
|
26
|
+
source: core_1.Flags.string({ description: 'Limit the list to one Run History source' }),
|
|
27
|
+
status: core_1.Flags.string({ description: 'Limit the list to one Run History status', options: data_provider_1.AGENT_RUN_HISTORY_STATUSES }),
|
|
28
|
+
...communication_history_1.historyTimeFlags,
|
|
29
|
+
task: core_1.Flags.string({ description: 'Exact Task reference for a bound Agent session' }),
|
|
30
|
+
cursor: core_1.Flags.string({ description: 'Continue with the cursor from the previous page and the same filters' }),
|
|
31
|
+
limit: core_1.Flags.integer({ description: 'Maximum runs per page (1–50 for people, 1–8 for Agent sessions, default 3 for sessions)', min: 1, max: 50 }),
|
|
32
|
+
json: core_1.Flags.boolean({ description: 'Output as JSON' }),
|
|
33
|
+
};
|
|
34
|
+
async run() {
|
|
35
|
+
const { flags } = await this.parse(RunsList);
|
|
36
|
+
const session = (0, communication_history_1.resolveHistorySession)(() => this.requireAuth());
|
|
37
|
+
const { agent, conversation, source, from, to, status, cursor, limit, since, timezone, task } = flags;
|
|
38
|
+
const conversationScope = source === 'native' || (source === 'chat' && conversation);
|
|
39
|
+
const validScope = conversationScope ? conversation && !agent :
|
|
40
|
+
source === 'hosted_job' ? !conversation && !agent : agent && !conversation;
|
|
41
|
+
if ((session && (agent || conversation)) || (!session && (!validScope || since || timezone || task))) {
|
|
42
|
+
this.failWithCliError({
|
|
43
|
+
code: 'INVALID_RUN_HISTORY_SCOPE',
|
|
44
|
+
message: session ? 'The session selects the Agent and conversation automatically.' :
|
|
45
|
+
'Use --agent for Agent history, --conversation with --source chat or native, or --source hosted_job for Hosted Jobs. --since, --timezone, and --task require an Agent session.',
|
|
46
|
+
exit: 1,
|
|
47
|
+
retryable: false,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
const page = session ? await (0, execution_history_1.readExecutionHistory)(session.sessionId, 'list', {
|
|
52
|
+
source, from, to, status, cursor, limit, since, timezone, taskId: task,
|
|
53
|
+
}) : await (0, agent_runs_1.listAgentRuns)({ agentId: agent, conversationId: conversation, source, from, to, status, cursor, limit });
|
|
54
|
+
if (flags.json) {
|
|
55
|
+
this.log(JSON.stringify(page, null, 2));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
for (const run of page.items) {
|
|
59
|
+
const title = (0, search_display_1.searchDisplayText)(run.title ?? '');
|
|
60
|
+
const acceptedAt = (0, search_display_1.searchDisplayText)((0, format_1.localTime)(run.acceptedAt));
|
|
61
|
+
this.log([
|
|
62
|
+
run.id, (0, search_display_1.searchDisplayText)(run.source), (0, search_display_1.searchDisplayText)(run.status), acceptedAt, title,
|
|
63
|
+
].filter(Boolean).join(' · '));
|
|
64
|
+
}
|
|
65
|
+
if (!page.items.length) {
|
|
66
|
+
this.log(page.nextCursor ? 'No matches on this page.' : 'No visible runs match these filters.');
|
|
67
|
+
}
|
|
68
|
+
if (page.coverage === 'partial')
|
|
69
|
+
this.log('History coverage is partial. Some runs may be missing.');
|
|
70
|
+
if (page.nextCursor)
|
|
71
|
+
this.log(`Next page Add --cursor ${(0, search_display_1.shellSearchCursor)(page.nextCursor)} to the same command.`);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
if ((0, http_error_1.httpStatusOf)(error) === 400 && error.code === 'INVALID_RUN_HISTORY_CURSOR') {
|
|
75
|
+
this.failWithCliError({
|
|
76
|
+
code: 'INVALID_RUN_HISTORY_CURSOR',
|
|
77
|
+
message: 'Use the same workspace and filters as the previous page, or omit --cursor to start again.',
|
|
78
|
+
status: 400,
|
|
79
|
+
exit: 1,
|
|
80
|
+
retryable: false,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
this.handleApiError(error);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.default = RunsList;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command';
|
|
2
|
+
export default class RunsShow extends BaseCommand {
|
|
3
|
+
static autonomousCredentialPolicy: "bound-session";
|
|
4
|
+
static description: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static args: {
|
|
7
|
+
runId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
8
|
+
};
|
|
9
|
+
static flags: {
|
|
10
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const base_command_1 = require("../../base-command");
|
|
5
|
+
const agent_runs_1 = require("../../lib/agent-runs");
|
|
6
|
+
const communication_history_1 = require("../../lib/communication-history");
|
|
7
|
+
const execution_history_1 = require("../../lib/execution-history");
|
|
8
|
+
const format_1 = require("../../lib/format");
|
|
9
|
+
class RunsShow extends base_command_1.BaseCommand {
|
|
10
|
+
static autonomousCredentialPolicy = 'bound-session';
|
|
11
|
+
static description = 'Show a canonical Agent Run and its execution attempts';
|
|
12
|
+
static examples = ['<%= config.bin %> runs show <run-id>', '<%= config.bin %> runs show <run-id> --json'];
|
|
13
|
+
static args = { runId: agent_runs_1.runIdArgument };
|
|
14
|
+
static flags = { json: core_1.Flags.boolean({ description: 'Output as JSON' }) };
|
|
15
|
+
async run() {
|
|
16
|
+
const { args, flags } = await this.parse(RunsShow);
|
|
17
|
+
const session = (0, communication_history_1.resolveHistorySession)(() => this.requireAuth());
|
|
18
|
+
try {
|
|
19
|
+
if (session) {
|
|
20
|
+
const run = await (0, execution_history_1.readExecutionHistory)(session.sessionId, 'show', { runId: args.runId });
|
|
21
|
+
if (flags.json)
|
|
22
|
+
this.log(JSON.stringify(run, null, 2));
|
|
23
|
+
else {
|
|
24
|
+
this.log([run.id, run.source, run.status, (0, format_1.localTime)(run.acceptedAt)].join(' · '));
|
|
25
|
+
for (const attempt of run.attempts)
|
|
26
|
+
this.log(`Attempt ${attempt.number} ${attempt.id} (${attempt.executor})`);
|
|
27
|
+
if (run.coverage === 'partial')
|
|
28
|
+
this.log('Attempt history coverage is partial.');
|
|
29
|
+
}
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const run = await (0, agent_runs_1.readAgentRun)(args.runId);
|
|
33
|
+
const { snapshot } = run;
|
|
34
|
+
if (flags.json) {
|
|
35
|
+
this.log(JSON.stringify(run, null, 2));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
this.log(`Run ${run.id}`);
|
|
39
|
+
this.log(`Source: ${run.source}`);
|
|
40
|
+
if (snapshot)
|
|
41
|
+
this.log(`Status: ${snapshot.status}`);
|
|
42
|
+
this.log(`Accepted: ${(0, format_1.localTime)(run.acceptedAt)}`);
|
|
43
|
+
const wait = run.runtimeWait;
|
|
44
|
+
if (wait?.remedy === 'update_daemon')
|
|
45
|
+
this.log('Update the skrr daemon on the selected machine so this run can start.');
|
|
46
|
+
else if (wait?.missingCapability === 'session_managed_attempt_v1') {
|
|
47
|
+
this.log('Waiting for a daemon that supports managed execution.');
|
|
48
|
+
}
|
|
49
|
+
else if (wait?.missingCapability === 'duty_execution_contract_v3_ephemeral') {
|
|
50
|
+
this.log('Waiting for a worker that supports Duty sandboxes.');
|
|
51
|
+
}
|
|
52
|
+
if (snapshot?.activeAttemptId)
|
|
53
|
+
this.log(`Active Attempt: ${snapshot.activeAttemptId}`);
|
|
54
|
+
for (const attempt of run.attempts) {
|
|
55
|
+
this.log(`Attempt ${attempt.number}: ${attempt.id} (${attempt.executor})`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
this.handleApiError(error);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.default = RunsShow;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command';
|
|
2
|
+
export default class RunsStop extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
runId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
attempt: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
queued: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
};
|
|
13
|
+
run(): Promise<void>;
|
|
14
|
+
}
|