@skrr-ai/cli 0.1.14 → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/base-command.d.ts +14 -0
  2. package/dist/base-command.js +60 -1
  3. package/dist/commands/agents/create.d.ts +1 -0
  4. package/dist/commands/agents/create.js +6 -1
  5. package/dist/commands/agents/instructions/add.d.ts +21 -0
  6. package/dist/commands/agents/instructions/add.js +115 -0
  7. package/dist/commands/agents/instructions/disable.d.ts +13 -0
  8. package/dist/commands/agents/instructions/disable.js +50 -0
  9. package/dist/commands/agents/instructions/edit.d.ts +16 -0
  10. package/dist/commands/agents/instructions/edit.js +79 -0
  11. package/dist/commands/agents/instructions/enable.d.ts +13 -0
  12. package/dist/commands/agents/instructions/enable.js +50 -0
  13. package/dist/commands/agents/instructions/move.d.ts +15 -0
  14. package/dist/commands/agents/instructions/move.js +61 -0
  15. package/dist/commands/agents/instructions/preview.d.ts +13 -0
  16. package/dist/commands/agents/instructions/preview.js +59 -0
  17. package/dist/commands/agents/instructions/remove.d.ts +13 -0
  18. package/dist/commands/agents/instructions/remove.js +49 -0
  19. package/dist/commands/agents/instructions/set.d.ts +17 -0
  20. package/dist/commands/agents/instructions/set.js +79 -0
  21. package/dist/commands/agents/instructions/show.d.ts +15 -0
  22. package/dist/commands/agents/instructions/show.js +76 -0
  23. package/dist/commands/agents/instructions/upgrade.d.ts +16 -0
  24. package/dist/commands/agents/instructions/upgrade.js +77 -0
  25. package/dist/commands/agents/show.js +5 -0
  26. package/dist/commands/agents/triggers/policy.js +8 -2
  27. package/dist/commands/agents/update.d.ts +1 -0
  28. package/dist/commands/agents/update.js +8 -2
  29. package/dist/commands/daemon/index.js +2 -0
  30. package/dist/commands/daemon/recover-offline-queue.d.ts +9 -0
  31. package/dist/commands/daemon/recover-offline-queue.js +24 -0
  32. package/dist/commands/daemon/start.js +29 -1
  33. package/dist/commands/instruction-blocks/create.d.ts +19 -0
  34. package/dist/commands/instruction-blocks/create.js +94 -0
  35. package/dist/commands/instruction-blocks/delete.d.ts +13 -0
  36. package/dist/commands/instruction-blocks/delete.js +35 -0
  37. package/dist/commands/instruction-blocks/list.d.ts +13 -0
  38. package/dist/commands/instruction-blocks/list.js +71 -0
  39. package/dist/commands/instruction-blocks/show.d.ts +12 -0
  40. package/dist/commands/instruction-blocks/show.js +35 -0
  41. package/dist/commands/instruction-blocks/update.d.ts +23 -0
  42. package/dist/commands/instruction-blocks/update.js +94 -0
  43. package/dist/commands/spaces/auto-executor/preview.d.ts +1 -0
  44. package/dist/commands/spaces/auto-executor/preview.js +62 -3
  45. package/dist/commands/spaces/auto-executor/update.d.ts +4 -0
  46. package/dist/commands/spaces/auto-executor/update.js +78 -7
  47. package/dist/commands/spaces/capacity.js +14 -2
  48. package/dist/commands/spaces/update.d.ts +4 -0
  49. package/dist/commands/spaces/update.js +49 -2
  50. package/dist/commands/tasks/complete.d.ts +12 -5
  51. package/dist/commands/tasks/complete.js +50 -28
  52. package/dist/commands/tasks/continue-ready.js +9 -1
  53. package/dist/commands/tasks/create.d.ts +1 -0
  54. package/dist/commands/tasks/create.js +25 -1
  55. package/dist/commands/tasks/deliverable/add.d.ts +23 -0
  56. package/dist/commands/tasks/deliverable/add.js +70 -0
  57. package/dist/commands/tasks/events/append.d.ts +1 -1
  58. package/dist/commands/tasks/events/append.js +4 -4
  59. package/dist/commands/tasks/expectations.d.ts +12 -0
  60. package/dist/commands/tasks/expectations.js +92 -0
  61. package/dist/commands/tasks/judge.d.ts +29 -0
  62. package/dist/commands/tasks/judge.js +68 -0
  63. package/dist/commands/tasks/report.d.ts +1 -1
  64. package/dist/commands/tasks/report.js +3 -3
  65. package/dist/commands/tasks/update.d.ts +1 -0
  66. package/dist/commands/tasks/update.js +34 -4
  67. package/dist/commands/tasks/waive.d.ts +25 -0
  68. package/dist/commands/tasks/waive.js +58 -0
  69. package/dist/lib/agent-config.js +5 -0
  70. package/dist/lib/agent-instructions.d.ts +15 -0
  71. package/dist/lib/agent-instructions.js +55 -0
  72. package/dist/lib/command-hygiene.d.ts +6 -1
  73. package/dist/lib/command-hygiene.js +49 -29
  74. package/dist/lib/exec-runtime-binary.d.ts +13 -0
  75. package/dist/lib/exec-runtime-binary.js +45 -0
  76. package/dist/lib/git-task.d.ts +37 -0
  77. package/dist/lib/git-task.js +151 -0
  78. package/dist/lib/instruction-blocks.d.ts +29 -0
  79. package/dist/lib/instruction-blocks.js +159 -0
  80. package/dist/lib/runtime-start-verification.d.ts +49 -0
  81. package/dist/lib/runtime-start-verification.js +108 -0
  82. package/dist/lib/task-execution.d.ts +18 -2
  83. package/dist/lib/task-execution.js +19 -14
  84. package/dist/lib/task-transcript.js +1 -1
  85. package/dist/lib/tasks.d.ts +50 -0
  86. package/dist/lib/tasks.js +66 -1
  87. package/dist/node_modules/@skrr-ai/data-provider/index.js +2027 -1904
  88. package/dist/node_modules/@skrr-ai/inference-broker/package.json +1 -1
  89. package/oclif.manifest.json +13706 -11858
  90. package/package.json +4 -1
