@skrr-ai/cli 0.1.185 → 0.1.188

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/bin/dev.cjs ADDED
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ // Load the same commands, flags and hooks as the shipped CLI, directly from the
4
+ // checkout. A stale release manifest cannot determine which source command runs.
5
+ const path = require('node:path');
6
+ const { Plugin, settings, run } = require('@oclif/core');
7
+
8
+ async function main(argv) {
9
+ const root = path.resolve(__dirname, '..');
10
+ const pjson = require('../package.json');
11
+ settings.enableAutoTranspile = true;
12
+ const source = new Plugin({ root, isRoot: true, ignoreManifest: true, errorOnManifestCreate: true });
13
+ await source.load();
14
+ const bundled = await Promise.all(
15
+ (pjson.oclif.plugins ?? []).map(async (name) => {
16
+ const plugin = new Plugin({ root, name, parent: source, type: 'core' });
17
+ await plugin.load();
18
+ return plugin;
19
+ }),
20
+ );
21
+ require('../src/lib/command-manifest.ts').useSourceCommandManifest(root, source.manifest);
22
+ require('../src/lib/config.ts').seedWorkspaceEnv();
23
+ await run(argv, { root, plugins: [source, ...bundled] });
24
+ }
25
+
26
+ main(process.argv.slice(2)).catch((error) => {
27
+ console.error(error.message || String(error));
28
+ process.exitCode = error.oclif?.exit ?? 1;
29
+ });
package/bin/run.js CHANGED
@@ -97,12 +97,20 @@ function describeCliVersion(startPath) {
97
97
  }
98
98
 
99
99
  const cliRoot = path.resolve(__dirname, '..');
100
+ const requireLocalBuild = process.env.SKRR_NO_DEV_FALLBACK === '1';
100
101
  const missingBuildPath = missingLocalCommandBuild({
101
102
  cliRoot,
102
103
  argv: process.argv.slice(2),
103
- verifySourceIdentity: process.env.CI !== 'true',
104
+ verifySourceIdentity: requireLocalBuild || process.env.CI !== 'true',
104
105
  });
105
106
  if (missingBuildPath) {
107
+ if (requireLocalBuild) {
108
+ console.error(
109
+ `[skrr] SKRR_NO_DEV_FALLBACK=1: CLI build output is missing or stale at ${missingBuildPath}. ` +
110
+ `Run "npm --prefix cli run build" in ${path.dirname(cliRoot)}.`,
111
+ );
112
+ process.exit(1);
113
+ }
106
114
  const invokedName = path.basename(process.argv[1] || 'skrr');
107
115
  const commandName = invokedName === 'run.js' ? 'skrr' : invokedName;
108
116
  const fallback =
@@ -114,21 +122,6 @@ if (missingBuildPath) {
114
122
  requiredCommand: path.relative(path.join(cliRoot, 'dist', 'commands'), missingBuildPath),
115
123
  });
