@sapienx/agentos 0.1.2 → 0.1.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.
Files changed (170) hide show
  1. package/README.md +7 -0
  2. package/bin/agentos.js +502 -7
  3. package/bundle/.next/BUILD_ID +1 -1
  4. package/bundle/.next/app-path-routes-manifest.json +10 -9
  5. package/bundle/.next/build-manifest.json +3 -3
  6. package/bundle/.next/required-server-files.json +3 -3
  7. package/bundle/.next/routes-manifest.json +6 -0
  8. package/bundle/.next/server/app/_global-error/page.js +3 -3
  9. package/bundle/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  10. package/bundle/.next/server/app/_global-error.html +2 -2
  11. package/bundle/.next/server/app/_global-error.rsc +1 -1
  12. package/bundle/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  13. package/bundle/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  14. package/bundle/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  15. package/bundle/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  16. package/bundle/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  17. package/bundle/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  18. package/bundle/.next/server/app/_not-found/page.js +2 -2
  19. package/bundle/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  20. package/bundle/.next/server/app/_not-found.html +1 -1
  21. package/bundle/.next/server/app/_not-found.rsc +4 -4
  22. package/bundle/.next/server/app/_not-found.segments/_full.segment.rsc +4 -4
  23. package/bundle/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  24. package/bundle/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
  25. package/bundle/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  26. package/bundle/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  27. package/bundle/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  28. package/bundle/.next/server/app/api/agents/route.js +1 -1
  29. package/bundle/.next/server/app/api/agents/route.js.nft.json +1 -1
  30. package/bundle/.next/server/app/api/agents/route_client-reference-manifest.js +1 -1
  31. package/bundle/.next/server/app/api/diagnostics/route.js +1 -1
  32. package/bundle/.next/server/app/api/diagnostics/route.js.nft.json +1 -1
  33. package/bundle/.next/server/app/api/diagnostics/route_client-reference-manifest.js +1 -1
  34. package/bundle/.next/server/app/api/files/reveal/route.js +1 -1
  35. package/bundle/.next/server/app/api/files/reveal/route_client-reference-manifest.js +1 -1
  36. package/bundle/.next/server/app/api/gateway/control/route.js +1 -1
  37. package/bundle/.next/server/app/api/gateway/control/route.js.nft.json +1 -1
  38. package/bundle/.next/server/app/api/gateway/control/route_client-reference-manifest.js +1 -1
  39. package/bundle/.next/server/app/api/mission/route.js +1 -1
  40. package/bundle/.next/server/app/api/mission/route.js.nft.json +1 -1
  41. package/bundle/.next/server/app/api/mission/route_client-reference-manifest.js +1 -1
  42. package/bundle/.next/server/app/api/onboarding/models/route.js +7 -5
  43. package/bundle/.next/server/app/api/onboarding/models/route.js.nft.json +1 -1
  44. package/bundle/.next/server/app/api/onboarding/models/route_client-reference-manifest.js +1 -1
  45. package/bundle/.next/server/app/api/onboarding/route.js +7 -5
  46. package/bundle/.next/server/app/api/onboarding/route.js.nft.json +1 -1
  47. package/bundle/.next/server/app/api/onboarding/route_client-reference-manifest.js +1 -1
  48. package/bundle/.next/server/app/api/planner/[planId]/deploy/route.js +2 -2
  49. package/bundle/.next/server/app/api/planner/[planId]/deploy/route.js.nft.json +1 -1
  50. package/bundle/.next/server/app/api/planner/[planId]/deploy/route_client-reference-manifest.js +1 -1
  51. package/bundle/.next/server/app/api/planner/[planId]/route.js +1 -1
  52. package/bundle/.next/server/app/api/planner/[planId]/route.js.nft.json +1 -1
  53. package/bundle/.next/server/app/api/planner/[planId]/route_client-reference-manifest.js +1 -1
  54. package/bundle/.next/server/app/api/planner/[planId]/simulate/route.js +1 -1
  55. package/bundle/.next/server/app/api/planner/[planId]/simulate/route.js.nft.json +1 -1
  56. package/bundle/.next/server/app/api/planner/[planId]/simulate/route_client-reference-manifest.js +1 -1
  57. package/bundle/.next/server/app/api/planner/[planId]/turn/route.js +1 -1
  58. package/bundle/.next/server/app/api/planner/[planId]/turn/route.js.nft.json +1 -1
  59. package/bundle/.next/server/app/api/planner/[planId]/turn/route_client-reference-manifest.js +1 -1
  60. package/bundle/.next/server/app/api/planner/route.js +1 -1
  61. package/bundle/.next/server/app/api/planner/route.js.nft.json +1 -1
  62. package/bundle/.next/server/app/api/planner/route_client-reference-manifest.js +1 -1
  63. package/bundle/.next/server/app/api/reset/route.js +3 -0
  64. package/bundle/.next/server/app/api/reset/route.js.nft.json +1 -0
  65. package/bundle/.next/server/app/api/reset/route_client-reference-manifest.js +1 -0
  66. package/bundle/.next/server/app/api/runtimes/[runtimeId]/route.js +1 -1
  67. package/bundle/.next/server/app/api/runtimes/[runtimeId]/route.js.nft.json +1 -1
  68. package/bundle/.next/server/app/api/runtimes/[runtimeId]/route_client-reference-manifest.js +1 -1
  69. package/bundle/.next/server/app/api/settings/gateway/route.js +1 -1
  70. package/bundle/.next/server/app/api/settings/gateway/route.js.nft.json +1 -1
  71. package/bundle/.next/server/app/api/settings/gateway/route_client-reference-manifest.js +1 -1
  72. package/bundle/.next/server/app/api/settings/workspace-root/route.js +1 -1
  73. package/bundle/.next/server/app/api/settings/workspace-root/route.js.nft.json +1 -1
  74. package/bundle/.next/server/app/api/settings/workspace-root/route_client-reference-manifest.js +1 -1
  75. package/bundle/.next/server/app/api/snapshot/route.js +1 -1
  76. package/bundle/.next/server/app/api/snapshot/route.js.nft.json +1 -1
  77. package/bundle/.next/server/app/api/snapshot/route_client-reference-manifest.js +1 -1
  78. package/bundle/.next/server/app/api/stream/route.js +2 -2
  79. package/bundle/.next/server/app/api/stream/route.js.nft.json +1 -1
  80. package/bundle/.next/server/app/api/stream/route_client-reference-manifest.js +1 -1
  81. package/bundle/.next/server/app/api/system/open-terminal/route.js +1 -1
  82. package/bundle/.next/server/app/api/system/open-terminal/route_client-reference-manifest.js +1 -1
  83. package/bundle/.next/server/app/api/update/route.js +2 -2
  84. package/bundle/.next/server/app/api/update/route.js.nft.json +1 -1
  85. package/bundle/.next/server/app/api/update/route_client-reference-manifest.js +1 -1
  86. package/bundle/.next/server/app/api/workspaces/route.js +2 -2
  87. package/bundle/.next/server/app/api/workspaces/route.js.nft.json +1 -1
  88. package/bundle/.next/server/app/api/workspaces/route_client-reference-manifest.js +1 -1
  89. package/bundle/.next/server/app/page.js +12 -9
  90. package/bundle/.next/server/app/page.js.nft.json +1 -1
  91. package/bundle/.next/server/app/page_client-reference-manifest.js +1 -1
  92. package/bundle/.next/server/app-paths-manifest.json +10 -9
  93. package/bundle/.next/server/chunks/463.js +2 -2
  94. package/bundle/.next/server/chunks/603.js +1 -1
  95. package/bundle/.next/server/chunks/907.js +28 -27
  96. package/bundle/.next/server/functions-config-manifest.json +1 -0
  97. package/bundle/.next/server/middleware-build-manifest.js +1 -1
  98. package/bundle/.next/server/pages/404.html +1 -1
  99. package/bundle/.next/server/pages/500.html +2 -2
  100. package/bundle/.next/static/4ThNPJp9bEISWCDFyw3Jd/_buildManifest.js +1 -0
  101. package/bundle/.next/static/chunks/4a846800-817e4d43c6c4047f.js +1 -0
  102. package/bundle/.next/static/chunks/632-680acc061529597b.js +13 -0
  103. package/bundle/.next/static/chunks/app/_global-error/{page-0d1d1bc0507fcf1d.js → page-b01b0a6fdf60f7fe.js} +1 -1
  104. package/bundle/.next/static/chunks/app/_not-found/{page-0d1d1bc0507fcf1d.js → page-b01b0a6fdf60f7fe.js} +1 -1
  105. package/bundle/.next/static/chunks/app/api/agents/{route-0d1d1bc0507fcf1d.js → route-b01b0a6fdf60f7fe.js} +1 -1
  106. package/bundle/.next/static/chunks/app/api/diagnostics/{route-0d1d1bc0507fcf1d.js → route-b01b0a6fdf60f7fe.js} +1 -1
  107. package/bundle/.next/static/chunks/app/api/files/reveal/route-b01b0a6fdf60f7fe.js +1 -0
  108. package/bundle/.next/static/chunks/app/api/gateway/control/route-b01b0a6fdf60f7fe.js +1 -0
  109. package/bundle/.next/static/chunks/app/api/mission/route-b01b0a6fdf60f7fe.js +1 -0
  110. package/bundle/.next/static/chunks/app/api/onboarding/models/route-b01b0a6fdf60f7fe.js +1 -0
  111. package/bundle/.next/static/chunks/app/api/onboarding/route-b01b0a6fdf60f7fe.js +1 -0
  112. package/bundle/.next/static/chunks/app/api/planner/[planId]/deploy/route-b01b0a6fdf60f7fe.js +1 -0
  113. package/bundle/.next/static/chunks/app/api/planner/[planId]/route-b01b0a6fdf60f7fe.js +1 -0
  114. package/bundle/.next/static/chunks/app/api/planner/[planId]/simulate/route-b01b0a6fdf60f7fe.js +1 -0
  115. package/bundle/.next/static/chunks/app/api/planner/[planId]/turn/route-b01b0a6fdf60f7fe.js +1 -0
  116. package/bundle/.next/static/chunks/app/api/planner/route-b01b0a6fdf60f7fe.js +1 -0
  117. package/bundle/.next/static/chunks/app/api/reset/route-b01b0a6fdf60f7fe.js +1 -0
  118. package/bundle/.next/static/chunks/app/api/runtimes/[runtimeId]/route-b01b0a6fdf60f7fe.js +1 -0
  119. package/bundle/.next/static/chunks/app/api/settings/gateway/route-b01b0a6fdf60f7fe.js +1 -0
  120. package/bundle/.next/static/chunks/app/api/settings/workspace-root/route-b01b0a6fdf60f7fe.js +1 -0
  121. package/bundle/.next/static/chunks/app/api/snapshot/route-b01b0a6fdf60f7fe.js +1 -0
  122. package/bundle/.next/static/chunks/app/api/stream/route-b01b0a6fdf60f7fe.js +1 -0
  123. package/bundle/.next/static/chunks/app/api/system/open-terminal/route-b01b0a6fdf60f7fe.js +1 -0
  124. package/bundle/.next/static/chunks/app/api/update/route-b01b0a6fdf60f7fe.js +1 -0
  125. package/bundle/.next/static/chunks/app/api/workspaces/route-b01b0a6fdf60f7fe.js +1 -0
  126. package/bundle/.next/static/chunks/app/layout-6c2c9cd9b518452f.js +1 -0
  127. package/bundle/.next/static/chunks/app/not-found-b01b0a6fdf60f7fe.js +1 -0
  128. package/bundle/.next/static/chunks/app/page-a410ba4980548bfd.js +14 -0
  129. package/bundle/.next/static/chunks/{main-app-9229332086036e25.js → main-app-245e6e74e3ad1df9.js} +1 -1
  130. package/bundle/.next/static/chunks/next/dist/client/components/builtin/app-error-b01b0a6fdf60f7fe.js +1 -0
  131. package/bundle/.next/static/chunks/next/dist/client/components/builtin/forbidden-b01b0a6fdf60f7fe.js +1 -0
  132. package/bundle/.next/static/chunks/next/dist/client/components/builtin/global-error-62eeb2b37b76f847.js +1 -0
  133. package/bundle/.next/static/chunks/next/dist/client/components/builtin/unauthorized-b01b0a6fdf60f7fe.js +1 -0
  134. package/bundle/.next/static/css/b437564fd435ab82.css +3 -0
  135. package/bundle/public/readme/create.webp +0 -0
  136. package/bundle/public/readme/setup.webp +0 -0
  137. package/bundle/public/readme/wizzard.webp +0 -0
  138. package/bundle/scripts/openclaw-mission-dispatch-runner.mjs +234 -0
  139. package/bundle/server.js +1 -1
  140. package/package.json +2 -2
  141. package/bundle/.next/static/VOlzZmzuIhPpxC4007UHA/_buildManifest.js +0 -1
  142. package/bundle/.next/static/chunks/329-1f8436466b6b9b86.js +0 -13
  143. package/bundle/.next/static/chunks/4a846800-ac18ff898328f8a0.js +0 -1
  144. package/bundle/.next/static/chunks/app/api/files/reveal/route-0d1d1bc0507fcf1d.js +0 -1
  145. package/bundle/.next/static/chunks/app/api/gateway/control/route-0d1d1bc0507fcf1d.js +0 -1
  146. package/bundle/.next/static/chunks/app/api/mission/route-0d1d1bc0507fcf1d.js +0 -1
  147. package/bundle/.next/static/chunks/app/api/onboarding/models/route-0d1d1bc0507fcf1d.js +0 -1
  148. package/bundle/.next/static/chunks/app/api/onboarding/route-0d1d1bc0507fcf1d.js +0 -1
  149. package/bundle/.next/static/chunks/app/api/planner/[planId]/deploy/route-0d1d1bc0507fcf1d.js +0 -1
  150. package/bundle/.next/static/chunks/app/api/planner/[planId]/route-0d1d1bc0507fcf1d.js +0 -1
  151. package/bundle/.next/static/chunks/app/api/planner/[planId]/simulate/route-0d1d1bc0507fcf1d.js +0 -1
  152. package/bundle/.next/static/chunks/app/api/planner/[planId]/turn/route-0d1d1bc0507fcf1d.js +0 -1
  153. package/bundle/.next/static/chunks/app/api/planner/route-0d1d1bc0507fcf1d.js +0 -1
  154. package/bundle/.next/static/chunks/app/api/runtimes/[runtimeId]/route-0d1d1bc0507fcf1d.js +0 -1
  155. package/bundle/.next/static/chunks/app/api/settings/gateway/route-0d1d1bc0507fcf1d.js +0 -1
  156. package/bundle/.next/static/chunks/app/api/settings/workspace-root/route-0d1d1bc0507fcf1d.js +0 -1
  157. package/bundle/.next/static/chunks/app/api/snapshot/route-0d1d1bc0507fcf1d.js +0 -1
  158. package/bundle/.next/static/chunks/app/api/stream/route-0d1d1bc0507fcf1d.js +0 -1
  159. package/bundle/.next/static/chunks/app/api/system/open-terminal/route-0d1d1bc0507fcf1d.js +0 -1
  160. package/bundle/.next/static/chunks/app/api/update/route-0d1d1bc0507fcf1d.js +0 -1
  161. package/bundle/.next/static/chunks/app/api/workspaces/route-0d1d1bc0507fcf1d.js +0 -1
  162. package/bundle/.next/static/chunks/app/layout-f29ac7241aef5824.js +0 -1
  163. package/bundle/.next/static/chunks/app/not-found-0d1d1bc0507fcf1d.js +0 -1
  164. package/bundle/.next/static/chunks/app/page-9b9885753576b25c.js +0 -11
  165. package/bundle/.next/static/chunks/next/dist/client/components/builtin/app-error-0d1d1bc0507fcf1d.js +0 -1
  166. package/bundle/.next/static/chunks/next/dist/client/components/builtin/forbidden-0d1d1bc0507fcf1d.js +0 -1
  167. package/bundle/.next/static/chunks/next/dist/client/components/builtin/global-error-382f4d4fed37de4d.js +0 -1
  168. package/bundle/.next/static/chunks/next/dist/client/components/builtin/unauthorized-0d1d1bc0507fcf1d.js +0 -1
  169. package/bundle/.next/static/css/fafac7874e0b1aad.css +0 -3
  170. /package/bundle/.next/static/{VOlzZmzuIhPpxC4007UHA → 4ThNPJp9bEISWCDFyw3Jd}/_ssgManifest.js +0 -0
