agentsdock 0.0.0-stage → 1.0.10-beta.6

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.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
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.
package/NOTICE ADDED
@@ -0,0 +1,19 @@
1
+ AgentsDock
2
+ Copyright 2026 Zhengyi Luo and contributors
3
+
4
+ AgentsDock's original code is licensed under the Apache License, Version 2.0,
5
+ except where a component explicitly states another license. See LICENSE.
6
+
7
+ Third-party and separately licensed components retain their own copyrights,
8
+ licenses, and attribution notices. In particular:
9
+
10
+ - mobile-react/LICENSE preserves the Expo template's MIT license and
11
+ copyright notice for 650 Industries, Inc. (Expo).
12
+ - The agentsdock-native-video, agentsdock-native-terminal, and
13
+ agentsdock-android-updater modules retain the MIT license declared in
14
+ their package metadata.
15
+ - SwiftTerm retains its MIT license in
16
+ mobile-react/modules/agentsdock-native-terminal/ios/Vendor/SwiftTerm/LICENSE.
17
+
18
+ Dependencies and other bundled third-party materials remain subject to their
19
+ respective license terms. This notice does not replace those licenses.
package/README.md CHANGED
@@ -1,3 +1,231 @@
1
- # Temporary Holding Version
1
+ # agentsdock
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Install and manage your AgentsDock server with one command name. This is the
4
+ public CLI entry point; the desktop app remains a separate signed download.
5
+ The same-version `@agentsdock/server` dependency supplies the runtime and the
6
+ existing signed update protocol. Existing scoped-package installations remain
7
+ supported.
8
+
9
+ ## Install the command
10
+
11
+ ```sh
12
+ npm install -g agentsdock@beta
13
+ agentsdock list
14
+ ```
15
+
16
+ On a fresh machine, the global install automatically sets up and starts the
17
+ default server using the existing installer and its defaults. There is no
18
+ mandatory second `setup` command. It first checks for existing installation or
19
+ state, including named instances; repeat installs leave these unchanged and do
20
+ not restart, overwrite or upgrade a running service. The runtime lives in its
21
+ managed installation directory, independently of the npm package/cache.
22
+
23
+ The first short-command release is on Beta. Use the explicit `@beta` above;
24
+ untagged `npm install -g agentsdock` is for a future approved stable CLI release.
25
+ This documentation describes the package being prepared; commands are available
26
+ from the registry only after that package/channel has been published. Do not
27
+ infer name ownership from an npm 404 response.
28
+
29
+ `-g` makes the command available outside the current project when npm's global
30
+ bin directory is on your PATH. A local `npm install agentsdock` is also supported;
31
+ invoke it using `npx agentsdock`, not a bare shell command. Local/dependency
32
+ installs, linked source checkouts, CI installs and npx do not automatically start
33
+ a service. Use `npx agentsdock setup` when you deliberately want a server from a
34
+ local install. No installation changes shell configuration or logs into a provider.
35
+
36
+ Use Node >=22.14, `uv`, and Apple silicon macOS with a desktop login or Linux with
37
+ a working user systemd session. Run as the server owner without `sudo`. Install
38
+ and authenticate your preferred provider CLI separately. `setup` (also `install`)
39
+ refuses to overwrite an existing default installation or history. Global auto
40
+ setup uses the same `uv` and native service prerequisites; it does not install
41
+ Homebrew, provider CLIs or Tailscale without a separate user action.
42
+
43
+ The npm lifecycle may hide successful script output. Add `--foreground-scripts`
44
+ to the npm command if you want to see its status messages. Automatic setup never
45
+ copies raw installer output or access tokens into npm logs. Use `agentsdock list`
46
+ for connection addresses and `agentsdock token` to view/copy the token afterward.
47
+ A failed auto setup makes npm report failure instead of claiming the server is
48
+ ready. To obtain interactive diagnostics or choose a custom port/bind:
49
+
50
+ ```sh
51
+ AGENTSDOCK_SKIP_SETUP=1 npm install -g agentsdock@beta
52
+ agentsdock setup --port 7854 --bind 127.0.0.1
53
+ ```
54
+
55
+ `--ignore-scripts` also disables auto setup, as required by npm; this package does
56
+ not bypass that setting. `setup` remains the explicit retry/custom-install path.
57
+
58
+ Before a new setup or local instance-management helper runs, npm lifecycle
59
+ `node_modules/.bin` paths, npm's disposable `_npx` cache paths and npm node-gyp
60
+ shims are removed from the inherited PATH. Ordered absolute user, provider and
61
+ Node locations remain available; empty/relative entries are not persisted.
62
+ This lexical filter does not resolve symlink aliases or authenticate executables.
63
+ It prevents new temporary npm-path dependencies; it does not rewrite the saved
64
+ PATH of an already-installed server or change managed-update policy.
65
+
66
+ ## Manage servers
67
+
68
+ ```sh
69
+ agentsdock list
70
+ agentsdock status
71
+ agentsdock new work --port 7854 --bind 127.0.0.1
72
+ agentsdock status work
73
+ agentsdock token
74
+ agentsdock token work
75
+ agentsdock restart work
76
+ agentsdock remove work
77
+ ```
78
+
79
+ Flat commands are the primary interface. `servers ACTION` and `instances ACTION`
80
+ remain aliases, as do `new --name NAME` and `token/status --instance NAME`.
81
+ Start/stop/restart/remove require an
82
+ explicit instance or the native helper's explicit `--all` selector. Legacy and
83
+ named-instance stop/restart can interrupt running work; wait for chats to finish
84
+ first. The split default server requires verified idle admission before stopping
85
+ either component. Remove retains the
86
+ existing confirmation and history-preservation behavior. Tokens are private;
87
+ `token` only reads an existing token and does not reinstall or restart a server.
88
+ Without a name, `agentsdock token` lists this OS user's existing servers on the
89
+ machine (including stopped instances). Use Up/Down arrows to highlight a server
90
+ and Enter to select it; Esc, Ctrl+C or Ctrl+D cancels without showing a token.
91
+ The menu scrolls when needed and restores terminal input before showing a token.
92
+ It displays only the selected token, retaining the optional clipboard prompt.
93
+ Basic terminals without cursor control retain the numbered/name prompt, where
94
+ empty input cancels. Even a single server requires confirmation. In a script or with
95
+ redirected output, select explicitly: `agentsdock token default` or
96
+ `agentsdock token work`. Loopback binding is local-only; choose a reachable bind
97
+ explicitly if another device needs access.
98
+
99
+ `agentsdock status` prints a separate readable block for every instance: status,
100
+ addresses, installed version and port. `agentsdock status work` selects just one.
101
+ The status is the native service-manager state, not an authenticated health probe;
102
+ the version comes from that instance's installed runtime, not the npm CLI package.
103
+ `agentsdock info work` retains JSON output. If `setup` finds an existing default
104
+ installation, it leaves it unchanged and points to `agentsdock new` for another
105
+ instance (or `agentsdock new work --port 7854` for an explicit name and port).
106
+
107
+ Beta.5 preparation adds guarded control of both default-server components.
108
+ Stop/restart requires an installed worker that supports the paired lifecycle
109
+ protocol; installing a newer CLI alone does not update an older server. If the
110
+ command reports that requirement, update the installed server through the app's
111
+ signed managed-update path first. It leaves unsupported running services intact.
112
+ Busy work, pending updates, changed native registrations or uncertain ownership
113
+ prevent a forced stop. Interrupted operations retain an owned retry journal;
114
+ follow the command's retry guidance rather than deleting it manually.
115
+
116
+ Exact-package native setup, lifecycle and removal acceptance for beta.5 remains
117
+ pending. Source/fixture tests are not proof of fresh macOS or Linux service
118
+ operation. Earlier Linux auto-setup results do not substitute for the new pair.
119
+
120
+ The packaged CLI has also been installed and reinstalled on Apple silicon
121
+ macOS with existing services. Disposable named launchd instances passed real
122
+ creation (explicit and automatic name/port), token/authenticated-health,
123
+ start/stop/restart, uninstall cancellation and removal/name-release checks.
124
+ Saved test data remained in its private backup. This does not close the
125
+ fresh-default or split-service acceptance gaps above.
126
+
127
+ ## Complete public command comparison
128
+
129
+ `work` is an example instance name; `default` selects the original instance.
130
+ These are server installation/administration commands, not the run-bound
131
+ mailbox/jobs/team tools supplied to agents inside an authorized chat.
132
+
133
+ | Purpose | Previous entry point | Short entry point |
134
+ | --- | --- | --- |
135
+ | Install the command and create a fresh default server | `npm install -g @agentsdock/server` then `agentsdock-server install` | `npm install -g agentsdock` (automatic first setup) |
136
+ | Explicit retry/custom default setup | `agentsdock-server install` / first `./install.sh` | `agentsdock setup` or `agentsdock install` |
137
+ | All instances and connection addresses | `./instances.sh list` | `agentsdock list` |
138
+ | All instance statuses, addresses, versions and ports | `./instances.sh status` | `agentsdock status` (separate blocks) |
139
+ | One instance's readable status | `./instances.sh status work` | `agentsdock status work` |
140
+ | One instance's details as JSON | `./instances.sh info work` | `agentsdock info work` |
141
+ | New automatic name/free port | `./instances.sh new` | `agentsdock new` |
142
+ | New named instance | `./instances.sh new --name work --port 7854` | `agentsdock new work --port 7854` |
143
+ | Start one | `./instances.sh start work` | `agentsdock start work` |
144
+ | Stop one | `./instances.sh stop work` | `agentsdock stop work` |
145
+ | Restart one | `./instances.sh restart work` | `agentsdock restart work` |
146
+ | Choose an existing server and read its token | `./instances.sh token` | `agentsdock token` |
147
+ | Read default token directly | `./install.sh --show-token` | `agentsdock token default` |
148
+ | Read named token | `./install.sh --instance work --show-token` | `agentsdock token work` |
149
+ | Uninstall one, preserve history | `./uninstall.sh --instance work` / `./instances.sh remove work` | `agentsdock remove work` or `agentsdock uninstall work` |
150
+ | Explicitly purge instance state | `./uninstall.sh --instance work --purge-state` | `agentsdock remove work --purge-state` |
151
+ | Start/stop/restart all | `./instances.sh restart --all` (or start/stop) | `agentsdock restart --all` (or start/stop) |
152
+ | Exclude an instance from a bulk action | `./instances.sh restart --all --exclude default` | `agentsdock restart --all --exclude default` |
153
+ | Uninstall all with confirmation | `./instances.sh remove --all` / bare `./uninstall.sh` | `agentsdock remove --all` |
154
+ | Submit a signed managed update | `agentsdock-server update` plus required descriptor/identity arguments | `agentsdock update` with the same arguments |
155
+ | Guarded pre-activation recovery | `agentsdock-server recover` | `agentsdock recover` |
156
+ | Installed CLI/package version | `agentsdock-server --version` | `agentsdock version` or `agentsdock --version` |
157
+ | CLI help | `agentsdock-server --help` | `agentsdock help` / `agentsdock --help` / `agentsdock -h` |
158
+
159
+ Supported options retain their native meanings:
160
+
161
+ - `setup`/`install`: `--port`, `--bind`, `--non-interactive`, `--dry-run`.
162
+ - `new`: optional positional name or `--name`, `--port`, `--bind`.
163
+ - `start`/`stop`/`restart`/`remove`: positional name or `--instance NAME`, or
164
+ explicit `--all`; repeat `--exclude NAME` only with `--all`.
165
+ - `remove`/`uninstall`: also `--yes` and `--purge-state`. Purge retains the native
166
+ interactive confirmation and cannot be made unattended with `--yes`.
167
+ - `token`/`status`: positional name or `--instance NAME`, never both.
168
+ - `update`: the six required arguments in the example below. Bare `update` or
169
+ `update work` does not select a registry tag or silently restart a server.
170
+
171
+ Differences from the old source scripts:
172
+
173
+ - `setup`/`install` is fresh-default-only. Re-running `./install.sh` on an
174
+ installed service could reinstall it; the public CLI instead refuses that
175
+ path and keeps signed managed updates separate.
176
+ - Bare `remove`/`uninstall` refuses an omitted target. Unlike bare
177
+ `./uninstall.sh`, it never implies removing all instances.
178
+ - `version` is the installed CLI/package version, not a remote or already-running
179
+ server's health/version result. `info` reads the selected instance's metadata.
180
+ - Source-only operations are **not yet exposed** as short commands: rebinding or
181
+ changing the port of an existing installation; manifest-based bulk creation
182
+ (`./instances.sh install --manifest ...`); Team Hub configuration/reactivation;
183
+ foreground development `python agent_server.py serve`. There are no implemented
184
+ `agentsdock configure`, `agentsdock logs`, `agentsdock login`, or `agentsdock serve`
185
+ commands in this package.
186
+ - Direct checkout reinstalls (`./instances.sh update`, installer's version or
187
+ custom-root overrides) are not aliases for the signed `update` command. Split
188
+ runtime preparation/activation and internal recovery flags remain under the
189
+ managed updater, rather than arbitrary public pass-through arguments.
190
+ - Provider login remains in each provider's native CLI. Existing source scripts
191
+ and the `agentsdock-server` command remain available for their original uses.
192
+
193
+ ## Updates and recovery
194
+
195
+ Prefer the app's update control. `agentsdock update` accepts the same signed
196
+ descriptor, identity and token-file arguments as `agentsdock-server update`:
197
+
198
+ ```sh
199
+ agentsdock update --server-url https://server.example \
200
+ --server-identity ID --server-instance-id INSTANCE \
201
+ --token-file /private/path/server-token \
202
+ --manifest agents-server-npm-manifest.json \
203
+ --signature agents-server-npm-manifest.sig
204
+ ```
205
+
206
+ `agentsdock recover` retains the narrowly scoped existing pre-activation recovery
207
+ checks. The CLI does not turn `servers update` or arbitrary installer arguments
208
+ into an unsigned update bypass. Updating this npm command does not itself update
209
+ an already-running server; managed activation remains independent of npm caches.
210
+
211
+ ## Preparing this package
212
+
213
+ From the canonical repository root:
214
+
215
+ ```sh
216
+ python3 server/scripts/package_agentsdock_cli.py --output dist/agentsdock-cli
217
+ ```
218
+
219
+ This stamps the same committed `server/VERSION`, pins the exact scoped dependency,
220
+ and produces a tarball and checksum receipt without publishing or installing.
221
+ Test the tarball with that exact server package before publication. Release
222
+ automation must publish/verify the scoped runtime first, then this CLI, with the
223
+ same stable/beta channel and appropriate trusted-publisher ownership. Existing
224
+ server manifests, signing keys and previously frozen candidates are unchanged.
225
+
226
+ The canonical `server-npm-publish.yml` now prepares both packages and publishes
227
+ the verified runtime before this CLI, with exact source/version/hash checks and
228
+ explicit stable-tag preservation. See the
229
+ [matched release procedure](../../../docs/NPM_CLI_RELEASES.md) for private staging,
230
+ first-publication authentication and required native acceptance. A first beta
231
+ uses `agentsdock@beta`; it does not create a stable unscoped `latest` tag.
package/cli.cjs ADDED
@@ -0,0 +1,164 @@
1
+ #!/usr/bin/env node
2
+ 'use strict'
3
+
4
+ const fs = require('node:fs')
5
+ const path = require('node:path')
6
+ const os = require('node:os')
7
+ const { spawnSync } = require('node:child_process')
8
+
9
+ const HELP = `Usage: agentsdock setup [--port PORT] [--bind IP] [--non-interactive] [--dry-run]
10
+ agentsdock install [same options as setup]
11
+ agentsdock list
12
+ agentsdock info NAME
13
+ agentsdock new [NAME] [--port PORT] [--bind IP]
14
+ agentsdock start|stop|restart|remove NAME
15
+ agentsdock token [NAME]
16
+ agentsdock status [NAME]
17
+ agentsdock update --server-url URL --server-identity ID --server-instance-id ID
18
+ --token-file PATH --manifest PATH --signature PATH
19
+ agentsdock recover
20
+ agentsdock --version
21
+
22
+ setup/install creates a fresh default server. Use new for another instance.
23
+ remove (also uninstall) asks for confirmation and preserves history by default.
24
+ token lists existing servers; use Up/Down and Enter to choose, or token NAME for direct access. Keep tokens private.
25
+ status shows each instance's status, addresses, installed version and port; add NAME for one instance.
26
+ update uses the signed managed updater; npm installation alone never upgrades a running server.
27
+ start/stop/restart/remove also accept --all [--exclude NAME]; an omitted target never selects all.
28
+ new --name NAME, token/status --instance NAME, and servers/instances ACTION remain supported.
29
+ Install this command globally with npm install -g agentsdock, or use npx agentsdock.
30
+ The first global installation automatically sets up the server; existing installations are left unchanged.
31
+ `
32
+ const ROOT_SELECTORS = ['AGENTS_SERVER_INSTALL_DIR', 'AGENTS_SERVER_CONFIG_DIR',
33
+ 'AGENTS_SERVER_STATE_DIR', 'AGENTSDOCK_STATE_DIR', 'ZENITHBOT_AGENT_DIR',
34
+ 'XDG_CONFIG_HOME', 'XDG_DATA_HOME', 'AGENTS_SERVER_INSTANCE']
35
+ const ENV_KEYS = ['PATH', 'USER', 'LOGNAME', 'SHELL', 'TMPDIR', 'LANG', 'LC_ALL',
36
+ 'TERM', 'TERMINFO', 'SSL_CERT_FILE', 'SSL_CERT_DIR', 'XDG_RUNTIME_DIR', 'DBUS_SESSION_BUS_ADDRESS']
37
+
38
+ function selector(args, fallback) {
39
+ if (!args.length) return fallback
40
+ const name = args.length === 1 ? args[0] : args.length === 2 && args[0] === '--instance' ? args[1] : ''
41
+ if (!/^[a-z][a-z0-9-]{0,31}$/.test(name)) throw new Error('Use NAME or --instance NAME to select one server.')
42
+ return name
43
+ }
44
+
45
+ const INSTANCE_ACTIONS = ['list', 'info', 'new', 'start', 'stop', 'restart', 'remove']
46
+ function instanceRequest(action, args) {
47
+ if (!INSTANCE_ACTIONS.includes(action)) {
48
+ throw new Error('Use list, info, new, start, stop, restart, or remove. Use agentsdock update for signed updates.')
49
+ }
50
+ if (action === 'new' && args[0] && !args[0].startsWith('-')) {
51
+ const name = selector([args[0]])
52
+ if (args.slice(1).some(value => value === '--name' || value.startsWith('--name='))) {
53
+ throw new Error('Select the new instance name once: NAME or --name NAME.')
54
+ }
55
+ args = ['--name', name, ...args.slice(1)]
56
+ }
57
+ return { kind: 'local', script: 'instances.sh', args: [action, ...args] }
58
+ }
59
+
60
+ function parse(argv) {
61
+ const [command = '--help', ...args] = argv
62
+ if (argv.some(value => /[\x00-\x1f\x7f]/.test(value))) throw new Error('Invalid control character in arguments.')
63
+ if (['help', '--help', '-h', '--version', 'version'].includes(command)) {
64
+ if (args.length) throw new Error('Unexpected arguments.')
65
+ return { kind: ['--version', 'version'].includes(command) ? 'version' : 'help' }
66
+ }
67
+ if (['setup', 'install', 'update', 'recover'].includes(command)) {
68
+ return { kind: 'core', args: [command === 'setup' ? 'install' : command, ...args] }
69
+ }
70
+ if (command === 'token') {
71
+ const name = selector(args)
72
+ return name
73
+ ? { kind: 'local', script: 'install.sh', args: ['--instance', name, '--show-token'] }
74
+ : { kind: 'local', script: 'instances.sh', args: ['token'] }
75
+ }
76
+ if (command === 'status') {
77
+ const name = selector(args)
78
+ return { kind: 'local', script: 'instances.sh', args: name ? ['status', name] : ['status'] }
79
+ }
80
+ if (INSTANCE_ACTIONS.includes(command) || command === 'uninstall') {
81
+ return instanceRequest(command === 'uninstall' ? 'remove' : command, args)
82
+ }
83
+ if (['servers', 'instances'].includes(command)) {
84
+ const [action = 'list', ...rest] = args
85
+ // Internal binding helpers, manifests and the checkout-only update bypass
86
+ // are not public npm commands. Python retains all instance/path validation.
87
+ return instanceRequest(action, rest)
88
+ }
89
+ throw new Error('Unknown command. Run agentsdock --help.')
90
+ }
91
+
92
+ function readJson(filename) {
93
+ const info = fs.lstatSync(filename)
94
+ if (!info.isFile() || info.size > 64000) throw new Error('Invalid CLI package metadata.')
95
+ return JSON.parse(fs.readFileSync(filename, 'utf8'))
96
+ }
97
+
98
+ function loadRuntime(packageRoot = __dirname, resolve = require.resolve) {
99
+ const own = readJson(path.join(packageRoot, 'package.json'))
100
+ const coreRoot = path.dirname(resolve('@agentsdock/server/package.json'))
101
+ const core = readJson(path.join(coreRoot, 'package.json'))
102
+ if (own.name !== 'agentsdock' || core.name !== '@agentsdock/server' ||
103
+ own.dependencies?.['@agentsdock/server'] !== own.version || core.version !== own.version) {
104
+ throw new Error('CLI and server package versions differ. Reinstall the matching agentsdock package.')
105
+ }
106
+ const payload = path.join(coreRoot, 'server')
107
+ const versionFile = path.join(payload, 'VERSION')
108
+ const info = fs.lstatSync(versionFile)
109
+ if (!info.isFile() || info.size > 200 || fs.readFileSync(versionFile, 'utf8').trim() !== own.version) {
110
+ throw new Error('CLI and server payload versions differ. Reinstall the matching agentsdock package.')
111
+ }
112
+ const coreCli = require(path.join(coreRoot, 'npm/cli.cjs'))
113
+ return { version: own.version, payload, coreRoot, run: coreCli.run, preflight: coreCli.ensureFreshInstall,
114
+ persistentPath: coreCli.persistentPath }
115
+ }
116
+
117
+ function localEnvironment(context, runtime) {
118
+ if (context.uid === 0) throw new Error('Run as the server owner, without sudo.')
119
+ if (!['darwin', 'linux'].includes(context.platform)) throw new Error('Server management requires macOS or Linux.')
120
+ for (const name of ROOT_SELECTORS) {
121
+ if (context.env[name]) throw new Error(`Custom selector ${name} is unsupported; use --instance to select a managed server.`)
122
+ }
123
+ const env = { HOME: context.home }
124
+ for (const key of ENV_KEYS) if (context.env[key]) env[key] = context.env[key]
125
+ if (runtime && Object.hasOwn(context.env, 'PATH')) env.PATH = runtime.persistentPath(context.env.PATH)
126
+ return env
127
+ }
128
+
129
+ async function run(argv, overrides = {}) {
130
+ const context = { print: text => process.stdout.write(`${text}\n`), env: process.env,
131
+ home: os.homedir(), uid: process.getuid?.(), platform: process.platform,
132
+ spawn: spawnSync, load: loadRuntime, ...overrides }
133
+ const request = parse(argv)
134
+ if (request.kind === 'help') { context.print(HELP); return 0 }
135
+ const runtime = context.load()
136
+ if (request.kind === 'version') { context.print(runtime.version); return 0 }
137
+ if (request.kind === 'core') {
138
+ try {
139
+ const env = request.args[0] === 'update' ? context.env : localEnvironment(context, runtime)
140
+ return await runtime.run(request.args, { env,
141
+ print: text => context.print(text.replaceAll('agentsdock-server', 'agentsdock')) })
142
+ } catch (error) {
143
+ if (request.args[0] === 'install' && error.code === 'AGENTSDOCK_EXISTING_INSTALLATION') {
144
+ error.message += '\nIf you want to add a new server instance, run: agentsdock new' +
145
+ '\nOr choose its name and port: agentsdock new work --port 7854'
146
+ }
147
+ throw error
148
+ }
149
+ }
150
+ const env = localEnvironment(context, runtime)
151
+ const script = path.join(runtime.payload, request.script)
152
+ if (!fs.lstatSync(script).isFile()) throw new Error('The installed server helper is not a regular file.')
153
+ // Preserve the terminal for confirmation/clipboard prompts. Never interpolate
154
+ // a command string, inherit startup hooks, or start a detached helper.
155
+ const result = context.spawn('/bin/bash', [script, ...request.args], { stdio: 'inherit', env })
156
+ if (result.error) throw new Error('Could not start the installed server helper.')
157
+ return Number.isInteger(result.status) ? result.status : 1
158
+ }
159
+
160
+ if (require.main === module) run(process.argv.slice(2)).then(code => { process.exitCode = code }).catch(error => {
161
+ process.stderr.write(`agentsdock: ${error.message.replaceAll('agentsdock-server', 'agentsdock')}\n`)
162
+ process.exitCode = 1
163
+ })
164
+ module.exports = { parse, loadRuntime, localEnvironment, run }
package/package.json CHANGED
@@ -1,6 +1,38 @@
1
1
  {
2
2
  "name": "agentsdock",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.10-beta.6",
4
+ "description": "Install and manage your AgentsDock server from the command line",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/ZhengyiLuo/AgentsDock.git",
9
+ "directory": "server/npm/agentsdock"
10
+ },
11
+ "bin": {
12
+ "agentsdock": "cli.cjs"
13
+ },
14
+ "engines": {
15
+ "node": ">=22.14.0"
16
+ },
17
+ "os": [
18
+ "darwin",
19
+ "linux"
20
+ ],
21
+ "files": [
22
+ "cli.cjs",
23
+ "postinstall.cjs",
24
+ "README.md",
25
+ "LICENSE",
26
+ "NOTICE"
27
+ ],
28
+ "scripts": {
29
+ "postinstall": "node postinstall.cjs"
30
+ },
31
+ "dependencies": {
32
+ "@agentsdock/server": "1.0.10-beta.6"
33
+ },
34
+ "publishConfig": {
35
+ "access": "public",
36
+ "registry": "https://registry.npmjs.org/"
37
+ }
38
+ }
@@ -0,0 +1,121 @@
1
+ 'use strict'
2
+
3
+ const path = require('node:path')
4
+ const fs = require('node:fs')
5
+ const os = require('node:os')
6
+ const { isIP } = require('node:net')
7
+ const { spawn, spawnSync } = require('node:child_process')
8
+ const { loadRuntime, localEnvironment } = require('./cli.cjs')
9
+
10
+ function skipReason(context) {
11
+ const env = context.env
12
+ if (env.AGENTSDOCK_SKIP_SETUP === '1') return 'Automatic setup was explicitly skipped.'
13
+ if ((env.CI && !['0', 'false'].includes(env.CI.toLowerCase())) || env.GITHUB_ACTIONS === 'true') {
14
+ return 'CI installation: automatic service setup skipped.'
15
+ }
16
+ if (env.npm_lifecycle_event !== 'postinstall' || env.npm_command !== 'install') {
17
+ return 'Automatic setup only runs during npm install.'
18
+ }
19
+ if (env.npm_config_global !== 'true') return 'Local installation: run npx agentsdock setup when you want to create a server.'
20
+ // Never start a service merely because another global tool depends on us,
21
+ // or because a source checkout was linked. npm's direct global package must
22
+ // occupy its canonical prefix, not a nested dependency or npx cache.
23
+ const prefix = env.npm_config_prefix
24
+ if (!prefix || !path.isAbsolute(prefix)) return 'Could not establish the direct global installation; setup skipped.'
25
+ const expected = path.join(path.resolve(prefix), 'lib/node_modules/agentsdock')
26
+ let direct = false
27
+ try {
28
+ direct = fs.lstatSync(expected).isDirectory() &&
29
+ fs.realpathSync(context.packageRoot) === fs.realpathSync(expected)
30
+ } catch { /* A different npm layout must never create an unexpected service. */ }
31
+ if (!direct) {
32
+ return 'Dependency or linked installation: automatic service setup skipped.'
33
+ }
34
+ return null
35
+ }
36
+
37
+ function lines(accept) {
38
+ let pending = '', overflow = false
39
+ return chunk => {
40
+ for (const character of chunk.toString()) {
41
+ if (character === '\n') {
42
+ if (!overflow) accept(pending.replace(/\r$/, ''))
43
+ pending = ''; overflow = false
44
+ } else if (!overflow && pending.length < 16384) pending += character
45
+ else { pending = ''; overflow = true }
46
+ }
47
+ }
48
+ }
49
+
50
+ async function postinstall(overrides = {}) {
51
+ const context = { env: process.env, home: os.homedir(), uid: process.getuid?.(),
52
+ platform: process.platform, packageRoot: __dirname, spawn: spawnSync,
53
+ launch: spawn, load: loadRuntime, print: text => process.stdout.write(`agentsdock: ${text}\n`), ...overrides }
54
+ const skipped = skipReason(context)
55
+ if (skipped) { context.print(skipped); return 0 }
56
+ const environment = localEnvironment(context)
57
+ for (const relative of ['.local/share/agents-server-instances', '.config/agents-server-instances', '.agentsdock-instances']) {
58
+ try {
59
+ fs.lstatSync(path.join(context.home, relative))
60
+ context.print('Existing named-server installation or state found; left unchanged. Use agentsdock list to inspect it.')
61
+ return 0
62
+ } catch (error) { if (error.code !== 'ENOENT') throw error }
63
+ }
64
+ const runtime = context.load()
65
+ if (Object.hasOwn(context.env, 'PATH')) environment.PATH = runtime.persistentPath(context.env.PATH)
66
+ try {
67
+ runtime.preflight({ ...context, env: environment })
68
+ } catch (error) {
69
+ if (error.code !== 'AGENTSDOCK_EXISTING_INSTALLATION') throw error
70
+ context.print('Existing server installation or state found; left unchanged. Use agentsdock list to inspect it.')
71
+ return 0
72
+ }
73
+ context.print('Setting up your first AgentsDock server. This may take a few minutes.')
74
+ let receipt, missingUv = false, racedInstallation = false
75
+ // Do not forward installer output into npm's captured logs: the setup JSON
76
+ // contains an access token. Retain only a validated non-secret summary and
77
+ // fixed diagnostics, never raw output (even when the installer fails).
78
+ const stdout = lines(line => {
79
+ if (!line.startsWith('AGENTSDOCK_SETUP_RESULT=')) return
80
+ try {
81
+ const result = JSON.parse(line.slice('AGENTSDOCK_SETUP_RESULT='.length))
82
+ const url = new URL(result.server_url)
83
+ const host = url.hostname.replace(/^\[|\]$/g, '')
84
+ if (result.server_version === runtime.version && url.protocol === 'http:' &&
85
+ (host === 'localhost' || isIP(host)) &&
86
+ !url.username && !url.password && !url.search && !url.hash && url.pathname === '/') {
87
+ receipt = { url: url.origin, version: runtime.version }
88
+ }
89
+ } catch { /* A malformed/missing success receipt must not become success. */ }
90
+ })
91
+ const stderr = lines(line => {
92
+ if (/trusted uv|uv.*not.*(?:available|found)/i.test(line)) missingUv = true
93
+ if (/An existing server installation or state was found|An AgentsServer service already exists|An existing user service was found/.test(line)) racedInstallation = true
94
+ })
95
+ const status = await new Promise((resolve, reject) => {
96
+ const child = context.launch(process.execPath,
97
+ [path.join(runtime.coreRoot, 'npm/cli.cjs'), 'install', '--non-interactive'],
98
+ { env: environment, stdio: ['ignore', 'pipe', 'pipe'] })
99
+ child.stdout.on('data', stdout)
100
+ child.stderr.on('data', stderr)
101
+ child.once('error', () => reject(new Error('Could not launch automatic server setup.')))
102
+ child.once('close', code => resolve(code))
103
+ })
104
+ if (status !== 0 && racedInstallation) {
105
+ context.print('Another installation or existing state was detected; no replacement was attempted. Run agentsdock list.')
106
+ return 0
107
+ }
108
+ if (status !== 0 || !receipt) {
109
+ const detail = missingUv ? ' A trusted uv installation is required on PATH.' : ''
110
+ throw new Error('Automatic setup did not complete successfully.' + detail +
111
+ ' For interactive diagnostics, install the CLI with AGENTSDOCK_SKIP_SETUP=1 npm install -g agentsdock, then run agentsdock setup. Existing state is never deleted automatically.')
112
+ }
113
+ context.print(`Server ${receipt.version} is ready at ${receipt.url}. Open AgentsDock to connect. Use agentsdock token to view/copy its private token.`)
114
+ return 0
115
+ }
116
+
117
+ if (require.main === module) postinstall().then(code => { process.exitCode = code }).catch(error => {
118
+ process.stderr.write(`agentsdock: ${error.message}\n`)
119
+ process.exitCode = 1
120
+ })
121
+ module.exports = { skipReason, lines, postinstall }