@pixelbyte-software/pixcode 1.51.2 → 1.51.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CODE_OF_CONDUCT.md +41 -41
- package/CONTRIBUTING.md +155 -155
- package/LICENSE +718 -718
- package/README.de.md +169 -169
- package/README.ja.md +167 -167
- package/README.ko.md +167 -167
- package/README.md +419 -419
- package/README.ru.md +169 -169
- package/README.tr.md +298 -298
- package/README.zh-CN.md +167 -167
- package/SECURITY.md +46 -46
- package/dist/api-automation.html +110 -110
- package/dist/api-docs.html +548 -548
- package/dist/assets/{index-EN9ngyxf.js → index-17CwxHSZ.js} +185 -185
- package/dist/assets/index-B9N-gfOQ.css +32 -0
- package/dist/clear-cache.html +85 -85
- package/dist/convert-icons.md +52 -52
- package/dist/docs.html +308 -308
- package/dist/favicon.svg +8 -8
- package/dist/features.html +133 -133
- package/dist/generate-icons.js +48 -48
- package/dist/humans.txt +15 -15
- package/dist/icons/codex-white.svg +3 -3
- package/dist/icons/codex.svg +3 -3
- package/dist/icons/cursor-white.svg +11 -11
- package/dist/icons/icon-128x128.svg +9 -9
- package/dist/icons/icon-144x144.svg +9 -9
- package/dist/icons/icon-152x152.svg +9 -9
- package/dist/icons/icon-192x192.svg +9 -9
- package/dist/icons/icon-384x384.svg +9 -9
- package/dist/icons/icon-512x512.svg +9 -9
- package/dist/icons/icon-72x72.svg +9 -9
- package/dist/icons/icon-96x96.svg +9 -9
- package/dist/icons/icon-template.svg +9 -9
- package/dist/icons/qwen-logo.svg +14 -14
- package/dist/index.html +59 -59
- package/dist/landing.html +268 -268
- package/dist/llms-full.txt +119 -119
- package/dist/llms.txt +53 -53
- package/dist/logo.svg +12 -12
- package/dist/manifest.json +60 -60
- package/dist/openapi.yaml +1696 -1696
- package/dist/orchestration.html +125 -125
- package/dist/robots.txt +4 -4
- package/dist/site.css +692 -692
- package/dist/sitemap.xml +51 -51
- package/dist/sw.js +132 -132
- package/dist-server/server/cli.js +96 -96
- package/dist-server/server/daemon/manager.js +33 -33
- package/dist-server/server/daemon-manager.js +64 -64
- package/dist-server/server/index.js +122 -3
- package/dist-server/server/index.js.map +1 -1
- package/dist-server/server/modules/orchestration/a2a/adapters/json-event.adapter.js +84 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/json-event.adapter.js.map +1 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/json-event.adapter.test.js +43 -0
- package/dist-server/server/modules/orchestration/a2a/adapters/json-event.adapter.test.js.map +1 -0
- package/dist-server/server/modules/orchestration/hermes/hermes.routes.js +55 -1
- package/dist-server/server/modules/orchestration/hermes/hermes.routes.js.map +1 -1
- package/dist-server/server/modules/orchestration/index.js +1 -0
- package/dist-server/server/modules/orchestration/index.js.map +1 -1
- package/dist-server/server/routes/commands.js +25 -25
- package/dist-server/server/routes/git.js +17 -17
- package/dist-server/server/routes/live-view.js +46 -46
- package/dist-server/server/services/hermes-gateway.js +310 -0
- package/dist-server/server/services/hermes-gateway.js.map +1 -1
- package/dist-server/server/services/public-api-manifest.js +59 -51
- package/dist-server/server/services/public-api-manifest.js.map +1 -1
- package/package.json +222 -222
- package/scripts/fix-node-pty.js +67 -67
- package/scripts/github/create-v1.38-issues.mjs +351 -351
- package/scripts/github/create-vscode-workbench-issues.mjs +121 -121
- package/scripts/hermes/configure-pixcode-mcp.mjs +165 -163
- package/scripts/hermes/pixcode-mcp-server.mjs +1009 -958
- package/scripts/smoke/changes-panel-layout.mjs +48 -48
- package/scripts/smoke/chat-composer-fixed-layout.mjs +55 -55
- package/scripts/smoke/chat-message-timeline-order.mjs +41 -41
- package/scripts/smoke/chat-realtime-hydration.mjs +44 -44
- package/scripts/smoke/chat-session-provider-pools.mjs +35 -35
- package/scripts/smoke/chat-session-state.mjs +19 -19
- package/scripts/smoke/code-editor-theme.mjs +55 -55
- package/scripts/smoke/code-editor-vscode-engine.mjs +91 -91
- package/scripts/smoke/command-center-agent-writes.mjs +79 -79
- package/scripts/smoke/command-center-non-git.mjs +46 -46
- package/scripts/smoke/context-packet.mjs +43 -43
- package/scripts/smoke/control-room-ux-redesign.mjs +91 -91
- package/scripts/smoke/daemon-entrypoint.mjs +20 -20
- package/scripts/smoke/default-landing-routing.mjs +33 -33
- package/scripts/smoke/desktop-native-notifications.mjs +30 -30
- package/scripts/smoke/desktop-tray-icon.mjs +33 -33
- package/scripts/smoke/discord-release-workflow.mjs +24 -24
- package/scripts/smoke/git-install-update.mjs +255 -255
- package/scripts/smoke/handoff-artifact-protocol.mjs +50 -50
- package/scripts/smoke/hermes-api-install.mjs +56 -56
- package/scripts/smoke/hermes-gateway-persistence.mjs +104 -104
- package/scripts/smoke/hermes-mcp-pixcode-roundtrip.mjs +426 -367
- package/scripts/smoke/hermes-rest-chat-api.mjs +162 -162
- package/scripts/smoke/hermes-rest-chat-live.mjs +45 -45
- package/scripts/smoke/hermes-rest-codex-launch.mjs +209 -209
- package/scripts/smoke/hermes-rest-gateway.mjs +79 -70
- package/scripts/smoke/hermes-rest-live.mjs +42 -42
- package/scripts/smoke/hermes-roundtrip.mjs +167 -167
- package/scripts/smoke/hermes-settings-commands.mjs +349 -346
- package/scripts/smoke/hermes-smoke-launcher-guard.mjs +34 -34
- package/scripts/smoke/live-view-diagnostics.mjs +53 -53
- package/scripts/smoke/live-view-environment.mjs +92 -92
- package/scripts/smoke/live-view-integration.mjs +450 -450
- package/scripts/smoke/mac-desktop-runtime.mjs +37 -37
- package/scripts/smoke/mobile-tunnel-guidance.mjs +29 -29
- package/scripts/smoke/model-registry.mjs +36 -36
- package/scripts/smoke/multi-project-ui.mjs +45 -45
- package/scripts/smoke/multi-worker-slots.mjs +42 -42
- package/scripts/smoke/notification-center.mjs +87 -87
- package/scripts/smoke/notification-inapp-preference.mjs +23 -23
- package/scripts/smoke/notification-taxonomy.mjs +58 -58
- package/scripts/smoke/orchestration-api.mjs +172 -172
- package/scripts/smoke/orchestration-execution-dashboard.mjs +33 -33
- package/scripts/smoke/orchestration-live-run.mjs +176 -176
- package/scripts/smoke/orchestration-mobile-scroll.mjs +29 -29
- package/scripts/smoke/orchestration-model-sync.mjs +30 -30
- package/scripts/smoke/orchestration-permission-fallback.mjs +34 -34
- package/scripts/smoke/orchestration-runtime-guards.mjs +48 -48
- package/scripts/smoke/orchestration-user-facing-output.mjs +25 -25
- package/scripts/smoke/permission-policy.mjs +50 -50
- package/scripts/smoke/pixcode-workbench-1-48.mjs +167 -167
- package/scripts/smoke/provider-models-opencode-live.mjs +66 -66
- package/scripts/smoke/provider-rest-api.mjs +124 -124
- package/scripts/smoke/provider-selection-status.mjs +52 -52
- package/scripts/smoke/run-state-refresh.mjs +52 -52
- package/scripts/smoke/runtime-manager.mjs +99 -99
- package/scripts/smoke/shell-manual-disconnect.mjs +30 -30
- package/scripts/smoke/side-panel-editor-layout.mjs +34 -34
- package/scripts/smoke/static-root-routing.mjs +21 -21
- package/scripts/smoke/strict-handoff-compact.mjs +60 -60
- package/scripts/smoke/taskmaster-config.mjs +24 -24
- package/scripts/smoke/taskmaster-execution-telegram.mjs +3 -3
- package/scripts/smoke/taskmaster-onboarding.mjs +3 -3
- package/scripts/smoke/taskmaster-run-graph.mjs +3 -3
- package/scripts/smoke/telegram-control.mjs +242 -242
- package/scripts/smoke/tunnel-persistence.mjs +56 -56
- package/scripts/smoke/update-issue-progress.mjs +69 -69
- package/scripts/smoke/update-ux.mjs +55 -55
- package/scripts/smoke/v138-completion.mjs +132 -132
- package/scripts/smoke/v138-desktop-release-hardening.mjs +69 -69
- package/scripts/smoke/v138-diagnostics.mjs +63 -63
- package/scripts/smoke/v138-issue-planner.mjs +33 -33
- package/scripts/smoke/v143-remote-control.mjs +76 -76
- package/scripts/smoke/v144-production-loop.mjs +47 -47
- package/scripts/smoke/v145-platformization.mjs +46 -46
- package/scripts/smoke/v146-control-room-ui.mjs +150 -150
- package/scripts/smoke/version-modal-autoshow.mjs +29 -29
- package/scripts/smoke/vscode-workbench-layout.mjs +63 -63
- package/scripts/smoke/vscode-workbench-polish.mjs +461 -436
- package/scripts/smoke/workflow-fallback-replay.mjs +56 -56
- package/scripts/smoke/workflow-templates.mjs +43 -43
- package/scripts/smoke/workflow-trace-timeline.mjs +46 -46
- package/scripts/update-git-install.mjs +293 -293
- package/server/claude-sdk.js +920 -920
- package/server/cli.js +1039 -1039
- package/server/constants/config.js +4 -4
- package/server/cursor-cli.js +344 -344
- package/server/daemon/manager.js +563 -563
- package/server/daemon-manager.js +964 -964
- package/server/database/db.js +921 -921
- package/server/database/json-store.js +197 -197
- package/server/gemini-cli.js +550 -550
- package/server/gemini-response-handler.js +79 -79
- package/server/index.js +128 -2
- package/server/load-env.js +35 -35
- package/server/middleware/auth.js +175 -175
- package/server/modules/orchestration/a2a/adapter-registry.ts +108 -108
- package/server/modules/orchestration/a2a/adapters/abstract-a2a.adapter.ts +63 -63
- package/server/modules/orchestration/a2a/adapters/claude-code.adapter.ts +286 -286
- package/server/modules/orchestration/a2a/adapters/codex.adapter.ts +244 -244
- package/server/modules/orchestration/a2a/adapters/cursor.adapter.ts +249 -249
- package/server/modules/orchestration/a2a/adapters/gemini.adapter.ts +248 -248
- package/server/modules/orchestration/a2a/adapters/json-event.adapter.test.ts +60 -0
- package/server/modules/orchestration/a2a/adapters/json-event.adapter.ts +101 -0
- package/server/modules/orchestration/a2a/adapters/opencode.adapter.ts +248 -248
- package/server/modules/orchestration/a2a/adapters/qwen.adapter.ts +248 -248
- package/server/modules/orchestration/a2a/agent-card.ts +55 -55
- package/server/modules/orchestration/a2a/routes.ts +590 -590
- package/server/modules/orchestration/a2a/task-store.ts +178 -178
- package/server/modules/orchestration/a2a/types.ts +126 -126
- package/server/modules/orchestration/a2a/validator.ts +113 -113
- package/server/modules/orchestration/hermes/hermes.routes.ts +642 -583
- package/server/modules/orchestration/index.ts +101 -100
- package/server/modules/orchestration/preview/port-watcher.ts +112 -112
- package/server/modules/orchestration/preview/preview-proxy.ts +60 -60
- package/server/modules/orchestration/preview/types.ts +19 -19
- package/server/modules/orchestration/security/permission-policy.ts +401 -401
- package/server/modules/orchestration/tasks/orchestration-task-store.ts +41 -41
- package/server/modules/orchestration/tasks/orchestration-task.routes.ts +64 -64
- package/server/modules/orchestration/tasks/orchestration-task.service.ts +209 -209
- package/server/modules/orchestration/tasks/orchestration-task.types.ts +40 -40
- package/server/modules/orchestration/tasks/task-run-graph.ts +155 -155
- package/server/modules/orchestration/workflows/approval-queue.ts +106 -106
- package/server/modules/orchestration/workflows/built-in-workflows.ts +127 -127
- package/server/modules/orchestration/workflows/context-packet.ts +186 -186
- package/server/modules/orchestration/workflows/handoff-artifact.ts +175 -175
- package/server/modules/orchestration/workflows/workflow-fallback-policy.ts +161 -161
- package/server/modules/orchestration/workflows/workflow-replay.ts +254 -254
- package/server/modules/orchestration/workflows/workflow-runner.ts +2070 -2070
- package/server/modules/orchestration/workflows/workflow-store.ts +97 -97
- package/server/modules/orchestration/workflows/workflow-templates.ts +272 -272
- package/server/modules/orchestration/workflows/workflow-trace.ts +424 -424
- package/server/modules/orchestration/workflows/workflow.routes.ts +586 -586
- package/server/modules/orchestration/workflows/workflow.types.ts +111 -111
- package/server/modules/orchestration/workflows/workspace-target.ts +122 -122
- package/server/modules/orchestration/workspace/docker-workspace.ts +136 -136
- package/server/modules/orchestration/workspace/path-safety.ts +55 -55
- package/server/modules/orchestration/workspace/types.ts +52 -52
- package/server/modules/orchestration/workspace/workspace-manager.ts +102 -102
- package/server/modules/orchestration/workspace/worktree-workspace.ts +126 -126
- package/server/modules/providers/index.ts +2 -2
- package/server/modules/providers/list/claude/claude-auth.provider.ts +146 -146
- package/server/modules/providers/list/claude/claude-mcp.provider.ts +135 -135
- package/server/modules/providers/list/claude/claude-sessions.provider.ts +306 -306
- package/server/modules/providers/list/claude/claude.provider.ts +15 -15
- package/server/modules/providers/list/codex/codex-auth.provider.ts +117 -117
- package/server/modules/providers/list/codex/codex-mcp.provider.ts +135 -135
- package/server/modules/providers/list/codex/codex-sessions.provider.ts +319 -319
- package/server/modules/providers/list/codex/codex.provider.ts +15 -15
- package/server/modules/providers/list/cursor/cursor-auth.provider.ts +147 -147
- package/server/modules/providers/list/cursor/cursor-mcp.provider.ts +108 -108
- package/server/modules/providers/list/cursor/cursor-sessions.provider.ts +421 -421
- package/server/modules/providers/list/cursor/cursor.provider.ts +15 -15
- package/server/modules/providers/list/gemini/gemini-auth.provider.ts +173 -173
- package/server/modules/providers/list/gemini/gemini-mcp.provider.ts +110 -110
- package/server/modules/providers/list/gemini/gemini-sessions.provider.ts +227 -227
- package/server/modules/providers/list/gemini/gemini.provider.ts +15 -15
- package/server/modules/providers/list/opencode/opencode-auth.provider.ts +131 -131
- package/server/modules/providers/list/opencode/opencode-mcp.provider.ts +126 -126
- package/server/modules/providers/list/opencode/opencode-sessions.provider.ts +286 -286
- package/server/modules/providers/list/opencode/opencode.provider.ts +29 -29
- package/server/modules/providers/list/qwen/qwen-auth.provider.ts +146 -146
- package/server/modules/providers/list/qwen/qwen-mcp.provider.ts +114 -114
- package/server/modules/providers/list/qwen/qwen-sessions.provider.ts +265 -265
- package/server/modules/providers/list/qwen/qwen.provider.ts +21 -21
- package/server/modules/providers/provider.registry.ts +40 -40
- package/server/modules/providers/provider.routes.ts +944 -944
- package/server/modules/providers/services/mcp.service.ts +86 -86
- package/server/modules/providers/services/provider-auth.service.ts +26 -26
- package/server/modules/providers/services/sessions.service.ts +45 -45
- package/server/modules/providers/shared/base/abstract.provider.ts +20 -20
- package/server/modules/providers/shared/mcp/mcp.provider.ts +151 -151
- package/server/modules/providers/shared/provider-configs.ts +142 -142
- package/server/modules/providers/tests/mcp.test.ts +293 -293
- package/server/openai-codex.js +462 -462
- package/server/opencode-cli.js +491 -491
- package/server/opencode-response-handler.js +111 -111
- package/server/projects.js +3008 -3008
- package/server/qwen-code-cli.js +410 -410
- package/server/qwen-response-handler.js +73 -73
- package/server/routes/agent.js +1435 -1435
- package/server/routes/auth.js +159 -159
- package/server/routes/codex.js +20 -20
- package/server/routes/commands.js +570 -570
- package/server/routes/cursor.js +61 -61
- package/server/routes/diagnostics.js +41 -41
- package/server/routes/gemini.js +25 -25
- package/server/routes/git.js +1650 -1650
- package/server/routes/live-view.js +411 -411
- package/server/routes/mcp-utils.js +13 -13
- package/server/routes/messages.js +62 -62
- package/server/routes/network.js +125 -125
- package/server/routes/platformization.js +212 -212
- package/server/routes/plugins.js +320 -320
- package/server/routes/production-agent-loop.js +90 -90
- package/server/routes/projects.js +917 -917
- package/server/routes/public-api.js +34 -34
- package/server/routes/qwen.js +27 -27
- package/server/routes/remote.js +55 -55
- package/server/routes/settings.js +321 -321
- package/server/routes/telegram.js +140 -140
- package/server/routes/user.js +125 -125
- package/server/routes/webhooks.js +63 -63
- package/server/services/control-room.js +102 -102
- package/server/services/diagnostics.js +165 -165
- package/server/services/external-access.js +375 -375
- package/server/services/hermes-gateway.js +1562 -1247
- package/server/services/hermes-install-jobs.js +729 -729
- package/server/services/install-jobs.js +715 -715
- package/server/services/live-view.js +956 -956
- package/server/services/managed-runtimes.js +493 -493
- package/server/services/model-registry.js +144 -144
- package/server/services/notification-orchestrator.js +365 -365
- package/server/services/notification-taxonomy.js +204 -204
- package/server/services/platformization.js +815 -815
- package/server/services/production-agent-loop.js +248 -248
- package/server/services/provider-cli-versions.js +149 -149
- package/server/services/provider-credentials.js +189 -189
- package/server/services/provider-models.js +396 -396
- package/server/services/public-api-manifest.js +190 -182
- package/server/services/remote-connection.js +127 -127
- package/server/services/runtime-manager.js +323 -323
- package/server/services/startup-update.js +234 -234
- package/server/services/telegram/bot.js +331 -331
- package/server/services/telegram/control-center.js +979 -979
- package/server/services/telegram/telegram-http-client.js +151 -151
- package/server/services/telegram/translations.js +340 -340
- package/server/services/vapid-keys.js +36 -36
- package/server/services/webhooks.js +216 -216
- package/server/sessionManager.js +225 -225
- package/server/shared/interfaces.ts +54 -54
- package/server/shared/types.ts +172 -172
- package/server/shared/utils.ts +193 -193
- package/server/tsconfig.json +36 -36
- package/server/utils/colors.js +21 -21
- package/server/utils/commandParser.js +305 -305
- package/server/utils/frontmatter.js +18 -18
- package/server/utils/gitConfig.js +34 -34
- package/server/utils/plugin-loader.js +457 -457
- package/server/utils/plugin-process-manager.js +185 -185
- package/server/utils/port-access.js +209 -209
- package/server/utils/runtime-paths.js +37 -37
- package/server/utils/url-detection.js +71 -71
- package/server/vite-daemon.js +79 -79
- package/shared/modelConstants.js +161 -161
- package/shared/networkHosts.js +22 -22
- package/dist/assets/index-DMz0zv6T.css +0 -32
|
@@ -1,958 +1,1009 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import readline from 'node:readline';
|
|
4
|
-
import { fileURLToPath } from 'node:url';
|
|
5
|
-
|
|
6
|
-
const baseUrl = (process.env.PIXCODE_BASE_URL || '').replace(/\/$/, '');
|
|
7
|
-
const apiKey = process.env.PIXCODE_API_KEY || '';
|
|
8
|
-
const appRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..');
|
|
9
|
-
const mcpServerPath = path.join(appRoot, 'scripts', 'hermes', 'pixcode-mcp-server.mjs');
|
|
10
|
-
const READBACK_IDLE_STABLE_MS = Math.max(
|
|
11
|
-
1000,
|
|
12
|
-
Number.parseInt(process.env.PIXCODE_MCP_READBACK_IDLE_STABLE_MS || '8000', 10) || 8000,
|
|
13
|
-
);
|
|
14
|
-
const DEFAULT_STARTUP_WAIT_MS = 100000;
|
|
15
|
-
const ALLOWED_PIXCODE_API_METHODS = new Set(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']);
|
|
16
|
-
|
|
17
|
-
const tools = [
|
|
18
|
-
{
|
|
19
|
-
name: 'pixcode_list_projects',
|
|
20
|
-
description: 'List Pixcode workspaces/projects visible to this user, including display name, path, and file count when available.',
|
|
21
|
-
inputSchema: {
|
|
22
|
-
type: 'object',
|
|
23
|
-
properties: {},
|
|
24
|
-
additionalProperties: false,
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
name: 'pixcode_get_provider_status',
|
|
29
|
-
description: 'Get install/auth/version status for one Pixcode CLI provider before launching it inside Pixcode.',
|
|
30
|
-
inputSchema: {
|
|
31
|
-
type: 'object',
|
|
32
|
-
properties: {
|
|
33
|
-
provider: {
|
|
34
|
-
type: 'string',
|
|
35
|
-
enum: ['claude', 'codex', 'cursor', 'gemini', 'qwen', 'opencode'],
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
required: ['provider'],
|
|
39
|
-
additionalProperties: false,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: 'pixcode_open_cli_terminal',
|
|
44
|
-
description: 'Use this instead of Hermes shell/proc/skill execution whenever the user asks to open Codex, Claude, Cursor, Gemini, Qwen, or OpenCode inside Pixcode. It asks the open Pixcode workbench to continue the existing visible provider terminal in the project and submit startup input there. Do not run a parallel Hermes codex/claude/proc command for the same request. Do not request a fresh session unless the user explicitly asks for a new session. For multi-step, piece-by-piece, or long-running work, put the full user instruction in startupInput so the provider CLI does the work visibly inside Pixcode. When startupInput is present, Pixcode waits for the terminal to become idle before returning readback by default; never treat the first working frame as final output.',
|
|
45
|
-
inputSchema: {
|
|
46
|
-
type: 'object',
|
|
47
|
-
properties: {
|
|
48
|
-
provider: {
|
|
49
|
-
type: 'string',
|
|
50
|
-
enum: ['claude', 'codex', 'cursor', 'gemini', 'qwen', 'opencode'],
|
|
51
|
-
},
|
|
52
|
-
projectPath: {
|
|
53
|
-
type: 'string',
|
|
54
|
-
description: 'Absolute project path. Omit to use the currently selected Pixcode project.',
|
|
55
|
-
},
|
|
56
|
-
prompt: {
|
|
57
|
-
type: 'string',
|
|
58
|
-
description: 'Optional audit/reason text for Pixcode. This is not typed into the provider CLI.',
|
|
59
|
-
},
|
|
60
|
-
startupInput: {
|
|
61
|
-
type: 'string',
|
|
62
|
-
description: 'Exact startup input typed into the provider CLI after the TUI is ready. Use this for commands like /init, hello prompts, or full multi-step task instructions the user asked to run visibly.',
|
|
63
|
-
},
|
|
64
|
-
forceNewSession: {
|
|
65
|
-
type: 'boolean',
|
|
66
|
-
description: 'Start a fresh visible provider CLI session only when the user explicitly asks for a new session. Omit or false to continue the existing visible provider terminal.',
|
|
67
|
-
},
|
|
68
|
-
bypassPermissions: {
|
|
69
|
-
type: 'boolean',
|
|
70
|
-
description: 'When true, Pixcode starts the provider CLI with its strongest no-approval/bypass flags where supported. Defaults to true for Hermes-launched visible task work.',
|
|
71
|
-
},
|
|
72
|
-
permissionMode: {
|
|
73
|
-
type: 'string',
|
|
74
|
-
enum: ['default', 'bypassPermissions', 'acceptEdits', 'yolo', 'auto_edit', 'plan'],
|
|
75
|
-
description: 'Optional provider permission mode. Omit to use bypassPermissions when bypassPermissions is not false.',
|
|
76
|
-
},
|
|
77
|
-
waitForOutputMs: {
|
|
78
|
-
type: 'number',
|
|
79
|
-
description: 'Optional milliseconds to wait for recent terminal output. Pixcode keeps polling while terminalState is busy, so use a large value when the user asks for the final provider answer.',
|
|
80
|
-
},
|
|
81
|
-
waitForCompletionMs: {
|
|
82
|
-
type: 'number',
|
|
83
|
-
description: 'Optional explicit milliseconds to wait for the visible provider CLI to return to an idle prompt before reporting output. Overrides waitForOutputMs.',
|
|
84
|
-
},
|
|
85
|
-
launchId: {
|
|
86
|
-
type: 'number',
|
|
87
|
-
description: 'Optional Pixcode terminal launch id. Use the id returned by pixcode_open_cli_terminal when reading one specific visible terminal.',
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
required: ['provider'],
|
|
91
|
-
additionalProperties: false,
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
name: 'pixcode_read_cli_terminal',
|
|
96
|
-
description: 'Read recent visible Pixcode provider CLI terminal output for a project. Use after pixcode_open_cli_terminal when the user asks what Codex/Claude/Gemini/Qwen/OpenCode printed.',
|
|
97
|
-
inputSchema: {
|
|
98
|
-
type: 'object',
|
|
99
|
-
properties: {
|
|
100
|
-
provider: {
|
|
101
|
-
type: 'string',
|
|
102
|
-
enum: ['claude', 'codex', 'cursor', 'gemini', 'qwen', 'opencode'],
|
|
103
|
-
},
|
|
104
|
-
projectPath: {
|
|
105
|
-
type: 'string',
|
|
106
|
-
description: 'Absolute project path. Omit to use the currently selected Pixcode project.',
|
|
107
|
-
},
|
|
108
|
-
maxChars: {
|
|
109
|
-
type: 'number',
|
|
110
|
-
description: 'Maximum transcript characters to return, capped by Pixcode.',
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
required: ['provider'],
|
|
114
|
-
additionalProperties: false,
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
name: 'pixcode_get_hermes_gateway_status',
|
|
119
|
-
description: 'Read Pixcode-managed Hermes REST gateway status, including base URL, running state, and the last probe result.',
|
|
120
|
-
inputSchema: {
|
|
121
|
-
type: 'object',
|
|
122
|
-
properties: {
|
|
123
|
-
projectPath: {
|
|
124
|
-
type: 'string',
|
|
125
|
-
description: 'Absolute project path. Omit to inspect all managed Hermes gateways.',
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
additionalProperties: false,
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
name: 'pixcode_probe_hermes_gateway',
|
|
133
|
-
description: 'Ask Pixcode to call Hermes Agent REST endpoints and report whether health, capabilities, model discovery, and an optional real prompt respond.',
|
|
134
|
-
inputSchema: {
|
|
135
|
-
type: 'object',
|
|
136
|
-
properties: {
|
|
137
|
-
projectPath: {
|
|
138
|
-
type: 'string',
|
|
139
|
-
description: 'Absolute project path. Omit to probe the first running managed Hermes gateway.',
|
|
140
|
-
},
|
|
141
|
-
input: {
|
|
142
|
-
type: 'string',
|
|
143
|
-
description: 'Optional prompt to submit to Hermes /v1/runs after the lightweight REST checks pass.',
|
|
144
|
-
},
|
|
145
|
-
startIfNeeded: {
|
|
146
|
-
type: 'boolean',
|
|
147
|
-
description: 'When true, Pixcode starts the managed Hermes gateway before probing.',
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
additionalProperties: false,
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
name: 'pixcode_get_hermes_diagnostics',
|
|
155
|
-
description: 'Read Pixcode Hermes integration diagnostics: installed command, active model/provider, Hermes toolsets, Pixcode MCP tool registration, REST gateway status, cron API state, and redacted recent error signals.',
|
|
156
|
-
inputSchema: {
|
|
157
|
-
type: 'object',
|
|
158
|
-
properties: {
|
|
159
|
-
projectPath: {
|
|
160
|
-
type: 'string',
|
|
161
|
-
description: 'Absolute project path. Omit to diagnose the first running managed Hermes gateway and default Hermes profile.',
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
additionalProperties: false,
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
name: '
|
|
169
|
-
description: 'Read Pixcode
|
|
170
|
-
inputSchema: {
|
|
171
|
-
type: 'object',
|
|
172
|
-
properties: {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
type: 'string',
|
|
189
|
-
description: '
|
|
190
|
-
},
|
|
191
|
-
|
|
192
|
-
type: '
|
|
193
|
-
description: '
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
},
|
|
219
|
-
|
|
220
|
-
type: 'string',
|
|
221
|
-
description: '
|
|
222
|
-
},
|
|
223
|
-
|
|
224
|
-
type: '
|
|
225
|
-
description: '
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
},
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
type: '
|
|
289
|
-
|
|
290
|
-
},
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
function
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
if (
|
|
351
|
-
throw new Error('Pixcode
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
if (
|
|
371
|
-
endpoint
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
const
|
|
393
|
-
if (
|
|
394
|
-
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
return
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
const
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
const
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
let
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
:
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import readline from 'node:readline';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
|
|
6
|
+
const baseUrl = (process.env.PIXCODE_BASE_URL || '').replace(/\/$/, '');
|
|
7
|
+
const apiKey = process.env.PIXCODE_API_KEY || '';
|
|
8
|
+
const appRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..');
|
|
9
|
+
const mcpServerPath = path.join(appRoot, 'scripts', 'hermes', 'pixcode-mcp-server.mjs');
|
|
10
|
+
const READBACK_IDLE_STABLE_MS = Math.max(
|
|
11
|
+
1000,
|
|
12
|
+
Number.parseInt(process.env.PIXCODE_MCP_READBACK_IDLE_STABLE_MS || '8000', 10) || 8000,
|
|
13
|
+
);
|
|
14
|
+
const DEFAULT_STARTUP_WAIT_MS = 100000;
|
|
15
|
+
const ALLOWED_PIXCODE_API_METHODS = new Set(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']);
|
|
16
|
+
|
|
17
|
+
const tools = [
|
|
18
|
+
{
|
|
19
|
+
name: 'pixcode_list_projects',
|
|
20
|
+
description: 'List Pixcode workspaces/projects visible to this user, including display name, path, and file count when available.',
|
|
21
|
+
inputSchema: {
|
|
22
|
+
type: 'object',
|
|
23
|
+
properties: {},
|
|
24
|
+
additionalProperties: false,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'pixcode_get_provider_status',
|
|
29
|
+
description: 'Get install/auth/version status for one Pixcode CLI provider before launching it inside Pixcode.',
|
|
30
|
+
inputSchema: {
|
|
31
|
+
type: 'object',
|
|
32
|
+
properties: {
|
|
33
|
+
provider: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
enum: ['claude', 'codex', 'cursor', 'gemini', 'qwen', 'opencode'],
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
required: ['provider'],
|
|
39
|
+
additionalProperties: false,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'pixcode_open_cli_terminal',
|
|
44
|
+
description: 'Use this instead of Hermes shell/proc/skill execution whenever the user asks to open Codex, Claude, Cursor, Gemini, Qwen, or OpenCode inside Pixcode. It asks the open Pixcode workbench to continue the existing visible provider terminal in the project and submit startup input there. Do not run a parallel Hermes codex/claude/proc command for the same request. Do not request a fresh session unless the user explicitly asks for a new session. For multi-step, piece-by-piece, or long-running work, put the full user instruction in startupInput so the provider CLI does the work visibly inside Pixcode. When startupInput is present, Pixcode waits for the terminal to become idle before returning readback by default; never treat the first working frame as final output.',
|
|
45
|
+
inputSchema: {
|
|
46
|
+
type: 'object',
|
|
47
|
+
properties: {
|
|
48
|
+
provider: {
|
|
49
|
+
type: 'string',
|
|
50
|
+
enum: ['claude', 'codex', 'cursor', 'gemini', 'qwen', 'opencode'],
|
|
51
|
+
},
|
|
52
|
+
projectPath: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
description: 'Absolute project path. Omit to use the currently selected Pixcode project.',
|
|
55
|
+
},
|
|
56
|
+
prompt: {
|
|
57
|
+
type: 'string',
|
|
58
|
+
description: 'Optional audit/reason text for Pixcode. This is not typed into the provider CLI.',
|
|
59
|
+
},
|
|
60
|
+
startupInput: {
|
|
61
|
+
type: 'string',
|
|
62
|
+
description: 'Exact startup input typed into the provider CLI after the TUI is ready. Use this for commands like /init, hello prompts, or full multi-step task instructions the user asked to run visibly.',
|
|
63
|
+
},
|
|
64
|
+
forceNewSession: {
|
|
65
|
+
type: 'boolean',
|
|
66
|
+
description: 'Start a fresh visible provider CLI session only when the user explicitly asks for a new session. Omit or false to continue the existing visible provider terminal.',
|
|
67
|
+
},
|
|
68
|
+
bypassPermissions: {
|
|
69
|
+
type: 'boolean',
|
|
70
|
+
description: 'When true, Pixcode starts the provider CLI with its strongest no-approval/bypass flags where supported. Defaults to true for Hermes-launched visible task work.',
|
|
71
|
+
},
|
|
72
|
+
permissionMode: {
|
|
73
|
+
type: 'string',
|
|
74
|
+
enum: ['default', 'bypassPermissions', 'acceptEdits', 'yolo', 'auto_edit', 'plan'],
|
|
75
|
+
description: 'Optional provider permission mode. Omit to use bypassPermissions when bypassPermissions is not false.',
|
|
76
|
+
},
|
|
77
|
+
waitForOutputMs: {
|
|
78
|
+
type: 'number',
|
|
79
|
+
description: 'Optional milliseconds to wait for recent terminal output. Pixcode keeps polling while terminalState is busy, so use a large value when the user asks for the final provider answer.',
|
|
80
|
+
},
|
|
81
|
+
waitForCompletionMs: {
|
|
82
|
+
type: 'number',
|
|
83
|
+
description: 'Optional explicit milliseconds to wait for the visible provider CLI to return to an idle prompt before reporting output. Overrides waitForOutputMs.',
|
|
84
|
+
},
|
|
85
|
+
launchId: {
|
|
86
|
+
type: 'number',
|
|
87
|
+
description: 'Optional Pixcode terminal launch id. Use the id returned by pixcode_open_cli_terminal when reading one specific visible terminal.',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
required: ['provider'],
|
|
91
|
+
additionalProperties: false,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: 'pixcode_read_cli_terminal',
|
|
96
|
+
description: 'Read recent visible Pixcode provider CLI terminal output for a project. Use after pixcode_open_cli_terminal when the user asks what Codex/Claude/Gemini/Qwen/OpenCode printed.',
|
|
97
|
+
inputSchema: {
|
|
98
|
+
type: 'object',
|
|
99
|
+
properties: {
|
|
100
|
+
provider: {
|
|
101
|
+
type: 'string',
|
|
102
|
+
enum: ['claude', 'codex', 'cursor', 'gemini', 'qwen', 'opencode'],
|
|
103
|
+
},
|
|
104
|
+
projectPath: {
|
|
105
|
+
type: 'string',
|
|
106
|
+
description: 'Absolute project path. Omit to use the currently selected Pixcode project.',
|
|
107
|
+
},
|
|
108
|
+
maxChars: {
|
|
109
|
+
type: 'number',
|
|
110
|
+
description: 'Maximum transcript characters to return, capped by Pixcode.',
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
required: ['provider'],
|
|
114
|
+
additionalProperties: false,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: 'pixcode_get_hermes_gateway_status',
|
|
119
|
+
description: 'Read Pixcode-managed Hermes REST gateway status, including base URL, running state, and the last probe result.',
|
|
120
|
+
inputSchema: {
|
|
121
|
+
type: 'object',
|
|
122
|
+
properties: {
|
|
123
|
+
projectPath: {
|
|
124
|
+
type: 'string',
|
|
125
|
+
description: 'Absolute project path. Omit to inspect all managed Hermes gateways.',
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
additionalProperties: false,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: 'pixcode_probe_hermes_gateway',
|
|
133
|
+
description: 'Ask Pixcode to call Hermes Agent REST endpoints and report whether health, capabilities, model discovery, and an optional real prompt respond.',
|
|
134
|
+
inputSchema: {
|
|
135
|
+
type: 'object',
|
|
136
|
+
properties: {
|
|
137
|
+
projectPath: {
|
|
138
|
+
type: 'string',
|
|
139
|
+
description: 'Absolute project path. Omit to probe the first running managed Hermes gateway.',
|
|
140
|
+
},
|
|
141
|
+
input: {
|
|
142
|
+
type: 'string',
|
|
143
|
+
description: 'Optional prompt to submit to Hermes /v1/runs after the lightweight REST checks pass.',
|
|
144
|
+
},
|
|
145
|
+
startIfNeeded: {
|
|
146
|
+
type: 'boolean',
|
|
147
|
+
description: 'When true, Pixcode starts the managed Hermes gateway before probing.',
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
additionalProperties: false,
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: 'pixcode_get_hermes_diagnostics',
|
|
155
|
+
description: 'Read Pixcode Hermes integration diagnostics: installed command, active model/provider, Hermes toolsets, Pixcode MCP tool registration, REST gateway status, cron API state, and redacted recent error signals.',
|
|
156
|
+
inputSchema: {
|
|
157
|
+
type: 'object',
|
|
158
|
+
properties: {
|
|
159
|
+
projectPath: {
|
|
160
|
+
type: 'string',
|
|
161
|
+
description: 'Absolute project path. Omit to diagnose the first running managed Hermes gateway and default Hermes profile.',
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
additionalProperties: false,
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: 'pixcode_get_hermes_control_plane',
|
|
169
|
+
description: 'Read the full Pixcode Hermes control-plane snapshot: install status, managed/source Hermes homes, workspace gateways, profiles, sessions, cron jobs, MCP readiness, capabilities, diagnostics, and recommended fixes.',
|
|
170
|
+
inputSchema: {
|
|
171
|
+
type: 'object',
|
|
172
|
+
properties: {
|
|
173
|
+
projectPath: {
|
|
174
|
+
type: 'string',
|
|
175
|
+
description: 'Absolute project path. Omit to inspect all managed Hermes gateways and the active/default Hermes profile.',
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
additionalProperties: false,
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
name: 'pixcode_repair_hermes_control_plane',
|
|
183
|
+
description: 'Ask Pixcode to repair Hermes control-plane wiring by starting or replacing the managed gateway and rewriting Pixcode MCP config for the workspace. Use forceRestart only when stale tools or an unhealthy gateway must be replaced.',
|
|
184
|
+
inputSchema: {
|
|
185
|
+
type: 'object',
|
|
186
|
+
properties: {
|
|
187
|
+
projectPath: {
|
|
188
|
+
type: 'string',
|
|
189
|
+
description: 'Absolute project path for the managed Hermes gateway.',
|
|
190
|
+
},
|
|
191
|
+
forceRestart: {
|
|
192
|
+
type: 'boolean',
|
|
193
|
+
description: 'Stop and restart the managed Hermes gateway before repairing MCP config.',
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
additionalProperties: false,
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
name: 'pixcode_get_api_manifest',
|
|
201
|
+
description: 'Read Pixcode public API documentation manifest. Use this to discover controllable Pixcode API groups, paths, and scopes before calling pixcode_api_request.',
|
|
202
|
+
inputSchema: {
|
|
203
|
+
type: 'object',
|
|
204
|
+
properties: {},
|
|
205
|
+
additionalProperties: false,
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: 'pixcode_api_request',
|
|
210
|
+
description: 'Call the authenticated local Pixcode REST API. Use this for full Pixcode control after reading pixcode_get_api_manifest. Path must be a local /api/... path or /health; never pass an external URL.',
|
|
211
|
+
inputSchema: {
|
|
212
|
+
type: 'object',
|
|
213
|
+
properties: {
|
|
214
|
+
method: {
|
|
215
|
+
type: 'string',
|
|
216
|
+
enum: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'],
|
|
217
|
+
description: 'HTTP method to use.',
|
|
218
|
+
},
|
|
219
|
+
path: {
|
|
220
|
+
type: 'string',
|
|
221
|
+
description: 'Local Pixcode path, for example /api/projects, /api/providers/codex/auth/status?refresh=1, or /api/remote/config.',
|
|
222
|
+
},
|
|
223
|
+
body: {
|
|
224
|
+
type: 'object',
|
|
225
|
+
description: 'Optional JSON body for POST, PUT, PATCH, or DELETE requests.',
|
|
226
|
+
additionalProperties: true,
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
required: ['method', 'path'],
|
|
230
|
+
additionalProperties: false,
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
name: 'pixcode_hermes_gateway_request',
|
|
235
|
+
description: 'Call the Pixcode-managed Hermes REST gateway for advanced Hermes features such as /v1/runs, /v1/responses, /api/jobs cron management, /v1/capabilities, and /health. Use startIfNeeded when the gateway is not already running.',
|
|
236
|
+
inputSchema: {
|
|
237
|
+
type: 'object',
|
|
238
|
+
properties: {
|
|
239
|
+
method: {
|
|
240
|
+
type: 'string',
|
|
241
|
+
enum: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'],
|
|
242
|
+
},
|
|
243
|
+
endpoint: {
|
|
244
|
+
type: 'string',
|
|
245
|
+
description: 'Hermes gateway endpoint, for example /api/jobs, /api/jobs/<id>/run, /v1/capabilities, or /v1/responses.',
|
|
246
|
+
},
|
|
247
|
+
body: {
|
|
248
|
+
type: 'object',
|
|
249
|
+
additionalProperties: true,
|
|
250
|
+
},
|
|
251
|
+
projectPath: {
|
|
252
|
+
type: 'string',
|
|
253
|
+
description: 'Absolute project path for the managed Hermes gateway.',
|
|
254
|
+
},
|
|
255
|
+
startIfNeeded: {
|
|
256
|
+
type: 'boolean',
|
|
257
|
+
description: 'Start the managed Hermes gateway first when it is not already running.',
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
required: ['method', 'endpoint'],
|
|
261
|
+
additionalProperties: false,
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
name: 'pixcode_manage_hermes_cron',
|
|
266
|
+
description: 'Create, list, update, pause, resume, run, or delete Hermes cron jobs through the Pixcode-managed Hermes REST gateway. Cron jobs can run in a project workdir and use Hermes skills/toolsets.',
|
|
267
|
+
inputSchema: {
|
|
268
|
+
type: 'object',
|
|
269
|
+
properties: {
|
|
270
|
+
action: {
|
|
271
|
+
type: 'string',
|
|
272
|
+
enum: ['list', 'create', 'get', 'update', 'delete', 'pause', 'resume', 'run'],
|
|
273
|
+
},
|
|
274
|
+
jobId: {
|
|
275
|
+
type: 'string',
|
|
276
|
+
description: 'Required for get, update, delete, pause, resume, and run.',
|
|
277
|
+
},
|
|
278
|
+
projectPath: {
|
|
279
|
+
type: 'string',
|
|
280
|
+
description: 'Absolute project path for the managed Hermes gateway and default cron workdir.',
|
|
281
|
+
},
|
|
282
|
+
name: { type: 'string' },
|
|
283
|
+
schedule: { type: 'string' },
|
|
284
|
+
prompt: { type: 'string' },
|
|
285
|
+
workdir: { type: 'string' },
|
|
286
|
+
skills: {
|
|
287
|
+
type: 'array',
|
|
288
|
+
items: { type: 'string' },
|
|
289
|
+
},
|
|
290
|
+
delivery: { type: 'string' },
|
|
291
|
+
startIfNeeded: { type: 'boolean' },
|
|
292
|
+
},
|
|
293
|
+
required: ['action'],
|
|
294
|
+
additionalProperties: false,
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
name: 'pixcode_send_cli_input',
|
|
299
|
+
description: 'Send text or an Enter key directly to an existing visible Pixcode provider terminal. Use this when a terminal is already open and the user asks Hermes to continue that exact visible session.',
|
|
300
|
+
inputSchema: {
|
|
301
|
+
type: 'object',
|
|
302
|
+
properties: {
|
|
303
|
+
provider: {
|
|
304
|
+
type: 'string',
|
|
305
|
+
enum: ['claude', 'codex', 'cursor', 'gemini', 'qwen', 'opencode'],
|
|
306
|
+
},
|
|
307
|
+
projectPath: {
|
|
308
|
+
type: 'string',
|
|
309
|
+
description: 'Absolute project path. Omit to use the newest visible terminal for the provider.',
|
|
310
|
+
},
|
|
311
|
+
input: {
|
|
312
|
+
type: 'string',
|
|
313
|
+
description: 'Text to type. May be empty when submit=true to press Enter on already typed input.',
|
|
314
|
+
},
|
|
315
|
+
submit: {
|
|
316
|
+
type: 'boolean',
|
|
317
|
+
description: 'Append Enter after input. Defaults to true.',
|
|
318
|
+
},
|
|
319
|
+
launchId: {
|
|
320
|
+
type: 'number',
|
|
321
|
+
description: 'Optional Pixcode terminal launch id to target one visible terminal.',
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
required: ['provider'],
|
|
325
|
+
additionalProperties: false,
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
];
|
|
329
|
+
|
|
330
|
+
function send(payload) {
|
|
331
|
+
process.stdout.write(`${JSON.stringify(payload)}\n`);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function textResult(text) {
|
|
335
|
+
return {
|
|
336
|
+
content: [
|
|
337
|
+
{
|
|
338
|
+
type: 'text',
|
|
339
|
+
text,
|
|
340
|
+
},
|
|
341
|
+
],
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function sleep(ms) {
|
|
346
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
async function pixcodeFetch(endpoint, options = {}) {
|
|
350
|
+
if (!baseUrl || !apiKey) {
|
|
351
|
+
throw new Error('Pixcode MCP is missing PIXCODE_BASE_URL or PIXCODE_API_KEY.');
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const response = await fetch(`${baseUrl}${endpoint}`, {
|
|
355
|
+
...options,
|
|
356
|
+
headers: {
|
|
357
|
+
Authorization: `Bearer ${apiKey}`,
|
|
358
|
+
'Content-Type': 'application/json',
|
|
359
|
+
...(options.headers || {}),
|
|
360
|
+
},
|
|
361
|
+
});
|
|
362
|
+
const text = await response.text();
|
|
363
|
+
let body = null;
|
|
364
|
+
try {
|
|
365
|
+
body = text ? JSON.parse(text) : null;
|
|
366
|
+
} catch {
|
|
367
|
+
body = text;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
if (!response.ok) {
|
|
371
|
+
throw new Error(`Pixcode API ${endpoint} failed with HTTP ${response.status}: ${typeof body === 'string' ? body : JSON.stringify(body)}`);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
return body;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function normalizeLocalPixcodePath(pathValue) {
|
|
378
|
+
const endpoint = typeof pathValue === 'string' ? pathValue.trim() : '';
|
|
379
|
+
if (!endpoint) {
|
|
380
|
+
throw new Error('Pixcode API path is required.');
|
|
381
|
+
}
|
|
382
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//iu.test(endpoint) || endpoint.startsWith('//')) {
|
|
383
|
+
throw new Error('Pixcode API path must be local; external URLs are not allowed.');
|
|
384
|
+
}
|
|
385
|
+
if (endpoint !== '/health' && !endpoint.startsWith('/api/')) {
|
|
386
|
+
throw new Error('Pixcode API path must start with /api/ or be /health.');
|
|
387
|
+
}
|
|
388
|
+
return endpoint;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function normalizeHermesGatewayEndpoint(endpointValue) {
|
|
392
|
+
const endpoint = typeof endpointValue === 'string' ? endpointValue.trim() : '';
|
|
393
|
+
if (!endpoint) {
|
|
394
|
+
throw new Error('Hermes gateway endpoint is required.');
|
|
395
|
+
}
|
|
396
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//iu.test(endpoint) || endpoint.startsWith('//')) {
|
|
397
|
+
throw new Error('Hermes gateway endpoint must be local; external URLs are not allowed.');
|
|
398
|
+
}
|
|
399
|
+
if (!endpoint.startsWith('/')) {
|
|
400
|
+
throw new Error('Hermes gateway endpoint must start with /.');
|
|
401
|
+
}
|
|
402
|
+
if (
|
|
403
|
+
endpoint !== '/health' &&
|
|
404
|
+
endpoint !== '/health/detailed' &&
|
|
405
|
+
!endpoint.startsWith('/v1/') &&
|
|
406
|
+
!endpoint.startsWith('/api/')
|
|
407
|
+
) {
|
|
408
|
+
throw new Error('Hermes gateway endpoint must be /health, /v1/..., or /api/....');
|
|
409
|
+
}
|
|
410
|
+
return endpoint;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
function normalizeHttpMethod(methodValue) {
|
|
414
|
+
const method = String(methodValue || 'GET').trim().toUpperCase();
|
|
415
|
+
if (!ALLOWED_PIXCODE_API_METHODS.has(method)) {
|
|
416
|
+
throw new Error(`Unsupported HTTP method: ${method || '(empty)'}`);
|
|
417
|
+
}
|
|
418
|
+
return method;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
async function pixcodeJsonRequest(pathValue, { method = 'GET', body } = {}) {
|
|
422
|
+
const endpoint = normalizeLocalPixcodePath(pathValue);
|
|
423
|
+
const normalizedMethod = normalizeHttpMethod(method);
|
|
424
|
+
const requestOptions = { method: normalizedMethod };
|
|
425
|
+
if (typeof body !== 'undefined' && normalizedMethod !== 'GET') {
|
|
426
|
+
requestOptions.body = JSON.stringify(body);
|
|
427
|
+
}
|
|
428
|
+
return pixcodeFetch(endpoint, requestOptions);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
async function sendProviderTerminalInput(provider, projectPath, input, submit = true, launchId = null) {
|
|
432
|
+
return pixcodeFetch('/api/shell/sessions/provider-input', {
|
|
433
|
+
method: 'POST',
|
|
434
|
+
body: JSON.stringify({
|
|
435
|
+
provider,
|
|
436
|
+
projectPath: projectPath || null,
|
|
437
|
+
input: typeof input === 'string' ? input : '',
|
|
438
|
+
submit: submit !== false,
|
|
439
|
+
launchId: Number(launchId || 0) || null,
|
|
440
|
+
}),
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
async function readProviderStatus(provider) {
|
|
445
|
+
const body = await pixcodeFetch(`/api/providers/${encodeURIComponent(provider)}/auth/status?refresh=1`);
|
|
446
|
+
return body?.data ?? body;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
async function readProviderTerminalOutput(provider, projectPath, maxChars, launchId = null) {
|
|
450
|
+
const params = new URLSearchParams({
|
|
451
|
+
provider,
|
|
452
|
+
maxChars: String(maxChars || 12000),
|
|
453
|
+
});
|
|
454
|
+
if (projectPath) params.set('projectPath', projectPath);
|
|
455
|
+
if (launchId) params.set('launchId', String(launchId));
|
|
456
|
+
return pixcodeFetch(`/api/shell/sessions/provider-output?${params.toString()}`);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
function getLastMatchIndex(text, pattern) {
|
|
460
|
+
let lastIndex = -1;
|
|
461
|
+
for (const match of text.matchAll(pattern)) {
|
|
462
|
+
lastIndex = match.index ?? lastIndex;
|
|
463
|
+
}
|
|
464
|
+
return lastIndex;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
function inferTerminalState(provider, terminalOutput) {
|
|
468
|
+
if (!terminalOutput) return 'unknown';
|
|
469
|
+
if (typeof terminalOutput.terminalState === 'string') return terminalOutput.terminalState;
|
|
470
|
+
if (typeof terminalOutput.isBusy === 'boolean') return terminalOutput.isBusy ? 'busy' : 'idle';
|
|
471
|
+
if (terminalOutput.active === false) return terminalOutput.output ? 'idle' : 'unknown';
|
|
472
|
+
|
|
473
|
+
const output = String(terminalOutput.output || '');
|
|
474
|
+
if (!output.trim()) return 'unknown';
|
|
475
|
+
if (/Process exited with code/iu.test(output)) return 'idle';
|
|
476
|
+
|
|
477
|
+
const lastWeakBusy = getLastMatchIndex(output, /(?:^|\n)\s*[•*]\s*(?:Working|Running|Thinking)\b/giu);
|
|
478
|
+
const lastStrongBusy = Math.max(
|
|
479
|
+
getLastMatchIndex(output, /\bWorking\s*\([^)]*esc to interrupt[^)]*\)/giu),
|
|
480
|
+
getLastMatchIndex(output, /\bmsg=interrupt\b/giu),
|
|
481
|
+
);
|
|
482
|
+
const lastBusy = Math.max(lastWeakBusy, lastStrongBusy);
|
|
483
|
+
|
|
484
|
+
if (provider === 'codex') {
|
|
485
|
+
const lastPrompt = Math.max(
|
|
486
|
+
getLastMatchIndex(output, /(?:^|\n)\s*›(?:\s|$)/gu),
|
|
487
|
+
getLastMatchIndex(output, /(?:^|\n)\s*❯(?:\s|$)/gu),
|
|
488
|
+
);
|
|
489
|
+
if (lastPrompt >= 0) return lastStrongBusy > lastPrompt ? 'busy' : 'idle';
|
|
490
|
+
if (lastBusy >= 0) return 'busy';
|
|
491
|
+
return 'unknown';
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
if (lastBusy >= 0) return 'busy';
|
|
495
|
+
return 'unknown';
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
function isTerminalReadbackFinal(provider, terminalOutput) {
|
|
499
|
+
const terminalState = inferTerminalState(provider, terminalOutput);
|
|
500
|
+
return terminalState === 'idle' || terminalState === 'completed' || terminalState === 'exited' || terminalState === 'failed';
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
function isTerminalReadbackHardFinal(provider, terminalOutput) {
|
|
504
|
+
const terminalState = inferTerminalState(provider, terminalOutput);
|
|
505
|
+
return terminalState === 'completed' || terminalState === 'exited' || terminalState === 'failed' || Boolean(terminalOutput?.terminalFailed);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
function getReadbackFingerprint(terminalOutput) {
|
|
509
|
+
return [
|
|
510
|
+
terminalOutput?.terminalState || '',
|
|
511
|
+
terminalOutput?.lifecycleState || '',
|
|
512
|
+
terminalOutput?.exitCode ?? '',
|
|
513
|
+
terminalOutput?.exitSignal || '',
|
|
514
|
+
String(terminalOutput?.output || '').slice(-12000),
|
|
515
|
+
].join('\n---pixcode-readback---\n');
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
function outputHasProviderPrompt(provider, output) {
|
|
519
|
+
const text = String(output || '');
|
|
520
|
+
if (provider === 'codex') {
|
|
521
|
+
return /(?:^|\n)\s*[›❯]\s*$/u.test(text) || /(?:^|\n)\s*›\s+[^\n]*$/u.test(text);
|
|
522
|
+
}
|
|
523
|
+
return /(?:^|\n).{0,80}(?:>\s*|❯\s*)$/u.test(text);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
function startupInputLooksStuckAtPrompt(provider, terminalOutput, startupInput) {
|
|
527
|
+
if (!startupInput || !terminalOutput?.output || terminalOutput.isBusy) return false;
|
|
528
|
+
const output = String(terminalOutput.output || '');
|
|
529
|
+
const escapedInput = startupInput.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
530
|
+
if (provider === 'codex') {
|
|
531
|
+
return new RegExp(`(?:^|\\n)\\s*[›❯]\\s*${escapedInput}\\s*$`, 'u').test(output);
|
|
532
|
+
}
|
|
533
|
+
return output.endsWith(startupInput) || outputHasProviderPrompt(provider, output);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
async function recoverStuckStartupInput(provider, projectPath, startupInput, terminalOutput, launchId = null) {
|
|
537
|
+
if (!startupInputLooksStuckAtPrompt(provider, terminalOutput, startupInput)) {
|
|
538
|
+
return null;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
const output = String(terminalOutput?.output || '');
|
|
542
|
+
const inputAlreadyVisible = output.includes(startupInput);
|
|
543
|
+
return sendProviderTerminalInput(
|
|
544
|
+
provider,
|
|
545
|
+
projectPath,
|
|
546
|
+
inputAlreadyVisible ? '' : startupInput,
|
|
547
|
+
true,
|
|
548
|
+
launchId,
|
|
549
|
+
);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
async function waitForProviderTerminalOutput(provider, projectPath, waitMs, launchId = null) {
|
|
553
|
+
const startedAt = Date.now();
|
|
554
|
+
let latestOutput = null;
|
|
555
|
+
let stableFingerprint = null;
|
|
556
|
+
let stableSince = 0;
|
|
557
|
+
let stableFinal = false;
|
|
558
|
+
do {
|
|
559
|
+
const elapsed = Date.now() - startedAt;
|
|
560
|
+
const remaining = Math.max(0, waitMs - elapsed);
|
|
561
|
+
await sleep(Math.min(1000, Math.max(250, remaining)));
|
|
562
|
+
latestOutput = await readProviderTerminalOutput(provider, projectPath, 12000, launchId).catch((error) => ({
|
|
563
|
+
active: false,
|
|
564
|
+
terminalState: 'unknown',
|
|
565
|
+
error: error instanceof Error ? error.message : String(error),
|
|
566
|
+
}));
|
|
567
|
+
|
|
568
|
+
if (latestOutput?.output && isTerminalReadbackFinal(provider, latestOutput)) {
|
|
569
|
+
if (isTerminalReadbackHardFinal(provider, latestOutput)) {
|
|
570
|
+
stableFinal = true;
|
|
571
|
+
break;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
const fingerprint = getReadbackFingerprint(latestOutput);
|
|
575
|
+
if (fingerprint !== stableFingerprint) {
|
|
576
|
+
stableFingerprint = fingerprint;
|
|
577
|
+
stableSince = Date.now();
|
|
578
|
+
}
|
|
579
|
+
if (Date.now() - stableSince >= READBACK_IDLE_STABLE_MS) {
|
|
580
|
+
stableFinal = true;
|
|
581
|
+
break;
|
|
582
|
+
}
|
|
583
|
+
} else {
|
|
584
|
+
stableFingerprint = null;
|
|
585
|
+
stableSince = 0;
|
|
586
|
+
}
|
|
587
|
+
} while (Date.now() - startedAt < waitMs);
|
|
588
|
+
|
|
589
|
+
if (latestOutput && !latestOutput.terminalState) {
|
|
590
|
+
latestOutput.terminalState = inferTerminalState(provider, latestOutput);
|
|
591
|
+
}
|
|
592
|
+
if (latestOutput && typeof latestOutput.isBusy !== 'boolean') {
|
|
593
|
+
latestOutput.isBusy = latestOutput.terminalState === 'busy';
|
|
594
|
+
}
|
|
595
|
+
if (latestOutput) {
|
|
596
|
+
latestOutput.readbackStable = stableFinal;
|
|
597
|
+
latestOutput.terminalOutputFinal = stableFinal;
|
|
598
|
+
}
|
|
599
|
+
return latestOutput;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
function isLegacyPromptLikelyStartupInput(prompt) {
|
|
603
|
+
if (!prompt || prompt.length > 160 || prompt.includes('\n')) return false;
|
|
604
|
+
if (/^[/:!@]/u.test(prompt)) return true;
|
|
605
|
+
if (prompt.includes(':')) return false;
|
|
606
|
+
if (/\b(user|request|reason|audit|task|kullanıcı|kullanicinin|istek|isteği|gorev|görev|terminal|codex|claude|qwen|gemini|cursor|opencode|open|aç|ac|başlat|baslat|send|gönder|gonder)\b/iu.test(prompt)) {
|
|
607
|
+
return false;
|
|
608
|
+
}
|
|
609
|
+
return prompt.length <= 80;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
async function upsertProviderPixcodeMcp(provider, projectPath, scope) {
|
|
613
|
+
const body = await pixcodeFetch(`/api/providers/${encodeURIComponent(provider)}/mcp/servers`, {
|
|
614
|
+
method: 'POST',
|
|
615
|
+
body: JSON.stringify({
|
|
616
|
+
name: 'pixcode',
|
|
617
|
+
transport: 'stdio',
|
|
618
|
+
scope,
|
|
619
|
+
workspacePath: projectPath || process.cwd(),
|
|
620
|
+
command: process.execPath,
|
|
621
|
+
args: [mcpServerPath],
|
|
622
|
+
env: {
|
|
623
|
+
PIXCODE_BASE_URL: baseUrl,
|
|
624
|
+
PIXCODE_API_KEY: apiKey,
|
|
625
|
+
},
|
|
626
|
+
}),
|
|
627
|
+
});
|
|
628
|
+
return body?.data?.server ?? body?.server ?? body;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
async function ensureProviderPixcodeMcp(provider, projectPath) {
|
|
632
|
+
try {
|
|
633
|
+
const server = await upsertProviderPixcodeMcp(provider, projectPath, 'project');
|
|
634
|
+
return { scope: 'project', server, projectScopeError: null };
|
|
635
|
+
} catch (error) {
|
|
636
|
+
const projectScopeError = error instanceof Error ? error.message : String(error);
|
|
637
|
+
try {
|
|
638
|
+
const server = await upsertProviderPixcodeMcp(provider, projectPath, 'user');
|
|
639
|
+
return { scope: 'user', server, projectScopeError };
|
|
640
|
+
} catch (fallbackError) {
|
|
641
|
+
const userScopeError = fallbackError instanceof Error ? fallbackError.message : String(fallbackError);
|
|
642
|
+
throw new Error(`Pixcode MCP auto-config failed for project scope (${projectScopeError}) and user scope (${userScopeError})`);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
async function callTool(name, args = {}) {
|
|
648
|
+
if (name === 'pixcode_list_projects') {
|
|
649
|
+
const projects = await pixcodeFetch('/api/projects');
|
|
650
|
+
const normalized = (Array.isArray(projects) ? projects : []).map((project) => ({
|
|
651
|
+
name: project.name,
|
|
652
|
+
displayName: project.displayName,
|
|
653
|
+
path: project.fullPath || project.path,
|
|
654
|
+
fileCount: project.fileCount ?? null,
|
|
655
|
+
}));
|
|
656
|
+
return textResult(JSON.stringify(normalized, null, 2));
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
if (name === 'pixcode_get_provider_status') {
|
|
660
|
+
const provider = String(args.provider || '');
|
|
661
|
+
const status = await readProviderStatus(provider);
|
|
662
|
+
return textResult(JSON.stringify(status, null, 2));
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
if (name === 'pixcode_open_cli_terminal') {
|
|
666
|
+
const provider = String(args.provider || '');
|
|
667
|
+
const projectPath = typeof args.projectPath === 'string' && args.projectPath.trim()
|
|
668
|
+
? args.projectPath.trim()
|
|
669
|
+
: null;
|
|
670
|
+
const status = await readProviderStatus(provider);
|
|
671
|
+
if (status?.installed === false) {
|
|
672
|
+
return textResult(JSON.stringify({
|
|
673
|
+
launched: false,
|
|
674
|
+
provider,
|
|
675
|
+
reason: 'not_installed',
|
|
676
|
+
message: `${provider} CLI is not installed. Install it in Pixcode before launching a terminal.`,
|
|
677
|
+
status,
|
|
678
|
+
}, null, 2));
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
let mcpConfigured = false;
|
|
682
|
+
let mcpConfig = null;
|
|
683
|
+
let mcpError = null;
|
|
684
|
+
try {
|
|
685
|
+
mcpConfig = await ensureProviderPixcodeMcp(provider, projectPath);
|
|
686
|
+
mcpConfigured = true;
|
|
687
|
+
} catch (error) {
|
|
688
|
+
mcpError = error instanceof Error ? error.message : String(error);
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
const startupInput = typeof args.startupInput === 'string' && args.startupInput.trim()
|
|
692
|
+
? args.startupInput
|
|
693
|
+
: (isLegacyPromptLikelyStartupInput(args.prompt) ? args.prompt.trim() : null);
|
|
694
|
+
const bypassPermissions = args.bypassPermissions === false ? false : true;
|
|
695
|
+
const forceNewSession = args.forceNewSession === true || args.newSession === true || args.freshSession === true;
|
|
696
|
+
const permissionMode = typeof args.permissionMode === 'string' && args.permissionMode.trim()
|
|
697
|
+
? args.permissionMode.trim()
|
|
698
|
+
: (bypassPermissions ? 'bypassPermissions' : null);
|
|
699
|
+
|
|
700
|
+
const body = await pixcodeFetch('/api/orchestration/hermes/terminal-launches', {
|
|
701
|
+
method: 'POST',
|
|
702
|
+
body: JSON.stringify({
|
|
703
|
+
provider,
|
|
704
|
+
projectPath,
|
|
705
|
+
prompt: args.prompt || null,
|
|
706
|
+
startupInput,
|
|
707
|
+
forceNewSession,
|
|
708
|
+
bypassPermissions,
|
|
709
|
+
skipPermissions: bypassPermissions,
|
|
710
|
+
permissionMode,
|
|
711
|
+
}),
|
|
712
|
+
});
|
|
713
|
+
const launchId = Number(body?.event?.id || body?.id || 0) || null;
|
|
714
|
+
let terminalOutput = null;
|
|
715
|
+
const defaultWaitMs = startupInput ? DEFAULT_STARTUP_WAIT_MS : 0;
|
|
716
|
+
const requestedWaitMs = Number(args.waitForCompletionMs ?? args.waitForOutputMs ?? defaultWaitMs);
|
|
717
|
+
const waitForOutputMs = Math.min(600000, Math.max(0, requestedWaitMs));
|
|
718
|
+
if (waitForOutputMs > 0) {
|
|
719
|
+
terminalOutput = await waitForProviderTerminalOutput(provider, projectPath, waitForOutputMs, launchId);
|
|
720
|
+
if (startupInput && terminalOutput && !isTerminalReadbackFinal(provider, terminalOutput)) {
|
|
721
|
+
const recovery = await recoverStuckStartupInput(provider, projectPath, startupInput, terminalOutput, launchId).catch((error) => ({
|
|
722
|
+
error: error instanceof Error ? error.message : String(error),
|
|
723
|
+
}));
|
|
724
|
+
if (recovery) {
|
|
725
|
+
const recoveredOutput = await waitForProviderTerminalOutput(provider, projectPath, Math.min(waitForOutputMs, 120000), launchId);
|
|
726
|
+
terminalOutput = recoveredOutput || terminalOutput;
|
|
727
|
+
if (terminalOutput) {
|
|
728
|
+
terminalOutput.startupInputRecovery = recovery;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
const terminalOutputFinal = terminalOutput
|
|
734
|
+
? Boolean(terminalOutput.terminalOutputFinal ?? isTerminalReadbackFinal(provider, terminalOutput))
|
|
735
|
+
: false;
|
|
736
|
+
return textResult(JSON.stringify({
|
|
737
|
+
launched: true,
|
|
738
|
+
launchId,
|
|
739
|
+
pixcodeMcpConfigured: mcpConfigured,
|
|
740
|
+
pixcodeMcpScope: mcpConfig?.scope ?? null,
|
|
741
|
+
pixcodeMcpProjectScopeError: mcpConfig?.projectScopeError ?? null,
|
|
742
|
+
pixcodeMcpError: mcpError,
|
|
743
|
+
event: body?.event ?? body,
|
|
744
|
+
permissionBypass: bypassPermissions,
|
|
745
|
+
status,
|
|
746
|
+
terminalOutputFinal,
|
|
747
|
+
terminalFailed: Boolean(terminalOutput?.terminalFailed),
|
|
748
|
+
message: terminalOutput && !terminalOutputFinal
|
|
749
|
+
? 'Provider terminal is still running or not at an idle prompt yet. Do not summarize this as final output; call pixcode_read_cli_terminal with launchId later.'
|
|
750
|
+
: terminalOutput?.terminalFailed
|
|
751
|
+
? 'Provider terminal exited with a failure. Do not report this as successful; tell the user the visible CLI failed and include the exit code/output.'
|
|
752
|
+
: undefined,
|
|
753
|
+
terminalOutput,
|
|
754
|
+
}, null, 2));
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
if (name === 'pixcode_read_cli_terminal') {
|
|
758
|
+
const provider = String(args.provider || '');
|
|
759
|
+
const projectPath = typeof args.projectPath === 'string' && args.projectPath.trim()
|
|
760
|
+
? args.projectPath.trim()
|
|
761
|
+
: null;
|
|
762
|
+
const maxChars = Math.min(20000, Math.max(1000, Number(args.maxChars || 12000)));
|
|
763
|
+
const launchId = Number(args.launchId || 0) || null;
|
|
764
|
+
const body = await readProviderTerminalOutput(provider, projectPath, maxChars, launchId);
|
|
765
|
+
if (body && !body.terminalState) {
|
|
766
|
+
body.terminalState = inferTerminalState(provider, body);
|
|
767
|
+
}
|
|
768
|
+
if (body && typeof body.isBusy !== 'boolean') {
|
|
769
|
+
body.isBusy = body.terminalState === 'busy';
|
|
770
|
+
}
|
|
771
|
+
body.terminalOutputFinal = isTerminalReadbackFinal(provider, body);
|
|
772
|
+
body.terminalFailed = Boolean(body.terminalFailed);
|
|
773
|
+
return textResult(JSON.stringify(body, null, 2));
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
if (name === 'pixcode_get_hermes_gateway_status') {
|
|
777
|
+
const projectPath = typeof args.projectPath === 'string' && args.projectPath.trim()
|
|
778
|
+
? `?projectPath=${encodeURIComponent(args.projectPath.trim())}`
|
|
779
|
+
: '';
|
|
780
|
+
const body = await pixcodeFetch(`/api/orchestration/hermes/gateway/status${projectPath}`);
|
|
781
|
+
return textResult(JSON.stringify(body, null, 2));
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
if (name === 'pixcode_probe_hermes_gateway') {
|
|
785
|
+
const body = await pixcodeFetch('/api/orchestration/hermes/gateway/probe', {
|
|
786
|
+
method: 'POST',
|
|
787
|
+
body: JSON.stringify({
|
|
788
|
+
projectPath: args.projectPath || null,
|
|
789
|
+
input: args.input || null,
|
|
790
|
+
startIfNeeded: args.startIfNeeded === true,
|
|
791
|
+
}),
|
|
792
|
+
});
|
|
793
|
+
return textResult(JSON.stringify(body, null, 2));
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
if (name === 'pixcode_get_hermes_diagnostics') {
|
|
797
|
+
const projectPath = typeof args.projectPath === 'string' && args.projectPath.trim()
|
|
798
|
+
? `?projectPath=${encodeURIComponent(args.projectPath.trim())}`
|
|
799
|
+
: '';
|
|
800
|
+
const body = await pixcodeFetch(`/api/orchestration/hermes/diagnostics${projectPath}`);
|
|
801
|
+
return textResult(JSON.stringify(body, null, 2));
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
if (name === 'pixcode_get_hermes_control_plane') {
|
|
805
|
+
const projectPath = typeof args.projectPath === 'string' && args.projectPath.trim()
|
|
806
|
+
? `?projectPath=${encodeURIComponent(args.projectPath.trim())}`
|
|
807
|
+
: '';
|
|
808
|
+
const body = await pixcodeFetch(`/api/orchestration/hermes/control-plane${projectPath}`);
|
|
809
|
+
return textResult(JSON.stringify(body, null, 2));
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
if (name === 'pixcode_repair_hermes_control_plane') {
|
|
813
|
+
const body = await pixcodeFetch('/api/orchestration/hermes/control-plane/repair', {
|
|
814
|
+
method: 'POST',
|
|
815
|
+
body: JSON.stringify({
|
|
816
|
+
projectPath: args.projectPath || null,
|
|
817
|
+
forceRestart: args.forceRestart === true,
|
|
818
|
+
}),
|
|
819
|
+
});
|
|
820
|
+
return textResult(JSON.stringify(body, null, 2));
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
if (name === 'pixcode_get_api_manifest') {
|
|
824
|
+
const body = await pixcodeJsonRequest('/api/public/manifest', { method: 'GET' });
|
|
825
|
+
return textResult(JSON.stringify(body, null, 2));
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
if (name === 'pixcode_api_request') {
|
|
829
|
+
const body = await pixcodeJsonRequest(args.path, {
|
|
830
|
+
method: args.method || 'GET',
|
|
831
|
+
body: args.body,
|
|
832
|
+
});
|
|
833
|
+
return textResult(JSON.stringify(body, null, 2));
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
if (name === 'pixcode_hermes_gateway_request') {
|
|
837
|
+
const endpoint = normalizeHermesGatewayEndpoint(args.endpoint);
|
|
838
|
+
const body = await pixcodeFetch('/api/orchestration/hermes/gateway/request', {
|
|
839
|
+
method: 'POST',
|
|
840
|
+
body: JSON.stringify({
|
|
841
|
+
method: normalizeHttpMethod(args.method || 'GET'),
|
|
842
|
+
endpoint,
|
|
843
|
+
body: args.body || null,
|
|
844
|
+
projectPath: args.projectPath || null,
|
|
845
|
+
startIfNeeded: args.startIfNeeded === true,
|
|
846
|
+
}),
|
|
847
|
+
});
|
|
848
|
+
return textResult(JSON.stringify(body, null, 2));
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
if (name === 'pixcode_manage_hermes_cron') {
|
|
852
|
+
const action = String(args.action || '').trim();
|
|
853
|
+
const jobId = typeof args.jobId === 'string' && args.jobId.trim() ? args.jobId.trim() : null;
|
|
854
|
+
const jobBody = {
|
|
855
|
+
name: args.name || undefined,
|
|
856
|
+
schedule: args.schedule || undefined,
|
|
857
|
+
prompt: args.prompt || undefined,
|
|
858
|
+
workdir: args.workdir || args.projectPath || undefined,
|
|
859
|
+
skills: Array.isArray(args.skills) ? args.skills : undefined,
|
|
860
|
+
delivery: args.delivery || undefined,
|
|
861
|
+
};
|
|
862
|
+
Object.keys(jobBody).forEach((key) => {
|
|
863
|
+
if (typeof jobBody[key] === 'undefined') delete jobBody[key];
|
|
864
|
+
});
|
|
865
|
+
|
|
866
|
+
let method = 'GET';
|
|
867
|
+
let endpoint = '/api/jobs';
|
|
868
|
+
let body = null;
|
|
869
|
+
if (action === 'create') {
|
|
870
|
+
method = 'POST';
|
|
871
|
+
body = jobBody;
|
|
872
|
+
} else if (action === 'list') {
|
|
873
|
+
method = 'GET';
|
|
874
|
+
} else {
|
|
875
|
+
if (!jobId) throw new Error(`jobId is required for Hermes cron action "${action}".`);
|
|
876
|
+
const encodedJobId = encodeURIComponent(jobId);
|
|
877
|
+
if (action === 'get') {
|
|
878
|
+
method = 'GET';
|
|
879
|
+
endpoint = `/api/jobs/${encodedJobId}`;
|
|
880
|
+
} else if (action === 'update') {
|
|
881
|
+
method = 'PATCH';
|
|
882
|
+
endpoint = `/api/jobs/${encodedJobId}`;
|
|
883
|
+
body = jobBody;
|
|
884
|
+
} else if (action === 'delete') {
|
|
885
|
+
method = 'DELETE';
|
|
886
|
+
endpoint = `/api/jobs/${encodedJobId}`;
|
|
887
|
+
} else if (action === 'pause' || action === 'resume' || action === 'run') {
|
|
888
|
+
method = 'POST';
|
|
889
|
+
endpoint = `/api/jobs/${encodedJobId}/${action}`;
|
|
890
|
+
} else {
|
|
891
|
+
throw new Error(`Unsupported Hermes cron action: ${action || '(empty)'}`);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
const response = await pixcodeFetch('/api/orchestration/hermes/gateway/request', {
|
|
896
|
+
method: 'POST',
|
|
897
|
+
body: JSON.stringify({
|
|
898
|
+
method,
|
|
899
|
+
endpoint,
|
|
900
|
+
body,
|
|
901
|
+
projectPath: args.projectPath || args.workdir || null,
|
|
902
|
+
startIfNeeded: args.startIfNeeded !== false,
|
|
903
|
+
}),
|
|
904
|
+
});
|
|
905
|
+
return textResult(JSON.stringify(response, null, 2));
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
if (name === 'pixcode_send_cli_input') {
|
|
909
|
+
const provider = String(args.provider || '');
|
|
910
|
+
const projectPath = typeof args.projectPath === 'string' && args.projectPath.trim()
|
|
911
|
+
? args.projectPath.trim()
|
|
912
|
+
: null;
|
|
913
|
+
const body = await sendProviderTerminalInput(
|
|
914
|
+
provider,
|
|
915
|
+
projectPath,
|
|
916
|
+
typeof args.input === 'string' ? args.input : '',
|
|
917
|
+
args.submit !== false,
|
|
918
|
+
Number(args.launchId || 0) || null,
|
|
919
|
+
);
|
|
920
|
+
return textResult(JSON.stringify(body, null, 2));
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
throw new Error(`Unknown Pixcode MCP tool: ${name}`);
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
async function handleMessage(message) {
|
|
927
|
+
if (message.method === 'initialize') {
|
|
928
|
+
send({
|
|
929
|
+
jsonrpc: '2.0',
|
|
930
|
+
id: message.id,
|
|
931
|
+
result: {
|
|
932
|
+
protocolVersion: message.params?.protocolVersion || '2024-11-05',
|
|
933
|
+
capabilities: {
|
|
934
|
+
tools: {},
|
|
935
|
+
},
|
|
936
|
+
serverInfo: {
|
|
937
|
+
name: 'pixcode-mcp',
|
|
938
|
+
version: '1.0.0',
|
|
939
|
+
},
|
|
940
|
+
},
|
|
941
|
+
});
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
if (message.method === 'tools/list') {
|
|
946
|
+
send({
|
|
947
|
+
jsonrpc: '2.0',
|
|
948
|
+
id: message.id,
|
|
949
|
+
result: { tools },
|
|
950
|
+
});
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
if (message.method === 'tools/call') {
|
|
955
|
+
try {
|
|
956
|
+
const result = await callTool(message.params?.name, message.params?.arguments || {});
|
|
957
|
+
send({
|
|
958
|
+
jsonrpc: '2.0',
|
|
959
|
+
id: message.id,
|
|
960
|
+
result,
|
|
961
|
+
});
|
|
962
|
+
} catch (error) {
|
|
963
|
+
send({
|
|
964
|
+
jsonrpc: '2.0',
|
|
965
|
+
id: message.id,
|
|
966
|
+
error: {
|
|
967
|
+
code: -32000,
|
|
968
|
+
message: error instanceof Error ? error.message : String(error),
|
|
969
|
+
},
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
return;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
if (typeof message.id !== 'undefined') {
|
|
976
|
+
send({
|
|
977
|
+
jsonrpc: '2.0',
|
|
978
|
+
id: message.id,
|
|
979
|
+
error: {
|
|
980
|
+
code: -32601,
|
|
981
|
+
message: `Method not found: ${message.method}`,
|
|
982
|
+
},
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
const rl = readline.createInterface({
|
|
988
|
+
input: process.stdin,
|
|
989
|
+
crlfDelay: Number.POSITIVE_INFINITY,
|
|
990
|
+
});
|
|
991
|
+
|
|
992
|
+
rl.on('line', (line) => {
|
|
993
|
+
if (!line.trim()) return;
|
|
994
|
+
|
|
995
|
+
void (async () => {
|
|
996
|
+
try {
|
|
997
|
+
await handleMessage(JSON.parse(line));
|
|
998
|
+
} catch (error) {
|
|
999
|
+
send({
|
|
1000
|
+
jsonrpc: '2.0',
|
|
1001
|
+
id: null,
|
|
1002
|
+
error: {
|
|
1003
|
+
code: -32700,
|
|
1004
|
+
message: error instanceof Error ? error.message : String(error),
|
|
1005
|
+
},
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
})();
|
|
1009
|
+
});
|