huaweicloud-devkit 1.1.13 → 2.0.0-next.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/README.md +16 -5
- package/README.zh-CN.md +16 -5
- package/bin/dsh-postinstall.cjs +171 -31
- package/bin/setup.cjs +1 -1
- package/cordis.patch.yml +1 -1
- package/integrations/atomcode/hooks/huaweicloud-telemetry.js +29 -33
- package/integrations/dsh/hook-plugin.d.mts +19 -0
- package/integrations/dsh/hook-plugin.mjs +23 -22
- package/integrations/hermes/hooks/huaweicloud-telemetry.py +26 -43
- package/integrations/hermes/manifest.yaml +35 -10
- package/integrations/opencode/commands/huaweicloud-doctor.md +3 -2
- package/integrations/opencode/hooks/skill-tracker.js +70 -89
- package/integrations/opencode/opencode.json +5 -6
- package/integrations/workbuddy/hooks/telemetry-tracker.py +27 -45
- package/package.json +32 -11
- package/plugins/huaweicloud-core/.claude-plugin/plugin.json +1 -2
- package/plugins/huaweicloud-core/.codex-plugin/plugin.json +1 -2
- package/plugins/huaweicloud-core/.cursor-plugin/plugin.json +1 -2
- package/plugins/huaweicloud-core/.hermes-plugin/plugin.json +1 -2
- package/plugins/huaweicloud-core/.mcp.json +1 -1
- package/plugins/huaweicloud-core/.workbuddy-plugin/plugin.json +1 -2
- package/plugins/huaweicloud-core/dist/agents/atomcode.js +118 -0
- package/plugins/huaweicloud-core/dist/agents/codearts-work.js +121 -0
- package/plugins/huaweicloud-core/dist/agents/codearts.js +69 -0
- package/plugins/huaweicloud-core/dist/agents/codex-desktop.js +193 -0
- package/plugins/huaweicloud-core/dist/agents/codex.js +205 -0
- package/plugins/huaweicloud-core/dist/agents/dsh-patch.js +172 -0
- package/plugins/huaweicloud-core/dist/agents/dsh.js +129 -0
- package/plugins/huaweicloud-core/dist/agents/hermes-config.js +976 -0
- package/plugins/huaweicloud-core/dist/agents/hermes-hook-plugin.js +90 -0
- package/plugins/huaweicloud-core/dist/agents/hermes-hooks.js +166 -0
- package/plugins/huaweicloud-core/dist/agents/hermes-sdk.js +58 -0
- package/plugins/huaweicloud-core/dist/agents/hermes.js +150 -0
- package/plugins/huaweicloud-core/dist/agents/officeace-registry.js +179 -0
- package/plugins/huaweicloud-core/dist/agents/officeace-sqlite.js +132 -0
- package/plugins/huaweicloud-core/dist/agents/officeace.js +173 -0
- package/plugins/huaweicloud-core/dist/agents/openclaw.js +54 -0
- package/plugins/huaweicloud-core/dist/agents/opencode-config.js +188 -0
- package/plugins/huaweicloud-core/dist/agents/opencode.js +112 -0
- package/plugins/huaweicloud-core/dist/agents/workbuddy.js +194 -0
- package/plugins/huaweicloud-core/dist/auth/account-type.js +136 -0
- package/plugins/huaweicloud-core/dist/auth/agent-registration.js +243 -0
- package/plugins/huaweicloud-core/dist/auth/cli.js +114 -0
- package/plugins/huaweicloud-core/dist/auth/codearts-context.js +131 -0
- package/plugins/huaweicloud-core/dist/auth/credential-placeholder.js +41 -0
- package/plugins/huaweicloud-core/dist/auth/credential-resolver.js +74 -0
- package/plugins/huaweicloud-core/dist/auth/credential-validator.js +139 -0
- package/plugins/huaweicloud-core/dist/auth/credentials.js +20 -0
- package/plugins/huaweicloud-core/dist/auth/error-table.js +123 -0
- package/plugins/huaweicloud-core/dist/auth/hcloud-profile.js +89 -0
- package/plugins/huaweicloud-core/dist/auth/init-cli.js +139 -0
- package/plugins/huaweicloud-core/dist/auth/missing-credential-error.js +33 -0
- package/plugins/huaweicloud-core/dist/auth/obs-config.js +31 -0
- package/plugins/huaweicloud-core/dist/auth/project-id.js +90 -0
- package/plugins/huaweicloud-core/dist/auth/reconcile.js +256 -0
- package/plugins/huaweicloud-core/dist/auth/runtime-credentials.js +32 -0
- package/plugins/huaweicloud-core/dist/auth/s1-store.js +171 -0
- package/plugins/huaweicloud-core/dist/auth/service.js +397 -0
- package/plugins/huaweicloud-core/dist/auth/sts-expiry.js +58 -0
- package/plugins/huaweicloud-core/dist/capability-catalog.js +494 -0
- package/plugins/huaweicloud-core/dist/codearts-sandbox.js +32 -0
- package/plugins/huaweicloud-core/dist/codex-probe.js +77 -0
- package/plugins/huaweicloud-core/dist/data/icons-manifest.v1.json +3517 -0
- package/plugins/huaweicloud-core/dist/dep/installers/gateway.js +186 -0
- package/plugins/huaweicloud-core/dist/dep/installers/hcloud.js +370 -0
- package/plugins/huaweicloud-core/dist/dep/installers/table.js +28 -0
- package/plugins/huaweicloud-core/dist/dep/provision.js +247 -0
- package/plugins/huaweicloud-core/dist/dep/receipts.js +385 -0
- package/plugins/huaweicloud-core/dist/detect-framework-match.js +111 -0
- package/plugins/huaweicloud-core/dist/detect-framework-pkg.js +85 -0
- package/plugins/huaweicloud-core/dist/detect-framework-scan.js +93 -0
- package/plugins/huaweicloud-core/dist/detect-framework-table.js +153 -0
- package/plugins/huaweicloud-core/dist/detect-framework.js +7 -0
- package/plugins/huaweicloud-core/dist/doctor-native.js +167 -0
- package/plugins/huaweicloud-core/dist/doctor-payload.js +34 -0
- package/plugins/huaweicloud-core/dist/doctor-report.js +8 -0
- package/plugins/huaweicloud-core/dist/explain-error.js +209 -0
- package/plugins/huaweicloud-core/dist/hcloud-api-error.js +64 -0
- package/plugins/huaweicloud-core/dist/hcloud-catalog.js +91 -0
- package/plugins/huaweicloud-core/dist/hcloud-cli.js +24 -0
- package/plugins/huaweicloud-core/dist/hcloud-obs-redact.js +68 -0
- package/plugins/huaweicloud-core/dist/hcloud-plan.js +298 -0
- package/plugins/huaweicloud-core/dist/hcloud-probe.js +153 -0
- package/plugins/huaweicloud-core/dist/hcloud-run-once.js +245 -0
- package/plugins/huaweicloud-core/dist/hcloud-run.js +107 -0
- package/plugins/huaweicloud-core/dist/hcloud-sg-preflight.js +104 -0
- package/plugins/huaweicloud-core/dist/hcloud-sts.js +113 -0
- package/plugins/huaweicloud-core/dist/hcloud-triage.js +71 -0
- package/plugins/huaweicloud-core/dist/icon-library.js +216 -0
- package/plugins/huaweicloud-core/dist/install-payload.js +35 -0
- package/plugins/huaweicloud-core/dist/install-plan.js +85 -0
- package/plugins/huaweicloud-core/dist/install-prompts.js +119 -0
- package/plugins/huaweicloud-core/dist/koocli-version.js +83 -0
- package/plugins/huaweicloud-core/dist/lib/approval-tokens.js +234 -0
- package/plugins/huaweicloud-core/dist/lib/as-record.js +10 -0
- package/plugins/huaweicloud-core/dist/lib/as-text.js +15 -0
- package/plugins/huaweicloud-core/dist/lib/banner.js +10 -0
- package/plugins/huaweicloud-core/dist/lib/call-trace.js +128 -0
- package/plugins/huaweicloud-core/dist/lib/cli-io.js +72 -0
- package/plugins/huaweicloud-core/dist/lib/credentials.js +173 -0
- package/plugins/huaweicloud-core/dist/lib/dep-resolve.js +64 -0
- package/plugins/huaweicloud-core/dist/lib/dependency-model.js +152 -0
- package/plugins/huaweicloud-core/dist/lib/hdkit/hdkitservice-api.js +217 -0
- package/plugins/huaweicloud-core/dist/lib/hdkit/hwlink-api.js +163 -0
- package/plugins/huaweicloud-core/dist/lib/hdkit/sandbox-pool.js +303 -0
- package/plugins/huaweicloud-core/dist/lib/hw-request-signing.js +57 -0
- package/plugins/huaweicloud-core/dist/lib/koocli-paths.js +18 -0
- package/plugins/huaweicloud-core/dist/lib/native-receipt.js +110 -0
- package/plugins/huaweicloud-core/dist/lib/opencode-permission-seam.js +132 -0
- package/plugins/huaweicloud-core/dist/lib/pack-state.js +179 -0
- package/plugins/huaweicloud-core/dist/lib/pack-types.js +21 -0
- package/plugins/huaweicloud-core/dist/lib/secret-vault/cli.js +273 -0
- package/plugins/huaweicloud-core/dist/lib/secret-vault/custody.js +396 -0
- package/plugins/huaweicloud-core/dist/lib/secret-vault/refs.js +63 -0
- package/plugins/huaweicloud-core/dist/lib/secret-vault/store.js +236 -0
- package/plugins/huaweicloud-core/dist/lib/skill-frontmatter.js +158 -0
- package/plugins/huaweicloud-core/dist/lib/skill-manifest.js +55 -0
- package/plugins/huaweicloud-core/dist/lib/skill-tree.js +44 -0
- package/plugins/huaweicloud-core/dist/lib/tool-schema-parts.js +66 -0
- package/plugins/huaweicloud-core/dist/mcp-agent-config.js +80 -0
- package/plugins/huaweicloud-core/dist/mcp-config-backup.js +74 -0
- package/plugins/huaweicloud-core/dist/mcp-config-io.js +195 -0
- package/plugins/huaweicloud-core/dist/mcp-config-merge.js +188 -0
- package/plugins/huaweicloud-core/dist/mcp-protocol.js +320 -0
- package/plugins/huaweicloud-core/dist/mcp-server.js +62136 -0
- package/plugins/huaweicloud-core/dist/mcp-server.js.map +7 -0
- package/plugins/huaweicloud-core/dist/mcp-stdio-transport.js +206 -0
- package/plugins/huaweicloud-core/dist/officeace-paths.js +142 -0
- package/plugins/huaweicloud-core/dist/packs/auth/pack.js +11 -0
- package/plugins/huaweicloud-core/dist/packs/auth/tools.js +276 -0
- package/plugins/huaweicloud-core/dist/packs/discovery/pack.js +11 -0
- package/plugins/huaweicloud-core/dist/packs/discovery/tools.js +78 -0
- package/plugins/huaweicloud-core/dist/packs/enable.js +81 -0
- package/plugins/huaweicloud-core/dist/packs/huaweicloud-cli/pack.js +39 -0
- package/plugins/huaweicloud-core/dist/packs/huaweicloud-cli/tools.js +435 -0
- package/plugins/huaweicloud-core/dist/packs/huaweicloud-open-mcp/approval.js +222 -0
- package/plugins/huaweicloud-core/dist/packs/huaweicloud-open-mcp/pack.js +17 -0
- package/plugins/huaweicloud-core/dist/packs/huaweicloud-open-mcp/sidecar.js +486 -0
- package/plugins/huaweicloud-core/dist/packs/huaweicloud-open-mcp/tools.js +134 -0
- package/plugins/huaweicloud-core/dist/packs/obs/pack.js +11 -0
- package/plugins/huaweicloud-core/dist/packs/obs/tools.js +425 -0
- package/plugins/huaweicloud-core/dist/packs/registry.js +143 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/git-transfer.js +79 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-account.js +80 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-credentials.js +138 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-deploy.js +45 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-session.js +48 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-tunnel.js +59 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-upload.js +34 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/pack.js +14 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/schemas.js +191 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/tools.js +146 -0
- package/plugins/huaweicloud-core/dist/packs/secrets/pack.js +8 -0
- package/plugins/huaweicloud-core/dist/packs/secrets/tools.js +126 -0
- package/plugins/huaweicloud-core/dist/packs/update/pack.js +11 -0
- package/plugins/huaweicloud-core/dist/packs/update/tools.js +82 -0
- package/plugins/huaweicloud-core/dist/packs/voucher/pack.js +11 -0
- package/plugins/huaweicloud-core/dist/packs/voucher/tools.js +91 -0
- package/plugins/huaweicloud-core/dist/packs-cli/commands.js +108 -0
- package/plugins/huaweicloud-core/dist/packs-cli/doctor.js +81 -0
- package/plugins/huaweicloud-core/dist/packs-cli/report.js +133 -0
- package/plugins/huaweicloud-core/dist/packs-cli/slots.js +104 -0
- package/plugins/huaweicloud-core/dist/packs-cli/write-command.js +108 -0
- package/plugins/huaweicloud-core/dist/packs-cli/writers.js +115 -0
- package/plugins/huaweicloud-core/dist/packs-configure.js +81 -0
- package/plugins/huaweicloud-core/dist/packs-policy.js +149 -0
- package/plugins/huaweicloud-core/dist/payload-files.js +78 -0
- package/plugins/huaweicloud-core/dist/payload-native-clean.js +142 -0
- package/plugins/huaweicloud-core/dist/payload-native-sync.js +89 -0
- package/plugins/huaweicloud-core/dist/payload-placement.js +94 -0
- package/plugins/huaweicloud-core/dist/payload-roster.js +80 -0
- package/plugins/huaweicloud-core/dist/payload-runtime-deps.js +67 -0
- package/plugins/huaweicloud-core/dist/payload-status.js +43 -0
- package/plugins/huaweicloud-core/dist/payload-utils.js +42 -0
- package/plugins/huaweicloud-core/dist/preflight.js +232 -0
- package/plugins/huaweicloud-core/dist/proxy/cli.js +83 -0
- package/plugins/huaweicloud-core/dist/proxy/proxy-agent.js +92 -0
- package/plugins/huaweicloud-core/dist/proxy/proxy-bypass.js +83 -0
- package/plugins/huaweicloud-core/dist/proxy/proxy-cidr.js +105 -0
- package/plugins/huaweicloud-core/dist/proxy/proxy-config-io.js +61 -0
- package/plugins/huaweicloud-core/dist/proxy/proxy-config.js +10 -0
- package/plugins/huaweicloud-core/dist/risk-rule-engine.js +229 -0
- package/plugins/huaweicloud-core/dist/safety/classify-hcloud.js +191 -0
- package/plugins/huaweicloud-core/dist/safety/classify-text.js +1032 -0
- package/plugins/huaweicloud-core/dist/safety/command-operation.js +25 -0
- package/plugins/huaweicloud-core/dist/safety/credential-path.js +23 -0
- package/plugins/huaweicloud-core/dist/safety/default-policy.js +28 -0
- package/plugins/huaweicloud-core/dist/safety/feeder.js +119 -0
- package/plugins/huaweicloud-core/dist/safety/heredoc.js +95 -0
- package/plugins/huaweicloud-core/dist/safety/policy.js +75 -0
- package/plugins/huaweicloud-core/dist/safety/redact.js +42 -0
- package/plugins/huaweicloud-core/dist/safety/risk-merge.js +22 -0
- package/plugins/huaweicloud-core/dist/safety/script-stream.js +90 -0
- package/plugins/huaweicloud-core/dist/safety/secret-exec.js +44 -0
- package/plugins/huaweicloud-core/dist/safety/segments.js +138 -0
- package/plugins/huaweicloud-core/dist/safety/shell-text.js +414 -0
- package/plugins/huaweicloud-core/dist/safety/skill-quality-cli.js +152 -0
- package/plugins/huaweicloud-core/dist/safety/tokens.js +297 -0
- package/plugins/huaweicloud-core/dist/safety/unwrap.js +148 -0
- package/plugins/huaweicloud-core/dist/safety/vocabulary.js +37 -0
- package/plugins/huaweicloud-core/dist/safety/windows-rebase.js +56 -0
- package/plugins/huaweicloud-core/dist/safety/windows.js +137 -0
- package/plugins/huaweicloud-core/dist/safety/xargs-argv.js +64 -0
- package/plugins/huaweicloud-core/dist/safety-policy.js +14 -0
- package/plugins/huaweicloud-core/dist/sandbox/deploy-check.js +246 -0
- package/plugins/huaweicloud-core/dist/sandbox/deploy-nginx-verify.js +76 -0
- package/plugins/huaweicloud-core/dist/sandbox/deploy-nginx.js +215 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-auth.js +246 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-exec.js +10 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-expose-flow.js +225 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-expose.js +214 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-gateway.js +34 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-keepalive.js +212 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-key.js +175 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-renew.js +69 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-tunnel.js +48 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-validation.js +79 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-verify.js +101 -0
- package/plugins/huaweicloud-core/dist/sandbox/hwlink-connection.js +145 -0
- package/plugins/huaweicloud-core/dist/sandbox/sandbox-file-server.py +45 -0
- package/plugins/huaweicloud-core/dist/sandbox/sandbox-output.js +45 -0
- package/plugins/huaweicloud-core/dist/sandbox/session-manager.js +55 -0
- package/plugins/huaweicloud-core/dist/sandbox/tunnel-http.js +137 -0
- package/plugins/huaweicloud-core/dist/sandbox/uninstall-cleanup.js +45 -0
- package/plugins/huaweicloud-core/dist/sandbox/upload-diagnostics.js +45 -0
- package/plugins/huaweicloud-core/dist/sandbox/upload-file.js +119 -0
- package/plugins/huaweicloud-core/dist/sandbox/upload-project.js +171 -0
- package/plugins/huaweicloud-core/dist/sandbox/upload-transport.js +96 -0
- package/plugins/huaweicloud-core/dist/sandbox/ws-exec-loader.js +43 -0
- package/plugins/huaweicloud-core/dist/search-docs.js +64 -0
- package/plugins/huaweicloud-core/dist/search-market.js +277 -0
- package/plugins/huaweicloud-core/dist/services/availability.js +51 -0
- package/plugins/huaweicloud-core/dist/services/regions.js +110 -0
- package/plugins/huaweicloud-core/dist/setup-cli.js +1343 -0
- package/plugins/huaweicloud-core/dist/skill-disclosure.js +231 -0
- package/plugins/huaweicloud-core/dist/targets.js +139 -0
- package/plugins/huaweicloud-core/dist/telemetry/agent-detect.js +44 -0
- package/plugins/huaweicloud-core/dist/telemetry/agent-registry.js +196 -0
- package/plugins/huaweicloud-core/dist/telemetry/agent-versions-desktop.js +143 -0
- package/plugins/huaweicloud-core/dist/telemetry/agent-versions.js +78 -0
- package/plugins/huaweicloud-core/dist/telemetry/event-pipeline.js +206 -0
- package/plugins/huaweicloud-core/dist/telemetry/hook-ingest.js +81 -0
- package/plugins/huaweicloud-core/dist/telemetry/identity-stamps.js +104 -0
- package/plugins/huaweicloud-core/dist/telemetry/invoke-value.js +47 -0
- package/plugins/huaweicloud-core/dist/telemetry/telemetry-fs.js +42 -0
- package/plugins/huaweicloud-core/dist/telemetry/telemetry-types.js +14 -0
- package/plugins/huaweicloud-core/dist/telemetry/telemetry-values.js +121 -0
- package/plugins/huaweicloud-core/dist/telemetry/telemetry.js +262 -0
- package/plugins/huaweicloud-core/dist/tool-definitions.js +276 -0
- package/plugins/huaweicloud-core/dist/tool-schemas.js +156 -0
- package/plugins/huaweicloud-core/dist/tools.js +269 -0
- package/plugins/huaweicloud-core/dist/update-cache.js +79 -0
- package/plugins/huaweicloud-core/dist/update-check.js +23 -0
- package/plugins/huaweicloud-core/dist/update-hint.js +45 -0
- package/plugins/huaweicloud-core/dist/update-installed.js +53 -0
- package/plugins/huaweicloud-core/dist/update-registry.js +141 -0
- package/plugins/huaweicloud-core/dist/update-semver.js +76 -0
- package/plugins/huaweicloud-core/dist/update-skip.js +81 -0
- package/plugins/huaweicloud-core/dist/update-upgrade.js +94 -0
- package/plugins/huaweicloud-core/dist/vendor-gate.js +89 -0
- package/plugins/huaweicloud-core/dist/ws-exec/hwlink-exec-client.js +10 -0
- package/plugins/huaweicloud-core/dist/ws-exec/hwlink-exec-pending.js +71 -0
- package/plugins/huaweicloud-core/dist/ws-exec/hwlink-exec-session.js +235 -0
- package/plugins/huaweicloud-core/dist/ws-exec/hwlink-fair-queue.js +139 -0
- package/plugins/huaweicloud-core/dist/ws-exec/hwlink-interactive-terminal.js +106 -0
- package/plugins/huaweicloud-core/dist/ws-exec/hwlink-multiplexer.js +229 -0
- package/plugins/huaweicloud-core/dist/ws-exec/hwlink-normalize.js +53 -0
- package/plugins/huaweicloud-core/dist/ws-exec/hwlink-packet.js +148 -0
- package/plugins/huaweicloud-core/dist/ws-exec/hwlink-terminal-channel.js +155 -0
- package/plugins/huaweicloud-core/dist/ws-exec/hwlink-tunnel-channel.js +254 -0
- package/plugins/huaweicloud-core/dist/ws-exec/index.js +20 -0
- package/plugins/huaweicloud-core/dist/ws-exec/ws-exec-client.js +76 -0
- package/plugins/huaweicloud-core/hooks/huaweicloud-safety.mjs +62 -3
- package/plugins/huaweicloud-core/hooks/huaweicloud-safety.py +2500 -33
- package/plugins/huaweicloud-core/openclaw.plugin.json +2 -2
- package/plugins/huaweicloud-core/safety/policy.json +45 -4
- package/plugins/huaweicloud-core/safety/rules/cloud-risk-rules.json +47 -9
- package/plugins/huaweicloud-core/skills/.manifest.json +67 -0
- package/plugins/huaweicloud-core/skills/huawei-billing/SKILL.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-cbr/SKILL.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-cce/SKILL.md +3 -1
- package/plugins/huaweicloud-core/skills/huawei-cloud-apig-instance-management/SKILL.md +27 -51
- package/plugins/huaweicloud-core/skills/huawei-cloud-apig-instance-management/references/acceptance-criteria.md +10 -12
- package/plugins/huaweicloud-core/skills/huawei-cloud-apig-instance-management/references/cli-installation-guide.md +23 -27
- package/plugins/huaweicloud-core/skills/huawei-cloud-apig-instance-management/references/dataflow-diagram.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-cloud-apig-instance-management/references/iam-policies.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-cloud-apig-instance-management/references/verification-method.md +8 -16
- package/plugins/huaweicloud-core/skills/huawei-cloud-apig-instance-management/scripts/cli/cli_entry.py +71 -461
- package/plugins/huaweicloud-core/skills/huawei-cloud-apig-instance-management/scripts/ensure_cli.sh +28 -68
- package/plugins/huaweicloud-core/skills/huawei-cloud-cts-trace-management/SKILL.md +56 -144
- package/plugins/huaweicloud-core/skills/huawei-cloud-cts-trace-management/references/acceptance-criteria.md +14 -12
- package/plugins/huaweicloud-core/skills/huawei-cloud-cts-trace-management/references/cli-installation-guide.md +72 -39
- package/plugins/huaweicloud-core/skills/huawei-cloud-cts-trace-management/references/dataflow-diagram.md +3 -1
- package/plugins/huaweicloud-core/skills/huawei-cloud-cts-trace-management/references/iam-policies.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-cloud-cts-trace-management/references/verification-method.md +12 -0
- package/plugins/huaweicloud-core/skills/huawei-cloud-cts-trace-management/scripts/cli/cli_entry.py +67 -307
- package/plugins/huaweicloud-core/skills/huawei-cloud-cts-trace-management/scripts/ensure_cli.sh +28 -68
- package/plugins/huaweicloud-core/skills/huawei-cloud-cts-trace-management/templates/test-defaults.json +1 -1
- package/plugins/huaweicloud-core/skills/huawei-cloud-cts-trace-management/templates/test-vars.json +9 -9
- package/plugins/huaweicloud-core/skills/huawei-cloud-dds-dcs-instance-management/SKILL.md +82 -160
- package/plugins/huaweicloud-core/skills/huawei-cloud-dds-dcs-instance-management/references/acceptance-criteria.md +9 -8
- package/plugins/huaweicloud-core/skills/huawei-cloud-dds-dcs-instance-management/references/cli-installation-guide.md +73 -40
- package/plugins/huaweicloud-core/skills/huawei-cloud-dds-dcs-instance-management/references/dataflow-diagram.md +4 -2
- package/plugins/huaweicloud-core/skills/huawei-cloud-dds-dcs-instance-management/references/iam-policies.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-cloud-dds-dcs-instance-management/references/related-commands.md +16 -14
- package/plugins/huaweicloud-core/skills/huawei-cloud-dds-dcs-instance-management/references/verification-method.md +7 -20
- package/plugins/huaweicloud-core/skills/huawei-cloud-dds-dcs-instance-management/scripts/cli/cli_entry.py +67 -307
- package/plugins/huaweicloud-core/skills/huawei-cloud-dds-dcs-instance-management/scripts/ensure_cli.sh +28 -68
- package/plugins/huaweicloud-core/skills/huawei-cloud-deployment-task-management/SKILL.md +92 -95
- package/plugins/huaweicloud-core/skills/huawei-cloud-deployment-task-management/references/acceptance-criteria.md +11 -10
- package/plugins/huaweicloud-core/skills/huawei-cloud-deployment-task-management/references/cli-installation-guide.md +86 -67
- package/plugins/huaweicloud-core/skills/huawei-cloud-deployment-task-management/references/dataflow-diagram.md +4 -2
- package/plugins/huaweicloud-core/skills/huawei-cloud-deployment-task-management/references/iam-policies.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-cloud-deployment-task-management/references/test-data-guide.md +29 -25
- package/plugins/huaweicloud-core/skills/huawei-cloud-deployment-task-management/references/verification-method.md +13 -11
- package/plugins/huaweicloud-core/skills/huawei-cloud-deployment-task-management/scripts/cli/cli_entry.py +67 -307
- package/plugins/huaweicloud-core/skills/huawei-cloud-deployment-task-management/scripts/ensure_cli.sh +28 -68
- package/plugins/huaweicloud-core/skills/huawei-cloud-dew-key-management/SKILL.md +107 -127
- package/plugins/huaweicloud-core/skills/huawei-cloud-dew-key-management/references/acceptance-criteria.md +26 -25
- package/plugins/huaweicloud-core/skills/huawei-cloud-dew-key-management/references/cli-installation-guide.md +66 -51
- package/plugins/huaweicloud-core/skills/huawei-cloud-dew-key-management/references/csms-usage.md +23 -19
- package/plugins/huaweicloud-core/skills/huawei-cloud-dew-key-management/references/dataflow-diagram.md +4 -2
- package/plugins/huaweicloud-core/skills/huawei-cloud-dew-key-management/references/iam-policies.md +25 -30
- package/plugins/huaweicloud-core/skills/huawei-cloud-dew-key-management/references/kms-usage.md +13 -11
- package/plugins/huaweicloud-core/skills/huawei-cloud-dew-key-management/references/verification-method.md +13 -7
- package/plugins/huaweicloud-core/skills/huawei-cloud-dew-key-management/scripts/cli/cli_entry.py +67 -354
- package/plugins/huaweicloud-core/skills/huawei-cloud-dew-key-management/scripts/ensure_cli.sh +28 -69
- package/plugins/huaweicloud-core/skills/huawei-cloud-dew-key-management/templates/test-vars.json +11 -11
- package/plugins/huaweicloud-core/skills/huawei-cloud-eye/SKILL.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-cloud-gaussdb-instance-management/SKILL.md +28 -109
- package/plugins/huaweicloud-core/skills/huawei-cloud-gaussdb-instance-management/references/acceptance-criteria.md +27 -31
- package/plugins/huaweicloud-core/skills/huawei-cloud-gaussdb-instance-management/references/cli-installation-guide.md +49 -24
- package/plugins/huaweicloud-core/skills/huawei-cloud-gaussdb-instance-management/references/dataflow-diagram.md +2 -5
- package/plugins/huaweicloud-core/skills/huawei-cloud-gaussdb-instance-management/references/iam-policies.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-cloud-gaussdb-instance-management/references/verification-method.md +8 -25
- package/plugins/huaweicloud-core/skills/huawei-cloud-gaussdb-instance-management/scripts/cli/cli_entry.py +67 -307
- package/plugins/huaweicloud-core/skills/huawei-cloud-gaussdb-instance-management/scripts/ensure_cli.sh +28 -68
- package/plugins/huaweicloud-core/skills/huawei-cloud-smn-dms-message/SKILL.md +60 -135
- package/plugins/huaweicloud-core/skills/huawei-cloud-smn-dms-message/references/acceptance-criteria.md +9 -11
- package/plugins/huaweicloud-core/skills/huawei-cloud-smn-dms-message/references/cli-installation-guide.md +16 -12
- package/plugins/huaweicloud-core/skills/huawei-cloud-smn-dms-message/references/dataflow-diagram.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-cloud-smn-dms-message/references/engine-operation-reference.md +15 -13
- package/plugins/huaweicloud-core/skills/huawei-cloud-smn-dms-message/references/iam-policies.md +9 -7
- package/plugins/huaweicloud-core/skills/huawei-cloud-smn-dms-message/references/security-audit-guide.md +9 -5
- package/plugins/huaweicloud-core/skills/huawei-cloud-smn-dms-message/references/verification-method.md +16 -37
- package/plugins/huaweicloud-core/skills/huawei-cloud-smn-dms-message/scripts/cli/cli_entry.py +101 -0
- package/plugins/huaweicloud-core/skills/huawei-cloud-smn-dms-message/scripts/ensure_cli.sh +27 -184
- package/plugins/huaweicloud-core/skills/huawei-cloud-waf-aad-rule-management/SKILL.md +71 -103
- package/plugins/huaweicloud-core/skills/huawei-cloud-waf-aad-rule-management/references/acceptance-criteria.md +4 -2
- package/plugins/huaweicloud-core/skills/huawei-cloud-waf-aad-rule-management/references/cli-installation-guide.md +72 -84
- package/plugins/huaweicloud-core/skills/huawei-cloud-waf-aad-rule-management/references/dataflow-diagram.md +3 -3
- package/plugins/huaweicloud-core/skills/huawei-cloud-waf-aad-rule-management/references/iam-policies.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-cloud-waf-aad-rule-management/references/related-commands.md +7 -5
- package/plugins/huaweicloud-core/skills/huawei-cloud-waf-aad-rule-management/references/verification-method.md +11 -9
- package/plugins/huaweicloud-core/skills/huawei-cloud-waf-aad-rule-management/scripts/cli/cli_entry.py +101 -0
- package/plugins/huaweicloud-core/skills/huawei-cloud-waf-aad-rule-management/scripts/ensure_cli.sh +27 -42
- package/plugins/huaweicloud-core/skills/huawei-ecs/SKILL.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/create-instance.md +24 -13
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/evs.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/flavors.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/hc-activity.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/troubleshooting.md +25 -21
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/windows-ssh.md +7 -5
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/SKILL.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/apig-event-format.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/create-function.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/deploy-workflow.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/triggers.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-getting-started/SKILL.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-iac/SKILL.md +40 -38
- package/plugins/huaweicloud-core/skills/huawei-iac/references/architectures.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-iac/references/resource-catalog.md +14 -12
- package/plugins/huaweicloud-core/skills/huawei-iac/references/state-file.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-iam/SKILL.md +3 -1
- package/plugins/huaweicloud-core/skills/huawei-iam/references/policy-examples.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-iam/references/quick-ref.md +4 -1
- package/plugins/huaweicloud-core/skills/huawei-modelarts/SKILL.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-obs/SKILL.md +32 -29
- package/plugins/huaweicloud-core/skills/huawei-obs/references/bucket-create.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-obs/references/bucket-lifecycle.md +4 -2
- package/plugins/huaweicloud-core/skills/huawei-obs/references/common-pitfalls.md +17 -15
- package/plugins/huaweicloud-core/skills/huawei-obs/references/single-file-share.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-obs/references/static-website.md +10 -6
- package/plugins/huaweicloud-core/skills/huawei-openapi/SKILL.md +50 -0
- package/plugins/huaweicloud-core/skills/huawei-rds/SKILL.md +15 -13
- package/plugins/huaweicloud-core/skills/huawei-sandbox/SKILL.md +98 -91
- package/plugins/huaweicloud-core/skills/huawei-sandbox/references/framework-commands.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-sandbox/references/fullstack-postgrest.md +33 -27
- package/plugins/huaweicloud-core/skills/huawei-sandbox/references/nginx-templates.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-sandbox/references/resource-pool.md +3 -1
- package/plugins/huaweicloud-core/skills/huawei-sandbox/references/tunnel-persistence.md +9 -2
- package/plugins/huaweicloud-core/skills/huawei-voucher/SKILL.md +5 -3
- package/plugins/huaweicloud-core/skills/huawei-vpc/SKILL.md +3 -0
- package/plugins/huaweicloud-core/skills/huawei-vpc/references/network.md +16 -0
- package/plugins/huaweicloud-core/skills/huawei-vpc/references/security-group.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-vpc/references/subnet.md +2 -0
- package/plugins/huaweicloud-core/skills/huaweicloud-api-and-sdk/SKILL.md +3 -0
- package/plugins/huaweicloud-core/skills/huaweicloud-capability-discovery/SKILL.md +16 -13
- package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/SKILL.md +6 -11
- package/plugins/huaweicloud-core/skills/huaweicloud-core/SKILL.md +38 -35
- package/plugins/huaweicloud-core/skills/huaweicloud-core/references/report-issue.md +2 -0
- package/plugins/huaweicloud-core/skills/huaweicloud-core/references/select.md +2 -0
- package/plugins/huaweicloud-core/skills/huaweicloud-safety/SKILL.md +3 -0
- package/plugins/huaweicloud-core/skills/huaweicloud-safety/references/secrets.md +32 -0
- package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/SKILL.md +2 -0
- package/plugins/huaweicloud-core/src/agents/atomcode.ts +138 -0
- package/plugins/huaweicloud-core/src/agents/codearts-work.ts +136 -0
- package/plugins/huaweicloud-core/src/agents/codearts.ts +92 -0
- package/plugins/huaweicloud-core/src/agents/codex-desktop.ts +219 -0
- package/plugins/huaweicloud-core/src/agents/codex.ts +230 -0
- package/plugins/huaweicloud-core/src/agents/dsh-patch.ts +195 -0
- package/plugins/huaweicloud-core/src/agents/dsh.ts +153 -0
- package/plugins/huaweicloud-core/src/agents/hermes-config.ts +974 -0
- package/plugins/huaweicloud-core/src/agents/hermes-hook-plugin.ts +99 -0
- package/plugins/huaweicloud-core/src/agents/hermes-hooks.ts +187 -0
- package/plugins/huaweicloud-core/src/agents/hermes-sdk.ts +63 -0
- package/plugins/huaweicloud-core/src/agents/hermes.ts +192 -0
- package/plugins/huaweicloud-core/src/agents/officeace-registry.ts +188 -0
- package/plugins/huaweicloud-core/src/agents/officeace-sqlite.ts +153 -0
- package/plugins/huaweicloud-core/src/agents/officeace.ts +202 -0
- package/plugins/huaweicloud-core/src/agents/openclaw.ts +73 -0
- package/plugins/huaweicloud-core/src/agents/opencode-config.ts +193 -0
- package/plugins/huaweicloud-core/src/agents/opencode.ts +148 -0
- package/plugins/huaweicloud-core/src/agents/workbuddy.ts +216 -0
- package/plugins/huaweicloud-core/src/auth/account-type.ts +191 -0
- package/plugins/huaweicloud-core/src/auth/agent-registration.ts +267 -0
- package/plugins/huaweicloud-core/src/auth/cli.ts +133 -0
- package/plugins/huaweicloud-core/src/auth/codearts-context.ts +139 -0
- package/plugins/huaweicloud-core/src/auth/credential-placeholder.ts +36 -0
- package/plugins/huaweicloud-core/src/auth/credential-resolver.ts +81 -0
- package/plugins/huaweicloud-core/src/auth/credential-validator.ts +176 -0
- package/plugins/huaweicloud-core/src/auth/credentials.ts +52 -0
- package/plugins/huaweicloud-core/src/auth/{guidance.mjs → error-table.ts} +58 -12
- package/plugins/huaweicloud-core/src/auth/hcloud-profile.ts +119 -0
- package/plugins/huaweicloud-core/src/auth/init-cli.ts +155 -0
- package/plugins/huaweicloud-core/src/auth/missing-credential-error.ts +44 -0
- package/plugins/huaweicloud-core/src/auth/obs-config.ts +42 -0
- package/plugins/huaweicloud-core/src/auth/project-id.ts +104 -0
- package/plugins/huaweicloud-core/src/auth/reconcile.ts +345 -0
- package/plugins/huaweicloud-core/src/auth/runtime-credentials.ts +38 -0
- package/plugins/huaweicloud-core/src/auth/s1-store.ts +214 -0
- package/plugins/huaweicloud-core/src/auth/{service.mjs → service.ts} +210 -36
- package/plugins/huaweicloud-core/src/auth/sts-expiry.ts +58 -0
- package/plugins/huaweicloud-core/src/capability-catalog.ts +519 -0
- package/plugins/huaweicloud-core/src/codearts-sandbox.ts +32 -0
- package/plugins/huaweicloud-core/src/codex-probe.ts +86 -0
- package/plugins/huaweicloud-core/src/data/icons-manifest.v1.json +5 -23
- package/plugins/huaweicloud-core/src/dep/installers/gateway.ts +213 -0
- package/plugins/huaweicloud-core/src/dep/installers/hcloud.ts +407 -0
- package/plugins/huaweicloud-core/src/dep/installers/table.ts +123 -0
- package/plugins/huaweicloud-core/src/dep/provision.ts +335 -0
- package/plugins/huaweicloud-core/src/dep/receipts.ts +464 -0
- package/plugins/huaweicloud-core/src/detect-framework-match.ts +143 -0
- package/plugins/huaweicloud-core/src/detect-framework-pkg.ts +79 -0
- package/plugins/huaweicloud-core/src/detect-framework-scan.ts +117 -0
- package/plugins/huaweicloud-core/src/detect-framework-table.ts +166 -0
- package/plugins/huaweicloud-core/src/detect-framework.ts +8 -0
- package/plugins/huaweicloud-core/src/doctor-native.ts +189 -0
- package/plugins/huaweicloud-core/src/doctor-payload.ts +77 -0
- package/plugins/huaweicloud-core/src/doctor-report.ts +30 -0
- package/plugins/huaweicloud-core/src/explain-error.ts +246 -0
- package/plugins/huaweicloud-core/src/hcloud-api-error.ts +69 -0
- package/plugins/huaweicloud-core/src/hcloud-catalog.ts +115 -0
- package/plugins/huaweicloud-core/src/hcloud-cli.ts +41 -0
- package/plugins/huaweicloud-core/src/hcloud-obs-redact.ts +65 -0
- package/plugins/huaweicloud-core/src/hcloud-plan.ts +344 -0
- package/plugins/huaweicloud-core/src/{hcloud-probe.mjs → hcloud-probe.ts} +87 -60
- package/plugins/huaweicloud-core/src/hcloud-run-once.ts +251 -0
- package/plugins/huaweicloud-core/src/hcloud-run.ts +151 -0
- package/plugins/huaweicloud-core/src/hcloud-sg-preflight.ts +111 -0
- package/plugins/huaweicloud-core/src/hcloud-sts.ts +123 -0
- package/plugins/huaweicloud-core/src/hcloud-triage.ts +80 -0
- package/plugins/huaweicloud-core/src/{icon-library.mjs → icon-library.ts} +115 -23
- package/plugins/huaweicloud-core/src/install-payload.ts +63 -0
- package/plugins/huaweicloud-core/src/install-plan.ts +85 -0
- package/plugins/huaweicloud-core/src/install-prompts.ts +134 -0
- package/plugins/huaweicloud-core/src/koocli-version.ts +87 -0
- package/plugins/huaweicloud-core/src/lib/approval-tokens.ts +315 -0
- package/plugins/huaweicloud-core/src/lib/as-record.ts +10 -0
- package/plugins/huaweicloud-core/src/lib/as-text.ts +16 -0
- package/plugins/huaweicloud-core/src/lib/banner.ts +12 -0
- package/plugins/huaweicloud-core/src/lib/call-trace.ts +153 -0
- package/plugins/huaweicloud-core/src/lib/cli-io.ts +81 -0
- package/plugins/huaweicloud-core/src/lib/credentials.ts +202 -0
- package/plugins/huaweicloud-core/src/lib/dep-resolve.ts +107 -0
- package/plugins/huaweicloud-core/src/lib/dependency-model.ts +236 -0
- package/plugins/huaweicloud-core/src/{sandbox/hdkitservice-api.mjs → lib/hdkit/hdkitservice-api.ts} +99 -118
- package/plugins/huaweicloud-core/src/lib/hdkit/hwlink-api.ts +245 -0
- package/plugins/huaweicloud-core/src/{sandbox/sandbox-pool.mjs → lib/hdkit/sandbox-pool.ts} +115 -47
- package/plugins/huaweicloud-core/src/lib/hw-request-signing.ts +101 -0
- package/plugins/huaweicloud-core/src/lib/koocli-paths.ts +21 -0
- package/plugins/huaweicloud-core/src/lib/native-receipt.ts +131 -0
- package/plugins/huaweicloud-core/src/lib/opencode-permission-seam.ts +145 -0
- package/plugins/huaweicloud-core/src/lib/pack-state.ts +192 -0
- package/plugins/huaweicloud-core/src/lib/pack-types.ts +74 -0
- package/plugins/huaweicloud-core/src/lib/secret-vault/cli.ts +270 -0
- package/plugins/huaweicloud-core/src/lib/secret-vault/custody.ts +468 -0
- package/plugins/huaweicloud-core/src/lib/secret-vault/refs.ts +75 -0
- package/plugins/huaweicloud-core/src/lib/secret-vault/store.ts +357 -0
- package/plugins/huaweicloud-core/src/lib/skill-frontmatter.ts +164 -0
- package/plugins/huaweicloud-core/src/lib/skill-manifest.ts +55 -0
- package/plugins/huaweicloud-core/src/lib/skill-tree.ts +45 -0
- package/plugins/huaweicloud-core/src/lib/tool-schema-parts.ts +80 -0
- package/plugins/huaweicloud-core/src/mcp-agent-config.ts +90 -0
- package/plugins/huaweicloud-core/src/{mcp-config-backup.mjs → mcp-config-backup.ts} +14 -10
- package/plugins/huaweicloud-core/src/mcp-config-io.ts +215 -0
- package/plugins/huaweicloud-core/src/mcp-config-merge.ts +205 -0
- package/plugins/huaweicloud-core/src/mcp-protocol.ts +385 -0
- package/plugins/huaweicloud-core/src/mcp-server-remote.ts +178 -0
- package/plugins/huaweicloud-core/src/mcp-server.ts +87 -0
- package/plugins/huaweicloud-core/src/mcp-stdio-transport.ts +245 -0
- package/plugins/huaweicloud-core/src/officeace-paths.ts +146 -0
- package/plugins/huaweicloud-core/src/packs/auth/pack.ts +14 -0
- package/plugins/huaweicloud-core/src/packs/auth/tools.ts +327 -0
- package/plugins/huaweicloud-core/src/packs/discovery/pack.ts +14 -0
- package/plugins/huaweicloud-core/src/packs/discovery/tools.ts +97 -0
- package/plugins/huaweicloud-core/src/packs/enable.ts +90 -0
- package/plugins/huaweicloud-core/src/packs/huaweicloud-cli/pack.ts +42 -0
- package/plugins/huaweicloud-core/src/packs/huaweicloud-cli/tools.ts +493 -0
- package/plugins/huaweicloud-core/src/packs/huaweicloud-open-mcp/approval.ts +250 -0
- package/plugins/huaweicloud-core/src/packs/huaweicloud-open-mcp/pack.ts +19 -0
- package/plugins/huaweicloud-core/src/packs/huaweicloud-open-mcp/sidecar.ts +603 -0
- package/plugins/huaweicloud-core/src/packs/huaweicloud-open-mcp/tools.ts +155 -0
- package/plugins/huaweicloud-core/src/packs/obs/pack.ts +13 -0
- package/plugins/huaweicloud-core/src/packs/obs/tools.ts +487 -0
- package/plugins/huaweicloud-core/src/packs/registry.ts +162 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/git-transfer.ts +93 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-account.ts +93 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-credentials.ts +144 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-deploy.ts +63 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-session.ts +59 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-tunnel.ts +101 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-upload.ts +46 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/pack.ts +16 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/schemas.ts +249 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/tools.ts +183 -0
- package/plugins/huaweicloud-core/src/packs/secrets/pack.ts +11 -0
- package/plugins/huaweicloud-core/src/packs/secrets/tools.ts +146 -0
- package/plugins/huaweicloud-core/src/packs/update/pack.ts +13 -0
- package/plugins/huaweicloud-core/src/packs/update/tools.ts +107 -0
- package/plugins/huaweicloud-core/src/packs/voucher/pack.ts +13 -0
- package/plugins/huaweicloud-core/src/packs/voucher/tools.ts +112 -0
- package/plugins/huaweicloud-core/src/packs-cli/commands.ts +121 -0
- package/plugins/huaweicloud-core/src/packs-cli/doctor.ts +85 -0
- package/plugins/huaweicloud-core/src/packs-cli/report.ts +171 -0
- package/plugins/huaweicloud-core/src/packs-cli/slots.ts +139 -0
- package/plugins/huaweicloud-core/src/packs-cli/write-command.ts +114 -0
- package/plugins/huaweicloud-core/src/packs-cli/writers.ts +125 -0
- package/plugins/huaweicloud-core/src/packs-configure.ts +104 -0
- package/plugins/huaweicloud-core/src/packs-policy.ts +203 -0
- package/plugins/huaweicloud-core/src/payload-files.ts +78 -0
- package/plugins/huaweicloud-core/src/payload-native-clean.ts +154 -0
- package/plugins/huaweicloud-core/src/payload-native-sync.ts +110 -0
- package/plugins/huaweicloud-core/src/payload-placement.ts +107 -0
- package/plugins/huaweicloud-core/src/payload-roster.ts +85 -0
- package/plugins/huaweicloud-core/src/payload-runtime-deps.ts +68 -0
- package/plugins/huaweicloud-core/src/payload-status.ts +53 -0
- package/plugins/huaweicloud-core/src/payload-utils.ts +51 -0
- package/plugins/huaweicloud-core/src/preflight.ts +250 -0
- package/plugins/huaweicloud-core/src/proxy/cli.ts +103 -0
- package/plugins/huaweicloud-core/src/proxy/{proxy-agent.mjs → proxy-agent.ts} +25 -16
- package/plugins/huaweicloud-core/src/proxy/proxy-bypass.ts +90 -0
- package/plugins/huaweicloud-core/src/proxy/proxy-cidr.ts +98 -0
- package/plugins/huaweicloud-core/src/proxy/proxy-config-io.ts +73 -0
- package/plugins/huaweicloud-core/src/proxy/proxy-config.ts +18 -0
- package/plugins/huaweicloud-core/src/risk-rule-engine.ts +325 -0
- package/plugins/huaweicloud-core/src/safety/classify-hcloud.ts +246 -0
- package/plugins/huaweicloud-core/src/safety/classify-text.ts +1099 -0
- package/plugins/huaweicloud-core/src/safety/command-operation.ts +28 -0
- package/plugins/huaweicloud-core/src/safety/credential-path.ts +25 -0
- package/plugins/huaweicloud-core/src/safety/default-policy.ts +34 -0
- package/plugins/huaweicloud-core/src/safety/feeder.ts +140 -0
- package/plugins/huaweicloud-core/src/safety/heredoc.ts +100 -0
- package/plugins/huaweicloud-core/src/safety/policy.ts +109 -0
- package/plugins/huaweicloud-core/src/safety/redact.ts +63 -0
- package/plugins/huaweicloud-core/src/safety/risk-merge.ts +31 -0
- package/plugins/huaweicloud-core/src/safety/script-stream.ts +95 -0
- package/plugins/huaweicloud-core/src/safety/secret-exec.ts +42 -0
- package/plugins/huaweicloud-core/src/safety/segments.ts +153 -0
- package/plugins/huaweicloud-core/src/safety/shell-text.ts +415 -0
- package/plugins/huaweicloud-core/src/safety/skill-quality-cli.ts +141 -0
- package/plugins/huaweicloud-core/src/safety/tokens.ts +322 -0
- package/plugins/huaweicloud-core/src/safety/unwrap.ts +162 -0
- package/plugins/huaweicloud-core/src/safety/vocabulary.ts +38 -0
- package/plugins/huaweicloud-core/src/safety/windows-rebase.ts +56 -0
- package/plugins/huaweicloud-core/src/safety/windows.ts +133 -0
- package/plugins/huaweicloud-core/src/safety/xargs-argv.ts +79 -0
- package/plugins/huaweicloud-core/src/safety-policy.ts +16 -0
- package/plugins/huaweicloud-core/src/sandbox/deploy-check.ts +307 -0
- package/plugins/huaweicloud-core/src/sandbox/deploy-nginx-verify.ts +96 -0
- package/plugins/huaweicloud-core/src/sandbox/deploy-nginx.ts +300 -0
- package/plugins/huaweicloud-core/src/sandbox/devbridge-auth.ts +291 -0
- package/plugins/huaweicloud-core/src/sandbox/devbridge-exec.ts +28 -0
- package/plugins/huaweicloud-core/src/sandbox/devbridge-expose-flow.ts +289 -0
- package/plugins/huaweicloud-core/src/sandbox/devbridge-expose.ts +310 -0
- package/plugins/huaweicloud-core/src/sandbox/devbridge-gateway.ts +36 -0
- package/plugins/huaweicloud-core/src/sandbox/devbridge-keepalive.ts +254 -0
- package/plugins/huaweicloud-core/src/sandbox/{devbridge-key.mjs → devbridge-key.ts} +48 -32
- package/plugins/huaweicloud-core/src/sandbox/devbridge-renew.ts +87 -0
- package/plugins/huaweicloud-core/src/sandbox/devbridge-tunnel.ts +79 -0
- package/plugins/huaweicloud-core/src/sandbox/devbridge-validation.ts +100 -0
- package/plugins/huaweicloud-core/src/sandbox/devbridge-verify.ts +120 -0
- package/plugins/huaweicloud-core/src/sandbox/hwlink-connection.ts +188 -0
- package/plugins/huaweicloud-core/src/sandbox/sandbox-output.ts +46 -0
- package/plugins/huaweicloud-core/src/sandbox/session-manager.ts +89 -0
- package/plugins/huaweicloud-core/src/sandbox/tunnel-http.ts +155 -0
- package/plugins/huaweicloud-core/src/sandbox/{uninstall-cleanup.mjs → uninstall-cleanup.ts} +4 -4
- package/plugins/huaweicloud-core/src/sandbox/upload-diagnostics.ts +46 -0
- package/plugins/huaweicloud-core/src/sandbox/upload-file.ts +161 -0
- package/plugins/huaweicloud-core/src/sandbox/upload-project.ts +218 -0
- package/plugins/huaweicloud-core/src/sandbox/upload-transport.ts +150 -0
- package/plugins/huaweicloud-core/src/sandbox/ws-exec-loader.ts +104 -0
- package/plugins/huaweicloud-core/src/search-docs.ts +64 -0
- package/plugins/huaweicloud-core/src/{search-market.mjs → search-market.ts} +96 -28
- package/plugins/huaweicloud-core/src/services/availability.ts +53 -0
- package/plugins/huaweicloud-core/src/services/regions.ts +110 -0
- package/plugins/huaweicloud-core/src/setup-cli.ts +1563 -0
- package/plugins/huaweicloud-core/src/skill-disclosure.ts +242 -0
- package/plugins/huaweicloud-core/src/targets.ts +156 -0
- package/plugins/huaweicloud-core/src/telemetry/{agent-detect.mjs → agent-detect.ts} +16 -5
- package/plugins/huaweicloud-core/src/telemetry/agent-registry.ts +210 -0
- package/plugins/huaweicloud-core/src/telemetry/agent-versions-desktop.ts +138 -0
- package/plugins/huaweicloud-core/src/telemetry/agent-versions.ts +84 -0
- package/plugins/huaweicloud-core/src/telemetry/event-pipeline.ts +214 -0
- package/plugins/huaweicloud-core/src/telemetry/hook-ingest.ts +82 -0
- package/plugins/huaweicloud-core/src/telemetry/identity-stamps.ts +108 -0
- package/plugins/huaweicloud-core/src/telemetry/invoke-value.ts +47 -0
- package/plugins/huaweicloud-core/src/telemetry/telemetry-fs.ts +47 -0
- package/plugins/huaweicloud-core/src/telemetry/telemetry-types.ts +97 -0
- package/plugins/huaweicloud-core/src/telemetry/telemetry-values.ts +116 -0
- package/plugins/huaweicloud-core/src/telemetry/telemetry.ts +299 -0
- package/plugins/huaweicloud-core/src/tool-definitions.ts +294 -0
- package/plugins/huaweicloud-core/src/tool-schemas.ts +180 -0
- package/plugins/huaweicloud-core/src/tools.ts +417 -0
- package/plugins/huaweicloud-core/src/update-cache.ts +95 -0
- package/plugins/huaweicloud-core/src/update-check.ts +51 -0
- package/plugins/huaweicloud-core/src/update-hint.ts +82 -0
- package/plugins/huaweicloud-core/src/update-installed.ts +53 -0
- package/plugins/huaweicloud-core/src/update-registry.ts +146 -0
- package/plugins/huaweicloud-core/src/update-semver.ts +80 -0
- package/plugins/huaweicloud-core/src/update-skip.ts +94 -0
- package/plugins/huaweicloud-core/src/update-upgrade.ts +123 -0
- package/plugins/huaweicloud-core/src/vendor-gate.ts +103 -0
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-exec-client.ts +15 -0
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-exec-pending.ts +113 -0
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-exec-session.ts +334 -0
- package/plugins/huaweicloud-core/src/ws-exec/{hwlink-fair-queue.js → hwlink-fair-queue.ts} +46 -15
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-interactive-terminal.ts +158 -0
- package/plugins/huaweicloud-core/src/ws-exec/{hwlink-multiplexer.js → hwlink-multiplexer.ts} +108 -30
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-normalize.ts +60 -0
- package/plugins/huaweicloud-core/src/ws-exec/{hwlink-packet.js → hwlink-packet.ts} +40 -16
- package/plugins/huaweicloud-core/src/ws-exec/{hwlink-terminal-channel.js → hwlink-terminal-channel.ts} +30 -18
- package/plugins/huaweicloud-core/src/ws-exec/{hwlink-tunnel-channel.mjs → hwlink-tunnel-channel.ts} +75 -27
- package/plugins/huaweicloud-core/src/ws-exec/{index.js → index.ts} +11 -11
- package/plugins/huaweicloud-core/src/ws-exec/ws-exec-client.ts +102 -0
- package/plugins/huaweicloud-core/tsconfig.json +21 -0
- package/rules/huawei-agent-rules.mdc +2 -2
- package/integrations/hermes/skills-snapshot.json +0 -175
- package/integrations/opencode/skills/huaweicloud-core/SKILL.md +0 -32
- package/plugins/huaweicloud-core/skills/huawei-cloud-apig-instance-management/scripts/cli/cli_reporting.py +0 -589
- package/plugins/huaweicloud-core/skills/huawei-cloud-cts-trace-management/references/test-report.md +0 -35
- package/plugins/huaweicloud-core/skills/huawei-cloud-cts-trace-management/scripts/cli/cli_reporting.py +0 -928
- package/plugins/huaweicloud-core/skills/huawei-cloud-dds-dcs-instance-management/scripts/cli/cli_reporting.py +0 -928
- package/plugins/huaweicloud-core/skills/huawei-cloud-deployment-task-management/references/test-report.md +0 -52
- package/plugins/huaweicloud-core/skills/huawei-cloud-deployment-task-management/scripts/cli/cli_reporting.py +0 -928
- package/plugins/huaweicloud-core/skills/huawei-cloud-dew-key-management/scripts/cli/cli_reporting.py +0 -577
- package/plugins/huaweicloud-core/skills/huawei-cloud-gaussdb-instance-management/scripts/cli/cli_reporting.py +0 -928
- package/plugins/huaweicloud-core/skills/huawei-cloud-gaussdb-instance-management/scripts/gaussdb_cli.sh +0 -138
- package/plugins/huaweicloud-core/skills/huawei-cloud-smn-dms-message/scripts/install_cli.sh +0 -94
- package/plugins/huaweicloud-core/skills/huawei-cloud-smn-dms-message/scripts/smn_dms_skill.py +0 -444
- package/plugins/huaweicloud-core/src/account-type.mjs +0 -135
- package/plugins/huaweicloud-core/src/auth/agent-registration.mjs +0 -243
- package/plugins/huaweicloud-core/src/auth/credential-validator.mjs +0 -198
- package/plugins/huaweicloud-core/src/auth/credentials.mjs +0 -446
- package/plugins/huaweicloud-core/src/auth/project-id.mjs +0 -68
- package/plugins/huaweicloud-core/src/auth/reconcile.mjs +0 -257
- package/plugins/huaweicloud-core/src/detect-framework.mjs +0 -402
- package/plugins/huaweicloud-core/src/hcloud-cli.mjs +0 -825
- package/plugins/huaweicloud-core/src/koocli-version.mjs +0 -47
- package/plugins/huaweicloud-core/src/mcp-config-merge.mjs +0 -219
- package/plugins/huaweicloud-core/src/mcp-protocol.mjs +0 -109
- package/plugins/huaweicloud-core/src/mcp-server-remote.mjs +0 -108
- package/plugins/huaweicloud-core/src/mcp-server.mjs +0 -221
- package/plugins/huaweicloud-core/src/officeace-paths.mjs +0 -51
- package/plugins/huaweicloud-core/src/preflight.mjs +0 -125
- package/plugins/huaweicloud-core/src/proxy/proxy-config.mjs +0 -187
- package/plugins/huaweicloud-core/src/risk-rule-engine.mjs +0 -182
- package/plugins/huaweicloud-core/src/safety-policy.mjs +0 -625
- package/plugins/huaweicloud-core/src/sandbox/hwlink-api.mjs +0 -224
- package/plugins/huaweicloud-core/src/sandbox/session-manager.mjs +0 -2594
- package/plugins/huaweicloud-core/src/setup-cli.mjs +0 -5379
- package/plugins/huaweicloud-core/src/telemetry/agent-registry.mjs +0 -341
- package/plugins/huaweicloud-core/src/telemetry/telemetry.mjs +0 -492
- package/plugins/huaweicloud-core/src/tools.mjs +0 -3190
- package/plugins/huaweicloud-core/src/update-check.mjs +0 -476
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-exec-client.js +0 -461
- package/plugins/huaweicloud-core/src/ws-exec/ws-exec-client.js +0 -365
|
@@ -0,0 +1,603 @@
|
|
|
1
|
+
import { spawn, type ChildProcess } from 'node:child_process';
|
|
2
|
+
import { mkdtempSync, rmSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { isAbsolute, join } from 'node:path';
|
|
5
|
+
|
|
6
|
+
import { DEPENDENCIES } from '../../lib/dependency-model.ts';
|
|
7
|
+
import { resolveDependencyCommand } from '../../lib/dep-resolve.ts';
|
|
8
|
+
import { ensurePackState, packStateDir } from '../../lib/pack-state.ts';
|
|
9
|
+
import { redactSecrets } from '../../safety-policy.ts';
|
|
10
|
+
|
|
11
|
+
// Process-scope singleton for the huaweicloud-open-mcp sidecar.
|
|
12
|
+
//
|
|
13
|
+
// Ownership: the sidecar belongs to THIS PROCESS, never to an McpServer
|
|
14
|
+
// object. The remote transport constructs and closes a server per HTTP
|
|
15
|
+
// request (src/mcp-server-remote.ts), so any lifecycle hooked on server
|
|
16
|
+
// construction or close would kill the sidecar once per request. The
|
|
17
|
+
// registry imports every pack's handler modules unconditionally, so module
|
|
18
|
+
// scope must stay side-effect free: the child spawns lazily on the first
|
|
19
|
+
// tool call, which is also what keeps a DEVKIT_PACKS-trimmed server from
|
|
20
|
+
// ever spawning it — the tools are not registered, so no call arrives.
|
|
21
|
+
//
|
|
22
|
+
// Lifetime: the child's stdin is a pipe held by this process. When the
|
|
23
|
+
// parent dies the pipe closes and the child sees EOF on stdin — the same
|
|
24
|
+
// shutdown signal this devkit's own stdio transport uses — and exits. No
|
|
25
|
+
// detached flag, no pidfile.
|
|
26
|
+
//
|
|
27
|
+
// Protocol: hand-rolled newline-delimited JSON-RPC 2.0 client. Only
|
|
28
|
+
// dist/mcp-server.js may import the MCP SDK (esbuild bundles it there), so
|
|
29
|
+
// the sidecar speaks the wire protocol directly; initialize +
|
|
30
|
+
// notifications/initialized + tools/call is the full surface the proxy
|
|
31
|
+
// needs. A per-call timeout rejects the pending entry without killing the
|
|
32
|
+
// child: the gateway retries its own HTTP internally, and one slow call
|
|
33
|
+
// must not take the server down for the calls after it.
|
|
34
|
+
|
|
35
|
+
const HANDSHAKE_TIMEOUT_MS = 20_000;
|
|
36
|
+
const CALL_TIMEOUT_MS = 60_000;
|
|
37
|
+
const STDERR_TAIL_LIMIT = 4096;
|
|
38
|
+
|
|
39
|
+
const stats = { spawns: 0, lastPid: null as number | null };
|
|
40
|
+
|
|
41
|
+
interface PendingEntry {
|
|
42
|
+
resolve: (_value: unknown) => void;
|
|
43
|
+
reject: (_error: Error) => void;
|
|
44
|
+
timer: ReturnType<typeof setTimeout>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// One newline-delimited JSON-RPC reply from the gateway child, asserted once
|
|
48
|
+
// at the JSON.parse boundary (same pattern as the sidecar.call casts below).
|
|
49
|
+
interface JsonRpcReply {
|
|
50
|
+
id?: number;
|
|
51
|
+
result?: unknown;
|
|
52
|
+
error?: { message?: string };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
class OpenMcpSidecar {
|
|
56
|
+
readonly child: ChildProcess;
|
|
57
|
+
private nextId = 1;
|
|
58
|
+
private readonly pending = new Map<number, PendingEntry>();
|
|
59
|
+
// Named lineBuffer, not buffer: the unicorn no-unsafe-buffer-conversion
|
|
60
|
+
// rule pattern-matches `<x>.buffer.slice(...)` as a TypedArray conversion.
|
|
61
|
+
private lineBuffer = '';
|
|
62
|
+
stderrTail = '';
|
|
63
|
+
alive = true;
|
|
64
|
+
|
|
65
|
+
constructor(child: ChildProcess) {
|
|
66
|
+
this.child = child;
|
|
67
|
+
if (!child.stdout || !child.stderr || !child.stdin) throw new Error('sidecar spawned without piped stdio');
|
|
68
|
+
child.stdout.setEncoding('utf8');
|
|
69
|
+
child.stdout.on('data', (chunk: string) => this.onStdout(chunk));
|
|
70
|
+
child.stderr.setEncoding('utf8');
|
|
71
|
+
child.stderr.on('data', (chunk: string) => {
|
|
72
|
+
this.stderrTail = (this.stderrTail + chunk).slice(-STDERR_TAIL_LIMIT);
|
|
73
|
+
});
|
|
74
|
+
// A write landing in the window between the child's OS-level death and
|
|
75
|
+
// Node's 'exit' delivery EPIPEs asynchronously on this socket; without a
|
|
76
|
+
// listener that error is unhandled and takes down the whole server.
|
|
77
|
+
// Routing it into onExit rejects the in-flight call fast instead.
|
|
78
|
+
child.stdin.on('error', () => this.onExit('sidecar stdin write failed'));
|
|
79
|
+
child.on('exit', () => this.onExit('sidecar process exited'));
|
|
80
|
+
child.on('error', (error) => this.onExit(error.message));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private onStdout(chunk: string): void {
|
|
84
|
+
this.lineBuffer += chunk;
|
|
85
|
+
let newline = this.lineBuffer.indexOf('\n');
|
|
86
|
+
while (newline >= 0) {
|
|
87
|
+
const line = this.lineBuffer.slice(0, newline).trim();
|
|
88
|
+
this.lineBuffer = this.lineBuffer.slice(newline + 1);
|
|
89
|
+
if (line) this.onLine(line);
|
|
90
|
+
newline = this.lineBuffer.indexOf('\n');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private onLine(line: string): void {
|
|
95
|
+
let message: JsonRpcReply;
|
|
96
|
+
try {
|
|
97
|
+
message = JSON.parse(line) as JsonRpcReply;
|
|
98
|
+
} catch {
|
|
99
|
+
return; // non-JSON noise on stdout; the protocol is line-delimited JSON only
|
|
100
|
+
}
|
|
101
|
+
if (typeof message.id !== 'number') return; // server notification: nothing subscribed
|
|
102
|
+
const entry = this.pending.get(message.id);
|
|
103
|
+
if (!entry) return;
|
|
104
|
+
clearTimeout(entry.timer);
|
|
105
|
+
this.pending.delete(message.id);
|
|
106
|
+
if (message.error) entry.reject(new Error(message.error.message || 'open-mcp gateway error'));
|
|
107
|
+
else entry.resolve(message.result);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private onExit(reason: string): void {
|
|
111
|
+
if (!this.alive) return;
|
|
112
|
+
this.alive = false;
|
|
113
|
+
for (const [, entry] of this.pending) {
|
|
114
|
+
clearTimeout(entry.timer);
|
|
115
|
+
entry.reject(new Error(`${reason}${this.stderrTail ? ` (stderr: ${this.stderrTail})` : ''}`));
|
|
116
|
+
}
|
|
117
|
+
this.pending.clear();
|
|
118
|
+
// Only the current singleton's death clears it: a stale child (a
|
|
119
|
+
// handshake-failure orphan being killed, or a reset victim exiting
|
|
120
|
+
// late) must not drop a healthy replacement.
|
|
121
|
+
if (currentSidecar === this) {
|
|
122
|
+
currentSidecar = null;
|
|
123
|
+
sidecarPromise = null;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
request(method: string, params: Record<string, unknown>, timeoutMs: number): Promise<unknown> {
|
|
128
|
+
if (!this.alive) {
|
|
129
|
+
// The caller holds a reference from before the child died; writing
|
|
130
|
+
// would be silently dropped and burn the full timeout.
|
|
131
|
+
return Promise.reject(new Error('open-mcp gateway sidecar is dead; the next call respawns it'));
|
|
132
|
+
}
|
|
133
|
+
const id = this.nextId++;
|
|
134
|
+
return new Promise((resolve, reject) => {
|
|
135
|
+
const timer = setTimeout(() => {
|
|
136
|
+
this.pending.delete(id);
|
|
137
|
+
reject(new Error(`open-mcp gateway ${method} timed out after ${timeoutMs}ms`));
|
|
138
|
+
}, timeoutMs);
|
|
139
|
+
this.pending.set(id, { resolve, reject, timer });
|
|
140
|
+
this.child.stdin!.write(`${JSON.stringify({ jsonrpc: '2.0', id, method, params })}\n`);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
notify(method: string): void {
|
|
145
|
+
if (!this.alive) return;
|
|
146
|
+
this.child.stdin!.write(`${JSON.stringify({ jsonrpc: '2.0', method })}\n`);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// SIGTERM → SIGKILL escalation, the hcloud-cli.ts supervision pattern:
|
|
150
|
+
// a child that ignores SIGTERM still dies, and the escalation timer is
|
|
151
|
+
// cleared the moment the exit lands.
|
|
152
|
+
kill(): void {
|
|
153
|
+
if (!this.alive) return;
|
|
154
|
+
this.child.kill('SIGTERM');
|
|
155
|
+
const force = setTimeout(() => this.child.kill('SIGKILL'), 3000);
|
|
156
|
+
this.child.once('exit', () => clearTimeout(force));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// kill() plus the bounded wait for the actual exit, so a replacement spawn
|
|
160
|
+
// never overlaps a live old child. The bound sits past kill's 3s SIGKILL
|
|
161
|
+
// escalation; a child still alive after that resolves anyway — the next
|
|
162
|
+
// spawn's handshake failure path would kill its own child, never this one.
|
|
163
|
+
async stop(): Promise<void> {
|
|
164
|
+
if (!this.alive) return;
|
|
165
|
+
this.kill();
|
|
166
|
+
await new Promise<void>((resolve) => {
|
|
167
|
+
const bound = setTimeout(resolve, 4500);
|
|
168
|
+
this.child.once('exit', () => {
|
|
169
|
+
clearTimeout(bound);
|
|
170
|
+
resolve();
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async handshake(): Promise<void> {
|
|
176
|
+
await this.request(
|
|
177
|
+
'initialize',
|
|
178
|
+
{
|
|
179
|
+
protocolVersion: '2025-03-26',
|
|
180
|
+
capabilities: {},
|
|
181
|
+
clientInfo: { name: 'huaweicloud-devkit', version: '1.0.0' },
|
|
182
|
+
},
|
|
183
|
+
HANDSHAKE_TIMEOUT_MS,
|
|
184
|
+
);
|
|
185
|
+
this.notify('notifications/initialized');
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
async call(name: string, args: Record<string, unknown>, timeoutMs = CALL_TIMEOUT_MS): Promise<unknown> {
|
|
189
|
+
return this.request('tools/call', { name, arguments: args }, timeoutMs);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
let sidecarPromise: Promise<OpenMcpSidecar> | null = null;
|
|
194
|
+
// The resolved instance behind sidecarPromise; onExit compares against it so
|
|
195
|
+
// a stale child's late exit cannot clear a healthy replacement.
|
|
196
|
+
let currentSidecar: OpenMcpSidecar | null = null;
|
|
197
|
+
|
|
198
|
+
// Supported install paths, in resolution order: OPENMCP_BIN (absolute path
|
|
199
|
+
// to the gateway binary; tests point it at the fake fixture) → a persistent
|
|
200
|
+
// install on disk (~/.local/bin covers pip --user, pipx, and uv tool
|
|
201
|
+
// install; the PATH lookup covers venvs) → the uvx fallback, which runs the
|
|
202
|
+
// gateway with no persistent install at all. uvx fetches and caches the
|
|
203
|
+
// package on first run, so a cold first call can exceed the handshake
|
|
204
|
+
// timeout; the next call retries against the warm cache. Modeled on
|
|
205
|
+
// findHcloudBin/resolveHcloudCommand: the agent harness PATH can differ
|
|
206
|
+
// from the installer shell's, so resolution happens at spawn time, not
|
|
207
|
+
// install time. The env parameter follows the resolveEnabledPacks(env)
|
|
208
|
+
// precedent so tests can pin HOME/PATH deterministically. The chain itself
|
|
209
|
+
// lives in src/lib/dep-resolve.ts and the data in DEPENDENCIES
|
|
210
|
+
// ('open-mcp-gateway'.resolution), shared with install-time provisioning
|
|
211
|
+
// and findHcloudBin, so the binary that was installed is the binary that
|
|
212
|
+
// runs; this mapping only adapts the result to the spawn shape.
|
|
213
|
+
export interface GatewayCommand {
|
|
214
|
+
command: string;
|
|
215
|
+
argsPrefix: string[];
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export function resolveGatewayCommand(env: NodeJS.ProcessEnv = process.env): GatewayCommand | null {
|
|
219
|
+
const resolved = resolveDependencyCommand(DEPENDENCIES['open-mcp-gateway'].resolution, env);
|
|
220
|
+
if (!resolved) return null;
|
|
221
|
+
return { command: resolved.command, argsPrefix: [...resolved.argsPrefix] };
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// The devkit's spawn-arg policy for the gateway child, as one pure function
|
|
225
|
+
// so tests pin every branch without spawning anything. Four flags, one rule
|
|
226
|
+
// each (pin-unless-env, the --log-file precedent):
|
|
227
|
+
//
|
|
228
|
+
// --elicitation off always: the sidecar is a non-interactive child by
|
|
229
|
+
// construction, and elicitation is not probe-able at
|
|
230
|
+
// handshake (not declared in capabilities even with
|
|
231
|
+
// --elicitation auto). Consent is the gateway policy
|
|
232
|
+
// engine's business: it refuses under policy and its
|
|
233
|
+
// refusal reason teaches the conversational consent
|
|
234
|
+
// flow (confirm with the user, then manage_policy).
|
|
235
|
+
// --mode openapi only when HUAWEICLOUD_MCP_MODE is unset; when the
|
|
236
|
+
// operator set the gateway's own env, no arg is passed
|
|
237
|
+
// so the env wins (args outrank env in the gateway).
|
|
238
|
+
// discover is rejected here: it proxies arbitrary
|
|
239
|
+
// external MCP servers, a capability face the devkit's
|
|
240
|
+
// floors do not model.
|
|
241
|
+
// --policy <state> only when HUAWEICLOUD_MCP_POLICY_FILE is unset; the
|
|
242
|
+
// devkit-provisioned file lives in the pack state
|
|
243
|
+
// space (lib/pack-state.ts) and the caller creates it
|
|
244
|
+
// BEFORE spawn — the gateway fail-fasts
|
|
245
|
+
// (FileNotFoundError) on a missing policy file, and a
|
|
246
|
+
// devkit-authored provisioning error beats a
|
|
247
|
+
// gateway-authored one.
|
|
248
|
+
// --audit-file never. The gateway's NDJSON audit records full
|
|
249
|
+
// unredacted tool arguments with no rotation, so the
|
|
250
|
+
// devkit never provisions that sink. An operator who
|
|
251
|
+
// sets HUAWEICLOUD_MCP_AUDIT_FILE opts in and owns the
|
|
252
|
+
// file (pack-state adds it to the protected tree).
|
|
253
|
+
export interface GatewaySpawnPlan {
|
|
254
|
+
args: string[];
|
|
255
|
+
/** Provisioning the caller must complete before spawn; null when the operator owns the policy path. */
|
|
256
|
+
provision: { dir: string; policyPath: string } | null;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const SUPPORTED_MODE_TOKENS = new Set(['openapi', 'data']);
|
|
260
|
+
|
|
261
|
+
// Single definition of the provisioned policy file name: the spawn arg,
|
|
262
|
+
// the provisioning call, and the approval module's permanent-grant
|
|
263
|
+
// guidance all derive from it, so they cannot drift apart (the gateway
|
|
264
|
+
// fail-fasts on a missing --policy target, which is exactly the failure
|
|
265
|
+
// pre-spawn provisioning exists to prevent).
|
|
266
|
+
export const POLICY_FILE = 'policy';
|
|
267
|
+
|
|
268
|
+
export function resolveGatewaySpawnArgs(env: NodeJS.ProcessEnv = process.env): GatewaySpawnPlan {
|
|
269
|
+
// Relative operator paths are rejected before anything consumes them:
|
|
270
|
+
// the gateway child resolves them against its scratch cwd, this server
|
|
271
|
+
// against its own, and the protected-tree guard against tmpdir — three
|
|
272
|
+
// anchors, three different files. Refusing the ambiguous form is the
|
|
273
|
+
// same philosophy as the guard refusing '..' segments.
|
|
274
|
+
for (const key of ['HUAWEICLOUD_MCP_POLICY_FILE', 'HUAWEICLOUD_MCP_AUDIT_FILE'] as const) {
|
|
275
|
+
const value = (env[key] ?? '').trim();
|
|
276
|
+
if (value !== '' && !isAbsolute(value)) {
|
|
277
|
+
throw new Error(
|
|
278
|
+
`${key} must be an absolute path (got "${value}"): the gateway child, this server, and the protected-tree guard each resolve relative paths against different working directories.`,
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const args: string[] = ['--elicitation', 'off'];
|
|
284
|
+
|
|
285
|
+
const mode = (env.HUAWEICLOUD_MCP_MODE ?? '').trim();
|
|
286
|
+
if (mode === '') {
|
|
287
|
+
args.push('--mode', 'openapi');
|
|
288
|
+
} else {
|
|
289
|
+
const tokens = mode
|
|
290
|
+
.split(',')
|
|
291
|
+
.map((token) => token.trim())
|
|
292
|
+
.filter((token) => token.length > 0);
|
|
293
|
+
const unsupported = tokens.filter((token) => !SUPPORTED_MODE_TOKENS.has(token));
|
|
294
|
+
if (tokens.length === 0 || unsupported.length > 0) {
|
|
295
|
+
throw new Error(
|
|
296
|
+
`HUAWEICLOUD_MCP_MODE "${mode}" is not supported by the devkit proxy. Supported: openapi, data (comma-combinable). ` +
|
|
297
|
+
'The gateway discover mode proxies arbitrary external MCP servers and is not modeled by the devkit approval boundary yet.',
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
// Operator pinned a mode through the gateway's own env: pass no --mode.
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const policyEnv = (env.HUAWEICLOUD_MCP_POLICY_FILE ?? '').trim();
|
|
304
|
+
let provision: GatewaySpawnPlan['provision'] = null;
|
|
305
|
+
if (policyEnv === '') {
|
|
306
|
+
const dir = packStateDir('huaweicloud-open-mcp', env);
|
|
307
|
+
provision = { dir, policyPath: join(dir, POLICY_FILE) };
|
|
308
|
+
args.push('--policy', provision.policyPath);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// The gateway's logging defaults to a RELATIVE logs/ path that it mkdirs
|
|
312
|
+
// at boot: bare, it would drop a logs/ directory into whatever cwd the
|
|
313
|
+
// child inherited and die outright on a read-only cwd. Pin it to tmpdir
|
|
314
|
+
// unless the operator already configured the gateway's own env var.
|
|
315
|
+
if (!(env.HUAWEICLOUD_MCP_LOG_FILE ?? '').trim()) {
|
|
316
|
+
args.push('--log-file', join(tmpdir(), 'huaweicloud-open-mcp.log'));
|
|
317
|
+
}
|
|
318
|
+
return { args, provision };
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// Scratch-cwd bookkeeping for spawnSidecar: every spawn pins its gateway
|
|
322
|
+
// child to a per-child mkdtemp cwd, and each is removed when that child
|
|
323
|
+
// closes, plus a process-exit sweep. 'close', not 'exit': a failed spawn
|
|
324
|
+
// (a resolvable-but-broken gateway binary, ENOENT/EACCES) emits 'error'
|
|
325
|
+
// then 'close' and never 'exit', and openMcpSidecar resets its promise on
|
|
326
|
+
// failure — an exit-only hook would stack one scratch dir per retried
|
|
327
|
+
// call for the process lifetime. The sweep is
|
|
328
|
+
// required for the production path — the child follows the parent's stdin,
|
|
329
|
+
// but a parent racing through process exit cannot wait for the child's
|
|
330
|
+
// exit event — and the close hook covers mid-process death so a
|
|
331
|
+
// replacement spawn does not stack scratch dirs (one per spawn leaked
|
|
332
|
+
// before; the 2026-10-09 TMPDIR=$HOME runs made ~23 per suite visible).
|
|
333
|
+
// Registered lazily inside spawnSidecar so module scope stays
|
|
334
|
+
// side-effect free. Removal is best-effort: a gateway artifact the host
|
|
335
|
+
// refuses to delete must never fail the server.
|
|
336
|
+
const scratchCwds = new Set<string>();
|
|
337
|
+
let scratchExitSweepInstalled = false;
|
|
338
|
+
|
|
339
|
+
function removeScratchCwd(dir: string): void {
|
|
340
|
+
scratchCwds.delete(dir);
|
|
341
|
+
try {
|
|
342
|
+
rmSync(dir, { recursive: true, force: true });
|
|
343
|
+
} catch {
|
|
344
|
+
// best-effort by design
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
async function spawnSidecar(): Promise<OpenMcpSidecar> {
|
|
349
|
+
const gateway = resolveGatewayCommand();
|
|
350
|
+
if (!gateway) {
|
|
351
|
+
throw new Error(
|
|
352
|
+
'huaweicloud-open-mcp gateway not found. Install it with pip (`pip install huaweicloud-open-mcp`) or keep `uvx` on PATH to run it without a persistent install (`uv tool install huaweicloud-open-mcp` also works). OPENMCP_BIN can point at the gateway binary directly.',
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
const plan = resolveGatewaySpawnArgs();
|
|
356
|
+
if (plan.provision) {
|
|
357
|
+
// Precedes spawn: the gateway fail-fasts on a missing policy file, and
|
|
358
|
+
// the policy store is the authorization base for the delegated face.
|
|
359
|
+
ensurePackState('huaweicloud-open-mcp', [POLICY_FILE]);
|
|
360
|
+
}
|
|
361
|
+
// Per-child scratch cwd, not the shared tmpdir root: two MCP server
|
|
362
|
+
// processes (stdio + remote) each spawn a gateway child, and relative
|
|
363
|
+
// out.path/tables.path values resolve against this cwd — a shared root
|
|
364
|
+
// would make their relative writes collide. The protected-tree guard
|
|
365
|
+
// anchors relative targets at tmpdir(), the PARENT of every scratch cwd:
|
|
366
|
+
// a relative name can only ever be over-denied there (basename collision
|
|
367
|
+
// with a protected root), never under-denied, because any climb out
|
|
368
|
+
// needs '..' — which the guard refuses outright.
|
|
369
|
+
const scratchCwd = mkdtempSync(join(tmpdir(), 'openmcp-gw-'));
|
|
370
|
+
scratchCwds.add(scratchCwd);
|
|
371
|
+
if (!scratchExitSweepInstalled) {
|
|
372
|
+
scratchExitSweepInstalled = true;
|
|
373
|
+
process.on('exit', () => {
|
|
374
|
+
for (const dir of scratchCwds) removeScratchCwd(dir);
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
// A JS entry (OPENMCP_BIN pointed at a .mjs/.js/.cjs file — the test
|
|
378
|
+
// fixture's shape, or any script-style install) must run under the
|
|
379
|
+
// current Node, not be exec'd directly: win32 CreateProcess only runs PE
|
|
380
|
+
// images and Node reports EFTYPE for the script file, while POSIX merely
|
|
381
|
+
// tolerates it via the shebang. Extension detection only — the catalog's
|
|
382
|
+
// real installs are native entry points (pip/pipx/uv shims), never .js.
|
|
383
|
+
const isJsEntry = /\.(?:mjs|cjs|js)$/i.test(gateway.command);
|
|
384
|
+
const child = spawn(
|
|
385
|
+
isJsEntry ? process.execPath : gateway.command,
|
|
386
|
+
isJsEntry ? [gateway.command, ...gateway.argsPrefix, ...plan.args] : [...gateway.argsPrefix, ...plan.args],
|
|
387
|
+
{
|
|
388
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
389
|
+
windowsHide: true,
|
|
390
|
+
cwd: scratchCwd,
|
|
391
|
+
},
|
|
392
|
+
);
|
|
393
|
+
child.on('close', () => removeScratchCwd(scratchCwd));
|
|
394
|
+
stats.spawns += 1;
|
|
395
|
+
stats.lastPid = child.pid ?? null;
|
|
396
|
+
const sidecar = new OpenMcpSidecar(child);
|
|
397
|
+
try {
|
|
398
|
+
await sidecar.handshake();
|
|
399
|
+
} catch (error) {
|
|
400
|
+
// A failed handshake must not leak the child: the parent holds its
|
|
401
|
+
// stdin pipe open, so an un-killed orphan stays alive — and pins the
|
|
402
|
+
// event loop — for the process lifetime, once per retry.
|
|
403
|
+
sidecar.kill();
|
|
404
|
+
throw error;
|
|
405
|
+
}
|
|
406
|
+
return sidecar;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
export function openMcpSidecar(): Promise<OpenMcpSidecar> {
|
|
410
|
+
if (!sidecarPromise) {
|
|
411
|
+
sidecarPromise = spawnSidecar()
|
|
412
|
+
.then((sidecar) => {
|
|
413
|
+
currentSidecar = sidecar;
|
|
414
|
+
return sidecar;
|
|
415
|
+
})
|
|
416
|
+
.catch((error) => {
|
|
417
|
+
sidecarPromise = null; // spawn or handshake failed: the next call retries
|
|
418
|
+
throw error;
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
return sidecarPromise;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
export interface OpenMcpToolResult {
|
|
425
|
+
ok: boolean;
|
|
426
|
+
tool: string;
|
|
427
|
+
[key: string]: unknown;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// The gateway's wire envelope reports refusals as {ok:false, reason} inside
|
|
431
|
+
// a SUCCESSFUL tools/call result, while every other pack surfaces failures
|
|
432
|
+
// as {ok:false, error}. Map reason into error so callers and telemetry see
|
|
433
|
+
// one failure shape; reason is kept for gateway fidelity.
|
|
434
|
+
function withErrorKey(result: OpenMcpToolResult): OpenMcpToolResult {
|
|
435
|
+
if (result.ok === false && result.error === undefined && typeof result.reason === 'string') {
|
|
436
|
+
return { ...result, error: result.reason };
|
|
437
|
+
}
|
|
438
|
+
return result;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// Error text crosses the boundary with both redactors applied: if the
|
|
442
|
+
// text parses as JSON (validation failures echo the offending input as an
|
|
443
|
+
// object), the key-name walk is stronger than any string pattern; the
|
|
444
|
+
// quoted-key string patterns cover the rest.
|
|
445
|
+
function redactErrorText(text: string): string {
|
|
446
|
+
try {
|
|
447
|
+
return JSON.stringify(redactSecrets(JSON.parse(text)));
|
|
448
|
+
} catch {
|
|
449
|
+
return String(redactSecrets(text));
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// One proxied tools/call, normalized to the devkit result shape. The
|
|
454
|
+
// gateway is the authoritative validator of its own tool inputs; the zod
|
|
455
|
+
// schemas in tools.ts are a thin boundary guard, so unexpected extras pass
|
|
456
|
+
// through and errors surface as {ok:false} rather than throws. Success
|
|
457
|
+
// payloads cross this boundary redacted (gateway output can echo secret
|
|
458
|
+
// arguments); error paths redact too — refusal prose survives verbatim,
|
|
459
|
+
// only credential-shaped values are rewritten.
|
|
460
|
+
//
|
|
461
|
+
// forwarded marks a COMPLETED proxied tools/call: only the returns past
|
|
462
|
+
// sidecar.call's await carry it, never the catch. The catch covers every
|
|
463
|
+
// non-round-trip failure (timeout, mid-call child death, spawn/handshake
|
|
464
|
+
// failure) and one answered-but-rejected shape: a JSON-RPC error reply
|
|
465
|
+
// (Unknown tool) rejects in onLine and lands here too — conservative, and
|
|
466
|
+
// unreachable for the eval's vocabulary-pinned tasks. Callers
|
|
467
|
+
// distinguishing "the gateway answered" from "the call never completed"
|
|
468
|
+
// (the eval harness's reached verdict, drift reporting) must read this
|
|
469
|
+
// flag, not infer it from tool presence — the catch also sets tool, so
|
|
470
|
+
// tool alone proves only that callOpenMcpTool was entered.
|
|
471
|
+
export async function callOpenMcpTool(
|
|
472
|
+
name: string,
|
|
473
|
+
args: Record<string, unknown>,
|
|
474
|
+
timeoutMs?: number,
|
|
475
|
+
): Promise<OpenMcpToolResult> {
|
|
476
|
+
try {
|
|
477
|
+
const sidecar = await openMcpSidecar();
|
|
478
|
+
const raw = (await sidecar.call(name, args, timeoutMs)) as {
|
|
479
|
+
content?: Array<{ text?: string }>;
|
|
480
|
+
structuredContent?: Record<string, unknown>;
|
|
481
|
+
isError?: boolean;
|
|
482
|
+
};
|
|
483
|
+
if (raw.isError) {
|
|
484
|
+
const text = (raw.content || [])
|
|
485
|
+
.map((part) => part.text || '')
|
|
486
|
+
.join('\n')
|
|
487
|
+
.trim();
|
|
488
|
+
return { ok: false, forwarded: true, tool: name, error: redactErrorText(text) || 'open-mcp gateway tool error' };
|
|
489
|
+
}
|
|
490
|
+
if (raw.structuredContent && typeof raw.structuredContent === 'object') {
|
|
491
|
+
// Redact the payload object itself, not the ok/tool envelope keys the
|
|
492
|
+
// devkit layers on top of the spread.
|
|
493
|
+
return withErrorKey({
|
|
494
|
+
ok: true,
|
|
495
|
+
forwarded: true,
|
|
496
|
+
tool: name,
|
|
497
|
+
...(redactSecrets(raw.structuredContent) as Record<string, unknown>),
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
const text = (raw.content || [])
|
|
501
|
+
.map((part) => part.text || '')
|
|
502
|
+
.join('\n')
|
|
503
|
+
.trim();
|
|
504
|
+
try {
|
|
505
|
+
return withErrorKey({
|
|
506
|
+
ok: true,
|
|
507
|
+
forwarded: true,
|
|
508
|
+
tool: name,
|
|
509
|
+
...(redactSecrets(JSON.parse(text)) as Record<string, unknown>),
|
|
510
|
+
});
|
|
511
|
+
} catch {
|
|
512
|
+
return { ok: true, forwarded: true, tool: name, raw: redactSecrets(text) };
|
|
513
|
+
}
|
|
514
|
+
} catch (error) {
|
|
515
|
+
const message = redactSecrets(error instanceof Error ? error.message : String(error));
|
|
516
|
+
return { ok: false, tool: name, error: message };
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
export interface GatewayToolListing {
|
|
521
|
+
name: string;
|
|
522
|
+
description?: string;
|
|
523
|
+
inputSchema?: unknown;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
// The child's tools/list, normalized for the gateway_list_tools face:
|
|
527
|
+
// full entries (descriptions, input schemas) plus the drift report
|
|
528
|
+
// against the devkit's static projection (KNOWN_GATEWAY_TOOLS in
|
|
529
|
+
// tools.ts).
|
|
530
|
+
export async function listGatewayTools(): Promise<GatewayToolListing[]> {
|
|
531
|
+
const sidecar = await openMcpSidecar();
|
|
532
|
+
const raw = (await sidecar.request('tools/list', {}, CALL_TIMEOUT_MS)) as {
|
|
533
|
+
tools?: Array<{ name?: unknown; description?: unknown; inputSchema?: unknown }>;
|
|
534
|
+
};
|
|
535
|
+
const tools: GatewayToolListing[] = [];
|
|
536
|
+
for (const entry of Array.isArray(raw?.tools) ? raw.tools : []) {
|
|
537
|
+
if (entry === null || typeof entry !== 'object' || typeof entry.name !== 'string') continue;
|
|
538
|
+
tools.push({
|
|
539
|
+
name: entry.name,
|
|
540
|
+
description: typeof entry.description === 'string' ? entry.description : undefined,
|
|
541
|
+
inputSchema: entry.inputSchema,
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
return tools;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// Test hooks, same convention as _resetHintConsumption in mcp-protocol.ts.
|
|
548
|
+
// lastPid records the most recent spawn attempt's child pid so tests can
|
|
549
|
+
// assert orphan-freedom (no live process left) after failure paths.
|
|
550
|
+
export function _openMcpSidecarStats(): { spawns: number; alive: boolean; lastPid: number | null } {
|
|
551
|
+
return { spawns: stats.spawns, alive: sidecarPromise !== null, lastPid: stats.lastPid };
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
export async function _resetOpenMcpSidecar(): Promise<void> {
|
|
555
|
+
const promise = sidecarPromise;
|
|
556
|
+
currentSidecar = null;
|
|
557
|
+
sidecarPromise = null;
|
|
558
|
+
if (!promise) return;
|
|
559
|
+
try {
|
|
560
|
+
const sidecar = await promise;
|
|
561
|
+
sidecar.kill();
|
|
562
|
+
} catch {
|
|
563
|
+
// spawn or handshake already failed; spawnSidecar's catch killed the child
|
|
564
|
+
}
|
|
565
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// First-class in-session restart: recycle the gateway child, e.g. after the
|
|
569
|
+
// host upgraded the binary (npx huaweicloud-devkit dep install
|
|
570
|
+
// open-mcp-gateway) while the agent was live. The old child is stopped and
|
|
571
|
+
// its real exit awaited (bounded by the kill escalation window) before the
|
|
572
|
+
// replacement spawns, so the upgraded binary is the one that runs.
|
|
573
|
+
//
|
|
574
|
+
// Serialization: the restart continuation itself becomes the sidecar
|
|
575
|
+
// promise, so tool calls racing the restart await the same replacement
|
|
576
|
+
// spawn instead of interleaving their own. currentSidecar is cleared BEFORE
|
|
577
|
+
// the old child stops, so the old child's onExit (which only clears state
|
|
578
|
+
// when currentSidecar === this) cannot wipe the continuation. In-flight
|
|
579
|
+
// proxied calls are rejected by the pending-entry machinery when the old
|
|
580
|
+
// child dies — the restart tool's description sets that expectation.
|
|
581
|
+
// Idempotent: no live singleton means the call is just a spawn.
|
|
582
|
+
export function restartOpenMcpSidecar(): Promise<{ pid: number | null; spawns: number }> {
|
|
583
|
+
const previous = sidecarPromise;
|
|
584
|
+
currentSidecar = null;
|
|
585
|
+
const next = (async () => {
|
|
586
|
+
if (previous) {
|
|
587
|
+
try {
|
|
588
|
+
const old = await previous;
|
|
589
|
+
await old.stop();
|
|
590
|
+
} catch {
|
|
591
|
+
// A failed spawn or handshake already killed its child.
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
const sidecar = await spawnSidecar();
|
|
595
|
+
currentSidecar = sidecar;
|
|
596
|
+
return sidecar;
|
|
597
|
+
})();
|
|
598
|
+
sidecarPromise = next.catch((error) => {
|
|
599
|
+
sidecarPromise = null; // the restart's spawn failed: the next call retries
|
|
600
|
+
throw error;
|
|
601
|
+
});
|
|
602
|
+
return sidecarPromise.then(() => ({ pid: stats.lastPid, spawns: stats.spawns }));
|
|
603
|
+
}
|