@wrenai/genbi 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +141 -0
- package/bin/genbi.mjs +31 -0
- package/dist/assets/echarts-LTFC-ysd.js +40 -0
- package/dist/assets/index-Bo--QMUN.js +441 -0
- package/dist/assets/index-Xs4q7pNo.css +1 -0
- package/dist/index.html +14 -0
- package/dist/wrenai_logo.png +0 -0
- package/dist/wrenai_logo_white.png +0 -0
- package/dist-server/harness/auth/detect.d.ts +18 -0
- package/dist-server/harness/auth/detect.js +37 -0
- package/dist-server/harness/auth/index.d.ts +4 -0
- package/dist-server/harness/auth/index.js +2 -0
- package/dist-server/harness/auth/probe.d.ts +18 -0
- package/dist-server/harness/auth/probe.js +52 -0
- package/dist-server/harness/auth/types.d.ts +42 -0
- package/dist-server/harness/auth/types.js +9 -0
- package/dist-server/harness/bundle/loader.d.ts +32 -0
- package/dist-server/harness/bundle/loader.js +43 -0
- package/dist-server/harness/bundle/schema.d.ts +199 -0
- package/dist-server/harness/bundle/schema.js +127 -0
- package/dist-server/harness/bundle/version.d.ts +10 -0
- package/dist-server/harness/bundle/version.js +43 -0
- package/dist-server/harness/capability/gate.d.ts +6 -0
- package/dist-server/harness/capability/gate.js +29 -0
- package/dist-server/harness/capability/registry.d.ts +6 -0
- package/dist-server/harness/capability/registry.js +17 -0
- package/dist-server/harness/cli-args.d.ts +123 -0
- package/dist-server/harness/cli-args.js +247 -0
- package/dist-server/harness/cli.d.ts +2 -0
- package/dist-server/harness/cli.js +151 -0
- package/dist-server/harness/compile/cache.d.ts +23 -0
- package/dist-server/harness/compile/cache.js +109 -0
- package/dist-server/harness/compile/compose-profile.d.ts +34 -0
- package/dist-server/harness/compile/compose-profile.js +95 -0
- package/dist-server/harness/compile/errors.d.ts +22 -0
- package/dist-server/harness/compile/errors.js +41 -0
- package/dist-server/harness/compile/fingerprint.d.ts +22 -0
- package/dist-server/harness/compile/fingerprint.js +84 -0
- package/dist-server/harness/compile/index.d.ts +8 -0
- package/dist-server/harness/compile/index.js +7 -0
- package/dist-server/harness/compile/pipeline.d.ts +66 -0
- package/dist-server/harness/compile/pipeline.js +176 -0
- package/dist-server/harness/compile/resolve-binary.d.ts +55 -0
- package/dist-server/harness/compile/resolve-binary.js +133 -0
- package/dist-server/harness/compile/types.d.ts +107 -0
- package/dist-server/harness/compile/types.js +1 -0
- package/dist-server/harness/compile/warble-identity.d.ts +12 -0
- package/dist-server/harness/compile/warble-identity.js +33 -0
- package/dist-server/harness/compliance/gate.d.ts +35 -0
- package/dist-server/harness/compliance/gate.js +48 -0
- package/dist-server/harness/compliance/index.d.ts +2 -0
- package/dist-server/harness/compliance/index.js +1 -0
- package/dist-server/harness/compliance/types.d.ts +16 -0
- package/dist-server/harness/compliance/types.js +1 -0
- package/dist-server/harness/events/emitter.d.ts +34 -0
- package/dist-server/harness/events/emitter.js +25 -0
- package/dist-server/harness/events/index.d.ts +4 -0
- package/dist-server/harness/events/index.js +2 -0
- package/dist-server/harness/events/sse.d.ts +20 -0
- package/dist-server/harness/events/sse.js +48 -0
- package/dist-server/harness/events/types.d.ts +131 -0
- package/dist-server/harness/events/types.js +1 -0
- package/dist-server/harness/exec/errors.d.ts +16 -0
- package/dist-server/harness/exec/errors.js +29 -0
- package/dist-server/harness/exec/index.d.ts +5 -0
- package/dist-server/harness/exec/index.js +2 -0
- package/dist-server/harness/exec/local.d.ts +32 -0
- package/dist-server/harness/exec/local.js +134 -0
- package/dist-server/harness/exec/policy.d.ts +12 -0
- package/dist-server/harness/exec/policy.js +1 -0
- package/dist-server/harness/exec/types.d.ts +63 -0
- package/dist-server/harness/exec/types.js +1 -0
- package/dist-server/harness/guardrails/index.d.ts +2 -0
- package/dist-server/harness/guardrails/index.js +1 -0
- package/dist-server/harness/guardrails/policy.d.ts +45 -0
- package/dist-server/harness/guardrails/policy.js +57 -0
- package/dist-server/harness/index.d.ts +37 -0
- package/dist-server/harness/index.js +19 -0
- package/dist-server/harness/loop/errors.d.ts +53 -0
- package/dist-server/harness/loop/errors.js +72 -0
- package/dist-server/harness/loop/executor.d.ts +123 -0
- package/dist-server/harness/loop/executor.js +380 -0
- package/dist-server/harness/loop/guard.d.ts +16 -0
- package/dist-server/harness/loop/guard.js +1 -0
- package/dist-server/harness/loop/index.d.ts +5 -0
- package/dist-server/harness/loop/index.js +3 -0
- package/dist-server/harness/native-producer/index.d.ts +109 -0
- package/dist-server/harness/native-producer/index.js +302 -0
- package/dist-server/harness/npm-package-resolve.d.ts +28 -0
- package/dist-server/harness/npm-package-resolve.js +47 -0
- package/dist-server/harness/providers/adapters/anthropic.d.ts +7 -0
- package/dist-server/harness/providers/adapters/anthropic.js +6 -0
- package/dist-server/harness/providers/adapters/mock.d.ts +4 -0
- package/dist-server/harness/providers/adapters/mock.js +5 -0
- package/dist-server/harness/providers/adapters/openai-compatible.d.ts +10 -0
- package/dist-server/harness/providers/adapters/openai-compatible.js +10 -0
- package/dist-server/harness/providers/binding.d.ts +23 -0
- package/dist-server/harness/providers/binding.js +13 -0
- package/dist-server/harness/providers/errors.d.ts +6 -0
- package/dist-server/harness/providers/errors.js +12 -0
- package/dist-server/harness/providers/index.d.ts +18 -0
- package/dist-server/harness/providers/index.js +22 -0
- package/dist-server/harness/providers/registry.d.ts +16 -0
- package/dist-server/harness/providers/registry.js +24 -0
- package/dist-server/harness/render/envelope.d.ts +145 -0
- package/dist-server/harness/render/envelope.js +428 -0
- package/dist-server/harness/render/errors.d.ts +33 -0
- package/dist-server/harness/render/errors.js +46 -0
- package/dist-server/harness/render/index.d.ts +5 -0
- package/dist-server/harness/render/index.js +3 -0
- package/dist-server/harness/render/validate.d.ts +13 -0
- package/dist-server/harness/render/validate.js +88 -0
- package/dist-server/harness/route/adapter-spec.d.ts +40 -0
- package/dist-server/harness/route/adapter-spec.js +61 -0
- package/dist-server/harness/route/agent-sdk-cli.d.ts +30 -0
- package/dist-server/harness/route/agent-sdk-cli.js +86 -0
- package/dist-server/harness/route/agent-sdk-manifest.d.ts +31 -0
- package/dist-server/harness/route/agent-sdk-manifest.js +56 -0
- package/dist-server/harness/route/artifact-content.d.ts +53 -0
- package/dist-server/harness/route/artifact-content.js +83 -0
- package/dist-server/harness/route/chat-event-mapper.d.ts +95 -0
- package/dist-server/harness/route/chat-event-mapper.js +164 -0
- package/dist-server/harness/route/codex-ask-events.d.ts +25 -0
- package/dist-server/harness/route/codex-ask-events.js +395 -0
- package/dist-server/harness/route/codex-ask.d.ts +15 -0
- package/dist-server/harness/route/codex-ask.js +242 -0
- package/dist-server/harness/route/codex-local-cli.d.ts +20 -0
- package/dist-server/harness/route/codex-local-cli.js +78 -0
- package/dist-server/harness/route/codex-local-manifest.d.ts +22 -0
- package/dist-server/harness/route/codex-local-manifest.js +180 -0
- package/dist-server/harness/route/describe.d.ts +54 -0
- package/dist-server/harness/route/describe.js +84 -0
- package/dist-server/harness/route/dispatched.d.ts +138 -0
- package/dist-server/harness/route/dispatched.js +339 -0
- package/dist-server/harness/route/in-process.d.ts +43 -0
- package/dist-server/harness/route/in-process.js +106 -0
- package/dist-server/harness/route/index.d.ts +19 -0
- package/dist-server/harness/route/index.js +12 -0
- package/dist-server/harness/route/profile-source.d.ts +37 -0
- package/dist-server/harness/route/profile-source.js +76 -0
- package/dist-server/harness/route/route.d.ts +33 -0
- package/dist-server/harness/route/route.js +114 -0
- package/dist-server/harness/route/tier-binding.d.ts +36 -0
- package/dist-server/harness/route/tier-binding.js +63 -0
- package/dist-server/harness/route/types.d.ts +286 -0
- package/dist-server/harness/route/types.js +1 -0
- package/dist-server/harness/session/errors.d.ts +4 -0
- package/dist-server/harness/session/errors.js +7 -0
- package/dist-server/harness/session/gate.d.ts +11 -0
- package/dist-server/harness/session/gate.js +13 -0
- package/dist-server/harness/session/index.d.ts +5 -0
- package/dist-server/harness/session/index.js +3 -0
- package/dist-server/harness/session/run.d.ts +60 -0
- package/dist-server/harness/session/run.js +333 -0
- package/dist-server/harness/session/types.d.ts +29 -0
- package/dist-server/harness/session/types.js +1 -0
- package/dist-server/harness/setup/codex-events.d.ts +12 -0
- package/dist-server/harness/setup/codex-events.js +108 -0
- package/dist-server/harness/setup/runner.d.ts +497 -0
- package/dist-server/harness/setup/runner.js +1314 -0
- package/dist-server/harness/tools/errors.d.ts +107 -0
- package/dist-server/harness/tools/errors.js +141 -0
- package/dist-server/harness/tools/index.d.ts +13 -0
- package/dist-server/harness/tools/index.js +8 -0
- package/dist-server/harness/tools/mcp.d.ts +26 -0
- package/dist-server/harness/tools/mcp.js +15 -0
- package/dist-server/harness/tools/native.d.ts +179 -0
- package/dist-server/harness/tools/native.js +322 -0
- package/dist-server/harness/tools/parse.d.ts +14 -0
- package/dist-server/harness/tools/parse.js +18 -0
- package/dist-server/harness/tools/resolve-wren-binary.d.ts +12 -0
- package/dist-server/harness/tools/resolve-wren-binary.js +21 -0
- package/dist-server/harness/tools/resolve.d.ts +51 -0
- package/dist-server/harness/tools/resolve.js +79 -0
- package/dist-server/harness/tools/setup-native.d.ts +84 -0
- package/dist-server/harness/tools/setup-native.js +353 -0
- package/dist-server/harness/tools/wiring.d.ts +10 -0
- package/dist-server/harness/tools/wiring.js +16 -0
- package/dist-server/providers/setup.provider.yaml +31 -0
- package/dist-server/providers/wren.provider.yaml +33 -0
- package/dist-server/server/adopt.d.ts +87 -0
- package/dist-server/server/adopt.js +263 -0
- package/dist-server/server/app.d.ts +6 -0
- package/dist-server/server/app.js +2521 -0
- package/dist-server/server/auth-choice.d.ts +16 -0
- package/dist-server/server/auth-choice.js +36 -0
- package/dist-server/server/bin.d.ts +2 -0
- package/dist-server/server/bin.js +601 -0
- package/dist-server/server/bootstrap-project-binding.d.ts +31 -0
- package/dist-server/server/bootstrap-project-binding.js +71 -0
- package/dist-server/server/clarify.d.ts +10 -0
- package/dist-server/server/clarify.js +17 -0
- package/dist-server/server/codex-setup-mcp.d.ts +2 -0
- package/dist-server/server/codex-setup-mcp.js +147 -0
- package/dist-server/server/compose.d.ts +89 -0
- package/dist-server/server/compose.js +271 -0
- package/dist-server/server/conn-config.d.ts +30 -0
- package/dist-server/server/conn-config.js +253 -0
- package/dist-server/server/context-files.d.ts +12 -0
- package/dist-server/server/context-files.js +117 -0
- package/dist-server/server/context-map.d.ts +30 -0
- package/dist-server/server/context-map.js +95 -0
- package/dist-server/server/context-source.d.ts +68 -0
- package/dist-server/server/context-source.js +85 -0
- package/dist-server/server/db.d.ts +862 -0
- package/dist-server/server/db.js +1839 -0
- package/dist-server/server/enrichment-runner.d.ts +184 -0
- package/dist-server/server/enrichment-runner.js +213 -0
- package/dist-server/server/enrichment-verify.d.ts +73 -0
- package/dist-server/server/enrichment-verify.js +290 -0
- package/dist-server/server/enrichment.d.ts +232 -0
- package/dist-server/server/enrichment.js +199 -0
- package/dist-server/server/env-detect.d.ts +8 -0
- package/dist-server/server/env-detect.js +17 -0
- package/dist-server/server/env-field-hints.d.ts +46 -0
- package/dist-server/server/env-field-hints.js +48 -0
- package/dist-server/server/fold.d.ts +133 -0
- package/dist-server/server/fold.js +407 -0
- package/dist-server/server/harness-profile-sources.d.ts +3 -0
- package/dist-server/server/harness-profile-sources.js +24 -0
- package/dist-server/server/harness.d.ts +19 -0
- package/dist-server/server/harness.js +439 -0
- package/dist-server/server/impact.d.ts +18 -0
- package/dist-server/server/impact.js +85 -0
- package/dist-server/server/interactive-terminal.d.ts +175 -0
- package/dist-server/server/interactive-terminal.js +336 -0
- package/dist-server/server/native-artifacts.d.ts +1004 -0
- package/dist-server/server/native-artifacts.js +564 -0
- package/dist-server/server/native-dispatch-registry.d.ts +42 -0
- package/dist-server/server/native-dispatch-registry.js +45 -0
- package/dist-server/server/native-producer-fence.d.ts +14 -0
- package/dist-server/server/native-producer-fence.js +48 -0
- package/dist-server/server/native-session-resume.d.ts +6 -0
- package/dist-server/server/native-session-resume.js +103 -0
- package/dist-server/server/native-session-workspace.d.ts +40 -0
- package/dist-server/server/native-session-workspace.js +175 -0
- package/dist-server/server/native-sessions.d.ts +374 -0
- package/dist-server/server/native-sessions.js +1517 -0
- package/dist-server/server/native-wren-runtime.d.ts +20 -0
- package/dist-server/server/native-wren-runtime.js +259 -0
- package/dist-server/server/node-pty-host.d.ts +31 -0
- package/dist-server/server/node-pty-host.js +100 -0
- package/dist-server/server/route-intent.d.ts +40 -0
- package/dist-server/server/route-intent.js +23 -0
- package/dist-server/server/runtime-binding.d.ts +52 -0
- package/dist-server/server/runtime-binding.js +258 -0
- package/dist-server/server/source-catalog.d.ts +84 -0
- package/dist-server/server/source-catalog.js +221 -0
- package/dist-server/server/source-driver.d.ts +35 -0
- package/dist-server/server/source-driver.js +124 -0
- package/dist-server/server/spa.d.ts +2 -0
- package/dist-server/server/spa.js +51 -0
- package/dist-server/server/subscription-model-catalog.d.ts +27 -0
- package/dist-server/server/subscription-model-catalog.js +203 -0
- package/dist-server/server/turn.d.ts +249 -0
- package/dist-server/server/turn.js +1074 -0
- package/dist-server/server/wire-types.d.ts +799 -0
- package/dist-server/server/wire-types.js +1 -0
- package/dist-server/server/wren-home.d.ts +19 -0
- package/dist-server/server/wren-home.js +33 -0
- package/dist-server/server/wren-profiles.d.ts +43 -0
- package/dist-server/server/wren-profiles.js +123 -0
- package/package.json +93 -0
- package/profiles/genbi-default/context/binding.yml +9 -0
- package/profiles/genbi-default/ir.golden.json +506 -0
- package/profiles/genbi-default/profile.yml +16 -0
- package/profiles/genbi-enrich-context/components/apply_enrichment/component.yml +42 -0
- package/profiles/genbi-enrich-context/components/draft_enrichment/component.yml +30 -0
- package/profiles/genbi-enrich-context/components/draft_enrichment/steps/draft.md +34 -0
- package/profiles/genbi-enrich-context/components/inspect_context/component.yml +32 -0
- package/profiles/genbi-enrich-context/components/inspect_context/steps/inspect.md +13 -0
- package/profiles/genbi-enrich-context/context/binding.yml +4 -0
- package/profiles/genbi-enrich-context/ir.golden.json +302 -0
- package/profiles/genbi-enrich-context/profile.yml +15 -0
- package/profiles/genbi-monitor/context/binding.yml +7 -0
- package/profiles/genbi-monitor/ir.golden.json +188 -0
- package/profiles/genbi-monitor/profile.yml +27 -0
- package/profiles/genbi-setup/components/build_context/component.yml +44 -0
- package/profiles/genbi-setup/components/build_context/steps/build.md +14 -0
- package/profiles/genbi-setup/components/connect_source/component.yml +51 -0
- package/profiles/genbi-setup/components/connect_source/steps/connect.md +23 -0
- package/profiles/genbi-setup/context/binding.yml +8 -0
- package/profiles/genbi-setup/ir.golden.json +140 -0
- package/profiles/genbi-setup/profile.yml +18 -0
- package/profiles/genbi-setup/raw/schema.json +5 -0
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
import type { AuthChoice } from "../auth/index.js";
|
|
2
|
+
import { type AgentEvent } from "../events/index.js";
|
|
3
|
+
import { StepBudgetExhaustedError } from "../loop/index.js";
|
|
4
|
+
export { StepBudgetExhaustedError };
|
|
5
|
+
import type { AdapterSpec } from "../providers/index.js";
|
|
6
|
+
import type { ResolvedCli } from "../route/agent-sdk-cli.js";
|
|
7
|
+
/** The warble component the setup wizard's connect step dispatches. */
|
|
8
|
+
export declare const CONNECT_SOURCE_AGENT_ID = "connect_source";
|
|
9
|
+
/** The Warble component the setup wizard's context step dispatches (`profiles/genbi-setup/components/build_context`). */
|
|
10
|
+
export declare const BUILD_CONTEXT_AGENT_ID = "build_context";
|
|
11
|
+
/**
|
|
12
|
+
* Default agent-loop budget for setup turns, forwarded as `warble-agent-sdk
|
|
13
|
+
* chat --max-turns`. Well above the dispatcher's own default (40) because
|
|
14
|
+
* `build_context` agentically generates an MDL — many read/introspect/write/
|
|
15
|
+
* build/validate tool calls — and routinely blows past 40, failing the turn
|
|
16
|
+
* with `error_max_turns`. Overridable via `DispatchedSetupRunnerOptions.maxTurns`
|
|
17
|
+
* (wired to `WREN_HARNESS_SETUP_MAX_TURNS` in `server/bin.ts`).
|
|
18
|
+
*/
|
|
19
|
+
export declare const DEFAULT_SETUP_MAX_TURNS = 120;
|
|
20
|
+
export interface SetupStepRunOptions {
|
|
21
|
+
/** The composed single-line prompt (see `composeSetupPrompt`). */
|
|
22
|
+
readonly prompt: string;
|
|
23
|
+
/** The workspace root the initial connect turn scaffolds `<name>/` into. */
|
|
24
|
+
readonly workspaceRoot: string;
|
|
25
|
+
/**
|
|
26
|
+
* The persisted, validated single-segment project name. Required by the
|
|
27
|
+
* project-bound `connect_resume` and `context` turns; optional only so
|
|
28
|
+
* pre-existing initial-connect callers retain their workspace-root cwd.
|
|
29
|
+
*/
|
|
30
|
+
readonly projectName?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Step semantics for the dispatch cwd. Initial `connect` is intentionally
|
|
33
|
+
* workspace-bound so it can scaffold; later turns are project-bound.
|
|
34
|
+
*/
|
|
35
|
+
readonly stepKey?: "connect" | "connect_resume" | "context";
|
|
36
|
+
readonly authChoice: AuthChoice;
|
|
37
|
+
/**
|
|
38
|
+
* Which warble component to dispatch — `CONNECT_SOURCE_AGENT_ID` for the
|
|
39
|
+
* `connect`/`connect_resume` steps, `BUILD_CONTEXT_AGENT_ID` for the
|
|
40
|
+
* `context` step. Optional and defaults to `CONNECT_SOURCE_AGENT_ID` so
|
|
41
|
+
* every pre-existing caller/test (all predating the `context` step) keeps
|
|
42
|
+
* dispatching exactly what it always has without passing this explicitly.
|
|
43
|
+
*/
|
|
44
|
+
readonly agentId?: string;
|
|
45
|
+
/** Forwarded to the dispatched executor so the turn's worklog streams identically to an Ask turn. */
|
|
46
|
+
readonly onEvent?: (event: AgentEvent) => void;
|
|
47
|
+
/**
|
|
48
|
+
* Plan A session resume: an SDK session id captured from an earlier turn's `SetupStepRunResult`
|
|
49
|
+
* (success) or its thrown error (failure — see `DispatchedSessionError`, `../route/dispatched.js`). When
|
|
50
|
+
* set, forwarded to `DispatchedOptions.resumeSessionId` so this turn resumes the SAME agent-sdk
|
|
51
|
+
* conversation instead of starting a fresh one. Omitted (or a runner that doesn't support it)
|
|
52
|
+
* falls back to the pre-existing fresh-dispatch behavior.
|
|
53
|
+
*/
|
|
54
|
+
readonly resumeSessionId?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface SetupStepRunResult {
|
|
57
|
+
/** The dispatched turn's final answer text — callers parse this via `parseSetupTerminal`. */
|
|
58
|
+
readonly finalText: string;
|
|
59
|
+
/**
|
|
60
|
+
* The SDK session id this turn ran under, for resuming a LATER turn via
|
|
61
|
+
* `SetupStepRunOptions.resumeSessionId`. Optional so pre-existing stub runners in tests aren't
|
|
62
|
+
* forced to return it (mirrors `SetupStepRunner.effectiveMaxTurns`'s optionality above);
|
|
63
|
+
* callers that need it treat an absent field the same as `undefined` — no session captured.
|
|
64
|
+
* `null` means the dispatcher itself reported no session id at all.
|
|
65
|
+
*/
|
|
66
|
+
readonly sessionId?: string | null;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Backend-abstract seam for dispatching one setup-wizard turn. Implementations
|
|
70
|
+
* own how the `connect_source` component actually runs (dispatched subprocess
|
|
71
|
+
* today; a future in-process variant could implement this same
|
|
72
|
+
* interface) and are responsible for forwarding `onEvent` so the caller's SSE
|
|
73
|
+
* worklog streaming is unaffected by which backend served the turn.
|
|
74
|
+
*/
|
|
75
|
+
export interface SetupStepRunner {
|
|
76
|
+
run(options: SetupStepRunOptions): Promise<SetupStepRunResult>;
|
|
77
|
+
/**
|
|
78
|
+
* The `--max-turns` budget this runner will actually dispatch a given
|
|
79
|
+
* `agentId` with — the same value `run()` computes internally. Callers that
|
|
80
|
+
* need to *describe* a future dispatch (e.g. the `max_turns_continue`
|
|
81
|
+
* decision's "Continue (+N turns)" label — see `server/turn.ts`) call this
|
|
82
|
+
* instead of duplicating the resolution logic, so the label can never drift
|
|
83
|
+
* from what `run()` actually applies. Optional so pre-existing stub runners
|
|
84
|
+
* in tests aren't forced to implement it; callers fall back to
|
|
85
|
+
* `DEFAULT_SETUP_MAX_TURNS` when it's absent.
|
|
86
|
+
*/
|
|
87
|
+
effectiveMaxTurns?(agentId: string): number | undefined;
|
|
88
|
+
}
|
|
89
|
+
export interface SetupRunnerSet {
|
|
90
|
+
readonly claudeSubscription: SetupStepRunner;
|
|
91
|
+
readonly codexSubscription: SetupStepRunner;
|
|
92
|
+
readonly nonSubscription: SetupStepRunner;
|
|
93
|
+
}
|
|
94
|
+
/** Single provider-aware selection seam shared by boot wiring and tests. */
|
|
95
|
+
export declare function selectSetupRunnerForAuth(authChoice: AuthChoice, runners: SetupRunnerSet): SetupStepRunner;
|
|
96
|
+
export interface DispatchedSetupRunnerOptions {
|
|
97
|
+
/** Path to the committed genbi-setup IR (e.g. `profiles/genbi-setup/ir.golden.json`) — see `resolveSetupIrPath`. */
|
|
98
|
+
readonly irPath: string;
|
|
99
|
+
readonly warbleBin?: string;
|
|
100
|
+
readonly agentSdkBin?: string;
|
|
101
|
+
readonly outDir?: string;
|
|
102
|
+
readonly workDir?: string;
|
|
103
|
+
/** Live dispatcher config generated from the persisted runtime tier rows. */
|
|
104
|
+
readonly getModelsConfig?: () => string | undefined;
|
|
105
|
+
/** Agent-loop budget forwarded as `--max-turns`; defaults to `DEFAULT_SETUP_MAX_TURNS` when unset. */
|
|
106
|
+
readonly maxTurns?: number;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Dispatches a setup-wizard turn over dispatched, bypassing `route()` entirely
|
|
110
|
+
* (unlike the Ask turn path) so it can perform its own, setup-specific
|
|
111
|
+
* subscription-mode check with a clear, actionable error message rather than
|
|
112
|
+
* `route()`'s generic in-process/B branch. Uses `DispatchedOptions.irPath` to skip
|
|
113
|
+
* `compileProfile` — there is no bound wren project yet during setup, so
|
|
114
|
+
* there is nothing to compile a profile against; the setup dispatch always
|
|
115
|
+
* runs the same fixed, warble-committed IR regardless of which project is
|
|
116
|
+
* being onboarded.
|
|
117
|
+
*/
|
|
118
|
+
export declare class DispatchedSetupRunner implements SetupStepRunner {
|
|
119
|
+
private readonly options;
|
|
120
|
+
constructor(options: DispatchedSetupRunnerOptions);
|
|
121
|
+
effectiveMaxTurns(agentId: string): number | undefined;
|
|
122
|
+
run(runOptions: SetupStepRunOptions): Promise<SetupStepRunResult>;
|
|
123
|
+
}
|
|
124
|
+
export interface CodexSetupRunnerOptions {
|
|
125
|
+
readonly irPath: string;
|
|
126
|
+
readonly getStrongModel: () => string;
|
|
127
|
+
readonly codexLocalBin?: string;
|
|
128
|
+
/** Test/dev override for a command with required prefix args. */
|
|
129
|
+
readonly codexLocalCli?: ResolvedCli;
|
|
130
|
+
readonly codexBin?: string;
|
|
131
|
+
readonly mcpServer?: ResolvedCli;
|
|
132
|
+
readonly timeoutMs?: number;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Setup-only Codex subscription runner. It invokes the target's `dispatch`
|
|
136
|
+
* command directly against the committed setup IR and exposes exactly one
|
|
137
|
+
* guarded MCP tool. Normal Ask routing never calls this class.
|
|
138
|
+
*/
|
|
139
|
+
export declare class CodexSetupRunner implements SetupStepRunner {
|
|
140
|
+
private readonly options;
|
|
141
|
+
constructor(options: CodexSetupRunnerOptions);
|
|
142
|
+
run(runOptions: SetupStepRunOptions): Promise<SetupStepRunResult>;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* This package's bundled setup capability-provider fragment
|
|
146
|
+
* (`providers/setup.provider.yaml`) — the default `--provider` for
|
|
147
|
+
* `InProcessSetupRunner`'s dispatch, mirroring `compileProfile`'s own
|
|
148
|
+
* `DEFAULT_WREN_PROVIDER_PATH` constant (`harness/compile/pipeline.ts`).
|
|
149
|
+
*/
|
|
150
|
+
export declare const DEFAULT_SETUP_PROVIDER_PATH: string;
|
|
151
|
+
export interface InProcessSetupRunnerOptions {
|
|
152
|
+
/** Path to the committed genbi-setup IR (e.g. `profiles/genbi-setup/ir.golden.json`) — same contract as `DispatchedSetupRunnerOptions.irPath`. */
|
|
153
|
+
readonly irPath: string;
|
|
154
|
+
readonly warbleBin?: string;
|
|
155
|
+
/** Overrides the bundled `providers/setup.provider.yaml` fragment `warble dispatch --provider` uses. */
|
|
156
|
+
readonly providerPath?: string;
|
|
157
|
+
/** Scratch dir the dispatched vercel bundle is written into; a fresh `mkdtemp` per run when unset. */
|
|
158
|
+
readonly outDir?: string;
|
|
159
|
+
/** Forwarded to `deriveAdapterSpec` for `authChoice.mode === "local"` (see its own doc comment). */
|
|
160
|
+
readonly model?: string;
|
|
161
|
+
/** Live strong-tier adapter/model binding from persisted runtime settings. */
|
|
162
|
+
readonly getStrongAdapterSpec?: (authChoice: AuthChoice) => AdapterSpec;
|
|
163
|
+
/**
|
|
164
|
+
* Agent-loop step budget forwarded as `ExecuteAgentContext.maxSteps`;
|
|
165
|
+
* resolved the same way as `DispatchedSetupRunnerOptions.maxTurns` via the
|
|
166
|
+
* shared `resolveEffectiveMaxTurns` (only `build_context` gets the raised
|
|
167
|
+
* `DEFAULT_SETUP_MAX_TURNS` budget by default; `connect`/`connect_resume`
|
|
168
|
+
* fall back to `ToolLoopAgent`'s own SDK default of 20 steps unless this
|
|
169
|
+
* is set). Wired to the same `WREN_HARNESS_SETUP_MAX_TURNS` env var as
|
|
170
|
+
* `DispatchedSetupRunnerOptions.maxTurns` in `server/bin.ts`.
|
|
171
|
+
*/
|
|
172
|
+
readonly maxTurns?: number;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Dispatches a setup-wizard turn over in-process: the in-process vercel loop
|
|
176
|
+
* (`harness/loop/executor.ts`'s `executeAgent`), instead of shelling a
|
|
177
|
+
* claude-agent-sdk subprocess. Mirrors `DispatchedSetupRunner`'s own shape
|
|
178
|
+
* (same `SetupStepRunner` interface, same "bypass the per-user compile
|
|
179
|
+
* pipeline and dispatch the fixed, warble-committed setup IR directly"
|
|
180
|
+
* design) but reuses the in-process building blocks `harness/route/in-process.ts`'s
|
|
181
|
+
* `runInProcessDefault` wires together, minus the two pieces that don't apply to
|
|
182
|
+
* setup:
|
|
183
|
+
*
|
|
184
|
+
* - No `resolveWrenBinary()` preflight — the setup components' only tool
|
|
185
|
+
* (`setup_execution`, see `harness/tools/setup-native.ts`) never shells
|
|
186
|
+
* the `wren` CLI directly; it's a general scoped exec/write pair, not a
|
|
187
|
+
* wren-specific one.
|
|
188
|
+
* - No `deriveEnforcement(agent)` (`harness/guardrails/policy.ts`) — that
|
|
189
|
+
* function maps `read_only`/`scoped_write`/threshold guardrails onto an
|
|
190
|
+
* `EnforcementPolicy` and has no branch for the `setup_execution`
|
|
191
|
+
* guardrail shape (`{name: "setup_execution", locked: true, scope: "."}`)
|
|
192
|
+
* the two setup components declare. Rather than widen that shared module
|
|
193
|
+
* for a guardrail only this path uses, this runner builds its own fixed
|
|
194
|
+
* `ExecutionPolicy` below, matching what `setup_execution` actually grants
|
|
195
|
+
* on the dispatched (claude-agent-sdk) side: unrestricted exec (subject only
|
|
196
|
+
* to the native tool's own destructive/redirection denylist, never
|
|
197
|
+
* `readOnly`-gated) and a write scope of the whole workspace root.
|
|
198
|
+
*
|
|
199
|
+
* Unlike `DispatchedSetupRunner`, which forwards its `--max-turns` budget to a
|
|
200
|
+
* subprocess CLI flag, this runner's turn budget is an in-process
|
|
201
|
+
* `ExecuteAgentContext.maxSteps` (an `isStepCount` stop condition on the
|
|
202
|
+
* step's underlying `ToolLoopAgent`) — see `effectiveMaxTurns()` below for
|
|
203
|
+
* how it's resolved, and `StepBudgetExhaustedError` (`harness/loop/errors.ts`)
|
|
204
|
+
* for how a turn that runs out of steps before finishing is reported.
|
|
205
|
+
*
|
|
206
|
+
* Also calls `executeAgent` directly rather than the higher-level
|
|
207
|
+
* `runAgent()` in-process's Ask-turn path uses: `runAgent` asserts every
|
|
208
|
+
* `agent.capabilities[]` entry against a `CapabilityRegistry`, but
|
|
209
|
+
* `connect_source`/`build_context` declare `source_connect`/`context_build`
|
|
210
|
+
* — capabilities outside the fixed `DEFAULT_CAPABILITIES` set a wren-project
|
|
211
|
+
* Ask turn resolves. `executeAgent` (confirmed via `ExecuteAgentContext`'s
|
|
212
|
+
* own shape) has no `capabilityRegistry` concept at all, so it runs the
|
|
213
|
+
* bundle's dataflow with no capability assertion — exactly what dispatching
|
|
214
|
+
* a setup-only capability needs, without inventing a parallel registry for
|
|
215
|
+
* two names nothing else provides.
|
|
216
|
+
*/
|
|
217
|
+
export declare class InProcessSetupRunner implements SetupStepRunner {
|
|
218
|
+
private readonly options;
|
|
219
|
+
constructor(options: InProcessSetupRunnerOptions);
|
|
220
|
+
/**
|
|
221
|
+
* The `ExecuteAgentContext.maxSteps` budget this runner will actually pass
|
|
222
|
+
* into `executeAgent` for a given `agentId` — the same value `run()`
|
|
223
|
+
* computes internally. This was previously documented as always
|
|
224
|
+
* `undefined` on the theory that "`executeAgent` has no turn-budget
|
|
225
|
+
* concept at all" — that was already false when it was written: every
|
|
226
|
+
* tools-bearing step ran as a `ToolLoopAgent` turn, and `ToolLoopAgent`
|
|
227
|
+
* itself silently defaults to a 20-step budget (`ai`'s
|
|
228
|
+
* `stopWhen: this.settings.stopWhen ?? isStepCount(20)`) whenever nothing
|
|
229
|
+
* overrides it. There was a real, unconfigurable ceiling the whole time;
|
|
230
|
+
* it just had no name and nothing here reported it. Now that `run()` below
|
|
231
|
+
* threads an explicit `maxSteps` through, this reports the real value —
|
|
232
|
+
* mirroring `DispatchedSetupRunner.effectiveMaxTurns` — via the same
|
|
233
|
+
* `resolveEffectiveMaxTurns` helper so the two can never disagree.
|
|
234
|
+
*/
|
|
235
|
+
effectiveMaxTurns(agentId: string): number | undefined;
|
|
236
|
+
run(runOptions: SetupStepRunOptions): Promise<SetupStepRunResult>;
|
|
237
|
+
}
|
|
238
|
+
export type SetupTerminalStatus = "ok" | "needs_input" | "error";
|
|
239
|
+
export interface SetupTerminalContext {
|
|
240
|
+
/** The workspace root the project was scaffolded under. */
|
|
241
|
+
readonly root: string;
|
|
242
|
+
/** The project name (the scaffolded directory is `<root>/<name>`). */
|
|
243
|
+
readonly name: string;
|
|
244
|
+
/**
|
|
245
|
+
* Which setup step this terminal check is verifying — a string, not
|
|
246
|
+
* `SetupStepKey`, so this module (`harness/`) never has to import the BFF layer
|
|
247
|
+
* (`server/compose.ts`); callers pass `turn.setupStepKey` straight through.
|
|
248
|
+
* Undefined (or any value other than `"connect_resume"`/`"context"`) is
|
|
249
|
+
* treated exactly like `"connect"`, matching every pre-existing caller/test
|
|
250
|
+
* that never set this field.
|
|
251
|
+
*
|
|
252
|
+
* Three distinct `ok` verifications exist, one per step — a plain boolean
|
|
253
|
+
* stopped being expressive enough once `context` joined `connect`/
|
|
254
|
+
* `connect_resume`:
|
|
255
|
+
*
|
|
256
|
+
* - `"connect"` (default): `<root>/<name>/wren_project.yml` must exist —
|
|
257
|
+
* the scaffold this step is supposed to have just written.
|
|
258
|
+
* - `"connect_resume"`: by the time this step runs, `wren_project.yml`
|
|
259
|
+
* already exists (written during `connect`), so re-checking it would be
|
|
260
|
+
* vacuous — it would let a resume's claimed "ok" pass on pure agent
|
|
261
|
+
* self-report, defeating the "don't trust the agent" design. Instead this
|
|
262
|
+
* checks for a distinct `.wren-validated` sentinel file, which
|
|
263
|
+
* `composeSetupPrompt`'s `connect_resume` branch instructs the agent to
|
|
264
|
+
* create ONLY after a successful `wren profile add`/validate call. A
|
|
265
|
+
* sentinel file is used (rather than inspecting wren's own profile
|
|
266
|
+
* registry, e.g. `~/.wren/profiles.yml`) because that registry's exact
|
|
267
|
+
* path/format is not something this BFF can reliably assume is stable
|
|
268
|
+
* across wren CLI versions/environments; the sentinel is fully within our
|
|
269
|
+
* own control and lives right next to `wren_project.yml`.
|
|
270
|
+
* - `"context"`: checks `<root>/<name>/target/mdl.json` — the artifact
|
|
271
|
+
* `wren context build` writes by default (confirmed via `wren context
|
|
272
|
+
* build --help`: "Build into target/mdl.json for the engine" — and by
|
|
273
|
+
* inspecting a real built fixture, whose top-level shape is
|
|
274
|
+
* `{ catalog, schema, models: [...], relationships, views, cubes,
|
|
275
|
+
* dataSource, layoutVersion }`). A missing file, invalid JSON, a
|
|
276
|
+
* `models` array with zero entries, or (when a worklog is available) no
|
|
277
|
+
* successfully completed recognized schema
|
|
278
|
+
* discovery command all downgrade a claimed "ok" to "error" — an agent
|
|
279
|
+
* that ran `wren context build` against an empty/unfinished MDL project
|
|
280
|
+
* must not be trusted just because it self-reports success.
|
|
281
|
+
*
|
|
282
|
+
* `needs_input` gets an analogous check, but only for `"connect"`
|
|
283
|
+
* (undefined/default): `needs_input` IS `connect`'s designed success
|
|
284
|
+
* ending — its own prompt (`composeSetupPrompt`) promises a scaffolded
|
|
285
|
+
* project directory, a `wren_project.yml`, and an empty `.env` template
|
|
286
|
+
* before it stops to wait for the user. Without this check, an agent that
|
|
287
|
+
* burned its whole turn on the skill's Preflight and produced none of
|
|
288
|
+
* those files could still report `needs_input`, and the wizard would offer
|
|
289
|
+
* the "I've filled in .env" affordance for a project that was never
|
|
290
|
+
* created. `connect_resume` and `context` do NOT get this check: neither
|
|
291
|
+
* step's prompt promises a NEW on-disk artifact as part of a `needs_input`
|
|
292
|
+
* ending (e.g. `context`'s `needs_input` is "ambiguous relationship,
|
|
293
|
+
* please confirm" — there is nothing new on disk to verify), so there is
|
|
294
|
+
* no analogous claim to hold them to.
|
|
295
|
+
*/
|
|
296
|
+
readonly stepKey?: string;
|
|
297
|
+
/**
|
|
298
|
+
* The data source the user actually selected for this project (e.g.
|
|
299
|
+
* `"duckdb"`), as already known to the BFF from the setup form — never
|
|
300
|
+
* re-derived from anything an agent turn wrote. Only consulted when
|
|
301
|
+
* `stepKey === "connect_resume"`; every other step (and every
|
|
302
|
+
* pre-existing caller/test that omits this field) is unaffected.
|
|
303
|
+
*
|
|
304
|
+
* This backs a SECOND, additive `ok` check for `connect_resume`, layered
|
|
305
|
+
* on top of the `.wren-validated` sentinel check above: sentinel presence
|
|
306
|
+
* only proves *some* profile validated successfully, not that it was the
|
|
307
|
+
* *right* one. Two deliberately-NOT-taken approaches, for the record:
|
|
308
|
+
*
|
|
309
|
+
* - Reading the onboarding skill's scratch file (`conn.profile.yml`)
|
|
310
|
+
* directly: rejected. The skill's own happy path deletes that file the
|
|
311
|
+
* moment validation succeeds (see `skills_content/onboarding/SKILL.md`
|
|
312
|
+
* step 3.5), so a post-turn check reading it would be a no-op on
|
|
313
|
+
* exactly the success case it exists to guard. It would also hardcode
|
|
314
|
+
* that scratch filename into this BFF layer, which a prior decision
|
|
315
|
+
* deliberately undid (this module is meant to stay agnostic of the
|
|
316
|
+
* skill's internal scratch-file naming).
|
|
317
|
+
* - Reading `~/.wren/profiles.yml`: already rejected above for the
|
|
318
|
+
* sentinel check, for the same environment/version-stability reason.
|
|
319
|
+
*
|
|
320
|
+
* Instead this reads `<root>/<name>/wren_project.yml` — an artifact this
|
|
321
|
+
* module already reads elsewhere in this same function — and checks two
|
|
322
|
+
* of its fields against ground truth the wren CLI itself is responsible
|
|
323
|
+
* for keeping consistent:
|
|
324
|
+
*
|
|
325
|
+
* 1. `profile:` must be non-empty. The CLI's own
|
|
326
|
+
* `maybe_pin_new_profile_to_project` gate (in `core/wren/src/wren/
|
|
327
|
+
* context.py`) refuses to pin a profile whose datasource conflicts
|
|
328
|
+
* with an already-declared one, leaving `profile:` unset — so an
|
|
329
|
+
* empty `profile:` here means the CLI itself never committed to a
|
|
330
|
+
* pin, regardless of what the agent claims.
|
|
331
|
+
* 2. `data_source:` must match this field (case-insensitive, trimmed).
|
|
332
|
+
* `pin_profile` always writes `profile:` and `data_source:` together
|
|
333
|
+
* from the SAME profile, so this catches the case the gate above
|
|
334
|
+
* can't: an agent that force-repins via `wren context set-profile
|
|
335
|
+
* <project>` (which has no mismatch gate — it's an explicit override)
|
|
336
|
+
* onto a profile for the wrong data source.
|
|
337
|
+
*
|
|
338
|
+
* A mismatch or missing pin downgrades a claimed "ok" to "error" with a
|
|
339
|
+
* message that names the profile fields, not `.env` — the wrong-datasource
|
|
340
|
+
* failure mode this exists to catch has nothing to do with `.env`'s
|
|
341
|
+
* contents.
|
|
342
|
+
*/
|
|
343
|
+
readonly expectedSourceType?: string;
|
|
344
|
+
/**
|
|
345
|
+
* The turn's tool-call worklog (a `ToolStep[]`, defined in
|
|
346
|
+
* `server/wire-types.ts`), declared here as a narrow LOCAL structural type
|
|
347
|
+
* rather than imported — for the same one-way-dependency reason `stepKey`
|
|
348
|
+
* above is a bare `string`, not `SetupStepKey`: this module (`harness/`)
|
|
349
|
+
* must never import from `server/`. Optional and additive: every existing
|
|
350
|
+
* caller/test that omits it keeps the exact pre-existing behavior below.
|
|
351
|
+
*
|
|
352
|
+
* Consulted when `stepKey === "context"`: an `ok` must have successful
|
|
353
|
+
* discovery evidence as well as the structural MDL gate, while an `error`
|
|
354
|
+
* still uses it for the diagnostic attribution described by
|
|
355
|
+
* {@link firstFailedExec}.
|
|
356
|
+
*/
|
|
357
|
+
readonly worklog?: readonly SetupWorklogEntry[];
|
|
358
|
+
/**
|
|
359
|
+
* A host-recorded, identity-bound completed prefix from earlier corrective
|
|
360
|
+
* context attempts. Agent prose never supplies this value. It is optional
|
|
361
|
+
* so callers that only have one worklog retain the original behavior.
|
|
362
|
+
*/
|
|
363
|
+
readonly priorContextLifecycle?: ContextLifecyclePrefix;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* The minimal structural shape of a `ToolStep` (`server/wire-types.ts`) that
|
|
367
|
+
* {@link firstFailedExec} needs. Declared locally rather than imported — see
|
|
368
|
+
* `SetupTerminalContext.worklog`'s doc comment.
|
|
369
|
+
*
|
|
370
|
+
* `state` mirrors `ToolStep.state` and is ALREADY populated correctly, today,
|
|
371
|
+
* for every mode: `LiveWorkLog.ingest` (`server/fold.ts`) sets it straight
|
|
372
|
+
* from the originating `AgentEvent`'s own structured `status`/`outcome`
|
|
373
|
+
* field, and `server/turn.ts` passes that raw, unsanitized snapshot into
|
|
374
|
+
* `parseSetupTerminal` — no plumbing change was needed to expose it here.
|
|
375
|
+
* See {@link execSucceeded} for why it is trustworthy for a dispatched (`Bash`)
|
|
376
|
+
* entry but NOT for a in-process / Codex local (`setup_execution`-shaped) one.
|
|
377
|
+
*/
|
|
378
|
+
export interface SetupWorklogEntry {
|
|
379
|
+
readonly label: string;
|
|
380
|
+
readonly input?: unknown;
|
|
381
|
+
readonly detail?: string;
|
|
382
|
+
readonly state?: "running" | "done" | "error";
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* A non-secret, host-derived identity for retained context lifecycle proof.
|
|
386
|
+
* It deliberately binds the canonical on-disk project, the BFF-selected
|
|
387
|
+
* source type, wren's project-level profile declaration, and a non-secret
|
|
388
|
+
* digest of the effective connection target. If any required filesystem fact
|
|
389
|
+
* cannot be read or is ambiguous, callers must fail closed and not reuse
|
|
390
|
+
* evidence from an earlier attempt.
|
|
391
|
+
*/
|
|
392
|
+
export declare function contextLifecycleIdentityFingerprint(root: string, name: string, selectedSourceType: string): string | undefined;
|
|
393
|
+
export interface SetupTerminalResult {
|
|
394
|
+
readonly status: SetupTerminalStatus;
|
|
395
|
+
readonly message: string;
|
|
396
|
+
/**
|
|
397
|
+
* A host-owned rejection of an agent's claimed `SETUP_STATUS: ok`.
|
|
398
|
+
*
|
|
399
|
+
* This is deliberately structured rather than inferred from the display
|
|
400
|
+
* message: `server/turn.ts` uses it to decide whether the completed,
|
|
401
|
+
* resumable agent session gets one corrective continuation. Agent-declared
|
|
402
|
+
* errors, dispatcher failures, cancellation, and timeouts do not create
|
|
403
|
+
* this diagnostic and therefore cannot enter that recovery path.
|
|
404
|
+
*/
|
|
405
|
+
readonly diagnostic?: HostContractDiagnostic;
|
|
406
|
+
/**
|
|
407
|
+
* A deterministic workflow outcome, deliberately separate from the
|
|
408
|
+
* human-facing message so callers never have to re-classify prose.
|
|
409
|
+
* Present when a context turn needs the BFF's explicit bounded
|
|
410
|
+
* missing-discovery correction.
|
|
411
|
+
*/
|
|
412
|
+
readonly failureKind?: "no_successful_schema_discovery" | "missing_terminal_status";
|
|
413
|
+
}
|
|
414
|
+
export type HostContractCode = "connect_artifact_missing" | "connection_marker_missing" | "connection_profile_missing" | "connection_source_mismatch" | "context_schema_discovery_missing" | "context_schema_discovery_failed" | "context_validate_missing" | "context_build_missing" | "context_lifecycle_out_of_order" | "context_mdl_missing" | "context_mdl_empty";
|
|
415
|
+
/** Non-secret, host-owned evidence returned when a claimed setup success fails its artifact gate. */
|
|
416
|
+
export interface HostContractDiagnostic {
|
|
417
|
+
readonly kind: "host_contract";
|
|
418
|
+
readonly code: HostContractCode;
|
|
419
|
+
/** What the BFF observed. This must remain safe to return to the agent. */
|
|
420
|
+
readonly observed: string;
|
|
421
|
+
/** The concrete artifact/workflow conditions that must be true before another claimed success. */
|
|
422
|
+
readonly expectedArtifactContract: readonly string[];
|
|
423
|
+
}
|
|
424
|
+
export type RecordedSchemaDiscovery = {
|
|
425
|
+
readonly kind: "successful";
|
|
426
|
+
readonly command: string;
|
|
427
|
+
} | {
|
|
428
|
+
readonly kind: "failed";
|
|
429
|
+
readonly command: string;
|
|
430
|
+
readonly exitCode?: number;
|
|
431
|
+
} | {
|
|
432
|
+
readonly kind: "none";
|
|
433
|
+
};
|
|
434
|
+
/**
|
|
435
|
+
* The single setup-workflow contract for recognisable schema discovery. A
|
|
436
|
+
* matching command is evidence only after it completed successfully (see
|
|
437
|
+
* {@link execSucceeded} for what "successfully" means per mode); command
|
|
438
|
+
* text alone proves neither execution nor a readable schema. Callers use
|
|
439
|
+
* this for both terminal acceptance and the no-introspection diagnostic,
|
|
440
|
+
* rather than reimplementing the allowlist elsewhere.
|
|
441
|
+
*/
|
|
442
|
+
export declare function classifyRecordedSchemaDiscovery(worklog: readonly SetupWorklogEntry[]): RecordedSchemaDiscovery;
|
|
443
|
+
/** Ordered, host-recorded progress; each value includes all preceding work. */
|
|
444
|
+
export type ContextLifecyclePrefix = "none" | "discovery" | "validate" | "build";
|
|
445
|
+
export type RecordedContextLifecycle = {
|
|
446
|
+
readonly kind: "successful";
|
|
447
|
+
} | {
|
|
448
|
+
readonly kind: "missing_discovery";
|
|
449
|
+
} | {
|
|
450
|
+
readonly kind: "validate_missing";
|
|
451
|
+
readonly observed: string;
|
|
452
|
+
} | {
|
|
453
|
+
readonly kind: "build_missing";
|
|
454
|
+
readonly observed: string;
|
|
455
|
+
} | {
|
|
456
|
+
readonly kind: "out_of_order";
|
|
457
|
+
readonly observed: string;
|
|
458
|
+
};
|
|
459
|
+
/**
|
|
460
|
+
* Returns the greatest ordered prefix proved by the supplied successful tool
|
|
461
|
+
* calls. This intentionally retains an earlier valid prefix even if a later
|
|
462
|
+
* call in the same attempt is out of order, so a corrective attempt can ask
|
|
463
|
+
* only for the unproven suffix.
|
|
464
|
+
*/
|
|
465
|
+
export declare function recordedContextLifecyclePrefix(worklog: readonly SetupWorklogEntry[], prior?: ContextLifecyclePrefix): ContextLifecyclePrefix;
|
|
466
|
+
export declare function classifyRecordedContextLifecycle(worklog: readonly SetupWorklogEntry[], prior?: ContextLifecyclePrefix): RecordedContextLifecycle;
|
|
467
|
+
/**
|
|
468
|
+
* Parses the LAST `SETUP_STATUS: ok|needs_input|error` line out of a setup
|
|
469
|
+
* turn's finalText (the terminal contract lives in the composed
|
|
470
|
+
* prompt, not warble — the agent is instructed to emit this line, and an
|
|
471
|
+
* agent narrating its plan mid-message could emit misleading earlier
|
|
472
|
+
* "SETUP_STATUS"-like text, so only the last line counts).
|
|
473
|
+
*
|
|
474
|
+
* For `ok`, independently verifies an on-disk artifact before trusting the
|
|
475
|
+
* agent's self-report, rather than blindly advancing the wizard — see
|
|
476
|
+
* `SetupTerminalContext.stepKey`'s doc comment for exactly which artifact each
|
|
477
|
+
* step checks (`wren_project.yml` / `.wren-validated` / `target/mdl.json`
|
|
478
|
+
* with at least one model).
|
|
479
|
+
*
|
|
480
|
+
* The `context` step's `ok` check also requires a successfully completed
|
|
481
|
+
* recognized schema-discovery command whenever a worklog is available. It
|
|
482
|
+
* does NOT try to infer fabrication from model names or columns. Two semantic
|
|
483
|
+
* heuristics were considered and rejected as unsafe:
|
|
484
|
+
* - Flagging a model literally named "example": a real warehouse can
|
|
485
|
+
* genuinely have a table named "example" (the composed `context` prompt
|
|
486
|
+
* itself explicitly tolerates a pre-existing "example" placeholder
|
|
487
|
+
* surviving on disk), so this would false-positive on a legitimate build.
|
|
488
|
+
* - Flagging models with zero columns: a fabricating agent writes
|
|
489
|
+
* plausible-looking column lists (that's what makes the fabrication
|
|
490
|
+
* convincing), so this wouldn't even have caught the real incident —
|
|
491
|
+
* it's a weak signal with no compensating safety benefit.
|
|
492
|
+
* No cheap structural signal reliably distinguishes fabricated MDL from a
|
|
493
|
+
* real one. The completed-discovery gate is therefore the deterministic
|
|
494
|
+
* provenance boundary here; the prompt still tells the agent to never
|
|
495
|
+
* fabricate and to report failed discovery honestly as additional guidance.
|
|
496
|
+
*/
|
|
497
|
+
export declare function parseSetupTerminal(finalText: string, context: SetupTerminalContext): SetupTerminalResult;
|