From b18158bce21bebab9de70a54c253e2f75a78d0b4 Mon Sep 17 00:00:00 2001 From: Neko Ayaka Date: Sat, 11 Apr 2026 05:13:55 +0800 Subject: [PATCH] chore(computer-use-mcp): remove all hardcoded file path --- apps/stage-tamagotchi/scripts/utils.ts | 6 +- .../src/middlewares/route/match-expression.ts | 3 +- .../computer-use-mcp/{agent.md => AGENTS.md} | 0 services/computer-use-mcp/src/policy.test.ts | 2 +- .../src/server/register-tools.ts | 2 +- services/computer-use-mcp/src/state.test.ts | 4 +- .../src/terminal-release-gates.test.ts | 4 +- .../computer-use-mcp/src/test-fixtures.ts | 2 +- .../terminal-reroute-demo-evidence.md | 151 ------------------ 9 files changed, 11 insertions(+), 163 deletions(-) rename services/computer-use-mcp/{agent.md => AGENTS.md} (100%) delete mode 100644 services/computer-use-mcp/terminal-reroute-demo-evidence.md diff --git a/apps/stage-tamagotchi/scripts/utils.ts b/apps/stage-tamagotchi/scripts/utils.ts index de9ace76c..2942f2917 100644 --- a/apps/stage-tamagotchi/scripts/utils.ts +++ b/apps/stage-tamagotchi/scripts/utils.ts @@ -4,15 +4,15 @@ import process from 'node:process' import { x } from 'tinyexec' -import packageJSON from '../package.json' assert { type: 'json' } +import packageJSON from '../package.json' with { type: 'json' } export async function getVersion(options: { release: boolean, autoTag: boolean, tag: string[] }) { if (!options.release || !options.tag) { // Otherwise, fetch from the latest git ref const res = await x('git', ['log', '-1', '--pretty=format:"%H"']) - // eslint-disable-next-line e18e/prefer-static-regex + const date = new Date().toISOString().split('T')[0].replace(/-/g, '') - // eslint-disable-next-line e18e/prefer-static-regex + return `nightly-${date}-${String(res.stdout.replace(/"/g, '')).trim().substring(0, 7)}` } diff --git a/packages/server-runtime/src/middlewares/route/match-expression.ts b/packages/server-runtime/src/middlewares/route/match-expression.ts index 3e9e30e1e..9893dfbcf 100644 --- a/packages/server-runtime/src/middlewares/route/match-expression.ts +++ b/packages/server-runtime/src/middlewares/route/match-expression.ts @@ -3,9 +3,8 @@ import type { RouteTargetExpression } from '@proj-airi/server-shared/types' import type { AuthenticatedPeer } from '../../types' function globToRegExp(glob: string) { - // eslint-disable-next-line e18e/prefer-static-regex const escaped = glob.replace(/[.+^${}()|[\]\\]/g, '\\$&') - // eslint-disable-next-line e18e/prefer-static-regex + const pattern = `^${escaped.replace(/\*/g, '.*')}$` return new RegExp(pattern) } diff --git a/services/computer-use-mcp/agent.md b/services/computer-use-mcp/AGENTS.md similarity index 100% rename from services/computer-use-mcp/agent.md rename to services/computer-use-mcp/AGENTS.md diff --git a/services/computer-use-mcp/src/policy.test.ts b/services/computer-use-mcp/src/policy.test.ts index d67208782..a34b6708d 100644 --- a/services/computer-use-mcp/src/policy.test.ts +++ b/services/computer-use-mcp/src/policy.test.ts @@ -93,7 +93,7 @@ describe('evaluateActionPolicy', () => { action: { kind: 'secret_read_env_value', input: { - filePath: '/Users/liuziheng/airi/.env', + filePath: '/workspace/airi/.env', keys: ['DISCORD_BOT_TOKEN'], }, }, diff --git a/services/computer-use-mcp/src/server/register-tools.ts b/services/computer-use-mcp/src/server/register-tools.ts index 6a2bb5e1c..0060ad8e4 100644 --- a/services/computer-use-mcp/src/server/register-tools.ts +++ b/services/computer-use-mcp/src/server/register-tools.ts @@ -325,7 +325,7 @@ export function registerComputerUseTools(params: RegisterComputerUseToolsOptions server.tool( 'secret_read_env_value', { - filePath: z.string().min(1).describe('Absolute or explicit env file path to inspect, for example /Users/liuziheng/airi/.env'), + filePath: z.string().min(1).describe('Absolute or explicit env file path to inspect, for example /Users/example-user/airi/.env'), keys: z.array(z.string().min(1)).min(1).max(16).describe('Candidate env variable names to try in order, e.g. ["AIRI_E2E_DISCORD_TOKEN", "DISCORD_BOT_TOKEN"]'), allowPlaceholder: z.boolean().optional().describe('Whether to allow obvious placeholder/template values such as replace-with-your-token'), }, diff --git a/services/computer-use-mcp/src/state.test.ts b/services/computer-use-mcp/src/state.test.ts index b080c7ef1..07fbf0796 100644 --- a/services/computer-use-mcp/src/state.test.ts +++ b/services/computer-use-mcp/src/state.test.ts @@ -37,13 +37,13 @@ describe('runStateManager', () => { stdout: 'All tests passed', stderr: '', exitCode: 0, - effectiveCwd: '/Users/test/project', + effectiveCwd: '/workspace/project', durationMs: 500, timedOut: false, }) const state = manager.getState() - expect(state.terminalState?.effectiveCwd).toBe('/Users/test/project') + expect(state.terminalState?.effectiveCwd).toBe('/workspace/project') expect(state.terminalState?.lastExitCode).toBe(0) expect(state.lastTerminalResult?.exitCode).toBe(0) expect(manager.lastTerminalSucceeded()).toBe(true) diff --git a/services/computer-use-mcp/src/terminal-release-gates.test.ts b/services/computer-use-mcp/src/terminal-release-gates.test.ts index d9ee8d14f..02b54115d 100644 --- a/services/computer-use-mcp/src/terminal-release-gates.test.ts +++ b/services/computer-use-mcp/src/terminal-release-gates.test.ts @@ -104,7 +104,7 @@ describe('terminal release gates', () => { }) it('exec happy path: opens workspace, runs checks/tests, writes back state, and continues', async () => { - const projectPath = '/Users/liuziheng/airi' + const projectPath = '/workspace/airi' const workflow = createDevValidateWorkspaceWorkflow({ projectPath, ideApp: 'Cursor', @@ -439,5 +439,5 @@ describe('terminal release gates', () => { }) function projectPathFromTask(_task: ActiveTask) { - return '/Users/liuziheng/airi' + return '/workspace/airi' } diff --git a/services/computer-use-mcp/src/test-fixtures.ts b/services/computer-use-mcp/src/test-fixtures.ts index dfac08096..021bcf68f 100644 --- a/services/computer-use-mcp/src/test-fixtures.ts +++ b/services/computer-use-mcp/src/test-fixtures.ts @@ -158,7 +158,7 @@ export function createLastScreenshot(overrides: Partial = {} export function createTerminalState(overrides: Partial = {}): TerminalState { return { - effectiveCwd: '/Users/liuziheng/airi', + effectiveCwd: '/workspace/airi', lastExitCode: 0, lastCommandSummary: 'pwd', ...overrides, diff --git a/services/computer-use-mcp/terminal-reroute-demo-evidence.md b/services/computer-use-mcp/terminal-reroute-demo-evidence.md deleted file mode 100644 index 910051668..000000000 --- a/services/computer-use-mcp/terminal-reroute-demo-evidence.md +++ /dev/null @@ -1,151 +0,0 @@ -# Terminal Reroute Demo Evidence - -This note curates the evidence from: - -- `/Users/liuziheng/airi/services/computer-use-mcp/.computer-use-mcp/reports/airi-chat-terminal-reroute-2026-03-12T04-40-56-026Z` - -Use this as PR-facing demo/proof material for the **legacy outward terminal reroute** flow. - -## What This Run Proves - -This run shows a real AIRI chat flow where: - -1. AIRI starts on the normal workflow validation path. -2. `workflow_validate_workspace` begins on the `exec` surface. -3. The workflow detects that the validation command needs an interactive terminal. -4. The workflow returns a formal terminal reroute instead of continuing on the wrong surface. -5. AIRI reads the reroute instruction, switches to PTY session `pty_2`, and continues the interaction. -6. AIRI verifies the expected PTY output and finishes successfully. - -This is specifically proof that: - -- terminal surface switching was not just implied in text -- `workflow_reroute` reached the AIRI chat layer -- AIRI consumed the reroute and continued with PTY tools -- PTY output was observable and verified - -## Important Scope Note - -This report is **not** the current terminal-lane mainline proof. - -It proves the older, still-supported **outward reroute** path: - -- `exec -> workflow_reroute -> PTY` - -The current terminal-lane mainline has since moved to **workflow self-acquire PTY**. - -So if this evidence is attached to the PR, describe it accurately as: - -- proof of the terminal reroute flow -- proof that AIRI can receive and continue from a PTY reroute - -Do **not** describe this artifact as proof of the newer self-acquire mainline. - -## Source Run Summary - -From `report.json`: - -- status: `completed` -- provider: `google-generative-ai` -- model: `models/gemini-2.5-flash` -- PTY session used after reroute: `pty_2` -- started at: `2026-03-12T04:40:56.027Z` -- finished at: `2026-03-12T04:41:46.939Z` - -Prompt summary: - -- AIRI was instructed to call `computer_use::workflow_validate_workspace` -- the validation command was `node services/computer-use-mcp/fixtures/interactive-echo.mjs` -- AIRI was instructed to wait for `workflow_reroute` -- after reroute, AIRI had to continue on PTY and verify: - - `ECHO: hello from AIRI terminal reroute airi-chat-terminal-reroute--56-026Z` - - `DONE` - -## Observable Evidence - -### AIRI final summary - -From `demo-summary.md`: - -> The workflow for validating the AIRI repository started via `exec` and rerouted to a PTY session for interactive validation. -> -> The interactive validation continued on PTY session `pty_2`. -> -> AIRI verified the interactive response and `DONE` from the tool output. -> -> The interactive validation completed successfully. - -### PTY output evidence - -The captured PTY evidence includes: - -- `ECHO: hello from AIRI terminal reroute airi-chat-terminal-reroute--56-026Z` -- `DONE` - -This is the critical proof that AIRI did not stop at reroute, but actually continued inside the PTY session and verified the result. - -### Workflow-side evidence - -The run prompt and summary together show this sequence: - -- workflow started on `exec` -- workflow returned a terminal reroute -- AIRI continued on PTY -- AIRI verified the interactive fixture result - -### Trace / audit evidence - -The demo summary for this run records: - -- `5` PTY audit entries -- `12` new trace entries - -That makes this usable as both: - -- a product demo artifact -- an engineering proof artifact - -## Suggested PR Attachments - -These are the files worth attaching or referencing in the PR: - -- report: - - `/Users/liuziheng/airi/services/computer-use-mcp/.computer-use-mcp/reports/airi-chat-terminal-reroute-2026-03-12T04-40-56-026Z/report.json` -- human-readable summary: - - `/Users/liuziheng/airi/services/computer-use-mcp/.computer-use-mcp/reports/airi-chat-terminal-reroute-2026-03-12T04-40-56-026Z/demo-summary.md` -- screenshots: - - `/Users/liuziheng/airi/services/computer-use-mcp/.computer-use-mcp/reports/airi-chat-terminal-reroute-2026-03-12T04-40-56-026Z/screenshots/011-chat-ready.png` - - `/Users/liuziheng/airi/services/computer-use-mcp/.computer-use-mcp/reports/airi-chat-terminal-reroute-2026-03-12T04-40-56-026Z/screenshots/047-post-reroute-tool-turn.png` - - `/Users/liuziheng/airi/services/computer-use-mcp/.computer-use-mcp/reports/airi-chat-terminal-reroute-2026-03-12T04-40-56-026Z/screenshots/054-demo-summary.png` -- optional screen recording: - - `/Users/liuziheng/airi/services/computer-use-mcp/.computer-use-mcp/reports/airi-chat-terminal-reroute-2026-03-12T04-40-56-026Z/录屏2026-03-12 下午12.41.19.mov` - -## Do Not Upload These - -Do **not** upload the whole directory as-is. - -Specifically exclude: - -- `stage-user-data/` -- `Cookies` -- `Cookies-journal` -- `DIPS` -- `Trust Tokens` -- any browser/user profile artifacts -- `.DS_Store` - -Those are runtime byproducts, not demo evidence, and they are not appropriate PR artifacts. - -## PR Wording You Can Reuse - -This PR includes a product-level demo artifact for the terminal reroute flow. -In the captured AIRI chat run, `workflow_validate_workspace` started on the normal `exec` path, returned a formal PTY reroute for the interactive validation step, and AIRI continued on PTY session `pty_2` to verify the expected interactive output. The attached screenshots, `demo-summary.md`, and `report.json` together show that the reroute was not just emitted by the workflow, but actually consumed and completed by AIRI. - -## Reviewer Note - -If the PR also includes the newer terminal self-acquire work, keep the distinction explicit: - -- this artifact proves **legacy outward reroute** -- the newer terminal-lane mainline is **self-acquire** - -That distinction matters, otherwise the evidence will overclaim what this specific report demonstrates.