@ravefox/space 0.2.1 → 0.3.0

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 (163) hide show
  1. package/LICENSE +21 -205
  2. package/README.md +80 -31
  3. package/bin/space.js +106 -0
  4. package/lib/agents.js +119 -0
  5. package/lib/credentials.js +95 -0
  6. package/lib/daemon.js +294 -0
  7. package/lib/harness.js +166 -0
  8. package/lib/http.js +101 -0
  9. package/lib/login.js +68 -0
  10. package/lib/mcp.js +34 -0
  11. package/lib/runtime.js +241 -0
  12. package/lib/store.js +96 -0
  13. package/lib/tools.js +93 -0
  14. package/package.json +27 -46
  15. package/NOTICE +0 -55
  16. package/assets/webhook-sdk/python/bot.py +0 -63
  17. package/assets/webhook-sdk/python/commonly.py +0 -232
  18. package/node_modules/@commonlyai/seats/README.md +0 -25
  19. package/node_modules/@commonlyai/seats/package.json +0 -22
  20. package/node_modules/@commonlyai/seats/src/adapters/hermes.js +0 -264
  21. package/node_modules/@commonlyai/seats/src/adapters/stub.js +0 -24
  22. package/node_modules/@commonlyai/seats/src/contract.js +0 -48
  23. package/node_modules/@commonlyai/seats/src/failures.js +0 -44
  24. package/node_modules/@commonlyai/seats/src/harness-plan.js +0 -329
  25. package/node_modules/@commonlyai/seats/src/index.js +0 -22
  26. package/node_modules/@commonlyai/seats/src/process-group.js +0 -269
  27. package/node_modules/@commonlyai/seats/src/record/format.js +0 -737
  28. package/node_modules/@commonlyai/seats/src/record/otel.js +0 -238
  29. package/node_modules/@commonlyai/seats/src/runtime-observation.js +0 -29
  30. package/node_modules/@commonlyai/seats/src/seat-model.js +0 -17
  31. package/node_modules/@commonlyai/seats/src/supervisor.js +0 -308
  32. package/node_modules/@commonlyai/seats/src/trace/events.js +0 -46
  33. package/node_modules/@commonlyai/seats/src/trace/store.js +0 -276
  34. package/node_modules/@commonlyai/seats/src/turn-processes.js +0 -226
  35. package/node_modules/@commonlyai/seats/src/upstream-refusal.js +0 -418
  36. package/node_modules/@commonlyai/seats/src/valet/env.js +0 -201
  37. package/node_modules/@commonlyai/seats/src/valet/grant.js +0 -123
  38. package/node_modules/@commonlyai/seats/src/valet/permissions.js +0 -213
  39. package/node_modules/@commonlyai/seats/src/wire/provider-proxy.js +0 -529
  40. package/skills/commonly/SKILL.md +0 -233
  41. package/src/commands/agent.js +0 -6334
  42. package/src/commands/daemon.js +0 -933
  43. package/src/commands/dev.js +0 -153
  44. package/src/commands/doctor.js +0 -141
  45. package/src/commands/inbox.js +0 -330
  46. package/src/commands/login.js +0 -194
  47. package/src/commands/mcp.js +0 -56
  48. package/src/commands/pod.js +0 -120
  49. package/src/commands/task.js +0 -279
  50. package/src/commands/verify.js +0 -48
  51. package/src/index.js +0 -99
  52. package/src/lib/adapter-login.js +0 -76
  53. package/src/lib/adapters/broker-bridge-entry.js +0 -76
  54. package/src/lib/adapters/claude.js +0 -2207
  55. package/src/lib/adapters/codex-broker-bridge.mjs +0 -298
  56. package/src/lib/adapters/codex.js +0 -1898
  57. package/src/lib/adapters/dsh.js +0 -513
  58. package/src/lib/adapters/goose.js +0 -510
  59. package/src/lib/adapters/hermes.js +0 -18
  60. package/src/lib/adapters/index.js +0 -68
  61. package/src/lib/adapters/opencode.js +0 -1681
  62. package/src/lib/adapters/pi-commonly-mcp.mjs +0 -71
  63. package/src/lib/adapters/pi-mcp-client.mjs +0 -617
  64. package/src/lib/adapters/pi-shell-env.mjs +0 -41
  65. package/src/lib/adapters/pi.js +0 -1025
  66. package/src/lib/adapters/qwen.js +0 -523
  67. package/src/lib/adapters/seat-model.js +0 -8
  68. package/src/lib/adapters/stub.js +0 -1
  69. package/src/lib/adapters/tested-version.js +0 -106
  70. package/src/lib/api.js +0 -205
  71. package/src/lib/claim-outcome.js +0 -128
  72. package/src/lib/claimed-work-gate.js +0 -73
  73. package/src/lib/cli-hint.js +0 -33
  74. package/src/lib/commit-attribution.js +0 -391
  75. package/src/lib/config.js +0 -155
  76. package/src/lib/content-refusal.js +0 -94
  77. package/src/lib/credential-file.js +0 -208
  78. package/src/lib/daemon-agent-states.js +0 -95
  79. package/src/lib/daemon-hint.js +0 -18
  80. package/src/lib/daemon-logs.js +0 -43
  81. package/src/lib/daemon-service-windows.js +0 -263
  82. package/src/lib/daemon-service.js +0 -486
  83. package/src/lib/daemon-state.js +0 -84
  84. package/src/lib/daemon-store.js +0 -119
  85. package/src/lib/daemon-supervisor.js +0 -629
  86. package/src/lib/daemon-watch.js +0 -115
  87. package/src/lib/declared-mcp-guard.js +0 -284
  88. package/src/lib/default-environment.js +0 -207
  89. package/src/lib/device-login.js +0 -126
  90. package/src/lib/digest-frame.js +0 -151
  91. package/src/lib/doctor.js +0 -291
  92. package/src/lib/egress-proxy.js +0 -160
  93. package/src/lib/enforcement.js +0 -946
  94. package/src/lib/environment.js +0 -681
  95. package/src/lib/first-output-watchdog.js +0 -191
  96. package/src/lib/git-readonly-server.js +0 -138
  97. package/src/lib/git-readonly.js +0 -463
  98. package/src/lib/git-remote-commonly.mjs +0 -100
  99. package/src/lib/grant-broker-guard.js +0 -345
  100. package/src/lib/hooks-config.js +0 -238
  101. package/src/lib/host-gh-broker.js +0 -152
  102. package/src/lib/host-gh-shim.mjs +0 -98
  103. package/src/lib/inbox.js +0 -483
  104. package/src/lib/instance-proxy.js +0 -76
  105. package/src/lib/machine-host.js +0 -29
  106. package/src/lib/mcp-credential-delivery.js +0 -121
  107. package/src/lib/mcp-first-run.js +0 -50
  108. package/src/lib/mcp-home.js +0 -644
  109. package/src/lib/mcp-ready.js +0 -68
  110. package/src/lib/mcp-server-version.js +0 -123
  111. package/src/lib/mcp-token.js +0 -36
  112. package/src/lib/mcp-warm-child.mjs +0 -412
  113. package/src/lib/memory-bridge.js +0 -191
  114. package/src/lib/memory-import.js +0 -156
  115. package/src/lib/missing-harness.js +0 -31
  116. package/src/lib/model-unavailable.js +0 -154
  117. package/src/lib/native-runtime-inventory.js +0 -40
  118. package/src/lib/outsider-grant-mcp.js +0 -82
  119. package/src/lib/own-key-launch.js +0 -42
  120. package/src/lib/pod-catch-up.js +0 -55
  121. package/src/lib/pod-focus.js +0 -224
  122. package/src/lib/pod-tail.js +0 -68
  123. package/src/lib/poll-liveness.js +0 -103
  124. package/src/lib/poll-retry.js +0 -81
  125. package/src/lib/poller.js +0 -200
  126. package/src/lib/provider-proxy.js +0 -42
  127. package/src/lib/public-seat-mcp-flag.js +0 -36
  128. package/src/lib/public-tool-error.js +0 -60
  129. package/src/lib/public-withheld-tools.js +0 -48
  130. package/src/lib/reply-receipt.js +0 -55
  131. package/src/lib/resolve-on-path.js +0 -22
  132. package/src/lib/runtime-inventory.js +0 -56
  133. package/src/lib/runtime-observation.js +0 -37
  134. package/src/lib/sandbox/bwrap.js +0 -275
  135. package/src/lib/sandbox/codex-perimeter.js +0 -16
  136. package/src/lib/sandbox/host-check.js +0 -268
  137. package/src/lib/sandbox/mode.js +0 -49
  138. package/src/lib/sandbox/opencode-loopback.mjs +0 -68
  139. package/src/lib/sandbox/seatbelt.js +0 -684
  140. package/src/lib/sandbox/turn-dir.js +0 -56
  141. package/src/lib/sandbox/windows-unsandboxed.js +0 -183
  142. package/src/lib/sandbox/workspace-git-config.js +0 -243
  143. package/src/lib/sandbox/workspace-pin.js +0 -158
  144. package/src/lib/seat-runtime-controls.js +0 -61
  145. package/src/lib/seat-stop.js +0 -97
  146. package/src/lib/server-skills.js +0 -32
  147. package/src/lib/session-recycle.js +0 -219
  148. package/src/lib/session-store.js +0 -215
  149. package/src/lib/skill-prompt.js +0 -74
  150. package/src/lib/skills-import.js +0 -113
  151. package/src/lib/spawn-credential.js +0 -402
  152. package/src/lib/spawn-retry.js +0 -311
  153. package/src/lib/stable-install.js +0 -176
  154. package/src/lib/supervised-turn.js +0 -352
  155. package/src/lib/task.js +0 -235
  156. package/src/lib/turn-failure-notice.js +0 -177
  157. package/src/lib/unconfined-seat-guard.js +0 -94
  158. package/src/lib/update-check.js +0 -192
  159. package/src/lib/upstream-refusal.js +0 -1
  160. package/src/lib/webhook-server.js +0 -109
  161. package/src/lib/windows-command.js +0 -393
  162. package/src/lib/workspace-git.js +0 -87
  163. package/src/lib/workspace-trust.js +0 -162
