@alwith/module-computer 0.6.2 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +29 -6
  2. package/artifacts/cmux-cua-e0f7388-alwith.5-aarch64-apple-darwin.tar.gz +0 -0
  3. package/dist/artifacts.js +1 -1
  4. package/dist/generated/commands.d.ts +12 -0
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.js +1 -1
  7. package/native/darwin-arm64/THIRD_PARTY_NOTICES.md +4 -4
  8. package/native/darwin-arm64/artifact.json +2 -2
  9. package/native/darwin-arm64/libalwith_native_computer.dylib +0 -0
  10. package/native/linux-x64/THIRD_PARTY_NOTICES.md +11 -11
  11. package/native/linux-x64/artifact.json +2 -2
  12. package/native/linux-x64/libalwith_native_computer.so +0 -0
  13. package/native/win32-x64/THIRD_PARTY_NOTICES.md +4 -4
  14. package/native/win32-x64/alwith_native_computer.dll +0 -0
  15. package/native/win32-x64/artifact.json +2 -2
  16. package/package.json +2 -2
  17. package/proxy/stdio.mjs +157 -14
  18. package/artifacts/cmux-cua-e0f7388-alwith.4-aarch64-apple-darwin.tar.gz +0 -0
  19. /package/artifacts/{cmux-cua-e0f7388-alwith.4-x86_64-pc-windows-msvc.tar.gz → cmux-cua-e0f7388-alwith.5-x86_64-pc-windows-msvc.tar.gz} +0 -0
  20. /package/artifacts/{cmux-cua-e0f7388-alwith.4-x86_64-unknown-linux-gnu.tar.gz → cmux-cua-e0f7388-alwith.5-x86_64-unknown-linux-gnu.tar.gz} +0 -0
  21. /package/native/darwin-arm64/licenses/{flate2-1.1.10 → flate2-1.1.11}/LICENSE-APACHE +0 -0
  22. /package/native/darwin-arm64/licenses/{flate2-1.1.10 → flate2-1.1.11}/LICENSE-MIT +0 -0
  23. /package/native/darwin-arm64/licenses/{specta-2.0.0-rc.27 → specta-2.0.0-rc.28}/LICENSE +0 -0
  24. /package/native/darwin-arm64/licenses/{specta-macros-2.0.0-rc.27 → specta-macros-2.0.0-rc.28}/LICENSE +0 -0
  25. /package/native/darwin-arm64/licenses/{uuid-1.29.0 → uuid-1.29.1}/LICENSE-APACHE +0 -0
  26. /package/native/darwin-arm64/licenses/{uuid-1.29.0 → uuid-1.29.1}/LICENSE-MIT +0 -0
  27. /package/native/linux-x64/licenses/{cc-1.11.0 → cc-1.11.1}/LICENSE-APACHE +0 -0
  28. /package/native/linux-x64/licenses/{cc-1.11.0 → cc-1.11.1}/LICENSE-MIT +0 -0
  29. /package/native/linux-x64/licenses/{flate2-1.1.10 → flate2-1.1.11}/LICENSE-APACHE +0 -0
  30. /package/native/linux-x64/licenses/{flate2-1.1.10 → flate2-1.1.11}/LICENSE-MIT +0 -0
  31. /package/native/linux-x64/licenses/{serde_spanned-1.1.2 → serde_spanned-1.1.3}/LICENSE-APACHE +0 -0
  32. /package/native/linux-x64/licenses/{serde_spanned-1.1.2 → serde_spanned-1.1.3}/LICENSE-MIT +0 -0
  33. /package/native/linux-x64/licenses/{smallvec-1.16.4 → smallvec-1.16.5}/LICENSE-APACHE +0 -0
  34. /package/native/linux-x64/licenses/{smallvec-1.16.4 → smallvec-1.16.5}/LICENSE-MIT +0 -0
  35. /package/native/linux-x64/licenses/{specta-2.0.0-rc.27 → specta-2.0.0-rc.28}/LICENSE +0 -0
  36. /package/native/linux-x64/licenses/{specta-macros-2.0.0-rc.27 → specta-macros-2.0.0-rc.28}/LICENSE +0 -0
  37. /package/native/linux-x64/licenses/{toml-1.2.0+spec-1.1.0 → toml-1.2.1+spec-1.1.0}/LICENSE-APACHE +0 -0
  38. /package/native/linux-x64/licenses/{toml-1.2.0+spec-1.1.0 → toml-1.2.1+spec-1.1.0}/LICENSE-MIT +0 -0
  39. /package/native/linux-x64/licenses/{toml_datetime-1.1.2+spec-1.1.0 → toml_datetime-1.1.3+spec-1.1.0}/LICENSE-APACHE +0 -0
  40. /package/native/linux-x64/licenses/{toml_datetime-1.1.2+spec-1.1.0 → toml_datetime-1.1.3+spec-1.1.0}/LICENSE-MIT +0 -0
  41. /package/native/linux-x64/licenses/{toml_edit-0.25.18+spec-1.1.0 → toml_edit-0.25.19+spec-1.1.0}/LICENSE-APACHE +0 -0
  42. /package/native/linux-x64/licenses/{toml_edit-0.25.18+spec-1.1.0 → toml_edit-0.25.19+spec-1.1.0}/LICENSE-MIT +0 -0
  43. /package/native/linux-x64/licenses/{uuid-1.29.0 → uuid-1.29.1}/LICENSE-APACHE +0 -0
  44. /package/native/linux-x64/licenses/{uuid-1.29.0 → uuid-1.29.1}/LICENSE-MIT +0 -0
  45. /package/native/linux-x64/licenses/{winnow-1.0.4 → winnow-1.0.5}/LICENSE-MIT +0 -0
  46. /package/native/win32-x64/licenses/{flate2-1.1.10 → flate2-1.1.11}/LICENSE-APACHE +0 -0
  47. /package/native/win32-x64/licenses/{flate2-1.1.10 → flate2-1.1.11}/LICENSE-MIT +0 -0
  48. /package/native/win32-x64/licenses/{specta-2.0.0-rc.27 → specta-2.0.0-rc.28}/LICENSE +0 -0
  49. /package/native/win32-x64/licenses/{specta-macros-2.0.0-rc.27 → specta-macros-2.0.0-rc.28}/LICENSE +0 -0
  50. /package/native/win32-x64/licenses/{uuid-1.29.0 → uuid-1.29.1}/LICENSE-APACHE +0 -0
  51. /package/native/win32-x64/licenses/{uuid-1.29.0 → uuid-1.29.1}/LICENSE-MIT +0 -0
