From 54db4583e66134010375a1fa94256f36034ffdff Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Thu, 25 Jun 2026 12:22:41 +0900 Subject: feat(ssh): wave 1 — ExecBackend + computer data model + runtime threading MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wave 1 of transparent SSH support (parallel owner-agents on disjoint packages, plus the orchestrator-authored kernel contract seam from wave 0): - packages/wire: + Computer/ComputerEntry (read-only view over ~/.ssh/config Host aliases) + Workspace.defaultComputerId (string|null, null=local). Types only; 3 conformance tests. - packages/exec-backend (NEW core extension): the ExecBackend abstraction (spawn + minimal fs surface) the bundled tools will program against instead of node:fs/child_process. LocalExecBackend wraps today's node calls (behavior-identical; node:fs-style .code errors). execBackendHandle + ExecBackendResolver (sync; computerId undefined -> local; set -> throws until the ssh package wires remote resolution in wave 5). 20 tests. - packages/kernel (runtime only): thread computerId through dispatch.ts + run-turn.ts exactly as cwd is threaded (opaque, forwarded to ToolExecuteContext; absent = local = byte-identical to today). +2 tests. - packages/conversation-store: computer (SSH alias) assignment + resolution mirroring cwd — WorkspaceRow.defaultComputerId + setWorkspaceDefaultComputerId + getComputerId/setComputerId/clearComputerId + getEffectiveComputer (override -> per-conv -> workspace default -> null/local). Fixes the 3 Workspace literal sites the new required wire field broke. +18 tests. - orchestrator: root tsconfig.json ref for exec-backend + bun install. Verified: tsc -b EXIT 0, biome clean, 1592 vitest pass (was 1549, +43). Refs: notes/ssh-support-plan.md (decisions §0.5/§13). No merge or push. --- packages/exec-backend/src/service.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 packages/exec-backend/src/service.ts (limited to 'packages/exec-backend/src/service.ts') diff --git a/packages/exec-backend/src/service.ts b/packages/exec-backend/src/service.ts new file mode 100644 index 0000000..81ea5fa --- /dev/null +++ b/packages/exec-backend/src/service.ts @@ -0,0 +1,27 @@ +import { defineService } from "@dispatch/kernel"; +import type { ExecBackend } from "./backend.js"; + +/** + * Resolve an `ExecBackend` for a given computer. + * + * - `computerId` **undefined** → local (today's behavior; `LocalExecBackend`). + * - `computerId` **set** → remote (SSH; wired by `host-bin` + the `ssh` package + * in a later wave — the `SshExecBackend` implements the same `ExecBackend` + * interface). + * + * The resolver is SYNCHRONOUS by design: it returns a backend whose methods are + * async, so any remote connection acquisition happens lazily inside the first + * backend method call, not at resolver-call time. This keeps the resolver + * side-effect-free — merely resolving a backend never opens a connection; only + * when a tool actually executes does the (remote) backend connect. + */ +export type ExecBackendResolver = (computerId?: string) => ExecBackend; + +/** + * Typed service handle for the `ExecBackend` resolver. + * + * The `exec-backend` extension provides this via `host.provideService`. + * Tool extensions resolve their per-call backend from it (injected at + * activation by `host-bin`). + */ +export const execBackendHandle = defineService("exec-backend/resolver"); -- cgit v1.2.3