crewx 0.8.0-rc.9 → 0.8.0-rc.91
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/README.md +197 -229
- package/bin/crewx-lib.js +108 -0
- package/bin/crewx-ui.js +83 -0
- package/bin/crewx.js +144 -3
- package/bin/package.json +1 -0
- package/dist/assets/MarketPage-Cvo8aVQt.js +31 -0
- package/dist/assets/PromptTab-ritoI9hm.js +37 -0
- package/dist/assets/_baseUniq-D-vYMu09.js +1 -0
- package/dist/assets/arc-BYanzRKX.js +1 -0
- package/dist/assets/architectureDiagram-Q4EWVU46-DiKRGwoM.js +36 -0
- package/dist/assets/blockDiagram-DXYQGD6D-BAlFcSgI.js +132 -0
- package/dist/assets/c4Diagram-AHTNJAMY-C8KLArMt.js +10 -0
- package/dist/assets/channel-0n1XK9nN.js +1 -0
- package/dist/assets/chatgpt-logo-dark.svg +15 -0
- package/dist/assets/chatgpt-logo.svg +15 -0
- package/dist/assets/chunk-4BX2VUAB-Dkx0jWDY.js +1 -0
- package/dist/assets/chunk-4TB4RGXK-_fW5ld1w.js +206 -0
- package/dist/assets/chunk-55IACEB6-kRhiL-bc.js +1 -0
- package/dist/assets/chunk-EDXVE4YY-DTha-Dl2.js +1 -0
- package/dist/assets/chunk-FMBD7UC4-CHl2rQqk.js +15 -0
- package/dist/assets/chunk-OYMX7WX6-HcHTeBom.js +231 -0
- package/dist/assets/chunk-QZHKN3VN-DLIaU0x1.js +1 -0
- package/dist/assets/chunk-YZCP3GAM-DAq_xC49.js +1 -0
- package/dist/assets/classDiagram-6PBFFD2Q-BAGFUSDM.js +1 -0
- package/dist/assets/classDiagram-v2-HSJHXN6E-BAGFUSDM.js +1 -0
- package/dist/assets/claude-logo-dark.svg +1 -0
- package/dist/assets/claude-logo.svg +1 -0
- package/dist/assets/clone-CtKj6sEW.js +1 -0
- package/dist/assets/cose-bilkent-S5V4N54A-Bumhm_n2.js +1 -0
- package/dist/assets/crewx-logo.png +0 -0
- package/dist/assets/cytoscape.esm-BiciSPf8.js +331 -0
- package/dist/assets/dagre-KV5264BT-CcQdJ_HT.js +4 -0
- package/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/dist/assets/diagram-5BDNPKRD-BRzhnTUO.js +10 -0
- package/dist/assets/diagram-G4DWMVQ6-DO2a0QyN.js +24 -0
- package/dist/assets/diagram-MMDJMWI5-8mzuGbGW.js +43 -0
- package/dist/assets/diagram-TYMM5635-BEMGFn90.js +24 -0
- package/dist/assets/erDiagram-SMLLAGMA-BQN5yqII.js +85 -0
- package/dist/assets/flowDiagram-DWJPFMVM-D4htmWZR.js +162 -0
- package/dist/assets/ganttDiagram-T4ZO3ILL-Dbu5yCGU.js +292 -0
- package/dist/assets/gemini-logo.svg +1 -0
- package/dist/assets/gitGraphDiagram-UUTBAWPF-CLEFY34L.js +106 -0
- package/dist/assets/github-copilot-logo-dark.svg +1 -0
- package/dist/assets/github-copilot-logo.svg +1 -0
- package/dist/assets/graph-BtAIaAZI.js +1 -0
- package/dist/assets/infoDiagram-42DDH7IO-CgjmqOx2.js +2 -0
- package/dist/assets/init-Gi6I4Gst.js +1 -0
- package/dist/assets/ishikawaDiagram-UXIWVN3A-CHYdITxe.js +70 -0
- package/dist/assets/journeyDiagram-VCZTEJTY-BBCOwqzV.js +139 -0
- package/dist/assets/kanban-definition-6JOO6SKY-Cg8Aus7V.js +89 -0
- package/dist/assets/katex-DkKDou_j.js +257 -0
- package/dist/assets/layout-CFl0_GxZ.js +1 -0
- package/dist/assets/linear-CkV62jWx.js +1 -0
- package/dist/assets/main-CmP-VosD.css +10 -0
- package/dist/assets/main-CqrnRrwT.js +1166 -0
- package/dist/assets/min-BdrLldJH.js +1 -0
- package/dist/assets/mindmap-definition-QFDTVHPH-jKsyKX-1.js +96 -0
- package/dist/assets/ordinal-Cboi1Yqb.js +1 -0
- package/dist/assets/pieDiagram-DEJITSTG-DggmHuIl.js +30 -0
- package/dist/assets/quadrantDiagram-34T5L4WZ-DVeG40E4.js +7 -0
- package/dist/assets/requirementDiagram-MS252O5E-D0ISCRPS.js +84 -0
- package/dist/assets/sankeyDiagram-XADWPNL6-BFaXlzcA.js +10 -0
- package/dist/assets/sequenceDiagram-FGHM5R23-B0ATS6Us.js +157 -0
- package/dist/assets/stateDiagram-FHFEXIEX-Dzetzj7w.js +1 -0
- package/dist/assets/stateDiagram-v2-QKLJ7IA2-CpR-vCrX.js +1 -0
- package/dist/assets/timeline-definition-GMOUNBTQ-gxk5Cthq.js +120 -0
- package/dist/assets/vennDiagram-DHZGUBPP-DuzISLu6.js +34 -0
- package/dist/assets/wardley-RL74JXVD-DIsZOdLy.js +162 -0
- package/dist/assets/wardleyDiagram-NUSXRM2D-ZOHcpxVD.js +20 -0
- package/dist/assets/xychartDiagram-5P7HB3ND-HGeoIY5m.js +7 -0
- package/dist/favicon.ico +0 -0
- package/dist/index.html +13 -0
- package/dist-electron/main.js +194 -0
- package/dist-electron/overlay.js +129 -0
- package/dist-electron/package.json +1 -0
- package/dist-electron/preload.js +12 -0
- package/dist-server/adapters/adapter.module.js +35 -0
- package/dist-server/adapters/adapter.service.js +79 -0
- package/dist-server/adapters/http-router.service.js +91 -0
- package/dist-server/app.module.js +85 -0
- package/dist-server/bootstrap/crewx-server.js +32 -0
- package/dist-server/common/decorators/project.decorator.js +21 -0
- package/dist-server/common/decorators/workspace.decorator.js +24 -0
- package/dist-server/common/interceptor/api-id-header.interceptor.js +55 -0
- package/dist-server/common/interceptor/http-logging.interceptor.js +121 -0
- package/dist-server/common/limits/defaults.js +13 -0
- package/dist-server/common/limits/limits-provider.js +6 -0
- package/dist-server/common/limits/limits.controller.js +38 -0
- package/dist-server/common/limits/limits.module.js +24 -0
- package/dist-server/common/limits/local-limits.provider.js +27 -0
- package/dist-server/common/middleware/workspace.middleware.js +170 -0
- package/dist-server/common/workspace-context.store.js +25 -0
- package/dist-server/domain/agent/agent.controller.js +125 -0
- package/dist-server/domain/agent/agent.module.js +27 -0
- package/dist-server/domain/agent/agent.service.js +342 -0
- package/dist-server/domain/agent/agent.types.js +3 -0
- package/dist-server/domain/agent/dto/create-agent.dto.js +73 -0
- package/dist-server/domain/agent/dto/preview-prompt.dto.js +77 -0
- package/dist-server/domain/agent/dto/update-agent.dto.js +66 -0
- package/dist-server/domain/agent/template-processor.service.js +71 -0
- package/dist-server/domain/box/box.controller.js +77 -0
- package/dist-server/domain/box/box.module.js +21 -0
- package/dist-server/domain/box/box.service.js +97 -0
- package/dist-server/domain/box/dto/create-box.dto.js +74 -0
- package/dist-server/domain/cli/cli.controller.js +88 -0
- package/dist-server/domain/cli/cli.module.js +21 -0
- package/dist-server/domain/cli/cli.service.js +427 -0
- package/dist-server/domain/cli/dto/update-cli.dto.js +31 -0
- package/dist-server/domain/doc/doc.controller.js +94 -0
- package/dist-server/domain/doc/doc.module.js +21 -0
- package/dist-server/domain/doc/doc.service.js +344 -0
- package/dist-server/domain/doc/dto/doc.dto.js +64 -0
- package/dist-server/domain/document/document.controller.js +57 -0
- package/dist-server/domain/document/document.module.js +22 -0
- package/dist-server/domain/document/document.service.js +271 -0
- package/dist-server/domain/document/dto/register-document.dto.js +24 -0
- package/dist-server/domain/fs/dto/tree-node.dto.js +2 -0
- package/dist-server/domain/fs/dto/tree-query.dto.js +35 -0
- package/dist-server/domain/fs/fs.controller.js +44 -0
- package/dist-server/domain/fs/fs.module.js +22 -0
- package/dist-server/domain/fs/fs.service.js +170 -0
- package/dist-server/domain/git/git.module.js +20 -0
- package/dist-server/domain/git/git.service.js +222 -0
- package/dist-server/domain/health/health.controller.js +38 -0
- package/dist-server/domain/health/health.module.js +19 -0
- package/dist-server/domain/knowledge/dto/graph-knowledge.dto.js +27 -0
- package/dist-server/domain/knowledge/dto/knowledge.dto.js +71 -0
- package/dist-server/domain/knowledge/knowledge.controller.js +122 -0
- package/dist-server/domain/knowledge/knowledge.module.js +21 -0
- package/dist-server/domain/knowledge/knowledge.service.js +538 -0
- package/dist-server/domain/mcp/crewx-tool.factory.js +175 -0
- package/dist-server/domain/mcp/mcp-auth.guard.js +61 -0
- package/dist-server/domain/mcp/mcp.constants.js +4 -0
- package/dist-server/domain/mcp/mcp.controller.js +73 -0
- package/dist-server/domain/mcp/mcp.dto.js +12 -0
- package/dist-server/domain/mcp/mcp.module.js +38 -0
- package/dist-server/domain/mcp/mcp.service.js +415 -0
- package/dist-server/domain/message/dto/list-messages.dto.js +57 -0
- package/dist-server/domain/message/dto/send-message.dto.js +45 -0
- package/dist-server/domain/message/message.controller.js +73 -0
- package/dist-server/domain/message/message.module.js +25 -0
- package/dist-server/domain/message/message.service.js +153 -0
- package/dist-server/domain/onboarding/onboarding.controller.js +97 -0
- package/dist-server/domain/onboarding/onboarding.module.js +23 -0
- package/dist-server/domain/onboarding/onboarding.service.js +106 -0
- package/dist-server/domain/onboarding/onboarding.types.js +2 -0
- package/dist-server/domain/onboarding/presets/custom.js +10 -0
- package/dist-server/domain/onboarding/presets/dev-team.js +41 -0
- package/dist-server/domain/onboarding/presets/index.js +15 -0
- package/dist-server/domain/onboarding/presets/marketing-team.js +29 -0
- package/dist-server/domain/onboarding/presets/planning-team.js +29 -0
- package/dist-server/domain/onboarding/presets/solo.js +17 -0
- package/dist-server/domain/project/dto/create-project.dto.js +46 -0
- package/dist-server/domain/project/dto/update-project.dto.js +60 -0
- package/dist-server/domain/project/project.controller.js +129 -0
- package/dist-server/domain/project/project.module.js +22 -0
- package/dist-server/domain/project/project.service.js +173 -0
- package/dist-server/domain/skill/dto/add-registry.dto.js +23 -0
- package/dist-server/domain/skill/dto/install-skill.dto.js +30 -0
- package/dist-server/domain/skill/skill.controller.js +136 -0
- package/dist-server/domain/skill/skill.module.js +22 -0
- package/dist-server/domain/skill/skill.service.js +612 -0
- package/dist-server/domain/task/dto/all-tasks.dto.js +55 -0
- package/dist-server/domain/task/dto/list-tasks.dto.js +69 -0
- package/dist-server/domain/task/dto/search-tasks.dto.js +66 -0
- package/dist-server/domain/task/dto/send-message.dto.js +31 -0
- package/dist-server/domain/task/dto/task-status.dto.js +34 -0
- package/dist-server/domain/task/dto/workspace-usage.dto.js +38 -0
- package/dist-server/domain/task/task.constants.js +5 -0
- package/dist-server/domain/task/task.controller.js +169 -0
- package/dist-server/domain/task/task.module.js +21 -0
- package/dist-server/domain/task/task.service.js +654 -0
- package/dist-server/domain/thread/dto/build-context.dto.js +42 -0
- package/dist-server/domain/thread/dto/list-messages.dto.js +49 -0
- package/dist-server/domain/thread/dto/list-threads.dto.js +70 -0
- package/dist-server/domain/thread/dto/search-threads.dto.js +13 -0
- package/dist-server/domain/thread/thread.controller.js +116 -0
- package/dist-server/domain/thread/thread.module.js +23 -0
- package/dist-server/domain/thread/thread.service.js +365 -0
- package/dist-server/domain/usage/usage.controller.js +118 -0
- package/dist-server/domain/usage/usage.module.js +21 -0
- package/dist-server/domain/usage/usage.service.js +343 -0
- package/dist-server/domain/usage/usage.types.js +4 -0
- package/dist-server/domain/wbs/wbs.controller.js +51 -0
- package/dist-server/domain/wbs/wbs.module.js +21 -0
- package/dist-server/domain/wbs/wbs.service.js +94 -0
- package/dist-server/domain/workflow/workflow.controller.js +53 -0
- package/dist-server/domain/workflow/workflow.module.js +21 -0
- package/dist-server/domain/workflow/workflow.service.js +209 -0
- package/dist-server/domain/workspace/dto/create-workspace.dto.js +45 -0
- package/dist-server/domain/workspace/dto/switch-workspace.dto.js +32 -0
- package/dist-server/domain/workspace/dto/workspace-info.dto.js +2 -0
- package/dist-server/domain/workspace/workspace.controller.js +83 -0
- package/dist-server/domain/workspace/workspace.module.js +22 -0
- package/dist-server/domain/workspace/workspace.service.js +206 -0
- package/dist-server/main.js +138 -0
- package/dist-server/modules/crewx.module.js +50 -0
- package/dist-server/package.json +3 -0
- package/dist-server/repository/base-sqlite.repository.js +103 -0
- package/dist-server/repository/box.repository.js +174 -0
- package/dist-server/repository/message.repository.js +22 -0
- package/dist-server/repository/project.repository.js +187 -0
- package/dist-server/repository/repository.module.js +34 -0
- package/dist-server/repository/request-log.repository.js +94 -0
- package/dist-server/repository/task.repository.js +365 -0
- package/dist-server/repository/thread.repository.js +352 -0
- package/dist-server/shared/crewx-home.js +58 -0
- package/dist-server/shared/crewx-state.js +66 -0
- package/dist-server/utils/tokenizer.js +8 -0
- package/package.json +198 -18
- package/packages/cli/dist/bootstrap/crewx-cli.d.ts +11 -0
- package/packages/cli/dist/bootstrap/crewx-cli.js +31 -0
- package/packages/cli/dist/builtin.d.ts +15 -0
- package/packages/cli/dist/builtin.js +124 -0
- package/packages/cli/dist/commands/agent.d.ts +12 -0
- package/packages/cli/dist/commands/agent.js +246 -0
- package/packages/cli/dist/commands/doctor.d.ts +12 -0
- package/packages/cli/dist/commands/doctor.js +190 -0
- package/packages/cli/dist/commands/execute.d.ts +21 -0
- package/packages/cli/dist/commands/execute.js +117 -0
- package/packages/cli/dist/commands/hook/install.d.ts +21 -0
- package/packages/cli/dist/commands/hook/install.js +175 -0
- package/packages/cli/dist/commands/hook/paths.d.ts +19 -0
- package/packages/cli/dist/commands/hook/paths.js +94 -0
- package/packages/cli/dist/commands/hook/status.d.ts +7 -0
- package/packages/cli/dist/commands/hook/status.js +86 -0
- package/packages/cli/dist/commands/hook/uninstall.d.ts +8 -0
- package/packages/cli/dist/commands/hook/uninstall.js +71 -0
- package/packages/cli/dist/commands/hook-dispatch.d.ts +15 -0
- package/packages/cli/dist/commands/hook-dispatch.js +180 -0
- package/packages/cli/dist/commands/init.d.ts +24 -0
- package/packages/cli/dist/commands/init.js +133 -0
- package/packages/cli/dist/commands/kill.d.ts +12 -0
- package/packages/cli/dist/commands/kill.js +49 -0
- package/packages/cli/dist/commands/log.d.ts +13 -0
- package/packages/cli/dist/commands/log.js +97 -0
- package/packages/cli/dist/commands/parse-agent-message.d.ts +31 -0
- package/packages/cli/dist/commands/parse-agent-message.js +52 -0
- package/packages/cli/dist/commands/parse-common-flags.d.ts +36 -0
- package/packages/cli/dist/commands/parse-common-flags.js +105 -0
- package/packages/cli/dist/commands/ps.d.ts +12 -0
- package/packages/cli/dist/commands/ps.js +71 -0
- package/packages/cli/dist/commands/query.d.ts +21 -0
- package/packages/cli/dist/commands/query.js +117 -0
- package/packages/cli/dist/commands/result.d.ts +13 -0
- package/packages/cli/dist/commands/result.js +73 -0
- package/packages/cli/dist/commands/slack.d.ts +12 -0
- package/packages/cli/dist/commands/slack.js +559 -0
- package/packages/cli/dist/commands/task-db.d.ts +33 -0
- package/packages/cli/dist/commands/task-db.js +107 -0
- package/packages/cli/dist/examples/deny-secrets-plugin.d.ts +22 -0
- package/packages/cli/dist/examples/deny-secrets-plugin.js +40 -0
- package/packages/cli/dist/index.d.ts +1 -0
- package/packages/cli/dist/index.js +5 -0
- package/packages/cli/dist/logging.d.ts +21 -0
- package/packages/cli/dist/logging.js +86 -0
- package/packages/cli/dist/main.d.ts +11 -0
- package/packages/cli/dist/main.js +301 -0
- package/packages/cli/dist/plugins/examples/echo-hook.d.ts +24 -0
- package/packages/cli/dist/plugins/examples/echo-hook.js +60 -0
- package/packages/cli/dist/plugins/examples/verify-echo-hook.d.ts +8 -0
- package/packages/cli/dist/plugins/examples/verify-echo-hook.js +47 -0
- package/packages/cli/dist/plugins/sqlite-tracing.d.ts +13 -0
- package/packages/cli/dist/plugins/sqlite-tracing.js +20 -0
- package/packages/cli/dist/register-builtin-tools.d.ts +5 -0
- package/packages/cli/dist/register-builtin-tools.js +9 -0
- package/packages/cli/dist/slack/file-download.d.ts +17 -0
- package/packages/cli/dist/slack/file-download.js +134 -0
- package/packages/cli/dist/slack/markdown.d.ts +5 -0
- package/packages/cli/dist/slack/markdown.js +33 -0
- package/packages/cli/dist/utils/env-defaults.d.ts +5 -0
- package/packages/cli/dist/utils/env-defaults.js +10 -0
- package/packages/cli/dist/utils/version.d.ts +1 -0
- package/packages/cli/dist/utils/version.js +28 -0
- package/packages/cli/package.json +52 -0
- package/scripts/build-manual.mjs +266 -0
- package/scripts/emit-dist-server-package-json.mjs +7 -0
- package/scripts/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/scripts/postinstall.mjs +44 -0
- package/scripts/smoke-tarball.mjs +285 -0
- package/scripts/snapshot-msg-list.sh +52 -0
- package/server.js +164 -0
package/README.md
CHANGED
|
@@ -1,300 +1,268 @@
|
|
|
1
|
-
#
|
|
1
|
+
# CrewX
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Build your AI agent team — bring any model, orchestrate any workflow
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/crewx)
|
|
6
|
+
[](https://nodejs.org/)
|
|
7
|
+
[](#license)
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
## What is CrewX?
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
CrewX is a developer tool for building and managing AI agent teams. Define agents in YAML, wire them into workflows, and let them collaborate using built-in tools — all from a single CLI or web dashboard.
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- **Team
|
|
14
|
-
- **Thread-based context** - Maintains conversation history automatically
|
|
15
|
-
- **Multi-agent collaboration** - `@claude`, `@gemini`, `@copilot` work together in real-time
|
|
16
|
-
- **Natural integration** - Works like chatting with team members
|
|
17
|
-
- **Shared knowledge** - Team learns from AI interactions, not isolated sessions
|
|
18
|
-
|
|
19
|
-
### **Remote Agents** - Distributed AI Teams
|
|
20
|
-
Connect and orchestrate CrewX instances across projects and servers:
|
|
21
|
-
- **Cross-project experts** - Frontend dev asks backend team's API specialist agent
|
|
22
|
-
- **Team collaboration** - Each team builds their own agents, entire org can use them
|
|
23
|
-
- **Expert knowledge sharing** - Ask senior's code review agent, security team's audit agent anytime
|
|
24
|
-
- **Separate but connected** - Each project keeps its own context, collaborate when needed
|
|
25
|
-
|
|
26
|
-
```yaml
|
|
27
|
-
# Access another project's specialized agents
|
|
28
|
-
providers:
|
|
29
|
-
- id: backend_project
|
|
30
|
-
type: remote
|
|
31
|
-
location: "file:///workspace/backend-api/crewx.yaml"
|
|
32
|
-
external_agent_id: "api_expert"
|
|
33
|
-
|
|
34
|
-
# Use their expertise in your project
|
|
35
|
-
crewx query "@api_expert design user authentication API"
|
|
36
|
-
crewx execute "@api_expert implement OAuth flow"
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### **Plugin Provider System** - Universal AI Integration
|
|
40
|
-
Transform any CLI tool or AI service into an agent:
|
|
41
|
-
- **Bring Your Own AI** - OpenAI, Anthropic, Ollama, LiteLLM, or any AI service
|
|
42
|
-
- **Bring Your Own Tools** - jq, curl, ffmpeg, or any CLI tool becomes an agent
|
|
43
|
-
- **Bring Your Own Framework** - Integrate LangChain, CrewAI, AutoGPT seamlessly
|
|
44
|
-
- **No coding required** - Simple YAML configuration
|
|
45
|
-
- **Mix and match** - Combine different AI services in one workflow
|
|
46
|
-
|
|
47
|
-
```yaml
|
|
48
|
-
# Example: Add any AI service as a plugin
|
|
49
|
-
providers:
|
|
50
|
-
- id: ollama
|
|
51
|
-
type: plugin
|
|
52
|
-
cli_command: ollama
|
|
53
|
-
default_model: "llama3"
|
|
54
|
-
query_args: ["run", "{model}"]
|
|
55
|
-
prompt_in_args: false
|
|
56
|
-
|
|
57
|
-
agents:
|
|
58
|
-
- id: "local_llama"
|
|
59
|
-
provider: "plugin/ollama"
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
### Other Benefits
|
|
63
|
-
- **No additional costs** - Use existing Claude Pro, Gemini, Codex or GitHub Copilot subscriptions
|
|
64
|
-
- **Multi-agent collaboration** - Different AI models working on specialized tasks
|
|
65
|
-
- **Parallel execution** - Multiple agents working simultaneously
|
|
66
|
-
- **Flexible integration** - CLI, MCP server, or Slack bot
|
|
13
|
+
- **Bring Your Own AI** — Claude, Gemini, Copilot, Codex, or any OpenAI-compatible model
|
|
14
|
+
- **One command to start** — `npx crewx` launches everything
|
|
15
|
+
- **Team orchestration** — agents work together through threads, workflows, and shared memory
|
|
67
16
|
|
|
68
17
|
## Quick Start
|
|
69
18
|
|
|
70
19
|
```bash
|
|
71
|
-
|
|
72
|
-
npm install -g crewx
|
|
73
|
-
|
|
74
|
-
# Initialize
|
|
75
|
-
crewx init
|
|
76
|
-
|
|
77
|
-
# Check system
|
|
78
|
-
crewx doctor
|
|
79
|
-
|
|
80
|
-
# Try it out
|
|
81
|
-
crewx query "@claude analyze my code"
|
|
82
|
-
crewx execute "@claude create a login component"
|
|
20
|
+
npx crewx
|
|
83
21
|
```
|
|
84
22
|
|
|
85
|
-
|
|
23
|
+
That's it. This launches the CrewX dashboard at `http://localhost:8150` where you can manage agents, create threads, and monitor workflows.
|
|
24
|
+
|
|
25
|
+
### Initialize a new project
|
|
86
26
|
|
|
87
|
-
### Slack Mode - Team Collaboration (Recommended)
|
|
88
27
|
```bash
|
|
89
|
-
|
|
90
|
-
|
|
28
|
+
npx crewx init
|
|
29
|
+
```
|
|
91
30
|
|
|
92
|
-
|
|
93
|
-
crewx slack --mode execute
|
|
31
|
+
This creates a `crewx.yaml` in your project with default agents and settings.
|
|
94
32
|
|
|
95
|
-
|
|
96
|
-
# - @mention AI agents in channels
|
|
97
|
-
# - Maintain context in threads
|
|
98
|
-
# - Share AI insights with the whole team
|
|
99
|
-
```
|
|
100
|
-
👉 **[Complete Slack Setup Guide →](../../docs/slack-install.md)**
|
|
33
|
+
### Talk to your agents
|
|
101
34
|
|
|
102
|
-
### CLI Mode - Direct terminal usage
|
|
103
35
|
```bash
|
|
104
|
-
|
|
105
|
-
crewx
|
|
106
|
-
crewx query "@claude @gemini @copilot compare approaches"
|
|
107
|
-
```
|
|
36
|
+
# Ask a question (query mode)
|
|
37
|
+
npx crewx q "@claude review this codebase"
|
|
108
38
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
crewx mcp # VS Code, Claude Desktop, Cursor
|
|
112
|
-
```
|
|
39
|
+
# Execute a task (agents can edit files)
|
|
40
|
+
npx crewx x "@copilot implement login component"
|
|
113
41
|
|
|
114
|
-
|
|
42
|
+
# Multi-agent collaboration
|
|
43
|
+
npx crewx q "@claude @gemini compare approaches for caching"
|
|
44
|
+
```
|
|
115
45
|
|
|
116
|
-
|
|
117
|
-
- **Gemini CLI** - Real-time web access
|
|
118
|
-
- **GitHub Copilot CLI** - Specialized coding assistant
|
|
119
|
-
- **Codex CLI** - Open inference with workspace-aware execution
|
|
46
|
+
## Key Features
|
|
120
47
|
|
|
121
|
-
|
|
48
|
+
### BYOA (Bring Your Own AI)
|
|
122
49
|
|
|
123
|
-
|
|
124
|
-
# Read-only analysis
|
|
125
|
-
crewx query "@claude explain this function"
|
|
50
|
+
Use your existing AI subscriptions — or run fully local with Ollama. No vendor lock-in.
|
|
126
51
|
|
|
127
|
-
|
|
128
|
-
|
|
52
|
+
| Provider | CLI | Status |
|
|
53
|
+
|----------|-----|--------|
|
|
54
|
+
| Claude | `claude` | Supported |
|
|
55
|
+
| Gemini | `gemini` | Supported |
|
|
56
|
+
| GitHub Copilot | `copilot` | Supported |
|
|
57
|
+
| Codex | `codex` | Supported |
|
|
58
|
+
| Ollama (local LLM) | API provider | Supported |
|
|
59
|
+
| OpenAI-compatible | API provider | Supported |
|
|
129
60
|
|
|
130
|
-
|
|
131
|
-
crewx execute "@claude create tests" "@gemini write docs"
|
|
61
|
+
Build a **fully local AI team** with Ollama — no cloud, no API costs, complete data privacy. Mix and match cloud and local models in the same team.
|
|
132
62
|
|
|
133
|
-
|
|
134
|
-
crewx query "@architect design API" | \
|
|
135
|
-
crewx execute "@backend implement it"
|
|
63
|
+
### Agent Teams
|
|
136
64
|
|
|
137
|
-
|
|
138
|
-
crewx query "@claude design login" --thread "auth-feature"
|
|
139
|
-
crewx execute "@gemini implement it" --thread "auth-feature"
|
|
65
|
+
Define your team in `crewx.yaml`:
|
|
140
66
|
|
|
141
|
-
|
|
142
|
-
|
|
67
|
+
```yaml
|
|
68
|
+
agents:
|
|
69
|
+
- id: reviewer
|
|
70
|
+
name: Code Reviewer
|
|
71
|
+
provider: cli/claude
|
|
72
|
+
inline:
|
|
73
|
+
model: claude-sonnet-4-6
|
|
74
|
+
prompt: |
|
|
75
|
+
You are a senior code reviewer.
|
|
76
|
+
Focus on correctness, performance, and security.
|
|
77
|
+
|
|
78
|
+
- id: implementer
|
|
79
|
+
name: Implementer
|
|
80
|
+
provider: cli/copilot
|
|
81
|
+
inline:
|
|
82
|
+
prompt: |
|
|
83
|
+
You are a full-stack developer.
|
|
84
|
+
Write clean, tested code following project conventions.
|
|
143
85
|
```
|
|
144
86
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
- `cli/claude`
|
|
148
|
-
- `cli/gemini`
|
|
149
|
-
- `cli/copilot`
|
|
150
|
-
- `cli/codex`
|
|
87
|
+
### Thread Conversations
|
|
151
88
|
|
|
152
|
-
|
|
89
|
+
Thread-based conversations keep context across multiple interactions. Agents remember previous messages and can build on each other's work.
|
|
153
90
|
|
|
154
91
|
```bash
|
|
155
|
-
#
|
|
156
|
-
crewx
|
|
157
|
-
crewx execute "@crewx Create a React specialist with TypeScript"
|
|
158
|
-
crewx execute "@crewx Create a DevOps agent for Docker"
|
|
92
|
+
# Start a thread
|
|
93
|
+
npx crewx q "@reviewer review PR #42" --thread="pr-42-review"
|
|
159
94
|
|
|
160
|
-
#
|
|
161
|
-
crewx
|
|
95
|
+
# Continue the conversation
|
|
96
|
+
npx crewx q "@implementer fix the issues found" --thread="pr-42-review"
|
|
162
97
|
```
|
|
163
98
|
|
|
164
|
-
|
|
99
|
+
### Semantic Workflows
|
|
165
100
|
|
|
166
|
-
|
|
101
|
+
Define agent collaboration as semantic workflow YAML — branching, parallel execution, approval gates, and loops:
|
|
167
102
|
|
|
168
103
|
```yaml
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
104
|
+
# workflows/code-review.yaml
|
|
105
|
+
workflows:
|
|
106
|
+
code-review:
|
|
107
|
+
metadata:
|
|
108
|
+
name: "Code Review Workflow"
|
|
109
|
+
nodes:
|
|
110
|
+
review:
|
|
111
|
+
type: agent_task
|
|
112
|
+
agent: reviewer
|
|
113
|
+
mode: query
|
|
114
|
+
input: "Review the latest changes for bugs and security issues"
|
|
115
|
+
output: review_result
|
|
116
|
+
next: fix
|
|
117
|
+
|
|
118
|
+
fix:
|
|
119
|
+
type: agent_task
|
|
120
|
+
agent: implementer
|
|
121
|
+
mode: execute
|
|
122
|
+
input: "Fix the issues found: {{review_result}}"
|
|
123
|
+
next: end
|
|
124
|
+
|
|
125
|
+
end:
|
|
126
|
+
type: end
|
|
179
127
|
```
|
|
180
128
|
|
|
181
|
-
|
|
129
|
+
### Built-in Tools
|
|
182
130
|
|
|
183
|
-
|
|
131
|
+
Each tool is a standalone npm package — install individually or use all out of the box:
|
|
184
132
|
|
|
185
|
-
|
|
133
|
+
| Package | npm | Description |
|
|
134
|
+
|---------|-----|-------------|
|
|
135
|
+
| `@crewx/memory` | [](https://www.npmjs.com/package/@crewx/memory) | Persistent agent memory (markdown + frontmatter) |
|
|
136
|
+
| `@crewx/doc` | [](https://www.npmjs.com/package/@crewx/doc) | Document TOC extraction and section reader |
|
|
137
|
+
| `@crewx/search` | [](https://www.npmjs.com/package/@crewx/search) | BM25 full-text code/document search |
|
|
138
|
+
| `@crewx/cron` | [](https://www.npmjs.com/package/@crewx/cron) | Scheduled task execution |
|
|
139
|
+
| `@crewx/wbs` | [](https://www.npmjs.com/package/@crewx/wbs) | Work breakdown structure management |
|
|
140
|
+
| `@crewx/workflow` | [](https://www.npmjs.com/package/@crewx/workflow) | Semantic workflow engine (branch, parallel, approval) |
|
|
141
|
+
| `@crewx/skill` | [](https://www.npmjs.com/package/@crewx/skill) | Reusable skill system (Claude Code compatible) |
|
|
142
|
+
| `@crewx/knowledge-core` | [](https://www.npmjs.com/package/@crewx/knowledge-core) | Knowledge graph engine |
|
|
143
|
+
| `@crewx/shared` | [](https://www.npmjs.com/package/@crewx/shared) | Shared utilities for built-in tools |
|
|
186
144
|
|
|
187
|
-
|
|
188
|
-
```bash
|
|
189
|
-
# Add a remote CrewX instance
|
|
190
|
-
providers:
|
|
191
|
-
- id: backend_server
|
|
192
|
-
type: remote
|
|
193
|
-
location: "http://api.example.com:3000"
|
|
194
|
-
external_agent_id: "backend_team"
|
|
145
|
+
### Desktop & Server
|
|
195
146
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
147
|
+
- **Web Dashboard** — `npx crewx` serves a full management UI
|
|
148
|
+
- **Electron Desktop App** — native app with the same features
|
|
149
|
+
- **MCP Server** — JSON-RPC 2.0 endpoint for IDE integration (Claude Code, Cursor, etc.)
|
|
199
150
|
|
|
200
|
-
|
|
201
|
-
crewx query "@remote_backend check API status"
|
|
202
|
-
```
|
|
151
|
+
## Use Cases
|
|
203
152
|
|
|
204
|
-
|
|
205
|
-
-
|
|
206
|
-
- **Distributed teams** - Each team runs their own CrewX with specialized agents
|
|
207
|
-
- **Resource sharing** - Access powerful compute resources remotely
|
|
208
|
-
- **Multi-project coordination** - Orchestrate work across multiple projects
|
|
153
|
+
### Development Workflow Automation
|
|
154
|
+
Set up AI-powered code review, testing, and deployment pipelines. Multiple agents handle different stages of your development process.
|
|
209
155
|
|
|
210
|
-
|
|
156
|
+
### Team Productivity
|
|
157
|
+
Distribute tasks across specialized agents. A reviewer checks code quality while an implementer writes features — in parallel.
|
|
211
158
|
|
|
212
|
-
|
|
159
|
+
### AI-Powered Business Automation
|
|
160
|
+
Build agent teams that handle business processes end-to-end. From customer research to content generation, agents collaborate through workflows and shared knowledge.
|
|
213
161
|
|
|
214
|
-
|
|
162
|
+
## Supported Providers
|
|
215
163
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
├── packages/
|
|
219
|
-
│ ├── sdk/ # @sowonai/crewx-sdk (Apache-2.0)
|
|
220
|
-
│ │ ├── Core AI provider interfaces
|
|
221
|
-
│ │ ├── Conversation management
|
|
222
|
-
│ │ ├── Knowledge utilities
|
|
223
|
-
│ │ └── Agent domain types
|
|
224
|
-
│ └── cli/ # crewx (MIT)
|
|
225
|
-
│ ├── CLI implementation
|
|
226
|
-
│ ├── Slack integration
|
|
227
|
-
│ ├── MCP server
|
|
228
|
-
│ └── Provider implementations
|
|
229
|
-
├── docs/ # Comprehensive documentation
|
|
230
|
-
└── README.md # This file
|
|
231
|
-
```
|
|
164
|
+
### CLI Providers
|
|
165
|
+
Use AI tools you already have installed:
|
|
232
166
|
|
|
233
|
-
|
|
167
|
+
| Provider | CLI | Notes |
|
|
168
|
+
|----------|-----|-------|
|
|
169
|
+
| Claude (Anthropic) | `claude` | Complex reasoning, system design |
|
|
170
|
+
| Gemini (Google) | `gemini` | Research, data analysis |
|
|
171
|
+
| GitHub Copilot | `copilot` | Code generation |
|
|
172
|
+
| Codex (OpenAI) | `codex` | General-purpose coding |
|
|
234
173
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
| `@sowonai/crewx-sdk` | Apache-2.0 | Core SDK for building custom AI integrations | `npm install @sowonai/crewx-sdk` |
|
|
238
|
-
| `crewx` | MIT | Full-featured CLI tool for immediate use | `npm install -g crewx` |
|
|
174
|
+
### API Providers
|
|
175
|
+
Connect any API-compatible model — including local LLMs:
|
|
239
176
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
177
|
+
| Provider | Type | Notes |
|
|
178
|
+
|----------|------|-------|
|
|
179
|
+
| Ollama | Local LLM | Run fully local — zero cloud, zero cost, full privacy |
|
|
180
|
+
| OpenAI API | Cloud API | GPT-4o, o1, etc. |
|
|
181
|
+
| OpenAI-compatible | Cloud/Local | Any endpoint following OpenAI API spec |
|
|
243
182
|
|
|
244
|
-
|
|
183
|
+
Mix CLI and API providers in the same team. For example, Claude for planning + Ollama for execution — best of both worlds.
|
|
245
184
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
185
|
+
## Requirements
|
|
186
|
+
|
|
187
|
+
- **Node.js** >= 22 (required by Copilot CLI provider)
|
|
188
|
+
- **OS**: macOS, Windows, or Linux
|
|
189
|
+
- At least one AI CLI installed: `claude`, `gemini`, `copilot`, or `codex`
|
|
190
|
+
|
|
191
|
+
## Configuration
|
|
249
192
|
|
|
250
|
-
|
|
251
|
-
npm run build
|
|
193
|
+
### Minimal `crewx.yaml`
|
|
252
194
|
|
|
253
|
-
|
|
254
|
-
|
|
195
|
+
```yaml
|
|
196
|
+
agents:
|
|
197
|
+
- id: assistant
|
|
198
|
+
provider: cli/claude
|
|
199
|
+
inline:
|
|
200
|
+
prompt: "You are a helpful coding assistant."
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Full example with skills and workflows
|
|
204
|
+
|
|
205
|
+
```yaml
|
|
206
|
+
skills:
|
|
207
|
+
paths:
|
|
208
|
+
- ./skills # Custom skill directory
|
|
255
209
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
210
|
+
agents:
|
|
211
|
+
- id: lead
|
|
212
|
+
name: Tech Lead
|
|
213
|
+
provider: cli/claude
|
|
214
|
+
skills:
|
|
215
|
+
include:
|
|
216
|
+
- code-reviewer
|
|
217
|
+
- api-designer
|
|
218
|
+
inline:
|
|
219
|
+
model: claude-opus-4-6
|
|
220
|
+
prompt: |
|
|
221
|
+
You are a tech lead responsible for architecture decisions
|
|
222
|
+
and code quality.
|
|
223
|
+
|
|
224
|
+
- id: dev
|
|
225
|
+
name: Developer
|
|
226
|
+
provider: cli/copilot
|
|
227
|
+
inline:
|
|
228
|
+
prompt: |
|
|
229
|
+
You are a full-stack developer.
|
|
230
|
+
Follow the tech lead's guidance.
|
|
259
231
|
```
|
|
260
232
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
233
|
+
### CLI Commands
|
|
234
|
+
|
|
235
|
+
| Command | Description |
|
|
236
|
+
|---------|-------------|
|
|
237
|
+
| `npx crewx` | Launch web dashboard |
|
|
238
|
+
| `npx crewx init` | Initialize project with `crewx.yaml` |
|
|
239
|
+
| `npx crewx q "@agent message"` | Query an agent (read-only) |
|
|
240
|
+
| `npx crewx x "@agent message"` | Execute a task (can edit files) |
|
|
241
|
+
| `npx crewx agent list` | List configured agents |
|
|
242
|
+
| `npx crewx doctor` | Check system health |
|
|
243
|
+
| `npx crewx skill list` | List available skills |
|
|
244
|
+
| `npx crewx workflow list` | List workflows |
|
|
245
|
+
| `npx crewx memory index <agent>` | View agent memory |
|
|
246
|
+
| `npx crewx search "query"` | Full-text search |
|
|
265
247
|
|
|
266
248
|
## Documentation
|
|
267
249
|
|
|
268
|
-
|
|
269
|
-
-
|
|
270
|
-
-
|
|
271
|
-
- [⚙️ Agent Configuration](docs/agent-configuration.md) - Custom agents and advanced config
|
|
272
|
-
- [🌐 Remote Agents](docs/remote-agents.md) - Connect to remote CrewX instances
|
|
273
|
-
- [📚 Template System](docs/templates.md) - Knowledge management and dynamic prompts for agents
|
|
274
|
-
- [📝 Template Variables](docs/template-variables.md) - Dynamic variables in agent configurations
|
|
275
|
-
- [🔧 Tool System](docs/tools.md) - Tool integration and creation guide
|
|
276
|
-
- [🔧 Troubleshooting](docs/troubleshooting.md) - Common issues and solutions
|
|
277
|
-
- [💬 Slack Integration](../../docs/slack-install.md) - Slack bot setup
|
|
278
|
-
|
|
279
|
-
### Developer Guides
|
|
280
|
-
- [🏗️ SDK API Reference](packages/sdk/README.md) - Build custom integrations
|
|
281
|
-
- [⚙️ CLI Development](packages/cli/README.md) - CLI architecture and development
|
|
282
|
-
- [📦 Build & Release](BUILD.md) - Building and releasing packages
|
|
283
|
-
- [🔧 Development Workflow](docs/development.md) - Contributing guidelines
|
|
250
|
+
- **Web Dashboard**: Launch with `npx crewx` and explore at `http://localhost:8150`
|
|
251
|
+
- **API Reference**: Swagger UI available at `http://localhost:8150/api/docs`
|
|
252
|
+
- **Contributing**: See [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
284
253
|
|
|
285
254
|
## License
|
|
286
255
|
|
|
287
|
-
|
|
288
|
-
- **CLI** (`crewx`): MIT License
|
|
289
|
-
|
|
290
|
-
Copyright (c) 2025 SowonLabs
|
|
291
|
-
|
|
292
|
-
## Contributing
|
|
256
|
+
CrewX is built on an open-source CLI engine:
|
|
293
257
|
|
|
294
|
-
|
|
258
|
+
| Component | License | Notes |
|
|
259
|
+
|-----------|---------|-------|
|
|
260
|
+
| CLI Engine + SDK | Apache-2.0 | Open source — [sowonlabs/crewx](https://github.com/sowonlabs/crewx) |
|
|
261
|
+
| Built-in Tools (`@crewx/*`) | Proprietary | Free to use via npm, source not published |
|
|
262
|
+
| Web UI + Server | Proprietary | Included in this package |
|
|
295
263
|
|
|
296
|
-
|
|
264
|
+
The open-source CLI ([sowonlabs/crewx](https://github.com/sowonlabs/crewx)) is the foundation of this project. New CLI features are developed here first and periodically contributed back to the open-source repository.
|
|
297
265
|
|
|
298
266
|
---
|
|
299
267
|
|
|
300
|
-
|
|
268
|
+
**[SowonLabs](https://sowonlabs.com)** | [GitHub](https://github.com/sowonlabs/crewx) | hello@sowonlabs.com
|
package/bin/crewx-lib.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* crewx launcher library — testable pure-logic functions extracted from crewx.js.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Parse --port option from extra CLI args and validate the value.
|
|
7
|
+
*
|
|
8
|
+
* @param {string[]} extraArgs - remaining args after route resolution (e.g. ['--port', '3000'])
|
|
9
|
+
* @returns {{ port: number } | { error: string } | null}
|
|
10
|
+
* - `{ port }` when a valid port is found
|
|
11
|
+
* - `{ error }` when --port is present but the value is invalid
|
|
12
|
+
* - `null` when --port is not specified
|
|
13
|
+
*/
|
|
14
|
+
export function parseWebPort(extraArgs) {
|
|
15
|
+
const portIdx = extraArgs.indexOf('--port');
|
|
16
|
+
if (portIdx === -1) return null;
|
|
17
|
+
const portVal = Number(extraArgs[portIdx + 1]);
|
|
18
|
+
if (!portVal || portVal < 1 || portVal > 65535) {
|
|
19
|
+
return { error: 'Invalid port number. Use 1-65535.' };
|
|
20
|
+
}
|
|
21
|
+
return { port: portVal };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Determine the route based on CLI arguments.
|
|
26
|
+
* UI flags (--web, --no-open, --overlay, --electron, --desktop) are checked first.
|
|
27
|
+
* Any other argument routes to CLI. No arguments → web default (with browser auto-open).
|
|
28
|
+
*
|
|
29
|
+
* @param {string[]} args - process.argv.slice(2)
|
|
30
|
+
* @returns {{ route: string, routeArgs: string[] }}
|
|
31
|
+
*/
|
|
32
|
+
export function resolveRoute(args) {
|
|
33
|
+
const firstArg = args[0];
|
|
34
|
+
|
|
35
|
+
if (firstArg === '--web') return { route: 'web', routeArgs: args.slice(1) };
|
|
36
|
+
if (firstArg === '--no-open') return { route: 'web', routeArgs: args.slice(1) };
|
|
37
|
+
if (firstArg === '--overlay') return { route: 'overlay', routeArgs: args.slice(1) };
|
|
38
|
+
if (firstArg === '--electron') return { route: 'electron-explicit', routeArgs: args.slice(1) };
|
|
39
|
+
if (firstArg === '--desktop') return { route: 'electron-explicit', routeArgs: args.slice(1) };
|
|
40
|
+
if (firstArg !== undefined) return { route: 'cli', routeArgs: args };
|
|
41
|
+
return { route: 'web-default', routeArgs: args };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Forward signals to a child process for clean shutdown.
|
|
46
|
+
*
|
|
47
|
+
* Uses an `exited` flag (set by the child's 'exit' event) instead of
|
|
48
|
+
* `child.killed`, because `child.killed` becomes `true` immediately after
|
|
49
|
+
* calling `child.kill()` — even if the child process is still running.
|
|
50
|
+
* This ensures the SIGKILL escalation timer can actually fire.
|
|
51
|
+
*
|
|
52
|
+
* On Windows, SIGTERM is equivalent to an immediate kill.
|
|
53
|
+
*
|
|
54
|
+
* @param {import('child_process').ChildProcess} child
|
|
55
|
+
* @param {{ escalateKill?: boolean, detached?: boolean }} options
|
|
56
|
+
*/
|
|
57
|
+
export function setupSignalForwarding(child, { escalateKill = false, detached = false } = {}) {
|
|
58
|
+
let exited = false;
|
|
59
|
+
let escalationScheduled = false;
|
|
60
|
+
|
|
61
|
+
child.on('exit', () => {
|
|
62
|
+
exited = true;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// When detached, the child runs in its own process group.
|
|
66
|
+
// Use process.kill(-pid) to kill the entire group (Electron + GPU helpers).
|
|
67
|
+
// When not detached, use child.kill() for single-process kill.
|
|
68
|
+
const killChild = (signal) => {
|
|
69
|
+
try {
|
|
70
|
+
if (detached) {
|
|
71
|
+
process.kill(-child.pid, signal);
|
|
72
|
+
} else {
|
|
73
|
+
child.kill(signal);
|
|
74
|
+
}
|
|
75
|
+
} catch {
|
|
76
|
+
// Process or process group already terminated
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
process.on('SIGINT', () => {
|
|
81
|
+
if (!exited) {
|
|
82
|
+
killChild('SIGTERM');
|
|
83
|
+
if (escalateKill && !escalationScheduled) {
|
|
84
|
+
escalationScheduled = true;
|
|
85
|
+
setTimeout(() => {
|
|
86
|
+
if (!exited) killChild('SIGKILL');
|
|
87
|
+
}, 3000).unref();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
process.on('SIGTERM', () => {
|
|
93
|
+
if (!exited) killChild('SIGTERM');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
process.on('SIGHUP', () => {
|
|
97
|
+
if (!exited) killChild('SIGHUP');
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Clean up the child process group when the parent exits unexpectedly
|
|
101
|
+
if (detached) {
|
|
102
|
+
process.on('exit', () => {
|
|
103
|
+
if (!exited) {
|
|
104
|
+
try { process.kill(-child.pid, 'SIGKILL'); } catch {}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|