@drisp/cli 0.7.8 → 0.7.9

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.
@@ -8,7 +8,7 @@ import {
8
8
  installWorkflowPlugins,
9
9
  resolveWorkflow,
10
10
  writeGlobalConfig
11
- } from "./chunk-OYUBT6RS.js";
11
+ } from "./chunk-FYXEDUQ6.js";
12
12
  import "./chunk-G3PMV62Z.js";
13
13
 
14
14
  // src/setup/steps/WorkflowInstallWizard.tsx
@@ -93,4 +93,4 @@ function WorkflowInstallWizard({ source, onDone }) {
93
93
  export {
94
94
  WorkflowInstallWizard as default
95
95
  };
96
- //# sourceMappingURL=WorkflowInstallWizard-IOJD3YOA.js.map
96
+ //# sourceMappingURL=WorkflowInstallWizard-FKASDA6N.js.map
@@ -22447,6 +22447,15 @@ function budgetTokens(memory) {
22447
22447
  if (memory.cumulativeTokens === null) return null;
22448
22448
  return Math.max(0, memory.cumulativeTokens - (memory.usage?.cacheRead ?? 0));
22449
22449
  }
22450
+ function runUsage(memory) {
22451
+ const counted = budgetTokens(memory);
22452
+ if (counted === null) return null;
22453
+ const whole = (tokens) => Number.isFinite(tokens) ? Math.min(Math.max(0, Math.round(tokens)), Number.MAX_SAFE_INTEGER) : 0;
22454
+ return {
22455
+ counted: whole(counted),
22456
+ cacheRead: whole(memory.usage?.cacheRead ?? 0)
22457
+ };
22458
+ }
22450
22459
  function resourceInterruption(stop) {
22451
22460
  const names2 = {
22452
22461
  tokens: "token budget",
@@ -24308,6 +24317,7 @@ export {
24308
24317
  WAITING_ON_CHILDREN_STOP_REASON,
24309
24318
  AWAITING_APPROVAL_STOP_REASON,
24310
24319
  budgetTokens,
24320
+ runUsage,
24311
24321
  createSteerQueue,
24312
24322
  DEFAULT_PERMISSION_GRACE_MS,
24313
24323
  serializeRunMemory,
@@ -24374,4 +24384,4 @@ export {
24374
24384
  compileWorkflowPlan,
24375
24385
  collectMcpServersWithOptions
24376
24386
  };
24377
- //# sourceMappingURL=chunk-OYUBT6RS.js.map
24387
+ //# sourceMappingURL=chunk-FYXEDUQ6.js.map
@@ -48,6 +48,7 @@ import {
48
48
  resolveWorkflow,
49
49
  resolveWorkflowManifestPath,
50
50
  resolveWorkflowPlugins,
51
+ runUsage,
51
52
  selectWorkflowCapabilities,
52
53
  serializeRunMemory,
53
54
  sizeClassLimits,
@@ -55,7 +56,7 @@ import {
55
56
  verifyRendered,
56
57
  wakesFreshAfterHandover,
57
58
  workflowRegistryDir
58
- } from "./chunk-OYUBT6RS.js";
59
+ } from "./chunk-FYXEDUQ6.js";
59
60
  import {
60
61
  __commonJS,
61
62
  __toESM
@@ -13087,12 +13088,13 @@ function forecastOfCap(declaredCap) {
13087
13088
  }
13088
13089
 
13089
13090
  // ../../packages/protocol/src/v2.ts
13090
- var protocolVersion = { major: 2, minor: 2 };
13091
+ var protocolVersion = { major: 2, minor: 3 };
13091
13092
  var conversationContinuationCapability = "conversation_continuation";
13092
13093
  var abandonedConversationContinuationCapability = "abandoned_conversation_continuation";
13093
13094
  var repositoryAccessCapability = "repository_checkout_v1";
13094
13095
  var workflowInstallCapability = "workflow_install_v1";
13095
13096
  var runDelegationCapability = "run_delegation_v1";
13097
+ var runUsageCapability = "run_usage_v1";
13096
13098
  var runArtifactNameSchema = external_exports.string().regex(/^[a-z][a-z0-9_]{0,63}$/);
13097
13099
  var runArtifactMaxBytes = 64 * 1024;
13098
13100
  var secretEnvironmentSchema = external_exports.record(
@@ -13160,6 +13162,8 @@ var factIdentity = {
13160
13162
  executionRevision: positive,
13161
13163
  emittedAt: timestamp
13162
13164
  };
13165
+ var runUsageSchema = external_exports.strictObject({ counted: sequence, cacheRead: sequence });
13166
+ var reportedUsage = { usage: runUsageSchema.optional() };
13163
13167
  var controlRecordSchema = external_exports.discriminatedUnion("kind", [
13164
13168
  /** Instance-scoped, not tied to a Run: the full replacement inventory of installed Workflows. */
13165
13169
  external_exports.strictObject({ kind: external_exports.literal("workflows.changed"), workflows: installedWorkflowsSchema }),
@@ -13190,7 +13194,8 @@ var controlRecordSchema = external_exports.discriminatedUnion("kind", [
13190
13194
  external_exports.strictObject({ kind: external_exports.literal("local_checkpoint"), checkpointId: id }),
13191
13195
  external_exports.strictObject({ kind: external_exports.literal("portable_checkpoint"), checkpointId: id }),
13192
13196
  external_exports.strictObject({ kind: external_exports.literal("repair_required"), detail: external_exports.string().max(4096) })
13193
- ])
13197
+ ]),
13198
+ ...reportedUsage
13194
13199
  }),
13195
13200
  external_exports.strictObject({
13196
13201
  kind: external_exports.literal("run.finished"),
@@ -13203,8 +13208,14 @@ var controlRecordSchema = external_exports.discriminatedUnion("kind", [
13203
13208
  * Why a Build Run failed, as its close reason (docs/specs/build-orchestrator.md). Sent only for a grant with
13204
13209
  * `parent` or `delegationToken`, which only a Hub that knows this field issues.
13205
13210
  */
13206
- reason: buildCloseReasonSchema.optional()
13211
+ reason: buildCloseReasonSchema.optional(),
13212
+ ...reportedUsage
13207
13213
  }),
13214
+ /**
13215
+ * The usage of a Run while it executes, for a grant marked `reportUsage`. Not an execution fact: it carries no
13216
+ * execution revision, so it never advances, parks or closes the Run, and never wakes its parent.
13217
+ */
13218
+ external_exports.strictObject({ kind: external_exports.literal("run.usage"), runId: id, attemptId: id, ...runUsageSchema.shape }),
13208
13219
  external_exports.strictObject({ kind: external_exports.literal("command.applied"), runId: id, attemptId: id, commandId: id }),
13209
13220
  external_exports.strictObject({
13210
13221
  kind: external_exports.literal("command.rejected"),
@@ -13343,7 +13354,9 @@ var grantSchema = external_exports.strictObject({
13343
13354
  /** This attempt's delegation token: only for a Run started with `delegation`, only to a `run_delegation_v1` Runner. */
13344
13355
  delegationToken: external_exports.string().min(32).max(256).optional(),
13345
13356
  /** Copied from the start intent of a delegated child. */
13346
- parent: runParentSchema.optional()
13357
+ parent: runParentSchema.optional(),
13358
+ /** The runner reports this attempt's usage: set only for a `run_usage_v1` Runner. */
13359
+ reportUsage: external_exports.literal(true).optional()
13347
13360
  });
13348
13361
  var historyRecordSchema = external_exports.strictObject({
13349
13362
  eventId: id,
@@ -13404,7 +13417,13 @@ var runViewSchema = external_exports.object({
13404
13417
  label: external_exports.string().max(160).optional(),
13405
13418
  key: runKeySchema.optional(),
13406
13419
  parent: runParentSchema.optional(),
13407
- delegation: delegationSchema.optional(),
13420
+ /**
13421
+ * Not strict, unlike the start intent's: a Hub keeps more on the Run's delegation (`initialTokenBudget`) than it
13422
+ * shows, and a client never refuses a view for a field it does not read.
13423
+ */
13424
+ delegation: external_exports.object(delegationSchema.shape).optional(),
13425
+ /** The largest cumulative usage the Run's Runner reported; absent until one does (an older Runner never does). */
13426
+ usage: runUsageSchema.optional(),
13408
13427
  /** Resolved by the runner at start; absent until the Run starts and for runners that predate reporting. */
13409
13428
  workflow: workflowIdentitySchema.optional(),
13410
13429
  execution: external_exports.object({
@@ -14529,6 +14548,7 @@ var ExecutionHost = class {
14529
14548
  const outcome = await this.executor.execute(run.grant, this.store, abort.signal);
14530
14549
  if (publish && !abort.signal.aborted && ["completed", "awaiting_attention"].includes(outcome.status))
14531
14550
  await publish(run.grant, abort.signal);
14551
+ const usage = outcome.usage && run.grant.reportUsage ? { usage: outcome.usage } : {};
14532
14552
  this.store.transaction(() => {
14533
14553
  this.store.fact(runId, (identity) => {
14534
14554
  if (outcome.status === "awaiting_attention")
@@ -14547,7 +14567,8 @@ var ExecutionHost = class {
14547
14567
  continuation: {
14548
14568
  kind: this.portableCheckpoints ? "portable_checkpoint" : "local_checkpoint",
14549
14569
  checkpointId: crypto.randomUUID()
14550
- }
14570
+ },
14571
+ ...usage
14551
14572
  };
14552
14573
  return {
14553
14574
  ...identity,
@@ -14559,7 +14580,8 @@ var ExecutionHost = class {
14559
14580
  // resend it forever. Portable checkpoints are configured only on managed Runners.
14560
14581
  ...outcome.workspaceMissing && this.portableCheckpoints && run.grant.spec.repository ? { workspaceUnavailable: true } : {},
14561
14582
  // Only a Hub that issues `parent` or a delegation token knows the field; an older one rejects it.
14562
- ...outcome.reason && (run.grant.parent || run.grant.delegationToken) ? { reason: outcome.reason } : {}
14583
+ ...outcome.reason && (run.grant.parent || run.grant.delegationToken) ? { reason: outcome.reason } : {},
14584
+ ...usage
14563
14585
  };
14564
14586
  });
14565
14587
  if (this.portableCheckpoints && outcome.status !== "awaiting_attention" && !outcome.workspaceMissing)
@@ -14893,9 +14915,18 @@ async function restoreCheckpoint(store, input) {
14893
14915
 
14894
14916
  // ../../modules/runtime/src/software-version.ts
14895
14917
  import "fs";
14896
- var runnerSoftwareVersion = true ? "0.7.8" : JSON.parse(readFileSync2(new URL("../../../apps/cli/package.json", import.meta.url), "utf8")).version;
14918
+ var runnerSoftwareVersion = true ? "0.7.9" : JSON.parse(readFileSync2(new URL("../../../apps/cli/package.json", import.meta.url), "utf8")).version;
14897
14919
 
14898
14920
  // ../../modules/runtime/src/connection.ts
14921
+ var runnerCapabilities = [
14922
+ "local_checkpoint",
14923
+ conversationContinuationCapability,
14924
+ abandonedConversationContinuationCapability,
14925
+ repositoryAccessCapability,
14926
+ workflowInstallCapability,
14927
+ runDelegationCapability,
14928
+ runUsageCapability
14929
+ ];
14899
14930
  var RunnerDisconnectedError = class extends Error {
14900
14931
  constructor() {
14901
14932
  super("runner_disconnected");
@@ -15032,7 +15063,7 @@ var RunnerConnection = class {
15032
15063
  runnerId: store.identity.runnerId,
15033
15064
  installationId: store.identity.installationId,
15034
15065
  softwareVersion: runnerSoftwareVersion,
15035
- capabilities: ["local_checkpoint", conversationContinuationCapability, abandonedConversationContinuationCapability, repositoryAccessCapability, workflowInstallCapability, runDelegationCapability],
15066
+ capabilities: [...runnerCapabilities],
15036
15067
  ...this.options.workflows ? { workflows: this.options.workflows.current() } : {},
15037
15068
  ...this.options.readiness?.current() ? { readiness: this.options.readiness.current() } : {},
15038
15069
  control: {
@@ -21361,6 +21392,25 @@ function runArtifactEmitter(directory, record, midTurnMinGapMs = MID_TURN_MIN_GA
21361
21392
  // ../../modules/runtime/src/run-usage.ts
21362
21393
  import { readFileSync as readFileSync5, renameSync, writeFileSync as writeFileSync4 } from "fs";
21363
21394
  import { join as join8 } from "path";
21395
+ var LIVE_USAGE_MIN_TOKENS = 1e5;
21396
+ var LIVE_USAGE_MIN_INTERVAL_MS = 3e4;
21397
+ function liveUsageReporter(grant, store, read3, now = Date.now) {
21398
+ if (!grant.reportUsage) return () => {
21399
+ };
21400
+ let last = { counted: read3()?.counted ?? 0, at: now() };
21401
+ return () => {
21402
+ const usage = read3();
21403
+ const at = now();
21404
+ if (!usage || usage.counted - last.counted < LIVE_USAGE_MIN_TOKENS || at - last.at < LIVE_USAGE_MIN_INTERVAL_MS)
21405
+ return;
21406
+ const sent = store.transaction(() => {
21407
+ if (store.run(grant.runId).phase !== "executing") return false;
21408
+ store.appendControl({ kind: "run.usage", runId: grant.runId, attemptId: grant.attemptId, ...usage });
21409
+ return true;
21410
+ });
21411
+ if (sent) last = { counted: usage.counted, at };
21412
+ };
21413
+ }
21364
21414
  var isMark = (value) => {
21365
21415
  const mark = value;
21366
21416
  return !!mark && Number.isInteger(mark.index) && typeof mark.title === "string" && typeof mark.tokens === "number" && Number.isFinite(mark.tokens) && mark.tokens >= 0;
@@ -21567,6 +21617,11 @@ function createWorkflowExecutor(dependencies = {}) {
21567
21617
  }
21568
21618
  emitArtifacts(midTurn);
21569
21619
  };
21620
+ const usage2 = () => {
21621
+ const memory = deserializeRunMemory(view2.getLatestRun()?.runMemoryJson);
21622
+ return memory ? runUsage(memory) : null;
21623
+ };
21624
+ const reportLiveUsage2 = liveUsageReporter(grant, store, usage2, dependencies.now);
21570
21625
  const previous = view2.getLatestRun();
21571
21626
  const predecessor = grant.previousRun ? store.sessionValues(grant.sessionId, "workflow").find((snapshot) => snapshot.id === grant.previousRun.runId) : void 0;
21572
21627
  const adapterResumeSessionId2 = grant.purpose === "resume" ? previous?.adapterSessionId : predecessor?.adapterSessionId;
@@ -21610,7 +21665,18 @@ ${JSON.stringify(continuation.answer)}` : grant.spec.prompt;
21610
21665
  Current human request:
21611
21666
  ${prompt2}`;
21612
21667
  }
21613
- return { workingDirectory: workingDirectory2, config: config2, view: view2, adapterResumeSessionId: adapterResumeSessionId2, storedAnswer: storedAnswer2, prompt: prompt2, displayText: displayText2, sweepArtifacts: sweepArtifacts2 };
21668
+ return {
21669
+ workingDirectory: workingDirectory2,
21670
+ config: config2,
21671
+ view: view2,
21672
+ adapterResumeSessionId: adapterResumeSessionId2,
21673
+ storedAnswer: storedAnswer2,
21674
+ prompt: prompt2,
21675
+ displayText: displayText2,
21676
+ sweepArtifacts: sweepArtifacts2,
21677
+ usage: usage2,
21678
+ reportLiveUsage: reportLiveUsage2
21679
+ };
21614
21680
  };
21615
21681
  let setup2;
21616
21682
  try {
@@ -21622,7 +21688,18 @@ ${prompt2}`;
21622
21688
  if (error instanceof RunSetupError && isBuildCloseReason(error.code)) return { status: "failed", reason: error.code };
21623
21689
  return { status: "failed" };
21624
21690
  }
21625
- const { workingDirectory, config, view, adapterResumeSessionId, storedAnswer, prompt, displayText, sweepArtifacts } = setup2;
21691
+ const {
21692
+ workingDirectory,
21693
+ config,
21694
+ view,
21695
+ adapterResumeSessionId,
21696
+ storedAnswer,
21697
+ prompt,
21698
+ displayText,
21699
+ sweepArtifacts,
21700
+ usage,
21701
+ reportLiveUsage
21702
+ } = setup2;
21626
21703
  const queue = createSteerQueue();
21627
21704
  queues.set(grant.runId, queue);
21628
21705
  const sweep = setInterval(() => {
@@ -21630,6 +21707,10 @@ ${prompt2}`;
21630
21707
  sweepArtifacts(true);
21631
21708
  } catch {
21632
21709
  }
21710
+ try {
21711
+ reportLiveUsage();
21712
+ } catch {
21713
+ }
21633
21714
  }, dependencies.artifactIntervalMs ?? 2e3);
21634
21715
  sweep.unref();
21635
21716
  const result = await trackHarnessProcesses(store, grant.runId, () => (dependencies.execute ?? runExec)({
@@ -21697,8 +21778,10 @@ ${prompt2}`;
21697
21778
  runMemoryJson: serializeRunMemory({ ...memory, pendingSteers })
21698
21779
  });
21699
21780
  });
21781
+ const reported = usage();
21782
+ const withUsage = (outcome) => reported ? { ...outcome, usage: reported } : outcome;
21700
21783
  if (status === "awaiting_attention" && !result.workflowOutcome.interruption && result.workflowOutcome.stopReason === WAITING_ON_CHILDREN_STOP_REASON)
21701
- return { status, interruption: { kind: "waiting", message: WAITING_ON_CHILDREN_MESSAGE } };
21784
+ return withUsage({ status, interruption: { kind: "waiting", message: WAITING_ON_CHILDREN_MESSAGE } });
21702
21785
  if (status === "awaiting_attention" && !result.workflowOutcome.interruption && result.workflowOutcome.stopReason === AWAITING_APPROVAL_STOP_REASON) {
21703
21786
  const question = config.workflow?.approvalQuestion;
21704
21787
  if (!question) {
@@ -21706,13 +21789,13 @@ ${prompt2}`;
21706
21789
  code: "approval_question_missing",
21707
21790
  message: "The Journal ended with AWAITING_APPROVAL, but the Workflow has no approvalQuestion."
21708
21791
  });
21709
- return { status: "failed", reason: "approval_question_missing" };
21792
+ return withUsage({ status: "failed", reason: "approval_question_missing" });
21710
21793
  }
21711
21794
  record(APPROVAL_REQUESTED, { question, plan: emittedPlan(store, grant.runId) });
21712
- return { status, interruption: { kind: "question", message: question } };
21795
+ return withUsage({ status, interruption: { kind: "question", message: question } });
21713
21796
  }
21714
21797
  const interruption = status === "awaiting_attention" ? result.workflowOutcome.interruption ?? interruptionFromSuspension(result.workflowOutcome.stopReason) : void 0;
21715
- return {
21798
+ return withUsage({
21716
21799
  status,
21717
21800
  ...interruption ? {
21718
21801
  interruption: {
@@ -21724,7 +21807,7 @@ ${prompt2}`;
21724
21807
  ...interruption.kind === "question" && interruption.requestId ? { requestId: interruption.requestId } : {}
21725
21808
  }
21726
21809
  } : {}
21727
- };
21810
+ });
21728
21811
  }
21729
21812
  };
21730
21813
  }
@@ -22121,4 +22204,4 @@ export {
22121
22204
  runMachineRunners,
22122
22205
  writeIdentityOnce
22123
22206
  };
22124
- //# sourceMappingURL=chunk-HGMJ3YL2.js.map
22207
+ //# sourceMappingURL=chunk-TWOJJ2JD.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runMachineRunners
3
- } from "./chunk-HGMJ3YL2.js";
3
+ } from "./chunk-TWOJJ2JD.js";
4
4
 
5
5
  // src/app/entry/runnerDaemon.ts
6
6
  if (process.argv.includes("--help")) {
@@ -13,4 +13,4 @@ if (process.argv.includes("--help")) {
13
13
  process.exitCode = 1;
14
14
  });
15
15
  }
16
- //# sourceMappingURL=chunk-TBUUNMC6.js.map
16
+ //# sourceMappingURL=chunk-Z5KVWWZU.js.map
package/dist/cli.js CHANGED
@@ -142,7 +142,7 @@ import {
142
142
  visualPositionToOffset,
143
143
  wrapText,
144
144
  writeIdentityOnce
145
- } from "./chunk-HGMJ3YL2.js";
145
+ } from "./chunk-TWOJJ2JD.js";
146
146
  import {
147
147
  generateId as generateId2
148
148
  } from "./chunk-PQIB66SG.js";
@@ -201,7 +201,7 @@ import {
201
201
  workflowRegistryDir,
202
202
  writeGlobalConfig,
203
203
  writeProjectConfig
204
- } from "./chunk-OYUBT6RS.js";
204
+ } from "./chunk-FYXEDUQ6.js";
205
205
  import {
206
206
  __toESM
207
207
  } from "./chunk-G3PMV62Z.js";
@@ -16323,7 +16323,7 @@ Available commands: ${[...KNOWN_COMMANDS].join(", ")}`
16323
16323
  await exitWith(1);
16324
16324
  return;
16325
16325
  }
16326
- const { default: WorkflowInstallWizard } = await import("./WorkflowInstallWizard-IOJD3YOA.js");
16326
+ const { default: WorkflowInstallWizard } = await import("./WorkflowInstallWizard-FKASDA6N.js");
16327
16327
  const { waitUntilExit } = render(
16328
16328
  /* @__PURE__ */ jsx24(
16329
16329
  WorkflowInstallWizard,
@@ -1,6 +1,6 @@
1
- import "./chunk-TBUUNMC6.js";
2
- import "./chunk-HGMJ3YL2.js";
1
+ import "./chunk-Z5KVWWZU.js";
2
+ import "./chunk-TWOJJ2JD.js";
3
3
  import "./chunk-PQIB66SG.js";
4
- import "./chunk-OYUBT6RS.js";
4
+ import "./chunk-FYXEDUQ6.js";
5
5
  import "./chunk-G3PMV62Z.js";
6
6
  //# sourceMappingURL=dashboard-daemon.js.map
package/dist/runner.js CHANGED
@@ -1,6 +1,6 @@
1
- import "./chunk-TBUUNMC6.js";
2
- import "./chunk-HGMJ3YL2.js";
1
+ import "./chunk-Z5KVWWZU.js";
2
+ import "./chunk-TWOJJ2JD.js";
3
3
  import "./chunk-PQIB66SG.js";
4
- import "./chunk-OYUBT6RS.js";
4
+ import "./chunk-FYXEDUQ6.js";
5
5
  import "./chunk-G3PMV62Z.js";
6
6
  //# sourceMappingURL=runner.js.map
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "hooks",
18
18
  "dashboard"
19
19
  ],
20
- "version": "0.7.8",
20
+ "version": "0.7.9",
21
21
  "license": "MIT",
22
22
  "bin": {
23
23
  "athena": "dist/cli.js",