Skip to content

docs(programs): B5 docs-only — runProgram and developer interfaces - #1309

Merged
gewenyu99 merged 54 commits into
posthog/functional-b-host-capabilitiesfrom
posthog/functional-b4-api-reference
Sep 25, 2026
Merged

gewenyu99 merged 54 commits into
posthog/functional-b-host-capabilitiesfrom
posthog/functional-b4-api-reference

Conversation

@gewenyu99

@gewenyu99 gewenyu99 commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Scope: Docs only, plus the two quack examples.

Related: #1320

Do a quack

The code: run-program-quack.ts calls runProgram and run-agent-quack.ts calls runAgent. Each runs one prompt that replies quack.

Both passed on the local stack, running #1363's head (486657dc) with this PR's examples.

npx tsx --tsconfig tsconfig.json docs/examples/run-agent-quack.ts
npx tsx --tsconfig tsconfig.json docs/examples/run-program-quack.ts
$ npx tsx --tsconfig tsconfig.json docs/examples/run-agent-quack.ts
activity: quack
transcriptTail: quack
quack
outcome: success

$ npx tsx --tsconfig tsconfig.json docs/examples/run-program-quack.ts
lifecycle: started
reply: quack
quack
outcome: success

The docs for runProgram and runAgent, and short READMEs for programs, the agent and the runner. Code is unchanged: apart from the two quack examples and a tsconfig.json include that typechecks them, every file equals #1357.

Stack: #1306 moves → #1307 surface shell → #1308 plumbing → #1357 runner context → #1309 docs → #1363 stream retry.

  • Developer interfaces: the four ways to run the wizard, one diagram, and for runProgram and runAgent what each is for, its signature, a field table and a runnable quack example.
  • Programs, agent and runner READMEs: what goes in and out, where things live, and a ⚠️ banner for what changes by the end of the refactor.
  • AGENTS.md: corrected paths, DEFAULT_BINDING is Pi + linear, and program callbacks use their runner context.
Checks

