kaijibot 2026.8.21 → 2026.8.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +1 -1
- package/README.md +1 -1
- package/dist/.buildstamp +1 -1
- package/dist/abort-Bg5O8Yiz.js +202 -0
- package/dist/abort-cutoff.runtime-CvjKPRCc.js +20 -0
- package/dist/abort-cutoff.runtime.js +1 -1
- package/dist/abort.runtime-UZvtDM6M.js +2 -0
- package/dist/abort.runtime.js +1 -1
- package/dist/acp-cli-BHDaxHbu.js +2171 -0
- package/dist/acp-spawn-BJJ8QbXE.js +1024 -0
- package/dist/acp-stateful-target-driver-DyZ1dneY.js +88 -0
- package/dist/action-agents-Bx5S-ZYL.js +67 -0
- package/dist/action-focus-DGURwLDo.js +124 -0
- package/dist/action-help-7ey3e-V9.js +7 -0
- package/dist/action-info-BxQpOqFZ.js +58 -0
- package/dist/action-kill-C7kGSXgP.js +33 -0
- package/dist/action-list-cwGVroWS.js +21 -0
- package/dist/action-log-DT-bRM9X.js +30 -0
- package/dist/action-send-BNv-Wz-l.js +39 -0
- package/dist/action-spawn-DkEYjxPF.js +46 -0
- package/dist/action-unfocus-CU1WRop0.js +28 -0
- package/dist/agent-BOaVCAE9.js +2 -0
- package/dist/agent-command-0Ie27CS4.js +1479 -0
- package/dist/agent-runner-utils-fBrjJUeq.js +202 -0
- package/dist/agent-runner.runtime-DEArTfVM.js +2825 -0
- package/dist/agent-runner.runtime.js +1 -1
- package/dist/agents/auth-profiles.runtime.js +1 -1
- package/dist/agents/model-catalog.runtime.js +1 -1
- package/dist/agents/models-config.runtime.js +1 -1
- package/dist/agents/pi-model-discovery-runtime.js +1 -1
- package/dist/agents-CH6NQBfT.js +5 -0
- package/dist/agents-DuBi4yGs.js +887 -0
- package/dist/anthropic-vertex-stream-C-dr7gew.js +5666 -0
- package/dist/api-C-d6hJ6R.js +3 -0
- package/dist/api-CWzMTsre.js +35 -0
- package/dist/api-CspIEuoI.js +4 -0
- package/dist/api-DWfH8UCU.js +19 -0
- package/dist/api-DnP8S2bH.js +5 -0
- package/dist/api-Y8trG2YC.js +2 -0
- package/dist/api-fZ1Mwhb9.js +2 -0
- package/dist/api-inKLxoen.js +45 -0
- package/dist/api-plrtNPKq.js +2 -0
- package/dist/api-tiV4Lam3.js +2 -0
- package/dist/apply-DyMW1n_a.js +493 -0
- package/dist/apply.runtime-BOvle-IJ.js +166 -0
- package/dist/apply.runtime-C0ny2nmc.js +2 -0
- package/dist/apply.runtime.js +1 -1
- package/dist/approval-client-helpers-Ss4gUaso.js +82 -0
- package/dist/approval-gateway-resolver-D6xh0K2G.js +58 -0
- package/dist/approval-gateway-runtime-CffF6RIQ.js +2 -0
- package/dist/approval-handler-runtime-p9BmT1Xf.js +439 -0
- package/dist/approval-native-runtime-DN73OHKf.js +709 -0
- package/dist/approval-renderers-CITEnajR.js +64 -0
- package/dist/asr-Jt-OmxEb.js +196 -0
- package/dist/audit-BM_BshdA.js +885 -0
- package/dist/audit-extra.async-Cvm-ViC4.js +847 -0
- package/dist/audit.deep.runtime-Ccabqd1Y.js +2 -0
- package/dist/audit.deep.runtime.js +1 -1
- package/dist/audit.nondeep.runtime-BNrDSb24.js +859 -0
- package/dist/audit.nondeep.runtime.js +1 -1
- package/dist/audit.runtime-BKUEHsrE.js +7 -0
- package/dist/audit.runtime.js +1 -1
- package/dist/auth-Dt8gUUJi.js +181 -0
- package/dist/auth-choice-BC_BWYZD.js +3 -0
- package/dist/auth-choice-BtwWAcEq.js +71 -0
- package/dist/auth-choice-CO__21te.js +353 -0
- package/dist/auth-choice-options-BxgjFsFO.js +104 -0
- package/dist/auth-choice-prompt-B-P39mib.js +2 -0
- package/dist/auth-choice-prompt-Dp7Vptqj.js +36 -0
- package/dist/auth-choice.plugin-providers.runtime-BJqmauZz.js +11 -0
- package/dist/auth-choice.plugin-providers.runtime.js +1 -1
- package/dist/auth-health-CPclIUZ3.js +165 -0
- package/dist/auth-profiles-P49vCUs4.js +438 -0
- package/dist/auth-profiles.runtime-pIuc_0v-.js +7 -0
- package/dist/auth-profiles.runtime.js +1 -1
- package/dist/auto-recall-Dm-J3oEj.js +78 -0
- package/dist/backup-create-DcO0pYFy.js +391 -0
- package/dist/banner-CIw8Yepm.js +2 -0
- package/dist/banner-w4GNKrs6.js +281 -0
- package/dist/binding-routing-upMo3iCO.js +50 -0
- package/dist/binding-targets-C9WygzAM.js +99 -0
- package/dist/bridge-server-Cu0xkN0E.js +103 -0
- package/dist/browser-config-runtime-3QVJiqnP.js +6 -0
- package/dist/browser-control-auth-BkunTzw7.js +120 -0
- package/dist/browser-node-runtime-BusKdg2E.js +12 -0
- package/dist/browser-profiles-BocOxjqC.js +170 -0
- package/dist/browser-runtime-D3goJLF9.js +377 -0
- package/dist/browser-setup-tools-j-IDYASL.js +12 -0
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +4 -4
- package/dist/bundled/session-memory/handler.js +2 -2
- package/dist/call-CMDK9Mqx.js +2 -0
- package/dist/call-Cisydyym.js +495 -0
- package/dist/call.runtime-CJUaD_Ck.js +2 -0
- package/dist/call.runtime.js +1 -1
- package/dist/capability-cli-e_bf338W.js +1357 -0
- package/dist/catalog-provider-D5mzbnCM.js +40 -0
- package/dist/cdp.helpers-BqVqEY02.js +372 -0
- package/dist/channel-core-cQ4DROoP.js +5 -0
- package/dist/channel-summary-BHojSrOd.js +139 -0
- package/dist/channel-summary-CzjCL-4-.js +2 -0
- package/dist/channel.runtime-D6e2VBFb.js +399 -0
- package/dist/channel.runtime.js +1 -1
- package/dist/channels-cli-Y-Wnalvd.js +248 -0
- package/dist/channels-uiGUmLk2.js +1147 -0
- package/dist/chat-CQc5lJAu.js +213 -0
- package/dist/chrome-BcU0ZvUn.js +1080 -0
- package/dist/chrome.executables-Dp0Lkjmz.js +550 -0
- package/dist/cli/daemon-cli.js +1 -1
- package/dist/cli-BGB7qdp3.js +191 -0
- package/dist/cli-BtTS8CKF.js +2 -0
- package/dist/cli-CQX3q4Fm.js +57 -0
- package/dist/cli-ZLAF588A.js +154 -0
- package/dist/cli-auth-seam-D-Qci5-b.js +14 -0
- package/dist/cli-backend-DxaeTZ8N.js +66 -0
- package/dist/cli-g4KJW_UT.js +2 -0
- package/dist/cli-migration-B2SFdY0j.js +127 -0
- package/dist/cli-runner-BVQt0v1D.js +1662 -0
- package/dist/cli-runner.runtime-BAMS4uW0.js +3 -0
- package/dist/cli-runner.runtime-H3alxbDK.js +2 -0
- package/dist/cli-runner.runtime.js +1 -1
- package/dist/cli-shared-BaJRfEqD.js +142 -0
- package/dist/cli-startup-metadata.json +2 -2
- package/dist/cli.runtime-CQ1qvGdJ.js +819 -0
- package/dist/cli.runtime.js +1 -1
- package/dist/client-bootstrap-BE7PiMJr.js +28 -0
- package/dist/codex-native-web-search-TdFXLTHZ.js +2 -0
- package/dist/codex-native-web-search-dKQT4ZPV.js +156 -0
- package/dist/collector-BXDPP4rJ.js +2 -0
- package/dist/collector-CT3qBEYi.js +424 -0
- package/dist/command-auth-FR5r0kKW.js +75 -0
- package/dist/command-config-resolution-BfTLOZxI.js +23 -0
- package/dist/command-config-resolution-GV0h_B0u.js +2 -0
- package/dist/command-execution-startup-oMdUg9Py.js +269 -0
- package/dist/command-format-CZ8oMoC9.js +2 -0
- package/dist/command-queue-BlORGS1M.js +260 -0
- package/dist/command-registry-DNKWkedC.js +3 -0
- package/dist/command-registry-DO6fBZ31.js +113 -0
- package/dist/command-secret-gateway-Cnjliq_k.js +528 -0
- package/dist/commands-acp-OeD4TGXU.js +1017 -0
- package/dist/commands-compact.runtime-ZE5b-Pvj.js +10 -0
- package/dist/commands-compact.runtime.js +1 -1
- package/dist/commands-core.runtime-Ca3exd9B.js +2 -0
- package/dist/commands-core.runtime.js +1 -1
- package/dist/commands-handlers.runtime-DKL8ULNw.js +3762 -0
- package/dist/commands-handlers.runtime.js +1 -1
- package/dist/commands-models-uaQEC1GX.js +306 -0
- package/dist/commands-reset-hooks-0RFpUGBC.js +129 -0
- package/dist/commands-status-4HTjDVIN.js +223 -0
- package/dist/commands-status.runtime-CyJiWLQs.js +2 -0
- package/dist/commands-status.runtime.js +1 -1
- package/dist/commands-subagents-control.runtime-B3DtD7Se.js +3 -0
- package/dist/commands-subagents-control.runtime-BLHWicyx.js +2 -0
- package/dist/commands-subagents-control.runtime.js +1 -1
- package/dist/commands.runtime-Bk9-pUEs.js +103 -0
- package/dist/commands.runtime.js +1 -1
- package/dist/comment-shared-BCggDOtV.js +40 -0
- package/dist/compact-CBJu2_ft.js +11324 -0
- package/dist/compact.runtime-Bj3PGRRh.js +7 -0
- package/dist/compact.runtime.js +1 -1
- package/dist/completion-cli-B27D7vni.js +468 -0
- package/dist/completion-cli-QdkbM0Vz.js +2 -0
- package/dist/config-BZb7_jO5.js +166 -0
- package/dist/config-C2M27bOw.js +8 -0
- package/dist/config-D_fICGrQ.js +53 -0
- package/dist/config-cli-B7j3KePQ.js +948 -0
- package/dist/config-defaults-XFEo6I7v.js +163 -0
- package/dist/config-guard-wGGj2x7b.js +94 -0
- package/dist/config-runtime-xwO8vvQP.js +14 -0
- package/dist/config-validation-tPbNhbrH.js +279 -0
- package/dist/configure-CXFWPXal.js +1162 -0
- package/dist/configure-lBR_2rAt.js +2 -0
- package/dist/connection-auth-ClCO21bT.js +30 -0
- package/dist/context-CJMC7SyI.js +249 -0
- package/dist/context-CWC_tVM8.js +2 -0
- package/dist/context-writer-DNkMBOu9.js +290 -0
- package/dist/control-auth-DUZs9D8n.js +122 -0
- package/dist/control-ui/assets/agents-HENIRhRj.js +767 -0
- package/dist/control-ui/assets/anthropic-DlOZcqqy.js +40 -0
- package/dist/control-ui/assets/azure-openai-responses-BmSDwKAQ.js +2 -0
- package/dist/control-ui/assets/cron-B2CJajqc.js +744 -0
- package/dist/control-ui/assets/dialogues-DmWmdbMF.js +83 -0
- package/dist/control-ui/assets/history-CP7LOJan.js +71 -0
- package/dist/control-ui/assets/index-BsGBtIKy.css +1 -0
- package/dist/control-ui/assets/index-BtNFbQhY.js +2686 -0
- package/dist/control-ui/assets/mistral-CYEJ-E7G.js +72 -0
- package/dist/control-ui/assets/openai-codex-responses-BnLjDxo3.js +8 -0
- package/dist/control-ui/assets/openai-completions-D46D4eD2.js +6 -0
- package/dist/control-ui/assets/openai-responses-CNVWXuC0.js +2 -0
- package/dist/control-ui/assets/openai-responses-shared-ByeOE-gc.js +13 -0
- package/dist/control-ui/index.html +2 -2
- package/dist/conversation-id-DlazDTmW.js +140 -0
- package/dist/conversation-runtime-BjljNAU1.js +31 -0
- package/dist/core-4Dt1_PpO.js +210 -0
- package/dist/cron-cli-CTGN3Kum.js +637 -0
- package/dist/curator-BM2jeaou.js +600 -0
- package/dist/curator-_QLWjb7r.js +2 -0
- package/dist/daemon-cli-BLe7aLfJ.js +476 -0
- package/dist/daemon-install-BneaHOcs.js +70 -0
- package/dist/delegate-CyUm6mk6.js +61 -0
- package/dist/deliver-BvUx9v-a.js +3 -0
- package/dist/deliver-DQbRPHSb.js +782 -0
- package/dist/deliver-runtime-ERlRZAW4.js +2 -0
- package/dist/delivery-outbound.runtime-Bi6Lu4JP.js +6 -0
- package/dist/delivery-outbound.runtime.js +1 -1
- package/dist/delivery-queue-B4kCxhnW.js +2 -0
- package/dist/delivery-queue-DDHwRyN-.js +372 -0
- package/dist/deps-DZQeVHSD.js +60 -0
- package/dist/devices-cli-CFSjN2KZ.js +336 -0
- package/dist/diagnostic-Bh12mVkv.js +311 -0
- package/dist/direct-dm-Bn07LLbq.js +139 -0
- package/dist/directive-handling.fast-lane-Cd6SSr-l.js +64 -0
- package/dist/directive-handling.fast-lane-ejwgECy7.js +2 -0
- package/dist/directive-handling.impl-Bpy5KQZr.js +659 -0
- package/dist/directive-handling.impl-ZEKrT-pi.js +2 -0
- package/dist/directive-handling.parse-COyCTXvI.js +376 -0
- package/dist/directive-handling.persist-CgxhTMmz.js +139 -0
- package/dist/directive-handling.persist.runtime-4pppF2CM.js +2 -0
- package/dist/directive-handling.persist.runtime.js +1 -1
- package/dist/directive-handling.shared-BuNzwbwp.js +159 -0
- package/dist/directory-cli-gWQfdmFR.js +240 -0
- package/dist/dispatch-Cg_O6HsU.js +1126 -0
- package/dist/dispatch-acp-C7kPkeqX.js +969 -0
- package/dist/dispatch-acp-manager.runtime-Bh3V5wGh.js +3 -0
- package/dist/dispatch-acp-manager.runtime.js +1 -1
- package/dist/dispatch-acp-media.runtime-pWY6A7VY.js +3 -0
- package/dist/dispatch-acp-media.runtime.js +1 -1
- package/dist/dispatch-acp-session.runtime-DdkuSkq8.js +2 -0
- package/dist/dispatch-acp-session.runtime.js +1 -1
- package/dist/dispatch-acp.runtime-fr_7acr8.js +19 -0
- package/dist/dispatch-acp.runtime.js +1 -1
- package/dist/dns-cli-C4uepTJE.js +193 -0
- package/dist/docs-cli-DWzfteG6.js +156 -0
- package/dist/doctor-completion-D2s3ieS6.js +90 -0
- package/dist/doctor-config-preflight-BIf8igIW.js +148 -0
- package/dist/doctor-config-preflight-BiJSPUPg.js +2 -0
- package/dist/doctor-state-migrations-BbfPLoLz.js +2 -0
- package/dist/doctor-state-migrations-DFQets45.js +3 -0
- package/dist/drive-CvbBPFcl.js +718 -0
- package/dist/embedding-provider-DUT_HxYD.js +26 -0
- package/dist/embedding-provider-DjVEIg-4.js +33 -0
- package/dist/embedding-provider-TKNNnQ3m.js +129 -0
- package/dist/engine-CT4xJJ-H.js +82 -0
- package/dist/engine-embeddings-BN4uJOv0.js +1489 -0
- package/dist/entry-capabilities-BhpTqh0w.js +89 -0
- package/dist/entry.js +2 -2
- package/dist/env-overrides-Dn5yy0l4.js +347 -0
- package/dist/env-overrides.runtime-DdD841Km.js +7 -0
- package/dist/env-overrides.runtime.js +1 -1
- package/dist/exec-approval-forwarder.runtime-CV81fvQh.js +3 -0
- package/dist/exec-approval-forwarder.runtime.js +1 -1
- package/dist/exec-approval-reply-C_NfihTE.js +292 -0
- package/dist/exec-approvals-cli-DKOFcUAn.js +485 -0
- package/dist/exec-defaults-Cs1FwIKH.js +1440 -0
- package/dist/extensionAPI.js +4 -4
- package/dist/extensions/alibaba/index.js +1 -1
- package/dist/extensions/alibaba/video-generation-provider.js +1 -1
- package/dist/extensions/anthropic/api.js +2 -2
- package/dist/extensions/anthropic/cli-auth-seam.js +1 -1
- package/dist/extensions/anthropic/cli-backend-api.js +2 -2
- package/dist/extensions/anthropic/cli-backend.js +1 -1
- package/dist/extensions/anthropic/cli-migration.js +1 -1
- package/dist/extensions/anthropic/cli-shared.js +1 -1
- package/dist/extensions/anthropic/config-defaults.js +1 -1
- package/dist/extensions/anthropic/contract-api.js +1 -1
- package/dist/extensions/anthropic/index.js +1 -1
- package/dist/extensions/anthropic/media-understanding-provider.js +1 -1
- package/dist/extensions/anthropic/provider-policy-api.js +1 -1
- package/dist/extensions/anthropic/register.runtime.js +1 -1
- package/dist/extensions/anthropic/setup-api.js +1 -1
- package/dist/extensions/anthropic/stream-wrappers.js +1 -1
- package/dist/extensions/anthropic/test-api.js +3 -3
- package/dist/extensions/anthropic-vertex/api.js +3 -3
- package/dist/extensions/anthropic-vertex/index.js +2 -2
- package/dist/extensions/anthropic-vertex/provider-catalog.js +1 -1
- package/dist/extensions/anthropic-vertex/region.js +1 -1
- package/dist/extensions/anthropic-vertex/setup-api.js +1 -1
- package/dist/extensions/arcee/index.js +2 -2
- package/dist/extensions/browser/browser-bridge.js +1 -1
- package/dist/extensions/browser/browser-cdp.js +1 -1
- package/dist/extensions/browser/browser-config.js +3 -3
- package/dist/extensions/browser/browser-control-auth.js +1 -1
- package/dist/extensions/browser/browser-doctor.js +4 -4
- package/dist/extensions/browser/browser-host-inspection.js +1 -1
- package/dist/extensions/browser/browser-maintenance.js +2 -2
- package/dist/extensions/browser/browser-profiles.js +1 -1
- package/dist/extensions/browser/browser-runtime-api.js +11 -11
- package/dist/extensions/browser/index.js +1 -1
- package/dist/extensions/browser/plugin-registration.js +1 -1
- package/dist/extensions/browser/register.runtime.js +3 -3
- package/dist/extensions/browser/runtime-api.js +12 -12
- package/dist/extensions/browser/setup-api.js +2 -2
- package/dist/extensions/browser/test-support.js +1 -1
- package/dist/extensions/byteplus/index.js +3 -3
- package/dist/extensions/byteplus/video-generation-provider.js +1 -1
- package/dist/extensions/cerebras/index.js +1 -1
- package/dist/extensions/chutes/api.js +3 -3
- package/dist/extensions/chutes/index.js +7 -7
- package/dist/extensions/chutes/models.js +1 -1
- package/dist/extensions/chutes/onboard.js +2 -2
- package/dist/extensions/chutes/provider-catalog.js +1 -1
- package/dist/extensions/cloudflare-ai-gateway/api.js +1 -1
- package/dist/extensions/cloudflare-ai-gateway/catalog-provider.js +1 -1
- package/dist/extensions/cloudflare-ai-gateway/index.js +6 -6
- package/dist/extensions/deepinfra/api.js +3 -3
- package/dist/extensions/deepinfra/embedding-provider.js +1 -1
- package/dist/extensions/deepinfra/index.js +4 -4
- package/dist/extensions/deepinfra/media-understanding-provider.js +1 -1
- package/dist/extensions/deepinfra/memory-embedding-adapter.js +1 -1
- package/dist/extensions/deepinfra/video-generation-provider.js +1 -1
- package/dist/extensions/deepseek/index.js +1 -1
- package/dist/extensions/device-pair/api.js +2 -2
- package/dist/extensions/device-pair/index.js +5 -5
- package/dist/extensions/device-pair/notify.js +1 -1
- package/dist/extensions/device-pair/pair-command-approve.js +1 -1
- package/dist/extensions/device-pair/qr-image.js +2 -2
- package/dist/extensions/diffs/.kaijibot-runtime-deps-stamp.json +1 -1
- package/dist/extensions/diffs/index.js +1 -1
- package/dist/extensions/diffs/node_modules/.package-lock.json +3 -3
- package/dist/extensions/diffs/node_modules/typebox/build/format/email.mjs +1 -1
- package/dist/extensions/diffs/node_modules/typebox/build/format/idna/idn-hostname.mjs +19 -1
- package/dist/extensions/diffs/node_modules/typebox/package.json +1 -1
- package/dist/extensions/exa/index.js +1 -1
- package/dist/extensions/feishu/.kaijibot-runtime-deps-stamp.json +1 -1
- package/dist/extensions/feishu/api.js +16 -16
- package/dist/extensions/feishu/contract-api.js +2 -2
- package/dist/extensions/feishu/node_modules/.package-lock.json +3 -3
- package/dist/extensions/feishu/node_modules/typebox/build/format/email.mjs +1 -1
- package/dist/extensions/feishu/node_modules/typebox/build/format/idna/idn-hostname.mjs +19 -1
- package/dist/extensions/feishu/node_modules/typebox/package.json +1 -1
- package/dist/extensions/feishu/runtime-api.js +2 -2
- package/dist/extensions/feishu/security-contract-api.js +1 -1
- package/dist/extensions/feishu/session-key-api.js +1 -1
- package/dist/extensions/feishu/setup-api.js +1 -1
- package/dist/extensions/fireworks/index.js +1 -1
- package/dist/extensions/github-copilot/api.js +1 -1
- package/dist/extensions/github-copilot/index.js +6 -6
- package/dist/extensions/github-copilot/login.js +1 -1
- package/dist/extensions/github-copilot/models-defaults.js +1 -1
- package/dist/extensions/github-copilot/models.js +1 -1
- package/dist/extensions/github-copilot/register.runtime.js +4 -4
- package/dist/extensions/github-copilot/replay-policy.js +1 -1
- package/dist/extensions/google/api.js +1 -1
- package/dist/extensions/google/gemini-cli-provider.js +1 -1
- package/dist/extensions/google/image-generation-provider.js +1 -1
- package/dist/extensions/google/index.js +5 -5
- package/dist/extensions/google/media-understanding-provider.js +1 -1
- package/dist/extensions/google/music-generation-provider.js +1 -1
- package/dist/extensions/google/oauth-token-shared.js +1 -1
- package/dist/extensions/google/oauth.credentials.js +1 -1
- package/dist/extensions/google/oauth.flow.js +1 -1
- package/dist/extensions/google/oauth.js +2 -2
- package/dist/extensions/google/oauth.runtime.js +1 -1
- package/dist/extensions/google/oauth.settings.js +1 -1
- package/dist/extensions/google/oauth.token.js +1 -1
- package/dist/extensions/google/provider-models.js +1 -1
- package/dist/extensions/google/provider-registration.js +1 -1
- package/dist/extensions/google/runtime-api.js +2 -2
- package/dist/extensions/google/test-api.js +2 -2
- package/dist/extensions/google/video-generation-provider.js +1 -1
- package/dist/extensions/google/web-search-provider.js +1 -1
- package/dist/extensions/groq/index.js +1 -1
- package/dist/extensions/groq/media-understanding-provider.js +1 -1
- package/dist/extensions/groq/test-api.js +1 -1
- package/dist/extensions/huggingface/api.js +3 -3
- package/dist/extensions/huggingface/index.js +3 -3
- package/dist/extensions/huggingface/models.js +1 -1
- package/dist/extensions/huggingface/onboard.js +1 -1
- package/dist/extensions/huggingface/provider-catalog.js +2 -2
- package/dist/extensions/image-generation-core/api.js +2 -2
- package/dist/extensions/image-generation-core/runtime-api.js +2 -2
- package/dist/extensions/kilocode/api.js +2 -2
- package/dist/extensions/kilocode/index.js +6 -6
- package/dist/extensions/kilocode/onboard.js +2 -2
- package/dist/extensions/kilocode/provider-catalog.js +1 -1
- package/dist/extensions/kilocode/provider-models.js +1 -1
- package/dist/extensions/kilocode/shared.js +1 -1
- package/dist/extensions/kimi-coding/index.js +3 -3
- package/dist/extensions/kindle-portal/.kaijibot-runtime-deps-stamp.json +1 -1
- package/dist/extensions/kindle-portal/node_modules/.package-lock.json +3 -3
- package/dist/extensions/kindle-portal/node_modules/typebox/build/format/email.mjs +1 -1
- package/dist/extensions/kindle-portal/node_modules/typebox/build/format/idna/idn-hostname.mjs +19 -1
- package/dist/extensions/kindle-portal/node_modules/typebox/package.json +1 -1
- package/dist/extensions/knowledge-wiki/index.js +2 -2
- package/dist/extensions/litellm/index.js +1 -1
- package/dist/extensions/llm-task/index.js +1 -1
- package/dist/extensions/lmstudio/api.js +6 -6
- package/dist/extensions/lmstudio/index.js +2 -2
- package/dist/extensions/lmstudio/runtime-api.js +1 -1
- package/dist/extensions/media-understanding-core/runtime-api.js +2 -2
- package/dist/extensions/memory-core/cli-metadata.js +2 -2
- package/dist/extensions/memory-core/index.js +12 -12
- package/dist/extensions/memory-core/manager-runtime.js +1 -1
- package/dist/extensions/memory-core/runtime-api.js +5 -5
- package/dist/extensions/memory-lancedb/cli-metadata.js +1 -1
- package/dist/extensions/memory-lancedb/index.js +1 -1
- package/dist/extensions/microsoft/index.js +1 -1
- package/dist/extensions/microsoft/speech-provider.js +1 -1
- package/dist/extensions/microsoft/test-api.js +1 -1
- package/dist/extensions/microsoft/tts.js +1 -1
- package/dist/extensions/microsoft-foundry/auth.js +1 -1
- package/dist/extensions/microsoft-foundry/cli.js +1 -1
- package/dist/extensions/microsoft-foundry/index.js +1 -1
- package/dist/extensions/microsoft-foundry/onboard.js +2 -2
- package/dist/extensions/microsoft-foundry/provider.js +1 -1
- package/dist/extensions/microsoft-foundry/runtime.js +1 -1
- package/dist/extensions/microsoft-foundry/shared-runtime.js +2 -2
- package/dist/extensions/microsoft-foundry/shared.js +1 -1
- package/dist/extensions/minimax/image-generation-provider.js +1 -1
- package/dist/extensions/minimax/index.js +7 -7
- package/dist/extensions/minimax/media-understanding-provider.js +1 -1
- package/dist/extensions/minimax/music-generation-provider.js +1 -1
- package/dist/extensions/minimax/oauth.js +1 -1
- package/dist/extensions/minimax/oauth.runtime.js +1 -1
- package/dist/extensions/minimax/provider-registration.js +1 -1
- package/dist/extensions/minimax/speech-provider.js +1 -1
- package/dist/extensions/minimax/test-api.js +2 -2
- package/dist/extensions/minimax/video-generation-provider.js +1 -1
- package/dist/extensions/minimax/web-search-provider.js +1 -1
- package/dist/extensions/mistral/embedding-provider.js +1 -1
- package/dist/extensions/mistral/index.js +2 -2
- package/dist/extensions/mistral/media-understanding-provider.js +1 -1
- package/dist/extensions/mistral/memory-embedding-adapter.js +3 -3
- package/dist/extensions/mistral/test-api.js +1 -1
- package/dist/extensions/moonshot/index.js +5 -5
- package/dist/extensions/moonshot/media-understanding-provider.js +1 -1
- package/dist/extensions/moonshot/test-api.js +2 -2
- package/dist/extensions/moonshot/web-search-provider.js +1 -1
- package/dist/extensions/nvidia/index.js +1 -1
- package/dist/extensions/ollama/api.js +3 -3
- package/dist/extensions/ollama/index.js +6 -6
- package/dist/extensions/ollama/runtime-api.js +2 -2
- package/dist/extensions/ollama/web-search-provider.js +1 -1
- package/dist/extensions/openai/api.js +3 -3
- package/dist/extensions/openai/image-generation-provider.js +1 -1
- package/dist/extensions/openai/index.js +9 -9
- package/dist/extensions/openai/media-understanding-provider.js +1 -1
- package/dist/extensions/openai/openai-codex-auth-identity.js +1 -1
- package/dist/extensions/openai/openai-codex-cli-auth.js +1 -1
- package/dist/extensions/openai/openai-codex-provider.js +1 -1
- package/dist/extensions/openai/openai-codex-shared.js +1 -1
- package/dist/extensions/openai/openai-provider.js +1 -1
- package/dist/extensions/openai/prompt-overlay.js +1 -1
- package/dist/extensions/openai/realtime-provider-shared.js +1 -1
- package/dist/extensions/openai/realtime-transcription-provider.js +1 -1
- package/dist/extensions/openai/realtime-voice-provider.js +1 -1
- package/dist/extensions/openai/register.runtime.js +8 -8
- package/dist/extensions/openai/shared.js +1 -1
- package/dist/extensions/openai/speech-provider.js +1 -1
- package/dist/extensions/openai/test-api.js +5 -5
- package/dist/extensions/openai/transport-policy.js +1 -1
- package/dist/extensions/openai/video-generation-provider.js +1 -1
- package/dist/extensions/opencode/index.js +3 -3
- package/dist/extensions/opencode-go/index.js +2 -2
- package/dist/extensions/openrouter/api.js +2 -2
- package/dist/extensions/openrouter/image-generation-provider.js +1 -1
- package/dist/extensions/openrouter/index.js +6 -6
- package/dist/extensions/openrouter/media-understanding-provider.js +1 -1
- package/dist/extensions/openrouter/music-generation-provider.js +1 -1
- package/dist/extensions/openrouter/test-api.js +3 -3
- package/dist/extensions/openrouter/video-generation-provider.js +1 -1
- package/dist/extensions/openshell/index.js +4 -4
- package/dist/extensions/qianfan/index.js +1 -1
- package/dist/extensions/qwen/index.js +3 -3
- package/dist/extensions/qwen/media-understanding-provider.js +1 -1
- package/dist/extensions/qwen/test-api.js +2 -2
- package/dist/extensions/qwen/video-generation-provider.js +1 -1
- package/dist/extensions/runway/index.js +1 -1
- package/dist/extensions/runway/video-generation-provider.js +1 -1
- package/dist/extensions/sglang/api.js +2 -2
- package/dist/extensions/sglang/index.js +2 -2
- package/dist/extensions/sglang/models.js +1 -1
- package/dist/extensions/sherpa-speech/asr.js +1 -1
- package/dist/extensions/sherpa-speech/engine.js +1 -1
- package/dist/extensions/sherpa-speech/index.js +1 -1
- package/dist/extensions/speech-core/api.js +2 -2
- package/dist/extensions/speech-core/runtime-api.js +4 -4
- package/dist/extensions/stepfun/index.js +2 -2
- package/dist/extensions/talk-voice/index.js +3 -3
- package/dist/extensions/tavily/index.js +1 -1
- package/dist/extensions/together/index.js +1 -1
- package/dist/extensions/together/video-generation-provider.js +1 -1
- package/dist/extensions/venice/api.js +3 -3
- package/dist/extensions/venice/index.js +5 -5
- package/dist/extensions/venice/models.js +1 -1
- package/dist/extensions/venice/onboard.js +2 -2
- package/dist/extensions/venice/provider-catalog.js +1 -1
- package/dist/extensions/vercel-ai-gateway/index.js +1 -1
- package/dist/extensions/vllm/api.js +2 -2
- package/dist/extensions/vllm/index.js +2 -2
- package/dist/extensions/vllm/models.js +1 -1
- package/dist/extensions/vllm/register.runtime.js +2 -2
- package/dist/extensions/volcengine/index.js +2 -2
- package/dist/extensions/vydra/image-generation-provider.js +1 -1
- package/dist/extensions/vydra/index.js +5 -5
- package/dist/extensions/vydra/shared.js +1 -1
- package/dist/extensions/vydra/speech-provider.js +1 -1
- package/dist/extensions/vydra/video-generation-provider.js +1 -1
- package/dist/extensions/webhooks/.kaijibot-runtime-deps-stamp.json +1 -1
- package/dist/extensions/webhooks/api.js +1 -1
- package/dist/extensions/webhooks/index.js +3 -3
- package/dist/extensions/webhooks/runtime-api.js +1 -1
- package/dist/extensions/wechat/api.js +3 -3
- package/dist/extensions/xai/api.js +5 -5
- package/dist/extensions/xai/code-execution.js +3 -3
- package/dist/extensions/xai/index.js +9 -9
- package/dist/extensions/xai/model-definitions.js +1 -1
- package/dist/extensions/xai/onboard.js +1 -1
- package/dist/extensions/xai/provider-catalog.js +1 -1
- package/dist/extensions/xai/provider-models.js +1 -1
- package/dist/extensions/xai/setup-api.js +1 -1
- package/dist/extensions/xai/video-generation-provider.js +1 -1
- package/dist/extensions/xai/web-search.js +1 -1
- package/dist/extensions/xai/x-search.js +3 -3
- package/dist/extensions/xiaomi/index.js +1 -1
- package/dist/extensions/zai/index.js +5 -5
- package/dist/extensions/zai/media-understanding-provider.js +1 -1
- package/dist/extensions/zai/test-api.js +1 -1
- package/dist/extra-params-CEZLNZPM.js +295 -0
- package/dist/format-P9xNDyfD.js +245 -0
- package/dist/fragment-collector-D6OalgG0.js +189 -0
- package/dist/gateway-cli-Zfvn259p.js +1532 -0
- package/dist/gateway-install-token-6z725yP4.js +284 -0
- package/dist/gateway-rpc-BIq75xob.js +14 -0
- package/dist/gateway-rpc.runtime-qaUC59kw.js +23 -0
- package/dist/gateway-rpc.runtime.js +1 -1
- package/dist/gemini-cli-provider-DapCuX8Q.js +106 -0
- package/dist/gemini-web-search-provider-qckYFHgT.js +167 -0
- package/dist/get-reply-from-config.runtime-DHsGpgGI.js +2 -0
- package/dist/get-reply-from-config.runtime.js +1 -1
- package/dist/gmail-setup-utils-Cc3pRzTO.js +422 -0
- package/dist/health-3b-YI19K.js +579 -0
- package/dist/health-MLtfjMov.js +2 -0
- package/dist/heartbeat-runner-BUj0aHm6.js +4 -0
- package/dist/heartbeat-runner-CsnBv3An.js +1365 -0
- package/dist/heartbeat-runner.runtime-DYHZ3Vol.js +2 -0
- package/dist/heartbeat-runner.runtime.js +1 -1
- package/dist/help-ktSd2tag.js +76 -0
- package/dist/hooks-cli-IZb2tmWn.js +364 -0
- package/dist/image-C3lHN8WH.js +152 -0
- package/dist/image-generation-core-Csa-tOLR.js +17 -0
- package/dist/image-generation-core.auth.runtime-DWfzUU3N.js +2 -0
- package/dist/image-generation-core.auth.runtime.js +1 -1
- package/dist/image-generation-provider-Bq81bEDF.js +94 -0
- package/dist/image-generation-provider-D9rV0jKg.js +280 -0
- package/dist/image-generation-provider-DLxx1bzz.js +130 -0
- package/dist/image-generation-provider-DtYtLZ5X.js +136 -0
- package/dist/image-generation-provider-DxkBVWXc.js +163 -0
- package/dist/image-generation-runtime-BSjvNi3e.js +2 -0
- package/dist/image-runtime-DiMm78ho.js +7 -0
- package/dist/inbound-reply-dispatch-vAjY1w2F.js +73 -0
- package/dist/inbound.runtime-CRF3jMe0.js +3 -0
- package/dist/inbound.runtime-DTPuWSKr.js +4 -0
- package/dist/inbound.runtime.js +1 -1
- package/dist/index.js +2 -2
- package/dist/infra-runtime-D3jjt6RI.js +25 -0
- package/dist/ingest-DZbARiPc.js +2 -0
- package/dist/ingest-gzQEKaUE.js +842 -0
- package/dist/io-NwOu0Lqq.js +7188 -0
- package/dist/io-p7f7Dzgz.js +5 -0
- package/dist/kaijibot-tools-DlPDuhB1.js +9434 -0
- package/dist/kaijibot-tools.runtime-Cme2o8P6.js +2 -0
- package/dist/kaijibot-tools.runtime.js +1 -1
- package/dist/kimi-web-search-provider-Ccz-6FOv.js +308 -0
- package/dist/library-CNY5LwdW.js +45 -0
- package/dist/lifecycle-DPisznBr.js +51 -0
- package/dist/lifecycle-core-DHpL48zF.js +422 -0
- package/dist/list.runtime-BGQLMIEV.js +9 -0
- package/dist/list.runtime-rNaKvGI6.js +12 -0
- package/dist/list.runtime.js +1 -1
- package/dist/llm-engine-CJ4a8si7.js +2 -0
- package/dist/llm-engine-JflSw21y.js +1792 -0
- package/dist/llm-extractor-f_T1e84b.js +445 -0
- package/dist/llm-slug-generator.js +2 -2
- package/dist/load-context-BgiRixkE.js +51 -0
- package/dist/logging-BmlPHvHz.js +13 -0
- package/dist/logging-i6p97HMj.js +2 -0
- package/dist/login-BCtkm5rk.js +108 -0
- package/dist/logs-cli-ObIjoAas.js +264 -0
- package/dist/logs-cli.runtime-BFjo2k4n.js +2 -0
- package/dist/logs-cli.runtime.js +1 -1
- package/dist/manager-CWqmCOrL.js +2049 -0
- package/dist/manager-YA9gsC3-.js +3314 -0
- package/dist/mcp/plugin-tools-serve.js +3 -3
- package/dist/mcp-cli-4snhlJll.js +733 -0
- package/dist/mcp-config-BorcRx6O.js +115 -0
- package/dist/media-runtime-we0ajcYl.js +312 -0
- package/dist/media-understanding-provider-3Ttl6hmp.js +18 -0
- package/dist/media-understanding-provider-BGTcMbZI.js +13 -0
- package/dist/media-understanding-provider-BWZtBNix.js +30 -0
- package/dist/media-understanding-provider-CLJBFDyf.js +123 -0
- package/dist/media-understanding-provider-CZ0oRDnO.js +69 -0
- package/dist/media-understanding-provider-CfBvdveE.js +112 -0
- package/dist/media-understanding-provider-D6Ei6zjV.js +18 -0
- package/dist/media-understanding-provider-DEbLZtur.js +37 -0
- package/dist/media-understanding-provider-DysTPulI.js +14 -0
- package/dist/media-understanding-provider-guIrycoj.js +21 -0
- package/dist/media-understanding-provider-sqqt3Zo1.js +67 -0
- package/dist/media-understanding-runtime-DIH8yX06.js +2 -0
- package/dist/media-understanding-zIdRKTHF.js +83 -0
- package/dist/memory-CEPz51C1.js +242 -0
- package/dist/memory-Dz9LyrwM.js +3 -0
- package/dist/memory-core-host-engine-embeddings-D_hioQXv.js +2 -0
- package/dist/memory-core-host-engine-foundation-1Abnrvzg.js +11 -0
- package/dist/memory-core-host-runtime-cli-CPpWR4jD.js +9 -0
- package/dist/memory-core-host-runtime-core-QOAE1eXJ.js +8 -0
- package/dist/memory-embedding-adapter-CJMHQ4fD.js +33 -0
- package/dist/memory-host-search.runtime-CCL0QyRa.js +2 -0
- package/dist/memory-host-search.runtime.js +1 -1
- package/dist/memory-index-BaKGqStn.js +2 -0
- package/dist/memory-index-Dq16t3Le.js +514 -0
- package/dist/memory-runtime-Cr2ycPVC.js +2 -0
- package/dist/memory-runtime-DuWAywa6.js +26 -0
- package/dist/message-B59-6tOr.js +223 -0
- package/dist/message-action-runner-CD2L-ZBQ.js +2 -0
- package/dist/message-action-runner-y-EYEp0n.js +1628 -0
- package/dist/message.config.runtime-NCa2v5Ci.js +3 -0
- package/dist/message.config.runtime.js +1 -1
- package/dist/message.gateway.runtime-Ba2cmeG0.js +2 -0
- package/dist/message.gateway.runtime.js +1 -1
- package/dist/metadata-registry-loader-BAAhCgIz.js +2 -0
- package/dist/metadata-registry-loader-D7YsnsL7.js +15 -0
- package/dist/minimax-vlm-CRQ1qjBy.js +183 -0
- package/dist/minimax-web-search-provider-CBq2_5UU.js +165 -0
- package/dist/mmr-CqmAMXIW.js +146 -0
- package/dist/model-NNxPja4R.js +630 -0
- package/dist/model-auth-BCNvl8s6.js +427 -0
- package/dist/model-auth-label-B0iZbvPM.js +45 -0
- package/dist/model-catalog-B_WMQ0w_.js +204 -0
- package/dist/model-definitions-YQ1lzfH1.js +258 -0
- package/dist/model-picker-ByUUyua6.js +3 -0
- package/dist/model-picker-D2NwBUVu.js +500 -0
- package/dist/model-picker.runtime-BLIC1v4k.js +15 -0
- package/dist/model-picker.runtime.js +1 -1
- package/dist/model-selection-BNkt6VsY.js +381 -0
- package/dist/model-suppression-BLpblK4C.js +28 -0
- package/dist/model-suppression.runtime-CzgXh3-Q.js +7 -0
- package/dist/model-suppression.runtime.js +1 -1
- package/dist/models-11Amlqm7.js +2584 -0
- package/dist/models-BAPi-xJJ.js +2 -0
- package/dist/models-BUxoFu33.js +47 -0
- package/dist/models-Ch34kBry.js +18 -0
- package/dist/models-CxT1_oJh.js +157 -0
- package/dist/models-DdsCg0Z3.js +18 -0
- package/dist/models-cli-DyOOLtYl.js +198 -0
- package/dist/models-config-C91hdcPk.js +900 -0
- package/dist/models-config.providers.secrets-CAQfFlJs.js +299 -0
- package/dist/models-jeG3zz29.js +555 -0
- package/dist/models-uX_1Gq3N.js +760 -0
- package/dist/models.fetch-CBAxXkYq.js +518 -0
- package/dist/monitor-DAF8Gyq4.js +4435 -0
- package/dist/monitor-DSKG-_yl.js +1023 -0
- package/dist/music-generation-provider-BnrTAmbY.js +142 -0
- package/dist/music-generation-provider-CEN-hiuw.js +238 -0
- package/dist/music-generation-provider-CltAphNV.js +169 -0
- package/dist/node-cli-DiZrvwCr.js +2374 -0
- package/dist/nodes-cli-CHIEN-F1.js +1046 -0
- package/dist/nodes-utils-DsRDUdkI.js +196 -0
- package/dist/notify-CLlD_xFa.js +305 -0
- package/dist/oauth-BH1NzJxX.js +57 -0
- package/dist/oauth-oo4i0YoK.js +152 -0
- package/dist/oauth-token-shared-DQSx2gNJ.js +28 -0
- package/dist/oauth.credentials-Bry_dis_.js +165 -0
- package/dist/oauth.flow-BHm8lbRc.js +122 -0
- package/dist/oauth.settings-BEQZQI_l.js +44 -0
- package/dist/oauth.token-CrxxQ__U.js +43 -0
- package/dist/onboard-7nVuWCbc.js +25 -0
- package/dist/onboard-BR4C6q_p.js +25 -0
- package/dist/onboard-CLJvlk15.js +621 -0
- package/dist/onboard-CdxRLmEw2.js +58 -0
- package/dist/onboard-ClstIj39.js +29 -0
- package/dist/onboard-DCvok686.js +25 -0
- package/dist/onboard-RcjANnyK.js +312 -0
- package/dist/onboard-custom-utbZx3tp.js +2 -0
- package/dist/onboard-custom-zmMvywOs.js +647 -0
- package/dist/onboard-helpers-DptwxvqO.js +223 -0
- package/dist/onboard-helpers-hUiLSHkd.js +5 -0
- package/dist/onboard-remote-BLFcjcH2.js +2 -0
- package/dist/onboard-remote-D21HhC2v.js +193 -0
- package/dist/onboard-search-D-BZAp6B.js +324 -0
- package/dist/onboard-skills-B90sl6kA.js +134 -0
- package/dist/onboard-skills-DBZJuUNt.js +2 -0
- package/dist/openai-codex-auth-identity-DJ-yiC5N.js +45 -0
- package/dist/openai-codex-cli-auth-BdZB_Fn0.js +57 -0
- package/dist/openai-codex-provider-D23flY_z.js +299 -0
- package/dist/openai-codex-shared-7LLW54Av.js +6 -0
- package/dist/openai-provider-xmL-RBDi.js +283 -0
- package/dist/openai-transport-stream-M1bujvhd.js +1632 -0
- package/dist/operator-approvals-client-DNHRZj38.js +68 -0
- package/dist/order-DFWeiLxK.js +794 -0
- package/dist/pair-command-approve-CSw5-2fz.js +34 -0
- package/dist/pairing-cli-WXk-duET.js +118 -0
- package/dist/persistent-bindings.lifecycle-CvUywK5_.js +94 -0
- package/dist/pi-bundle-mcp-tools-CX0SFgbF.js +709 -0
- package/dist/pi-embedded-BycqI-F6.js +2 -0
- package/dist/pi-embedded-CROyZQKw.js +6 -0
- package/dist/pi-embedded-runner-DvjFL5Sg.js +8350 -0
- package/dist/pi-embedded-subscribe.handlers.compaction.runtime-DAY2Idkx.js +23 -0
- package/dist/pi-embedded-subscribe.handlers.compaction.runtime.js +1 -1
- package/dist/pi-embedded.runtime-CnpLMfdZ.js +5 -0
- package/dist/pi-embedded.runtime.js +1 -1
- package/dist/pi-model-discovery-eCOzFFEF.js +232 -0
- package/dist/pi-tools.before-tool-call.runtime-DxhFk59d.js +354 -0
- package/dist/pi-tools.before-tool-call.runtime.js +1 -1
- package/dist/plugin-enabled-CHyNN_TN.js +71 -0
- package/dist/plugin-install-config-policy-AxFoCFZw.js +137 -0
- package/dist/plugin-registration-DNzK0hY5.js +23 -0
- package/dist/plugin-registry-CtFzpQUT.js +3 -0
- package/dist/plugin-registry-loader-2DtlC05M.js +22 -0
- package/dist/plugin-registry-rGAVZ04A.js +2 -0
- package/dist/plugin-sdk/.boundary-entry-shims.stamp +1 -1
- package/dist/plugin-sdk/acp-binding-runtime.js +1 -1
- package/dist/plugin-sdk/acp-runtime.js +3 -3
- package/dist/plugin-sdk/agent-harness-runtime.js +6 -6
- package/dist/plugin-sdk/agent-runtime.js +9 -9
- package/dist/plugin-sdk/approval-client-runtime.js +2 -2
- package/dist/plugin-sdk/approval-gateway-runtime.js +2 -2
- package/dist/plugin-sdk/approval-handler-runtime.js +3 -3
- package/dist/plugin-sdk/approval-reply-runtime.js +2 -2
- package/dist/plugin-sdk/approval-runtime.js +4 -4
- package/dist/plugin-sdk/browser-config-runtime.js +2 -2
- package/dist/plugin-sdk/browser-config.js +2 -2
- package/dist/plugin-sdk/browser-control-auth.js +1 -1
- package/dist/plugin-sdk/browser-node-runtime.js +3 -3
- package/dist/plugin-sdk/browser-profiles.js +1 -1
- package/dist/plugin-sdk/browser-setup-tools.js +2 -2
- package/dist/plugin-sdk/browser-support.js +7 -7
- package/dist/plugin-sdk/channel-core.js +2 -2
- package/dist/plugin-sdk/channel-inbound.js +3 -3
- package/dist/plugin-sdk/command-auth.js +4 -4
- package/dist/plugin-sdk/compat.js +2 -2
- package/dist/plugin-sdk/config-mutation.js +4 -4
- package/dist/plugin-sdk/config-runtime.js +6 -6
- package/dist/plugin-sdk/config-schema.js +1 -1
- package/dist/plugin-sdk/conversation-binding-runtime.js +1 -1
- package/dist/plugin-sdk/conversation-runtime.js +4 -4
- package/dist/plugin-sdk/core.js +3 -3
- package/dist/plugin-sdk/direct-dm.js +1 -1
- package/dist/plugin-sdk/gateway-method-runtime.js +1 -1
- package/dist/plugin-sdk/gateway-runtime.js +1 -1
- package/dist/plugin-sdk/generate-text.js +1 -1
- package/dist/plugin-sdk/image-generation-core.js +2 -2
- package/dist/plugin-sdk/image-generation-runtime.js +2 -2
- package/dist/plugin-sdk/inbound-reply-dispatch.js +1 -1
- package/dist/plugin-sdk/index.js +1 -1
- package/dist/plugin-sdk/infra-runtime.js +4 -4
- package/dist/plugin-sdk/media-generation-runtime-shared.js +1 -1
- package/dist/plugin-sdk/media-generation-runtime.js +1 -1
- package/dist/plugin-sdk/media-runtime.js +5 -5
- package/dist/plugin-sdk/media-understanding-runtime.js +2 -2
- package/dist/plugin-sdk/media-understanding.js +2 -2
- package/dist/plugin-sdk/memory-core-host-engine-embeddings.js +2 -2
- package/dist/plugin-sdk/memory-core-host-engine-foundation.js +2 -2
- package/dist/plugin-sdk/memory-core-host-runtime-cli.js +2 -2
- package/dist/plugin-sdk/memory-core-host-runtime-core.js +3 -3
- package/dist/plugin-sdk/memory-core.js +5 -5
- package/dist/plugin-sdk/memory-host-core.js +3 -3
- package/dist/plugin-sdk/memory-host-search.js +1 -1
- package/dist/plugin-sdk/models-provider-runtime.js +1 -1
- package/dist/plugin-sdk/plugin-test-runtime.js +3 -3
- package/dist/plugin-sdk/provider-auth-api-key.js +4 -4
- package/dist/plugin-sdk/provider-auth.js +7 -7
- package/dist/plugin-sdk/provider-entry.js +1 -1
- package/dist/plugin-sdk/provider-setup.js +2 -2
- package/dist/plugin-sdk/provider-stream-family.js +3 -3
- package/dist/plugin-sdk/provider-stream.js +2 -2
- package/dist/plugin-sdk/provider-test-contracts.js +2 -2
- package/dist/plugin-sdk/provider-transport-runtime.js +1 -1
- package/dist/plugin-sdk/reply-dispatch-runtime.js +1 -1
- package/dist/plugin-sdk/reply-runtime.js +7 -7
- package/dist/plugin-sdk/runtime-secret-resolution.js +1 -1
- package/dist/plugin-sdk/runtime.js +3 -3
- package/dist/plugin-sdk/sandbox.js +2 -2
- package/dist/plugin-sdk/self-hosted-provider-setup.js +1 -1
- package/dist/plugin-sdk/session-store-runtime.js +2 -2
- package/dist/plugin-sdk/simple-completion-runtime.js +1 -1
- package/dist/plugin-sdk/skill-commands-runtime.js +1 -1
- package/dist/plugin-sdk/speech-core.js +1 -1
- package/dist/plugin-sdk/src/cognitive/feedback/collector.d.ts +21 -0
- package/dist/plugin-sdk/src/cognitive/persona/lifecycle.d.ts +3 -6
- package/dist/plugin-sdk/src/cognitive/types.d.ts +14 -0
- package/dist/plugin-sdk/src/config/types.cognitive.d.ts +2 -0
- package/dist/plugin-sdk/src/config/zod-schema.cognitive.d.ts +2 -0
- package/dist/plugin-sdk/src/config/zod-schema.d.ts +1 -0
- package/dist/plugin-sdk/testing.js +5 -5
- package/dist/plugin-sdk/text-runtime.js +2 -2
- package/dist/plugin-sdk/video-generation-core.js +1 -1
- package/dist/plugin-sdk/video-generation-runtime.js +1 -1
- package/dist/plugin-service-ByhemcPW.js +2494 -0
- package/dist/plugins/provider-discovery.runtime.js +1 -1
- package/dist/plugins/provider-runtime.runtime.js +1 -1
- package/dist/plugins/runtime/index.js +1 -1
- package/dist/plugins-cli-Bsu-vzeD.js +576 -0
- package/dist/plugins-command-helpers-DHYkcqua.js +117 -0
- package/dist/plugins-install-persist-C8eGd_C5.js +121 -0
- package/dist/plugins-update-command-3xt3Uqf8.js +1009 -0
- package/dist/policy-D-ZKSMmN.js +172 -0
- package/dist/preemptive-compaction-DBfSd-op.js +430 -0
- package/dist/proactive-scheduler-CsHZHnLk.js +1535 -0
- package/dist/probe-CWzUPp-f.js +426 -0
- package/dist/probe-QRfkrTQp.js +54 -0
- package/dist/probe-auth-DG3q8vB9.js +69 -0
- package/dist/probe-auth-GBOKLPAd.js +3 -0
- package/dist/profiles-CBddrdQK.js +117 -0
- package/dist/program-g6p3Qeig.js +111 -0
- package/dist/prompt-overlay-CTwbv1jO.js +72 -0
- package/dist/prompt-select-styled-Cgy0KIgT.js +5305 -0
- package/dist/provider-B_TyrVqo.js +70 -0
- package/dist/provider-api-key-auth-DsEmjrKm.js +113 -0
- package/dist/provider-api-key-auth.runtime-DnU922Pm.js +14 -0
- package/dist/provider-api-key-auth.runtime.js +1 -1
- package/dist/provider-auth-B0NxCABI.js +36 -0
- package/dist/provider-auth-api-key-BRkYGkki.js +5 -0
- package/dist/provider-auth-choice-BU5MwS9n.js +134 -0
- package/dist/provider-auth-choice-preference-BjTvWslj.js +62 -0
- package/dist/provider-auth-choice.runtime-B8ZRr0Ji.js +2 -0
- package/dist/provider-auth-choice.runtime-DIN9GqRk.js +14 -0
- package/dist/provider-auth-choice.runtime.js +1 -1
- package/dist/provider-auth-guidance-BmbcHSR7.js +34 -0
- package/dist/provider-auth-helpers-BHAUl4Gr.js +168 -0
- package/dist/provider-catalog-BL8_CAyj.js +11 -0
- package/dist/provider-catalog-BRtoWqwn.js +11 -0
- package/dist/provider-catalog-BeddZRA_.js +12 -0
- package/dist/provider-catalog-Dl5yMnFQ.js +17 -0
- package/dist/provider-catalog-Doxz6-g3.js +56 -0
- package/dist/provider-catalog-nJImUuqB.js +26 -0
- package/dist/provider-dispatcher-D2GbNyfD.js +22 -0
- package/dist/provider-entry-B01Usrgw.js +97 -0
- package/dist/provider-flow-DgiCMoEf.js +66 -0
- package/dist/provider-models-CjNZS5bS.js +35 -0
- package/dist/provider-models-KjFLrk3V.js +119 -0
- package/dist/provider-models-vPWkBVJC.js +116 -0
- package/dist/provider-registration-BKyn4HAU.js +238 -0
- package/dist/provider-registration-Dtxvk5CC.js +57 -0
- package/dist/provider-runtime-DOtN11v9.js +2 -0
- package/dist/provider-runtime-DSAVX2DR.js +366 -0
- package/dist/provider-runtime.runtime-kKhVhqLz.js +26 -0
- package/dist/provider-runtime.runtime.js +1 -1
- package/dist/provider-self-hosted-setup-l_z2VcmU.js +249 -0
- package/dist/provider-setup-Bf_9tp4f.js +2 -0
- package/dist/provider-stream-BdikYSRa.js +285 -0
- package/dist/provider-stream-family-DSm3KbQw.js +2 -0
- package/dist/provider-usage-BGu0-R4j.js +289 -0
- package/dist/provider-usage-lgVGEKOt.js +3 -0
- package/dist/provider-wizard-BLwU3k7w.js +166 -0
- package/dist/providers.runtime-C0Xkoksw.js +125 -0
- package/dist/providers.runtime.js +1 -1
- package/dist/proxy-stream-wrappers-CIRRoMpa.js +480 -0
- package/dist/push-apns-BuLz1QrB.js +1061 -0
- package/dist/pw-ai-Ld88tf39.js +2268 -0
- package/dist/qmd-manager-kG_qjIil.js +1799 -0
- package/dist/qr-cli-CsNdevN-.js +359 -0
- package/dist/qr-image-CJ2mMFzI.js +2 -0
- package/dist/queue-fniCZ6ND.js +636 -0
- package/dist/realtime-provider-shared-B2y3nIjr.js +21 -0
- package/dist/realtime-transcription-provider-BYeb_Pdh.js +180 -0
- package/dist/realtime-voice-provider-Cs5kAI5o.js +342 -0
- package/dist/record-shared-vbhlkLLm.js +10 -0
- package/dist/refresh-DgMFD0Y0.js +115 -0
- package/dist/region-BOx9--Jp.js +74 -0
- package/dist/register.agent-i88emBrg.js +241 -0
- package/dist/register.backup-PaaKiScO.js +234 -0
- package/dist/register.configure-DOwB_pGJ.js +15 -0
- package/dist/register.maintenance-CYchYFw1.js +443 -0
- package/dist/register.message-DCzLrhHI.js +601 -0
- package/dist/register.onboard-La1ps81U.js +83 -0
- package/dist/register.runtime-Br9LK2gh.js +81 -0
- package/dist/register.runtime-CgbjcVmK.js +343 -0
- package/dist/register.runtime.js +1 -1
- package/dist/register.setup-BwGIBl0j.js +104 -0
- package/dist/register.status-health-sessions-Bg-JiJ0c.js +1211 -0
- package/dist/register.subclis-BvRTTvO6.js +3 -0
- package/dist/register.subclis-C72FAl_s.js +232 -0
- package/dist/repair-DUb-NpH_.js +112 -0
- package/dist/replay-policy-8aUdDKqI.js +8 -0
- package/dist/reply-SolAjGzg.js +3523 -0
- package/dist/reply.runtime-BzJw9WP7.js +2 -0
- package/dist/reply.runtime.js +1 -1
- package/dist/resolve-b0jc4sM3.js +280 -0
- package/dist/restart-CReI1iMn.js +454 -0
- package/dist/root-help-DOYfXVGX.js +44 -0
- package/dist/route-reply-Bsd_X1hM.js +141 -0
- package/dist/route-reply.runtime-0EDNxcfO.js +2 -0
- package/dist/route-reply.runtime.js +1 -1
- package/dist/rpc-C4VoC6lx.js +61 -0
- package/dist/rpc.runtime-CrjwpfEG.js +21 -0
- package/dist/rpc.runtime.js +1 -1
- package/dist/run-main-BqkJC57m.js +453 -0
- package/dist/run-wait-KirpkWGm.js +118 -0
- package/dist/runner-BVkPQnQI.js +1497 -0
- package/dist/runs-Djzm6zWd.js +495 -0
- package/dist/runtime-6nDEFb75.js +72 -0
- package/dist/runtime-BU-qtT4-.js +107 -0
- package/dist/runtime-BYFm5p1W.js +725 -0
- package/dist/runtime-Bw9f54EP.js +355 -0
- package/dist/runtime-D2tXO42J2.js +242 -0
- package/dist/runtime-DOWgnTkX.js +191 -0
- package/dist/runtime-DObmMc6X.js +253 -0
- package/dist/runtime-DoFRWRgY.js +9 -0
- package/dist/runtime-Dt-rXRTW.js +2 -0
- package/dist/runtime-api-BtobjiSx.js +12 -0
- package/dist/runtime-api-CjjNrjOu2.js +2 -0
- package/dist/runtime-api-D7fKSLcI.js +3 -0
- package/dist/runtime-embedded-pi.runtime-2nLOBaP4.js +3 -0
- package/dist/runtime-embedded-pi.runtime.js +1 -1
- package/dist/runtime-internal-BBIguEmO.js +2 -0
- package/dist/runtime-model-auth.runtime-Cgx5HiVv.js +39 -0
- package/dist/runtime-model-auth.runtime.js +1 -1
- package/dist/runtime-oxFh0OA-.js +2 -0
- package/dist/runtime-plugins-zeEZH6Ee.js +69 -0
- package/dist/runtime-prepare.runtime-C1hoi3Pj.js +80 -0
- package/dist/runtime-prepare.runtime.js +1 -1
- package/dist/runtime-provider-CXi4BTPW.js +21 -0
- package/dist/runtime-r3Ke_KuH.js +200 -0
- package/dist/runtime-registry-loader-471RbKgH.js +2 -0
- package/dist/runtime-registry-loader-Dov85dVR.js +58 -0
- package/dist/runtime-schema-DUetufoV.js +28395 -0
- package/dist/runtime-shared-BGttaPX3.js +249 -0
- package/dist/runtime-taskflow-CXpDzGWH.js +250 -0
- package/dist/runtime-web-channel-plugin-Dyt-ZWxm.js +215 -0
- package/dist/runtime-web-tools-CXeVnAOE.js +1467 -0
- package/dist/runtime-web-tools-fallback.runtime-B5P96RjD.js +9 -0
- package/dist/runtime-web-tools-fallback.runtime.js +1 -1
- package/dist/sandbox-B7Mdkad9.js +2586 -0
- package/dist/sandbox-Bkj7NfH_.js +4 -0
- package/dist/sandbox-cli-BMrDh7ip.js +447 -0
- package/dist/secrets-cli-CDO_S3rr.js +2114 -0
- package/dist/security-audit-D4tdLi7R.js +34 -0
- package/dist/security-cli-BtMEiNIM.js +486 -0
- package/dist/semantic-dedup-BGgf2SFR.js +95 -0
- package/dist/send-C5pIHqBv.js +993 -0
- package/dist/send-media-Dcmyu6Y-.js +2123 -0
- package/dist/server-D0ZKpih4.js +77 -0
- package/dist/server-context-BekzVd0R.js +4164 -0
- package/dist/server-iDg2UFb7.js +13 -0
- package/dist/server-methods-MPVSmE3_.js +11937 -0
- package/dist/server-middleware-FqXPNqqT.js +110 -0
- package/dist/server-node-events-C1iGhswC.js +451 -0
- package/dist/server.impl-CFp5ICor.js +19766 -0
- package/dist/session-C-0F1BlP.js +48 -0
- package/dist/session-conversation-Ckza03tl.js +27 -0
- package/dist/session-cost-usage-Dnbtqvv7.js +648 -0
- package/dist/session-cost-usage-iTVG22AO.js +2 -0
- package/dist/session-file-CiJXAZP4.js +44 -0
- package/dist/session-key-6G1LpIon.js +65 -0
- package/dist/session-meta-knhthO95.js +109 -0
- package/dist/session-override-CGqy8cfR.js +103 -0
- package/dist/session-reset-model.runtime-VxsiNT-r.js +120 -0
- package/dist/session-reset-model.runtime.js +1 -1
- package/dist/session-reset-service-6oOKZMC9.js +474 -0
- package/dist/session-subagent-reactivation.runtime-DzMHk0SH.js +2 -0
- package/dist/session-subagent-reactivation.runtime.js +1 -1
- package/dist/session-system-events-BifSkL6x.js +63 -0
- package/dist/session-tab-registry-DR0gRhet.js +553 -0
- package/dist/session-updates-CHOc_4vH.js +234 -0
- package/dist/session-updates.runtime-DsHKjhyM.js +2 -0
- package/dist/session-updates.runtime.js +1 -1
- package/dist/session-utils-GLg54NBi.js +930 -0
- package/dist/sessions-BxOkBx-e.js +45 -0
- package/dist/sessions-C6oolVsU.js +231 -0
- package/dist/sessions-D6_b32XT.js +2 -0
- package/dist/sessions.runtime-Dtv72AMI.js +2 -0
- package/dist/sessions.runtime.js +1 -1
- package/dist/setup-DOX0TZju.js +505 -0
- package/dist/setup-DwqTuGTp.js +329 -0
- package/dist/setup-surface-Ore2Ehcn.js +586 -0
- package/dist/setup.finalize-hAPbyOmw.js +436 -0
- package/dist/setup.gateway-config-DteoOy8F.js +246 -0
- package/dist/shared-CLjMam2L.js +36 -0
- package/dist/shared-DGIkRU6J.js +218 -0
- package/dist/shared-DUnO9yTD.js +175 -0
- package/dist/shared-DeBJWig-.js +137 -0
- package/dist/shared-igYZ1cFQ.js +224 -0
- package/dist/shared-runtime-cWVnVIl5.js +7 -0
- package/dist/short-term-promotion-BhxerFzv.js +1631 -0
- package/dist/simple-completion-runtime-Bv1VtWSA.js +131 -0
- package/dist/simple-completion-transport-CLqa5Iyl.js +32 -0
- package/dist/skill-commands-D02-U6zf.js +82 -0
- package/dist/skill-commands.runtime-J2XiyESs.js +2 -0
- package/dist/skill-commands.runtime.js +1 -1
- package/dist/skills-BI8fjdW_.js +4 -0
- package/dist/skills-C6n71k5r.js +1075 -0
- package/dist/skills-cli-zp3lOjti.js +382 -0
- package/dist/skills-install-DlqA6nec.js +822 -0
- package/dist/skills-status-B57B5p12.js +170 -0
- package/dist/skills-status-DSk7-Gbk.js +2 -0
- package/dist/soul-cli-D_VMWljI.js +110 -0
- package/dist/speech-core-5C9NDTWw.js +126 -0
- package/dist/speech-provider-5npDU3CX.js +103 -0
- package/dist/speech-provider-B-nDtAnq.js +182 -0
- package/dist/speech-provider-BgLqt9Ul.js +184 -0
- package/dist/speech-provider-DAxRZc2f.js +167 -0
- package/dist/stage-sandbox-media.runtime-CFdAVxo8.js +230 -0
- package/dist/stage-sandbox-media.runtime.js +1 -1
- package/dist/standalone-generate-BG6TQ0jK.js +217 -0
- package/dist/standalone-generate-CgZQCsuI.js +2 -0
- package/dist/startup-auth-CKh--SuD.js +151 -0
- package/dist/state-migrations-CN7oRMHd.js +823 -0
- package/dist/status-BAqccuUp.js +278 -0
- package/dist/status-BaSW-xxu.js +2 -0
- package/dist/status-CAODeWKS.js +3 -0
- package/dist/status-CJpxvQmZ.js +500 -0
- package/dist/status-KOZpSuVN.js +2 -0
- package/dist/status-TqK4AoMQ.js +473 -0
- package/dist/status-all-DNG9crv3.js +495 -0
- package/dist/status-evx_KM_Z.js +399 -0
- package/dist/status-json-CT6-w9e9.js +14 -0
- package/dist/status-json-command-sAasGH5G.js +92 -0
- package/dist/status-runtime-shared-DTGujn3T.js +271 -0
- package/dist/status.command.text-runtime-CugrZfYj.js +15 -0
- package/dist/status.gateway-connection.runtime-kuu5mcJa.js +2 -0
- package/dist/status.gateway-connection.runtime.js +1 -1
- package/dist/status.gateway-probe-DNRjTzrV.js +16 -0
- package/dist/status.scan-overview-BjX4TLdw.js +395 -0
- package/dist/status.scan-rcGDJYtU.js +62 -0
- package/dist/status.scan.deps.runtime-CvmH94mX.js +18 -0
- package/dist/status.scan.deps.runtime.js +1 -1
- package/dist/status.scan.fast-json-BJv_9gqh.js +128 -0
- package/dist/status.scan.fast-json-DKOmheDO.js +2 -0
- package/dist/status.scan.runtime-BRjuY3QE.js +417 -0
- package/dist/status.scan.runtime.js +1 -1
- package/dist/status.summary-Bxs_2k1b.js +2 -0
- package/dist/status.summary-Dag8_BJw.js +209 -0
- package/dist/store-BCDEVRXR.js +1112 -0
- package/dist/store-C6poa5Og.js +1075 -0
- package/dist/store-DxQRR8Va.js +424 -0
- package/dist/store.runtime-D6t_wvEo.js +2 -0
- package/dist/store.runtime.js +1 -1
- package/dist/stream-CxAFhAae.js +649 -0
- package/dist/stream-wrappers-BALQapyz.js +144 -0
- package/dist/subagent-announce.registry.runtime-C55O0bdZ.js +3 -0
- package/dist/subagent-announce.registry.runtime.js +1 -1
- package/dist/subagent-control-CoVHKnJF.js +485 -0
- package/dist/subagent-followup.runtime-9Gmh8O_s.js +68 -0
- package/dist/subagent-followup.runtime.js +1 -1
- package/dist/subagent-list-BPsxOWK_.js +168 -0
- package/dist/subagent-orphan-recovery-BCcEet7k.js +214 -0
- package/dist/subagent-registry-DfHx9pew.js +2889 -0
- package/dist/subagent-registry-runtime-B_Mc7UDa.js +2 -0
- package/dist/subagent-registry.runtime-gOuSIzDg.js +3 -0
- package/dist/subagent-registry.runtime.js +1 -1
- package/dist/subagent-spawn-BOLGVu7f.js +782 -0
- package/dist/subagents-format-DXuyOMu-.js +629 -0
- package/dist/system-cli-_jfrKryu.js +60 -0
- package/dist/targets-DKzJlbu6.js +595 -0
- package/dist/task-executor-DhjMRE2d.js +350 -0
- package/dist/task-owner-access-rwopIPhc.js +48 -0
- package/dist/task-registry-C6EQpySp.js +2346 -0
- package/dist/task-registry-control.runtime-t4jeMENC.js +3 -0
- package/dist/task-registry-control.runtime.js +1 -1
- package/dist/task-registry-delivery-runtime-BMfszrF8.js +2 -0
- package/dist/task-registry-delivery-runtime-D_Ocdg0_.js +3 -0
- package/dist/task-registry.maintenance-DNXaqTr4.js +2 -0
- package/dist/task-registry.maintenance-DqvsLuqb.js +425 -0
- package/dist/testing-CXEcd2QQ.js +441 -0
- package/dist/text-report-CUwo5L1k.js +587 -0
- package/dist/text-runtime-B3UrMt6T.js +313 -0
- package/dist/thread-bindings-BR0oLaqe.js +223 -0
- package/dist/tool-auth-shared-BwlRX_zo.js +53 -0
- package/dist/tool-config-shared-CThVi2Zv.js +19 -0
- package/dist/tool-schema-runtime-CiqxCMkH.js +1892 -0
- package/dist/tools-BUzk9uUn.js +110 -0
- package/dist/tools-effective-inventory-CMhZ6G55.js +152 -0
- package/dist/tools.runtime-D6GnPvuW.js +4 -0
- package/dist/tools.runtime.js +1 -1
- package/dist/transcript-kBzFcvfJ.js +233 -0
- package/dist/transcript.runtime-X5nUWG5J.js +2 -0
- package/dist/transcript.runtime.js +1 -1
- package/dist/transport-policy-qrbV7LdB.js +75 -0
- package/dist/tts-BW2-rTjx.js +31 -0
- package/dist/tui-Cnxy7MIi.js +4018 -0
- package/dist/tui-cli-COdAidhT.js +31 -0
- package/dist/update-cli-C62761SQ.js +1779 -0
- package/dist/update-runner-BY92EdE9.js +1492 -0
- package/dist/usage-format-CPx6tGPA.js +2 -0
- package/dist/usage-format-CpsXzXcG.js +507 -0
- package/dist/video-generation-provider-BKRHP8oO.js +171 -0
- package/dist/video-generation-provider-CCsVq0-G.js +263 -0
- package/dist/video-generation-provider-CPHXFGar.js +246 -0
- package/dist/video-generation-provider-DRMOwtTj.js +104 -0
- package/dist/video-generation-provider-DohNwNos.js +181 -0
- package/dist/video-generation-provider-DsIqJI0e.js +227 -0
- package/dist/video-generation-provider-Kg01Dy_G.js +233 -0
- package/dist/video-generation-provider-Z-xZjApd.js +240 -0
- package/dist/video-generation-provider-kfoZ8epM.js +64 -0
- package/dist/video-generation-provider-wgwFq2Wr.js +77 -0
- package/dist/web-fetch-providers.runtime-YHUYJGZL.js +33 -0
- package/dist/web-fetch-providers.runtime.js +1 -1
- package/dist/web-search-C0DUuJkz.js +221 -0
- package/dist/web-search-provider-BVISR8ti.js +155 -0
- package/dist/web-search-providers.runtime-BxK0HVx5.js +206 -0
- package/dist/web-search-providers.runtime.js +1 -1
- package/dist/webhooks-cli-CNvp2Osa.js +321 -0
- package/dist/x-search-shared-uvKOvvdl.js +109 -0
- package/dist/zod-schema-CgftpN_n.js +1401 -0
- package/docs/concepts/cognitive-overview.md +27 -12
- package/package.json +2 -1
- package/dist/abort-BA4i4CO6.js +0 -202
- package/dist/abort-cutoff.runtime-140Dy9Z_.js +0 -20
- package/dist/abort.runtime-D2xd_Jxq.js +0 -2
- package/dist/acp-cli-lUerPOt4.js +0 -2171
- package/dist/acp-spawn-CKu5HWZd.js +0 -1024
- package/dist/acp-stateful-target-driver-DNcDMame.js +0 -88
- package/dist/action-agents-bNO5zlxQ.js +0 -67
- package/dist/action-focus-BQH1yzA9.js +0 -124
- package/dist/action-help-Copk6G3d.js +0 -7
- package/dist/action-info-BUV_zoSU.js +0 -58
- package/dist/action-kill-BMDz9l_U.js +0 -33
- package/dist/action-list-CxkulhYF.js +0 -21
- package/dist/action-log-D0K9-YCV.js +0 -30
- package/dist/action-send-B8ggJVwC.js +0 -39
- package/dist/action-spawn-D9kSXA_K.js +0 -46
- package/dist/action-unfocus-bI4VBonB.js +0 -28
- package/dist/agent-CdxQT19_.js +0 -2
- package/dist/agent-command-Bu_cXSEL.js +0 -1479
- package/dist/agent-runner-utils--p6HAP6k.js +0 -202
- package/dist/agent-runner.runtime-BossnlL1.js +0 -2825
- package/dist/agents-DA2-qNUI.js +0 -887
- package/dist/agents-DaKVGj9F.js +0 -5
- package/dist/anthropic-vertex-stream-CrF-fPgb.js +0 -5666
- package/dist/api-BPByI3-X.js +0 -2
- package/dist/api-BRJq6Aya.js +0 -2
- package/dist/api-BpAm-eRQ.js +0 -2
- package/dist/api-BvFPt7b2.js +0 -19
- package/dist/api-CSOm-O9I.js +0 -5
- package/dist/api-ChQfiSmG.js +0 -4
- package/dist/api-CqBQhm6r.js +0 -2
- package/dist/api-D7qSjVDS.js +0 -3
- package/dist/api-DbRoXBTn.js +0 -45
- package/dist/api-_HshnS5J.js +0 -35
- package/dist/apply-G86rau7x.js +0 -493
- package/dist/apply.runtime-BoYc09wu.js +0 -166
- package/dist/apply.runtime-Dmh02lO-.js +0 -2
- package/dist/approval-client-helpers-cyaJyAMz.js +0 -82
- package/dist/approval-gateway-resolver-bdX78er-.js +0 -58
- package/dist/approval-gateway-runtime-CJm68vrp.js +0 -2
- package/dist/approval-handler-runtime-CT08B2_a.js +0 -439
- package/dist/approval-native-runtime-CN4meUkM.js +0 -709
- package/dist/approval-renderers-CnmO8wke.js +0 -64
- package/dist/asr-Cz-FH-3c.js +0 -196
- package/dist/audit-Cbfv4nmn.js +0 -885
- package/dist/audit-extra.async-DQv_s9K0.js +0 -847
- package/dist/audit.deep.runtime-CAPtrWg1.js +0 -2
- package/dist/audit.nondeep.runtime-HUJ6INiD.js +0 -859
- package/dist/audit.runtime-CAKbHyXK.js +0 -7
- package/dist/auth-CRAwpkC_.js +0 -181
- package/dist/auth-choice-Bhps2D29.js +0 -3
- package/dist/auth-choice-kMIs0xTd.js +0 -71
- package/dist/auth-choice-options-Bx_XsiW-.js +0 -104
- package/dist/auth-choice-prompt-B-koxVGL.js +0 -2
- package/dist/auth-choice-prompt-DytHsI5U.js +0 -36
- package/dist/auth-choice-vRXPONqL.js +0 -353
- package/dist/auth-choice.plugin-providers.runtime-BNfpK_sp.js +0 -11
- package/dist/auth-health-BAxUQXZE.js +0 -165
- package/dist/auth-profiles-YXfmeEhu.js +0 -438
- package/dist/auth-profiles.runtime-CNNciZQU.js +0 -7
- package/dist/auto-recall-CsrNcQNa.js +0 -78
- package/dist/backup-create-DuIPhK_s.js +0 -391
- package/dist/banner-Bb9u_-IS.js +0 -2
- package/dist/banner-BkHTsqFt.js +0 -281
- package/dist/binding-routing-C6_mrNEN.js +0 -50
- package/dist/binding-targets-Cq2e7wRT.js +0 -99
- package/dist/bridge-server-Co3awCAM.js +0 -103
- package/dist/browser-config-runtime-BtkKPBMj.js +0 -6
- package/dist/browser-control-auth-Bqu1lakr.js +0 -120
- package/dist/browser-node-runtime-D8xut4fJ.js +0 -12
- package/dist/browser-profiles-gPG14SPk.js +0 -170
- package/dist/browser-runtime-BBkGI01q.js +0 -377
- package/dist/browser-setup-tools-CD_s48fd.js +0 -12
- package/dist/call-CiUZqjsN.js +0 -2
- package/dist/call-k_nZXTJ3.js +0 -495
- package/dist/call.runtime-CZI7yxSF.js +0 -2
- package/dist/capability-cli-CIm_YhHH.js +0 -1357
- package/dist/catalog-provider-Ch4CMHLl.js +0 -40
- package/dist/cdp.helpers-BVl3YwYe.js +0 -372
- package/dist/channel-core-BB7pTANC.js +0 -5
- package/dist/channel-summary-TxoZjGPA.js +0 -139
- package/dist/channel-summary-dKkFDRbe.js +0 -2
- package/dist/channel.runtime-2WY9MkoH.js +0 -399
- package/dist/channels-D66hRVnR.js +0 -1147
- package/dist/channels-cli-0DjAVaKh.js +0 -248
- package/dist/chat-Fv3LkEfF.js +0 -213
- package/dist/chrome-CEE9kYYR.js +0 -1080
- package/dist/chrome.executables-Dp7W-RgV.js +0 -550
- package/dist/cli-BsNkLoFI.js +0 -57
- package/dist/cli-DQH9X5IE.js +0 -2
- package/dist/cli-DW_ou4hw.js +0 -2
- package/dist/cli-DuoVlLKx.js +0 -154
- package/dist/cli-QG03g_im.js +0 -191
- package/dist/cli-auth-seam-BrijKBRQ.js +0 -14
- package/dist/cli-backend-CIs4F7ip.js +0 -66
- package/dist/cli-migration-CVktTGRI.js +0 -127
- package/dist/cli-runner-12iECISR.js +0 -1662
- package/dist/cli-runner.runtime-C5noDuQ-.js +0 -3
- package/dist/cli-runner.runtime-YrAg_h19.js +0 -2
- package/dist/cli-shared-BUW2okV2.js +0 -142
- package/dist/cli.runtime-Bhxt80sB.js +0 -819
- package/dist/client-bootstrap-BWo-ZK_j.js +0 -28
- package/dist/codex-native-web-search-C6s55zGf.js +0 -2
- package/dist/codex-native-web-search-Cxf1u7R-.js +0 -156
- package/dist/collector-CRTTihSY.js +0 -349
- package/dist/collector-tJxrYXuY.js +0 -2
- package/dist/command-auth-Dlrd5CYD.js +0 -75
- package/dist/command-config-resolution-B8pxzh3W.js +0 -2
- package/dist/command-config-resolution-BXSCDJTh.js +0 -23
- package/dist/command-execution-startup-DYXpKpvc.js +0 -269
- package/dist/command-format-JYoGhCek.js +0 -2
- package/dist/command-queue-CmX7XAL1.js +0 -260
- package/dist/command-registry-BF51N12E.js +0 -3
- package/dist/command-registry-BqpfCBbW.js +0 -113
- package/dist/command-secret-gateway-DuuctECr.js +0 -528
- package/dist/commands-acp-DiLJUV45.js +0 -1017
- package/dist/commands-compact.runtime-BOM8PsWH.js +0 -10
- package/dist/commands-core.runtime-CH_aGeT-.js +0 -2
- package/dist/commands-handlers.runtime-Ca6xoeW5.js +0 -3762
- package/dist/commands-models-CRURuXR-.js +0 -306
- package/dist/commands-reset-hooks-D3RzsOIn.js +0 -129
- package/dist/commands-status-Cufj4x2j.js +0 -223
- package/dist/commands-status.runtime-C8Nz4Glk.js +0 -2
- package/dist/commands-subagents-control.runtime-DjhcmoRT.js +0 -3
- package/dist/commands-subagents-control.runtime-s_DYQWfW.js +0 -2
- package/dist/commands.runtime-ChfYOBeV.js +0 -103
- package/dist/comment-shared-DFEZzqhH.js +0 -40
- package/dist/compact-DEsHFhEL.js +0 -11324
- package/dist/compact.runtime-BzLFUSmk.js +0 -7
- package/dist/completion-cli-CiWtzUFQ.js +0 -2
- package/dist/completion-cli-h3zgpXGM.js +0 -468
- package/dist/config-B3cxNRyw.js +0 -8
- package/dist/config-Bd1PtH4x.js +0 -166
- package/dist/config-DuLfQQvE.js +0 -53
- package/dist/config-cli-BiEmyiRa.js +0 -948
- package/dist/config-defaults-Bw9wwyo1.js +0 -163
- package/dist/config-guard-BGGjXg_Y.js +0 -94
- package/dist/config-runtime-Bvdi0W59.js +0 -14
- package/dist/config-validation-BDeuMlc1.js +0 -279
- package/dist/configure-CUSDnrHs.js +0 -2
- package/dist/configure-FDqT3i_9.js +0 -1162
- package/dist/connection-auth-7izNv08V.js +0 -30
- package/dist/context-B2wCjR9D.js +0 -249
- package/dist/context-n8ANhlMJ.js +0 -2
- package/dist/context-writer-COhxMkVz.js +0 -290
- package/dist/control-auth-Csa4b5CR.js +0 -122
- package/dist/control-ui/assets/agents-CYCtph5J.js +0 -767
- package/dist/control-ui/assets/anthropic-B66S-tt5.js +0 -40
- package/dist/control-ui/assets/azure-openai-responses-CRJyPvrW.js +0 -2
- package/dist/control-ui/assets/cron-DPaLQLTR.js +0 -744
- package/dist/control-ui/assets/dialogues-DPJy1B4C.js +0 -83
- package/dist/control-ui/assets/history-CT3DjMa7.js +0 -71
- package/dist/control-ui/assets/index-Ci2oc-eJ.css +0 -1
- package/dist/control-ui/assets/index-Ua-cFlP6.js +0 -2686
- package/dist/control-ui/assets/mistral-DWkPN1WM.js +0 -72
- package/dist/control-ui/assets/openai-codex-responses-CSJ_tbUW.js +0 -8
- package/dist/control-ui/assets/openai-completions-QUhkmdlC.js +0 -6
- package/dist/control-ui/assets/openai-responses-CjthZA3L.js +0 -2
- package/dist/control-ui/assets/openai-responses-shared-tozh4HQx.js +0 -13
- package/dist/conversation-id-d7KXWjzV.js +0 -140
- package/dist/conversation-runtime-D-YmpVS2.js +0 -31
- package/dist/core-8TPCsNB-.js +0 -210
- package/dist/cron-cli-C5ok2iVK.js +0 -637
- package/dist/curator-9KwCnpXG.js +0 -598
- package/dist/curator-t_jLT3Ie.js +0 -2
- package/dist/daemon-cli-Cr_y38yv.js +0 -476
- package/dist/daemon-install-CrhzPiZ-.js +0 -70
- package/dist/delegate-r3VqUt34.js +0 -61
- package/dist/deliver-Cuu36rnv.js +0 -3
- package/dist/deliver-SAyi_F0e.js +0 -782
- package/dist/deliver-runtime-DKv9J6QE.js +0 -2
- package/dist/delivery-outbound.runtime-DDoInTnF.js +0 -6
- package/dist/delivery-queue-CWi3kUit.js +0 -372
- package/dist/delivery-queue-ecSu6ZNL.js +0 -2
- package/dist/deps-BIU2SScd.js +0 -60
- package/dist/devices-cli-BUAuMOOj.js +0 -336
- package/dist/diagnostic-BLwuJXPT.js +0 -311
- package/dist/direct-dm-D_7_vKGq.js +0 -139
- package/dist/directive-handling.fast-lane-C91i_iZm.js +0 -2
- package/dist/directive-handling.fast-lane-F7l0XNwG.js +0 -64
- package/dist/directive-handling.impl-8RAWZiZE.js +0 -659
- package/dist/directive-handling.impl-BxAIWFS-.js +0 -2
- package/dist/directive-handling.parse-B3O0CfXY.js +0 -376
- package/dist/directive-handling.persist-QXt7GHcD.js +0 -139
- package/dist/directive-handling.persist.runtime-CPPm2qYQ.js +0 -2
- package/dist/directive-handling.shared-C5ywsGJd.js +0 -159
- package/dist/directory-cli-D9v1dSPr.js +0 -240
- package/dist/dispatch-DoyBs65s.js +0 -1126
- package/dist/dispatch-acp-Dz8rU6t9.js +0 -969
- package/dist/dispatch-acp-manager.runtime-tPUGDjl3.js +0 -3
- package/dist/dispatch-acp-media.runtime-rwYN3ewY.js +0 -3
- package/dist/dispatch-acp-session.runtime-C9nyGih8.js +0 -2
- package/dist/dispatch-acp.runtime-Co-JFuKU.js +0 -19
- package/dist/dns-cli-BRVJtnve.js +0 -193
- package/dist/docs-cli-DvJd--iI.js +0 -156
- package/dist/doctor-completion-C46W5KI7.js +0 -90
- package/dist/doctor-config-preflight-B_UDrFsE.js +0 -148
- package/dist/doctor-config-preflight-DtvhOeuT.js +0 -2
- package/dist/doctor-state-migrations-Cd3yfnI1.js +0 -2
- package/dist/doctor-state-migrations-D3qorqjy.js +0 -3
- package/dist/drive-C2mxxJx5.js +0 -718
- package/dist/embedding-provider-C5S1sxvR.js +0 -129
- package/dist/embedding-provider-CNDA2uD3.js +0 -26
- package/dist/embedding-provider-CdVS1B85.js +0 -33
- package/dist/engine-CKgZ1obQ.js +0 -82
- package/dist/engine-embeddings-Bt1bTxtw.js +0 -1489
- package/dist/entry-capabilities-DrciJZn1.js +0 -89
- package/dist/env-overrides-DTd6EBBV.js +0 -347
- package/dist/env-overrides.runtime-Dxy8Shg7.js +0 -7
- package/dist/exec-approval-forwarder.runtime-Dpa8Gi_P.js +0 -3
- package/dist/exec-approval-reply-BaUWuhD6.js +0 -292
- package/dist/exec-approvals-cli-BuOJPaPp.js +0 -485
- package/dist/exec-defaults-B5egc-6t.js +0 -1440
- package/dist/extra-params-Bfdm7Piq.js +0 -295
- package/dist/format-KzNAm6y6.js +0 -245
- package/dist/fragment-collector-DEW1fwlc.js +0 -189
- package/dist/gateway-cli-CWHsIpm8.js +0 -1532
- package/dist/gateway-install-token-CcpoWcqs.js +0 -284
- package/dist/gateway-rpc-Do_3fQSm.js +0 -14
- package/dist/gateway-rpc.runtime-C4kzyrJj.js +0 -23
- package/dist/gemini-cli-provider-YULRMcs8.js +0 -106
- package/dist/gemini-web-search-provider-D_QJZMM3.js +0 -167
- package/dist/get-reply-from-config.runtime-BpdriKtr.js +0 -2
- package/dist/gmail-setup-utils-D_e1q-h_.js +0 -422
- package/dist/health-B5YmS_bW.js +0 -2
- package/dist/health-CQ4zXQ-2.js +0 -579
- package/dist/heartbeat-runner--rVDmB2Z.js +0 -1365
- package/dist/heartbeat-runner-CwtXIPI-.js +0 -4
- package/dist/heartbeat-runner.runtime-D_5UeAsX.js +0 -2
- package/dist/help-CAj5xloH.js +0 -76
- package/dist/hooks-cli-BGDBJqzt.js +0 -364
- package/dist/image-DiK7kcmJ.js +0 -152
- package/dist/image-generation-core-Cwutmg_V.js +0 -17
- package/dist/image-generation-core.auth.runtime-DA7XD5V2.js +0 -2
- package/dist/image-generation-provider-B-0SxnvJ.js +0 -280
- package/dist/image-generation-provider-B-UW3NU_.js +0 -94
- package/dist/image-generation-provider-BR1_oIU4.js +0 -130
- package/dist/image-generation-provider-CnGMLnE9.js +0 -163
- package/dist/image-generation-provider-DHvw6TSJ.js +0 -136
- package/dist/image-generation-runtime-DCWf9P6F.js +0 -2
- package/dist/image-runtime-DGNzvqkb.js +0 -7
- package/dist/inbound-reply-dispatch-DgEqNffL.js +0 -73
- package/dist/inbound.runtime-CloYEZJO.js +0 -4
- package/dist/inbound.runtime-DLbKJWOY.js +0 -3
- package/dist/infra-runtime-DE-Vi3Dn.js +0 -25
- package/dist/ingest-DbZJju1a.js +0 -842
- package/dist/ingest-Dyj9M3ZM.js +0 -2
- package/dist/io-Bz-M35LC.js +0 -7184
- package/dist/io-DacBLjh1.js +0 -5
- package/dist/kaijibot-tools-Df_9YJcO.js +0 -9434
- package/dist/kaijibot-tools.runtime-CZId-V1O.js +0 -2
- package/dist/kimi-web-search-provider-DunVVASJ.js +0 -308
- package/dist/library-BqMFzJMy.js +0 -45
- package/dist/lifecycle-core-DD_IXtH-.js +0 -422
- package/dist/lifecycle-lZ5BtT_X.js +0 -57
- package/dist/list.runtime-DU0ctAjd.js +0 -12
- package/dist/list.runtime-DXWlaAJq.js +0 -9
- package/dist/llm-engine-CMR9RxLA.js +0 -1792
- package/dist/llm-engine-VKRjaGY_.js +0 -2
- package/dist/llm-extractor-BCPvoWmb.js +0 -445
- package/dist/load-context-DV3B4twI.js +0 -51
- package/dist/logging-BMNGvpuz.js +0 -13
- package/dist/logging-CN3VAZ70.js +0 -2
- package/dist/login-Dex1JqnY.js +0 -108
- package/dist/logs-cli-BZFJyrsk.js +0 -264
- package/dist/logs-cli.runtime-bBS2Sbi6.js +0 -2
- package/dist/manager-BmS2ofc4.js +0 -2049
- package/dist/manager-CabVEPeE.js +0 -3314
- package/dist/mcp-cli-DGrmbpsu.js +0 -733
- package/dist/mcp-config-CY_3tJVi.js +0 -115
- package/dist/media-runtime-CAa8uHqv.js +0 -312
- package/dist/media-understanding-D_VRj6xY.js +0 -83
- package/dist/media-understanding-provider-B9Jfjq6L.js +0 -13
- package/dist/media-understanding-provider-BWksuEBw.js +0 -30
- package/dist/media-understanding-provider-Bhtq5Kpe.js +0 -14
- package/dist/media-understanding-provider-BzsmDAMk.js +0 -67
- package/dist/media-understanding-provider-C6_6yxvP.js +0 -123
- package/dist/media-understanding-provider-CdRlAb9s.js +0 -18
- package/dist/media-understanding-provider-D5m-2RW8.js +0 -21
- package/dist/media-understanding-provider-PmVmfI6p.js +0 -112
- package/dist/media-understanding-provider-cmLTPd8x.js +0 -18
- package/dist/media-understanding-provider-nPxfFv8l.js +0 -37
- package/dist/media-understanding-provider-yp9gxov6.js +0 -69
- package/dist/media-understanding-runtime-Bu7m-lVs.js +0 -2
- package/dist/memory-5jlpYBqx.js +0 -242
- package/dist/memory-BFKl6oSn.js +0 -3
- package/dist/memory-core-host-engine-embeddings-p06288xV.js +0 -2
- package/dist/memory-core-host-engine-foundation-DHbdNLgZ.js +0 -11
- package/dist/memory-core-host-runtime-cli-BnvAiNzO.js +0 -9
- package/dist/memory-core-host-runtime-core-CnVg69Uw.js +0 -8
- package/dist/memory-embedding-adapter-Cux48Bvk.js +0 -33
- package/dist/memory-host-search.runtime-D6ORyqHq.js +0 -2
- package/dist/memory-index-DSbV_yD0.js +0 -2
- package/dist/memory-index-EFkCRTeh.js +0 -514
- package/dist/memory-runtime-BKqNwQ9X.js +0 -2
- package/dist/memory-runtime-Cn41W0bC.js +0 -26
- package/dist/message-CMCdNyAT.js +0 -223
- package/dist/message-action-runner-CG2CcWaS.js +0 -1628
- package/dist/message-action-runner-DUZQ7nmt.js +0 -2
- package/dist/message.config.runtime-B3ztIjsr.js +0 -3
- package/dist/message.gateway.runtime-COLMRCv4.js +0 -2
- package/dist/metadata-registry-loader-BSyFpHop.js +0 -15
- package/dist/metadata-registry-loader-Ci3mcmNV.js +0 -2
- package/dist/minimax-vlm-D1DbVSjC.js +0 -183
- package/dist/minimax-web-search-provider-BzgvahXM.js +0 -165
- package/dist/mmr-Clamw4uq.js +0 -146
- package/dist/model-CJIbRRp9.js +0 -630
- package/dist/model-auth-BQpkMtoP.js +0 -427
- package/dist/model-auth-label-dLSkL9EI.js +0 -45
- package/dist/model-catalog-DgqowW_L.js +0 -204
- package/dist/model-definitions-BOTIDDWJ.js +0 -258
- package/dist/model-picker-B4SuA28P.js +0 -3
- package/dist/model-picker-buwrc8kM.js +0 -500
- package/dist/model-picker.runtime-DXgS2Rab.js +0 -15
- package/dist/model-selection-CBuo2hSg.js +0 -381
- package/dist/model-suppression-CthTVW_x.js +0 -28
- package/dist/model-suppression.runtime-R-qnGNBa.js +0 -7
- package/dist/models-B3UnmjRf.js +0 -18
- package/dist/models-BucP8NI1.js +0 -760
- package/dist/models-C3w7hz3K.js +0 -18
- package/dist/models-C4-eAnR7.js +0 -157
- package/dist/models-DMLYOe4h.js +0 -2
- package/dist/models-DNNfkS3j.js +0 -2584
- package/dist/models-DkiHZi9S.js +0 -47
- package/dist/models-OhM18fW_.js +0 -555
- package/dist/models-cli-CfvtZXPd.js +0 -198
- package/dist/models-config-BLMZzgfx.js +0 -900
- package/dist/models-config.providers.secrets-rjdH8T5l.js +0 -299
- package/dist/models.fetch-D1o7sMO8.js +0 -518
- package/dist/monitor-CJdL31iS.js +0 -4435
- package/dist/monitor-DB732mUY.js +0 -1023
- package/dist/music-generation-provider-BrUTQBmG.js +0 -169
- package/dist/music-generation-provider-D6aYWSSm.js +0 -238
- package/dist/music-generation-provider-dpX_Oiuw.js +0 -142
- package/dist/node-cli-BSrC37hh.js +0 -2374
- package/dist/nodes-cli-uwgDIsqv.js +0 -1046
- package/dist/nodes-utils-ChvZvxK1.js +0 -196
- package/dist/notify-C9-q0Rdu.js +0 -305
- package/dist/oauth-CVAbqwnx.js +0 -152
- package/dist/oauth-RbN-L8pg.js +0 -57
- package/dist/oauth-token-shared-CCzflFLG.js +0 -28
- package/dist/oauth.credentials-BeCOUsTe.js +0 -165
- package/dist/oauth.flow-C2PFyq_h.js +0 -122
- package/dist/oauth.settings-CBmYrmAk.js +0 -44
- package/dist/oauth.token-DSow_5Ie.js +0 -43
- package/dist/onboard-B-ZJptUZ.js +0 -25
- package/dist/onboard-Beu-mw_-.js +0 -29
- package/dist/onboard-BzUrcgZ5.js +0 -25
- package/dist/onboard-CPuf8esc.js +0 -25
- package/dist/onboard-CTfex1XR2.js +0 -58
- package/dist/onboard-D-ccZlbM.js +0 -312
- package/dist/onboard-DHXNhsF7.js +0 -621
- package/dist/onboard-custom-9KIp_ybR.js +0 -647
- package/dist/onboard-custom-CbXUFVN6.js +0 -2
- package/dist/onboard-helpers-BFknCN7m.js +0 -223
- package/dist/onboard-helpers-DSJ_xWpL.js +0 -5
- package/dist/onboard-remote-C28pAu4b.js +0 -193
- package/dist/onboard-remote-DQxyE18D.js +0 -2
- package/dist/onboard-search-CPHGVmos.js +0 -324
- package/dist/onboard-skills-B642NK1o.js +0 -2
- package/dist/onboard-skills-CI4B6Kx5.js +0 -134
- package/dist/openai-codex-auth-identity-PqpqYz4a.js +0 -45
- package/dist/openai-codex-cli-auth-cFTkwXjR.js +0 -57
- package/dist/openai-codex-provider-DjUpM_l9.js +0 -299
- package/dist/openai-codex-shared-o0pq7UkS.js +0 -6
- package/dist/openai-provider-ChZN4Q0c.js +0 -283
- package/dist/openai-transport-stream-DXBBlxJ9.js +0 -1632
- package/dist/operator-approvals-client-RJESCyw4.js +0 -68
- package/dist/order-D863tCt-.js +0 -794
- package/dist/pair-command-approve-5Jr6xo-1.js +0 -34
- package/dist/pairing-cli-BF3jieZo.js +0 -118
- package/dist/persistent-bindings.lifecycle-CjXEQUMz.js +0 -94
- package/dist/pi-bundle-mcp-tools-DPVGNVRw.js +0 -709
- package/dist/pi-embedded-Cp3OIZy9.js +0 -2
- package/dist/pi-embedded-DJN2vlNF.js +0 -6
- package/dist/pi-embedded-runner-DXHhhGRS.js +0 -8348
- package/dist/pi-embedded-subscribe.handlers.compaction.runtime-D1jUEg-R.js +0 -23
- package/dist/pi-embedded.runtime-DQPfEvkF.js +0 -5
- package/dist/pi-model-discovery-B9q9ykaA.js +0 -232
- package/dist/pi-tools.before-tool-call.runtime-vGvkJ6V9.js +0 -354
- package/dist/plugin-enabled-CMdiRqJS.js +0 -71
- package/dist/plugin-install-config-policy-32D2JJMl.js +0 -137
- package/dist/plugin-registration-BhPJI7wp.js +0 -23
- package/dist/plugin-registry-Bo4RF_Fn.js +0 -2
- package/dist/plugin-registry-C4M8QkVh.js +0 -3
- package/dist/plugin-registry-loader-ZzUapRh3.js +0 -22
- package/dist/plugin-service-31XQtuZr.js +0 -2494
- package/dist/plugins-cli-20A8dYUN.js +0 -576
- package/dist/plugins-command-helpers-C3Qls10N.js +0 -117
- package/dist/plugins-install-persist-DEr-zA4G.js +0 -121
- package/dist/plugins-update-command-D0Iv4BPb.js +0 -1009
- package/dist/policy-BEVsx7jw.js +0 -172
- package/dist/preemptive-compaction-DlRJt7Zq.js +0 -430
- package/dist/proactive-scheduler-B3w5rW0h.js +0 -1444
- package/dist/probe-CCTEVLB2.js +0 -54
- package/dist/probe-DcSW0ngD.js +0 -426
- package/dist/probe-auth-C7DjgU_m.js +0 -69
- package/dist/probe-auth-Cfwc8qaj.js +0 -3
- package/dist/profiles-BYudUysD.js +0 -117
- package/dist/program-E_Dt_QTp.js +0 -111
- package/dist/prompt-overlay-DsEnjhTn.js +0 -72
- package/dist/prompt-select-styled-Dtw90p2J.js +0 -5305
- package/dist/provider-api-key-auth-CerNsquw.js +0 -113
- package/dist/provider-api-key-auth.runtime-B0BpFkRm.js +0 -14
- package/dist/provider-auth-DwgUXcgu.js +0 -36
- package/dist/provider-auth-api-key-BQfXwqgU.js +0 -5
- package/dist/provider-auth-choice-BKxMQwxd.js +0 -134
- package/dist/provider-auth-choice-preference-DeDdHlsY.js +0 -62
- package/dist/provider-auth-choice.runtime-BJxc73Ex.js +0 -2
- package/dist/provider-auth-choice.runtime-DBcrr0Ab.js +0 -14
- package/dist/provider-auth-guidance-Cqo9An-I.js +0 -34
- package/dist/provider-auth-helpers-r9kVb6L3.js +0 -168
- package/dist/provider-catalog-CjNAbR9b.js +0 -12
- package/dist/provider-catalog-CpTP4D3p.js +0 -56
- package/dist/provider-catalog-D1iJW59q.js +0 -11
- package/dist/provider-catalog-Dc48HHhB.js +0 -11
- package/dist/provider-catalog-jKq2UIeG.js +0 -17
- package/dist/provider-catalog-pmlFBXYr.js +0 -26
- package/dist/provider-dispatcher-Dl07uV70.js +0 -22
- package/dist/provider-entry-DkwXZuZY.js +0 -97
- package/dist/provider-flow-CmI4jkWV.js +0 -66
- package/dist/provider-iVtrs6XY.js +0 -70
- package/dist/provider-models-BXMZj2p1.js +0 -119
- package/dist/provider-models-Bq_MZ0xR.js +0 -35
- package/dist/provider-models-CsUYkHTw.js +0 -116
- package/dist/provider-registration-DkqLtXSj.js +0 -57
- package/dist/provider-registration-vrLHkywc.js +0 -238
- package/dist/provider-runtime-C_ebc-4l.js +0 -2
- package/dist/provider-runtime-Czioyn5w.js +0 -366
- package/dist/provider-runtime.runtime-lPuF4lqy.js +0 -26
- package/dist/provider-self-hosted-setup-Bjk91HZ7.js +0 -249
- package/dist/provider-setup-hUbxRciz.js +0 -2
- package/dist/provider-stream-DTbeHqKf.js +0 -285
- package/dist/provider-stream-family-Cz7SHqeS.js +0 -2
- package/dist/provider-usage-4x0im5xP.js +0 -3
- package/dist/provider-usage-CdkW3Bkb.js +0 -289
- package/dist/provider-wizard-BPkIa2bk.js +0 -166
- package/dist/providers.runtime-CawuCJXc.js +0 -125
- package/dist/proxy-stream-wrappers-BcJuaE24.js +0 -480
- package/dist/push-apns-CO3sqbX3.js +0 -1061
- package/dist/pw-ai-DEf5tZLp.js +0 -2268
- package/dist/qmd-manager-CrqmeTuY.js +0 -1799
- package/dist/qr-cli-g_Pkqstu.js +0 -359
- package/dist/qr-image-DcG1bUox.js +0 -2
- package/dist/queue-BveCZpTb.js +0 -636
- package/dist/realtime-provider-shared-BIili3oc.js +0 -21
- package/dist/realtime-transcription-provider-DqEHy_Jr.js +0 -180
- package/dist/realtime-voice-provider-Dau1KlKK.js +0 -342
- package/dist/record-shared-CC55xbFE.js +0 -10
- package/dist/refresh-BXJ80ji4.js +0 -115
- package/dist/region-CPFmncMW.js +0 -74
- package/dist/register.agent-D5el253o.js +0 -241
- package/dist/register.backup-CBhoChp-.js +0 -234
- package/dist/register.configure-DeqUaelp.js +0 -15
- package/dist/register.maintenance-Dv5x9ZE6.js +0 -443
- package/dist/register.message-e2Pbh8A_.js +0 -601
- package/dist/register.onboard-COuTKpAw.js +0 -83
- package/dist/register.runtime-BjOIl4eF.js +0 -81
- package/dist/register.runtime-BzJ6RkQN.js +0 -343
- package/dist/register.setup-DQYY7K4K.js +0 -104
- package/dist/register.status-health-sessions-CXNGQh_O.js +0 -1211
- package/dist/register.subclis-B6uy_ogx.js +0 -232
- package/dist/register.subclis-Cmdrfiej.js +0 -3
- package/dist/repair-C8v1vNU-.js +0 -112
- package/dist/replay-policy-C6igC4nS.js +0 -8
- package/dist/reply-Bd8ShNWW.js +0 -3523
- package/dist/reply.runtime-ByKwE5dg.js +0 -2
- package/dist/resolve-CSTOvc_c.js +0 -280
- package/dist/restart-C0QhPXk1.js +0 -454
- package/dist/root-help-D2vz4lbV.js +0 -44
- package/dist/route-reply-CXZFXlfK.js +0 -141
- package/dist/route-reply.runtime-BK8V9NEg.js +0 -2
- package/dist/rpc-f0OkPaI1.js +0 -61
- package/dist/rpc.runtime-BQ78T_pB.js +0 -21
- package/dist/run-main-CkwrrhfI.js +0 -453
- package/dist/run-wait-B4pXPLkF.js +0 -118
- package/dist/runner-BSA9M_M9.js +0 -1497
- package/dist/runs-CEDW87Fd.js +0 -495
- package/dist/runtime-C18YgW822.js +0 -242
- package/dist/runtime-C3OJQ1Xd.js +0 -200
- package/dist/runtime-CDNVtwVk.js +0 -72
- package/dist/runtime-CMNHfJtF.js +0 -725
- package/dist/runtime-C_o_otMV.js +0 -355
- package/dist/runtime-CiJWy5Ce.js +0 -9
- package/dist/runtime-D8bLKXLh.js +0 -253
- package/dist/runtime-DM4z9RVx.js +0 -2
- package/dist/runtime-Di50Fr1z.js +0 -191
- package/dist/runtime-W3qG5LHM.js +0 -2
- package/dist/runtime-api-Bx7nlc4w.js +0 -12
- package/dist/runtime-api-DCNC_FTy2.js +0 -2
- package/dist/runtime-api-_Z8MjR0l.js +0 -3
- package/dist/runtime-embedded-pi.runtime-Cv0MW9ps.js +0 -3
- package/dist/runtime-internal-DclGtT-e.js +0 -2
- package/dist/runtime-model-auth.runtime-Bjl23_fr.js +0 -39
- package/dist/runtime-oEwr_zQb.js +0 -107
- package/dist/runtime-plugins-CwWhqXLJ.js +0 -69
- package/dist/runtime-prepare.runtime-Bi-YD5R-.js +0 -80
- package/dist/runtime-provider-CSEDbSxr.js +0 -21
- package/dist/runtime-registry-loader-CbbaZCXY.js +0 -58
- package/dist/runtime-registry-loader-kqiMFCUa.js +0 -2
- package/dist/runtime-schema-CDuvvU7B.js +0 -28383
- package/dist/runtime-shared-BxJFDFe6.js +0 -249
- package/dist/runtime-taskflow-RwpXng2l.js +0 -250
- package/dist/runtime-web-channel-plugin-Bw74Ar_q.js +0 -215
- package/dist/runtime-web-tools-CEaAGeYr.js +0 -1467
- package/dist/runtime-web-tools-fallback.runtime-DU8Hp_QZ.js +0 -9
- package/dist/sandbox-BC2XUWcW.js +0 -4
- package/dist/sandbox-cli-ain0MYTB.js +0 -447
- package/dist/sandbox-epLgxWBQ.js +0 -2586
- package/dist/secrets-cli-iLwRZbRt.js +0 -2114
- package/dist/security-audit-DfrokBuq.js +0 -34
- package/dist/security-cli-BqsMM550.js +0 -486
- package/dist/semantic-dedup-BBpIPaSV.js +0 -95
- package/dist/send-C5LHdZqP.js +0 -993
- package/dist/send-media-Df0E2Z_m.js +0 -2123
- package/dist/server-2CD2yd73.js +0 -13
- package/dist/server-B44RMlVT.js +0 -77
- package/dist/server-context-SulhWpXY.js +0 -4164
- package/dist/server-methods-BPzzX5VC.js +0 -11937
- package/dist/server-middleware-WQzQIrD4.js +0 -110
- package/dist/server-node-events-Ug_Atc7G.js +0 -451
- package/dist/server.impl-InfVdwPj.js +0 -19765
- package/dist/session-B5RmIL21.js +0 -48
- package/dist/session-conversation-CFty7VTc.js +0 -27
- package/dist/session-cost-usage-CckjvorH.js +0 -2
- package/dist/session-cost-usage-DMRjhi4B.js +0 -648
- package/dist/session-file-DGJqy_ea.js +0 -44
- package/dist/session-key-D-jBcxEp.js +0 -65
- package/dist/session-meta-BijZlLS3.js +0 -109
- package/dist/session-override-1YQHEAlz.js +0 -103
- package/dist/session-reset-model.runtime-CEWrfXLr.js +0 -120
- package/dist/session-reset-service-Dphtb16d.js +0 -474
- package/dist/session-subagent-reactivation.runtime-CF4aqSpn.js +0 -2
- package/dist/session-system-events-BSVIh760.js +0 -63
- package/dist/session-tab-registry-DG9SGi0I.js +0 -553
- package/dist/session-updates-BRFvmIoC.js +0 -234
- package/dist/session-updates.runtime-CiHARWGr.js +0 -2
- package/dist/session-utils-Cai4P9ih.js +0 -930
- package/dist/sessions-BTcXDmCA.js +0 -2
- package/dist/sessions-CyYVTseV.js +0 -45
- package/dist/sessions-Fb0ep3uj.js +0 -231
- package/dist/sessions.runtime-BGyynSR4.js +0 -2
- package/dist/setup-CjEjg8Ci.js +0 -505
- package/dist/setup-D-ypxGnK.js +0 -329
- package/dist/setup-surface-QaubzT60.js +0 -586
- package/dist/setup.finalize-B3MWkUF9.js +0 -436
- package/dist/setup.gateway-config-BdK0tA_r.js +0 -246
- package/dist/shared-0JcWj8-R.js +0 -224
- package/dist/shared-BOd3OCF0.js +0 -36
- package/dist/shared-DICWV0-6.js +0 -218
- package/dist/shared-DiGX-JK8.js +0 -137
- package/dist/shared-DktX3NHd.js +0 -175
- package/dist/shared-runtime-BltNIfGY.js +0 -7
- package/dist/short-term-promotion-CT1zdD1r.js +0 -1631
- package/dist/simple-completion-runtime-CZyp8rJ3.js +0 -131
- package/dist/simple-completion-transport-BWyoXghG.js +0 -32
- package/dist/skill-commands-BC_2IdwF.js +0 -82
- package/dist/skill-commands.runtime-BP6BnOeq.js +0 -2
- package/dist/skills-BQX1AsbM.js +0 -4
- package/dist/skills-D7XPR8N-.js +0 -1075
- package/dist/skills-cli-CxmgxC7X.js +0 -382
- package/dist/skills-install-CHUWYiLs.js +0 -822
- package/dist/skills-status-DRTnP8E3.js +0 -170
- package/dist/skills-status-v28wm8HD.js +0 -2
- package/dist/soul-cli-B1-3BHbA.js +0 -110
- package/dist/speech-core-aXx4I3sB.js +0 -126
- package/dist/speech-provider-BTBQ5VOv.js +0 -103
- package/dist/speech-provider-BciszvJf.js +0 -184
- package/dist/speech-provider-BoQDEC_Y.js +0 -167
- package/dist/speech-provider-C-wTEx8k.js +0 -182
- package/dist/stage-sandbox-media.runtime-DhlTQjXA.js +0 -230
- package/dist/standalone-generate-BRvNW_O7.js +0 -2
- package/dist/standalone-generate-CDfZss4x.js +0 -217
- package/dist/startup-auth-B5V0AaIU.js +0 -151
- package/dist/state-migrations-BNib6l8O.js +0 -823
- package/dist/status-8clcfnN0.js +0 -473
- package/dist/status-C9YBVOov.js +0 -278
- package/dist/status-CNcOKUs2.js +0 -500
- package/dist/status-D1l9Tu3s.js +0 -399
- package/dist/status-DKth_wbp.js +0 -2
- package/dist/status-P3bvFirO.js +0 -3
- package/dist/status-TmH9qSMG.js +0 -2
- package/dist/status-all-BeyVXDNT.js +0 -495
- package/dist/status-json-Cj42CVZZ.js +0 -14
- package/dist/status-json-command-DWk5RiyN.js +0 -92
- package/dist/status-runtime-shared-orzti3tZ.js +0 -271
- package/dist/status.command.text-runtime-B-tNLc3T.js +0 -15
- package/dist/status.gateway-connection.runtime-BrkaJ2f5.js +0 -2
- package/dist/status.gateway-probe-BwuiZk1h.js +0 -16
- package/dist/status.scan-DegSjLE2.js +0 -62
- package/dist/status.scan-overview-CrSELCru.js +0 -395
- package/dist/status.scan.deps.runtime-DrUvBz4e.js +0 -18
- package/dist/status.scan.fast-json-Bm5lN6IK.js +0 -2
- package/dist/status.scan.fast-json-Ch2Zw813.js +0 -128
- package/dist/status.scan.runtime-D-LvzBYN.js +0 -417
- package/dist/status.summary-OB-43Bvk.js +0 -2
- package/dist/status.summary-gJukahkb.js +0 -209
- package/dist/store-D5JODeba.js +0 -421
- package/dist/store-D_vXZ7m9.js +0 -1112
- package/dist/store-yc7MvXdd.js +0 -1075
- package/dist/store.runtime-6eaZtPq6.js +0 -2
- package/dist/stream-BgcqyefI.js +0 -649
- package/dist/stream-wrappers-B7-5gN0i.js +0 -144
- package/dist/subagent-announce.registry.runtime-R2bop0gW.js +0 -3
- package/dist/subagent-control-UyMtkJwo.js +0 -485
- package/dist/subagent-followup.runtime-bTK0TymS.js +0 -68
- package/dist/subagent-list-c0JKZR0g.js +0 -168
- package/dist/subagent-orphan-recovery-CSEzwva5.js +0 -214
- package/dist/subagent-registry-Be219RP1.js +0 -2889
- package/dist/subagent-registry-runtime-Dk57Y91p.js +0 -2
- package/dist/subagent-registry.runtime-D6h_BK2i.js +0 -3
- package/dist/subagent-spawn-BeyYZuFf.js +0 -782
- package/dist/subagents-format-ZcZBg1Vh.js +0 -629
- package/dist/system-cli-_3czEwa7.js +0 -60
- package/dist/targets-CXrDP8_l.js +0 -595
- package/dist/task-executor-DNUNtRg8.js +0 -350
- package/dist/task-owner-access--E5Vkg9U.js +0 -48
- package/dist/task-registry-COE-B6MO.js +0 -2346
- package/dist/task-registry-control.runtime-BzsTfRw1.js +0 -3
- package/dist/task-registry-delivery-runtime-Cv6xz8KP.js +0 -2
- package/dist/task-registry-delivery-runtime-DSfcd2LA.js +0 -3
- package/dist/task-registry.maintenance-Bhd9abl9.js +0 -2
- package/dist/task-registry.maintenance-W3lTkY0l.js +0 -425
- package/dist/testing-CQ_-oCQB.js +0 -441
- package/dist/text-report-BgqWDKJR.js +0 -587
- package/dist/text-runtime-asv4kIxS.js +0 -313
- package/dist/thread-bindings-BCRWofo_.js +0 -223
- package/dist/tool-auth-shared-BWZwTobX.js +0 -53
- package/dist/tool-config-shared-BleK697I.js +0 -19
- package/dist/tool-schema-runtime-DZsW_KR4.js +0 -1892
- package/dist/tools-C7lv9rSD.js +0 -110
- package/dist/tools-effective-inventory-SB9JwX-y.js +0 -152
- package/dist/tools.runtime-J5rhfXQp.js +0 -4
- package/dist/transcript-DxWx6dVc.js +0 -233
- package/dist/transcript.runtime-CmBnobSv.js +0 -2
- package/dist/transport-policy-BGfaKNz0.js +0 -75
- package/dist/tts-C1GyTLOi.js +0 -31
- package/dist/tui-Cqdp1x16.js +0 -4018
- package/dist/tui-cli-BC4O3H6r.js +0 -31
- package/dist/update-cli-BzaCTuax.js +0 -1779
- package/dist/update-runner-Cvxezvhf.js +0 -1492
- package/dist/usage-format-DQTT4pqY.js +0 -507
- package/dist/usage-format-sR4xu0xw.js +0 -2
- package/dist/video-generation-provider-7YR4_ldd.js +0 -171
- package/dist/video-generation-provider-AlAZkYIW.js +0 -181
- package/dist/video-generation-provider-BEqi4pUJ.js +0 -104
- package/dist/video-generation-provider-CraaZaR7.js +0 -77
- package/dist/video-generation-provider-CuvO2Hzh.js +0 -246
- package/dist/video-generation-provider-D-t16ACe.js +0 -240
- package/dist/video-generation-provider-DeowxvLt.js +0 -233
- package/dist/video-generation-provider-HbOZ3qzI.js +0 -227
- package/dist/video-generation-provider-_apx1yFE.js +0 -263
- package/dist/video-generation-provider-bvpb6cdV.js +0 -64
- package/dist/web-fetch-providers.runtime-m66rypbB.js +0 -33
- package/dist/web-search-DSDz1iyf.js +0 -221
- package/dist/web-search-provider-DnYRRBVM.js +0 -155
- package/dist/web-search-providers.runtime-Cv56XIGr.js +0 -206
- package/dist/webhooks-cli-DQ_JTSNA.js +0 -321
- package/dist/x-search-shared-DKPdPR5_.js +0 -109
- package/dist/zod-schema-B7jQiHXQ.js +0 -1400
package/dist/manager-CabVEPeE.js
DELETED
|
@@ -1,3314 +0,0 @@
|
|
|
1
|
-
import { i as normalizeLowercaseStringOrEmpty } from "./string-coerce-xZwG7Dq8.js";
|
|
2
|
-
import { r as formatErrorMessage } from "./errors-Ez4cKI2Y.js";
|
|
3
|
-
import { b as truncateUtf16Safe, m as resolveUserPath } from "./utils-C8dt4mi-.js";
|
|
4
|
-
import { t as createSubsystemLogger } from "./subsystem-BikUf0BS.js";
|
|
5
|
-
import { n as resolveGlobalSingleton } from "./global-singleton-DSEXPThW.js";
|
|
6
|
-
import { a as resolveAgentDir, p as resolveAgentWorkspaceDir } from "./agent-scope-z3lpbLWu.js";
|
|
7
|
-
import { t as getProviderEnvVars } from "./provider-env-vars-CCNAnvw1.js";
|
|
8
|
-
import { c as resolveSessionTranscriptsDirForAgent } from "./paths-DrQr2my6.js";
|
|
9
|
-
import { n as onSessionTranscriptUpdate } from "./transcript-events-B4kB35M0.js";
|
|
10
|
-
import { i as getMemoryMultimodalExtensions, r as classifyMemoryMultimodalPath, t as buildCaseInsensitiveExtensionGlob } from "./multimodal-wvoT0UA9.js";
|
|
11
|
-
import { n as listMemoryEmbeddingProviders, r as listRegisteredMemoryEmbeddingProviderAdapters, t as getMemoryEmbeddingProvider } from "./memory-embedding-provider-runtime-rD89o-fZ.js";
|
|
12
|
-
import { t as resolveMemorySearchConfig } from "./memory-search-BR_QeLiB.js";
|
|
13
|
-
import { t as extractKeywords } from "./query-expansion-DZmPTJZ2.js";
|
|
14
|
-
import "./text-runtime-asv4kIxS.js";
|
|
15
|
-
import "./error-runtime-CjdJMgGl.js";
|
|
16
|
-
import { a as ensureDir, c as listMemoryFiles, d as remapChunkLines, f as runWithConcurrency, h as hasNonTextEmbeddingParts, i as cosineSimilarity, l as normalizeExtraMemoryPaths, n as buildMultimodalChunkForIndexing, o as hashText, p as isFileMissingError, r as chunkMarkdown, t as buildFileEntry, u as parseEmbedding } from "./internal-TCZa_GcL.js";
|
|
17
|
-
import { r as readMemoryFile } from "./backend-config-CLRxp1xK.js";
|
|
18
|
-
import { C as buildGeminiEmbeddingRequest, S as DEFAULT_GEMINI_EMBEDDING_MODEL, _ as DEFAULT_LMSTUDIO_EMBEDDING_MODEL, a as runOpenAiEmbeddingBatches, c as createLocalEmbeddingProvider, d as DEFAULT_OPENAI_EMBEDDING_MODEL, f as createOpenAiEmbeddingProvider, g as createMistralEmbeddingProvider, h as DEFAULT_MISTRAL_EMBEDDING_MODEL, i as OPENAI_BATCH_ENDPOINT, l as DEFAULT_VOYAGE_EMBEDDING_MODEL, n as enforceEmbeddingMaxInputTokens, o as runGeminiEmbeddingBatches, r as runVoyageEmbeddingBatches, s as DEFAULT_LOCAL_MODEL, u as createVoyageEmbeddingProvider, v as createLmstudioEmbeddingProvider, w as createGeminiEmbeddingProvider } from "./engine-embeddings-Bt1bTxtw.js";
|
|
19
|
-
import "./memory-core-host-engine-embeddings-p06288xV.js";
|
|
20
|
-
import "./memory-core-host-engine-foundation-DHbdNLgZ.js";
|
|
21
|
-
import { i as sessionPathForFile, r as listSessionFilesForAgent, t as buildSessionEntry } from "./session-files-df0MVPzf.js";
|
|
22
|
-
import "./memory-core-host-engine-qmd-CZXRycnv.js";
|
|
23
|
-
import { n as loadSqliteVecExtension, r as ensureMemoryIndexSchema, t as requireNodeSqlite } from "./engine-storage-B9QalbVC.js";
|
|
24
|
-
import "./memory-core-host-engine-storage-JditWiSB.js";
|
|
25
|
-
import "./provider-env-vars-yCHiZMoj.js";
|
|
26
|
-
import { n as applyMMRToHybridResults, t as DEFAULT_MMR_CONFIG } from "./mmr-Clamw4uq.js";
|
|
27
|
-
import { n as deduplicateBySimilarity, t as DEFAULT_SEMANTIC_DEDUP_CONFIG } from "./semantic-dedup-BBpIPaSV.js";
|
|
28
|
-
import fs from "node:fs";
|
|
29
|
-
import path from "node:path";
|
|
30
|
-
import fs$1 from "node:fs/promises";
|
|
31
|
-
import { randomUUID } from "node:crypto";
|
|
32
|
-
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
33
|
-
import chokidar from "chokidar";
|
|
34
|
-
//#region extensions/memory-core/src/memory/provider-adapter-registration.ts
|
|
35
|
-
function filterUnregisteredMemoryEmbeddingProviderAdapters(params) {
|
|
36
|
-
const existingIds = new Set(params.registeredAdapters.map((adapter) => adapter.id));
|
|
37
|
-
return params.builtinAdapters.filter((adapter) => !existingIds.has(adapter.id));
|
|
38
|
-
}
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region extensions/memory-core/src/memory/provider-adapters.ts
|
|
41
|
-
function isMissingApiKeyError(err) {
|
|
42
|
-
return formatErrorMessage(err).includes("No API key found for provider");
|
|
43
|
-
}
|
|
44
|
-
function sanitizeHeaders(headers, excludedHeaderNames) {
|
|
45
|
-
const excluded = new Set(excludedHeaderNames.map((name) => normalizeLowercaseStringOrEmpty(name)));
|
|
46
|
-
return Object.entries(headers).filter(([key]) => !excluded.has(normalizeLowercaseStringOrEmpty(key))).toSorted(([a], [b]) => a.localeCompare(b)).map(([key, value]) => [key, value]);
|
|
47
|
-
}
|
|
48
|
-
function mapBatchEmbeddingsByIndex(byCustomId, count) {
|
|
49
|
-
const embeddings = [];
|
|
50
|
-
for (let index = 0; index < count; index += 1) embeddings.push(byCustomId.get(String(index)) ?? []);
|
|
51
|
-
return embeddings;
|
|
52
|
-
}
|
|
53
|
-
function isNodeLlamaCppMissing(err) {
|
|
54
|
-
if (!(err instanceof Error)) return false;
|
|
55
|
-
return err.code === "ERR_MODULE_NOT_FOUND" && err.message.includes("node-llama-cpp");
|
|
56
|
-
}
|
|
57
|
-
function formatLocalSetupError(err) {
|
|
58
|
-
const detail = formatErrorMessage(err);
|
|
59
|
-
const missing = isNodeLlamaCppMissing(err);
|
|
60
|
-
return [
|
|
61
|
-
"Local embeddings unavailable.",
|
|
62
|
-
missing ? "Reason: optional dependency node-llama-cpp is missing (or failed to install)." : detail ? `Reason: ${detail}` : void 0,
|
|
63
|
-
missing && detail ? `Detail: ${detail}` : null,
|
|
64
|
-
"To enable local embeddings:",
|
|
65
|
-
"1) Use Node 24 (recommended for installs/updates; Node 22 LTS, currently 22.14+, remains supported)",
|
|
66
|
-
missing ? "2) Reinstall KaijiBot (this should install node-llama-cpp): npm i -g kaijibot@latest" : null,
|
|
67
|
-
"3) If you use pnpm: pnpm approve-builds (select node-llama-cpp), then pnpm rebuild node-llama-cpp",
|
|
68
|
-
...[
|
|
69
|
-
"openai",
|
|
70
|
-
"gemini",
|
|
71
|
-
"voyage",
|
|
72
|
-
"mistral"
|
|
73
|
-
].map((provider) => `Or set agents.defaults.memorySearch.provider = "${provider}" (remote).`)
|
|
74
|
-
].filter(Boolean).join("\n");
|
|
75
|
-
}
|
|
76
|
-
function canAutoSelectLocal(modelPath) {
|
|
77
|
-
const trimmed = modelPath?.trim();
|
|
78
|
-
if (!trimmed) return false;
|
|
79
|
-
if (/^(hf:|https?:)/i.test(trimmed)) return false;
|
|
80
|
-
const resolved = resolveUserPath(trimmed);
|
|
81
|
-
try {
|
|
82
|
-
return fs.statSync(resolved).isFile();
|
|
83
|
-
} catch {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function supportsGeminiMultimodalEmbeddings(model) {
|
|
88
|
-
return model.trim().replace(/^models\//, "").replace(/^(gemini|google)\//, "") === "gemini-embedding-2-preview";
|
|
89
|
-
}
|
|
90
|
-
function resolveMemoryEmbeddingAuthProviderId(providerId) {
|
|
91
|
-
return providerId === "gemini" ? "google" : providerId;
|
|
92
|
-
}
|
|
93
|
-
const builtinMemoryEmbeddingProviderAdapters = [
|
|
94
|
-
{
|
|
95
|
-
id: "local",
|
|
96
|
-
defaultModel: DEFAULT_LOCAL_MODEL,
|
|
97
|
-
transport: "local",
|
|
98
|
-
autoSelectPriority: 10,
|
|
99
|
-
formatSetupError: formatLocalSetupError,
|
|
100
|
-
shouldContinueAutoSelection: () => true,
|
|
101
|
-
create: async (options) => {
|
|
102
|
-
const provider = await createLocalEmbeddingProvider({
|
|
103
|
-
...options,
|
|
104
|
-
provider: "local",
|
|
105
|
-
fallback: "none"
|
|
106
|
-
});
|
|
107
|
-
return {
|
|
108
|
-
provider,
|
|
109
|
-
runtime: {
|
|
110
|
-
id: "local",
|
|
111
|
-
cacheKeyData: {
|
|
112
|
-
provider: "local",
|
|
113
|
-
model: provider.model
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
id: "openai",
|
|
121
|
-
defaultModel: DEFAULT_OPENAI_EMBEDDING_MODEL,
|
|
122
|
-
transport: "remote",
|
|
123
|
-
autoSelectPriority: 20,
|
|
124
|
-
allowExplicitWhenConfiguredAuto: true,
|
|
125
|
-
shouldContinueAutoSelection: isMissingApiKeyError,
|
|
126
|
-
create: async (options) => {
|
|
127
|
-
const { provider, client } = await createOpenAiEmbeddingProvider({
|
|
128
|
-
...options,
|
|
129
|
-
provider: "openai",
|
|
130
|
-
fallback: "none"
|
|
131
|
-
});
|
|
132
|
-
return {
|
|
133
|
-
provider,
|
|
134
|
-
runtime: {
|
|
135
|
-
id: "openai",
|
|
136
|
-
cacheKeyData: {
|
|
137
|
-
provider: "openai",
|
|
138
|
-
baseUrl: client.baseUrl,
|
|
139
|
-
model: client.model,
|
|
140
|
-
headers: sanitizeHeaders(client.headers, ["authorization"])
|
|
141
|
-
},
|
|
142
|
-
batchEmbed: async (batch) => {
|
|
143
|
-
return mapBatchEmbeddingsByIndex(await runOpenAiEmbeddingBatches({
|
|
144
|
-
openAi: client,
|
|
145
|
-
agentId: batch.agentId,
|
|
146
|
-
requests: batch.chunks.map((chunk, index) => ({
|
|
147
|
-
custom_id: String(index),
|
|
148
|
-
method: "POST",
|
|
149
|
-
url: OPENAI_BATCH_ENDPOINT,
|
|
150
|
-
body: {
|
|
151
|
-
model: client.model,
|
|
152
|
-
input: chunk.text
|
|
153
|
-
}
|
|
154
|
-
})),
|
|
155
|
-
wait: batch.wait,
|
|
156
|
-
concurrency: batch.concurrency,
|
|
157
|
-
pollIntervalMs: batch.pollIntervalMs,
|
|
158
|
-
timeoutMs: batch.timeoutMs,
|
|
159
|
-
debug: batch.debug
|
|
160
|
-
}), batch.chunks.length);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
id: "gemini",
|
|
168
|
-
defaultModel: DEFAULT_GEMINI_EMBEDDING_MODEL,
|
|
169
|
-
transport: "remote",
|
|
170
|
-
autoSelectPriority: 30,
|
|
171
|
-
allowExplicitWhenConfiguredAuto: true,
|
|
172
|
-
supportsMultimodalEmbeddings: ({ model }) => supportsGeminiMultimodalEmbeddings(model),
|
|
173
|
-
shouldContinueAutoSelection: isMissingApiKeyError,
|
|
174
|
-
create: async (options) => {
|
|
175
|
-
const { provider, client } = await createGeminiEmbeddingProvider({
|
|
176
|
-
...options,
|
|
177
|
-
provider: "gemini",
|
|
178
|
-
fallback: "none"
|
|
179
|
-
});
|
|
180
|
-
return {
|
|
181
|
-
provider,
|
|
182
|
-
runtime: {
|
|
183
|
-
id: "gemini",
|
|
184
|
-
cacheKeyData: {
|
|
185
|
-
provider: "gemini",
|
|
186
|
-
baseUrl: client.baseUrl,
|
|
187
|
-
model: client.model,
|
|
188
|
-
outputDimensionality: client.outputDimensionality,
|
|
189
|
-
headers: sanitizeHeaders(client.headers, ["authorization", "x-goog-api-key"])
|
|
190
|
-
},
|
|
191
|
-
batchEmbed: async (batch) => {
|
|
192
|
-
if (batch.chunks.some((chunk) => hasNonTextEmbeddingParts(chunk.embeddingInput))) return null;
|
|
193
|
-
return mapBatchEmbeddingsByIndex(await runGeminiEmbeddingBatches({
|
|
194
|
-
gemini: client,
|
|
195
|
-
agentId: batch.agentId,
|
|
196
|
-
requests: batch.chunks.map((chunk, index) => ({
|
|
197
|
-
custom_id: String(index),
|
|
198
|
-
request: buildGeminiEmbeddingRequest({
|
|
199
|
-
input: chunk.embeddingInput ?? { text: chunk.text },
|
|
200
|
-
taskType: "RETRIEVAL_DOCUMENT",
|
|
201
|
-
modelPath: client.modelPath,
|
|
202
|
-
outputDimensionality: client.outputDimensionality
|
|
203
|
-
})
|
|
204
|
-
})),
|
|
205
|
-
wait: batch.wait,
|
|
206
|
-
concurrency: batch.concurrency,
|
|
207
|
-
pollIntervalMs: batch.pollIntervalMs,
|
|
208
|
-
timeoutMs: batch.timeoutMs,
|
|
209
|
-
debug: batch.debug
|
|
210
|
-
}), batch.chunks.length);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
id: "voyage",
|
|
218
|
-
defaultModel: DEFAULT_VOYAGE_EMBEDDING_MODEL,
|
|
219
|
-
transport: "remote",
|
|
220
|
-
autoSelectPriority: 40,
|
|
221
|
-
allowExplicitWhenConfiguredAuto: true,
|
|
222
|
-
shouldContinueAutoSelection: isMissingApiKeyError,
|
|
223
|
-
create: async (options) => {
|
|
224
|
-
const { provider, client } = await createVoyageEmbeddingProvider({
|
|
225
|
-
...options,
|
|
226
|
-
provider: "voyage",
|
|
227
|
-
fallback: "none"
|
|
228
|
-
});
|
|
229
|
-
return {
|
|
230
|
-
provider,
|
|
231
|
-
runtime: {
|
|
232
|
-
id: "voyage",
|
|
233
|
-
batchEmbed: async (batch) => {
|
|
234
|
-
return mapBatchEmbeddingsByIndex(await runVoyageEmbeddingBatches({
|
|
235
|
-
client,
|
|
236
|
-
agentId: batch.agentId,
|
|
237
|
-
requests: batch.chunks.map((chunk, index) => ({
|
|
238
|
-
custom_id: String(index),
|
|
239
|
-
body: { input: chunk.text }
|
|
240
|
-
})),
|
|
241
|
-
wait: batch.wait,
|
|
242
|
-
concurrency: batch.concurrency,
|
|
243
|
-
pollIntervalMs: batch.pollIntervalMs,
|
|
244
|
-
timeoutMs: batch.timeoutMs,
|
|
245
|
-
debug: batch.debug
|
|
246
|
-
}), batch.chunks.length);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
id: "mistral",
|
|
254
|
-
defaultModel: DEFAULT_MISTRAL_EMBEDDING_MODEL,
|
|
255
|
-
transport: "remote",
|
|
256
|
-
autoSelectPriority: 50,
|
|
257
|
-
allowExplicitWhenConfiguredAuto: true,
|
|
258
|
-
shouldContinueAutoSelection: isMissingApiKeyError,
|
|
259
|
-
create: async (options) => {
|
|
260
|
-
const { provider, client } = await createMistralEmbeddingProvider({
|
|
261
|
-
...options,
|
|
262
|
-
provider: "mistral",
|
|
263
|
-
fallback: "none"
|
|
264
|
-
});
|
|
265
|
-
return {
|
|
266
|
-
provider,
|
|
267
|
-
runtime: {
|
|
268
|
-
id: "mistral",
|
|
269
|
-
cacheKeyData: {
|
|
270
|
-
provider: "mistral",
|
|
271
|
-
model: client.model
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
},
|
|
277
|
-
{
|
|
278
|
-
id: "lmstudio",
|
|
279
|
-
defaultModel: DEFAULT_LMSTUDIO_EMBEDDING_MODEL,
|
|
280
|
-
transport: "remote",
|
|
281
|
-
create: async (options) => {
|
|
282
|
-
const { provider, client } = await createLmstudioEmbeddingProvider({
|
|
283
|
-
...options,
|
|
284
|
-
provider: "lmstudio",
|
|
285
|
-
fallback: "none"
|
|
286
|
-
});
|
|
287
|
-
return {
|
|
288
|
-
provider,
|
|
289
|
-
runtime: {
|
|
290
|
-
id: "lmstudio",
|
|
291
|
-
cacheKeyData: {
|
|
292
|
-
provider: "lmstudio",
|
|
293
|
-
baseUrl: client.baseUrl,
|
|
294
|
-
model: client.model,
|
|
295
|
-
headers: sanitizeHeaders(client.headers, ["authorization"])
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
];
|
|
302
|
-
const builtinMemoryEmbeddingProviderAdapterById = new Map(builtinMemoryEmbeddingProviderAdapters.map((adapter) => [adapter.id, adapter]));
|
|
303
|
-
function getBuiltinMemoryEmbeddingProviderAdapter(id) {
|
|
304
|
-
return builtinMemoryEmbeddingProviderAdapterById.get(id);
|
|
305
|
-
}
|
|
306
|
-
function registerBuiltInMemoryEmbeddingProviders(register) {
|
|
307
|
-
for (const adapter of filterUnregisteredMemoryEmbeddingProviderAdapters({
|
|
308
|
-
builtinAdapters: builtinMemoryEmbeddingProviderAdapters,
|
|
309
|
-
registeredAdapters: listRegisteredMemoryEmbeddingProviderAdapters()
|
|
310
|
-
})) register.registerMemoryEmbeddingProvider(adapter);
|
|
311
|
-
}
|
|
312
|
-
function getBuiltinMemoryEmbeddingProviderDoctorMetadata(providerId) {
|
|
313
|
-
const adapter = getBuiltinMemoryEmbeddingProviderAdapter(providerId);
|
|
314
|
-
if (!adapter) return null;
|
|
315
|
-
const authProviderId = resolveMemoryEmbeddingAuthProviderId(adapter.id);
|
|
316
|
-
return {
|
|
317
|
-
providerId: adapter.id,
|
|
318
|
-
authProviderId,
|
|
319
|
-
envVars: getProviderEnvVars(authProviderId),
|
|
320
|
-
transport: adapter.transport === "local" ? "local" : "remote",
|
|
321
|
-
autoSelectPriority: adapter.autoSelectPriority
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
function listBuiltinAutoSelectMemoryEmbeddingProviderDoctorMetadata() {
|
|
325
|
-
return builtinMemoryEmbeddingProviderAdapters.filter((adapter) => typeof adapter.autoSelectPriority === "number").toSorted((a, b) => (a.autoSelectPriority ?? 0) - (b.autoSelectPriority ?? 0)).map((adapter) => ({
|
|
326
|
-
providerId: adapter.id,
|
|
327
|
-
authProviderId: resolveMemoryEmbeddingAuthProviderId(adapter.id),
|
|
328
|
-
envVars: getProviderEnvVars(resolveMemoryEmbeddingAuthProviderId(adapter.id)),
|
|
329
|
-
transport: adapter.transport === "local" ? "local" : "remote",
|
|
330
|
-
autoSelectPriority: adapter.autoSelectPriority
|
|
331
|
-
}));
|
|
332
|
-
}
|
|
333
|
-
//#endregion
|
|
334
|
-
//#region extensions/memory-core/src/memory/embeddings.ts
|
|
335
|
-
function formatProviderError(adapter, err) {
|
|
336
|
-
return adapter.formatSetupError?.(err) ?? formatErrorMessage(err);
|
|
337
|
-
}
|
|
338
|
-
function shouldContinueAutoSelection(adapter, err) {
|
|
339
|
-
return adapter.shouldContinueAutoSelection?.(err) ?? false;
|
|
340
|
-
}
|
|
341
|
-
function getAdapter(id, config) {
|
|
342
|
-
const adapter = getMemoryEmbeddingProvider(id, config);
|
|
343
|
-
if (!adapter) throw new Error(`Unknown memory embedding provider: ${id}`);
|
|
344
|
-
return adapter;
|
|
345
|
-
}
|
|
346
|
-
function listAutoSelectAdapters(options) {
|
|
347
|
-
return listMemoryEmbeddingProviders(options.config).filter((adapter) => typeof adapter.autoSelectPriority === "number").filter((adapter) => adapter.id === "local" ? canAutoSelectLocal(options.local?.modelPath) : true).toSorted((a, b) => (a.autoSelectPriority ?? Number.MAX_SAFE_INTEGER) - (b.autoSelectPriority ?? Number.MAX_SAFE_INTEGER));
|
|
348
|
-
}
|
|
349
|
-
function resolveProviderModel(adapter, requestedModel) {
|
|
350
|
-
const trimmed = requestedModel.trim();
|
|
351
|
-
if (trimmed) return trimmed;
|
|
352
|
-
return adapter.defaultModel ?? "";
|
|
353
|
-
}
|
|
354
|
-
function resolveEmbeddingProviderFallbackModel(providerId, fallbackSourceModel, config) {
|
|
355
|
-
return getMemoryEmbeddingProvider(providerId, config)?.defaultModel ?? fallbackSourceModel;
|
|
356
|
-
}
|
|
357
|
-
async function createWithAdapter(adapter, options) {
|
|
358
|
-
const result = await adapter.create({
|
|
359
|
-
...options,
|
|
360
|
-
model: resolveProviderModel(adapter, options.model)
|
|
361
|
-
});
|
|
362
|
-
return {
|
|
363
|
-
provider: result.provider,
|
|
364
|
-
requestedProvider: options.provider,
|
|
365
|
-
runtime: result.runtime
|
|
366
|
-
};
|
|
367
|
-
}
|
|
368
|
-
async function createEmbeddingProvider(options) {
|
|
369
|
-
if (options.provider === "auto") {
|
|
370
|
-
const reasons = [];
|
|
371
|
-
for (const adapter of listAutoSelectAdapters(options)) try {
|
|
372
|
-
return {
|
|
373
|
-
...await createWithAdapter(adapter, {
|
|
374
|
-
...options,
|
|
375
|
-
provider: adapter.id
|
|
376
|
-
}),
|
|
377
|
-
requestedProvider: "auto"
|
|
378
|
-
};
|
|
379
|
-
} catch (err) {
|
|
380
|
-
const message = formatProviderError(adapter, err);
|
|
381
|
-
if (shouldContinueAutoSelection(adapter, err)) {
|
|
382
|
-
reasons.push(message);
|
|
383
|
-
continue;
|
|
384
|
-
}
|
|
385
|
-
const wrapped = new Error(message);
|
|
386
|
-
wrapped.cause = err;
|
|
387
|
-
throw wrapped;
|
|
388
|
-
}
|
|
389
|
-
return {
|
|
390
|
-
provider: null,
|
|
391
|
-
requestedProvider: "auto",
|
|
392
|
-
providerUnavailableReason: reasons.length > 0 ? reasons.join("\n\n") : "No embeddings provider available."
|
|
393
|
-
};
|
|
394
|
-
}
|
|
395
|
-
const primaryAdapter = getAdapter(options.provider, options.config);
|
|
396
|
-
try {
|
|
397
|
-
return await createWithAdapter(primaryAdapter, options);
|
|
398
|
-
} catch (primaryErr) {
|
|
399
|
-
const reason = formatProviderError(primaryAdapter, primaryErr);
|
|
400
|
-
if (options.fallback && options.fallback !== "none" && options.fallback !== options.provider) {
|
|
401
|
-
const fallbackAdapter = getAdapter(options.fallback, options.config);
|
|
402
|
-
try {
|
|
403
|
-
return {
|
|
404
|
-
...await createWithAdapter(fallbackAdapter, {
|
|
405
|
-
...options,
|
|
406
|
-
provider: options.fallback
|
|
407
|
-
}),
|
|
408
|
-
requestedProvider: options.provider,
|
|
409
|
-
fallbackFrom: options.provider,
|
|
410
|
-
fallbackReason: reason
|
|
411
|
-
};
|
|
412
|
-
} catch (fallbackErr) {
|
|
413
|
-
const fallbackReason = formatProviderError(fallbackAdapter, fallbackErr);
|
|
414
|
-
const wrapped = /* @__PURE__ */ new Error(`${reason}\n\nFallback to ${options.fallback} failed: ${fallbackReason}`);
|
|
415
|
-
wrapped.cause = primaryErr;
|
|
416
|
-
throw wrapped;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
const wrapped = new Error(reason);
|
|
420
|
-
wrapped.cause = primaryErr;
|
|
421
|
-
throw wrapped;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
//#endregion
|
|
425
|
-
//#region extensions/memory-core/src/memory/temporal-decay.ts
|
|
426
|
-
const DEFAULT_TEMPORAL_DECAY_CONFIG = {
|
|
427
|
-
enabled: false,
|
|
428
|
-
halfLifeDays: 30
|
|
429
|
-
};
|
|
430
|
-
const DAY_MS = 1440 * 60 * 1e3;
|
|
431
|
-
const DATED_MEMORY_PATH_RE = /(?:^|\/)memory\/(\d{4})-(\d{2})-(\d{2})\.md$/;
|
|
432
|
-
function toDecayLambda(halfLifeDays) {
|
|
433
|
-
if (!Number.isFinite(halfLifeDays) || halfLifeDays <= 0) return 0;
|
|
434
|
-
return Math.LN2 / halfLifeDays;
|
|
435
|
-
}
|
|
436
|
-
function calculateTemporalDecayMultiplier(params) {
|
|
437
|
-
const lambda = toDecayLambda(params.halfLifeDays);
|
|
438
|
-
const clampedAge = Math.max(0, params.ageInDays);
|
|
439
|
-
if (lambda <= 0 || !Number.isFinite(clampedAge)) return 1;
|
|
440
|
-
return Math.exp(-lambda * clampedAge);
|
|
441
|
-
}
|
|
442
|
-
function applyTemporalDecayToScore(params) {
|
|
443
|
-
return params.score * calculateTemporalDecayMultiplier(params);
|
|
444
|
-
}
|
|
445
|
-
function parseMemoryDateFromPath(filePath) {
|
|
446
|
-
const normalized = filePath.replaceAll("\\", "/").replace(/^\.\//, "");
|
|
447
|
-
const match = DATED_MEMORY_PATH_RE.exec(normalized);
|
|
448
|
-
if (!match) return null;
|
|
449
|
-
const year = Number(match[1]);
|
|
450
|
-
const month = Number(match[2]);
|
|
451
|
-
const day = Number(match[3]);
|
|
452
|
-
if (!Number.isInteger(year) || !Number.isInteger(month) || !Number.isInteger(day)) return null;
|
|
453
|
-
const timestamp = Date.UTC(year, month - 1, day);
|
|
454
|
-
const parsed = new Date(timestamp);
|
|
455
|
-
if (parsed.getUTCFullYear() !== year || parsed.getUTCMonth() !== month - 1 || parsed.getUTCDate() !== day) return null;
|
|
456
|
-
return parsed;
|
|
457
|
-
}
|
|
458
|
-
function isEvergreenMemoryPath(filePath) {
|
|
459
|
-
const normalized = filePath.replaceAll("\\", "/").replace(/^\.\//, "");
|
|
460
|
-
if (normalized === "MEMORY.md" || normalized === "memory.md") return true;
|
|
461
|
-
if (!normalized.startsWith("memory/")) return false;
|
|
462
|
-
return !DATED_MEMORY_PATH_RE.test(normalized);
|
|
463
|
-
}
|
|
464
|
-
async function extractTimestamp(params) {
|
|
465
|
-
const fromPath = parseMemoryDateFromPath(params.filePath);
|
|
466
|
-
if (fromPath) return fromPath;
|
|
467
|
-
if (params.source === "memory" && isEvergreenMemoryPath(params.filePath)) return null;
|
|
468
|
-
if (!params.workspaceDir) return null;
|
|
469
|
-
const absolutePath = path.isAbsolute(params.filePath) ? params.filePath : path.resolve(params.workspaceDir, params.filePath);
|
|
470
|
-
try {
|
|
471
|
-
const stat = await fs$1.stat(absolutePath);
|
|
472
|
-
if (!Number.isFinite(stat.mtimeMs)) return null;
|
|
473
|
-
return new Date(stat.mtimeMs);
|
|
474
|
-
} catch {
|
|
475
|
-
return null;
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
function ageInDaysFromTimestamp(timestamp, nowMs) {
|
|
479
|
-
return Math.max(0, nowMs - timestamp.getTime()) / DAY_MS;
|
|
480
|
-
}
|
|
481
|
-
async function applyTemporalDecayToHybridResults(params) {
|
|
482
|
-
const config = {
|
|
483
|
-
...DEFAULT_TEMPORAL_DECAY_CONFIG,
|
|
484
|
-
...params.temporalDecay
|
|
485
|
-
};
|
|
486
|
-
if (!config.enabled) return [...params.results];
|
|
487
|
-
const nowMs = params.nowMs ?? Date.now();
|
|
488
|
-
const timestampPromiseCache = /* @__PURE__ */ new Map();
|
|
489
|
-
return Promise.all(params.results.map(async (entry) => {
|
|
490
|
-
const cacheKey = `${entry.source}:${entry.path}`;
|
|
491
|
-
let timestampPromise = timestampPromiseCache.get(cacheKey);
|
|
492
|
-
if (!timestampPromise) {
|
|
493
|
-
timestampPromise = extractTimestamp({
|
|
494
|
-
filePath: entry.path,
|
|
495
|
-
source: entry.source,
|
|
496
|
-
workspaceDir: params.workspaceDir
|
|
497
|
-
});
|
|
498
|
-
timestampPromiseCache.set(cacheKey, timestampPromise);
|
|
499
|
-
}
|
|
500
|
-
const timestamp = await timestampPromise;
|
|
501
|
-
if (!timestamp) return entry;
|
|
502
|
-
const decayedScore = applyTemporalDecayToScore({
|
|
503
|
-
score: entry.score,
|
|
504
|
-
ageInDays: ageInDaysFromTimestamp(timestamp, nowMs),
|
|
505
|
-
halfLifeDays: config.halfLifeDays
|
|
506
|
-
});
|
|
507
|
-
return {
|
|
508
|
-
...entry,
|
|
509
|
-
score: decayedScore
|
|
510
|
-
};
|
|
511
|
-
}));
|
|
512
|
-
}
|
|
513
|
-
//#endregion
|
|
514
|
-
//#region extensions/memory-core/src/memory/hybrid.ts
|
|
515
|
-
function buildFtsQuery(raw) {
|
|
516
|
-
const tokens = raw.match(/[\p{L}\p{N}_]+/gu)?.map((t) => t.trim()).filter(Boolean) ?? [];
|
|
517
|
-
if (tokens.length === 0) return null;
|
|
518
|
-
return tokens.map((t) => `"${t.replaceAll("\"", "")}"`).join(" AND ");
|
|
519
|
-
}
|
|
520
|
-
function bm25RankToScore(rank) {
|
|
521
|
-
if (!Number.isFinite(rank)) return 1 / 1e3;
|
|
522
|
-
if (rank < 0) {
|
|
523
|
-
const relevance = -rank;
|
|
524
|
-
return relevance / (1 + relevance);
|
|
525
|
-
}
|
|
526
|
-
return 1 / (1 + rank);
|
|
527
|
-
}
|
|
528
|
-
async function mergeHybridResults(params) {
|
|
529
|
-
const byId = /* @__PURE__ */ new Map();
|
|
530
|
-
for (const r of params.vector) byId.set(r.id, {
|
|
531
|
-
id: r.id,
|
|
532
|
-
path: r.path,
|
|
533
|
-
startLine: r.startLine,
|
|
534
|
-
endLine: r.endLine,
|
|
535
|
-
source: r.source,
|
|
536
|
-
snippet: r.snippet,
|
|
537
|
-
vectorScore: r.vectorScore,
|
|
538
|
-
textScore: 0
|
|
539
|
-
});
|
|
540
|
-
for (const r of params.keyword) {
|
|
541
|
-
const existing = byId.get(r.id);
|
|
542
|
-
if (existing) {
|
|
543
|
-
existing.textScore = r.textScore;
|
|
544
|
-
if (r.snippet && r.snippet.length > 0) existing.snippet = r.snippet;
|
|
545
|
-
} else byId.set(r.id, {
|
|
546
|
-
id: r.id,
|
|
547
|
-
path: r.path,
|
|
548
|
-
startLine: r.startLine,
|
|
549
|
-
endLine: r.endLine,
|
|
550
|
-
source: r.source,
|
|
551
|
-
snippet: r.snippet,
|
|
552
|
-
vectorScore: 0,
|
|
553
|
-
textScore: r.textScore
|
|
554
|
-
});
|
|
555
|
-
}
|
|
556
|
-
const sorted = (await applyTemporalDecayToHybridResults({
|
|
557
|
-
results: Array.from(byId.values()).map((entry) => {
|
|
558
|
-
const score = params.vectorWeight * entry.vectorScore + params.textWeight * entry.textScore;
|
|
559
|
-
return {
|
|
560
|
-
path: entry.path,
|
|
561
|
-
startLine: entry.startLine,
|
|
562
|
-
endLine: entry.endLine,
|
|
563
|
-
score,
|
|
564
|
-
snippet: entry.snippet,
|
|
565
|
-
source: entry.source
|
|
566
|
-
};
|
|
567
|
-
}),
|
|
568
|
-
temporalDecay: {
|
|
569
|
-
...DEFAULT_TEMPORAL_DECAY_CONFIG,
|
|
570
|
-
...params.temporalDecay
|
|
571
|
-
},
|
|
572
|
-
workspaceDir: params.workspaceDir,
|
|
573
|
-
nowMs: params.nowMs
|
|
574
|
-
})).toSorted((a, b) => b.score - a.score);
|
|
575
|
-
const dedupConfig = {
|
|
576
|
-
...DEFAULT_SEMANTIC_DEDUP_CONFIG,
|
|
577
|
-
...params.semanticDedup
|
|
578
|
-
};
|
|
579
|
-
const afterDedup = dedupConfig.enabled ? (() => {
|
|
580
|
-
const dedupedItems = deduplicateBySimilarity(sorted.map((r, i) => ({
|
|
581
|
-
id: `${r.path}:${r.startLine}:${i}`,
|
|
582
|
-
score: r.score,
|
|
583
|
-
content: r.snippet
|
|
584
|
-
})), dedupConfig);
|
|
585
|
-
const keptIds = new Set(dedupedItems.map((d) => d.id));
|
|
586
|
-
return sorted.filter((_, i) => keptIds.has(`${_.path}:${_.startLine}:${i}`));
|
|
587
|
-
})() : sorted;
|
|
588
|
-
const mmrConfig = {
|
|
589
|
-
...DEFAULT_MMR_CONFIG,
|
|
590
|
-
...params.mmr
|
|
591
|
-
};
|
|
592
|
-
if (mmrConfig.enabled) return applyMMRToHybridResults(afterDedup, mmrConfig);
|
|
593
|
-
return afterDedup;
|
|
594
|
-
}
|
|
595
|
-
//#endregion
|
|
596
|
-
//#region extensions/memory-core/src/memory/manager-async-state.ts
|
|
597
|
-
function startAsyncSearchSync(params) {
|
|
598
|
-
if (!params.enabled || !params.dirty && !params.sessionsDirty) return;
|
|
599
|
-
params.sync({ reason: "search" }).catch((err) => {
|
|
600
|
-
params.onError(err);
|
|
601
|
-
});
|
|
602
|
-
}
|
|
603
|
-
async function awaitPendingManagerWork(params) {
|
|
604
|
-
if (params.pendingSync) try {
|
|
605
|
-
await params.pendingSync;
|
|
606
|
-
} catch {}
|
|
607
|
-
if (params.pendingProviderInit) try {
|
|
608
|
-
await params.pendingProviderInit;
|
|
609
|
-
} catch {}
|
|
610
|
-
}
|
|
611
|
-
function resetMemoryBatchFailureState(state) {
|
|
612
|
-
return {
|
|
613
|
-
...state,
|
|
614
|
-
count: 0,
|
|
615
|
-
lastError: void 0,
|
|
616
|
-
lastProvider: void 0
|
|
617
|
-
};
|
|
618
|
-
}
|
|
619
|
-
function recordMemoryBatchFailure(state, params) {
|
|
620
|
-
if (!state.enabled) return state;
|
|
621
|
-
const increment = params.forceDisable ? 2 : Math.max(1, params.attempts ?? 1);
|
|
622
|
-
const count = state.count + increment;
|
|
623
|
-
return {
|
|
624
|
-
enabled: !(params.forceDisable || count >= 2),
|
|
625
|
-
count,
|
|
626
|
-
lastError: params.message,
|
|
627
|
-
lastProvider: params.provider
|
|
628
|
-
};
|
|
629
|
-
}
|
|
630
|
-
//#endregion
|
|
631
|
-
//#region extensions/memory-core/src/memory/manager-cache.ts
|
|
632
|
-
function resolveSingletonManagedCache(cacheKey) {
|
|
633
|
-
return resolveGlobalSingleton(cacheKey, () => ({
|
|
634
|
-
cache: /* @__PURE__ */ new Map(),
|
|
635
|
-
pending: /* @__PURE__ */ new Map()
|
|
636
|
-
}));
|
|
637
|
-
}
|
|
638
|
-
async function getOrCreateManagedCacheEntry(params) {
|
|
639
|
-
if (params.bypassCache) return await params.create();
|
|
640
|
-
const existing = params.cache.get(params.key);
|
|
641
|
-
if (existing) return existing;
|
|
642
|
-
const pending = params.pending.get(params.key);
|
|
643
|
-
if (pending) return pending;
|
|
644
|
-
const createPromise = (async () => {
|
|
645
|
-
const refreshed = params.cache.get(params.key);
|
|
646
|
-
if (refreshed) return refreshed;
|
|
647
|
-
const entry = await params.create();
|
|
648
|
-
params.cache.set(params.key, entry);
|
|
649
|
-
return entry;
|
|
650
|
-
})();
|
|
651
|
-
params.pending.set(params.key, createPromise);
|
|
652
|
-
try {
|
|
653
|
-
return await createPromise;
|
|
654
|
-
} finally {
|
|
655
|
-
if (params.pending.get(params.key) === createPromise) params.pending.delete(params.key);
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
async function closeManagedCacheEntries(params) {
|
|
659
|
-
const pending = Array.from(params.pending.values());
|
|
660
|
-
if (pending.length > 0) await Promise.allSettled(pending);
|
|
661
|
-
const entries = Array.from(params.cache.values());
|
|
662
|
-
params.cache.clear();
|
|
663
|
-
for (const entry of entries) {
|
|
664
|
-
if (typeof entry.close !== "function") continue;
|
|
665
|
-
try {
|
|
666
|
-
await entry.close();
|
|
667
|
-
} catch (err) {
|
|
668
|
-
params.onCloseError?.(err);
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
//#endregion
|
|
673
|
-
//#region extensions/memory-core/src/memory/manager-embedding-cache.ts
|
|
674
|
-
function loadMemoryEmbeddingCache(params) {
|
|
675
|
-
const provider = params.provider;
|
|
676
|
-
if (!params.enabled || !provider || !params.providerKey || params.hashes.length === 0) return /* @__PURE__ */ new Map();
|
|
677
|
-
const unique = [];
|
|
678
|
-
const seen = /* @__PURE__ */ new Set();
|
|
679
|
-
for (const hash of params.hashes) {
|
|
680
|
-
if (!hash || seen.has(hash)) continue;
|
|
681
|
-
seen.add(hash);
|
|
682
|
-
unique.push(hash);
|
|
683
|
-
}
|
|
684
|
-
if (unique.length === 0) return /* @__PURE__ */ new Map();
|
|
685
|
-
const tableName = params.tableName ?? "embedding_cache";
|
|
686
|
-
const out = /* @__PURE__ */ new Map();
|
|
687
|
-
const baseParams = [
|
|
688
|
-
provider.id,
|
|
689
|
-
provider.model,
|
|
690
|
-
params.providerKey
|
|
691
|
-
];
|
|
692
|
-
const batchSize = 400;
|
|
693
|
-
for (let start = 0; start < unique.length; start += batchSize) {
|
|
694
|
-
const batch = unique.slice(start, start + batchSize);
|
|
695
|
-
const placeholders = batch.map(() => "?").join(", ");
|
|
696
|
-
const rows = params.db.prepare(`SELECT hash, embedding FROM ${tableName}\n WHERE provider = ? AND model = ? AND provider_key = ? AND hash IN (${placeholders})`).all(...baseParams, ...batch);
|
|
697
|
-
for (const row of rows) out.set(row.hash, parseEmbedding(row.embedding));
|
|
698
|
-
}
|
|
699
|
-
return out;
|
|
700
|
-
}
|
|
701
|
-
function upsertMemoryEmbeddingCache(params) {
|
|
702
|
-
const provider = params.provider;
|
|
703
|
-
if (!params.enabled || !provider || !params.providerKey || params.entries.length === 0) return;
|
|
704
|
-
const tableName = params.tableName ?? "embedding_cache";
|
|
705
|
-
const now = params.now ?? Date.now();
|
|
706
|
-
const stmt = params.db.prepare(`INSERT INTO ${tableName} (provider, model, provider_key, hash, embedding, dims, updated_at)\n VALUES (?, ?, ?, ?, ?, ?, ?)\n ON CONFLICT(provider, model, provider_key, hash) DO UPDATE SET\n embedding=excluded.embedding,\n dims=excluded.dims,\n updated_at=excluded.updated_at`);
|
|
707
|
-
for (const entry of params.entries) {
|
|
708
|
-
const embedding = entry.embedding ?? [];
|
|
709
|
-
stmt.run(provider.id, provider.model, params.providerKey, entry.hash, JSON.stringify(embedding), embedding.length, now);
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
function collectMemoryCachedEmbeddings(params) {
|
|
713
|
-
const embeddings = Array.from({ length: params.chunks.length }, () => []);
|
|
714
|
-
const missing = [];
|
|
715
|
-
for (let index = 0; index < params.chunks.length; index += 1) {
|
|
716
|
-
const chunk = params.chunks[index];
|
|
717
|
-
const hit = chunk?.hash ? params.cached.get(chunk.hash) : void 0;
|
|
718
|
-
if (hit && hit.length > 0) embeddings[index] = hit;
|
|
719
|
-
else if (chunk) missing.push({
|
|
720
|
-
index,
|
|
721
|
-
chunk
|
|
722
|
-
});
|
|
723
|
-
}
|
|
724
|
-
return {
|
|
725
|
-
embeddings,
|
|
726
|
-
missing
|
|
727
|
-
};
|
|
728
|
-
}
|
|
729
|
-
//#endregion
|
|
730
|
-
//#region extensions/memory-core/src/memory/manager-embedding-policy.ts
|
|
731
|
-
function estimateUtf8Bytes(text) {
|
|
732
|
-
if (!text) return 0;
|
|
733
|
-
return Buffer.byteLength(text, "utf8");
|
|
734
|
-
}
|
|
735
|
-
function estimateStructuredEmbeddingInputBytes(input) {
|
|
736
|
-
if (!input.parts?.length) return estimateUtf8Bytes(input.text);
|
|
737
|
-
let total = 0;
|
|
738
|
-
for (const part of input.parts) if (part.type === "text") total += estimateUtf8Bytes(part.text);
|
|
739
|
-
else {
|
|
740
|
-
total += estimateUtf8Bytes(part.mimeType);
|
|
741
|
-
total += estimateUtf8Bytes(part.data);
|
|
742
|
-
}
|
|
743
|
-
return total;
|
|
744
|
-
}
|
|
745
|
-
function filterNonEmptyMemoryChunks(chunks) {
|
|
746
|
-
return chunks.filter((chunk) => chunk.text.trim().length > 0);
|
|
747
|
-
}
|
|
748
|
-
function buildMemoryEmbeddingBatches(chunks, maxTokens) {
|
|
749
|
-
const batches = [];
|
|
750
|
-
let current = [];
|
|
751
|
-
let currentTokens = 0;
|
|
752
|
-
for (const chunk of chunks) {
|
|
753
|
-
const estimate = chunk.embeddingInput ? estimateStructuredEmbeddingInputBytes(chunk.embeddingInput) : estimateUtf8Bytes(chunk.text);
|
|
754
|
-
if (current.length > 0 && currentTokens + estimate > maxTokens) {
|
|
755
|
-
batches.push(current);
|
|
756
|
-
current = [];
|
|
757
|
-
currentTokens = 0;
|
|
758
|
-
}
|
|
759
|
-
if (current.length === 0 && estimate > maxTokens) {
|
|
760
|
-
batches.push([chunk]);
|
|
761
|
-
continue;
|
|
762
|
-
}
|
|
763
|
-
current.push(chunk);
|
|
764
|
-
currentTokens += estimate;
|
|
765
|
-
}
|
|
766
|
-
if (current.length > 0) batches.push(current);
|
|
767
|
-
return batches;
|
|
768
|
-
}
|
|
769
|
-
function isRetryableMemoryEmbeddingError(message) {
|
|
770
|
-
return /(rate[_ ]limit|too many requests|429|resource has been exhausted|5\d\d|cloudflare|tokens per day)/i.test(message);
|
|
771
|
-
}
|
|
772
|
-
function resolveMemoryEmbeddingRetryDelay(delayMs, randomValue, maxDelayMs) {
|
|
773
|
-
return Math.min(maxDelayMs, Math.round(delayMs * (1 + randomValue * .2)));
|
|
774
|
-
}
|
|
775
|
-
async function runMemoryEmbeddingRetryLoop(params) {
|
|
776
|
-
let attempt = 0;
|
|
777
|
-
let delayMs = params.baseDelayMs;
|
|
778
|
-
while (true) try {
|
|
779
|
-
return await params.run();
|
|
780
|
-
} catch (err) {
|
|
781
|
-
const message = formatErrorMessage(err);
|
|
782
|
-
if (!params.isRetryable(message) || attempt >= params.maxAttempts) throw err;
|
|
783
|
-
await params.waitForRetry(delayMs);
|
|
784
|
-
delayMs *= 2;
|
|
785
|
-
attempt += 1;
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
function buildTextEmbeddingInputs(chunks) {
|
|
789
|
-
return chunks.map((chunk) => chunk.embeddingInput ?? { text: chunk.text });
|
|
790
|
-
}
|
|
791
|
-
//#endregion
|
|
792
|
-
//#region extensions/memory-core/src/memory/manager-fts-state.ts
|
|
793
|
-
function deleteMemoryFtsRows(params) {
|
|
794
|
-
const tableName = params.tableName ?? "chunks_fts";
|
|
795
|
-
if (params.currentModel) {
|
|
796
|
-
params.db.prepare(`DELETE FROM ${tableName} WHERE path = ? AND source = ? AND model = ?`).run(params.path, params.source, params.currentModel);
|
|
797
|
-
return;
|
|
798
|
-
}
|
|
799
|
-
params.db.prepare(`DELETE FROM ${tableName} WHERE path = ? AND source = ?`).run(params.path, params.source);
|
|
800
|
-
}
|
|
801
|
-
//#endregion
|
|
802
|
-
//#region extensions/memory-core/src/memory/manager-atomic-reindex.ts
|
|
803
|
-
const defaultFileOps = {
|
|
804
|
-
rename: fs$1.rename,
|
|
805
|
-
rm: fs$1.rm,
|
|
806
|
-
wait: setTimeout$1
|
|
807
|
-
};
|
|
808
|
-
const transientFileErrorCodes = new Set([
|
|
809
|
-
"EBUSY",
|
|
810
|
-
"EPERM",
|
|
811
|
-
"EACCES"
|
|
812
|
-
]);
|
|
813
|
-
const defaultMaxRenameAttempts = 6;
|
|
814
|
-
const defaultRenameRetryDelayMs = 25;
|
|
815
|
-
const defaultMaxRemoveAttempts = 10;
|
|
816
|
-
const defaultRemoveRetryDelayMs = 50;
|
|
817
|
-
function isTransientFileError(err) {
|
|
818
|
-
return transientFileErrorCodes.has(err.code ?? "");
|
|
819
|
-
}
|
|
820
|
-
function resolveMemoryIndexFileOptions(options = {}) {
|
|
821
|
-
return {
|
|
822
|
-
fileOps: options.fileOps ?? defaultFileOps,
|
|
823
|
-
maxRenameAttempts: Math.max(1, options.maxRenameAttempts ?? defaultMaxRenameAttempts),
|
|
824
|
-
renameRetryDelayMs: options.renameRetryDelayMs ?? defaultRenameRetryDelayMs,
|
|
825
|
-
maxRemoveAttempts: Math.max(1, options.maxRemoveAttempts ?? defaultMaxRemoveAttempts),
|
|
826
|
-
removeRetryDelayMs: options.removeRetryDelayMs ?? defaultRemoveRetryDelayMs
|
|
827
|
-
};
|
|
828
|
-
}
|
|
829
|
-
async function renameWithRetry(source, target, options) {
|
|
830
|
-
for (let attempt = 1; attempt <= options.maxRenameAttempts; attempt++) try {
|
|
831
|
-
await options.fileOps.rename(source, target);
|
|
832
|
-
return;
|
|
833
|
-
} catch (err) {
|
|
834
|
-
if (err.code === "ENOENT") return;
|
|
835
|
-
if (!isTransientFileError(err) || attempt === options.maxRenameAttempts) throw err;
|
|
836
|
-
await options.fileOps.wait(options.renameRetryDelayMs * attempt);
|
|
837
|
-
}
|
|
838
|
-
throw new Error("rename retry loop exited unexpectedly");
|
|
839
|
-
}
|
|
840
|
-
async function moveMemoryIndexFiles(sourceBase, targetBase, options = {}) {
|
|
841
|
-
const resolvedOptions = resolveMemoryIndexFileOptions(options);
|
|
842
|
-
for (const suffix of [
|
|
843
|
-
"",
|
|
844
|
-
"-wal",
|
|
845
|
-
"-shm"
|
|
846
|
-
]) await renameWithRetry(`${sourceBase}${suffix}`, `${targetBase}${suffix}`, resolvedOptions);
|
|
847
|
-
}
|
|
848
|
-
async function rmWithRetry(path, options) {
|
|
849
|
-
for (let attempt = 1; attempt <= options.maxRemoveAttempts; attempt++) try {
|
|
850
|
-
await options.fileOps.rm(path, { force: true });
|
|
851
|
-
return;
|
|
852
|
-
} catch (err) {
|
|
853
|
-
if (err.code === "ENOENT") return;
|
|
854
|
-
if (!isTransientFileError(err) || attempt === options.maxRemoveAttempts) throw err;
|
|
855
|
-
await options.fileOps.wait(options.removeRetryDelayMs * attempt);
|
|
856
|
-
}
|
|
857
|
-
throw new Error("rm retry loop exited unexpectedly");
|
|
858
|
-
}
|
|
859
|
-
async function removeMemoryIndexFiles(basePath, options = {}) {
|
|
860
|
-
const resolvedOptions = resolveMemoryIndexFileOptions(options);
|
|
861
|
-
for (const suffix of [
|
|
862
|
-
"",
|
|
863
|
-
"-wal",
|
|
864
|
-
"-shm"
|
|
865
|
-
]) await rmWithRetry(`${basePath}${suffix}`, resolvedOptions);
|
|
866
|
-
}
|
|
867
|
-
async function swapMemoryIndexFiles(targetPath, tempPath) {
|
|
868
|
-
const backupPath = `${targetPath}.backup-${randomUUID()}`;
|
|
869
|
-
await moveMemoryIndexFiles(targetPath, backupPath);
|
|
870
|
-
try {
|
|
871
|
-
await moveMemoryIndexFiles(tempPath, targetPath);
|
|
872
|
-
} catch (err) {
|
|
873
|
-
await moveMemoryIndexFiles(backupPath, targetPath);
|
|
874
|
-
throw err;
|
|
875
|
-
}
|
|
876
|
-
await removeMemoryIndexFiles(backupPath);
|
|
877
|
-
}
|
|
878
|
-
async function runMemoryAtomicReindex(params) {
|
|
879
|
-
try {
|
|
880
|
-
const result = await params.build();
|
|
881
|
-
await swapMemoryIndexFiles(params.targetPath, params.tempPath);
|
|
882
|
-
return result;
|
|
883
|
-
} catch (err) {
|
|
884
|
-
try {
|
|
885
|
-
await params.beforeTempCleanup?.();
|
|
886
|
-
await removeMemoryIndexFiles(params.tempPath, params.fileOptions);
|
|
887
|
-
} catch (cleanupErr) {
|
|
888
|
-
throw new AggregateError([err, cleanupErr], "memory atomic reindex failed and temp cleanup failed", { cause: cleanupErr });
|
|
889
|
-
}
|
|
890
|
-
throw err;
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
//#endregion
|
|
894
|
-
//#region extensions/memory-core/src/memory/manager-db.ts
|
|
895
|
-
function openMemoryDatabaseAtPath(dbPath, allowExtension) {
|
|
896
|
-
ensureDir(path.dirname(dbPath));
|
|
897
|
-
const { DatabaseSync } = requireNodeSqlite();
|
|
898
|
-
const db = new DatabaseSync(dbPath, { allowExtension });
|
|
899
|
-
db.exec("PRAGMA busy_timeout = 5000");
|
|
900
|
-
return db;
|
|
901
|
-
}
|
|
902
|
-
//#endregion
|
|
903
|
-
//#region extensions/memory-core/src/memory/manager-provider-state.ts
|
|
904
|
-
function resolveMemoryPrimaryProviderRequest(params) {
|
|
905
|
-
return {
|
|
906
|
-
provider: params.settings.provider,
|
|
907
|
-
model: params.settings.model,
|
|
908
|
-
remote: params.settings.remote,
|
|
909
|
-
outputDimensionality: params.settings.outputDimensionality,
|
|
910
|
-
fallback: params.settings.fallback,
|
|
911
|
-
local: params.settings.local
|
|
912
|
-
};
|
|
913
|
-
}
|
|
914
|
-
function resolveMemoryProviderState(result) {
|
|
915
|
-
return {
|
|
916
|
-
provider: result.provider,
|
|
917
|
-
fallbackFrom: result.fallbackFrom,
|
|
918
|
-
fallbackReason: result.fallbackReason,
|
|
919
|
-
providerUnavailableReason: result.providerUnavailableReason,
|
|
920
|
-
providerRuntime: result.runtime
|
|
921
|
-
};
|
|
922
|
-
}
|
|
923
|
-
function applyMemoryFallbackProviderState(params) {
|
|
924
|
-
return {
|
|
925
|
-
...params.current,
|
|
926
|
-
fallbackFrom: params.fallbackFrom,
|
|
927
|
-
fallbackReason: params.reason,
|
|
928
|
-
provider: params.result.provider,
|
|
929
|
-
providerRuntime: params.result.runtime
|
|
930
|
-
};
|
|
931
|
-
}
|
|
932
|
-
function resolveMemoryFallbackProviderRequest(params) {
|
|
933
|
-
const fallback = params.settings.fallback;
|
|
934
|
-
if (!fallback || fallback === "none" || !params.currentProviderId || fallback === params.currentProviderId) return null;
|
|
935
|
-
return {
|
|
936
|
-
provider: fallback,
|
|
937
|
-
model: resolveEmbeddingProviderFallbackModel(fallback, params.settings.model, params.cfg),
|
|
938
|
-
remote: params.settings.remote,
|
|
939
|
-
outputDimensionality: params.settings.outputDimensionality,
|
|
940
|
-
fallback: "none",
|
|
941
|
-
local: params.settings.local
|
|
942
|
-
};
|
|
943
|
-
}
|
|
944
|
-
//#endregion
|
|
945
|
-
//#region extensions/memory-core/src/memory/manager-reindex-state.ts
|
|
946
|
-
function resolveConfiguredSourcesForMeta(sources) {
|
|
947
|
-
const normalized = Array.from(sources).filter((source) => source === "memory" || source === "sessions").toSorted();
|
|
948
|
-
return normalized.length > 0 ? normalized : ["memory"];
|
|
949
|
-
}
|
|
950
|
-
function normalizeMetaSources(meta) {
|
|
951
|
-
if (!Array.isArray(meta.sources)) return ["memory"];
|
|
952
|
-
const normalized = Array.from(new Set(meta.sources.filter((source) => source === "memory" || source === "sessions"))).toSorted();
|
|
953
|
-
return normalized.length > 0 ? normalized : ["memory"];
|
|
954
|
-
}
|
|
955
|
-
function configuredMetaSourcesDiffer(params) {
|
|
956
|
-
const metaSources = normalizeMetaSources(params.meta);
|
|
957
|
-
if (metaSources.length !== params.configuredSources.length) return true;
|
|
958
|
-
return metaSources.some((source, index) => source !== params.configuredSources[index]);
|
|
959
|
-
}
|
|
960
|
-
function resolveConfiguredScopeHash(params) {
|
|
961
|
-
const extraPaths = normalizeExtraMemoryPaths(params.workspaceDir, params.extraPaths).map((value) => value.replace(/\\/g, "/")).toSorted();
|
|
962
|
-
return hashText(JSON.stringify({
|
|
963
|
-
extraPaths,
|
|
964
|
-
multimodal: {
|
|
965
|
-
enabled: params.multimodal.enabled,
|
|
966
|
-
modalities: [...params.multimodal.modalities].toSorted(),
|
|
967
|
-
maxFileBytes: params.multimodal.maxFileBytes
|
|
968
|
-
}
|
|
969
|
-
}));
|
|
970
|
-
}
|
|
971
|
-
function shouldRunFullMemoryReindex(params) {
|
|
972
|
-
const { meta } = params;
|
|
973
|
-
return !meta || (params.provider ? meta.model !== params.provider.model : meta.model !== "fts-only") || (params.provider ? meta.provider !== params.provider.id : meta.provider !== "none") || meta.providerKey !== params.providerKey || configuredMetaSourcesDiffer({
|
|
974
|
-
meta,
|
|
975
|
-
configuredSources: params.configuredSources
|
|
976
|
-
}) || meta.scopeHash !== params.configuredScopeHash || meta.chunkTokens !== params.chunkTokens || meta.chunkOverlap !== params.chunkOverlap || params.vectorReady && params.provider !== null && !meta.vectorDims || (meta.ftsTokenizer ?? "porter") !== (params.ftsTokenizer ?? "porter");
|
|
977
|
-
}
|
|
978
|
-
//#endregion
|
|
979
|
-
//#region extensions/memory-core/src/memory/manager-session-reindex.ts
|
|
980
|
-
function shouldSyncSessionsForReindex(params) {
|
|
981
|
-
if (!params.hasSessionSource) return false;
|
|
982
|
-
if (params.sync?.sessionFiles?.some((sessionFile) => sessionFile.trim().length > 0)) return true;
|
|
983
|
-
if (params.sync?.force) return true;
|
|
984
|
-
if (params.needsFullReindex) return true;
|
|
985
|
-
const reason = params.sync?.reason;
|
|
986
|
-
if (reason === "session-start" || reason === "watch") return false;
|
|
987
|
-
return params.sessionsDirty && params.dirtySessionFileCount > 0;
|
|
988
|
-
}
|
|
989
|
-
//#endregion
|
|
990
|
-
//#region extensions/memory-core/src/memory/manager-session-sync-state.ts
|
|
991
|
-
function resolveMemorySessionSyncPlan(params) {
|
|
992
|
-
const activePaths = params.targetSessionFiles ? null : new Set(params.files.map((file) => params.sessionPathForFile(file)));
|
|
993
|
-
const existingRows = activePaths === null ? null : params.existingRows ?? [];
|
|
994
|
-
return {
|
|
995
|
-
activePaths,
|
|
996
|
-
existingRows,
|
|
997
|
-
existingHashes: existingRows ? new Map(existingRows.map((row) => [row.path, row.hash])) : null,
|
|
998
|
-
indexAll: params.needsFullReindex || Boolean(params.targetSessionFiles) || params.sessionsDirtyFiles.size === 0
|
|
999
|
-
};
|
|
1000
|
-
}
|
|
1001
|
-
//#endregion
|
|
1002
|
-
//#region extensions/memory-core/src/memory/manager-source-state.ts
|
|
1003
|
-
const MEMORY_SOURCE_FILE_STATE_SQL = `SELECT path, hash FROM files WHERE source = ?`;
|
|
1004
|
-
const MEMORY_SOURCE_FILE_HASH_SQL = `SELECT hash FROM files WHERE path = ? AND source = ?`;
|
|
1005
|
-
function loadMemorySourceFileState(params) {
|
|
1006
|
-
const normalizedRows = params.db.prepare(MEMORY_SOURCE_FILE_STATE_SQL).all(params.source) ?? [];
|
|
1007
|
-
return {
|
|
1008
|
-
rows: normalizedRows,
|
|
1009
|
-
hashes: new Map(normalizedRows.map((row) => [row.path, row.hash]))
|
|
1010
|
-
};
|
|
1011
|
-
}
|
|
1012
|
-
function resolveMemorySourceExistingHash(params) {
|
|
1013
|
-
if (params.existingHashes) return params.existingHashes.get(params.path);
|
|
1014
|
-
return params.db.prepare(MEMORY_SOURCE_FILE_HASH_SQL).get(params.path, params.source)?.hash;
|
|
1015
|
-
}
|
|
1016
|
-
//#endregion
|
|
1017
|
-
//#region extensions/memory-core/src/memory/manager-targeted-sync.ts
|
|
1018
|
-
function clearMemorySyncedSessionFiles(params) {
|
|
1019
|
-
if (!params.targetSessionFiles) params.sessionsDirtyFiles.clear();
|
|
1020
|
-
else for (const targetSessionFile of params.targetSessionFiles) params.sessionsDirtyFiles.delete(targetSessionFile);
|
|
1021
|
-
return params.sessionsDirtyFiles.size > 0;
|
|
1022
|
-
}
|
|
1023
|
-
async function runMemoryTargetedSessionSync(params) {
|
|
1024
|
-
if (!params.hasSessionSource || !params.targetSessionFiles) return {
|
|
1025
|
-
handled: false,
|
|
1026
|
-
sessionsDirty: params.sessionsDirtyFiles.size > 0
|
|
1027
|
-
};
|
|
1028
|
-
try {
|
|
1029
|
-
await params.syncSessionFiles({
|
|
1030
|
-
needsFullReindex: false,
|
|
1031
|
-
targetSessionFiles: Array.from(params.targetSessionFiles),
|
|
1032
|
-
progress: params.progress
|
|
1033
|
-
});
|
|
1034
|
-
return {
|
|
1035
|
-
handled: true,
|
|
1036
|
-
sessionsDirty: clearMemorySyncedSessionFiles({
|
|
1037
|
-
sessionsDirtyFiles: params.sessionsDirtyFiles,
|
|
1038
|
-
targetSessionFiles: params.targetSessionFiles
|
|
1039
|
-
})
|
|
1040
|
-
};
|
|
1041
|
-
} catch (err) {
|
|
1042
|
-
const reason = formatErrorMessage(err);
|
|
1043
|
-
if (!(params.shouldFallbackOnError(reason) && await params.activateFallbackProvider(reason))) throw err;
|
|
1044
|
-
const reindexParams = {
|
|
1045
|
-
reason: params.reason,
|
|
1046
|
-
force: true,
|
|
1047
|
-
progress: params.progress
|
|
1048
|
-
};
|
|
1049
|
-
if (params.useUnsafeReindex) await params.runUnsafeReindex(reindexParams);
|
|
1050
|
-
else await params.runSafeReindex(reindexParams);
|
|
1051
|
-
return {
|
|
1052
|
-
handled: true,
|
|
1053
|
-
sessionsDirty: params.sessionsDirtyFiles.size > 0
|
|
1054
|
-
};
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
//#endregion
|
|
1058
|
-
//#region extensions/memory-core/src/memory/manager-sync-ops.ts
|
|
1059
|
-
const META_KEY = "memory_index_meta_v1";
|
|
1060
|
-
const VECTOR_TABLE$2 = "chunks_vec";
|
|
1061
|
-
const FTS_TABLE$2 = "chunks_fts";
|
|
1062
|
-
const EMBEDDING_CACHE_TABLE$2 = "embedding_cache";
|
|
1063
|
-
const SESSION_DIRTY_DEBOUNCE_MS = 5e3;
|
|
1064
|
-
const SESSION_DELTA_READ_CHUNK_BYTES = 64 * 1024;
|
|
1065
|
-
const VECTOR_LOAD_TIMEOUT_MS = 3e4;
|
|
1066
|
-
const IGNORED_MEMORY_WATCH_DIR_NAMES = new Set([
|
|
1067
|
-
".git",
|
|
1068
|
-
"node_modules",
|
|
1069
|
-
".pnpm-store",
|
|
1070
|
-
".venv",
|
|
1071
|
-
"venv",
|
|
1072
|
-
".tox",
|
|
1073
|
-
"__pycache__"
|
|
1074
|
-
]);
|
|
1075
|
-
const log$3 = createSubsystemLogger("memory");
|
|
1076
|
-
function shouldIgnoreMemoryWatchPath(watchPath, stats, multimodalSettings) {
|
|
1077
|
-
const normalized = path.normalize(watchPath);
|
|
1078
|
-
if (normalized.split(path.sep).map((segment) => normalizeLowercaseStringOrEmpty(segment)).some((segment) => IGNORED_MEMORY_WATCH_DIR_NAMES.has(segment))) return true;
|
|
1079
|
-
if (stats?.isDirectory?.()) return false;
|
|
1080
|
-
const extension = normalizeLowercaseStringOrEmpty(path.extname(normalized));
|
|
1081
|
-
if (extension.length === 0 || extension === ".md") return false;
|
|
1082
|
-
if (!multimodalSettings) return true;
|
|
1083
|
-
return classifyMemoryMultimodalPath(normalized, multimodalSettings) === null;
|
|
1084
|
-
}
|
|
1085
|
-
function runDetachedMemorySync(sync, reason) {
|
|
1086
|
-
sync().catch((err) => {
|
|
1087
|
-
log$3.warn(`memory sync failed (${reason}): ${String(err)}`);
|
|
1088
|
-
});
|
|
1089
|
-
}
|
|
1090
|
-
var MemoryManagerSyncOps = class {
|
|
1091
|
-
constructor() {
|
|
1092
|
-
this.provider = null;
|
|
1093
|
-
this.sources = /* @__PURE__ */ new Set();
|
|
1094
|
-
this.providerKey = null;
|
|
1095
|
-
this.fts = {
|
|
1096
|
-
enabled: false,
|
|
1097
|
-
available: false
|
|
1098
|
-
};
|
|
1099
|
-
this.vectorReady = null;
|
|
1100
|
-
this.watcher = null;
|
|
1101
|
-
this.watchTimer = null;
|
|
1102
|
-
this.sessionWatchTimer = null;
|
|
1103
|
-
this.sessionUnsubscribe = null;
|
|
1104
|
-
this.intervalTimer = null;
|
|
1105
|
-
this.closed = false;
|
|
1106
|
-
this.dirty = false;
|
|
1107
|
-
this.sessionsDirty = false;
|
|
1108
|
-
this.sessionsDirtyFiles = /* @__PURE__ */ new Set();
|
|
1109
|
-
this.sessionPendingFiles = /* @__PURE__ */ new Set();
|
|
1110
|
-
this.sessionDeltas = /* @__PURE__ */ new Map();
|
|
1111
|
-
this.lastMetaSerialized = null;
|
|
1112
|
-
}
|
|
1113
|
-
async ensureVectorReady(dimensions) {
|
|
1114
|
-
if (!this.vector.enabled) return false;
|
|
1115
|
-
if (!this.vectorReady) this.vectorReady = this.withTimeout(this.loadVectorExtension(), VECTOR_LOAD_TIMEOUT_MS, `sqlite-vec load timed out after ${Math.round(VECTOR_LOAD_TIMEOUT_MS / 1e3)}s`);
|
|
1116
|
-
let ready = false;
|
|
1117
|
-
try {
|
|
1118
|
-
ready = await this.vectorReady || false;
|
|
1119
|
-
} catch (err) {
|
|
1120
|
-
const message = formatErrorMessage(err);
|
|
1121
|
-
this.vector.available = false;
|
|
1122
|
-
this.vector.loadError = message;
|
|
1123
|
-
this.vectorReady = null;
|
|
1124
|
-
log$3.warn(`sqlite-vec unavailable: ${message}`);
|
|
1125
|
-
return false;
|
|
1126
|
-
}
|
|
1127
|
-
if (ready && typeof dimensions === "number" && dimensions > 0) this.ensureVectorTable(dimensions);
|
|
1128
|
-
return ready;
|
|
1129
|
-
}
|
|
1130
|
-
async loadVectorExtension() {
|
|
1131
|
-
if (this.vector.available !== null) return this.vector.available;
|
|
1132
|
-
if (!this.vector.enabled) {
|
|
1133
|
-
this.vector.available = false;
|
|
1134
|
-
return false;
|
|
1135
|
-
}
|
|
1136
|
-
try {
|
|
1137
|
-
const resolvedPath = this.vector.extensionPath?.trim() ? resolveUserPath(this.vector.extensionPath) : void 0;
|
|
1138
|
-
const loaded = await loadSqliteVecExtension({
|
|
1139
|
-
db: this.db,
|
|
1140
|
-
extensionPath: resolvedPath
|
|
1141
|
-
});
|
|
1142
|
-
if (!loaded.ok) throw new Error(loaded.error ?? "unknown sqlite-vec load error");
|
|
1143
|
-
this.vector.extensionPath = loaded.extensionPath;
|
|
1144
|
-
this.vector.available = true;
|
|
1145
|
-
return true;
|
|
1146
|
-
} catch (err) {
|
|
1147
|
-
const message = formatErrorMessage(err);
|
|
1148
|
-
this.vector.available = false;
|
|
1149
|
-
this.vector.loadError = message;
|
|
1150
|
-
log$3.warn(`sqlite-vec unavailable: ${message}`);
|
|
1151
|
-
return false;
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
ensureVectorTable(dimensions) {
|
|
1155
|
-
if (this.vector.dims === dimensions) return;
|
|
1156
|
-
if (this.vector.dims && this.vector.dims !== dimensions) this.dropVectorTable();
|
|
1157
|
-
this.db.exec(`CREATE VIRTUAL TABLE IF NOT EXISTS ${VECTOR_TABLE$2} USING vec0(\n id TEXT PRIMARY KEY,\n embedding FLOAT[${dimensions}]\n)`);
|
|
1158
|
-
this.vector.dims = dimensions;
|
|
1159
|
-
}
|
|
1160
|
-
dropVectorTable() {
|
|
1161
|
-
try {
|
|
1162
|
-
this.db.exec(`DROP TABLE IF EXISTS ${VECTOR_TABLE$2}`);
|
|
1163
|
-
} catch (err) {
|
|
1164
|
-
const message = formatErrorMessage(err);
|
|
1165
|
-
log$3.debug(`Failed to drop ${VECTOR_TABLE$2}: ${message}`);
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
hasVectorTable() {
|
|
1169
|
-
return this.db.prepare(`SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?`).get(VECTOR_TABLE$2) !== void 0;
|
|
1170
|
-
}
|
|
1171
|
-
buildSourceFilter(alias) {
|
|
1172
|
-
const sources = Array.from(this.sources);
|
|
1173
|
-
if (sources.length === 0) return {
|
|
1174
|
-
sql: "",
|
|
1175
|
-
params: []
|
|
1176
|
-
};
|
|
1177
|
-
return {
|
|
1178
|
-
sql: ` AND ${alias ? `${alias}.source` : "source"} IN (${sources.map(() => "?").join(", ")})`,
|
|
1179
|
-
params: sources
|
|
1180
|
-
};
|
|
1181
|
-
}
|
|
1182
|
-
openDatabase() {
|
|
1183
|
-
return openMemoryDatabaseAtPath(resolveUserPath(this.settings.store.path), this.settings.store.vector.enabled);
|
|
1184
|
-
}
|
|
1185
|
-
seedEmbeddingCache(sourceDb) {
|
|
1186
|
-
if (!this.cache.enabled) return;
|
|
1187
|
-
try {
|
|
1188
|
-
const rows = sourceDb.prepare(`SELECT provider, model, provider_key, hash, embedding, dims, updated_at FROM ${EMBEDDING_CACHE_TABLE$2}`).all();
|
|
1189
|
-
if (!rows.length) return;
|
|
1190
|
-
const insert = this.db.prepare(`INSERT INTO ${EMBEDDING_CACHE_TABLE$2} (provider, model, provider_key, hash, embedding, dims, updated_at)
|
|
1191
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
1192
|
-
ON CONFLICT(provider, model, provider_key, hash) DO UPDATE SET
|
|
1193
|
-
embedding=excluded.embedding,
|
|
1194
|
-
dims=excluded.dims,
|
|
1195
|
-
updated_at=excluded.updated_at`);
|
|
1196
|
-
this.db.exec("BEGIN");
|
|
1197
|
-
for (const row of rows) insert.run(row.provider, row.model, row.provider_key, row.hash, row.embedding, row.dims, row.updated_at);
|
|
1198
|
-
this.db.exec("COMMIT");
|
|
1199
|
-
} catch (err) {
|
|
1200
|
-
try {
|
|
1201
|
-
this.db.exec("ROLLBACK");
|
|
1202
|
-
} catch {}
|
|
1203
|
-
throw err;
|
|
1204
|
-
}
|
|
1205
|
-
}
|
|
1206
|
-
ensureSchema() {
|
|
1207
|
-
const result = ensureMemoryIndexSchema({
|
|
1208
|
-
db: this.db,
|
|
1209
|
-
embeddingCacheTable: EMBEDDING_CACHE_TABLE$2,
|
|
1210
|
-
cacheEnabled: this.cache.enabled,
|
|
1211
|
-
ftsTable: FTS_TABLE$2,
|
|
1212
|
-
ftsEnabled: this.fts.enabled,
|
|
1213
|
-
ftsTokenizer: this.settings.store.fts.tokenizer
|
|
1214
|
-
});
|
|
1215
|
-
this.fts.available = result.ftsAvailable;
|
|
1216
|
-
if (result.ftsError) {
|
|
1217
|
-
this.fts.loadError = result.ftsError;
|
|
1218
|
-
if (this.fts.enabled) log$3.warn(`fts unavailable: ${result.ftsError}`);
|
|
1219
|
-
}
|
|
1220
|
-
}
|
|
1221
|
-
ensureWatcher() {
|
|
1222
|
-
if (!this.sources.has("memory") || !this.settings.sync.watch || this.watcher) return;
|
|
1223
|
-
const watchPaths = new Set([
|
|
1224
|
-
path.join(this.workspaceDir, "MEMORY.md"),
|
|
1225
|
-
path.join(this.workspaceDir, "memory.md"),
|
|
1226
|
-
path.join(this.workspaceDir, "memory")
|
|
1227
|
-
]);
|
|
1228
|
-
const additionalPaths = normalizeExtraMemoryPaths(this.workspaceDir, this.settings.extraPaths);
|
|
1229
|
-
for (const entry of additionalPaths) try {
|
|
1230
|
-
const stat = fs.lstatSync(entry);
|
|
1231
|
-
if (stat.isSymbolicLink()) continue;
|
|
1232
|
-
if (stat.isDirectory()) {
|
|
1233
|
-
watchPaths.add(path.join(entry, "**", "*.md"));
|
|
1234
|
-
if (this.settings.multimodal.enabled) for (const modality of this.settings.multimodal.modalities) for (const extension of getMemoryMultimodalExtensions(modality)) watchPaths.add(path.join(entry, "**", buildCaseInsensitiveExtensionGlob(extension)));
|
|
1235
|
-
continue;
|
|
1236
|
-
}
|
|
1237
|
-
if (stat.isFile() && (normalizeLowercaseStringOrEmpty(entry).endsWith(".md") || classifyMemoryMultimodalPath(entry, this.settings.multimodal) !== null)) watchPaths.add(entry);
|
|
1238
|
-
} catch {}
|
|
1239
|
-
this.watcher = chokidar.watch(Array.from(watchPaths), {
|
|
1240
|
-
ignoreInitial: true,
|
|
1241
|
-
ignored: (watchPath, stats) => shouldIgnoreMemoryWatchPath(watchPath, stats, this.settings.multimodal),
|
|
1242
|
-
awaitWriteFinish: {
|
|
1243
|
-
stabilityThreshold: this.settings.sync.watchDebounceMs,
|
|
1244
|
-
pollInterval: 100
|
|
1245
|
-
}
|
|
1246
|
-
});
|
|
1247
|
-
const markDirty = () => {
|
|
1248
|
-
this.dirty = true;
|
|
1249
|
-
this.scheduleWatchSync();
|
|
1250
|
-
};
|
|
1251
|
-
this.watcher.on("add", markDirty);
|
|
1252
|
-
this.watcher.on("change", markDirty);
|
|
1253
|
-
this.watcher.on("unlink", markDirty);
|
|
1254
|
-
}
|
|
1255
|
-
ensureSessionListener() {
|
|
1256
|
-
if (!this.sources.has("sessions") || this.sessionUnsubscribe) return;
|
|
1257
|
-
this.sessionUnsubscribe = onSessionTranscriptUpdate((update) => {
|
|
1258
|
-
if (this.closed) return;
|
|
1259
|
-
const sessionFile = update.sessionFile;
|
|
1260
|
-
if (!this.isSessionFileForAgent(sessionFile)) return;
|
|
1261
|
-
this.scheduleSessionDirty(sessionFile);
|
|
1262
|
-
});
|
|
1263
|
-
}
|
|
1264
|
-
scheduleSessionDirty(sessionFile) {
|
|
1265
|
-
this.sessionPendingFiles.add(sessionFile);
|
|
1266
|
-
if (this.sessionWatchTimer) return;
|
|
1267
|
-
this.sessionWatchTimer = setTimeout(() => {
|
|
1268
|
-
this.sessionWatchTimer = null;
|
|
1269
|
-
this.processSessionDeltaBatch().catch((err) => {
|
|
1270
|
-
log$3.warn(`memory session delta failed: ${String(err)}`);
|
|
1271
|
-
});
|
|
1272
|
-
}, SESSION_DIRTY_DEBOUNCE_MS);
|
|
1273
|
-
}
|
|
1274
|
-
async processSessionDeltaBatch() {
|
|
1275
|
-
if (this.sessionPendingFiles.size === 0) return;
|
|
1276
|
-
const pending = Array.from(this.sessionPendingFiles);
|
|
1277
|
-
this.sessionPendingFiles.clear();
|
|
1278
|
-
let shouldSync = false;
|
|
1279
|
-
for (const sessionFile of pending) {
|
|
1280
|
-
const delta = await this.updateSessionDelta(sessionFile);
|
|
1281
|
-
if (!delta) continue;
|
|
1282
|
-
const bytesThreshold = delta.deltaBytes;
|
|
1283
|
-
const messagesThreshold = delta.deltaMessages;
|
|
1284
|
-
const bytesHit = bytesThreshold <= 0 ? delta.pendingBytes > 0 : delta.pendingBytes >= bytesThreshold;
|
|
1285
|
-
const messagesHit = messagesThreshold <= 0 ? delta.pendingMessages > 0 : delta.pendingMessages >= messagesThreshold;
|
|
1286
|
-
if (!bytesHit && !messagesHit) continue;
|
|
1287
|
-
this.sessionsDirtyFiles.add(sessionFile);
|
|
1288
|
-
this.sessionsDirty = true;
|
|
1289
|
-
delta.pendingBytes = bytesThreshold > 0 ? Math.max(0, delta.pendingBytes - bytesThreshold) : 0;
|
|
1290
|
-
delta.pendingMessages = messagesThreshold > 0 ? Math.max(0, delta.pendingMessages - messagesThreshold) : 0;
|
|
1291
|
-
shouldSync = true;
|
|
1292
|
-
}
|
|
1293
|
-
if (shouldSync) this.sync({ reason: "session-delta" }).catch((err) => {
|
|
1294
|
-
log$3.warn(`memory sync failed (session-delta): ${String(err)}`);
|
|
1295
|
-
});
|
|
1296
|
-
}
|
|
1297
|
-
async updateSessionDelta(sessionFile) {
|
|
1298
|
-
const thresholds = this.settings.sync.sessions;
|
|
1299
|
-
if (!thresholds) return null;
|
|
1300
|
-
let stat;
|
|
1301
|
-
try {
|
|
1302
|
-
stat = await fs$1.stat(sessionFile);
|
|
1303
|
-
} catch {
|
|
1304
|
-
return null;
|
|
1305
|
-
}
|
|
1306
|
-
const size = stat.size;
|
|
1307
|
-
let state = this.sessionDeltas.get(sessionFile);
|
|
1308
|
-
if (!state) {
|
|
1309
|
-
state = {
|
|
1310
|
-
lastSize: 0,
|
|
1311
|
-
pendingBytes: 0,
|
|
1312
|
-
pendingMessages: 0
|
|
1313
|
-
};
|
|
1314
|
-
this.sessionDeltas.set(sessionFile, state);
|
|
1315
|
-
}
|
|
1316
|
-
const deltaBytes = Math.max(0, size - state.lastSize);
|
|
1317
|
-
if (deltaBytes === 0 && size === state.lastSize) return {
|
|
1318
|
-
deltaBytes: thresholds.deltaBytes,
|
|
1319
|
-
deltaMessages: thresholds.deltaMessages,
|
|
1320
|
-
pendingBytes: state.pendingBytes,
|
|
1321
|
-
pendingMessages: state.pendingMessages
|
|
1322
|
-
};
|
|
1323
|
-
if (size < state.lastSize) {
|
|
1324
|
-
state.lastSize = size;
|
|
1325
|
-
state.pendingBytes += size;
|
|
1326
|
-
if (thresholds.deltaMessages > 0 && (thresholds.deltaBytes <= 0 || state.pendingBytes < thresholds.deltaBytes)) state.pendingMessages += await this.countNewlines(sessionFile, 0, size);
|
|
1327
|
-
} else {
|
|
1328
|
-
state.pendingBytes += deltaBytes;
|
|
1329
|
-
if (thresholds.deltaMessages > 0 && (thresholds.deltaBytes <= 0 || state.pendingBytes < thresholds.deltaBytes)) state.pendingMessages += await this.countNewlines(sessionFile, state.lastSize, size);
|
|
1330
|
-
state.lastSize = size;
|
|
1331
|
-
}
|
|
1332
|
-
this.sessionDeltas.set(sessionFile, state);
|
|
1333
|
-
return {
|
|
1334
|
-
deltaBytes: thresholds.deltaBytes,
|
|
1335
|
-
deltaMessages: thresholds.deltaMessages,
|
|
1336
|
-
pendingBytes: state.pendingBytes,
|
|
1337
|
-
pendingMessages: state.pendingMessages
|
|
1338
|
-
};
|
|
1339
|
-
}
|
|
1340
|
-
async countNewlines(absPath, start, end) {
|
|
1341
|
-
if (end <= start) return 0;
|
|
1342
|
-
let handle;
|
|
1343
|
-
try {
|
|
1344
|
-
handle = await fs$1.open(absPath, "r");
|
|
1345
|
-
} catch (err) {
|
|
1346
|
-
if (isFileMissingError(err)) return 0;
|
|
1347
|
-
throw err;
|
|
1348
|
-
}
|
|
1349
|
-
try {
|
|
1350
|
-
let offset = start;
|
|
1351
|
-
let count = 0;
|
|
1352
|
-
const buffer = Buffer.alloc(SESSION_DELTA_READ_CHUNK_BYTES);
|
|
1353
|
-
while (offset < end) {
|
|
1354
|
-
const toRead = Math.min(buffer.length, end - offset);
|
|
1355
|
-
const { bytesRead } = await handle.read(buffer, 0, toRead, offset);
|
|
1356
|
-
if (bytesRead <= 0) break;
|
|
1357
|
-
for (let i = 0; i < bytesRead; i += 1) if (buffer[i] === 10) count += 1;
|
|
1358
|
-
offset += bytesRead;
|
|
1359
|
-
}
|
|
1360
|
-
return count;
|
|
1361
|
-
} finally {
|
|
1362
|
-
await handle.close();
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
resetSessionDelta(absPath, size) {
|
|
1366
|
-
const state = this.sessionDeltas.get(absPath);
|
|
1367
|
-
if (!state) return;
|
|
1368
|
-
state.lastSize = size;
|
|
1369
|
-
state.pendingBytes = 0;
|
|
1370
|
-
state.pendingMessages = 0;
|
|
1371
|
-
}
|
|
1372
|
-
isSessionFileForAgent(sessionFile) {
|
|
1373
|
-
if (!sessionFile) return false;
|
|
1374
|
-
const sessionsDir = resolveSessionTranscriptsDirForAgent(this.agentId);
|
|
1375
|
-
const resolvedFile = path.resolve(sessionFile);
|
|
1376
|
-
const resolvedDir = path.resolve(sessionsDir);
|
|
1377
|
-
return resolvedFile.startsWith(`${resolvedDir}${path.sep}`);
|
|
1378
|
-
}
|
|
1379
|
-
normalizeTargetSessionFiles(sessionFiles) {
|
|
1380
|
-
if (!sessionFiles || sessionFiles.length === 0) return null;
|
|
1381
|
-
const normalized = /* @__PURE__ */ new Set();
|
|
1382
|
-
for (const sessionFile of sessionFiles) {
|
|
1383
|
-
const trimmed = sessionFile.trim();
|
|
1384
|
-
if (!trimmed) continue;
|
|
1385
|
-
const resolved = path.resolve(trimmed);
|
|
1386
|
-
if (this.isSessionFileForAgent(resolved)) normalized.add(resolved);
|
|
1387
|
-
}
|
|
1388
|
-
return normalized.size > 0 ? normalized : null;
|
|
1389
|
-
}
|
|
1390
|
-
ensureIntervalSync() {
|
|
1391
|
-
const minutes = this.settings.sync.intervalMinutes;
|
|
1392
|
-
if (!minutes || minutes <= 0 || this.intervalTimer) return;
|
|
1393
|
-
const ms = minutes * 60 * 1e3;
|
|
1394
|
-
this.intervalTimer = setInterval(() => {
|
|
1395
|
-
runDetachedMemorySync(() => this.sync({ reason: "interval" }), "interval");
|
|
1396
|
-
}, ms);
|
|
1397
|
-
}
|
|
1398
|
-
scheduleWatchSync() {
|
|
1399
|
-
if (!this.sources.has("memory") || !this.settings.sync.watch) return;
|
|
1400
|
-
if (this.watchTimer) clearTimeout(this.watchTimer);
|
|
1401
|
-
this.watchTimer = setTimeout(() => {
|
|
1402
|
-
this.watchTimer = null;
|
|
1403
|
-
runDetachedMemorySync(() => this.sync({ reason: "watch" }), "watch");
|
|
1404
|
-
}, this.settings.sync.watchDebounceMs);
|
|
1405
|
-
}
|
|
1406
|
-
shouldSyncSessions(params, needsFullReindex = false) {
|
|
1407
|
-
return shouldSyncSessionsForReindex({
|
|
1408
|
-
hasSessionSource: this.sources.has("sessions"),
|
|
1409
|
-
sessionsDirty: this.sessionsDirty,
|
|
1410
|
-
dirtySessionFileCount: this.sessionsDirtyFiles.size,
|
|
1411
|
-
sync: params,
|
|
1412
|
-
needsFullReindex
|
|
1413
|
-
});
|
|
1414
|
-
}
|
|
1415
|
-
async syncMemoryFiles(params) {
|
|
1416
|
-
const deleteFileByPathAndSource = this.db.prepare(`DELETE FROM files WHERE path = ? AND source = ?`);
|
|
1417
|
-
const deleteChunksByPathAndSource = this.db.prepare(`DELETE FROM chunks WHERE path = ? AND source = ?`);
|
|
1418
|
-
const deleteVectorRowsByPathAndSource = this.vector.enabled && this.vector.available && this.hasVectorTable() ? this.db.prepare(`DELETE FROM ${VECTOR_TABLE$2} WHERE id IN (SELECT id FROM chunks WHERE path = ? AND source = ?)`) : null;
|
|
1419
|
-
const deleteFtsRowsByPathAndSource = this.fts.enabled && this.fts.available ? this.db.prepare(`DELETE FROM ${FTS_TABLE$2} WHERE path = ? AND source = ?`) : null;
|
|
1420
|
-
const fileEntries = (await runWithConcurrency((await listMemoryFiles(this.workspaceDir, this.settings.extraPaths, this.settings.multimodal)).map((file) => async () => await buildFileEntry(file, this.workspaceDir, this.settings.multimodal)), this.getIndexConcurrency())).filter((entry) => entry !== null);
|
|
1421
|
-
log$3.debug("memory sync: indexing memory files", {
|
|
1422
|
-
files: fileEntries.length,
|
|
1423
|
-
needsFullReindex: params.needsFullReindex,
|
|
1424
|
-
batch: this.batch.enabled,
|
|
1425
|
-
concurrency: this.getIndexConcurrency()
|
|
1426
|
-
});
|
|
1427
|
-
const existingState = loadMemorySourceFileState({
|
|
1428
|
-
db: this.db,
|
|
1429
|
-
source: "memory"
|
|
1430
|
-
});
|
|
1431
|
-
const existingRows = existingState.rows;
|
|
1432
|
-
const existingHashes = existingState.hashes;
|
|
1433
|
-
const activePaths = new Set(fileEntries.map((entry) => entry.path));
|
|
1434
|
-
if (params.progress) {
|
|
1435
|
-
params.progress.total += fileEntries.length;
|
|
1436
|
-
params.progress.report({
|
|
1437
|
-
completed: params.progress.completed,
|
|
1438
|
-
total: params.progress.total,
|
|
1439
|
-
label: this.batch.enabled ? "Indexing memory files (batch)..." : "Indexing memory files…"
|
|
1440
|
-
});
|
|
1441
|
-
}
|
|
1442
|
-
await runWithConcurrency(fileEntries.map((entry) => async () => {
|
|
1443
|
-
if (!params.needsFullReindex && existingHashes.get(entry.path) === entry.hash) {
|
|
1444
|
-
if (params.progress) {
|
|
1445
|
-
params.progress.completed += 1;
|
|
1446
|
-
params.progress.report({
|
|
1447
|
-
completed: params.progress.completed,
|
|
1448
|
-
total: params.progress.total
|
|
1449
|
-
});
|
|
1450
|
-
}
|
|
1451
|
-
return;
|
|
1452
|
-
}
|
|
1453
|
-
await this.indexFile(entry, { source: "memory" });
|
|
1454
|
-
if (params.progress) {
|
|
1455
|
-
params.progress.completed += 1;
|
|
1456
|
-
params.progress.report({
|
|
1457
|
-
completed: params.progress.completed,
|
|
1458
|
-
total: params.progress.total
|
|
1459
|
-
});
|
|
1460
|
-
}
|
|
1461
|
-
}), this.getIndexConcurrency());
|
|
1462
|
-
for (const stale of existingRows) {
|
|
1463
|
-
if (activePaths.has(stale.path)) continue;
|
|
1464
|
-
deleteFileByPathAndSource.run(stale.path, "memory");
|
|
1465
|
-
if (deleteVectorRowsByPathAndSource) try {
|
|
1466
|
-
deleteVectorRowsByPathAndSource.run(stale.path, "memory");
|
|
1467
|
-
} catch {}
|
|
1468
|
-
deleteChunksByPathAndSource.run(stale.path, "memory");
|
|
1469
|
-
if (deleteFtsRowsByPathAndSource) try {
|
|
1470
|
-
deleteFtsRowsByPathAndSource.run(stale.path, "memory");
|
|
1471
|
-
} catch {}
|
|
1472
|
-
}
|
|
1473
|
-
}
|
|
1474
|
-
async syncSessionFiles(params) {
|
|
1475
|
-
const deleteFileByPathAndSource = this.db.prepare(`DELETE FROM files WHERE path = ? AND source = ?`);
|
|
1476
|
-
const deleteChunksByPathAndSource = this.db.prepare(`DELETE FROM chunks WHERE path = ? AND source = ?`);
|
|
1477
|
-
const deleteVectorRowsByPathAndSource = this.vector.enabled && this.vector.available && this.hasVectorTable() ? this.db.prepare(`DELETE FROM ${VECTOR_TABLE$2} WHERE id IN (SELECT id FROM chunks WHERE path = ? AND source = ?)`) : null;
|
|
1478
|
-
const deleteFtsRowsByPathSourceAndModel = this.fts.enabled && this.fts.available ? this.db.prepare(`DELETE FROM ${FTS_TABLE$2} WHERE path = ? AND source = ? AND model = ?`) : null;
|
|
1479
|
-
const targetSessionFiles = params.needsFullReindex ? null : this.normalizeTargetSessionFiles(params.targetSessionFiles);
|
|
1480
|
-
const files = targetSessionFiles ? Array.from(targetSessionFiles) : await listSessionFilesForAgent(this.agentId);
|
|
1481
|
-
const { activePaths, existingRows, existingHashes, indexAll } = resolveMemorySessionSyncPlan({
|
|
1482
|
-
needsFullReindex: params.needsFullReindex,
|
|
1483
|
-
files,
|
|
1484
|
-
targetSessionFiles,
|
|
1485
|
-
sessionsDirtyFiles: this.sessionsDirtyFiles,
|
|
1486
|
-
existingRows: targetSessionFiles ? null : loadMemorySourceFileState({
|
|
1487
|
-
db: this.db,
|
|
1488
|
-
source: "sessions"
|
|
1489
|
-
}).rows,
|
|
1490
|
-
sessionPathForFile
|
|
1491
|
-
});
|
|
1492
|
-
log$3.debug("memory sync: indexing session files", {
|
|
1493
|
-
files: files.length,
|
|
1494
|
-
indexAll,
|
|
1495
|
-
dirtyFiles: this.sessionsDirtyFiles.size,
|
|
1496
|
-
targetedFiles: targetSessionFiles?.size ?? 0,
|
|
1497
|
-
batch: this.batch.enabled,
|
|
1498
|
-
concurrency: this.getIndexConcurrency()
|
|
1499
|
-
});
|
|
1500
|
-
if (params.progress) {
|
|
1501
|
-
params.progress.total += files.length;
|
|
1502
|
-
params.progress.report({
|
|
1503
|
-
completed: params.progress.completed,
|
|
1504
|
-
total: params.progress.total,
|
|
1505
|
-
label: this.batch.enabled ? "Indexing session files (batch)..." : "Indexing session files…"
|
|
1506
|
-
});
|
|
1507
|
-
}
|
|
1508
|
-
await runWithConcurrency(files.map((absPath) => async () => {
|
|
1509
|
-
if (!indexAll && !this.sessionsDirtyFiles.has(absPath)) {
|
|
1510
|
-
if (params.progress) {
|
|
1511
|
-
params.progress.completed += 1;
|
|
1512
|
-
params.progress.report({
|
|
1513
|
-
completed: params.progress.completed,
|
|
1514
|
-
total: params.progress.total
|
|
1515
|
-
});
|
|
1516
|
-
}
|
|
1517
|
-
return;
|
|
1518
|
-
}
|
|
1519
|
-
const entry = await buildSessionEntry(absPath);
|
|
1520
|
-
if (!entry) {
|
|
1521
|
-
if (params.progress) {
|
|
1522
|
-
params.progress.completed += 1;
|
|
1523
|
-
params.progress.report({
|
|
1524
|
-
completed: params.progress.completed,
|
|
1525
|
-
total: params.progress.total
|
|
1526
|
-
});
|
|
1527
|
-
}
|
|
1528
|
-
return;
|
|
1529
|
-
}
|
|
1530
|
-
const existingHash = resolveMemorySourceExistingHash({
|
|
1531
|
-
db: this.db,
|
|
1532
|
-
source: "sessions",
|
|
1533
|
-
path: entry.path,
|
|
1534
|
-
existingHashes
|
|
1535
|
-
});
|
|
1536
|
-
if (!params.needsFullReindex && existingHash === entry.hash) {
|
|
1537
|
-
if (params.progress) {
|
|
1538
|
-
params.progress.completed += 1;
|
|
1539
|
-
params.progress.report({
|
|
1540
|
-
completed: params.progress.completed,
|
|
1541
|
-
total: params.progress.total
|
|
1542
|
-
});
|
|
1543
|
-
}
|
|
1544
|
-
this.resetSessionDelta(absPath, entry.size);
|
|
1545
|
-
return;
|
|
1546
|
-
}
|
|
1547
|
-
await this.indexFile(entry, {
|
|
1548
|
-
source: "sessions",
|
|
1549
|
-
content: entry.content
|
|
1550
|
-
});
|
|
1551
|
-
this.resetSessionDelta(absPath, entry.size);
|
|
1552
|
-
if (params.progress) {
|
|
1553
|
-
params.progress.completed += 1;
|
|
1554
|
-
params.progress.report({
|
|
1555
|
-
completed: params.progress.completed,
|
|
1556
|
-
total: params.progress.total
|
|
1557
|
-
});
|
|
1558
|
-
}
|
|
1559
|
-
}), this.getIndexConcurrency());
|
|
1560
|
-
if (activePaths === null) return;
|
|
1561
|
-
for (const stale of existingRows ?? []) {
|
|
1562
|
-
if (activePaths.has(stale.path)) continue;
|
|
1563
|
-
deleteFileByPathAndSource.run(stale.path, "sessions");
|
|
1564
|
-
if (deleteVectorRowsByPathAndSource) try {
|
|
1565
|
-
deleteVectorRowsByPathAndSource.run(stale.path, "sessions");
|
|
1566
|
-
} catch {}
|
|
1567
|
-
deleteChunksByPathAndSource.run(stale.path, "sessions");
|
|
1568
|
-
if (deleteFtsRowsByPathSourceAndModel) try {
|
|
1569
|
-
deleteFtsRowsByPathSourceAndModel.run(stale.path, "sessions", this.provider?.model ?? "fts-only");
|
|
1570
|
-
} catch {}
|
|
1571
|
-
}
|
|
1572
|
-
}
|
|
1573
|
-
createSyncProgress(onProgress) {
|
|
1574
|
-
const state = {
|
|
1575
|
-
completed: 0,
|
|
1576
|
-
total: 0,
|
|
1577
|
-
label: void 0,
|
|
1578
|
-
report: (update) => {
|
|
1579
|
-
if (update.label) state.label = update.label;
|
|
1580
|
-
const label = update.total > 0 && state.label ? `${state.label} ${update.completed}/${update.total}` : state.label;
|
|
1581
|
-
onProgress({
|
|
1582
|
-
completed: update.completed,
|
|
1583
|
-
total: update.total,
|
|
1584
|
-
label
|
|
1585
|
-
});
|
|
1586
|
-
}
|
|
1587
|
-
};
|
|
1588
|
-
return state;
|
|
1589
|
-
}
|
|
1590
|
-
async runSync(params) {
|
|
1591
|
-
const progress = params?.progress ? this.createSyncProgress(params.progress) : void 0;
|
|
1592
|
-
if (progress) progress.report({
|
|
1593
|
-
completed: progress.completed,
|
|
1594
|
-
total: progress.total,
|
|
1595
|
-
label: "Loading vector extension…"
|
|
1596
|
-
});
|
|
1597
|
-
const vectorReady = await this.ensureVectorReady();
|
|
1598
|
-
const meta = this.readMeta();
|
|
1599
|
-
const configuredSources = resolveConfiguredSourcesForMeta(this.sources);
|
|
1600
|
-
const configuredScopeHash = resolveConfiguredScopeHash({
|
|
1601
|
-
workspaceDir: this.workspaceDir,
|
|
1602
|
-
extraPaths: this.settings.extraPaths,
|
|
1603
|
-
multimodal: {
|
|
1604
|
-
enabled: this.settings.multimodal.enabled,
|
|
1605
|
-
modalities: this.settings.multimodal.modalities,
|
|
1606
|
-
maxFileBytes: this.settings.multimodal.maxFileBytes
|
|
1607
|
-
}
|
|
1608
|
-
});
|
|
1609
|
-
const targetSessionFiles = this.normalizeTargetSessionFiles(params?.sessionFiles);
|
|
1610
|
-
const hasTargetSessionFiles = targetSessionFiles !== null;
|
|
1611
|
-
const targetedSessionSync = await runMemoryTargetedSessionSync({
|
|
1612
|
-
hasSessionSource: this.sources.has("sessions"),
|
|
1613
|
-
targetSessionFiles,
|
|
1614
|
-
reason: params?.reason,
|
|
1615
|
-
progress: progress ?? void 0,
|
|
1616
|
-
useUnsafeReindex: process.env.OPENCLAW_TEST_FAST === "1" && process.env.OPENCLAW_TEST_MEMORY_UNSAFE_REINDEX === "1",
|
|
1617
|
-
sessionsDirtyFiles: this.sessionsDirtyFiles,
|
|
1618
|
-
syncSessionFiles: async (targetedParams) => {
|
|
1619
|
-
await this.syncSessionFiles(targetedParams);
|
|
1620
|
-
},
|
|
1621
|
-
shouldFallbackOnError: (message) => this.shouldFallbackOnError(message),
|
|
1622
|
-
activateFallbackProvider: async (reason) => await this.activateFallbackProvider(reason),
|
|
1623
|
-
runSafeReindex: async (reindexParams) => {
|
|
1624
|
-
await this.runSafeReindex(reindexParams);
|
|
1625
|
-
},
|
|
1626
|
-
runUnsafeReindex: async (reindexParams) => {
|
|
1627
|
-
await this.runUnsafeReindex(reindexParams);
|
|
1628
|
-
}
|
|
1629
|
-
});
|
|
1630
|
-
if (targetedSessionSync.handled) {
|
|
1631
|
-
this.sessionsDirty = targetedSessionSync.sessionsDirty;
|
|
1632
|
-
return;
|
|
1633
|
-
}
|
|
1634
|
-
const needsFullReindex = params?.force && !hasTargetSessionFiles || shouldRunFullMemoryReindex({
|
|
1635
|
-
meta,
|
|
1636
|
-
provider: this.provider ? {
|
|
1637
|
-
id: this.provider.id,
|
|
1638
|
-
model: this.provider.model
|
|
1639
|
-
} : null,
|
|
1640
|
-
providerKey: this.providerKey ?? void 0,
|
|
1641
|
-
configuredSources,
|
|
1642
|
-
configuredScopeHash,
|
|
1643
|
-
chunkTokens: this.settings.chunking.tokens,
|
|
1644
|
-
chunkOverlap: this.settings.chunking.overlap,
|
|
1645
|
-
vectorReady,
|
|
1646
|
-
ftsTokenizer: this.settings.store.fts.tokenizer
|
|
1647
|
-
});
|
|
1648
|
-
try {
|
|
1649
|
-
if (needsFullReindex) {
|
|
1650
|
-
if (process.env.OPENCLAW_TEST_FAST === "1" && process.env.OPENCLAW_TEST_MEMORY_UNSAFE_REINDEX === "1") await this.runUnsafeReindex({
|
|
1651
|
-
reason: params?.reason,
|
|
1652
|
-
force: params?.force,
|
|
1653
|
-
progress: progress ?? void 0
|
|
1654
|
-
});
|
|
1655
|
-
else await this.runSafeReindex({
|
|
1656
|
-
reason: params?.reason,
|
|
1657
|
-
force: params?.force,
|
|
1658
|
-
progress: progress ?? void 0
|
|
1659
|
-
});
|
|
1660
|
-
return;
|
|
1661
|
-
}
|
|
1662
|
-
const shouldSyncMemory = this.sources.has("memory") && (!hasTargetSessionFiles && params?.force || needsFullReindex || this.dirty);
|
|
1663
|
-
const shouldSyncSessions = this.shouldSyncSessions(params, needsFullReindex);
|
|
1664
|
-
if (shouldSyncMemory) {
|
|
1665
|
-
await this.syncMemoryFiles({
|
|
1666
|
-
needsFullReindex,
|
|
1667
|
-
progress: progress ?? void 0
|
|
1668
|
-
});
|
|
1669
|
-
this.dirty = false;
|
|
1670
|
-
}
|
|
1671
|
-
if (shouldSyncSessions) {
|
|
1672
|
-
await this.syncSessionFiles({
|
|
1673
|
-
needsFullReindex,
|
|
1674
|
-
targetSessionFiles: targetSessionFiles ? Array.from(targetSessionFiles) : void 0,
|
|
1675
|
-
progress: progress ?? void 0
|
|
1676
|
-
});
|
|
1677
|
-
this.sessionsDirty = false;
|
|
1678
|
-
this.sessionsDirtyFiles.clear();
|
|
1679
|
-
} else if (this.sessionsDirtyFiles.size > 0) this.sessionsDirty = true;
|
|
1680
|
-
else this.sessionsDirty = false;
|
|
1681
|
-
} catch (err) {
|
|
1682
|
-
const reason = formatErrorMessage(err);
|
|
1683
|
-
if (this.shouldFallbackOnError(reason) && await this.activateFallbackProvider(reason)) {
|
|
1684
|
-
await this.runSafeReindex({
|
|
1685
|
-
reason: params?.reason ?? "fallback",
|
|
1686
|
-
force: true,
|
|
1687
|
-
progress: progress ?? void 0
|
|
1688
|
-
});
|
|
1689
|
-
return;
|
|
1690
|
-
}
|
|
1691
|
-
throw err;
|
|
1692
|
-
}
|
|
1693
|
-
}
|
|
1694
|
-
shouldFallbackOnError(message) {
|
|
1695
|
-
return /embedding|embeddings|batch/i.test(message);
|
|
1696
|
-
}
|
|
1697
|
-
resolveBatchConfig() {
|
|
1698
|
-
const batch = this.settings.remote?.batch;
|
|
1699
|
-
return {
|
|
1700
|
-
enabled: Boolean(batch?.enabled && this.provider && this.providerRuntime?.batchEmbed),
|
|
1701
|
-
wait: batch?.wait ?? true,
|
|
1702
|
-
concurrency: Math.max(1, batch?.concurrency ?? 2),
|
|
1703
|
-
pollIntervalMs: batch?.pollIntervalMs ?? 2e3,
|
|
1704
|
-
timeoutMs: (batch?.timeoutMinutes ?? 60) * 60 * 1e3
|
|
1705
|
-
};
|
|
1706
|
-
}
|
|
1707
|
-
async activateFallbackProvider(reason) {
|
|
1708
|
-
const fallbackRequest = resolveMemoryFallbackProviderRequest({
|
|
1709
|
-
cfg: this.cfg,
|
|
1710
|
-
settings: this.settings,
|
|
1711
|
-
currentProviderId: this.provider?.id ?? null
|
|
1712
|
-
});
|
|
1713
|
-
if (!fallbackRequest || !this.provider) return false;
|
|
1714
|
-
if (this.fallbackFrom) return false;
|
|
1715
|
-
const fallbackFrom = this.provider.id;
|
|
1716
|
-
const fallbackResult = await createEmbeddingProvider({
|
|
1717
|
-
config: this.cfg,
|
|
1718
|
-
agentDir: resolveAgentDir(this.cfg, this.agentId),
|
|
1719
|
-
...fallbackRequest
|
|
1720
|
-
});
|
|
1721
|
-
const fallbackState = applyMemoryFallbackProviderState({
|
|
1722
|
-
current: {
|
|
1723
|
-
provider: this.provider,
|
|
1724
|
-
fallbackFrom: this.fallbackFrom,
|
|
1725
|
-
fallbackReason: this.fallbackReason,
|
|
1726
|
-
providerUnavailableReason: void 0,
|
|
1727
|
-
providerRuntime: this.providerRuntime
|
|
1728
|
-
},
|
|
1729
|
-
fallbackFrom,
|
|
1730
|
-
reason,
|
|
1731
|
-
result: fallbackResult
|
|
1732
|
-
});
|
|
1733
|
-
this.fallbackFrom = fallbackState.fallbackFrom;
|
|
1734
|
-
this.fallbackReason = fallbackState.fallbackReason;
|
|
1735
|
-
this.provider = fallbackState.provider;
|
|
1736
|
-
this.providerRuntime = fallbackState.providerRuntime;
|
|
1737
|
-
this.providerKey = this.computeProviderKey();
|
|
1738
|
-
this.batch = this.resolveBatchConfig();
|
|
1739
|
-
log$3.warn(`memory embeddings: switched to fallback provider (${fallbackRequest.provider})`, { reason });
|
|
1740
|
-
return true;
|
|
1741
|
-
}
|
|
1742
|
-
async runSafeReindex(params) {
|
|
1743
|
-
const dbPath = resolveUserPath(this.settings.store.path);
|
|
1744
|
-
const tempDbPath = `${dbPath}.tmp-${randomUUID()}`;
|
|
1745
|
-
const tempDb = openMemoryDatabaseAtPath(tempDbPath, this.settings.store.vector.enabled);
|
|
1746
|
-
const originalDb = this.db;
|
|
1747
|
-
let originalDbClosed = false;
|
|
1748
|
-
const originalState = {
|
|
1749
|
-
ftsAvailable: this.fts.available,
|
|
1750
|
-
ftsError: this.fts.loadError,
|
|
1751
|
-
vectorAvailable: this.vector.available,
|
|
1752
|
-
vectorLoadError: this.vector.loadError,
|
|
1753
|
-
vectorDims: this.vector.dims,
|
|
1754
|
-
vectorReady: this.vectorReady
|
|
1755
|
-
};
|
|
1756
|
-
const restoreOriginalState = () => {
|
|
1757
|
-
if (originalDbClosed) this.db = openMemoryDatabaseAtPath(dbPath, this.settings.store.vector.enabled);
|
|
1758
|
-
else this.db = originalDb;
|
|
1759
|
-
this.fts.available = originalState.ftsAvailable;
|
|
1760
|
-
this.fts.loadError = originalState.ftsError;
|
|
1761
|
-
this.vector.available = originalDbClosed ? null : originalState.vectorAvailable;
|
|
1762
|
-
this.vector.loadError = originalState.vectorLoadError;
|
|
1763
|
-
this.vector.dims = originalState.vectorDims;
|
|
1764
|
-
this.vectorReady = originalDbClosed ? null : originalState.vectorReady;
|
|
1765
|
-
};
|
|
1766
|
-
this.db = tempDb;
|
|
1767
|
-
this.lastMetaSerialized = null;
|
|
1768
|
-
this.vectorReady = null;
|
|
1769
|
-
this.vector.available = null;
|
|
1770
|
-
this.vector.loadError = void 0;
|
|
1771
|
-
this.vector.dims = void 0;
|
|
1772
|
-
this.fts.available = false;
|
|
1773
|
-
this.fts.loadError = void 0;
|
|
1774
|
-
this.ensureSchema();
|
|
1775
|
-
let nextMeta = null;
|
|
1776
|
-
try {
|
|
1777
|
-
nextMeta = await runMemoryAtomicReindex({
|
|
1778
|
-
targetPath: dbPath,
|
|
1779
|
-
tempPath: tempDbPath,
|
|
1780
|
-
build: async () => {
|
|
1781
|
-
this.seedEmbeddingCache(originalDb);
|
|
1782
|
-
const shouldSyncMemory = this.sources.has("memory");
|
|
1783
|
-
const shouldSyncSessions = this.shouldSyncSessions({
|
|
1784
|
-
reason: params.reason,
|
|
1785
|
-
force: params.force
|
|
1786
|
-
}, true);
|
|
1787
|
-
if (shouldSyncMemory) {
|
|
1788
|
-
await this.syncMemoryFiles({
|
|
1789
|
-
needsFullReindex: true,
|
|
1790
|
-
progress: params.progress
|
|
1791
|
-
});
|
|
1792
|
-
this.dirty = false;
|
|
1793
|
-
}
|
|
1794
|
-
if (shouldSyncSessions) {
|
|
1795
|
-
await this.syncSessionFiles({
|
|
1796
|
-
needsFullReindex: true,
|
|
1797
|
-
progress: params.progress
|
|
1798
|
-
});
|
|
1799
|
-
this.sessionsDirty = false;
|
|
1800
|
-
this.sessionsDirtyFiles.clear();
|
|
1801
|
-
} else if (this.sessionsDirtyFiles.size > 0) this.sessionsDirty = true;
|
|
1802
|
-
else this.sessionsDirty = false;
|
|
1803
|
-
const meta = {
|
|
1804
|
-
model: this.provider?.model ?? "fts-only",
|
|
1805
|
-
provider: this.provider?.id ?? "none",
|
|
1806
|
-
providerKey: this.providerKey,
|
|
1807
|
-
sources: resolveConfiguredSourcesForMeta(this.sources),
|
|
1808
|
-
scopeHash: resolveConfiguredScopeHash({
|
|
1809
|
-
workspaceDir: this.workspaceDir,
|
|
1810
|
-
extraPaths: this.settings.extraPaths,
|
|
1811
|
-
multimodal: {
|
|
1812
|
-
enabled: this.settings.multimodal.enabled,
|
|
1813
|
-
modalities: this.settings.multimodal.modalities,
|
|
1814
|
-
maxFileBytes: this.settings.multimodal.maxFileBytes
|
|
1815
|
-
}
|
|
1816
|
-
}),
|
|
1817
|
-
chunkTokens: this.settings.chunking.tokens,
|
|
1818
|
-
chunkOverlap: this.settings.chunking.overlap,
|
|
1819
|
-
ftsTokenizer: this.settings.store.fts.tokenizer
|
|
1820
|
-
};
|
|
1821
|
-
if (this.vector.available && this.vector.dims) meta.vectorDims = this.vector.dims;
|
|
1822
|
-
this.writeMeta(meta);
|
|
1823
|
-
this.pruneEmbeddingCacheIfNeeded?.();
|
|
1824
|
-
this.db.close();
|
|
1825
|
-
originalDb.close();
|
|
1826
|
-
originalDbClosed = true;
|
|
1827
|
-
return meta;
|
|
1828
|
-
}
|
|
1829
|
-
});
|
|
1830
|
-
this.db = openMemoryDatabaseAtPath(dbPath, this.settings.store.vector.enabled);
|
|
1831
|
-
this.lastMetaSerialized = null;
|
|
1832
|
-
this.vectorReady = null;
|
|
1833
|
-
this.vector.available = null;
|
|
1834
|
-
this.vector.loadError = void 0;
|
|
1835
|
-
this.ensureSchema();
|
|
1836
|
-
this.vector.dims = nextMeta?.vectorDims;
|
|
1837
|
-
} catch (err) {
|
|
1838
|
-
try {
|
|
1839
|
-
this.db.close();
|
|
1840
|
-
} catch {}
|
|
1841
|
-
restoreOriginalState();
|
|
1842
|
-
throw err;
|
|
1843
|
-
}
|
|
1844
|
-
}
|
|
1845
|
-
async runUnsafeReindex(params) {
|
|
1846
|
-
this.resetIndex();
|
|
1847
|
-
const shouldSyncMemory = this.sources.has("memory");
|
|
1848
|
-
const shouldSyncSessions = this.shouldSyncSessions({
|
|
1849
|
-
reason: params.reason,
|
|
1850
|
-
force: params.force
|
|
1851
|
-
}, true);
|
|
1852
|
-
if (shouldSyncMemory) {
|
|
1853
|
-
await this.syncMemoryFiles({
|
|
1854
|
-
needsFullReindex: true,
|
|
1855
|
-
progress: params.progress
|
|
1856
|
-
});
|
|
1857
|
-
this.dirty = false;
|
|
1858
|
-
}
|
|
1859
|
-
if (shouldSyncSessions) {
|
|
1860
|
-
await this.syncSessionFiles({
|
|
1861
|
-
needsFullReindex: true,
|
|
1862
|
-
progress: params.progress
|
|
1863
|
-
});
|
|
1864
|
-
this.sessionsDirty = false;
|
|
1865
|
-
this.sessionsDirtyFiles.clear();
|
|
1866
|
-
} else if (this.sessionsDirtyFiles.size > 0) this.sessionsDirty = true;
|
|
1867
|
-
else this.sessionsDirty = false;
|
|
1868
|
-
const nextMeta = {
|
|
1869
|
-
model: this.provider?.model ?? "fts-only",
|
|
1870
|
-
provider: this.provider?.id ?? "none",
|
|
1871
|
-
providerKey: this.providerKey,
|
|
1872
|
-
sources: resolveConfiguredSourcesForMeta(this.sources),
|
|
1873
|
-
scopeHash: resolveConfiguredScopeHash({
|
|
1874
|
-
workspaceDir: this.workspaceDir,
|
|
1875
|
-
extraPaths: this.settings.extraPaths,
|
|
1876
|
-
multimodal: {
|
|
1877
|
-
enabled: this.settings.multimodal.enabled,
|
|
1878
|
-
modalities: this.settings.multimodal.modalities,
|
|
1879
|
-
maxFileBytes: this.settings.multimodal.maxFileBytes
|
|
1880
|
-
}
|
|
1881
|
-
}),
|
|
1882
|
-
chunkTokens: this.settings.chunking.tokens,
|
|
1883
|
-
chunkOverlap: this.settings.chunking.overlap,
|
|
1884
|
-
ftsTokenizer: this.settings.store.fts.tokenizer
|
|
1885
|
-
};
|
|
1886
|
-
if (this.vector.available && this.vector.dims) nextMeta.vectorDims = this.vector.dims;
|
|
1887
|
-
this.writeMeta(nextMeta);
|
|
1888
|
-
this.pruneEmbeddingCacheIfNeeded?.();
|
|
1889
|
-
}
|
|
1890
|
-
resetIndex() {
|
|
1891
|
-
this.db.exec(`DELETE FROM files`);
|
|
1892
|
-
this.db.exec(`DELETE FROM chunks`);
|
|
1893
|
-
if (this.fts.enabled && this.fts.available) try {
|
|
1894
|
-
this.db.exec(`DROP TABLE IF EXISTS ${FTS_TABLE$2}`);
|
|
1895
|
-
} catch {}
|
|
1896
|
-
this.ensureSchema();
|
|
1897
|
-
this.dropVectorTable();
|
|
1898
|
-
this.vector.dims = void 0;
|
|
1899
|
-
this.sessionsDirtyFiles.clear();
|
|
1900
|
-
}
|
|
1901
|
-
readMeta() {
|
|
1902
|
-
const row = this.db.prepare(`SELECT value FROM meta WHERE key = ?`).get(META_KEY);
|
|
1903
|
-
if (!row?.value) {
|
|
1904
|
-
this.lastMetaSerialized = null;
|
|
1905
|
-
return null;
|
|
1906
|
-
}
|
|
1907
|
-
try {
|
|
1908
|
-
const parsed = JSON.parse(row.value);
|
|
1909
|
-
this.lastMetaSerialized = row.value;
|
|
1910
|
-
return parsed;
|
|
1911
|
-
} catch {
|
|
1912
|
-
this.lastMetaSerialized = null;
|
|
1913
|
-
return null;
|
|
1914
|
-
}
|
|
1915
|
-
}
|
|
1916
|
-
writeMeta(meta) {
|
|
1917
|
-
const value = JSON.stringify(meta);
|
|
1918
|
-
if (this.lastMetaSerialized === value) return;
|
|
1919
|
-
this.db.prepare(`INSERT INTO meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value=excluded.value`).run(META_KEY, value);
|
|
1920
|
-
this.lastMetaSerialized = value;
|
|
1921
|
-
}
|
|
1922
|
-
};
|
|
1923
|
-
//#endregion
|
|
1924
|
-
//#region extensions/memory-core/src/memory/manager-vector-write.ts
|
|
1925
|
-
const vectorToBlob$1 = (embedding) => Buffer.from(new Float32Array(embedding).buffer);
|
|
1926
|
-
function replaceMemoryVectorRow(params) {
|
|
1927
|
-
const tableName = params.tableName ?? "chunks_vec";
|
|
1928
|
-
try {
|
|
1929
|
-
params.db.prepare(`DELETE FROM ${tableName} WHERE id = ?`).run(params.id);
|
|
1930
|
-
} catch {}
|
|
1931
|
-
params.db.prepare(`INSERT INTO ${tableName} (id, embedding) VALUES (?, ?)`).run(params.id, vectorToBlob$1(params.embedding));
|
|
1932
|
-
}
|
|
1933
|
-
//#endregion
|
|
1934
|
-
//#region extensions/memory-core/src/memory/manager-embedding-ops.ts
|
|
1935
|
-
const VECTOR_TABLE$1 = "chunks_vec";
|
|
1936
|
-
const FTS_TABLE$1 = "chunks_fts";
|
|
1937
|
-
const EMBEDDING_CACHE_TABLE$1 = "embedding_cache";
|
|
1938
|
-
const EMBEDDING_BATCH_MAX_TOKENS = 8e3;
|
|
1939
|
-
const EMBEDDING_INDEX_CONCURRENCY = 4;
|
|
1940
|
-
const EMBEDDING_RETRY_MAX_ATTEMPTS = 3;
|
|
1941
|
-
const EMBEDDING_RETRY_BASE_DELAY_MS = 500;
|
|
1942
|
-
const EMBEDDING_RETRY_MAX_DELAY_MS = 8e3;
|
|
1943
|
-
const EMBEDDING_QUERY_TIMEOUT_REMOTE_MS = 6e4;
|
|
1944
|
-
const EMBEDDING_QUERY_TIMEOUT_LOCAL_MS = 5 * 6e4;
|
|
1945
|
-
const EMBEDDING_BATCH_TIMEOUT_REMOTE_MS = 2 * 6e4;
|
|
1946
|
-
const EMBEDDING_BATCH_TIMEOUT_LOCAL_MS = 10 * 6e4;
|
|
1947
|
-
const log$2 = createSubsystemLogger("memory");
|
|
1948
|
-
var MemoryManagerEmbeddingOps = class extends MemoryManagerSyncOps {
|
|
1949
|
-
pruneEmbeddingCacheIfNeeded() {
|
|
1950
|
-
if (!this.cache.enabled) return;
|
|
1951
|
-
const max = this.cache.maxEntries;
|
|
1952
|
-
if (!max || max <= 0) return;
|
|
1953
|
-
const count = this.db.prepare(`SELECT COUNT(*) as c FROM ${EMBEDDING_CACHE_TABLE$1}`).get()?.c ?? 0;
|
|
1954
|
-
if (count <= max) return;
|
|
1955
|
-
const excess = count - max;
|
|
1956
|
-
this.db.prepare(`DELETE FROM ${EMBEDDING_CACHE_TABLE$1}\n WHERE rowid IN (\n SELECT rowid FROM ${EMBEDDING_CACHE_TABLE$1}\n ORDER BY updated_at ASC\n LIMIT ?\n )`).run(excess);
|
|
1957
|
-
}
|
|
1958
|
-
async embedChunksInBatches(chunks) {
|
|
1959
|
-
if (chunks.length === 0) return [];
|
|
1960
|
-
const { embeddings, missing } = this.collectCachedEmbeddings(chunks);
|
|
1961
|
-
if (missing.length === 0) return embeddings;
|
|
1962
|
-
const batches = buildMemoryEmbeddingBatches(missing.map((m) => m.chunk), EMBEDDING_BATCH_MAX_TOKENS);
|
|
1963
|
-
const toCache = [];
|
|
1964
|
-
const provider = this.provider;
|
|
1965
|
-
if (!provider) throw new Error("Cannot embed batch in FTS-only mode (no embedding provider)");
|
|
1966
|
-
let cursor = 0;
|
|
1967
|
-
for (const batch of batches) {
|
|
1968
|
-
const inputs = buildTextEmbeddingInputs(batch);
|
|
1969
|
-
const hasStructuredInputs = inputs.some((input) => hasNonTextEmbeddingParts(input));
|
|
1970
|
-
if (hasStructuredInputs && !provider.embedBatchInputs) throw new Error(`Embedding provider "${provider.id}" does not support multimodal memory inputs.`);
|
|
1971
|
-
const batchEmbeddings = hasStructuredInputs ? await this.embedBatchInputsWithRetry(inputs) : await this.embedBatchWithRetry(batch.map((chunk) => chunk.text));
|
|
1972
|
-
for (let i = 0; i < batch.length; i += 1) {
|
|
1973
|
-
const item = missing[cursor + i];
|
|
1974
|
-
const embedding = batchEmbeddings[i] ?? [];
|
|
1975
|
-
if (item) {
|
|
1976
|
-
embeddings[item.index] = embedding;
|
|
1977
|
-
toCache.push({
|
|
1978
|
-
hash: item.chunk.hash,
|
|
1979
|
-
embedding
|
|
1980
|
-
});
|
|
1981
|
-
}
|
|
1982
|
-
}
|
|
1983
|
-
cursor += batch.length;
|
|
1984
|
-
}
|
|
1985
|
-
upsertMemoryEmbeddingCache({
|
|
1986
|
-
db: this.db,
|
|
1987
|
-
enabled: this.cache.enabled,
|
|
1988
|
-
provider: this.provider,
|
|
1989
|
-
providerKey: this.providerKey,
|
|
1990
|
-
entries: toCache,
|
|
1991
|
-
tableName: EMBEDDING_CACHE_TABLE$1
|
|
1992
|
-
});
|
|
1993
|
-
return embeddings;
|
|
1994
|
-
}
|
|
1995
|
-
computeProviderKey() {
|
|
1996
|
-
if (!this.provider) return hashText(JSON.stringify({
|
|
1997
|
-
provider: "none",
|
|
1998
|
-
model: "fts-only"
|
|
1999
|
-
}));
|
|
2000
|
-
if (this.providerRuntime?.cacheKeyData) return hashText(JSON.stringify(this.providerRuntime.cacheKeyData));
|
|
2001
|
-
return hashText(JSON.stringify({
|
|
2002
|
-
provider: this.provider.id,
|
|
2003
|
-
model: this.provider.model
|
|
2004
|
-
}));
|
|
2005
|
-
}
|
|
2006
|
-
buildBatchDebug(source, chunks) {
|
|
2007
|
-
return (message, data) => log$2.debug(message, data ? {
|
|
2008
|
-
...data,
|
|
2009
|
-
source,
|
|
2010
|
-
chunks: chunks.length
|
|
2011
|
-
} : {
|
|
2012
|
-
source,
|
|
2013
|
-
chunks: chunks.length
|
|
2014
|
-
});
|
|
2015
|
-
}
|
|
2016
|
-
async embedChunksWithBatch(chunks, _entry, source) {
|
|
2017
|
-
const provider = this.provider;
|
|
2018
|
-
const batchEmbed = this.providerRuntime?.batchEmbed;
|
|
2019
|
-
if (!provider || !batchEmbed) return this.embedChunksInBatches(chunks);
|
|
2020
|
-
if (chunks.length === 0) return [];
|
|
2021
|
-
const { embeddings, missing } = this.collectCachedEmbeddings(chunks);
|
|
2022
|
-
if (missing.length === 0) return embeddings;
|
|
2023
|
-
const missingChunks = missing.map((item) => item.chunk);
|
|
2024
|
-
const batchResult = await this.runBatchWithFallback({
|
|
2025
|
-
provider: provider.id,
|
|
2026
|
-
run: async () => await batchEmbed({
|
|
2027
|
-
agentId: this.agentId,
|
|
2028
|
-
chunks: missingChunks,
|
|
2029
|
-
wait: this.batch.wait,
|
|
2030
|
-
concurrency: this.batch.concurrency,
|
|
2031
|
-
pollIntervalMs: this.batch.pollIntervalMs,
|
|
2032
|
-
timeoutMs: this.batch.timeoutMs,
|
|
2033
|
-
debug: this.buildBatchDebug(source, chunks)
|
|
2034
|
-
}),
|
|
2035
|
-
fallback: async () => await this.embedChunksInBatches(chunks)
|
|
2036
|
-
});
|
|
2037
|
-
if (!batchResult) return this.embedChunksInBatches(chunks);
|
|
2038
|
-
const toCache = [];
|
|
2039
|
-
for (let index = 0; index < missing.length; index += 1) {
|
|
2040
|
-
const item = missing[index];
|
|
2041
|
-
const embedding = batchResult[index] ?? [];
|
|
2042
|
-
if (!item) continue;
|
|
2043
|
-
embeddings[item.index] = embedding;
|
|
2044
|
-
toCache.push({
|
|
2045
|
-
hash: item.chunk.hash,
|
|
2046
|
-
embedding
|
|
2047
|
-
});
|
|
2048
|
-
}
|
|
2049
|
-
upsertMemoryEmbeddingCache({
|
|
2050
|
-
db: this.db,
|
|
2051
|
-
enabled: this.cache.enabled,
|
|
2052
|
-
provider,
|
|
2053
|
-
providerKey: this.providerKey,
|
|
2054
|
-
entries: toCache,
|
|
2055
|
-
tableName: EMBEDDING_CACHE_TABLE$1
|
|
2056
|
-
});
|
|
2057
|
-
return embeddings;
|
|
2058
|
-
}
|
|
2059
|
-
collectCachedEmbeddings(chunks) {
|
|
2060
|
-
return collectMemoryCachedEmbeddings({
|
|
2061
|
-
chunks,
|
|
2062
|
-
cached: loadMemoryEmbeddingCache({
|
|
2063
|
-
db: this.db,
|
|
2064
|
-
enabled: this.cache.enabled,
|
|
2065
|
-
provider: this.provider,
|
|
2066
|
-
providerKey: this.providerKey,
|
|
2067
|
-
hashes: chunks.map((chunk) => chunk.hash),
|
|
2068
|
-
tableName: EMBEDDING_CACHE_TABLE$1
|
|
2069
|
-
})
|
|
2070
|
-
});
|
|
2071
|
-
}
|
|
2072
|
-
async embedBatchWithRetry(texts) {
|
|
2073
|
-
if (texts.length === 0) return [];
|
|
2074
|
-
const provider = this.provider;
|
|
2075
|
-
if (!provider) throw new Error("Cannot embed batch in FTS-only mode (no embedding provider)");
|
|
2076
|
-
return await runMemoryEmbeddingRetryLoop({
|
|
2077
|
-
run: async () => {
|
|
2078
|
-
const timeoutMs = this.resolveEmbeddingTimeout("batch");
|
|
2079
|
-
log$2.debug("memory embeddings: batch start", {
|
|
2080
|
-
provider: provider.id,
|
|
2081
|
-
items: texts.length,
|
|
2082
|
-
timeoutMs
|
|
2083
|
-
});
|
|
2084
|
-
return await this.withTimeout(provider.embedBatch(texts), timeoutMs, `memory embeddings batch timed out after ${Math.round(timeoutMs / 1e3)}s`);
|
|
2085
|
-
},
|
|
2086
|
-
isRetryable: isRetryableMemoryEmbeddingError,
|
|
2087
|
-
waitForRetry: async (delayMs) => {
|
|
2088
|
-
await this.waitForEmbeddingRetry(delayMs, "retrying");
|
|
2089
|
-
},
|
|
2090
|
-
maxAttempts: EMBEDDING_RETRY_MAX_ATTEMPTS,
|
|
2091
|
-
baseDelayMs: EMBEDDING_RETRY_BASE_DELAY_MS
|
|
2092
|
-
});
|
|
2093
|
-
}
|
|
2094
|
-
async embedBatchInputsWithRetry(inputs) {
|
|
2095
|
-
if (inputs.length === 0) return [];
|
|
2096
|
-
const provider = this.provider;
|
|
2097
|
-
const embedBatchInputs = provider?.embedBatchInputs;
|
|
2098
|
-
if (!embedBatchInputs) return await this.embedBatchWithRetry(inputs.map((input) => input.text));
|
|
2099
|
-
return await runMemoryEmbeddingRetryLoop({
|
|
2100
|
-
run: async () => {
|
|
2101
|
-
const timeoutMs = this.resolveEmbeddingTimeout("batch");
|
|
2102
|
-
log$2.debug("memory embeddings: structured batch start", {
|
|
2103
|
-
provider: provider.id,
|
|
2104
|
-
items: inputs.length,
|
|
2105
|
-
timeoutMs
|
|
2106
|
-
});
|
|
2107
|
-
return await this.withTimeout(embedBatchInputs(inputs), timeoutMs, `memory embeddings batch timed out after ${Math.round(timeoutMs / 1e3)}s`);
|
|
2108
|
-
},
|
|
2109
|
-
isRetryable: isRetryableMemoryEmbeddingError,
|
|
2110
|
-
waitForRetry: async (delayMs) => {
|
|
2111
|
-
await this.waitForEmbeddingRetry(delayMs, "retrying structured batch");
|
|
2112
|
-
},
|
|
2113
|
-
maxAttempts: EMBEDDING_RETRY_MAX_ATTEMPTS,
|
|
2114
|
-
baseDelayMs: EMBEDDING_RETRY_BASE_DELAY_MS
|
|
2115
|
-
});
|
|
2116
|
-
}
|
|
2117
|
-
async waitForEmbeddingRetry(delayMs, action) {
|
|
2118
|
-
const waitMs = resolveMemoryEmbeddingRetryDelay(delayMs, Math.random(), EMBEDDING_RETRY_MAX_DELAY_MS);
|
|
2119
|
-
log$2.warn(`memory embeddings rate limited; ${action} in ${waitMs}ms`);
|
|
2120
|
-
await new Promise((resolve) => setTimeout(resolve, waitMs));
|
|
2121
|
-
}
|
|
2122
|
-
resolveEmbeddingTimeout(kind) {
|
|
2123
|
-
const isLocal = this.provider?.id === "local";
|
|
2124
|
-
if (kind === "query") return isLocal ? EMBEDDING_QUERY_TIMEOUT_LOCAL_MS : EMBEDDING_QUERY_TIMEOUT_REMOTE_MS;
|
|
2125
|
-
return isLocal ? EMBEDDING_BATCH_TIMEOUT_LOCAL_MS : EMBEDDING_BATCH_TIMEOUT_REMOTE_MS;
|
|
2126
|
-
}
|
|
2127
|
-
async embedQueryWithTimeout(text) {
|
|
2128
|
-
if (!this.provider) throw new Error("Cannot embed query in FTS-only mode (no embedding provider)");
|
|
2129
|
-
const timeoutMs = this.resolveEmbeddingTimeout("query");
|
|
2130
|
-
log$2.debug("memory embeddings: query start", {
|
|
2131
|
-
provider: this.provider.id,
|
|
2132
|
-
timeoutMs
|
|
2133
|
-
});
|
|
2134
|
-
return await this.withTimeout(this.provider.embedQuery(text), timeoutMs, `memory embeddings query timed out after ${Math.round(timeoutMs / 1e3)}s`);
|
|
2135
|
-
}
|
|
2136
|
-
async withTimeout(promise, timeoutMs, message) {
|
|
2137
|
-
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) return await promise;
|
|
2138
|
-
let timer = null;
|
|
2139
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
2140
|
-
timer = setTimeout(() => reject(new Error(message)), timeoutMs);
|
|
2141
|
-
});
|
|
2142
|
-
try {
|
|
2143
|
-
return await Promise.race([promise, timeoutPromise]);
|
|
2144
|
-
} finally {
|
|
2145
|
-
if (timer) clearTimeout(timer);
|
|
2146
|
-
}
|
|
2147
|
-
}
|
|
2148
|
-
async withBatchFailureLock(fn) {
|
|
2149
|
-
let release;
|
|
2150
|
-
const wait = this.batchFailureLock;
|
|
2151
|
-
this.batchFailureLock = new Promise((resolve) => {
|
|
2152
|
-
release = resolve;
|
|
2153
|
-
});
|
|
2154
|
-
await wait;
|
|
2155
|
-
try {
|
|
2156
|
-
return await fn();
|
|
2157
|
-
} finally {
|
|
2158
|
-
release();
|
|
2159
|
-
}
|
|
2160
|
-
}
|
|
2161
|
-
async resetBatchFailureCount() {
|
|
2162
|
-
await this.withBatchFailureLock(async () => {
|
|
2163
|
-
if (this.batchFailureCount > 0) log$2.debug("memory embeddings: batch recovered; resetting failure count");
|
|
2164
|
-
const nextState = resetMemoryBatchFailureState({
|
|
2165
|
-
enabled: this.batch.enabled,
|
|
2166
|
-
count: this.batchFailureCount,
|
|
2167
|
-
lastError: this.batchFailureLastError,
|
|
2168
|
-
lastProvider: this.batchFailureLastProvider
|
|
2169
|
-
});
|
|
2170
|
-
this.batch.enabled = nextState.enabled;
|
|
2171
|
-
this.batchFailureCount = nextState.count;
|
|
2172
|
-
this.batchFailureLastError = nextState.lastError;
|
|
2173
|
-
this.batchFailureLastProvider = nextState.lastProvider;
|
|
2174
|
-
});
|
|
2175
|
-
}
|
|
2176
|
-
async recordBatchFailure(params) {
|
|
2177
|
-
return await this.withBatchFailureLock(async () => {
|
|
2178
|
-
if (!this.batch.enabled) return {
|
|
2179
|
-
disabled: true,
|
|
2180
|
-
count: this.batchFailureCount
|
|
2181
|
-
};
|
|
2182
|
-
const nextState = recordMemoryBatchFailure({
|
|
2183
|
-
enabled: this.batch.enabled,
|
|
2184
|
-
count: this.batchFailureCount,
|
|
2185
|
-
lastError: this.batchFailureLastError,
|
|
2186
|
-
lastProvider: this.batchFailureLastProvider
|
|
2187
|
-
}, params);
|
|
2188
|
-
this.batch.enabled = nextState.enabled;
|
|
2189
|
-
this.batchFailureCount = nextState.count;
|
|
2190
|
-
this.batchFailureLastError = nextState.lastError;
|
|
2191
|
-
this.batchFailureLastProvider = nextState.lastProvider;
|
|
2192
|
-
return {
|
|
2193
|
-
disabled: !nextState.enabled,
|
|
2194
|
-
count: nextState.count
|
|
2195
|
-
};
|
|
2196
|
-
});
|
|
2197
|
-
}
|
|
2198
|
-
isBatchTimeoutError(message) {
|
|
2199
|
-
return /timed out|timeout/i.test(message);
|
|
2200
|
-
}
|
|
2201
|
-
async runBatchWithTimeoutRetry(params) {
|
|
2202
|
-
try {
|
|
2203
|
-
return await params.run();
|
|
2204
|
-
} catch (err) {
|
|
2205
|
-
const message = formatErrorMessage(err);
|
|
2206
|
-
if (this.isBatchTimeoutError(message)) {
|
|
2207
|
-
log$2.warn(`memory embeddings: ${params.provider} batch timed out; retrying once`);
|
|
2208
|
-
try {
|
|
2209
|
-
return await params.run();
|
|
2210
|
-
} catch (retryErr) {
|
|
2211
|
-
retryErr.batchAttempts = 2;
|
|
2212
|
-
throw retryErr;
|
|
2213
|
-
}
|
|
2214
|
-
}
|
|
2215
|
-
throw err;
|
|
2216
|
-
}
|
|
2217
|
-
}
|
|
2218
|
-
async runBatchWithFallback(params) {
|
|
2219
|
-
if (!this.batch.enabled) return await params.fallback();
|
|
2220
|
-
try {
|
|
2221
|
-
const result = await this.runBatchWithTimeoutRetry({
|
|
2222
|
-
provider: params.provider,
|
|
2223
|
-
run: params.run
|
|
2224
|
-
});
|
|
2225
|
-
await this.resetBatchFailureCount();
|
|
2226
|
-
return result;
|
|
2227
|
-
} catch (err) {
|
|
2228
|
-
const message = formatErrorMessage(err);
|
|
2229
|
-
const attempts = err.batchAttempts ?? 1;
|
|
2230
|
-
const forceDisable = /asyncBatchEmbedContent not available/i.test(message);
|
|
2231
|
-
const failure = await this.recordBatchFailure({
|
|
2232
|
-
provider: params.provider,
|
|
2233
|
-
message,
|
|
2234
|
-
attempts,
|
|
2235
|
-
forceDisable
|
|
2236
|
-
});
|
|
2237
|
-
const suffix = failure.disabled ? "disabling batch" : "keeping batch enabled";
|
|
2238
|
-
log$2.warn(`memory embeddings: ${params.provider} batch failed (${failure.count}/2); ${suffix}; falling back to non-batch embeddings: ${message}`);
|
|
2239
|
-
return await params.fallback();
|
|
2240
|
-
}
|
|
2241
|
-
}
|
|
2242
|
-
getIndexConcurrency() {
|
|
2243
|
-
return this.batch.enabled ? this.batch.concurrency : EMBEDDING_INDEX_CONCURRENCY;
|
|
2244
|
-
}
|
|
2245
|
-
clearIndexedFileData(pathname, source) {
|
|
2246
|
-
if (this.vector.enabled) try {
|
|
2247
|
-
this.db.prepare(`DELETE FROM ${VECTOR_TABLE$1} WHERE id IN (SELECT id FROM chunks WHERE path = ? AND source = ?)`).run(pathname, source);
|
|
2248
|
-
} catch {}
|
|
2249
|
-
if (this.fts.enabled && this.fts.available) try {
|
|
2250
|
-
deleteMemoryFtsRows({
|
|
2251
|
-
db: this.db,
|
|
2252
|
-
tableName: FTS_TABLE$1,
|
|
2253
|
-
path: pathname,
|
|
2254
|
-
source,
|
|
2255
|
-
currentModel: this.provider?.model
|
|
2256
|
-
});
|
|
2257
|
-
} catch {}
|
|
2258
|
-
this.db.prepare(`DELETE FROM chunks WHERE path = ? AND source = ?`).run(pathname, source);
|
|
2259
|
-
}
|
|
2260
|
-
upsertFileRecord(entry, source) {
|
|
2261
|
-
this.db.prepare(`INSERT INTO files (path, source, hash, mtime, size) VALUES (?, ?, ?, ?, ?)
|
|
2262
|
-
ON CONFLICT(path) DO UPDATE SET
|
|
2263
|
-
source=excluded.source,
|
|
2264
|
-
hash=excluded.hash,
|
|
2265
|
-
mtime=excluded.mtime,
|
|
2266
|
-
size=excluded.size`).run(entry.path, source, entry.hash, entry.mtimeMs, entry.size);
|
|
2267
|
-
}
|
|
2268
|
-
deleteFileRecord(pathname, source) {
|
|
2269
|
-
this.db.prepare(`DELETE FROM files WHERE path = ? AND source = ?`).run(pathname, source);
|
|
2270
|
-
}
|
|
2271
|
-
/**
|
|
2272
|
-
* Write chunks (and optional embeddings) for a file into the index.
|
|
2273
|
-
* Handles both the chunks table, the vector table, and the FTS table.
|
|
2274
|
-
* Pass an empty embeddings array to skip vector writes (FTS-only mode).
|
|
2275
|
-
*/
|
|
2276
|
-
writeChunks(entry, source, model, chunks, embeddings, vectorReady) {
|
|
2277
|
-
const now = Date.now();
|
|
2278
|
-
this.clearIndexedFileData(entry.path, source);
|
|
2279
|
-
for (let i = 0; i < chunks.length; i++) {
|
|
2280
|
-
const chunk = chunks[i];
|
|
2281
|
-
const embedding = embeddings[i] ?? [];
|
|
2282
|
-
const id = hashText(`${source}:${entry.path}:${chunk.startLine}:${chunk.endLine}:${chunk.hash}:${model}`);
|
|
2283
|
-
this.db.prepare(`INSERT INTO chunks (id, path, source, start_line, end_line, hash, model, text, embedding, updated_at)
|
|
2284
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
2285
|
-
ON CONFLICT(id) DO UPDATE SET
|
|
2286
|
-
hash=excluded.hash,
|
|
2287
|
-
model=excluded.model,
|
|
2288
|
-
text=excluded.text,
|
|
2289
|
-
embedding=excluded.embedding,
|
|
2290
|
-
updated_at=excluded.updated_at`).run(id, entry.path, source, chunk.startLine, chunk.endLine, chunk.hash, model, chunk.text, JSON.stringify(embedding), now);
|
|
2291
|
-
if (vectorReady && embedding.length > 0) replaceMemoryVectorRow({
|
|
2292
|
-
db: this.db,
|
|
2293
|
-
tableName: VECTOR_TABLE$1,
|
|
2294
|
-
id,
|
|
2295
|
-
embedding
|
|
2296
|
-
});
|
|
2297
|
-
if (this.fts.enabled && this.fts.available) this.db.prepare(`INSERT INTO ${FTS_TABLE$1} (text, id, path, source, model, start_line, end_line)\n VALUES (?, ?, ?, ?, ?, ?, ?)`).run(chunk.text, id, entry.path, source, model, chunk.startLine, chunk.endLine);
|
|
2298
|
-
}
|
|
2299
|
-
if (vectorReady) this.lastVectorDegradationWarnKey = void 0;
|
|
2300
|
-
if (this.vector.enabled && !vectorReady && chunks.length > 0) {
|
|
2301
|
-
const errDetail = this.vector.loadError ? `: ${this.vector.loadError}` : "";
|
|
2302
|
-
if (this.lastVectorDegradationWarnKey !== errDetail) {
|
|
2303
|
-
this.lastVectorDegradationWarnKey = errDetail;
|
|
2304
|
-
log$2.warn(`chunks written for ${entry.path} without vector embeddings — chunks_vec not updated (sqlite-vec unavailable${errDetail}). Vector recall degraded for this file.`);
|
|
2305
|
-
} else log$2.debug(`chunks written without vector embeddings (${entry.path}); sqlite-vec unavailable${errDetail}`);
|
|
2306
|
-
}
|
|
2307
|
-
this.upsertFileRecord(entry, source);
|
|
2308
|
-
}
|
|
2309
|
-
async indexFile(entry, options) {
|
|
2310
|
-
if (!this.provider) {
|
|
2311
|
-
if ("kind" in entry && entry.kind === "multimodal") return;
|
|
2312
|
-
const chunks = filterNonEmptyMemoryChunks(chunkMarkdown(options.content ?? await fs$1.readFile(entry.absPath, "utf-8"), this.settings.chunking));
|
|
2313
|
-
if (options.source === "sessions" && "lineMap" in entry) remapChunkLines(chunks, entry.lineMap);
|
|
2314
|
-
this.writeChunks(entry, options.source, "fts-only", chunks, [], false);
|
|
2315
|
-
return;
|
|
2316
|
-
}
|
|
2317
|
-
let chunks;
|
|
2318
|
-
let structuredInputBytes;
|
|
2319
|
-
if ("kind" in entry && entry.kind === "multimodal") {
|
|
2320
|
-
if (!this.provider) {
|
|
2321
|
-
log$2.debug("Skipping multimodal indexing in FTS-only mode", {
|
|
2322
|
-
path: entry.path,
|
|
2323
|
-
source: options.source
|
|
2324
|
-
});
|
|
2325
|
-
this.clearIndexedFileData(entry.path, options.source);
|
|
2326
|
-
this.upsertFileRecord(entry, options.source);
|
|
2327
|
-
return;
|
|
2328
|
-
}
|
|
2329
|
-
const multimodalChunk = await buildMultimodalChunkForIndexing(entry);
|
|
2330
|
-
if (!multimodalChunk) {
|
|
2331
|
-
this.clearIndexedFileData(entry.path, options.source);
|
|
2332
|
-
this.deleteFileRecord(entry.path, options.source);
|
|
2333
|
-
return;
|
|
2334
|
-
}
|
|
2335
|
-
structuredInputBytes = multimodalChunk.structuredInputBytes;
|
|
2336
|
-
chunks = [multimodalChunk.chunk];
|
|
2337
|
-
} else {
|
|
2338
|
-
const baseChunks = filterNonEmptyMemoryChunks(chunkMarkdown(options.content ?? await fs$1.readFile(entry.absPath, "utf-8"), this.settings.chunking));
|
|
2339
|
-
chunks = this.provider ? enforceEmbeddingMaxInputTokens(this.provider, baseChunks, EMBEDDING_BATCH_MAX_TOKENS) : baseChunks;
|
|
2340
|
-
if (options.source === "sessions" && "lineMap" in entry) remapChunkLines(chunks, entry.lineMap);
|
|
2341
|
-
}
|
|
2342
|
-
if (!this.provider) {
|
|
2343
|
-
this.writeChunks(entry, options.source, "fts-only", chunks, [], false);
|
|
2344
|
-
return;
|
|
2345
|
-
}
|
|
2346
|
-
let embeddings;
|
|
2347
|
-
try {
|
|
2348
|
-
embeddings = this.batch.enabled ? await this.embedChunksWithBatch(chunks, entry, options.source) : await this.embedChunksInBatches(chunks);
|
|
2349
|
-
} catch (err) {
|
|
2350
|
-
const message = formatErrorMessage(err);
|
|
2351
|
-
if ("kind" in entry && entry.kind === "multimodal" && /(413|payload too large|request too large|input too large|too many tokens|input limit|request size)/i.test(message)) {
|
|
2352
|
-
log$2.warn("memory embeddings: skipping multimodal file rejected as too large", {
|
|
2353
|
-
path: entry.path,
|
|
2354
|
-
bytes: structuredInputBytes,
|
|
2355
|
-
provider: this.provider.id,
|
|
2356
|
-
model: this.provider.model,
|
|
2357
|
-
error: message
|
|
2358
|
-
});
|
|
2359
|
-
this.clearIndexedFileData(entry.path, options.source);
|
|
2360
|
-
this.upsertFileRecord(entry, options.source);
|
|
2361
|
-
return;
|
|
2362
|
-
}
|
|
2363
|
-
throw err;
|
|
2364
|
-
}
|
|
2365
|
-
const sample = embeddings.find((embedding) => embedding.length > 0);
|
|
2366
|
-
const vectorReady = sample ? await this.ensureVectorReady(sample.length) : false;
|
|
2367
|
-
this.writeChunks(entry, options.source, this.provider.model, chunks, embeddings, vectorReady);
|
|
2368
|
-
}
|
|
2369
|
-
};
|
|
2370
|
-
//#endregion
|
|
2371
|
-
//#region extensions/memory-core/src/memory/manager-search-preflight.ts
|
|
2372
|
-
function resolveMemorySearchPreflight(params) {
|
|
2373
|
-
const normalizedQuery = params.query.trim();
|
|
2374
|
-
if (!normalizedQuery) return {
|
|
2375
|
-
normalizedQuery,
|
|
2376
|
-
shouldInitializeProvider: false,
|
|
2377
|
-
shouldSearch: false
|
|
2378
|
-
};
|
|
2379
|
-
if (!params.hasIndexedContent) return {
|
|
2380
|
-
normalizedQuery,
|
|
2381
|
-
shouldInitializeProvider: false,
|
|
2382
|
-
shouldSearch: false
|
|
2383
|
-
};
|
|
2384
|
-
return {
|
|
2385
|
-
normalizedQuery,
|
|
2386
|
-
shouldInitializeProvider: true,
|
|
2387
|
-
shouldSearch: true
|
|
2388
|
-
};
|
|
2389
|
-
}
|
|
2390
|
-
//#endregion
|
|
2391
|
-
//#region extensions/memory-core/src/memory/manager-search.ts
|
|
2392
|
-
const vectorToBlob = (embedding) => Buffer.from(new Float32Array(embedding).buffer);
|
|
2393
|
-
const FTS_QUERY_TOKEN_RE = /[\p{L}\p{N}_]+/gu;
|
|
2394
|
-
const SHORT_CJK_TRIGRAM_RE = /[\u3040-\u30ff\u3400-\u9fff\uac00-\ud7af\u3131-\u3163]/u;
|
|
2395
|
-
function normalizeSearchTokens(raw) {
|
|
2396
|
-
return raw.match(FTS_QUERY_TOKEN_RE)?.map((token) => token.trim().toLowerCase()).filter(Boolean) ?? [];
|
|
2397
|
-
}
|
|
2398
|
-
function scoreFallbackKeywordResult(params) {
|
|
2399
|
-
const queryTokens = [...new Set(normalizeSearchTokens(params.query))];
|
|
2400
|
-
if (queryTokens.length === 0) return params.ftsScore;
|
|
2401
|
-
const textTokens = normalizeSearchTokens(params.text);
|
|
2402
|
-
const textTokenSet = new Set(textTokens);
|
|
2403
|
-
const pathLower = params.path.toLowerCase();
|
|
2404
|
-
const overlap = queryTokens.filter((token) => textTokenSet.has(token)).length;
|
|
2405
|
-
const uniqueQueryOverlap = overlap / Math.max(new Set(queryTokens).size, 1);
|
|
2406
|
-
const density = overlap / Math.max(textTokenSet.size, 1);
|
|
2407
|
-
const pathBoost = queryTokens.reduce((score, token) => score + (pathLower.includes(token) ? .18 : 0), 0);
|
|
2408
|
-
const textLengthBoost = Math.min(params.text.length / 160, .18);
|
|
2409
|
-
const lexicalBoost = uniqueQueryOverlap * .45 + density * .2 + pathBoost + textLengthBoost;
|
|
2410
|
-
return Math.min(1, params.ftsScore + lexicalBoost);
|
|
2411
|
-
}
|
|
2412
|
-
function escapeLikePattern(term) {
|
|
2413
|
-
return term.replaceAll("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_");
|
|
2414
|
-
}
|
|
2415
|
-
function buildMatchQueryFromTerms(terms) {
|
|
2416
|
-
if (terms.length === 0) return null;
|
|
2417
|
-
return terms.map((term) => `"${term.replaceAll("\"", "")}"`).join(" AND ");
|
|
2418
|
-
}
|
|
2419
|
-
function planKeywordSearch(params) {
|
|
2420
|
-
if (params.ftsTokenizer !== "trigram") return {
|
|
2421
|
-
matchQuery: params.buildFtsQuery(params.query),
|
|
2422
|
-
substringTerms: []
|
|
2423
|
-
};
|
|
2424
|
-
const tokens = params.query.match(FTS_QUERY_TOKEN_RE)?.map((token) => token.trim()).filter(Boolean) ?? [];
|
|
2425
|
-
if (tokens.length === 0) return {
|
|
2426
|
-
matchQuery: null,
|
|
2427
|
-
substringTerms: []
|
|
2428
|
-
};
|
|
2429
|
-
const matchTerms = [];
|
|
2430
|
-
const substringTerms = [];
|
|
2431
|
-
for (const token of tokens) {
|
|
2432
|
-
if (SHORT_CJK_TRIGRAM_RE.test(token) && Array.from(token).length < 3) {
|
|
2433
|
-
substringTerms.push(token);
|
|
2434
|
-
continue;
|
|
2435
|
-
}
|
|
2436
|
-
matchTerms.push(token);
|
|
2437
|
-
}
|
|
2438
|
-
return {
|
|
2439
|
-
matchQuery: buildMatchQueryFromTerms(matchTerms),
|
|
2440
|
-
substringTerms
|
|
2441
|
-
};
|
|
2442
|
-
}
|
|
2443
|
-
async function searchVector(params) {
|
|
2444
|
-
if (params.queryVec.length === 0 || params.limit <= 0) return [];
|
|
2445
|
-
if (await params.ensureVectorReady(params.queryVec.length)) return params.db.prepare(`SELECT c.id, c.path, c.start_line, c.end_line, c.text,
|
|
2446
|
-
c.source,
|
|
2447
|
-
vec_distance_cosine(v.embedding, ?) AS dist
|
|
2448
|
-
FROM ${params.vectorTable} v\n JOIN chunks c ON c.id = v.id\n WHERE c.model = ?${params.sourceFilterVec.sql}\n ORDER BY dist ASC\n LIMIT ?`).all(vectorToBlob(params.queryVec), params.providerModel, ...params.sourceFilterVec.params, params.limit).map((row) => ({
|
|
2449
|
-
id: row.id,
|
|
2450
|
-
path: row.path,
|
|
2451
|
-
startLine: row.start_line,
|
|
2452
|
-
endLine: row.end_line,
|
|
2453
|
-
score: 1 - row.dist,
|
|
2454
|
-
snippet: truncateUtf16Safe(row.text, params.snippetMaxChars),
|
|
2455
|
-
source: row.source
|
|
2456
|
-
}));
|
|
2457
|
-
if (countChunks(params.db, params.providerModel, params.sourceFilterChunks) > 1e3) return [];
|
|
2458
|
-
return listChunks({
|
|
2459
|
-
db: params.db,
|
|
2460
|
-
providerModel: params.providerModel,
|
|
2461
|
-
sourceFilter: params.sourceFilterChunks
|
|
2462
|
-
}).map((chunk) => ({
|
|
2463
|
-
chunk,
|
|
2464
|
-
score: cosineSimilarity(params.queryVec, chunk.embedding)
|
|
2465
|
-
})).filter((entry) => Number.isFinite(entry.score)).toSorted((a, b) => b.score - a.score).slice(0, params.limit).map((entry) => ({
|
|
2466
|
-
id: entry.chunk.id,
|
|
2467
|
-
path: entry.chunk.path,
|
|
2468
|
-
startLine: entry.chunk.startLine,
|
|
2469
|
-
endLine: entry.chunk.endLine,
|
|
2470
|
-
score: entry.score,
|
|
2471
|
-
snippet: truncateUtf16Safe(entry.chunk.text, params.snippetMaxChars),
|
|
2472
|
-
source: entry.chunk.source
|
|
2473
|
-
}));
|
|
2474
|
-
}
|
|
2475
|
-
function countChunks(db, providerModel, sourceFilter) {
|
|
2476
|
-
return db.prepare(`SELECT COUNT(*) as c FROM chunks WHERE model = ?${sourceFilter.sql}`).get(providerModel, ...sourceFilter.params)?.c ?? 0;
|
|
2477
|
-
}
|
|
2478
|
-
function listChunks(params) {
|
|
2479
|
-
return params.db.prepare(`SELECT id, path, start_line, end_line, text, embedding, source
|
|
2480
|
-
FROM chunks
|
|
2481
|
-
WHERE model = ?${params.sourceFilter.sql}`).all(params.providerModel, ...params.sourceFilter.params).map((row) => ({
|
|
2482
|
-
id: row.id,
|
|
2483
|
-
path: row.path,
|
|
2484
|
-
startLine: row.start_line,
|
|
2485
|
-
endLine: row.end_line,
|
|
2486
|
-
text: row.text,
|
|
2487
|
-
embedding: parseEmbedding(row.embedding),
|
|
2488
|
-
source: row.source
|
|
2489
|
-
}));
|
|
2490
|
-
}
|
|
2491
|
-
async function searchKeyword(params) {
|
|
2492
|
-
if (params.limit <= 0) return [];
|
|
2493
|
-
const plan = planKeywordSearch({
|
|
2494
|
-
query: params.query,
|
|
2495
|
-
ftsTokenizer: params.ftsTokenizer,
|
|
2496
|
-
buildFtsQuery: params.buildFtsQuery
|
|
2497
|
-
});
|
|
2498
|
-
if (!plan.matchQuery && plan.substringTerms.length === 0) return [];
|
|
2499
|
-
const modelClause = params.providerModel ? " AND model = ?" : "";
|
|
2500
|
-
const modelParams = params.providerModel ? [params.providerModel] : [];
|
|
2501
|
-
const substringClause = plan.substringTerms.map(() => " AND text LIKE ? ESCAPE '\\'").join("");
|
|
2502
|
-
const substringParams = plan.substringTerms.map((term) => `%${escapeLikePattern(term)}%`);
|
|
2503
|
-
const whereClause = plan.matchQuery ? `${params.ftsTable} MATCH ?${substringClause}${modelClause}${params.sourceFilter.sql}` : `1=1${substringClause}${modelClause}${params.sourceFilter.sql}`;
|
|
2504
|
-
const queryParams = [
|
|
2505
|
-
...plan.matchQuery ? [plan.matchQuery] : [],
|
|
2506
|
-
...substringParams,
|
|
2507
|
-
...modelParams,
|
|
2508
|
-
...params.sourceFilter.params,
|
|
2509
|
-
params.limit
|
|
2510
|
-
];
|
|
2511
|
-
const rankExpression = plan.matchQuery ? `bm25(${params.ftsTable})` : "0";
|
|
2512
|
-
return params.db.prepare(`SELECT id, path, source, start_line, end_line, text,\n ${rankExpression} AS rank\n FROM ${params.ftsTable}\n WHERE ${whereClause}\n ORDER BY rank ASC\n LIMIT ?`).all(...queryParams).map((row) => {
|
|
2513
|
-
const textScore = plan.matchQuery ? params.bm25RankToScore(row.rank) : 1;
|
|
2514
|
-
const score = params.boostFallbackRanking ? scoreFallbackKeywordResult({
|
|
2515
|
-
query: params.query,
|
|
2516
|
-
path: row.path,
|
|
2517
|
-
text: row.text,
|
|
2518
|
-
ftsScore: textScore
|
|
2519
|
-
}) : textScore;
|
|
2520
|
-
return {
|
|
2521
|
-
id: row.id,
|
|
2522
|
-
path: row.path,
|
|
2523
|
-
startLine: row.start_line,
|
|
2524
|
-
endLine: row.end_line,
|
|
2525
|
-
score,
|
|
2526
|
-
textScore,
|
|
2527
|
-
snippet: truncateUtf16Safe(row.text, params.snippetMaxChars),
|
|
2528
|
-
source: row.source
|
|
2529
|
-
};
|
|
2530
|
-
});
|
|
2531
|
-
}
|
|
2532
|
-
//#endregion
|
|
2533
|
-
//#region extensions/memory-core/src/memory/manager-status-state.ts
|
|
2534
|
-
const MEMORY_STATUS_AGGREGATE_SQL = "SELECT 'files' AS kind, source, COUNT(*) as c FROM files WHERE 1=1__FILTER__ GROUP BY source\nUNION ALL\nSELECT 'chunks' AS kind, source, COUNT(*) as c FROM chunks WHERE 1=1__FILTER__ GROUP BY source";
|
|
2535
|
-
function resolveInitialMemoryDirty(params) {
|
|
2536
|
-
return params.hasMemorySource && (params.statusOnly ? !params.hasIndexedMeta : true);
|
|
2537
|
-
}
|
|
2538
|
-
function resolveStatusProviderInfo(params) {
|
|
2539
|
-
if (params.provider) return {
|
|
2540
|
-
provider: params.provider.id,
|
|
2541
|
-
model: params.provider.model,
|
|
2542
|
-
searchMode: "hybrid"
|
|
2543
|
-
};
|
|
2544
|
-
if (params.providerInitialized) return {
|
|
2545
|
-
provider: "none",
|
|
2546
|
-
model: void 0,
|
|
2547
|
-
searchMode: "fts-only"
|
|
2548
|
-
};
|
|
2549
|
-
return {
|
|
2550
|
-
provider: params.requestedProvider,
|
|
2551
|
-
model: params.configuredModel || void 0,
|
|
2552
|
-
searchMode: "hybrid"
|
|
2553
|
-
};
|
|
2554
|
-
}
|
|
2555
|
-
function collectMemoryStatusAggregate(params) {
|
|
2556
|
-
const sources = Array.from(params.sources);
|
|
2557
|
-
const bySource = /* @__PURE__ */ new Map();
|
|
2558
|
-
for (const source of sources) bySource.set(source, {
|
|
2559
|
-
files: 0,
|
|
2560
|
-
chunks: 0
|
|
2561
|
-
});
|
|
2562
|
-
const sourceFilterSql = params.sourceFilterSql ?? "";
|
|
2563
|
-
const sourceFilterParams = params.sourceFilterParams ?? [];
|
|
2564
|
-
const aggregateRows = params.db.prepare(MEMORY_STATUS_AGGREGATE_SQL.replaceAll("__FILTER__", sourceFilterSql)).all(...sourceFilterParams, ...sourceFilterParams);
|
|
2565
|
-
let files = 0;
|
|
2566
|
-
let chunks = 0;
|
|
2567
|
-
for (const row of aggregateRows) {
|
|
2568
|
-
const count = row.c ?? 0;
|
|
2569
|
-
const entry = bySource.get(row.source) ?? {
|
|
2570
|
-
files: 0,
|
|
2571
|
-
chunks: 0
|
|
2572
|
-
};
|
|
2573
|
-
if (row.kind === "files") {
|
|
2574
|
-
entry.files = count;
|
|
2575
|
-
files += count;
|
|
2576
|
-
} else {
|
|
2577
|
-
entry.chunks = count;
|
|
2578
|
-
chunks += count;
|
|
2579
|
-
}
|
|
2580
|
-
bySource.set(row.source, entry);
|
|
2581
|
-
}
|
|
2582
|
-
return {
|
|
2583
|
-
files,
|
|
2584
|
-
chunks,
|
|
2585
|
-
sourceCounts: sources.map((source) => Object.assign({ source }, bySource.get(source)))
|
|
2586
|
-
};
|
|
2587
|
-
}
|
|
2588
|
-
//#endregion
|
|
2589
|
-
//#region extensions/memory-core/src/memory/manager-sync-control.ts
|
|
2590
|
-
const log$1 = createSubsystemLogger("memory");
|
|
2591
|
-
function isMemoryReadonlyDbError(err) {
|
|
2592
|
-
const readonlyPattern = /attempt to write a readonly database|database is read-only|SQLITE_READONLY/i;
|
|
2593
|
-
const messages = /* @__PURE__ */ new Set();
|
|
2594
|
-
const pushValue = (value) => {
|
|
2595
|
-
if (typeof value !== "string") return;
|
|
2596
|
-
const normalized = value.trim();
|
|
2597
|
-
if (!normalized) return;
|
|
2598
|
-
messages.add(normalized);
|
|
2599
|
-
};
|
|
2600
|
-
pushValue(formatErrorMessage(err));
|
|
2601
|
-
if (err && typeof err === "object") {
|
|
2602
|
-
const record = err;
|
|
2603
|
-
pushValue(record.message);
|
|
2604
|
-
pushValue(record.code);
|
|
2605
|
-
pushValue(record.name);
|
|
2606
|
-
if (record.cause && typeof record.cause === "object") {
|
|
2607
|
-
const cause = record.cause;
|
|
2608
|
-
pushValue(cause.message);
|
|
2609
|
-
pushValue(cause.code);
|
|
2610
|
-
pushValue(cause.name);
|
|
2611
|
-
}
|
|
2612
|
-
}
|
|
2613
|
-
return [...messages].some((value) => readonlyPattern.test(value));
|
|
2614
|
-
}
|
|
2615
|
-
function extractMemoryErrorReason(err) {
|
|
2616
|
-
if (err instanceof Error && err.message.trim()) return err.message;
|
|
2617
|
-
if (err && typeof err === "object") {
|
|
2618
|
-
const record = err;
|
|
2619
|
-
if (typeof record.message === "string" && record.message.trim()) return record.message;
|
|
2620
|
-
if (typeof record.code === "string" && record.code.trim()) return record.code;
|
|
2621
|
-
}
|
|
2622
|
-
return String(err);
|
|
2623
|
-
}
|
|
2624
|
-
async function runMemorySyncWithReadonlyRecovery(state, params) {
|
|
2625
|
-
try {
|
|
2626
|
-
await state.runSync(params);
|
|
2627
|
-
return;
|
|
2628
|
-
} catch (err) {
|
|
2629
|
-
if (!isMemoryReadonlyDbError(err) || state.closed) throw err;
|
|
2630
|
-
const reason = extractMemoryErrorReason(err);
|
|
2631
|
-
state.readonlyRecoveryAttempts += 1;
|
|
2632
|
-
state.readonlyRecoveryLastError = reason;
|
|
2633
|
-
log$1.warn(`memory sync readonly handle detected; reopening sqlite connection`, { reason });
|
|
2634
|
-
try {
|
|
2635
|
-
state.db.close();
|
|
2636
|
-
} catch {}
|
|
2637
|
-
state.db = state.openDatabase();
|
|
2638
|
-
state.vectorReady = null;
|
|
2639
|
-
state.vector.available = null;
|
|
2640
|
-
state.vector.loadError = void 0;
|
|
2641
|
-
state.ensureSchema();
|
|
2642
|
-
const meta = state.readMeta();
|
|
2643
|
-
state.vector.dims = meta?.vectorDims;
|
|
2644
|
-
try {
|
|
2645
|
-
await state.runSync(params);
|
|
2646
|
-
state.readonlyRecoverySuccesses += 1;
|
|
2647
|
-
} catch (retryErr) {
|
|
2648
|
-
state.readonlyRecoveryFailures += 1;
|
|
2649
|
-
throw retryErr;
|
|
2650
|
-
}
|
|
2651
|
-
}
|
|
2652
|
-
}
|
|
2653
|
-
function enqueueMemoryTargetedSessionSync(state, sessionFiles) {
|
|
2654
|
-
const queuedSessionFiles = state.getQueuedSessionFiles();
|
|
2655
|
-
for (const sessionFile of sessionFiles ?? []) {
|
|
2656
|
-
const trimmed = sessionFile.trim();
|
|
2657
|
-
if (trimmed) queuedSessionFiles.add(trimmed);
|
|
2658
|
-
}
|
|
2659
|
-
if (queuedSessionFiles.size === 0) return state.getSyncing() ?? Promise.resolve();
|
|
2660
|
-
if (!state.getQueuedSessionSync()) state.setQueuedSessionSync((async () => {
|
|
2661
|
-
try {
|
|
2662
|
-
await state.getSyncing()?.catch(() => void 0);
|
|
2663
|
-
while (!state.isClosed() && state.getQueuedSessionFiles().size > 0) {
|
|
2664
|
-
const pendingSessionFiles = Array.from(state.getQueuedSessionFiles());
|
|
2665
|
-
state.getQueuedSessionFiles().clear();
|
|
2666
|
-
await state.sync({
|
|
2667
|
-
reason: "queued-session-files",
|
|
2668
|
-
sessionFiles: pendingSessionFiles
|
|
2669
|
-
});
|
|
2670
|
-
}
|
|
2671
|
-
} finally {
|
|
2672
|
-
state.setQueuedSessionSync(null);
|
|
2673
|
-
}
|
|
2674
|
-
})());
|
|
2675
|
-
return state.getQueuedSessionSync() ?? Promise.resolve();
|
|
2676
|
-
}
|
|
2677
|
-
//#endregion
|
|
2678
|
-
//#region extensions/memory-core/src/memory/recall-verify.ts
|
|
2679
|
-
const DEFAULT_RECALL_VERIFY_CONFIG = {
|
|
2680
|
-
enabled: false,
|
|
2681
|
-
fuzzyWindow: 20
|
|
2682
|
-
};
|
|
2683
|
-
function normalizeForComparison(text) {
|
|
2684
|
-
return text.trim().replaceAll(/\s+/g, " ");
|
|
2685
|
-
}
|
|
2686
|
-
/**
|
|
2687
|
-
* Verify search results by re-reading source files and checking that snippets
|
|
2688
|
-
* still exist at the claimed line ranges.
|
|
2689
|
-
*
|
|
2690
|
-
* When `config.enabled` is false (the default), every result is returned with
|
|
2691
|
-
* `verified: true` — the caller trusts the index.
|
|
2692
|
-
*
|
|
2693
|
-
* When enabled, each result goes through:
|
|
2694
|
-
* 1. Read the source file.
|
|
2695
|
-
* 2. Compare the snippet at the claimed range (whitespace-normalized).
|
|
2696
|
-
* 3. If not found, slide a window of the same height within ±`fuzzyWindow`.
|
|
2697
|
-
* 4. Return corrected `actualStartLine` / `actualEndLine` when relocated.
|
|
2698
|
-
*/
|
|
2699
|
-
async function verifySearchResults(results, fileReader, config = {}) {
|
|
2700
|
-
const resolved = {
|
|
2701
|
-
enabled: config.enabled ?? DEFAULT_RECALL_VERIFY_CONFIG.enabled,
|
|
2702
|
-
fuzzyWindow: config.fuzzyWindow ?? DEFAULT_RECALL_VERIFY_CONFIG.fuzzyWindow
|
|
2703
|
-
};
|
|
2704
|
-
if (!resolved.enabled) return results.map((r) => ({
|
|
2705
|
-
...r,
|
|
2706
|
-
verified: true
|
|
2707
|
-
}));
|
|
2708
|
-
const verified = [];
|
|
2709
|
-
for (const result of results) {
|
|
2710
|
-
const content = await fileReader.readFile(result.path);
|
|
2711
|
-
if (content === null) {
|
|
2712
|
-
verified.push({
|
|
2713
|
-
...result,
|
|
2714
|
-
verified: false
|
|
2715
|
-
});
|
|
2716
|
-
continue;
|
|
2717
|
-
}
|
|
2718
|
-
const lines = content.split("\n");
|
|
2719
|
-
const snippetNorm = normalizeForComparison(result.snippet);
|
|
2720
|
-
const rangeHeight = result.endLine - result.startLine + 1;
|
|
2721
|
-
if (normalizeForComparison(lines.slice(result.startLine - 1, result.endLine).join("\n")).includes(snippetNorm)) {
|
|
2722
|
-
verified.push({
|
|
2723
|
-
...result,
|
|
2724
|
-
verified: true
|
|
2725
|
-
});
|
|
2726
|
-
continue;
|
|
2727
|
-
}
|
|
2728
|
-
const searchStart = Math.max(1, result.startLine - resolved.fuzzyWindow);
|
|
2729
|
-
const searchEnd = Math.min(lines.length, result.endLine + resolved.fuzzyWindow);
|
|
2730
|
-
let found = false;
|
|
2731
|
-
for (let pos = searchStart; pos + rangeHeight - 1 <= searchEnd; pos++) if (normalizeForComparison(lines.slice(pos - 1, pos - 1 + rangeHeight).join("\n")).includes(snippetNorm)) {
|
|
2732
|
-
verified.push({
|
|
2733
|
-
...result,
|
|
2734
|
-
verified: true,
|
|
2735
|
-
actualStartLine: pos,
|
|
2736
|
-
actualEndLine: pos + rangeHeight - 1
|
|
2737
|
-
});
|
|
2738
|
-
found = true;
|
|
2739
|
-
break;
|
|
2740
|
-
}
|
|
2741
|
-
if (!found) verified.push({
|
|
2742
|
-
...result,
|
|
2743
|
-
verified: false
|
|
2744
|
-
});
|
|
2745
|
-
}
|
|
2746
|
-
return verified;
|
|
2747
|
-
}
|
|
2748
|
-
//#endregion
|
|
2749
|
-
//#region extensions/memory-core/src/memory/manager.ts
|
|
2750
|
-
const SNIPPET_MAX_CHARS = 700;
|
|
2751
|
-
const VECTOR_TABLE = "chunks_vec";
|
|
2752
|
-
const FTS_TABLE = "chunks_fts";
|
|
2753
|
-
const EMBEDDING_CACHE_TABLE = "embedding_cache";
|
|
2754
|
-
const MEMORY_INDEX_MANAGER_CACHE_KEY = Symbol.for("kaijibot.memoryIndexManagerCache");
|
|
2755
|
-
const log = createSubsystemLogger("memory");
|
|
2756
|
-
const { cache: INDEX_CACHE, pending: INDEX_CACHE_PENDING } = resolveSingletonManagedCache(MEMORY_INDEX_MANAGER_CACHE_KEY);
|
|
2757
|
-
async function closeAllMemoryIndexManagers() {
|
|
2758
|
-
await closeManagedCacheEntries({
|
|
2759
|
-
cache: INDEX_CACHE,
|
|
2760
|
-
pending: INDEX_CACHE_PENDING,
|
|
2761
|
-
onCloseError: (err) => {
|
|
2762
|
-
log.warn(`failed to close memory index manager: ${String(err)}`);
|
|
2763
|
-
}
|
|
2764
|
-
});
|
|
2765
|
-
}
|
|
2766
|
-
var MemoryIndexManager = class MemoryIndexManager extends MemoryManagerEmbeddingOps {
|
|
2767
|
-
static async loadProviderResult(params) {
|
|
2768
|
-
return await createEmbeddingProvider({
|
|
2769
|
-
config: params.cfg,
|
|
2770
|
-
agentDir: resolveAgentDir(params.cfg, params.agentId),
|
|
2771
|
-
...resolveMemoryPrimaryProviderRequest({ settings: params.settings })
|
|
2772
|
-
});
|
|
2773
|
-
}
|
|
2774
|
-
static async get(params) {
|
|
2775
|
-
const { cfg, agentId } = params;
|
|
2776
|
-
const settings = resolveMemorySearchConfig(cfg, agentId);
|
|
2777
|
-
if (!settings) return null;
|
|
2778
|
-
const workspaceDir = resolveAgentWorkspaceDir(cfg, agentId);
|
|
2779
|
-
const purpose = params.purpose === "status" ? "status" : "default";
|
|
2780
|
-
const key = `${agentId}:${workspaceDir}:${JSON.stringify(settings)}:${purpose}`;
|
|
2781
|
-
return await getOrCreateManagedCacheEntry({
|
|
2782
|
-
cache: INDEX_CACHE,
|
|
2783
|
-
pending: INDEX_CACHE_PENDING,
|
|
2784
|
-
key,
|
|
2785
|
-
bypassCache: params.purpose === "status",
|
|
2786
|
-
create: async () => new MemoryIndexManager({
|
|
2787
|
-
cacheKey: key,
|
|
2788
|
-
cfg,
|
|
2789
|
-
agentId,
|
|
2790
|
-
workspaceDir,
|
|
2791
|
-
settings,
|
|
2792
|
-
purpose: params.purpose
|
|
2793
|
-
})
|
|
2794
|
-
});
|
|
2795
|
-
}
|
|
2796
|
-
constructor(params) {
|
|
2797
|
-
super();
|
|
2798
|
-
this.providerInitPromise = null;
|
|
2799
|
-
this.providerInitialized = false;
|
|
2800
|
-
this.batchFailureCount = 0;
|
|
2801
|
-
this.batchFailureLock = Promise.resolve();
|
|
2802
|
-
this.vectorReady = null;
|
|
2803
|
-
this.watcher = null;
|
|
2804
|
-
this.watchTimer = null;
|
|
2805
|
-
this.sessionWatchTimer = null;
|
|
2806
|
-
this.sessionUnsubscribe = null;
|
|
2807
|
-
this.intervalTimer = null;
|
|
2808
|
-
this.closed = false;
|
|
2809
|
-
this.dirty = false;
|
|
2810
|
-
this.sessionsDirty = false;
|
|
2811
|
-
this.sessionsDirtyFiles = /* @__PURE__ */ new Set();
|
|
2812
|
-
this.sessionPendingFiles = /* @__PURE__ */ new Set();
|
|
2813
|
-
this.sessionDeltas = /* @__PURE__ */ new Map();
|
|
2814
|
-
this.sessionWarm = /* @__PURE__ */ new Set();
|
|
2815
|
-
this.syncing = null;
|
|
2816
|
-
this.queuedSessionFiles = /* @__PURE__ */ new Set();
|
|
2817
|
-
this.queuedSessionSync = null;
|
|
2818
|
-
this.readonlyRecoveryAttempts = 0;
|
|
2819
|
-
this.readonlyRecoverySuccesses = 0;
|
|
2820
|
-
this.readonlyRecoveryFailures = 0;
|
|
2821
|
-
this.cacheKey = params.cacheKey;
|
|
2822
|
-
this.cfg = params.cfg;
|
|
2823
|
-
this.agentId = params.agentId;
|
|
2824
|
-
this.workspaceDir = params.workspaceDir;
|
|
2825
|
-
this.settings = params.settings;
|
|
2826
|
-
this.provider = null;
|
|
2827
|
-
this.requestedProvider = params.settings.provider;
|
|
2828
|
-
if (params.providerResult) this.applyProviderResult(params.providerResult);
|
|
2829
|
-
this.sources = new Set(params.settings.sources);
|
|
2830
|
-
this.db = this.openDatabase();
|
|
2831
|
-
this.providerKey = this.computeProviderKey();
|
|
2832
|
-
this.cache = {
|
|
2833
|
-
enabled: params.settings.cache.enabled,
|
|
2834
|
-
maxEntries: params.settings.cache.maxEntries
|
|
2835
|
-
};
|
|
2836
|
-
this.fts = {
|
|
2837
|
-
enabled: params.settings.query.hybrid.enabled,
|
|
2838
|
-
available: false
|
|
2839
|
-
};
|
|
2840
|
-
this.ensureSchema();
|
|
2841
|
-
this.vector = {
|
|
2842
|
-
enabled: params.settings.store.vector.enabled,
|
|
2843
|
-
available: null,
|
|
2844
|
-
extensionPath: params.settings.store.vector.extensionPath
|
|
2845
|
-
};
|
|
2846
|
-
const meta = this.readMeta();
|
|
2847
|
-
if (meta?.vectorDims) this.vector.dims = meta.vectorDims;
|
|
2848
|
-
const statusOnly = params.purpose === "status";
|
|
2849
|
-
if (!statusOnly) {
|
|
2850
|
-
this.ensureWatcher();
|
|
2851
|
-
this.ensureSessionListener();
|
|
2852
|
-
this.ensureIntervalSync();
|
|
2853
|
-
}
|
|
2854
|
-
this.dirty = resolveInitialMemoryDirty({
|
|
2855
|
-
hasMemorySource: this.sources.has("memory"),
|
|
2856
|
-
statusOnly,
|
|
2857
|
-
hasIndexedMeta: Boolean(meta)
|
|
2858
|
-
});
|
|
2859
|
-
this.batch = this.resolveBatchConfig();
|
|
2860
|
-
}
|
|
2861
|
-
applyProviderResult(providerResult) {
|
|
2862
|
-
const providerState = resolveMemoryProviderState(providerResult);
|
|
2863
|
-
this.provider = providerState.provider;
|
|
2864
|
-
this.fallbackFrom = providerState.fallbackFrom;
|
|
2865
|
-
this.fallbackReason = providerState.fallbackReason;
|
|
2866
|
-
this.providerUnavailableReason = providerState.providerUnavailableReason;
|
|
2867
|
-
this.providerRuntime = providerState.providerRuntime;
|
|
2868
|
-
this.providerInitialized = true;
|
|
2869
|
-
}
|
|
2870
|
-
async ensureProviderInitialized() {
|
|
2871
|
-
if (this.providerInitialized) return;
|
|
2872
|
-
if (!this.providerInitPromise) this.providerInitPromise = (async () => {
|
|
2873
|
-
const providerResult = await MemoryIndexManager.loadProviderResult({
|
|
2874
|
-
cfg: this.cfg,
|
|
2875
|
-
agentId: this.agentId,
|
|
2876
|
-
settings: this.settings
|
|
2877
|
-
});
|
|
2878
|
-
this.applyProviderResult(providerResult);
|
|
2879
|
-
this.providerKey = this.computeProviderKey();
|
|
2880
|
-
this.batch = this.resolveBatchConfig();
|
|
2881
|
-
})();
|
|
2882
|
-
try {
|
|
2883
|
-
await this.providerInitPromise;
|
|
2884
|
-
} finally {
|
|
2885
|
-
if (this.providerInitialized) this.providerInitPromise = null;
|
|
2886
|
-
}
|
|
2887
|
-
}
|
|
2888
|
-
async warmSession(sessionKey) {
|
|
2889
|
-
if (!this.settings.sync.onSessionStart) return;
|
|
2890
|
-
const key = sessionKey?.trim() || "";
|
|
2891
|
-
if (key && this.sessionWarm.has(key)) return;
|
|
2892
|
-
this.sync({ reason: "session-start" }).catch((err) => {
|
|
2893
|
-
log.warn(`memory sync failed (session-start): ${String(err)}`);
|
|
2894
|
-
});
|
|
2895
|
-
if (key) this.sessionWarm.add(key);
|
|
2896
|
-
}
|
|
2897
|
-
async search(query, opts) {
|
|
2898
|
-
opts?.onDebug?.({ backend: "builtin" });
|
|
2899
|
-
let hasIndexedContent = this.hasIndexedContent();
|
|
2900
|
-
if (!hasIndexedContent) {
|
|
2901
|
-
try {
|
|
2902
|
-
await this.sync({
|
|
2903
|
-
reason: "search",
|
|
2904
|
-
force: true
|
|
2905
|
-
});
|
|
2906
|
-
} catch (err) {
|
|
2907
|
-
log.warn(`memory sync failed (search-bootstrap): ${String(err)}`);
|
|
2908
|
-
}
|
|
2909
|
-
hasIndexedContent = this.hasIndexedContent();
|
|
2910
|
-
}
|
|
2911
|
-
const preflight = resolveMemorySearchPreflight({
|
|
2912
|
-
query,
|
|
2913
|
-
hasIndexedContent
|
|
2914
|
-
});
|
|
2915
|
-
if (!preflight.shouldSearch) return [];
|
|
2916
|
-
const cleaned = preflight.normalizedQuery;
|
|
2917
|
-
this.warmSession(opts?.sessionKey);
|
|
2918
|
-
startAsyncSearchSync({
|
|
2919
|
-
enabled: this.settings.sync.onSearch,
|
|
2920
|
-
dirty: this.dirty,
|
|
2921
|
-
sessionsDirty: this.sessionsDirty,
|
|
2922
|
-
sync: async (params) => await this.sync(params),
|
|
2923
|
-
onError: (err) => {
|
|
2924
|
-
log.warn(`memory sync failed (search): ${String(err)}`);
|
|
2925
|
-
}
|
|
2926
|
-
});
|
|
2927
|
-
if (preflight.shouldInitializeProvider) await this.ensureProviderInitialized();
|
|
2928
|
-
const minScore = opts?.minScore ?? this.settings.query.minScore;
|
|
2929
|
-
const maxResults = opts?.maxResults ?? this.settings.query.maxResults;
|
|
2930
|
-
const hybrid = this.settings.query.hybrid;
|
|
2931
|
-
const candidates = Math.min(200, Math.max(1, Math.floor(maxResults * hybrid.candidateMultiplier)));
|
|
2932
|
-
if (!this.provider) {
|
|
2933
|
-
if (!this.fts.enabled || !this.fts.available) {
|
|
2934
|
-
log.warn("memory search: no provider and FTS unavailable");
|
|
2935
|
-
return [];
|
|
2936
|
-
}
|
|
2937
|
-
const fullQueryResults = await this.searchKeyword(cleaned, candidates, { boostFallbackRanking: true }).catch(() => []);
|
|
2938
|
-
const resultSets = fullQueryResults.length > 0 ? [fullQueryResults] : await Promise.all((() => {
|
|
2939
|
-
const keywords = extractKeywords(cleaned, { ftsTokenizer: this.settings.store.fts.tokenizer });
|
|
2940
|
-
return (keywords.length > 0 ? keywords : [cleaned]).map((term) => this.searchKeyword(term, candidates, { boostFallbackRanking: true }).catch(() => []));
|
|
2941
|
-
})());
|
|
2942
|
-
const seenIds = /* @__PURE__ */ new Map();
|
|
2943
|
-
for (const results of resultSets) for (const result of results) {
|
|
2944
|
-
const existing = seenIds.get(result.id);
|
|
2945
|
-
if (!existing || result.score > existing.score) seenIds.set(result.id, result);
|
|
2946
|
-
}
|
|
2947
|
-
const sorted = (await applyTemporalDecayToHybridResults({
|
|
2948
|
-
results: [...seenIds.values()],
|
|
2949
|
-
temporalDecay: hybrid.temporalDecay,
|
|
2950
|
-
workspaceDir: this.workspaceDir
|
|
2951
|
-
})).toSorted((a, b) => b.score - a.score);
|
|
2952
|
-
const ftsResults = this.selectScoredResults(sorted, maxResults, minScore, 0);
|
|
2953
|
-
return await this.applyVerification(ftsResults);
|
|
2954
|
-
}
|
|
2955
|
-
const keywordResults = hybrid.enabled && this.fts.enabled && this.fts.available ? await this.searchKeyword(cleaned, candidates).catch(() => []) : [];
|
|
2956
|
-
const queryVec = await this.embedQueryWithTimeout(cleaned);
|
|
2957
|
-
const vectorResults = queryVec.some((v) => v !== 0) ? await this.searchVector(queryVec, candidates).catch(() => []) : [];
|
|
2958
|
-
if (!hybrid.enabled || !this.fts.enabled || !this.fts.available) {
|
|
2959
|
-
const vecResults = vectorResults.filter((entry) => entry.score >= minScore).slice(0, maxResults);
|
|
2960
|
-
return await this.applyVerification(vecResults);
|
|
2961
|
-
}
|
|
2962
|
-
const merged = await this.mergeHybridResults({
|
|
2963
|
-
vector: vectorResults,
|
|
2964
|
-
keyword: keywordResults,
|
|
2965
|
-
vectorWeight: hybrid.vectorWeight,
|
|
2966
|
-
textWeight: hybrid.textWeight,
|
|
2967
|
-
mmr: hybrid.mmr,
|
|
2968
|
-
temporalDecay: hybrid.temporalDecay
|
|
2969
|
-
});
|
|
2970
|
-
const strict = merged.filter((entry) => entry.score >= minScore);
|
|
2971
|
-
if (strict.length > 0 || keywordResults.length === 0) {
|
|
2972
|
-
const strictResults = strict.slice(0, maxResults);
|
|
2973
|
-
return await this.applyVerification(strictResults);
|
|
2974
|
-
}
|
|
2975
|
-
const relaxedMinScore = Math.min(minScore, hybrid.textWeight);
|
|
2976
|
-
const keywordKeys = new Set(keywordResults.map((entry) => `${entry.source}:${entry.path}:${entry.startLine}:${entry.endLine}`));
|
|
2977
|
-
const hybridResults = this.selectScoredResults(merged.filter((entry) => keywordKeys.has(`${entry.source}:${entry.path}:${entry.startLine}:${entry.endLine}`)), maxResults, minScore, relaxedMinScore);
|
|
2978
|
-
return await this.applyVerification(hybridResults);
|
|
2979
|
-
}
|
|
2980
|
-
selectScoredResults(results, maxResults, minScore, relaxedMinScore = minScore) {
|
|
2981
|
-
const strict = results.filter((entry) => entry.score >= minScore);
|
|
2982
|
-
if (strict.length > 0) return strict.slice(0, maxResults);
|
|
2983
|
-
return results.filter((entry) => entry.score >= relaxedMinScore).slice(0, maxResults);
|
|
2984
|
-
}
|
|
2985
|
-
async applyVerification(results) {
|
|
2986
|
-
const verifyConfig = this.settings.query.verify;
|
|
2987
|
-
if (!verifyConfig?.enabled) return results;
|
|
2988
|
-
return (await verifySearchResults(results, { readFile: async (relPath) => {
|
|
2989
|
-
try {
|
|
2990
|
-
const fullPath = path.join(this.workspaceDir, relPath);
|
|
2991
|
-
return await fs$1.readFile(fullPath, "utf-8");
|
|
2992
|
-
} catch {
|
|
2993
|
-
return null;
|
|
2994
|
-
}
|
|
2995
|
-
} }, verifyConfig)).filter((r) => r.verified).map((r) => ({
|
|
2996
|
-
path: r.path,
|
|
2997
|
-
startLine: r.actualStartLine ?? r.startLine,
|
|
2998
|
-
endLine: r.actualEndLine ?? r.endLine,
|
|
2999
|
-
score: r.score,
|
|
3000
|
-
snippet: r.snippet,
|
|
3001
|
-
source: r.source,
|
|
3002
|
-
citation: r.citation
|
|
3003
|
-
}));
|
|
3004
|
-
}
|
|
3005
|
-
hasIndexedContent() {
|
|
3006
|
-
if (this.db.prepare(`SELECT 1 as found FROM chunks LIMIT 1`).get()?.found === 1) return true;
|
|
3007
|
-
if (!this.fts.enabled || !this.fts.available) return false;
|
|
3008
|
-
return this.db.prepare(`SELECT 1 as found FROM ${FTS_TABLE} LIMIT 1`).get()?.found === 1;
|
|
3009
|
-
}
|
|
3010
|
-
async searchVector(queryVec, limit) {
|
|
3011
|
-
if (!this.provider) return [];
|
|
3012
|
-
return (await searchVector({
|
|
3013
|
-
db: this.db,
|
|
3014
|
-
vectorTable: VECTOR_TABLE,
|
|
3015
|
-
providerModel: this.provider.model,
|
|
3016
|
-
queryVec,
|
|
3017
|
-
limit,
|
|
3018
|
-
snippetMaxChars: SNIPPET_MAX_CHARS,
|
|
3019
|
-
ensureVectorReady: async (dimensions) => await this.ensureVectorReady(dimensions),
|
|
3020
|
-
sourceFilterVec: this.buildSourceFilter("c"),
|
|
3021
|
-
sourceFilterChunks: this.buildSourceFilter()
|
|
3022
|
-
})).map((entry) => entry);
|
|
3023
|
-
}
|
|
3024
|
-
buildFtsQuery(raw) {
|
|
3025
|
-
return buildFtsQuery(raw);
|
|
3026
|
-
}
|
|
3027
|
-
async searchKeyword(query, limit, options) {
|
|
3028
|
-
if (!this.fts.enabled || !this.fts.available) return [];
|
|
3029
|
-
const sourceFilter = this.buildSourceFilter();
|
|
3030
|
-
const providerModel = this.provider?.model;
|
|
3031
|
-
return (await searchKeyword({
|
|
3032
|
-
db: this.db,
|
|
3033
|
-
ftsTable: FTS_TABLE,
|
|
3034
|
-
providerModel,
|
|
3035
|
-
query,
|
|
3036
|
-
ftsTokenizer: this.settings.store.fts.tokenizer,
|
|
3037
|
-
limit,
|
|
3038
|
-
snippetMaxChars: SNIPPET_MAX_CHARS,
|
|
3039
|
-
sourceFilter,
|
|
3040
|
-
buildFtsQuery: (raw) => this.buildFtsQuery(raw),
|
|
3041
|
-
bm25RankToScore,
|
|
3042
|
-
boostFallbackRanking: options?.boostFallbackRanking
|
|
3043
|
-
})).map((entry) => entry);
|
|
3044
|
-
}
|
|
3045
|
-
mergeHybridResults(params) {
|
|
3046
|
-
return mergeHybridResults({
|
|
3047
|
-
vector: params.vector.map((r) => ({
|
|
3048
|
-
id: r.id,
|
|
3049
|
-
path: r.path,
|
|
3050
|
-
startLine: r.startLine,
|
|
3051
|
-
endLine: r.endLine,
|
|
3052
|
-
source: r.source,
|
|
3053
|
-
snippet: r.snippet,
|
|
3054
|
-
vectorScore: r.score
|
|
3055
|
-
})),
|
|
3056
|
-
keyword: params.keyword.map((r) => ({
|
|
3057
|
-
id: r.id,
|
|
3058
|
-
path: r.path,
|
|
3059
|
-
startLine: r.startLine,
|
|
3060
|
-
endLine: r.endLine,
|
|
3061
|
-
source: r.source,
|
|
3062
|
-
snippet: r.snippet,
|
|
3063
|
-
textScore: r.textScore
|
|
3064
|
-
})),
|
|
3065
|
-
vectorWeight: params.vectorWeight,
|
|
3066
|
-
textWeight: params.textWeight,
|
|
3067
|
-
mmr: params.mmr,
|
|
3068
|
-
temporalDecay: params.temporalDecay,
|
|
3069
|
-
workspaceDir: this.workspaceDir
|
|
3070
|
-
}).then((entries) => entries.map((entry) => entry));
|
|
3071
|
-
}
|
|
3072
|
-
async sync(params) {
|
|
3073
|
-
if (this.closed) return;
|
|
3074
|
-
await this.ensureProviderInitialized();
|
|
3075
|
-
if (this.syncing) {
|
|
3076
|
-
if (params?.sessionFiles?.some((sessionFile) => sessionFile.trim().length > 0)) return this.enqueueTargetedSessionSync(params.sessionFiles);
|
|
3077
|
-
return this.syncing;
|
|
3078
|
-
}
|
|
3079
|
-
this.syncing = this.runSyncWithReadonlyRecovery(params).finally(() => {
|
|
3080
|
-
this.syncing = null;
|
|
3081
|
-
});
|
|
3082
|
-
return this.syncing ?? Promise.resolve();
|
|
3083
|
-
}
|
|
3084
|
-
enqueueTargetedSessionSync(sessionFiles) {
|
|
3085
|
-
return enqueueMemoryTargetedSessionSync({
|
|
3086
|
-
isClosed: () => this.closed,
|
|
3087
|
-
getSyncing: () => this.syncing,
|
|
3088
|
-
getQueuedSessionFiles: () => this.queuedSessionFiles,
|
|
3089
|
-
getQueuedSessionSync: () => this.queuedSessionSync,
|
|
3090
|
-
setQueuedSessionSync: (value) => {
|
|
3091
|
-
this.queuedSessionSync = value;
|
|
3092
|
-
},
|
|
3093
|
-
sync: async (params) => await this.sync(params)
|
|
3094
|
-
}, sessionFiles);
|
|
3095
|
-
}
|
|
3096
|
-
isReadonlyDbError(err) {
|
|
3097
|
-
return isMemoryReadonlyDbError(err);
|
|
3098
|
-
}
|
|
3099
|
-
extractErrorReason(err) {
|
|
3100
|
-
return extractMemoryErrorReason(err);
|
|
3101
|
-
}
|
|
3102
|
-
async runSyncWithReadonlyRecovery(params) {
|
|
3103
|
-
const getClosed = () => this.closed;
|
|
3104
|
-
const getDb = () => this.db;
|
|
3105
|
-
const setDb = (value) => {
|
|
3106
|
-
this.db = value;
|
|
3107
|
-
};
|
|
3108
|
-
const getVectorReady = () => this.vectorReady;
|
|
3109
|
-
const setVectorReady = (value) => {
|
|
3110
|
-
this.vectorReady = value;
|
|
3111
|
-
};
|
|
3112
|
-
const getReadonlyRecoveryAttempts = () => this.readonlyRecoveryAttempts;
|
|
3113
|
-
const setReadonlyRecoveryAttempts = (value) => {
|
|
3114
|
-
this.readonlyRecoveryAttempts = value;
|
|
3115
|
-
};
|
|
3116
|
-
const getReadonlyRecoverySuccesses = () => this.readonlyRecoverySuccesses;
|
|
3117
|
-
const setReadonlyRecoverySuccesses = (value) => {
|
|
3118
|
-
this.readonlyRecoverySuccesses = value;
|
|
3119
|
-
};
|
|
3120
|
-
const getReadonlyRecoveryFailures = () => this.readonlyRecoveryFailures;
|
|
3121
|
-
const setReadonlyRecoveryFailures = (value) => {
|
|
3122
|
-
this.readonlyRecoveryFailures = value;
|
|
3123
|
-
};
|
|
3124
|
-
const getReadonlyRecoveryLastError = () => this.readonlyRecoveryLastError;
|
|
3125
|
-
const setReadonlyRecoveryLastError = (value) => {
|
|
3126
|
-
this.readonlyRecoveryLastError = value;
|
|
3127
|
-
};
|
|
3128
|
-
await runMemorySyncWithReadonlyRecovery({
|
|
3129
|
-
get closed() {
|
|
3130
|
-
return getClosed();
|
|
3131
|
-
},
|
|
3132
|
-
get db() {
|
|
3133
|
-
return getDb();
|
|
3134
|
-
},
|
|
3135
|
-
set db(value) {
|
|
3136
|
-
setDb(value);
|
|
3137
|
-
},
|
|
3138
|
-
get vectorReady() {
|
|
3139
|
-
return getVectorReady();
|
|
3140
|
-
},
|
|
3141
|
-
set vectorReady(value) {
|
|
3142
|
-
setVectorReady(value);
|
|
3143
|
-
},
|
|
3144
|
-
vector: this.vector,
|
|
3145
|
-
get readonlyRecoveryAttempts() {
|
|
3146
|
-
return getReadonlyRecoveryAttempts();
|
|
3147
|
-
},
|
|
3148
|
-
set readonlyRecoveryAttempts(value) {
|
|
3149
|
-
setReadonlyRecoveryAttempts(value);
|
|
3150
|
-
},
|
|
3151
|
-
get readonlyRecoverySuccesses() {
|
|
3152
|
-
return getReadonlyRecoverySuccesses();
|
|
3153
|
-
},
|
|
3154
|
-
set readonlyRecoverySuccesses(value) {
|
|
3155
|
-
setReadonlyRecoverySuccesses(value);
|
|
3156
|
-
},
|
|
3157
|
-
get readonlyRecoveryFailures() {
|
|
3158
|
-
return getReadonlyRecoveryFailures();
|
|
3159
|
-
},
|
|
3160
|
-
set readonlyRecoveryFailures(value) {
|
|
3161
|
-
setReadonlyRecoveryFailures(value);
|
|
3162
|
-
},
|
|
3163
|
-
get readonlyRecoveryLastError() {
|
|
3164
|
-
return getReadonlyRecoveryLastError();
|
|
3165
|
-
},
|
|
3166
|
-
set readonlyRecoveryLastError(value) {
|
|
3167
|
-
setReadonlyRecoveryLastError(value);
|
|
3168
|
-
},
|
|
3169
|
-
runSync: (nextParams) => this.runSync(nextParams),
|
|
3170
|
-
openDatabase: () => this.openDatabase(),
|
|
3171
|
-
ensureSchema: () => this.ensureSchema(),
|
|
3172
|
-
readMeta: () => this.readMeta() ?? void 0
|
|
3173
|
-
}, params);
|
|
3174
|
-
}
|
|
3175
|
-
async readFile(params) {
|
|
3176
|
-
return await readMemoryFile({
|
|
3177
|
-
workspaceDir: this.workspaceDir,
|
|
3178
|
-
extraPaths: this.settings.extraPaths,
|
|
3179
|
-
relPath: params.relPath,
|
|
3180
|
-
from: params.from,
|
|
3181
|
-
lines: params.lines
|
|
3182
|
-
});
|
|
3183
|
-
}
|
|
3184
|
-
status() {
|
|
3185
|
-
const sourceFilter = this.buildSourceFilter();
|
|
3186
|
-
const aggregateState = collectMemoryStatusAggregate({
|
|
3187
|
-
db: { prepare: (sql) => ({ all: (...args) => this.db.prepare(sql).all(...args) }) },
|
|
3188
|
-
sources: this.sources,
|
|
3189
|
-
sourceFilterSql: sourceFilter.sql,
|
|
3190
|
-
sourceFilterParams: sourceFilter.params
|
|
3191
|
-
});
|
|
3192
|
-
const providerInfo = resolveStatusProviderInfo({
|
|
3193
|
-
provider: this.provider,
|
|
3194
|
-
providerInitialized: this.providerInitialized,
|
|
3195
|
-
requestedProvider: this.requestedProvider,
|
|
3196
|
-
configuredModel: this.settings.model || void 0
|
|
3197
|
-
});
|
|
3198
|
-
return {
|
|
3199
|
-
backend: "builtin",
|
|
3200
|
-
files: aggregateState.files,
|
|
3201
|
-
chunks: aggregateState.chunks,
|
|
3202
|
-
dirty: this.dirty || this.sessionsDirty,
|
|
3203
|
-
workspaceDir: this.workspaceDir,
|
|
3204
|
-
dbPath: this.settings.store.path,
|
|
3205
|
-
provider: providerInfo.provider,
|
|
3206
|
-
model: providerInfo.model,
|
|
3207
|
-
requestedProvider: this.requestedProvider,
|
|
3208
|
-
sources: Array.from(this.sources),
|
|
3209
|
-
extraPaths: this.settings.extraPaths,
|
|
3210
|
-
sourceCounts: aggregateState.sourceCounts,
|
|
3211
|
-
cache: this.cache.enabled ? {
|
|
3212
|
-
enabled: true,
|
|
3213
|
-
entries: this.db.prepare(`SELECT COUNT(*) as c FROM ${EMBEDDING_CACHE_TABLE}`).get()?.c ?? 0,
|
|
3214
|
-
maxEntries: this.cache.maxEntries
|
|
3215
|
-
} : {
|
|
3216
|
-
enabled: false,
|
|
3217
|
-
maxEntries: this.cache.maxEntries
|
|
3218
|
-
},
|
|
3219
|
-
fts: {
|
|
3220
|
-
enabled: this.fts.enabled,
|
|
3221
|
-
available: this.fts.available,
|
|
3222
|
-
error: this.fts.loadError
|
|
3223
|
-
},
|
|
3224
|
-
fallback: this.fallbackReason ? {
|
|
3225
|
-
from: this.fallbackFrom ?? "local",
|
|
3226
|
-
reason: this.fallbackReason
|
|
3227
|
-
} : void 0,
|
|
3228
|
-
vector: {
|
|
3229
|
-
enabled: this.vector.enabled,
|
|
3230
|
-
available: this.vector.available ?? void 0,
|
|
3231
|
-
extensionPath: this.vector.extensionPath,
|
|
3232
|
-
loadError: this.vector.loadError,
|
|
3233
|
-
dims: this.vector.dims
|
|
3234
|
-
},
|
|
3235
|
-
batch: {
|
|
3236
|
-
enabled: this.batch.enabled,
|
|
3237
|
-
failures: this.batchFailureCount,
|
|
3238
|
-
limit: 2,
|
|
3239
|
-
wait: this.batch.wait,
|
|
3240
|
-
concurrency: this.batch.concurrency,
|
|
3241
|
-
pollIntervalMs: this.batch.pollIntervalMs,
|
|
3242
|
-
timeoutMs: this.batch.timeoutMs,
|
|
3243
|
-
lastError: this.batchFailureLastError,
|
|
3244
|
-
lastProvider: this.batchFailureLastProvider
|
|
3245
|
-
},
|
|
3246
|
-
custom: {
|
|
3247
|
-
searchMode: providerInfo.searchMode,
|
|
3248
|
-
providerUnavailableReason: this.providerUnavailableReason,
|
|
3249
|
-
readonlyRecovery: {
|
|
3250
|
-
attempts: this.readonlyRecoveryAttempts,
|
|
3251
|
-
successes: this.readonlyRecoverySuccesses,
|
|
3252
|
-
failures: this.readonlyRecoveryFailures,
|
|
3253
|
-
lastError: this.readonlyRecoveryLastError
|
|
3254
|
-
}
|
|
3255
|
-
}
|
|
3256
|
-
};
|
|
3257
|
-
}
|
|
3258
|
-
async probeVectorAvailability() {
|
|
3259
|
-
if (!this.vector.enabled) return false;
|
|
3260
|
-
await this.ensureProviderInitialized();
|
|
3261
|
-
if (!this.provider) return false;
|
|
3262
|
-
return this.ensureVectorReady();
|
|
3263
|
-
}
|
|
3264
|
-
async probeEmbeddingAvailability() {
|
|
3265
|
-
await this.ensureProviderInitialized();
|
|
3266
|
-
if (!this.provider) return {
|
|
3267
|
-
ok: false,
|
|
3268
|
-
error: this.providerUnavailableReason ?? "No embedding provider available (FTS-only mode)"
|
|
3269
|
-
};
|
|
3270
|
-
try {
|
|
3271
|
-
await this.embedBatchWithRetry(["ping"]);
|
|
3272
|
-
return { ok: true };
|
|
3273
|
-
} catch (err) {
|
|
3274
|
-
return {
|
|
3275
|
-
ok: false,
|
|
3276
|
-
error: formatErrorMessage(err)
|
|
3277
|
-
};
|
|
3278
|
-
}
|
|
3279
|
-
}
|
|
3280
|
-
async close() {
|
|
3281
|
-
if (this.closed) return;
|
|
3282
|
-
this.closed = true;
|
|
3283
|
-
const pendingSync = this.syncing;
|
|
3284
|
-
const pendingProviderInit = this.providerInitPromise;
|
|
3285
|
-
if (this.watchTimer) {
|
|
3286
|
-
clearTimeout(this.watchTimer);
|
|
3287
|
-
this.watchTimer = null;
|
|
3288
|
-
}
|
|
3289
|
-
if (this.sessionWatchTimer) {
|
|
3290
|
-
clearTimeout(this.sessionWatchTimer);
|
|
3291
|
-
this.sessionWatchTimer = null;
|
|
3292
|
-
}
|
|
3293
|
-
if (this.intervalTimer) {
|
|
3294
|
-
clearInterval(this.intervalTimer);
|
|
3295
|
-
this.intervalTimer = null;
|
|
3296
|
-
}
|
|
3297
|
-
if (this.watcher) {
|
|
3298
|
-
await this.watcher.close();
|
|
3299
|
-
this.watcher = null;
|
|
3300
|
-
}
|
|
3301
|
-
if (this.sessionUnsubscribe) {
|
|
3302
|
-
this.sessionUnsubscribe();
|
|
3303
|
-
this.sessionUnsubscribe = null;
|
|
3304
|
-
}
|
|
3305
|
-
await awaitPendingManagerWork({
|
|
3306
|
-
pendingSync,
|
|
3307
|
-
pendingProviderInit
|
|
3308
|
-
});
|
|
3309
|
-
this.db.close();
|
|
3310
|
-
INDEX_CACHE.delete(this.cacheKey);
|
|
3311
|
-
}
|
|
3312
|
-
};
|
|
3313
|
-
//#endregion
|
|
3314
|
-
export { listBuiltinAutoSelectMemoryEmbeddingProviderDoctorMetadata as a, getBuiltinMemoryEmbeddingProviderDoctorMetadata as i, closeAllMemoryIndexManagers as n, registerBuiltInMemoryEmbeddingProviders as o, createEmbeddingProvider as r, MemoryIndexManager as t };
|