package/LICENSE CHANGED
@@ -1,205 +1,21 @@
1
-
2
- Apache License
3
- Version 2.0, January 2004
4
- http://www.apache.org/licenses/
5
-
6
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
-
8
- 1. Definitions.
9
-
10
- "License" shall mean the terms and conditions for use, reproduction,
11
- and distribution as defined by Sections 1 through 9 of this document.
12
-
13
- "Licensor" shall mean the copyright owner or entity authorized by
14
- the copyright owner that is granting the License.
15
-
16
- "Legal Entity" shall mean the union of the acting entity and all
17
- other entities that control, are controlled by, or are under common
18
- control with that entity. For the purposes of this definition,
19
- "control" means (i) the power, direct or indirect, to cause the
20
- direction or management of such entity, whether by contract or
21
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
- outstanding shares, or (iii) beneficial ownership of such entity.
23
-
24
- "You" (or "Your") shall mean an individual or Legal Entity
25
- exercising permissions granted by this License.
26
-
27
- "Source" form shall mean the preferred form for making modifications,
28
- including but not limited to software source code, documentation
29
- source, and configuration files.
30
-
31
- "Object" form shall mean any form resulting from mechanical
32
- transformation or translation of a Source form, including but
33
- not limited to compiled object code, generated documentation,
34
- and conversions to other media types.
35
-
36
- "Work" shall mean the work of authorship, whether in Source or
37
- Object form, made available under the License, as indicated by a
38
- copyright notice that is included in or attached to the work
39
- (an example is provided in the Appendix below).
40
-
41
- "Derivative Works" shall mean any work, whether in Source or Object
42
- form, that is based on (or derived from) the Work and for which the
43
- editorial revisions, annotations, elaborations, or other modifications
44
- represent, as a whole, an original work of authorship. For the purposes
45
- of this License, Derivative Works shall not include works that remain
46
- separable from, or merely link (or bind by name) to the interfaces of,
47
- the Work and Derivative Works thereof.
48
-
49
- "Contribution" shall mean any work of authorship, including
50
- the original version of the Work and any modifications or additions
51
- to that Work or Derivative Works thereof, that is intentionally
52
- submitted to Licensor for inclusion in the Work by the copyright owner
53
- or by an individual or Legal Entity authorized to submit on behalf of
54
- the copyright owner. For the purposes of this definition, "submitted"
55
- means any form of electronic, verbal, or written communication sent
56
- to the Licensor or its representatives, including but not limited to
57
- communication on electronic mailing lists, source code control systems,
58
- and issue tracking systems that are managed by, or on behalf of, the
59
- Licensor for the purpose of discussing and improving the Work, but
60
- excluding communication that is conspicuously marked or otherwise
61
- designated in writing by the copyright owner as "Not a Contribution."
62
-
63
- "Contributor" shall mean Licensor and any individual or Legal Entity
64
- on behalf of whom a Contribution has been received by Licensor and
65
- subsequently incorporated within the Work.
66
-
67
- 2. Grant of Copyright License. Subject to the terms and conditions of
68
- this License, each Contributor hereby grants to You a perpetual,
69
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
- copyright license to reproduce, prepare Derivative Works of,
71
- publicly display, publicly perform, sublicense, and distribute the
72
- Work and such Derivative Works in Source or Object form.
73
-
74
- 3. Grant of Patent License. Subject to the terms and conditions of
75
- this License, each Contributor hereby grants to You a perpetual,
76
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
- (except as stated in this section) patent license to make, have made,
78
- use, offer to sell, sell, import, and otherwise transfer the Work,
79
- where such license applies only to those patent claims licensable
80
- by such Contributor that are necessarily infringed by their
81
- Contribution(s) alone or by combination of their Contribution(s)
82
- with the Work to which such Contribution(s) was submitted. If You
83
- institute patent litigation against any entity (including a
84
- cross-claim or counterclaim in a lawsuit) alleging that the Work
85
- or a Contribution incorporated within the Work constitutes direct
86
- or contributory patent infringement, then any patent licenses
87
- granted to You under this License for that Work shall terminate
88
- as of the date such litigation is filed.
89
-
90
- 4. Redistribution. You may reproduce and distribute copies of the
91
- Work or Derivative Works thereof in any medium, with or without
92
- modifications, and in Source or Object form, provided that You
93
- meet the following conditions:
94
-
95
- (a) You must give any other recipients of the Work or
96
- Derivative Works a copy of this License; and
97
-
98
- (b) You must cause any modified files to carry prominent notices
99
- stating that You changed the files; and
100
-
101
- (c) You must retain, in the Source form of any Derivative Works
102
- that You distribute, all copyright, patent, trademark, and
103
- attribution notices from the Source form of the Work,
104
- excluding those notices that do not pertain to any part of
105
- the Derivative Works; and
106
-
107
- (d) If the Work includes a "NOTICE" text file as part of its
108
- distribution, then any Derivative Works that You distribute must
109
- include a readable copy of the attribution notices contained
110
- within such NOTICE file, excluding those notices that do not
111
- pertain to any part of the Derivative Works, in at least one
112
- of the following places: within a NOTICE text file distributed
113
- as part of the Derivative Works; within the Source form or
114
- documentation, if provided along with the Derivative Works; or,
115
- within a display generated by the Derivative Works, if and
116
- wherever such third-party notices normally appear. The contents
117
- of the NOTICE file are for informational purposes only and
118
- do not modify the License. You may add Your own attribution
119
- notices within Derivative Works that You distribute, alongside
120
- or as an addendum to the NOTICE text from the Work, provided
121
- that such additional attribution notices cannot be construed
122
- as modifying the License.
123
-
124
- You may add Your own copyright statement to Your modifications and
125
- may provide additional or different license terms and conditions
126
- for use, reproduction, or distribution of Your modifications, or
127
- for any such Derivative Works as a whole, provided Your use,
128
- reproduction, and distribution of the Work otherwise complies with
129
- the conditions stated in this License.
130
-
131
- 5. Submission of Contributions. Unless You explicitly state otherwise,
132
- any Contribution intentionally submitted for inclusion in the Work
133
- by You to the Licensor shall be under the terms and conditions of
134
- this License, without any additional terms or conditions.
135
- Notwithstanding the above, nothing herein shall supersede or modify
136
- the terms of any separate license agreement you may have executed
137
- with Licensor regarding such Contributions.
138
-
139
- 6. Trademarks. This License does not grant permission to use the trade
140
- names, trademarks, service marks, or product names of the Licensor,
141
- except as required for reasonable and customary use in describing the
142
- origin of the Work and reproducing the content of the NOTICE file.
143
-
144
- 7. Disclaimer of Warranty. Unless required by applicable law or
145
- agreed to in writing, Licensor provides the Work (and each
146
- Contributor provides its Contributions) on an "AS IS" BASIS,
147
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
- implied, including, without limitation, any warranties or conditions
149
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
- PARTICULAR PURPOSE. You are solely responsible for determining the
151
- appropriateness of using or redistributing the Work and assume any
152
- risks associated with Your exercise of permissions under this License.
153
-
154
- 8. Limitation of Liability. In no event and under no legal theory,
155
- whether in tort (including negligence), contract, or otherwise,
156
- unless required by applicable law (such as deliberate and grossly
157
- negligent acts) or agreed to in writing, shall any Contributor be
158
- liable to You for damages, including any direct, indirect, special,
159
- incidental, or consequential damages of any character arising as a
160
- result of this License or out of the use or inability to use the
161
- Work (including but not limited to damages for loss of goodwill,
162
- work stoppage, computer failure or malfunction, or any and all
163
- other commercial damages or losses), even if such Contributor
164
- has been advised of the possibility of such damages.
165
-
166
- 9. Accepting Warranty or Additional Liability. While redistributing
167
- the Work or Derivative Works thereof, You may choose to offer,
168
- and charge a fee for, acceptance of support, warranty, indemnity,
169
- or other liability obligations and/or rights consistent with this
170
- License. However, in accepting such obligations, You may act only
171
- on Your own behalf and on Your sole responsibility, not on behalf
172
- of any other Contributor, and only if You agree to indemnify,
173
- defend, and hold each Contributor harmless for any liability
174
- incurred by, or claims asserted against, such Contributor by reason
175
- of your accepting any such warranty or additional liability.
176
-
177
- END OF TERMS AND CONDITIONS
178
-
179
- APPENDIX: How to apply the Apache License to your work.
180
-
181
- To apply the Apache License to your work, attach the following
182
- boilerplate notice, with the fields enclosed by brackets "[]"
183
- replaced with your own identifying information. (Don't include
184
- the brackets!) The text should be enclosed in the appropriate
185
- comment syntax for the file format. We also recommend that a
186
- file or class name and description of purpose be included on the
187
- same "printed page" as the copyright notice for easier
188
- identification within third-party archives.
189
-
190
- Copyright [yyyy] [name of copyright owner]
191
-
192
- Licensed under the Apache License, Version 2.0 (the "License");
193
- you may not use this file except in compliance with the License.
194
- You may obtain a copy of the License at
195
-
196
- http://www.apache.org/licenses/LICENSE-2.0
197
-
198
- Unless required by applicable law or agreed to in writing, software
199
- distributed under the License is distributed on an "AS IS" BASIS,
200
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
- See the License for the specific language governing permissions and
202
- limitations under the License.
203
- Copyright 2026 Commonly
204
-
205
- Copyright 2026 Ravefox and contributors (Space modifications)
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ravefox and contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,64 +1,113 @@
1
1
  # Space CLI
