@unbrained/pm-cli 2026.10.4 → 2026.10.5
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 +2 -2
- package/CHANGELOG.md +11 -0
- package/dist/cli/after-command-context-usage.js +1 -1
- package/dist/cli/argv-utils.js +1 -1
- package/dist/cli/bootstrap-args.js +1 -1
- package/dist/cli/bundle-integrity.js +2 -2
- package/dist/cli/command-namespaces.js +1 -1
- package/dist/cli/commander-usage.d.ts +1 -1
- package/dist/cli/commander-usage.js +7 -4
- package/dist/cli/commands/annotations/comments.js +1 -1
- package/dist/cli/commands/annotations/docs.js +1 -1
- package/dist/cli/commands/annotations/files.js +1 -1
- package/dist/cli/commands/annotations/learnings.js +1 -1
- package/dist/cli/commands/annotations/notes.js +1 -1
- package/dist/cli/commands/extension/describe.js +1 -1
- package/dist/cli/commands/extension/extension.js +1 -1
- package/dist/cli/commands/extension/scaffold.js +1 -1
- package/dist/cli/commands/extension/shared.js +1 -1
- package/dist/cli/commands/governance/gc.js +1 -1
- package/dist/cli/commands/governance/health.js +1 -1
- package/dist/cli/commands/governance/telemetry.js +1 -1
- package/dist/cli/commands/governance/validate.js +1 -1
- package/dist/cli/commands/history/activity.js +1 -1
- package/dist/cli/commands/history/history-compact.js +1 -1
- package/dist/cli/commands/history/history-redact.js +1 -1
- package/dist/cli/commands/history/history-repair.js +1 -1
- package/dist/cli/commands/history/history.js +1 -1
- package/dist/cli/commands/history/restore.js +1 -1
- package/dist/cli/commands/lifecycle/append.js +1 -1
- package/dist/cli/commands/lifecycle/claim.js +1 -1
- package/dist/cli/commands/lifecycle/close-many.js +1 -1
- package/dist/cli/commands/lifecycle/close.js +1 -1
- package/dist/cli/commands/lifecycle/copy.js +1 -1
- package/dist/cli/commands/lifecycle/create.js +1 -1
- package/dist/cli/commands/lifecycle/delete.js +1 -1
- package/dist/cli/commands/lifecycle/focus.js +1 -1
- package/dist/cli/commands/lifecycle/plan.js +1 -1
- package/dist/cli/commands/lifecycle/update-many.js +1 -1
- package/dist/cli/commands/lifecycle/update.js +1 -1
- package/dist/cli/commands/query/aggregate.js +1 -1
- package/dist/cli/commands/query/context.js +1 -1
- package/dist/cli/commands/query/deps.js +1 -1
- package/dist/cli/commands/query/duplicates.js +1 -1
- package/dist/cli/commands/query/eval.js +1 -1
- package/dist/cli/commands/query/get.js +1 -1
- package/dist/cli/commands/query/graph.js +1 -1
- package/dist/cli/commands/query/list.js +1 -1
- package/dist/cli/commands/query/next.js +1 -1
- package/dist/cli/commands/query/search.js +1 -1
- package/dist/cli/commands/query/stats.js +1 -1
- package/dist/cli/commands/test/test-all.js +1 -1
- package/dist/cli/commands/test/test-runs.js +1 -1
- package/dist/cli/commands/test/test.js +1 -1
- package/dist/cli/commands/workspace/config.js +1 -1
- package/dist/cli/commands/workspace/contracts.js +1 -1
- package/dist/cli/commands/workspace/init.js +1 -1
- package/dist/cli/commands/workspace/merge.js +1 -1
- package/dist/cli/commands/workspace/profile.js +1 -1
- package/dist/cli/commands/workspace/schema.js +1 -1
- package/dist/cli/commands/workspace/upgrade.js +1 -1
- package/dist/cli/context-intent-invocation.js +1 -1
- package/dist/cli/description-stdin.js +1 -1
- package/dist/cli/error-guidance.js +3 -1
- package/dist/cli/extension-command-help.js +5 -3
- package/dist/cli/extension-command-options.js +1 -1
- package/dist/cli/extension-recovery.js +1 -1
- package/dist/cli/help-content.js +5 -2
- package/dist/cli/help-json-payload.js +6 -3
- package/dist/cli/invocation-profile.js +2 -2
- package/dist/cli/main.js +5 -5
- package/dist/cli/migration-gates.js +1 -1
- package/dist/cli/option-values.js +1 -1
- package/dist/cli/public.js +1 -1
- package/dist/cli/register-annotations.js +1 -1
- package/dist/cli/register-assurance.js +1 -1
- package/dist/cli/register-files-lookup.js +1 -1
- package/dist/cli/register-history-activity.js +1 -1
- package/dist/cli/register-history-author.js +1 -1
- package/dist/cli/register-history-maintenance.js +2 -2
- package/dist/cli/register-list-query.js +10 -10
- package/dist/cli/register-mutation-options.js +1 -1
- package/dist/cli/register-mutation.js +2 -2
- package/dist/cli/register-operations.js +1 -1
- package/dist/cli/register-setup.js +1 -1
- package/dist/cli/register-structured-mutation.js +1 -1
- package/dist/cli/registration-helpers.js +1 -1
- package/dist/cli/runtime/activation.js +1 -1
- package/dist/cli/runtime/invocation-options.js +1 -1
- package/dist/cli/runtime/projection-retry.js +1 -1
- package/dist/cli/runtime/selection.js +1 -1
- package/dist/cli/runtime/telemetry-outcome.js +1 -1
- package/dist/cli/runtime-compatibility-boundary.js +4 -4
- package/dist/cli/schema/registration.js +2 -2
- package/dist/cli/schema-registration-helpers.js +1 -1
- package/dist/cli/search-refresh.js +1 -1
- package/dist/cli/stats-analytics-json.js +1 -1
- package/dist/cli/telemetry-flush.js +1 -1
- package/dist/cli-bundle/bundle-manifest.json +163 -163
- package/dist/cli-bundle/chunks/chunk-3CYOBJUK.js +3 -0
- package/dist/cli-bundle/chunks/chunk-5MNOWZPN.js +3 -0
- package/dist/cli-bundle/chunks/chunk-AJ7H6XUF.js +20 -0
- package/dist/cli-bundle/chunks/chunk-D332RXZ7.js +80 -0
- package/dist/cli-bundle/chunks/chunk-HRJ6G6ZG.js +31 -0
- package/dist/cli-bundle/chunks/chunk-KRVI56QE.js +6 -0
- package/dist/cli-bundle/chunks/chunk-N4YGSG6F.js +238 -0
- package/dist/cli-bundle/chunks/{chunk-7CE2DJMA.js → chunk-OOLYASYJ.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-R7CG2DB7.js +2 -0
- package/dist/cli-bundle/chunks/chunk-TGMONGWX.js +2 -0
- package/dist/cli-bundle/chunks/chunk-UZ7BIUCI.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-GZMWISWW.js → chunk-VZ63DEVJ.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-WFZ4UEOB.js +2 -0
- package/dist/cli-bundle/chunks/chunk-YVBRASXO.js +8 -0
- package/dist/cli-bundle/chunks/{chunk-SMKHR6BM.js → chunk-Z66DWDAU.js} +87 -87
- package/dist/cli-bundle/chunks/{register-list-query-QBGXO5JJ.js → register-list-query-75QXHIFH.js} +11 -11
- package/dist/cli-bundle/chunks/register-mutation-YS54SCHG.js +20 -0
- package/dist/cli-bundle/chunks/register-operations-6KHZQSYJ.js +2 -0
- package/dist/cli-bundle/chunks/register-setup-RTATEN2M.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-Q6DJ5DFQ.js → chunk-2CVX3KR3.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-5C3IDDW7.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-467EW5RL.js → chunk-ABV67XCC.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-B5RSLVE6.js +3 -0
- package/dist/cli-bundle/focused-chunks/chunk-C224METM.js +20 -0
- package/dist/cli-bundle/focused-chunks/chunk-CLDPTMQY.js +6 -0
- package/dist/cli-bundle/focused-chunks/chunk-DDRN42PB.js +8 -0
- package/dist/cli-bundle/focused-chunks/{chunk-7O4NUJVO.js → chunk-DOVTUKJQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-ECBOPEJE.js +75 -0
- package/dist/cli-bundle/focused-chunks/chunk-GITOYRUW.js +165 -0
- package/dist/cli-bundle/focused-chunks/chunk-GUIF3WVC.js +30 -0
- package/dist/cli-bundle/focused-chunks/chunk-LE4JUCRR.js +3 -0
- package/dist/cli-bundle/focused-chunks/{chunk-HFAW3FJQ.js → chunk-PSXFFQFT.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-RHIH6XIW.js +12 -0
- package/dist/cli-bundle/focused-chunks/chunk-UDYRVBOZ.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-XV5RV4ZT.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-JCVMOSWQ.js → chunk-YMU42COG.js} +2 -2
- package/dist/cli-bundle/main.js +27 -27
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +2 -2
- package/dist/cli-bundle/sdk-core.js +32 -32
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +55 -55
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +10 -10
- package/dist/cli.js +1 -1
- package/dist/core/checkpoint/checkpoint-gc.js +1 -1
- package/dist/core/checkpoint/mutation-checkpoint.js +2 -2
- package/dist/core/config/nested-settings.js +1 -1
- package/dist/core/config/positional-value.js +1 -1
- package/dist/core/diagnostics/remediation.js +1 -1
- package/dist/core/extensions/activation-summary-markdown.js +2 -1
- package/dist/core/extensions/activation-summary.js +1 -1
- package/dist/core/extensions/activation-transaction.js +1 -1
- package/dist/core/extensions/capability-usage.js +1 -1
- package/dist/core/extensions/command-hook-context.js +1 -1
- package/dist/core/extensions/command-metadata-contract.js +1 -1
- package/dist/core/extensions/command-visibility-tier.js +1 -1
- package/dist/core/extensions/contribution-inventory.js +1 -1
- package/dist/core/extensions/exporter-output-contract.js +1 -1
- package/dist/core/extensions/extension-candidate.js +1 -1
- package/dist/core/extensions/extension-capability-aliases.js +1 -1
- package/dist/core/extensions/extension-hook-runtime.js +1 -1
- package/dist/core/extensions/extension-policy.js +1 -1
- package/dist/core/extensions/extension-registries.js +1 -1
- package/dist/core/extensions/extension-runtime-helpers.js +1 -1
- package/dist/core/extensions/extension-types.js +1 -1
- package/dist/core/extensions/flag-definition-validation.js +1 -1
- package/dist/core/extensions/flag-value-types.js +1 -1
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/extensions/item-field-types.js +1 -1
- package/dist/core/extensions/item-fields.js +1 -1
- package/dist/core/extensions/loader.js +1 -1
- package/dist/core/extensions/manifest-parser.js +1 -1
- package/dist/core/extensions/manifest-schema.js +1 -1
- package/dist/core/extensions/module-graph-snapshot.js +1 -1
- package/dist/core/extensions/preflight-ownership.js +1 -1
- package/dist/core/extensions/registration-contracts.js +1 -1
- package/dist/core/extensions/registration-validation.js +1 -1
- package/dist/core/extensions/registration-values.js +1 -1
- package/dist/core/extensions/reserved-host-flags.js +1 -1
- package/dist/core/extensions/runtime-registrations.js +1 -1
- package/dist/core/extensions/service-ownership.js +1 -1
- package/dist/core/extensions/version-compat.js +1 -1
- package/dist/core/fs/atomic-create.js +1 -1
- package/dist/core/fs/fs-utils.js +2 -2
- package/dist/core/fs/host-environment-errors.js +1 -1
- package/dist/core/fs/index.js +1 -1
- package/dist/core/fs/path-utils.js +1 -1
- package/dist/core/governance/content-fields.js +1 -1
- package/dist/core/governance/issue-codes.js +1 -1
- package/dist/core/governance/metadata-coverage.js +1 -1
- package/dist/core/history/digest.js +1 -1
- package/dist/core/history/drift-cache.js +3 -3
- package/dist/core/history/drift-scan.d.ts +4 -0
- package/dist/core/history/drift-scan.js +1 -1
- package/dist/core/history/event-classification.js +1 -1
- package/dist/core/history/event-index.js +8 -7
- package/dist/core/history/history-compact-bulk.js +1 -1
- package/dist/core/history/history-diff.js +1 -1
- package/dist/core/history/history-rewrite.js +1 -1
- package/dist/core/history/history-storage-stats.js +1 -1
- package/dist/core/history/history-stream-policy.js +1 -1
- package/dist/core/history/history.js +2 -2
- package/dist/core/history/identity.js +1 -1
- package/dist/core/history/index.js +1 -1
- package/dist/core/history/operation-contract.js +1 -1
- package/dist/core/history/projection.js +1 -1
- package/dist/core/history/read.js +1 -1
- package/dist/core/history/replay.js +2 -1
- package/dist/core/history/tombstone.js +1 -1
- package/dist/core/history/version-address.js +1 -1
- package/dist/core/history/workspace-history.js +2 -2
- package/dist/core/io/body-file.js +1 -1
- package/dist/core/io/bulk-ids-input.js +2 -1
- package/dist/core/item/actionability.js +1 -1
- package/dist/core/item/dependency-reference.js +1 -1
- package/dist/core/item/id.js +1 -1
- package/dist/core/item/index.js +1 -1
- package/dist/core/item/item-format-version.js +1 -1
- package/dist/core/item/item-format.js +6 -4
- package/dist/core/item/item-record.js +1 -1
- package/dist/core/item/item-type-definition.js +1 -1
- package/dist/core/item/parent-reference-policy.js +1 -1
- package/dist/core/item/parse.js +8 -2
- package/dist/core/item/plan-lifecycle.js +1 -1
- package/dist/core/item/priority.js +1 -1
- package/dist/core/item/sprint-release-format.js +1 -1
- package/dist/core/item/status-filter.js +1 -1
- package/dist/core/item/status.js +1 -1
- package/dist/core/item/toon-decode.js +1 -1
- package/dist/core/item/type-registry.js +1 -1
- package/dist/core/item/type-synonyms.js +1 -1
- package/dist/core/lock/index.js +1 -1
- package/dist/core/lock/lock-gc.js +1 -1
- package/dist/core/lock/lock.js +3 -3
- package/dist/core/output/mutation-projection.js +1 -1
- package/dist/core/output/output-control.js +1 -1
- package/dist/core/output/output.js +22 -10
- package/dist/core/output/query-summary.js +1 -1
- package/dist/core/output/tabular.js +3 -1
- package/dist/core/packages/manifest.js +1 -1
- package/dist/core/packages/root.js +1 -1
- package/dist/core/policy/workflow-policy-schema.js +1 -1
- package/dist/core/policy/workflow-policy-store.js +1 -1
- package/dist/core/policy/workflow-policy.js +1 -1
- package/dist/core/profile/profile-describe.js +1 -1
- package/dist/core/profile/profile-lint.js +1 -1
- package/dist/core/profile/profile-plan.js +1 -1
- package/dist/core/profile/profile-presets.js +25 -1
- package/dist/core/reproducibility/context.js +1 -1
- package/dist/core/schema/fields-file.js +2 -2
- package/dist/core/schema/item-types-file.js +2 -2
- package/dist/core/schema/runtime-field-filters.js +1 -1
- package/dist/core/schema/runtime-field-values.js +1 -1
- package/dist/core/schema/runtime-schema.js +2 -2
- package/dist/core/schema/status-defs-file.js +2 -2
- package/dist/core/schema/status-token.js +1 -1
- package/dist/core/schema/type-inference.js +1 -1
- package/dist/core/schema/type-presets.js +1 -1
- package/dist/core/schema/type-workflows.js +1 -1
- package/dist/core/search/background-refresh.js +2 -2
- package/dist/core/search/bm25.js +1 -1
- package/dist/core/search/cache.js +2 -2
- package/dist/core/search/corpus.js +1 -1
- package/dist/core/search/embedding-batches.js +1 -1
- package/dist/core/search/eval-thresholds.js +1 -1
- package/dist/core/search/eval.js +1 -1
- package/dist/core/search/http-client.js +1 -1
- package/dist/core/search/providers.js +1 -1
- package/dist/core/search/relevance.js +1 -1
- package/dist/core/search/semantic-defaults.js +1 -1
- package/dist/core/search/staleness.js +1 -1
- package/dist/core/search/vector-stores.js +2 -2
- package/dist/core/search/vectorization-metadata.js +1 -1
- package/dist/core/sentry/helpers.js +1 -1
- package/dist/core/sentry/instrument.js +1 -1
- package/dist/core/session/session-state.js +1 -1
- package/dist/core/shared/agent-session-context.js +1 -1
- package/dist/core/shared/author.js +5 -1
- package/dist/core/shared/command-line.js +1 -1
- package/dist/core/shared/command-types.js +1 -1
- package/dist/core/shared/conflict-markers.js +1 -1
- package/dist/core/shared/constants.js +1 -1
- package/dist/core/shared/errors.js +1 -1
- package/dist/core/shared/html-entity-decode.js +1 -1
- package/dist/core/shared/index.js +1 -1
- package/dist/core/shared/item-metadata-contract.js +1 -1
- package/dist/core/shared/lazy-module.js +1 -1
- package/dist/core/shared/levenshtein.js +1 -1
- package/dist/core/shared/memo.js +1 -1
- package/dist/core/shared/numeric-parsers.js +1 -1
- package/dist/core/shared/option-alias-visibility.js +1 -1
- package/dist/core/shared/primitives.js +1 -1
- package/dist/core/shared/secret-rules.js +1 -1
- package/dist/core/shared/serial-queue.js +1 -1
- package/dist/core/shared/serialization.js +1 -1
- package/dist/core/shared/split-comma-list.js +1 -1
- package/dist/core/shared/text-normalization.js +1 -1
- package/dist/core/shared/time.js +2 -1
- package/dist/core/store/index.js +1 -1
- package/dist/core/store/item-format-migration.js +1 -1
- package/dist/core/store/item-metadata-cache.js +1 -1
- package/dist/core/store/item-metadata-query-index.js +7 -7
- package/dist/core/store/item-metadata-read-work.js +1 -1
- package/dist/core/store/item-store.js +1 -1
- package/dist/core/store/paths.js +1 -1
- package/dist/core/store/settings-concurrency.js +1 -1
- package/dist/core/store/settings-read-cache.js +1 -1
- package/dist/core/store/settings-validator.js +1 -1
- package/dist/core/store/settings.js +3 -3
- package/dist/core/store/tracker-preflight.js +1 -1
- package/dist/core/telemetry/consent.js +2 -2
- package/dist/core/telemetry/observability.js +1 -1
- package/dist/core/telemetry/policy.js +1 -1
- package/dist/core/telemetry/read-sampling.js +2 -2
- package/dist/core/telemetry/runtime.js +9 -5
- package/dist/core/test/background-runs.js +3 -3
- package/dist/core/test/item-test-run-tracking.js +1 -1
- package/dist/core/test/run-selectors.js +1 -1
- package/dist/core/validate/estimate-defaults.js +1 -1
- package/dist/core/validate/fix-planning.js +1 -1
- package/dist/core/validate/linked-artifact-reference.js +1 -1
- package/dist/core/validate/missing-by-type.js +1 -1
- package/dist/core/validate/missing-link-owners.js +1 -1
- package/dist/core/validate/stale-file-classification.js +1 -1
- package/dist/mcp/http-server.js +6 -4
- package/dist/mcp/legacy-adapter.js +1 -1
- package/dist/mcp/runtime-capabilities.js +1 -1
- package/dist/mcp/server.js +4 -4
- package/dist/mcp/tool-definitions.js +1 -1
- package/dist/sdk/actionability.js +1 -1
- package/dist/sdk/agent/closed-domain-contracts.js +1 -1
- package/dist/sdk/agent/command-recovery.js +1 -1
- package/dist/sdk/agent/command-suggestions.js +1 -1
- package/dist/sdk/agent/create-option-policy.js +1 -1
- package/dist/sdk/agent/identity-config.js +1 -1
- package/dist/sdk/agent/item-addressing.js +1 -1
- package/dist/sdk/agent/refusal-closure-census.js +2 -1
- package/dist/sdk/agent/refusal-closure.js +1 -1
- package/dist/sdk/agent/refusal-corpus-contracts.js +1 -1
- package/dist/sdk/agent/refusal-reachability.js +3 -1
- package/dist/sdk/agent/subcommand-recovery.js +1 -1
- package/dist/sdk/agent/task-transcript-contracts.js +1 -1
- package/dist/sdk/agent/tracker-preflight-contracts.js +1 -1
- package/dist/sdk/agent-capability-contracts.js +3 -1
- package/dist/sdk/agent-session-context.js +1 -1
- package/dist/sdk/annotations.js +1 -1
- package/dist/sdk/author-attribution.js +1 -1
- package/dist/sdk/authoring.js +1 -1
- package/dist/sdk/cli-bootstrap.js +1 -1
- package/dist/sdk/cli-contracts/agent-output-contracts.js +5 -3
- package/dist/sdk/cli-contracts/bootstrap-command-scanner.js +1 -1
- package/dist/sdk/cli-contracts/command-aliases.js +1 -1
- package/dist/sdk/cli-contracts/command-exit-contracts.js +1 -1
- package/dist/sdk/cli-contracts/commander-mutation-options.js +1 -1
- package/dist/sdk/cli-contracts/commander-types.js +1 -1
- package/dist/sdk/cli-contracts/completeness.js +1 -1
- package/dist/sdk/cli-contracts/enum-contracts.js +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +2 -1
- package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
- package/dist/sdk/cli-contracts/registration-helpers.js +7 -7
- package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
- package/dist/sdk/cli-contracts/schemas/assurance-definition.js +1 -1
- package/dist/sdk/cli-contracts/string-lists.js +1 -1
- package/dist/sdk/cli-contracts/tool-option-contracts.js +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
- package/dist/sdk/cli-contracts/tool-schema.js +1 -1
- package/dist/sdk/cli-contracts/typed-action-inputs.js +1 -1
- package/dist/sdk/cli-contracts.js +1 -1
- package/dist/sdk/cli-program.js +1 -1
- package/dist/sdk/command-line.js +1 -1
- package/dist/sdk/comments.js +1 -1
- package/dist/sdk/compile-cache.js +1 -1
- package/dist/sdk/completion/bash.js +2 -1
- package/dist/sdk/completion/fish.js +13 -7
- package/dist/sdk/completion/shared.js +1 -1
- package/dist/sdk/completion/zsh.js +14 -8
- package/dist/sdk/completion.js +1 -1
- package/dist/sdk/compose.js +1 -1
- package/dist/sdk/config.js +1 -1
- package/dist/sdk/context/recency.js +1 -1
- package/dist/sdk/context/semantic-session-attribution.js +1 -1
- package/dist/sdk/context/usage-egress.js +1 -1
- package/dist/sdk/context/usage-ledger.js +6 -3
- package/dist/sdk/context-intent-contracts.js +1 -1
- package/dist/sdk/context-intent-runtime.js +1 -1
- package/dist/sdk/context-packing.js +1 -1
- package/dist/sdk/context-relevance.js +1 -1
- package/dist/sdk/context-signal-store.js +2 -2
- package/dist/sdk/context-usage.js +1 -1
- package/dist/sdk/contracts.js +1 -1
- package/dist/sdk/core-governance.js +1 -1
- package/dist/sdk/core.js +1 -1
- package/dist/sdk/corpus-shape.js +1 -1
- package/dist/sdk/define.js +1 -1
- package/dist/sdk/dependencies.js +1 -1
- package/dist/sdk/dependency-flag-validation.js +1 -1
- package/dist/sdk/dependency-provenance.js +1 -1
- package/dist/sdk/docs.js +1 -1
- package/dist/sdk/duplicates.js +1 -1
- package/dist/sdk/environment/agent-environment.js +1 -1
- package/dist/sdk/environment/host-environment-errors.js +1 -1
- package/dist/sdk/environment/project-runtime-compatibility.js +2 -1
- package/dist/sdk/environment/source-context.js +1 -1
- package/dist/sdk/environment/tracker-preflight.js +1 -1
- package/dist/sdk/error-code-catalog.js +1 -1
- package/dist/sdk/error-runtime.js +1 -1
- package/dist/sdk/errors.js +1 -1
- package/dist/sdk/eval.js +1 -1
- package/dist/sdk/extension/author-manifest.js +1 -1
- package/dist/sdk/extension/bundled-catalog.js +1 -1
- package/dist/sdk/extension/concurrency.js +1 -1
- package/dist/sdk/extension/copy-scope.js +1 -1
- package/dist/sdk/extension/custom-field-collisions.js +1 -1
- package/dist/sdk/extension/describe.js +4 -2
- package/dist/sdk/extension/doctor.js +1 -1
- package/dist/sdk/extension/install-plan.js +1 -1
- package/dist/sdk/extension/install-receipts.js +1 -1
- package/dist/sdk/extension/install-runtime.js +3 -3
- package/dist/sdk/extension/install-snapshot.js +1 -1
- package/dist/sdk/extension/install-sources.js +5 -5
- package/dist/sdk/extension/managed-state.js +2 -2
- package/dist/sdk/extension/migrations.js +2 -2
- package/dist/sdk/extension/output-ownership.js +1 -1
- package/dist/sdk/extension/runtime-summary.js +1 -1
- package/dist/sdk/extension/scaffold.js +11 -4
- package/dist/sdk/extension/shared.js +1 -1
- package/dist/sdk/extension/source-resolution.js +1 -1
- package/dist/sdk/extension/static-inventory.js +1 -1
- package/dist/sdk/extension/update-check.js +1 -1
- package/dist/sdk/extension-command-context.js +1 -1
- package/dist/sdk/extension-contracts.js +1 -1
- package/dist/sdk/extension.js +1 -1
- package/dist/sdk/files.js +1 -1
- package/dist/sdk/flag-invocation-contracts.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
- package/dist/sdk/generated-error-code-catalog.js +1 -1
- package/dist/sdk/governance/assurance-action-contracts.js +1 -1
- package/dist/sdk/governance/assurance-action.js +1 -1
- package/dist/sdk/governance/assurance-limits.js +1 -1
- package/dist/sdk/governance/assurance-mutation-error.js +1 -1
- package/dist/sdk/governance/assurance-presets.js +1 -1
- package/dist/sdk/governance/assurance-runtime.js +1 -1
- package/dist/sdk/governance/assurance.js +4 -4
- package/dist/sdk/governance/boundary-fixtures.js +1 -1
- package/dist/sdk/governance/closure-timestamps.js +1 -1
- package/dist/sdk/governance/coverage-assurance.js +1 -1
- package/dist/sdk/governance/defect-recurrence-coverage.js +1 -1
- package/dist/sdk/governance/defect-recurrence-graph.js +1 -1
- package/dist/sdk/governance/defect-recurrence-signals.js +1 -1
- package/dist/sdk/governance/defect-recurrence.js +1 -1
- package/dist/sdk/governance/extension-host-version.js +1 -1
- package/dist/sdk/governance/gc.js +1 -1
- package/dist/sdk/governance/health-merge-evidence.js +1 -1
- package/dist/sdk/governance/health.js +2 -1
- package/dist/sdk/governance/hierarchy-validation.js +1 -1
- package/dist/sdk/governance/linked-file-report.js +1 -1
- package/dist/sdk/governance/merge-receipt-history.js +1 -1
- package/dist/sdk/governance/provenance-health.js +4 -1
- package/dist/sdk/governance/reindex.js +5 -4
- package/dist/sdk/governance/stale-work.js +1 -1
- package/dist/sdk/governance/status-role-diagnostics.js +1 -1
- package/dist/sdk/governance/storage-integrity.js +1 -1
- package/dist/sdk/governance/tracked-runtime-cache.js +1 -1
- package/dist/sdk/governance/upgrade.js +2 -2
- package/dist/sdk/governance/validate-history-drift.js +1 -1
- package/dist/sdk/governance/validate-item-reader.js +1 -1
- package/dist/sdk/governance/validate-normalization.js +1 -1
- package/dist/sdk/governance/validate.js +1 -1
- package/dist/sdk/governance/workflow-completeness.js +1 -1
- package/dist/sdk/governance/workflow-policy.js +3 -3
- package/dist/sdk/governance/workspace-position.js +2 -1
- package/dist/sdk/governance.js +1 -1
- package/dist/sdk/graph/adapter.js +1 -1
- package/dist/sdk/graph/analytics.js +1 -1
- package/dist/sdk/graph/assembly.js +1 -1
- package/dist/sdk/graph/cache.js +1 -1
- package/dist/sdk/graph/centrality.js +1 -1
- package/dist/sdk/graph/conformance.js +1 -1
- package/dist/sdk/graph/deadline-scheduling.js +1 -1
- package/dist/sdk/graph/durable-cache.js +1 -1
- package/dist/sdk/graph/governance-contracts.js +1 -1
- package/dist/sdk/graph/governance.js +1 -1
- package/dist/sdk/graph/hierarchy-integrity.js +1 -1
- package/dist/sdk/graph/index.js +1 -1
- package/dist/sdk/graph/lifecycle-coverage.js +1 -1
- package/dist/sdk/graph/mutation-advisory.js +1 -1
- package/dist/sdk/graph/query-contracts.js +1 -1
- package/dist/sdk/graph/remediation.js +1 -1
- package/dist/sdk/graph/run.js +1 -1
- package/dist/sdk/graph/scheduling.js +1 -1
- package/dist/sdk/graph/traversal.js +1 -1
- package/dist/sdk/graph/workspace-relationship-kind-registry.js +1 -1
- package/dist/sdk/graph.js +1 -1
- package/dist/sdk/guide-topics.js +1 -1
- package/dist/sdk/guide.js +8 -1
- package/dist/sdk/history/attestation-command.js +1 -1
- package/dist/sdk/history/attestation-contract.js +1 -1
- package/dist/sdk/history/attestation-scan.js +1 -1
- package/dist/sdk/history/attestation.js +1 -1
- package/dist/sdk/history/maintenance.js +1 -1
- package/dist/sdk/history/salvage.js +3 -2
- package/dist/sdk/history/subject.js +1 -1
- package/dist/sdk/history-analytics.js +1 -1
- package/dist/sdk/history-compact.js +1 -1
- package/dist/sdk/history-mcp.js +1 -1
- package/dist/sdk/history-provenance.js +1 -1
- package/dist/sdk/history-read.js +1 -1
- package/dist/sdk/history-redact.js +1 -1
- package/dist/sdk/history-repair.js +1 -1
- package/dist/sdk/improvement-ledger-validation.js +1 -1
- package/dist/sdk/improvement-ledger.js +2 -2
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/init-agent-guidance.js +16 -2
- package/dist/sdk/init.js +16 -2
- package/dist/sdk/invocation-author.js +1 -1
- package/dist/sdk/item-children.js +1 -1
- package/dist/sdk/item-metadata-index.js +1 -1
- package/dist/sdk/item-schedule.js +1 -1
- package/dist/sdk/item-transaction.js +1 -1
- package/dist/sdk/learnings.js +1 -1
- package/dist/sdk/lifecycle/append.js +4 -2
- package/dist/sdk/lifecycle/claim.js +1 -1
- package/dist/sdk/lifecycle/close-many.js +1 -1
- package/dist/sdk/lifecycle/close.js +1 -1
- package/dist/sdk/lifecycle/copy.js +1 -1
- package/dist/sdk/lifecycle/create.js +1 -1
- package/dist/sdk/lifecycle/delete.js +1 -1
- package/dist/sdk/lifecycle/event-validation-messages.js +1 -1
- package/dist/sdk/lifecycle/focus.js +1 -1
- package/dist/sdk/lifecycle/hierarchy-mutation-lock.js +1 -1
- package/dist/sdk/lifecycle/legacy-none-tokens.js +1 -1
- package/dist/sdk/lifecycle/lifecycle-transitions.js +1 -1
- package/dist/sdk/lifecycle/mcp-actions.js +1 -1
- package/dist/sdk/lifecycle/metadata-normalizers.js +1 -1
- package/dist/sdk/lifecycle/mutation-command-options.js +1 -1
- package/dist/sdk/lifecycle/plan-mutation-receipt.js +1 -1
- package/dist/sdk/lifecycle/plan.js +1 -1
- package/dist/sdk/lifecycle/recurrence-parsers.js +1 -1
- package/dist/sdk/lifecycle/reopen.js +1 -1
- package/dist/sdk/lifecycle/repeatable-metadata-parsers.js +2 -1
- package/dist/sdk/lifecycle/restore.js +1 -1
- package/dist/sdk/lifecycle/shared-unset-fields.js +1 -1
- package/dist/sdk/lifecycle/task-composition.js +1 -1
- package/dist/sdk/lifecycle/update-many.js +1 -1
- package/dist/sdk/lifecycle/update.js +2 -1
- package/dist/sdk/lifecycle-completion.js +1 -1
- package/dist/sdk/lifecycle-policy.js +1 -1
- package/dist/sdk/linked-artifacts.js +2 -1
- package/dist/sdk/mcp/apps.js +1 -1
- package/dist/sdk/mcp/authorization.js +1 -1
- package/dist/sdk/mcp/discovery.js +1 -1
- package/dist/sdk/mcp/interactions.js +1 -1
- package/dist/sdk/mcp/protocol.js +1 -1
- package/dist/sdk/mcp/skills.js +3 -1
- package/dist/sdk/mcp/subscriptions.js +1 -1
- package/dist/sdk/mcp/tasks.js +2 -2
- package/dist/sdk/mcp/transport.js +1 -1
- package/dist/sdk/merge/abandoned-receipts.js +1 -1
- package/dist/sdk/merge/driver.js +1 -1
- package/dist/sdk/merge/index.js +1 -1
- package/dist/sdk/merge/install.js +4 -2
- package/dist/sdk/merge/receipt-file-boundary.js +1 -1
- package/dist/sdk/merge/receipt-operation.js +1 -1
- package/dist/sdk/merge/receipt-schema.js +1 -1
- package/dist/sdk/merge/receipts.js +4 -4
- package/dist/sdk/merge/reconcile.js +1 -1
- package/dist/sdk/merge/three-way.js +3 -2
- package/dist/sdk/merge/worktree-config.js +1 -1
- package/dist/sdk/merge.js +1 -1
- package/dist/sdk/mutation-events.js +1 -1
- package/dist/sdk/mutation-guard.js +1 -1
- package/dist/sdk/notes.js +1 -1
- package/dist/sdk/output-contracts.js +1 -1
- package/dist/sdk/output-projection.js +1 -1
- package/dist/sdk/output-token-accounting.js +1 -1
- package/dist/sdk/output.js +2 -1
- package/dist/sdk/ownership-source.js +1 -1
- package/dist/sdk/package-import-adapters.js +1 -1
- package/dist/sdk/package-migrations.js +1 -1
- package/dist/sdk/package-runtime-options.js +1 -1
- package/dist/sdk/pagination.js +1 -1
- package/dist/sdk/profile.js +5 -1
- package/dist/sdk/provenance.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/query/activity.js +1 -1
- package/dist/sdk/query/aggregate.js +1 -1
- package/dist/sdk/query/calendar.js +4 -1
- package/dist/sdk/query/complete-list.js +1 -1
- package/dist/sdk/query/context.js +2 -1
- package/dist/sdk/query/duplicate-candidates.js +1 -1
- package/dist/sdk/query/get.d.ts +14 -2
- package/dist/sdk/query/get.js +1 -1
- package/dist/sdk/query/history.js +1 -1
- package/dist/sdk/query/item-filter-options.js +1 -1
- package/dist/sdk/query/light-metadata.js +1 -1
- package/dist/sdk/query/list-filter-shared.js +1 -1
- package/dist/sdk/query/list.js +1 -1
- package/dist/sdk/query/multi-value-filters.js +1 -1
- package/dist/sdk/query/next-ready-budget.js +1 -1
- package/dist/sdk/query/next.js +2 -1
- package/dist/sdk/query/parsers.js +1 -1
- package/dist/sdk/query/projection-contracts.js +1 -1
- package/dist/sdk/query/search/corpus.js +2 -1
- package/dist/sdk/query/search/filters.js +1 -1
- package/dist/sdk/query/search/input.js +1 -1
- package/dist/sdk/query/search/lexical.js +1 -1
- package/dist/sdk/query/search/response.js +1 -1
- package/dist/sdk/query/search/semantic.js +3 -2
- package/dist/sdk/query/search/types.js +1 -1
- package/dist/sdk/query/search-contracts.js +1 -1
- package/dist/sdk/query/search-pagination.js +1 -1
- package/dist/sdk/query/search-rendering.js +1 -1
- package/dist/sdk/query/search.js +1 -1
- package/dist/sdk/query/workspace-contracts.js +1 -1
- package/dist/sdk/query.js +1 -1
- package/dist/sdk/read-output/continuation.js +1 -1
- package/dist/sdk/read-output/options.js +1 -1
- package/dist/sdk/read-output/provenance.js +1 -1
- package/dist/sdk/read-output-budget.js +1 -1
- package/dist/sdk/read-output-contracts.js +1 -1
- package/dist/sdk/read-output-rows.js +1 -1
- package/dist/sdk/read-output-session.js +1 -1
- package/dist/sdk/relationship-analytics.js +1 -1
- package/dist/sdk/relationship-context.js +1 -1
- package/dist/sdk/relationship-history.js +7 -4
- package/dist/sdk/relationship-kinds/contract.js +1 -1
- package/dist/sdk/relationship-migration.js +1 -1
- package/dist/sdk/relationships.js +1 -1
- package/dist/sdk/reproducibility/process.js +1 -1
- package/dist/sdk/runtime/actions.js +1 -1
- package/dist/sdk/runtime/context.js +1 -1
- package/dist/sdk/runtime/schema-preview.js +1 -1
- package/dist/sdk/runtime/schema.js +1 -1
- package/dist/sdk/runtime-action-aliases.js +1 -1
- package/dist/sdk/runtime-extended-actions.js +1 -1
- package/dist/sdk/runtime-input.js +1 -1
- package/dist/sdk/runtime-primitives.js +1 -1
- package/dist/sdk/runtime-public-contracts.js +1 -1
- package/dist/sdk/runtime-stats-options.js +1 -1
- package/dist/sdk/runtime.js +1 -1
- package/dist/sdk/scheduling-shortcuts.js +1 -1
- package/dist/sdk/schema-migration.js +4 -3
- package/dist/sdk/schema.js +7 -1
- package/dist/sdk/search-refresh-worker.js +1 -1
- package/dist/sdk/similarity-scoring.js +1 -1
- package/dist/sdk/similarity.js +1 -1
- package/dist/sdk/start-task-status.js +1 -1
- package/dist/sdk/stats.js +1 -1
- package/dist/sdk/structured-mutations.js +1 -1
- package/dist/sdk/telemetry-flush.js +1 -1
- package/dist/sdk/telemetry.js +4 -3
- package/dist/sdk/templates.js +26 -2
- package/dist/sdk/test/batch.js +2 -2
- package/dist/sdk/test/entry.js +1 -1
- package/dist/sdk/test/execution.js +6 -5
- package/dist/sdk/test/json-path.js +1 -1
- package/dist/sdk/test/linked-command-detection.js +1 -1
- package/dist/sdk/test/measurements.js +1 -1
- package/dist/sdk/test/parsers.js +1 -1
- package/dist/sdk/test/runs.js +1 -1
- package/dist/sdk/test/trust.js +2 -2
- package/dist/sdk/test/workspace-snapshot.js +1 -1
- package/dist/sdk/testing.js +7 -4
- package/dist/sdk/traceability/runtime-files-lookup.js +1 -1
- package/dist/sdk/traceability/source-traceability.js +2 -1
- package/dist/sdk/tracker-root-discovery.js +1 -1
- package/dist/sdk/workspace-contracts-cache.js +1 -1
- package/dist/sdk/workspace-contracts.js +1 -1
- package/dist/sdk/workspace-memory.js +2 -2
- package/dist/sdk/workspace-recipe.js +1 -1
- package/dist/sdk/workspace-snapshot.js +5 -4
- package/dist/sdk/workspace-transaction-gc.js +1 -1
- package/dist/sdk/workspace-transaction.js +2 -2
- package/dist/sdk/workspace.js +3 -2
- package/dist/types/index.js +1 -1
- package/dist/types.js +1 -1
- package/docs/AGENT_EVIDENCE_CONSISTENCY.md +88 -0
- package/docs/GET_READ_EVIDENCE.md +68 -0
- package/docs/README.md +2 -0
- package/marketplace.json +2 -2
- package/package.json +1 -1
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/extensions/vcs/index.ts +4 -2
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +2 -2
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +2 -2
- package/plugins/pm-codex/plugin.json +1 -1
- package/scripts/finalize-build.mjs +3 -2
- package/dist/cli-bundle/chunks/chunk-7UVXKI7K.js +0 -2
- package/dist/cli-bundle/chunks/chunk-D7Z2ZMJL.js +0 -3
- package/dist/cli-bundle/chunks/chunk-DEZPZOQ7.js +0 -2
- package/dist/cli-bundle/chunks/chunk-J52QIRRZ.js +0 -80
- package/dist/cli-bundle/chunks/chunk-JDKD3WGG.js +0 -6
- package/dist/cli-bundle/chunks/chunk-JQ7DW663.js +0 -2
- package/dist/cli-bundle/chunks/chunk-QXIDOOWT.js +0 -20
- package/dist/cli-bundle/chunks/chunk-SGFQQXFD.js +0 -2
- package/dist/cli-bundle/chunks/chunk-V3U77H3V.js +0 -31
- package/dist/cli-bundle/chunks/chunk-XZDWAYJC.js +0 -3
- package/dist/cli-bundle/chunks/chunk-Y6VRBTP3.js +0 -238
- package/dist/cli-bundle/chunks/chunk-YAAFYFS4.js +0 -8
- package/dist/cli-bundle/chunks/register-mutation-53ZLT4RX.js +0 -20
- package/dist/cli-bundle/chunks/register-operations-OBK2FXUU.js +0 -2
- package/dist/cli-bundle/chunks/register-setup-HM3OCBH2.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-2JFYR56O.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-32EVUSS4.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-5GUSO2P4.js +0 -20
- package/dist/cli-bundle/focused-chunks/chunk-6XBRADQQ.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-CURTIIQT.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-IJUWEEEB.js +0 -6
- package/dist/cli-bundle/focused-chunks/chunk-JMJK2L4Z.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-KG3H4UZZ.js +0 -30
- package/dist/cli-bundle/focused-chunks/chunk-MHQ2XICU.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-RJV6QVJE.js +0 -75
- package/dist/cli-bundle/focused-chunks/chunk-ZE2JZ7R6.js +0 -12
- package/dist/cli-bundle/focused-chunks/chunk-ZLEN4HZD.js +0 -165
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
`;await writeFileAtomic(ledgerPath,serialized)}function buildVectorPayload(item){return{id:item.id,type:item.type,status:item.status,priority:item.priority,updated_at:item.updated_at}}function buildVectorizationIdentityForProvider(provider){const identity=buildVectorizationEmbeddingIdentity(provider.name,provider.model);if(!identity){throw new Error("Embedding provider must include a provider name and model")}return identity}function buildSkippedSemanticRefreshResult(itemIds,warning){return{refreshed:[],skipped:itemIds,warnings:[warning]}}async function resolveSemanticRefreshRuntimeContext(pmRoot,normalizedItemIds,options){if(!options.settings&&!await pathExists(getSettingsPath(pmRoot))){return buildSkippedSemanticRefreshResult(normalizedItemIds,"search_semantic_refresh_skipped:settings_not_initialized")}let settings;try{if(options.settings){settings=options.settings}else{const settingsRead=await readSettingsWithMetadata(pmRoot);const readFailure=settingsRead.warnings.find(warning=>warning.startsWith("settings_read_"));if(readFailure){return buildSkippedSemanticRefreshResult(normalizedItemIds,`search_semantic_refresh_skipped:settings_read_failed:${readFailure}`)}settings=settingsRead.settings}}catch(error){return buildSkippedSemanticRefreshResult(normalizedItemIds,`search_semantic_refresh_skipped:settings_read_failed:${toErrorMessage(error)}`)}const effectiveSettings=options.apply_runtime_defaults?resolveSettingsWithSemanticRuntimeDefaults(settings).settings:settings;const provider=resolveEmbeddingProviders(effectiveSettings).active;if(!provider){return buildSkippedSemanticRefreshResult(normalizedItemIds,"search_semantic_refresh_skipped:provider_unconfigured")}const vectorStore=resolveVectorStores(effectiveSettings,pmRoot).active;if(!vectorStore){return buildSkippedSemanticRefreshResult(normalizedItemIds,"search_semantic_refresh_skipped:vector_store_unconfigured")}return{settings:effectiveSettings,provider,vectorStore}}async function collectSemanticRefreshWorkload(pmRoot,idPrefix,preferredFormat,normalizedItemIds,typeToFolder,schema){const warnings=[];const skipped=new Set;const missing=new Set;const documents=[];for(const itemId of normalizedItemIds){const located=await locateItem(pmRoot,itemId,idPrefix,preferredFormat,typeToFolder);if(!located){missing.add(itemId);continue}try{const loaded=await readLocatedItem(located,{schema});documents.push({id:loaded.document.metadata.id,document:loaded.document})}catch(error){skipped.add(located.id);warnings.push(`search_semantic_refresh_item_read_failed:${located.id}:${toErrorMessage(error)}`)}}documents.sort((left,right)=>left.id.localeCompare(right.id));return{documents,missingIds:toUniqueSorted(missing),skippedIds:toUniqueSorted(skipped),warnings}}async function embedLocatedSemanticVectors(settings,provider,documents){const corpusCharacterLimit=resolveSemanticCorpusCharacterLimit(provider.name,settings.search.embedding_corpus_max_characters).maxCharacters;const corpusFields=resolveSearchCorpusFields(settings);const corpusInputs=documents.map(entry=>buildSemanticCorpusInput(entry.document,{providerName:provider.name,maxCharacters:corpusCharacterLimit,fields:corpusFields}));const embeddingResult=await executeEmbeddingBatchesWithRetry(provider,settings,corpusInputs);return{vectors:embeddingResult.vectors,vector_dimension:inferConsistentVectorDimension(embeddingResult.vectors,"Semantic refresh embedding"),warnings:embeddingResult.warnings}}async function upsertLocatedSemanticVectors(vectorStore,documents,vectors){await executeVectorUpsert(vectorStore,documents.map((entry,index)=>({id:entry.id,vector:vectors[index],payload:buildVectorPayload(entry.document.metadata)})));return{refreshed:documents.map(entry=>entry.id),skipped:[],warnings:[]}}async function resetSemanticVectorStore(vectorStore,ledgerEntries){try{await executeVectorReset(vectorStore,Object.keys(ledgerEntries));return{refreshed:[],skipped:[],warnings:[]}}catch(error){return{refreshed:[],skipped:[],warnings:[`search_semantic_refresh_reset_failed:${toErrorMessage(error)}`]}}}async function pruneMissingSemanticVectors(vectorStore,missingIds){if(missingIds.length===0){return{refreshed:[],skipped:[],warnings:[]}}try{await executeVectorDelete(vectorStore,missingIds);return{refreshed:[],skipped:[],warnings:[]}}catch(error){return{refreshed:[],skipped:missingIds,warnings:[`search_semantic_refresh_delete_failed:${toErrorMessage(error)}`]}}}async function invalidateSearchCacheArtifacts(pmRoot){const invalidated=[];const warnings=[];for(const relativePath of SEARCH_CACHE_ARTIFACT_PATHS){const artifactPath=path.join(pmRoot,relativePath);try{if(!await pathExists(artifactPath)){continue}await removeFileIfExists(artifactPath);invalidated.push(relativePath)}catch(error){warnings.push(formatInvalidationWarning(relativePath,error))}}return{invalidated,warnings}}async function refreshSemanticEmbeddingsForMutatedItems(pmRoot,itemIds,options={}){const normalizedItemIds=toUniqueSorted(itemIds);if(normalizedItemIds.length===0){return{refreshed:[],skipped:[],warnings:[]}}const runtimeContext=await resolveSemanticRefreshRuntimeContext(pmRoot,normalizedItemIds,options);if(!("settings"in runtimeContext)){return runtimeContext}const typeRegistry=resolveItemTypeRegistry(runtimeContext.settings,getActiveExtensionRegistrations());const workload=await collectSemanticRefreshWorkload(pmRoot,runtimeContext.settings.id_prefix,runtimeContext.settings.item_format,normalizedItemIds,typeRegistry.type_to_folder,runtimeContext.settings.schema);const ledgerRead=workload.documents.length>0||workload.missingIds.length>0?await readVectorizationStatusLedger(pmRoot):{entries:{},embedding:null,warnings:[]};const embeddingIdentity=buildVectorizationIdentityForProvider(runtimeContext.provider);const nextLedgerBaseEntries=ledgerRead.entries;let refreshedResult={refreshed:[],skipped:[],warnings:[]};let nextEmbeddingMetadata=ledgerRead.embedding;if(workload.documents.length>0){if(ledgerRead.embedding&&hasVectorizationEmbeddingIdentityChanged(ledgerRead.embedding,embeddingIdentity)){refreshedResult={refreshed:[],skipped:workload.documents.map(entry=>entry.id),warnings:["search_semantic_refresh_requires_reindex:embedding_identity_changed"]}}else{try{const embedded=await embedLocatedSemanticVectors(runtimeContext.settings,runtimeContext.provider,workload.documents);if(hasVectorizationVectorDimensionChanged(ledgerRead.embedding,embedded.vector_dimension)){refreshedResult={refreshed:[],skipped:workload.documents.map(entry=>entry.id),warnings:[...embedded.warnings,"search_semantic_refresh_requires_reindex:vector_dimension_changed"]}}else{nextEmbeddingMetadata=buildVectorizationEmbeddingMetadata(embeddingIdentity,embedded.vector_dimension);const upserted=await upsertLocatedSemanticVectors(runtimeContext.vectorStore,workload.documents,embedded.vectors);refreshedResult={refreshed:upserted.refreshed,skipped:upserted.skipped,warnings:[...embedded.warnings,...upserted.warnings]}}}catch(error){refreshedResult={refreshed:[],skipped:workload.documents.map(entry=>entry.id),warnings:[`search_semantic_refresh_failed:${toErrorMessage(error)}`]}}}}const pruneResult=await pruneMissingSemanticVectors(runtimeContext.vectorStore,workload.missingIds);const refreshedIdSet=new Set(refreshedResult.refreshed);const refreshedEntries=Object.fromEntries(workload.documents.filter(entry=>refreshedIdSet.has(entry.id)).map(entry=>[entry.id,entry.document.metadata.updated_at]));const ledgerWarnings=[];if(Object.keys(refreshedEntries).length>0||workload.missingIds.length>0){const nextEntries={...nextLedgerBaseEntries,...normalizeVectorizationLedgerEntries(refreshedEntries)};for(const missingId of workload.missingIds){delete nextEntries[missingId]}try{await writeVectorizationStatusLedger(pmRoot,nextEntries,nextEmbeddingMetadata)}catch(error){ledgerWarnings.push(`search_vectorization_status_ledger_write_failed:${toErrorMessage(error)}`)}ledgerWarnings.push(...ledgerRead.warnings)}return{refreshed:toUniqueSorted([...refreshedResult.refreshed,...pruneResult.refreshed]),skipped:toUniqueSorted([...workload.skippedIds,...refreshedResult.skipped,...pruneResult.skipped]),warnings:[...workload.warnings,...refreshedResult.warnings,...pruneResult.warnings,...ledgerWarnings]}}function isSemanticRefreshActive(settings,applyRuntimeDefaults){const effectiveSettings=applyRuntimeDefaults?resolveSettingsWithSemanticRuntimeDefaults(settings).settings:settings;return Boolean(resolveEmbeddingProviders(effectiveSettings).active&&resolveVectorStores(effectiveSettings).active)}async function refreshSearchArtifactsForMutation(pmRoot,itemIds,options={}){const invalidation=await invalidateSearchCacheArtifacts(pmRoot);const normalizedItemIds=toUniqueSorted(itemIds);if(normalizedItemIds.length===0){return{invalidated:invalidation.invalidated,refreshed:[],skipped:[],warnings:invalidation.warnings}}if(!await pathExists(getSettingsPath(pmRoot))){const semanticRefresh2=await refreshSemanticEmbeddingsForMutatedItems(pmRoot,normalizedItemIds);return{invalidated:invalidation.invalidated,refreshed:semanticRefresh2.refreshed,skipped:semanticRefresh2.skipped,warnings:[...invalidation.warnings,...semanticRefresh2.warnings]}}let settings;try{const settingsRead=await readSettingsWithMetadata(pmRoot);const readFailure=settingsRead.warnings.find(warning=>warning.startsWith("settings_read_"));if(readFailure){return{invalidated:invalidation.invalidated,refreshed:[],skipped:normalizedItemIds,warnings:[...invalidation.warnings,`search_semantic_refresh_skipped:settings_read_failed:${readFailure}`]}}settings=settingsRead.settings}catch(error){return{invalidated:invalidation.invalidated,refreshed:[],skipped:normalizedItemIds,warnings:[...invalidation.warnings,`search_semantic_refresh_skipped:settings_read_failed:${toErrorMessage(error)}`]}}if(settings.search.mutation_refresh_policy==="cache_only"){return{invalidated:invalidation.invalidated,refreshed:[],skipped:normalizedItemIds,warnings:invalidation.warnings}}const applyRuntimeDefaults=settings.search.mutation_refresh_policy==="semantic_auto";if(options.background&&isSemanticRefreshActive(settings,applyRuntimeDefaults)){await scheduleBackgroundSemanticRefresh(pmRoot,normalizedItemIds);return{invalidated:invalidation.invalidated,refreshed:[],skipped:[],warnings:[...invalidation.warnings,"search_semantic_refresh_scheduled_background"],scheduled:true}}const semanticRefresh=await refreshSemanticEmbeddingsForMutatedItems(pmRoot,normalizedItemIds,{settings,apply_runtime_defaults:applyRuntimeDefaults});return{invalidated:invalidation.invalidated,refreshed:semanticRefresh.refreshed,skipped:semanticRefresh.skipped,warnings:[...invalidation.warnings,...semanticRefresh.warnings]}}const _testOnly={buildSkippedSemanticRefreshResult,buildVectorizationIdentityForProvider,normalizeVectorizationLedgerEntries,resetSemanticVectorStore};export{SEARCH_CACHE_ARTIFACT_PATHS,VECTORIZATION_STATUS_LEDGER_PATH,_testOnly,invalidateSearchCacheArtifacts,isSemanticRefreshActive,readVectorizationStatusLedger,refreshSearchArtifactsForMutation,refreshSemanticEmbeddingsForMutatedItems,writeVectorizationStatusLedger};
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7113dff5-c8e0-5ba6-b0ae-2ff849ed94df")}catch{}})();import path from"node:path";import{getActiveExtensionRegistrations}from"../extensions/index.js";import{pathExists,readFileIfExists,removeFileIfExists,writeFileAtomic}from"../fs/fs-utils.js";import{resolveItemTypeRegistry}from"../item/type-registry.js";import{toErrorMessage}from"../shared/primitives.js";import{locateItem,readLocatedItem}from"../store/item-store.js";import{getSettingsPath}from"../store/paths.js";import{readSettingsWithMetadata}from"../store/settings.js";import{executeEmbeddingBatchesWithRetry}from"./embedding-batches.js";import{buildSemanticCorpusInput,resolveSearchCorpusFields,resolveSemanticCorpusCharacterLimit}from"./corpus.js";import{resolveEmbeddingProviders}from"./providers.js";import{resolveSettingsWithSemanticRuntimeDefaults}from"./semantic-defaults.js";import{scheduleBackgroundSemanticRefresh}from"./background-refresh.js";import{executeVectorDelete,executeVectorReset,executeVectorUpsert,resolveVectorStores}from"./vector-stores.js";import{buildVectorizationEmbeddingIdentity,buildVectorizationEmbeddingMetadata,hasVectorizationEmbeddingIdentityChanged,hasVectorizationVectorDimensionChanged,inferConsistentVectorDimension,normalizeVectorizationEmbeddingMetadata}from"./vectorization-metadata.js";import{nowIso}from"../shared/time.js";const SEARCH_CACHE_ARTIFACT_PATHS=["index/manifest.json","search/embeddings.jsonl"],VECTORIZATION_STATUS_LEDGER_PATH="search/vectorization-status.json";function formatInvalidationWarning(relativePath,error){return`search_cache_invalidation_failed:${relativePath}:${String(error)}`}function toUniqueSorted(values){return[...new Set([...values].map(value=>value.trim()).filter(value=>value.length>0))].sort((left,right)=>left.localeCompare(right))}function isValidUpdatedAt(value){return typeof value=="string"&&value.trim().length>0&&Number.isFinite(Date.parse(value))}function normalizeVectorizationLedgerEntries(entries){const normalized=new Map;for(const[rawId,rawUpdatedAt]of Object.entries(entries)){const id=rawId.trim();id.length===0||!isValidUpdatedAt(rawUpdatedAt)||normalized.set(id,rawUpdatedAt)}return Object.fromEntries([...normalized.entries()].sort((left,right)=>left[0].localeCompare(right[0])))}async function readVectorizationStatusLedger(pmRoot){const ledgerPath=path.join(pmRoot,VECTORIZATION_STATUS_LEDGER_PATH),raw=await readFileIfExists(ledgerPath);if(raw===null||raw.trim().length===0)return{entries:{},embedding:null,warnings:[]};let parsed;try{parsed=JSON.parse(raw)}catch{return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]}}if(typeof parsed!="object"||parsed===null||parsed.version!==1||!Array.isArray(parsed.items))return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]};const mapped=new Map;for(const entry of parsed.items){if(typeof entry!="object"||entry===null)return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]};const id=entry.id,updatedAt=entry.updated_at;if(typeof id!="string"||id.trim().length===0||!isValidUpdatedAt(updatedAt))return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]};mapped.set(id.trim(),updatedAt)}let embedding=null;try{embedding=normalizeVectorizationEmbeddingMetadata(parsed.embedding)}catch{return{entries:{},embedding:null,warnings:["search_vectorization_status_ledger_invalid"]}}return{entries:Object.fromEntries([...mapped.entries()].sort((left,right)=>left[0].localeCompare(right[0]))),embedding,warnings:[]}}async function writeVectorizationStatusLedger(pmRoot,entries,embedding){const normalizedEntries=normalizeVectorizationLedgerEntries(entries),ledgerPath=path.join(pmRoot,VECTORIZATION_STATUS_LEDGER_PATH),serialized=`${JSON.stringify({version:1,generated_at:nowIso(),...embedding?{embedding}:{},items:Object.entries(normalizedEntries).map(([id,updated_at])=>({id,updated_at}))},null,2)}
|
|
2
|
+
`;await writeFileAtomic(ledgerPath,serialized)}function buildVectorPayload(item){return{id:item.id,type:item.type,status:item.status,priority:item.priority,updated_at:item.updated_at}}function buildVectorizationIdentityForProvider(provider){const identity=buildVectorizationEmbeddingIdentity(provider.name,provider.model);if(!identity)throw new Error("Embedding provider must include a provider name and model");return identity}function buildSkippedSemanticRefreshResult(itemIds,warning){return{refreshed:[],skipped:itemIds,warnings:[warning]}}async function resolveSemanticRefreshRuntimeContext(pmRoot,normalizedItemIds,options){if(!options.settings&&!await pathExists(getSettingsPath(pmRoot)))return buildSkippedSemanticRefreshResult(normalizedItemIds,"search_semantic_refresh_skipped:settings_not_initialized");let settings;try{if(options.settings)settings=options.settings;else{const settingsRead=await readSettingsWithMetadata(pmRoot),readFailure=settingsRead.warnings.find(warning=>warning.startsWith("settings_read_"));if(readFailure)return buildSkippedSemanticRefreshResult(normalizedItemIds,`search_semantic_refresh_skipped:settings_read_failed:${readFailure}`);settings=settingsRead.settings}}catch(error){return buildSkippedSemanticRefreshResult(normalizedItemIds,`search_semantic_refresh_skipped:settings_read_failed:${toErrorMessage(error)}`)}const effectiveSettings=options.apply_runtime_defaults?resolveSettingsWithSemanticRuntimeDefaults(settings).settings:settings,provider=resolveEmbeddingProviders(effectiveSettings).active;if(!provider)return buildSkippedSemanticRefreshResult(normalizedItemIds,"search_semantic_refresh_skipped:provider_unconfigured");const vectorStore=resolveVectorStores(effectiveSettings,pmRoot).active;return vectorStore?{settings:effectiveSettings,provider,vectorStore}:buildSkippedSemanticRefreshResult(normalizedItemIds,"search_semantic_refresh_skipped:vector_store_unconfigured")}async function collectSemanticRefreshWorkload(pmRoot,idPrefix,preferredFormat,normalizedItemIds,typeToFolder,schema){const warnings=[],skipped=new Set,missing=new Set,documents=[];for(const itemId of normalizedItemIds){const located=await locateItem(pmRoot,itemId,idPrefix,preferredFormat,typeToFolder);if(!located){missing.add(itemId);continue}try{const loaded=await readLocatedItem(located,{schema});documents.push({id:loaded.document.metadata.id,document:loaded.document})}catch(error){skipped.add(located.id),warnings.push(`search_semantic_refresh_item_read_failed:${located.id}:${toErrorMessage(error)}`)}}return documents.sort((left,right)=>left.id.localeCompare(right.id)),{documents,missingIds:toUniqueSorted(missing),skippedIds:toUniqueSorted(skipped),warnings}}async function embedLocatedSemanticVectors(settings,provider,documents){const corpusCharacterLimit=resolveSemanticCorpusCharacterLimit(provider.name,settings.search.embedding_corpus_max_characters).maxCharacters,corpusFields=resolveSearchCorpusFields(settings),corpusInputs=documents.map(entry=>buildSemanticCorpusInput(entry.document,{providerName:provider.name,maxCharacters:corpusCharacterLimit,fields:corpusFields})),embeddingResult=await executeEmbeddingBatchesWithRetry(provider,settings,corpusInputs);return{vectors:embeddingResult.vectors,vector_dimension:inferConsistentVectorDimension(embeddingResult.vectors,"Semantic refresh embedding"),warnings:embeddingResult.warnings}}async function upsertLocatedSemanticVectors(vectorStore,documents,vectors){return await executeVectorUpsert(vectorStore,documents.map((entry,index)=>({id:entry.id,vector:vectors[index],payload:buildVectorPayload(entry.document.metadata)}))),{refreshed:documents.map(entry=>entry.id),skipped:[],warnings:[]}}async function resetSemanticVectorStore(vectorStore,ledgerEntries){try{return await executeVectorReset(vectorStore,Object.keys(ledgerEntries)),{refreshed:[],skipped:[],warnings:[]}}catch(error){return{refreshed:[],skipped:[],warnings:[`search_semantic_refresh_reset_failed:${toErrorMessage(error)}`]}}}async function pruneMissingSemanticVectors(vectorStore,missingIds){if(missingIds.length===0)return{refreshed:[],skipped:[],warnings:[]};try{return await executeVectorDelete(vectorStore,missingIds),{refreshed:[],skipped:[],warnings:[]}}catch(error){return{refreshed:[],skipped:missingIds,warnings:[`search_semantic_refresh_delete_failed:${toErrorMessage(error)}`]}}}async function invalidateSearchCacheArtifacts(pmRoot){const invalidated=[],warnings=[];for(const relativePath of SEARCH_CACHE_ARTIFACT_PATHS){const artifactPath=path.join(pmRoot,relativePath);try{if(!await pathExists(artifactPath))continue;await removeFileIfExists(artifactPath),invalidated.push(relativePath)}catch(error){warnings.push(formatInvalidationWarning(relativePath,error))}}return{invalidated,warnings}}async function refreshSemanticEmbeddingsForMutatedItems(pmRoot,itemIds,options={}){const normalizedItemIds=toUniqueSorted(itemIds);if(normalizedItemIds.length===0)return{refreshed:[],skipped:[],warnings:[]};const runtimeContext=await resolveSemanticRefreshRuntimeContext(pmRoot,normalizedItemIds,options);if(!("settings"in runtimeContext))return runtimeContext;const typeRegistry=resolveItemTypeRegistry(runtimeContext.settings,getActiveExtensionRegistrations()),workload=await collectSemanticRefreshWorkload(pmRoot,runtimeContext.settings.id_prefix,runtimeContext.settings.item_format,normalizedItemIds,typeRegistry.type_to_folder,runtimeContext.settings.schema),ledgerRead=workload.documents.length>0||workload.missingIds.length>0?await readVectorizationStatusLedger(pmRoot):{entries:{},embedding:null,warnings:[]},embeddingIdentity=buildVectorizationIdentityForProvider(runtimeContext.provider),nextLedgerBaseEntries=ledgerRead.entries;let refreshedResult={refreshed:[],skipped:[],warnings:[]},nextEmbeddingMetadata=ledgerRead.embedding;if(workload.documents.length>0)if(ledgerRead.embedding&&hasVectorizationEmbeddingIdentityChanged(ledgerRead.embedding,embeddingIdentity))refreshedResult={refreshed:[],skipped:workload.documents.map(entry=>entry.id),warnings:["search_semantic_refresh_requires_reindex:embedding_identity_changed"]};else try{const embedded=await embedLocatedSemanticVectors(runtimeContext.settings,runtimeContext.provider,workload.documents);if(hasVectorizationVectorDimensionChanged(ledgerRead.embedding,embedded.vector_dimension))refreshedResult={refreshed:[],skipped:workload.documents.map(entry=>entry.id),warnings:[...embedded.warnings,"search_semantic_refresh_requires_reindex:vector_dimension_changed"]};else{nextEmbeddingMetadata=buildVectorizationEmbeddingMetadata(embeddingIdentity,embedded.vector_dimension);const upserted=await upsertLocatedSemanticVectors(runtimeContext.vectorStore,workload.documents,embedded.vectors);refreshedResult={refreshed:upserted.refreshed,skipped:upserted.skipped,warnings:[...embedded.warnings,...upserted.warnings]}}}catch(error){refreshedResult={refreshed:[],skipped:workload.documents.map(entry=>entry.id),warnings:[`search_semantic_refresh_failed:${toErrorMessage(error)}`]}}const pruneResult=await pruneMissingSemanticVectors(runtimeContext.vectorStore,workload.missingIds),refreshedIdSet=new Set(refreshedResult.refreshed),refreshedEntries=Object.fromEntries(workload.documents.filter(entry=>refreshedIdSet.has(entry.id)).map(entry=>[entry.id,entry.document.metadata.updated_at])),ledgerWarnings=[];if(Object.keys(refreshedEntries).length>0||workload.missingIds.length>0){const nextEntries={...nextLedgerBaseEntries,...normalizeVectorizationLedgerEntries(refreshedEntries)};for(const missingId of workload.missingIds)delete nextEntries[missingId];try{await writeVectorizationStatusLedger(pmRoot,nextEntries,nextEmbeddingMetadata)}catch(error){ledgerWarnings.push(`search_vectorization_status_ledger_write_failed:${toErrorMessage(error)}`)}ledgerWarnings.push(...ledgerRead.warnings)}return{refreshed:toUniqueSorted([...refreshedResult.refreshed,...pruneResult.refreshed]),skipped:toUniqueSorted([...workload.skippedIds,...refreshedResult.skipped,...pruneResult.skipped]),warnings:[...workload.warnings,...refreshedResult.warnings,...pruneResult.warnings,...ledgerWarnings]}}function isSemanticRefreshActive(settings,applyRuntimeDefaults){const effectiveSettings=applyRuntimeDefaults?resolveSettingsWithSemanticRuntimeDefaults(settings).settings:settings;return!!(resolveEmbeddingProviders(effectiveSettings).active&&resolveVectorStores(effectiveSettings).active)}async function refreshSearchArtifactsForMutation(pmRoot,itemIds,options={}){const invalidation=await invalidateSearchCacheArtifacts(pmRoot),normalizedItemIds=toUniqueSorted(itemIds);if(normalizedItemIds.length===0)return{invalidated:invalidation.invalidated,refreshed:[],skipped:[],warnings:invalidation.warnings};if(!await pathExists(getSettingsPath(pmRoot))){const semanticRefresh2=await refreshSemanticEmbeddingsForMutatedItems(pmRoot,normalizedItemIds);return{invalidated:invalidation.invalidated,refreshed:semanticRefresh2.refreshed,skipped:semanticRefresh2.skipped,warnings:[...invalidation.warnings,...semanticRefresh2.warnings]}}let settings;try{const settingsRead=await readSettingsWithMetadata(pmRoot),readFailure=settingsRead.warnings.find(warning=>warning.startsWith("settings_read_"));if(readFailure)return{invalidated:invalidation.invalidated,refreshed:[],skipped:normalizedItemIds,warnings:[...invalidation.warnings,`search_semantic_refresh_skipped:settings_read_failed:${readFailure}`]};settings=settingsRead.settings}catch(error){return{invalidated:invalidation.invalidated,refreshed:[],skipped:normalizedItemIds,warnings:[...invalidation.warnings,`search_semantic_refresh_skipped:settings_read_failed:${toErrorMessage(error)}`]}}if(settings.search.mutation_refresh_policy==="cache_only")return{invalidated:invalidation.invalidated,refreshed:[],skipped:normalizedItemIds,warnings:invalidation.warnings};const applyRuntimeDefaults=settings.search.mutation_refresh_policy==="semantic_auto";if(options.background&&isSemanticRefreshActive(settings,applyRuntimeDefaults))return await scheduleBackgroundSemanticRefresh(pmRoot,normalizedItemIds),{invalidated:invalidation.invalidated,refreshed:[],skipped:[],warnings:[...invalidation.warnings,"search_semantic_refresh_scheduled_background"],scheduled:!0};const semanticRefresh=await refreshSemanticEmbeddingsForMutatedItems(pmRoot,normalizedItemIds,{settings,apply_runtime_defaults:applyRuntimeDefaults});return{invalidated:invalidation.invalidated,refreshed:semanticRefresh.refreshed,skipped:semanticRefresh.skipped,warnings:[...invalidation.warnings,...semanticRefresh.warnings]}}const _testOnly={buildSkippedSemanticRefreshResult,buildVectorizationIdentityForProvider,normalizeVectorizationLedgerEntries,resetSemanticVectorStore};export{SEARCH_CACHE_ARTIFACT_PATHS,VECTORIZATION_STATUS_LEDGER_PATH,_testOnly,invalidateSearchCacheArtifacts,isSemanticRefreshActive,readVectorizationStatusLedger,refreshSearchArtifactsForMutation,refreshSemanticEmbeddingsForMutatedItems,writeVectorizationStatusLedger};
|
|
3
3
|
//# sourceMappingURL=cache.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5c86afdf-6d8d-5851-82c1-ae5bcc9f0196")}catch{}})();import{coercePositiveInteger}from"../shared/primitives.js";const DEFAULT_SEARCH_CORPUS_FIELDS=["title","description","tags","status","type","priority","assignee","parent","goal","value","why_now","risk","confidence","estimated_minutes","acceptance_criteria","resolution","expected_result","actual_result","body","comments","notes","learnings","reminders","events","dependencies","plan"];function resolveSearchCorpusFields(settings){const configured=settings?.search?.corpus_fields;if(!Array.isArray(configured))return[...DEFAULT_SEARCH_CORPUS_FIELDS];const knownFields=new Set(DEFAULT_SEARCH_CORPUS_FIELDS),selected=Array.from(new Set(configured.filter(entry=>typeof entry=="string").map(entry=>entry.trim()).filter(entry=>entry.length>0&&knownFields.has(entry))));return selected.length>0?selected:[...DEFAULT_SEARCH_CORPUS_FIELDS]}const DEFAULT_SEMANTIC_CORPUS_INPUT_MAX_CHARACTERS=8e3,OLLAMA_SEMANTIC_CORPUS_INPUT_MAX_CHARACTERS=3200,SEMANTIC_CORPUS_TRUNCATION_SUFFIX="...[semantic corpus truncated]",SEARCH_EMBEDDING_CORPUS_MAX_CHARACTERS_INVALID_WARNING="search_embedding_corpus_max_characters_invalid:using_provider_default";function compactParts(parts){return parts.map(part=>part==null?"":String(part).trim()).filter(part=>part.length>0).join(" ")}function buildReminderCorpus(item){return(item.reminders??[]).map(reminder=>compactParts([reminder.at,reminder.text]))}function buildEventCorpus(item){return(item.events??[]).map(event=>compactParts([event.start_at,event.end_at,event.title,event.description,event.location,event.all_day===!0?"all day":void 0,event.timezone,event.recurrence?.freq,event.recurrence?.interval,event.recurrence?.count,event.recurrence?.until,event.recurrence?.by_weekday?.join(" "),event.recurrence?.by_month_day?.join(" "),event.recurrence?.exdates?.join(" ")]))}function appendPlanStepFlatCorpus(segments,step){segments.push(step.title,step.body,step.status,step.owner,step.evidence,step.blocked_reason,step.superseded_by);for(const link of step.linked_items??[])segments.push(`${link.kind} ${link.id}`,link.note);for(const file of step.files??[])segments.push(file.path,file.note);for(const test of step.tests??[])segments.push(test.command,test.path,test.note);for(const doc of step.docs??[])segments.push(doc.path,doc.note)}function appendPlanMetadataFlatCorpus(segments,item){for(const decision of item.plan_decisions??[])segments.push(decision.decision,decision.rationale,decision.evidence);for(const discovery of item.plan_discoveries??[])segments.push(discovery.text);for(const check of item.plan_validation??[])segments.push(check.text,check.command,check.expected)}function buildPlanFlatCorpus(item){const segments=[];segments.push(item.plan_mode,item.plan_scope,item.plan_harness,item.plan_resume_context);for(const step of item.plan_steps??[])appendPlanStepFlatCorpus(segments,step);return appendPlanMetadataFlatCorpus(segments,item),segments.filter(segment=>typeof segment=="string"&&segment.length>0).join(" ")}function buildPlanCorpus(item){const steps=(item.plan_steps??[]).map(step=>compactParts([step.order,step.id,step.title,step.body,step.status,step.owner,step.evidence,step.blocked_reason,step.superseded_by,(step.linked_items??[]).map(link=>compactParts([link.kind,link.id,link.note])).join(" "),(step.files??[]).map(file=>compactParts([file.path,file.note])).join(" "),(step.tests??[]).map(test=>compactParts([test.command,test.path,test.note])).join(" "),(step.docs??[]).map(doc=>compactParts([doc.path,doc.note])).join(" ")])),decisions=(item.plan_decisions??[]).map(entry=>compactParts([entry.decision,entry.rationale,entry.evidence,entry.step_id])),discoveries=(item.plan_discoveries??[]).map(entry=>compactParts([entry.text,entry.step_id])),validation=(item.plan_validation??[]).map(entry=>compactParts([entry.text,entry.command,entry.expected]));if([item.plan_mode,item.plan_scope,item.plan_harness,item.plan_resume_context,...steps,...decisions,...discoveries,...validation].some(entry=>entry!==void 0))return{mode:item.plan_mode,scope:item.plan_scope,harness:item.plan_harness,resume_context:item.plan_resume_context,steps,decisions,discoveries,validation}}function isNonEmptyString(value){return typeof value=="string"&&value.trim().length>0}const CORPUS_FIELD_BUILDERS={title:document=>document.metadata.title,description:document=>document.metadata.description,tags:document=>document.metadata.tags,status:document=>document.metadata.status,type:document=>document.metadata.type,priority:document=>typeof document.metadata.priority=="number"?document.metadata.priority:void 0,assignee:document=>isNonEmptyString(document.metadata.assignee)?document.metadata.assignee:void 0,parent:document=>isNonEmptyString(document.metadata.parent)?document.metadata.parent:void 0,goal:document=>isNonEmptyString(document.metadata.goal)?document.metadata.goal:void 0,value:document=>isNonEmptyString(document.metadata.value)?document.metadata.value:void 0,why_now:document=>isNonEmptyString(document.metadata.why_now)?document.metadata.why_now:void 0,risk:document=>isNonEmptyString(document.metadata.risk)?document.metadata.risk:void 0,confidence:document=>document.metadata.confidence!==void 0&&document.metadata.confidence!==null?document.metadata.confidence:void 0,estimated_minutes:document=>typeof document.metadata.estimated_minutes=="number"?document.metadata.estimated_minutes:void 0,acceptance_criteria:document=>isNonEmptyString(document.metadata.acceptance_criteria)?document.metadata.acceptance_criteria:void 0,resolution:document=>isNonEmptyString(document.metadata.resolution)?document.metadata.resolution:void 0,expected_result:document=>isNonEmptyString(document.metadata.expected_result)?document.metadata.expected_result:void 0,actual_result:document=>isNonEmptyString(document.metadata.actual_result)?document.metadata.actual_result:void 0,body:document=>document.body,comments:document=>(document.metadata.comments??[]).map(entry=>entry.text),notes:document=>(document.metadata.notes??[]).map(entry=>entry.text),learnings:document=>(document.metadata.learnings??[]).map(entry=>entry.text),reminders:document=>buildReminderCorpus(document.metadata),events:document=>buildEventCorpus(document.metadata),dependencies:document=>(document.metadata.dependencies??[]).map(entry=>({id:entry.id,kind:entry.kind})),plan:document=>buildPlanCorpus(document.metadata)};function buildSearchCorpus(document,options={}){const fields=options.fields??DEFAULT_SEARCH_CORPUS_FIELDS,corpus={};for(const field of fields){const builder=CORPUS_FIELD_BUILDERS[field];if(!builder)continue;const value=builder(document);value!==void 0&&(corpus[field]=value)}return corpus}function resolveSemanticCorpusInputCharacterLimit(providerName){return providerName?.trim().toLowerCase()==="ollama"?OLLAMA_SEMANTIC_CORPUS_INPUT_MAX_CHARACTERS:DEFAULT_SEMANTIC_CORPUS_INPUT_MAX_CHARACTERS}function resolveSemanticCorpusCharacterLimit(providerName,configuredMaxCharacters){const providerDefaultLimit=resolveSemanticCorpusInputCharacterLimit(providerName),parsed=coercePositiveInteger(configuredMaxCharacters);return parsed!==null?{maxCharacters:parsed,warning:null}:{maxCharacters:providerDefaultLimit,warning:configuredMaxCharacters==null?null:SEARCH_EMBEDDING_CORPUS_MAX_CHARACTERS_INVALID_WARNING}}function buildSemanticCorpusInput(document,options={}){const serialized=JSON.stringify(buildSearchCorpus(document,{fields:options.fields})),maxCharacters=resolveSemanticCorpusCharacterLimit(options.providerName,options.maxCharacters).maxCharacters;if(serialized.length<=maxCharacters)return serialized;if(maxCharacters<=SEMANTIC_CORPUS_TRUNCATION_SUFFIX.length)return SEMANTIC_CORPUS_TRUNCATION_SUFFIX.slice(0,maxCharacters);const keepLength=Math.max(0,maxCharacters-SEMANTIC_CORPUS_TRUNCATION_SUFFIX.length);return`${serialized.slice(0,keepLength)}${SEMANTIC_CORPUS_TRUNCATION_SUFFIX}`}export{DEFAULT_SEARCH_CORPUS_FIELDS,DEFAULT_SEMANTIC_CORPUS_INPUT_MAX_CHARACTERS,OLLAMA_SEMANTIC_CORPUS_INPUT_MAX_CHARACTERS,SEARCH_EMBEDDING_CORPUS_MAX_CHARACTERS_INVALID_WARNING,SEMANTIC_CORPUS_TRUNCATION_SUFFIX,buildEventCorpus,buildPlanCorpus,buildPlanFlatCorpus,buildReminderCorpus,buildSearchCorpus,buildSemanticCorpusInput,resolveSearchCorpusFields,resolveSemanticCorpusCharacterLimit,resolveSemanticCorpusInputCharacterLimit};
|
|
2
2
|
//# sourceMappingURL=corpus.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="67bae1a1-19d1-50ea-816f-4b68e6bb69d9")}catch{}})();import{executeEmbeddingRequest}from"./providers.js";import{SearchHttpError}from"./http-client.js";import{toErrorMessage}from"../shared/primitives.js";import{SEMANTIC_CORPUS_TRUNCATION_SUFFIX,resolveSemanticCorpusCharacterLimit}from"./corpus.js";function resolveBatchRuntime(settings,maxInputCharacters,maxRequestBytes){const batchSizeCandidate=settings.search.embedding_batch_size,timeoutMsCandidate=settings.search.embedding_timeout_ms,maxRetriesCandidate=settings.search.scanner_max_batch_retries,batchSize=Number.isFinite(batchSizeCandidate)&&batchSizeCandidate>0?Math.max(1,Math.floor(batchSizeCandidate)):1,timeoutMs=Number.isFinite(timeoutMsCandidate)&&timeoutMsCandidate>0?Math.max(1,Math.floor(timeoutMsCandidate)):3e4,maxRetries=Number.isFinite(maxRetriesCandidate)&&maxRetriesCandidate>=0?Math.floor(maxRetriesCandidate):0;return{batchSize,timeoutMs,maxRetries,maxRequestBytes,maxInputCharacters}}function createBatches(provider,inputs,batchSize,maxRequestBytes){const batches=[];let currentBatch=[];const envelopeBytes=Buffer.byteLength(JSON.stringify({model:provider.model,input:[]}));let currentBytes=envelopeBytes;for(const input of inputs){const inputBytes=Buffer.byteLength(JSON.stringify(input.trim()));if(envelopeBytes+inputBytes>maxRequestBytes)throw new RangeError(`Embedding input exceeds request byte ceiling ${maxRequestBytes}; lower search.embedding_corpus_max_characters or raise maxRequestBytes`);const separatorBytes=currentBatch.length>0?1:0;(currentBatch.length>=batchSize||currentBytes+separatorBytes+inputBytes>maxRequestBytes)&&(batches.push(currentBatch),currentBatch=[],currentBytes=envelopeBytes),currentBytes+=inputBytes+(currentBatch.length>0?1:0),currentBatch.push(input)}return batches.push(currentBatch),batches}function truncateInputForRuntime(input,maxInputCharacters){if(!Number.isFinite(maxInputCharacters)||maxInputCharacters<=0||input.length<=maxInputCharacters)return input;const keepLength=Math.max(0,maxInputCharacters-SEMANTIC_CORPUS_TRUNCATION_SUFFIX.length);return`${input.slice(0,keepLength)}${SEMANTIC_CORPUS_TRUNCATION_SUFFIX}`.slice(0,maxInputCharacters)}function isEmbeddingTimeoutError(error){const message=toErrorMessage(error).toLowerCase();return message.includes("timed out")||message.includes("timeout")}function buildEmbeddingFailureMessage(provider,batchLabel,batchSize,timeoutMs,attempts,error){const base=`Embedding batch ${batchLabel} failed after ${attempts} attempt(s): ${toErrorMessage(error)}`,details=`provider=${provider.name} model=${provider.model} batch_size=${batchSize} timeout_ms=${timeoutMs}`;return isEmbeddingTimeoutError(error)?`${base} (${details}; guidance=check provider availability or lower search.embedding_batch_size, raise search.embedding_timeout_ms, or run keyword search while semantic indexing catches up)`:`${base} (${details})`}function resolveSplitReason(error){return error instanceof SearchHttpError?error.status===413?"payload_too_large":null:isEmbeddingTimeoutError(error)?"timeout":null}async function executeBatchWithAdaptiveSplit(provider,batch,batchLabel,timeoutMs,maxRetries,warnings,receipt){let lastError=null;for(let attempt=0;attempt<=maxRetries;attempt+=1)try{receipt.requests+=1;const batchVectors=await executeEmbeddingRequest(provider,batch,{timeout_ms:timeoutMs});return attempt>0&&warnings.push(`search_embedding_batch_retry_succeeded:batch=${batchLabel}:attempt=${attempt+1}:size=${batch.length}`),receipt.successful_batches+=1,receipt.batch_size_histogram[batch.length]=(receipt.batch_size_histogram[batch.length]??0)+1,batchVectors}catch(error){lastError=error;const splitReason=resolveSplitReason(error);if(splitReason!==null&&batch.length>1){receipt.split_batches+=1;const midpoint=Math.ceil(batch.length/2),left=batch.slice(0,midpoint),right=batch.slice(midpoint);return warnings.push(`search_embedding_batch_split_after_${splitReason}:batch=${batchLabel}:size=${batch.length}:parts=${left.length}|${right.length}`),[...await executeBatchWithAdaptiveSplit(provider,left,`${batchLabel}.1`,timeoutMs,maxRetries,warnings,receipt),...await executeBatchWithAdaptiveSplit(provider,right,`${batchLabel}.2`,timeoutMs,maxRetries,warnings,receipt)]}if(attempt<maxRetries){receipt.retries+=1;const delayMs=Math.min(1e3*2**attempt,8e3);await new Promise(resolve=>setTimeout(resolve,delayMs))}}throw new Error(buildEmbeddingFailureMessage(provider,batchLabel,batch.length,timeoutMs,maxRetries+1,lastError))}async function executeEmbeddingBatchesWithRetry(provider,settings,inputs,options={}){if(inputs.length===0)return{vectors:[],warnings:[]};const startedAt=performance.now(),maxRequestBytes=options.maxRequestBytes??262144;if(!Number.isSafeInteger(maxRequestBytes)||maxRequestBytes<=0)throw new RangeError("maxRequestBytes must be a positive safe integer");const receipt={provider:provider.name,model:provider.model,max_request_bytes:maxRequestBytes,limit_source:options.maxRequestBytes===void 0?"default":"caller",planned_batches:0,requests:0,successful_batches:0,split_batches:0,retries:0,batch_size_histogram:{},elapsed_ms:0,inputs_per_second:0},warnings=[],corpusLimitResolution=resolveSemanticCorpusCharacterLimit(provider.name,settings.search.embedding_corpus_max_characters);corpusLimitResolution.warning&&warnings.push(corpusLimitResolution.warning);const runtime=resolveBatchRuntime(settings,corpusLimitResolution.maxCharacters,maxRequestBytes);let truncatedInputCount=0;const normalizedInputs=inputs.map(input=>{if(input.trim().length===0)throw new TypeError("Embedding inputs must be non-empty strings");const normalized=truncateInputForRuntime(input,runtime.maxInputCharacters);return normalized.length<input.length&&(truncatedInputCount+=1),normalized});truncatedInputCount>0&&warnings.push(`search_embedding_input_truncated:count=${truncatedInputCount}:max_characters=${runtime.maxInputCharacters}`);const batches=createBatches(provider,normalizedInputs,runtime.batchSize,runtime.maxRequestBytes);receipt.planned_batches=batches.length;const vectors=[];let completedInputs=0;for(let batchIndex=0;batchIndex<batches.length;batchIndex+=1){const batch=batches[batchIndex];options.onProgress?.({batch_index:batchIndex+1,batch_total:batches.length,batch_size:batch.length,completed_inputs:completedInputs,total_inputs:normalizedInputs.length,phase:"start"}),vectors.push(...await executeBatchWithAdaptiveSplit(provider,batch,String(batchIndex+1),runtime.timeoutMs,runtime.maxRetries,warnings,receipt)),completedInputs+=batch.length,options.onProgress?.({batch_index:batchIndex+1,batch_total:batches.length,batch_size:batch.length,completed_inputs:completedInputs,total_inputs:normalizedInputs.length,phase:"complete"})}return receipt.elapsed_ms=Math.max(1,performance.now()-startedAt),receipt.inputs_per_second=inputs.length*1e3/receipt.elapsed_ms,{vectors,warnings,receipt}}export{executeEmbeddingBatchesWithRetry};
|
|
2
2
|
//# sourceMappingURL=embedding-batches.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f303192a-cac2-588b-b988-e3a8132f4199")}catch{}})();const EVAL_METRIC_NAMES=["ndcg","mrr","precision","recall"];function parseEvalMetricFloors(value){if(typeof value!="object"||value===null||Array.isArray(value))throw new TypeError("Eval minimum must be an object of metric floors");const result={};for(const[key,floor]of Object.entries(value)){if(!EVAL_METRIC_NAMES.some(metric=>metric===key))throw new TypeError(`Unknown eval minimum metric: ${key}`);if(typeof floor!="number"||!Number.isFinite(floor)||floor<0||floor>1)throw new TypeError(`Eval minimum.${key} must be a finite number in [0, 1]`);result[key]=floor}return result}function evaluateMetricFloors(metrics,floors){const validated=parseEvalMetricFloors(floors),violations=[];for(const metric of EVAL_METRIC_NAMES){const minimum=validated[metric];if(minimum===void 0)continue;const actual=metrics[metric];!Number.isFinite(actual)||actual<0||actual>1?violations.push(`${metric}:invalid`):actual<minimum&&violations.push(`${metric}:${actual}<${minimum}`)}return violations}export{EVAL_METRIC_NAMES,evaluateMetricFloors,parseEvalMetricFloors};
|
|
2
2
|
//# sourceMappingURL=eval-thresholds.js.map
|
package/dist/core/search/eval.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c34cc860-67c7-548b-99ff-f4155ef44bb0")}catch{}})();import{parseEvalMetricFloors}from"./eval-thresholds.js";const DEFAULT_EVAL_K=10,EVAL_QUERY_SET_SCHEMA_ID="https://schema.unbrained.dev/pm/eval-query-set/v1",EVAL_QUERY_SET_CONTRACT={schema:EVAL_QUERY_SET_SCHEMA_ID,accepted_top_level:["array","object"],required_query_fields:["query","relevant_ids"],optional_fields:["mode","description","minimum"],modes:["keyword","semantic","hybrid"]},EVAL_QUERY_SET_EXAMPLE={schema:EVAL_QUERY_SET_SCHEMA_ID,queries:[{query:"offline search",relevant_ids:["pm-75k9"],mode:"keyword"}]};class EvalQuerySetError extends Error{constructor(message){super(message),this.name="EvalQuerySetError"}}const VALID_EVAL_MODES=new Set(["keyword","semantic","hybrid"]);function dcgAtK(relevanceGains,k){let dcg=0;const limit=Math.min(k,relevanceGains.length);for(let index=0;index<limit;index+=1)dcg+=relevanceGains[index]/Math.log2(index+2);return dcg}function ndcgAtK(rankedIds,relevantIds,k){if(relevantIds.size===0)return 0;const gains=rankedIds.map(id=>relevantIds.has(id)?1:0),dcg=dcgAtK(gains,k),idealGains=Array.from({length:relevantIds.size},()=>1),idealDcg=dcgAtK(idealGains,k);return idealDcg===0?0:dcg/idealDcg}function reciprocalRankAtK(rankedIds,relevantIds,k){const limit=Math.min(k,rankedIds.length);for(let index=0;index<limit;index+=1)if(relevantIds.has(rankedIds[index]))return 1/(index+1);return 0}function countRelevantInTopK(rankedIds,relevantIds,k){const limit=Math.min(k,rankedIds.length);let hits=0;for(let index=0;index<limit;index+=1)relevantIds.has(rankedIds[index])&&(hits+=1);return hits}function precisionAtK(rankedIds,relevantIds,k){return k<=0?0:countRelevantInTopK(rankedIds,relevantIds,k)/k}function recallAtK(rankedIds,relevantIds,k){return relevantIds.size===0?0:countRelevantInTopK(rankedIds,relevantIds,k)/relevantIds.size}function evaluateRanking(rankedIds,relevantIds,k){return{ndcg:ndcgAtK(rankedIds,relevantIds,k),mrr:reciprocalRankAtK(rankedIds,relevantIds,k),precision:precisionAtK(rankedIds,relevantIds,k),recall:recallAtK(rankedIds,relevantIds,k),relevant_total:relevantIds.size,retrieved_relevant:countRelevantInTopK(rankedIds,relevantIds,k)}}function aggregateEvalMetrics(perQuery){const queryCount=perQuery.length;if(queryCount===0)return{ndcg:0,mrr:0,precision:0,recall:0,query_count:0};const sum=perQuery.reduce((accumulator,metrics)=>({ndcg:accumulator.ndcg+metrics.ndcg,mrr:accumulator.mrr+metrics.mrr,precision:accumulator.precision+metrics.precision,recall:accumulator.recall+metrics.recall}),{ndcg:0,mrr:0,precision:0,recall:0});return{ndcg:sum.ndcg/queryCount,mrr:sum.mrr/queryCount,precision:sum.precision/queryCount,recall:sum.recall/queryCount,query_count:queryCount}}function parseEvalQueryEntry(raw,index){if(typeof raw!="object"||raw===null)throw new EvalQuerySetError(`Eval query at index ${index} must be an object`);const entry=raw,query=typeof entry.query=="string"?entry.query.trim():"";if(query.length===0)throw new EvalQuerySetError(`Eval query at index ${index} must have a non-empty "query" string`);if(!Array.isArray(entry.relevant_ids))throw new EvalQuerySetError(`Eval query at index ${index} must have a "relevant_ids" array`);if(entry.relevant_ids.some(value=>typeof value!="string"))throw new EvalQuerySetError(`Eval query at index ${index} must have a "relevant_ids" array of strings`);const relevantIds=[...new Set(entry.relevant_ids.map(value=>value.trim()).filter(value=>value.length>0))];if(relevantIds.length===0)throw new EvalQuerySetError(`Eval query at index ${index} must list at least one relevant id`);if(entry.mode!==void 0&&(typeof entry.mode!="string"||!VALID_EVAL_MODES.has(entry.mode)))throw new EvalQuerySetError(`Eval query at index ${index} has an invalid mode (expected keyword|semantic|hybrid)`);return{query,relevant_ids:relevantIds,...entry.minimum===void 0?{}:{minimum:parseEvalMetricFloors(entry.minimum)},...entry.mode!==void 0?{mode:entry.mode}:{},...typeof entry.description=="string"&&entry.description.trim().length>0?{description:entry.description.trim()}:{}}}function parseEvalQuerySet(raw){const rawSchema=typeof raw=="object"&&raw!==null&&!Array.isArray(raw)?raw.schema:void 0;if(rawSchema!==void 0&&rawSchema!==EVAL_QUERY_SET_SCHEMA_ID)throw new EvalQuerySetError(`Unsupported eval query set schema; expected "${EVAL_QUERY_SET_SCHEMA_ID}"`);const rawQueries=Array.isArray(raw)?raw:typeof raw=="object"&&raw!==null?raw.queries:void 0;if(!Array.isArray(rawQueries))throw new EvalQuerySetError('Eval query set must be an array of queries or an object with a "queries" array');if(rawQueries.length===0)throw new EvalQuerySetError("Eval query set must contain at least one query");return{schema:EVAL_QUERY_SET_SCHEMA_ID,queries:rawQueries.map((entry,index)=>parseEvalQueryEntry(entry,index))}}export{DEFAULT_EVAL_K,EVAL_QUERY_SET_CONTRACT,EVAL_QUERY_SET_EXAMPLE,EVAL_QUERY_SET_SCHEMA_ID,EvalQuerySetError,aggregateEvalMetrics,dcgAtK,evaluateRanking,ndcgAtK,parseEvalQuerySet,precisionAtK,recallAtK,reciprocalRankAtK};
|
|
2
2
|
//# sourceMappingURL=eval.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9b58b44d-819c-5115-b011-f9dfa8e2ab41")}catch{}})();import{toErrorMessage}from"../shared/primitives.js";const DEFAULT_SEARCH_HTTP_TIMEOUT_MS=3e4;class SearchHttpError extends Error{status;constructor(message,status){super(message),this.name="SearchHttpError",this.status=status}}function normalizeSearchHttpTimeoutMs(timeoutMs,requestLabel,defaultTimeoutMs=DEFAULT_SEARCH_HTTP_TIMEOUT_MS){const resolved=timeoutMs??defaultTimeoutMs;if(!Number.isFinite(resolved)||resolved<=0)throw new Error(`${requestLabel} timeout must be a positive finite number`);return Math.floor(resolved)}function resolveSearchHttpFetcher(fetcher,requestLabel){if(fetcher)return fetcher;if(typeof globalThis.fetch=="function")return globalThis.fetch.bind(globalThis);throw new Error(`${requestLabel} execution requires a fetch implementation`)}async function readFailedSearchHttpResponseBody(response){try{return(await response.text()).replaceAll(/\s+/g," ").trim()}catch(error){return`(failed to read response body: ${toErrorMessage(error)})`}}async function executeSearchJsonRequest(options){const controller=new AbortController,timeoutHandle=setTimeout(()=>{controller.abort()},options.timeoutMs);try{let response;try{response=await options.fetcher(options.endpoint,{method:options.method,headers:options.headers,body:JSON.stringify(options.body),signal:controller.signal})}catch(error){throw error instanceof Error&&error.name==="AbortError"?new Error(`${options.requestLabel} timed out after ${options.timeoutMs}ms`):new Error(`${options.requestLabel} execution failed: ${toErrorMessage(error)}`)}if(!response.ok){const responseBody=await readFailedSearchHttpResponseBody(response),detail=responseBody.length>0?`: ${responseBody}`:"";throw new SearchHttpError(`${options.requestLabel} failed with status ${response.status} ${response.statusText}${detail}`,response.status)}try{return await response.json()}catch(error){throw new Error(`${options.responseLabel} JSON parse failed: ${toErrorMessage(error)}`)}}finally{clearTimeout(timeoutHandle)}}export{SearchHttpError,executeSearchJsonRequest,normalizeSearchHttpTimeoutMs,readFailedSearchHttpResponseBody,resolveSearchHttpFetcher};
|
|
2
2
|
//# sourceMappingURL=http-client.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8e3bb919-c8f9-50b5-8e41-b6719d17bd21")}catch{}})();import{executeSearchJsonRequest,normalizeSearchHttpTimeoutMs,resolveSearchHttpFetcher}from"./http-client.js";import{isFiniteNumberArray,toNonEmptyString,trimTrailingSlashes}from"../shared/primitives.js";function resolveProviderConfigSource(activeName,configured){const active=toNonEmptyString(activeName);if(!active)return"unconfigured";const configuredValue=toNonEmptyString(configured);return configuredValue&&configuredValue.toLowerCase()===active.toLowerCase()?"configured":"auto-detected"}function normalizeOpenAiEmbeddingsEndpoint(baseUrl){const normalizedBaseUrl=trimTrailingSlashes(baseUrl),normalizedLower=normalizedBaseUrl.toLowerCase();return normalizedLower.endsWith("/embeddings")?normalizedBaseUrl:normalizedLower.endsWith("/v1")?`${normalizedBaseUrl}/embeddings`:`${normalizedBaseUrl}/v1/embeddings`}function resolveSearchEmbeddingModelOverride(settings){const candidate=settings.search?.embedding_model;return toNonEmptyString(candidate)||null}function resolveOpenAiProvider(settings){const baseUrl=toNonEmptyString(settings.providers?.openai?.base_url),model=toNonEmptyString(settings.providers?.openai?.model);if(!baseUrl||!model)return null;const override=resolveSearchEmbeddingModelOverride(settings),apiKey=toNonEmptyString(settings.providers?.openai?.api_key);return{name:"openai",base_url:baseUrl,model:override??model,...apiKey?{api_key:apiKey}:{}}}function resolveOllamaProvider(settings){const baseUrl=toNonEmptyString(settings.providers?.ollama?.base_url),model=toNonEmptyString(settings.providers?.ollama?.model);if(!baseUrl||!model)return null;const override=resolveSearchEmbeddingModelOverride(settings);return{name:"ollama",base_url:baseUrl,model:override??model}}function normalizeEmbeddingInputs(input){const inputs=(Array.isArray(input)?input:[input]).map(entry=>entry.trim()).filter(entry=>entry.length>0);if(inputs.length===0)throw new Error("Embedding input must include at least one non-empty string");return inputs}function dedupeEmbeddingInputs(inputs){const uniqueInputs=[],originalToUniqueIndex=[],uniqueIndexByInput=new Map;for(const entry of inputs){const existingUniqueIndex=uniqueIndexByInput.get(entry);if(existingUniqueIndex===void 0){const nextUniqueIndex=uniqueInputs.length;uniqueInputs.push(entry),uniqueIndexByInput.set(entry,nextUniqueIndex),originalToUniqueIndex.push(nextUniqueIndex);continue}originalToUniqueIndex.push(existingUniqueIndex)}return{uniqueInputs,originalToUniqueIndex}}function buildOrderedOpenAiEntries(data){const openAiEntries=data.map((entry,position)=>({embedding:entry.embedding,index:entry.index,position}));if(openAiEntries.some(entry=>entry.index!==void 0)){for(const entry of openAiEntries)if(!Number.isInteger(entry.index))throw new TypeError(`OpenAI embedding response entry at position ${entry.position} is missing a valid integer index`);return[...openAiEntries].sort((a,b)=>{const byIndex=a.index-b.index;return byIndex!==0?byIndex:a.position-b.position})}return openAiEntries}function resolveEmbeddingProviders(settings){const openAi=resolveOpenAiProvider(settings),ollama=resolveOllamaProvider(settings),available=[openAi,ollama].filter(entry=>entry!==null),preferredName=toNonEmptyString(settings.search?.provider),preferredKey=preferredName?preferredName.toLowerCase():null;return{active:(preferredKey?available.find(entry=>entry.name===preferredKey):void 0)??available[0]??null,available}}function resolveEmbeddingRequestTarget(provider){const baseUrl=trimTrailingSlashes(provider.base_url);return provider.name==="openai"?{provider:"openai",endpoint:normalizeOpenAiEmbeddingsEndpoint(baseUrl),model:provider.model}:{provider:"ollama",endpoint:`${baseUrl}/api/embed`,model:provider.model}}function buildEmbeddingRequestPlan(provider,input){const normalizedInputs=normalizeEmbeddingInputs(input);return provider.name==="openai"?{target:resolveEmbeddingRequestTarget(provider),method:"POST",headers:{"content-type":"application/json",...provider.api_key?{authorization:`Bearer ${provider.api_key}`}:{}},body:{model:provider.model,input:normalizedInputs.length===1?normalizedInputs[0]:normalizedInputs}}:{target:resolveEmbeddingRequestTarget(provider),method:"POST",headers:{"content-type":"application/json"},body:{model:provider.model,input:normalizedInputs}}}function normalizeEmbeddingResponse(provider,response){if(provider.name==="openai"){const data=response.data;if(!Array.isArray(data)||data.length===0)throw new Error("OpenAI embedding response must include a non-empty data array");return buildOrderedOpenAiEntries(data).map((entry,index)=>{const embedding=entry.embedding;if(!isFiniteNumberArray(embedding))throw new Error(`OpenAI embedding response entry at index ${index} is missing a numeric embedding vector`);return[...embedding]})}const singleEmbedding=response.embedding;if(isFiniteNumberArray(singleEmbedding))return[[...singleEmbedding]];const multipleEmbeddings=response.embeddings;if(Array.isArray(multipleEmbeddings)&&multipleEmbeddings.length>0)return multipleEmbeddings.map((entry,index)=>{if(!isFiniteNumberArray(entry))throw new Error(`Ollama embedding response entry at index ${index} is missing a numeric embedding vector`);return[...entry]});throw new Error("Ollama embedding response must include embedding or embeddings vectors")}async function executeEmbeddingRequest(provider,input,options={}){const timeoutMs=normalizeSearchHttpTimeoutMs(options.timeout_ms,"Embedding request"),fetcher=resolveSearchHttpFetcher(options.fetcher,"Embedding request"),normalizedInputs=normalizeEmbeddingInputs(input),dedupedInputs=dedupeEmbeddingInputs(normalizedInputs),requestPlan=buildEmbeddingRequestPlan(provider,dedupedInputs.uniqueInputs),payload=await executeSearchJsonRequest({endpoint:requestPlan.target.endpoint,method:requestPlan.method,headers:requestPlan.headers,body:requestPlan.body,timeoutMs,fetcher,requestLabel:"Embedding request",responseLabel:"Embedding response"}),vectors=normalizeEmbeddingResponse(provider,payload);if(vectors.length!==dedupedInputs.uniqueInputs.length)throw new Error(`Embedding response cardinality mismatch: expected ${dedupedInputs.uniqueInputs.length} vector(s), received ${vectors.length}`);return dedupedInputs.originalToUniqueIndex.map(uniqueIndex=>[...vectors[uniqueIndex]])}export{buildEmbeddingRequestPlan,executeEmbeddingRequest,normalizeEmbeddingResponse,resolveEmbeddingProviders,resolveEmbeddingRequestTarget,resolveProviderConfigSource};
|
|
2
2
|
//# sourceMappingURL=providers.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b75c3c5e-e2b7-5e65-a56a-883dc896290e")}catch{}})();import{coercePositiveInteger,toNonEmptyString}from"../shared/primitives.js";import{tokenizeAlphaNumeric}from"../shared/text-normalization.js";import{executeEmbeddingRequest}from"./providers.js";const DEFAULT_QUERY_EXPANSION_MAX_QUERIES=4,DEFAULT_RERANK_TOP_K=20,MAX_RERANK_TOP_K=200,QUERY_EXPANSION_STOP_WORDS=new Set(["a","an","and","for","from","in","into","of","on","or","the","to","with"]);function dedupeQueries(values,limit){const deduped=[],seen=new Set;for(const entry of values){const normalized=entry.trim().replaceAll(/\s+/g," ");if(normalized.length===0)continue;const dedupeKey=normalized.toLowerCase();if(!seen.has(dedupeKey)&&(seen.add(dedupeKey),deduped.push(normalized),deduped.length>=limit))break}return deduped}function singularizeSimple(token){const normalizedToken=token.toLowerCase();return normalizedToken.length>4&&normalizedToken.endsWith("ies")?`${normalizedToken.slice(0,-3)}y`:normalizedToken.length>4&&(normalizedToken.endsWith("ches")||normalizedToken.endsWith("shes")||normalizedToken.endsWith("xes")||normalizedToken.endsWith("zes")||normalizedToken.endsWith("sses"))?normalizedToken.slice(0,-2):normalizedToken.length>3&&normalizedToken.endsWith("s")&&!normalizedToken.endsWith("ss")&&!normalizedToken.endsWith("us")&&!normalizedToken.endsWith("is")&&!normalizedToken.endsWith("as")?normalizedToken.slice(0,-1):normalizedToken}function pluralizeSimple(token){const normalizedToken=token.toLowerCase();return normalizedToken.length>2&&(!normalizedToken.endsWith("s")||normalizedToken.endsWith("ss"))?normalizedToken.endsWith("y")&&!/[aeiou]y$/u.test(normalizedToken)?`${normalizedToken.slice(0,-1)}ies`:normalizedToken.endsWith("ch")||normalizedToken.endsWith("sh")||normalizedToken.endsWith("x")||normalizedToken.endsWith("z")||normalizedToken.endsWith("ss")?`${normalizedToken}es`:`${normalizedToken}s`:normalizedToken}function buildDeterministicQueryExpansions(query,maxQueries=DEFAULT_QUERY_EXPANSION_MAX_QUERIES){const normalizedQuery=query.trim().replaceAll(/\s+/g," ");if(normalizedQuery.length===0)return[];const tokens=tokenizeAlphaNumeric(normalizedQuery);if(tokens.length===0)return[normalizedQuery];const contentTokens=tokens.filter(token=>!QUERY_EXPANSION_STOP_WORDS.has(token.toLowerCase())),singularized=tokens.map(token=>singularizeSimple(token)),pluralized=contentTokens.map(token=>pluralizeSimple(token));return dedupeQueries([normalizedQuery,tokens.join(" "),contentTokens.join(" "),singularized.join(" "),pluralized.join(" ")],Math.max(1,maxQueries))}function normalizeQueryExpansionOutput(raw){const rawQueries=Array.isArray(raw)?raw:raw?.queries;return Array.isArray(rawQueries)?dedupeQueries(rawQueries.filter(entry=>typeof entry=="string"),DEFAULT_QUERY_EXPANSION_MAX_QUERIES):[]}function mergeQueryExpansions(base,extra,maxQueries){return dedupeQueries([...base,...extra],Math.max(1,maxQueries))}function resolveQueryExpansionConfig(settings,fallbackProviderName){const queryExpansion=settings.search?.query_expansion,configuredProvider=toNonEmptyString(queryExpansion?.provider);return{enabled:queryExpansion?.enabled===!0,provider:configuredProvider??fallbackProviderName,max_queries:DEFAULT_QUERY_EXPANSION_MAX_QUERIES}}function resolveRerankConfig(settings,fallbackModel){const rerank=settings.search?.rerank,configuredModel=toNonEmptyString(rerank?.model),normalizedTopK=coercePositiveInteger(rerank?.top_k)??DEFAULT_RERANK_TOP_K;return{enabled:rerank?.enabled===!0,model:configuredModel??fallbackModel,top_k:Math.min(MAX_RERANK_TOP_K,normalizedTopK)}}function normalizeRerankOutput(raw){const rawHits=Array.isArray(raw)?raw:raw?.hits;if(!Array.isArray(rawHits))return[];const bestById=new Map;for(const entry of rawHits){if(typeof entry!="object"||entry===null)continue;const id=toNonEmptyString(entry.id),score=entry.score;if(!id||typeof score!="number"||!Number.isFinite(score))continue;const existing=bestById.get(id);(existing===void 0||score>existing)&&bestById.set(id,score)}const normalized=[...bestById.entries()].map(([id,score])=>({id,score}));return normalized.sort((left,right)=>left.score!==right.score?right.score-left.score:left.id.localeCompare(right.id)),normalized}function dotProduct(left,right){const size=left.length;let result=0;for(let index=0;index<size;index+=1)result+=left[index]*right[index];return result}function l2Norm(vector){let sumSquares=0;for(let index=0;index<vector.length;index+=1)sumSquares+=vector[index]*vector[index];return Math.sqrt(sumSquares)}function cosineSimilarityWithKnownLeftNorm(left,right,leftNorm){if(!left||!right||left.length===0||right.length===0||left.length!==right.length)return 0;const numerator=dotProduct(left,right),rightNorm=l2Norm(right),denominator=leftNorm*rightNorm;return!Number.isFinite(numerator)||!Number.isFinite(leftNorm)||!Number.isFinite(rightNorm)||!Number.isFinite(denominator)||denominator===0?0:Math.max(-1,Math.min(1,numerator/denominator))}async function rerankCandidatesWithEmbeddings(provider,model,query,candidates,timeoutMs){if(candidates.length===0)return new Map;const effectiveModel=toNonEmptyString(model)??provider.model,rerankProvider=effectiveModel===provider.model?provider:{...provider,model:effectiveModel},payload=[query.trim(),...candidates.map(entry=>entry.text)],vectors=await executeEmbeddingRequest(rerankProvider,payload,timeoutMs?{timeout_ms:timeoutMs}:{}),queryVector=vectors[0];if(!queryVector)return new Map;const queryNorm=l2Norm(queryVector),scoreById=new Map;for(let index=0;index<candidates.length;index+=1){const candidate=candidates[index],candidateVector=vectors[index+1];if(!candidateVector)continue;const similarity=cosineSimilarityWithKnownLeftNorm(queryVector,candidateVector,queryNorm);scoreById.set(candidate.id,Math.max(0,Math.min(1,(similarity+1)/2)))}return scoreById}export{DEFAULT_QUERY_EXPANSION_MAX_QUERIES,DEFAULT_RERANK_TOP_K,buildDeterministicQueryExpansions,mergeQueryExpansions,normalizeQueryExpansionOutput,normalizeRerankOutput,rerankCandidatesWithEmbeddings,resolveQueryExpansionConfig,resolveRerankConfig};
|
|
2
2
|
//# sourceMappingURL=relevance.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7889f11f-36f9-5384-8429-58d951c342da")}catch{}})();import{spawnSync}from"node:child_process";import{toNonEmptyString}from"../shared/primitives.js";const DISABLE_AUTO_DEFAULTS_ENV="PM_DISABLE_OLLAMA_AUTO_DEFAULTS",OLLAMA_MODEL_ENV="PM_OLLAMA_MODEL",DEFAULT_OLLAMA_BASE_URL="http://localhost:11434",RECOMMENDED_OLLAMA_EMBEDDING_MODEL="qwen3-embedding:0.6b",DEFAULT_LANCEDB_PATH=".agents/pm/search/lancedb/",OLLAMA_VERSION_TIMEOUT_MS=1500,OLLAMA_LIST_TIMEOUT_MS=2500,QWEN_EMBEDDING_MODEL_PATTERN=/qwen.*(?:embed|embedding)|(?:embed|embedding).*qwen/i,EMBEDDING_MODEL_PATTERN=/embed|embedding/i,toOptionalNonEmptyString=toNonEmptyString;function isAutoDefaultsDisabled(){const raw=toOptionalNonEmptyString(process.env[DISABLE_AUTO_DEFAULTS_ENV]);if(!raw)return!1;const normalized=raw.toLowerCase();return normalized==="1"||normalized==="true"||normalized==="yes"}function hasConfiguredValue(values){return values.some(entry=>toOptionalNonEmptyString(entry)!==null)}function hasCompetingProvider(provider){const normalized=toOptionalNonEmptyString(provider);return!!(normalized&&normalized.toLowerCase()!=="ollama")}function hasCompetingVectorAdapter(adapter){const normalized=toOptionalNonEmptyString(adapter);return!!(normalized&&normalized.toLowerCase()!=="lancedb")}function hasCompetingSemanticConfiguration(settings){return hasCompetingProvider(settings.search?.provider)||hasCompetingVectorAdapter(settings.vector_store?.adapter)||hasConfiguredValue([settings.providers?.openai?.base_url,settings.providers?.openai?.model,settings.providers?.openai?.api_key])?!0:hasConfiguredValue([settings.vector_store?.qdrant?.url,settings.vector_store?.qdrant?.api_key])}function isOllamaInstalled(){const result=spawnSync("ollama",["--version"],{encoding:"utf8",timeout:OLLAMA_VERSION_TIMEOUT_MS});return result.error?!1:result.status===0}function parseOllamaModelList(output){const lines=output.split(/\r?\n/).map(line=>line.trim()).filter(line=>line.length>0);if(lines.length===0)return null;const models=lines.map(line=>line.split(/\s+/)[0]?.trim()).filter(entry=>!!(entry&&entry.length>0)).filter(entry=>entry.toUpperCase()!=="NAME");return models.length===0?null:models.find(entry=>QWEN_EMBEDDING_MODEL_PATTERN.test(entry))||(models.find(entry=>EMBEDDING_MODEL_PATTERN.test(entry))??null)}function resolveAutoOllamaModel(settings){const settingsModel=toOptionalNonEmptyString(settings.providers?.ollama?.model);if(settingsModel)return settingsModel;const envModel=toOptionalNonEmptyString(process.env[OLLAMA_MODEL_ENV]);if(envModel)return envModel;const listed=spawnSync("ollama",["list"],{encoding:"utf8",timeout:OLLAMA_LIST_TIMEOUT_MS});if(!listed.error&&listed.status===0){const listedModel=parseOllamaModelList(typeof listed.stdout=="string"?listed.stdout:"");if(listedModel)return listedModel}return null}function resolveSemanticDefaultNeeds(settings){return{baseUrl:toOptionalNonEmptyString(settings.providers?.ollama?.base_url)===null,model:toOptionalNonEmptyString(settings.providers?.ollama?.model)===null,lancedbPath:toOptionalNonEmptyString(settings.vector_store?.lancedb?.path)===null,embeddingModel:toOptionalNonEmptyString(settings.search?.embedding_model)===null}}function needsAnySemanticDefault(needs){return needs.baseUrl||needs.model||needs.lancedbPath||needs.embeddingModel}function applyOllamaProviderDefaults(settings,needs,resolvedModel){if(!needs.baseUrl&&!needs.model)return;const providers=settings.providers??={},ollama=providers.ollama??={};needs.baseUrl&&(ollama.base_url=DEFAULT_OLLAMA_BASE_URL),needs.model&&(ollama.model=resolvedModel)}function applyVectorStoreDefaults(settings,needs){if(!needs.lancedbPath)return;const vectorStore=settings.vector_store??={},lancedb=vectorStore.lancedb??={};lancedb.path=DEFAULT_LANCEDB_PATH}function applySearchEmbeddingDefaults(settings,needs,resolvedModel){if(!needs.embeddingModel)return;const search=settings.search??={};search.embedding_model=resolvedModel}function resolveSettingsWithSemanticRuntimeDefaults(settings){const unchanged={settings,auto_ollama_defaults_applied:!1};if(isAutoDefaultsDisabled()||hasCompetingSemanticConfiguration(settings))return unchanged;const needs=resolveSemanticDefaultNeeds(settings);if(!needsAnySemanticDefault(needs)||needs.model&&!isOllamaInstalled())return unchanged;const nextSettings=structuredClone(settings),resolvedModel=resolveAutoOllamaModel(nextSettings);return resolvedModel?(applyOllamaProviderDefaults(nextSettings,needs,resolvedModel),applyVectorStoreDefaults(nextSettings,needs),applySearchEmbeddingDefaults(nextSettings,needs,resolvedModel),{settings:nextSettings,auto_ollama_defaults_applied:!0}):{...unchanged,auto_ollama_defaults_skipped_reason:"no_installed_embedding_model",auto_ollama_defaults_remediation:`Run ollama pull ${RECOMMENDED_OLLAMA_EMBEDDING_MODEL} or configure providers.ollama.model explicitly (and search.embedding_model if you need an override).`}}export{resolveSettingsWithSemanticRuntimeDefaults};
|
|
2
2
|
//# sourceMappingURL=semantic-defaults.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f091d0c3-f2a7-5d76-8656-4aebe82e9798")}catch{}})();function collectStaleVectorizationIds(items,ledgerEntries){const entries=ledgerEntries??{};return items.filter(item=>entries[item.id]!==item.updated_at).map(item=>item.id).sort((left,right)=>left.localeCompare(right))}export{collectStaleVectorizationIds};
|
|
2
2
|
//# sourceMappingURL=staleness.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
!(function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="887ac66e-679f-5a07-a6a2-8a19a4007198")}catch(e2){}})();import{mkdir,readFile,stat,unlink}from"node:fs/promises";import{basename,dirname,isAbsolute,join,resolve}from"node:path";import{executeSearchJsonRequest,normalizeSearchHttpTimeoutMs,resolveSearchHttpFetcher}from"./http-client.js";import{isFiniteNumberArray,toErrorMessage,toNonEmptyString,trimTrailingSlashes}from"../shared/primitives.js";import{isFileMissingError,writeFileAtomic}from"../fs/fs-utils.js";const DEFAULT_COLLECTION="pm_items";const COLLECTION_SANITIZE_PATTERN=/[^a-zA-Z0-9_-]/g;const MAX_COLLECTION_NAME_LENGTH=128;const LANCE_DB_LOCAL_SNAPSHOT_DIR=".pm-cli-local-vectors";const LANCE_DB_LOCAL_SNAPSHOT_VERSION=1;const lanceDbLocalTables=new Map;function resolveStoreCollectionName(store){const candidate=toNonEmptyString(store.collection_name)??DEFAULT_COLLECTION;return candidate.replaceAll(COLLECTION_SANITIZE_PATTERN,"_").slice(0,MAX_COLLECTION_NAME_LENGTH)}function normalizeVector(value){if(!isFiniteNumberArray(value)||value.length===0){throw new Error("Vector values must be a non-empty numeric array")}return[...value]}function normalizeLimit(value){if(!Number.isFinite(value)||value<=0){throw new Error("Vector query limit must be a positive number")}return Math.floor(value)}function normalizeQdrantQueryResponse(payload){const result=payload.result;if(!Array.isArray(result)){throw new TypeError("Qdrant query response must include a result array")}const hits=result.map((entry,index)=>{const idValue=entry.id;const idCandidate=typeof idValue==="number"?String(idValue):idValue;const id=toNonEmptyString(idCandidate);if(!id){throw new Error(`Qdrant query response entry at index ${index} is missing a non-empty id`)}const score=entry.score;if(typeof score!=="number"||!Number.isFinite(score)){throw new TypeError(`Qdrant query response entry at index ${index} is missing a finite numeric score`)}const payloadValue=entry.payload;if(payloadValue!==void 0&&(typeof payloadValue!=="object"||payloadValue===null||Array.isArray(payloadValue))){throw new Error(`Qdrant query response entry at index ${index} must provide payload as an object when set`)}return{id,score,...payloadValue?{payload:payloadValue}:{}}});hits.sort((left,right)=>{if(left.score!==right.score){return right.score-left.score}return left.id.localeCompare(right.id)});return hits}function normalizeQdrantUpsertResponse(payload){const nestedStatus=toNonEmptyString(payload.result?.status);if(nestedStatus){return{status:nestedStatus}}const topLevelStatus=toNonEmptyString(payload.status);if(topLevelStatus){return{status:topLevelStatus}}throw new Error("Qdrant upsert response must include status metadata")}async function executeRemoteVectorPlan(endpoint,plan,timeoutMs,fetcher,requestKind){return await executeSearchJsonRequest({endpoint,method:plan.method,headers:plan.headers,body:plan.body,timeoutMs,fetcher,requestLabel:`Vector ${requestKind} request`,responseLabel:`Vector ${requestKind} response`})}function resolveQdrantStore(settings){const url=toNonEmptyString(settings.vector_store?.qdrant?.url);if(!url){return null}const collectionName=toNonEmptyString(settings.vector_store?.collection_name);const apiKey=toNonEmptyString(settings.vector_store?.qdrant?.api_key);return{name:"qdrant",url,...collectionName&&collectionName!==DEFAULT_COLLECTION?{collection_name:collectionName}:{},...apiKey?{api_key:apiKey}:{}}}function resolveWorkspaceRootFromPmRoot(pmRoot){const resolved=resolve(pmRoot);const parent=dirname(resolved);if(basename(resolved)==="pm"&&basename(parent)===".agents"){return dirname(parent)}return resolved}function anchorLanceDbStorePath(storePath,pmRoot){if(!pmRoot||isAbsolute(storePath)){return storePath}return resolve(resolveWorkspaceRootFromPmRoot(pmRoot),storePath)}function resolveLanceDbStore(settings,pmRoot){const lancedbPath=toNonEmptyString(settings.vector_store?.lancedb?.path);if(!lancedbPath){return null}const collectionName=toNonEmptyString(settings.vector_store?.collection_name);return{name:"lancedb",path:anchorLanceDbStorePath(lancedbPath,pmRoot),...collectionName&&collectionName!==DEFAULT_COLLECTION?{collection_name:collectionName}:{}}}function normalizeVectorRecords(records){if(!Array.isArray(records)||records.length===0){throw new Error("Vector upsert records must include at least one entry")}return records.map((record,index)=>{const id=toNonEmptyString(record.id);if(!id){throw new Error(`Vector upsert record at index ${index} is missing a non-empty id`)}const vector=normalizeVector(record.vector);const payload=record.payload;if(payload!==void 0&&(typeof payload!=="object"||payload===null||Array.isArray(payload))){throw new Error(`Vector upsert record at index ${index} must provide payload as an object when set`)}return{id,vector,...payload?{payload}:{}}})}function normalizeVectorDeleteIds(ids){if(!Array.isArray(ids)||ids.length===0){throw new Error("Vector delete ids must include at least one entry")}const normalizedIds=ids.map((id,index)=>{const normalized=toNonEmptyString(id);if(!normalized){throw new Error(`Vector delete id at index ${index} is missing a non-empty value`)}return normalized}).sort((left,right)=>left.localeCompare(right));const uniqueIds=[];for(const id of normalizedIds){if(uniqueIds.at(-1)!==id){uniqueIds.push(id)}}return uniqueIds}function resolveQdrantDeleteTarget(upsertTarget){return upsertTarget.replace(/\/points\?wait=true$/,"/points/delete?wait=true")}function resolveQdrantCollectionTarget(upsertTarget){return upsertTarget.replace(/\/points\?wait=true$/,"")}function buildQdrantJsonHeaders(store){return{"content-type":"application/json",...store.api_key?{"api-key":store.api_key}:{}}}function getLanceDbLocalTableKey(storePath,table){return getLanceDbSnapshotPath(storePath,table)}function getLanceDbSnapshotPath(storePath,table){return join(resolve(storePath),LANCE_DB_LOCAL_SNAPSHOT_DIR,`${table}.json`)}function normalizeSnapshotRecord(entry,index,snapshotPath){const id=toNonEmptyString(entry.id);if(!id){throw new Error(`LanceDB local snapshot '${snapshotPath}' record at index ${index} is missing a non-empty id`)}const vector=normalizeVector(entry.vector);const payload=entry.payload;if(payload!==void 0&&(typeof payload!=="object"||payload===null||Array.isArray(payload))){throw new Error(`LanceDB local snapshot '${snapshotPath}' record '${id}' must provide payload as an object when set`)}return{id,vector,...payload?{payload}:{}}}function parseLanceDbSnapshot(snapshotPath,expectedTable,raw){let parsed;try{parsed=JSON.parse(raw)}catch(error){throw new Error(`LanceDB local snapshot at '${snapshotPath}' is not valid JSON: ${toErrorMessage(error)}`)}if(typeof parsed!=="object"||parsed===null||Array.isArray(parsed)){throw new Error(`LanceDB local snapshot at '${snapshotPath}' must be a JSON object`)}const version=parsed.version;if(version!==LANCE_DB_LOCAL_SNAPSHOT_VERSION){throw new Error(`LanceDB local snapshot at '${snapshotPath}' must include version=${LANCE_DB_LOCAL_SNAPSHOT_VERSION}`)}const table=toNonEmptyString(parsed.table);if(!table){throw new Error(`LanceDB local snapshot at '${snapshotPath}' must include a non-empty table value`)}if(table!==expectedTable){throw new Error(`LanceDB local snapshot at '${snapshotPath}' table mismatch: expected '${expectedTable}', received '${table}'`)}const recordsValue=parsed.records;if(!Array.isArray(recordsValue)){throw new TypeError(`LanceDB local snapshot at '${snapshotPath}' must include a records array`)}const tableRecords=new Map;for(let index=0;index<recordsValue.length;index+=1){const record=normalizeSnapshotRecord(recordsValue[index],index,snapshotPath);tableRecords.set(record.id,record)}return tableRecords}async function readLanceDbSnapshotStats(snapshotPath){try{const stats=await stat(snapshotPath);return{mtimeMs:stats.mtimeMs,size:stats.size}}catch(error){if(!isFileMissingError(error)){throw error}return null}}function resolveMissingLanceDbSnapshotCache(key,cached){if(!cached){return null}if(cached.mtimeMs===null&&cached.size===null&&cached.records.size===0){return cached.records}const loaded=new Map;lanceDbLocalTables.set(key,{records:loaded,mtimeMs:null,size:null});return loaded}function cachedLanceDbSnapshotMatches(cached,snapshotStats){return cached!==void 0&&snapshotStats!==null&&cached.mtimeMs===snapshotStats.mtimeMs&&cached.size===snapshotStats.size}async function loadLanceDbLocalTable(storePath,table){const key=getLanceDbLocalTableKey(storePath,table);const snapshotPath=getLanceDbSnapshotPath(storePath,table);const snapshotStats=await readLanceDbSnapshotStats(snapshotPath);const cached=lanceDbLocalTables.get(key);if(!snapshotStats){const resolved=resolveMissingLanceDbSnapshotCache(key,cached);if(resolved){return resolved}}if(cachedLanceDbSnapshotMatches(cached,snapshotStats)){return cached.records}let loaded=new Map;try{const raw=await readFile(snapshotPath,"utf8");loaded=parseLanceDbSnapshot(snapshotPath,table,raw)}catch(error){if(!isFileMissingError(error)){throw error}}lanceDbLocalTables.set(key,{records:loaded,mtimeMs:snapshotStats?.mtimeMs??null,size:snapshotStats?.size??null});return loaded}function buildSnapshotRecords(table){const records=[...table.values()];records.sort((left,right)=>left.id.localeCompare(right.id));return records.map(record=>({id:record.id,vector:[...record.vector],...record.payload?{payload:record.payload}:{}}))}async function removeSnapshotFile(snapshotPath){try{await unlink(snapshotPath)}catch(error){if(!isFileMissingError(error)){throw new Error(`LanceDB local snapshot delete failed at '${snapshotPath}': ${toErrorMessage(error)}`)}}}async function persistLanceDbLocalTable(storePath,tableName,table){const snapshotPath=getLanceDbSnapshotPath(storePath,tableName);if(table.size===0){await removeSnapshotFile(snapshotPath);return}const snapshotDir=dirname(snapshotPath);try{await mkdir(snapshotDir,{recursive:true})}catch(error){throw new Error(`LanceDB local snapshot directory create failed at '${snapshotDir}': ${toErrorMessage(error)}`)}const serialized=`${JSON.stringify({version:LANCE_DB_LOCAL_SNAPSHOT_VERSION,table:tableName,records:buildSnapshotRecords(table)})}
|
|
2
|
-
`;try{await writeFileAtomic(snapshotPath,serialized)}catch(error){throw new Error(`LanceDB local snapshot write failed at '${snapshotPath}': ${toErrorMessage(error)}`)}}async function resetLanceDbLocalTable(storePath,tableName){const key=getLanceDbLocalTableKey(storePath,tableName)
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b5f2e49a-fb72-554b-b0a8-dca0adee71f4")}catch{}})();import{mkdir,readFile,stat,unlink}from"node:fs/promises";import{basename,dirname,isAbsolute,join,resolve}from"node:path";import{executeSearchJsonRequest,normalizeSearchHttpTimeoutMs,resolveSearchHttpFetcher}from"./http-client.js";import{isFiniteNumberArray,toErrorMessage,toNonEmptyString,trimTrailingSlashes}from"../shared/primitives.js";import{isFileMissingError,writeFileAtomic}from"../fs/fs-utils.js";const DEFAULT_COLLECTION="pm_items",COLLECTION_SANITIZE_PATTERN=/[^a-zA-Z0-9_-]/g,MAX_COLLECTION_NAME_LENGTH=128,LANCE_DB_LOCAL_SNAPSHOT_DIR=".pm-cli-local-vectors",LANCE_DB_LOCAL_SNAPSHOT_VERSION=1,lanceDbLocalTables=new Map;function resolveStoreCollectionName(store){return(toNonEmptyString(store.collection_name)??DEFAULT_COLLECTION).replaceAll(COLLECTION_SANITIZE_PATTERN,"_").slice(0,MAX_COLLECTION_NAME_LENGTH)}function normalizeVector(value){if(!isFiniteNumberArray(value)||value.length===0)throw new Error("Vector values must be a non-empty numeric array");return[...value]}function normalizeLimit(value){if(!Number.isFinite(value)||value<=0)throw new Error("Vector query limit must be a positive number");return Math.floor(value)}function normalizeQdrantQueryResponse(payload){const result=payload.result;if(!Array.isArray(result))throw new TypeError("Qdrant query response must include a result array");const hits=result.map((entry,index)=>{const idValue=entry.id,idCandidate=typeof idValue=="number"?String(idValue):idValue,id=toNonEmptyString(idCandidate);if(!id)throw new Error(`Qdrant query response entry at index ${index} is missing a non-empty id`);const score=entry.score;if(typeof score!="number"||!Number.isFinite(score))throw new TypeError(`Qdrant query response entry at index ${index} is missing a finite numeric score`);const payloadValue=entry.payload;if(payloadValue!==void 0&&(typeof payloadValue!="object"||payloadValue===null||Array.isArray(payloadValue)))throw new Error(`Qdrant query response entry at index ${index} must provide payload as an object when set`);return{id,score,...payloadValue?{payload:payloadValue}:{}}});return hits.sort((left,right)=>left.score!==right.score?right.score-left.score:left.id.localeCompare(right.id)),hits}function normalizeQdrantUpsertResponse(payload){const nestedStatus=toNonEmptyString(payload.result?.status);if(nestedStatus)return{status:nestedStatus};const topLevelStatus=toNonEmptyString(payload.status);if(topLevelStatus)return{status:topLevelStatus};throw new Error("Qdrant upsert response must include status metadata")}async function executeRemoteVectorPlan(endpoint,plan,timeoutMs,fetcher,requestKind){return await executeSearchJsonRequest({endpoint,method:plan.method,headers:plan.headers,body:plan.body,timeoutMs,fetcher,requestLabel:`Vector ${requestKind} request`,responseLabel:`Vector ${requestKind} response`})}function resolveQdrantStore(settings){const url=toNonEmptyString(settings.vector_store?.qdrant?.url);if(!url)return null;const collectionName=toNonEmptyString(settings.vector_store?.collection_name),apiKey=toNonEmptyString(settings.vector_store?.qdrant?.api_key);return{name:"qdrant",url,...collectionName&&collectionName!==DEFAULT_COLLECTION?{collection_name:collectionName}:{},...apiKey?{api_key:apiKey}:{}}}function resolveWorkspaceRootFromPmRoot(pmRoot){const resolved=resolve(pmRoot),parent=dirname(resolved);return basename(resolved)==="pm"&&basename(parent)===".agents"?dirname(parent):resolved}function anchorLanceDbStorePath(storePath,pmRoot){return!pmRoot||isAbsolute(storePath)?storePath:resolve(resolveWorkspaceRootFromPmRoot(pmRoot),storePath)}function resolveLanceDbStore(settings,pmRoot){const lancedbPath=toNonEmptyString(settings.vector_store?.lancedb?.path);if(!lancedbPath)return null;const collectionName=toNonEmptyString(settings.vector_store?.collection_name);return{name:"lancedb",path:anchorLanceDbStorePath(lancedbPath,pmRoot),...collectionName&&collectionName!==DEFAULT_COLLECTION?{collection_name:collectionName}:{}}}function normalizeVectorRecords(records){if(!Array.isArray(records)||records.length===0)throw new Error("Vector upsert records must include at least one entry");return records.map((record,index)=>{const id=toNonEmptyString(record.id);if(!id)throw new Error(`Vector upsert record at index ${index} is missing a non-empty id`);const vector=normalizeVector(record.vector),payload=record.payload;if(payload!==void 0&&(typeof payload!="object"||payload===null||Array.isArray(payload)))throw new Error(`Vector upsert record at index ${index} must provide payload as an object when set`);return{id,vector,...payload?{payload}:{}}})}function normalizeVectorDeleteIds(ids){if(!Array.isArray(ids)||ids.length===0)throw new Error("Vector delete ids must include at least one entry");const normalizedIds=ids.map((id,index)=>{const normalized=toNonEmptyString(id);if(!normalized)throw new Error(`Vector delete id at index ${index} is missing a non-empty value`);return normalized}).sort((left,right)=>left.localeCompare(right)),uniqueIds=[];for(const id of normalizedIds)uniqueIds.at(-1)!==id&&uniqueIds.push(id);return uniqueIds}function resolveQdrantDeleteTarget(upsertTarget){return upsertTarget.replace(/\/points\?wait=true$/,"/points/delete?wait=true")}function resolveQdrantCollectionTarget(upsertTarget){return upsertTarget.replace(/\/points\?wait=true$/,"")}function buildQdrantJsonHeaders(store){return{"content-type":"application/json",...store.api_key?{"api-key":store.api_key}:{}}}function getLanceDbLocalTableKey(storePath,table){return getLanceDbSnapshotPath(storePath,table)}function getLanceDbSnapshotPath(storePath,table){return join(resolve(storePath),LANCE_DB_LOCAL_SNAPSHOT_DIR,`${table}.json`)}function normalizeSnapshotRecord(entry,index,snapshotPath){const id=toNonEmptyString(entry.id);if(!id)throw new Error(`LanceDB local snapshot '${snapshotPath}' record at index ${index} is missing a non-empty id`);const vector=normalizeVector(entry.vector),payload=entry.payload;if(payload!==void 0&&(typeof payload!="object"||payload===null||Array.isArray(payload)))throw new Error(`LanceDB local snapshot '${snapshotPath}' record '${id}' must provide payload as an object when set`);return{id,vector,...payload?{payload}:{}}}function parseLanceDbSnapshot(snapshotPath,expectedTable,raw){let parsed;try{parsed=JSON.parse(raw)}catch(error){throw new Error(`LanceDB local snapshot at '${snapshotPath}' is not valid JSON: ${toErrorMessage(error)}`)}if(typeof parsed!="object"||parsed===null||Array.isArray(parsed))throw new Error(`LanceDB local snapshot at '${snapshotPath}' must be a JSON object`);if(parsed.version!==LANCE_DB_LOCAL_SNAPSHOT_VERSION)throw new Error(`LanceDB local snapshot at '${snapshotPath}' must include version=${LANCE_DB_LOCAL_SNAPSHOT_VERSION}`);const table=toNonEmptyString(parsed.table);if(!table)throw new Error(`LanceDB local snapshot at '${snapshotPath}' must include a non-empty table value`);if(table!==expectedTable)throw new Error(`LanceDB local snapshot at '${snapshotPath}' table mismatch: expected '${expectedTable}', received '${table}'`);const recordsValue=parsed.records;if(!Array.isArray(recordsValue))throw new TypeError(`LanceDB local snapshot at '${snapshotPath}' must include a records array`);const tableRecords=new Map;for(let index=0;index<recordsValue.length;index+=1){const record=normalizeSnapshotRecord(recordsValue[index],index,snapshotPath);tableRecords.set(record.id,record)}return tableRecords}async function readLanceDbSnapshotStats(snapshotPath){try{const stats=await stat(snapshotPath);return{mtimeMs:stats.mtimeMs,size:stats.size}}catch(error){if(!isFileMissingError(error))throw error;return null}}function resolveMissingLanceDbSnapshotCache(key,cached){if(!cached)return null;if(cached.mtimeMs===null&&cached.size===null&&cached.records.size===0)return cached.records;const loaded=new Map;return lanceDbLocalTables.set(key,{records:loaded,mtimeMs:null,size:null}),loaded}function cachedLanceDbSnapshotMatches(cached,snapshotStats){return cached!==void 0&&snapshotStats!==null&&cached.mtimeMs===snapshotStats.mtimeMs&&cached.size===snapshotStats.size}async function loadLanceDbLocalTable(storePath,table){const key=getLanceDbLocalTableKey(storePath,table),snapshotPath=getLanceDbSnapshotPath(storePath,table),snapshotStats=await readLanceDbSnapshotStats(snapshotPath),cached=lanceDbLocalTables.get(key);if(!snapshotStats){const resolved=resolveMissingLanceDbSnapshotCache(key,cached);if(resolved)return resolved}if(cachedLanceDbSnapshotMatches(cached,snapshotStats))return cached.records;let loaded=new Map;try{const raw=await readFile(snapshotPath,"utf8");loaded=parseLanceDbSnapshot(snapshotPath,table,raw)}catch(error){if(!isFileMissingError(error))throw error}return lanceDbLocalTables.set(key,{records:loaded,mtimeMs:snapshotStats?.mtimeMs??null,size:snapshotStats?.size??null}),loaded}function buildSnapshotRecords(table){const records=[...table.values()];return records.sort((left,right)=>left.id.localeCompare(right.id)),records.map(record=>({id:record.id,vector:[...record.vector],...record.payload?{payload:record.payload}:{}}))}async function removeSnapshotFile(snapshotPath){try{await unlink(snapshotPath)}catch(error){if(!isFileMissingError(error))throw new Error(`LanceDB local snapshot delete failed at '${snapshotPath}': ${toErrorMessage(error)}`)}}async function persistLanceDbLocalTable(storePath,tableName,table){const snapshotPath=getLanceDbSnapshotPath(storePath,tableName);if(table.size===0){await removeSnapshotFile(snapshotPath);return}const snapshotDir=dirname(snapshotPath);try{await mkdir(snapshotDir,{recursive:!0})}catch(error){throw new Error(`LanceDB local snapshot directory create failed at '${snapshotDir}': ${toErrorMessage(error)}`)}const serialized=`${JSON.stringify({version:LANCE_DB_LOCAL_SNAPSHOT_VERSION,table:tableName,records:buildSnapshotRecords(table)})}
|
|
2
|
+
`;try{await writeFileAtomic(snapshotPath,serialized)}catch(error){throw new Error(`LanceDB local snapshot write failed at '${snapshotPath}': ${toErrorMessage(error)}`)}}async function resetLanceDbLocalTable(storePath,tableName){const key=getLanceDbLocalTableKey(storePath,tableName),snapshotPath=getLanceDbSnapshotPath(storePath,tableName);await removeSnapshotFile(snapshotPath),lanceDbLocalTables.delete(key)}function l2Norm(vector){let sumSq=0;for(let index=0;index<vector.length;index+=1)sumSq+=vector[index]*vector[index];return Math.sqrt(sumSq)}function cosineSimilarity(left,right){let dotProd=0;for(let index=0;index<left.length;index+=1)dotProd+=left[index]*right[index];const leftNorm=l2Norm(left),rightNorm=l2Norm(right);return leftNorm===0||rightNorm===0?0:dotProd/(leftNorm*rightNorm)}function resolveVectorStores(settings,pmRoot){const qdrant=resolveQdrantStore(settings),lancedb=resolveLanceDbStore(settings,pmRoot),available=[qdrant,lancedb].filter(entry=>entry!==null),preferredName=toNonEmptyString(settings.vector_store?.adapter),preferredKey=preferredName?preferredName.toLowerCase():null;return{active:(preferredKey?available.find(entry=>entry.name===preferredKey):void 0)??available[0]??null,available}}function resolveVectorStoreRequestTarget(store){const collectionName=resolveStoreCollectionName(store);if(store.name==="qdrant"){const baseUrl=trimTrailingSlashes(store.url),encodedCollection2=encodeURIComponent(collectionName);return{store:"qdrant",query_target:`${baseUrl}/collections/${encodedCollection2}/points/search`,upsert_target:`${baseUrl}/collections/${encodedCollection2}/points?wait=true`}}const encodedPath=encodeURIComponent(store.path),encodedCollection=encodeURIComponent(collectionName);return{store:"lancedb",query_target:`lancedb://${encodedPath}#${encodedCollection}`,upsert_target:`lancedb://${encodedPath}#${encodedCollection}`}}function buildVectorQueryPlan(store,vector,limit){const target=resolveVectorStoreRequestTarget(store),normalizedVector=normalizeVector(vector),normalizedLimit=normalizeLimit(limit);return store.name==="qdrant"?{target,method:"POST",headers:buildQdrantJsonHeaders(store),body:{vector:normalizedVector,limit:normalizedLimit,with_payload:!0}}:{target,method:"LOCAL",headers:{},body:{table:resolveStoreCollectionName(store),vector:normalizedVector,limit:normalizedLimit}}}function buildVectorUpsertPlan(store,records){const target=resolveVectorStoreRequestTarget(store),normalizedRecords=normalizeVectorRecords(records);return store.name==="qdrant"?{target,method:"POST",headers:buildQdrantJsonHeaders(store),body:{points:normalizedRecords}}:{target,method:"LOCAL",headers:{},body:{table:resolveStoreCollectionName(store),records:normalizedRecords}}}function buildVectorDeletePlan(store,ids){const target=resolveVectorStoreRequestTarget(store),normalizedIds=normalizeVectorDeleteIds(ids);return store.name==="qdrant"?{target,method:"POST",headers:buildQdrantJsonHeaders(store),body:{points:normalizedIds}}:{target,method:"LOCAL",headers:{},body:{table:resolveStoreCollectionName(store),ids:normalizedIds}}}async function executeVectorQuery(store,vector,limit,options={}){const plan=buildVectorQueryPlan(store,vector,limit);if(plan.method==="LOCAL"){const lanceDbStore=store,queryBody=plan.body,table=await loadLanceDbLocalTable(lanceDbStore.path,queryBody.table);if(table.size===0)return[];const queryVector=normalizeVector(queryBody.vector),queryLimit=normalizeLimit(queryBody.limit),hits=[];let dimensionMismatchCount=0;for(const record of table.values()){if(record.vector.length!==queryVector.length){dimensionMismatchCount++;continue}hits.push({id:record.id,score:cosineSimilarity(queryVector,record.vector),...record.payload?{payload:record.payload}:{}})}return dimensionMismatchCount>0&&options.warnings&&options.warnings.push(`vector_dimension_mismatch:${dimensionMismatchCount} records skipped (expected ${queryVector.length} dimensions)`),hits.sort((left,right)=>left.score!==right.score?right.score-left.score:left.id.localeCompare(right.id)),hits.slice(0,queryLimit)}const timeoutMs=normalizeSearchHttpTimeoutMs(options.timeout_ms,"Vector request"),fetcher=resolveSearchHttpFetcher(options.fetcher,"Vector request"),payload=await executeRemoteVectorPlan(plan.target.query_target,{method:"POST",headers:plan.headers,body:plan.body},timeoutMs,fetcher,"query");return normalizeQdrantQueryResponse(payload)}async function executeVectorUpsert(store,records,options={}){const plan=buildVectorUpsertPlan(store,records);if(plan.method==="LOCAL"){const lanceDbStore=store,upsertBody=plan.body,key=getLanceDbLocalTableKey(lanceDbStore.path,upsertBody.table),table=await loadLanceDbLocalTable(lanceDbStore.path,upsertBody.table);for(const record of upsertBody.records)table.set(record.id,record);await persistLanceDbLocalTable(lanceDbStore.path,upsertBody.table,table);const snapshotPath=getLanceDbSnapshotPath(lanceDbStore.path,upsertBody.table),snapshotStats=await stat(snapshotPath);return lanceDbLocalTables.set(key,{records:table,mtimeMs:snapshotStats.mtimeMs,size:snapshotStats.size}),{status:"ok"}}const timeoutMs=normalizeSearchHttpTimeoutMs(options.timeout_ms,"Vector request"),fetcher=resolveSearchHttpFetcher(options.fetcher,"Vector request"),payload=await executeRemoteVectorPlan(plan.target.upsert_target,{method:"POST",headers:plan.headers,body:plan.body},timeoutMs,fetcher,"upsert");return normalizeQdrantUpsertResponse(payload)}async function executeVectorDelete(store,ids,options={}){const plan=buildVectorDeletePlan(store,ids);if(plan.method==="LOCAL"){const lanceDbStore=store,deleteBody=plan.body,key=getLanceDbLocalTableKey(lanceDbStore.path,deleteBody.table),table=await loadLanceDbLocalTable(lanceDbStore.path,deleteBody.table);if(table.size===0)return{status:"ok"};for(const id of deleteBody.ids)table.delete(id);if(await persistLanceDbLocalTable(lanceDbStore.path,deleteBody.table,table),table.size===0)lanceDbLocalTables.delete(key);else{const snapshotPath=getLanceDbSnapshotPath(lanceDbStore.path,deleteBody.table),snapshotStats=await stat(snapshotPath);lanceDbLocalTables.set(key,{records:table,mtimeMs:snapshotStats.mtimeMs,size:snapshotStats.size})}return{status:"ok"}}const timeoutMs=normalizeSearchHttpTimeoutMs(options.timeout_ms,"Vector request"),fetcher=resolveSearchHttpFetcher(options.fetcher,"Vector request"),payload=await executeRemoteVectorPlan(resolveQdrantDeleteTarget(plan.target.upsert_target),{method:"POST",headers:plan.headers,body:plan.body},timeoutMs,fetcher,"delete");return normalizeQdrantUpsertResponse(payload)}async function executeVectorReset(store,knownIds=[],options={},vectorDimension){if(store.name==="lancedb")return await resetLanceDbLocalTable(store.path,resolveStoreCollectionName(store)),{status:"ok"};if(vectorDimension!==void 0){if(!Number.isInteger(vectorDimension)||vectorDimension<=0)throw new Error("Vector reset dimension must be a positive integer when provided");const target=resolveVectorStoreRequestTarget(store),collectionTarget=resolveQdrantCollectionTarget(target.upsert_target),timeoutMs=normalizeSearchHttpTimeoutMs(options.timeout_ms,"Vector request"),fetcher=resolveSearchHttpFetcher(options.fetcher,"Vector request"),headers=buildQdrantJsonHeaders(store);try{await executeRemoteVectorPlan(collectionTarget,{method:"DELETE",headers,body:{}},timeoutMs,fetcher,"delete")}catch(error){if(!toErrorMessage(error).includes("failed with status 404"))throw error}const payload=await executeRemoteVectorPlan(collectionTarget,{method:"PUT",headers,body:{vectors:{size:vectorDimension,distance:"Cosine"}}},timeoutMs,fetcher,"upsert");return normalizeQdrantUpsertResponse(payload)}const idsToDelete=knownIds.map(id=>id.trim()).filter(id=>id.length>0);return idsToDelete.length===0?{status:"ok"}:await executeVectorDelete(store,idsToDelete,options)}export{buildVectorDeletePlan,buildVectorQueryPlan,buildVectorUpsertPlan,executeVectorDelete,executeVectorQuery,executeVectorReset,executeVectorUpsert,resolveVectorStoreRequestTarget,resolveVectorStores};
|
|
3
3
|
//# sourceMappingURL=vector-stores.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f8acaac5-64f7-5e22-987e-4eb12a1aa1cf")}catch{}})();import{toNonEmptyString}from"../shared/primitives.js";function buildVectorizationEmbeddingIdentity(provider,model){const normalizedProvider=toNonEmptyString(provider),normalizedModel=toNonEmptyString(model);return!normalizedProvider||!normalizedModel?null:{provider:normalizedProvider,model:normalizedModel}}function normalizeVectorizationEmbeddingMetadata(value){if(value==null)return null;if(typeof value!="object"||Array.isArray(value))throw new Error("Vectorization embedding metadata must be an object when set");const identity=buildVectorizationEmbeddingIdentity(value.provider,value.model),vectorDimension=value.vector_dimension;if(!identity||typeof vectorDimension!="number"||!Number.isInteger(vectorDimension)||vectorDimension<=0)throw new Error("Vectorization embedding metadata must include provider, model, and positive vector_dimension");return{...identity,vector_dimension:vectorDimension}}function buildVectorizationEmbeddingMetadata(identity,vectorDimension){if(!Number.isInteger(vectorDimension)||vectorDimension<=0)throw new Error("Vectorization embedding metadata requires a positive vector dimension");return{provider:identity.provider,model:identity.model,vector_dimension:vectorDimension}}function hasVectorizationEmbeddingIdentityChanged(metadata,identity){return!metadata||metadata.provider!==identity.provider||metadata.model!==identity.model}function hasVectorizationVectorDimensionChanged(metadata,vectorDimension){return!!(metadata&&metadata.vector_dimension!==vectorDimension)}function inferConsistentVectorDimension(vectors,context){if(vectors.length===0)throw new Error(`${context} returned no vectors`);const dimension=vectors[0].length;if(!Number.isInteger(dimension)||dimension<=0)throw new Error(`${context} returned an empty vector`);for(let index=1;index<vectors.length;index+=1)if(vectors[index]?.length!==dimension)throw new Error(`${context} returned mixed vector dimensions`);return dimension}export{buildVectorizationEmbeddingIdentity,buildVectorizationEmbeddingMetadata,hasVectorizationEmbeddingIdentityChanged,hasVectorizationVectorDimensionChanged,inferConsistentVectorDimension,normalizeVectorizationEmbeddingMetadata};
|
|
2
2
|
//# sourceMappingURL=vectorization-metadata.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ceaee876-c2c8-5b28-91ee-f670384fd559")}catch{}})();import{getSentry}from"./instrument.js";import{PmCliError}from"../shared/errors.js";import{EXIT_CODE}from"../shared/constants.js";import{deriveTelemetryCommandResolution,deriveTelemetryCommandTaxonomy}from"../telemetry/observability.js";let activeCommandSpan;function setSpanAttribute(span,key,value){if(value===void 0)return;const attributeTarget=span;typeof attributeTarget.setAttribute=="function"&&attributeTarget.setAttribute(key,value)}function setSentryTagIfPresent(Sentry,key,value){typeof value=="string"&&value.trim().length>0&&Sentry.setTag(key,value)}function setSentryCommandFinishTags(Sentry,normalizedOk,metadata){Sentry.setTag("pm.ok",normalizedOk),Sentry.setTag("pm.command_ok",normalizedOk),typeof metadata?.exit_code=="number"&&(Sentry.setTag("pm.exit_code",String(metadata.exit_code)),Sentry.setTag("pm.command_exit_code",String(metadata.exit_code))),setSentryTagIfPresent(Sentry,"pm.error_code",metadata?.error_code),setSentryTagIfPresent(Sentry,"pm.error_category",metadata?.error_category),setSentryTagIfPresent(Sentry,"pm.command_resolution",metadata?.command_resolution),setSentryTagIfPresent(Sentry,"pm.resolution_stage",metadata?.resolution_stage)}function setCommandSpanFinishAttributes(span,normalizedOk,normalizedExitCode,metadata){setSpanAttribute(span,"pm.ok",normalizedOk),setSpanAttribute(span,"pm.command_ok",normalizedOk),setSpanAttribute(span,"pm.exit_code",normalizedExitCode),setSpanAttribute(span,"pm.command_exit_code",normalizedExitCode),setSpanAttribute(span,"pm.error_code",metadata?.error_code),setSpanAttribute(span,"pm.error_category",metadata?.error_category),setSpanAttribute(span,"pm.command_resolution",metadata?.command_resolution),setSpanAttribute(span,"pm.resolution_stage",metadata?.resolution_stage)}function sentrySetCommandContext(command,args,options,metadata){const Sentry=getSentry();if(!Sentry)return;const taxonomy=deriveTelemetryCommandTaxonomy(command);Sentry.setTag("pm.command",command),Sentry.setTag("pm.command_root",taxonomy.command_root),Sentry.setTag("pm.command_family",taxonomy.command_family),typeof metadata?.source_context=="string"&&metadata.source_context.trim().length>0&&Sentry.setTag("pm.source_context",metadata.source_context);const safeArgs=args.map(arg=>arg.startsWith("--")?arg.split("=")[0]:arg);Sentry.setContext("pm.command",{name:command,root:taxonomy.command_root,leaf:taxonomy.command_leaf,family:taxonomy.command_family,args:safeArgs,option_keys:Object.keys(options).sort(),source_context:metadata?.source_context,source_context_source:metadata?.source_context_source}),Sentry.addBreadcrumb({category:"pm.command",message:`pm ${command}`,level:"info",data:{args:safeArgs,command_root:taxonomy.command_root,command_family:taxonomy.command_family,source_context:metadata?.source_context}})}function sentryStartCommandSpan(command){const Sentry=getSentry();Sentry&&(activeCommandSpan=Sentry.startInactiveSpan({op:"pm.command",name:`pm ${command}`,forceTransaction:!0}))}function sentryFinishCommandSpan(ok,error,metadata){if(!activeCommandSpan)return;const normalizedOk=ok?"true":"false",normalizedExitCode=typeof metadata?.exit_code=="number"?String(metadata.exit_code):void 0,Sentry=getSentry();Sentry&&setSentryCommandFinishTags(Sentry,normalizedOk,metadata),setCommandSpanFinishAttributes(activeCommandSpan,normalizedOk,normalizedExitCode,metadata),activeCommandSpan.setStatus(ok?{code:1}:{code:2,message:error??"command_failed"}),activeCommandSpan.end(),activeCommandSpan=void 0}const UNCLASSIFIED_CAPTURED_ERROR_CODE="unclassified_runtime_error";function readCapturedErrorContract(error){const candidate=typeof error=="object"&&error!==null?error:void 0,hasDeclaredExitCode=typeof candidate?.exitCode=="number",exitCode=hasDeclaredExitCode?Math.trunc(candidate?.exitCode):EXIT_CODE.GENERIC_FAILURE;return{error_code:typeof candidate?.code=="string"&&candidate.code.length>0&&hasDeclaredExitCode?candidate?.code:UNCLASSIFIED_CAPTURED_ERROR_CODE,exit_code:exitCode}}function buildCapturedErrorTags(error){const contract=readCapturedErrorContract(error);return{"pm.error_code":contract.error_code,"pm.exit_code":String(contract.exit_code)}}function sentryCaptureCliError(error){if(!shouldCaptureCliError(error))return;const Sentry=getSentry();if(!Sentry)return;const tags=buildCapturedErrorTags(error);if(error instanceof Error){const extras={};"exitCode"in error&&typeof error.exitCode=="number"&&(extras.exit_code=error.exitCode),"context"in error&&typeof error.context=="object"&&(extras.error_context=error.context),Sentry.captureException(error,{extra:extras,tags})}else Sentry.captureException(new Error(String(error)),{tags})}function sentryLogCliUsageError(params){const Sentry=getSentry();if(!Sentry)return;const resolvedCommandResolution=params.command_resolution??deriveTelemetryCommandResolution({ok:!1,errorCode:params.error_code,errorCategory:params.error_category}),resolvedResolutionStage=params.resolution_stage??"unknown",payload={"pm.command":params.command,"pm.error_code":params.error_code,"pm.error_category":params.error_category,"pm.exit_code":params.exit_code,"pm.error_message":params.error_message,"pm.command_resolution":resolvedCommandResolution,"pm.resolution_stage":resolvedResolutionStage,"pm.source_context":params.source_context??""},loggerCandidate=Sentry.logger;if(loggerCandidate&&typeof loggerCandidate.warn=="function"){loggerCandidate.warn("pm_cli_usage_error",payload);return}Sentry.captureMessage(`pm_cli_usage_error:${params.error_code}`,{level:"warning",tags:{"pm.command":params.command,"pm.error_code":params.error_code,"pm.error_category":params.error_category,"pm.exit_code":String(params.exit_code),"pm.command_resolution":resolvedCommandResolution,"pm.resolution_stage":resolvedResolutionStage,"pm.source_context":params.source_context??"unknown"},extra:payload})}function shouldCaptureCliError(error){if(error instanceof PmCliError||error instanceof Error&&error.name==="AbortError"&&/(?:ctrl\+[cd]|sigint|user[- ]initiated)/i.test(error.message))return!1;if(typeof error=="object"&&error!==null&&"exitCode"in error&&typeof error.exitCode=="number"){if(error instanceof Error&&error.name==="CommandError")return!1;const exitCode=Math.trunc(error.exitCode);return!new Set([EXIT_CODE.SUCCESS,EXIT_CODE.USAGE,EXIT_CODE.NOT_FOUND,EXIT_CODE.CONFLICT]).has(exitCode)}return!0}async function sentryFlush(timeoutMs=3e3){const Sentry=getSentry();if(Sentry)try{await Sentry.flush(timeoutMs)}catch{}}export{UNCLASSIFIED_CAPTURED_ERROR_CODE,sentryCaptureCliError,sentryFinishCommandSpan,sentryFlush,sentryLogCliUsageError,sentrySetCommandContext,sentryStartCommandSpan,shouldCaptureCliError};
|
|
2
2
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!(function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="12bf6794-9410-5683-bb83-a0da8d2614a7")}catch(e2){}})();import{createRequire}from"node:module";import{resolvePmCliVersion}from"../packages/root.js";import{resolveTelemetryEnvironmentPolicy}from"../telemetry/policy.js";const OPT_OUT_VALUES=new Set(["1","true","yes","on"]);function isSentryDisabled(){if(OPT_OUT_VALUES.has((process.env.PM_SENTRY_DISABLED??"").trim().toLowerCase()))return true;if(resolveTelemetryEnvironmentPolicy().telemetry_disabled)return true;if(typeof process.env.VITEST==="string"||typeof process.env.VITEST_WORKER_ID==="string")return true;return false}const SENSITIVE_KEY_PATTERN=/(?:token|secret|password|passwd|api[_-]?key|apikey|authorization|cookie|credentials|bearer|dsn)/i;const INLINE_SENSITIVE_ASSIGNMENT_RE=new RegExp(`\\b(${SENSITIVE_KEY_PATTERN.source})\\s*[:=]\\s*([^\\s,;]+)`,"giu");const ABSOLUTE_PATH_TOKEN_RE=/(^|[\s"'`(=])\/(?:[^\s"'`),;]+)/g;const FILE_URL_PATH_RE=/file:\/\/\/?[^\s"'`),;]+/giu;const WINDOWS_PATH_TOKEN_RE=/\b[A-Za-z]:\\[^\s"'`),;]+/g;const PRIVATE_IP_RE=/\b(?:10\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|172\.(?:1[6-9]|2\d|3[01])\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d))\b/g;const PATH_FIELD_KEY_PATTERN=/(?:^|[_-])(path|filename|file|module|cwd|dir|directory|location|source|script)s?$/i;const MAX_KNOWN_NOISY_CONSOLE_MESSAGE_PATTERNS=15;const KNOWN_NOISY_CONSOLE_MESSAGE_PATTERNS=["[starter-extension] activating","[starter-extension] all 8 capabilities registered.","[starter-extension] commands:","[starter] preflight check for workspace","[starter] output_format service override active","[pm-ext-ts-starter] activating","[pm-ext-ts-starter] all capabilities registered.","run `pm init` first to initialise a pm workspace"];function looksLikeFilesystemPath(value){const normalized=value.trim();if(normalized.length===0){return false}if(normalized.startsWith("/")||normalized.startsWith("file://")){return true}if(/^[A-Za-z]:\\/.test(normalized)||normalized.startsWith("\\\\")){return true}return normalized.includes("/home/")}function scrubString(value,keyHint){if(keyHint&&PATH_FIELD_KEY_PATTERN.test(keyHint)&&looksLikeFilesystemPath(value)){return"[scrubbed_path]"}const scrubbed=value.replaceAll(INLINE_SENSITIVE_ASSIGNMENT_RE,(_m,key)=>`${key}=[scrubbed]`).replaceAll(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/giu,"[scrubbed_email]").replaceAll(/bearer\s+[a-z0-9._=-]+/giu,"bearer [scrubbed]").replaceAll(/sntr[ysu]_[A-Za-z0-9_-]+/g,"[scrubbed_sentry_token]").replaceAll(PRIVATE_IP_RE,"[scrubbed_ip]").replaceAll(FILE_URL_PATH_RE,"[scrubbed_path]").replaceAll(WINDOWS_PATH_TOKEN_RE,"[scrubbed_path]").replaceAll(ABSOLUTE_PATH_TOKEN_RE,(_match,prefix)=>`${prefix}[scrubbed_path]`);if(looksLikeFilesystemPath(scrubbed)){return"[scrubbed_path]"}return scrubbed}function scrubEventData(obj){const result={};for(const[key,value]of Object.entries(obj)){if(SENSITIVE_KEY_PATTERN.test(key)){result[key]="[scrubbed]"}else if(typeof value==="string"){result[key]=scrubString(value,key)}else if(Array.isArray(value)){result[key]=value.map(entry=>{if(typeof entry==="string"){return scrubString(entry,key)}if(entry&&typeof entry==="object"){return scrubEventData(entry)}return entry})}else if(value&&typeof value==="object"){result[key]=scrubEventData(value)}else{result[key]=value}}return result}function scrubStackFrame(frame){for(const key of["filename","absPath","abs_path","module"]){const rawValue=frame[key];if(typeof rawValue==="string"){frame[key]=scrubString(rawValue,key)}}const contextLine=frame.context_line;if(typeof contextLine==="string"){frame.context_line=scrubString(contextLine,"context_line")}for(const key of["pre_context","post_context"]){const context=frame[key];if(!Array.isArray(context)){continue}frame[key]=context.map(entry=>typeof entry==="string"?scrubString(entry,key):entry)}if(frame.vars&&typeof frame.vars==="object"){frame.vars=scrubEventData(frame.vars)}if(frame.data&&typeof frame.data==="object"){frame.data=scrubEventData(frame.data)}}const requireFromInstrument=createRequire(import.meta.url);const defaultSentryLoader=()=>requireFromInstrument("@sentry/node");let _sentry;let _initDone=false;let _loadSentry=defaultSentryLoader;const PM_CLI_SENTRY_DSN="https://bf7ad2ec76c0051c2ee94e48e8bd6868@o4510603477712896.ingest.de.sentry.io/4511316775338064";function hasPmCliErrorPrefix(value){return/^\s*PmCliError:/.test(value)}function isKnownNoisyConsoleMessage(value){const normalized=value.trim().toLowerCase();if(normalized.length===0){return false}return KNOWN_NOISY_CONSOLE_MESSAGE_PATTERNS.some(pattern=>normalized.includes(pattern))}function isKnownNoisyConsoleEvent(event){if(event.logger!=="console"){return false}if(typeof event.message==="string"&&isKnownNoisyConsoleMessage(event.message)){return true}return Array.isArray(event.exception?.values)&&event.exception.values.some(entry=>typeof entry.value==="string"&&isKnownNoisyConsoleMessage(entry.value))}function isNodeRuntimeWarningEvent(event){if(event.logger!=="console")return false;const isRuntimeWarning=value=>typeof value==="string"&&/^\(node:\d+\) MaxListenersExceededWarning: Possible EventEmitter memory leak detected\./.test(value);if(isRuntimeWarning(event.message))return true;return Array.isArray(event.exception?.values)&&event.exception.values.some(entry=>isRuntimeWarning(entry.value))}function isExpectedCliErrorEvent(event){if(event.exception?.values?.some(ex=>ex.type==="PmCliError"))return true;if(event.exception?.values?.some(ex=>typeof ex.value==="string"&&hasPmCliErrorPrefix(ex.value)))return true;if(event.logger==="console"&&typeof event.message==="string"&&hasPmCliErrorPrefix(event.message))return true;return false}function isPmCliErrorBreadcrumb(breadcrumb){return breadcrumb.category==="console"&&typeof breadcrumb.message==="string"&&hasPmCliErrorPrefix(breadcrumb.message)}function isKnownNoisyConsoleBreadcrumb(breadcrumb){return breadcrumb.category==="console"&&typeof breadcrumb.message==="string"&&isKnownNoisyConsoleMessage(breadcrumb.message)}function resolveCliVersion(){return resolvePmCliVersion(import.meta.url,["../../.."])??"0.0.0"}function resolveEnvironment(){const explicit=process.env.SENTRY_ENVIRONMENT?.trim();if(explicit&&explicit.length>0)return explicit;if(process.env.VITEST||process.env.VITEST_WORKER_ID||process.env.NODE_ENV==="test")return"test";if(process.env.CI)return"ci";return"production"}const DEFAULT_TRACES_SAMPLE_RATE=.2;function resolveTracesSampleRate(){const raw=process.env.SENTRY_TRACES_SAMPLE_RATE?.trim();if(!raw)return DEFAULT_TRACES_SAMPLE_RATE;const parsed=Number(raw);if(!Number.isFinite(parsed)||parsed<0||parsed>1){return DEFAULT_TRACES_SAMPLE_RATE}return parsed}function scrubSentryExceptionValues(event){if(!event.exception?.values){return}for(const exception of event.exception.values){if(exception.value){exception.value=scrubString(exception.value,"value")}if(exception.stacktrace?.frames){for(const frame of exception.stacktrace.frames){scrubStackFrame(frame)}}}}function scrubSentryBreadcrumbs(event){if(!event.breadcrumbs){return}for(const breadcrumb of event.breadcrumbs){if(breadcrumb.message){breadcrumb.message=scrubString(breadcrumb.message)}if(breadcrumb.data&&typeof breadcrumb.data==="object"){breadcrumb.data=scrubEventData(breadcrumb.data)}}}function scrubSentryContexts(event){if(!event.contexts){return}for(const[ctxKey,ctx]of Object.entries(event.contexts)){if(ctx&&typeof ctx==="object"){event.contexts[ctxKey]=scrubEventData(ctx)}}}function scrubSentryRecordField(event,key){const target=event;const value=target[key];if(value&&typeof value==="object"){target[key]=scrubEventData(value)}}const beforeSend=event=>{if(isExpectedCliErrorEvent(event)||isKnownNoisyConsoleEvent(event))return null;if(isNodeRuntimeWarningEvent(event)){event.level="warning";event.tags={...event.tags,"pm.diagnostic_class":"node_runtime_warning"}}if(event.message)event.message=scrubString(event.message,"message");if(event.transaction)event.transaction=scrubString(event.transaction,"transaction");scrubSentryExceptionValues(event);scrubSentryBreadcrumbs(event);scrubSentryRecordField(event,"extra");scrubSentryContexts(event);for(const key of["request","user","tags"])scrubSentryRecordField(event,key);return event};const beforeSendTransaction=event=>{if(event.breadcrumbs){event.breadcrumbs=event.breadcrumbs.filter(breadcrumb=>!isPmCliErrorBreadcrumb(breadcrumb)&&!isKnownNoisyConsoleBreadcrumb(breadcrumb));scrubSentryBreadcrumbs(event)}scrubSentryContexts(event);return event};const beforeBreadcrumb=breadcrumb=>{if(isPmCliErrorBreadcrumb(breadcrumb)||isKnownNoisyConsoleBreadcrumb(breadcrumb))return null;if(breadcrumb.message)breadcrumb.message=scrubString(breadcrumb.message,"message");if(breadcrumb.data&&typeof breadcrumb.data==="object"){breadcrumb.data=scrubEventData(breadcrumb.data)}return breadcrumb};async function ensureSentryInit(){if(_initDone)return _sentry;_initDone=true;if(isSentryDisabled())return void 0;const SentryModule=_loadSentry();_sentry=SentryModule;const dsn=process.env.SENTRY_DSN?.trim()||PM_CLI_SENTRY_DSN;const release=resolveCliVersion();SentryModule.init({dsn,release:`pm-cli@${release}`,environment:resolveEnvironment(),tracesSampleRate:resolveTracesSampleRate(),enableLogs:true,attachStacktrace:true,normalizeDepth:6,shutdownTimeout:3e3,sendDefaultPii:false,serverName:void 0,integrations:[SentryModule.extraErrorDataIntegration({depth:4}),SentryModule.captureConsoleIntegration({levels:["warn","error"]})],initialScope:{tags:{"cli.name":"pm-cli","cli.version":release,"runtime.node":process.version,"runtime.platform":process.platform,"runtime.arch":process.arch}},beforeSend,beforeSendTransaction,beforeBreadcrumb});return SentryModule}function getSentry(){return _sentry}const _testOnly={isExpectedCliErrorEvent,isKnownNoisyConsoleEvent,isNodeRuntimeWarningEvent,isPmCliErrorBreadcrumb,isKnownNoisyConsoleBreadcrumb,scrubString,scrubEventData,resolveTracesSampleRate,KNOWN_NOISY_CONSOLE_MESSAGE_PATTERNS,MAX_KNOWN_NOISY_CONSOLE_MESSAGE_PATTERNS,defaultSentryLoader,setSentryLoaderForTests(loader){_loadSentry=loader??defaultSentryLoader},resetSentryStateForTests(){_sentry=void 0;_initDone=false}};export{_testOnly,ensureSentryInit,getSentry};
|
|
1
|
+
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="da2c4c10-3c43-5037-ac69-31204480af99")}catch{}})();import{createRequire}from"node:module";import{resolvePmCliVersion}from"../packages/root.js";import{resolveTelemetryEnvironmentPolicy}from"../telemetry/policy.js";const OPT_OUT_VALUES=new Set(["1","true","yes","on"]);function isSentryDisabled(){return!!(OPT_OUT_VALUES.has((process.env.PM_SENTRY_DISABLED??"").trim().toLowerCase())||resolveTelemetryEnvironmentPolicy().telemetry_disabled||typeof process.env.VITEST=="string"||typeof process.env.VITEST_WORKER_ID=="string")}const SENSITIVE_KEY_PATTERN=/(?:token|secret|password|passwd|api[_-]?key|apikey|authorization|cookie|credentials|bearer|dsn)/i,INLINE_SENSITIVE_ASSIGNMENT_RE=new RegExp(`\\b(${SENSITIVE_KEY_PATTERN.source})\\s*[:=]\\s*([^\\s,;]+)`,"giu"),ABSOLUTE_PATH_TOKEN_RE=/(^|[\s"'`(=])\/(?:[^\s"'`),;]+)/g,FILE_URL_PATH_RE=/file:\/\/\/?[^\s"'`),;]+/giu,WINDOWS_PATH_TOKEN_RE=/\b[A-Za-z]:\\[^\s"'`),;]+/g,PRIVATE_IP_RE=/\b(?:10\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|172\.(?:1[6-9]|2\d|3[01])\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d))\b/g,PATH_FIELD_KEY_PATTERN=/(?:^|[_-])(path|filename|file|module|cwd|dir|directory|location|source|script)s?$/i,MAX_KNOWN_NOISY_CONSOLE_MESSAGE_PATTERNS=15,KNOWN_NOISY_CONSOLE_MESSAGE_PATTERNS=["[starter-extension] activating","[starter-extension] all 8 capabilities registered.","[starter-extension] commands:","[starter] preflight check for workspace","[starter] output_format service override active","[pm-ext-ts-starter] activating","[pm-ext-ts-starter] all capabilities registered.","run `pm init` first to initialise a pm workspace"];function looksLikeFilesystemPath(value){const normalized=value.trim();return normalized.length===0?!1:normalized.startsWith("/")||normalized.startsWith("file://")||/^[A-Za-z]:\\/.test(normalized)||normalized.startsWith("\\\\")?!0:normalized.includes("/home/")}function scrubString(value,keyHint){if(keyHint&&PATH_FIELD_KEY_PATTERN.test(keyHint)&&looksLikeFilesystemPath(value))return"[scrubbed_path]";const scrubbed=value.replaceAll(INLINE_SENSITIVE_ASSIGNMENT_RE,(_m,key)=>`${key}=[scrubbed]`).replaceAll(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/giu,"[scrubbed_email]").replaceAll(/bearer\s+[a-z0-9._=-]+/giu,"bearer [scrubbed]").replaceAll(/sntr[ysu]_[A-Za-z0-9_-]+/g,"[scrubbed_sentry_token]").replaceAll(PRIVATE_IP_RE,"[scrubbed_ip]").replaceAll(FILE_URL_PATH_RE,"[scrubbed_path]").replaceAll(WINDOWS_PATH_TOKEN_RE,"[scrubbed_path]").replaceAll(ABSOLUTE_PATH_TOKEN_RE,(_match,prefix)=>`${prefix}[scrubbed_path]`);return looksLikeFilesystemPath(scrubbed)?"[scrubbed_path]":scrubbed}function scrubEventData(obj){const result={};for(const[key,value]of Object.entries(obj))SENSITIVE_KEY_PATTERN.test(key)?result[key]="[scrubbed]":typeof value=="string"?result[key]=scrubString(value,key):Array.isArray(value)?result[key]=value.map(entry=>typeof entry=="string"?scrubString(entry,key):entry&&typeof entry=="object"?scrubEventData(entry):entry):value&&typeof value=="object"?result[key]=scrubEventData(value):result[key]=value;return result}function scrubStackFrame(frame){for(const key of["filename","absPath","abs_path","module"]){const rawValue=frame[key];typeof rawValue=="string"&&(frame[key]=scrubString(rawValue,key))}const contextLine=frame.context_line;typeof contextLine=="string"&&(frame.context_line=scrubString(contextLine,"context_line"));for(const key of["pre_context","post_context"]){const context=frame[key];Array.isArray(context)&&(frame[key]=context.map(entry=>typeof entry=="string"?scrubString(entry,key):entry))}frame.vars&&typeof frame.vars=="object"&&(frame.vars=scrubEventData(frame.vars)),frame.data&&typeof frame.data=="object"&&(frame.data=scrubEventData(frame.data))}const requireFromInstrument=createRequire(import.meta.url),defaultSentryLoader=()=>requireFromInstrument("@sentry/node");let _sentry,_initDone=!1,_loadSentry=defaultSentryLoader;const PM_CLI_SENTRY_DSN="https://bf7ad2ec76c0051c2ee94e48e8bd6868@o4510603477712896.ingest.de.sentry.io/4511316775338064";function hasPmCliErrorPrefix(value){return/^\s*PmCliError:/.test(value)}function isKnownNoisyConsoleMessage(value){const normalized=value.trim().toLowerCase();return normalized.length===0?!1:KNOWN_NOISY_CONSOLE_MESSAGE_PATTERNS.some(pattern=>normalized.includes(pattern))}function isKnownNoisyConsoleEvent(event){return event.logger!=="console"?!1:typeof event.message=="string"&&isKnownNoisyConsoleMessage(event.message)?!0:Array.isArray(event.exception?.values)&&event.exception.values.some(entry=>typeof entry.value=="string"&&isKnownNoisyConsoleMessage(entry.value))}function isNodeRuntimeWarningEvent(event){if(event.logger!=="console")return!1;const isRuntimeWarning=value=>typeof value=="string"&&/^\(node:\d+\) MaxListenersExceededWarning: Possible EventEmitter memory leak detected\./.test(value);return isRuntimeWarning(event.message)?!0:Array.isArray(event.exception?.values)&&event.exception.values.some(entry=>isRuntimeWarning(entry.value))}function isExpectedCliErrorEvent(event){return!!(event.exception?.values?.some(ex=>ex.type==="PmCliError")||event.exception?.values?.some(ex=>typeof ex.value=="string"&&hasPmCliErrorPrefix(ex.value))||event.logger==="console"&&typeof event.message=="string"&&hasPmCliErrorPrefix(event.message))}function isPmCliErrorBreadcrumb(breadcrumb){return breadcrumb.category==="console"&&typeof breadcrumb.message=="string"&&hasPmCliErrorPrefix(breadcrumb.message)}function isKnownNoisyConsoleBreadcrumb(breadcrumb){return breadcrumb.category==="console"&&typeof breadcrumb.message=="string"&&isKnownNoisyConsoleMessage(breadcrumb.message)}function resolveCliVersion(){return resolvePmCliVersion(import.meta.url,["../../.."])??"0.0.0"}function resolveEnvironment(){const explicit=process.env.SENTRY_ENVIRONMENT?.trim();return explicit&&explicit.length>0?explicit:process.env.VITEST||process.env.VITEST_WORKER_ID||process.env.NODE_ENV==="test"?"test":process.env.CI?"ci":"production"}const DEFAULT_TRACES_SAMPLE_RATE=.2;function resolveTracesSampleRate(){const raw=process.env.SENTRY_TRACES_SAMPLE_RATE?.trim();if(!raw)return DEFAULT_TRACES_SAMPLE_RATE;const parsed=Number(raw);return!Number.isFinite(parsed)||parsed<0||parsed>1?DEFAULT_TRACES_SAMPLE_RATE:parsed}function scrubSentryExceptionValues(event){if(event.exception?.values){for(const exception of event.exception.values)if(exception.value&&(exception.value=scrubString(exception.value,"value")),exception.stacktrace?.frames)for(const frame of exception.stacktrace.frames)scrubStackFrame(frame)}}function scrubSentryBreadcrumbs(event){if(event.breadcrumbs)for(const breadcrumb of event.breadcrumbs)breadcrumb.message&&(breadcrumb.message=scrubString(breadcrumb.message)),breadcrumb.data&&typeof breadcrumb.data=="object"&&(breadcrumb.data=scrubEventData(breadcrumb.data))}function scrubSentryContexts(event){if(event.contexts)for(const[ctxKey,ctx]of Object.entries(event.contexts))ctx&&typeof ctx=="object"&&(event.contexts[ctxKey]=scrubEventData(ctx))}function scrubSentryRecordField(event,key){const target=event,value=target[key];value&&typeof value=="object"&&(target[key]=scrubEventData(value))}const beforeSend=event=>{if(isExpectedCliErrorEvent(event)||isKnownNoisyConsoleEvent(event))return null;isNodeRuntimeWarningEvent(event)&&(event.level="warning",event.tags={...event.tags,"pm.diagnostic_class":"node_runtime_warning"}),event.message&&(event.message=scrubString(event.message,"message")),event.transaction&&(event.transaction=scrubString(event.transaction,"transaction")),scrubSentryExceptionValues(event),scrubSentryBreadcrumbs(event),scrubSentryRecordField(event,"extra"),scrubSentryContexts(event);for(const key of["request","user","tags"])scrubSentryRecordField(event,key);return event},beforeSendTransaction=event=>(event.breadcrumbs&&(event.breadcrumbs=event.breadcrumbs.filter(breadcrumb=>!isPmCliErrorBreadcrumb(breadcrumb)&&!isKnownNoisyConsoleBreadcrumb(breadcrumb)),scrubSentryBreadcrumbs(event)),scrubSentryContexts(event),event),beforeBreadcrumb=breadcrumb=>isPmCliErrorBreadcrumb(breadcrumb)||isKnownNoisyConsoleBreadcrumb(breadcrumb)?null:(breadcrumb.message&&(breadcrumb.message=scrubString(breadcrumb.message,"message")),breadcrumb.data&&typeof breadcrumb.data=="object"&&(breadcrumb.data=scrubEventData(breadcrumb.data)),breadcrumb);async function ensureSentryInit(){if(_initDone)return _sentry;if(_initDone=!0,isSentryDisabled())return;const SentryModule=_loadSentry();_sentry=SentryModule;const dsn=process.env.SENTRY_DSN?.trim()||PM_CLI_SENTRY_DSN,release=resolveCliVersion();return SentryModule.init({dsn,release:`pm-cli@${release}`,environment:resolveEnvironment(),tracesSampleRate:resolveTracesSampleRate(),enableLogs:!0,attachStacktrace:!0,normalizeDepth:6,shutdownTimeout:3e3,sendDefaultPii:!1,serverName:void 0,integrations:[SentryModule.extraErrorDataIntegration({depth:4}),SentryModule.captureConsoleIntegration({levels:["warn","error"]})],initialScope:{tags:{"cli.name":"pm-cli","cli.version":release,"runtime.node":process.version,"runtime.platform":process.platform,"runtime.arch":process.arch}},beforeSend,beforeSendTransaction,beforeBreadcrumb}),SentryModule}function getSentry(){return _sentry}const _testOnly={isExpectedCliErrorEvent,isKnownNoisyConsoleEvent,isNodeRuntimeWarningEvent,isPmCliErrorBreadcrumb,isKnownNoisyConsoleBreadcrumb,scrubString,scrubEventData,resolveTracesSampleRate,KNOWN_NOISY_CONSOLE_MESSAGE_PATTERNS,MAX_KNOWN_NOISY_CONSOLE_MESSAGE_PATTERNS,defaultSentryLoader,setSentryLoaderForTests(loader){_loadSentry=loader??defaultSentryLoader},resetSentryStateForTests(){_sentry=void 0,_initDone=!1}};export{_testOnly,ensureSentryInit,getSentry};
|
|
2
2
|
//# sourceMappingURL=instrument.js.map
|