@skrr-ai/cli 0.1.201 → 0.1.204

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.
Files changed (67) hide show
  1. package/dist/base-command.js +1 -1
  2. package/dist/commands/agent/message/context.d.ts +3 -0
  3. package/dist/commands/agent/message/context.js +33 -1
  4. package/dist/commands/agent/message/no-reply.d.ts +17 -0
  5. package/dist/commands/agent/message/no-reply.js +54 -0
  6. package/dist/commands/agent/message/retract.d.ts +24 -0
  7. package/dist/commands/agent/message/retract.js +167 -0
  8. package/dist/commands/agent/message/send.d.ts +47 -3
  9. package/dist/commands/agent/message/send.js +135 -4
  10. package/dist/commands/agents/chat.d.ts +12 -0
  11. package/dist/commands/agents/chat.js +258 -25
  12. package/dist/commands/agents/manager/status.d.ts +9 -0
  13. package/dist/commands/agents/manager/status.js +84 -0
  14. package/dist/commands/agents/queue/clear.d.ts +13 -0
  15. package/dist/commands/agents/queue/clear.js +31 -0
  16. package/dist/commands/agents/queue/list.d.ts +10 -0
  17. package/dist/commands/agents/queue/list.js +34 -0
  18. package/dist/commands/agents/queue/move.d.ts +16 -0
  19. package/dist/commands/agents/queue/move.js +33 -0
  20. package/dist/commands/agents/queue/pause.d.ts +7 -0
  21. package/dist/commands/agents/queue/pause.js +24 -0
  22. package/dist/commands/agents/queue/resume.d.ts +7 -0
  23. package/dist/commands/agents/queue/resume.js +24 -0
  24. package/dist/commands/agents/queue/steer.d.ts +14 -0
  25. package/dist/commands/agents/queue/steer.js +38 -0
  26. package/dist/commands/agents/queue/withdraw.d.ts +10 -0
  27. package/dist/commands/agents/queue/withdraw.js +27 -0
  28. package/dist/commands/agents/supervision.d.ts +1 -0
  29. package/dist/commands/agents/supervision.js +28 -9
  30. package/dist/commands/duties/advance-next.d.ts +17 -0
  31. package/dist/commands/duties/advance-next.js +122 -0
  32. package/dist/commands/duties/create.js +22 -3
  33. package/dist/commands/duties/pack/plan.js +45 -0
  34. package/dist/commands/duties/preflight.d.ts +1 -0
  35. package/dist/commands/duties/preflight.js +18 -2
  36. package/dist/commands/spaces/auto-executor/preview.js +6 -2
  37. package/dist/commands/spaces/charter/revise.d.ts +16 -0
  38. package/dist/commands/spaces/charter/revise.js +84 -0
  39. package/dist/commands/spaces/skills/propose.d.ts +1 -0
  40. package/dist/commands/spaces/skills/propose.js +5 -0
  41. package/dist/commands/tasks/create.js +16 -1
  42. package/dist/commands/tasks/result/show.d.ts +1 -0
  43. package/dist/commands/tasks/result/show.js +22 -1
  44. package/dist/commands/tasks/start.d.ts +3 -0
  45. package/dist/commands/tasks/start.js +12 -1
  46. package/dist/commands/triggers/capabilities.js +24 -5
  47. package/dist/commands/triggers/create.d.ts +1 -1
  48. package/dist/commands/triggers/create.js +15 -6
  49. package/dist/generated/agent-guides.json +258 -24
  50. package/dist/lib/agent-chat-queue-command.d.ts +29 -0
  51. package/dist/lib/agent-chat-queue-command.js +75 -0
  52. package/dist/lib/agent-chat-queue.d.ts +77 -0
  53. package/dist/lib/agent-chat-queue.js +245 -0
  54. package/dist/lib/agent-chat-start.d.ts +101 -0
  55. package/dist/lib/agent-chat-start.js +151 -6
  56. package/dist/lib/duties.d.ts +5 -1
  57. package/dist/lib/duties.js +16 -5
  58. package/dist/lib/duty-product.js +6 -0
  59. package/dist/lib/input-queue.d.ts +18 -0
  60. package/dist/lib/input-queue.js +59 -0
  61. package/dist/lib/message-intent.d.ts +26 -3
  62. package/dist/lib/message-intent.js +7 -1
  63. package/dist/lib/task-runtime-headers.d.ts +7 -0
  64. package/dist/lib/task-runtime-headers.js +46 -9
  65. package/dist/node_modules/@skrr-ai/data-provider/index.js +10464 -10221
  66. package/oclif.manifest.json +1288 -87
  67. package/package.json +6 -3
@@ -368,8 +368,8 @@ JSON
368
368
  }),
