@crewhaus/target-browser-driver 0.5.7 → 0.6.0
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/dist/index.js +14 -16
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
import { CrewhausError } from "@crewhaus/errors";
|
|
51
51
|
import { escapeJsonString } from "@crewhaus/infra-utils";
|
|
52
52
|
import { renderBundleReadme, } from "@crewhaus/ir";
|
|
53
|
+
import { HYBRID_FAMILIES_BY_SHAPE, HYBRID_WIRING_IMPORT, renderHybridWiringFields, renderModelWiringFields, } from "@crewhaus/model-service";
|
|
53
54
|
export class TargetEmitError extends CrewhausError {
|
|
54
55
|
name = "TargetEmitError";
|
|
55
56
|
constructor(message, cause) {
|
|
@@ -120,18 +121,6 @@ function resolveTools(toolNames, toolConfigs) {
|
|
|
120
121
|
}
|
|
121
122
|
return { imports, inits, registrations };
|
|
122
123
|
}
|
|
123
|
-
/**
|
|
124
|
-
* Adaptive model routing — render the `modelPool` runChatLoop field.
|
|
125
|
-
* JSON.stringify safely quotes the validated pool object (mirroring
|
|
126
|
-
* target-cli's renderModelFailoverFields; keep the pipeline/research/batch/
|
|
127
|
-
* browser copies in sync). Empty when the spec omits `model_pool`, keeping
|
|
128
|
-
* bundles byte-identical.
|
|
129
|
-
*/
|
|
130
|
-
function poolField(ir, indent) {
|
|
131
|
-
return ir.agent.modelPool !== undefined
|
|
132
|
-
? `\n${indent}modelPool: ${JSON.stringify(ir.agent.modelPool)},`
|
|
133
|
-
: "";
|
|
134
|
-
}
|
|
135
124
|
/**
|
|
136
125
|
* Section 55 / item 23 — render the `failureTaxonomy` runChatLoop field.
|
|
137
126
|
* Empty when the spec omits the block (mirror: target-cli +
|
|
@@ -209,6 +198,13 @@ export function emitBrowserDriver(ir, opts = {}) {
|
|
|
209
198
|
return { files };
|
|
210
199
|
}
|
|
211
200
|
function renderAgent(ir) {
|
|
201
|
+
// 0.6.0 PR 9f (§11.3) — the closure half of the pool: Consult / Escalate,
|
|
202
|
+
// the route classifier, the guide / shadow lanes. Rendered onto the shared
|
|
203
|
+
// `runOptions` both drives spread, so the REPL and the one-shot path carry
|
|
204
|
+
// the same closures. "" — and no import — when the pool declares none of
|
|
205
|
+
// them, so pre-0.6.0 browser bundles stay byte-identical.
|
|
206
|
+
const hybridFields = renderHybridWiringFields(ir.agent, " ", ir.name, HYBRID_FAMILIES_BY_SHAPE.browser);
|
|
207
|
+
const hybridImport = hybridFields.length > 0 ? `${HYBRID_WIRING_IMPORT}\n` : "";
|
|
212
208
|
const startUrl = ir.driver.startUrl;
|
|
213
209
|
// SECURITY — `driver.allowPrivateTargets` relaxes BOTH SSRF layers together:
|
|
214
210
|
// the chromium backend's DNS-pinning proxy and the Navigate tool's pre-goto
|
|
@@ -259,7 +255,7 @@ import { createFindElementTool } from "@crewhaus/tool-vision-grounding";
|
|
|
259
255
|
import { runChatLoop } from "@crewhaus/runtime-core";
|
|
260
256
|
import { createPendingApprovalStore, resolveSessionRootDir } from "@crewhaus/runtime-core";
|
|
261
257
|
import { createRunContext } from "@crewhaus/run-context";
|
|
262
|
-
import { defaultCatalog } from "@crewhaus/tool-catalog";
|
|
258
|
+
${hybridImport}import { defaultCatalog } from "@crewhaus/tool-catalog";
|
|
263
259
|
import { createSessionStore } from "@crewhaus/session-store";
|
|
264
260
|
import { createInMemoryIdempotencyStore, idempotencyKey, withIdempotency } from "@crewhaus/idempotency-keys";
|
|
265
261
|
${toolImportBlock}${hooksImport}${permImport}${toolBootBlock}
|
|
@@ -269,7 +265,9 @@ const SESSION_ID_REGEX = /^sess_[0-9a-f]{16}$/;
|
|
|
269
265
|
const SPEC_NAME = ${escapeJsonString(ir.name)};
|
|
270
266
|
const SPEC_MODEL = ${escapeJsonString(ir.agent.model)};
|
|
271
267
|
const SPEC_INSTRUCTIONS = ${escapeJsonString(ir.agent.instructions)};
|
|
272
|
-
const SPEC_GROUNDING_MODEL = ${escapeJsonString(ir.groundingModel)}
|
|
268
|
+
const SPEC_GROUNDING_MODEL = ${escapeJsonString(ir.groundingModel)};${ir.groundingParams !== undefined
|
|
269
|
+
? `\nconst SPEC_GROUNDING_PARAMS = ${JSON.stringify(ir.groundingParams)};`
|
|
270
|
+
: ""}
|
|
273
271
|
const SPEC_BACKEND: "host" | "chromium" | "remote" = ${escapeJsonString(ir.driver.backend)};
|
|
274
272
|
const SPEC_VIEWPORT = { width: ${ir.driver.viewport.width}, height: ${ir.driver.viewport.height} };
|
|
275
273
|
const SPEC_START_URL = ${startUrl !== undefined ? escapeJsonString(startUrl) : "undefined"};${hooksConst}
|
|
@@ -356,7 +354,7 @@ async function main(): Promise<void> {
|
|
|
356
354
|
const navigateTool = createNavigateTool({ driver${allowPrivateNavField} });
|
|
357
355
|
const screenshotTool = createScreenshotTool({ driver });
|
|
358
356
|
const mk = createAllMouseKeyboardTools({ driver });
|
|
359
|
-
const findElement = createFindElementTool({ driver, model: SPEC_GROUNDING_MODEL });
|
|
357
|
+
const findElement = createFindElementTool({ driver, model: SPEC_GROUNDING_MODEL${ir.groundingParams !== undefined ? ", params: SPEC_GROUNDING_PARAMS" : ""} });
|
|
360
358
|
const tools = [navigateTool, screenshotTool, mk.click, mk.type, mk.key, mk.scroll, findElement, ...defaultCatalog.list()];
|
|
361
359
|
|
|
362
360
|
// On resume the run context must carry the resumed sessionId (runtime-core
|
|
@@ -368,7 +366,7 @@ async function main(): Promise<void> {
|
|
|
368
366
|
// context. limits/budget/max_tokens (Batch A) apply to each turn.
|
|
369
367
|
const runOptions = {
|
|
370
368
|
model: SPEC_MODEL,
|
|
371
|
-
instructions: SPEC_INSTRUCTIONS,${
|
|
369
|
+
instructions: SPEC_INSTRUCTIONS,${renderModelWiringFields(ir.agent, " ")}${hybridFields}${taxonomyField(ir, " ")}
|
|
372
370
|
runContext,
|
|
373
371
|
sessionName: SPEC_NAME,
|
|
374
372
|
sessionTarget: "browser" as const,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crewhaus/target-browser-driver",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Codegen for the BROW target — emits a single agent.ts that boots a chromium driver + vision-grounding tools (Section 25 BROW)",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,9 +15,10 @@
|
|
|
15
15
|
"test": "bun test src"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@crewhaus/errors": "0.
|
|
19
|
-
"@crewhaus/infra-utils": "0.
|
|
20
|
-
"@crewhaus/ir": "0.
|
|
18
|
+
"@crewhaus/errors": "0.6.0",
|
|
19
|
+
"@crewhaus/infra-utils": "0.6.0",
|
|
20
|
+
"@crewhaus/ir": "0.6.0",
|
|
21
|
+
"@crewhaus/model-service": "0.6.0"
|
|
21
22
|
},
|
|
22
23
|
"license": "Apache-2.0",
|
|
23
24
|
"author": {
|