starmux 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/CONTRIBUTING.md +1 -1
  2. package/README.md +169 -97
  3. package/SECURITY.md +3 -3
  4. package/dist/src/access-control.js +23 -20
  5. package/dist/src/access-control.js.map +1 -1
  6. package/dist/src/access-dashboard.js +8 -2
  7. package/dist/src/access-dashboard.js.map +1 -1
  8. package/dist/src/cli/instances.js +87 -14
  9. package/dist/src/cli/instances.js.map +1 -1
  10. package/dist/src/cli/mac-mcp-gateway.js +4 -3
  11. package/dist/src/cli/mac-mcp-gateway.js.map +1 -1
  12. package/dist/src/cli/starmux-status.js +122 -0
  13. package/dist/src/cli/starmux-status.js.map +1 -0
  14. package/dist/src/cli/starmux.js +222 -49
  15. package/dist/src/cli/starmux.js.map +1 -1
  16. package/dist/src/deny-dashboard.js +2 -2
  17. package/dist/src/deny-dashboard.js.map +1 -1
  18. package/dist/src/instance-runtime.js +11 -2
  19. package/dist/src/instance-runtime.js.map +1 -1
  20. package/dist/src/instance-store.js +3 -1
  21. package/dist/src/instance-store.js.map +1 -1
  22. package/dist/src/ops-dashboard.js +4 -4
  23. package/dist/src/ops-dashboard.js.map +1 -1
  24. package/dist/src/permissions-dashboard.js +2 -2
  25. package/dist/src/permissions-dashboard.js.map +1 -1
  26. package/dist/src/runtime-paths.js +3 -3
  27. package/dist/src/runtime-paths.js.map +1 -1
  28. package/dist/src/starmux-migration.js +1 -1
  29. package/dist/src/starmux-migration.js.map +1 -1
  30. package/dist/vendor/desktop-commander/LICENSE +21 -0
  31. package/dist/vendor/desktop-commander/dist/bootstrap.js +22 -0
  32. package/dist/vendor/desktop-commander/dist/command-manager.js +246 -0
  33. package/dist/vendor/desktop-commander/dist/config-field-definitions.js +37 -0
  34. package/dist/vendor/desktop-commander/dist/config-manager.js +634 -0
  35. package/dist/vendor/desktop-commander/dist/config-recovery.js +81 -0
  36. package/dist/vendor/desktop-commander/dist/config.js +19 -0
  37. package/dist/vendor/desktop-commander/dist/custom-stdio.js +358 -0
  38. package/dist/vendor/desktop-commander/dist/error-handlers.js +15 -0
  39. package/dist/vendor/desktop-commander/dist/handlers/edit-search-handlers.js +6 -0
  40. package/dist/vendor/desktop-commander/dist/handlers/filesystem-handlers.js +450 -0
  41. package/dist/vendor/desktop-commander/dist/handlers/history-handlers.js +67 -0
  42. package/dist/vendor/desktop-commander/dist/handlers/index.js +7 -0
  43. package/dist/vendor/desktop-commander/dist/handlers/process-handlers.js +15 -0
  44. package/dist/vendor/desktop-commander/dist/handlers/search-answers.js +172 -0
  45. package/dist/vendor/desktop-commander/dist/handlers/search-handlers.js +136 -0
  46. package/dist/vendor/desktop-commander/dist/handlers/terminal-handlers.js +35 -0
  47. package/dist/vendor/desktop-commander/dist/index.js +88 -0
  48. package/dist/vendor/desktop-commander/dist/search-manager.js +1262 -0
  49. package/dist/vendor/desktop-commander/dist/server.js +1414 -0
  50. package/dist/vendor/desktop-commander/dist/terminal-manager.js +757 -0
  51. package/dist/vendor/desktop-commander/dist/tools/config.js +211 -0
  52. package/dist/vendor/desktop-commander/dist/tools/edit.js +455 -0
  53. package/dist/vendor/desktop-commander/dist/tools/feedback.js +10 -0
  54. package/dist/vendor/desktop-commander/dist/tools/filesystem.js +1047 -0
  55. package/dist/vendor/desktop-commander/dist/tools/fuzzySearch.js +74 -0
  56. package/dist/vendor/desktop-commander/dist/tools/fuzzySearchCore.js +125 -0
  57. package/dist/vendor/desktop-commander/dist/tools/improved-process-tools.js +726 -0
  58. package/dist/vendor/desktop-commander/dist/tools/mime-types.js +28 -0
  59. package/dist/vendor/desktop-commander/dist/tools/pdf/extract-images.js +131 -0
  60. package/dist/vendor/desktop-commander/dist/tools/pdf/index.js +4 -0
  61. package/dist/vendor/desktop-commander/dist/tools/pdf/lib/pdf2md.js +78 -0
  62. package/dist/vendor/desktop-commander/dist/tools/pdf/manipulations.js +112 -0
  63. package/dist/vendor/desktop-commander/dist/tools/pdf/markdown.js +30 -0
  64. package/dist/vendor/desktop-commander/dist/tools/pdf/utils.js +45 -0
  65. package/dist/vendor/desktop-commander/dist/tools/process.js +90 -0
  66. package/dist/vendor/desktop-commander/dist/tools/prompts.js +259 -0
  67. package/dist/vendor/desktop-commander/dist/tools/schemas.js +242 -0
  68. package/dist/vendor/desktop-commander/dist/tools/usage.js +24 -0
  69. package/dist/vendor/desktop-commander/dist/types.js +1 -0
  70. package/dist/vendor/desktop-commander/dist/ui/config-editor/config-editor-runtime.js +150 -0
  71. package/dist/vendor/desktop-commander/dist/ui/config-editor/index.html +13 -0
  72. package/dist/vendor/desktop-commander/dist/ui/config-editor/styles.css +587 -0
  73. package/dist/vendor/desktop-commander/dist/ui/contracts.js +57 -0
  74. package/dist/vendor/desktop-commander/dist/ui/file-preview/index.html +16 -0
  75. package/dist/vendor/desktop-commander/dist/ui/file-preview/preview-runtime.js +471 -0
  76. package/dist/vendor/desktop-commander/dist/ui/file-preview/shared/preview-file-types.js +59 -0
  77. package/dist/vendor/desktop-commander/dist/ui/file-preview/styles.css +1631 -0
  78. package/dist/vendor/desktop-commander/dist/ui/resources.js +93 -0
  79. package/dist/vendor/desktop-commander/dist/utils/ab-test.js +122 -0
  80. package/dist/vendor/desktop-commander/dist/utils/atomic-write.js +80 -0
  81. package/dist/vendor/desktop-commander/dist/utils/capture.js +40 -0
  82. package/dist/vendor/desktop-commander/dist/utils/dockerPrompt.js +9 -0
  83. package/dist/vendor/desktop-commander/dist/utils/exit-process.js +31 -0
  84. package/dist/vendor/desktop-commander/dist/utils/feature-flags.js +18 -0
  85. package/dist/vendor/desktop-commander/dist/utils/files/base.js +5 -0
  86. package/dist/vendor/desktop-commander/dist/utils/files/binary.js +65 -0
  87. package/dist/vendor/desktop-commander/dist/utils/files/docx.js +694 -0
  88. package/dist/vendor/desktop-commander/dist/utils/files/excel.js +497 -0
  89. package/dist/vendor/desktop-commander/dist/utils/files/factory.js +168 -0
  90. package/dist/vendor/desktop-commander/dist/utils/files/image.js +89 -0
  91. package/dist/vendor/desktop-commander/dist/utils/files/index.js +14 -0
  92. package/dist/vendor/desktop-commander/dist/utils/files/pdf.js +124 -0
  93. package/dist/vendor/desktop-commander/dist/utils/files/text.js +423 -0
  94. package/dist/vendor/desktop-commander/dist/utils/fuzzySearchLogger.js +126 -0
  95. package/dist/vendor/desktop-commander/dist/utils/internal-facts.js +23 -0
  96. package/dist/vendor/desktop-commander/dist/utils/lazy-package.js +44 -0
  97. package/dist/vendor/desktop-commander/dist/utils/lineEndingHandler.js +77 -0
  98. package/dist/vendor/desktop-commander/dist/utils/logger.js +72 -0
  99. package/dist/vendor/desktop-commander/dist/utils/mcp-ui-ab-test.js +62 -0
  100. package/dist/vendor/desktop-commander/dist/utils/open-browser.js +2 -0
  101. package/dist/vendor/desktop-commander/dist/utils/process-detection.js +260 -0
  102. package/dist/vendor/desktop-commander/dist/utils/process-tree.js +223 -0
  103. package/dist/vendor/desktop-commander/dist/utils/rename.js +74 -0
  104. package/dist/vendor/desktop-commander/dist/utils/ripgrep-resolver.js +69 -0
  105. package/dist/vendor/desktop-commander/dist/utils/shell.js +187 -0
  106. package/dist/vendor/desktop-commander/dist/utils/system-info.js +727 -0
  107. package/dist/vendor/desktop-commander/dist/utils/terminal-timestamps.js +18 -0
  108. package/dist/vendor/desktop-commander/dist/utils/toolHistory.js +309 -0
  109. package/dist/vendor/desktop-commander/dist/utils/trackTools.js +55 -0
  110. package/dist/vendor/desktop-commander/dist/utils/unsupportedParams.js +66 -0
  111. package/dist/vendor/desktop-commander/dist/utils/usageTracker.js +225 -0
  112. package/dist/vendor/desktop-commander/dist/utils/welcome-onboarding.js +2 -0
  113. package/dist/vendor/desktop-commander/dist/utils/withTimeout.js +85 -0
  114. package/dist/vendor/desktop-commander/dist/version.js +1 -0
  115. package/dist/vendor/desktop-commander/package.json +15 -0
  116. package/docs/ACCESS_CONTROL.md +5 -5
  117. package/docs/CLIENTS.md +11 -19
  118. package/docs/CONNECT_CHATGPT.md +4 -6
  119. package/docs/INSTALL.md +9 -5
  120. package/docs/INSTANCES.md +5 -2
  121. package/docs/OAUTH.md +6 -14
  122. package/docs/PLATFORMS.md +4 -4
  123. package/docs/README.md +2 -11
  124. package/docs/REMOTE_SETUP.md +13 -13
  125. package/docs/SECURITY.md +5 -5
  126. package/docs/assets/starmux-architecture.svg +315 -0
  127. package/package.json +14 -2
  128. package/docs/ARCHITECTURE.md +0 -51
  129. package/docs/MIGRATION.md +0 -37
  130. package/docs/RELEASE_STATUS.md +0 -31
  131. package/docs/TYPESCRIPT_MIGRATION.md +0 -56
  132. package/docs/VALIDATION_OAUTH.md +0 -79
  133. package/docs/VALIDATION_TUNNEL.md +0 -39
  134. package/docs/VALIDATION_WORKBUDDY.md +0 -59
  135. package/docs/assets/mcp-connection-route.svg +0 -104
  136. package/docs/assets/mcp-gateway-simple.svg +0 -62