package/README.md CHANGED
@@ -5,14 +5,15 @@ Computer access using cmux-cua 0.7.1, pinned to commit
5
5
  `alwith-cmux-host-v2` contract on macOS ARM64, Windows x64 and Linux x64.
6
6
  macOS uses the Codex profile; Windows and Linux use the native window profile. The TypeScript entry
7
7
  composes MCP descriptors from native authority without storing conversations.
8
- It returns a generation revision so clients can refresh existing threads when
9
- the host's grant changes. New, resumed and forked threads receive the same tools
10
- when the application grant is enabled.
8
+ Its stable attachment descriptor is independent of Driver readiness and application
9
+ execution authority. New, resumed and forked threads receive the same discoverable
10
+ tool contract; the application grant is checked only when a computer tool executes.
11
11
 
12
12
  The Rust host owns one embedded Driver child and a private transport. Its logical
13
13
  lease key is chosen by the consumer: U uses one application lease shared by every
14
14
  conversation. Individual thread cancellation or window hiding does not revoke
15
- this lease. Disabling computer use stops the child and invalidates every proxy.
15
+ this lease. Disabling computer use stops the child and revokes every native execution connection
16
+ while leaving MCP discovery available.
16
17
  Hosts must shut down on application exit and connection loss. Launch directly
17
18
  from the signed application for macOS permission attribution.
18
19
 
@@ -39,7 +40,7 @@ Run `bun run test`, `bun run build`, and `bun run test:rust` in this directory.
39
40
  The gateway binds an MCP connection token to the returned session
40
41
  ID. It serializes tool access with a FIFO lease held until Runtime turn completion.
41
42
  Cancellation drains an outstanding native action before handoff; transport failure
42
- requires the host to stop the Driver before resetting the gateway. Consumers must
43
+ requires the host to stop the Driver before releasing native execution ownership. Consumers must
43
44
  forward Runtime run-state snapshots, including sessions awaiting input. Codex may restart an MCP
44
45
  process with its existing session descriptor. The gateway drains any dispatched action and closes
45
46
  the previous transport before accepting the replacement, which must discover its tools again.
@@ -66,7 +67,7 @@ each session-bound tool call. Driver `start_session` is idempotent while active
66
67
  ended session, so a long-lived MCP connection cannot remain stuck on a tombstone.
67
68
  A failed declaration prevents the requested tool from being dispatched. User tool
68
69
  failures are returned unchanged and are never replayed. Application reconnection
69
- still replaces the driver generation and invalidates all old proxy connections.
70
+ replaces the Driver generation and its execution connections while retaining MCP attachment identity.
70
71
 
71
72
  On macOS, the agent receives the ten app-oriented cmux tools unchanged. Observe
72
73
  with `get_app_state`, use its grounded indices or coordinates, then refresh after