@@ -79,10 +79,15 @@ function satisfiesWaitTarget(task, until) {
79
79
  return until === 'terminal' ? exports.TERMINAL_STATUSES.has(status) : status === until;
80
80
  }
81
81
  function isActiveTask(task) {
82
- const status = statusOf(task);
83
- return (status === 'in_progress' ||
84
- isNonEmptyString(task.checkoutRunId) ||
85
- isNonEmptyString(task.sessionId));
82
+ if (isTerminalTask(task))
83
+ return false;
84
+ const reasonCode = task.actionability?.reasonCode;
85
+ if (typeof reasonCode === 'string')
86
+ return reasonCode === 'execution_running';
87
+ // Compatibility for older servers that do not attach actionability. A
88
+ // workflow status or leftover session is not compute ownership; only the
89
+ // checkout is a conservative fallback.
90
+ return isNonEmptyString(task.checkoutRunId);
86
91
  }
87
92
  function isRecoveredExecutionTask(task) {
88
93
  if (!isStartableTask(task))
@@ -178,19 +183,25 @@ async function fetchSpaceTasks(spaceId, limit = 500) {
178
183
  return items;
179
184
  }
180
185
  async function getSpaceCapacity(spaceId, limit = 1000) {
181
- const [space, tasks] = await Promise.all([
186
+ const [space, tasks, preview] = await Promise.all([
182
187
  data_provider_1.dataService.getSpace(spaceId),
183
188
  fetchSpaceTasks(spaceId, limit),
189
+ data_provider_1.dataService.previewSpaceAutoExecutor(spaceId),
184
190
  ]);
185
191
  const activeTasks = tasks.filter(isActiveTask);
186
- const maxActiveTasks = normalizePositiveInt(space.autoExecuteMaxActiveTasks, 3);
187
- const activeCount = activeTasks.length;
192
+ const canonicalCapacity = preview?.plan?.capacity;
193
+ if (!canonicalCapacity) {
194
+ throw new Error('Space auto-executor preview did not return canonical capacity');
195
+ }
196
+ const maxActiveTasks = canonicalCapacity.maxActiveTasks;
197
+ const activeCount = canonicalCapacity.activeCount;
188
198
  return {
189
199
  object: 'space_task_capacity',
190
200
  space,
191
201
  maxActiveTasks,
192
202
  activeCount,
193
- availableSlots: Math.max(0, maxActiveTasks - activeCount),
203
+ availableSlots: canonicalCapacity.availableSlots,
204
+ budget: canonicalCapacity.budget ?? null,
194
205
  activeTasks,
195
206
  sampledTaskCount: tasks.length,
196
207
  };
@@ -314,9 +325,3 @@ function stringValue(value) {
314
325
  function isNonEmptyString(value) {
315
326
  return typeof value === 'string' && value.trim().length > 0;
316
327
  }
317
- function normalizePositiveInt(value, fallback) {
318
- const n = Number(value);
319
- if (!Number.isFinite(n) || n <= 0)
320
- return fallback;
321
- return Math.floor(n);
322
- }
@@ -53,7 +53,7 @@ function parseTaskOutputBlock(body) {
53
53
  return {
54
54
  status: field('status'),
55
55
  summary: field('summary'),
56
- artifacts: field('artifacts'),
56
+ artifacts: field('deliverables') || field('artifacts'),
57
57
  verdict: field('verdict'),
58
58
  };
59
59
  }
@@ -1,3 +1,4 @@
1
+ import type { ParsedDeliverableCoordinate, ParsedExpectationSpec } from '@skrr-ai/data-provider';
1
2
  export declare const TASK_PRIORITIES: readonly ["low", "medium", "high", "critical"];
2
3
  /**
3
4
  * The kinds `tasks events append --kind` will accept.
@@ -50,6 +51,14 @@ export type TaskCreateFlagValues = {
50
51
  'assignee-agent'?: string[];
51
52
  'assignee-user'?: string[];
52
53
  'execution-mode'?: string;
54
+ expectations?: Array<{
55
+ shape?: string;
56
+ kind?: string;
57
+ format?: string;
58
+ target?: string;
59
+ description?: string;
60
+ presetKey?: string;
61
+ }>;
53
62
  'start-date'?: string;
54
63
  'due-date'?: string;
55
64
  estimate?: number;
@@ -62,6 +71,47 @@ export type TaskCreateFlagValues = {
62
71
  * true ⇒ 'ephemeral', false ⇒ 'shared', undefined ⇒ undefined (inherit/leave).
63
72
  */
64
73
  export declare function executionIsolationFromWorktreeFlag(worktree: boolean | undefined): 'shared' | 'ephemeral' | undefined;
74
+ /**
75
+ * Parse an expectation spec.
76
+ *
77
+ * DELEGATES to `@skrr-ai/data-provider`, which owns the grammar and is read by
78
+ * the API and the web client too. The copy this replaces validated correctly
79
+ * and then described a syntax it refused — its messages named three different
80
+ * flags (`--requires`, `--output`, `--accept`) and used `git_ref:origin/main`
81
+ * as the example, a value the same function rejects. For an agent the refusal
82
+ * IS the documentation: it hits the error and corrects, so an error naming a
83
+ * rejected example costs a whole turn and can loop.
84
+ */
85
+ export declare function parseExpectation(spec: string): {
86
+ ok: true;
87
+ value: ParsedExpectationSpec;
88
+ } | {
89
+ ok: false;
90
+ error: string;
91
+ };
92
+ /** Parse several, failing on the first that cannot be read. */
93
+ export declare function parseExpectations(specs: string[] | undefined): {
94
+ ok: true;
95
+ value: ParsedExpectationSpec[];
96
+ } | {
97
+ ok: false;
98
+ error: string;
99
+ };
100
+ export declare const EXPECT_FLAG_HELP: string;
101
+ /**
102
+ * Parse a deliverable coordinate. Also delegated — `:` and `@` and now `/` all
103
+ * mean different things, and a second implementation of that grammar is how the
104
+ * declaring side and the recording side stop agreeing.
105
+ */
106
+ export declare function parseDeliverableCoordinate(spec: string): {
107
+ ok: true;
108
+ value: ParsedDeliverableCoordinate;
109
+ } | {
110
+ ok: false;
111
+ error: string;
112
+ };
113
+ /** Lifecycle values a caller may assert, for flag validation. */
114
+ export declare const DELIVERABLE_LIFECYCLE_VALUES: readonly ["local", "in_review", "durable", "blocked", "superseded"];
65
115
  export declare function buildTaskCreatePayload(body: TaskRecord, flags?: TaskCreateFlagValues): TaskRecord;
66
116
  /**
67
117
  * The Agent this CLI process is running AS, if any.
package/dist/lib/tasks.js CHANGED
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RECOGNIZED_TASK_VERDICTS = exports.TASK_WORK_EVENT_KINDS = exports.TASK_PRIORITIES = void 0;
3
+ exports.RECOGNIZED_TASK_VERDICTS = exports.DELIVERABLE_LIFECYCLE_VALUES = exports.EXPECT_FLAG_HELP = exports.TASK_WORK_EVENT_KINDS = exports.TASK_PRIORITIES = void 0;
4
4
  exports.releasePinRepairGuard = releasePinRepairGuard;
5
5
  exports.taskUpdateMutationGuard = taskUpdateMutationGuard;
6
6
  exports.executionIsolationFromWorktreeFlag = executionIsolationFromWorktreeFlag;
7
+ exports.parseExpectation = parseExpectation;
8
+ exports.parseExpectations = parseExpectations;
9
+ exports.parseDeliverableCoordinate = parseDeliverableCoordinate;
7
10
  exports.buildTaskCreatePayload = buildTaskCreatePayload;
8
11
  exports.boundSessionAgentId = boundSessionAgentId;
9
12
  exports.applyDaemonSessionDefaults = applyDaemonSessionDefaults;
@@ -106,6 +109,67 @@ function executionIsolationFromWorktreeFlag(worktree) {
106
109
  return undefined;
107
110
  return worktree ? 'ephemeral' : 'shared';
108
111
  }
112
+ /**
113
+ * Parse an expectation spec.
114
+ *
115
+ * DELEGATES to `@skrr-ai/data-provider`, which owns the grammar and is read by
116
+ * the API and the web client too. The copy this replaces validated correctly
117
+ * and then described a syntax it refused — its messages named three different
118
+ * flags (`--requires`, `--output`, `--accept`) and used `git_ref:origin/main`
119
+ * as the example, a value the same function rejects. For an agent the refusal
120
+ * IS the documentation: it hits the error and corrects, so an error naming a
121
+ * rejected example costs a whole turn and can loop.
122
+ */
123
+ function parseExpectation(spec) {
124
+ return (0, data_provider_1.parseExpectationSpec)(spec);
125
+ }
126
+ /** Parse several, failing on the first that cannot be read. */
127
+ function parseExpectations(specs) {
128
+ if (!specs || specs.length === 0) {
129
+ return { ok: true, value: [] };
130
+ }
131
+ const out = [];
132
+ for (const spec of specs) {
133
+ const parsed = (0, data_provider_1.parseExpectationSpec)(spec);
134
+ if (!parsed.ok) {
135
+ return parsed;
136
+ }
137
+ out.push(parsed.value);
138
+ }
139
+ return { ok: true, value: out };
140
+ }
141
+ /**
142
+ * The one-line help every expectation flag shares, so they cannot disagree.
143
+ *
144
+ * The vocabulary is read from the owning package, but DEFENSIVELY: oclif
145
+ * evaluates a flag `description` when the command class body runs, i.e. at
146
+ * module load, and several suites mock `@skrr-ai/data-provider` with an
147
+ * explicit allow-list that predates these exports. Under such a mock the arrays
148
+ * are `undefined`, and a HELP STRING is never worth failing a module load for —
149
+ * the fallbacks below are a test-environment courtesy, never the vocabulary
150
+ * anything is validated against. `parseExpectationSpec` runs at call time
151
+ * against the real module and remains the only authority.
152
+ */
153
+ const kindsForHelp = Array.isArray(data_provider_1.TASK_OUTCOME_KINDS)
154
+ ? data_provider_1.TASK_OUTCOME_KINDS.join(', ')
155
+ : 'code, page, url, file, message, dataset';
156
+ const presetsForHelp = Array.isArray(data_provider_1.EXPECTATION_PRESETS)
157
+ ? data_provider_1.EXPECTATION_PRESETS.map((preset) => `@${preset.key}`).join(', ')
158
+ : '@merged-to-main, @pdf-delivered';
159
+ exports.EXPECT_FLAG_HELP = 'What this task must produce, as <kind>[/<format>][:<target>] or @<preset> — ' +
160
+ `e.g. 'code:origin/main', 'file/pdf:Drive/Reports', '@merged-to-main'. ` +
161
+ `Kinds: ${kindsForHelp}. Presets: ${presetsForHelp}. ` +
162
+ 'Anything else is stored as a plain-language expectation a person settles. Repeatable.';
163
+ /**
164
+ * Parse a deliverable coordinate. Also delegated — `:` and `@` and now `/` all
165
+ * mean different things, and a second implementation of that grammar is how the
166
+ * declaring side and the recording side stop agreeing.
167
+ */
168
+ function parseDeliverableCoordinate(spec) {
169
+ return (0, data_provider_1.parseDeliverableCoordinate)(spec);
170
+ }
171
+ /** Lifecycle values a caller may assert, for flag validation. */
172
+ exports.DELIVERABLE_LIFECYCLE_VALUES = data_provider_1.DELIVERABLE_LIFECYCLES;
109
173
  function buildTaskCreatePayload(body, flags = {}) {
110
174
  const payload = (0, prompt_1.mergeDefined)(body, {
111
175
  templateId: flags.template,
@@ -123,6 +187,7 @@ function buildTaskCreatePayload(body, flags = {}) {
123
187
  assigneeAgentIds: flags['assignee-agent'],
124
188
  assigneeUserIds: flags['assignee-user'],
125
189
  executionMode: flags['execution-mode'],
190
+ expectations: flags.expectations,
126
191
  startDate: flags['start-date'],
127
192
  dueDate: flags['due-date'],
128
193
  estimate: flags.estimate,