@mastra/memory 1.41.3-alpha.2 → 1.41.3-alpha.4
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 +87 -87
- package/dist/docs/references/integrations-databases-libsql.md +1 -1
- package/dist/index.cjs +1 -1
- 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/extracted-values.d.ts +5 -1
- package/dist/processors/observational-memory/reflector-runner.d.ts +14 -0
- package/dist/{src-BC-wnTHt.cjs → src-CKIbQdMJ.cjs} +1251 -974
- package/dist/{src-CRmfe-8x.js → src-TRQ73bGO.js} +430 -153
- package/package.json +3 -3
|
@@ -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({
|
|
@@ -24283,14 +24283,14 @@ function getRetrievalInstructions(scope = "resource", customInstructions, search
|
|
|
24283
24283
|
The recall tool works across ALL of this user's conversation threads, not just the current one.
|
|
24284
24284
|
|
|
24285
24285
|
- Use \`mode: "search"\` with a \`query\` to find relevant history, even when you already know the thread. Each result includes its thread ID, observation group ID, and source message range.
|
|
24286
|
-
- Use \`mode: "messages"\` for original wording or details behind an observation
|
|
24286
|
+
- Use \`mode: "messages"\` for original wording or details behind an observation \u2014 pass \`threadId\` to read another thread and a \`cursor\` from the source message range.
|
|
24287
24287
|
- Use \`mode: "threads"\` to list the user's threads (IDs, titles, dates) when you need to discover where something was discussed. Use \`before\`/\`after\` to narrow by date.
|
|
24288
24288
|
|
|
24289
|
-
**If search results look irrelevant, do not give up.** Search only covers content that has been indexed
|
|
24289
|
+
**If search results look irrelevant, do not give up.** Search only covers content that has been indexed \u2014 a short or recent conversation may exist in raw message history before any observation of it was created. When search returns nothing suitable but the user is clearly referring to a past conversation, call \`mode: "threads"\` to find candidate threads (titles and dates are strong clues), then read them with \`mode: "messages"\`. Use a useful hit as an entry point to the surrounding history rather than treating it as the whole answer.` : `### Choosing a mode
|
|
24290
24290
|
The recall tool works across ALL of this user's conversation threads, not just the current one.
|
|
24291
24291
|
|
|
24292
24292
|
- Use \`mode: "threads"\` to list the user's threads (IDs, titles, dates) when you need to discover where something was discussed. Use \`before\`/\`after\` to narrow by date.
|
|
24293
|
-
- Use \`mode: "messages"\` when you know the thread
|
|
24293
|
+
- Use \`mode: "messages"\` when you know the thread \u2014 pass \`threadId\` to read another thread, or a \`cursor\` from an observation-group range.
|
|
24294
24294
|
|
|
24295
24295
|
When the user refers to a past conversation you don't have a cursor for, call \`mode: "threads"\` to find candidate threads (titles and dates are strong clues), then read them with \`mode: "messages"\`. Raw history may exist for threads that have no observations yet.` : `### Choosing a mode
|
|
24296
24296
|
The recall tool is limited to the current conversation thread.
|
|
@@ -24315,7 +24315,7 @@ When searches keep returning the same groups, often as already-in-context refere
|
|
|
24315
24315
|
"Excerpt already in current context" marks a hit whose text an earlier search result already shows. "Group already in current context" marks a group that is already in your observations or whose source messages are still in the conversation. "Source range overlaps current context" marks a group whose source messages are still in the conversation. Search keeps these references and tries lower-ranked matches to fill the requested number of excerpts. This backfill is bounded: fewer excerpts do not mean history is exhausted. Use the evidence already present rather than repeating the same lookup. You can still ${pagingEnabled ? "page a referenced group" : "read a referenced group's source messages"} when you need all of it, or search again if that context is no longer available.
|
|
24316
24316
|
|
|
24317
24317
|
If search still finds nothing useful, browse raw messages${isResource ? " or discover other threads" : " in this thread"} before concluding the information is unavailable. Raw history may exist for threads that have no observations yet.` : "";
|
|
24318
|
-
const base = `## Recall
|
|
24318
|
+
const base = `## Recall \u2014 looking up source messages
|
|
24319
24319
|
|
|
24320
24320
|
Your memory contains observation groups with IDs and source message ranges, shown as \`## Group\` headings with \`_range: startId:endId\` or as \`<observation-group>\` tags. Use the **recall** tool to recover retained original observations and source messages.
|
|
24321
24321
|
|
|
@@ -24326,13 +24326,13 @@ Groups marked \`kind="reflection"\` (rendered as \`_kind: reflection_\`) are los
|
|
|
24326
24326
|
|
|
24327
24327
|
### When to use recall
|
|
24328
24328
|
- The user asks you to **repeat, show, or reproduce** something from a past conversation
|
|
24329
|
-
- The user asks for **exact content**
|
|
24329
|
+
- The user asks for **exact content** \u2014 code, text, quotes, error messages, URLs, file paths, specific numbers
|
|
24330
24330
|
- Your observations mention something but your memory lacks the detail needed to fully answer (e.g. you know a blog post was shared but only have a summary of it)
|
|
24331
24331
|
- You want to **verify or expand on** an observation before responding
|
|
24332
24332
|
- The answer depends on historical dates, order, or duration: verify both event dates and that they refer to the events the user means. Distinguish a plan, an actual start, a later update, and a repeated mention instead of choosing a nearby date from a summary
|
|
24333
24333
|
- An observation records something the assistant proposed, such as a schedule, date, or plan, and your observations don't show what the user decided. Read the raw messages around it to find the user's decision before treating the proposal as what happened
|
|
24334
24334
|
- Relevant details are missing, ambiguous, or conflicting in the current observations${isResource ? `
|
|
24335
|
-
- The user references another conversation that your observations don't cover
|
|
24335
|
+
- The user references another conversation that your observations don't cover \u2014 even if you have no observations yet, their other threads may contain it` : ""}
|
|
24336
24336
|
|
|
24337
24337
|
**Default to using recall when the user references specific past content.** Your observations capture the gist, not the details. If there's any doubt whether your memory is complete enough, use recall.
|
|
24338
24338
|
|
|
@@ -24367,17 +24367,17 @@ Each range has the format \`startId:endId\` where both are message IDs separated
|
|
|
24367
24367
|
In \`mode: "messages"\`, recall returns **low** detail by default: truncated text and tool names only. Each message shows its ID and each part has a positional index like \`[p0]\`, \`[p1]\`, etc.
|
|
24368
24368
|
|
|
24369
24369
|
- Use \`detail: "high"\` to get full message content including tool arguments and results. This will only return the high detail version of a single message part at a time.
|
|
24370
|
-
- Use \`partIndex\` with a cursor to fetch a single part at full detail
|
|
24370
|
+
- Use \`partIndex\` with a cursor to fetch a single part at full detail \u2014 for example, to read one specific tool result or code block without loading every part.
|
|
24371
24371
|
|
|
24372
24372
|
If the result says \`truncated: true\`, the output was cut to fit the token budget. You can paginate or use \`partIndex\` to target specific content. If a single part is itself too large, follow the returned \`nextCharOffset\` as described below.
|
|
24373
24373
|
|
|
24374
24374
|
### Following up on truncated parts
|
|
24375
24375
|
Low-detail results may include truncation hints like:
|
|
24376
|
-
\`[truncated
|
|
24376
|
+
\`[truncated \u2014 call recall cursor="..." partIndex=N detail="high" for full content]\`
|
|
24377
24377
|
|
|
24378
24378
|
**When you see these hints and need the full content, make the exact call described in the hint.** This is the normal workflow: first recall at low detail to scan, then drill into specific parts at high detail. Do not stop at the low-detail result if the user asked for exact content.
|
|
24379
24379
|
|
|
24380
|
-
If a single part is larger than the token budget, the \`partIndex\` result is \`truncated: true\` and includes \`nextCharOffset\`. Repeat the same call with \`charOffset\` set to that exact value to read the next chunk from where the previous one ended. Keep following \`nextCharOffset\` until the result no longer includes it
|
|
24380
|
+
If a single part is larger than the token budget, the \`partIndex\` result is \`truncated: true\` and includes \`nextCharOffset\`. Repeat the same call with \`charOffset\` set to that exact value to read the next chunk from where the previous one ended. Keep following \`nextCharOffset\` until the result no longer includes it \u2014 the chunks together contain the full part. Retrying without \`charOffset\` returns the same prefix again.
|
|
24381
24381
|
|
|
24382
24382
|
### When recall is NOT needed
|
|
24383
24383
|
- The user is asking for a high-level summary and your observations already cover it
|
|
@@ -24774,6 +24774,15 @@ function buildThreadMetadataFromExtractedValues(extractors, values) {
|
|
|
24774
24774
|
async function applyExtractorHooks(opts) {
|
|
24775
24775
|
const values = normalizeExtractedValues(opts.values) ?? {};
|
|
24776
24776
|
const failures = [...opts.failures ?? []];
|
|
24777
|
+
let recentMessages;
|
|
24778
|
+
let recentMessagesResolved = false;
|
|
24779
|
+
const resolveRecentMessages = () => {
|
|
24780
|
+
if (!recentMessagesResolved) {
|
|
24781
|
+
recentMessages = typeof opts.recentMessages === "function" ? opts.recentMessages() : opts.recentMessages;
|
|
24782
|
+
recentMessagesResolved = true;
|
|
24783
|
+
}
|
|
24784
|
+
return recentMessages;
|
|
24785
|
+
};
|
|
24777
24786
|
for (const extractor of opts.extractors) {
|
|
24778
24787
|
const isHook = extractor.mode === "hook";
|
|
24779
24788
|
const hasValue = Object.prototype.hasOwnProperty.call(values, extractor.slug);
|
|
@@ -24793,7 +24802,9 @@ async function applyExtractorHooks(opts) {
|
|
|
24793
24802
|
previous: isHook ? void 0 : opts.previousValues?.[extractor.slug],
|
|
24794
24803
|
current,
|
|
24795
24804
|
rawObservations: opts.rawObservations,
|
|
24796
|
-
recentMessages
|
|
24805
|
+
get recentMessages() {
|
|
24806
|
+
return resolveRecentMessages();
|
|
24807
|
+
},
|
|
24797
24808
|
mainAgent: opts.mainAgent,
|
|
24798
24809
|
memory: opts.memory,
|
|
24799
24810
|
sendSignal: opts.sendSignal,
|
|
@@ -25552,7 +25563,7 @@ const YEAR = String.raw`(?:19|20|21)\d{2}(?!\d)`;
|
|
|
25552
25563
|
const MERIDIEM = String.raw`(?:[AaPp]\.[Mm]\.|[AaPp][Mm]\b)`;
|
|
25553
25564
|
const TIME = String.raw`(?:,?\s+(?:at\s+)?\d{1,2}:\d{2}(?:\s*${MERIDIEM})?|\s+at\s+\d{1,2}\s*${MERIDIEM})`;
|
|
25554
25565
|
const QUALIFIER = String.raw`(?:(?:early|mid|late)[- ](?:to[- ](?:early|mid|late)[- ])?)`;
|
|
25555
|
-
const RANGE_SEP = String.raw`(?:\s*[
|
|
25566
|
+
const RANGE_SEP = String.raw`(?:\s*[\u2013\u2014]\s*|\s*-\s*|\s+(?:to|through|until)\s+)`;
|
|
25556
25567
|
/**
|
|
25557
25568
|
* Dates written into observation text that carry their own year, longest forms first:
|
|
25558
25569
|
* "Mar 1 - Mar 18, 2025", "May 27-28, 2023", "January 10, 2024 at 3:00 PM",
|
|
@@ -25855,15 +25866,15 @@ const SHORT_TOKEN_THRESHOLD = 3;
|
|
|
25855
25866
|
const KANA_CHARS_PER_TOKEN = 1.35;
|
|
25856
25867
|
const DEFAULT_LANGUAGE_CONFIGS = [
|
|
25857
25868
|
{
|
|
25858
|
-
pattern: /[
|
|
25869
|
+
pattern: /[\u00E4\u00F6\u00FC\u00DF\u1E9E]/i,
|
|
25859
25870
|
averageCharsPerToken: 2.6
|
|
25860
25871
|
},
|
|
25861
25872
|
{
|
|
25862
|
-
pattern: /[
|
|
25873
|
+
pattern: /[\u00E9\u00E8\u00EA\u00EB\u00E0\u00E2\u00EE\u00EF\u00F4\u00FB\u00F9\u00FC\u00FF\u00E7\u0153\u00E6\u00E1\u00ED\u00F3\u00FA\u00F1]/i,
|
|
25863
25874
|
averageCharsPerToken: 3
|
|
25864
25875
|
},
|
|
25865
25876
|
{
|
|
25866
|
-
pattern: /[
|
|
25877
|
+
pattern: /[\u0105\u0107\u0119\u0142\u0144\u00F3\u015B\u017A\u017C\u011B\u0161\u010D\u0159\u017E\u00FD\u016F\u00FA\u010F\u0165\u0148]/i,
|
|
25867
25878
|
averageCharsPerToken: 2.5
|
|
25868
25879
|
},
|
|
25869
25880
|
{
|
|
@@ -25952,10 +25963,10 @@ function sanitizeSurrogates(value) {
|
|
|
25952
25963
|
if (next >= 56320 && next <= 57343) {
|
|
25953
25964
|
sanitized += value.charAt(index) + value.charAt(index + 1);
|
|
25954
25965
|
index++;
|
|
25955
|
-
} else sanitized += "
|
|
25966
|
+
} else sanitized += "\uFFFD";
|
|
25956
25967
|
continue;
|
|
25957
25968
|
}
|
|
25958
|
-
sanitized += code >= 56320 && code <= 57343 ? "
|
|
25969
|
+
sanitized += code >= 56320 && code <= 57343 ? "\uFFFD" : value[index];
|
|
25959
25970
|
}
|
|
25960
25971
|
return sanitized;
|
|
25961
25972
|
}
|
|
@@ -25977,7 +25988,7 @@ function truncatePath(path) {
|
|
|
25977
25988
|
const headLength = 50;
|
|
25978
25989
|
const tailLength = 60;
|
|
25979
25990
|
const omitted = path.length - headLength - tailLength;
|
|
25980
|
-
return `${safeSlice(path, headLength)}
|
|
25991
|
+
return `${safeSlice(path, headLength)}\u2026[${omitted} chars; ${stablePathDigest(path)}]\u2026${safeTail(path, tailLength)}`;
|
|
25981
25992
|
}
|
|
25982
25993
|
function formatPath(parent, key, isArray) {
|
|
25983
25994
|
if (isArray) return truncatePath(`${parent}[${key}]`);
|
|
@@ -26086,7 +26097,7 @@ function selectOutlineEntries(entries, limits) {
|
|
|
26086
26097
|
const rendered = joinEntries(selected, marker);
|
|
26087
26098
|
if (fits(rendered, limits)) return rendered;
|
|
26088
26099
|
if (fits(marker, limits)) return marker;
|
|
26089
|
-
return fits("
|
|
26100
|
+
return fits("\u2026", limits) ? "\u2026" : "";
|
|
26090
26101
|
}
|
|
26091
26102
|
function indentPreview(value) {
|
|
26092
26103
|
return value.split("\n").map((line) => ` | ${line}`).join("\n");
|
|
@@ -26129,13 +26140,13 @@ function formatToolArgumentsForObserver(value, options) {
|
|
|
26129
26140
|
if (!isObjectLike$1(value)) {
|
|
26130
26141
|
if (typeof value !== "string" || value.length <= OBSERVER_TOOL_ARGUMENT_INLINE_STRING_MAX_CHARS) {
|
|
26131
26142
|
const primitive = formatPrimitive(value);
|
|
26132
|
-
return fits(primitive, limits) ? primitive : fits("
|
|
26143
|
+
return fits(primitive, limits) ? primitive : fits("\u2026", limits) ? "\u2026" : "";
|
|
26133
26144
|
}
|
|
26134
26145
|
const summary = `<string, ${value.length} characters; preview size-limited>`;
|
|
26135
26146
|
const rendered = appendWithinBudget(summary, formatPreview("preview", value, limits, summary), limits);
|
|
26136
26147
|
if (rendered) return rendered;
|
|
26137
26148
|
if (fits(summary, limits)) return summary;
|
|
26138
|
-
return fits("
|
|
26149
|
+
return fits("\u2026", limits) ? "\u2026" : "";
|
|
26139
26150
|
}
|
|
26140
26151
|
const outline = [];
|
|
26141
26152
|
const previews = [];
|
|
@@ -26381,24 +26392,24 @@ function formatToolResultForObserver(value, options) {
|
|
|
26381
26392
|
const OBSERVER_EXTRACTION_INSTRUCTIONS = `CRITICAL: DISTINGUISH USER ASSERTIONS FROM QUESTIONS
|
|
26382
26393
|
|
|
26383
26394
|
When the user TELLS you something about themselves, mark it as an assertion:
|
|
26384
|
-
- "I have two kids"
|
|
26385
|
-
- "I work at Acme Corp"
|
|
26386
|
-
- "I graduated in 2019"
|
|
26395
|
+
- "I have two kids" \u2192 \u{1F534} (14:30) User stated has two kids
|
|
26396
|
+
- "I work at Acme Corp" \u2192 \u{1F534} (14:31) User stated works at Acme Corp
|
|
26397
|
+
- "I graduated in 2019" \u2192 \u{1F534} (14:32) User stated graduated in 2019
|
|
26387
26398
|
|
|
26388
26399
|
When the user ASKS about something, mark it as a question/request:
|
|
26389
|
-
- "Can you help me with X?"
|
|
26390
|
-
- "What's the best way to do Y?"
|
|
26400
|
+
- "Can you help me with X?" \u2192 \u{1F534} (15:00) User asked help with X
|
|
26401
|
+
- "What's the best way to do Y?" \u2192 \u{1F534} (15:01) User asked best way to do Y
|
|
26391
26402
|
|
|
26392
26403
|
Distinguish between QUESTIONS and STATEMENTS OF INTENT:
|
|
26393
|
-
- "Can you recommend..."
|
|
26394
|
-
- "I'm looking forward to [doing X]"
|
|
26395
|
-
- "I need to [do X]"
|
|
26404
|
+
- "Can you recommend..." \u2192 Question (extract as "User asked...")
|
|
26405
|
+
- "I'm looking forward to [doing X]" \u2192 Statement of intent (extract as "User stated they will [do X] (include estimated/actual date if mentioned)")
|
|
26406
|
+
- "I need to [do X]" \u2192 Statement of intent (extract as "User stated they need to [do X] (again, add date if mentioned)")
|
|
26396
26407
|
|
|
26397
26408
|
STATE CHANGES AND UPDATES:
|
|
26398
26409
|
When a user indicates they are changing something, frame it as a state change that supersedes previous information:
|
|
26399
|
-
- "I'm going to start doing X instead of Y"
|
|
26400
|
-
- "I'm switching from A to B"
|
|
26401
|
-
- "I moved my stuff to the new place"
|
|
26410
|
+
- "I'm going to start doing X instead of Y" \u2192 "User will start doing X (changing from Y)"
|
|
26411
|
+
- "I'm switching from A to B" \u2192 "User is switching from A to B"
|
|
26412
|
+
- "I moved my stuff to the new place" \u2192 "User moved their stuff to the new place (no longer at previous location)"
|
|
26402
26413
|
|
|
26403
26414
|
If the new state contradicts or updates previous information, make that explicit:
|
|
26404
26415
|
- BAD: "User plans to use the new method"
|
|
@@ -26489,11 +26500,11 @@ BAD: User got something.
|
|
|
26489
26500
|
GOOD: User purchased / received / was given something. (be specific)
|
|
26490
26501
|
|
|
26491
26502
|
Common clarifications:
|
|
26492
|
-
- "getting" something regularly
|
|
26493
|
-
- "getting" something once
|
|
26494
|
-
- "got"
|
|
26495
|
-
- "signed up"
|
|
26496
|
-
- "stopped getting"
|
|
26503
|
+
- "getting" something regularly \u2192 "subscribed to" or "enrolled in"
|
|
26504
|
+
- "getting" something once \u2192 "purchased" or "acquired"
|
|
26505
|
+
- "got" \u2192 "purchased", "received as gift", "was given", "picked up"
|
|
26506
|
+
- "signed up" \u2192 "enrolled in", "registered for", "subscribed to"
|
|
26507
|
+
- "stopped getting" \u2192 "canceled", "unsubscribed from", "discontinued"
|
|
26497
26508
|
|
|
26498
26509
|
When the assistant interprets or confirms the user's vague language, prefer the assistant's precise terminology.
|
|
26499
26510
|
|
|
@@ -26578,16 +26589,16 @@ AVOIDING REPETITIVE OBSERVATIONS:
|
|
|
26578
26589
|
- Do NOT repeat the same observation across multiple turns if there is no new information.
|
|
26579
26590
|
- When the agent performs repeated similar actions (e.g., browsing files, running the same tool type multiple times), group them into a single parent observation with sub-bullets for each new result.
|
|
26580
26591
|
|
|
26581
|
-
Example
|
|
26582
|
-
*
|
|
26583
|
-
*
|
|
26584
|
-
*
|
|
26592
|
+
Example \u2014 BAD (repetitive):
|
|
26593
|
+
* \u{1F7E1} (14:30) Agent used view tool on src/auth.ts
|
|
26594
|
+
* \u{1F7E1} (14:31) Agent used view tool on src/users.ts
|
|
26595
|
+
* \u{1F7E1} (14:32) Agent used view tool on src/routes.ts
|
|
26585
26596
|
|
|
26586
|
-
Example
|
|
26587
|
-
*
|
|
26588
|
-
* -> viewed src/auth.ts
|
|
26589
|
-
* -> viewed src/users.ts
|
|
26590
|
-
* -> viewed src/routes.ts
|
|
26597
|
+
Example \u2014 GOOD (grouped):
|
|
26598
|
+
* \u{1F7E1} (14:30) Agent browsed source files for auth flow
|
|
26599
|
+
* -> viewed src/auth.ts \u2014 found token validation logic
|
|
26600
|
+
* -> viewed src/users.ts \u2014 found user lookup by email
|
|
26601
|
+
* -> viewed src/routes.ts \u2014 found middleware chain
|
|
26591
26602
|
|
|
26592
26603
|
Only add a new observation for a repeated action if the NEW result changes the picture.
|
|
26593
26604
|
|
|
@@ -26600,29 +26611,29 @@ COMPLETION TRACKING:
|
|
|
26600
26611
|
Completion observations are not just summaries. They are explicit memory signals to the assistant that a task, question, or subtask has been resolved.
|
|
26601
26612
|
Without clear completion markers, the assistant may forget that work is already finished and may repeat, reopen, or continue an already-completed task.
|
|
26602
26613
|
|
|
26603
|
-
Use
|
|
26614
|
+
Use \u2705 to answer: "What exactly is now done?"
|
|
26604
26615
|
Choose completion observations that help the assistant know what is finished and should not be reworked unless new information appears.
|
|
26605
26616
|
|
|
26606
|
-
Use
|
|
26617
|
+
Use \u2705 when:
|
|
26607
26618
|
- The user explicitly confirms something worked or was answered ("thanks, that fixed it", "got it", "perfect")
|
|
26608
26619
|
- The assistant provided a definitive, complete answer to a factual question and the user moved on
|
|
26609
26620
|
- A multi-step task reached its stated goal
|
|
26610
26621
|
- The user acknowledged receipt of requested information
|
|
26611
26622
|
- A concrete subtask, fix, deliverable, or implementation step became complete during ongoing work
|
|
26612
26623
|
|
|
26613
|
-
Do NOT use
|
|
26614
|
-
- The assistant merely responded
|
|
26624
|
+
Do NOT use \u2705 when:
|
|
26625
|
+
- The assistant merely responded \u2014 the user might follow up with corrections
|
|
26615
26626
|
- The topic is paused but not resolved ("I'll try that later")
|
|
26616
26627
|
- The user's reaction is ambiguous
|
|
26617
26628
|
|
|
26618
26629
|
FORMAT:
|
|
26619
26630
|
As a sub-bullet under the related observation group:
|
|
26620
|
-
*
|
|
26631
|
+
* \u{1F534} (14:30) User asked how to configure auth middleware
|
|
26621
26632
|
* -> Agent explained JWT setup with code example
|
|
26622
|
-
*
|
|
26633
|
+
* \u2705 User confirmed auth is working
|
|
26623
26634
|
|
|
26624
26635
|
Or as a standalone observation when closing out a broader task:
|
|
26625
|
-
*
|
|
26636
|
+
* \u2705 (14:45) Auth configuration task completed \u2014 user confirmed middleware is working
|
|
26626
26637
|
|
|
26627
26638
|
Completion observations should be terse but specific about WHAT was completed.
|
|
26628
26639
|
Prefer concrete resolved outcomes over abstract workflow status so the assistant remembers what is already done.`;
|
|
@@ -26639,28 +26650,28 @@ buildObserverOutputFormat();
|
|
|
26639
26650
|
*/
|
|
26640
26651
|
function buildObserverOutputFormat(extractors) {
|
|
26641
26652
|
return `Use priority levels:
|
|
26642
|
-
-
|
|
26643
|
-
-
|
|
26644
|
-
-
|
|
26645
|
-
-
|
|
26653
|
+
- \u{1F534} High: explicit user facts, preferences, unresolved goals, critical context
|
|
26654
|
+
- \u{1F7E1} Medium: project details, learned information, tool results
|
|
26655
|
+
- \u{1F7E2} Low: minor details, uncertain observations
|
|
26656
|
+
- \u2705 Completed: concrete task finished, question answered, issue resolved, goal achieved, or subtask completed in a way that helps the assistant know it is done
|
|
26646
26657
|
|
|
26647
26658
|
Group related observations (like tool sequences) by indenting:
|
|
26648
|
-
*
|
|
26659
|
+
* \u{1F534} (14:33) Agent debugging auth issue
|
|
26649
26660
|
* -> ran git status, found 3 modified files
|
|
26650
26661
|
* -> viewed auth.ts:45-60, found missing null check
|
|
26651
26662
|
* -> applied fix, tests now pass
|
|
26652
|
-
*
|
|
26663
|
+
* \u2705 Tests passing, auth issue resolved
|
|
26653
26664
|
|
|
26654
26665
|
Group observations by date. Within a date, list observations in the order the events happened (not by importance), each with 24-hour time.
|
|
26655
26666
|
|
|
26656
26667
|
<observations>
|
|
26657
26668
|
Date: Dec 4, 2025
|
|
26658
|
-
*
|
|
26659
|
-
*
|
|
26660
|
-
*
|
|
26669
|
+
* \u{1F534} (14:30) User prefers direct answers
|
|
26670
|
+
* \u{1F534} (14:31) Working on feature X
|
|
26671
|
+
* \u{1F7E1} (14:32) User might prefer dark mode
|
|
26661
26672
|
|
|
26662
26673
|
Date: Dec 5, 2025
|
|
26663
|
-
*
|
|
26674
|
+
* \u{1F534} (09:15) Continued work on feature X
|
|
26664
26675
|
</observations>
|
|
26665
26676
|
|
|
26666
26677
|
${buildExtractorOutputSections(extractors ?? []) || (extractors === void 0 ? `
|
|
@@ -26690,9 +26701,9 @@ const OBSERVER_GUIDELINES = `- Be specific enough for the assistant to act on
|
|
|
26690
26701
|
- If the agent calls tools, observe what was called, why, and what was learned
|
|
26691
26702
|
- When observing files with line numbers, include the line number if useful
|
|
26692
26703
|
- If the agent provides a detailed response, observe the contents so it could be repeated
|
|
26693
|
-
- Make sure you start each observation with a priority emoji (
|
|
26694
|
-
- Capture the user's words closely
|
|
26695
|
-
- Treat
|
|
26704
|
+
- Make sure you start each observation with a priority emoji (\u{1F534}, \u{1F7E1}, \u{1F7E2}) or a completion marker (\u2705)
|
|
26705
|
+
- Capture the user's words closely \u2014 short/medium messages near-verbatim, long messages summarized with key quotes. User confirmations or explicit resolved outcomes should be \u2705 when they clearly signal something is done; unresolved or critical user facts remain \u{1F534}
|
|
26706
|
+
- Treat \u2705 as a memory signal that tells the assistant something is finished and should not be repeated unless new information changes it
|
|
26696
26707
|
- Make completion observations answer "What exactly is now done?"
|
|
26697
26708
|
- Prefer concrete resolved outcomes over meta-level workflow or bookkeeping updates
|
|
26698
26709
|
- When multiple concrete things were completed, capture the concrete completed work rather than collapsing it into a vague progress summary
|
|
@@ -26746,8 +26757,8 @@ For multi-thread output, wrap each thread's observations like this:
|
|
|
26746
26757
|
<observations>
|
|
26747
26758
|
<thread id="thread_id_1">
|
|
26748
26759
|
Date: Dec 4, 2025
|
|
26749
|
-
*
|
|
26750
|
-
*
|
|
26760
|
+
* \u{1F534} (14:30) User prefers direct answers
|
|
26761
|
+
* \u{1F534} (14:31) Working on feature X${currentTaskEnabled ? `
|
|
26751
26762
|
|
|
26752
26763
|
<current-task>
|
|
26753
26764
|
What the agent is currently working on in this thread
|
|
@@ -26760,7 +26771,7 @@ Hint for the agent's next message in this thread
|
|
|
26760
26771
|
|
|
26761
26772
|
<thread id="thread_id_2">
|
|
26762
26773
|
Date: Dec 5, 2025
|
|
26763
|
-
*
|
|
26774
|
+
* \u{1F534} (09:15) User asked about deployment${currentTaskEnabled ? `
|
|
26764
26775
|
|
|
26765
26776
|
<current-task>
|
|
26766
26777
|
Current task for this thread
|
|
@@ -27608,7 +27619,7 @@ function sanitizeObservationLines(observations) {
|
|
|
27608
27619
|
const lines = observations.split("\n");
|
|
27609
27620
|
let changed = false;
|
|
27610
27621
|
for (let i = 0; i < lines.length; i++) if (lines[i].length > MAX_OBSERVATION_LINE_CHARS) {
|
|
27611
|
-
lines[i] = safeSlice(lines[i], MAX_OBSERVATION_LINE_CHARS) + "
|
|
27622
|
+
lines[i] = safeSlice(lines[i], MAX_OBSERVATION_LINE_CHARS) + " \u2026 [truncated]";
|
|
27612
27623
|
changed = true;
|
|
27613
27624
|
}
|
|
27614
27625
|
return changed ? lines.join("\n") : observations;
|
|
@@ -27832,8 +27843,8 @@ function extractCurrentTask(observations) {
|
|
|
27832
27843
|
*/
|
|
27833
27844
|
function optimizeObservationsForContext(observations) {
|
|
27834
27845
|
let optimized = stripEphemeralAnchorIds(observations);
|
|
27835
|
-
optimized = optimized.replace(
|
|
27836
|
-
optimized = optimized.replace(
|
|
27846
|
+
optimized = optimized.replace(/\uD83D\uDFE1\s*/g, "");
|
|
27847
|
+
optimized = optimized.replace(/\uD83D\uDFE2\s*/g, "");
|
|
27837
27848
|
optimized = optimized.replace(/\s*->\s*/g, " ");
|
|
27838
27849
|
optimized = optimized.replace(/ +/g, " ");
|
|
27839
27850
|
optimized = optimized.replace(/\n{3,}/g, "\n\n");
|
|
@@ -30119,8 +30130,8 @@ const updateWorkingMemoryTool = (memoryConfig) => {
|
|
|
30119
30130
|
}
|
|
30120
30131
|
const usesMergeSemantics = Boolean(schema);
|
|
30121
30132
|
const useStateSignals = memoryConfig?.workingMemory?.useStateSignals === true;
|
|
30122
|
-
const stateSignalsPreamble = `The current working memory state is delivered to you each turn by the system inside a <working-memory>...</working-memory> block. That block is system-emitted state, NOT something the user typed
|
|
30123
|
-
const description = schema ? useStateSignals ? `${stateSignalsPreamble} Data is merged with existing memory
|
|
30133
|
+
const stateSignalsPreamble = `The current working memory state is delivered to you each turn by the system inside a <working-memory>...</working-memory> block. That block is system-emitted state, NOT something the user typed \u2014 never describe it as the user sharing it. Read from it directly when answering. Only call this tool when the user provides genuinely NEW or CHANGED facts that should be persisted; do NOT call it to re-save unchanged data.`;
|
|
30134
|
+
const description = schema ? useStateSignals ? `${stateSignalsPreamble} Data is merged with existing memory \u2014 only include fields you want to add or update.` : `Update the working memory with new information. Data is merged with existing memory - only include fields you want to add or update. To preserve existing data, omit the field entirely. Arrays are replaced entirely when provided, so pass the complete array or omit it to keep the existing values.` : useStateSignals ? `${stateSignalsPreamble} Pass the full updated Markdown blob as a string in the memory field.` : `Update the working memory with new information. Any data not included will be overwritten. Always pass data as string to the memory field. Never pass an object.`;
|
|
30124
30135
|
return (0, _mastra_core_tools.createTool)({
|
|
30125
30136
|
id: "update-working-memory",
|
|
30126
30137
|
description,
|
|
@@ -31151,8 +31162,8 @@ async function pageGroups({ om, threadId, resourceId, groupId, recordId, directi
|
|
|
31151
31162
|
})).count > 0;
|
|
31152
31163
|
const hasLater = direction === "before" || hasMore;
|
|
31153
31164
|
const newer = hasLater ? null : await newerMessagesNote(page.at(-1).group, countNewerMessages, pagingThreadId);
|
|
31154
|
-
text.unshift(hasEarlier ?
|
|
31155
|
-
text.push(hasLater ?
|
|
31165
|
+
text.unshift(hasEarlier ? `\u2014 Browse earlier: ${pagingCall(page[0].group.id, "before", pagingThreadId, page[0].record.id)} \u2014` : "\u2014 Start of retained observation history for this thread. \u2014");
|
|
31166
|
+
text.push(hasLater ? `\u2014 Browse later: ${pagingCall(page.at(-1).group.id, "after", pagingThreadId, page.at(-1).record.id)} \u2014` : newer ? `\u2014 End of observation history for this thread. ${newer} \u2014` : "\u2014 End of retained observation history for this thread. \u2014");
|
|
31156
31167
|
text.unshift(`### Observation page\nThread: ${threadTitle || "(untitled)"}\nShowing ${page.length} groups ${requestedDirection === void 0 ? "starting at" : `strictly ${direction}`} \`${groupId}\` (oldest first).`);
|
|
31157
31168
|
return {
|
|
31158
31169
|
results: text.join("\n\n"),
|
|
@@ -31340,7 +31351,7 @@ async function listThreadsForResource({ memory, resourceId, currentThreadId, pag
|
|
|
31340
31351
|
const title = thread.title || "(untitled)";
|
|
31341
31352
|
const updated = formatTimestamp(thread.updatedAt);
|
|
31342
31353
|
const created = formatTimestamp(thread.createdAt);
|
|
31343
|
-
const marker = isCurrent ? "
|
|
31354
|
+
const marker = isCurrent ? " \u2190 current" : "";
|
|
31344
31355
|
lines.push(`- **${title}**${marker}`);
|
|
31345
31356
|
lines.push(` id: ${thread.id}`);
|
|
31346
31357
|
lines.push(` updated: ${updated} | created: ${created}`);
|
|
@@ -31519,7 +31530,7 @@ async function searchMessagesForResource({ memory, om, resourceId, currentThread
|
|
|
31519
31530
|
const groupLine = match.groupId ? `- observation group: ${groupCursor(match.groupId, match.recordId)}` : void 0;
|
|
31520
31531
|
const scoreLine = `- score: ${match.score.toFixed(2)}`;
|
|
31521
31532
|
const prev = i > 0 ? ordered[i - 1].match : void 0;
|
|
31522
|
-
if (om && prev?.groupId && match.groupId && prev.threadId === match.threadId) sections.push(
|
|
31533
|
+
if (om && prev?.groupId && match.groupId && prev.threadId === match.threadId) sections.push(`\u2014 Observation groups may be hidden between these results; continue with ${pagingCall(prev.groupId, "after", includeThreadId ? prev.threadId : void 0, prev.recordId)} \u2014`);
|
|
31523
31534
|
if (suppression) {
|
|
31524
31535
|
sections.push(`${groupLine}\n thread: ${match.threadId}; ${suppression}`);
|
|
31525
31536
|
continue;
|
|
@@ -32074,7 +32085,7 @@ async function recallAttachmentView({ memory, threadId, resourceId, cursor, part
|
|
|
32074
32085
|
const partType = rawPart?.type;
|
|
32075
32086
|
if (!rawPart || partType !== "image" && partType !== "file") return { messages: `Part ${partIndex} of message ${cursor} is ${rawPart ? `a ${partType ?? "unknown"}-type part` : "missing"}, not an attachment. Call recall with the same cursor and partIndex without viewAttachment to read it.` };
|
|
32076
32087
|
const resolvedAttachment = resolveViewableAttachment(rawPart);
|
|
32077
|
-
if ("note" in resolvedAttachment) return { messages: `${formatAttachmentPart(partType, rawPart)}
|
|
32088
|
+
if ("note" in resolvedAttachment) return { messages: `${formatAttachmentPart(partType, rawPart)} \u2014 ${resolvedAttachment.note}` };
|
|
32078
32089
|
return { content: [{
|
|
32079
32090
|
type: "text",
|
|
32080
32091
|
text: formatAttachmentPart(partType, rawPart)
|
|
@@ -32477,7 +32488,7 @@ const recallTool = (_memoryConfig, options) => {
|
|
|
32477
32488
|
if (!thread) return { error: "Could not resolve current thread." };
|
|
32478
32489
|
if (isResourceScope && resourceId && thread.resourceId !== resourceId) throw new Error("Thread does not belong to the active resource");
|
|
32479
32490
|
return {
|
|
32480
|
-
threads: `- **${thread.title || "(untitled)"}**
|
|
32491
|
+
threads: `- **${thread.title || "(untitled)"}** \u2190 current\n id: ${thread.id}\n updated: ${formatTimestamp(thread.updatedAt)} | created: ${formatTimestamp(thread.createdAt)}`,
|
|
32481
32492
|
count: 1,
|
|
32482
32493
|
page: 0,
|
|
32483
32494
|
hasMore: false
|
|
@@ -33048,6 +33059,79 @@ var BufferingCoordinator = class BufferingCoordinator {
|
|
|
33048
33059
|
* Key format: "refl:{lockKey}"
|
|
33049
33060
|
*/
|
|
33050
33061
|
static reflectionBufferCycleIds = /* @__PURE__ */ new Map();
|
|
33062
|
+
/**
|
|
33063
|
+
* The buffered-reflection op that set the reflection boundary and cycle, and the generation
|
|
33064
|
+
* it buffers for. Key format: "refl:{lockKey}"
|
|
33065
|
+
*/
|
|
33066
|
+
static reflectionBufferOwners = /* @__PURE__ */ new Map();
|
|
33067
|
+
/** Set the reflection boundary for a new buffered-reflection op on generation `recordId`. */
|
|
33068
|
+
static startReflectionBuffer(bufferKey, tokens, recordId) {
|
|
33069
|
+
const owner = {
|
|
33070
|
+
recordId,
|
|
33071
|
+
retired: false
|
|
33072
|
+
};
|
|
33073
|
+
BufferingCoordinator.lastBufferedBoundary.set(bufferKey, tokens);
|
|
33074
|
+
BufferingCoordinator.reflectionBufferOwners.set(bufferKey, owner);
|
|
33075
|
+
return owner;
|
|
33076
|
+
}
|
|
33077
|
+
/** Drop this process's reflection boundary, cycle, and owner. */
|
|
33078
|
+
static clearReflectionBuffer(bufferKey) {
|
|
33079
|
+
BufferingCoordinator.lastBufferedBoundary.delete(bufferKey);
|
|
33080
|
+
BufferingCoordinator.reflectionBufferCycleIds.delete(bufferKey);
|
|
33081
|
+
BufferingCoordinator.reflectionBufferOwners.delete(bufferKey);
|
|
33082
|
+
}
|
|
33083
|
+
/**
|
|
33084
|
+
* Another writer retired generation `recordId`, so a buffer this process prepared for it can
|
|
33085
|
+
* never activate. Its boundary and cycle are dropped now, or, while the op that set them is
|
|
33086
|
+
* still running (it may be awaiting its `onReflectionEnd` hook), when that op finishes. State
|
|
33087
|
+
* owned by a newer generation is kept.
|
|
33088
|
+
*/
|
|
33089
|
+
static retireReflectionBuffer(bufferKey, recordId) {
|
|
33090
|
+
const owner = BufferingCoordinator.reflectionBufferOwners.get(bufferKey);
|
|
33091
|
+
if (owner && owner.recordId !== recordId) return;
|
|
33092
|
+
if (owner && BufferingCoordinator.asyncBufferingOps.has(bufferKey)) {
|
|
33093
|
+
owner.retired = true;
|
|
33094
|
+
return;
|
|
33095
|
+
}
|
|
33096
|
+
BufferingCoordinator.clearReflectionBuffer(bufferKey);
|
|
33097
|
+
}
|
|
33098
|
+
/**
|
|
33099
|
+
* Reconcile this process's reflection buffer state against an observed head record.
|
|
33100
|
+
* Whenever `head.id` differs from `owner.recordId`, confirm against a fresh storage read started
|
|
33101
|
+
* after `owner` existed (never trusting `generationCount`, which resets to 0 after `clear()`):
|
|
33102
|
+
* only retire/clear when storage's live head is no longer `owner.recordId`.
|
|
33103
|
+
*/
|
|
33104
|
+
static async reconcileReflectionBufferHead(bufferKey, headId, readLiveHead) {
|
|
33105
|
+
const owner = BufferingCoordinator.reflectionBufferOwners.get(bufferKey);
|
|
33106
|
+
if (!owner || owner.recordId === headId) return;
|
|
33107
|
+
const ownerRecordId = owner.recordId;
|
|
33108
|
+
const live = await readLiveHead();
|
|
33109
|
+
if (BufferingCoordinator.reflectionBufferOwners.get(bufferKey) !== owner || owner.recordId !== ownerRecordId) return;
|
|
33110
|
+
if (live?.id === ownerRecordId) return;
|
|
33111
|
+
if (BufferingCoordinator.asyncBufferingOps.has(bufferKey)) {
|
|
33112
|
+
owner.retired = true;
|
|
33113
|
+
return;
|
|
33114
|
+
}
|
|
33115
|
+
BufferingCoordinator.clearReflectionBuffer(bufferKey);
|
|
33116
|
+
}
|
|
33117
|
+
/**
|
|
33118
|
+
* Take the buffered-reflection cycle id for generation `recordId` and release its
|
|
33119
|
+
* coordinator state after its buffer activates. State owned by another generation
|
|
33120
|
+
* is left untouched.
|
|
33121
|
+
*/
|
|
33122
|
+
static consumeReflectionBuffer(bufferKey, recordId) {
|
|
33123
|
+
const owner = BufferingCoordinator.reflectionBufferOwners.get(bufferKey);
|
|
33124
|
+
if (owner && owner.recordId !== recordId) return void 0;
|
|
33125
|
+
const cycleId = BufferingCoordinator.reflectionBufferCycleIds.get(bufferKey);
|
|
33126
|
+
if (owner && BufferingCoordinator.asyncBufferingOps.has(bufferKey)) owner.retired = true;
|
|
33127
|
+
else BufferingCoordinator.clearReflectionBuffer(bufferKey);
|
|
33128
|
+
return cycleId;
|
|
33129
|
+
}
|
|
33130
|
+
/** Called when the op that started as `owner` finishes; completes a deferred retirement. */
|
|
33131
|
+
static finishReflectionBuffer(bufferKey, owner) {
|
|
33132
|
+
if (BufferingCoordinator.reflectionBufferOwners.get(bufferKey) !== owner) return;
|
|
33133
|
+
if (owner.retired) BufferingCoordinator.clearReflectionBuffer(bufferKey);
|
|
33134
|
+
}
|
|
33051
33135
|
constructor(opts) {
|
|
33052
33136
|
this.observationConfig = opts.observationConfig;
|
|
33053
33137
|
this.reflectionConfig = opts.reflectionConfig;
|
|
@@ -33103,6 +33187,7 @@ var BufferingCoordinator = class BufferingCoordinator {
|
|
|
33103
33187
|
BufferingCoordinator.asyncBufferingOps.delete(obsBufKey);
|
|
33104
33188
|
BufferingCoordinator.asyncBufferingOps.delete(reflBufKey);
|
|
33105
33189
|
BufferingCoordinator.reflectionBufferCycleIds.delete(reflBufKey);
|
|
33190
|
+
BufferingCoordinator.reflectionBufferOwners.delete(reflBufKey);
|
|
33106
33191
|
}
|
|
33107
33192
|
}
|
|
33108
33193
|
/**
|
|
@@ -33163,9 +33248,9 @@ const suggestedResponseInstructions = `Hint for the agent's immediate next messa
|
|
|
33163
33248
|
- "The assistant should wait for the user to respond before continuing."
|
|
33164
33249
|
- Call the view tool on src/example.ts to continue debugging.`;
|
|
33165
33250
|
const threadTitleInstructions = `A short, noun-phrase title for this conversation (2-5 words). Examples:
|
|
33166
|
-
- "Auth bug fix"
|
|
33167
|
-
- "Dark mode toggle"
|
|
33168
|
-
- "Deployment pipeline setup"
|
|
33251
|
+
- "Auth bug fix" \u2014 not "Fixing the auth bug"
|
|
33252
|
+
- "Dark mode toggle" \u2014 not "User wants dark mode toggle added"
|
|
33253
|
+
- "Deployment pipeline setup" \u2014 not "Setting up deployment pipeline for project"
|
|
33169
33254
|
Only update when the topic meaningfully changes.`;
|
|
33170
33255
|
function createCurrentTaskExtractor() {
|
|
33171
33256
|
return new Extractor({
|
|
@@ -34242,7 +34327,7 @@ var SyncObservationStrategy = class extends ObservationStrategy {
|
|
|
34242
34327
|
failures: result.extractionFailures,
|
|
34243
34328
|
previousValues: this.priorExtractedValues,
|
|
34244
34329
|
rawObservations: result.observations,
|
|
34245
|
-
recentMessages: formatMessagesForObserver(this.opts.messages, {
|
|
34330
|
+
recentMessages: () => formatMessagesForObserver(this.opts.messages, {
|
|
34246
34331
|
maxPartLength: 500,
|
|
34247
34332
|
timeZone: this.opts.record.observedTimezone
|
|
34248
34333
|
}),
|
|
@@ -34467,7 +34552,7 @@ var AsyncBufferObservationStrategy = class extends ObservationStrategy {
|
|
|
34467
34552
|
failures: result.extractionFailures,
|
|
34468
34553
|
previousValues: this.priorExtractedValues,
|
|
34469
34554
|
rawObservations: result.observations,
|
|
34470
|
-
recentMessages: formatMessagesForObserver(messages, {
|
|
34555
|
+
recentMessages: () => formatMessagesForObserver(messages, {
|
|
34471
34556
|
maxPartLength: 500,
|
|
34472
34557
|
timeZone: this.opts.record.observedTimezone
|
|
34473
34558
|
}),
|
|
@@ -34897,7 +34982,7 @@ var ResourceScopedObservationStrategy = class extends ObservationStrategy {
|
|
|
34897
34982
|
failures: result.extractionFailures,
|
|
34898
34983
|
previousValues,
|
|
34899
34984
|
rawObservations: result.observations,
|
|
34900
|
-
recentMessages: formatMessagesForObserver(threadMessages, {
|
|
34985
|
+
recentMessages: () => formatMessagesForObserver(threadMessages, {
|
|
34901
34986
|
maxPartLength: 500,
|
|
34902
34987
|
timeZone: this.opts.record.observedTimezone
|
|
34903
34988
|
}),
|
|
@@ -35230,7 +35315,7 @@ var ObservationStep = class {
|
|
|
35230
35315
|
}
|
|
35231
35316
|
/** Step context from prepare(). Throws if prepare() hasn't been called. */
|
|
35232
35317
|
get context() {
|
|
35233
|
-
if (!this._context) throw new Error("Step not prepared yet
|
|
35318
|
+
if (!this._context) throw new Error("Step not prepared yet \u2014 call prepare() first");
|
|
35234
35319
|
return this._context;
|
|
35235
35320
|
}
|
|
35236
35321
|
/**
|
|
@@ -35650,7 +35735,7 @@ var ObservationStep = class {
|
|
|
35650
35735
|
const messagesToSeal = messageToSeal ? [messageToSeal] : [];
|
|
35651
35736
|
this.turn.abortSignal?.throwIfAborted();
|
|
35652
35737
|
om.sealMessagesForBuffering(messagesToSeal);
|
|
35653
|
-
if (this.seededResponseMessage) omDebug("[OM:observe] skipping response-id rotation
|
|
35738
|
+
if (this.seededResponseMessage) omDebug("[OM:observe] skipping response-id rotation \u2014 step-0 seeded response message holds the active id");
|
|
35654
35739
|
else try {
|
|
35655
35740
|
await this.turn.hooks?.onSyncObservationComplete?.();
|
|
35656
35741
|
} catch (error) {
|
|
@@ -35801,12 +35886,12 @@ var ObservationTurn = class {
|
|
|
35801
35886
|
messageList;
|
|
35802
35887
|
/** The current cached record. Refreshed after mutations (activate/observe/reflect). */
|
|
35803
35888
|
get record() {
|
|
35804
|
-
if (!this._record) throw new Error("Turn not started
|
|
35889
|
+
if (!this._record) throw new Error("Turn not started \u2014 call start() first");
|
|
35805
35890
|
return this._record;
|
|
35806
35891
|
}
|
|
35807
35892
|
/** The context loaded during start(). */
|
|
35808
35893
|
get context() {
|
|
35809
|
-
if (!this._context) throw new Error("Turn not started
|
|
35894
|
+
if (!this._context) throw new Error("Turn not started \u2014 call start() first");
|
|
35810
35895
|
return this._context;
|
|
35811
35896
|
}
|
|
35812
35897
|
/** Whether the turn has been ended and can no longer accept steps. */
|
|
@@ -35875,7 +35960,7 @@ var ObservationTurn = class {
|
|
|
35875
35960
|
* (its output messages will be saved at the start of the new step's prepare()).
|
|
35876
35961
|
*/
|
|
35877
35962
|
step(stepNumber) {
|
|
35878
|
-
if (!this._started) throw new Error("Turn not started
|
|
35963
|
+
if (!this._started) throw new Error("Turn not started \u2014 call start() first");
|
|
35879
35964
|
if (this._ended) throw new Error("Turn already ended");
|
|
35880
35965
|
this._currentStep = new ObservationStep(this, stepNumber);
|
|
35881
35966
|
return this._currentStep;
|
|
@@ -35970,6 +36055,80 @@ var ObservationTurn = class {
|
|
|
35970
36055
|
};
|
|
35971
36056
|
}
|
|
35972
36057
|
};
|
|
36058
|
+
// src/processors/observational-memory/buffered-reflection-values.ts
|
|
36059
|
+
const pendingValuesBaseSchema = zod.z.object({
|
|
36060
|
+
recordId: zod.z.string(),
|
|
36061
|
+
reflectedObservationLineCount: zod.z.number(),
|
|
36062
|
+
values: zod.z.record(zod.z.string(), zod.z.unknown())
|
|
36063
|
+
});
|
|
36064
|
+
const pendingValuesSchema = zod.z.union([pendingValuesBaseSchema.extend({
|
|
36065
|
+
reflectionDigest: zod.z.string().regex(/^[a-f0-9]{64}$/),
|
|
36066
|
+
reflection: zod.z.never().optional()
|
|
36067
|
+
}), pendingValuesBaseSchema.extend({
|
|
36068
|
+
reflection: zod.z.string(),
|
|
36069
|
+
reflectionDigest: zod.z.never().optional()
|
|
36070
|
+
})]);
|
|
36071
|
+
const metadataSchema = zod.z.record(zod.z.string(), zod.z.unknown());
|
|
36072
|
+
function reflectionDigest(reflection) {
|
|
36073
|
+
return (0, crypto$1.createHash)("sha256").update(reflection).digest("hex");
|
|
36074
|
+
}
|
|
36075
|
+
function getMastraMetadata(metadata) {
|
|
36076
|
+
const parsed = metadataSchema.safeParse(metadata?.mastra);
|
|
36077
|
+
return parsed.success ? parsed.data : {};
|
|
36078
|
+
}
|
|
36079
|
+
/** Keep prepared values outside active OM metadata, durable across Memory instances. */
|
|
36080
|
+
async function stageBufferedReflectionValues(storage, record, values) {
|
|
36081
|
+
if (!record.threadId || !record.bufferedReflection) return;
|
|
36082
|
+
const digest = reflectionDigest(record.bufferedReflection);
|
|
36083
|
+
await storage.updateThreadMetadata({
|
|
36084
|
+
id: record.threadId,
|
|
36085
|
+
update: (thread) => ({
|
|
36086
|
+
...thread.metadata,
|
|
36087
|
+
mastra: {
|
|
36088
|
+
...getMastraMetadata(thread.metadata),
|
|
36089
|
+
omBufferedReflection: {
|
|
36090
|
+
recordId: record.id,
|
|
36091
|
+
reflectionDigest: digest,
|
|
36092
|
+
reflectedObservationLineCount: record.reflectedObservationLineCount ?? 0,
|
|
36093
|
+
values: values ?? {}
|
|
36094
|
+
}
|
|
36095
|
+
}
|
|
36096
|
+
})
|
|
36097
|
+
});
|
|
36098
|
+
}
|
|
36099
|
+
/** Called under the OM commit lock, only after this exact buffer was activated. */
|
|
36100
|
+
async function publishBufferedReflectionValues(storage, extractors, record) {
|
|
36101
|
+
if (!record.threadId || !record.bufferedReflection) return;
|
|
36102
|
+
const digest = reflectionDigest(record.bufferedReflection);
|
|
36103
|
+
await storage.updateThreadMetadata({
|
|
36104
|
+
id: record.threadId,
|
|
36105
|
+
update: (thread) => {
|
|
36106
|
+
const mastra = getMastraMetadata(thread.metadata);
|
|
36107
|
+
const parsed = pendingValuesSchema.safeParse(mastra.omBufferedReflection);
|
|
36108
|
+
if (!parsed.success) return;
|
|
36109
|
+
const pending = parsed.data;
|
|
36110
|
+
if (pending.recordId !== record.id || (pending.reflectionDigest !== void 0 ? pending.reflectionDigest !== digest : pending.reflection !== record.bufferedReflection) || pending.reflectedObservationLineCount !== (record.reflectedObservationLineCount ?? 0)) return;
|
|
36111
|
+
const update = buildThreadMetadataFromExtractedValues(extractors, pending.values);
|
|
36112
|
+
const previous = (0, _mastra_core_memory.getThreadOMMetadata)(thread.metadata);
|
|
36113
|
+
const metadata = (0, _mastra_core_memory.setThreadOMMetadata)(thread.metadata, {
|
|
36114
|
+
currentTask: update.currentTask ?? previous?.currentTask,
|
|
36115
|
+
suggestedResponse: update.suggestedResponse ?? previous?.suggestedResponse,
|
|
36116
|
+
threadTitle: update.threadTitle ?? previous?.threadTitle,
|
|
36117
|
+
extracted: {
|
|
36118
|
+
...previous?.extracted,
|
|
36119
|
+
...update.extracted
|
|
36120
|
+
}
|
|
36121
|
+
});
|
|
36122
|
+
return {
|
|
36123
|
+
...metadata,
|
|
36124
|
+
mastra: {
|
|
36125
|
+
...getMastraMetadata(metadata),
|
|
36126
|
+
omBufferedReflection: null
|
|
36127
|
+
}
|
|
36128
|
+
};
|
|
36129
|
+
}
|
|
36130
|
+
});
|
|
36131
|
+
}
|
|
35973
36132
|
// src/processors/observational-memory/reflector-agent.ts
|
|
35974
36133
|
/**
|
|
35975
36134
|
* Build the Reflector's system prompt.
|
|
@@ -36024,8 +36183,8 @@ When consolidating observations:
|
|
|
36024
36183
|
- Keep what the user explicitly said they have never done, do not know, or refused, and keep every stated preference, rule, and instruction with its meaning intact
|
|
36025
36184
|
- Prefer many short factual lines over prose summaries. Do not replace facts with generalities like "discussed travel plans"
|
|
36026
36185
|
- Combine related items where it makes sense (e.g., "agent called view tool 5 times on file x")
|
|
36027
|
-
- Preserve
|
|
36028
|
-
- Preserve the concrete resolved outcome captured by
|
|
36186
|
+
- Preserve \u2705 completion markers \u2014 they are memory signals that tell the assistant what is already resolved and help prevent repeated work
|
|
36187
|
+
- Preserve the concrete resolved outcome captured by \u2705 markers so the assistant knows what exactly is done
|
|
36029
36188
|
- Condense the wording of older observations more than recent ones, but keep their facts
|
|
36030
36189
|
|
|
36031
36190
|
CRITICAL: USER ASSERTIONS vs QUESTIONS
|
|
@@ -36047,23 +36206,23 @@ When observations contain <thread id="..."> sections:
|
|
|
36047
36206
|
Example input:
|
|
36048
36207
|
<thread id="thread-1">
|
|
36049
36208
|
Date: Dec 4, 2025
|
|
36050
|
-
*
|
|
36051
|
-
*
|
|
36209
|
+
* \u{1F534} (14:30) User prefers TypeScript
|
|
36210
|
+
* \u{1F7E1} (14:35) Working on auth feature
|
|
36052
36211
|
</thread>
|
|
36053
36212
|
<thread id="thread-2">
|
|
36054
36213
|
Date: Dec 4, 2025
|
|
36055
|
-
*
|
|
36056
|
-
*
|
|
36214
|
+
* \u{1F534} (15:00) User prefers TypeScript
|
|
36215
|
+
* \u{1F7E1} (15:05) Debugging API endpoint
|
|
36057
36216
|
</thread>
|
|
36058
36217
|
|
|
36059
36218
|
Example output (consolidated):
|
|
36060
36219
|
Date: Dec 4, 2025
|
|
36061
|
-
*
|
|
36220
|
+
* \u{1F534} (14:30) User prefers TypeScript
|
|
36062
36221
|
<thread id="thread-1">
|
|
36063
|
-
*
|
|
36222
|
+
* \u{1F7E1} (14:35) Working on auth feature
|
|
36064
36223
|
</thread>
|
|
36065
36224
|
<thread id="thread-2">
|
|
36066
|
-
*
|
|
36225
|
+
* \u{1F7E1} (15:05) Debugging API endpoint
|
|
36067
36226
|
</thread>
|
|
36068
36227
|
|
|
36069
36228
|
=== OUTPUT FORMAT ===
|
|
@@ -36094,8 +36253,8 @@ Please re-process with slightly more compression:
|
|
|
36094
36253
|
- Memory is getting long - use a more condensed style throughout
|
|
36095
36254
|
- Combine related items more aggressively but do not lose important specific details of names, places, events, and people
|
|
36096
36255
|
- Combine repeated similar tool calls (e.g. multiple file views, searches, or edits in the same area) into a single summary line describing what was explored/changed and the outcome
|
|
36097
|
-
- Preserve
|
|
36098
|
-
- Preserve the concrete resolved outcome captured by
|
|
36256
|
+
- Preserve \u2705 completion markers \u2014 they are memory signals that tell the assistant what is already resolved and help prevent repeated work
|
|
36257
|
+
- Preserve the concrete resolved outcome captured by \u2705 markers so the assistant knows what exactly is done
|
|
36099
36258
|
|
|
36100
36259
|
Aim for a 8/10 detail level.
|
|
36101
36260
|
`,
|
|
@@ -36111,8 +36270,8 @@ Please re-process with much more aggressive compression:
|
|
|
36111
36270
|
- Combine related items aggressively but do not lose important specific details of names, places, events, and people
|
|
36112
36271
|
- Combine repeated similar tool calls (e.g. multiple file views, searches, or edits in the same area) into a single summary line describing what was explored/changed and the outcome
|
|
36113
36272
|
- If the same file or module is mentioned across many observations, merge into one entry covering the full arc
|
|
36114
|
-
- Preserve
|
|
36115
|
-
- Preserve the concrete resolved outcome captured by
|
|
36273
|
+
- Preserve \u2705 completion markers \u2014 they are memory signals that tell the assistant what is already resolved and help prevent repeated work
|
|
36274
|
+
- Preserve the concrete resolved outcome captured by \u2705 markers so the assistant knows what exactly is done
|
|
36116
36275
|
- Remove redundant information and merge overlapping observations
|
|
36117
36276
|
|
|
36118
36277
|
Aim for a 6/10 detail level.
|
|
@@ -36123,14 +36282,14 @@ Aim for a 6/10 detail level.
|
|
|
36123
36282
|
Your previous reflections have failed to compress sufficiently after multiple attempts.
|
|
36124
36283
|
|
|
36125
36284
|
Please re-process with maximum compression:
|
|
36126
|
-
- Summarize the oldest observations (first 50-70%) into brief high-level paragraphs
|
|
36285
|
+
- Summarize the oldest observations (first 50-70%) into brief high-level paragraphs \u2014 only key facts, decisions, and outcomes
|
|
36127
36286
|
- For the most recent observations (last 30-50%), retain important details but still use a condensed style
|
|
36128
|
-
- Ruthlessly merge related observations
|
|
36129
|
-
- Combine all tool call sequences (file views, searches, edits, builds) into outcome-only summaries
|
|
36130
|
-
- Drop procedural details (tool calls, retries, intermediate steps)
|
|
36287
|
+
- Ruthlessly merge related observations \u2014 if 10 observations are about the same topic, combine into 1-2 lines
|
|
36288
|
+
- Combine all tool call sequences (file views, searches, edits, builds) into outcome-only summaries \u2014 drop individual steps entirely
|
|
36289
|
+
- Drop procedural details (tool calls, retries, intermediate steps) \u2014 keep only final outcomes
|
|
36131
36290
|
- Drop observations that are no longer relevant or have been superseded by newer information
|
|
36132
|
-
- Preserve
|
|
36133
|
-
- Preserve the concrete resolved outcome captured by
|
|
36291
|
+
- Preserve \u2705 completion markers \u2014 they are memory signals that tell the assistant what is already resolved and help prevent repeated work
|
|
36292
|
+
- Preserve the concrete resolved outcome captured by \u2705 markers so the assistant knows what exactly is done
|
|
36134
36293
|
- Preserve: names, dates, decisions, errors, user preferences, and architectural choices
|
|
36135
36294
|
|
|
36136
36295
|
Aim for a 4/10 detail level.
|
|
@@ -36141,14 +36300,14 @@ Aim for a 4/10 detail level.
|
|
|
36141
36300
|
Multiple compression attempts have failed. The content may already be dense from a prior reflection.
|
|
36142
36301
|
|
|
36143
36302
|
You MUST dramatically reduce the number of observations while keeping the standard observation format (date groups with bullet points and priority emojis):
|
|
36144
|
-
- Tool call observations are the biggest source of bloat. Collapse ALL tool call sequences into outcome-only observations
|
|
36145
|
-
- Never preserve individual tool calls (viewed file X, searched for Y, ran build)
|
|
36303
|
+
- Tool call observations are the biggest source of bloat. Collapse ALL tool call sequences into outcome-only observations \u2014 e.g. 10 observations about viewing/searching/editing files become 1 observation about what was actually learned or achieved (e.g. "Investigated auth module and found token validation was skipping expiry check")
|
|
36304
|
+
- Never preserve individual tool calls (viewed file X, searched for Y, ran build) \u2014 only preserve what was discovered or accomplished
|
|
36146
36305
|
- Consolidate many related observations into single, more generic observations
|
|
36147
36306
|
- Merge all same-day date groups into at most 2-3 date groups per day
|
|
36148
36307
|
- For older content, each topic or task should be at most 1-2 observations capturing the key outcome
|
|
36149
36308
|
- For recent content, retain more detail but still merge related items aggressively
|
|
36150
36309
|
- If multiple observations describe incremental progress on the same task, keep only the final state
|
|
36151
|
-
- Preserve
|
|
36310
|
+
- Preserve \u2705 completion markers and their outcomes but merge related completions into fewer lines
|
|
36152
36311
|
- Preserve: user preferences, key decisions, architectural choices, and unresolved issues
|
|
36153
36312
|
|
|
36154
36313
|
Aim for a 2/10 detail level. Fewer, more generic observations are better than many specific ones that exceed the budget.
|
|
@@ -36329,6 +36488,15 @@ function isReflectionApplied(returned, newRecordId, reflectedRecordId) {
|
|
|
36329
36488
|
return returned.supersededBy === void 0 && returned.id !== reflectedRecordId;
|
|
36330
36489
|
}
|
|
36331
36490
|
/**
|
|
36491
|
+
* The active observations a buffered-reflection swap writes: the buffered reflection replaces the
|
|
36492
|
+
* first `reflectedLineCount` lines, and the trimmed remainder follows after a blank line. Mirrors
|
|
36493
|
+
* `swapBufferedReflectionToActive` in the storage adapters.
|
|
36494
|
+
*/
|
|
36495
|
+
function bufferedActivationText({ bufferedReflection, observations, reflectedLineCount }) {
|
|
36496
|
+
const unreflected = observations.split("\n").slice(reflectedLineCount).join("\n").trim();
|
|
36497
|
+
return unreflected ? `${bufferedReflection}\n\n${unreflected}` : bufferedReflection;
|
|
36498
|
+
}
|
|
36499
|
+
/**
|
|
36332
36500
|
* Runs the Reflector agent for compressing observations.
|
|
36333
36501
|
* Handles synchronous reflection, async buffered reflection, and activation.
|
|
36334
36502
|
*/
|
|
@@ -36563,7 +36731,7 @@ var ReflectorRunner = class {
|
|
|
36563
36731
|
operationType: "reflection",
|
|
36564
36732
|
startedAt: streamContext.startedAt,
|
|
36565
36733
|
tokensAttempted: originalTokens,
|
|
36566
|
-
error: `Did not compress below threshold (${originalTokens}
|
|
36734
|
+
error: `Did not compress below threshold (${originalTokens} \u2192 ${reflectedTokens}, target: ${targetThreshold}), retrying at level ${currentLevel + 1}`,
|
|
36567
36735
|
retrying: true,
|
|
36568
36736
|
recordId: streamContext.recordId,
|
|
36569
36737
|
threadId: streamContext.threadId
|
|
@@ -36593,7 +36761,7 @@ var ReflectorRunner = class {
|
|
|
36593
36761
|
}
|
|
36594
36762
|
currentLevel = Math.min(currentLevel + 1, maxLevel);
|
|
36595
36763
|
}
|
|
36596
|
-
if (observations.trim().length > 0 && parsed.observations.trim().length === 0) throw new Error(`Reflector produced empty output after ${attemptNumber} attempt(s)${parsed.degenerate ? " (degenerate repetition)" : ""}
|
|
36764
|
+
if (observations.trim().length > 0 && parsed.observations.trim().length === 0) throw new Error(`Reflector produced empty output after ${attemptNumber} attempt(s)${parsed.degenerate ? " (degenerate repetition)" : ""} \u2014 refusing to commit an empty reflection over ${originalTokens} observation tokens`);
|
|
36597
36765
|
const structuredExtraction = await extractStructuredValues({
|
|
36598
36766
|
agent,
|
|
36599
36767
|
source: "reflector",
|
|
@@ -36637,18 +36805,18 @@ var ReflectorRunner = class {
|
|
|
36637
36805
|
startAsyncBufferedReflection(record, observationTokens, lockKey, writer, requestContext, observabilityContext, reflectionHooks, priorExtractedValues, mainAgent, sendSignal, trigger, currentModel) {
|
|
36638
36806
|
const bufferKey = this.buffering.getReflectionBufferKey(lockKey);
|
|
36639
36807
|
if (this.buffering.isAsyncBufferingInProgress(bufferKey)) return;
|
|
36640
|
-
BufferingCoordinator.
|
|
36808
|
+
const owner = BufferingCoordinator.startReflectionBuffer(bufferKey, observationTokens, record.id);
|
|
36641
36809
|
registerOp(record.id, "bufferingReflection");
|
|
36642
36810
|
const flagSet = this.storage.setBufferingReflectionFlag(record.id, true).catch((err) => {
|
|
36643
36811
|
omError("[OM] Failed to set buffering reflection flag", err);
|
|
36644
36812
|
});
|
|
36645
|
-
const
|
|
36813
|
+
const run = async () => {
|
|
36646
36814
|
await flagSet;
|
|
36647
36815
|
let outcome;
|
|
36648
36816
|
let reflectionError;
|
|
36649
36817
|
try {
|
|
36650
36818
|
await reflectionHooks?.onReflectionStart?.();
|
|
36651
|
-
outcome = await this.doAsyncBufferedReflection(record, bufferKey, writer, requestContext, observabilityContext, priorExtractedValues, mainAgent, sendSignal, trigger, currentModel);
|
|
36819
|
+
outcome = await this.doAsyncBufferedReflection(record, bufferKey, owner, writer, requestContext, observabilityContext, priorExtractedValues, mainAgent, sendSignal, trigger, currentModel);
|
|
36652
36820
|
} catch (error) {
|
|
36653
36821
|
reflectionError = error instanceof Error ? error : new Error(String(error));
|
|
36654
36822
|
if (writer) try {
|
|
@@ -36671,7 +36839,7 @@ var ReflectorRunner = class {
|
|
|
36671
36839
|
omError("[OM] Failed to persist buffering-failed marker after async buffered reflection failure", markerError);
|
|
36672
36840
|
}
|
|
36673
36841
|
omError("[OM] Async buffered reflection failed", error);
|
|
36674
|
-
|
|
36842
|
+
owner.retired = true;
|
|
36675
36843
|
} finally {
|
|
36676
36844
|
try {
|
|
36677
36845
|
await reflectionHooks?.onReflectionEnd?.({
|
|
@@ -36682,13 +36850,15 @@ var ReflectorRunner = class {
|
|
|
36682
36850
|
} catch (hookError) {
|
|
36683
36851
|
omError("[OM] onReflectionEnd hook failed after async buffered reflection", hookError);
|
|
36684
36852
|
}
|
|
36685
|
-
BufferingCoordinator.
|
|
36853
|
+
BufferingCoordinator.finishReflectionBuffer(bufferKey, owner);
|
|
36854
|
+
if (BufferingCoordinator.asyncBufferingOps.get(bufferKey) === asyncOp) BufferingCoordinator.asyncBufferingOps.delete(bufferKey);
|
|
36686
36855
|
unregisterOp(record.id, "bufferingReflection");
|
|
36687
36856
|
await this.storage.setBufferingReflectionFlag(record.id, false).catch((err) => {
|
|
36688
36857
|
omError("[OM] Failed to clear buffering reflection flag", err);
|
|
36689
36858
|
});
|
|
36690
36859
|
}
|
|
36691
|
-
}
|
|
36860
|
+
};
|
|
36861
|
+
const asyncOp = run();
|
|
36692
36862
|
BufferingCoordinator.asyncBufferingOps.set(bufferKey, asyncOp);
|
|
36693
36863
|
this.trackBackgroundWork?.(asyncOp, lockKey);
|
|
36694
36864
|
}
|
|
@@ -36696,13 +36866,27 @@ var ReflectorRunner = class {
|
|
|
36696
36866
|
* Perform async buffered reflection — reflects observations and stores to bufferedReflection.
|
|
36697
36867
|
* Does NOT create a new generation or update activeObservations.
|
|
36698
36868
|
*/
|
|
36699
|
-
async doAsyncBufferedReflection(record, bufferKey, writer, requestContext, observabilityContext, priorExtractedValues, mainAgent, sendSignal, trigger, currentModel) {
|
|
36700
|
-
const
|
|
36869
|
+
async doAsyncBufferedReflection(record, bufferKey, owner, writer, requestContext, observabilityContext, priorExtractedValues, mainAgent, sendSignal, trigger, currentModel) {
|
|
36870
|
+
const freshRecord = await this.storage.getObservationalMemory(record.threadId, record.resourceId);
|
|
36871
|
+
if (BufferingCoordinator.reflectionBufferOwners.get(bufferKey) !== owner) {
|
|
36872
|
+
omDebug(`[OM:reflect] doAsyncBufferedReflection: ${bufferKey} was cleared while the op waited; stopping`);
|
|
36873
|
+
return;
|
|
36874
|
+
}
|
|
36875
|
+
const currentRecord = freshRecord ?? record;
|
|
36876
|
+
if (freshRecord?.bufferedReflection) {
|
|
36877
|
+
omDebug(`[OM:reflect] doAsyncBufferedReflection: live head ${freshRecord.id} already has a buffered reflection; skipping duplicate run`);
|
|
36878
|
+
owner.retired = true;
|
|
36879
|
+
return;
|
|
36880
|
+
}
|
|
36701
36881
|
const observationTokens = currentRecord.observationTokenCount ?? 0;
|
|
36702
36882
|
const reflectThreshold = getMaxThreshold(this.getEffectiveReflectionTokens(currentRecord));
|
|
36703
36883
|
const bufferActivation = this.reflectionConfig.bufferActivation ?? .5;
|
|
36704
36884
|
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
36705
36885
|
const cycleId = `reflect-buf-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
|
|
36886
|
+
if (owner.recordId !== currentRecord.id) {
|
|
36887
|
+
owner.recordId = currentRecord.id;
|
|
36888
|
+
owner.retired = false;
|
|
36889
|
+
}
|
|
36706
36890
|
BufferingCoordinator.reflectionBufferCycleIds.set(bufferKey, cycleId);
|
|
36707
36891
|
const allLines = (currentRecord.activeObservations ?? "").split("\n");
|
|
36708
36892
|
const totalLines = allLines.length;
|
|
@@ -36718,7 +36902,7 @@ var ReflectorRunner = class {
|
|
|
36718
36902
|
const reflectedObservationLineCount = linesToReflect;
|
|
36719
36903
|
const sliceTokenEstimate = Math.round(avgTokensPerLine * linesToReflect);
|
|
36720
36904
|
const compressionTarget = Math.round(sliceTokenEstimate * .75);
|
|
36721
|
-
omDebug(`[OM:reflect] doAsyncBufferedReflection: slicing observations for reflection
|
|
36905
|
+
omDebug(`[OM:reflect] doAsyncBufferedReflection: slicing observations for reflection \u2014 totalLines=${totalLines}, avgTokPerLine=${avgTokensPerLine.toFixed(1)}, activationPointTokens=${activationPointTokens}, linesToReflect=${linesToReflect}/${totalLines}, sliceTokenEstimate=${sliceTokenEstimate}, compressionTarget=${compressionTarget}`);
|
|
36722
36906
|
omDebug(`[OM:reflect] doAsyncBufferedReflection: starting reflector call, recordId=${currentRecord.id}, observationTokens=${sliceTokenEstimate}, compressionTarget=${compressionTarget} (inputTokens), activeObsLength=${activeObservations.length}, reflectedLineCount=${reflectedObservationLineCount}`);
|
|
36723
36907
|
if (writer) {
|
|
36724
36908
|
const startMarker = createBufferingStartMarker({
|
|
@@ -36739,10 +36923,18 @@ var ReflectorRunner = class {
|
|
|
36739
36923
|
const compressionStartLevel = await this.getCompressionStartLevel(requestContext);
|
|
36740
36924
|
const reflectResult = await this.call(activeObservations, void 0, void 0, compressionTarget, void 0, true, compressionStartLevel, requestContext, priorExtractedValues, observabilityContext, void 0, mainAgent, sendSignal, currentModel);
|
|
36741
36925
|
reflectResult.observations = await applyTextTransform(this.hooks, "afterReflection", reflectResult.observations, hookContext);
|
|
36926
|
+
if (!reflectResult.observations.trim()) {
|
|
36927
|
+
omDebug(`[OM:reflect] doAsyncBufferedReflection: reflection for ${currentRecord.id} is empty after afterReflection; discarding it`);
|
|
36928
|
+
owner.retired = true;
|
|
36929
|
+
return {
|
|
36930
|
+
usage: reflectResult.usage,
|
|
36931
|
+
providerMetadata: reflectResult.providerMetadata
|
|
36932
|
+
};
|
|
36933
|
+
}
|
|
36742
36934
|
const reflectionTokenCount = this.tokenCounter.countObservations(reflectResult.observations);
|
|
36743
36935
|
omDebug(`[OM:reflect] doAsyncBufferedReflection: reflector returned ${reflectionTokenCount} tokens (${reflectResult.observations?.length} chars), saving to recordId=${currentRecord.id}`);
|
|
36744
36936
|
if (!await runOMCommit(this.buffering.getLockKey(currentRecord.threadId, currentRecord.resourceId), async () => {
|
|
36745
|
-
if ((await this.storage.getObservationalMemory(currentRecord.threadId, currentRecord.resourceId))?.id !== currentRecord.id) return false;
|
|
36937
|
+
if ((await this.storage.getObservationalMemory(currentRecord.threadId, currentRecord.resourceId))?.id !== currentRecord.id || BufferingCoordinator.reflectionBufferOwners.get(bufferKey) !== owner) return false;
|
|
36746
36938
|
await this.storage.updateBufferedReflection({
|
|
36747
36939
|
id: currentRecord.id,
|
|
36748
36940
|
reflection: reflectResult.observations,
|
|
@@ -36750,17 +36942,18 @@ var ReflectorRunner = class {
|
|
|
36750
36942
|
inputTokenCount: sliceTokenEstimate,
|
|
36751
36943
|
reflectedObservationLineCount
|
|
36752
36944
|
});
|
|
36945
|
+
const buffered = await this.storage.getObservationalMemory(currentRecord.threadId, currentRecord.resourceId);
|
|
36946
|
+
if (buffered?.id === currentRecord.id && buffered.bufferedReflection === reflectResult.observations) await stageBufferedReflectionValues(this.storage, buffered, reflectResult.extractedValues);
|
|
36753
36947
|
return true;
|
|
36754
36948
|
})) {
|
|
36755
36949
|
omDebug(`[OM:reflect] doAsyncBufferedReflection: record ${currentRecord.id} is no longer the head; discarding the buffered reflection`);
|
|
36756
|
-
|
|
36950
|
+
owner.retired = true;
|
|
36757
36951
|
return {
|
|
36758
36952
|
usage: reflectResult.usage,
|
|
36759
36953
|
providerMetadata: reflectResult.providerMetadata
|
|
36760
36954
|
};
|
|
36761
36955
|
}
|
|
36762
36956
|
omDebug(`[OM:reflect] doAsyncBufferedReflection: bufferedReflection saved with lineCount=${reflectedObservationLineCount}`);
|
|
36763
|
-
await persistThreadExtractedValues(this.storage, this.reflectionConfig.extractors, currentRecord.threadId ?? void 0, reflectResult.extractedValues);
|
|
36764
36957
|
if (writer) {
|
|
36765
36958
|
const endMarker = createBufferingEndMarker({
|
|
36766
36959
|
cycleId,
|
|
@@ -36786,6 +36979,57 @@ var ReflectorRunner = class {
|
|
|
36786
36979
|
};
|
|
36787
36980
|
}
|
|
36788
36981
|
/**
|
|
36982
|
+
* Decide what a buffered-reflection swap did. Built-in adapters only swap the buffer and line
|
|
36983
|
+
* count in the snapshot, return the stored record (no new generation) when another writer
|
|
36984
|
+
* extended them after the head check, and mark a generation they created after that check with
|
|
36985
|
+
* `bufferedReflectionVerified`. Adapters without that check build the new generation from
|
|
36986
|
+
* whatever is stored. Either way the swap must also produce what the snapshot's buffer and line
|
|
36987
|
+
* count give from the text the swap retired (retired records are never written again, so that
|
|
36988
|
+
* text is exactly what the swap read).
|
|
36989
|
+
*
|
|
36990
|
+
* Staged values are published only with the adapter's proof. Without it an extension that
|
|
36991
|
+
* repeats the unreflected tail produces the same text as the snapshot's buffer, so the values
|
|
36992
|
+
* fail closed: the activation still applies, but the staged values stay unpublished.
|
|
36993
|
+
*/
|
|
36994
|
+
async classifyBufferedReflectionSwap({ result, newRecordId, snapshot, bufferedReflection, reflectedLineCount }) {
|
|
36995
|
+
if (result.id === snapshot.id) return {
|
|
36996
|
+
kind: "not-applied",
|
|
36997
|
+
headId: result.id
|
|
36998
|
+
};
|
|
36999
|
+
const createdByThisSwap = result.id === newRecordId;
|
|
37000
|
+
if (!createdByThisSwap && result.supersededBy !== void 0) return {
|
|
37001
|
+
kind: "not-applied",
|
|
37002
|
+
headId: result.id
|
|
37003
|
+
};
|
|
37004
|
+
const swapActiveObservations = result.activeObservations;
|
|
37005
|
+
const bufferedReflectionVerified = result.bufferedReflectionVerified === true;
|
|
37006
|
+
let matchesSnapshotBuffer = false;
|
|
37007
|
+
try {
|
|
37008
|
+
const retired = (await this.storage.getObservationalMemoryHistory(snapshot.threadId, snapshot.resourceId, 5, { recordId: snapshot.id })).find((candidate) => candidate.id === snapshot.id);
|
|
37009
|
+
matchesSnapshotBuffer = retired !== void 0 && swapActiveObservations === bufferedActivationText({
|
|
37010
|
+
bufferedReflection,
|
|
37011
|
+
observations: retired.activeObservations,
|
|
37012
|
+
reflectedLineCount
|
|
37013
|
+
});
|
|
37014
|
+
} catch (error) {
|
|
37015
|
+
omError("[OM] Failed to read the generation retired by buffered reflection activation", error);
|
|
37016
|
+
}
|
|
37017
|
+
const snapshotBufferActivated = matchesSnapshotBuffer && bufferedReflectionVerified;
|
|
37018
|
+
if (createdByThisSwap) return {
|
|
37019
|
+
kind: "applied",
|
|
37020
|
+
record: result,
|
|
37021
|
+
snapshotBufferActivated
|
|
37022
|
+
};
|
|
37023
|
+
return matchesSnapshotBuffer ? {
|
|
37024
|
+
kind: "applied",
|
|
37025
|
+
record: result,
|
|
37026
|
+
snapshotBufferActivated
|
|
37027
|
+
} : {
|
|
37028
|
+
kind: "not-applied",
|
|
37029
|
+
headId: result.id
|
|
37030
|
+
};
|
|
37031
|
+
}
|
|
37032
|
+
/**
|
|
36789
37033
|
* Try to activate buffered reflection when threshold is reached.
|
|
36790
37034
|
* Returns a discriminated result so the caller can distinguish between
|
|
36791
37035
|
* "activated", "no buffer present", and "suppressed by overshoot guard"
|
|
@@ -36805,24 +37049,32 @@ var ReflectorRunner = class {
|
|
|
36805
37049
|
}
|
|
36806
37050
|
}
|
|
36807
37051
|
}
|
|
36808
|
-
const
|
|
37052
|
+
const storedRecord = await this.storage.getObservationalMemory(record.threadId, record.resourceId);
|
|
37053
|
+
const freshRecord = storedRecord ? { ...storedRecord } : void 0;
|
|
36809
37054
|
omDebug(`[OM:reflect] tryActivateBufferedReflection: recordId=${record.id}, hasBufferedReflection=${!!freshRecord?.bufferedReflection}, bufferedReflectionLen=${freshRecord?.bufferedReflection?.length ?? 0}`);
|
|
36810
37055
|
omDebug(`[OM:reflect] tryActivateBufferedReflection: freshRecord.id=${freshRecord?.id}, freshBufferedReflection=${freshRecord?.bufferedReflection ? "present (" + freshRecord.bufferedReflection.length + " chars)" : "empty"}, freshObsTokens=${freshRecord?.observationTokenCount}`);
|
|
37056
|
+
if (freshRecord) await BufferingCoordinator.reconcileReflectionBufferHead(bufferKey, freshRecord.id, () => this.storage.getObservationalMemory(record.threadId, record.resourceId));
|
|
36811
37057
|
if (!freshRecord?.bufferedReflection) {
|
|
36812
37058
|
omDebug(`[OM:reflect] tryActivateBufferedReflection: no buffered reflection after re-fetch`);
|
|
36813
37059
|
return { status: "no-buffer" };
|
|
36814
37060
|
}
|
|
36815
37061
|
const beforeTokens = freshRecord.observationTokenCount ?? 0;
|
|
36816
37062
|
const reflectedLineCount = freshRecord.reflectedObservationLineCount ?? 0;
|
|
36817
|
-
const
|
|
37063
|
+
const currentObservations = freshRecord.activeObservations ?? "";
|
|
37064
|
+
const unreflectedLines = currentObservations.split("\n").slice(reflectedLineCount);
|
|
36818
37065
|
const unreflectedContent = unreflectedLines.join("\n").trim();
|
|
36819
|
-
const
|
|
37066
|
+
const bufferedReflection = freshRecord.bufferedReflection;
|
|
37067
|
+
const combinedObservations = bufferedActivationText({
|
|
37068
|
+
bufferedReflection,
|
|
37069
|
+
observations: currentObservations,
|
|
37070
|
+
reflectedLineCount
|
|
37071
|
+
});
|
|
36820
37072
|
const combinedTokenCount = this.tokenCounter.countObservations(combinedObservations);
|
|
36821
37073
|
if (activationMetadata?.triggeredBy === "ttl" || activationMetadata?.triggeredBy === "provider_change") {
|
|
36822
37074
|
const unreflectedTailTokens = unreflectedContent ? this.tokenCounter.countObservations(unreflectedContent) : 0;
|
|
36823
37075
|
const bufferedReflectionTokens = freshRecord.bufferedReflectionTokens ?? 0;
|
|
36824
37076
|
if (unreflectedTailTokens < bufferedReflectionTokens) {
|
|
36825
|
-
omDebug(`[OM:reflect] tryActivateBufferedReflection: suppressing early ${activationMetadata.triggeredBy} activation
|
|
37077
|
+
omDebug(`[OM:reflect] tryActivateBufferedReflection: suppressing early ${activationMetadata.triggeredBy} activation \u2014 unreflectedTailTokens=${unreflectedTailTokens} < bufferedReflectionTokens=${bufferedReflectionTokens}; keeping buffer for threshold activation`);
|
|
36826
37078
|
return {
|
|
36827
37079
|
status: "suppressed",
|
|
36828
37080
|
reason: "composition"
|
|
@@ -36833,7 +37085,7 @@ var ReflectorRunner = class {
|
|
|
36833
37085
|
const regularActivationTarget = reflectThreshold * (1 - bufferActivation);
|
|
36834
37086
|
const minCombinedTokens = Math.round(regularActivationTarget * EARLY_ACTIVATION_SIZE_FLOOR_RATIO);
|
|
36835
37087
|
if (combinedTokenCount < minCombinedTokens) {
|
|
36836
|
-
omDebug(`[OM:reflect] tryActivateBufferedReflection: suppressing early ${activationMetadata.triggeredBy} activation
|
|
37088
|
+
omDebug(`[OM:reflect] tryActivateBufferedReflection: suppressing early ${activationMetadata.triggeredBy} activation \u2014 combinedTokenCount=${combinedTokenCount} < minCombinedTokens=${minCombinedTokens} (${EARLY_ACTIVATION_SIZE_FLOOR_RATIO * 100}% of regular activation target ${Math.round(regularActivationTarget)}, threshold=${reflectThreshold}, bufferActivation=${bufferActivation}); keeping buffer for threshold activation`);
|
|
36837
37089
|
return {
|
|
36838
37090
|
status: "suppressed",
|
|
36839
37091
|
reason: "size"
|
|
@@ -36842,28 +37094,48 @@ var ReflectorRunner = class {
|
|
|
36842
37094
|
}
|
|
36843
37095
|
omDebug(`[OM:reflect] tryActivateBufferedReflection: activating, beforeTokens=${beforeTokens}, combinedTokenCount=${combinedTokenCount}, reflectedLineCount=${reflectedLineCount}, unreflectedLines=${unreflectedLines.length}`);
|
|
36844
37096
|
const newRecordId = crypto.randomUUID();
|
|
36845
|
-
const
|
|
37097
|
+
const commit = await runOMCommit(lockKey, async () => {
|
|
36846
37098
|
abortSignal?.throwIfAborted();
|
|
36847
|
-
|
|
37099
|
+
const head = await this.storage.getObservationalMemory(record.threadId, record.resourceId);
|
|
37100
|
+
if (head && (head.id !== freshRecord.id || head.bufferedReflection !== freshRecord.bufferedReflection || head.reflectedObservationLineCount !== freshRecord.reflectedObservationLineCount)) return {
|
|
37101
|
+
kind: "not-applied",
|
|
37102
|
+
headId: head.id
|
|
37103
|
+
};
|
|
37104
|
+
const result = await this.storage.swapBufferedReflectionToActive({
|
|
36848
37105
|
currentRecord: freshRecord,
|
|
36849
37106
|
tokenCount: combinedTokenCount,
|
|
36850
37107
|
newRecordId
|
|
36851
37108
|
});
|
|
37109
|
+
const outcome = await this.classifyBufferedReflectionSwap({
|
|
37110
|
+
result,
|
|
37111
|
+
newRecordId,
|
|
37112
|
+
snapshot: freshRecord,
|
|
37113
|
+
bufferedReflection,
|
|
37114
|
+
reflectedLineCount
|
|
37115
|
+
});
|
|
37116
|
+
if (outcome.kind === "applied" && outcome.snapshotBufferActivated) try {
|
|
37117
|
+
await publishBufferedReflectionValues(this.storage, this.reflectionConfig.extractors, freshRecord);
|
|
37118
|
+
} catch (error) {
|
|
37119
|
+
omError("[OM] Failed to publish buffered reflection values after activation", error);
|
|
37120
|
+
}
|
|
37121
|
+
return outcome;
|
|
36852
37122
|
}, {
|
|
36853
37123
|
priority: "reflection",
|
|
36854
37124
|
abortSignal
|
|
36855
37125
|
});
|
|
36856
|
-
if (
|
|
36857
|
-
omDebug(`[OM:reflect] tryActivateBufferedReflection: buffered reflection on ${freshRecord.id} not applied (head is ${
|
|
37126
|
+
if (commit.kind === "not-applied") {
|
|
37127
|
+
omDebug(`[OM:reflect] tryActivateBufferedReflection: buffered reflection on ${freshRecord.id} not applied (head is ${commit.headId})`);
|
|
37128
|
+
if (commit.headId !== freshRecord.id) BufferingCoordinator.retireReflectionBuffer(bufferKey, freshRecord.id);
|
|
36858
37129
|
return { status: "not-applied" };
|
|
36859
37130
|
}
|
|
36860
|
-
|
|
37131
|
+
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`);
|
|
37132
|
+
const originalCycleId = BufferingCoordinator.consumeReflectionBuffer(bufferKey, freshRecord.id);
|
|
36861
37133
|
const afterRecord = await this.storage.getObservationalMemory(record.threadId, record.resourceId);
|
|
36862
37134
|
const afterTokens = afterRecord?.observationTokenCount ?? 0;
|
|
36863
37135
|
omDebug(`[OM:reflect] tryActivateBufferedReflection: activation complete! beforeTokens=${beforeTokens}, afterTokens=${afterTokens}, newRecordId=${afterRecord?.id}, newGenCount=${afterRecord?.generationCount}`);
|
|
36864
37136
|
if (writer) {
|
|
36865
37137
|
const activationMarker = createActivationMarker({
|
|
36866
|
-
cycleId:
|
|
37138
|
+
cycleId: originalCycleId ?? `reflect-act-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`,
|
|
36867
37139
|
operationType: "reflection",
|
|
36868
37140
|
chunksActivated: 1,
|
|
36869
37141
|
tokensActivated: beforeTokens,
|
|
@@ -36889,7 +37161,6 @@ var ReflectorRunner = class {
|
|
|
36889
37161
|
}).catch(() => {});
|
|
36890
37162
|
await this.persistMarkerToMessage(activationMarker, messageList, freshRecord.threadId ?? "", freshRecord.resourceId ?? void 0, abortSignal);
|
|
36891
37163
|
}
|
|
36892
|
-
BufferingCoordinator.reflectionBufferCycleIds.delete(bufferKey);
|
|
36893
37164
|
return { status: "activated" };
|
|
36894
37165
|
}
|
|
36895
37166
|
/**
|
|
@@ -36906,7 +37177,7 @@ var ReflectorRunner = class {
|
|
|
36906
37177
|
const priorExtractedValues = await getThreadExtractedValues(this.storage, this.reflectionConfig.extractors, requestedThreadId ?? record.threadId);
|
|
36907
37178
|
abortSignal?.throwIfAborted();
|
|
36908
37179
|
if (this.buffering.isAsyncReflectionEnabled() && observationTokens < reflectThreshold) {
|
|
36909
|
-
if ((() => {
|
|
37180
|
+
if (await (async () => {
|
|
36910
37181
|
if (!this.buffering.isAsyncReflectionEnabled()) return false;
|
|
36911
37182
|
if (record.isBufferingReflection) {
|
|
36912
37183
|
if (isOpActiveInProcess(record.id, "bufferingReflection")) return false;
|
|
@@ -36914,6 +37185,7 @@ var ReflectorRunner = class {
|
|
|
36914
37185
|
this.storage.setBufferingReflectionFlag(record.id, false).catch(() => {});
|
|
36915
37186
|
}
|
|
36916
37187
|
const bufferKey = this.buffering.getReflectionBufferKey(lockKey);
|
|
37188
|
+
await BufferingCoordinator.reconcileReflectionBufferHead(bufferKey, record.id, () => this.storage.getObservationalMemory(record.threadId, record.resourceId));
|
|
36917
37189
|
if (this.buffering.isAsyncBufferingInProgress(bufferKey)) return false;
|
|
36918
37190
|
if (BufferingCoordinator.lastBufferedBoundary.has(bufferKey)) return false;
|
|
36919
37191
|
if (record.bufferedReflection) return false;
|
|
@@ -36942,7 +37214,7 @@ var ReflectorRunner = class {
|
|
|
36942
37214
|
omDebug(`[OM:reflect] isReflecting=true and active in this process, skipping`);
|
|
36943
37215
|
return;
|
|
36944
37216
|
}
|
|
36945
|
-
omDebug(`[OM:reflect] isReflecting=true but NOT active in this process
|
|
37217
|
+
omDebug(`[OM:reflect] isReflecting=true but NOT active in this process \u2014 stale flag from dead process, clearing`);
|
|
36946
37218
|
await this.storage.setReflectingFlag(record.id, false);
|
|
36947
37219
|
}
|
|
36948
37220
|
if (this.buffering.isAsyncReflectionEnabled()) {
|
|
@@ -36956,10 +37228,15 @@ var ReflectorRunner = class {
|
|
|
36956
37228
|
else {
|
|
36957
37229
|
const activationPoint = reflectThreshold * this.reflectionConfig.bufferActivation;
|
|
36958
37230
|
if (observationTokens < activationPoint) {
|
|
36959
|
-
omDebug(`[OM:reflect] skipping async reflection
|
|
37231
|
+
omDebug(`[OM:reflect] skipping async reflection \u2014 observationTokens (${observationTokens}) below activation point (${activationPoint}), triggered by ${activationTriggeredBy}`);
|
|
37232
|
+
return;
|
|
37233
|
+
}
|
|
37234
|
+
const bufferKey = this.buffering.getReflectionBufferKey(lockKey);
|
|
37235
|
+
if (this.buffering.isAsyncBufferingInProgress(bufferKey) || BufferingCoordinator.lastBufferedBoundary.has(bufferKey)) {
|
|
37236
|
+
omDebug(`[OM:reflect] skipping async reflection \u2014 reflection buffer already active or present for ${bufferKey}`);
|
|
36960
37237
|
return;
|
|
36961
37238
|
}
|
|
36962
|
-
omDebug(`[OM:reflect] async activation failed, no blockAfter or below it (obsTokens=${observationTokens}, blockAfter=${this.reflectionConfig.blockAfter})
|
|
37239
|
+
omDebug(`[OM:reflect] async activation failed, no blockAfter or below it (obsTokens=${observationTokens}, blockAfter=${this.reflectionConfig.blockAfter}) \u2014 starting background reflection`);
|
|
36963
37240
|
this.startAsyncBufferedReflection(record, observationTokens, lockKey, writer, requestContext, observabilityContext, reflectionHooks, priorExtractedValues, mainAgent, sendSignal, trigger, currentModel);
|
|
36964
37241
|
return;
|
|
36965
37242
|
}
|
|
@@ -36967,7 +37244,7 @@ var ReflectorRunner = class {
|
|
|
36967
37244
|
if (activationTriggeredBy === "threshold") {
|
|
36968
37245
|
const suppressedAtTokens = this.syncReflectionSuppression.get(lockKey);
|
|
36969
37246
|
if (suppressedAtTokens !== void 0 && observationTokens === suppressedAtTokens) {
|
|
36970
|
-
omDebug(`[OM:reflect] skipping sync reflection
|
|
37247
|
+
omDebug(`[OM:reflect] skipping sync reflection \u2014 observations unchanged at ${observationTokens} tokens since the last unproductive attempt; retrying once they change`);
|
|
36971
37248
|
return;
|
|
36972
37249
|
}
|
|
36973
37250
|
}
|
|
@@ -37810,7 +38087,7 @@ var ObservationalMemory = class ObservationalMemory {
|
|
|
37810
38087
|
const asyncBufferingDisabled = config.observation?.bufferTokens === false || config.scope === "resource" && !userExplicitlyConfiguredAsync;
|
|
37811
38088
|
if (isSharedBudget && !asyncBufferingDisabled) {
|
|
37812
38089
|
if (userExplicitlyConfiguredAsync) throw new Error("shareTokenBudget requires async buffering to be disabled (this is a temporary limitation). Add observation: { bufferTokens: false } to your config:\n\n observationalMemory: {\n shareTokenBudget: true,\n observation: { bufferTokens: false },\n }\n\nRemove any other async buffering settings (bufferTokens, bufferActivation, blockAfter).");
|
|
37813
|
-
else throw new Error("shareTokenBudget requires async buffering to be disabled (this is a temporary limitation). Add observation: { bufferTokens: false } to your config:\n\n observationalMemory: {\n shareTokenBudget: true,\n observation: { bufferTokens: false },\n }\n\nAsync buffering is enabled by default
|
|
38090
|
+
else throw new Error("shareTokenBudget requires async buffering to be disabled (this is a temporary limitation). Add observation: { bufferTokens: false } to your config:\n\n observationalMemory: {\n shareTokenBudget: true,\n observation: { bufferTokens: false },\n }\n\nAsync buffering is enabled by default \u2014 this opt-out is only needed when using shareTokenBudget.");
|
|
37814
38091
|
}
|
|
37815
38092
|
const observationActivateAfterIdle = config.observation?.activateAfterIdle ?? config.activateAfterIdle;
|
|
37816
38093
|
const observationActivateAfterIdlePath = config.observation?.activateAfterIdle !== void 0 ? "observation.activateAfterIdle" : "activateAfterIdle";
|
|
@@ -37907,7 +38184,7 @@ var ObservationalMemory = class ObservationalMemory {
|
|
|
37907
38184
|
hasWarnedResourceScopeDeprecation = true;
|
|
37908
38185
|
console.warn("[Mastra] Observational memory `scope: 'resource'` is deprecated and will be removed in a future release because it works much worse than thread scope for prompt caching and agent understanding. Remove `scope` to use the default thread scope, and enable `retrieval` for cross-thread recall. See https://mastra.ai/docs/memory/observational-memory#resource-scope-deprecated");
|
|
37909
38186
|
}
|
|
37910
|
-
omDebug(`[OM:init] new ObservationalMemory instance created
|
|
38187
|
+
omDebug(`[OM:init] new ObservationalMemory instance created \u2014 scope=${this.scope}, messageTokens=${JSON.stringify(this.observationConfig.messageTokens)}, obsAsyncEnabled=${this.buffering.isAsyncObservationEnabled()}, bufferTokens=${this.observationConfig.bufferTokens}, bufferActivation=${this.observationConfig.bufferActivation}, blockAfter=${this.observationConfig.blockAfter}, reflectionTokens=${this.reflectionConfig.observationTokens}, refAsyncEnabled=${this.buffering.isAsyncReflectionEnabled()}, refAsyncActivation=${this.reflectionConfig.bufferActivation}, refBlockAfter=${this.reflectionConfig.blockAfter}`);
|
|
37911
38188
|
}
|
|
37912
38189
|
__registerMastra(mastra) {
|
|
37913
38190
|
this.mastra = mastra;
|
|
@@ -38188,7 +38465,7 @@ var ObservationalMemory = class ObservationalMemory {
|
|
|
38188
38465
|
threadId: null,
|
|
38189
38466
|
resourceId: resourceId ?? threadId
|
|
38190
38467
|
};
|
|
38191
|
-
if (!threadId) throw new Error("ObservationalMemory (scope: 'thread') requires a threadId, but received an empty value. This is a bug
|
|
38468
|
+
if (!threadId) throw new Error("ObservationalMemory (scope: 'thread') requires a threadId, but received an empty value. This is a bug \u2014 getThreadContext should have caught this earlier.");
|
|
38192
38469
|
return {
|
|
38193
38470
|
threadId,
|
|
38194
38471
|
resourceId: resourceId ?? threadId
|
|
@@ -38499,7 +38776,7 @@ var ObservationalMemory = class ObservationalMemory {
|
|
|
38499
38776
|
const isImportant = new Array(totalCount);
|
|
38500
38777
|
for (let i = 0; i < totalCount; i++) {
|
|
38501
38778
|
lineTokens[i] = this.tokenCounter.countString(lines[i]);
|
|
38502
|
-
isImportant[i] = lines[i].includes("
|
|
38779
|
+
isImportant[i] = lines[i].includes("\u{1F534}") || lines[i].includes("\u2705");
|
|
38503
38780
|
}
|
|
38504
38781
|
const suffixTokens = new Array(totalCount + 1);
|
|
38505
38782
|
suffixTokens[totalCount] = 0;
|
|
@@ -38832,7 +39109,7 @@ ${formattedMessages}
|
|
|
38832
39109
|
resourceId: freshRecord.resourceId ?? void 0
|
|
38833
39110
|
});
|
|
38834
39111
|
} catch (err) {
|
|
38835
|
-
omError("[OM] Failed to persist sealed messages before buffering
|
|
39112
|
+
omError("[OM] Failed to persist sealed messages before buffering \u2014 skipping observation cycle", err);
|
|
38836
39113
|
return;
|
|
38837
39114
|
}
|
|
38838
39115
|
const cycleId = `buffer-obs-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
|
|
@@ -39982,7 +40259,7 @@ ${formattedMessages}
|
|
|
39982
40259
|
usage: void 0
|
|
39983
40260
|
};
|
|
39984
40261
|
}
|
|
39985
|
-
omDebug(`[OM:reflect] isReflecting=true but NOT active in this process
|
|
40262
|
+
omDebug(`[OM:reflect] isReflecting=true but NOT active in this process \u2014 stale flag from dead process, clearing`);
|
|
39986
40263
|
await this.storage.setReflectingFlag(record.id, false);
|
|
39987
40264
|
}
|
|
39988
40265
|
await this.storage.setReflectingFlag(record.id, true);
|
|
@@ -40217,7 +40494,7 @@ ${formattedMessages}
|
|
|
40217
40494
|
// src/processors/observational-memory/temporal-markers.ts
|
|
40218
40495
|
const TEMPORAL_GAP_REMINDER_TYPE = "temporal-gap";
|
|
40219
40496
|
function getTemporalGapReminderText(gapText, timestamp) {
|
|
40220
|
-
return `${gapText}
|
|
40497
|
+
return `${gapText} \u2014 ${formatTemporalTimestamp(new Date(timestamp))}`;
|
|
40221
40498
|
}
|
|
40222
40499
|
function getTemporalGapReminderMetadata(message, gapText, gapMs, timestamp) {
|
|
40223
40500
|
const formattedTimestamp = formatTemporalTimestamp(new Date(timestamp));
|
|
@@ -40439,14 +40716,14 @@ var ObservationalMemoryProcessor = class {
|
|
|
40439
40716
|
omDebug(`[OM:processInputStep:ENTER] step=${stepNumber}, hasMastraMemory=${!!requestContext?.get("MastraMemory")}, hasMemoryInfo=${!!messageList?.serialize()?.memoryInfo?.threadId}`);
|
|
40440
40717
|
const context = this.engine.getThreadContext(requestContext, messageList);
|
|
40441
40718
|
if (!context) {
|
|
40442
|
-
omDebug(`[OM:processInputStep:NO-CONTEXT] getThreadContext returned null
|
|
40719
|
+
omDebug(`[OM:processInputStep:NO-CONTEXT] getThreadContext returned null \u2014 returning early`);
|
|
40443
40720
|
return messageList;
|
|
40444
40721
|
}
|
|
40445
40722
|
const gatewayMemoryManaged = await isGatewayMemoryManaged(model);
|
|
40446
40723
|
state[GATEWAY_STATE_KEY] = gatewayMemoryManaged;
|
|
40447
40724
|
if (gatewayMemoryManaged) {
|
|
40448
40725
|
await this.endActiveTurn(state);
|
|
40449
|
-
omDebug(`[OM:processInputStep:GATEWAY] gateway manages memory
|
|
40726
|
+
omDebug(`[OM:processInputStep:GATEWAY] gateway manages memory \u2014 skipping local processing`);
|
|
40450
40727
|
return messageList;
|
|
40451
40728
|
}
|
|
40452
40729
|
const { threadId, resourceId } = context;
|
|
@@ -40667,7 +40944,7 @@ var ObservationalMemoryProcessor = class {
|
|
|
40667
40944
|
if (!context) return;
|
|
40668
40945
|
if ((0, _mastra_core_memory.parseMemoryRequestContext)(requestContext)?.memoryConfig?.readOnly) return;
|
|
40669
40946
|
state[CONTEXT_OVERFLOW_STEP_KEY] = stepNumber;
|
|
40670
|
-
omDebug(`[OM:processAPIError] context overflow at step ${stepNumber}
|
|
40947
|
+
omDebug(`[OM:processAPIError] context overflow at step ${stepNumber} \u2014 observing pending messages`);
|
|
40671
40948
|
const { threadId, resourceId } = context;
|
|
40672
40949
|
await this.engine.waitForBuffering(threadId, resourceId, void 0, args.abortSignal);
|
|
40673
40950
|
const messages = getObservableMessages(messageList);
|