diff --git a/.github/workflows/mcpx.yml b/.github/workflows/mcpx.yml index 828ee48e1e..8771e5aeda 100644 --- a/.github/workflows/mcpx.yml +++ b/.github/workflows/mcpx.yml @@ -454,7 +454,7 @@ jobs: working-directory: pkgs/mcpx run: | for f in permission.test.ts picker.test.ts sampling.test.ts tool-filter.test.ts tools.test.ts v2.test.ts; do - test -f "plugin/opencode/v2/" || { echo "registered v2 test file missing: plugin/opencode/v2/"; exit 1; } + test -f "plugin/opencode/v2/$f" || { echo "registered v2 test file missing: plugin/opencode/v2/$f"; exit 1; } done bun test plugin/opencode/v2/ diff --git a/pkgs/mcpx/docs/compendium.manifest.json b/pkgs/mcpx/docs/compendium.manifest.json index 89438d2d60..d295076863 100644 --- a/pkgs/mcpx/docs/compendium.manifest.json +++ b/pkgs/mcpx/docs/compendium.manifest.json @@ -900,6 +900,13 @@ "lines": 3, "note": "docs-history change fragment for #1871 (research and incidental findings chapter); history metadata consumed by the docs-history tooling, not a compendium page" }, + { + "path": "docs/changes/research-and-findings-nix-slice.md", + "chapter": null, + "role": "not-compendium", + "lines": 3, + "note": "docs-history change fragment for #1871 (research chapter nix slice); history metadata consumed by the docs-history tooling, not a compendium page" + }, { "path": "docs/cli.md", "chapter": "designs", diff --git a/pkgs/mcpx/docs/environment.md b/pkgs/mcpx/docs/environment.md index eb3d20fe1b..00118a2581 100644 --- a/pkgs/mcpx/docs/environment.md +++ b/pkgs/mcpx/docs/environment.md @@ -90,60 +90,60 @@ and read by name for that reason. -| variable | set by | when | what it is | read by | -| --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `MCPX_SESSION` | `mcpx exec` / `mcpx run`; the exec service (`/v1/exec`, `mcpx_exec`); an event consumer | always | the session key this run's tool calls are leased under: --session, else MCPX_SESSION_ID, else one minted for the run | the generated client, which sends it with every call | -| `MCPX_SESSION_ID` | `mcpx exec` / `mcpx run`; the exec service (`/v1/exec`, `mcpx_exec`); an event consumer; the opencode plugin; the plugin loader, for a discovered plugin | the CLI passes through the value it was given, which may be empty; the plugin sets it at every plugin.env level | the session the host assigned. Unlike MCPX_SESSION it survives from one command to the next, so it is what session-scoped servers key on | `mcpx` run inside the script or shell, as its session when --session is not given | -| `MCPX_PARENT_SESSION_ID` | `mcpx exec` / `mcpx run`; an event consumer; the opencode plugin | the CLI passes through what it was given; the daemon passes the caller's parent session into a script run's environment; the plugin at plugin.env=full, when there is a parent | the session that spawned this one, so a parent agent and its subagents can share a server | `mcpx` run inside the script or shell, and the generated client for parent-session scoping | -| `MCPX_EPHEMERAL` | `mcpx exec` / `mcpx run`; the exec service (`/v1/exec`, `mcpx_exec`) | always | 1 when the session key was minted for this run alone, so its instances may be stopped as soon as it ends | the generated client | -| `MCPX_RUN` | `mcpx exec` / `mcpx run`; the exec service (`/v1/exec`, `mcpx_exec`) | always | this execution's run id, which groups the artifacts it produces | the generated client, when storing an artifact | -| `MCPX_INPUT` | `mcpx exec` / `mcpx run` | mcpx exec and mcpx run, locally and with --remote; not when mcpx serve collects the output | report: nothing in this run can answer a server's question mid-call, so a call that asks one exits 75 with the question instead of waiting for it to expire | the generated client, sent as X-Mcpx-Input | -| `MCPX_HOOK_NAME` | the declared-hook runner, for a hook it runs | always | the declared name of the hook being run | the hook itself | -| `MCPX_HOOK_PHASE` | the declared-hook runner, for a hook it runs; the exec service (`/v1/exec`, `mcpx_exec`) | always | the hook's phase; always observe for config-declared hooks, the exec hook's phase (pre, post, onError, onSuccess) for a per-call exec hook | the hook itself | -| `MCPX_HOOK_POINT` | the exec service (`/v1/exec`, `mcpx_exec`) | always | the point the hook is attached to; script for per-call exec hooks in this version | the hook itself | -| `MCPX_HOOK_ERROR` | the exec service (`/v1/exec`, `mcpx_exec`) | only for a hook running because the script failed; truncated to 1024 bytes | the error the hook is running for, in one line; the full hook context is JSON on stdin | the hook itself | -| `MCPX_HOOK_EVENT_KIND` | the declared-hook runner, for a hook it runs | always | the kind of the event the hook is running for; the full event is JSON on stdin | the hook itself | -| `MCPX_HOOK_EVENT_SEQ` | the declared-hook runner, for a hook it runs | always | the event's sequence number on the daemon's bus | the hook itself | -| `MCPX_HOOK_EVENT_SERVER` | the declared-hook runner, for a hook it runs | empty when the event names no server | the server the event is about | the hook itself | -| `MCPX_HOOK_EVENT_SESSION` | the declared-hook runner, for a hook it runs | empty when the event belongs to no session | the session the event belongs to | the hook itself | -| `MCPX_HOOK_EVENT_URI` | the declared-hook runner, for a hook it runs | empty when the event names no resource | the resource URI the event is about | the hook itself | -| `MCPX_ENDPOINT` | `mcpx exec` / `mcpx run`; the exec service (`/v1/exec`, `mcpx_exec`); an event consumer | always | the daemon's HTTP endpoint | the generated client; the plugin as a fallback for MCPX_DAEMON_ENDPOINT | -| `MCPX_SOCKET` | `mcpx exec` / `mcpx run`; the exec service (`/v1/exec`, `mcpx_exec`); the plugin loader, for a discovered plugin | empty when the daemon is remote, since its socket is not reachable from here | the daemon's unix socket, which is faster than the endpoint. Also where a daemon binds and a client dials, for anyone who sets it by hand | the generated client, `mcpx` run inside the script or shell, the plugin | -| `MCPX_TRANSPORT_BEARER_TOKEN` | `mcpx exec` / `mcpx run`; the exec service (`/v1/exec`, `mcpx_exec`); an event consumer | only when transport.bearerToken is configured | the daemon's bearer token, handed to the script so the generated client can authenticate to a daemon that requires it (#1975); the token itself stays out of the generated code | the generated client, `mcpx` run inside the script or shell, the plugin; also the setting `transport.bearerToken` | -| `MCPX_SETTINGS` | `mcpx exec` / `mcpx run`; the exec service (`/v1/exec`, `mcpx_exec`) | only when the caller sent call settings with the run (for example a requested pool.callTimeout) | the call-settings header for this run, carried into the script so the generated client forwards the caller's per-call requests on the calls it makes on the script's behalf | the generated client, which sends it as the x-mcpx-settings header | -| `MCPX_ARTIFACTS_LOCAL` | `mcpx exec` / `mcpx run`; the exec service (`/v1/exec`, `mcpx_exec`) | always | 1 when the daemon shares this filesystem, so artifact({path}) may hand over a path instead of the bytes | the generated client | -| `MCPX_CWD` | `mcpx exec` / `mcpx run`; the exec service (`/v1/exec`, `mcpx_exec`) | the exec service only when the caller sent its working directory | the directory the caller ran mcpx from, which a remote run cannot discover | the generated client (paths.cwd, and cwd scoping) | -| `MCPX_PID` | `mcpx exec` / `mcpx run`; the exec service (`/v1/exec`, `mcpx_exec`) | always | the pid of the mcpx process that started the script | the generated client, for pid scoping | -| `MCPX_ENTRY` | the runner, for every script | always | the file the runtime was started on: mcpx's generated launcher, or the script itself under --no-launcher. For exec the script is a generated file | the generated client (paths.entry) | -| `MCPX_CLIENT` | the runner, for every script | always | the generated client module | the generated client (paths.client) | -| `MCPX_CONFIG_PATH` | `mcpx exec` / `mcpx run` | always | the nearest configuration file in effect, empty when there is none | the generated client (paths.config) | -| `MCPX_PATHS_CONFIG` | `mcpx exec` / `mcpx run` | a daemon auto-started by this invocation, only when a --paths-config seed lives in this process's memory; an environment seed needs no forwarding, as the child inherits the environment | the paths.config seed this process resolved configuration discovery from, forwarded so the auto-started daemon resolves the same chain this process did | `mcpx` run inside the script or shell, in configuration discovery (a bootstrap read: paths.config decides which files the settings are read from, so there is no resolved Set to ask); also the setting `paths.config` | -| `MCPX_SCRIPT_DIRS` | `mcpx exec` / `mcpx run` | always | the directories searched for named scripts, nearest first, colon-separated | the generated client (paths.scriptDirs) | -| `MCPX_API_DECLARATION_SHA256` | `mcpx exec` / `mcpx run` | always | the fingerprint of a declared API's declaration, set on the child a declared API launches: PoolID hashes the environment, so editing the declaration replaces the pool instead of keeping a child started for the old one | the pool, as a pool identity input (api serve: PoolID hashes the server environment) | -| `MCPX_ADAPTER_DECLARATION_SHA256` | `mcpx exec` / `mcpx run` | always | the fingerprint of an adapter's declaration, set on the server an adapter launches: PoolID hashes the environment, so editing the declaration replaces the pool instead of keeping a child started for the old one | the pool, as a pool identity input (PoolID hashes the server environment); the daemon, which exempts an adapter's own exact name from the namespace-collision check when the adapter is replaced | -| `MCPX_RUNTIME` | the runner, for every script | always | deno, bun or node; on a dispatched run, the interpreter's name (sh, python3) | the generated client; on a dispatched run, the script itself | -| `MCPX_DISPATCH` | the runner, for every script | only on a dispatched (non-JavaScript) run | how the interpreter was chosen: shebang or interpreter (script.interpreter) | the script itself, and anyone reading its environment | -| `MCPX_ALLOW_READ` | the runner, for every script | only when the permissions allow reading files | 1: the client's file helpers may read. Without it they refuse, naming the permission, rather than leaving it to the sandbox | the generated client | -| `MCPX_LOG_LEVEL` | `mcpx exec` / `mcpx run` | always | the lowest level the script's log keeps | the generated client; `mcpx` run inside the script or shell reads it as logging.level; also the setting `logging.level` | -| `MCPX_LOG_SOURCE` | `mcpx exec` / `mcpx run` | always | which levels record a call site: a level name for that level and above, 0 for none | the generated client | -| `MCPX_DAEMON_ENDPOINT` | the opencode plugin | plugin.env=standard or above, once the plugin has chosen a daemon | the daemon this editor session settled on, so a shell command that runs mcpx talks to the same one instead of looking for its own | `mcpx` run inside the script or shell, as daemon.endpoint; the plugin, as the daemon to use; also the setting `daemon.endpoint` | -| `MCPX_TRACE_IDS` | the opencode plugin | plugin.env=standard or above, when there is anything to say | JSON pairs such as [["session_id","abc"],["worktree","/p"]], extended at full with the parent session and the whole ancestry | `mcpx` run inside the script or shell, which puts every pair on every log record | -| `MCPX_CALL_ID` | the opencode plugin | plugin.env=standard or above | the editor's id for this one tool call | the command | -| `MCPX_OPENCODE_CWD` | the opencode plugin | plugin.env=standard or above | the directory the command runs in, which is not always the project root | the command | -| `MCPX_OPENCODE_DIRECTORY` | the opencode plugin | plugin.env=standard or above | the project directory the editor opened | the command | -| `MCPX_OPENCODE_WORKTREE` | the opencode plugin | plugin.env=standard or above | the project's worktree | the command | -| `MCPX_WORKTREE_NAME` | the opencode plugin | plugin.env=standard or above, when there is a worktree | the worktree's last path element | the command | -| `MCPX_PROJECT_ID` | the opencode plugin | plugin.env=standard or above | the editor's project id | the command | -| `MCPX_HARNESS` | the opencode plugin | plugin.env=standard or above | opencode | the command | -| `MCPX_HARNESS_VERSION` | the opencode plugin | plugin.env=standard or above | the editor's version | the command | -| `MCPX_HARNESS_PID` | the opencode plugin | plugin.env=standard or above | the editor's pid | the command | -| `MCPX_HARNESS_STARTED` | the opencode plugin | plugin.env=standard or above | when the plugin started | the command | -| `MCPX_SHELL_SEQ` | the opencode plugin | plugin.env=standard or above | a counter of shell commands in this editor process | the command | -| `MCPX_SESSION_TITLE` | the opencode plugin | plugin.env=full | the session's title | the command | -| `MCPX_SESSION_DIRECTORY` | the opencode plugin | plugin.env=full | the session's directory | the command | -| `MCPX_SESSION_VERSION` | the opencode plugin | plugin.env=full | the editor version that created the session | the command | -| `MCPX_SESSION_DEPTH` | the opencode plugin | plugin.env=full | how many parents the session has | the command | -| `MCPX_SESSION_CREATED` | the opencode plugin | plugin.env=full, when known | when the session was created, ISO 8601 | the command | -| `MCPX_SESSION_AGE_MS` | the opencode plugin | plugin.env=full, when known | the session's age when the command started, in milliseconds | the command | +| variable | set by | when | what it is | read by | +| --- | --- | --- | --- | --- | +| `MCPX_SESSION` | `mcpx exec` / `mcpx run`; the exec service (`/v1/exec`, `mcpx_exec`); an event consumer | always | the session key this run's tool calls are leased under: --session, else MCPX_SESSION_ID, else one minted for the run | the generated client, which sends it with every call | +| `MCPX_SESSION_ID` | `mcpx exec` / `mcpx run`; the exec service (`/v1/exec`, `mcpx_exec`); an event consumer; the opencode plugin; the plugin loader, for a discovered plugin | the CLI passes through the value it was given, which may be empty; the plugin sets it at every plugin.env level | the session the host assigned. Unlike MCPX_SESSION it survives from one command to the next, so it is what session-scoped servers key on | `mcpx` run inside the script or shell, as its session when --session is not given | +| `MCPX_PARENT_SESSION_ID` | `mcpx exec` / `mcpx run`; an event consumer; the opencode plugin | the CLI passes through what it was given; the daemon passes the caller's parent session into a script run's environment; the plugin at plugin.env=full, when there is a parent | the session that spawned this one, so a parent agent and its subagents can share a server | `mcpx` run inside the script or shell, and the generated client for parent-session scoping | +| `MCPX_EPHEMERAL` | `mcpx exec` / `mcpx run`; the exec service (`/v1/exec`, `mcpx_exec`) | always | 1 when the session key was minted for this run alone, so its instances may be stopped as soon as it ends | the generated client | +| `MCPX_RUN` | `mcpx exec` / `mcpx run`; the exec service (`/v1/exec`, `mcpx_exec`) | always | this execution's run id, which groups the artifacts it produces | the generated client, when storing an artifact | +| `MCPX_INPUT` | `mcpx exec` / `mcpx run` | mcpx exec and mcpx run, locally and with --remote; not when mcpx serve collects the output | report: nothing in this run can answer a server's question mid-call, so a call that asks one exits 75 with the question instead of waiting for it to expire | the generated client, sent as X-Mcpx-Input | +| `MCPX_HOOK_NAME` | the declared-hook runner, for a hook it runs | always | the declared name of the hook being run | the hook itself | +| `MCPX_HOOK_PHASE` | the declared-hook runner, for a hook it runs; the exec service (`/v1/exec`, `mcpx_exec`) | always | the hook's phase; always observe for config-declared hooks, the exec hook's phase (pre, post, onError, onSuccess) for a per-call exec hook | the hook itself | +| `MCPX_HOOK_POINT` | the exec service (`/v1/exec`, `mcpx_exec`) | always | the point the hook is attached to; script for per-call exec hooks in this version | the hook itself | +| `MCPX_HOOK_ERROR` | the exec service (`/v1/exec`, `mcpx_exec`) | only for a hook running because the script failed; truncated to 1024 bytes | the error the hook is running for, in one line; the full hook context is JSON on stdin | the hook itself | +| `MCPX_HOOK_EVENT_KIND` | the declared-hook runner, for a hook it runs | always | the kind of the event the hook is running for; the full event is JSON on stdin | the hook itself | +| `MCPX_HOOK_EVENT_SEQ` | the declared-hook runner, for a hook it runs | always | the event's sequence number on the daemon's bus | the hook itself | +| `MCPX_HOOK_EVENT_SERVER` | the declared-hook runner, for a hook it runs | empty when the event names no server | the server the event is about | the hook itself | +| `MCPX_HOOK_EVENT_SESSION` | the declared-hook runner, for a hook it runs | empty when the event belongs to no session | the session the event belongs to | the hook itself | +| `MCPX_HOOK_EVENT_URI` | the declared-hook runner, for a hook it runs | empty when the event names no resource | the resource URI the event is about | the hook itself | +| `MCPX_ENDPOINT` | `mcpx exec` / `mcpx run`; the exec service (`/v1/exec`, `mcpx_exec`); an event consumer | always | the daemon's HTTP endpoint | the generated client; the plugin as a fallback for MCPX_DAEMON_ENDPOINT | +| `MCPX_SOCKET` | `mcpx exec` / `mcpx run`; the exec service (`/v1/exec`, `mcpx_exec`); the plugin loader, for a discovered plugin | empty when the daemon is remote, since its socket is not reachable from here | the daemon's unix socket, which is faster than the endpoint. Also where a daemon binds and a client dials, for anyone who sets it by hand | the generated client, `mcpx` run inside the script or shell, the plugin | +| `MCPX_TRANSPORT_BEARER_TOKEN` | `mcpx exec` / `mcpx run`; the exec service (`/v1/exec`, `mcpx_exec`); an event consumer | only when transport.bearerToken is configured | the daemon's bearer token, handed to the script so the generated client can authenticate to a daemon that requires it (#1975); the token itself stays out of the generated code | the generated client, `mcpx` run inside the script or shell, the plugin; also the setting `transport.bearerToken` | +| `MCPX_SETTINGS` | `mcpx exec` / `mcpx run`; the exec service (`/v1/exec`, `mcpx_exec`) | only when the caller sent call settings with the run (for example a requested pool.callTimeout) | the call-settings header for this run, carried into the script so the generated client forwards the caller's per-call requests on the calls it makes on the script's behalf | the generated client, which sends it as the x-mcpx-settings header | +| `MCPX_ARTIFACTS_LOCAL` | `mcpx exec` / `mcpx run`; the exec service (`/v1/exec`, `mcpx_exec`) | always | 1 when the daemon shares this filesystem, so artifact({path}) may hand over a path instead of the bytes | the generated client | +| `MCPX_CWD` | `mcpx exec` / `mcpx run`; the exec service (`/v1/exec`, `mcpx_exec`) | the exec service only when the caller sent its working directory | the directory the caller ran mcpx from, which a remote run cannot discover | the generated client (paths.cwd, and cwd scoping) | +| `MCPX_PID` | `mcpx exec` / `mcpx run`; the exec service (`/v1/exec`, `mcpx_exec`) | always | the pid of the mcpx process that started the script | the generated client, for pid scoping | +| `MCPX_ENTRY` | the runner, for every script | always | the file the runtime was started on: mcpx's generated launcher, or the script itself under --no-launcher. For exec the script is a generated file | the generated client (paths.entry) | +| `MCPX_CLIENT` | the runner, for every script | always | the generated client module | the generated client (paths.client) | +| `MCPX_CONFIG_PATH` | `mcpx exec` / `mcpx run` | always | the nearest configuration file in effect, empty when there is none | the generated client (paths.config) | +| `MCPX_PATHS_CONFIG` | `mcpx exec` / `mcpx run` | a daemon auto-started by this invocation, only when a --paths-config seed lives in this process's memory; an environment seed needs no forwarding, as the child inherits the environment | the paths.config seed this process resolved configuration discovery from, forwarded so the auto-started daemon resolves the same chain this process did | `mcpx` run inside the script or shell, in configuration discovery (a bootstrap read: paths.config decides which files the settings are read from, so there is no resolved Set to ask); also the setting `paths.config` | +| `MCPX_SCRIPT_DIRS` | `mcpx exec` / `mcpx run` | always | the directories searched for named scripts, nearest first, colon-separated | the generated client (paths.scriptDirs) | +| `MCPX_API_DECLARATION_SHA256` | `mcpx exec` / `mcpx run` | always | the fingerprint of a declared API's declaration, set on the child a declared API launches: PoolID hashes the environment, so editing the declaration replaces the pool instead of keeping a child started for the old one | the pool, as a pool identity input (api serve: PoolID hashes the server environment) | +| `MCPX_ADAPTER_DECLARATION_SHA256` | `mcpx exec` / `mcpx run` | always | the fingerprint of an adapter's declaration, set on the server an adapter launches: PoolID hashes the environment, so editing the declaration replaces the pool instead of keeping a child started for the old one | the pool, as a pool identity input (PoolID hashes the server environment); the daemon, which exempts an adapter's own exact name from the namespace-collision check when the adapter is replaced | +| `MCPX_RUNTIME` | the runner, for every script | always | deno, bun or node; on a dispatched run, the interpreter's name (sh, python3) | the generated client; on a dispatched run, the script itself | +| `MCPX_DISPATCH` | the runner, for every script | only on a dispatched (non-JavaScript) run | how the interpreter was chosen: shebang or interpreter (script.interpreter) | the script itself, and anyone reading its environment | +| `MCPX_ALLOW_READ` | the runner, for every script | only when the permissions allow reading files | 1: the client's file helpers may read. Without it they refuse, naming the permission, rather than leaving it to the sandbox | the generated client | +| `MCPX_LOG_LEVEL` | `mcpx exec` / `mcpx run` | always | the lowest level the script's log keeps | the generated client; `mcpx` run inside the script or shell reads it as logging.level; also the setting `logging.level` | +| `MCPX_LOG_SOURCE` | `mcpx exec` / `mcpx run` | always | which levels record a call site: a level name for that level and above, 0 for none | the generated client | +| `MCPX_DAEMON_ENDPOINT` | the opencode plugin | plugin.env=standard or above, once the plugin has chosen a daemon | the daemon this editor session settled on, so a shell command that runs mcpx talks to the same one instead of looking for its own | `mcpx` run inside the script or shell, as daemon.endpoint; the plugin, as the daemon to use; also the setting `daemon.endpoint` | +| `MCPX_TRACE_IDS` | the opencode plugin | plugin.env=standard or above, when there is anything to say | JSON pairs such as [["session_id","abc"],["worktree","/p"]], extended at full with the parent session and the whole ancestry | `mcpx` run inside the script or shell, which puts every pair on every log record | +| `MCPX_CALL_ID` | the opencode plugin | plugin.env=standard or above | the editor's id for this one tool call | the command | +| `MCPX_OPENCODE_CWD` | the opencode plugin | plugin.env=standard or above | the directory the command runs in, which is not always the project root | the command | +| `MCPX_OPENCODE_DIRECTORY` | the opencode plugin | plugin.env=standard or above | the project directory the editor opened | the command | +| `MCPX_OPENCODE_WORKTREE` | the opencode plugin | plugin.env=standard or above | the project's worktree | the command | +| `MCPX_WORKTREE_NAME` | the opencode plugin | plugin.env=standard or above, when there is a worktree | the worktree's last path element | the command | +| `MCPX_PROJECT_ID` | the opencode plugin | plugin.env=standard or above | the editor's project id | the command | +| `MCPX_HARNESS` | the opencode plugin | plugin.env=standard or above | opencode | the command | +| `MCPX_HARNESS_VERSION` | the opencode plugin | plugin.env=standard or above | the editor's version | the command | +| `MCPX_HARNESS_PID` | the opencode plugin | plugin.env=standard or above | the editor's pid | the command | +| `MCPX_HARNESS_STARTED` | the opencode plugin | plugin.env=standard or above | when the plugin started | the command | +| `MCPX_SHELL_SEQ` | the opencode plugin | plugin.env=standard or above | a counter of shell commands in this editor process | the command | +| `MCPX_SESSION_TITLE` | the opencode plugin | plugin.env=full | the session's title | the command | +| `MCPX_SESSION_DIRECTORY` | the opencode plugin | plugin.env=full | the session's directory | the command | +| `MCPX_SESSION_VERSION` | the opencode plugin | plugin.env=full | the editor version that created the session | the command | +| `MCPX_SESSION_DEPTH` | the opencode plugin | plugin.env=full | how many parents the session has | the command | +| `MCPX_SESSION_CREATED` | the opencode plugin | plugin.env=full, when known | when the session was created, ISO 8601 | the command | +| `MCPX_SESSION_AGE_MS` | the opencode plugin | plugin.env=full, when known | the session's age when the command started, in milliseconds | the command | diff --git a/pkgs/mcpx/internal/cli/ssh_endpoint_test.go b/pkgs/mcpx/internal/cli/ssh_endpoint_test.go index 37ea4d22f5..a6d49cc66a 100644 --- a/pkgs/mcpx/internal/cli/ssh_endpoint_test.go +++ b/pkgs/mcpx/internal/cli/ssh_endpoint_test.go @@ -14,6 +14,7 @@ import ( "github.com/developing-today/code/pkgs/mcpx/internal/daemon" "github.com/developing-today/code/pkgs/mcpx/internal/events" + "github.com/developing-today/code/pkgs/mcpx/internal/testsupport" ) // The ssh transport runs the system ssh binary. These tests put a fake @@ -78,7 +79,7 @@ func shimSSH(t *testing.T, sock, logPath string) { // health check and a server-sent event stream. func testSocketServer(t *testing.T) string { t.Helper() - sock := filepath.Join(t.TempDir(), "daemon.sock") + sock := filepath.Join(testsupport.SocketDir(t), "daemon.sock") ln, err := net.Listen("unix", sock) if err != nil { t.Fatal(err) diff --git a/pkgs/mcpx/internal/daemon/authz_test.go b/pkgs/mcpx/internal/daemon/authz_test.go index e197a9c302..3f6d09a69d 100644 --- a/pkgs/mcpx/internal/daemon/authz_test.go +++ b/pkgs/mcpx/internal/daemon/authz_test.go @@ -11,12 +11,13 @@ import ( "testing" "github.com/developing-today/code/pkgs/mcpx/internal/api" + "github.com/developing-today/code/pkgs/mcpx/internal/testsupport" ) // A unix-socket connection's principal carries the peer uid the kernel // reports — on this machine, the test process's own uid. func TestPrincipalForUnixConnReadsPeerUID(t *testing.T) { - socket := filepath.Join(t.TempDir(), "probe.sock") + socket := filepath.Join(testsupport.SocketDir(t), "probe.sock") ln, err := net.Listen("unix", socket) if err != nil { t.Fatal(err) diff --git a/pkgs/mcpx/internal/daemon/paths_resolve_test.go b/pkgs/mcpx/internal/daemon/paths_resolve_test.go index f9921766b6..112e2475c1 100644 --- a/pkgs/mcpx/internal/daemon/paths_resolve_test.go +++ b/pkgs/mcpx/internal/daemon/paths_resolve_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/developing-today/code/pkgs/mcpx/internal/daemon" + "github.com/developing-today/code/pkgs/mcpx/internal/testsupport" ) // longState returns a state directory whose in-state socket path exceeds @@ -138,7 +139,7 @@ func TestRelocated(t *testing.T) { if preferred != filepath.Join(state, "daemon-abcdef123456.sock") { t.Fatalf("preferred = %q", preferred) } - short := daemon.Paths{State: t.TempDir()}.ForConfig("abcdef123456") + short := daemon.Paths{State: testsupport.SocketDir(t)}.ForConfig("abcdef123456") if _, relocated := short.Relocated(); relocated { t.Fatal("short state path must not report relocation") } diff --git a/pkgs/mcpx/internal/e2e/envguard_test.go b/pkgs/mcpx/internal/e2e/envguard_test.go index 9fa29f9dad..c4554ce0b2 100644 --- a/pkgs/mcpx/internal/e2e/envguard_test.go +++ b/pkgs/mcpx/internal/e2e/envguard_test.go @@ -264,6 +264,7 @@ var safeMCPX = map[string]struct{}{ "MCPX_SCRIPT_IMPORTS_ON_DYNAMIC": {}, "MCPX_SCRIPT_IMPORTS_ON_MISSING": {}, "MCPX_SCRIPT_LAUNCHER": {}, + "MCPX_SCRIPT_LANGUAGE": {}, "MCPX_SCRIPT_ON_ERROR": {}, "MCPX_SCRIPT_ON_SUCCESS": {}, "MCPX_SCRIPT_PREFIX": {}, diff --git a/pkgs/mcpx/internal/runner/dispatch_test.go b/pkgs/mcpx/internal/runner/dispatch_test.go index 698f883454..dcd26bb41a 100644 --- a/pkgs/mcpx/internal/runner/dispatch_test.go +++ b/pkgs/mcpx/internal/runner/dispatch_test.go @@ -814,6 +814,13 @@ func TestDispatchedWorkdirPolicyAllocatesARunnerDirectory(t *testing.T) { t.Fatalf("Run(workdir dispatch): %v (stderr %q)", err, stderr.String()) } got := strings.TrimSpace(stdout.String()) + // The child reports its physical working directory (pwd resolves + // symlinks), while t.TempDir hands back the unresolved path: on + // macOS /var is a symlink to /private/var, so compare against the + // resolved root or this fails on every Mac (#10487). + if resolved, err := filepath.EvalSymlinks(root); err == nil { + root = resolved + } if got == "" || !strings.HasPrefix(got, root) { t.Fatalf("dispatched workdir run executed in %q, want a directory under WorkRoot %q", got, root) }