package/README.md CHANGED
@@ -19,7 +19,10 @@ Optional flags:
19
19
  ```bash
20
20
  agentos start --port 3000 --host 127.0.0.1
21
21
  agentos start --port 3000 --host 127.0.0.1 --open
22
+ agentos stop
23
+ agentos stop --port 3000 --force
22
24
  agentos doctor
25
+ agentos uninstall
23
26
  ```
24
27
 
25
28
  Optional environment variables:
@@ -32,4 +35,8 @@ AGENTOS_OPEN=1
32
35
 
33
36
  `agentos doctor` prints the effective URL, bundle status, Node.js compatibility, OpenClaw detection, and browser auto-open support.
34
37
 
38
+ `agentos stop` sends `SIGTERM` to the tracked AgentOS server on the selected port. Use `--force` only if the process refuses to stop cleanly.
39
+
40
+ `agentos uninstall` removes a release-installer copy. If the package was installed with `pnpm` or `npm`, remove it with your package manager instead.
41
+
35
42
  AgentOS is designed to work with a local OpenClaw installation. If OpenClaw is missing, AgentOS still starts and guides onboarding in the UI.
package/bin/agentos.js CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { spawn, spawnSync } from "node:child_process";
4
- import { existsSync } from "node:fs";
4
+ import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, rmdirSync, writeFileSync } from "node:fs";
5
+ import { createInterface } from "node:readline/promises";
5
6
  import os from "node:os";
