Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
963403d
refactor(skills): separate download files from agent scan
gewenyu99 Sep 22, 2026
9fc46f1
fix(agent): scan project skills before SDK load
gewenyu99 Sep 22, 2026
36f3805
refactor(programs): project agent progress into invocation state
gewenyu99 Sep 22, 2026
111ffba
refactor(programs): add explicit inference credentials providers
gewenyu99 Sep 22, 2026
077cec5
refactor(programs): own binding policy and experiment selection
gewenyu99 Sep 22, 2026
accaeec
fix: clean run-installed skills on failed Wizard exits
gewenyu99 Sep 22, 2026
a24cc40
refactor(programs): resolve dynamic runs from explicit data
gewenyu99 Sep 22, 2026
fb8b36f
feat: run no-agent programs headlessly
gewenyu99 Sep 22, 2026
128c5cf
refactor(programs): resolve dynamic integration recipes from data
gewenyu99 Sep 22, 2026
24a140e
feat(programs): retain invocation data and settled run ledger
gewenyu99 Sep 22, 2026
2fbbdcc
refactor(agent): use caller inference auth in both harnesses
gewenyu99 Sep 22, 2026
36295c9
feat(programs): add callable runProgram host
gewenyu99 Sep 22, 2026
b9b978f
refactor(programs): load callable program config without TUI
gewenyu99 Sep 22, 2026
e9360b6
feat(programs): compose runs and expose invocation outcomes
gewenyu99 Sep 22, 2026
28411b6
refactor(programs): route legacy agent runs through callable host
gewenyu99 Sep 22, 2026
80785b1
feat(agent): propagate host cancellation through active runs
gewenyu99 Sep 22, 2026
33e55dd
feat(programs): honor host cancellation before and during runs
gewenyu99 Sep 22, 2026
565742a
refactor(programs): keep callable host runtime closure headless
gewenyu99 Sep 22, 2026
e334fe9
refactor(programs): finish callable host lifecycle and cleanup
gewenyu99 Sep 22, 2026
49f75e6
refactor(programs): own gateway authentication outside agent
gewenyu99 Sep 22, 2026
4f519e8
Merge A3 and B1 review fixes into B2
gewenyu99 Sep 23, 2026
0947e09
fix callable program host boundaries
gewenyu99 Sep 23, 2026
72d3aff
Merge B2 callable host review fixes
gewenyu99 Sep 23, 2026
4fcdb1f
fix: secure project skill preflight and run cleanup
gewenyu99 Sep 23, 2026
f8fe062
Merge B2 skill security review fixes
gewenyu99 Sep 23, 2026
5e3a0cf
Keep skill cleanup outside UI abort closure
gewenyu99 Sep 23, 2026
0c54a24
Exercise registered cleanup through its runtime path
gewenyu99 Sep 23, 2026
8e630f5
fix(agent): scan project skills before load and clean failed installs
gewenyu99 Sep 23, 2026
0caf084
Keep skill cleanup armed until runner success
gewenyu99 Sep 23, 2026
ee51b5d
fix(agent): harden skill preflight and disarm completed-run cleanup
gewenyu99 Sep 23, 2026
62400eb
fix: retain signal handlers through skill cleanup commit
gewenyu99 Sep 23, 2026
cc26a0a
fix: retain run skill cleanup through complete runner exit
gewenyu99 Sep 23, 2026
0777f83
fix: keep TUI signal cleanup armed through exit
gewenyu99 Sep 23, 2026
8975f7c
Merge standalone skill safety layer before callable host
gewenyu99 Sep 23, 2026
42a506a
chore(programs): sync B2 with the A3 terminal-failure fix
gewenyu99 Sep 23, 2026
161e20f
Merge updated A3 outcomes into skill safety layer
gewenyu99 Sep 23, 2026
c2b9346
Merge updated A3 outcomes and skill scan into B2 callable host
gewenyu99 Sep 23, 2026
99737e6
Merge B1 lint correction into skill safety layer
gewenyu99 Sep 23, 2026
31623cb
Merge B1 formatting follow-up through skill safety layer
gewenyu99 Sep 23, 2026
4d1367f
chore(programs): join the restacked B2 with the remote B2 review fixes
gewenyu99 Sep 23, 2026
2449b58
chore(programs): bring the joined B1 into B2
gewenyu99 Sep 23, 2026
89364ba
Merge posthog/functional-b1-pr into posthog/functional-b-integration
gewenyu99 Sep 23, 2026
64992ed
refactor(programs): stop the adapter's step runner shadowing runProgram
gewenyu99 Sep 23, 2026
da08062
feat(programs): pass the invocation signal to credentials and AI appr…
gewenyu99 Sep 23, 2026
cb6d336
feat(programs): send program-data snapshots through onProgress
gewenyu99 Sep 23, 2026
0b50bae
feat(programs): share the health and settings checks as preflight
gewenyu99 Sep 23, 2026
838bfd0
feat(programs): resolve the binding with launch overrides inside runP…
gewenyu99 Sep 23, 2026
5c9796e
refactor(programs): run agentic detection through runAgent
gewenyu99 Sep 23, 2026
f3bfe2e
feat(programs): identify, stamp and refresh inside runProgram
gewenyu99 Sep 23, 2026
b07faad
feat(programs): answer composition and post-auth pauses through a con…
gewenyu99 Sep 23, 2026
d110d71
feat(agent): flush the scan report from runAgent and tag runs in prog…
gewenyu99 Sep 23, 2026
e06fa16
Merge WP3 lane B (preflight) into posthog/functional-b-integration
gewenyu99 Sep 23, 2026
aa78a96
Merge WP3 lane C (detection through runAgent) into posthog/functional…
gewenyu99 Sep 23, 2026
ee2e72f
refactor(programs): shrink the legacy adapter to host wiring
gewenyu99 Sep 23, 2026
5bb7e18
Merge posthog/functional-b1-pr into posthog/functional-b-integration
gewenyu99 Sep 23, 2026
8ec5235
refactor(programs): watch each program file once, in runProgram
gewenyu99 Sep 23, 2026
df329b6
feat(programs): read live completion URLs and snapshot program input
gewenyu99 Sep 23, 2026
d938a43
Merge WP3 lane E (live completion reads) into posthog/functional-b-in…
gewenyu99 Sep 23, 2026
43a369e
refactor(programs): keep one skill-cleanup handle per runProgram call
gewenyu99 Sep 23, 2026
50c2edb
refactor(agent): close the entry's pre-runAgent door
gewenyu99 Sep 23, 2026
e5bc2b8
perf(agent): keep the runner out of the startup closure
gewenyu99 Sep 23, 2026
62cb971
docs: name the default agent binding correctly in AGENTS.md
gewenyu99 Sep 23, 2026
07d4f16
Merge posthog/functional-b1-pr into posthog/functional-b-integration
gewenyu99 Sep 24, 2026
bd2657e
Merge posthog/functional-b1-pr into posthog/functional-b-integration
gewenyu99 Sep 24, 2026
bf9c7c6
refactor(agent): delete project-skill scan at load
gewenyu99 Sep 24, 2026
cec8176
refactor(agent): leave the case-insensitive skill glob to its own PR
gewenyu99 Sep 24, 2026
4e4b693
refactor(agent): restore downloadSkill to its B1 shape
gewenyu99 Sep 24, 2026
bfa5be3
test(agent): move the A3 cancellation tests out of B2
gewenyu99 Sep 24, 2026
06e0eab
refactor(agent): one host-signal channel and no redundant abort returns
gewenyu99 Sep 24, 2026
23c56e4
test(agent): drop duplicate, private-wiring and unreachable-path tests
gewenyu99 Sep 24, 2026
3629a81
refactor(agent): slim the run contract and the harness resolver
gewenyu99 Sep 24, 2026
8c2bb29
test(architecture): one closure walker and one runProgram closure test
gewenyu99 Sep 24, 2026
4d88468
refactor(agent): revert formatting, reorder and README rewrap churn
gewenyu99 Sep 24, 2026
bca4bf2
refactor(programs): drop the test-only run-definition dispatcher
gewenyu99 Sep 24, 2026
452d5ea
refactor(programs): keep the health-check list on the runtime registry
gewenyu99 Sep 24, 2026
ffc210a
refactor(programs): use the agent's binding types and drop repeated t…
gewenyu99 Sep 24, 2026
1d6e20b
refactor(programs): drop the duplicate program-id guard and merge aut…
gewenyu99 Sep 24, 2026
2a03385
refactor(shared): delete the dead addOverride and package.json writers
gewenyu99 Sep 24, 2026
dbf087b
refactor(programs): trim the legacy adapter to one function
gewenyu99 Sep 24, 2026
b6f374f
refactor(programs): import integration effects the recipe can reach i…
gewenyu99 Sep 24, 2026
db8b743
refactor(programs): fold small per-program files and duplicate tests
gewenyu99 Sep 24, 2026
7108df5
refactor: drop the forwarding shims so moves read as renames
gewenyu99 Sep 24, 2026
d88f335
refactor(ci): keep the lazy CI bearer in the e2e host that needs it
gewenyu99 Sep 24, 2026
3f22d9c
refactor(programs): build runProgram's outcome in one place
gewenyu99 Sep 24, 2026
4fac3ea
refactor(programs): run no-agent programs through the host workflow only
gewenyu99 Sep 24, 2026
11ced24
refactor(programs): keep ProgramStore to the data runProgram reads
gewenyu99 Sep 24, 2026
8ae91e6
refactor(programs): one pre-agent try in runProgram
gewenyu99 Sep 24, 2026
280804a
test(programs): one runProgram test per behavior
gewenyu99 Sep 24, 2026
4721d12
refactor(programs): one type re-export block per module, no test-only…
gewenyu99 Sep 24, 2026
4cde604
test(programs): key the runProgram host tables by capability
gewenyu99 Sep 24, 2026
d953e8c
refactor(skills): match skill-run cleanup to the fix PR off main
gewenyu99 Sep 24, 2026
7995240
Merge posthog/functional-b2-move into posthog/functional-b-integration
gewenyu99 Sep 24, 2026
71d813d
docs(programs): drop formatting-only churn in the self-driving archit…
gewenyu99 Sep 24, 2026
44e52fc
test(programs): keep one runProgram test per contract
gewenyu99 Sep 24, 2026
d4bcaf5
test(programs): trim the legacy adapter's host-wiring tests
gewenyu99 Sep 24, 2026
550f066
test(programs): trim the watcher, store, preflight and run-definition…
gewenyu99 Sep 24, 2026
77c6712
test(detection): check the deferred scan report on the runAgent call
gewenyu99 Sep 24, 2026
f9d2dad
refactor(programs): run the health and settings gates in the adapter …
gewenyu99 Sep 24, 2026
a3cff67
refactor(programs): run the caller's run definition and program settings
gewenyu99 Sep 24, 2026
dbc41fe
refactor(programs): restore the per-program files and the task stream
gewenyu99 Sep 24, 2026
1988473
refactor(shared): restore gateway-auth and scan-consent to the base
gewenyu99 Sep 24, 2026
7e0aac3
test(programs): fold the signal and skill-commit checks into their co…
gewenyu99 Sep 24, 2026
d7a895a
Merge posthog/functional-b2-move into posthog/functional-b-integration
gewenyu99 Sep 24, 2026
663861c
Merge posthog/functional-b1-pr into posthog/functional-b-integration
gewenyu99 Sep 24, 2026
862b007
refactor(programs): reduce B2 to the runProgram surface shell
gewenyu99 Sep 24, 2026
42a379d
Merge posthog/functional-b1-pr into posthog/functional-b-integration
gewenyu99 Sep 24, 2026
a467ba9
refactor(programs): declare the runProgram surface shell on the origi…
gewenyu99 Sep 24, 2026
1725cc3
refactor(programs): call it runProgram, keep host for callers
gewenyu99 Sep 24, 2026
b3a38c6
docs(programs): describe each runProgram field inline
gewenyu99 Sep 25, 2026
1e84cbc
refactor(programs): call it the runner, not the host
gewenyu99 Sep 25, 2026
9e6a0e7
Merge posthog/functional-b1-pr into posthog/functional-b-integration
gewenyu99 Sep 25, 2026
67cb4da
Merge posthog/functional-b1-pr into posthog/functional-b-integration
gewenyu99 Sep 25, 2026
53574fe
docs(programs): correct four runProgram field comments
gewenyu99 Sep 25, 2026
a87c695
Merge posthog/functional-b1-pr into posthog/functional-b-integration
gewenyu99 Sep 25, 2026
44d51af
refactor(programs): take DiscoveredFeature from shared, alias program…
gewenyu99 Sep 25, 2026
68a321c
Merge posthog/functional-b1-pr into posthog/functional-b-integration
gewenyu99 Sep 25, 2026
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
4 changes: 3 additions & 1 deletion src/agent/progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ export type AgentProgress =
/** The handoff document the agent published (`WizardUI.setHandoffText`). */
| { kind: 'handoff'; text: string }
/** The run's final outro payload (`WizardUI.setOutroData`). */
| { kind: 'completion'; outro: OutroData };
| { kind: 'completion'; outro: OutroData }
/** One short line per agent step, only from a run that collects its transcript. */
| { kind: 'activity'; line: string };
Comment thread
johncwaters marked this conversation as resolved.

