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.

feat(computer): review Pi tool calls and add the new Runtime acceptance recipe

jeffrey46c9e6683655
diff --git a/.agents/skills/verify-linger/features/README.md b/.agents/skills/verify-linger/features/README.md
index d9e588bf..1ff2a540 100644
--- a/.agents/skills/verify-linger/features/README.md
+++ b/.agents/skills/verify-linger/features/README.md
@@ -19,6 +19,7 @@ Recipes are definitions, not execution results or claims about an uncommitted re
| Move an Agent to a second Computer | [Move](rooms.md#move-an-agent-to-a-second-computer) | None end to end | First requests after the move each get one reply; verify retained history |
| Install, upgrade and remove a Computer | [Local Computer](local-computer.md#install-and-lifecycle) | Runner smoke layers, installer and Windows native tests | Real installer, enrollment, deletion guards and credential revocation |
| Install and pair on Windows | [Windows](local-computer.md#windows-install-pairing-and-background-run) | Windows Go tests and `check-local-computer-windows.ps1` | Elevated refusal, pairing, run after terminal close, state after reboot |
+| Add or change an Agent Runtime | [New Runtime](local-computer.md#new-runtime-acceptance) | Runtime adapter fake-process tests; Runner smoke | Every tool class, permissions, complex Tasks and failures against a Claude Code baseline |
| Let an Agent use the desktop and a browser | [Desktop and browser tools](local-computer.md#desktop-and-browser-tools) | Opt-in `Test*Live` Daemon probes; dialog unit tests | Model-driven task result; connect and disconnect the user's Chrome |
| Stop, reconnect or recover work | [Execution lifecycle](rooms.md#execution-lifecycle) | Runner smoke/soak and process tests | Real-model interruption and visible recovery without duplicate effects |
| Stop one Agent's Run | [Stop by Run ID](rooms.md#run-status-and-stop-by-run-id) | Run controls and run-status transport unit tests | Real Run reaches its terminal state; other Runs continue |
diff --git a/.agents/skills/verify-linger/features/local-computer.md b/.agents/skills/verify-linger/features/local-computer.md
index 99aaef5e..61d6bfda 100644
--- a/.agents/skills/verify-linger/features/local-computer.md
+++ b/.agents/skills/verify-linger/features/local-computer.md
@@ -305,6 +305,52 @@ When using the private token-file probe, verify the target page before and after
**Reuse:** `browser-connection-dialog.test.tsx` and `TestUserChromeLive`.
+## New Runtime acceptance
+
+Run this recipe whenever a Runtime is added to the Computer, and again when an
+existing Runtime's adapter changes how it reports tools, permissions, sessions
+or failures. A single delivered reply only proves the entry path. Drive every
+step on a deployment that ships the adapter under test, and repeat each prompt
+on a Claude Code Agent on the same Computer as the baseline.
+
+**Setup:** Install the Runtime's CLI on the Computer and sign it in. Confirm
+the Computer reports the target release's `app-sha256` and the Runtime as
+ready. Create one Agent on the new Runtime and one on Claude Code, each in its
+own Room. Record `TEAMHUB_PERMISSION_REVIEW` as in
+[Runtime permission decisions](tasks.md#runtime-permission-decisions).
+
+**Journey:** Send each prompt below to both Agents, waiting for each Run to end.
+
+1. Direct commands: send a message, add an emoji reaction, and send a card
+ with an attachment. Read and write a Document, search knowledge, search
+ the web, and read and write a local file in the workspace.
+2. A confirm command, such as `agent update`, produces an approval card;
+ approve one and deny another.
+3. A judged command, such as `image-gen`, goes to TeamHub's remote review.
+4. A background Task that ends by delivering a file to the Room.
+5. Multi-step research that ends in a new Document.
+6. A follow-up message sent while the previous Run still works.
+7. A long command line, over 200 characters, and content in a non-Latin
+ script in the prompt, tool input and reply.
+8. A request the Runtime must fail, such as a missing file, and one that ends
+ by user Stop.
+
+**Pass:** Every step ends with the requested effect, and the delivered message,
+Document or file matches the request. The working indicator appears in the
+composer within about one second of sending, as for Claude Code; record the
+delay for both Agents. Each tool call shows a readable name and its outcome.
+A confirm or judged command waits for its decision, and a denied action has
+no effect. A failed or stopped Run shows a specific reason, not an
+unclassified error. The follow-up reaches the same session, and the next Run
+resumes it.
+
+**Evidence:** For each step, record the Room, Run ID, Runtime, model, elapsed
+time to the working indicator, terminal status and the effect checked. Check
+`runtime-presentation-runs` for the message and `daemon.log` for a failed
+Operation. Report any step that differs from the Claude Code baseline, even
+when the step passes. A Runtime the deployment cannot run is a blocker, not
+a skipped step.
+
## Source-built Computer
`bash scripts/dev-local-computer.sh start|status|stop` drives a Daemon against `pnpm dev`.
diff --git a/apps/computer/local-daemon/README.md b/apps/computer/local-daemon/README.md
index fb9bf148..2b84c3ff 100644
--- a/apps/computer/local-daemon/README.md
+++ b/apps/computer/local-daemon/README.md
@@ -837,6 +837,15 @@ with its dependencies resolves its own jiti first. Node reads `NODE_PATH` at
startup, so the extension then restores the value Pi inherited, and the
commands Pi starts never resolve a package from the bundle.
+The same extension carries Pi's permission review, so the Daemon loads it for a
+Run with permission review even without MCP servers. Its `tool_call` hook opens
+an RPC `input` dialog titled `linger.permission_review` for each `bash` and
+`mcp__*` call, with the call as JSON. The Daemon answers it with a JSON verdict
+from the Run's permission review, with `bash` reviewed as a shell command. A
+Run without review gets an allow verdict, because a resident Pi process may
+serve both kinds of Run. A missing or unreadable verdict blocks the call. The
+Daemon cancels any other extension dialog.
+
The compatibility probe of the pinned Playwright catalog is
`TestPinnedPlaywrightCatalog`; it needs `LINGER_PLAYWRIGHT_COMPAT_ENTRY` and
`LINGER_PLAYWRIGHT_COMPAT_NODE`. The macOS read-only probe is
diff --git a/apps/computer/local-daemon/internal/provider/native/pi_fake_test.go b/apps/computer/local-daemon/internal/provider/native/pi_fake_test.go
index 5942d060..c27c9718 100644
--- a/apps/computer/local-daemon/internal/provider/native/pi_fake_test.go
+++ b/apps/computer/local-daemon/internal/provider/native/pi_fake_test.go
@@ -21,6 +21,9 @@ const (
piFakeArgvEnv = "PI_FAKE_ARGV"
piFakeChildEnv = "PI_FAKE_CHILD_PID"
piFakeLogEnv = "PI_FAKE_COMMANDS"
+ // piFakeDialogEnv names the file the review mode appends each
+ // extension UI response to.
+ piFakeDialogEnv = "PI_FAKE_DIALOGS"
)
func init() {
@@ -116,6 +119,12 @@ func piFake(mode string, args []string) int {
if json.Unmarshal(line, &command) != nil {
return 22
}
+ if command.Type == "extension_ui_response" {
+ if code := f.dialogAnswered(line); code >= 0 {
+ return code
+ }
+ continue
+ }
if path := os.Getenv(piFakeLogEnv); path != "" {
if log, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o600); err == nil {
_, _ = log.WriteString(command.Type + "\n")
@@ -220,6 +229,12 @@ func (f *piFakeProcess) act() int {
}})
f.tool("call_ls", "bash", false)
f.finish()
+ case "review":
+ // Another extension's dialog first: the Daemon cancels it.
+ f.send(map[string]any{"type": "extension_ui_request", "id": "ui-other", "method": "confirm", "title": "Clear session?", "message": "x"})
+ f.send(map[string]any{"type": "extension_ui_request", "id": "ui-notify", "method": "notify", "message": "x"})
+ call, _ := json.Marshal(map[string]any{"toolName": "bash", "input": map[string]any{"command": "git push"}})
+ f.send(map[string]any{"type": "extension_ui_request", "id": "ui-review", "method": "input", "title": piReviewDialog, "placeholder": string(call)})
case "composite":
f.tool("call_shared|fc_first", "read", false)
f.tool("call_shared|fc_second", "read", false)
@@ -230,6 +245,25 @@ func (f *piFakeProcess) act() int {
return -1
}
+// dialogAnswered records one extension UI response and finishes the turn
+// once the review is answered. It returns an exit code, or -1.
+func (f *piFakeProcess) dialogAnswered(line []byte) int {
+ if path := os.Getenv(piFakeDialogEnv); path != "" {
+ if log, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o600); err == nil {
+ _, _ = log.Write(line)
+ _ = log.Close()
+ }
+ }
+ var answer struct{ ID string }
+ if json.Unmarshal(line, &answer) != nil {
+ return 22
+ }
+ if answer.ID == "ui-review" {
+ f.finish()
+ }
+ return -1
+}
+
// piFakeCatalog answers each catalog request with an unrelated rejected
// reply first, then the real one.
func piFakeCatalog() int {
diff --git a/apps/computer/local-daemon/internal/provider/native/pi_mcp.go b/apps/computer/local-daemon/internal/provider/native/pi_mcp.go
index edda34c6..01e77bc4 100644
--- a/apps/computer/local-daemon/internal/provider/native/pi_mcp.go
+++ b/apps/computer/local-daemon/internal/provider/native/pi_mcp.go
@@ -40,12 +40,8 @@ func piPrepareMCP(raw json.RawMessage, extension, sessionDir string) (piMCPWirin
if config.MCPServers == nil || len(*config.MCPServers) == 0 {
return piMCPWiring{}, nil
}
- if extension == "" || !filepath.IsAbs(extension) {
- return piMCPWiring{}, errors.New("the managed Pi MCP extension is not installed; repair the Computer installation")
- }
- info, err := os.Stat(extension)
- if err != nil || !info.Mode().IsRegular() {
- return piMCPWiring{}, errors.New("the managed Pi MCP extension is unavailable; repair the Computer installation")
+ if err := piCheckExtension(extension); err != nil {
+ return piMCPWiring{}, err
}
path := filepath.Join(sessionDir, piMCPConfigName)
if err := piWritePrivate(path, raw); err != nil {
@@ -54,6 +50,18 @@ func piPrepareMCP(raw json.RawMessage, extension, sessionDir string) (piMCPWirin
return piMCPWiring{configPath: path}, nil
}
+// piCheckExtension checks that the managed extension is installed.
+func piCheckExtension(extension string) error {
+ if extension == "" || !filepath.IsAbs(extension) {
+ return errors.New("the managed Pi MCP extension is not installed; repair the Computer installation")
+ }
+ info, err := os.Stat(extension)
+ if err != nil || !info.Mode().IsRegular() {
+ return errors.New("the managed Pi MCP extension is unavailable; repair the Computer installation")
+ }
+ return nil
+}
+
// piExtensionNodePath puts the Computer tools' node_modules on Pi's module
// search path. Pi loads every extension through jiti, which its bare npm
// bundle does not carry: a Pi unpacked without its dependencies, as the
diff --git a/apps/computer/local-daemon/internal/provider/native/pi_process.go b/apps/computer/local-daemon/internal/provider/native/pi_process.go
index fe14e223..aff66ff8 100644
--- a/apps/computer/local-daemon/internal/provider/native/pi_process.go
+++ b/apps/computer/local-daemon/internal/provider/native/pi_process.go
@@ -203,6 +203,10 @@ func (p *piProcess) read() {
p.route(frame)
continue
}
+ if head.Type == "extension_ui_request" {
+ p.answerDialog(frame)
+ continue
+ }
var event piEventFrame
if json.Unmarshal(frame, &event) != nil {
continue
diff --git a/apps/computer/local-daemon/internal/provider/native/pi_review.go b/apps/computer/local-daemon/internal/provider/native/pi_review.go
new file mode 100644
index 00000000..a4800293
--- /dev/null
+++ b/apps/computer/local-daemon/internal/provider/native/pi_review.go
@@ -0,0 +1,105 @@
+package native
+
+import (
+ "bytes"
+ "encoding/json"
+
+ "github.com/simplexai-labs/linger/apps/computer/local-daemon/internal/permission"
+)
+
+// piReviewDialog titles the input dialog the managed extension opens for
+// each command or MCP call; its placeholder is the call as JSON.
+const piReviewDialog = "linger.permission_review"
+
+// piVerdict is the answer the managed extension parses.
+type piVerdict struct {
+ Allow bool `json:"allow"`
+ Message string `json:"message,omitempty"`
+}
+
+// answerDialog answers an extension UI request. The managed extension's
+// review goes to the bound turn; any other dialog is cancelled, as no one
+// can answer it, and notifications need no answer.
+func (p *piProcess) answerDialog(frame []byte) {
+ var request struct {
+ ID string `json:"id"`
+ Method string `json:"method"`
+ Title string `json:"title"`
+ Placeholder string `json:"placeholder"`
+ }
+ if json.Unmarshal(frame, &request) != nil || request.ID == "" {
+ return
+ }
+ switch request.Method {
+ case "select", "confirm", "input", "editor":
+ default:
+ return
+ }
+ if request.Method != "input" || request.Title != piReviewDialog {
+ go p.writeFrame(map[string]any{"type": "extension_ui_response", "id": request.ID, "cancelled": true})
+ return
+ }
+ turn := p.boundTurn()
+ go func() {
+ verdict := piVerdict{Message: "No Run is waiting for this tool call"}
+ if turn != nil {
+ verdict = turn.review(request.Placeholder)
+ }
+ value, _ := json.Marshal(verdict)
+ p.writeFrame(map[string]any{"type": "extension_ui_response", "id": request.ID, "value": string(value)})
+ }()
+}
+
+// writeFrame writes one frame to Pi's stdin. A failed write leaves the
+// dialog open until the turn ends and Pi is stopped or aborted.
+func (p *piProcess) writeFrame(frame map[string]any) {
+ var encoded bytes.Buffer
+ encoder := json.NewEncoder(&encoded)
+ encoder.SetEscapeHTML(false)
+ if encoder.Encode(frame) != nil {
+ return
+ }
+ p.writeMu.Lock()
+ defer p.writeMu.Unlock()
+ _, _ = p.stdin.Write(encoded.Bytes())
+}
+
+// review judges one call the managed extension asked about. A turn without
+// a reviewer allows every call, as Pi then runs with the Agent's full local
+// authority.
+func (t *piTurn) review(payload string) piVerdict {
+ if t.reviewer == nil {
+ return piVerdict{Allow: true}
+ }
+ var call struct {
+ ToolName string `json:"toolName"`
+ Input map[string]any `json:"input"`
+ }
+ if json.Unmarshal([]byte(payload), &call) != nil || call.ToolName == "" {
+ return piVerdict{Message: "The tool call could not be read for permission review"}
+ }
+ verdict := t.reviewer.Review(t.runCtx, piReview(call.ToolName, call.Input, t.dir))
+ return piVerdict{Allow: verdict.Decision == permission.Allow, Message: verdict.Message}
+}
+
+// piReview builds the permission review of one call. A bash call is
+// reviewed as a shell command so the shared shell rules apply.
+func piReview(tool string, input map[string]any, workspace string) permission.Request {
+ if input == nil {
+ input = map[string]any{}
+ }
+ encoded, _ := json.Marshal(input)
+ command := ""
+ if tool == "bash" {
+ command, _ = input["command"].(string)
+ tool = "Bash"
+ }
+ request := permission.Request{Action: permission.Action{
+ Runtime: "pi", Surface: permission.Surface(tool, command), Tool: tool,
+ Command: command, Input: string(encoded),
+ }}
+ if tool == "Bash" {
+ request.Evidence = permission.ScriptEvidence(command, workspace)
+ }
+ return request
+}
diff --git a/apps/computer/local-daemon/internal/provider/native/pi_run.go b/apps/computer/local-daemon/internal/provider/native/pi_run.go
index 549702de..b0b3d316 100644
--- a/apps/computer/local-daemon/internal/provider/native/pi_run.go
+++ b/apps/computer/local-daemon/internal/provider/native/pi_run.go
@@ -9,6 +9,8 @@ import (
"strings"
"sync"
"time"
+
+ "github.com/simplexai-labs/linger/apps/computer/local-daemon/internal/permission"
)
const piEventBuffer = 256
@@ -38,6 +40,10 @@ type piTurn struct {
requests *modelRequestClock
readiness *ReadinessCounters
+ // reviewer judges the calls the managed extension asks about; nil
+ // allows them all. dir is the workspace commands are judged in.
+ reviewer *permission.Reviewer
+ dir string
// steering is the steer waiting for Pi to show its user message; at most
// one, as steerMu serializes steers.
diff --git a/apps/computer/local-daemon/internal/provider/native/pi_runtime.go b/apps/computer/local-daemon/internal/provider/native/pi_runtime.go
index 615c0034..6e364acf 100644
--- a/apps/computer/local-daemon/internal/provider/native/pi_runtime.go
+++ b/apps/computer/local-daemon/internal/provider/native/pi_runtime.go
@@ -145,6 +145,7 @@ func (p *piRuntime) reuse(ctx context.Context, proc *piProcess, plan piLaunchPla
}
turn := newPiTurn(runCtx, cancel, proc, true, plan.fence, p.profile.Logger)
turn.readiness = plan.spec.Readiness
+ turn.reviewer, turn.dir = plan.spec.PermissionReviewer, plan.spec.Dir
if err := proc.bind(turn); err != nil {
return fail(err)
}
@@ -197,6 +198,11 @@ func (p *piRuntime) spawn(ctx context.Context, plan piLaunchPlan, lock *os.File)
if mcp, err = piPrepareMCP(config, p.profile.ManagedMCPExtension, plan.sessionDir); err != nil {
return nil, err
}
+ if spec.PermissionReviewer != nil {
+ if err := piCheckExtension(p.profile.ManagedMCPExtension); err != nil {
+ return nil, err
+ }
+ }
// The session flags sit right after "--mode rpc".
tail := p.args(plan, instructions, mcp.wired())
args := append([]string{tail[0], tail[1], "--session-dir", plan.sessionDir, "--session-id", plan.sessionID}, tail[2:]...)
@@ -207,7 +213,7 @@ func (p *piRuntime) spawn(ctx context.Context, plan piLaunchPlan, lock *os.File)
if mcp.wired() {
env[piMCPConfigEnvKey] = mcp.configPath
}
- if mcp.wired() || p.guardsShellText(spec) {
+ if mcp.wired() || spec.PermissionReviewer != nil || p.guardsShellText(spec) {
piExtensionNodePath(env, p.profile.ManagedMCPExtension)
}
if p.guardsShellText(spec) {
@@ -236,6 +242,7 @@ func (p *piRuntime) spawn(ctx context.Context, plan piLaunchPlan, lock *os.File)
runCtx, cancel := budgetContext(ctx, spec.Budget)
turn := newPiTurn(runCtx, cancel, proc, false, plan.fence, p.profile.Logger)
turn.readiness = plan.spec.Readiness
+ turn.reviewer, turn.dir = spec.PermissionReviewer, spec.Dir
spec.Readiness.spawned()
spec.Readiness.session(spec.ResumeID != "")
_ = proc.bind(turn)
@@ -268,8 +275,10 @@ func (p *piRuntime) args(plan piLaunchPlan, instructions string, wired bool) []s
args = append(args, "--skill", skills)
}
}
+ // The managed extension also carries permission review: its tool_call
+ // hook asks the Daemon over RPC (piProcess.answerDialog).
tools := piBaseTools
- if wired || p.guardsShellText(spec) {
+ if wired || spec.PermissionReviewer != nil || p.guardsShellText(spec) {
args = append(args, "--extension", p.profile.ManagedMCPExtension)
}
if wired {
diff --git a/apps/computer/local-daemon/internal/provider/native/pi_runtime_test.go b/apps/computer/local-daemon/internal/provider/native/pi_runtime_test.go
index 4e36d9d0..3764cb42 100644
--- a/apps/computer/local-daemon/internal/provider/native/pi_runtime_test.go
+++ b/apps/computer/local-daemon/internal/provider/native/pi_runtime_test.go
@@ -12,6 +12,8 @@ import (
"strings"
"testing"
"time"
+
+ "github.com/simplexai-labs/linger/apps/computer/local-daemon/internal/permission"
)
type piHarness struct {
@@ -134,13 +136,14 @@ func TestPiStartPreconditions(t *testing.T) {
prompt string
spec RunSpec
}{
- "blank prompt": {" \n", RunSpec{}},
- "computer args": {"x", RunSpec{ComputerArgs: []string{"--x"}}},
- "agent args": {"x", RunSpec{AgentArgs: []string{"--x"}}},
- "bad effort": {"x", RunSpec{Effort: "ultra"}},
- "invalid mcp": {"x", RunSpec{MCPServers: json.RawMessage(`[1]`)}},
- "missing session": {"x", RunSpec{ResumeID: "never-created"}},
- "extension absent": {"x", RunSpec{MCPServers: json.RawMessage(`{"mcpServers":{"computer":{"type":"http","url":"http://127.0.0.1:1/"}}}`)}},
+ "blank prompt": {" \n", RunSpec{}},
+ "computer args": {"x", RunSpec{ComputerArgs: []string{"--x"}}},
+ "agent args": {"x", RunSpec{AgentArgs: []string{"--x"}}},
+ "bad effort": {"x", RunSpec{Effort: "ultra"}},
+ "invalid mcp": {"x", RunSpec{MCPServers: json.RawMessage(`[1]`)}},
+ "missing session": {"x", RunSpec{ResumeID: "never-created"}},
+ "extension absent": {"x", RunSpec{MCPServers: json.RawMessage(`{"mcpServers":{"computer":{"type":"http","url":"http://127.0.0.1:1/"}}}`)}},
+ "review without extension": {"x", RunSpec{PermissionReviewer: &permission.Reviewer{}}},
}
for name, tc := range cases {
tc.spec.Dir = h.dir
@@ -359,6 +362,54 @@ func TestPiRecoverableToolFailure(t *testing.T) {
}
}
+func TestPiAnswersTheManagedExtensionsReview(t *testing.T) {
+ extension := filepath.Join(t.TempDir(), "pi-mcp.mjs")
+ if err := os.WriteFile(extension, []byte("export default {}\n"), 0o600); err != nil {
+ t.Fatal(err)
+ }
+ for _, c := range []struct {
+ name string
+ reviewer bool
+ want piVerdict
+ }{
+ {name: "without review", want: piVerdict{Allow: true}},
+ {name: "denied", reviewer: true, want: piVerdict{Message: "not now"}},
+ } {
+ t.Run(c.name, func(t *testing.T) {
+ dialogs := filepath.Join(t.TempDir(), "dialogs")
+ h := piNewHarness(t, "review", map[string]string{piFakeDialogEnv: dialogs})
+ h.runtime, _ = Open("pi", Profile{Program: h.runtime.(*piRuntime).profile.Program, Env: h.env, ManagedMCPExtension: extension})
+ requester := agyDenyingRequester{asked: make(chan string, 1)}
+ spec := RunSpec{}
+ if c.reviewer {
+ spec.PermissionReviewer = &permission.Reviewer{Requester: requester, Timeout: time.Minute}
+ }
+ if _, outcome := piCollect(t, h.start(t.Context(), "push it", spec)); outcome.Status != statusCompleted {
+ t.Fatalf("outcome = %+v", outcome)
+ }
+ if asked := len(requester.asked); asked != map[bool]int{true: 1}[c.reviewer] {
+ t.Fatalf("reviews asked = %d", asked)
+ }
+ data, _ := os.ReadFile(dialogs)
+ answers := map[string]map[string]any{}
+ for _, line := range strings.Split(strings.TrimSpace(string(data)), "\n") {
+ var answer map[string]any
+ if json.Unmarshal([]byte(line), &answer) != nil {
+ t.Fatalf("answer %q", line)
+ }
+ answers[answer["id"].(string)] = answer
+ }
+ if len(answers) != 2 || answers["ui-other"]["cancelled"] != true {
+ t.Fatalf("answers = %v", answers)
+ }
+ var verdict piVerdict
+ if value, _ := answers["ui-review"]["value"].(string); json.Unmarshal([]byte(value), &verdict) != nil || verdict != c.want {
+ t.Fatalf("verdict = %+v, want %+v", verdict, c.want)
+ }
+ })
+ }
+}
+
func TestPiCompositeToolIDs(t *testing.T) {
h := piNewHarness(t, "composite", nil)
events, outcome := piCollect(t, h.start(t.Context(), "go", RunSpec{}))
diff --git a/apps/computer/tests/computer-tools.test.ts b/apps/computer/tests/computer-tools.test.ts
index 37a10952..48f210c1 100644
--- a/apps/computer/tests/computer-tools.test.ts
+++ b/apps/computer/tests/computer-tools.test.ts
@@ -107,3 +107,41 @@ process.stdin.on("end", () => {
},
30_000,
);
+
+it("asks the Daemon about Pi commands and MCP calls and blocks unless allowed", async () => {
+ const entry = new URL("../tools/pi-mcp.mjs", import.meta.url).href;
+ const { PERMISSION_REVIEW, reviewToolCall } = (await import(entry)) as {
+ PERMISSION_REVIEW: string;
+ reviewToolCall: (
+ event: { toolName: string; input: Record<string, unknown> },
+ ui: { input: (title: string, placeholder: string) => Promise<unknown> },
+ ) => Promise<unknown>;
+ };
+ const asked: Array<{ title: string; call: unknown }> = [];
+ const ui = (answer: string | undefined) => ({
+ input: async (title: string, placeholder: string) => {
+ asked.push({ title, call: JSON.parse(placeholder) });
+ return answer;
+ },
+ });
+ const bash = { toolName: "bash", input: { command: "git push" } };
+
+ expect(
+ await reviewToolCall({ toolName: "read", input: {} }, ui("")),
+ ).toBeUndefined();
+ expect(asked).toEqual([]);
+ expect(
+ await reviewToolCall(bash, ui(JSON.stringify({ allow: true }))),
+ ).toBeUndefined();
+ expect(asked).toEqual([{ title: PERMISSION_REVIEW, call: bash }]);
+ expect(
+ await reviewToolCall(
+ { toolName: "mcp__computer__click", input: {} },
+ ui(JSON.stringify({ allow: false, message: "not now" })),
+ ),
+ ).toEqual({ block: true, reason: "not now" });
+ expect(await reviewToolCall(bash, ui(undefined))).toEqual({
+ block: true,
+ reason: "bash was not approved",
+ });
+});
diff --git a/apps/computer/tools/pi-mcp.mjs b/apps/computer/tools/pi-mcp.mjs
index 13c36642..30de5403 100644
--- a/apps/computer/tools/pi-mcp.mjs
+++ b/apps/computer/tools/pi-mcp.mjs
@@ -109,9 +109,52 @@ const mcpExtension = createMcpExtension({
},
});
-// The Daemon loads this extension for the shell text check, and for the
-// Operation's MCP servers when it has any.
+// PERMISSION_REVIEW names the Daemon's review dialog. Pi forwards the dialog
+// over RPC; the Daemon answers with a JSON verdict, {"allow", "message"}.
+export const PERMISSION_REVIEW = "linger.permission_review";
+
+// reviewedTool reports whether a call goes to the Daemon's permission review:
+// commands and MCP tools.
+export function reviewedTool(toolName) {
+ return toolName === "bash" || toolName.startsWith("mcp__");
+}
+
+// reviewToolCall asks the Daemon about one call and blocks it unless the
+// verdict allows it. A missing or unreadable answer blocks the call.
+// The Daemon allows every call of a Run without permission review.
+export async function reviewToolCall(event, ui, signal) {
+ if (!reviewedTool(event.toolName)) return undefined;
+ const answer = await ui.input(
+ PERMISSION_REVIEW,
+ JSON.stringify({ toolName: event.toolName, input: event.input ?? {} }),
+ signal ? { signal } : undefined,
+ );
+ let verdict;
+ try {
+ verdict = JSON.parse(answer ?? "");
+ } catch {
+ verdict = undefined;
+ }
+ if (verdict?.allow === true) return undefined;
+ return {
+ block: true,
+ reason:
+ typeof verdict?.message === "string" && verdict.message
+ ? verdict.message
+ : `${event.toolName} was not approved`,
+ };
+}
+
+// The Daemon loads this extension for the shell text check, permission
+// review, MCP servers, or any of them. The review hook is always on, because
+// a resident Pi process may serve a reviewed Run after one without review.
+// A call the shell text check refuses never reaches review.
export default async function managedExtension(pi) {
- pi.on("tool_call", (event) => refuseRewrittenShellText(event));
+ pi.on(
+ "tool_call",
+ async (event, ctx) =>
+ (await refuseRewrittenShellText(event)) ??
+ reviewToolCall(event, ctx.ui, ctx.signal),
+ );
if (process.env.LINGER_PI_MANAGED_MCP_CONFIG) await mcpExtension(pi);
}
diff --git a/apps/teamhub/internal/permissionreview/types.go b/apps/teamhub/internal/permissionreview/types.go
index 1dc90372..8f50f7e0 100644
--- a/apps/teamhub/internal/permissionreview/types.go
+++ b/apps/teamhub/internal/permissionreview/types.go
@@ -47,7 +47,8 @@ const (
// Action is the planned tool call under review. It is untrusted evidence: the
// model must never treat fields here as authorization.
type Action struct {
- // Runtime is "claude" or "codex"; background for the model, not a rule input.
+ // Runtime is "claude", "codex", "antigravity", or "pi"; background for the
+ // model, not a rule input.
Runtime string `json:"runtime"`
// Surface classifies what kind of effect this action can have. One of
// "shell", "file_edit", "connected_app", "browser", "computer", "web".
diff --git a/contracts/generated/go/teamhubinternal/openapi.gen.go b/contracts/generated/go/teamhubinternal/openapi.gen.go
index 973b9bd8..b904b598 100644
--- a/contracts/generated/go/teamhubinternal/openapi.gen.go
+++ b/contracts/generated/go/teamhubinternal/openapi.gen.go
@@ -1324,6 +1324,7 @@ const (
RuntimePermissionActionRuntimeAntigravity RuntimePermissionActionRuntime = "antigravity"
RuntimePermissionActionRuntimeClaude RuntimePermissionActionRuntime = "claude"
RuntimePermissionActionRuntimeCodex RuntimePermissionActionRuntime = "codex"
+ RuntimePermissionActionRuntimePi RuntimePermissionActionRuntime = "pi"
)
// Valid indicates whether the value is a known member of the RuntimePermissionActionRuntime enum.
@@ -1335,6 +1336,8 @@ func (e RuntimePermissionActionRuntime) Valid() bool {
return true
case RuntimePermissionActionRuntimeCodex:
return true
+ case RuntimePermissionActionRuntimePi:
+ return true
default:
return false
}
diff --git a/contracts/generated/typescript/src/generated/teamhub-internal/types.ts b/contracts/generated/typescript/src/generated/teamhub-internal/types.ts
index ac92b50e..29aecaa5 100644
--- a/contracts/generated/typescript/src/generated/teamhub-internal/types.ts
+++ b/contracts/generated/typescript/src/generated/teamhub-internal/types.ts
@@ -1682,7 +1682,7 @@ export interface components {
};
RuntimePermissionAction: {
/** @enum {string} */
- runtime: "claude" | "codex" | "antigravity";
+ runtime: "claude" | "codex" | "antigravity" | "pi";
/** @enum {string} */
surface:
| "shell"
diff --git a/contracts/openapi/components/agent-runtime-state.yaml b/contracts/openapi/components/agent-runtime-state.yaml
index 3da827d2..e512e843 100644
--- a/contracts/openapi/components/agent-runtime-state.yaml
+++ b/contracts/openapi/components/agent-runtime-state.yaml
@@ -1800,7 +1800,7 @@ components:
additionalProperties: false
required: [runtime, surface, tool]
properties:
- runtime: { type: string, enum: [claude, codex, antigravity] }
+ runtime: { type: string, enum: [claude, codex, antigravity, pi] }
surface:
type: string
enum: [shell, file_edit, connected_app, browser, computer, web, other]