@anuma/sdk 3.3.0 → 3.4.0
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/client/index.cjs +793 -1420
- package/dist/client/index.d.mts +406 -402
- package/dist/client/index.d.ts +406 -402
- package/dist/client/index.mjs +793 -1420
- package/dist/expo/{chunk-NMZMXIUM.mjs → chunk-C7PGRFBG.mjs} +82 -9
- package/dist/expo/index.cjs +234 -168
- package/dist/expo/index.d.mts +70 -1
- package/dist/expo/index.d.ts +70 -1
- package/dist/expo/index.mjs +144 -156
- package/dist/expo/{recall-7FUJRHOI.mjs → recall-7ZX6T2VD.mjs} +1 -1
- package/dist/index.cjs +453 -783
- package/dist/index.d.mts +491 -487
- package/dist/index.d.ts +491 -487
- package/dist/index.mjs +453 -783
- package/dist/react/{chunk-GZRK43CA.mjs → chunk-CGC3UJHM.mjs} +82 -9
- package/dist/react/index.cjs +305 -290
- package/dist/react/index.d.mts +453 -380
- package/dist/react/index.d.ts +453 -380
- package/dist/react/index.mjs +215 -278
- package/dist/react/{recall-YZGWZC5W.mjs → recall-OTUNGQHQ.mjs} +1 -1
- package/dist/server/{chunk-NVTMJWFA.mjs → chunk-LUDHA4X4.mjs} +82 -9
- package/dist/server/index.cjs +124 -30
- package/dist/server/index.d.mts +70 -1
- package/dist/server/index.d.ts +70 -1
- package/dist/server/index.mjs +34 -18
- package/dist/server/{recall-76WPPKLR.mjs → recall-GWRWPGE4.mjs} +1 -1
- package/dist/tools/selection/index.cjs +3 -0
- package/dist/tools/selection/index.mjs +3 -0
- package/package.json +2 -2
package/dist/expo/index.mjs
CHANGED
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
NODE_BUDGET,
|
|
13
13
|
RerankerUnavailableError,
|
|
14
14
|
TOPICS_EXTRACTION_VERSION,
|
|
15
|
+
TREND_RECENT_WINDOW_DAYS,
|
|
16
|
+
TREND_STALE_WINDOW_DAYS,
|
|
15
17
|
VAULT_SIZE_HOP_CAP,
|
|
16
18
|
archiveVaultMemoryOp,
|
|
17
19
|
assertVaultScopeForSweep,
|
|
@@ -19,6 +21,7 @@ import {
|
|
|
19
21
|
chunkAndEmbedAllMessages,
|
|
20
22
|
chunkAndEmbedMessage,
|
|
21
23
|
chunkText,
|
|
24
|
+
classifyObservationTrend,
|
|
22
25
|
clearAllEncryptionKeys,
|
|
23
26
|
clearAllEncryptionState,
|
|
24
27
|
clearEncryptionKey,
|
|
@@ -87,6 +90,7 @@ import {
|
|
|
87
90
|
shouldChunkMessage,
|
|
88
91
|
stampTopicsExtractedAtOp,
|
|
89
92
|
stripToolCalls,
|
|
93
|
+
summarizeObservationTrends,
|
|
90
94
|
supersedeVaultMemoryOp,
|
|
91
95
|
traverseGraphLane,
|
|
92
96
|
updateConversationPinnedOp,
|
|
@@ -99,7 +103,7 @@ import {
|
|
|
99
103
|
upsertMessageOp,
|
|
100
104
|
useEncryption,
|
|
101
105
|
vaultMemoryToStored
|
|
102
|
-
} from "./chunk-
|
|
106
|
+
} from "./chunk-C7PGRFBG.mjs";
|
|
103
107
|
import {
|
|
104
108
|
PII_PATTERNS,
|
|
105
109
|
PiiRedactor,
|
|
@@ -292,7 +296,7 @@ function createWebSearchPreProcessor(options = {}) {
|
|
|
292
296
|
}
|
|
293
297
|
|
|
294
298
|
// src/client/core/serverSentEvents.gen.ts
|
|
295
|
-
|
|
299
|
+
function createSseClient({
|
|
296
300
|
onRequest,
|
|
297
301
|
onSseError,
|
|
298
302
|
onSseEvent,
|
|
@@ -304,7 +308,7 @@ var createSseClient = ({
|
|
|
304
308
|
sseSleepFn,
|
|
305
309
|
url,
|
|
306
310
|
...options
|
|
307
|
-
})
|
|
311
|
+
}) {
|
|
308
312
|
let lastEventId;
|
|
309
313
|
const sleep3 = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
310
314
|
const createStream = async function* () {
|
|
@@ -332,10 +336,7 @@ var createSseClient = ({
|
|
|
332
336
|
}
|
|
333
337
|
const _fetch = options.fetch ?? globalThis.fetch;
|
|
334
338
|
const response = await _fetch(request);
|
|
335
|
-
if (!response.ok)
|
|
336
|
-
throw new Error(
|
|
337
|
-
`SSE failed: ${response.status} ${response.statusText}`
|
|
338
|
-
);
|
|
339
|
+
if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
339
340
|
if (!response.body) throw new Error("No body in SSE response");
|
|
340
341
|
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
341
342
|
let buffer = "";
|
|
@@ -351,6 +352,7 @@ var createSseClient = ({
|
|
|
351
352
|
const { done, value } = await reader.read();
|
|
352
353
|
if (done) break;
|
|
353
354
|
buffer += value;
|
|
355
|
+
buffer = buffer.replace(/\r\n?/g, "\n");
|
|
354
356
|
const chunks = buffer.split("\n\n");
|
|
355
357
|
buffer = chunks.pop() ?? "";
|
|
356
358
|
for (const chunk of chunks) {
|
|
@@ -365,10 +367,7 @@ var createSseClient = ({
|
|
|
365
367
|
} else if (line.startsWith("id:")) {
|
|
366
368
|
lastEventId = line.replace(/^id:\s*/, "");
|
|
367
369
|
} else if (line.startsWith("retry:")) {
|
|
368
|
-
const parsed = Number.parseInt(
|
|
369
|
-
line.replace(/^retry:\s*/, ""),
|
|
370
|
-
10
|
|
371
|
-
);
|
|
370
|
+
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
372
371
|
if (!Number.isNaN(parsed)) {
|
|
373
372
|
retryDelay = parsed;
|
|
374
373
|
}
|
|
@@ -414,17 +413,14 @@ var createSseClient = ({
|
|
|
414
413
|
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
|
|
415
414
|
break;
|
|
416
415
|
}
|
|
417
|
-
const backoff = Math.min(
|
|
418
|
-
retryDelay * 2 ** (attempt - 1),
|
|
419
|
-
sseMaxRetryDelay ?? 3e4
|
|
420
|
-
);
|
|
416
|
+
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
|
|
421
417
|
await sleep3(backoff);
|
|
422
418
|
}
|
|
423
419
|
}
|
|
424
420
|
};
|
|
425
421
|
const stream = createStream();
|
|
426
422
|
return { stream };
|
|
427
|
-
}
|
|
423
|
+
}
|
|
428
424
|
|
|
429
425
|
// src/lib/chat/runHooks.ts
|
|
430
426
|
function composeHooks(hooks) {
|
|
@@ -3873,10 +3869,7 @@ import { useCallback, useEffect, useRef, useState } from "react";
|
|
|
3873
3869
|
|
|
3874
3870
|
// src/client/core/bodySerializer.gen.ts
|
|
3875
3871
|
var jsonBodySerializer = {
|
|
3876
|
-
bodySerializer: (body) => JSON.stringify(
|
|
3877
|
-
body,
|
|
3878
|
-
(_key, value) => typeof value === "bigint" ? value.toString() : value
|
|
3879
|
-
)
|
|
3872
|
+
bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
|
|
3880
3873
|
};
|
|
3881
3874
|
|
|
3882
3875
|
// src/client/core/pathSerializer.gen.ts
|
|
@@ -3978,11 +3971,7 @@ var serializeObjectParam = ({
|
|
|
3978
3971
|
if (style !== "deepObject" && !explode) {
|
|
3979
3972
|
let values = [];
|
|
3980
3973
|
Object.entries(value).forEach(([key, v]) => {
|
|
3981
|
-
values = [
|
|
3982
|
-
...values,
|
|
3983
|
-
key,
|
|
3984
|
-
allowReserved ? v : encodeURIComponent(v)
|
|
3985
|
-
];
|
|
3974
|
+
values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
|
|
3986
3975
|
});
|
|
3987
3976
|
const joinedValues2 = values.join(",");
|
|
3988
3977
|
switch (style) {
|
|
@@ -4065,10 +4054,7 @@ var defaultPathSerializer = ({ path, url: _url }) => {
|
|
|
4065
4054
|
continue;
|
|
4066
4055
|
}
|
|
4067
4056
|
if (Array.isArray(value)) {
|
|
4068
|
-
url = url.replace(
|
|
4069
|
-
match,
|
|
4070
|
-
serializeArrayParam({ explode, name, style, value })
|
|
4071
|
-
);
|
|
4057
|
+
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
|
4072
4058
|
continue;
|
|
4073
4059
|
}
|
|
4074
4060
|
if (typeof value === "object") {
|
|
@@ -4163,9 +4149,7 @@ var getParseAs = (contentType) => {
|
|
|
4163
4149
|
if (cleanContent === "multipart/form-data") {
|
|
4164
4150
|
return "formData";
|
|
4165
4151
|
}
|
|
4166
|
-
if (["application/", "audio/", "image/", "video/"].some(
|
|
4167
|
-
(type) => cleanContent.startsWith(type)
|
|
4168
|
-
)) {
|
|
4152
|
+
if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
|
|
4169
4153
|
return "blob";
|
|
4170
4154
|
}
|
|
4171
4155
|
if (cleanContent.startsWith("text/")) {
|
|
@@ -4182,11 +4166,8 @@ var checkForExistence = (options, name) => {
|
|
|
4182
4166
|
}
|
|
4183
4167
|
return false;
|
|
4184
4168
|
};
|
|
4185
|
-
|
|
4186
|
-
security
|
|
4187
|
-
...options
|
|
4188
|
-
}) => {
|
|
4189
|
-
for (const auth of security) {
|
|
4169
|
+
async function setAuthParams(options) {
|
|
4170
|
+
for (const auth of options.security ?? []) {
|
|
4190
4171
|
if (checkForExistence(options, auth.name)) {
|
|
4191
4172
|
continue;
|
|
4192
4173
|
}
|
|
@@ -4211,7 +4192,7 @@ var setAuthParams = async ({
|
|
|
4211
4192
|
break;
|
|
4212
4193
|
}
|
|
4213
4194
|
}
|
|
4214
|
-
}
|
|
4195
|
+
}
|
|
4215
4196
|
var buildUrl = (options) => {
|
|
4216
4197
|
const url = getUrl({
|
|
4217
4198
|
baseUrl: options.baseUrl,
|
|
@@ -4363,10 +4344,7 @@ var createClient = (config = {}) => {
|
|
|
4363
4344
|
serializedBody: void 0
|
|
4364
4345
|
};
|
|
4365
4346
|
if (opts.security) {
|
|
4366
|
-
await setAuthParams(
|
|
4367
|
-
...opts,
|
|
4368
|
-
security: opts.security
|
|
4369
|
-
});
|
|
4347
|
+
await setAuthParams(opts);
|
|
4370
4348
|
}
|
|
4371
4349
|
if (opts.requestValidator) {
|
|
4372
4350
|
await opts.requestValidator(opts);
|
|
@@ -4377,105 +4355,115 @@ var createClient = (config = {}) => {
|
|
|
4377
4355
|
if (opts.body === void 0 || opts.serializedBody === "") {
|
|
4378
4356
|
opts.headers.delete("Content-Type");
|
|
4379
4357
|
}
|
|
4380
|
-
const
|
|
4381
|
-
|
|
4358
|
+
const resolvedOpts = opts;
|
|
4359
|
+
const url = buildUrl(resolvedOpts);
|
|
4360
|
+
return { opts: resolvedOpts, url };
|
|
4382
4361
|
};
|
|
4383
4362
|
const request = async (options) => {
|
|
4384
|
-
const
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4363
|
+
const throwOnError = options.throwOnError ?? _config.throwOnError;
|
|
4364
|
+
let response;
|
|
4365
|
+
try {
|
|
4366
|
+
const { opts, url } = await beforeRequest(options);
|
|
4367
|
+
for (const fn of interceptors.request.fns) {
|
|
4368
|
+
if (fn) {
|
|
4369
|
+
await fn(opts);
|
|
4370
|
+
}
|
|
4388
4371
|
}
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4372
|
+
const _fetch = opts.fetch;
|
|
4373
|
+
const requestInit = {
|
|
4374
|
+
...opts,
|
|
4375
|
+
body: getValidRequestBody(opts)
|
|
4376
|
+
};
|
|
4377
|
+
response = await _fetch(url, requestInit);
|
|
4378
|
+
for (const fn of interceptors.response.fns) {
|
|
4379
|
+
if (fn) {
|
|
4380
|
+
response = await fn(response, opts);
|
|
4381
|
+
}
|
|
4399
4382
|
}
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4383
|
+
const result = {
|
|
4384
|
+
response
|
|
4385
|
+
};
|
|
4386
|
+
if (response.ok) {
|
|
4387
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
4388
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
4389
|
+
let emptyData;
|
|
4390
|
+
switch (parseAs) {
|
|
4391
|
+
case "arrayBuffer":
|
|
4392
|
+
case "blob":
|
|
4393
|
+
case "text":
|
|
4394
|
+
emptyData = await response[parseAs]();
|
|
4395
|
+
break;
|
|
4396
|
+
case "formData":
|
|
4397
|
+
emptyData = new FormData();
|
|
4398
|
+
break;
|
|
4399
|
+
case "stream":
|
|
4400
|
+
emptyData = response.body;
|
|
4401
|
+
break;
|
|
4402
|
+
case "json":
|
|
4403
|
+
default:
|
|
4404
|
+
emptyData = {};
|
|
4405
|
+
break;
|
|
4406
|
+
}
|
|
4407
|
+
return {
|
|
4408
|
+
data: emptyData,
|
|
4409
|
+
...result
|
|
4410
|
+
};
|
|
4411
|
+
}
|
|
4412
|
+
let data;
|
|
4408
4413
|
switch (parseAs) {
|
|
4409
4414
|
case "arrayBuffer":
|
|
4410
4415
|
case "blob":
|
|
4416
|
+
case "formData":
|
|
4411
4417
|
case "text":
|
|
4412
|
-
|
|
4418
|
+
data = await response[parseAs]();
|
|
4413
4419
|
break;
|
|
4414
|
-
case "
|
|
4415
|
-
|
|
4420
|
+
case "json": {
|
|
4421
|
+
const text12 = await response.text();
|
|
4422
|
+
data = text12 ? JSON.parse(text12) : {};
|
|
4416
4423
|
break;
|
|
4424
|
+
}
|
|
4417
4425
|
case "stream":
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4426
|
+
return {
|
|
4427
|
+
data: response.body,
|
|
4428
|
+
...result
|
|
4429
|
+
};
|
|
4430
|
+
}
|
|
4431
|
+
if (parseAs === "json") {
|
|
4432
|
+
if (opts.responseValidator) {
|
|
4433
|
+
await opts.responseValidator(data);
|
|
4434
|
+
}
|
|
4435
|
+
if (opts.responseTransformer) {
|
|
4436
|
+
data = await opts.responseTransformer(data);
|
|
4437
|
+
}
|
|
4424
4438
|
}
|
|
4425
4439
|
return {
|
|
4426
|
-
data
|
|
4440
|
+
data,
|
|
4427
4441
|
...result
|
|
4428
4442
|
};
|
|
4429
4443
|
}
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
case "json":
|
|
4436
|
-
case "text":
|
|
4437
|
-
data = await response[parseAs]();
|
|
4438
|
-
break;
|
|
4439
|
-
case "stream":
|
|
4440
|
-
return {
|
|
4441
|
-
data: response.body,
|
|
4442
|
-
...result
|
|
4443
|
-
};
|
|
4444
|
+
const textError = await response.text();
|
|
4445
|
+
let jsonError;
|
|
4446
|
+
try {
|
|
4447
|
+
jsonError = JSON.parse(textError);
|
|
4448
|
+
} catch {
|
|
4444
4449
|
}
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
if (
|
|
4450
|
-
|
|
4450
|
+
throw jsonError ?? textError;
|
|
4451
|
+
} catch (error) {
|
|
4452
|
+
let finalError = error;
|
|
4453
|
+
for (const fn of interceptors.error.fns) {
|
|
4454
|
+
if (fn) {
|
|
4455
|
+
finalError = await fn(finalError, response, options);
|
|
4451
4456
|
}
|
|
4452
4457
|
}
|
|
4458
|
+
finalError = finalError || {};
|
|
4459
|
+
if (throwOnError) {
|
|
4460
|
+
throw finalError;
|
|
4461
|
+
}
|
|
4453
4462
|
return {
|
|
4454
|
-
|
|
4455
|
-
|
|
4463
|
+
error: finalError,
|
|
4464
|
+
response
|
|
4456
4465
|
};
|
|
4457
4466
|
}
|
|
4458
|
-
const textError = await response.text();
|
|
4459
|
-
let jsonError;
|
|
4460
|
-
try {
|
|
4461
|
-
jsonError = JSON.parse(textError);
|
|
4462
|
-
} catch {
|
|
4463
|
-
}
|
|
4464
|
-
const error = jsonError ?? textError;
|
|
4465
|
-
let finalError = error;
|
|
4466
|
-
for (const fn of interceptors.error.fns) {
|
|
4467
|
-
if (fn) {
|
|
4468
|
-
finalError = await fn(error, response, opts);
|
|
4469
|
-
}
|
|
4470
|
-
}
|
|
4471
|
-
finalError = finalError || {};
|
|
4472
|
-
if (opts.throwOnError) {
|
|
4473
|
-
throw finalError;
|
|
4474
|
-
}
|
|
4475
|
-
return {
|
|
4476
|
-
error: finalError,
|
|
4477
|
-
...result
|
|
4478
|
-
};
|
|
4479
4467
|
};
|
|
4480
4468
|
const makeMethodFn = (method) => (options) => request({ ...options, method });
|
|
4481
4469
|
const makeSseFn = (method) => async (options) => {
|
|
@@ -4483,15 +4471,10 @@ var createClient = (config = {}) => {
|
|
|
4483
4471
|
return createSseClient({
|
|
4484
4472
|
...opts,
|
|
4485
4473
|
body: opts.body,
|
|
4486
|
-
headers: opts.headers,
|
|
4487
4474
|
method,
|
|
4488
4475
|
onRequest: async (url2, init) => {
|
|
4489
4476
|
let request2 = new Request(url2, init);
|
|
4490
|
-
const requestInit = {
|
|
4491
|
-
...init,
|
|
4492
|
-
method: init.method,
|
|
4493
|
-
url: url2
|
|
4494
|
-
};
|
|
4477
|
+
const requestInit = { ...init, url: url2 };
|
|
4495
4478
|
for (const fn of interceptors.request.fns) {
|
|
4496
4479
|
if (fn) {
|
|
4497
4480
|
await fn(requestInit);
|
|
@@ -4500,11 +4483,13 @@ var createClient = (config = {}) => {
|
|
|
4500
4483
|
}
|
|
4501
4484
|
return request2;
|
|
4502
4485
|
},
|
|
4486
|
+
serializedBody: getValidRequestBody(opts),
|
|
4503
4487
|
url
|
|
4504
4488
|
});
|
|
4505
4489
|
};
|
|
4490
|
+
const _buildUrl = (options) => buildUrl({ ..._config, ...options });
|
|
4506
4491
|
return {
|
|
4507
|
-
buildUrl,
|
|
4492
|
+
buildUrl: _buildUrl,
|
|
4508
4493
|
connect: makeMethodFn("CONNECT"),
|
|
4509
4494
|
delete: makeMethodFn("DELETE"),
|
|
4510
4495
|
get: makeMethodFn("GET"),
|
|
@@ -4536,34 +4521,17 @@ var createClient = (config = {}) => {
|
|
|
4536
4521
|
var client = createClient(createClientConfig(createConfig()));
|
|
4537
4522
|
|
|
4538
4523
|
// src/client/sdk.gen.ts
|
|
4539
|
-
var getApiV1CreditsBalance = (options) => {
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
};
|
|
4551
|
-
var postApiV1CreditsPurchase = (options) => {
|
|
4552
|
-
return (options.client ?? client).post({
|
|
4553
|
-
url: "/api/v1/credits/purchase",
|
|
4554
|
-
...options,
|
|
4555
|
-
headers: {
|
|
4556
|
-
"Content-Type": "application/json",
|
|
4557
|
-
...options.headers
|
|
4558
|
-
}
|
|
4559
|
-
});
|
|
4560
|
-
};
|
|
4561
|
-
var getApiV1Models = (options) => {
|
|
4562
|
-
return (options?.client ?? client).get({
|
|
4563
|
-
url: "/api/v1/models",
|
|
4564
|
-
...options
|
|
4565
|
-
});
|
|
4566
|
-
};
|
|
4524
|
+
var getApiV1CreditsBalance = (options) => (options?.client ?? client).get({ url: "/api/v1/credits/balance", ...options });
|
|
4525
|
+
var getApiV1CreditsPacks = (options) => (options?.client ?? client).get({ url: "/api/v1/credits/packs", ...options });
|
|
4526
|
+
var postApiV1CreditsPurchase = (options) => (options.client ?? client).post({
|
|
4527
|
+
url: "/api/v1/credits/purchase",
|
|
4528
|
+
...options,
|
|
4529
|
+
headers: {
|
|
4530
|
+
"Content-Type": "application/json",
|
|
4531
|
+
...options.headers
|
|
4532
|
+
}
|
|
4533
|
+
});
|
|
4534
|
+
var getApiV1Models = (options) => (options?.client ?? client).get({ url: "/api/v1/models", ...options });
|
|
4567
4535
|
|
|
4568
4536
|
// src/react/useCredits.ts
|
|
4569
4537
|
function useCredits(options = {}) {
|
|
@@ -8640,6 +8608,13 @@ async function synthesizeProfile(ctx, options = {}) {
|
|
|
8640
8608
|
includeSuperseded: true
|
|
8641
8609
|
});
|
|
8642
8610
|
const watermark = computeVaultWatermark(memories);
|
|
8611
|
+
const observationTrends = summarizeObservationTrends(
|
|
8612
|
+
memories.filter((m) => !m.isDeleted && m.supersededBy === null).map((m) => ({
|
|
8613
|
+
createdAt: m.createdAt,
|
|
8614
|
+
lastObservedAt: m.lastObservedAt,
|
|
8615
|
+
proofCount: m.proofCount
|
|
8616
|
+
}))
|
|
8617
|
+
);
|
|
8643
8618
|
const presentIds = new Set(memories.map((m) => m.uniqueId));
|
|
8644
8619
|
const hasStaleSections = previous?.sections.some((s) => s.stale);
|
|
8645
8620
|
const citesMissingFact = previous?.sections.some(
|
|
@@ -8647,10 +8622,14 @@ async function synthesizeProfile(ctx, options = {}) {
|
|
|
8647
8622
|
);
|
|
8648
8623
|
if (previous && previous.vaultWatermark === watermark && !hasStaleSections && !citesMissingFact) {
|
|
8649
8624
|
const sameOrder = previous.sections.length === facets.length && facets.every((f, i) => previous.sections[i]?.key === f.key);
|
|
8650
|
-
if (sameOrder)
|
|
8625
|
+
if (sameOrder) {
|
|
8626
|
+
if (trendsEqual(previous.observationTrends, observationTrends)) return previous;
|
|
8627
|
+
return { ...previous, observationTrends };
|
|
8628
|
+
}
|
|
8651
8629
|
return {
|
|
8652
8630
|
...previous,
|
|
8653
|
-
sections: facets.map((f) => previous.sections.find((s) => s.key === f.key))
|
|
8631
|
+
sections: facets.map((f) => previous.sections.find((s) => s.key === f.key)),
|
|
8632
|
+
observationTrends
|
|
8654
8633
|
};
|
|
8655
8634
|
}
|
|
8656
8635
|
const staleKeys = await computeStaleFacetKeys(ctx, memories, facets, previous, watermark);
|
|
@@ -8683,6 +8662,7 @@ async function synthesizeProfile(ctx, options = {}) {
|
|
|
8683
8662
|
sections,
|
|
8684
8663
|
vaultWatermark: watermark,
|
|
8685
8664
|
config,
|
|
8665
|
+
observationTrends,
|
|
8686
8666
|
generatedAt: Date.now()
|
|
8687
8667
|
};
|
|
8688
8668
|
}
|
|
@@ -8693,6 +8673,10 @@ function configMatches(a, b) {
|
|
|
8693
8673
|
function facetsSignature(facets) {
|
|
8694
8674
|
return facets.map((f) => JSON.stringify([f.key, f.label, f.query, f.guidance])).sort().join("\n");
|
|
8695
8675
|
}
|
|
8676
|
+
function trendsEqual(a, b) {
|
|
8677
|
+
if (!a) return false;
|
|
8678
|
+
return a.new === b.new && a.strengthening === b.strengthening && a.stable === b.stable && a.weakening === b.weakening && a.stale === b.stale;
|
|
8679
|
+
}
|
|
8696
8680
|
function changeTime(m) {
|
|
8697
8681
|
return Math.max(m.updatedAt.getTime(), m.supersededAt ?? 0, m.lastObservedAt ?? 0);
|
|
8698
8682
|
}
|
|
@@ -14411,6 +14395,8 @@ export {
|
|
|
14411
14395
|
StreamExpiredError,
|
|
14412
14396
|
TOPICS_EXTRACTION_VERSION,
|
|
14413
14397
|
TOPIC_EXTRACTION_BATCH_SIZE,
|
|
14398
|
+
TREND_RECENT_WINDOW_DAYS,
|
|
14399
|
+
TREND_STALE_WINDOW_DAYS,
|
|
14414
14400
|
VAULT_SIZE_HOP_CAP,
|
|
14415
14401
|
WalletPoller,
|
|
14416
14402
|
addConversationMemoriesOp,
|
|
@@ -14426,6 +14412,7 @@ export {
|
|
|
14426
14412
|
classifyCryptoPriceBatch,
|
|
14427
14413
|
classifyDecay,
|
|
14428
14414
|
classifyInjectionCandidates,
|
|
14415
|
+
classifyObservationTrend,
|
|
14429
14416
|
classifyStockPrice,
|
|
14430
14417
|
classifyStockPriceBatch,
|
|
14431
14418
|
classifyWeather,
|
|
@@ -14525,6 +14512,7 @@ export {
|
|
|
14525
14512
|
stampTopicsExtractedAtOp,
|
|
14526
14513
|
streamCancelPath,
|
|
14527
14514
|
streamReplayPath,
|
|
14515
|
+
summarizeObservationTrends,
|
|
14528
14516
|
supersedeVaultMemoryOp,
|
|
14529
14517
|
synthesizeProfile,
|
|
14530
14518
|
traverseGraphLane,
|