6
7
  import path from "node:path";
7
8
  import process from "node:process";
@@ -14,6 +15,12 @@ const bundleDir = path.join(packageRoot, "bundle");
14
15
  const bundledServerPath = path.join(bundleDir, "server.js");
15
16
 
16
17
  const packageJson = JSON.parse(await readTextFile(packageJsonPath));
18
+ const defaultInstallRoot = path.join(os.homedir(), ".agentos");
19
+ const defaultBinDir = path.join(os.homedir(), ".local", "bin");
20
+ const runtimeInstallRoot = resolveRuntimeInstallRoot();
21
+ const runtimeStateDir = path.join(runtimeInstallRoot, "run");
22
+ const stopPollIntervalMs = 100;
23
+ const stopTimeoutMs = 5_000;
17
24
 
18
25
  main().catch((error) => {
19
26
  console.error(error instanceof Error ? error.message : String(error));
@@ -44,6 +51,26 @@ async function main() {
44
51
  return;
45
52
  }
46
53
 
54
+ if (firstArg === "stop") {
55
+ if (args[1] === "--help" || args[1] === "-h" || args[1] === "help") {
56
+ printStopHelp();
57
+ return;
58
+ }
59
+
60
+ await runStop(args.slice(1));
61
+ return;
62
+ }
63
+
64
+ if (firstArg === "uninstall") {
65
+ if (args[1] === "--help" || args[1] === "-h" || args[1] === "help") {
66
+ printUninstallHelp();
67
+ return;
68
+ }
69
+
70
+ await runUninstall(args.slice(1));
71
+ return;
72
+ }
73
+
47
74
  if (firstArg === "start") {
48
75
  await startServer(args.slice(1));
49
76
  return;
@@ -56,9 +83,21 @@ async function startServer(rawArgs) {
56
83
  ensureBundleExists();
57
84
 
58
85
  const options = parseStartArgs(rawArgs);
86
+ const runtimeStatePath = resolveRuntimeStatePath(options.port);
87
+ const trackedState = readRuntimeState(runtimeStatePath);
59
88
  const openClawCheck = detectOpenClaw();
60
89
  const browserOpener = detectBrowserOpener();
61
90
 
91
+ if (trackedState?.pid && isProcessRunning(trackedState.pid)) {
92
+ throw new Error(
93
+ `AgentOS is already running on port ${options.port} (PID ${trackedState.pid}). Use "agentos stop --port ${options.port}" first.`
94
+ );
95
+ }
96
+
97
+ if (trackedState) {
98
+ clearRuntimeState(runtimeStatePath);
99
+ }
100
+
62
101
  const url = `http://${displayHost(options.host)}:${options.port}`;
63
102
  console.log(`Starting AgentOS on ${url}`);
64
103
 
@@ -84,6 +123,23 @@ async function startServer(rawArgs) {
84
123
  }
85
124
  });
86
125
 
126
+ if (!child.pid) {
127
+ child.kill("SIGTERM");
128
+ throw new Error("AgentOS could not determine the server PID.");
129
+ }
130
+
131
+ try {
132
+ writeRuntimeState(runtimeStatePath, {
133
+ pid: child.pid,
134
+ port: options.port,
135
+ host: options.host,
136
+ startedAt: new Date().toISOString()
137
+ });
138
+ } catch (error) {
139
+ child.kill("SIGTERM");
140
+ throw error;
141
+ }
142
+
87
143
  const browserState = { opened: false };
88
144
  const relayStdout = createRelay(process.stdout, options, url, browserOpener, browserState);
89
145
  const relayStderr = createRelay(process.stderr, options, url, browserOpener, browserState);
@@ -91,6 +147,19 @@ async function startServer(rawArgs) {
91
147
  child.stdout.on("data", relayStdout);
92
148
  child.stderr.on("data", relayStderr);
93
149
 
150
+ let cleanedUp = false;
151
+ const cleanup = () => {
152
+ if (cleanedUp) {
153
+ return;
154
+ }
155
+
156
+ cleanedUp = true;
157
+ process.off("SIGINT", forwardSignal);
158
+ process.off("SIGTERM", forwardSignal);
159
+ process.off("SIGQUIT", forwardSignal);
160
+ clearRuntimeState(runtimeStatePath, child.pid);
161
+ };
162
+
94
163
  const forwardSignal = (signal) => {
95
164
  if (!child.killed) {
96
165
  child.kill(signal);
@@ -99,10 +168,16 @@ async function startServer(rawArgs) {
99
168
 
100
169
  process.on("SIGINT", forwardSignal);
101
170
  process.on("SIGTERM", forwardSignal);
171
+ process.on("SIGQUIT", forwardSignal);
172
+
173
+ child.on("error", (error) => {
174
+ cleanup();
175
+ console.error(`AgentOS failed to start: ${error.message}`);
176
+ process.exit(1);
177
+ });
102
178
 
103
179
  child.on("exit", (code, signal) => {
104
- process.off("SIGINT", forwardSignal);
105
- process.off("SIGTERM", forwardSignal);
180
+ cleanup();
106
181
 
107
182
  if (signal) {
108
183
  process.kill(process.pid, signal);
@@ -176,6 +251,48 @@ function runDoctor() {
176
251
  }
177
252
  }
178
253
 
254
+ async function runStop(rawArgs) {
255
+ const options = parseStopArgs(rawArgs);
256
+ const runtimeStatePath = resolveRuntimeStatePath(options.port);
257
+ const trackedState = readRuntimeState(runtimeStatePath);
258
+ const targetPid = trackedState?.pid ?? findListeningPidForPort(options.port);
259
+
260
+ if (!targetPid) {
261
+ clearRuntimeState(runtimeStatePath);
262
+ console.log(`No running AgentOS process was found on port ${options.port}.`);
263
+ return;
264
+ }
265
+
266
+ console.log(`Stopping AgentOS on port ${options.port} (PID ${targetPid})...`);
267
+
268
+ try {
269
+ process.kill(targetPid, options.force ? "SIGKILL" : "SIGTERM");
270
+ } catch (error) {
271
+ if (error && typeof error === "object" && "code" in error && error.code === "ESRCH") {
272
+ clearRuntimeState(runtimeStatePath);
273
+ console.log(`AgentOS is not running on port ${options.port}.`);
274
+ return;
275
+ }
276
+
277
+ throw error;
278
+ }
279
+
280
+ const stopped = await waitForProcessExit(targetPid, options.force ? 1_000 : stopTimeoutMs);
281
+
282
+ if (!stopped) {
283
+ console.error(
284
+ options.force
285
+ ? `AgentOS did not stop after SIGKILL on port ${options.port}.`
286
+ : `AgentOS did not stop within ${Math.round(stopTimeoutMs / 1000)} seconds. Re-run "agentos stop --port ${options.port} --force" if you want to terminate it.`
287
+ );
288
+ process.exitCode = 1;
289
+ return;
290
+ }
291
+
292
+ clearRuntimeState(runtimeStatePath);
293
+ console.log(`Stopped AgentOS on port ${options.port}.`);
294
+ }
295
+
179
296
  function parseStartArgs(rawArgs) {
180
297
  const envPort = process.env.AGENTOS_PORT || process.env.PORT;
181
298
  const options = {
@@ -233,6 +350,59 @@ function parseStartArgs(rawArgs) {
233
350
  return options;
234
351
  }
235
352
 
353
+ function parseStopArgs(rawArgs) {
354
+ const envPort = process.env.AGENTOS_PORT || process.env.PORT;
355
+ const options = {
356
+ port: envPort && /^\d+$/.test(envPort) ? Number(envPort) : 3000,
357
+ force: false
358
+ };
359
+
360
+ for (let index = 0; index < rawArgs.length; index += 1) {
361
+ const arg = rawArgs[index];
362
+
363
+ if (arg === "--port" || arg === "-p") {
364
+ const value = rawArgs[index + 1];
365
+ index += 1;
366
+ assertPort(value);
367
+ options.port = Number(value);
368
+ continue;
369
+ }
370
+
371
+ if (arg.startsWith("--port=")) {
372
+ const value = arg.slice("--port=".length);
373
+ assertPort(value);
374
+ options.port = Number(value);
375
+ continue;
376
+ }
377
+
378
+ if (arg === "--force" || arg === "-f") {
379
+ options.force = true;
380
+ continue;
381
+ }
382
+
383
+ throw new Error(`Unknown argument: ${arg}`);
384
+ }
385
+
386
+ return options;
387
+ }
388
+
389
+ function parseUninstallArgs(rawArgs) {
390
+ const options = {
391
+ yes: false
392
+ };
393
+
394
+ for (const arg of rawArgs) {
395
+ if (arg === "--yes" || arg === "-y") {
396
+ options.yes = true;
397
+ continue;
398
+ }
399
+
400
+ throw new Error(`Unknown argument: ${arg}`);
401
+ }
402
+
403
+ return options;
404
+ }
405
+
236
406
  function assertPort(value) {
237
407
  if (!value || !/^\d+$/.test(value)) {
238
408
  throw new Error("Expected a numeric value after --port.");
@@ -328,14 +498,44 @@ function printHelp() {
328
498
  Usage:
329
499
  agentos
330
500
  agentos start --port 3000 --host 127.0.0.1 --open
501
+ agentos stop --port 3000 [--force]
331
502
  agentos doctor
503
+ agentos uninstall [--yes]
332
504
  agentos --version
333
505
 
334
506
  Options:
335
- --port, -p Port to bind the local server (default: 3000)
336
- --host, -H Host to bind the local server (default: 127.0.0.1)
337
- --open, -o Open AgentOS in the default browser after startup
338
- --no-open Disable browser auto-open even if AGENTOS_OPEN is set
507
+ start: --port, -p Port to bind the local server (default: 3000)
508
+ start: --host, -H Host to bind the local server (default: 127.0.0.1)
509
+ start: --open, -o Open AgentOS in the default browser after startup
510
+ start: --no-open Disable browser auto-open even if AGENTOS_OPEN is set
511
+ stop: --port, -p Port to stop (default: 3000)
512
+ stop: --force, -f Send SIGKILL if SIGTERM does not stop the server
513
+ `);
514
+ }
515
+
516
+ function printStopHelp() {
517
+ console.log(`Stop a running AgentOS server.
518
+
519
+ Usage:
520
+ agentos stop
521
+ agentos stop --port 3000
522
+ agentos stop --port 3000 --force
523
+
524
+ Options:
525
+ --port, -p Port to stop (default: 3000)
526
+ --force, -f Send SIGKILL if SIGTERM does not stop the server
527
+ `);
528
+ }
529
+
530
+ function printUninstallHelp() {
531
+ console.log(`Remove an AgentOS release installation.
532
+
533
+ Usage:
534
+ agentos uninstall
535
+ agentos uninstall --yes
536
+
537
+ Options:
538
+ --yes, -y Skip the confirmation prompt
339
539
  `);
340
540
  }
341
541
 
@@ -427,3 +627,298 @@ async function readTextFile(filePath) {
427
627
  const { readFile } = await import("node:fs/promises");
428
628
  return readFile(filePath, "utf8");
429
629
  }
630
+
631
+ async function runUninstall(rawArgs) {
632
+ const options = parseUninstallArgs(rawArgs);
633
+ const install = inspectInstallation();
634
+
635
+ if (install.kind === "package-manager") {
636
+ printPackageManagerUninstallGuidance();
637
+ return;
638
+ }
639
+
640
+ if (install.kind === "source") {
641
+ console.log("This AgentOS copy looks like a source checkout, not a release installation.");
642
+ console.log(`Delete the checkout manually if you want to remove it: ${findRepoRoot()}`);
643
+ return;
644
+ }
645
+
646
+ if (!options.yes) {
647
+ const confirmed = await confirmUninstall(install);
648
+
649
+ if (!confirmed) {
650
+ console.log("Uninstall cancelled.");
651
+ return;
652
+ }
653
+ }
654
+
655
+ const removedPaths = [];
656
+
657
+ if (await removePathIfExists(install.packagePath)) {
658
+ removedPaths.push(install.packagePath);
659
+ }
660
+
661
+ if (install.launcherPath && (await removePathIfExists(install.launcherPath))) {
662
+ removedPaths.push(install.launcherPath);
663
+ }
664
+
665
+ await removeDirectoryIfEmpty(install.installRoot);
666
+
667
+ if (removedPaths.length === 0) {
668
+ console.log("No removable AgentOS release files were found.");
669
+ return;
670
+ }
671
+
672
+ console.log("Removed AgentOS release installation:");
673
+
674
+ for (const removedPath of removedPaths) {
675
+ console.log(`- ${removedPath}`);
676
+ }
677
+
678
+ if (!install.launcherPath) {
679
+ console.log(`No managed launcher was detected on PATH. If you used a custom bin directory, remove that launcher manually.`);
680
+ }
681
+ }
682
+
683
+ function inspectInstallation() {
684
+ if (path.basename(packageRoot) === "package") {
685
+ return {
686
+ kind: "release",
687
+ installRoot: path.dirname(packageRoot),
688
+ packagePath: packageRoot,
689
+ launcherPath: detectManagedLauncher(packageRoot)
690
+ };
691
+ }
692
+
693
+ if (packageRoot.includes(`${path.sep}node_modules${path.sep}`) || packageRoot.includes(`${path.sep}.pnpm${path.sep}`)) {
694
+ return {
695
+ kind: "package-manager"
696
+ };
697
+ }
698
+
699
+ return {
700
+ kind: "source"
701
+ };
702
+ }
703
+
704
+ function printPackageManagerUninstallGuidance() {
705
+ console.log("This AgentOS install appears to come from a package manager.");
706
+ console.log("Remove it with one of:");
707
+ console.log(" pnpm remove -g @sapienx/agentos");
708
+ console.log(" npm uninstall -g @sapienx/agentos");
709
+ }
710
+
711
+ function findRepoRoot() {
712
+ return path.resolve(packageRoot, "..", "..");
713
+ }
714
+
715
+ function detectManagedLauncher(installedPackagePath) {
716
+ const scriptMarker = normalizeForMatch(path.join(installedPackagePath, "bin", "agentos.js"));
717
+ const candidates = new Set([
718
+ resolveCommandPath("agentos"),
719
+ path.join(defaultBinDir, "agentos")
720
+ ]);
721
+
722
+ for (const candidate of candidates) {
723
+ if (!candidate || !existsSync(candidate)) {
724
+ continue;
725
+ }
726
+
727
+ try {
728
+ const contents = readFileSync(candidate, "utf8");
729
+
730
+ if (normalizeForMatch(contents).includes(scriptMarker)) {
731
+ return candidate;
732
+ }
733
+ } catch {
734
+ continue;
735
+ }
736
+ }
737
+
738
+ return null;
739
+ }
740
+
741
+ function normalizeForMatch(value) {
742
+ return value.replaceAll("\\", "/");
743
+ }
744
+
745
+ function resolveRuntimeInstallRoot() {
746
+ if (process.env.AGENTOS_INSTALL_ROOT) {
747
+ return path.resolve(process.env.AGENTOS_INSTALL_ROOT);
748
+ }
749
+
750
+ if (path.basename(packageRoot) === "package") {
751
+ return path.dirname(packageRoot);
752
+ }
753
+
754
+ return defaultInstallRoot;
755
+ }
756
+
757
+ function resolveRuntimeStatePath(port) {
758
+ return path.join(runtimeStateDir, `agentos-${port}.json`);
759
+ }
760
+
761
+ function readRuntimeState(runtimeStatePath) {
762
+ if (!existsSync(runtimeStatePath)) {
763
+ return null;
764
+ }
765
+
766
+ try {
767
+ const payload = JSON.parse(readFileSync(runtimeStatePath, "utf8"));
768
+
769
+ if (!payload || typeof payload !== "object" || !Number.isInteger(payload.pid) || payload.pid <= 0) {
770
+ return null;
771
+ }
772
+
773
+ return payload;
774
+ } catch {
775
+ return null;
776
+ }
777
+ }
778
+
779
+ function writeRuntimeState(runtimeStatePath, payload) {
780
+ mkdirSync(runtimeStateDir, {
781
+ recursive: true
782
+ });
783
+ writeFileSync(runtimeStatePath, `${JSON.stringify(payload, null, 2)}\n`, "utf8");
784
+ }
785
+
786
+ function clearRuntimeState(runtimeStatePath, expectedPid) {
787
+ if (existsSync(runtimeStatePath)) {
788
+ if (expectedPid) {
789
+ const payload = readRuntimeState(runtimeStatePath);
790
+
791
+ if (payload?.pid && payload.pid !== expectedPid) {
792
+ return;
793
+ }
794
+ }
795
+
796
+ rmSync(runtimeStatePath, {
797
+ force: true
798
+ });
799
+ }
800
+
801
+ if (!existsSync(runtimeStateDir)) {
802
+ return;
803
+ }
804
+
805
+ if (readdirSync(runtimeStateDir).length === 0) {
806
+ rmdirSync(runtimeStateDir);
807
+ }
808
+ }
809
+
810
+ function isProcessRunning(pid) {
811
+ try {
812
+ process.kill(pid, 0);
813
+ return true;
814
+ } catch (error) {
815
+ if (error && typeof error === "object" && "code" in error) {
816
+ if (error.code === "ESRCH") {
817
+ return false;
818
+ }
819
+
820
+ if (error.code === "EPERM") {
821
+ return true;
822
+ }
823
+ }
824
+
825
+ throw error;
826
+ }
827
+ }
828
+
829
+ function findListeningPidForPort(port) {
830
+ if (process.platform === "win32") {
831
+ return null;
832
+ }
833
+
834
+ const result = spawnSync("lsof", ["-nP", `-iTCP:${port}`, "-sTCP:LISTEN", "-t"], {
835
+ encoding: "utf8"
836
+ });
837
+
838
+ if (result.error || result.status !== 0) {
839
+ return null;
840
+ }
841
+
842
+ const firstLine = result.stdout
843
+ .split(/\r?\n/)
844
+ .map((line) => line.trim())
845
+ .find(Boolean);
846
+
847
+ if (!firstLine || !/^\d+$/.test(firstLine)) {
848
+ return null;
849
+ }
850
+
851
+ return Number(firstLine);
852
+ }
853
+
854
+ async function waitForProcessExit(pid, timeoutMs) {
855
+ const startedAt = Date.now();
856
+
857
+ while (Date.now() - startedAt < timeoutMs) {
858
+ if (!isProcessRunning(pid)) {
859
+ return true;
860
+ }
861
+
862
+ await new Promise((resolve) => {
863
+ setTimeout(resolve, stopPollIntervalMs);
864
+ });
865
+ }
866
+
867
+ return !isProcessRunning(pid);
868
+ }
869
+
870
+ async function confirmUninstall(install) {
871
+ if (!process.stdin.isTTY || !process.stdout.isTTY) {
872
+ throw new Error("Refusing to uninstall without --yes in a non-interactive terminal.");
873
+ }
874
+
875
+ console.log("AgentOS release uninstall");
876
+ console.log(`Package: ${install.packagePath}`);
877
+
878
+ if (install.launcherPath) {
879
+ console.log(`Launcher: ${install.launcherPath}`);
880
+ } else {
881
+ console.log(`Launcher: not detected on PATH`);
882
+ }
883
+
884
+ const readline = createInterface({
885
+ input: process.stdin,
886
+ output: process.stdout
887
+ });
888
+
889
+ try {
890
+ const answer = await readline.question("Remove these files? [y/N] ");
891
+ return /^y(es)?$/i.test(answer.trim());
892
+ } finally {
893
+ readline.close();
894
+ }
895
+ }
896
+
897
+ async function removePathIfExists(targetPath) {
898
+ const { rm } = await import("node:fs/promises");
899
+
900
+ if (!existsSync(targetPath)) {
901
+ return false;
902
+ }
903
+
904
+ await rm(targetPath, {
905
+ recursive: true,
906
+ force: true
907
+ });
908
+
909
+ return true;
910
+ }
911
+
912
+ async function removeDirectoryIfEmpty(targetPath) {
913
+ const { readdir, rmdir } = await import("node:fs/promises");
914
+
915
+ if (!existsSync(targetPath)) {
916
+ return;
917
+ }
918
+
919
+ const entries = await readdir(targetPath);
920
+
921
+ if (entries.length === 0) {
922
+ await rmdir(targetPath);
923
+ }
924
+ }
@@ -1 +1 @@
1
- VOlzZmzuIhPpxC4007UHA
1
+ 4ThNPJp9bEISWCDFyw3Jd
@@ -1,25 +1,26 @@
1
1
  {
2
- "/_not-found/page": "/_not-found",
3
2
  "/_global-error/page": "/_global-error",
4
- "/api/mission/route": "/api/mission",
3
+ "/_not-found/page": "/_not-found",
5
4
  "/api/files/reveal/route": "/api/files/reveal",
6
5
  "/api/agents/route": "/api/agents",
7
6
  "/api/diagnostics/route": "/api/diagnostics",
8
7
  "/api/gateway/control/route": "/api/gateway/control",
9
- "/api/planner/[planId]/route": "/api/planner/[planId]",
10
- "/api/planner/[planId]/deploy/route": "/api/planner/[planId]/deploy",
8
+ "/api/mission/route": "/api/mission",
11
9
  "/api/planner/[planId]/simulate/route": "/api/planner/[planId]/simulate",
10
+ "/api/planner/[planId]/deploy/route": "/api/planner/[planId]/deploy",
11
+ "/api/planner/[planId]/route": "/api/planner/[planId]",
12
+ "/api/planner/[planId]/turn/route": "/api/planner/[planId]/turn",
12
13
  "/api/runtimes/[runtimeId]/route": "/api/runtimes/[runtimeId]",
14
+ "/api/snapshot/route": "/api/snapshot",
15
+ "/api/reset/route": "/api/reset",
16
+ "/api/settings/workspace-root/route": "/api/settings/workspace-root",
17
+ "/api/onboarding/models/route": "/api/onboarding/models",
13
18
  "/api/settings/gateway/route": "/api/settings/gateway",
14
19
  "/api/planner/route": "/api/planner",
15
- "/api/planner/[planId]/turn/route": "/api/planner/[planId]/turn",
16
- "/api/settings/workspace-root/route": "/api/settings/workspace-root",
17
- "/api/snapshot/route": "/api/snapshot",
18
20
  "/api/system/open-terminal/route": "/api/system/open-terminal",
19
21
  "/api/stream/route": "/api/stream",
20
- "/api/onboarding/route": "/api/onboarding",
21
22
  "/api/update/route": "/api/update",
22
- "/api/onboarding/models/route": "/api/onboarding/models",
23
+ "/api/onboarding/route": "/api/onboarding",
23
24
  "/api/workspaces/route": "/api/workspaces",
24
25
  "/page": "/"
25
26
  }
@@ -4,14 +4,14 @@
4
4
  ],
5
5
  "devFiles": [],
6
6
  "lowPriorityFiles": [
7
- "static/VOlzZmzuIhPpxC4007UHA/_buildManifest.js",
8
- "static/VOlzZmzuIhPpxC4007UHA/_ssgManifest.js"
7
+ "static/4ThNPJp9bEISWCDFyw3Jd/_buildManifest.js",
8
+ "static/4ThNPJp9bEISWCDFyw3Jd/_ssgManifest.js"
9
9
  ],
10
10
  "rootMainFiles": [
11
11
  "static/chunks/webpack-032b5b42e067a790.js",
12
12
  "static/chunks/474f1956-ebf51c0dd00ff236.js",
13
13
  "static/chunks/26-8f7c2b7e8773b4cb.js",
14
- "static/chunks/main-app-9229332086036e25.js"
14
+ "static/chunks/main-app-245e6e74e3ad1df9.js"
15
15
  ],
16
16
  "rootMainFilesTree": {},
17
17
  "pages": {
@@ -101,7 +101,7 @@
101
101
  "transform": "lodash/{{member}}"
102
102
  }
103
103
  },
104
- "outputFileTracingRoot": "/Users/kazimakgul/Documents/GitHub/AgentOS-Core",
104
+ "outputFileTracingRoot": "/Users/kazimakgul/Documents/GitHub/AgentOS",
105
105
  "cacheComponents": false,
106
106
  "cacheLife": {
107
107
  "default": {
@@ -294,11 +294,11 @@
294
294
  "bundlePagesRouterDependencies": false,
295
295
  "configFileName": "next.config.mjs",
296
296
  "turbopack": {
297
- "root": "/Users/kazimakgul/Documents/GitHub/AgentOS-Core"
297
+ "root": "/Users/kazimakgul/Documents/GitHub/AgentOS"
298
298
  },
299
299
  "distDirRoot": ".next"
300
300
  },
301
- "appDir": "/Users/kazimakgul/Documents/GitHub/AgentOS-Core",
301
+ "appDir": "/Users/kazimakgul/Documents/GitHub/AgentOS",
302
302
  "relativeAppDir": "",
303
303
  "files": [
304
304
  ".next/routes-manifest.json",
@@ -129,6 +129,12 @@
129
129
  "routeKeys": {},
130
130
  "namedRegex": "^/api/planner(?:/)?$"
131
131
  },
132
+ {
133
+ "page": "/api/reset",
134
+ "regex": "^/api/reset(?:/)?$",
135
+ "routeKeys": {},
136
+ "namedRegex": "^/api/reset(?:/)?$"
137
+ },
132
138
  {
133
139
  "page": "/api/settings/gateway",
134
140
  "regex": "^/api/settings/gateway(?:/)?$",