@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MLola
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# @mlola/browser-protocol
|
|
2
|
+
|
|
3
|
+
Typed contracts for the [MLola Browser Runtime](https://mlola.com/browser-runtime):
|
|
4
|
+
observations, typed actions, decision providers, verification, policy, budgets
|
|
5
|
+
and the event log.
|
|
6
|
+
|
|
7
|
+
No browser, no model, no filesystem — this is the stable vocabulary the rest of
|
|
8
|
+
the runtime is built from.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { OPERATIONS, headForOperation, type BrowserSnapshot } from "@mlola/browser-protocol";
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Full documentation: <https://mlola.com/browser-runtime>
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed action protocol (PRD §14, §25, §33).
|
|
3
|
+
*
|
|
4
|
+
* Models choose among runtime-owned operations and runtime-owned targets. Model
|
|
5
|
+
* output never becomes a selector, an XPath, a raw coordinate, JavaScript, a
|
|
6
|
+
* shell command or a browser protocol method.
|
|
7
|
+
*/
|
|
8
|
+
import type { ArtifactId, ElementIndex, NodeId, TabId } from "./ids.ts";
|
|
9
|
+
import type { ProvenanceClass } from "./provenance.ts";
|
|
10
|
+
export declare const OPERATIONS: readonly ["CLICK", "TYPE_TEXT", "SELECT", "SCROLL_UP", "SCROLL_DOWN", "WAIT", "BACK", "FORWARD", "OPEN_TAB", "SWITCH_TAB", "CLOSE_TAB", "DOWNLOAD", "UPLOAD", "PRESS", "ACCEPT_DIALOG", "DISMISS_DIALOG", "DONE", "BLOCKED", "ASK_USER"];
|
|
11
|
+
export type OperationId = (typeof OPERATIONS)[number];
|
|
12
|
+
/** Operations offered to the decision model in the normal loop. */
|
|
13
|
+
export declare const DECISION_OPERATIONS: readonly OperationId[];
|
|
14
|
+
/** Operations the runtime executes but never offers to the model by default. */
|
|
15
|
+
export declare const INTERNAL_OPERATIONS: readonly OperationId[];
|
|
16
|
+
export declare const TARGET_HEADS: readonly ["click_target", "type_text_target", "select_target", "switch_tab_target", "open_tab_target", "download_target", "upload_target"];
|
|
17
|
+
export type TargetHeadId = (typeof TARGET_HEADS)[number];
|
|
18
|
+
export interface TargetCandidate {
|
|
19
|
+
/** Model-facing key: element index ("2"), option ("4:1") or tab id ("t2"). */
|
|
20
|
+
key: string;
|
|
21
|
+
/** One-line description shown to the decision model. */
|
|
22
|
+
label: string;
|
|
23
|
+
nodeIndex?: ElementIndex;
|
|
24
|
+
nodeId?: NodeId;
|
|
25
|
+
optionIndex?: number;
|
|
26
|
+
optionValue?: string;
|
|
27
|
+
tabId?: TabId;
|
|
28
|
+
url?: string;
|
|
29
|
+
artifactId?: ArtifactId;
|
|
30
|
+
provenance: ProvenanceClass;
|
|
31
|
+
/** Excluded from the offered space; kept for audit. */
|
|
32
|
+
quarantined?: boolean;
|
|
33
|
+
quarantineReason?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface ActionSpace {
|
|
36
|
+
/** Operation head alternatives. */
|
|
37
|
+
operations: OperationId[];
|
|
38
|
+
/** Speculative target heads; runtime uses only the selected operation's head. */
|
|
39
|
+
heads: Partial<Record<TargetHeadId, TargetCandidate[]>>;
|
|
40
|
+
/** Which head each offered operation must use. */
|
|
41
|
+
headForOperation: Partial<Record<OperationId, TargetHeadId>>;
|
|
42
|
+
/** Targets removed by deterministic safety filters, kept for observability. */
|
|
43
|
+
quarantined: TargetCandidate[];
|
|
44
|
+
}
|
|
45
|
+
export declare const headForOperation: (op: OperationId) => TargetHeadId | undefined;
|
|
46
|
+
/** Runtime-owned element reference. Bound to a snapshot generation. */
|
|
47
|
+
export interface ElementRef {
|
|
48
|
+
index: ElementIndex;
|
|
49
|
+
nodeId: NodeId;
|
|
50
|
+
pageToken: string;
|
|
51
|
+
generation: number;
|
|
52
|
+
labelHash: string;
|
|
53
|
+
}
|
|
54
|
+
export type PressKey = "Enter" | "Escape" | "Tab" | "ArrowDown" | "ArrowUp" | "ArrowLeft" | "ArrowRight" | "Home" | "End" | "PageDown" | "PageUp" | "Backspace" | "Delete";
|
|
55
|
+
export type TypedAction = {
|
|
56
|
+
op: "CLICK";
|
|
57
|
+
ref: ElementRef;
|
|
58
|
+
clickCount?: 1 | 2;
|
|
59
|
+
} | {
|
|
60
|
+
op: "TYPE_TEXT";
|
|
61
|
+
ref: ElementRef;
|
|
62
|
+
/** Text is produced by the runtime (literal reuse or validated generation). */
|
|
63
|
+
text: string;
|
|
64
|
+
mode: "fill" | "keyboard";
|
|
65
|
+
submitAfter?: boolean;
|
|
66
|
+
} | {
|
|
67
|
+
op: "SELECT";
|
|
68
|
+
ref: ElementRef;
|
|
69
|
+
/** Copied from the observation, re-validated before execution. */
|
|
70
|
+
option: {
|
|
71
|
+
index: number;
|
|
72
|
+
label: string;
|
|
73
|
+
value: string;
|
|
74
|
+
};
|
|
75
|
+
} | {
|
|
76
|
+
op: "SCROLL_UP";
|
|
77
|
+
ref?: ElementRef;
|
|
78
|
+
amount: "page" | "half" | "small";
|
|
79
|
+
} | {
|
|
80
|
+
op: "SCROLL_DOWN";
|
|
81
|
+
ref?: ElementRef;
|
|
82
|
+
amount: "page" | "half" | "small";
|
|
83
|
+
} | {
|
|
84
|
+
op: "WAIT";
|
|
85
|
+
ms: number;
|
|
86
|
+
} | {
|
|
87
|
+
op: "BACK";
|
|
88
|
+
} | {
|
|
89
|
+
op: "FORWARD";
|
|
90
|
+
} | {
|
|
91
|
+
op: "OPEN_TAB";
|
|
92
|
+
url: string;
|
|
93
|
+
sourceRef?: ElementRef;
|
|
94
|
+
} | {
|
|
95
|
+
op: "SWITCH_TAB";
|
|
96
|
+
tabId: TabId;
|
|
97
|
+
} | {
|
|
98
|
+
op: "CLOSE_TAB";
|
|
99
|
+
tabId: TabId;
|
|
100
|
+
} | {
|
|
101
|
+
op: "DOWNLOAD";
|
|
102
|
+
ref: ElementRef;
|
|
103
|
+
} | {
|
|
104
|
+
op: "UPLOAD";
|
|
105
|
+
ref: ElementRef;
|
|
106
|
+
artifactId: ArtifactId;
|
|
107
|
+
mechanism: "file_input" | "file_chooser" | "drop_zone";
|
|
108
|
+
} | {
|
|
109
|
+
op: "PRESS";
|
|
110
|
+
key: PressKey;
|
|
111
|
+
ref?: ElementRef;
|
|
112
|
+
} | {
|
|
113
|
+
op: "ACCEPT_DIALOG";
|
|
114
|
+
} | {
|
|
115
|
+
op: "DISMISS_DIALOG";
|
|
116
|
+
};
|
|
117
|
+
export declare const operationOf: (action: TypedAction) => OperationId;
|
|
118
|
+
export declare const mayHaveUnknownEffect: (action: TypedAction) => boolean;
|
|
119
|
+
/** Deterministic signature used for loop detection (PRD §30). */
|
|
120
|
+
export declare const actionSignature: (action: TypedAction) => string;
|
|
121
|
+
export declare const describeAction: (action: TypedAction) => string;
|
|
122
|
+
/** Actions that are a claim about task state rather than a browser interaction. */
|
|
123
|
+
export declare const isTerminalClaim: (op: OperationId) => boolean;
|
|
124
|
+
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,eAAO,MAAM,UAAU,0OAoBb,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtD,mEAAmE;AACnE,eAAO,MAAM,mBAAmB,EAAE,SAAS,WAAW,EAkBrD,CAAC;AAEF,gFAAgF;AAChF,eAAO,MAAM,mBAAmB,EAAE,SAAS,WAAW,EAA2B,CAAC;AAElF,eAAO,MAAM,YAAY,4IAQf,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,C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C,KAAK,EAAE,KAAK,CAAA;CAAE,GACjC;IAAE,EAAE,EAAE,UAAU,CAAC;IAAC,GAAG,EAAE,UAAU,CAAA;CAAE,GACnC;IACE,EAAE,EAAE,QAAQ,CAAC;IACb,GAAG,EAAE,UAAU,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;IACvB,SAAS,EAAE,YAAY,GAAG,cAAc,GAAG,WAAW,CAAC;CACxD,GACD;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,QAAQ,CAAC;IAAC,GAAG,CAAC,EAAE,UAAU,CAAA;CAAE,GAChD;IAAE,EAAE,EAAE,eAAe,CAAA;CAAE,GACvB;IAAE,EAAE,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAE7B,eAAO,MAAM,WAAW,GAAI,QAAQ,WAAW,KAAG,WAAwB,CAAC;AAK3E,eAAO,MAAM,oBAAoB,GAAI,QAAQ,WAAW,KAAG,OAA4C,CAAC;AAExG,iEAAiE;AACjE,eAAO,MAAM,eAAe,GAAI,QAAQ,WAAW,KAAG,MA0BrD,CAAC;AAUF,eAAO,MAAM,cAAc,GAAI,QAAQ,WAAW,KAAG,MA+BpD,CAAC;AAIF,mFAAmF;AACnF,eAAO,MAAM,eAAe,GAAI,IAAI,WAAW,KAAG,OAAiE,CAAC"}
|
package/dist/actions.js
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed action protocol (PRD §14, §25, §33).
|
|
3
|
+
*
|
|
4
|
+
* Models choose among runtime-owned operations and runtime-owned targets. Model
|
|
5
|
+
* output never becomes a selector, an XPath, a raw coordinate, JavaScript, a
|
|
6
|
+
* shell command or a browser protocol method.
|
|
7
|
+
*/
|
|
8
|
+
export const OPERATIONS = [
|
|
9
|
+
"CLICK",
|
|
10
|
+
"TYPE_TEXT",
|
|
11
|
+
"SELECT",
|
|
12
|
+
"SCROLL_UP",
|
|
13
|
+
"SCROLL_DOWN",
|
|
14
|
+
"WAIT",
|
|
15
|
+
"BACK",
|
|
16
|
+
"FORWARD",
|
|
17
|
+
"OPEN_TAB",
|
|
18
|
+
"SWITCH_TAB",
|
|
19
|
+
"CLOSE_TAB",
|
|
20
|
+
"DOWNLOAD",
|
|
21
|
+
"UPLOAD",
|
|
22
|
+
"PRESS",
|
|
23
|
+
"ACCEPT_DIALOG",
|
|
24
|
+
"DISMISS_DIALOG",
|
|
25
|
+
"DONE",
|
|
26
|
+
"BLOCKED",
|
|
27
|
+
"ASK_USER",
|
|
28
|
+
];
|
|
29
|
+
/** Operations offered to the decision model in the normal loop. */
|
|
30
|
+
export const DECISION_OPERATIONS = [
|
|
31
|
+
"CLICK",
|
|
32
|
+
"TYPE_TEXT",
|
|
33
|
+
"SELECT",
|
|
34
|
+
"SCROLL_UP",
|
|
35
|
+
"SCROLL_DOWN",
|
|
36
|
+
"WAIT",
|
|
37
|
+
"BACK",
|
|
38
|
+
"FORWARD",
|
|
39
|
+
"OPEN_TAB",
|
|
40
|
+
"SWITCH_TAB",
|
|
41
|
+
"DOWNLOAD",
|
|
42
|
+
"UPLOAD",
|
|
43
|
+
"ACCEPT_DIALOG",
|
|
44
|
+
"DISMISS_DIALOG",
|
|
45
|
+
"DONE",
|
|
46
|
+
"BLOCKED",
|
|
47
|
+
"ASK_USER",
|
|
48
|
+
];
|
|
49
|
+
/** Operations the runtime executes but never offers to the model by default. */
|
|
50
|
+
export const INTERNAL_OPERATIONS = ["CLOSE_TAB", "PRESS"];
|
|
51
|
+
export const TARGET_HEADS = [
|
|
52
|
+
"click_target",
|
|
53
|
+
"type_text_target",
|
|
54
|
+
"select_target",
|
|
55
|
+
"switch_tab_target",
|
|
56
|
+
"open_tab_target",
|
|
57
|
+
"download_target",
|
|
58
|
+
"upload_target",
|
|
59
|
+
];
|
|
60
|
+
export const headForOperation = (op) => {
|
|
61
|
+
switch (op) {
|
|
62
|
+
case "CLICK":
|
|
63
|
+
return "click_target";
|
|
64
|
+
case "TYPE_TEXT":
|
|
65
|
+
return "type_text_target";
|
|
66
|
+
case "SELECT":
|
|
67
|
+
return "select_target";
|
|
68
|
+
case "SWITCH_TAB":
|
|
69
|
+
return "switch_tab_target";
|
|
70
|
+
case "OPEN_TAB":
|
|
71
|
+
return "open_tab_target";
|
|
72
|
+
case "DOWNLOAD":
|
|
73
|
+
return "download_target";
|
|
74
|
+
case "UPLOAD":
|
|
75
|
+
return "upload_target";
|
|
76
|
+
default:
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
export const operationOf = (action) => action.op;
|
|
81
|
+
/** Actions with possibly harmful side effects if duplicated (PRD §29). */
|
|
82
|
+
const UNKNOWN_EFFECT_OPS = new Set(["CLICK", "UPLOAD", "DOWNLOAD"]);
|
|
83
|
+
export const mayHaveUnknownEffect = (action) => UNKNOWN_EFFECT_OPS.has(action.op);
|
|
84
|
+
/** Deterministic signature used for loop detection (PRD §30). */
|
|
85
|
+
export const actionSignature = (action) => {
|
|
86
|
+
const base = action.op;
|
|
87
|
+
switch (action.op) {
|
|
88
|
+
case "CLICK":
|
|
89
|
+
return `${base}:${action.ref.nodeId}`;
|
|
90
|
+
case "TYPE_TEXT":
|
|
91
|
+
return `${base}:${action.ref.nodeId}:${action.text.length}`;
|
|
92
|
+
case "SELECT":
|
|
93
|
+
return `${base}:${action.ref.nodeId}:${action.option.index}`;
|
|
94
|
+
case "SCROLL_UP":
|
|
95
|
+
case "SCROLL_DOWN":
|
|
96
|
+
return `${base}:${action.ref?.nodeId ?? "page"}:${action.amount}`;
|
|
97
|
+
case "SWITCH_TAB":
|
|
98
|
+
case "CLOSE_TAB":
|
|
99
|
+
return `${base}:${action.tabId}`;
|
|
100
|
+
case "OPEN_TAB":
|
|
101
|
+
return `${base}:${safeHost(action.url)}`;
|
|
102
|
+
case "DOWNLOAD":
|
|
103
|
+
return `${base}:${action.ref.nodeId}`;
|
|
104
|
+
case "UPLOAD":
|
|
105
|
+
return `${base}:${action.ref.nodeId}:${action.artifactId}`;
|
|
106
|
+
case "PRESS":
|
|
107
|
+
return `${base}:${action.key}`;
|
|
108
|
+
default:
|
|
109
|
+
return base;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const safeHost = (url) => {
|
|
113
|
+
try {
|
|
114
|
+
return new URL(url).host;
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return "invalid";
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
export const describeAction = (action) => {
|
|
121
|
+
switch (action.op) {
|
|
122
|
+
case "CLICK":
|
|
123
|
+
return `CLICK [${action.ref.index}]`;
|
|
124
|
+
case "TYPE_TEXT":
|
|
125
|
+
return `${action.mode === "fill" ? "TYPE" : "KEYBOARD"} [${action.ref.index}] "${truncate(action.text, 60)}"`;
|
|
126
|
+
case "SELECT":
|
|
127
|
+
return `SELECT [${action.ref.index}] -> ${truncate(action.option.label, 40)}`;
|
|
128
|
+
case "SCROLL_UP":
|
|
129
|
+
case "SCROLL_DOWN":
|
|
130
|
+
return `${action.op} ${action.amount}`;
|
|
131
|
+
case "WAIT":
|
|
132
|
+
return `WAIT ${action.ms}ms`;
|
|
133
|
+
case "OPEN_TAB":
|
|
134
|
+
return `OPEN_TAB ${truncate(action.url, 80)}`;
|
|
135
|
+
case "SWITCH_TAB":
|
|
136
|
+
case "CLOSE_TAB":
|
|
137
|
+
return `${action.op} ${action.tabId}`;
|
|
138
|
+
case "DOWNLOAD":
|
|
139
|
+
return `DOWNLOAD [${action.ref.index}]`;
|
|
140
|
+
case "UPLOAD":
|
|
141
|
+
return `UPLOAD ${action.artifactId} -> [${action.ref.index}]`;
|
|
142
|
+
case "PRESS":
|
|
143
|
+
return `PRESS ${action.key}`;
|
|
144
|
+
case "ACCEPT_DIALOG":
|
|
145
|
+
return "ACCEPT_DIALOG";
|
|
146
|
+
case "DISMISS_DIALOG":
|
|
147
|
+
return "DISMISS_DIALOG";
|
|
148
|
+
default:
|
|
149
|
+
return action.op;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
const truncate = (s, n) => (s.length <= n ? s : `${s.slice(0, n - 1)}…`);
|
|
153
|
+
/** Actions that are a claim about task state rather than a browser interaction. */
|
|
154
|
+
export const isTerminalClaim = (op) => op === "DONE" || op === "BLOCKED" || op === "ASK_USER";
|
|
155
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,OAAO;IACP,WAAW;IACX,QAAQ;IACR,WAAW;IACX,aAAa;IACb,MAAM;IACN,MAAM;IACN,SAAS;IACT,UAAU;IACV,YAAY;IACZ,WAAW;IACX,UAAU;IACV,QAAQ;IACR,OAAO;IACP,eAAe;IACf,gBAAgB;IAChB,MAAM;IACN,SAAS;IACT,UAAU;CACF,CAAC;AAIX,mEAAmE;AACnE,MAAM,CAAC,MAAM,mBAAmB,GAA2B;IACzD,OAAO;IACP,WAAW;IACX,QAAQ;IACR,WAAW;IACX,aAAa;IACb,MAAM;IACN,MAAM;IACN,SAAS;IACT,UAAU;IACV,YAAY;IACZ,UAAU;IACV,QAAQ;IACR,eAAe;IACf,gBAAgB;IAChB,MAAM;IACN,SAAS;IACT,UAAU;CACX,CAAC;AAEF,gFAAgF;AAChF,MAAM,CAAC,MAAM,mBAAmB,GAA2B,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AAElF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,cAAc;IACd,kBAAkB;IAClB,eAAe;IACf,mBAAmB;IACnB,iBAAiB;IACjB,iBAAiB;IACjB,eAAe;CACP,CAAC;AAiCX,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAAe,EAA4B,EAAE;IAC5E,QAAQ,EAAE,EAAE,CAAC;QACX,KAAK,OAAO;YACV,OAAO,cAAc,CAAC;QACxB,KAAK,WAAW;YACd,OAA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,EAAE,KAAK,MAAM,IAAI,EAAE,KAAK,SAAS,IAAI,EAAE,KAAK,UAAU,CAAC"}
|
package/dist/budget.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Budgets and usage accounting (PRD §45, §55).
|
|
3
|
+
*/
|
|
4
|
+
export interface Budgets {
|
|
5
|
+
maxSteps: number;
|
|
6
|
+
maxDecisionCalls: number;
|
|
7
|
+
maxPlannerCalls: number;
|
|
8
|
+
maxTextCalls: number;
|
|
9
|
+
maxVisionCalls: number;
|
|
10
|
+
maxCostUsd: number;
|
|
11
|
+
maxDurationMs: number;
|
|
12
|
+
maxRecoveryAttemptsPerStep: number;
|
|
13
|
+
maxRecoveryAttemptsTotal: number;
|
|
14
|
+
maxConsecutiveNoProgress: number;
|
|
15
|
+
maxHumanHelpRequests: number;
|
|
16
|
+
}
|
|
17
|
+
export declare const DEFAULT_BUDGETS: Budgets;
|
|
18
|
+
export type ProviderRole = "decision" | "planner" | "text" | "vision";
|
|
19
|
+
export interface Usage {
|
|
20
|
+
provider: string;
|
|
21
|
+
model?: string;
|
|
22
|
+
calls?: number;
|
|
23
|
+
inputTokens?: number;
|
|
24
|
+
outputTokens?: number;
|
|
25
|
+
costUsd?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface BudgetSnapshot {
|
|
28
|
+
steps: number;
|
|
29
|
+
calls: Record<ProviderRole, number>;
|
|
30
|
+
costUsd: number;
|
|
31
|
+
durationMs: number;
|
|
32
|
+
recoveryAttempts: number;
|
|
33
|
+
humanHelpRequests: number;
|
|
34
|
+
}
|
|
35
|
+
export type BudgetVerdict = {
|
|
36
|
+
kind: "continue";
|
|
37
|
+
} | {
|
|
38
|
+
kind: "degrade";
|
|
39
|
+
reason: string;
|
|
40
|
+
} | {
|
|
41
|
+
kind: "ask_user";
|
|
42
|
+
reason: string;
|
|
43
|
+
} | {
|
|
44
|
+
kind: "fail";
|
|
45
|
+
reason: string;
|
|
46
|
+
code: "BUDGET_EXHAUSTED";
|
|
47
|
+
};
|
|
48
|
+
export interface CostRates {
|
|
49
|
+
/** USD per million input tokens. */
|
|
50
|
+
inputPerMTok?: number;
|
|
51
|
+
/** USD per million output tokens. */
|
|
52
|
+
outputPerMTok?: number;
|
|
53
|
+
/** USD per call, when a provider prices per call. */
|
|
54
|
+
perCall?: number;
|
|
55
|
+
}
|
|
56
|
+
export declare const estimateCost: (usage: Usage, rates: CostRates | undefined) => number;
|
|
57
|
+
//# sourceMappingURL=budget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget.d.ts","sourceRoot":"","sources":["../src/budget.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,OAAO;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,0BAA0B,EAAE,MAAM,CAAC;IACnC,wBAAwB,EAAE,MAAM,CAAC;IACjC,wBAAwB,EAAE,MAAM,CAAC;IACjC,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,eAAO,MAAM,eAAe,EAAE,OAY7B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEtE,MAAM,WAAW,KAAK;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GACpB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAE/D,MAAM,WAAW,SAAS;IACxB,oCAAoC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qCAAqC;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,YAAY,GAAI,OAAO,KAAK,EAAE,OAAO,SAAS,GAAG,SAAS,KAAG,MAMzE,CAAC"}
|
package/dist/budget.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Budgets and usage accounting (PRD §45, §55).
|
|
3
|
+
*/
|
|
4
|
+
export const DEFAULT_BUDGETS = {
|
|
5
|
+
maxSteps: 80,
|
|
6
|
+
maxDecisionCalls: 160,
|
|
7
|
+
maxPlannerCalls: 12,
|
|
8
|
+
maxTextCalls: 24,
|
|
9
|
+
maxVisionCalls: 8,
|
|
10
|
+
maxCostUsd: 2.0,
|
|
11
|
+
maxDurationMs: 20 * 60 * 1000,
|
|
12
|
+
maxRecoveryAttemptsPerStep: 3,
|
|
13
|
+
maxRecoveryAttemptsTotal: 12,
|
|
14
|
+
maxConsecutiveNoProgress: 3,
|
|
15
|
+
maxHumanHelpRequests: 4,
|
|
16
|
+
};
|
|
17
|
+
export const estimateCost = (usage, rates) => {
|
|
18
|
+
if (!rates)
|
|
19
|
+
return usage.costUsd ?? 0;
|
|
20
|
+
const calls = usage.calls ?? 1;
|
|
21
|
+
const inCost = ((usage.inputTokens ?? 0) / 1_000_000) * (rates.inputPerMTok ?? 0);
|
|
22
|
+
const outCost = ((usage.outputTokens ?? 0) / 1_000_000) * (rates.outputPerMTok ?? 0);
|
|
23
|
+
return (usage.costUsd ?? 0) + inCost + outCost + (rates.perCall ?? 0) * calls;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=budget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget.js","sourceRoot":"","sources":["../src/budget.ts"],"names":[],"mappings":"AAAA;;GAEG;AAgBH,MAAM,CAAC,MAAM,eAAe,GAAY;IACtC,QAAQ,EAAE,EAAE;IACZ,gBAAgB,EAAE,GAAG;IACrB,eAAe,EAAE,EAAE;IACnB,YAAY,EAAE,EAAE;IAChB,cAAc,EAAE,CAAC;IACjB,UAAU,EAAE,GAAG;IACf,aAAa,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;IAC7B,0BAA0B,EAAE,CAAC;IAC7B,wBAAwB,EAAE,EAAE;IAC5B,wBAAwB,EAAE,CAAC;IAC3B,oBAAoB,EAAE,CAAC;CACxB,CAAC;AAqCF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAY,EAAE,KAA4B,EAAU,EAAE;IACjF,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;IACtC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;IAC/B,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC;IAClF,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,YAAY,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,CAAC,CAAC;IACrF,OAAO,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC,GAAG,MAAM,GAAG,OAAO,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC;AAChF,CAAC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protocol versioning and capability negotiation (PRD §47, §48).
|
|
3
|
+
*
|
|
4
|
+
* Daemon ↔ SDK ↔ browser backend must agree explicitly. Unsupported features
|
|
5
|
+
* fail loudly; they are never silently emulated with unsafe substitutes.
|
|
6
|
+
*/
|
|
7
|
+
export declare const PROTOCOL_VERSION: "1.0";
|
|
8
|
+
export declare const BACKEND_CAPABILITIES: readonly ["observe", "click", "type", "select", "scroll", "press", "history", "tabs", "open_tab", "close_tab", "borrow", "return_tab", "human_help", "download", "upload", "console", "network", "screenshot", "canvas", "dialog_handling", "clipboard"];
|
|
9
|
+
export type BackendCapability = (typeof BACKEND_CAPABILITIES)[number];
|
|
10
|
+
export interface CapabilitySet {
|
|
11
|
+
protocol: typeof PROTOCOL_VERSION;
|
|
12
|
+
browser: Partial<Record<BackendCapability, boolean>>;
|
|
13
|
+
/** Session/client level capabilities (daemon ↔ client). */
|
|
14
|
+
runtime: {
|
|
15
|
+
borrow_tabs: boolean;
|
|
16
|
+
request_help: boolean;
|
|
17
|
+
downloads: boolean;
|
|
18
|
+
uploads: boolean;
|
|
19
|
+
canvas_click: boolean;
|
|
20
|
+
approvals: boolean;
|
|
21
|
+
human_takeover: boolean;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export declare const RUNTIME_CAPABILITIES: CapabilitySet["runtime"];
|
|
25
|
+
export declare class UnsupportedCapabilityError extends Error {
|
|
26
|
+
readonly capability: BackendCapability | string;
|
|
27
|
+
constructor(capability: BackendCapability | string, detail?: string);
|
|
28
|
+
}
|
|
29
|
+
export declare const supports: (caps: Partial<Record<BackendCapability, boolean>>, capability: BackendCapability) => boolean;
|
|
30
|
+
export declare const requireCapability: (caps: Partial<Record<BackendCapability, boolean>>, capability: BackendCapability) => void;
|
|
31
|
+
//# sourceMappingURL=capabilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,gBAAgB,EAAG,KAAc,CAAC;AAE/C,eAAO,MAAM,oBAAoB,0PAsBvB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtE,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,OAAO,gBAAgB,CAAC;IAClC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,CAAC;IACrD,2DAA2D;IAC3D,OAAO,EAAE;QACP,WAAW,EAAE,OAAO,CAAC;QACrB,YAAY,EAAE,OAAO,CAAC;QACtB,SAAS,EAAE,OAAO,CAAC;QACnB,OAAO,EAAE,OAAO,CAAC;QACjB,YAAY,EAAE,OAAO,CAAC;QACtB,SAAS,EAAE,OAAO,CAAC;QACnB,cAAc,EAAE,OAAO,CAAC;KACzB,CAAC;CACH;AAED,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC,SAAS,CAQzD,CAAC;AAEF,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,QAAQ,CAAC,UAAU,EAAE,iBAAiB,GAAG,MAAM,CAAC;gBACpC,UAAU,EAAE,iBAAiB,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAQpE;AAED,eAAO,MAAM,QAAQ,GACnB,MAAM,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,EACjD,YAAY,iBAAiB,KAC5B,OAAoC,CAAC;AAExC,eAAO,MAAM,iBAAiB,GAC5B,MAAM,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,EACjD,YAAY,iBAAiB,KAC5B,IAEF,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protocol versioning and capability negotiation (PRD §47, §48).
|
|
3
|
+
*
|
|
4
|
+
* Daemon ↔ SDK ↔ browser backend must agree explicitly. Unsupported features
|
|
5
|
+
* fail loudly; they are never silently emulated with unsafe substitutes.
|
|
6
|
+
*/
|
|
7
|
+
export const PROTOCOL_VERSION = "1.0";
|
|
8
|
+
export const BACKEND_CAPABILITIES = [
|
|
9
|
+
"observe",
|
|
10
|
+
"click",
|
|
11
|
+
"type",
|
|
12
|
+
"select",
|
|
13
|
+
"scroll",
|
|
14
|
+
"press",
|
|
15
|
+
"history",
|
|
16
|
+
"tabs",
|
|
17
|
+
"open_tab",
|
|
18
|
+
"close_tab",
|
|
19
|
+
"borrow",
|
|
20
|
+
"return_tab",
|
|
21
|
+
"human_help",
|
|
22
|
+
"download",
|
|
23
|
+
"upload",
|
|
24
|
+
"console",
|
|
25
|
+
"network",
|
|
26
|
+
"screenshot",
|
|
27
|
+
"canvas",
|
|
28
|
+
"dialog_handling",
|
|
29
|
+
"clipboard",
|
|
30
|
+
];
|
|
31
|
+
export const RUNTIME_CAPABILITIES = {
|
|
32
|
+
borrow_tabs: true,
|
|
33
|
+
request_help: true,
|
|
34
|
+
downloads: true,
|
|
35
|
+
uploads: true,
|
|
36
|
+
canvas_click: false,
|
|
37
|
+
approvals: true,
|
|
38
|
+
human_takeover: true,
|
|
39
|
+
};
|
|
40
|
+
export class UnsupportedCapabilityError extends Error {
|
|
41
|
+
capability;
|
|
42
|
+
constructor(capability, detail) {
|
|
43
|
+
super(`unsupported capability "${capability}"${detail ? `: ${detail}` : ""}. ` +
|
|
44
|
+
`The selected backend does not advertise it; refusing to emulate unsafely.`);
|
|
45
|
+
this.name = "UnsupportedCapabilityError";
|
|
46
|
+
this.capability = capability;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export const supports = (caps, capability) => caps[capability] === true;
|
|
50
|
+
export const requireCapability = (caps, capability) => {
|
|
51
|
+
if (!supports(caps, capability))
|
|
52
|
+
throw new UnsupportedCapabilityError(capability);
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=capabilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAc,CAAC;AAE/C,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,SAAS;IACT,OAAO;IACP,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,SAAS;IACT,MAAM;IACN,UAAU;IACV,WAAW;IACX,QAAQ;IACR,YAAY;IACZ,YAAY;IACZ,UAAU;IACV,QAAQ;IACR,SAAS;IACT,SAAS;IACT,YAAY;IACZ,QAAQ;IACR,iBAAiB;IACjB,WAAW;CACH,CAAC;AAmBX,MAAM,CAAC,MAAM,oBAAoB,GAA6B;IAC5D,WAAW,EAAE,IAAI;IACjB,YAAY,EAAE,IAAI;IAClB,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;IACb,YAAY,EAAE,KAAK;IACnB,SAAS,EAAE,IAAI;IACf,cAAc,EAAE,IAAI;CACrB,CAAC;AAEF,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IAC1C,UAAU,CAA6B;IAChD,YAAY,UAAsC,EAAE,MAAe;QACjE,KAAK,CACH,2BAA2B,UAAU,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI;YACtE,2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