@skrr-ai/cli 0.1.14 → 0.1.15
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/dist/base-command.d.ts +14 -0
- package/dist/base-command.js +60 -1
- package/dist/commands/agents/create.d.ts +1 -0
- package/dist/commands/agents/create.js +6 -1
- package/dist/commands/agents/instructions/add.d.ts +21 -0
- package/dist/commands/agents/instructions/add.js +115 -0
- package/dist/commands/agents/instructions/disable.d.ts +13 -0
- package/dist/commands/agents/instructions/disable.js +50 -0
- package/dist/commands/agents/instructions/edit.d.ts +16 -0
- package/dist/commands/agents/instructions/edit.js +79 -0
- package/dist/commands/agents/instructions/enable.d.ts +13 -0
- package/dist/commands/agents/instructions/enable.js +50 -0
- package/dist/commands/agents/instructions/move.d.ts +15 -0
- package/dist/commands/agents/instructions/move.js +61 -0
- package/dist/commands/agents/instructions/preview.d.ts +13 -0
- package/dist/commands/agents/instructions/preview.js +59 -0
- package/dist/commands/agents/instructions/remove.d.ts +13 -0
- package/dist/commands/agents/instructions/remove.js +49 -0
- package/dist/commands/agents/instructions/set.d.ts +17 -0
- package/dist/commands/agents/instructions/set.js +79 -0
- package/dist/commands/agents/instructions/show.d.ts +15 -0
- package/dist/commands/agents/instructions/show.js +76 -0
- package/dist/commands/agents/instructions/upgrade.d.ts +16 -0
- package/dist/commands/agents/instructions/upgrade.js +77 -0
- package/dist/commands/agents/show.js +5 -0
- package/dist/commands/agents/triggers/policy.js +8 -2
- package/dist/commands/agents/update.d.ts +1 -0
- package/dist/commands/agents/update.js +8 -2
- package/dist/commands/daemon/index.js +2 -0
- package/dist/commands/daemon/recover-offline-queue.d.ts +9 -0
- package/dist/commands/daemon/recover-offline-queue.js +24 -0
- package/dist/commands/daemon/start.js +29 -1
- package/dist/commands/instruction-blocks/create.d.ts +19 -0
- package/dist/commands/instruction-blocks/create.js +94 -0
- package/dist/commands/instruction-blocks/delete.d.ts +13 -0
- package/dist/commands/instruction-blocks/delete.js +35 -0
- package/dist/commands/instruction-blocks/list.d.ts +13 -0
- package/dist/commands/instruction-blocks/list.js +71 -0
- package/dist/commands/instruction-blocks/show.d.ts +12 -0
- package/dist/commands/instruction-blocks/show.js +35 -0
- package/dist/commands/instruction-blocks/update.d.ts +23 -0
- package/dist/commands/instruction-blocks/update.js +94 -0
- package/dist/commands/spaces/auto-executor/preview.d.ts +1 -0
- package/dist/commands/spaces/auto-executor/preview.js +62 -3
- package/dist/commands/spaces/auto-executor/update.d.ts +4 -0
- package/dist/commands/spaces/auto-executor/update.js +78 -7
- package/dist/commands/spaces/capacity.js +14 -2
- package/dist/commands/spaces/update.d.ts +4 -0
- package/dist/commands/spaces/update.js +49 -2
- package/dist/commands/tasks/complete.d.ts +12 -5
- package/dist/commands/tasks/complete.js +50 -28
- package/dist/commands/tasks/continue-ready.js +9 -1
- package/dist/commands/tasks/create.d.ts +1 -0
- package/dist/commands/tasks/create.js +25 -1
- package/dist/commands/tasks/deliverable/add.d.ts +23 -0
- package/dist/commands/tasks/deliverable/add.js +70 -0
- package/dist/commands/tasks/events/append.d.ts +1 -1
- package/dist/commands/tasks/events/append.js +4 -4
- package/dist/commands/tasks/expectations.d.ts +12 -0
- package/dist/commands/tasks/expectations.js +92 -0
- package/dist/commands/tasks/judge.d.ts +29 -0
- package/dist/commands/tasks/judge.js +68 -0
- package/dist/commands/tasks/report.d.ts +1 -1
- package/dist/commands/tasks/report.js +3 -3
- package/dist/commands/tasks/update.d.ts +1 -0
- package/dist/commands/tasks/update.js +34 -4
- package/dist/commands/tasks/waive.d.ts +25 -0
- package/dist/commands/tasks/waive.js +58 -0
- package/dist/lib/agent-config.js +5 -0
- package/dist/lib/agent-instructions.d.ts +15 -0
- package/dist/lib/agent-instructions.js +55 -0
- package/dist/lib/command-hygiene.d.ts +6 -1
- package/dist/lib/command-hygiene.js +49 -29
- package/dist/lib/exec-runtime-binary.d.ts +13 -0
- package/dist/lib/exec-runtime-binary.js +45 -0
- package/dist/lib/git-task.d.ts +37 -0
- package/dist/lib/git-task.js +151 -0
- package/dist/lib/instruction-blocks.d.ts +29 -0
- package/dist/lib/instruction-blocks.js +159 -0
- package/dist/lib/runtime-start-verification.d.ts +49 -0
- package/dist/lib/runtime-start-verification.js +108 -0
- package/dist/lib/task-execution.d.ts +18 -2
- package/dist/lib/task-execution.js +19 -14
- package/dist/lib/task-transcript.js +1 -1
- package/dist/lib/tasks.d.ts +50 -0
- package/dist/lib/tasks.js +66 -1
- package/dist/node_modules/@skrr-ai/data-provider/index.js +2027 -1904
- package/dist/node_modules/@skrr-ai/inference-broker/package.json +1 -1
- package/oclif.manifest.json +13706 -11858
- package/package.json +4 -1
package/dist/base-command.d.ts
CHANGED
|
@@ -370,5 +370,19 @@ export declare function describeHarnessUnavailable(body: Record<string, unknown>
|
|
|
370
370
|
export declare function describeResourceNotFound(serverMessage: string | undefined, bin?: string, baseURL?: string): string | null;
|
|
371
371
|
export declare function describeAssigneeNotInSpace(serverMessage: string | undefined, bin?: string): string;
|
|
372
372
|
export declare function describeForbidden(bodyMessage?: string | null, method?: string | null): string;
|
|
373
|
+
/**
|
|
374
|
+
* True when a credential is unmistakably machine/daemon authority rather
|
|
375
|
+
* than a human CLI session. This is a diagnostic guard only, never an
|
|
376
|
+
* authorization decision: the server remains authoritative for every token.
|
|
377
|
+
*
|
|
378
|
+
* Opaque daemon access tokens have a stable public prefix. Legacy daemon JWTs
|
|
379
|
+
* expose `scope: "daemon"`; decoding the unsigned payload lets the CLI give a
|
|
380
|
+
* repair instruction instead of calling a predictable 403 a transient edge
|
|
381
|
+
* failure. Malformed and unknown token shapes intentionally return false so a
|
|
382
|
+
* generic authentication failure remains honest.
|
|
383
|
+
*/
|
|
384
|
+
export declare function isDaemonScopedCredential(token?: string | null): boolean;
|
|
385
|
+
/** The one repair for a daemon token passed to a human CLI command. */
|
|
386
|
+
export declare function describeDaemonScopedCredential(bin: string): string;
|
|
373
387
|
export declare function isRetryableFailure(status: number | undefined, body: Record<string, unknown> | null): boolean;
|
|
374
388
|
export { Flags };
|
package/dist/base-command.js
CHANGED
|
@@ -8,6 +8,8 @@ exports.describeHarnessUnavailable = describeHarnessUnavailable;
|
|
|
8
8
|
exports.describeResourceNotFound = describeResourceNotFound;
|
|
9
9
|
exports.describeAssigneeNotInSpace = describeAssigneeNotInSpace;
|
|
10
10
|
exports.describeForbidden = describeForbidden;
|
|
11
|
+
exports.isDaemonScopedCredential = isDaemonScopedCredential;
|
|
12
|
+
exports.describeDaemonScopedCredential = describeDaemonScopedCredential;
|
|
11
13
|
exports.isRetryableFailure = isRetryableFailure;
|
|
12
14
|
const core_1 = require("@oclif/core");
|
|
13
15
|
Object.defineProperty(exports, "Flags", { enumerable: true, get: function () { return core_1.Flags; } });
|
|
@@ -576,6 +578,14 @@ class BaseCommand extends core_1.Command {
|
|
|
576
578
|
retryable: false,
|
|
577
579
|
});
|
|
578
580
|
}
|
|
581
|
+
if (isDaemonScopedCredential(this.resolvedCredential.token)) {
|
|
582
|
+
this.failWithCliError({
|
|
583
|
+
message: describeDaemonScopedCredential(this.config.bin),
|
|
584
|
+
code: 'DAEMON_SCOPE_CREDENTIAL',
|
|
585
|
+
exit: 2,
|
|
586
|
+
retryable: false,
|
|
587
|
+
});
|
|
588
|
+
}
|
|
579
589
|
}
|
|
580
590
|
/**
|
|
581
591
|
* Resolve the authenticated user's id via `GET /api/user`.
|
|
@@ -802,7 +812,22 @@ class BaseCommand extends core_1.Command {
|
|
|
802
812
|
const body = parseErrorBody(e.body);
|
|
803
813
|
const bodyCode = stringProp(body, 'code') || stringProp(body, 'errorType');
|
|
804
814
|
const bodyMessage = stringProp(body, 'message') || stringProp(body, 'error');
|
|
805
|
-
|
|
815
|
+
// `requireAuth()` catches this before requests for normal commands, but
|
|
816
|
+
// keep the API-error check too: a handful of commands make a direct
|
|
817
|
+
// request and a supplied `--token` can bypass their normal preflight.
|
|
818
|
+
// A daemon credential reaching a human endpoint is deterministic, not
|
|
819
|
+
// an edge outage; retrying only repeats the same 401/403.
|
|
820
|
+
if ((e.status === 401 || e.status === 403) &&
|
|
821
|
+
isDaemonScopedCredential(this.resolvedCredential?.token)) {
|
|
822
|
+
this.failWithCliError({
|
|
823
|
+
message: say(describeDaemonScopedCredential(this.config.bin)),
|
|
824
|
+
code: 'DAEMON_SCOPE_CREDENTIAL',
|
|
825
|
+
status: e.status,
|
|
826
|
+
exit: 2,
|
|
827
|
+
retryable: false,
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
else if (bodyCode === 'AGENT_RUNTIME_UNAVAILABLE') {
|
|
806
831
|
// A specific agent's runtime is offline — not a platform outage, even
|
|
807
832
|
// though the server returns 503. Intercept before the 503→outage
|
|
808
833
|
// heuristic so we neither claim a service outage nor promise a
|
|
@@ -1391,6 +1416,40 @@ function describeForbidden(bodyMessage, method) {
|
|
|
1391
1416
|
}
|
|
1392
1417
|
return `${lead}.`;
|
|
1393
1418
|
}
|
|
1419
|
+
/**
|
|
1420
|
+
* True when a credential is unmistakably machine/daemon authority rather
|
|
1421
|
+
* than a human CLI session. This is a diagnostic guard only, never an
|
|
1422
|
+
* authorization decision: the server remains authoritative for every token.
|
|
1423
|
+
*
|
|
1424
|
+
* Opaque daemon access tokens have a stable public prefix. Legacy daemon JWTs
|
|
1425
|
+
* expose `scope: "daemon"`; decoding the unsigned payload lets the CLI give a
|
|
1426
|
+
* repair instruction instead of calling a predictable 403 a transient edge
|
|
1427
|
+
* failure. Malformed and unknown token shapes intentionally return false so a
|
|
1428
|
+
* generic authentication failure remains honest.
|
|
1429
|
+
*/
|
|
1430
|
+
function isDaemonScopedCredential(token) {
|
|
1431
|
+
if (typeof token !== 'string' || token.length === 0)
|
|
1432
|
+
return false;
|
|
1433
|
+
if (token.startsWith('osk_dmn_'))
|
|
1434
|
+
return true;
|
|
1435
|
+
const payload = token.split('.')[1];
|
|
1436
|
+
if (!payload)
|
|
1437
|
+
return false;
|
|
1438
|
+
try {
|
|
1439
|
+
const decoded = JSON.parse(Buffer.from(payload, 'base64url').toString('utf8'));
|
|
1440
|
+
return (typeof decoded === 'object' &&
|
|
1441
|
+
decoded !== null &&
|
|
1442
|
+
decoded.scope === 'daemon');
|
|
1443
|
+
}
|
|
1444
|
+
catch {
|
|
1445
|
+
return false;
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
/** The one repair for a daemon token passed to a human CLI command. */
|
|
1449
|
+
function describeDaemonScopedCredential(bin) {
|
|
1450
|
+
return ('This command received a daemon-scoped credential, which cannot access user API commands. ' +
|
|
1451
|
+
`Run \`${bin} login\` to create a CLI credential. For the local runtime itself, use \`${bin} daemon login\`.`);
|
|
1452
|
+
}
|
|
1394
1453
|
function isRetryableFailure(status, body) {
|
|
1395
1454
|
const declared = body?.retryable;
|
|
1396
1455
|
if (typeof declared === 'boolean')
|
|
@@ -55,6 +55,7 @@ export default class AgentsCreate extends BaseCommand {
|
|
|
55
55
|
'tone-mode': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
56
56
|
'tone-id': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
57
57
|
'tone-notes': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
58
|
+
'max-concurrent-task-executions': import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
58
59
|
skills: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
59
60
|
'agent-actions': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
60
61
|
'tool-policy': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
@@ -86,7 +86,9 @@ class AgentsCreate extends base_command_1.BaseCommand {
|
|
|
86
86
|
model: core_1.Flags.string({
|
|
87
87
|
description: 'Model identifier (required unless set via --from-json)',
|
|
88
88
|
}),
|
|
89
|
-
instructions: core_1.Flags.string({
|
|
89
|
+
instructions: core_1.Flags.string({
|
|
90
|
+
description: 'Initial raw custom instructions (creates one inline block; use `agents instructions` to compose reusable blocks later)',
|
|
91
|
+
}),
|
|
90
92
|
category: core_1.Flags.string({ description: 'Agent category' }),
|
|
91
93
|
target: core_1.Flags.string({
|
|
92
94
|
description: 'Required execution target. Use a Harness id, Hosted Machine session, or Agent Worker. Use hosted-machine, sbs_..., agent-worker, or a connected Harness id.',
|
|
@@ -116,6 +118,9 @@ class AgentsCreate extends base_command_1.BaseCommand {
|
|
|
116
118
|
'tone-mode': core_1.Flags.string({ description: 'Tone mode' }),
|
|
117
119
|
'tone-id': core_1.Flags.string({ description: 'Tone ID' }),
|
|
118
120
|
'tone-notes': core_1.Flags.string({ description: 'Per-agent tone notes' }),
|
|
121
|
+
'max-concurrent-task-executions': core_1.Flags.integer({
|
|
122
|
+
description: 'Max Task executions this agent may run at once ACROSS every space (0 = unlimited)',
|
|
123
|
+
}),
|
|
119
124
|
skills: core_1.Flags.string({ description: 'Skills JSON array' }),
|
|
120
125
|
'agent-actions': core_1.Flags.string({ description: 'Embedded actions JSON array' }),
|
|
121
126
|
'tool-policy': core_1.Flags.string({ description: 'Tool policy JSON object' }),
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base-command';
|
|
2
|
+
export default class AgentsInstructionsAdd extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
id: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
agent: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
inline: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
block: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
|
+
version: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
14
|
+
binding: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
15
|
+
title: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
16
|
+
body: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
17
|
+
file: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
18
|
+
disabled: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
19
|
+
};
|
|
20
|
+
run(): Promise<void>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
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 agent_instructions_1 = require("../../../lib/agent-instructions");
|
|
8
|
+
const instruction_blocks_1 = require("../../../lib/instruction-blocks");
|
|
9
|
+
const instruction_input_1 = require("../../../lib/instruction-input");
|
|
10
|
+
class AgentsInstructionsAdd extends base_command_1.BaseCommand {
|
|
11
|
+
static description = 'Add an inline instruction or a version-pinned library block to an Agent';
|
|
12
|
+
static examples = [
|
|
13
|
+
'<%= config.bin %> agents instructions add <agent-id> --inline --title "Working preferences" --body "Lead with the answer."',
|
|
14
|
+
'<%= config.bin %> agents instructions add <agent-id> --block block_official_github_pr_review --binding repository=acme/api',
|
|
15
|
+
'<%= config.bin %> agents instructions add <agent-id> --block block_… --version 2 --disabled',
|
|
16
|
+
];
|
|
17
|
+
static args = {
|
|
18
|
+
id: core_1.Args.string({
|
|
19
|
+
description: 'Agent ID. Omit to use OVERSKY_SESSION_AGENT_ID.',
|
|
20
|
+
required: false,
|
|
21
|
+
ignoreStdin: true,
|
|
22
|
+
}),
|
|
23
|
+
};
|
|
24
|
+
static flags = {
|
|
25
|
+
json: core_1.Flags.boolean({ description: 'Output the updated Agent as JSON' }),
|
|
26
|
+
agent: core_1.Flags.string({ description: 'Agent ID (alias for the positional argument)' }),
|
|
27
|
+
inline: core_1.Flags.boolean({ description: 'Add a new inline block owned by this Agent' }),
|
|
28
|
+
block: core_1.Flags.string({ description: 'Library or official block ID to attach' }),
|
|
29
|
+
version: core_1.Flags.integer({
|
|
30
|
+
description: 'Version to pin (defaults to the block’s current version)',
|
|
31
|
+
}),
|
|
32
|
+
binding: core_1.Flags.string({
|
|
33
|
+
description: 'Parameter binding as key=value (repeatable)',
|
|
34
|
+
multiple: true,
|
|
35
|
+
}),
|
|
36
|
+
title: core_1.Flags.string({ description: 'Inline block title (required with --inline)' }),
|
|
37
|
+
body: core_1.Flags.string({ description: 'Inline instruction text' }),
|
|
38
|
+
file: core_1.Flags.string({ description: 'Read inline instruction text from a file, or - for stdin' }),
|
|
39
|
+
disabled: core_1.Flags.boolean({ description: 'Attach the block disabled' }),
|
|
40
|
+
};
|
|
41
|
+
async run() {
|
|
42
|
+
this.requireAuth();
|
|
43
|
+
const { args, flags } = await this.parse(AgentsInstructionsAdd);
|
|
44
|
+
if (Boolean(flags.inline) === Boolean(flags.block)) {
|
|
45
|
+
this.error('Choose exactly one source: --inline or --block <block-id>.', { exit: 2 });
|
|
46
|
+
}
|
|
47
|
+
if (flags.inline && (flags.version !== undefined || flags.binding?.length)) {
|
|
48
|
+
this.error('--version and --binding only apply to --block.', { exit: 2 });
|
|
49
|
+
}
|
|
50
|
+
let agentId;
|
|
51
|
+
try {
|
|
52
|
+
agentId = await (0, agent_instructions_1.resolveInstructionAgentId)(args.id, flags.agent);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
const failure = (0, agent_resolver_1.agentResolutionFailure)(error);
|
|
56
|
+
this.failWithCliError({
|
|
57
|
+
message: failure.message,
|
|
58
|
+
code: failure.code,
|
|
59
|
+
exit: 2,
|
|
60
|
+
retryable: false,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
let entry;
|
|
64
|
+
try {
|
|
65
|
+
if (flags.inline) {
|
|
66
|
+
const body = (await (0, instruction_input_1.readInstructionBody)({
|
|
67
|
+
body: flags.body,
|
|
68
|
+
file: flags.file,
|
|
69
|
+
required: true,
|
|
70
|
+
}));
|
|
71
|
+
if (!flags.title?.trim())
|
|
72
|
+
throw new Error('--title is required with --inline.');
|
|
73
|
+
entry = {
|
|
74
|
+
instanceId: (0, instruction_blocks_1.nextInstanceId)('inline'),
|
|
75
|
+
enabled: !flags.disabled,
|
|
76
|
+
source: { kind: 'inline', title: flags.title, body },
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
const block = await data_provider_1.dataService.getInstructionBlock(flags.block);
|
|
81
|
+
const version = flags.version ?? block.currentVersion;
|
|
82
|
+
const bindings = (0, instruction_blocks_1.parseBindings)(flags.binding);
|
|
83
|
+
if (!block.versions.some((candidate) => candidate.version === version)) {
|
|
84
|
+
throw new Error(`${block.id} has no v${version}. Run \`skrr instruction-blocks show ${block.id}\`.`);
|
|
85
|
+
}
|
|
86
|
+
entry = {
|
|
87
|
+
instanceId: (0, instruction_blocks_1.nextInstanceId)('library'),
|
|
88
|
+
enabled: !flags.disabled,
|
|
89
|
+
source: { kind: 'library', blockId: block.id, version },
|
|
90
|
+
...(bindings ? { bindings } : {}),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
this.error(error.message, { exit: 2 });
|
|
96
|
+
}
|
|
97
|
+
let loaded;
|
|
98
|
+
let updated;
|
|
99
|
+
try {
|
|
100
|
+
loaded = await (0, agent_instructions_1.loadAgentInstructions)(agentId);
|
|
101
|
+
updated = await (0, agent_instructions_1.saveAgentInstructions)(agentId, {
|
|
102
|
+
schemaVersion: 1,
|
|
103
|
+
entries: [...loaded.composition.entries, entry],
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
this.handleApiError(error);
|
|
108
|
+
}
|
|
109
|
+
if (flags.json)
|
|
110
|
+
return this.log(JSON.stringify(updated, null, 2));
|
|
111
|
+
this.log(`Added ${entry.source.kind === 'inline' ? entry.source.title : entry.source.blockId} to ${agentId}.`);
|
|
112
|
+
this.log(`Instance: ${entry.instanceId}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.default = AgentsInstructionsAdd;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base-command';
|
|
2
|
+
export default class AgentsInstructionsDisable extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
instance: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
agent: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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_resolver_1 = require("../../../lib/agent-resolver");
|
|
6
|
+
const agent_instructions_1 = require("../../../lib/agent-instructions");
|
|
7
|
+
const instruction_blocks_1 = require("../../../lib/instruction-blocks");
|
|
8
|
+
class AgentsInstructionsDisable extends base_command_1.BaseCommand {
|
|
9
|
+
static description = 'Disable one instruction block without removing its configuration';
|
|
10
|
+
static examples = [
|
|
11
|
+
'<%= config.bin %> agents instructions disable library_… --agent <agent-id>',
|
|
12
|
+
];
|
|
13
|
+
static args = {
|
|
14
|
+
instance: core_1.Args.string({ description: 'Block instance ID', required: true, ignoreStdin: true }),
|
|
15
|
+
};
|
|
16
|
+
static flags = {
|
|
17
|
+
json: core_1.Flags.boolean({ description: 'Output the updated Agent as JSON' }),
|
|
18
|
+
agent: core_1.Flags.string({ description: 'Agent ID (alias for the positional argument)' }),
|
|
19
|
+
};
|
|
20
|
+
async run() {
|
|
21
|
+
this.requireAuth();
|
|
22
|
+
const { args, flags } = await this.parse(AgentsInstructionsDisable);
|
|
23
|
+
let agentId;
|
|
24
|
+
try {
|
|
25
|
+
agentId = await (0, agent_instructions_1.resolveInstructionAgentId)(undefined, flags.agent);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
const failure = (0, agent_resolver_1.agentResolutionFailure)(error);
|
|
29
|
+
this.failWithCliError({
|
|
30
|
+
message: failure.message,
|
|
31
|
+
code: failure.code,
|
|
32
|
+
exit: 2,
|
|
33
|
+
retryable: false,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
let updated;
|
|
37
|
+
try {
|
|
38
|
+
const { composition } = await (0, agent_instructions_1.loadAgentInstructions)(agentId);
|
|
39
|
+
const entry = (0, instruction_blocks_1.entryByInstance)(composition, args.instance);
|
|
40
|
+
updated = await (0, agent_instructions_1.saveAgentInstructions)(agentId, (0, instruction_blocks_1.replaceEntry)(composition, args.instance, { ...entry, enabled: false }));
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
this.handleApiError(error);
|
|
44
|
+
}
|
|
45
|
+
if (flags.json)
|
|
46
|
+
return this.log(JSON.stringify(updated, null, 2));
|
|
47
|
+
this.log(`Disabled ${args.instance} on ${agentId}; its configuration is retained.`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.default = AgentsInstructionsDisable;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base-command';
|
|
2
|
+
export default class AgentsInstructionsEdit extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
instance: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
agent: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
title: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
|
+
body: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
|
+
file: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
14
|
+
};
|
|
15
|
+
run(): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
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_resolver_1 = require("../../../lib/agent-resolver");
|
|
6
|
+
const agent_instructions_1 = require("../../../lib/agent-instructions");
|
|
7
|
+
const instruction_blocks_1 = require("../../../lib/instruction-blocks");
|
|
8
|
+
const instruction_input_1 = require("../../../lib/instruction-input");
|
|
9
|
+
class AgentsInstructionsEdit extends base_command_1.BaseCommand {
|
|
10
|
+
static description = 'Edit an inline block owned by an Agent (library blocks are immutable; fork or upgrade them instead)';
|
|
11
|
+
static examples = [
|
|
12
|
+
'<%= config.bin %> agents instructions edit inline_… --agent <agent-id> --body "Name uncertainty."',
|
|
13
|
+
'<%= config.bin %> agents instructions edit inline_… --agent <agent-id> --title "Reporting format" --file ./format.md',
|
|
14
|
+
];
|
|
15
|
+
static args = {
|
|
16
|
+
instance: core_1.Args.string({
|
|
17
|
+
description: 'Inline block instance ID',
|
|
18
|
+
required: true,
|
|
19
|
+
ignoreStdin: true,
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
22
|
+
static flags = {
|
|
23
|
+
json: core_1.Flags.boolean({ description: 'Output the updated Agent as JSON' }),
|
|
24
|
+
agent: core_1.Flags.string({ description: 'Agent ID (alias for the positional argument)' }),
|
|
25
|
+
title: core_1.Flags.string({ description: 'New inline block title' }),
|
|
26
|
+
body: core_1.Flags.string({ description: 'New inline block text' }),
|
|
27
|
+
file: core_1.Flags.string({ description: 'Read new inline block text from a file, or - for stdin' }),
|
|
28
|
+
};
|
|
29
|
+
async run() {
|
|
30
|
+
this.requireAuth();
|
|
31
|
+
const { args, flags } = await this.parse(AgentsInstructionsEdit);
|
|
32
|
+
let agentId;
|
|
33
|
+
try {
|
|
34
|
+
agentId = await (0, agent_instructions_1.resolveInstructionAgentId)(undefined, flags.agent);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
const failure = (0, agent_resolver_1.agentResolutionFailure)(error);
|
|
38
|
+
this.failWithCliError({
|
|
39
|
+
message: failure.message,
|
|
40
|
+
code: failure.code,
|
|
41
|
+
exit: 2,
|
|
42
|
+
retryable: false,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
let body;
|
|
46
|
+
try {
|
|
47
|
+
body = await (0, instruction_input_1.readInstructionBody)({ body: flags.body, file: flags.file });
|
|
48
|
+
if (flags.title === undefined && body === undefined) {
|
|
49
|
+
throw new Error('Nothing to edit. Pass --title, --body, or --file.');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
this.error(error.message, { exit: 2 });
|
|
54
|
+
}
|
|
55
|
+
let updated;
|
|
56
|
+
try {
|
|
57
|
+
const { composition } = await (0, agent_instructions_1.loadAgentInstructions)(agentId);
|
|
58
|
+
const current = (0, instruction_blocks_1.entryByInstance)(composition, args.instance);
|
|
59
|
+
if (current.source.kind !== 'inline') {
|
|
60
|
+
throw new Error(`Instance ${args.instance} is a version-pinned library block. Edit its source with \`skrr instruction-blocks update\`, then use \`agents instructions upgrade\` when ready.`);
|
|
61
|
+
}
|
|
62
|
+
updated = await (0, agent_instructions_1.saveAgentInstructions)(agentId, (0, instruction_blocks_1.replaceEntry)(composition, args.instance, {
|
|
63
|
+
...current,
|
|
64
|
+
source: {
|
|
65
|
+
kind: 'inline',
|
|
66
|
+
title: flags.title ?? current.source.title,
|
|
67
|
+
body: body ?? current.source.body,
|
|
68
|
+
},
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
this.handleApiError(error);
|
|
73
|
+
}
|
|
74
|
+
if (flags.json)
|
|
75
|
+
return this.log(JSON.stringify(updated, null, 2));
|
|
76
|
+
this.log(`Edited inline block ${args.instance} on ${agentId}.`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.default = AgentsInstructionsEdit;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base-command';
|
|
2
|
+
export default class AgentsInstructionsEnable extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
instance: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
agent: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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_resolver_1 = require("../../../lib/agent-resolver");
|
|
6
|
+
const agent_instructions_1 = require("../../../lib/agent-instructions");
|
|
7
|
+
const instruction_blocks_1 = require("../../../lib/instruction-blocks");
|
|
8
|
+
class AgentsInstructionsEnable extends base_command_1.BaseCommand {
|
|
9
|
+
static description = 'Enable one instruction block on an Agent';
|
|
10
|
+
static examples = [
|
|
11
|
+
'<%= config.bin %> agents instructions enable library_… --agent <agent-id>',
|
|
12
|
+
];
|
|
13
|
+
static args = {
|
|
14
|
+
instance: core_1.Args.string({ description: 'Block instance ID', required: true, ignoreStdin: true }),
|
|
15
|
+
};
|
|
16
|
+
static flags = {
|
|
17
|
+
json: core_1.Flags.boolean({ description: 'Output the updated Agent as JSON' }),
|
|
18
|
+
agent: core_1.Flags.string({ description: 'Agent ID (alias for the positional argument)' }),
|
|
19
|
+
};
|
|
20
|
+
async run() {
|
|
21
|
+
this.requireAuth();
|
|
22
|
+
const { args, flags } = await this.parse(AgentsInstructionsEnable);
|
|
23
|
+
let agentId;
|
|
24
|
+
try {
|
|
25
|
+
agentId = await (0, agent_instructions_1.resolveInstructionAgentId)(undefined, flags.agent);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
const failure = (0, agent_resolver_1.agentResolutionFailure)(error);
|
|
29
|
+
this.failWithCliError({
|
|
30
|
+
message: failure.message,
|
|
31
|
+
code: failure.code,
|
|
32
|
+
exit: 2,
|
|
33
|
+
retryable: false,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
let updated;
|
|
37
|
+
try {
|
|
38
|
+
const { composition } = await (0, agent_instructions_1.loadAgentInstructions)(agentId);
|
|
39
|
+
const entry = (0, instruction_blocks_1.entryByInstance)(composition, args.instance);
|
|
40
|
+
updated = await (0, agent_instructions_1.saveAgentInstructions)(agentId, (0, instruction_blocks_1.replaceEntry)(composition, args.instance, { ...entry, enabled: true }));
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
this.handleApiError(error);
|
|
44
|
+
}
|
|
45
|
+
if (flags.json)
|
|
46
|
+
return this.log(JSON.stringify(updated, null, 2));
|
|
47
|
+
this.log(`Enabled ${args.instance} on ${agentId}.`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.default = AgentsInstructionsEnable;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base-command';
|
|
2
|
+
export default class AgentsInstructionsMove extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
instance: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
agent: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
before: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
12
|
+
after: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
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_resolver_1 = require("../../../lib/agent-resolver");
|
|
6
|
+
const agent_instructions_1 = require("../../../lib/agent-instructions");
|
|
7
|
+
const instruction_blocks_1 = require("../../../lib/instruction-blocks");
|
|
8
|
+
class AgentsInstructionsMove extends base_command_1.BaseCommand {
|
|
9
|
+
static description = 'Reorder one instruction block; later enabled blocks can supplement or narrow earlier ones';
|
|
10
|
+
static examples = [
|
|
11
|
+
'<%= config.bin %> agents instructions move library_… --agent <agent-id> --before inline_…',
|
|
12
|
+
'<%= config.bin %> agents instructions move inline_… --agent <agent-id> --after library_…',
|
|
13
|
+
];
|
|
14
|
+
static args = {
|
|
15
|
+
instance: core_1.Args.string({
|
|
16
|
+
description: 'Block instance to move',
|
|
17
|
+
required: true,
|
|
18
|
+
ignoreStdin: true,
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
21
|
+
static flags = {
|
|
22
|
+
json: core_1.Flags.boolean({ description: 'Output the updated Agent as JSON' }),
|
|
23
|
+
agent: core_1.Flags.string({ description: 'Agent ID (alias for the positional argument)' }),
|
|
24
|
+
before: core_1.Flags.string({ description: 'Move immediately before this instance ID' }),
|
|
25
|
+
after: core_1.Flags.string({ description: 'Move immediately after this instance ID' }),
|
|
26
|
+
};
|
|
27
|
+
async run() {
|
|
28
|
+
this.requireAuth();
|
|
29
|
+
const { args, flags } = await this.parse(AgentsInstructionsMove);
|
|
30
|
+
if (Boolean(flags.before) === Boolean(flags.after)) {
|
|
31
|
+
this.error('Choose exactly one placement: --before <instance> or --after <instance>.', {
|
|
32
|
+
exit: 2,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
let agentId;
|
|
36
|
+
try {
|
|
37
|
+
agentId = await (0, agent_instructions_1.resolveInstructionAgentId)(undefined, flags.agent);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
const failure = (0, agent_resolver_1.agentResolutionFailure)(error);
|
|
41
|
+
this.failWithCliError({
|
|
42
|
+
message: failure.message,
|
|
43
|
+
code: failure.code,
|
|
44
|
+
exit: 2,
|
|
45
|
+
retryable: false,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
let updated;
|
|
49
|
+
try {
|
|
50
|
+
const { composition } = await (0, agent_instructions_1.loadAgentInstructions)(agentId);
|
|
51
|
+
updated = await (0, agent_instructions_1.saveAgentInstructions)(agentId, (0, instruction_blocks_1.moveEntry)(composition, args.instance, (flags.before ?? flags.after), flags.before ? 'before' : 'after'));
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
this.handleApiError(error);
|
|
55
|
+
}
|
|
56
|
+
if (flags.json)
|
|
57
|
+
return this.log(JSON.stringify(updated, null, 2));
|
|
58
|
+
this.log(`Moved ${args.instance} ${flags.before ? 'before' : 'after'} ${flags.before ?? flags.after}.`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.default = AgentsInstructionsMove;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base-command';
|
|
2
|
+
export default class AgentsInstructionsPreview extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
id: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
agent: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|