@parcha/agentrun-kernel 0.1.0-beta.40 → 0.1.0-beta.42

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,19 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## 0.1.0-beta.41 (2026-11-16)
6
+
7
+ - A message sent to a working `claude-agent` run now steers it mid-turn. Before, it waited for the turn's end, and a run whose whole job is one turn read it only after the work was done. The model now reads it at its next step, after the tool calls in flight finish, in the same turn. `POST /v2/runs/{id}/messages` answers mode `steer` for a working claude-agent run (it answered `follow_up`), and `GET /v2/capabilities` lists `claude-agent` with `steer: true`.
8
+ - The Timeline shows the message where the model read it: after the tool call it was sent during, never where it waited in the queue. Its command row is taken in that commit.
9
+ - A message sent as the turn ends starts the next turn, and the run ends only after that turn.
10
+ - A runner lost after it placed the message, before the model took it, neither loses it nor sends it twice. The next runner places nothing again, its resumed turn carries the message if the CLI never had it, and the message is on the Timeline once.
11
+ - A trigger's message that answers nothing (`answers: false`), and the answer to a question the run's last turn ended on, still run as turns of their own, as before.
12
+ - Adapters: `AdapterEvent` gains `message_taken` (`ids`): the submissions the model was given, for a host that keeps the run's record itself. `@parcha/agentrun-harness-claude`'s session implements `steer()`, places nothing again for an id it already holds, and says `message_taken`.
13
+ - Model requests AgentRun sends to OpenRouter carry OpenRouter's app attribution headers: `HTTP-Referer: https://github.com/Parcha-ai/agentrun`, `X-OpenRouter-Title: AgentRun` and `X-OpenRouter-Categories: cloud-agent,personal-agent`. Usage then counts toward AgentRun's page on OpenRouter (openrouter.ai/apps?url=https://github.com/Parcha-ai/agentrun), including a self-hosted server's usage on its owner's own key. Set `AGENTRUN_OPENROUTER_ATTRIBUTION=off` where AgentRun starts to send none.
14
+ - The headers go only where a request goes to openrouter.ai itself, which covers every harness: the model proxy (claude-agent, codex, opencode, and pi on OpenRouter's Anthropic and OpenAI models), pi's translation route (every other OpenRouter model, the free ones included), and the server's Decisions providers on OpenRouter (OpenRouter's models, and Parallel's through OpenRouter). Anthropic, OpenAI, a ChatGPT plan and a gateway at another URL never get them.
15
+ - The kernel's host entry (`OPENROUTER_APP`, `openRouterApp`, `openRouterAttribution`) is the one place that names the app; the server hands it to the Decisions provider.
16
+ - The Decisions provider's `app` option takes `categories` and sends `title` as `X-OpenRouter-Title` (OpenRouter's current name for `X-Title`).
17
+
5
18
  ## 0.1.0-beta.39 (2026-11-16)
6
19
 
7
20
  - Near its cap, a run's parallel steps wait for each other instead of parking: a model request, a decision or a paid tool call (a web fetch, a search, a monid call, codemode's among them) that does not fit only because steps still running hold the room it needs waits for them to settle, and is sent once its room is back. It is refused only when what the run has spent and its own least need do not fit with nothing else running. The cap is never passed: every step is admitted by the same rule over the holds as they are then. Eight subagents started at once under a $0.50 cap, or a burst of 25 fetches and searches under a $4 cap that cost about $0.50, now finish where they parked at `spend_cap_reached`.
package/NOTICE CHANGED
@@ -1,6 +1,8 @@
1
1
  AgentRun
2
2
  Copyright 2026 Parcha Labs, Inc.
3
3
 
4
+ The boxd computer provider (packages/computer/src/boxd.ts) was contributed by Michiel Voortman.
5
+
4
6
  This product includes software from vercel-labs/durable-harness (https://github.com/vercel-labs/durable-harness), Copyright 2026 Vercel Inc., licensed under the Apache License 2.0.
5
7
 
6
8
  The copied files are listed in vendor/durable-harness/UPSTREAM.json. Two kernel files written for AgentRun, src/kernel/types.ts and src/kernel/errors.ts, keep one declaration each identical to that project's harness-world package (EffectRecord's fields and the EffectFailure class), so the copied files compile against them; UPSTREAM.json records them as "interfaces matched".
