@parcha/agentrun-harness-claude 0.1.0-beta.58 → 0.1.0-beta.59
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 +41 -1
- package/dist/adapter.js +1 -1
- package/dist/env.d.ts +2 -0
- package/dist/env.js +6 -1
- package/dist/facts.js +2 -0
- package/dist/harness.js +2 -0
- package/dist/login.d.ts +19 -4
- package/dist/login.js +30 -9
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,46 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## 0.1.0-beta.59 (2026-11-25)
|
|
6
|
+
|
|
7
|
+
**Breaking:**
|
|
8
|
+
|
|
9
|
+
- Ollama models run only on a harness that forwards the route, an output schema beside tools on Ollama is refused, and an ACP agent's permission requests for AgentRun's tools are no longer answered from their titles. What to change on upgrade: <!-- changes/b51-breaking.md -->
|
|
10
|
+
- A harness module on Messages or Responses that should keep running Ollama models must forward its model requests with the `fetch` its launch hands it (`ModuleLaunch.fetch`, given to `startModelProxy`'s `fetch`) and set `forwardsRoute: true` in its facts. Without the fact it is offered no Ollama model, and a run of it that names one is refused before it starts, in words that name these two steps.
|
|
11
|
+
- A claude-agent node with an output schema on an Ollama model now stops with a 400 `invalid_request_error`, since the claude-agent harness sends its tools on every turn and Ollama can't hold an answer to a format and also call tools. Drop the schema, or run the node on a model with a key.
|
|
12
|
+
- A recipe for an agent that asks permission before every tool call needs an `allowFile` in a form its agent reads, or the title tie (`quirks.permissionTie: "title"`). Without either, every request for an AgentRun tool goes to the host's gate as the agent's own call, and its runs stop there.
|
|
13
|
+
- An agent's `tool_call` title no longer names the AgentRun tool it calls. A recipe without `announces` (the new field where its agent's `tool_call` names the tool) has every call matched to its MCP call by its arguments alone, a call with no arguments included. A call announced with no input at all is matched to an MCP call that nothing else matches, the oldest first, until the agent reports it ended, so two such calls in flight can trade ids. Declare `announces` to tie each call to its own.
|
|
14
|
+
- Goose's offer promises `tool_gate: "config"` (was `"permission"`): its calls of AgentRun's tools are held by its permission file and the host's gate at the MCP call.
|
|
15
|
+
- `agentrun harness-check` fails `mcp_tool` for an agent that asks permission for `check_echo` on a recipe with neither field. A recipe whose check passed before can fail its next one.
|
|
16
|
+
- `examples/harness-recipe/antigravity.json` declares `announces` and the title tie (`quirks.permissionTie: "title"`), since agy asks permission for every MCP call: its requests for the AgentRun calls it announced are answered allow once, and the host's gate decides at the MCP call. A copy of the recipe made before this release has neither and needs both, or its runs stop at the gate.
|
|
17
|
+
- The exported test helper `fakeAgentRecipe` (`@parcha/agentrun-harness-acp/testing`) now gives its recipe an `allowFile` (style "goose", the default) or the title tie (style "cursor"), and each style's `announces`, as each shipped recipe does. The fake's style "cursor" now announces its MCP calls late, as Cursor 2026.11.13 does (`announce: "early"` for the old shape). A suite that relied on the fake asking for AgentRun's tools and being answered from the title gets neither by default.
|
|
18
|
+
- On macOS, signing in to Claude from the console now saves the login's Keychain item under the Mac user the server runs as, so `claude auth status` in that person's terminal reads it signed in, as AgentRun's badge does. Before, the claude CLI that AgentRun starts for the sign-in, the status check and a run got no `USER`, so the item's account was `unknown`. Those three now carry `USER` and `LOGNAME` set to the user the server runs as (`os.userInfo()`), even when the server itself was started without `USER` or with another user's. <!-- changes/claude-keychain-account-user.md -->
|
|
19
|
+
|
|
20
|
+
Who breaks: anyone who signed Claude in from the console on macOS before this release. That login reads signed out once the server is updated, since its item is under `unknown`. What to do: sign in again under Settings → Model keys. The old item stays in the Keychain under the account `unknown`; `@parcha/agentrun-serve`'s changelog for this version says how to delete it.
|
|
21
|
+
|
|
22
|
+
**Changes:**
|
|
23
|
+
|
|
24
|
+
- A model the runner's route translates onto a harness's wire (this machine's Ollama models on Anthropic's Messages and OpenAI's Responses) is offered only to a harness whose proxy forwards with the route's `fetch`, and the Messages translation no longer drops what it can't run. Before, any harness on the wire was offered those models, including a module that sends its requests to the network, where nothing answers. <!-- changes/b51-route-hints.md -->
|
|
25
|
+
- `AdapterFacts` gains `forwardsRoute`. claude-agent, Goose, codex and opencode set it, and so does every recipe that builds on Goose's facts. A harness without it is offered none of the route's models, takes none as its default, and its words say to add a key ("No model yet for <harness>: add an OpenRouter or Anthropic key"). A run that names one is refused before it starts.
|
|
26
|
+
- An output schema (`output_config.format` of type `json_schema`) on a Messages request with no tools now reaches Ollama as its `format`. Before, it was dropped and the answer came back unconstrained. Beside tools it is refused with a 400 `invalid_request_error` that says to drop the output schema or use a model route that takes tools with a format, because Ollama holds the whole answer to the format and leaves the model no way to call a tool.
|
|
27
|
+
- The Messages translation answers `POST /v1/messages` and `POST /v1/messages/count_tokens` alone. Any other method or path is a 404 `not_found_error` in Anthropic's error shape, and nothing reaches Ollama.
|
|
28
|
+
- `agentrun harness-check` on a model the route translates (`--model ollama/<tag>`) now reaches it. Its recorder wraps the route's own fetch, so the recipe's agent gets the same route a server's run gets and the check still sees every request. Before, every request went to the route's placeholder origin and `mcp_tool` failed.
|
|
29
|
+
- A run's trace no longer costs or carries what it should not. Under `agentrun-serve runner`, where each run is a process of its own, a run's end waited up to 3 s on the collector, since that process flushed its own spans before it exited: now it sends its trace to its runner, which exports it in the background, and a run's process never holds an `OTEL_*` setting at all. The runner reads that trace as untrusted: every string it carries (a provider, a host, a call id, a request's or turn's end, a failure) is cut of every secret the runner holds, or taken only from values the runner knows, and a call's id, its parent's or a route's name longer than 128 characters is kept as its SHA-256, so a run's process can't hold megabytes of ids open in its runner. A name the model wrote no longer reaches a span as written: a call the harness refused (a tool the session does not have; the kernel's `tool_start` event says `refused: true`, which claude-agent now sets) is `execute_tool` with `error.type=tool_refused` and no tool name, a model the run does not know (not a route's model, nor one its price table names by that same id) is named by its route's model, and every name is cut of every secret the runner holds and at 64 characters. Each value of `OTEL_EXPORTER_OTLP_HEADERS` and `OTEL_EXPORTER_OTLP_TRACES_HEADERS` of 8 characters or more is now a secret the server and the runner hold, under any header name, an unknown one too, but a `Content-Type`, `Accept`, `Content-Encoding` or `User-Agent` header's value, and a dataset or tenant header's (`x-honeycomb-dataset`, `x-axiom-dataset`, `x-scope-orgid`), which is only cut from the tracer's `[otel]` lines, so a dataset named `production` refuses no source capture. A credential is held without the word before it too, after a known auth scheme (`Bearer`, `Basic`, `Api-Key`, `Api-Token`, `Token`, `sentry`, `Splunk`, `GenieKey`) or under a credential-named header (`authorization`, `x-sentry-auth`, `x-api-key`); any other header's value is held whole, never its tail alone. So are an OTLP endpoint's user, password and each query parameter named like a credential: a word of its name is a credential word or ends in key, token, secret, password, auth, sig, signature or credential (`api_key`, `access_token`, `apiKey`, `accesstoken`, `writekey`; never `authority` or `keyspace`). A comma inside a header value must be written `%2C`. The tracer's own `[otel]` lines, where an exporter's error may quote a header it sent, are cut of each such value at any length, a short one too, and of what follows any header value's first word; everywhere else (the runner's logs, what a run writes, a served run, a source capture) a held value is still cut at 8 characters or more and a shorter header value is on no held list, on purpose, since a needle of a few characters would cut ordinary text, turn a served number such as `1` into `[redacted]`, or refuse a source capture of any project that holds it. <!-- changes/otel-trace-names-and-child-export.md -->
|
|
30
|
+
- The Claude login on this machine now uses the folders the server's env gives it only when they belong to the server's own user, as it already did for the home. Those folders are `CLAUDE_CONFIG_DIR`, `CLAUDE_SECURESTORAGE_CONFIG_DIR`, and `ANTHROPIC_CONFIG_DIR` or else `XDG_CONFIG_HOME`'s `anthropic`. Each one must be a folder that user owns, or a folder still to be made inside one it owns. The home and these folders are judged by one rule, so that no other user can change where the path leads after the check: <!-- changes/claude-login-config-dirs.md -->
|
|
31
|
+
|
|
32
|
+
- The path is walked as the system walks it, one name at a time, so a trailing slash, `.` or `..` hides nothing, and a `..` after a link goes up from where the link leads. Each link on the way, and each link in the chain it leads through, must be one that user or root made.
|
|
33
|
+
- Each folder above the real folder must be that user's or root's, and not one others may write in (anyone, or its group, unless that group is the user's private one), unless the sticky bit keeps each entry its maker's (as /tmp has it).
|
|
34
|
+
- The folder itself must be that user's and not open to others' writes by the same rule. So must the folder a still-to-make one is made in, sticky or not, so a folder still to make in /tmp is refused, root's included.
|
|
35
|
+
- The CLI gets the real path the check looked at (the home included), from the same look: each decision (a run, the sign-in, the Settings view's line and status check, a turn-on) walks the folders once and takes the login, or the refusal, from that walk, never the path as given. Where the folders are refused, the view's `command` is empty and its `folder` is the folder as the env names it. Where the env's path has a link on it, the shown sign-in line and the CLI now name the folder the link leads to. On macOS the CLI names its Keychain item after that folder, so a login the person's own Claude CLI keeps under a path with a link reads as signed out until it is signed in again from here.
|
|
36
|
+
|
|
37
|
+
A server started under a sudo that keeps the env (root, with the person's `CLAUDE_CONFIG_DIR`) no longer signs the Claude CLI in as root inside the person's folder. Where a folder fails the check, the turn-on and the sign-in at this machine's login are refused (403) in words that name the variable and the folder, and no run goes on the login. AgentRun's own login keeps its folders in the data folder, so the env's folders refuse nothing there, but the home rule above applies to both places. A login saved before on folders, the home's included, that fail the check is kept, not turned off: the start logs why it is not used, every read refuses it in those words, and it is back once the folder is mended (a chmod, or the server started as the right user). A chmod needs no restart: a run's check, a save's, a template's plan or apply, and capabilities look at the folders again, so the login is offered and runs again as soon as the view reads it signed in, and stops again once its folder is refused. Such a request asked while the server is still making the offers again from such a change, or from a turn-on or turn-off, waits for them, and the server logs `claude_login_wait` as it waits, with `why`: `queue` (behind a turn-on, turn-off or sign-in), `refresh` or `turn`. A sign-in, a turn-on or a turn-off never waits for those offers. The Settings view says such a login is `refused`, with why, and offers Turn off, which removes it; until then no API key is made. The refusal words now name the server's user (`uid 501 (svc)`, say), the home's refusal included. A folder that is the user's but open to others' writes is refused in words of its own, which name the open folder, its mode and the `chmod g-w,o-w` that closes it. A folder of this machine's login still to make is made by AgentRun at the turn-on and before the CLI's sign-in, 0700 whatever the umask, and checked again before the CLI gets it, so a login the CLI signs in there is not refused after.
|
|
38
|
+
|
|
39
|
+
Where the env's `HOME` is another user's and the login therefore uses the server's user's own home, the sign-in line the Settings view shows now carries `HOME=<that home>`. Before, it left `HOME` to the terminal, so the line run in the person's terminal signed in to their own home, which the server never reads. The harness's `ClaudeAgentLogin` has a new optional `homeApart` that asks for this.
|
|
40
|
+
|
|
41
|
+
A folder its group may write in is the user's alone where that group is the user's private one, as the local account files alone say: `/etc/nsswitch.conf` takes users and groups from those files only (`files` or `compat`), and the group is the user's primary group, which no other user has as theirs and which `/etc/group` lists with no other member. So a umask of 002 under such a group refuses nothing there. A switch that also asks another source (sssd, LDAP, NIS, winbind, or systemd's user records, as recent Ubuntu, Debian and Fedora installs do) can give the group members the files do not show, so there such a folder is refused.
|
|
42
|
+
|
|
43
|
+
Behaviour change: a login that ran before is refused, at either place, where the server's home is a folder anyone may write in, or its group where another user is in it, or is reached through one (a home on a volume whose group is set for a pod, 2775, say). So is a login on this machine's folders where one of these variables points at another user's folder, or reaches through another user's link or folder, or through such an open folder. A group shared with other users, a group that is not the user's primary one, one `/etc/group` does not list, account files that defer to a directory service (a `+` or `-` line), and any group where `/etc/nsswitch.conf` asks a source other than the files for users or groups, or is missing, all count as open: under a umask of 002 with such a group, a home, a `~/.config` or a `CLAUDE_CONFIG_DIR` folder made by hand is refused until it is `chmod g-w`. The setting stays. Start the server as the person whose Claude plan it is, with that person's variables, and make the folders on the way writable by their owner alone.
|
|
44
|
+
|
|
5
45
|
## 0.1.0-beta.58 (2026-11-25)
|
|
6
46
|
|
|
7
47
|
- More follow-ups to the Claude login on this machine (Settings → Model keys), and to the server's probe of the harness offers. <!-- changes/claude-sign-in-followups-2.md -->
|
|
@@ -13,7 +53,7 @@
|
|
|
13
53
|
- A sign-in whose CLI is a script naming an interpreter that is not there (`#!/path`, or `#!/usr/bin/env <program>` with the program on no folder of the sign-in's PATH) fails at its start, in words that name the interpreter. Before, the parent watch's exit 127 read as the CLI's own exit. The `#!` line is read as the kernel reads it, as bytes, so an interpreter under a folder whose name is not ASCII (a home folder named `José`, say) is found.
|
|
14
54
|
- `parentWatched` throws a `RangeError` at the call for a `termGraceMs` the parent-watch shim would refuse (anything but a whole number of ms from 1 to 2^31 - 1), whichever watch is asked for. Before, the shim exited 2 at spawn, which read as the child's own exit.
|
|
15
55
|
- The status check reads an answer that is already in the CLI's output when the drain's second ends, though the server's event loop was held up past that second. Before, the loop ran the drain's timer before its reads, and the check read `no_status`.
|
|
16
|
-
- Where each run is a user of its own (the image, `run_isolation: "uid"`), a claude-agent run now runs on Claude
|
|
56
|
+
- Where each run is a user of its own (the image, `run_isolation: "uid"`), a claude-agent run now runs on the Claude login in AgentRun's own login folder instead of failing at its claim. The runner, as the server's user, reads the login's access token from that folder and hands the run's CLI that token alone, in `CLAUDE_CODE_OAUTH_TOKEN`: never the folder and never the refresh token, so the run's CLI never renews the login. The runner reads the folder again when the run starts and whenever Anthropic refuses the token mid-run, so a renewal your own Claude CLI wrote there is picked up. The runner also renews the login itself, in the CLI's place, when a token has less than five minutes left and after Anthropic refuses one mid-run: it sends the pinned CLI's own refresh request, holds the CLI's own refresh lock on the folder, reads the file again under it (a renewal by the CLI or another runner is taken, and nothing is sent twice), and writes the answer back to that folder's `.credentials.json` alone, atomically at mode 0600, every other field kept. It holds the lock as the CLI does, by the directory it made and the mtime it set (to the microsecond; on a filesystem that keeps whole seconds alone, any mtime in that second, as the CLI reads its own lock there), so a lock another holder took over while the runner was paused is never touched or removed, and nothing is sent under it. Runners take the lock one at a time, a dead one included, through a short-lived `.takeover` directory beside it, so two runners never hold it at once, unless a runner stalls past the 60 s stale time inside a takeover or between its last check of the lock and its removal of it (every lock that expires has these gaps). The CLI does not see that directory: between a runner and the CLI the lock is as safe as the CLI's own, and where the CLI's second lock beside the login folder can be made, it keeps the two from both sending. If the write back fails, the runner keeps the new pair in memory: later asks get its token, send nothing (the old refresh token is spent and never sent again) and try the write again, under the same lock and after reading the file again, so a newer pair another holder wrote is kept; once that token has less than five minutes left and is still unsaved, the run fails in words that say the renewal could not be saved and what to fix. A held token Anthropic refuses is never handed again: the ask fails while its pair is unsaved, and once the pair is saved the runner renews from it. One ask sends at most one renewal and nothing retries it. A renewal that fails, a refresh token Anthropic refused included, fails the run at its start, and ends the turn mid-run, in words that say to open the Claude CLI once to renew the login; a token refused mid-run that the runner had no way to renew ends the turn in words that say to run the claude CLI once on this login to renew it. No token is in the runner's log or in any error, and each token handed is cut from the run's journal, messages and rows as the runner writes them. A command the run's CLI starts can read the token, as the run's own user can. Under per-run users, a run on this machine's own Claude login (`~/.claude`, or the `CLAUDE_CONFIG_DIR` AgentRun was started with) still fails at its claim. So does a login run while another runner on the same data folder runs its login runs under the server's user, and the error names that runner. A login kept in a form the runner does not read fails in words too. For each of these, set `AGENTRUN_RUN_USER=same` or give the run a `model_key`. `claudeAgentAdapter({ login })` in `@parcha/agentrun-harness-claude` also takes `{ token(), refused?(sent) }`, a host's reader of the login's access token: on the CLI's request for a newer token it tells the host which token was refused, then answers from `token()`. The pinned CLI's refresh request, lock and write back are exported as `CLAUDE_LOGIN_REFRESH` (and `loginRefresh` from `/facts`), and a test reads each of them in the installed CLI. <!-- changes/claude-login-per-run-users.md -->
|
|
17
57
|
- A host tool with replay `never` called early in a long message of parallel calls now runs. Such a tool waits until the transcript line that made its call is in the log, and the Agent SDK hands the log a message's lines only once the whole message has streamed, while the CLI starts each call as its block ends. The 10 s wait was counted from the call, so in a message of 12 calls streamed about 1.3 s apart the first calls were refused ("the transcript entry for tool call ... did not reach the log within 10000 ms") though nothing was wrong. The wait's clock now restarts on each stream event of the message that made the call (the main thread's, or a subagent's own), so it runs out 10 s after that message ends, or after its last event if the stream stalls; a call whose line never lands is still refused then. A message's end unties its calls from the stream, so the next message in the same stream (the main thread's next answer, say) never holds them open. A short message waits as before. <!-- changes/claude-barrier-message-end.md -->
|
|
18
58
|
A call the CLI refuses itself early in such a message is shown to the host again: its answer line comes with the rest of the message, and the wait for it had run out the same way, so the refusal was only logged ("a refused call is not shown").
|
|
19
59
|
|
package/dist/adapter.js
CHANGED
|
@@ -399,7 +399,7 @@ export function claudeAgentAdapter(options) {
|
|
|
399
399
|
// A call the CLI refused itself (a tool the session doesn't have): shown as a call that failed, by the name the
|
|
400
400
|
// model gave. The CLI's transcript, mirrored to the store, keeps the refusal.
|
|
401
401
|
if (e?.type === "tool_refused" && typeof e.callId === "string" && typeof e.name === "string") {
|
|
402
|
-
io.onEvent({ type: "tool_start", callId: e.callId, name: e.name, args: e.args ?? {} });
|
|
402
|
+
io.onEvent({ type: "tool_start", callId: e.callId, name: e.name, args: e.args ?? {}, refused: true });
|
|
403
403
|
io.onEvent({ type: "tool_end", callId: e.callId, name: e.name, isError: true });
|
|
404
404
|
options.log?.("claude-agent: the CLI turned down a call to a tool this session does not have", { name: e.name, reason: e.reason });
|
|
405
405
|
}
|
package/dist/env.d.ts
CHANGED
|
@@ -73,6 +73,8 @@ export interface DurableEnvOptions {
|
|
|
73
73
|
* - `HOME`, `CLAUDE_CONFIG_DIR`, `TMPDIR` and the XDG dirs in the session's
|
|
74
74
|
* cache dirs, which the relay wipes before every spawn (`/var/lib/dh/s`),
|
|
75
75
|
* but `HOME` on macOS on a login: the person's (login.ts personHome);
|
|
76
|
+
* - on a login, `USER` and `LOGNAME`: the user this process runs as
|
|
77
|
+
* (login.ts loginUser), the account of the login's Keychain item on macOS;
|
|
76
78
|
* - the projects key fixed (`CLAUDE_CODE_PROJECT_DIR_NAME`), so a transcript
|
|
77
79
|
* resumes on any VM, whatever the cwd;
|
|
78
80
|
* - the model through the VM's model port, with the attach's key; the
|
package/dist/env.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* about 50 `CLAUDE_*`, `ANTHROPIC_*` and `MCP_*` variables that change the
|
|
11
11
|
* CLI's behavior; none reaches the child unless it is listed here.
|
|
12
12
|
*/
|
|
13
|
-
import { loginEnv, personHome } from './login.js';
|
|
13
|
+
import { loginEnv, loginUser, personHome } from './login.js';
|
|
14
14
|
/** What never reaches a CLI that runs on a person's login from the app's own variables: a model URL, key or token of
|
|
15
15
|
* any kind, a refresh token or a token's file descriptor among them. A login handed as a token sets its own
|
|
16
16
|
* CLAUDE_CODE_OAUTH_TOKEN after. */
|
|
@@ -25,6 +25,8 @@ export const PROJECT_DIR_NAME = 'session';
|
|
|
25
25
|
* - `HOME`, `CLAUDE_CONFIG_DIR`, `TMPDIR` and the XDG dirs in the session's
|
|
26
26
|
* cache dirs, which the relay wipes before every spawn (`/var/lib/dh/s`),
|
|
27
27
|
* but `HOME` on macOS on a login: the person's (login.ts personHome);
|
|
28
|
+
* - on a login, `USER` and `LOGNAME`: the user this process runs as
|
|
29
|
+
* (login.ts loginUser), the account of the login's Keychain item on macOS;
|
|
28
30
|
* - the projects key fixed (`CLAUDE_CODE_PROJECT_DIR_NAME`), so a transcript
|
|
29
31
|
* resumes on any VM, whatever the cwd;
|
|
30
32
|
* - the model through the VM's model port, with the attach's key; the
|
|
@@ -67,6 +69,9 @@ export function durableEnv(options) {
|
|
|
67
69
|
// On macOS the CLI on a login reads its tokens from the login keychain, which is under the person's home: in the
|
|
68
70
|
// session's it finds none and reads signed out. Its config, XDG and temporary dirs stay the session's.
|
|
69
71
|
HOME: options.login && platform === 'darwin' ? personHome(options.login) : home,
|
|
72
|
+
// On a login, the user it is the login of: on macOS the CLI names the Keychain item's account by USER, and with
|
|
73
|
+
// none it reads the account "unknown", not the one the sign-in saved the tokens under (login.ts loginUser).
|
|
74
|
+
...(options.login ? loginUser() : {}),
|
|
70
75
|
TMPDIR: options.tmpDir,
|
|
71
76
|
CLAUDE_CONFIG_DIR: options.configDir,
|
|
72
77
|
CLAUDE_CODE_PROJECT_DIR_NAME: PROJECT_DIR_NAME,
|
package/dist/facts.js
CHANGED
|
@@ -27,6 +27,8 @@ export const facts = Object.freeze({
|
|
|
27
27
|
webSearch: "native",
|
|
28
28
|
// Its model is Anthropic's, on its own settings, never the gateway's default for the other harnesses.
|
|
29
29
|
ownModel: true,
|
|
30
|
+
// Its proxy forwards with the fetch it is handed: a model the route translates onto its wire runs on it.
|
|
31
|
+
forwardsRoute: true,
|
|
30
32
|
// Anthropic's ids hold no dot; OpenRouter names the same models with dots (anthropic/claude-sonnet-5.5).
|
|
31
33
|
normalizeModel: (model) => (model.provider === "anthropic" ? { ...model, modelId: model.modelId.replaceAll(".", "-") } : model),
|
|
32
34
|
install: Object.freeze({ npmLine: CLAUDE_AGENT_SDK_INSTALL, spec: `@anthropic-ai/claude-agent-sdk@${CLAUDE_AGENT_SDK_VERSION}`, codes: Object.freeze({ install: "CLAUDE_AGENT_NOT_INSTALLED", pins: "CLAUDE_AGENT_PIN_MISMATCH" }) }),
|
package/dist/harness.js
CHANGED
|
@@ -340,6 +340,8 @@ export function claudeCodeHarness(options = {}) {
|
|
|
340
340
|
try {
|
|
341
341
|
const result = await running;
|
|
342
342
|
const images = (result.images ?? []).map((image) => ({ type: 'image', data: image.data, mimeType: image.mimeType }));
|
|
343
|
+
// The tool's structured content is not passed on: the pinned CLI replaces an MCP answer's content with
|
|
344
|
+
// JSON.stringify(structuredContent), so sending both would hide the tool's text from the model.
|
|
343
345
|
return { content: [{ type: 'text', text: result.text }, ...images], ...(result.isError ? { isError: true } : {}) };
|
|
344
346
|
}
|
|
345
347
|
catch (err) {
|
package/dist/login.d.ts
CHANGED
|
@@ -21,6 +21,10 @@ export interface ClaudeAgentLogin {
|
|
|
21
21
|
* server's `HOME` when its user owns it, else that user's own home), so the status check, the sign-in and a run on
|
|
22
22
|
* macOS all run in that one home (personHome). With `home`, the same folder. */
|
|
23
23
|
userHome?: string;
|
|
24
|
+
/** Set where `userHome` is not the home a terminal with the server's env has (serve's homeOf: that env's `HOME` was
|
|
25
|
+
* another user's, so the server's user's own home was taken): the line a person runs (loginCommand) then carries
|
|
26
|
+
* `HOME`, so it signs in where the server reads, never in that terminal's own home. */
|
|
27
|
+
homeApart?: boolean;
|
|
24
28
|
}
|
|
25
29
|
/** A login handed to the CLI as its access token alone, by a host that holds the login itself. `token()` is asked at
|
|
26
30
|
* each start of the CLI and when Anthropic refuses the token the CLI holds: it answers the login's access token as
|
|
@@ -68,7 +72,8 @@ export declare function signInEnv(login: ClaudeAgentLogin, platform?: NodeJS.Pla
|
|
|
68
72
|
* holding '=' as one more variable, so a CLI path holding one (/data/a=b/claude) goes to `sh -c` as its `$0`, single
|
|
69
73
|
* quoted, which every one of those shells reads alike too. What env skips: a `claude` alias or function of the
|
|
70
74
|
* person's shell. Elsewhere nothing is cleared, and the line is the variables in front of the CLI, as a shell reads
|
|
71
|
-
* them (sh, bash, zsh, fish 3.1 and later; not tcsh).
|
|
75
|
+
* them (sh, bash, zsh, fish 3.1 and later; not tcsh). A login whose home is not the terminal's (`homeApart`) carries
|
|
76
|
+
* `HOME` first (personHome), as the sign-in this host starts does. `platform`: as signInEnv's. */
|
|
72
77
|
export declare const loginCommand: (login: ClaudeAgentLogin, cli?: string, platform?: NodeJS.Platform) => string;
|
|
73
78
|
/** What the CLI says of its login: whether it is signed in, how, and the account's own words when it gives them. */
|
|
74
79
|
export interface ClaudeLoginStatus {
|
|
@@ -120,8 +125,17 @@ export declare function sweepClaudeStatusFolders(options?: {
|
|
|
120
125
|
* the CLI reads its tokens from the login keychain, which is under that home: in any other home (an empty one, a
|
|
121
126
|
* session's) it finds no keychain and reads signed out, whatever the variables. */
|
|
122
127
|
export declare const personHome: (login: ClaudeAgentLogin) => string;
|
|
123
|
-
/**
|
|
124
|
-
*
|
|
128
|
+
/** `USER` and `LOGNAME` for a CLI started on a login, built from nothing (the status check, the sign-in this host starts,
|
|
129
|
+
* a run): the user this process runs as, as the system has it (`os.userInfo()`, which reads the user database, never
|
|
130
|
+
* the server's own USER), the user whose home personHome is. On macOS the pinned CLI names its Keychain item's account
|
|
131
|
+
* by `$USER`, else by its runtime's `os.userInfo().username`; it is a Bun binary, whose userInfo reads `$USER` too and
|
|
132
|
+
* says "unknown" without it. So a CLI started with no USER saves and reads the login's tokens under the account
|
|
133
|
+
* "unknown", where the person's own `claude`, run in a terminal that has USER, never looks: it reads signed out while
|
|
134
|
+
* the badge reads signed in. A user the system cannot name (no entry in its user database) is the server's USER or
|
|
135
|
+
* LOGNAME, when it has one. */
|
|
136
|
+
export declare function loginUser(): Record<string, string>;
|
|
137
|
+
/** Ask the CLI at `cli` whether it is signed in at `login`: `auth status --json`, with only PATH, the user (loginUser)
|
|
138
|
+
* and the login's variables beside it, in the person's home (personHome) on every place and platform.
|
|
125
139
|
* The CLI rewrites its account file (`.claude.json`, in its config dir) whenever that file's migration number is not its
|
|
126
140
|
* own, and adds a settings file, a backup and a lock beside it the first time, all in its config dir, so the check never
|
|
127
141
|
* runs it on the login's own file, whatever the caller says of the login: the config dir is a copy of the account file
|
|
@@ -165,7 +179,8 @@ export interface ClaudeSignIn {
|
|
|
165
179
|
stop(): void;
|
|
166
180
|
}
|
|
167
181
|
/** Start the CLI's own sign-in at `login` (`auth login`), with the line's own variables (signInEnv) in the person's home
|
|
168
|
-
* (personHome)
|
|
182
|
+
* (personHome), as that person (loginUser: the account the Keychain item is saved under on macOS, the one their own
|
|
183
|
+
* terminal's `claude` reads), and on their desktop (`display`): it opens a browser on this machine and keeps what it gets in the login's folder.
|
|
169
184
|
* Nothing of it is read here: its output goes nowhere. It is ended after `timeoutMs` (SIGN_IN_MS by default), which
|
|
170
185
|
* `ended` says apart from any other end.
|
|
171
186
|
* It dies with this process, as a session's CLI does: started under the kernel's parent watch (parentWatched; `watch`,
|
package/dist/login.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
import { spawn } from "node:child_process";
|
|
15
15
|
import { accessSync, closeSync, constants, mkdtempSync, openSync, readSync, rmSync, statSync } from "node:fs";
|
|
16
16
|
import { lstat, mkdir, open, readdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
17
|
-
import { homedir, tmpdir } from "node:os";
|
|
17
|
+
import { homedir, tmpdir, userInfo } from "node:os";
|
|
18
18
|
import { delimiter, join } from "node:path";
|
|
19
19
|
import { parentWatched } from "@parcha/agentrun-kernel/host";
|
|
20
20
|
/** Whether `login` is handed as a token (ClaudeLoginToken), not as its directories. */
|
|
@@ -66,11 +66,12 @@ const FOLDER_VARS = ["CLAUDE_CONFIG_DIR", "CLAUDE_SECURESTORAGE_CONFIG_DIR"];
|
|
|
66
66
|
* holding '=' as one more variable, so a CLI path holding one (/data/a=b/claude) goes to `sh -c` as its `$0`, single
|
|
67
67
|
* quoted, which every one of those shells reads alike too. What env skips: a `claude` alias or function of the
|
|
68
68
|
* person's shell. Elsewhere nothing is cleared, and the line is the variables in front of the CLI, as a shell reads
|
|
69
|
-
* them (sh, bash, zsh, fish 3.1 and later; not tcsh).
|
|
69
|
+
* them (sh, bash, zsh, fish 3.1 and later; not tcsh). A login whose home is not the terminal's (`homeApart`) carries
|
|
70
|
+
* `HOME` first (personHome), as the sign-in this host starts does. `platform`: as signInEnv's. */
|
|
70
71
|
export const loginCommand = (login, cli = "claude", platform = process.platform) => {
|
|
71
|
-
const env = signInEnv(login, platform);
|
|
72
|
+
const env = login.homeApart ? { HOME: personHome(login), ...signInEnv(login, platform) } : signInEnv(login, platform);
|
|
72
73
|
const cleared = FOLDER_VARS.filter((name) => !(name in env));
|
|
73
|
-
const vars = Object.entries(env).filter(([name]) => name !== "HOME").map(([name, value]) => `${name}=${shellWord(value)}`);
|
|
74
|
+
const vars = Object.entries(env).filter(([name]) => name !== "HOME" || login.homeApart).map(([name, value]) => `${name}=${shellWord(value)}`);
|
|
74
75
|
if (!cleared.length)
|
|
75
76
|
return [...vars, commandWord(cli), "auth", "login"].join(" ");
|
|
76
77
|
const run = cli.includes("=") ? ["sh", "-c", `'exec "$0" auth login'`, quoted(cli)] : [shellWord(cli), "auth", "login"];
|
|
@@ -295,8 +296,27 @@ async function accountCopy(from, to) {
|
|
|
295
296
|
* the CLI reads its tokens from the login keychain, which is under that home: in any other home (an empty one, a
|
|
296
297
|
* session's) it finds no keychain and reads signed out, whatever the variables. */
|
|
297
298
|
export const personHome = (login) => login.userHome ?? login.home ?? homedir();
|
|
298
|
-
/**
|
|
299
|
-
*
|
|
299
|
+
/** `USER` and `LOGNAME` for a CLI started on a login, built from nothing (the status check, the sign-in this host starts,
|
|
300
|
+
* a run): the user this process runs as, as the system has it (`os.userInfo()`, which reads the user database, never
|
|
301
|
+
* the server's own USER), the user whose home personHome is. On macOS the pinned CLI names its Keychain item's account
|
|
302
|
+
* by `$USER`, else by its runtime's `os.userInfo().username`; it is a Bun binary, whose userInfo reads `$USER` too and
|
|
303
|
+
* says "unknown" without it. So a CLI started with no USER saves and reads the login's tokens under the account
|
|
304
|
+
* "unknown", where the person's own `claude`, run in a terminal that has USER, never looks: it reads signed out while
|
|
305
|
+
* the badge reads signed in. A user the system cannot name (no entry in its user database) is the server's USER or
|
|
306
|
+
* LOGNAME, when it has one. */
|
|
307
|
+
export function loginUser() {
|
|
308
|
+
let name;
|
|
309
|
+
try {
|
|
310
|
+
name = userInfo().username || undefined;
|
|
311
|
+
}
|
|
312
|
+
catch {
|
|
313
|
+
name = undefined;
|
|
314
|
+
}
|
|
315
|
+
name ??= process.env.USER || process.env.LOGNAME || undefined;
|
|
316
|
+
return name === undefined ? {} : { USER: name, LOGNAME: name };
|
|
317
|
+
}
|
|
318
|
+
/** Ask the CLI at `cli` whether it is signed in at `login`: `auth status --json`, with only PATH, the user (loginUser)
|
|
319
|
+
* and the login's variables beside it, in the person's home (personHome) on every place and platform.
|
|
300
320
|
* The CLI rewrites its account file (`.claude.json`, in its config dir) whenever that file's migration number is not its
|
|
301
321
|
* own, and adds a settings file, a backup and a lock beside it the first time, all in its config dir, so the check never
|
|
302
322
|
* runs it on the login's own file, whatever the caller says of the login: the config dir is a copy of the account file
|
|
@@ -327,7 +347,7 @@ export async function claudeLoginStatus(cli, login, options = {}) {
|
|
|
327
347
|
const where = { HOME, ...loginEnv(login, options.platform), CLAUDE_CONFIG_DIR: await accountCopy(accountFile(login), join(scratch, "config")) };
|
|
328
348
|
const { stdout, timedOut } = await new Promise((resolve, reject) => {
|
|
329
349
|
const child = spawn(cli, ["auth", "status", "--json"], {
|
|
330
|
-
env: { PATH: options.path ?? process.env.PATH ?? "/usr/bin:/bin", ...where, DISABLE_AUTOUPDATER: "1", DISABLE_TELEMETRY: "1", DISABLE_ERROR_REPORTING: "1", CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: "1" },
|
|
350
|
+
env: { PATH: options.path ?? process.env.PATH ?? "/usr/bin:/bin", ...loginUser(), ...where, DISABLE_AUTOUPDATER: "1", DISABLE_TELEMETRY: "1", DISABLE_ERROR_REPORTING: "1", CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: "1" },
|
|
331
351
|
stdio: ["ignore", "pipe", "ignore"],
|
|
332
352
|
});
|
|
333
353
|
let out = "";
|
|
@@ -481,7 +501,8 @@ function startable(cli, path) {
|
|
|
481
501
|
}
|
|
482
502
|
}
|
|
483
503
|
/** Start the CLI's own sign-in at `login` (`auth login`), with the line's own variables (signInEnv) in the person's home
|
|
484
|
-
* (personHome)
|
|
504
|
+
* (personHome), as that person (loginUser: the account the Keychain item is saved under on macOS, the one their own
|
|
505
|
+
* terminal's `claude` reads), and on their desktop (`display`): it opens a browser on this machine and keeps what it gets in the login's folder.
|
|
485
506
|
* Nothing of it is read here: its output goes nowhere. It is ended after `timeoutMs` (SIGN_IN_MS by default), which
|
|
486
507
|
* `ended` says apart from any other end.
|
|
487
508
|
* It dies with this process, as a session's CLI does: started under the kernel's parent watch (parentWatched; `watch`,
|
|
@@ -503,7 +524,7 @@ export function startClaudeLogin(cli, login, options = {}) {
|
|
|
503
524
|
startable(cli, path);
|
|
504
525
|
const run = parentWatched({ command: cli, args: ["auth", "login", "--claudeai"] }, options.watch, { termGraceMs: SIGN_IN_TERM_GRACE_MS });
|
|
505
526
|
child = spawn(run.command, run.args, {
|
|
506
|
-
env: { PATH: path, HOME: personHome(login), ...display, ...signInEnv(login), DISABLE_AUTOUPDATER: "1", DISABLE_TELEMETRY: "1", DISABLE_ERROR_REPORTING: "1" },
|
|
527
|
+
env: { PATH: path, HOME: personHome(login), ...loginUser(), ...display, ...signInEnv(login), DISABLE_AUTOUPDATER: "1", DISABLE_TELEMETRY: "1", DISABLE_ERROR_REPORTING: "1" },
|
|
507
528
|
stdio: "ignore",
|
|
508
529
|
});
|
|
509
530
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcha/agentrun-harness-claude",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.59",
|
|
4
4
|
"description": "The Claude Agent SDK as an AgentRun harness: the host's tools as its only tools, its model behind a loopback proxy, durable in AgentRun's own store.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentrun",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"test": "node --test --test-concurrency=8 'test/*.test.mjs'"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@parcha/agentrun-kernel": "0.1.0-beta.
|
|
51
|
+
"@parcha/agentrun-kernel": "0.1.0-beta.59"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@anthropic-ai/claude-agent-sdk": "0.3.286",
|
|
@@ -77,6 +77,6 @@
|
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@anthropic-ai/claude-agent-sdk": "0.3.286",
|
|
80
|
-
"@parcha/agentrun-dsl": "0.1.0-beta.
|
|
80
|
+
"@parcha/agentrun-dsl": "0.1.0-beta.59"
|
|
81
81
|
}
|
|
82
82
|
}
|