@skrr-ai/cli 0.1.152 → 0.1.153
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/send.d.ts +3 -1
- package/dist/commands/agent/message/send.js +52 -1
- package/dist/commands/agents/always-on/held-messages.d.ts +22 -0
- package/dist/commands/agents/always-on/held-messages.js +62 -0
- package/dist/commands/agents/always-on/release-run.d.ts +37 -0
- package/dist/commands/agents/always-on/release-run.js +92 -0
- package/dist/commands/agents/always-on/status.js +5 -0
- package/dist/commands/duties/create.js +24 -9
- package/dist/commands/duties/export.js +2 -1
- package/dist/commands/duties/preflight.js +17 -0
- package/dist/commands/duties/update.d.ts +1 -0
- package/dist/commands/duties/update.js +87 -66
- package/dist/commands/triggers/fire-detail.js +19 -0
- package/dist/generated/agent-guides.json +35 -35
- package/dist/lib/duties.d.ts +5 -0
- package/dist/lib/duties.js +75 -1
- package/dist/lib/duty-event-wakes.js +6 -3
- package/dist/lib/duty-loop-status.js +26 -2
- package/dist/lib/duty-product.js +4 -1
- package/dist/lib/held-messages.d.ts +11 -0
- package/dist/lib/held-messages.js +93 -0
- package/dist/lib/message-intent.d.ts +15 -0
- package/dist/lib/roles.d.ts +1 -1
- package/dist/lib/triggers.d.ts +13 -1
- package/dist/lib/triggers.js +43 -0
- package/dist/lib/update-check.js +9 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/dutyExecutionContract.d.ts +1 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/dutyExecutionContract.js +1 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/dutyExecutionContract.d.ts +1 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/dutyExecutionContract.js +1 -1
- package/dist/node_modules/@skrr-ai/data-provider/index.js +6070 -6030
- package/oclif.manifest.json +191 -2
- package/package.json +4 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type EntityEmbed } from '@skrr-ai/data-provider';
|
|
2
2
|
import { BaseCommand } from '../../../base-command';
|
|
3
3
|
import { type ResolvedAgentIdentity } from '../../../lib/agent-resolver';
|
|
4
|
-
import { type CanonicalMessageDestination, type CanonicalMessageIntentRequest, type CanonicalMessageIntentResponse, type CommunicationPresentation } from '../../../lib/message-intent';
|
|
4
|
+
import { type CanonicalMessageDestination, type CanonicalMessageIntentRequest, type CanonicalMessageIntentResponse, type CommunicationPresentation, type OneVoiceOutcome } from '../../../lib/message-intent';
|
|
5
5
|
import { type WireEmbedRejection } from '../../../lib/entity-embeds';
|
|
6
6
|
/**
|
|
7
7
|
* A reading-comfort prompt, not a protocol limit. The Gateway deliberately
|
|
@@ -60,6 +60,8 @@ export type CanonicalIntentEnvelope = {
|
|
|
60
60
|
initiativeId?: string;
|
|
61
61
|
/** The owner replied after this update began — withhold the tail. */
|
|
62
62
|
ownerInterjected?: boolean;
|
|
63
|
+
/** Whether One Voice counted this message against the owner's attention budget (OSK-22367). */
|
|
64
|
+
oneVoice?: OneVoiceOutcome;
|
|
63
65
|
};
|
|
64
66
|
};
|
|
65
67
|
/**
|
|
@@ -479,6 +479,7 @@ class AgentMessageSend extends base_command_1.BaseCommand {
|
|
|
479
479
|
retryable: result.retryable,
|
|
480
480
|
initiativeId: result.initiativeId,
|
|
481
481
|
ownerInterjected: result.ownerInterjected,
|
|
482
|
+
oneVoice: result.oneVoice,
|
|
482
483
|
},
|
|
483
484
|
});
|
|
484
485
|
}
|
|
@@ -1227,7 +1228,57 @@ function formatEnvelope(envelope) {
|
|
|
1227
1228
|
? '; reach=user-controlled; presentation=user-controlled'
|
|
1228
1229
|
: ''}]`
|
|
1229
1230
|
: '';
|
|
1230
|
-
|
|
1231
|
+
const consequence = STATUS_CONSEQUENCE[status];
|
|
1232
|
+
return `Agent message intent for ${envelope.agent.id} → ${destination}: ${status}${suffix}.${presentation}${describeOneVoice(envelope.intent.oneVoice)}${consequence ? ` ${consequence}` : ''}`;
|
|
1233
|
+
}
|
|
1234
|
+
/**
|
|
1235
|
+
* What a status other than `delivered` means for the sender, in the words of
|
|
1236
|
+
* `skrr guide communication delivery-statuses` (OSK-23276). The exit code is 0 for
|
|
1237
|
+
* several of these on purpose (the platform still owns the outcome), so the exit code
|
|
1238
|
+
* cannot say "this did not reach the owner" and the text has to. It is appended after
|
|
1239
|
+
* the existing line, so anything that reads the old prefix keeps working, and `--json`
|
|
1240
|
+
* is unchanged. A status with no entry prints nothing extra rather than a guess.
|
|
1241
|
+
*/
|
|
1242
|
+
const STATUS_CONSEQUENCE = {
|
|
1243
|
+
submitted: 'Recorded and not dispatched yet; the platform still owns it. Do not resend.',
|
|
1244
|
+
held: 'Not delivered yet: policy is withholding it and it may still be delivered. Do not resend.',
|
|
1245
|
+
re_evaluation: 'Being re-checked against policy; the platform still owns it. Do not resend.',
|
|
1246
|
+
approval_required: "Not delivered yet: it is waiting for the owner's approval. Do not resend.",
|
|
1247
|
+
authorized: 'Cleared for dispatch; the platform still owns it. Do not resend.',
|
|
1248
|
+
dispatching: 'Being delivered right now. Do not resend.',
|
|
1249
|
+
transport_failed: 'Delivery errored; retryable and retryAfter in --json say whether to try again.',
|
|
1250
|
+
dropped: 'Will not be delivered. Read the reason and change the request before resending.',
|
|
1251
|
+
expired: 'It outlived its window before delivery.',
|
|
1252
|
+
cancelled: 'It was withdrawn before delivery.',
|
|
1253
|
+
duplicate: 'Nothing new was sent: this key already carried this identical update, so the earlier send stands.',
|
|
1254
|
+
accepted: 'An earlier send already delivered this update.',
|
|
1255
|
+
failed: 'The transport could not deliver it; retryable in --json says whether a retry can help.',
|
|
1256
|
+
queued_offline: 'Held by the local daemon until it can reach the platform; still in flight, do not resend.',
|
|
1257
|
+
refused: 'A guard declined the send; the reason names it.',
|
|
1258
|
+
unknown: 'The transport could not certify the outcome; do not assume it arrived or that it did not.',
|
|
1259
|
+
};
|
|
1260
|
+
/**
|
|
1261
|
+
* What the sender is told about the owner's attention budget (OSK-22367). Silence used to cover
|
|
1262
|
+
* three different facts: counted, not counted by design, and not counted because the write failed.
|
|
1263
|
+
* Only the last one is a defect, and it is spelled differently so a skim does not read it as the
|
|
1264
|
+
* second.
|
|
1265
|
+
*/
|
|
1266
|
+
const ONE_VOICE_REASON_TEXT = {
|
|
1267
|
+
interactive_session: 'an interactive session, so the owner is present',
|
|
1268
|
+
not_owner_attention_destination: "not a destination that spends the owner's attention",
|
|
1269
|
+
};
|
|
1270
|
+
function describeOneVoice(outcome) {
|
|
1271
|
+
if (!outcome)
|
|
1272
|
+
return '';
|
|
1273
|
+
if (outcome.counted)
|
|
1274
|
+
return ' One Voice: counted.';
|
|
1275
|
+
if (outcome.reason === 'accounting_failed') {
|
|
1276
|
+
return ' One Voice: NOT counted (accounting failed; heuristic producers may not back off for this message).';
|
|
1277
|
+
}
|
|
1278
|
+
const reason = outcome.reason
|
|
1279
|
+
? (ONE_VOICE_REASON_TEXT[outcome.reason] ?? outcome.reason)
|
|
1280
|
+
: 'no reason given';
|
|
1281
|
+
return ` One Voice: not counted (${reason}).`;
|
|
1231
1282
|
}
|
|
1232
1283
|
function describeDestination(destination) {
|
|
1233
1284
|
if (destination.kind === 'agent_email')
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base-command';
|
|
2
|
+
/**
|
|
3
|
+
* `skrr agents always-on held-messages <agent-id>` — list the session messages the delivery policy
|
|
4
|
+
* is holding for an agent (`GET /api/agents/:id/always-on/held-messages`).
|
|
5
|
+
*
|
|
6
|
+
* Metadata only: an id, when it was submitted, when the hold expires and a neutral reason. The API
|
|
7
|
+
* never returns message text, and a held message follows the delivery policy with no manual release,
|
|
8
|
+
* so this command is a read and has no sibling that decides one. (The `ask_first` queue is a
|
|
9
|
+
* different thing: `skrr agent message pending|approve|decline`.)
|
|
10
|
+
*/
|
|
11
|
+
export default class AgentsAlwaysOnHeldMessages extends BaseCommand {
|
|
12
|
+
static description: string;
|
|
13
|
+
static examples: string[];
|
|
14
|
+
static args: {
|
|
15
|
+
id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
16
|
+
};
|
|
17
|
+
static flags: {
|
|
18
|
+
cursor: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
20
|
+
};
|
|
21
|
+
run(): Promise<void>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
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 held_messages_1 = require("../../../lib/held-messages");
|
|
7
|
+
/**
|
|
8
|
+
* `skrr agents always-on held-messages <agent-id>` — list the session messages the delivery policy
|
|
9
|
+
* is holding for an agent (`GET /api/agents/:id/always-on/held-messages`).
|
|
10
|
+
*
|
|
11
|
+
* Metadata only: an id, when it was submitted, when the hold expires and a neutral reason. The API
|
|
12
|
+
* never returns message text, and a held message follows the delivery policy with no manual release,
|
|
13
|
+
* so this command is a read and has no sibling that decides one. (The `ask_first` queue is a
|
|
14
|
+
* different thing: `skrr agent message pending|approve|decline`.)
|
|
15
|
+
*/
|
|
16
|
+
class AgentsAlwaysOnHeldMessages extends base_command_1.BaseCommand {
|
|
17
|
+
static description = 'List the session messages held by delivery policy for an agent (metadata only; message text is never returned)';
|
|
18
|
+
static examples = [
|
|
19
|
+
'<%= config.bin %> agents always-on held-messages <agent-id>',
|
|
20
|
+
'<%= config.bin %> agents always-on held-messages <agent-id> --json',
|
|
21
|
+
'<%= config.bin %> agents always-on held-messages <agent-id> --cursor <nextCursor>',
|
|
22
|
+
];
|
|
23
|
+
static args = {
|
|
24
|
+
id: core_1.Args.string({ description: 'Agent ID', required: true, ignoreStdin: true }),
|
|
25
|
+
};
|
|
26
|
+
static flags = {
|
|
27
|
+
cursor: core_1.Flags.string({ description: "Cursor from a previous page's nextCursor" }),
|
|
28
|
+
json: core_1.Flags.boolean({ description: 'Output the server response as JSON' }),
|
|
29
|
+
};
|
|
30
|
+
async run() {
|
|
31
|
+
this.requireAuth();
|
|
32
|
+
const { args, flags } = await this.parse(AgentsAlwaysOnHeldMessages);
|
|
33
|
+
let response;
|
|
34
|
+
try {
|
|
35
|
+
response = await data_provider_1.dataService.getAlwaysOnHeldMessages(args.id, flags.cursor);
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
this.handleApiError(err);
|
|
39
|
+
}
|
|
40
|
+
// A body that is not the documented shape is an error, not an empty list: "none held" is the
|
|
41
|
+
// reading that would reassure about exactly what this command exists to show.
|
|
42
|
+
const result = (0, held_messages_1.parseHeldOwnerMessages)(response);
|
|
43
|
+
if (!result) {
|
|
44
|
+
this.failWithCliError({
|
|
45
|
+
message: 'The server returned a held-messages response this CLI does not recognise.',
|
|
46
|
+
code: 'HELD_MESSAGES_RESPONSE_UNEXPECTED',
|
|
47
|
+
exit: 1,
|
|
48
|
+
retryable: false,
|
|
49
|
+
details: {
|
|
50
|
+
suggestion: 'Update skrr, and check that the server is a release that serves GET /api/agents/:id/always-on/held-messages.',
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (flags.json) {
|
|
55
|
+
this.log(JSON.stringify(response, null, 2));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
for (const line of (0, held_messages_1.heldMessageLines)(args.id, result))
|
|
59
|
+
this.log(line);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.default = AgentsAlwaysOnHeldMessages;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base-command';
|
|
2
|
+
/**
|
|
3
|
+
* `skrr agents always-on release-run <agent-id> <run-id>` — the owner lets ONE queued Run start although the machine that
|
|
4
|
+
* ran it never confirmed it stopped, via `POST /api/agents/:id/always-on/runs/:runId/stop-release` (OSK-22700).
|
|
5
|
+
*
|
|
6
|
+
* A Run whose daemon was killed mid-turn is queued again and refused as `previous_execution_stopping`: the platform will
|
|
7
|
+
* not start a second provider request while the first may still run. `skrr triggers fire-detail` shows that wait and the
|
|
8
|
+
* generation to pass here. Releasing is the one exit that does not wait for the machine, so it costs something the
|
|
9
|
+
* platform cannot take back: the provider may receive a SECOND request for the same turn.
|
|
10
|
+
*
|
|
11
|
+
* So the command refuses to go anywhere without `--accept-duplicate-risk`: with the flag missing it prints the risk and
|
|
12
|
+
* exits non-zero WITHOUT calling the API. With it, the server still decides: it requires you to be the Agent's owner
|
|
13
|
+
* signed in as a person (`skrr login`; a personal access token never reaches the route, and an Agent's CLI session, a workload
|
|
14
|
+
* credential and a daemon are refused), checks the generation you read, and releases only a queued, non-Task Run that really
|
|
15
|
+
* is held by this check. Nothing about who you are or which dispatch is released is taken from the command line.
|
|
16
|
+
*
|
|
17
|
+
* What this does NOT guarantee, and the help says so: your own `skrr login` IS you to the server, so a program running on your
|
|
18
|
+
* machine with your login (a coding agent, a script) passes every check above. `--accept-duplicate-risk` is the flag a person
|
|
19
|
+
* adds after reading the risk; it is friction, not a barrier, and nothing on the server can tell a person typing it from a
|
|
20
|
+
* script. That is also why `triggers fire-detail` prints this command WITHOUT the flag. Do not hand your login to a program
|
|
21
|
+
* you would not trust to make this decision; give it its own delegated session, which the server refuses.
|
|
22
|
+
*/
|
|
23
|
+
export default class AgentsAlwaysOnReleaseRun extends BaseCommand {
|
|
24
|
+
static description: string;
|
|
25
|
+
static examples: string[];
|
|
26
|
+
static args: {
|
|
27
|
+
id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
28
|
+
runId: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
29
|
+
};
|
|
30
|
+
static flags: {
|
|
31
|
+
'expected-generation': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
32
|
+
'accept-duplicate-risk': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
33
|
+
reason: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
34
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
35
|
+
};
|
|
36
|
+
run(): Promise<void>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
/**
|
|
7
|
+
* `skrr agents always-on release-run <agent-id> <run-id>` — the owner lets ONE queued Run start although the machine that
|
|
8
|
+
* ran it never confirmed it stopped, via `POST /api/agents/:id/always-on/runs/:runId/stop-release` (OSK-22700).
|
|
9
|
+
*
|
|
10
|
+
* A Run whose daemon was killed mid-turn is queued again and refused as `previous_execution_stopping`: the platform will
|
|
11
|
+
* not start a second provider request while the first may still run. `skrr triggers fire-detail` shows that wait and the
|
|
12
|
+
* generation to pass here. Releasing is the one exit that does not wait for the machine, so it costs something the
|
|
13
|
+
* platform cannot take back: the provider may receive a SECOND request for the same turn.
|
|
14
|
+
*
|
|
15
|
+
* So the command refuses to go anywhere without `--accept-duplicate-risk`: with the flag missing it prints the risk and
|
|
16
|
+
* exits non-zero WITHOUT calling the API. With it, the server still decides: it requires you to be the Agent's owner
|
|
17
|
+
* signed in as a person (`skrr login`; a personal access token never reaches the route, and an Agent's CLI session, a workload
|
|
18
|
+
* credential and a daemon are refused), checks the generation you read, and releases only a queued, non-Task Run that really
|
|
19
|
+
* is held by this check. Nothing about who you are or which dispatch is released is taken from the command line.
|
|
20
|
+
*
|
|
21
|
+
* What this does NOT guarantee, and the help says so: your own `skrr login` IS you to the server, so a program running on your
|
|
22
|
+
* machine with your login (a coding agent, a script) passes every check above. `--accept-duplicate-risk` is the flag a person
|
|
23
|
+
* adds after reading the risk; it is friction, not a barrier, and nothing on the server can tell a person typing it from a
|
|
24
|
+
* script. That is also why `triggers fire-detail` prints this command WITHOUT the flag. Do not hand your login to a program
|
|
25
|
+
* you would not trust to make this decision; give it its own delegated session, which the server refuses.
|
|
26
|
+
*/
|
|
27
|
+
class AgentsAlwaysOnReleaseRun extends base_command_1.BaseCommand {
|
|
28
|
+
static description = 'Let one queued Run start although the machine that ran it never confirmed it stopped (Agent owner only; the provider may receive a second request for the same turn). Release it only when its machine is online and ready: the claim spends the release even if the new attempt then parks before it reaches a machine, and the Run then needs another. It runs as you, so a program using your login can do this too: --accept-duplicate-risk is a deliberate step, not a barrier';
|
|
29
|
+
static examples = [
|
|
30
|
+
'<%= config.bin %> triggers fire-detail <trigger-id> <fire-id> # shows the Run, the wait and the generation',
|
|
31
|
+
'<%= config.bin %> agents always-on release-run <agent-id> <run-id> --expected-generation 3 --accept-duplicate-risk',
|
|
32
|
+
'<%= config.bin %> agents always-on release-run <agent-id> <run-id> --expected-generation 3 --accept-duplicate-risk --reason "Laptop was destroyed" --json',
|
|
33
|
+
];
|
|
34
|
+
static args = {
|
|
35
|
+
id: core_1.Args.string({ description: 'Agent ID', required: true, ignoreStdin: true }),
|
|
36
|
+
runId: core_1.Args.string({
|
|
37
|
+
description: 'Run ID (the `Run:` line of `triggers fire-detail`)',
|
|
38
|
+
required: true,
|
|
39
|
+
ignoreStdin: true,
|
|
40
|
+
}),
|
|
41
|
+
};
|
|
42
|
+
static flags = {
|
|
43
|
+
'expected-generation': core_1.Flags.integer({
|
|
44
|
+
min: 0,
|
|
45
|
+
required: true,
|
|
46
|
+
description: 'The generation `triggers fire-detail` printed for this wait. A stale one is refused, so you cannot release a wait you did not read.',
|
|
47
|
+
}),
|
|
48
|
+
'accept-duplicate-risk': core_1.Flags.boolean({
|
|
49
|
+
description: 'I understand the provider may receive a second request for the same turn. Required: without it nothing is sent.',
|
|
50
|
+
}),
|
|
51
|
+
reason: core_1.Flags.string({
|
|
52
|
+
description: `Why you know the machine is gone (up to ${data_provider_1.RUN_STOP_RELEASE.reasonMaxLength} characters), kept on the Run`,
|
|
53
|
+
}),
|
|
54
|
+
json: core_1.Flags.boolean({ description: 'Print the server answer as JSON' }),
|
|
55
|
+
};
|
|
56
|
+
async run() {
|
|
57
|
+
this.requireAuth();
|
|
58
|
+
const { args, flags } = await this.parse(AgentsAlwaysOnReleaseRun);
|
|
59
|
+
if (!flags['accept-duplicate-risk']) {
|
|
60
|
+
// Before any API call: the cost is named first, and a script that forgot the flag fails instead of releasing.
|
|
61
|
+
this.failWithCliError({
|
|
62
|
+
message: `${data_provider_1.RUN_STOP_RELEASE_RISK}\n` +
|
|
63
|
+
'→ If you are sure, run the same command again with --accept-duplicate-risk.',
|
|
64
|
+
code: 'DUPLICATE_RISK_NOT_ACCEPTED',
|
|
65
|
+
exit: 1,
|
|
66
|
+
retryable: false,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
let result;
|
|
70
|
+
try {
|
|
71
|
+
result = await data_provider_1.dataService.releaseAlwaysOnRunStop(args.id, args.runId, {
|
|
72
|
+
expectedGeneration: flags['expected-generation'],
|
|
73
|
+
acknowledged: data_provider_1.RUN_STOP_RELEASE.acknowledged,
|
|
74
|
+
...(flags.reason ? { reason: flags.reason } : {}),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
// The server's refusals carry their own sentence and `code` (`not_owner`, `generation_conflict`, ...), which is shown as is.
|
|
79
|
+
this.handleApiError(err);
|
|
80
|
+
}
|
|
81
|
+
if (flags.json) {
|
|
82
|
+
this.printJsonResult(result);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
// `result.message` is the server's account (the risk, what a stored result does, that the Run stays under the stop check).
|
|
86
|
+
this.log(result.alreadyReleased
|
|
87
|
+
? `Run ${result.runId} was already released (generation ${result.generation}).`
|
|
88
|
+
: `Released run ${result.runId} of agent ${result.agentId} (generation ${result.generation}).`);
|
|
89
|
+
this.log(result.message);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.default = AgentsAlwaysOnReleaseRun;
|
|
@@ -116,6 +116,11 @@ class AgentsAlwaysOnStatus extends base_command_1.BaseCommand {
|
|
|
116
116
|
else {
|
|
117
117
|
this.log('Checks/Runs: unavailable');
|
|
118
118
|
}
|
|
119
|
+
// Queued Runs held back by a refused claim (for example waiting for the previous executor's stop
|
|
120
|
+
// receipt) are otherwise indistinguishable from Runs behind others in the queue (OSK-22700).
|
|
121
|
+
const waitingOnClaim = (0, data_provider_1.describeRunClaimRefusalSummary)(cr?.claimRefusals);
|
|
122
|
+
if (waitingOnClaim)
|
|
123
|
+
this.log(`Waiting: ${waitingOnClaim}`);
|
|
119
124
|
if (status.messaging?.degraded) {
|
|
120
125
|
const reasons = (status.messaging.degradedReasons || []).join(', ') || 'unknown';
|
|
121
126
|
this.log(`Messaging: degraded (${reasons})`);
|
|
@@ -48,6 +48,18 @@ function configuredId(config, ...keys) {
|
|
|
48
48
|
return typeof value === 'string' && value.trim().length > 0;
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
+
/** Match TriggerSync's closed work-item selector and its Goal fallback. */
|
|
52
|
+
function hasWorkItemEventScope(source, config, goalId) {
|
|
53
|
+
const keys = ['taskId', 'goalId', 'keyResultId', 'spaceId'];
|
|
54
|
+
const declared = keys.filter((key) => Object.hasOwn(config ?? {}, key));
|
|
55
|
+
if (declared.length > 1)
|
|
56
|
+
return false;
|
|
57
|
+
const key = declared[0] ?? 'goalId';
|
|
58
|
+
if (key === 'spaceId' || (source === 'goal' && key === 'taskId'))
|
|
59
|
+
return false;
|
|
60
|
+
const value = declared.length ? config?.[key] : goalId;
|
|
61
|
+
return typeof value === 'string' && value.trim().length > 0 && value.trim().length <= 200;
|
|
62
|
+
}
|
|
51
63
|
/** Do not silently discard a JSON source's scope or event filters. */
|
|
52
64
|
function applyWatchedSourceFlags(payload, built) {
|
|
53
65
|
if (!built)
|
|
@@ -86,7 +98,6 @@ function hasStructurallyValidExplicitEvent(config) {
|
|
|
86
98
|
* while the resulting Duty still wakes exclusively on its backstop.
|
|
87
99
|
*/
|
|
88
100
|
function hasEventCapableWatchedSource(payload) {
|
|
89
|
-
const goalId = typeof payload.goalId === 'string' && payload.goalId.trim().length > 0;
|
|
90
101
|
const watchedSources = Array.isArray(payload.watchedSources) ? payload.watchedSources : [];
|
|
91
102
|
return watchedSources.some((value) => {
|
|
92
103
|
const sourceEntry = record(value);
|
|
@@ -100,12 +111,8 @@ function hasEventCapableWatchedSource(payload) {
|
|
|
100
111
|
if (DEFAULT_EVENT_SOURCES.has(source)) {
|
|
101
112
|
return Array.isArray(config?.events) ? hasStructurallyValidExplicitEvent(config) : true;
|
|
102
113
|
}
|
|
103
|
-
if (source === 'tasks')
|
|
104
|
-
return
|
|
105
|
-
}
|
|
106
|
-
if (source === 'goal') {
|
|
107
|
-
return goalId || configuredId(config, 'goalId', 'keyResultId');
|
|
108
|
-
}
|
|
114
|
+
if (source === 'tasks' || source === 'goal')
|
|
115
|
+
return hasWorkItemEventScope(source, config, payload.goalId);
|
|
109
116
|
if (source === 'space')
|
|
110
117
|
return configuredId(config, 'spaceId');
|
|
111
118
|
if (source === 'conversations')
|
|
@@ -134,7 +141,7 @@ function assertEventDrivenWatchedSource(payload) {
|
|
|
134
141
|
const hasInvalidEvents = sources.some((value) => {
|
|
135
142
|
const source = record(value);
|
|
136
143
|
const config = record(source?.config);
|
|
137
|
-
return source?.enabled !== false && Array.isArray(config?.events) &&
|
|
144
|
+
return source?.enabled !== false && source?.source !== 'tasks' && source?.source !== 'goal' && Array.isArray(config?.events) &&
|
|
138
145
|
!hasStructurallyValidExplicitEvent(config);
|
|
139
146
|
});
|
|
140
147
|
if (hasInvalidEvents) {
|
|
@@ -143,6 +150,14 @@ function assertEventDrivenWatchedSource(payload) {
|
|
|
143
150
|
'for example {"entityType":"github","eventType":"check_run_failed"}. ' +
|
|
144
151
|
'Supply valid bindings, or remove config.events to use the source defaults (which may include more events).');
|
|
145
152
|
}
|
|
153
|
+
if (sources.some((value) => {
|
|
154
|
+
const source = record(value);
|
|
155
|
+
return source?.source === 'tasks' && source.enabled !== false;
|
|
156
|
+
})) {
|
|
157
|
+
throw new Error('Task events need a specific Task, Goal or Key Result scope. Bind this Duty to a Goal with --goal <goal-id>, or supply ' +
|
|
158
|
+
'watchedSources with source "tasks" and exactly one config.taskId, config.goalId or config.keyResultId ' +
|
|
159
|
+
'in --from-json. Remove any other object selector; when watchedSources is in JSON, omit --watch.');
|
|
160
|
+
}
|
|
146
161
|
throw new Error('Event-driven cadence (--event-driven or --cadence-mode event_plus_interval) requires at least one event-capable watched source. ' +
|
|
147
162
|
'Add --watch github (or another event-capable source), or choose an interval-only cadence.');
|
|
148
163
|
}
|
|
@@ -344,7 +359,7 @@ JSON
|
|
|
344
359
|
description: 'Watched source the criterion reads (implies --evaluator source_state), e.g. github',
|
|
345
360
|
}),
|
|
346
361
|
watch: core_1.Flags.string({
|
|
347
|
-
description: `Watched source (repeatable). One of: ${duties_1.DUTY_WATCHED_SOURCES.join(', ')}. Some sources need companion flags: --watch-space, --watch-monitor, --metric-key. conversations and messages need an id (config.conversationId, config.groupChatId) that only --from-json can set.`,
|
|
362
|
+
description: `Watched source (repeatable). One of: ${duties_1.DUTY_WATCHED_SOURCES.join(', ')}. Some sources need companion flags: --watch-space, --watch-monitor, --metric-key. Task event wakes need --goal or an object selector in --from-json; omit --watch when JSON supplies watchedSources. conversations and messages need an id (config.conversationId, config.groupChatId) that only --from-json can set.`,
|
|
348
363
|
multiple: true,
|
|
349
364
|
options: [...duties_1.DUTY_WATCHED_SOURCES],
|
|
350
365
|
}),
|
|
@@ -48,7 +48,8 @@ class DutiesExport extends base_command_1.BaseCommand {
|
|
|
48
48
|
const requires = manifest.requires;
|
|
49
49
|
const grants = requires?.grants?.length ?? 0;
|
|
50
50
|
const sensors = requires?.sensors?.length ?? 0;
|
|
51
|
-
const artifactSchemaVersion = manifest.
|
|
51
|
+
const artifactSchemaVersion = manifest.manifestVersion ??
|
|
52
|
+
manifest.version ?? 1;
|
|
52
53
|
if (selection.summary) {
|
|
53
54
|
const summary = (0, artifact_export_1.contentFreeSummary)({
|
|
54
55
|
command: 'duties export',
|
|
@@ -187,6 +187,23 @@ function preflightGateLines(gate, verbose = false, refusesActivation = false) {
|
|
|
187
187
|
if (typeof hint === 'string' && hint.trim()) {
|
|
188
188
|
lines.push(` ${hint.trim()}`);
|
|
189
189
|
}
|
|
190
|
+
if (gate.id === 'event_bindings' && Array.isArray(gate.detail?.eventTypes)) {
|
|
191
|
+
const events = gate.detail.eventTypes.flatMap((item) => {
|
|
192
|
+
if (!item || typeof item !== 'object' || Array.isArray(item))
|
|
193
|
+
return [];
|
|
194
|
+
const { source, event } = item;
|
|
195
|
+
return typeof source === 'string' && typeof event === 'string' && source.trim() && event.trim()
|
|
196
|
+
? [`${source}: ${event}`] : [];
|
|
197
|
+
});
|
|
198
|
+
if (events.length)
|
|
199
|
+
lines.push(` Event types in the derived plan (not proof of delivery): ${events.join(', ')}`);
|
|
200
|
+
if (gate.detail.eventTypesTruncated === true)
|
|
201
|
+
lines.push(' Additional event types omitted.');
|
|
202
|
+
if (gate.detail.eventTypesLinksUnreadable === true)
|
|
203
|
+
lines.push(' Watch links could not be read; this event list may be incomplete.');
|
|
204
|
+
if (gate.detail.eventTypesIncomplete === true)
|
|
205
|
+
lines.push(' Some bindings could not be described; this event list may be incomplete.');
|
|
206
|
+
}
|
|
190
207
|
for (const sentence of (0, preflight_copy_1.gateExplanationLines)(gate))
|
|
191
208
|
lines.push(` ${sentence}`);
|
|
192
209
|
for (const sentence of (0, preflight_copy_1.placementTargetLines)(gate))
|
|
@@ -30,6 +30,7 @@ export default class DutiesUpdate extends BaseCommand {
|
|
|
30
30
|
yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
31
31
|
'from-json': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
32
32
|
'if-version': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
33
|
+
'restore-saved-cadence': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
33
34
|
'task-review-policy': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
34
35
|
title: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
35
36
|
description: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -85,6 +85,9 @@ JSON
|
|
|
85
85
|
'if-version': core_1.Flags.integer({
|
|
86
86
|
description: 'Only update this observed contract version; returns a conflict if it changed',
|
|
87
87
|
}),
|
|
88
|
+
'restore-saved-cadence': core_1.Flags.boolean({
|
|
89
|
+
description: 'Restore the inactive schedule shown by duties show. On an active Duty this can schedule automatic checks.',
|
|
90
|
+
}),
|
|
88
91
|
'task-review-policy': core_1.Flags.string({
|
|
89
92
|
options: [...data_provider_1.TASK_REVIEW_POLICIES],
|
|
90
93
|
description: 'Owner choice for generated Tasks; required records a blocker but does not stop the owner close.',
|
|
@@ -174,7 +177,8 @@ JSON
|
|
|
174
177
|
const wantsTarget = flags.outcome !== undefined || flags.deadline !== undefined || criteria.length > 0;
|
|
175
178
|
const wantsCadence = flags.cadence !== undefined ||
|
|
176
179
|
flags['cadence-mode'] !== undefined ||
|
|
177
|
-
flags.timezone !== undefined
|
|
180
|
+
flags.timezone !== undefined ||
|
|
181
|
+
flags['restore-saved-cadence'] === true;
|
|
178
182
|
let payload;
|
|
179
183
|
try {
|
|
180
184
|
payload = await (0, prompt_2.readJsonBody)(flags['from-json']);
|
|
@@ -325,75 +329,92 @@ JSON
|
|
|
325
329
|
payload.expectedVersion = current?.version;
|
|
326
330
|
}
|
|
327
331
|
if (wantsCadence) {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
// `activeHours`/`daysOfWeek` turned "weekdays 09:00-22:00" into "around the clock" on
|
|
333
|
-
// `--cadence 2h` (OSK-18366). Mirrors `cadenceShape` in api/server/routes/duties.js.
|
|
334
|
-
for (const key of CARRIED_CADENCE_KEYS) {
|
|
335
|
-
if (existing[key] !== undefined)
|
|
336
|
-
storedCadence[key] = existing[key];
|
|
337
|
-
}
|
|
338
|
-
if (payload.cadence !== undefined) {
|
|
339
|
-
if (!payload.cadence ||
|
|
340
|
-
typeof payload.cadence !== 'object' ||
|
|
341
|
-
Array.isArray(payload.cadence)) {
|
|
342
|
-
this.error('cadence must be a JSON object when using cadence flags.', { exit: 1 });
|
|
332
|
+
if (flags['restore-saved-cadence']) {
|
|
333
|
+
if (flags.cadence !== undefined || flags['cadence-mode'] !== undefined ||
|
|
334
|
+
flags.timezone !== undefined || payload.cadence !== undefined) {
|
|
335
|
+
this.error('--restore-saved-cadence cannot be combined with other cadence edits.', { exit: 1 });
|
|
343
336
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
const cadence = {
|
|
347
|
-
...storedCadence,
|
|
348
|
-
...authoredCadence,
|
|
349
|
-
};
|
|
350
|
-
if (flags.cadence) {
|
|
351
|
-
cadence.intervalMs = (0, duties_1.parseIntervalToMs)(flags.cadence);
|
|
352
|
-
// Setting an interval on a manual duty implies interval mode.
|
|
353
|
-
if (!cadence.mode || cadence.mode === 'manual')
|
|
354
|
-
cadence.mode = 'interval';
|
|
355
|
-
}
|
|
356
|
-
if (flags['cadence-mode'])
|
|
357
|
-
cadence.mode = flags['cadence-mode'];
|
|
358
|
-
if (flags.timezone)
|
|
359
|
-
cadence.timezone = flags.timezone;
|
|
360
|
-
// A daily cadence runs at set times and has no interval, so `--cadence 6h`
|
|
361
|
-
// on one was stored as an `intervalMs` nothing reads: the command succeeded,
|
|
362
|
-
// the version moved, and the cadence still read "daily 08:00". Refuse it and
|
|
363
|
-
// say what would do what was meant (OSK-15418).
|
|
364
|
-
if (flags.cadence && cadence.mode === 'daily') {
|
|
365
|
-
const at = Array.isArray(cadence.times) && cadence.times.length
|
|
366
|
-
? ` at ${cadence.times.join(', ')}`
|
|
367
|
-
: '';
|
|
368
|
-
this.error(`This duty's cadence is daily${at}, which has no interval, so --cadence ${flags.cadence} would change nothing. ` +
|
|
369
|
-
`To check every ${flags.cadence} instead, add --cadence-mode interval. ` +
|
|
370
|
-
'To change the daily times, use --from-json with cadence.times.', { exit: 1 });
|
|
371
|
-
}
|
|
372
|
-
// A mode change must not carry the previous mode's fields into the
|
|
373
|
-
// replacement. Keep explicitly authored fields so invalid combinations
|
|
374
|
-
// are refused rather than silently discarding what the user requested.
|
|
375
|
-
if (cadence.mode !== existing.mode) {
|
|
376
|
-
if (cadence.mode !== 'daily' && !Object.hasOwn(authoredCadence ?? {}, 'times')) {
|
|
377
|
-
delete cadence.times;
|
|
337
|
+
if (current?.cadence?.mode !== 'manual' || !current?.savedCadence) {
|
|
338
|
+
this.error('There is no saved schedule to restore on this manual Duty. Run `skrr duties show` to inspect it.', { exit: 1 });
|
|
378
339
|
}
|
|
379
|
-
if (
|
|
380
|
-
|
|
340
|
+
if (!Number.isSafeInteger(current.version) || current.version < 1) {
|
|
341
|
+
this.error('The current Duty version is unavailable; refresh it before restoring a schedule.', { exit: 1 });
|
|
381
342
|
}
|
|
343
|
+
payload.cadence = current.savedCadence;
|
|
344
|
+
if (payload.expectedVersion === undefined)
|
|
345
|
+
payload.expectedVersion = current.version;
|
|
382
346
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
347
|
+
else {
|
|
348
|
+
const existing = current?.cadence ?? {};
|
|
349
|
+
const storedCadence = {};
|
|
350
|
+
// Every authored cadence field. The API replaces `cadence` wholesale, so a field left out
|
|
351
|
+
// of this list is erased from the Duty by an edit that never mentioned it: omitting
|
|
352
|
+
// `activeHours`/`daysOfWeek` turned "weekdays 09:00-22:00" into "around the clock" on
|
|
353
|
+
// `--cadence 2h` (OSK-18366). Mirrors `cadenceShape` in api/server/routes/duties.js.
|
|
354
|
+
for (const key of CARRIED_CADENCE_KEYS) {
|
|
355
|
+
if (existing[key] !== undefined)
|
|
356
|
+
storedCadence[key] = existing[key];
|
|
357
|
+
}
|
|
358
|
+
if (payload.cadence !== undefined) {
|
|
359
|
+
if (!payload.cadence ||
|
|
360
|
+
typeof payload.cadence !== 'object' ||
|
|
361
|
+
Array.isArray(payload.cadence)) {
|
|
362
|
+
this.error('cadence must be a JSON object when using cadence flags.', { exit: 1 });
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
const authoredCadence = payload.cadence;
|
|
366
|
+
const cadence = {
|
|
367
|
+
...storedCadence,
|
|
368
|
+
...authoredCadence,
|
|
369
|
+
};
|
|
370
|
+
if (flags.cadence) {
|
|
371
|
+
cadence.intervalMs = (0, duties_1.parseIntervalToMs)(flags.cadence);
|
|
372
|
+
// Setting an interval on a manual duty implies interval mode.
|
|
373
|
+
if (!cadence.mode || cadence.mode === 'manual')
|
|
374
|
+
cadence.mode = 'interval';
|
|
375
|
+
}
|
|
376
|
+
if (flags['cadence-mode'])
|
|
377
|
+
cadence.mode = flags['cadence-mode'];
|
|
378
|
+
if (flags.timezone)
|
|
379
|
+
cadence.timezone = flags.timezone;
|
|
380
|
+
// A daily cadence runs at set times and has no interval, so `--cadence 6h`
|
|
381
|
+
// on one was stored as an `intervalMs` nothing reads: the command succeeded,
|
|
382
|
+
// the version moved, and the cadence still read "daily 08:00". Refuse it and
|
|
383
|
+
// say what would do what was meant (OSK-15418).
|
|
384
|
+
if (flags.cadence && cadence.mode === 'daily') {
|
|
385
|
+
const at = Array.isArray(cadence.times) && cadence.times.length
|
|
386
|
+
? ` at ${cadence.times.join(', ')}`
|
|
387
|
+
: '';
|
|
388
|
+
this.error(`This duty's cadence is daily${at}, which has no interval, so --cadence ${flags.cadence} would change nothing. ` +
|
|
389
|
+
`To check every ${flags.cadence} instead, add --cadence-mode interval. ` +
|
|
390
|
+
'To change the daily times, use --from-json with cadence.times.', { exit: 1 });
|
|
391
|
+
}
|
|
392
|
+
// A mode change must not carry the previous mode's fields into the
|
|
393
|
+
// replacement. Keep explicitly authored fields so invalid combinations
|
|
394
|
+
// are refused rather than silently discarding what the user requested.
|
|
395
|
+
if (cadence.mode !== existing.mode) {
|
|
396
|
+
if (cadence.mode !== 'daily' && !Object.hasOwn(authoredCadence ?? {}, 'times')) {
|
|
397
|
+
delete cadence.times;
|
|
398
|
+
}
|
|
399
|
+
if (cadence.mode !== 'sampled' && !Object.hasOwn(authoredCadence ?? {}, 'jitterRatio')) {
|
|
400
|
+
delete cadence.jitterRatio;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
// A daily cadence's rhythm is its times, and the API refuses an `intervalMs` beside them.
|
|
404
|
+
// Dropping the inherited one also repairs a row an earlier build let store both.
|
|
405
|
+
if (cadence.mode === 'daily' && !Object.hasOwn(authoredCadence ?? {}, 'intervalMs')) {
|
|
406
|
+
delete cadence.intervalMs;
|
|
407
|
+
}
|
|
408
|
+
if (!['interval', 'daily', 'event_plus_interval'].includes(String(cadence.mode)) &&
|
|
409
|
+
!Object.hasOwn(authoredCadence ?? {}, 'activeHours'))
|
|
410
|
+
delete cadence.activeHours;
|
|
411
|
+
if (!['interval', 'event_plus_interval', 'daily'].includes(String(cadence.mode)) &&
|
|
412
|
+
!Object.hasOwn(authoredCadence ?? {}, 'daysOfWeek'))
|
|
413
|
+
delete cadence.daysOfWeek;
|
|
414
|
+
payload.cadence = cadence;
|
|
415
|
+
if (payload.expectedVersion === undefined && current?.version !== undefined) {
|
|
416
|
+
payload.expectedVersion = current.version;
|
|
417
|
+
}
|
|
397
418
|
}
|
|
398
419
|
}
|
|
399
420
|
const concurrencyPatch = (0, duties_1.dutyConcurrencyEnvelopePatch)({
|