@@ -1,6 +1,7 @@
1
1
  export { ANTHROPIC_IMAGE_TOKENS_MAX, ANTHROPIC_TOOL_USE_SYSTEM_PROMPT_TOKENS, ASSUMED_TOOL_PROMPT_TOKENS, anthropicImageTokens, GEMINI_HIGH_RESOLUTION_TOKENS, geminiImageTokens, imageInputOf, imageProviderOf, imageSizeOf, imageTokens, INPUT_OVERHEAD_APIS, LOCAL_COUNT_MARGIN, messagesImagesIn, messagesInputAfter, messagesLocalInputTokens, OPENAI_IMAGE_TOKENS_MAX, openaiImageTokens, openaiPatchMultiplier, providerInputOverhead, responsesEscapedBytes, responsesImagesIn, responsesInputOverhead, responsesLocalInputTokens, type BilledRequest, type ImageInput, type InputShape } from "./overhead.js";
2
2
  export { O200K_SHA256, O200K_VOCABULARY, o200kModel, o200kTokens } from "./o200k.js";
3
3
  export { COUNT_TIMEOUT_MS, countedInputOf, CredentialUnavailable, localInputOf, hostHeaderProblems, lastObjectOf, NATIVE_SEARCH_USD, ProxyRefusal, ROUTE_ORIGIN, sameKey, startModelProxy, statesUsageCost, streamErrorOf, usageCostOf } from "./proxy.js";
4
+ export { OPENROUTER_APP, OPENROUTER_ATTRIBUTION_ENV, onOpenRouter, openRouterApp, openRouterAttribution } from "./openrouter-attribution.js";
4
5
  export type { InputCounter, ModelProxy, ModelProxyHooks, ModelProxyOptions, ModelUsageReport, ProviderPolicy, ProxyRequest, ProxyRequestContext, ProxyRoute, ProxyUsage, StreamError } from "./proxy.js";
5
6
  export { processAlive } from "./alive.js";
6
7
  export { serialWriter } from "./serial.js";
@@ -3,6 +3,7 @@
3
3
  export { ANTHROPIC_IMAGE_TOKENS_MAX, ANTHROPIC_TOOL_USE_SYSTEM_PROMPT_TOKENS, ASSUMED_TOOL_PROMPT_TOKENS, anthropicImageTokens, GEMINI_HIGH_RESOLUTION_TOKENS, geminiImageTokens, imageInputOf, imageProviderOf, imageSizeOf, imageTokens, INPUT_OVERHEAD_APIS, LOCAL_COUNT_MARGIN, messagesImagesIn, messagesInputAfter, messagesLocalInputTokens, OPENAI_IMAGE_TOKENS_MAX, openaiImageTokens, openaiPatchMultiplier, providerInputOverhead, responsesEscapedBytes, responsesImagesIn, responsesInputOverhead, responsesLocalInputTokens } from "./overhead.js";
4
4
  export { O200K_SHA256, O200K_VOCABULARY, o200kModel, o200kTokens } from "./o200k.js";
5
5
  export { COUNT_TIMEOUT_MS, countedInputOf, CredentialUnavailable, localInputOf, hostHeaderProblems, lastObjectOf, NATIVE_SEARCH_USD, ProxyRefusal, ROUTE_ORIGIN, sameKey, startModelProxy, statesUsageCost, streamErrorOf, usageCostOf } from "./proxy.js";
6
+ export { OPENROUTER_APP, OPENROUTER_ATTRIBUTION_ENV, onOpenRouter, openRouterApp, openRouterAttribution } from "./openrouter-attribution.js";
6
7
  export { processAlive } from "./alive.js";
7
8
  export { serialWriter } from "./serial.js";
8
9
  export { PARENT_WATCH_SHIM, parentWatched, parentWatchHere, SETPRIV } from "./parent-death.js";
