mixdog 0.7.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/.claude-plugin/marketplace.json +31 -0
- package/.claude-plugin/plugin.json +20 -0
- package/.gitattributes +34 -0
- package/.mcp.json +14 -0
- package/ARCHITECTURE.md +77 -0
- package/CHANGELOG.md +7 -0
- package/CONTRIBUTING.md +45 -0
- package/DATA-FLOW.md +79 -0
- package/LICENSE +21 -0
- package/README.md +389 -0
- package/SECURITY.md +138 -0
- package/UNINSTALL.md +112 -0
- package/agents/maintenance.md +5 -0
- package/agents/memory-classification.md +30 -0
- package/agents/scheduler-task.md +18 -0
- package/agents/webhook-handler.md +27 -0
- package/agents/worker.md +24 -0
- package/bin/bridge +133 -0
- package/bin/statusline-launcher.mjs +78 -0
- package/bin/statusline-lib.mjs +550 -0
- package/bin/statusline.mjs +607 -0
- package/bun.lock +802 -0
- package/commands/config.md +16 -0
- package/commands/doctor.md +13 -0
- package/commands/setup.md +17 -0
- package/defaults/cycle3-review-prompt.md +90 -0
- package/defaults/hidden-roles.json +65 -0
- package/defaults/memory-chunk-prompt.md +63 -0
- package/defaults/memory-promote-prompt.md +135 -0
- package/defaults/mixdog-config.template.json +27 -0
- package/defaults/user-workflow.json +8 -0
- package/defaults/user-workflow.md +12 -0
- package/hooks/hooks.json +73 -0
- package/hooks/lib/active-instance.cjs +77 -0
- package/hooks/lib/permission-evaluator.cjs +411 -0
- package/hooks/lib/permission-route.cjs +63 -0
- package/hooks/lib/permission-rules.cjs +170 -0
- package/hooks/lib/settings-loader.cjs +116 -0
- package/hooks/post-tool-use.cjs +84 -0
- package/hooks/pre-mcp-sandbox.cjs +158 -0
- package/hooks/pre-tool-subagent.cjs +253 -0
- package/hooks/session-start.cjs +1372 -0
- package/hooks/turn-timer.cjs +82 -0
- package/lib/claude-md-writer.cjs +386 -0
- package/lib/config-cjs.cjs +61 -0
- package/lib/hook-pipe-path.cjs +10 -0
- package/lib/keychain-cjs.cjs +263 -0
- package/lib/plugin-paths.cjs +61 -0
- package/lib/rules-builder.cjs +241 -0
- package/lib/text-utils.cjs +61 -0
- package/native/README.md +117 -0
- package/native/prebuilt/linux-aarch64/mixdog-shim +0 -0
- package/native/prebuilt/linux-x86_64/mixdog-shim +0 -0
- package/native/prebuilt/macos-aarch64/mixdog-shim +0 -0
- package/native/prebuilt/macos-x86_64/mixdog-shim +0 -0
- package/native/prebuilt/windows-x86_64/mixdog-shim.exe +0 -0
- package/package.json +107 -0
- package/prompts/code-review.txt +16 -0
- package/prompts/security-audit.txt +17 -0
- package/rules/bridge/00-common.md +39 -0
- package/rules/bridge/20-skip-protocol.md +18 -0
- package/rules/bridge/30-explorer.md +33 -0
- package/rules/bridge/40-cycle1-agent.md +52 -0
- package/rules/bridge/41-cycle2-agent.md +62 -0
- package/rules/bridge/42-cycle3-agent.md +44 -0
- package/rules/lead/00-tool-lead.md +61 -0
- package/rules/lead/01-general.md +23 -0
- package/rules/lead/02-channels.md +49 -0
- package/rules/lead/03-team.md +27 -0
- package/rules/lead/04-workflow.md +20 -0
- package/rules/shared/00-language.md +14 -0
- package/rules/shared/01-tool.md +138 -0
- package/scripts/bootstrap.mjs +184 -0
- package/scripts/bridge-unify-smoke.mjs +308 -0
- package/scripts/build-runtime-linux.sh +348 -0
- package/scripts/build-runtime-macos.sh +217 -0
- package/scripts/build-runtime-windows.ps1 +242 -0
- package/scripts/builtin-utils-smoke.mjs +392 -0
- package/scripts/check-json.mjs +45 -0
- package/scripts/check-syntax-changed.mjs +102 -0
- package/scripts/check-syntax.mjs +58 -0
- package/scripts/code-graph-batch.test.mjs +33 -0
- package/scripts/config-preserve-smoke.mjs +180 -0
- package/scripts/doctor.mjs +484 -0
- package/scripts/edit-normalize-fuzz.mjs +130 -0
- package/scripts/edit-normalize-smoke.mjs +401 -0
- package/scripts/edit-operation-smoke.mjs +369 -0
- package/scripts/edit2-smoke.mjs +63 -0
- package/scripts/fuzzy-e2e.mjs +28 -0
- package/scripts/fuzzy-smoke.mjs +26 -0
- package/scripts/generate-runtime-manifest.mjs +166 -0
- package/scripts/guard-smoke.mjs +66 -0
- package/scripts/hidden-role-schema-smoke.mjs +162 -0
- package/scripts/hook-routing-smoke.mjs +29 -0
- package/scripts/inject-input.ps1 +204 -0
- package/scripts/io-complex-smoke.mjs +667 -0
- package/scripts/io-explore-bench.mjs +424 -0
- package/scripts/io-guardrails-smoke.mjs +205 -0
- package/scripts/io-mini-bench-baseline.json +11 -0
- package/scripts/io-mini-bench.mjs +216 -0
- package/scripts/io-route-harness.mjs +933 -0
- package/scripts/io-telemetry-report.mjs +691 -0
- package/scripts/mutation-bench.mjs +564 -0
- package/scripts/mutation-io-smoke.mjs +1081 -0
- package/scripts/native-patch-bridge-smoke.mjs +288 -0
- package/scripts/native-patch-smoke.mjs +304 -0
- package/scripts/patch-interior-context-smoke.mjs +49 -0
- package/scripts/patch-newline-utf8-smoke.mjs +157 -0
- package/scripts/perf-hook-smoke.mjs +71 -0
- package/scripts/permission-eval-smoke.mjs +426 -0
- package/scripts/prep-patch.mjs +53 -0
- package/scripts/prep-shim.mjs +96 -0
- package/scripts/provider-cache-smoke.mjs +687 -0
- package/scripts/report-runtime-health.mjs +132 -0
- package/scripts/run-mcp.mjs +1547 -0
- package/scripts/salvage-v4a-shatter.test.mjs +58 -0
- package/scripts/scoped-cache-io-smoke.mjs +103 -0
- package/scripts/shell-policy-round3-smoke.mjs +46 -0
- package/scripts/smoke-runtime-negative.ps1 +100 -0
- package/scripts/smoke-runtime-negative.sh +95 -0
- package/scripts/stall-policy-smoke.mjs +50 -0
- package/scripts/start-memory-worker.mjs +23 -0
- package/scripts/statusline-launcher-smoke.mjs +82 -0
- package/scripts/stress-atomic-write.mjs +1028 -0
- package/scripts/test-config-rmw-restore.mjs +122 -0
- package/scripts/test-fault-inject.mjs +164 -0
- package/scripts/test-large-file.mjs +174 -0
- package/scripts/tool-edge-smoke.mjs +209 -0
- package/scripts/uninstall.mjs +201 -0
- package/scripts/webhook-selfheal-smoke.mjs +29 -0
- package/scripts/write-overwrite-guard-smoke.mjs +56 -0
- package/server-main.mjs +3055 -0
- package/server.mjs +468 -0
- package/setup/config-merge.mjs +254 -0
- package/setup/install.mjs +120 -0
- package/setup/launch-core.mjs +507 -0
- package/setup/launch.mjs +101 -0
- package/setup/setup-server.mjs +3206 -0
- package/setup/setup.html +3693 -0
- package/skills/retro-skill-proposer/SKILL.md +92 -0
- package/skills/schedule-add/SKILL.md +77 -0
- package/skills/setup/SKILL.md +346 -0
- package/skills/webhook-add/SKILL.md +81 -0
- package/src/agent/bridge-stall-watchdog.mjs +337 -0
- package/src/agent/index.mjs +2138 -0
- package/src/agent/orchestrator/activity-bus.mjs +38 -0
- package/src/agent/orchestrator/ai-wrapped-dispatch.mjs +1010 -0
- package/src/agent/orchestrator/bridge-retry.mjs +220 -0
- package/src/agent/orchestrator/bridge-trace.mjs +583 -0
- package/src/agent/orchestrator/cache-mtime.mjs +58 -0
- package/src/agent/orchestrator/config.mjs +358 -0
- package/src/agent/orchestrator/context/collect.mjs +651 -0
- package/src/agent/orchestrator/dispatch-persist.mjs +549 -0
- package/src/agent/orchestrator/drain-registry.mjs +50 -0
- package/src/agent/orchestrator/explore-validator.mjs +8 -0
- package/src/agent/orchestrator/internal-roles.mjs +118 -0
- package/src/agent/orchestrator/internal-tools.mjs +88 -0
- package/src/agent/orchestrator/jobs.mjs +116 -0
- package/src/agent/orchestrator/mcp/client.mjs +364 -0
- package/src/agent/orchestrator/providers/anthropic-betas.mjs +21 -0
- package/src/agent/orchestrator/providers/anthropic-oauth.mjs +1745 -0
- package/src/agent/orchestrator/providers/anthropic.mjs +437 -0
- package/src/agent/orchestrator/providers/gemini.mjs +1175 -0
- package/src/agent/orchestrator/providers/grok-oauth.mjs +782 -0
- package/src/agent/orchestrator/providers/model-catalog.mjs +241 -0
- package/src/agent/orchestrator/providers/openai-compat.mjs +1467 -0
- package/src/agent/orchestrator/providers/openai-oauth-ws.mjs +1890 -0
- package/src/agent/orchestrator/providers/openai-oauth.mjs +1307 -0
- package/src/agent/orchestrator/providers/openai-ws.mjs +104 -0
- package/src/agent/orchestrator/providers/registry.mjs +192 -0
- package/src/agent/orchestrator/providers/retry-classifier.mjs +325 -0
- package/src/agent/orchestrator/session/abort-lookup.mjs +13 -0
- package/src/agent/orchestrator/session/cache/post-edit-marks.mjs +42 -0
- package/src/agent/orchestrator/session/cache/prefetch-cache.mjs +142 -0
- package/src/agent/orchestrator/session/cache/read-cache.mjs +319 -0
- package/src/agent/orchestrator/session/cache/scoped-cache-outcome.mjs +11 -0
- package/src/agent/orchestrator/session/cache/scoped-cache.mjs +361 -0
- package/src/agent/orchestrator/session/cache/util.mjs +49 -0
- package/src/agent/orchestrator/session/loop.mjs +1478 -0
- package/src/agent/orchestrator/session/manager.mjs +1975 -0
- package/src/agent/orchestrator/session/read-dedup.mjs +6 -0
- package/src/agent/orchestrator/session/result-classification.mjs +65 -0
- package/src/agent/orchestrator/session/save-session-worker.mjs +18 -0
- package/src/agent/orchestrator/session/store.mjs +624 -0
- package/src/agent/orchestrator/session/stream-watchdog.mjs +130 -0
- package/src/agent/orchestrator/session/tool-result-offload.mjs +166 -0
- package/src/agent/orchestrator/session/trim.mjs +491 -0
- package/src/agent/orchestrator/smart-bridge/CACHE-SHARD.md +115 -0
- package/src/agent/orchestrator/smart-bridge/bridge-llm.mjs +327 -0
- package/src/agent/orchestrator/smart-bridge/cache-obs.mjs +150 -0
- package/src/agent/orchestrator/smart-bridge/cache-strategy.mjs +228 -0
- package/src/agent/orchestrator/smart-bridge/index.mjs +215 -0
- package/src/agent/orchestrator/smart-bridge/profiles.mjs +37 -0
- package/src/agent/orchestrator/smart-bridge/registry.mjs +348 -0
- package/src/agent/orchestrator/smart-bridge/session-builder.mjs +116 -0
- package/src/agent/orchestrator/stall-policy.mjs +195 -0
- package/src/agent/orchestrator/tool-loop-guard.mjs +75 -0
- package/src/agent/orchestrator/tools/bash-policy-scan.mjs +77 -0
- package/src/agent/orchestrator/tools/bash-session.mjs +721 -0
- package/src/agent/orchestrator/tools/builtin/advisory-lock.mjs +171 -0
- package/src/agent/orchestrator/tools/builtin/arg-guard.mjs +455 -0
- package/src/agent/orchestrator/tools/builtin/atomic-write.mjs +236 -0
- package/src/agent/orchestrator/tools/builtin/bash-tool.mjs +480 -0
- package/src/agent/orchestrator/tools/builtin/binary-file.mjs +76 -0
- package/src/agent/orchestrator/tools/builtin/builtin-tools.mjs +256 -0
- package/src/agent/orchestrator/tools/builtin/cache-layers.mjs +386 -0
- package/src/agent/orchestrator/tools/builtin/cwd-utils.mjs +37 -0
- package/src/agent/orchestrator/tools/builtin/device-paths.mjs +154 -0
- package/src/agent/orchestrator/tools/builtin/diagnostics-tool.mjs +292 -0
- package/src/agent/orchestrator/tools/builtin/diff-utils.mjs +109 -0
- package/src/agent/orchestrator/tools/builtin/edit-base-guard.mjs +58 -0
- package/src/agent/orchestrator/tools/builtin/edit-byte-plan.mjs +240 -0
- package/src/agent/orchestrator/tools/builtin/edit-byte-utils.mjs +113 -0
- package/src/agent/orchestrator/tools/builtin/edit-commit.mjs +74 -0
- package/src/agent/orchestrator/tools/builtin/edit-context-utils.mjs +242 -0
- package/src/agent/orchestrator/tools/builtin/edit-diagnostics.mjs +211 -0
- package/src/agent/orchestrator/tools/builtin/edit-engine.mjs +1364 -0
- package/src/agent/orchestrator/tools/builtin/edit-failure-context.mjs +126 -0
- package/src/agent/orchestrator/tools/builtin/edit-hint.mjs +141 -0
- package/src/agent/orchestrator/tools/builtin/edit-match-utils.mjs +194 -0
- package/src/agent/orchestrator/tools/builtin/edit-partial-write.mjs +60 -0
- package/src/agent/orchestrator/tools/builtin/edit-stale-refresh.mjs +168 -0
- package/src/agent/orchestrator/tools/builtin/edit-tool.mjs +173 -0
- package/src/agent/orchestrator/tools/builtin/edit-utf8-guard.mjs +48 -0
- package/src/agent/orchestrator/tools/builtin/fs-reachability.mjs +48 -0
- package/src/agent/orchestrator/tools/builtin/fuzzy-match.mjs +99 -0
- package/src/agent/orchestrator/tools/builtin/glob-walk.mjs +170 -0
- package/src/agent/orchestrator/tools/builtin/grep-formatting.mjs +113 -0
- package/src/agent/orchestrator/tools/builtin/hash-utils.mjs +6 -0
- package/src/agent/orchestrator/tools/builtin/list-formatting.mjs +7 -0
- package/src/agent/orchestrator/tools/builtin/list-tool.mjs +593 -0
- package/src/agent/orchestrator/tools/builtin/native-edit-runner.mjs +89 -0
- package/src/agent/orchestrator/tools/builtin/notebook-edit-tool.mjs +300 -0
- package/src/agent/orchestrator/tools/builtin/open-config-tool.mjs +26 -0
- package/src/agent/orchestrator/tools/builtin/path-diagnostics.mjs +152 -0
- package/src/agent/orchestrator/tools/builtin/path-locks.mjs +35 -0
- package/src/agent/orchestrator/tools/builtin/path-utils.mjs +201 -0
- package/src/agent/orchestrator/tools/builtin/read-args.mjs +103 -0
- package/src/agent/orchestrator/tools/builtin/read-batch.mjs +172 -0
- package/src/agent/orchestrator/tools/builtin/read-constants.mjs +40 -0
- package/src/agent/orchestrator/tools/builtin/read-formatting.mjs +118 -0
- package/src/agent/orchestrator/tools/builtin/read-image-resize.mjs +189 -0
- package/src/agent/orchestrator/tools/builtin/read-image.mjs +88 -0
- package/src/agent/orchestrator/tools/builtin/read-lines.mjs +12 -0
- package/src/agent/orchestrator/tools/builtin/read-mode-tool.mjs +455 -0
- package/src/agent/orchestrator/tools/builtin/read-open.mjs +190 -0
- package/src/agent/orchestrator/tools/builtin/read-range-index.mjs +271 -0
- package/src/agent/orchestrator/tools/builtin/read-ranges.mjs +26 -0
- package/src/agent/orchestrator/tools/builtin/read-single-tool.mjs +728 -0
- package/src/agent/orchestrator/tools/builtin/read-snapshot-runtime.mjs +173 -0
- package/src/agent/orchestrator/tools/builtin/read-special-files.mjs +268 -0
- package/src/agent/orchestrator/tools/builtin/read-streaming.mjs +602 -0
- package/src/agent/orchestrator/tools/builtin/read-tool.mjs +530 -0
- package/src/agent/orchestrator/tools/builtin/read-windows.mjs +107 -0
- package/src/agent/orchestrator/tools/builtin/rename-tool.mjs +196 -0
- package/src/agent/orchestrator/tools/builtin/rg-runner.mjs +422 -0
- package/src/agent/orchestrator/tools/builtin/search-builders.mjs +158 -0
- package/src/agent/orchestrator/tools/builtin/search-tool.mjs +869 -0
- package/src/agent/orchestrator/tools/builtin/shell-analysis.mjs +653 -0
- package/src/agent/orchestrator/tools/builtin/shell-jobs.mjs +936 -0
- package/src/agent/orchestrator/tools/builtin/shell-output.mjs +36 -0
- package/src/agent/orchestrator/tools/builtin/shell-runtime.mjs +214 -0
- package/src/agent/orchestrator/tools/builtin/snapshot-helpers.mjs +143 -0
- package/src/agent/orchestrator/tools/builtin/snapshot-store.mjs +206 -0
- package/src/agent/orchestrator/tools/builtin/snapshot-validation.mjs +98 -0
- package/src/agent/orchestrator/tools/builtin/text-stats.mjs +69 -0
- package/src/agent/orchestrator/tools/builtin/windows-roots.mjs +23 -0
- package/src/agent/orchestrator/tools/builtin/write-tool.mjs +401 -0
- package/src/agent/orchestrator/tools/builtin.mjs +500 -0
- package/src/agent/orchestrator/tools/code-graph-prewarm-worker.mjs +39 -0
- package/src/agent/orchestrator/tools/code-graph-tool-defs.mjs +24 -0
- package/src/agent/orchestrator/tools/code-graph.mjs +4095 -0
- package/src/agent/orchestrator/tools/cwd-tool.mjs +298 -0
- package/src/agent/orchestrator/tools/destructive-warning.mjs +323 -0
- package/src/agent/orchestrator/tools/edit-normalize.mjs +603 -0
- package/src/agent/orchestrator/tools/env-scrub.mjs +100 -0
- package/src/agent/orchestrator/tools/graph-binary-fetcher.mjs +144 -0
- package/src/agent/orchestrator/tools/graph-manifest.json +26 -0
- package/src/agent/orchestrator/tools/host-input.mjs +204 -0
- package/src/agent/orchestrator/tools/mutation-content-cache.mjs +67 -0
- package/src/agent/orchestrator/tools/mutation-planner.mjs +75 -0
- package/src/agent/orchestrator/tools/next-call-utils.mjs +48 -0
- package/src/agent/orchestrator/tools/patch-binary-fetcher.mjs +133 -0
- package/src/agent/orchestrator/tools/patch-manifest.json +26 -0
- package/src/agent/orchestrator/tools/patch-tool-defs.mjs +20 -0
- package/src/agent/orchestrator/tools/patch.mjs +2754 -0
- package/src/agent/orchestrator/tools/progress-message.mjs +118 -0
- package/src/agent/orchestrator/tools/result-compression.mjs +279 -0
- package/src/agent/orchestrator/tools/shell-command.mjs +865 -0
- package/src/agent/orchestrator/tools/shell-exec-policy.mjs +89 -0
- package/src/agent/orchestrator/tools/shell-policy-danger-target.mjs +27 -0
- package/src/agent/orchestrator/tools/shell-policy-imports.mjs +7 -0
- package/src/agent/orchestrator/tools/shell-policy.mjs +345 -0
- package/src/agent/orchestrator/tools/shell-snapshot.mjs +313 -0
- package/src/agent/orchestrator/workflow-store.mjs +93 -0
- package/src/agent/tool-defs.mjs +103 -0
- package/src/channels/backends/discord.mjs +784 -0
- package/src/channels/data/voice-runtime-manifest.json +138 -0
- package/src/channels/index.mjs +3229 -0
- package/src/channels/lib/cli-worker-host.mjs +12 -0
- package/src/channels/lib/config-lock.mjs +13 -0
- package/src/channels/lib/config.mjs +292 -0
- package/src/channels/lib/drop-trace.mjs +71 -0
- package/src/channels/lib/event-pipeline.mjs +81 -0
- package/src/channels/lib/event-queue.mjs +345 -0
- package/src/channels/lib/executor.mjs +168 -0
- package/src/channels/lib/format.mjs +188 -0
- package/src/channels/lib/holidays.mjs +138 -0
- package/src/channels/lib/hook-pipe-server.mjs +802 -0
- package/src/channels/lib/interaction-workflows.mjs +184 -0
- package/src/channels/lib/memory-client.mjs +149 -0
- package/src/channels/lib/output-forwarder.mjs +765 -0
- package/src/channels/lib/runtime-paths.mjs +479 -0
- package/src/channels/lib/scheduler.mjs +723 -0
- package/src/channels/lib/session-control.mjs +36 -0
- package/src/channels/lib/session-discovery.mjs +103 -0
- package/src/channels/lib/settings.mjs +11 -0
- package/src/channels/lib/state-file.mjs +68 -0
- package/src/channels/lib/status-snapshot.mjs +219 -0
- package/src/channels/lib/tool-format.mjs +140 -0
- package/src/channels/lib/transcript-discovery.mjs +195 -0
- package/src/channels/lib/voice-runtime-fetcher.mjs +734 -0
- package/src/channels/lib/webhook.mjs +1179 -0
- package/src/channels/lib/whisper-server.mjs +477 -0
- package/src/channels/tool-defs.mjs +170 -0
- package/src/daemon/host.mjs +118 -0
- package/src/daemon/mcp-transport.mjs +47 -0
- package/src/daemon/session.mjs +100 -0
- package/src/daemon/thin-client.mjs +71 -0
- package/src/daemon/transport.mjs +163 -0
- package/src/memory/data/runtime-manifest.json +40 -0
- package/src/memory/index.mjs +3305 -0
- package/src/memory/lib/agent-ipc.mjs +93 -0
- package/src/memory/lib/bridge-trace-queries.mjs +120 -0
- package/src/memory/lib/core-memory-store.mjs +330 -0
- package/src/memory/lib/embedding-provider.mjs +269 -0
- package/src/memory/lib/embedding-worker.mjs +323 -0
- package/src/memory/lib/llm-worker-host.mjs +17 -0
- package/src/memory/lib/memory-cycle.mjs +11 -0
- package/src/memory/lib/memory-cycle1.mjs +641 -0
- package/src/memory/lib/memory-cycle2.mjs +1284 -0
- package/src/memory/lib/memory-cycle3.mjs +540 -0
- package/src/memory/lib/memory-embed.mjs +299 -0
- package/src/memory/lib/memory-extraction.mjs +5 -0
- package/src/memory/lib/memory-maintenance-store.mjs +32 -0
- package/src/memory/lib/memory-ops-policy.mjs +190 -0
- package/src/memory/lib/memory-recall-id-patch.mjs +15 -0
- package/src/memory/lib/memory-recall-read-query.mjs +7 -0
- package/src/memory/lib/memory-recall-scope-filter.mjs +63 -0
- package/src/memory/lib/memory-recall-store.mjs +621 -0
- package/src/memory/lib/memory-retrievers.mjs +112 -0
- package/src/memory/lib/memory-score.mjs +71 -0
- package/src/memory/lib/memory-text-utils.mjs +58 -0
- package/src/memory/lib/memory.mjs +412 -0
- package/src/memory/lib/model-profile.mjs +85 -0
- package/src/memory/lib/pg/adapter.mjs +308 -0
- package/src/memory/lib/pg/process.mjs +360 -0
- package/src/memory/lib/pg/supervisor.mjs +396 -0
- package/src/memory/lib/project-id-resolver.mjs +86 -0
- package/src/memory/lib/runtime-fetcher.mjs +442 -0
- package/src/memory/lib/trace-store.mjs +728 -0
- package/src/memory/tool-defs.mjs +79 -0
- package/src/search/index.mjs +1173 -0
- package/src/search/lib/backends/anthropic-oauth.mjs +98 -0
- package/src/search/lib/backends/exa.mjs +50 -0
- package/src/search/lib/backends/firecrawl.mjs +61 -0
- package/src/search/lib/backends/gemini-api.mjs +83 -0
- package/src/search/lib/backends/grok-oauth.mjs +86 -0
- package/src/search/lib/backends/index.mjs +150 -0
- package/src/search/lib/backends/openai-api.mjs +144 -0
- package/src/search/lib/backends/openai-oauth.mjs +98 -0
- package/src/search/lib/backends/openai-web-search.mjs +76 -0
- package/src/search/lib/backends/tavily.mjs +55 -0
- package/src/search/lib/backends/xai-api.mjs +113 -0
- package/src/search/lib/cache.mjs +131 -0
- package/src/search/lib/config.mjs +192 -0
- package/src/search/lib/formatter.mjs +115 -0
- package/src/search/lib/provider-usage.mjs +67 -0
- package/src/search/lib/providers.mjs +47 -0
- package/src/search/lib/search-intent.mjs +109 -0
- package/src/search/lib/setup-handler.mjs +261 -0
- package/src/search/lib/state.mjs +201 -0
- package/src/search/lib/web-tools.mjs +1207 -0
- package/src/search/tool-defs.mjs +83 -0
- package/src/setup/defender-exclusion.mjs +183 -0
- package/src/shared/abort-controller.mjs +15 -0
- package/src/shared/atomic-file.mjs +420 -0
- package/src/shared/config.mjs +350 -0
- package/src/shared/daemon-recycle.mjs +108 -0
- package/src/shared/disable-claude-builtins.mjs +88 -0
- package/src/shared/err-text.mjs +12 -0
- package/src/shared/llm/cost.mjs +66 -0
- package/src/shared/llm/http-agent.mjs +123 -0
- package/src/shared/llm/index.mjs +41 -0
- package/src/shared/llm/pid-cleanup.mjs +27 -0
- package/src/shared/llm/usage-log.mjs +47 -0
- package/src/shared/plugin-paths.mjs +58 -0
- package/src/shared/schedules-store.mjs +70 -0
- package/src/shared/seed.mjs +119 -0
- package/src/shared/user-cwd.mjs +213 -0
- package/src/shared/user-data-guard.mjs +238 -0
- package/src/status/aggregator.mjs +584 -0
- package/src/status/server.mjs +413 -0
- package/tools.json +1653 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# build-runtime-macos.sh — Build self-contained PostgreSQL 16 + pgvector runtime on macOS.
|
|
3
|
+
# Uses dylibbundler — the canonical macOS dependency-bundling tool — for @rpath
|
|
4
|
+
# / install_name / transitive dyld closure (auriamg/macdylibbundler). Replaces
|
|
5
|
+
# 200 lines of hand-rolled otool + install_name_tool walking.
|
|
6
|
+
# Produces: dist/mixdog-runtime-darwin-{arch}-pg{pgver}-pgvector{vecver}.tar.gz
|
|
7
|
+
|
|
8
|
+
set -euo pipefail
|
|
9
|
+
|
|
10
|
+
PG_VERSION="16.4"
|
|
11
|
+
PGVECTOR_VERSION="0.8.2"
|
|
12
|
+
TARGET_OS="${TARGET_OS:-darwin}"
|
|
13
|
+
TARGET_ARCH="${TARGET_ARCH:-$(uname -m | sed 's/x86_64/x64/')}"
|
|
14
|
+
|
|
15
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
16
|
+
ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
17
|
+
BUILD_DIR="$ROOT_DIR/build/runtime-darwin-$TARGET_ARCH"
|
|
18
|
+
STAGE_DIR="$BUILD_DIR/stage"
|
|
19
|
+
DIST_DIR="$ROOT_DIR/dist"
|
|
20
|
+
RUNTIME_DIR="$BUILD_DIR/runtime"
|
|
21
|
+
|
|
22
|
+
OUTPUT_NAME="mixdog-runtime-${TARGET_OS}-${TARGET_ARCH}-pg${PG_VERSION}-pgvector${PGVECTOR_VERSION}.tar.gz"
|
|
23
|
+
|
|
24
|
+
mkdir -p "$BUILD_DIR" "$STAGE_DIR" "$DIST_DIR" "$RUNTIME_DIR"/{bin,lib,share}
|
|
25
|
+
|
|
26
|
+
echo "==> Installing build dependencies via Homebrew"
|
|
27
|
+
brew install readline icu4c openssl@3 pkg-config curl git dylibbundler
|
|
28
|
+
|
|
29
|
+
BREW_PREFIX="$(brew --prefix)"
|
|
30
|
+
export CPPFLAGS="-I${BREW_PREFIX}/opt/readline/include -I${BREW_PREFIX}/opt/openssl@3/include -I${BREW_PREFIX}/opt/icu4c/include"
|
|
31
|
+
export LDFLAGS="-L${BREW_PREFIX}/opt/readline/lib -L${BREW_PREFIX}/opt/openssl@3/lib -L${BREW_PREFIX}/opt/icu4c/lib"
|
|
32
|
+
export PKG_CONFIG_PATH="${BREW_PREFIX}/opt/openssl@3/lib/pkgconfig:${BREW_PREFIX}/opt/icu4c/lib/pkgconfig"
|
|
33
|
+
|
|
34
|
+
if [[ -x "$STAGE_DIR/bin/postgres" ]]; then
|
|
35
|
+
echo "==> Cache hit: PG already built at $STAGE_DIR — skipping configure/make"
|
|
36
|
+
unset TARGET_OS TARGET_ARCH
|
|
37
|
+
else
|
|
38
|
+
echo "==> Downloading PostgreSQL $PG_VERSION source"
|
|
39
|
+
cd "$BUILD_DIR"
|
|
40
|
+
if [[ ! -f "postgresql-${PG_VERSION}.tar.gz" ]]; then
|
|
41
|
+
curl -fsSL "https://ftp.postgresql.org/pub/source/v${PG_VERSION}/postgresql-${PG_VERSION}.tar.gz" \
|
|
42
|
+
-o "postgresql-${PG_VERSION}.tar.gz"
|
|
43
|
+
fi
|
|
44
|
+
rm -rf "postgresql-${PG_VERSION}"
|
|
45
|
+
tar xzf "postgresql-${PG_VERSION}.tar.gz"
|
|
46
|
+
|
|
47
|
+
# macOS 15.4+ SDKs declare strchrnul (non-static, availability-floored at
|
|
48
|
+
# 15.4). PG 16.4 predates that: with HAVE_STRCHRNUL its unconditional use
|
|
49
|
+
# trips -Werror=unguarded-availability-new; without it (the ac_cv override
|
|
50
|
+
# below) its static-inline fallback collides with the SDK declaration
|
|
51
|
+
# ("static declaration follows non-static declaration"). Rename the
|
|
52
|
+
# file-local fallback so the build never touches the libc symbol — also
|
|
53
|
+
# keeps the binary loadable on macOS < 15.4. Upstream fixed this after
|
|
54
|
+
# 16.4; drop both hunks on the next PG version bump.
|
|
55
|
+
sed -i '' 's/strchrnul/pg_strchrnul/g' "postgresql-${PG_VERSION}/src/port/snprintf.c"
|
|
56
|
+
|
|
57
|
+
echo "==> Configuring + building PostgreSQL"
|
|
58
|
+
cd "postgresql-${PG_VERSION}"
|
|
59
|
+
# Xcode 16.4 SDK (macOS 15.5) declares strchrnul with an availability
|
|
60
|
+
# floor of macOS 15.4; configure's link test passes but compilation under
|
|
61
|
+
# -Werror=unguarded-availability-new fails when the deployment target is
|
|
62
|
+
# older (PG 16.4 predates the guard upstream added later). Force-disable
|
|
63
|
+
# detection so PG uses its portable fallback — keeps the binary loadable
|
|
64
|
+
# on every macOS the deployment target allows.
|
|
65
|
+
./configure \
|
|
66
|
+
--prefix="$STAGE_DIR" \
|
|
67
|
+
--without-perl --without-python --without-tcl \
|
|
68
|
+
--with-openssl --with-icu --with-readline \
|
|
69
|
+
--enable-thread-safety \
|
|
70
|
+
ac_cv_func_strchrnul=no \
|
|
71
|
+
CFLAGS="-O2"
|
|
72
|
+
unset TARGET_OS TARGET_ARCH
|
|
73
|
+
make -j"$(sysctl -n hw.logicalcpu)"
|
|
74
|
+
make install
|
|
75
|
+
make -C contrib/pgcrypto install
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
PG_CONFIG="$STAGE_DIR/bin/pg_config"
|
|
79
|
+
export PATH="$STAGE_DIR/bin:$PATH"
|
|
80
|
+
|
|
81
|
+
if [[ -f "$STAGE_DIR/lib/postgresql/vector.dylib" ]]; then
|
|
82
|
+
echo "==> Cache hit: pgvector already installed — skipping clone/build"
|
|
83
|
+
else
|
|
84
|
+
echo "==> Cloning + building pgvector $PGVECTOR_VERSION"
|
|
85
|
+
cd "$BUILD_DIR"
|
|
86
|
+
rm -rf pgvector
|
|
87
|
+
git clone --branch "v${PGVECTOR_VERSION}" --depth 1 \
|
|
88
|
+
https://github.com/pgvector/pgvector.git pgvector
|
|
89
|
+
cd pgvector
|
|
90
|
+
make PG_CONFIG="$PG_CONFIG" -j"$(sysctl -n hw.logicalcpu)"
|
|
91
|
+
make PG_CONFIG="$PG_CONFIG" install
|
|
92
|
+
fi
|
|
93
|
+
|
|
94
|
+
echo "==> Stripping macOS binaries"
|
|
95
|
+
find "$STAGE_DIR/bin" -type f -exec strip -S -x {} \; 2>/dev/null || true
|
|
96
|
+
find "$STAGE_DIR/lib" -name '*.dylib' -type f -exec strip -S -x {} \; 2>/dev/null || true
|
|
97
|
+
|
|
98
|
+
echo "==> Assembling runtime layout"
|
|
99
|
+
rm -rf "$RUNTIME_DIR"
|
|
100
|
+
mkdir -p "$RUNTIME_DIR"/{bin,lib,share}
|
|
101
|
+
for BIN in postgres pg_ctl pg_dump pg_restore psql initdb; do
|
|
102
|
+
cp -a "$STAGE_DIR/bin/$BIN" "$RUNTIME_DIR/bin/" 2>/dev/null || echo "WARN: $BIN not found"
|
|
103
|
+
done
|
|
104
|
+
cp -a "$STAGE_DIR/lib"/. "$RUNTIME_DIR/lib/" 2>/dev/null || true
|
|
105
|
+
cp -a "$STAGE_DIR/share"/. "$RUNTIME_DIR/share/" 2>/dev/null || true
|
|
106
|
+
|
|
107
|
+
# ---------------------------------------------------------------------------
|
|
108
|
+
# Bundle foreign Homebrew dylibs via dylibbundler. This is the canonical
|
|
109
|
+
# macOS tool: walks transitive deps including @rpath, copies into a target
|
|
110
|
+
# dir, rewrites install_name + LC_RPATH on every Mach-O. Replaces the
|
|
111
|
+
# hand-rolled otool/install_name_tool loop that missed @rpath references.
|
|
112
|
+
#
|
|
113
|
+
# Flags:
|
|
114
|
+
# -of overwrite existing files in target dir
|
|
115
|
+
# -b bundle (don't only print)
|
|
116
|
+
# -cd create-dest if missing
|
|
117
|
+
# -ns no-codesign (we ad-hoc sign at the end ourselves)
|
|
118
|
+
# -p rpath to use in rewritten install_names (relative to binary)
|
|
119
|
+
# -d target lib dir
|
|
120
|
+
# -x Mach-O input to scan (repeatable)
|
|
121
|
+
# ---------------------------------------------------------------------------
|
|
122
|
+
echo "==> Bundling foreign deps via dylibbundler"
|
|
123
|
+
DYLIBBUNDLER_ARGS=(-of -b -cd -ns -d "$RUNTIME_DIR/lib/" -p '@executable_path/../lib/')
|
|
124
|
+
for BIN in postgres pg_ctl pg_dump pg_restore psql initdb; do
|
|
125
|
+
[[ -f "$RUNTIME_DIR/bin/$BIN" ]] && DYLIBBUNDLER_ARGS+=(-x "$RUNTIME_DIR/bin/$BIN")
|
|
126
|
+
done
|
|
127
|
+
while IFS= read -r -d '' ext; do
|
|
128
|
+
DYLIBBUNDLER_ARGS+=(-x "$ext")
|
|
129
|
+
done < <(find "$RUNTIME_DIR/lib/postgresql" -name '*.dylib' -print0 2>/dev/null)
|
|
130
|
+
dylibbundler "${DYLIBBUNDLER_ARGS[@]}"
|
|
131
|
+
|
|
132
|
+
echo "==> Stripping static archives from lib/"
|
|
133
|
+
find "$RUNTIME_DIR/lib" -name '*.a' -delete
|
|
134
|
+
|
|
135
|
+
echo "==> Ad-hoc re-codesign every Mach-O (dylibbundler invalidates signature)"
|
|
136
|
+
while IFS= read -r -d '' macho; do
|
|
137
|
+
if file "$macho" 2>/dev/null | grep -q 'Mach-O'; then
|
|
138
|
+
codesign --force --sign - "$macho" 2>/dev/null || true
|
|
139
|
+
fi
|
|
140
|
+
done < <(find "$RUNTIME_DIR/bin" "$RUNTIME_DIR/lib" -type f -print0)
|
|
141
|
+
|
|
142
|
+
echo "==> Self-contained smoke test (initdb + CREATE EXTENSION vector + distance query)"
|
|
143
|
+
unset DYLD_FALLBACK_LIBRARY_PATH DYLD_LIBRARY_PATH
|
|
144
|
+
SMOKE_DATA="$BUILD_DIR/smoke-pgdata"
|
|
145
|
+
SMOKE_LOG="$BUILD_DIR/smoke-pg.log"
|
|
146
|
+
SMOKE_PORT=55899
|
|
147
|
+
rm -rf "$SMOKE_DATA"
|
|
148
|
+
|
|
149
|
+
"$RUNTIME_DIR/bin/postgres" --version
|
|
150
|
+
BAD="$(otool -L "$RUNTIME_DIR/bin/postgres" | grep -E '(/opt/homebrew|/usr/local/Cellar|/opt/local|'"$STAGE_DIR"')' || true)"
|
|
151
|
+
if [[ -n "$BAD" ]]; then echo "FAIL: stray paths in postgres:"; echo "$BAD"; exit 1; fi
|
|
152
|
+
VECTOR_DYLIB="$RUNTIME_DIR/lib/postgresql/vector.dylib"
|
|
153
|
+
if [[ -f "$VECTOR_DYLIB" ]]; then
|
|
154
|
+
VBAD="$(otool -L "$VECTOR_DYLIB" | grep -E '(/opt/homebrew|/usr/local/Cellar|/opt/local|'"$STAGE_DIR"')' || true)"
|
|
155
|
+
if [[ -n "$VBAD" ]]; then echo "FAIL: stray paths in vector.dylib:"; echo "$VBAD"; exit 1; fi
|
|
156
|
+
fi
|
|
157
|
+
|
|
158
|
+
"$RUNTIME_DIR/bin/initdb" -D "$SMOKE_DATA" --auth-local=trust --no-locale -E UTF8 -U postgres > /dev/null
|
|
159
|
+
"$RUNTIME_DIR/bin/pg_ctl" -D "$SMOKE_DATA" -o "-p $SMOKE_PORT -h 127.0.0.1" -l "$SMOKE_LOG" -w start
|
|
160
|
+
trap '"$RUNTIME_DIR/bin/pg_ctl" -D "$SMOKE_DATA" -m fast stop > /dev/null 2>&1 || true' EXIT
|
|
161
|
+
|
|
162
|
+
"$RUNTIME_DIR/bin/psql" -h 127.0.0.1 -p "$SMOKE_PORT" -U postgres -d postgres -c "CREATE EXTENSION vector;" > /dev/null
|
|
163
|
+
EXTV="$("$RUNTIME_DIR/bin/psql" -h 127.0.0.1 -p "$SMOKE_PORT" -U postgres -d postgres -tAc "SELECT extversion FROM pg_extension WHERE extname='vector';")"
|
|
164
|
+
DIST="$("$RUNTIME_DIR/bin/psql" -h 127.0.0.1 -p "$SMOKE_PORT" -U postgres -d postgres -tAc "SELECT '[1,2,3]'::vector <-> '[1,2,4]'::vector;")"
|
|
165
|
+
echo " vector extension version: $EXTV"
|
|
166
|
+
echo " distance query result: $DIST"
|
|
167
|
+
[[ "$EXTV" == "$PGVECTOR_VERSION" ]] || { echo "FAIL: extversion=$EXTV expected=$PGVECTOR_VERSION"; exit 1; }
|
|
168
|
+
"$RUNTIME_DIR/bin/pg_ctl" -D "$SMOKE_DATA" -m fast stop > /dev/null
|
|
169
|
+
trap - EXIT
|
|
170
|
+
rm -rf "$SMOKE_DATA"
|
|
171
|
+
echo " PASS smoke (extension load + vector distance)"
|
|
172
|
+
|
|
173
|
+
# Licenses
|
|
174
|
+
curl -fsSL "https://raw.githubusercontent.com/postgres/postgres/REL_16_STABLE/COPYRIGHT" \
|
|
175
|
+
-o "$RUNTIME_DIR/LICENSE.postgresql"
|
|
176
|
+
cp "$BUILD_DIR/pgvector/LICENSE" "$RUNTIME_DIR/LICENSE.pgvector"
|
|
177
|
+
|
|
178
|
+
echo "==> Creating tarball: $OUTPUT_NAME"
|
|
179
|
+
cd "$BUILD_DIR"
|
|
180
|
+
tar czf "$DIST_DIR/$OUTPUT_NAME" -C "$RUNTIME_DIR" .
|
|
181
|
+
|
|
182
|
+
echo "==> Generating sha256 sidecar"
|
|
183
|
+
cd "$DIST_DIR"
|
|
184
|
+
shasum -a 256 "$OUTPUT_NAME" > "${OUTPUT_NAME}.sha256"
|
|
185
|
+
|
|
186
|
+
# ---------------------------------------------------------------------------
|
|
187
|
+
# Phase A: Re-smoke from EXTRACTED tarball with hostile env. Catches false-pass
|
|
188
|
+
# from build-host having Homebrew formulae that bundled tarball might be
|
|
189
|
+
# missing — dylibbundler should have rewritten everything, this is the proof.
|
|
190
|
+
# ---------------------------------------------------------------------------
|
|
191
|
+
echo "==> Re-smoke from extracted tarball (hostile env)"
|
|
192
|
+
EXTRACT_DIR="$BUILD_DIR/extract-smoke"
|
|
193
|
+
rm -rf "$EXTRACT_DIR"; mkdir -p "$EXTRACT_DIR"
|
|
194
|
+
tar xzf "$DIST_DIR/$OUTPUT_NAME" -C "$EXTRACT_DIR"
|
|
195
|
+
EXTRACT_DATA="$EXTRACT_DIR/extract-pgdata"
|
|
196
|
+
EXTRACT_LOG="$EXTRACT_DIR/extract-pg.log"
|
|
197
|
+
EXTRACT_PORT=55898
|
|
198
|
+
|
|
199
|
+
env -i HOME="$EXTRACT_DIR" PATH="/usr/bin:/bin" \
|
|
200
|
+
"$EXTRACT_DIR/bin/postgres" --version
|
|
201
|
+
env -i HOME="$EXTRACT_DIR" PATH="/usr/bin:/bin" \
|
|
202
|
+
"$EXTRACT_DIR/bin/initdb" -D "$EXTRACT_DATA" --auth-local=trust --no-locale -E UTF8 -U postgres > /dev/null
|
|
203
|
+
env -i HOME="$EXTRACT_DIR" PATH="/usr/bin:/bin" \
|
|
204
|
+
"$EXTRACT_DIR/bin/pg_ctl" -D "$EXTRACT_DATA" -o "-p $EXTRACT_PORT -h 127.0.0.1" -l "$EXTRACT_LOG" -w start
|
|
205
|
+
trap 'env -i HOME="'"$EXTRACT_DIR"'" PATH=/usr/bin:/bin "'"$EXTRACT_DIR"'/bin/pg_ctl" -D "'"$EXTRACT_DATA"'" -m fast stop > /dev/null 2>&1 || true' EXIT
|
|
206
|
+
env -i HOME="$EXTRACT_DIR" PATH="/usr/bin:/bin" \
|
|
207
|
+
"$EXTRACT_DIR/bin/psql" -h 127.0.0.1 -p "$EXTRACT_PORT" -U postgres -d postgres -c "CREATE EXTENSION vector;" > /dev/null
|
|
208
|
+
EXTV2="$(env -i HOME="$EXTRACT_DIR" PATH="/usr/bin:/bin" "$EXTRACT_DIR/bin/psql" -h 127.0.0.1 -p "$EXTRACT_PORT" -U postgres -d postgres -tAc "SELECT extversion FROM pg_extension WHERE extname='vector';")"
|
|
209
|
+
[[ "$EXTV2" == "$PGVECTOR_VERSION" ]] || { echo "FAIL: extracted-smoke extversion=$EXTV2"; exit 1; }
|
|
210
|
+
env -i HOME="$EXTRACT_DIR" PATH="/usr/bin:/bin" \
|
|
211
|
+
"$EXTRACT_DIR/bin/pg_ctl" -D "$EXTRACT_DATA" -m fast stop > /dev/null
|
|
212
|
+
trap - EXIT
|
|
213
|
+
rm -rf "$EXTRACT_DIR"
|
|
214
|
+
echo " PASS extracted-tarball smoke"
|
|
215
|
+
|
|
216
|
+
echo "==> Done: $DIST_DIR/$OUTPUT_NAME"
|
|
217
|
+
ls -lh "$DIST_DIR/$OUTPUT_NAME"
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
# build-runtime-windows.ps1 — Build PostgreSQL 16 + pgvector runtime on Windows.
|
|
2
|
+
# Uses windows-2022 GHA runner's preinstalled PostgreSQL 16 (consistent
|
|
3
|
+
# pg_config + postgres.exe from same package) — avoids EDB zip's split-version
|
|
4
|
+
# packaging bug that linked pgvector against PG 14 ABI.
|
|
5
|
+
# Builds pgvector from source via MSVC/nmake, then assembles a self-contained
|
|
6
|
+
# runtime tree (bin + lib + share at root). Final smoke: initdb + CREATE
|
|
7
|
+
# EXTENSION vector + distance query.
|
|
8
|
+
# Produces: dist\mixdog-runtime-win32-x64-pg{pgver}-pgvector{vecver}.tar.gz
|
|
9
|
+
|
|
10
|
+
$ErrorActionPreference = 'Stop'
|
|
11
|
+
|
|
12
|
+
$PG_VERSION = '16.4'
|
|
13
|
+
$PGVECTOR_VERSION = '0.8.2'
|
|
14
|
+
$TARGET_OS = $env:TARGET_OS ?? 'win32'
|
|
15
|
+
$TARGET_ARCH = $env:TARGET_ARCH ?? 'x64'
|
|
16
|
+
|
|
17
|
+
# Auto-detect highest preinstalled PG ≥ 16 OR install via chocolatey.
|
|
18
|
+
$PgInstallRoot = 'C:\Program Files\PostgreSQL'
|
|
19
|
+
|
|
20
|
+
function Find-PgRoot {
|
|
21
|
+
if (-not (Test-Path $PgInstallRoot)) { return $null }
|
|
22
|
+
$cands = Get-ChildItem $PgInstallRoot -Directory -ErrorAction SilentlyContinue |
|
|
23
|
+
Where-Object { $_.Name -match '^(\d+)' } |
|
|
24
|
+
Sort-Object { [int]([regex]::Match($_.Name, '^(\d+)').Groups[1].Value) } -Descending
|
|
25
|
+
foreach ($c in $cands) {
|
|
26
|
+
$major = [int]([regex]::Match($c.Name, '^(\d+)').Groups[1].Value)
|
|
27
|
+
if ($major -ge 16 -and (Test-Path "$($c.FullName)\bin\pg_config.exe")) {
|
|
28
|
+
return $c.FullName
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return $null
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
$PgRoot = Find-PgRoot
|
|
35
|
+
if (-not $PgRoot) {
|
|
36
|
+
Write-Host "==> No preinstalled PG ≥ 16 found. Installing via chocolatey..."
|
|
37
|
+
if (Test-Path $PgInstallRoot) {
|
|
38
|
+
Write-Host "Existing PG dirs (none usable):"
|
|
39
|
+
Get-ChildItem $PgInstallRoot -Directory -ErrorAction SilentlyContinue | Select-Object Name
|
|
40
|
+
}
|
|
41
|
+
choco install postgresql16 --version=16.4.0 --params '/Password:postgres' -y --no-progress 2>&1 | Out-Host
|
|
42
|
+
if ($LASTEXITCODE -ne 0) { Write-Error "choco install postgresql16 failed (exit $LASTEXITCODE)"; exit 1 }
|
|
43
|
+
$PgRoot = Find-PgRoot
|
|
44
|
+
if (-not $PgRoot) {
|
|
45
|
+
Write-Error "ASSERT FAILED: chocolatey install completed but PG ≥ 16 still not found under $PgInstallRoot"
|
|
46
|
+
Get-ChildItem $PgInstallRoot -Directory -ErrorAction SilentlyContinue | Select-Object Name
|
|
47
|
+
exit 1
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
52
|
+
$RootDir = (Resolve-Path "$ScriptDir\..").Path
|
|
53
|
+
$BuildDir = "$RootDir\build\runtime-win32-$TARGET_ARCH"
|
|
54
|
+
$DistDir = "$RootDir\dist"
|
|
55
|
+
$RuntimeDir = "$BuildDir\runtime"
|
|
56
|
+
|
|
57
|
+
$PgBin = "$PgRoot\bin"
|
|
58
|
+
$PgConfig = "$PgBin\pg_config.exe"
|
|
59
|
+
|
|
60
|
+
$OutputName = "mixdog-runtime-${TARGET_OS}-${TARGET_ARCH}-pg${PG_VERSION}-pgvector${PGVECTOR_VERSION}.tar.gz"
|
|
61
|
+
|
|
62
|
+
Write-Host "==> Using preinstalled PG: $PgRoot"
|
|
63
|
+
& $PgConfig --version
|
|
64
|
+
$RealVersion = (& $PgConfig --version) -replace 'PostgreSQL ', ''
|
|
65
|
+
Write-Host " pg_config reports version: $RealVersion"
|
|
66
|
+
|
|
67
|
+
if (Test-Path $RuntimeDir) { Remove-Item -Recurse -Force $RuntimeDir }
|
|
68
|
+
New-Item -ItemType Directory -Force -Path $BuildDir, $DistDir,
|
|
69
|
+
"$RuntimeDir\bin", "$RuntimeDir\lib", "$RuntimeDir\share" | Out-Null
|
|
70
|
+
|
|
71
|
+
Write-Host "==> Cloning pgvector $PGVECTOR_VERSION"
|
|
72
|
+
$PgVectorDir = "$BuildDir\pgvector"
|
|
73
|
+
$VectorDllBuilt = "$PgVectorDir\vector.dll"
|
|
74
|
+
|
|
75
|
+
if (Test-Path $VectorDllBuilt) {
|
|
76
|
+
Write-Host " Cache hit: vector.dll already built at $VectorDllBuilt"
|
|
77
|
+
} else {
|
|
78
|
+
if (Test-Path $PgVectorDir) { Remove-Item -Recurse -Force $PgVectorDir }
|
|
79
|
+
git clone --branch "v$PGVECTOR_VERSION" --depth 1 `
|
|
80
|
+
https://github.com/pgvector/pgvector.git $PgVectorDir
|
|
81
|
+
|
|
82
|
+
Write-Host "==> Building pgvector (MSVC/nmake against system PG 16)"
|
|
83
|
+
Push-Location $PgVectorDir
|
|
84
|
+
try {
|
|
85
|
+
$VsWhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
|
|
86
|
+
$VcVarsAll = & $VsWhere -latest -find 'VC\Auxiliary\Build\vcvarsall.bat' 2>$null | Select-Object -First 1
|
|
87
|
+
if (-not $VcVarsAll) {
|
|
88
|
+
Write-Error "vswhere could not locate vcvarsall.bat — Visual Studio Build Tools required."
|
|
89
|
+
exit 1
|
|
90
|
+
}
|
|
91
|
+
# CRITICAL: prepend $PgRoot\bin to PATH so any bare `pg_config` call
|
|
92
|
+
# inside Makefile.win resolves to PG 16 — runner has PG 14/15
|
|
93
|
+
# preinstalled and would otherwise win the PATH lookup, producing
|
|
94
|
+
# PG14-ABI vector.dll that fails to load in our PG 16 postgres.exe.
|
|
95
|
+
# Set in PowerShell so cmd /c inherits; setting inside the cmd batch
|
|
96
|
+
# via %PATH% loses vcvarsall's additions due to parse-time expansion.
|
|
97
|
+
$env:PATH = "$PgRoot\bin;$env:PATH"
|
|
98
|
+
$env:PGROOT = $PgRoot
|
|
99
|
+
$BuildCmd = "`"$VcVarsAll`" amd64 && nmake /F Makefile.win PG_CONFIG=`"$PgConfig`""
|
|
100
|
+
cmd /c $BuildCmd
|
|
101
|
+
if ($LASTEXITCODE -ne 0) {
|
|
102
|
+
Write-Error "pgvector nmake build failed (exit $LASTEXITCODE)"
|
|
103
|
+
exit 1
|
|
104
|
+
}
|
|
105
|
+
} finally {
|
|
106
|
+
Pop-Location
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
Write-Host "==> Assembling runtime layout — copy bin (.exe + .dll), lib, share from $PgRoot"
|
|
111
|
+
# Copy ALL .exe + .dll from PG bin so postgres.exe + libpq.dll + libcrypto/libssl/
|
|
112
|
+
# libintl/libiconv/icu*/libxml2/libxslt/libwinpthread/libecpg/libpgtypes etc. all
|
|
113
|
+
# ship together. PG 16 install layout puts these all in bin\.
|
|
114
|
+
Copy-Item "$PgBin\*.exe","$PgBin\*.dll" "$RuntimeDir\bin\" -Force
|
|
115
|
+
|
|
116
|
+
# lib\: PG extension modules (incl. contrib like pgcrypto.dll). vector.dll
|
|
117
|
+
# placed here below — PG looks for $libdir/<ext>.dll which resolves to lib\.
|
|
118
|
+
Copy-Item -Recurse -Force "$PgRoot\lib\*" "$RuntimeDir\lib\" -ErrorAction SilentlyContinue
|
|
119
|
+
# share\: extension SQL/control, locale, timezone data, conf samples.
|
|
120
|
+
Copy-Item -Recurse -Force "$PgRoot\share\*" "$RuntimeDir\share\" -ErrorAction SilentlyContinue
|
|
121
|
+
|
|
122
|
+
Write-Host "==> Manually staging pgvector artifacts (avoid pg_config-derived install paths)"
|
|
123
|
+
$RuntimeExtDir = "$RuntimeDir\share\extension"
|
|
124
|
+
New-Item -ItemType Directory -Force -Path $RuntimeExtDir | Out-Null
|
|
125
|
+
Copy-Item "$PgVectorDir\vector.dll" "$RuntimeDir\lib\" -Force
|
|
126
|
+
Copy-Item "$PgVectorDir\vector.control" $RuntimeExtDir -Force
|
|
127
|
+
Copy-Item "$PgVectorDir\sql\vector--*.sql" $RuntimeExtDir -Force
|
|
128
|
+
|
|
129
|
+
Write-Host "==> Asserting runtime layout"
|
|
130
|
+
$VectorControl = "$RuntimeDir\share\extension\vector.control"
|
|
131
|
+
if (-not (Test-Path $VectorControl)) { Write-Error "ASSERT FAILED: $VectorControl not found"; exit 1 }
|
|
132
|
+
$VectorSql = "$RuntimeDir\share\extension\vector--$PGVECTOR_VERSION.sql"
|
|
133
|
+
if (-not (Test-Path $VectorSql)) { Write-Error "ASSERT FAILED: $VectorSql not found"; exit 1 }
|
|
134
|
+
if (-not (Test-Path "$RuntimeDir\lib\vector.dll")) {
|
|
135
|
+
Write-Error "ASSERT FAILED: vector.dll not found in lib\"
|
|
136
|
+
exit 1
|
|
137
|
+
}
|
|
138
|
+
Write-Host " PASS runtime layout"
|
|
139
|
+
|
|
140
|
+
# Licenses
|
|
141
|
+
if (Test-Path "$PgRoot\doc\postgresql\COPYRIGHT") {
|
|
142
|
+
Copy-Item "$PgRoot\doc\postgresql\COPYRIGHT" "$RuntimeDir\LICENSE.postgresql" -Force
|
|
143
|
+
} elseif (Test-Path "$PgRoot\doc\COPYRIGHT") {
|
|
144
|
+
Copy-Item "$PgRoot\doc\COPYRIGHT" "$RuntimeDir\LICENSE.postgresql" -Force
|
|
145
|
+
}
|
|
146
|
+
if (Test-Path "$PgVectorDir\LICENSE") {
|
|
147
|
+
Copy-Item "$PgVectorDir\LICENSE" "$RuntimeDir\LICENSE.pgvector" -Force
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
Write-Host "==> Self-contained smoke test (initdb + CREATE EXTENSION vector + distance query)"
|
|
151
|
+
& "$RuntimeDir\bin\postgres.exe" --version
|
|
152
|
+
if ($LASTEXITCODE -ne 0) { Write-Error "FAIL: postgres.exe --version exit $LASTEXITCODE"; exit 1 }
|
|
153
|
+
|
|
154
|
+
$SmokeData = "$BuildDir\smoke-pgdata"
|
|
155
|
+
$SmokeLog = "$BuildDir\smoke-pg.log"
|
|
156
|
+
$SmokePort = 55899
|
|
157
|
+
if (Test-Path $SmokeData) { Remove-Item -Recurse -Force $SmokeData }
|
|
158
|
+
|
|
159
|
+
& "$RuntimeDir\bin\initdb.exe" -D $SmokeData --username=postgres --auth-local=trust --no-locale -E UTF8 | Out-Null
|
|
160
|
+
if ($LASTEXITCODE -ne 0) { Write-Error "FAIL: initdb"; exit 1 }
|
|
161
|
+
|
|
162
|
+
& "$RuntimeDir\bin\pg_ctl.exe" -D $SmokeData -o "-p $SmokePort -h 127.0.0.1" -l $SmokeLog -w start
|
|
163
|
+
if ($LASTEXITCODE -ne 0) { Write-Error "FAIL: pg_ctl start (see $SmokeLog)"; Get-Content $SmokeLog | Select-Object -Last 30; exit 1 }
|
|
164
|
+
|
|
165
|
+
try {
|
|
166
|
+
& "$RuntimeDir\bin\psql.exe" -h 127.0.0.1 -p $SmokePort -U postgres -d postgres -c "CREATE EXTENSION vector;" | Out-Null
|
|
167
|
+
if ($LASTEXITCODE -ne 0) { throw "CREATE EXTENSION vector failed" }
|
|
168
|
+
$ExtV = & "$RuntimeDir\bin\psql.exe" -h 127.0.0.1 -p $SmokePort -U postgres -d postgres -tAc "SELECT extversion FROM pg_extension WHERE extname='vector';"
|
|
169
|
+
$Dist = & "$RuntimeDir\bin\psql.exe" -h 127.0.0.1 -p $SmokePort -U postgres -d postgres -tAc "SELECT '[1,2,3]'::vector <-> '[1,2,4]'::vector;"
|
|
170
|
+
Write-Host " vector extension version: $ExtV"
|
|
171
|
+
Write-Host " distance query result: $Dist"
|
|
172
|
+
if ($ExtV.Trim() -ne $PGVECTOR_VERSION) {
|
|
173
|
+
Write-Error "FAIL: extversion='$ExtV' expected='$PGVECTOR_VERSION'"
|
|
174
|
+
exit 1
|
|
175
|
+
}
|
|
176
|
+
Write-Host " PASS smoke (extension load + vector distance)"
|
|
177
|
+
}
|
|
178
|
+
finally {
|
|
179
|
+
& "$RuntimeDir\bin\pg_ctl.exe" -D $SmokeData -m fast stop 2>$null | Out-Null
|
|
180
|
+
Remove-Item -Recurse -Force $SmokeData -ErrorAction SilentlyContinue
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
Write-Host "==> Creating tarball: $OutputName"
|
|
184
|
+
$DistDirFwd = $DistDir.Replace('\', '/')
|
|
185
|
+
$RuntimeDirFwd = $RuntimeDir.Replace('\', '/')
|
|
186
|
+
& tar -czf "$DistDirFwd/$OutputName" -C "$RuntimeDirFwd" .
|
|
187
|
+
if ($LASTEXITCODE -ne 0) { Write-Error "tar failed (exit $LASTEXITCODE)"; exit 1 }
|
|
188
|
+
|
|
189
|
+
Write-Host "==> Generating sha256 sidecar"
|
|
190
|
+
Push-Location $DistDir
|
|
191
|
+
$Hash = (Get-FileHash -Algorithm SHA256 $OutputName).Hash.ToLower()
|
|
192
|
+
"$Hash $OutputName" | Out-File -Encoding ascii "${OutputName}.sha256"
|
|
193
|
+
Pop-Location
|
|
194
|
+
|
|
195
|
+
# ---------------------------------------------------------------------------
|
|
196
|
+
# Phase A: Re-smoke from EXTRACTED tarball with hostile env (cleared PATH,
|
|
197
|
+
# only system32). Catches false-pass where the build host has VC redist /
|
|
198
|
+
# preinstalled DLLs that the tarball might be missing.
|
|
199
|
+
# ---------------------------------------------------------------------------
|
|
200
|
+
Write-Host "==> Re-smoke from extracted tarball (hostile env)"
|
|
201
|
+
$ExtractDir = "$BuildDir\extract-smoke"
|
|
202
|
+
if (Test-Path $ExtractDir) { Remove-Item -Recurse -Force $ExtractDir }
|
|
203
|
+
New-Item -ItemType Directory -Force -Path $ExtractDir | Out-Null
|
|
204
|
+
& tar -xzf "$DistDirFwd/$OutputName" -C ($ExtractDir.Replace('\','/'))
|
|
205
|
+
if ($LASTEXITCODE -ne 0) { Write-Error "extract failed"; exit 1 }
|
|
206
|
+
|
|
207
|
+
$ExtractData = "$ExtractDir\extract-pgdata"
|
|
208
|
+
$ExtractLog = "$ExtractDir\extract-pg.log"
|
|
209
|
+
$ExtractPort = 55898
|
|
210
|
+
|
|
211
|
+
# Snapshot current env, then strip to minimal Windows PATH (no PG14/15/16
|
|
212
|
+
# preinstalled bin, no chocolatey, no MSVC tools).
|
|
213
|
+
$SavedPath = $env:PATH
|
|
214
|
+
$SavedPgRoot = $env:PGROOT
|
|
215
|
+
$env:PATH = "$env:SystemRoot\System32;$env:SystemRoot"
|
|
216
|
+
$env:PGROOT = $null
|
|
217
|
+
$env:PGDATA = $null
|
|
218
|
+
|
|
219
|
+
try {
|
|
220
|
+
& "$ExtractDir\bin\postgres.exe" --version
|
|
221
|
+
if ($LASTEXITCODE -ne 0) { throw "FAIL: postgres --version under hostile env" }
|
|
222
|
+
& "$ExtractDir\bin\initdb.exe" -D $ExtractData --username=postgres --auth-local=trust --no-locale -E UTF8 | Out-Null
|
|
223
|
+
if ($LASTEXITCODE -ne 0) { throw "FAIL: initdb under hostile env" }
|
|
224
|
+
& "$ExtractDir\bin\pg_ctl.exe" -D $ExtractData -o "-p $ExtractPort -h 127.0.0.1" -l $ExtractLog -w start
|
|
225
|
+
if ($LASTEXITCODE -ne 0) { Get-Content $ExtractLog | Select-Object -Last 30; throw "FAIL: pg_ctl start under hostile env" }
|
|
226
|
+
try {
|
|
227
|
+
& "$ExtractDir\bin\psql.exe" -h 127.0.0.1 -p $ExtractPort -U postgres -d postgres -c "CREATE EXTENSION vector;" | Out-Null
|
|
228
|
+
if ($LASTEXITCODE -ne 0) { throw "FAIL: CREATE EXTENSION vector under hostile env" }
|
|
229
|
+
$ExtV2 = & "$ExtractDir\bin\psql.exe" -h 127.0.0.1 -p $ExtractPort -U postgres -d postgres -tAc "SELECT extversion FROM pg_extension WHERE extname='vector';"
|
|
230
|
+
if ($ExtV2.Trim() -ne $PGVECTOR_VERSION) { throw "FAIL: extracted-smoke extversion='$ExtV2'" }
|
|
231
|
+
Write-Host " PASS extracted-tarball smoke (hostile env)"
|
|
232
|
+
} finally {
|
|
233
|
+
& "$ExtractDir\bin\pg_ctl.exe" -D $ExtractData -m fast stop 2>$null | Out-Null
|
|
234
|
+
}
|
|
235
|
+
} finally {
|
|
236
|
+
$env:PATH = $SavedPath
|
|
237
|
+
$env:PGROOT = $SavedPgRoot
|
|
238
|
+
Remove-Item -Recurse -Force $ExtractDir -ErrorAction SilentlyContinue
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
Write-Host "==> Done: $DistDir\$OutputName"
|
|
242
|
+
Get-Item "$DistDir\$OutputName" | Select-Object Name, Length
|