@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,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown when an `agent.tools[]` entry declares `source: "native"` under a
|
|
3
|
+
* name the injected native-tool registry has no factory for.
|
|
4
|
+
*/
|
|
5
|
+
export declare class UnknownNativeToolError extends Error {
|
|
6
|
+
constructor(name: string);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Thrown when an `agent.tools[]` entry declares `source: "mcp:<server>/<name>"`
|
|
10
|
+
* for a server id that has no entry in the runtime-injected `McpServerConfigMap`.
|
|
11
|
+
* This is the "server-missing" half of tool-level fail-fast — it fires before
|
|
12
|
+
* any MCP connection is attempted.
|
|
13
|
+
*/
|
|
14
|
+
export declare class McpServerNotConfiguredError extends Error {
|
|
15
|
+
constructor(serverId: string);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Thrown when a declared `mcp:<server>/<name>` tool's server connects
|
|
19
|
+
* successfully but its discovered tool set does not include `<name>`. This
|
|
20
|
+
* is the "tool-missing" half of tool-level fail-fast.
|
|
21
|
+
*/
|
|
22
|
+
export declare class McpToolNotExposedError extends Error {
|
|
23
|
+
constructor(serverId: string, toolName: string);
|
|
24
|
+
}
|
|
25
|
+
/** Thrown when an `agent.tools[]` entry's `source` is not `"native"` or `"mcp:<server>/<name>"`. */
|
|
26
|
+
export declare class UnsupportedToolSourceError extends Error {
|
|
27
|
+
constructor(source: string);
|
|
28
|
+
}
|
|
29
|
+
/** Thrown when the native `query` tool's underlying `wren` CLI invocation exits non-zero. */
|
|
30
|
+
export declare class WrenQueryExecutionError extends Error {
|
|
31
|
+
constructor(sql: string, exitCode: number, stderr: string);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Thrown when the `wren` binary cannot be found — either at preflight (not on
|
|
35
|
+
* `PATH` before a native-tool run even starts, see `resolveWrenBinary`) or
|
|
36
|
+
* mid-run (a spawn `ENOENT` on a `query` tool call, e.g. `wren` was
|
|
37
|
+
* uninstalled/moved after preflight passed; see `ExecResult.notFound` in
|
|
38
|
+
* `harness/exec/types.ts`). Deliberately its own error, distinct from
|
|
39
|
+
* `WrenQueryExecutionError`, so a missing binary is never mistaken for an
|
|
40
|
+
* ordinary nonzero exit (which the repair-fold loop may otherwise retry).
|
|
41
|
+
*/
|
|
42
|
+
export declare class WrenBinaryNotFoundError extends Error {
|
|
43
|
+
constructor(detail: string);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Thrown when the native `semantic_introspect` tool's underlying
|
|
47
|
+
* `wren context show -o json` invocation either exits non-zero or exits zero
|
|
48
|
+
* but prints stdout that doesn't parse as JSON. Both cases share this one
|
|
49
|
+
* error type because introspection has no per-call input (no SQL) to report
|
|
50
|
+
* alongside an exit-code failure — `detail` carries whichever of the two
|
|
51
|
+
* happened. (The `query` tool only wraps its non-zero-exit case in
|
|
52
|
+
* `WrenQueryExecutionError`; a `parseWrenJsonl` failure there surfaces as a
|
|
53
|
+
* raw parse error — introspection wraps both.) Kept distinct from
|
|
54
|
+
* `WrenQueryExecutionError` so a caller can still tell "the query tool
|
|
55
|
+
* failed" from "introspection failed" apart; a missing binary still surfaces
|
|
56
|
+
* as `WrenBinaryNotFoundError`, checked before either failure mode here.
|
|
57
|
+
*/
|
|
58
|
+
export declare class WrenIntrospectExecutionError extends Error {
|
|
59
|
+
constructor(detail: string);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Thrown when the `setup_execution` native tool's `exec` action is asked to
|
|
63
|
+
* run a command matching the destructive/redirection denylist (verbatim
|
|
64
|
+
* from warble's claude-agent-sdk dispatcher guardrails — see
|
|
65
|
+
* `harness/tools/setup-native.ts`'s doc comment). Thrown BEFORE the command
|
|
66
|
+
* is ever handed to `ExecutionEnv.exec`, so a rejection has zero side
|
|
67
|
+
* effects — nothing is spawned.
|
|
68
|
+
*/
|
|
69
|
+
export declare class SetupCommandDeniedError extends Error {
|
|
70
|
+
constructor(command: string, reason: string);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Thrown when the `setup_execution` native tool's `write` action is asked to
|
|
74
|
+
* write outside the setup workspace root — either the nominal
|
|
75
|
+
* `path.relative`-based check, or the realpath-based re-check that catches a
|
|
76
|
+
* symlink escape (mirroring `harness/route/artifact-content.ts`'s two-phase
|
|
77
|
+
* containment pattern). Thrown BEFORE `ExecutionEnv.writeFile` is ever
|
|
78
|
+
* called, so a rejection has zero side effects — nothing is written.
|
|
79
|
+
*/
|
|
80
|
+
export declare class SetupWriteScopeError extends Error {
|
|
81
|
+
constructor(requestedPath: string, scope: string);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Thrown when the `setup_execution` native tool's `exec` action is given a
|
|
85
|
+
* `cwd` that resolves outside the setup workspace root — the same two-phase
|
|
86
|
+
* containment check as `SetupWriteScopeError` (nominal `path.relative`, then
|
|
87
|
+
* a realpath re-check for a symlink escape), applied to the exec cwd instead
|
|
88
|
+
* of a write path. Thrown BEFORE `ExecutionEnv.exec` is ever called, so a
|
|
89
|
+
* rejection has zero side effects — nothing is spawned.
|
|
90
|
+
*/
|
|
91
|
+
export declare class SetupExecCwdScopeError extends Error {
|
|
92
|
+
constructor(requestedCwd: string, scope: string);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Thrown when the `setup_execution` native tool's flat input object is
|
|
96
|
+
* missing the field its declared `action` requires — e.g. `action: "exec"`
|
|
97
|
+
* with no `command`, or `action: "write"` with no `path`/`content`. The
|
|
98
|
+
* tool's exposed `inputSchema` must be a single top-level object rather than
|
|
99
|
+
* a discriminated union (see `harness/tools/setup-native.ts`'s module doc
|
|
100
|
+
* comment for why), so the per-action required-field combination a
|
|
101
|
+
* discriminated union would otherwise enforce at the schema level is instead
|
|
102
|
+
* checked in `execute`, BEFORE `assertCommandAllowed`/`assertWriteWithinScope`
|
|
103
|
+
* or any actual exec/write — a rejection here has zero side effects.
|
|
104
|
+
*/
|
|
105
|
+
export declare class SetupExecutionInputError extends Error {
|
|
106
|
+
constructor(action: string, missingField: string);
|
|
107
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown when an `agent.tools[]` entry declares `source: "native"` under a
|
|
3
|
+
* name the injected native-tool registry has no factory for.
|
|
4
|
+
*/
|
|
5
|
+
export class UnknownNativeToolError extends Error {
|
|
6
|
+
constructor(name) {
|
|
7
|
+
super(`no native tool registered for name: "${name}"`);
|
|
8
|
+
this.name = "UnknownNativeToolError";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Thrown when an `agent.tools[]` entry declares `source: "mcp:<server>/<name>"`
|
|
13
|
+
* for a server id that has no entry in the runtime-injected `McpServerConfigMap`.
|
|
14
|
+
* This is the "server-missing" half of tool-level fail-fast — it fires before
|
|
15
|
+
* any MCP connection is attempted.
|
|
16
|
+
*/
|
|
17
|
+
export class McpServerNotConfiguredError extends Error {
|
|
18
|
+
constructor(serverId) {
|
|
19
|
+
super(`agent declares a tool from MCP server "${serverId}" but no server ` +
|
|
20
|
+
`config was provided (expected an entry in the McpServerConfigMap)`);
|
|
21
|
+
this.name = "McpServerNotConfiguredError";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Thrown when a declared `mcp:<server>/<name>` tool's server connects
|
|
26
|
+
* successfully but its discovered tool set does not include `<name>`. This
|
|
27
|
+
* is the "tool-missing" half of tool-level fail-fast.
|
|
28
|
+
*/
|
|
29
|
+
export class McpToolNotExposedError extends Error {
|
|
30
|
+
constructor(serverId, toolName) {
|
|
31
|
+
super(`MCP server "${serverId}" does not expose a tool named "${toolName}"`);
|
|
32
|
+
this.name = "McpToolNotExposedError";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** Thrown when an `agent.tools[]` entry's `source` is not `"native"` or `"mcp:<server>/<name>"`. */
|
|
36
|
+
export class UnsupportedToolSourceError extends Error {
|
|
37
|
+
constructor(source) {
|
|
38
|
+
super(`unsupported tool source: "${source}" (expected "native" or "mcp:<server>/<name>")`);
|
|
39
|
+
this.name = "UnsupportedToolSourceError";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Thrown when the native `query` tool's underlying `wren` CLI invocation exits non-zero. */
|
|
43
|
+
export class WrenQueryExecutionError extends Error {
|
|
44
|
+
constructor(sql, exitCode, stderr) {
|
|
45
|
+
super(`wren query failed with exit code ${exitCode} for SQL: ${sql}\n${stderr}`);
|
|
46
|
+
this.name = "WrenQueryExecutionError";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Thrown when the `wren` binary cannot be found — either at preflight (not on
|
|
51
|
+
* `PATH` before a native-tool run even starts, see `resolveWrenBinary`) or
|
|
52
|
+
* mid-run (a spawn `ENOENT` on a `query` tool call, e.g. `wren` was
|
|
53
|
+
* uninstalled/moved after preflight passed; see `ExecResult.notFound` in
|
|
54
|
+
* `harness/exec/types.ts`). Deliberately its own error, distinct from
|
|
55
|
+
* `WrenQueryExecutionError`, so a missing binary is never mistaken for an
|
|
56
|
+
* ordinary nonzero exit (which the repair-fold loop may otherwise retry).
|
|
57
|
+
*/
|
|
58
|
+
export class WrenBinaryNotFoundError extends Error {
|
|
59
|
+
constructor(detail) {
|
|
60
|
+
super(`could not find the "wren" binary: ${detail}\nfix: install wren and ensure it is on PATH.`);
|
|
61
|
+
this.name = "WrenBinaryNotFoundError";
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Thrown when the native `semantic_introspect` tool's underlying
|
|
66
|
+
* `wren context show -o json` invocation either exits non-zero or exits zero
|
|
67
|
+
* but prints stdout that doesn't parse as JSON. Both cases share this one
|
|
68
|
+
* error type because introspection has no per-call input (no SQL) to report
|
|
69
|
+
* alongside an exit-code failure — `detail` carries whichever of the two
|
|
70
|
+
* happened. (The `query` tool only wraps its non-zero-exit case in
|
|
71
|
+
* `WrenQueryExecutionError`; a `parseWrenJsonl` failure there surfaces as a
|
|
72
|
+
* raw parse error — introspection wraps both.) Kept distinct from
|
|
73
|
+
* `WrenQueryExecutionError` so a caller can still tell "the query tool
|
|
74
|
+
* failed" from "introspection failed" apart; a missing binary still surfaces
|
|
75
|
+
* as `WrenBinaryNotFoundError`, checked before either failure mode here.
|
|
76
|
+
*/
|
|
77
|
+
export class WrenIntrospectExecutionError extends Error {
|
|
78
|
+
constructor(detail) {
|
|
79
|
+
super(`wren context show failed: ${detail}`);
|
|
80
|
+
this.name = "WrenIntrospectExecutionError";
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Thrown when the `setup_execution` native tool's `exec` action is asked to
|
|
85
|
+
* run a command matching the destructive/redirection denylist (verbatim
|
|
86
|
+
* from warble's claude-agent-sdk dispatcher guardrails — see
|
|
87
|
+
* `harness/tools/setup-native.ts`'s doc comment). Thrown BEFORE the command
|
|
88
|
+
* is ever handed to `ExecutionEnv.exec`, so a rejection has zero side
|
|
89
|
+
* effects — nothing is spawned.
|
|
90
|
+
*/
|
|
91
|
+
export class SetupCommandDeniedError extends Error {
|
|
92
|
+
constructor(command, reason) {
|
|
93
|
+
super(`setup command denied (${reason}): ${command}`);
|
|
94
|
+
this.name = "SetupCommandDeniedError";
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Thrown when the `setup_execution` native tool's `write` action is asked to
|
|
99
|
+
* write outside the setup workspace root — either the nominal
|
|
100
|
+
* `path.relative`-based check, or the realpath-based re-check that catches a
|
|
101
|
+
* symlink escape (mirroring `harness/route/artifact-content.ts`'s two-phase
|
|
102
|
+
* containment pattern). Thrown BEFORE `ExecutionEnv.writeFile` is ever
|
|
103
|
+
* called, so a rejection has zero side effects — nothing is written.
|
|
104
|
+
*/
|
|
105
|
+
export class SetupWriteScopeError extends Error {
|
|
106
|
+
constructor(requestedPath, scope) {
|
|
107
|
+
super(`setup write path "${requestedPath}" escapes the setup workspace scope "${scope}"`);
|
|
108
|
+
this.name = "SetupWriteScopeError";
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Thrown when the `setup_execution` native tool's `exec` action is given a
|
|
113
|
+
* `cwd` that resolves outside the setup workspace root — the same two-phase
|
|
114
|
+
* containment check as `SetupWriteScopeError` (nominal `path.relative`, then
|
|
115
|
+
* a realpath re-check for a symlink escape), applied to the exec cwd instead
|
|
116
|
+
* of a write path. Thrown BEFORE `ExecutionEnv.exec` is ever called, so a
|
|
117
|
+
* rejection has zero side effects — nothing is spawned.
|
|
118
|
+
*/
|
|
119
|
+
export class SetupExecCwdScopeError extends Error {
|
|
120
|
+
constructor(requestedCwd, scope) {
|
|
121
|
+
super(`setup exec cwd "${requestedCwd}" escapes the setup workspace scope "${scope}"`);
|
|
122
|
+
this.name = "SetupExecCwdScopeError";
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Thrown when the `setup_execution` native tool's flat input object is
|
|
127
|
+
* missing the field its declared `action` requires — e.g. `action: "exec"`
|
|
128
|
+
* with no `command`, or `action: "write"` with no `path`/`content`. The
|
|
129
|
+
* tool's exposed `inputSchema` must be a single top-level object rather than
|
|
130
|
+
* a discriminated union (see `harness/tools/setup-native.ts`'s module doc
|
|
131
|
+
* comment for why), so the per-action required-field combination a
|
|
132
|
+
* discriminated union would otherwise enforce at the schema level is instead
|
|
133
|
+
* checked in `execute`, BEFORE `assertCommandAllowed`/`assertWriteWithinScope`
|
|
134
|
+
* or any actual exec/write — a rejection here has zero side effects.
|
|
135
|
+
*/
|
|
136
|
+
export class SetupExecutionInputError extends Error {
|
|
137
|
+
constructor(action, missingField) {
|
|
138
|
+
super(`setup_execution action "${action}" requires a "${missingField}" field`);
|
|
139
|
+
this.name = "SetupExecutionInputError";
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { McpServerNotConfiguredError, McpToolNotExposedError, SetupCommandDeniedError, SetupWriteScopeError, UnknownNativeToolError, UnsupportedToolSourceError, WrenBinaryNotFoundError, WrenIntrospectExecutionError, WrenQueryExecutionError, } from "./errors.js";
|
|
2
|
+
export { parseToolSource } from "./parse.js";
|
|
3
|
+
export type { ParsedToolSource } from "./parse.js";
|
|
4
|
+
export { resolveWrenBinary } from "./resolve-wren-binary.js";
|
|
5
|
+
export { assembleDashboardBlocks, BUILD_DASHBOARD_TOOL_NAME, buildDashboardInputSchema, createBuildDashboardTool, createDefaultNativeToolRegistry, createNativeToolRegistry, createWrenNativeToolRegistry, createWrenQueryTool, createWrenSemanticIntrospectTool, createWriteArtifactTool, SEMANTIC_INTROSPECT_TOOL_NAME, WREN_QUERY_TOOL_NAME, WRITE_ARTIFACT_TOOL_NAME, } from "./native.js";
|
|
6
|
+
export type { BuildDashboardInput, BuildDashboardResult, NativeToolFactory, NativeToolRegistry, WrenNativeToolOptions, WrenQueryResult, WrenQueryToolOptions, WrenSemanticIntrospectResult, } from "./native.js";
|
|
7
|
+
export { createSetupExecutionTool, executeSetupExecution, setupExecutionInputSchema, SETUP_EXECUTION_TOOL_NAME, } from "./setup-native.js";
|
|
8
|
+
export type { SetupExecutionInput, SetupExecutionResult, SetupExecutionToolOptions } from "./setup-native.js";
|
|
9
|
+
export { connectMcpServer } from "./mcp.js";
|
|
10
|
+
export type { McpServerConfig, McpServerConfigMap } from "./mcp.js";
|
|
11
|
+
export { resolveTools } from "./resolve.js";
|
|
12
|
+
export type { ResolvedTools, ResolveToolsContext } from "./resolve.js";
|
|
13
|
+
export { withResolvedTools } from "./wiring.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { McpServerNotConfiguredError, McpToolNotExposedError, SetupCommandDeniedError, SetupWriteScopeError, UnknownNativeToolError, UnsupportedToolSourceError, WrenBinaryNotFoundError, WrenIntrospectExecutionError, WrenQueryExecutionError, } from "./errors.js";
|
|
2
|
+
export { parseToolSource } from "./parse.js";
|
|
3
|
+
export { resolveWrenBinary } from "./resolve-wren-binary.js";
|
|
4
|
+
export { assembleDashboardBlocks, BUILD_DASHBOARD_TOOL_NAME, buildDashboardInputSchema, createBuildDashboardTool, createDefaultNativeToolRegistry, createNativeToolRegistry, createWrenNativeToolRegistry, createWrenQueryTool, createWrenSemanticIntrospectTool, createWriteArtifactTool, SEMANTIC_INTROSPECT_TOOL_NAME, WREN_QUERY_TOOL_NAME, WRITE_ARTIFACT_TOOL_NAME, } from "./native.js";
|
|
5
|
+
export { createSetupExecutionTool, executeSetupExecution, setupExecutionInputSchema, SETUP_EXECUTION_TOOL_NAME, } from "./setup-native.js";
|
|
6
|
+
export { connectMcpServer } from "./mcp.js";
|
|
7
|
+
export { resolveTools } from "./resolve.js";
|
|
8
|
+
export { withResolvedTools } from "./wiring.js";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type MCPClient, type MCPClientConfig } from "@ai-sdk/mcp";
|
|
2
|
+
/**
|
|
3
|
+
* Connection config for one MCP server, keyed by server id (e.g. `"wren"`)
|
|
4
|
+
* in `McpServerConfigMap`. Two shapes: `"stdio"` spawns a local process
|
|
5
|
+
* (the real `mcp:wren` wiring — a `wren` MCP process over a jaffle DuckDB —
|
|
6
|
+
* is this shape), and `"transport"` accepts any `@ai-sdk/mcp` transport config/instance
|
|
7
|
+
* directly (http/sse, or a hand-rolled `MCPTransport` such as the hermetic
|
|
8
|
+
* mock server this package's tests spawn over stdio).
|
|
9
|
+
*
|
|
10
|
+
* This is always supplied by the caller at run time — never read from the
|
|
11
|
+
* bundle (the bundle only names the server id via `mcp:<server>/<name>`).
|
|
12
|
+
*/
|
|
13
|
+
export type McpServerConfig = {
|
|
14
|
+
readonly kind: "stdio";
|
|
15
|
+
readonly command: string;
|
|
16
|
+
readonly args?: readonly string[];
|
|
17
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
18
|
+
readonly cwd?: string;
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: "transport";
|
|
21
|
+
readonly transport: MCPClientConfig["transport"];
|
|
22
|
+
};
|
|
23
|
+
/** Runtime-injected map of MCP server id -> connection config. */
|
|
24
|
+
export type McpServerConfigMap = Readonly<Record<string, McpServerConfig>>;
|
|
25
|
+
/** Connects to one configured MCP server, returning the live client. */
|
|
26
|
+
export declare function connectMcpServer(config: McpServerConfig): Promise<MCPClient>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createMCPClient } from "@ai-sdk/mcp";
|
|
2
|
+
import { Experimental_StdioMCPTransport } from "@ai-sdk/mcp/mcp-stdio";
|
|
3
|
+
const DEFAULT_CLIENT_NAME = "wren-harness";
|
|
4
|
+
/** Connects to one configured MCP server, returning the live client. */
|
|
5
|
+
export async function connectMcpServer(config) {
|
|
6
|
+
const transport = config.kind === "stdio"
|
|
7
|
+
? new Experimental_StdioMCPTransport({
|
|
8
|
+
command: config.command,
|
|
9
|
+
...(config.args ? { args: [...config.args] } : {}),
|
|
10
|
+
...(config.env ? { env: { ...config.env } } : {}),
|
|
11
|
+
...(config.cwd ? { cwd: config.cwd } : {}),
|
|
12
|
+
})
|
|
13
|
+
: config.transport;
|
|
14
|
+
return createMCPClient({ transport, clientName: DEFAULT_CLIENT_NAME });
|
|
15
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { type Tool } from "ai";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import type { ExecutionEnv, ExecutionPolicy } from "../exec/index.js";
|
|
4
|
+
/** Builds a fresh AI SDK tool instance for a registered native tool name. */
|
|
5
|
+
export type NativeToolFactory = () => Tool;
|
|
6
|
+
/**
|
|
7
|
+
* Injectable registry mapping a harness-native tool name (open string, e.g.
|
|
8
|
+
* `write_artifact`) to a factory that builds the AI SDK `Tool` for it.
|
|
9
|
+
* Mirrors the shape of `ProviderRegistry` (harness/providers/registry.ts):
|
|
10
|
+
* an empty registry callers populate, plus a default-populated convenience
|
|
11
|
+
* constructor.
|
|
12
|
+
*/
|
|
13
|
+
export interface NativeToolRegistry {
|
|
14
|
+
register(name: string, factory: NativeToolFactory): void;
|
|
15
|
+
has(name: string): boolean;
|
|
16
|
+
create(name: string): Tool;
|
|
17
|
+
}
|
|
18
|
+
export declare function createNativeToolRegistry(): NativeToolRegistry;
|
|
19
|
+
export declare const WRITE_ARTIFACT_TOOL_NAME = "write_artifact";
|
|
20
|
+
/**
|
|
21
|
+
* `write_artifact`: routes the write through the injected `ExecutionEnv`,
|
|
22
|
+
* confined to `policy.artifactWriteScope`. The policy is the
|
|
23
|
+
* `deriveEnforcement`-computed `EnforcementPolicy` for the owning
|
|
24
|
+
* agent — a locked `scoped_write` guardrail is what grants
|
|
25
|
+
* `artifactWriteScope` in the first place, so an agent with no such
|
|
26
|
+
* guardrail gets a policy with no scope and every call fails closed with
|
|
27
|
+
* `WriteScopeNotGrantedError` (thrown by the `ExecutionEnv`, not here).
|
|
28
|
+
* This coexists with a locked `read_only_execution` guardrail by design:
|
|
29
|
+
* `readOnly` gates *data-access* execution (`exec`/non-allowlisted
|
|
30
|
+
* `fetch`), never the scoped artifact write.
|
|
31
|
+
*/
|
|
32
|
+
export declare function createWriteArtifactTool(env: ExecutionEnv, policy: ExecutionPolicy): Tool;
|
|
33
|
+
/** A native-tool registry pre-populated with the built-in `write_artifact` and `build_dashboard` tools, bound to `env`/`policy`. */
|
|
34
|
+
export declare function createDefaultNativeToolRegistry(env: ExecutionEnv, policy: ExecutionPolicy): NativeToolRegistry;
|
|
35
|
+
export declare const BUILD_DASHBOARD_TOOL_NAME = "build_dashboard";
|
|
36
|
+
export declare const buildDashboardInputSchema: z.ZodObject<{
|
|
37
|
+
kpi_cards: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
38
|
+
label: z.ZodString;
|
|
39
|
+
value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
40
|
+
unit: z.ZodOptional<z.ZodString>;
|
|
41
|
+
delta: z.ZodOptional<z.ZodNumber>;
|
|
42
|
+
}, z.core.$strip>>>;
|
|
43
|
+
chart: z.ZodOptional<z.ZodObject<{
|
|
44
|
+
chart_type: z.ZodEnum<{
|
|
45
|
+
area: "area";
|
|
46
|
+
bar: "bar";
|
|
47
|
+
line: "line";
|
|
48
|
+
pie: "pie";
|
|
49
|
+
scatter: "scatter";
|
|
50
|
+
}>;
|
|
51
|
+
x: z.ZodString;
|
|
52
|
+
series: z.ZodArray<z.ZodString>;
|
|
53
|
+
rows: z.ZodArray<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodUnknown>]>>;
|
|
54
|
+
}, z.core.$strip>>;
|
|
55
|
+
table: z.ZodOptional<z.ZodObject<{
|
|
56
|
+
columns: z.ZodArray<z.ZodString>;
|
|
57
|
+
rows: z.ZodArray<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodUnknown>]>>;
|
|
58
|
+
}, z.core.$strip>>;
|
|
59
|
+
definition: z.ZodOptional<z.ZodObject<{
|
|
60
|
+
sql: z.ZodString;
|
|
61
|
+
source_tables: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
62
|
+
filters: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
63
|
+
}, z.core.$strip>>;
|
|
64
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
export type BuildDashboardInput = z.infer<typeof buildDashboardInputSchema>;
|
|
67
|
+
/** The deterministically-assembled `{blocks}` payload `build_dashboard` returns — already the render-envelope shape `generate_dashboard`'s `output_schema` expects. */
|
|
68
|
+
export interface BuildDashboardResult {
|
|
69
|
+
readonly blocks: Record<string, unknown>[];
|
|
70
|
+
readonly summary?: string;
|
|
71
|
+
/**
|
|
72
|
+
* CAVEAT: `verified` here is SELF-DECLARED by the tool's structured input,
|
|
73
|
+
* NOT earned from a real successful `query` call the way the `toolTable`
|
|
74
|
+
* path's `verified` is (that one is tied to `run.ts`'s
|
|
75
|
+
* `sawSuccessfulDataAccessCall`). This is inert today because
|
|
76
|
+
* `generate_dashboard` declares NO locked `gated_check` guardrail, so the
|
|
77
|
+
* deterministic gate never inspects it. If a future profile ever adds a
|
|
78
|
+
* `gated_check` to `generate_dashboard`, this capture path must ALSO be
|
|
79
|
+
* updated to earn `verified` from the real per-panel `query` calls —
|
|
80
|
+
* otherwise the gate would be trivially satisfiable by any `build_dashboard`
|
|
81
|
+
* call carrying hallucinated panel data.
|
|
82
|
+
*/
|
|
83
|
+
readonly verified: true;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Deterministically assembles the typed panels the model composed
|
|
87
|
+
* (`kpi_cards`/`chart`/`table`/`definition`) into `generate_dashboard`'s
|
|
88
|
+
* `{blocks}` render contract — one `kpi_card` block per KPI, then `chart`,
|
|
89
|
+
* then `table`, then `definition` (this is the "sensible dashboard order":
|
|
90
|
+
* headline numbers first, then the visual trend/breakdown, then the
|
|
91
|
+
* supporting detail, then the query provenance), each only when the
|
|
92
|
+
* corresponding panel is present in `input`. No LLM call, no I/O — pure
|
|
93
|
+
* reshaping of model-supplied, schema-validated structure, which is what
|
|
94
|
+
* makes this safe to trust as `verified: true` (see `WrenQueryResult`'s own
|
|
95
|
+
* reasoning for why a real, non-erroring data-access result earns
|
|
96
|
+
* `verified`): every panel here was composed by the model from its own
|
|
97
|
+
* queried results, not fabricated by this function.
|
|
98
|
+
*/
|
|
99
|
+
export declare function assembleDashboardBlocks(input: BuildDashboardInput): BuildDashboardResult;
|
|
100
|
+
/**
|
|
101
|
+
* `build_dashboard` (native realization): a schema-enforced, purely
|
|
102
|
+
* deterministic assembly tool. The zod `inputSchema` is what makes the model
|
|
103
|
+
* reliably supply *structured* panels (typed kpi/chart/table/definition
|
|
104
|
+
* shapes) instead of prose it would otherwise have to be trusted to format
|
|
105
|
+
* correctly; `execute` then just reshapes that already-validated input into
|
|
106
|
+
* the render contract — no LLM call, no I/O, so it can never itself fail
|
|
107
|
+
* non-deterministically the way a render-LLM synthesis step can.
|
|
108
|
+
*/
|
|
109
|
+
export declare function createBuildDashboardTool(): Tool;
|
|
110
|
+
export declare const WREN_QUERY_TOOL_NAME = "query";
|
|
111
|
+
export interface WrenQueryToolOptions {
|
|
112
|
+
/** Backend the CLI invocation runs through — never a direct child_process call (mirrors write_artifact's own routing through the injected `ExecutionEnv`). */
|
|
113
|
+
readonly env: ExecutionEnv;
|
|
114
|
+
readonly policy: ExecutionPolicy;
|
|
115
|
+
/** Directory containing `wren_project.yml` + a built `target/mdl.json`; becomes the CLI invocation's cwd. */
|
|
116
|
+
readonly projectDir: string;
|
|
117
|
+
}
|
|
118
|
+
/** The parsed result of a `query` tool call: `wren -o json`'s JSONL stdout, reshaped into columns + row objects. */
|
|
119
|
+
export interface WrenQueryResult {
|
|
120
|
+
readonly columns: readonly string[];
|
|
121
|
+
readonly rows: readonly Record<string, unknown>[];
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* `query` (native realization): runs a read-only SQL query through the real
|
|
125
|
+
* `wren` CLI — `wren -q -o json [-l <limit>] -s '<sql>'` — executed via the
|
|
126
|
+
* injected `ExecutionEnv` with `cwd: projectDir`, exactly like
|
|
127
|
+
* `write_artifact` routes through `env.writeFile` instead of touching the
|
|
128
|
+
* filesystem directly. Declared `mode: "read"` so a locked
|
|
129
|
+
* `read_only_execution` guardrail (which `answer_query` always carries)
|
|
130
|
+
* never blocks it — only `mode: "write"` commands are rejected by a
|
|
131
|
+
* read-only policy (see `ExecutionEnv.exec`'s doc comment).
|
|
132
|
+
*
|
|
133
|
+
* `policy.rowLimit` (guardrail-enforcement fix): clamps `input.limit` via
|
|
134
|
+
* `clampRowLimit`, so a locked `row_limit` guardrail actually bounds `-l`
|
|
135
|
+
* instead of being derived and then ignored. `policy.statementTimeoutSec`
|
|
136
|
+
* becomes `ExecCommand.timeoutMs` on the `wren` invocation, so a locked
|
|
137
|
+
* `statement_timeout` guardrail actually kills a runaway query instead of
|
|
138
|
+
* letting it run unbounded.
|
|
139
|
+
*
|
|
140
|
+
* `wren -o json` prints one JSON object per result row (JSONL, not a JSON
|
|
141
|
+
* array) — this parses that into `{ columns, rows }`, where `columns` are
|
|
142
|
+
* the first row's keys (an empty result set yields `columns: []`).
|
|
143
|
+
*/
|
|
144
|
+
export declare function createWrenQueryTool(options: WrenQueryToolOptions): Tool;
|
|
145
|
+
export declare const SEMANTIC_INTROSPECT_TOOL_NAME = "semantic_introspect";
|
|
146
|
+
/** The parsed result of a `semantic_introspect` tool call: `wren context show -o json`'s single JSON object, passed through as-is (models/relationships/views/cubes/dataSource — the model reads it directly, this tool does no reshaping). */
|
|
147
|
+
export type WrenSemanticIntrospectResult = Record<string, unknown>;
|
|
148
|
+
/**
|
|
149
|
+
* `semantic_introspect` (native realization): introspects the bound
|
|
150
|
+
* semantic layer via the real `wren` CLI — `wren context show -o json` —
|
|
151
|
+
* executed via the injected `ExecutionEnv` with `cwd: projectDir`, the same
|
|
152
|
+
* shape as {@link createWrenQueryTool}. Declared `mode: "read"` for the same
|
|
153
|
+
* reason `query` is: `explore_model` always carries a locked
|
|
154
|
+
* `read_only_execution` guardrail, and this must never be blocked by it.
|
|
155
|
+
*
|
|
156
|
+
* Unlike `query`, `wren context show -o json` prints a SINGLE JSON object
|
|
157
|
+
* (not JSONL), so this parses with a plain `JSON.parse` rather than
|
|
158
|
+
* `parseWrenJsonl`, and takes no per-call input (introspection covers the
|
|
159
|
+
* whole project, not one statement) — `inputSchema` is deliberately empty.
|
|
160
|
+
*
|
|
161
|
+
* NOTE: `wren cube list` enrichment (cubes/metrics, "if available" per the
|
|
162
|
+
* component's step prompt) is intentionally deferred — it prints plain,
|
|
163
|
+
* non-JSON text (e.g. "No cubes defined.") rather than structured output,
|
|
164
|
+
* which would need its own ad hoc parser for a v1 that's optional per the
|
|
165
|
+
* step prompt anyway.
|
|
166
|
+
*/
|
|
167
|
+
export declare function createWrenSemanticIntrospectTool(options: WrenQueryToolOptions): Tool;
|
|
168
|
+
/** Options for {@link createWrenNativeToolRegistry} — the `query` tool's options, reused as the registry's binding. */
|
|
169
|
+
export type WrenNativeToolOptions = WrenQueryToolOptions;
|
|
170
|
+
/**
|
|
171
|
+
* A native-tool registry carrying both the built-in `write_artifact` tool
|
|
172
|
+
* (bound to `options.env`/`options.policy`, same as
|
|
173
|
+
* `createDefaultNativeToolRegistry`) and the real `query` tool wired to
|
|
174
|
+
* `options.projectDir`. Pass this as `RunAgentContext.nativeTools` to
|
|
175
|
+
* resolve an `answer_query` agent whose `query` tool declares
|
|
176
|
+
* `source: "native"` to a real `wren` CLI invocation instead of an MCP
|
|
177
|
+
* server.
|
|
178
|
+
*/
|
|
179
|
+
export declare function createWrenNativeToolRegistry(options: WrenNativeToolOptions): NativeToolRegistry;
|