@@ -0,0 +1,14 @@
1
+ /** AgentRun on OpenRouter: the URL its app page already exists under (the repository's), its name, its categories. */
2
+ export declare const OPENROUTER_APP: {
3
+ readonly url: "https://github.com/Parcha-ai/agentrun";
4
+ readonly title: "AgentRun";
5
+ readonly categories: "cloud-agent,personal-agent";
6
+ };
7
+ /** The setting that turns attribution off: `off` (any case) sends no attribution header. */
8
+ export declare const OPENROUTER_ATTRIBUTION_ENV = "AGENTRUN_OPENROUTER_ATTRIBUTION";
9
+ /** Whether `origin` (a base URL) is OpenRouter's: its host is openrouter.ai. */
10
+ export declare function onOpenRouter(origin: string): boolean;
11
+ /** AgentRun's app, or none where `env` (the environment AgentRun started in) turns attribution off. */
12
+ export declare function openRouterApp(env?: NodeJS.ProcessEnv): typeof OPENROUTER_APP | undefined;
13
+ /** The attribution headers a request to OpenRouter carries, or none where `env` turns them off. */
14
+ export declare function openRouterAttribution(env?: NodeJS.ProcessEnv): Readonly<Record<string, string>>;
@@ -0,0 +1,25 @@
1
+ // AgentRun's app attribution on OpenRouter (https://openrouter.ai/docs/app-attribution, read 2026-11-16): the one place
2
+ // that names the app. HTTP-Referer is the app's permanent id (its URL; without it no app page), X-OpenRouter-Title its
3
+ // display name, X-OpenRouter-Categories at most 2 of OpenRouter's own (an unknown one is dropped without an error).
4
+ // X-OpenRouter-App-Visibility is never sent: a new app sent `hidden` stays hidden for good, and AgentRun's is public.
5
+ // Sent by the model proxy where its upstream is OpenRouter's origin (proxy.ts), by serve's model route where pi-ai sends
6
+ // to OpenRouter itself (runner/model-route.ts), and by the Decisions provider, which serve hands this app (decisions.ts).
7
+ // A self-hosted server sends them on its owner's own key, so its usage counts toward AgentRun's listing, as Cline's and
8
+ // Roo's do; AGENTRUN_OPENROUTER_ATTRIBUTION=off where it starts sends none.
9
+ /** AgentRun on OpenRouter: the URL its app page already exists under (the repository's), its name, its categories. */
10
+ export const OPENROUTER_APP = { url: "https://github.com/Parcha-ai/agentrun", title: "AgentRun", categories: "cloud-agent,personal-agent" };
11
+ /** The setting that turns attribution off: `off` (any case) sends no attribution header. */
12
+ export const OPENROUTER_ATTRIBUTION_ENV = "AGENTRUN_OPENROUTER_ATTRIBUTION";
13
+ /** Whether `origin` (a base URL) is OpenRouter's: its host is openrouter.ai. */
14
+ export function onOpenRouter(origin) {
15
+ return URL.canParse(origin) && new URL(origin).hostname === "openrouter.ai";
16
+ }
17
+ /** AgentRun's app, or none where `env` (the environment AgentRun started in) turns attribution off. */
18
+ export function openRouterApp(env = process.env) {
19
+ return env[OPENROUTER_ATTRIBUTION_ENV]?.trim().toLowerCase() === "off" ? undefined : OPENROUTER_APP;
20
+ }
21
+ /** The attribution headers a request to OpenRouter carries, or none where `env` turns them off. */
22
+ export function openRouterAttribution(env = process.env) {
23
+ const app = openRouterApp(env);
24
+ return app ? { "HTTP-Referer": app.url, "X-OpenRouter-Title": app.title, "X-OpenRouter-Categories": app.categories } : {};
25
+ }
@@ -19,6 +19,7 @@ import { createServer } from "node:http";
19
19
  import { CONTENT_FILTERED } from "../types.js";
20
20
  import { isConnectCode, isGatewayTimeout, rejectionCode } from "../booking.js";
21
21
  import { SPEND_CAP_REACHED } from "../kernel/cap/words.js";
22
+ import { onOpenRouter, openRouterAttribution } from "./openrouter-attribution.js";
22
23
  /** Whether a request's admission refused it for the run's spend cap, read from the error's fields alone: the cap's own
23
24
  * error (CapRefused, its `code`), or the runner's stop for the cap's verdict (HarnessRunError, its `refusal`: the
24
25
  * verdict's Refusal.code). Never from its words. */
