UNPKG

@mastra/core

Version:
1 lines • 27.1 kB
{"version":3,"file":"request-context-D9RXYCy8.cjs","names":[],"sources":["../../_internal-core/dist/request-context/index.js","../src/request-context/index.ts"],"sourcesContent":["// src/request-context/index.ts\n/**\n* Reserved key for setting resourceId from middleware.\n* When set in RequestContext, this takes precedence over client-provided values\n* for security (prevents attackers from hijacking another user's memory).\n*\n* @example\n* ```typescript\n* // In your auth middleware:\n* const requestContext = c.get('requestContext');\n* requestContext.set(MASTRA_RESOURCE_ID_KEY, authenticatedUser.id);\n* ```\n*/\nconst MASTRA_RESOURCE_ID_KEY = \"mastra__resourceId\";\n/**\n* Reserved key for setting threadId from middleware.\n* When set in RequestContext, this takes precedence over client-provided values\n* for security (prevents attackers from hijacking another user's memory).\n*\n* @example\n* ```typescript\n* // In your auth middleware:\n* const requestContext = c.get('requestContext');\n* requestContext.set(MASTRA_THREAD_ID_KEY, threadId);\n* ```\n*/\nconst MASTRA_THREAD_ID_KEY = \"mastra__threadId\";\n/**\n* Reserved key for setting agent scopes from middleware.\n*\n* Holds a `string[]` of `<type>:<value>` addresses (for example `org:acme`,\n* `resource:user-1`, `thread:t-9`). Scope types are arbitrary; `resource:` and\n* `thread:` are the conventions Memory reads as the run's resource and thread.\n* Middleware-set scopes are combined with the agent's `scopes` resolver and the\n* per-call `scopes` option. Conflicting `resource:`/`thread:` values throw.\n*\n* During a run, the agent passes tools, processors and sub-agents a copy of the\n* request context whose `mastra__scopes` holds only the non-identity scopes;\n* the caller's own request context is never modified.\n*\n* @example\n* ```typescript\n* // In your auth middleware:\n* const requestContext = c.get('requestContext');\n* requestContext.set(MASTRA_SCOPES_KEY, [`org:${user.orgId}`, `resource:${user.id}`]);\n* ```\n*/\nconst MASTRA_SCOPES_KEY = \"mastra__scopes\";\n/**\n* Reserved key for storing version overrides on RequestContext.\n* When set, sub-agent delegation resolves versioned agents from these overrides.\n*\n* @example\n* ```typescript\n* requestContext.set(MASTRA_VERSIONS_KEY, {\n* agents: { 'researcher-agent': { versionId: '123' } },\n* });\n* ```\n*/\nconst MASTRA_VERSIONS_KEY = \"mastra__versions\";\n/**\n* Reserved key for storing the raw auth token from the incoming request.\n* Used by the editor to forward authentication when connecting to MCP servers\n* that require the same auth as the Mastra server itself.\n*/\nconst MASTRA_AUTH_TOKEN_KEY = \"mastra__authToken\";\n/**\n* Reserved key carrying a delegating agent's `MastraMemory` into a delegated\n* run, so a sub-agent without its own memory can persist that run's transcript\n* without the shared sub-agent instance being modified. The value is\n* `{ agentId, memory }` and only the named agent reads it.\n*\n* Holds a live class instance, so it is deliberately run-scoped: it is excluded\n* from the durable request-context snapshot and is not copied into further\n* nested delegated runs. Internal to delegation — do not set it yourself.\n*/\nconst MASTRA_INHERITED_MEMORY_KEY = \"mastra__inheritedMemory\";\n/**\n* Reserved key naming who sent a user message: `{ id, name?, avatarUrl? }`.\n* Set by the host that authenticated the request; the agent-controller copies\n* it onto the sent message as `providerMetadata.mastra.author` so a shared\n* thread can show who wrote what.\n*\n* @example\n* ```typescript\n* // In your auth middleware:\n* requestContext.setRaw(MASTRA_MESSAGE_AUTHOR_KEY, { id: user.id, name: user.name, avatarUrl: user.avatarUrl });\n* ```\n*/\nconst MASTRA_MESSAGE_AUTHOR_KEY = \"mastra__messageAuthor\";\n/**\n* Reserved key holding the authenticated end user, normalized to the\n* `MastraUser` shape (`{ id, name?, email?, avatarUrl?, role? }`).\n*\n* Set by the server auth middleware after an auth provider authenticates the\n* request (via `MastraAuthProvider.toMastraUser()`). Read at\n* `DynamicArgument` resolution time so config callbacks receive an optional\n* `user` argument. The raw provider-specific user object is stored separately\n* under `mastra__user`.\n*/\nconst MASTRA_NORMALIZED_USER_KEY = \"mastra__normalizedUser\";\n/**\n* Keys that only describe the request that set them: the bearer token and the\n* authenticated user with their roles, permissions and Knowledge principals.\n* The user keys are set by the server auth middleware (`mastra__user`,\n* `mastra__userRoles`, `mastra__userPermissions` and\n* `mastra__knowledgePrincipals` are defined in `@mastra/server`) and are\n* reserved, so clients cannot supply them.\n*/\nconst LIVE_REQUEST_KEYS = [\n\tMASTRA_AUTH_TOKEN_KEY,\n\tMASTRA_NORMALIZED_USER_KEY,\n\t\"mastra__user\",\n\t\"mastra__userPermissions\",\n\t\"mastra__userRoles\",\n\t\"mastra__knowledgePrincipals\"\n];\n/**\n* Unprefixed aliases the server auth middleware writes next to the namespaced\n* keys for backward compatibility. They aren't reserved, and apps without the\n* server may store their own values under them, so each alias is only dropped\n* when its namespaced key shows the auth middleware wrote it.\n*/\nconst LEGACY_USER_ALIASES = {\n\tuser: \"mastra__user\",\n\tuserRoles: \"mastra__userRoles\",\n\tuserPermissions: \"mastra__userPermissions\"\n};\n/**\n* Returns a copy of a persisted request context without the keys that belong to\n* the request that wrote it (the bearer token and the authenticated user, roles\n* and permissions). Workflow and durable-agent resume, restart and time travel\n* use this so those values come from the request doing the resuming, and a\n* resume without a signed-in user can't act as the user who started the run.\n*/\nfunction withoutLiveRequestKeys(requestContext) {\n\tconst rest = { ...requestContext };\n\tfor (const [alias, key] of Object.entries(LEGACY_USER_ALIASES)) if (key in rest) delete rest[alias];\n\tfor (const key of LIVE_REQUEST_KEYS) delete rest[key];\n\treturn rest;\n}\n/**\n* Whether a request-context key is reserved for Mastra itself.\n*\n* Framework keys use the `mastra__` prefix (e.g. `mastra__threadId`,\n* `mastra__authToken`) and internal runtime plumbing uses the `__mastra_`\n* prefix (e.g. the channel render context, which holds live platform adapters).\n* Reserved keys are framework state rather than caller-provided data, so they\n* are left out of span serialization.\n*/\nfunction isReservedRequestContextKey(key) {\n\treturn key.startsWith(\"mastra__\") || key.startsWith(\"__mastra_\");\n}\nfunction mergeVersionOverrides(base, overrides) {\n\tif (!base && !overrides) return void 0;\n\treturn {\n\t\t...base,\n\t\t...overrides,\n\t\tagents: {\n\t\t\t...base?.agents,\n\t\t\t...overrides?.agents\n\t\t},\n\t\t...overrides?.defaultStatus ? { defaultStatus: overrides.defaultStatus } : base?.defaultStatus ? { defaultStatus: base.defaultStatus } : {}\n\t};\n}\n/**\n* Marker thrown by `RequestContext.toJSON()` when it detects cyclic re-entry.\n*\n* Cyclic re-entry happens when a stored value transitively references another\n* `RequestContext` whose `toJSON()` is already on the call stack. `JSON.stringify`\n* inside `isSerializable` then walks into that context, V8 invokes its\n* `toJSON()`, which iterates its registry and calls `JSON.stringify` on values\n* that may walk back through the first context — and so on. Each step is a\n* fresh `JSON.stringify` call with a fresh internal cycle stack, so V8's\n* built-in cycle detection never trips and the recursion would pin one CPU\n* core at 100% indefinitely.\n*\n* The fix: throw this marker on reentry. The marker propagates upward through\n* `isSerializable`'s nested catches (which re-throw it) until it reaches the\n* outermost `toJSON()`'s `isSerializable` — there it is swallowed and the\n* offending key is filtered, the same way in-value circular references are\n* filtered today.\n*/\nvar CyclicRequestContextToJSONError = class extends Error {\n\tconstructor(message) {\n\t\tsuper(message);\n\t\tthis.name = \"CyclicRequestContextToJSONError\";\n\t}\n};\n/**\n* Tracks `RequestContext` instances whose `toJSON()` is currently on the call\n* stack. Used to detect cyclic re-entry. Stored as a `WeakSet` so entries are\n* garbage-collected with their owning context.\n*/\nconst _toJSONInProgress = /* @__PURE__ */ new WeakSet();\n/**\n* Nesting depth of active `toJSON()` calls. The outermost call (depth === 1\n* after entry) catches the cyclic marker error and filters the offending\n* value; inner calls re-throw so the marker propagates to the outermost.\n*/\nlet _toJSONDepth = 0;\n/**\n* Maximum number of nodes the `isSerializable` probe lets `JSON.stringify`\n* visit for a single stored value.\n*\n* `JSON.stringify` expands shared (non-circular) references once per path,\n* not once per object: an acyclic graph where every level shares one child\n* (`{ a: n, b: n }` nested `d` times) holds `d + 1` heap objects but expands\n* to `2^d` visited nodes. Around `2^26` the output also exceeds V8's string\n* length cap and stringify throws `RangeError` — but only after doing the\n* traversal work, which keeps doubling past the cap. Unbounded, a ~30-object\n* value can block the event loop for minutes and then be silently filtered.\n*\n* The budget counts node *visits* (shared references count once per path)\n* because that is exactly the work any real downstream serialization of the\n* value would do — a value that fails the budget would also be pathological\n* to persist. 1M visits keeps the worst-case probe in the tens of\n* milliseconds while remaining far above any reasonable context value.\n*\n* The budget is shared across nested `RequestContext` probes within one\n* outermost probe (see `_probeBudgetRemaining`), so a shared-reference graph of\n* nested contexts is bounded too. One caveat remains: `Buffer.prototype.toJSON`\n* materializes a `{ type, data }` object before the replacer, so Buffers charge\n* one budget unit per byte rather than the arithmetic typed-array fast path — a\n* Buffer past the budget is filtered.\n*/\nconst SERIALIZATION_PROBE_BUDGET = 1e6;\n/**\n* The intrinsic `%TypedArray%.prototype.length` getter. Reads the element\n* count from internal slots, so it cannot be shadowed by an own `length`\n* property, works across realms, and throws `TypeError` for `DataView` —\n* which makes it double as the discriminator between typed arrays (intrinsic\n* indexed elements) and other `ArrayBuffer` views (plain-object semantics).\n*/\nconst _typedArrayLength = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Int8Array.prototype), \"length\").get;\n/**\n* Whether a value is a plain object (prototype `Object.prototype` or `null`)\n* or an array — i.e. structural data safe to hand to the span serializer to\n* walk. Class instances, functions, `Map`/`Set`, `Date`, etc. are excluded so\n* their internals aren't walked into traces.\n*/\nfunction isPlainObjectOrArray(value) {\n\ttry {\n\t\tif (Array.isArray(value)) return true;\n\t\tif (value === null || typeof value !== \"object\") return false;\n\t\tconst proto = Object.getPrototypeOf(value);\n\t\treturn proto === Object.prototype || proto === null;\n\t} catch {\n\t\treturn false;\n\t}\n}\n/**\n* Shared state for the serialization probe budget.\n*\n* The budget is drawn down by every `isSerializable` probe running within one\n* outermost probe — including the probes a nested `RequestContext.toJSON()`\n* runs, which `JSON.stringify` invokes *before* the outer replacer sees the\n* result. Sharing one budget across them keeps the probe's time bound holding\n* regardless of nesting; a fresh per-call budget (the earlier approach) let a\n* shared-reference graph of nested contexts re-run full-budget probes on every\n* visit and block for seconds. `_probeBudgetActive` marks that an outermost\n* probe owns the budget so nested probes draw down rather than reset it.\n*/\nlet _probeBudgetActive = false;\nlet _probeBudgetRemaining = 0;\n/**\n* Carries typed, request-specific values through agents, tools, and workflows.\n* Pass the instance as `requestContext` when starting an operation.\n*\n* @example\n* ```typescript\n* import { RequestContext } from '@mastra/core/request-context';\n*\n* const requestContext = new RequestContext<{ locale: string }>([\n* ['locale', 'en'],\n* ]);\n* ```\n*\n* @see For documentation bundled with your installed package, locate\n* `@mastra/core/package.json` with your project's resolver or package-manager\n* tooling, then read `dist/docs/SKILL.md` from that package root and follow its\n* reference links. Use package-manager tools for virtual or archived packages.\n*\n* @see [Request context documentation](https://mastra.ai/docs/server/request-context)\n* if packaged docs are unavailable.\n*/\nvar RequestContext = class {\n\tregistry = /* @__PURE__ */ new Map();\n\tconstructor(iterable) {\n\t\tif (iterable && typeof iterable === \"object\" && typeof iterable[Symbol.iterator] !== \"function\") this.registry = new Map(Object.entries(iterable));\n\t\telse this.registry = new Map(iterable);\n\t}\n\t/**\n\t* set a value with strict typing if `Values` is a Record and the key exists in it.\n\t*\n\t* Declared schema keys stay strictly typed. For runtime-only keys that are not part of\n\t* `Values` (for example reserved middleware keys), use {@link setRaw}.\n\t*/\n\tset(key, value) {\n\t\tthis.registry.set(key, value);\n\t}\n\t/**\n\t* Set a runtime-only key that is not part of the declared `Values` schema.\n\t*\n\t* The runtime store is an open map: schema validation checks declared keys and\n\t* passes undeclared keys through. Use this when writing infrastructure keys\n\t* (for example `mastra__resourceId`) or other values that intentionally omit\n\t* from `requestContextSchema`.\n\t*/\n\tsetRaw(key, value) {\n\t\tthis.registry.set(key, value);\n\t}\n\t/**\n\t* Get a value with its type\n\t*\n\t* Declared schema keys stay strictly typed. For runtime-only keys that are not part of\n\t* `Values` (for example reserved middleware keys), use {@link getRaw}.\n\t*/\n\tget(key) {\n\t\treturn this.registry.get(key);\n\t}\n\t/**\n\t* Get a runtime-only key that is not part of the declared `Values` schema.\n\t*\n\t* Returns `unknown` because the schema does not describe these keys — narrow\n\t* the result at the call site.\n\t*/\n\tgetRaw(key) {\n\t\treturn this.registry.get(key);\n\t}\n\t/**\n\t* Check if a key exists in the container\n\t*\n\t* Declared schema keys stay strictly typed. For runtime-only keys, use {@link hasRaw}.\n\t*/\n\thas(key) {\n\t\treturn this.registry.has(key);\n\t}\n\t/**\n\t* Check whether a runtime-only key exists in the open map.\n\t*/\n\thasRaw(key) {\n\t\treturn this.registry.has(key);\n\t}\n\t/**\n\t* Delete a value by key\n\t*\n\t* Declared schema keys stay strictly typed. For runtime-only keys, use {@link deleteRaw}.\n\t*/\n\tdelete(key) {\n\t\treturn this.registry.delete(key);\n\t}\n\t/**\n\t* Delete a runtime-only key from the open map.\n\t*/\n\tdeleteRaw(key) {\n\t\treturn this.registry.delete(key);\n\t}\n\t/**\n\t* Clear all values from the container\n\t*/\n\tclear() {\n\t\tthis.registry.clear();\n\t}\n\t/**\n\t* Get all keys in the container\n\t*/\n\tkeys() {\n\t\treturn this.registry.keys();\n\t}\n\t/**\n\t* Get all values in the container\n\t*/\n\tvalues() {\n\t\treturn this.registry.values();\n\t}\n\t/**\n\t* Get all entries in the container.\n\t* Returns a discriminated union of tuples for proper type narrowing when iterating.\n\t*/\n\tentries() {\n\t\treturn this.registry.entries();\n\t}\n\t/**\n\t* Get the size of the container\n\t*/\n\tsize() {\n\t\treturn this.registry.size;\n\t}\n\t/**\n\t* Execute a function for each entry in the container.\n\t* The callback receives properly typed key-value pairs.\n\t*/\n\tforEach(callbackfn) {\n\t\tthis.registry.forEach(callbackfn);\n\t}\n\t/**\n\t* Custom JSON serialization method.\n\t* Converts the internal Map to a plain object for proper JSON serialization.\n\t* Non-serializable values (functions, symbols, RPC proxies, in-value\n\t* circular references, and values whose serialization re-enters this\n\t* `toJSON` via cross-context back-references) are skipped to prevent\n\t* serialization errors when storing to database.\n\t*\n\t* Reentry safety: if a stored value's `isSerializable` probe re-enters\n\t* `toJSON()` on this same instance (through a chain of RequestContexts\n\t* holding references to each other), we throw `CyclicRequestContextToJSONError`.\n\t* Inner `isSerializable` calls re-throw the marker; the outermost\n\t* `isSerializable` swallows it and filters the offending key, the same\n\t* way it filters in-value circular references today.\n\t*/\n\ttoJSON() {\n\t\tif (_toJSONInProgress.has(this)) throw new CyclicRequestContextToJSONError(\"RequestContext.toJSON: detected cyclic re-entry (a stored value transitively references this context)\");\n\t\t_toJSONInProgress.add(this);\n\t\t_toJSONDepth++;\n\t\ttry {\n\t\t\tconst result = {};\n\t\t\tfor (const [key, value] of this.registry.entries()) if (this.isSerializable(value)) result[key] = value;\n\t\t\treturn result;\n\t\t} finally {\n\t\t\t_toJSONInProgress.delete(this);\n\t\t\t_toJSONDepth--;\n\t\t}\n\t}\n\t/**\n\t* Check if a value can be safely serialized to JSON.\n\t*\n\t* The probe is budgeted (see `SERIALIZATION_PROBE_BUDGET`): a value whose\n\t* serialization would visit an unbounded number of nodes — an acyclic\n\t* graph with layered shared references expands as 2^depth — is treated as\n\t* non-serializable and filtered instead of blocking the event loop for\n\t* the full expansion. The budget is shared across nested `RequestContext`\n\t* probes within one outermost probe (a nested `toJSON()` runs before the\n\t* replacer sees its result), so the bound holds even when the graph reaches\n\t* nested contexts through many shared paths.\n\t*\n\t* Re-throws `CyclicRequestContextToJSONError` when called from a nested\n\t* `toJSON()` (`_toJSONDepth > 1`), so the marker propagates up to the\n\t* outermost `toJSON()`'s `isSerializable`, which then swallows it and\n\t* filters the offending key. This is what lets the outermost call return\n\t* a clean JSON-safe dict for cross-context cycles.\n\t*/\n\tisSerializable(value) {\n\t\tif (value === null || value === void 0) return true;\n\t\tif (typeof value === \"function\") return false;\n\t\tif (typeof value === \"symbol\") return false;\n\t\tif (typeof value !== \"object\" && typeof value !== \"bigint\") return true;\n\t\tconst outermostProbe = !_probeBudgetActive;\n\t\tif (outermostProbe) {\n\t\t\t_probeBudgetActive = true;\n\t\t\t_probeBudgetRemaining = SERIALIZATION_PROBE_BUDGET;\n\t\t}\n\t\ttry {\n\t\t\tJSON.stringify(value, (_key, probed) => {\n\t\t\t\tif (--_probeBudgetRemaining < 0) throw new RangeError(\"RequestContext.isSerializable: value expands past the serialization probe budget\");\n\t\t\t\tif (ArrayBuffer.isView(probed)) {\n\t\t\t\t\tlet elementCount;\n\t\t\t\t\ttry {\n\t\t\t\t\t\telementCount = _typedArrayLength.call(probed);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\treturn probed;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof probed[0] === \"bigint\") return probed;\n\t\t\t\t\t_probeBudgetRemaining -= elementCount;\n\t\t\t\t\tif (_probeBudgetRemaining < 0) throw new RangeError(\"RequestContext.isSerializable: value expands past the serialization probe budget\");\n\t\t\t\t\tconst surrogate = Object.create(null);\n\t\t\t\t\tfor (const key of Object.keys(probed)) {\n\t\t\t\t\t\tconst index = Number(key);\n\t\t\t\t\t\tif (!(Number.isInteger(index) && index >= 0 && String(index) === key)) surrogate[key] = probed[key];\n\t\t\t\t\t}\n\t\t\t\t\treturn surrogate;\n\t\t\t\t}\n\t\t\t\treturn probed;\n\t\t\t});\n\t\t\treturn true;\n\t\t} catch (e) {\n\t\t\tif (e instanceof CyclicRequestContextToJSONError && _toJSONDepth > 1) throw e;\n\t\t\treturn false;\n\t\t} finally {\n\t\t\tif (outermostProbe) _probeBudgetActive = false;\n\t\t}\n\t}\n\t/**\n\t* Custom span serialization. Exposes the registry *entries* (never the\n\t* instance's own private fields) so `deepClean` in `@mastra/observability`\n\t* doesn't walk the runtime-enumerable `registry` Map — which would\n\t* serialize its raw entries (including bearer tokens) into exported spans.\n\t*\n\t* Per stored value:\n\t* - Reserved Mastra keys (`mastra__*`, `__mastra_*`) are omitted. They hold\n\t* framework state such as the auth token, delegated memory, and live\n\t* channel adapters, not caller-provided data.\n\t* - Primitives are returned as-is.\n\t* - Plain objects and arrays are returned by reference so the downstream\n\t* `deepClean` walks and bounds them — this keeps nested request-context\n\t* data visible in traces instead of collapsing it to `[object]`.\n\t* - Every other type (class instances, functions, Map/Set, Date, etc.) is\n\t* collapsed to `[${typeof value}]` rather than walked, so a class's\n\t* internals never reach the trace serializer.\n\t*\n\t* The plain objects/arrays passed through here MUST still be bounded by a\n\t* downstream `deepClean` before export.\n\t*/\n\tserializeForSpan() {\n\t\tconst safe = {};\n\t\tfor (const [key, value] of this.registry.entries()) {\n\t\t\tif (isReservedRequestContextKey(key)) continue;\n\t\t\tif (value === null || value === void 0 || typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") safe[key] = value;\n\t\t\telse if (isPlainObjectOrArray(value)) safe[key] = value;\n\t\t\telse safe[key] = `[${typeof value}]`;\n\t\t}\n\t\treturn safe;\n\t}\n\t/**\n\t* Get all values as a typed object for destructuring.\n\t* Returns Record<string, any> when untyped, or the Values type when typed.\n\t*\n\t* @example\n\t* ```typescript\n\t* const ctx = new RequestContext<{ userId: string; apiKey: string }>();\n\t* ctx.set('userId', 'user-123');\n\t* ctx.set('apiKey', 'key-456');\n\t* const { userId, apiKey } = ctx.all;\n\t* ```\n\t*/\n\tget all() {\n\t\treturn Object.fromEntries(this.registry);\n\t}\n};\nexport { MASTRA_AUTH_TOKEN_KEY, MASTRA_INHERITED_MEMORY_KEY, MASTRA_MESSAGE_AUTHOR_KEY, MASTRA_NORMALIZED_USER_KEY, MASTRA_RESOURCE_ID_KEY, MASTRA_SCOPES_KEY, MASTRA_THREAD_ID_KEY, MASTRA_VERSIONS_KEY, RequestContext, isReservedRequestContextKey, mergeVersionOverrides, withoutLiveRequestKeys };\n\n//# sourceMappingURL=index.js.map","export {\n MASTRA_AUTH_TOKEN_KEY,\n MASTRA_INHERITED_MEMORY_KEY,\n MASTRA_MESSAGE_AUTHOR_KEY,\n MASTRA_NORMALIZED_USER_KEY,\n MASTRA_RESOURCE_ID_KEY,\n MASTRA_SCOPES_KEY,\n MASTRA_THREAD_ID_KEY,\n MASTRA_VERSIONS_KEY,\n RequestContext,\n isReservedRequestContextKey,\n mergeVersionOverrides,\n withoutLiveRequestKeys,\n} from '@internal/core/request-context';\nexport type { VersionOverrides, VersionSelector } from '@internal/core/request-context';\n\n/**\n * Internal key carrying the tool-call IDs an `untilIdle` continuation turn reports\n * as finished, so message history can load their messages even when they fall\n * outside the history window.\n */\nexport const MASTRA_CONTINUATION_TOOL_CALL_IDS_KEY = '__mastra_continuationToolCallIds';\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAM,yBAAyB;;;;;;;;;;;;;AAa/B,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;AAqB7B,MAAM,oBAAoB;;;;;;;;;;;;AAY1B,MAAM,sBAAsB;;;;;;AAM5B,MAAM,wBAAwB;;;;;;;;;;;AAW9B,MAAM,8BAA8B;;;;;;;;;;;;;AAapC,MAAM,4BAA4B;;;;;;;;;;;AAWlC,MAAM,6BAA6B;;;;;;;;;AASnC,MAAM,oBAAoB;CACzB;CACA;CACA;CACA;CACA;CACA;AACD;;;;;;;AAOA,MAAM,sBAAsB;CAC3B,MAAM;CACN,WAAW;CACX,iBAAiB;AAClB;;;;;;;;AAQA,SAAS,uBAAuB,gBAAgB;CAC/C,MAAM,OAAO,EAAE,GAAG,eAAe;CACjC,KAAK,MAAM,CAAC,OAAO,QAAQ,OAAO,QAAQ,mBAAmB,GAAG,IAAI,OAAO,MAAM,OAAO,KAAK;CAC7F,KAAK,MAAM,OAAO,mBAAmB,OAAO,KAAK;CACjD,OAAO;AACR;;;;;;;;;;AAUA,SAAS,4BAA4B,KAAK;CACzC,OAAO,IAAI,WAAW,UAAU,KAAK,IAAI,WAAW,WAAW;AAChE;AACA,SAAS,sBAAsB,MAAM,WAAW;CAC/C,IAAI,CAAC,QAAQ,CAAC,WAAW,OAAO,KAAK;CACrC,OAAO;EACN,GAAG;EACH,GAAG;EACH,QAAQ;GACP,GAAG,MAAM;GACT,GAAG,WAAW;EACf;EACA,GAAG,WAAW,gBAAgB,EAAE,eAAe,UAAU,cAAc,IAAI,MAAM,gBAAgB,EAAE,eAAe,KAAK,cAAc,IAAI,CAAC;CAC3I;AACD;;;;;;;;;;;;;;;;;;;AAmBA,IAAI,kCAAkC,cAAc,MAAM;CACzD,YAAY,SAAS;EACpB,MAAM,OAAO;E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