116
124
  if (fallback) {
117
- // A developer verifying a change is the one caller for whom this fallback is
118
- // not a safety net: it silently substitutes a DIFFERENT BUILD of the thing
119
- // under test. The loop that trips it is exactly fix -> commit -> verify,
120
- // because the pre-commit hook reformats staged sources and that invalidates
121
- // the whole-tree digest for every command, not just the one edited.
122
- //
123
- // So name the substitution rather than just the fact, and let anyone who is
124
- // verifying turn the fallback off outright.
125
- if (process.env.SKRR_NO_DEV_FALLBACK === '1') {
126
- console.error(
127
- `[skrr] Refusing to fall back: SKRR_NO_DEV_FALLBACK=1 and the local build is stale at ` +
128
- `${missingBuildPath}. Run "npm --prefix cli run build".`,
129
- );
130
- process.exit(1);
131
- }
132
125
  console.error(
133
126
  `[skrr] Local development build is incomplete (${missingBuildPath}).\n` +
134
127
  `[skrr] Running ${fallback} (${describeCliVersion(fallback)}) INSTEAD OF ` +
@@ -283,8 +283,8 @@ class AgentsDelete extends base_command_1.BaseCommand {
283
283
  response = await data_provider_1.dataService.deleteAgent({ agent_id: args.id });
284
284
  }
285
285
  catch (err) {
286
- // A held Run refuses the delete until its owner reviews and closes it (OSK-24684). Name each Run and the
287
- // commands that resolve it, not the generic conflict.
286
+ // A server that predates OSK-24684 refuses the delete while a Run is held for result review. Name each Run and
287
+ // the commands that resolve it, not the generic conflict. A current server ends those Runs instead.
288
288
  const held = (0, data_provider_1.readAgentDeleteHeldRuns)((0, http_error_1.httpBodyOf)(err));
289
289
  if (held) {
290
290
  if (flags.json) {
@@ -312,6 +312,9 @@ class AgentsDelete extends base_command_1.BaseCommand {
312
312
  this.log(line);
313
313
  for (const line of agentRetainedReport(response, this.config.bin))
314
314
  this.log(line);
315
+ // The Runs held for result review the delete ended: nothing else will say so once the agent is gone (OSK-24684).
316
+ for (const line of (0, data_provider_1.agentDeleteEndedHeldRunsLines)(response))
317
+ this.log(line);
315
318
  }
316
319
  }
317
320
  exports.default = AgentsDelete;
@@ -20,6 +20,8 @@ export type VisibleCommandEntry = {
20
20
  flags: Record<string, unknown>;
21
21
  examples: string[];
22
22
  };
23
+ /** The source launcher supplies the catalog generated from the same commands it runs. */
24
+ export declare function useSourceCommandManifest(root: string, manifest: CommandManifest): void;
23
25
  export declare function manifestPath(rootDir: string): string;
24
26
  export declare function loadCommandManifest(rootDir: string): CommandManifest;
25
27
  export declare function commandKey(command: string): string;
@@ -33,6 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.useSourceCommandManifest = useSourceCommandManifest;
36
37
  exports.manifestPath = manifestPath;
37
38
  exports.loadCommandManifest = loadCommandManifest;
38
39
  exports.commandKey = commandKey;
@@ -43,10 +44,17 @@ const path = __importStar(require("node:path"));
43
44
  const COMMAND_KEY_RE = /\s+/g;
44
45
  const VISIBLE_COMMAND_ENTRIES_RE = /:/g;
45
46
  const SEARCH_VISIBLE_COMMAND_ENTRIES_RE = /\s+/;
47
+ let sourceManifest;
48
+ /** The source launcher supplies the catalog generated from the same commands it runs. */
49
+ function useSourceCommandManifest(root, manifest) {
50
+ sourceManifest = { root, manifest };
51
+ }
46
52
  function manifestPath(rootDir) {
47
53
  return path.join(rootDir, 'oclif.manifest.json');
48
54
  }
49
55
  function loadCommandManifest(rootDir) {
56
+ if (sourceManifest?.root === rootDir)
57
+ return sourceManifest.manifest;
50
58
  const p = manifestPath(rootDir);
51
59
  const raw = fs.readFileSync(p, 'utf8');
52
60
  return JSON.parse(raw);
@@ -289,6 +289,30 @@ export declare function createManagedEngineHooks(input: ManagedEngineHooksInput)
289
289
  * Returns null when there is nothing worth saying.
290
290
  */
291
291
  export declare function managedRenewalStoppedLine(reason: RenewalStopReason, detail?: string): string | null;
292
+ /**
293
+ * Account-decision codes newer than the server's first ones, which the server sends only to a
294
+ * client that lists them in its admit request.
295
+ *
296
+ * `balance-held` (OSK-24743) is a short balance whose money is held by work that gives it back on
297
+ * its own, usually this workspace's previous session in the seconds before its usage is recorded.
298
+ * Like `plan-concurrency-exhausted` it clears without anyone acting and still stops the run: the
299
+ * server read the account and named the remedy (wait for the other run, or add credit), and
300
+ * falling back would move this session onto the user's own key because another session holds the
301
+ * money. A CLI that does not list it is sent `balance-exhausted` with the same sentence.
302
+ */
303
+ export declare const ANNOUNCED_REFUSAL_CODES: readonly string[];
304
+ /**
305
+ * What this CLI's broker can carry, announced on admission (OSK-24682).
306
+ *
307
+ * `managed_claude_prompt_cache_v1`: the broker this CLI bundles carries a Claude lease that allows
308
+ * prompt caching (`@skrr-ai/inference-broker`: it hands the engine `OVERSKY_MANAGED_PROMPT_CACHING`
309
+ * when the lease's envelope allows it), the same broker the daemon announces it for. Admission
310
+ * withholds caching from a runtime that does not announce it (`promptCacheEnvelopeForRuntime`),
311
+ * so `skrr code` turns were admitted with `allowPromptCaching: false` and paid every input token
312
+ * at the full rate on every request, while the same model co-located on a Hosted Machine read its
313
+ * prefix from the cache. Whether a model may cache is still the policy's.
314
+ */
315
+ export declare const ANNOUNCED_RUNTIME_CAPABILITIES: readonly string[];
292
316
  export type ManagedAcquisitionFailure =
293
317
  /** The server decided about the account. The engine must not start. */
294
318
  {
@@ -59,7 +59,7 @@
59
59
  * forbids, and without a key it only starts an engine that cannot run.
60
60
  */
61
61
  Object.defineProperty(exports, "__esModule", { value: true });
62
- exports.ManagedAcquisitionError = void 0;
62
+ exports.ANNOUNCED_RUNTIME_CAPABILITIES = exports.ANNOUNCED_REFUSAL_CODES = exports.ManagedAcquisitionError = void 0;
63
63
  exports.acquireManagedSession = acquireManagedSession;
64
64
  exports.managedLeaseClockLine = managedLeaseClockLine;
65
65
  exports.createManagedEngineHooks = createManagedEngineHooks;
@@ -915,6 +915,11 @@ signal) {
915
915
  ...(input.reasoningEffort !== undefined ? { reasoningEffort: input.reasoningEffort } : {}),
916
916
  localRuntimeId: input.localRuntimeId,
917
917
  machineUuid: input.machineUuid,
918
+ // The refusal codes this CLI acts on beyond the ones every version knew. The server sends
919
+ // `balance-held` only to a client that lists it, because an older CLI would read an unknown
920
+ // code as "nothing was decided" and fall back to another credential (OSK-24743).
921
+ refusalCodes: exports.ANNOUNCED_REFUSAL_CODES,
922
+ runtimeCapabilities: exports.ANNOUNCED_RUNTIME_CAPABILITIES,
918
923
  }),
919
924
  ...(signal ? { signal } : {}),
920
925
  });
@@ -1392,12 +1397,39 @@ function managedRenewalStoppedLine(reason, detail) {
1392
1397
  */
1393
1398
  const ACCOUNT_DECISION_CODES = new Set([
1394
1399
  'balance-exhausted',
1400
+ 'balance-held',
1395
1401
  'billing-account-missing',
1396
1402
  'plan-allowance-exhausted',
1397
1403
  'plan-model-denied',
1398
1404
  'plan-window-exhausted',
1399
1405
  'plan-concurrency-exhausted',
1400
1406
  ]);
1407
+ /**
1408
+ * Account-decision codes newer than the server's first ones, which the server sends only to a
1409
+ * client that lists them in its admit request.
1410
+ *
1411
+ * `balance-held` (OSK-24743) is a short balance whose money is held by work that gives it back on
1412
+ * its own, usually this workspace's previous session in the seconds before its usage is recorded.
1413
+ * Like `plan-concurrency-exhausted` it clears without anyone acting and still stops the run: the
1414
+ * server read the account and named the remedy (wait for the other run, or add credit), and
1415
+ * falling back would move this session onto the user's own key because another session holds the
1416
+ * money. A CLI that does not list it is sent `balance-exhausted` with the same sentence.
1417
+ */
1418
+ exports.ANNOUNCED_REFUSAL_CODES = Object.freeze(['balance-held']);
1419
+ /**
1420
+ * What this CLI's broker can carry, announced on admission (OSK-24682).
1421
+ *
1422
+ * `managed_claude_prompt_cache_v1`: the broker this CLI bundles carries a Claude lease that allows
1423
+ * prompt caching (`@skrr-ai/inference-broker`: it hands the engine `OVERSKY_MANAGED_PROMPT_CACHING`
1424
+ * when the lease's envelope allows it), the same broker the daemon announces it for. Admission
1425
+ * withholds caching from a runtime that does not announce it (`promptCacheEnvelopeForRuntime`),
1426
+ * so `skrr code` turns were admitted with `allowPromptCaching: false` and paid every input token
1427
+ * at the full rate on every request, while the same model co-located on a Hosted Machine read its
1428
+ * prefix from the cache. Whether a model may cache is still the policy's.
1429
+ */
1430
+ exports.ANNOUNCED_RUNTIME_CAPABILITIES = Object.freeze([
1431
+ inference_broker_harnesses_1.MANAGED_CLAUDE_PROMPT_CACHE_CAPABILITY,
1432
+ ]);
1401
1433
  /**
1402
1434
  * What a failed acquisition does next, and the ONE line that says so.
1403
1435
  *