@parcha/agentrun-kernel 0.1.0-beta.48 → 0.1.0-beta.50

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/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## 0.1.0-beta.49 (2026-11-20)
6
+
7
+ - `GET /v2/runs/{run_id}/usage` (`runusage/1`) says what one run cost, line by line, and whose invoice each part lands on: `tokens` per model (`model`, and `provider` where the server sent the requests itself; null behind a gateway), `tools` per charger (`charged_by`, with calls of unpriced tools in `not_metered_calls`), and `browser_time` per browser provider (`provider`, seconds). Each line has its quantity as measured, its dollars as the run's booking holds them, and its basis (`reported`, `estimate`, `unpriced`). It reads the same for a pi run, a CLI-harness run and a workflow run (its decisions on the model that answered them). The lines join to `total`, the run's `cost.usd`; a charge of unknown cost is null with what is known beside it, never $0. `ended_at` is the end the lines cover: a follow-up can reopen an ended run, and a later read with another `ended_at` says it moved. The console's Dev tools tab shows the lines as "Cost by line". In the kernel, a paid request may say `reported` (it settles at the provider's own figure), written on its `runner.request`. <!-- changes/run-usage-lines.md -->
8
+
5
9
  ## 0.1.0-beta.47 (2026-11-19)
6
10
 
7
11
  - A pi run's model requests that answer at about the same time are each priced at their own cost. When one turn started several `subagent` calls, the child whose answer asked first was given every child's booking and the others $0, so the run page's Timeline and Dev tools tab and `GET /v2/runs/{id}/trace` showed one request at the sum (three requests of the same tokens at $0.02163, $0.01266 and $0.04326, say) and others at $0. Each answer now reads the bookings of its own conversation's requests. The run's cost was right throughout and does not change; a run already recorded keeps the per-request figures it was written with. <!-- changes/parallel-request-costs.md -->
