Conversation
…on contracts
runAgent(config, input, {onProgress?, interaction?, signal?}) returns a
RunResult and never rejects. RunConfig and RunInput replace the session and
program config reads, AgentProgress replaces the 58 getUI() calls, an optional
AgentInteraction replaces the getUI() answerer, and every former wizardAbort
returns as a failure with the same fields. Unexpected throws return as
outcome 'crashed' with the original error.
Gates, authenticate, token refresh, flag fetch, binding resolution and the
exit move to src/lib/programs/run-agent-legacy.ts, which maps each progress
event to one WizardUI call so every existing caller keeps its output.
PROGRAM_BINDINGS, ProgramRun and authenticate leave the agent for programs.
The architecture test forbids agent -> src/ui imports; known violations go
from 72 to 60. A standalone test runs the agent with @ui mocked to throw.
Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
🧙 Wizard CIRun the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands: Test all apps:
Test all apps in a directory:
Test an individual app:
Show more apps
Test against a Context Mill branch:
Add Results will be posted here when complete. |
|
Verified locally on the rebased commit a18d15f. Not waiting on CI.
Run log and parity table live in |
|
Logs and outputs from the local verification of a18d15f. Headless
|
|
Superseded by a trimmed cut of the same change on |
Intent
Make the agent callable as a function.
runAgent(config, input, {onProgress?, interaction?, signal?})returns aRunResult, and nothing undersrc/lib/agenttouches a screen, a session, the program registry orprocess.exit. Release A, A1′ of the functional stack plan, on top of #1288.Impact
People using the wizard. Nothing changes. Every runner still calls a session-taking
runAgent, now atsrc/lib/programs/run-agent-legacy.ts. It maps each progress event back to the sameWizardUIcall in the same order, so frames, flow traces, exit codes and error copy are byte-identical. Zero goldens regenerated.People maintaining it. The agent is sealed. The import-boundaries test refuses any
src/uiimport from it, and every ending is a result rather than an exit or a throw. Anyone writing a harness or sequence takesBackendRunInputsorSequenceContextand anemit, never a session. Anyone importingrunAgent,ProgramRun,PROGRAM_BINDINGS,bootstrapProgram,sessionToOptionsorabortOnInstallFailurefrom the agent has to re-point, and all in-tree callers already did.The map
Shaded nodes are new. Before, the gates, the UI calls and the exit all lived inside the agent's bootstrap and sequences. Now the adapter owns the left and right edges, the agent owns the middle, and the two only meet through data.
The contract
RunConfigRunInputAgentProgressgetUI()call, same order, copied payloads. A throwing observer is logged, the run continues.AgentInteractionask,cancelAsk,taskNotice,cancelTaskNotice, all optional. No answerer means no bridge, the tool says unavailable, notices decline. Same as today's CI path.RunResultoutcome,outro,failure,snapshot(tasks, status lines, stage, handoff text, URLs, token totals, cost).The five endings
outcomesuccessrunLinearProgram/runOrchestratoraborted[ABORT]wizardAbort(failure)failedwizardAbortsite, plusinstallFailureand the 401wizardAbort(failure)cancelledwizardAbort(failure), unreachable from the adaptercrashedrunner/index.tswrapping any throwfailure.error, so run-wizard's mint-failure screen and headlessclassifyRunFailuresee what they sawfailurehas the fieldswizardAborttakes (code,message,outroData,error,exitCode,detail), so the exit path receives what it always received.What moved
agent startedcapture,authenticate, AI opt-in gate, post-auth gates, flag fetch, run tags, token refresh, binding resolution, switchboard telemetry,registerCleanup, outro settings-restore hook,wizardAbortsrc/lib/programs/run-agent-legacy.tsauthenticate,refreshAccessTokenIfNeededsrc/lib/programs/authenticate.ts, body unchangedPROGRAM_BINDINGSsrc/lib/programs/bindings.tsProgramRunwith its session-taking hookssrc/lib/programs/program-run.ts, extends agentAgentRunDefinitionWizardErrorsrc/lib/errors/wizard-error.ts, re-exported fromwizard-abortTokenUsageDelta,SpinnerHandle,AuthErrorDetailsrc/lib/agent/progress.ts, re-exported fromwizard-ui.tsFour honest differences
finallyflushes the YARA report before the exit sequence instead of insiderunCleanups. Idempotent, and the printed order is unchanged.switchboard resolvedcapture instead of preceding it.getPendingQuestionused to read a forked session snapshot and was always null. It now reads bridge-side state, the guard pi already keeps.RunTaskFatalthroughdrainQueue) and the orchestrator'sfinallyruns whereprocess.exitused to skip it. In-flight sibling tasks keep running until exit, as before.Verification
pnpm typecheckpnpm lintpnpm build+vitest runagent-imports-uirule at 0run-agent-standalone.test.ts@uimocked to throw on any use, fake harness, no store, no registryPostHog set up: 7/7 steps completed (1 skipped as not required), same line as P0Full parity table and run log:
workbench/wizard-functional-evidence/a1-prime-evidence.md(local).Created with PostHog Desktop