@letta-ai/letta-code 0.31.7 → 0.31.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mcp-client.js +8 -8
- package/dist/mcp-client.js.map +3 -3
- package/dist/memory-constraints.js +18 -0
- package/dist/memory-constraints.js.map +10 -0
- package/dist/types/agent/memory-constraints.d.ts +1 -1
- package/dist/types/agent/memory-constraints.d.ts.map +1 -1
- package/dist/types/agent/subagents/index.d.ts +0 -2
- package/dist/types/agent/subagents/index.d.ts.map +1 -1
- package/dist/types/agent/subagents/subagent-model.d.ts +20 -0
- package/dist/types/agent/subagents/subagent-model.d.ts.map +1 -1
- package/dist/types/{utils → agent}/system-prompt-size.d.ts +8 -4
- package/dist/types/agent/system-prompt-size.d.ts.map +1 -0
- package/dist/types/cli/helpers/system-prompt-warning.d.ts +2 -1
- package/dist/types/cli/helpers/system-prompt-warning.d.ts.map +1 -1
- package/dist/types/mcp-client.d.ts +6 -0
- package/dist/types/mcp-client.d.ts.map +1 -1
- package/dist/types/memory-constraints.d.ts +15 -0
- package/dist/types/memory-constraints.d.ts.map +1 -0
- package/dist/types/permissions/shell-analysis.d.ts.map +1 -1
- package/dist/types/providers/openai-codex-provider.d.ts +2 -10
- package/dist/types/providers/openai-codex-provider.d.ts.map +1 -1
- package/dist/types/tools/impl/task.d.ts +20 -2
- package/dist/types/tools/impl/task.d.ts.map +1 -1
- package/dist/types/types/chatgpt-oauth.d.ts +9 -0
- package/dist/types/types/chatgpt-oauth.d.ts.map +1 -0
- package/dist/types/types/protocol_v2.d.ts +3 -3
- package/dist/types/types/protocol_v2.d.ts.map +1 -1
- package/letta.js +29364 -28397
- package/package.json +11 -1
- package/scripts/source-file-size-baseline.json +2 -1
- package/skills/browser-use/SKILL.md +363 -0
- package/skills/browser-use/references/recording.md +60 -0
- package/skills/self-configuration/SKILL.md +3 -1
- package/dist/types/utils/system-prompt-size.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@letta-ai/letta-code",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.8",
|
|
4
4
|
"description": "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "bun@1.3.10",
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
"dist/app-server-client.cjs.map",
|
|
23
23
|
"dist/memory-confinement.js",
|
|
24
24
|
"dist/memory-confinement.js.map",
|
|
25
|
+
"dist/memory-constraints.js",
|
|
26
|
+
"dist/memory-constraints.js.map",
|
|
25
27
|
"dist/mcp-client.js",
|
|
26
28
|
"dist/mcp-client.js.map",
|
|
27
29
|
"dist/agent-presets.js",
|
|
@@ -58,6 +60,11 @@
|
|
|
58
60
|
"import": "./dist/memory-confinement.js",
|
|
59
61
|
"default": "./dist/memory-confinement.js"
|
|
60
62
|
},
|
|
63
|
+
"./memory-constraints": {
|
|
64
|
+
"types": "./dist/types/memory-constraints.d.ts",
|
|
65
|
+
"import": "./dist/memory-constraints.js",
|
|
66
|
+
"default": "./dist/memory-constraints.js"
|
|
67
|
+
},
|
|
61
68
|
"./mcp-client": {
|
|
62
69
|
"types": "./dist/types/mcp-client.d.ts",
|
|
63
70
|
"import": "./dist/mcp-client.js",
|
|
@@ -211,6 +218,9 @@
|
|
|
211
218
|
"memory-confinement": [
|
|
212
219
|
"./dist/types/memory-confinement.d.ts"
|
|
213
220
|
],
|
|
221
|
+
"memory-constraints": [
|
|
222
|
+
"./dist/types/memory-constraints.d.ts"
|
|
223
|
+
],
|
|
214
224
|
"mcp-client": [
|
|
215
225
|
"./dist/types/mcp-client.d.ts"
|
|
216
226
|
],
|
|
@@ -43,7 +43,8 @@
|
|
|
43
43
|
"src/websocket/listener/commands/memory.ts": 1114,
|
|
44
44
|
"src/websocket/listener/file-commands.ts": 1053,
|
|
45
45
|
"src/websocket/listener/lifecycle.ts": 1048,
|
|
46
|
-
"src/websocket/listener/protocol-inbound.ts":
|
|
46
|
+
"src/websocket/listener/protocol-inbound.ts": 2207,
|
|
47
|
+
|
|
47
48
|
"src/websocket/listener/protocol-outbound.ts": 1047,
|
|
48
49
|
"src/websocket/listener/turn.ts": 1058
|
|
49
50
|
}
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: browser-use
|
|
3
|
+
description: Control a real browser to navigate pages, click, type, fill forms, inspect rendered UI, take screenshots, or record video. Load only when the user asks to open or automate a browser, interact with or test rendered page UI, scrape a site that needs browser execution, or capture a browser screenshot or video. Do not load for backend logs, traces, API or stream events, source-code inspection, or plain HTTP or web research that does not require a browser.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Browser Use with CDP
|
|
7
|
+
|
|
8
|
+
Drive the browser through its native Chrome DevTools Protocol over the
|
|
9
|
+
remote-debugging WebSocket. This works with zero dependencies: launch the
|
|
10
|
+
browser with `--remote-debugging-port`, then talk JSON over `fetch` and the
|
|
11
|
+
built-in `WebSocket` global (available in Bun and Node ≥ 22 — no `ws` package).
|
|
12
|
+
|
|
13
|
+
If the project already has Playwright or Puppeteer installed, using it is
|
|
14
|
+
usually simpler — reach for raw CDP when no automation library is available,
|
|
15
|
+
when protocol-level control is needed, or when recording a deterministic
|
|
16
|
+
visual demo.
|
|
17
|
+
|
|
18
|
+
Protocol reference: https://chromedevtools.github.io/devtools-protocol/.
|
|
19
|
+
The running browser's exact schema is at `http://127.0.0.1:<port>/json/protocol`;
|
|
20
|
+
tip-of-tree docs can differ from the installed version.
|
|
21
|
+
|
|
22
|
+
## Managed cloud sandbox default: visible browser
|
|
23
|
+
|
|
24
|
+
When running in a cloud sandbox, default every browser task to the visible
|
|
25
|
+
managed desktop, even when the user did not explicitly ask to watch. Most
|
|
26
|
+
browser tasks exist because plain HTTP is not enough; a headless browser is
|
|
27
|
+
more likely to trigger bot protection and gives the user no way to observe or
|
|
28
|
+
take over. This matters especially for clicking or typing, forms, sign-in,
|
|
29
|
+
checkout/payment, CAPTCHAs or bot protection, and user handoff.
|
|
30
|
+
|
|
31
|
+
For the first managed-sandbox browser window, use the skill's launcher instead
|
|
32
|
+
of assembling Chrome, DISPLAY, or Xvfb commands yourself:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
/root/.letta/cloud-skills/browser-use/scripts/open-visible-browser.sh 'https://example.com'
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
It starts the managed desktop and launches Chrome through the persistent Cua
|
|
39
|
+
Driver with its required root flag. Then load `computer-use` for visible
|
|
40
|
+
interaction. If protocol-level control is necessary, use Cua Driver's explicit
|
|
41
|
+
`browser_prepare` flow after binding the exact visible window; do not pass
|
|
42
|
+
remote-debugging flags through `launch_app`. The launcher exits zero only
|
|
43
|
+
after Cua Driver reports an on-screen browser window. If it exits nonzero, stop
|
|
44
|
+
and report the launch failure instead of claiming the browser opened.
|
|
45
|
+
|
|
46
|
+
When the user asks to review, watch, or take over, leave that browser window
|
|
47
|
+
open after the task. Do not kill or close it before replying.
|
|
48
|
+
|
|
49
|
+
1. Run `start-letta-desktop` and use its exit status as the result. Warnings
|
|
50
|
+
from optional services do not mean startup failed when the command exits 0.
|
|
51
|
+
If it exits nonzero, stop and report that the managed desktop is
|
|
52
|
+
unavailable. Never create another Xvfb, VNC server, or private display: the
|
|
53
|
+
Computer viewer only shows the managed desktop.
|
|
54
|
+
2. Load `computer-use`, inspect the managed desktop, and use Cua Driver to
|
|
55
|
+
operate an existing Chrome window or launch Chrome there. When launching,
|
|
56
|
+
round-trip Chrome's `launch_path` from `cua-driver call list_apps '{}'
|
|
57
|
+
instead of rebuilding it; the managed launch path carries required flags.
|
|
58
|
+
For forms, sign-in, checkout, CAPTCHA, and bot-protected pages, keep using
|
|
59
|
+
Cua Driver so the interaction remains visible and available for user
|
|
60
|
+
takeover.
|
|
61
|
+
3. Use CDP only when protocol-level inspection or deterministic automation is
|
|
62
|
+
needed. Bind the exact visible browser window with Cua Driver, then use its
|
|
63
|
+
explicit `browser_prepare` flow. Do not pass remote-debugging flags
|
|
64
|
+
through `launch_app`. Include `--no-sandbox` when running Chrome as
|
|
65
|
+
root. Do not add `--headless` or override `DISPLAY`.
|
|
66
|
+
4. Use headless mode only for work the user explicitly wants in the background
|
|
67
|
+
and that cannot require interaction or handoff, such as read-only scraping,
|
|
68
|
+
CI, or screenshot/PDF generation.
|
|
69
|
+
5. Verify the result through the managed desktop window (Cua Driver window
|
|
70
|
+
state or screenshot), not only through DOM output or a screenshot from a
|
|
71
|
+
separate process.
|
|
72
|
+
|
|
73
|
+
A headless page does not satisfy a request to open or reopen a site in the
|
|
74
|
+
user-visible browser.
|
|
75
|
+
|
|
76
|
+
## Workflow
|
|
77
|
+
|
|
78
|
+
1. Find a Chromium-based browser (below). If none exists, see "No Chrome installed".
|
|
79
|
+
2. In a managed cloud sandbox, follow the visible-browser default above.
|
|
80
|
+
Otherwise, launch with a dedicated profile and remote debugging. Never
|
|
81
|
+
attach to the user's normal profile unless explicitly asked.
|
|
82
|
+
3. Discover targets via `/json/list`; pick the `"page"` target by URL or title.
|
|
83
|
+
4. Connect to its `webSocketDebuggerUrl` and enable only the domains you need
|
|
84
|
+
(usually `Page`, `Runtime`, `DOM`, `Input`; add `Network`, `Log` when debugging).
|
|
85
|
+
5. Inspect before acting: find elements by accessible name, label, text, role,
|
|
86
|
+
stable ID, or placeholder — not generated classes or child indexes.
|
|
87
|
+
6. Act through `Input.*` for user-like interactions; use `Runtime.evaluate` for
|
|
88
|
+
inspection, coordinate math, and setup with no meaningful user interaction.
|
|
89
|
+
7. Wait on observable state, never fixed sleeps alone.
|
|
90
|
+
8. Verify the result (DOM state, URL, screenshot, console/network events).
|
|
91
|
+
9. Clean up temporary background work: stop screencasts and close the
|
|
92
|
+
WebSocket. Kill a browser you launched only when the user did not ask to
|
|
93
|
+
review, watch, or take over the visible window.
|
|
94
|
+
|
|
95
|
+
## Finding the browser
|
|
96
|
+
|
|
97
|
+
Any Chromium-based browser supports CDP (Chrome, Chromium, Edge, Brave). Probe
|
|
98
|
+
in order:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# macOS
|
|
102
|
+
for c in "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \
|
|
103
|
+
"/Applications/Chromium.app/Contents/MacOS/Chromium" \
|
|
104
|
+
"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge" \
|
|
105
|
+
"/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"; do
|
|
106
|
+
[ -x "$c" ] && { echo "$c"; break; }
|
|
107
|
+
done
|
|
108
|
+
|
|
109
|
+
# Linux
|
|
110
|
+
for c in google-chrome google-chrome-stable chromium chromium-browser microsoft-edge brave-browser; do
|
|
111
|
+
command -v "$c" && break
|
|
112
|
+
done
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
On Windows, check `%ProgramFiles%\Google\Chrome\Application\chrome.exe`,
|
|
116
|
+
`%ProgramFiles(x86)%\...`, `%LocalAppData%\Google\Chrome\Application\chrome.exe`,
|
|
117
|
+
and the same patterns for `Microsoft\Edge`.
|
|
118
|
+
|
|
119
|
+
### No Chrome installed
|
|
120
|
+
|
|
121
|
+
Any browser found by the probe above works identically — use it. If truly no
|
|
122
|
+
Chromium-based browser exists, do not install or download one automatically.
|
|
123
|
+
Tell the user that browser use requires Chrome or another Chromium-based
|
|
124
|
+
browser and recommend either:
|
|
125
|
+
|
|
126
|
+
1. Install Chrome on the current computer, then retry the browser task.
|
|
127
|
+
2. Teleport the conversation back to its Cloud sandbox, where the managed
|
|
128
|
+
browser is already installed.
|
|
129
|
+
|
|
130
|
+
Wait for the user to choose. Do not silently replace the browser task with
|
|
131
|
+
plain HTTP or claim browser automation succeeded.
|
|
132
|
+
|
|
133
|
+
## Launching
|
|
134
|
+
|
|
135
|
+
Outside a managed cloud sandbox, use a disposable profile and a fixed port.
|
|
136
|
+
Chrome refuses to run as root without `--no-sandbox`, so add that flag when
|
|
137
|
+
`id -u` is 0:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
chrome_args=( \
|
|
141
|
+
--remote-debugging-port=9222 \
|
|
142
|
+
--user-data-dir=/tmp/cdp-profile \
|
|
143
|
+
--window-size=1440,900 \
|
|
144
|
+
--force-device-scale-factor=1 \
|
|
145
|
+
--no-first-run \
|
|
146
|
+
--no-default-browser-check \
|
|
147
|
+
)
|
|
148
|
+
[ "$(id -u)" -eq 0 ] && chrome_args+=(--no-sandbox)
|
|
149
|
+
"$CHROME" "${chrome_args[@]}" https://example.com
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Outside a managed cloud sandbox, add `--headless=new` only for explicitly
|
|
153
|
+
invisible work or when no display exists. In a managed cloud sandbox, follow
|
|
154
|
+
the visible-browser rule above and never replace its managed display with a
|
|
155
|
+
private one.
|
|
156
|
+
With `--remote-debugging-port=0`, read the chosen port from
|
|
157
|
+
`<user-data-dir>/DevToolsActivePort`. Launch in the background and poll
|
|
158
|
+
`http://127.0.0.1:9222/json/version` until it responds.
|
|
159
|
+
|
|
160
|
+
HTTP endpoints: `/json/version` (browser metadata + browser-level WebSocket URL),
|
|
161
|
+
`/json/list` (targets), `PUT /json/new?<url>` (open tab),
|
|
162
|
+
`/json/activate/<id>`, `/json/close/<id>`, `/json/protocol` (schema).
|
|
163
|
+
|
|
164
|
+
Attach to the **page** target for `Page`/`DOM`/`Runtime`/`Input` work; use the
|
|
165
|
+
**browser** target only for browser-wide commands (target control, downloads,
|
|
166
|
+
browser contexts).
|
|
167
|
+
|
|
168
|
+
## Minimal CDP client
|
|
169
|
+
|
|
170
|
+
CDP messages are JSON with monotonically increasing request ids. Run with `bun`:
|
|
171
|
+
|
|
172
|
+
```ts
|
|
173
|
+
const targets = await (await fetch("http://127.0.0.1:9222/json/list")).json();
|
|
174
|
+
const target = targets.find((t: any) => t.type === "page");
|
|
175
|
+
if (!target) throw new Error("No page target");
|
|
176
|
+
|
|
177
|
+
const ws = new WebSocket(target.webSocketDebuggerUrl);
|
|
178
|
+
await new Promise((resolve, reject) => {
|
|
179
|
+
ws.onopen = resolve;
|
|
180
|
+
ws.onerror = reject;
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
let nextId = 0;
|
|
184
|
+
const pending = new Map();
|
|
185
|
+
ws.onmessage = (event) => {
|
|
186
|
+
const msg = JSON.parse(String(event.data));
|
|
187
|
+
if (!msg.id) return handleEvent(msg); // Page.loadEventFired, Log.entryAdded, ...
|
|
188
|
+
const p = pending.get(msg.id);
|
|
189
|
+
if (!p) return;
|
|
190
|
+
pending.delete(msg.id);
|
|
191
|
+
msg.error ? p.reject(new Error(JSON.stringify(msg.error))) : p.resolve(msg.result);
|
|
192
|
+
};
|
|
193
|
+
ws.onclose = () => {
|
|
194
|
+
for (const p of pending.values()) p.reject(new Error("socket closed"));
|
|
195
|
+
pending.clear();
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
function send(method: string, params: object = {}): Promise<any> {
|
|
199
|
+
return new Promise((resolve, reject) => {
|
|
200
|
+
const id = ++nextId;
|
|
201
|
+
pending.set(id, { resolve, reject });
|
|
202
|
+
ws.send(JSON.stringify({ id, method, params }));
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
await send("Page.enable");
|
|
207
|
+
await send("Runtime.enable");
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Navigations destroy execution contexts and can invalidate in-flight
|
|
211
|
+
`Runtime.evaluate` calls; retry after observing the new document.
|
|
212
|
+
|
|
213
|
+
## Inspecting the page
|
|
214
|
+
|
|
215
|
+
Start with a concise UI inventory:
|
|
216
|
+
|
|
217
|
+
```ts
|
|
218
|
+
const result = await send("Runtime.evaluate", {
|
|
219
|
+
expression: `JSON.stringify({
|
|
220
|
+
buttons: [...document.querySelectorAll('button')].map((el) => ({
|
|
221
|
+
text: el.innerText.trim(), aria: el.getAttribute('aria-label'), title: el.title
|
|
222
|
+
})).filter((x) => x.text || x.aria || x.title),
|
|
223
|
+
inputs: [...document.querySelectorAll('input, textarea, [contenteditable=true]')].map((el) => ({
|
|
224
|
+
tag: el.tagName, type: el.type, placeholder: el.placeholder,
|
|
225
|
+
aria: el.getAttribute('aria-label'), value: el.value
|
|
226
|
+
}))
|
|
227
|
+
})`,
|
|
228
|
+
returnByValue: true,
|
|
229
|
+
});
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Use `awaitPromise: true` for async expressions and `userGesture: true` when the
|
|
233
|
+
page requires user activation. Treat `exceptionDetails` in the result as an
|
|
234
|
+
error even though the CDP command itself succeeded.
|
|
235
|
+
|
|
236
|
+
`document.querySelector` does not cross shadow boundaries — traverse open
|
|
237
|
+
shadow roots explicitly; for closed shadow roots or remote-object work use the
|
|
238
|
+
`DOM` domain (`DOM.getDocument`, `DOM.querySelector`, `DOM.getBoxModel`).
|
|
239
|
+
|
|
240
|
+
## Clicking and typing
|
|
241
|
+
|
|
242
|
+
Compute coordinates in CSS pixels immediately before acting, then send native
|
|
243
|
+
input events:
|
|
244
|
+
|
|
245
|
+
```ts
|
|
246
|
+
async function point(expr: string) {
|
|
247
|
+
const r = await send("Runtime.evaluate", {
|
|
248
|
+
expression: `(() => {
|
|
249
|
+
const el = ${expr};
|
|
250
|
+
if (!el) return null;
|
|
251
|
+
el.scrollIntoView({ block: 'center', inline: 'center' });
|
|
252
|
+
const b = el.getBoundingClientRect();
|
|
253
|
+
return { x: b.left + b.width / 2, y: b.top + b.height / 2 };
|
|
254
|
+
})()`,
|
|
255
|
+
returnByValue: true,
|
|
256
|
+
});
|
|
257
|
+
if (!r.result.value) throw new Error(`Element not found: ${expr}`);
|
|
258
|
+
return r.result.value;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
async function click(expr: string) {
|
|
262
|
+
const { x, y } = await point(expr);
|
|
263
|
+
await send("Input.dispatchMouseEvent", { type: "mouseMoved", x, y });
|
|
264
|
+
await send("Input.dispatchMouseEvent", { type: "mousePressed", x, y, button: "left", buttons: 1, clickCount: 1 });
|
|
265
|
+
await send("Input.dispatchMouseEvent", { type: "mouseReleased", x, y, button: "left", buttons: 0, clickCount: 1 });
|
|
266
|
+
}
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Focus an editable element (click it), then insert text:
|
|
270
|
+
|
|
271
|
+
```ts
|
|
272
|
+
await click(`document.querySelector('input[aria-label="Search"]')`);
|
|
273
|
+
await send("Input.insertText", { text: "search terms" });
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
Use `Input.insertText` for text and Unicode; use paired `Input.dispatchKeyEvent`
|
|
277
|
+
(`keyDown` + `keyUp` with `key`, `code`, `windowsVirtualKeyCode`) for Enter,
|
|
278
|
+
Escape, arrows, Tab, and shortcuts. Modifier bits: Alt=1, Ctrl=2, Meta=4, Shift=8.
|
|
279
|
+
|
|
280
|
+
Native `<select>` and framework-controlled inputs may need the prototype setter
|
|
281
|
+
plus bubbling events:
|
|
282
|
+
|
|
283
|
+
```ts
|
|
284
|
+
const setter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value").set;
|
|
285
|
+
setter.call(input, "new value");
|
|
286
|
+
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
287
|
+
input.dispatchEvent(new Event("change", { bubbles: true }));
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Prefer real `Input.*` events for the behavior being demonstrated or tested;
|
|
291
|
+
direct DOM mutation is fine for deterministic setup and inspection.
|
|
292
|
+
|
|
293
|
+
## Waiting reliably
|
|
294
|
+
|
|
295
|
+
A returned command does not mean the action completed. Poll the state that
|
|
296
|
+
proves completion:
|
|
297
|
+
|
|
298
|
+
```ts
|
|
299
|
+
async function waitFor(expr: string, timeoutMs = 30_000) {
|
|
300
|
+
const start = Date.now();
|
|
301
|
+
while (Date.now() - start < timeoutMs) {
|
|
302
|
+
const r = await send("Runtime.evaluate", { expression: `Boolean(${expr})`, returnByValue: true });
|
|
303
|
+
if (r.result.value) return;
|
|
304
|
+
await new Promise((res) => setTimeout(res, 250));
|
|
305
|
+
}
|
|
306
|
+
throw new Error(`Timed out waiting for ${expr}`);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
await waitFor(`document.body.innerText.includes('Saved')`);
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
For navigation, wait on `Page.loadEventFired` or a lifecycle `networkIdle`
|
|
313
|
+
event — but SPA route changes may emit neither, so prefer the UI condition
|
|
314
|
+
that actually matters.
|
|
315
|
+
|
|
316
|
+
## Screenshots, PDF, and video
|
|
317
|
+
|
|
318
|
+
```ts
|
|
319
|
+
const shot = await send("Page.captureScreenshot", { format: "png" });
|
|
320
|
+
await Bun.write("screenshot.png", Buffer.from(shot.data, "base64"));
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
`captureBeyondViewport: true` for full-page; `Page.getLayoutMetrics` + `clip`
|
|
324
|
+
for exact regions; `Page.printToPDF` for PDFs. For video recording with
|
|
325
|
+
`Page.startScreencast` and demo-polish tips, read
|
|
326
|
+
[references/recording.md](references/recording.md).
|
|
327
|
+
|
|
328
|
+
## Debugging failures
|
|
329
|
+
|
|
330
|
+
Enable `Network` and `Log`, then watch `Network.requestWillBeSent`,
|
|
331
|
+
`Network.responseReceived`, `Network.loadingFailed`, `Runtime.consoleAPICalled`,
|
|
332
|
+
`Runtime.exceptionThrown`, and `Log.entryAdded`. Fetch bodies with
|
|
333
|
+
`Network.getResponseBody`. Never log authorization headers, cookies, API keys,
|
|
334
|
+
passwords, or response bodies containing secrets — scrub before returning
|
|
335
|
+
output to context.
|
|
336
|
+
|
|
337
|
+
Common failure modes:
|
|
338
|
+
|
|
339
|
+
- **ECONNREFUSED on the port**: browser exited, wrong port, or debugging not
|
|
340
|
+
enabled — check `/json/version` first.
|
|
341
|
+
- **No matching target**: inspect `/json/list`; match by URL/title, don't take
|
|
342
|
+
the first page blindly.
|
|
343
|
+
- **Execution context destroyed**: the page navigated; wait for the new
|
|
344
|
+
document and re-evaluate.
|
|
345
|
+
- **Click misses an existing element**: scroll into view and recalculate the
|
|
346
|
+
box immediately before dispatching.
|
|
347
|
+
- **Typed text doesn't stick in a controlled input**: focus + `Input.insertText`,
|
|
348
|
+
or the prototype-setter pattern above.
|
|
349
|
+
- **Opening DevTools disconnects automation**: embedded DevTools can detach
|
|
350
|
+
other clients — don't open DevTools during a run.
|
|
351
|
+
- **Page commands fail on the browser endpoint**: attach to the page target.
|
|
352
|
+
|
|
353
|
+
## Safety
|
|
354
|
+
|
|
355
|
+
Browser automation acts with the user's browser authority.
|
|
356
|
+
|
|
357
|
+
- Use a disposable profile by default.
|
|
358
|
+
- Do not submit purchases, publish content, send messages, delete data, or
|
|
359
|
+
accept consequential dialogs without explicit authorization.
|
|
360
|
+
- Do not extract saved passwords, tokens, cookies, or unrelated browsing data.
|
|
361
|
+
- Stay within the requested origin and workflow.
|
|
362
|
+
- Keep the remote-debugging listener on loopback (`127.0.0.1`) unless the user
|
|
363
|
+
explicitly needs remote access and has authentication in place.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Recording video with Page.startScreencast
|
|
2
|
+
|
|
3
|
+
Screencast frames arrive when Chrome paints, not at a constant frame rate.
|
|
4
|
+
Acknowledge every frame immediately or Chrome stops sending them:
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
let latestFrame: Buffer | undefined;
|
|
8
|
+
|
|
9
|
+
function handleEvent(msg: any) {
|
|
10
|
+
if (msg.method !== "Page.screencastFrame") return;
|
|
11
|
+
latestFrame = Buffer.from(msg.params.data, "base64");
|
|
12
|
+
void send("Page.screencastFrameAck", { sessionId: msg.params.sessionId });
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
await send("Page.startScreencast", {
|
|
16
|
+
format: "jpeg",
|
|
17
|
+
quality: 88,
|
|
18
|
+
maxWidth: 1440,
|
|
19
|
+
maxHeight: 900,
|
|
20
|
+
everyNthFrame: 1,
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
To produce a standard constant-frame-rate video, sample `latestFrame` on a
|
|
25
|
+
fixed timer into numbered JPEGs while the flow runs, then encode:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
let frameNo = 0;
|
|
29
|
+
const sampler = setInterval(() => {
|
|
30
|
+
if (latestFrame) {
|
|
31
|
+
void Bun.write(`frames/frame-${String(frameNo++).padStart(6, "0")}.jpg`, latestFrame);
|
|
32
|
+
}
|
|
33
|
+
}, 100); // 10 fps
|
|
34
|
+
// ... perform the flow ...
|
|
35
|
+
clearInterval(sampler);
|
|
36
|
+
await send("Page.stopScreencast");
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
ffmpeg -y -framerate 10 -i frames/frame-%06d.jpg \
|
|
41
|
+
-c:v libx264 -crf 18 -pix_fmt yuv420p -movflags +faststart demo.mp4
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
- Seed `latestFrame` with a `Page.captureScreenshot` before starting so an
|
|
45
|
+
idle opening scene is not blank.
|
|
46
|
+
- Stop the screencast in a `finally` block.
|
|
47
|
+
- Verify with `ffprobe`, extract a few representative frames with `ffmpeg`,
|
|
48
|
+
and inspect them before reporting success.
|
|
49
|
+
|
|
50
|
+
## Demo polish
|
|
51
|
+
|
|
52
|
+
- Fix the viewport size and `--force-device-scale-factor=1`.
|
|
53
|
+
- Use a clean profile and reset app state before the final take.
|
|
54
|
+
- Rehearse the entire flow once before recording.
|
|
55
|
+
- Add a visible synthetic cursor (an absolutely-positioned element moved via
|
|
56
|
+
`Runtime.evaluate`) — CDP frames do not include the OS pointer.
|
|
57
|
+
- Pause briefly after meaningful actions so viewers can follow.
|
|
58
|
+
- Never expose credentials: use a dedicated non-sensitive demo token and mask
|
|
59
|
+
password fields.
|
|
60
|
+
- End on the completed result for several seconds.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: self-configuration
|
|
3
|
-
description: Inspect or modify Letta Code's own memory, model, context window, system prompt, compaction, permissions, toolsets, mods, skills, channels, schedules, agent secrets, and local runtime settings. Use when the user asks how this agent or conversation is configured,
|
|
3
|
+
description: Inspect or modify Letta Code's own memory, model, context window, system prompt, compaction, permissions, toolsets, mods, skills, channels, schedules, agent secrets, and local runtime settings. Use when the user asks how this agent or conversation is configured, asks you to change how you behave or how the harness runs you, or renames you.
|
|
4
4
|
license: MIT
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -158,6 +158,8 @@ npx tsx <SKILL_DIR>/scripts/update-agent-settings.ts \
|
|
|
158
158
|
|
|
159
159
|
Name and description are agent-level metadata. Do not pass them with `--target conversation`. Values must be non-empty; the helper does not clear metadata by accident.
|
|
160
160
|
|
|
161
|
+
When the user renames you, this patch is the authoritative change — editing a name written in persona memory does not change the agent's actual name. Do both: patch the agent name here, then update any memory file that states your name so they agree.
|
|
162
|
+
|
|
161
163
|
```bash
|
|
162
164
|
npx tsx <SKILL_DIR>/scripts/update-agent-settings.ts \
|
|
163
165
|
--target agent \
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"system-prompt-size.d.ts","sourceRoot":"","sources":["../../../src/utils/system-prompt-size.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,eAAO,MAAM,6BAA6B,IAAI,CAAC;AAE/C,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIzD;AAgCD;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,MAAM,GAChB,wBAAwB,CAiB1B;AAED;;GAEG;AACH,wBAAgB,uCAAuC,CACrD,SAAS,EAAE,MAAM,GAChB,MAAM,CAER"}
|