huaweicloud-devkit 1.1.14-next.2 → 2.0.0-next.1
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 -17
- package/README.zh-CN.md +16 -17
- 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 +142 -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 +192 -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/approvals-cli.js +159 -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 +320 -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 +110 -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 +353 -0
- package/plugins/huaweicloud-core/dist/lib/approvals-pin.js +128 -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 +62222 -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 +453 -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 +75 -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 +1045 -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 +76 -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 +1350 -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 +147 -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 +101 -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 +2519 -33
- package/plugins/huaweicloud-core/openclaw.plugin.json +2 -2
- package/plugins/huaweicloud-core/safety/policy.json +53 -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 +100 -93
- 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 +7 -5
- 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 +10 -12
- package/plugins/huaweicloud-core/skills/huaweicloud-core/SKILL.md +38 -37
- 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 +16 -6
- package/plugins/huaweicloud-core/skills/huaweicloud-safety/references/approvals.md +47 -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 +163 -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 +197 -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/approvals-cli.ts +187 -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 +383 -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 +154 -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 +496 -0
- package/plugins/huaweicloud-core/src/lib/approvals-pin.ts +153 -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/lib/hdkit/hdkitservice-api.ts +255 -0
- 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} +126 -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 +513 -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 +76 -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 +1114 -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 +111 -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 +1570 -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 +152 -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 +130 -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/auto-upgrade-runner.mjs +0 -58
- 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 -118
- package/plugins/huaweicloud-core/src/mcp-server-remote.mjs +0 -108
- package/plugins/huaweicloud-core/src/mcp-server.mjs +0 -233
- 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/hdkitservice-api.mjs +0 -293
- 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 -3211
- package/plugins/huaweicloud-core/src/update-auto.mjs +0 -669
- package/plugins/huaweicloud-core/src/update-check.mjs +0 -607
- package/plugins/huaweicloud-core/src/update-policy.mjs +0 -82
- 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,247 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { createInterface } from 'node:readline';
|
|
3
|
+
import { readReceipt, receiptDir, withDepLock, } from "./receipts.js";
|
|
4
|
+
import { DEP_INSTALLERS, installerFor } from "./installers/table.js";
|
|
5
|
+
import { resolveDependencyCommand } from "../lib/dep-resolve.js";
|
|
6
|
+
import { DEPENDENCIES, PACK_DEPENDENCIES, requiredDependencies, } from "../lib/dependency-model.js";
|
|
7
|
+
// The dep subsystem's decision core, the half that is dependency-agnostic
|
|
8
|
+
// on purpose: the provisioning policy loop (presence → policy → install,
|
|
9
|
+
// kind-branched because kind is the process model and therefore the policy
|
|
10
|
+
// shape) and the receipt-gated uninstall decision (pack-requirement gate →
|
|
11
|
+
// receipt gate → per-dependency uninstaller, under the receipt lock).
|
|
12
|
+
// Per-dependency behavior lives in installers/hcloud.ts and
|
|
13
|
+
// installers/gateway.ts, composed by the DEP_INSTALLERS table in
|
|
14
|
+
// installers/table.ts; every dispatch resolves per-id through installerFor
|
|
15
|
+
// and every action default comes from the table entry, so a second member
|
|
16
|
+
// of an existing kind provisions through its own installer out of the box.
|
|
17
|
+
// Node builtins plus the zod-free lib/ and dep/receipts modules only — this
|
|
18
|
+
// module compiles into the unbundled dist/setup-cli.js graph, where only
|
|
19
|
+
// undici exists at runtime.
|
|
20
|
+
//
|
|
21
|
+
// The seams, kept injectable for hermetic tests (test/dep-provision.test.ts):
|
|
22
|
+
// the policy loop's probe/install/resolve/confirm seams and the uninstall
|
|
23
|
+
// side's receiptsDir/env/resolveDependency/runCommand seams. The three
|
|
24
|
+
// action seams (probeHcloud, installKooCli, installGateway) are named for
|
|
25
|
+
// the one member of their kind that exists today and capture ONLY that
|
|
26
|
+
// dependency's iteration (identity comparison against the table entry); any
|
|
27
|
+
// other member of the same kind runs its own installer. Collapsing the
|
|
28
|
+
// names into per-id overrides is a cosmetic rename for the day a second
|
|
29
|
+
// member lands. Everything else (policy, output, ordering, refusal
|
|
30
|
+
// wording) is the contract under test.
|
|
31
|
+
const INFO = ' \x1b[36m[INFO]\x1b[0m';
|
|
32
|
+
const WARN = ' \x1b[33m[WARN]\x1b[0m';
|
|
33
|
+
async function defaultConfirm(prompt) {
|
|
34
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
35
|
+
return new Promise((ok) => {
|
|
36
|
+
rl.question(`${prompt} [y/N] `, (answer) => {
|
|
37
|
+
rl.close();
|
|
38
|
+
const normalized = answer.trim().toLowerCase();
|
|
39
|
+
ok(normalized === 'y' || normalized === 'yes');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
// The shared default for the resolve seam: the single resolution chain over
|
|
44
|
+
// the catalog's data. Provisioning and uninstall inject the same thing.
|
|
45
|
+
function defaultResolveDependency(id, env) {
|
|
46
|
+
const entry = DEPENDENCIES[id];
|
|
47
|
+
return entry && 'resolution' in entry ? resolveDependencyCommand(entry.resolution, env) : null;
|
|
48
|
+
}
|
|
49
|
+
export async function provisionDependencies(ids, opts = {}) {
|
|
50
|
+
const tty = opts.tty === true;
|
|
51
|
+
const env = opts.env ?? process.env;
|
|
52
|
+
const log = opts.log ?? console.log;
|
|
53
|
+
const resolve = opts.resolveDependency ?? defaultResolveDependency;
|
|
54
|
+
const confirm = opts.confirm ?? defaultConfirm;
|
|
55
|
+
for (const id of ids) {
|
|
56
|
+
// The loop reasons over the DependencySpec interface, not the catalog's
|
|
57
|
+
// const literals: policy code must handle any legal spec, and the
|
|
58
|
+
// literal types would narrow installPolicy to today's values.
|
|
59
|
+
const spec = DEPENDENCIES[id];
|
|
60
|
+
if (!spec)
|
|
61
|
+
continue;
|
|
62
|
+
try {
|
|
63
|
+
if (spec.kind === 'sandbox-resident') {
|
|
64
|
+
log(`${INFO} ${id}: sandbox-resident (lives inside the cloud sandbox; the host never manages it)`);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const installer = installerFor(id);
|
|
68
|
+
if (installer === null) {
|
|
69
|
+
// InstallerFor makes this unreachable in compiled code; fail loudly
|
|
70
|
+
// rather than silently skipping a required binary.
|
|
71
|
+
log(`${WARN} ${id}: no installer in DEP_INSTALLERS; skipping provisioning`);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (installer.kind === 'cli') {
|
|
75
|
+
// The probeHcloud/installKooCli overrides are named for hcloud, the
|
|
76
|
+
// one cli-kind member today: they capture only hcloud's iteration.
|
|
77
|
+
// Every other cli-kind dependency probes and installs through its
|
|
78
|
+
// own table entry.
|
|
79
|
+
const probe = installer === DEP_INSTALLERS.hcloud ? (opts.probeHcloud ?? installer.probe) : installer.probe;
|
|
80
|
+
const installCli = installer === DEP_INSTALLERS.hcloud ? (opts.installKooCli ?? installer.install) : installer.install;
|
|
81
|
+
// Presence is the question; a version mismatch stays doctor's
|
|
82
|
+
// warning territory. privacy_pending also counts as present: the
|
|
83
|
+
// binary exists, acceptance is a terminal action.
|
|
84
|
+
const presence = probe();
|
|
85
|
+
if (presence.installed) {
|
|
86
|
+
const version = presence.installedVersion ? ` (${presence.installedVersion})` : '';
|
|
87
|
+
log(`${INFO} ${id}: present${version}, skipping install`);
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (spec.installPolicy === 'auto') {
|
|
91
|
+
if (tty) {
|
|
92
|
+
const ok = await installCli({ tty });
|
|
93
|
+
log(ok ? `${INFO} ${id}: installed` : `${WARN} ${id}: install incomplete; see the manual instructions above`);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
// Network-free non-interactive contract: print the pinned
|
|
97
|
+
// manual command, never start a download. The instructions are
|
|
98
|
+
// the dependency's own — through the installer, never hardcoded
|
|
99
|
+
// here.
|
|
100
|
+
log(`${WARN} ${id}: not found; auto-install needs an interactive session`);
|
|
101
|
+
installer.manualInstructions(log);
|
|
102
|
+
}
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
log(`${INFO} ${id}: not found. ${spec.installHint}`);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (installer.kind === 'managed-child') {
|
|
109
|
+
// The installGateway override is named for the gateway, the one
|
|
110
|
+
// managed-child member today: it captures only the gateway's
|
|
111
|
+
// iteration.
|
|
112
|
+
const installManagedChild = installer === DEP_INSTALLERS['open-mcp-gateway']
|
|
113
|
+
? (opts.installGateway ?? installer.install)
|
|
114
|
+
: installer.install;
|
|
115
|
+
const resolved = resolve(id, env);
|
|
116
|
+
// Only a PERSISTENT tier (env/candidate/path) counts as present; a
|
|
117
|
+
// fallback-tier resolution does not, so policy 'prompt' still
|
|
118
|
+
// offers the persistent install and the default install never
|
|
119
|
+
// prompts everyone.
|
|
120
|
+
if (resolved && resolved.tier !== 'fallback') {
|
|
121
|
+
log(`${INFO} ${id}: present (${resolved.tier}: ${resolved.command})`);
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const hint = spec.installHint;
|
|
125
|
+
// The fallback's command name (uvx) is catalog data, not installer
|
|
126
|
+
// text: it derives from the resolution model so a future
|
|
127
|
+
// managed-child dependency renders its own fallback correctly.
|
|
128
|
+
const fallbackCommand = spec.resolution.fallback?.command;
|
|
129
|
+
if (!tty) {
|
|
130
|
+
log(resolved && fallbackCommand
|
|
131
|
+
? `${INFO} ${id}: running via ${fallbackCommand} (no persistent install). ${hint}`
|
|
132
|
+
: `${INFO} ${id}: not found. ${hint}`);
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
const yes = await confirm(`Install the ${spec.title} persistently ${installer.confirmPromptSuffix}?`);
|
|
136
|
+
if (!yes) {
|
|
137
|
+
log(`${INFO} ${id}: skipped. ${hint}`);
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
const result = await installManagedChild();
|
|
141
|
+
log(result.ok
|
|
142
|
+
? `${INFO} ${id}: installed via ${result.tier}`
|
|
143
|
+
: fallbackCommand
|
|
144
|
+
? `${WARN} ${id}: install failed; the ${fallbackCommand} fallback still applies. ${hint}`
|
|
145
|
+
: `${WARN} ${id}: install failed. ${hint}`);
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
// Exhaustiveness: a third installer kind must fail to compile at the
|
|
149
|
+
// never assignment in installers/table.ts's InstallerFor, and this
|
|
150
|
+
// arm keeps the loop honest if one ever slips through.
|
|
151
|
+
const exhaustive = installer;
|
|
152
|
+
log(`${WARN} ${id}: unsupported installer kind ${String(exhaustive)}`);
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
log(`${WARN} ${id}: provisioning failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function defaultRunCommand(command, args) {
|
|
160
|
+
const r = spawnSync(command, [...args], { encoding: 'utf8', timeout: 60_000, windowsHide: true });
|
|
161
|
+
return { status: r.status ?? null, stdout: String(r.stdout || ''), stderr: String(r.stderr || '') };
|
|
162
|
+
}
|
|
163
|
+
// The shared refusal sentence for sandbox-resident ids — one wording
|
|
164
|
+
// consumed by both the spec gate and the table-agreement guard below.
|
|
165
|
+
function sandboxResidentRefusal(id) {
|
|
166
|
+
return { ok: false, message: `${id} ships inside the cloud sandbox; the host never installs or removes it.` };
|
|
167
|
+
}
|
|
168
|
+
function requiringPacks(id, enabledPacks) {
|
|
169
|
+
// The naming half of the refusal: the decision itself went through
|
|
170
|
+
// requiredDependencies over the same edge table; this inverse lookup only
|
|
171
|
+
// produces the pack names the refusal lists. Sorted so the line is
|
|
172
|
+
// deterministic regardless of set order.
|
|
173
|
+
return [...enabledPacks]
|
|
174
|
+
.filter((pack) => PACK_DEPENDENCIES[pack].includes(id))
|
|
175
|
+
.sort((a, b) => a.localeCompare(b));
|
|
176
|
+
}
|
|
177
|
+
function specRefusal(id) {
|
|
178
|
+
const spec = DEPENDENCIES[id];
|
|
179
|
+
if (!spec)
|
|
180
|
+
return { ok: false, message: `Unknown dependency id: ${id}` };
|
|
181
|
+
if (spec.kind === 'sandbox-resident') {
|
|
182
|
+
return sandboxResidentRefusal(id);
|
|
183
|
+
}
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
// The decision core both call shapes share: the receipt gate, the
|
|
187
|
+
// seam-normalized context, and the dispatch to the per-dependency
|
|
188
|
+
// uninstaller. No pack-requirement check lives here.
|
|
189
|
+
function placedUninstall(id, dir, opts) {
|
|
190
|
+
const installer = installerFor(id);
|
|
191
|
+
if (installer === null) {
|
|
192
|
+
// specRefusal already refused sandbox-resident ids before this gate;
|
|
193
|
+
// this arm is the table-agreement guard — same wording, one source.
|
|
194
|
+
return sandboxResidentRefusal(id);
|
|
195
|
+
}
|
|
196
|
+
const receipt = readReceipt(id, dir);
|
|
197
|
+
if (!receipt) {
|
|
198
|
+
return {
|
|
199
|
+
ok: false,
|
|
200
|
+
message: `Refusing to uninstall ${id}: no devkit install receipt, so this devkit did not place it and will not remove it. ${installer.escapeHatch}`,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
// The seam defaults are applied exactly once, at the gate: installers
|
|
204
|
+
// receive a fully-resolved context and never re-derive defaults
|
|
205
|
+
// themselves. Injected overrides keep their precedence.
|
|
206
|
+
const ctx = {
|
|
207
|
+
env: opts.env ?? process.env,
|
|
208
|
+
resolveDependency: opts.resolveDependency ?? defaultResolveDependency,
|
|
209
|
+
runCommand: opts.runCommand ?? defaultRunCommand,
|
|
210
|
+
};
|
|
211
|
+
return installer.uninstall(receipt, dir, ctx);
|
|
212
|
+
}
|
|
213
|
+
export function uninstallDependency(id, targets, opts = {}) {
|
|
214
|
+
const refusal = specRefusal(id);
|
|
215
|
+
if (refusal)
|
|
216
|
+
return refusal;
|
|
217
|
+
const dir = opts.receiptsDir ?? receiptDir();
|
|
218
|
+
// The whole decision — requirement check, receipt read, deletion, receipt
|
|
219
|
+
// removal — serializes against concurrent installs under the receipt lock.
|
|
220
|
+
return withDepLock(() => {
|
|
221
|
+
// The same derivation the installer used, never a second one: the
|
|
222
|
+
// effective union's required-dependency set decides; requiringPacks only
|
|
223
|
+
// names the packs for the refusal line.
|
|
224
|
+
if (requiredDependencies(targets.enabledPacks).has(id)) {
|
|
225
|
+
const requiring = requiringPacks(id, targets.enabledPacks);
|
|
226
|
+
const carrierLabels = targets.carriers
|
|
227
|
+
.filter((target) => [...target.packs].some((pack) => requiring.includes(pack)))
|
|
228
|
+
.map((target) => target.label);
|
|
229
|
+
const carriers = carrierLabels.length > 0 ? ` (installed targets: ${carrierLabels.join(', ')})` : '';
|
|
230
|
+
return {
|
|
231
|
+
ok: false,
|
|
232
|
+
message: `Refusing to uninstall ${id}: required by enabled pack(s) ${requiring.join(', ')}${carriers}. Remove or trim those targets first: npx huaweicloud-devkit uninstall --target <agent>, or reinstall with --packs`,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
return placedUninstall(id, dir, opts);
|
|
236
|
+
}, dir);
|
|
237
|
+
}
|
|
238
|
+
// The forced shape for the uninstall --clean-* flags: the user already
|
|
239
|
+
// answered "remove account-level tools", so no pack-requirement refusal
|
|
240
|
+
// applies. There is no union to consult — the receipt gate alone decides.
|
|
241
|
+
export function uninstallPlacedDependency(id, opts = {}) {
|
|
242
|
+
const refusal = specRefusal(id);
|
|
243
|
+
if (refusal)
|
|
244
|
+
return refusal;
|
|
245
|
+
const dir = opts.receiptsDir ?? receiptDir();
|
|
246
|
+
return withDepLock(() => placedUninstall(id, dir, opts), dir);
|
|
247
|
+
}
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { DEPENDENCIES } from "../lib/dependency-model.js";
|
|
5
|
+
export function receiptDir(base = process.env.HUAWEICLOUD_HOME || homedir()) {
|
|
6
|
+
return join(base, '.config', 'huaweicloud', 'deps');
|
|
7
|
+
}
|
|
8
|
+
function receiptPath(id, dir) {
|
|
9
|
+
return join(dir, `${id}.json`);
|
|
10
|
+
}
|
|
11
|
+
// A record that does not attribute the binary to this devkit (wrong id,
|
|
12
|
+
// foreign provisioner, missing timestamp) reads as absent: uninstall then
|
|
13
|
+
// refuses rather than deleting something it cannot claim.
|
|
14
|
+
export function readReceipt(id, dir = receiptDir()) {
|
|
15
|
+
const file = receiptPath(id, dir);
|
|
16
|
+
if (!existsSync(file))
|
|
17
|
+
return null;
|
|
18
|
+
try {
|
|
19
|
+
const parsed = JSON.parse(readFileSync(file, 'utf8'));
|
|
20
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
21
|
+
return null;
|
|
22
|
+
const record = parsed;
|
|
23
|
+
if (record.binary !== id || record.provisioner !== 'devkit' || typeof record.installedAt !== 'string') {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const receipt = { binary: id, provisioner: 'devkit', installedAt: record.installedAt };
|
|
27
|
+
if (record.tier === 'uv' || record.tier === 'pipx' || record.tier === 'pip3')
|
|
28
|
+
receipt.tier = record.tier;
|
|
29
|
+
if (typeof record.path === 'string' && record.path.length > 0)
|
|
30
|
+
receipt.path = record.path;
|
|
31
|
+
return receipt;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// Atomic write (temp file + rename, the update-check.ts skip-state pattern):
|
|
38
|
+
// a reader never observes a half-written receipt, and a crash mid-write
|
|
39
|
+
// leaves only a stray .tmp, never a corrupt <id>.json.
|
|
40
|
+
export function writeReceipt(receipt, dir = receiptDir()) {
|
|
41
|
+
if (DEPENDENCIES[receipt.binary]?.kind === 'sandbox-resident') {
|
|
42
|
+
throw new Error(`${receipt.binary} is sandbox-resident; the host never manages it, so it cannot carry a receipt`);
|
|
43
|
+
}
|
|
44
|
+
withDepLock(() => {
|
|
45
|
+
mkdirSync(dir, { recursive: true });
|
|
46
|
+
const file = receiptPath(receipt.binary, dir);
|
|
47
|
+
const tmp = `${file}.${process.pid}.${Date.now()}.tmp`;
|
|
48
|
+
writeFileSync(tmp, `${JSON.stringify(receipt, null, 2)}\n`, 'utf8');
|
|
49
|
+
renameSync(tmp, file);
|
|
50
|
+
}, dir);
|
|
51
|
+
}
|
|
52
|
+
export function removeReceipt(id, dir = receiptDir()) {
|
|
53
|
+
withDepLock(() => {
|
|
54
|
+
rmSync(receiptPath(id, dir), { force: true });
|
|
55
|
+
}, dir);
|
|
56
|
+
}
|
|
57
|
+
const RECEIPTS_WARN = ' \x1b[33m[WARN]\x1b[0m';
|
|
58
|
+
// Receipt writes are best-effort bookkeeping after a verifiably successful
|
|
59
|
+
// install: a failed write must not fail the install (the binary is real, the
|
|
60
|
+
// escape hatch still exists), and an already-present binary never reaches
|
|
61
|
+
// this function — the provisioning loop skips before the installer runs, so
|
|
62
|
+
// devkit only ever claims a binary this run placed.
|
|
63
|
+
export function recordInstallReceipt(receipt) {
|
|
64
|
+
try {
|
|
65
|
+
writeReceipt(receipt);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
console.log(`${RECEIPTS_WARN} could not write the install receipt for ${receipt.binary}: ${error instanceof Error ? error.message : String(error)}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// ---------------------------------------------------------------------------
|
|
72
|
+
// The lock. Sync critical sections only: the uninstall decision and the
|
|
73
|
+
// receipt mutations are plain fs operations, so the guard is a plain sync
|
|
74
|
+
// function. Same-process re-entry (an uninstall body calling removeReceipt)
|
|
75
|
+
// recurses instead of deadlocking on its own lock.
|
|
76
|
+
//
|
|
77
|
+
// DESIGN: the lock is a DIRECTORY claimed with mkdir (O_EXCL semantics —
|
|
78
|
+
// EEXIST means someone holds it), carrying a pid file written by the holder
|
|
79
|
+
// AFTER the claim, into the holder's own directory, where no other process
|
|
80
|
+
// can observe a half-written state as stealable. A path FILE plus rename
|
|
81
|
+
// takeover was tried three times and kept failing the two-contender
|
|
82
|
+
// mutual-exclusion test; the directory design narrows the windows but does
|
|
83
|
+
// NOT remove the race class structurally — round-11 live-reproduced a
|
|
84
|
+
// double hold through the takeover path (two contenders both pass the
|
|
85
|
+
// re-read against the same dead lock; the slower one's mutation lands
|
|
86
|
+
// after the faster one's fresh claim and steals it). Every mutation of the
|
|
87
|
+
// lock path is therefore a SELF-VALIDATING rename:
|
|
88
|
+
//
|
|
89
|
+
// - acquiring = mkdir; the only writer of the pid file is the holder, and
|
|
90
|
+
// it writes into its OWN directory (no cross-process half-state);
|
|
91
|
+
// - a lock is taken over ONLY when its pid file names a process that is
|
|
92
|
+
// verifiably dead (a dead owner can never be inside its section or
|
|
93
|
+
// release later) or when the takeover window expired on a wedged holder
|
|
94
|
+
// (documented residual: a >90s "live" holder is assumed wedged; the
|
|
95
|
+
// critical sections cap at ~60s);
|
|
96
|
+
// - the takeover renames the lock to a per-process stash and re-reads
|
|
97
|
+
// the stash's pid: only a stash still naming the SAME judged-dead
|
|
98
|
+
// holder honors the win; anything else means the rename stole a live
|
|
99
|
+
// claim and the stash is restored;
|
|
100
|
+
// - an EMPTY lock directory (holder between mkdir and its pid write —
|
|
101
|
+
// microseconds) is unknown, never stealable: waiters poll past it;
|
|
102
|
+
// - release is the same self-validating rename: the lock moves to a
|
|
103
|
+
// stash whose pid must still name THIS process before removal, so a
|
|
104
|
+
// wedged holder releasing after a takeover restores the taker's claim
|
|
105
|
+
// instead of deleting it.
|
|
106
|
+
//
|
|
107
|
+
// Residual: pid reuse could make a dead holder's pid look alive — that only
|
|
108
|
+
// DELAYS a takeover past the window (bounded, converges). A crash between
|
|
109
|
+
// a winning rename and its verification leaves a reclaimable stash; the
|
|
110
|
+
// acquire-time sweep removes those.
|
|
111
|
+
// ---------------------------------------------------------------------------
|
|
112
|
+
const LOCK_DIR_NAME = 'lock';
|
|
113
|
+
const LOCK_PID_FILE = 'pid';
|
|
114
|
+
const LOCK_POLL_MS = 50;
|
|
115
|
+
// A live holder doing real work is waited out; a holder wedged past this
|
|
116
|
+
// window is taken over anyway — the guard must never block forever. The
|
|
117
|
+
// window must exceed the longest critical section (the tier uninstall's
|
|
118
|
+
// 60s spawnSync) plus resolution margin, or a legitimate holder still
|
|
119
|
+
// inside its section gets its lock taken over mid-flight.
|
|
120
|
+
const LOCK_TAKEOVER_MS = 90_000;
|
|
121
|
+
const lockDepth = new Map();
|
|
122
|
+
const heldDirs = new Set();
|
|
123
|
+
let exitCleanupInstalled = false;
|
|
124
|
+
function lockDirPath(dir) {
|
|
125
|
+
return join(dir, LOCK_DIR_NAME);
|
|
126
|
+
}
|
|
127
|
+
function isPidAlive(pid) {
|
|
128
|
+
// kill(pid, 0) succeeds against an unreaped zombie: the holder exited but
|
|
129
|
+
// its parent never waited, so the pid stays allocated and the kernel still
|
|
130
|
+
// answers the signal probe. A crashed holder's lock must not be treated as
|
|
131
|
+
// live for the whole takeover window, so on Linux /proc/<pid>/stat is the
|
|
132
|
+
// truth (state Z means the process can never run again) and kill(pid, 0) is
|
|
133
|
+
// only the fallback for other platforms and read failures.
|
|
134
|
+
if (process.platform === 'linux') {
|
|
135
|
+
try {
|
|
136
|
+
const stat = readFileSync(`/proc/${pid}/stat`, 'utf8');
|
|
137
|
+
// comm is parenthesized and may itself contain ')' or spaces, so the
|
|
138
|
+
// state is the first field after the LAST closing paren.
|
|
139
|
+
const state = stat.slice(stat.lastIndexOf(')') + 2).split(' ')[0];
|
|
140
|
+
return state !== 'Z';
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
// Unreadable /proc (reaped pid, or an exotic mount): fall through.
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
process.kill(pid, 0);
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
// EPERM: the process exists but belongs to another user. ESRCH: dead.
|
|
152
|
+
return error.code === 'EPERM';
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function sleepSync(ms) {
|
|
156
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
157
|
+
}
|
|
158
|
+
// The holder's pid, read from the pid file inside its lock directory. null
|
|
159
|
+
// means the directory is empty (the holder is between mkdir and its pid
|
|
160
|
+
// write) or unreadable — unknown, which callers treat as "keep waiting",
|
|
161
|
+
// never as stealable.
|
|
162
|
+
function readHolderPid(dir) {
|
|
163
|
+
return readPidAt(join(lockDirPath(dir), LOCK_PID_FILE));
|
|
164
|
+
}
|
|
165
|
+
// The pid inside a takeover stash — same layout as a live lock directory,
|
|
166
|
+
// at an arbitrary path. Round-11: the arbitration validates the stash's
|
|
167
|
+
// contents AFTER winning the rename, so a rename that stole a live claim
|
|
168
|
+
// is detected and restored instead of honored.
|
|
169
|
+
function readStashHolderPid(stashDir) {
|
|
170
|
+
return readPidAt(join(stashDir, LOCK_PID_FILE));
|
|
171
|
+
}
|
|
172
|
+
function readPidAt(pidFile) {
|
|
173
|
+
try {
|
|
174
|
+
const pid = Number.parseInt(readFileSync(pidFile, 'utf8').trim(), 10);
|
|
175
|
+
return Number.isSafeInteger(pid) && pid > 0 ? pid : null;
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// Crash-orphaned takeover/release stashes: a process that died between
|
|
182
|
+
// its winning rename and the stash rm left `${lock}.*.takeover` (or
|
|
183
|
+
// `.release`) behind. The lock machinery never looks at them again, so
|
|
184
|
+
// they would accumulate forever (round-11). Any stale stash is
|
|
185
|
+
// unclaimed by construction — a live winner renames its OWN stash away —
|
|
186
|
+
// so a best-effort sweep at acquire time is safe.
|
|
187
|
+
function sweepStaleStashes(dir) {
|
|
188
|
+
try {
|
|
189
|
+
for (const entry of readdirSync(dir)) {
|
|
190
|
+
if (entry.startsWith(`${LOCK_DIR_NAME}.`) && (entry.endsWith('.takeover') || entry.endsWith('.release'))) {
|
|
191
|
+
rmSync(join(dir, entry), { recursive: true, force: true });
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
catch {
|
|
196
|
+
// unreadable or absent receipt dir: the claim below will recreate it
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function acquireLock(dir, takeoverMs = LOCK_TAKEOVER_MS) {
|
|
200
|
+
mkdirSync(dir, { recursive: true });
|
|
201
|
+
sweepStaleStashes(dir);
|
|
202
|
+
const lock = lockDirPath(dir);
|
|
203
|
+
const deadline = Date.now() + takeoverMs;
|
|
204
|
+
for (;;) {
|
|
205
|
+
// Identity of the directory THIS iteration creates at the lock path —
|
|
206
|
+
// the claim is only complete once the pid file lands in THAT directory.
|
|
207
|
+
// Round-9 (CI, live-reproduced under CPU load): a past-deadline rival
|
|
208
|
+
// takes the empty dir over between the mkdir and the pid write, and the
|
|
209
|
+
// preempted creator then either threw ENOENT out of withDepLock
|
|
210
|
+
// (crashing the caller — the observed [0,1]) or its write landed in the
|
|
211
|
+
// rival's REPLACEMENT dir, overwriting the rival's pid and letting both
|
|
212
|
+
// processes hold at once (the observed overlaps). The identity re-stat
|
|
213
|
+
// after the write closes both: a directory that is no longer the one we
|
|
214
|
+
// created means the claim was lost — re-contend instead of entering the
|
|
215
|
+
// section. ino + birthtimeMs together discriminate a recycled-inode
|
|
216
|
+
// replacement (same ino, later birth time); on filesystems reporting
|
|
217
|
+
// neither (some Windows/network mounts) the check degrades to a no-op
|
|
218
|
+
// and only the ENOENT catch below remains.
|
|
219
|
+
try {
|
|
220
|
+
mkdirSync(lock);
|
|
221
|
+
// Written into our OWN directory after the atomic claim: no other
|
|
222
|
+
// process ever sees this file half-written, and no other process ever
|
|
223
|
+
// writes it. The mkdir alone is the claim; the pid file is the
|
|
224
|
+
// attribution takeovers judge on.
|
|
225
|
+
const claimed = statSync(lock);
|
|
226
|
+
writeFileSync(join(lock, LOCK_PID_FILE), `${process.pid}\n`);
|
|
227
|
+
const rechecked = statSync(lock);
|
|
228
|
+
if (rechecked.ino !== claimed.ino || rechecked.birthtimeMs !== claimed.birthtimeMs) {
|
|
229
|
+
sleepSync(LOCK_POLL_MS);
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
const code = error.code;
|
|
236
|
+
// EEXIST: the path is held, contend for it below. ENOENT: our fresh
|
|
237
|
+
// claim was taken over (renamed away) before the pid write could land
|
|
238
|
+
// — a lost claim, never a crash. Anything else is a real error.
|
|
239
|
+
if (code !== 'EEXIST' && code !== 'ENOENT')
|
|
240
|
+
throw error;
|
|
241
|
+
}
|
|
242
|
+
const holder = readHolderPid(dir);
|
|
243
|
+
// A live holder is waited out for as long as ITS OWN claim is younger
|
|
244
|
+
// than the takeover window — the claim's age, not this waiter's
|
|
245
|
+
// patience, is the wedgedness truth. Measuring the window on the
|
|
246
|
+
// waiter's clock (the old `Date.now() < deadline` here) misjudges a
|
|
247
|
+
// claim that STARTED after the waiter's deadline expired — the round-9
|
|
248
|
+
// overlap, live-reproduced under CPU load: two past-deadline
|
|
249
|
+
// contenders, the second seizing the first's fresh claim mid-section.
|
|
250
|
+
// The pid file is written once, at claim time, so its mtime is the
|
|
251
|
+
// claim's birth certificate; an unreadable one means the holder state
|
|
252
|
+
// just changed — re-read on the next poll, never seize on stale data.
|
|
253
|
+
if (holder !== null && isPidAlive(holder)) {
|
|
254
|
+
let claimIsFresh = true;
|
|
255
|
+
try {
|
|
256
|
+
claimIsFresh = Date.now() - statSync(join(lock, LOCK_PID_FILE)).mtimeMs < takeoverMs;
|
|
257
|
+
}
|
|
258
|
+
catch {
|
|
259
|
+
// pid file vanished between the read and this stat: the holder
|
|
260
|
+
// state changed underneath — treat as fresh so the next poll
|
|
261
|
+
// re-reads instead of judging on stale data.
|
|
262
|
+
}
|
|
263
|
+
if (claimIsFresh) {
|
|
264
|
+
sleepSync(LOCK_POLL_MS);
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
// An empty directory (holder mid-create, microseconds) is unknown and
|
|
269
|
+
// never stealable — wait it out; a crashed creator's empty dir is
|
|
270
|
+
// reclaimed only past the takeover window below.
|
|
271
|
+
if (holder === null && Date.now() < deadline) {
|
|
272
|
+
sleepSync(LOCK_POLL_MS);
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
// Verified removal — the judgment above may be STALE: another taker can
|
|
276
|
+
// have replaced the lock between our read and this point, and removing
|
|
277
|
+
// its fresh claim would let two processes hold at once. Re-read
|
|
278
|
+
// immediately before removing, and only remove when the pid still names
|
|
279
|
+
// the SAME verifiably-dead holder (or the directory is still empty past
|
|
280
|
+
// the window): while the dead holder's directory stands, no new claim
|
|
281
|
+
// can exist — claims need the path absent — so a re-read that still
|
|
282
|
+
// matches is safe to act on. A changed pid means the lock is someone
|
|
283
|
+
// else's now: keep waiting.
|
|
284
|
+
if (readHolderPid(dir) !== holder) {
|
|
285
|
+
sleepSync(LOCK_POLL_MS);
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
// The removal is a SELF-VALIDATING arbitration (round-11: the bare
|
|
289
|
+
// rename did not close the race — a loser whose rename lands after
|
|
290
|
+
// the winner's mkdir steals the winner's FRESH live lock; both hold.
|
|
291
|
+
// Live-reproduced with a stalled contender). renameSync moves the
|
|
292
|
+
// lock to a per-process stash, then the stash's pid is re-read: only
|
|
293
|
+
// a stash that still names the SAME judged-dead holder (or the
|
|
294
|
+
// empty-past-deadline case) honors the win. A stash naming anyone
|
|
295
|
+
// else means the rename stole a live claim — restore it and wait.
|
|
296
|
+
const uniqueStash = `${lock}.${process.pid}.${Date.now()}.takeover`;
|
|
297
|
+
try {
|
|
298
|
+
renameSync(lock, uniqueStash);
|
|
299
|
+
}
|
|
300
|
+
catch {
|
|
301
|
+
sleepSync(LOCK_POLL_MS);
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
const stashHolder = readStashHolderPid(uniqueStash);
|
|
305
|
+
const stashStillOurs = holder === null ? stashHolder === null : stashHolder === holder;
|
|
306
|
+
if (!stashStillOurs) {
|
|
307
|
+
// The rename took a live claim: put it back and wait.
|
|
308
|
+
try {
|
|
309
|
+
renameSync(uniqueStash, lock);
|
|
310
|
+
}
|
|
311
|
+
catch {
|
|
312
|
+
// The lock path is occupied again — the stash is orphaned; the
|
|
313
|
+
// entry sweep below reclaims it.
|
|
314
|
+
}
|
|
315
|
+
sleepSync(LOCK_POLL_MS);
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
rmSync(uniqueStash, { recursive: true, force: true });
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
// Remove the lock only while its pid file still names this process, and
|
|
322
|
+
// do it as a SELF-VALIDATING rename (round-11): the read-then-rmSync
|
|
323
|
+
// shape had the same steal window the acquisition path had — a wedged
|
|
324
|
+
// holder releasing just after a takeover could delete the NEW holder's
|
|
325
|
+
// lock between its pid read and its rm. Renaming to a per-process stash
|
|
326
|
+
// and verifying the stash's pid still names THIS process makes the
|
|
327
|
+
// release fail-safe: a stash naming anyone else means the lock was taken
|
|
328
|
+
// over, and the stash is restored.
|
|
329
|
+
function releaseLock(dir) {
|
|
330
|
+
const lock = lockDirPath(dir);
|
|
331
|
+
const stash = `${lock}.${process.pid}.${Date.now()}.release`;
|
|
332
|
+
try {
|
|
333
|
+
renameSync(lock, stash);
|
|
334
|
+
}
|
|
335
|
+
catch {
|
|
336
|
+
return; // already gone or taken over: nothing to release
|
|
337
|
+
}
|
|
338
|
+
if (readStashHolderPid(stash) === process.pid) {
|
|
339
|
+
rmSync(stash, { recursive: true, force: true });
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
// The lock was taken over between our rename and this read: restore
|
|
343
|
+
// the taker's claim. A failed restore leaves a reclaimable stash.
|
|
344
|
+
try {
|
|
345
|
+
renameSync(stash, lock);
|
|
346
|
+
}
|
|
347
|
+
catch {
|
|
348
|
+
// the sweep in acquireLock reclaims the orphan
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
function installExitCleanup() {
|
|
353
|
+
if (exitCleanupInstalled)
|
|
354
|
+
return;
|
|
355
|
+
exitCleanupInstalled = true;
|
|
356
|
+
// finally blocks do not run through process.exit(); this is the safety net.
|
|
357
|
+
process.on('exit', () => {
|
|
358
|
+
for (const dir of heldDirs)
|
|
359
|
+
releaseLock(dir);
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
export function withDepLock(fn, dir = receiptDir(), takeoverMs = LOCK_TAKEOVER_MS) {
|
|
363
|
+
const depth = lockDepth.get(dir) ?? 0;
|
|
364
|
+
if (depth > 0) {
|
|
365
|
+
lockDepth.set(dir, depth + 1);
|
|
366
|
+
try {
|
|
367
|
+
return fn();
|
|
368
|
+
}
|
|
369
|
+
finally {
|
|
370
|
+
lockDepth.set(dir, depth - 1);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
acquireLock(dir, takeoverMs);
|
|
374
|
+
installExitCleanup();
|
|
375
|
+
heldDirs.add(dir);
|
|
376
|
+
lockDepth.set(dir, 1);
|
|
377
|
+
try {
|
|
378
|
+
return fn();
|
|
379
|
+
}
|
|
380
|
+
finally {
|
|
381
|
+
lockDepth.set(dir, 0);
|
|
382
|
+
releaseLock(dir);
|
|
383
|
+
heldDirs.delete(dir);
|
|
384
|
+
}
|
|
385
|
+
}
|