369
369
  activate: core_1.Flags.boolean({
370
370
  description: 'Turn the duty on right after creating it — the same resume + Preflight boundary ' +
371
- "as `duties resume`. A refused activation keeps the draft and reports the refusal's " +
372
- 'code, reason and fix, and exits nonzero. Use the returned ID to resume it instead of creating another.',
371
+ "as `duties resume`. A refusal reports its code, reason and fix, and exits nonzero. " +
372
+ 'If a new draft was saved, use its returned ID to resume it.',
373
373
  }),
374
374
  deadline: core_1.Flags.string({ description: 'ISO-8601 deadline for an `achieve` duty' }),
375
375
  criterion: core_1.Flags.string({
@@ -635,7 +635,26 @@ JSON
635
635
  // A refusal is reported on the result — never thrown over the draft's id.
636
636
  let activation = null;
637
637
  const start = duty?.directStart;
638
- if (flags.activate && start) {
638
+ const requestedController = record(record(payload.policy)?.cadenceController);
639
+ const existingController = duty?.policy?.cadenceController;
640
+ const mismatchedSetting = start?.state === 'existing' && duty?.status === 'active'
641
+ ? ['mode', 'riskProfile'].find((setting) => typeof requestedController?.[setting] === 'string' &&
642
+ requestedController[setting] !== existingController?.[setting])
643
+ : undefined;
644
+ if (flags.activate && mismatchedSetting) {
645
+ const label = mismatchedSetting === 'mode' ? 'mode' : 'risk profile';
646
+ const current = existingController?.[mismatchedSetting] ?? 'unreported';
647
+ const requested = requestedController?.[mismatchedSetting];
648
+ activation = {
649
+ activated: false,
650
+ refusal: {
651
+ code: 'DUTY_EXISTING_CADENCE_POLICY_MISMATCH',
652
+ reason: `The existing active Duty has cadence controller ${label} ${current}. This request asked for ${requested}.`,
653
+ fix: `Create a separate draft without --activate, then run \`${this.config.bin} duties resume <new-duty-id>\`.`,
654
+ },
655
+ };
656
+ }
657
+ else if (flags.activate && start) {
639
658
  activation =
640
659
  duty?.status === 'active'
641
660
  ? { activated: true }
@@ -7,6 +7,19 @@ const data_provider_1 = require("@skrr-ai/data-provider");
7
7
  const base_command_1 = require("../../../base-command");
8
8
  const prompt_1 = require("../../../lib/prompt");
9
9
  const duties_1 = require("../../../lib/duties");
10
+ function formatVerificationDuration(ms) {
11
+ if (ms > 0) {
12
+ if (ms % 86_400_000 === 0)
13
+ return `${ms / 86_400_000}d`;
14
+ if (ms % 3_600_000 === 0)
15
+ return `${ms / 3_600_000}h`;
16
+ if (ms % 60_000 === 0)
17
+ return `${ms / 60_000}m`;
18
+ if (ms % 1000 === 0)
19
+ return `${ms / 1000}s`;
20
+ }
21
+ return `${ms}ms`;
22
+ }
10
23
  function formatPlanPreview(duty) {
11
24
  if (!duty)
12
25
  return [];
@@ -19,6 +32,38 @@ function formatPlanPreview(duty) {
19
32
  lines.push(`Outcome ${duty.target.outcome}`);
20
33
  if (duty.cadence?.mode)
21
34
  lines.push(`Checks ${(0, duties_1.cadenceLabel)(duty)}`);
35
+ const policy = duty.evaluationPolicy;
36
+ if (policy) {
37
+ const verification = [];
38
+ if (policy.delayMs != null) {
39
+ verification.push(`Initial delay ${formatVerificationDuration(policy.delayMs)}`);
40
+ }
41
+ if (policy.settleDelayMs != null) {
42
+ verification.push(`settling delay ${formatVerificationDuration(policy.settleDelayMs)}`);
43
+ }
44
+ if (policy.maxAttempts != null) {
45
+ verification.push(`up to ${policy.maxAttempts} ${policy.maxAttempts === 1 ? 'attempt' : 'attempts'}`);
46
+ }
47
+ if (verification.length)
48
+ lines.push(`Verification ${verification.join(' · ')}`);
49
+ const evidence = [];
50
+ if (policy.windowMs != null) {
51
+ evidence.push(policy.windowMs === 0
52
+ ? 'No fixed observation window'
53
+ : `Observation window ${formatVerificationDuration(policy.windowMs)}`);
54
+ }
55
+ const freshness = [...new Set([...(policy.criteria || []), ...(policy.guardrails || [])]
56
+ .map((criterion) => criterion.minimumFreshnessMs)
57
+ .filter((value) => typeof value === 'number'))].map(formatVerificationDuration);
58
+ if (freshness.length === 1) {
59
+ evidence.push(`collected within ${freshness[0]} of verification`);
60
+ }
61
+ else if (freshness.length > 1) {
62
+ evidence.push(`collection age limits vary by criterion (${freshness.join(', ')})`);
63
+ }
64
+ if (evidence.length)
65
+ lines.push(`Evidence ${evidence.join(' · ')}`);
66
+ }
22
67
  if (duty.delivery?.mode) {
23
68
  const mode = duty.delivery.mode.replaceAll('_', ' ');
24
69
  const destinations = [...new Set((duty.reports || [])
@@ -34,6 +34,7 @@ type PreflightGate = DutyPreflightReport['gates'][number];
34
34
  export declare function nextRunsLines(report: {
35
35
  verdict?: string;
36
36
  nextRuns?: string[];
37
+ nextRunsSource?: DutyPreflightReport['nextRunsSource'];
37
38
  }, projectedActivation?: boolean): string[];
38
39
  /**
39
40
  * The first line of a preflight. `Ready to run` is a statement about activation (no blocking gate),
@@ -37,13 +37,29 @@ const preflight_copy_1 = require("../../lib/preflight-copy");
37
37
  * cadence WOULD do, so they are labelled that way instead of reading as a promise.
38
38
  */
39
39
  function nextRunsLines(report, projectedActivation = false) {
40
+ if (report.nextRunsSource === 'unconfirmed')
41
+ return ['', 'Next scheduled check is unconfirmed'];
42
+ if (report.nextRunsSource === 'not_scheduled')
43
+ return ['', 'No recurring check scheduled'];
44
+ if (report.nextRunsSource === 'scheduler' && report.nextRuns?.length) {
45
+ const [next, ...projected] = report.nextRuns;
46
+ return [
47
+ '',
48
+ `Next scheduled check: ${next}`,
49
+ ...(projected.length
50
+ ? ['Projected checks after that:', ...projected.map((at) => ` ${at}`)]
51
+ : []),
52
+ ];
53
+ }
40
54
  if (!report.nextRuns?.length)
41
55
  return ['', 'Next runs: none scheduled'];
42
56
  const header = projectedActivation
43
57
  ? 'Projected runs if activated:'
44
58
  : report.verdict === 'blocked'
45
59
  ? 'Next runs (the cadence\u2019s times; none will fire while the run is blocked above):'
46
- : 'Next runs:';
60
+ : report.nextRunsSource === 'cadence_projection'
61
+ ? 'Projected checks from cadence:'
62
+ : 'Next runs:';
47
63
  return ['', header, ...report.nextRuns.map((run) => ` ${run}`)];
48
64
  }
49
65
  /**
@@ -288,7 +304,7 @@ class DutiesPreflight extends base_command_1.BaseCommand {
288
304
  static flags = {
289
305
  json: core_1.Flags.boolean({ description: 'Output the complete preflight report as JSON' }),
290
306
  verbose: core_1.Flags.boolean({ description: 'Include diagnostic gate codes' }),
291
- next: core_1.Flags.integer({ description: 'Number of upcoming runs to project (1–10)' }),
307
+ next: core_1.Flags.integer({ description: 'Number of upcoming check times to show (1–10)' }),
292
308
  'from-json': core_1.Flags.string({
293
309
  description: 'Unsaved Duty create body file, or - for stdin',
294
310
  }),
@@ -6,6 +6,7 @@ exports.refillLines = refillLines;
6
6
  const core_1 = require("@oclif/core");
7
7
  const data_provider_1 = require("@skrr-ai/data-provider");
8
8
  const base_command_1 = require("../../../base-command");
9
+ const api_fetch_1 = require("../../../lib/api-fetch");
9
10
  const space_output_1 = require("../../../lib/space-output");
10
11
  const PRINCIPAL_LINE_RE = /_/g;
11
12
  /**
@@ -53,10 +54,13 @@ class SpacesAutoExecutorPreview extends base_command_1.BaseCommand {
53
54
  // ignored, and raw JSON printed unconditionally. There was no readable
54
55
  // rendering of a preview anywhere in the CLI.
55
56
  const { args, flags } = await this.parse(SpacesAutoExecutorPreview);
56
- const spaceRef = await this.resolveEntityRef('space', args.id);
57
+ const orchestration = process.env.OVERSKY_SPACE_ORCHESTRATION_WORK === '1';
58
+ const spaceRef = orchestration ? args.id : await this.resolveEntityRef('space', args.id);
57
59
  let result;
58
60
  try {
59
- result = (await data_provider_1.dataService.previewSpaceAutoExecutor(spaceRef));
61
+ result = orchestration
62
+ ? await (0, api_fetch_1.apiFetch)(`/api/spaces/${encodeURIComponent(spaceRef)}/auto-executor/preview?runtime=space-orchestration`, { credential: this.resolvedCredential })
63
+ : await data_provider_1.dataService.previewSpaceAutoExecutor(spaceRef);
60
64
  }
61
65
  catch (err) {
62
66
  this.handleApiError(err);
@@ -0,0 +1,16 @@
1
+ import { BaseCommand } from '../../../base-command';
2
+ export default class SpacesCharterRevise extends BaseCommand {
3
+ static description: string;
4
+ static args: {
5
+ space: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
6
+ };
7
+ static flags: {
8
+ 'page-id': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
9
+ section: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ lead: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ append: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
+ note: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
13
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
+ };
15
+ run(): Promise<void>;
16
+ }
@@ -0,0 +1,84 @@
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 wiki_1 = require("../../../lib/wiki");
7
+ class SpacesCharterRevise extends base_command_1.BaseCommand {
8
+ static description = 'Submit a bounded change to the existing Charter through the Space write policy';
9
+ static args = {
10
+ space: core_1.Args.string({ description: 'Space ID', required: true, ignoreStdin: true }),
11
+ };
12
+ static flags = {
13
+ 'page-id': core_1.Flags.string({ required: true, description: 'Page ID of the Charter you read' }),
14
+ section: core_1.Flags.string({ description: 'Replace the body under an exact Markdown heading', exclusive: ['lead', 'append'] }),
15
+ lead: core_1.Flags.boolean({ description: 'Replace the lead', exclusive: ['section', 'append'] }),
16
+ append: core_1.Flags.boolean({ description: 'Append to the end', exclusive: ['section', 'lead'] }),
17
+ note: core_1.Flags.string({ required: true, description: 'Reason and evidence for the change' }),
18
+ json: core_1.Flags.boolean({ description: 'Output as JSON' }),
19
+ };
20
+ async run() {
21
+ this.requireAuth();
22
+ const { args, flags } = await this.parse(SpacesCharterRevise);
23
+ if (!(flags.section || flags.lead || flags.append)) {
24
+ this.error('Choose --section, --lead, or --append.', { exit: 2 });
25
+ }
26
+ let content = await (0, wiki_1.readContentInput)({ stdin: true });
27
+ if (!content.trim())
28
+ this.error('Supply the replacement or appended Markdown on stdin.', { exit: 2 });
29
+ const charter = await data_provider_1.dataService.getSpaceWikiCharter(args.space)
30
+ .catch((error) => this.handleApiError(error));
31
+ if (charter.charter?.pageId !== flags['page-id']) {
32
+ this.failWithCliError({
33
+ code: 'WIKI_CHARTER_CHANGED',
34
+ message: 'Read the current Charter before revising it.',
35
+ status: 409,
36
+ exit: 2,
37
+ retryable: false,
38
+ });
39
+ }
40
+ const section = flags.section?.trim();
41
+ if (section) {
42
+ const selected = (0, data_provider_1.parsePageSectionSelector)(section);
43
+ if (!selected.ok || !selected.anchor.level || !charter.charter.content?.split(/\r?\n/).includes(section)) {
44
+ this.failWithCliError({
45
+ code: 'WIKI_CHARTER_SECTION_HEADING_REQUIRED',
46
+ message: 'Use the exact Markdown heading line from the current Charter, including its # markers.',
47
+ status: 409,
48
+ exit: 2,
49
+ retryable: false,
50
+ });
51
+ }
52
+ // The existing Wiki section writer replaces the heading and its body.
53
+ if (content.trimStart().split(/\r?\n/, 1)[0] !== section) {
54
+ content = `${section}\n\n${content}`;
55
+ }
56
+ }
57
+ try {
58
+ const result = await data_provider_1.dataService.writeSpaceWikiPageContent({
59
+ spaceId: args.space,
60
+ pageId: flags['page-id'],
61
+ data: {
62
+ content,
63
+ expectedKind: 'charter',
64
+ mode: flags.append ? 'append' : 'replace',
65
+ section,
66
+ lead: flags.lead || undefined,
67
+ note: flags.note,
68
+ },
69
+ });
70
+ if (flags.json) {
71
+ this.printJsonResult(result);
72
+ }
73
+ else {
74
+ this.log('status' in result && result.status === 'pending_approval'
75
+ ? 'Charter revision submitted for approval.'
76
+ : 'Charter revised.');
77
+ }
78
+ }
79
+ catch (error) {
80
+ this.handleApiError(error);
81
+ }
82
+ }
83
+ }
84
+ exports.default = SpacesCharterRevise;
@@ -23,6 +23,7 @@ export default class SpacesSkillsPropose extends BaseCommand {
23
23
  applies: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
24
24
  except: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
25
25
  key: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
26
+ 'task-result': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
26
27
  json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
27
28
  };
28
29
  run(): Promise<void>;
@@ -43,6 +43,10 @@ class SpacesSkillsPropose extends base_command_1.BaseCommand {
43
43
  key: core_1.Flags.string({
44
44
  description: 'Idempotency key: a retry with the same key returns the first proposal',
45
45
  }),
46
+ 'task-result': core_1.Flags.string({
47
+ description: 'Exact Task Result ID from this Space’s Notebook (repeatable)',
48
+ multiple: true,
49
+ }),
46
50
  json: core_1.Flags.boolean({ description: 'Output as JSON' }),
47
51
  };
48
52
  async run() {
@@ -65,6 +69,7 @@ class SpacesSkillsPropose extends base_command_1.BaseCommand {
65
69
  ...(flags.summary ? { summary: flags.summary } : {}),
66
70
  ...(flags.applies?.length ? { applicability: flags.applies } : {}),
67
71
  ...(flags.except?.length ? { exclusions: flags.except } : {}),
72
+ ...(flags['task-result']?.length ? { notebookTaskResultIds: flags['task-result'] } : {}),
68
73
  idempotencyKey: flags.key || `space-skill:${(0, node_crypto_1.randomUUID)()}`,
69
74
  });
70
75
  }
@@ -15,7 +15,9 @@ const tasks_1 = require("../../lib/tasks");
15
15
  const task_instruction_offer_1 = require("../../lib/task-instruction-offer");
16
16
  const list_workspace_1 = require("../../lib/list-workspace");
17
17
  const web_url_1 = require("../../lib/web-url");
18
+ const write_outcome_1 = require("../../lib/write-outcome");
18
19
  const TASK_CREATE_MAY_HAVE_COMMITTED_RE = /fetch failed|socket hang up|timed? ?out/i;
20
+ const TASK_CREATE_PRE_WRITE_REFUSALS = { SPACE_GOAL_WORK_CAPACITY_FULL: 409 };
19
21
  /**
20
22
  * Whether the estimate we asked for survived the write. (S3 dogfood finding)
21
23
  *
@@ -705,7 +707,20 @@ class TasksCreate extends base_command_1.BaseCommand {
705
707
  */
706
708
  failTaskCreate(err, payload, goalFromFlag) {
707
709
  const goalId = payload.goalId;
708
- if ((0, base_command_1.apiRefusal)(err).code === tasks_1.TASK_GOAL_NOT_FOUND && typeof goalId === 'string' && goalId) {
710
+ const refusal = (0, base_command_1.apiRefusal)(err);
711
+ const request = (0, write_outcome_1.requestOfError)(err);
712
+ if (request.method?.toUpperCase() === 'POST' &&
713
+ request.path === '/api/tasks' &&
714
+ refusal.body?.phase === 'before_write' &&
715
+ (0, write_outcome_1.classifyRequestOutcome)({
716
+ request,
717
+ status: err?.status,
718
+ body: refusal.body,
719
+ refusals: TASK_CREATE_PRE_WRITE_REFUSALS,
720
+ }).kind === 'rejected') {
721
+ this.setJsonOperation({ writeState: 'not_attempted' });
722
+ }
723
+ if (refusal.code === tasks_1.TASK_GOAL_NOT_FOUND && typeof goalId === 'string' && goalId) {
709
724
  this.failWithCliError({
710
725
  message: (0, tasks_1.describeTaskGoalNotFound)({
711
726
  goalId,
@@ -14,6 +14,7 @@ export default class TasksResultShow extends BaseCommand {
14
14
  static flags: {
15
15
  task: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
16
  history: import("@oclif/core/interfaces").BooleanFlag<boolean>;
17
+ result: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
18
  json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
18
19
  };
19
20
  run(): Promise<void>;
@@ -6,6 +6,7 @@ const data_provider_1 = require("@skrr-ai/data-provider");
6
6
  const base_command_1 = require("../../../base-command");
7
7
  const task_resolver_1 = require("../../../lib/task-resolver");
8
8
  const task_legacy_1 = require("../../../lib/task-legacy");
9
+ const api_fetch_1 = require("../../../lib/api-fetch");
9
10
  /**
10
11
  * What a reviewer needs to accept ONE exact Result (OSK-15430). `result show` printed the summary and
11
12
  * the conclusion, and kept the Result id (the value `tasks review --result-id` requires), the linked
@@ -57,19 +58,39 @@ function describeResultDetail(current, all = []) {
57
58
  return lines;
58
59
  }
59
60
  class TasksResultShow extends base_command_1.BaseCommand {
60
- static description = 'Show the current Task Result and its exact Review';
61
+ static description = 'Show the current Task Result and its Review, or read an exact Result version';
61
62
  static args = {
62
63
  task: core_1.Args.string({ required: false, ignoreStdin: true, description: 'Task id or ref' }),
63
64
  };
64
65
  static flags = {
65
66
  task: core_1.Flags.string({ description: 'Task id; overrides runtime context' }),
66
67
  history: core_1.Flags.boolean({ description: 'Include superseded Result versions' }),
68
+ result: core_1.Flags.string({ description: 'Read one immutable Result by id', exclusive: ['history'] }),
67
69
  json: core_1.Flags.boolean({ description: 'Output JSON' }),
68
70
  };
69
71
  async run() {
70
72
  this.requireAuth();
71
73
  const { args, flags } = await this.parse(TasksResultShow);
72
74
  const task = (0, task_resolver_1.resolveTaskIdentity)({ positionalId: args.task, flagTask: flags.task });
75
+ if (flags.result) {
76
+ const scopeKey = process.env.OVERSKY_SPACE_REVIEW_WORK === '1' || process.env.OVERSKY_SPACE_GOAL_WORK === '1' ? 'reviewSpaceId'
77
+ : process.env.OVERSKY_SPACE_NOTEBOOK_RESULT === '1' ? 'notebookSpaceId' : undefined;
78
+ const spaceId = process.env.OVERSKY_SESSION_SPACE_ID;
79
+ if (scopeKey && !spaceId)
80
+ this.error('This evidence read requires a bound Space.', { exit: 2 });
81
+ const query = scopeKey && spaceId ? `?${new URLSearchParams({ [scopeKey]: spaceId })}` : '';
82
+ const path = `/api/tasks/${encodeURIComponent(task.id)}/results/${encodeURIComponent(flags.result)}`;
83
+ try {
84
+ const exact = await (0, api_fetch_1.apiFetch)(`${path}${query}`);
85
+ if (flags.json)
86
+ return this.log(JSON.stringify(exact));
87
+ return this.log([`Result v${exact.version} ${exact.id}`, exact.summary, exact.body,
88
+ ...describeResultDetail(exact)].filter(Boolean).join('\n'));
89
+ }
90
+ catch (error) {
91
+ return this.handleApiError(error);
92
+ }
93
+ }
73
94
  let result;
74
95
  try {
75
96
  result = await data_provider_1.dataService.listTaskResults(task.id, { includeSuperseded: flags.history });
@@ -14,6 +14,9 @@ export default class TasksStart extends BaseCommand {
14
14
  capability: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
15
  branch: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
16
  'request-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ 'orchestration-version': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
+ 'orchestration-assign-agent': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
+ 'orchestration-failed-run': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
20
  };
18
21
  run(): Promise<void>;
19
22
  }
@@ -55,10 +55,20 @@ class TasksStart extends base_command_1.BaseCommand {
55
55
  'request-id': core_1.Flags.string({
56
56
  description: 'Stable idempotency key for this logical start. Reuse it after a lost response; inspect it with tasks start-receipt.',
57
57
  }),
58
+ 'orchestration-version': core_1.Flags.integer({ hidden: true, min: 0 }),
59
+ 'orchestration-assign-agent': core_1.Flags.string({ hidden: true, dependsOn: ['orchestration-version'] }),
60
+ 'orchestration-failed-run': core_1.Flags.string({ hidden: true, dependsOn: ['orchestration-version'], exclusive: ['orchestration-assign-agent'] }),
58
61
  };
59
62
  async run() {
60
63
  this.requireAuth();
61
64
  const { args, flags } = await this.parse(TasksStart);
65
+ const orchestrationVersion = flags['orchestration-version'];
66
+ const assignAgentId = flags['orchestration-assign-agent'];
67
+ const failedRunId = flags['orchestration-failed-run'];
68
+ if (orchestrationVersion !== undefined && (process.env.OVERSKY_SPACE_ORCHESTRATION_WORK !== '1' ||
69
+ !flags['request-id'] || flags.branch || flags['dry-run'] || flags.skill || flags.capability?.length)) {
70
+ this.error('A scoped orchestration start requires the Duty runtime, a Task version and a request id.', { exit: 2 });
71
+ }
62
72
  let taskIdentity;
63
73
  try {
64
74
  taskIdentity = (0, task_resolver_1.resolveTaskIdentity)({ positionalId: args.id, flagTask: flags.task });
@@ -153,7 +163,7 @@ class TasksStart extends base_command_1.BaseCommand {
153
163
  try {
154
164
  // Check capability before any mutation. Skill and capability overrides
155
165
  // still use the existing endpoint that can honor them.
156
- if (!flags.skill && !flags.capability?.length) {
166
+ if (orchestrationVersion === undefined && !flags.skill && !flags.capability?.length) {
157
167
  const chat = await data_provider_1.dataService.getTaskChat(taskId).catch((error) => {
158
168
  if ([404, 405].includes((0, http_error_1.httpStatusOf)(error) ?? 0))
159
169
  return null;
@@ -192,6 +202,7 @@ class TasksStart extends base_command_1.BaseCommand {
192
202
  result = await data_provider_1.dataService.startTask(taskId, {
193
203
  ...(flags.skill ? { skillId: flags.skill } : {}),
194
204
  ...(flags.capability?.length ? { requestedCapabilities: flags.capability } : {}),
205
+ ...(orchestrationVersion !== undefined ? { orchestration: { expectedVersion: orchestrationVersion, assignAgentId, failedRunId } } : {}),
195
206
  requestId,
196
207
  });
197
208
  }
@@ -31,15 +31,25 @@ class TriggersCapabilities extends base_command_1.BaseCommand {
31
31
  return;
32
32
  }
33
33
  this.log(`Scope: ${String(capabilities.scopeKind ?? args.scope)}`);
34
- this.log(`Kinds: ${Array.isArray(capabilities.allowedKinds) ? capabilities.allowedKinds.join(', ') : '-'}`);
34
+ const kinds = Array.isArray(capabilities.kinds) ? capabilities.kinds : null;
35
+ const authorableKinds = kinds?.filter((kind) => kind.executable && kind.authoringSurface === 'user').map((kind) => kind.kind) ??
36
+ capabilities.allowedKinds;
37
+ this.log(`Kinds: ${Array.isArray(authorableKinds) ? authorableKinds.join(', ') || '-' : '-'}`);
38
+ for (const kind of kinds ?? []) {
39
+ if (kind.executable && kind.authoringSurface === 'user')
40
+ continue;
41
+ const label = kind.authoringSurface === 'domain' ? 'Domain-managed' : 'Unavailable';
42
+ this.log(`${label} (${kind.kind})${kind.reason ? `: ${kind.reason}` : ''}`);
43
+ }
35
44
  // The modes `triggers create --mode` will accept. `allowedExecutorModes` is longer: it keeps the
36
45
  // modes only an internal producer may mint, which create refuses, so listing it here offered
37
46
  // choices that fail on submit (OSK-22489). A server that predates the field only has the long
38
47
  // list, and a person on it may be offered one refused choice.
39
- const authorable = Array.isArray(capabilities.authorableExecutorModes)
40
- ? capabilities.authorableExecutorModes
41
- : capabilities.allowedExecutorModes;
42
- this.log(`Modes: ${Array.isArray(authorable) ? authorable.join(', ') : '-'}`);
48
+ const { allowedExecutorModes, authorableExecutorModes } = capabilities;
49
+ const hasAuthoringPolicy = Array.isArray(authorableExecutorModes);
50
+ const authorable = hasAuthoringPolicy ? authorableExecutorModes : allowedExecutorModes;
51
+ const modesLabel = hasAuthoringPolicy ? 'Modes you can create' : 'Modes';
52
+ this.log(`${modesLabel}: ${Array.isArray(authorable) ? authorable.join(', ') || 'none' : '-'}`);
43
53
  // The mode names say nothing about side effects; describe the ones an author usually picks
44
54
  // between (OSK-21766).
45
55
  if (Array.isArray(authorable)) {
@@ -49,6 +59,15 @@ class TriggersCapabilities extends base_command_1.BaseCommand {
49
59
  this.log(` ${String(mode)}: ${effect}`);
50
60
  }
51
61
  }
62
+ if (Array.isArray(authorableExecutorModes) && Array.isArray(allowedExecutorModes)) {
63
+ const managed = allowedExecutorModes.filter((mode) => !authorableExecutorModes.includes(mode));
64
+ if (managed.length > 0) {
65
+ this.log(`Platform-managed modes: ${managed.join(', ')}`);
66
+ if (args.scope === 'duty_watcher') {
67
+ this.log('Manage the schedule on the Duty. To check now, run skrr duties check-now <duty-id>.');
68
+ }
69
+ }
70
+ }
52
71
  const vars = Array.isArray(capabilities.templateVariables)
53
72
  ? capabilities.templateVariables.map((v) => typeof v === 'object' && v !== null ? String(v.name) : String(v))
54
73
  : capabilities.templateVariableNames;
@@ -80,7 +80,7 @@ export default class TriggersCreate extends BaseCommand {
80
80
  run(): Promise<void>;
81
81
  /** How a saved working / quiet window will be read, when that is not what it looks like (OSK-22530). */
82
82
  private warnWindowAdvice;
83
- private warnMissingSelfSchedule;
83
+ private warnSelfSchedule;
84
84
  /**
85
85
  * The server creates the trigger and then says whether something already
86
86
  * watches the same thing. Printed AFTER the summary, and the sentence itself
@@ -28,7 +28,11 @@ class TriggersCreate extends base_command_1.BaseCommand {
28
28
  description: 'Scope ref as key=value (repeatable), for example --ref agentId=abc',
29
29
  multiple: true,
30
30
  }),
31
- kind: core_1.Flags.string({ description: 'Trigger kind', options: [...triggers_1.TRIGGER_KINDS] }),
31
+ kind: core_1.Flags.string({
32
+ description: 'Trigger kind. Some kinds are service-managed or unavailable. ' +
33
+ '`triggers capabilities <scope>` lists which kinds you can create and run.',
34
+ options: [...triggers_1.TRIGGER_KINDS],
35
+ }),
32
36
  label: core_1.Flags.string({ description: 'Human-readable trigger label' }),
33
37
  enabled: core_1.Flags.boolean({
34
38
  // The default is ON, and the USAGE line renders this as a bare
@@ -129,7 +133,9 @@ class TriggersCreate extends base_command_1.BaseCommand {
129
133
  probability: core_1.Flags.string({ description: 'Stochastic probability from 0 to 1' }),
130
134
  'jitter-ms': core_1.Flags.integer({ description: 'Stochastic jitter in ms' }),
131
135
  'eval-interval-minutes': core_1.Flags.integer({ description: 'Stochastic eval interval in minutes' }),
132
- 'next-run-at': core_1.Flags.string({ description: 'ISO datetime for self_scheduled triggers' }),
136
+ 'next-run-at': core_1.Flags.string({
137
+ description: 'Initial ISO time for self_scheduled. Its owning service sets later times. For once, use --at.',
138
+ }),
133
139
  'form-title': core_1.Flags.string({ description: 'Form heading for form triggers' }),
134
140
  'form-subtitle': core_1.Flags.string({ description: 'Form subtitle for form triggers' }),
135
141
  'form-fields': core_1.Flags.string({
@@ -333,7 +339,7 @@ class TriggersCreate extends base_command_1.BaseCommand {
333
339
  }
334
340
  if (trigger.dryRun) {
335
341
  this.log('Trigger accepted by dry run.');
336
- this.warnMissingSelfSchedule(trigger);
342
+ this.warnSelfSchedule(trigger);
337
343
  this.warnWindowAdvice(trigger);
338
344
  return;
339
345
  }
@@ -342,7 +348,7 @@ class TriggersCreate extends base_command_1.BaseCommand {
342
348
  if (url)
343
349
  this.log(`View it at ${url}`);
344
350
  this.warnDuplicateSubscriptions(trigger);
345
- this.warnMissingSelfSchedule(trigger);
351
+ this.warnSelfSchedule(trigger);
346
352
  this.warnWindowAdvice(trigger);
347
353
  }
348
354
  /** How a saved working / quiet window will be read, when that is not what it looks like (OSK-22530). */
@@ -350,11 +356,11 @@ class TriggersCreate extends base_command_1.BaseCommand {
350
356
  for (const advice of (0, triggers_1.windowAuthoringAdvice)(trigger))
351
357
  this.warn(advice);
352
358
  }
353
- warnMissingSelfSchedule(trigger) {
359
+ warnSelfSchedule(trigger) {
354
360
  const warnings = trigger?.warnings;
355
361
  if (!Array.isArray(warnings))
356
362
  return;
357
- const warning = warnings.find((item) => item && typeof item === 'object' && item.code === 'self_scheduled_without_next_run');
363
+ const warning = warnings.find((item) => item?.code === 'self_scheduled_without_next_run' || item?.code === 'self_scheduled_initial_only');
358
364
  if (typeof warning?.message === 'string')
359
365
  this.warn(warning.message);
360
366
  }
@@ -412,6 +418,9 @@ class TriggersCreate extends base_command_1.BaseCommand {
412
418
  this.error('--kind once requires --at <iso-datetime>.', { exit: 1 });
413
419
  }
414
420
  }
421
+ if (payload.kind === 'self_scheduled' && !payload.selfScheduled) {
422
+ this.error('A self-scheduled trigger needs an owning service to set its wake times. Pass --next-run-at for an initial time, or use --kind once --at for a one-time wake.', { exit: 1 });
423
+ }
415
424
  if (payload.kind === 'schedule') {
416
425
  const schedule = payload.schedule;
417
426
  try {