@mastra/server 1.75.0-alpha.2 → 1.75.0-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/{api-schema-manifest-D9_jxxNw.cjs → api-schema-manifest-BmNlBOvP.cjs} +2 -2
- package/dist/{api-schema-manifest-D9_jxxNw.cjs.map → api-schema-manifest-BmNlBOvP.cjs.map} +1 -1
- package/dist/{api-schema-manifest-B0p6nxU1.js → api-schema-manifest-Bsnp8kpD.js} +2 -2
- package/dist/{api-schema-manifest-B0p6nxU1.js.map → api-schema-manifest-Bsnp8kpD.js.map} +1 -1
- package/dist/{dist-5xXLv6KR.js → dist-BFUX7iPi.js} +67 -41
- package/dist/dist-BFUX7iPi.js.map +1 -0
- package/dist/{dist-B6rOIYr_.cjs → dist-DgDFoIF5.cjs} +67 -41
- package/dist/dist-DgDFoIF5.cjs.map +1 -0
- package/dist/docs/SKILL.md +2 -2
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-observability-tracing-trace-query.md +113 -2
- package/dist/{observability-new-endpoints-lNC3o66-.js → observability-new-endpoints-DQuhr8aL.js} +114 -4
- package/dist/observability-new-endpoints-DQuhr8aL.js.map +1 -0
- package/dist/{observability-new-endpoints-7Zd6uEZf.cjs → observability-new-endpoints-Kphyk3do.cjs} +118 -2
- package/dist/observability-new-endpoints-Kphyk3do.cjs.map +1 -0
- package/dist/{routes-CJygX0-a.js → routes--Al6ya95.js} +3 -2
- package/dist/routes--Al6ya95.js.map +1 -0
- package/dist/{routes-BuiLQCOQ.cjs → routes-CeYKJ-Re.cjs} +3 -2
- package/dist/routes-CeYKJ-Re.cjs.map +1 -0
- package/dist/server/handlers/agent-builder.cjs +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/observability-new-endpoints.cjs +2 -1
- package/dist/server/handlers/observability-new-endpoints.d.ts +260 -0
- package/dist/server/handlers/observability-new-endpoints.d.ts.map +1 -1
- package/dist/server/handlers/observability-new-endpoints.js +2 -2
- package/dist/server/handlers/observability-shared.cjs +19 -0
- package/dist/server/handlers/observability-shared.cjs.map +1 -1
- package/dist/server/handlers/observability-shared.d.ts +10 -0
- package/dist/server/handlers/observability-shared.d.ts.map +1 -1
- package/dist/server/handlers/observability-shared.js +18 -1
- package/dist/server/handlers/observability-shared.js.map +1 -1
- package/dist/server/handlers/observability.cjs +3 -1
- package/dist/server/handlers/observability.cjs.map +1 -1
- package/dist/server/handlers/observability.js +3 -2
- package/dist/server/handlers/observability.js.map +1 -1
- package/dist/server/handlers/system.cjs +2 -2
- package/dist/server/handlers/system.d.ts +2 -0
- package/dist/server/handlers/system.d.ts.map +1 -1
- package/dist/server/handlers/system.js +2 -2
- package/dist/server/schemas/index.cjs +1 -1
- package/dist/server/schemas/index.js +1 -1
- package/dist/server/schemas/system.d.ts +2 -0
- package/dist/server/schemas/system.d.ts.map +1 -1
- package/dist/server/server-adapter/index.cjs +1 -1
- package/dist/server/server-adapter/index.js +1 -1
- package/dist/server/server-adapter/routes/observability.d.ts +129 -0
- package/dist/server/server-adapter/routes/observability.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/system.d.ts +2 -0
- package/dist/server/server-adapter/routes/system.d.ts.map +1 -1
- package/dist/{system-CskEzH1o.cjs → system-Be5n6H_z.cjs} +2 -1
- package/dist/system-Be5n6H_z.cjs.map +1 -0
- package/dist/{system-6qFm79mm.js → system-BtGAJr9R.js} +2 -1
- package/dist/system-BtGAJr9R.js.map +1 -0
- package/package.json +5 -5
- package/dist/dist-5xXLv6KR.js.map +0 -1
- package/dist/dist-B6rOIYr_.cjs.map +0 -1
- package/dist/observability-new-endpoints-7Zd6uEZf.cjs.map +0 -1
- package/dist/observability-new-endpoints-lNC3o66-.js.map +0 -1
- package/dist/routes-BuiLQCOQ.cjs.map +0 -1
- package/dist/routes-CJygX0-a.js.map +0 -1
- package/dist/system-6qFm79mm.js.map +0 -1
- package/dist/system-CskEzH1o.cjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require("./rolldown-runtime-Bd6kNlEP.cjs");
|
|
2
2
|
const require_route_builder = require("./route-builder-2yrD15TL.cjs");
|
|
3
|
-
const require_routes = require("./routes-
|
|
3
|
+
const require_routes = require("./routes-CeYKJ-Re.cjs");
|
|
4
4
|
//#region src/server/server-adapter/api-schema-manifest.ts
|
|
5
5
|
function convertSchema(schema) {
|
|
6
6
|
return schema ? require_route_builder.schemaToJsonSchema(schema) : void 0;
|
|
@@ -53,4 +53,4 @@ function buildApiSchemaManifest(routes = require_routes.SERVER_ROUTES) {
|
|
|
53
53
|
//#endregion
|
|
54
54
|
exports.buildApiSchemaManifest = buildApiSchemaManifest;
|
|
55
55
|
|
|
56
|
-
//# sourceMappingURL=api-schema-manifest-
|
|
56
|
+
//# sourceMappingURL=api-schema-manifest-BmNlBOvP.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-schema-manifest-
|
|
1
|
+
{"version":3,"file":"api-schema-manifest-BmNlBOvP.cjs","names":["schemaToJsonSchema","SERVER_ROUTES"],"sources":["../src/server/server-adapter/api-schema-manifest.ts"],"sourcesContent":["import type { JSONSchema7 } from '@mastra/schema-compat';\nimport { schemaToJsonSchema } from './openapi-utils';\nimport { SERVER_ROUTES } from './routes/index';\nimport type { ServerRoute } from './routes/index';\n\nexport interface ApiSchemaResponseShape {\n kind: 'array' | 'record' | 'object-property' | 'single' | 'unknown';\n listProperty?: string;\n paginationProperty?: string;\n}\n\nexport interface ApiSchemaManifestRoute {\n method: string;\n path: string;\n responseType: string;\n pathParamSchema?: JSONSchema7;\n queryParamSchema?: JSONSchema7;\n bodySchema?: JSONSchema7;\n responseSchema?: JSONSchema7;\n responseShape: ApiSchemaResponseShape;\n}\n\nexport interface ApiSchemaManifest {\n version: 1;\n routes: ApiSchemaManifestRoute[];\n}\n\nfunction convertSchema(schema: ServerRoute['bodySchema']): JSONSchema7 | undefined {\n return schema ? schemaToJsonSchema(schema) : undefined;\n}\n\nfunction asJsonSchema(value: unknown): JSONSchema7 | undefined {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as JSONSchema7) : undefined;\n}\n\nfunction schemaType(schema: JSONSchema7 | undefined): JSONSchema7['type'] | undefined {\n const type = schema?.type;\n return Array.isArray(type) ? type.find(Boolean) : type;\n}\n\nfunction inferResponseShape(responseSchema: JSONSchema7 | undefined): ApiSchemaResponseShape {\n if (!responseSchema) return { kind: 'unknown' };\n\n const type = schemaType(responseSchema);\n if (type === 'array') return { kind: 'array' };\n if (type !== 'object') return { kind: 'single' };\n\n const properties =\n responseSchema.properties && !Array.isArray(responseSchema.properties) ? responseSchema.properties : {};\n const propertyNames = Object.keys(properties);\n const paginationProperty = 'page' in properties ? 'page' : 'pagination' in properties ? 'pagination' : undefined;\n const listProperty = Object.entries(properties).find(\n ([, property]) => schemaType(asJsonSchema(property)) === 'array',\n )?.[0];\n\n if (listProperty && (paginationProperty || propertyNames.length <= 2)) {\n return { kind: 'object-property', listProperty, paginationProperty };\n }\n if (responseSchema.additionalProperties && propertyNames.length === 0) return { kind: 'record' };\n return { kind: 'single' };\n}\n\nfunction isManifestRoute(route: ServerRoute): boolean {\n return route.responseType === 'json' && !route.deprecated;\n}\n\nexport function buildApiSchemaManifest(routes: readonly ServerRoute[] = SERVER_ROUTES): ApiSchemaManifest {\n return {\n version: 1,\n routes: routes.filter(isManifestRoute).map(route => {\n const responseSchema = convertSchema(route.responseSchema);\n return {\n method: route.method,\n path: route.path,\n responseType: route.responseType,\n pathParamSchema: convertSchema(route.pathParamSchema),\n queryParamSchema: convertSchema(route.queryParamSchema),\n bodySchema: convertSchema(route.bodySchema),\n responseSchema,\n responseShape: inferResponseShape(responseSchema),\n };\n }),\n };\n}\n"],"mappings":";;;;AA2BA,SAAS,cAAc,QAA4D;CACjF,OAAO,SAASA,sBAAAA,mBAAmB,MAAM,IAAI,KAAA;AAC/C;AAEA,SAAS,aAAa,OAAyC;CAC7D,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AAc,MAAM,eAAe;IACpD,kBAAkB,cAAc,MAAM,gBAAgB;IACtD,YAAY,cAAc,MAAM,UAAU;IAC1C;IACA,eAAe,mBAAmB,cAAc;GAClD;EACF,CAAC;CACH;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as schemaToJsonSchema } from "./route-builder-lBil8Cvo.js";
|
|
2
|
-
import { t as SERVER_ROUTES } from "./routes
|
|
2
|
+
import { t as SERVER_ROUTES } from "./routes--Al6ya95.js";
|
|
3
3
|
//#region src/server/server-adapter/api-schema-manifest.ts
|
|
4
4
|
function convertSchema(schema) {
|
|
5
5
|
return schema ? schemaToJsonSchema(schema) : void 0;
|
|
@@ -52,4 +52,4 @@ function buildApiSchemaManifest(routes = SERVER_ROUTES) {
|
|
|
52
52
|
//#endregion
|
|
53
53
|
export { buildApiSchemaManifest };
|
|
54
54
|
|
|
55
|
-
//# sourceMappingURL=api-schema-manifest-
|
|
55
|
+
//# sourceMappingURL=api-schema-manifest-Bsnp8kpD.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-schema-manifest-
|
|
1
|
+
{"version":3,"file":"api-schema-manifest-Bsnp8kpD.js","names":[],"sources":["../src/server/server-adapter/api-schema-manifest.ts"],"sourcesContent":["import type { JSONSchema7 } from '@mastra/schema-compat';\nimport { schemaToJsonSchema } from './openapi-utils';\nimport { SERVER_ROUTES } from './routes/index';\nimport type { ServerRoute } from './routes/index';\n\nexport interface ApiSchemaResponseShape {\n kind: 'array' | 'record' | 'object-property' | 'single' | 'unknown';\n listProperty?: string;\n paginationProperty?: string;\n}\n\nexport interface ApiSchemaManifestRoute {\n method: string;\n path: string;\n responseType: string;\n pathParamSchema?: JSONSchema7;\n queryParamSchema?: JSONSchema7;\n bodySchema?: JSONSchema7;\n responseSchema?: JSONSchema7;\n responseShape: ApiSchemaResponseShape;\n}\n\nexport interface ApiSchemaManifest {\n version: 1;\n routes: ApiSchemaManifestRoute[];\n}\n\nfunction convertSchema(schema: ServerRoute['bodySchema']): JSONSchema7 | undefined {\n return schema ? schemaToJsonSchema(schema) : undefined;\n}\n\nfunction asJsonSchema(value: unknown): JSONSchema7 | undefined {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as JSONSchema7) : undefined;\n}\n\nfunction schemaType(schema: JSONSchema7 | undefined): JSONSchema7['type'] | undefined {\n const type = schema?.type;\n return Array.isArray(type) ? type.find(Boolean) : type;\n}\n\nfunction inferResponseShape(responseSchema: JSONSchema7 | undefined): ApiSchemaResponseShape {\n if (!responseSchema) return { kind: 'unknown' };\n\n const type = schemaType(responseSchema);\n if (type === 'array') return { kind: 'array' };\n if (type !== 'object') return { kind: 'single' };\n\n const properties =\n responseSchema.properties && !Array.isArray(responseSchema.properties) ? responseSchema.properties : {};\n const propertyNames = Object.keys(properties);\n const paginationProperty = 'page' in properties ? 'page' : 'pagination' in properties ? 'pagination' : undefined;\n const listProperty = Object.entries(properties).find(\n ([, property]) => schemaType(asJsonSchema(property)) === 'array',\n )?.[0];\n\n if (listProperty && (paginationProperty || propertyNames.length <= 2)) {\n return { kind: 'object-property', listProperty, paginationProperty };\n }\n if (responseSchema.additionalProperties && propertyNames.length === 0) return { kind: 'record' };\n return { kind: 'single' };\n}\n\nfunction isManifestRoute(route: ServerRoute): boolean {\n return route.responseType === 'json' && !route.deprecated;\n}\n\nexport function buildApiSchemaManifest(routes: readonly ServerRoute[] = SERVER_ROUTES): ApiSchemaManifest {\n return {\n version: 1,\n routes: routes.filter(isManifestRoute).map(route => {\n const responseSchema = convertSchema(route.responseSchema);\n return {\n method: route.method,\n path: route.path,\n responseType: route.responseType,\n pathParamSchema: convertSchema(route.pathParamSchema),\n queryParamSchema: convertSchema(route.queryParamSchema),\n bodySchema: convertSchema(route.bodySchema),\n responseSchema,\n responseShape: inferResponseShape(responseSchema),\n };\n }),\n };\n}\n"],"mappings":";;;AA2BA,SAAS,cAAc,QAA4D;CACjF,OAAO,SAAS,mBAAmB,MAAM,IAAI,KA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;IACZ,cAAc,MAAM;IACpB,iBAAiB,cAAc,MAAM,eAAe;IACpD,kBAAkB,cAAc,MAAM,gBAAgB;IACtD,YAAY,cAAc,MAAM,UAAU;IAC1C;IACA,eAAe,mBAAmB,cAAc;GAClD;EACF,CAAC;CACH;AACF"}
|
|
@@ -4637,7 +4637,7 @@ function splitLines(text) {
|
|
|
4637
4637
|
return result;
|
|
4638
4638
|
}
|
|
4639
4639
|
//#endregion
|
|
4640
|
-
//#region ../memory/dist/src-
|
|
4640
|
+
//#region ../memory/dist/src-BxI-PDpC.js
|
|
4641
4641
|
var __defProp$3 = Object.defineProperty;
|
|
4642
4642
|
var __exportAll = (all, no_symbols) => {
|
|
4643
4643
|
let target = {};
|
|
@@ -26674,6 +26674,7 @@ function serializeNonImageFilePartForTokenCounting(part) {
|
|
|
26674
26674
|
function isValidCacheEntry(entry, expectedKey, expectedSource) {
|
|
26675
26675
|
return Boolean(entry && entry.v === TOKEN_ESTIMATE_CACHE_VERSION && entry.source === expectedSource && entry.key === expectedKey && Number.isFinite(entry.tokens));
|
|
26676
26676
|
}
|
|
26677
|
+
const modelContextStorage = new AsyncLocalStorage();
|
|
26677
26678
|
function parseModelContext(model) {
|
|
26678
26679
|
if (!model) return void 0;
|
|
26679
26680
|
if (typeof model === "object") return model.provider || model.modelId ? {
|
|
@@ -27295,7 +27296,6 @@ async function fetchGoogleAttachmentTokenEstimate(modelId, part) {
|
|
|
27295
27296
|
var TokenCounter = class TokenCounter {
|
|
27296
27297
|
cacheSource;
|
|
27297
27298
|
defaultModelContext;
|
|
27298
|
-
modelContextStorage = new AsyncLocalStorage();
|
|
27299
27299
|
inFlightAttachmentCounts = /* @__PURE__ */ new Map();
|
|
27300
27300
|
multimodalToolResultCounts = /* @__PURE__ */ new WeakMap();
|
|
27301
27301
|
static TOKENS_PER_MESSAGE = 3.8;
|
|
@@ -27305,10 +27305,12 @@ var TokenCounter = class TokenCounter {
|
|
|
27305
27305
|
this.defaultModelContext = parseModelContext(options?.model);
|
|
27306
27306
|
}
|
|
27307
27307
|
runWithModelContext(model, fn) {
|
|
27308
|
-
|
|
27308
|
+
const contexts = new Map(modelContextStorage.getStore());
|
|
27309
|
+
contexts.set(this, parseModelContext(model));
|
|
27310
|
+
return modelContextStorage.run(contexts, fn);
|
|
27309
27311
|
}
|
|
27310
27312
|
getModelContext() {
|
|
27311
|
-
return
|
|
27313
|
+
return modelContextStorage.getStore()?.get(this) ?? this.defaultModelContext;
|
|
27312
27314
|
}
|
|
27313
27315
|
/**
|
|
27314
27316
|
* Count tokens in a plain string
|
|
@@ -32462,7 +32464,7 @@ var ObservationStep = class {
|
|
|
32462
32464
|
if (obsResult.succeeded) {
|
|
32463
32465
|
observed = true;
|
|
32464
32466
|
didThresholdCleanup = true;
|
|
32465
|
-
const observedIds = obsResult.
|
|
32467
|
+
const observedIds = obsResult.cleanupMessageIds;
|
|
32466
32468
|
const minRemaining = resolveRetentionFloor(om.getObservationConfig().bufferActivation ?? 1, statusSnapshot.threshold);
|
|
32467
32469
|
await om.cleanupMessages({
|
|
32468
32470
|
threadId,
|
|
@@ -32529,8 +32531,8 @@ var ObservationStep = class {
|
|
|
32529
32531
|
}
|
|
32530
32532
|
/**
|
|
32531
32533
|
* Run the full threshold observation pipeline:
|
|
32532
|
-
* waitForBuffering → re-check → activate → reflect → observe
|
|
32533
|
-
*
|
|
32534
|
+
* waitForBuffering → re-check → activate buffered chunks → reflect → observe
|
|
32535
|
+
* (sync fallback when pending tokens are still at or above the threshold)
|
|
32534
32536
|
*/
|
|
32535
32537
|
async runThresholdObservation() {
|
|
32536
32538
|
const { threadId, resourceId, messageList } = this.turn;
|
|
@@ -32538,59 +32540,76 @@ var ObservationStep = class {
|
|
|
32538
32540
|
await om.waitForBuffering(threadId, resourceId);
|
|
32539
32541
|
await this.turn.refreshRecord();
|
|
32540
32542
|
const observableMessages = this.seededResponseMessage ? getObservableMessages(messageList).filter((msg) => msg.id !== this.turn.responseMessageId) : getObservableMessages(messageList);
|
|
32541
|
-
|
|
32543
|
+
let status = await om.getStatus({
|
|
32542
32544
|
threadId,
|
|
32543
32545
|
resourceId,
|
|
32544
32546
|
record: this.turn.record,
|
|
32545
32547
|
messages: observableMessages
|
|
32546
32548
|
});
|
|
32547
|
-
if (!
|
|
32549
|
+
if (!status.shouldObserve) return {
|
|
32548
32550
|
succeeded: false,
|
|
32549
|
-
record:
|
|
32551
|
+
record: status.record,
|
|
32552
|
+
cleanupMessageIds: []
|
|
32550
32553
|
};
|
|
32551
|
-
|
|
32554
|
+
let pendingMessages = observableMessages;
|
|
32555
|
+
const activatedMessageIds = [];
|
|
32556
|
+
let activated = false;
|
|
32557
|
+
while (status.shouldObserve && status.canActivate) {
|
|
32552
32558
|
const activation = await om.activate({
|
|
32553
32559
|
threadId,
|
|
32554
32560
|
resourceId,
|
|
32555
32561
|
record: this.turn.record,
|
|
32556
|
-
messages:
|
|
32562
|
+
messages: pendingMessages,
|
|
32563
|
+
pendingTokens: status.pendingTokens,
|
|
32557
32564
|
currentModel: this.turn.actorModelContext,
|
|
32558
32565
|
writer: this.turn.writer,
|
|
32559
32566
|
messageList
|
|
32560
32567
|
});
|
|
32561
32568
|
this.turn.setRecord(activation.record);
|
|
32562
|
-
if (activation.activated)
|
|
32563
|
-
|
|
32564
|
-
|
|
32565
|
-
|
|
32566
|
-
|
|
32569
|
+
if (!activation.activated) break;
|
|
32570
|
+
activated = true;
|
|
32571
|
+
const ids = new Set(activation.activatedMessageIds ?? []);
|
|
32572
|
+
activatedMessageIds.push(...ids);
|
|
32573
|
+
pendingMessages = pendingMessages.filter((msg) => !ids.has(msg.id));
|
|
32574
|
+
status = await om.getStatus({
|
|
32575
|
+
threadId,
|
|
32576
|
+
resourceId,
|
|
32577
|
+
record: this.turn.record,
|
|
32578
|
+
messages: pendingMessages
|
|
32579
|
+
});
|
|
32580
|
+
}
|
|
32581
|
+
if (activated) {
|
|
32582
|
+
const postActivationRecord = this.turn.record;
|
|
32583
|
+
await om.reflector.maybeReflect({
|
|
32584
|
+
record: postActivationRecord,
|
|
32585
|
+
observationTokens: postActivationRecord.observationTokenCount ?? 0,
|
|
32586
|
+
threadId,
|
|
32587
|
+
writer: this.turn.writer,
|
|
32588
|
+
messageList,
|
|
32589
|
+
currentModel: this.turn.actorModelContext,
|
|
32590
|
+
requestContext: this.turn.requestContext,
|
|
32591
|
+
observabilityContext: this.turn.observabilityContext,
|
|
32592
|
+
lastActivityAt: getLastActivityFromMessages(getObservableMessages(messageList)),
|
|
32593
|
+
reflectionHooks: om.composeHooks(void 0, {
|
|
32567
32594
|
threadId,
|
|
32568
|
-
|
|
32569
|
-
messageList,
|
|
32570
|
-
currentModel: this.turn.actorModelContext,
|
|
32571
|
-
requestContext: this.turn.requestContext,
|
|
32572
|
-
observabilityContext: this.turn.observabilityContext,
|
|
32573
|
-
lastActivityAt: getLastActivityFromMessages(getObservableMessages(messageList)),
|
|
32574
|
-
reflectionHooks: om.composeHooks(void 0, {
|
|
32575
|
-
threadId,
|
|
32576
|
-
resourceId,
|
|
32577
|
-
trigger: "turn-sync"
|
|
32578
|
-
}),
|
|
32595
|
+
resourceId,
|
|
32579
32596
|
trigger: "turn-sync"
|
|
32580
|
-
})
|
|
32581
|
-
|
|
32582
|
-
|
|
32583
|
-
|
|
32584
|
-
|
|
32585
|
-
|
|
32586
|
-
|
|
32597
|
+
}),
|
|
32598
|
+
trigger: "turn-sync"
|
|
32599
|
+
});
|
|
32600
|
+
if (!status.shouldObserve) return {
|
|
32601
|
+
succeeded: true,
|
|
32602
|
+
record: postActivationRecord,
|
|
32603
|
+
activatedMessageIds,
|
|
32604
|
+
cleanupMessageIds: activatedMessageIds
|
|
32605
|
+
};
|
|
32587
32606
|
}
|
|
32588
32607
|
let obsResult;
|
|
32589
32608
|
try {
|
|
32590
32609
|
obsResult = await om.observe({
|
|
32591
32610
|
threadId,
|
|
32592
32611
|
resourceId,
|
|
32593
|
-
messages:
|
|
32612
|
+
messages: pendingMessages,
|
|
32594
32613
|
messageList,
|
|
32595
32614
|
trigger: "turn-sync",
|
|
32596
32615
|
agent: this.turn.agent,
|
|
@@ -32603,8 +32622,10 @@ var ObservationStep = class {
|
|
|
32603
32622
|
} catch (error) {
|
|
32604
32623
|
if (om.config.observation.failurePolicy !== "continue" || !isOmModelExecutionError(error) || error.failureKind !== "observer-model") throw error;
|
|
32605
32624
|
return {
|
|
32606
|
-
succeeded:
|
|
32607
|
-
record:
|
|
32625
|
+
succeeded: activated,
|
|
32626
|
+
record: this.turn.record,
|
|
32627
|
+
activatedMessageIds: activated ? activatedMessageIds : void 0,
|
|
32628
|
+
cleanupMessageIds: activatedMessageIds
|
|
32608
32629
|
};
|
|
32609
32630
|
}
|
|
32610
32631
|
if (obsResult.observed) {
|
|
@@ -32631,8 +32652,10 @@ var ObservationStep = class {
|
|
|
32631
32652
|
if (messagesToSeal.length > 0) await om.persistMessages(messagesToSeal, threadId, resourceId);
|
|
32632
32653
|
}
|
|
32633
32654
|
return {
|
|
32634
|
-
succeeded: obsResult.observed,
|
|
32655
|
+
succeeded: activated || obsResult.observed,
|
|
32635
32656
|
record: obsResult.record,
|
|
32657
|
+
activatedMessageIds: activated ? activatedMessageIds : void 0,
|
|
32658
|
+
cleanupMessageIds: [.../* @__PURE__ */ new Set([...activatedMessageIds, ...obsResult.observed ? obsResult.record.observedMessageIds ?? [] : []])],
|
|
32636
32659
|
observerExchange: om.observer.lastExchange
|
|
32637
32660
|
};
|
|
32638
32661
|
}
|
|
@@ -36310,6 +36333,7 @@ ${formattedMessages}
|
|
|
36310
36333
|
let activateAfterIdleExpiredMs;
|
|
36311
36334
|
let previousModel;
|
|
36312
36335
|
let currentModel;
|
|
36336
|
+
let livePendingTokens = opts.pendingTokens;
|
|
36313
36337
|
if (opts.checkThreshold) {
|
|
36314
36338
|
const thresholdMessages = opts.messages ?? await this.loadMessagesFromStorage(threadId, resourceId, record.lastObservedAt ? new Date(record.lastObservedAt) : void 0);
|
|
36315
36339
|
const activateAfterIdle = resolveActivationTTL(this.observationConfig.activateAfterIdle, opts.currentModel);
|
|
@@ -36338,6 +36362,7 @@ ${formattedMessages}
|
|
|
36338
36362
|
activated: false,
|
|
36339
36363
|
record
|
|
36340
36364
|
};
|
|
36365
|
+
livePendingTokens ??= status.pendingTokens;
|
|
36341
36366
|
}
|
|
36342
36367
|
}
|
|
36343
36368
|
if (record.isBufferingObservation) {
|
|
@@ -36361,8 +36386,9 @@ ${formattedMessages}
|
|
|
36361
36386
|
const messageTokensThreshold = getMaxThreshold(this.getEffectiveMessageTokens(freshRecord));
|
|
36362
36387
|
const activationRatio = resolveActivationRatio(this.observationConfig.bufferActivation ?? .7, messageTokensThreshold);
|
|
36363
36388
|
const totalChunkMessageTokens = freshChunks.reduce((sum, c) => sum + (c.messageTokens ?? 0), 0);
|
|
36364
|
-
const currentPendingTokens = freshRecord.pendingMessageTokens || totalChunkMessageTokens;
|
|
36389
|
+
const currentPendingTokens = livePendingTokens ?? (freshRecord.pendingMessageTokens || totalChunkMessageTokens);
|
|
36365
36390
|
const forceMaxActivation = !!(this.observationConfig.blockAfter && currentPendingTokens >= this.observationConfig.blockAfter);
|
|
36391
|
+
if (freshRecord.pendingMessageTokens !== currentPendingTokens) await this.storage.setPendingMessageTokens(freshRecord.id, currentPendingTokens);
|
|
36366
36392
|
const activationResult = await this.storage.swapBufferedToActive({
|
|
36367
36393
|
id: freshRecord.id,
|
|
36368
36394
|
activationRatio,
|
|
@@ -50437,4 +50463,4 @@ const agentBuilderWorkflows = {
|
|
|
50437
50463
|
//#endregion
|
|
50438
50464
|
export { agentBuilderWorkflows };
|
|
50439
50465
|
|
|
50440
|
-
//# sourceMappingURL=dist-
|
|
50466
|
+
//# sourceMappingURL=dist-BFUX7iPi.js.map
|