@monoes/monomindcli 2.8.4 → 2.9.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/helpers/auto-memory-hook.mjs +0 -0
- package/.claude/helpers/handlers/route-handler.cjs +12 -0
- package/.claude/helpers/handlers/session-restore-handler.cjs +28 -7
- package/.claude/helpers/hook-handler.cjs +0 -0
- package/.claude/helpers/utils/micro-agents.cjs +22 -0
- package/.claude/skills/monodesign/scripts/live/sveltekit-adapter.mjs +11 -6
- package/.claude/skills/monodesign/scripts/live-inject.mjs +20 -7
- package/.claude/skills/monodesign/scripts/live-server.mjs +38 -2
- package/LICENSE +191 -0
- package/README.md +8 -6
- package/dist/src/browser/dashboard/server.d.ts +5 -0
- package/dist/src/browser/dashboard/server.d.ts.map +1 -1
- package/dist/src/browser/dashboard/server.js +59 -4
- package/dist/src/browser/dashboard/server.js.map +1 -1
- package/dist/src/browser/dashboard/ui.html +18 -8
- package/dist/src/browser/workflow/store.d.ts.map +1 -1
- package/dist/src/browser/workflow/store.js +3 -2
- package/dist/src/browser/workflow/store.js.map +1 -1
- package/dist/src/capabilities/cap-documents.d.ts.map +1 -1
- package/dist/src/capabilities/cap-documents.js +14 -9
- package/dist/src/capabilities/cap-documents.js.map +1 -1
- package/dist/src/commands/doctor.d.ts.map +1 -1
- package/dist/src/commands/doctor.js +22 -18
- package/dist/src/commands/doctor.js.map +1 -1
- package/dist/src/commands/download-embeddings.d.ts +8 -0
- package/dist/src/commands/download-embeddings.d.ts.map +1 -0
- package/dist/src/commands/download-embeddings.js +34 -0
- package/dist/src/commands/download-embeddings.js.map +1 -0
- package/dist/src/commands/hooks.d.ts.map +1 -1
- package/dist/src/commands/hooks.js +14 -0
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +4 -0
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/init-wizard.js +1 -1
- package/dist/src/commands/init-wizard.js.map +1 -1
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/init.js +48 -1
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/monograph.d.ts.map +1 -1
- package/dist/src/commands/monograph.js +35 -1
- package/dist/src/commands/monograph.js.map +1 -1
- package/dist/src/commands/org-observe.d.ts +10 -0
- package/dist/src/commands/org-observe.d.ts.map +1 -1
- package/dist/src/commands/org-observe.js +195 -31
- package/dist/src/commands/org-observe.js.map +1 -1
- package/dist/src/commands/org.d.ts +1 -0
- package/dist/src/commands/org.d.ts.map +1 -1
- package/dist/src/commands/org.js +139 -3
- package/dist/src/commands/org.js.map +1 -1
- package/dist/src/commands/route.d.ts +1 -9
- package/dist/src/commands/route.d.ts.map +1 -1
- package/dist/src/commands/route.js +42 -65
- package/dist/src/commands/route.js.map +1 -1
- package/dist/src/commands/security-cve.d.ts.map +1 -1
- package/dist/src/commands/security-cve.js +2 -1
- package/dist/src/commands/security-cve.js.map +1 -1
- package/dist/src/index.d.ts +0 -10
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -15
- package/dist/src/index.js.map +1 -1
- package/dist/src/init/copy-assets.d.ts +17 -0
- package/dist/src/init/copy-assets.d.ts.map +1 -0
- package/dist/src/init/copy-assets.js +271 -0
- package/dist/src/init/copy-assets.js.map +1 -0
- package/dist/src/init/executor.d.ts +2 -30
- package/dist/src/init/executor.d.ts.map +1 -1
- package/dist/src/init/executor.js +56 -2493
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/helpers-generator.d.ts.map +1 -1
- package/dist/src/init/helpers-generator.js +9 -0
- package/dist/src/init/helpers-generator.js.map +1 -1
- package/dist/src/init/settings-generator.d.ts.map +1 -1
- package/dist/src/init/settings-generator.js +0 -4
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/init/shared.d.ts +112 -0
- package/dist/src/init/shared.d.ts.map +1 -0
- package/dist/src/init/shared.js +475 -0
- package/dist/src/init/shared.js.map +1 -0
- package/dist/src/init/statusline-generator.d.ts.map +1 -1
- package/dist/src/init/statusline-generator.js +37 -0
- package/dist/src/init/statusline-generator.js.map +1 -1
- package/dist/src/init/types.d.ts +1 -1
- package/dist/src/init/types.d.ts.map +1 -1
- package/dist/src/init/upgrade.d.ts +34 -0
- package/dist/src/init/upgrade.d.ts.map +1 -0
- package/dist/src/init/upgrade.js +477 -0
- package/dist/src/init/upgrade.js.map +1 -0
- package/dist/src/init/write-antigravity.d.ts +13 -0
- package/dist/src/init/write-antigravity.d.ts.map +1 -0
- package/dist/src/init/write-antigravity.js +117 -0
- package/dist/src/init/write-antigravity.js.map +1 -0
- package/dist/src/init/write-capabilities.d.ts +9 -0
- package/dist/src/init/write-capabilities.d.ts.map +1 -0
- package/dist/src/init/write-capabilities.js +392 -0
- package/dist/src/init/write-capabilities.js.map +1 -0
- package/dist/src/init/write-claude.d.ts +25 -0
- package/dist/src/init/write-claude.d.ts.map +1 -0
- package/dist/src/init/write-claude.js +279 -0
- package/dist/src/init/write-claude.js.map +1 -0
- package/dist/src/init/write-kimicode.d.ts +19 -0
- package/dist/src/init/write-kimicode.d.ts.map +1 -0
- package/dist/src/init/write-kimicode.js +223 -0
- package/dist/src/init/write-kimicode.js.map +1 -0
- package/dist/src/init/write-opencode.d.ts +14 -0
- package/dist/src/init/write-opencode.d.ts.map +1 -0
- package/dist/src/init/write-opencode.js +130 -0
- package/dist/src/init/write-opencode.js.map +1 -0
- package/dist/src/init/write-runtime-config.d.ts +14 -0
- package/dist/src/init/write-runtime-config.d.ts.map +1 -0
- package/dist/src/init/write-runtime-config.js +214 -0
- package/dist/src/init/write-runtime-config.js.map +1 -0
- package/dist/src/init/write-sample-org.d.ts +9 -0
- package/dist/src/init/write-sample-org.d.ts.map +1 -0
- package/dist/src/init/write-sample-org.js +39 -0
- package/dist/src/init/write-sample-org.js.map +1 -0
- package/dist/src/knowledge/eval/golden-set.js +1 -1
- package/dist/src/knowledge/eval/golden-set.js.map +1 -1
- package/dist/src/mcp-tools/analyze-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/analyze-tools.js +2 -25
- package/dist/src/mcp-tools/analyze-tools.js.map +1 -1
- package/dist/src/mcp-tools/auto-install.d.ts.map +1 -1
- package/dist/src/mcp-tools/auto-install.js +2 -1
- package/dist/src/mcp-tools/auto-install.js.map +1 -1
- package/dist/src/mcp-tools/hooks-routing.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-routing.js +26 -0
- package/dist/src/mcp-tools/hooks-routing.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +2 -37
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/mcp-tools/monograph/agent-history-tools.d.ts +5 -0
- package/dist/src/mcp-tools/monograph/agent-history-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/monograph/agent-history-tools.js +177 -0
- package/dist/src/mcp-tools/monograph/agent-history-tools.js.map +1 -0
- package/dist/src/mcp-tools/monograph/build-tools.d.ts +9 -0
- package/dist/src/mcp-tools/monograph/build-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/monograph/build-tools.js +299 -0
- package/dist/src/mcp-tools/monograph/build-tools.js.map +1 -0
- package/dist/src/mcp-tools/monograph/group-tools.d.ts +10 -0
- package/dist/src/mcp-tools/monograph/group-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/monograph/group-tools.js +225 -0
- package/dist/src/mcp-tools/monograph/group-tools.js.map +1 -0
- package/dist/src/mcp-tools/monograph/health-tools.d.ts +6 -0
- package/dist/src/mcp-tools/monograph/health-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/monograph/health-tools.js +113 -0
- package/dist/src/mcp-tools/monograph/health-tools.js.map +1 -0
- package/dist/src/mcp-tools/monograph/impact-tools.d.ts +9 -0
- package/dist/src/mcp-tools/monograph/impact-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/monograph/impact-tools.js +532 -0
- package/dist/src/mcp-tools/monograph/impact-tools.js.map +1 -0
- package/dist/src/mcp-tools/monograph/index.d.ts +10 -0
- package/dist/src/mcp-tools/monograph/index.d.ts.map +1 -0
- package/dist/src/mcp-tools/monograph/index.js +73 -0
- package/dist/src/mcp-tools/monograph/index.js.map +1 -0
- package/dist/src/mcp-tools/monograph/query-tools.d.ts +11 -0
- package/dist/src/mcp-tools/monograph/query-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/monograph/query-tools.js +500 -0
- package/dist/src/mcp-tools/monograph/query-tools.js.map +1 -0
- package/dist/src/mcp-tools/monograph/shared.d.ts +64 -0
- package/dist/src/mcp-tools/monograph/shared.d.ts.map +1 -0
- package/dist/src/mcp-tools/monograph/shared.js +215 -0
- package/dist/src/mcp-tools/monograph/shared.js.map +1 -0
- package/dist/src/mcp-tools/monograph/visualize-tools.d.ts +10 -0
- package/dist/src/mcp-tools/monograph/visualize-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/monograph/visualize-tools.js +382 -0
- package/dist/src/mcp-tools/monograph/visualize-tools.js.map +1 -0
- package/dist/src/mcp-tools/monograph-tools.d.ts +4 -23
- package/dist/src/mcp-tools/monograph-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/monograph-tools.js +4 -2439
- package/dist/src/mcp-tools/monograph-tools.js.map +1 -1
- package/dist/src/mcp-tools/monomind-tools.d.ts +8 -0
- package/dist/src/mcp-tools/monomind-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/monomind-tools.js +13 -1
- package/dist/src/mcp-tools/monomind-tools.js.map +1 -1
- package/dist/src/mcp-tools/quality/security-compliance/detect-secrets.d.ts.map +1 -1
- package/dist/src/mcp-tools/quality/security-compliance/detect-secrets.js +31 -2
- package/dist/src/mcp-tools/quality/security-compliance/detect-secrets.js.map +1 -1
- package/dist/src/mcp-tools/terminal-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/terminal-tools.js +31 -1
- package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
- package/dist/src/mcp-tools/types.d.ts +8 -27
- package/dist/src/mcp-tools/types.d.ts.map +1 -1
- package/dist/src/mcp-tools/types.js +9 -91
- package/dist/src/mcp-tools/types.js.map +1 -1
- package/dist/src/memory/file-permissions.d.ts +15 -0
- package/dist/src/memory/file-permissions.d.ts.map +1 -0
- package/dist/src/memory/file-permissions.js +25 -0
- package/dist/src/memory/file-permissions.js.map +1 -0
- package/dist/src/memory/memory-bridge.d.ts.map +1 -1
- package/dist/src/memory/memory-bridge.js +94 -34
- package/dist/src/memory/memory-bridge.js.map +1 -1
- package/dist/src/memory/memory-crud.d.ts.map +1 -1
- package/dist/src/memory/memory-crud.js +298 -275
- package/dist/src/memory/memory-crud.js.map +1 -1
- package/dist/src/memory/memory-initializer.d.ts +2 -4
- package/dist/src/memory/memory-initializer.d.ts.map +1 -1
- package/dist/src/memory/memory-initializer.js +53 -76
- package/dist/src/memory/memory-initializer.js.map +1 -1
- package/dist/src/memory/memory-migrations.d.ts +1 -14
- package/dist/src/memory/memory-migrations.d.ts.map +1 -1
- package/dist/src/memory/memory-migrations.js +52 -105
- package/dist/src/memory/memory-migrations.js.map +1 -1
- package/dist/src/memory/sona-optimizer.d.ts +1 -1
- package/dist/src/memory/sona-optimizer.js +1 -1
- package/dist/src/monovector/index.d.ts +16 -19
- package/dist/src/monovector/index.d.ts.map +1 -1
- package/dist/src/monovector/index.js +50 -8
- package/dist/src/monovector/index.js.map +1 -1
- package/dist/src/orgrt/approvals.d.ts +16 -0
- package/dist/src/orgrt/approvals.d.ts.map +1 -0
- package/dist/src/orgrt/approvals.js +72 -0
- package/dist/src/orgrt/approvals.js.map +1 -0
- package/dist/src/orgrt/bus.d.ts.map +1 -1
- package/dist/src/orgrt/bus.js +21 -0
- package/dist/src/orgrt/bus.js.map +1 -1
- package/dist/src/orgrt/checkpoint-ops.d.ts +19 -0
- package/dist/src/orgrt/checkpoint-ops.d.ts.map +1 -0
- package/dist/src/orgrt/checkpoint-ops.js +219 -0
- package/dist/src/orgrt/checkpoint-ops.js.map +1 -0
- package/dist/src/orgrt/checkpoint.d.ts +33 -1
- package/dist/src/orgrt/checkpoint.d.ts.map +1 -1
- package/dist/src/orgrt/checkpoint.js +50 -6
- package/dist/src/orgrt/checkpoint.js.map +1 -1
- package/dist/src/orgrt/cross-org.d.ts +32 -0
- package/dist/src/orgrt/cross-org.d.ts.map +1 -0
- package/dist/src/orgrt/cross-org.js +256 -0
- package/dist/src/orgrt/cross-org.js.map +1 -0
- package/dist/src/orgrt/daemon.d.ts +131 -157
- package/dist/src/orgrt/daemon.d.ts.map +1 -1
- package/dist/src/orgrt/daemon.js +356 -966
- package/dist/src/orgrt/daemon.js.map +1 -1
- package/dist/src/orgrt/decisions.d.ts +33 -0
- package/dist/src/orgrt/decisions.d.ts.map +1 -0
- package/dist/src/orgrt/decisions.js +169 -0
- package/dist/src/orgrt/decisions.js.map +1 -0
- package/dist/src/orgrt/kimicode-runner.d.ts.map +1 -1
- package/dist/src/orgrt/kimicode-runner.js +5 -1
- package/dist/src/orgrt/kimicode-runner.js.map +1 -1
- package/dist/src/orgrt/opencode-runner.d.ts.map +1 -1
- package/dist/src/orgrt/opencode-runner.js +10 -2
- package/dist/src/orgrt/opencode-runner.js.map +1 -1
- package/dist/src/orgrt/org-memory.d.ts +45 -0
- package/dist/src/orgrt/org-memory.d.ts.map +1 -0
- package/dist/src/orgrt/org-memory.js +220 -0
- package/dist/src/orgrt/org-memory.js.map +1 -0
- package/dist/src/orgrt/policy.d.ts +4 -0
- package/dist/src/orgrt/policy.d.ts.map +1 -1
- package/dist/src/orgrt/policy.js +13 -1
- package/dist/src/orgrt/policy.js.map +1 -1
- package/dist/src/orgrt/prechecks.d.ts +15 -0
- package/dist/src/orgrt/prechecks.d.ts.map +1 -0
- package/dist/src/orgrt/prechecks.js +21 -0
- package/dist/src/orgrt/prechecks.js.map +1 -0
- package/dist/src/orgrt/questions.d.ts +39 -0
- package/dist/src/orgrt/questions.d.ts.map +1 -0
- package/dist/src/orgrt/questions.js +135 -0
- package/dist/src/orgrt/questions.js.map +1 -0
- package/dist/src/orgrt/remote.d.ts +25 -0
- package/dist/src/orgrt/remote.d.ts.map +1 -0
- package/dist/src/orgrt/remote.js +73 -0
- package/dist/src/orgrt/remote.js.map +1 -0
- package/dist/src/orgrt/scheduler-integration.d.ts +19 -0
- package/dist/src/orgrt/scheduler-integration.d.ts.map +1 -0
- package/dist/src/orgrt/scheduler-integration.js +90 -0
- package/dist/src/orgrt/scheduler-integration.js.map +1 -0
- package/dist/src/orgrt/server.d.ts.map +1 -1
- package/dist/src/orgrt/server.js +70 -2
- package/dist/src/orgrt/server.js.map +1 -1
- package/dist/src/orgrt/session.d.ts +30 -1
- package/dist/src/orgrt/session.d.ts.map +1 -1
- package/dist/src/orgrt/session.js +184 -53
- package/dist/src/orgrt/session.js.map +1 -1
- package/dist/src/orgrt/state-detector.d.ts +19 -0
- package/dist/src/orgrt/state-detector.d.ts.map +1 -0
- package/dist/src/orgrt/state-detector.js +59 -0
- package/dist/src/orgrt/state-detector.js.map +1 -0
- package/dist/src/orgrt/task-dag.d.ts +27 -0
- package/dist/src/orgrt/task-dag.d.ts.map +1 -0
- package/dist/src/orgrt/task-dag.js +100 -0
- package/dist/src/orgrt/task-dag.js.map +1 -0
- package/dist/src/orgrt/tool-fence.d.ts +7 -4
- package/dist/src/orgrt/tool-fence.d.ts.map +1 -1
- package/dist/src/orgrt/tool-fence.js +47 -6
- package/dist/src/orgrt/tool-fence.js.map +1 -1
- package/dist/src/orgrt/types.d.ts +57 -2
- package/dist/src/orgrt/types.d.ts.map +1 -1
- package/dist/src/orgrt/types.js +34 -3
- package/dist/src/orgrt/types.js.map +1 -1
- package/dist/src/routing/model-download.d.ts +49 -0
- package/dist/src/routing/model-download.d.ts.map +1 -0
- package/dist/src/routing/model-download.js +106 -0
- package/dist/src/routing/model-download.js.map +1 -0
- package/dist/src/services/crash-reporter.d.ts +5 -0
- package/dist/src/services/crash-reporter.d.ts.map +1 -1
- package/dist/src/services/crash-reporter.js +49 -0
- package/dist/src/services/crash-reporter.js.map +1 -1
- package/dist/src/transfer/anonymization/index.d.ts +18 -15
- package/dist/src/transfer/anonymization/index.d.ts.map +1 -1
- package/dist/src/transfer/anonymization/index.js +7 -119
- package/dist/src/transfer/anonymization/index.js.map +1 -1
- package/dist/src/ui/dashboard.html +606 -7
- package/dist/src/ui/orgs.html +7 -1
- package/dist/src/ui/routes-monograph.mjs +6 -0
- package/dist/src/ui/server.mjs +327 -7
- package/dist/src/update/checker.d.ts.map +1 -1
- package/dist/src/update/checker.js +2 -1
- package/dist/src/update/checker.js.map +1 -1
- package/dist/src/update/executor.d.ts.map +1 -1
- package/dist/src/update/executor.js +7 -3
- package/dist/src/update/executor.js.map +1 -1
- package/dist/src/update/index.d.ts +0 -1
- package/dist/src/update/index.d.ts.map +1 -1
- package/dist/src/update/index.js +5 -24
- package/dist/src/update/index.js.map +1 -1
- package/dist/src/utils/db-mutex.d.ts +11 -0
- package/dist/src/utils/db-mutex.d.ts.map +1 -0
- package/dist/src/utils/db-mutex.js +23 -0
- package/dist/src/utils/db-mutex.js.map +1 -0
- package/dist/src/utils/input-guards.d.ts +23 -0
- package/dist/src/utils/input-guards.d.ts.map +1 -1
- package/dist/src/utils/input-guards.js +72 -0
- package/dist/src/utils/input-guards.js.map +1 -1
- package/dist/src/utils/npm-command.d.ts +10 -0
- package/dist/src/utils/npm-command.d.ts.map +1 -0
- package/dist/src/utils/npm-command.js +12 -0
- package/dist/src/utils/npm-command.js.map +1 -0
- package/dist/src/utils/paths.d.ts +28 -0
- package/dist/src/utils/paths.d.ts.map +1 -0
- package/dist/src/utils/paths.js +108 -0
- package/dist/src/utils/paths.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -17
- package/scripts/download-embedding-model.mjs +97 -0
- package/scripts/publish.sh +0 -0
- package/scripts/sync-claude-assets.sh +0 -0
- package/dist/src/production/circuit-breaker.d.ts +0 -121
- package/dist/src/production/circuit-breaker.d.ts.map +0 -1
- package/dist/src/production/circuit-breaker.js +0 -262
- package/dist/src/production/circuit-breaker.js.map +0 -1
- package/dist/src/production/error-handler.d.ts +0 -119
- package/dist/src/production/error-handler.d.ts.map +0 -1
- package/dist/src/production/error-handler.js +0 -324
- package/dist/src/production/error-handler.js.map +0 -1
- package/dist/src/production/index.d.ts +0 -6
- package/dist/src/production/index.d.ts.map +0 -1
- package/dist/src/production/index.js +0 -6
- package/dist/src/production/index.js.map +0 -1
- package/dist/src/production/monitoring.d.ts +0 -181
- package/dist/src/production/monitoring.d.ts.map +0 -1
- package/dist/src/production/monitoring.js +0 -375
- package/dist/src/production/monitoring.js.map +0 -1
- package/dist/src/production/rate-limiter.d.ts +0 -125
- package/dist/src/production/rate-limiter.d.ts.map +0 -1
- package/dist/src/production/rate-limiter.js +0 -218
- package/dist/src/production/rate-limiter.js.map +0 -1
- package/dist/src/production/retry.d.ts +0 -48
- package/dist/src/production/retry.d.ts.map +0 -1
- package/dist/src/production/retry.js +0 -189
- package/dist/src/production/retry.js.map +0 -1
- package/dist/src/transfer/types.d.ts +0 -245
- package/dist/src/transfer/types.d.ts.map +0 -1
- package/dist/src/transfer/types.js +0 -6
- package/dist/src/transfer/types.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-fence.d.ts","sourceRoot":"","sources":["../../../src/orgrt/tool-fence.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,0EAA0E;AAC1E,eAAO,MAAM,YAAY,QAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-fence.d.ts","sourceRoot":"","sources":["../../../src/orgrt/tool-fence.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,0EAA0E;AAC1E,eAAO,MAAM,YAAY,QAAoC,CAAC;AAuB9D;+DAC+D;AAC/D,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,MAAM,CA6B7D;AAkBD;;;;;yEAKyE;AACzE,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAAE,EAClB,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GACjD,QAAQ,EAAE,CAwBZ;AAED;;wDAEwD;AACxD,wBAAsB,eAAe,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAa1F;AAED,uEAAuE;AACvE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAI9E"}
|
|
@@ -16,6 +16,39 @@
|
|
|
16
16
|
import { z } from 'zod';
|
|
17
17
|
/** Fenced block the model uses to call a tool (see buildToolProtocol). */
|
|
18
18
|
export const TOOL_CALL_RE = /```tool_call\s*\n([\s\S]*?)```/g;
|
|
19
|
+
/** Return the prefix of `s` ending at the first balanced JSON object/array,
|
|
20
|
+
* respecting string literals. Falls back to `s` unchanged when no balanced
|
|
21
|
+
* prefix exists (JSON.parse then reports the original error). */
|
|
22
|
+
function firstBalancedJson(s) {
|
|
23
|
+
let depth = 0, inStr = false, esc = false;
|
|
24
|
+
for (let i = 0; i < s.length; i++) {
|
|
25
|
+
const c = s[i];
|
|
26
|
+
if (esc) {
|
|
27
|
+
esc = false;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (c === '\\' && inStr) {
|
|
31
|
+
esc = true;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (c === '"') {
|
|
35
|
+
inStr = !inStr;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (inStr)
|
|
39
|
+
continue;
|
|
40
|
+
if (c === '{' || c === '[')
|
|
41
|
+
depth++;
|
|
42
|
+
else if (c === '}' || c === ']') {
|
|
43
|
+
depth--;
|
|
44
|
+
if (depth === 0)
|
|
45
|
+
return s.slice(0, i + 1);
|
|
46
|
+
if (depth < 0)
|
|
47
|
+
return s;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return s;
|
|
51
|
+
}
|
|
19
52
|
/** Max tool_call → tool_result round-trips within a single mailbox prompt.
|
|
20
53
|
* Guards against a model that keeps calling tools forever. */
|
|
21
54
|
export const MAX_TOOL_ROUNDS = 10;
|
|
@@ -91,17 +124,23 @@ function describeZod(schema) {
|
|
|
91
124
|
return `optional ${describeZod(schema._def.innerType)}`;
|
|
92
125
|
return desc ? `${kind} — ${desc}` : kind;
|
|
93
126
|
}
|
|
94
|
-
/** Extract tool_call fences from raw assistant texts.
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
|
|
127
|
+
/** Extract tool_call fences from raw assistant texts. A fence whose JSON
|
|
128
|
+
* cannot be parsed at all is skipped — but NOT silently: `onMalformed` (when
|
|
129
|
+
* given) is invoked with the raw fence body and the parse error so callers
|
|
130
|
+
* can surface it (runners emit it as an assistant note, which session.ts
|
|
131
|
+
* routes to the org bus and scrollback). A parsed object without a string
|
|
132
|
+
* `name` is skipped quietly — there is nothing actionable to report. */
|
|
133
|
+
export function parseToolCalls(rawTexts, onMalformed) {
|
|
98
134
|
const calls = [];
|
|
99
135
|
for (const text of rawTexts) {
|
|
100
136
|
TOOL_CALL_RE.lastIndex = 0;
|
|
101
137
|
let m;
|
|
102
138
|
while ((m = TOOL_CALL_RE.exec(text)) !== null) {
|
|
103
139
|
try {
|
|
104
|
-
|
|
140
|
+
// Models sometimes append extra closing braces after the JSON object
|
|
141
|
+
// (observed with kimi k3: `...}}}`); parse only the first balanced
|
|
142
|
+
// object instead of rejecting the whole fence.
|
|
143
|
+
const parsed = JSON.parse(firstBalancedJson(m[1].trim()));
|
|
105
144
|
if (typeof parsed.name !== 'string' || !parsed.name)
|
|
106
145
|
continue;
|
|
107
146
|
calls.push({
|
|
@@ -111,7 +150,9 @@ export function parseToolCalls(rawTexts) {
|
|
|
111
150
|
: {},
|
|
112
151
|
});
|
|
113
152
|
}
|
|
114
|
-
catch {
|
|
153
|
+
catch (err) {
|
|
154
|
+
onMalformed?.(m[1].trim(), err instanceof Error ? err.message : String(err));
|
|
155
|
+
}
|
|
115
156
|
}
|
|
116
157
|
}
|
|
117
158
|
return calls;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-fence.js","sourceRoot":"","sources":["../../../src/orgrt/tool-fence.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,0EAA0E;AAC1E,MAAM,CAAC,MAAM,YAAY,GAAG,iCAAiC,CAAC;AAE9D;+DAC+D;AAC/D,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAOlC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAmB;IACnD,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAC5C,MAAM,KAAK,GAAG;QACZ,EAAE;QACF,EAAE;QACF,iCAAiC;QACjC,EAAE;QACF,oEAAoE;QACpE,iEAAiE;QACjE,EAAE;QACF,cAAc;QACd,+CAA+C;QAC/C,KAAK;QACL,EAAE;QACF,2EAA2E;QAC3E,0EAA0E;QAC1E,0DAA0D;QAC1D,EAAE;QACF,oCAAoC;QACpC,EAAE;KACH,CAAC;IACF,KAAK,MAAM,CAA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AAkB,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,CAClF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -67,7 +67,13 @@ export declare const RoleSchema: z.ZodObject<{
|
|
|
67
67
|
read: "read";
|
|
68
68
|
}>>>;
|
|
69
69
|
}, z.core.$loose>>;
|
|
70
|
+
runtime: z.ZodOptional<z.ZodEnum<{
|
|
71
|
+
claude: "claude";
|
|
72
|
+
kimicode: "kimicode";
|
|
73
|
+
opencode: "opencode";
|
|
74
|
+
}>>;
|
|
70
75
|
max_turns_per_message: z.ZodOptional<z.ZodNumber>;
|
|
76
|
+
budget_tokens: z.ZodOptional<z.ZodNumber>;
|
|
71
77
|
}, z.core.$loose>;
|
|
72
78
|
export declare const OrgDefSchema: z.ZodObject<{
|
|
73
79
|
name: z.ZodString;
|
|
@@ -80,14 +86,32 @@ export declare const OrgDefSchema: z.ZodObject<{
|
|
|
80
86
|
memory_namespace: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
81
87
|
max_turns_per_message: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
82
88
|
idle_minutes: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
83
|
-
workspace: z.ZodOptional<z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"repo">, z.ZodLiteral<"isolated">, z.ZodString]>>>;
|
|
89
|
+
workspace: z.ZodOptional<z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"repo">, z.ZodLiteral<"isolated">, z.ZodLiteral<"worktree">, z.ZodLiteral<"worktree-per-role">, z.ZodString]>>>;
|
|
90
|
+
circuit_breaker: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
91
|
+
failure_threshold: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
92
|
+
cooldown_ms: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
93
|
+
}, z.core.$strip>>>;
|
|
94
|
+
stale_base_threshold: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
95
|
+
prechecks: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
96
|
+
name: z.ZodString;
|
|
97
|
+
command: z.ZodString;
|
|
98
|
+
}, z.core.$strip>>>>;
|
|
84
99
|
}, z.core.$loose>>, z.ZodTransform<{
|
|
85
100
|
memory_namespace?: string | undefined;
|
|
86
101
|
idle_minutes?: number | undefined;
|
|
102
|
+
circuit_breaker?: {
|
|
103
|
+
failure_threshold?: number | undefined;
|
|
104
|
+
cooldown_ms?: number | undefined;
|
|
105
|
+
} | undefined;
|
|
106
|
+
prechecks?: {
|
|
107
|
+
name: string;
|
|
108
|
+
command: string;
|
|
109
|
+
}[] | undefined;
|
|
87
110
|
max_concurrent_agents: number;
|
|
88
111
|
budget_tokens: number;
|
|
89
112
|
max_turns_per_message: number;
|
|
90
113
|
workspace: string;
|
|
114
|
+
stale_base_threshold: number;
|
|
91
115
|
}, {
|
|
92
116
|
[x: string]: unknown;
|
|
93
117
|
max_concurrent_agents?: number | undefined;
|
|
@@ -96,6 +120,15 @@ export declare const OrgDefSchema: z.ZodObject<{
|
|
|
96
120
|
max_turns_per_message?: number | undefined;
|
|
97
121
|
idle_minutes?: number | undefined;
|
|
98
122
|
workspace?: string | undefined;
|
|
123
|
+
circuit_breaker?: {
|
|
124
|
+
failure_threshold?: number | undefined;
|
|
125
|
+
cooldown_ms?: number | undefined;
|
|
126
|
+
} | undefined;
|
|
127
|
+
stale_base_threshold?: number | undefined;
|
|
128
|
+
prechecks?: {
|
|
129
|
+
name: string;
|
|
130
|
+
command: string;
|
|
131
|
+
}[] | undefined;
|
|
99
132
|
}>>;
|
|
100
133
|
roles: z.ZodArray<z.ZodObject<{
|
|
101
134
|
id: z.ZodString;
|
|
@@ -136,8 +169,19 @@ export declare const OrgDefSchema: z.ZodObject<{
|
|
|
136
169
|
read: "read";
|
|
137
170
|
}>>>;
|
|
138
171
|
}, z.core.$loose>>;
|
|
172
|
+
runtime: z.ZodOptional<z.ZodEnum<{
|
|
173
|
+
claude: "claude";
|
|
174
|
+
kimicode: "kimicode";
|
|
175
|
+
opencode: "opencode";
|
|
176
|
+
}>>;
|
|
139
177
|
max_turns_per_message: z.ZodOptional<z.ZodNumber>;
|
|
178
|
+
budget_tokens: z.ZodOptional<z.ZodNumber>;
|
|
140
179
|
}, z.core.$loose>>;
|
|
180
|
+
runtime: z.ZodOptional<z.ZodEnum<{
|
|
181
|
+
claude: "claude";
|
|
182
|
+
kimicode: "kimicode";
|
|
183
|
+
opencode: "opencode";
|
|
184
|
+
}>>;
|
|
141
185
|
}, z.core.$loose>;
|
|
142
186
|
export type OrgDef = z.infer<typeof OrgDefSchema>;
|
|
143
187
|
export type OrgRole = z.infer<typeof RoleSchema>;
|
|
@@ -149,7 +193,7 @@ export interface BusEvent {
|
|
|
149
193
|
ts: number;
|
|
150
194
|
org: string;
|
|
151
195
|
run: string;
|
|
152
|
-
type: 'message' | 'xorg' | 'tool' | 'asset' | 'chat' | 'status' | 'audit' | 'usage' | 'question';
|
|
196
|
+
type: 'message' | 'xorg' | 'tool' | 'asset' | 'chat' | 'status' | 'audit' | 'usage' | 'question' | 'gate';
|
|
153
197
|
from?: string;
|
|
154
198
|
to?: string;
|
|
155
199
|
subject?: string;
|
|
@@ -166,6 +210,17 @@ export interface BusEvent {
|
|
|
166
210
|
interactionId?: string;
|
|
167
211
|
agentSessionId?: string;
|
|
168
212
|
}
|
|
213
|
+
export interface DecisionGate {
|
|
214
|
+
id: string;
|
|
215
|
+
name: string;
|
|
216
|
+
description: string;
|
|
217
|
+
roleId: string;
|
|
218
|
+
status: 'pending' | 'approved' | 'rejected';
|
|
219
|
+
createdAt: number;
|
|
220
|
+
resolvedBy?: string;
|
|
221
|
+
resolvedAt?: number;
|
|
222
|
+
resolution?: string;
|
|
223
|
+
}
|
|
169
224
|
export declare const ORG_DIR = ".monomind/orgs";
|
|
170
225
|
/**
|
|
171
226
|
* Recommended org_send handoff format for inter-role communication:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/orgrt/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,4FAA4F;AAC5F,eAAO,MAAM,cAAc;;;;;;;;;;;;;kBAOhB,CAAC;AAEZ,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/orgrt/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,4FAA4F;AAC5F,eAAO,MAAM,cAAc;;;;;;;;;;;;;kBAOhB,CAAC;AAEZ,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;iBAcH,CAAC;AAE3B,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0BP,CAAC;AAEjB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAkCmG,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAOlH,CAAC;AAEjB,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAClD,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AACjD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D,mGAAmG;AACnG,M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;GAuBG"}
|
package/dist/src/orgrt/types.js
CHANGED
|
@@ -15,7 +15,9 @@ export const RolePolicySchema = z.object({
|
|
|
15
15
|
/** glob patterns relative to org cwd */
|
|
16
16
|
fileWrite: z.array(z.string()).default(['**']),
|
|
17
17
|
fileRead: z.array(z.string()).default(['**']),
|
|
18
|
-
/** allowed domains for WebFetch/WebSearch; empty array = no web
|
|
18
|
+
/** allowed domains for WebFetch/WebSearch; empty array = no web.
|
|
19
|
+
* Entries: exact host, subdomain suffix ('example.com' also matches
|
|
20
|
+
* 'api.example.com'), '*.example.com' wildcard, or '*' for any host. */
|
|
19
21
|
webAllow: z.array(z.string()).optional(),
|
|
20
22
|
maxTokens: z.number().int().positive().optional(),
|
|
21
23
|
/** Git access level: 'none' blocks all git, 'read' allows status/log/diff,
|
|
@@ -35,10 +37,19 @@ export const RoleSchema = z.object({
|
|
|
35
37
|
}).partial().optional(),
|
|
36
38
|
provider: ProviderSchema.optional(),
|
|
37
39
|
policy: RolePolicySchema.optional(),
|
|
40
|
+
/** Per-role runtime override: when set, this role's sessions run on the given
|
|
41
|
+
* agent runtime regardless of the org-level `runtime` field or the
|
|
42
|
+
* MONOMIND_RUNTIME env var ('claude' explicitly forces the Claude default).
|
|
43
|
+
* Enables mixed-runtime orgs — e.g. a Claude coordinator with opencode workers. */
|
|
44
|
+
runtime: z.enum(['claude', 'kimicode', 'opencode']).optional(),
|
|
38
45
|
/** Per-role override of run_config.max_turns_per_message — roles that legitimately
|
|
39
46
|
* need many more turns per message (e.g. a developer doing sequential build/fix/verify
|
|
40
47
|
* cycles) than others (e.g. docs, pm) shouldn't be forced onto one global budget. */
|
|
41
48
|
max_turns_per_message: z.number().int().positive().optional(),
|
|
49
|
+
/** Per-role override of the even run_config.budget_tokens split — a role on a
|
|
50
|
+
* token-hungry model (e.g. GLM via opencode) can get a larger budget without
|
|
51
|
+
* inflating the org-wide budget for every other role. Unset = even split. */
|
|
52
|
+
budget_tokens: z.number().int().positive().optional(),
|
|
42
53
|
}).passthrough();
|
|
43
54
|
export const OrgDefSchema = z.object({
|
|
44
55
|
name: z.string().min(1),
|
|
@@ -57,10 +68,30 @@ export const OrgDefSchema = z.object({
|
|
|
57
68
|
* 'isolated' — a scratch dir under .monomind/orgs/<name>/workspace, which the
|
|
58
69
|
* policy engine's workdir check then confines every path to.
|
|
59
70
|
* An absolute path is used verbatim. */
|
|
60
|
-
workspace: z.union([z.literal('repo'), z.literal('isolated'), z.string()]).optional(),
|
|
71
|
+
workspace: z.union([z.literal('repo'), z.literal('isolated'), z.literal('worktree'), z.literal('worktree-per-role'), z.string()]).optional(),
|
|
72
|
+
/** Circuit breaker: after N consecutive non-success session results from
|
|
73
|
+
* a role, trip the circuit and close the role's mailbox instead of looping. */
|
|
74
|
+
circuit_breaker: z.object({
|
|
75
|
+
failure_threshold: z.number().int().positive().default(5),
|
|
76
|
+
cooldown_ms: z.number().int().nonnegative().default(0),
|
|
77
|
+
}).partial().optional(),
|
|
78
|
+
/** Stale-base drift detection: warn (or refuse) when the working tree is
|
|
79
|
+
* too many commits behind its tracking branch. 0 disables. */
|
|
80
|
+
stale_base_threshold: z.number().int().nonnegative().default(0),
|
|
81
|
+
/** Precondition checks: shell commands that must exit 0 before a scheduled
|
|
82
|
+
* run starts. If any fail, the run is skipped and the failure logged. */
|
|
83
|
+
prechecks: z.array(z.object({
|
|
84
|
+
name: z.string(),
|
|
85
|
+
command: z.string(),
|
|
86
|
+
})).optional(),
|
|
61
87
|
}).partial().passthrough().default({})
|
|
62
|
-
.transform(rc => ({ max_concurrent_agents: 4, budget_tokens: 1_000_000, max_turns_per_message: 30, workspace: 'repo', ...rc })),
|
|
88
|
+
.transform(rc => ({ max_concurrent_agents: 4, budget_tokens: 1_000_000, max_turns_per_message: 30, workspace: 'repo', stale_base_threshold: 0, ...rc })),
|
|
63
89
|
roles: z.array(RoleSchema).min(1),
|
|
90
|
+
/** Which agent runtime hosts this org's role sessions. When absent, the
|
|
91
|
+
* MONOMIND_RUNTIME env var is honored, falling back to the default Claude
|
|
92
|
+
* runner. Per-org values override the env var, and a role's own `runtime`
|
|
93
|
+
* field (see RoleSchema) overrides this per role. */
|
|
94
|
+
runtime: z.enum(['claude', 'kimicode', 'opencode']).optional(),
|
|
64
95
|
}).passthrough();
|
|
65
96
|
export const ORG_DIR = '.monomind/orgs';
|
|
66
97
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/orgrt/types.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,4FAA4F;AAC5F,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC;IACtH,8DAA8D;IAC9D,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,iEAAiE;IACjE,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACpC,CAAC,CAAC,MAAM,EAAE,CAAC;AAEZ,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC1C,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAC1C,wCAAwC;IACxC,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CA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CAAC,OAAO,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;SACnC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,qBAAqB,EAAE,CAAC,EAAE,aAAa,EAAE,SAAS,EAAE,qBAAqB,EAAE,EAAE,EAAE,SAAS,EAAE,MAAgB,EAAE,oBAAoB,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;IACpK,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACjC;;;0DAGsD;IACtD,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC/D,CAAC,CAAC,WAAW,EAAE,CAAC;AA2CjB,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;GAuBG"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opt-in download of the semantic-routing embedding model.
|
|
3
|
+
*
|
|
4
|
+
* The semantic router (`routing/embedder.ts`) needs the weights of
|
|
5
|
+
* Snowflake/snowflake-arctic-embed-xs (~88 MB) cached on disk by
|
|
6
|
+
* `@huggingface/transformers`. On a fresh install they are absent, so the
|
|
7
|
+
* router silently falls back to keyword + hash routing. Nothing may download
|
|
8
|
+
* them implicitly — this module exists so `monomind init` can ASK first, and
|
|
9
|
+
* so users can fetch the model later via `monomind download-embeddings` (or
|
|
10
|
+
* `scripts/download-embedding-model.mjs` on a source checkout).
|
|
11
|
+
*
|
|
12
|
+
* Kept dependency-light and free of CLI I/O so it is unit-testable: the
|
|
13
|
+
* prompt/TTY decisions live in `embeddingDownloadDecision()`, the actual
|
|
14
|
+
* download in `downloadEmbeddingModel()`.
|
|
15
|
+
*/
|
|
16
|
+
/** HuggingFace model id — kept in sync with `routing/embedder.ts`. */
|
|
17
|
+
export declare const EMBEDDING_MODEL_ID = "Snowflake/snowflake-arctic-embed-xs";
|
|
18
|
+
/** Approximate download size, used only for prompt/UX copy. */
|
|
19
|
+
export declare const EMBEDDING_MODEL_SIZE_LABEL = "~88 MB";
|
|
20
|
+
/**
|
|
21
|
+
* Locate the cache directory `@huggingface/transformers` writes model weights
|
|
22
|
+
* into (`<package root>/.cache`), or null when the optionalDependency is not
|
|
23
|
+
* installed. Resolution mirrors the guard in
|
|
24
|
+
* `__tests__/route-layer-source-worker.test.ts`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function findTransformersCacheDir(): string | null;
|
|
27
|
+
/** True when the embedding model weights are already cached on disk. */
|
|
28
|
+
export declare function isEmbeddingModelCached(): boolean;
|
|
29
|
+
export type EmbeddingDownloadReason = 'already-cached' | 'non-interactive' | 'prompt';
|
|
30
|
+
/**
|
|
31
|
+
* Pure decision for the init-time download prompt, kept separate from I/O so
|
|
32
|
+
* tests can drive it with stubbed TTY/CI values.
|
|
33
|
+
*/
|
|
34
|
+
export declare function embeddingDownloadDecision(input: {
|
|
35
|
+
cached: boolean;
|
|
36
|
+
stdinTTY: boolean;
|
|
37
|
+
stdoutTTY: boolean;
|
|
38
|
+
ci: boolean;
|
|
39
|
+
}): EmbeddingDownloadReason;
|
|
40
|
+
/**
|
|
41
|
+
* Download the embedding model by loading the feature-extraction pipeline
|
|
42
|
+
* once, which populates the transformers.js cache. Progress is reported via
|
|
43
|
+
* the optional `onProgress` callback (human-readable lines).
|
|
44
|
+
*
|
|
45
|
+
* Throws when `@huggingface/transformers` is not installed or the download
|
|
46
|
+
* fails — callers decide how to present that.
|
|
47
|
+
*/
|
|
48
|
+
export declare function downloadEmbeddingModel(onProgress?: (line: string) => void): Promise<void>;
|
|
49
|
+
//# sourceMappingURL=model-download.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-download.d.ts","sourceRoot":"","sources":["../../../src/routing/model-download.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,sEAAsE;AACtE,eAAO,MAAM,kBAAkB,wCAAwC,CAAC;AAExE,+DAA+D;AAC/D,eAAO,MAAM,0BAA0B,WAAW,CAAC;AAEnD;;;;;GAKG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,GAAG,IAAI,CAkBxD;AAED,wEAAwE;AACxE,wBAAgB,sBAAsB,IAAI,OAAO,CAMhD;AAED,MAAM,MAAM,uBAAuB,GAC/B,gBAAgB,GAChB,iBAAiB,GACjB,QAAQ,CAAC;AAEb;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE;IAC/C,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,EAAE,EAAE,OAAO,CAAC;CACb,GAAG,uBAAuB,CAI1B;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAClC,OAAO,CAAC,IAAI,CAAC,CA2Bf"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opt-in download of the semantic-routing embedding model.
|
|
3
|
+
*
|
|
4
|
+
* The semantic router (`routing/embedder.ts`) needs the weights of
|
|
5
|
+
* Snowflake/snowflake-arctic-embed-xs (~88 MB) cached on disk by
|
|
6
|
+
* `@huggingface/transformers`. On a fresh install they are absent, so the
|
|
7
|
+
* router silently falls back to keyword + hash routing. Nothing may download
|
|
8
|
+
* them implicitly — this module exists so `monomind init` can ASK first, and
|
|
9
|
+
* so users can fetch the model later via `monomind download-embeddings` (or
|
|
10
|
+
* `scripts/download-embedding-model.mjs` on a source checkout).
|
|
11
|
+
*
|
|
12
|
+
* Kept dependency-light and free of CLI I/O so it is unit-testable: the
|
|
13
|
+
* prompt/TTY decisions live in `embeddingDownloadDecision()`, the actual
|
|
14
|
+
* download in `downloadEmbeddingModel()`.
|
|
15
|
+
*/
|
|
16
|
+
import { existsSync } from 'fs';
|
|
17
|
+
import { createRequire } from 'module';
|
|
18
|
+
import { dirname, join } from 'path';
|
|
19
|
+
/** HuggingFace model id — kept in sync with `routing/embedder.ts`. */
|
|
20
|
+
export const EMBEDDING_MODEL_ID = 'Snowflake/snowflake-arctic-embed-xs';
|
|
21
|
+
/** Approximate download size, used only for prompt/UX copy. */
|
|
22
|
+
export const EMBEDDING_MODEL_SIZE_LABEL = '~88 MB';
|
|
23
|
+
/**
|
|
24
|
+
* Locate the cache directory `@huggingface/transformers` writes model weights
|
|
25
|
+
* into (`<package root>/.cache`), or null when the optionalDependency is not
|
|
26
|
+
* installed. Resolution mirrors the guard in
|
|
27
|
+
* `__tests__/route-layer-source-worker.test.ts`.
|
|
28
|
+
*/
|
|
29
|
+
export function findTransformersCacheDir() {
|
|
30
|
+
let entry;
|
|
31
|
+
try {
|
|
32
|
+
const require = createRequire(import.meta.url);
|
|
33
|
+
// Resolve the main entry, not '<pkg>/package.json' — the package does not
|
|
34
|
+
// export its package.json, so that throws ERR_PACKAGE_PATH_NOT_EXPORTED.
|
|
35
|
+
entry = require.resolve('@huggingface/transformers');
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
let dir = dirname(entry);
|
|
41
|
+
for (let i = 0; i < 5 && !existsSync(join(dir, 'package.json')); i++) {
|
|
42
|
+
const parent = dirname(dir);
|
|
43
|
+
if (parent === dir)
|
|
44
|
+
break;
|
|
45
|
+
dir = parent;
|
|
46
|
+
}
|
|
47
|
+
return join(dir, '.cache');
|
|
48
|
+
}
|
|
49
|
+
/** True when the embedding model weights are already cached on disk. */
|
|
50
|
+
export function isEmbeddingModelCached() {
|
|
51
|
+
const cache = findTransformersCacheDir();
|
|
52
|
+
if (!cache)
|
|
53
|
+
return false;
|
|
54
|
+
// 'Xenova' covers checkouts where a Xenova-mirrored model populated the
|
|
55
|
+
// same cache (same check the semantic-routing tests use).
|
|
56
|
+
return existsSync(join(cache, 'Snowflake')) || existsSync(join(cache, 'Xenova'));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Pure decision for the init-time download prompt, kept separate from I/O so
|
|
60
|
+
* tests can drive it with stubbed TTY/CI values.
|
|
61
|
+
*/
|
|
62
|
+
export function embeddingDownloadDecision(input) {
|
|
63
|
+
if (input.cached)
|
|
64
|
+
return 'already-cached';
|
|
65
|
+
if (!input.stdinTTY || !input.stdoutTTY || input.ci)
|
|
66
|
+
return 'non-interactive';
|
|
67
|
+
return 'prompt';
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Download the embedding model by loading the feature-extraction pipeline
|
|
71
|
+
* once, which populates the transformers.js cache. Progress is reported via
|
|
72
|
+
* the optional `onProgress` callback (human-readable lines).
|
|
73
|
+
*
|
|
74
|
+
* Throws when `@huggingface/transformers` is not installed or the download
|
|
75
|
+
* fails — callers decide how to present that.
|
|
76
|
+
*/
|
|
77
|
+
export async function downloadEmbeddingModel(onProgress) {
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
|
+
let hf;
|
|
80
|
+
try {
|
|
81
|
+
hf = await import('@huggingface/transformers');
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
throw new Error('@huggingface/transformers is not installed (it is an optionalDependency). ' +
|
|
85
|
+
'Reinstall with optional dependencies enabled, e.g. `npm install --include=optional`.');
|
|
86
|
+
}
|
|
87
|
+
const seen = new Set();
|
|
88
|
+
await hf.pipeline('feature-extraction', EMBEDDING_MODEL_ID, {
|
|
89
|
+
dtype: 'fp32',
|
|
90
|
+
progress_callback: (p) => {
|
|
91
|
+
if (!onProgress || !p)
|
|
92
|
+
return;
|
|
93
|
+
if (p.status === 'downloading' && p.file && !seen.has(p.file)) {
|
|
94
|
+
seen.add(p.file);
|
|
95
|
+
onProgress(`Downloading ${p.file}...`);
|
|
96
|
+
}
|
|
97
|
+
else if (p.status === 'progress' && p.file && typeof p.progress === 'number') {
|
|
98
|
+
onProgress(`Downloading ${p.file}... ${Math.floor(p.progress)}%`);
|
|
99
|
+
}
|
|
100
|
+
else if (p.status === 'done' && p.file) {
|
|
101
|
+
onProgress(`Downloaded ${p.file}`);
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=model-download.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-download.js","sourceRoot":"","sources":["../../../src/routing/model-download.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAErC,sEAAsE;AACtE,MAAM,CAAC,MAAM,kBAAkB,GAAG,qCAAqC,CAAC;AAExE,+DAA+D;AAC/D,MAAM,CAAC,MAAM,0BAA0B,GAAG,QAAQ,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB;IACtC,IAAI,KAAa,CAAC;IAClB,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/C,0EAA0E;QAC1E,yEAAyE;QACzE,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAC;IACvD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACrE,MAAM,MAAM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,EAAE;YAC9E,IAAI,CAAC,UAAU,IAAI,CAAC,CAAC;gBAAE,OAAO;YAC9B,IAAI,CAAC,CAAC,MAAM,KAAK,aAAa,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC9D,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBACjB,UAAU,CAAC,eAAe,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC;YACzC,CAAC;iBAAM,IAAI,CAAC,CAAC,MAAM,KAAK,UAAU,IAAI,CAAC,CAAC,IAAI,IAAI,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;gBAC/E,UAAU,CAAC,eAAe,CAAC,CAAC,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YACpE,CAAC;iBAAM,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;gBACzC,UAAU,CAAC,cAAc,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -28,6 +28,11 @@ export declare function setEnabled(enabled: boolean): void;
|
|
|
28
28
|
/**
|
|
29
29
|
* Strip obvious secrets/PII before anything gets sent to a public GitHub repo.
|
|
30
30
|
* Not a substitute for careful callers — this is a last-resort net.
|
|
31
|
+
*
|
|
32
|
+
* C6 hardening adds: absolute-path collapse (any multi-segment path to
|
|
33
|
+
* basename), hostname redaction (contextual after ://@, standalone with
|
|
34
|
+
* TLD heuristic — excludes version numbers, known code extensions, and
|
|
35
|
+
* decimals), IPv4/IPv6, emails, SSNs, and phone numbers.
|
|
31
36
|
*/
|
|
32
37
|
export declare function redact(text: string): string;
|
|
33
38
|
export declare function computeSignature(repo: string, title: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crash-reporter.d.ts","sourceRoot":"","sources":["../../../src/services/crash-reporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA2BH,MAAM,WAAW,gBAAgB;IAC/B,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,6FAA6F;IAC7F,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,eAAe,GAAG,UAAU,GAAG,cAAc,GAAG,OAAO,CAAC;IAC1F,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAwCD,wBAAgB,SAAS,IAAI,OAAO,CASnC;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAEjD;AAED
|
|
1
|
+
{"version":3,"file":"crash-reporter.d.ts","sourceRoot":"","sources":["../../../src/services/crash-reporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA2BH,MAAM,WAAW,gBAAgB;IAC/B,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,6FAA6F;IAC7F,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,eAAe,GAAG,UAAU,GAAG,cAAc,GAAG,OAAO,CAAC;IAC1F,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAwCD,wBAAgB,SAAS,IAAI,OAAO,CASnC;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAEjD;AAED;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA2F3C;AAkBD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAGpE;AA2KD;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA4FrF"}
|
|
@@ -70,6 +70,11 @@ export function setEnabled(enabled) {
|
|
|
70
70
|
/**
|
|
71
71
|
* Strip obvious secrets/PII before anything gets sent to a public GitHub repo.
|
|
72
72
|
* Not a substitute for careful callers — this is a last-resort net.
|
|
73
|
+
*
|
|
74
|
+
* C6 hardening adds: absolute-path collapse (any multi-segment path to
|
|
75
|
+
* basename), hostname redaction (contextual after ://@, standalone with
|
|
76
|
+
* TLD heuristic — excludes version numbers, known code extensions, and
|
|
77
|
+
* decimals), IPv4/IPv6, emails, SSNs, and phone numbers.
|
|
73
78
|
*/
|
|
74
79
|
export function redact(text) {
|
|
75
80
|
let out = text;
|
|
@@ -86,6 +91,17 @@ export function redact(text) {
|
|
|
86
91
|
out = out.replace(/\/home\/[^/\s]+/g, '/home/<user>');
|
|
87
92
|
out = out.replace(/\/Users\/[^/\s]+/g, '/Users/<user>');
|
|
88
93
|
out = out.replace(/C:\\Users\\[^\\\s]+/g, 'C:\\Users\\<user>');
|
|
94
|
+
// C6: strip IPv4 addresses — leaked via ECONNREFUSED, fetch errors,
|
|
95
|
+
// telemetry endpoints, internal service URLs. IPv6 is handled later with
|
|
96
|
+
// bracket, full, and compressed :: forms.
|
|
97
|
+
out = out.replace(/\b(?:\d{1,3}\.){3}\d{1,3}\b/g, '<ip>');
|
|
98
|
+
// C6: strip emails — commonly embedded in ValidationError messages and
|
|
99
|
+
// customer data dumps that reach the crash handler via err.message.
|
|
100
|
+
out = out.replace(/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g, '<email>');
|
|
101
|
+
// C6: PII in err.message — SSN and phone numbers commonly appear in
|
|
102
|
+
// validation errors. SSN is high-sensitivity; phone is medium.
|
|
103
|
+
out = out.replace(/\b\d{3}-\d{2}-\d{4}\b/g, '<ssn>');
|
|
104
|
+
out = out.replace(/(?:\+?\d{1,3}[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}\b/g, '<phone>');
|
|
89
105
|
const SECRET_PATTERNS = [
|
|
90
106
|
/(?:api[_-]?key|apikey)\s*[:=]\s*['"]?[^\s'"]{8,}['"]?/gi,
|
|
91
107
|
/(?:secret|password|passwd|pwd)\s*[:=]\s*['"]?[^\s'"]{8,}['"]?/gi,
|
|
@@ -102,6 +118,39 @@ export function redact(text) {
|
|
|
102
118
|
];
|
|
103
119
|
for (const pattern of SECRET_PATTERNS)
|
|
104
120
|
out = out.replace(pattern, '[redacted]');
|
|
121
|
+
// Collapse any remaining multi-segment absolute path to its basename,
|
|
122
|
+
// preserving optional :line:col suffixes for debuggability. Fires on
|
|
123
|
+
// /a/b, ~/a/b, C:\a\b — single-segment paths (/tmp) are not touched.
|
|
124
|
+
// Runs AFTER home-dir and username replacement.
|
|
125
|
+
out = out.replace(/(?:~\/|(?<![:/>\w])\/(?!\/)|[A-Z]:\\)(?:[^\s'"]*[/\\])([\w.-]+(?::\d+(?::\d+)?)?)/g, '<path>/$1');
|
|
126
|
+
// Hostname / domain redaction.
|
|
127
|
+
// 1. Contextual: hostnames that follow :// or @ (requires at least one dot).
|
|
128
|
+
out = out.replace(/(\/\/|@)([a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)+)/g, '$1<host>');
|
|
129
|
+
// 2. Standalone: 3+ dot-separated segments with a TLD-like tail (2-6
|
|
130
|
+
// alpha chars). Excludes version numbers (v2.9.0, 1.2.3), filenames
|
|
131
|
+
// whose last segment is a known code/config extension, and bare
|
|
132
|
+
// decimal numbers.
|
|
133
|
+
const KNOWN_CODE_EXTS = /\.(?:js|ts|jsx|tsx|json|md|yaml|yml|html|css|mjs|cjs|toml|xml|txt|log|sql|sh|py|go|rs|rb|java|c|cpp|h|hpp|swift|kt|lock|map)$/i;
|
|
134
|
+
out = out.replace(/\b([a-zA-Z][a-zA-Z0-9-]*(?:\.[a-zA-Z0-9][a-zA-Z0-9-]*)+\.[a-zA-Z]{2,6})\b/g, (match) => {
|
|
135
|
+
if (/^v?\d+(\.\d+)+$/.test(match))
|
|
136
|
+
return match; // version
|
|
137
|
+
if (KNOWN_CODE_EXTS.test(match))
|
|
138
|
+
return match; // filename
|
|
139
|
+
if (/^\d+(\.\d+)+$/.test(match))
|
|
140
|
+
return match; // decimal
|
|
141
|
+
return '<host>';
|
|
142
|
+
});
|
|
143
|
+
// IPv6 addresses.
|
|
144
|
+
// Bracketed form (URLs): [::1], [fe80::1], [2001:db8::1]
|
|
145
|
+
out = out.replace(/\[(?:[0-9a-fA-F]{0,4}:){2,}[0-9a-fA-F]{0,4}\]/g, '[<ipv6>]');
|
|
146
|
+
// Full unbracketed: 3+ colon-separated hex groups (avoids HH:MM:SS false positives)
|
|
147
|
+
out = out.replace(/(?<![:\w])(?:[0-9a-fA-F]{1,4}:){3,7}[0-9a-fA-F]{0,4}(?![:\w])/g, '<ipv6>');
|
|
148
|
+
// Compressed :: with leading hex groups: fe80::1, 2001:db8::1.
|
|
149
|
+
// Uses \b (not lookbehind) so hex digits before :: don't block the match.
|
|
150
|
+
// std::vector is safe: 's' is not [0-9a-fA-F].
|
|
151
|
+
out = out.replace(/\b[0-9a-fA-F]{1,4}(?::[0-9a-fA-F]{1,4})*::(?:[0-9a-fA-F]{1,4}(?::[0-9a-fA-F]{1,4})*)?\b/g, '<ipv6>');
|
|
152
|
+
// Compressed :: without leading hex: ::1, ::ffff:10.0.0.1
|
|
153
|
+
out = out.replace(/(?<![:\w])::(?:[0-9a-fA-F]{1,4}(?::[0-9a-fA-F]{1,4})*)?(?![:\w])/g, '<ipv6>');
|
|
105
154
|
return out;
|
|
106
155
|
}
|
|
107
156
|
/**
|