@@ -71,7 +71,8 @@ export interface RunTools {
71
71
  * reserved, not spent; given back on a lost claim, never booked as cut. `ref`: the one booking it names: a ref already
72
72
  * booked (on the run's records, or on this claim) books nothing again, and the answer says `booked`. `under`: the key
73
73
  * of the model session whose tool call it runs in (ModelRequest.paid.under): it is judged beside that session's
74
- * requests in flight and never waits on them, since one of them may be the request that asked for it. */
74
+ * requests in flight and never waits on them, since one of them may be the request that asked for it. `reported`: it is
75
+ * settled at the provider's own figure for the call (ModelRequest.paid.reported). */
75
76
  admit(request: {
76
77
  readonly id: string;
77
78
  readonly name: string;
@@ -85,6 +86,7 @@ export interface RunTools {
85
86
  readonly hold?: true;
86
87
  readonly ref?: string;
87
88
  readonly under?: string;
89
+ readonly reported?: true;
88
90
  }): Promise<Admission & {
89
91
  readonly booked?: true;
90
92
  }>;
@@ -124,7 +124,7 @@ export async function paidCalls(writer, before, options = {}) {
124
124
  const refsOf = () => (refs ??= writer.read().then((records) => new Set(records.filter((r) => r.kind === RUNNER_RECORDS.request).map((r) => r.data?.ref).filter((ref) => typeof ref === "string"))));
125
125
  const book = (request) =>
126
126
  // A hold that is no figure (an unpriced browser provider's) goes to the rule as given, which refuses it for good.
127
- steps.book(request.id, { model: `paid:${request.name}`, inputTokensMax: 0, ...(request.holdUsd !== 0 ? { feeUsd: request.holdUsd } : {}), paid: { name: request.name, basis: request.basis, ...(request.call === undefined ? {} : { call: request.call }), ...(request.chargedBy === undefined ? {} : { charged_by: request.chargedBy }), ...(request.tool === undefined ? {} : { tool: request.tool }), ...(request.tag === undefined ? {} : { tag: request.tag }), ...(request.owed ? { owed: true } : {}), ...(request.hold ? { hold: true } : {}), ...(request.ref === undefined ? {} : { ref: request.ref }), ...(request.under === undefined ? {} : { under: request.under }) } });
127
+ steps.book(request.id, { model: `paid:${request.name}`, inputTokensMax: 0, ...(request.holdUsd !== 0 ? { feeUsd: request.holdUsd } : {}), paid: { name: request.name, basis: request.basis, ...(request.call === undefined ? {} : { call: request.call }), ...(request.chargedBy === undefined ? {} : { charged_by: request.chargedBy }), ...(request.tool === undefined ? {} : { tool: request.tool }), ...(request.tag === undefined ? {} : { tag: request.tag }), ...(request.owed ? { owed: true } : {}), ...(request.hold ? { hold: true } : {}), ...(request.ref === undefined ? {} : { ref: request.ref }), ...(request.under === undefined ? {} : { under: request.under }), ...(request.reported ? { reported: true } : {}) } });
128
128
  return {
129
129
  admit: async (request) => {
130
130
  if (request.ref === undefined)
package/dist/runner.js CHANGED
@@ -336,7 +336,7 @@ function bookingFor(writer, options) {
336
336
  const freeRequest = !!verdict && "freeRequest" in verdict && verdict.freeRequest === true;
337
337
  // A paid tool call (ModelRequest.paid) says so on its record (`paid`), so a later process that books it cut knows its
338
338
  // hold is its fee as admitted, never a bound on what its provider charged (bookCut).
339
- await write([{ kind: RUNNER_RECORDS.request, data: { turn, model, ...(paid ? { paid: true } : {}), ...(hold === undefined ? {} : { heldUsd: hold }), ...(onPlan ? { plan: true } : {}), ...(freeRequest ? { freeRequest: true } : {}), ...(side ? { side } : {}), ...(host === undefined ? {} : { host }), ...(paid?.call === undefined ? {} : { call: paid.call }), ...(paid?.charged_by === undefined ? {} : { charged_by: paid.charged_by }), ...(paid?.tool === undefined ? {} : { tool: paid.tool }), ...(paid?.tag === undefined ? {} : { tag: paid.tag }), ...(paid?.owed ? { owed: true } : {}), ...(paid?.hold ? { hold: true } : {}), ...(paid?.ref === undefined ? {} : { ref: paid.ref }) } }]);
339
+ await write([{ kind: RUNNER_RECORDS.request, data: { turn, model, ...(paid ? { paid: true } : {}), ...(hold === undefined ? {} : { heldUsd: hold }), ...(onPlan ? { plan: true } : {}), ...(freeRequest ? { freeRequest: true } : {}), ...(side ? { side } : {}), ...(host === undefined ? {} : { host }), ...(paid?.call === undefined ? {} : { call: paid.call }), ...(paid?.charged_by === undefined ? {} : { charged_by: paid.charged_by }), ...(paid?.tool === undefined ? {} : { tool: paid.tool }), ...(paid?.tag === undefined ? {} : { tag: paid.tag }), ...(paid?.owed ? { owed: true } : {}), ...(paid?.hold ? { hold: true } : {}), ...(paid?.ref === undefined ? {} : { ref: paid.ref }), ...(paid?.reported ? { reported: true } : {}) } }]);
340
340
  turns = turn;
341
341
  if (host !== undefined)
342
342
  hosts.set(turn, host);
package/dist/types.d.ts CHANGED
@@ -204,7 +204,9 @@ export interface ModelRequest {
204
204
  * `under`: the key of the model session whose tool call it runs in (the CLI's session): a request of that session
205
205
  * still in flight may be the one that asked for the call, unbooked until the call returns (Claude Code books its
206
206
  * cost after its calls, Codex starts a call with its response open), so the call never waits on it (runBooking).
207
- * Not written on its record. */
207
+ * Not written on its record. `reported`: what it is settled at is the provider's own figure for the call (its answer
208
+ * says what it charged), not a price this server set; written on its record, so a read of the booking can say how a
209
+ * charge's figure was reached. */
208
210
  paid?: {
209
211
  name: string;
210
212
  basis: string;
@@ -216,6 +218,7 @@ export interface ModelRequest {
216
218
  hold?: true;
217
219
  ref?: string;
218
220
  under?: string;
221
+ reported?: true;
219
222
  };
220
223
  /** A side call, never its turn's own: on another model than the session's (a client's title, a summary), or the
221
224
  * host's own request beside the harness's (`host`). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcha/agentrun-kernel",
3
- "version": "0.1.0-beta.48",
3
+ "version": "0.1.0-beta.50",
4
4
  "description": "Agent harnesses other than Pi, starting with Codex, behind one seam: a DSL node's runNode and an AgentRun run on a harness adapter, durable in AgentRun's own store.",
5
5
  "keywords": [
6
6
  "agentrun",
@@ -62,7 +62,7 @@
62
62
  "test": "node --test --test-concurrency=8 'test/*.test.mjs'"
63
63
  },
64
64
  "dependencies": {
65
- "@parcha/agentrun-dsl": "0.1.0-beta.48",
65
+ "@parcha/agentrun-dsl": "0.1.0-beta.50",
66
66
  "ajv": "8.18.0",
67
67
  "typebox": "1.3.27"
68
68
  },