Checks at 3844eb8e: pnpm typecheck and pnpm lint (0 errors) pass, with the quack examples included. Only Markdown changed since. At d1ed52c4, pnpm vitest run (3,433 tests, the same as #1357) and pnpm test:arch (11 tests) passed.

Created with PostHog Desktop

Document callable agent and program contracts, development CI invocation, outcomes, cancellation, and current headless limits.

Generated-By: PostHog Desktop

Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
@github-actions

Copy link
Copy Markdown

🧙 Wizard CI

Run 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:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci ai-observability
  • /wizard-ci basic-integration
  • /wizard-ci mcp-analytics
  • /wizard-ci replay-vision
  • /wizard-ci revenue
  • /wizard-ci self-driving
  • /wizard-ci warehouse
  • /wizard-ci warehouse-seeded

Test an individual app:

  • /wizard-ci ai-observability/anthropic
  • /wizard-ci ai-observability/google-adk
  • /wizard-ci ai-observability/groq
Show more apps
  • /wizard-ci ai-observability/manual-capture
  • /wizard-ci ai-observability/openai
  • /wizard-ci ai-observability/openai-agents
  • /wizard-ci ai-observability/opentelemetry
  • /wizard-ci ai-observability/vercel-ai
  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/flutter
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci replay-vision/javascript-node
  • /wizard-ci replay-vision/next-js
  • /wizard-ci replay-vision/react-vite
  • /wizard-ci revenue/stripe
  • /wizard-ci self-driving/astro
  • /wizard-ci self-driving/fastapi
  • /wizard-ci self-driving/nuxt
  • /wizard-ci self-driving/react-router
  • /wizard-ci self-driving/sveltekit
  • /wizard-ci warehouse/monorepo-env
  • /wizard-ci warehouse/multi-source-next
  • /wizard-ci warehouse/stripe-node
  • /wizard-ci warehouse/zero-source
  • /wizard-ci warehouse-seeded/next-stripe
  • /wizard-ci warehouse-seeded/next-stripe-declined

Test against a Context Mill branch:

  • /wizard-ci all context-mill:my-branch

Add context-mill:<branch> to any command above to pin the Context Mill branch. It defaults to main.

Results will be posted here when complete.

@gewenyu99

Copy link
Copy Markdown
Collaborator Author

B4 docs review: start with Non-interactive developer interfaces, then the program API reference and agent API reference. They cover contracts, inputs/options, outputs, invocation, cancellation, development CI, and current limits without TUI usage instructions. Validation: pnpm typecheck, focused host/agent tests (48/48), architecture tests (11/11), formatting of the new reference pages, and local link checks.

Generated-By: PostHog Desktop

Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Generated-By: PostHog Desktop

Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
…4-api-reference

# Conflicts:
#	src/agent/README.md
@gewenyu99 gewenyu99 changed the title docs(programs): WIP non-TUI developer API reference docs(programs): document non-TUI developer interfaces Sep 22, 2026
Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Merge posthog/functional-b3-parity (1acd24b) into B4. The conflicts are
in the agent and runner READMEs. B4's wording and ownership map stay, and
statements the A3 fix made untrue are corrected:

- Every failure carries a code and a message.
- A host cancellation keeps a failure the run already decided.
- The orchestrator cancels siblings after the first fatal task.
- The scan-report flush no longer rejects the promise.

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Two histories merged A3 and the B3 ancestry into B4 independently. This
keeps the remote B4 resolution (fa7f08b). The next merge brings the
joined B3, with the surface e2e routes.

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
B4 is now the joined B3 plus B4's own docs and runner comment changes.
The e2e swap is restored after the previous join commit took the remote
tree: the jest suite, `run-live.ts` and `bin/test-e2e` are gone, and the
three `test:e2e:*` routes and their scripts are back.

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
…point to the reference hosts

- The developer interfaces said external host callbacks may reject the
  runProgram promise. Credential, approval and composition callback
  rejections resolve as `failed`. Only an unexpected invocation error
  rejects.
- The programs reference said workflow requests receive the signal. Only
  the no-agent `workflow` does. `compositionWorkflow.confirmStep` does not,
  and its rejection during an abort returns `failed`.
- The agent and program sections now name their runnable reference hosts,
  `pnpm test:e2e:agent` and `pnpm test:e2e:programs`, and the environment
  they read.
- The agent reference lists `OutroKind` among the runtime exports.

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
…erence

Brings the final Release A, through B1–B3, into the API reference. The
agent reference keeps B4's fuller text and now states A's contract:
- `ask` and `taskNotice` take `{ signal }`, one signal per request;
- `Aborted` means only a host cancel;
- an agent's own `[ABORT]` returns `Failed`;
- the host sends terminal analytics, with the status its outcome names;
- `AgentErrorType` is listed with the runtime exports.

The runner README's flow and the runner header say the agent sends no
terminal analytics.

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
…erence

Brings B3 at fbddbb2, which carries all of B2's WP3, into the API
reference. The conflicts keep B4's fuller text and take these contract facts
from B3:
- `RunConfig.scanReport`, where `defer` leaves the scan report to the host
  run;
- the snapshot's transcript tail when the run definition sets
  `collectTranscript`;
- the smaller runtime export list: `DEFAULT_AGENT_BINDING`, `resolveHarness`,
  `harnessRunsTasks`, `AgentSignals`, `WIZARD_TOOL_NAMES`, `OutroKind`,
  `downloadSkill` and `runMcpPromptViaSdk`;
- runProgram resolves credentials through a host provider, awaits the host's
  gates and loads flags, and the legacy adapter supplies those capabilities
  from the session;
- the switchboard holds the registries and `resolveHarness`, and programs own
  the sequence precedence in `resolveProgramBinding`;
- the scan report flushes once, at the end or earlier on a process drain,
  and its line arrives as `log` progress;
- every host reaches runAgent through runProgram, and a standalone caller
  builds the config and input itself.

The runner README is Prettier-formatted. The rest of the pre-WP3 wording in
the developer interfaces and the programs README is left for B4-10.

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
…erence

Bring B3's programs reference and the deck registry comment into B4. The
programs README was added on both sides. The resolution takes B3's
Signatures, Intent and Architecture structure, which describes the current
contracts, and keeps the B4 detail that is still true: the link from
createPosthogInferenceAuthProvider to the inference authentication section,
the note that the development --ci runner passes a fixed gateway token, and
the closing pointer to the developer interfaces guide. The guide's link to
the old "Inputs and capabilities" anchor now points to the new Inputs
section.

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Bring the developer interfaces guide and the agent and runner READMEs in line
with the code. The callable program section now covers the two ways to supply
credentials, with the provider's resolve(programId, { signal }) called once
per invocation. It says runProgram identifies the user, stamps the AI SDK
evidence and refreshes a token near expiry, resolves the binding from
input.overrides, and copies its input. It lists which capabilities receive
the signal, including the workflow connector's step, and the example narrows
on the ProgramProgress kind. A new Preflight section describes the shared
readiness and settings checks. Both surfaces now say they send no terminal
analytics, and the CI section says detection runs through its own runAgent
call.

The agent README adds the collectTranscript tail and requestRemark options,
spells out scanReport: 'defer', lists the ten @agent runtime names, passes the
per-request signal in the ask example, and names agentic detection as a
direct runAgent caller. The runner README moves credential resolution,
stamping, refresh, overrides and the switchboard decision into runProgram and
starts the flow with preflight.

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
…erence

Kept B4's rewritten agent, runner and programs READMEs, and took the trimmed
B2 contracts where they conflict: the programs entry table drops the
test-only policy re-exports, ProgramInput loses mcp, and the agent README
keeps B3's failed-run skill cleanup bullet and now counts eleven entry
names, including TASK_OUTCOMES_KEY. developer-interfaces.md now describes
settledRuns and diagnostics instead of final progress, names noAgentWorkflow
in place of the MCP port, drops the duplicate-runId and throwing-run-definition
rejections, and points both reference hosts at the wizard-workbench harness.
The programs README lists the new run order, with flags, run definition and
refresh before the file watchers.

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
…b4-api-reference

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
…nges

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
…b4-api-reference

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
…b4-api-reference

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
…d the TUI line

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
@gewenyu99
gewenyu99 added this pull request to stack #1362 September 25, 2026 15:16
Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589

@gewenyu99 gewenyu99 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥸 Reviewed by NotVincent, totally not Vincent. The real Vincent will review it separately. Probably slop, please disregard.

Comment thread docs/developer-interfaces.md Outdated
Comment thread src/programs/README.md Outdated
Comment thread docs/developer-interfaces.md Outdated
Comment thread docs/developer-interfaces.md Outdated
Comment thread src/programs/README.md Outdated
Comment thread src/programs/README.md Outdated
Comment thread src/programs/README.md Outdated
Comment thread src/programs/README.md Outdated
Comment thread src/programs/README.md Outdated
Comment thread src/programs/README.md Outdated
@gewenyu99
gewenyu99 marked this pull request as ready for review September 25, 2026 15:54
@gewenyu99
gewenyu99 requested a review from a team as a code owner September 25, 2026 15:54

@johncwaters johncwaters left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Automated review. Not written by a human.

Verdict: REQUEST CHANGES

See inline comments. The real John is already reading with physical eyes.

Comment thread docs/developer-interfaces.md Outdated
Comment thread docs/developer-interfaces.md
Comment thread src/programs/README.md
Comment thread src/agent/README.md
Comment thread src/agent/runner/README.md
Comment thread AGENTS.md
@@ -0,0 +1,309 @@
# Developer interfaces

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

personal opinion/experience: having code/interfaces in docs drifts quickly compared to linking to the code itself. As a human my eyes glaze over and as an agent I want them reading the actual code not the potential code in docs.

The actual interface and everything is sick!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NotVincent here. Agreed. The field tables now link straight to the types, and each field has its comment next to it in the code. Each surface keeps one short example for the call shape.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Human vincent here. Yeah this is a good point. We can deal with this later. Since we're rippping things apart, this just makes the transition easy. Good catch @johncwaters

…b4-api-reference

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
…data

- The runAgent example removes Write, Edit and Bash instead of adding Read
  and Glob, and the field table says allowedTools adds to the base tools and
  disallowedTools removes them.
- The runProgram field table says data and program snapshots hold tokens.
- The registry link points at frameworks/registry.ts, and every line anchor
  points at its declaration again.

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Comment thread docs/developer-interfaces.md Outdated
@veria-ai

veria-ai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Security review

No open security issues remain on this pull request.

Fixed/addressed: 1 · PR risk: 0/10

Two runnable scripts replace the inline examples. tsconfig includes
docs/examples, so typecheck keeps them in step with the code.

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Both quack examples log in with a personal API key the way --ci does and
read the gateway token from WIZARD_CI_GATEWAY_TOKEN_FILE, so a run needs
no browser and spends no mint.

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
@gewenyu99
gewenyu99 merged commit 3254636 into main Sep 25, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants