@mastra/core 1.86.0-alpha.8 → 1.86.0-alpha.9
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/dist/_types/@internal_core@0.1.4/dist/knowledge-compat/index.d.ts +363 -0
- package/dist/a2a/index.cjs +1 -1
- package/dist/a2a/index.js +1 -1
- package/dist/agent/agent.d.ts +12 -0
- package/dist/agent/durable/index.cjs +1 -13
- package/dist/agent/durable/index.js +1 -13
- package/dist/agent/durable/preparation.d.ts +2 -0
- package/dist/agent/durable/utils/resolve-runtime.d.ts +9 -0
- package/dist/agent/durable/workflows/durable-loop-builder.d.ts +4 -0
- package/dist/agent/durable/workflows/finalize-run.d.ts +3 -1
- package/dist/agent/durable/workflows/steps/llm-execution.d.ts +1 -0
- package/dist/agent/index.cjs +3 -3
- package/dist/agent/index.js +3 -3
- package/dist/agent/message-list/index.cjs +1 -1
- package/dist/agent/message-list/index.js +1 -1
- package/dist/agent/message-list/message-list.d.ts +11 -0
- package/dist/agent/message-list/utils/provider-compat.d.ts +1 -0
- package/dist/agent/request-context-snapshot.d.ts +1 -1
- package/dist/agent/streams/types.d.ts +10 -0
- package/dist/agent/thread-stream-runtime.d.ts +5 -0
- package/dist/agent-builder/ee/index.cjs +1 -1
- package/dist/agent-builder/ee/index.js +1 -1
- package/dist/agent-controller/index.cjs +1 -1
- package/dist/agent-controller/index.js +1 -1
- package/dist/{agent-controller-DEPayioq.cjs → agent-controller-CrQ9OF80.cjs} +7 -7
- package/dist/{agent-controller-B7POPub5.js → agent-controller-SSlKzE6A.js} +7 -7
- package/dist/background-tasks/index.cjs +1 -1
- package/dist/background-tasks/index.js +1 -1
- package/dist/{background-tasks-7iftnRK_.cjs → background-tasks-BDrYBis-.cjs} +5 -3
- package/dist/{background-tasks-Cv1ecD6S.js → background-tasks-BnJfNLFo.js} +5 -3
- package/dist/browser/index.cjs +2 -2
- package/dist/browser/index.js +2 -2
- package/dist/{builder-Gg-xnX_E.js → builder-Cl-0BWkh.js} +2 -2
- package/dist/{builder-DuJBbQDH.cjs → builder-Cw8u3pPl.cjs} +2 -2
- package/dist/capabilities/302ai.json +204 -204
- package/dist/capabilities/abliteratedllm.json +30 -30
- package/dist/capabilities/above.json +21 -21
- package/dist/capabilities/adaption.json +15 -15
- package/dist/capabilities/adzuki.json +24 -24
- package/dist/capabilities/agentrouter.json +9 -9
- package/dist/capabilities/agnes.json +3 -3
- package/dist/capabilities/ai-router.json +8 -8
- package/dist/capabilities/aiand.json +31 -23
- package/dist/capabilities/aigrow.json +14 -14
- package/dist/capabilities/aimlapi.json +144 -147
- package/dist/capabilities/aipg.json +2 -2
- package/dist/capabilities/aixy.json +21 -21
- package/dist/capabilities/aki-io.json +10 -10
- package/dist/capabilities/alibaba-cn.json +136 -117
- package/dist/capabilities/alibaba-coding-plan-cn.json +7 -19
- package/dist/capabilities/alibaba-coding-plan.json +7 -19
- package/dist/capabilities/alibaba-token-plan-cn.json +49 -67
- package/dist/capabilities/alibaba-token-plan.json +50 -68
- package/dist/capabilities/alibaba.json +72 -119
- package/dist/capabilities/ambient.json +8 -8
- package/dist/capabilities/amd.json +10 -10
- package/dist/capabilities/anthropic.json +47 -47
- package/dist/capabilities/anyapi.json +19 -19
- package/dist/capabilities/apiko.json +5 -5
- package/dist/capabilities/arcee.json +11 -11
- package/dist/capabilities/augure.json +2 -2
- package/dist/capabilities/auriko.json +23 -23
- package/dist/capabilities/bailing.json +4 -4
- package/dist/capabilities/baseten.json +55 -25
- package/dist/capabilities/bee.json +4 -4
- package/dist/capabilities/berget.json +5 -5
- package/dist/capabilities/bothub.json +17 -17
- package/dist/capabilities/boundless.json +37 -37
- package/dist/capabilities/bumo.json +41 -41
- package/dist/capabilities/byteplus.json +26 -26
- package/dist/capabilities/cerebras.json +4 -4
- package/dist/capabilities/cheapaimodel.json +3 -3
- package/dist/capabilities/cheapest-token.json +30 -30
- package/dist/capabilities/chutes.json +10 -10
- package/dist/capabilities/cline-pass.json +39 -39
- package/dist/capabilities/cloudcode.json +9 -9
- package/dist/capabilities/cloudferro-sherlock.json +4 -4
- package/dist/capabilities/cloudflare-workers-ai.json +33 -33
- package/dist/capabilities/commandcode.json +139 -139
- package/dist/capabilities/concentrate.json +274 -274
- package/dist/capabilities/cortecs.json +108 -108
- package/dist/capabilities/crossmodel.json +189 -189
- package/dist/capabilities/crusoe.json +10 -10
- package/dist/capabilities/daoxe.json +9 -9
- package/dist/capabilities/databricks.json +315 -59
- package/dist/capabilities/deepinfra.json +90 -155
- package/dist/capabilities/deepseek.json +2 -2
- package/dist/capabilities/digitalocean.json +114 -114
- package/dist/capabilities/dothoosh.json +34 -34
- package/dist/capabilities/doubleword.json +28 -28
- package/dist/capabilities/edenai.json +433 -433
- package/dist/capabilities/empiriolabs.json +176 -176
- package/dist/capabilities/engy.json +17 -17
- package/dist/capabilities/entrim.json +6 -6
- package/dist/capabilities/evroc.json +13 -13
- package/dist/capabilities/ezkielyna.json +12 -12
- package/dist/capabilities/fastrouter.json +88 -88
- package/dist/capabilities/fireworks-ai.json +104 -41
- package/dist/capabilities/freemodel.json +20 -20
- package/dist/capabilities/friendli.json +9 -9
- package/dist/capabilities/frogbot.json +93 -93
- package/dist/capabilities/gisoo.json +19 -19
- package/dist/capabilities/gmicloud.json +21 -21
- package/dist/capabilities/google.json +55 -55
- package/dist/capabilities/graphn.json +11 -11
- package/dist/capabilities/greenpt.json +36 -36
- package/dist/capabilities/groq.json +9 -9
- package/dist/capabilities/helicone.json +83 -83
- package/dist/capabilities/hostinger-router.json +13 -13
- package/dist/capabilities/hpc-ai.json +8 -8
- package/dist/capabilities/huawei-maas.json +17 -17
- package/dist/capabilities/hubris.json +28 -28
- package/dist/capabilities/huggingface.json +200 -53
- package/dist/capabilities/humain.json +2 -2
- package/dist/capabilities/hyper.json +26 -26
- package/dist/capabilities/impossibl.json +127 -127
- package/dist/capabilities/inception.json +2 -2
- package/dist/capabilities/inceptron.json +8 -8
- package/dist/capabilities/inco.json +4 -4
- package/dist/capabilities/infer.json +14 -14
- package/dist/capabilities/inference-coop.json +15 -15
- package/dist/capabilities/inferenceapis.json +22 -22
- package/dist/capabilities/inferris.json +3 -3
- package/dist/capabilities/infersia.json +9 -9
- package/dist/capabilities/inferx.json +3 -3
- package/dist/capabilities/infomaniak.json +4 -4
- package/dist/capabilities/io-net.json +5 -5
- package/dist/capabilities/isoquant.json +4 -4
- package/dist/capabilities/iteracompute.json +51 -51
- package/dist/capabilities/jalapeno.json +12 -12
- package/dist/capabilities/jiekou.json +65 -65
- package/dist/capabilities/joingonka.json +4 -4
- package/dist/capabilities/jzstoken.json +54 -54
- package/dist/capabilities/keln.json +21 -28
- package/dist/capabilities/kenari.json +124 -121
- package/dist/capabilities/kilo.json +635 -636
- package/dist/capabilities/kimi-code-plan-cn.json +6 -6
- package/dist/capabilities/kimi-code-plan-global.json +6 -6
- package/dist/capabilities/kitani.json +4 -4
- package/dist/capabilities/klavo.json +13 -13
- package/dist/capabilities/korouter.json +31 -31
- package/dist/capabilities/kunavo.json +9 -9
- package/dist/capabilities/liquid.json +10 -10
- package/dist/capabilities/llmgateway-providers.json +909 -909
- package/dist/capabilities/llmgateway.json +333 -333
- package/dist/capabilities/llmtr.json +19 -19
- package/dist/capabilities/logits.json +2 -2
- package/dist/capabilities/longcat.json +1 -6
- package/dist/capabilities/lowrouter.json +52 -52
- package/dist/capabilities/lyceum.json +7 -7
- package/dist/capabilities/melious.json +16 -16
- package/dist/capabilities/merge-gateway.json +275 -275
- package/dist/capabilities/meta.json +9 -9
- package/dist/capabilities/minimax-cn-coding-plan.json +6 -6
- package/dist/capabilities/minimax-coding-plan.json +6 -6
- package/dist/capabilities/mistral.json +18 -18
- package/dist/capabilities/mixlayer.json +5 -5
- package/dist/capabilities/modal.json +13 -13
- package/dist/capabilities/model-oracle-ai.json +26 -26
- package/dist/capabilities/modelis.json +24 -24
- package/dist/capabilities/modelscope.json +2 -2
- package/dist/capabilities/modular.json +9 -9
- package/dist/capabilities/moneo.json +14 -14
- package/dist/capabilities/moonshotai-cn.json +6 -6
- package/dist/capabilities/moonshotai.json +6 -6
- package/dist/capabilities/morph.json +13 -13
- package/dist/capabilities/munito-eu.json +6 -6
- package/dist/capabilities/munito.json +10 -10
- package/dist/capabilities/nan.json +24 -24
- package/dist/capabilities/nano-gpt.json +577 -577
- package/dist/capabilities/nearai.json +82 -82
- package/dist/capabilities/nebius.json +29 -29
- package/dist/capabilities/neon.json +134 -134
- package/dist/capabilities/neuralwatt.json +43 -43
- package/dist/capabilities/nokeep.json +4 -4
- package/dist/capabilities/novita-ai.json +135 -135
- package/dist/capabilities/nvidia.json +38 -38
- package/dist/capabilities/oathbreaker.json +2 -2
- package/dist/capabilities/obscurify.json +26 -26
- package/dist/capabilities/oci.json +5 -5
- package/dist/capabilities/ofox.json +338 -338
- package/dist/capabilities/ollama-cloud.json +55 -55
- package/dist/capabilities/openai.json +48 -48
- package/dist/capabilities/opencode-go.json +81 -81
- package/dist/capabilities/openreason.json +5 -5
- package/dist/capabilities/openrouter.json +548 -563
- package/dist/capabilities/opper.json +23 -23
- package/dist/capabilities/orcarouter.json +212 -212
- package/dist/capabilities/outerlabs.json +30 -30
- package/dist/capabilities/ovhcloud.json +8 -8
- package/dist/capabilities/pareto.json +5 -5
- package/dist/capabilities/pendra.json +4 -4
- package/dist/capabilities/perplexity-agent.json +59 -59
- package/dist/capabilities/perplexity.json +2 -2
- package/dist/capabilities/phala.json +27 -27
- package/dist/capabilities/pioneer.json +24 -24
- package/dist/capabilities/poe.json +136 -136
- package/dist/capabilities/powerspring.json +14 -14
- package/dist/capabilities/primalabs.json +7 -7
- package/dist/capabilities/prime.json +108 -108
- package/dist/capabilities/privatemode-ai.json +12 -12
- package/dist/capabilities/proxystacks.json +6 -6
- package/dist/capabilities/qiniu-ai.json +15 -15
- package/dist/capabilities/refuseless.json +9 -9
- package/dist/capabilities/regolo-ai.json +6 -6
- package/dist/capabilities/requesty.json +171 -171
- package/dist/capabilities/ruapi.json +20 -20
- package/dist/capabilities/runcrate.json +16 -16
- package/dist/capabilities/runinfra.json +17 -17
- package/dist/capabilities/sakana.json +6 -6
- package/dist/capabilities/sambanova.json +6 -6
- package/dist/capabilities/sandbase.json +16 -16
- package/dist/capabilities/sarvam.json +12 -12
- package/dist/capabilities/scaleway.json +17 -17
- package/dist/capabilities/scnet-token-plan.json +8 -8
- package/dist/capabilities/scx-ai.json +29 -29
- package/dist/capabilities/sensenova.json +14 -14
- package/dist/capabilities/siliconflow-cn.json +61 -61
- package/dist/capabilities/siliconflow.json +57 -57
- package/dist/capabilities/snowflake-cortex.json +24 -24
- package/dist/capabilities/sokkan.json +10 -10
- package/dist/capabilities/sparrowcodes.json +24 -24
- package/dist/capabilities/standardcompute.json +89 -89
- package/dist/capabilities/steadyrouter.json +38 -38
- package/dist/capabilities/stepfun-ai-step-plan.json +7 -7
- package/dist/capabilities/stepfun-ai.json +16 -9
- package/dist/capabilities/stepfun-step-plan.json +16 -9
- package/dist/capabilities/stepfun.json +16 -9
- package/dist/capabilities/stepping-stone.json +18 -18
- package/dist/capabilities/subconscious.json +2 -2
- package/dist/capabilities/synthetic.json +12 -12
- package/dist/capabilities/synthorai.json +26 -26
- package/dist/capabilities/teamorouter.json +21 -21
- package/dist/capabilities/teapot-router.json +9 -9
- package/dist/capabilities/tencent-coding-plan.json +1 -23
- package/dist/capabilities/tencent-token-plan.json +57 -20
- package/dist/capabilities/tencent-tokenhub.json +182 -7
- package/dist/capabilities/tensorx.json +36 -36
- package/dist/capabilities/the-grid-ai.json +29 -29
- package/dist/capabilities/thinkingmachines.json +73 -56
- package/dist/capabilities/tinfoil.json +9 -9
- package/dist/capabilities/toapis.json +3 -3
- package/dist/capabilities/togetherai.json +61 -90
- package/dist/capabilities/tokengo.json +21 -21
- package/dist/capabilities/tokenify.json +9 -9
- package/dist/capabilities/trustedrouter.json +7 -7
- package/dist/capabilities/trustedtokens.json +14 -14
- package/dist/capabilities/umans-ai-coding-plan.json +13 -13
- package/dist/capabilities/umans-ai.json +10 -10
- package/dist/capabilities/uncensuredai.json +4 -4
- package/dist/capabilities/unrestricted.json +4 -4
- package/dist/capabilities/uplinkswitch.json +19 -19
- package/dist/capabilities/upstage.json +6 -6
- package/dist/capabilities/vancine.json +19 -19
- package/dist/capabilities/vercel.json +558 -537
- package/dist/capabilities/vivgrid.json +78 -78
- package/dist/capabilities/volcengine-coding-plan.json +26 -56
- package/dist/capabilities/volcengine.json +57 -62
- package/dist/capabilities/vultr.json +28 -28
- package/dist/capabilities/wafer.ai.json +18 -18
- package/dist/capabilities/wallaby.json +5 -5
- package/dist/capabilities/wally.json +14 -14
- package/dist/capabilities/wandb.json +20 -20
- package/dist/capabilities/watt.json +22 -22
- package/dist/capabilities/xai.json +4 -4
- package/dist/capabilities/xiaomi-token-plan-ams.json +2 -12
- package/dist/capabilities/xiaomi-token-plan-cn.json +2 -12
- package/dist/capabilities/xiaomi-token-plan-sgp.json +2 -12
- package/dist/capabilities/xiaomi.json +3 -25
- package/dist/capabilities/xpersona.json +11 -11
- package/dist/capabilities/xxapi.json +27 -27
- package/dist/capabilities/zai-coding-plan.json +14 -14
- package/dist/capabilities/zai.json +47 -24
- package/dist/capabilities/zenifra.json +24 -24
- package/dist/capabilities/zenmux.json +185 -185
- package/dist/capabilities/zerogpu.json +12 -12
- package/dist/capabilities/zhipuai-coding-plan.json +8 -8
- package/dist/capabilities/zhipuai.json +35 -20
- package/dist/capabilities/zro.json +7 -7
- package/dist/channels/index.cjs +2 -2
- package/dist/channels/index.js +2 -2
- package/dist/{channels-BRVCOutx.js → channels-Cz1y3W6u.js} +1 -1
- package/dist/{channels-MjTA9bFp.cjs → channels-DQg4v_gm.cjs} +1 -1
- package/dist/coding-agent/index.cjs +2 -2
- package/dist/coding-agent/index.js +2 -2
- package/dist/datasets/index.cjs +2 -2
- package/dist/datasets/index.js +2 -2
- package/dist/docs/SKILL.md +3 -2
- package/dist/docs/assets/SOURCE_MAP.json +895 -870
- package/dist/docs/references/docs-harness-background-tasks.md +4 -1
- package/dist/docs/references/docs-knowledge-importers.md +195 -0
- package/dist/docs/references/docs-knowledge-load-your-content.md +1 -1
- package/dist/docs/references/docs-knowledge-overview.md +1 -1
- package/dist/docs/references/docs-sandbox-filesystem.md +1 -1
- package/dist/docs/references/docs-signals-thread-streams.md +1 -1
- package/dist/docs/references/docs-studio-auth.md +54 -7
- package/dist/docs/references/integrations-auth-clerk.md +48 -4
- package/dist/docs/references/reference-agents-agent.md +1 -1
- package/dist/docs/references/reference-agents-durable-agent.md +10 -4
- package/dist/docs/references/reference-auth-clerk.md +21 -1
- package/dist/docs/references/reference-knowledge-knowledge-class.md +11 -4
- package/dist/docs/references/reference-memory-observational-memory.md +2 -2
- package/dist/docs/references/reference-streaming-ChunkType.md +2 -2
- package/dist/docs/references/reference-workspace-local-sandbox.md +2 -0
- package/dist/error/index.cjs +1 -1
- package/dist/error/index.js +1 -1
- package/dist/{error-C9d_24w-.js → error-BLwEXqOK.js} +2 -2
- package/dist/{error-BRQf2ku0.cjs → error-BdEvO8za.cjs} +2 -2
- package/dist/evals/index.cjs +1 -1
- package/dist/evals/index.js +1 -1
- package/dist/evals/scoreTraces/index.cjs +1 -1
- package/dist/evals/scoreTraces/index.js +1 -1
- package/dist/features/index.cjs +1 -0
- package/dist/features/index.js +1 -0
- package/dist/{filesystem-B5X-5G0x.js → filesystem-B8ad6kAW.js} +1 -1
- package/dist/{filesystem-BDSpwBke.cjs → filesystem-BB5YWXH-.cjs} +1 -1
- package/dist/{filesystem-DzM9pcQ8.js → filesystem-BDHUxbHn.js} +1 -1
- package/dist/{filesystem-B0AZrbj8.cjs → filesystem-BP5yz5LG.cjs} +1 -1
- package/dist/{filesystem-BsdkC311.js → filesystem-B_afSgYk.js} +1 -1
- package/dist/{filesystem-C-cyJfi1.cjs → filesystem-BaOJOc-V.cjs} +1 -1
- package/dist/{filesystem-B3s0WRud.js → filesystem-BhYgU8qg.js} +1 -1
- package/dist/{filesystem-DzfqVTO_.js → filesystem-CLBVmR5j.js} +1 -1
- package/dist/{filesystem-CEbD_77-.cjs → filesystem-Cgxc2a_-.cjs} +1 -1
- package/dist/{filesystem-Cv79mHRk.js → filesystem-ClBOBoDc.js} +1 -1
- package/dist/{filesystem-DsCQiBl2.cjs → filesystem-DVVecqZt.cjs} +1 -1
- package/dist/{filesystem-CUAgLugE.cjs → filesystem-Fpsu7e24.cjs} +1 -1
- package/dist/{filesystem-versioned-Bijb_p9l.js → filesystem-versioned-BL1ojJLo.js} +1 -1
- package/dist/{filesystem-versioned-DZGyPbNC.cjs → filesystem-versioned-BavRtYWJ.cjs} +1 -1
- package/dist/harness/index.cjs +1 -1
- package/dist/harness/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/knowledge/config.d.ts +10 -0
- package/dist/knowledge/host-writes.d.ts +10 -0
- package/dist/knowledge/importers/conformance.d.ts +25 -0
- package/dist/knowledge/importers/define.d.ts +204 -0
- package/dist/knowledge/importers/host.d.ts +143 -0
- package/dist/knowledge/importers/index.d.ts +12 -0
- package/dist/knowledge/importers/local-host.d.ts +106 -0
- package/dist/knowledge/importers/manifest.d.ts +25 -0
- package/dist/knowledge/importers/runner.d.ts +61 -0
- package/dist/knowledge/importers/sink.d.ts +105 -0
- package/dist/knowledge/importers/types.d.ts +144 -0
- package/dist/knowledge/index.cjs +2715 -8
- package/dist/knowledge/index.d.ts +54 -4
- package/dist/knowledge/index.js +2692 -9
- package/dist/knowledge/instructions.d.ts +1 -1
- package/dist/knowledge/links.d.ts +8 -0
- package/dist/knowledge/pinned-state-processor.d.ts +5 -0
- package/dist/knowledge/pinned.d.ts +4 -1
- package/dist/knowledge/scope-runtime.d.ts +10 -0
- package/dist/llm/index.cjs +3 -3
- package/dist/llm/index.js +3 -3
- package/dist/llm/model/provider-types.generated.d.ts +7705 -7727
- package/dist/{llm-DmUucguC.cjs → llm-8Av3mSjD.cjs} +2 -2
- package/dist/{llm-Djd8Qzi0.js → llm-B5A5cwJr.js} +2 -2
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +2 -2
- package/dist/{manager-CO_Xz2zR.js → manager-DfWQCJUK.js} +2 -2
- package/dist/{manager-D27PkIPo.cjs → manager-sv35JY-z.cjs} +2 -2
- package/dist/mastra/index.cjs +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/mastra/resolve-agent.d.ts +3 -1
- package/dist/{mastra-Ch00nEAJ.js → mastra-CigBrT7X.js} +17 -23
- package/dist/{mastra-qsVWpOTi.cjs → mastra-D4hvfuxX.cjs} +19 -25
- package/dist/memory/index.cjs +3 -3
- package/dist/memory/index.js +3 -3
- package/dist/{message-list-DPXPXvin.cjs → message-list-Cj0Sq_JP.cjs} +63 -8
- package/dist/{message-list-DEuRl82K.js → message-list-KRbg-TnI.js} +63 -8
- package/dist/{model-Do6DTJoj.cjs → model-BK93CMtl.cjs} +1 -1
- package/dist/{model-CW-mfGYA.js → model-CYtXw861.js} +1 -1
- package/dist/{netlify-DU32SDT6.cjs → netlify-BAnn3ouY.cjs} +1 -1
- package/dist/{netlify-DZSAbdve.js → netlify-CuI1ZrwR.js} +1 -1
- package/dist/notifications/index.cjs +1 -1
- package/dist/notifications/index.js +1 -1
- package/dist/processor-provider/index.cjs +1 -1
- package/dist/processor-provider/index.js +1 -1
- package/dist/processors/abort-signal-scope.d.ts +6 -0
- package/dist/processors/index.cjs +2 -2
- package/dist/processors/index.js +2 -2
- package/dist/{provider-registry-zGezZVsL.cjs → provider-registry-BwuI_IpT.cjs} +21696 -21828
- package/dist/{provider-registry-deA0x-Gd.js → provider-registry-CmQLzLF_.js} +21696 -21828
- package/dist/provider-registry.json +22300 -22417
- package/dist/{registry-generator-VvBfOKAD.js → registry-generator-C17V4WfG.js} +1 -1
- package/dist/{registry-generator-BkQ1AxZn.cjs → registry-generator-C_0ae7Ce.cjs} +1 -1
- package/dist/{rehydrate-DDYFpQsV.cjs → rehydrate-CDQ4dOYj.cjs} +2 -2
- package/dist/{rehydrate-BjLV643n.js → rehydrate-PnaVawGX.js} +2 -2
- package/dist/relevance/index.cjs +2 -2
- package/dist/relevance/index.js +2 -2
- package/dist/{run-registry-5Suldxz3.cjs → run-registry-BmckDVBk.cjs} +1156 -403
- package/dist/{run-registry-CGRPldLH.js → run-registry-BwEcwYlU.js} +1103 -404
- package/dist/{source-DDwx-87N.cjs → source-BVOi8Xhp.cjs} +1 -1
- package/dist/{source-Did_2XQc.js → source-fNa6u1kH.js} +1 -1
- package/dist/storage/domains/agents/index.cjs +1 -1
- package/dist/storage/domains/agents/index.js +1 -1
- package/dist/storage/domains/knowledge/base.d.ts +67 -0
- package/dist/storage/domains/knowledge/importers-inmemory.d.ts +146 -0
- package/dist/storage/domains/knowledge/importers.d.ts +287 -0
- package/dist/storage/domains/knowledge/index.d.ts +1 -0
- package/dist/storage/domains/knowledge/inmemory.d.ts +11 -0
- package/dist/storage/domains/knowledge/pages-inmemory.d.ts +12 -1
- package/dist/storage/domains/knowledge/pages.d.ts +1 -0
- package/dist/storage/domains/mcp-clients/index.cjs +1 -1
- package/dist/storage/domains/mcp-clients/index.js +1 -1
- package/dist/storage/domains/mcp-servers/index.cjs +1 -1
- package/dist/storage/domains/mcp-servers/index.js +1 -1
- package/dist/storage/domains/prompt-blocks/index.cjs +1 -1
- package/dist/storage/domains/prompt-blocks/index.js +1 -1
- package/dist/storage/domains/scorer-definitions/index.cjs +1 -1
- package/dist/storage/domains/scorer-definitions/index.js +1 -1
- package/dist/storage/domains/skills/index.cjs +1 -1
- package/dist/storage/domains/skills/index.js +1 -1
- package/dist/storage/domains/workspaces/index.cjs +1 -1
- package/dist/storage/domains/workspaces/index.js +1 -1
- package/dist/storage/index.cjs +15 -10
- package/dist/storage/index.js +11 -11
- package/dist/stream/base/output.d.ts +17 -0
- package/dist/stream/index.cjs +2 -2
- package/dist/stream/index.js +2 -2
- package/dist/stream/types.d.ts +5 -2
- package/dist/{stream-Dvy_0o14.cjs → stream-0kdqBOOn.cjs} +64 -9
- package/dist/{stream-Dpwx0whf.js → stream-D1y9GzoD.js} +29 -10
- package/dist/test-utils/llm-mock.cjs +1 -1
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/tool-loop-agent/index.cjs +1 -1
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/{tool-loop-agent-PbWrEj1k.js → tool-loop-agent-BdjWGVIb.js} +4 -4
- package/dist/{tool-loop-agent-UxOv3FoK.cjs → tool-loop-agent-kWaZAT6Q.cjs} +4 -4
- package/dist/{utils-BbMTlyBO.cjs → utils-BKUCaZ12.cjs} +1 -1
- package/dist/{utils-BnNi1BYM.js → utils-GHY3hmLx.js} +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/dist/{validate-HSBcm96b.js → validate-CB-q-R2F.js} +1 -1
- package/dist/{validate-Skps-cM3.cjs → validate-De92squ7.cjs} +1 -1
- package/dist/vector/index.cjs +2 -2
- package/dist/vector/index.js +2 -2
- package/dist/worker/index.cjs +1 -1
- package/dist/worker/index.js +1 -1
- package/dist/{worker-BNS5A3qP.cjs → worker-BbWPQuPR.cjs} +2 -2
- package/dist/{worker-DehaD4qD.js → worker-C3u_xzY2.js} +2 -2
- package/dist/{worker-BE-0DyKL.cjs → worker-CAKvQj9_.cjs} +2 -2
- package/dist/{worker-BKrKHZzU.js → worker-Kwm8EKcj.js} +2 -2
- package/dist/{workflow-BjUTwaK9.cjs → workflow-CSjXeNcR.cjs} +3 -3
- package/dist/{workflow-Bvw6yDjc.js → workflow-CVmI1Sw-.js} +3 -3
- package/dist/workflows/builder/index.cjs +1 -1
- package/dist/workflows/builder/index.js +1 -1
- package/dist/workflows/evented/index.cjs +1 -1
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/index.cjs +4 -4
- package/dist/workflows/index.js +4 -4
- package/dist/workspace/filesystem/filesystem.d.ts +5 -0
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/sandbox/local-sandbox.d.ts +16 -7
- package/dist/workspace/sandbox/native-sandbox/types.d.ts +11 -1
- package/dist/{workspace-C05xDH60.js → workspace-DY2Nxiyi.js} +75 -27
- package/dist/{workspace-D1OzzlLw.cjs → workspace-X2RHJZU9.cjs} +75 -27
- package/package.json +3 -3
- package/src/llm/model/provider-types.generated.d.ts +7705 -7727
|
@@ -3,15 +3,15 @@ import { a as RegisteredLogger, t as ConsoleLogger, u as noopLogger } from "./lo
|
|
|
3
3
|
import { t as MastraBase } from "./base-CKLWBhDo.js";
|
|
4
4
|
import { A as compactStopReasonContext, D as agentLoopTermination, O as executionFailureTermination, S as resolveObservabilityContext, b as wrapMastra, i as subtractReportedUsage, k as tripwireTermination, n as extractUsageMetrics, r as isUsageIncomplete, t as calculateObservedUsage, x as createObservabilityContext, y as unwrapMastraTracingProxy } from "./observability-D7RNOAPx.js";
|
|
5
5
|
import { a as MastraNonRetryableError, i as MastraError, n as ErrorDomain, o as getErrorFromUnknown, t as ErrorCategory } from "./error-oh2DLsP2.js";
|
|
6
|
-
import { c as describeProviderError, i as classifyProviderError, l as readProviderErrorDetails, t as recordTerminalErrorMessage } from "./error-
|
|
7
|
-
import { $ as
|
|
6
|
+
import { c as describeProviderError, i as classifyProviderError, l as readProviderErrorDetails, t as recordTerminalErrorMessage } from "./error-BLwEXqOK.js";
|
|
7
|
+
import { $ as resolveProcessorSpanAttributes, $t as computeModelOutputProviderMetadata, A as OUTPUT_STREAM_HOOK_DURATION_KEY_PREFIX, An as safeError, B as ProviderHistoryCompat, Bt as summarizeStepResult, C as markChunkOutputProcessed, Cn as isMastraTimeoutError, Ct as resolveTemplate, D as asJsonSchema, Dn as MastraModelInput, Dt as getStepResult, E as isStructuredOutputError, Et as validateTemplate, F as findOwnModelStepSpan, Ft as materializeState, G as REPROCESS_PART_KEY, Gt as patchState, Ht as applyStatePatch, It as materializeWorkflowRun, J as summarizeActiveToolsForSpan, Jt as isObservationalMemoryEnabled$1, K as takeHeldParts, L as isTrailingAssistantGuardContinuation, Lt as pickStateKeys, M as ProcessorState, Mn as createRunScopeKey, Mt as applyStateColumnsWrite, N as endOutputStreamSpanAtStepEnd, Nt as isStateCheckpointDue, O as getResponseFormat, On as safeClose, Ot as getStepResultAsync, P as endOutputStreamSpanOutsideStep, Pt as latestStepResults, Q as summarizeToolChoiceForSpan, Qt as commitToolResult, R as needsTrailingAssistantGuard, Rt as stateBaseOf, S as stampChunkProducedAt, Sn as guardStreamWithAbort, T as escapeUnescapedControlCharsInJsonStrings, Tn as settledOrElapsed, Tt as traverseMappingPath, Vt as unusedStateEntries, W as FLUSH_HELD_PARTS_KEY, Wt as diffStateAsJson, X as summarizeProcessorResultForSpan, Xt as parseMemoryRequestContext, Y as summarizeProcessorModelForSpan, Z as summarizeProcessorToolsForSpan, _ as reconcileBufferedStepTexts, _n as DEADLINE_SAVE_WAIT_MS, _t as collectMappingStepRefs, a as convertFullStreamChunkToMastra, an as withAgentWorkflowToolMarker, at as RunJournal, b as resolveProcessorWriterMessageId, bn as getAbortReason, bt as resolveStepOutputs, c as WorkflowRunOutput, cn as isProcessorWorkflow, ct as hydrateStepResults, d as MastraModelOutput, dn as resolveThreadIdFromArgs, dt as loadStepResults, en as hasToolResultProcessor, et as resolveProcessorSpanName, f as clearStepPartIndexes, fn as supportedLanguageModelSpecifications, ft as loadedStepResults, g as persistProcessorDataChunk, gn as DEADLINE_SAVE_CLAIM_HOLD_MS, gt as stubStepResult, h as findStepPartBoundaries, hn as applyStateSignal, ht as storageV2StepResultAccessors, in as snapshotToolResult, it as PROCESSOR_ABORT_SIGNAL, j as ProcessorRunner, jn as createRunScope, k as isSignalChunkExcluded, kn as safeEnqueue, kt as getSnapshotMemoryInfo, l as TripWire, ln as isSupportedLanguageModel, lt as isStepResultStub, m as findIterationOffsetInParts, mn as tryStreamWithJsonFallback, mt as residentStepResultsLoader, nn as readModelOutput, nt as PROCESSOR_LATE_SIGNAL_SINK, on as normalizeModelOutput, ot as buildStepResultAccessors, p as createDestructurableOutput, pn as tryGenerateWithJsonFallback, pt as residentStepResults, q as withoutHeldContent, rn as resolveModelOutputAfterToolResultProcessors, rt as createProcessorSendSignal, s as MastraAgentNetworkStream, sn as validationErrorModelOutput, st as getHydratedStepResult, tn as latestProcessedModelOutput, tt as toProcessorSpanPhase, u as getModelOutputForTripwire, un as resolveSuspendedToolRunId, ut as lazyStepResults, v as resolveMessageText, vn as MastraTimeoutError, vt as collectPredicateStepRefs, w as createOutputHandler, wn as raceAgainstAbort, wt as templateReadsState, x as getChunkProducedAt, xn as guardStreamUntilMatch, xt as stepRefId, y as resolveOutputMessageSkippingCompletionChecks, yn as createTimeoutAbortSignal, yt as predicateReadsState, z as removeTrailingAssistantGuardContinuations, zt as stateColumnsWrite } from "./stream-D1y9GzoD.js";
|
|
8
8
|
import { c as MASTRA_THREAD_ID_KEY, d as isReservedRequestContextKey, f as mergeVersionOverrides$1, l as MASTRA_VERSIONS_KEY, n as MASTRA_AUTH_TOKEN_KEY, o as MASTRA_RESOURCE_ID_KEY, p as withoutLiveRequestKeys, r as MASTRA_INHERITED_MEMORY_KEY, s as MASTRA_SCOPES_KEY, t as MASTRA_CONTINUATION_TOOL_CALL_IDS_KEY, u as RequestContext } from "./request-context-COnZHt2-.js";
|
|
9
9
|
import { c as RUN_LOG_TTL_MS, f as slimNestedAgentChunks, g as NoopLeaseProvider, h as EventEmitterPubSub, m as stripModelSnapshots, n as PublisherQueueLimitError, o as serializeError$1, r as CachingPubSub, t as DefaultStepResult, u as isRunLocalTopic, v as isLeaseProvider, y as withAck } from "./output-helpers-CedRCE17.js";
|
|
10
|
-
import { A as stableStringify$1, E as removeWorkingMemoryTags, P as embed$3, Z as preserveResponseItemIdsOnMerge, a as isTerminalToolInvocationState, c as withUnavailableAttachmentUrls, d as aiV5UIMessagesToAIV5ModelMessages, f as coreContentToString, i as isClientToolInvocationUpdate, l as isDownloadAssetsError, m as filterMessagesForPersistence, n as MessageList, ot as normalizeToolOutput, p as messagesAreEqual, r as advancesToolInvocationState, s as unavailableAttachmentPlaceholder, t as convertMessages, u as MessageMerger } from "./message-list-
|
|
10
|
+
import { A as stableStringify$1, E as removeWorkingMemoryTags, P as embed$3, Z as preserveResponseItemIdsOnMerge, a as isTerminalToolInvocationState, c as withUnavailableAttachmentUrls, d as aiV5UIMessagesToAIV5ModelMessages, f as coreContentToString, i as isClientToolInvocationUpdate, l as isDownloadAssetsError, m as filterMessagesForPersistence, n as MessageList, ot as normalizeToolOutput, p as messagesAreEqual, r as advancesToolInvocationState, s as unavailableAttachmentPlaceholder, t as convertMessages, u as MessageMerger } from "./message-list-KRbg-TnI.js";
|
|
11
11
|
import { Bt as listScoresArgsSchema, Ft as listLogsArgsSchema, Lt as listMetricsArgsSchema, Nt as listFeedbackArgsSchema, t as EntityType } from "./storage-Cc50aQAp.js";
|
|
12
12
|
import { a as getOrCreateSpan, f as resolveCurrentSpan, l as getTimeToFirstChunkMs, n as executeWithContextSync, o as getResumeTracingContext, p as resolveExportedSpanId, s as getRootExportSpan, t as executeWithContext, u as getWorkflowResumeTracingContext } from "./utils-DU_pU5SK.js";
|
|
13
13
|
import { i as setSpanErrorOrigin, n as getSpanErrorOrigin } from "./error-count-BH-rJW7q.js";
|
|
14
|
-
import { a as ModelRouterLanguageModel, d as attachModelStreamTransport, f as isDataChunk, i as resolveModelConfig, n as ModelRouterEmbeddingModel, o as resolveApiProviderId, p as readModelStreamTransport } from "./llm-
|
|
14
|
+
import { a as ModelRouterLanguageModel, d as attachModelStreamTransport, f as isDataChunk, i as resolveModelConfig, n as ModelRouterEmbeddingModel, o as resolveApiProviderId, p as readModelStreamTransport } from "./llm-B5A5cwJr.js";
|
|
15
15
|
import { a as withToolPayloadTransformMetadata, i as transformToolPayloadForTargets, n as hasTransformedToolPayload, o as withToolPayloadTransformProviderMetadata, r as normalizeToolPayloadTransformPolicy, t as getTransformedToolPayload } from "./payload-transform-Dj3HUeD4.js";
|
|
16
16
|
import { boundedStringify, ensureSerializable, safeStringify } from "./utils/safe-stringify.js";
|
|
17
17
|
import { d as signalSpanAttributes, h as signalToXmlMarkup, l as mastraDBMessageToSignal, n as createSignal, o as isMastraSignalMessage, s as isTransientSignalMessage, u as resolveDeliveryAttributes } from "./signals-CqR_iWkg.js";
|
|
@@ -24,13 +24,13 @@ import { _ as getRequestContextInputValues, a as getModelFacingValidationError,
|
|
|
24
24
|
import { a as isApprovalExempt, c as isProviderDefinedTool, d as markAgentWorkflowTool, f as markApprovalExempt, l as isProviderTool, n as getNeedsApprovalFn, o as isBuiltBeforeApproval, r as getProviderToolName, s as isMastraTool, t as getBeforeApprovalFn } from "./toolchecks-DrsZdc3S.js";
|
|
25
25
|
import { a as waitDelay, i as getRetryAfterMs, n as DEFAULT_MAX_RETRY_AFTER_MS, r as clampDelayMs } from "./fetchWithRetry-DFSvpYDT.js";
|
|
26
26
|
import { i as hasFreeFormObject } from "./model-DS-b2R-R.js";
|
|
27
|
-
import { c as modelSupportsStructuredOutput, l as modelSupportsTemperature } from "./provider-registry-
|
|
27
|
+
import { c as modelSupportsStructuredOutput, l as modelSupportsTemperature } from "./provider-registry-CmQLzLF_.js";
|
|
28
28
|
import { t as InMemoryServerCache } from "./inmemory-BDD0w8gx.js";
|
|
29
29
|
import { n as resolveDynamicArgument, t as getRequestUser } from "./dynamic-argument-BzPK3qPN.js";
|
|
30
|
-
import { t as MastraLLMV1 } from "./model-
|
|
31
|
-
import { A as eagerToolCallDidNotExecute, D as EagerToolExecutionCoordinator, E as EAGER_TOOL_EXECUTION_MARKER, F as hasRunningRunStep, I as isRunStepActive, L as setRunLeaseFence, M as isEagerlyExecutableToolCall, N as TOOL_ABORT_NOTICE, O as EagerToolExecutionNotRun, P as clearRunLeaseFence, R as startRunStep, S as selectFields, T as EAGER_TOOL_BAILOUT, a as ensureToolProperties, b as removeUndefinedValues, d as makeCoreTool, i as delay$1, j as eagerToolCallSuspensionIntent, k as eagerToolCallAlreadyAnnouncedInput, n as createMastraProxy, o as generateEmptyFromSchema, p as makeProcessorCoreTool, r as deepMerge$1, v as readPositiveIntEnv, w as EAGER_TOOL_ABORT_SIGNAL, y as rebindProcessorTools, z as whenRunStepsSettle } from "./utils-
|
|
30
|
+
import { t as MastraLLMV1 } from "./model-CYtXw861.js";
|
|
31
|
+
import { A as eagerToolCallDidNotExecute, D as EagerToolExecutionCoordinator, E as EAGER_TOOL_EXECUTION_MARKER, F as hasRunningRunStep, I as isRunStepActive, L as setRunLeaseFence, M as isEagerlyExecutableToolCall, N as TOOL_ABORT_NOTICE, O as EagerToolExecutionNotRun, P as clearRunLeaseFence, R as startRunStep, S as selectFields, T as EAGER_TOOL_BAILOUT, a as ensureToolProperties, b as removeUndefinedValues, d as makeCoreTool, i as delay$1, j as eagerToolCallSuspensionIntent, k as eagerToolCallAlreadyAnnouncedInput, n as createMastraProxy, o as generateEmptyFromSchema, p as makeProcessorCoreTool, r as deepMerge$1, v as readPositiveIntEnv, w as EAGER_TOOL_ABORT_SIGNAL, y as rebindProcessorTools, z as whenRunStepsSettle } from "./utils-GHY3hmLx.js";
|
|
32
32
|
import { h as getWorkflowFGAResourceId, i as MastraFGAPermissions, y as requireFGA } from "./ee-iTj2bRDt-By_B9ngH.js";
|
|
33
|
-
import { a as resolveBackgroundConfig, o as createBackgroundTask, t as generateBackgroundTaskSystemPrompt } from "./background-tasks-
|
|
33
|
+
import { a as resolveBackgroundConfig, o as createBackgroundTask, t as generateBackgroundTaskSystemPrompt } from "./background-tasks-BnJfNLFo.js";
|
|
34
34
|
import { t as ToolStream } from "./stream-D9JOykz7.js";
|
|
35
35
|
import { MISSING, collectInvalidPredicatePaths, createPredicateEvaluator, derivePredicateLabel, normalizePredicatePath, walk } from "./predicate/index.js";
|
|
36
36
|
import { Classifier } from "./classifier/index.js";
|
|
@@ -42,20 +42,20 @@ import { A as writeObjective, D as readObjective, O as resolveEffectiveGoalSetti
|
|
|
42
42
|
import { An as computeTraceStatus, Cr as extractTrajectory, Dr as saveScorePayloadSchema, It as TABLE_SCHEMAS, Lt as TABLE_SCORERS, Nn as extractBranchSpans, Pn as getBranchArgsSchema, Qn as listTracesArgsSchema, Sr as withBufferedReflectionVerified, Tr as extractWorkflowTrajectory, Yn as listBranchesArgsSchema, _r as isAppendOnlySince, ar as spanRecordSchema, br as maxObservationCursor, cr as toTraceSpans, gn as BRANCH_SPAN_TYPE_SET, gr as compareObservationalMemoryHeadOrder, hr as assertActiveObservationsApplied, or as toLightSpanRecord, pn as matchesExpectedWorkflowStatus, qn as isPreviewTruncated, sr as toTraceSpan, vn as TraceStatus, vr as isBufferedChunkCoveredByCursor, wr as extractTrajectoryFromTrace, xr as planReflectionGenerationText, yr as isBufferedReflectionUnchangedSince } from "./constants-BmdTvEYN.js";
|
|
43
43
|
import { t as GoalSignalProvider } from "./signal-provider-BslnAjWG.js";
|
|
44
44
|
import { t as slugify } from "./slugify-BUNmb-Ga.js";
|
|
45
|
-
import { N as LocalSandbox, at as LocalFilesystem, dt as sliceByTokensSafe, ft as estimateTokenCount, it as normalizeReadTrackerPath, lt as WORKSPACE_TOOLS, m as resolveToolConfig, mt as shellQuote, o as Workspace, p as createWorkspaceTools, pt as sliceByTokens, rt as evaluateReadRecord, s as createSkillTools, st as CompositeFilesystem } from "./workspace-
|
|
45
|
+
import { N as LocalSandbox, at as LocalFilesystem, dt as sliceByTokensSafe, ft as estimateTokenCount, it as normalizeReadTrackerPath, lt as WORKSPACE_TOOLS, m as resolveToolConfig, mt as shellQuote, o as Workspace, p as createWorkspaceTools, pt as sliceByTokens, rt as evaluateReadRecord, s as createSkillTools, st as CompositeFilesystem } from "./workspace-DY2Nxiyi.js";
|
|
46
46
|
import { i as normalizeWebSearchProvider, n as createWebSearchProviderTool, r as isWebSearchTool } from "./tools-CDfyMpzN.js";
|
|
47
47
|
import { D as BM25Index, O as tokenize } from "./workspace-skills-38OY32_b.js";
|
|
48
|
-
import { f as calculatePagination, g as InMemoryThreadStateStorage, h as resolveListOrderBy, m as normalizePerPage, p as compareByField, s as StorageDomain, u as MastraCompositeStore } from "./filesystem-versioned-
|
|
48
|
+
import { f as calculatePagination, g as InMemoryThreadStateStorage, h as resolveListOrderBy, m as normalizePerPage, p as compareByField, s as StorageDomain, u as MastraCompositeStore } from "./filesystem-versioned-BL1ojJLo.js";
|
|
49
49
|
import { coreFeatures } from "./features/index.js";
|
|
50
50
|
import { $n as traceQueryTimeRangeSchema, Dn as planThreadPredicate, En as planSpanQuerySelectionPredicate, Jt as TRACE_QUERY_ORDER_FIELDS, On as planThreadQuerySelectionPredicate, Qn as traceQuerySortValueSchema, Tn as planPredicate, Yt as TRACE_QUERY_PREDICATE_COMPLEXITY_MESSAGE, Zn as traceQueryScalarPredicateSchema, an as compareTraceQueryStrings, cn as formatTraceQuerySchemaIssues, en as TraceQueryCursorError, gn as isTraceQuerySortValueFor, in as TraceQueryValidationError, mn as hasTraceQueryTokenPredicate, sn as findPredicateComplexityIssue, yn as normalizeTraceQueryTenantScope } from "./dashboard-C3Cm0dWp.js";
|
|
51
|
-
import { i as InMemoryAgentsStorage, n as FilesystemAgentsStorage, r as InMemoryDB } from "./source-
|
|
51
|
+
import { i as InMemoryAgentsStorage, n as FilesystemAgentsStorage, r as InMemoryDB } from "./source-fNa6u1kH.js";
|
|
52
52
|
import { t as InMemoryFavoritesStorage } from "./inmemory-C4cocobU.js";
|
|
53
|
-
import { n as InMemoryMCPClientsStorage, t as FilesystemMCPClientsStorage } from "./filesystem-
|
|
54
|
-
import { n as InMemoryMCPServersStorage, t as FilesystemMCPServersStorage } from "./filesystem-
|
|
55
|
-
import { n as InMemoryPromptBlocksStorage, t as FilesystemPromptBlocksStorage } from "./filesystem-
|
|
56
|
-
import { n as InMemoryScorerDefinitionsStorage, t as FilesystemScorerDefinitionsStorage } from "./filesystem-
|
|
57
|
-
import { n as InMemorySkillsStorage, t as FilesystemSkillsStorage } from "./filesystem-
|
|
58
|
-
import { n as InMemoryWorkspacesStorage, t as FilesystemWorkspacesStorage } from "./filesystem-
|
|
53
|
+
import { n as InMemoryMCPClientsStorage, t as FilesystemMCPClientsStorage } from "./filesystem-B8ad6kAW.js";
|
|
54
|
+
import { n as InMemoryMCPServersStorage, t as FilesystemMCPServersStorage } from "./filesystem-ClBOBoDc.js";
|
|
55
|
+
import { n as InMemoryPromptBlocksStorage, t as FilesystemPromptBlocksStorage } from "./filesystem-CLBVmR5j.js";
|
|
56
|
+
import { n as InMemoryScorerDefinitionsStorage, t as FilesystemScorerDefinitionsStorage } from "./filesystem-BDHUxbHn.js";
|
|
57
|
+
import { n as InMemorySkillsStorage, t as FilesystemSkillsStorage } from "./filesystem-B_afSgYk.js";
|
|
58
|
+
import { n as InMemoryWorkspacesStorage, t as FilesystemWorkspacesStorage } from "./filesystem-BhYgU8qg.js";
|
|
59
59
|
import { n as resolveAgentSkills, t as mergeWorkspaceSkills } from "./agent-skills-resolver-CUEIMDbx.js";
|
|
60
60
|
import { n as DefaultVoice } from "./voice-OS-kmlEA.js";
|
|
61
61
|
import { TTLCache } from "@isaacs/ttlcache";
|
|
@@ -773,6 +773,12 @@ function hasResumableStreams(agent) {
|
|
|
773
773
|
if (typeof agent.hasResumableStreams === "function") return agent.hasResumableStreams();
|
|
774
774
|
return isDurableAgentLike(agent);
|
|
775
775
|
}
|
|
776
|
+
// src/agent/streams/execution-capability.ts
|
|
777
|
+
/** Native engine selection or the released structural adapter contract (including Inngest). */
|
|
778
|
+
function hasDurableExecution(obj) {
|
|
779
|
+
if (isDurableAgentLike(obj)) return true;
|
|
780
|
+
return typeof obj === "object" && obj !== null && "__hasDurableExecution" in obj && typeof obj.__hasDurableExecution === "function" && obj.__hasDurableExecution() === true;
|
|
781
|
+
}
|
|
776
782
|
// src/workflows/stream-utils.ts
|
|
777
783
|
async function forwardAgentStreamChunk({ writer, chunk }) {
|
|
778
784
|
if (!writer) return;
|
|
@@ -801,8 +807,9 @@ function resolveEntryActor(stepOptions, runActor) {
|
|
|
801
807
|
* unwrapped to the agent it wraps. Warns because the step runs non-durably.
|
|
802
808
|
*/
|
|
803
809
|
function resolveLegacyAgent(agent, mastra) {
|
|
804
|
-
if (!
|
|
810
|
+
if (!hasDurableExecution(agent)) return agent;
|
|
805
811
|
mastra?.getLogger()?.warn(`Agent "${agent.id}" is durable but uses a legacy v1 model, which has no durable execution path, so the step runs it non-durably.`);
|
|
812
|
+
if (!isDurableAgentLike(agent)) return agent;
|
|
806
813
|
const inner = agent.agent;
|
|
807
814
|
return inner !== agent ? inner : agent;
|
|
808
815
|
}
|
|
@@ -7531,6 +7538,7 @@ function createStepFromProcessor$1(processor) {
|
|
|
7531
7538
|
};
|
|
7532
7539
|
const passThrough = {
|
|
7533
7540
|
agent,
|
|
7541
|
+
abortSignal,
|
|
7534
7542
|
lateSignalSink,
|
|
7535
7543
|
phase,
|
|
7536
7544
|
runId: agentRunId,
|
|
@@ -11681,7 +11689,7 @@ const MASTRA_DURABLE_SEGMENTS_KEY = "mastra__durableSegments";
|
|
|
11681
11689
|
* round-trip are skipped so a single non-serializable value can't break the
|
|
11682
11690
|
* snapshot.
|
|
11683
11691
|
*/
|
|
11684
|
-
function snapshotRequestContextEntries(requestContext) {
|
|
11692
|
+
function snapshotRequestContextEntries(requestContext, onEntryOmitted) {
|
|
11685
11693
|
if (!requestContext) return void 0;
|
|
11686
11694
|
const out = {};
|
|
11687
11695
|
let any = false;
|
|
@@ -11693,7 +11701,10 @@ function snapshotRequestContextEntries(requestContext) {
|
|
|
11693
11701
|
if (key === "mastra__durableExecutions") continue;
|
|
11694
11702
|
if (key === "mastra__durableSegments") continue;
|
|
11695
11703
|
const json = boundedStringify(value);
|
|
11696
|
-
if (json === void 0)
|
|
11704
|
+
if (json === void 0) {
|
|
11705
|
+
onEntryOmitted?.();
|
|
11706
|
+
continue;
|
|
11707
|
+
}
|
|
11697
11708
|
out[key] = JSON.parse(json);
|
|
11698
11709
|
any = true;
|
|
11699
11710
|
}
|
|
@@ -21158,15 +21169,17 @@ function createStepFromProcessor(processor) {
|
|
|
21158
21169
|
description: processor.name ?? `Processor ${processor.id}`,
|
|
21159
21170
|
inputSchema: toStandardSchema(ProcessorStepSchema),
|
|
21160
21171
|
outputSchema: toStandardSchema(ProcessorStepOutputSchema),
|
|
21161
|
-
execute: async ({ inputData, requestContext, outputWriter, tracing, tracingContext, loggerVNext, metrics, mastra, runId: workflowRunId }) => {
|
|
21172
|
+
execute: async ({ inputData, requestContext, outputWriter, tracing, tracingContext, loggerVNext, metrics, mastra, runId: workflowRunId, abortSignal: runAbortSignal }) => {
|
|
21162
21173
|
const observabilityContext = resolveObservabilityContext({
|
|
21163
21174
|
tracing,
|
|
21164
21175
|
tracingContext,
|
|
21165
21176
|
loggerVNext,
|
|
21166
21177
|
metrics
|
|
21167
21178
|
});
|
|
21179
|
+
const scopedSignal = mastra?.__getRunScope(workflowRunId)?.get(PROCESSOR_ABORT_SIGNAL);
|
|
21180
|
+
const abortSignal = scopedSignal && runAbortSignal ? AbortSignal.any([scopedSignal, runAbortSignal]) : scopedSignal ?? runAbortSignal;
|
|
21168
21181
|
const input = inputData;
|
|
21169
|
-
const { phase, messages, messageList, stepNumber, runId: agentRunId, systemMessages, part, streamParts, state, result: outputResult, finishReason, providerMetadata, toolCalls, text, retryCount, model, tools, toolChoice, activeTools, providerOptions, modelSettings, structuredOutput, steps, usage, messageId, rotateResponseMessageId, toolName, toolCallId, args: toolCallArgs, toolResultValue, modelOutput, providerExecuted, processorStates,
|
|
21182
|
+
const { phase, messages, messageList, stepNumber, runId: agentRunId, systemMessages, part, streamParts, state, result: outputResult, finishReason, providerMetadata, toolCalls, text, retryCount, model, tools, toolChoice, activeTools, providerOptions, modelSettings, structuredOutput, steps, usage, messageId, rotateResponseMessageId, toolName, toolCallId, args: toolCallArgs, toolResultValue, modelOutput, providerExecuted, processorStates, lateSignalSink } = input;
|
|
21170
21183
|
const abort = (reason, options) => {
|
|
21171
21184
|
throw new TripWire(reason || `Tripwire triggered by ${processor.id}`, options, processor.id);
|
|
21172
21185
|
};
|
|
@@ -38625,261 +38638,6 @@ var InMemoryHarness = class extends HarnessStorage {
|
|
|
38625
38638
|
return cloneSessionRecord(next);
|
|
38626
38639
|
}
|
|
38627
38640
|
};
|
|
38628
|
-
// src/storage/domains/knowledge/base.ts
|
|
38629
|
-
/** @experimental Knowledge APIs are experimental and may change without notice. */
|
|
38630
|
-
const KNOWLEDGE_STORAGE_CONTRACT_VERSION = 4;
|
|
38631
|
-
/** @experimental Knowledge APIs are experimental and may change without notice. */
|
|
38632
|
-
const KNOWLEDGE_STORAGE_SCHEMA_VERSION = 4;
|
|
38633
|
-
/**
|
|
38634
|
-
* Classifies an adapter-provided, read-only schema snapshot. Adapters own the physical probe; this
|
|
38635
|
-
* helper owns version negotiation and never mutates the snapshot or backing store.
|
|
38636
|
-
*
|
|
38637
|
-
* @experimental Knowledge APIs are experimental and may change without notice.
|
|
38638
|
-
*/
|
|
38639
|
-
function inspectKnowledgeSchema(snapshot) {
|
|
38640
|
-
if (!snapshot.available) return {
|
|
38641
|
-
status: "unavailable",
|
|
38642
|
-
schemaVersion: null,
|
|
38643
|
-
reason: snapshot.reason ?? "The Knowledge storage adapter is unavailable."
|
|
38644
|
-
};
|
|
38645
|
-
if (snapshot.tableNames.length === 0) return {
|
|
38646
|
-
status: "uninitialized",
|
|
38647
|
-
schemaVersion: null
|
|
38648
|
-
};
|
|
38649
|
-
if (snapshot.schemaVersion === 4) return {
|
|
38650
|
-
status: "compatible",
|
|
38651
|
-
schemaVersion: 4
|
|
38652
|
-
};
|
|
38653
|
-
return {
|
|
38654
|
-
status: "incompatible-reset-required",
|
|
38655
|
-
schemaVersion: snapshot.schemaVersion ?? null,
|
|
38656
|
-
reason: snapshot.reason ?? `Existing experimental Knowledge tables are not compatible with schema version 4.`
|
|
38657
|
-
};
|
|
38658
|
-
}
|
|
38659
|
-
/** @experimental Knowledge APIs are experimental and may change without notice. */
|
|
38660
|
-
var KnowledgeConflictError = class extends Error {
|
|
38661
|
-
constructor(id) {
|
|
38662
|
-
super(`Knowledge record version conflict: ${id}`);
|
|
38663
|
-
this.name = "KnowledgeConflictError";
|
|
38664
|
-
}
|
|
38665
|
-
};
|
|
38666
|
-
var KnowledgeNotFoundError$1 = class extends Error {
|
|
38667
|
-
constructor(type, id) {
|
|
38668
|
-
super(`Knowledge ${type} not found: ${id}`);
|
|
38669
|
-
this.name = "KnowledgeNotFoundError";
|
|
38670
|
-
}
|
|
38671
|
-
};
|
|
38672
|
-
var KnowledgeSchemaResetRequiredError = class extends Error {
|
|
38673
|
-
inspection;
|
|
38674
|
-
constructor(inspection) {
|
|
38675
|
-
super(`Knowledge schema reset required: ${inspection.reason}. Existing Knowledge data is not migrated. To replace it, call \`await storage.stores?.knowledge?.dangerouslyReset()\`, which deletes every Knowledge row and nothing else.`);
|
|
38676
|
-
this.name = "KnowledgeSchemaResetRequiredError";
|
|
38677
|
-
this.inspection = inspection;
|
|
38678
|
-
}
|
|
38679
|
-
};
|
|
38680
|
-
var KnowledgeUnsupportedCapabilityError = class extends Error {
|
|
38681
|
-
constructor(capability) {
|
|
38682
|
-
super(`This Knowledge storage adapter does not expose ${capability}.`);
|
|
38683
|
-
this.name = "KnowledgeUnsupportedCapabilityError";
|
|
38684
|
-
}
|
|
38685
|
-
};
|
|
38686
|
-
function assertKnowledgeSchemaCompatible(inspection) {
|
|
38687
|
-
if (inspection.status === "compatible" || inspection.status === "uninitialized") return;
|
|
38688
|
-
if (inspection.status === "incompatible-reset-required") throw new KnowledgeSchemaResetRequiredError(inspection);
|
|
38689
|
-
throw new Error(`Knowledge schema inspection unavailable: ${inspection.reason}`);
|
|
38690
|
-
}
|
|
38691
|
-
const CROCKFORD = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
38692
|
-
let lastUlidTime = -1;
|
|
38693
|
-
let lastUlidRandom = 0n;
|
|
38694
|
-
function parseKnowledgeWikilinks(text) {
|
|
38695
|
-
const names = [];
|
|
38696
|
-
const seen = /* @__PURE__ */ new Set();
|
|
38697
|
-
let contentStart = -1;
|
|
38698
|
-
for (let index = 0; index < text.length - 1; index++) {
|
|
38699
|
-
const pair = text.slice(index, index + 2);
|
|
38700
|
-
if (pair === "[[") {
|
|
38701
|
-
contentStart = index + 2;
|
|
38702
|
-
index++;
|
|
38703
|
-
continue;
|
|
38704
|
-
}
|
|
38705
|
-
if (pair !== "]]" || contentStart < 0) continue;
|
|
38706
|
-
const name = text.slice(contentStart, index).trim();
|
|
38707
|
-
const key = name.toLocaleLowerCase();
|
|
38708
|
-
if (name && !seen.has(key)) {
|
|
38709
|
-
seen.add(key);
|
|
38710
|
-
names.push(name);
|
|
38711
|
-
}
|
|
38712
|
-
contentStart = -1;
|
|
38713
|
-
index++;
|
|
38714
|
-
}
|
|
38715
|
-
return names;
|
|
38716
|
-
}
|
|
38717
|
-
function encodeCrockford(value, length) {
|
|
38718
|
-
let encoded = "";
|
|
38719
|
-
for (let index = 0; index < length; index++) {
|
|
38720
|
-
encoded = CROCKFORD[Number(value & 31n)] + encoded;
|
|
38721
|
-
value >>= 5n;
|
|
38722
|
-
}
|
|
38723
|
-
return encoded;
|
|
38724
|
-
}
|
|
38725
|
-
function createKnowledgeUlid(now = Date.now()) {
|
|
38726
|
-
if (now <= lastUlidTime) {
|
|
38727
|
-
now = lastUlidTime;
|
|
38728
|
-
lastUlidRandom = lastUlidRandom + 1n & (1n << 80n) - 1n;
|
|
38729
|
-
} else {
|
|
38730
|
-
lastUlidTime = now;
|
|
38731
|
-
lastUlidRandom = globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(10)).reduce((value, byte) => value << 8n | BigInt(byte), 0n);
|
|
38732
|
-
}
|
|
38733
|
-
return `${encodeCrockford(BigInt(now), 10)}${encodeCrockford(lastUlidRandom, 16)}`;
|
|
38734
|
-
}
|
|
38735
|
-
var KnowledgeStorage = class extends StorageDomain {
|
|
38736
|
-
#storageIsolationKey;
|
|
38737
|
-
constructor(config = {}) {
|
|
38738
|
-
super({
|
|
38739
|
-
component: "STORAGE",
|
|
38740
|
-
name: "KNOWLEDGE"
|
|
38741
|
-
});
|
|
38742
|
-
this.#storageIsolationKey = config.storageIsolationKey ?? this;
|
|
38743
|
-
}
|
|
38744
|
-
/** Identifies the physical Knowledge backend and namespace used by this domain. */
|
|
38745
|
-
getStorageIsolationKey() {
|
|
38746
|
-
return this.#storageIsolationKey;
|
|
38747
|
-
}
|
|
38748
|
-
getCapabilities() {
|
|
38749
|
-
return {
|
|
38750
|
-
contractVersion: 4,
|
|
38751
|
-
schemaVersion: 1,
|
|
38752
|
-
supportsSchemaInspection: false,
|
|
38753
|
-
supportsExplicitReset: false
|
|
38754
|
-
};
|
|
38755
|
-
}
|
|
38756
|
-
async inspectSchema() {
|
|
38757
|
-
return {
|
|
38758
|
-
status: "unavailable",
|
|
38759
|
-
schemaVersion: null,
|
|
38760
|
-
reason: "This Knowledge storage adapter does not support schema inspection."
|
|
38761
|
-
};
|
|
38762
|
-
}
|
|
38763
|
-
async dangerouslyReset() {
|
|
38764
|
-
throw new Error("This Knowledge storage adapter does not support an explicit Knowledge-only reset.");
|
|
38765
|
-
}
|
|
38766
|
-
/**
|
|
38767
|
-
* Scope declarations the store supplies itself, such as the scopes a hosted store's importers write
|
|
38768
|
-
* to, with their access rules. Knowledge merges them under its config's, reusing the answer for a
|
|
38769
|
-
* short window, so a declaration the store adds, removes or changes (revoking access included)
|
|
38770
|
-
* applies within it; a key the config declares keeps the config's declaration. None by default.
|
|
38771
|
-
*
|
|
38772
|
-
* @experimental
|
|
38773
|
-
*/
|
|
38774
|
-
async getScopeDeclarations() {
|
|
38775
|
-
return {};
|
|
38776
|
-
}
|
|
38777
|
-
materializeScope(_input) {
|
|
38778
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("materializeScope"));
|
|
38779
|
-
}
|
|
38780
|
-
getScopesByAddress(_input) {
|
|
38781
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("getScopesByAddress"));
|
|
38782
|
-
}
|
|
38783
|
-
listScopeDeclarations() {
|
|
38784
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("listScopeDeclarations"));
|
|
38785
|
-
}
|
|
38786
|
-
renameScopeDeclaration(_input) {
|
|
38787
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("renameScopeDeclaration"));
|
|
38788
|
-
}
|
|
38789
|
-
listChildScopes(_input) {
|
|
38790
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("listChildScopes"));
|
|
38791
|
-
}
|
|
38792
|
-
countChildScopes(_input) {
|
|
38793
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("countChildScopes"));
|
|
38794
|
-
}
|
|
38795
|
-
getPage(_input) {
|
|
38796
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("getPage"));
|
|
38797
|
-
}
|
|
38798
|
-
getPages(_input) {
|
|
38799
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("getPages"));
|
|
38800
|
-
}
|
|
38801
|
-
getPageByPath(_input) {
|
|
38802
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("getPageByPath"));
|
|
38803
|
-
}
|
|
38804
|
-
findPagesByName(_input) {
|
|
38805
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("findPagesByName"));
|
|
38806
|
-
}
|
|
38807
|
-
listChildPages(_input) {
|
|
38808
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("listChildPages"));
|
|
38809
|
-
}
|
|
38810
|
-
listPages(_input) {
|
|
38811
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("listPages"));
|
|
38812
|
-
}
|
|
38813
|
-
createPage(_input) {
|
|
38814
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("createPage"));
|
|
38815
|
-
}
|
|
38816
|
-
updatePage(_input) {
|
|
38817
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("updatePage"));
|
|
38818
|
-
}
|
|
38819
|
-
movePage(_input) {
|
|
38820
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("movePage"));
|
|
38821
|
-
}
|
|
38822
|
-
mergePages(_input) {
|
|
38823
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("mergePages"));
|
|
38824
|
-
}
|
|
38825
|
-
deletePage(_input) {
|
|
38826
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("deletePage"));
|
|
38827
|
-
}
|
|
38828
|
-
getNote(_input) {
|
|
38829
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("getNote"));
|
|
38830
|
-
}
|
|
38831
|
-
countChildPages(_input) {
|
|
38832
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("countChildPages"));
|
|
38833
|
-
}
|
|
38834
|
-
replacePageBodyLinks(_input) {
|
|
38835
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("replacePageBodyLinks"));
|
|
38836
|
-
}
|
|
38837
|
-
listPageBodyLinkSources(_input) {
|
|
38838
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("listPageBodyLinkSources"));
|
|
38839
|
-
}
|
|
38840
|
-
countPageLinks(_input) {
|
|
38841
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("countPageLinks"));
|
|
38842
|
-
}
|
|
38843
|
-
listPageLinks(_input) {
|
|
38844
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("listPageLinks"));
|
|
38845
|
-
}
|
|
38846
|
-
countNotes(_input) {
|
|
38847
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("countNotes"));
|
|
38848
|
-
}
|
|
38849
|
-
listNotes(_input) {
|
|
38850
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("listNotes"));
|
|
38851
|
-
}
|
|
38852
|
-
listNotesMentioning(_input) {
|
|
38853
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("listNotesMentioning"));
|
|
38854
|
-
}
|
|
38855
|
-
addNote(_input) {
|
|
38856
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("addNote"));
|
|
38857
|
-
}
|
|
38858
|
-
restampNote(_input) {
|
|
38859
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("restampNote"));
|
|
38860
|
-
}
|
|
38861
|
-
removeNote(_input) {
|
|
38862
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("removeNote"));
|
|
38863
|
-
}
|
|
38864
|
-
restoreNote(_input) {
|
|
38865
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("restoreNote"));
|
|
38866
|
-
}
|
|
38867
|
-
searchPages(_input) {
|
|
38868
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("searchPages"));
|
|
38869
|
-
}
|
|
38870
|
-
listPageActivity(_input) {
|
|
38871
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("listPageActivity"));
|
|
38872
|
-
}
|
|
38873
|
-
addPinAudience(_input) {
|
|
38874
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("addPinAudience"));
|
|
38875
|
-
}
|
|
38876
|
-
removePinAudience(_input) {
|
|
38877
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("removePinAudience"));
|
|
38878
|
-
}
|
|
38879
|
-
listPins(_input) {
|
|
38880
|
-
return Promise.reject(new KnowledgeUnsupportedCapabilityError("listPins"));
|
|
38881
|
-
}
|
|
38882
|
-
};
|
|
38883
38641
|
const KNOWLEDGE_TABLE_NAMES = [
|
|
38884
38642
|
"mastra_knowledge_nodes",
|
|
38885
38643
|
"mastra_knowledge_records",
|
|
@@ -38915,6 +38673,20 @@ const KNOWLEDGE_PAGES_TABLE_NAMES = [
|
|
|
38915
38673
|
new Set([...KNOWLEDGE_TABLE_NAMES, ...RETIRED_KNOWLEDGE_TABLE_NAMES].filter((name) => !KNOWLEDGE_PAGES_TABLE_NAMES.includes(name)));
|
|
38916
38674
|
KNOWLEDGE_TABLE_NAMES.filter((name) => KNOWLEDGE_PAGES_TABLE_NAMES.includes(name));
|
|
38917
38675
|
/**
|
|
38676
|
+
* A list cursor the store cannot decode (malformed, or from another store or version). Defined
|
|
38677
|
+
* here so every adapter can throw it on any core version; core re-exports it from
|
|
38678
|
+
* `@mastra/core/storage`. Recognise it by `name`.
|
|
38679
|
+
* @experimental
|
|
38680
|
+
*/
|
|
38681
|
+
var KnowledgeInvalidCursorError = class extends Error {
|
|
38682
|
+
cursor;
|
|
38683
|
+
constructor(cursor) {
|
|
38684
|
+
super("Invalid Knowledge cursor: this store cannot decode it");
|
|
38685
|
+
this.cursor = cursor;
|
|
38686
|
+
this.name = "KnowledgeInvalidCursorError";
|
|
38687
|
+
}
|
|
38688
|
+
};
|
|
38689
|
+
/**
|
|
38918
38690
|
* Keyword-search words: the query split on whitespace, lowercased, deduplicated, keeping the first
|
|
38919
38691
|
* {@link KNOWLEDGE_SEARCH_MAX_WORDS}. A hit needs at least one of them (as a case-insensitive
|
|
38920
38692
|
* substring); an empty list means the search returns nothing.
|
|
@@ -39181,6 +38953,667 @@ function knowledgePositionBetween(before, after) {
|
|
|
39181
38953
|
if (before !== void 0 && after !== void 0 && before >= after) throw new Error(`Invalid position range: ${before} >= ${after}`);
|
|
39182
38954
|
return after === void 0 ? positionAfter(before ?? "") : positionMidpoint(before ?? "", after);
|
|
39183
38955
|
}
|
|
38956
|
+
// src/storage/domains/knowledge/base.ts
|
|
38957
|
+
/** @experimental Knowledge APIs are experimental and may change without notice. */
|
|
38958
|
+
const KNOWLEDGE_STORAGE_CONTRACT_VERSION = 4;
|
|
38959
|
+
/** @experimental Knowledge APIs are experimental and may change without notice. */
|
|
38960
|
+
const KNOWLEDGE_STORAGE_SCHEMA_VERSION = 4;
|
|
38961
|
+
/**
|
|
38962
|
+
* Classifies an adapter-provided, read-only schema snapshot. Adapters own the physical probe; this
|
|
38963
|
+
* helper owns version negotiation and never mutates the snapshot or backing store.
|
|
38964
|
+
*
|
|
38965
|
+
* @experimental Knowledge APIs are experimental and may change without notice.
|
|
38966
|
+
*/
|
|
38967
|
+
function inspectKnowledgeSchema(snapshot) {
|
|
38968
|
+
if (!snapshot.available) return {
|
|
38969
|
+
status: "unavailable",
|
|
38970
|
+
schemaVersion: null,
|
|
38971
|
+
reason: snapshot.reason ?? "The Knowledge storage adapter is unavailable."
|
|
38972
|
+
};
|
|
38973
|
+
if (snapshot.tableNames.length === 0) return {
|
|
38974
|
+
status: "uninitialized",
|
|
38975
|
+
schemaVersion: null
|
|
38976
|
+
};
|
|
38977
|
+
if (snapshot.schemaVersion === 4) return {
|
|
38978
|
+
status: "compatible",
|
|
38979
|
+
schemaVersion: 4
|
|
38980
|
+
};
|
|
38981
|
+
return {
|
|
38982
|
+
status: "incompatible-reset-required",
|
|
38983
|
+
schemaVersion: snapshot.schemaVersion ?? null,
|
|
38984
|
+
reason: snapshot.reason ?? `Existing experimental Knowledge tables are not compatible with schema version 4.`
|
|
38985
|
+
};
|
|
38986
|
+
}
|
|
38987
|
+
/** @experimental Knowledge APIs are experimental and may change without notice. */
|
|
38988
|
+
var KnowledgeConflictError = class extends Error {
|
|
38989
|
+
constructor(id) {
|
|
38990
|
+
super(`Knowledge record version conflict: ${id}`);
|
|
38991
|
+
this.name = "KnowledgeConflictError";
|
|
38992
|
+
}
|
|
38993
|
+
};
|
|
38994
|
+
var KnowledgeNotFoundError$1 = class extends Error {
|
|
38995
|
+
constructor(type, id) {
|
|
38996
|
+
super(`Knowledge ${type} not found: ${id}`);
|
|
38997
|
+
this.name = "KnowledgeNotFoundError";
|
|
38998
|
+
}
|
|
38999
|
+
};
|
|
39000
|
+
var KnowledgeSchemaResetRequiredError = class extends Error {
|
|
39001
|
+
inspection;
|
|
39002
|
+
constructor(inspection) {
|
|
39003
|
+
super(`Knowledge schema reset required: ${inspection.reason}. Existing Knowledge data is not migrated. To replace it, call \`await storage.stores?.knowledge?.dangerouslyReset()\`, which deletes every Knowledge row and nothing else.`);
|
|
39004
|
+
this.name = "KnowledgeSchemaResetRequiredError";
|
|
39005
|
+
this.inspection = inspection;
|
|
39006
|
+
}
|
|
39007
|
+
};
|
|
39008
|
+
var KnowledgeUnsupportedCapabilityError = class extends Error {
|
|
39009
|
+
constructor(capability) {
|
|
39010
|
+
super(`This Knowledge storage adapter does not expose ${capability}.`);
|
|
39011
|
+
this.name = "KnowledgeUnsupportedCapabilityError";
|
|
39012
|
+
}
|
|
39013
|
+
};
|
|
39014
|
+
/** A transaction ran past its `deadlineAt` and was rolled back; nothing in it was applied. Retrying is safe. */
|
|
39015
|
+
var KnowledgeTransactionDeadlineError = class extends Error {
|
|
39016
|
+
retryable = true;
|
|
39017
|
+
constructor(options) {
|
|
39018
|
+
super("The Knowledge transaction ran past its deadline and was rolled back.", options);
|
|
39019
|
+
this.name = "KnowledgeTransactionDeadlineError";
|
|
39020
|
+
}
|
|
39021
|
+
};
|
|
39022
|
+
function assertKnowledgeSchemaCompatible(inspection) {
|
|
39023
|
+
if (inspection.status === "compatible" || inspection.status === "uninitialized") return;
|
|
39024
|
+
if (inspection.status === "incompatible-reset-required") throw new KnowledgeSchemaResetRequiredError(inspection);
|
|
39025
|
+
throw new Error(`Knowledge schema inspection unavailable: ${inspection.reason}`);
|
|
39026
|
+
}
|
|
39027
|
+
const CROCKFORD = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
39028
|
+
let lastUlidTime = -1;
|
|
39029
|
+
let lastUlidRandom = 0n;
|
|
39030
|
+
function parseKnowledgeWikilinks(text) {
|
|
39031
|
+
const names = [];
|
|
39032
|
+
const seen = /* @__PURE__ */ new Set();
|
|
39033
|
+
let contentStart = -1;
|
|
39034
|
+
for (let index = 0; index < text.length - 1; index++) {
|
|
39035
|
+
const pair = text.slice(index, index + 2);
|
|
39036
|
+
if (pair === "[[") {
|
|
39037
|
+
contentStart = index + 2;
|
|
39038
|
+
index++;
|
|
39039
|
+
continue;
|
|
39040
|
+
}
|
|
39041
|
+
if (pair !== "]]" || contentStart < 0) continue;
|
|
39042
|
+
const name = text.slice(contentStart, index).trim();
|
|
39043
|
+
const key = name.toLocaleLowerCase();
|
|
39044
|
+
if (name && !seen.has(key)) {
|
|
39045
|
+
seen.add(key);
|
|
39046
|
+
names.push(name);
|
|
39047
|
+
}
|
|
39048
|
+
contentStart = -1;
|
|
39049
|
+
index++;
|
|
39050
|
+
}
|
|
39051
|
+
return names;
|
|
39052
|
+
}
|
|
39053
|
+
function encodeCrockford(value, length) {
|
|
39054
|
+
let encoded = "";
|
|
39055
|
+
for (let index = 0; index < length; index++) {
|
|
39056
|
+
encoded = CROCKFORD[Number(value & 31n)] + encoded;
|
|
39057
|
+
value >>= 5n;
|
|
39058
|
+
}
|
|
39059
|
+
return encoded;
|
|
39060
|
+
}
|
|
39061
|
+
function createKnowledgeUlid(now = Date.now()) {
|
|
39062
|
+
if (now <= lastUlidTime) {
|
|
39063
|
+
now = lastUlidTime;
|
|
39064
|
+
lastUlidRandom = lastUlidRandom + 1n & (1n << 80n) - 1n;
|
|
39065
|
+
} else {
|
|
39066
|
+
lastUlidTime = now;
|
|
39067
|
+
lastUlidRandom = globalThis.crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(10)).reduce((value, byte) => value << 8n | BigInt(byte), 0n);
|
|
39068
|
+
}
|
|
39069
|
+
return `${encodeCrockford(BigInt(now), 10)}${encodeCrockford(lastUlidRandom, 16)}`;
|
|
39070
|
+
}
|
|
39071
|
+
var KnowledgeStorage = class extends StorageDomain {
|
|
39072
|
+
#storageIsolationKey;
|
|
39073
|
+
constructor(config = {}) {
|
|
39074
|
+
super({
|
|
39075
|
+
component: "STORAGE",
|
|
39076
|
+
name: "KNOWLEDGE"
|
|
39077
|
+
});
|
|
39078
|
+
this.#storageIsolationKey = config.storageIsolationKey ?? this;
|
|
39079
|
+
}
|
|
39080
|
+
/** Identifies the physical Knowledge backend and namespace used by this domain. */
|
|
39081
|
+
getStorageIsolationKey() {
|
|
39082
|
+
return this.#storageIsolationKey;
|
|
39083
|
+
}
|
|
39084
|
+
getCapabilities() {
|
|
39085
|
+
return {
|
|
39086
|
+
contractVersion: 4,
|
|
39087
|
+
schemaVersion: 1,
|
|
39088
|
+
supportsSchemaInspection: false,
|
|
39089
|
+
supportsExplicitReset: false
|
|
39090
|
+
};
|
|
39091
|
+
}
|
|
39092
|
+
/**
|
|
39093
|
+
* Runs `operation` against a view of this store whose reads and writes all belong to one
|
|
39094
|
+
* transaction: it commits when `operation` resolves and rolls back when it throws, and no other
|
|
39095
|
+
* connection sees its writes until it commits. A store method that fails inside the view undoes
|
|
39096
|
+
* only its own writes, so the caller can catch it and go on. `transaction` on the view joins the
|
|
39097
|
+
* same transaction the same way. Adapters in the same package can write their own tables through
|
|
39098
|
+
* the view, so they commit with the page writes.
|
|
39099
|
+
*
|
|
39100
|
+
* Calls on this store (not the view) while `operation` runs are outside the transaction. Await
|
|
39101
|
+
* calls on the view one at a time, as on a single connection.
|
|
39102
|
+
*
|
|
39103
|
+
* @experimental
|
|
39104
|
+
*/
|
|
39105
|
+
transaction(_operation, _options) {
|
|
39106
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("transactions"));
|
|
39107
|
+
}
|
|
39108
|
+
/**
|
|
39109
|
+
* On a {@link transaction} view: locks the pages' rows against other writers until commit. A no-op
|
|
39110
|
+
* on stores whose transactions already exclude every other writer (one write transaction at a
|
|
39111
|
+
* time).
|
|
39112
|
+
*
|
|
39113
|
+
* @experimental
|
|
39114
|
+
*/
|
|
39115
|
+
lockPages(_ids) {
|
|
39116
|
+
return Promise.resolve();
|
|
39117
|
+
}
|
|
39118
|
+
/**
|
|
39119
|
+
* On a {@link transaction} view: the ids of the live pages under `rootId` (not the root itself),
|
|
39120
|
+
* locked so no page can be added under, moved out of or removed from that subtree until commit.
|
|
39121
|
+
* A later {@link movePage} of `rootId` in the same transaction moves exactly these pages. Throws
|
|
39122
|
+
* {@link KnowledgeMoveTooLargeError} past {@link MAX_KNOWLEDGE_MOVE_PAGES}. The default walks the
|
|
39123
|
+
* children without locking, which holds on stores whose transactions exclude every other writer.
|
|
39124
|
+
*
|
|
39125
|
+
* @experimental
|
|
39126
|
+
*/
|
|
39127
|
+
async lockSubtree(rootId) {
|
|
39128
|
+
const ids = [];
|
|
39129
|
+
const parents = [rootId];
|
|
39130
|
+
while (parents.length) {
|
|
39131
|
+
const parentId = parents.shift();
|
|
39132
|
+
let cursor;
|
|
39133
|
+
do {
|
|
39134
|
+
const page = await this.listChildPages({
|
|
39135
|
+
parentId,
|
|
39136
|
+
read: "all",
|
|
39137
|
+
...cursor ? { cursor } : {}
|
|
39138
|
+
});
|
|
39139
|
+
for (const child of page.pages) {
|
|
39140
|
+
ids.push(child.id);
|
|
39141
|
+
parents.push(child.id);
|
|
39142
|
+
}
|
|
39143
|
+
if (ids.length >= 500) throw new KnowledgeMoveTooLargeError(rootId, ids.length + 1);
|
|
39144
|
+
cursor = page.nextCursor ?? void 0;
|
|
39145
|
+
} while (cursor);
|
|
39146
|
+
}
|
|
39147
|
+
return ids;
|
|
39148
|
+
}
|
|
39149
|
+
/**
|
|
39150
|
+
* Importer bookkeeping on the same database and namespace as the pages, or undefined when the
|
|
39151
|
+
* adapter has none. On a {@link transaction} view it belongs to that transaction.
|
|
39152
|
+
*
|
|
39153
|
+
* @experimental
|
|
39154
|
+
*/
|
|
39155
|
+
get importers() {}
|
|
39156
|
+
async inspectSchema() {
|
|
39157
|
+
return {
|
|
39158
|
+
status: "unavailable",
|
|
39159
|
+
schemaVersion: null,
|
|
39160
|
+
reason: "This Knowledge storage adapter does not support schema inspection."
|
|
39161
|
+
};
|
|
39162
|
+
}
|
|
39163
|
+
async dangerouslyReset() {
|
|
39164
|
+
throw new Error("This Knowledge storage adapter does not support an explicit Knowledge-only reset.");
|
|
39165
|
+
}
|
|
39166
|
+
/**
|
|
39167
|
+
* Scope declarations the store supplies itself, such as the scopes a hosted store's importers write
|
|
39168
|
+
* to, with their access rules. Knowledge merges them under its config's, reusing the answer for a
|
|
39169
|
+
* short window, so a declaration the store adds, removes or changes (revoking access included)
|
|
39170
|
+
* applies within it; a key the config declares keeps the config's declaration. None by default.
|
|
39171
|
+
*
|
|
39172
|
+
* @experimental
|
|
39173
|
+
*/
|
|
39174
|
+
async getScopeDeclarations() {
|
|
39175
|
+
return {};
|
|
39176
|
+
}
|
|
39177
|
+
materializeScope(_input) {
|
|
39178
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("materializeScope"));
|
|
39179
|
+
}
|
|
39180
|
+
getScopesByAddress(_input) {
|
|
39181
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("getScopesByAddress"));
|
|
39182
|
+
}
|
|
39183
|
+
listScopeDeclarations() {
|
|
39184
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("listScopeDeclarations"));
|
|
39185
|
+
}
|
|
39186
|
+
renameScopeDeclaration(_input) {
|
|
39187
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("renameScopeDeclaration"));
|
|
39188
|
+
}
|
|
39189
|
+
listChildScopes(_input) {
|
|
39190
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("listChildScopes"));
|
|
39191
|
+
}
|
|
39192
|
+
countChildScopes(_input) {
|
|
39193
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("countChildScopes"));
|
|
39194
|
+
}
|
|
39195
|
+
getPage(_input) {
|
|
39196
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("getPage"));
|
|
39197
|
+
}
|
|
39198
|
+
getPages(_input) {
|
|
39199
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("getPages"));
|
|
39200
|
+
}
|
|
39201
|
+
getPageByPath(_input) {
|
|
39202
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("getPageByPath"));
|
|
39203
|
+
}
|
|
39204
|
+
findPagesByName(_input) {
|
|
39205
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("findPagesByName"));
|
|
39206
|
+
}
|
|
39207
|
+
listChildPages(_input) {
|
|
39208
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("listChildPages"));
|
|
39209
|
+
}
|
|
39210
|
+
listPages(_input) {
|
|
39211
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("listPages"));
|
|
39212
|
+
}
|
|
39213
|
+
createPage(_input) {
|
|
39214
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("createPage"));
|
|
39215
|
+
}
|
|
39216
|
+
updatePage(_input) {
|
|
39217
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("updatePage"));
|
|
39218
|
+
}
|
|
39219
|
+
movePage(_input) {
|
|
39220
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("movePage"));
|
|
39221
|
+
}
|
|
39222
|
+
mergePages(_input) {
|
|
39223
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("mergePages"));
|
|
39224
|
+
}
|
|
39225
|
+
deletePage(_input) {
|
|
39226
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("deletePage"));
|
|
39227
|
+
}
|
|
39228
|
+
getNote(_input) {
|
|
39229
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("getNote"));
|
|
39230
|
+
}
|
|
39231
|
+
countChildPages(_input) {
|
|
39232
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("countChildPages"));
|
|
39233
|
+
}
|
|
39234
|
+
replacePageBodyLinks(_input) {
|
|
39235
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("replacePageBodyLinks"));
|
|
39236
|
+
}
|
|
39237
|
+
listPageBodyLinkSources(_input) {
|
|
39238
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("listPageBodyLinkSources"));
|
|
39239
|
+
}
|
|
39240
|
+
countPageLinks(_input) {
|
|
39241
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("countPageLinks"));
|
|
39242
|
+
}
|
|
39243
|
+
listPageLinks(_input) {
|
|
39244
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("listPageLinks"));
|
|
39245
|
+
}
|
|
39246
|
+
countNotes(_input) {
|
|
39247
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("countNotes"));
|
|
39248
|
+
}
|
|
39249
|
+
listNotes(_input) {
|
|
39250
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("listNotes"));
|
|
39251
|
+
}
|
|
39252
|
+
listNotesMentioning(_input) {
|
|
39253
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("listNotesMentioning"));
|
|
39254
|
+
}
|
|
39255
|
+
addNote(_input) {
|
|
39256
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("addNote"));
|
|
39257
|
+
}
|
|
39258
|
+
restampNote(_input) {
|
|
39259
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("restampNote"));
|
|
39260
|
+
}
|
|
39261
|
+
removeNote(_input) {
|
|
39262
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("removeNote"));
|
|
39263
|
+
}
|
|
39264
|
+
restoreNote(_input) {
|
|
39265
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("restoreNote"));
|
|
39266
|
+
}
|
|
39267
|
+
searchPages(_input) {
|
|
39268
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("searchPages"));
|
|
39269
|
+
}
|
|
39270
|
+
listPageActivity(_input) {
|
|
39271
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("listPageActivity"));
|
|
39272
|
+
}
|
|
39273
|
+
addPinAudience(_input) {
|
|
39274
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("addPinAudience"));
|
|
39275
|
+
}
|
|
39276
|
+
removePinAudience(_input) {
|
|
39277
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("removePinAudience"));
|
|
39278
|
+
}
|
|
39279
|
+
listPins(_input) {
|
|
39280
|
+
return Promise.reject(new KnowledgeUnsupportedCapabilityError("listPins"));
|
|
39281
|
+
}
|
|
39282
|
+
};
|
|
39283
|
+
// src/storage/domains/knowledge/importers.ts
|
|
39284
|
+
/** A binding was registered again with a different importer or target. */
|
|
39285
|
+
var KnowledgeImporterBindingConflictError = class extends Error {
|
|
39286
|
+
bindingId;
|
|
39287
|
+
constructor(bindingId) {
|
|
39288
|
+
super(`Knowledge importer binding ${bindingId} already exists with a different importer or target`);
|
|
39289
|
+
this.bindingId = bindingId;
|
|
39290
|
+
this.name = "KnowledgeImporterBindingConflictError";
|
|
39291
|
+
}
|
|
39292
|
+
};
|
|
39293
|
+
/** A conditional run write found the run in another state (see each method). */
|
|
39294
|
+
var KnowledgeImporterRunStateError = class extends Error {
|
|
39295
|
+
runId;
|
|
39296
|
+
reason;
|
|
39297
|
+
constructor(runId, reason) {
|
|
39298
|
+
super(`Knowledge importer run ${runId} refused the write: ${reason}`);
|
|
39299
|
+
this.runId = runId;
|
|
39300
|
+
this.reason = reason;
|
|
39301
|
+
this.name = "KnowledgeImporterRunStateError";
|
|
39302
|
+
}
|
|
39303
|
+
};
|
|
39304
|
+
/** @experimental */
|
|
39305
|
+
var KnowledgeImportersStorage = class {
|
|
39306
|
+
/**
|
|
39307
|
+
* The store's clock, which every run timestamp it writes (`startedAt`, `heartbeatAt`) comes from:
|
|
39308
|
+
* a host compares leases against it rather than its own clock. Defaults to this process's clock,
|
|
39309
|
+
* which is the store's own for an in-process store.
|
|
39310
|
+
*/
|
|
39311
|
+
async now() {
|
|
39312
|
+
return /* @__PURE__ */ new Date();
|
|
39313
|
+
}
|
|
39314
|
+
};
|
|
39315
|
+
// src/storage/domains/knowledge/importers-inmemory.ts
|
|
39316
|
+
const empty = () => ({
|
|
39317
|
+
bindings: /* @__PURE__ */ new Map(),
|
|
39318
|
+
nodes: /* @__PURE__ */ new Map(),
|
|
39319
|
+
state: /* @__PURE__ */ new Map(),
|
|
39320
|
+
runs: /* @__PURE__ */ new Map(),
|
|
39321
|
+
flushes: /* @__PURE__ */ new Map(),
|
|
39322
|
+
changes: /* @__PURE__ */ new Map(),
|
|
39323
|
+
guard: {
|
|
39324
|
+
activePath: "new",
|
|
39325
|
+
generation: 1,
|
|
39326
|
+
firstWriteAt: null
|
|
39327
|
+
},
|
|
39328
|
+
order: 0
|
|
39329
|
+
});
|
|
39330
|
+
const key = (...parts) => JSON.stringify(parts);
|
|
39331
|
+
/**
|
|
39332
|
+
* UTF-8 byte order, the order PostgreSQL's `COLLATE "C"` and SQLite's BINARY give. Code point order
|
|
39333
|
+
* is the same thing; JavaScript's `<` compares UTF-16 code units, which puts characters above U+FFFF
|
|
39334
|
+
* (surrogate pairs) before U+E000–U+FFFF.
|
|
39335
|
+
*/
|
|
39336
|
+
const byteOrder = (a, b) => {
|
|
39337
|
+
for (let i = 0, j = 0; i < a.length && j < b.length;) {
|
|
39338
|
+
const x = a.codePointAt(i);
|
|
39339
|
+
const y = b.codePointAt(j);
|
|
39340
|
+
if (x !== y) return x < y ? -1 : 1;
|
|
39341
|
+
i += x > 65535 ? 2 : 1;
|
|
39342
|
+
j += y > 65535 ? 2 : 1;
|
|
39343
|
+
}
|
|
39344
|
+
return a.length === b.length ? 0 : a.length < b.length ? -1 : 1;
|
|
39345
|
+
};
|
|
39346
|
+
function addCounts(into, add) {
|
|
39347
|
+
const out = { ...into };
|
|
39348
|
+
for (const [name, value] of Object.entries(add)) out[name] = (out[name] ?? 0) + value;
|
|
39349
|
+
return out;
|
|
39350
|
+
}
|
|
39351
|
+
/**
|
|
39352
|
+
* In-memory importer bookkeeping. One process, no locks: the owning store runs transactions one at
|
|
39353
|
+
* a time and rolls them back by restoring {@link snapshot}.
|
|
39354
|
+
*/
|
|
39355
|
+
var InMemoryKnowledgeImportersStorage = class extends KnowledgeImportersStorage {
|
|
39356
|
+
#s = empty();
|
|
39357
|
+
snapshot() {
|
|
39358
|
+
return structuredClone(this.#s);
|
|
39359
|
+
}
|
|
39360
|
+
restore(state) {
|
|
39361
|
+
this.#s = state;
|
|
39362
|
+
}
|
|
39363
|
+
async init() {}
|
|
39364
|
+
async dangerouslyClearAll() {
|
|
39365
|
+
this.#s = empty();
|
|
39366
|
+
}
|
|
39367
|
+
/** Part of the Knowledge store's reset: empties everything and moves the generation forward. */
|
|
39368
|
+
clearOnReset() {
|
|
39369
|
+
const { activePath, generation } = this.#s.guard;
|
|
39370
|
+
this.#s = empty();
|
|
39371
|
+
this.#s.guard = {
|
|
39372
|
+
activePath,
|
|
39373
|
+
generation: generation + 1,
|
|
39374
|
+
firstWriteAt: null
|
|
39375
|
+
};
|
|
39376
|
+
}
|
|
39377
|
+
async registerBinding(input) {
|
|
39378
|
+
const existing = this.#s.bindings.get(input.id);
|
|
39379
|
+
if (existing) {
|
|
39380
|
+
if (existing.importer !== input.importer || existing.target !== input.target) throw new KnowledgeImporterBindingConflictError(input.id);
|
|
39381
|
+
return {
|
|
39382
|
+
status: "unchanged",
|
|
39383
|
+
binding: { ...existing }
|
|
39384
|
+
};
|
|
39385
|
+
}
|
|
39386
|
+
const binding = {
|
|
39387
|
+
...input,
|
|
39388
|
+
anchorPageId: null,
|
|
39389
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
39390
|
+
};
|
|
39391
|
+
this.#s.bindings.set(input.id, binding);
|
|
39392
|
+
return {
|
|
39393
|
+
status: "created",
|
|
39394
|
+
binding: { ...binding }
|
|
39395
|
+
};
|
|
39396
|
+
}
|
|
39397
|
+
async getBinding(id) {
|
|
39398
|
+
const binding = this.#s.bindings.get(id);
|
|
39399
|
+
return binding ? { ...binding } : null;
|
|
39400
|
+
}
|
|
39401
|
+
async setBindingAnchor(input) {
|
|
39402
|
+
const binding = this.#s.bindings.get(input.bindingId);
|
|
39403
|
+
if (!binding || binding.anchorPageId !== input.expected) return false;
|
|
39404
|
+
binding.anchorPageId = input.pageId;
|
|
39405
|
+
return true;
|
|
39406
|
+
}
|
|
39407
|
+
async listBindings() {
|
|
39408
|
+
return [...this.#s.bindings.values()].sort((a, b) => byteOrder(a.id, b.id)).map((b) => ({ ...b }));
|
|
39409
|
+
}
|
|
39410
|
+
async retireBinding(id) {
|
|
39411
|
+
this.#s.bindings.delete(id);
|
|
39412
|
+
for (const [k, node] of this.#s.nodes) if (node.bindingId === id) this.#s.nodes.delete(k);
|
|
39413
|
+
this.#s.state.delete(id);
|
|
39414
|
+
const runs = /* @__PURE__ */ new Set();
|
|
39415
|
+
for (const [runId, run] of this.#s.runs) {
|
|
39416
|
+
if (run.bindingId !== id) continue;
|
|
39417
|
+
runs.add(runId);
|
|
39418
|
+
this.#s.runs.delete(runId);
|
|
39419
|
+
}
|
|
39420
|
+
for (const [k, flush] of this.#s.flushes) if (runs.has(flush.runId)) this.#s.flushes.delete(k);
|
|
39421
|
+
for (const [k, { change }] of this.#s.changes) if (runs.has(change.runId)) this.#s.changes.delete(k);
|
|
39422
|
+
}
|
|
39423
|
+
async startRun(input) {
|
|
39424
|
+
const runs = [...this.#s.runs.values()].filter((r) => r.bindingId === input.bindingId);
|
|
39425
|
+
if (input.fireKey) {
|
|
39426
|
+
const fired = runs.find((r) => r.fireKey === input.fireKey);
|
|
39427
|
+
if (fired) return {
|
|
39428
|
+
status: "duplicate",
|
|
39429
|
+
run: structuredClone(fired)
|
|
39430
|
+
};
|
|
39431
|
+
}
|
|
39432
|
+
const running = runs.some((r) => r.status === "running");
|
|
39433
|
+
const now = /* @__PURE__ */ new Date();
|
|
39434
|
+
const run = {
|
|
39435
|
+
id: input.runId,
|
|
39436
|
+
bindingId: input.bindingId,
|
|
39437
|
+
generation: input.generation,
|
|
39438
|
+
status: running ? "skipped" : "running",
|
|
39439
|
+
fireKey: input.fireKey ?? null,
|
|
39440
|
+
deadlineAt: input.deadlineAt ?? null,
|
|
39441
|
+
cancelRequestedAt: null,
|
|
39442
|
+
heartbeatAt: null,
|
|
39443
|
+
lastSeq: 0,
|
|
39444
|
+
finish: null,
|
|
39445
|
+
counts: {},
|
|
39446
|
+
startedAt: now,
|
|
39447
|
+
completedAt: running ? now : null
|
|
39448
|
+
};
|
|
39449
|
+
this.#s.runs.set(run.id, run);
|
|
39450
|
+
return {
|
|
39451
|
+
status: running ? "skipped" : "started",
|
|
39452
|
+
run: structuredClone(run)
|
|
39453
|
+
};
|
|
39454
|
+
}
|
|
39455
|
+
async getRun(runId) {
|
|
39456
|
+
const run = this.#s.runs.get(runId);
|
|
39457
|
+
return run ? structuredClone(run) : null;
|
|
39458
|
+
}
|
|
39459
|
+
async listRuns(bindingId, options = {}) {
|
|
39460
|
+
return [...this.#s.runs.values()].filter((r) => r.bindingId === bindingId).sort((a, b) => b.startedAt.getTime() - a.startedAt.getTime()).slice(0, options.limit ?? 50).map((r) => structuredClone(r));
|
|
39461
|
+
}
|
|
39462
|
+
async requestCancel(runId) {
|
|
39463
|
+
const run = this.#s.runs.get(runId);
|
|
39464
|
+
if (!run || run.status !== "running") return null;
|
|
39465
|
+
run.cancelRequestedAt ??= /* @__PURE__ */ new Date();
|
|
39466
|
+
return structuredClone(run);
|
|
39467
|
+
}
|
|
39468
|
+
async heartbeat(runId) {
|
|
39469
|
+
const run = this.#s.runs.get(runId);
|
|
39470
|
+
if (!run || run.status !== "running") return null;
|
|
39471
|
+
run.heartbeatAt = /* @__PURE__ */ new Date();
|
|
39472
|
+
return structuredClone(run);
|
|
39473
|
+
}
|
|
39474
|
+
async abandonRun(input) {
|
|
39475
|
+
const run = this.#s.runs.get(input.runId);
|
|
39476
|
+
if (!run || run.status !== "running") return null;
|
|
39477
|
+
run.status = input.status ?? "failed";
|
|
39478
|
+
run.finish = structuredClone(input.finish);
|
|
39479
|
+
run.completedAt = /* @__PURE__ */ new Date();
|
|
39480
|
+
return structuredClone(run);
|
|
39481
|
+
}
|
|
39482
|
+
/** Transactions run one at a time in memory, so a read is as good as a lock. */
|
|
39483
|
+
async lockRun(runId) {
|
|
39484
|
+
return this.getRun(runId);
|
|
39485
|
+
}
|
|
39486
|
+
#activeRun(runId, generation) {
|
|
39487
|
+
const run = this.#s.runs.get(runId);
|
|
39488
|
+
if (!run) throw new KnowledgeImporterRunStateError(runId, "not_found");
|
|
39489
|
+
if (run.status !== "running") throw new KnowledgeImporterRunStateError(runId, "not_running");
|
|
39490
|
+
if (run.generation !== generation) throw new KnowledgeImporterRunStateError(runId, "generation");
|
|
39491
|
+
if (this.#s.guard.generation !== generation) throw new KnowledgeImporterRunStateError(runId, "stale_guard");
|
|
39492
|
+
return run;
|
|
39493
|
+
}
|
|
39494
|
+
async getFlush(runId, generation, seq) {
|
|
39495
|
+
const flush = this.#s.flushes.get(key(runId, generation, seq));
|
|
39496
|
+
return flush ? structuredClone(flush) : null;
|
|
39497
|
+
}
|
|
39498
|
+
async recordFlush(input) {
|
|
39499
|
+
const run = this.#activeRun(input.runId, input.generation);
|
|
39500
|
+
if (run.lastSeq !== input.seq - 1) throw new KnowledgeImporterRunStateError(input.runId, "seq");
|
|
39501
|
+
const { counts, ...flush } = input;
|
|
39502
|
+
this.#s.flushes.set(key(input.runId, input.generation, input.seq), structuredClone(flush));
|
|
39503
|
+
run.lastSeq = input.seq;
|
|
39504
|
+
run.counts = addCounts(run.counts, counts);
|
|
39505
|
+
}
|
|
39506
|
+
async finishRun(input) {
|
|
39507
|
+
const run = this.#activeRun(input.runId, input.generation);
|
|
39508
|
+
if (run.lastSeq !== input.lastSeq) throw new KnowledgeImporterRunStateError(input.runId, "seq");
|
|
39509
|
+
run.status = input.status;
|
|
39510
|
+
run.finish = structuredClone(input.finish);
|
|
39511
|
+
run.completedAt = /* @__PURE__ */ new Date();
|
|
39512
|
+
return structuredClone(run);
|
|
39513
|
+
}
|
|
39514
|
+
async getNode(bindingId, sourceId) {
|
|
39515
|
+
const node = this.#s.nodes.get(key(bindingId, sourceId));
|
|
39516
|
+
return node ? structuredClone(node) : null;
|
|
39517
|
+
}
|
|
39518
|
+
async getNodeByPage(pageId) {
|
|
39519
|
+
const node = [...this.#s.nodes.values()].find((n) => n.pageId === pageId);
|
|
39520
|
+
return node ? structuredClone(node) : null;
|
|
39521
|
+
}
|
|
39522
|
+
async saveNode(node) {
|
|
39523
|
+
const owner = [...this.#s.nodes.values()].find((n) => n.pageId === node.pageId);
|
|
39524
|
+
if (owner && (owner.bindingId !== node.bindingId || owner.sourceId !== node.sourceId)) throw new Error(`Knowledge page ${node.pageId} is already mapped to another imported node`);
|
|
39525
|
+
this.#s.nodes.set(key(node.bindingId, node.sourceId), structuredClone({
|
|
39526
|
+
...node,
|
|
39527
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
39528
|
+
}));
|
|
39529
|
+
}
|
|
39530
|
+
async deleteNode(bindingId, sourceId) {
|
|
39531
|
+
this.#s.nodes.delete(key(bindingId, sourceId));
|
|
39532
|
+
}
|
|
39533
|
+
async listNodes(bindingId, options = {}) {
|
|
39534
|
+
const limit = options.limit ?? 500;
|
|
39535
|
+
const nodes = [...this.#s.nodes.values()].filter((n) => n.bindingId === bindingId && (options.after === void 0 || byteOrder(n.sourceId, options.after) > 0) && (!options.unsettled || n.unsettled)).sort((a, b) => byteOrder(a.sourceId, b.sourceId));
|
|
39536
|
+
const items = nodes.slice(0, limit).map((n) => structuredClone(n));
|
|
39537
|
+
return {
|
|
39538
|
+
items,
|
|
39539
|
+
next: nodes.length > limit ? items[items.length - 1].sourceId : null
|
|
39540
|
+
};
|
|
39541
|
+
}
|
|
39542
|
+
#linking(bindingId, targetSourceIds) {
|
|
39543
|
+
const targets = new Set(targetSourceIds);
|
|
39544
|
+
return [...this.#s.nodes.values()].filter((n) => n.bindingId === bindingId && n.links.some((link) => targets.has(link.sourceId)));
|
|
39545
|
+
}
|
|
39546
|
+
async listLinkingNodes(bindingId, targetSourceIds, options = {}) {
|
|
39547
|
+
const limit = options.limit ?? 500;
|
|
39548
|
+
const ids = this.#linking(bindingId, targetSourceIds).map((n) => n.sourceId).filter((id) => options.after === void 0 || byteOrder(id, options.after) > 0).sort(byteOrder);
|
|
39549
|
+
const items = ids.slice(0, limit);
|
|
39550
|
+
return {
|
|
39551
|
+
items,
|
|
39552
|
+
next: ids.length > limit ? items[items.length - 1] : null
|
|
39553
|
+
};
|
|
39554
|
+
}
|
|
39555
|
+
async markLinkingNodesUnsettled(bindingId, targetSourceIds) {
|
|
39556
|
+
for (const n of this.#linking(bindingId, targetSourceIds)) n.unsettled = true;
|
|
39557
|
+
}
|
|
39558
|
+
async findNodeByAlias(bindingId, alias) {
|
|
39559
|
+
const node = [...this.#s.nodes.values()].find((n) => n.bindingId === bindingId && n.aliases.includes(alias));
|
|
39560
|
+
return node ? structuredClone(node) : null;
|
|
39561
|
+
}
|
|
39562
|
+
async getState(bindingId) {
|
|
39563
|
+
const out = {};
|
|
39564
|
+
for (const [name, value] of this.#s.state.get(bindingId) ?? []) Object.defineProperty(out, name, {
|
|
39565
|
+
value,
|
|
39566
|
+
enumerable: true,
|
|
39567
|
+
writable: true,
|
|
39568
|
+
configurable: true
|
|
39569
|
+
});
|
|
39570
|
+
return out;
|
|
39571
|
+
}
|
|
39572
|
+
async setState(bindingId, state) {
|
|
39573
|
+
const stored = this.#s.state.get(bindingId) ?? /* @__PURE__ */ new Map();
|
|
39574
|
+
for (const name of Object.keys(state)) stored.set(name, state[name]);
|
|
39575
|
+
this.#s.state.set(bindingId, stored);
|
|
39576
|
+
}
|
|
39577
|
+
async recordRunChange(change) {
|
|
39578
|
+
const id = key(change.runId, change.sourceId);
|
|
39579
|
+
const order = this.#s.changes.get(id)?.order ?? ++this.#s.order;
|
|
39580
|
+
this.#s.changes.set(id, {
|
|
39581
|
+
order,
|
|
39582
|
+
change: structuredClone(change)
|
|
39583
|
+
});
|
|
39584
|
+
}
|
|
39585
|
+
async listRunChanges(runId, options = {}) {
|
|
39586
|
+
const limit = options.limit ?? 500;
|
|
39587
|
+
const after = options.after === void 0 ? 0 : Number(options.after);
|
|
39588
|
+
const rows = [...this.#s.changes.values()].filter((c) => c.change.runId === runId && c.order > after).sort((a, b) => a.order - b.order);
|
|
39589
|
+
const page = rows.slice(0, limit);
|
|
39590
|
+
return {
|
|
39591
|
+
items: page.map((c) => structuredClone(c.change)),
|
|
39592
|
+
next: rows.length > limit ? String(page[page.length - 1].order) : null
|
|
39593
|
+
};
|
|
39594
|
+
}
|
|
39595
|
+
async readWriterGuard() {
|
|
39596
|
+
return { ...this.#s.guard };
|
|
39597
|
+
}
|
|
39598
|
+
async lockWriterGuard(_mode) {
|
|
39599
|
+
return { ...this.#s.guard };
|
|
39600
|
+
}
|
|
39601
|
+
/** Transactions are serialized here, so holding one is the lock. */
|
|
39602
|
+
async markFirstWrite() {
|
|
39603
|
+
if (this.#s.guard.firstWriteAt) return false;
|
|
39604
|
+
this.#s.guard.firstWriteAt = /* @__PURE__ */ new Date();
|
|
39605
|
+
return true;
|
|
39606
|
+
}
|
|
39607
|
+
async advanceWriterGuard(input) {
|
|
39608
|
+
if (input.generation <= this.#s.guard.generation) throw new Error(`Knowledge importer writer generation must move forward (${this.#s.guard.generation} -> ${input.generation})`);
|
|
39609
|
+
this.#s.guard = {
|
|
39610
|
+
activePath: input.activePath,
|
|
39611
|
+
generation: input.generation,
|
|
39612
|
+
firstWriteAt: null
|
|
39613
|
+
};
|
|
39614
|
+
return { ...this.#s.guard };
|
|
39615
|
+
}
|
|
39616
|
+
};
|
|
39184
39617
|
// src/storage/domains/knowledge/pages-inmemory.ts
|
|
39185
39618
|
const DEFAULT_SEARCH_LIMIT = 20;
|
|
39186
39619
|
function pageSize(limit) {
|
|
@@ -39189,8 +39622,9 @@ function pageSize(limit) {
|
|
|
39189
39622
|
return Math.min(limit, 100);
|
|
39190
39623
|
}
|
|
39191
39624
|
function paginate(items, cursor, limit) {
|
|
39625
|
+
if (cursor !== void 0 && !/^(0|[1-9]\d*)$/.test(cursor)) throw new KnowledgeInvalidCursorError(cursor);
|
|
39192
39626
|
const start = cursor === void 0 ? 0 : Number(cursor);
|
|
39193
|
-
if (!Number.
|
|
39627
|
+
if (!Number.isSafeInteger(start)) throw new KnowledgeInvalidCursorError(String(cursor));
|
|
39194
39628
|
const size = pageSize(limit);
|
|
39195
39629
|
return {
|
|
39196
39630
|
items: items.slice(start, start + size),
|
|
@@ -39205,12 +39639,6 @@ const oldestFirst = (a, b) => newestFirst(b, a);
|
|
|
39205
39639
|
const clone$1 = (value) => structuredClone(value);
|
|
39206
39640
|
const PIN_KINDS = ["page", "list"];
|
|
39207
39641
|
const pinKey = (pageId, kind) => `${kind}:${pageId}`;
|
|
39208
|
-
/**
|
|
39209
|
-
* In-memory schema-4 page store: the reference implementation of {@link KnowledgePageStore} that the
|
|
39210
|
-
* shared contract suite checks every adapter against.
|
|
39211
|
-
*
|
|
39212
|
-
* @experimental
|
|
39213
|
-
*/
|
|
39214
39642
|
var InMemoryKnowledgePageStore = class {
|
|
39215
39643
|
#pages = /* @__PURE__ */ new Map();
|
|
39216
39644
|
#notes = /* @__PURE__ */ new Map();
|
|
@@ -39218,6 +39646,25 @@ var InMemoryKnowledgePageStore = class {
|
|
|
39218
39646
|
#activity = [];
|
|
39219
39647
|
#bodyLinks = /* @__PURE__ */ new Map();
|
|
39220
39648
|
#clock = 0;
|
|
39649
|
+
/** A deep copy of every page, note, pin, body link and event, for {@link restore}. */
|
|
39650
|
+
snapshot() {
|
|
39651
|
+
return structuredClone({
|
|
39652
|
+
pages: this.#pages,
|
|
39653
|
+
notes: this.#notes,
|
|
39654
|
+
pins: this.#pins,
|
|
39655
|
+
activity: this.#activity,
|
|
39656
|
+
bodyLinks: this.#bodyLinks
|
|
39657
|
+
});
|
|
39658
|
+
}
|
|
39659
|
+
/** Puts back what {@link snapshot} copied. */
|
|
39660
|
+
restore(snapshot) {
|
|
39661
|
+
const copy = structuredClone(snapshot);
|
|
39662
|
+
this.#pages = copy.pages;
|
|
39663
|
+
this.#notes = copy.notes;
|
|
39664
|
+
this.#pins = copy.pins;
|
|
39665
|
+
this.#activity = copy.activity;
|
|
39666
|
+
this.#bodyLinks = copy.bodyLinks;
|
|
39667
|
+
}
|
|
39221
39668
|
/** Drops every page, note, pin, body link and event. */
|
|
39222
39669
|
clear() {
|
|
39223
39670
|
this.#pages.clear();
|
|
@@ -39918,6 +40365,10 @@ var InMemoryKnowledgePageStore = class {
|
|
|
39918
40365
|
// src/storage/domains/knowledge/inmemory.ts
|
|
39919
40366
|
var InMemoryKnowledgeStorage = class extends KnowledgeStorage {
|
|
39920
40367
|
#pageStore = new InMemoryKnowledgePageStore();
|
|
40368
|
+
#importers = new InMemoryKnowledgeImportersStorage();
|
|
40369
|
+
get importers() {
|
|
40370
|
+
return this.#importers;
|
|
40371
|
+
}
|
|
39921
40372
|
materializeScope(input) {
|
|
39922
40373
|
return this.#pageStore.materializeScope(input);
|
|
39923
40374
|
}
|
|
@@ -40023,9 +40474,41 @@ var InMemoryKnowledgeStorage = class extends KnowledgeStorage {
|
|
|
40023
40474
|
listPins(input) {
|
|
40024
40475
|
return this.#pageStore.listPins(input);
|
|
40025
40476
|
}
|
|
40477
|
+
#transactionTail = Promise.resolve();
|
|
40026
40478
|
constructor(_config) {
|
|
40027
40479
|
super();
|
|
40028
40480
|
}
|
|
40481
|
+
/**
|
|
40482
|
+
* In memory there is no second connection: transactions run one at a time and roll back by
|
|
40483
|
+
* restoring a snapshot of pages and importer rows, and a read on this store (or a write from
|
|
40484
|
+
* outside the transaction) while one runs sees and shares its state: an outside write made during
|
|
40485
|
+
* a transaction that rolls back is rolled back with it. Each store call
|
|
40486
|
+
* on the view, and each nested `transaction`, undoes its own writes when it fails.
|
|
40487
|
+
*/
|
|
40488
|
+
transaction(operation) {
|
|
40489
|
+
const run = this.#transactionTail.then(() => this.#savepoint(() => operation(this.#view())));
|
|
40490
|
+
this.#transactionTail = run.catch(() => void 0);
|
|
40491
|
+
return run;
|
|
40492
|
+
}
|
|
40493
|
+
async #savepoint(operation) {
|
|
40494
|
+
const before = this.#pageStore.snapshot();
|
|
40495
|
+
const importersBefore = this.#importers.snapshot();
|
|
40496
|
+
try {
|
|
40497
|
+
return await operation();
|
|
40498
|
+
} catch (error) {
|
|
40499
|
+
this.#pageStore.restore(before);
|
|
40500
|
+
this.#importers.restore(importersBefore);
|
|
40501
|
+
throw error;
|
|
40502
|
+
}
|
|
40503
|
+
}
|
|
40504
|
+
#view() {
|
|
40505
|
+
return new Proxy(this, { get: (target, property, receiver) => {
|
|
40506
|
+
if (property === "transaction") return (operation) => target.#savepoint(() => operation(receiver));
|
|
40507
|
+
const value = Reflect.get(target, property, target);
|
|
40508
|
+
if (typeof value !== "function" || !(property in target.#pageStore)) return value;
|
|
40509
|
+
return (...args) => target.#savepoint(() => value.apply(target, args));
|
|
40510
|
+
} });
|
|
40511
|
+
}
|
|
40029
40512
|
getCapabilities() {
|
|
40030
40513
|
return {
|
|
40031
40514
|
contractVersion: 4,
|
|
@@ -40033,6 +40516,7 @@ var InMemoryKnowledgeStorage = class extends KnowledgeStorage {
|
|
|
40033
40516
|
supportsSchemaInspection: true,
|
|
40034
40517
|
supportsExplicitReset: true,
|
|
40035
40518
|
supportsPinKinds: true,
|
|
40519
|
+
supportsTransactions: true,
|
|
40036
40520
|
supportsActivityDateRange: true
|
|
40037
40521
|
};
|
|
40038
40522
|
}
|
|
@@ -40044,6 +40528,7 @@ var InMemoryKnowledgeStorage = class extends KnowledgeStorage {
|
|
|
40044
40528
|
}
|
|
40045
40529
|
async dangerouslyReset() {
|
|
40046
40530
|
await this.dangerouslyClearAll();
|
|
40531
|
+
this.#importers.clearOnReset();
|
|
40047
40532
|
}
|
|
40048
40533
|
async dangerouslyClearAll() {
|
|
40049
40534
|
this.#pageStore.clear();
|
|
@@ -45180,7 +45665,14 @@ var MessageHistory = class {
|
|
|
45180
45665
|
const persistenceMessageList = messageList.cloneForPersistence();
|
|
45181
45666
|
const newInput = persistenceMessageList.get.input.db();
|
|
45182
45667
|
const newOutput = persistenceMessageList.get.response.db();
|
|
45183
|
-
const
|
|
45668
|
+
const resaveIds = new Set(persistenceMessageList.getMessagesToResave().map((message) => message.id));
|
|
45669
|
+
const newIds = new Set([...newInput, ...newOutput].map((message) => message.id));
|
|
45670
|
+
const resaved = persistenceMessageList.get.all.db().filter((message) => resaveIds.has(message.id) && !newIds.has(message.id));
|
|
45671
|
+
const messagesToSave = persistenceMessageList.transformMessagesForTranscript([
|
|
45672
|
+
...newInput,
|
|
45673
|
+
...newOutput,
|
|
45674
|
+
...resaved
|
|
45675
|
+
]);
|
|
45184
45676
|
if (messagesToSave.length === 0) return messageList;
|
|
45185
45677
|
this.memorySpan(observabilityContext)?.update({ attributes: { messageCount: messagesToSave.length } });
|
|
45186
45678
|
await this.persistMessages({
|
|
@@ -51076,14 +51568,16 @@ async function storedAttachmentBytes(fs, dir, root = true) {
|
|
|
51076
51568
|
return total;
|
|
51077
51569
|
}
|
|
51078
51570
|
// src/knowledge/instructions.ts
|
|
51079
|
-
|
|
51571
|
+
function readInstructions(canEdit) {
|
|
51572
|
+
return `Use the Knowledge tools for durable, shared knowledge. Pinned knowledge pages may already be in your context if <pinned-knowledge> tags are present in the visible conversation history: answer from their bodies without searching for or reading them again${canEdit ? ", and edit one straight from its body and the version shown, unless its body was cut off: then read it first, since a write replaces the whole body" : ""}. Read a pinned page with knowledge_read only when the answer depends on what its notes say, or on its child pages; a note count alone is no reason to read it. For anything else, search with knowledge_search before answering from Knowledge, and read a page with knowledge_read before relying on it. To see how a scope or section is organized, list it with knowledge_list and read pages by the refs it gives. Read a page whole first; when its body is too long, it comes back as its headings with line numbers and the first lines under each: read the section you need, or match the terms you are looking for. A result's more says what it left out: follow it only when what you need is not already in what you have read, and answer as soon as you have it. Cite the page or note you used. When nothing is found, say so plainly instead of guessing. When notes disagree, show both with their dates.`;
|
|
51573
|
+
}
|
|
51080
51574
|
const KNOWLEDGE_WRITE_INSTRUCTIONS = `When you write to Knowledge, add one durable fact per note with knowledge_note, on the page it is about. Add notes to an existing page before creating a new one. Put long-form text such as specs and runbooks in a page body with knowledge_page. A body write replaces the whole body. When a read returns only part of a body (numbered lines from a long page, a section, or matches), each part comes with its range: to edit those lines, write the new text, without the line numbers, with that range (or a smaller one inside it) and the version you read, and only those lines are replaced. Never write a partial body back without its range. Write page bodies in markdown (headings, lists, links); notes may use inline markdown such as links and code. Record a change as a new dated note rather than rewriting an old one, and remove only notes that are wrong.`;
|
|
51081
51575
|
const KNOWLEDGE_PINS_INSTRUCTIONS = `Maintain pinned pages with knowledge_pin (op pin or unpin). Pinned pages are delivered to the main agent on every turn, so they cost tokens permanently and must stay short. Pin only knowledge that should apply without being asked for, such as standing instructions, durable preferences, and hard constraints. Pin only knowledge that is BOTH costly to rediscover AND not the kind of thing a future agent would think to search for; anything a reminder can surface on demand does not belong in the pin set. Unpin a page as soon as it stops being unconditionally true.`;
|
|
51082
51576
|
function buildKnowledgeInstructions(groups, option) {
|
|
51083
51577
|
if (option === false) return "";
|
|
51084
51578
|
if (typeof option === "string") return option;
|
|
51085
51579
|
const parts = {
|
|
51086
|
-
read: groups.read ?
|
|
51580
|
+
read: groups.read ? readInstructions(groups.write) : "",
|
|
51087
51581
|
write: groups.write ? KNOWLEDGE_WRITE_INSTRUCTIONS : "",
|
|
51088
51582
|
pins: groups.pins ? KNOWLEDGE_PINS_INSTRUCTIONS : ""
|
|
51089
51583
|
};
|
|
@@ -51869,6 +52363,17 @@ async function knowledgeSubtree(storage, root) {
|
|
|
51869
52363
|
*/
|
|
51870
52364
|
const MAX_KNOWLEDGE_LINK_REFRESH_NAMESAKES = 99;
|
|
51871
52365
|
/**
|
|
52366
|
+
* A link refresh that landed but stopped at {@link MAX_KNOWLEDGE_LINK_REFRESH_SOURCES} linking pages
|
|
52367
|
+
* or {@link MAX_KNOWLEDGE_LINK_REFRESH_NAMESAKES} namesakes: the rest keep their links until they're
|
|
52368
|
+
* next written or `knowledge.reindexLinks()` runs.
|
|
52369
|
+
*/
|
|
52370
|
+
var KnowledgeLinkRefreshIncompleteError = class extends Error {
|
|
52371
|
+
constructor(message) {
|
|
52372
|
+
super(message);
|
|
52373
|
+
this.name = "KnowledgeLinkRefreshIncompleteError";
|
|
52374
|
+
}
|
|
52375
|
+
};
|
|
52376
|
+
/**
|
|
51872
52377
|
* Re-resolves the pages whose body links one of `pages` or names a ref one of them answers to now,
|
|
51873
52378
|
* after they were created, renamed, moved, merged or deleted, in page id order up to
|
|
51874
52379
|
* {@link MAX_KNOWLEDGE_LINK_REFRESH_SOURCES}. With `withDescendants`, the pages' subtrees count too
|
|
@@ -51898,7 +52403,7 @@ async function refreshKnowledgeLinksTo(storage, pages, options = {}) {
|
|
|
51898
52403
|
refs: [...refs],
|
|
51899
52404
|
toPageIds: [...targets]
|
|
51900
52405
|
})).sort();
|
|
51901
|
-
const crowdedError = () =>
|
|
52406
|
+
const crowdedError = () => new KnowledgeLinkRefreshIncompleteError(`More than ${MAX_KNOWLEDGE_LINK_REFRESH_NAMESAKES} pages are named ${crowded.join(", ")}; links to the rest were left as they were`);
|
|
51902
52407
|
if (!sources.length) {
|
|
51903
52408
|
if (crowded.length) throw crowdedError();
|
|
51904
52409
|
return;
|
|
@@ -51921,10 +52426,7 @@ async function refreshKnowledgeLinksTo(storage, pages, options = {}) {
|
|
|
51921
52426
|
done++;
|
|
51922
52427
|
}
|
|
51923
52428
|
const left = sources.length - done;
|
|
51924
|
-
if (left > 0) {
|
|
51925
|
-
const names = pages.map((page) => `"${page.name}"`).join(", ");
|
|
51926
|
-
throw new Error(`${left} more pages link to ${names}; their links were left as they were`);
|
|
51927
|
-
}
|
|
52429
|
+
if (left > 0) throw new KnowledgeLinkRefreshIncompleteError(`${left} more pages link to ${pages.map((page) => `"${page.name}"`).join(", ")}; their links were left as they were`);
|
|
51928
52430
|
if (crowded.length) throw crowdedError();
|
|
51929
52431
|
}
|
|
51930
52432
|
/**
|
|
@@ -61128,12 +61630,13 @@ async function removeKnowledgePage(host, input) {
|
|
|
61128
61630
|
await host.runtime.checkDeclarations();
|
|
61129
61631
|
const storage = await host.getStorage();
|
|
61130
61632
|
const [scope] = await storage.getScopesByAddress([input.scope]);
|
|
61131
|
-
|
|
61132
|
-
const page = await storage.getPageByPath({
|
|
61633
|
+
const page = scope ? await storage.getPageByPath({
|
|
61133
61634
|
scopeId: scope.id,
|
|
61134
61635
|
path: keys,
|
|
61135
61636
|
read: "all"
|
|
61136
|
-
});
|
|
61637
|
+
}) : null;
|
|
61638
|
+
const expected = input.expected;
|
|
61639
|
+
if (expected && (page?.id !== expected.id || page.version !== expected.version)) throw new KnowledgeConflictError(expected.id);
|
|
61137
61640
|
if (!page) return null;
|
|
61138
61641
|
const template = await host.runtime.templatePageRef(page);
|
|
61139
61642
|
if (template) throw new Error(`"${template}" is declared in config; change the scope's pages to remove it.`);
|
|
@@ -61145,6 +61648,7 @@ async function removeKnowledgePage(host, input) {
|
|
|
61145
61648
|
deletedBy: input.author ?? "host"
|
|
61146
61649
|
});
|
|
61147
61650
|
} catch (error) {
|
|
61651
|
+
if (expected && error?.name === "KnowledgeNotFoundError") throw new KnowledgeConflictError(expected.id);
|
|
61148
61652
|
if (error?.name === "KnowledgePageHasChildrenError") throw new Error(`"${input.scope}#${input.path}" has child pages; remove them first.`);
|
|
61149
61653
|
throw error;
|
|
61150
61654
|
}
|
|
@@ -61845,7 +62349,7 @@ function bodyView(body, input) {
|
|
|
61845
62349
|
const headings = knowledgeBodyOutline(body);
|
|
61846
62350
|
const skeleton = headings.length ? knowledgeBodySkeleton(lines, headings.map((heading) => heading.line), input.maxTokens) : void 0;
|
|
61847
62351
|
if (skeleton !== void 0) {
|
|
61848
|
-
more.push(`body: the page is ${lines.count} lines, too long to show whole, so \`lines\` shows every heading and the first lines under it; \u22EF marks lines left out and \u2026 a line cut short. Read the part you need with section (a heading) or from (a line number), then answer. To edit, read that part first: this view has no range to write back
|
|
62352
|
+
more.push(`body: the page is ${lines.count} lines, too long to show whole, so \`lines\` shows every heading and the first lines under it; \u22EF marks lines left out and \u2026 a line cut short. Read the part you need with section (a heading) or from (a line number), then answer.${input.canEdit ? " To edit, read that part first: this view has no range to write back." : ""}`);
|
|
61849
62353
|
return {
|
|
61850
62354
|
lines: skeleton,
|
|
61851
62355
|
lineCount: lines.count
|
|
@@ -61875,10 +62379,10 @@ function bodyView(body, input) {
|
|
|
61875
62379
|
...outline.length ? { outline } : {}
|
|
61876
62380
|
};
|
|
61877
62381
|
}
|
|
61878
|
-
function readTool(host) {
|
|
62382
|
+
function readTool(host, canEdit) {
|
|
61879
62383
|
return createTool({
|
|
61880
62384
|
id: "knowledge_read",
|
|
61881
|
-
description: `Read a page: its body, its notes, its child pages and the notes on other pages that mention it. Read a scope address (org:acme) to browse that scope. Without \`page\`, lists the scopes this run holds. When a page's notes, or the notes mentioning it, come to more than ${KNOWLEDGE_READ_INLINE_TOKENS.toLocaleString("en-US")} tokens, a whole read leaves them out and counts them in \`more\`; read them on their own with \`notes\` or \`mentionedIn\`. A body returns at most ${maxTokensOf(host).toLocaleString("en-US")} tokens at a time. A body that fits comes whole as \`body\`; a longer one comes as numbered \`lines\` (\`12\u2502text\`) with the \`range\` they cover, and \`more\` says where to read on; a first read of a long page shows every heading with its line number and the first lines under it, so you can pick the part to read. For a long page, ask for its \`outline\` of headings with their line numbers, read one \`section\`, or \`match\` terms to see only the lines that contain them, with \`context\` lines around each. Those part reads return just that part of the body
|
|
62385
|
+
description: `Read a page: its body, its notes, its child pages and the notes on other pages that mention it. Read a scope address (org:acme) to browse that scope. Without \`page\`, lists the scopes this run holds. When a page's notes, or the notes mentioning it, come to more than ${KNOWLEDGE_READ_INLINE_TOKENS.toLocaleString("en-US")} tokens, a whole read leaves them out and counts them in \`more\`; read them on their own with \`notes\` or \`mentionedIn\`. A body returns at most ${maxTokensOf(host).toLocaleString("en-US")} tokens at a time. A body that fits comes whole as \`body\`; a longer one comes as numbered \`lines\` (\`12\u2502text\`) with the \`range\` they cover, and \`more\` says where to read on; a first read of a long page shows every heading with its line number and the first lines under it, so you can pick the part to read. For a long page, ask for its \`outline\` of headings with their line numbers, read one \`section\`, or \`match\` terms to see only the lines that contain them, with \`context\` lines around each. Those part reads return just that part of the body.` + (canEdit ? " To edit part of a long body, pass the `range` a read gave you to knowledge_page." : ""),
|
|
61882
62386
|
inputSchema: {
|
|
61883
62387
|
type: "object",
|
|
61884
62388
|
properties: {
|
|
@@ -61975,7 +62479,8 @@ function readTool(host) {
|
|
|
61975
62479
|
context: matchContext,
|
|
61976
62480
|
from,
|
|
61977
62481
|
more,
|
|
61978
|
-
maxTokens: maxTokensOf(host)
|
|
62482
|
+
maxTokens: maxTokensOf(host),
|
|
62483
|
+
canEdit
|
|
61979
62484
|
});
|
|
61980
62485
|
return {
|
|
61981
62486
|
page: {
|
|
@@ -62078,7 +62583,8 @@ function readTool(host) {
|
|
|
62078
62583
|
const view = bodyView(page.body ?? "", {
|
|
62079
62584
|
context: matchContext,
|
|
62080
62585
|
more,
|
|
62081
|
-
maxTokens: maxTokensOf(host)
|
|
62586
|
+
maxTokens: maxTokensOf(host),
|
|
62587
|
+
canEdit
|
|
62082
62588
|
});
|
|
62083
62589
|
const noteList = await noteSummaries(run, notes.notes, mentionCache);
|
|
62084
62590
|
const mentionList = (await noteSummaries(run, mentioning.notes, mentionCache)).map((note, i) => ({
|
|
@@ -62359,11 +62865,12 @@ const NUMBERED_LINE = /^\s*\d+\u2502/;
|
|
|
62359
62865
|
* Without one, a body longer than one read returns is refused: the writer can only have seen part
|
|
62360
62866
|
* of it, and writing that part back would drop the rest.
|
|
62361
62867
|
*/
|
|
62362
|
-
function writtenBody(args, page, maxTokens) {
|
|
62868
|
+
function writtenBody(args, page, maxTokens, canRead) {
|
|
62869
|
+
const read = canRead ? "knowledge_read" : "read";
|
|
62363
62870
|
const stored = page.body ?? "";
|
|
62364
62871
|
if (args.body !== void 0) {
|
|
62365
62872
|
const written = args.body.split("\n").filter((line) => line.trim());
|
|
62366
|
-
if (written.length && written.every((line) => NUMBERED_LINE.test(line))) throw new Error(
|
|
62873
|
+
if (written.length && written.every((line) => NUMBERED_LINE.test(line))) throw new Error(`This body still has the line numbers a ${read} put in front of each line ("12\u2502"). Write the text without them.`);
|
|
62367
62874
|
}
|
|
62368
62875
|
if (args.range) {
|
|
62369
62876
|
if (args.body === void 0) throw new Error("range needs body: the text that replaces those lines.");
|
|
@@ -62372,18 +62879,18 @@ function writtenBody(args, page, maxTokens) {
|
|
|
62372
62879
|
const lines = new KnowledgeBodyLines(stored);
|
|
62373
62880
|
let start = lines.startOffset(args.range.start);
|
|
62374
62881
|
let end = lines.endOffset(args.range.end);
|
|
62375
|
-
if (start > end) throw new Error(`The range starts after it ends. Pass the range a
|
|
62376
|
-
if (end > knowledgeBodyWindow(lines, start, stored.length, maxTokens).end) throw new Error(`Lines ${args.range.start.line}\u2013${args.range.end.line} run past what one
|
|
62882
|
+
if (start > end) throw new Error(`The range starts after it ends. Pass the range a ${read} returned.`);
|
|
62883
|
+
if (end > knowledgeBodyWindow(lines, start, stored.length, maxTokens).end) throw new Error(`Lines ${args.range.start.line}\u2013${args.range.end.line} run past what one ${read} from line ${args.range.start.line} shows, so this can't be a range a read gave you. Edit the body part by part: write each part back with the range its own read returned.`);
|
|
62377
62884
|
if (args.range.start.col === void 0 && args.range.end.col === void 0 && args.body === "") {
|
|
62378
62885
|
if (end < stored.length) end++;
|
|
62379
62886
|
else if (start > 0) start--;
|
|
62380
62887
|
}
|
|
62381
62888
|
return stored.slice(0, start) + args.body + stored.slice(end);
|
|
62382
62889
|
}
|
|
62383
|
-
if (args.body !== void 0 && estimateTokenCount(stored) > maxTokens) throw new Error(`This page's body is ${stored.length} characters, more than one
|
|
62890
|
+
if (args.body !== void 0 && estimateTokenCount(stored) > maxTokens) throw new Error(`This page's body is ${stored.length} characters, more than one ${read} returns, and a body write without a range replaces all of it. ` + (canRead ? "Write back only the lines you read, with the range that read returned and its expectedVersion; read other parts with from, section or match and write each back with its own range." : "Without a read there is no range to write it back with, so leave this page unchanged."));
|
|
62384
62891
|
return args.body;
|
|
62385
62892
|
}
|
|
62386
|
-
function pageTool(host) {
|
|
62893
|
+
function pageTool(host, canRead) {
|
|
62387
62894
|
return createTool({
|
|
62388
62895
|
id: "knowledge_page",
|
|
62389
62896
|
description: "Write, move, merge or delete pages. A page body is the curated summary of its topic (needs editor to change); discrete attributed details belong in notes (knowledge_note). op \"write\": with `page`, edits that page (name, description, body; a scope page takes body only); without `page`, creates a page named `name` in `scope`. op \"move\": moves `page` under `parent` or to the top of `scope`. op \"merge\": merges `page` into `into`, keeping both pages' notes. op \"delete\": deletes `page` (needs owner on its scope); a page with child pages, a scope page and a page declared in config can't be deleted. `scope` is only for where content lands (create, move destination); edits and merges take none. Pages declared in config can be edited and merged into, but not moved, merged away or deleted.",
|
|
@@ -62438,7 +62945,7 @@ function pageTool(host) {
|
|
|
62438
62945
|
},
|
|
62439
62946
|
range: {
|
|
62440
62947
|
type: "object",
|
|
62441
|
-
description:
|
|
62948
|
+
description: `Edit: a range a ${canRead ? "knowledge_read" : "read"} returned (or part of one), e.g. {"start": {"line": 12}, "end": {"line": 14}}. \`body\` then replaces lines 12 through 14; an empty body removes them. A \`col\` limits it to part of a very long line. Needs expectedVersion.`,
|
|
62442
62949
|
properties: {
|
|
62443
62950
|
start: linePositionSchema,
|
|
62444
62951
|
end: linePositionSchema
|
|
@@ -62475,7 +62982,7 @@ function pageTool(host) {
|
|
|
62475
62982
|
expectedVersion: args.expectedVersion ?? page.version,
|
|
62476
62983
|
name: args.name,
|
|
62477
62984
|
description: args.description,
|
|
62478
|
-
body: writtenBody(args, page, maxTokensOf(host)),
|
|
62985
|
+
body: writtenBody(args, page, maxTokensOf(host), canRead),
|
|
62479
62986
|
provenance
|
|
62480
62987
|
});
|
|
62481
62988
|
await embed(host, (index) => index.indexPage(updated), pageEmbedFailed(storage, updated));
|
|
@@ -62675,10 +63182,10 @@ function noteTool(host) {
|
|
|
62675
63182
|
}
|
|
62676
63183
|
});
|
|
62677
63184
|
}
|
|
62678
|
-
function pinTool(host, onChange) {
|
|
63185
|
+
function pinTool(host, canRead, onChange) {
|
|
62679
63186
|
return createTool({
|
|
62680
63187
|
id: "knowledge_pin",
|
|
62681
|
-
description:
|
|
63188
|
+
description: `Pin a page into the context of every run holding one of the audience scopes, every turn; or unpin it. With kind "list", pin a listing of the pages under it instead (refs, names and child counts, ${canRead ? "like knowledge_list from it, " : ""}\`depth\` levels down), kept current as pages are added, renamed or removed. Pinned pages cost tokens on every turn: pin only standing instructions, durable preferences and hard constraints that apply without being asked for, and listings agents need to find their way. Needs editor on the page's scope and, for each audience, holding it or editor on it. A pinned page is delivered only to runs that can read it, and a listing shows only the pages they can read.`,
|
|
62682
63189
|
inputSchema: {
|
|
62683
63190
|
type: "object",
|
|
62684
63191
|
properties: {
|
|
@@ -62983,14 +63490,14 @@ function buildKnowledgePageTools(host, groups, onPinChange) {
|
|
|
62983
63490
|
if (groups.read) {
|
|
62984
63491
|
tools.knowledge_list = listTool(host);
|
|
62985
63492
|
tools.knowledge_search = searchTool(host);
|
|
62986
|
-
tools.knowledge_read = readTool(host);
|
|
63493
|
+
tools.knowledge_read = readTool(host, groups.write);
|
|
62987
63494
|
tools.knowledge_activity = activityTool(host);
|
|
62988
63495
|
}
|
|
62989
63496
|
if (groups.write) {
|
|
62990
|
-
tools.knowledge_page = pageTool(host);
|
|
63497
|
+
tools.knowledge_page = pageTool(host, groups.read);
|
|
62991
63498
|
tools.knowledge_note = noteTool(host);
|
|
62992
63499
|
}
|
|
62993
|
-
if (groups.pins) tools.knowledge_pin = pinTool(host, onPinChange);
|
|
63500
|
+
if (groups.pins) tools.knowledge_pin = pinTool(host, groups.read, onPinChange);
|
|
62994
63501
|
return tools;
|
|
62995
63502
|
}
|
|
62996
63503
|
// src/knowledge/pinned.ts
|
|
@@ -62998,6 +63505,8 @@ const PINNED_KNOWLEDGE_STATE_ID = "knowledge";
|
|
|
62998
63505
|
const PINNED_SNAPSHOT_TAG = "pinned-knowledge";
|
|
62999
63506
|
const PINNED_DELTA_TAG = "pinned-knowledge-update";
|
|
63000
63507
|
const PIN_TRUNCATION_MARKER = "[truncated \u2014 knowledge_read for the rest]";
|
|
63508
|
+
/** The marker for runs without `knowledge_read`, which can't open the rest. */
|
|
63509
|
+
const PIN_EXCERPT_MARKER = "[truncated]";
|
|
63001
63510
|
/** Entry id of the line listing stored pins that didn't fit the budget. */
|
|
63002
63511
|
const PIN_OVERFLOW_ID = "overflow";
|
|
63003
63512
|
function bindConfigPin(entry, params) {
|
|
@@ -63038,12 +63547,12 @@ async function resolveListing(run, origin, depth, maxTokens) {
|
|
|
63038
63547
|
/**
|
|
63039
63548
|
* Fills `maxTokens` a level at a time: every depth-1 line that fits, then depth 2, and so on, stopping
|
|
63040
63549
|
* at the first line that doesn't fit (always at least one). Lines print in tree order, so each child
|
|
63041
|
-
* still sits under its parent; a cut ends with a pointer to knowledge_list.
|
|
63550
|
+
* still sits under its parent; a cut ends with a pointer to knowledge_list when the run has it.
|
|
63042
63551
|
*/
|
|
63043
|
-
function renderListing(listing, ref, maxTokens) {
|
|
63552
|
+
function renderListing(listing, ref, maxTokens, read) {
|
|
63044
63553
|
const head = `Pages under ${listing.origin.name} (${ref}, depth ${listing.depth}):`;
|
|
63045
63554
|
if (listing.lines.length === 0) return `${head} none.`;
|
|
63046
|
-
const tail = (left) => `\u2026${left > 0 && !listing.more ? `and ${left} more` : "and more"}
|
|
63555
|
+
const tail = (left) => `\u2026${left > 0 && !listing.more ? `and ${left} more` : "and more"}${read ? `; knowledge_list from: "${ref}"` : ""}`;
|
|
63047
63556
|
const all = [
|
|
63048
63557
|
head,
|
|
63049
63558
|
...listing.lines.map((line) => line.text),
|
|
@@ -63069,12 +63578,13 @@ function renderListing(listing, ref, maxTokens) {
|
|
|
63069
63578
|
tail(listing.lines.length - kept.length)
|
|
63070
63579
|
].join("\n");
|
|
63071
63580
|
}
|
|
63072
|
-
function render(page, label, maxTokens) {
|
|
63581
|
+
function render(page, label, maxTokens, read) {
|
|
63073
63582
|
const notes = label.notes === void 0 ? "" : label.notes === 0 ? ", no notes" : label.notes === 1 ? ", 1 note" : `, ${label.notes} notes`;
|
|
63074
63583
|
const text = `${page.name} (${label.ref}, v${page.version}${notes}): ${page.body.trim()}`;
|
|
63075
63584
|
if (estimateTokenCount(text) <= maxTokens) return text;
|
|
63076
|
-
const
|
|
63077
|
-
|
|
63585
|
+
const marker = read ? PIN_TRUNCATION_MARKER : PIN_EXCERPT_MARKER;
|
|
63586
|
+
const room = Math.max(maxTokens - estimateTokenCount(marker) - 1, 1);
|
|
63587
|
+
return `${sliceByTokens(text, 0, room).trimEnd()} ${marker}`;
|
|
63078
63588
|
}
|
|
63079
63589
|
/** The run's principals grouped by `pinnedContextPriority`, highest first. */
|
|
63080
63590
|
function priorityTiers(compiled, principals) {
|
|
@@ -63167,9 +63677,10 @@ async function rankedStoredPins(run, excludePageIds, want) {
|
|
|
63167
63677
|
total
|
|
63168
63678
|
};
|
|
63169
63679
|
}
|
|
63170
|
-
function overflowLine(names, more) {
|
|
63680
|
+
function overflowLine(names, more, read) {
|
|
63171
63681
|
const listed = names.join(", ");
|
|
63172
|
-
|
|
63682
|
+
const rest = more > 0 ? `${listed ? `${listed}, ` : ""}\u2026and ${more} more` : listed;
|
|
63683
|
+
return `Also pinned${read ? " (open with knowledge_read)" : ""}: ${rest}`;
|
|
63173
63684
|
}
|
|
63174
63685
|
/**
|
|
63175
63686
|
* The pinned pages a run receives, rendered: config pins first (always delivered; an equal share each
|
|
@@ -63178,7 +63689,8 @@ function overflowLine(names, more) {
|
|
|
63178
63689
|
* the rest. The line counts against the token budget. Only pages the run can read and that have a body
|
|
63179
63690
|
* are delivered. A run costs a fixed handful of store calls however many pins exist.
|
|
63180
63691
|
*/
|
|
63181
|
-
|
|
63692
|
+
/** `read` is whether the run has `knowledge_read` and `knowledge_list`; without them no entry names either. */
|
|
63693
|
+
async function knowledgeDeliveredPins(run, budget, read) {
|
|
63182
63694
|
const configPinned = await configPins(run, budget.maxTokens);
|
|
63183
63695
|
const configured = configPinned.pages.filter((page) => page.body?.trim());
|
|
63184
63696
|
const listings = configPinned.listings;
|
|
@@ -63216,11 +63728,11 @@ async function knowledgeDeliveredPins(run, budget) {
|
|
|
63216
63728
|
const renderConfig = (room) => {
|
|
63217
63729
|
for (const page of configured) entries.push({
|
|
63218
63730
|
id: page.id,
|
|
63219
|
-
text: render(page, labelOf(page), room)
|
|
63731
|
+
text: render(page, labelOf(page), room, read)
|
|
63220
63732
|
});
|
|
63221
63733
|
for (const listing of listings) entries.push({
|
|
63222
63734
|
id: `${PIN_LIST_ID_PREFIX}${listing.origin.id}`,
|
|
63223
|
-
text: renderListing(listing, listingRef(listing), room)
|
|
63735
|
+
text: renderListing(listing, listingRef(listing), room, read)
|
|
63224
63736
|
});
|
|
63225
63737
|
};
|
|
63226
63738
|
renderConfig(Number.POSITIVE_INFINITY);
|
|
@@ -63242,10 +63754,10 @@ async function knowledgeDeliveredPins(run, budget) {
|
|
|
63242
63754
|
}
|
|
63243
63755
|
const entry = listing ? {
|
|
63244
63756
|
id: `${PIN_LIST_ID_PREFIX}${page.id}`,
|
|
63245
|
-
text: renderListing(listing, listingRef(listing), remaining)
|
|
63757
|
+
text: renderListing(listing, listingRef(listing), remaining, read)
|
|
63246
63758
|
} : {
|
|
63247
63759
|
id: page.id,
|
|
63248
|
-
text: render(page, labelOf(page), remaining)
|
|
63760
|
+
text: render(page, labelOf(page), remaining, read)
|
|
63249
63761
|
};
|
|
63250
63762
|
used += estimateTokenCount(entry.text);
|
|
63251
63763
|
delivered.push({
|
|
@@ -63253,7 +63765,7 @@ async function knowledgeDeliveredPins(run, budget) {
|
|
|
63253
63765
|
pin
|
|
63254
63766
|
});
|
|
63255
63767
|
}
|
|
63256
|
-
const line = () => overflowLine(left.slice(0, 10).map((pin) => pin.kind === "list" ? `${pin.pageName} (listing)` : pin.pageName), total - delivered.length - Math.min(left.length, 10));
|
|
63768
|
+
const line = () => overflowLine(left.slice(0, 10).map((pin) => pin.kind === "list" ? `${pin.pageName} (listing)` : pin.pageName), total - delivered.length - Math.min(left.length, 10), read);
|
|
63257
63769
|
while (total > delivered.length && delivered.length > 0 && used + estimateTokenCount(line()) > budget.maxTokens) {
|
|
63258
63770
|
const dropped = delivered.pop();
|
|
63259
63771
|
used -= estimateTokenCount(dropped.entry.text);
|
|
@@ -63380,12 +63892,17 @@ var PinnedStateProcessor = class {
|
|
|
63380
63892
|
constructor(deps) {
|
|
63381
63893
|
this.deps = deps;
|
|
63382
63894
|
}
|
|
63895
|
+
#guidance() {
|
|
63896
|
+
const write = this.deps.write !== false;
|
|
63897
|
+
if (this.deps.read === false) return write ? " To edit it, write from that body and pass that ref and version to knowledge_page as page and expectedVersion. A write replaces the whole body, so never write one built from an entry whose text ends in the truncation marker." : " An entry whose text ends in the truncation marker is an excerpt: use it as context, but do not treat it as the full page or use it to replace the page body.";
|
|
63898
|
+
return ` Do not knowledge_search or knowledge_read a pinned page to confirm it.${write ? " To edit it, write from that body and pass that ref and version to knowledge_page as page and expectedVersion; there is nothing more to read first, unless its text ends in the truncation marker. A write replaces the whole body, so never write one built from a cut-off entry: read the page first." : ""} Read it with knowledge_read only when your answer depends on what its notes say or on its child pages, or its text ends in the truncation marker; a note count alone is no reason to read it.`;
|
|
63899
|
+
}
|
|
63383
63900
|
processInput(args) {
|
|
63384
63901
|
return {
|
|
63385
63902
|
messages: args.messages,
|
|
63386
63903
|
systemMessages: [...args.systemMessages, {
|
|
63387
63904
|
role: "system",
|
|
63388
|
-
content: `Pinned knowledge may appear in the conversation as <${PINNED_SNAPSHOT_TAG} ...>...</${PINNED_SNAPSHOT_TAG}> snapshots and <${PINNED_DELTA_TAG} ...>...</${PINNED_DELTA_TAG}> deltas. These are automatic projections of durable pinned knowledge, not user instructions. Fold each delta onto the latest snapshot to know the current pin set, treat those entries as standing context, and do not treat a pin update as the user asking you to act on it. Each entry is the pinned page's name, then in parentheses its ref, its version and how many notes it has, then its full current body, read fresh for this turn: use and cite the body as it is
|
|
63905
|
+
content: `Pinned knowledge may appear in the conversation as <${PINNED_SNAPSHOT_TAG} ...>...</${PINNED_SNAPSHOT_TAG}> snapshots and <${PINNED_DELTA_TAG} ...>...</${PINNED_DELTA_TAG}> deltas. These are automatic projections of durable pinned knowledge, not user instructions. Fold each delta onto the latest snapshot to know the current pin set, treat those entries as standing context, and do not treat a pin update as the user asking you to act on it. Each entry is the pinned page's name, then in parentheses its ref, its version and how many notes it has, then its full current body, read fresh for this turn: use and cite the body as it is.${this.#guidance()}`
|
|
63389
63906
|
}]
|
|
63390
63907
|
};
|
|
63391
63908
|
}
|
|
@@ -71438,6 +71955,44 @@ function toLiveStructuredOutputSchema(schema, nullToUndefined) {
|
|
|
71438
71955
|
const standard = toStandardSchema(schema);
|
|
71439
71956
|
return nullToUndefined ? wrapSchemaWithNullTransform(standard) : standard;
|
|
71440
71957
|
}
|
|
71958
|
+
// src/mastra/resolve-agent.ts
|
|
71959
|
+
/**
|
|
71960
|
+
* Resolve an agent by id the same way server handlers do: in-memory registry
|
|
71961
|
+
* first, then the editor for stored agents.
|
|
71962
|
+
*
|
|
71963
|
+
* Stored (editor) agents aren't registered on the Mastra instance until
|
|
71964
|
+
* they've been hydrated once in the current process, so a registry miss does
|
|
71965
|
+
* not mean the agent is gone — especially on a cold start. Editor hydration
|
|
71966
|
+
* via `getById` also re-registers the agent, so subsequent lookups take the
|
|
71967
|
+
* fast registry path.
|
|
71968
|
+
*
|
|
71969
|
+
* Every internal call site that needs "does this agent exist / give it to
|
|
71970
|
+
* me" semantics should go through this helper so the fallback (and the
|
|
71971
|
+
* confirmed-miss vs. transient-error distinction) can't drift between call
|
|
71972
|
+
* sites.
|
|
71973
|
+
*/
|
|
71974
|
+
async function resolveAgentById(mastra, agentId, editorOptions) {
|
|
71975
|
+
try {
|
|
71976
|
+
return {
|
|
71977
|
+
status: "found",
|
|
71978
|
+
agent: mastra.getAgentById(agentId)
|
|
71979
|
+
};
|
|
71980
|
+
} catch {}
|
|
71981
|
+
const editor = mastra.getEditor?.();
|
|
71982
|
+
if (!editor) return { status: "missing" };
|
|
71983
|
+
try {
|
|
71984
|
+
const agent = await editor.agent.getById(agentId, editorOptions);
|
|
71985
|
+
return agent ? {
|
|
71986
|
+
status: "found",
|
|
71987
|
+
agent
|
|
71988
|
+
} : { status: "missing" };
|
|
71989
|
+
} catch (error) {
|
|
71990
|
+
return {
|
|
71991
|
+
status: "error",
|
|
71992
|
+
error
|
|
71993
|
+
};
|
|
71994
|
+
}
|
|
71995
|
+
}
|
|
71441
71996
|
// src/agent/save-queue/index.ts
|
|
71442
71997
|
var SaveQueueManager = class SaveQueueManager {
|
|
71443
71998
|
logger;
|
|
@@ -71693,6 +72248,32 @@ var DurableProcessorRebuildError = class extends Error {
|
|
|
71693
72248
|
this.cause = cause;
|
|
71694
72249
|
}
|
|
71695
72250
|
};
|
|
72251
|
+
/**
|
|
72252
|
+
* The process running a step could not find the run's agent in its registry
|
|
72253
|
+
* or editor. Running on would execute the step with no tools, memory or
|
|
72254
|
+
* processors, so the step fails instead.
|
|
72255
|
+
*/
|
|
72256
|
+
var DurableAgentNotFoundError = class extends Error {
|
|
72257
|
+
constructor(agentId, runId, cause) {
|
|
72258
|
+
super(`[DurableAgent:${agentId}] Agent "${agentId}" is not registered and the editor could not load it, so run ${runId} cannot run here${cause ? `: ${cause instanceof Error ? cause.message : String(cause)}` : ""}`);
|
|
72259
|
+
this.name = "DurableAgentNotFoundError";
|
|
72260
|
+
this.cause = cause;
|
|
72261
|
+
}
|
|
72262
|
+
};
|
|
72263
|
+
async function resolveRunAgent(mastra, agentId, runId, agentVersionId) {
|
|
72264
|
+
const version = agentVersionId ? { versionId: agentVersionId } : void 0;
|
|
72265
|
+
const result = await resolveAgentById(mastra, agentId, version);
|
|
72266
|
+
if (result.status !== "found") throw new DurableAgentNotFoundError(agentId, runId, result.status === "error" ? result.error : void 0);
|
|
72267
|
+
const { agent } = result;
|
|
72268
|
+
if (!version || agent.toRawConfig()?.resolvedVersionId === agentVersionId) return agent;
|
|
72269
|
+
try {
|
|
72270
|
+
const pinned = agent.source === "stored" ? await mastra.getEditor()?.agent.getById(agentId, version) : await mastra.resolveVersionedAgent(agent, version);
|
|
72271
|
+
if (pinned && pinned.toRawConfig()?.resolvedVersionId === version.versionId) return pinned;
|
|
72272
|
+
throw new Error(`Agent version "${agentVersionId}" was not found`);
|
|
72273
|
+
} catch (error) {
|
|
72274
|
+
throw new DurableAgentNotFoundError(agentId, runId, error);
|
|
72275
|
+
}
|
|
72276
|
+
}
|
|
71696
72277
|
async function rebuildProcessorPipeline(options) {
|
|
71697
72278
|
const { agent, agentId, requestContext, emptyErrorProcessorOverride, processorStates, logger } = options;
|
|
71698
72279
|
try {
|
|
@@ -71736,6 +72317,22 @@ function assertToolsetToolsAvailable(tools, toolsetToolNames, agentId, runId) {
|
|
|
71736
72317
|
});
|
|
71737
72318
|
}
|
|
71738
72319
|
/**
|
|
72320
|
+
* The background-task manager and agent config a run dispatches with, resolved
|
|
72321
|
+
* the same way as in preparation.ts. Only the process that started the run has
|
|
72322
|
+
* them on its registry entry, so a worker rebuilding the run restores them here;
|
|
72323
|
+
* without them every background-eligible tool runs inline (#31090).
|
|
72324
|
+
*
|
|
72325
|
+
* Dispatch stays off when the run's options are unknown: the entry keeps the
|
|
72326
|
+
* first manager a rebuild restores, so restoring one ungated could dispatch for
|
|
72327
|
+
* a run that disabled background tasks.
|
|
72328
|
+
*/
|
|
72329
|
+
function resolveBackgroundTasks(mastra, agent, execOptions) {
|
|
72330
|
+
return {
|
|
72331
|
+
backgroundTaskManager: !execOptions || execOptions.disableBackgroundTasks || execOptions.backgroundTaskPolicy?.allowToolDispatch === false ? void 0 : mastra.backgroundTaskManager,
|
|
72332
|
+
backgroundTasksConfig: agent.getBackgroundTasksConfig?.()
|
|
72333
|
+
};
|
|
72334
|
+
}
|
|
72335
|
+
/**
|
|
71739
72336
|
* Resolve all runtime dependencies needed for durable step execution.
|
|
71740
72337
|
*
|
|
71741
72338
|
* This function reconstructs the non-serializable state needed to execute
|
|
@@ -71769,11 +72366,13 @@ async function resolveRuntimeDependencies(options) {
|
|
|
71769
72366
|
let processorStates = globalEntry?.processorStates;
|
|
71770
72367
|
let rehydratedFromMastra = false;
|
|
71771
72368
|
let rebuiltAgent;
|
|
72369
|
+
let backgroundTasks;
|
|
71772
72370
|
if (hasHydratedEntry) logger?.debug?.(`[DurableAgent:${agentId}] Using model and tools from global registry for run ${runId}`);
|
|
71773
72371
|
else if (mastra) try {
|
|
71774
|
-
const agent = mastra.
|
|
72372
|
+
const agent = await resolveRunAgent(mastra, agentId, runId, input.agentVersionId);
|
|
71775
72373
|
rebuiltAgent = isDurableAgentLike(agent) && agent.agent !== agent ? agent.agent : agent;
|
|
71776
72374
|
const resolveRequestContext = restoreRequestContext$1(input.requestContextEntries, options.requestContext);
|
|
72375
|
+
backgroundTasks = resolveBackgroundTasks(mastra, agent, input.options);
|
|
71777
72376
|
tools = await agent.getToolsForExecution({
|
|
71778
72377
|
runId,
|
|
71779
72378
|
threadId: input.state.threadId,
|
|
@@ -71781,7 +72380,9 @@ async function resolveRuntimeDependencies(options) {
|
|
|
71781
72380
|
requestContext: resolveRequestContext,
|
|
71782
72381
|
memoryConfig: input.state.memoryConfig,
|
|
71783
72382
|
autoResumeSuspendedTools: input.options?.autoResumeSuspendedTools,
|
|
71784
|
-
clientTools: input.options?.clientTools
|
|
72383
|
+
clientTools: input.options?.clientTools,
|
|
72384
|
+
backgroundTaskEnabled: Boolean(backgroundTasks.backgroundTaskManager),
|
|
72385
|
+
backgroundTaskPolicy: input.options?.backgroundTaskPolicy
|
|
71785
72386
|
});
|
|
71786
72387
|
assertToolsetToolsAvailable(tools, input.options?.toolsetToolNames, agentId, runId);
|
|
71787
72388
|
model = await agent.getModel?.({ requestContext: resolveRequestContext }) ?? resolveModel(input.modelConfig, mastra);
|
|
@@ -71810,7 +72411,7 @@ async function resolveRuntimeDependencies(options) {
|
|
|
71810
72411
|
processorStates = rebuiltProcessors.processorStates;
|
|
71811
72412
|
rehydratedFromMastra = true;
|
|
71812
72413
|
} catch (error) {
|
|
71813
|
-
if (error instanceof DurableProcessorRebuildError) throw error;
|
|
72414
|
+
if (error instanceof DurableProcessorRebuildError || error instanceof DurableAgentNotFoundError) throw error;
|
|
71814
72415
|
if ((input.options?.toolsetToolNames?.length ?? 0) > 0) throw error;
|
|
71815
72416
|
logger?.debug?.(`[DurableAgent:${agentId}] Failed to get agent from Mastra: ${error}`);
|
|
71816
72417
|
model = resolveModel(input.modelConfig, mastra);
|
|
@@ -71835,7 +72436,8 @@ async function resolveRuntimeDependencies(options) {
|
|
|
71835
72436
|
outputProcessors,
|
|
71836
72437
|
errorProcessors,
|
|
71837
72438
|
processorStates,
|
|
71838
|
-
agent: rebuiltAgent
|
|
72439
|
+
agent: rebuiltAgent,
|
|
72440
|
+
...backgroundTasks
|
|
71839
72441
|
};
|
|
71840
72442
|
if (globalEntry) Object.assign(globalEntry, rebuilt);
|
|
71841
72443
|
else setRunRegistryEntry(runId, rebuilt, mastra);
|
|
@@ -71887,10 +72489,11 @@ async function rebuildRunToolsFromMastra(options) {
|
|
|
71887
72489
|
if (!mastra) return void 0;
|
|
71888
72490
|
let agentResolved = false;
|
|
71889
72491
|
try {
|
|
71890
|
-
const agent = mastra.
|
|
72492
|
+
const agent = await resolveRunAgent(mastra, agentId, runId, options.agentVersionId);
|
|
71891
72493
|
agentResolved = true;
|
|
71892
72494
|
const processorAgent = isDurableAgentLike(agent) && agent.agent !== agent ? agent.agent : agent;
|
|
71893
72495
|
const resolveRequestContext = restoreRequestContext$1(requestContextEntries, requestContext);
|
|
72496
|
+
const backgroundTasks = resolveBackgroundTasks(mastra, agent, execOptions);
|
|
71894
72497
|
const tools = await agent.getToolsForExecution({
|
|
71895
72498
|
runId,
|
|
71896
72499
|
threadId: state.threadId,
|
|
@@ -71898,7 +72501,9 @@ async function rebuildRunToolsFromMastra(options) {
|
|
|
71898
72501
|
requestContext: resolveRequestContext,
|
|
71899
72502
|
memoryConfig: state.memoryConfig,
|
|
71900
72503
|
autoResumeSuspendedTools: execOptions?.autoResumeSuspendedTools,
|
|
71901
|
-
clientTools: execOptions?.clientTools
|
|
72504
|
+
clientTools: execOptions?.clientTools,
|
|
72505
|
+
backgroundTaskEnabled: Boolean(backgroundTasks.backgroundTaskManager),
|
|
72506
|
+
backgroundTaskPolicy: execOptions?.backgroundTaskPolicy
|
|
71902
72507
|
});
|
|
71903
72508
|
if (!isHydratedRegistryEntry(getRunRegistryEntry(runId, mastra))) assertToolsetToolsAvailable(tools, execOptions?.toolsetToolNames, agentId, runId);
|
|
71904
72509
|
const memory = await agent.getMemory?.({ requestContext: resolveRequestContext });
|
|
@@ -71925,6 +72530,7 @@ async function rebuildRunToolsFromMastra(options) {
|
|
|
71925
72530
|
memory,
|
|
71926
72531
|
saveQueueManager,
|
|
71927
72532
|
agent: processorAgent,
|
|
72533
|
+
...backgroundTasks,
|
|
71928
72534
|
...rebuiltProcessors,
|
|
71929
72535
|
...options.rehydrateProcessors ? { requestContext: resolveRequestContext } : {}
|
|
71930
72536
|
};
|
|
@@ -71943,6 +72549,8 @@ async function rebuildRunToolsFromMastra(options) {
|
|
|
71943
72549
|
existing.errorProcessors ??= rebuiltProcessors.errorProcessors;
|
|
71944
72550
|
existing.processorStates ??= rebuiltProcessors.processorStates;
|
|
71945
72551
|
existing.agent ??= processorAgent;
|
|
72552
|
+
existing.backgroundTaskManager ??= backgroundTasks.backgroundTaskManager;
|
|
72553
|
+
existing.backgroundTasksConfig ??= backgroundTasks.backgroundTasksConfig;
|
|
71946
72554
|
} else {
|
|
71947
72555
|
existing = patch;
|
|
71948
72556
|
setRunRegistryEntry(runId, existing, mastra);
|
|
@@ -72475,6 +73083,7 @@ async function runDurableFinishSideEffects({ runId, initData, messageListState,
|
|
|
72475
73083
|
outputResultChunks.push(data);
|
|
72476
73084
|
} };
|
|
72477
73085
|
const outputTextBeforeProcessing = resolveOutputText(messageList);
|
|
73086
|
+
let rewrittenStepTexts;
|
|
72478
73087
|
if (registryEntry?.outputProcessors?.length) try {
|
|
72479
73088
|
let agent = registryEntry.agent;
|
|
72480
73089
|
if (!agent && mastra) try {
|
|
@@ -72483,7 +73092,7 @@ async function runDurableFinishSideEffects({ runId, initData, messageListState,
|
|
|
72483
73092
|
} catch {
|
|
72484
73093
|
agent = void 0;
|
|
72485
73094
|
}
|
|
72486
|
-
|
|
73095
|
+
const runner = new ProcessorRunner({
|
|
72487
73096
|
inputProcessors: registryEntry.inputProcessors ?? [],
|
|
72488
73097
|
outputProcessors: registryEntry.outputProcessors,
|
|
72489
73098
|
errorProcessors: registryEntry.errorProcessors ?? [],
|
|
@@ -72491,7 +73100,38 @@ async function runDurableFinishSideEffects({ runId, initData, messageListState,
|
|
|
72491
73100
|
agentName: initData.agentName ?? initData.agentId,
|
|
72492
73101
|
agent,
|
|
72493
73102
|
processorStates: registryEntry.processorStates
|
|
72494
|
-
})
|
|
73103
|
+
});
|
|
73104
|
+
const steps = outputResult?.steps;
|
|
73105
|
+
const lastStep = steps?.at(-1);
|
|
73106
|
+
const responses = messageList.get.response.db();
|
|
73107
|
+
const reply = steps && steps.length > 1 && responses.some((msg) => {
|
|
73108
|
+
const result = msg.content.metadata?.completionResult;
|
|
73109
|
+
return result && typeof result === "object" && "suppressFeedback" in result && result.suppressFeedback === true;
|
|
73110
|
+
}) ? resolveOutputMessageSkippingCompletionChecks(messageList) : void 0;
|
|
73111
|
+
const parts = reply?.content.parts;
|
|
73112
|
+
const offset = parts ? findIterationOffsetInParts(parts, lastStep?.text) : void 0;
|
|
73113
|
+
const split = reply && offset !== void 0 ? messageList.splitResponseMessageAtPartOffset(reply.id, offset) : void 0;
|
|
73114
|
+
const earlierSteps = split ? steps?.slice(0, -1).map((step) => ({ ...step })) : void 0;
|
|
73115
|
+
const earlierReply = split ? messageList.get.response.db().find((msg) => msg.id === split.earlierMessageId) : void 0;
|
|
73116
|
+
const earlierText = earlierReply ? resolveMessageText(earlierReply) : void 0;
|
|
73117
|
+
const earlierBoundaries = earlierSteps ? findStepPartBoundaries(earlierReply, earlierSteps) : void 0;
|
|
73118
|
+
try {
|
|
73119
|
+
await runner.runOutputProcessors(messageList, createObservabilityContext(tracingContext), effectiveRequestContext, 0, outputResultWriter, outputResult);
|
|
73120
|
+
if (split && earlierSteps && lastStep) {
|
|
73121
|
+
const processed = messageList.get.response.db();
|
|
73122
|
+
const earlier = processed.find((msg) => msg.id === split.earlierMessageId);
|
|
73123
|
+
const resolved = resolveOutputMessageSkippingCompletionChecks(messageList);
|
|
73124
|
+
const current = resolved && resolved.id !== split.earlierMessageId ? resolved : processed.find((msg) => msg.id === split.currentMessageId);
|
|
73125
|
+
reconcileBufferedStepTexts(earlierSteps, earlier ? resolveMessageText(earlier) : "", earlier, earlierBoundaries, earlierText);
|
|
73126
|
+
const stepTexts = [...earlierSteps.map((step) => step.text), current ? resolveMessageText(current) : ""];
|
|
73127
|
+
if (stepTexts.some((text, index) => text !== steps?.[index]?.text)) rewrittenStepTexts = stepTexts;
|
|
73128
|
+
}
|
|
73129
|
+
} finally {
|
|
73130
|
+
if (split) {
|
|
73131
|
+
clearStepPartIndexes(messageList.get.response.db());
|
|
73132
|
+
messageList.coalesceSplitResponseMessages(split.earlierMessageId, split.currentMessageId);
|
|
73133
|
+
}
|
|
73134
|
+
}
|
|
72495
73135
|
} catch (error) {
|
|
72496
73136
|
if (error instanceof TripWire) {
|
|
72497
73137
|
await undoSavedResponseMessages({
|
|
@@ -72525,6 +73165,11 @@ async function runDurableFinishSideEffects({ runId, initData, messageListState,
|
|
|
72525
73165
|
}
|
|
72526
73166
|
const outputText = resolveOutputText(messageList);
|
|
72527
73167
|
const outputTextChanged = outputText !== outputTextBeforeProcessing;
|
|
73168
|
+
const finishMessages = {
|
|
73169
|
+
all: messageList.get.all.aiV5.model(),
|
|
73170
|
+
user: messageList.get.input.aiV5.model(),
|
|
73171
|
+
nonUser: messageList.get.response.aiV5.model()
|
|
73172
|
+
};
|
|
72528
73173
|
const saveQueueManager = registryEntry?.saveQueueManager ?? rebuiltSaveQueueManager;
|
|
72529
73174
|
const memory = registryEntry?.memory ?? rebuiltMemory;
|
|
72530
73175
|
const authorizeMemory = durableState?.threadId && durableState.resourceId ? (permission) => authorizeDurableMemory(getDurableMemoryAuthorizationChecks(registryEntry), {
|
|
@@ -72606,6 +73251,8 @@ async function runDurableFinishSideEffects({ runId, initData, messageListState,
|
|
|
72606
73251
|
messageListState: messageList.serialize(),
|
|
72607
73252
|
outputText,
|
|
72608
73253
|
outputTextChanged,
|
|
73254
|
+
finishMessages,
|
|
73255
|
+
rewrittenStepTexts,
|
|
72609
73256
|
titleGeneration,
|
|
72610
73257
|
titleForStream,
|
|
72611
73258
|
structuredOutputChunks,
|
|
@@ -74503,6 +75150,7 @@ var DurableChunkPublishError$1 = class extends Error {
|
|
|
74503
75150
|
const durableLLMInputSchema = z$1.object({
|
|
74504
75151
|
runId: z$1.string(),
|
|
74505
75152
|
agentId: z$1.string(),
|
|
75153
|
+
agentVersionId: z$1.string().optional(),
|
|
74506
75154
|
agentName: z$1.string().optional(),
|
|
74507
75155
|
messageListState: z$1.any(),
|
|
74508
75156
|
initialUntaggedSystemMessages: z$1.array(z$1.any()).optional(),
|
|
@@ -74671,7 +75319,7 @@ function createDurableLLMExecutionStep(_options) {
|
|
|
74671
75319
|
const registry = getRunRegistryEntry(runId, mastra);
|
|
74672
75320
|
if (registry) registry.tracingTermination = termination;
|
|
74673
75321
|
};
|
|
74674
|
-
const emitFatalErrorBail = async (fatalError, modelId, signalPreempted = false) => {
|
|
75322
|
+
const emitFatalErrorBail = async (fatalError, modelId, { signalPreempted = false, modelRejectedBeforeStream = false } = {}) => {
|
|
74675
75323
|
ownership?.throwIfLost();
|
|
74676
75324
|
getRunRegistryEntry(runId, mastra)?.runScope?.set(LOCAL_MODEL_REQUEST_KEY, request);
|
|
74677
75325
|
const usage = {
|
|
@@ -74697,7 +75345,8 @@ function createDurableLLMExecutionStep(_options) {
|
|
|
74697
75345
|
payload: {
|
|
74698
75346
|
stepResult: {
|
|
74699
75347
|
reason: "error",
|
|
74700
|
-
isContinued: false
|
|
75348
|
+
isContinued: false,
|
|
75349
|
+
...modelRejectedBeforeStream && !isMastraTimeoutError(fatalError) ? { warnings: [] } : {}
|
|
74701
75350
|
},
|
|
74702
75351
|
output: { usage },
|
|
74703
75352
|
metadata: {}
|
|
@@ -74724,7 +75373,7 @@ function createDurableLLMExecutionStep(_options) {
|
|
|
74724
75373
|
ownership?.throwIfLost();
|
|
74725
75374
|
if (executionAbortSignalEarly?.aborted) {
|
|
74726
75375
|
const earlyTimeout = resolveTotalTimeoutAbort(executionAbortSignalEarly);
|
|
74727
|
-
if (earlyTimeout) return emitFatalErrorBail(earlyTimeout, typedInput.modelConfig?.modelId ?? "unknown", inputData.signalPreempted === true);
|
|
75376
|
+
if (earlyTimeout) return emitFatalErrorBail(earlyTimeout, typedInput.modelConfig?.modelId ?? "unknown", { signalPreempted: inputData.signalPreempted === true });
|
|
74728
75377
|
return {
|
|
74729
75378
|
...await storeStepTranscript(),
|
|
74730
75379
|
text: "",
|
|
@@ -74784,6 +75433,7 @@ function createDurableLLMExecutionStep(_options) {
|
|
|
74784
75433
|
}];
|
|
74785
75434
|
if (modelList.length === 0) throw new Error("No enabled models available for execution");
|
|
74786
75435
|
let lastError;
|
|
75436
|
+
let modelRejectedBeforeStream = false;
|
|
74787
75437
|
let skipUnavailableAttachments = false;
|
|
74788
75438
|
const maxProcessorRetries = resolveMaxProcessorRetries({
|
|
74789
75439
|
maxProcessorRetries: typedInput.options?.maxProcessorRetries,
|
|
@@ -74836,7 +75486,7 @@ function createDurableLLMExecutionStep(_options) {
|
|
|
74836
75486
|
payload: { id }
|
|
74837
75487
|
}, true);
|
|
74838
75488
|
const totalTimeout = resolveTotalTimeoutAbort(executionAbortSignalEarly, error instanceof Error ? error : void 0);
|
|
74839
|
-
if (totalTimeout) return emitFatalErrorBail(totalTimeout, modelId, true);
|
|
75489
|
+
if (totalTimeout) return emitFatalErrorBail(totalTimeout, modelId, { signalPreempted: true });
|
|
74840
75490
|
return {
|
|
74841
75491
|
...await storeStepTranscript(),
|
|
74842
75492
|
text: "",
|
|
@@ -74886,6 +75536,7 @@ function createDurableLLMExecutionStep(_options) {
|
|
|
74886
75536
|
const modelEntry = modelList[modelIndex];
|
|
74887
75537
|
const maxRetries = hasModelList || (typedInput.options?.agentMaxRetriesConfigured ?? false) ? modelEntry.maxRetries || 0 : typedInput.options?.modelSettings?.maxRetries ?? modelEntry.maxRetries ?? 0;
|
|
74888
75538
|
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
75539
|
+
let modelRequestRejected = false;
|
|
74889
75540
|
ownership?.throwIfLost();
|
|
74890
75541
|
request = {};
|
|
74891
75542
|
const attemptMessageId = currentMessageId;
|
|
@@ -75524,6 +76175,9 @@ function createDurableLLMExecutionStep(_options) {
|
|
|
75524
76175
|
includeRawChunks: execOptions.includeRawChunks,
|
|
75525
76176
|
methodType: "stream",
|
|
75526
76177
|
structuredOutput,
|
|
76178
|
+
onRequestFailed: () => {
|
|
76179
|
+
modelRequestRejected = true;
|
|
76180
|
+
},
|
|
75527
76181
|
onResult: ({ warnings: w, request: r, rawResponse: rr }) => {
|
|
75528
76182
|
warnings = w || [];
|
|
75529
76183
|
request = r || {};
|
|
@@ -76072,6 +76726,7 @@ function createDurableLLMExecutionStep(_options) {
|
|
|
76072
76726
|
};
|
|
76073
76727
|
}
|
|
76074
76728
|
lastError = errorObj;
|
|
76729
|
+
modelRejectedBeforeStream = modelRequestRejected;
|
|
76075
76730
|
const registryEntryInner = getRunRegistryEntry(runId, mastra);
|
|
76076
76731
|
const canRetryErrorInner = maxProcessorRetries !== void 0 && processorRetryCount < maxProcessorRetries;
|
|
76077
76732
|
if (registryEntryInner?.errorProcessors?.length) try {
|
|
@@ -76150,6 +76805,7 @@ function createDurableLLMExecutionStep(_options) {
|
|
|
76150
76805
|
};
|
|
76151
76806
|
}
|
|
76152
76807
|
lastError = streamErrorObj;
|
|
76808
|
+
modelRejectedBeforeStream = modelRequestRejected;
|
|
76153
76809
|
if (attempt < maxRetries) continue;
|
|
76154
76810
|
break;
|
|
76155
76811
|
}
|
|
@@ -76372,6 +77028,7 @@ function createDurableLLMExecutionStep(_options) {
|
|
|
76372
77028
|
if (interruption.signal.aborted) return finishInterruptedRequest(error, modelEntry.config.modelId);
|
|
76373
77029
|
if (error instanceof TripWire) throw error;
|
|
76374
77030
|
lastError = error instanceof Error ? error : new Error(String(error));
|
|
77031
|
+
modelRejectedBeforeStream = modelRequestRejected;
|
|
76375
77032
|
const selectedOuterAbortSignal = getRunRegistryEntry(runId, mastra)?.abortSignal ?? abortSignal;
|
|
76376
77033
|
const outerAbortSignal = ownership?.composeSignal(selectedOuterAbortSignal) ?? selectedOuterAbortSignal;
|
|
76377
77034
|
const totalTimeout = resolveTotalTimeoutAbort(outerAbortSignal, lastError);
|
|
@@ -76471,7 +77128,7 @@ function createDurableLLMExecutionStep(_options) {
|
|
|
76471
77128
|
}
|
|
76472
77129
|
const fatalError = lastError ?? /* @__PURE__ */ new Error("Exhausted all fallback models and reached the maximum number of retries.");
|
|
76473
77130
|
terminalAttemptContext?.recordTerminalError(fatalError);
|
|
76474
|
-
return emitFatalErrorBail(fatalError, modelList.at(-1)?.config.modelId ?? "unknown");
|
|
77131
|
+
return emitFatalErrorBail(fatalError, modelList.at(-1)?.config.modelId ?? "unknown", { modelRejectedBeforeStream });
|
|
76475
77132
|
})
|
|
76476
77133
|
});
|
|
76477
77134
|
}
|
|
@@ -77696,6 +78353,7 @@ function createDurableToolCallStep() {
|
|
|
77696
78353
|
mastra,
|
|
77697
78354
|
runId,
|
|
77698
78355
|
agentId: initData.agentId,
|
|
78356
|
+
agentVersionId: initData.agentVersionId,
|
|
77699
78357
|
state,
|
|
77700
78358
|
options: agentOptions,
|
|
77701
78359
|
requestContextEntries: initData.requestContextEntries,
|
|
@@ -77715,8 +78373,9 @@ function createDurableToolCallStep() {
|
|
|
77715
78373
|
if (!tool && !hasAuthoritativeToolSnapshot) tool = Object.values(rebuiltTools).find((t) => t && typeof t === "object" && "id" in t && t.id === toolName);
|
|
77716
78374
|
}
|
|
77717
78375
|
}
|
|
77718
|
-
|
|
77719
|
-
if (!tool &&
|
|
78376
|
+
const canUseGlobalTools = !hasAuthoritativeToolSnapshot && (!initData.agentVersionId || rebuiltTools !== void 0);
|
|
78377
|
+
if (!tool && canUseGlobalTools) tool = resolveTool$1(toolName, mastra);
|
|
78378
|
+
if (!tool && canUseGlobalTools && mastra) {
|
|
77720
78379
|
mastraTools = mastra.listTools?.();
|
|
77721
78380
|
if (mastraTools) {
|
|
77722
78381
|
tool = findProviderToolByName(mastraTools, toolName);
|
|
@@ -79417,7 +80076,9 @@ function createDurableLLMMappingStep() {
|
|
|
79417
80076
|
mastra,
|
|
79418
80077
|
runId: _runId,
|
|
79419
80078
|
agentId: _agentId,
|
|
80079
|
+
agentVersionId: getInitData()?.agentVersionId,
|
|
79420
80080
|
state,
|
|
80081
|
+
options: (getInitData?.())?.options,
|
|
79421
80082
|
requestContext
|
|
79422
80083
|
});
|
|
79423
80084
|
saveQueueManager = rebuilt?.saveQueueManager;
|
|
@@ -79866,7 +80527,10 @@ const durableAgenticInputSchema = z$1.object({
|
|
|
79866
80527
|
* Schema for the iteration state that flows through the dowhile loop.
|
|
79867
80528
|
* Extends base schema with model list for fallback support.
|
|
79868
80529
|
*/
|
|
79869
|
-
const iterationStateSchema = baseIterationStateSchema.extend({
|
|
80530
|
+
const iterationStateSchema = baseIterationStateSchema.extend({
|
|
80531
|
+
agentVersionId: z$1.string().optional(),
|
|
80532
|
+
modelList: z$1.array(z$1.any()).optional()
|
|
80533
|
+
});
|
|
79870
80534
|
/**
|
|
79871
80535
|
* Whether a reader that attaches mid-run can read the run's earlier events. Steps publish on the
|
|
79872
80536
|
* engine's bus, but `observe()` reads through the agent's own stream bus, which has no replay
|
|
@@ -79875,7 +80539,8 @@ const iterationStateSchema = baseIterationStateSchema.extend({ modelList: z$1.ar
|
|
|
79875
80539
|
function runTopicReplays(rt) {
|
|
79876
80540
|
const topic = AGENT_STREAM_TOPIC(rt.runId);
|
|
79877
80541
|
if (!rt.pubsub?.__replaysTopic(topic)) return false;
|
|
79878
|
-
|
|
80542
|
+
const agent = Object.values(rt.mastra?.listAgents() ?? {}).find((registered) => registered.id === rt.agentId);
|
|
80543
|
+
return (agent?.pubsub ?? agent?.__getStreamBus?.()?.pubsub)?.__replaysTopic?.(topic) ?? true;
|
|
79879
80544
|
}
|
|
79880
80545
|
function liveOrRebuiltAgentSpan(agentSpanData, reg, observability) {
|
|
79881
80546
|
if (!agentSpanData) return void 0;
|
|
@@ -80116,6 +80781,7 @@ var DurableAgenticLoopBuilder = class extends BaseAgenticLoopBuilder {
|
|
|
80116
80781
|
return params.bail({
|
|
80117
80782
|
...update,
|
|
80118
80783
|
...await storeAccumulatedSteps(params, accumulatedSteps),
|
|
80784
|
+
agentVersionId: initData.agentVersionId,
|
|
80119
80785
|
modelList: initData.modelList
|
|
80120
80786
|
});
|
|
80121
80787
|
}
|
|
@@ -80146,6 +80812,7 @@ var DurableAgenticLoopBuilder = class extends BaseAgenticLoopBuilder {
|
|
|
80146
80812
|
return {
|
|
80147
80813
|
runId: state.runId,
|
|
80148
80814
|
agentId: state.agentId,
|
|
80815
|
+
agentVersionId: state.agentVersionId,
|
|
80149
80816
|
agentName: state.agentName,
|
|
80150
80817
|
messageListState: state.messageListState,
|
|
80151
80818
|
initialUntaggedSystemMessages: state.initialUntaggedSystemMessages,
|
|
@@ -80206,6 +80873,7 @@ var DurableAgenticLoopBuilder = class extends BaseAgenticLoopBuilder {
|
|
|
80206
80873
|
return {
|
|
80207
80874
|
...baseUpdate,
|
|
80208
80875
|
...await storeAccumulatedSteps(params, accumulatedSteps),
|
|
80876
|
+
agentVersionId: initData.agentVersionId,
|
|
80209
80877
|
modelList: initData.modelList
|
|
80210
80878
|
};
|
|
80211
80879
|
}, { id: "update-iteration-state" }).then(isTaskCompleteStep).then(goalStep).commit();
|
|
@@ -80498,8 +81166,21 @@ var DurableAgenticLoopBuilder = class extends BaseAgenticLoopBuilder {
|
|
|
80498
81166
|
steps
|
|
80499
81167
|
}
|
|
80500
81168
|
});
|
|
80501
|
-
const
|
|
80502
|
-
|
|
81169
|
+
const rewrittenStepTexts = finishResult.rewrittenStepTexts;
|
|
81170
|
+
const textRewritten = !!lastStep && (finishResult.outputTextChanged || !!rewrittenStepTexts);
|
|
81171
|
+
if (rewrittenStepTexts) {
|
|
81172
|
+
for (const [index, text] of rewrittenStepTexts.entries()) {
|
|
81173
|
+
storedSteps[index] = {
|
|
81174
|
+
...storedSteps[index],
|
|
81175
|
+
text
|
|
81176
|
+
};
|
|
81177
|
+
steps[index] = {
|
|
81178
|
+
...steps[index],
|
|
81179
|
+
text
|
|
81180
|
+
};
|
|
81181
|
+
}
|
|
81182
|
+
finalText = finishResult.outputText;
|
|
81183
|
+
} else if (lastStep && finishResult.outputTextChanged) {
|
|
80503
81184
|
lastStep.text = finishResult.outputText;
|
|
80504
81185
|
steps[steps.length - 1] = {
|
|
80505
81186
|
...steps[steps.length - 1],
|
|
@@ -80554,7 +81235,7 @@ var DurableAgenticLoopBuilder = class extends BaseAgenticLoopBuilder {
|
|
|
80554
81235
|
if (pubsub) await emitFinishEvent(pubsub, state.runId, {
|
|
80555
81236
|
output: finalOutput.output,
|
|
80556
81237
|
stepResult: finalOutput.stepResult,
|
|
80557
|
-
messages: finishMessages,
|
|
81238
|
+
messages: finishResult.finishMessages ?? finishMessages,
|
|
80558
81239
|
...textRewritten && { textRewritten },
|
|
80559
81240
|
...stopCause && { stopCause }
|
|
80560
81241
|
});
|
|
@@ -81059,6 +81740,11 @@ var DefaultAgentExecutionEngine = class {
|
|
|
81059
81740
|
};
|
|
81060
81741
|
getWorkflow(options) {
|
|
81061
81742
|
if (!this.#workflow) {
|
|
81743
|
+
if (options.storesRunsInJournal) {
|
|
81744
|
+
const storage = this.mastra?.getStorage();
|
|
81745
|
+
const workflowsStore = storage?.stores?.workflows;
|
|
81746
|
+
if (workflowsStore && !workflowsStore.supportsRunJournal()) options.guardrailLogger?.warn(`DurableAgent '${this.id}' sets storageVersion: 2, which ${storage?.name ?? "the configured"} storage doesn't support yet; storing new runs as version 1.`);
|
|
81747
|
+
}
|
|
81062
81748
|
this.#workflow = this.createWorkflow(options);
|
|
81063
81749
|
this.warnOnRiskyPersistencePolicy(options.shouldPersistSnapshot, options.guardrailLogger);
|
|
81064
81750
|
if (this.mastra) {
|
|
@@ -81802,7 +82488,7 @@ async function prepareForDurableExecution(options) {
|
|
|
81802
82488
|
});
|
|
81803
82489
|
let tripwireData;
|
|
81804
82490
|
if (inputProcessors.length > 0) try {
|
|
81805
|
-
const { ProcessorRunner } = await import("./stream-
|
|
82491
|
+
const { ProcessorRunner } = await import("./stream-D1y9GzoD.js").then((n) => n.I);
|
|
81806
82492
|
await new ProcessorRunner({
|
|
81807
82493
|
inputProcessors,
|
|
81808
82494
|
outputProcessors,
|
|
@@ -81841,7 +82527,7 @@ async function prepareForDurableExecution(options) {
|
|
|
81841
82527
|
throw inputProcessorError;
|
|
81842
82528
|
}
|
|
81843
82529
|
}
|
|
81844
|
-
let requestContextEntriesSnapshot = snapshotRequestContextEntries(requestContext);
|
|
82530
|
+
let requestContextEntriesSnapshot = snapshotRequestContextEntries(requestContext, options.onRequestContextEntryOmitted);
|
|
81845
82531
|
if (!Array.isArray(requestContextEntriesSnapshot?.["mastra__scopes"])) requestContextEntriesSnapshot = {
|
|
81846
82532
|
...requestContextEntriesSnapshot,
|
|
81847
82533
|
[MASTRA_SCOPES_KEY]: []
|
|
@@ -83722,11 +84408,7 @@ var Agent = class Agent extends MastraBase {
|
|
|
83722
84408
|
}
|
|
83723
84409
|
const durable = config.durable;
|
|
83724
84410
|
if (durable && typeof durable === "object") {
|
|
83725
|
-
const legacyKeys = [
|
|
83726
|
-
"maxSteps",
|
|
83727
|
-
"id",
|
|
83728
|
-
"name"
|
|
83729
|
-
].filter((key) => Object.hasOwn(durable, key));
|
|
84411
|
+
const legacyKeys = ["id", "name"].filter((key) => Object.hasOwn(durable, key));
|
|
83730
84412
|
if (legacyKeys.length) this.logger.warn(`Agent "${this.id}" ignores durable execution options: ${legacyKeys.join(", ")}. Use createDurableAgent({ agent, ...executionOptions }) to configure wrapper-specific options. On native Agent, durable configures resumable streams and the execution engine.`);
|
|
83731
84413
|
}
|
|
83732
84414
|
this.#scopes = config.scopes;
|
|
@@ -84224,7 +84906,7 @@ var Agent = class Agent extends MastraBase {
|
|
|
84224
84906
|
#warnInheritedExecutionOptions(options) {
|
|
84225
84907
|
if (!this.#executionEnginePolicy.inherited) return;
|
|
84226
84908
|
if (options.eagerToolExecution === true) this.#warnExecutionPolicy("eager", "Mastra-inherited execution engine policy does not support eagerToolExecution.");
|
|
84227
|
-
if (this.#executionEnginePolicy.engine === "evented" && options.stopWhen !== void 0) this.#warnExecutionPolicy("stopWhen", "Mastra-inherited evented
|
|
84909
|
+
if (this.#executionEnginePolicy.engine === "evented" && options.stopWhen !== void 0) this.#warnExecutionPolicy("stopWhen", "Mastra-inherited evented execution does not carry stopWhen to another process. Set maxSteps to bound the run across processes.");
|
|
84228
84910
|
}
|
|
84229
84911
|
#beginExecutionPolicy() {
|
|
84230
84912
|
this.#executionEnginePolicy.freeze();
|
|
@@ -84556,7 +85238,8 @@ var Agent = class Agent extends MastraBase {
|
|
|
84556
85238
|
}
|
|
84557
85239
|
processors.push(new PinnedStateProcessor({
|
|
84558
85240
|
principalsKey: (context) => knowledge.__principalsKey(context),
|
|
84559
|
-
readPins: (context) => knowledge.__deliveredPins(context)
|
|
85241
|
+
readPins: (context) => knowledge.__deliveredPins(context),
|
|
85242
|
+
...knowledge.__toolGroups
|
|
84560
85243
|
}));
|
|
84561
85244
|
}
|
|
84562
85245
|
return processors;
|
|
@@ -89905,6 +90588,17 @@ var Agent = class Agent extends MastraBase {
|
|
|
89905
90588
|
return agentThreadStreamRuntime.listActiveThreadRuns(this.getPubSub());
|
|
89906
90589
|
}
|
|
89907
90590
|
/**
|
|
90591
|
+
* The resource and thread that a `runId`-only `sendSignal`, `sendMessage` or `queueMessage`
|
|
90592
|
+
* target resolves to, or undefined when this process doesn't track the run. Servers use it to
|
|
90593
|
+
* check that a caller owns the run before sending to it. Core rejects a target whose `resourceId` doesn't own
|
|
90594
|
+
* its `runId`, but that is a consistency check, not authorization: Core doesn't know who is calling and trusts a
|
|
90595
|
+
* `runId`-only target. Callers that take `runId` from untrusted input must authenticate the caller and compare
|
|
90596
|
+
* this owner with the caller's trusted resource before sending.
|
|
90597
|
+
*/
|
|
90598
|
+
getThreadRunTarget(runId) {
|
|
90599
|
+
return agentThreadStreamRuntime.getThreadRunTarget(runId, this.getPubSub());
|
|
90600
|
+
}
|
|
90601
|
+
/**
|
|
89908
90602
|
* Lists suspended agent runs from workflow snapshot storage — runs waiting on
|
|
89909
90603
|
* a tool-call approval (`requireApproval` / `requireToolApproval`) or on a
|
|
89910
90604
|
* tool that called `suspend()`.
|
|
@@ -91253,6 +91947,7 @@ var Agent = class Agent extends MastraBase {
|
|
|
91253
91947
|
- always produce a title, even when the transcript is only a greeting or trivial exchange
|
|
91254
91948
|
- ensure it is not more than 80 characters long
|
|
91255
91949
|
- the title should be a summary of the user's message
|
|
91950
|
+
- write the title in the same language the user's messages are written in
|
|
91256
91951
|
- do not use quotes or colons
|
|
91257
91952
|
- the entire text you return will be used as the title`;
|
|
91258
91953
|
if (!instructions) return DEFAULT_TITLE_INSTRUCTIONS;
|
|
@@ -91279,10 +91974,13 @@ var Agent = class Agent extends MastraBase {
|
|
|
91279
91974
|
return this.#executionEnginePolicy.engine === "evented" ? "evented" : "default";
|
|
91280
91975
|
}
|
|
91281
91976
|
getWorkflow() {
|
|
91977
|
+
const durable = this.durable;
|
|
91978
|
+
const config = typeof durable === "object" ? durable : void 0;
|
|
91282
91979
|
return this.executionEngine.getWorkflow({
|
|
91980
|
+
maxSteps: config?.maxSteps,
|
|
91283
91981
|
workflowEngine: this.workflowEngine,
|
|
91284
|
-
storesRunsInJournal:
|
|
91285
|
-
shouldPersistSnapshot:
|
|
91982
|
+
storesRunsInJournal: config?.storageVersion === 2,
|
|
91983
|
+
shouldPersistSnapshot: config?.shouldPersistSnapshot,
|
|
91286
91984
|
logger: this.logger,
|
|
91287
91985
|
guardrailLogger: this.guardrailLogger
|
|
91288
91986
|
});
|
|
@@ -92267,8 +92965,8 @@ var Agent = class Agent extends MastraBase {
|
|
|
92267
92965
|
async #resolveDurableRunOptions(options, snapshot) {
|
|
92268
92966
|
if (options?.[RESOLVED_EXECUTION_OPTIONS]) return options;
|
|
92269
92967
|
const defaultOptions = await this.getDefaultOptions({ requestContext: options?.requestContext });
|
|
92270
|
-
this.#warnInheritedExecutionOptions(defaultOptions);
|
|
92271
92968
|
const resolvedOptions = deepMerge$1(withDefaultToolCallConcurrencyLimit(defaultOptions ?? {}, options), options ?? {});
|
|
92969
|
+
this.#warnInheritedExecutionOptions(resolvedOptions);
|
|
92272
92970
|
if (options?.actor !== void 0) resolvedOptions.actor = options.actor;
|
|
92273
92971
|
const scopedOptions = await this.#applyScopes(resolvedOptions, {
|
|
92274
92972
|
callScopes: options?.scopes,
|
|
@@ -92564,6 +93262,7 @@ var Agent = class Agent extends MastraBase {
|
|
|
92564
93262
|
optionsAreResolved: true,
|
|
92565
93263
|
resolvedDefaultOptions: options?.[RESOLVED_DEFAULT_OPTIONS],
|
|
92566
93264
|
scopesResolved: true,
|
|
93265
|
+
onRequestContextEntryOmitted: this.#executionEnginePolicy.inherited ? () => this.#warnExecutionPolicy("requestContextSnapshot", "Mastra-inherited durable execution omitted a value from the request context snapshot. Use JSON-safe values that fit in the snapshot if another process needs them.") : void 0,
|
|
92567
93266
|
mastra: this.#mastra,
|
|
92568
93267
|
methodType,
|
|
92569
93268
|
durableAgentId: this.id,
|
|
@@ -95850,44 +96549,6 @@ function resolveRegisteredClassifier(mastra, classifierId, scorerId) {
|
|
|
95850
96549
|
throw new Error(`Classifier '${classifierId}' not found for scorer '${scorerId}'. Register it with Mastra classifiers or pass the classifier instance directly.`, { cause: error });
|
|
95851
96550
|
}
|
|
95852
96551
|
}
|
|
95853
|
-
// src/mastra/resolve-agent.ts
|
|
95854
|
-
/**
|
|
95855
|
-
* Resolve an agent by id the same way server handlers do: in-memory registry
|
|
95856
|
-
* first, then the editor for stored agents.
|
|
95857
|
-
*
|
|
95858
|
-
* Stored (editor) agents aren't registered on the Mastra instance until
|
|
95859
|
-
* they've been hydrated once in the current process, so a registry miss does
|
|
95860
|
-
* not mean the agent is gone — especially on a cold start. Editor hydration
|
|
95861
|
-
* via `getById` also re-registers the agent, so subsequent lookups take the
|
|
95862
|
-
* fast registry path.
|
|
95863
|
-
*
|
|
95864
|
-
* Every internal call site that needs "does this agent exist / give it to
|
|
95865
|
-
* me" semantics should go through this helper so the fallback (and the
|
|
95866
|
-
* confirmed-miss vs. transient-error distinction) can't drift between call
|
|
95867
|
-
* sites.
|
|
95868
|
-
*/
|
|
95869
|
-
async function resolveAgentById(mastra, agentId) {
|
|
95870
|
-
try {
|
|
95871
|
-
return {
|
|
95872
|
-
status: "found",
|
|
95873
|
-
agent: mastra.getAgentById(agentId)
|
|
95874
|
-
};
|
|
95875
|
-
} catch {}
|
|
95876
|
-
const editor = mastra.getEditor?.();
|
|
95877
|
-
if (!editor) return { status: "missing" };
|
|
95878
|
-
try {
|
|
95879
|
-
const agent = await editor.agent.getById(agentId);
|
|
95880
|
-
return agent ? {
|
|
95881
|
-
status: "found",
|
|
95882
|
-
agent
|
|
95883
|
-
} : { status: "missing" };
|
|
95884
|
-
} catch (error) {
|
|
95885
|
-
return {
|
|
95886
|
-
status: "error",
|
|
95887
|
-
error
|
|
95888
|
-
};
|
|
95889
|
-
}
|
|
95890
|
-
}
|
|
95891
96552
|
// src/mastra/hooks.ts
|
|
95892
96553
|
function toScorerTargetEntityType(entityType) {
|
|
95893
96554
|
switch (entityType) {
|
|
@@ -102703,6 +103364,12 @@ var AgentThreadStreamRuntime = class {
|
|
|
102703
103364
|
type: "run-suspended",
|
|
102704
103365
|
runId,
|
|
102705
103366
|
streamId
|
|
103367
|
+
} : hasDurableExecution(record.agent) ? {
|
|
103368
|
+
type: "run-completed",
|
|
103369
|
+
runId,
|
|
103370
|
+
streamId,
|
|
103371
|
+
persisted: false,
|
|
103372
|
+
status: "interrupted"
|
|
102706
103373
|
} : {
|
|
102707
103374
|
type: "run-completed",
|
|
102708
103375
|
runId,
|
|
@@ -103238,14 +103905,20 @@ var AgentThreadStreamRuntime = class {
|
|
|
103238
103905
|
if (!answersTo(runId)) return;
|
|
103239
103906
|
const queues = data.preRun ? state.preRunSignalsByThread : state.pendingSignalsByThread;
|
|
103240
103907
|
if ([state.preRunSignalsByThread.get(key), state.pendingSignalsByThread.get(key)].some((queue) => queue?.some((signal) => signal.id === data.signal.id))) return;
|
|
103241
|
-
const queue = queues.get(key) ?? [];
|
|
103242
103908
|
const signal = createSignal(data.signal);
|
|
103909
|
+
if (this.#pendingUserMessageChunk(runId, signal, "pending")) this.#publish(pubsub, key, {
|
|
103910
|
+
type: "user-message-admitted",
|
|
103911
|
+
signalId: signal.id,
|
|
103912
|
+
admittedRunId: runId
|
|
103913
|
+
});
|
|
103914
|
+
const queue = queues.get(key) ?? [];
|
|
103243
103915
|
queue.push(signal);
|
|
103244
103916
|
queues.set(key, queue);
|
|
103245
103917
|
subscription.admittedSignalIds.add(data.signal.id);
|
|
103246
103918
|
this.#publishPendingUserMessage(pubsub, key, runId, signal, "pending");
|
|
103247
103919
|
this.#notifyPendingSignals(state, key, signal);
|
|
103248
|
-
} else if (data?.type === "user-message-
|
|
103920
|
+
} else if (data?.type === "user-message-admitted") this.#settleForwardedIdleSignal(state, key, data.signalId, data.admittedRunId);
|
|
103921
|
+
else if (data?.type === "user-message-presentation") {
|
|
103249
103922
|
const { chunk } = data;
|
|
103250
103923
|
if (chunk.type === "data-user-message-pending" && chunk.data.metadata?.status === "pending") this.#settleForwardedIdleSignal(state, key, chunk.data.id, chunk.runId);
|
|
103251
103924
|
} else if (data?.type === "signals-cancelled") {
|
|
@@ -103298,7 +103971,7 @@ var AgentThreadStreamRuntime = class {
|
|
|
103298
103971
|
const onEvent = (event, ack) => {
|
|
103299
103972
|
const type = event.data?.type;
|
|
103300
103973
|
const awaitingForwards = state.forwardedIdleSignalsByThread.has(key);
|
|
103301
|
-
if (type !== "signal-enqueued" && type !== "signals-cancelled" && type !== "run-abort-requested" && type !== "run-registered" && !(type === "user-message-presentation" && awaitingForwards) && !((type === "run-completed" || type === "run-failed") && (awaitingForwards || subscription.successorRunIds.has(event.data.runId) || this.#localActiveRunId(state, key) !== void 0)) && !((type === "run-aborted" || type === "run-discarded") && this.#localActiveRunId(state, key) !== void 0) && !(type === "run-discarded" && awaitingForwards)) return ack?.();
|
|
103974
|
+
if (type !== "signal-enqueued" && type !== "signals-cancelled" && type !== "run-abort-requested" && type !== "run-registered" && !((type === "user-message-presentation" || type === "user-message-admitted") && awaitingForwards) && !((type === "run-completed" || type === "run-failed") && (awaitingForwards || subscription.successorRunIds.has(event.data.runId) || this.#localActiveRunId(state, key) !== void 0)) && !((type === "run-aborted" || type === "run-discarded") && this.#localActiveRunId(state, key) !== void 0) && !(type === "run-discarded" && awaitingForwards)) return ack?.();
|
|
103302
103975
|
subscription.references++;
|
|
103303
103976
|
const handled = tail.then(() => handleEvent(event));
|
|
103304
103977
|
tail = handled.catch(() => {});
|
|
@@ -103375,6 +104048,17 @@ var AgentThreadStreamRuntime = class {
|
|
|
103375
104048
|
}
|
|
103376
104049
|
for (const key of state.threadControlSubscriptions.keys()) this.#releaseUnusedThreadControlSubscription(state, key);
|
|
103377
104050
|
}
|
|
104051
|
+
/**
|
|
104052
|
+
* A `runId` target that also names a `resourceId` must name the run's own resource. Without this, the signal
|
|
104053
|
+
* would be created for the caller's resource and delivered into another resource's run. Core cannot know who the
|
|
104054
|
+
* caller is: a target naming only a `runId` is trusted, so callers exposing `runId` targets to untrusted input
|
|
104055
|
+
* must pass the caller's `resourceId` or check ownership with `getThreadRunTarget()` first.
|
|
104056
|
+
*/
|
|
104057
|
+
#assertRunTargetOwner(state, target) {
|
|
104058
|
+
if (!target.runId || !target.resourceId) return;
|
|
104059
|
+
const owner = state.threadRunsById.get(target.runId)?.resourceId;
|
|
104060
|
+
if (owner && owner !== target.resourceId) throw new Error(`Agent run ${target.runId} belongs to a different resource`);
|
|
104061
|
+
}
|
|
103378
104062
|
#threadKey(resourceId, threadId) {
|
|
103379
104063
|
return agentThreadStreamKey(resourceId, threadId);
|
|
103380
104064
|
}
|
|
@@ -104271,7 +104955,7 @@ var AgentThreadStreamRuntime = class {
|
|
|
104271
104955
|
const topic = this.#threadTopic(key);
|
|
104272
104956
|
await resolvedPubSub.publish(topic, {
|
|
104273
104957
|
type: event.type,
|
|
104274
|
-
runId: "runId" in event ? event.runId : key,
|
|
104958
|
+
runId: ("runId" in event ? event.runId : void 0) ?? key,
|
|
104275
104959
|
data: event
|
|
104276
104960
|
});
|
|
104277
104961
|
}
|
|
@@ -104878,6 +105562,14 @@ var AgentThreadStreamRuntime = class {
|
|
|
104878
105562
|
hasThreadRun(runId, pubsub) {
|
|
104879
105563
|
return this.#getState(pubsub).threadRunsById.has(runId);
|
|
104880
105564
|
}
|
|
105565
|
+
/** The resource and thread a `runId`-only signal or message target resolves to in this process. */
|
|
105566
|
+
getThreadRunTarget(runId, pubsub) {
|
|
105567
|
+
const record = this.#getState(pubsub).threadRunsById.get(runId);
|
|
105568
|
+
return record ? {
|
|
105569
|
+
resourceId: record.resourceId,
|
|
105570
|
+
threadId: record.threadId
|
|
105571
|
+
} : void 0;
|
|
105572
|
+
}
|
|
104881
105573
|
/** Whether the run's original stream is still live and carries its resumed segments. */
|
|
104882
105574
|
hasRunContinuation(runId, pubsub) {
|
|
104883
105575
|
return this.#getState(pubsub).threadRunsById.get(runId)?.continuation?.canContinue() === true;
|
|
@@ -105110,6 +105802,7 @@ var AgentThreadStreamRuntime = class {
|
|
|
105110
105802
|
const chunk = this.#pendingUserMessageChunk(runId, signal, status);
|
|
105111
105803
|
if (chunk) this.#publish(pubsub, key, {
|
|
105112
105804
|
type: "user-message-presentation",
|
|
105805
|
+
runId,
|
|
105113
105806
|
chunk
|
|
105114
105807
|
});
|
|
105115
105808
|
}
|
|
@@ -106227,6 +106920,7 @@ var AgentThreadStreamRuntime = class {
|
|
|
106227
106920
|
const statuses = [];
|
|
106228
106921
|
const settledRunIds = /* @__PURE__ */ new Map();
|
|
106229
106922
|
const reportedSuspensions = /* @__PURE__ */ new Set();
|
|
106923
|
+
const reportedInterruptions = /* @__PURE__ */ new Set();
|
|
106230
106924
|
const presentations = [];
|
|
106231
106925
|
const presentedSignalIds = /* @__PURE__ */ new Set();
|
|
106232
106926
|
const settledSignalIds = /* @__PURE__ */ new Set();
|
|
@@ -106248,6 +106942,9 @@ var AgentThreadStreamRuntime = class {
|
|
|
106248
106942
|
if (status === "suspended") {
|
|
106249
106943
|
if (reportedSuspensions.has(streamId)) return;
|
|
106250
106944
|
reportedSuspensions.add(streamId);
|
|
106945
|
+
} else if (status === "interrupted") {
|
|
106946
|
+
if (reportedInterruptions.has(streamId)) return;
|
|
106947
|
+
reportedInterruptions.add(streamId);
|
|
106251
106948
|
} else settledRunIds.set(runId, streamId);
|
|
106252
106949
|
if (!options.withRunStatus) return;
|
|
106253
106950
|
statuses.push({
|
|
@@ -106732,7 +107429,7 @@ var AgentThreadStreamRuntime = class {
|
|
|
106732
107429
|
if (data.type !== "run-suspended") parkedPromptRunIds.delete(data.runId);
|
|
106733
107430
|
if (data.type === "run-completed") await this.#drainPendingIdleSignals(state, resolvedPubSub, key, data.runId);
|
|
106734
107431
|
if (data.type !== "run-suspended" || !suspendedRunEnded) {
|
|
106735
|
-
const status = data.type === "run-aborted" ? "aborted" : data.type === "run-suspended" || data.status === "suspended" ? "suspended" : data.status === "canceled" ? "aborted" : data.status === "success" || data.status === void 0 && data.persisted !== false ? "success" : "failed";
|
|
107432
|
+
const status = data.type === "run-aborted" ? "aborted" : data.type === "run-suspended" || data.status === "suspended" ? "suspended" : data.status === "canceled" ? "aborted" : data.status === "interrupted" ? "interrupted" : data.status === "success" || data.status === void 0 && data.persisted !== false ? "success" : "failed";
|
|
106736
107433
|
enqueueStatus(data.runId, eventStreamId, status);
|
|
106737
107434
|
}
|
|
106738
107435
|
wake();
|
|
@@ -107218,6 +107915,7 @@ var AgentThreadStreamRuntime = class {
|
|
|
107218
107915
|
activeRecord ??= state.threadRunsById.get(runId);
|
|
107219
107916
|
if (activeRecord) key ??= this.#threadKey(activeRecord.resourceId, activeRecord.threadId);
|
|
107220
107917
|
}
|
|
107918
|
+
this.#assertRunTargetOwner(state, target);
|
|
107221
107919
|
const resourceId = target.resourceId ?? activeRecord?.resourceId;
|
|
107222
107920
|
const threadId = target.threadId ?? activeRecord?.threadId;
|
|
107223
107921
|
if (!resourceId || !threadId) throw new Error("resourceId and threadId are required to queue a message");
|
|
@@ -107377,6 +108075,7 @@ var AgentThreadStreamRuntime = class {
|
|
|
107377
108075
|
activeRecord ??= state.threadRunsById.get(runId);
|
|
107378
108076
|
if (activeRecord) key ??= this.#threadKey(activeRecord.resourceId, activeRecord.threadId);
|
|
107379
108077
|
}
|
|
108078
|
+
this.#assertRunTargetOwner(state, target);
|
|
107380
108079
|
const resourceId = target.resourceId ?? activeRecord?.resourceId;
|
|
107381
108080
|
const threadId = target.threadId ?? activeRecord?.threadId;
|
|
107382
108081
|
if (!resourceId || !threadId) throw new Error("No active agent run found for signal target");
|
|
@@ -108254,4 +108953,4 @@ var ExtendedRunRegistry = class extends RunRegistry {
|
|
|
108254
108953
|
this.#memoryInfo.clear();
|
|
108255
108954
|
}
|
|
108256
108955
|
};
|
|
108257
|
-
export { createDurableBackgroundTaskCheckStep as $, planTraceQuery as $a, validateStepInput as $c, resolveRetentionTargets as $i, assertKnowledgeCeilingRaised as $n, normalizeMessageHistoryConfig as $o, KnowledgeMoveTooLargeError as $r, EventedExecutionEngine as $s, knowledgeDeliveredPins as $t, agentInstructions as A, threadQueryResponseSchema as Aa, RESUME_SNAPSHOT_POLL_INTERVAL_MS as Ac, inspectKnowledgeSchema as Ai, ToolInvocationPartSchema as Al, ChatChannelProcessor as An, createBackgroundWorkSignalProcessor as Ao, ScoresInMemory as Ar, StepExecutor as As, readRunDeadline as At, createDurableAgenticWorkflow as B, parseSpanQueryRequest as Ba, defineStateAccessors as Bc, assertSupportedPatterns as Bi, runFencingNotSupportedError as Bl, toChatLogger as Bn, ToolSearchProcessor as Bo, notificationSignalAttributes as Br, emitFinishEvent as Bs, formatCompletionFeedback as Bt, MastraScorer as C, tracePageResponseSchema as Ca, createConcurrencyLimiter as Cc, KnowledgeConflictError as Ci, ProcessorStepInputSchema as Cl, decodeKnowledgeScopeId as Cn, MastraMemory as Co, createEmptyWorkflowSnapshot as Cr, EventedRun as Cs, runDurableStreamUntilIdle as Ct, isNotScorable as D, planThreadRowsQuery as Da, createStepFromAgent$1 as Dc, KnowledgeUnsupportedCapabilityError as Di, SourcePartSchema as Dl, resolveWaitUntil as Dn, isSystemReminderMessage as Do, WorkflowDefinitionsStorage as Dr, createStep as Ds, DurableStepIds as Dt, filterRun as E, encodeThreadQueryCursor as Ea, createMappingStep as Ec, KnowledgeStorage as Ei, ReasoningPartSchema as El, AgentChannels as En, filterSystemReminderMessages as Eo, InMemoryWorkflowDefinitionsStorage as Er, cloneWorkflow$1 as Es, DurableAgentDefaults as Et, normalizeResumeGenerateArgs as F, SPAN_QUERY_MAX_PREVIEW_CHARACTERS as Fa, cleanStepResult as Fc, ExperimentsStorage as Fi, coverNestedRun as Fl, DEFAULT_CHANNEL_TOOLS_SETTINGS as Fn, buildResponseCacheKey as Fo, InMemoryNotificationsStorage as Fr, __resetExecutionFencesForTests as Fs, pruneAgentLoopSnapshot as Ft, createWorkflowInput as G, spanQueryIdentitySchema as Ga, hydrateSerializedStepErrors as Gc, SchemaValidationError as Gi, WorkingMemory as Gn, TokenCostControl as Go, readNotificationRoutingRequirement as Gr, publishAbortRequest as Gs, runChecks as Gt, createDurableIsTaskCompleteStep as H, resolveSpanQueryCost as Ha, getResumeLabelsByStepId as Hc, getSchemaValidator as Hi, setRunFenceContext as Hl, MemoryInputFilter as Hn, ToolCallFilter as Ho, notificationSummaryContents as Hr, emitStepStartEvent as Hs, formatValidationFeedback as Ht, prepareForDurableExecution as I, SPAN_QUERY_ORDER_FIELDS as Ia, createDeprecationProxy as Ic, DatasetsInMemory as Ii, currentRunGeneration as Il, channelToolScopeResolver as In, WorkspaceInstructionsProcessor as Io, NotificationsStorage as Ir, diffResponseMessages as Is, DEFAULT_TOOL_DECLINE_REASON as It, serializeModelConfig as J, spanQueryRowSchema as Ja, omitPriorCompletionFields as Jc, InMemoryBlobStore as Ji, getMemoryRunState as Jn, groupLinkedToolMessages as Jo, resolveDeliveryFailureUpdate as Jr, createRunAbortController as Js, runStreamCompletionScorers as Jt, serializeDurableOptions as K, spanQueryRequestSchema as Ka, isEntryFinished as Kc, InMemoryChannelsStorage as Ki, MessageHistory as Kn, SystemPromptScrubber as Ko, MAX_NOTIFICATION_DELIVERY_ATTEMPTS as Kr, requestAcknowledgedAbort as Ks, runCompletionScorers as Kt, applyReservedMemoryContextKeys as L, buildSpanQueryResponse as La, createRestartExecutionParams as Lc, DatasetsStorage as Li, isRunFenceConflictError as Ll, createChannelToolScope as Ln, SkillSearchProcessor as Lo, dispatchDueNotifications as Lr, emitAbortEvent as Ls, resolveDeclineReason as Lt, MAX_FS_SUBAGENT_DEPTH as M, SPAN_QUERY_MAX_COST_METRICS as Ma, abortableSleep as Mc, InMemoryHarness as Mi, RUN_FENCE_CONFLICT_ERROR_ID as Ml, renderBuiltInToolEvent as Mn, DEFAULT_RESPONSE_CACHE_TTL_SECONDS as Mo, InMemorySchedulesStorage as Mr, WorkflowStepConflictError as Ms, getRunStreamSlot as Mt, AGENT_RESUME_CLAIM_STALE_MS as N, SPAN_QUERY_MAX_CURSOR_BYTES as Na, applyStateDelta as Nc, HarnessStorage as Ni, RUN_FENCING_NOT_SUPPORTED_ERROR_ID as Nl, formatToolApproval as Nn, RESPONSE_CACHE_CONTEXT_KEY as No, SchedulesStorage as Nr, assertWorkflowStepGuard as Ns, getScopeStreamSlot as Nt, notScorable as O, threadQueryIdentitySchema as Oa, createStepFromClassifier as Oc, assertKnowledgeSchemaCompatible as Oi, StepStartPartSchema as Ol, defaultTypingStatus as On, augmentWithInit as Oo, InMemoryToolProviderConnectionsStorage as Or, createWorkflow$1 as Os, RUN_DEADLINE_KEY as Ot, Agent as P, SPAN_QUERY_MAX_LIMIT as Pa, assertTimeTravelGraphMatchesSnapshot as Pc, ExperimentsInMemory as Pi, RunFenceConflictError as Pl, ChannelSessionRejectedError as Pn, ResponseCache as Po, normalizeScheduleTarget as Pr, isWorkflowStepConflictError as Ps, untilIdleHandlesBackgroundTask as Pt, isSpanChunk as Q, planThreadQuery as Qa, setLongTimeout as Qc, executeRetentionPrune as Qi, MAX_KNOWLEDGE_SCOPE_TAGS as Qn, isAfterMemoryTokenBoundary as Qo, InMemoryKnowledgeStorage as Qr, AgentStreamEventTypes as Qs, PINNED_READ_MEMO_KEY as Qt, persistDurableRunInput as R, createSpanQueryPreview as Ra, createTimeTravelExecutionParams as Rc, DatasetItemIdentityConflictError as Ri, matchesRunFence as Rl, createChannelTools as Rn, SkillsProcessor as Ro, createNotificationSignal as Rr, emitChunkEvent as Rs, getServerSideFallbackInfo as Rt, createClassifierScorer as S, tracePageRequestSchema as Sa, ExecutionEngine as Sc, KNOWLEDGE_STORAGE_SCHEMA_VERSION as Si, ProcessorOutputStreamPhaseSchema as Sl, strongerKnowledgeRole as Sn, upsertMessageVectors as So, WorkflowsStorage as Sr, createWorkflow as Ss, createDurableAgentStream as St, createScorer as T, THREAD_QUERY_MAX_LIMIT as Ta, runWithConcurrency as Tc, KnowledgeSchemaResetRequiredError as Ti, ProcessorStepSchema as Tl, buildKnowledgeInstructions as Tn, memoryDefaultOptions as To, mergeWorkflowStepResult as Tr, cloneStep as Ts, DURABLE_STOP_WHEN_ERROR_ID as Tt, createDurableLLMMappingStep as U, spanQueryCostSchema as Ua, getSingleStepEntryId as Uc, UnsupportedSchemaPatternError as Ui, SemanticRecall as Un, RegexFilterProcessor as Uo, notificationSummarySignalMetadata as Ur, emitSuspendedEvent as Us, generateFinalResult as Ut, createDurableGoalStep as V, planSpanQuery as Va, getRestartStartIndex as Vc, createValidator as Vi, runOutsideRunFenceScope as Vl, BaseProcessor as Vn, AgentsMDInjector as Vo, notificationSignalMetadata as Vr, emitStepFinishEvent as Vs, formatStreamCompletionFeedback as Vt, createDurableToolCallStep as W, spanQueryIdentityKey as Wa, getStepIds as Wc, SchemaUpdateValidationError as Wi, globalEmbeddingCache as Wn, CostGuardProcessor as Wo, summarizeNotifications as Wr, AgentStreamBus as Ws, generateStructuredFinalResult as Wt, createDurableLLMExecutionStep as X, encodeTraceQueryDeltaCursor as Xa, resolveForeachConcurrency as Xc, BackgroundTasksInMemory as Xi, MAX_KNOWLEDGE_NODE_DESCRIPTION_LENGTH as Xn, advanceMemoryTokenBoundary as Xo, InMemoryMemory as Xr, AGENT_STREAM_TOPIC as Xs, loop as Xt, serializeToolsMetadata as Y, encodeTraceQueryCursor as Ya, omitPriorSuspensionFields as Yc, BlobStore as Yi, MockMemory as Yn, loadMessageHistory as Yo, resolveNotificationDeliveryDecision as Yr, AGENT_CONTROL_TOPIC as Ys, runValidation as Yt, MessagePartSpans as Z, getTraceQueryDeltaWatermark as Za, runCountDeprecationMessage as Zc, BackgroundTasksStorage as Zi, MAX_KNOWLEDGE_RECORD_TEXT_LENGTH as Zn, getMemoryTokenBoundary as Zo, MemoryStorage as Zr, AgentControlEventTypes as Zs, validateModelTimeoutSettings as Zt, runEvals as _, validateStorageMetadataFilter as _a, repeatAfterSettled as _c, knowledgePinDepth as _i, ProcessorInputStepPhaseSchema as _l, KnowledgeDeclarationError as _n, buildMessageEmbeddingRows as _o, FilesystemDB as _r, isRetryableOpenAIResponsesStreamError as _s, resolveTool$1 as _t, endRunSpansWithError as a, ensureDate as aa, createStep$1 as ac, MAX_KNOWLEDGE_PAGE_BODY_LINKS as ai, getEntryId as al, removeKnowledgeNote as an, buildUpdateSpanRecord as ao, expandKnowledgeScope as ar, PIIDetector as as, baseDurableAgenticInputSchema as at, validateAndSaveScore as b, tracePageIdSchema as ba, evaluateScoringPredicate as bc, parseKnowledgePageRef as bi, ProcessorOutputResultPhaseSchema as bl, knowledgeRunScopes as bn, messageVectorId as bo, WorkflowsInMemory as br, cloneWorkflow as bs, liveSegmentSpan as bt, globalRunRegistry as c, getSqlType as ca, predicateToCondition as cc, MAX_KNOWLEDGE_PAGE_LINKS as ci, waitMs as cl, upsertKnowledgePage as cn, serializeSpanAttributes as co, knowledgeSemanticDocumentId as cr, UnicodeNormalizer as cs, modelConfigSchema as ct, takeRunScorerInstances as d, parseDuration as da, createNestedRunParentStatusLookup as dc, MAX_KNOWLEDGE_PIN_LIST_DEPTH as di, isDurableAgentLike as dl, refreshKnowledgeLinksTo as dn, ObservabilityStorage as do, parseKnowledgeNodeCursor as dr, isMalformedFunctionCallError as ds, runDurableFinishSideEffects as dt, retentionCutoffMs as ea, getNestedWorkflow as ec, KnowledgePageDepthError as ei, validateStepRequestContext as el, buildKnowledgePageTools as en, buildCreateSpanRecord as eo, assertKnowledgeDescriptionWithinBound as er, BatchPartsProcessor as es, resolveDurableToolCallConcurrency as et, AgentThreadLeaseLostError as f, safelyParseJSON as fa, nestedRunParentOf as fc, assertKnowledgeNoteTextWithinBound as fi, FilePartSchema as fl, reindexKnowledgeLinks as fn, FactoryStorage as fo, StoreOperationsInMemory as fr, UnsupportedFileHandler as fs, loadRunStoredMessages as ft, describeNonSuccessFinishReason as g, transformScoreRow as ga, renewWorkflowLease as gc, knowledgePagePath as gi, ProcessorInputPhaseSchema as gl, knowledgeRoleOn as gn, MESSAGE_EMBEDDING_CHARS_PER_TOKEN as go, FilesystemStore as gr, isBadRequestError as gs, resolveRuntimeDependencies as gt, AGENTIC_LOOP_WORKFLOW_ID as h, transformRow as ha, WORKFLOW_RUN_LEASE_TTL_MS as hc, knowledgeLinkRefKey as hi, MessagePartSchema as hl, knowledgeReadScopeFor as hn, DEFAULT_MESSAGE_EMBEDDING_MAX_CHUNK_CHARS as ho, createGitHubSourceControlProviderFromEnv as hr, StreamErrorRetryProcessor as hs, resolveModel as ht, deleteRunRegistryEntry as i, createVectorErrorId as ia, cloneStep$1 as ic, MAX_KNOWLEDGE_NOTE_TOKENS as ii, waitForSuspendedSnapshot as il, moveKnowledgePage as in, buildScoreRecord as io, createKnowledgeNodeCursor as ir, LanguageDetector as is, accumulatedUsageSchema as it, assembleAgentFromFsEntry as j, threadQueryRowSchema as ja, RESUME_SNAPSHOT_WAIT_STATUSES as jc, parseKnowledgeWikilinks as ji, isAgentCompatible as jl, CHAT_CHANNEL_RENDER_CONTEXT_KEY as jn, CyberRefusalHandler as jo, ScoresStorage as jr, computeScheduleDefinitionHash as js, __registerMastraCtor as jt, agentConfig as k, threadQueryRequestSchema as ka, createStepFromTool as kc, createKnowledgeUlid as ki, TextPartSchema as kl, MastraStateAdapter as kn, getStorageSource as ko, ToolProviderConnectionsStorage as kr, WorkflowEventProcessor as ks, ensureRemoteAbortListener as kt, isDurableAgentExecutionDetached as l, hasErrorCode as la, evaluatePredicate as lc, MAX_KNOWLEDGE_PAGE_LINK_REF_LENGTH as li, workflowTermination as ll, KnowledgeSemanticIndex as ln, toEntityType as lo, knowledgeSemanticIdempotencyKey as lr, STABILITY_ERROR_PROCESSOR_IDS as ls, modelListEntrySchema as lt, AGENTIC_EXECUTION_WORKFLOW_ID as m, storageMessageMatchesMetadataFilter as ma, nestedRunStatusOf as mc, canonicalKnowledgeName as mi, MessageContentSchema as ml, knowledgeAccessGrants as mn, UniqueViolationError as mo, GitHubSourceControlProvider as mr, FILE_UPLOAD_ERROR_CODES as ms, resolveInternalState as mt, RunRegistry as n, createStorageErrorId as na, Run as nc, KnowledgePageKeyConflictError as ni, validateStepStateData as nl, knowledgeRunPrincipals as nn, buildLogRecord as no, assertKnowledgeScopeWithinCeiling as nr, ClassifierProcessor as ns, calculateAccumulatedUsage as nt, getActiveDurableAgentWorkflowExecutions as o, filterByDateRange as oa, isProcessor$1 as oc, MAX_KNOWLEDGE_PAGE_DEPTH as oi, getEntryWorkflow as ol, removeKnowledgePage as on, getObjectOrNull as oo, isKnowledgeScopeVisible as or, PromptInjectionDetector as os, baseIterationStateSchema as ot, agentThreadStreamRuntime as p, serializeDate as pa, nestedRunRecoveryAction as pc, assertKnowledgePageDescriptionWithinBound as pi, ImagePartSchema as pl, updateKnowledgeLinks as pn, FactoryStorageDomain as po, StoreOperations as pr, FileUploadProcessor as ps, rebuildRunToolsFromMastra as pt, serializeDurableState as q, spanQueryResponseSchema as qa, isSingleStepEntry as qc, ChannelsStorage as qi, MemoryRunState as qn, TokenLimiterProcessor as qo, defaultNotificationDeliveryDecision as qr, subscribeToAbortRequests as qs, runDefaultCompletionCheck as qt, abandonDurableAgentExecutions as r, createStoreErrorId as ra, Workflow as rc, MAX_KNOWLEDGE_MOVE_PAGES as ri, validateStepSuspendData as rl, addKnowledgeNote as rn, buildMetricRecord as ro, canonicalizeKnowledgeScope as rr, StructuredOutputProcessor as rs, createBaseIterationStateUpdate as rt, getRunRegistryEntry as s, getDefaultValue as sa, mapVariable as sc, MAX_KNOWLEDGE_PAGE_DESCRIPTION_TOKENS as si, assertDrainTimeout as sl, updateKnowledgeNote as sn, getStringOrNull as so, knowledgeScopeKey as sr, ModerationProcessor as ss, durableAgenticOutputSchema as st, ExtendedRunRegistry as t, runRetentionBatches as ta, getStepEntry as tc, KnowledgePageHasChildrenError as ti, validateStepResumeData as tl, KnowledgeRun as tn, buildFeedbackRecord as to, assertKnowledgeRecordTextWithinBound as tr, ModelSelectionProcessor as ts, buildStepRecord as tt, setRunRegistryEntry as u, jsonValueEquals as ua, cancelNestedRun as uc, MAX_KNOWLEDGE_PAGE_LIST_LIMIT as ui, hasResumableStreams as ul, embed$2 as un, ObservabilityInMemory as uo, knowledgeVisibleScopeKeys as ur, defaultStabilityErrorProcessors as us, executeDurableAgentScorers as ut, flushBeforeTraceRead as v, TracePageError as va, DefaultExecutionEngine as vc, knowledgePositionBetween as vi, ProcessorMessageContentSchema as vl, compileKnowledgeScopes as vn, chunkMessageText as vo, InMemoryStore as vr, PrefillErrorHandler as vs, toolRequiresApproval as vt, ScorerRunError as w, THREAD_QUERY_DEFAULT_LIMIT as wa, normalizeConcurrency as wc, KnowledgeNotFoundError$1 as wi, ProcessorStepOutputSchema as wl, encodeKnowledgeScopeId as wn, MemoryProcessor as wo, mergeStepResult as wr, EventedWorkflow as ws, runResumeDurableStreamUntilIdle as wt, resolveAgentById as x, tracePageNodeSchema as xa, validateScoringPredicate as xc, KNOWLEDGE_STORAGE_CONTRACT_VERSION as xi, ProcessorOutputStepPhaseSchema as xl, knowledgeScopeAddress as xn, resolveMaxChunkChars as xo, cloneRunData as xr, createEventedWorkflow as xs, segmentSpanData as xt, createOnScorerHook as y, readTracePage as ya, SCORING_PREDICATE_ROOTS as yc, knowledgeScopeReadable as yi, ProcessorMessageSchema as yl, knowledgeMemoryScopes as yn, extractMessageEmbeddingText as yo, MockStore as yr, getGoalActivityDurationMs as ys, carrySegmentSpans as yt, detachFullStreamOnEnd as z, encodeSpanQueryCursor as za, defineLazyWriter as zc, SchemaValidator as zi, resolveRunFence as zl, resolveChannelToolsSettings as zn, formatSkillsCatalog as zo, createNotificationSummarySignal as zr, emitErrorEvent as zs, formatCheckFeedback as zt };
|
|
108956
|
+
export { resolveDurableToolCallConcurrency as $, spanQueryIdentitySchema as $a, hydrateSerializedStepErrors as $c, SchemaValidationError as $i, MAX_KNOWLEDGE_NODE_DESCRIPTION_LENGTH as $n, TokenCostControl as $o, InMemoryMemory as $r, publishAbortRequest as $s, knowledgeDeliveredPins as $t, assembleAgentFromFsEntry as A, tracePageRequestSchema as Aa, ExecutionEngine as Ac, assertKnowledgeNoteTextWithinBound as Ai, ProcessorOutputStepPhaseSchema as Al, resolveWaitUntil as An, upsertMessageVectors as Ao, WorkflowDefinitionsStorage as Ar, createWorkflow as As, readRunDeadline as At, createDurableGoalStep as B, SPAN_QUERY_MAX_COST_METRICS as Ba, abortableSleep as Bc, InMemoryHarness as Bi, isAgentCompatible as Bl, createChannelToolScope as Bn, DEFAULT_RESPONSE_CACHE_TTL_SECONDS as Bo, dispatchDueNotifications as Br, WorkflowStepConflictError as Bs, formatCompletionFeedback as Bt, ScorerRunError as C, transformRow as Ca, WORKFLOW_RUN_LEASE_TTL_MS as Cc, MAX_KNOWLEDGE_PAGE_BODY_LINKS as Ci, MessageContentSchema as Cl, knowledgeRunScopes as Cn, DEFAULT_MESSAGE_EMBEDDING_MAX_CHUNK_CHARS as Co, WorkflowsInMemory as Cr, StreamErrorRetryProcessor as Cs, runDurableStreamUntilIdle as Ct, notScorable as D, readTracePage as Da, SCORING_PREDICATE_ROOTS as Dc, MAX_KNOWLEDGE_PAGE_LINK_REF_LENGTH as Di, ProcessorMessageContentSchema as Dl, encodeKnowledgeScopeId as Dn, extractMessageEmbeddingText as Do, mergeStepResult as Dr, getGoalActivityDurationMs as Ds, DurableStepIds as Dt, isNotScorable as E, TracePageError as Ea, DefaultExecutionEngine as Ec, MAX_KNOWLEDGE_PAGE_LINKS as Ei, ProcessorInputStepPhaseSchema as El, decodeKnowledgeScopeId as En, chunkMessageText as Eo, createEmptyWorkflowSnapshot as Er, PrefillErrorHandler as Es, DurableAgentDefaults as Et, prepareForDurableExecution as F, planThreadRowsQuery as Fa, createStepFromAgent$1 as Fc, knowledgePinDepth as Fi, ReasoningPartSchema as Fl, renderBuiltInToolEvent as Fn, isSystemReminderMessage as Fo, InMemorySchedulesStorage as Fr, createStep as Fs, pruneAgentLoopSnapshot as Ft, serializeDurableOptions as G, buildSpanQueryResponse as Ga, createRestartExecutionParams as Gc, DatasetsStorage as Gi, currentRunGeneration as Gl, MemoryInputFilter as Gn, SkillSearchProcessor as Go, notificationSummaryContents as Gr, emitAbortEvent as Gs, runChecks as Gt, createDurableLLMMappingStep as H, SPAN_QUERY_MAX_LIMIT as Ha, assertTimeTravelGraphMatchesSnapshot as Hc, ExperimentsInMemory as Hi, RUN_FENCING_NOT_SUPPORTED_ERROR_ID as Hl, resolveChannelToolsSettings as Hn, ResponseCache as Ho, createNotificationSummarySignal as Hr, isWorkflowStepConflictError as Hs, formatValidationFeedback as Ht, applyReservedMemoryContextKeys as I, threadQueryIdentitySchema as Ia, createStepFromClassifier as Ic, knowledgePositionBetween as Ii, SourcePartSchema as Il, formatToolApproval as In, augmentWithInit as Io, SchedulesStorage as Ir, createWorkflow$1 as Is, DEFAULT_TOOL_DECLINE_REASON as It, serializeToolsMetadata as J, parseSpanQueryRequest as Ja, defineStateAccessors as Jc, assertSupportedPatterns as Ji, resolveRunFence as Jl, WorkingMemory as Jn, ToolSearchProcessor as Jo, readNotificationRoutingRequirement as Jr, emitFinishEvent as Js, runStreamCompletionScorers as Jt, serializeDurableState as K, createSpanQueryPreview as Ka, createTimeTravelExecutionParams as Kc, DatasetItemIdentityConflictError as Ki, isRunFenceConflictError as Kl, SemanticRecall as Kn, SkillsProcessor as Ko, notificationSummarySignalMetadata as Kr, emitChunkEvent as Ks, runCompletionScorers as Kt, persistDurableRunInput as L, threadQueryRequestSchema as La, createStepFromTool as Lc, knowledgeScopeReadable as Li, StepStartPartSchema as Ll, ChannelSessionRejectedError as Ln, getStorageSource as Lo, normalizeScheduleTarget as Lr, WorkflowEventProcessor as Ls, resolveDeclineReason as Lt, AGENT_RESUME_CLAIM_STALE_MS as M, THREAD_QUERY_DEFAULT_LIMIT as Ma, normalizeConcurrency as Mc, canonicalKnowledgeName as Mi, ProcessorStepInputSchema as Ml, MastraStateAdapter as Mn, MemoryProcessor as Mo, ToolProviderConnectionsStorage as Mr, EventedWorkflow as Ms, getRunStreamSlot as Mt, Agent as N, THREAD_QUERY_MAX_LIMIT as Na, runWithConcurrency as Nc, knowledgeLinkRefKey as Ni, ProcessorStepOutputSchema as Nl, ChatChannelProcessor as Nn, memoryDefaultOptions as No, ScoresInMemory as Nr, cloneStep as Ns, getScopeStreamSlot as Nt, agentConfig as O, tracePageIdSchema as Oa, evaluateScoringPredicate as Oc, MAX_KNOWLEDGE_PAGE_LIST_LIMIT as Oi, ProcessorMessageSchema as Ol, buildKnowledgeInstructions as On, messageVectorId as Oo, mergeWorkflowStepResult as Or, cloneWorkflow as Os, RUN_DEADLINE_KEY as Ot, normalizeResumeGenerateArgs as P, encodeThreadQueryCursor as Pa, createMappingStep as Pc, knowledgePagePath as Pi, ProcessorStepSchema as Pl, CHAT_CHANNEL_RENDER_CONTEXT_KEY as Pn, filterSystemReminderMessages as Po, ScoresStorage as Pr, cloneWorkflow$1 as Ps, untilIdleHandlesBackgroundTask as Pt, createDurableBackgroundTaskCheckStep as Q, spanQueryIdentityKey as Qa, getStepIds as Qc, SchemaUpdateValidationError as Qi, MockMemory as Qn, CostGuardProcessor as Qo, resolveNotificationDeliveryDecision as Qr, AgentStreamBus as Qs, PINNED_READ_MEMO_KEY as Qt, detachFullStreamOnEnd as R, threadQueryResponseSchema as Ra, RESUME_SNAPSHOT_POLL_INTERVAL_MS as Rc, parseKnowledgePageRef as Ri, TextPartSchema as Rl, DEFAULT_CHANNEL_TOOLS_SETTINGS as Rn, createBackgroundWorkSignalProcessor as Ro, InMemoryNotificationsStorage as Rr, StepExecutor as Rs, getServerSideFallbackInfo as Rt, MastraScorer as S, storageMessageMatchesMetadataFilter as Sa, nestedRunStatusOf as Sc, MAX_KNOWLEDGE_NOTE_TOKENS as Si, ImagePartSchema as Sl, knowledgeMemoryScopes as Sn, UniqueViolationError as So, MockStore as Sr, FILE_UPLOAD_ERROR_CODES as Ss, createDurableAgentStream as St, filterRun as T, validateStorageMetadataFilter as Ta, repeatAfterSettled as Tc, MAX_KNOWLEDGE_PAGE_DESCRIPTION_TOKENS as Ti, ProcessorInputPhaseSchema as Tl, strongerKnowledgeRole as Tn, buildMessageEmbeddingRows as To, WorkflowsStorage as Tr, isRetryableOpenAIResponsesStreamError as Ts, DURABLE_STOP_WHEN_ERROR_ID as Tt, createDurableToolCallStep as U, SPAN_QUERY_MAX_PREVIEW_CHARACTERS as Ua, cleanStepResult as Uc, ExperimentsStorage as Ui, RunFenceConflictError as Ul, toChatLogger as Un, buildResponseCacheKey as Uo, notificationSignalAttributes as Ur, __resetExecutionFencesForTests as Us, generateFinalResult as Ut, createDurableIsTaskCompleteStep as V, SPAN_QUERY_MAX_CURSOR_BYTES as Va, applyStateDelta as Vc, HarnessStorage as Vi, RUN_FENCE_CONFLICT_ERROR_ID as Vl, createChannelTools as Vn, RESPONSE_CACHE_CONTEXT_KEY as Vo, createNotificationSignal as Vr, assertWorkflowStepGuard as Vs, formatStreamCompletionFeedback as Vt, createWorkflowInput as W, SPAN_QUERY_ORDER_FIELDS as Wa, createDeprecationProxy as Wc, DatasetsInMemory as Wi, coverNestedRun as Wl, BaseProcessor as Wn, WorkspaceInstructionsProcessor as Wo, notificationSignalMetadata as Wr, diffResponseMessages as Ws, generateStructuredFinalResult as Wt, MessagePartSpans as X, resolveSpanQueryCost as Xa, getResumeLabelsByStepId as Xc, getSchemaValidator as Xi, runOutsideRunFenceScope as Xl, MemoryRunState as Xn, ToolCallFilter as Xo, defaultNotificationDeliveryDecision as Xr, emitStepStartEvent as Xs, loop as Xt, createDurableLLMExecutionStep as Y, planSpanQuery as Ya, getRestartStartIndex as Yc, createValidator as Yi, runFencingNotSupportedError as Yl, MessageHistory as Yn, AgentsMDInjector as Yo, MAX_NOTIFICATION_DELIVERY_ATTEMPTS as Yr, emitStepFinishEvent as Ys, runValidation as Yt, isSpanChunk as Z, spanQueryCostSchema as Za, getSingleStepEntryId as Zc, UnsupportedSchemaPatternError as Zi, setRunFenceContext as Zl, getMemoryRunState as Zn, RegexFilterProcessor as Zo, resolveDeliveryFailureUpdate as Zr, emitSuspendedEvent as Zs, validateModelTimeoutSettings as Zt, runEvals as _, hasErrorCode as _a, evaluatePredicate as _c, KnowledgeMoveTooLargeError as _i, workflowTermination as _l, knowledgeAccessGrants as _n, toEntityType as _o, GitHubSourceControlProvider as _r, STABILITY_ERROR_PROCESSOR_IDS as _s, toolRequiresApproval as _t, endRunSpansWithError as a, BackgroundTasksStorage as aa, AgentControlEventTypes as ac, KNOWLEDGE_STORAGE_CONTRACT_VERSION as ai, runCountDeprecationMessage as al, removeKnowledgeNote as an, getTraceQueryDeltaWatermark as ao, assertKnowledgeScopeWithinCeiling as ar, getMemoryTokenBoundary as as, baseIterationStateSchema as at, validateAndSaveScore as b, safelyParseJSON as ba, nestedRunParentOf as bc, KnowledgePageKeyConflictError as bi, isDurableAgentLike as bl, KnowledgeDeclarationError as bn, FactoryStorage as bo, FilesystemDB as br, UnsupportedFileHandler as bs, liveSegmentSpan as bt, globalRunRegistry as c, retentionCutoffMs as ca, getNestedWorkflow as cc, KnowledgeNotFoundError$1 as ci, validateStepRequestContext as cl, upsertKnowledgePage as cn, buildCreateSpanRecord as co, expandKnowledgeScope as cr, BatchPartsProcessor as cs, modelListEntrySchema as ct, takeRunScorerInstances as d, createStoreErrorId as da, Workflow as dc, KnowledgeTransactionDeadlineError as di, validateStepSuspendData as dl, KnowledgeLinkRefreshIncompleteError as dn, buildMetricRecord as do, knowledgeSemanticDocumentId as dr, StructuredOutputProcessor as ds, loadRunStoredMessages as dt, InMemoryChannelsStorage as ea, requestAcknowledgedAbort as ec, MemoryStorage as ei, isEntryFinished as el, buildKnowledgePageTools as en, spanQueryRequestSchema as eo, MAX_KNOWLEDGE_RECORD_TEXT_LENGTH as er, SystemPromptScrubber as es, buildStepRecord as et, AgentThreadLeaseLostError as f, createVectorErrorId as fa, cloneStep$1 as fc, KnowledgeUnsupportedCapabilityError as fi, waitForSuspendedSnapshot as fl, knowledgeSubtree as fn, buildScoreRecord as fo, knowledgeSemanticIdempotencyKey as fr, LanguageDetector as fs, rebuildRunToolsFromMastra as ft, describeNonSuccessFinishReason as g, getSqlType as ga, predicateToCondition as gc, parseKnowledgeWikilinks as gi, waitMs as gl, updateKnowledgeLinks as gn, serializeSpanAttributes as go, StoreOperations as gr, UnicodeNormalizer as gs, resolveTool$1 as gt, AGENTIC_LOOP_WORKFLOW_ID as h, getDefaultValue as ha, mapVariable as hc, inspectKnowledgeSchema as hi, assertDrainTimeout as hl, syncKnowledgePageBodyLinks as hn, getStringOrNull as ho, StoreOperationsInMemory as hr, ModerationProcessor as hs, resolveRuntimeDependencies as ht, deleteRunRegistryEntry as i, BackgroundTasksInMemory as ia, AGENT_STREAM_TOPIC as ic, KnowledgeImportersStorage as ii, resolveForeachConcurrency as il, moveKnowledgePage as in, encodeTraceQueryDeltaCursor as io, assertKnowledgeRecordTextWithinBound as ir, advanceMemoryTokenBoundary as is, baseDurableAgenticInputSchema as it, MAX_FS_SUBAGENT_DEPTH as j, tracePageResponseSchema as ja, createConcurrencyLimiter as jc, assertKnowledgePageDescriptionWithinBound as ji, ProcessorOutputStreamPhaseSchema as jl, defaultTypingStatus as jn, MastraMemory as jo, InMemoryToolProviderConnectionsStorage as jr, EventedRun as js, __registerMastraCtor as jt, agentInstructions as k, tracePageNodeSchema as ka, validateScoringPredicate as kc, MAX_KNOWLEDGE_PIN_LIST_DEPTH as ki, ProcessorOutputResultPhaseSchema as kl, AgentChannels as kn, resolveMaxChunkChars as ko, InMemoryWorkflowDefinitionsStorage as kr, createEventedWorkflow as ks, ensureRemoteAbortListener as kt, isDurableAgentExecutionDetached as l, runRetentionBatches as la, getStepEntry as lc, KnowledgeSchemaResetRequiredError as li, validateStepResumeData as ll, KnowledgeSemanticIndex as ln, buildFeedbackRecord as lo, isKnowledgeScopeVisible as lr, ModelSelectionProcessor as ls, executeDurableAgentScorers as lt, AGENTIC_EXECUTION_WORKFLOW_ID as m, filterByDateRange as ma, isProcessor$1 as mc, createKnowledgeUlid as mi, getEntryWorkflow as ml, reindexKnowledgeLinks as mn, getObjectOrNull as mo, parseKnowledgeNodeCursor as mr, PromptInjectionDetector as ms, resolveModel as mt, RunRegistry as n, InMemoryBlobStore as na, createRunAbortController as nc, KnowledgeImporterBindingConflictError as ni, omitPriorCompletionFields as nl, knowledgeRunPrincipals as nn, spanQueryRowSchema as no, assertKnowledgeCeilingRaised as nr, groupLinkedToolMessages as ns, createBaseIterationStateUpdate as nt, getActiveDurableAgentWorkflowExecutions as o, executeRetentionPrune as oa, AgentStreamEventTypes as oc, KNOWLEDGE_STORAGE_SCHEMA_VERSION as oi, setLongTimeout as ol, removeKnowledgePage as on, planThreadQuery as oo, canonicalizeKnowledgeScope as or, isAfterMemoryTokenBoundary as os, durableAgenticOutputSchema as ot, agentThreadStreamRuntime as p, ensureDate as pa, createStep$1 as pc, assertKnowledgeSchemaCompatible as pi, getEntryId as pl, refreshKnowledgeLinksTo as pn, buildUpdateSpanRecord as po, knowledgeVisibleScopeKeys as pr, PIIDetector as ps, resolveInternalState as pt, serializeModelConfig as q, encodeSpanQueryCursor as qa, defineLazyWriter as qc, SchemaValidator as qi, matchesRunFence as ql, globalEmbeddingCache as qn, formatSkillsCatalog as qo, summarizeNotifications as qr, emitErrorEvent as qs, runDefaultCompletionCheck as qt, abandonDurableAgentExecutions as r, BlobStore as ra, AGENT_CONTROL_TOPIC as rc, KnowledgeImporterRunStateError as ri, omitPriorSuspensionFields as rl, addKnowledgeNote as rn, encodeTraceQueryCursor as ro, assertKnowledgeDescriptionWithinBound as rr, loadMessageHistory as rs, accumulatedUsageSchema as rt, getRunRegistryEntry as s, resolveRetentionTargets as sa, EventedExecutionEngine as sc, KnowledgeConflictError as si, validateStepInput as sl, updateKnowledgeNote as sn, planTraceQuery as so, createKnowledgeNodeCursor as sr, normalizeMessageHistoryConfig as ss, modelConfigSchema as st, ExtendedRunRegistry as t, ChannelsStorage as ta, subscribeToAbortRequests as tc, InMemoryKnowledgeStorage as ti, isSingleStepEntry as tl, KnowledgeRun as tn, spanQueryResponseSchema as to, MAX_KNOWLEDGE_SCOPE_TAGS as tr, TokenLimiterProcessor as ts, calculateAccumulatedUsage as tt, setRunRegistryEntry as u, createStorageErrorId as ua, Run as uc, KnowledgeStorage as ui, validateStepStateData as ul, embed$2 as un, buildLogRecord as uo, knowledgeScopeKey as ur, ClassifierProcessor as us, runDurableFinishSideEffects as ut, flushBeforeTraceRead as v, jsonValueEquals as va, cancelNestedRun as vc, KnowledgePageDepthError as vi, hasDurableExecution as vl, knowledgeReadScopeFor as vn, ObservabilityInMemory as vo, createGitHubSourceControlProviderFromEnv as vr, defaultStabilityErrorProcessors as vs, resolveAgentById as vt, createScorer as w, transformScoreRow as wa, renewWorkflowLease as wc, MAX_KNOWLEDGE_PAGE_DEPTH as wi, MessagePartSchema as wl, knowledgeScopeAddress as wn, MESSAGE_EMBEDDING_CHARS_PER_TOKEN as wo, cloneRunData as wr, isBadRequestError as ws, runResumeDurableStreamUntilIdle as wt, createClassifierScorer as x, serializeDate as xa, nestedRunRecoveryAction as xc, MAX_KNOWLEDGE_MOVE_PAGES as xi, FilePartSchema as xl, compileKnowledgeScopes as xn, FactoryStorageDomain as xo, InMemoryStore as xr, FileUploadProcessor as xs, segmentSpanData as xt, createOnScorerHook as y, parseDuration as ya, createNestedRunParentStatusLookup as yc, KnowledgePageHasChildrenError as yi, hasResumableStreams as yl, knowledgeRoleOn as yn, ObservabilityStorage as yo, FilesystemStore as yr, isMalformedFunctionCallError as ys, carrySegmentSpans as yt, createDurableAgenticWorkflow as z, threadQueryRowSchema as za, RESUME_SNAPSHOT_WAIT_STATUSES as zc, KnowledgeInvalidCursorError as zi, ToolInvocationPartSchema as zl, channelToolScopeResolver as zn, CyberRefusalHandler as zo, NotificationsStorage as zr, computeScheduleDefinitionHash as zs, formatCheckFeedback as zt };
|