@@ -845,6 +846,9 @@ export async function startModelProxy(options, key) {
845
846
  const hostHeaders = { ...options.headers };
846
847
  const forward = options.fetch ?? fetch;
847
848
  const origin = baseOf(options.origin);
849
+ /** AgentRun's app attribution, on a proxy whose upstream is OpenRouter's and on no other (openrouter-attribution.ts).
850
+ * Not the host's headers: no error is cut for echoing its public values. */
851
+ const attribution = onOpenRouter(origin) ? openRouterAttribution() : {};
848
852
  /** Whether each answer states what it cost in its usage (`statesUsageCost`): read as the request's reported figure when
849
853
  * no header gave one, the price's figure kept beside it. */
850
854
  const costStated = statesUsageCost(origin);
@@ -1047,14 +1051,17 @@ export async function startModelProxy(options, key) {
1047
1051
  if (!credential)
1048
1052
  return refuse(res, 500, "the session has no provider credential", req);
1049
1053
  try {
1050
- // The host's own headers, over any the client sent by those names; then the credential's, over everything. A name
1051
- // replaces any other spelling of it, so no two headers of one name reach the provider combined.
1054
+ // OpenRouter's attribution, then the host's own headers, over any the client sent by those names; then the
1055
+ // credential's, over everything. A name replaces any other spelling of it, so no two headers of one name reach the
1056
+ // provider combined.
1052
1057
  const set = (name, value) => {
1053
1058
  for (const sent of Object.keys(headers))
1054
1059
  if (sent.toLowerCase() === name.toLowerCase())
1055
1060
  delete headers[sent];
1056
1061
  headers[name] = value;
1057
1062
  };
1063
+ for (const [name, value] of Object.entries(attribution))
1064
+ set(name, value);
1058
1065
  for (const [name, value] of Object.entries(hostHeaders))
1059
1066
  set(name, value);
1060
1067
  for (const [name, value] of Object.entries(policy.authHeaders(credential)))
package/dist/types.d.ts CHANGED
@@ -425,6 +425,13 @@ export type AdapterEvent = {
425
425
  status: TurnStatus;
426
426
  stopReason?: "length";
427
427
  outputTokens?: number;
428
+ }
429
+ /** The model was given these submissions (the ids `send` or `steer` placed them under): a steer placed mid-turn reaches
430
+ * it at the turn's next step, after the tool calls in flight. An adapter that records nothing of its own says it, so
431
+ * its host records the message where the model read it. */
432
+ | {
433
+ type: "message_taken";
434
+ ids: readonly string[];
428
435
  };
429
436
  /** An event as a host receives it: the adapter's, the runner's own, and the node each belongs to. */
430
437
  export type HarnessEvent = (AdapterEvent | {
@@ -485,7 +492,9 @@ export interface AdapterSession {
485
492
  * `mode`: "steer" (the default) steers the turn in flight; "followUp" waits for the turn's end and runs as a turn of
486
493
  * its own (a message that answers nothing, such as a trigger's). `origin`: who wrote it when the person did not (a
487
494
  * trigger's message), kept on the message the harness records, as the Timeline shows it. Absent when the harness takes
488
- * no message mid-turn: the host refuses the steer in words. */
495
+ * no message mid-turn: the host refuses the steer in words. A host that lost its runner after the placement hands the
496
+ * same message on again under the same `id`: an adapter that can tell (claude-agent's) places nothing again. An adapter
497
+ * whose host keeps the record (a CLI's) says when the model took it (`message_taken`). */
489
498
  steer?(text: string, id?: string, mode?: "steer" | "followUp", options?: {
490
499
  readonly origin?: {
491
500
  readonly [key: string]: unknown;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcha/agentrun-kernel",
3
- "version": "0.1.0-beta.40",
3
+ "version": "0.1.0-beta.42",
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.40",
65
+ "@parcha/agentrun-dsl": "0.1.0-beta.42",
66
66
  "ajv": "8.18.0",
67
67
  "typebox": "1.3.27"
68
68
  },