@@ -1 +1 @@
1
- {"version":3,"file":"mac-mcp-gateway.js","sourceRoot":"","sources":["../../../src/cli/mac-mcp-gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,IAAI,QAAQ,EAAC,WAAW,EAAC,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACnG,OAAO,EAAE,SAAS,EAAC,YAAY,EAAC,SAAS,EAAC,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9E,MAAM,aAAa,GAAC,CAAC,CAAC,MAAM,CAAC,EAAC,OAAO,EAAC,CAAC,CAAC,MAAM,EAAE,EAAC,YAAY,EAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EAAC,CAAC,CAAC;AACrF,kFAAkF;AAClF,OAAO,EAAE,MAAM,EAAC,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,IAAI,MAAM,WAAW,CA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AAC,CAAC;AACrB,CAAC","sourcesContent":["import {supportedHost} from \"../platform.js\";\nimport { z } from \"zod\";\nimport { legacyCliEntry as cliEntry,packageRoot,desktopCommanderEntry } from \"../runtime-paths.js\";\nimport { errorCode,errorMessage,isInteger,parseJSON } from \"../validation.js\";\nconst packageSchema=z.object({version:z.string(),dependencies:z.record(z.string())});\n// Minimal, portable local Gateway entrypoint. No implicit public network binding.\nimport { access,readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nconst project=packageRoot;\nconst pkg=packageSchema.parse(parseJSON(await readFile(path.join(project,\"package.json\"),\"utf8\")));\nconst command=process.argv[2]||\"help\";\n\nfunction help(){\n process.stdout.write(`Mac MCP Gateway ${pkg.version}\n\nUsage:\n mac-mcp-gateway instance create NAME --project /absolute/path\n mac-mcp-gateway instance list [--json]\n mac-mcp-gateway instance import FILE --name NAME [--link]\n mac-mcp-gateway instance copy|rename NAME NEW_NAME\n mac-mcp-gateway instance default|archive|restore NAME\n mac-mcp-gateway instance migrate [setup|live] [--confirm]\n mac-mcp-gateway config path|show|edit|validate|diff|apply --instance NAME\n mac-mcp-gateway run|stop|status|doctor|verify|logs --instance NAME\n mac-mcp-gateway status --all --json\n\n mac-mcp-gateway run [--port N] Foreground; Ctrl+C stops; current OS account\n mac-mcp-gateway run --app-parent-pid PID App-owned foreground; stops if GUI parent exits\n mac-mcp-gateway stop Stop the Core at the configured local endpoint\n mac-mcp-gateway status Human-readable health for the configured Core\n mac-mcp-gateway status --json Original structured status for scripts/agents\n mac-mcp-gateway logs [--lines N] Inspect local Gateway logs (owner only)\n mac-mcp-gateway privacy [--all] [--target /absolute/path]\n macOS only: compare terminal and Gateway protected-directory access\n\n mac-mcp-gateway access Show access mode and client credentials\n mac-mcp-gateway access create \"Name\" Create a key (displayed once)\n mac-mcp-gateway access mode api-key Require a key on every MCP request\n mac-mcp-gateway access mode ingress Delegate access control to ingress\n mac-mcp-gateway access revoke ID Revoke one credential immediately\n mac-mcp-gateway access oauth configure --issuer URL --resource URL --client-id ID --subjects SUBJECT\n Discover and save OAuth settings; does not enable auth\n mac-mcp-gateway access oauth doctor Check OAuth discovery and PKCE support\n mac-mcp-gateway access mode oauth Require OAuth on MCP requests\n mac-mcp-gateway access revoke-oauth ID Revoke an OAuth session locally\n mac-mcp-gateway access owner-token Show the local Dashboard management token\n\n mac-mcp-gateway setup Configure local access and connection preference\n mac-mcp-gateway doctor Check saved configuration and Desktop Commander\n mac-mcp-gateway verify Verify the running local MCP endpoint\n\n --profile auto|live|setup Advanced configuration selection only\n run --json Structured startup identity and lifecycle events\n\nConfiguration:\n Saved onboarding settings take precedence over legacy installation settings.\n run always starts the Core shipped with this CLI and displays its build identity.\n\nAdvanced environment-based doctor:\n MAC_MCP_PROJECT_ROOT=/absolute/canonical/project\n\nOptional:\n MAC_MCP_WORKSPACE_MODE=read-only|read-write (default read-only)\n MAC_MCP_PROJECT_PORT=8793 (127.0.0.1 only)\n MAC_MCP_DEV_COMMANDS=presets|trusted-project (default presets)\n MAC_MCP_GIT_MODE=off|review|write|push (default off)\n MAC_MCP_WORKTREE_MODE=off|linked (default off)\n\nIMPORTANT: trusted-project Shell inherits the current OS account's permissions.\nThe Core binds loopback. Configure protected HTTPS or Tunnel for remote access.\nGateway key authentication is optional; access defaults to managed by ingress.\n`);\n}\nasync function doctor(){\n const facts: {event:string;node:string;platform:string;workspaceConfigured:boolean;mode:string;devCommands:string;upstreamVersion:string|null;workspaceValidated?:boolean;workspaceMode?:string;gitMode?:string;worktreeMode?:string;desktopCommanderTools?:number;result?:string;reason?:string}={event:\"GATEWAY_DOCTOR\",node:process.version,platform:process.platform,\n workspaceConfigured:Boolean(process.env.MAC_MCP_PROJECT_ROOT),\n mode:process.env.MAC_MCP_WORKSPACE_MODE||\"read-only\",\n devCommands:process.env.MAC_MCP_DEV_COMMANDS||\"presets\",\n upstreamVersion:pkg.dependencies?.[\"@wonderwhy-er/desktop-commander\"]||null};\n let code=0;\n try{\n const {createProjectPolicy}=await import(\"../project-workspace-policy.js\");\n const {LocalDesktopReadProbe}=await import(\"../local-desktop-read-probe.js\");\n supportedHost();\n if(!facts.workspaceConfigured)throw Error(\"MAC_MCP_PROJECT_ROOT_REQUIRED\");\n const nativeAccessMode=process.env.MAC_MCP_DC_ACCESS_MODE||\"workspace\";\n if(![\"workspace\",\"native\"].includes(nativeAccessMode)||\n (nativeAccessMode===\"native\"&&\n (facts.devCommands!==\"trusted-project\"||facts.mode!==\"read-write\")))\n throw Error(\"NATIVE_ACCESS_REQUIRES_OWNER_TRUSTED_DEVELOPER_PROFILE\");\n const policy=await createProjectPolicy({\n root:process.env.MAC_MCP_PROJECT_ROOT,\n mode:facts.mode,developerCommands:facts.devCommands,\n allowTrustedHomeRoot:nativeAccessMode===\"native\"&&facts.devCommands===\"trusted-project\"\n });\n facts.workspaceValidated=true;\n facts.workspaceMode=policy.mode;\n const desiredPort=Number(process.env.MAC_MCP_PROJECT_PORT||8793);\n if(!isInteger(desiredPort)||desiredPort<0||desiredPort>65535)\n throw Error(\"INVALID_PROJECT_PORT\");\n const gitMode=process.env.MAC_MCP_GIT_MODE||\"off\";\n if(![\"off\",\"review\",\"write\",\"push\"].includes(gitMode))throw Error(\"INVALID_GIT_MODE\");\n facts.gitMode=gitMode;\n const worktreeMode=process.env.MAC_MCP_WORKTREE_MODE||\"off\";\n if(![\"off\",\"linked\"].includes(worktreeMode))throw Error(\"INVALID_WORKTREE_MODE\");\n facts.worktreeMode=worktreeMode;\n await access(desktopCommanderEntry);\n const dc=new LocalDesktopReadProbe({\n writeScope:process.env.MAC_MCP_DC_WRITE_SCOPE||\"unrestricted\"\n });\n try{\n await dc.connect();\n facts.desktopCommanderTools=dc.upstreamCatalog.length;\n if(!dc.upstreamCatalog.some(t=>t.name===\"start_process\"))\n throw Error(\"DESKTOP_COMMANDER_START_PROCESS_MISSING\");\n facts.result=\"PASS\";\n }finally{await dc.close().catch(()=>{});}\n }catch(error){\n facts.result=\"FAIL\";\n facts.reason=String(errorCode(error)||errorMessage(error)||\"UNKNOWN\").slice(0,100);\n code=1;\n }\n // Never include access tokens, project paths, command arguments or private filenames.\n process.stdout.write(JSON.stringify(facts)+\"\\n\");\n process.exitCode=code;\n}\nif(await (await import(\"./instances.js\")).maybeHandleInstances(process.argv.slice(2))){\n // Shared named-instance commands own their complete lifecycle.\n}else if(command===\"setup\"){\n process.argv.splice(2,1);\n await import(\"./setup-wizard.js\");\n}else if(command===\"access\"){\n try{await (await import(\"./access.js\")).accessCommand(process.argv.slice(3));}\n catch(error){process.stderr.write(\"GATEWAY_ACCESS_ERROR \"+errorMessage(error)+\"\\n\");process.exitCode=1;}\n}else if(command===\"verify\"){\n await import(\"./verify-setup.js\");\n}else if(command===\"help\"||command===\"--help\"||command===\"-h\"){\n help();\n}else if(command===\"doctor\"){\n if(process.env.MAC_MCP_PROJECT_ROOT)await doctor();\n else{\n try{\n const {loadSetupConfig,setupRuntimeEnv}=await import(\"../release1-onboarding.js\");\n Object.assign(process.env,setupRuntimeEnv(await loadSetupConfig()));\n await doctor();\n }catch(error){\n if(errorCode(error)===\"ENOENT\")await doctor();\n else process.stdout.write(JSON.stringify({event:\"GATEWAY_DOCTOR\",result:\"FAIL\",\n reason:errorCode(error)||errorMessage(error)})+\"\\n\");\n process.stderr.write(\"Run mac-mcp-gateway setup to configure local access.\\n\");\n process.exitCode=1;\n }\n }\n }else if([\"run\",\"install\",\"start\",\"stop\",\"restart\",\"status\",\"logs\",\"privacy\"].includes(command)){\n try{\n const {parseArgs,operatorCommand}=await import(\"../operator-cli.js\");\n const {options}=parseArgs(process.argv.slice(2));\n const result=await operatorCommand(command,{\n ...options,entry:cliEntry()\n });\n if(result.event===\"GATEWAY_LOGS\")process.stdout.write(result.output);\n else if(result.event===\"GATEWAY_RUN_EXIT\"&&!options.json&&options.appParentPid===undefined)\n process.stdout.write(result.code===0?\" Gateway stopped.\\n\":` Gateway exited with code ${result.code}.\\n`);\n else if(result.event===\"GATEWAY_STATUS\"&&!options.json){\n const {formatGatewayStatus}=await import(\"../gateway-status-format.js\");\n process.stdout.write(formatGatewayStatus(result,{\n version:pkg.version,color:Boolean(process.stdout.isTTY)&&!process.env.NO_COLOR\n }));\n }else process.stdout.write(JSON.stringify(result)+\"\\n\");\n if(result.event===\"GATEWAY_RUN_EXIT\")process.exitCode=result.code;\n }catch(error){\n process.stderr.write(\"GATEWAY_CLI_ERROR \"+\n String(errorCode(error)||errorMessage(error)||\"UNKNOWN\").slice(0,240)+\"\\n\");\n process.exitCode=1;\n }\n}else if(command===\"start-raw\"){\n // Legacy direct entry bypassed global one-Core arbitration. Never allow\n // a public subprocess to start a second ungoverned production Core.\n process.stderr.write(\"LEGACY_DIRECT_BOOTSTRAP_DISABLED_USE_SETUP\\n\");\n process.exitCode=2;\n}else if(command===\"doctor-setup\"||command===\"start-setup\"){\n try{\n const {loadSetupConfig,setupRuntimeEnv}=await import(\"../release1-onboarding.js\");\n if(command===\"start-setup\"){\n const ownerPid=Number(process.env.MAC_MCP_INTERNAL_SETUP_OWNER_PID);\n const runId=process.env.MAC_MCP_INTERNAL_SETUP_RUN_ID;\n const token=process.env.MAC_MCP_INTERNAL_SETUP_TOKEN;\n const internallyLaunched=Boolean(ownerPid&&runId&&token);\n if(!internallyLaunched){\n // Legacy user command is now an alias for supervised CLI Run.\n const {operatorCommand}=await import(\"../operator-cli.js\");\n const result=await operatorCommand(\"run\",{\n profile:\"setup\",entry:cliEntry()\n });\n process.stdout.write(JSON.stringify(result)+\"\\n\");\n if(result.event===\"GATEWAY_RUN_EXIT\")process.exitCode=result.code;\n }else{\n const {verifyInternalSetupWorker}=await import(\"../global-core-control.js\");\n const config=await loadSetupConfig(process.env.MAC_MCP_SETUP_FILE);\n verifyInternalSetupWorker({\n port:config.port,ownerPid,runId,token\n });\n Object.assign(process.env,setupRuntimeEnv(config));\n delete process.env.MAC_MCP_UPSTREAMS_FILE;\n const {runGateway}=await import(\"../dc-workspace-http.js\");\n await runGateway();\n }\n }else{\n const config=await loadSetupConfig(process.env.MAC_MCP_SETUP_FILE);\n Object.assign(process.env,setupRuntimeEnv(config));\n delete process.env.MAC_MCP_UPSTREAMS_FILE;\n await doctor();\n }\n }catch(error){\n process.stderr.write(\"SETUP_PROFILE_INVALID \"+\n String(errorCode(error)||errorMessage(error)||\"UNKNOWN\").slice(0,90)+\"\\n\");\n process.exitCode=1;\n }\n}else{\n process.stderr.write(\"Unknown command. Use --help.\\n\");\n process.exitCode=2;\n}\n"]}
1
+ {"version":3,"file":"mac-mcp-gateway.js","sourceRoot":"","sources":["../../../src/cli/mac-mcp-gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,IAAI,QAAQ,EAAC,WAAW,EAAC,qBAAqB,EAAC,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAC/H,OAAO,EAAE,SAAS,EAAC,YAAY,EAAC,SAAS,EAAC,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9E,MAAM,aAAa,GAAC,CAAC,CAAC,MAAM,CAAC,EAAC,OAAO,EAAC,CAAC,CAAC,MAAM,EAAE,EAAC,YAAY,EAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EAAC,eAAe,EAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAC,CAAC,CAAC;AACrI,kFAAkF;AAClF,OAAO,EAAE,MAAM,EAAC,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,OAAO,GAAC,WAAW,CAAC;AAC1B,MAAM,GAAG,GAAC,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAC,cAAc,CAAC,EAAC,MAAM,C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AAI,CAAC,CAAC;QAC7E,OAAO,CAAC,QAAQ,GAAC,CAAC,CAAC;IACrB,CAAC;AACH,CAAC;KAAI,CAAC;IACJ,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACvD,OAAO,CAAC,QAAQ,GAAC,CAAC,CAAC;AACrB,CAAC","sourcesContent":["import {supportedHost} from \"../platform.js\";\nimport { z } from \"zod\";\nimport { legacyCliEntry as cliEntry,packageRoot,desktopCommanderEntry,desktopCommanderPackageJson } from \"../runtime-paths.js\";\nimport { errorCode,errorMessage,isInteger,parseJSON } from \"../validation.js\";\nconst packageSchema=z.object({version:z.string(),dependencies:z.record(z.string()),devDependencies:z.record(z.string()).optional()});\n// Minimal, portable local Gateway entrypoint. No implicit public network binding.\nimport { access,readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nconst project=packageRoot;\nconst pkg=packageSchema.parse(parseJSON(await readFile(path.join(project,\"package.json\"),\"utf8\")));\nconst command=process.argv[2]||\"help\";\n\nfunction help(){\n process.stdout.write(`Mac MCP Gateway ${pkg.version}\n\nUsage:\n mac-mcp-gateway instance create NAME --project /absolute/path\n mac-mcp-gateway instance list [--json]\n mac-mcp-gateway instance import FILE --name NAME [--link]\n mac-mcp-gateway instance copy|rename NAME NEW_NAME\n mac-mcp-gateway instance default|archive|restore NAME\n mac-mcp-gateway instance migrate [setup|live] [--confirm]\n mac-mcp-gateway config path|show|edit|validate|diff|apply --instance NAME\n mac-mcp-gateway run|stop|status|doctor|verify|logs --instance NAME\n mac-mcp-gateway status --all --json\n\n mac-mcp-gateway run [--port N] Foreground; Ctrl+C stops; current OS account\n mac-mcp-gateway run --app-parent-pid PID App-owned foreground; stops if GUI parent exits\n mac-mcp-gateway stop Stop the Core at the configured local endpoint\n mac-mcp-gateway status Human-readable health for the configured Core\n mac-mcp-gateway status --json Original structured status for scripts/agents\n mac-mcp-gateway logs [--lines N] Inspect local Gateway logs (owner only)\n mac-mcp-gateway privacy [--all] [--target /absolute/path]\n macOS only: compare terminal and Gateway protected-directory access\n\n mac-mcp-gateway access Show access mode and client credentials\n mac-mcp-gateway access create \"Name\" Create a key (displayed once)\n mac-mcp-gateway access mode api-key Require a key on every MCP request\n mac-mcp-gateway access mode ingress Delegate access control to ingress\n mac-mcp-gateway access revoke ID Revoke one credential immediately\n mac-mcp-gateway access oauth configure --issuer URL --resource URL --client-id ID --subjects SUBJECT\n Discover and save OAuth settings; does not enable auth\n mac-mcp-gateway access oauth doctor Check OAuth discovery and PKCE support\n mac-mcp-gateway access mode oauth Require OAuth on MCP requests\n mac-mcp-gateway access revoke-oauth ID Revoke an OAuth session locally\n mac-mcp-gateway access owner-token Show the local Dashboard management token\n\n mac-mcp-gateway setup Configure local access and connection preference\n mac-mcp-gateway doctor Check saved configuration and Desktop Commander\n mac-mcp-gateway verify Verify the running local MCP endpoint\n\n --profile auto|live|setup Advanced configuration selection only\n run --json Structured startup identity and lifecycle events\n\nConfiguration:\n Saved onboarding settings take precedence over legacy installation settings.\n run always starts the Core shipped with this CLI and displays its build identity.\n\nAdvanced environment-based doctor:\n MAC_MCP_PROJECT_ROOT=/absolute/canonical/project\n\nOptional:\n MAC_MCP_WORKSPACE_MODE=read-only|read-write (default read-only)\n MAC_MCP_PROJECT_PORT=8793 (127.0.0.1 only)\n MAC_MCP_DEV_COMMANDS=presets|trusted-project (default presets)\n MAC_MCP_GIT_MODE=off|review|write|push (default off)\n MAC_MCP_WORKTREE_MODE=off|linked (default off)\n\nIMPORTANT: trusted-project Shell inherits the current OS account's permissions.\nThe Core binds loopback. Configure protected HTTPS or Tunnel for remote access.\nGateway key authentication is optional; access defaults to managed by ingress.\n`);\n}\nasync function doctor(){\n const vendorPkg=await readFile(desktopCommanderPackageJson,\"utf8\").then(t=>z.object({version:z.string()}).parse(parseJSON(t))).catch(()=>null);\n const facts: {event:string;node:string;platform:string;workspaceConfigured:boolean;mode:string;devCommands:string;upstreamVersion:string|null;workspaceValidated?:boolean;workspaceMode?:string;gitMode?:string;worktreeMode?:string;desktopCommanderTools?:number;result?:string;reason?:string}={event:\"GATEWAY_DOCTOR\",node:process.version,platform:process.platform,\n workspaceConfigured:Boolean(process.env.MAC_MCP_PROJECT_ROOT),\n mode:process.env.MAC_MCP_WORKSPACE_MODE||\"read-only\",\n devCommands:process.env.MAC_MCP_DEV_COMMANDS||\"presets\",\n upstreamVersion:vendorPkg?.version||pkg.dependencies?.[\"@wonderwhy-er/desktop-commander\"]||pkg.devDependencies?.[\"@wonderwhy-er/desktop-commander\"]||null};\n let code=0;\n try{\n const {createProjectPolicy}=await import(\"../project-workspace-policy.js\");\n const {LocalDesktopReadProbe}=await import(\"../local-desktop-read-probe.js\");\n supportedHost();\n if(!facts.workspaceConfigured)throw Error(\"MAC_MCP_PROJECT_ROOT_REQUIRED\");\n const nativeAccessMode=process.env.MAC_MCP_DC_ACCESS_MODE||\"workspace\";\n if(![\"workspace\",\"native\"].includes(nativeAccessMode)||\n (nativeAccessMode===\"native\"&&\n (facts.devCommands!==\"trusted-project\"||facts.mode!==\"read-write\")))\n throw Error(\"NATIVE_ACCESS_REQUIRES_OWNER_TRUSTED_DEVELOPER_PROFILE\");\n const policy=await createProjectPolicy({\n root:process.env.MAC_MCP_PROJECT_ROOT,\n mode:facts.mode,developerCommands:facts.devCommands,\n allowTrustedHomeRoot:nativeAccessMode===\"native\"&&facts.devCommands===\"trusted-project\"\n });\n facts.workspaceValidated=true;\n facts.workspaceMode=policy.mode;\n const desiredPort=Number(process.env.MAC_MCP_PROJECT_PORT||8793);\n if(!isInteger(desiredPort)||desiredPort<0||desiredPort>65535)\n throw Error(\"INVALID_PROJECT_PORT\");\n const gitMode=process.env.MAC_MCP_GIT_MODE||\"off\";\n if(![\"off\",\"review\",\"write\",\"push\"].includes(gitMode))throw Error(\"INVALID_GIT_MODE\");\n facts.gitMode=gitMode;\n const worktreeMode=process.env.MAC_MCP_WORKTREE_MODE||\"off\";\n if(![\"off\",\"linked\"].includes(worktreeMode))throw Error(\"INVALID_WORKTREE_MODE\");\n facts.worktreeMode=worktreeMode;\n await access(desktopCommanderEntry);\n const dc=new LocalDesktopReadProbe({\n writeScope:process.env.MAC_MCP_DC_WRITE_SCOPE||\"unrestricted\"\n });\n try{\n await dc.connect();\n facts.desktopCommanderTools=dc.upstreamCatalog.length;\n if(!dc.upstreamCatalog.some(t=>t.name===\"start_process\"))\n throw Error(\"DESKTOP_COMMANDER_START_PROCESS_MISSING\");\n facts.result=\"PASS\";\n }finally{await dc.close().catch(()=>{});}\n }catch(error){\n facts.result=\"FAIL\";\n facts.reason=String(errorCode(error)||errorMessage(error)||\"UNKNOWN\").slice(0,100);\n code=1;\n }\n // Never include access tokens, project paths, command arguments or private filenames.\n process.stdout.write(JSON.stringify(facts)+\"\\n\");\n process.exitCode=code;\n}\nif(await (await import(\"./instances.js\")).maybeHandleInstances(process.argv.slice(2))){\n // Shared named-instance commands own their complete lifecycle.\n}else if(command===\"setup\"){\n process.argv.splice(2,1);\n await import(\"./setup-wizard.js\");\n}else if(command===\"access\"){\n try{await (await import(\"./access.js\")).accessCommand(process.argv.slice(3));}\n catch(error){process.stderr.write(\"GATEWAY_ACCESS_ERROR \"+errorMessage(error)+\"\\n\");process.exitCode=1;}\n}else if(command===\"verify\"){\n await import(\"./verify-setup.js\");\n}else if(command===\"help\"||command===\"--help\"||command===\"-h\"){\n help();\n}else if(command===\"doctor\"){\n if(process.env.MAC_MCP_PROJECT_ROOT)await doctor();\n else{\n try{\n const {loadSetupConfig,setupRuntimeEnv}=await import(\"../release1-onboarding.js\");\n Object.assign(process.env,setupRuntimeEnv(await loadSetupConfig()));\n await doctor();\n }catch(error){\n if(errorCode(error)===\"ENOENT\")await doctor();\n else process.stdout.write(JSON.stringify({event:\"GATEWAY_DOCTOR\",result:\"FAIL\",\n reason:errorCode(error)||errorMessage(error)})+\"\\n\");\n process.stderr.write(\"Run mac-mcp-gateway setup to configure local access.\\n\");\n process.exitCode=1;\n }\n }\n }else if([\"run\",\"install\",\"start\",\"stop\",\"restart\",\"status\",\"logs\",\"privacy\"].includes(command)){\n try{\n const {parseArgs,operatorCommand}=await import(\"../operator-cli.js\");\n const {options}=parseArgs(process.argv.slice(2));\n const result=await operatorCommand(command,{\n ...options,entry:cliEntry()\n });\n if(result.event===\"GATEWAY_LOGS\")process.stdout.write(result.output);\n else if(result.event===\"GATEWAY_RUN_EXIT\"&&!options.json&&options.appParentPid===undefined)\n process.stdout.write(result.code===0?\" Gateway stopped.\\n\":` Gateway exited with code ${result.code}.\\n`);\n else if(result.event===\"GATEWAY_STATUS\"&&!options.json){\n const {formatGatewayStatus}=await import(\"../gateway-status-format.js\");\n process.stdout.write(formatGatewayStatus(result,{\n version:pkg.version,color:Boolean(process.stdout.isTTY)&&!process.env.NO_COLOR\n }));\n }else process.stdout.write(JSON.stringify(result)+\"\\n\");\n if(result.event===\"GATEWAY_RUN_EXIT\")process.exitCode=result.code;\n }catch(error){\n process.stderr.write(\"GATEWAY_CLI_ERROR \"+\n String(errorCode(error)||errorMessage(error)||\"UNKNOWN\").slice(0,240)+\"\\n\");\n process.exitCode=1;\n }\n}else if(command===\"start-raw\"){\n // Legacy direct entry bypassed global one-Core arbitration. Never allow\n // a public subprocess to start a second ungoverned production Core.\n process.stderr.write(\"LEGACY_DIRECT_BOOTSTRAP_DISABLED_USE_SETUP\\n\");\n process.exitCode=2;\n}else if(command===\"doctor-setup\"||command===\"start-setup\"){\n try{\n const {loadSetupConfig,setupRuntimeEnv}=await import(\"../release1-onboarding.js\");\n if(command===\"start-setup\"){\n const ownerPid=Number(process.env.MAC_MCP_INTERNAL_SETUP_OWNER_PID);\n const runId=process.env.MAC_MCP_INTERNAL_SETUP_RUN_ID;\n const token=process.env.MAC_MCP_INTERNAL_SETUP_TOKEN;\n const internallyLaunched=Boolean(ownerPid&&runId&&token);\n if(!internallyLaunched){\n // Legacy user command is now an alias for supervised CLI Run.\n const {operatorCommand}=await import(\"../operator-cli.js\");\n const result=await operatorCommand(\"run\",{\n profile:\"setup\",entry:cliEntry()\n });\n process.stdout.write(JSON.stringify(result)+\"\\n\");\n if(result.event===\"GATEWAY_RUN_EXIT\")process.exitCode=result.code;\n }else{\n const {verifyInternalSetupWorker}=await import(\"../global-core-control.js\");\n const config=await loadSetupConfig(process.env.MAC_MCP_SETUP_FILE);\n verifyInternalSetupWorker({\n port:config.port,ownerPid,runId,token\n });\n Object.assign(process.env,setupRuntimeEnv(config));\n delete process.env.MAC_MCP_UPSTREAMS_FILE;\n const {runGateway}=await import(\"../dc-workspace-http.js\");\n await runGateway();\n }\n }else{\n const config=await loadSetupConfig(process.env.MAC_MCP_SETUP_FILE);\n Object.assign(process.env,setupRuntimeEnv(config));\n delete process.env.MAC_MCP_UPSTREAMS_FILE;\n await doctor();\n }\n }catch(error){\n process.stderr.write(\"SETUP_PROFILE_INVALID \"+\n String(errorCode(error)||errorMessage(error)||\"UNKNOWN\").slice(0,90)+\"\\n\");\n process.exitCode=1;\n }\n}else{\n process.stderr.write(\"Unknown command. Use --help.\\n\");\n process.exitCode=2;\n}\n"]}
@@ -0,0 +1,122 @@
1
+ import { createAccessControl } from '../access-control.js';
2
+ import { exists, instancePaths } from '../instance-store.js';
3
+ import { shellQuote } from '../platform.js';
4
+ async function authentication(instance, status) {
5
+ const file = instancePaths(instance).access;
6
+ try {
7
+ const state = await (await createAccessControl(file, { initialize: false })).snapshot();
8
+ if (status.phase === 'running' && status.health === 'ok' && status.accessMode !== state.mode) {
9
+ return { mode: null, activeKeys: 0, oauth: null, problem: 'Authentication changed while checking. Run status again.' };
10
+ }
11
+ const incomplete = status.phase !== 'running' && instance.requiredAccess !== 'ingress' && state.mode !== instance.requiredAccess;
12
+ return { mode: state.mode, activeKeys: state.credentials.filter(c => c.status === 'active').length,
13
+ oauth: state.oauth ? { issuer: state.oauth.issuer, resource: state.oauth.resource, clientId: state.oauth.clientId, scope: state.oauth.scope, tokenAuth: state.oauth.tokenEndpointAuthMethod } : null,
14
+ problem: incomplete ? `This instance requires ${instance.requiredAccess} authentication before starting.` : null };
15
+ }
16
+ catch (error) {
17
+ // A new, never-started instance has an ingress default, but a lost store must
18
+ // never be presented as an intentional switch to unauthenticated access.
19
+ if (error.code === 'ENOENT' && status.phase === 'stopped' && instance.requiredAccess === 'ingress' && !await exists(file + '.initialized')) {
20
+ return { mode: 'ingress', activeKeys: 0, oauth: null, problem: null };
21
+ }
22
+ return { mode: null, activeKeys: 0, oauth: null, problem: 'Authentication settings are unavailable. Inspect them with the Auth command below.' };
23
+ }
24
+ }
25
+ export async function formatStarmuxStatus(instance, status, config, options = {}) {
26
+ const auth = await authentication(instance, status);
27
+ // Omit `-i default` for the default instance to keep everyday single-instance output clean.
28
+ const omitSelector = options.isDefault === true && instance.name === 'default';
29
+ const selector = /^[A-Za-z0-9_.-]+$/.test(instance.name) && !instance.name.startsWith('-') ? instance.name : shellQuote(instance.name);
30
+ const flag = omitSelector ? '' : (instance.name.startsWith('-') ? ` --instance=${selector}` : ` -i ${selector}`);
31
+ const command = (action) => `starmux ${action}${flag}`;
32
+ const ready = status.phase === 'running' && status.health === 'ok';
33
+ const hasProblem = Boolean(status.configProblem || status.runtimeProblem || auth.problem);
34
+ const indicator = hasProblem ? '!' : ready ? '●' : status.phase === 'running' ? '◐' : '○';
35
+ const labels = {
36
+ ingress: 'None (no token required)',
37
+ 'api-key': `API key (Bearer token; ${auth.activeKeys} active ${auth.activeKeys === 1 ? 'key' : 'keys'})`,
38
+ oauth: 'OAuth (browser sign-in)'
39
+ };
40
+ const saved = status.phase === 'running' ? ' (saved; live state unavailable)' : ' (saved for next start)';
41
+ const row = (label, value) => ' ' + label.padEnd(16) + value;
42
+ const codingCmd = command('up --code');
43
+ const mode = !config
44
+ ? 'Unavailable'
45
+ : config.accessRole === 'trusted'
46
+ ? (config.writeScope === 'home-only' ? 'Coding (Home sandbox · edits, shell & git)' : 'Coding (OS account · edits, shell & git)')
47
+ : config.mode === 'read-write'
48
+ ? 'File writes (restricted)'
49
+ : `Read-only (run '${codingCmd}' to enable edits & shell)`;
50
+ const runtime = status.executionMode === 'background'
51
+ ? 'Background · continues after this terminal closes'
52
+ : status.executionMode === 'foreground-owned'
53
+ ? (status.runtime?.launcher === 'app' ? 'App-owned · stops when the app closes' : 'Foreground · Ctrl+C stops this instance')
54
+ : 'Stopped';
55
+ const title = omitSelector
56
+ ? `${indicator} Starmux is ${status.phase}`
57
+ : `${indicator} Starmux is ${status.phase} (instance: ${instance.name})`;
58
+ const lines = ['', title];
59
+ if (ready && status.port) {
60
+ lines.push(row('Listen', `http://127.0.0.1:${status.port}/mcp (this computer only)`));
61
+ }
62
+ lines.push(row('Workspace', config?.projectRoot ?? 'Unavailable'), row('Mode', mode), row('Auth', auth.mode ? labels[auth.mode] + (ready ? '' : saved) : 'Unavailable'), row('Runtime', runtime));
63
+ if (ready && status.port && auth.mode === 'oauth' && auth.oauth) {
64
+ lines.push(row('Client URL', auth.oauth.resource), row('Issuer', auth.oauth.issuer));
65
+ }
66
+ if (status.configProblem || status.runtimeProblem)
67
+ lines.push(row('Problem', status.configProblem ?? status.runtimeProblem));
68
+ if (auth.problem)
69
+ lines.push(row('Auth issue', auth.problem));
70
+ const keyCommand = command('auth key "My AI Client"');
71
+ if (ready && !auth.problem) {
72
+ lines.push('', 'Connect an AI client (MCP settings)');
73
+ lines.push(row('Transport', 'Streamable HTTP'));
74
+ if (auth.mode === 'ingress') {
75
+ lines.push(row('URL (Local)', `http://127.0.0.1:${status.port}/mcp (AI client on this computer)`), row('URL (Remote)', `https://<your-domain-or-tunnel>/mcp (via protected HTTPS proxy or tunnel -> 127.0.0.1:${status.port})`), row('Authentication', `None (optional Bearer API key: ${keyCommand})`));
76
+ }
77
+ else if (auth.mode === 'api-key') {
78
+ lines.push(row('URL (Local)', `http://127.0.0.1:${status.port}/mcp (AI client on this computer)`), row('URL (Remote)', `https://<your-domain-or-tunnel>/mcp (via protected HTTPS proxy or tunnel -> 127.0.0.1:${status.port})`), row('Authentication', `Bearer API key (${auth.activeKeys} active ${auth.activeKeys === 1 ? 'key' : 'keys'})`), row('Header', 'Authorization: Bearer <YOUR_API_KEY>'));
79
+ if (!auth.activeKeys) {
80
+ lines.push(row('Create key', `${keyCommand} (no active keys; required before connecting)`));
81
+ }
82
+ }
83
+ else if (auth.mode === 'oauth' && auth.oauth) {
84
+ lines.push(row('URL (Remote)', auth.oauth.resource), row('Authentication', 'OAuth (browser sign-in)'), row('Issuer', auth.oauth.issuer), row('Client ID', `${auth.oauth.clientId} (Scope: ${auth.oauth.scope} · Token auth: ${auth.oauth.tokenAuth})`));
85
+ }
86
+ }
87
+ lines.push('', 'Commands');
88
+ if (auth.problem) {
89
+ lines.push(row('Check auth', command('auth')));
90
+ }
91
+ else if (!ready) {
92
+ if (status.phase === 'stopped' && !status.configProblem && !status.runtimeProblem) {
93
+ if (auth.mode === 'api-key' && !auth.activeKeys)
94
+ lines.push(row('Create key', keyCommand));
95
+ lines.push(row('Start', command('up')), row('Start coding', codingCmd));
96
+ }
97
+ else {
98
+ lines.push(row('Diagnose', command('doctor')));
99
+ }
100
+ }
101
+ else {
102
+ if (auth.mode === 'api-key' && auth.activeKeys) {
103
+ lines.push(row('Verify', `STARMUX_TOKEN=<key> ${command('verify')}`), row('New API key', keyCommand));
104
+ }
105
+ else if (auth.mode === 'oauth') {
106
+ lines.push(row('Check OAuth', command('auth oauth doctor')), row('Verify', command('verify')));
107
+ }
108
+ else {
109
+ lines.push(row('Verify', command('verify')));
110
+ }
111
+ }
112
+ if (status.configState === 'pending')
113
+ lines.push(row('Apply config', command('config apply')));
114
+ lines.push(row('Auth & keys', command('auth')));
115
+ if (ready)
116
+ lines.push(row('Dashboard', `${command('dashboard')} (view & copy settings in browser)`));
117
+ lines.push(row('Logs', command('logs -f')));
118
+ if (status.phase === 'running')
119
+ lines.push(row('Stop', command('down')));
120
+ return lines.join('\n') + '\n';
121
+ }
122
+ //# sourceMappingURL=starmux-status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"starmux-status.js","sourceRoot":"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ACR,GAAG,CAAC,aAAa,EAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,EAC/C,GAAG,CAAC,QAAQ,EAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAChC,CAAC;QACJ,CAAC;aAAI,CAAC;YACJ,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IACD,IAAG,MAAM,CAAC,WAAW,KAAG,SAAS;QAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,EAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAC1F,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,EAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC/C,IAAG,KAAK;QAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAC,GAAG,OAAO,CAAC,WAAW,CAAC,qCAAqC,CAAC,CAAC,CAAC;IACnG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAC3C,IAAG,MAAM,CAAC,KAAK,KAAG,SAAS;QAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACpE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAC,IAAI,CAAC;AAC/B,CAAC","sourcesContent":["import {createAccessControl} from '../access-control.js';\nimport type {instanceStatus} from '../instance-runtime.js';\nimport {exists,instancePaths,type Instance,type InstanceConfig} from '../instance-store.js';\nimport {shellQuote} from '../platform.js';\n\ntype Status=Awaited<ReturnType<typeof instanceStatus>>;\ntype AuthMode='ingress'|'api-key'|'oauth';\ntype OAuthSummary={issuer:string;resource:string;clientId:string;scope:string;tokenAuth:string};\ntype AuthSummary={mode:AuthMode|null;activeKeys:number;oauth:OAuthSummary|null;problem:string|null};\n\nasync function authentication(instance:Instance,status:Status):Promise<AuthSummary>{\n const file=instancePaths(instance).access;\n try{\n const state=await (await createAccessControl(file,{initialize:false})).snapshot();\n if(status.phase==='running'&&status.health==='ok'&&status.accessMode!==state.mode){\n return {mode:null,activeKeys:0,oauth:null,problem:'Authentication changed while checking. Run status again.'};\n }\n const incomplete=status.phase!=='running'&&instance.requiredAccess!=='ingress'&&state.mode!==instance.requiredAccess;\n return {mode:state.mode,activeKeys:state.credentials.filter(c=>c.status==='active').length,\n oauth:state.oauth?{issuer:state.oauth.issuer,resource:state.oauth.resource,clientId:state.oauth.clientId,scope:state.oauth.scope,tokenAuth:state.oauth.tokenEndpointAuthMethod}:null,\n problem:incomplete?`This instance requires ${instance.requiredAccess} authentication before starting.`:null};\n }catch(error){\n // A new, never-started instance has an ingress default, but a lost store must\n // never be presented as an intentional switch to unauthenticated access.\n if((error as NodeJS.ErrnoException).code==='ENOENT'&&status.phase==='stopped'&&instance.requiredAccess==='ingress'&&!await exists(file+'.initialized')){\n return {mode:'ingress',activeKeys:0,oauth:null,problem:null};\n }\n return {mode:null,activeKeys:0,oauth:null,problem:'Authentication settings are unavailable. Inspect them with the Auth command below.'};\n }\n}\n\nexport async function formatStarmuxStatus(instance:Instance,status:Status,config:InstanceConfig|undefined,options:{isDefault?:boolean}={}){\n const auth=await authentication(instance,status);\n // Omit `-i default` for the default instance to keep everyday single-instance output clean.\n const omitSelector=options.isDefault===true&&instance.name==='default';\n const selector=/^[A-Za-z0-9_.-]+$/.test(instance.name)&&!instance.name.startsWith('-')?instance.name:shellQuote(instance.name);\n const flag=omitSelector?'':(instance.name.startsWith('-')?` --instance=${selector}`:` -i ${selector}`);\n const command=(action:string)=>`starmux ${action}${flag}`;\n const ready=status.phase==='running'&&status.health==='ok';\n const hasProblem=Boolean(status.configProblem||status.runtimeProblem||auth.problem);\n const indicator=hasProblem?'!':ready?'●':status.phase==='running'?'◐':'○';\n const labels={\n ingress:'None (no token required)',\n 'api-key':`API key (Bearer token; ${auth.activeKeys} active ${auth.activeKeys===1?'key':'keys'})`,\n oauth:'OAuth (browser sign-in)'\n };\n const saved=status.phase==='running'?' (saved; live state unavailable)':' (saved for next start)';\n const row=(label:string,value:string)=>' '+label.padEnd(16)+value;\n const codingCmd=command('up --code');\n const mode=!config\n ?'Unavailable'\n :config.accessRole==='trusted'\n ?(config.writeScope==='home-only'?'Coding (Home sandbox · edits, shell & git)':'Coding (OS account · edits, shell & git)')\n :config.mode==='read-write'\n ?'File writes (restricted)'\n :`Read-only (run '${codingCmd}' to enable edits & shell)`;\n const runtime=status.executionMode==='background'\n ?'Background · continues after this terminal closes'\n :status.executionMode==='foreground-owned'\n ?(status.runtime?.launcher==='app'?'App-owned · stops when the app closes':'Foreground · Ctrl+C stops this instance')\n :'Stopped';\n const title=omitSelector\n ?`${indicator} Starmux is ${status.phase}`\n :`${indicator} Starmux is ${status.phase} (instance: ${instance.name})`;\n const lines=['',title];\n if(ready&&status.port){\n lines.push(row('Listen',`http://127.0.0.1:${status.port}/mcp (this computer only)`));\n }\n lines.push(\n row('Workspace',config?.projectRoot??'Unavailable'),\n row('Mode',mode),\n row('Auth',auth.mode?labels[auth.mode]+(ready?'':saved):'Unavailable'),\n row('Runtime',runtime)\n );\n if(ready&&status.port&&auth.mode==='oauth'&&auth.oauth){\n lines.push(row('Client URL',auth.oauth.resource),row('Issuer',auth.oauth.issuer));\n }\n if(status.configProblem||status.runtimeProblem)lines.push(row('Problem',status.configProblem??status.runtimeProblem!));\n if(auth.problem)lines.push(row('Auth issue',auth.problem));\n\n const keyCommand=command('auth key \"My AI Client\"');\n if(ready&&!auth.problem){\n lines.push('','Connect an AI client (MCP settings)');\n lines.push(row('Transport','Streamable HTTP'));\n if(auth.mode==='ingress'){\n lines.push(\n row('URL (Local)',`http://127.0.0.1:${status.port}/mcp (AI client on this computer)`),\n row('URL (Remote)',`https://<your-domain-or-tunnel>/mcp (via protected HTTPS proxy or tunnel -> 127.0.0.1:${status.port})`),\n row('Authentication',`None (optional Bearer API key: ${keyCommand})`)\n );\n }else if(auth.mode==='api-key'){\n lines.push(\n row('URL (Local)',`http://127.0.0.1:${status.port}/mcp (AI client on this computer)`),\n row('URL (Remote)',`https://<your-domain-or-tunnel>/mcp (via protected HTTPS proxy or tunnel -> 127.0.0.1:${status.port})`),\n row('Authentication',`Bearer API key (${auth.activeKeys} active ${auth.activeKeys===1?'key':'keys'})`),\n row('Header','Authorization: Bearer <YOUR_API_KEY>')\n );\n if(!auth.activeKeys){\n lines.push(row('Create key',`${keyCommand} (no active keys; required before connecting)`));\n }\n }else if(auth.mode==='oauth'&&auth.oauth){\n lines.push(\n row('URL (Remote)',auth.oauth.resource),\n row('Authentication','OAuth (browser sign-in)'),\n row('Issuer',auth.oauth.issuer),\n row('Client ID',`${auth.oauth.clientId} (Scope: ${auth.oauth.scope} · Token auth: ${auth.oauth.tokenAuth})`)\n );\n }\n }\n\n lines.push('','Commands');\n if(auth.problem){\n lines.push(row('Check auth',command('auth')));\n }else if(!ready){\n if(status.phase==='stopped'&&!status.configProblem&&!status.runtimeProblem){\n if(auth.mode==='api-key'&&!auth.activeKeys)lines.push(row('Create key',keyCommand));\n lines.push(row('Start',command('up')),row('Start coding',codingCmd));\n }else{\n lines.push(row('Diagnose',command('doctor')));\n }\n }else{\n if(auth.mode==='api-key'&&auth.activeKeys){\n lines.push(\n row('Verify',`STARMUX_TOKEN=<key> ${command('verify')}`),\n row('New API key',keyCommand)\n );\n }else if(auth.mode==='oauth'){\n lines.push(\n row('Check OAuth',command('auth oauth doctor')),\n row('Verify',command('verify'))\n );\n }else{\n lines.push(row('Verify',command('verify')));\n }\n }\n if(status.configState==='pending')lines.push(row('Apply config',command('config apply')));\n lines.push(row('Auth & keys',command('auth')));\n if(ready)lines.push(row('Dashboard',`${command('dashboard')} (view & copy settings in browser)`));\n lines.push(row('Logs',command('logs -f')));\n if(status.phase==='running')lines.push(row('Stop',command('down')));\n return lines.join('\\n')+'\\n';\n}\n"]}