@runtypelabs/cli 2.21.6 → 2.22.0

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 (2) hide show
  1. package/dist/index.js +163 -20
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -15128,7 +15128,7 @@ function date4(params) {
15128
15128
  // ../../node_modules/.pnpm/zod@4.4.2/node_modules/zod/v4/classic/external.js
15129
15129
  config(en_default());
15130
15130
 
15131
- // ../shared/dist/chunk-R2PFJC7N.mjs
15131
+ // ../shared/dist/chunk-NUTME5YJ.mjs
15132
15132
  var apiReleaseChannelSchema = external_exports.enum(["staging", "production"]);
15133
15133
  var API_ARTIFACT_SCRIPT_PATTERN = /^api-[a-z0-9][a-z0-9-]{0,62}$/;
15134
15134
  var apiArtifactScriptNameSchema = external_exports.string().regex(
@@ -15168,6 +15168,20 @@ var apiRoutingDocSchema = external_exports.object({
15168
15168
  message: "activeScript may only be null while legacyFallback is true",
15169
15169
  path: ["api", "activeScript"]
15170
15170
  });
15171
+ var edgeContextPayloadSchema = external_exports.object({
15172
+ /** Resolved Runtype user id (`user_…`). */
15173
+ userId: external_exports.string().min(1),
15174
+ /** Resolved org id (`org_…`); null for a personal (no-org) credential. */
15175
+ orgId: external_exports.string().min(1).nullable(),
15176
+ /** Billing tier display name (e.g. `growth`); informational at the edge. */
15177
+ tier: external_exports.string().min(1),
15178
+ /** Effective permission scopes for the credential (e.g. `["*"]`). */
15179
+ scopes: external_exports.array(external_exports.string()),
15180
+ /** Token id (one per mint) — replay/audit handle, never reused as a secret. */
15181
+ jti: external_exports.string().min(1),
15182
+ /** Expiry as epoch MILLISECONDS; the token is rejected once `exp <= now`. */
15183
+ exp: external_exports.number().int().positive()
15184
+ });
15171
15185
 
15172
15186
  // ../shared/dist/chunk-KR4LFVFE.mjs
15173
15187
  function getNestedValue(obj, path18) {
@@ -52726,6 +52740,32 @@ function listForkCandidates(log) {
52726
52740
  return candidates;
52727
52741
  }
52728
52742
 
52743
+ // src/marathon/steering-queue.ts
52744
+ function createSteeringQueue(options = {}) {
52745
+ const items = [];
52746
+ const notify = () => {
52747
+ options.onSizeChange?.(items.length);
52748
+ };
52749
+ return {
52750
+ push(message) {
52751
+ items.push(message);
52752
+ notify();
52753
+ },
52754
+ drain() {
52755
+ if (items.length === 0) return [];
52756
+ const drained = items.splice(0);
52757
+ notify();
52758
+ return drained;
52759
+ },
52760
+ size() {
52761
+ return items.length;
52762
+ },
52763
+ isEmpty() {
52764
+ return items.length === 0;
52765
+ }
52766
+ };
52767
+ }
52768
+
52729
52769
  // src/ink/marathon/CheckpointPrompt.tsx
52730
52770
  import { useState as useState26, useEffect as useEffect21, useRef as useRef8 } from "react";
52731
52771
  import { Box as Box23, Text as Text26 } from "ink";
@@ -55133,14 +55173,12 @@ function MarathonApp({
55133
55173
  getCallbacks: () => callbacks,
55134
55174
  getState: () => getHydratedState(),
55135
55175
  drainSteeringQueue: () => {
55136
- const drained = steeringQueueRef.current.splice(0);
55137
- if (drained.length > 0) setQueuedSteerCount(0);
55176
+ const drained = steeringQueue.drain();
55138
55177
  return drained.length > 0 ? drained : void 0;
55139
55178
  },
55140
- hasQueuedSteering: () => steeringQueueRef.current.length > 0,
55179
+ hasQueuedSteering: () => !steeringQueue.isEmpty(),
55141
55180
  drainFollowUpQueue: () => {
55142
- const drained = followUpQueueRef.current.splice(0);
55143
- if (drained.length > 0) setQueuedFollowUpCount(0);
55181
+ const drained = followUpQueue.drain();
55144
55182
  return drained.length > 0 ? drained : void 0;
55145
55183
  },
55146
55184
  appendSessionSnapshot: (snapshot) => {
@@ -55222,10 +55260,18 @@ function MarathonApp({
55222
55260
  setEscAbortArmed(false);
55223
55261
  }
55224
55262
  }, [isAgentWorkingPhase, escAbortArmed]);
55225
- const steeringQueueRef = useRef9([]);
55226
- const followUpQueueRef = useRef9([]);
55227
55263
  const [queuedSteerCount, setQueuedSteerCount] = useState31(0);
55228
55264
  const [queuedFollowUpCount, setQueuedFollowUpCount] = useState31(0);
55265
+ const steeringQueueHolder = useRef9(null);
55266
+ if (steeringQueueHolder.current === null) {
55267
+ steeringQueueHolder.current = createSteeringQueue({ onSizeChange: setQueuedSteerCount });
55268
+ }
55269
+ const steeringQueue = steeringQueueHolder.current;
55270
+ const followUpQueueHolder = useRef9(null);
55271
+ if (followUpQueueHolder.current === null) {
55272
+ followUpQueueHolder.current = createSteeringQueue({ onSizeChange: setQueuedFollowUpCount });
55273
+ }
55274
+ const followUpQueue = followUpQueueHolder.current;
55229
55275
  const [showSteerComposer, setShowSteerComposer] = useState31(false);
55230
55276
  const [steerDraft, setSteerDraft] = useState31("");
55231
55277
  const [activeScreen, setActiveScreen] = useState31("overview");
@@ -55724,8 +55770,7 @@ function MarathonApp({
55724
55770
  if (escAbortTimeout.current) clearTimeout(escAbortTimeout.current);
55725
55771
  setEscAbortArmed(false);
55726
55772
  if (onAbortTurn?.() && !noCheckpoint) {
55727
- const queued = steeringQueueRef.current.splice(0);
55728
- setQueuedSteerCount(0);
55773
+ const queued = steeringQueue.drain();
55729
55774
  const restored = [...queued, steerDraft].map((text) => text.trim()).filter(Boolean).join("\n\n");
55730
55775
  setSteerDraft("");
55731
55776
  setCheckpointInitialMessage(restored || void 0);
@@ -56457,11 +56502,9 @@ function MarathonApp({
56457
56502
  initialDraft: steerDraft,
56458
56503
  onSubmit: (message, kind) => {
56459
56504
  if (kind === "steer") {
56460
- steeringQueueRef.current.push(message);
56461
- setQueuedSteerCount(steeringQueueRef.current.length);
56505
+ steeringQueue.push(message);
56462
56506
  } else {
56463
- followUpQueueRef.current.push(message);
56464
- setQueuedFollowUpCount(followUpQueueRef.current.length);
56507
+ followUpQueue.push(message);
56465
56508
  }
56466
56509
  setSteerDraft("");
56467
56510
  setShowSteerComposer(false);
@@ -59455,7 +59498,40 @@ function resolveModelForPhase(phase, cliOverrides, milestoneModels) {
59455
59498
  }
59456
59499
  return cliOverrides.defaultModel;
59457
59500
  }
59458
- function resolveErrorHandlingForPhase(phase, cliFallbackModel, milestoneFallbackModels) {
59501
+ function resolveMaxTokensForPhase(phase, cliMaxTokens, milestoneMaxTokens, defaultMaxTokens) {
59502
+ if (phase && milestoneMaxTokens?.[phase] !== void 0) return milestoneMaxTokens[phase];
59503
+ if (cliMaxTokens !== void 0) return cliMaxTokens;
59504
+ return defaultMaxTokens;
59505
+ }
59506
+ function resolveTemperatureForPhase(phase, cliTemperature, milestoneTemperature, defaultTemperature) {
59507
+ if (phase && milestoneTemperature?.[phase] !== void 0) return milestoneTemperature[phase];
59508
+ if (cliTemperature !== void 0) return cliTemperature;
59509
+ return defaultTemperature;
59510
+ }
59511
+ function parseMaxTokensFlag(raw) {
59512
+ if (raw === void 0) return void 0;
59513
+ const value = Number(raw);
59514
+ if (!Number.isInteger(value) || value <= 0) {
59515
+ throw new Error(`Invalid --max-tokens "${raw}": expected a positive integer`);
59516
+ }
59517
+ return value;
59518
+ }
59519
+ function parseTemperatureFlag(raw) {
59520
+ if (raw === void 0) return void 0;
59521
+ const value = Number(raw);
59522
+ if (!Number.isFinite(value) || value < 0 || value > 2) {
59523
+ throw new Error(`Invalid --temperature "${raw}": expected a number between 0 and 2`);
59524
+ }
59525
+ return value;
59526
+ }
59527
+ function resolveFallbackOnEmptyForPhase(phase, milestoneFallbackOnEmpty, defaultFallbackOnEmpty) {
59528
+ if (phase && milestoneFallbackOnEmpty?.[phase] !== void 0) {
59529
+ return milestoneFallbackOnEmpty[phase];
59530
+ }
59531
+ return defaultFallbackOnEmpty ?? false;
59532
+ }
59533
+ function resolveErrorHandlingForPhase(phase, cliFallbackModel, milestoneFallbackModels, fallbackOnEmpty) {
59534
+ const triggers = fallbackOnEmpty ? [{ type: "empty-output" }, { type: "error" }] : void 0;
59459
59535
  const phaseFallbacks = phase ? milestoneFallbackModels?.[phase] : void 0;
59460
59536
  if (phaseFallbacks?.length) {
59461
59537
  return {
@@ -59468,7 +59544,8 @@ function resolveErrorHandlingForPhase(phase, cliFallbackModel, milestoneFallback
59468
59544
  ...fb.temperature !== void 0 ? { temperature: fb.temperature } : {},
59469
59545
  ...fb.maxTokens !== void 0 ? { maxTokens: fb.maxTokens } : {}
59470
59546
  }))
59471
- ]
59547
+ ],
59548
+ ...triggers ? { triggers } : {}
59472
59549
  };
59473
59550
  }
59474
59551
  if (cliFallbackModel) {
@@ -59477,7 +59554,8 @@ function resolveErrorHandlingForPhase(phase, cliFallbackModel, milestoneFallback
59477
59554
  fallbacks: [
59478
59555
  { type: "retry", delay: 5e3 },
59479
59556
  { type: "model", model: cliFallbackModel }
59480
- ]
59557
+ ],
59558
+ ...triggers ? { triggers } : {}
59481
59559
  };
59482
59560
  }
59483
59561
  return void 0;
@@ -59632,6 +59710,15 @@ function collectPlaybookWarnings(config3) {
59632
59710
  );
59633
59711
  }
59634
59712
  }
59713
+ const emptyDefault = config3.fallbackOnEmpty === true;
59714
+ for (const m2 of config3.milestones) {
59715
+ const enabled = m2.fallbackOnEmpty ?? emptyDefault;
59716
+ if (enabled && !m2.fallbackModels?.length) {
59717
+ warnings.push(
59718
+ `Playbook '${config3.name}': milestone '${m2.name}' enables fallbackOnEmpty but defines no fallbackModels \u2014 empty output has nothing to fall back to.`
59719
+ );
59720
+ }
59721
+ }
59635
59722
  return warnings;
59636
59723
  }
59637
59724
  var PLUGIN_EXTENSIONS = /* @__PURE__ */ new Set([".js", ".mjs", ".cjs"]);
@@ -59709,17 +59796,29 @@ async function loadPlaybook(nameOrPath, cwd) {
59709
59796
  });
59710
59797
  const milestoneModels = {};
59711
59798
  const milestoneFallbackModels = {};
59799
+ const milestoneMaxTokens = {};
59800
+ const milestoneTemperature = {};
59801
+ const milestoneFallbackOnEmpty = {};
59712
59802
  for (const m2 of config3.milestones) {
59713
59803
  if (m2.model) milestoneModels[m2.name] = m2.model;
59714
59804
  if (m2.fallbackModels?.length) {
59715
59805
  milestoneFallbackModels[m2.name] = m2.fallbackModels.map(normalizeFallbackModel);
59716
59806
  }
59807
+ if (m2.maxTokens !== void 0) milestoneMaxTokens[m2.name] = m2.maxTokens;
59808
+ if (m2.temperature !== void 0) milestoneTemperature[m2.name] = m2.temperature;
59809
+ if (m2.fallbackOnEmpty !== void 0) milestoneFallbackOnEmpty[m2.name] = m2.fallbackOnEmpty;
59717
59810
  }
59718
59811
  return {
59719
59812
  workflow,
59720
59813
  milestones: config3.milestones.map((m2) => m2.name),
59721
59814
  milestoneModels: Object.keys(milestoneModels).length > 0 ? milestoneModels : void 0,
59722
59815
  milestoneFallbackModels: Object.keys(milestoneFallbackModels).length > 0 ? milestoneFallbackModels : void 0,
59816
+ milestoneMaxTokens: Object.keys(milestoneMaxTokens).length > 0 ? milestoneMaxTokens : void 0,
59817
+ milestoneTemperature: Object.keys(milestoneTemperature).length > 0 ? milestoneTemperature : void 0,
59818
+ milestoneFallbackOnEmpty: Object.keys(milestoneFallbackOnEmpty).length > 0 ? milestoneFallbackOnEmpty : void 0,
59819
+ ...config3.maxTokens !== void 0 ? { defaultMaxTokens: config3.maxTokens } : {},
59820
+ ...config3.temperature !== void 0 ? { defaultTemperature: config3.temperature } : {},
59821
+ ...config3.fallbackOnEmpty !== void 0 ? { defaultFallbackOnEmpty: config3.fallbackOnEmpty } : {},
59723
59822
  verification: config3.verification,
59724
59823
  rules: config3.rules,
59725
59824
  policy: config3.policy,
@@ -60282,6 +60381,12 @@ async function taskAction(agent, options) {
60282
60381
  let playbookMilestones;
60283
60382
  let playbookMilestoneModels;
60284
60383
  let playbookMilestoneFallbackModels;
60384
+ let playbookMilestoneMaxTokens;
60385
+ let playbookMilestoneTemperature;
60386
+ let playbookMilestoneFallbackOnEmpty;
60387
+ let playbookDefaultMaxTokens;
60388
+ let playbookDefaultTemperature;
60389
+ let playbookDefaultFallbackOnEmpty;
60285
60390
  let playbookPolicy;
60286
60391
  if (options.playbook) {
60287
60392
  const result = await loadPlaybook(options.playbook);
@@ -60289,6 +60394,12 @@ async function taskAction(agent, options) {
60289
60394
  playbookMilestones = result.milestones;
60290
60395
  playbookMilestoneModels = result.milestoneModels;
60291
60396
  playbookMilestoneFallbackModels = result.milestoneFallbackModels;
60397
+ playbookMilestoneMaxTokens = result.milestoneMaxTokens;
60398
+ playbookMilestoneTemperature = result.milestoneTemperature;
60399
+ playbookMilestoneFallbackOnEmpty = result.milestoneFallbackOnEmpty;
60400
+ playbookDefaultMaxTokens = result.defaultMaxTokens;
60401
+ playbookDefaultTemperature = result.defaultTemperature;
60402
+ playbookDefaultFallbackOnEmpty = result.defaultFallbackOnEmpty;
60292
60403
  playbookPolicy = result.policy;
60293
60404
  for (const warning of result.warnings) {
60294
60405
  if (useStartupShell) {
@@ -60300,6 +60411,8 @@ async function taskAction(agent, options) {
60300
60411
  } else {
60301
60412
  playbookPolicy = void 0;
60302
60413
  }
60414
+ const cliMaxTokens = parseMaxTokensFlag(options.maxTokens);
60415
+ const cliTemperature = parseTemperatureFlag(options.temperature);
60303
60416
  if (useStartupShell && !options.model?.trim()) {
60304
60417
  if (playbookMilestoneModels && Object.keys(playbookMilestoneModels).length > 0 && startupShellRef.current) {
60305
60418
  let editableModels = { ...playbookMilestoneModels };
@@ -60439,7 +60552,12 @@ ${rulesContext}`;
60439
60552
  const initialErrorHandling = resolveErrorHandlingForPhase(
60440
60553
  currentPhase,
60441
60554
  options.fallbackModel,
60442
- playbookMilestoneFallbackModels
60555
+ playbookMilestoneFallbackModels,
60556
+ resolveFallbackOnEmptyForPhase(
60557
+ currentPhase,
60558
+ playbookMilestoneFallbackOnEmpty,
60559
+ playbookDefaultFallbackOnEmpty
60560
+ )
60443
60561
  );
60444
60562
  if (initialErrorHandling) {
60445
60563
  await client.agents.update(agentId, { config: { errorHandling: initialErrorHandling } }).catch(() => {
@@ -60773,6 +60891,18 @@ Saving state... done. Session saved to ${filePath}`);
60773
60891
  },
60774
60892
  playbookMilestoneModels
60775
60893
  );
60894
+ const phaseMaxTokens = resolveMaxTokensForPhase(
60895
+ resumeState?.workflowPhase,
60896
+ cliMaxTokens,
60897
+ playbookMilestoneMaxTokens,
60898
+ playbookDefaultMaxTokens
60899
+ );
60900
+ const phaseTemperature = resolveTemperatureForPhase(
60901
+ resumeState?.workflowPhase,
60902
+ cliTemperature,
60903
+ playbookMilestoneTemperature,
60904
+ playbookDefaultTemperature
60905
+ );
60776
60906
  const effectiveModelForContext = phaseModel || options.model || agentConfigModel || defaultConfiguredModel;
60777
60907
  const compactStrategy = resolveCompactStrategyForModel(effectiveModelForContext);
60778
60908
  const contextLimitTokens = resolveContextLimitForModel(effectiveModelForContext);
@@ -60787,6 +60917,8 @@ Saving state... done. Session saved to ${filePath}`);
60787
60917
  maxSessions: remainingSessions - accumulatedSessions,
60788
60918
  maxCost: currentRemainingCost,
60789
60919
  model: phaseModel || options.model,
60920
+ ...phaseMaxTokens !== void 0 ? { maxTokens: phaseMaxTokens } : {},
60921
+ ...phaseTemperature !== void 0 ? { temperature: phaseTemperature } : {},
60790
60922
  abortSignal: turnAbortController.signal,
60791
60923
  reasoning: !options.noReasoning,
60792
60924
  debugMode: options.debug ?? true,
@@ -60958,7 +61090,12 @@ Saving state... done. Session saved to ${filePath}`);
60958
61090
  const newErrorHandling = resolveErrorHandlingForPhase(
60959
61091
  resumeState.workflowPhase,
60960
61092
  options.fallbackModel,
60961
- playbookMilestoneFallbackModels
61093
+ playbookMilestoneFallbackModels,
61094
+ resolveFallbackOnEmptyForPhase(
61095
+ resumeState.workflowPhase,
61096
+ playbookMilestoneFallbackOnEmpty,
61097
+ playbookDefaultFallbackOnEmpty
61098
+ )
60962
61099
  );
60963
61100
  client.agents.update(agentId, {
60964
61101
  config: { errorHandling: newErrorHandling ?? null }
@@ -61468,7 +61605,13 @@ function resolveSandboxWorkflowSelection(message, sandboxProvider, resumeState)
61468
61605
  };
61469
61606
  }
61470
61607
  function applyTaskOptions(cmd) {
61471
- return cmd.argument("<agent>", "Agent ID or name").option("-g, --goal <text>", "Goal message for the agent").option("--max-sessions <n>", "Maximum sessions", "50").option("--max-cost <n>", "Budget in USD").option("--model <modelId>", "Model ID to use (overrides agent config)").option("--name <name>", "Task name (used for state file, defaults to agent name)").option("--session <name>", "Resume a specific session by name").option(
61608
+ return cmd.argument("<agent>", "Agent ID or name").option("-g, --goal <text>", "Goal message for the agent").option("--max-sessions <n>", "Maximum sessions", "50").option("--max-cost <n>", "Budget in USD").option("--model <modelId>", "Model ID to use (overrides agent config)").option(
61609
+ "--max-tokens <n>",
61610
+ "Max output-token budget per session (overrides agent config; playbook milestones can override per phase)"
61611
+ ).option(
61612
+ "--temperature <n>",
61613
+ "Sampling temperature 0-2 per session (overrides agent config; playbook milestones can override per phase)"
61614
+ ).option("--name <name>", "Task name (used for state file, defaults to agent name)").option("--session <name>", "Resume a specific session by name").option(
61472
61615
  "--state-dir <path>",
61473
61616
  "Directory for state files (default: ~/.runtype/projects/<hash>/marathons/)"
61474
61617
  ).option(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runtypelabs/cli",
3
- "version": "2.21.6",
3
+ "version": "2.22.0",
4
4
  "description": "Command-line interface for Runtype AI platform",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -24,7 +24,7 @@
24
24
  "rosie-skills": "0.8.1",
25
25
  "yaml": "^2.9.0",
26
26
  "@runtypelabs/ink-components": "0.3.2",
27
- "@runtypelabs/sdk": "4.18.0",
27
+ "@runtypelabs/sdk": "4.19.0",
28
28
  "@runtypelabs/terminal-animations": "0.2.1"
29
29
  },
30
30
  "devDependencies": {
@@ -39,7 +39,7 @@
39
39
  "tsx": "^4.7.1",
40
40
  "typescript": "^5.3.3",
41
41
  "vitest": "^4.1.0",
42
- "@runtypelabs/shared": "1.33.0"
42
+ "@runtypelabs/shared": "1.33.1"
43
43
  },
44
44
  "engines": {
45
45
  "node": ">=22.0.0"