Skip to content

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.

refactor(computer): drop the unreachable direct-input binding path

jeffreyd980f69d3e6e
diff --git a/apps/computer/local-daemon/README.md b/apps/computer/local-daemon/README.md
index a46b8ebf..735bf6ba 100644
--- a/apps/computer/local-daemon/README.md
+++ b/apps/computer/local-daemon/README.md
@@ -328,7 +328,8 @@ QuickJS compiled to WebAssembly. A separate engine compiles the script. The
execution engine has no filesystem, network, process or module loader, and it
rejects dynamic code evaluation. The Daemon limits memory, runtime, call count
and output. Only the explicit `state` object is intended to persist between
-calls within one Operation. `ui_reset` discards this state and image handles.
+calls within one Operation. An uncaught script error resets `state`, so a
+script catches the failures it expects. `ui_reset` discards this state and image handles.
Applications and action records survive a reset. An unknown write outcome
blocks further writes to its driver in this Operation. Every `ui_exec` and
`ui_reset` result lists the Operation's unknown actions. Retained images share
diff --git a/apps/computer/local-daemon/internal/daemon/daemon.go b/apps/computer/local-daemon/internal/daemon/daemon.go
index adac90e0..d22f5b7a 100644
--- a/apps/computer/local-daemon/internal/daemon/daemon.go
+++ b/apps/computer/local-daemon/internal/daemon/daemon.go
@@ -81,6 +81,8 @@ type LocalSkillCatalog interface {
type LocalToolBinder interface {
Bind(context.Context, provider.OperationSpec, mcpproxy.OperationIdentity, *mcpproxy.Set) error
+ // BindUI runs after Bind and publishes the script entry over its drivers.
+ BindUI(context.Context, provider.OperationSpec, mcpproxy.OperationIdentity, *mcpproxy.Set) error
}
// localToolPrewarmer is optional: a LocalToolBinder that can discover its tool
diff --git a/apps/computer/local-daemon/internal/daemon/local_tools_test.go b/apps/computer/local-daemon/internal/daemon/local_tools_test.go
index 8d20d667..a51f6168 100644
--- a/apps/computer/local-daemon/internal/daemon/local_tools_test.go
+++ b/apps/computer/local-daemon/internal/daemon/local_tools_test.go
@@ -21,6 +21,10 @@ import (
type localToolBinderFunc func(context.Context, provider.OperationSpec, mcpproxy.OperationIdentity, *mcpproxy.Set) error
+func (localToolBinderFunc) BindUI(context.Context, provider.OperationSpec, mcpproxy.OperationIdentity, *mcpproxy.Set) error {
+ return nil
+}
+
func (f localToolBinderFunc) Bind(ctx context.Context, spec provider.OperationSpec, identity mcpproxy.OperationIdentity, set *mcpproxy.Set) error {
return f(ctx, spec, identity, set)
}
@@ -70,6 +74,10 @@ type prewarmingLocalTools struct {
ctxs chan context.Context
}
+func (*prewarmingLocalTools) BindUI(context.Context, provider.OperationSpec, mcpproxy.OperationIdentity, *mcpproxy.Set) error {
+ return nil
+}
+
func (p *prewarmingLocalTools) Bind(context.Context, provider.OperationSpec, mcpproxy.OperationIdentity, *mcpproxy.Set) error {
return nil
}
diff --git a/apps/computer/local-daemon/internal/daemon/operation_start_accepted_test.go b/apps/computer/local-daemon/internal/daemon/operation_start_accepted_test.go
index a25aa18e..50474591 100644
--- a/apps/computer/local-daemon/internal/daemon/operation_start_accepted_test.go
+++ b/apps/computer/local-daemon/internal/daemon/operation_start_accepted_test.go
@@ -26,6 +26,10 @@ type blockingBinder struct {
err error
}
+func (*blockingBinder) BindUI(context.Context, provider.OperationSpec, mcpproxy.OperationIdentity, *mcpproxy.Set) error {
+ return nil
+}
+
func (b *blockingBinder) Bind(ctx context.Context, _ provider.OperationSpec, identity mcpproxy.OperationIdentity, set *mcpproxy.Set) error {
if identity.OperationID != b.operationID {
return nil
diff --git a/apps/computer/local-daemon/internal/daemon/operation_start_prepare.go b/apps/computer/local-daemon/internal/daemon/operation_start_prepare.go
index 938dac7f..b6713706 100644
--- a/apps/computer/local-daemon/internal/daemon/operation_start_prepare.go
+++ b/apps/computer/local-daemon/internal/daemon/operation_start_prepare.go
@@ -40,12 +40,8 @@ func (d *Daemon) openOperationMCP(ctx context.Context, spec provider.OperationSp
if err := d.localTools.Bind(ctx, spec, identity, proxies); err != nil {
return nil, errors.Join(err, proxies.Close())
}
- if unified, ok := d.localTools.(interface {
- BindUI(context.Context, provider.OperationSpec, mcpproxy.OperationIdentity, *mcpproxy.Set) error
- }); ok {
- if err := unified.BindUI(ctx, spec, identity, proxies); err != nil {
- return nil, errors.Join(err, proxies.Close())
- }
+ if err := d.localTools.BindUI(ctx, spec, identity, proxies); err != nil {
+ return nil, errors.Join(err, proxies.Close())
}
}
return proxies, nil
diff --git a/apps/computer/local-daemon/internal/linger/localtools/installation.go b/apps/computer/local-daemon/internal/linger/localtools/installation.go
index 0f0e9307..e1fac340 100644
--- a/apps/computer/local-daemon/internal/linger/localtools/installation.go
+++ b/apps/computer/local-daemon/internal/linger/localtools/installation.go
@@ -10,13 +10,11 @@ import (
"strings"
)
+// quickJSAssets are the engine files the UI runtime loads directly. The
+// bundler owns the engine's complete file list.
var quickJSAssets = []string{
- "node_modules/quickjs-wasi/package.json",
"node_modules/quickjs-wasi/quickjs.wasm",
"node_modules/quickjs-wasi/dist/index.js",
- "node_modules/quickjs-wasi/dist/extensions.js",
- "node_modules/quickjs-wasi/dist/version.js",
- "node_modules/quickjs-wasi/dist/wasi-shim.js",
}
type Installation struct{ NodePath, PlaywrightEntry, PiExtension, CuaPath string }
diff --git a/apps/computer/local-daemon/internal/linger/localtools/localtools_test.go b/apps/computer/local-daemon/internal/linger/localtools/localtools_test.go
index e2c2ecdd..2a5b9e2d 100644
--- a/apps/computer/local-daemon/internal/linger/localtools/localtools_test.go
+++ b/apps/computer/local-daemon/internal/linger/localtools/localtools_test.go
@@ -617,7 +617,7 @@ func TestLocalToolServerPreparationRevocationAndImage(t *testing.T) {
}}, []tool{{Name: "screenshot", InputSchema: json.RawMessage(`{"type":"object"}`)}}, func(context.Context, string, json.RawMessage) (json.RawMessage, error) {
calls++
return json.RawMessage(`{"content":[{"type":"image","mimeType":"image/png","data":"` + strings.Repeat("A", 2*1024*1024) + `"}]}`), nil
- })
+ }, mcpproxy.LocalToolTimeout)
if err != nil {
t.Fatal(err)
}
diff --git a/apps/computer/local-daemon/internal/linger/localtools/manager.go b/apps/computer/local-daemon/internal/linger/localtools/manager.go
index ccf6d19f..0728517e 100644
--- a/apps/computer/local-daemon/internal/linger/localtools/manager.go
+++ b/apps/computer/local-daemon/internal/linger/localtools/manager.go
@@ -294,7 +294,7 @@ func (m *Manager) Bind(ctx context.Context, spec provider.OperationSpec, identit
}{
{"computer", computerTools, computerCall, op.computerEvidence, nil}, {"browser", browserTools, browserCall, op.browserEvidence, op.browserAllowed},
} {
- server, err := openToolServer(opCtx, identity, binding.tools, op.wrap(binding.call))
+ server, err := openToolServer(opCtx, identity, binding.tools, op.wrap(binding.call), mcpproxy.LocalToolTimeout)
if err != nil {
return errors.Join(err, op.close())
}
diff --git a/apps/computer/local-daemon/internal/linger/localtools/server.go b/apps/computer/local-daemon/internal/linger/localtools/server.go
index 46d8c735..67a2cafa 100644
--- a/apps/computer/local-daemon/internal/linger/localtools/server.go
+++ b/apps/computer/local-daemon/internal/linger/localtools/server.go
@@ -33,16 +33,12 @@ type toolServer struct {
timeout time.Duration
}
-func openToolServer(ctx context.Context, identity mcpproxy.OperationIdentity, tools []tool, call func(context.Context, string, json.RawMessage) (json.RawMessage, error), timeouts ...time.Duration) (*toolServer, error) {
+func openToolServer(ctx context.Context, identity mcpproxy.OperationIdentity, tools []tool, call func(context.Context, string, json.RawMessage) (json.RawMessage, error), timeout time.Duration) (*toolServer, error) {
listener, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
return nil, err
}
- s := &toolServer{path: "/mcp/" + rand.Text(), tools: tools, identity: identity, ctx: ctx, call: call, ready: make(chan struct{}), slots: make(chan struct{}, 16), calls: make(map[string]context.CancelFunc)}
- s.timeout = mcpproxy.LocalToolTimeout
- if len(timeouts) == 1 && timeouts[0] > 0 {
- s.timeout = timeouts[0]
- }
+ s := &toolServer{path: "/mcp/" + rand.Text(), tools: tools, identity: identity, ctx: ctx, call: call, ready: make(chan struct{}), slots: make(chan struct{}, 16), calls: make(map[string]context.CancelFunc), timeout: timeout}
s.url = "http://" + listener.Addr().String() + s.path
s.server = &http.Server{Handler: http.HandlerFunc(s.handle), ReadHeaderTimeout: 5 * time.Second}
go func() { _ = s.server.Serve(listener) }()
@@ -256,11 +252,7 @@ func schedulingError(ctx context.Context) error {
return nil
}
-func toolCallBudget(request *http.Request, maximum ...time.Duration) (time.Duration, error) {
- budget := mcpproxy.LocalToolTimeout
- if len(maximum) == 1 && maximum[0] > 0 {
- budget = maximum[0]
- }
+func toolCallBudget(request *http.Request, budget time.Duration) (time.Duration, error) {
if values := request.Header.Values("X-Linger-Tool-Budget-Ms"); len(values) > 0 {
if len(values) != 1 {
return 0, errors.New("Invalid local tool time budget")
diff --git a/apps/computer/local-daemon/internal/linger/localtools/server_cancellation_test.go b/apps/computer/local-daemon/internal/linger/localtools/server_cancellation_test.go
index ef47738e..b236a494 100644
--- a/apps/computer/local-daemon/internal/linger/localtools/server_cancellation_test.go
+++ b/apps/computer/local-daemon/internal/linger/localtools/server_cancellation_test.go
@@ -15,7 +15,7 @@ import (
func cancellationServer(t *testing.T, ctx context.Context, identity mcpproxy.OperationIdentity, call func(context.Context, string, json.RawMessage) (json.RawMessage, error)) *toolServer {
t.Helper()
- s, err := openToolServer(ctx, identity, []tool{{Name: "test", InputSchema: json.RawMessage(`{"type":"object"}`)}}, call)
+ s, err := openToolServer(ctx, identity, []tool{{Name: "test", InputSchema: json.RawMessage(`{"type":"object"}`)}}, call, mcpproxy.LocalToolTimeout)
if err != nil {
t.Fatal(err)
}
diff --git a/apps/computer/local-daemon/internal/linger/localtools/ui_runtime.go b/apps/computer/local-daemon/internal/linger/localtools/ui_runtime.go
index f051d253..f93b26e7 100644
--- a/apps/computer/local-daemon/internal/linger/localtools/ui_runtime.go
+++ b/apps/computer/local-daemon/internal/linger/localtools/ui_runtime.go
@@ -102,7 +102,7 @@ func unifiedUITools() []tool {
{
Name: "ui_exec",
Description: "Execute one async JavaScript body for the longest sequence you can determine from current UI evidence. Await each action, inspect its result, branch or loop in this same body, then return the verified outcome. " +
- "Return to the model for ambiguous choices, visual interpretation or missing information. Only state persists across executions. When the user specifies the next control, resolve it from the fresh observation and act immediately in this script. " +
+ "Return to the model for ambiguous choices, visual interpretation or missing information. Only state persists across executions; an uncaught script error resets it, so catch expected failures in the script. When the user specifies the next control, resolve it from the fresh observation and act immediately in this script. " +
"For repeated stages, read changing values from each observation in JavaScript and continue in a bounded loop. Never paste a value from the last model turn when the current UI supplies it. On an unrecognized stage return its observation before writing. " +
"Browser: const page=await ui.page(url); let v=await page.observe(); on resume omit the URL. Read v.text. Use v=await v.click(role,name), v=await v.type(role,name,text) or v=await v.select(role,name,[value]). " +
"Fill several named controls from one observation with v=await v.fill([{type,name,value},...]); type is the control role, e.g. textbox or combobox. " +
diff --git a/apps/computer/local-daemon/internal/linger/localtools/ui_runtime_test.go b/apps/computer/local-daemon/internal/linger/localtools/ui_runtime_test.go
index 02d93670..9b30892e 100644
--- a/apps/computer/local-daemon/internal/linger/localtools/ui_runtime_test.go
+++ b/apps/computer/local-daemon/internal/linger/localtools/ui_runtime_test.go
@@ -48,7 +48,7 @@ func newUIRuntimeFixture(t *testing.T, required bool, callback func(context.Cont
{Name: "browser_click", InputSchema: schema(map[string]any{})},
{Name: "browser_take_screenshot", InputSchema: schema(map[string]any{})},
}
- original, err := openToolServer(t.Context(), identity, methods, callback)
+ original, err := openToolServer(t.Context(), identity, methods, callback, mcpproxy.LocalToolTimeout)
if err != nil {
t.Fatal(err)
}
diff --git a/apps/computer/local-daemon/internal/provider/executor.go b/apps/computer/local-daemon/internal/provider/executor.go
index f5ff37e0..035893e5 100644
--- a/apps/computer/local-daemon/internal/provider/executor.go
+++ b/apps/computer/local-daemon/internal/provider/executor.go
@@ -797,15 +797,10 @@ func retireClaudeResident(home string) error {
return native.StopParkedClaudeResidentForCredentials(filepath.Join(home, "sessions"))
}
-// codexBatchedInputs are the macOS desktop inputs that Codex sends only as
-// run_actions steps.
-var codexBatchedInputs = []any{"click", "double_click", "right_click", "drag", "scroll", "type_text", "press_key", "hotkey"}
-
// codexDirectLocalTools gives Codex the Daemon's own computer and browser
// tools as plain function tools, as Codex's computer-use plugin does with its
// REPL: outside code mode and never deferred. A call is then a JSON function
// call, not a script that wraps each tool in text(await tools.mcp__...).
-// An older binding with direct desktop inputs uses run_actions for batches.
func codexDirectLocalTools(mcpConfig json.RawMessage, localTools []string) (json.RawMessage, error) {
if len(mcpConfig) == 0 || len(localTools) == 0 {
return mcpConfig, nil
@@ -815,16 +810,10 @@ func codexDirectLocalTools(mcpConfig json.RawMessage, localTools []string) (json
return nil, fmt.Errorf("Codex MCP configuration is invalid: %w", err)
}
servers, _ := parsed["mcpServers"].(map[string]any)
- unified := slices.Contains(localTools, "mcp__computer__ui_exec")
for _, tool := range localTools {
name, _, ok := strings.Cut(strings.TrimPrefix(tool, "mcp__"), "__")
if settings, found := servers[name].(map[string]any); ok && found {
settings["omit_tools_from"] = []any{"code_mode", "deferred"}
- if name == "computer" && !unified {
- settings["disabled_tools"] = codexBatchedInputs
- } else if name == "computer" {
- delete(settings, "disabled_tools")
- }
}
}
return json.Marshal(parsed)
diff --git a/apps/computer/local-daemon/internal/provider/executor_codex_direct_test.go b/apps/computer/local-daemon/internal/provider/executor_codex_direct_test.go
index e0421fd9..a7fbe155 100644
--- a/apps/computer/local-daemon/internal/provider/executor_codex_direct_test.go
+++ b/apps/computer/local-daemon/internal/provider/executor_codex_direct_test.go
@@ -2,7 +2,6 @@ package provider
import (
"encoding/json"
- "slices"
"testing"
"github.com/simplexai-labs/linger/apps/computer/local-daemon/internal/provider/native"
@@ -25,9 +24,6 @@ func TestCodexDirectLocalToolsKeepsDaemonToolsOutOfCodeMode(t *testing.T) {
t.Fatalf("%s: %v", name, parsed.Servers[name])
}
}
- if disabled, _ := parsed.Servers["computer"]["disabled_tools"].([]any); !slices.Contains(disabled, any("hotkey")) || parsed.Servers["browser"]["disabled_tools"] != nil {
- t.Fatalf("desktop inputs must go through run_actions: %v", parsed.Servers)
- }
if _, found := parsed.Servers["wiki"]["omit_tools_from"]; found {
t.Fatalf("a remote server left code mode: %v", parsed.Servers["wiki"])
}