@mastra/memory 1.41.3-alpha.1 → 1.41.3-alpha.3
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/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +71 -71
- package/dist/docs/references/docs-memory-observational-memory.md +3 -3
- package/dist/docs/references/docs-memory-working-memory.md +33 -0
- package/dist/hooks.cjs +0 -2
- package/dist/hooks.js +0 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +26 -3
- package/dist/index.js +1 -1
- package/dist/processors/index.cjs +1 -1
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/buffered-reflection-values.d.ts +7 -0
- package/dist/processors/observational-memory/buffering-coordinator.d.ts +38 -0
- package/dist/processors/observational-memory/reflector-runner.d.ts +14 -0
- package/dist/processors/working-memory-instruction-compat.d.ts +54 -0
- package/dist/{src-CKA5LbDL.cjs → src-CDIIMmAU.cjs} +1342 -884
- package/dist/{src-BvZXenIm.js → src-CDv__4kY.js} +521 -63
- package/package.json +8 -7
- package/dist/hooks.cjs.map +0 -1
- package/dist/hooks.d.ts.map +0 -1
- package/dist/hooks.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/persistence-projection.test-utils.d.ts.map +0 -1
- package/dist/processors/index.d.ts.map +0 -1
- package/dist/processors/observational-memory/activation-ttl.d.ts.map +0 -1
- package/dist/processors/observational-memory/anchor-ids.d.ts.map +0 -1
- package/dist/processors/observational-memory/auto-model.d.ts.map +0 -1
- package/dist/processors/observational-memory/buffering-coordinator.d.ts.map +0 -1
- package/dist/processors/observational-memory/built-in-extractors.d.ts.map +0 -1
- package/dist/processors/observational-memory/commit-queue.d.ts.map +0 -1
- package/dist/processors/observational-memory/constants.d.ts.map +0 -1
- package/dist/processors/observational-memory/date-utils.d.ts.map +0 -1
- package/dist/processors/observational-memory/debug.d.ts.map +0 -1
- package/dist/processors/observational-memory/error.d.ts.map +0 -1
- package/dist/processors/observational-memory/extracted-values.d.ts.map +0 -1
- package/dist/processors/observational-memory/extraction-runner.d.ts.map +0 -1
- package/dist/processors/observational-memory/extractor.d.ts.map +0 -1
- package/dist/processors/observational-memory/hooks.d.ts.map +0 -1
- package/dist/processors/observational-memory/index.d.ts.map +0 -1
- package/dist/processors/observational-memory/internal-request-context.d.ts.map +0 -1
- package/dist/processors/observational-memory/markers.d.ts.map +0 -1
- package/dist/processors/observational-memory/measure-image-buffer.d.ts.map +0 -1
- package/dist/processors/observational-memory/message-utils.d.ts.map +0 -1
- package/dist/processors/observational-memory/model-by-input-tokens.d.ts.map +0 -1
- package/dist/processors/observational-memory/model-context.d.ts.map +0 -1
- package/dist/processors/observational-memory/observation-groups.d.ts.map +0 -1
- package/dist/processors/observational-memory/observation-strategies/async-buffer.d.ts.map +0 -1
- package/dist/processors/observational-memory/observation-strategies/base.d.ts.map +0 -1
- package/dist/processors/observational-memory/observation-strategies/index.d.ts.map +0 -1
- package/dist/processors/observational-memory/observation-strategies/resource-scoped.d.ts.map +0 -1
- package/dist/processors/observational-memory/observation-strategies/sync.d.ts.map +0 -1
- package/dist/processors/observational-memory/observation-strategies/thread-title.d.ts.map +0 -1
- package/dist/processors/observational-memory/observation-strategies/types.d.ts.map +0 -1
- package/dist/processors/observational-memory/observation-turn/index.d.ts.map +0 -1
- package/dist/processors/observational-memory/observation-turn/load-memory-context.d.ts.map +0 -1
- package/dist/processors/observational-memory/observation-turn/safe-buffer-prefix.d.ts.map +0 -1
- package/dist/processors/observational-memory/observation-turn/step.d.ts.map +0 -1
- package/dist/processors/observational-memory/observation-turn/turn.d.ts.map +0 -1
- package/dist/processors/observational-memory/observation-turn/types.d.ts.map +0 -1
- package/dist/processors/observational-memory/observation-utils.d.ts.map +0 -1
- package/dist/processors/observational-memory/observational-memory.d.ts.map +0 -1
- package/dist/processors/observational-memory/observer-agent.d.ts.map +0 -1
- package/dist/processors/observational-memory/observer-runner.d.ts.map +0 -1
- package/dist/processors/observational-memory/operation-registry.d.ts.map +0 -1
- package/dist/processors/observational-memory/processor.d.ts.map +0 -1
- package/dist/processors/observational-memory/record-lineage.d.ts.map +0 -1
- package/dist/processors/observational-memory/reflector-agent.d.ts.map +0 -1
- package/dist/processors/observational-memory/reflector-runner.d.ts.map +0 -1
- package/dist/processors/observational-memory/repro-capture.d.ts.map +0 -1
- package/dist/processors/observational-memory/retry.d.ts.map +0 -1
- package/dist/processors/observational-memory/string-utils.d.ts.map +0 -1
- package/dist/processors/observational-memory/summarize.d.ts.map +0 -1
- package/dist/processors/observational-memory/temporal-markers.d.ts.map +0 -1
- package/dist/processors/observational-memory/temporary-memory.d.ts.map +0 -1
- package/dist/processors/observational-memory/thresholds.d.ts.map +0 -1
- package/dist/processors/observational-memory/token-counter.d.ts.map +0 -1
- package/dist/processors/observational-memory/tool-argument-helpers.d.ts.map +0 -1
- package/dist/processors/observational-memory/tool-result-helpers.d.ts.map +0 -1
- package/dist/processors/observational-memory/tracing.d.ts.map +0 -1
- package/dist/processors/observational-memory/transform-hooks.d.ts.map +0 -1
- package/dist/processors/observational-memory/types.d.ts.map +0 -1
- package/dist/processors/observational-memory/wait-with-abort.d.ts.map +0 -1
- package/dist/processors/observational-memory/working-memory-extractor.d.ts.map +0 -1
- package/dist/processors/working-memory-state/index.d.ts.map +0 -1
- package/dist/processors/working-memory-state/processor.d.ts.map +0 -1
- package/dist/removed-subconscious.d.ts.map +0 -1
- package/dist/src-BvZXenIm.js.map +0 -1
- package/dist/src-CKA5LbDL.cjs.map +0 -1
- package/dist/system-reminders.d.ts.map +0 -1
- package/dist/tools/om-observations.d.ts.map +0 -1
- package/dist/tools/om-search-context.d.ts.map +0 -1
- package/dist/tools/om-tools.d.ts.map +0 -1
- package/dist/tools/working-memory.d.ts.map +0 -1
|
@@ -19103,7 +19103,7 @@ function encodeSubprotocolValue(value) {
|
|
|
19103
19103
|
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
19104
19104
|
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/u, "");
|
|
19105
19105
|
}
|
|
19106
|
-
const z$
|
|
19106
|
+
const z$6 = {
|
|
19107
19107
|
any: zod_v4.any,
|
|
19108
19108
|
array: zod_v4.array,
|
|
19109
19109
|
boolean: zod_v4.boolean,
|
|
@@ -19243,7 +19243,7 @@ var GatewayRateLimitError = class extends GatewayError {
|
|
|
19243
19243
|
const name$6 = "GatewayModelNotFoundError";
|
|
19244
19244
|
const marker$6 = `vercel.ai.gateway.error.${name$6}`;
|
|
19245
19245
|
const symbol$6 = Symbol.for(marker$6);
|
|
19246
|
-
const modelNotFoundParamSchema = lazySchema(() => zodSchema(z$
|
|
19246
|
+
const modelNotFoundParamSchema = lazySchema(() => zodSchema(z$6.object({ modelId: z$6.string() })));
|
|
19247
19247
|
/**
|
|
19248
19248
|
* Model not found or not available
|
|
19249
19249
|
*/
|
|
@@ -19337,7 +19337,7 @@ var GatewayFailedDependencyError = class extends GatewayError {
|
|
|
19337
19337
|
const name$2 = "GatewayForbiddenError";
|
|
19338
19338
|
const marker$2 = `vercel.ai.gateway.error.${name$2}`;
|
|
19339
19339
|
const symbol$2 = Symbol.for(marker$2);
|
|
19340
|
-
const forbiddenParamSchema = lazySchema(() => zodSchema(z$
|
|
19340
|
+
const forbiddenParamSchema = lazySchema(() => zodSchema(z$6.object({ ruleId: z$6.string() })));
|
|
19341
19341
|
/**
|
|
19342
19342
|
* Forbidden - the request was rejected by policy (e.g. a routing rule),
|
|
19343
19343
|
* not an authentication failure.
|
|
@@ -19477,14 +19477,14 @@ async function createGatewayErrorFromResponse({ response, statusCode, defaultMes
|
|
|
19477
19477
|
});
|
|
19478
19478
|
}
|
|
19479
19479
|
}
|
|
19480
|
-
const gatewayErrorResponseSchema = lazySchema(() => zodSchema(z$
|
|
19481
|
-
error: z$
|
|
19482
|
-
message: z$
|
|
19483
|
-
type: z$
|
|
19484
|
-
param: z$
|
|
19485
|
-
code: z$
|
|
19480
|
+
const gatewayErrorResponseSchema = lazySchema(() => zodSchema(z$6.object({
|
|
19481
|
+
error: z$6.object({
|
|
19482
|
+
message: z$6.string(),
|
|
19483
|
+
type: z$6.string().nullish(),
|
|
19484
|
+
param: z$6.unknown().nullish(),
|
|
19485
|
+
code: z$6.union([z$6.string(), z$6.number()]).nullish()
|
|
19486
19486
|
}),
|
|
19487
|
-
generationId: z$
|
|
19487
|
+
generationId: z$6.string().nullish()
|
|
19488
19488
|
})));
|
|
19489
19489
|
function extractApiCallResponse(error) {
|
|
19490
19490
|
if (error.data !== void 0) return error.data;
|
|
@@ -19583,7 +19583,7 @@ async function parseAuthMethod(headers) {
|
|
|
19583
19583
|
});
|
|
19584
19584
|
return result.success ? result.value : void 0;
|
|
19585
19585
|
}
|
|
19586
|
-
const gatewayAuthMethodSchema = lazySchema(() => zodSchema(z$
|
|
19586
|
+
const gatewayAuthMethodSchema = lazySchema(() => zodSchema(z$6.union([z$6.literal("api-key"), z$6.literal("oidc")])));
|
|
19587
19587
|
const KNOWN_MODEL_TYPES = [
|
|
19588
19588
|
"embedding",
|
|
19589
19589
|
"decision",
|
|
@@ -19608,7 +19608,7 @@ var GatewayFetchMetadata = class {
|
|
|
19608
19608
|
headers: this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
19609
19609
|
successfulResponseHandler: createJsonResponseHandler(gatewayAvailableModelsResponseSchema),
|
|
19610
19610
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
19611
|
-
errorSchema: z$
|
|
19611
|
+
errorSchema: z$6.any(),
|
|
19612
19612
|
errorToMessage: (data) => getErrorMessage(data) ?? "unknown error"
|
|
19613
19613
|
}),
|
|
19614
19614
|
fetch: this.config.fetch
|
|
@@ -19631,7 +19631,7 @@ var GatewayFetchMetadata = class {
|
|
|
19631
19631
|
headers,
|
|
19632
19632
|
successfulResponseHandler: createJsonResponseHandler(gatewayCreditsResponseSchema),
|
|
19633
19633
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
19634
|
-
errorSchema: z$
|
|
19634
|
+
errorSchema: z$6.any(),
|
|
19635
19635
|
errorToMessage: (data) => getErrorMessage(data) ?? "unknown error"
|
|
19636
19636
|
}),
|
|
19637
19637
|
fetch: this.config.fetch
|
|
@@ -19646,31 +19646,31 @@ function getTeamIdOrSlug(headers) {
|
|
|
19646
19646
|
if (!headers) return void 0;
|
|
19647
19647
|
for (const [name, value] of Object.entries(headers)) if (name.toLowerCase() === "x-vercel-ai-gateway-team") return value?.trim() || void 0;
|
|
19648
19648
|
}
|
|
19649
|
-
const gatewayAvailableModelsResponseSchema = lazySchema(() => zodSchema(z$
|
|
19650
|
-
id: z$
|
|
19651
|
-
name: z$
|
|
19652
|
-
description: z$
|
|
19653
|
-
pricing: z$
|
|
19654
|
-
input: z$
|
|
19655
|
-
output: z$
|
|
19656
|
-
input_cache_read: z$
|
|
19657
|
-
input_cache_write: z$
|
|
19649
|
+
const gatewayAvailableModelsResponseSchema = lazySchema(() => zodSchema(z$6.object({ models: z$6.array(z$6.object({
|
|
19650
|
+
id: z$6.string(),
|
|
19651
|
+
name: z$6.string(),
|
|
19652
|
+
description: z$6.string().nullish(),
|
|
19653
|
+
pricing: z$6.object({
|
|
19654
|
+
input: z$6.string(),
|
|
19655
|
+
output: z$6.string(),
|
|
19656
|
+
input_cache_read: z$6.string().nullish(),
|
|
19657
|
+
input_cache_write: z$6.string().nullish()
|
|
19658
19658
|
}).transform(({ input, output, input_cache_read, input_cache_write }) => ({
|
|
19659
19659
|
input,
|
|
19660
19660
|
output,
|
|
19661
19661
|
...input_cache_read ? { cachedInputTokens: input_cache_read } : {},
|
|
19662
19662
|
...input_cache_write ? { cacheCreationInputTokens: input_cache_write } : {}
|
|
19663
19663
|
})).nullish(),
|
|
19664
|
-
specification: z$
|
|
19665
|
-
specificationVersion: z$
|
|
19666
|
-
provider: z$
|
|
19667
|
-
modelId: z$
|
|
19664
|
+
specification: z$6.object({
|
|
19665
|
+
specificationVersion: z$6.literal("v4"),
|
|
19666
|
+
provider: z$6.string(),
|
|
19667
|
+
modelId: z$6.string()
|
|
19668
19668
|
}),
|
|
19669
|
-
modelType: z$
|
|
19669
|
+
modelType: z$6.string().nullish()
|
|
19670
19670
|
})).transform((models) => models.filter((m) => m.modelType == null || KNOWN_MODEL_TYPES.includes(m.modelType))) })));
|
|
19671
|
-
const gatewayCreditsResponseSchema = lazySchema(() => zodSchema(z$
|
|
19672
|
-
balance: z$
|
|
19673
|
-
total_used: z$
|
|
19671
|
+
const gatewayCreditsResponseSchema = lazySchema(() => zodSchema(z$6.object({
|
|
19672
|
+
balance: z$6.string(),
|
|
19673
|
+
total_used: z$6.string()
|
|
19674
19674
|
}).transform(({ balance, total_used }) => ({
|
|
19675
19675
|
balance,
|
|
19676
19676
|
totalUsed: total_used
|
|
@@ -19698,7 +19698,7 @@ var GatewaySpendReport = class {
|
|
|
19698
19698
|
headers: this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
19699
19699
|
successfulResponseHandler: createJsonResponseHandler(gatewaySpendReportResponseSchema),
|
|
19700
19700
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
19701
|
-
errorSchema: z$
|
|
19701
|
+
errorSchema: z$6.any(),
|
|
19702
19702
|
errorToMessage: (data) => getErrorMessage(data) ?? "unknown error"
|
|
19703
19703
|
}),
|
|
19704
19704
|
fetch: this.config.fetch
|
|
@@ -19709,22 +19709,22 @@ var GatewaySpendReport = class {
|
|
|
19709
19709
|
}
|
|
19710
19710
|
}
|
|
19711
19711
|
};
|
|
19712
|
-
const gatewaySpendReportResponseSchema = lazySchema(() => zodSchema(z$
|
|
19713
|
-
day: z$
|
|
19714
|
-
hour: z$
|
|
19715
|
-
user: z$
|
|
19716
|
-
model: z$
|
|
19717
|
-
tag: z$
|
|
19718
|
-
provider: z$
|
|
19719
|
-
credential_type: z$
|
|
19720
|
-
total_cost: z$
|
|
19721
|
-
market_cost: z$
|
|
19722
|
-
input_tokens: z$
|
|
19723
|
-
output_tokens: z$
|
|
19724
|
-
cached_input_tokens: z$
|
|
19725
|
-
cache_creation_input_tokens: z$
|
|
19726
|
-
reasoning_tokens: z$
|
|
19727
|
-
request_count: z$
|
|
19712
|
+
const gatewaySpendReportResponseSchema = lazySchema(() => zodSchema(z$6.object({ results: z$6.array(z$6.object({
|
|
19713
|
+
day: z$6.string().optional(),
|
|
19714
|
+
hour: z$6.string().optional(),
|
|
19715
|
+
user: z$6.string().optional(),
|
|
19716
|
+
model: z$6.string().optional(),
|
|
19717
|
+
tag: z$6.string().optional(),
|
|
19718
|
+
provider: z$6.string().optional(),
|
|
19719
|
+
credential_type: z$6.enum(["byok", "system"]).optional(),
|
|
19720
|
+
total_cost: z$6.number(),
|
|
19721
|
+
market_cost: z$6.number().optional(),
|
|
19722
|
+
input_tokens: z$6.number().optional(),
|
|
19723
|
+
output_tokens: z$6.number().optional(),
|
|
19724
|
+
cached_input_tokens: z$6.number().optional(),
|
|
19725
|
+
cache_creation_input_tokens: z$6.number().optional(),
|
|
19726
|
+
reasoning_tokens: z$6.number().optional(),
|
|
19727
|
+
request_count: z$6.number().optional()
|
|
19728
19728
|
}).transform(({ credential_type, total_cost, market_cost, input_tokens, output_tokens, cached_input_tokens, cache_creation_input_tokens, reasoning_tokens, request_count, ...rest }) => ({
|
|
19729
19729
|
...rest,
|
|
19730
19730
|
...credential_type !== void 0 ? { credentialType: credential_type } : {},
|
|
@@ -19750,7 +19750,7 @@ var GatewayGenerationInfoFetcher = class {
|
|
|
19750
19750
|
headers: this.config.headers ? await resolve(this.config.headers) : void 0,
|
|
19751
19751
|
successfulResponseHandler: createJsonResponseHandler(gatewayGenerationInfoResponseSchema),
|
|
19752
19752
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
19753
|
-
errorSchema: z$
|
|
19753
|
+
errorSchema: z$6.any(),
|
|
19754
19754
|
errorToMessage: (data) => getErrorMessage(data) ?? "unknown error"
|
|
19755
19755
|
}),
|
|
19756
19756
|
fetch: this.config.fetch
|
|
@@ -19761,25 +19761,25 @@ var GatewayGenerationInfoFetcher = class {
|
|
|
19761
19761
|
}
|
|
19762
19762
|
}
|
|
19763
19763
|
};
|
|
19764
|
-
const gatewayGenerationInfoResponseSchema = lazySchema(() => zodSchema(z$
|
|
19765
|
-
id: z$
|
|
19766
|
-
total_cost: z$
|
|
19767
|
-
upstream_inference_cost: z$
|
|
19768
|
-
usage: z$
|
|
19769
|
-
created_at: z$
|
|
19770
|
-
model: z$
|
|
19771
|
-
is_byok: z$
|
|
19772
|
-
provider_name: z$
|
|
19773
|
-
streamed: z$
|
|
19774
|
-
finish_reason: z$
|
|
19775
|
-
latency: z$
|
|
19776
|
-
generation_time: z$
|
|
19777
|
-
native_tokens_prompt: z$
|
|
19778
|
-
native_tokens_completion: z$
|
|
19779
|
-
native_tokens_reasoning: z$
|
|
19780
|
-
native_tokens_cached: z$
|
|
19781
|
-
native_tokens_cache_creation: z$
|
|
19782
|
-
billable_web_search_calls: z$
|
|
19764
|
+
const gatewayGenerationInfoResponseSchema = lazySchema(() => zodSchema(z$6.object({ data: z$6.object({
|
|
19765
|
+
id: z$6.string(),
|
|
19766
|
+
total_cost: z$6.number(),
|
|
19767
|
+
upstream_inference_cost: z$6.number(),
|
|
19768
|
+
usage: z$6.number(),
|
|
19769
|
+
created_at: z$6.string(),
|
|
19770
|
+
model: z$6.string(),
|
|
19771
|
+
is_byok: z$6.boolean(),
|
|
19772
|
+
provider_name: z$6.string(),
|
|
19773
|
+
streamed: z$6.boolean(),
|
|
19774
|
+
finish_reason: z$6.string(),
|
|
19775
|
+
latency: z$6.number(),
|
|
19776
|
+
generation_time: z$6.number(),
|
|
19777
|
+
native_tokens_prompt: z$6.number(),
|
|
19778
|
+
native_tokens_completion: z$6.number(),
|
|
19779
|
+
native_tokens_reasoning: z$6.number(),
|
|
19780
|
+
native_tokens_cached: z$6.number(),
|
|
19781
|
+
native_tokens_cache_creation: z$6.number(),
|
|
19782
|
+
billable_web_search_calls: z$6.number()
|
|
19783
19783
|
}).transform(({ total_cost, upstream_inference_cost, created_at, is_byok, provider_name, finish_reason, generation_time, native_tokens_prompt, native_tokens_completion, native_tokens_reasoning, native_tokens_cached, native_tokens_cache_creation, billable_web_search_calls, ...rest }) => ({
|
|
19784
19784
|
...rest,
|
|
19785
19785
|
totalCost: total_cost,
|
|
@@ -19832,7 +19832,7 @@ var GatewayBatch = class {
|
|
|
19832
19832
|
},
|
|
19833
19833
|
successfulResponseHandler: createJsonResponseHandler(gatewayBatchStartResponseSchema),
|
|
19834
19834
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
19835
|
-
errorSchema: z$
|
|
19835
|
+
errorSchema: z$6.any(),
|
|
19836
19836
|
errorToMessage: (data) => getErrorMessage(data) ?? "unknown error"
|
|
19837
19837
|
}),
|
|
19838
19838
|
...abortSignal && { abortSignal },
|
|
@@ -19861,7 +19861,7 @@ var GatewayBatch = class {
|
|
|
19861
19861
|
body: { batchId },
|
|
19862
19862
|
successfulResponseHandler: createJsonResponseHandler(gatewayBatchStatusResponseSchema),
|
|
19863
19863
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
19864
|
-
errorSchema: z$
|
|
19864
|
+
errorSchema: z$6.any(),
|
|
19865
19865
|
errorToMessage: (data) => getErrorMessage(data) ?? "unknown error"
|
|
19866
19866
|
}),
|
|
19867
19867
|
...abortSignal && { abortSignal },
|
|
@@ -19889,7 +19889,7 @@ var GatewayBatch = class {
|
|
|
19889
19889
|
body: { batchId },
|
|
19890
19890
|
successfulResponseHandler: createJsonLinesResponseHandler(gatewayBatchItemResultLineSchema, { maxLineBytes: this.config.maxLineBytes }),
|
|
19891
19891
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
19892
|
-
errorSchema: z$
|
|
19892
|
+
errorSchema: z$6.any(),
|
|
19893
19893
|
errorToMessage: (data) => getErrorMessage(data) ?? "unknown error"
|
|
19894
19894
|
}),
|
|
19895
19895
|
...abortSignal && { abortSignal },
|
|
@@ -19911,7 +19911,7 @@ var GatewayBatch = class {
|
|
|
19911
19911
|
body: { batchId },
|
|
19912
19912
|
successfulResponseHandler: createJsonResponseHandler(gatewayBatchStatusResponseSchema),
|
|
19913
19913
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
19914
|
-
errorSchema: z$
|
|
19914
|
+
errorSchema: z$6.any(),
|
|
19915
19915
|
errorToMessage: (data) => getErrorMessage(data) ?? "unknown error"
|
|
19916
19916
|
}),
|
|
19917
19917
|
...abortSignal && { abortSignal },
|
|
@@ -20046,48 +20046,48 @@ async function* convertGatewayBatchResultLines(lines) {
|
|
|
20046
20046
|
yield item;
|
|
20047
20047
|
}
|
|
20048
20048
|
}
|
|
20049
|
-
const gatewayBatchItemResultLineSchema = lazySchema(() => zodSchema(z$
|
|
20050
|
-
type: z$
|
|
20051
|
-
id: z$
|
|
20052
|
-
status: z$
|
|
20049
|
+
const gatewayBatchItemResultLineSchema = lazySchema(() => zodSchema(z$6.object({
|
|
20050
|
+
type: z$6.literal("text"),
|
|
20051
|
+
id: z$6.string(),
|
|
20052
|
+
status: z$6.enum([
|
|
20053
20053
|
"cancelled",
|
|
20054
20054
|
"expired",
|
|
20055
20055
|
"failed",
|
|
20056
20056
|
"succeeded"
|
|
20057
20057
|
])
|
|
20058
|
-
}).catchall(z$
|
|
20059
|
-
const gatewayBatchErrorSchema = () => z$
|
|
20060
|
-
message: z$
|
|
20061
|
-
type: z$
|
|
20062
|
-
code: z$
|
|
20063
|
-
statusCode: z$
|
|
20058
|
+
}).catchall(z$6.unknown())));
|
|
20059
|
+
const gatewayBatchErrorSchema = () => z$6.object({
|
|
20060
|
+
message: z$6.string(),
|
|
20061
|
+
type: z$6.string().nullish(),
|
|
20062
|
+
code: z$6.string().nullish(),
|
|
20063
|
+
statusCode: z$6.number().nullish()
|
|
20064
20064
|
});
|
|
20065
|
-
const gatewayBatchRequestCountsSchema = () => z$
|
|
20066
|
-
total: z$
|
|
20067
|
-
pending: z$
|
|
20068
|
-
completed: z$
|
|
20069
|
-
failed: z$
|
|
20065
|
+
const gatewayBatchRequestCountsSchema = () => z$6.object({
|
|
20066
|
+
total: z$6.number().nullish(),
|
|
20067
|
+
pending: z$6.number().nullish(),
|
|
20068
|
+
completed: z$6.number().nullish(),
|
|
20069
|
+
failed: z$6.number().nullish()
|
|
20070
20070
|
});
|
|
20071
|
-
const gatewayBatchProviderMetadataSchema = () => z$
|
|
20072
|
-
const gatewayBatchStatusFieldsSchema = () => z$
|
|
20073
|
-
status: z$
|
|
20071
|
+
const gatewayBatchProviderMetadataSchema = () => z$6.record(z$6.string(), z$6.record(z$6.string(), z$6.unknown()));
|
|
20072
|
+
const gatewayBatchStatusFieldsSchema = () => z$6.object({
|
|
20073
|
+
status: z$6.enum([
|
|
20074
20074
|
"completed",
|
|
20075
20075
|
"failed",
|
|
20076
20076
|
"pending"
|
|
20077
20077
|
]),
|
|
20078
|
-
rawStatus: z$
|
|
20078
|
+
rawStatus: z$6.string().nullish(),
|
|
20079
20079
|
requestCounts: gatewayBatchRequestCountsSchema().nullish(),
|
|
20080
20080
|
error: gatewayBatchErrorSchema().nullish(),
|
|
20081
|
-
createdAt: z$
|
|
20082
|
-
expiresAt: z$
|
|
20081
|
+
createdAt: z$6.string().nullish(),
|
|
20082
|
+
expiresAt: z$6.string().nullish(),
|
|
20083
20083
|
providerMetadata: gatewayBatchProviderMetadataSchema().nullish()
|
|
20084
20084
|
});
|
|
20085
20085
|
const gatewayBatchStartResponseSchema = lazySchema(() => zodSchema(gatewayBatchStatusFieldsSchema().extend({
|
|
20086
|
-
batchId: z$
|
|
20087
|
-
warnings: z$
|
|
20088
|
-
requestId: z$
|
|
20089
|
-
warning: z$
|
|
20090
|
-
}).catchall(z$
|
|
20086
|
+
batchId: z$6.string(),
|
|
20087
|
+
warnings: z$6.array(z$6.object({
|
|
20088
|
+
requestId: z$6.string().nullish(),
|
|
20089
|
+
warning: z$6.unknown()
|
|
20090
|
+
}).catchall(z$6.unknown())).nullish()
|
|
20091
20091
|
})));
|
|
20092
20092
|
const gatewayBatchStatusResponseSchema = lazySchema(() => zodSchema(gatewayBatchStatusFieldsSchema()));
|
|
20093
20093
|
var GatewayLanguageModel = class GatewayLanguageModel {
|
|
@@ -20125,9 +20125,9 @@ var GatewayLanguageModel = class GatewayLanguageModel {
|
|
|
20125
20125
|
url: this.getUrl(),
|
|
20126
20126
|
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, false), await resolve(this.config.o11yHeaders)),
|
|
20127
20127
|
body: args,
|
|
20128
|
-
successfulResponseHandler: createJsonResponseHandler(z$
|
|
20128
|
+
successfulResponseHandler: createJsonResponseHandler(z$6.any()),
|
|
20129
20129
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
20130
|
-
errorSchema: z$
|
|
20130
|
+
errorSchema: z$6.any(),
|
|
20131
20131
|
errorToMessage: (data) => getErrorMessage(data) ?? "unknown error"
|
|
20132
20132
|
}),
|
|
20133
20133
|
...abortSignal && { abortSignal },
|
|
@@ -20155,9 +20155,9 @@ var GatewayLanguageModel = class GatewayLanguageModel {
|
|
|
20155
20155
|
url: this.getUrl(),
|
|
20156
20156
|
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, true), await resolve(this.config.o11yHeaders)),
|
|
20157
20157
|
body: args,
|
|
20158
|
-
successfulResponseHandler: createEventSourceResponseHandler(z$
|
|
20158
|
+
successfulResponseHandler: createEventSourceResponseHandler(z$6.any()),
|
|
20159
20159
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
20160
|
-
errorSchema: z$
|
|
20160
|
+
errorSchema: z$6.any(),
|
|
20161
20161
|
errorToMessage: (data) => getErrorMessage(data) ?? "unknown error"
|
|
20162
20162
|
}),
|
|
20163
20163
|
...abortSignal && { abortSignal },
|
|
@@ -20256,7 +20256,7 @@ var GatewayEmbeddingModel = class GatewayEmbeddingModel {
|
|
|
20256
20256
|
},
|
|
20257
20257
|
successfulResponseHandler: createJsonResponseHandler(gatewayEmbeddingResponseSchema),
|
|
20258
20258
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
20259
|
-
errorSchema: z$
|
|
20259
|
+
errorSchema: z$6.any(),
|
|
20260
20260
|
errorToMessage: (data) => getErrorMessage(data) ?? "unknown error"
|
|
20261
20261
|
}),
|
|
20262
20262
|
...abortSignal && { abortSignal },
|
|
@@ -20286,32 +20286,32 @@ var GatewayEmbeddingModel = class GatewayEmbeddingModel {
|
|
|
20286
20286
|
};
|
|
20287
20287
|
}
|
|
20288
20288
|
};
|
|
20289
|
-
const gatewayEmbeddingWarningSchema = () => z$
|
|
20290
|
-
z$
|
|
20291
|
-
type: z$
|
|
20292
|
-
feature: z$
|
|
20293
|
-
details: z$
|
|
20289
|
+
const gatewayEmbeddingWarningSchema = () => z$6.discriminatedUnion("type", [
|
|
20290
|
+
z$6.object({
|
|
20291
|
+
type: z$6.literal("unsupported"),
|
|
20292
|
+
feature: z$6.string(),
|
|
20293
|
+
details: z$6.string().optional()
|
|
20294
20294
|
}),
|
|
20295
|
-
z$
|
|
20296
|
-
type: z$
|
|
20297
|
-
feature: z$
|
|
20298
|
-
details: z$
|
|
20295
|
+
z$6.object({
|
|
20296
|
+
type: z$6.literal("compatibility"),
|
|
20297
|
+
feature: z$6.string(),
|
|
20298
|
+
details: z$6.string().optional()
|
|
20299
20299
|
}),
|
|
20300
|
-
z$
|
|
20301
|
-
type: z$
|
|
20302
|
-
setting: z$
|
|
20303
|
-
message: z$
|
|
20300
|
+
z$6.object({
|
|
20301
|
+
type: z$6.literal("deprecated"),
|
|
20302
|
+
setting: z$6.string(),
|
|
20303
|
+
message: z$6.string()
|
|
20304
20304
|
}),
|
|
20305
|
-
z$
|
|
20306
|
-
type: z$
|
|
20307
|
-
message: z$
|
|
20305
|
+
z$6.object({
|
|
20306
|
+
type: z$6.literal("other"),
|
|
20307
|
+
message: z$6.string()
|
|
20308
20308
|
})
|
|
20309
20309
|
]);
|
|
20310
|
-
const gatewayEmbeddingResponseSchema = lazySchema(() => zodSchema(z$
|
|
20311
|
-
embeddings: z$
|
|
20312
|
-
usage: z$
|
|
20313
|
-
warnings: z$
|
|
20314
|
-
providerMetadata: z$
|
|
20310
|
+
const gatewayEmbeddingResponseSchema = lazySchema(() => zodSchema(z$6.object({
|
|
20311
|
+
embeddings: z$6.array(z$6.array(z$6.number())),
|
|
20312
|
+
usage: z$6.object({ tokens: z$6.number() }).nullish(),
|
|
20313
|
+
warnings: z$6.array(gatewayEmbeddingWarningSchema()).optional(),
|
|
20314
|
+
providerMetadata: z$6.record(z$6.string(), z$6.record(z$6.string(), z$6.unknown())).optional()
|
|
20315
20315
|
})));
|
|
20316
20316
|
var GatewayImageModel = class GatewayImageModel {
|
|
20317
20317
|
static [WORKFLOW_SERIALIZE](model) {
|
|
@@ -20350,7 +20350,7 @@ var GatewayImageModel = class GatewayImageModel {
|
|
|
20350
20350
|
},
|
|
20351
20351
|
successfulResponseHandler: createJsonResponseHandler(gatewayImageResponseSchema),
|
|
20352
20352
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
20353
|
-
errorSchema: z$
|
|
20353
|
+
errorSchema: z$6.any(),
|
|
20354
20354
|
errorToMessage: (data) => getErrorMessage(data) ?? "unknown error"
|
|
20355
20355
|
}),
|
|
20356
20356
|
...abortSignal && { abortSignal },
|
|
@@ -20393,38 +20393,38 @@ function maybeEncodeImageFile(file) {
|
|
|
20393
20393
|
};
|
|
20394
20394
|
return file;
|
|
20395
20395
|
}
|
|
20396
|
-
const providerMetadataEntrySchema$3 = () => z$
|
|
20397
|
-
const gatewayImageWarningSchema = () => z$
|
|
20398
|
-
z$
|
|
20399
|
-
type: z$
|
|
20400
|
-
feature: z$
|
|
20401
|
-
details: z$
|
|
20396
|
+
const providerMetadataEntrySchema$3 = () => z$6.object({ images: z$6.array(z$6.unknown()).optional() }).catchall(z$6.unknown());
|
|
20397
|
+
const gatewayImageWarningSchema = () => z$6.discriminatedUnion("type", [
|
|
20398
|
+
z$6.object({
|
|
20399
|
+
type: z$6.literal("unsupported"),
|
|
20400
|
+
feature: z$6.string(),
|
|
20401
|
+
details: z$6.string().optional()
|
|
20402
20402
|
}),
|
|
20403
|
-
z$
|
|
20404
|
-
type: z$
|
|
20405
|
-
feature: z$
|
|
20406
|
-
details: z$
|
|
20403
|
+
z$6.object({
|
|
20404
|
+
type: z$6.literal("compatibility"),
|
|
20405
|
+
feature: z$6.string(),
|
|
20406
|
+
details: z$6.string().optional()
|
|
20407
20407
|
}),
|
|
20408
|
-
z$
|
|
20409
|
-
type: z$
|
|
20410
|
-
setting: z$
|
|
20411
|
-
message: z$
|
|
20408
|
+
z$6.object({
|
|
20409
|
+
type: z$6.literal("deprecated"),
|
|
20410
|
+
setting: z$6.string(),
|
|
20411
|
+
message: z$6.string()
|
|
20412
20412
|
}),
|
|
20413
|
-
z$
|
|
20414
|
-
type: z$
|
|
20415
|
-
message: z$
|
|
20413
|
+
z$6.object({
|
|
20414
|
+
type: z$6.literal("other"),
|
|
20415
|
+
message: z$6.string()
|
|
20416
20416
|
})
|
|
20417
20417
|
]);
|
|
20418
|
-
const gatewayImageUsageSchema = () => z$
|
|
20419
|
-
inputTokens: z$
|
|
20420
|
-
outputTokens: z$
|
|
20421
|
-
totalTokens: z$
|
|
20418
|
+
const gatewayImageUsageSchema = () => z$6.object({
|
|
20419
|
+
inputTokens: z$6.number().nullish(),
|
|
20420
|
+
outputTokens: z$6.number().nullish(),
|
|
20421
|
+
totalTokens: z$6.number().nullish()
|
|
20422
20422
|
});
|
|
20423
|
-
const gatewayImageResponseSchema = lazySchema(() => zodSchema(z$
|
|
20424
|
-
images: z$
|
|
20425
|
-
isRetryable: z$
|
|
20426
|
-
warnings: z$
|
|
20427
|
-
providerMetadata: z$
|
|
20423
|
+
const gatewayImageResponseSchema = lazySchema(() => zodSchema(z$6.object({
|
|
20424
|
+
images: z$6.array(z$6.string()),
|
|
20425
|
+
isRetryable: z$6.boolean().optional(),
|
|
20426
|
+
warnings: z$6.array(gatewayImageWarningSchema()).optional(),
|
|
20427
|
+
providerMetadata: z$6.record(z$6.string(), providerMetadataEntrySchema$3()).optional(),
|
|
20428
20428
|
usage: gatewayImageUsageSchema().optional()
|
|
20429
20429
|
})));
|
|
20430
20430
|
var GatewayVideoModel = class {
|
|
@@ -20495,7 +20495,7 @@ var GatewayVideoModel = class {
|
|
|
20495
20495
|
};
|
|
20496
20496
|
},
|
|
20497
20497
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
20498
|
-
errorSchema: z$
|
|
20498
|
+
errorSchema: z$6.any(),
|
|
20499
20499
|
errorToMessage: (data) => getErrorMessage(data) ?? "unknown error"
|
|
20500
20500
|
}),
|
|
20501
20501
|
...abortSignal && { abortSignal },
|
|
@@ -20535,7 +20535,7 @@ var GatewayVideoModel = class {
|
|
|
20535
20535
|
},
|
|
20536
20536
|
successfulResponseHandler: createJsonResponseHandler(gatewayVideoStartResponseSchema),
|
|
20537
20537
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
20538
|
-
errorSchema: z$
|
|
20538
|
+
errorSchema: z$6.any(),
|
|
20539
20539
|
errorToMessage: (data) => getErrorMessage(data) ?? "unknown error"
|
|
20540
20540
|
}),
|
|
20541
20541
|
...abortSignal && { abortSignal },
|
|
@@ -20564,7 +20564,7 @@ var GatewayVideoModel = class {
|
|
|
20564
20564
|
body: { operation },
|
|
20565
20565
|
successfulResponseHandler: createJsonResponseHandler(gatewayVideoStatusResponseSchema),
|
|
20566
20566
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
20567
|
-
errorSchema: z$
|
|
20567
|
+
errorSchema: z$6.any(),
|
|
20568
20568
|
errorToMessage: (data) => getErrorMessage(data) ?? "unknown error"
|
|
20569
20569
|
}),
|
|
20570
20570
|
...abortSignal && { abortSignal },
|
|
@@ -20646,101 +20646,101 @@ function maybeEncodeVideoFile(file) {
|
|
|
20646
20646
|
};
|
|
20647
20647
|
return file;
|
|
20648
20648
|
}
|
|
20649
|
-
const providerMetadataEntrySchema$2 = () => z$
|
|
20650
|
-
const gatewayVideoDataSchema = () => z$
|
|
20651
|
-
type: z$
|
|
20652
|
-
url: z$
|
|
20653
|
-
mediaType: z$
|
|
20654
|
-
}), z$
|
|
20655
|
-
type: z$
|
|
20656
|
-
data: z$
|
|
20657
|
-
mediaType: z$
|
|
20649
|
+
const providerMetadataEntrySchema$2 = () => z$6.object({ videos: z$6.array(z$6.unknown()).optional() }).catchall(z$6.unknown());
|
|
20650
|
+
const gatewayVideoDataSchema = () => z$6.union([z$6.object({
|
|
20651
|
+
type: z$6.literal("url"),
|
|
20652
|
+
url: z$6.string(),
|
|
20653
|
+
mediaType: z$6.string()
|
|
20654
|
+
}), z$6.object({
|
|
20655
|
+
type: z$6.literal("base64"),
|
|
20656
|
+
data: z$6.string(),
|
|
20657
|
+
mediaType: z$6.string()
|
|
20658
20658
|
})]);
|
|
20659
|
-
const gatewayVideoWarningSchema = () => z$
|
|
20660
|
-
z$
|
|
20661
|
-
type: z$
|
|
20662
|
-
feature: z$
|
|
20663
|
-
details: z$
|
|
20659
|
+
const gatewayVideoWarningSchema = () => z$6.discriminatedUnion("type", [
|
|
20660
|
+
z$6.object({
|
|
20661
|
+
type: z$6.literal("unsupported"),
|
|
20662
|
+
feature: z$6.string(),
|
|
20663
|
+
details: z$6.string().optional()
|
|
20664
20664
|
}),
|
|
20665
|
-
z$
|
|
20666
|
-
type: z$
|
|
20667
|
-
feature: z$
|
|
20668
|
-
details: z$
|
|
20665
|
+
z$6.object({
|
|
20666
|
+
type: z$6.literal("compatibility"),
|
|
20667
|
+
feature: z$6.string(),
|
|
20668
|
+
details: z$6.string().optional()
|
|
20669
20669
|
}),
|
|
20670
|
-
z$
|
|
20671
|
-
type: z$
|
|
20672
|
-
setting: z$
|
|
20673
|
-
message: z$
|
|
20670
|
+
z$6.object({
|
|
20671
|
+
type: z$6.literal("deprecated"),
|
|
20672
|
+
setting: z$6.string(),
|
|
20673
|
+
message: z$6.string()
|
|
20674
20674
|
}),
|
|
20675
|
-
z$
|
|
20676
|
-
type: z$
|
|
20677
|
-
message: z$
|
|
20675
|
+
z$6.object({
|
|
20676
|
+
type: z$6.literal("other"),
|
|
20677
|
+
message: z$6.string()
|
|
20678
20678
|
})
|
|
20679
20679
|
]);
|
|
20680
|
-
const gatewayVideoEventSchema = lazySchema(() => zodSchema(z$
|
|
20681
|
-
type: z$
|
|
20682
|
-
videos: z$
|
|
20683
|
-
warnings: z$
|
|
20684
|
-
providerMetadata: z$
|
|
20685
|
-
}), z$
|
|
20686
|
-
type: z$
|
|
20687
|
-
message: z$
|
|
20688
|
-
errorType: z$
|
|
20689
|
-
statusCode: z$
|
|
20690
|
-
param: z$
|
|
20680
|
+
const gatewayVideoEventSchema = lazySchema(() => zodSchema(z$6.discriminatedUnion("type", [z$6.object({
|
|
20681
|
+
type: z$6.literal("result"),
|
|
20682
|
+
videos: z$6.array(gatewayVideoDataSchema()),
|
|
20683
|
+
warnings: z$6.array(gatewayVideoWarningSchema()).optional(),
|
|
20684
|
+
providerMetadata: z$6.record(z$6.string(), providerMetadataEntrySchema$2()).optional()
|
|
20685
|
+
}), z$6.object({
|
|
20686
|
+
type: z$6.literal("error"),
|
|
20687
|
+
message: z$6.string(),
|
|
20688
|
+
errorType: z$6.string(),
|
|
20689
|
+
statusCode: z$6.number(),
|
|
20690
|
+
param: z$6.unknown().nullable()
|
|
20691
20691
|
})])));
|
|
20692
|
-
const gatewayVideoStartResponseSchema = lazySchema(() => zodSchema(z$
|
|
20693
|
-
operation: z$
|
|
20694
|
-
warnings: z$
|
|
20695
|
-
providerMetadata: z$
|
|
20692
|
+
const gatewayVideoStartResponseSchema = lazySchema(() => zodSchema(z$6.object({
|
|
20693
|
+
operation: z$6.unknown(),
|
|
20694
|
+
warnings: z$6.array(gatewayVideoWarningSchema()).nullish(),
|
|
20695
|
+
providerMetadata: z$6.record(z$6.string(), providerMetadataEntrySchema$2()).nullish()
|
|
20696
20696
|
})));
|
|
20697
|
-
const gatewayVideoStatusResponseSchema = lazySchema(() => zodSchema(z$
|
|
20698
|
-
z$
|
|
20699
|
-
status: z$
|
|
20700
|
-
warnings: z$
|
|
20701
|
-
providerMetadata: z$
|
|
20697
|
+
const gatewayVideoStatusResponseSchema = lazySchema(() => zodSchema(z$6.discriminatedUnion("status", [
|
|
20698
|
+
z$6.object({
|
|
20699
|
+
status: z$6.literal("pending"),
|
|
20700
|
+
warnings: z$6.array(gatewayVideoWarningSchema()).nullish(),
|
|
20701
|
+
providerMetadata: z$6.record(z$6.string(), providerMetadataEntrySchema$2()).nullish()
|
|
20702
20702
|
}),
|
|
20703
|
-
z$
|
|
20704
|
-
status: z$
|
|
20705
|
-
videos: z$
|
|
20706
|
-
warnings: z$
|
|
20707
|
-
providerMetadata: z$
|
|
20703
|
+
z$6.object({
|
|
20704
|
+
status: z$6.literal("completed"),
|
|
20705
|
+
videos: z$6.array(gatewayVideoDataSchema()),
|
|
20706
|
+
warnings: z$6.array(gatewayVideoWarningSchema()).nullish(),
|
|
20707
|
+
providerMetadata: z$6.record(z$6.string(), providerMetadataEntrySchema$2()).nullish()
|
|
20708
20708
|
}),
|
|
20709
|
-
z$
|
|
20710
|
-
status: z$
|
|
20711
|
-
error: z$
|
|
20712
|
-
providerMetadata: z$
|
|
20709
|
+
z$6.object({
|
|
20710
|
+
status: z$6.literal("error"),
|
|
20711
|
+
error: z$6.string(),
|
|
20712
|
+
providerMetadata: z$6.record(z$6.string(), providerMetadataEntrySchema$2()).nullish()
|
|
20713
20713
|
}),
|
|
20714
|
-
z$
|
|
20715
|
-
status: z$
|
|
20716
|
-
providerMetadata: z$
|
|
20714
|
+
z$6.object({
|
|
20715
|
+
status: z$6.literal("cancelled"),
|
|
20716
|
+
providerMetadata: z$6.record(z$6.string(), providerMetadataEntrySchema$2()).nullish()
|
|
20717
20717
|
})
|
|
20718
20718
|
])));
|
|
20719
|
-
const gatewayDecisionProviderOptionsSchema = lazySchema(() => zodSchema(z$
|
|
20720
|
-
const probabilitySchema = () => z$
|
|
20721
|
-
const questionSchema = () => z$
|
|
20722
|
-
const directConditionSchema = () => z$
|
|
20719
|
+
const gatewayDecisionProviderOptionsSchema = lazySchema(() => zodSchema(z$6.object({ models: gatewayModelFallbacksSchema().optional() }).catchall(z$6.unknown())));
|
|
20720
|
+
const probabilitySchema = () => z$6.number().finite().min(0).max(1);
|
|
20721
|
+
const questionSchema = () => z$6.string().min(1).max(256);
|
|
20722
|
+
const directConditionSchema = () => z$6.union([z$6.object({
|
|
20723
20723
|
question: questionSchema().optional(),
|
|
20724
20724
|
confidenceBelow: probabilitySchema()
|
|
20725
|
-
}).strict(), z$
|
|
20725
|
+
}).strict(), z$6.object({
|
|
20726
20726
|
question: questionSchema().optional(),
|
|
20727
|
-
probabilityBetween: z$
|
|
20727
|
+
probabilityBetween: z$6.array(probabilitySchema()).length(2).refine(([minimum, maximum]) => minimum <= maximum, { message: "probabilityBetween minimum must be less than or equal to maximum" })
|
|
20728
20728
|
}).strict()]);
|
|
20729
|
-
const groupBeyondMaxDepthSchema = () => z$
|
|
20730
|
-
z$
|
|
20731
|
-
z$
|
|
20732
|
-
z$
|
|
20729
|
+
const groupBeyondMaxDepthSchema = () => z$6.union([
|
|
20730
|
+
z$6.object({ any: z$6.unknown() }),
|
|
20731
|
+
z$6.object({ all: z$6.unknown() }),
|
|
20732
|
+
z$6.object({ atLeast: z$6.unknown() })
|
|
20733
20733
|
]).superRefine((_, context) => {
|
|
20734
20734
|
context.addIssue({
|
|
20735
20735
|
code: "custom",
|
|
20736
20736
|
message: `conditions can be nested at most 5 levels deep`
|
|
20737
20737
|
});
|
|
20738
20738
|
});
|
|
20739
|
-
const conditionalModelFallbackSchema = () => z$
|
|
20740
|
-
model: z$
|
|
20739
|
+
const conditionalModelFallbackSchema = () => z$6.object({
|
|
20740
|
+
model: z$6.string().min(1),
|
|
20741
20741
|
when: conditionSchema(1)
|
|
20742
20742
|
}).strict();
|
|
20743
|
-
const gatewayModelFallbacksSchema = () => z$
|
|
20743
|
+
const gatewayModelFallbacksSchema = () => z$6.array(z$6.union([z$6.string(), conditionalModelFallbackSchema()])).superRefine((entries, context) => {
|
|
20744
20744
|
const conditionalIndexes = entries.flatMap((entry, index) => typeof entry === "string" ? [] : [index]);
|
|
20745
20745
|
if (conditionalIndexes.length > 1) context.addIssue({
|
|
20746
20746
|
code: "custom",
|
|
@@ -20753,15 +20753,15 @@ const gatewayModelFallbacksSchema = () => z$5.array(z$5.union([z$5.string(), con
|
|
|
20753
20753
|
});
|
|
20754
20754
|
});
|
|
20755
20755
|
function conditionSchema(depth) {
|
|
20756
|
-
if (depth === 5) return z$
|
|
20756
|
+
if (depth === 5) return z$6.union([directConditionSchema(), groupBeyondMaxDepthSchema()]);
|
|
20757
20757
|
const childConditionSchema = conditionSchema(depth + 1);
|
|
20758
|
-
const conditionListSchema = z$
|
|
20759
|
-
return z$
|
|
20758
|
+
const conditionListSchema = z$6.array(childConditionSchema).min(1).max(20);
|
|
20759
|
+
return z$6.union([
|
|
20760
20760
|
directConditionSchema(),
|
|
20761
|
-
z$
|
|
20762
|
-
z$
|
|
20763
|
-
z$
|
|
20764
|
-
count: z$
|
|
20761
|
+
z$6.object({ any: conditionListSchema }).strict(),
|
|
20762
|
+
z$6.object({ all: conditionListSchema }).strict(),
|
|
20763
|
+
z$6.object({ atLeast: z$6.object({
|
|
20764
|
+
count: z$6.number().int().min(1),
|
|
20765
20765
|
conditions: conditionListSchema
|
|
20766
20766
|
}).strict().refine(({ count, conditions }) => count <= conditions.length, {
|
|
20767
20767
|
message: "atLeast count cannot exceed the number of conditions",
|
|
@@ -20812,7 +20812,7 @@ var GatewayDecisionModel = class {
|
|
|
20812
20812
|
},
|
|
20813
20813
|
successfulResponseHandler: createJsonResponseHandler(gatewayDecisionResponseSchema),
|
|
20814
20814
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
20815
|
-
errorSchema: z$
|
|
20815
|
+
errorSchema: z$6.any(),
|
|
20816
20816
|
errorToMessage: (data) => getErrorMessage(data) ?? "unknown error"
|
|
20817
20817
|
}),
|
|
20818
20818
|
...abortSignal && { abortSignal },
|
|
@@ -20844,57 +20844,57 @@ var GatewayDecisionModel = class {
|
|
|
20844
20844
|
};
|
|
20845
20845
|
}
|
|
20846
20846
|
};
|
|
20847
|
-
const gatewayDecisionAnswerSchema = () => z$
|
|
20848
|
-
z$
|
|
20849
|
-
type: z$
|
|
20850
|
-
choice: z$
|
|
20851
|
-
probabilities: z$
|
|
20847
|
+
const gatewayDecisionAnswerSchema = () => z$6.discriminatedUnion("type", [
|
|
20848
|
+
z$6.object({
|
|
20849
|
+
type: z$6.literal("choice"),
|
|
20850
|
+
choice: z$6.string(),
|
|
20851
|
+
probabilities: z$6.record(z$6.string(), z$6.number()).optional()
|
|
20852
20852
|
}),
|
|
20853
|
-
z$
|
|
20854
|
-
type: z$
|
|
20855
|
-
score: z$
|
|
20856
|
-
probabilities: z$
|
|
20853
|
+
z$6.object({
|
|
20854
|
+
type: z$6.literal("score"),
|
|
20855
|
+
score: z$6.number(),
|
|
20856
|
+
probabilities: z$6.record(z$6.string(), z$6.number()).optional()
|
|
20857
20857
|
}),
|
|
20858
|
-
z$
|
|
20859
|
-
type: z$
|
|
20860
|
-
probability: z$
|
|
20858
|
+
z$6.object({
|
|
20859
|
+
type: z$6.literal("boolean"),
|
|
20860
|
+
probability: z$6.number()
|
|
20861
20861
|
}),
|
|
20862
|
-
z$
|
|
20862
|
+
z$6.object({ type: z$6.literal("refusal") })
|
|
20863
20863
|
]);
|
|
20864
|
-
const gatewayDecisionWarningSchema = () => z$
|
|
20865
|
-
z$
|
|
20866
|
-
type: z$
|
|
20867
|
-
feature: z$
|
|
20868
|
-
details: z$
|
|
20864
|
+
const gatewayDecisionWarningSchema = () => z$6.discriminatedUnion("type", [
|
|
20865
|
+
z$6.object({
|
|
20866
|
+
type: z$6.literal("unsupported"),
|
|
20867
|
+
feature: z$6.string(),
|
|
20868
|
+
details: z$6.string().optional()
|
|
20869
20869
|
}),
|
|
20870
|
-
z$
|
|
20871
|
-
type: z$
|
|
20872
|
-
feature: z$
|
|
20873
|
-
details: z$
|
|
20870
|
+
z$6.object({
|
|
20871
|
+
type: z$6.literal("compatibility"),
|
|
20872
|
+
feature: z$6.string(),
|
|
20873
|
+
details: z$6.string().optional()
|
|
20874
20874
|
}),
|
|
20875
|
-
z$
|
|
20876
|
-
type: z$
|
|
20877
|
-
setting: z$
|
|
20878
|
-
message: z$
|
|
20875
|
+
z$6.object({
|
|
20876
|
+
type: z$6.literal("deprecated"),
|
|
20877
|
+
setting: z$6.string(),
|
|
20878
|
+
message: z$6.string()
|
|
20879
20879
|
}),
|
|
20880
|
-
z$
|
|
20881
|
-
type: z$
|
|
20882
|
-
message: z$
|
|
20880
|
+
z$6.object({
|
|
20881
|
+
type: z$6.literal("other"),
|
|
20882
|
+
message: z$6.string()
|
|
20883
20883
|
})
|
|
20884
20884
|
]);
|
|
20885
|
-
const gatewayDecisionResponseSchema = lazySchema(() => zodSchema(z$
|
|
20886
|
-
answers: z$
|
|
20887
|
-
model: z$
|
|
20888
|
-
rounding: z$
|
|
20889
|
-
probabilityDecimals: z$
|
|
20890
|
-
scoreDecimals: z$
|
|
20885
|
+
const gatewayDecisionResponseSchema = lazySchema(() => zodSchema(z$6.object({
|
|
20886
|
+
answers: z$6.record(z$6.string(), gatewayDecisionAnswerSchema()),
|
|
20887
|
+
model: z$6.string().optional(),
|
|
20888
|
+
rounding: z$6.object({
|
|
20889
|
+
probabilityDecimals: z$6.number().optional(),
|
|
20890
|
+
scoreDecimals: z$6.number().optional()
|
|
20891
20891
|
}).optional(),
|
|
20892
|
-
usage: z$
|
|
20893
|
-
inputTokens: z$
|
|
20894
|
-
outputTokens: z$
|
|
20892
|
+
usage: z$6.object({
|
|
20893
|
+
inputTokens: z$6.number().optional(),
|
|
20894
|
+
outputTokens: z$6.number().optional()
|
|
20895
20895
|
}).optional(),
|
|
20896
|
-
warnings: z$
|
|
20897
|
-
providerMetadata: z$
|
|
20896
|
+
warnings: z$6.array(gatewayDecisionWarningSchema()).optional(),
|
|
20897
|
+
providerMetadata: z$6.record(z$6.string(), z$6.record(z$6.string(), z$6.unknown())).optional()
|
|
20898
20898
|
})));
|
|
20899
20899
|
function toGatewayDecisionState(state) {
|
|
20900
20900
|
return state.map((part) => {
|
|
@@ -20933,7 +20933,7 @@ var GatewayRerankingModel = class {
|
|
|
20933
20933
|
},
|
|
20934
20934
|
successfulResponseHandler: createJsonResponseHandler(gatewayRerankingResponseSchema),
|
|
20935
20935
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
20936
|
-
errorSchema: z$
|
|
20936
|
+
errorSchema: z$6.any(),
|
|
20937
20937
|
errorToMessage: (data) => getErrorMessage(data) ?? "unknown error"
|
|
20938
20938
|
}),
|
|
20939
20939
|
...abortSignal && { abortSignal },
|
|
@@ -20962,34 +20962,34 @@ var GatewayRerankingModel = class {
|
|
|
20962
20962
|
};
|
|
20963
20963
|
}
|
|
20964
20964
|
};
|
|
20965
|
-
const gatewayRerankingWarningSchema = () => z$
|
|
20966
|
-
z$
|
|
20967
|
-
type: z$
|
|
20968
|
-
feature: z$
|
|
20969
|
-
details: z$
|
|
20965
|
+
const gatewayRerankingWarningSchema = () => z$6.discriminatedUnion("type", [
|
|
20966
|
+
z$6.object({
|
|
20967
|
+
type: z$6.literal("unsupported"),
|
|
20968
|
+
feature: z$6.string(),
|
|
20969
|
+
details: z$6.string().optional()
|
|
20970
20970
|
}),
|
|
20971
|
-
z$
|
|
20972
|
-
type: z$
|
|
20973
|
-
feature: z$
|
|
20974
|
-
details: z$
|
|
20971
|
+
z$6.object({
|
|
20972
|
+
type: z$6.literal("compatibility"),
|
|
20973
|
+
feature: z$6.string(),
|
|
20974
|
+
details: z$6.string().optional()
|
|
20975
20975
|
}),
|
|
20976
|
-
z$
|
|
20977
|
-
type: z$
|
|
20978
|
-
setting: z$
|
|
20979
|
-
message: z$
|
|
20976
|
+
z$6.object({
|
|
20977
|
+
type: z$6.literal("deprecated"),
|
|
20978
|
+
setting: z$6.string(),
|
|
20979
|
+
message: z$6.string()
|
|
20980
20980
|
}),
|
|
20981
|
-
z$
|
|
20982
|
-
type: z$
|
|
20983
|
-
message: z$
|
|
20981
|
+
z$6.object({
|
|
20982
|
+
type: z$6.literal("other"),
|
|
20983
|
+
message: z$6.string()
|
|
20984
20984
|
})
|
|
20985
20985
|
]);
|
|
20986
|
-
const gatewayRerankingResponseSchema = lazySchema(() => zodSchema(z$
|
|
20987
|
-
ranking: z$
|
|
20988
|
-
index: z$
|
|
20989
|
-
relevanceScore: z$
|
|
20986
|
+
const gatewayRerankingResponseSchema = lazySchema(() => zodSchema(z$6.object({
|
|
20987
|
+
ranking: z$6.array(z$6.object({
|
|
20988
|
+
index: z$6.number(),
|
|
20989
|
+
relevanceScore: z$6.number()
|
|
20990
20990
|
})),
|
|
20991
|
-
warnings: z$
|
|
20992
|
-
providerMetadata: z$
|
|
20991
|
+
warnings: z$6.array(gatewayRerankingWarningSchema()).optional(),
|
|
20992
|
+
providerMetadata: z$6.record(z$6.string(), z$6.record(z$6.string(), z$6.unknown())).optional()
|
|
20993
20993
|
})));
|
|
20994
20994
|
/**
|
|
20995
20995
|
* `asGatewayError` is async while the WebSocket event handlers are
|
|
@@ -21053,7 +21053,7 @@ var GatewayTranscriptionModel = class {
|
|
|
21053
21053
|
},
|
|
21054
21054
|
successfulResponseHandler: createJsonResponseHandler(gatewayTranscriptionResponseSchema),
|
|
21055
21055
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
21056
|
-
errorSchema: z$
|
|
21056
|
+
errorSchema: z$6.any(),
|
|
21057
21057
|
errorToMessage: (data) => getErrorMessage(data) ?? "unknown error"
|
|
21058
21058
|
}),
|
|
21059
21059
|
...abortSignal && { abortSignal },
|
|
@@ -21261,40 +21261,40 @@ function createGatewayTranscriptionStream({ webSocket, url, protocols, headers,
|
|
|
21261
21261
|
}
|
|
21262
21262
|
});
|
|
21263
21263
|
}
|
|
21264
|
-
const providerMetadataEntrySchema$1 = () => z$
|
|
21265
|
-
const gatewayTranscriptionWarningSchema = () => z$
|
|
21266
|
-
z$
|
|
21267
|
-
type: z$
|
|
21268
|
-
feature: z$
|
|
21269
|
-
details: z$
|
|
21264
|
+
const providerMetadataEntrySchema$1 = () => z$6.object({}).catchall(z$6.unknown());
|
|
21265
|
+
const gatewayTranscriptionWarningSchema = () => z$6.discriminatedUnion("type", [
|
|
21266
|
+
z$6.object({
|
|
21267
|
+
type: z$6.literal("unsupported"),
|
|
21268
|
+
feature: z$6.string(),
|
|
21269
|
+
details: z$6.string().optional()
|
|
21270
21270
|
}),
|
|
21271
|
-
z$
|
|
21272
|
-
type: z$
|
|
21273
|
-
feature: z$
|
|
21274
|
-
details: z$
|
|
21271
|
+
z$6.object({
|
|
21272
|
+
type: z$6.literal("compatibility"),
|
|
21273
|
+
feature: z$6.string(),
|
|
21274
|
+
details: z$6.string().optional()
|
|
21275
21275
|
}),
|
|
21276
|
-
z$
|
|
21277
|
-
type: z$
|
|
21278
|
-
setting: z$
|
|
21279
|
-
message: z$
|
|
21276
|
+
z$6.object({
|
|
21277
|
+
type: z$6.literal("deprecated"),
|
|
21278
|
+
setting: z$6.string(),
|
|
21279
|
+
message: z$6.string()
|
|
21280
21280
|
}),
|
|
21281
|
-
z$
|
|
21282
|
-
type: z$
|
|
21283
|
-
message: z$
|
|
21281
|
+
z$6.object({
|
|
21282
|
+
type: z$6.literal("other"),
|
|
21283
|
+
message: z$6.string()
|
|
21284
21284
|
})
|
|
21285
21285
|
]);
|
|
21286
|
-
const gatewayTranscriptionResponseSchema = lazySchema(() => zodSchema(z$
|
|
21287
|
-
text: z$
|
|
21288
|
-
segments: z$
|
|
21289
|
-
text: z$
|
|
21290
|
-
startSecond: z$
|
|
21291
|
-
endSecond: z$
|
|
21286
|
+
const gatewayTranscriptionResponseSchema = lazySchema(() => zodSchema(z$6.object({
|
|
21287
|
+
text: z$6.string(),
|
|
21288
|
+
segments: z$6.array(z$6.object({
|
|
21289
|
+
text: z$6.string(),
|
|
21290
|
+
startSecond: z$6.number(),
|
|
21291
|
+
endSecond: z$6.number()
|
|
21292
21292
|
})).optional(),
|
|
21293
|
-
language: z$
|
|
21294
|
-
durationInSeconds: z$
|
|
21295
|
-
warnings: z$
|
|
21296
|
-
usage: z$
|
|
21297
|
-
providerMetadata: z$
|
|
21293
|
+
language: z$6.string().nullish(),
|
|
21294
|
+
durationInSeconds: z$6.number().nullish(),
|
|
21295
|
+
warnings: z$6.array(gatewayTranscriptionWarningSchema()).optional(),
|
|
21296
|
+
usage: z$6.record(z$6.string(), z$6.json()).optional(),
|
|
21297
|
+
providerMetadata: z$6.record(z$6.string(), providerMetadataEntrySchema$1()).optional()
|
|
21298
21298
|
})));
|
|
21299
21299
|
var GatewaySpeechModel = class {
|
|
21300
21300
|
constructor(modelId, config) {
|
|
@@ -21322,7 +21322,7 @@ var GatewaySpeechModel = class {
|
|
|
21322
21322
|
},
|
|
21323
21323
|
successfulResponseHandler: createJsonResponseHandler(gatewaySpeechResponseSchema),
|
|
21324
21324
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
21325
|
-
errorSchema: z$
|
|
21325
|
+
errorSchema: z$6.any(),
|
|
21326
21326
|
errorToMessage: (data) => getErrorMessage(data) ?? "unknown error"
|
|
21327
21327
|
}),
|
|
21328
21328
|
...abortSignal && { abortSignal },
|
|
@@ -21532,33 +21532,33 @@ function createGatewaySpeechStream({ webSocket, url, protocols, headers, startFr
|
|
|
21532
21532
|
}
|
|
21533
21533
|
});
|
|
21534
21534
|
}
|
|
21535
|
-
const providerMetadataEntrySchema = () => z$
|
|
21536
|
-
const gatewaySpeechWarningSchema = () => z$
|
|
21537
|
-
z$
|
|
21538
|
-
type: z$
|
|
21539
|
-
feature: z$
|
|
21540
|
-
details: z$
|
|
21535
|
+
const providerMetadataEntrySchema = () => z$6.object({}).catchall(z$6.unknown());
|
|
21536
|
+
const gatewaySpeechWarningSchema = () => z$6.discriminatedUnion("type", [
|
|
21537
|
+
z$6.object({
|
|
21538
|
+
type: z$6.literal("unsupported"),
|
|
21539
|
+
feature: z$6.string(),
|
|
21540
|
+
details: z$6.string().optional()
|
|
21541
21541
|
}),
|
|
21542
|
-
z$
|
|
21543
|
-
type: z$
|
|
21544
|
-
feature: z$
|
|
21545
|
-
details: z$
|
|
21542
|
+
z$6.object({
|
|
21543
|
+
type: z$6.literal("compatibility"),
|
|
21544
|
+
feature: z$6.string(),
|
|
21545
|
+
details: z$6.string().optional()
|
|
21546
21546
|
}),
|
|
21547
|
-
z$
|
|
21548
|
-
type: z$
|
|
21549
|
-
setting: z$
|
|
21550
|
-
message: z$
|
|
21547
|
+
z$6.object({
|
|
21548
|
+
type: z$6.literal("deprecated"),
|
|
21549
|
+
setting: z$6.string(),
|
|
21550
|
+
message: z$6.string()
|
|
21551
21551
|
}),
|
|
21552
|
-
z$
|
|
21553
|
-
type: z$
|
|
21554
|
-
message: z$
|
|
21552
|
+
z$6.object({
|
|
21553
|
+
type: z$6.literal("other"),
|
|
21554
|
+
message: z$6.string()
|
|
21555
21555
|
})
|
|
21556
21556
|
]);
|
|
21557
|
-
const gatewaySpeechResponseSchema = lazySchema(() => zodSchema(z$
|
|
21558
|
-
audio: z$
|
|
21559
|
-
warnings: z$
|
|
21560
|
-
usage: z$
|
|
21561
|
-
providerMetadata: z$
|
|
21557
|
+
const gatewaySpeechResponseSchema = lazySchema(() => zodSchema(z$6.object({
|
|
21558
|
+
audio: z$6.string(),
|
|
21559
|
+
warnings: z$6.array(gatewaySpeechWarningSchema()).optional(),
|
|
21560
|
+
usage: z$6.record(z$6.string(), z$6.json()).optional(),
|
|
21561
|
+
providerMetadata: z$6.record(z$6.string(), providerMetadataEntrySchema()).optional()
|
|
21562
21562
|
})));
|
|
21563
21563
|
/**
|
|
21564
21564
|
* Realtime model backed by the AI Gateway.
|
|
@@ -21627,30 +21627,30 @@ function toGatewayRealtimeUrl(baseURL, modelId) {
|
|
|
21627
21627
|
url.searchParams.set("ai-model-id", modelId);
|
|
21628
21628
|
return url.toString();
|
|
21629
21629
|
}
|
|
21630
|
-
const jsonObjectSchema = () => z$
|
|
21630
|
+
const jsonObjectSchema = () => z$6.record(z$6.string(), z$6.unknown());
|
|
21631
21631
|
const browserbaseFetchToolFactory = createProviderExecutedToolFactory({
|
|
21632
21632
|
id: "gateway.browserbase_fetch",
|
|
21633
|
-
inputSchema: lazySchema(() => zodSchema(z$
|
|
21634
|
-
url: z$
|
|
21635
|
-
allow_redirects: z$
|
|
21636
|
-
allow_insecure_ssl: z$
|
|
21637
|
-
proxies: z$
|
|
21638
|
-
format: z$
|
|
21633
|
+
inputSchema: lazySchema(() => zodSchema(z$6.object({
|
|
21634
|
+
url: z$6.string().url().describe("URL of the page to fetch."),
|
|
21635
|
+
allow_redirects: z$6.boolean().optional().describe("Whether to follow HTTP redirects (default: false)."),
|
|
21636
|
+
allow_insecure_ssl: z$6.boolean().optional().describe("Whether to bypass TLS certificate verification (default: false). Only use for trusted hosts."),
|
|
21637
|
+
proxies: z$6.boolean().optional().describe("Whether to route the request through Browserbase proxies (default: false)."),
|
|
21638
|
+
format: z$6.enum([
|
|
21639
21639
|
"raw",
|
|
21640
21640
|
"json",
|
|
21641
21641
|
"markdown"
|
|
21642
21642
|
]).optional().describe("Output format. raw returns the response body unchanged, markdown returns page content as Markdown, and json returns structured content using schema."),
|
|
21643
21643
|
schema: jsonObjectSchema().optional().describe("JSON Schema for structured extraction. Only use with format set to json.")
|
|
21644
21644
|
}))),
|
|
21645
|
-
outputSchema: lazySchema(() => zodSchema(z$
|
|
21646
|
-
id: z$
|
|
21647
|
-
content: z$
|
|
21648
|
-
contentType: z$
|
|
21649
|
-
encoding: z$
|
|
21650
|
-
headers: z$
|
|
21651
|
-
statusCode: z$
|
|
21652
|
-
}), z$
|
|
21653
|
-
error: z$
|
|
21645
|
+
outputSchema: lazySchema(() => zodSchema(z$6.union([z$6.object({
|
|
21646
|
+
id: z$6.string(),
|
|
21647
|
+
content: z$6.union([z$6.string(), jsonObjectSchema()]),
|
|
21648
|
+
contentType: z$6.string(),
|
|
21649
|
+
encoding: z$6.string(),
|
|
21650
|
+
headers: z$6.record(z$6.string(), z$6.string()),
|
|
21651
|
+
statusCode: z$6.number()
|
|
21652
|
+
}), z$6.object({
|
|
21653
|
+
error: z$6.enum([
|
|
21654
21654
|
"api_error",
|
|
21655
21655
|
"configuration_error",
|
|
21656
21656
|
"execution_error",
|
|
@@ -21659,31 +21659,31 @@ const browserbaseFetchToolFactory = createProviderExecutedToolFactory({
|
|
|
21659
21659
|
"timeout",
|
|
21660
21660
|
"unknown"
|
|
21661
21661
|
]),
|
|
21662
|
-
statusCode: z$
|
|
21663
|
-
message: z$
|
|
21662
|
+
statusCode: z$6.number().optional(),
|
|
21663
|
+
message: z$6.string()
|
|
21664
21664
|
})])))
|
|
21665
21665
|
});
|
|
21666
21666
|
const browserbaseFetch = (config = {}) => browserbaseFetchToolFactory(config);
|
|
21667
21667
|
const browserbaseSearchToolFactory = createProviderExecutedToolFactory({
|
|
21668
21668
|
id: "gateway.browserbase_search",
|
|
21669
|
-
inputSchema: lazySchema(() => zodSchema(z$
|
|
21670
|
-
query: z$
|
|
21671
|
-
num_results: z$
|
|
21669
|
+
inputSchema: lazySchema(() => zodSchema(z$6.object({
|
|
21670
|
+
query: z$6.string().min(1).max(200).describe("Web search query. Must be between 1 and 200 characters."),
|
|
21671
|
+
num_results: z$6.number().int().min(1).max(25).optional().describe("Maximum number of results to return (1-25, default: 10).")
|
|
21672
21672
|
}))),
|
|
21673
|
-
outputSchema: lazySchema(() => zodSchema(z$
|
|
21674
|
-
query: z$
|
|
21675
|
-
requestId: z$
|
|
21676
|
-
results: z$
|
|
21677
|
-
id: z$
|
|
21678
|
-
title: z$
|
|
21679
|
-
url: z$
|
|
21680
|
-
author: z$
|
|
21681
|
-
favicon: z$
|
|
21682
|
-
image: z$
|
|
21683
|
-
publishedDate: z$
|
|
21673
|
+
outputSchema: lazySchema(() => zodSchema(z$6.union([z$6.object({
|
|
21674
|
+
query: z$6.string(),
|
|
21675
|
+
requestId: z$6.string(),
|
|
21676
|
+
results: z$6.array(z$6.object({
|
|
21677
|
+
id: z$6.string(),
|
|
21678
|
+
title: z$6.string(),
|
|
21679
|
+
url: z$6.string(),
|
|
21680
|
+
author: z$6.string().optional(),
|
|
21681
|
+
favicon: z$6.string().optional(),
|
|
21682
|
+
image: z$6.string().optional(),
|
|
21683
|
+
publishedDate: z$6.string().optional()
|
|
21684
21684
|
}))
|
|
21685
|
-
}), z$
|
|
21686
|
-
error: z$
|
|
21685
|
+
}), z$6.object({
|
|
21686
|
+
error: z$6.enum([
|
|
21687
21687
|
"api_error",
|
|
21688
21688
|
"configuration_error",
|
|
21689
21689
|
"execution_error",
|
|
@@ -21692,13 +21692,13 @@ const browserbaseSearchToolFactory = createProviderExecutedToolFactory({
|
|
|
21692
21692
|
"timeout",
|
|
21693
21693
|
"unknown"
|
|
21694
21694
|
]),
|
|
21695
|
-
statusCode: z$
|
|
21696
|
-
message: z$
|
|
21695
|
+
statusCode: z$6.number().optional(),
|
|
21696
|
+
message: z$6.string()
|
|
21697
21697
|
})])))
|
|
21698
21698
|
});
|
|
21699
21699
|
const browserbaseSearch = (config = {}) => browserbaseSearchToolFactory(config);
|
|
21700
|
-
const gatewayToolErrorSchema = () => z$
|
|
21701
|
-
error: z$
|
|
21700
|
+
const gatewayToolErrorSchema = () => z$6.object({
|
|
21701
|
+
error: z$6.enum([
|
|
21702
21702
|
"api_error",
|
|
21703
21703
|
"configuration_error",
|
|
21704
21704
|
"execution_error",
|
|
@@ -21709,53 +21709,53 @@ const gatewayToolErrorSchema = () => z$5.object({
|
|
|
21709
21709
|
"unknown",
|
|
21710
21710
|
"unknown_tool"
|
|
21711
21711
|
]),
|
|
21712
|
-
message: z$
|
|
21713
|
-
statusCode: z$
|
|
21714
|
-
retryAfter: z$
|
|
21715
|
-
statusText: z$
|
|
21712
|
+
message: z$6.string(),
|
|
21713
|
+
statusCode: z$6.number().optional(),
|
|
21714
|
+
retryAfter: z$6.string().optional(),
|
|
21715
|
+
statusText: z$6.string().optional()
|
|
21716
21716
|
}).passthrough();
|
|
21717
21717
|
const deepseekFetchToolFactory = createProviderExecutedToolFactory({
|
|
21718
21718
|
id: "gateway.deepseek_fetch",
|
|
21719
|
-
inputSchema: lazySchema(() => zodSchema(z$
|
|
21720
|
-
outputSchema: lazySchema(() => zodSchema(z$
|
|
21721
|
-
title: z$
|
|
21722
|
-
content: z$
|
|
21719
|
+
inputSchema: lazySchema(() => zodSchema(z$6.object({ url: z$6.string().describe("URL to fetch, at most 8192 characters; HTTP(S) only, without a username or password.") }))),
|
|
21720
|
+
outputSchema: lazySchema(() => zodSchema(z$6.union([z$6.object({
|
|
21721
|
+
title: z$6.string().nullish(),
|
|
21722
|
+
content: z$6.string()
|
|
21723
21723
|
}).passthrough(), gatewayToolErrorSchema()])))
|
|
21724
21724
|
});
|
|
21725
21725
|
const deepseekFetch = (config = {}) => deepseekFetchToolFactory(config);
|
|
21726
21726
|
const deepseekSearchToolFactory = createProviderExecutedToolFactory({
|
|
21727
21727
|
id: "gateway.deepseek_search",
|
|
21728
|
-
inputSchema: lazySchema(() => zodSchema(z$
|
|
21729
|
-
query: z$
|
|
21730
|
-
count: z$
|
|
21731
|
-
need_content: z$
|
|
21732
|
-
ori_question: z$
|
|
21728
|
+
inputSchema: lazySchema(() => zodSchema(z$6.object({
|
|
21729
|
+
query: z$6.string().describe("Web search query, 1 to 128 Unicode characters. Supports site:, -site:, lang:, after:, before:, and quoted phrases."),
|
|
21730
|
+
count: z$6.number().int().optional().describe("Number of results, 1 to 50 (default: 10)."),
|
|
21731
|
+
need_content: z$6.boolean().optional().describe("Include available page content (default: false)."),
|
|
21732
|
+
ori_question: z$6.string().nullable().optional().describe("Original user question, 1 to 128 Unicode characters.")
|
|
21733
21733
|
}))),
|
|
21734
|
-
outputSchema: lazySchema(() => zodSchema(z$
|
|
21735
|
-
authority: z$
|
|
21736
|
-
content: z$
|
|
21737
|
-
date: z$
|
|
21738
|
-
rerank_score: z$
|
|
21739
|
-
site_icon: z$
|
|
21740
|
-
site_name: z$
|
|
21741
|
-
snippet: z$
|
|
21742
|
-
summary: z$
|
|
21743
|
-
title: z$
|
|
21744
|
-
url: z$
|
|
21734
|
+
outputSchema: lazySchema(() => zodSchema(z$6.union([z$6.object({ results: z$6.array(z$6.object({
|
|
21735
|
+
authority: z$6.number().nullish(),
|
|
21736
|
+
content: z$6.string().nullish(),
|
|
21737
|
+
date: z$6.string().nullish(),
|
|
21738
|
+
rerank_score: z$6.number().nullish(),
|
|
21739
|
+
site_icon: z$6.string().nullish(),
|
|
21740
|
+
site_name: z$6.string().nullish(),
|
|
21741
|
+
snippet: z$6.string().nullish(),
|
|
21742
|
+
summary: z$6.string().nullish(),
|
|
21743
|
+
title: z$6.string().nullish(),
|
|
21744
|
+
url: z$6.string().nullish()
|
|
21745
21745
|
}).passthrough()) }).passthrough(), gatewayToolErrorSchema()])))
|
|
21746
21746
|
});
|
|
21747
21747
|
const deepseekSearch = (config = {}) => deepseekSearchToolFactory(config);
|
|
21748
21748
|
const exaSearchToolFactory = createProviderExecutedToolFactory({
|
|
21749
21749
|
id: "gateway.exa_search",
|
|
21750
|
-
inputSchema: lazySchema(() => zodSchema(z$
|
|
21751
|
-
query: z$
|
|
21752
|
-
type: z$
|
|
21750
|
+
inputSchema: lazySchema(() => zodSchema(z$6.object({
|
|
21751
|
+
query: z$6.string().describe("Natural-language web search query. This is required."),
|
|
21752
|
+
type: z$6.enum([
|
|
21753
21753
|
"auto",
|
|
21754
21754
|
"fast",
|
|
21755
21755
|
"instant"
|
|
21756
21756
|
]).optional().describe("Search method. Use auto for the default balance of speed and quality."),
|
|
21757
|
-
num_results: z$
|
|
21758
|
-
category: z$
|
|
21757
|
+
num_results: z$6.number().optional().describe("Maximum number of results to return (1-100, default: 10)."),
|
|
21758
|
+
category: z$6.enum([
|
|
21759
21759
|
"company",
|
|
21760
21760
|
"people",
|
|
21761
21761
|
"research paper",
|
|
@@ -21763,21 +21763,21 @@ const exaSearchToolFactory = createProviderExecutedToolFactory({
|
|
|
21763
21763
|
"personal site",
|
|
21764
21764
|
"financial report"
|
|
21765
21765
|
]).optional().describe("Optional content category to focus results."),
|
|
21766
|
-
user_location: z$
|
|
21767
|
-
include_domains: z$
|
|
21768
|
-
exclude_domains: z$
|
|
21769
|
-
start_published_date: z$
|
|
21770
|
-
end_published_date: z$
|
|
21771
|
-
contents: z$
|
|
21772
|
-
text: z$
|
|
21773
|
-
max_characters: z$
|
|
21774
|
-
include_html_tags: z$
|
|
21775
|
-
verbosity: z$
|
|
21766
|
+
user_location: z$6.string().optional().describe("Two-letter ISO country code such as 'US'."),
|
|
21767
|
+
include_domains: z$6.array(z$6.string()).optional().describe("Only return results from these domains."),
|
|
21768
|
+
exclude_domains: z$6.array(z$6.string()).optional().describe("Exclude results from these domains."),
|
|
21769
|
+
start_published_date: z$6.string().optional().describe("Only return links published after this ISO 8601 date."),
|
|
21770
|
+
end_published_date: z$6.string().optional().describe("Only return links published before this ISO 8601 date."),
|
|
21771
|
+
contents: z$6.object({
|
|
21772
|
+
text: z$6.union([z$6.boolean(), z$6.object({
|
|
21773
|
+
max_characters: z$6.number().optional(),
|
|
21774
|
+
include_html_tags: z$6.boolean().optional(),
|
|
21775
|
+
verbosity: z$6.enum([
|
|
21776
21776
|
"compact",
|
|
21777
21777
|
"standard",
|
|
21778
21778
|
"full"
|
|
21779
21779
|
]).optional(),
|
|
21780
|
-
include_sections: z$
|
|
21780
|
+
include_sections: z$6.array(z$6.enum([
|
|
21781
21781
|
"header",
|
|
21782
21782
|
"navigation",
|
|
21783
21783
|
"banner",
|
|
@@ -21786,7 +21786,7 @@ const exaSearchToolFactory = createProviderExecutedToolFactory({
|
|
|
21786
21786
|
"footer",
|
|
21787
21787
|
"metadata"
|
|
21788
21788
|
])).optional(),
|
|
21789
|
-
exclude_sections: z$
|
|
21789
|
+
exclude_sections: z$6.array(z$6.enum([
|
|
21790
21790
|
"header",
|
|
21791
21791
|
"navigation",
|
|
21792
21792
|
"banner",
|
|
@@ -21796,48 +21796,48 @@ const exaSearchToolFactory = createProviderExecutedToolFactory({
|
|
|
21796
21796
|
"metadata"
|
|
21797
21797
|
])).optional()
|
|
21798
21798
|
})]).optional(),
|
|
21799
|
-
highlights: z$
|
|
21800
|
-
query: z$
|
|
21801
|
-
max_characters: z$
|
|
21799
|
+
highlights: z$6.union([z$6.boolean(), z$6.object({
|
|
21800
|
+
query: z$6.string().optional(),
|
|
21801
|
+
max_characters: z$6.number().optional()
|
|
21802
21802
|
})]).optional(),
|
|
21803
|
-
max_age_hours: z$
|
|
21804
|
-
livecrawl_timeout: z$
|
|
21805
|
-
subpages: z$
|
|
21806
|
-
subpage_target: z$
|
|
21807
|
-
extras: z$
|
|
21808
|
-
links: z$
|
|
21809
|
-
image_links: z$
|
|
21803
|
+
max_age_hours: z$6.number().optional(),
|
|
21804
|
+
livecrawl_timeout: z$6.number().optional(),
|
|
21805
|
+
subpages: z$6.number().optional(),
|
|
21806
|
+
subpage_target: z$6.union([z$6.string(), z$6.array(z$6.string())]).optional(),
|
|
21807
|
+
extras: z$6.object({
|
|
21808
|
+
links: z$6.number().optional(),
|
|
21809
|
+
image_links: z$6.number().optional()
|
|
21810
21810
|
}).optional()
|
|
21811
21811
|
}).optional().describe("Controls extracted page content and freshness.")
|
|
21812
21812
|
}))),
|
|
21813
|
-
outputSchema: lazySchema(() => zodSchema(z$
|
|
21814
|
-
requestId: z$
|
|
21815
|
-
searchType: z$
|
|
21816
|
-
resolvedSearchType: z$
|
|
21817
|
-
results: z$
|
|
21818
|
-
title: z$
|
|
21819
|
-
url: z$
|
|
21820
|
-
id: z$
|
|
21821
|
-
publishedDate: z$
|
|
21822
|
-
author: z$
|
|
21823
|
-
image: z$
|
|
21824
|
-
favicon: z$
|
|
21825
|
-
text: z$
|
|
21826
|
-
highlights: z$
|
|
21827
|
-
highlightScores: z$
|
|
21828
|
-
summary: z$
|
|
21829
|
-
subpages: z$
|
|
21830
|
-
extras: z$
|
|
21831
|
-
links: z$
|
|
21832
|
-
imageLinks: z$
|
|
21813
|
+
outputSchema: lazySchema(() => zodSchema(z$6.union([z$6.object({
|
|
21814
|
+
requestId: z$6.string(),
|
|
21815
|
+
searchType: z$6.string().optional(),
|
|
21816
|
+
resolvedSearchType: z$6.string().optional(),
|
|
21817
|
+
results: z$6.array(z$6.object({
|
|
21818
|
+
title: z$6.string(),
|
|
21819
|
+
url: z$6.string(),
|
|
21820
|
+
id: z$6.string(),
|
|
21821
|
+
publishedDate: z$6.string().nullable().optional(),
|
|
21822
|
+
author: z$6.string().nullable().optional(),
|
|
21823
|
+
image: z$6.string().nullable().optional(),
|
|
21824
|
+
favicon: z$6.string().nullable().optional(),
|
|
21825
|
+
text: z$6.string().optional(),
|
|
21826
|
+
highlights: z$6.array(z$6.string()).optional(),
|
|
21827
|
+
highlightScores: z$6.array(z$6.number()).optional(),
|
|
21828
|
+
summary: z$6.string().optional(),
|
|
21829
|
+
subpages: z$6.array(z$6.any()).optional(),
|
|
21830
|
+
extras: z$6.object({
|
|
21831
|
+
links: z$6.array(z$6.string()).optional(),
|
|
21832
|
+
imageLinks: z$6.array(z$6.string()).optional()
|
|
21833
21833
|
}).optional()
|
|
21834
21834
|
})),
|
|
21835
|
-
costDollars: z$
|
|
21836
|
-
total: z$
|
|
21837
|
-
search: z$
|
|
21835
|
+
costDollars: z$6.object({
|
|
21836
|
+
total: z$6.number().optional(),
|
|
21837
|
+
search: z$6.record(z$6.string(), z$6.number()).optional()
|
|
21838
21838
|
}).optional()
|
|
21839
|
-
}), z$
|
|
21840
|
-
error: z$
|
|
21839
|
+
}), z$6.object({
|
|
21840
|
+
error: z$6.enum([
|
|
21841
21841
|
"api_error",
|
|
21842
21842
|
"rate_limit",
|
|
21843
21843
|
"timeout",
|
|
@@ -21846,8 +21846,8 @@ const exaSearchToolFactory = createProviderExecutedToolFactory({
|
|
|
21846
21846
|
"execution_error",
|
|
21847
21847
|
"unknown"
|
|
21848
21848
|
]),
|
|
21849
|
-
statusCode: z$
|
|
21850
|
-
message: z$
|
|
21849
|
+
statusCode: z$6.number().optional(),
|
|
21850
|
+
message: z$6.string()
|
|
21851
21851
|
})])))
|
|
21852
21852
|
});
|
|
21853
21853
|
const exaSearch = (config = {}) => exaSearchToolFactory(config);
|
|
@@ -21861,277 +21861,277 @@ const parallelSearchModes = [
|
|
|
21861
21861
|
];
|
|
21862
21862
|
const parallelSearchToolFactory = createProviderExecutedToolFactory({
|
|
21863
21863
|
id: "gateway.parallel_search",
|
|
21864
|
-
inputSchema: lazySchema(() => zodSchema(z$
|
|
21865
|
-
objective: z$
|
|
21866
|
-
search_queries: z$
|
|
21867
|
-
mode: z$
|
|
21868
|
-
max_results: z$
|
|
21869
|
-
source_policy: z$
|
|
21870
|
-
include_domains: z$
|
|
21871
|
-
exclude_domains: z$
|
|
21872
|
-
after_date: z$
|
|
21864
|
+
inputSchema: lazySchema(() => zodSchema(z$6.object({
|
|
21865
|
+
objective: z$6.string().describe("Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."),
|
|
21866
|
+
search_queries: z$6.array(z$6.string()).optional().describe("Provide 2-3 concise keyword queries, 3-6 words each (max 5, 200 chars each). Strongly recommended; the search runs on these queries."),
|
|
21867
|
+
mode: z$6.enum(parallelSearchModes).optional().describe("Search mode: \"turbo\" and \"fast\" return quickly with shorter excerpts, \"basic\" is balanced (default), \"advanced\" is the most thorough. \"turbo\" supports English and Japanese only. \"one-shot\" and \"agentic\" are deprecated aliases of \"basic\" and \"advanced\"."),
|
|
21868
|
+
max_results: z$6.number().optional().describe("Maximum number of results to return (1-20). Defaults to 10 if not specified."),
|
|
21869
|
+
source_policy: z$6.object({
|
|
21870
|
+
include_domains: z$6.array(z$6.string()).optional().describe("Domains or domain/path prefixes to restrict results to, without scheme or port. Example: ['wikipedia.org', 'docs.python.org/3']."),
|
|
21871
|
+
exclude_domains: z$6.array(z$6.string()).optional().describe("Domains or domain/path prefixes to exclude, without scheme or port. Example: ['reddit.com']."),
|
|
21872
|
+
after_date: z$6.string().optional().describe("Only include results published on or after this date. Use an ISO 8601 calendar date formatted YYYY-MM-DD (e.g. 2025-01-01); do not include a time.")
|
|
21873
21873
|
}).optional().describe("Source policy for controlling which domains to include/exclude and freshness."),
|
|
21874
|
-
excerpts: z$
|
|
21875
|
-
max_chars_per_result: z$
|
|
21876
|
-
max_chars_total: z$
|
|
21874
|
+
excerpts: z$6.object({
|
|
21875
|
+
max_chars_per_result: z$6.number().optional().describe("Maximum characters per result."),
|
|
21876
|
+
max_chars_total: z$6.number().optional().describe("Deprecated: use the top-level max_chars_total.")
|
|
21877
21877
|
}).optional().describe("Excerpt configuration for controlling result length."),
|
|
21878
|
-
max_chars_total: z$
|
|
21879
|
-
fetch_policy: z$
|
|
21880
|
-
max_age_seconds: z$
|
|
21881
|
-
timeout_seconds: z$
|
|
21882
|
-
disable_cache_fallback: z$
|
|
21878
|
+
max_chars_total: z$6.number().optional().describe("Maximum total characters across all result excerpts."),
|
|
21879
|
+
fetch_policy: z$6.object({
|
|
21880
|
+
max_age_seconds: z$6.number().optional().describe("Maximum age of cached content in seconds before a live fetch, minimum 600."),
|
|
21881
|
+
timeout_seconds: z$6.number().optional().describe("Timeout in seconds for a live fetch when content is not cached. Capped by the gateway tool timeout."),
|
|
21882
|
+
disable_cache_fallback: z$6.boolean().optional().describe("Return an error instead of older cached content when a live fetch fails.")
|
|
21883
21883
|
}).optional().describe("Fetch policy for controlling content freshness."),
|
|
21884
|
-
location: z$
|
|
21884
|
+
location: z$6.string().optional().describe("ISO 3166-1 alpha-2 country code to localize results, e.g. \"us\".")
|
|
21885
21885
|
}))),
|
|
21886
|
-
outputSchema: lazySchema(() => zodSchema(z$
|
|
21887
|
-
search_id: z$
|
|
21888
|
-
results: z$
|
|
21889
|
-
url: z$
|
|
21890
|
-
title: z$
|
|
21891
|
-
publish_date: z$
|
|
21892
|
-
excerpts: z$
|
|
21886
|
+
outputSchema: lazySchema(() => zodSchema(z$6.union([z$6.object({
|
|
21887
|
+
search_id: z$6.string(),
|
|
21888
|
+
results: z$6.array(z$6.object({
|
|
21889
|
+
url: z$6.string(),
|
|
21890
|
+
title: z$6.string().nullable().optional(),
|
|
21891
|
+
publish_date: z$6.string().nullable().optional(),
|
|
21892
|
+
excerpts: z$6.array(z$6.string())
|
|
21893
21893
|
})),
|
|
21894
|
-
warnings: z$
|
|
21895
|
-
type: z$
|
|
21896
|
-
message: z$
|
|
21897
|
-
detail: z$
|
|
21894
|
+
warnings: z$6.array(z$6.object({
|
|
21895
|
+
type: z$6.string(),
|
|
21896
|
+
message: z$6.string(),
|
|
21897
|
+
detail: z$6.record(z$6.string(), z$6.unknown()).nullable().optional()
|
|
21898
21898
|
})).nullable().optional(),
|
|
21899
|
-
usage: z$
|
|
21900
|
-
name: z$
|
|
21901
|
-
count: z$
|
|
21899
|
+
usage: z$6.array(z$6.object({
|
|
21900
|
+
name: z$6.string(),
|
|
21901
|
+
count: z$6.number().optional()
|
|
21902
21902
|
})).nullable().optional(),
|
|
21903
|
-
session_id: z$
|
|
21903
|
+
session_id: z$6.string().optional()
|
|
21904
21904
|
}), gatewayToolErrorSchema()])))
|
|
21905
21905
|
});
|
|
21906
21906
|
const parallelSearch = (config = {}) => parallelSearchToolFactory(config);
|
|
21907
21907
|
const perplexitySearchToolFactory = createProviderExecutedToolFactory({
|
|
21908
21908
|
id: "gateway.perplexity_search",
|
|
21909
|
-
inputSchema: lazySchema(() => zodSchema(z$
|
|
21910
|
-
query: z$
|
|
21911
|
-
max_results: z$
|
|
21912
|
-
max_tokens_per_page: z$
|
|
21913
|
-
max_tokens: z$
|
|
21914
|
-
country: z$
|
|
21915
|
-
search_domain_filter: z$
|
|
21916
|
-
search_language_filter: z$
|
|
21917
|
-
search_after_date: z$
|
|
21918
|
-
search_before_date: z$
|
|
21919
|
-
last_updated_after_filter: z$
|
|
21920
|
-
last_updated_before_filter: z$
|
|
21921
|
-
search_recency_filter: z$
|
|
21909
|
+
inputSchema: lazySchema(() => zodSchema(z$6.object({
|
|
21910
|
+
query: z$6.union([z$6.string(), z$6.array(z$6.string())]).describe("Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries."),
|
|
21911
|
+
max_results: z$6.number().optional().describe("Maximum number of search results to return (1-20, default: 10)"),
|
|
21912
|
+
max_tokens_per_page: z$6.number().optional().describe("Maximum number of tokens to extract per search result page (256-2048, default: 2048)"),
|
|
21913
|
+
max_tokens: z$6.number().optional().describe("Maximum total tokens across all search results (default: 25000, max: 1000000)"),
|
|
21914
|
+
country: z$6.string().optional().describe("Two-letter ISO 3166-1 alpha-2 country code for regional search results (e.g., 'US', 'GB', 'FR')"),
|
|
21915
|
+
search_domain_filter: z$6.array(z$6.string()).optional().describe("List of domains to include or exclude from search results (max 20). To include: ['nature.com', 'science.org']. To exclude: ['-example.com', '-spam.net']"),
|
|
21916
|
+
search_language_filter: z$6.array(z$6.string()).optional().describe("List of ISO 639-1 language codes to filter results (max 10, lowercase). Examples: ['en', 'fr', 'de']"),
|
|
21917
|
+
search_after_date: z$6.string().optional().describe("Include only results published after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."),
|
|
21918
|
+
search_before_date: z$6.string().optional().describe("Include only results published before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."),
|
|
21919
|
+
last_updated_after_filter: z$6.string().optional().describe("Include only results last updated after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."),
|
|
21920
|
+
last_updated_before_filter: z$6.string().optional().describe("Include only results last updated before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."),
|
|
21921
|
+
search_recency_filter: z$6.enum([
|
|
21922
21922
|
"day",
|
|
21923
21923
|
"week",
|
|
21924
21924
|
"month",
|
|
21925
21925
|
"year"
|
|
21926
21926
|
]).optional().describe("Filter results by relative time period. Cannot be used with search_after_date or search_before_date.")
|
|
21927
21927
|
}))),
|
|
21928
|
-
outputSchema: lazySchema(() => zodSchema(z$
|
|
21929
|
-
results: z$
|
|
21930
|
-
title: z$
|
|
21931
|
-
url: z$
|
|
21932
|
-
snippet: z$
|
|
21933
|
-
date: z$
|
|
21934
|
-
lastUpdated: z$
|
|
21928
|
+
outputSchema: lazySchema(() => zodSchema(z$6.union([z$6.object({
|
|
21929
|
+
results: z$6.array(z$6.object({
|
|
21930
|
+
title: z$6.string(),
|
|
21931
|
+
url: z$6.string(),
|
|
21932
|
+
snippet: z$6.string(),
|
|
21933
|
+
date: z$6.string().optional(),
|
|
21934
|
+
lastUpdated: z$6.string().optional()
|
|
21935
21935
|
})),
|
|
21936
|
-
id: z$
|
|
21937
|
-
}), z$
|
|
21938
|
-
error: z$
|
|
21936
|
+
id: z$6.string()
|
|
21937
|
+
}), z$6.object({
|
|
21938
|
+
error: z$6.enum([
|
|
21939
21939
|
"api_error",
|
|
21940
21940
|
"rate_limit",
|
|
21941
21941
|
"timeout",
|
|
21942
21942
|
"invalid_input",
|
|
21943
21943
|
"unknown"
|
|
21944
21944
|
]),
|
|
21945
|
-
statusCode: z$
|
|
21946
|
-
message: z$
|
|
21945
|
+
statusCode: z$6.number().optional(),
|
|
21946
|
+
message: z$6.string()
|
|
21947
21947
|
})])))
|
|
21948
21948
|
});
|
|
21949
21949
|
const perplexitySearch = (config = {}) => perplexitySearchToolFactory(config);
|
|
21950
|
-
const takoDataSourceInputSchema = () => z$
|
|
21951
|
-
count: z$
|
|
21952
|
-
include_contents: z$
|
|
21953
|
-
mode: z$
|
|
21954
|
-
content_format: z$
|
|
21950
|
+
const takoDataSourceInputSchema = () => z$6.object({
|
|
21951
|
+
count: z$6.number().optional().describe("Maximum number of data results to return (1-20). When include_contents is true, each additional result adds its own data surcharge."),
|
|
21952
|
+
include_contents: z$6.boolean().optional().describe("Inline rows for each data result. This adds a data surcharge based on row count and dataset source. To estimate cost, search with include_contents disabled and inspect cards.content.export_pricing. This applies to every returned card; limit sources.data.count and sources.data.max_rows to control cost."),
|
|
21953
|
+
mode: z$6.enum(["inline", "url"]).optional().describe("Requested data delivery mode. Search card data is always inline."),
|
|
21954
|
+
content_format: z$6.enum([
|
|
21955
21955
|
"card_json",
|
|
21956
21956
|
"csv",
|
|
21957
21957
|
"json_compact",
|
|
21958
21958
|
"json_records"
|
|
21959
21959
|
]).optional().describe("Serialization for inlined card data."),
|
|
21960
|
-
max_rows: z$
|
|
21961
|
-
node_ids: z$
|
|
21962
|
-
strict: z$
|
|
21960
|
+
max_rows: z$6.number().optional().describe("Maximum rows to inline per result. Omit to use the allowance in cards.content.export_pricing. A data surcharge applies per 1,000 exported rows; lower values reduce cost."),
|
|
21961
|
+
node_ids: z$6.array(z$6.string()).optional().describe("Data Graph node IDs to prioritize. Maximum 20."),
|
|
21962
|
+
strict: z$6.boolean().optional().describe("Only return cards matching node_ids. Requires a non-empty node_ids.")
|
|
21963
21963
|
});
|
|
21964
|
-
const takoWebSourceInputSchema = () => z$
|
|
21965
|
-
count: z$
|
|
21966
|
-
include_contents: z$
|
|
21967
|
-
category: z$
|
|
21964
|
+
const takoWebSourceInputSchema = () => z$6.object({
|
|
21965
|
+
count: z$6.number().optional().describe("Maximum number of web results to return (1-20)."),
|
|
21966
|
+
include_contents: z$6.boolean().optional().describe("Inline extracted web page text. This can add a data charge."),
|
|
21967
|
+
category: z$6.enum([
|
|
21968
21968
|
"finance",
|
|
21969
21969
|
"news",
|
|
21970
21970
|
"sports"
|
|
21971
21971
|
]).optional().describe("Optional web-result category filter."),
|
|
21972
|
-
include_domains: z$
|
|
21973
|
-
exclude_domains: z$
|
|
21974
|
-
snippet_max_chars: z$
|
|
21975
|
-
highlights: z$
|
|
21976
|
-
article_content_max_chars: z$
|
|
21977
|
-
published_after: z$
|
|
21978
|
-
published_before: z$
|
|
21972
|
+
include_domains: z$6.array(z$6.string()).optional().describe("Only return results from these bare domains."),
|
|
21973
|
+
exclude_domains: z$6.array(z$6.string()).optional().describe("Exclude results from these bare domains."),
|
|
21974
|
+
snippet_max_chars: z$6.number().optional().describe("Maximum characters in each web-result snippet."),
|
|
21975
|
+
highlights: z$6.boolean().optional().describe("Include highlighted passages in web results. Defaults to true in AI Gateway."),
|
|
21976
|
+
article_content_max_chars: z$6.number().optional().describe("Maximum extracted characters per web page when including contents."),
|
|
21977
|
+
published_after: z$6.string().optional().describe("Keep results published on or after this ISO date (YYYY-MM-DD)."),
|
|
21978
|
+
published_before: z$6.string().optional().describe("Keep results published on or before this ISO date (YYYY-MM-DD).")
|
|
21979
21979
|
});
|
|
21980
|
-
const takoSearchInputSchema = lazySchema(() => zodSchema(z$
|
|
21981
|
-
query: z$
|
|
21982
|
-
effort: z$
|
|
21980
|
+
const takoSearchInputSchema = lazySchema(() => zodSchema(z$6.object({
|
|
21981
|
+
query: z$6.string().describe("Natural-language search query. Include the entity, metric, and time period. Quote a phrase to force it to one entity, for example \"Tesla\":PRODUCT price."),
|
|
21982
|
+
effort: z$6.enum([
|
|
21983
21983
|
"deep",
|
|
21984
21984
|
"fast",
|
|
21985
21985
|
"instant"
|
|
21986
21986
|
]).optional().describe("Search effort. fast is the balanced default, instant favors cached results and low latency, and deep broadens retrieval with reranking at higher cost and latency."),
|
|
21987
|
-
sources: z$
|
|
21987
|
+
sources: z$6.object({
|
|
21988
21988
|
data: takoDataSourceInputSchema().optional(),
|
|
21989
21989
|
web: takoWebSourceInputSchema().optional()
|
|
21990
21990
|
}).optional().describe("Sources to search. Omit to search both curated data and the web. When provided, only keys present are searched."),
|
|
21991
|
-
location: z$
|
|
21992
|
-
latitude: z$
|
|
21993
|
-
longitude: z$
|
|
21991
|
+
location: z$6.object({
|
|
21992
|
+
latitude: z$6.number().describe("Latitude between -90 and 90."),
|
|
21993
|
+
longitude: z$6.number().describe("Longitude between -180 and 180.")
|
|
21994
21994
|
}).optional().describe("End-user coordinates for localized results."),
|
|
21995
|
-
country_code: z$
|
|
21996
|
-
locale: z$
|
|
21997
|
-
timezone: z$
|
|
21998
|
-
output_settings: z$
|
|
21999
|
-
image_dark_mode: z$
|
|
22000
|
-
force_refresh: z$
|
|
21995
|
+
country_code: z$6.string().optional().describe("Two-letter ISO 3166-1 country code, such as 'US'."),
|
|
21996
|
+
locale: z$6.string().optional().describe("BCP-47 locale, such as 'en-US'."),
|
|
21997
|
+
timezone: z$6.string().optional().describe("IANA timezone, such as 'America/New_York'."),
|
|
21998
|
+
output_settings: z$6.object({
|
|
21999
|
+
image_dark_mode: z$6.boolean().optional().describe("Render card preview images in dark mode."),
|
|
22000
|
+
force_refresh: z$6.boolean().optional().describe("Instant-effort only. Request a refreshed instant result.")
|
|
22001
22001
|
}).optional().describe("Controls card rendering in the search response."),
|
|
22002
|
-
include_related: z$
|
|
22002
|
+
include_related: z$6.number().optional().describe("Maximum related search suggestions to include (1-20).")
|
|
22003
22003
|
})));
|
|
22004
|
-
const takoDatasetCellSchema = () => z$
|
|
22005
|
-
z$
|
|
22006
|
-
z$
|
|
22007
|
-
z$
|
|
22004
|
+
const takoDatasetCellSchema = () => z$6.union([
|
|
22005
|
+
z$6.boolean(),
|
|
22006
|
+
z$6.number(),
|
|
22007
|
+
z$6.string()
|
|
22008
22008
|
]).nullable();
|
|
22009
|
-
const takoResultContentSchema = () => z$
|
|
22010
|
-
content_format: z$
|
|
22009
|
+
const takoResultContentSchema = () => z$6.object({
|
|
22010
|
+
content_format: z$6.enum([
|
|
22011
22011
|
"card_json",
|
|
22012
22012
|
"csv",
|
|
22013
22013
|
"json_compact",
|
|
22014
22014
|
"json_records"
|
|
22015
22015
|
]).nullish(),
|
|
22016
|
-
cost: z$
|
|
22017
|
-
data: z$
|
|
22018
|
-
records: z$
|
|
22019
|
-
dataset: z$
|
|
22020
|
-
columns: z$
|
|
22021
|
-
name: z$
|
|
22022
|
-
type: z$
|
|
22016
|
+
cost: z$6.number().optional(),
|
|
22017
|
+
data: z$6.string().nullish(),
|
|
22018
|
+
records: z$6.array(z$6.record(z$6.string(), takoDatasetCellSchema())).nullish(),
|
|
22019
|
+
dataset: z$6.object({
|
|
22020
|
+
columns: z$6.array(z$6.object({
|
|
22021
|
+
name: z$6.string(),
|
|
22022
|
+
type: z$6.enum([
|
|
22023
22023
|
"boolean",
|
|
22024
22024
|
"date",
|
|
22025
22025
|
"datetime",
|
|
22026
22026
|
"number",
|
|
22027
22027
|
"string"
|
|
22028
22028
|
]),
|
|
22029
|
-
unit: z$
|
|
22029
|
+
unit: z$6.string().nullish()
|
|
22030
22030
|
})),
|
|
22031
|
-
rows: z$
|
|
22032
|
-
total_rows: z$
|
|
22033
|
-
truncated: z$
|
|
22034
|
-
ref: z$
|
|
22035
|
-
sources: z$
|
|
22036
|
-
name: z$
|
|
22037
|
-
index: z$
|
|
22031
|
+
rows: z$6.array(z$6.array(takoDatasetCellSchema())),
|
|
22032
|
+
total_rows: z$6.number(),
|
|
22033
|
+
truncated: z$6.boolean(),
|
|
22034
|
+
ref: z$6.string(),
|
|
22035
|
+
sources: z$6.array(z$6.object({
|
|
22036
|
+
name: z$6.string(),
|
|
22037
|
+
index: z$6.enum(["data", "web"]).optional()
|
|
22038
22038
|
})),
|
|
22039
|
-
provenance: z$
|
|
22039
|
+
provenance: z$6.enum(["query", "web_extraction"]).optional()
|
|
22040
22040
|
}).nullish(),
|
|
22041
|
-
card_data: z$
|
|
22042
|
-
card_data_schema: z$
|
|
22043
|
-
url: z$
|
|
22044
|
-
expires_at: z$
|
|
22045
|
-
total_rows: z$
|
|
22046
|
-
truncated: z$
|
|
22047
|
-
export_pricing: z$
|
|
22048
|
-
baseline_usd: z$
|
|
22049
|
-
free_rows: z$
|
|
22050
|
-
max_rows_ceiling: z$
|
|
22051
|
-
row_cpm_usd: z$
|
|
22041
|
+
card_data: z$6.object({}).passthrough().nullish(),
|
|
22042
|
+
card_data_schema: z$6.object({}).passthrough().nullish(),
|
|
22043
|
+
url: z$6.string().nullish(),
|
|
22044
|
+
expires_at: z$6.string().nullish(),
|
|
22045
|
+
total_rows: z$6.number().nullish(),
|
|
22046
|
+
truncated: z$6.boolean().optional(),
|
|
22047
|
+
export_pricing: z$6.object({
|
|
22048
|
+
baseline_usd: z$6.number(),
|
|
22049
|
+
free_rows: z$6.number(),
|
|
22050
|
+
max_rows_ceiling: z$6.number(),
|
|
22051
|
+
row_cpm_usd: z$6.number()
|
|
22052
22052
|
}).nullish(),
|
|
22053
|
-
manifest: z$
|
|
22054
|
-
dtype: z$
|
|
22053
|
+
manifest: z$6.array(z$6.object({
|
|
22054
|
+
dtype: z$6.enum([
|
|
22055
22055
|
"boolean",
|
|
22056
22056
|
"date",
|
|
22057
22057
|
"datetime",
|
|
22058
22058
|
"number",
|
|
22059
22059
|
"string"
|
|
22060
22060
|
]).nullish(),
|
|
22061
|
-
entity: z$
|
|
22062
|
-
metric: z$
|
|
22063
|
-
name: z$
|
|
22064
|
-
unit: z$
|
|
22061
|
+
entity: z$6.string().nullish(),
|
|
22062
|
+
metric: z$6.string().nullish(),
|
|
22063
|
+
name: z$6.string().nullish(),
|
|
22064
|
+
unit: z$6.string().nullish()
|
|
22065
22065
|
})).nullish()
|
|
22066
22066
|
}).passthrough();
|
|
22067
|
-
const takoCardSchema = () => z$
|
|
22068
|
-
card_id: z$
|
|
22069
|
-
title: z$
|
|
22070
|
-
description: z$
|
|
22071
|
-
semantic_description: z$
|
|
22072
|
-
webpage_url: z$
|
|
22073
|
-
image_url: z$
|
|
22074
|
-
embed_url: z$
|
|
22075
|
-
sources: z$
|
|
22076
|
-
source_name: z$
|
|
22077
|
-
source_description: z$
|
|
22078
|
-
source_index: z$
|
|
22079
|
-
source_text: z$
|
|
22080
|
-
url: z$
|
|
22067
|
+
const takoCardSchema = () => z$6.object({
|
|
22068
|
+
card_id: z$6.string().nullish(),
|
|
22069
|
+
title: z$6.string().nullish(),
|
|
22070
|
+
description: z$6.string().nullish(),
|
|
22071
|
+
semantic_description: z$6.string().nullish(),
|
|
22072
|
+
webpage_url: z$6.string().nullish(),
|
|
22073
|
+
image_url: z$6.string().nullish(),
|
|
22074
|
+
embed_url: z$6.string().nullish(),
|
|
22075
|
+
sources: z$6.array(z$6.object({
|
|
22076
|
+
source_name: z$6.string().nullish(),
|
|
22077
|
+
source_description: z$6.string().nullish(),
|
|
22078
|
+
source_index: z$6.enum(["data", "web"]),
|
|
22079
|
+
source_text: z$6.string().nullish(),
|
|
22080
|
+
url: z$6.string().nullish()
|
|
22081
22081
|
})).nullish(),
|
|
22082
|
-
methodologies: z$
|
|
22083
|
-
methodology_name: z$
|
|
22084
|
-
methodology_description: z$
|
|
22082
|
+
methodologies: z$6.array(z$6.object({
|
|
22083
|
+
methodology_name: z$6.string().nullable(),
|
|
22084
|
+
methodology_description: z$6.string().nullable()
|
|
22085
22085
|
})).nullish(),
|
|
22086
|
-
source_indexes: z$
|
|
22087
|
-
card_type: z$
|
|
22088
|
-
relevance: z$
|
|
22086
|
+
source_indexes: z$6.array(z$6.enum(["data", "web"])).nullish(),
|
|
22087
|
+
card_type: z$6.string().nullish(),
|
|
22088
|
+
relevance: z$6.enum([
|
|
22089
22089
|
"High",
|
|
22090
22090
|
"Low",
|
|
22091
22091
|
"Medium"
|
|
22092
22092
|
]).nullish(),
|
|
22093
22093
|
content: takoResultContentSchema().nullish(),
|
|
22094
|
-
exportable: z$
|
|
22095
|
-
nodes: z$
|
|
22096
|
-
id: z$
|
|
22097
|
-
type: z$
|
|
22098
|
-
name: z$
|
|
22099
|
-
description: z$
|
|
22094
|
+
exportable: z$6.boolean().optional(),
|
|
22095
|
+
nodes: z$6.array(z$6.object({
|
|
22096
|
+
id: z$6.string(),
|
|
22097
|
+
type: z$6.enum(["entity", "metric"]),
|
|
22098
|
+
name: z$6.string(),
|
|
22099
|
+
description: z$6.string().nullish()
|
|
22100
22100
|
})).nullish(),
|
|
22101
|
-
metric_definitions: z$
|
|
22102
|
-
name: z$
|
|
22103
|
-
definition: z$
|
|
22101
|
+
metric_definitions: z$6.array(z$6.object({
|
|
22102
|
+
name: z$6.string(),
|
|
22103
|
+
definition: z$6.string()
|
|
22104
22104
|
})).nullish(),
|
|
22105
|
-
data_freshness: z$
|
|
22106
|
-
coverage_end: z$
|
|
22107
|
-
data_as_of: z$
|
|
22108
|
-
last_updated: z$
|
|
22105
|
+
data_freshness: z$6.object({
|
|
22106
|
+
coverage_end: z$6.string().nullish(),
|
|
22107
|
+
data_as_of: z$6.string().nullish(),
|
|
22108
|
+
last_updated: z$6.string().nullish()
|
|
22109
22109
|
}).nullish()
|
|
22110
22110
|
}).passthrough();
|
|
22111
|
-
const takoWebResultSchema = () => z$
|
|
22112
|
-
title: z$
|
|
22113
|
-
url: z$
|
|
22114
|
-
snippet: z$
|
|
22115
|
-
source_name: z$
|
|
22116
|
-
publish_date: z$
|
|
22111
|
+
const takoWebResultSchema = () => z$6.object({
|
|
22112
|
+
title: z$6.string(),
|
|
22113
|
+
url: z$6.string(),
|
|
22114
|
+
snippet: z$6.string().nullish(),
|
|
22115
|
+
source_name: z$6.string().nullish(),
|
|
22116
|
+
publish_date: z$6.string().nullish(),
|
|
22117
22117
|
content: takoResultContentSchema().nullish()
|
|
22118
22118
|
}).passthrough();
|
|
22119
22119
|
const takoSearchToolFactory = createProviderExecutedToolFactory({
|
|
22120
22120
|
id: "gateway.tako_search",
|
|
22121
22121
|
inputSchema: takoSearchInputSchema,
|
|
22122
|
-
outputSchema: lazySchema(() => zodSchema(z$
|
|
22123
|
-
request_id: z$
|
|
22124
|
-
cards: z$
|
|
22125
|
-
web_results: z$
|
|
22126
|
-
usage: z$
|
|
22127
|
-
total_cost_usd: z$
|
|
22128
|
-
compute: z$
|
|
22129
|
-
data: z$
|
|
22130
|
-
cost_usd: z$
|
|
22131
|
-
datasets: z$
|
|
22122
|
+
outputSchema: lazySchema(() => zodSchema(z$6.union([z$6.object({
|
|
22123
|
+
request_id: z$6.string(),
|
|
22124
|
+
cards: z$6.array(takoCardSchema()).optional(),
|
|
22125
|
+
web_results: z$6.array(takoWebResultSchema()).optional(),
|
|
22126
|
+
usage: z$6.object({
|
|
22127
|
+
total_cost_usd: z$6.number(),
|
|
22128
|
+
compute: z$6.object({ cost_usd: z$6.number() }).nullish(),
|
|
22129
|
+
data: z$6.object({
|
|
22130
|
+
cost_usd: z$6.number(),
|
|
22131
|
+
datasets: z$6.number()
|
|
22132
22132
|
}).nullish()
|
|
22133
22133
|
}).nullish(),
|
|
22134
|
-
related: z$
|
|
22134
|
+
related: z$6.array(z$6.object({}).passthrough()).nullish()
|
|
22135
22135
|
}).passthrough(), gatewayToolErrorSchema()])))
|
|
22136
22136
|
});
|
|
22137
22137
|
const takoSearch = (config = {}) => takoSearchToolFactory(config);
|
|
@@ -22204,9 +22204,9 @@ async function getVercelRequestId() {
|
|
|
22204
22204
|
const VERSION$1 = "4.0.135";
|
|
22205
22205
|
const AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
22206
22206
|
/** Response shape of `POST /v1/realtime/client-secrets`. `expiresAt` is epoch seconds. */
|
|
22207
|
-
const gatewayClientSecretResponseSchema = lazySchema(() => zodSchema(z$
|
|
22208
|
-
token: z$
|
|
22209
|
-
expiresAt: z$
|
|
22207
|
+
const gatewayClientSecretResponseSchema = lazySchema(() => zodSchema(z$6.object({
|
|
22208
|
+
token: z$6.string(),
|
|
22209
|
+
expiresAt: z$6.number().nullish()
|
|
22210
22210
|
})));
|
|
22211
22211
|
/**
|
|
22212
22212
|
* Create a remote provider instance.
|
|
@@ -22266,7 +22266,7 @@ function createGateway(options = {}) {
|
|
|
22266
22266
|
},
|
|
22267
22267
|
successfulResponseHandler: createJsonResponseHandler(gatewayClientSecretResponseSchema),
|
|
22268
22268
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
22269
|
-
errorSchema: z$
|
|
22269
|
+
errorSchema: z$6.any(),
|
|
22270
22270
|
errorToMessage: (data) => getErrorMessage(data) ?? "unknown error"
|
|
22271
22271
|
}),
|
|
22272
22272
|
fetch: options.fetch
|
|
@@ -23403,7 +23403,7 @@ createIdGenerator({
|
|
|
23403
23403
|
size: 24
|
|
23404
23404
|
});
|
|
23405
23405
|
TransformStream;
|
|
23406
|
-
const z$
|
|
23406
|
+
const z$5 = {
|
|
23407
23407
|
array: zod_v4.array,
|
|
23408
23408
|
boolean: zod_v4.boolean,
|
|
23409
23409
|
custom: zod_v4.custom,
|
|
@@ -23422,37 +23422,37 @@ const z$4 = {
|
|
|
23422
23422
|
union: zod_v4.union,
|
|
23423
23423
|
unknown: zod_v4.unknown
|
|
23424
23424
|
};
|
|
23425
|
-
const jsonValueSchema = z$
|
|
23426
|
-
z$
|
|
23427
|
-
z$
|
|
23428
|
-
z$
|
|
23429
|
-
z$
|
|
23430
|
-
z$
|
|
23431
|
-
z$
|
|
23425
|
+
const jsonValueSchema = z$5.lazy(() => z$5.union([
|
|
23426
|
+
z$5.null(),
|
|
23427
|
+
z$5.string(),
|
|
23428
|
+
z$5.number(),
|
|
23429
|
+
z$5.boolean(),
|
|
23430
|
+
z$5.record(z$5.string(), jsonValueSchema.optional()),
|
|
23431
|
+
z$5.array(jsonValueSchema)
|
|
23432
23432
|
]));
|
|
23433
|
-
const providerMetadataSchema = z$
|
|
23434
|
-
z$
|
|
23435
|
-
source: z$
|
|
23436
|
-
type: z$
|
|
23437
|
-
sourceType: z$
|
|
23438
|
-
id: z$
|
|
23439
|
-
url: z$
|
|
23440
|
-
title: z$
|
|
23433
|
+
const providerMetadataSchema = z$5.record(z$5.string(), z$5.record(z$5.string(), jsonValueSchema.optional()));
|
|
23434
|
+
z$5.object({
|
|
23435
|
+
source: z$5.discriminatedUnion("sourceType", [z$5.object({
|
|
23436
|
+
type: z$5.literal("source"),
|
|
23437
|
+
sourceType: z$5.literal("url"),
|
|
23438
|
+
id: z$5.string(),
|
|
23439
|
+
url: z$5.string(),
|
|
23440
|
+
title: z$5.string().optional(),
|
|
23441
23441
|
providerMetadata: providerMetadataSchema.optional()
|
|
23442
|
-
}), z$
|
|
23443
|
-
type: z$
|
|
23444
|
-
sourceType: z$
|
|
23445
|
-
id: z$
|
|
23446
|
-
mediaType: z$
|
|
23447
|
-
title: z$
|
|
23448
|
-
filename: z$
|
|
23442
|
+
}), z$5.object({
|
|
23443
|
+
type: z$5.literal("source"),
|
|
23444
|
+
sourceType: z$5.literal("document"),
|
|
23445
|
+
id: z$5.string(),
|
|
23446
|
+
mediaType: z$5.string(),
|
|
23447
|
+
title: z$5.string(),
|
|
23448
|
+
filename: z$5.string().optional(),
|
|
23449
23449
|
providerMetadata: providerMetadataSchema.optional()
|
|
23450
23450
|
})]),
|
|
23451
|
-
startIndex: z$
|
|
23452
|
-
endIndex: z$
|
|
23453
|
-
citedText: z$
|
|
23451
|
+
startIndex: z$5.number().int().nonnegative().optional(),
|
|
23452
|
+
endIndex: z$5.number().int().nonnegative().optional(),
|
|
23453
|
+
citedText: z$5.string().optional()
|
|
23454
23454
|
});
|
|
23455
|
-
z$
|
|
23455
|
+
z$5.record(z$5.string(), jsonValueSchema.optional());
|
|
23456
23456
|
createIdGenerator({
|
|
23457
23457
|
prefix: "aitxt",
|
|
23458
23458
|
size: 24
|
|
@@ -23469,8 +23469,8 @@ createIdGenerator({
|
|
|
23469
23469
|
prefix: "call",
|
|
23470
23470
|
size: 24
|
|
23471
23471
|
});
|
|
23472
|
-
z$
|
|
23473
|
-
z$
|
|
23472
|
+
z$5.record(z$5.string(), jsonValueSchema.optional());
|
|
23473
|
+
z$5.record(z$5.string(), z$5.string());
|
|
23474
23474
|
/**
|
|
23475
23475
|
* Writes an enumerable own property without invoking inherited setters such as
|
|
23476
23476
|
* `Object.prototype.__proto__`. Keeps the target object's prototype unchanged.
|
|
@@ -23877,19 +23877,19 @@ createIdGenerator({
|
|
|
23877
23877
|
prefix: "call",
|
|
23878
23878
|
size: 24
|
|
23879
23879
|
});
|
|
23880
|
-
const fileInlineDataSchema = z$
|
|
23881
|
-
z$
|
|
23882
|
-
z$
|
|
23883
|
-
z$
|
|
23884
|
-
z$
|
|
23880
|
+
const fileInlineDataSchema = z$5.union([
|
|
23881
|
+
z$5.string(),
|
|
23882
|
+
z$5.custom(isUint8Array, { message: "Must be a Uint8Array" }),
|
|
23883
|
+
z$5.custom(isArrayBuffer, { message: "Must be an ArrayBuffer" }),
|
|
23884
|
+
z$5.custom(isBuffer, { message: "Must be a Buffer" })
|
|
23885
23885
|
]);
|
|
23886
|
-
const providerReferenceSchema = z$
|
|
23886
|
+
const providerReferenceSchema = z$5.record(z$5.string(), z$5.string());
|
|
23887
23887
|
/**
|
|
23888
23888
|
* @internal
|
|
23889
23889
|
*/
|
|
23890
|
-
const textPartSchema = z$
|
|
23891
|
-
type: z$
|
|
23892
|
-
text: z$
|
|
23890
|
+
const textPartSchema = z$5.object({
|
|
23891
|
+
type: z$5.literal("text"),
|
|
23892
|
+
text: z$5.string(),
|
|
23893
23893
|
providerOptions: providerMetadataSchema.optional()
|
|
23894
23894
|
});
|
|
23895
23895
|
/**
|
|
@@ -23897,186 +23897,186 @@ const textPartSchema = z$4.object({
|
|
|
23897
23897
|
* @deprecated Use `filePartSchema` with `mediaType: 'image'` instead:
|
|
23898
23898
|
* `{ type: 'file', mediaType: 'image', data: { type: 'data', data } }`.
|
|
23899
23899
|
*/
|
|
23900
|
-
const imagePartSchema = z$
|
|
23901
|
-
type: z$
|
|
23902
|
-
image: z$
|
|
23900
|
+
const imagePartSchema = z$5.object({
|
|
23901
|
+
type: z$5.literal("image"),
|
|
23902
|
+
image: z$5.union([
|
|
23903
23903
|
fileInlineDataSchema,
|
|
23904
|
-
z$
|
|
23904
|
+
z$5.instanceof(URL),
|
|
23905
23905
|
providerReferenceSchema
|
|
23906
23906
|
]),
|
|
23907
|
-
mediaType: z$
|
|
23907
|
+
mediaType: z$5.string().optional(),
|
|
23908
23908
|
providerOptions: providerMetadataSchema.optional()
|
|
23909
23909
|
});
|
|
23910
|
-
const taggedFileDataSchema = z$
|
|
23911
|
-
z$
|
|
23912
|
-
type: z$
|
|
23910
|
+
const taggedFileDataSchema = z$5.discriminatedUnion("type", [
|
|
23911
|
+
z$5.object({
|
|
23912
|
+
type: z$5.literal("data"),
|
|
23913
23913
|
data: fileInlineDataSchema
|
|
23914
23914
|
}),
|
|
23915
|
-
z$
|
|
23916
|
-
type: z$
|
|
23917
|
-
url: z$
|
|
23915
|
+
z$5.object({
|
|
23916
|
+
type: z$5.literal("url"),
|
|
23917
|
+
url: z$5.instanceof(URL)
|
|
23918
23918
|
}),
|
|
23919
|
-
z$
|
|
23920
|
-
type: z$
|
|
23919
|
+
z$5.object({
|
|
23920
|
+
type: z$5.literal("reference"),
|
|
23921
23921
|
reference: providerReferenceSchema
|
|
23922
23922
|
}),
|
|
23923
|
-
z$
|
|
23924
|
-
type: z$
|
|
23925
|
-
text: z$
|
|
23923
|
+
z$5.object({
|
|
23924
|
+
type: z$5.literal("text"),
|
|
23925
|
+
text: z$5.string()
|
|
23926
23926
|
})
|
|
23927
23927
|
]);
|
|
23928
|
-
const taggedReasoningFileDataSchema = z$
|
|
23929
|
-
type: z$
|
|
23928
|
+
const taggedReasoningFileDataSchema = z$5.discriminatedUnion("type", [z$5.object({
|
|
23929
|
+
type: z$5.literal("data"),
|
|
23930
23930
|
data: fileInlineDataSchema
|
|
23931
|
-
}), z$
|
|
23932
|
-
type: z$
|
|
23933
|
-
url: z$
|
|
23931
|
+
}), z$5.object({
|
|
23932
|
+
type: z$5.literal("url"),
|
|
23933
|
+
url: z$5.instanceof(URL)
|
|
23934
23934
|
})]);
|
|
23935
23935
|
/**
|
|
23936
23936
|
* @internal
|
|
23937
23937
|
*/
|
|
23938
|
-
const filePartSchema = z$
|
|
23939
|
-
type: z$
|
|
23940
|
-
data: z$
|
|
23938
|
+
const filePartSchema = z$5.object({
|
|
23939
|
+
type: z$5.literal("file"),
|
|
23940
|
+
data: z$5.union([
|
|
23941
23941
|
taggedFileDataSchema,
|
|
23942
23942
|
fileInlineDataSchema,
|
|
23943
|
-
z$
|
|
23943
|
+
z$5.instanceof(URL),
|
|
23944
23944
|
providerReferenceSchema
|
|
23945
23945
|
]),
|
|
23946
|
-
filename: z$
|
|
23947
|
-
mediaType: z$
|
|
23946
|
+
filename: z$5.string().optional(),
|
|
23947
|
+
mediaType: z$5.string(),
|
|
23948
23948
|
providerOptions: providerMetadataSchema.optional()
|
|
23949
23949
|
});
|
|
23950
23950
|
/**
|
|
23951
23951
|
* @internal
|
|
23952
23952
|
*/
|
|
23953
|
-
const reasoningPartSchema = z$
|
|
23954
|
-
type: z$
|
|
23955
|
-
text: z$
|
|
23953
|
+
const reasoningPartSchema = z$5.object({
|
|
23954
|
+
type: z$5.literal("reasoning"),
|
|
23955
|
+
text: z$5.string(),
|
|
23956
23956
|
providerOptions: providerMetadataSchema.optional()
|
|
23957
23957
|
});
|
|
23958
23958
|
/**
|
|
23959
23959
|
* @internal
|
|
23960
23960
|
*/
|
|
23961
|
-
const customPartSchema = z$
|
|
23962
|
-
type: z$
|
|
23963
|
-
kind: z$
|
|
23961
|
+
const customPartSchema = z$5.object({
|
|
23962
|
+
type: z$5.literal("custom"),
|
|
23963
|
+
kind: z$5.string().transform((value) => value),
|
|
23964
23964
|
providerOptions: providerMetadataSchema.optional()
|
|
23965
23965
|
});
|
|
23966
23966
|
/**
|
|
23967
23967
|
* @internal
|
|
23968
23968
|
*/
|
|
23969
|
-
const reasoningFilePartSchema = z$
|
|
23970
|
-
type: z$
|
|
23971
|
-
data: z$
|
|
23969
|
+
const reasoningFilePartSchema = z$5.object({
|
|
23970
|
+
type: z$5.literal("reasoning-file"),
|
|
23971
|
+
data: z$5.union([
|
|
23972
23972
|
taggedReasoningFileDataSchema,
|
|
23973
23973
|
fileInlineDataSchema,
|
|
23974
|
-
z$
|
|
23974
|
+
z$5.instanceof(URL)
|
|
23975
23975
|
]),
|
|
23976
|
-
mediaType: z$
|
|
23976
|
+
mediaType: z$5.string(),
|
|
23977
23977
|
providerOptions: providerMetadataSchema.optional()
|
|
23978
23978
|
});
|
|
23979
23979
|
/**
|
|
23980
23980
|
* @internal
|
|
23981
23981
|
*/
|
|
23982
|
-
const toolCallPartSchema = z$
|
|
23983
|
-
type: z$
|
|
23984
|
-
toolCallId: z$
|
|
23985
|
-
toolName: z$
|
|
23986
|
-
input: z$
|
|
23982
|
+
const toolCallPartSchema = z$5.object({
|
|
23983
|
+
type: z$5.literal("tool-call"),
|
|
23984
|
+
toolCallId: z$5.string(),
|
|
23985
|
+
toolName: z$5.string(),
|
|
23986
|
+
input: z$5.unknown(),
|
|
23987
23987
|
providerOptions: providerMetadataSchema.optional(),
|
|
23988
|
-
providerExecuted: z$
|
|
23988
|
+
providerExecuted: z$5.boolean().optional()
|
|
23989
23989
|
});
|
|
23990
23990
|
/**
|
|
23991
23991
|
* @internal
|
|
23992
23992
|
*/
|
|
23993
|
-
const outputSchema = z$
|
|
23994
|
-
z$
|
|
23995
|
-
type: z$
|
|
23996
|
-
value: z$
|
|
23993
|
+
const outputSchema = z$5.discriminatedUnion("type", [
|
|
23994
|
+
z$5.object({
|
|
23995
|
+
type: z$5.literal("text"),
|
|
23996
|
+
value: z$5.string(),
|
|
23997
23997
|
providerOptions: providerMetadataSchema.optional()
|
|
23998
23998
|
}),
|
|
23999
|
-
z$
|
|
24000
|
-
type: z$
|
|
23999
|
+
z$5.object({
|
|
24000
|
+
type: z$5.literal("json"),
|
|
24001
24001
|
value: jsonValueSchema,
|
|
24002
24002
|
providerOptions: providerMetadataSchema.optional()
|
|
24003
24003
|
}),
|
|
24004
|
-
z$
|
|
24005
|
-
type: z$
|
|
24006
|
-
reason: z$
|
|
24004
|
+
z$5.object({
|
|
24005
|
+
type: z$5.literal("execution-denied"),
|
|
24006
|
+
reason: z$5.string().optional(),
|
|
24007
24007
|
providerOptions: providerMetadataSchema.optional()
|
|
24008
24008
|
}),
|
|
24009
|
-
z$
|
|
24010
|
-
type: z$
|
|
24011
|
-
value: z$
|
|
24009
|
+
z$5.object({
|
|
24010
|
+
type: z$5.literal("error-text"),
|
|
24011
|
+
value: z$5.string(),
|
|
24012
24012
|
providerOptions: providerMetadataSchema.optional()
|
|
24013
24013
|
}),
|
|
24014
|
-
z$
|
|
24015
|
-
type: z$
|
|
24014
|
+
z$5.object({
|
|
24015
|
+
type: z$5.literal("error-json"),
|
|
24016
24016
|
value: jsonValueSchema,
|
|
24017
24017
|
providerOptions: providerMetadataSchema.optional()
|
|
24018
24018
|
}),
|
|
24019
|
-
z$
|
|
24020
|
-
type: z$
|
|
24021
|
-
value: z$
|
|
24022
|
-
z$
|
|
24023
|
-
type: z$
|
|
24024
|
-
text: z$
|
|
24019
|
+
z$5.object({
|
|
24020
|
+
type: z$5.literal("content"),
|
|
24021
|
+
value: z$5.array(z$5.union([
|
|
24022
|
+
z$5.object({
|
|
24023
|
+
type: z$5.literal("text"),
|
|
24024
|
+
text: z$5.string(),
|
|
24025
24025
|
providerOptions: providerMetadataSchema.optional()
|
|
24026
24026
|
}),
|
|
24027
|
-
z$
|
|
24028
|
-
type: z$
|
|
24027
|
+
z$5.object({
|
|
24028
|
+
type: z$5.literal("file"),
|
|
24029
24029
|
data: taggedFileDataSchema,
|
|
24030
|
-
mediaType: z$
|
|
24031
|
-
filename: z$
|
|
24030
|
+
mediaType: z$5.string(),
|
|
24031
|
+
filename: z$5.string().optional(),
|
|
24032
24032
|
providerOptions: providerMetadataSchema.optional()
|
|
24033
24033
|
}),
|
|
24034
|
-
z$
|
|
24035
|
-
type: z$
|
|
24036
|
-
data: z$
|
|
24037
|
-
mediaType: z$
|
|
24038
|
-
filename: z$
|
|
24034
|
+
z$5.object({
|
|
24035
|
+
type: z$5.literal("file-data"),
|
|
24036
|
+
data: z$5.string(),
|
|
24037
|
+
mediaType: z$5.string(),
|
|
24038
|
+
filename: z$5.string().optional(),
|
|
24039
24039
|
providerOptions: providerMetadataSchema.optional()
|
|
24040
24040
|
}),
|
|
24041
|
-
z$
|
|
24042
|
-
type: z$
|
|
24043
|
-
url: z$
|
|
24044
|
-
mediaType: z$
|
|
24041
|
+
z$5.object({
|
|
24042
|
+
type: z$5.literal("file-url"),
|
|
24043
|
+
url: z$5.string(),
|
|
24044
|
+
mediaType: z$5.string().optional(),
|
|
24045
24045
|
providerOptions: providerMetadataSchema.optional()
|
|
24046
24046
|
}),
|
|
24047
|
-
z$
|
|
24048
|
-
type: z$
|
|
24049
|
-
fileId: z$
|
|
24047
|
+
z$5.object({
|
|
24048
|
+
type: z$5.literal("file-id"),
|
|
24049
|
+
fileId: z$5.union([z$5.string(), z$5.record(z$5.string(), z$5.string())]),
|
|
24050
24050
|
providerOptions: providerMetadataSchema.optional()
|
|
24051
24051
|
}),
|
|
24052
|
-
z$
|
|
24053
|
-
type: z$
|
|
24054
|
-
providerReference: z$
|
|
24052
|
+
z$5.object({
|
|
24053
|
+
type: z$5.literal("file-reference"),
|
|
24054
|
+
providerReference: z$5.record(z$5.string(), z$5.string()),
|
|
24055
24055
|
providerOptions: providerMetadataSchema.optional()
|
|
24056
24056
|
}),
|
|
24057
|
-
z$
|
|
24058
|
-
type: z$
|
|
24059
|
-
data: z$
|
|
24060
|
-
mediaType: z$
|
|
24057
|
+
z$5.object({
|
|
24058
|
+
type: z$5.literal("image-data"),
|
|
24059
|
+
data: z$5.string(),
|
|
24060
|
+
mediaType: z$5.string(),
|
|
24061
24061
|
providerOptions: providerMetadataSchema.optional()
|
|
24062
24062
|
}),
|
|
24063
|
-
z$
|
|
24064
|
-
type: z$
|
|
24065
|
-
url: z$
|
|
24063
|
+
z$5.object({
|
|
24064
|
+
type: z$5.literal("image-url"),
|
|
24065
|
+
url: z$5.string(),
|
|
24066
24066
|
providerOptions: providerMetadataSchema.optional()
|
|
24067
24067
|
}),
|
|
24068
|
-
z$
|
|
24069
|
-
type: z$
|
|
24070
|
-
fileId: z$
|
|
24068
|
+
z$5.object({
|
|
24069
|
+
type: z$5.literal("image-file-id"),
|
|
24070
|
+
fileId: z$5.union([z$5.string(), z$5.record(z$5.string(), z$5.string())]),
|
|
24071
24071
|
providerOptions: providerMetadataSchema.optional()
|
|
24072
24072
|
}),
|
|
24073
|
-
z$
|
|
24074
|
-
type: z$
|
|
24075
|
-
providerReference: z$
|
|
24073
|
+
z$5.object({
|
|
24074
|
+
type: z$5.literal("image-file-reference"),
|
|
24075
|
+
providerReference: z$5.record(z$5.string(), z$5.string()),
|
|
24076
24076
|
providerOptions: providerMetadataSchema.optional()
|
|
24077
24077
|
}),
|
|
24078
|
-
z$
|
|
24079
|
-
type: z$
|
|
24078
|
+
z$5.object({
|
|
24079
|
+
type: z$5.literal("custom"),
|
|
24080
24080
|
providerOptions: providerMetadataSchema.optional()
|
|
24081
24081
|
})
|
|
24082
24082
|
]))
|
|
@@ -24085,51 +24085,51 @@ const outputSchema = z$4.discriminatedUnion("type", [
|
|
|
24085
24085
|
/**
|
|
24086
24086
|
* @internal
|
|
24087
24087
|
*/
|
|
24088
|
-
const toolResultPartSchema = z$
|
|
24089
|
-
type: z$
|
|
24090
|
-
toolCallId: z$
|
|
24091
|
-
toolName: z$
|
|
24088
|
+
const toolResultPartSchema = z$5.object({
|
|
24089
|
+
type: z$5.literal("tool-result"),
|
|
24090
|
+
toolCallId: z$5.string(),
|
|
24091
|
+
toolName: z$5.string(),
|
|
24092
24092
|
output: outputSchema,
|
|
24093
24093
|
providerOptions: providerMetadataSchema.optional()
|
|
24094
24094
|
});
|
|
24095
24095
|
/**
|
|
24096
24096
|
* @internal
|
|
24097
24097
|
*/
|
|
24098
|
-
const toolApprovalRequestSchema = z$
|
|
24099
|
-
type: z$
|
|
24100
|
-
approvalId: z$
|
|
24101
|
-
toolCallId: z$
|
|
24102
|
-
reason: z$
|
|
24103
|
-
isAutomatic: z$
|
|
24104
|
-
signature: z$
|
|
24105
|
-
inputSchemaInput: z$
|
|
24098
|
+
const toolApprovalRequestSchema = z$5.object({
|
|
24099
|
+
type: z$5.literal("tool-approval-request"),
|
|
24100
|
+
approvalId: z$5.string(),
|
|
24101
|
+
toolCallId: z$5.string(),
|
|
24102
|
+
reason: z$5.string().optional(),
|
|
24103
|
+
isAutomatic: z$5.boolean().optional(),
|
|
24104
|
+
signature: z$5.string().optional(),
|
|
24105
|
+
inputSchemaInput: z$5.unknown().optional()
|
|
24106
24106
|
});
|
|
24107
24107
|
/**
|
|
24108
24108
|
* @internal
|
|
24109
24109
|
*/
|
|
24110
|
-
const toolApprovalResponseSchema = z$
|
|
24111
|
-
type: z$
|
|
24112
|
-
approvalId: z$
|
|
24113
|
-
approved: z$
|
|
24114
|
-
reason: z$
|
|
24110
|
+
const toolApprovalResponseSchema = z$5.object({
|
|
24111
|
+
type: z$5.literal("tool-approval-response"),
|
|
24112
|
+
approvalId: z$5.string(),
|
|
24113
|
+
approved: z$5.boolean(),
|
|
24114
|
+
reason: z$5.string().optional()
|
|
24115
24115
|
});
|
|
24116
|
-
const systemModelMessageSchema = z$
|
|
24117
|
-
role: z$
|
|
24118
|
-
content: z$
|
|
24116
|
+
const systemModelMessageSchema = z$5.object({
|
|
24117
|
+
role: z$5.literal("system"),
|
|
24118
|
+
content: z$5.string(),
|
|
24119
24119
|
providerOptions: providerMetadataSchema.optional()
|
|
24120
24120
|
});
|
|
24121
|
-
const userModelMessageSchema = z$
|
|
24122
|
-
role: z$
|
|
24123
|
-
content: z$
|
|
24121
|
+
const userModelMessageSchema = z$5.object({
|
|
24122
|
+
role: z$5.literal("user"),
|
|
24123
|
+
content: z$5.union([z$5.string(), z$5.array(z$5.union([
|
|
24124
24124
|
textPartSchema,
|
|
24125
24125
|
imagePartSchema,
|
|
24126
24126
|
filePartSchema
|
|
24127
24127
|
]))]),
|
|
24128
24128
|
providerOptions: providerMetadataSchema.optional()
|
|
24129
24129
|
});
|
|
24130
|
-
const assistantModelMessageSchema = z$
|
|
24131
|
-
role: z$
|
|
24132
|
-
content: z$
|
|
24130
|
+
const assistantModelMessageSchema = z$5.object({
|
|
24131
|
+
role: z$5.literal("assistant"),
|
|
24132
|
+
content: z$5.union([z$5.string(), z$5.array(z$5.union([
|
|
24133
24133
|
textPartSchema,
|
|
24134
24134
|
customPartSchema,
|
|
24135
24135
|
filePartSchema,
|
|
@@ -24141,20 +24141,20 @@ const assistantModelMessageSchema = z$4.object({
|
|
|
24141
24141
|
]))]),
|
|
24142
24142
|
providerOptions: providerMetadataSchema.optional()
|
|
24143
24143
|
});
|
|
24144
|
-
const toolModelMessageSchema = z$
|
|
24145
|
-
role: z$
|
|
24146
|
-
content: z$
|
|
24144
|
+
const toolModelMessageSchema = z$5.object({
|
|
24145
|
+
role: z$5.literal("tool"),
|
|
24146
|
+
content: z$5.array(z$5.union([toolResultPartSchema, toolApprovalResponseSchema])),
|
|
24147
24147
|
providerOptions: providerMetadataSchema.optional()
|
|
24148
24148
|
});
|
|
24149
|
-
z$
|
|
24149
|
+
z$5.union([
|
|
24150
24150
|
systemModelMessageSchema,
|
|
24151
24151
|
userModelMessageSchema,
|
|
24152
24152
|
assistantModelMessageSchema,
|
|
24153
24153
|
toolModelMessageSchema
|
|
24154
24154
|
]);
|
|
24155
|
-
z$
|
|
24156
|
-
token: z$
|
|
24157
|
-
url: z$
|
|
24155
|
+
z$5.object({
|
|
24156
|
+
token: z$5.string().refine((value) => value.trim().length > 0),
|
|
24157
|
+
url: z$5.string().refine((value) => {
|
|
24158
24158
|
try {
|
|
24159
24159
|
const url = new URL(value);
|
|
24160
24160
|
return (url.protocol === "ws:" || url.protocol === "wss:") && url.hostname !== "";
|
|
@@ -24162,12 +24162,12 @@ z$4.object({
|
|
|
24162
24162
|
return false;
|
|
24163
24163
|
}
|
|
24164
24164
|
}),
|
|
24165
|
-
expiresAt: z$
|
|
24166
|
-
tools: z$
|
|
24167
|
-
type: z$
|
|
24168
|
-
name: z$
|
|
24169
|
-
description: z$
|
|
24170
|
-
parameters: z$
|
|
24165
|
+
expiresAt: z$5.number().positive().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
24166
|
+
tools: z$5.array(z$5.object({
|
|
24167
|
+
type: z$5.literal("function"),
|
|
24168
|
+
name: z$5.string().min(1),
|
|
24169
|
+
description: z$5.string().optional(),
|
|
24170
|
+
parameters: z$5.record(z$5.string(), z$5.unknown())
|
|
24171
24171
|
})).optional()
|
|
24172
24172
|
});
|
|
24173
24173
|
createIdGenerator({
|
|
@@ -30381,6 +30381,65 @@ var WorkingMemoryExtractor = class extends Extractor {
|
|
|
30381
30381
|
}, false, true);
|
|
30382
30382
|
}
|
|
30383
30383
|
};
|
|
30384
|
+
// src/processors/working-memory-instruction-compat.ts
|
|
30385
|
+
/**
|
|
30386
|
+
* Stand-in for core's `WorkingMemory` input processor on `@mastra/core` versions whose processor renders its own
|
|
30387
|
+
* built-in instruction text and has no instruction provider (every core before `getWorkingMemoryInstruction`
|
|
30388
|
+
* was added to `MastraMemory`, including 1.86.0-alpha.1 through 1.86.0-alpha.5). `Memory.getInputProcessors()`
|
|
30389
|
+
* swaps it in for the auto-created processor on those cores, so `Memory` subclass instruction overrides reach
|
|
30390
|
+
* the model there too (#29752).
|
|
30391
|
+
*
|
|
30392
|
+
* Loading and caching match core's `WorkingMemory.processInput` exactly; only the instruction comes from the
|
|
30393
|
+
* memory instance. Keep it in sync with packages/core/src/processors/memory/working-memory.ts.
|
|
30394
|
+
*/
|
|
30395
|
+
var WorkingMemoryInstructionCompat = class {
|
|
30396
|
+
options;
|
|
30397
|
+
id = "working-memory";
|
|
30398
|
+
name = "WorkingMemory";
|
|
30399
|
+
constructor(options) {
|
|
30400
|
+
this.options = options;
|
|
30401
|
+
}
|
|
30402
|
+
async processInput(args) {
|
|
30403
|
+
const { messageList, requestContext } = args;
|
|
30404
|
+
const memoryContext = (0, _mastra_core_memory.parseMemoryRequestContext)(requestContext);
|
|
30405
|
+
const threadId = memoryContext?.thread?.id;
|
|
30406
|
+
const resourceId = memoryContext?.resourceId;
|
|
30407
|
+
if (!memoryContext || !threadId && !resourceId) return messageList;
|
|
30408
|
+
const scope = this.options.scope || "resource";
|
|
30409
|
+
const memoryRunState = memoryContext.runState?.();
|
|
30410
|
+
let workingMemoryData = null;
|
|
30411
|
+
if (scope === "thread" && threadId) {
|
|
30412
|
+
const stored = (memoryRunState?.thread ?? await this.options.storage.getThreadById({ threadId }))?.metadata?.workingMemory;
|
|
30413
|
+
workingMemoryData = typeof stored === "string" && stored ? stored : null;
|
|
30414
|
+
} else if (scope === "resource" && resourceId) {
|
|
30415
|
+
const loadWorkingMemory = async () => {
|
|
30416
|
+
const resource = await this.options.storage.getResourceById({ resourceId });
|
|
30417
|
+
return typeof resource?.workingMemory === "string" && resource.workingMemory ? resource.workingMemory : null;
|
|
30418
|
+
};
|
|
30419
|
+
workingMemoryData = memoryRunState ? await memoryRunState.load(`working-memory:resource:${resourceId}`, loadWorkingMemory) : await loadWorkingMemory();
|
|
30420
|
+
}
|
|
30421
|
+
const loadTemplate = () => this.options.getWorkingMemoryTemplate({ memoryConfig: memoryContext.memoryConfig });
|
|
30422
|
+
const template = (memoryRunState ? await memoryRunState.load("working-memory:template", loadTemplate) : await loadTemplate()) || this.options.template || {
|
|
30423
|
+
format: "markdown",
|
|
30424
|
+
content: this.options.defaultTemplate
|
|
30425
|
+
};
|
|
30426
|
+
const workingMemoryConfig = memoryContext.memoryConfig?.workingMemory;
|
|
30427
|
+
const isConfiguredReadOnly = Boolean(this.options.readOnly || memoryContext.memoryConfig?.readOnly);
|
|
30428
|
+
const isAppManaged = this.options.agentManaged === false || typeof workingMemoryConfig === "object" && workingMemoryConfig.agentManaged === false;
|
|
30429
|
+
const instruction = this.options.renderInstruction(isConfiguredReadOnly || isAppManaged ? {
|
|
30430
|
+
kind: "read-only",
|
|
30431
|
+
template,
|
|
30432
|
+
data: workingMemoryData,
|
|
30433
|
+
autoUpdated: !isConfiguredReadOnly
|
|
30434
|
+
} : {
|
|
30435
|
+
kind: this.options.useVNext ? "vnext" : "tool",
|
|
30436
|
+
template,
|
|
30437
|
+
data: workingMemoryData
|
|
30438
|
+
});
|
|
30439
|
+
if (instruction) messageList.addSystem(instruction, "memory");
|
|
30440
|
+
return messageList;
|
|
30441
|
+
}
|
|
30442
|
+
};
|
|
30384
30443
|
// src/removed-subconscious.ts
|
|
30385
30444
|
/**
|
|
30386
30445
|
* Subconscious was removed. These stubs keep code written against older `@mastra/memory`
|
|
@@ -30514,13 +30573,57 @@ function getUnobservedPartsPreservingToolCallPairs(message) {
|
|
|
30514
30573
|
if (id) unobservedResultIds.add(id);
|
|
30515
30574
|
}
|
|
30516
30575
|
if (unobservedResultIds.size === 0) return unobservedParts;
|
|
30517
|
-
const
|
|
30576
|
+
const preserved = [];
|
|
30577
|
+
let pendingReasoning = [];
|
|
30578
|
+
let toolSinceReasoning = false;
|
|
30579
|
+
let keptAnything = false;
|
|
30580
|
+
for (let i = 0; i < endMarkerIndex; i++) {
|
|
30581
|
+
const part = parts[i];
|
|
30518
30582
|
const id = getToolInvocationId(part, "call");
|
|
30519
|
-
|
|
30520
|
-
|
|
30521
|
-
|
|
30583
|
+
if (id !== void 0 && unobservedResultIds.has(id)) {
|
|
30584
|
+
for (const index of pendingReasoning) preserved.push(parts[index]);
|
|
30585
|
+
pendingReasoning = [];
|
|
30586
|
+
toolSinceReasoning = true;
|
|
30587
|
+
preserved.push(part);
|
|
30588
|
+
keptAnything = true;
|
|
30589
|
+
continue;
|
|
30590
|
+
}
|
|
30591
|
+
if (part?.type === "reasoning" && hasReplayableReasoningMetadata(part)) {
|
|
30592
|
+
if (toolSinceReasoning) pendingReasoning = [];
|
|
30593
|
+
toolSinceReasoning = false;
|
|
30594
|
+
pendingReasoning.push(i);
|
|
30595
|
+
continue;
|
|
30596
|
+
}
|
|
30597
|
+
if (part?.type === "tool-invocation") {
|
|
30598
|
+
toolSinceReasoning = true;
|
|
30599
|
+
continue;
|
|
30600
|
+
}
|
|
30601
|
+
if (part?.type === "step-start") {
|
|
30602
|
+
if (toolSinceReasoning) pendingReasoning = [];
|
|
30603
|
+
continue;
|
|
30604
|
+
}
|
|
30605
|
+
if (part?.type === "text") continue;
|
|
30606
|
+
pendingReasoning = [];
|
|
30607
|
+
}
|
|
30608
|
+
return keptAnything ? [...preserved, ...unobservedParts] : unobservedParts;
|
|
30522
30609
|
}
|
|
30523
30610
|
/**
|
|
30611
|
+
* Reasoning part metadata a provider can replay (a signature, redacted payload, item id).
|
|
30612
|
+
* Mirrors `hasReplayableReasoningMetadata` in `@mastra/core`'s message-list utils.
|
|
30613
|
+
*/
|
|
30614
|
+
function hasReplayableReasoningMetadata(part) {
|
|
30615
|
+
const metadata = part.providerMetadata;
|
|
30616
|
+
if (!metadata || typeof metadata !== "object") return false;
|
|
30617
|
+
return Object.values(metadata).some((value) => !!value && typeof value === "object" && REPLAYABLE_REASONING_KEYS.some((key) => key in value));
|
|
30618
|
+
}
|
|
30619
|
+
const REPLAYABLE_REASONING_KEYS = [
|
|
30620
|
+
"signature",
|
|
30621
|
+
"redactedData",
|
|
30622
|
+
"itemId",
|
|
30623
|
+
"reasoningEncryptedContent",
|
|
30624
|
+
"thoughtSignature"
|
|
30625
|
+
];
|
|
30626
|
+
/**
|
|
30524
30627
|
* Get the messages Observational Memory is allowed to work with.
|
|
30525
30628
|
*
|
|
30526
30629
|
* Messages supplied through the `context` option and the synthetic `om-continuation`
|
|
@@ -32945,6 +33048,79 @@ var BufferingCoordinator = class BufferingCoordinator {
|
|
|
32945
33048
|
* Key format: "refl:{lockKey}"
|
|
32946
33049
|
*/
|
|
32947
33050
|
static reflectionBufferCycleIds = /* @__PURE__ */ new Map();
|
|
33051
|
+
/**
|
|
33052
|
+
* The buffered-reflection op that set the reflection boundary and cycle, and the generation
|
|
33053
|
+
* it buffers for. Key format: "refl:{lockKey}"
|
|
33054
|
+
*/
|
|
33055
|
+
static reflectionBufferOwners = /* @__PURE__ */ new Map();
|
|
33056
|
+
/** Set the reflection boundary for a new buffered-reflection op on generation `recordId`. */
|
|
33057
|
+
static startReflectionBuffer(bufferKey, tokens, recordId) {
|
|
33058
|
+
const owner = {
|
|
33059
|
+
recordId,
|
|
33060
|
+
retired: false
|
|
33061
|
+
};
|
|
33062
|
+
BufferingCoordinator.lastBufferedBoundary.set(bufferKey, tokens);
|
|
33063
|
+
BufferingCoordinator.reflectionBufferOwners.set(bufferKey, owner);
|
|
33064
|
+
return owner;
|
|
33065
|
+
}
|
|
33066
|
+
/** Drop this process's reflection boundary, cycle, and owner. */
|
|
33067
|
+
static clearReflectionBuffer(bufferKey) {
|
|
33068
|
+
BufferingCoordinator.lastBufferedBoundary.delete(bufferKey);
|
|
33069
|
+
BufferingCoordinator.reflectionBufferCycleIds.delete(bufferKey);
|
|
33070
|
+
BufferingCoordinator.reflectionBufferOwners.delete(bufferKey);
|
|
33071
|
+
}
|
|
33072
|
+
/**
|
|
33073
|
+
* Another writer retired generation `recordId`, so a buffer this process prepared for it can
|
|
33074
|
+
* never activate. Its boundary and cycle are dropped now, or, while the op that set them is
|
|
33075
|
+
* still running (it may be awaiting its `onReflectionEnd` hook), when that op finishes. State
|
|
33076
|
+
* owned by a newer generation is kept.
|
|
33077
|
+
*/
|
|
33078
|
+
static retireReflectionBuffer(bufferKey, recordId) {
|
|
33079
|
+
const owner = BufferingCoordinator.reflectionBufferOwners.get(bufferKey);
|
|
33080
|
+
if (owner && owner.recordId !== recordId) return;
|
|
33081
|
+
if (owner && BufferingCoordinator.asyncBufferingOps.has(bufferKey)) {
|
|
33082
|
+
owner.retired = true;
|
|
33083
|
+
return;
|
|
33084
|
+
}
|
|
33085
|
+
BufferingCoordinator.clearReflectionBuffer(bufferKey);
|
|
33086
|
+
}
|
|
33087
|
+
/**
|
|
33088
|
+
* Reconcile this process's reflection buffer state against an observed head record.
|
|
33089
|
+
* Whenever `head.id` differs from `owner.recordId`, confirm against a fresh storage read started
|
|
33090
|
+
* after `owner` existed (never trusting `generationCount`, which resets to 0 after `clear()`):
|
|
33091
|
+
* only retire/clear when storage's live head is no longer `owner.recordId`.
|
|
33092
|
+
*/
|
|
33093
|
+
static async reconcileReflectionBufferHead(bufferKey, headId, readLiveHead) {
|
|
33094
|
+
const owner = BufferingCoordinator.reflectionBufferOwners.get(bufferKey);
|
|
33095
|
+
if (!owner || owner.recordId === headId) return;
|
|
33096
|
+
const ownerRecordId = owner.recordId;
|
|
33097
|
+
const live = await readLiveHead();
|
|
33098
|
+
if (BufferingCoordinator.reflectionBufferOwners.get(bufferKey) !== owner || owner.recordId !== ownerRecordId) return;
|
|
33099
|
+
if (live?.id === ownerRecordId) return;
|
|
33100
|
+
if (BufferingCoordinator.asyncBufferingOps.has(bufferKey)) {
|
|
33101
|
+
owner.retired = true;
|
|
33102
|
+
return;
|
|
33103
|
+
}
|
|
33104
|
+
BufferingCoordinator.clearReflectionBuffer(bufferKey);
|
|
33105
|
+
}
|
|
33106
|
+
/**
|
|
33107
|
+
* Take the buffered-reflection cycle id for generation `recordId` and release its
|
|
33108
|
+
* coordinator state after its buffer activates. State owned by another generation
|
|
33109
|
+
* is left untouched.
|
|
33110
|
+
*/
|
|
33111
|
+
static consumeReflectionBuffer(bufferKey, recordId) {
|
|
33112
|
+
const owner = BufferingCoordinator.reflectionBufferOwners.get(bufferKey);
|
|
33113
|
+
if (owner && owner.recordId !== recordId) return void 0;
|
|
33114
|
+
const cycleId = BufferingCoordinator.reflectionBufferCycleIds.get(bufferKey);
|
|
33115
|
+
if (owner && BufferingCoordinator.asyncBufferingOps.has(bufferKey)) owner.retired = true;
|
|
33116
|
+
else BufferingCoordinator.clearReflectionBuffer(bufferKey);
|
|
33117
|
+
return cycleId;
|
|
33118
|
+
}
|
|
33119
|
+
/** Called when the op that started as `owner` finishes; completes a deferred retirement. */
|
|
33120
|
+
static finishReflectionBuffer(bufferKey, owner) {
|
|
33121
|
+
if (BufferingCoordinator.reflectionBufferOwners.get(bufferKey) !== owner) return;
|
|
33122
|
+
if (owner.retired) BufferingCoordinator.clearReflectionBuffer(bufferKey);
|
|
33123
|
+
}
|
|
32948
33124
|
constructor(opts) {
|
|
32949
33125
|
this.observationConfig = opts.observationConfig;
|
|
32950
33126
|
this.reflectionConfig = opts.reflectionConfig;
|
|
@@ -33000,6 +33176,7 @@ var BufferingCoordinator = class BufferingCoordinator {
|
|
|
33000
33176
|
BufferingCoordinator.asyncBufferingOps.delete(obsBufKey);
|
|
33001
33177
|
BufferingCoordinator.asyncBufferingOps.delete(reflBufKey);
|
|
33002
33178
|
BufferingCoordinator.reflectionBufferCycleIds.delete(reflBufKey);
|
|
33179
|
+
BufferingCoordinator.reflectionBufferOwners.delete(reflBufKey);
|
|
33003
33180
|
}
|
|
33004
33181
|
}
|
|
33005
33182
|
/**
|
|
@@ -35867,6 +36044,80 @@ var ObservationTurn = class {
|
|
|
35867
36044
|
};
|
|
35868
36045
|
}
|
|
35869
36046
|
};
|
|
36047
|
+
// src/processors/observational-memory/buffered-reflection-values.ts
|
|
36048
|
+
const pendingValuesBaseSchema = zod.z.object({
|
|
36049
|
+
recordId: zod.z.string(),
|
|
36050
|
+
reflectedObservationLineCount: zod.z.number(),
|
|
36051
|
+
values: zod.z.record(zod.z.string(), zod.z.unknown())
|
|
36052
|
+
});
|
|
36053
|
+
const pendingValuesSchema = zod.z.union([pendingValuesBaseSchema.extend({
|
|
36054
|
+
reflectionDigest: zod.z.string().regex(/^[a-f0-9]{64}$/),
|
|
36055
|
+
reflection: zod.z.never().optional()
|
|
36056
|
+
}), pendingValuesBaseSchema.extend({
|
|
36057
|
+
reflection: zod.z.string(),
|
|
36058
|
+
reflectionDigest: zod.z.never().optional()
|
|
36059
|
+
})]);
|
|
36060
|
+
const metadataSchema = zod.z.record(zod.z.string(), zod.z.unknown());
|
|
36061
|
+
function reflectionDigest(reflection) {
|
|
36062
|
+
return (0, crypto$1.createHash)("sha256").update(reflection).digest("hex");
|
|
36063
|
+
}
|
|
36064
|
+
function getMastraMetadata(metadata) {
|
|
36065
|
+
const parsed = metadataSchema.safeParse(metadata?.mastra);
|
|
36066
|
+
return parsed.success ? parsed.data : {};
|
|
36067
|
+
}
|
|
36068
|
+
/** Keep prepared values outside active OM metadata, durable across Memory instances. */
|
|
36069
|
+
async function stageBufferedReflectionValues(storage, record, values) {
|
|
36070
|
+
if (!record.threadId || !record.bufferedReflection) return;
|
|
36071
|
+
const digest = reflectionDigest(record.bufferedReflection);
|
|
36072
|
+
await storage.updateThreadMetadata({
|
|
36073
|
+
id: record.threadId,
|
|
36074
|
+
update: (thread) => ({
|
|
36075
|
+
...thread.metadata,
|
|
36076
|
+
mastra: {
|
|
36077
|
+
...getMastraMetadata(thread.metadata),
|
|
36078
|
+
omBufferedReflection: {
|
|
36079
|
+
recordId: record.id,
|
|
36080
|
+
reflectionDigest: digest,
|
|
36081
|
+
reflectedObservationLineCount: record.reflectedObservationLineCount ?? 0,
|
|
36082
|
+
values: values ?? {}
|
|
36083
|
+
}
|
|
36084
|
+
}
|
|
36085
|
+
})
|
|
36086
|
+
});
|
|
36087
|
+
}
|
|
36088
|
+
/** Called under the OM commit lock, only after this exact buffer was activated. */
|
|
36089
|
+
async function publishBufferedReflectionValues(storage, extractors, record) {
|
|
36090
|
+
if (!record.threadId || !record.bufferedReflection) return;
|
|
36091
|
+
const digest = reflectionDigest(record.bufferedReflection);
|
|
36092
|
+
await storage.updateThreadMetadata({
|
|
36093
|
+
id: record.threadId,
|
|
36094
|
+
update: (thread) => {
|
|
36095
|
+
const mastra = getMastraMetadata(thread.metadata);
|
|
36096
|
+
const parsed = pendingValuesSchema.safeParse(mastra.omBufferedReflection);
|
|
36097
|
+
if (!parsed.success) return;
|
|
36098
|
+
const pending = parsed.data;
|
|
36099
|
+
if (pending.recordId !== record.id || (pending.reflectionDigest !== void 0 ? pending.reflectionDigest !== digest : pending.reflection !== record.bufferedReflection) || pending.reflectedObservationLineCount !== (record.reflectedObservationLineCount ?? 0)) return;
|
|
36100
|
+
const update = buildThreadMetadataFromExtractedValues(extractors, pending.values);
|
|
36101
|
+
const previous = (0, _mastra_core_memory.getThreadOMMetadata)(thread.metadata);
|
|
36102
|
+
const metadata = (0, _mastra_core_memory.setThreadOMMetadata)(thread.metadata, {
|
|
36103
|
+
currentTask: update.currentTask ?? previous?.currentTask,
|
|
36104
|
+
suggestedResponse: update.suggestedResponse ?? previous?.suggestedResponse,
|
|
36105
|
+
threadTitle: update.threadTitle ?? previous?.threadTitle,
|
|
36106
|
+
extracted: {
|
|
36107
|
+
...previous?.extracted,
|
|
36108
|
+
...update.extracted
|
|
36109
|
+
}
|
|
36110
|
+
});
|
|
36111
|
+
return {
|
|
36112
|
+
...metadata,
|
|
36113
|
+
mastra: {
|
|
36114
|
+
...getMastraMetadata(metadata),
|
|
36115
|
+
omBufferedReflection: null
|
|
36116
|
+
}
|
|
36117
|
+
};
|
|
36118
|
+
}
|
|
36119
|
+
});
|
|
36120
|
+
}
|
|
35870
36121
|
// src/processors/observational-memory/reflector-agent.ts
|
|
35871
36122
|
/**
|
|
35872
36123
|
* Build the Reflector's system prompt.
|
|
@@ -36226,6 +36477,15 @@ function isReflectionApplied(returned, newRecordId, reflectedRecordId) {
|
|
|
36226
36477
|
return returned.supersededBy === void 0 && returned.id !== reflectedRecordId;
|
|
36227
36478
|
}
|
|
36228
36479
|
/**
|
|
36480
|
+
* The active observations a buffered-reflection swap writes: the buffered reflection replaces the
|
|
36481
|
+
* first `reflectedLineCount` lines, and the trimmed remainder follows after a blank line. Mirrors
|
|
36482
|
+
* `swapBufferedReflectionToActive` in the storage adapters.
|
|
36483
|
+
*/
|
|
36484
|
+
function bufferedActivationText({ bufferedReflection, observations, reflectedLineCount }) {
|
|
36485
|
+
const unreflected = observations.split("\n").slice(reflectedLineCount).join("\n").trim();
|
|
36486
|
+
return unreflected ? `${bufferedReflection}\n\n${unreflected}` : bufferedReflection;
|
|
36487
|
+
}
|
|
36488
|
+
/**
|
|
36229
36489
|
* Runs the Reflector agent for compressing observations.
|
|
36230
36490
|
* Handles synchronous reflection, async buffered reflection, and activation.
|
|
36231
36491
|
*/
|
|
@@ -36534,18 +36794,18 @@ var ReflectorRunner = class {
|
|
|
36534
36794
|
startAsyncBufferedReflection(record, observationTokens, lockKey, writer, requestContext, observabilityContext, reflectionHooks, priorExtractedValues, mainAgent, sendSignal, trigger, currentModel) {
|
|
36535
36795
|
const bufferKey = this.buffering.getReflectionBufferKey(lockKey);
|
|
36536
36796
|
if (this.buffering.isAsyncBufferingInProgress(bufferKey)) return;
|
|
36537
|
-
BufferingCoordinator.
|
|
36797
|
+
const owner = BufferingCoordinator.startReflectionBuffer(bufferKey, observationTokens, record.id);
|
|
36538
36798
|
registerOp(record.id, "bufferingReflection");
|
|
36539
36799
|
const flagSet = this.storage.setBufferingReflectionFlag(record.id, true).catch((err) => {
|
|
36540
36800
|
omError("[OM] Failed to set buffering reflection flag", err);
|
|
36541
36801
|
});
|
|
36542
|
-
const
|
|
36802
|
+
const run = async () => {
|
|
36543
36803
|
await flagSet;
|
|
36544
36804
|
let outcome;
|
|
36545
36805
|
let reflectionError;
|
|
36546
36806
|
try {
|
|
36547
36807
|
await reflectionHooks?.onReflectionStart?.();
|
|
36548
|
-
outcome = await this.doAsyncBufferedReflection(record, bufferKey, writer, requestContext, observabilityContext, priorExtractedValues, mainAgent, sendSignal, trigger, currentModel);
|
|
36808
|
+
outcome = await this.doAsyncBufferedReflection(record, bufferKey, owner, writer, requestContext, observabilityContext, priorExtractedValues, mainAgent, sendSignal, trigger, currentModel);
|
|
36549
36809
|
} catch (error) {
|
|
36550
36810
|
reflectionError = error instanceof Error ? error : new Error(String(error));
|
|
36551
36811
|
if (writer) try {
|
|
@@ -36568,7 +36828,7 @@ var ReflectorRunner = class {
|
|
|
36568
36828
|
omError("[OM] Failed to persist buffering-failed marker after async buffered reflection failure", markerError);
|
|
36569
36829
|
}
|
|
36570
36830
|
omError("[OM] Async buffered reflection failed", error);
|
|
36571
|
-
|
|
36831
|
+
owner.retired = true;
|
|
36572
36832
|
} finally {
|
|
36573
36833
|
try {
|
|
36574
36834
|
await reflectionHooks?.onReflectionEnd?.({
|
|
@@ -36579,13 +36839,15 @@ var ReflectorRunner = class {
|
|
|
36579
36839
|
} catch (hookError) {
|
|
36580
36840
|
omError("[OM] onReflectionEnd hook failed after async buffered reflection", hookError);
|
|
36581
36841
|
}
|
|
36582
|
-
BufferingCoordinator.
|
|
36842
|
+
BufferingCoordinator.finishReflectionBuffer(bufferKey, owner);
|
|
36843
|
+
if (BufferingCoordinator.asyncBufferingOps.get(bufferKey) === asyncOp) BufferingCoordinator.asyncBufferingOps.delete(bufferKey);
|
|
36583
36844
|
unregisterOp(record.id, "bufferingReflection");
|
|
36584
36845
|
await this.storage.setBufferingReflectionFlag(record.id, false).catch((err) => {
|
|
36585
36846
|
omError("[OM] Failed to clear buffering reflection flag", err);
|
|
36586
36847
|
});
|
|
36587
36848
|
}
|
|
36588
|
-
}
|
|
36849
|
+
};
|
|
36850
|
+
const asyncOp = run();
|
|
36589
36851
|
BufferingCoordinator.asyncBufferingOps.set(bufferKey, asyncOp);
|
|
36590
36852
|
this.trackBackgroundWork?.(asyncOp, lockKey);
|
|
36591
36853
|
}
|
|
@@ -36593,13 +36855,27 @@ var ReflectorRunner = class {
|
|
|
36593
36855
|
* Perform async buffered reflection — reflects observations and stores to bufferedReflection.
|
|
36594
36856
|
* Does NOT create a new generation or update activeObservations.
|
|
36595
36857
|
*/
|
|
36596
|
-
async doAsyncBufferedReflection(record, bufferKey, writer, requestContext, observabilityContext, priorExtractedValues, mainAgent, sendSignal, trigger, currentModel) {
|
|
36597
|
-
const
|
|
36858
|
+
async doAsyncBufferedReflection(record, bufferKey, owner, writer, requestContext, observabilityContext, priorExtractedValues, mainAgent, sendSignal, trigger, currentModel) {
|
|
36859
|
+
const freshRecord = await this.storage.getObservationalMemory(record.threadId, record.resourceId);
|
|
36860
|
+
if (BufferingCoordinator.reflectionBufferOwners.get(bufferKey) !== owner) {
|
|
36861
|
+
omDebug(`[OM:reflect] doAsyncBufferedReflection: ${bufferKey} was cleared while the op waited; stopping`);
|
|
36862
|
+
return;
|
|
36863
|
+
}
|
|
36864
|
+
const currentRecord = freshRecord ?? record;
|
|
36865
|
+
if (freshRecord?.bufferedReflection) {
|
|
36866
|
+
omDebug(`[OM:reflect] doAsyncBufferedReflection: live head ${freshRecord.id} already has a buffered reflection; skipping duplicate run`);
|
|
36867
|
+
owner.retired = true;
|
|
36868
|
+
return;
|
|
36869
|
+
}
|
|
36598
36870
|
const observationTokens = currentRecord.observationTokenCount ?? 0;
|
|
36599
36871
|
const reflectThreshold = getMaxThreshold(this.getEffectiveReflectionTokens(currentRecord));
|
|
36600
36872
|
const bufferActivation = this.reflectionConfig.bufferActivation ?? .5;
|
|
36601
36873
|
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
36602
36874
|
const cycleId = `reflect-buf-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
|
|
36875
|
+
if (owner.recordId !== currentRecord.id) {
|
|
36876
|
+
owner.recordId = currentRecord.id;
|
|
36877
|
+
owner.retired = false;
|
|
36878
|
+
}
|
|
36603
36879
|
BufferingCoordinator.reflectionBufferCycleIds.set(bufferKey, cycleId);
|
|
36604
36880
|
const allLines = (currentRecord.activeObservations ?? "").split("\n");
|
|
36605
36881
|
const totalLines = allLines.length;
|
|
@@ -36636,10 +36912,18 @@ var ReflectorRunner = class {
|
|
|
36636
36912
|
const compressionStartLevel = await this.getCompressionStartLevel(requestContext);
|
|
36637
36913
|
const reflectResult = await this.call(activeObservations, void 0, void 0, compressionTarget, void 0, true, compressionStartLevel, requestContext, priorExtractedValues, observabilityContext, void 0, mainAgent, sendSignal, currentModel);
|
|
36638
36914
|
reflectResult.observations = await applyTextTransform(this.hooks, "afterReflection", reflectResult.observations, hookContext);
|
|
36915
|
+
if (!reflectResult.observations.trim()) {
|
|
36916
|
+
omDebug(`[OM:reflect] doAsyncBufferedReflection: reflection for ${currentRecord.id} is empty after afterReflection; discarding it`);
|
|
36917
|
+
owner.retired = true;
|
|
36918
|
+
return {
|
|
36919
|
+
usage: reflectResult.usage,
|
|
36920
|
+
providerMetadata: reflectResult.providerMetadata
|
|
36921
|
+
};
|
|
36922
|
+
}
|
|
36639
36923
|
const reflectionTokenCount = this.tokenCounter.countObservations(reflectResult.observations);
|
|
36640
36924
|
omDebug(`[OM:reflect] doAsyncBufferedReflection: reflector returned ${reflectionTokenCount} tokens (${reflectResult.observations?.length} chars), saving to recordId=${currentRecord.id}`);
|
|
36641
36925
|
if (!await runOMCommit(this.buffering.getLockKey(currentRecord.threadId, currentRecord.resourceId), async () => {
|
|
36642
|
-
if ((await this.storage.getObservationalMemory(currentRecord.threadId, currentRecord.resourceId))?.id !== currentRecord.id) return false;
|
|
36926
|
+
if ((await this.storage.getObservationalMemory(currentRecord.threadId, currentRecord.resourceId))?.id !== currentRecord.id || BufferingCoordinator.reflectionBufferOwners.get(bufferKey) !== owner) return false;
|
|
36643
36927
|
await this.storage.updateBufferedReflection({
|
|
36644
36928
|
id: currentRecord.id,
|
|
36645
36929
|
reflection: reflectResult.observations,
|
|
@@ -36647,17 +36931,18 @@ var ReflectorRunner = class {
|
|
|
36647
36931
|
inputTokenCount: sliceTokenEstimate,
|
|
36648
36932
|
reflectedObservationLineCount
|
|
36649
36933
|
});
|
|
36934
|
+
const buffered = await this.storage.getObservationalMemory(currentRecord.threadId, currentRecord.resourceId);
|
|
36935
|
+
if (buffered?.id === currentRecord.id && buffered.bufferedReflection === reflectResult.observations) await stageBufferedReflectionValues(this.storage, buffered, reflectResult.extractedValues);
|
|
36650
36936
|
return true;
|
|
36651
36937
|
})) {
|
|
36652
36938
|
omDebug(`[OM:reflect] doAsyncBufferedReflection: record ${currentRecord.id} is no longer the head; discarding the buffered reflection`);
|
|
36653
|
-
|
|
36939
|
+
owner.retired = true;
|
|
36654
36940
|
return {
|
|
36655
36941
|
usage: reflectResult.usage,
|
|
36656
36942
|
providerMetadata: reflectResult.providerMetadata
|
|
36657
36943
|
};
|
|
36658
36944
|
}
|
|
36659
36945
|
omDebug(`[OM:reflect] doAsyncBufferedReflection: bufferedReflection saved with lineCount=${reflectedObservationLineCount}`);
|
|
36660
|
-
await persistThreadExtractedValues(this.storage, this.reflectionConfig.extractors, currentRecord.threadId ?? void 0, reflectResult.extractedValues);
|
|
36661
36946
|
if (writer) {
|
|
36662
36947
|
const endMarker = createBufferingEndMarker({
|
|
36663
36948
|
cycleId,
|
|
@@ -36683,6 +36968,57 @@ var ReflectorRunner = class {
|
|
|
36683
36968
|
};
|
|
36684
36969
|
}
|
|
36685
36970
|
/**
|
|
36971
|
+
* Decide what a buffered-reflection swap did. Built-in adapters only swap the buffer and line
|
|
36972
|
+
* count in the snapshot, return the stored record (no new generation) when another writer
|
|
36973
|
+
* extended them after the head check, and mark a generation they created after that check with
|
|
36974
|
+
* `bufferedReflectionVerified`. Adapters without that check build the new generation from
|
|
36975
|
+
* whatever is stored. Either way the swap must also produce what the snapshot's buffer and line
|
|
36976
|
+
* count give from the text the swap retired (retired records are never written again, so that
|
|
36977
|
+
* text is exactly what the swap read).
|
|
36978
|
+
*
|
|
36979
|
+
* Staged values are published only with the adapter's proof. Without it an extension that
|
|
36980
|
+
* repeats the unreflected tail produces the same text as the snapshot's buffer, so the values
|
|
36981
|
+
* fail closed: the activation still applies, but the staged values stay unpublished.
|
|
36982
|
+
*/
|
|
36983
|
+
async classifyBufferedReflectionSwap({ result, newRecordId, snapshot, bufferedReflection, reflectedLineCount }) {
|
|
36984
|
+
if (result.id === snapshot.id) return {
|
|
36985
|
+
kind: "not-applied",
|
|
36986
|
+
headId: result.id
|
|
36987
|
+
};
|
|
36988
|
+
const createdByThisSwap = result.id === newRecordId;
|
|
36989
|
+
if (!createdByThisSwap && result.supersededBy !== void 0) return {
|
|
36990
|
+
kind: "not-applied",
|
|
36991
|
+
headId: result.id
|
|
36992
|
+
};
|
|
36993
|
+
const swapActiveObservations = result.activeObservations;
|
|
36994
|
+
const bufferedReflectionVerified = result.bufferedReflectionVerified === true;
|
|
36995
|
+
let matchesSnapshotBuffer = false;
|
|
36996
|
+
try {
|
|
36997
|
+
const retired = (await this.storage.getObservationalMemoryHistory(snapshot.threadId, snapshot.resourceId, 5, { recordId: snapshot.id })).find((candidate) => candidate.id === snapshot.id);
|
|
36998
|
+
matchesSnapshotBuffer = retired !== void 0 && swapActiveObservations === bufferedActivationText({
|
|
36999
|
+
bufferedReflection,
|
|
37000
|
+
observations: retired.activeObservations,
|
|
37001
|
+
reflectedLineCount
|
|
37002
|
+
});
|
|
37003
|
+
} catch (error) {
|
|
37004
|
+
omError("[OM] Failed to read the generation retired by buffered reflection activation", error);
|
|
37005
|
+
}
|
|
37006
|
+
const snapshotBufferActivated = matchesSnapshotBuffer && bufferedReflectionVerified;
|
|
37007
|
+
if (createdByThisSwap) return {
|
|
37008
|
+
kind: "applied",
|
|
37009
|
+
record: result,
|
|
37010
|
+
snapshotBufferActivated
|
|
37011
|
+
};
|
|
37012
|
+
return matchesSnapshotBuffer ? {
|
|
37013
|
+
kind: "applied",
|
|
37014
|
+
record: result,
|
|
37015
|
+
snapshotBufferActivated
|
|
37016
|
+
} : {
|
|
37017
|
+
kind: "not-applied",
|
|
37018
|
+
headId: result.id
|
|
37019
|
+
};
|
|
37020
|
+
}
|
|
37021
|
+
/**
|
|
36686
37022
|
* Try to activate buffered reflection when threshold is reached.
|
|
36687
37023
|
* Returns a discriminated result so the caller can distinguish between
|
|
36688
37024
|
* "activated", "no buffer present", and "suppressed by overshoot guard"
|
|
@@ -36702,18 +37038,26 @@ var ReflectorRunner = class {
|
|
|
36702
37038
|
}
|
|
36703
37039
|
}
|
|
36704
37040
|
}
|
|
36705
|
-
const
|
|
37041
|
+
const storedRecord = await this.storage.getObservationalMemory(record.threadId, record.resourceId);
|
|
37042
|
+
const freshRecord = storedRecord ? { ...storedRecord } : void 0;
|
|
36706
37043
|
omDebug(`[OM:reflect] tryActivateBufferedReflection: recordId=${record.id}, hasBufferedReflection=${!!freshRecord?.bufferedReflection}, bufferedReflectionLen=${freshRecord?.bufferedReflection?.length ?? 0}`);
|
|
36707
37044
|
omDebug(`[OM:reflect] tryActivateBufferedReflection: freshRecord.id=${freshRecord?.id}, freshBufferedReflection=${freshRecord?.bufferedReflection ? "present (" + freshRecord.bufferedReflection.length + " chars)" : "empty"}, freshObsTokens=${freshRecord?.observationTokenCount}`);
|
|
37045
|
+
if (freshRecord) await BufferingCoordinator.reconcileReflectionBufferHead(bufferKey, freshRecord.id, () => this.storage.getObservationalMemory(record.threadId, record.resourceId));
|
|
36708
37046
|
if (!freshRecord?.bufferedReflection) {
|
|
36709
37047
|
omDebug(`[OM:reflect] tryActivateBufferedReflection: no buffered reflection after re-fetch`);
|
|
36710
37048
|
return { status: "no-buffer" };
|
|
36711
37049
|
}
|
|
36712
37050
|
const beforeTokens = freshRecord.observationTokenCount ?? 0;
|
|
36713
37051
|
const reflectedLineCount = freshRecord.reflectedObservationLineCount ?? 0;
|
|
36714
|
-
const
|
|
37052
|
+
const currentObservations = freshRecord.activeObservations ?? "";
|
|
37053
|
+
const unreflectedLines = currentObservations.split("\n").slice(reflectedLineCount);
|
|
36715
37054
|
const unreflectedContent = unreflectedLines.join("\n").trim();
|
|
36716
|
-
const
|
|
37055
|
+
const bufferedReflection = freshRecord.bufferedReflection;
|
|
37056
|
+
const combinedObservations = bufferedActivationText({
|
|
37057
|
+
bufferedReflection,
|
|
37058
|
+
observations: currentObservations,
|
|
37059
|
+
reflectedLineCount
|
|
37060
|
+
});
|
|
36717
37061
|
const combinedTokenCount = this.tokenCounter.countObservations(combinedObservations);
|
|
36718
37062
|
if (activationMetadata?.triggeredBy === "ttl" || activationMetadata?.triggeredBy === "provider_change") {
|
|
36719
37063
|
const unreflectedTailTokens = unreflectedContent ? this.tokenCounter.countObservations(unreflectedContent) : 0;
|
|
@@ -36739,28 +37083,48 @@ var ReflectorRunner = class {
|
|
|
36739
37083
|
}
|
|
36740
37084
|
omDebug(`[OM:reflect] tryActivateBufferedReflection: activating, beforeTokens=${beforeTokens}, combinedTokenCount=${combinedTokenCount}, reflectedLineCount=${reflectedLineCount}, unreflectedLines=${unreflectedLines.length}`);
|
|
36741
37085
|
const newRecordId = crypto.randomUUID();
|
|
36742
|
-
const
|
|
37086
|
+
const commit = await runOMCommit(lockKey, async () => {
|
|
36743
37087
|
abortSignal?.throwIfAborted();
|
|
36744
|
-
|
|
37088
|
+
const head = await this.storage.getObservationalMemory(record.threadId, record.resourceId);
|
|
37089
|
+
if (head && (head.id !== freshRecord.id || head.bufferedReflection !== freshRecord.bufferedReflection || head.reflectedObservationLineCount !== freshRecord.reflectedObservationLineCount)) return {
|
|
37090
|
+
kind: "not-applied",
|
|
37091
|
+
headId: head.id
|
|
37092
|
+
};
|
|
37093
|
+
const result = await this.storage.swapBufferedReflectionToActive({
|
|
36745
37094
|
currentRecord: freshRecord,
|
|
36746
37095
|
tokenCount: combinedTokenCount,
|
|
36747
37096
|
newRecordId
|
|
36748
37097
|
});
|
|
37098
|
+
const outcome = await this.classifyBufferedReflectionSwap({
|
|
37099
|
+
result,
|
|
37100
|
+
newRecordId,
|
|
37101
|
+
snapshot: freshRecord,
|
|
37102
|
+
bufferedReflection,
|
|
37103
|
+
reflectedLineCount
|
|
37104
|
+
});
|
|
37105
|
+
if (outcome.kind === "applied" && outcome.snapshotBufferActivated) try {
|
|
37106
|
+
await publishBufferedReflectionValues(this.storage, this.reflectionConfig.extractors, freshRecord);
|
|
37107
|
+
} catch (error) {
|
|
37108
|
+
omError("[OM] Failed to publish buffered reflection values after activation", error);
|
|
37109
|
+
}
|
|
37110
|
+
return outcome;
|
|
36749
37111
|
}, {
|
|
36750
37112
|
priority: "reflection",
|
|
36751
37113
|
abortSignal
|
|
36752
37114
|
});
|
|
36753
|
-
if (
|
|
36754
|
-
omDebug(`[OM:reflect] tryActivateBufferedReflection: buffered reflection on ${freshRecord.id} not applied (head is ${
|
|
37115
|
+
if (commit.kind === "not-applied") {
|
|
37116
|
+
omDebug(`[OM:reflect] tryActivateBufferedReflection: buffered reflection on ${freshRecord.id} not applied (head is ${commit.headId})`);
|
|
37117
|
+
if (commit.headId !== freshRecord.id) BufferingCoordinator.retireReflectionBuffer(bufferKey, freshRecord.id);
|
|
36755
37118
|
return { status: "not-applied" };
|
|
36756
37119
|
}
|
|
36757
|
-
|
|
37120
|
+
if (!commit.snapshotBufferActivated) omDebug(`[OM:reflect] tryActivateBufferedReflection: ${commit.record.id} does not hold exactly the snapshot's buffered reflection (extended by another writer, or unverifiable); staged values stay unpublished`);
|
|
37121
|
+
const originalCycleId = BufferingCoordinator.consumeReflectionBuffer(bufferKey, freshRecord.id);
|
|
36758
37122
|
const afterRecord = await this.storage.getObservationalMemory(record.threadId, record.resourceId);
|
|
36759
37123
|
const afterTokens = afterRecord?.observationTokenCount ?? 0;
|
|
36760
37124
|
omDebug(`[OM:reflect] tryActivateBufferedReflection: activation complete! beforeTokens=${beforeTokens}, afterTokens=${afterTokens}, newRecordId=${afterRecord?.id}, newGenCount=${afterRecord?.generationCount}`);
|
|
36761
37125
|
if (writer) {
|
|
36762
37126
|
const activationMarker = createActivationMarker({
|
|
36763
|
-
cycleId:
|
|
37127
|
+
cycleId: originalCycleId ?? `reflect-act-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`,
|
|
36764
37128
|
operationType: "reflection",
|
|
36765
37129
|
chunksActivated: 1,
|
|
36766
37130
|
tokensActivated: beforeTokens,
|
|
@@ -36786,7 +37150,6 @@ var ReflectorRunner = class {
|
|
|
36786
37150
|
}).catch(() => {});
|
|
36787
37151
|
await this.persistMarkerToMessage(activationMarker, messageList, freshRecord.threadId ?? "", freshRecord.resourceId ?? void 0, abortSignal);
|
|
36788
37152
|
}
|
|
36789
|
-
BufferingCoordinator.reflectionBufferCycleIds.delete(bufferKey);
|
|
36790
37153
|
return { status: "activated" };
|
|
36791
37154
|
}
|
|
36792
37155
|
/**
|
|
@@ -36803,7 +37166,7 @@ var ReflectorRunner = class {
|
|
|
36803
37166
|
const priorExtractedValues = await getThreadExtractedValues(this.storage, this.reflectionConfig.extractors, requestedThreadId ?? record.threadId);
|
|
36804
37167
|
abortSignal?.throwIfAborted();
|
|
36805
37168
|
if (this.buffering.isAsyncReflectionEnabled() && observationTokens < reflectThreshold) {
|
|
36806
|
-
if ((() => {
|
|
37169
|
+
if (await (async () => {
|
|
36807
37170
|
if (!this.buffering.isAsyncReflectionEnabled()) return false;
|
|
36808
37171
|
if (record.isBufferingReflection) {
|
|
36809
37172
|
if (isOpActiveInProcess(record.id, "bufferingReflection")) return false;
|
|
@@ -36811,6 +37174,7 @@ var ReflectorRunner = class {
|
|
|
36811
37174
|
this.storage.setBufferingReflectionFlag(record.id, false).catch(() => {});
|
|
36812
37175
|
}
|
|
36813
37176
|
const bufferKey = this.buffering.getReflectionBufferKey(lockKey);
|
|
37177
|
+
await BufferingCoordinator.reconcileReflectionBufferHead(bufferKey, record.id, () => this.storage.getObservationalMemory(record.threadId, record.resourceId));
|
|
36814
37178
|
if (this.buffering.isAsyncBufferingInProgress(bufferKey)) return false;
|
|
36815
37179
|
if (BufferingCoordinator.lastBufferedBoundary.has(bufferKey)) return false;
|
|
36816
37180
|
if (record.bufferedReflection) return false;
|
|
@@ -36856,6 +37220,11 @@ var ReflectorRunner = class {
|
|
|
36856
37220
|
omDebug(`[OM:reflect] skipping async reflection — observationTokens (${observationTokens}) below activation point (${activationPoint}), triggered by ${activationTriggeredBy}`);
|
|
36857
37221
|
return;
|
|
36858
37222
|
}
|
|
37223
|
+
const bufferKey = this.buffering.getReflectionBufferKey(lockKey);
|
|
37224
|
+
if (this.buffering.isAsyncBufferingInProgress(bufferKey) || BufferingCoordinator.lastBufferedBoundary.has(bufferKey)) {
|
|
37225
|
+
omDebug(`[OM:reflect] skipping async reflection — reflection buffer already active or present for ${bufferKey}`);
|
|
37226
|
+
return;
|
|
37227
|
+
}
|
|
36859
37228
|
omDebug(`[OM:reflect] async activation failed, no blockAfter or below it (obsTokens=${observationTokens}, blockAfter=${this.reflectionConfig.blockAfter}) — starting background reflection`);
|
|
36860
37229
|
this.startAsyncBufferedReflection(record, observationTokens, lockKey, writer, requestContext, observabilityContext, reflectionHooks, priorExtractedValues, mainAgent, sendSignal, trigger, currentModel);
|
|
36861
37230
|
return;
|
|
@@ -40777,6 +41146,26 @@ function isTransientSignalMessage(message) {
|
|
|
40777
41146
|
const metadata = message.content.metadata;
|
|
40778
41147
|
return isRecord(metadata) && isRecord(metadata.signal) && !Array.isArray(metadata.signal) && metadata.signal.transient === true;
|
|
40779
41148
|
}
|
|
41149
|
+
const DEFAULT_WORKING_MEMORY_TEMPLATE = `
|
|
41150
|
+
# User Information
|
|
41151
|
+
- **First Name**:
|
|
41152
|
+
- **Last Name**:
|
|
41153
|
+
- **Location**:
|
|
41154
|
+
- **Occupation**:
|
|
41155
|
+
- **Interests**:
|
|
41156
|
+
- **Goals**:
|
|
41157
|
+
- **Events**:
|
|
41158
|
+
- **Facts**:
|
|
41159
|
+
- **Projects**:
|
|
41160
|
+
`;
|
|
41161
|
+
/**
|
|
41162
|
+
* True when the installed `@mastra/core` builds its WorkingMemory processor with the memory instance as the
|
|
41163
|
+
* instruction provider. Cores from before `MastraMemory.getWorkingMemoryInstruction` existed (up to and
|
|
41164
|
+
* including 1.86.0-alpha.5) don't, and render their own built-in text. Checked per call, not at import.
|
|
41165
|
+
*/
|
|
41166
|
+
function coreRendersWorkingMemoryInstructionThroughMemory() {
|
|
41167
|
+
return "getWorkingMemoryInstruction" in _mastra_core_memory.MastraMemory.prototype;
|
|
41168
|
+
}
|
|
40780
41169
|
function normalizeObservationalMemoryConfig(config) {
|
|
40781
41170
|
if (config === true) return { model: "auto" };
|
|
40782
41171
|
if (config === false || config === void 0) return void 0;
|
|
@@ -41708,10 +42097,14 @@ ${workingMemory}`;
|
|
|
41708
42097
|
if (scope === "resource" && !resourceId) throw new Error("Memory error: Resource-scoped working memory is enabled but no resourceId was provided. Either provide a resourceId or explicitly set workingMemory.scope to 'thread'.");
|
|
41709
42098
|
if (scope === "resource" && resourceId) {
|
|
41710
42099
|
const loadWorkingMemory = async () => {
|
|
41711
|
-
|
|
42100
|
+
const resource = await (await this.getMemoryStore()).getResourceById({ resourceId });
|
|
42101
|
+
return typeof resource?.workingMemory === "string" && resource.workingMemory ? resource.workingMemory : null;
|
|
41712
42102
|
};
|
|
41713
42103
|
workingMemoryData = runState ? await runState.load(`working-memory:resource:${resourceId}`, loadWorkingMemory) : await loadWorkingMemory();
|
|
41714
|
-
} else
|
|
42104
|
+
} else {
|
|
42105
|
+
const stored = (runState?.threadLoaded ? runState.thread : await this.getThreadById({ threadId }))?.metadata?.workingMemory;
|
|
42106
|
+
workingMemoryData = typeof stored === "string" && stored ? stored : null;
|
|
42107
|
+
}
|
|
41715
42108
|
if (!workingMemoryData) return null;
|
|
41716
42109
|
return workingMemoryData;
|
|
41717
42110
|
}
|
|
@@ -41758,18 +42151,17 @@ ${workingMemory}`;
|
|
|
41758
42151
|
});
|
|
41759
42152
|
if (!workingMemoryTemplate) return null;
|
|
41760
42153
|
const workingMemoryConfig = config.workingMemory;
|
|
41761
|
-
|
|
42154
|
+
const args = config?.readOnly || workingMemoryConfig.agentManaged === false ? {
|
|
42155
|
+
kind: "read-only",
|
|
41762
42156
|
template: workingMemoryTemplate,
|
|
41763
42157
|
data: workingMemoryData,
|
|
41764
42158
|
autoUpdated: !config?.readOnly
|
|
41765
|
-
}
|
|
41766
|
-
|
|
41767
|
-
template: workingMemoryTemplate,
|
|
41768
|
-
data: workingMemoryData
|
|
41769
|
-
}) : this.getWorkingMemoryToolInstruction({
|
|
42159
|
+
} : {
|
|
42160
|
+
kind: "version" in workingMemoryConfig && workingMemoryConfig.version === "vnext" ? "vnext" : "tool",
|
|
41770
42161
|
template: workingMemoryTemplate,
|
|
41771
42162
|
data: workingMemoryData
|
|
41772
|
-
}
|
|
42163
|
+
};
|
|
42164
|
+
return (this.getWorkingMemoryInstruction(args) ?? this.renderBuiltInWorkingMemoryInstruction(args)) || null;
|
|
41773
42165
|
}
|
|
41774
42166
|
/** Fetch current stored copies of messages in a resumed turn, bypassing run-state history caches. */
|
|
41775
42167
|
async getPersistedMessages(threadId, ids) {
|
|
@@ -42016,19 +42408,8 @@ ${workingMemory}`;
|
|
|
42016
42408
|
} : void 0
|
|
42017
42409
|
});
|
|
42018
42410
|
}
|
|
42019
|
-
defaultWorkingMemoryTemplate =
|
|
42020
|
-
|
|
42021
|
-
- **First Name**:
|
|
42022
|
-
- **Last Name**:
|
|
42023
|
-
- **Location**:
|
|
42024
|
-
- **Occupation**:
|
|
42025
|
-
- **Interests**:
|
|
42026
|
-
- **Goals**:
|
|
42027
|
-
- **Events**:
|
|
42028
|
-
- **Facts**:
|
|
42029
|
-
- **Projects**:
|
|
42030
|
-
`;
|
|
42031
|
-
getWorkingMemoryToolInstruction({ template, data }) {
|
|
42411
|
+
defaultWorkingMemoryTemplate = DEFAULT_WORKING_MEMORY_TEMPLATE;
|
|
42412
|
+
builtInWorkingMemoryToolInstruction({ template, data }) {
|
|
42032
42413
|
const emptyWorkingMemoryTemplateObject = template.format === "json" ? (0, _mastra_core_utils.generateEmptyFromSchema)(template.content) : null;
|
|
42033
42414
|
const hasEmptyWorkingMemoryTemplateObject = emptyWorkingMemoryTemplateObject && Object.keys(emptyWorkingMemoryTemplateObject).length > 0;
|
|
42034
42415
|
return `WORKING_MEMORY_SYSTEM_INSTRUCTION:
|
|
@@ -42064,7 +42445,8 @@ Notes:
|
|
|
42064
42445
|
- IMPORTANT: You MUST call updateWorkingMemory in every response to a prompt where you received relevant information.
|
|
42065
42446
|
- IMPORTANT: Preserve the ${template.format === "json" ? "JSON" : "Markdown"} formatting structure above while updating the content.`;
|
|
42066
42447
|
}
|
|
42067
|
-
|
|
42448
|
+
builtInWorkingMemoryToolInstructionVNext({ template, data }) {
|
|
42449
|
+
const templateContent = typeof template.content === "string" ? template.content : JSON.stringify(template.content);
|
|
42068
42450
|
return `WORKING_MEMORY_SYSTEM_INSTRUCTION:
|
|
42069
42451
|
Store and update any conversation-relevant information by calling the updateWorkingMemory tool.
|
|
42070
42452
|
|
|
@@ -42077,7 +42459,7 @@ Guidelines:
|
|
|
42077
42459
|
6. Information not being relevant to the current conversation is not a valid reason to replace or remove working memory information. Your working memory spans across multiple conversations and may be needed again later, even if it's not currently relevant.
|
|
42078
42460
|
|
|
42079
42461
|
<working_memory_template>
|
|
42080
|
-
${
|
|
42462
|
+
${templateContent}
|
|
42081
42463
|
</working_memory_template>
|
|
42082
42464
|
|
|
42083
42465
|
<working_memory_data>
|
|
@@ -42086,7 +42468,7 @@ ${data || "No working memory data available."}
|
|
|
42086
42468
|
|
|
42087
42469
|
Notes:
|
|
42088
42470
|
- Update memory whenever referenced information changes
|
|
42089
|
-
${
|
|
42471
|
+
${templateContent !== DEFAULT_WORKING_MEMORY_TEMPLATE ? `- Only store information if it's in the working memory template, do not store other information unless the user asks you to remember it, as that non-template information may be irrelevant` : `- If you're unsure whether to store something, store it (eg if the user tells you information about themselves, call updateWorkingMemory immediately to update it)
|
|
42090
42472
|
`}
|
|
42091
42473
|
- This system is here so that you can maintain the conversation when your context window is very short. Update your working memory because you may need it to maintain the conversation without the full conversation history
|
|
42092
42474
|
- REMEMBER: the way you update your working memory is by calling the updateWorkingMemory tool with the ${template.format === "json" ? "JSON" : "Markdown"} content. The system will store it for you. The user will not see it.
|
|
@@ -42094,12 +42476,7 @@ ${template.content !== this.defaultWorkingMemoryTemplate ? `- Only store informa
|
|
|
42094
42476
|
- IMPORTANT: Preserve the ${template.format === "json" ? "JSON" : "Markdown"} formatting structure above while updating the content.
|
|
42095
42477
|
`;
|
|
42096
42478
|
}
|
|
42097
|
-
|
|
42098
|
-
* Generate read-only working memory instructions.
|
|
42099
|
-
* This provides the working memory context without any tool update instructions.
|
|
42100
|
-
* Used when memory is in readOnly mode, or with `autoUpdated` when the app updates it (agentManaged: false).
|
|
42101
|
-
*/
|
|
42102
|
-
getReadOnlyWorkingMemoryInstruction({ data, autoUpdated = false }) {
|
|
42479
|
+
builtInReadOnlyWorkingMemoryInstruction({ data, autoUpdated = false }) {
|
|
42103
42480
|
return `WORKING_MEMORY_SYSTEM_INSTRUCTION (${autoUpdated ? "AUTO-UPDATED" : "READ-ONLY"}):
|
|
42104
42481
|
The following is your working memory - persistent information about the user and conversation collected over previous interactions. This data is provided for context to help you maintain continuity.
|
|
42105
42482
|
|
|
@@ -42116,6 +42493,46 @@ Notes:
|
|
|
42116
42493
|
- This system is here so that you can maintain the conversation when your context window is very short
|
|
42117
42494
|
- The user will not see the working memory data directly`;
|
|
42118
42495
|
}
|
|
42496
|
+
/** Instruction for agents that update working memory with the updateWorkingMemory tool. Override to customize it. */
|
|
42497
|
+
getWorkingMemoryToolInstruction(args) {
|
|
42498
|
+
return this.builtInWorkingMemoryToolInstruction(args);
|
|
42499
|
+
}
|
|
42500
|
+
/** Instruction for `version: 'vnext'` template working memory. Override to customize it. */
|
|
42501
|
+
__experimental_getWorkingMemoryToolInstructionVNext(args) {
|
|
42502
|
+
return this.builtInWorkingMemoryToolInstructionVNext(args);
|
|
42503
|
+
}
|
|
42504
|
+
/**
|
|
42505
|
+
* Generate read-only working memory instructions.
|
|
42506
|
+
* This provides the working memory context without any tool update instructions.
|
|
42507
|
+
* Used when memory is in readOnly mode, or with `autoUpdated` when the app updates it (agentManaged: false).
|
|
42508
|
+
* Override to customize it.
|
|
42509
|
+
*/
|
|
42510
|
+
getReadOnlyWorkingMemoryInstruction(args) {
|
|
42511
|
+
return this.builtInReadOnlyWorkingMemoryInstruction(args);
|
|
42512
|
+
}
|
|
42513
|
+
/**
|
|
42514
|
+
* Renders the working memory instruction an agent receives, using the instruction methods above,
|
|
42515
|
+
* so a subclass that overrides them changes what the model sees. Return `undefined` to use the
|
|
42516
|
+
* built-in instruction, or an empty string to send none.
|
|
42517
|
+
*/
|
|
42518
|
+
getWorkingMemoryInstruction(args) {
|
|
42519
|
+
switch (args.kind) {
|
|
42520
|
+
case "read-only": return this.getReadOnlyWorkingMemoryInstruction(args);
|
|
42521
|
+
case "vnext": return this.__experimental_getWorkingMemoryToolInstructionVNext(args);
|
|
42522
|
+
case "tool": return this.getWorkingMemoryToolInstruction(args);
|
|
42523
|
+
}
|
|
42524
|
+
}
|
|
42525
|
+
/**
|
|
42526
|
+
* The built-in text, ignoring subclass overrides of the instruction methods. Used when
|
|
42527
|
+
* getWorkingMemoryInstruction returns `undefined`, matching the agent processor's own fallback.
|
|
42528
|
+
*/
|
|
42529
|
+
renderBuiltInWorkingMemoryInstruction(args) {
|
|
42530
|
+
switch (args.kind) {
|
|
42531
|
+
case "read-only": return this.builtInReadOnlyWorkingMemoryInstruction(args);
|
|
42532
|
+
case "vnext": return this.builtInWorkingMemoryToolInstructionVNext(args);
|
|
42533
|
+
case "tool": return this.builtInWorkingMemoryToolInstruction(args);
|
|
42534
|
+
}
|
|
42535
|
+
}
|
|
42119
42536
|
isVNextWorkingMemoryConfig(config) {
|
|
42120
42537
|
if (!config?.workingMemory) return false;
|
|
42121
42538
|
const isMDWorkingMemory = !(`schema` in config.workingMemory) && (typeof config.workingMemory.template === `string` || config.workingMemory.template) && config.workingMemory;
|
|
@@ -42815,8 +43232,11 @@ Notes:
|
|
|
42815
43232
|
};
|
|
42816
43233
|
}
|
|
42817
43234
|
const moved = /* @__PURE__ */ new Set();
|
|
42818
|
-
|
|
42819
|
-
|
|
43235
|
+
const deadline = Date.now() + 12e4;
|
|
43236
|
+
let retryDelayMs = 1e3;
|
|
43237
|
+
let complete = false;
|
|
43238
|
+
migration: while (Date.now() < deadline) {
|
|
43239
|
+
const stale = await vector.query({
|
|
42820
43240
|
indexName,
|
|
42821
43241
|
...readParams,
|
|
42822
43242
|
topK: 20,
|
|
@@ -42824,9 +43244,21 @@ Notes:
|
|
|
42824
43244
|
thread_id: threadId,
|
|
42825
43245
|
resource_id: { $ne: resourceId }
|
|
42826
43246
|
}
|
|
42827
|
-
})
|
|
42828
|
-
if (
|
|
43247
|
+
});
|
|
43248
|
+
if (stale.length === 0) {
|
|
43249
|
+
complete = true;
|
|
43250
|
+
break;
|
|
43251
|
+
}
|
|
43252
|
+
const pending = stale.filter((result) => !moved.has(result.id));
|
|
43253
|
+
if (pending.length === 0) {
|
|
43254
|
+
const delayMs = Math.min(retryDelayMs, Math.max(0, deadline - Date.now()));
|
|
43255
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
43256
|
+
retryDelayMs = Math.min(retryDelayMs * 2, 3e4);
|
|
43257
|
+
continue;
|
|
43258
|
+
}
|
|
43259
|
+
retryDelayMs = 1e3;
|
|
42829
43260
|
for (const result of pending) {
|
|
43261
|
+
if (Date.now() >= deadline) break migration;
|
|
42830
43262
|
moved.add(result.id);
|
|
42831
43263
|
if (!result.metadata) {
|
|
42832
43264
|
this.logger.warn("Skipping observation vector without metadata during thread transfer", {
|
|
@@ -42848,6 +43280,7 @@ Notes:
|
|
|
42848
43280
|
});
|
|
42849
43281
|
}
|
|
42850
43282
|
}
|
|
43283
|
+
if (!complete) throw new Error(`Observation vector migration in index "${indexName}" did not complete within 120 seconds (${moved.size} vector IDs processed). The store may still be returning stale results; retry the transfer.`);
|
|
42851
43284
|
}
|
|
42852
43285
|
}
|
|
42853
43286
|
/**
|
|
@@ -43048,6 +43481,10 @@ Notes:
|
|
|
43048
43481
|
*/
|
|
43049
43482
|
async getInputProcessors(configuredProcessors = [], context) {
|
|
43050
43483
|
const processors = await super.getInputProcessors(configuredProcessors, context);
|
|
43484
|
+
if (!coreRendersWorkingMemoryInstructionThroughMemory()) {
|
|
43485
|
+
const index = processors.findIndex((p) => p.id === "working-memory" && !configuredProcessors.includes(p));
|
|
43486
|
+
if (index !== -1) processors[index] = await this.createWorkingMemoryInstructionCompatProcessor(context);
|
|
43487
|
+
}
|
|
43051
43488
|
const om = await this.createOMProcessor(configuredProcessors, context);
|
|
43052
43489
|
if (om) processors.push(om);
|
|
43053
43490
|
const wm = await this.createWorkingMemoryStateProcessor(configuredProcessors, context);
|
|
@@ -43096,6 +43533,29 @@ Notes:
|
|
|
43096
43533
|
return new ObservationalMemoryProcessor(engine, this, { temporalMarkers: effectiveConfig.temporalMarkers });
|
|
43097
43534
|
}
|
|
43098
43535
|
/**
|
|
43536
|
+
* Builds the WorkingMemory input processor for cores without an instruction provider, from the same
|
|
43537
|
+
* config core's `MastraMemory.getInputProcessors()` uses for the processor it replaces.
|
|
43538
|
+
*/
|
|
43539
|
+
async createWorkingMemoryInstructionCompatProcessor(context) {
|
|
43540
|
+
const runtimeMemory = context?.get("MastraMemory");
|
|
43541
|
+
const effectiveConfig = runtimeMemory?.memoryConfig ? this.getMergedThreadConfig(runtimeMemory.memoryConfig) : this.threadConfig;
|
|
43542
|
+
const workingMemory = typeof effectiveConfig.workingMemory === "object" ? effectiveConfig.workingMemory : void 0;
|
|
43543
|
+
return new WorkingMemoryInstructionCompat({
|
|
43544
|
+
storage: await this.getMemoryStore(),
|
|
43545
|
+
template: workingMemory?.template ? {
|
|
43546
|
+
format: "markdown",
|
|
43547
|
+
content: workingMemory.template
|
|
43548
|
+
} : void 0,
|
|
43549
|
+
scope: workingMemory?.scope,
|
|
43550
|
+
useVNext: workingMemory !== void 0 && "version" in workingMemory && workingMemory.version === "vnext",
|
|
43551
|
+
readOnly: effectiveConfig.readOnly,
|
|
43552
|
+
agentManaged: workingMemory?.agentManaged,
|
|
43553
|
+
defaultTemplate: DEFAULT_WORKING_MEMORY_TEMPLATE,
|
|
43554
|
+
getWorkingMemoryTemplate: (args) => this.getWorkingMemoryTemplate(args),
|
|
43555
|
+
renderInstruction: (args) => this.getWorkingMemoryInstruction(args) ?? this.renderBuiltInWorkingMemoryInstruction(args)
|
|
43556
|
+
});
|
|
43557
|
+
}
|
|
43558
|
+
/**
|
|
43099
43559
|
* Creates a WorkingMemoryStateProcessor when working memory is enabled and the
|
|
43100
43560
|
* `useStateSignals` opt-in is set. Returns null otherwise or if the processor
|
|
43101
43561
|
* is already present in the user's configured processors.
|
|
@@ -43387,5 +43847,3 @@ Object.defineProperty(exports, "wrapInObservationGroup", {
|
|
|
43387
43847
|
return wrapInObservationGroup;
|
|
43388
43848
|
}
|
|
43389
43849
|
});
|
|
43390
|
-
|
|
43391
|
-
//# sourceMappingURL=src-CKA5LbDL.cjs.map
|