2
2
 
3
- Connect your AI agents to **Space**. Set up a computer once, run agents in the
4
- background and manage their connections from your workspace.
3
+ Connect your AI teammates to **Space**, keep them available in the background
4
+ and manage their connections from your workspace.
5
5
 
6
- Built and maintained by **Ravefox**. Space CLI has its own releases, updates
7
- and product roadmap.
6
+ Built and maintained by **Ravefox**.
8
7
 
9
- [Open Space](https://space.ravefox.dev) · [Roadmap](https://vote.ravefox.dev/roadmap) · [Support](https://vote.ravefox.dev/support) · [Telegram](https://t.me/ravefoxlab)
8
+ [Space](https://space.ravefox.dev) · [Roadmap](https://vote.ravefox.dev/roadmap) · [Support](https://vote.ravefox.dev/support) · [Telegram](https://t.me/ravefoxlab)
10
9
 
11
- ## Get started
10
+ ## Start
12
11
 
13
- Requires **Node.js 22 or newer** and an installed, signed-in agent such as Codex.
12
+ Install **Node.js 22+** and sign in to **Codex 0.164+** or **Claude Code** on the
13
+ computer that will run your agent. Then:
14
14
 
15
15
  ```sh
16
16
  npx -y @ravefox/space@latest daemon setup --instance https://space.ravefox.dev
17
17
  ```
18
18
 
19
- Setup installs Space CLI, signs you into Space, registers your computer and
20
- sets up its background service. In Space, choose **On my computer** when adding
21
- an agent, then select the registered computer.
19
+ Approve the Space sign-in in your browser. Setup registers this computer and
20
+ installs a stable, private copy of Space CLI and its background service. Choose
21
+ **On my computer** in Space and select this computer when connecting an agent.
22
22
 
23
- You can connect more agents to the same computer without starting a separate
24
- terminal listener for each one.
23
+ Background setup supports macOS and Linux with user systemd. A Linux server
24
+ without a user session can run `space daemon run` under an operator-managed
25
+ service. Foreground connections are also available on supported harness hosts.
25
26
 
26
- ## Update
27
+ ## Install and update
27
28
 
28
- Run the setup command again to update the installed CLI and service:
29
+ ```sh
30
+ npm install -g @ravefox/space@latest
31
+ space --help
32
+ ```
33
+
34
+ Run `daemon setup` again to update the installed background service. One
35
+ computer supervises up to four explicitly assigned Codex/Claude agents; it does
36
+ not adopt unrelated connections from your disk.
29
37
 
30
38
  ```sh
31
- npx -y @ravefox/space@latest daemon setup --instance https://space.ravefox.dev
39
+ space daemon status
40
+ space daemon logs --lines 50
41
+ space daemon restart
42
+ space daemon stop
32
43
  ```
33
44
 
34
- ## Install the command globally
45
+ ## Connect one agent directly
46
+
47
+ Copy the scoped connection values from Space into your environment, then:
35
48
 
36
49
  ```sh
37
- npm install -g @ravefox/space@latest
38
- space --help
50
+ space agent run my-agent --adapter codex
51
+ ```
52
+
53
+ Space accepts `SPACE_API_URL` and `SPACE_AGENT_TOKEN`. Existing server-provided
54
+ `COMMONLY_API_URL` and `COMMONLY_AGENT_TOKEN` connection variables also work.
55
+ The token is saved privately after its agent identity is verified. Close the
56
+ terminal to stop a foreground listener; use daemon setup for background work.
57
+
58
+ ```sh
59
+ space agent list
60
+ space agent configure my-agent --model MODEL --instructions-file ./instructions.md
61
+ space agent run my-agent --workspace ./project --allow write
62
+ space doctor
39
63
  ```
40
64
 
41
- ## Run an agent in the foreground
65
+ Codex model commands use a restricted permission profile with command network
66
+ access disabled and credential directories denied. Claude runs with built-in
67
+ tools disabled and only the Space MCP tools enabled. Codex workspace writes
68
+ require `--allow write`. Unrestricted mode, arbitrary external MCP servers,
69
+ provider overrides and automatic local skill imports are refused explicitly.
70
+ Space tools read current-pod context, messages, attachments, posts and skills;
71
+ write permitted agent memory, comment on known posts and propose human-approved
72
+ actions. The runner posts the final reply, preventing duplicate chat sends.
73
+
74
+ ## Settings and authorization
75
+
76
+ State belongs to Space under `~/.space` (or `SPACE_HOME`), with private files
77
+ and separate human, machine, agent and short-lived turn credentials. Model
78
+ access belongs to the harness on the computer running it. Space CLI does not
79
+ include a subscription or transfer model credentials between computers.
42
80
 
43
- Use the connection settings shown in Space:
81
+ A local agent needs the computer awake and online. For replies while a laptop
82
+ is off, connect an always-on server and authenticate its harness there.
83
+ Each turn receives only its current pod context. Personal model history and
84
+ other projects are not automatically imported.
85
+
86
+ ## Existing connections
87
+
88
+ The 0.3 line is a fresh implementation. It does not read old connection state
89
+ implicitly. To import one existing private connection file, use:
44
90
 
45
91
  ```sh
46
- npx -y @ravefox/space@latest agent run my-agent --adapter codex
92
+ space migrate /absolute/path/to/connection.json
47
93
  ```
48
94
 
49
- This process runs until you stop it or close the terminal. Use background setup
50
- for a persistent connection.
95
+ The source remains intact. Unsupported custom tools, provider settings or
96
+ unrestricted permissions need explicit reconfiguration. Existing running
97
+ services keep their installed version until you intentionally update them.
51
98
 
52
- ## Where your agent runs
99
+ ## Use Space tools in another MCP client
53
100
 
54
- An agent on your computer needs that computer to be awake and online. To keep
55
- an agent available while your laptop is off, connect it from an always-on server
56
- and sign in to its model provider there.
101
+ ```sh
102
+ space mcp config my-agent --pod POD_ID
103
+ ```
57
104
 
58
- Space CLI uses the model access configured on the computer where the agent
59
- runs. It does not include a model subscription or silently transfer credentials
60
- between computers.
105
+ This prints an stdio MCP configuration with a private record reference, not the
106
+ agent token. Keep the record and your Space directory private.
61
107
 
62
108
  ## Feedback
63
109
 
64
- [Request a feature](https://vote.ravefox.dev/roadmap), [ask a question or report a bug](https://vote.ravefox.dev/support), or [join Ravefox on Telegram](https://t.me/ravefoxlab).
110
+ [Request a feature](https://vote.ravefox.dev/roadmap), [ask a question or report a bug](https://vote.ravefox.dev/support), or [join Telegram](https://t.me/ravefoxlab).
111
+
112
+ Space CLI source is released under the MIT license, copyright Ravefox.
113
+ Dependencies retain their respective licenses.
package/bin/space.js ADDED
@@ -0,0 +1,106 @@
1
+ #!/usr/bin/env node
2
+ // Copyright 2026 Ravefox. SPDX-License-Identifier: MIT
3
+ import { Command } from 'commander';
4
+ import { readFile, readdir } from 'node:fs/promises';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { join, resolve } from 'node:path';
7
+ import { readState, writeState, stateDir, sessionFor } from '../lib/store.js';
8
+ import { SpaceClient } from '../lib/http.js';
9
+ import { login, ensureLogin } from '../lib/login.js';
10
+ import { runAgent, agentKey, validateAgent } from '../lib/runtime.js';
11
+ import { availableAdapters } from '../lib/harness.js';
12
+ import { runMcp } from '../lib/mcp.js';
13
+ import { setupDaemon, registerMachine, runDaemon, daemonStatus, daemonService, daemonLogs, unregisterMachine } from '../lib/daemon.js';
14
+ import { importAgent, attachAgent, listAgents, lookupAgent, removeAgent, migrateLegacy } from '../lib/agents.js';
15
+
16
+ const meta = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'));
17
+ const program = new Command().name('space').description('Connect and manage your AI teammates in Space').version(meta.version).showHelpAfterError();
18
+ const print = value => console.log(typeof value === 'string' ? value : JSON.stringify(value, null, 2));
19
+ const stop = new AbortController();
20
+ process.once('SIGINT', () => stop.abort(new Error('Stopped')));
21
+ process.once('SIGTERM', () => stop.abort(new Error('Stopped')));
22
+ const withInstance = command => command.option('--instance <url>', 'Space server URL');
23
+ const withIdentity = command => withInstance(command).option('--instance-id <id>', 'Agent identity variant', 'default');
24
+ const human = async options => new SpaceClient(await ensureLogin({ instance: options.instance }));
25
+
26
+ withInstance(program.command('login').description('Sign in through your browser')).option('--no-browser', 'Print the approval URL without opening it').action(async options => { await login({ instance: options.instance, open: options.browser }); });
27
+ withInstance(program.command('whoami').description('Show the signed-in Space account')).action(async options => {
28
+ const result = await (await human(options)).get('/api/auth/user');
29
+ const user = result.user || result;
30
+ print({ username: user.username, email: user.email, id: user._id || user.id, instance: sessionFor(options.instance).url });
31
+ });
32
+ program.command('doctor').description('Check Node, installed harnesses and saved connections').action(async () => print({ version: meta.version, node: process.versions.node, state: stateDir(), adapters: await availableAdapters(), agents: await listAgents(), machine: readState('machine.json')?.machineName || null }));
33
+
34
+ const agent = program.command('agent').description('Connect an AI teammate');
35
+ agent.command('list').description('List local connections without secrets').action(async () => print(await listAgents()));
36
+ withIdentity(agent.command('run <name>').description('Keep one agent listening until stopped'))
37
+ .option('--adapter <name>', 'codex or claude')
38
+ .option('--workspace <path>', 'Local project directory')
39
+ .option('--model <name>', 'Explicit model for this connection')
40
+ .option('--allow <permissions>', 'Optional workspace writes: write')
41
+ .option('--instructions <text>', 'Instructions for this agent')
42
+ .action(async (name, options) => {
43
+ let record;
44
+ if (process.env.SPACE_AGENT_TOKEN || process.env.COMMONLY_AGENT_TOKEN) record = await importAgent({ name, ...options });
45
+ else record = await lookupAgent({ name, ...options });
46
+ if (!record) throw new Error('No saved connection. Use the connection command from Space or space agent attach.');
47
+ const requested = options.allow?.split(',').map(x => x.trim()).filter(Boolean) || [];
48
+ if (requested.some(x => x !== 'write')) throw new Error('Only --allow write is supported. Network access for model commands remains disabled.');
49
+ record = { ...record, ...(options.adapter ? { adapter: options.adapter } : {}), ...(options.workspace ? { workspacePath: resolve(options.workspace) } : {}), ...(options.model ? { model: options.model } : {}), ...(options.instructions ? { instructions: options.instructions } : {}), ...(requested.includes('write') ? { sandbox: 'workspace-write' } : {}) };
50
+ await runAgent({ record, signal: stop.signal });
51
+ });
52
+ withIdentity(agent.command('attach <adapter>').description('Create an agent connection in a pod'))
53
+ .requiredOption('--pod <id>', 'Space pod ID').requiredOption('--name <name>', 'Agent name')
54
+ .option('--env <file>', 'Explicit connection environment file')
55
+ .action(async (adapter, options) => { const result = await attachAgent({ adapter, ...options }); print({ connected: true, agent: result.agentName, instanceId: result.instanceId, adapter: result.adapter }); });
56
+ withIdentity(agent.command('detach <name>').description('Remove a local connection; leaves the server agent intact')).action(async (name, options) => print(await removeAgent({ name, ...options })));
57
+ withIdentity(agent.command('configure <name>').description('Change local model and instructions for a saved connection')).option('--model <name>').option('--instructions-file <file>').action(async (name, options) => {
58
+ const record = await lookupAgent({ name, ...options });
59
+ if (!record) throw new Error('No saved connection');
60
+ if (options.model) record.model = options.model;
61
+ if (options.instructionsFile) { const content = await readFile(options.instructionsFile, 'utf8'); if (content.length > 16000) throw new Error('Instructions exceed 16,000 characters'); record.instructions = content; }
62
+ validateAgent(record); writeState(`agents/${agentKey(record)}.json`, record); print({ updated: true, agent: record.agentName });
63
+ });
64
+ program.command('migrate <file>').description('Explicitly import one existing connection file without deleting the source').action(async path => { const record = await migrateLegacy({ path }); print({ imported: true, agent: record.agentName, instanceId: record.instanceId }); });
65
+
66
+ const daemon = program.command('daemon').description('Manage this computer and its background agents');
67
+ for (const [name, handler] of [['setup', setupDaemon], ['register', registerMachine]]) withInstance(daemon.command(name)).option('--name <name>', 'Computer name').action(async options => print(await handler(options)));
68
+ daemon.command('run').description('Run the computer supervisor in the foreground').action(() => runDaemon({ signal: stop.signal }));
69
+ daemon.command('status').description('Show computer and agent state').action(async () => print(await daemonStatus()));
70
+ daemon.command('logs').description('Show recent background service logs').option('--lines <count>', 'Number of lines', '50').action(async options => print(await daemonLogs(options)));
71
+ for (const action of ['install', 'start', 'stop', 'restart', 'uninstall']) daemon.command(action).action(async () => print(await daemonService(action)));
72
+ withInstance(daemon.command('unregister')).action(async options => print(await unregisterMachine(options)));
73
+
74
+ const mcp = program.command('mcp').description('Use Space tools from an MCP client');
75
+ mcp.command('serve').description('Serve MCP tools over stdio').requiredOption('--record <name>', 'Private record inside SPACE_HOME').option('--pod <id>', 'Current pod').action(async options => {
76
+ if (!/^(?:agents|turns)\/[a-z0-9-]+\.json$/.test(options.record)) throw new Error('Invalid MCP record name');
77
+ const record = readState(options.record);
78
+ if (!record?.runtimeToken) throw new Error('No saved agent credential');
79
+ const server = await runMcp({ record, podId: options.pod || record.podId });
80
+ stop.signal.addEventListener('abort', () => void server.close(), { once: true });
81
+ });
82
+ withIdentity(mcp.command('config <name>').description('Print MCP configuration without exposing a token')).option('--pod <id>').action(async (name, options) => {
83
+ const record = await lookupAgent({ name, ...options });
84
+ if (!record) throw new Error('No saved connection');
85
+ const pod = options.pod || record.podId;
86
+ if (!pod) throw new Error('Specify a pod with --pod');
87
+ print({ mcpServers: { space: { command: process.execPath, args: [fileURLToPath(import.meta.url), 'mcp', 'serve', '--record', `agents/${agentKey(record)}.json`, '--pod', pod], env: { SPACE_HOME: stateDir() } } } });
88
+ });
89
+ const pod = program.command('pod').description('Work with Space conversations');
90
+ withInstance(pod.command('list')).action(async options => print(await (await human(options)).get('/api/pods')));
91
+ withInstance(pod.command('tail <id>')).option('--limit <count>', 'Recent messages', '20').action(async (id, options) => {
92
+ if (!/^[a-f\d]{24}$/i.test(id)) throw new Error('Invalid pod ID');
93
+ const limit = Number(options.limit); if (!Number.isSafeInteger(limit) || limit < 1 || limit > 50) throw new Error('Limit must be 1–50');
94
+ print(await (await human(options)).get(`/api/messages/${id}`, { limit }));
95
+ });
96
+ withInstance(pod.command('send <id> <text>')).action(async (id, text, options) => {
97
+ if (!/^[a-f\d]{24}$/i.test(id)) throw new Error('Invalid pod ID');
98
+ const result = await (await human(options)).post(`/api/messages/${id}`, { content: text });
99
+ print({ sent: true, id: result._id || result.message?._id || result.id });
100
+ });
101
+ program.addHelpText('after', '\nGet started:\n npx -y @ravefox/space@latest daemon setup\n\nSpace: https://space.ravefox.dev\nSupport: https://vote.ravefox.dev/support\n');
102
+ try { await program.parseAsync(process.argv); }
103
+ catch (error) {
104
+ if (!stop.signal.aborted) console.error(`Space: ${error.message}`);
105
+ process.exitCode = stop.signal.aborted ? 0 : 1;
106
+ }
package/lib/agents.js ADDED
@@ -0,0 +1,119 @@
1
+ // Copyright 2026 Ravefox. SPDX-License-Identifier: MIT
2
+ import fs from 'node:fs';
3
+ import { resolve, join } from 'node:path';
4
+ import { homedir } from 'node:os';
5
+ import { SpaceClient } from './http.js';
6
+ import { readState, writeState, deleteState, stateDir, normalizeInstance, sessionFor } from './store.js';
7
+ import { ensureLogin } from './login.js';
8
+ import { agentKey, validateAgent } from './runtime.js';
9
+
10
+ const API = '/api/agents/runtime/installations';
11
+ const fileFor = (record) => `agents/${agentKey(record)}.json`;
12
+ function identity(name, instanceId = 'default') {
13
+ if (typeof name !== 'string' || !/^[a-z0-9_-]{1,64}$/.test(name)) throw new Error('Invalid agent name');
14
+ if (typeof instanceId !== 'string' || !/^[A-Za-z0-9._-]{1,64}$/.test(instanceId)) throw new Error('Invalid agent instance');
15
+ return { agentName: name, instanceId };
16
+ }
17
+ function sandbox(allow) {
18
+ const grants = allow ? String(allow).split(',').map(x => x.trim()) : [];
19
+ if (grants.some(x => x !== 'write')) throw new Error('Only --allow write is supported; unrestricted network access is not available.');
20
+ return grants.includes('write') ? 'workspace-write' : 'read-only';
21
+ }
22
+ async function verified(record) {
23
+ validateAgent(record);
24
+ const principal = await new SpaceClient({ url: record.instanceUrl, token: record.runtimeToken }).get(API);
25
+ if (principal?.agentName !== record.agentName || (principal.instanceId || 'default') !== record.instanceId
26
+ || !Array.isArray(principal.installations) || !principal.installations.some(row => row.status === 'active')) {
27
+ throw new Error('Runtime token does not match this agent and instance, or has no active installation.');
28
+ }
29
+ if (record.podId && !principal.installations.some(row => row.podId === record.podId && row.status === 'active')) throw new Error('Agent is not authorized for this pod.');
30
+ return record;
31
+ }
32
+ export async function importAgent({ name, instanceId = 'default', adapter = 'codex', instance, token, podId, workspace, model, instructions, allow } = {}) {
33
+ const instanceUrl = normalizeInstance(instance || process.env.SPACE_API_URL || process.env.COMMONLY_API_URL || sessionFor().url);
34
+ const envUrl = process.env.SPACE_API_URL || process.env.COMMONLY_API_URL;
35
+ if (!token && envUrl && normalizeInstance(envUrl) !== instanceUrl) throw new Error('The environment token belongs to another Space server.');
36
+ const runtimeToken = token || process.env.SPACE_AGENT_TOKEN || process.env.COMMONLY_AGENT_TOKEN;
37
+ if (typeof runtimeToken !== 'string' || !/^cm_agent_[A-Za-z0-9_-]+$/.test(runtimeToken)) throw new Error('Provide an agent-scoped runtime token.');
38
+ if (podId !== undefined && (typeof podId !== 'string' || !/^[a-f0-9]{24}$/i.test(podId))) throw new Error('Invalid pod ID');
39
+ if (model !== undefined && (typeof model !== 'string' || !model || model.length > 256 || /[\x00-\x1f]/.test(model))) throw new Error('Invalid model');
40
+ if (instructions !== undefined && (typeof instructions !== 'string' || instructions.length > 20000)) throw new Error('Invalid instructions');
41
+ if (workspace !== undefined && (typeof workspace !== 'string' || !workspace || /[\x00-\x1f]/.test(workspace))) throw new Error('Invalid workspace');
42
+ const record = { ...identity(name, instanceId), instanceUrl, runtimeToken, adapter, sandbox: sandbox(allow),
43
+ ...(podId ? { podId } : {}), ...(model ? { model } : {}), ...(instructions ? { instructions } : {}) };
44
+ record.workspacePath = workspace ? resolve(workspace) : join(homedir(), '.local', 'share', 'space', 'workspaces', agentKey(record));
45
+ await verified(record); writeState(fileFor(record), record); return record;
46
+ }
47
+ export function lookupAgent({ name, instanceId = 'default', instance } = {}) {
48
+ const expected = { ...identity(name, instanceId), instanceUrl: sessionFor(instance).url };
49
+ const record = readState(fileFor(expected));
50
+ if (!record) throw new Error('This agent is not connected to the selected Space server.');
51
+ if (record.agentName !== expected.agentName || record.instanceId !== expected.instanceId || normalizeInstance(record.instanceUrl) !== expected.instanceUrl) throw new Error('Saved agent identity mismatch');
52
+ return validateAgent(record);
53
+ }
54
+ export function listAgents() {
55
+ // readState checks owner, mode, symlinks and size on every discovered record.
56
+ readState('agents/.probe.json');
57
+ let names;
58
+ try { names = fs.readdirSync(join(stateDir(), 'agents')); } catch (error) { if (error.code === 'ENOENT') return []; throw error; }
59
+ return names.filter(name => /^[a-f0-9]{64}\.json$/.test(name)).map(name => {
60
+ const record = readState(`agents/${name}`); validateAgent(record);
61
+ if (name !== `${agentKey(record)}.json`) throw new Error('Saved agent filename mismatch');
62
+ const { agentName, instanceId, instanceUrl, adapter, model, workspacePath } = record;
63
+ return { agentName, instanceId, instanceUrl, adapter, model, workspacePath };
64
+ });
65
+ }
66
+ export function removeAgent(options) {
67
+ const record = lookupAgent(options); deleteState(fileFor(record)); return { removed: true, serverCredentialRevoked: false };
68
+ }
69
+ function privateJson(path) {
70
+ const fd = fs.openSync(resolve(path), fs.constants.O_RDONLY | (fs.constants.O_NOFOLLOW || 0));
71
+ try {
72
+ const stat = fs.fstatSync(fd);
73
+ if (!stat.isFile() || stat.nlink !== 1 || (process.getuid && stat.uid !== process.getuid()) || (stat.mode & 0o077) || stat.size > 1024 * 1024) throw new Error('Choose one owner-only JSON credential file.');
74
+ return JSON.parse(fs.readFileSync(fd, 'utf8'));
75
+ } finally { fs.closeSync(fd); }
76
+ }
77
+ export async function migrateLegacy({ path } = {}) {
78
+ if (typeof path !== 'string' || !path) throw new Error('Specify one legacy credential JSON file explicitly.');
79
+ const old = privateJson(path);
80
+ if (typeof old.instanceUrl !== 'string' || !old.instanceUrl) throw new Error('Legacy credential must identify its original server.');
81
+ normalizeInstance(old.instanceUrl);
82
+ const mode = old.environment?.sandbox?.mode || old.sandbox || 'read-only';
83
+ if (!['read-only', 'workspace-write'].includes(mode)) throw new Error('Legacy unrestricted access cannot be migrated automatically.');
84
+ if (old.environment?.provider || old.environment?.mcp?.some(server => !['commonly', 'space'].includes(server?.name))
85
+ || (old.environment?.skills && Object.values(old.environment.skills).some(paths => Array.isArray(paths) && paths.length))) throw new Error('Legacy custom tools/skills/provider settings require explicit setup.');
86
+ return importAgent({ name: old.agentName, instanceId: old.instanceId || 'default', adapter: old.adapter,
87
+ instance: old.instanceUrl, token: old.runtimeToken, podId: old.podId, workspace: old.workspacePath,
88
+ model: old.environment?.model || old.model, instructions: old.instructions, allow: mode === 'workspace-write' ? 'write' : undefined });
89
+ }
90
+ export async function attachAgent({ adapter = 'codex', name, pod, instance, instanceId = 'default', env } = {}) {
91
+ identity(name, instanceId);
92
+ if (typeof pod !== 'string' || !/^[a-f0-9]{24}$/i.test(pod)) throw new Error('Specify a valid pod ID.');
93
+ let environment = {};
94
+ if (env) {
95
+ environment = privateJson(env);
96
+ if (!environment || typeof environment !== 'object' || Array.isArray(environment)
97
+ || Object.keys(environment).some(key => !['model', 'effort', 'sandbox', 'version'].includes(key))
98
+ || (environment.sandbox && Object.keys(environment.sandbox).some(key => !['mode', 'trust'].includes(key)))) throw new Error('This release accepts only model, effort and sandbox settings; other environment capabilities need explicit support.');
99
+ }
100
+ validateAgent({ ...identity(name, instanceId), runtimeToken: 'cm_agent_validation', adapter, environment });
101
+ const session = await ensureLogin({ instance });
102
+ const client = new SpaceClient(session);
103
+ const result = await client.post('/api/registry/install', { agentName: name, instanceId, podId: pod,
104
+ version: '1.0.0', config: { runtime: { runtimeType: adapter, adapter, host: 'byo' }, environment },
105
+ scopes: ['context:read', 'messages:write', 'memory:read', 'memory:write'] });
106
+ const installed = result?.installation;
107
+ if (installed?.agentName !== name || installed.instanceId !== instanceId || installed.status !== 'active') throw new Error('Installed identity differs from the requested agent.');
108
+ let token = result.runtimeToken;
109
+ if (!token) {
110
+ try { const saved = lookupAgent({ name, instanceId, instance: session.url }); await verified(saved); token = saved.runtimeToken; } catch { /* ask server for a new non-rotating token */ }
111
+ }
112
+ if (!token) {
113
+ const issued = await client.post(`/api/registry/pods/${pod}/agents/${encodeURIComponent(name)}/runtime-tokens`, { instanceId });
114
+ token = issued.token;
115
+ if (!token) throw new Error('This identity already has a connection. Import its existing token or explicitly reconnect it from Space; no credential was rotated.');
116
+ }
117
+ return importAgent({ name, instanceId, adapter, instance: session.url, token, podId: pod, model: environment.model,
118
+ allow: environment.sandbox?.mode === 'workspace-write' ? 'write' : undefined });
119
+ }