Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
feat(computer): browse the Computer's own browser faster and like a person
jeffreye63769bad8a0
diff --git a/apps/computer/local-daemon/README.md b/apps/computer/local-daemon/README.mdindex 73d8ecb1..19a19b01 100644--- a/apps/computer/local-daemon/README.md+++ b/apps/computer/local-daemon/README.md@@ -327,7 +327,10 @@ profile under `computer-tools/agent-<browser>` in the state directory, so theuser signs in there once. Safari cannot run a second profile; the Computeruses its own window in the user's Safari. Without a `bundle_id`, the Daemonpicks the first installed of Chrome, Edge, Firefox and Safari.-Input to that browser is paced: 600 to 1800 ms between inputs, at most 300+It opens a site only at its home page and refuses any other web address with+`COMPUTER_HOME_PAGE_ONLY`: the Agent reaches a search, listing or item through+the site's own search box, menus and links, as a person does.+Input to that browser is paced: 150 to 400 ms between inputs (100 to 250 ms inside a script; typed text 8 ms per character; one script `cua.sleep` at most 1.5 s), at most 300inputs per task and 1500 per day, and at most 20 inputs per `run_script`.`report_blocker` with the page URL stopsthe task; `rate_limited` also puts the site (its registrable domain) in a@@ -338,10 +341,18 @@ A change in the number of tabs between the task's inputs stops the task with`COMPUTER_TAB_CHANGED`, because the next input could reach another page. Atab that the task's own input or script opens or closes is the task's: thetask holds the browser's input lease, and the count is kept once the tab strip-settles, since the browser shows such a tab a moment later. Only the window+settles, since the browser shows such a tab a moment later. Reading the tab+strip replaces Cua's snapshot of the window, so the Daemon remembers the rows+of recent reads and moves an Agent's element token, in an input or written+into a script, to the current snapshot when its row reads the same there.+Only the windowthe task opened with `launch_app` is held. A script that names no window inits `args` is taken to drive that window; a script to another app is neither-paced nor held, and a paced script may not call `launch_app`.+paced nor held, and a paced script may not call `launch_app`. The browser+window is the largest window whose tab strip reads: a starting Chrome can list+a larger surface without an accessibility window, which is skipped. The+`launch_app` result tells the Agent to move between pages through the site's+own controls and never type into the address bar.Desktop input keeps one persistent action record,`computer-tools/action.json`. Each Agent's browser and each seat in thediff --git a/apps/computer/local-daemon/internal/linger/localtools/agent_browser.go b/apps/computer/local-daemon/internal/linger/localtools/agent_browser.goindex b48f1134..fa0d2cdd 100644--- a/apps/computer/local-daemon/internal/linger/localtools/agent_browser.go+++ b/apps/computer/local-daemon/internal/linger/localtools/agent_browser.go@@ -235,7 +235,7 @@ func (c *cuaSession) launchAgentSafari(ctx context.Context, b agentBrowser, urlsc.op.mu.Lock()c.op.chromeTabs, c.op.chromePID, c.op.chromeWindow = tabs, pid, window.WindowIDc.op.mu.Unlock()- note := "This is the Computer's own window in the user's Safari. Safari has no separate profile, so this window has the user's Safari sign-ins; work only in this window, never in the user's other Safari windows. It works while other windows cover it, but only on the desktop (Space) the user is on. Keys without an element go to this window in the background. Type into a page field with type_text and the field's element_token. Close a tab with its tab's close action, not cmd+w."+ note := "This is the Computer's own window in the user's Safari. Safari has no separate profile, so this window has the user's Safari sign-ins; work only in this window, never in the user's other Safari windows. It works while other windows cover it, but only on the desktop (Space) the user is on. Keys without an element go to this window in the background. Type into a page field with type_text and the field's element_token. Move between pages as a person does: through the page's search box, menus and links, back with cmd+[; never type an address into the address bar. Close a tab with its tab's close action, not cmd+w."if started {note = "Opened a new Safari window for the Computer. " + note}diff --git a/apps/computer/local-daemon/internal/linger/localtools/agent_chrome.go b/apps/computer/local-daemon/internal/linger/localtools/agent_chrome.goindex 6d133db0..aab1da8a 100644--- a/apps/computer/local-daemon/internal/linger/localtools/agent_chrome.go+++ b/apps/computer/local-daemon/internal/linger/localtools/agent_chrome.go@@ -102,15 +102,20 @@ func (c *cuaSession) launchAgentChrome(ctx context.Context, b agentBrowser, urlsreturn nil, err}}- started := pid == 0 || len(windows) == 0- if started {- // A running instance without a window opens one for the same- // command. The command opens no URL: the browser would put its first- // tab in front, so each URL opens below as a new tab, the last one in- // front.+ // A running instance without a window opens one for the same command.+ // The command opens no URL: the browser would put its first tab in front,+ // so each URL opens below as a new tab, the last one in front.+ openWindow := func() error {args := append([]string{"-g", "-n", "-b", b.Bundle, "--args"}, b.Args(directory)...)if output, err := exec.CommandContext(ctx, "/usr/bin/open", args...).CombinedOutput(); err != nil {- return nil, fmt.Errorf("launch_app: %s: %w", strings.TrimSpace(string(output)), err)+ return fmt.Errorf("launch_app: %s: %w", strings.TrimSpace(string(output)), err)+ }+ return nil+ }+ started := pid == 0 || len(windows) == 0+ if started {+ if err := openWindow(); err != nil {+ return nil, err}deadline := time.Now().Add(agentChromeWait)for len(windows) == 0 {@@ -130,13 +135,21 @@ func (c *cuaSession) launchAgentChrome(ctx context.Context, b agentBrowser, urls}}}- // Bubbles such as the translate or permission prompts are small extra- // windows of the same pid, so the browser window is the largest one.- window := slices.MaxFunc(windows, func(a, b listedWindow) int {- return cmp.Compare(a.Bounds.Width*a.Bounds.Height, b.Bounds.Width*b.Bounds.Height)- })- // A just-started window shows its tab strip a moment after it appears.- for deadline := time.Now().Add(agentChromeWait); started && len(urls) > 0 && c.agentChromeTabs(ctx, pid, window.WindowID) == 0; {+ window, tabs := c.agentChromeWindow(ctx, pid, windows)+ if !started && len(urls) > 0 && tabs == 0 && !offSpace(window) {+ // A window macOS has not shown for a while first reads as empty. One+ // that stays empty has left the accessibility tree while its frame is+ // still listed, so the browser opens a fresh window for the URLs.+ if tabs = c.agentChromeTabsUntil(ctx, pid, window.WindowID, agentChromeWait, func(n int) bool { return n > 0 }); tabs == 0 {+ if err := openWindow(); err != nil {+ return nil, err+ }+ started = true+ }+ }+ // A just-started browser shows its tab strip a moment after its window+ // appears, and may first list a window that is not the browser window.+ for deadline := time.Now().Add(agentChromeWait); started && len(urls) > 0 && tabs == 0; {if time.Now().After(deadline) {if offSpace(window) {return nil, errAgentChromeOffSpace@@ -146,6 +159,11 @@ func (c *cuaSession) launchAgentChrome(ctx context.Context, b agentBrowser, urlsif err := sleepContext(ctx, 200*time.Millisecond); err != nil {return nil, err}+ if listed, err := c.appWindows(ctx, pid); err != nil {+ return nil, err+ } else if len(listed) > 0 {+ window, tabs = c.agentChromeWindow(ctx, pid, listed)+ }}for i, url := range urls {// A browser this call started shows only its start page, which for@@ -159,7 +177,7 @@ func (c *cuaSession) launchAgentChrome(ctx context.Context, b agentBrowser, urlsreturn nil, err}}- note := "This is the Computer's own " + b.Name + ", separate from the user's everyday browser and with its own sign-ins. It works while other windows cover it, but only on the desktop (Space) the user is on. Keys without an element, such as escape, go to it in the background; the Computer never brings it forward for them. Only a click with delivery_mode foreground brings it forward: use one only where a control takes only a real pointer, and tell the user first. Type into a page field with type_text and the field's element_token: pressing an element does not move the keyboard focus, so keys without one can land in the address bar. Close a tab with the Close button of its tab, not cmd+w. If a site asks to sign in, ask the user to sign in once in this window."+ note := "This is the Computer's own " + b.Name + ", separate from the user's everyday browser and with its own sign-ins. It works while other windows cover it, but only on the desktop (Space) the user is on. Keys without an element, such as escape, go to it in the background; the Computer never brings it forward for them. Only a click with delivery_mode foreground brings it forward: use one only where a control takes only a real pointer, and tell the user first. Type into a page field with type_text and the field's element_token: pressing an element does not move the keyboard focus, so keys without one can land in the address bar. Move between pages as a person does: through the page's search box, menus and links, back with cmd+[; never type an address into the address bar. Close a tab with the Close button of its tab, not cmd+w. If a site asks to sign in, ask the user to sign in once in this window."if started {note = "Started the Computer's own " + b.Name + "; its window came forward once. " + note}@@ -167,7 +185,7 @@ func (c *cuaSession) launchAgentChrome(ctx context.Context, b agentBrowser, urlsm.mu.Lock()m.agentChromePID, m.agentChromeChecked = pid, time.Now()m.mu.Unlock()- tabs := c.agentChromeTabs(ctx, pid, window.WindowID)+ tabs = c.agentChromeTabs(ctx, pid, window.WindowID)c.op.mu.Lock()c.op.chromeTabs, c.op.chromePID, c.op.chromeWindow = tabs, pid, window.WindowIDc.op.mu.Unlock()@@ -180,6 +198,25 @@ func (c *cuaSession) launchAgentChrome(ctx context.Context, b agentBrowser, urls"structuredContent": map[string]any{"browser": b.Name, "pid": pid, "windows": []map[string]any{{"window_id": window.WindowID, "title": window.Title, "on_screen": window.IsOnScreen}}, "tabs": tabs, "note": note}})}+// agentChromeWindow picks the browser window among windows and reads its+// tab count. Bubbles such as the translate or permission prompts are small+// extra windows of the same pid, so the browser window is the largest one+// whose tab strip reads. A starting Chrome can list a larger surface that has+// no accessibility window; it is skipped. With no readable tab strip, the+// largest window is returned with 0 tabs.+func (c *cuaSession) agentChromeWindow(ctx context.Context, pid int, windows []listedWindow) (listedWindow, int) {+ bySize := slices.Clone(windows)+ slices.SortStableFunc(bySize, func(a, b listedWindow) int {+ return cmp.Compare(b.Bounds.Width*b.Bounds.Height, a.Bounds.Width*a.Bounds.Height)+ })+ for _, window := range bySize {+ if tabs := c.agentChromeTabs(ctx, pid, window.WindowID); tabs > 0 {+ return window, tabs+ }+ }+ return bySize[0], 0+}+// agentChromeOpenTab opens url in a new tab of window: cmd+t and Return go// to this Chrome only, and the address bar takes the URL as its value.// Chrome's address bar ignores the accessibility confirm action. This Chromediff --git a/apps/computer/local-daemon/internal/linger/localtools/agent_chrome_pace.go b/apps/computer/local-daemon/internal/linger/localtools/agent_chrome_pace.goindex 5cf7f6a1..1c736822 100644--- a/apps/computer/local-daemon/internal/linger/localtools/agent_chrome_pace.go+++ b/apps/computer/local-daemon/internal/linger/localtools/agent_chrome_pace.go@@ -40,12 +40,23 @@ const (// agentChromePause is the gap kept between two inputs to the Computer's own// browser; a test replaces it.var agentChromePause = func() time.Duration {- return time.Duration(600+rand.IntN(1200)) * time.Millisecond //nolint:gosec // pacing jitter, not a secret+ return time.Duration(150+rand.IntN(250)) * time.Millisecond //nolint:gosec // pacing jitter, not a secret}// scriptInputPause is the range, in milliseconds, of the pause a paced script// waits before each input.-const scriptInputPauseMin, scriptInputPauseSpan = 400, 900+const scriptInputPauseMin, scriptInputPauseSpan = 100, 150++// agentChromeTypeDelay is the gap, in milliseconds, between the characters+// type_text sends to the Computer's own browser. Chromium takes no+// accessibility text insertion, so Cua types key by key; its own default of+// 30 ms makes a short search take a second or more.+const agentChromeTypeDelay = 8++// scriptSleepLimit caps one cua.sleep, in milliseconds, in a script for the+// Computer's own browser: a page is waited for with app.waitFor, and a fixed+// wait only adds time the user watches.+const scriptSleepLimit = 1500// blockerKinds are the checks report_blocker accepts. Every kind but// content_unavailable stops the task's input to the Computer's own browser.@@ -87,6 +98,21 @@ func siteOf(address string) string {return host}+// homePage refuses a web address other than a site's home page in the+// Computer's own browser. A person opens a site and reaches a search,+// listing or item through its own search box, menus and links; a built+// address skips that and reads to the site as automation.+func homePage(address string) error {+ parsed, err := url.Parse(address)+ if err != nil {+ return nil //nolint:nilerr // an address that does not parse names no site page+ }+ if !webAddress(parsed) || (parsed.Path == "" || parsed.Path == "/") && parsed.RawQuery == "" && parsed.Fragment == "" {+ return nil+ }+ return fmt.Errorf("COMPUTER_HOME_PAGE_ONLY: the Computer's own browser opens a site at its home page, such as %s://%s/; reach the page you need through the site's search box, menus and links: %w", parsed.Scheme, parsed.Host, errNotSent)+}+// coolingSite refuses work on a site in its cooldown.func (m *Manager) coolingSite(sites []string) error {m.paceMu.Lock()diff --git a/apps/computer/local-daemon/internal/linger/localtools/client.go b/apps/computer/local-daemon/internal/linger/localtools/client.goindex 6eaf6640..2e7e156f 100644--- a/apps/computer/local-daemon/internal/linger/localtools/client.go+++ b/apps/computer/local-daemon/internal/linger/localtools/client.go@@ -40,6 +40,8 @@ type mcpClient struct {stop context.CancelFunccloseOnce sync.Onceerr error+ // observe, when set, sees every completed tool call and its result.+ observe func(params any, result json.RawMessage)}func startClient(ctx context.Context, command string, args []string, cwd string, env []string) (*mcpClient, error) {@@ -202,6 +204,9 @@ func (c *mcpClient) request(ctx context.Context, method string, params any) (jsoif len(response.Result) == 0 {return nil, errors.Join(errOutcomeUnknown, errors.New("missing local MCP response"))}+ if c.observe != nil && method == "tools/call" {+ c.observe(params, response.Result)+ }return response.Result, nilcase <-ctx.Done():return nil, errors.Join(errOutcomeUnknown, context.Cause(ctx))diff --git a/apps/computer/local-daemon/internal/linger/localtools/cua.go b/apps/computer/local-daemon/internal/linger/localtools/cua.goindex f2141dc4..60d71c98 100644--- a/apps/computer/local-daemon/internal/linger/localtools/cua.go+++ b/apps/computer/local-daemon/internal/linger/localtools/cua.go@@ -53,6 +53,8 @@ type cuaSession struct {named map[int]float64// input is, per macOS app, when the Agent last sent it input.input map[int]time.Time+ // snapshots carries the Agent's tokens over the Computer's own reads.+ snapshots *snapshotRows}func (c *cuaSession) checkDesktop() error {@@ -116,7 +118,8 @@ func (m *Manager) openCua(ctx context.Context, op *operation) (*cuaSession, []toclient, err := startClientWith(ctx, run, m.options.CuaPath, arguments, op.spec.WorkingDirectory, environment)var session *cuaSessionif client != nil {- session = &cuaSession{op: op, client: client, label: "linger-" + rand.Text(), servicePID: servicePID}+ session = &cuaSession{op: op, client: client, label: "linger-" + rand.Text(), servicePID: servicePID, snapshots: newSnapshotRows()}+ client.observe = session.snapshots.observe}if err != nil {return session, nil, err@@ -157,7 +160,7 @@ func (m *Manager) openCua(ctx context.Context, op *operation) (*cuaSession, []toif item.Name == "launch_app" && runtime.GOOS == "darwin" {item.Description = "Open a macOS app in the background through Launch Services, as `open -g` does, and return its pid and windows. Optional urls are handed to the app; for Finder, pass a folder to open it in a window."item.InputSchema = schema(map[string]any{"bundle_id": map[string]string{"type": "string", "description": "Preferred, for example com.apple.TextEdit."}, "name": map[string]string{"type": "string", "description": "App name, when the bundle id is unknown."}, "urls": map[string]any{"type": "array", "items": map[string]string{"type": "string"}, "description": "Files or folders to open in the app."},- "agent_browser": map[string]string{"type": "boolean", "description": "Open the URLs in the Computer's own browser, which keeps working while other windows cover it on the user's desktop and has its own sign-ins, instead of the user's everyday browser. With no bundle_id it is the first installed of Chrome, Edge, Firefox and Safari; a bundle_id of com.google.Chrome, com.microsoft.edgemac, org.mozilla.firefox or com.apple.Safari picks one. Safari has no separate profile, so there it is a window of its own in the user's Safari, with the user's sign-ins."}})+ "agent_browser": map[string]string{"type": "boolean", "description": "Open the URLs in the Computer's own browser, which keeps working while other windows cover it on the user's desktop and has its own sign-ins, instead of the user's everyday browser. Only a site's home page opens there, such as https://www.example.com/. With no bundle_id it is the first installed of Chrome, Edge, Firefox and Safari; a bundle_id of com.google.Chrome, com.microsoft.edgemac, org.mozilla.firefox or com.apple.Safari picks one. Safari has no separate profile, so there it is a window of its own in the user's Safari, with the user's sign-ins."}})}if item.Name == "get_desktop_state" {item.Description += " Read-only whole-screen view; act through the window tools with a pid and window_id. A system privacy prompt about CuaDriver belongs to the user: never answer it, and keep working through the window tools."@@ -381,6 +384,17 @@ func (c *cuaSession) call(ctx context.Context, name string, args json.RawMessageif err != nil {return nil, err}+ if own, _ := arguments["agent_browser"].(bool); own && name == "launch_app" {+ // Refused before the launch takes the browser, the pace or the journal.+ urls, _ := arguments["urls"].([]any)+ for _, item := range urls {+ if address, ok := item.(string); ok {+ if err := homePage(address); err != nil {+ return nil, err+ }+ }+ }+ }agentChrome, err := c.claimAgentChromeInput(ctx, name, arguments, paged)if err != nil {return nil, err@@ -508,8 +522,16 @@ func (c *cuaSession) call(ctx context.Context, name string, args json.RawMessagereturn nil, err}}+ if c.snapshots != nil {+ // The Computer's own reads since the Agent's read, such as the tab+ // check, replaced the snapshot the Agent's token names.+ c.snapshots.remap(arguments)+ }driverStarted := time.Now()result, err := c.sendInput(ctx, name, arguments, appKeys, agentChrome)+ if c.snapshots != nil {+ c.snapshots.sent()+ }driverMs = time.Since(driverStarted).Milliseconds()if err == nil {result = c.annotateInputResult(name, result)@@ -633,7 +655,7 @@ func (c *cuaSession) claimAgentChromeInput(ctx context.Context, name string, arg}}if modifiers, _ := arguments["modifier"].([]any); agentChrome && len(modifiers) > 0 && arguments["delivery_mode"] != "foreground" {- return false, fmt.Errorf("COMPUTER_INPUT_NOT_SENT: a click with modifier keys needs the window in front, and the Computer's own browser is never brought forward for it; open a link with launch_app urls instead: %w", errNotSent)+ return false, fmt.Errorf("COMPUTER_INPUT_NOT_SENT: a click with modifier keys needs the window in front, and the Computer's own browser is never brought forward for it; click the link without modifier keys instead: %w", errNotSent)}return agentChrome, nil}@@ -672,6 +694,9 @@ func (c *cuaSession) prepareInput(ctx context.Context, name string, arguments ma}appKeys = false}+ if agentChrome && name == "type_text" && arguments["delay_ms"] == nil {+ arguments["delay_ms"] = agentChromeTypeDelay+ }if pid, ok := arguments["pid"].(float64); ok && runtime.GOOS == "darwin" {if window, ok := arguments["window_id"].(float64); ok {c.mu.Lock()diff --git a/apps/computer/local-daemon/internal/linger/localtools/cua_script.go b/apps/computer/local-daemon/internal/linger/localtools/cua_script.goindex 3126e360..ebb032fd 100644--- a/apps/computer/local-daemon/internal/linger/localtools/cua_script.go+++ b/apps/computer/local-daemon/internal/linger/localtools/cua_script.go@@ -15,7 +15,7 @@ import (// macScriptDescription replaces Cua's run_script description with the// Computer's rules: background input only, and a bounded result.const macScriptDescription = "Run a JavaScript program that drives apps on this Mac in ONE call: loops, waits, reads and checks between inputs, and only its return value comes back. Use it to repeat a flow over several items, such as open each result, read it and close it, instead of one model turn per input. The script is the body of an async function: use await and return a JSON value. The only API is cua:\n" +- "- const app = await cua.getApp({pid, windowId}) or cua.getApp(\"Google Chrome\"); cua.sleep(ms), where ms must be a whole number: a fraction returns at once without waiting; cua.listWindows({pid})\n" ++ "- const app = await cua.getApp({pid, windowId}) or cua.getApp(\"Google Chrome\"); cua.sleep(ms), where ms must be a whole number: a fraction returns at once without waiting, and in the Computer's own browser one sleep lasts at most 1.5 s: wait for a page with app.waitFor; cua.listWindows({pid})\n" +"- app.getState({query?, max_elements?, timeout_ms?, since?: \"latest\", tree_format?: \"elements\"}) returns {tree_markdown, window_title, snapshot_id, truncated?, elements?}; rows read as in get_window_state. In a script the walk stops after 250 nodes and 1000 ms unless you pass max_elements and timeout_ms, which cuts a browser page: pass about 3000 and 4000 there\n" +"- app.query({role?, name?}) finds named elements {element_token, role, label, frame}; app.waitFor({role?, name?, text?, gone?, timeout_ms?}) waits until the window shows (or no longer shows) them; text also matches static text\n" +"- app.click(t), doubleClick(t), typeText(text, t?), pressKey(\"escape\", t?), hotkey([\"cmd\",\"s\"]), scroll(t, \"down\", amount?), setValue(t, value), where t is {role, name, nth?}, an element_token, a row number of this app's last getState(), or [x, y] pixels of its last screenshot\n" +@@ -92,7 +92,9 @@ for (let i = 0; i < ks.length; i++) { const v = r[ks[i]], w = out(v); if (w ===return c || r; };const wrap = o => { const w = {}, seen = {};for (let q = o; q && q !== plainProtos[0]; q = proto(q)) { const ns = names(q); for (let i = 0; i < ns.length; i++) { const k = ns[i]; if (k === "constructor" || seen[k]) continue; seen[k] = true;-define(w, k, {enumerable: true, get() { const v = o[k]; if (typeof v !== "function") return out(v); return function (...a) { const c = {length: a.length}; for (let i = 0; i < a.length; i++) define(c, i, {value: plain(a[i])});+define(w, k, {enumerable: true, get() { const v = o[k]; if (typeof v !== "function") return out(v); return function (...a) { let c = {length: a.length}; for (let i = 0; i < a.length; i++) define(c, i, {value: plain(a[i])});+if (limit > 0 && k === "typeText") { const given = c.length > 2 && c[2] !== null && typeof c[2] === "object" ? c[2] : {}; const t = {length: 3}; define(t, 0, {value: c[0]}); define(t, 1, {value: c[1]}); define(t, 2, {value: {delay_ms: `+strconv.Itoa(agentChromeTypeDelay)+`, ...given}}); c = t; }+if (limit > 0 && k === "sleep" && o === real && typeof c[0] === "number" && c[0] > `+strconv.Itoa(scriptSleepLimit)+`) { const t = {length: 1}; define(t, 0, {value: `+strconv.Itoa(scriptSleepLimit)+`}); c = t; }const run = () => { const r = apply(v, o, c); return r !== null && typeof r === "object" && typeof r.then === "function" ? apply(then, r, [out]) : out(r); };if (limit > 0 && (k === "launchApp" || k === "call" && c[0] === "launch_app")) throw new Error("COMPUTER_SCRIPT_REFUSED: a script in the Computer's own browser opens no app or URL, so the site checks of launch_app hold; call launch_app as its own tool");if (limit <= 0 || !input(k, c)) return run();diff --git a/apps/computer/local-daemon/internal/linger/localtools/cua_script_guard_test.go b/apps/computer/local-daemon/internal/linger/localtools/cua_script_guard_test.goindex 3c525f45..7376be87 100644--- a/apps/computer/local-daemon/internal/linger/localtools/cua_script_guard_test.go+++ b/apps/computer/local-daemon/internal/linger/localtools/cua_script_guard_test.go@@ -4,6 +4,7 @@ import ("os""os/exec""path/filepath"+ "strconv""strings""testing")@@ -13,12 +14,12 @@ import (// the same prelude's semantics.const guardHarness = `import fs from "fs";const log = [];-class App { constructor(n) { this.n = n; } click(a) { log.push("raw:" + JSON.stringify(a)); return "clicked"; } }+class App { constructor(n) { this.n = n; } click(a) { log.push("raw:" + JSON.stringify(a)); return "clicked"; } typeText(text, on, options) { log.push("type:" + JSON.stringify(options)); return "typed"; } }const fake = { call(t, a) { log.push("call:" + t + ":" + JSON.stringify(a)); return Promise.resolve({ok: true}); },getApp() { return Promise.resolve(new App("a")); },listApps() { return Promise.resolve([new App("b")]); },box() { return Promise.resolve({inner: {app: new App("c")}}); },- sleep(ms) { log.push("sleep:" + (ms >= 400 && ms < 1300 ? "paced" : ms)); return Promise.resolve(); } };+ sleep(ms) { log.push("sleep:" + (ms >= 100 && ms < 250 ? "paced" : ms)); return Promise.resolve(); } };Object.defineProperty(globalThis, "cua", {value: Object.freeze(fake), writable: false, configurable: false});const AsyncFunction = (async function () {}).constructor;let result;@@ -96,6 +97,36 @@ func TestScriptGuardPacesInputsForTheComputersChrome(t *testing.T) {}}+// In the Computer's own browser a script types with a short gap between+// characters unless it names one, and one fixed wait lasts at most+// scriptSleepLimit: pages are waited for with app.waitFor.+func TestScriptGuardSpeedsTypingAndCapsWaits(t *testing.T) {+ node, err := exec.LookPath("node")+ if err != nil {+ t.Skip("node is not installed")+ }+ dir := t.TempDir()+ harness := filepath.Join(dir, "harness.mjs")+ script := filepath.Join(dir, "script.js")+ body := `const app = await cua.getApp({pid: 1}); await app.typeText("kettle", {role: "AXTextField"}); await app.typeText("pot", undefined, {delay_ms: 40}); await cua.sleep(5000); await cua.sleep(700); return "done";`+ if err := os.WriteFile(harness, []byte(guardHarness), 0o600); err != nil {+ t.Fatal(err)+ }+ if err := os.WriteFile(script, []byte(guardedScript(`{}`, body, 42, 20)), 0o600); err != nil {+ t.Fatal(err)+ }+ out, err := exec.Command(node, harness, script).CombinedOutput()+ if err != nil {+ t.Fatalf("node: %v\n%s", err, out)+ }+ got := string(out)+ for _, want := range []string{`type:{\"delay_ms\":` + strconv.Itoa(agentChromeTypeDelay) + `}`, `type:{\"delay_ms\":40}`, `"sleep:` + strconv.Itoa(scriptSleepLimit) + `"`, `"sleep:700"`} {+ if !strings.Contains(got, want) {+ t.Fatalf("got %s, want %s", got, want)+ }+ }+}+// A paced script opens no app or URL, so launch_app's site checks hold; an// unpaced script may still call it.func TestScriptGuardRefusesLaunchAppForTheComputersChrome(t *testing.T) {diff --git a/apps/computer/local-daemon/internal/linger/localtools/cua_snapshots.go b/apps/computer/local-daemon/internal/linger/localtools/cua_snapshots.gonew file mode 100644index 00000000..dd92f290--- /dev/null+++ b/apps/computer/local-daemon/internal/linger/localtools/cua_snapshots.go@@ -0,0 +1,182 @@+package localtools++import (+ "encoding/json"+ "fmt"+ "regexp"+ "strings"+ "sync"+)++// snapshotRowsKept bounds how many reads the Computer remembers, across+// windows. Each input to the Computer's own browser adds about three reads+// (the tab check, the read after it and the tab count), and an Agent acts on+// its latest read; a full browser tree is a few hundred kilobytes, so the+// bound also caps memory. A token whose read was dropped stays as it is.+const snapshotRowsKept = 16++// snapshotRows remembers the rows of the window reads that pass through one+// driver connection. Cua keeps one snapshot per window, and any read replaces+// it, including the Computer's own reads between the Agent's read and its+// input, such as the tab count of the Computer's own browser. remap carries a+// token of an older read over to the current snapshot when that row reads the+// same in both, so the Computer's own reads never stale the Agent's tokens.+type snapshotRows struct {+ mu sync.Mutex+ // reads maps a snapshot_id to its window and its rows by index.+ reads map[string]snapshotRead+ order []string+ // current is, per window, the snapshot_id of its latest read, or empty+ // when a script may have read it since.+ current map[string]string+ // seq numbers the reads; fence is the last read before the latest input.+ // An input can change the page, so a read from before it is never+ // carried over, even where a row reads the same.+ seq, fence int+}++type snapshotRead struct {+ window string+ rows map[string]string+ seq int+}++func newSnapshotRows() *snapshotRows {+ return &snapshotRows{reads: map[string]snapshotRead{}, current: map[string]string{}}+}++// observe records the rows of a read, or forgets the current snapshots after+// a script, whose reads run inside the driver.+func (s *snapshotRows) observe(params any, result json.RawMessage) {+ call, _ := params.(map[string]any)+ name, _ := call["name"].(string)+ if name == "run_script" {+ s.mu.Lock()+ clear(s.current)+ s.mu.Unlock()+ return+ }+ if name != "get_window_state" {+ return+ }+ var reply struct {+ Structured struct {+ Snapshot string `json:"snapshot_id"`+ PID float64 `json:"pid"`+ Window float64 `json:"window_id"`+ Tree string `json:"tree_markdown"`+ Diff string `json:"tree_diff"`+ Since string `json:"since"`+ Status string `json:"since_status"`+ } `json:"structuredContent"`+ }+ if json.Unmarshal(result, &reply) != nil || reply.Structured.Snapshot == "" {+ return+ }+ read := reply.Structured+ window := fmt.Sprintf("%g:%g", read.PID, read.Window)+ rows := map[string]string{}+ s.mu.Lock()+ defer s.mu.Unlock()+ text := read.Tree+ if read.Status == "diff" {+ text = read.Diff+ // Rows a diff does not list keep their index, unless Cua's+ // "reindexed:" line, the only sign it gives, says the indices+ // shifted.+ if base, ok := s.reads[read.Since]; ok && base.window == window && !strings.Contains(read.Diff, "reindexed:") {+ for index, row := range base.rows {+ rows[index] = row+ }+ }+ }+ for _, line := range strings.Split(text, "\n") {+ trimmed := strings.TrimLeft(line, " ")+ removed := strings.HasPrefix(trimmed, "- [") && read.Status == "diff"+ index, row, ok := snapshotRow(trimmed)+ if !ok {+ continue+ }+ if removed {+ delete(rows, index)+ continue+ }+ rows[index] = row+ }+ if _, known := s.reads[read.Snapshot]; !known {+ s.order = append(s.order, read.Snapshot)+ }+ s.seq+++ s.reads[read.Snapshot] = snapshotRead{window: window, rows: rows, seq: s.seq}+ s.current[window] = read.Snapshot+ for len(s.order) > snapshotRowsKept {+ delete(s.reads, s.order[0])+ s.order = s.order[1:]+ }+}++// snapshotRow splits a row such as `- [12] AXLink "Kettle"` or a diff row+// such as `~ [12] AXLink "Kettle"` into its index and the row from the index+// on. Indentation differs between a full and a filtered read, so it is+// dropped.+func snapshotRow(line string) (index, row string, ok bool) {+ for _, mark := range []string{"- ", "+ ", "~ "} {+ line = strings.TrimPrefix(line, mark)+ }+ if !strings.HasPrefix(line, "[") {+ return "", "", false+ }+ index, _, ok = strings.Cut(line[1:], "] ")+ if !ok || index == "" || strings.Trim(index, "0123456789") != "" {+ return "", "", false+ }+ return index, line, true+}++// scriptToken finds an element token written into a script or its args.+var scriptToken = regexp.MustCompile(`\bs[0-9a-f]{8}:[0-9]+\b`)++// remap points element_token, and each token written into a script, at the+// window's current snapshot when the token names an older read whose row+// reads the same there. A row that changed, or a read the Computer does not+// remember, keeps its token, which Cua then refuses as stale.+func (s *snapshotRows) remap(arguments map[string]any) {+ s.mu.Lock()+ defer s.mu.Unlock()+ if token, ok := arguments["element_token"].(string); ok {+ arguments["element_token"] = s.carry(token)+ }+ if script, ok := arguments["script"].(string); ok {+ arguments["script"] = scriptToken.ReplaceAllStringFunc(script, s.carry)+ }+}++// sent fences off every read so far: the input just sent may have changed+// the page, so a token of an earlier read must not land on a row that only+// reads the same.+func (s *snapshotRows) sent() {+ s.mu.Lock()+ s.fence = s.seq+ s.mu.Unlock()+}++// carry returns the token on the current snapshot of its window, or the+// token itself.+func (s *snapshotRows) carry(token string) string {+ snapshot, index, ok := strings.Cut(token, ":")+ if !ok {+ return token+ }+ read, known := s.reads[snapshot]+ if !known || read.seq <= s.fence {+ return token+ }+ current := s.current[read.window]+ if current == "" || current == snapshot {+ return token+ }+ if row, ok := read.rows[index]; ok && s.reads[current].rows[index] == row {+ return current + ":" + index+ }+ return token+}diff --git a/apps/computer/local-daemon/internal/linger/localtools/cua_snapshots_test.go b/apps/computer/local-daemon/internal/linger/localtools/cua_snapshots_test.gonew file mode 100644index 00000000..19751534--- /dev/null+++ b/apps/computer/local-daemon/internal/linger/localtools/cua_snapshots_test.go@@ -0,0 +1,86 @@+package localtools++import (+ "encoding/json"+ "testing"+)++func readResult(t *testing.T, structured map[string]any) json.RawMessage {+ t.Helper()+ encoded, err := json.Marshal(map[string]any{"structuredContent": structured})+ if err != nil {+ t.Fatal(err)+ }+ return encoded+}++func readCall(arguments map[string]any) map[string]any {+ return map[string]any{"name": "get_window_state", "arguments": arguments}+}++func TestSnapshotRowsCarriesTokensOverTheComputersOwnReads(t *testing.T) {+ s := newSnapshotRows()+ agentTree := "- [0] AXWindow \"Shop\"\n - [4] AXLink \"Kettle\" [actions=[press]]\n - [5] AXButton \"Add to cart\" [actions=[press]]"+ s.observe(readCall(nil), readResult(t, map[string]any{"snapshot_id": "s00000001", "pid": 7, "window_id": 9, "tree_markdown": agentTree}))+ // The Computer's tab check reads the whole window: the link is unchanged,+ // the button now reads differently, and its rows sit deeper.+ ownTree := "- [0] AXWindow \"Shop\"\n - [4] AXLink \"Kettle\" [actions=[press]]\n - [5] AXButton \"Added\" [actions=[press]]"+ s.observe(readCall(nil), readResult(t, map[string]any{"snapshot_id": "s00000002", "pid": 7, "window_id": 9, "tree_markdown": ownTree}))++ link := map[string]any{"element_token": "s00000001:4"}+ s.remap(link)+ if link["element_token"] != "s00000002:4" {+ t.Fatalf("unchanged row = %v, want s00000002:4", link["element_token"])+ }+ button := map[string]any{"element_token": "s00000001:5"}+ s.remap(button)+ if button["element_token"] != "s00000001:5" {+ t.Fatalf("changed row = %v, want its own stale token", button["element_token"])+ }++ // A diff read keeps the rows it does not list.+ s.observe(readCall(nil), readResult(t, map[string]any{"snapshot_id": "s00000003", "pid": 7, "window_id": 9, "since": "s00000002", "since_status": "diff",+ "tree_diff": "since s00000002: 0 added, 1 changed, 0 removed.\n~ [5] AXButton \"Add to cart\" [actions=[press]]"}))+ s.observe(readCall(nil), readResult(t, map[string]any{"snapshot_id": "s00000004", "pid": 7, "window_id": 9, "tree_markdown": agentTree}))+ for _, token := range []string{"s00000003:4", "s00000003:5", "s00000001:5"} {+ arguments := map[string]any{"element_token": token}+ s.remap(arguments)+ if want := "s00000004:" + token[10:]; arguments["element_token"] != want {+ t.Fatalf("%s = %v, want %s", token, arguments["element_token"], want)+ }+ }++ script := map[string]any{"script": `await app.click("s00000001:4"); await app.click("s00000099:4")`}+ s.remap(script)+ if want := `await app.click("s00000004:4"); await app.click("s00000099:4")`; script["script"] != want {+ t.Fatalf("script = %v, want %s", script["script"], want)+ }++ // After an input, an older read is never carried over: the page may+ // have changed under a row that reads the same.+ s.sent()+ s.observe(readCall(nil), readResult(t, map[string]any{"snapshot_id": "s00000005", "pid": 7, "window_id": 9, "tree_markdown": agentTree}))+ before := map[string]any{"element_token": "s00000004:4"}+ s.remap(before)+ if before["element_token"] != "s00000004:4" {+ t.Fatalf("read before an input = %v, want its own stale token", before["element_token"])+ }++ // A diff that says the indices shifted keeps only the rows it lists.+ s.observe(readCall(nil), readResult(t, map[string]any{"snapshot_id": "s00000006", "pid": 7, "window_id": 9, "since": "s00000005", "since_status": "diff",+ "tree_diff": "since s00000005: 1 added.\nreindexed: rows after 3 moved by 1\n+ [5] AXLink \"Kettle\" [actions=[press]]"}))+ s.observe(readCall(nil), readResult(t, map[string]any{"snapshot_id": "s00000007", "pid": 7, "window_id": 9, "tree_markdown": agentTree}))+ shifted := map[string]any{"element_token": "s00000006:4"}+ s.remap(shifted)+ if shifted["element_token"] != "s00000006:4" {+ t.Fatalf("row of a reindexed diff = %v, want its own stale token", shifted["element_token"])+ }++ // A script reads inside the driver, so no snapshot is known current.+ s.observe(map[string]any{"name": "run_script"}, json.RawMessage(`{}`))+ after := map[string]any{"element_token": "s00000001:4"}+ s.remap(after)+ if after["element_token"] != "s00000001:4" {+ t.Fatalf("after a script = %v, want the token unchanged", after["element_token"])+ }+}diff --git a/apps/computer/local-daemon/internal/linger/localtools/localtools_test.go b/apps/computer/local-daemon/internal/linger/localtools/localtools_test.goindex 4689fbce..39713581 100644--- a/apps/computer/local-daemon/internal/linger/localtools/localtools_test.go+++ b/apps/computer/local-daemon/internal/linger/localtools/localtools_test.go@@ -198,10 +198,18 @@ func runToolFixture(mode string) {result = map[string]any{"isError": true, "content": []any{map[string]string{"type": "text", "text": "keys were not delivered"}}}}case "list_windows":- result = map[string]any{"content": []any{}, "structuredContent": map[string]any{"windows": []any{- map[string]any{"pid": 42, "window_id": 9, "title": "b", "z_index": 3, "is_on_screen": true},- }}}+ windows := []any{map[string]any{"pid": 42, "window_id": 9, "title": "b", "z_index": 3, "is_on_screen": true, "bounds": map[string]any{"width": 800, "height": 600}}}+ if mode == "tabs-ghost" {+ // A starting Chrome lists a larger surface with no+ // accessibility window beside its browser window.+ windows = append(windows, map[string]any{"pid": 42, "window_id": 8, "title": "", "z_index": 4, "is_on_screen": true, "bounds": map[string]any{"width": 1600, "height": 1000}})+ }+ result = map[string]any{"content": []any{}, "structuredContent": map[string]any{"windows": windows}}case "get_window_state":+ if mode == "tabs-ghost" && request.Params.Arguments["window_id"] == float64(8) {+ result = map[string]any{"content": []any{}, "structuredContent": map[string]any{"tree_markdown": "", "degraded_reason": "ax_window_unresolved"}}+ break+ }var tree strings.Builderfor i := range tabs {fmt.Fprintf(&tree, "- [%d] AXRadioButton \"Tab %d\"\n- [%d] AXButton \"Close\" [actions=[press]]\n", 2*i, i, 2*i+1)@@ -1213,6 +1221,10 @@ func TestLocalToolCuaMacAgentChromeHoldsOnlyItsOwnWindow(t *testing.T) {if _, err := c.call(t.Context(), "launch_app", json.RawMessage(`{"agent_browser":true,"urls":["https://example.com/"]}`)); !strings.Contains(fmt.Sprint(err), "COMPUTER_SITE_BLOCKED") {t.Fatalf("err=%v, want the stopped task held", err)}+ // A built search address is refused before anything opens.+ if _, err := c.call(t.Context(), "launch_app", json.RawMessage(`{"agent_browser":true,"urls":["https://example.com/s/Kyoto?adults=2"]}`)); !strings.Contains(fmt.Sprint(err), "COMPUTER_HOME_PAGE_ONLY") {+ t.Fatalf("err=%v, want only a home page", err)+ }if err := c.drain(); err != nil {t.Fatal(err)}@@ -1832,3 +1844,22 @@ func TestLocalToolCuaDeltaCountFailureReadsFullWindowOnlyOnce(t *testing.T) {})}}++// A starting Chrome may list a larger surface that has no accessibility+// window; the browser window is the largest one whose tab strip reads.+func TestLocalToolCuaMacAgentChromePicksTheWindowWithTabs(t *testing.T) {+ if runtime.GOOS != "darwin" {+ t.Skip("the Computer's own Chrome is macOS only")+ }+ c := cuaFixtureSession(t, "tabs-ghost", filepath.Join(t.TempDir(), "calls.jsonl"))+ windows, err := c.appWindows(t.Context(), 42)+ if err != nil {+ t.Fatal(err)+ }+ if window, tabs := c.agentChromeWindow(t.Context(), 42, windows); window.WindowID != 9 || tabs != 1 {+ t.Fatalf("window=%v tabs=%d, want window 9 with 1 tab", window.WindowID, tabs)+ }+ if err := c.drain(); err != nil {+ t.Fatal(err)+ }+}diff --git a/apps/node-services/src/agent/prompt/compact-meta-instructions.ts b/apps/node-services/src/agent/prompt/compact-meta-instructions.tsindex f71bf91f..689aa63b 100644--- a/apps/node-services/src/agent/prompt/compact-meta-instructions.ts+++ b/apps/node-services/src/agent/prompt/compact-meta-instructions.ts@@ -69,11 +69,15 @@ const TASK_COMMAND = `teamhub task create --name "<title>" --requirement "<briefconst TASK_BRIEF = `- The AlterEgo can't see this conversation or message anyone. Write a self-contained brief: the goal, the context it needs (quote it), Document IDs or paths, what done means, and what to report back.`;+const OWN_BROWSER = `- Browsing a site in the Computer's own browser, the humanlike-browse way, is the exception: the person watches that window and a Task takes a minute to start, so do it yourself in this turn.`;+const DIRECT_TASKS = `Stay available: keep your own turns short and delegate heavier work.- Delegate non-trivial work (web research, several files, producing a document or file, a long command sequence) to your AlterEgo: ${TASK_COMMAND} Do quick answers and one-step lookups yourself.+${OWN_BROWSER}${TASK_BRIEF}`;const ROOM_TASKS = `- Delegate research and multi-step investigation to your AlterEgo so the Room isn't blocked on you: ${TASK_COMMAND}+${OWN_BROWSER}${TASK_BRIEF}`;const TASK_COORDINATION = `- After creating a Task, say in a line that it's under way, then move on. Don't wait or check on it; its report wakes you.diff --git a/apps/node-services/src/agent/prompt/meta-instructions.ts b/apps/node-services/src/agent/prompt/meta-instructions.tsindex cfac0c62..cdb99408 100644--- a/apps/node-services/src/agent/prompt/meta-instructions.ts+++ b/apps/node-services/src/agent/prompt/meta-instructions.ts@@ -117,14 +117,18 @@ People are watching a live chat, not a progress bar.const TASK_COMMAND = `teamhub task create --name "<short title>" --requirement "<brief>" (--requirement-file for a long brief). It starts at once; nobody approves it, and up to 10 Tasks can run at the same time.`;+const OWN_BROWSER = `- Browsing a site in the Computer's own browser, the humanlike-browse way, is the exception: the person watches that window and a Task takes a minute to start, so do it yourself in this turn.`;+const TASK_BRIEF = `- The AlterEgo can't read this Room, so write a self-contained requirement: what to do, the context from this conversation it needs (quote it), Document IDs or file paths, what counts as done, and what to report back. It can't reach people and reports only to you, so don't ask it to message anyone.`;// In a direct chat the Meta stays available and delegates anything heavier.const DIRECT_TASKS = `- Delegate any non-trivial work to your own AlterEgo with ${TASK_COMMAND} Non-trivial means web research beyond a quick lookup, reading or processing several files or data, producing a document, report or other file, a long command sequence, or anything that would keep you busy for more than a few seconds. Answer conversational questions and do one-step lookups yourself, and do the work directly when the person asks you to do it right now.- Give each independent piece of work its own Task and create them together so they run in parallel.+${OWN_BROWSER}${TASK_BRIEF}`;const ROOM_TASKS = `- Delegate researching something, digging through files, or a multi-step investigation to your own AlterEgo so the Room isn't blocked on you: ${TASK_COMMAND} Give each independent piece of work its own Task.+${OWN_BROWSER}${TASK_BRIEF}`;const TASK_COORDINATION = `- A Task runs as a separate AlterEgo of you in the background; its progress is not yours. Don't redo its work here.diff --git a/apps/node-services/tests/agent/__golden__/executor-hook-trace/cold-then-hot.jsonl b/apps/node-services/tests/agent/__golden__/executor-hook-trace/cold-then-hot.jsonlindex 2f2e595f..84e2eacf 100644--- a/apps/node-services/tests/agent/__golden__/executor-hook-trace/cold-then-hot.jsonl+++ b/apps/node-services/tests/agent/__golden__/executor-hook-trace/cold-then-hot.jsonl@@ -2,7 +2,7 @@{"hook":"context.onContextBound","context":{"kind":"meta","agentId":"agent-trace","roomId":"room-trace"},"bootstrap":"new"}{"step":"state.enqueueTrustedTurn","messageIds":["m-1"],"runId":"run-1"}{"hook":"activation.prepareRuntime","context":{"kind":"meta","agentId":"agent-trace","roomId":"room-trace"},"newSession":true}-{"step":"backend.activate","developerInstructions":"sha256:ebdbf70275173aa0","mappings":1}+{"step":"backend.activate","developerInstructions":"sha256:cbcff50bf9f3ce2f","mappings":1}{"step":"provider.createSession"}{"step":"state.claimLocalRun","runId":"run-1","messageIds":["m-1"]}{"hook":"context.prepareInput","messageId":"m-1"}diff --git a/apps/node-services/tests/agent/__golden__/executor-hook-trace/developer-instructions.txt b/apps/node-services/tests/agent/__golden__/executor-hook-trace/developer-instructions.txtindex a725089d..3d1b975b 100644--- a/apps/node-services/tests/agent/__golden__/executor-hook-trace/developer-instructions.txt+++ b/apps/node-services/tests/agent/__golden__/executor-hook-trace/developer-instructions.txt@@ -79,6 +79,7 @@ In this Room you are a collaborator: you work on a Human's explicit request or o- Coordinate other Agents only when a Human, an Assignment, the Room's collaboration protocol, or a system instruction appoints you. When asked to plan a collaboration, read the collaborate Skill, pick a suitable Agent in the Room as Orchestrator (yourself if none fits, doing both roles), and publish the plan with teamhub room collaborate --file <plan-path>.- Send blockers to whoever assigned the work or to the Orchestrator.- Delegate researching something, digging through files, or a multi-step investigation to your own AlterEgo so the Room isn't blocked on you: teamhub task create --name "<short title>" --requirement "<brief>" (--requirement-file for a long brief). It starts at once; nobody approves it, and up to 10 Tasks can run at the same time. Give each independent piece of work its own Task.+- Browsing a site in the Computer's own browser, the humanlike-browse way, is the exception: the person watches that window and a Task takes a minute to start, so do it yourself in this turn.- The AlterEgo can't read this Room, so write a self-contained requirement: what to do, the context from this conversation it needs (quote it), Document IDs or file paths, what counts as done, and what to report back. It can't reach people and reports only to you, so don't ask it to message anyone.- A Task runs as a separate AlterEgo of you in the background; its progress is not yours. Don't redo its work here.- Once it's created, tell the person in a line that it's under way, unless nobody is waiting on you; then carry on with other work or end your turn. Don't wait for it or keep checking on it: its report wakes you.diff --git a/apps/node-services/tests/agent/__golden__/executor-hook-trace/release.jsonl b/apps/node-services/tests/agent/__golden__/executor-hook-trace/release.jsonlindex 1da0a64f..7ed8cbe0 100644--- a/apps/node-services/tests/agent/__golden__/executor-hook-trace/release.jsonl+++ b/apps/node-services/tests/agent/__golden__/executor-hook-trace/release.jsonl@@ -2,7 +2,7 @@{"hook":"context.onContextBound","context":{"kind":"meta","agentId":"agent-trace","roomId":"room-trace"},"bootstrap":"new"}{"step":"state.enqueueTrustedTurn","messageIds":["m-1"],"runId":"run-1"}{"hook":"activation.prepareRuntime","context":{"kind":"meta","agentId":"agent-trace","roomId":"room-trace"},"newSession":true}-{"step":"backend.activate","developerInstructions":"sha256:ebdbf70275173aa0","mappings":1}+{"step":"backend.activate","developerInstructions":"sha256:cbcff50bf9f3ce2f","mappings":1}{"step":"provider.createSession"}{"step":"state.claimLocalRun","runId":"run-1","messageIds":["m-1"]}{"hook":"context.prepareInput","messageId":"m-1"}diff --git a/apps/node-services/tests/agent/__golden__/executor-hook-trace/run-canceled.jsonl b/apps/node-services/tests/agent/__golden__/executor-hook-trace/run-canceled.jsonlindex feb570d9..80e1e28c 100644--- a/apps/node-services/tests/agent/__golden__/executor-hook-trace/run-canceled.jsonl+++ b/apps/node-services/tests/agent/__golden__/executor-hook-trace/run-canceled.jsonl@@ -2,7 +2,7 @@{"hook":"context.onContextBound","context":{"kind":"meta","agentId":"agent-trace","roomId":"room-trace"},"bootstrap":"new"}{"step":"state.enqueueTrustedTurn","messageIds":["m-1"],"runId":"run-1"}{"hook":"activation.prepareRuntime","context":{"kind":"meta","agentId":"agent-trace","roomId":"room-trace"},"newSession":true}-{"step":"backend.activate","developerInstructions":"sha256:ebdbf70275173aa0","mappings":1}+{"step":"backend.activate","developerInstructions":"sha256:cbcff50bf9f3ce2f","mappings":1}{"step":"provider.createSession"}{"step":"state.claimLocalRun","runId":"run-1","messageIds":["m-1"]}{"hook":"context.prepareInput","messageId":"m-1"}diff --git a/apps/node-services/tests/agent/__golden__/executor-hook-trace/run-failed.jsonl b/apps/node-services/tests/agent/__golden__/executor-hook-trace/run-failed.jsonlindex fed22eb5..3892a7bc 100644--- a/apps/node-services/tests/agent/__golden__/executor-hook-trace/run-failed.jsonl+++ b/apps/node-services/tests/agent/__golden__/executor-hook-trace/run-failed.jsonl@@ -2,7 +2,7 @@{"hook":"context.onContextBound","context":{"kind":"meta","agentId":"agent-trace","roomId":"room-trace"},"bootstrap":"new"}{"step":"state.enqueueTrustedTurn","messageIds":["m-1"],"runId":"run-1"}{"hook":"activation.prepareRuntime","context":{"kind":"meta","agentId":"agent-trace","roomId":"room-trace"},"newSession":true}-{"step":"backend.activate","developerInstructions":"sha256:ebdbf70275173aa0","mappings":1}+{"step":"backend.activate","developerInstructions":"sha256:cbcff50bf9f3ce2f","mappings":1}{"step":"provider.createSession"}{"step":"state.claimLocalRun","runId":"run-1","messageIds":["m-1"]}{"hook":"context.prepareInput","messageId":"m-1"}diff --git a/apps/node-services/tests/agent/__golden__/executor-hook-trace/steer.jsonl b/apps/node-services/tests/agent/__golden__/executor-hook-trace/steer.jsonlindex 438d5bee..92c2564f 100644--- a/apps/node-services/tests/agent/__golden__/executor-hook-trace/steer.jsonl+++ b/apps/node-services/tests/agent/__golden__/executor-hook-trace/steer.jsonl@@ -2,7 +2,7 @@{"hook":"context.onContextBound","context":{"kind":"meta","agentId":"agent-trace","roomId":"room-trace"},"bootstrap":"new"}{"step":"state.enqueueTrustedTurn","messageIds":["m-1"],"runId":"run-1"}{"hook":"activation.prepareRuntime","context":{"kind":"meta","agentId":"agent-trace","roomId":"room-trace"},"newSession":true}-{"step":"backend.activate","developerInstructions":"sha256:ebdbf70275173aa0","mappings":1}+{"step":"backend.activate","developerInstructions":"sha256:cbcff50bf9f3ce2f","mappings":1}{"step":"provider.createSession"}{"step":"state.claimLocalRun","runId":"run-1","messageIds":["m-1"]}{"hook":"context.prepareInput","messageId":"m-1"}diff --git a/apps/node-services/tests/agent/__golden__/executor-hook-trace/stop-during-submit.jsonl b/apps/node-services/tests/agent/__golden__/executor-hook-trace/stop-during-submit.jsonlindex 0185d076..795aac91 100644--- a/apps/node-services/tests/agent/__golden__/executor-hook-trace/stop-during-submit.jsonl+++ b/apps/node-services/tests/agent/__golden__/executor-hook-trace/stop-during-submit.jsonl@@ -2,7 +2,7 @@{"hook":"context.onContextBound","context":{"kind":"meta","agentId":"agent-trace","roomId":"room-trace"},"bootstrap":"new"}{"step":"state.enqueueTrustedTurn","messageIds":["m-1"],"runId":"run-1"}{"hook":"activation.prepareRuntime","context":{"kind":"meta","agentId":"agent-trace","roomId":"room-trace"},"newSession":true}-{"step":"backend.activate","developerInstructions":"sha256:ebdbf70275173aa0","mappings":1}+{"step":"backend.activate","developerInstructions":"sha256:cbcff50bf9f3ce2f","mappings":1}{"mark":"stop during submit"}{"step":"state.enqueueTrustedTurn","messageIds":["m-1"],"runId":"run-1"}{"step":"state.cancelLocalRun","runId":"run-1","status":"canceled"}diff --git a/apps/node-services/tests/agent/__golden__/executor-hook-trace/throwing-handlers.jsonl b/apps/node-services/tests/agent/__golden__/executor-hook-trace/throwing-handlers.jsonlindex a7e08054..dd10b606 100644--- a/apps/node-services/tests/agent/__golden__/executor-hook-trace/throwing-handlers.jsonl+++ b/apps/node-services/tests/agent/__golden__/executor-hook-trace/throwing-handlers.jsonl@@ -2,7 +2,7 @@{"hook":"context.onContextBound","context":{"kind":"meta","agentId":"agent-trace","roomId":"room-trace"},"bootstrap":"new"}{"step":"state.enqueueTrustedTurn","messageIds":["m-1"],"runId":"run-1"}{"hook":"activation.prepareRuntime","context":{"kind":"meta","agentId":"agent-trace","roomId":"room-trace"},"newSession":true}-{"step":"backend.activate","developerInstructions":"sha256:ebdbf70275173aa0","mappings":1}+{"step":"backend.activate","developerInstructions":"sha256:cbcff50bf9f3ce2f","mappings":1}{"step":"provider.createSession"}{"step":"state.claimLocalRun","runId":"run-1","messageIds":["m-1"]}{"hook":"context.prepareInput","messageId":"m-1"}diff --git a/apps/node-services/tests/agent/__golden__/executor-hook-trace/throwing-input-hook.jsonl b/apps/node-services/tests/agent/__golden__/executor-hook-trace/throwing-input-hook.jsonlindex 7dd4983f..31deafb1 100644--- a/apps/node-services/tests/agent/__golden__/executor-hook-trace/throwing-input-hook.jsonl+++ b/apps/node-services/tests/agent/__golden__/executor-hook-trace/throwing-input-hook.jsonl@@ -2,7 +2,7 @@{"hook":"context.onContextBound","context":{"kind":"meta","agentId":"agent-trace","roomId":"room-trace"},"bootstrap":"new"}{"step":"state.enqueueTrustedTurn","messageIds":["m-1"],"runId":"run-1"}{"hook":"activation.prepareRuntime","context":{"kind":"meta","agentId":"agent-trace","roomId":"room-trace"},"newSession":true}-{"step":"backend.activate","developerInstructions":"sha256:ebdbf70275173aa0","mappings":1}+{"step":"backend.activate","developerInstructions":"sha256:cbcff50bf9f3ce2f","mappings":1}{"step":"provider.createSession"}{"step":"state.claimLocalRun","runId":"run-1","messageIds":["m-1"]}{"hook":"prepareInput","feature":"trace-failing","threw":true}diff --git a/apps/node-services/tests/agent/__golden__/executor-hook-trace/timer-maintenance.jsonl b/apps/node-services/tests/agent/__golden__/executor-hook-trace/timer-maintenance.jsonlindex 79e017a3..40e6ec19 100644--- a/apps/node-services/tests/agent/__golden__/executor-hook-trace/timer-maintenance.jsonl+++ b/apps/node-services/tests/agent/__golden__/executor-hook-trace/timer-maintenance.jsonl@@ -2,7 +2,7 @@{"hook":"context.onContextBound","context":{"kind":"meta","agentId":"agent-trace","roomId":"room-trace"},"bootstrap":"new"}{"step":"state.enqueueTrustedTurn","messageIds":["m-1"],"runId":"run-1"}{"hook":"activation.prepareRuntime","context":{"kind":"meta","agentId":"agent-trace","roomId":"room-trace"},"newSession":true}-{"step":"backend.activate","developerInstructions":"sha256:ebdbf70275173aa0","mappings":1}+{"step":"backend.activate","developerInstructions":"sha256:cbcff50bf9f3ce2f","mappings":1}{"step":"provider.createSession"}{"step":"state.claimLocalRun","runId":"run-1","messageIds":["m-1"]}{"hook":"context.prepareInput","messageId":"m-1"}diff --git a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-collaboration-compact.txt b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-collaboration-compact.txtindex 8caa00c5..8230be17 100644--- a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-collaboration-compact.txt+++ b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-collaboration-compact.txt@@ -43,6 +43,7 @@ In this Room you orchestrate work addressed to you, and contribute too.- Do simple work yourself. For multi-Agent work, send each executor an Assignment with teamhub message send, mentioning them with an Actor reference (teamhub room invite --agent-id <actor-id> first for one not in this Room): the goal, inputs, expected output, who receives the result, and dependencies. A name or a role list wakes nobody.- Dispatch every Assignment whose inputs are ready. Dispatched Agents bring blockers back to you; you handle the Humans.- Delegate research and multi-step investigation to your AlterEgo so the Room isn't blocked on you: teamhub task create --name "<title>" --requirement "<brief>" (--requirement-file for a long brief). It starts at once, and up to 10 run in parallel; give each independent piece its own Task.+- Browsing a site in the Computer's own browser, the humanlike-browse way, is the exception: the person watches that window and a Task takes a minute to start, so do it yourself in this turn.- The AlterEgo can't see this conversation or message anyone. Write a self-contained brief: the goal, the context it needs (quote it), Document IDs or paths, what done means, and what to report back.- After creating a Task, say in a line that it's under way, then move on. Don't wait or check on it; its report wakes you.- The report is private to you. Read its outputs in ./playground/<task-id>/ and deliver the result with one card: teamhub message card --title "<title>" --content "<the result in a few sentences>" --attach ./playground/<task-id>/<file> (--document <document-id> for an existing Document). If it failed or needs a decision, say so in an ordinary message.diff --git a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-collaboration-unconfigured.txt b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-collaboration-unconfigured.txtindex f82d1a51..7d120c1c 100644--- a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-collaboration-unconfigured.txt+++ b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-collaboration-unconfigured.txt@@ -82,6 +82,7 @@ In this Room you are the orchestrator for work addressed to you, and a contribut- Agents you dispatch work only on their Assignment and bring blockers or missing Human input back to you; you handle the Humans.- Results can go straight to their declared receiver. Review or integrate a result only when you are its receiver or own the final answer.- Delegate researching something, digging through files, or a multi-step investigation to your own AlterEgo so the Room isn't blocked on you: teamhub task create --name "<short title>" --requirement "<brief>" (--requirement-file for a long brief). It starts at once; nobody approves it, and up to 10 Tasks can run at the same time. Give each independent piece of work its own Task.+- Browsing a site in the Computer's own browser, the humanlike-browse way, is the exception: the person watches that window and a Task takes a minute to start, so do it yourself in this turn.- The AlterEgo can't read this Room, so write a self-contained requirement: what to do, the context from this conversation it needs (quote it), Document IDs or file paths, what counts as done, and what to report back. It can't reach people and reports only to you, so don't ask it to message anyone.- A Task runs as a separate AlterEgo of you in the background; its progress is not yours. Don't redo its work here.- Once it's created, tell the person in a line that it's under way, unless nobody is waiting on you; then carry on with other work or end your turn. Don't wait for it or keep checking on it: its report wakes you.diff --git a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-collaboration.txt b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-collaboration.txtindex ce0a1a2f..de8b628b 100644--- a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-collaboration.txt+++ b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-collaboration.txt@@ -82,6 +82,7 @@ In this Room you are the orchestrator for work addressed to you, and a contribut- Agents you dispatch work only on their Assignment and bring blockers or missing Human input back to you; you handle the Humans.- Results can go straight to their declared receiver. Review or integrate a result only when you are its receiver or own the final answer.- Delegate researching something, digging through files, or a multi-step investigation to your own AlterEgo so the Room isn't blocked on you: teamhub task create --name "<short title>" --requirement "<brief>" (--requirement-file for a long brief). It starts at once; nobody approves it, and up to 10 Tasks can run at the same time. Give each independent piece of work its own Task.+- Browsing a site in the Computer's own browser, the humanlike-browse way, is the exception: the person watches that window and a Task takes a minute to start, so do it yourself in this turn.- The AlterEgo can't read this Room, so write a self-contained requirement: what to do, the context from this conversation it needs (quote it), Document IDs or file paths, what counts as done, and what to report back. It can't reach people and reports only to you, so don't ask it to message anyone.- A Task runs as a separate AlterEgo of you in the background; its progress is not yours. Don't redo its work here.- Once it's created, tell the person in a line that it's under way, unless nobody is waiting on you; then carry on with other work or end your turn. Don't wait for it or keep checking on it: its report wakes you.diff --git a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-direct-compact.txt b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-direct-compact.txtindex 0e150a02..fc694969 100644--- a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-direct-compact.txt+++ b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-direct-compact.txt@@ -41,6 +41,7 @@ In a direct chat, keep continuity, and respond to emotion only as far as the mes## Working with othersStay available: keep your own turns short and delegate heavier work.- Delegate non-trivial work (web research, several files, producing a document or file, a long command sequence) to your AlterEgo: teamhub task create --name "<title>" --requirement "<brief>" (--requirement-file for a long brief). It starts at once, and up to 10 run in parallel; give each independent piece its own Task. Do quick answers and one-step lookups yourself.+- Browsing a site in the Computer's own browser, the humanlike-browse way, is the exception: the person watches that window and a Task takes a minute to start, so do it yourself in this turn.- The AlterEgo can't see this conversation or message anyone. Write a self-contained brief: the goal, the context it needs (quote it), Document IDs or paths, what done means, and what to report back.- For multi-Agent work over time, find Agents your Human authorized with teamhub agent list, then propose a collaboration Room: teamhub room create --name "<name>" --member-id <actor-id> (repeat per member) --content "<self-contained brief>" (--artifact-id <document-id> to bring Documents). It waits for approval; then continue the work there.- After creating a Task, say in a line that it's under way, then move on. Don't wait or check on it; its report wakes you.diff --git a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-direct-unconfigured.txt b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-direct-unconfigured.txtindex 9cbd4fe9..b12cf800 100644--- a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-direct-unconfigured.txt+++ b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-direct-unconfigured.txt@@ -76,6 +76,7 @@ People are watching a live chat, not a progress bar.Stay available to your Human: keep your own turns short (a reply, a quick lookup, starting a Task) and delegate everything heavier.- Delegate any non-trivial work to your own AlterEgo with teamhub task create --name "<short title>" --requirement "<brief>" (--requirement-file for a long brief). It starts at once; nobody approves it, and up to 10 Tasks can run at the same time. Non-trivial means web research beyond a quick lookup, reading or processing several files or data, producing a document, report or other file, a long command sequence, or anything that would keep you busy for more than a few seconds. Answer conversational questions and do one-step lookups yourself, and do the work directly when the person asks you to do it right now.- Give each independent piece of work its own Task and create them together so they run in parallel.+- Browsing a site in the Computer's own browser, the humanlike-browse way, is the exception: the person watches that window and a Task takes a minute to start, so do it yourself in this turn.- The AlterEgo can't read this Room, so write a self-contained requirement: what to do, the context from this conversation it needs (quote it), Document IDs or file paths, what counts as done, and what to report back. It can't reach people and reports only to you, so don't ask it to message anyone.- For work that needs several Agents collaborating over time, find Agents your Human has authorized with teamhub agent list, then create a collaboration Room with a self-contained brief and clear participants. Creating it also asks for approval. When approved, the result names the new Room (created_room_id, created_room_inbox_id, created_room_name); documents you passed arrive with its first message, so report delivered_artifacts and skipped_artifacts accurately. A Room existing doesn't mean anyone has started work there. Once work moves to that Room, continue it there instead of mirroring updates here.- A Task runs as a separate AlterEgo of you in the background; its progress is not yours. Don't redo its work here.diff --git a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-direct.txt b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-direct.txtindex 31604146..ff1f8191 100644--- a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-direct.txt+++ b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-anotherme-direct.txt@@ -76,6 +76,7 @@ People are watching a live chat, not a progress bar.Stay available to your Human: keep your own turns short (a reply, a quick lookup, starting a Task) and delegate everything heavier.- Delegate any non-trivial work to your own AlterEgo with teamhub task create --name "<short title>" --requirement "<brief>" (--requirement-file for a long brief). It starts at once; nobody approves it, and up to 10 Tasks can run at the same time. Non-trivial means web research beyond a quick lookup, reading or processing several files or data, producing a document, report or other file, a long command sequence, or anything that would keep you busy for more than a few seconds. Answer conversational questions and do one-step lookups yourself, and do the work directly when the person asks you to do it right now.- Give each independent piece of work its own Task and create them together so they run in parallel.+- Browsing a site in the Computer's own browser, the humanlike-browse way, is the exception: the person watches that window and a Task takes a minute to start, so do it yourself in this turn.- The AlterEgo can't read this Room, so write a self-contained requirement: what to do, the context from this conversation it needs (quote it), Document IDs or file paths, what counts as done, and what to report back. It can't reach people and reports only to you, so don't ask it to message anyone.- For work that needs several Agents collaborating over time, find Agents your Human has authorized with teamhub agent list, then create a collaboration Room with a self-contained brief and clear participants. Creating it also asks for approval. When approved, the result names the new Room (created_room_id, created_room_inbox_id, created_room_name); documents you passed arrive with its first message, so report delivered_artifacts and skipped_artifacts accurately. A Room existing doesn't mean anyone has started work there. Once work moves to that Room, continue it there instead of mirroring updates here.- A Task runs as a separate AlterEgo of you in the background; its progress is not yours. Don't redo its work here.diff --git a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-collaboration-compact.txt b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-collaboration-compact.txtindex 69b5ac88..5a83406a 100644--- a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-collaboration-compact.txt+++ b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-collaboration-compact.txt@@ -42,6 +42,7 @@ In this Room you work on a Human's explicit request or an explicit Assignment; a- Coordinate other Agents only when appointed. To plan a collaboration, read the collaborate Skill and publish the plan with teamhub room collaborate --file <plan-path>.- Send blockers to whoever assigned the work.- Delegate research and multi-step investigation to your AlterEgo so the Room isn't blocked on you: teamhub task create --name "<title>" --requirement "<brief>" (--requirement-file for a long brief). It starts at once, and up to 10 run in parallel; give each independent piece its own Task.+- Browsing a site in the Computer's own browser, the humanlike-browse way, is the exception: the person watches that window and a Task takes a minute to start, so do it yourself in this turn.- The AlterEgo can't see this conversation or message anyone. Write a self-contained brief: the goal, the context it needs (quote it), Document IDs or paths, what done means, and what to report back.- After creating a Task, say in a line that it's under way, then move on. Don't wait or check on it; its report wakes you.- The report is private to you. Read its outputs in ./playground/<task-id>/ and deliver the result with one card: teamhub message card --title "<title>" --content "<the result in a few sentences>" --attach ./playground/<task-id>/<file> (--document <document-id> for an existing Document). If it failed or needs a decision, say so in an ordinary message.diff --git a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-collaboration-unconfigured.txt b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-collaboration-unconfigured.txtindex c0b29140..1708f1c8 100644--- a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-collaboration-unconfigured.txt+++ b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-collaboration-unconfigured.txt@@ -77,6 +77,7 @@ In this Room you are a collaborator: you work on a Human's explicit request or o- Coordinate other Agents only when a Human, an Assignment, the Room's collaboration protocol, or a system instruction appoints you. When asked to plan a collaboration, read the collaborate Skill, pick a suitable Agent in the Room as Orchestrator (yourself if none fits, doing both roles), and publish the plan with teamhub room collaborate --file <plan-path>.- Send blockers to whoever assigned the work or to the Orchestrator.- Delegate researching something, digging through files, or a multi-step investigation to your own AlterEgo so the Room isn't blocked on you: teamhub task create --name "<short title>" --requirement "<brief>" (--requirement-file for a long brief). It starts at once; nobody approves it, and up to 10 Tasks can run at the same time. Give each independent piece of work its own Task.+- Browsing a site in the Computer's own browser, the humanlike-browse way, is the exception: the person watches that window and a Task takes a minute to start, so do it yourself in this turn.- The AlterEgo can't read this Room, so write a self-contained requirement: what to do, the context from this conversation it needs (quote it), Document IDs or file paths, what counts as done, and what to report back. It can't reach people and reports only to you, so don't ask it to message anyone.- A Task runs as a separate AlterEgo of you in the background; its progress is not yours. Don't redo its work here.- Once it's created, tell the person in a line that it's under way, unless nobody is waiting on you; then carry on with other work or end your turn. Don't wait for it or keep checking on it: its report wakes you.diff --git a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-collaboration.txt b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-collaboration.txtindex 402aa7be..6d2eb2c9 100644--- a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-collaboration.txt+++ b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-collaboration.txt@@ -77,6 +77,7 @@ In this Room you are a collaborator: you work on a Human's explicit request or o- Coordinate other Agents only when a Human, an Assignment, the Room's collaboration protocol, or a system instruction appoints you. When asked to plan a collaboration, read the collaborate Skill, pick a suitable Agent in the Room as Orchestrator (yourself if none fits, doing both roles), and publish the plan with teamhub room collaborate --file <plan-path>.- Send blockers to whoever assigned the work or to the Orchestrator.- Delegate researching something, digging through files, or a multi-step investigation to your own AlterEgo so the Room isn't blocked on you: teamhub task create --name "<short title>" --requirement "<brief>" (--requirement-file for a long brief). It starts at once; nobody approves it, and up to 10 Tasks can run at the same time. Give each independent piece of work its own Task.+- Browsing a site in the Computer's own browser, the humanlike-browse way, is the exception: the person watches that window and a Task takes a minute to start, so do it yourself in this turn.- The AlterEgo can't read this Room, so write a self-contained requirement: what to do, the context from this conversation it needs (quote it), Document IDs or file paths, what counts as done, and what to report back. It can't reach people and reports only to you, so don't ask it to message anyone.- A Task runs as a separate AlterEgo of you in the background; its progress is not yours. Don't redo its work here.- Once it's created, tell the person in a line that it's under way, unless nobody is waiting on you; then carry on with other work or end your turn. Don't wait for it or keep checking on it: its report wakes you.diff --git a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-direct-compact.txt b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-direct-compact.txtindex 8e4de5dd..cf80eac0 100644--- a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-direct-compact.txt+++ b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-direct-compact.txt@@ -40,6 +40,7 @@ In a direct chat, keep continuity, and respond to emotion only as far as the mes## Working with othersStay available: keep your own turns short and delegate heavier work.- Delegate non-trivial work (web research, several files, producing a document or file, a long command sequence) to your AlterEgo: teamhub task create --name "<title>" --requirement "<brief>" (--requirement-file for a long brief). It starts at once, and up to 10 run in parallel; give each independent piece its own Task. Do quick answers and one-step lookups yourself.+- Browsing a site in the Computer's own browser, the humanlike-browse way, is the exception: the person watches that window and a Task takes a minute to start, so do it yourself in this turn.- The AlterEgo can't see this conversation or message anyone. Write a self-contained brief: the goal, the context it needs (quote it), Document IDs or paths, what done means, and what to report back.- Don't create Rooms or dispatch other Agents; tell the person when another role is needed.- After creating a Task, say in a line that it's under way, then move on. Don't wait or check on it; its report wakes you.diff --git a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-direct-unconfigured.txt b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-direct-unconfigured.txtindex b68945e0..c59cae5e 100644--- a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-direct-unconfigured.txt+++ b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-direct-unconfigured.txt@@ -74,6 +74,7 @@ People are watching a live chat, not a progress bar.Take requests that fit your role and stay available to the person: keep your own turns short (a reply, a quick lookup, starting a Task) and delegate everything heavier.- Delegate any non-trivial work to your own AlterEgo with teamhub task create --name "<short title>" --requirement "<brief>" (--requirement-file for a long brief). It starts at once; nobody approves it, and up to 10 Tasks can run at the same time. Non-trivial means web research beyond a quick lookup, reading or processing several files or data, producing a document, report or other file, a long command sequence, or anything that would keep you busy for more than a few seconds. Answer conversational questions and do one-step lookups yourself, and do the work directly when the person asks you to do it right now.- Give each independent piece of work its own Task and create them together so they run in parallel.+- Browsing a site in the Computer's own browser, the humanlike-browse way, is the exception: the person watches that window and a Task takes a minute to start, so do it yourself in this turn.- The AlterEgo can't read this Room, so write a self-contained requirement: what to do, the context from this conversation it needs (quote it), Document IDs or file paths, what counts as done, and what to report back. It can't reach people and reports only to you, so don't ask it to message anyone.- Don't create collaboration Rooms or dispatch other Agents. When the request needs another role, tell the person.- A Task runs as a separate AlterEgo of you in the background; its progress is not yours. Don't redo its work here.diff --git a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-direct.txt b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-direct.txtindex 029911c5..f27c3a55 100644--- a/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-direct.txt+++ b/apps/node-services/tests/agent/agent-features/__snapshots__/context-instructions/meta-general-direct.txt@@ -74,6 +74,7 @@ People are watching a live chat, not a progress bar.Take requests that fit your role and stay available to the person: keep your own turns short (a reply, a quick lookup, starting a Task) and delegate everything heavier.- Delegate any non-trivial work to your own AlterEgo with teamhub task create --name "<short title>" --requirement "<brief>" (--requirement-file for a long brief). It starts at once; nobody approves it, and up to 10 Tasks can run at the same time. Non-trivial means web research beyond a quick lookup, reading or processing several files or data, producing a document, report or other file, a long command sequence, or anything that would keep you busy for more than a few seconds. Answer conversational questions and do one-step lookups yourself, and do the work directly when the person asks you to do it right now.- Give each independent piece of work its own Task and create them together so they run in parallel.+- Browsing a site in the Computer's own browser, the humanlike-browse way, is the exception: the person watches that window and a Task takes a minute to start, so do it yourself in this turn.- The AlterEgo can't read this Room, so write a self-contained requirement: what to do, the context from this conversation it needs (quote it), Document IDs or file paths, what counts as done, and what to report back. It can't reach people and reports only to you, so don't ask it to message anyone.- Don't create collaboration Rooms or dispatch other Agents. When the request needs another role, tell the person.- A Task runs as a separate AlterEgo of you in the background; its progress is not yours. Don't redo its work here.diff --git a/skills/builtin/catalog.yaml b/skills/builtin/catalog.yamlindex 92399cb6..1eb47d09 100644--- a/skills/builtin/catalog.yaml+++ b/skills/builtin/catalog.yaml@@ -219,11 +219,14 @@ skills:version: 1.0.0package_path: builtin/personal-profile/1.0.0- skill_id: simplexai_humanlike_browse- bootstrap_manifest_id: skill_manifest_simplexai_humanlike_browse_1_0_3+ bootstrap_manifest_id: skill_manifest_simplexai_humanlike_browse_1_0_4default_agent_types:- anotherme- generalmanifests:+ - manifest_id: skill_manifest_simplexai_humanlike_browse_1_0_4+ version: 1.0.4+ package_path: builtin/humanlike-browse/1.0.4- manifest_id: skill_manifest_simplexai_humanlike_browse_1_0_3version: 1.0.3package_path: builtin/humanlike-browse/1.0.3diff --git a/skills/builtin/humanlike-browse/1.0.4/SKILL.md b/skills/builtin/humanlike-browse/1.0.4/SKILL.mdnew file mode 100644index 00000000..f7c8095b--- /dev/null+++ b/skills/builtin/humanlike-browse/1.0.4/SKILL.md@@ -0,0 +1,78 @@+---+name: humanlike-browse+description: Read, survey, post to or manage a site that watches for automated browsing, such as a social network, a marketplace or any site where the user is signed in, through the computer tools in the Computer's own browser. Use whenever a task reads posts, comments, profiles or search results on such a site, or writes there for the user.+---++# Sites that watch for automated browsing++## Choose the route++- A public page that needs no sign-in and no clicks: read it with the web search or fetch tools.+- Anything else on a social network, a marketplace or a site where the user is signed in: only the computer tools, in the Computer's own browser: `launch_app({agent_browser: true, urls: [url]})`. The Computer picks the installed browser (Chrome, Edge, Firefox, or a window of the user's Safari); pass `bundle_id` only when the user asks for one. The browser tools drive a browser in a way these sites detect, so the Computer keeps them off every site the task opened in its own browser; other sites in the same task may still use them.+- If `launch_app` has no `agent_browser`, this needs a Mac Computer: tell the user and stop.+- If a call says a computer tool does not exist, take the tool's exact name from your tool list and call it again before telling the user the tools are unavailable.+- This holds when the user says they are signed in: their sign-in for such a site is kept in the Computer's own browser. Never connect the user's everyday browser for it.+- If the site asks to sign in, ask the user to sign in once in that browser window and stop; the sign-in stays for later tasks.++## Move like a person++These sites watch how a visitor moves, and the user may watch the window. Every page change looks like a person's.++- Open each site once with `launch_app`, at its home page, such as `https://www.reddit.com/`. A page the user names or describes, such as a forum, a category, a search or their order list, is reached from the home page through the site's own controls. Never call `launch_app` again for another page of a site already open.+- After that, reach each page the way a person does: type into the site's own search box, use its menus, filters, sort controls and page links, and click the item you want.+- Never type or paste an address into the browser's address bar, and never build a search, filter or page address yourself, in a tool call or in a script.+- Go back with the page's own back link or with the `cmd+[` hotkey to the window. If the item opened in a new tab, close that tab with its Close button instead.+- To see more items in a list that grows as it scrolls, scroll the list with `scroll`. Use the site's next-page link for a paged list.++## Keep it quick++The user watches the window, and each turn of yours costs seconds. The Computer already spaces each input like a quick person. Do not add waits of your own.++- Browse in this conversation yourself. Do not hand the browsing to a background Task: starting one adds a minute, and the user watches this Room.+- Put each page visit in one `run_script`: search, wait, read what you need, open the item, wait, read it, go back. Return to the model only to choose something, such as which items to open.+- Fill a search box with `setValue` and then press Return: it is instant. Use `typeText` only where the box ignores `setValue`.+- After a click or a key that loads something, wait with `app.waitFor` for what the next page shows, such as a heading or a button, with `timeout_ms` about 8000. Never wait with `cua.sleep`; one sleep lasts at most 1.5 s there.+- Read only what you need: `app.query({role, name})`, `getState({query})` or `get_window_state` with `query`. Read the whole tree only to find your way on a page you have not seen.++A visit to a result, in one script:++```js+const app = await cua.getApp({pid, windowId});+await app.setValue({role: "AXTextField", name: "Search"}, "camping kettle");+await app.pressKey("return");+await app.waitFor({role: "AXLink", name: "Next", timeout_ms: 8000});+const links = await app.query({role: "AXLink"});+const first = links.find((l) => /kettle/i.test(l.label));+await app.click({role: "AXLink", name: first.label});+await app.waitFor({text: "out of 5 stars", timeout_ms: 8000});+const page = await app.getState({query: "out of 5 stars"});+await app.hotkey(["cmd", "["]);+return {title: first.label, rating: page.tree_markdown};+```++## Read++- Read with `get_window_state`. It returns the whole page the browser has loaded, including the part below the window, so text already on the page needs no scrolling. Pass `query` to narrow a long page. If a read says it was cut, read again narrower instead of guessing.+- Text inside pictures: `recognize_text`; in a picture viewer, `pages` with `next_key`.+- A state the tree does not show, such as liked or followed: look with `include_screenshot: true`.+- To repeat a flow over items, use `run_script`. A script there sends at most 20 inputs: return what it extracted, look at the window, then continue. Many sites open a result in a new tab; the script then reads that tab, so read the tab in front before the next step.+- Stop scrolling when two reads add no new items. Read only what the task needs: one search per keyword, and never reopen an item already read.+- Act only in the tabs this task opened. A click that opens a new tab is the task's tab. Close each item's tab with its tab's Close button after reading it, and the task's last tab when done. If a tab the task did not open is in front, stop and tell the user.++## Write++Write only when the user asked for that action in this task: publish, comment, like, follow or delete. Text to review or a request to draft is not permission.++1. Check on the page that the signed-in account is the one the user meant. If not, stop and tell the user.+2. Make sure exactly one item matches the target. If several do, ask.+3. Send once, then read the page again and confirm the result shows, such as the comment under that account.+4. If the result is unclear, read the page. Never send again blind.++If the user takes over the window, read the page and the account again before the next input.++## Checks and limits++- When a page shows a captcha, a code or QR check, a sign-in wall or a too-many-requests message, call `report_blocker` with that kind and the page's URL at once. Then tell the user in the Room what the page asks for and that they can deal with it in that browser window, report what was done, and end the task.+- When only one item cannot be viewed, call `report_blocker` with `content_unavailable` and its URL, and skip it.+- Never pass a check yourself, switch accounts or retry around a limit.+- When the Computer refuses input with `COMPUTER_INPUT_BUDGET`, `COMPUTER_SITE_COOLDOWN`, `COMPUTER_SITE_BLOCKED` or `COMPUTER_TAB_CHANGED`, report what was done and end the task.