@parcha/agentrun-kernel 0.1.0-beta.33 → 0.1.0-beta.35

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 (41) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/host/index.d.ts +4 -4
  3. package/dist/host/index.js +3 -3
  4. package/dist/host/overhead.d.ts +75 -4
  5. package/dist/host/overhead.js +220 -10
  6. package/dist/host/pinned-binary.d.ts +27 -2
  7. package/dist/host/pinned-binary.js +97 -8
  8. package/dist/host/proxy.d.ts +40 -4
  9. package/dist/host/proxy.js +73 -2
  10. package/dist/index.d.ts +2 -2
  11. package/dist/index.js +2 -2
  12. package/dist/kernel/cap/index.d.ts +2 -2
  13. package/dist/kernel/cap/index.js +2 -2
  14. package/dist/kernel/cap/park.js +4 -2
  15. package/dist/kernel/cap/port.d.ts +3 -2
  16. package/dist/kernel/cap/port.js +7 -2
  17. package/dist/kernel/cap/price.js +5 -2
  18. package/dist/kernel/cap/run-cap.d.ts +21 -5
  19. package/dist/kernel/cap/run-cap.js +42 -4
  20. package/dist/kernel/cap/types.d.ts +7 -0
  21. package/dist/kernel/cap/words.d.ts +9 -0
  22. package/dist/kernel/cap/words.js +16 -1
  23. package/dist/kernel/registry/defs.d.ts +3 -6
  24. package/dist/kernel/registry/defs.js +6 -11
  25. package/dist/kernel/registry/hands.d.ts +3 -22
  26. package/dist/kernel/registry/index.d.ts +1 -3
  27. package/dist/kernel/registry/index.js +3 -3
  28. package/dist/kernel/registry/registry.d.ts +2 -5
  29. package/dist/kernel/registry/registry.js +8 -10
  30. package/dist/process/tools.d.ts +9 -0
  31. package/dist/process/tools.js +19 -6
  32. package/dist/run-booking.js +4 -1
  33. package/dist/runner.d.ts +27 -1
  34. package/dist/runner.js +55 -8
  35. package/dist/testing.d.ts +9 -2
  36. package/dist/testing.js +63 -18
  37. package/dist/types.d.ts +32 -3
  38. package/dist/types.js +2 -0
  39. package/package.json +3 -3
  40. package/dist/kernel/registry/browser.d.ts +0 -11
  41. package/dist/kernel/registry/browser.js +0 -14
