@skrr-ai/cli 0.1.201 → 0.1.202

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.
@@ -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 }
@@ -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,36 @@ 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 reviewSpaceId = process.env.OVERSKY_SPACE_REVIEW_WORK === '1'
77
+ ? process.env.OVERSKY_SESSION_SPACE_ID : undefined;
78
+ const query = reviewSpaceId ? `?${new URLSearchParams({ reviewSpaceId })}` : '';
79
+ const path = `/api/tasks/${encodeURIComponent(task.id)}/results/${encodeURIComponent(flags.result)}`;
80
+ try {
81
+ const exact = await (0, api_fetch_1.apiFetch)(`${path}${query}`);
82
+ if (flags.json)
83
+ return this.log(JSON.stringify(exact));
84
+ return this.log([`Result v${exact.version} ${exact.id}`, exact.summary, exact.body,
85
+ ...describeResultDetail(exact)].filter(Boolean).join('\n'));
86
+ }
87
+ catch (error) {
88
+ return this.handleApiError(error);
89
+ }
90
+ }
73
91
  let result;
74
92
  try {
75
93
  result = await data_provider_1.dataService.listTaskResults(task.id, { includeSuperseded: flags.history });
@@ -31,7 +31,16 @@ 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
@@ -39,7 +48,7 @@ class TriggersCapabilities extends base_command_1.BaseCommand {
39
48
  const authorable = Array.isArray(capabilities.authorableExecutorModes)
40
49
  ? capabilities.authorableExecutorModes
41
50
  : capabilities.allowedExecutorModes;
42
- this.log(`Modes: ${Array.isArray(authorable) ? authorable.join(', ') : '-'}`);
51
+ this.log(`Modes: ${Array.isArray(authorable) ? authorable.join(', ') || '-' : '-'}`);
43
52
  // The mode names say nothing about side effects; describe the ones an author usually picks
44
53
  // between (OSK-21766).
45
54
  if (Array.isArray(authorable)) {
@@ -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 {
@@ -1,3 +1,5 @@
1
+ export declare const SPACE_REVIEW_WORK_RUNTIME_PROOF_VERSION = 1;
2
+ export declare const SPACE_REVIEW_RESULT_RUNTIME_PROOF_VERSION = 1;
1
3
  /**
2
4
  * Account Authorization decides access; a separate server-issued session
3
5
  * credential proves Agent authorship. Environment ids are selectors only.
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SPACE_REVIEW_RESULT_RUNTIME_PROOF_VERSION = exports.SPACE_REVIEW_WORK_RUNTIME_PROOF_VERSION = void 0;
3
4
  exports.withTaskRuntimeHeaders = withTaskRuntimeHeaders;
4
5
  exports.taskRuntimeRedirectOptions = taskRuntimeRedirectOptions;
5
6
  const WITH_TASK_RUNTIME_HEADERS_RE = /^\/api\/tasks(?:\/|$)/;
@@ -7,6 +8,11 @@ const WITH_TASK_RUNTIME_HEADERS_RE_2 = /^\/api\/agents\/[^/]+\/agent-actions\/[^
7
8
  const WITH_TASK_RUNTIME_HEADERS_RE_3 = /^\/api\/(?:shortcuts|task-templates)\/[^/]+\/(?:instantiate|trigger)\/?$/;
8
9
  const WITH_TASK_RUNTIME_HEADERS_RE_4 = /^\/api\/templates\/[^/]+\/(?:instantiate|fork)\/?$/;
9
10
  const WITH_TASK_RUNTIME_HEADERS_RE_5 = /^\/api\/store\/services\/[^/]+\/install\/?$/;
11
+ const KEY_RESULT_LIST = /^\/api\/goals\/[^/]+\/key-results\/?$/;
12
+ const KEY_RESULT_ASSESS = /^\/api\/goals\/[^/]+\/key-results\/[^/]+\/assessments\/?$/;
13
+ const EXACT_TASK_RESULT = /^\/api\/tasks\/[^/]+\/results\/[^/]+\/?$/;
14
+ exports.SPACE_REVIEW_WORK_RUNTIME_PROOF_VERSION = 1;
15
+ exports.SPACE_REVIEW_RESULT_RUNTIME_PROOF_VERSION = 1;
10
16
  /**
11
17
  * Account Authorization decides access; a separate server-issued session
12
18
  * credential proves Agent authorship. Environment ids are selectors only.
@@ -15,14 +21,16 @@ const WITH_TASK_RUNTIME_HEADERS_RE_5 = /^\/api\/store\/services\/[^/]+\/install\
15
21
  */
16
22
  function withTaskRuntimeHeaders(headers, requestUrl, method, env = process.env) {
17
23
  const sent = { ...headers };
18
- // A companion credential never travels on a read, another API surface,
19
- // or a caller-selected header. Preserve existing nonsecret correlation
20
- // hints outside Task authorship mutations for other APIs' provenance checks.
24
+ // A companion credential travels only on the exact managed operations below.
25
+ // Preserve nonsecret correlation hints for other APIs' provenance checks.
21
26
  for (const key of Object.keys(sent)) {
22
27
  if (key.toLowerCase() === 'x-oversky-session-authorization')
23
28
  delete sent[key];
24
29
  }
25
- if (!['POST', 'PUT', 'PATCH', 'DELETE'].includes(method.toUpperCase()))
30
+ const verb = method.toUpperCase();
31
+ const mutation = ['POST', 'PUT', 'PATCH', 'DELETE'].includes(verb);
32
+ const reviewSpace = env.OVERSKY_SPACE_REVIEW_WORK === '1' ? env.OVERSKY_SESSION_SPACE_ID : undefined;
33
+ if (!mutation && !(reviewSpace && verb === 'GET'))
26
34
  return sent;
27
35
  const refuseOrigin = () => Object.assign(new Error('Managed Task requests require their bound server origin; refusing account-attributed fallback.'), {
28
36
  code: 'SESSION_TASK_ORIGIN_MISMATCH',
@@ -39,14 +47,23 @@ function withTaskRuntimeHeaders(headers, requestUrl, method, env = process.env)
39
47
  // Some platform operations materialize Tasks outside the Task router. Keep
40
48
  // their exact POST routes here; action/library edits, picker reads and other
41
49
  // integration routes must never receive the companion credential.
42
- const taskMutation = WITH_TASK_RUNTIME_HEADERS_RE.test(target.pathname);
43
- const taskCreation = method.toUpperCase() === 'POST' && [
50
+ const { pathname } = target;
51
+ const taskMutation = mutation && WITH_TASK_RUNTIME_HEADERS_RE.test(pathname);
52
+ const attributedWrite = verb === 'POST' && [
44
53
  WITH_TASK_RUNTIME_HEADERS_RE_2,
45
54
  WITH_TASK_RUNTIME_HEADERS_RE_3,
46
55
  WITH_TASK_RUNTIME_HEADERS_RE_4,
47
56
  WITH_TASK_RUNTIME_HEADERS_RE_5,
48
- ].some((route) => route.test(target.pathname));
49
- if (!taskMutation && !taskCreation)
57
+ KEY_RESULT_ASSESS,
58
+ ].some((route) => route.test(pathname));
59
+ const spacePath = reviewSpace ? `/api/spaces/${encodeURIComponent(reviewSpace)}` : undefined;
60
+ const reviewProof = spacePath && ((verb === 'GET' && (KEY_RESULT_LIST.test(pathname) || pathname === `${spacePath}/goals` ||
61
+ (EXACT_TASK_RESULT.test(pathname) && target.searchParams.getAll('reviewSpaceId').length === 1 &&
62
+ target.searchParams.get('reviewSpaceId') === reviewSpace) ||
63
+ (pathname === '/api/tasks' && target.searchParams.getAll('spaceId').length === 1 &&
64
+ target.searchParams.get('spaceId') === reviewSpace))) ||
65
+ (verb === 'POST' && pathname === `${spacePath}/wiki/pages`));
66
+ if (!taskMutation && !attributedWrite && !reviewProof)
50
67
  return sent;
51
68
  const names = new Set(['x-oversky-agent-id', 'x-oversky-session-id', 'x-oversky-autonomous-run-id']);
52
69
  for (const key of Object.keys(sent))
@@ -65,7 +82,7 @@ function withTaskRuntimeHeaders(headers, requestUrl, method, env = process.env)
65
82
  throw refuseOrigin();
66
83
  }
67
84
  // The companion credential only travels to the managed runtime's server
68
- // and only to Task mutations/materialization. Bound routes use it as Authorization.
85
+ // and only to the attributed operations and scoped Review receipts above.
69
86
  if (target.origin !== trusted.origin)
70
87
  throw refuseOrigin();
71
88
  if (!sessionId || !token) {
@@ -41919,7 +41919,7 @@
41919
41919
  "type": "option"
41920
41920
  },
41921
41921
  "activate": {
41922
- "description": "Turn the duty on right after creating it — the same resume + Preflight boundary as `duties resume`. A refused activation keeps the draft and reports the refusal's code, reason and fix, and exits nonzero. Use the returned ID to resume it instead of creating another.",
41922
+ "description": "Turn the duty on right after creating it — the same resume + Preflight boundary as `duties resume`. A refusal reports its code, reason and fix, and exits nonzero. If a new draft was saved, use its returned ID to resume it.",
41923
41923
  "name": "activate",
41924
41924
  "allowNo": false,
41925
41925
  "type": "boolean"
@@ -135001,7 +135001,7 @@
135001
135001
  "required": false
135002
135002
  }
135003
135003
  },
135004
- "description": "Show the current Task Result and its exact Review",
135004
+ "description": "Show the current Task Result and its Review, or read an exact Result version",
135005
135005
  "flags": {
135006
135006
  "bare": {
135007
135007
  "description": "Bare mode — ignore keychain/file credential sources. Token must come from env or --token.",
@@ -135049,6 +135049,16 @@
135049
135049
  "allowNo": false,
135050
135050
  "type": "boolean"
135051
135051
  },
135052
+ "result": {
135053
+ "description": "Read one immutable Result by id",
135054
+ "exclusive": [
135055
+ "history"
135056
+ ],
135057
+ "name": "result",
135058
+ "hasDynamicHelp": false,
135059
+ "multiple": false,
135060
+ "type": "option"
135061
+ },
135052
135062
  "json": {
135053
135063
  "description": "Output JSON",
135054
135064
  "name": "json",
@@ -144003,7 +144013,7 @@
144003
144013
  "type": "option"
144004
144014
  },
144005
144015
  "kind": {
144006
- "description": "Trigger kind",
144016
+ "description": "Trigger kind. Some kinds are service-managed or unavailable. `triggers capabilities <scope>` lists which kinds you can create and run.",
144007
144017
  "name": "kind",
144008
144018
  "hasDynamicHelp": false,
144009
144019
  "multiple": false,
@@ -144342,7 +144352,7 @@
144342
144352
  "type": "option"
144343
144353
  },
144344
144354
  "next-run-at": {
144345
- "description": "ISO datetime for self_scheduled triggers",
144355
+ "description": "Initial ISO time for self_scheduled. Its owning service sets later times. For once, use --at.",
144346
144356
  "name": "next-run-at",
144347
144357
  "hasDynamicHelp": false,
144348
144358
  "multiple": false,
@@ -151572,5 +151582,5 @@
151572
151582
  ]
151573
151583
  }
151574
151584
  },
151575
- "version": "0.1.201"
151585
+ "version": "0.1.202"
151576
151586
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skrr-ai/cli",
3
- "version": "0.1.201",
3
+ "version": "0.1.202",
4
4
  "description": "Command-line interface for skrr",
5
5
  "license": "ISC",
6
6
  "author": "skrr",
@@ -710,5 +710,5 @@
710
710
  "engines": {
711
711
  "node": ">=20.0.0"
712
712
  },
713
- "gitHead": "7c742e1a991446cd0457cbd61be6e35a863ed5ab"
713
+ "gitHead": "ef786b9ef8eda9f2e4ce6b06c91587a0080ab21d"
714
714
  }