@pixelbyte-software/pixcode 1.54.11 → 1.55.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.
- package/dist-server/server/claude-sdk.js +1 -1
- package/dist-server/server/claude-sdk.js.map +1 -1
- package/dist-server/server/index.js +6 -11
- package/dist-server/server/index.js.map +1 -1
- package/dist-server/server/modules/security/permission-policy.js.map +1 -0
- package/dist-server/server/modules/tasks/git-worktree.js +98 -0
- package/dist-server/server/modules/tasks/git-worktree.js.map +1 -0
- package/dist-server/server/modules/tasks/index.js +8 -0
- package/dist-server/server/modules/tasks/index.js.map +1 -0
- package/dist-server/server/modules/tasks/prompt-builder.js +85 -0
- package/dist-server/server/modules/tasks/prompt-builder.js.map +1 -0
- package/dist-server/server/modules/tasks/role-presets.js +94 -0
- package/dist-server/server/modules/tasks/role-presets.js.map +1 -0
- package/dist-server/server/modules/tasks/runners/claude-runner.js +109 -0
- package/dist-server/server/modules/tasks/runners/claude-runner.js.map +1 -0
- package/dist-server/server/modules/tasks/runners/codex-runner.js +67 -0
- package/dist-server/server/modules/tasks/runners/codex-runner.js.map +1 -0
- package/dist-server/server/modules/tasks/runners/spawn-runner.js +111 -0
- package/dist-server/server/modules/tasks/runners/spawn-runner.js.map +1 -0
- package/dist-server/server/modules/tasks/runners/types.js +5 -0
- package/dist-server/server/modules/tasks/runners/types.js.map +1 -0
- package/dist-server/server/modules/tasks/scheduler.js +69 -0
- package/dist-server/server/modules/tasks/scheduler.js.map +1 -0
- package/dist-server/server/modules/tasks/task-queue.js +81 -0
- package/dist-server/server/modules/tasks/task-queue.js.map +1 -0
- package/dist-server/server/modules/tasks/task-routes.js +195 -0
- package/dist-server/server/modules/tasks/task-routes.js.map +1 -0
- package/dist-server/server/modules/tasks/task-runner.js +187 -0
- package/dist-server/server/modules/tasks/task-runner.js.map +1 -0
- package/dist-server/server/modules/tasks/task-store.js +196 -0
- package/dist-server/server/modules/tasks/task-store.js.map +1 -0
- package/dist-server/server/modules/tasks/task-types.js +5 -0
- package/dist-server/server/modules/tasks/task-types.js.map +1 -0
- package/dist-server/server/modules/tasks/user-interaction.js +73 -0
- package/dist-server/server/modules/tasks/user-interaction.js.map +1 -0
- package/dist-server/server/services/control-room.js +9 -1
- package/dist-server/server/services/control-room.js.map +1 -1
- package/dist-server/server/services/public-api-manifest.js +5 -5
- package/dist-server/server/services/public-api-manifest.js.map +1 -1
- package/dist-server/server/services/telegram/control-center.js +10 -10
- package/dist-server/server/services/telegram/control-center.js.map +1 -1
- package/dist-server/server/services/telegram/telegram-gateway.js +2 -2
- package/dist-server/server/services/telegram/telegram-gateway.js.map +1 -1
- package/dist-server/server/services/telegram/translations.js +5 -5
- package/dist-server/server/services/telegram/translations.js.map +1 -1
- package/package.json +1 -1
- package/server/claude-sdk.js +1 -1
- package/server/index.js +6 -23
- package/server/modules/tasks/git-worktree.ts +102 -0
- package/server/modules/tasks/index.ts +9 -0
- package/server/modules/tasks/prompt-builder.ts +98 -0
- package/server/modules/tasks/role-presets.ts +113 -0
- package/server/modules/tasks/runners/claude-runner.ts +120 -0
- package/server/modules/tasks/runners/codex-runner.ts +80 -0
- package/server/modules/tasks/runners/spawn-runner.ts +122 -0
- package/server/modules/tasks/runners/types.ts +25 -0
- package/server/modules/tasks/scheduler.ts +75 -0
- package/server/modules/tasks/task-queue.ts +91 -0
- package/server/modules/tasks/task-routes.ts +245 -0
- package/server/modules/tasks/task-runner.ts +219 -0
- package/server/modules/tasks/task-store.ts +223 -0
- package/server/modules/tasks/task-types.ts +100 -0
- package/server/modules/tasks/user-interaction.ts +93 -0
- package/server/services/control-room.js +10 -1
- package/server/services/public-api-manifest.js +5 -5
- package/server/services/telegram/control-center.js +10 -10
- package/server/services/telegram/telegram-gateway.js +2 -2
- package/server/services/telegram/translations.js +5 -5
- package/dist/api-automation.html +0 -110
- package/dist/api-docs.html +0 -548
- package/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/assets/index-Bcqs_1vc.js +0 -877
- package/dist/assets/index-Dz1luE0u.css +0 -32
- package/dist/assets/index-ak1p_4ew.js +0 -11
- package/dist/assets/localMonaco-DFIbtDNp.js +0 -1
- package/dist/assets/vendor-codemirror-CIYNS698.js +0 -41
- package/dist/assets/vendor-react-DB6V5Fl1.js +0 -59
- package/dist/assets/vendor-xterm-C7tpxJl7.js +0 -9
- package/dist/clear-cache.html +0 -85
- package/dist/convert-icons.md +0 -53
- package/dist/docs.html +0 -308
- package/dist/favicon.png +0 -0
- package/dist/favicon.svg +0 -8
- package/dist/features.html +0 -133
- package/dist/generate-icons.js +0 -49
- package/dist/humans.txt +0 -15
- package/dist/icons/claude-ai-icon.svg +0 -1
- package/dist/icons/codex-white.svg +0 -3
- package/dist/icons/codex.svg +0 -3
- package/dist/icons/cursor-white.svg +0 -12
- package/dist/icons/cursor.svg +0 -1
- package/dist/icons/gemini-ai-icon.svg +0 -1
- package/dist/icons/icon-128x128.png +0 -0
- package/dist/icons/icon-128x128.svg +0 -9
- package/dist/icons/icon-144x144.png +0 -0
- package/dist/icons/icon-144x144.svg +0 -9
- package/dist/icons/icon-152x152.png +0 -0
- package/dist/icons/icon-152x152.svg +0 -9
- package/dist/icons/icon-192x192.png +0 -0
- package/dist/icons/icon-192x192.svg +0 -9
- package/dist/icons/icon-384x384.png +0 -0
- package/dist/icons/icon-384x384.svg +0 -9
- package/dist/icons/icon-512x512.png +0 -0
- package/dist/icons/icon-512x512.svg +0 -9
- package/dist/icons/icon-72x72.png +0 -0
- package/dist/icons/icon-72x72.svg +0 -9
- package/dist/icons/icon-96x96.png +0 -0
- package/dist/icons/icon-96x96.svg +0 -9
- package/dist/icons/icon-template.svg +0 -9
- package/dist/icons/opencode-logo-dark.svg +0 -1
- package/dist/icons/opencode-logo-light.svg +0 -1
- package/dist/icons/qwen-ai-icon.png +0 -0
- package/dist/icons/qwen-logo.svg +0 -15
- package/dist/index.html +0 -62
- package/dist/landing.html +0 -268
- package/dist/llms-full.txt +0 -119
- package/dist/llms.txt +0 -53
- package/dist/logo-128.png +0 -0
- package/dist/logo-256.png +0 -0
- package/dist/logo-32.png +0 -0
- package/dist/logo-512.png +0 -0
- package/dist/logo-64.png +0 -0
- package/dist/logo.png +0 -0
- package/dist/logo.svg +0 -12
- package/dist/manifest.json +0 -61
- package/dist/openapi.yaml +0 -1696
- package/dist/orchestration.html +0 -125
- package/dist/robots.txt +0 -4
- package/dist/screenshots/cli-selection.png +0 -0
- package/dist/screenshots/desktop-main.png +0 -0
- package/dist/screenshots/mobile-chat.png +0 -0
- package/dist/screenshots/tools-modal.png +0 -0
- package/dist/site.css +0 -692
- package/dist/sitemap.xml +0 -51
- package/dist/sw.js +0 -132
- package/dist-server/server/modules/orchestration/a2a/adapter-registry.js +0 -73
- package/dist-server/server/modules/orchestration/a2a/adapter-registry.js.map +0 -1
- package/dist-server/server/modules/orchestration/a2a/adapters/abstract-a2a.adapter.js +0 -17
- package/dist-server/server/modules/orchestration/a2a/adapters/abstract-a2a.adapter.js.map +0 -1
- package/dist-server/server/modules/orchestration/a2a/adapters/claude-code.adapter.js +0 -236
- package/dist-server/server/modules/orchestration/a2a/adapters/claude-code.adapter.js.map +0 -1
- package/dist-server/server/modules/orchestration/a2a/adapters/codex.adapter.js +0 -202
- package/dist-server/server/modules/orchestration/a2a/adapters/codex.adapter.js.map +0 -1
- package/dist-server/server/modules/orchestration/a2a/adapters/cursor.adapter.js +0 -205
- package/dist-server/server/modules/orchestration/a2a/adapters/cursor.adapter.js.map +0 -1
- package/dist-server/server/modules/orchestration/a2a/adapters/gemini.adapter.js +0 -205
- package/dist-server/server/modules/orchestration/a2a/adapters/gemini.adapter.js.map +0 -1
- package/dist-server/server/modules/orchestration/a2a/adapters/json-event.adapter.js +0 -84
- package/dist-server/server/modules/orchestration/a2a/adapters/json-event.adapter.js.map +0 -1
- package/dist-server/server/modules/orchestration/a2a/adapters/json-event.adapter.test.js +0 -43
- package/dist-server/server/modules/orchestration/a2a/adapters/json-event.adapter.test.js.map +0 -1
- package/dist-server/server/modules/orchestration/a2a/adapters/opencode.adapter.js +0 -205
- package/dist-server/server/modules/orchestration/a2a/adapters/opencode.adapter.js.map +0 -1
- package/dist-server/server/modules/orchestration/a2a/adapters/qwen.adapter.js +0 -205
- package/dist-server/server/modules/orchestration/a2a/adapters/qwen.adapter.js.map +0 -1
- package/dist-server/server/modules/orchestration/a2a/agent-card.js +0 -50
- package/dist-server/server/modules/orchestration/a2a/agent-card.js.map +0 -1
- package/dist-server/server/modules/orchestration/a2a/auth.middleware.js +0 -25
- package/dist-server/server/modules/orchestration/a2a/auth.middleware.js.map +0 -1
- package/dist-server/server/modules/orchestration/a2a/bus.js +0 -34
- package/dist-server/server/modules/orchestration/a2a/bus.js.map +0 -1
- package/dist-server/server/modules/orchestration/a2a/routes.js +0 -502
- package/dist-server/server/modules/orchestration/a2a/routes.js.map +0 -1
- package/dist-server/server/modules/orchestration/a2a/task-dispatcher.js +0 -295
- package/dist-server/server/modules/orchestration/a2a/task-dispatcher.js.map +0 -1
- package/dist-server/server/modules/orchestration/a2a/task-store.js +0 -144
- package/dist-server/server/modules/orchestration/a2a/task-store.js.map +0 -1
- package/dist-server/server/modules/orchestration/a2a/types.js +0 -6
- package/dist-server/server/modules/orchestration/a2a/types.js.map +0 -1
- package/dist-server/server/modules/orchestration/a2a/validator.js +0 -101
- package/dist-server/server/modules/orchestration/a2a/validator.js.map +0 -1
- package/dist-server/server/modules/orchestration/index.js +0 -27
- package/dist-server/server/modules/orchestration/index.js.map +0 -1
- package/dist-server/server/modules/orchestration/preview/port-watcher.js +0 -90
- package/dist-server/server/modules/orchestration/preview/port-watcher.js.map +0 -1
- package/dist-server/server/modules/orchestration/preview/preview-proxy.js +0 -58
- package/dist-server/server/modules/orchestration/preview/preview-proxy.js.map +0 -1
- package/dist-server/server/modules/orchestration/preview/types.js +0 -2
- package/dist-server/server/modules/orchestration/preview/types.js.map +0 -1
- package/dist-server/server/modules/orchestration/security/permission-policy.js.map +0 -1
- package/dist-server/server/modules/orchestration/tasks/orchestration-task-store.js +0 -34
- package/dist-server/server/modules/orchestration/tasks/orchestration-task-store.js.map +0 -1
- package/dist-server/server/modules/orchestration/tasks/orchestration-task.routes.js +0 -70
- package/dist-server/server/modules/orchestration/tasks/orchestration-task.routes.js.map +0 -1
- package/dist-server/server/modules/orchestration/tasks/orchestration-task.service.js +0 -181
- package/dist-server/server/modules/orchestration/tasks/orchestration-task.service.js.map +0 -1
- package/dist-server/server/modules/orchestration/tasks/orchestration-task.types.js +0 -2
- package/dist-server/server/modules/orchestration/tasks/orchestration-task.types.js.map +0 -1
- package/dist-server/server/modules/orchestration/tasks/task-run-graph.js +0 -100
- package/dist-server/server/modules/orchestration/tasks/task-run-graph.js.map +0 -1
- package/dist-server/server/modules/orchestration/workflows/approval-queue.js +0 -72
- package/dist-server/server/modules/orchestration/workflows/approval-queue.js.map +0 -1
- package/dist-server/server/modules/orchestration/workflows/built-in-workflows.js +0 -126
- package/dist-server/server/modules/orchestration/workflows/built-in-workflows.js.map +0 -1
- package/dist-server/server/modules/orchestration/workflows/context-packet.js +0 -89
- package/dist-server/server/modules/orchestration/workflows/context-packet.js.map +0 -1
- package/dist-server/server/modules/orchestration/workflows/handoff-artifact.js +0 -123
- package/dist-server/server/modules/orchestration/workflows/handoff-artifact.js.map +0 -1
- package/dist-server/server/modules/orchestration/workflows/workflow-fallback-policy.js +0 -114
- package/dist-server/server/modules/orchestration/workflows/workflow-fallback-policy.js.map +0 -1
- package/dist-server/server/modules/orchestration/workflows/workflow-replay.js +0 -177
- package/dist-server/server/modules/orchestration/workflows/workflow-replay.js.map +0 -1
- package/dist-server/server/modules/orchestration/workflows/workflow-runner.js +0 -1718
- package/dist-server/server/modules/orchestration/workflows/workflow-runner.js.map +0 -1
- package/dist-server/server/modules/orchestration/workflows/workflow-store.js +0 -76
- package/dist-server/server/modules/orchestration/workflows/workflow-store.js.map +0 -1
- package/dist-server/server/modules/orchestration/workflows/workflow-templates.js +0 -242
- package/dist-server/server/modules/orchestration/workflows/workflow-templates.js.map +0 -1
- package/dist-server/server/modules/orchestration/workflows/workflow-trace.js +0 -388
- package/dist-server/server/modules/orchestration/workflows/workflow-trace.js.map +0 -1
- package/dist-server/server/modules/orchestration/workflows/workflow.routes.js +0 -508
- package/dist-server/server/modules/orchestration/workflows/workflow.routes.js.map +0 -1
- package/dist-server/server/modules/orchestration/workflows/workflow.types.js +0 -2
- package/dist-server/server/modules/orchestration/workflows/workflow.types.js.map +0 -1
- package/dist-server/server/modules/orchestration/workflows/workspace-target.js +0 -100
- package/dist-server/server/modules/orchestration/workflows/workspace-target.js.map +0 -1
- package/dist-server/server/modules/orchestration/workspace/docker-workspace.js +0 -123
- package/dist-server/server/modules/orchestration/workspace/docker-workspace.js.map +0 -1
- package/dist-server/server/modules/orchestration/workspace/path-safety.js +0 -48
- package/dist-server/server/modules/orchestration/workspace/path-safety.js.map +0 -1
- package/dist-server/server/modules/orchestration/workspace/types.js +0 -11
- package/dist-server/server/modules/orchestration/workspace/types.js.map +0 -1
- package/dist-server/server/modules/orchestration/workspace/workspace-manager.js +0 -84
- package/dist-server/server/modules/orchestration/workspace/workspace-manager.js.map +0 -1
- package/dist-server/server/modules/orchestration/workspace/worktree-workspace.js +0 -97
- package/dist-server/server/modules/orchestration/workspace/worktree-workspace.js.map +0 -1
- package/server/modules/orchestration/a2a/adapter-registry.ts +0 -108
- package/server/modules/orchestration/a2a/adapters/abstract-a2a.adapter.ts +0 -63
- package/server/modules/orchestration/a2a/adapters/claude-code.adapter.ts +0 -286
- package/server/modules/orchestration/a2a/adapters/codex.adapter.ts +0 -244
- package/server/modules/orchestration/a2a/adapters/cursor.adapter.ts +0 -249
- package/server/modules/orchestration/a2a/adapters/gemini.adapter.ts +0 -248
- package/server/modules/orchestration/a2a/adapters/json-event.adapter.test.ts +0 -60
- package/server/modules/orchestration/a2a/adapters/json-event.adapter.ts +0 -101
- package/server/modules/orchestration/a2a/adapters/opencode.adapter.ts +0 -248
- package/server/modules/orchestration/a2a/adapters/qwen.adapter.ts +0 -248
- package/server/modules/orchestration/a2a/agent-card.ts +0 -55
- package/server/modules/orchestration/a2a/auth.middleware.ts +0 -29
- package/server/modules/orchestration/a2a/bus.ts +0 -46
- package/server/modules/orchestration/a2a/routes.ts +0 -586
- package/server/modules/orchestration/a2a/task-dispatcher.ts +0 -345
- package/server/modules/orchestration/a2a/task-store.ts +0 -178
- package/server/modules/orchestration/a2a/types.ts +0 -126
- package/server/modules/orchestration/a2a/validator.ts +0 -113
- package/server/modules/orchestration/index.ts +0 -99
- package/server/modules/orchestration/preview/port-watcher.ts +0 -112
- package/server/modules/orchestration/preview/preview-proxy.ts +0 -60
- package/server/modules/orchestration/preview/types.ts +0 -19
- package/server/modules/orchestration/tasks/orchestration-task-store.ts +0 -41
- package/server/modules/orchestration/tasks/orchestration-task.routes.ts +0 -81
- package/server/modules/orchestration/tasks/orchestration-task.service.ts +0 -201
- package/server/modules/orchestration/tasks/orchestration-task.types.ts +0 -40
- package/server/modules/orchestration/tasks/task-run-graph.ts +0 -155
- package/server/modules/orchestration/workflows/approval-queue.ts +0 -106
- package/server/modules/orchestration/workflows/built-in-workflows.ts +0 -127
- package/server/modules/orchestration/workflows/context-packet.ts +0 -186
- package/server/modules/orchestration/workflows/handoff-artifact.ts +0 -175
- package/server/modules/orchestration/workflows/workflow-fallback-policy.ts +0 -161
- package/server/modules/orchestration/workflows/workflow-replay.ts +0 -254
- package/server/modules/orchestration/workflows/workflow-runner.ts +0 -2062
- package/server/modules/orchestration/workflows/workflow-store.ts +0 -97
- package/server/modules/orchestration/workflows/workflow-templates.ts +0 -272
- package/server/modules/orchestration/workflows/workflow-trace.ts +0 -424
- package/server/modules/orchestration/workflows/workflow.routes.ts +0 -586
- package/server/modules/orchestration/workflows/workflow.types.ts +0 -111
- package/server/modules/orchestration/workflows/workspace-target.ts +0 -122
- package/server/modules/orchestration/workspace/docker-workspace.ts +0 -136
- package/server/modules/orchestration/workspace/path-safety.ts +0 -55
- package/server/modules/orchestration/workspace/types.ts +0 -52
- package/server/modules/orchestration/workspace/workspace-manager.ts +0 -102
- package/server/modules/orchestration/workspace/worktree-workspace.ts +0 -126
- /package/dist-server/server/modules/{orchestration/security → security}/permission-policy.js +0 -0
- /package/server/modules/{orchestration/security → security}/permission-policy.ts +0 -0
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs';
|
|
2
|
-
import { dirname, resolve } from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
|
|
5
|
-
export type WorkspaceTargetKind = 'selected_project' | 'pixcode_app' | 'custom';
|
|
6
|
-
|
|
7
|
-
export type ResolvedWorkspaceTarget = {
|
|
8
|
-
kind: WorkspaceTargetKind;
|
|
9
|
-
label: string;
|
|
10
|
-
projectPath: string;
|
|
11
|
-
selectedProjectPath?: string;
|
|
12
|
-
selectedProjectName?: string;
|
|
13
|
-
appRoot: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const pixcodePackageName = '@pixelbyte-software/pixcode';
|
|
17
|
-
|
|
18
|
-
function readRecord(value: unknown): Record<string, unknown> | undefined {
|
|
19
|
-
return value && typeof value === 'object' ? value as Record<string, unknown> : undefined;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function readString(value: unknown): string | undefined {
|
|
23
|
-
return typeof value === 'string' && value.trim() ? value.trim() : undefined;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function readTargetKind(value: unknown): WorkspaceTargetKind | undefined {
|
|
27
|
-
return value === 'selected_project' || value === 'pixcode_app' || value === 'custom'
|
|
28
|
-
? value
|
|
29
|
-
: undefined;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function findPixcodeAppRoot(): string {
|
|
33
|
-
let currentDir = dirname(fileURLToPath(import.meta.url));
|
|
34
|
-
|
|
35
|
-
for (let depth = 0; depth < 10; depth += 1) {
|
|
36
|
-
try {
|
|
37
|
-
const packagePath = resolve(currentDir, 'package.json');
|
|
38
|
-
const pkg = JSON.parse(readFileSync(packagePath, 'utf8')) as { name?: string };
|
|
39
|
-
if (pkg.name === pixcodePackageName) {
|
|
40
|
-
return currentDir;
|
|
41
|
-
}
|
|
42
|
-
} catch {
|
|
43
|
-
// Walk upward until the Pixcode package root is found.
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const parent = dirname(currentDir);
|
|
47
|
-
if (parent === currentDir) break;
|
|
48
|
-
currentDir = parent;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return process.cwd();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export function resolveWorkflowWorkspace(metadata?: Record<string, unknown>): ResolvedWorkspaceTarget {
|
|
55
|
-
const target = readRecord(metadata?.workspaceTarget);
|
|
56
|
-
const appRoot = findPixcodeAppRoot();
|
|
57
|
-
const selectedProjectPath = readString(metadata?.selectedProjectPath) ?? readString(metadata?.projectPath);
|
|
58
|
-
const selectedProjectName = readString(metadata?.projectName) ?? readString(metadata?.projectId);
|
|
59
|
-
const kind = readTargetKind(target?.kind) ?? 'selected_project';
|
|
60
|
-
const customPath = readString(target?.projectPath);
|
|
61
|
-
|
|
62
|
-
if (kind === 'pixcode_app') {
|
|
63
|
-
return {
|
|
64
|
-
kind,
|
|
65
|
-
label: 'Pixcode app',
|
|
66
|
-
projectPath: appRoot,
|
|
67
|
-
selectedProjectPath,
|
|
68
|
-
selectedProjectName,
|
|
69
|
-
appRoot,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (kind === 'custom') {
|
|
74
|
-
return {
|
|
75
|
-
kind,
|
|
76
|
-
label: readString(target?.label) ?? 'Custom workspace',
|
|
77
|
-
projectPath: customPath ?? selectedProjectPath ?? appRoot,
|
|
78
|
-
selectedProjectPath,
|
|
79
|
-
selectedProjectName,
|
|
80
|
-
appRoot,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return {
|
|
85
|
-
kind: 'selected_project',
|
|
86
|
-
label: selectedProjectName ?? 'Selected project',
|
|
87
|
-
projectPath: selectedProjectPath ?? appRoot,
|
|
88
|
-
selectedProjectPath,
|
|
89
|
-
selectedProjectName,
|
|
90
|
-
appRoot,
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export function workspaceTargetMetadata(target: ResolvedWorkspaceTarget): Record<string, unknown> {
|
|
95
|
-
return {
|
|
96
|
-
kind: target.kind,
|
|
97
|
-
label: target.label,
|
|
98
|
-
projectPath: target.projectPath,
|
|
99
|
-
selectedProjectPath: target.selectedProjectPath,
|
|
100
|
-
selectedProjectName: target.selectedProjectName,
|
|
101
|
-
appRoot: target.appRoot,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export function workspaceContextPrompt(target: ResolvedWorkspaceTarget): string {
|
|
106
|
-
return [
|
|
107
|
-
'Pixcode orchestration execution context:',
|
|
108
|
-
`- Target workspace: ${target.label}`,
|
|
109
|
-
`- Working directory for this agent: ${target.projectPath}`,
|
|
110
|
-
target.selectedProjectName ? `- Selected UI project: ${target.selectedProjectName}` : '',
|
|
111
|
-
target.selectedProjectPath ? `- Selected UI project path: ${target.selectedProjectPath}` : '',
|
|
112
|
-
`- Pixcode app root: ${target.appRoot}`,
|
|
113
|
-
'',
|
|
114
|
-
'Rules:',
|
|
115
|
-
'- Treat the working directory above as the authoritative project/application for this task.',
|
|
116
|
-
'- Do not guess another repository path unless the user explicitly asks for it.',
|
|
117
|
-
'- Do not access parent directories, sibling projects, or broad external globs outside the working directory unless the user explicitly asks.',
|
|
118
|
-
'- If the user asks to analyze or modify Pixcode/orchestration itself, the target workspace must be the Pixcode app root.',
|
|
119
|
-
'- Before running package-manager commands, inspect the package files in the working directory.',
|
|
120
|
-
'- If a tool reports a permission denial, summarize the limitation and continue from the provided context instead of retrying the same external path.',
|
|
121
|
-
].filter(Boolean).join('\n');
|
|
122
|
-
}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { WorkspaceError } from '@/modules/orchestration/workspace/types.js';
|
|
2
|
-
import type {
|
|
3
|
-
ExecResult,
|
|
4
|
-
WorkspaceHandle,
|
|
5
|
-
WorkspaceRequest,
|
|
6
|
-
} from '@/modules/orchestration/workspace/types.js';
|
|
7
|
-
|
|
8
|
-
async function run(
|
|
9
|
-
command: string,
|
|
10
|
-
args: string[],
|
|
11
|
-
): Promise<ExecResult> {
|
|
12
|
-
try {
|
|
13
|
-
const { execFile } = await import('node:child_process');
|
|
14
|
-
const { promisify } = await import('node:util');
|
|
15
|
-
const execFileAsync = promisify(execFile);
|
|
16
|
-
const { stdout, stderr } = await execFileAsync(command, args, {
|
|
17
|
-
maxBuffer: 20 * 1024 * 1024,
|
|
18
|
-
});
|
|
19
|
-
return { stdout: String(stdout), stderr: String(stderr), exitCode: 0 };
|
|
20
|
-
} catch (error) {
|
|
21
|
-
const err = error as Error & { stdout?: string; stderr?: string; code?: number };
|
|
22
|
-
return {
|
|
23
|
-
stdout: String(err.stdout ?? ''),
|
|
24
|
-
stderr: String(err.stderr ?? err.message),
|
|
25
|
-
exitCode: typeof err.code === 'number' ? err.code : 1,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export class DockerWorkspace implements WorkspaceHandle {
|
|
31
|
-
readonly kind = 'docker' as const;
|
|
32
|
-
readonly id: string;
|
|
33
|
-
readonly path: string;
|
|
34
|
-
readonly baseRef: string;
|
|
35
|
-
readonly metadata: Record<string, unknown>;
|
|
36
|
-
private containerId?: string;
|
|
37
|
-
private readonly worktreePath: string;
|
|
38
|
-
|
|
39
|
-
constructor(request: WorkspaceRequest) {
|
|
40
|
-
this.id = `docker_${request.taskId}`;
|
|
41
|
-
this.path = '/workspace';
|
|
42
|
-
this.baseRef = request.baseRef ?? 'HEAD';
|
|
43
|
-
this.worktreePath = request.projectPath;
|
|
44
|
-
this.metadata = {
|
|
45
|
-
...request.metadata,
|
|
46
|
-
image: request.metadata?.image ?? 'node:22-slim',
|
|
47
|
-
containerId: undefined,
|
|
48
|
-
exposedPorts: [],
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
private async ensureStarted(): Promise<void> {
|
|
53
|
-
if (this.containerId) return;
|
|
54
|
-
const image = String(this.metadata.image ?? 'node:22-slim');
|
|
55
|
-
const pullResult = await run('docker', ['pull', image]);
|
|
56
|
-
if (pullResult.exitCode !== 0) {
|
|
57
|
-
throw new WorkspaceError('WORKSPACE_DOCKER_PULL_FAILED', pullResult.stderr || pullResult.stdout, {
|
|
58
|
-
image,
|
|
59
|
-
workspaceId: this.id,
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
const createResult = await run('docker', [
|
|
63
|
-
'create',
|
|
64
|
-
'--rm',
|
|
65
|
-
'-v', `${this.worktreePath}:/workspace`,
|
|
66
|
-
'-w', '/workspace',
|
|
67
|
-
image,
|
|
68
|
-
'tail', '-f', '/dev/null',
|
|
69
|
-
]);
|
|
70
|
-
if (createResult.exitCode !== 0 || !createResult.stdout.trim()) {
|
|
71
|
-
throw new WorkspaceError('WORKSPACE_DOCKER_CREATE_FAILED', createResult.stderr || createResult.stdout, {
|
|
72
|
-
image,
|
|
73
|
-
workspaceId: this.id,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
this.containerId = createResult.stdout.trim();
|
|
77
|
-
const startResult = await run('docker', ['start', this.containerId]);
|
|
78
|
-
if (startResult.exitCode !== 0) {
|
|
79
|
-
await this.cleanupContainer();
|
|
80
|
-
throw new WorkspaceError('WORKSPACE_DOCKER_START_FAILED', startResult.stderr || startResult.stdout, {
|
|
81
|
-
containerId: this.containerId,
|
|
82
|
-
workspaceId: this.id,
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
this.metadata.containerId = this.containerId;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
private async cleanupContainer(): Promise<void> {
|
|
89
|
-
if (!this.containerId) return;
|
|
90
|
-
await run('docker', ['rm', '-f', this.containerId]).catch(() => {});
|
|
91
|
-
this.containerId = undefined;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async exec(command: string, args: string[] = []): Promise<ExecResult> {
|
|
95
|
-
await this.ensureStarted();
|
|
96
|
-
return run('docker', ['exec', this.containerId!, command, ...args]);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async readFile(relativePath: string): Promise<string> {
|
|
100
|
-
await this.ensureStarted();
|
|
101
|
-
const result = await run('docker', ['exec', this.containerId!, 'cat', relativePath]);
|
|
102
|
-
if (result.exitCode !== 0) {
|
|
103
|
-
throw new WorkspaceError('WORKSPACE_READ_FAILED', result.stderr, { path: relativePath });
|
|
104
|
-
}
|
|
105
|
-
return result.stdout;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async writeFile(relativePath: string, content: string): Promise<void> {
|
|
109
|
-
await this.ensureStarted();
|
|
110
|
-
const result = await run('docker', ['exec', this.containerId!, 'sh', '-c', `cat > ${relativePath}`]);
|
|
111
|
-
if (result.exitCode !== 0) {
|
|
112
|
-
throw new WorkspaceError('WORKSPACE_WRITE_FAILED', result.stderr, { path: relativePath });
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async diff(): Promise<string> {
|
|
117
|
-
const { execFile } = await import('node:child_process');
|
|
118
|
-
const { promisify } = await import('node:util');
|
|
119
|
-
const execFileAsync = promisify(execFile);
|
|
120
|
-
try {
|
|
121
|
-
const { stdout } = await execFileAsync('git', ['diff', `${this.baseRef}...HEAD`], {
|
|
122
|
-
cwd: this.worktreePath,
|
|
123
|
-
maxBuffer: 20 * 1024 * 1024,
|
|
124
|
-
});
|
|
125
|
-
return String(stdout);
|
|
126
|
-
} catch (error) {
|
|
127
|
-
const err = error as Error & { stderr?: string };
|
|
128
|
-
const output = String(err.stderr ?? err.message);
|
|
129
|
-
return /not a git repository|usage: git diff --no-index/i.test(output) ? '' : output;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
async destroy(): Promise<void> {
|
|
134
|
-
await this.cleanupContainer();
|
|
135
|
-
}
|
|
136
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import os from 'node:os';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
|
|
5
|
-
import { WorkspaceError } from '@/modules/orchestration/workspace/types.js';
|
|
6
|
-
|
|
7
|
-
const SAFE_ID = /^[a-zA-Z0-9_-]+$/;
|
|
8
|
-
|
|
9
|
-
export function getWorktreesRoot(): string {
|
|
10
|
-
return process.env.PIXCODE_WORKTREES_ROOT ?? path.join(os.homedir(), '.pixcode', 'worktrees');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function assertSafeId(value: string, label: string): string {
|
|
14
|
-
if (!SAFE_ID.test(value) || value.includes('..')) {
|
|
15
|
-
throw new WorkspaceError('UNSAFE_WORKSPACE_ID', `Unsafe ${label}: ${value}`, { value, label });
|
|
16
|
-
}
|
|
17
|
-
return value;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function ensureDirectory(dir: string): void {
|
|
21
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function safeWorkspacePath(workspaceId: string): string {
|
|
25
|
-
assertSafeId(workspaceId, 'workspace id');
|
|
26
|
-
const root = getWorktreesRoot();
|
|
27
|
-
ensureDirectory(root);
|
|
28
|
-
const resolvedRoot = fs.realpathSync.native(root);
|
|
29
|
-
const target = path.resolve(resolvedRoot, workspaceId);
|
|
30
|
-
if (!target.startsWith(`${resolvedRoot}${path.sep}`)) {
|
|
31
|
-
throw new WorkspaceError('WORKSPACE_PATH_TRAVERSAL', 'Workspace path escaped root', {
|
|
32
|
-
root: resolvedRoot,
|
|
33
|
-
target,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return target;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function safeJoin(root: string, relativePath: string): string {
|
|
40
|
-
if (path.isAbsolute(relativePath) || relativePath.includes('\0')) {
|
|
41
|
-
throw new WorkspaceError('WORKSPACE_PATH_TRAVERSAL', 'Workspace file path must be relative', {
|
|
42
|
-
relativePath,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const target = path.resolve(root, relativePath);
|
|
47
|
-
const resolvedRoot = fs.existsSync(root) ? fs.realpathSync.native(root) : path.resolve(root);
|
|
48
|
-
if (!target.startsWith(`${resolvedRoot}${path.sep}`) && target !== resolvedRoot) {
|
|
49
|
-
throw new WorkspaceError('WORKSPACE_PATH_TRAVERSAL', 'Workspace file path escaped root', {
|
|
50
|
-
root: resolvedRoot,
|
|
51
|
-
target,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
return target;
|
|
55
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { ExecFileOptions } from 'node:child_process';
|
|
2
|
-
|
|
3
|
-
export type WorkspaceKind = 'host' | 'worktree' | 'docker';
|
|
4
|
-
|
|
5
|
-
export interface ExecResult {
|
|
6
|
-
stdout: string;
|
|
7
|
-
stderr: string;
|
|
8
|
-
exitCode: number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface WorkspaceHandle {
|
|
12
|
-
id: string;
|
|
13
|
-
kind: WorkspaceKind;
|
|
14
|
-
path: string;
|
|
15
|
-
baseRef: string;
|
|
16
|
-
branchName?: string;
|
|
17
|
-
metadata: Record<string, unknown>;
|
|
18
|
-
exec(command: string, args?: string[], options?: ExecFileOptions): Promise<ExecResult>;
|
|
19
|
-
readFile(relativePath: string): Promise<string>;
|
|
20
|
-
writeFile(relativePath: string, content: string): Promise<void>;
|
|
21
|
-
diff(): Promise<string>;
|
|
22
|
-
destroy(): Promise<void>;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface WorkspaceRequest {
|
|
26
|
-
taskId: string;
|
|
27
|
-
projectPath: string;
|
|
28
|
-
kind?: WorkspaceKind;
|
|
29
|
-
baseRef?: string;
|
|
30
|
-
keepAfterCompletion?: boolean;
|
|
31
|
-
metadata?: Record<string, unknown>;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface WorkspaceMetadata {
|
|
35
|
-
id: string;
|
|
36
|
-
kind: WorkspaceKind;
|
|
37
|
-
path: string;
|
|
38
|
-
baseRef: string;
|
|
39
|
-
branchName?: string;
|
|
40
|
-
keepAfterCompletion?: boolean;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export class WorkspaceError extends Error {
|
|
44
|
-
constructor(
|
|
45
|
-
public readonly code: string,
|
|
46
|
-
message: string,
|
|
47
|
-
public readonly details: Record<string, unknown> = {},
|
|
48
|
-
) {
|
|
49
|
-
super(message);
|
|
50
|
-
this.name = 'WorkspaceError';
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
|
|
4
|
-
import { DockerWorkspace } from '@/modules/orchestration/workspace/docker-workspace.js';
|
|
5
|
-
import { safeJoin } from '@/modules/orchestration/workspace/path-safety.js';
|
|
6
|
-
import type {
|
|
7
|
-
ExecResult,
|
|
8
|
-
WorkspaceHandle,
|
|
9
|
-
WorkspaceKind,
|
|
10
|
-
WorkspaceRequest,
|
|
11
|
-
} from '@/modules/orchestration/workspace/types.js';
|
|
12
|
-
import { WorktreeWorkspace } from '@/modules/orchestration/workspace/worktree-workspace.js';
|
|
13
|
-
|
|
14
|
-
class HostWorkspace implements WorkspaceHandle {
|
|
15
|
-
readonly kind = 'host' as const;
|
|
16
|
-
readonly id: string;
|
|
17
|
-
readonly path: string;
|
|
18
|
-
readonly baseRef: string;
|
|
19
|
-
readonly metadata: Record<string, unknown>;
|
|
20
|
-
|
|
21
|
-
constructor(request: WorkspaceRequest) {
|
|
22
|
-
this.id = `host_${request.taskId}`;
|
|
23
|
-
this.path = request.projectPath;
|
|
24
|
-
this.baseRef = request.baseRef ?? 'HEAD';
|
|
25
|
-
this.metadata = { ...request.metadata, keepAfterCompletion: true };
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async exec(command: string, args: string[] = []): Promise<ExecResult> {
|
|
29
|
-
const { execFile } = await import('node:child_process');
|
|
30
|
-
const { promisify } = await import('node:util');
|
|
31
|
-
const execFileAsync = promisify(execFile);
|
|
32
|
-
try {
|
|
33
|
-
const { stdout, stderr } = await execFileAsync(command, args, {
|
|
34
|
-
cwd: this.path,
|
|
35
|
-
maxBuffer: 20 * 1024 * 1024,
|
|
36
|
-
});
|
|
37
|
-
return { stdout: String(stdout), stderr: String(stderr), exitCode: 0 };
|
|
38
|
-
} catch (error) {
|
|
39
|
-
const err = error as Error & { stdout?: string; stderr?: string; code?: number };
|
|
40
|
-
return {
|
|
41
|
-
stdout: String(err.stdout ?? ''),
|
|
42
|
-
stderr: String(err.stderr ?? err.message),
|
|
43
|
-
exitCode: typeof err.code === 'number' ? err.code : 1,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async readFile(relativePath: string): Promise<string> {
|
|
49
|
-
return fs.promises.readFile(safeJoin(this.path, relativePath), 'utf8');
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async writeFile(relativePath: string, content: string): Promise<void> {
|
|
53
|
-
const target = safeJoin(this.path, relativePath);
|
|
54
|
-
await fs.promises.mkdir(path.dirname(target), { recursive: true });
|
|
55
|
-
await fs.promises.writeFile(target, content, 'utf8');
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
async diff(): Promise<string> {
|
|
59
|
-
const insideWorkTree = await this.exec('git', ['rev-parse', '--is-inside-work-tree']);
|
|
60
|
-
if (insideWorkTree.exitCode !== 0 || insideWorkTree.stdout.trim() !== 'true') {
|
|
61
|
-
return '';
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const result = await this.exec('git', ['diff', `${this.baseRef}...HEAD`]);
|
|
65
|
-
return result.exitCode === 0 ? result.stdout : result.stderr || result.stdout;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
destroy(): Promise<void> {
|
|
69
|
-
return Promise.resolve();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function readKind(value: unknown): WorkspaceKind {
|
|
74
|
-
return value === 'host' || value === 'docker' || value === 'worktree' ? value : 'worktree';
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
class WorkspaceManager {
|
|
78
|
-
async create(request: WorkspaceRequest): Promise<WorkspaceHandle> {
|
|
79
|
-
const kind = readKind(request.kind);
|
|
80
|
-
if (kind === 'host') {
|
|
81
|
-
return new HostWorkspace(request);
|
|
82
|
-
}
|
|
83
|
-
if (kind === 'docker') {
|
|
84
|
-
return new DockerWorkspace(request);
|
|
85
|
-
}
|
|
86
|
-
return WorktreeWorkspace.create(request);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
recover(request: WorkspaceRequest): WorkspaceHandle {
|
|
90
|
-
return new HostWorkspace({
|
|
91
|
-
...request,
|
|
92
|
-
kind: 'host',
|
|
93
|
-
metadata: {
|
|
94
|
-
...request.metadata,
|
|
95
|
-
recovered: true,
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export const workspaceManager = new WorkspaceManager();
|
|
102
|
-
export type { WorkspaceManager };
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { execFile } from 'node:child_process';
|
|
2
|
-
import fs from 'node:fs/promises';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { promisify } from 'node:util';
|
|
5
|
-
|
|
6
|
-
import { assertSafeId, safeJoin, safeWorkspacePath } from '@/modules/orchestration/workspace/path-safety.js';
|
|
7
|
-
import type {
|
|
8
|
-
ExecResult,
|
|
9
|
-
WorkspaceHandle,
|
|
10
|
-
WorkspaceRequest,
|
|
11
|
-
} from '@/modules/orchestration/workspace/types.js';
|
|
12
|
-
import { WorkspaceError } from '@/modules/orchestration/workspace/types.js';
|
|
13
|
-
|
|
14
|
-
const execFileAsync = promisify(execFile);
|
|
15
|
-
|
|
16
|
-
async function run(
|
|
17
|
-
command: string,
|
|
18
|
-
args: string[],
|
|
19
|
-
cwd: string,
|
|
20
|
-
): Promise<ExecResult> {
|
|
21
|
-
try {
|
|
22
|
-
const { stdout, stderr } = await execFileAsync(command, args, {
|
|
23
|
-
cwd,
|
|
24
|
-
maxBuffer: 20 * 1024 * 1024,
|
|
25
|
-
});
|
|
26
|
-
return {
|
|
27
|
-
stdout: String(stdout),
|
|
28
|
-
stderr: String(stderr),
|
|
29
|
-
exitCode: 0,
|
|
30
|
-
};
|
|
31
|
-
} catch (error) {
|
|
32
|
-
const err = error as Error & {
|
|
33
|
-
stdout?: string | Buffer;
|
|
34
|
-
stderr?: string | Buffer;
|
|
35
|
-
code?: number;
|
|
36
|
-
};
|
|
37
|
-
return {
|
|
38
|
-
stdout: String(err.stdout ?? ''),
|
|
39
|
-
stderr: String(err.stderr ?? err.message),
|
|
40
|
-
exitCode: typeof err.code === 'number' ? err.code : 1,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export class WorktreeWorkspace implements WorkspaceHandle {
|
|
46
|
-
readonly kind = 'worktree' as const;
|
|
47
|
-
readonly id: string;
|
|
48
|
-
readonly path: string;
|
|
49
|
-
readonly baseRef: string;
|
|
50
|
-
readonly branchName: string;
|
|
51
|
-
readonly metadata: Record<string, unknown>;
|
|
52
|
-
private readonly projectPath: string;
|
|
53
|
-
|
|
54
|
-
private constructor(request: WorkspaceRequest, workspaceId: string, branchName: string) {
|
|
55
|
-
this.id = workspaceId;
|
|
56
|
-
this.path = safeWorkspacePath(workspaceId);
|
|
57
|
-
this.baseRef = request.baseRef ?? 'HEAD';
|
|
58
|
-
this.branchName = branchName;
|
|
59
|
-
this.projectPath = request.projectPath;
|
|
60
|
-
this.metadata = {
|
|
61
|
-
...request.metadata,
|
|
62
|
-
keepAfterCompletion: request.keepAfterCompletion === true,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
static async create(request: WorkspaceRequest): Promise<WorktreeWorkspace> {
|
|
67
|
-
assertSafeId(request.taskId, 'task id');
|
|
68
|
-
const workspaceId = `ws_${request.taskId}`;
|
|
69
|
-
const branchName = `pixcode/task_${request.taskId}`;
|
|
70
|
-
const workspace = new WorktreeWorkspace(request, workspaceId, branchName);
|
|
71
|
-
|
|
72
|
-
const existingBranch = await run('git', ['rev-parse', '--verify', branchName], request.projectPath);
|
|
73
|
-
if (existingBranch.exitCode === 0) {
|
|
74
|
-
throw new WorkspaceError('WORKSPACE_EXISTS', `Workspace branch already exists: ${branchName}`, {
|
|
75
|
-
branchName,
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const result = await run(
|
|
80
|
-
'git',
|
|
81
|
-
['worktree', 'add', workspace.path, '-b', branchName, workspace.baseRef],
|
|
82
|
-
request.projectPath,
|
|
83
|
-
);
|
|
84
|
-
if (result.exitCode !== 0) {
|
|
85
|
-
throw new WorkspaceError('WORKSPACE_CREATE_FAILED', result.stderr || result.stdout, {
|
|
86
|
-
stdout: result.stdout,
|
|
87
|
-
stderr: result.stderr,
|
|
88
|
-
baseRef: workspace.baseRef,
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return workspace;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
exec(command: string, args: string[] = []): Promise<ExecResult> {
|
|
96
|
-
return run(command, args, this.path);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async readFile(relativePath: string): Promise<string> {
|
|
100
|
-
return fs.readFile(safeJoin(this.path, relativePath), 'utf8');
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
async writeFile(relativePath: string, content: string): Promise<void> {
|
|
104
|
-
const target = safeJoin(this.path, relativePath);
|
|
105
|
-
await fs.mkdir(path.dirname(target), { recursive: true });
|
|
106
|
-
await fs.writeFile(target, content, 'utf8');
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
async diff(): Promise<string> {
|
|
110
|
-
const result = await run('git', ['diff', `${this.baseRef}...HEAD`], this.path);
|
|
111
|
-
if (result.exitCode !== 0) {
|
|
112
|
-
const output = result.stderr || result.stdout;
|
|
113
|
-
return /not a git repository|usage: git diff --no-index/i.test(output) ? '' : output;
|
|
114
|
-
}
|
|
115
|
-
return result.stdout;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
async destroy(): Promise<void> {
|
|
119
|
-
const result = await run('git', ['worktree', 'remove', '--force', this.path], this.projectPath);
|
|
120
|
-
if (result.exitCode !== 0) {
|
|
121
|
-
throw new WorkspaceError('WORKSPACE_DESTROY_FAILED', result.stderr || result.stdout, {
|
|
122
|
-
workspacePath: this.path,
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
/package/dist-server/server/modules/{orchestration/security → security}/permission-policy.js
RENAMED
|
File without changes
|
|
File without changes
|