@mlola/browser-protocol 0.1.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 +14 -0
- package/dist/actions.d.ts +124 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +155 -0
- package/dist/actions.js.map +1 -0
- package/dist/budget.d.ts +57 -0
- package/dist/budget.d.ts.map +1 -0
- package/dist/budget.js +25 -0
- package/dist/budget.js.map +1 -0
- package/dist/capabilities.d.ts +31 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +54 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/decision.d.ts +188 -0
- package/dist/decision.d.ts.map +1 -0
- package/dist/decision.js +9 -0
- package/dist/decision.js.map +1 -0
- package/dist/errors.d.ts +40 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +104 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.d.ts +326 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +75 -0
- package/dist/events.js.map +1 -0
- package/dist/human.d.ts +43 -0
- package/dist/human.d.ts.map +1 -0
- package/dist/human.js +10 -0
- package/dist/human.js.map +1 -0
- package/dist/ids.d.ts +34 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +22 -0
- package/dist/ids.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/memory.d.ts +37 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +54 -0
- package/dist/memory.js.map +1 -0
- package/dist/observation.d.ts +157 -0
- package/dist/observation.d.ts.map +1 -0
- package/dist/observation.js +45 -0
- package/dist/observation.js.map +1 -0
- package/dist/policy.d.ts +89 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +138 -0
- package/dist/policy.js.map +1 -0
- package/dist/provenance.d.ts +27 -0
- package/dist/provenance.d.ts.map +1 -0
- package/dist/provenance.js +46 -0
- package/dist/provenance.js.map +1 -0
- package/dist/schemas.d.ts +449 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +218 -0
- package/dist/schemas.js.map +1 -0
- package/dist/task.d.ts +94 -0
- package/dist/task.d.ts.map +1 -0
- package/dist/task.js +13 -0
- package/dist/task.js.map +1 -0
- package/dist/verification.d.ts +70 -0
- package/dist/verification.d.ts.map +1 -0
- package/dist/verification.js +24 -0
- package/dist/verification.js.map +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decision provider contracts (PRD §15, §16, §44).
|
|
3
|
+
*
|
|
4
|
+
* Provider roles are separate: the fast path decides *whether and where*,
|
|
5
|
+
* the text helper decides *what text*, the planner handles long horizons and
|
|
6
|
+
* recovery, vision is a fallback for visual-only surfaces.
|
|
7
|
+
*/
|
|
8
|
+
import type { ActionSpace, OperationId, TargetHeadId, TypedAction } from "./actions.ts";
|
|
9
|
+
import type { ArtifactId, HelpId, RunId, SnapshotId, StepId } from "./ids.ts";
|
|
10
|
+
import type { WorkingMemory } from "./memory.ts";
|
|
11
|
+
import type { BrowserSnapshot, ObservedNode, TabInfo } from "./observation.ts";
|
|
12
|
+
import type { ProvenanceClass } from "./provenance.ts";
|
|
13
|
+
import type { BudgetSnapshot, Usage } from "./budget.ts";
|
|
14
|
+
export interface StepSummary {
|
|
15
|
+
step: number;
|
|
16
|
+
action: string;
|
|
17
|
+
outcome: "ok" | "failed" | "no_effect";
|
|
18
|
+
detail?: string;
|
|
19
|
+
url?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface DecisionInput {
|
|
22
|
+
runId: RunId;
|
|
23
|
+
step: number;
|
|
24
|
+
goal: string;
|
|
25
|
+
subgoal?: string;
|
|
26
|
+
snapshot: BrowserSnapshot;
|
|
27
|
+
actionSpace: ActionSpace;
|
|
28
|
+
memory: WorkingMemory;
|
|
29
|
+
artifacts: ArtifactSummary[];
|
|
30
|
+
history: StepSummary[];
|
|
31
|
+
failure?: string;
|
|
32
|
+
budget: BudgetSnapshot;
|
|
33
|
+
}
|
|
34
|
+
export interface DecisionOutput {
|
|
35
|
+
operation: OperationId;
|
|
36
|
+
operationProbabilities: Record<string, number>;
|
|
37
|
+
operationConfidence: number;
|
|
38
|
+
/** Key into the selected operation's target head. */
|
|
39
|
+
target?: string;
|
|
40
|
+
targetProbabilities?: Record<string, number>;
|
|
41
|
+
targetConfidence?: number;
|
|
42
|
+
usage?: Usage;
|
|
43
|
+
latencyMs: number;
|
|
44
|
+
provider: string;
|
|
45
|
+
model?: string;
|
|
46
|
+
/** Provider raw response, local only. Never fed back into another model. */
|
|
47
|
+
raw?: unknown;
|
|
48
|
+
}
|
|
49
|
+
export interface DecisionProvider {
|
|
50
|
+
readonly name: string;
|
|
51
|
+
decide(input: DecisionInput): Promise<DecisionOutput>;
|
|
52
|
+
}
|
|
53
|
+
export interface TextGenerationInput {
|
|
54
|
+
goal: string;
|
|
55
|
+
subgoal?: string;
|
|
56
|
+
/** What the field is for, e.g. `textbox "Search"` — structure, not content. */
|
|
57
|
+
targetLabel: string;
|
|
58
|
+
targetRole: string;
|
|
59
|
+
/** Bounded runtime context; never contains secrets. */
|
|
60
|
+
context?: string;
|
|
61
|
+
/** Literal candidate values extracted deterministically from the goal. */
|
|
62
|
+
literals: string[];
|
|
63
|
+
maxLength?: number;
|
|
64
|
+
}
|
|
65
|
+
export interface TextGenerationOutput {
|
|
66
|
+
text: string;
|
|
67
|
+
source: "literal" | "model" | "user";
|
|
68
|
+
usage?: Usage;
|
|
69
|
+
latencyMs?: number;
|
|
70
|
+
provider: string;
|
|
71
|
+
}
|
|
72
|
+
export interface TextProvider {
|
|
73
|
+
readonly name: string;
|
|
74
|
+
generate(input: TextGenerationInput): Promise<TextGenerationOutput>;
|
|
75
|
+
}
|
|
76
|
+
export interface PlannerInput {
|
|
77
|
+
runId: RunId;
|
|
78
|
+
goal: string;
|
|
79
|
+
reason: "initial" | "subgoal_complete" | "route_invalid" | "recovery_exhausted" | "goal_changed";
|
|
80
|
+
snapshotSummary: string;
|
|
81
|
+
memory: WorkingMemory;
|
|
82
|
+
history: StepSummary[];
|
|
83
|
+
artifacts: ArtifactSummary[];
|
|
84
|
+
previousSubgoals: PlannedSubgoal[];
|
|
85
|
+
budget: BudgetSnapshot;
|
|
86
|
+
}
|
|
87
|
+
export interface PlannedSubgoal {
|
|
88
|
+
id: string;
|
|
89
|
+
description: string;
|
|
90
|
+
/** Deterministic completion hints when the planner can express them. */
|
|
91
|
+
hints?: string[];
|
|
92
|
+
status?: "pending" | "active" | "done" | "failed" | "skipped";
|
|
93
|
+
}
|
|
94
|
+
export interface PlannerOutput {
|
|
95
|
+
subgoals: PlannedSubgoal[];
|
|
96
|
+
notes?: string;
|
|
97
|
+
usage?: Usage;
|
|
98
|
+
latencyMs?: number;
|
|
99
|
+
provider: string;
|
|
100
|
+
model?: string;
|
|
101
|
+
}
|
|
102
|
+
export interface PlannerProvider {
|
|
103
|
+
readonly name: string;
|
|
104
|
+
plan(input: PlannerInput): Promise<PlannerOutput>;
|
|
105
|
+
/**
|
|
106
|
+
* Strong-model fallback: choose one operation (and target) from the offered
|
|
107
|
+
* action space. Optional — a planner-only provider degrades to planning.
|
|
108
|
+
*/
|
|
109
|
+
chooseAction?(input: FallbackDecisionInput): Promise<FallbackDecisionOutput>;
|
|
110
|
+
}
|
|
111
|
+
export interface FallbackDecisionInput extends DecisionInput {
|
|
112
|
+
/** Why the fast path could not decide. */
|
|
113
|
+
reason: string;
|
|
114
|
+
}
|
|
115
|
+
export interface FallbackDecisionOutput {
|
|
116
|
+
operation: OperationId;
|
|
117
|
+
target?: string;
|
|
118
|
+
notes?: string;
|
|
119
|
+
usage?: Usage;
|
|
120
|
+
latencyMs: number;
|
|
121
|
+
provider: string;
|
|
122
|
+
model?: string;
|
|
123
|
+
raw?: unknown;
|
|
124
|
+
}
|
|
125
|
+
export interface VisionLocateInput {
|
|
126
|
+
captureId: string;
|
|
127
|
+
imageBase64: string;
|
|
128
|
+
question: string;
|
|
129
|
+
candidates?: string[];
|
|
130
|
+
viewport: {
|
|
131
|
+
width: number;
|
|
132
|
+
height: number;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
export interface VisionLocateOutput {
|
|
136
|
+
/** Normalized point in the capture, 0..1. */
|
|
137
|
+
point?: {
|
|
138
|
+
x: number;
|
|
139
|
+
y: number;
|
|
140
|
+
};
|
|
141
|
+
label?: string;
|
|
142
|
+
confidence?: number;
|
|
143
|
+
usage?: Usage;
|
|
144
|
+
latencyMs?: number;
|
|
145
|
+
provider: string;
|
|
146
|
+
}
|
|
147
|
+
export interface VisionProvider {
|
|
148
|
+
readonly name: string;
|
|
149
|
+
locate(input: VisionLocateInput): Promise<VisionLocateOutput>;
|
|
150
|
+
}
|
|
151
|
+
export interface ArtifactSummary {
|
|
152
|
+
id: ArtifactId;
|
|
153
|
+
name: string;
|
|
154
|
+
mimeType: string;
|
|
155
|
+
documentType?: string;
|
|
156
|
+
source: "download" | "upload" | "provided";
|
|
157
|
+
verified: boolean;
|
|
158
|
+
sizeBytes?: number;
|
|
159
|
+
}
|
|
160
|
+
export interface CandidateTable {
|
|
161
|
+
snapshotId: SnapshotId;
|
|
162
|
+
stepId: StepId;
|
|
163
|
+
space: ActionSpace;
|
|
164
|
+
createdAt: number;
|
|
165
|
+
}
|
|
166
|
+
export interface TargetResolution {
|
|
167
|
+
head: TargetHeadId;
|
|
168
|
+
key: string;
|
|
169
|
+
node?: ObservedNode;
|
|
170
|
+
url?: string;
|
|
171
|
+
tab?: TabInfo;
|
|
172
|
+
artifactId?: ArtifactId;
|
|
173
|
+
provenance: ProvenanceClass;
|
|
174
|
+
}
|
|
175
|
+
export interface HumanHelpSummary {
|
|
176
|
+
id: HelpId;
|
|
177
|
+
prompt: string;
|
|
178
|
+
resolved: boolean;
|
|
179
|
+
}
|
|
180
|
+
export interface DecidedAction {
|
|
181
|
+
action: TypedAction;
|
|
182
|
+
decision: DecisionOutput;
|
|
183
|
+
snapshotId: SnapshotId;
|
|
184
|
+
stepId: StepId;
|
|
185
|
+
/** Provenance of the target that justified this action. */
|
|
186
|
+
targetProvenance?: ProvenanceClass;
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=decision.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decision.d.ts","sourceRoot":"","sources":["../src/decision.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAIzD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,IAAI,GAAG,QAAQ,GAAG,WAAW,CAAC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,aAAa,CAA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W,eAAe;IAC9B,EAAE,EAAE,UAAU,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,UAAU,GAAG,QAAQ,GAAG,UAAU,CAAC;IAC3C,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,WAAW,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,YAAY,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,UAAU,EAAE,eAAe,CAAC;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,cAAc,CAAC;IACzB,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,gBAAgB,CAAC,EAAE,eAAe,CAAC;CACpC"}
|
package/dist/decision.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decision provider contracts (PRD §15, §16, §44).
|
|
3
|
+
*
|
|
4
|
+
* Provider roles are separate: the fast path decides *whether and where*,
|
|
5
|
+
* the text helper decides *what text*, the planner handles long horizons and
|
|
6
|
+
* recovery, vision is a fallback for visual-only surfaces.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=decision.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decision.js","sourceRoot":"","sources":["../src/decision.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Failure classification (PRD §28.1) and the runtime error type.
|
|
3
|
+
*
|
|
4
|
+
* Failure classes are produced by deterministic code (executor, verifier,
|
|
5
|
+
* provider adapters) and drive the recovery ladder. A model may observe them,
|
|
6
|
+
* but never invents them.
|
|
7
|
+
*/
|
|
8
|
+
export declare const FAILURE_CLASSES: readonly ["STALE_DECISION", "DETACHED_TARGET", "TARGET_COVERED", "CLICK_INTERCEPTED", "TARGET_INVALID", "NAVIGATION_TIMEOUT", "PAGE_MUTATED", "UNEXPECTED_DIALOG", "UNEXPECTED_TAB", "DOWNLOAD_FAILED", "UPLOAD_FAILED", "FILL_MISMATCH", "SELECT_MISMATCH", "NETWORK_FAILURE", "PROVIDER_FAILURE", "DECISION_INVALID", "POLICY_DENIED", "APPROVAL_DENIED", "SECRET_TARGET", "BUDGET_EXHAUSTED", "NO_PROGRESS", "LOOP_DETECTED", "UNKNOWN_EFFECT", "EXECUTION_FAILED", "TARGET_NOT_FOUND", "HUMAN_HELP_TIMEOUT", "CANCELLED", "INTERNAL"];
|
|
9
|
+
export type FailureClass = (typeof FAILURE_CLASSES)[number];
|
|
10
|
+
export declare const isRecoverable: (c: FailureClass) => boolean;
|
|
11
|
+
export interface RuntimeErrorOptions {
|
|
12
|
+
detail?: string;
|
|
13
|
+
retryable?: boolean;
|
|
14
|
+
/** Deterministic evidence collected at the failure site. */
|
|
15
|
+
evidence?: Record<string, unknown>;
|
|
16
|
+
cause?: unknown;
|
|
17
|
+
/** True when the action may have executed despite the failure (PRD §29). */
|
|
18
|
+
unknownEffect?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare class RuntimeError extends Error {
|
|
21
|
+
readonly code: FailureClass;
|
|
22
|
+
readonly detail: string | undefined;
|
|
23
|
+
readonly retryable: boolean;
|
|
24
|
+
readonly evidence: Record<string, unknown>;
|
|
25
|
+
readonly unknownEffect: boolean;
|
|
26
|
+
constructor(code: FailureClass, message: string, opts?: RuntimeErrorOptions);
|
|
27
|
+
toJSON(): Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
export declare const asRuntimeError: (err: unknown) => RuntimeError;
|
|
30
|
+
/** Plain object form used in traces and events. */
|
|
31
|
+
export interface FailureRecord {
|
|
32
|
+
code: FailureClass;
|
|
33
|
+
message: string;
|
|
34
|
+
detail?: string;
|
|
35
|
+
retryable: boolean;
|
|
36
|
+
unknownEffect: boolean;
|
|
37
|
+
evidence?: Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
export declare const failureRecord: (err: RuntimeError) => FailureRecord;
|
|
40
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,eAAe,2gBA6BlB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AA4B5D,eAAO,MAAM,aAAa,GAAI,GAAG,YAAY,KAAG,OAA6B,CAAC;AAE9E,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,4EAA4E;IAC5E,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3C,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;gBAEpB,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,mBAAwB;IAU/E,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAUlC;AAED,eAAO,MAAM,cAAc,GAAI,KAAK,OAAO,KAAG,YAI7C,CAAC;AAEF,mDAAmD;AACnD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,eAAO,MAAM,aAAa,GAAI,KAAK,YAAY,KAAG,aAOhD,CAAC"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Failure classification (PRD §28.1) and the runtime error type.
|
|
3
|
+
*
|
|
4
|
+
* Failure classes are produced by deterministic code (executor, verifier,
|
|
5
|
+
* provider adapters) and drive the recovery ladder. A model may observe them,
|
|
6
|
+
* but never invents them.
|
|
7
|
+
*/
|
|
8
|
+
export const FAILURE_CLASSES = [
|
|
9
|
+
"STALE_DECISION",
|
|
10
|
+
"DETACHED_TARGET",
|
|
11
|
+
"TARGET_COVERED",
|
|
12
|
+
"CLICK_INTERCEPTED",
|
|
13
|
+
"TARGET_INVALID",
|
|
14
|
+
"NAVIGATION_TIMEOUT",
|
|
15
|
+
"PAGE_MUTATED",
|
|
16
|
+
"UNEXPECTED_DIALOG",
|
|
17
|
+
"UNEXPECTED_TAB",
|
|
18
|
+
"DOWNLOAD_FAILED",
|
|
19
|
+
"UPLOAD_FAILED",
|
|
20
|
+
"FILL_MISMATCH",
|
|
21
|
+
"SELECT_MISMATCH",
|
|
22
|
+
"NETWORK_FAILURE",
|
|
23
|
+
"PROVIDER_FAILURE",
|
|
24
|
+
"DECISION_INVALID",
|
|
25
|
+
"POLICY_DENIED",
|
|
26
|
+
"APPROVAL_DENIED",
|
|
27
|
+
"SECRET_TARGET",
|
|
28
|
+
"BUDGET_EXHAUSTED",
|
|
29
|
+
"NO_PROGRESS",
|
|
30
|
+
"LOOP_DETECTED",
|
|
31
|
+
"UNKNOWN_EFFECT",
|
|
32
|
+
"EXECUTION_FAILED",
|
|
33
|
+
"TARGET_NOT_FOUND",
|
|
34
|
+
"HUMAN_HELP_TIMEOUT",
|
|
35
|
+
"CANCELLED",
|
|
36
|
+
"INTERNAL",
|
|
37
|
+
];
|
|
38
|
+
/** Failures where re-observing and re-deciding is safe. */
|
|
39
|
+
const RECOVERABLE = new Set([
|
|
40
|
+
"STALE_DECISION",
|
|
41
|
+
"DETACHED_TARGET",
|
|
42
|
+
"TARGET_COVERED",
|
|
43
|
+
"CLICK_INTERCEPTED",
|
|
44
|
+
"TARGET_INVALID",
|
|
45
|
+
"NAVIGATION_TIMEOUT",
|
|
46
|
+
"PAGE_MUTATED",
|
|
47
|
+
"UNEXPECTED_DIALOG",
|
|
48
|
+
"UNEXPECTED_TAB",
|
|
49
|
+
"DOWNLOAD_FAILED",
|
|
50
|
+
"UPLOAD_FAILED",
|
|
51
|
+
"FILL_MISMATCH",
|
|
52
|
+
"SELECT_MISMATCH",
|
|
53
|
+
"NETWORK_FAILURE",
|
|
54
|
+
"PROVIDER_FAILURE",
|
|
55
|
+
"DECISION_INVALID",
|
|
56
|
+
"TARGET_NOT_FOUND",
|
|
57
|
+
"NO_PROGRESS",
|
|
58
|
+
"LOOP_DETECTED",
|
|
59
|
+
"UNKNOWN_EFFECT",
|
|
60
|
+
"EXECUTION_FAILED",
|
|
61
|
+
"INTERNAL",
|
|
62
|
+
]);
|
|
63
|
+
export const isRecoverable = (c) => RECOVERABLE.has(c);
|
|
64
|
+
export class RuntimeError extends Error {
|
|
65
|
+
code;
|
|
66
|
+
detail;
|
|
67
|
+
retryable;
|
|
68
|
+
evidence;
|
|
69
|
+
unknownEffect;
|
|
70
|
+
constructor(code, message, opts = {}) {
|
|
71
|
+
super(message, opts.cause !== undefined ? { cause: opts.cause } : undefined);
|
|
72
|
+
this.name = "RuntimeError";
|
|
73
|
+
this.code = code;
|
|
74
|
+
this.detail = opts.detail;
|
|
75
|
+
this.retryable = opts.retryable ?? isRecoverable(code);
|
|
76
|
+
this.evidence = opts.evidence ?? {};
|
|
77
|
+
this.unknownEffect = opts.unknownEffect ?? false;
|
|
78
|
+
}
|
|
79
|
+
toJSON() {
|
|
80
|
+
return {
|
|
81
|
+
code: this.code,
|
|
82
|
+
message: this.message,
|
|
83
|
+
detail: this.detail,
|
|
84
|
+
retryable: this.retryable,
|
|
85
|
+
unknownEffect: this.unknownEffect,
|
|
86
|
+
evidence: this.evidence,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
export const asRuntimeError = (err) => {
|
|
91
|
+
if (err instanceof RuntimeError)
|
|
92
|
+
return err;
|
|
93
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
94
|
+
return new RuntimeError("INTERNAL", `unexpected error: ${message}`, { cause: err });
|
|
95
|
+
};
|
|
96
|
+
export const failureRecord = (err) => ({
|
|
97
|
+
code: err.code,
|
|
98
|
+
message: err.message,
|
|
99
|
+
...(err.detail !== undefined ? { detail: err.detail } : {}),
|
|
100
|
+
retryable: err.retryable,
|
|
101
|
+
unknownEffect: err.unknownEffect,
|
|
102
|
+
...(Object.keys(err.evidence).length > 0 ? { evidence: err.evidence } : {}),
|
|
103
|
+
});
|
|
104
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,gBAAgB;IAChB,iBAAiB;IACjB,gBAAgB;IAChB,mBAAmB;IACnB,gBAAgB;IAChB,oBAAoB;IACpB,cAAc;IACd,mBAAmB;IACnB,gBAAgB;IAChB,iBAAiB;IACjB,eAAe;IACf,eAAe;IACf,iBAAiB;IACjB,iBAAiB;IACjB,kBAAkB;IAClB,kBAAkB;IAClB,eAAe;IACf,iBAAiB;IACjB,eAAe;IACf,kBAAkB;IAClB,aAAa;IACb,eAAe;IACf,gBAAgB;IAChB,kBAAkB;IAClB,kBAAkB;IAClB,oBAAoB;IACpB,WAAW;IACX,UAAU;CACF,CAAC;AAIX,2DAA2D;AAC3D,MAAM,WAAW,GAA8B,IAAI,GAAG,CAAe;IACnE,gBAAgB;IAChB,iBAAiB;IACjB,gBAAgB;IAChB,mBAAmB;IACnB,gBAAgB;IAChB,oBAAoB;IACpB,cAAc;IACd,mBAAmB;IACnB,gBAAgB;IAChB,iBAAiB;IACjB,eAAe;IACf,eAAe;IACf,iBAAiB;IACjB,iBAAiB;IACjB,kBAAkB;IAClB,kBAAkB;IAClB,kBAAkB;IAClB,aAAa;IACb,eAAe;IACf,gBAAgB;IAChB,kBAAkB;IAClB,UAAU;CACX,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAe,EAAW,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAY9E,MAAM,OAAO,YAAa,SAAQ,KAAK;IAC5B,IAAI,CAAe;IACnB,MAAM,CAAqB;IAC3B,SAAS,CAAU;IACnB,QAAQ,CAA0B;IAClC,aAAa,CAAU;IAEhC,YAAY,IAAkB,EAAE,OAAe,E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AAiB,EAAiB,EAAE,CAAC,CAAC;IAClE,IAAI,EAAE,GAAG,CAAC,IAAI;IACd,OAAO,EAAE,GAAG,CAAC,OAAO;IACpB,GAAG,CAAC,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3D,SAAS,EAAE,GAAG,CAAC,SAAS;IACxB,aAAa,EAAE,GAAG,CAAC,aAAa;IAChC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;CAC5E,CAAC,CAAC"}
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event-sourced run log (PRD §41, §42).
|
|
3
|
+
*
|
|
4
|
+
* The log is append-only. Every decision, policy outcome, execution result,
|
|
5
|
+
* verification and recovery step is recorded with enough context to replay and
|
|
6
|
+
* debug a run locally.
|
|
7
|
+
*/
|
|
8
|
+
import type { ArtifactSummary, DecisionOutput, PlannerOutput, StepSummary } from "./decision.ts";
|
|
9
|
+
import type { FailureRecord } from "./errors.ts";
|
|
10
|
+
import type { ArtifactId, HelpId, RunId, SessionId, SnapshotId, StepId, TabId } from "./ids.ts";
|
|
11
|
+
import type { Usage } from "./budget.ts";
|
|
12
|
+
import type { ApprovalResolution, PermissionMode, PolicyOutcome } from "./policy.ts";
|
|
13
|
+
import type { VerificationResult } from "./verification.ts";
|
|
14
|
+
import type { RunStatus } from "./task.ts";
|
|
15
|
+
export interface RunEventPayloads {
|
|
16
|
+
RUN_CREATED: {
|
|
17
|
+
goal: string;
|
|
18
|
+
startUrl?: string;
|
|
19
|
+
backend: string;
|
|
20
|
+
};
|
|
21
|
+
SESSION_CREATED: {
|
|
22
|
+
sessionId: SessionId;
|
|
23
|
+
backend: string;
|
|
24
|
+
};
|
|
25
|
+
SESSION_CONNECTED: {
|
|
26
|
+
sessionId: SessionId;
|
|
27
|
+
agentWindowId?: number;
|
|
28
|
+
};
|
|
29
|
+
RUN_STARTED: {
|
|
30
|
+
runId: RunId;
|
|
31
|
+
};
|
|
32
|
+
PLANNER_REQUESTED: {
|
|
33
|
+
reason: string;
|
|
34
|
+
step: number;
|
|
35
|
+
};
|
|
36
|
+
PLANNER_RECEIVED: {
|
|
37
|
+
plan: PlannerOutput;
|
|
38
|
+
subgoalCount: number;
|
|
39
|
+
};
|
|
40
|
+
SUBGOAL_STARTED: {
|
|
41
|
+
subgoal: string;
|
|
42
|
+
index: number;
|
|
43
|
+
};
|
|
44
|
+
SUBGOAL_COMPLETED: {
|
|
45
|
+
subgoal: string;
|
|
46
|
+
index: number;
|
|
47
|
+
};
|
|
48
|
+
PLAN_EXHAUSTED: {
|
|
49
|
+
reason: string;
|
|
50
|
+
};
|
|
51
|
+
SNAPSHOT_CAPTURED: {
|
|
52
|
+
snapshotId: SnapshotId;
|
|
53
|
+
generation: number;
|
|
54
|
+
url: string;
|
|
55
|
+
title: string;
|
|
56
|
+
nodeCount: number;
|
|
57
|
+
fingerprint: string;
|
|
58
|
+
latencyMs: number;
|
|
59
|
+
blocking?: string;
|
|
60
|
+
};
|
|
61
|
+
ACTION_SPACE_BUILT: {
|
|
62
|
+
operations: string[];
|
|
63
|
+
headSizes: Record<string, number>;
|
|
64
|
+
quarantined: number;
|
|
65
|
+
};
|
|
66
|
+
DECISION_REQUESTED: {
|
|
67
|
+
step: number;
|
|
68
|
+
provider: string;
|
|
69
|
+
operations: number;
|
|
70
|
+
targets: number;
|
|
71
|
+
};
|
|
72
|
+
DECISION_RECEIVED: {
|
|
73
|
+
decision: DecisionOutput;
|
|
74
|
+
usage?: Usage;
|
|
75
|
+
};
|
|
76
|
+
DECISION_INVALID: {
|
|
77
|
+
reason: string;
|
|
78
|
+
raw?: unknown;
|
|
79
|
+
};
|
|
80
|
+
FALLBACK_STARTED: {
|
|
81
|
+
reason: string;
|
|
82
|
+
from: string;
|
|
83
|
+
to: string;
|
|
84
|
+
step: number;
|
|
85
|
+
};
|
|
86
|
+
FALLBACK_COMPLETED: {
|
|
87
|
+
provider: string;
|
|
88
|
+
ok: boolean;
|
|
89
|
+
detail?: string;
|
|
90
|
+
};
|
|
91
|
+
POLICY_ALLOWED: {
|
|
92
|
+
outcome: PolicyOutcome;
|
|
93
|
+
summary: string;
|
|
94
|
+
};
|
|
95
|
+
POLICY_DENIED: {
|
|
96
|
+
outcome: PolicyOutcome;
|
|
97
|
+
summary: string;
|
|
98
|
+
};
|
|
99
|
+
APPROVAL_REQUESTED: {
|
|
100
|
+
approvalId: string;
|
|
101
|
+
summary: string;
|
|
102
|
+
risk: string;
|
|
103
|
+
url: string;
|
|
104
|
+
};
|
|
105
|
+
APPROVAL_RESOLVED: {
|
|
106
|
+
approvalId: string;
|
|
107
|
+
resolution: ApprovalResolution;
|
|
108
|
+
};
|
|
109
|
+
FRESHNESS_CHECK: {
|
|
110
|
+
snapshotId: SnapshotId;
|
|
111
|
+
ok: boolean;
|
|
112
|
+
reason?: string;
|
|
113
|
+
};
|
|
114
|
+
TARGET_VALIDATED: {
|
|
115
|
+
nodeId: number;
|
|
116
|
+
ok: boolean;
|
|
117
|
+
reason?: string;
|
|
118
|
+
};
|
|
119
|
+
ACTION_EXECUTED: {
|
|
120
|
+
stepId: StepId;
|
|
121
|
+
action: string;
|
|
122
|
+
latencyMs: number;
|
|
123
|
+
detail?: string;
|
|
124
|
+
unknownEffect?: boolean;
|
|
125
|
+
};
|
|
126
|
+
ACTION_FAILED: {
|
|
127
|
+
stepId: StepId;
|
|
128
|
+
failure: FailureRecord;
|
|
129
|
+
action: string;
|
|
130
|
+
};
|
|
131
|
+
ACTION_VERIFIED: {
|
|
132
|
+
stepId: StepId;
|
|
133
|
+
verification: VerificationResult;
|
|
134
|
+
};
|
|
135
|
+
ACTION_NO_EFFECT: {
|
|
136
|
+
stepId: StepId;
|
|
137
|
+
action: string;
|
|
138
|
+
reason: string;
|
|
139
|
+
};
|
|
140
|
+
STEP_COMPLETED: {
|
|
141
|
+
step: number;
|
|
142
|
+
summary: StepSummary;
|
|
143
|
+
};
|
|
144
|
+
LOOP_DETECTED: {
|
|
145
|
+
kind: "same_action" | "cycle" | "no_progress";
|
|
146
|
+
detail: string;
|
|
147
|
+
step: number;
|
|
148
|
+
};
|
|
149
|
+
RECOVERY_STARTED: {
|
|
150
|
+
failure: FailureRecord;
|
|
151
|
+
attempt: number;
|
|
152
|
+
strategy: string;
|
|
153
|
+
};
|
|
154
|
+
RECOVERY_COMPLETED: {
|
|
155
|
+
ok: boolean;
|
|
156
|
+
strategy: string;
|
|
157
|
+
detail?: string;
|
|
158
|
+
};
|
|
159
|
+
RECOVERY_ESCALATED: {
|
|
160
|
+
to: string;
|
|
161
|
+
reason: string;
|
|
162
|
+
};
|
|
163
|
+
DOWNLOAD_STARTED: {
|
|
164
|
+
url?: string;
|
|
165
|
+
suggestedName?: string;
|
|
166
|
+
nodeId?: number;
|
|
167
|
+
};
|
|
168
|
+
DOWNLOAD_COMPLETED: {
|
|
169
|
+
artifact: ArtifactSummary;
|
|
170
|
+
path: string;
|
|
171
|
+
latencyMs: number;
|
|
172
|
+
};
|
|
173
|
+
DOWNLOAD_FAILED: {
|
|
174
|
+
reason: string;
|
|
175
|
+
failure?: FailureRecord;
|
|
176
|
+
};
|
|
177
|
+
UPLOAD_STARTED: {
|
|
178
|
+
artifactId: ArtifactId;
|
|
179
|
+
nodeId: number;
|
|
180
|
+
mechanism: string;
|
|
181
|
+
};
|
|
182
|
+
UPLOAD_COMPLETED: {
|
|
183
|
+
artifactId: ArtifactId;
|
|
184
|
+
evidence: string;
|
|
185
|
+
};
|
|
186
|
+
UPLOAD_FAILED: {
|
|
187
|
+
artifactId: ArtifactId;
|
|
188
|
+
reason: string;
|
|
189
|
+
};
|
|
190
|
+
ARTIFACT_CREATED: {
|
|
191
|
+
artifact: ArtifactSummary;
|
|
192
|
+
};
|
|
193
|
+
ARTIFACT_VERIFIED: {
|
|
194
|
+
artifactId: ArtifactId;
|
|
195
|
+
detail: string;
|
|
196
|
+
};
|
|
197
|
+
TABS_CHANGED: {
|
|
198
|
+
tabs: {
|
|
199
|
+
id: TabId;
|
|
200
|
+
title: string;
|
|
201
|
+
url: string;
|
|
202
|
+
active: boolean;
|
|
203
|
+
ownership: string;
|
|
204
|
+
}[];
|
|
205
|
+
};
|
|
206
|
+
TAB_BORROWED: {
|
|
207
|
+
tabId: TabId;
|
|
208
|
+
approvedBy: string;
|
|
209
|
+
};
|
|
210
|
+
TAB_RETURNED: {
|
|
211
|
+
tabId: TabId;
|
|
212
|
+
windowId?: number;
|
|
213
|
+
index?: number;
|
|
214
|
+
};
|
|
215
|
+
BLOCKING_UI_DETECTED: {
|
|
216
|
+
kind: string;
|
|
217
|
+
title?: string;
|
|
218
|
+
text?: string;
|
|
219
|
+
};
|
|
220
|
+
DIALOG_HANDLED: {
|
|
221
|
+
kind: string;
|
|
222
|
+
resolution: string;
|
|
223
|
+
};
|
|
224
|
+
HUMAN_HELP_REQUESTED: {
|
|
225
|
+
helpId: HelpId;
|
|
226
|
+
prompt: string;
|
|
227
|
+
kind?: string;
|
|
228
|
+
timeoutMs?: number;
|
|
229
|
+
};
|
|
230
|
+
HUMAN_HELP_PROGRESS: {
|
|
231
|
+
helpId: HelpId;
|
|
232
|
+
note: string;
|
|
233
|
+
};
|
|
234
|
+
HUMAN_HELP_COMPLETED: {
|
|
235
|
+
helpId: HelpId;
|
|
236
|
+
criteriaMet: boolean;
|
|
237
|
+
detail?: string;
|
|
238
|
+
};
|
|
239
|
+
HUMAN_HELP_TIMEOUT: {
|
|
240
|
+
helpId: HelpId;
|
|
241
|
+
};
|
|
242
|
+
TAKEOVER_STARTED: {
|
|
243
|
+
reason: string;
|
|
244
|
+
prompt?: string;
|
|
245
|
+
};
|
|
246
|
+
TAKEOVER_ENDED: {
|
|
247
|
+
resumedBy: string;
|
|
248
|
+
};
|
|
249
|
+
SECRET_BLOCKED: {
|
|
250
|
+
reason: string;
|
|
251
|
+
summary: string;
|
|
252
|
+
};
|
|
253
|
+
BUDGET_WARNING: {
|
|
254
|
+
reason: string;
|
|
255
|
+
snapshot: Record<string, number>;
|
|
256
|
+
};
|
|
257
|
+
BUDGET_EXHAUSTED: {
|
|
258
|
+
reason: string;
|
|
259
|
+
};
|
|
260
|
+
VERIFICATION_RESULT: {
|
|
261
|
+
verification: VerificationResult;
|
|
262
|
+
stepId?: StepId;
|
|
263
|
+
};
|
|
264
|
+
RUN_COMPLETED: {
|
|
265
|
+
result: Record<string, unknown>;
|
|
266
|
+
status: RunStatus;
|
|
267
|
+
};
|
|
268
|
+
RUN_FAILED: {
|
|
269
|
+
failure: FailureRecord;
|
|
270
|
+
status: RunStatus;
|
|
271
|
+
};
|
|
272
|
+
RUN_CANCELLED: {
|
|
273
|
+
reason: string;
|
|
274
|
+
};
|
|
275
|
+
RUN_PAUSED: {
|
|
276
|
+
reason?: string;
|
|
277
|
+
};
|
|
278
|
+
RUN_RESUMED: {
|
|
279
|
+
reason?: string;
|
|
280
|
+
};
|
|
281
|
+
SESSION_STOPPING: {
|
|
282
|
+
reason: string;
|
|
283
|
+
};
|
|
284
|
+
SESSION_STOPPED: {
|
|
285
|
+
cleanup: Record<string, unknown>;
|
|
286
|
+
};
|
|
287
|
+
SCREENSHOT_CAPTURED: {
|
|
288
|
+
path: string;
|
|
289
|
+
reason: string;
|
|
290
|
+
captureId?: string;
|
|
291
|
+
};
|
|
292
|
+
PROVIDER_USAGE: {
|
|
293
|
+
role: string;
|
|
294
|
+
usage: Usage;
|
|
295
|
+
};
|
|
296
|
+
NOTE: {
|
|
297
|
+
text: string;
|
|
298
|
+
level?: "info" | "warn" | "error";
|
|
299
|
+
};
|
|
300
|
+
ERROR: {
|
|
301
|
+
failure: FailureRecord;
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
export type RunEventType = keyof RunEventPayloads;
|
|
305
|
+
export type RunEvent = {
|
|
306
|
+
[K in RunEventType]: {
|
|
307
|
+
seq: number;
|
|
308
|
+
ts: number;
|
|
309
|
+
runId: RunId;
|
|
310
|
+
sessionId?: SessionId;
|
|
311
|
+
stepId?: StepId;
|
|
312
|
+
type: K;
|
|
313
|
+
payload: RunEventPayloads[K];
|
|
314
|
+
};
|
|
315
|
+
}[RunEventType];
|
|
316
|
+
export type RunEventOf<K extends RunEventType> = Extract<RunEvent, {
|
|
317
|
+
type: K;
|
|
318
|
+
}>;
|
|
319
|
+
export declare const RUN_EVENT_TYPES: readonly ["RUN_CREATED", "SESSION_CREATED", "SESSION_CONNECTED", "RUN_STARTED", "PLANNER_REQUESTED", "PLANNER_RECEIVED", "SUBGOAL_STARTED", "SUBGOAL_COMPLETED", "PLAN_EXHAUSTED", "SNAPSHOT_CAPTURED", "ACTION_SPACE_BUILT", "DECISION_REQUESTED", "DECISION_RECEIVED", "DECISION_INVALID", "FALLBACK_STARTED", "FALLBACK_COMPLETED", "POLICY_ALLOWED", "POLICY_DENIED", "APPROVAL_REQUESTED", "APPROVAL_RESOLVED", "FRESHNESS_CHECK", "TARGET_VALIDATED", "ACTION_EXECUTED", "ACTION_FAILED", "ACTION_VERIFIED", "ACTION_NO_EFFECT", "STEP_COMPLETED", "LOOP_DETECTED", "RECOVERY_STARTED", "RECOVERY_COMPLETED", "RECOVERY_ESCALATED", "DOWNLOAD_STARTED", "DOWNLOAD_COMPLETED", "DOWNLOAD_FAILED", "UPLOAD_STARTED", "UPLOAD_COMPLETED", "UPLOAD_FAILED", "ARTIFACT_CREATED", "ARTIFACT_VERIFIED", "TABS_CHANGED", "TAB_BORROWED", "TAB_RETURNED", "BLOCKING_UI_DETECTED", "DIALOG_HANDLED", "HUMAN_HELP_REQUESTED", "HUMAN_HELP_PROGRESS", "HUMAN_HELP_COMPLETED", "HUMAN_HELP_TIMEOUT", "TAKEOVER_STARTED", "TAKEOVER_ENDED", "SECRET_BLOCKED", "BUDGET_WARNING", "BUDGET_EXHAUSTED", "VERIFICATION_RESULT", "RUN_COMPLETED", "RUN_FAILED", "RUN_CANCELLED", "RUN_PAUSED", "RUN_RESUMED", "SESSION_STOPPING", "SESSION_STOPPED", "SCREENSHOT_CAPTURED", "PROVIDER_USAGE", "NOTE", "ERROR"];
|
|
320
|
+
export interface EventSink {
|
|
321
|
+
emit<K extends RunEventType>(type: K, payload: RunEventPayloads[K], meta?: {
|
|
322
|
+
stepId?: StepId;
|
|
323
|
+
}): void;
|
|
324
|
+
}
|
|
325
|
+
export type PermissionModeSummary = PermissionMode;
|
|
326
|
+
//# sourceMappingURL=events.d.ts.map
|