@tangle-network/browser-agent-driver 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/LICENSE +196 -0
- package/README.md +149 -0
- package/dist/artifacts/composite-sink.d.ts +15 -0
- package/dist/artifacts/composite-sink.d.ts.map +1 -0
- package/dist/artifacts/composite-sink.js +27 -0
- package/dist/artifacts/composite-sink.js.map +1 -0
- package/dist/artifacts/filesystem-sink.d.ts +26 -0
- package/dist/artifacts/filesystem-sink.d.ts.map +1 -0
- package/dist/artifacts/filesystem-sink.js +81 -0
- package/dist/artifacts/filesystem-sink.js.map +1 -0
- package/dist/artifacts/types.d.ts +97 -0
- package/dist/artifacts/types.d.ts.map +1 -0
- package/dist/artifacts/types.js +9 -0
- package/dist/artifacts/types.js.map +1 -0
- package/dist/artifacts/webhook-sink.d.ts +71 -0
- package/dist/artifacts/webhook-sink.d.ts.map +1 -0
- package/dist/artifacts/webhook-sink.js +117 -0
- package/dist/artifacts/webhook-sink.js.map +1 -0
- package/dist/brain/index.d.ts +149 -0
- package/dist/brain/index.d.ts.map +1 -0
- package/dist/brain/index.js +1030 -0
- package/dist/brain/index.js.map +1 -0
- package/dist/browser-launch.d.ts +27 -0
- package/dist/browser-launch.d.ts.map +1 -0
- package/dist/browser-launch.js +92 -0
- package/dist/browser-launch.js.map +1 -0
- package/dist/cli.d.ts +14 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +1035 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +143 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +205 -0
- package/dist/config.js.map +1 -0
- package/dist/context-budget.d.ts +14 -0
- package/dist/context-budget.d.ts.map +1 -0
- package/dist/context-budget.js +39 -0
- package/dist/context-budget.js.map +1 -0
- package/dist/design-audit.d.ts +48 -0
- package/dist/design-audit.d.ts.map +1 -0
- package/dist/design-audit.js +172 -0
- package/dist/design-audit.js.map +1 -0
- package/dist/domain-policy.d.ts +4 -0
- package/dist/domain-policy.d.ts.map +1 -0
- package/dist/domain-policy.js +69 -0
- package/dist/domain-policy.js.map +1 -0
- package/dist/drivers/block-patterns.d.ts +11 -0
- package/dist/drivers/block-patterns.d.ts.map +1 -0
- package/dist/drivers/block-patterns.js +123 -0
- package/dist/drivers/block-patterns.js.map +1 -0
- package/dist/drivers/cdp-page-state.d.ts +22 -0
- package/dist/drivers/cdp-page-state.d.ts.map +1 -0
- package/dist/drivers/cdp-page-state.js +38 -0
- package/dist/drivers/cdp-page-state.js.map +1 -0
- package/dist/drivers/cdp-snapshot.d.ts +32 -0
- package/dist/drivers/cdp-snapshot.d.ts.map +1 -0
- package/dist/drivers/cdp-snapshot.js +120 -0
- package/dist/drivers/cdp-snapshot.js.map +1 -0
- package/dist/drivers/playwright.d.ts +84 -0
- package/dist/drivers/playwright.d.ts.map +1 -0
- package/dist/drivers/playwright.js +385 -0
- package/dist/drivers/playwright.js.map +1 -0
- package/dist/drivers/snapshot.d.ts +134 -0
- package/dist/drivers/snapshot.d.ts.map +1 -0
- package/dist/drivers/snapshot.js +354 -0
- package/dist/drivers/snapshot.js.map +1 -0
- package/dist/drivers/types.d.ts +37 -0
- package/dist/drivers/types.d.ts.map +1 -0
- package/dist/drivers/types.js +5 -0
- package/dist/drivers/types.js.map +1 -0
- package/dist/env-loader.d.ts +2 -0
- package/dist/env-loader.d.ts.map +1 -0
- package/dist/env-loader.js +35 -0
- package/dist/env-loader.js.map +1 -0
- package/dist/formatters/slack.d.ts +37 -0
- package/dist/formatters/slack.d.ts.map +1 -0
- package/dist/formatters/slack.js +97 -0
- package/dist/formatters/slack.js.map +1 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/memory/analyzer.d.ts +67 -0
- package/dist/memory/analyzer.d.ts.map +1 -0
- package/dist/memory/analyzer.js +265 -0
- package/dist/memory/analyzer.js.map +1 -0
- package/dist/memory/knowledge.d.ts +55 -0
- package/dist/memory/knowledge.d.ts.map +1 -0
- package/dist/memory/knowledge.js +115 -0
- package/dist/memory/knowledge.js.map +1 -0
- package/dist/memory/project-store.d.ts +43 -0
- package/dist/memory/project-store.d.ts.map +1 -0
- package/dist/memory/project-store.js +119 -0
- package/dist/memory/project-store.js.map +1 -0
- package/dist/memory/selectors.d.ts +46 -0
- package/dist/memory/selectors.d.ts.map +1 -0
- package/dist/memory/selectors.js +89 -0
- package/dist/memory/selectors.js.map +1 -0
- package/dist/memory/store.d.ts +39 -0
- package/dist/memory/store.d.ts.map +1 -0
- package/dist/memory/store.js +193 -0
- package/dist/memory/store.js.map +1 -0
- package/dist/model-pricing.d.ts +41 -0
- package/dist/model-pricing.d.ts.map +1 -0
- package/dist/model-pricing.js +197 -0
- package/dist/model-pricing.js.map +1 -0
- package/dist/multi-actor.d.ts +108 -0
- package/dist/multi-actor.d.ts.map +1 -0
- package/dist/multi-actor.js +192 -0
- package/dist/multi-actor.js.map +1 -0
- package/dist/override-pipeline.d.ts +57 -0
- package/dist/override-pipeline.d.ts.map +1 -0
- package/dist/override-pipeline.js +26 -0
- package/dist/override-pipeline.js.map +1 -0
- package/dist/personas.d.ts +19 -0
- package/dist/personas.d.ts.map +1 -0
- package/dist/personas.js +86 -0
- package/dist/personas.js.map +1 -0
- package/dist/preview.d.ts +32 -0
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +138 -0
- package/dist/preview.js.map +1 -0
- package/dist/provider-defaults.d.ts +6 -0
- package/dist/provider-defaults.d.ts.map +1 -0
- package/dist/provider-defaults.js +40 -0
- package/dist/provider-defaults.js.map +1 -0
- package/dist/providers/sandbox-backend.d.ts +22 -0
- package/dist/providers/sandbox-backend.d.ts.map +1 -0
- package/dist/providers/sandbox-backend.js +259 -0
- package/dist/providers/sandbox-backend.js.map +1 -0
- package/dist/recovery.d.ts +91 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +500 -0
- package/dist/recovery.js.map +1 -0
- package/dist/reporters/junit.d.ts +8 -0
- package/dist/reporters/junit.d.ts.map +1 -0
- package/dist/reporters/junit.js +99 -0
- package/dist/reporters/junit.js.map +1 -0
- package/dist/run-metrics.d.ts +4 -0
- package/dist/run-metrics.d.ts.map +1 -0
- package/dist/run-metrics.js +48 -0
- package/dist/run-metrics.js.map +1 -0
- package/dist/run-state.d.ts +22 -0
- package/dist/run-state.d.ts.map +1 -0
- package/dist/run-state.js +33 -0
- package/dist/run-state.js.map +1 -0
- package/dist/runner/goal-verification.d.ts +13 -0
- package/dist/runner/goal-verification.d.ts.map +1 -0
- package/dist/runner/goal-verification.js +152 -0
- package/dist/runner/goal-verification.js.map +1 -0
- package/dist/runner/index.d.ts +12 -0
- package/dist/runner/index.d.ts.map +1 -0
- package/dist/runner/index.js +18 -0
- package/dist/runner/index.js.map +1 -0
- package/dist/runner/overrides.d.ts +75 -0
- package/dist/runner/overrides.d.ts.map +1 -0
- package/dist/runner/overrides.js +385 -0
- package/dist/runner/overrides.js.map +1 -0
- package/dist/runner/page-analysis.d.ts +23 -0
- package/dist/runner/page-analysis.d.ts.map +1 -0
- package/dist/runner/page-analysis.js +91 -0
- package/dist/runner/page-analysis.js.map +1 -0
- package/dist/runner/runner.d.ts +66 -0
- package/dist/runner/runner.d.ts.map +1 -0
- package/dist/runner/runner.js +1314 -0
- package/dist/runner/runner.js.map +1 -0
- package/dist/runner/scout.d.ts +29 -0
- package/dist/runner/scout.d.ts.map +1 -0
- package/dist/runner/scout.js +81 -0
- package/dist/runner/scout.js.map +1 -0
- package/dist/runner/search-guidance.d.ts +31 -0
- package/dist/runner/search-guidance.d.ts.map +1 -0
- package/dist/runner/search-guidance.js +210 -0
- package/dist/runner/search-guidance.js.map +1 -0
- package/dist/runner/utils.d.ts +28 -0
- package/dist/runner/utils.d.ts.map +1 -0
- package/dist/runner/utils.js +119 -0
- package/dist/runner/utils.js.map +1 -0
- package/dist/runner.d.ts +8 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +21 -0
- package/dist/runner.js.map +1 -0
- package/dist/supervisor/critic.d.ts +29 -0
- package/dist/supervisor/critic.d.ts.map +1 -0
- package/dist/supervisor/critic.js +320 -0
- package/dist/supervisor/critic.js.map +1 -0
- package/dist/supervisor/policy.d.ts +11 -0
- package/dist/supervisor/policy.d.ts.map +1 -0
- package/dist/supervisor/policy.js +118 -0
- package/dist/supervisor/policy.js.map +1 -0
- package/dist/test-report.d.ts +15 -0
- package/dist/test-report.d.ts.map +1 -0
- package/dist/test-report.js +241 -0
- package/dist/test-report.js.map +1 -0
- package/dist/test-runner.d.ts +99 -0
- package/dist/test-runner.d.ts.map +1 -0
- package/dist/test-runner.js +1075 -0
- package/dist/test-runner.js.map +1 -0
- package/dist/types.d.ts +493 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/wallet/automation.d.ts +52 -0
- package/dist/wallet/automation.d.ts.map +1 -0
- package/dist/wallet/automation.js +507 -0
- package/dist/wallet/automation.js.map +1 -0
- package/package.json +101 -0
- package/scripts/postinstall-provider-patches.mjs +52 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-Actor Session — coordinated multi-user browser testing
|
|
3
|
+
*
|
|
4
|
+
* Each actor gets an isolated BrowserContext (separate cookies, localStorage,
|
|
5
|
+
* auth state) while sharing the same Browser instance. Consumers orchestrate
|
|
6
|
+
* with standard async/await for sequential flows and Promise.all() for parallel.
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const session = await MultiActorSession.create(browser, {
|
|
10
|
+
* actors: {
|
|
11
|
+
* admin: { storageState: '.auth/admin.json' },
|
|
12
|
+
* partner: { storageState: '.auth/partner.json' },
|
|
13
|
+
* user1: {},
|
|
14
|
+
* },
|
|
15
|
+
* agentConfig: { model: 'gpt-4o', vision: true },
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* await session.actor('admin').run({ goal: 'Create quest', startUrl: '/admin' });
|
|
19
|
+
* await session.actor('partner').run({ goal: 'Approve quest' });
|
|
20
|
+
*
|
|
21
|
+
* await session.parallel(
|
|
22
|
+
* ['user1', { goal: 'Start quest' }],
|
|
23
|
+
* ['admin', { goal: 'Monitor dashboard' }],
|
|
24
|
+
* );
|
|
25
|
+
*
|
|
26
|
+
* await session.close();
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
import { PlaywrightDriver } from './drivers/playwright.js';
|
|
30
|
+
import { AgentRunner } from './runner.js';
|
|
31
|
+
// ── Actor ──
|
|
32
|
+
export class Actor {
|
|
33
|
+
name;
|
|
34
|
+
_context;
|
|
35
|
+
_page;
|
|
36
|
+
_driver;
|
|
37
|
+
_runner;
|
|
38
|
+
_results = [];
|
|
39
|
+
constructor(name, _context, _page, _driver, _runner) {
|
|
40
|
+
this.name = name;
|
|
41
|
+
this._context = _context;
|
|
42
|
+
this._page = _page;
|
|
43
|
+
this._driver = _driver;
|
|
44
|
+
this._runner = _runner;
|
|
45
|
+
}
|
|
46
|
+
/** Run a scenario with this actor's agent. Results accumulate across calls. */
|
|
47
|
+
async run(scenario) {
|
|
48
|
+
const result = await this._runner.run(scenario);
|
|
49
|
+
this._results.push(result);
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
/** Raw Playwright page for direct operations / assertions */
|
|
53
|
+
get page() {
|
|
54
|
+
return this._page;
|
|
55
|
+
}
|
|
56
|
+
/** BrowserContext for cookie/storage inspection */
|
|
57
|
+
get context() {
|
|
58
|
+
return this._context;
|
|
59
|
+
}
|
|
60
|
+
/** PlaywrightDriver for low-level driver access */
|
|
61
|
+
get driver() {
|
|
62
|
+
return this._driver;
|
|
63
|
+
}
|
|
64
|
+
/** All results from this actor's runs */
|
|
65
|
+
get results() {
|
|
66
|
+
return this._results;
|
|
67
|
+
}
|
|
68
|
+
/** Most recent result, or undefined if no runs yet */
|
|
69
|
+
get lastResult() {
|
|
70
|
+
return this._results[this._results.length - 1];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// ── MultiActorSession ──
|
|
74
|
+
export class MultiActorSession {
|
|
75
|
+
_actors;
|
|
76
|
+
_closed = false;
|
|
77
|
+
constructor(actors) {
|
|
78
|
+
this._actors = actors;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Create a session with isolated browser contexts per actor.
|
|
82
|
+
*
|
|
83
|
+
* 1. Creates BrowserContext + Page + PlaywrightDriver + AgentRunner per actor
|
|
84
|
+
* 2. Calls setup() hooks if provided
|
|
85
|
+
* 3. Returns session ready for orchestration
|
|
86
|
+
*/
|
|
87
|
+
static async create(browser, config) {
|
|
88
|
+
const actors = new Map();
|
|
89
|
+
const createdContexts = [];
|
|
90
|
+
try {
|
|
91
|
+
for (const [name, actorCfg] of Object.entries(config.actors)) {
|
|
92
|
+
// Merge shared + per-actor agent config
|
|
93
|
+
const mergedAgentConfig = {
|
|
94
|
+
...config.agentConfig,
|
|
95
|
+
...actorCfg.agentConfig,
|
|
96
|
+
};
|
|
97
|
+
// Build context options with storageState
|
|
98
|
+
const contextOptions = {
|
|
99
|
+
...actorCfg.contextOptions,
|
|
100
|
+
};
|
|
101
|
+
if (actorCfg.storageState) {
|
|
102
|
+
contextOptions.storageState = actorCfg.storageState;
|
|
103
|
+
}
|
|
104
|
+
const context = await browser.newContext(contextOptions);
|
|
105
|
+
createdContexts.push(context);
|
|
106
|
+
const page = await context.newPage();
|
|
107
|
+
const driver = new PlaywrightDriver(page, actorCfg.driverOptions);
|
|
108
|
+
// Wire onTurn to prefix with actor name
|
|
109
|
+
const onTurn = config.onTurn
|
|
110
|
+
? (turn) => config.onTurn(name, turn)
|
|
111
|
+
: undefined;
|
|
112
|
+
const runnerOpts = {
|
|
113
|
+
driver,
|
|
114
|
+
config: mergedAgentConfig,
|
|
115
|
+
onTurn,
|
|
116
|
+
projectStore: config.projectStore,
|
|
117
|
+
};
|
|
118
|
+
const runner = new AgentRunner(runnerOpts);
|
|
119
|
+
// Run actor setup hook (e.g., manual login flow)
|
|
120
|
+
if (actorCfg.setup) {
|
|
121
|
+
await actorCfg.setup(page);
|
|
122
|
+
}
|
|
123
|
+
actors.set(name, new Actor(name, context, page, driver, runner));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
catch (err) {
|
|
127
|
+
// Clean up already-created contexts on partial failure
|
|
128
|
+
for (const ctx of createdContexts) {
|
|
129
|
+
await ctx.close().catch(() => { });
|
|
130
|
+
}
|
|
131
|
+
throw err;
|
|
132
|
+
}
|
|
133
|
+
return new MultiActorSession(actors);
|
|
134
|
+
}
|
|
135
|
+
/** Get an actor by name. Throws with available names on miss. */
|
|
136
|
+
actor(name) {
|
|
137
|
+
const a = this._actors.get(name);
|
|
138
|
+
if (!a) {
|
|
139
|
+
const available = [...this._actors.keys()].join(', ');
|
|
140
|
+
throw new Error(`Actor "${name}" not found. Available actors: ${available}`);
|
|
141
|
+
}
|
|
142
|
+
return a;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Run multiple actors in parallel. Returns a Map of actor name → result.
|
|
146
|
+
*
|
|
147
|
+
* If any actor fails (throws), all results collected so far are still
|
|
148
|
+
* available via each actor's `.results` array.
|
|
149
|
+
*/
|
|
150
|
+
async parallel(...tasks) {
|
|
151
|
+
const entries = await Promise.all(tasks.map(async ([name, scenario]) => {
|
|
152
|
+
const result = await this.actor(name).run(scenario);
|
|
153
|
+
return [name, result];
|
|
154
|
+
}));
|
|
155
|
+
return new Map(entries);
|
|
156
|
+
}
|
|
157
|
+
/** Close all browser contexts. Pages close with their contexts. */
|
|
158
|
+
async close() {
|
|
159
|
+
if (this._closed)
|
|
160
|
+
return;
|
|
161
|
+
this._closed = true;
|
|
162
|
+
const errors = [];
|
|
163
|
+
for (const actor of this._actors.values()) {
|
|
164
|
+
try {
|
|
165
|
+
await actor.context.close();
|
|
166
|
+
}
|
|
167
|
+
catch (err) {
|
|
168
|
+
errors.push(err instanceof Error ? err : new Error(String(err)));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (errors.length > 0) {
|
|
172
|
+
throw new AggregateError(errors, 'Failed to close some actor contexts');
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/** All results across all actors, keyed by actor name */
|
|
176
|
+
get results() {
|
|
177
|
+
const map = new Map();
|
|
178
|
+
for (const [name, actor] of this._actors) {
|
|
179
|
+
map.set(name, actor.results);
|
|
180
|
+
}
|
|
181
|
+
return map;
|
|
182
|
+
}
|
|
183
|
+
/** All actors for iteration */
|
|
184
|
+
get allActors() {
|
|
185
|
+
return [...this._actors.values()];
|
|
186
|
+
}
|
|
187
|
+
/** Actor names */
|
|
188
|
+
get actorNames() {
|
|
189
|
+
return [...this._actors.keys()];
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=multi-actor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multi-actor.js","sourceRoot":"","sources":["../src/multi-actor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AA+B1C,cAAc;AAEd,MAAM,OAAO,KAAK;IAIL;IACD;IACA;IACA;IACA;IAPF,QAAQ,GAAkB,EAAE,CAAC;IAErC,YACW,IAAY,EACb,QAAwB,EACxB,KAAW,EACX,OAAyB,EACzB,OAAoB;QAJnB,SAAI,GAAJ,IAAI,CAAQ;QACb,aAAQ,GAAR,QAAQ,CAAgB;QACxB,UAAK,GAAL,KAAK,CAAM;QACX,YAAO,GAAP,OAAO,CAAkB;QACzB,YAAO,GAAP,OAAO,CAAa;IAC3B,CAAC;IAEJ,+EAA+E;IAC/E,KAAK,CAAC,GAAG,CAAC,QAAkB;QAC1B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CA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BACH,MAAM,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YAC9B,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,CAAC,IAAI,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACnE,CAAC;QACH,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,cAAc,CAAC,MAAM,EAAE,qCAAqC,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC;IAED,yDAAyD;IACzD,IAAI,OAAO;QACT,MAAM,GAAG,GAAG,IAAI,GAAG,EAAkC,CAAC;QACtD,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACzC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAED,+BAA+B;IAC/B,IAAI,SAAS;QACX,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACpC,CAAC;IAED,kBAAkB;IAClB,IAAI,UAAU;QACZ,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IAClC,CAAC;CACF"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Override Pipeline — scored selection of post-decision action overrides.
|
|
3
|
+
*
|
|
4
|
+
* Replaces the 11 sequential if-checks in the runner loop with a single
|
|
5
|
+
* scored pipeline that collects all candidates and picks the highest-scoring one.
|
|
6
|
+
*
|
|
7
|
+
* Each OverrideProducer examines the current context and optionally returns
|
|
8
|
+
* an OverrideCandidate. The pipeline selects the candidate with the highest score.
|
|
9
|
+
*/
|
|
10
|
+
import type { Action, PageState } from './types.js';
|
|
11
|
+
export interface OverrideCandidate {
|
|
12
|
+
name: string;
|
|
13
|
+
action: Action;
|
|
14
|
+
expectedEffect: string;
|
|
15
|
+
feedback: string;
|
|
16
|
+
score: number;
|
|
17
|
+
/** Override prefix tag for the reasoning annotation (e.g. 'POLICY OVERRIDE', 'SCOUT OVERRIDE') */
|
|
18
|
+
reasoningTag: string;
|
|
19
|
+
}
|
|
20
|
+
export interface OverrideContext {
|
|
21
|
+
state: PageState;
|
|
22
|
+
goal: string;
|
|
23
|
+
allowedDomains?: string[];
|
|
24
|
+
action: Action;
|
|
25
|
+
visibleLinkMatch?: {
|
|
26
|
+
ref: string;
|
|
27
|
+
text: string;
|
|
28
|
+
score: number;
|
|
29
|
+
};
|
|
30
|
+
scoutLinkRecommendation?: {
|
|
31
|
+
ref: string;
|
|
32
|
+
text: string;
|
|
33
|
+
confidence: number;
|
|
34
|
+
reasoning: string;
|
|
35
|
+
};
|
|
36
|
+
branchLinkRecommendation?: {
|
|
37
|
+
ref: string;
|
|
38
|
+
text: string;
|
|
39
|
+
confidence: number;
|
|
40
|
+
reasoning: string;
|
|
41
|
+
};
|
|
42
|
+
aiTanglePartnerCompletion?: {
|
|
43
|
+
result: string;
|
|
44
|
+
feedback: string;
|
|
45
|
+
};
|
|
46
|
+
aiTangleOutputCompletion?: {
|
|
47
|
+
result: string;
|
|
48
|
+
feedback: string;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** Each override function returns a candidate or undefined */
|
|
52
|
+
export type OverrideProducer = (ctx: OverrideContext) => OverrideCandidate | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Collect all candidates from the registered producers and pick the highest-scoring one.
|
|
55
|
+
*/
|
|
56
|
+
export declare function runOverridePipeline(ctx: OverrideContext, producers: OverrideProducer[]): OverrideCandidate | undefined;
|
|
57
|
+
//# sourceMappingURL=override-pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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,GAAG,CAAC,GAAG,EAAE,eAAe,KAAK,iBAAiB,GAAG,SAAS,CAAC;AAEvF;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,eAAe,EACpB,SAAS,EAAE,gBAAgB,EAAE,GAC5B,iBAAiB,GAAG,SAAS,CAa/B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Override Pipeline — scored selection of post-decision action overrides.
|
|
3
|
+
*
|
|
4
|
+
* Replaces the 11 sequential if-checks in the runner loop with a single
|
|
5
|
+
* scored pipeline that collects all candidates and picks the highest-scoring one.
|
|
6
|
+
*
|
|
7
|
+
* Each OverrideProducer examines the current context and optionally returns
|
|
8
|
+
* an OverrideCandidate. The pipeline selects the candidate with the highest score.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Collect all candidates from the registered producers and pick the highest-scoring one.
|
|
12
|
+
*/
|
|
13
|
+
export function runOverridePipeline(ctx, producers) {
|
|
14
|
+
const candidates = [];
|
|
15
|
+
for (const producer of producers) {
|
|
16
|
+
const candidate = producer(ctx);
|
|
17
|
+
if (candidate)
|
|
18
|
+
candidates.push(candidate);
|
|
19
|
+
}
|
|
20
|
+
if (candidates.length === 0)
|
|
21
|
+
return undefined;
|
|
22
|
+
// Sort by score descending, return highest
|
|
23
|
+
candidates.sort((a, b) => b.score - a.score);
|
|
24
|
+
return candidates[0];
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=override-pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"override-pipeline.js","sourceRoot":"","sources":["../src/override-pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA6BH;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,GAAoB,EACpB,SAA6B;IAE7B,MAAM,UAAU,GAAwB,EAAE,CAAC;IAE3C,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,SAAS;YAAE,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAE9C,2CAA2C;IAC3C,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;IAC7C,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persona directive templates for richer, product-realistic user-flow goals.
|
|
3
|
+
* These directives are appended to the task goal before LLM planning.
|
|
4
|
+
*/
|
|
5
|
+
export declare const PERSONA_IDS: readonly ["alice-blueprint-builder", "auto"];
|
|
6
|
+
export type PersonaId = (typeof PERSONA_IDS)[number];
|
|
7
|
+
export interface PersonaDirectiveInput {
|
|
8
|
+
persona: PersonaId;
|
|
9
|
+
goal: string;
|
|
10
|
+
startUrl?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function getPersonaDirective(persona: PersonaId, context?: {
|
|
13
|
+
goal: string;
|
|
14
|
+
startUrl?: string;
|
|
15
|
+
}): string;
|
|
16
|
+
export declare function withPersonaDirective(input: PersonaDirectiveInput): string;
|
|
17
|
+
export declare function isPersonaId(value: string): value is PersonaId;
|
|
18
|
+
export declare function listPersonaIds(): readonly PersonaId[];
|
|
19
|
+
//# sourceMappingURL=personas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"personas.d.ts","sourceRoot":"","sources":["../src/personas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,WAAW,8CAA+C,CAAC;AAExE,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAGrD,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,SAAS,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAqED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAK7G;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,qBAAqB,GAAG,MAAM,CAGzE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,SAAS,CAE7D;AAED,wBAAgB,cAAc,IAAI,SAAS,SAAS,EAAE,CAErD"}
|
package/dist/personas.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persona directive templates for richer, product-realistic user-flow goals.
|
|
3
|
+
* These directives are appended to the task goal before LLM planning.
|
|
4
|
+
*/
|
|
5
|
+
export const PERSONA_IDS = ['alice-blueprint-builder', 'auto'];
|
|
6
|
+
const BUILTIN_PERSONA_DIRECTIVES = {
|
|
7
|
+
'alice-blueprint-builder': [
|
|
8
|
+
'Persona: Alice (technical product engineer) using the Tangle Blueprint Agent app to deliver real work.',
|
|
9
|
+
'Alice objective: create a meaningful project (not a toy prompt), with a Coinbase-oriented implementation path, then verify usable output.',
|
|
10
|
+
'Behavior policy: think proactively, adapt to blockers, and navigate like an experienced user.',
|
|
11
|
+
'Navigation heuristics:',
|
|
12
|
+
'- Find key product routes and controls (dashboard, new project, settings, model/provider configuration, run/preview).',
|
|
13
|
+
'- When needed, discover partner templates/routes, especially /partner/coinbase, /partner/succinct, /partner/tangle.',
|
|
14
|
+
'- If routes are not directly visible, inspect home cards, nav/sidebar links, profile menu, and settings pages.',
|
|
15
|
+
'Adaptive obstacle handling:',
|
|
16
|
+
'- If a project limit/quota blocks progress, open management, clean up stale projects, and continue.',
|
|
17
|
+
'- If auth, modal, or permission blockers appear, resolve them before resuming the primary goal.',
|
|
18
|
+
'Completion criteria:',
|
|
19
|
+
'- A substantive technical prompt is submitted to the target project flow.',
|
|
20
|
+
'- The project/run reaches a usable state (preview/build/chat response visible).',
|
|
21
|
+
'- Final state is verified with concrete evidence from the UI (URL, visible output, and key status).',
|
|
22
|
+
].join('\n'),
|
|
23
|
+
};
|
|
24
|
+
function buildAutoDirective(goal, startUrl) {
|
|
25
|
+
const context = `${goal} ${startUrl ?? ''}`.toLowerCase();
|
|
26
|
+
const isTangleContext = context.includes('ai.tangle.tools') || context.includes('blueprint') || context.includes('/partner/');
|
|
27
|
+
const partnerRoutes = [];
|
|
28
|
+
if (context.includes('coinbase'))
|
|
29
|
+
partnerRoutes.push('/partner/coinbase');
|
|
30
|
+
if (context.includes('succinct'))
|
|
31
|
+
partnerRoutes.push('/partner/succinct');
|
|
32
|
+
if (context.includes('tangle'))
|
|
33
|
+
partnerRoutes.push('/partner/tangle');
|
|
34
|
+
if (partnerRoutes.length === 0 && startUrl?.includes('ai.tangle.tools')) {
|
|
35
|
+
partnerRoutes.push('/partner/coinbase', '/partner/succinct', '/partner/tangle');
|
|
36
|
+
}
|
|
37
|
+
if (isTangleContext) {
|
|
38
|
+
const routeHint = partnerRoutes.length > 0
|
|
39
|
+
? `- Check partner/template routes likely relevant to this task: ${partnerRoutes.join(', ')}.`
|
|
40
|
+
: '- Discover available templates/routes via home cards, sidebar, and profile/settings menus.';
|
|
41
|
+
return [
|
|
42
|
+
'Persona: Adaptive product operator (senior technical IC + product mindset) focused on completing realistic end-to-end outcomes.',
|
|
43
|
+
`Primary objective: ${goal}`,
|
|
44
|
+
'Behavior policy: think proactively, adapt to blockers, and prefer high-signal actions over repetitive retries.',
|
|
45
|
+
'Navigation heuristics:',
|
|
46
|
+
'- Map the app quickly: dashboard/list views, create flow, settings, model/provider configuration, run/preview views.',
|
|
47
|
+
routeHint,
|
|
48
|
+
'Adaptive obstacle handling:',
|
|
49
|
+
'- If limits, auth prompts, or modals block progress, resolve the blocker first and then resume the main goal.',
|
|
50
|
+
'- If a route/control fails, try an adjacent route path or alternate entry point before repeating the same action.',
|
|
51
|
+
'Completion criteria:',
|
|
52
|
+
'- A substantive, user-valuable flow is completed (not toy chatter).',
|
|
53
|
+
'- The outcome is verified with concrete UI evidence (URL, visible state, run/preview artifact).',
|
|
54
|
+
].join('\n');
|
|
55
|
+
}
|
|
56
|
+
return [
|
|
57
|
+
'Persona: Adaptive web operator focused on completing tasks reliably on arbitrary websites.',
|
|
58
|
+
`Primary objective: ${goal}`,
|
|
59
|
+
'Behavior policy: prefer direct progress and concise actions over broad exploration.',
|
|
60
|
+
'Navigation heuristics:',
|
|
61
|
+
'- Use the site’s own navigation and search first; follow high-signal links that match the requested outcome.',
|
|
62
|
+
'- Avoid app-specific assumptions about routes or settings unless explicitly visible in the current site.',
|
|
63
|
+
'Adaptive obstacle handling:',
|
|
64
|
+
'- If blocked by auth/paywall/captcha or unavailable content, capture concrete evidence and try one adjacent strategy.',
|
|
65
|
+
'- Do not loop on the same failing interaction; switch approach quickly.',
|
|
66
|
+
'Completion criteria:',
|
|
67
|
+
'- Return the requested data/result with concrete evidence (URL + visible text/state).',
|
|
68
|
+
].join('\n');
|
|
69
|
+
}
|
|
70
|
+
export function getPersonaDirective(persona, context) {
|
|
71
|
+
if (persona === 'auto') {
|
|
72
|
+
return buildAutoDirective(context?.goal ?? 'Complete the requested user flow', context?.startUrl);
|
|
73
|
+
}
|
|
74
|
+
return BUILTIN_PERSONA_DIRECTIVES[persona];
|
|
75
|
+
}
|
|
76
|
+
export function withPersonaDirective(input) {
|
|
77
|
+
const directive = getPersonaDirective(input.persona, { goal: input.goal, startUrl: input.startUrl });
|
|
78
|
+
return `${input.goal}\n\n${directive}`;
|
|
79
|
+
}
|
|
80
|
+
export function isPersonaId(value) {
|
|
81
|
+
return PERSONA_IDS.includes(value);
|
|
82
|
+
}
|
|
83
|
+
export function listPersonaIds() {
|
|
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QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;IACrG,OAAO,GAAG,KAAK,CAAC,IAAI,OAAO,SAAS,EAAE,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,OAAO,WAAW,CAAC,QAAQ,CAAC,KAAkB,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Preview App Verification — navigate outside the sandbox iframe
|
|
3
|
+
* to verify the generated app actually works.
|
|
4
|
+
*
|
|
5
|
+
* The preview is rendered in an iframe (title="Preview") that has
|
|
6
|
+
* sandbox restrictions. This utility extracts the preview URL,
|
|
7
|
+
* navigates Playwright directly to it, captures the a11y tree + screenshot,
|
|
8
|
+
* and checks for errors.
|
|
9
|
+
*/
|
|
10
|
+
import type { Page } from 'playwright';
|
|
11
|
+
import { AriaSnapshotHelper } from './drivers/snapshot.js';
|
|
12
|
+
import type { PreviewVerification } from './types.js';
|
|
13
|
+
/**
|
|
14
|
+
* Verify the preview app by navigating directly to the preview URL.
|
|
15
|
+
*
|
|
16
|
+
* Steps:
|
|
17
|
+
* 1. Extract preview URL from the iframe
|
|
18
|
+
* 2. Navigate Playwright to the preview URL (bypasses sandbox)
|
|
19
|
+
* 3. Capture a11y tree + screenshot + errors
|
|
20
|
+
* 4. Navigate back to the original page
|
|
21
|
+
*
|
|
22
|
+
* Returns null if no preview iframe is found.
|
|
23
|
+
*/
|
|
24
|
+
export declare function verifyPreview(page: Page, snapshot: AriaSnapshotHelper, options?: {
|
|
25
|
+
captureScreenshot?: boolean;
|
|
26
|
+
screenshotQuality?: number;
|
|
27
|
+
/** Explicit preview URL — skips iframe extraction */
|
|
28
|
+
previewUrl?: string;
|
|
29
|
+
/** Custom iframe selector (default: 'iframe[title="Preview"]') */
|
|
30
|
+
iframeSelector?: string;
|
|
31
|
+
}): Promise<PreviewVerification | null>;
|
|
32
|
+
//# sourceMappingURL=preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../src/preview.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AA8BtD;;;;;;;;;;GAUG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,CAAC,EAAE;IACR,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kEAAkE;IAClE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GACA,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAuGrC"}
|
package/dist/preview.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Preview App Verification — navigate outside the sandbox iframe
|
|
3
|
+
* to verify the generated app actually works.
|
|
4
|
+
*
|
|
5
|
+
* The preview is rendered in an iframe (title="Preview") that has
|
|
6
|
+
* sandbox restrictions. This utility extracts the preview URL,
|
|
7
|
+
* navigates Playwright directly to it, captures the a11y tree + screenshot,
|
|
8
|
+
* and checks for errors.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Extract the preview iframe URL from the current page.
|
|
12
|
+
* Returns null if no preview iframe is found.
|
|
13
|
+
*/
|
|
14
|
+
async function extractPreviewUrl(page, customSelector) {
|
|
15
|
+
const sel = customSelector;
|
|
16
|
+
return page.evaluate(([selector]) => {
|
|
17
|
+
// Try custom selector first, then default pattern
|
|
18
|
+
if (selector) {
|
|
19
|
+
const el = document.querySelector(selector);
|
|
20
|
+
if (el?.src)
|
|
21
|
+
return el.src;
|
|
22
|
+
}
|
|
23
|
+
// Look for iframe with title="Preview" (bolt/blueprint pattern)
|
|
24
|
+
const iframe = document.querySelector('iframe[title="Preview"]');
|
|
25
|
+
if (iframe?.src)
|
|
26
|
+
return iframe.src;
|
|
27
|
+
// Fallback: any iframe with a src URL (works for any embedded app)
|
|
28
|
+
const iframes = document.querySelectorAll('iframe[src]');
|
|
29
|
+
for (const f of iframes) {
|
|
30
|
+
const src = f.src;
|
|
31
|
+
if (src && !src.startsWith('about:') && !src.startsWith('javascript:'))
|
|
32
|
+
return src;
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}, [sel]);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Verify the preview app by navigating directly to the preview URL.
|
|
39
|
+
*
|
|
40
|
+
* Steps:
|
|
41
|
+
* 1. Extract preview URL from the iframe
|
|
42
|
+
* 2. Navigate Playwright to the preview URL (bypasses sandbox)
|
|
43
|
+
* 3. Capture a11y tree + screenshot + errors
|
|
44
|
+
* 4. Navigate back to the original page
|
|
45
|
+
*
|
|
46
|
+
* Returns null if no preview iframe is found.
|
|
47
|
+
*/
|
|
48
|
+
export async function verifyPreview(page, snapshot, options) {
|
|
49
|
+
const previewUrl = options?.previewUrl ?? await extractPreviewUrl(page, options?.iframeSelector);
|
|
50
|
+
if (!previewUrl)
|
|
51
|
+
return null;
|
|
52
|
+
const originalUrl = page.url();
|
|
53
|
+
try {
|
|
54
|
+
// Navigate directly to the preview app
|
|
55
|
+
await page.goto(previewUrl, { timeout: 15_000, waitUntil: 'domcontentloaded' });
|
|
56
|
+
// Wait for page to fully load, then brief settle delay
|
|
57
|
+
await page.waitForFunction(() => document.readyState === 'complete', { timeout: 10_000 }).catch(() => { });
|
|
58
|
+
await page.waitForTimeout(500);
|
|
59
|
+
const title = await page.title();
|
|
60
|
+
// Capture a11y tree
|
|
61
|
+
snapshot.reset();
|
|
62
|
+
const snapshotText = await snapshot.buildSnapshot(page);
|
|
63
|
+
// Check for visible errors
|
|
64
|
+
const errors = await page.evaluate(() => {
|
|
65
|
+
const found = [];
|
|
66
|
+
/** Check if element is rendered (handles position:fixed where offsetParent is null) */
|
|
67
|
+
function isVisible(el) {
|
|
68
|
+
const rect = el.getBoundingClientRect();
|
|
69
|
+
return rect.width > 0 && rect.height > 0;
|
|
70
|
+
}
|
|
71
|
+
// Check for standard error indicators
|
|
72
|
+
const errorSelectors = ['[role="alert"]', 'pre.error'];
|
|
73
|
+
for (const sel of errorSelectors) {
|
|
74
|
+
const el = document.querySelector(sel);
|
|
75
|
+
if (el && el instanceof HTMLElement && isVisible(el)) {
|
|
76
|
+
const text = (el.textContent || '').trim().slice(0, 200);
|
|
77
|
+
if (text)
|
|
78
|
+
found.push(text);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// Vite error overlay uses a custom element with Shadow DOM —
|
|
82
|
+
// textContent is empty, so just detect its presence
|
|
83
|
+
const viteOverlay = document.querySelector('vite-error-overlay');
|
|
84
|
+
if (viteOverlay) {
|
|
85
|
+
// Try to read from shadow root if open
|
|
86
|
+
const shadowText = viteOverlay.shadowRoot?.querySelector('.message')?.textContent?.trim();
|
|
87
|
+
found.push(shadowText?.slice(0, 200) || 'Vite error overlay detected');
|
|
88
|
+
}
|
|
89
|
+
// Check for blank page — exclude script-only pages (SPA shells before hydration)
|
|
90
|
+
const body = document.body;
|
|
91
|
+
if (body) {
|
|
92
|
+
const hasVisibleChildren = Array.from(body.children).some((child) => child.tagName !== 'SCRIPT' && child.tagName !== 'LINK' &&
|
|
93
|
+
child instanceof HTMLElement && isVisible(child));
|
|
94
|
+
if (!hasVisibleChildren && body.innerText.trim().length === 0) {
|
|
95
|
+
found.push('Page appears blank — no visible content rendered');
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return found;
|
|
99
|
+
});
|
|
100
|
+
// Capture screenshot if requested
|
|
101
|
+
let screenshot;
|
|
102
|
+
if (options?.captureScreenshot !== false) {
|
|
103
|
+
const quality = options?.screenshotQuality ?? 50;
|
|
104
|
+
const buf = await page.screenshot({ type: 'jpeg', quality });
|
|
105
|
+
screenshot = buf.toString('base64');
|
|
106
|
+
}
|
|
107
|
+
const appLoaded = errors.length === 0 && snapshotText !== '(empty page)';
|
|
108
|
+
const result = {
|
|
109
|
+
previewUrl,
|
|
110
|
+
appLoaded,
|
|
111
|
+
title,
|
|
112
|
+
snapshot: snapshotText,
|
|
113
|
+
screenshot,
|
|
114
|
+
errors,
|
|
115
|
+
};
|
|
116
|
+
// Navigate back to the original page
|
|
117
|
+
try {
|
|
118
|
+
await page.goto(originalUrl, { timeout: 15_000, waitUntil: 'domcontentloaded' });
|
|
119
|
+
await page.waitForTimeout(1000);
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
// If nav-back fails, report it as an error so the agent knows
|
|
123
|
+
result.errors.push(`Failed to navigate back to ${originalUrl} — page may be on the preview URL`);
|
|
124
|
+
}
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
// If preview navigation itself fails, return a failed result
|
|
129
|
+
return {
|
|
130
|
+
previewUrl,
|
|
131
|
+
appLoaded: false,
|
|
132
|
+
title: '',
|
|
133
|
+
snapshot: '(preview navigation failed)',
|
|
134
|
+
errors: [err instanceof Error ? err.message : String(err)],
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview.js","sourceRoot":"","sources":["../src/preview.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH;;;GAGG;AACH,KAAK,UAAU,iBAAiB,CAAC,IAAU,EAAE,cAAuB;IAClE,MAAM,GAAG,GAAG,cAAc,CAAC;IAC3B,OAAO,IAAI,CAAC,QAAQ,CAAC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AAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;YAC7D,UAAU,GAAG,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACtC,CAAC;QAED,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,YAAY,KAAK,cAAc,CAAC;QAEzE,MAAM,MAAM,GAAwB;YAClC,UAAU;YACV,SAAS;YACT,KAAK;YACL,QAAQ,EAAE,YAAY;YACtB,UAAU;YACV,MAAM;SACP,CAAC;QAEF,qCAAqC;QACrC,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC,CAAC;YACjF,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAClC,CAAC;QAAC,MAAM,CAAC;YACP,8DAA8D;YAC9D,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,WAAW,mCAAmC,CAAC,CAAC;QACnG,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,6DAA6D;QAC7D,OAAO;YACL,UAAU;YACV,SAAS,EAAE,KAAK;YAChB,KAAK,EAAE,EAAE;YACT,QAAQ,EAAE,6BAA6B;YACvC,MAAM,EAAE,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;SAC3D,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type SupportedProvider = 'openai' | 'anthropic' | 'google' | 'codex-cli' | 'claude-code' | 'sandbox-backend';
|
|
2
|
+
export declare function resolveProviderModelName(provider: SupportedProvider, requestedModel?: string, options?: {
|
|
3
|
+
sandboxBackendType?: string;
|
|
4
|
+
}): string;
|
|
5
|
+
export declare function resolveProviderApiKey(provider: SupportedProvider, explicitApiKey?: string, env?: NodeJS.ProcessEnv): string | undefined;
|
|
6
|
+
//# sourceMappingURL=provider-defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-defaults.d.ts","sourceRoot":"","sources":["../src/provider-defaults.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GACzB,QAAQ,GACR,WAAW,GACX,QAAQ,GACR,WAAW,GACX,aAAa,GACb,iBAAiB,CAAC;AAEtB,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,iBAAiB,EAC3B,cAAc,CAAC,EAAE,MAAM,EACvB,OAAO,CAAC,EAAE;IACR,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,GACA,MAAM,CAwBR;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,iBAAiB,EAC3B,cAAc,CAAC,EAAE,MAAM,EACvB,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,GAAG,SAAS,CAgBpB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export function resolveProviderModelName(provider, requestedModel, options) {
|
|
2
|
+
const model = requestedModel?.trim();
|
|
3
|
+
if (provider === 'claude-code') {
|
|
4
|
+
if (!model || /^gpt-5(?:[.-]|$)/i.test(model)) {
|
|
5
|
+
return 'sonnet';
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
if (provider === 'sandbox-backend') {
|
|
9
|
+
const backendType = (options?.sandboxBackendType || process.env.SANDBOX_BACKEND_TYPE || '').trim().toLowerCase();
|
|
10
|
+
if (backendType === 'claude-code') {
|
|
11
|
+
if (!model || /^gpt-5(?:[.-]|$)/i.test(model)) {
|
|
12
|
+
return 'sonnet';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (backendType === 'codex') {
|
|
16
|
+
if (!model) {
|
|
17
|
+
return 'gpt-5';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return model || 'gpt-5.4';
|
|
22
|
+
}
|
|
23
|
+
export function resolveProviderApiKey(provider, explicitApiKey, env = process.env) {
|
|
24
|
+
if (explicitApiKey)
|
|
25
|
+
return explicitApiKey;
|
|
26
|
+
switch (provider) {
|
|
27
|
+
case 'anthropic':
|
|
28
|
+
case 'claude-code':
|
|
29
|
+
return env.ANTHROPIC_API_KEY;
|
|
30
|
+
case 'sandbox-backend':
|
|
31
|
+
return undefined;
|
|
32
|
+
case 'google':
|
|
33
|
+
return env.GOOGLE_GENERATIVE_AI_API_KEY || env.GEMINI_API_KEY;
|
|
34
|
+
case 'codex-cli':
|
|
35
|
+
case 'openai':
|
|
36
|
+
default:
|
|
37
|
+
return env.OPENAI_API_KEY;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=provider-defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-defaults.js","sourceRoot":"","sources":["../src/provider-defaults.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,wBAAwB,CACtC,QAA2B,EAC3B,cAAuB,EACvB,OAEC;IAED,MAAM,KAAK,GAAG,cAAc,EAAE,IAAI,EAAE,CAAC;IAErC,IAAI,QAAQ,KAAK,aAAa,EAAE,CAAC;QAC/B,IAAI,CAAC,KAAK,IAAI,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9C,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IAED,IAAI,QAAQ,KAAK,iBAAiB,EAAE,CAAC;QACnC,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,kBAAkB,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QACjH,IAAI,WAAW,KAAK,aAAa,EAAE,CAAC;YAClC,IAAI,CAAC,KAAK,IAAI,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAA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