@e2edev/e2e 0.2.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 +21 -0
- package/README.md +104 -0
- package/dist/agent/act-validation.d.ts +27 -0
- package/dist/agent/act-validation.d.ts.map +1 -0
- package/dist/agent/act-validation.js +121 -0
- package/dist/agent/act-validation.js.map +1 -0
- package/dist/agent/act.d.ts +27 -0
- package/dist/agent/act.d.ts.map +1 -0
- package/dist/agent/act.js +775 -0
- package/dist/agent/act.js.map +1 -0
- package/dist/agent/actions.d.ts +66 -0
- package/dist/agent/actions.d.ts.map +1 -0
- package/dist/agent/actions.js +82 -0
- package/dist/agent/actions.js.map +1 -0
- package/dist/agent/ai-sdk.d.ts +16 -0
- package/dist/agent/ai-sdk.d.ts.map +1 -0
- package/dist/agent/ai-sdk.js +59 -0
- package/dist/agent/ai-sdk.js.map +1 -0
- package/dist/agent/call-options.d.ts +10 -0
- package/dist/agent/call-options.d.ts.map +1 -0
- package/dist/agent/call-options.js +28 -0
- package/dist/agent/call-options.js.map +1 -0
- package/dist/agent/default-agent.d.ts +22 -0
- package/dist/agent/default-agent.d.ts.map +1 -0
- package/dist/agent/default-agent.js +354 -0
- package/dist/agent/default-agent.js.map +1 -0
- package/dist/agent/error.d.ts +53 -0
- package/dist/agent/error.d.ts.map +1 -0
- package/dist/agent/error.js +94 -0
- package/dist/agent/error.js.map +1 -0
- package/dist/agent/executor.d.ts +238 -0
- package/dist/agent/executor.d.ts.map +1 -0
- package/dist/agent/executor.js +56 -0
- package/dist/agent/executor.js.map +1 -0
- package/dist/agent/index.d.ts +15 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +304 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/invocation.d.ts +194 -0
- package/dist/agent/invocation.d.ts.map +1 -0
- package/dist/agent/invocation.js +389 -0
- package/dist/agent/invocation.js.map +1 -0
- package/dist/agent/ledger.d.ts +24 -0
- package/dist/agent/ledger.d.ts.map +1 -0
- package/dist/agent/ledger.js +48 -0
- package/dist/agent/ledger.js.map +1 -0
- package/dist/agent/loop-guards.d.ts +35 -0
- package/dist/agent/loop-guards.d.ts.map +1 -0
- package/dist/agent/loop-guards.js +110 -0
- package/dist/agent/loop-guards.js.map +1 -0
- package/dist/agent/model/adapter.d.ts +97 -0
- package/dist/agent/model/adapter.d.ts.map +1 -0
- package/dist/agent/model/adapter.js +40 -0
- package/dist/agent/model/adapter.js.map +1 -0
- package/dist/agent/model/router.d.ts +36 -0
- package/dist/agent/model/router.d.ts.map +1 -0
- package/dist/agent/model/router.js +45 -0
- package/dist/agent/model/router.js.map +1 -0
- package/dist/agent/model/schema.d.ts +16 -0
- package/dist/agent/model/schema.d.ts.map +1 -0
- package/dist/agent/model/schema.js +37 -0
- package/dist/agent/model/schema.js.map +1 -0
- package/dist/agent/model/sdk.d.ts +28 -0
- package/dist/agent/model/sdk.d.ts.map +1 -0
- package/dist/agent/model/sdk.js +258 -0
- package/dist/agent/model/sdk.js.map +1 -0
- package/dist/agent/observation.d.ts +70 -0
- package/dist/agent/observation.d.ts.map +1 -0
- package/dist/agent/observation.js +174 -0
- package/dist/agent/observation.js.map +1 -0
- package/dist/agent/phases.d.ts +71 -0
- package/dist/agent/phases.d.ts.map +1 -0
- package/dist/agent/phases.js +124 -0
- package/dist/agent/phases.js.map +1 -0
- package/dist/agent/prompts.d.ts +40 -0
- package/dist/agent/prompts.d.ts.map +1 -0
- package/dist/agent/prompts.js +104 -0
- package/dist/agent/prompts.js.map +1 -0
- package/dist/agent/protocol.d.ts +31 -0
- package/dist/agent/protocol.d.ts.map +1 -0
- package/dist/agent/protocol.js +67 -0
- package/dist/agent/protocol.js.map +1 -0
- package/dist/agent/public.d.ts +12 -0
- package/dist/agent/public.d.ts.map +1 -0
- package/dist/agent/public.js +12 -0
- package/dist/agent/public.js.map +1 -0
- package/dist/agent/replay.d.ts +61 -0
- package/dist/agent/replay.d.ts.map +1 -0
- package/dist/agent/replay.js +185 -0
- package/dist/agent/replay.js.map +1 -0
- package/dist/agent/secrets.d.ts +22 -0
- package/dist/agent/secrets.d.ts.map +1 -0
- package/dist/agent/secrets.js +63 -0
- package/dist/agent/secrets.js.map +1 -0
- package/dist/agent/step-cache.d.ts +156 -0
- package/dist/agent/step-cache.d.ts.map +1 -0
- package/dist/agent/step-cache.js +301 -0
- package/dist/agent/step-cache.js.map +1 -0
- package/dist/agent/tool-loop.d.ts +51 -0
- package/dist/agent/tool-loop.d.ts.map +1 -0
- package/dist/agent/tool-loop.js +331 -0
- package/dist/agent/tool-loop.js.map +1 -0
- package/dist/agent/tool.d.ts +39 -0
- package/dist/agent/tool.d.ts.map +1 -0
- package/dist/agent/tool.js +52 -0
- package/dist/agent/tool.js.map +1 -0
- package/dist/backend/contract.d.ts +186 -0
- package/dist/backend/contract.d.ts.map +1 -0
- package/dist/backend/contract.js +65 -0
- package/dist/backend/contract.js.map +1 -0
- package/dist/backend/index.d.ts +316 -0
- package/dist/backend/index.d.ts.map +1 -0
- package/dist/backend/index.js +219 -0
- package/dist/backend/index.js.map +1 -0
- package/dist/backend/session.d.ts +23 -0
- package/dist/backend/session.d.ts.map +1 -0
- package/dist/backend/session.js +213 -0
- package/dist/backend/session.js.map +1 -0
- package/dist/backend/surface.d.ts +83 -0
- package/dist/backend/surface.d.ts.map +1 -0
- package/dist/backend/surface.js +11 -0
- package/dist/backend/surface.js.map +1 -0
- package/dist/cache/anchors.d.ts +37 -0
- package/dist/cache/anchors.d.ts.map +1 -0
- package/dist/cache/anchors.js +89 -0
- package/dist/cache/anchors.js.map +1 -0
- package/dist/cache/context.d.ts +74 -0
- package/dist/cache/context.d.ts.map +1 -0
- package/dist/cache/context.js +82 -0
- package/dist/cache/context.js.map +1 -0
- package/dist/cache/decide.d.ts +42 -0
- package/dist/cache/decide.d.ts.map +1 -0
- package/dist/cache/decide.js +47 -0
- package/dist/cache/decide.js.map +1 -0
- package/dist/cache/identity.d.ts +113 -0
- package/dist/cache/identity.d.ts.map +1 -0
- package/dist/cache/identity.js +109 -0
- package/dist/cache/identity.js.map +1 -0
- package/dist/cache/recorder.d.ts +76 -0
- package/dist/cache/recorder.d.ts.map +1 -0
- package/dist/cache/recorder.js +143 -0
- package/dist/cache/recorder.js.map +1 -0
- package/dist/cache/relocate.d.ts +69 -0
- package/dist/cache/relocate.d.ts.map +1 -0
- package/dist/cache/relocate.js +125 -0
- package/dist/cache/relocate.js.map +1 -0
- package/dist/cache/store.d.ts +68 -0
- package/dist/cache/store.d.ts.map +1 -0
- package/dist/cache/store.js +106 -0
- package/dist/cache/store.js.map +1 -0
- package/dist/cache/trace.d.ts +146 -0
- package/dist/cache/trace.d.ts.map +1 -0
- package/dist/cache/trace.js +249 -0
- package/dist/cache/trace.js.map +1 -0
- package/dist/cli/bin.d.ts +3 -0
- package/dist/cli/bin.d.ts.map +1 -0
- package/dist/cli/bin.js +4 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/index.d.ts +4 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +108 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/init.d.ts +6 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +101 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/collect/collect.d.ts +44 -0
- package/dist/collect/collect.d.ts.map +1 -0
- package/dist/collect/collect.js +89 -0
- package/dist/collect/collect.js.map +1 -0
- package/dist/collect/registry.d.ts +47 -0
- package/dist/collect/registry.d.ts.map +1 -0
- package/dist/collect/registry.js +262 -0
- package/dist/collect/registry.js.map +1 -0
- package/dist/collect/select.d.ts +54 -0
- package/dist/collect/select.d.ts.map +1 -0
- package/dist/collect/select.js +230 -0
- package/dist/collect/select.js.map +1 -0
- package/dist/config/agent.d.ts +91 -0
- package/dist/config/agent.d.ts.map +1 -0
- package/dist/config/agent.js +232 -0
- package/dist/config/agent.js.map +1 -0
- package/dist/config/load.d.ts +23 -0
- package/dist/config/load.d.ts.map +1 -0
- package/dist/config/load.js +75 -0
- package/dist/config/load.js.map +1 -0
- package/dist/config/resolve.d.ts +94 -0
- package/dist/config/resolve.d.ts.map +1 -0
- package/dist/config/resolve.js +500 -0
- package/dist/config/resolve.js.map +1 -0
- package/dist/config/validate.d.ts +6 -0
- package/dist/config/validate.d.ts.map +1 -0
- package/dist/config/validate.js +21 -0
- package/dist/config/validate.js.map +1 -0
- package/dist/credentials.d.ts +7 -0
- package/dist/credentials.d.ts.map +1 -0
- package/dist/credentials.js +42 -0
- package/dist/credentials.js.map +1 -0
- package/dist/expect/async.d.ts +5 -0
- package/dist/expect/async.d.ts.map +1 -0
- package/dist/expect/async.js +186 -0
- package/dist/expect/async.js.map +1 -0
- package/dist/expect/index.d.ts +7 -0
- package/dist/expect/index.d.ts.map +1 -0
- package/dist/expect/index.js +23 -0
- package/dist/expect/index.js.map +1 -0
- package/dist/expect/values.d.ts +4 -0
- package/dist/expect/values.d.ts.map +1 -0
- package/dist/expect/values.js +108 -0
- package/dist/expect/values.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/ai-trace.d.ts +151 -0
- package/dist/internal/ai-trace.d.ts.map +1 -0
- package/dist/internal/ai-trace.js +360 -0
- package/dist/internal/ai-trace.js.map +1 -0
- package/dist/internal/brands.d.ts +9 -0
- package/dist/internal/brands.d.ts.map +1 -0
- package/dist/internal/brands.js +9 -0
- package/dist/internal/brands.js.map +1 -0
- package/dist/internal/debug.d.ts +43 -0
- package/dist/internal/debug.d.ts.map +1 -0
- package/dist/internal/debug.js +102 -0
- package/dist/internal/debug.js.map +1 -0
- package/dist/internal/errors.d.ts +98 -0
- package/dist/internal/errors.d.ts.map +1 -0
- package/dist/internal/errors.js +212 -0
- package/dist/internal/errors.js.map +1 -0
- package/dist/internal/globs.d.ts +29 -0
- package/dist/internal/globs.d.ts.map +1 -0
- package/dist/internal/globs.js +126 -0
- package/dist/internal/globs.js.map +1 -0
- package/dist/internal/ids.d.ts +32 -0
- package/dist/internal/ids.d.ts.map +1 -0
- package/dist/internal/ids.js +124 -0
- package/dist/internal/ids.js.map +1 -0
- package/dist/internal/json-value.d.ts +15 -0
- package/dist/internal/json-value.d.ts.map +1 -0
- package/dist/internal/json-value.js +61 -0
- package/dist/internal/json-value.js.map +1 -0
- package/dist/internal/package-version.d.ts +6 -0
- package/dist/internal/package-version.d.ts.map +1 -0
- package/dist/internal/package-version.js +14 -0
- package/dist/internal/package-version.js.map +1 -0
- package/dist/internal/realm-slot.d.ts +13 -0
- package/dist/internal/realm-slot.d.ts.map +1 -0
- package/dist/internal/realm-slot.js +23 -0
- package/dist/internal/realm-slot.js.map +1 -0
- package/dist/internal/redact.d.ts +33 -0
- package/dist/internal/redact.d.ts.map +1 -0
- package/dist/internal/redact.js +56 -0
- package/dist/internal/redact.js.map +1 -0
- package/dist/internal/regexp.d.ts +10 -0
- package/dist/internal/regexp.d.ts.map +1 -0
- package/dist/internal/regexp.js +27 -0
- package/dist/internal/regexp.js.map +1 -0
- package/dist/internal/text.d.ts +39 -0
- package/dist/internal/text.d.ts.map +1 -0
- package/dist/internal/text.js +66 -0
- package/dist/internal/text.js.map +1 -0
- package/dist/internal/time.d.ts +37 -0
- package/dist/internal/time.d.ts.map +1 -0
- package/dist/internal/time.js +91 -0
- package/dist/internal/time.js.map +1 -0
- package/dist/internal/trace.d.ts +18 -0
- package/dist/internal/trace.d.ts.map +1 -0
- package/dist/internal/trace.js +46 -0
- package/dist/internal/trace.js.map +1 -0
- package/dist/internal/urls.d.ts +31 -0
- package/dist/internal/urls.d.ts.map +1 -0
- package/dist/internal/urls.js +95 -0
- package/dist/internal/urls.js.map +1 -0
- package/dist/locator/engine.d.ts +65 -0
- package/dist/locator/engine.d.ts.map +1 -0
- package/dist/locator/engine.js +164 -0
- package/dist/locator/engine.js.map +1 -0
- package/dist/locator/expression.d.ts +19 -0
- package/dist/locator/expression.d.ts.map +1 -0
- package/dist/locator/expression.js +85 -0
- package/dist/locator/expression.js.map +1 -0
- package/dist/locator/screen.d.ts +36 -0
- package/dist/locator/screen.d.ts.map +1 -0
- package/dist/locator/screen.js +281 -0
- package/dist/locator/screen.js.map +1 -0
- package/dist/report/build.d.ts +214 -0
- package/dist/report/build.d.ts.map +1 -0
- package/dist/report/build.js +346 -0
- package/dist/report/build.js.map +1 -0
- package/dist/report/code-frame.d.ts +20 -0
- package/dist/report/code-frame.d.ts.map +1 -0
- package/dist/report/code-frame.js +73 -0
- package/dist/report/code-frame.js.map +1 -0
- package/dist/report/debug-steps.d.ts +14 -0
- package/dist/report/debug-steps.d.ts.map +1 -0
- package/dist/report/debug-steps.js +85 -0
- package/dist/report/debug-steps.js.map +1 -0
- package/dist/report/list.d.ts +80 -0
- package/dist/report/list.d.ts.map +1 -0
- package/dist/report/list.js +372 -0
- package/dist/report/list.js.map +1 -0
- package/dist/report/live-status.d.ts +51 -0
- package/dist/report/live-status.d.ts.map +1 -0
- package/dist/report/live-status.js +162 -0
- package/dist/report/live-status.js.map +1 -0
- package/dist/report/write.d.ts +4 -0
- package/dist/report/write.d.ts.map +1 -0
- package/dist/report/write.js +13 -0
- package/dist/report/write.js.map +1 -0
- package/dist/run/app-process.d.ts +18 -0
- package/dist/run/app-process.d.ts.map +1 -0
- package/dist/run/app-process.js +112 -0
- package/dist/run/app-process.js.map +1 -0
- package/dist/run/artifacts.d.ts +51 -0
- package/dist/run/artifacts.d.ts.map +1 -0
- package/dist/run/artifacts.js +114 -0
- package/dist/run/artifacts.js.map +1 -0
- package/dist/run/events.d.ts +100 -0
- package/dist/run/events.d.ts.map +1 -0
- package/dist/run/events.js +59 -0
- package/dist/run/events.js.map +1 -0
- package/dist/run/execute.d.ts +119 -0
- package/dist/run/execute.d.ts.map +1 -0
- package/dist/run/execute.js +555 -0
- package/dist/run/execute.js.map +1 -0
- package/dist/run/fixtures.d.ts +40 -0
- package/dist/run/fixtures.d.ts.map +1 -0
- package/dist/run/fixtures.js +408 -0
- package/dist/run/fixtures.js.map +1 -0
- package/dist/run/in-process.d.ts +24 -0
- package/dist/run/in-process.d.ts.map +1 -0
- package/dist/run/in-process.js +120 -0
- package/dist/run/in-process.js.map +1 -0
- package/dist/run/public.d.ts +19 -0
- package/dist/run/public.d.ts.map +1 -0
- package/dist/run/public.js +11 -0
- package/dist/run/public.js.map +1 -0
- package/dist/run/realm.d.ts +52 -0
- package/dist/run/realm.d.ts.map +1 -0
- package/dist/run/realm.js +101 -0
- package/dist/run/realm.js.map +1 -0
- package/dist/run/records.d.ts +87 -0
- package/dist/run/records.d.ts.map +1 -0
- package/dist/run/records.js +3 -0
- package/dist/run/records.js.map +1 -0
- package/dist/run/retry.d.ts +18 -0
- package/dist/run/retry.d.ts.map +1 -0
- package/dist/run/retry.js +33 -0
- package/dist/run/retry.js.map +1 -0
- package/dist/run/runner.d.ts +49 -0
- package/dist/run/runner.d.ts.map +1 -0
- package/dist/run/runner.js +375 -0
- package/dist/run/runner.js.map +1 -0
- package/dist/run/scheduler.d.ts +45 -0
- package/dist/run/scheduler.d.ts.map +1 -0
- package/dist/run/scheduler.js +512 -0
- package/dist/run/scheduler.js.map +1 -0
- package/dist/run/serial.d.ts +52 -0
- package/dist/run/serial.d.ts.map +1 -0
- package/dist/run/serial.js +247 -0
- package/dist/run/serial.js.map +1 -0
- package/dist/run/sessions.d.ts +54 -0
- package/dist/run/sessions.d.ts.map +1 -0
- package/dist/run/sessions.js +221 -0
- package/dist/run/sessions.js.map +1 -0
- package/dist/run/steps.d.ts +196 -0
- package/dist/run/steps.d.ts.map +1 -0
- package/dist/run/steps.js +151 -0
- package/dist/run/steps.js.map +1 -0
- package/dist/run/unit-runner.d.ts +30 -0
- package/dist/run/unit-runner.d.ts.map +1 -0
- package/dist/run/unit-runner.js +11 -0
- package/dist/run/unit-runner.js.map +1 -0
- package/dist/run/units.d.ts +50 -0
- package/dist/run/units.d.ts.map +1 -0
- package/dist/run/units.js +103 -0
- package/dist/run/units.js.map +1 -0
- package/dist/run/worker/entry.d.ts +8 -0
- package/dist/run/worker/entry.d.ts.map +1 -0
- package/dist/run/worker/entry.js +137 -0
- package/dist/run/worker/entry.js.map +1 -0
- package/dist/run/worker/handle.d.ts +10 -0
- package/dist/run/worker/handle.d.ts.map +1 -0
- package/dist/run/worker/handle.js +74 -0
- package/dist/run/worker/handle.js.map +1 -0
- package/dist/run/worker/protocol.d.ts +129 -0
- package/dist/run/worker/protocol.d.ts.map +1 -0
- package/dist/run/worker/protocol.js +18 -0
- package/dist/run/worker/protocol.js.map +1 -0
- package/dist/run/worker/session.d.ts +69 -0
- package/dist/run/worker/session.d.ts.map +1 -0
- package/dist/run/worker/session.js +123 -0
- package/dist/run/worker/session.js.map +1 -0
- package/dist/types.d.ts +630 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +91 -0
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default step executor (RFC0001, layer 4 golden path): the tool-loop
|
|
3
|
+
* chassis plus the grammar toolset. Every mutating tool returns the
|
|
4
|
+
* updated screen; verdicts, budgets, hard stops, loop guards, wind-down, and
|
|
5
|
+
* the transcript come from the chassis (`tool-loop.ts`) unchanged.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { aiSdk } from './ai-sdk.js';
|
|
9
|
+
import { AgentError, isAgentError } from './error.js';
|
|
10
|
+
import { RUNTIME_CODES, } from './executor.js';
|
|
11
|
+
import { createToolLoopExecutor } from './tool-loop.js';
|
|
12
|
+
import { isDefinedTool, toolAppliesTo } from './tool.js';
|
|
13
|
+
const BASE_RULES = `You are an autonomous end-to-end testing agent executing exactly one test step against a real application.
|
|
14
|
+
|
|
15
|
+
Rules:
|
|
16
|
+
- Work only toward the given step; do not start the next step or explore beyond it.
|
|
17
|
+
- Use the tools to inspect and act. Node ids like "n42" are valid only for the newest observation; after any action, use ids from the latest "Updated screen" snapshot.
|
|
18
|
+
- Issue at most ONE mutating tool call per turn: every mutation refreshes the screen and invalidates all earlier node ids, so a second action batched in the same turn targets a stale screen and fails.
|
|
19
|
+
- Never invent node ids. If the target is not on screen, bring it on screen with the tools you have (scroll, navigate) or conclude.`;
|
|
20
|
+
/** How many trailing screen snapshots stay verbatim in the transcript. */
|
|
21
|
+
const SNAPSHOT_PRESERVE_COUNT = 2;
|
|
22
|
+
const SNAPSHOT_PATTERN = /(?:Updated|Current) screen \(revision /;
|
|
23
|
+
/** Builds the default AI SDK step executor. */
|
|
24
|
+
export function createAgent(options = {}) {
|
|
25
|
+
const userTools = validateUserTools(options.tools);
|
|
26
|
+
const system = [BASE_RULES, options.system]
|
|
27
|
+
.filter((part) => part !== undefined && part.trim() !== '')
|
|
28
|
+
.join('\n\n');
|
|
29
|
+
return createToolLoopExecutor({
|
|
30
|
+
name: 'e2e-default-agent',
|
|
31
|
+
version: '2',
|
|
32
|
+
...(options.model === undefined ? {} : { model: options.model }),
|
|
33
|
+
system,
|
|
34
|
+
...(options.maxTurns === undefined ? {} : { maxTurns: options.maxTurns }),
|
|
35
|
+
compactMessages: compactSnapshotHistory,
|
|
36
|
+
tools: (context, helpers) => ({
|
|
37
|
+
...wrapUserTools(context, helpers, userTools),
|
|
38
|
+
...buildGrammarTools(context, helpers),
|
|
39
|
+
}),
|
|
40
|
+
buildPrompt: async (context) => {
|
|
41
|
+
const observation = await context.observe();
|
|
42
|
+
const parts = [
|
|
43
|
+
context.step.kind === 'assert'
|
|
44
|
+
? `Judge whether this assertion holds; do not change application state: ${context.step.instruction}`
|
|
45
|
+
: `Execute this test step: ${context.step.instruction}`,
|
|
46
|
+
];
|
|
47
|
+
if (context.step.params !== undefined) {
|
|
48
|
+
parts.push(`Step parameters:\n${JSON.stringify(context.step.params)}`);
|
|
49
|
+
}
|
|
50
|
+
if (context.replayedPrefix !== undefined) {
|
|
51
|
+
parts.push(formatReplayedPrefix(context.replayedPrefix));
|
|
52
|
+
}
|
|
53
|
+
if (context.ledger !== '') {
|
|
54
|
+
parts.push(`Previously completed steps:\n${context.ledger}`);
|
|
55
|
+
}
|
|
56
|
+
parts.push(`Current screen (revision ${observation.revision}):\n${observation.text}`);
|
|
57
|
+
return parts.join('\n\n');
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The mid-step hand-off notice (RFC0001 layer 4): prose summaries and a reason
|
|
63
|
+
* token, replacing any ordinary prior-run hint. The agent continues from live
|
|
64
|
+
* state; redoing a replayed action would double-commit a mutation.
|
|
65
|
+
*/
|
|
66
|
+
function formatReplayedPrefix(prefix) {
|
|
67
|
+
const lines = prefix.replayedActions.map((summary, index) => `${index + 1}. ${summary}`);
|
|
68
|
+
return [
|
|
69
|
+
'Cached replay already performed these recorded actions for this step:',
|
|
70
|
+
...lines,
|
|
71
|
+
`Replay stopped (${prefix.stopReason}) after ${prefix.replayedActions.length} of ${prefix.totalActions} recorded actions.`,
|
|
72
|
+
...(prefix.stopReason === 'end-mismatch'
|
|
73
|
+
? [
|
|
74
|
+
'Every recorded action ran, but the screen does not show the recorded end state. ' +
|
|
75
|
+
'Check whether the step actually took effect before doing anything — the recorded flow may have silently failed to commit.',
|
|
76
|
+
]
|
|
77
|
+
: []),
|
|
78
|
+
...(prefix.uncertainAction === undefined
|
|
79
|
+
? []
|
|
80
|
+
: [
|
|
81
|
+
`WARNING: the next action (${prefix.uncertainAction}) failed with an UNKNOWN commit state — ` +
|
|
82
|
+
'its input may have reached the app. Verify the current state before doing anything like it again.',
|
|
83
|
+
]),
|
|
84
|
+
'Continue the step from the CURRENT screen state shown below — do NOT redo the actions above.',
|
|
85
|
+
].join('\n');
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The default toolset: thin AI SDK tools over the harness action grammar,
|
|
89
|
+
* limited to the verbs the target's backend declared. A verb the surface cannot
|
|
90
|
+
* honor is not offered at all, so the model never learns vocabulary it can only
|
|
91
|
+
* be rejected on.
|
|
92
|
+
*/
|
|
93
|
+
function buildGrammarTools(context, helpers) {
|
|
94
|
+
const { guard } = helpers;
|
|
95
|
+
const { verbs } = context.target;
|
|
96
|
+
/** Re-observes after a mutating action so the model always sees the result. */
|
|
97
|
+
const acted = async (description) => {
|
|
98
|
+
const observation = await context.observe();
|
|
99
|
+
return `${description}\n\nUpdated screen (revision ${observation.revision}):\n${observation.text}`;
|
|
100
|
+
};
|
|
101
|
+
const target = z
|
|
102
|
+
.string()
|
|
103
|
+
.min(1)
|
|
104
|
+
.describe('Node id from the newest observation, e.g. "n42"');
|
|
105
|
+
// The chassis loads the AI SDK before building tools, so reading the
|
|
106
|
+
// cached instance here cannot race the optional-peer loader.
|
|
107
|
+
const { tool } = aiSdk();
|
|
108
|
+
const tools = {
|
|
109
|
+
observe: tool({
|
|
110
|
+
description: 'Capture a fresh observation of the current screen without acting.',
|
|
111
|
+
inputSchema: z.object({}),
|
|
112
|
+
execute: () => guard(async () => {
|
|
113
|
+
const observation = await context.observe();
|
|
114
|
+
return `Current screen (revision ${observation.revision}):\n${observation.text}`;
|
|
115
|
+
}),
|
|
116
|
+
}),
|
|
117
|
+
};
|
|
118
|
+
if (verbs.has('tap')) {
|
|
119
|
+
tools['tap'] = tool({
|
|
120
|
+
description: 'Tap or click one node.',
|
|
121
|
+
inputSchema: z.object({ target }),
|
|
122
|
+
execute: ({ target: id }) => guard(async () => {
|
|
123
|
+
await context.actions.tap({ id });
|
|
124
|
+
return acted(`Tapped #${id}.`);
|
|
125
|
+
}),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
if (verbs.has('type')) {
|
|
129
|
+
tools['type'] = tool({
|
|
130
|
+
description: 'Type a plain-text value into one input node. Replaces the current value.',
|
|
131
|
+
inputSchema: z.object({ target, value: z.string() }),
|
|
132
|
+
execute: ({ target: id, value }) => guard(async () => {
|
|
133
|
+
await context.actions.type({ id }, value);
|
|
134
|
+
return acted(`Typed into #${id}.`);
|
|
135
|
+
}),
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
if (verbs.has('press')) {
|
|
139
|
+
tools['press'] = tool({
|
|
140
|
+
description: 'Send one key (e.g. "Enter", "Escape", "Tab") to one node.',
|
|
141
|
+
inputSchema: z.object({ target, key: z.string().min(1).max(64) }),
|
|
142
|
+
execute: ({ target: id, key }) => guard(async () => {
|
|
143
|
+
await context.actions.press({ id }, key);
|
|
144
|
+
return acted(`Pressed ${key} on #${id}.`);
|
|
145
|
+
}),
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
if (verbs.has('select')) {
|
|
149
|
+
tools['select'] = tool({
|
|
150
|
+
description: 'Pick one option from a select-like control by its visible label.',
|
|
151
|
+
inputSchema: z.object({ target, value: z.string().min(1) }),
|
|
152
|
+
execute: ({ target: id, value }) => guard(async () => {
|
|
153
|
+
await context.actions.select({ id }, value);
|
|
154
|
+
return acted(`Selected "${value}" in #${id}.`);
|
|
155
|
+
}),
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
if (verbs.has('scroll')) {
|
|
159
|
+
const direction = z.enum(['up', 'down', 'left', 'right']);
|
|
160
|
+
// Node-targeted scrolling rides `perform`; without it only the viewport scrolls.
|
|
161
|
+
tools['scroll'] = verbs.has('tap')
|
|
162
|
+
? tool({
|
|
163
|
+
description: 'Scroll the viewport, or one scrollable node when target is given.',
|
|
164
|
+
inputSchema: z.object({ direction, target: target.optional() }),
|
|
165
|
+
execute: ({ direction: way, target: id }) => guard(async () => {
|
|
166
|
+
await context.actions.scroll(way, id === undefined ? undefined : { id });
|
|
167
|
+
return acted(`Scrolled ${way}.`);
|
|
168
|
+
}),
|
|
169
|
+
})
|
|
170
|
+
: tool({
|
|
171
|
+
description: 'Scroll the viewport.',
|
|
172
|
+
inputSchema: z.object({ direction }),
|
|
173
|
+
execute: ({ direction: way }) => guard(async () => {
|
|
174
|
+
await context.actions.scroll(way);
|
|
175
|
+
return acted(`Scrolled ${way}.`);
|
|
176
|
+
}),
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
if (verbs.has('navigate')) {
|
|
180
|
+
tools['navigate'] = tool({
|
|
181
|
+
description: 'Navigate to a URL or app-relative path within the allowed origins.',
|
|
182
|
+
inputSchema: z.object({ url: z.string().min(1) }),
|
|
183
|
+
execute: ({ url }) => guard(async () => {
|
|
184
|
+
await context.actions.navigate(url);
|
|
185
|
+
return acted(`Navigated to ${url}.`);
|
|
186
|
+
}),
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
// Offered only when the step declared secrets and the surface can fill: an
|
|
190
|
+
// empty vocabulary is better than a tool the model can only be rejected on.
|
|
191
|
+
if (verbs.has('typeSecret') && context.step.secrets.length > 0) {
|
|
192
|
+
tools['type_secret'] = tool({
|
|
193
|
+
description: 'Fill one declared secret credential into a secure input field; the plaintext never passes through you. Available: ' +
|
|
194
|
+
context.step.secrets.map((secret) => `"${secret.name}" (${secret.purpose})`).join(', ') +
|
|
195
|
+
'.',
|
|
196
|
+
inputSchema: z.object({ target, name: z.string().min(1) }),
|
|
197
|
+
execute: ({ target: id, name }) => guard(async () => {
|
|
198
|
+
await context.actions.typeSecret({ id }, name);
|
|
199
|
+
return acted(`Filled secret "${name}" into #${id}.`);
|
|
200
|
+
}),
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
return tools;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Compacts stale screen snapshots out of the history: the initial prompt's
|
|
207
|
+
* `Current screen` and every tool result's `Updated screen`.
|
|
208
|
+
*
|
|
209
|
+
* Only the newest observations describe the screen the model is acting on;
|
|
210
|
+
* every older tree is dead weight that grows the prompt linearly with turn
|
|
211
|
+
* count - and the very first tree, in the user prompt, is the oldest of all.
|
|
212
|
+
* A stale snapshot keeps what preceded the tree (the instruction, or what
|
|
213
|
+
* the action did) and loses the tree. Returns the input array unchanged when
|
|
214
|
+
* there is nothing to compact, so the caller can skip the messages override.
|
|
215
|
+
*/
|
|
216
|
+
function compactSnapshotHistory(messages) {
|
|
217
|
+
const total = messages.reduce((count, message) => count + snapshotParts(message).filter((text) => text !== undefined).length, 0);
|
|
218
|
+
let stale = total - SNAPSHOT_PRESERVE_COUNT;
|
|
219
|
+
if (stale <= 0)
|
|
220
|
+
return messages;
|
|
221
|
+
return messages.map((message) => {
|
|
222
|
+
if (stale <= 0)
|
|
223
|
+
return message;
|
|
224
|
+
if (message.role === 'user') {
|
|
225
|
+
if (typeof message.content === 'string') {
|
|
226
|
+
if (!SNAPSHOT_PATTERN.test(message.content))
|
|
227
|
+
return message;
|
|
228
|
+
stale -= 1;
|
|
229
|
+
return { ...message, content: elideSnapshot(message.content) };
|
|
230
|
+
}
|
|
231
|
+
const content = message.content.map((part) => {
|
|
232
|
+
if (stale <= 0 || part.type !== 'text' || !SNAPSHOT_PATTERN.test(part.text))
|
|
233
|
+
return part;
|
|
234
|
+
stale -= 1;
|
|
235
|
+
return { ...part, text: elideSnapshot(part.text) };
|
|
236
|
+
});
|
|
237
|
+
return { ...message, content };
|
|
238
|
+
}
|
|
239
|
+
if (message.role !== 'tool')
|
|
240
|
+
return message;
|
|
241
|
+
const texts = snapshotParts(message);
|
|
242
|
+
if (!texts.some((text) => text !== undefined))
|
|
243
|
+
return message;
|
|
244
|
+
const content = message.content.map((part, index) => {
|
|
245
|
+
const text = texts[index];
|
|
246
|
+
if (text === undefined || stale <= 0)
|
|
247
|
+
return part;
|
|
248
|
+
stale -= 1;
|
|
249
|
+
return { ...part, output: { type: 'text', value: elideSnapshot(text) } };
|
|
250
|
+
});
|
|
251
|
+
return { ...message, content };
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
/** Everything before the snapshot marker, then the elision notice in place of the tree. */
|
|
255
|
+
function elideSnapshot(text) {
|
|
256
|
+
const at = text.search(SNAPSHOT_PATTERN);
|
|
257
|
+
const head = at <= 0 ? (text.split('\n', 1)[0] ?? '') : text.slice(0, at).trimEnd();
|
|
258
|
+
return `${head}\n[stale screen snapshot elided; act on the newest observation]`;
|
|
259
|
+
}
|
|
260
|
+
/** Per-part snapshot text of one message; undefined for non-snapshot parts. */
|
|
261
|
+
function snapshotParts(message) {
|
|
262
|
+
if (message.role === 'user') {
|
|
263
|
+
if (typeof message.content === 'string') {
|
|
264
|
+
return [SNAPSHOT_PATTERN.test(message.content) ? message.content : undefined];
|
|
265
|
+
}
|
|
266
|
+
return message.content.map((part) => part.type === 'text' && SNAPSHOT_PATTERN.test(part.text) ? part.text : undefined);
|
|
267
|
+
}
|
|
268
|
+
if (message.role !== 'tool')
|
|
269
|
+
return [];
|
|
270
|
+
return message.content.map((part) => {
|
|
271
|
+
if (part.type !== 'tool-result')
|
|
272
|
+
return undefined;
|
|
273
|
+
const output = part.output;
|
|
274
|
+
if (output.type !== 'text' || typeof output.value !== 'string')
|
|
275
|
+
return undefined;
|
|
276
|
+
return SNAPSHOT_PATTERN.test(output.value) ? output.value : undefined;
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
/** Validates `defineTool` values and reserved names once, at construction. */
|
|
280
|
+
function validateUserTools(tools) {
|
|
281
|
+
if (tools === undefined)
|
|
282
|
+
return {};
|
|
283
|
+
for (const [name, defined] of Object.entries(tools)) {
|
|
284
|
+
if (!isDefinedTool(defined)) {
|
|
285
|
+
throw new AgentError('POLICY_DENIED', `tool "${name}" was not created with defineTool; undeclared semantics are not trusted`);
|
|
286
|
+
}
|
|
287
|
+
if (name === 'complete_step') {
|
|
288
|
+
throw new AgentError('POLICY_DENIED', 'the complete_step tool name is reserved');
|
|
289
|
+
}
|
|
290
|
+
if (defined.tool.execute === undefined) {
|
|
291
|
+
throw new AgentError('POLICY_DENIED', `tool "${name}" has no execute function`);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return tools;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Wraps project tools so they run the same accounting pipeline as the
|
|
298
|
+
* grammar: every call is recorded, a mutating tool consumes an action-budget
|
|
299
|
+
* slot - refused before it runs once the ceiling is reached, consumed whether
|
|
300
|
+
* it succeeds or fails, exactly like a grammar action - and a runtime hard
|
|
301
|
+
* stop ends the loop. Any other failure goes back to the model as text it can
|
|
302
|
+
* react to, never as a provider failure of the step.
|
|
303
|
+
*/
|
|
304
|
+
function wrapUserTools(context, helpers, tools) {
|
|
305
|
+
const wrapped = {};
|
|
306
|
+
for (const [name, defined] of Object.entries(tools)) {
|
|
307
|
+
// A tool scoped to other platforms is not offered, so the model never
|
|
308
|
+
// learns a verb the surface cannot honor.
|
|
309
|
+
if (!toolAppliesTo(defined, context.target.platform))
|
|
310
|
+
continue;
|
|
311
|
+
// validateUserTools rejected any tool without execute at construction.
|
|
312
|
+
const execute = defined.tool.execute.bind(defined.tool);
|
|
313
|
+
const mutates = defined.annotations.mutates;
|
|
314
|
+
wrapped[name] = {
|
|
315
|
+
...defined.tool,
|
|
316
|
+
execute: async (input, executionOptions) => {
|
|
317
|
+
if (helpers.concluding()) {
|
|
318
|
+
return 'The step is already concluding; no further actions run.';
|
|
319
|
+
}
|
|
320
|
+
if (mutates && context.budgets.actionsUsed() >= context.budgets.maxActions) {
|
|
321
|
+
const stop = new AgentError('STEP_BUDGET_EXHAUSTED', `the step exhausted its action budget of ${context.budgets.maxActions}`);
|
|
322
|
+
helpers.reportHardStop(stop);
|
|
323
|
+
return `HARD STOP (${stop.code}): ${stop.message}`;
|
|
324
|
+
}
|
|
325
|
+
const startedMs = Date.now();
|
|
326
|
+
let attempted = false;
|
|
327
|
+
try {
|
|
328
|
+
attempted = true;
|
|
329
|
+
return await execute(input, executionOptions);
|
|
330
|
+
}
|
|
331
|
+
catch (cause) {
|
|
332
|
+
if (isAgentError(cause) && RUNTIME_CODES.has(cause.code)) {
|
|
333
|
+
helpers.reportHardStop(cause);
|
|
334
|
+
return `HARD STOP (${cause.code}): ${cause.message}`;
|
|
335
|
+
}
|
|
336
|
+
return `Tool "${name}" failed: ${cause instanceof Error ? cause.message : String(cause)}`;
|
|
337
|
+
}
|
|
338
|
+
finally {
|
|
339
|
+
if (attempted) {
|
|
340
|
+
try {
|
|
341
|
+
context.budgets.recordToolCall({ name, mutates, durationMs: Date.now() - startedMs });
|
|
342
|
+
}
|
|
343
|
+
catch (cause) {
|
|
344
|
+
if (isAgentError(cause) && RUNTIME_CODES.has(cause.code))
|
|
345
|
+
helpers.reportHardStop(cause);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
return wrapped;
|
|
353
|
+
}
|
|
354
|
+
//# sourceMappingURL=default-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-agent.js","sourceRoot":"","sources":["../../src/agent/default-agent.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EACL,aAAa,GAId,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,sBAAsB,EAAwB,MAAM,gBAAgB,CAAC;AAE9E,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAEzD,MAAM,UAAU,GAAG;;;;;;oIAMiH,CAAC;AAErI,0EAA0E;AAC1E,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAElC,MAAM,gBAAgB,GAAG,wCAAwC,CAAC;AAalE,+CAA+C;AAC/C,MAAM,UAAU,WAAW,CAAC,OAAO,GAAuB,EAAE;IAC1D,MAAM,SAAS,GAAG,iBAAiB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACnD,MAAM,MAAM,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC;SACxC,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,IAAI,KAAK,SAAS,I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
|
|
2
|
+
import { E2EError, type ErrorCategory } from '../internal/errors.ts';
|
|
3
|
+
import type { AgentErrorCode } from '../types.ts';
|
|
4
|
+
/**
|
|
5
|
+
* What a `blocked` verdict names as the obstacle. Mirrors the platform's
|
|
6
|
+
* categories exactly: the first four have external owners (fix the
|
|
7
|
+
* credential, the environment, the seed data, the setup); `automation` means
|
|
8
|
+
* the agent itself ran out of room and says nothing about the product.
|
|
9
|
+
*/
|
|
10
|
+
export type BlockedCategory = 'credentials' | 'environment' | 'seed_data' | 'test_setup' | 'automation';
|
|
11
|
+
/**
|
|
12
|
+
* The single source of truth for the closed agent code set: exit/result class
|
|
13
|
+
* per 06-cli.md, plus the blocked category for codes a `blocked` verdict may
|
|
14
|
+
* carry. The model never selects a code, a category, or a blocked category —
|
|
15
|
+
* everything derives from this table.
|
|
16
|
+
*/
|
|
17
|
+
export declare const AGENT_CODE_TABLE: Readonly<Record<AgentErrorCode, {
|
|
18
|
+
category: ErrorCategory;
|
|
19
|
+
blockedCategory?: BlockedCategory;
|
|
20
|
+
}>>;
|
|
21
|
+
/** Exit/result class per code; derived from the one table. */
|
|
22
|
+
export declare const CATEGORY_BY_CODE: Readonly<Record<AgentErrorCode, ErrorCategory>>;
|
|
23
|
+
/** The blocked category a code names, or undefined when it is not blockable. */
|
|
24
|
+
export declare function blockedCategoryOf(code: AgentErrorCode): BlockedCategory | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Runner-classified agent failure (spec api/e2e.d.ts). It extends the internal
|
|
27
|
+
* error base so category, exit code, retry eligibility, and report
|
|
28
|
+
* serialization stay consistent with every other runner error.
|
|
29
|
+
*/
|
|
30
|
+
export declare class AgentError extends E2EError {
|
|
31
|
+
readonly code: AgentErrorCode;
|
|
32
|
+
readonly explanation: string;
|
|
33
|
+
readonly screenshot?: string;
|
|
34
|
+
/** True when this failure reports a blocked step, not a product failure. */
|
|
35
|
+
readonly blocked: boolean;
|
|
36
|
+
constructor(code: AgentErrorCode, explanation: string, options?: {
|
|
37
|
+
screenshot?: string;
|
|
38
|
+
cause?: unknown;
|
|
39
|
+
blocked?: boolean;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Maps any runner error raised inside an invocation onto the closed agent code
|
|
44
|
+
* set. Model prose can never select a code.
|
|
45
|
+
*/
|
|
46
|
+
export declare function toAgentError(cause: unknown): AgentError;
|
|
47
|
+
/**
|
|
48
|
+
* True when a thrown value is an agent error from this or another realm.
|
|
49
|
+
* Identity rides on a global symbol marker, not the class name, so subclasses
|
|
50
|
+
* keep honest names and `instanceof` never spans realms.
|
|
51
|
+
*/
|
|
52
|
+
export declare function isAgentError(value: unknown): value is AgentError;
|
|
53
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/agent/error.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,OAAO,EAAiB,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACpF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GACvB,aAAa,GACb,aAAa,GACb,WAAW,GACX,YAAY,GACZ,YAAY,CAAC;AAEjB;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CACrC,MAAM,CAAC,cAAc,EAAE;IAAE,QAAQ,EAAE,aAAa,CAAC;IAAC,eAAe,CAAC,EAAE,eAAe,CAAA;CAAE,CAAC,CAuBvF,CAAC;AAEF,8DAA8D;AAC9D,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,cAAc,EAAE,aAAa,CAAC,CAGjC,CAAC;AAE7C,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,cAAc,GAAG,eAAe,GAAG,SAAS,CAEnF;AAKD;;;;GAIG;AACH,qBAAa,UAAW,SAAQ,QAAQ;IACtC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B,YACE,IAAI,EAAE,cAAc,EACpB,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAO,EAS1E;CACF;AAKD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAavD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAOhE"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/** Runner-owned agent error classification (spec 02-test-api.md, 06-cli.md). */
|
|
2
|
+
import { classifyError, E2EError } from '../internal/errors.js';
|
|
3
|
+
/**
|
|
4
|
+
* The single source of truth for the closed agent code set: exit/result class
|
|
5
|
+
* per 06-cli.md, plus the blocked category for codes a `blocked` verdict may
|
|
6
|
+
* carry. The model never selects a code, a category, or a blocked category —
|
|
7
|
+
* everything derives from this table.
|
|
8
|
+
*/
|
|
9
|
+
export const AGENT_CODE_TABLE = {
|
|
10
|
+
AUTH_CREDENTIAL_UNAVAILABLE: { category: 'configuration', blockedCategory: 'credentials' },
|
|
11
|
+
AUTH_CREDENTIAL_INVALID: { category: 'configuration', blockedCategory: 'credentials' },
|
|
12
|
+
ENVIRONMENT_UNAVAILABLE: { category: 'infrastructure', blockedCategory: 'environment' },
|
|
13
|
+
APP_UNREACHABLE: { category: 'infrastructure', blockedCategory: 'environment' },
|
|
14
|
+
SEED_DATA_MISSING: { category: 'configuration', blockedCategory: 'seed_data' },
|
|
15
|
+
TEST_SETUP_FAILED: { category: 'configuration', blockedCategory: 'test_setup' },
|
|
16
|
+
APP_NOT_OPEN: { category: 'test', blockedCategory: 'test_setup' },
|
|
17
|
+
POLICY_DENIED: { category: 'configuration', blockedCategory: 'test_setup' },
|
|
18
|
+
MODEL_UNAVAILABLE: { category: 'configuration', blockedCategory: 'automation' },
|
|
19
|
+
AUTOMATION_UNSUPPORTED: { category: 'test', blockedCategory: 'automation' },
|
|
20
|
+
STEP_BUDGET_EXHAUSTED: { category: 'test', blockedCategory: 'automation' },
|
|
21
|
+
STEP_TIMEOUT: { category: 'test', blockedCategory: 'automation' },
|
|
22
|
+
MODEL_PROVIDER_FAILED: { category: 'infrastructure' },
|
|
23
|
+
CANCELLED: { category: 'infrastructure' },
|
|
24
|
+
AUTHENTICATION_FAILED: { category: 'test' },
|
|
25
|
+
MODEL_OUTPUT_INVALID: { category: 'test' },
|
|
26
|
+
LOCATOR_NOT_FOUND: { category: 'test' },
|
|
27
|
+
LOCATOR_AMBIGUOUS: { category: 'test' },
|
|
28
|
+
ACTION_FAILED: { category: 'test' },
|
|
29
|
+
STEP_NO_CONCLUSION: { category: 'test' },
|
|
30
|
+
ASSERTION_FAILED: { category: 'test' },
|
|
31
|
+
};
|
|
32
|
+
/** Exit/result class per code; derived from the one table. */
|
|
33
|
+
export const CATEGORY_BY_CODE = Object.fromEntries(Object.entries(AGENT_CODE_TABLE).map(([code, entry]) => [code, entry.category]));
|
|
34
|
+
/** The blocked category a code names, or undefined when it is not blockable. */
|
|
35
|
+
export function blockedCategoryOf(code) {
|
|
36
|
+
return AGENT_CODE_TABLE[code]?.blockedCategory;
|
|
37
|
+
}
|
|
38
|
+
/** Cross-realm identity marker, mirroring `internal/errors.ts`. */
|
|
39
|
+
const AGENT_ERROR_MARKER = Symbol.for('e2e.agent-error.v1');
|
|
40
|
+
/**
|
|
41
|
+
* Runner-classified agent failure (spec api/e2e.d.ts). It extends the internal
|
|
42
|
+
* error base so category, exit code, retry eligibility, and report
|
|
43
|
+
* serialization stay consistent with every other runner error.
|
|
44
|
+
*/
|
|
45
|
+
export class AgentError extends E2EError {
|
|
46
|
+
code;
|
|
47
|
+
explanation;
|
|
48
|
+
screenshot;
|
|
49
|
+
/** True when this failure reports a blocked step, not a product failure. */
|
|
50
|
+
blocked;
|
|
51
|
+
constructor(code, explanation, options = {}) {
|
|
52
|
+
super(CATEGORY_BY_CODE[code], code, explanation, options);
|
|
53
|
+
this.name = new.target.name;
|
|
54
|
+
Object.defineProperty(this, AGENT_ERROR_MARKER, { value: true });
|
|
55
|
+
this.code = code;
|
|
56
|
+
this.explanation = explanation;
|
|
57
|
+
this.blocked = options.blocked === true;
|
|
58
|
+
if (options.screenshot !== undefined)
|
|
59
|
+
this.screenshot = options.screenshot;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** The closed agent code set, derived from the one classification table. */
|
|
63
|
+
const AGENT_CODES = new Set(Object.keys(CATEGORY_BY_CODE));
|
|
64
|
+
/**
|
|
65
|
+
* Maps any runner error raised inside an invocation onto the closed agent code
|
|
66
|
+
* set. Model prose can never select a code.
|
|
67
|
+
*/
|
|
68
|
+
export function toAgentError(cause) {
|
|
69
|
+
if (isAgentError(cause))
|
|
70
|
+
return cause;
|
|
71
|
+
const classified = cause instanceof E2EError ? cause : classifyError(cause);
|
|
72
|
+
if (AGENT_CODES.has(classified.code)) {
|
|
73
|
+
return new AgentError(classified.code, classified.message, { cause });
|
|
74
|
+
}
|
|
75
|
+
if (classified.code === 'UNSUPPORTED_CAPABILITY' || classified.code === 'INVALID_CONFIG') {
|
|
76
|
+
return new AgentError('POLICY_DENIED', classified.message, { cause });
|
|
77
|
+
}
|
|
78
|
+
if (classified.category === 'infrastructure') {
|
|
79
|
+
return new AgentError('APP_UNREACHABLE', classified.message, { cause });
|
|
80
|
+
}
|
|
81
|
+
return new AgentError('ACTION_FAILED', classified.message, { cause });
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* True when a thrown value is an agent error from this or another realm.
|
|
85
|
+
* Identity rides on a global symbol marker, not the class name, so subclasses
|
|
86
|
+
* keep honest names and `instanceof` never spans realms.
|
|
87
|
+
*/
|
|
88
|
+
export function isAgentError(value) {
|
|
89
|
+
return (value instanceof Error &&
|
|
90
|
+
AGENT_ERROR_MARKER in value &&
|
|
91
|
+
typeof value.code === 'string' &&
|
|
92
|
+
value.code in CATEGORY_BY_CODE);
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/agent/error.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAsB,MAAM,uBAAuB,CAAC;AAgBpF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAEzB;IACF,2BAA2B,EAAE,EAAE,QAAQ,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE;IAC1F,uBAAuB,EAAE,EAAE,QAAQ,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE;IACtF,uBAAuB,EAAE,EAAE,QAAQ,EAAE,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAE;IACvF,eAAe,EAAE,EAAE,QAAQ,EAAE,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAE;IAC/E,iBAAiB,EAAE,EAAE,QAAQ,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE;IAC9E,iBAAiB,EAAE,EAAE,QAAQ,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE;IAC/E,YAAY,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,YAAY,EAAE;IACjE,aAAa,EAAE,EAAE,QAAQ,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE;IAC3E,iBAAiB,EAAE,EAAE,QAAQ,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE;IAC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