@@ -104,3 +105,25 @@ that show computer UI, and call commands through `@alwith/module-computer/comman
104
105
  application forwards Runtime run states with `Computer::sync_running`, calls `Computer::release`
105
106
  when Runtime or Codex exits, awaits `Computer::shutdown` in its exit sequence and calls
106
107
  `Computer::kill_on_exit` last.
108
+
109
+ ## Conversation-independent MCP attachments
110
+
111
+ The application grant defaults to disabled. Every conversation can attach the same
112
+ computer MCP contract while execution is disabled. Attachment identity lasts for the
113
+ MCP conversation attachment; Driver generations and their private credentials are
114
+ internal to the native gateway. Opening, replaying, or sending a conversation must
115
+ not wait for computer permission checks or Driver readiness.
116
+
117
+ The gateway answers discovery without a running control daemon. macOS uses the
118
+ Driver's permission-free Codex bootstrap registry; Windows x64 and Linux x64 use
119
+ its pure `dump-docs --type mcp` registry export. Tool names, descriptions, schemas,
120
+ and action annotations come from that executable rather than application copies.
121
+ Metadata discovery neither captures the desktop nor starts a control daemon.
122
+
123
+ Only computer calls acquire desktop ownership, check the current application grant
124
+ and system permissions, and open an execution transport for the current Driver.
125
+ Disabling access revokes execution admission before stopping every native Driver
126
+ connection. Reconnection replaces those internal transports and credentials without
127
+ closing the agent-facing MCP attachment. Failed calls return MCP tool errors; they
128
+ do not fail conversation admission or replay. Unknown action outcomes are never
129
+ replayed. A new observation is required after recovery.
package/dist/artifacts.js CHANGED
@@ -1 +1 @@
1
- var a={version:"cmux-e0f7388-alwith.4",artifacts:{"aarch64-apple-darwin":{bundled:"../artifacts/cmux-cua-e0f7388-alwith.4-aarch64-apple-darwin.tar.gz",sha256:"24ec432b2fcae42eab31cb5d5164bcad34a179777e9284f026d93291fbd9cc11",archive:"cmux-cua-e0f7388-alwith.4-aarch64-apple-darwin.tar.gz",executable:"cua-driver"},"x86_64-pc-windows-msvc":{bundled:"../artifacts/cmux-cua-e0f7388-alwith.4-x86_64-pc-windows-msvc.tar.gz",sha256:"33490ea7ef0999462e0d592e792b6a0a48cb6c9c76165aa04285b320df13c824",archive:"cmux-cua-e0f7388-alwith.4-x86_64-pc-windows-msvc.tar.gz",executable:"cua-driver.exe"},"x86_64-unknown-linux-gnu":{bundled:"../artifacts/cmux-cua-e0f7388-alwith.4-x86_64-unknown-linux-gnu.tar.gz",sha256:"8664e8b4e7e81bc13641d4becb527430d140ba23f630e9f20d9da6d473e236db",archive:"cmux-cua-e0f7388-alwith.4-x86_64-unknown-linux-gnu.tar.gz",executable:"cua-driver"}}};var t=a;export{t as default};
1
+ var a={version:"cmux-e0f7388-alwith.5",artifacts:{"aarch64-apple-darwin":{bundled:"../artifacts/cmux-cua-e0f7388-alwith.5-aarch64-apple-darwin.tar.gz",sha256:"9fc31f7e3b5a53bee5d2ac8b4fcd5e992859dbfb68abd4f247051bd97be29ffe",archive:"cmux-cua-e0f7388-alwith.5-aarch64-apple-darwin.tar.gz",executable:"cua-driver"},"x86_64-pc-windows-msvc":{bundled:"../artifacts/cmux-cua-e0f7388-alwith.5-x86_64-pc-windows-msvc.tar.gz",sha256:"33490ea7ef0999462e0d592e792b6a0a48cb6c9c76165aa04285b320df13c824",archive:"cmux-cua-e0f7388-alwith.5-x86_64-pc-windows-msvc.tar.gz",executable:"cua-driver.exe"},"x86_64-unknown-linux-gnu":{bundled:"../artifacts/cmux-cua-e0f7388-alwith.5-x86_64-unknown-linux-gnu.tar.gz",sha256:"8664e8b4e7e81bc13641d4becb527430d140ba23f630e9f20d9da6d473e236db",archive:"cmux-cua-e0f7388-alwith.5-x86_64-unknown-linux-gnu.tar.gz",executable:"cua-driver"}}};var t=a;export{t as default};
@@ -61,6 +61,7 @@ export declare const events: {
61
61
  };
62
62
  export type Activity = Activity_Serialize | Activity_Deserialize;
63
63
  export type Activity_Deserialize = {
64
+ refreshing?: boolean;
64
65
  sessionId: string;
65
66
  phase: string;
66
67
  queuePosition: number;
@@ -70,6 +71,7 @@ export type Activity_Deserialize = {
70
71
  revision: number;
71
72
  };
72
73
  export type Activity_Serialize = {
74
+ refreshing: boolean;
73
75
  sessionId: string;
74
76
  phase: string;
75
77
  queuePosition: number;
@@ -93,6 +95,8 @@ export type ComputerPreview_Serialize = {
93
95
  };
94
96
  export type ComputerStatus = ComputerStatus_Serialize | ComputerStatus_Deserialize;
95
97
  export type ComputerStatus_Deserialize = {
98
+ driverPhase: string;
99
+ connections: ConnectionHealth;
96
100
  permissions: Permissions;
97
101
  available: boolean;
98
102
  enabled: boolean;
@@ -102,6 +106,8 @@ export type ComputerStatus_Deserialize = {
102
106
  diagnostics: string;
103
107
  };
104
108
  export type ComputerStatus_Serialize = {
109
+ driverPhase: string;
110
+ connections: ConnectionHealth;
105
111
  permissions: Permissions;
106
112
  available: boolean;
107
113
  enabled: boolean;
@@ -116,6 +122,12 @@ export type Connection = {
116
122
  args: string[];
117
123
  env: Environment[];
118
124
  };
125
+ export type ConnectionHealth = {
126
+ ready: number;
127
+ connecting: number;
128
+ disconnected: number;
129
+ failed: number;
130
+ };
119
131
  export type CursorPosition = {
120
132
  x: number;
121
133
  y: number;
package/dist/index.d.ts CHANGED
@@ -27,7 +27,7 @@ export interface ComputerMcpServer {
27
27
  }>;
28
28
  }
29
29
  export declare const COMPUTER_SERVER_NAME = "alwith_computer";
30
- export declare const COMPUTER_INSTRUCTIONS = "Computer actions must use the private MCP server named alwith_computer. Discover its tools before acting. When get_app_state is available, use the app-oriented tools: get_app_state starts app use and returns its key-window screenshot and accessibility tree; act using that app identity and the returned element indices or screenshot coordinates. Stable grounded actions can follow without another snapshot; refresh after navigation, layout changes, modal transitions or an action error, and verify the completed sequence. Actions report dispatch, not verified completion. Otherwise, read skill://cua-driver/SKILL.md from alwith_computer and use its window-oriented tools and element tokens. The host handles conversation ownership, queuing and preview. Respect driver refusals and explicit input delivery modes. If the connection fails or is revoked, stop and report the connection error; never substitute cua_repl, shell automation or another computer channel. Ask the user to retry the message after reconnecting in U.";
30
+ export declare const COMPUTER_INSTRUCTIONS = "Computer actions must use the private MCP server named alwith_computer. Discover its tools before acting. When get_app_state is available, use the app-oriented tools: get_app_state starts app use and returns its key-window screenshot and accessibility tree; act using that app identity and the returned element indices or screenshot coordinates. Group independent actions against a stable layout in one host turn, awaiting them sequentially. Do not run desktop actions concurrently. Prefer set_value for an editable field when supported. Do not poll get_app_state after each action: stable grounded actions can follow without another snapshot; refresh after navigation, layout changes, modal transitions or an action error, and verify the completed sequence. Actions report dispatch, not verified completion. Otherwise, read skill://cua-driver/SKILL.md from alwith_computer and use its window-oriented tools and element tokens. The host handles conversation ownership, queuing and preview. Respect driver refusals and explicit input delivery modes. Computer access is disabled until the user enables it in the application. If a computer call fails or access is revoked, stop computer actions and report the tool error; ordinary conversation can continue. Never replay an action whose outcome is unknown; never substitute cua_repl, shell automation or another computer channel. Ask the user to enable or reconnect computer access in the application when computer actions are needed.";
31
31
  export declare function computerContext(resolve: () => Promise<ComputerConnection | null>): Promise<{
32
32
  mcpServers: ComputerMcpServer[];
33
33
  appendSystemPrompt?: string;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var r="alwith_computer",o="Computer actions must use the private MCP server named alwith_computer. Discover its tools before acting. When get_app_state is available, use the app-oriented tools: get_app_state starts app use and returns its key-window screenshot and accessibility tree; act using that app identity and the returned element indices or screenshot coordinates. Stable grounded actions can follow without another snapshot; refresh after navigation, layout changes, modal transitions or an action error, and verify the completed sequence. Actions report dispatch, not verified completion. Otherwise, read skill://cua-driver/SKILL.md from alwith_computer and use its window-oriented tools and element tokens. The host handles conversation ownership, queuing and preview. Respect driver refusals and explicit input delivery modes. If the connection fails or is revoked, stop and report the connection error; never substitute cua_repl, shell automation or another computer channel. Ask the user to retry the message after reconnecting in U.";async function s(t){let e=await t();if(!e)return{mcpServers:[],revision:"disabled"};return{mcpServers:[{type:"stdio",name:"alwith_computer",command:e.command,args:[...e.args],env:e.env.map((n)=>({...n}))}],revision:e.generation,appendSystemPrompt:"Computer actions must use the private MCP server named alwith_computer. Discover its tools before acting. When get_app_state is available, use the app-oriented tools: get_app_state starts app use and returns its key-window screenshot and accessibility tree; act using that app identity and the returned element indices or screenshot coordinates. Stable grounded actions can follow without another snapshot; refresh after navigation, layout changes, modal transitions or an action error, and verify the completed sequence. Actions report dispatch, not verified completion. Otherwise, read skill://cua-driver/SKILL.md from alwith_computer and use its window-oriented tools and element tokens. The host handles conversation ownership, queuing and preview. Respect driver refusals and explicit input delivery modes. If the connection fails or is revoked, stop and report the connection error; never substitute cua_repl, shell automation or another computer channel. Ask the user to retry the message after reconnecting in U."}}export{o as COMPUTER_INSTRUCTIONS,r as COMPUTER_SERVER_NAME,s as computerContext};
1
+ var r="alwith_computer",o="Computer actions must use the private MCP server named alwith_computer. Discover its tools before acting. When get_app_state is available, use the app-oriented tools: get_app_state starts app use and returns its key-window screenshot and accessibility tree; act using that app identity and the returned element indices or screenshot coordinates. Group independent actions against a stable layout in one host turn, awaiting them sequentially. Do not run desktop actions concurrently. Prefer set_value for an editable field when supported. Do not poll get_app_state after each action: stable grounded actions can follow without another snapshot; refresh after navigation, layout changes, modal transitions or an action error, and verify the completed sequence. Actions report dispatch, not verified completion. Otherwise, read skill://cua-driver/SKILL.md from alwith_computer and use its window-oriented tools and element tokens. The host handles conversation ownership, queuing and preview. Respect driver refusals and explicit input delivery modes. Computer access is disabled until the user enables it in the application. If a computer call fails or access is revoked, stop computer actions and report the tool error; ordinary conversation can continue. Never replay an action whose outcome is unknown; never substitute cua_repl, shell automation or another computer channel. Ask the user to enable or reconnect computer access in the application when computer actions are needed.";async function s(t){let e=await t();if(!e)return{mcpServers:[],revision:"disabled"};return{mcpServers:[{type:"stdio",name:"alwith_computer",command:e.command,args:[...e.args],env:e.env.map((n)=>({...n}))}],revision:e.generation,appendSystemPrompt:"Computer actions must use the private MCP server named alwith_computer. Discover its tools before acting. When get_app_state is available, use the app-oriented tools: get_app_state starts app use and returns its key-window screenshot and accessibility tree; act using that app identity and the returned element indices or screenshot coordinates. Group independent actions against a stable layout in one host turn, awaiting them sequentially. Do not run desktop actions concurrently. Prefer set_value for an editable field when supported. Do not poll get_app_state after each action: stable grounded actions can follow without another snapshot; refresh after navigation, layout changes, modal transitions or an action error, and verify the completed sequence. Actions report dispatch, not verified completion. Otherwise, read skill://cua-driver/SKILL.md from alwith_computer and use its window-oriented tools and element tokens. The host handles conversation ownership, queuing and preview. Respect driver refusals and explicit input delivery modes. Computer access is disabled until the user enables it in the application. If a computer call fails or access is revoked, stop computer actions and report the tool error; ordinary conversation can continue. Never replay an action whose outcome is unknown; never substitute cua_repl, shell automation or another computer channel. Ask the user to enable or reconnect computer access in the application when computer actions are needed."}}export{o as COMPUTER_INSTRUCTIONS,r as COMPUTER_SERVER_NAME,s as computerContext};
@@ -20,7 +20,7 @@ ALwith native implementations are proprietary. Dependencies retain their own lic
20
20
  - errno@0.3.14: MIT OR Apache-2.0; licenses/errno-0.3.14/
21
21
  - fastrand@2.5.0: Apache-2.0 OR MIT; licenses/fastrand-2.5.0/
22
22
  - fdeflate@0.3.7: MIT OR Apache-2.0; licenses/fdeflate-0.3.7/
23
- - flate2@1.1.10: MIT OR Apache-2.0; licenses/flate2-1.1.10/
23
+ - flate2@1.1.11: MIT OR Apache-2.0; licenses/flate2-1.1.11/
24
24
  - getrandom@0.4.3: MIT OR Apache-2.0; licenses/getrandom-0.4.3/
25
25
  - image@0.25.10: MIT OR Apache-2.0; licenses/image-0.25.10/
26
26
  - itoa@1.0.18: MIT OR Apache-2.0; licenses/itoa-1.0.18/
@@ -71,8 +71,8 @@ ALwith native implementations are proprietary. Dependencies retain their own lic
71
71
  - signal-hook-registry@1.4.8: MIT OR Apache-2.0; licenses/signal-hook-registry-1.4.8/
72
72
  - simd-adler32@0.3.10: MIT; licenses/simd-adler32-0.3.10/
73
73
  - socket2@0.6.5: MIT OR Apache-2.0; licenses/socket2-0.6.5/
74
- - specta@2.0.0-rc.27: MIT; licenses/specta-2.0.0-rc.27/; source: https://raw.githubusercontent.com/specta-rs/specta/bb4d872b131b1a4a58a340a01c9a693a7d799485/LICENSE
75
- - specta-macros@2.0.0-rc.27: MIT; licenses/specta-macros-2.0.0-rc.27/; source: https://raw.githubusercontent.com/specta-rs/specta/bb4d872b131b1a4a58a340a01c9a693a7d799485/LICENSE
74
+ - specta@2.0.0-rc.28: MIT; licenses/specta-2.0.0-rc.28/; source: https://raw.githubusercontent.com/specta-rs/specta/82278bb5fef379b755af41b831ae3d3533e55b39/LICENSE
75
+ - specta-macros@2.0.0-rc.28: MIT; licenses/specta-macros-2.0.0-rc.28/; source: https://raw.githubusercontent.com/specta-rs/specta/82278bb5fef379b755af41b831ae3d3533e55b39/LICENSE
76
76
  - syn@2.0.119: MIT OR Apache-2.0; licenses/syn-2.0.119/
77
77
  - syn@3.0.9: MIT OR Apache-2.0; licenses/syn-3.0.9/
78
78
  - tempfile@3.27.0: MIT OR Apache-2.0; licenses/tempfile-3.27.0/
@@ -81,7 +81,7 @@ ALwith native implementations are proprietary. Dependencies retain their own lic
81
81
  - tokio@1.54.1: MIT; licenses/tokio-1.54.1/
82
82
  - tokio-macros@2.7.2: MIT; licenses/tokio-macros-2.7.2/
83
83
  - unicode-ident@1.0.27: (MIT OR Apache-2.0) AND Unicode-3.0; licenses/unicode-ident-1.0.27/
84
- - uuid@1.29.0: Apache-2.0 OR MIT; licenses/uuid-1.29.0/
84
+ - uuid@1.29.1: Apache-2.0 OR MIT; licenses/uuid-1.29.1/
85
85
  - xcap@0.9.8: Apache-2.0; licenses/xcap-0.9.8/
86
86
  - zlib-rs@0.6.8: Zlib; licenses/zlib-rs-0.6.8/
87
87
  - zmij@1.0.23: MIT; licenses/zmij-1.0.23/
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "module": "computer",
3
- "contract": 1,
3
+ "contract": 2,
4
4
  "abi": 1,
5
5
  "target": "aarch64-apple-darwin",
6
6
  "binary": "libalwith_native_computer.dylib",
7
- "sha256": "be4b98278e2dfbf8b934ab5fa6d12fca1a98a581cedad7f6e4a61835e126e481"
7
+ "sha256": "1c8b4a1bc58c34d4ede59e984599b34489795878aae8f3f3f6765425e8c6891e"
8
8
  }
@@ -27,7 +27,7 @@ ALwith native implementations are proprietary. Dependencies retain their own lic
27
27
  - bytemuck_derive@1.12.1: Zlib OR Apache-2.0 OR MIT; licenses/bytemuck_derive-1.12.1/
28
28
  - byteorder-lite@0.1.0: Unlicense OR MIT; licenses/byteorder-lite-0.1.0/
29
29
  - bytes@1.12.1: MIT; licenses/bytes-1.12.1/
30
- - cc@1.11.0: MIT OR Apache-2.0; licenses/cc-1.11.0/
30
+ - cc@1.11.1: MIT OR Apache-2.0; licenses/cc-1.11.1/
31
31
  - cexpr@0.6.0: Apache-2.0/MIT; licenses/cexpr-0.6.0/
32
32
  - cfg-expr@0.20.10: MIT OR Apache-2.0; licenses/cfg-expr-0.20.10/
33
33
  - cfg-if@1.0.5: MIT OR Apache-2.0; licenses/cfg-if-1.0.5/
@@ -57,7 +57,7 @@ ALwith native implementations are proprietary. Dependencies retain their own lic
57
57
  - fastrand@2.5.0: Apache-2.0 OR MIT; licenses/fastrand-2.5.0/
58
58
  - fdeflate@0.3.7: MIT OR Apache-2.0; licenses/fdeflate-0.3.7/
59
59
  - find-msvc-tools@0.1.15: MIT OR Apache-2.0; licenses/find-msvc-tools-0.1.15/
60
- - flate2@1.1.10: MIT OR Apache-2.0; licenses/flate2-1.1.10/
60
+ - flate2@1.1.11: MIT OR Apache-2.0; licenses/flate2-1.1.11/
61
61
  - form_urlencoded@1.2.2: MIT OR Apache-2.0; licenses/form_urlencoded-1.2.2/
62
62
  - futures-core@0.3.34: MIT OR Apache-2.0; licenses/futures-core-0.3.34/
63
63
  - futures-io@0.3.34: MIT OR Apache-2.0; licenses/futures-io-0.3.34/
@@ -141,16 +141,16 @@ ALwith native implementations are proprietary. Dependencies retain their own lic
141
141
  - serde_derive@1.0.229: MIT OR Apache-2.0; licenses/serde_derive-1.0.229/
142
142
  - serde_json@1.0.154: MIT OR Apache-2.0; licenses/serde_json-1.0.154/
143
143
  - serde_repr@0.1.21: MIT OR Apache-2.0; licenses/serde_repr-0.1.21/
144
- - serde_spanned@1.1.2: MIT OR Apache-2.0; licenses/serde_spanned-1.1.2/
144
+ - serde_spanned@1.1.3: MIT OR Apache-2.0; licenses/serde_spanned-1.1.3/
145
145
  - shlex@1.3.0: MIT OR Apache-2.0; licenses/shlex-1.3.0/
146
146
  - shlex@2.0.1: MIT OR Apache-2.0; licenses/shlex-2.0.1/
147
147
  - signal-hook-registry@1.4.8: MIT OR Apache-2.0; licenses/signal-hook-registry-1.4.8/
148
148
  - simd-adler32@0.3.10: MIT; licenses/simd-adler32-0.3.10/
149
149
  - slab@0.4.12: MIT; licenses/slab-0.4.12/
150
- - smallvec@1.16.4: MIT OR Apache-2.0; licenses/smallvec-1.16.4/
150
+ - smallvec@1.16.5: MIT OR Apache-2.0; licenses/smallvec-1.16.5/
151
151
  - socket2@0.6.5: MIT OR Apache-2.0; licenses/socket2-0.6.5/
152
- - specta@2.0.0-rc.27: MIT; licenses/specta-2.0.0-rc.27/; source: https://raw.githubusercontent.com/specta-rs/specta/bb4d872b131b1a4a58a340a01c9a693a7d799485/LICENSE
153
- - specta-macros@2.0.0-rc.27: MIT; licenses/specta-macros-2.0.0-rc.27/; source: https://raw.githubusercontent.com/specta-rs/specta/bb4d872b131b1a4a58a340a01c9a693a7d799485/LICENSE
152
+ - specta@2.0.0-rc.28: MIT; licenses/specta-2.0.0-rc.28/; source: https://raw.githubusercontent.com/specta-rs/specta/82278bb5fef379b755af41b831ae3d3533e55b39/LICENSE
153
+ - specta-macros@2.0.0-rc.28: MIT; licenses/specta-macros-2.0.0-rc.28/; source: https://raw.githubusercontent.com/specta-rs/specta/82278bb5fef379b755af41b831ae3d3533e55b39/LICENSE
154
154
  - stable_deref_trait@1.2.1: MIT OR Apache-2.0; licenses/stable_deref_trait-1.2.1/
155
155
  - syn@2.0.119: MIT OR Apache-2.0; licenses/syn-2.0.119/
156
156
  - syn@3.0.9: MIT OR Apache-2.0; licenses/syn-3.0.9/
@@ -163,9 +163,9 @@ ALwith native implementations are proprietary. Dependencies retain their own lic
163
163
  - tinystr@0.8.5: Unicode-3.0; licenses/tinystr-0.8.5/
164
164
  - tokio@1.54.1: MIT; licenses/tokio-1.54.1/
165
165
  - tokio-macros@2.7.2: MIT; licenses/tokio-macros-2.7.2/
166
- - toml@1.2.0+spec-1.1.0: MIT OR Apache-2.0; licenses/toml-1.2.0+spec-1.1.0/
167
- - toml_datetime@1.1.2+spec-1.1.0: MIT OR Apache-2.0; licenses/toml_datetime-1.1.2+spec-1.1.0/
168
- - toml_edit@0.25.18+spec-1.1.0: MIT OR Apache-2.0; licenses/toml_edit-0.25.18+spec-1.1.0/
166
+ - toml@1.2.1+spec-1.1.0: MIT OR Apache-2.0; licenses/toml-1.2.1+spec-1.1.0/
167
+ - toml_datetime@1.1.3+spec-1.1.0: MIT OR Apache-2.0; licenses/toml_datetime-1.1.3+spec-1.1.0/
168
+ - toml_edit@0.25.19+spec-1.1.0: MIT OR Apache-2.0; licenses/toml_edit-0.25.19+spec-1.1.0/
169
169
  - toml_parser@1.1.5+spec-1.1.0: MIT OR Apache-2.0; licenses/toml_parser-1.1.5+spec-1.1.0/
170
170
  - toml_writer@1.2.0+spec-1.1.0: MIT OR Apache-2.0; licenses/toml_writer-1.2.0+spec-1.1.0/
171
171
  - tracing@0.1.44: MIT; licenses/tracing-0.1.44/
@@ -176,7 +176,7 @@ ALwith native implementations are proprietary. Dependencies retain their own lic
176
176
  - url@2.5.8: MIT OR Apache-2.0; licenses/url-2.5.8/
177
177
  - utf8_iter@1.1.0: Apache-2.0 OR MIT; licenses/utf8_iter-1.1.0/
178
178
  - utf_types@1.0.0: Apache-2.0 OR MIT; licenses/utf_types-1.0.0/
179
- - uuid@1.29.0: Apache-2.0 OR MIT; licenses/uuid-1.29.0/
179
+ - uuid@1.29.1: Apache-2.0 OR MIT; licenses/uuid-1.29.1/
180
180
  - version-compare@0.2.1: MIT; licenses/version-compare-0.2.1/
181
181
  - wayland-backend@0.3.17: MIT; licenses/wayland-backend-0.3.17/
182
182
  - wayland-client@0.31.15: MIT; licenses/wayland-client-0.31.15/
@@ -185,7 +185,7 @@ ALwith native implementations are proprietary. Dependencies retain their own lic
185
185
  - wayland-scanner@0.31.11: MIT; licenses/wayland-scanner-0.31.11/
186
186
  - wayland-server@0.31.14: MIT; licenses/wayland-server-0.31.14/
187
187
  - wayland-sys@0.31.11: MIT; licenses/wayland-sys-0.31.11/
188
- - winnow@1.0.4: MIT; licenses/winnow-1.0.4/
188
+ - winnow@1.0.5: MIT; licenses/winnow-1.0.5/
189
189
  - writeable@0.6.4: Unicode-3.0; licenses/writeable-0.6.4/
190
190
  - xcap@0.9.8: Apache-2.0; licenses/xcap-0.9.8/
191
191
  - xcb@1.7.1: MIT; licenses/xcb-1.7.1/
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "module": "computer",
3
- "contract": 1,
3
+ "contract": 2,
4
4
  "abi": 1,
5
5
  "target": "x86_64-unknown-linux-gnu",
6
6
  "binary": "libalwith_native_computer.so",
7
- "sha256": "f0ebe723db77576e2f1fce79ed0f7b8faac7fb01351f39d09888f006568cdf35"
7
+ "sha256": "3742550036a0f4b3cc4ad295b22745b6142d6e53ca106edccb9b2e40becb091d"
8
8
  }
@@ -15,7 +15,7 @@ ALwith native implementations are proprietary. Dependencies retain their own lic
15
15
  - crc32fast@1.5.4: MIT OR Apache-2.0; licenses/crc32fast-1.5.4/
16
16
  - fastrand@2.5.0: Apache-2.0 OR MIT; licenses/fastrand-2.5.0/
17
17
  - fdeflate@0.3.7: MIT OR Apache-2.0; licenses/fdeflate-0.3.7/
18
- - flate2@1.1.10: MIT OR Apache-2.0; licenses/flate2-1.1.10/
18
+ - flate2@1.1.11: MIT OR Apache-2.0; licenses/flate2-1.1.11/
19
19
  - getrandom@0.4.3: MIT OR Apache-2.0; licenses/getrandom-0.4.3/
20
20
  - image@0.25.10: MIT OR Apache-2.0; licenses/image-0.25.10/
21
21
  - itoa@1.0.18: MIT OR Apache-2.0; licenses/itoa-1.0.18/
@@ -42,8 +42,8 @@ ALwith native implementations are proprietary. Dependencies retain their own lic
42
42
  - serde_json@1.0.154: MIT OR Apache-2.0; licenses/serde_json-1.0.154/
43
43
  - simd-adler32@0.3.10: MIT; licenses/simd-adler32-0.3.10/
44
44
  - socket2@0.6.5: MIT OR Apache-2.0; licenses/socket2-0.6.5/
45
- - specta@2.0.0-rc.27: MIT; licenses/specta-2.0.0-rc.27/; source: https://raw.githubusercontent.com/specta-rs/specta/bb4d872b131b1a4a58a340a01c9a693a7d799485/LICENSE
46
- - specta-macros@2.0.0-rc.27: MIT; licenses/specta-macros-2.0.0-rc.27/; source: https://raw.githubusercontent.com/specta-rs/specta/bb4d872b131b1a4a58a340a01c9a693a7d799485/LICENSE
45
+ - specta@2.0.0-rc.28: MIT; licenses/specta-2.0.0-rc.28/; source: https://raw.githubusercontent.com/specta-rs/specta/82278bb5fef379b755af41b831ae3d3533e55b39/LICENSE
46
+ - specta-macros@2.0.0-rc.28: MIT; licenses/specta-macros-2.0.0-rc.28/; source: https://raw.githubusercontent.com/specta-rs/specta/82278bb5fef379b755af41b831ae3d3533e55b39/LICENSE
47
47
  - syn@2.0.119: MIT OR Apache-2.0; licenses/syn-2.0.119/
48
48
  - syn@3.0.9: MIT OR Apache-2.0; licenses/syn-3.0.9/
49
49
  - tempfile@3.27.0: MIT OR Apache-2.0; licenses/tempfile-3.27.0/
@@ -52,7 +52,7 @@ ALwith native implementations are proprietary. Dependencies retain their own lic
52
52
  - tokio@1.54.1: MIT; licenses/tokio-1.54.1/
53
53
  - tokio-macros@2.7.2: MIT; licenses/tokio-macros-2.7.2/
54
54
  - unicode-ident@1.0.27: (MIT OR Apache-2.0) AND Unicode-3.0; licenses/unicode-ident-1.0.27/
55
- - uuid@1.29.0: Apache-2.0 OR MIT; licenses/uuid-1.29.0/
55
+ - uuid@1.29.1: Apache-2.0 OR MIT; licenses/uuid-1.29.1/
56
56
  - widestring@1.2.1: MIT OR Apache-2.0; licenses/widestring-1.2.1/
57
57
  - windows@0.62.2: MIT OR Apache-2.0; licenses/windows-0.62.2/
58
58
  - windows-collections@0.3.2: MIT OR Apache-2.0; licenses/windows-collections-0.3.2/
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "module": "computer",
3
- "contract": 1,
3
+ "contract": 2,
4
4
  "abi": 1,
5
5
  "target": "x86_64-pc-windows-msvc",
6
6
  "binary": "alwith_native_computer.dll",
7
- "sha256": "332081cf57c3d361c684f84b3f3b19e707ae2f065333b74892422335c4506607"
7
+ "sha256": "df8b16de0c5661295732d19e459d9e044b57ffc637629f8dae2a3592e6ccf6d1"
8
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alwith/module-computer",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "files": [
@@ -10,7 +10,7 @@
10
10
  "README.md",
11
11
  "licenses",
12
12
  "proxy",
13
- "artifacts/cmux-cua-e0f7388-alwith.4-*.tar.gz",
13
+ "artifacts/cmux-cua-e0f7388-alwith.5-*.tar.gz",
14
14
  "native/**"
15
15
  ],
16
16
  "exports": {
package/proxy/stdio.mjs CHANGED
@@ -1,19 +1,162 @@
1
- // A byte-only stdio carrier. Authentication and all scheduling live in the native host.
1
+ // Keep MCP stdio alive across gateway disconnects. Never replay a dispatched action.
2
2
  import { connect } from "node:net"
3
+ import { createInterface } from "node:readline"
4
+
3
5
  const [address, token] = process.argv.slice(2)
4
6
  if (!address || !token || !/^127\.0\.0\.1:\d+$/.test(address)) throw new Error("Invalid computer gateway address")
5
- const socket = connect({ host: "127.0.0.1", port: Number(address.split(":")[1]) })
6
- socket.on("connect", () => {
7
- socket.write(`${token}\n`)
8
- process.stdin.pipe(socket)
9
- socket.pipe(process.stdout)
7
+ let socket
8
+ let opening
9
+ let pending
10
+ let initialization
11
+ let stopped = false
12
+ let sequence = 0
13
+ const wire = new WeakMap()
14
+ const output = (value) => process.stdout.write(`${wire.get(value) ?? JSON.stringify(value)}\n`)
15
+ const failure = () =>
16
+ new Error(
17
+ "Computer gateway disconnected. The previous action may have completed; do not replay it. Reconnect computer access and obtain a fresh app state. If the application restarted, reopen the conversation to renew its connection."
18
+ )
19
+
20
+ function exchange(request) {
21
+ return new Promise((resolve, reject) => {
22
+ if (!socket || socket.destroyed) {
23
+ reject(failure())
24
+ return
25
+ }
26
+ const timer = setTimeout(() => socket?.destroy(failure()), 155_000)
27
+ pending = { id: request.id, resolve, reject, timer }
28
+ socket.write(`${JSON.stringify(request)}\n`)
29
+ })
30
+ }
31
+
32
+ async function establish() {
33
+ if (socket && !socket.destroyed) return
34
+ if (opening) return opening
35
+ opening = new Promise((resolve, reject) => {
36
+ const current = connect({
37
+ host: "127.0.0.1",
38
+ port: Number(address.split(":")[1])
39
+ })
40
+ socket = current
41
+ const timer = setTimeout(() => current.destroy(new Error("Computer gateway connection timed out")), 5000)
42
+ current.on("error", () => {})
43
+ current.on("close", () => {
44
+ clearTimeout(timer)
45
+ reject(failure())
46
+ if (socket !== current) return
47
+ socket = undefined
48
+ if (pending) {
49
+ clearTimeout(pending.timer)
50
+ pending.reject(failure())
51
+ pending = undefined
52
+ }
53
+ })
54
+ createInterface({ input: current }).on("line", (line) => {
55
+ let response
56
+ try {
57
+ response = JSON.parse(line)
58
+ } catch {
59
+ current.destroy(failure())
60
+ return
61
+ }
62
+ if (!response || typeof response !== "object" || Array.isArray(response)) {
63
+ current.destroy(failure())
64
+ return
65
+ }
66
+ wire.set(response, line)
67
+ if (pending && response.id === pending.id) {
68
+ const completed = pending
69
+ pending = undefined
70
+ clearTimeout(completed.timer)
71
+ completed.resolve(response)
72
+ } else output(response)
73
+ })
74
+ current.on("connect", () => {
75
+ clearTimeout(timer)
76
+ current.write(`${token}\n`)
77
+ resolve()
78
+ })
79
+ })
80
+ try {
81
+ await opening
82
+ if (initialization) {
83
+ for (const method of ["initialize", "tools/list"]) {
84
+ const request = method === "initialize" ? { ...initialization } : { jsonrpc: "2.0", method, params: {} }
85
+ request.id = `carrier-handshake-${++sequence}`
86
+ const response = await exchange(request)
87
+ if (response.error) throw new Error(`Computer gateway ${method} failed`)
88
+ if (method === "initialize")
89
+ socket.write(`${JSON.stringify({ jsonrpc: "2.0", method: "notifications/initialized" })}\n`)
90
+ }
91
+ }
92
+ } catch (error) {
93
+ socket?.destroy()
94
+ throw error
95
+ } finally {
96
+ opening = undefined
97
+ }
98
+ }
99
+
100
+ let queue = Promise.resolve()
101
+ const input = createInterface({ input: process.stdin })
102
+ input.on("line", (line) => {
103
+ // Server-request replies and cancellation notifications must bypass a pending call.
104
+ let message
105
+ try {
106
+ message = JSON.parse(line)
107
+ } catch {
108
+ output({
109
+ jsonrpc: "2.0",
110
+ id: null,
111
+ error: { code: -32700, message: "Invalid JSON" }
112
+ })
113
+ return
114
+ }
115
+ if (!message || typeof message !== "object" || Array.isArray(message)) {
116
+ output({ jsonrpc: "2.0", id: null, error: { code: -32600, message: "Invalid MCP request" } })
117
+ return
118
+ }
119
+ if (!message.method || !Object.hasOwn(message, "id")) {
120
+ if (socket && !socket.destroyed) socket.write(`${line}\n`)
121
+ return
122
+ }
123
+ queue = queue.then(async () => {
124
+ if (stopped) return
125
+ let request
126
+ try {
127
+ request = JSON.parse(line)
128
+ } catch {
129
+ output({
130
+ jsonrpc: "2.0",
131
+ id: null,
132
+ error: { code: -32700, message: "Invalid JSON" }
133
+ })
134
+ return
135
+ }
136
+ try {
137
+ await establish()
138
+ if (!Object.hasOwn(request, "id")) {
139
+ socket.write(`${line}\n`)
140
+ return
141
+ }
142
+ const response = await exchange(request)
143
+ if (request.method === "initialize" && !response.error) initialization = request
144
+ output(response)
145
+ } catch (error) {
146
+ if (Object.hasOwn(request, "id"))
147
+ output({
148
+ jsonrpc: "2.0",
149
+ id: request.id,
150
+ error: { code: -32000, message: error.message }
151
+ })
152
+ }
153
+ })
10
154
  })
11
- socket.on("error", () => {
12
- process.exitCode = 1
155
+ function stop() {
156
+ stopped = true
157
+ socket?.destroy()
158
+ input.close()
13
159
  process.stdin.destroy()
14
- })
15
- socket.on("close", () => {
16
- process.stdin.destroy()
17
- })
18
- process.stdin.on("end", () => socket.destroy())
19
- process.stdout.on("error", () => socket.destroy())
160
+ }
161
+ input.on("close", stop)
162
+ process.stdout.on("error", stop)