Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions packages/framework/src/agent-driver.test.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/framework/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { basename, dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { type ClaudeCodeDriverOptions, type Driver, type DriverSession, type PermissionMode } from 'agent-driver'
import { DRIVERS, DRIVER_SPECS, isDriverName, type DriverName } from './driver-cli.js'
import { createAgentDriver } from './agent-driver.js'
import { createTargetDriver } from './target-driver.js'
import type { CloudDriverOptions } from './driver/cloud.js'
import { checkLayout } from './layout.js'
import { githubSlugFor } from './dashboard/github.js'
Expand Down Expand Up @@ -1198,7 +1198,7 @@ async function driveAgent(opts: AgentOptions, io: CliIO): Promise<number> {
const cloudConfig = opts.target === 'web' && !fake ? await extensionStartConfig(process.env) : undefined
const driver: Driver = fake
? fakeDriver()
: createAgentDriver({
: createTargetDriver({
driver: opts.driver,
claudeOpts: withBrowser(claudeOpts, opts.browser, sharedBrowser?.browserUrl),
...(opts.target ? { target: opts.target } : {}),
Expand Down
34 changes: 34 additions & 0 deletions packages/framework/src/target-driver.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { strict as assert } from 'node:assert'
import { test } from 'node:test'
import { createTargetDriver } from './target-driver.js'
import { ActionsDriver, ClaudeCodeDriver, CodexDriver } from 'agent-driver'
import { CloudDriver } from './driver/cloud.js'

// The run-target wrapper (#1050/#610): `--run-on actions` becomes an ActionsDriver (#934),
// `--run-on web` a CloudDriver; anything else falls through to the driver for the chosen CLI,
// byte-identical to before.

const ACTIONS = { owner: 'gemstack-land', repo: 'gemstack', token: 't' }

test('createTargetDriver returns an ActionsDriver for target "actions"', () => {
const driver = createTargetDriver({ driver: 'claude', target: 'actions', actionsConfig: ACTIONS })
assert.ok(driver instanceof ActionsDriver)
})

test('createTargetDriver falls through to the driver for the chosen CLI otherwise', () => {
assert.ok(createTargetDriver({ driver: 'claude' }) instanceof ClaudeCodeDriver)
assert.ok(createTargetDriver({ driver: 'claude', target: 'local' }) instanceof ClaudeCodeDriver)
assert.ok(createTargetDriver({ driver: 'codex', target: 'local' }) instanceof CodexDriver)
})

test('createTargetDriver requires the Actions config when target is "actions"', () => {
assert.throws(() => createTargetDriver({ driver: 'claude', target: 'actions' }), /needs the repo owner/)
})

test('createTargetDriver returns a CloudDriver for target "web"', () => {
assert.ok(createTargetDriver({ driver: 'claude', target: 'web' }) instanceof CloudDriver)
})

test('the web target needs no configuration: the CLI already holds the account', () => {
assert.doesNotThrow(() => createTargetDriver({ driver: 'claude', target: 'web' }))
})
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import { ActionsDriver, type ActionsDriverOptions, type Driver } from 'agent-dri
import { CloudDriver, type CloudDriverOptions } from './driver/cloud.js'

/**
* Build the {@link Driver} for an agent's *target* (#1050): where the turn runs, on top of the agent
* Build the {@link Driver} for an agent's *target* (#1050): where the turn runs, on top of the CLI
* axis {@link createDriver} owns. `actions` returns an {@link ActionsDriver} (#934) built from the
* resolved owner/repo/token; `web` returns a {@link CloudDriver} (#610), which hands the task to a
* Claude Code cloud session; anything else falls through to the local agent driver — byte-identical
* to today.
* Claude Code cloud session; anything else falls through to the driver for the chosen CLI —
* byte-identical to today.
*
* Kept off {@link createDriver} on purpose: ActionsDriver's owner/repo/token do not fit
* {@link CreateDriverOptions}, and folding them in would push GitHub config onto every local agent.
*/
export interface CreateAgentDriverOptions extends CreateDriverOptions {
export interface CreateTargetDriverOptions extends CreateDriverOptions {
/**
* Where the agent executes: `local` (this device, the default), `actions` (a GitHub Actions
* runner, #1050) or `web` (a Claude Code cloud session, #610).
Expand All @@ -26,7 +26,7 @@ export interface CreateAgentDriverOptions extends CreateDriverOptions {
}

/** The one place an agent path turns `--run-on` into a real driver. */
export function createAgentDriver(opts: CreateAgentDriverOptions): Driver {
export function createTargetDriver(opts: CreateTargetDriverOptions): Driver {
if (opts.target === 'actions') {
if (!opts.actionsConfig) {
throw new Error('run target "actions" needs the repo owner/repo and a GitHub token; set a GitHub origin remote and GH_TOKEN')
Expand Down
Loading