@jlongo78/agent-spaces 0.5.1 → 0.5.3
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/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/build-manifest.json +2 -2
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/required-server-files.json +19 -19
- package/.next/standalone/.next/server/app/(desktop)/admin/analytics/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(desktop)/admin/users/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(desktop)/analytics/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(desktop)/network/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(desktop)/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(desktop)/projects/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(desktop)/sessions/[id]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(desktop)/sessions/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(desktop)/settings/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(desktop)/terminal/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(desktop)/terminal/pane/[id]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(desktop)/terminal/remote/[nodeId]/[workspaceId]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(desktop)/workspaces/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_global-error.html +2 -2
- package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/admin/analytics.html +1 -1
- package/.next/standalone/.next/server/app/admin/analytics.rsc +2 -2
- package/.next/standalone/.next/server/app/admin/analytics.segments/!KGRlc2t0b3Ap/admin/analytics/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/admin/analytics.segments/!KGRlc2t0b3Ap/admin/analytics.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/admin/analytics.segments/!KGRlc2t0b3Ap/admin.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/admin/analytics.segments/!KGRlc2t0b3Ap.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/admin/analytics.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/admin/analytics.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/admin/analytics.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/admin/analytics.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/admin/users.html +1 -1
- package/.next/standalone/.next/server/app/admin/users.rsc +2 -2
- package/.next/standalone/.next/server/app/admin/users.segments/!KGRlc2t0b3Ap/admin/users/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/admin/users.segments/!KGRlc2t0b3Ap/admin/users.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/admin/users.segments/!KGRlc2t0b3Ap/admin.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/admin/users.segments/!KGRlc2t0b3Ap.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/admin/users.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/admin/users.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/admin/users.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/admin/users.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/analytics.html +1 -1
- package/.next/standalone/.next/server/app/analytics.rsc +2 -2
- package/.next/standalone/.next/server/app/analytics.segments/!KGRlc2t0b3Ap/analytics/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/analytics.segments/!KGRlc2t0b3Ap/analytics.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/analytics.segments/!KGRlc2t0b3Ap.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/analytics.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/analytics.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/analytics.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/analytics.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/api/analytics/overview/route.js +2 -2
- package/.next/standalone/.next/server/app/api/analytics/overview/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/bulk/route.js +2 -2
- package/.next/standalone/.next/server/app/api/bulk/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/config/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/events/route.js +2 -2
- package/.next/standalone/.next/server/app/api/events/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/folders/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/network/handshake/route.js +1 -1
- package/.next/standalone/.next/server/app/api/network/handshake/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/panes/[id]/route.js +2 -2
- package/.next/standalone/.next/server/app/api/panes/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/panes/route.js +2 -2
- package/.next/standalone/.next/server/app/api/panes/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/projects/route.js +2 -2
- package/.next/standalone/.next/server/app/api/projects/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/search/route.js +2 -2
- package/.next/standalone/.next/server/app/api/search/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/sessions/[id]/chat/route.js +2 -2
- package/.next/standalone/.next/server/app/api/sessions/[id]/chat/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/sessions/[id]/messages/route.js +2 -2
- package/.next/standalone/.next/server/app/api/sessions/[id]/messages/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/sessions/[id]/route.js +2 -2
- package/.next/standalone/.next/server/app/api/sessions/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/sessions/route.js +2 -2
- package/.next/standalone/.next/server/app/api/sessions/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/sync/route.js +3 -3
- package/.next/standalone/.next/server/app/api/sync/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/tags/route.js +2 -2
- package/.next/standalone/.next/server/app/api/tags/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/tier/route.js +1 -1
- package/.next/standalone/.next/server/app/api/tier/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/workspaces/[id]/context/[key]/route.js +2 -2
- package/.next/standalone/.next/server/app/api/workspaces/[id]/context/[key]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/workspaces/[id]/context/route.js +2 -2
- package/.next/standalone/.next/server/app/api/workspaces/[id]/context/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/workspaces/[id]/messages/[msgId]/route.js +2 -2
- package/.next/standalone/.next/server/app/api/workspaces/[id]/messages/[msgId]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/workspaces/[id]/messages/route.js +2 -2
- package/.next/standalone/.next/server/app/api/workspaces/[id]/messages/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/workspaces/[id]/route.js +2 -2
- package/.next/standalone/.next/server/app/api/workspaces/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/workspaces/[id]/sessions/route.js +2 -2
- package/.next/standalone/.next/server/app/api/workspaces/[id]/sessions/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/workspaces/route.js +2 -2
- package/.next/standalone/.next/server/app/api/workspaces/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/login.html +1 -1
- package/.next/standalone/.next/server/app/login.rsc +2 -2
- package/.next/standalone/.next/server/app/login.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/login.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/login.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/login.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/login.segments/login/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/login.segments/login.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/m/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/m/projects/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/m/projects.html +1 -1
- package/.next/standalone/.next/server/app/m/projects.rsc +2 -2
- package/.next/standalone/.next/server/app/m/projects.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/m/projects.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/m/projects.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/m/projects.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/m/projects.segments/m/projects/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/m/projects.segments/m/projects.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/m/projects.segments/m.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/m/sessions/[id]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/m/sessions/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/m/sessions.html +1 -1
- package/.next/standalone/.next/server/app/m/sessions.rsc +2 -2
- package/.next/standalone/.next/server/app/m/sessions.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/m/sessions.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/m/sessions.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/m/sessions.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/m/sessions.segments/m/sessions/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/m/sessions.segments/m/sessions.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/m/sessions.segments/m.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/m/settings/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/m/settings.html +1 -1
- package/.next/standalone/.next/server/app/m/settings.rsc +2 -2
- package/.next/standalone/.next/server/app/m/settings.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/m/settings.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/m/settings.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/m/settings.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/m/settings.segments/m/settings/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/m/settings.segments/m/settings.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/m/settings.segments/m.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/m/terminal/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/m/terminal.html +1 -1
- package/.next/standalone/.next/server/app/m/terminal.rsc +2 -2
- package/.next/standalone/.next/server/app/m/terminal.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/m/terminal.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/m/terminal.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/m/terminal.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/m/terminal.segments/m/terminal/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/m/terminal.segments/m/terminal.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/m/terminal.segments/m.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/m.html +1 -1
- package/.next/standalone/.next/server/app/m.rsc +2 -2
- package/.next/standalone/.next/server/app/m.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/m.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/m.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/m.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/m.segments/m/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/m.segments/m.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/network.html +1 -1
- package/.next/standalone/.next/server/app/network.rsc +2 -2
- package/.next/standalone/.next/server/app/network.segments/!KGRlc2t0b3Ap/network/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/network.segments/!KGRlc2t0b3Ap/network.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/network.segments/!KGRlc2t0b3Ap.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/network.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/network.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/network.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/network.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/projects.html +1 -1
- package/.next/standalone/.next/server/app/projects.rsc +2 -2
- package/.next/standalone/.next/server/app/projects.segments/!KGRlc2t0b3Ap/projects/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/projects.segments/!KGRlc2t0b3Ap/projects.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/projects.segments/!KGRlc2t0b3Ap.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/projects.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/projects.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/projects.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/projects.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/sessions.html +1 -1
- package/.next/standalone/.next/server/app/sessions.rsc +2 -2
- package/.next/standalone/.next/server/app/sessions.segments/!KGRlc2t0b3Ap/sessions/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/sessions.segments/!KGRlc2t0b3Ap/sessions.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/sessions.segments/!KGRlc2t0b3Ap.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/sessions.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/sessions.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/sessions.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/sessions.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/settings.html +1 -1
- package/.next/standalone/.next/server/app/settings.rsc +2 -2
- package/.next/standalone/.next/server/app/settings.segments/!KGRlc2t0b3Ap/settings/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/settings.segments/!KGRlc2t0b3Ap/settings.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/settings.segments/!KGRlc2t0b3Ap.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/settings.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/settings.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/settings.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/terminal.html +1 -1
- package/.next/standalone/.next/server/app/terminal.rsc +2 -2
- package/.next/standalone/.next/server/app/terminal.segments/!KGRlc2t0b3Ap/terminal/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/terminal.segments/!KGRlc2t0b3Ap/terminal.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/terminal.segments/!KGRlc2t0b3Ap.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/terminal.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/terminal.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/terminal.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/terminal.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/workspaces.html +1 -1
- package/.next/standalone/.next/server/app/workspaces.rsc +2 -2
- package/.next/standalone/.next/server/app/workspaces.segments/!KGRlc2t0b3Ap/workspaces/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/workspaces.segments/!KGRlc2t0b3Ap/workspaces.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/workspaces.segments/!KGRlc2t0b3Ap.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/workspaces.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/workspaces.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/workspaces.segments/_index.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/workspaces.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__e742ef33._.js → [root-of-the-server]__0e4c2d35._.js} +2 -2
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__130dee4b._.js +98 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__142c2f41._.js +98 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__160e7c73._.js +148 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__2861e096._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__2d3d8d52._.js +98 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__57b966d5._.js +98 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__5a0020ba._.js +106 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__5bd0f118._.js +98 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__64f5810e._.js +98 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__74c48d65._.js +98 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__7d6610c4._.js +98 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__84f3af14._.js +98 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__8765f2fc._.js +98 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__a2ee9884._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__a6eb742d._.js +98 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__b4c83e91._.js +114 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__c546cf71._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__cae0486f._.js +106 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__d5615808._.js +98 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__d877df12._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__f66ceeb8._.js +98 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__f84e3cf3._.js +98 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__f893957c._.js +98 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__fcd26315._.js +98 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__fd505913._.js +98 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__feff7b91._.js +98 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__66aca5d4._.js +1 -1
- package/.next/standalone/.next/server/edge/chunks/_d73df637._.js +1 -1
- package/.next/standalone/.next/server/middleware-manifest.json +5 -5
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +2 -2
- package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/static/chunks/67c7bf5024309fca.css +3 -0
- package/.next/standalone/node_modules/@img/sharp-libvips-linux-x64/README.md +46 -0
- package/.next/standalone/node_modules/@img/sharp-libvips-linux-x64/lib/glib-2.0/include/glibconfig.h +221 -0
- package/.next/standalone/node_modules/@img/sharp-libvips-linux-x64/lib/index.js +1 -0
- package/.next/standalone/node_modules/@img/sharp-libvips-linux-x64/lib/libvips-cpp.so.8.17.3 +0 -0
- package/.next/standalone/node_modules/@img/sharp-libvips-linux-x64/package.json +42 -0
- package/.next/standalone/node_modules/@img/sharp-libvips-linuxmusl-x64/README.md +46 -0
- package/.next/standalone/node_modules/@img/sharp-libvips-linuxmusl-x64/lib/glib-2.0/include/glibconfig.h +221 -0
- package/.next/standalone/node_modules/@img/sharp-libvips-linuxmusl-x64/lib/index.js +1 -0
- package/.next/standalone/node_modules/@img/sharp-libvips-linuxmusl-x64/lib/libvips-cpp.so.8.17.3 +0 -0
- package/.next/standalone/node_modules/@img/sharp-libvips-linuxmusl-x64/package.json +42 -0
- package/.next/standalone/node_modules/@img/sharp-libvips-linuxmusl-x64/versions.json +30 -0
- package/.next/standalone/node_modules/@img/sharp-linux-x64/lib/sharp-linux-x64.node +0 -0
- package/.next/standalone/node_modules/@img/{sharp-win32-x64 → sharp-linux-x64}/package.json +46 -39
- package/.next/standalone/node_modules/@img/sharp-linuxmusl-x64/lib/sharp-linuxmusl-x64.node +0 -0
- package/.next/standalone/node_modules/@img/sharp-linuxmusl-x64/package.json +46 -0
- package/.next/standalone/package.json +89 -89
- package/.next/standalone/server.js +1 -1
- package/.next/standalone/tsconfig.json +34 -34
- package/LICENSE +661 -661
- package/README.md +131 -131
- package/bin/fix-standalone-externals.js +79 -79
- package/bin/lib/auto-setup.js +101 -101
- package/bin/mdns-service.js +171 -171
- package/bin/postinstall.js +35 -35
- package/bin/setup-admin.js +189 -189
- package/bin/spaces-dev.js +208 -208
- package/bin/spaces-install.js +483 -426
- package/bin/spaces-setup.js +247 -242
- package/bin/spaces.js +465 -465
- package/bin/terminal-server.js +1117 -1117
- package/package.json +89 -89
- package/.next/standalone/.claude/settings.local.json +0 -11
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__086be15a._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__20353b76._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__2b6758fc._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__2e9d1d5a._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__34c34116._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__3ce30e4e._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__43112c34._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__47a63195._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__60689e2b._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__83b9bcf3._.js +0 -11
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__89124c96._.js +0 -243
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__8c2eee30._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__8ffcf827._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__9e343d64._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__a651ede9._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__b4b692df._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__b4edb4d6._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__b71497ab._.js +0 -243
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__bef2ed87._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__c525457e._.js +0 -19
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__ccc27199._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__ce5edd98._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__dd2e81be._.js +0 -11
- package/.next/standalone/.next/static/chunks/ff5fac1bd7b518dd.css +0 -3
- package/.next/standalone/node_modules/@img/sharp-win32-x64/lib/sharp-win32-x64.node +0 -0
- /package/.next/standalone/.next/static/{U-EFIvMEHFIoGaoj6xBXK → nbYSIjUtkSwSvTgyR5p00}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{U-EFIvMEHFIoGaoj6xBXK → nbYSIjUtkSwSvTgyR5p00}/_clientMiddlewareManifest.json +0 -0
- /package/.next/standalone/.next/static/{U-EFIvMEHFIoGaoj6xBXK → nbYSIjUtkSwSvTgyR5p00}/_ssgManifest.js +0 -0
- /package/.next/standalone/node_modules/@img/{sharp-win32-x64 → sharp-libvips-linux-x64}/versions.json +0 -0
package/bin/spaces.js
CHANGED
|
@@ -1,466 +1,466 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const http = require('http');
|
|
4
|
-
const { execFileSync, spawn } = require('child_process');
|
|
5
|
-
const path = require('path');
|
|
6
|
-
const os = require('os');
|
|
7
|
-
const fs = require('fs');
|
|
8
|
-
// terminal-server is loaded lazily (after SPACES_TIER is set in process.env)
|
|
9
|
-
|
|
10
|
-
const SPACES_DIR = path.join(os.homedir(), '.spaces');
|
|
11
|
-
const CONFIG_PATH = path.join(SPACES_DIR, 'server.json');
|
|
12
|
-
const SESSION_SECRET_PATH = path.join(SPACES_DIR, 'session_secret');
|
|
13
|
-
const NEXT_INTERNAL_PORT = 3400;
|
|
14
|
-
const projectDir = path.join(__dirname, '..');
|
|
15
|
-
const MANAGED_PACKAGES = path.join(SPACES_DIR, 'packages');
|
|
16
|
-
const MANAGED_NODE_MODULES = path.join(MANAGED_PACKAGES, 'node_modules');
|
|
17
|
-
|
|
18
|
-
// ─── CLI arg parsing ──────────────────────────────────────
|
|
19
|
-
const args = process.argv.slice(2);
|
|
20
|
-
const cliFlags = {};
|
|
21
|
-
for (let i = 0; i < args.length; i++) {
|
|
22
|
-
if (args[i] === '--setup') { cliFlags.setup = true; }
|
|
23
|
-
else if (args[i] === '--port' && args[i + 1]) { cliFlags.port = parseInt(args[++i], 10); }
|
|
24
|
-
else if (args[i] === '--tier' && args[i + 1]) { cliFlags.tier = args[++i]; }
|
|
25
|
-
else if (args[i] === '--base-path' && args[i + 1]) { cliFlags.basePath = args[++i]; }
|
|
26
|
-
else if (args[i] === '--help' || args[i] === '-h') { cliFlags.help = true; }
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (cliFlags.help) {
|
|
30
|
-
console.log(`
|
|
31
|
-
Spaces - Agent Workspace Manager
|
|
32
|
-
|
|
33
|
-
Usage:
|
|
34
|
-
spaces Start the server (auto-detects tier)
|
|
35
|
-
spaces stop Stop running server
|
|
36
|
-
spaces install <teams|pro> Install a tier package
|
|
37
|
-
spaces uninstall [teams|pro] Uninstall packages (all if none specified)
|
|
38
|
-
spaces verify Verify installed packages
|
|
39
|
-
spaces upgrade [teams|pro] Upgrade installed packages
|
|
40
|
-
spaces --setup Interactive first-time setup wizard
|
|
41
|
-
spaces --port 3457 Override port
|
|
42
|
-
spaces --tier team Override tier (community|team|federation)
|
|
43
|
-
spaces --base-path /spaces Set base path for reverse proxy
|
|
44
|
-
spaces --help Show this help
|
|
45
|
-
`);
|
|
46
|
-
process.exit(0);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// ─── Stop command ─────────────────────────────────────────
|
|
50
|
-
const subcommand = args[0];
|
|
51
|
-
if (subcommand === 'stop') {
|
|
52
|
-
stopServer();
|
|
53
|
-
process.exit(0);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// ─── Route install/verify/upgrade to spaces-install.js ────
|
|
57
|
-
if (subcommand === 'install' || subcommand === 'uninstall' || subcommand === 'verify' || subcommand === 'upgrade') {
|
|
58
|
-
// Re-exec with spaces-install.js, passing through all args
|
|
59
|
-
const installScript = path.join(__dirname, 'spaces-install.js');
|
|
60
|
-
const { status } = require('child_process').spawnSync(
|
|
61
|
-
process.execPath, [installScript, ...args],
|
|
62
|
-
{ stdio: 'inherit', env: process.env }
|
|
63
|
-
);
|
|
64
|
-
process.exit(status || 0);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// ─── Setup wizard ─────────────────────────────────────────
|
|
68
|
-
if (cliFlags.setup) {
|
|
69
|
-
require('./spaces-setup');
|
|
70
|
-
// spaces-setup handles its own process.exit
|
|
71
|
-
} else {
|
|
72
|
-
startServer();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function startServer() {
|
|
76
|
-
// ─── Load saved config ────────────────────────────────────
|
|
77
|
-
let savedConfig = {};
|
|
78
|
-
if (fs.existsSync(CONFIG_PATH)) {
|
|
79
|
-
try { savedConfig = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8')); } catch {}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// ─── Resolve settings (CLI > env > config > defaults) ─────
|
|
83
|
-
const PORT = cliFlags.port
|
|
84
|
-
|| parseInt(process.env.SPACES_PORT || '', 10)
|
|
85
|
-
|| savedConfig.port
|
|
86
|
-
|| 3457;
|
|
87
|
-
|
|
88
|
-
const basePath = cliFlags.basePath
|
|
89
|
-
|| process.env.SPACES_BASE_PATH
|
|
90
|
-
|| savedConfig.basePath
|
|
91
|
-
|| '';
|
|
92
|
-
|
|
93
|
-
const allowedOrigins = process.env.SPACES_ALLOWED_ORIGINS
|
|
94
|
-
|| savedConfig.allowedOrigins
|
|
95
|
-
|| '';
|
|
96
|
-
|
|
97
|
-
// ─── Kill any existing server on this port ───────────────────
|
|
98
|
-
stopServer();
|
|
99
|
-
|
|
100
|
-
// ─── Resolve optional packages once ─────────────────────────
|
|
101
|
-
const proPath = resolveSpacesPro();
|
|
102
|
-
const teamsPath = resolveSpacesTeams();
|
|
103
|
-
|
|
104
|
-
// Tier resolution: CLI > env > config > auto-detect
|
|
105
|
-
let tier = cliFlags.tier
|
|
106
|
-
|| process.env.SPACES_TIER
|
|
107
|
-
|| savedConfig.tier
|
|
108
|
-
|| '';
|
|
109
|
-
|
|
110
|
-
// Auto-detect tier from package presence
|
|
111
|
-
if (!tier) {
|
|
112
|
-
if (proPath) tier = 'federation';
|
|
113
|
-
else if (teamsPath) tier = 'team';
|
|
114
|
-
else tier = 'community';
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
console.log('');
|
|
118
|
-
console.log(' Spaces - Agent Workspace Manager');
|
|
119
|
-
console.log(' =================================');
|
|
120
|
-
console.log('');
|
|
121
|
-
console.log(` Tier: ${tier}`);
|
|
122
|
-
|
|
123
|
-
// ─── Server tier prerequisites ────────────────────────────
|
|
124
|
-
const childEnv = { ...process.env };
|
|
125
|
-
|
|
126
|
-
if (tier !== 'community') {
|
|
127
|
-
// team/federation tiers require @spaces/teams (auth + collaboration)
|
|
128
|
-
if ((tier === 'team' || tier === 'federation') && !teamsPath) {
|
|
129
|
-
console.error(' Error: @spaces/teams is required for team/federation tiers.');
|
|
130
|
-
console.error(' Install it: spaces install teams');
|
|
131
|
-
process.exit(1);
|
|
132
|
-
}
|
|
133
|
-
// federation tier requires @spaces/pro (network)
|
|
134
|
-
if (tier === 'federation' && !proPath) {
|
|
135
|
-
console.error(' Error: @spaces/pro is required for the federation tier.');
|
|
136
|
-
console.error(' Install it: spaces install pro');
|
|
137
|
-
process.exit(1);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// Check for session secret
|
|
141
|
-
let sessionSecret = process.env.SPACES_SESSION_SECRET || '';
|
|
142
|
-
if (!sessionSecret && fs.existsSync(SESSION_SECRET_PATH)) {
|
|
143
|
-
sessionSecret = fs.readFileSync(SESSION_SECRET_PATH, 'utf-8').trim();
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// Check for admin DB — auto-setup if missing
|
|
147
|
-
const adminDbPath = path.join(SPACES_DIR, 'admin.db');
|
|
148
|
-
if (!fs.existsSync(adminDbPath) || !sessionSecret) {
|
|
149
|
-
const { autoSetup } = require('./lib/auto-setup');
|
|
150
|
-
const result = autoSetup({ SPACES_DIR, SESSION_SECRET_PATH, ADMIN_DB_PATH: adminDbPath, CONFIG_PATH, tier, port: PORT, basePath });
|
|
151
|
-
sessionSecret = result.sessionSecret;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
childEnv.SPACES_SESSION_SECRET = sessionSecret;
|
|
155
|
-
process.env.SPACES_SESSION_SECRET = sessionSecret;
|
|
156
|
-
console.log(` Admin DB: ${adminDbPath}`);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// Set tier in both child env and own process env (terminal-server reads it)
|
|
160
|
-
childEnv.SPACES_TIER = tier;
|
|
161
|
-
process.env.SPACES_TIER = tier;
|
|
162
|
-
if (basePath) {
|
|
163
|
-
childEnv.SPACES_BASE_PATH = basePath;
|
|
164
|
-
console.log(` Base path: ${basePath}`);
|
|
165
|
-
}
|
|
166
|
-
if (allowedOrigins) {
|
|
167
|
-
childEnv.SPACES_ALLOWED_ORIGINS = allowedOrigins;
|
|
168
|
-
process.env.SPACES_ALLOWED_ORIGINS = allowedOrigins;
|
|
169
|
-
console.log(` Allowed origins: ${allowedOrigins}`);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// ─── Resolve NODE_PATH for @spaces/pro and @spaces/teams ──
|
|
173
|
-
// Update both childEnv (for the Next.js child process) and process.env
|
|
174
|
-
// (for terminal-server.js which runs in this same parent process).
|
|
175
|
-
// Include:
|
|
176
|
-
// - Managed packages node_modules (~/.spaces/packages/node_modules)
|
|
177
|
-
// - Each managed package's own node_modules (for its bundled deps)
|
|
178
|
-
// - The host app's own node_modules (fallback for peer deps)
|
|
179
|
-
const appNodeModules = path.join(projectDir, 'node_modules');
|
|
180
|
-
const nodePaths = [MANAGED_NODE_MODULES, appNodeModules];
|
|
181
|
-
// Add each resolved package's own node_modules so its bundled deps are found
|
|
182
|
-
for (const pkgPath of [proPath, teamsPath]) {
|
|
183
|
-
if (pkgPath) {
|
|
184
|
-
// pkgPath is the package root (symlink target or direct path)
|
|
185
|
-
const realPath = fs.realpathSync(pkgPath);
|
|
186
|
-
const pkgNodeModules = path.join(realPath, 'node_modules');
|
|
187
|
-
if (fs.existsSync(pkgNodeModules) && !nodePaths.includes(pkgNodeModules)) {
|
|
188
|
-
nodePaths.push(pkgNodeModules);
|
|
189
|
-
}
|
|
190
|
-
// Also add the parent scope for @spaces/* resolution
|
|
191
|
-
const parentModules = path.dirname(path.dirname(pkgPath));
|
|
192
|
-
if (!nodePaths.includes(parentModules)) {
|
|
193
|
-
nodePaths.push(parentModules);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
for (const dir of nodePaths) {
|
|
198
|
-
for (const target of [childEnv, process.env]) {
|
|
199
|
-
const existing = target.NODE_PATH || '';
|
|
200
|
-
if (!existing.includes(dir)) {
|
|
201
|
-
target.NODE_PATH = existing
|
|
202
|
-
? `${dir}${path.delimiter}${existing}`
|
|
203
|
-
: dir;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
// Re-init module paths so require() in this process picks up the new NODE_PATH
|
|
208
|
-
require('module').Module._initPaths();
|
|
209
|
-
|
|
210
|
-
// Verify collaboration pipeline works end-to-end at startup
|
|
211
|
-
if (tier === 'team' || tier === 'federation') {
|
|
212
|
-
try {
|
|
213
|
-
const teams = require('@spaces/teams');
|
|
214
|
-
console.log(' Collaboration: @spaces/teams loaded OK');
|
|
215
|
-
// Smoke-test that peer deps resolve from this process
|
|
216
|
-
require('better-sqlite3');
|
|
217
|
-
} catch (e) {
|
|
218
|
-
console.error(` Warning: Collaboration may not work — ${e.message}`);
|
|
219
|
-
console.error(' Check that NODE_PATH includes the host app node_modules.');
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
console.log('');
|
|
224
|
-
|
|
225
|
-
// Check for ~/.claude/ directory
|
|
226
|
-
const claudeDir = path.join(os.homedir(), '.claude');
|
|
227
|
-
if (!fs.existsSync(claudeDir)) {
|
|
228
|
-
console.log(' Warning: ~/.claude/ not found. Have you used Claude Code yet?');
|
|
229
|
-
console.log('');
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// ─── Detect build type ────────────────────────────────────
|
|
233
|
-
const standaloneServer = path.join(projectDir, '.next', 'standalone', 'server.js');
|
|
234
|
-
const fullBuildDir = path.join(projectDir, '.next', 'BUILD_ID');
|
|
235
|
-
const isStandalone = fs.existsSync(standaloneServer);
|
|
236
|
-
const isFullBuild = fs.existsSync(fullBuildDir);
|
|
237
|
-
|
|
238
|
-
if (!isStandalone && !isFullBuild) {
|
|
239
|
-
console.error(' Error: No build found.');
|
|
240
|
-
console.error(' Run "npm run build" first, or install via "npm install -g @jlongo78/agent-spaces".');
|
|
241
|
-
process.exit(1);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
// ─── Spawn Next.js ────────────────────────────────────────
|
|
245
|
-
let next;
|
|
246
|
-
if (isStandalone) {
|
|
247
|
-
const parentNodeModules = path.join(projectDir, 'node_modules');
|
|
248
|
-
const existingNodePath = childEnv.NODE_PATH || '';
|
|
249
|
-
childEnv.NODE_PATH = existingNodePath
|
|
250
|
-
? `${parentNodeModules}${path.delimiter}${existingNodePath}`
|
|
251
|
-
: parentNodeModules;
|
|
252
|
-
|
|
253
|
-
next = spawn(process.execPath, [standaloneServer], {
|
|
254
|
-
cwd: path.dirname(standaloneServer),
|
|
255
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
256
|
-
env: {
|
|
257
|
-
...childEnv,
|
|
258
|
-
PORT: String(NEXT_INTERNAL_PORT),
|
|
259
|
-
HOSTNAME: '0.0.0.0',
|
|
260
|
-
NODE_ENV: 'production',
|
|
261
|
-
},
|
|
262
|
-
});
|
|
263
|
-
} else {
|
|
264
|
-
next = spawn('npx', ['next', 'start', '--port', String(NEXT_INTERNAL_PORT)], {
|
|
265
|
-
cwd: projectDir,
|
|
266
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
267
|
-
env: {
|
|
268
|
-
...childEnv,
|
|
269
|
-
PORT: String(NEXT_INTERNAL_PORT),
|
|
270
|
-
HOSTNAME: '0.0.0.0',
|
|
271
|
-
NODE_ENV: 'production',
|
|
272
|
-
},
|
|
273
|
-
shell: true,
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
let nextReady = false;
|
|
278
|
-
|
|
279
|
-
next.stdout.on('data', (data) => {
|
|
280
|
-
const msg = data.toString();
|
|
281
|
-
process.stdout.write(msg);
|
|
282
|
-
if (!nextReady && (msg.includes('Ready') || msg.includes('started server') || msg.includes('Listening') || msg.includes('localhost'))) {
|
|
283
|
-
nextReady = true;
|
|
284
|
-
console.log(`\n Ready at http://localhost:${PORT}\n`);
|
|
285
|
-
|
|
286
|
-
const url = `http://localhost:${PORT}`;
|
|
287
|
-
try {
|
|
288
|
-
if (process.platform === 'win32') {
|
|
289
|
-
execFileSync('cmd', ['/c', 'start', url], { stdio: 'ignore' });
|
|
290
|
-
} else if (process.platform === 'darwin') {
|
|
291
|
-
execFileSync('open', [url], { stdio: 'ignore' });
|
|
292
|
-
} else {
|
|
293
|
-
execFileSync('xdg-open', [url], { stdio: 'ignore' });
|
|
294
|
-
}
|
|
295
|
-
} catch {
|
|
296
|
-
console.log(` Open ${url} in your browser`);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
next.stderr.on('data', (data) => {
|
|
302
|
-
const msg = data.toString();
|
|
303
|
-
if (!msg.includes('Warning')) {
|
|
304
|
-
process.stderr.write(data);
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
next.on('exit', (code) => {
|
|
309
|
-
if (code !== 0 && code !== null) {
|
|
310
|
-
console.error(` [spaces] Next.js exited with code ${code}`);
|
|
311
|
-
}
|
|
312
|
-
cleanup();
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
// ─── HTTP proxy server ────────────────────────────────────
|
|
316
|
-
const server = http.createServer((req, res) => {
|
|
317
|
-
// WebSocket paths are handled by the 'upgrade' event, but a plain
|
|
318
|
-
// HTTP request to /ws (e.g. health check) should not be proxied to
|
|
319
|
-
// Next.js which would 308-redirect it due to trailingSlash.
|
|
320
|
-
const urlPath = (req.url || '').split('?')[0];
|
|
321
|
-
if (urlPath === '/ws' || urlPath.endsWith('/ws') || urlPath.endsWith('/ws/')) {
|
|
322
|
-
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
|
323
|
-
res.end('WebSocket endpoint');
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
const proxyReq = http.request(
|
|
328
|
-
{
|
|
329
|
-
hostname: '127.0.0.1',
|
|
330
|
-
port: NEXT_INTERNAL_PORT,
|
|
331
|
-
path: req.url,
|
|
332
|
-
method: req.method,
|
|
333
|
-
headers: req.headers,
|
|
334
|
-
},
|
|
335
|
-
(proxyRes) => {
|
|
336
|
-
res.writeHead(proxyRes.statusCode, proxyRes.headers);
|
|
337
|
-
proxyRes.pipe(res);
|
|
338
|
-
}
|
|
339
|
-
);
|
|
340
|
-
proxyReq.on('error', () => {
|
|
341
|
-
if (!res.headersSent) {
|
|
342
|
-
res.writeHead(502);
|
|
343
|
-
res.end('Server not ready yet. Refresh in a moment.');
|
|
344
|
-
}
|
|
345
|
-
});
|
|
346
|
-
req.pipe(proxyReq);
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
const { createTerminalServer } = require('./terminal-server');
|
|
350
|
-
createTerminalServer(server);
|
|
351
|
-
|
|
352
|
-
server.listen(PORT, () => {
|
|
353
|
-
console.log(` Starting server on http://localhost:${PORT}`);
|
|
354
|
-
console.log('');
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
function cleanup() {
|
|
358
|
-
next.kill();
|
|
359
|
-
server.close();
|
|
360
|
-
process.exit(0);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
process.on('SIGINT', cleanup);
|
|
364
|
-
process.on('SIGTERM', cleanup);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
// ─── Stop running server ─────────────────────────────────────
|
|
368
|
-
function findPidsOnPort(port) {
|
|
369
|
-
const pids = new Set();
|
|
370
|
-
// Try lsof first
|
|
371
|
-
try {
|
|
372
|
-
const output = execFileSync('lsof', ['-ti', `tcp:${port}`], { encoding: 'utf-8' }).trim();
|
|
373
|
-
for (const p of output.split('\n')) { if (p.trim()) pids.add(parseInt(p.trim(), 10)); }
|
|
374
|
-
} catch {}
|
|
375
|
-
// Fallback to fuser (catches processes lsof misses)
|
|
376
|
-
try {
|
|
377
|
-
const output = execFileSync('fuser', [`${port}/tcp`], { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
|
|
378
|
-
for (const p of output.split(/\s+/)) { if (p.trim()) pids.add(parseInt(p.trim(), 10)); }
|
|
379
|
-
} catch {}
|
|
380
|
-
return [...pids].filter(p => !isNaN(p) && p > 0);
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
function stopServer() {
|
|
384
|
-
let savedConfig = {};
|
|
385
|
-
if (fs.existsSync(CONFIG_PATH)) {
|
|
386
|
-
try { savedConfig = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8')); } catch {}
|
|
387
|
-
}
|
|
388
|
-
const port = parseInt(process.env.SPACES_PORT || '', 10) || savedConfig.port || 3457;
|
|
389
|
-
const ports = [port, NEXT_INTERNAL_PORT];
|
|
390
|
-
let killed = 0;
|
|
391
|
-
|
|
392
|
-
for (const p of ports) {
|
|
393
|
-
for (const pid of findPidsOnPort(p)) {
|
|
394
|
-
try {
|
|
395
|
-
process.kill(pid, 'SIGTERM');
|
|
396
|
-
killed++;
|
|
397
|
-
} catch {}
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
if (killed > 0) {
|
|
402
|
-
console.log(` Stopped ${killed} process(es) on port ${port}`);
|
|
403
|
-
// Wait for ports to be released, escalate to SIGKILL if needed
|
|
404
|
-
const deadline = Date.now() + 2000;
|
|
405
|
-
let escalated = false;
|
|
406
|
-
while (Date.now() < deadline) {
|
|
407
|
-
const remaining = ports.flatMap(p => findPidsOnPort(p));
|
|
408
|
-
if (remaining.length === 0) break;
|
|
409
|
-
if (!escalated && Date.now() > deadline - 1000) {
|
|
410
|
-
for (const pid of remaining) {
|
|
411
|
-
try { process.kill(pid, 'SIGKILL'); } catch {}
|
|
412
|
-
}
|
|
413
|
-
escalated = true;
|
|
414
|
-
}
|
|
415
|
-
require('child_process').spawnSync('sleep', ['0.2']);
|
|
416
|
-
}
|
|
417
|
-
} else {
|
|
418
|
-
console.log(` No running server found on port ${port}`);
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
// ─── @spaces/pro resolution ──────────────────────────────────
|
|
423
|
-
function resolveSpacesPro() {
|
|
424
|
-
// 1. Managed install (~/.spaces/packages/)
|
|
425
|
-
const managed = path.join(MANAGED_NODE_MODULES, '@spaces', 'pro');
|
|
426
|
-
if (fs.existsSync(path.join(managed, 'dist', 'index.js'))) return managed;
|
|
427
|
-
|
|
428
|
-
// 2. Local node_modules (npm link / optionalDep)
|
|
429
|
-
try {
|
|
430
|
-
return require.resolve('@spaces/pro');
|
|
431
|
-
} catch {}
|
|
432
|
-
|
|
433
|
-
// 3. Global npm prefix (legacy)
|
|
434
|
-
try {
|
|
435
|
-
const globalPrefix = execFileSync('npm', ['prefix', '-g'], { encoding: 'utf-8' }).trim();
|
|
436
|
-
const globalProPath = path.join(globalPrefix, 'lib', 'node_modules', '@spaces', 'pro');
|
|
437
|
-
if (fs.existsSync(globalProPath)) return globalProPath;
|
|
438
|
-
const altPath = path.join(globalPrefix, 'node_modules', '@spaces', 'pro');
|
|
439
|
-
if (fs.existsSync(altPath)) return altPath;
|
|
440
|
-
} catch {}
|
|
441
|
-
|
|
442
|
-
return null;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
// ─── @spaces/teams resolution ────────────────────────────────
|
|
446
|
-
function resolveSpacesTeams() {
|
|
447
|
-
// 1. Managed install (~/.spaces/packages/)
|
|
448
|
-
const managed = path.join(MANAGED_NODE_MODULES, '@spaces', 'teams');
|
|
449
|
-
if (fs.existsSync(path.join(managed, 'dist', 'index.js'))) return managed;
|
|
450
|
-
|
|
451
|
-
// 2. Local node_modules (npm link / optionalDep)
|
|
452
|
-
try {
|
|
453
|
-
return require.resolve('@spaces/teams');
|
|
454
|
-
} catch {}
|
|
455
|
-
|
|
456
|
-
// 3. Global npm prefix (legacy)
|
|
457
|
-
try {
|
|
458
|
-
const globalPrefix = execFileSync('npm', ['prefix', '-g'], { encoding: 'utf-8' }).trim();
|
|
459
|
-
const globalTeamsPath = path.join(globalPrefix, 'lib', 'node_modules', '@spaces', 'teams');
|
|
460
|
-
if (fs.existsSync(globalTeamsPath)) return globalTeamsPath;
|
|
461
|
-
const altPath = path.join(globalPrefix, 'node_modules', '@spaces', 'teams');
|
|
462
|
-
if (fs.existsSync(altPath)) return altPath;
|
|
463
|
-
} catch {}
|
|
464
|
-
|
|
465
|
-
return null;
|
|
466
|
-
}
|
|
2
|
+
|
|
3
|
+
const http = require('http');
|
|
4
|
+
const { execFileSync, spawn } = require('child_process');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const os = require('os');
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
// terminal-server is loaded lazily (after SPACES_TIER is set in process.env)
|
|
9
|
+
|
|
10
|
+
const SPACES_DIR = path.join(os.homedir(), '.spaces');
|
|
11
|
+
const CONFIG_PATH = path.join(SPACES_DIR, 'server.json');
|
|
12
|
+
const SESSION_SECRET_PATH = path.join(SPACES_DIR, 'session_secret');
|
|
13
|
+
const NEXT_INTERNAL_PORT = 3400;
|
|
14
|
+
const projectDir = path.join(__dirname, '..');
|
|
15
|
+
const MANAGED_PACKAGES = path.join(SPACES_DIR, 'packages');
|
|
16
|
+
const MANAGED_NODE_MODULES = path.join(MANAGED_PACKAGES, 'node_modules');
|
|
17
|
+
|
|
18
|
+
// ─── CLI arg parsing ──────────────────────────────────────
|
|
19
|
+
const args = process.argv.slice(2);
|
|
20
|
+
const cliFlags = {};
|
|
21
|
+
for (let i = 0; i < args.length; i++) {
|
|
22
|
+
if (args[i] === '--setup') { cliFlags.setup = true; }
|
|
23
|
+
else if (args[i] === '--port' && args[i + 1]) { cliFlags.port = parseInt(args[++i], 10); }
|
|
24
|
+
else if (args[i] === '--tier' && args[i + 1]) { cliFlags.tier = args[++i]; }
|
|
25
|
+
else if (args[i] === '--base-path' && args[i + 1]) { cliFlags.basePath = args[++i]; }
|
|
26
|
+
else if (args[i] === '--help' || args[i] === '-h') { cliFlags.help = true; }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (cliFlags.help) {
|
|
30
|
+
console.log(`
|
|
31
|
+
Spaces - Agent Workspace Manager
|
|
32
|
+
|
|
33
|
+
Usage:
|
|
34
|
+
spaces Start the server (auto-detects tier)
|
|
35
|
+
spaces stop Stop running server
|
|
36
|
+
spaces install <teams|pro> Install a tier package
|
|
37
|
+
spaces uninstall [teams|pro] Uninstall packages (all if none specified)
|
|
38
|
+
spaces verify Verify installed packages
|
|
39
|
+
spaces upgrade [teams|pro] Upgrade installed packages
|
|
40
|
+
spaces --setup Interactive first-time setup wizard
|
|
41
|
+
spaces --port 3457 Override port
|
|
42
|
+
spaces --tier team Override tier (community|team|federation)
|
|
43
|
+
spaces --base-path /spaces Set base path for reverse proxy
|
|
44
|
+
spaces --help Show this help
|
|
45
|
+
`);
|
|
46
|
+
process.exit(0);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ─── Stop command ─────────────────────────────────────────
|
|
50
|
+
const subcommand = args[0];
|
|
51
|
+
if (subcommand === 'stop') {
|
|
52
|
+
stopServer();
|
|
53
|
+
process.exit(0);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ─── Route install/verify/upgrade to spaces-install.js ────
|
|
57
|
+
if (subcommand === 'install' || subcommand === 'uninstall' || subcommand === 'verify' || subcommand === 'upgrade') {
|
|
58
|
+
// Re-exec with spaces-install.js, passing through all args
|
|
59
|
+
const installScript = path.join(__dirname, 'spaces-install.js');
|
|
60
|
+
const { status } = require('child_process').spawnSync(
|
|
61
|
+
process.execPath, [installScript, ...args],
|
|
62
|
+
{ stdio: 'inherit', env: process.env }
|
|
63
|
+
);
|
|
64
|
+
process.exit(status || 0);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// ─── Setup wizard ─────────────────────────────────────────
|
|
68
|
+
if (cliFlags.setup) {
|
|
69
|
+
require('./spaces-setup');
|
|
70
|
+
// spaces-setup handles its own process.exit
|
|
71
|
+
} else {
|
|
72
|
+
startServer();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function startServer() {
|
|
76
|
+
// ─── Load saved config ────────────────────────────────────
|
|
77
|
+
let savedConfig = {};
|
|
78
|
+
if (fs.existsSync(CONFIG_PATH)) {
|
|
79
|
+
try { savedConfig = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8')); } catch {}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// ─── Resolve settings (CLI > env > config > defaults) ─────
|
|
83
|
+
const PORT = cliFlags.port
|
|
84
|
+
|| parseInt(process.env.SPACES_PORT || '', 10)
|
|
85
|
+
|| savedConfig.port
|
|
86
|
+
|| 3457;
|
|
87
|
+
|
|
88
|
+
const basePath = cliFlags.basePath
|
|
89
|
+
|| process.env.SPACES_BASE_PATH
|
|
90
|
+
|| savedConfig.basePath
|
|
91
|
+
|| '';
|
|
92
|
+
|
|
93
|
+
const allowedOrigins = process.env.SPACES_ALLOWED_ORIGINS
|
|
94
|
+
|| savedConfig.allowedOrigins
|
|
95
|
+
|| '';
|
|
96
|
+
|
|
97
|
+
// ─── Kill any existing server on this port ───────────────────
|
|
98
|
+
stopServer();
|
|
99
|
+
|
|
100
|
+
// ─── Resolve optional packages once ─────────────────────────
|
|
101
|
+
const proPath = resolveSpacesPro();
|
|
102
|
+
const teamsPath = resolveSpacesTeams();
|
|
103
|
+
|
|
104
|
+
// Tier resolution: CLI > env > config > auto-detect
|
|
105
|
+
let tier = cliFlags.tier
|
|
106
|
+
|| process.env.SPACES_TIER
|
|
107
|
+
|| savedConfig.tier
|
|
108
|
+
|| '';
|
|
109
|
+
|
|
110
|
+
// Auto-detect tier from package presence
|
|
111
|
+
if (!tier) {
|
|
112
|
+
if (proPath) tier = 'federation';
|
|
113
|
+
else if (teamsPath) tier = 'team';
|
|
114
|
+
else tier = 'community';
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
console.log('');
|
|
118
|
+
console.log(' Spaces - Agent Workspace Manager');
|
|
119
|
+
console.log(' =================================');
|
|
120
|
+
console.log('');
|
|
121
|
+
console.log(` Tier: ${tier}`);
|
|
122
|
+
|
|
123
|
+
// ─── Server tier prerequisites ────────────────────────────
|
|
124
|
+
const childEnv = { ...process.env };
|
|
125
|
+
|
|
126
|
+
if (tier !== 'community') {
|
|
127
|
+
// team/federation tiers require @spaces/teams (auth + collaboration)
|
|
128
|
+
if ((tier === 'team' || tier === 'federation') && !teamsPath) {
|
|
129
|
+
console.error(' Error: @spaces/teams is required for team/federation tiers.');
|
|
130
|
+
console.error(' Install it: spaces install teams');
|
|
131
|
+
process.exit(1);
|
|
132
|
+
}
|
|
133
|
+
// federation tier requires @spaces/pro (network)
|
|
134
|
+
if (tier === 'federation' && !proPath) {
|
|
135
|
+
console.error(' Error: @spaces/pro is required for the federation tier.');
|
|
136
|
+
console.error(' Install it: spaces install pro');
|
|
137
|
+
process.exit(1);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Check for session secret
|
|
141
|
+
let sessionSecret = process.env.SPACES_SESSION_SECRET || '';
|
|
142
|
+
if (!sessionSecret && fs.existsSync(SESSION_SECRET_PATH)) {
|
|
143
|
+
sessionSecret = fs.readFileSync(SESSION_SECRET_PATH, 'utf-8').trim();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Check for admin DB — auto-setup if missing
|
|
147
|
+
const adminDbPath = path.join(SPACES_DIR, 'admin.db');
|
|
148
|
+
if (!fs.existsSync(adminDbPath) || !sessionSecret) {
|
|
149
|
+
const { autoSetup } = require('./lib/auto-setup');
|
|
150
|
+
const result = autoSetup({ SPACES_DIR, SESSION_SECRET_PATH, ADMIN_DB_PATH: adminDbPath, CONFIG_PATH, tier, port: PORT, basePath });
|
|
151
|
+
sessionSecret = result.sessionSecret;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
childEnv.SPACES_SESSION_SECRET = sessionSecret;
|
|
155
|
+
process.env.SPACES_SESSION_SECRET = sessionSecret;
|
|
156
|
+
console.log(` Admin DB: ${adminDbPath}`);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Set tier in both child env and own process env (terminal-server reads it)
|
|
160
|
+
childEnv.SPACES_TIER = tier;
|
|
161
|
+
process.env.SPACES_TIER = tier;
|
|
162
|
+
if (basePath) {
|
|
163
|
+
childEnv.SPACES_BASE_PATH = basePath;
|
|
164
|
+
console.log(` Base path: ${basePath}`);
|
|
165
|
+
}
|
|
166
|
+
if (allowedOrigins) {
|
|
167
|
+
childEnv.SPACES_ALLOWED_ORIGINS = allowedOrigins;
|
|
168
|
+
process.env.SPACES_ALLOWED_ORIGINS = allowedOrigins;
|
|
169
|
+
console.log(` Allowed origins: ${allowedOrigins}`);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// ─── Resolve NODE_PATH for @spaces/pro and @spaces/teams ──
|
|
173
|
+
// Update both childEnv (for the Next.js child process) and process.env
|
|
174
|
+
// (for terminal-server.js which runs in this same parent process).
|
|
175
|
+
// Include:
|
|
176
|
+
// - Managed packages node_modules (~/.spaces/packages/node_modules)
|
|
177
|
+
// - Each managed package's own node_modules (for its bundled deps)
|
|
178
|
+
// - The host app's own node_modules (fallback for peer deps)
|
|
179
|
+
const appNodeModules = path.join(projectDir, 'node_modules');
|
|
180
|
+
const nodePaths = [MANAGED_NODE_MODULES, appNodeModules];
|
|
181
|
+
// Add each resolved package's own node_modules so its bundled deps are found
|
|
182
|
+
for (const pkgPath of [proPath, teamsPath]) {
|
|
183
|
+
if (pkgPath) {
|
|
184
|
+
// pkgPath is the package root (symlink target or direct path)
|
|
185
|
+
const realPath = fs.realpathSync(pkgPath);
|
|
186
|
+
const pkgNodeModules = path.join(realPath, 'node_modules');
|
|
187
|
+
if (fs.existsSync(pkgNodeModules) && !nodePaths.includes(pkgNodeModules)) {
|
|
188
|
+
nodePaths.push(pkgNodeModules);
|
|
189
|
+
}
|
|
190
|
+
// Also add the parent scope for @spaces/* resolution
|
|
191
|
+
const parentModules = path.dirname(path.dirname(pkgPath));
|
|
192
|
+
if (!nodePaths.includes(parentModules)) {
|
|
193
|
+
nodePaths.push(parentModules);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
for (const dir of nodePaths) {
|
|
198
|
+
for (const target of [childEnv, process.env]) {
|
|
199
|
+
const existing = target.NODE_PATH || '';
|
|
200
|
+
if (!existing.includes(dir)) {
|
|
201
|
+
target.NODE_PATH = existing
|
|
202
|
+
? `${dir}${path.delimiter}${existing}`
|
|
203
|
+
: dir;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
// Re-init module paths so require() in this process picks up the new NODE_PATH
|
|
208
|
+
require('module').Module._initPaths();
|
|
209
|
+
|
|
210
|
+
// Verify collaboration pipeline works end-to-end at startup
|
|
211
|
+
if (tier === 'team' || tier === 'federation') {
|
|
212
|
+
try {
|
|
213
|
+
const teams = require('@spaces/teams');
|
|
214
|
+
console.log(' Collaboration: @spaces/teams loaded OK');
|
|
215
|
+
// Smoke-test that peer deps resolve from this process
|
|
216
|
+
require('better-sqlite3');
|
|
217
|
+
} catch (e) {
|
|
218
|
+
console.error(` Warning: Collaboration may not work — ${e.message}`);
|
|
219
|
+
console.error(' Check that NODE_PATH includes the host app node_modules.');
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
console.log('');
|
|
224
|
+
|
|
225
|
+
// Check for ~/.claude/ directory
|
|
226
|
+
const claudeDir = path.join(os.homedir(), '.claude');
|
|
227
|
+
if (!fs.existsSync(claudeDir)) {
|
|
228
|
+
console.log(' Warning: ~/.claude/ not found. Have you used Claude Code yet?');
|
|
229
|
+
console.log('');
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// ─── Detect build type ────────────────────────────────────
|
|
233
|
+
const standaloneServer = path.join(projectDir, '.next', 'standalone', 'server.js');
|
|
234
|
+
const fullBuildDir = path.join(projectDir, '.next', 'BUILD_ID');
|
|
235
|
+
const isStandalone = fs.existsSync(standaloneServer);
|
|
236
|
+
const isFullBuild = fs.existsSync(fullBuildDir);
|
|
237
|
+
|
|
238
|
+
if (!isStandalone && !isFullBuild) {
|
|
239
|
+
console.error(' Error: No build found.');
|
|
240
|
+
console.error(' Run "npm run build" first, or install via "npm install -g @jlongo78/agent-spaces".');
|
|
241
|
+
process.exit(1);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// ─── Spawn Next.js ────────────────────────────────────────
|
|
245
|
+
let next;
|
|
246
|
+
if (isStandalone) {
|
|
247
|
+
const parentNodeModules = path.join(projectDir, 'node_modules');
|
|
248
|
+
const existingNodePath = childEnv.NODE_PATH || '';
|
|
249
|
+
childEnv.NODE_PATH = existingNodePath
|
|
250
|
+
? `${parentNodeModules}${path.delimiter}${existingNodePath}`
|
|
251
|
+
: parentNodeModules;
|
|
252
|
+
|
|
253
|
+
next = spawn(process.execPath, [standaloneServer], {
|
|
254
|
+
cwd: path.dirname(standaloneServer),
|
|
255
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
256
|
+
env: {
|
|
257
|
+
...childEnv,
|
|
258
|
+
PORT: String(NEXT_INTERNAL_PORT),
|
|
259
|
+
HOSTNAME: '0.0.0.0',
|
|
260
|
+
NODE_ENV: 'production',
|
|
261
|
+
},
|
|
262
|
+
});
|
|
263
|
+
} else {
|
|
264
|
+
next = spawn('npx', ['next', 'start', '--port', String(NEXT_INTERNAL_PORT)], {
|
|
265
|
+
cwd: projectDir,
|
|
266
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
267
|
+
env: {
|
|
268
|
+
...childEnv,
|
|
269
|
+
PORT: String(NEXT_INTERNAL_PORT),
|
|
270
|
+
HOSTNAME: '0.0.0.0',
|
|
271
|
+
NODE_ENV: 'production',
|
|
272
|
+
},
|
|
273
|
+
shell: true,
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
let nextReady = false;
|
|
278
|
+
|
|
279
|
+
next.stdout.on('data', (data) => {
|
|
280
|
+
const msg = data.toString();
|
|
281
|
+
process.stdout.write(msg);
|
|
282
|
+
if (!nextReady && (msg.includes('Ready') || msg.includes('started server') || msg.includes('Listening') || msg.includes('localhost'))) {
|
|
283
|
+
nextReady = true;
|
|
284
|
+
console.log(`\n Ready at http://localhost:${PORT}\n`);
|
|
285
|
+
|
|
286
|
+
const url = `http://localhost:${PORT}`;
|
|
287
|
+
try {
|
|
288
|
+
if (process.platform === 'win32') {
|
|
289
|
+
execFileSync('cmd', ['/c', 'start', url], { stdio: 'ignore' });
|
|
290
|
+
} else if (process.platform === 'darwin') {
|
|
291
|
+
execFileSync('open', [url], { stdio: 'ignore' });
|
|
292
|
+
} else {
|
|
293
|
+
execFileSync('xdg-open', [url], { stdio: 'ignore' });
|
|
294
|
+
}
|
|
295
|
+
} catch {
|
|
296
|
+
console.log(` Open ${url} in your browser`);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
next.stderr.on('data', (data) => {
|
|
302
|
+
const msg = data.toString();
|
|
303
|
+
if (!msg.includes('Warning')) {
|
|
304
|
+
process.stderr.write(data);
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
next.on('exit', (code) => {
|
|
309
|
+
if (code !== 0 && code !== null) {
|
|
310
|
+
console.error(` [spaces] Next.js exited with code ${code}`);
|
|
311
|
+
}
|
|
312
|
+
cleanup();
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
// ─── HTTP proxy server ────────────────────────────────────
|
|
316
|
+
const server = http.createServer((req, res) => {
|
|
317
|
+
// WebSocket paths are handled by the 'upgrade' event, but a plain
|
|
318
|
+
// HTTP request to /ws (e.g. health check) should not be proxied to
|
|
319
|
+
// Next.js which would 308-redirect it due to trailingSlash.
|
|
320
|
+
const urlPath = (req.url || '').split('?')[0];
|
|
321
|
+
if (urlPath === '/ws' || urlPath.endsWith('/ws') || urlPath.endsWith('/ws/')) {
|
|
322
|
+
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
|
323
|
+
res.end('WebSocket endpoint');
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const proxyReq = http.request(
|
|
328
|
+
{
|
|
329
|
+
hostname: '127.0.0.1',
|
|
330
|
+
port: NEXT_INTERNAL_PORT,
|
|
331
|
+
path: req.url,
|
|
332
|
+
method: req.method,
|
|
333
|
+
headers: req.headers,
|
|
334
|
+
},
|
|
335
|
+
(proxyRes) => {
|
|
336
|
+
res.writeHead(proxyRes.statusCode, proxyRes.headers);
|
|
337
|
+
proxyRes.pipe(res);
|
|
338
|
+
}
|
|
339
|
+
);
|
|
340
|
+
proxyReq.on('error', () => {
|
|
341
|
+
if (!res.headersSent) {
|
|
342
|
+
res.writeHead(502);
|
|
343
|
+
res.end('Server not ready yet. Refresh in a moment.');
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
req.pipe(proxyReq);
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
const { createTerminalServer } = require('./terminal-server');
|
|
350
|
+
createTerminalServer(server);
|
|
351
|
+
|
|
352
|
+
server.listen(PORT, () => {
|
|
353
|
+
console.log(` Starting server on http://localhost:${PORT}`);
|
|
354
|
+
console.log('');
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
function cleanup() {
|
|
358
|
+
next.kill();
|
|
359
|
+
server.close();
|
|
360
|
+
process.exit(0);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
process.on('SIGINT', cleanup);
|
|
364
|
+
process.on('SIGTERM', cleanup);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// ─── Stop running server ─────────────────────────────────────
|
|
368
|
+
function findPidsOnPort(port) {
|
|
369
|
+
const pids = new Set();
|
|
370
|
+
// Try lsof first
|
|
371
|
+
try {
|
|
372
|
+
const output = execFileSync('lsof', ['-ti', `tcp:${port}`], { encoding: 'utf-8' }).trim();
|
|
373
|
+
for (const p of output.split('\n')) { if (p.trim()) pids.add(parseInt(p.trim(), 10)); }
|
|
374
|
+
} catch {}
|
|
375
|
+
// Fallback to fuser (catches processes lsof misses)
|
|
376
|
+
try {
|
|
377
|
+
const output = execFileSync('fuser', [`${port}/tcp`], { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
|
|
378
|
+
for (const p of output.split(/\s+/)) { if (p.trim()) pids.add(parseInt(p.trim(), 10)); }
|
|
379
|
+
} catch {}
|
|
380
|
+
return [...pids].filter(p => !isNaN(p) && p > 0);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function stopServer() {
|
|
384
|
+
let savedConfig = {};
|
|
385
|
+
if (fs.existsSync(CONFIG_PATH)) {
|
|
386
|
+
try { savedConfig = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8')); } catch {}
|
|
387
|
+
}
|
|
388
|
+
const port = parseInt(process.env.SPACES_PORT || '', 10) || savedConfig.port || 3457;
|
|
389
|
+
const ports = [port, NEXT_INTERNAL_PORT];
|
|
390
|
+
let killed = 0;
|
|
391
|
+
|
|
392
|
+
for (const p of ports) {
|
|
393
|
+
for (const pid of findPidsOnPort(p)) {
|
|
394
|
+
try {
|
|
395
|
+
process.kill(pid, 'SIGTERM');
|
|
396
|
+
killed++;
|
|
397
|
+
} catch {}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
if (killed > 0) {
|
|
402
|
+
console.log(` Stopped ${killed} process(es) on port ${port}`);
|
|
403
|
+
// Wait for ports to be released, escalate to SIGKILL if needed
|
|
404
|
+
const deadline = Date.now() + 2000;
|
|
405
|
+
let escalated = false;
|
|
406
|
+
while (Date.now() < deadline) {
|
|
407
|
+
const remaining = ports.flatMap(p => findPidsOnPort(p));
|
|
408
|
+
if (remaining.length === 0) break;
|
|
409
|
+
if (!escalated && Date.now() > deadline - 1000) {
|
|
410
|
+
for (const pid of remaining) {
|
|
411
|
+
try { process.kill(pid, 'SIGKILL'); } catch {}
|
|
412
|
+
}
|
|
413
|
+
escalated = true;
|
|
414
|
+
}
|
|
415
|
+
require('child_process').spawnSync('sleep', ['0.2']);
|
|
416
|
+
}
|
|
417
|
+
} else {
|
|
418
|
+
console.log(` No running server found on port ${port}`);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// ─── @spaces/pro resolution ──────────────────────────────────
|
|
423
|
+
function resolveSpacesPro() {
|
|
424
|
+
// 1. Managed install (~/.spaces/packages/)
|
|
425
|
+
const managed = path.join(MANAGED_NODE_MODULES, '@spaces', 'pro');
|
|
426
|
+
if (fs.existsSync(path.join(managed, 'dist', 'index.js'))) return managed;
|
|
427
|
+
|
|
428
|
+
// 2. Local node_modules (npm link / optionalDep)
|
|
429
|
+
try {
|
|
430
|
+
return require.resolve('@spaces/pro');
|
|
431
|
+
} catch {}
|
|
432
|
+
|
|
433
|
+
// 3. Global npm prefix (legacy)
|
|
434
|
+
try {
|
|
435
|
+
const globalPrefix = execFileSync('npm', ['prefix', '-g'], { encoding: 'utf-8' }).trim();
|
|
436
|
+
const globalProPath = path.join(globalPrefix, 'lib', 'node_modules', '@spaces', 'pro');
|
|
437
|
+
if (fs.existsSync(globalProPath)) return globalProPath;
|
|
438
|
+
const altPath = path.join(globalPrefix, 'node_modules', '@spaces', 'pro');
|
|
439
|
+
if (fs.existsSync(altPath)) return altPath;
|
|
440
|
+
} catch {}
|
|
441
|
+
|
|
442
|
+
return null;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// ─── @spaces/teams resolution ────────────────────────────────
|
|
446
|
+
function resolveSpacesTeams() {
|
|
447
|
+
// 1. Managed install (~/.spaces/packages/)
|
|
448
|
+
const managed = path.join(MANAGED_NODE_MODULES, '@spaces', 'teams');
|
|
449
|
+
if (fs.existsSync(path.join(managed, 'dist', 'index.js'))) return managed;
|
|
450
|
+
|
|
451
|
+
// 2. Local node_modules (npm link / optionalDep)
|
|
452
|
+
try {
|
|
453
|
+
return require.resolve('@spaces/teams');
|
|
454
|
+
} catch {}
|
|
455
|
+
|
|
456
|
+
// 3. Global npm prefix (legacy)
|
|
457
|
+
try {
|
|
458
|
+
const globalPrefix = execFileSync('npm', ['prefix', '-g'], { encoding: 'utf-8' }).trim();
|
|
459
|
+
const globalTeamsPath = path.join(globalPrefix, 'lib', 'node_modules', '@spaces', 'teams');
|
|
460
|
+
if (fs.existsSync(globalTeamsPath)) return globalTeamsPath;
|
|
461
|
+
const altPath = path.join(globalPrefix, 'node_modules', '@spaces', 'teams');
|
|
462
|
+
if (fs.existsSync(altPath)) return altPath;
|
|
463
|
+
} catch {}
|
|
464
|
+
|
|
465
|
+
return null;
|
|
466
|
+
}
|