Repository navigation
feat: load hosted agent drivers through a contract package - #3686
Merged
Merged
Conversation
Collaborator
Author
|
Human review: unapproved changes in protected areas at f8a29b2.
|
Collaborator
Author
|
Human review: unapproved changes in protected areas at 0adbc03.
|
Add @stim-cli/agent-driver, the contract stim-server uses to start the tool a client's coding agent drives hosted apps with: apiVersion 1, id, createAgentDriver, optional client and actions capabilities, a loader that never throws, and runAgentDriverContract. Move the agent-device adapter into @stim-cli/agent-driver-agent-device with no behavior change. stim-server and the CLI resolve drivers from a registry of the first-party packages they depend on instead of comparing hosting.agentDriver to agent-device. Grants and access records carry any driver name; a lease stays validated when present. Archived agent actions come from each driver's actions reader. Refs #3682
A session no registered driver ran in no longer fails to stop when hosting.agentDriver names an unknown driver. Tests cover the notice for an unknown setting and teardown by the claim root a session has. Refs #3682
Remove every first-party driver's client config file from a static list, so a driver package that does not load cannot leave its token file behind. The module loader catches errors from its own checks, and the driver loader refuses a factory that returns a promise. The contract kit turns a throwing or silent forward() and a listener error into a failed check and closes its connections. Refs #3682.
janicduplessis
force-pushed
the
feat/pluggable-agent-drivers
branch
from
October 13, 2026 15:18
0adbc03 to
d54ebbd
Compare
Collaborator
Author
|
Human review: unapproved changes in protected areas at d54ebbd.
|
janicduplessis
marked this pull request as ready for review
October 13, 2026 15:22
janicduplessis
enabled auto-merge
October 13, 2026 15:22
This was referenced Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
stim-server's hosted agent driver is selected by a hard-coded
hosting.agentDriver === 'agent-device'check. agent-device's name is also baked into the grant union in core, the client's remote config writer and the archived action reader. Adding a second tool means editing all of them. Design: docs/specs/2026-10-13-pluggable-agent-drivers-design.md.Solution
@stim-cli/agent-driveris a contract-only package, modeled on@stim-cli/cache:apiVersion: 1,idandcreateAgentDriver({ env, stateDir, claimRoot, device }), which returns the existingHostedAgentDriver. The host keeps every policy decision: grants, the tailnet node pin, restarts and teardown.clientturns a grant into a 0600 file plus a command that never carries the token, andactionsreads the driver's recorded actions.apiVersionorid, a module whose checks throw, or a throwing factory comes back asunavailable. A factory must return the driver itself; one that returns a promise is refused.runAgentDriverContractis a test kit for driver authors.@stim-cli/agent-driver-agent-deviceholds the oldagent-device-driver.ts, moved without behavior changes. Its client writes the sameagent-device-remote.json, and its actions reader readsagent-device/sessionsas before, so existing archives still read.src/agent-drivers.ts) and in the CLI replace the hard-coded check.HOSTED_AGENT_DRIVERSis still['none', 'agent-device'].nonewith a notice.agent-device-remote.json) statically. Removing access deletes those files even when a driver package fails to load, asmaindid, so a broken install never leaves a token file behind.Argent
Argent (
@swmansion/argent0.28.0) is researched and not shipped. The design doc has the details. Its transport fits: token-checked HTTP, loopback-only Host, and a remote client throughARGENT_TOOLS_URL. It can't be confined to one hosted device, though:DYLD_INSERT_LIBRARIESinto every booted simulator in the default set. Stim's simulators live in that set, so one hosted session would change other clients' simulators and the user's own.list-devicesandboot-devicereach the whole Mac.Once Argent can serve a single device, adding it is one package plus its name in the two registries and in
HOSTED_AGENT_DRIVERS.Risk
@stim-cli/agent-driverand@stim-cli/agent-driver-agent-deviceneed placeholder publications and trusted publishers. Follow "First publication of a NEW package" in docs/release-recovery.md.Test plan
packages/agent-driver-agent-device/__tests__/contract.test.ts. The moved driver tests are in__tests__/driver.test.ts.packages/agent-driver/__tests__/loader.test.ts: a BigIntapiVersion, a throwing getter, a factory returning a rejected promise (no unhandled rejection), and the kit failing a driver that reports a missing tool as a plain error, or whoseforward()throws or never answers.packages/stim-cli/src/__tests__/hosted-agent-access.test.ts: removing access deletesagent-device-remote.jsonwhen the agent-device package fails to import.packages/server/__tests__/agent-drivers.test.ts: an unknownhosting.agentDrivergivesnonewith a notice. Stopping a session uses the claim root's driver after the setting changes.agent-device-*.compat.test.tsfiles, whose imports changed, because there was no device hardware; the Desktopserver-runtime.mjsbundle; and the full e2e suite.Fixes #3682