export type ProgressEmitter = (event: AgentProgress) => void;

Expand Down
5 changes: 5 additions & 0 deletions src/agent/runner/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export interface AgentRunDefinition {
skillId?: string;
/** Additional program-specific prompt instructions. Appended after the default project prompt. */
customPrompt?: (ctx: PromptContext) => string;
prompt?: (ctx: PromptContext) => string; // replaces the assembled project prompt; linear
Comment thread
johncwaters marked this conversation as resolved.
Comment thread
johncwaters marked this conversation as resolved.
collectTranscript?: boolean; // keep a 256K-character transcript tail; linear, Anthropic
requestRemark?: boolean; // false skips the closing remark; linear, Anthropic
/** Additional MCP servers (e.g. Svelte MCP) */
additionalMcpServers?: Record<string, { url: string }>;
/** Package manager detector. Defaults to detectNodePackageManagers. */
Expand Down Expand Up @@ -178,6 +181,7 @@ export interface RunConfig {
seedTasks?: () => SeedTaskEntry[];
/** Completion hooks, bound by the caller. */
hooks?: RunHooks;
scanReport?: 'flush' | 'defer'; // defer leaves the scan report to the outer run
Comment thread
johncwaters marked this conversation as resolved.
}

/** Invocation flags the agent reads. */
Expand Down Expand Up @@ -286,6 +290,7 @@ export interface RunSnapshot {
notebookUrl?: string;
/** The handoff document the agent published, when it did. */
handoffText?: string;
transcriptTail?: string; // set when the run definition asks for collectTranscript
Comment thread
johncwaters marked this conversation as resolved.
}

/** A sequence decides an outcome; the dispatcher owns its snapshot. */
Expand Down
2 changes: 2 additions & 0 deletions src/agent/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export type {
AgentRunDefinition,
PromptContext,
RunConfig,
ResolvedBinding,
RunHooks,
RunInput,
RunResult,
} from './runner';
Expand Down
15 changes: 6 additions & 9 deletions src/lib/wizard-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ import type {
// entry would form a module cycle here.
// eslint-disable-next-line @typescript-eslint/no-restricted-imports -- B2: the session becomes a TUI projection
import { OutroKind } from '@agent/progress';
import { DiscoveredFeature } from '@shared/discovered-feature';

// These shapes moved to their owners; re-exported so every session reader
// keeps its import path. `Credentials` sits with the API types, and the
// outro, question and task-notice shapes are the agent's contract.
// keeps its import path. `Credentials` sits with the API types,
// `DiscoveredFeature` sits in shared so programs can name it without the
// session, and the outro, question and task-notice shapes are the agent's
// contract.
export type { Credentials, CloudRegion };
export { OutroKind };
export { OutroKind, DiscoveredFeature };
export type { AskAnswers, AskQuestion, OutroData, PendingQuestion, TaskNotice };

function parseProjectIdArg(value: string | undefined): number | undefined {
Expand All @@ -54,12 +57,6 @@ export enum RunPhase {
Error = 'error',
}

/** Features discovered by the feature-discovery subagent */
export enum DiscoveredFeature {
Stripe = 'stripe',
LLM = 'llm',
}

/** Consent to report what local detection found (see `scanConsent` below). */
export enum ScanConsent {
Undecided = 'undecided',
Expand Down
17 changes: 17 additions & 0 deletions src/programs/credentials.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/** Resolved credentials runProgram passes to one agent run. */

import type { ApiProject, ApiUser, Credentials } from '@shared/api';

export type ResolvedProgramCredentials = {
Comment thread
johncwaters marked this conversation as resolved.
posthog: Credentials; // token, project API key, project ID and host
project: ApiProject | null; // the project, when known
apiUser: ApiUser | null; // the user, when known
};

/** The caller authenticates once per scope; the signal aborts with the invocation. */
export type CredentialsProvider = {
resolve(
programId: string,
context: { signal: AbortSignal },
): Promise<ResolvedProgramCredentials>;
};
1 change: 1 addition & 0 deletions src/programs/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** Public runtime entry for the programs surface. */
export type * from './types';
export { runProgram } from './run-program';
export {
Program,
PROGRAM_REGISTRY,
Expand Down
95 changes: 95 additions & 0 deletions src/programs/program-store.ts

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.

this isn't hooked up yet in this PR, we will move this in a later PR

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.

Implemented in #1308: program-store.ts (at f550e227).

Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/* eslint-disable @typescript-eslint/no-unused-vars -- A shell: B3 fills in the bodies. */
import type { AgentProgress, ResolvedBinding, RunResult } from '@agent/types';
import type { ApiProject, ApiUser, Credentials } from '@shared/api';

/** One agent run's progress event, attributed to its run. */
export type ProgramRunProgress = {
kind: 'run'; // one agent event
runId: string; // the run it came from
event: AgentProgress; // status, tasks, links, completion and more
};

/** A copy of the invocation's data, sent after each write. */
export type ProgramDataProgress = {
kind: 'program'; // the program's data changed
data: ProgramInvocationData; // a copy of it after the change
};

export type ProgramProgress = ProgramRunProgress | ProgramDataProgress;

/** What a diagnostic is about: one run's progress event, or a data snapshot. */
type DiagnosticSource =
| { runId: string; eventKind: AgentProgress['kind'] }
| { eventKind: 'data' };

/** An observer failure or a late event, kept instead of breaking the run. */
export type ProgramDiagnostic = DiagnosticSource & { message: string };

/** Data owned by one program invocation, independent of its progress feed. */
export type ProgramInvocationData = {
credentials: Credentials | null; // the login; holds tokens, don't log it
apiProject: ApiProject | null; // the login's project
apiUser: ApiUser | null; // the login's user
detection: { frameworkContext: Record<string, unknown> }; // always {} here
binding: ResolvedBinding | null; // the route; null until it resolves
aiSdkStampReported: boolean; // true once the AI SDK stamp was considered
};

/** An agent run's final result. */
export type SettledProgramRun = {
runId: string; // the run's label
result: RunResult; // what runAgent returned
};

export type AgentProgressAdapter = {
onProgress(event: AgentProgress): void;
finish(result: RunResult): void;
};

export class ProgramStore {
constructor(
options: {
aiSdkStampReported?: boolean;
onData?: (progress: ProgramDataProgress) => void;
} = {},
) {
throw new Error('ProgramStore: not implemented');
}

readData(): ProgramInvocationData {
throw new Error('ProgramStore: not implemented');
}

setAuthenticated(
auth: Pick<ProgramInvocationData, 'credentials' | 'apiProject' | 'apiUser'>,
): void {
throw new Error('ProgramStore: not implemented');
}

setFrameworkContext(key: string, value: unknown): void {
throw new Error('ProgramStore: not implemented');
}

setBinding(binding: ResolvedBinding): void {
throw new Error('ProgramStore: not implemented');
}

setAiSdkStampReported(): void {
throw new Error('ProgramStore: not implemented');
}

beginRun(
runId: string,
observer?: (progress: ProgramRunProgress) => void,
): AgentProgressAdapter {
throw new Error('ProgramStore: not implemented');
}

settledRuns(): SettledProgramRun[] {
throw new Error('ProgramStore: not implemented');
}

readDiagnostics(): ProgramDiagnostic[] {
throw new Error('ProgramStore: not implemented');
}
}
107 changes: 107 additions & 0 deletions src/programs/run-program.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/** A caller-owned program invocation. No TUI store or session is required. */
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/require-await -- A shell: B3 fills in the body. */
import type { RunOutcome } from '@agent';
import type {
AgentInteraction,
AgentRunDefinition,
RunConfig,
RunHooks,
RunInput,
RunResult,
} from '@agent/types';
import type { Harness, Integration, Sequence } from '@shared/constants';
import type { DiscoveredFeature } from '@shared/discovered-feature';
import type { DetectedSource } from './warehouse-sources/types';
import type {
CredentialsProvider,
ResolvedProgramCredentials,
} from './credentials';
import type {
ProgramDiagnostic,
ProgramInvocationData,
ProgramProgress,
SettledProgramRun,
} from './program-store';

/** Launch-time routing choices, such as the CLI's --harness, --sequence and --model. */
export type ProgramOverrides = {
harness?: Harness; // --harness
sequence?: Sequence; // --sequence
model?: string; // --model
};

/** Feature flags and their payloads from one evaluation. */
export type WizardFlagSnapshot = {
flags: Record<string, string>; // flag key to variant
payloads: Record<string, unknown>; // flag key to payload
};

/** Program-level settings the caller reads from the program's `ProgramConfig`. */
export type ProgramSettings = {
requiresAi?: boolean; // false skips the AI-processing approval
Comment thread
johncwaters marked this conversation as resolved.
agentFlow?: string; // context-mill flow; defaults to the program ID
allowedTools?: RunConfig['allowedTools']; // added to the base tools
disallowedTools?: RunConfig['disallowedTools']; // removed from the base tools
excludedTaskTypes?: RunConfig['excludedTaskTypes']; // task types to skip for these flags
postAuthGates?: readonly string[]; // steps settled after login, before the agent
};

/** Copied when runProgram receives it; credentials, run, program, hooks and seedTasks stay by reference. */
export interface ProgramInput {
installDir: string; // the project the agent works in
run: AgentRunDefinition; // built from the program's ProgramConfig
program?: ProgramSettings; // from the same ProgramConfig
credentials?: ResolvedProgramCredentials; // a login you hold; else options.credentials
runId?: string; // labels progress and the outcome; generated when absent
overrides?: ProgramOverrides; // launch overrides; dev and test builds only
composed?: boolean; // true for a sub-run inside another program
skillId?: string; // labels the run; defaults to run.skillId, then integrationLabel
integration?: Integration | null; // the detected framework
frameworkDocsUrl?: string; // the framework's docs page
flags?: Partial<RunInput['flags']>; // run flags such as ci and signup
host?: RunInput['host']; // where PostHog is
wizardFlags?: Record<string, string>; // a flag snapshot; else options.featureFlags
wizardFlagPayloads?: Record<string, unknown>; // payloads for wizardFlags
seedTasks?: RunConfig['seedTasks']; // tasks queued before the planner runs
hooks?: RunHooks; // the program's completion hooks
warehouseSources?: readonly DetectedSource[]; // AI SDK stamp evidence
mayReportScanResults?: boolean; // consent to send the AI SDK stamp
discoveredFeatures?: readonly DiscoveredFeature[]; // AI SDK stamp evidence
aiSdkStampReported?: boolean; // true skips the AI SDK stamp
}

export interface ProgramOptions {
credentials?: CredentialsProvider; // resolves the login when input has none
interaction?: AgentInteraction; // answers the agent's questions and notices
onProgress?: (progress: ProgramProgress) => void; // run events and data snapshots
awaitAiApproval?: (context: {
programId: string;
signal: AbortSignal;
}) => Promise<boolean>; // asks for AI-processing approval; false aborts
awaitPostAuthGates?: (context: {
programId: string;
gates: readonly string[];
signal: AbortSignal;
}) => Promise<void>; // waits while the caller settles the gates
featureFlags?: () => Promise<WizardFlagSnapshot>; // loads flags when input has none
signal?: AbortSignal; // cancels the run
}

export interface ProgramRunOutcome {
programId: string; // the program that ran
outcome: RunOutcome; // success, aborted, failed or crashed
data: ProgramInvocationData; // the final login and route
settledRuns: SettledProgramRun[]; // the agent run's result, once it ran
diagnostics: ProgramDiagnostic[]; // observer failures and late events
artifacts: { reportFile?: string }; // where the agent writes its report
failure?: RunResult['failure']; // code and message on any non-success
}

/** Run an existing program from explicit inputs, with invocation-owned state. */
export async function runProgram(
programId: string,
callerInput: ProgramInput,
options: ProgramOptions = {},
): Promise<ProgramRunOutcome> {
throw new Error('runProgram: not implemented');
}
16 changes: 16 additions & 0 deletions src/programs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,19 @@ export type {
StoreInitContext,
} from './program-step';
export type { FrameworkConfig, SetupQuestion } from './framework-config';
export type {
ProgramInput,
ProgramOptions,
ProgramOverrides,
ProgramRunOutcome,
ProgramSettings,
WizardFlagSnapshot,
} from './run-program';
export type {
ProgramDataProgress,
ProgramDiagnostic,
ProgramInvocationData,
ProgramProgress,
ProgramRunProgress,
SettledProgramRun,
} from './program-store';
5 changes: 5 additions & 0 deletions src/shared/discovered-feature.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** Features discovered by the feature-discovery subagent */
export enum DiscoveredFeature {
Stripe = 'stripe',
LLM = 'llm',
}
3 changes: 3 additions & 0 deletions src/ui/agent-progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export function createUiReducer(ui: WizardUI): (event: AgentProgress) => void {
case 'completion':
ui.setOutroData(event.outro);
break;
case 'activity':
// Step lines belong to the caller that asked for them, not the run UI.
break;
default: {
const unhandled: never = event;
throw new Error(
Expand Down
Loading