package/dist/types.d.ts CHANGED
@@ -145,6 +145,8 @@ export interface ModelRequest {
145
145
  /** The most input tokens the request can be billed for (the model proxy's `inputTokensMaxOf`: the body's UTF-8 bytes
146
146
  * plus what the provider adds), undefined when it was not measured. */
147
147
  inputTokensMax?: number;
148
+ /** Its `inputTokensMax` is its provider's count, not its bytes (ProxyRequest.inputTokensCounted). */
149
+ inputTokensCounted?: true;
148
150
  /** The most output tokens the request asks for, when its body says (the proxy's policy reads it). */
149
151
  outputTokensAsked?: number;
150
152
  /** The least output it may be limited to and still answer: its answer's 1,024 tokens, plus the least thinking its
@@ -155,12 +157,23 @@ export interface ModelRequest {
155
157
  /** A paid tool call, no model request (a web search's request, a monid call): held at `feeUsd` alone by the cap's tool
156
158
  * rule, `name` and `basis` in a refusal's words. `call`: the tool call it was booked under, written on its
157
159
  * runner.request so the run view puts its charge under that call. `charged_by`: who charges for it (the tool's
158
- * provider: parallel, monid, an MCP server, a browser vendor), written there too, as main's charge row names it. */
160
+ * provider: parallel, monid, an MCP server, a browser vendor), written there too, as main's charge row names it.
161
+ * `tool` and `tag`: the tool whose charge it is (a browser's, "browser") and its session, written there for the run
162
+ * view to place it as main's charge of that tool. `owed`: money its provider is already owed (a browser session's
163
+ * release, the time a person used): held at `feeUsd` and booked, never asked of the cap's rule, so a run past its cap
164
+ * or of unknown spend still counts it (main keeps it so: keepHold). `hold`: a hold-only step: money reserved, not
165
+ * spent; given back on a lost claim, never booked as cut (its holder's charges book the money, each its own step).
166
+ * `ref`: the one booking it names (a browser charge's session and time): a second admit of the same ref is not booked. */
159
167
  paid?: {
160
168
  name: string;
161
169
  basis: string;
162
170
  call?: string;
163
171
  charged_by?: string;
172
+ tool?: string;
173
+ tag?: string;
174
+ owed?: true;
175
+ hold?: true;
176
+ ref?: string;
164
177
  };
165
178
  /** A side call, never its turn's own: on another model than the session's (a client's title, a summary), or the
166
179
  * host's own request beside the harness's (`host`). */
@@ -173,6 +186,10 @@ export interface ModelRequest {
173
186
  * the proxy minted for this label: ModelProxy.sideKey): a learned workflow's model node, say. The harness's own
174
187
  * requests carry none, and it cannot send one that does: it holds only the session's key. */
175
188
  host?: string;
189
+ /** Which of the session's routes it came by, when the session has more than one (ModelProxyOptions.route: a proxy beside
190
+ * the session's, for a model of another tier): the host prices it by its model and this route, so one model id two
191
+ * routes price apart is held at the price its route books it at. Absent: the session's own route. */
192
+ route?: string;
176
193
  }
177
194
  /** What a paid request cost, once it completed. */
178
195
  export interface ModelUsage {
@@ -259,12 +276,22 @@ export interface SessionIO {
259
276
  * runs nothing; a park holds the call, writing nothing, until the session's signal is aborted (the run parks on a
260
277
  * person). Absent: every call runs. */
261
278
  gate?(call: GateCall, context?: unknown): Promise<GateAnswer>;
279
+ /** A tool the adapter adds of its own (read_skill_file over the session's skills), made the host's: its calls go the
280
+ * way the host's own tools' do (the run's record of the call and its result, which its Timeline shows, the rule before
281
+ * a side effect, the host's hooks on the result). An adapter hands every tool it adds through it. Absent: the host
282
+ * keeps no record of calls, and the tool runs as it is. */
283
+ hostTool?(tool: HostTool): HostTool;
262
284
  }
285
+ /** `tool`, a tool the adapter adds of its own, made the host's (SessionIO.hostTool). */
286
+ export declare const hostedTool: (io: Pick<SessionIO, "hostTool">, tool: HostTool) => HostTool;
263
287
  /** A call as the host's gate is asked about it. */
264
288
  export interface GateCall {
265
289
  readonly callId: string;
266
290
  readonly tool: string;
267
291
  readonly args: Record<string, unknown>;
292
+ /** The call runs again after an earlier attempt whose start the log holds (a replay-safe call a crash cut): that
293
+ * attempt may have been sent, so a refusal never says nothing was. */
294
+ readonly replayed?: true;
268
295
  }
269
296
  /** The host's answer before a call's intent: run it, refuse it in these words, or park the run on it. */
270
297
  export type GateAnswer = "allow" | {
@@ -375,8 +402,10 @@ export interface AdapterSession {
375
402
  /** The session's own model route, for a request the host sends beside the harness's own (a learned workflow's model
376
403
  * node): its model proxy's address with a side key minted for `label` (ModelProxy.sideKey), the model its policy
377
404
  * takes and the API it speaks. Undefined while no proxy is up (no turn has attached one yet). Every model request of
378
- * a session goes through that one proxy: the same policy, origin, credential, price and booking. */
379
- port?(label: string): SessionPort | undefined;
405
+ * a session goes through that one proxy: the same policy, origin, credential, price and booking. `tier`: the run's
406
+ * model of that tier instead (a learned workflow's node of a tier), on a proxy of its own beside the session's, with
407
+ * that model's origin, credential and price and the session's booking; undefined when the session has none for it. */
408
+ port?(label: string, tier?: string): SessionPort | undefined;
380
409
  }
381
410
  /** The API a harness's model proxy speaks: what its provider, its keys and its catalog follow from. */
382
411
  export type Wire = "anthropic-messages" | "openai-responses";
package/dist/types.js CHANGED
@@ -15,3 +15,5 @@ export const HOST_RESULT_MAX_CHARS = 120_000;
15
15
  * answer again. A host reads a run's end by it (agentrun-serve's `moderated`).
16
16
  */
17
17
  export const CONTENT_FILTERED = "content_filter: the model provider stopped this answer";
18
+ /** `tool`, a tool the adapter adds of its own, made the host's (SessionIO.hostTool). */
19
+ export const hostedTool = (io, tool) => (io.hostTool ? io.hostTool(tool) : tool);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcha/agentrun-kernel",
3
- "version": "0.1.0-beta.33",
3
+ "version": "0.1.0-beta.35",
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",
@@ -13,7 +13,7 @@
13
13
  "license": "Apache-2.0",
14
14
  "author": "Parcha Labs, Inc.",
15
15
  "engines": {
16
- "node": ">=24.11.0"
16
+ "node": ">=24.22.3"
17
17
  },
18
18
  "main": "./dist/index.js",
19
19
  "types": "./dist/index.d.ts",
@@ -60,7 +60,7 @@
60
60
  "test": "node --test --test-concurrency=8 'test/*.test.mjs'"
61
61
  },
62
62
  "dependencies": {
63
- "@parcha/agentrun-dsl": "0.1.0-beta.33",
63
+ "@parcha/agentrun-dsl": "0.1.0-beta.35",
64
64
  "ajv": "8.18.0",
65
65
  "typebox": "1.3.27"
66
66
  },
@@ -1,11 +0,0 @@
1
- import type { ToolDef } from "./defs.js";
2
- /** A browser tool's contract, as pi-browser's ToolContract gives what the registry reads of it. */
3
- export type BrowserContract = {
4
- readonly name: string;
5
- readonly description: string;
6
- readonly parameters: object;
7
- /** After a crash a `safe` call runs again; an `unsafe` one is reported interrupted. */
8
- readonly replay: "safe" | "unsafe";
9
- };
10
- /** The browser kind's definitions: the host's contracts, as given, held to the setting browser. */
11
- export declare function browserToolDefs(contracts: readonly BrowserContract[] | undefined): readonly ToolDef[];
@@ -1,14 +0,0 @@
1
- /** The browser kind's definitions: the host's contracts, as given, held to the setting browser. */
2
- export function browserToolDefs(contracts) {
3
- if (contracts === undefined)
4
- throw new Error("the browser's definitions are pi-browser's BROWSER_TOOLS, which the host passes as browserTools: the kernel holds no copy");
5
- return contracts.map((contract) => ({
6
- name: contract.name,
7
- source: "host",
8
- gateName: `host:browser/${contract.name}`,
9
- settingsKey: "browser",
10
- description: contract.description,
11
- parameters: contract.parameters,
12
- replaySafe: contract.replay === "safe",
13
- }));
14
- }