@skrr-ai/cli 0.1.215 → 0.1.217
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/commands/agent/message/no-reply.d.ts +4 -0
- package/dist/commands/agent/message/no-reply.js +5 -1
- package/dist/commands/agents/always-on/recovery-review.d.ts +12 -0
- package/dist/commands/agents/always-on/recovery-review.js +52 -2
- package/dist/commands/agents/permissions/list.d.ts +12 -0
- package/dist/commands/agents/permissions/list.js +42 -0
- package/dist/commands/agents/permissions/remove.d.ts +15 -0
- package/dist/commands/agents/permissions/remove.js +68 -0
- package/dist/commands/dm/work.js +2 -0
- package/dist/commands/duties/action-proposal.js +7 -1
- package/dist/commands/duties/action-proposals.d.ts +9 -0
- package/dist/commands/duties/action-proposals.js +30 -12
- package/dist/commands/duties/check-now.d.ts +7 -0
- package/dist/commands/duties/check-now.js +36 -1
- package/dist/commands/duties/create.d.ts +15 -0
- package/dist/commands/duties/create.js +93 -5
- package/dist/commands/duties/pause.js +20 -2
- package/dist/commands/duties/trigger-status.js +6 -1
- package/dist/commands/duties/update.js +22 -7
- package/dist/commands/spaces/auto-executor/preview.d.ts +7 -0
- package/dist/commands/spaces/auto-executor/preview.js +21 -2
- package/dist/commands/tasks/chat/index.d.ts +11 -0
- package/dist/commands/tasks/chat/index.js +27 -0
- package/dist/commands/tasks/input/answer.d.ts +12 -0
- package/dist/commands/tasks/input/answer.js +59 -5
- package/dist/commands/tasks/operations/show.js +5 -6
- package/dist/commands/tasks/result/show.js +2 -4
- package/dist/commands/tasks/retry-receipt.js +1 -3
- package/dist/commands/wiki/write.js +7 -2
- package/dist/generated/agent-guides.json +24 -24
- package/dist/lib/compasses.d.ts +5 -0
- package/dist/lib/compasses.js +6 -1
- package/dist/lib/duties.d.ts +29 -0
- package/dist/lib/duties.js +122 -16
- package/dist/lib/permission-rules.d.ts +21 -0
- package/dist/lib/permission-rules.js +75 -0
- package/dist/lib/space-proposals.js +8 -1
- package/dist/lib/space-write-policy.js +18 -2
- package/dist/lib/task-extras.d.ts +19 -0
- package/dist/lib/task-extras.js +13 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/ownerChatDutyHarnesses.d.ts +43 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/ownerChatDutyHarnesses.js +36 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/ownerChatDutyHarnesses.d.ts +43 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/ownerChatDutyHarnesses.js +48 -0
- package/dist/node_modules/@skrr-ai/auth-core/package.json +10 -0
- package/dist/node_modules/@skrr-ai/data-provider/index.js +12658 -12041
- package/oclif.manifest.json +201 -4
- package/package.json +5 -2
|
@@ -4,6 +4,10 @@ import { BaseCommand } from '../../../base-command';
|
|
|
4
4
|
* acknowledged something, or the work speaks for itself. The server records it on the turn
|
|
5
5
|
* (`declared_silent`), and the turn's marker still shows that the turn happened.
|
|
6
6
|
*
|
|
7
|
+
* In a scheduled wake (an autonomous session: a heartbeat, check-in or watch) the same command
|
|
8
|
+
* declares that the wake needs no message. The server records it on the wake's Run, bound to the
|
|
9
|
+
* attempt it resolves from the session, and the scheduled executor reads it after the turn.
|
|
10
|
+
*
|
|
7
11
|
* Only inside a daemon session, for that session's own running turn: the server proves the
|
|
8
12
|
* turn from the session token, exactly as it does for a send.
|
|
9
13
|
*/
|
|
@@ -10,11 +10,15 @@ const message_intent_1 = require("../../../lib/message-intent");
|
|
|
10
10
|
* acknowledged something, or the work speaks for itself. The server records it on the turn
|
|
11
11
|
* (`declared_silent`), and the turn's marker still shows that the turn happened.
|
|
12
12
|
*
|
|
13
|
+
* In a scheduled wake (an autonomous session: a heartbeat, check-in or watch) the same command
|
|
14
|
+
* declares that the wake needs no message. The server records it on the wake's Run, bound to the
|
|
15
|
+
* attempt it resolves from the session, and the scheduled executor reads it after the turn.
|
|
16
|
+
*
|
|
13
17
|
* Only inside a daemon session, for that session's own running turn: the server proves the
|
|
14
18
|
* turn from the session token, exactly as it does for a send.
|
|
15
19
|
*/
|
|
16
20
|
class AgentMessageNoReply extends base_command_1.BaseCommand {
|
|
17
|
-
static description = 'Declare that this
|
|
21
|
+
static description = 'Declare that this turn needs no message: in an interactive turn, none in Main Chat (recorded on the turn; Main Chat does not act on it yet); in a scheduled wake (heartbeat, check-in, watch), that the wake stays silent (recorded on its run, replacing the HEARTBEAT_SILENT word). Only inside a daemon session, for its own running turn';
|
|
18
22
|
static examples = ['<%= config.bin %> agent message no-reply'];
|
|
19
23
|
static flags = {
|
|
20
24
|
json: core_1.Flags.boolean({
|
|
@@ -47,3 +47,15 @@ export declare function autoRecoveryLines(review: DutyRunRecoveryReview): string
|
|
|
47
47
|
* sent. Nothing for a Run with no record, or an older server.
|
|
48
48
|
*/
|
|
49
49
|
export declare function unprovenLine(review: DutyRunRecoveryReview): string | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* The Run's stored status, and what it means while held (OSK-33272). A held Run's record stays `running` on purpose:
|
|
52
|
+
* nothing may finish it but its owner's close, and later Checks wait on it. `Status: running` beside
|
|
53
|
+
* `Executor: quiescent` read as a turn still working, so the line says it is held, and whether its turn has stopped.
|
|
54
|
+
*/
|
|
55
|
+
export declare function statusText(review: DutyRunRecoveryReview): string;
|
|
56
|
+
/**
|
|
57
|
+
* Why the result is held, as its hold writer recorded it (OSK-33272), and what to do next. A reason or cause this CLI
|
|
58
|
+
* has no words for is printed as the code, marked. A Run stopped at its effect boundary says why on its own line
|
|
59
|
+
* (`unprovenLine`), so nothing here. An older server names no reason: say so, never fall silent.
|
|
60
|
+
*/
|
|
61
|
+
export declare function heldBecauseLines(review: DutyRunRecoveryReview): string[];
|
|
@@ -5,6 +5,8 @@ exports.recoveryCode = recoveryCode;
|
|
|
5
5
|
exports.closeLines = closeLines;
|
|
6
6
|
exports.autoRecoveryLines = autoRecoveryLines;
|
|
7
7
|
exports.unprovenLine = unprovenLine;
|
|
8
|
+
exports.statusText = statusText;
|
|
9
|
+
exports.heldBecauseLines = heldBecauseLines;
|
|
8
10
|
const core_1 = require("@oclif/core");
|
|
9
11
|
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
10
12
|
const base_command_1 = require("../../../base-command");
|
|
@@ -98,8 +100,10 @@ class AgentsAlwaysOnRecoveryReview extends base_command_1.BaseCommand {
|
|
|
98
100
|
this.log(`Run: ${review.runId}`);
|
|
99
101
|
if (review.source === 'unverified')
|
|
100
102
|
this.log("Duty: not shown; this run's link to its Duty could not be verified");
|
|
101
|
-
this.log(`Status: ${review
|
|
103
|
+
this.log(`Status: ${statusText(review)}; generation: ${review.generation ?? 'unknown'}; attempt: ${review.attempt ?? 'unknown'}`);
|
|
102
104
|
this.log(`Recovery: ${recoveryCode(review.hold, exports.RECOVERY_HOLD_CODES)}; stored result: ${review.result}`);
|
|
105
|
+
for (const line of heldBecauseLines(review))
|
|
106
|
+
this.log(line);
|
|
103
107
|
this.log(`Executor: ${recoveryCode(review.executor, exports.RECOVERY_EXECUTOR_CODES)}; effects: ${review.effects}`);
|
|
104
108
|
const basis = stopBasisLine(review);
|
|
105
109
|
if (basis)
|
|
@@ -308,19 +312,65 @@ function unprovenLine(review) {
|
|
|
308
312
|
...workspace,
|
|
309
313
|
].join(' ');
|
|
310
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* The Run's stored status, and what it means while held (OSK-33272). A held Run's record stays `running` on purpose:
|
|
317
|
+
* nothing may finish it but its owner's close, and later Checks wait on it. `Status: running` beside
|
|
318
|
+
* `Executor: quiescent` read as a turn still working, so the line says it is held, and whether its turn has stopped.
|
|
319
|
+
*/
|
|
320
|
+
function statusText(review) {
|
|
321
|
+
if (review.hold !== 'review_required' || review.status !== 'running')
|
|
322
|
+
return review.status;
|
|
323
|
+
if (review.executor === 'quiescent')
|
|
324
|
+
return 'running (held for review; its turn has stopped)';
|
|
325
|
+
if (review.executor === 'stop_unconfirmed')
|
|
326
|
+
return 'running (held for review; its turn is not confirmed stopped)';
|
|
327
|
+
return 'running (held for review)';
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Why the result is held, as its hold writer recorded it (OSK-33272), and what to do next. A reason or cause this CLI
|
|
331
|
+
* has no words for is printed as the code, marked. A Run stopped at its effect boundary says why on its own line
|
|
332
|
+
* (`unprovenLine`), so nothing here. An older server names no reason: say so, never fall silent.
|
|
333
|
+
*/
|
|
334
|
+
function heldBecauseLines(review) {
|
|
335
|
+
if (review.hold !== 'review_required' || review.effectReceipts !== undefined)
|
|
336
|
+
return [];
|
|
337
|
+
const reason = isNonEmptyString(review.holdReason) ? review.holdReason : undefined;
|
|
338
|
+
if (!reason)
|
|
339
|
+
return ['Held because: not reported by this server.'];
|
|
340
|
+
const words = (0, data_provider_1.describeDutyResultHoldReason)(reason);
|
|
341
|
+
const lines = [
|
|
342
|
+
`Held because: ${words ? `${reason}. ${words}` : recoveryCode(reason, data_provider_1.DUTY_RESULT_HOLD_REASONS)}`,
|
|
343
|
+
];
|
|
344
|
+
const cause = isNonEmptyString(review.holdCause) ? review.holdCause : undefined;
|
|
345
|
+
const remedy = cause ? (0, data_provider_1.describeRunFailureRemedy)(cause) : null;
|
|
346
|
+
if (cause) {
|
|
347
|
+
const causeWords = Object.hasOwn(data_provider_1.DUTY_RESULT_HOLD_CAUSE_SENTENCES, cause)
|
|
348
|
+
? data_provider_1.DUTY_RESULT_HOLD_CAUSE_SENTENCES[cause]
|
|
349
|
+
: undefined;
|
|
350
|
+
lines.push(`Cause: ${causeWords ? `${cause}. ${causeWords}` : cause}`);
|
|
351
|
+
}
|
|
352
|
+
lines.push(`Next: ${remedy ? `${remedy.replace(/\.?$/, '.')} Then: ` : ''}${data_provider_1.DUTY_RESULT_HOLD_NEXT_STEP}`);
|
|
353
|
+
return lines;
|
|
354
|
+
}
|
|
311
355
|
/** One line per held result: what a person needs to choose which one to open. */
|
|
312
356
|
function reviewLine(review) {
|
|
313
357
|
const stored = review.resultCapture === 'unsealable'
|
|
314
358
|
? `${review.result} (could not be sealed)`
|
|
315
359
|
: review.result;
|
|
360
|
+
const reason = isNonEmptyString(review.holdReason)
|
|
361
|
+
? `held because: ${recoveryCode(review.holdReason, data_provider_1.DUTY_RESULT_HOLD_REASONS)}${isNonEmptyString(review.holdCause) ? ` (${review.holdCause})` : ''}`
|
|
362
|
+
: '';
|
|
316
363
|
return [
|
|
317
364
|
review.runId,
|
|
318
365
|
review.source === 'unverified' ? 'duty unverified' : `duty ${review.dutyId ?? 'unknown'}`,
|
|
319
366
|
`recovery: ${recoveryCode(review.hold, exports.RECOVERY_HOLD_CODES)}`,
|
|
367
|
+
reason,
|
|
320
368
|
`stored result: ${stored}`,
|
|
321
369
|
`run status: ${review.status}`,
|
|
322
370
|
`attempt: ${review.attempt ?? 'unknown'}`,
|
|
323
|
-
]
|
|
371
|
+
]
|
|
372
|
+
.filter(Boolean)
|
|
373
|
+
.join(' ');
|
|
324
374
|
}
|
|
325
375
|
const isNonEmptyString = (value) => typeof value === 'string' && value.length > 0;
|
|
326
376
|
function parseReviewPage(value) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base-command';
|
|
2
|
+
export default class AgentsPermissionsList extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
agentId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
static flags: {
|
|
9
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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 permission_rules_1 = require("../../../lib/permission-rules");
|
|
7
|
+
class AgentsPermissionsList extends base_command_1.BaseCommand {
|
|
8
|
+
static description = 'List the "Always allow" rules you granted this agent: what each covers, where it applies, where you granted it from, and how often it has run. Calls a rule covers run without asking you. Only your own rules are listed. Rules are granted on a permission card, never from the CLI.';
|
|
9
|
+
static examples = [
|
|
10
|
+
'<%= config.bin %> agents permissions list <agent-id>',
|
|
11
|
+
'<%= config.bin %> agents permissions list <agent-id> --json',
|
|
12
|
+
];
|
|
13
|
+
static args = { agentId: core_1.Args.string({ required: true, ignoreStdin: true }) };
|
|
14
|
+
static flags = { json: core_1.Flags.boolean({ description: 'Output JSON' }) };
|
|
15
|
+
async run() {
|
|
16
|
+
this.requireAuth();
|
|
17
|
+
const { args, flags } = await this.parse(AgentsPermissionsList);
|
|
18
|
+
let result;
|
|
19
|
+
try {
|
|
20
|
+
result = await data_provider_1.dataService.listAgentPermissionRules(args.agentId);
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
this.handleApiError(err);
|
|
24
|
+
}
|
|
25
|
+
const rules = result.rules ?? [];
|
|
26
|
+
if (flags.json)
|
|
27
|
+
return this.log(this.agentJson(args.agentId, { rules }));
|
|
28
|
+
if (rules.length === 0) {
|
|
29
|
+
this.log(`Agent ${args.agentId}: no Always allow rules. It asks you before each call.`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
this.log(`Agent ${args.agentId}: ${rules.length === 1 ? '1 Always allow rule' : `${rules.length} Always allow rules`}`);
|
|
33
|
+
for (const rule of rules) {
|
|
34
|
+
this.log('');
|
|
35
|
+
for (const line of (0, permission_rules_1.ruleLines)(rule))
|
|
36
|
+
this.log(line);
|
|
37
|
+
}
|
|
38
|
+
this.log('');
|
|
39
|
+
this.log(`Remove one: ${this.config.bin} agents permissions remove ${args.agentId} <rule-id>`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.default = AgentsPermissionsList;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base-command';
|
|
2
|
+
export default class AgentsPermissionsRemove extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static args: {
|
|
6
|
+
agentId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
7
|
+
ruleId: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
8
|
+
};
|
|
9
|
+
static flags: {
|
|
10
|
+
all: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
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 prompt_1 = require("../../../lib/prompt");
|
|
7
|
+
class AgentsPermissionsRemove extends base_command_1.BaseCommand {
|
|
8
|
+
static description = 'Remove one of your "Always allow" rules for this agent, or all of them with --all. The next call a removed rule covered asks you again. This only takes permission away: rules are granted on a permission card, never from the CLI.';
|
|
9
|
+
static examples = [
|
|
10
|
+
'<%= config.bin %> agents permissions remove <agent-id> <rule-id>',
|
|
11
|
+
'<%= config.bin %> agents permissions remove <agent-id> --all',
|
|
12
|
+
'<%= config.bin %> agents permissions remove <agent-id> --all --yes',
|
|
13
|
+
];
|
|
14
|
+
static args = {
|
|
15
|
+
agentId: core_1.Args.string({ required: true, ignoreStdin: true }),
|
|
16
|
+
ruleId: core_1.Args.string({
|
|
17
|
+
required: false,
|
|
18
|
+
ignoreStdin: true,
|
|
19
|
+
description: 'The rule to remove (from `agents permissions list`)',
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
22
|
+
static flags = {
|
|
23
|
+
all: core_1.Flags.boolean({ description: 'Remove every rule you granted this agent: always ask' }),
|
|
24
|
+
yes: core_1.Flags.boolean({ char: 'y', description: 'Skip the confirmation for --all' }),
|
|
25
|
+
json: core_1.Flags.boolean({ description: 'Output JSON' }),
|
|
26
|
+
};
|
|
27
|
+
async run() {
|
|
28
|
+
this.requireAuth();
|
|
29
|
+
const { args, flags } = await this.parse(AgentsPermissionsRemove);
|
|
30
|
+
const all = Boolean(flags.all);
|
|
31
|
+
if (Boolean(args.ruleId) === all) {
|
|
32
|
+
this.error('Name one rule to remove, or pass --all to remove every rule.', { exit: 2 });
|
|
33
|
+
}
|
|
34
|
+
let result;
|
|
35
|
+
if (all) {
|
|
36
|
+
const ok = await (0, prompt_1.confirmDestructive)(`Remove every Always allow rule you granted agent ${args.agentId}? It will ask you before each call again.`, flags.yes);
|
|
37
|
+
if (!ok) {
|
|
38
|
+
this.log('Nothing removed.');
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
result = await data_provider_1.dataService.revokeAllAgentPermissionRules(args.agentId);
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
this.handleApiError(err);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
try {
|
|
50
|
+
result = await data_provider_1.dataService.revokeAgentPermissionRule(args.agentId, args.ruleId);
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
this.handleApiError(err);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const revoked = result.revoked ?? 0;
|
|
57
|
+
if (flags.json)
|
|
58
|
+
return this.log(this.agentJson(args.agentId, { revoked }));
|
|
59
|
+
if (all) {
|
|
60
|
+
this.log(revoked === 0
|
|
61
|
+
? `Agent ${args.agentId}: you had no Always allow rules. It asks you before each call.`
|
|
62
|
+
: `Agent ${args.agentId}: removed ${revoked === 1 ? '1 rule' : `${revoked} rules`}. It asks you before each call again.`);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this.log(`Agent ${args.agentId}: rule ${args.ruleId} removed. The next call it covered asks you again.`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.default = AgentsPermissionsRemove;
|
package/dist/commands/dm/work.js
CHANGED
|
@@ -71,6 +71,8 @@ class DmWork extends base_command_1.BaseCommand {
|
|
|
71
71
|
const handling = (0, data_provider_1.readCoordinatorSignalReason)(task.lastReturn?.reason);
|
|
72
72
|
if (task.lastReturn && handling) {
|
|
73
73
|
this.log(` Last update (${task.lastReturn.kind.replaceAll('_', ' ')}): ${(0, data_provider_1.describeCoordinatorHandling)(handling)}`);
|
|
74
|
+
if (handling.outcome === 'held' && task.lastReturn.heldText)
|
|
75
|
+
this.log(` Held message: ${task.lastReturn.heldText}`);
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
this.log(`${page.items.length} shown; ${page.total} authorized Task(s)${page.hasMore ? `; next cursor ${page.nextCursor}` : ''}.`);
|
|
@@ -41,7 +41,13 @@ class DutiesActionProposal extends base_command_1.BaseCommand {
|
|
|
41
41
|
this.log(`Action Bundle: ${proposal?.status ? (0, action_proposals_1.proposalStatusLabel)(proposal) : 'unknown'}`);
|
|
42
42
|
this.log(`Operation: ${String(execution?.operationId || 'unavailable')}`);
|
|
43
43
|
const receipt = execution?.receipt;
|
|
44
|
-
|
|
44
|
+
// A void bundle's receipt still reads `accepted`, because its status is still held (OSK-33446). Say
|
|
45
|
+
// beside it that the plan will not run, and that its expiry and reminders no longer apply.
|
|
46
|
+
const isVoid = proposal ? (0, action_proposals_1.proposalVoidedBy)(proposal) !== undefined : false;
|
|
47
|
+
this.log(`Receipt: ${String(receipt?.state || 'unknown')}${isVoid ? ' (void: will not run)' : ''}`);
|
|
48
|
+
if (isVoid) {
|
|
49
|
+
this.log("Expiry and reminders: not applicable; the Duty's next check can propose the work again.");
|
|
50
|
+
}
|
|
45
51
|
}
|
|
46
52
|
}
|
|
47
53
|
}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { BaseCommand } from '../../base-command';
|
|
2
|
+
/**
|
|
3
|
+
* Why a held bundle can never be approved or run, or `undefined` when it is not void. The server keeps
|
|
4
|
+
* `status` at `proposed` or `approved` and adds `voidedBy`, so this, not `status`, says whether a decision
|
|
5
|
+
* or a run is still possible (OSK-33415). Only a held bundle can be void: a finished one keeps its status.
|
|
6
|
+
*/
|
|
7
|
+
export declare function proposalVoidedBy(proposal: {
|
|
8
|
+
status?: unknown;
|
|
9
|
+
voidedBy?: unknown;
|
|
10
|
+
}): string | undefined;
|
|
2
11
|
/**
|
|
3
12
|
* An approved bundle waiting out the owner's quiet hours reads as held, with
|
|
4
13
|
* the instant it sends, never as a bare `approved` that looks stuck.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.proposalVoidedBy = proposalVoidedBy;
|
|
3
4
|
exports.proposalStatusLabel = proposalStatusLabel;
|
|
4
5
|
const core_1 = require("@oclif/core");
|
|
5
6
|
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
@@ -11,14 +12,26 @@ const VOIDED_BY_LABEL = {
|
|
|
11
12
|
duty_not_active: 'void: Duty not active',
|
|
12
13
|
duty_version_changed: 'void: Duty changed since',
|
|
13
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Why a held bundle can never be approved or run, or `undefined` when it is not void. The server keeps
|
|
17
|
+
* `status` at `proposed` or `approved` and adds `voidedBy`, so this, not `status`, says whether a decision
|
|
18
|
+
* or a run is still possible (OSK-33415). Only a held bundle can be void: a finished one keeps its status.
|
|
19
|
+
*/
|
|
20
|
+
function proposalVoidedBy(proposal) {
|
|
21
|
+
if (typeof proposal.voidedBy !== 'string' || !proposal.voidedBy)
|
|
22
|
+
return undefined;
|
|
23
|
+
return proposal.status === 'proposed' || proposal.status === 'approved'
|
|
24
|
+
? proposal.voidedBy
|
|
25
|
+
: undefined;
|
|
26
|
+
}
|
|
14
27
|
/**
|
|
15
28
|
* An approved bundle waiting out the owner's quiet hours reads as held, with
|
|
16
29
|
* the instant it sends, never as a bare `approved` that looks stuck.
|
|
17
30
|
*/
|
|
18
31
|
function proposalStatusLabel(proposal) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
32
|
+
const voidedBy = proposalVoidedBy(proposal);
|
|
33
|
+
if (voidedBy)
|
|
34
|
+
return VOIDED_BY_LABEL[voidedBy] || `void: ${voidedBy}`;
|
|
22
35
|
const hold = proposal.executionReceipt?.hold;
|
|
23
36
|
if (proposal.status === 'approved' && hold?.until) {
|
|
24
37
|
return `held until ${hold.untilLabel || hold.until}`;
|
|
@@ -66,15 +79,20 @@ class DutiesActionProposals extends base_command_1.BaseCommand {
|
|
|
66
79
|
for (const peer of proposal.overlaps || [])
|
|
67
80
|
this.log(`${proposal.id} overlaps ${peer.proposalId} (${peer.agentId}) ${peer.repoFullName}: ${peer.paths.join(', ')}`);
|
|
68
81
|
}
|
|
69
|
-
(0, format_1.renderTable)(response.data.map((proposal) =>
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
82
|
+
(0, format_1.renderTable)(response.data.map((proposal) => {
|
|
83
|
+
// A void bundle will never run, so its expiry and its approver reminders no longer apply
|
|
84
|
+
// (OSK-33446): showing them would read as a decision still waiting on someone.
|
|
85
|
+
const isVoid = proposalVoidedBy(proposal) !== undefined;
|
|
86
|
+
return {
|
|
87
|
+
id: proposal.id,
|
|
88
|
+
actions: String(proposal.actionSnapshots?.length || 1),
|
|
89
|
+
digest: proposal.snapshotDigest || 'legacy',
|
|
90
|
+
status: proposalStatusLabel(proposal),
|
|
91
|
+
attempt: `${proposal.attempt || 0}/${proposal.maxAttempts || 3}`,
|
|
92
|
+
expires: isVoid ? '—' : proposal.expiresAt || '—',
|
|
93
|
+
notices: isVoid ? '—' : (0, data_provider_1.describeProposalNotices)(proposal.notices),
|
|
94
|
+
};
|
|
95
|
+
}), [
|
|
78
96
|
{ key: 'id', header: 'PROPOSAL', verbatim: true },
|
|
79
97
|
{ key: 'actions', header: 'ACTIONS' },
|
|
80
98
|
{ key: 'digest', header: 'DIGEST', maxWidth: 64, verbatim: true },
|
|
@@ -9,6 +9,13 @@ export declare function manualCheckBlockerLines(result: Record<string, unknown>,
|
|
|
9
9
|
* searched for and quoted. `null` for a reason this does not know: the caller prints it as it came.
|
|
10
10
|
*/
|
|
11
11
|
export declare function describeNotQueuedReason(reason: unknown, id: string, bin?: string): string | null;
|
|
12
|
+
/**
|
|
13
|
+
* The lines for a Check now the server answered without queueing because the unreadable-observation
|
|
14
|
+
* backoff would hold it (OSK-33271): its Agent would not start, so nothing was queued. The sentence
|
|
15
|
+
* and the fix are the server's (the stop the Check would have recorded); the CLI adds the time and
|
|
16
|
+
* where to look. Empty for any other answer.
|
|
17
|
+
*/
|
|
18
|
+
export declare function backoffHoldLines(result: Record<string, unknown>, id: string, bin?: string): string[];
|
|
12
19
|
/**
|
|
13
20
|
* `skrr duties check-now <id>` — run one control-loop iteration immediately.
|
|
14
21
|
*
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.manualCheckBlockerLines = manualCheckBlockerLines;
|
|
4
4
|
exports.describeNotQueuedReason = describeNotQueuedReason;
|
|
5
|
+
exports.backoffHoldLines = backoffHoldLines;
|
|
5
6
|
const core_1 = require("@oclif/core");
|
|
7
|
+
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
6
8
|
const base_command_1 = require("../../base-command");
|
|
7
9
|
const web_url_1 = require("../../lib/web-url");
|
|
8
10
|
const duties_1 = require("../../lib/duties");
|
|
@@ -64,6 +66,35 @@ function describeNotQueuedReason(reason, id, bin = 'skrr') {
|
|
|
64
66
|
return null;
|
|
65
67
|
}
|
|
66
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* The lines for a Check now the server answered without queueing because the unreadable-observation
|
|
71
|
+
* backoff would hold it (OSK-33271): its Agent would not start, so nothing was queued. The sentence
|
|
72
|
+
* and the fix are the server's (the stop the Check would have recorded); the CLI adds the time and
|
|
73
|
+
* where to look. Empty for any other answer.
|
|
74
|
+
*/
|
|
75
|
+
function backoffHoldLines(result, id, bin = 'skrr') {
|
|
76
|
+
const reason = result.reason;
|
|
77
|
+
if (result.status !== 'skipped' ||
|
|
78
|
+
typeof reason !== 'string' ||
|
|
79
|
+
!data_provider_1.DUTY_CHECK_NOW_BACKOFF_REASONS.includes(reason)) {
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
const at = typeof result.nextAttemptAt === 'string' && result.nextAttemptAt ? result.nextAttemptAt : null;
|
|
83
|
+
const lines = [
|
|
84
|
+
reason === 'held_report_backoff'
|
|
85
|
+
? `Nothing was queued: the agent would not start, because its last report is held for approval (${reason}).`
|
|
86
|
+
: `Nothing was queued: the agent would not start, because the declared observations it reads came back unreadable and are on backoff (${reason}).`,
|
|
87
|
+
at
|
|
88
|
+
? `Next attempt allowed: the first check after ${at} (UTC).`
|
|
89
|
+
: 'Next attempt allowed: at a later check.',
|
|
90
|
+
];
|
|
91
|
+
if (typeof result.detail === 'string' && result.detail.trim())
|
|
92
|
+
lines.push(result.detail.trim());
|
|
93
|
+
if (typeof result.fix === 'string' && result.fix.trim())
|
|
94
|
+
lines.push(`Fix: ${result.fix.trim()}`);
|
|
95
|
+
lines.push(`See the last run's readings with \`${bin} duties observations ${id} --latest\`.`);
|
|
96
|
+
return lines;
|
|
97
|
+
}
|
|
67
98
|
/**
|
|
68
99
|
* `skrr duties check-now <id>` — run one control-loop iteration immediately.
|
|
69
100
|
*
|
|
@@ -113,8 +144,12 @@ class DutiesCheckNow extends base_command_1.BaseCommand {
|
|
|
113
144
|
: 'The server queued a regular Check. Version verification was not confirmed.');
|
|
114
145
|
}
|
|
115
146
|
if (status !== 'queued') {
|
|
147
|
+
const holdLines = backoffHoldLines(result, args.id, this.config.bin);
|
|
116
148
|
const sentence = describeNotQueuedReason(result.reason, args.id, this.config.bin);
|
|
117
|
-
if (
|
|
149
|
+
if (holdLines.length)
|
|
150
|
+
for (const line of holdLines)
|
|
151
|
+
this.log(line);
|
|
152
|
+
else if (sentence)
|
|
118
153
|
this.log(sentence);
|
|
119
154
|
else if (result.reason)
|
|
120
155
|
this.log(`Reason: ${String(result.reason)}`);
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
+
import { type DutyContractDifference } from '@skrr-ai/data-provider';
|
|
1
2
|
import { BaseCommand } from '../../base-command';
|
|
2
3
|
import { type AgentGuidePointer } from '../../lib/guide-pointer';
|
|
4
|
+
/**
|
|
5
|
+
* The `duties update` that applies what `create --activate` supplied and the existing Duty did
|
|
6
|
+
* not take (OSK-33270). Fields with a flag of their own get that flag, with the value from this
|
|
7
|
+
* request (never the server's bounded preview); everything else is a `--from-json` patch.
|
|
8
|
+
*/
|
|
9
|
+
export declare function existingDutyEditCommand({ dutyId, differences, payload, directiveFile, bin, }: {
|
|
10
|
+
dutyId: string;
|
|
11
|
+
differences: DutyContractDifference[];
|
|
12
|
+
payload: Record<string, unknown>;
|
|
13
|
+
directiveFile?: string;
|
|
14
|
+
bin?: string;
|
|
15
|
+
}): string;
|
|
3
16
|
/** Do not silently discard a JSON source's scope or event filters. */
|
|
4
17
|
export declare function applyWatchedSourceFlags(payload: Record<string, unknown>, built: Array<Record<string, unknown>> | undefined): void;
|
|
5
18
|
/**
|
|
@@ -88,4 +101,6 @@ export default class DutiesCreate extends BaseCommand {
|
|
|
88
101
|
'concurrency-reason': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
89
102
|
};
|
|
90
103
|
run(): Promise<void>;
|
|
104
|
+
/** The server's refusal of a start that landed on a Duty holding a different contract. */
|
|
105
|
+
private reportExistingContractDiffers;
|
|
91
106
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.existingDutyEditCommand = existingDutyEditCommand;
|
|
3
4
|
exports.applyWatchedSourceFlags = applyWatchedSourceFlags;
|
|
4
5
|
exports.hasEventCapableWatchedSource = hasEventCapableWatchedSource;
|
|
5
6
|
exports.assertEventDrivenWatchedSource = assertEventDrivenWatchedSource;
|
|
@@ -16,6 +17,40 @@ const triggers_1 = require("../../lib/triggers");
|
|
|
16
17
|
const duty_product_1 = require("../../lib/duty-product");
|
|
17
18
|
const duties_1 = require("../../lib/duties");
|
|
18
19
|
const DUTY_ACTIVATION_REFUSAL_RE = /^[A-Za-z][A-Za-z0-9_]*$/;
|
|
20
|
+
function shellWord(value) {
|
|
21
|
+
return /^[A-Za-z0-9_./:@-]+$/.test(value) ? value : JSON.stringify(value);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The `duties update` that applies what `create --activate` supplied and the existing Duty did
|
|
25
|
+
* not take (OSK-33270). Fields with a flag of their own get that flag, with the value from this
|
|
26
|
+
* request (never the server's bounded preview); everything else is a `--from-json` patch.
|
|
27
|
+
*/
|
|
28
|
+
function existingDutyEditCommand({ dutyId, differences, payload, directiveFile, bin = 'skrr', }) {
|
|
29
|
+
const remaining = new Set(differences.map((item) => item.field));
|
|
30
|
+
const parts = [`${bin} duties update ${dutyId}`];
|
|
31
|
+
if (remaining.has('title') && typeof payload.title === 'string') {
|
|
32
|
+
parts.push(`--title ${shellWord(payload.title)}`);
|
|
33
|
+
remaining.delete('title');
|
|
34
|
+
}
|
|
35
|
+
if (remaining.has('description') && typeof payload.description === 'string') {
|
|
36
|
+
parts.push(`--description ${shellWord(payload.description)}`);
|
|
37
|
+
remaining.delete('description');
|
|
38
|
+
}
|
|
39
|
+
if (remaining.has('agentDirective')) {
|
|
40
|
+
parts.push(`--agent-directive-file ${directiveFile ? shellWord(directiveFile) : '<file>'}`);
|
|
41
|
+
remaining.delete('agentDirective');
|
|
42
|
+
}
|
|
43
|
+
const outcome = record(payload.target)?.outcome;
|
|
44
|
+
if (remaining.has('target') &&
|
|
45
|
+
typeof outcome === 'string' &&
|
|
46
|
+
differences.every((item) => item.field !== 'target' || item.path === 'target.outcome')) {
|
|
47
|
+
parts.push(`--outcome ${shellWord(outcome)}`);
|
|
48
|
+
remaining.delete('target');
|
|
49
|
+
}
|
|
50
|
+
if (remaining.size)
|
|
51
|
+
parts.push(`--from-json <patch.json with ${[...remaining].join(', ')}>`);
|
|
52
|
+
return parts.join(' ');
|
|
53
|
+
}
|
|
19
54
|
const DEFAULT_EVENT_DRIVEN_BACKSTOP_MS = 24 * 60 * 60 * 1000;
|
|
20
55
|
const DEFAULT_EVENT_SOURCES = new Set(['github', 'slack', 'email', 'calendar']);
|
|
21
56
|
/**
|
|
@@ -141,8 +176,11 @@ function assertEventDrivenWatchedSource(payload) {
|
|
|
141
176
|
const hasInvalidEvents = sources.some((value) => {
|
|
142
177
|
const source = record(value);
|
|
143
178
|
const config = record(source?.config);
|
|
144
|
-
return source?.enabled !== false &&
|
|
145
|
-
|
|
179
|
+
return (source?.enabled !== false &&
|
|
180
|
+
source?.source !== 'tasks' &&
|
|
181
|
+
source?.source !== 'goal' &&
|
|
182
|
+
Array.isArray(config?.events) &&
|
|
183
|
+
!hasStructurallyValidExplicitEvent(config));
|
|
146
184
|
});
|
|
147
185
|
if (hasInvalidEvents) {
|
|
148
186
|
throw new Error('Event-driven cadence requires at least one event-capable watched source. ' +
|
|
@@ -269,7 +307,9 @@ function dutyActivationRefusal(err, { id, bin }) {
|
|
|
269
307
|
reason: refusal.message || (err instanceof Error ? err.message : 'Activation was refused.'),
|
|
270
308
|
fix: hint
|
|
271
309
|
? `${hint} Then run \`${bin} duties resume ${id}\`.`
|
|
272
|
-
: (0, data_provider_1.describeDutyActivationFix)(code === 'DUTY_ACTIVATION_REFUSED' ? undefined : code, {
|
|
310
|
+
: (0, data_provider_1.describeDutyActivationFix)(code === 'DUTY_ACTIVATION_REFUSED' ? undefined : code, {
|
|
311
|
+
turnOn: `run \`${bin} duties resume ${id}\``,
|
|
312
|
+
}),
|
|
273
313
|
...(guide ? { guide } : {}),
|
|
274
314
|
...(blockers.length > 1 ? { blockers } : {}),
|
|
275
315
|
};
|
|
@@ -368,7 +408,7 @@ JSON
|
|
|
368
408
|
}),
|
|
369
409
|
activate: core_1.Flags.boolean({
|
|
370
410
|
description: 'Turn the duty on right after creating it — the same resume + Preflight boundary ' +
|
|
371
|
-
|
|
411
|
+
'as `duties resume`. A refusal reports its code, reason and fix, and exits nonzero. ' +
|
|
372
412
|
'If a new draft was saved, use its returned ID to resume it.',
|
|
373
413
|
}),
|
|
374
414
|
deadline: core_1.Flags.string({ description: 'ISO-8601 deadline for an `achieve` duty' }),
|
|
@@ -614,7 +654,21 @@ JSON
|
|
|
614
654
|
duty = await duties_1.dutyApi.create(flags.activate ? { ...payload, activate: true } : payload);
|
|
615
655
|
}
|
|
616
656
|
catch (err) {
|
|
617
|
-
const { body } = (0, base_command_1.apiRefusal)(err);
|
|
657
|
+
const { body, code } = (0, base_command_1.apiRefusal)(err);
|
|
658
|
+
// The start landed on an existing Duty that holds a different contract, and the server
|
|
659
|
+
// refused it (OSK-33270). Report it the way OSK-32836 reported a different cadence mode:
|
|
660
|
+
// the existing Duty, `activated: false`, the refusal and its fix, and a nonzero exit.
|
|
661
|
+
if (flags.activate &&
|
|
662
|
+
code === data_provider_1.DUTY_EXISTING_CONTRACT_DIFFERS &&
|
|
663
|
+
record(body?.duty) &&
|
|
664
|
+
Array.isArray(body?.differences)) {
|
|
665
|
+
this.reportExistingContractDiffers(body, {
|
|
666
|
+
payload,
|
|
667
|
+
directiveFile: flags['agent-directive-file'],
|
|
668
|
+
json: flags.json === true,
|
|
669
|
+
});
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
618
672
|
const details = body?.details;
|
|
619
673
|
const olderServer = flags.activate &&
|
|
620
674
|
Array.isArray(details) &&
|
|
@@ -635,6 +689,8 @@ JSON
|
|
|
635
689
|
// A refusal is reported on the result — never thrown over the draft's id.
|
|
636
690
|
let activation = null;
|
|
637
691
|
const start = duty?.directStart;
|
|
692
|
+
// The server refuses this itself now, with every differing field (OSK-33270, above). This
|
|
693
|
+
// stays for a server older than that, which still answers `existing` with the stored Duty.
|
|
638
694
|
const requestedController = record(record(payload.policy)?.cadenceController);
|
|
639
695
|
const existingController = duty?.policy?.cadenceController;
|
|
640
696
|
const mismatchedSetting = start?.state === 'existing' && duty?.status === 'active'
|
|
@@ -736,5 +792,37 @@ JSON
|
|
|
736
792
|
this.warn(`Guide: ${refusal.guide.command}`);
|
|
737
793
|
}
|
|
738
794
|
}
|
|
795
|
+
/** The server's refusal of a start that landed on a Duty holding a different contract. */
|
|
796
|
+
reportExistingContractDiffers(body, { payload, directiveFile, json, }) {
|
|
797
|
+
const { duty, differences } = body;
|
|
798
|
+
const bin = this.config.bin;
|
|
799
|
+
const fix = `Edit the existing Duty instead: \`${existingDutyEditCommand({ dutyId: duty.id, differences, payload, directiveFile, bin })}\`. ` +
|
|
800
|
+
`To keep it and add a second Duty, create the new one without --activate, then run \`${bin} duties resume <new-duty-id>\`.`;
|
|
801
|
+
process.exitCode = 1;
|
|
802
|
+
if (json) {
|
|
803
|
+
this.log(JSON.stringify((0, web_url_1.withDutyUrl)(this.cliConfig.baseURL, {
|
|
804
|
+
...duty,
|
|
805
|
+
activated: false,
|
|
806
|
+
refusal: {
|
|
807
|
+
code: body.code,
|
|
808
|
+
reason: body.message,
|
|
809
|
+
differences,
|
|
810
|
+
...(body.differencesTruncated ? { differencesTruncated: true } : {}),
|
|
811
|
+
fix,
|
|
812
|
+
},
|
|
813
|
+
}), null, 2));
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
this.log('Existing duty:');
|
|
817
|
+
(0, duties_1.renderDutySummary)(duty, (line) => this.log(line));
|
|
818
|
+
this.warn(`Not created or started (${body.code}): ${body.message}`);
|
|
819
|
+
this.warn('Supplied here, held differently by that Duty, and not applied:');
|
|
820
|
+
for (const item of differences) {
|
|
821
|
+
this.warn(` - ${item.path}: it has ${item.stored ?? '(nothing)'}; this request had ${item.requested ?? '(nothing)'}`);
|
|
822
|
+
}
|
|
823
|
+
if (body.differencesTruncated)
|
|
824
|
+
this.warn(' - …and more.');
|
|
825
|
+
this.warn(`Fix: ${fix}`);
|
|
826
|
+
}
|
|
739
827
|
}
|
|
740
828
|
exports.default = DutiesCreate;
|