@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.
@@ -2231,6 +2231,9 @@ async function withEmbeddingRetry(call) {
2231
2231
  }
2232
2232
  }
2233
2233
  if (threw) throw lastThrown;
2234
+ if (last?.error instanceof Error && last.response?.status === void 0) {
2235
+ throw last.error;
2236
+ }
2234
2237
  return last;
2235
2238
  }
2236
2239
  function isFatalEmbeddingError(err) {
@@ -5276,6 +5279,48 @@ var init_graphTraversal = __esm({
5276
5279
  }
5277
5280
  });
5278
5281
 
5282
+ // src/lib/memory/observationTrend.ts
5283
+ function toMs(value) {
5284
+ return value instanceof Date ? value.getTime() : value;
5285
+ }
5286
+ function classifyObservationTrend(input, now = Date.now()) {
5287
+ const createdMs = toMs(input.createdAt);
5288
+ if (!Number.isFinite(createdMs) || !Number.isFinite(now)) return "stable";
5289
+ const lastMsRaw = input.lastObservedAt;
5290
+ const lastMs = lastMsRaw !== null && lastMsRaw !== void 0 && Number.isFinite(lastMsRaw) ? Math.max(createdMs, lastMsRaw) : createdMs;
5291
+ const proofs = Math.max(1, input.proofCount ?? 1);
5292
+ const ageDays2 = Math.max(0, (now - createdMs) / DAY_MS2);
5293
+ const daysSinceLast = Math.max(0, (now - lastMs) / DAY_MS2);
5294
+ if (daysSinceLast >= TREND_STALE_WINDOW_DAYS) return "stale";
5295
+ if (daysSinceLast >= TREND_RECENT_WINDOW_DAYS) return "weakening";
5296
+ if (ageDays2 <= TREND_RECENT_WINDOW_DAYS && proofs <= 2) return "new";
5297
+ if (proofs >= 3) return "strengthening";
5298
+ if (proofs >= 2 && ageDays2 > TREND_RECENT_WINDOW_DAYS) return "strengthening";
5299
+ return "stable";
5300
+ }
5301
+ function summarizeObservationTrends(inputs, now = Date.now()) {
5302
+ const counts = {
5303
+ new: 0,
5304
+ strengthening: 0,
5305
+ stable: 0,
5306
+ weakening: 0,
5307
+ stale: 0
5308
+ };
5309
+ for (const input of inputs) {
5310
+ counts[classifyObservationTrend(input, now)]++;
5311
+ }
5312
+ return counts;
5313
+ }
5314
+ var DAY_MS2, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS;
5315
+ var init_observationTrend = __esm({
5316
+ "src/lib/memory/observationTrend.ts"() {
5317
+ "use strict";
5318
+ DAY_MS2 = 1e3 * 60 * 60 * 24;
5319
+ TREND_RECENT_WINDOW_DAYS = 30;
5320
+ TREND_STALE_WINDOW_DAYS = 90;
5321
+ }
5322
+ });
5323
+
5279
5324
  // src/lib/memory/queryTemporal.ts
5280
5325
  function startOfDay(ts) {
5281
5326
  const d = new Date(ts);
@@ -5675,7 +5720,7 @@ async function recall(query, ctx, options = {}) {
5675
5720
  const fuseStart = nowMs();
5676
5721
  if (types.length === 1 || factResults.length === 0 || chunkResults.length === 0) {
5677
5722
  const memories2 = [
5678
- ...factResults.map(toFactMemory),
5723
+ ...factResults.map((r) => toFactMemory(r, options.now)),
5679
5724
  ...chunkResults.map(toChunkMemory)
5680
5725
  ];
5681
5726
  memories2.sort((a, b) => b.score - a.score);
@@ -5696,7 +5741,7 @@ async function recall(query, ctx, options = {}) {
5696
5741
  const fused = rrfFuse([factRanking, chunkRanking], options.rrfK);
5697
5742
  const byId = /* @__PURE__ */ new Map();
5698
5743
  for (const r of factResults) {
5699
- const m = toFactMemory(r);
5744
+ const m = toFactMemory(r, options.now);
5700
5745
  m.score = fused.get(`fact:${r.uniqueId}`) ?? 0;
5701
5746
  if (!m.scoreBreakdown) m.scoreBreakdown = {};
5702
5747
  m.scoreBreakdown.fused = r.similarity;
@@ -5745,7 +5790,10 @@ async function recall(query, ctx, options = {}) {
5745
5790
  ...vaultSize !== void 0 && { vaultSize }
5746
5791
  };
5747
5792
  }
5748
- function toFactMemory(r) {
5793
+ function toFactMemory(r, now) {
5794
+ const createdAt = r.createdAt ?? /* @__PURE__ */ new Date(0);
5795
+ const proofCount = r.proofCount ?? void 0;
5796
+ const lastObservedAt = r.lastObservedAt ?? null;
5749
5797
  return {
5750
5798
  id: r.uniqueId,
5751
5799
  kind: "fact",
@@ -5761,6 +5809,18 @@ function toFactMemory(r) {
5761
5809
  // (and UI reading them) carry the fact's type. Undefined when untyped.
5762
5810
  ...r.factType !== void 0 && { factType: r.factType },
5763
5811
  ...r.sourceChunkIds !== void 0 && r.sourceChunkIds !== null && { sourceChunkIds: r.sourceChunkIds },
5812
+ ...proofCount !== void 0 && proofCount !== null && { proofCount },
5813
+ ...lastObservedAt !== null && { lastObservedAt },
5814
+ // C2 — algorithmic trend from evidence timestamps (no LLM). Honor
5815
+ // RecallOptions.now so back-dated eval harnesses get consistent labels.
5816
+ observationTrend: classifyObservationTrend(
5817
+ {
5818
+ createdAt,
5819
+ lastObservedAt,
5820
+ proofCount
5821
+ },
5822
+ now ?? Date.now()
5823
+ ),
5764
5824
  // r.similarity from searchVaultMemoriesWithSize is the fused score
5765
5825
  // (cosine + BM25 + RRF + recency + proof) when useFusion=true (the
5766
5826
  // default) and pure cosine when useFusion=false. The breakdown
@@ -5769,7 +5829,7 @@ function toFactMemory(r) {
5769
5829
  content: r.content,
5770
5830
  score: r.similarity,
5771
5831
  scoreBreakdown: { fused: r.similarity },
5772
- createdAt: r.createdAt ?? /* @__PURE__ */ new Date(0),
5832
+ createdAt,
5773
5833
  updatedAt: r.updatedAt ?? /* @__PURE__ */ new Date(0)
5774
5834
  };
5775
5835
  }
@@ -5852,6 +5912,7 @@ var init_recall = __esm({
5852
5912
  init_embeddings();
5853
5913
  init_searchTool();
5854
5914
  init_graphTraversal();
5915
+ init_observationTrend();
5855
5916
  init_queryEntities();
5856
5917
  init_queryTemporal();
5857
5918
  init_rrf();
@@ -6447,6 +6508,7 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
6447
6508
  createdAt: m.createdAt,
6448
6509
  updatedAt: m.updatedAt,
6449
6510
  proofCount: m.proofCount,
6511
+ lastObservedAt: m.lastObservedAt,
6450
6512
  eventTimeStart: m.eventTimeStart,
6451
6513
  sourceChunkIds: m.sourceChunkIds,
6452
6514
  eventTimeEnd: m.eventTimeEnd,
@@ -6463,13 +6525,27 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
6463
6525
  );
6464
6526
  }
6465
6527
  }
6466
- const timestampById = new Map(
6467
- memories.map((m) => [m.uniqueId, { createdAt: m.createdAt, updatedAt: m.updatedAt }])
6528
+ const metaById = new Map(
6529
+ memories.map((m) => [
6530
+ m.uniqueId,
6531
+ {
6532
+ createdAt: m.createdAt,
6533
+ updatedAt: m.updatedAt,
6534
+ proofCount: m.proofCount,
6535
+ lastObservedAt: m.lastObservedAt
6536
+ }
6537
+ ])
6468
6538
  );
6469
6539
  const stampTimestamps = (out) => {
6470
6540
  const results2 = out.results.map((r) => {
6471
- const ts = timestampById.get(r.uniqueId);
6472
- return ts ? { ...r, createdAt: ts.createdAt, updatedAt: ts.updatedAt } : r;
6541
+ const meta = metaById.get(r.uniqueId);
6542
+ return meta ? {
6543
+ ...r,
6544
+ createdAt: meta.createdAt,
6545
+ updatedAt: meta.updatedAt,
6546
+ proofCount: meta.proofCount,
6547
+ lastObservedAt: meta.lastObservedAt
6548
+ } : r;
6473
6549
  });
6474
6550
  return {
6475
6551
  results: results2,
@@ -6958,6 +7034,8 @@ __export(index_exports, {
6958
7034
  THEME_ATTRS: () => THEME_ATTRS,
6959
7035
  TOPICS_EXTRACTION_VERSION: () => TOPICS_EXTRACTION_VERSION,
6960
7036
  TOPIC_EXTRACTION_BATCH_SIZE: () => TOPIC_EXTRACTION_BATCH_SIZE,
7037
+ TREND_RECENT_WINDOW_DAYS: () => TREND_RECENT_WINDOW_DAYS,
7038
+ TREND_STALE_WINDOW_DAYS: () => TREND_STALE_WINDOW_DAYS,
6961
7039
  TextProcessor: () => TextProcessor,
6962
7040
  UIInteractionProvider: () => UIInteractionProvider,
6963
7041
  VAULT_SIZE_HOP_CAP: () => VAULT_SIZE_HOP_CAP,
@@ -6979,6 +7057,7 @@ __export(index_exports, {
6979
7057
  classifyCryptoPriceBatch: () => classifyCryptoPriceBatch,
6980
7058
  classifyDecay: () => classifyDecay,
6981
7059
  classifyInjectionCandidates: () => classifyInjectionCandidates,
7060
+ classifyObservationTrend: () => classifyObservationTrend,
6982
7061
  classifyStockPrice: () => classifyStockPrice,
6983
7062
  classifyStockPriceBatch: () => classifyStockPriceBatch,
6984
7063
  classifyWeather: () => classifyWeather,
@@ -7248,6 +7327,7 @@ __export(index_exports, {
7248
7327
  storeNotionReturnUrl: () => storeNotionReturnUrl,
7249
7328
  streamCancelPath: () => streamCancelPath,
7250
7329
  streamReplayPath: () => streamReplayPath,
7330
+ summarizeObservationTrends: () => summarizeObservationTrends,
7251
7331
  supersedeVaultMemoryOp: () => supersedeVaultMemoryOp,
7252
7332
  synthesizeProfile: () => synthesizeProfile,
7253
7333
  traverseGraphLane: () => traverseGraphLane,
@@ -7302,7 +7382,7 @@ module.exports = __toCommonJS(index_exports);
7302
7382
  init_clientConfig();
7303
7383
 
7304
7384
  // src/client/core/serverSentEvents.gen.ts
7305
- var createSseClient = ({
7385
+ function createSseClient({
7306
7386
  onRequest,
7307
7387
  onSseError,
7308
7388
  onSseEvent,
@@ -7314,7 +7394,7 @@ var createSseClient = ({
7314
7394
  sseSleepFn,
7315
7395
  url,
7316
7396
  ...options
7317
- }) => {
7397
+ }) {
7318
7398
  let lastEventId;
7319
7399
  const sleep4 = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
7320
7400
  const createStream = async function* () {
@@ -7342,10 +7422,7 @@ var createSseClient = ({
7342
7422
  }
7343
7423
  const _fetch = options.fetch ?? globalThis.fetch;
7344
7424
  const response = await _fetch(request);
7345
- if (!response.ok)
7346
- throw new Error(
7347
- `SSE failed: ${response.status} ${response.statusText}`
7348
- );
7425
+ if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
7349
7426
  if (!response.body) throw new Error("No body in SSE response");
7350
7427
  const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
7351
7428
  let buffer = "";
@@ -7361,6 +7438,7 @@ var createSseClient = ({
7361
7438
  const { done, value } = await reader.read();
7362
7439
  if (done) break;
7363
7440
  buffer += value;
7441
+ buffer = buffer.replace(/\r\n?/g, "\n");
7364
7442
  const chunks = buffer.split("\n\n");
7365
7443
  buffer = chunks.pop() ?? "";
7366
7444
  for (const chunk of chunks) {
@@ -7375,10 +7453,7 @@ var createSseClient = ({
7375
7453
  } else if (line.startsWith("id:")) {
7376
7454
  lastEventId = line.replace(/^id:\s*/, "");
7377
7455
  } else if (line.startsWith("retry:")) {
7378
- const parsed = Number.parseInt(
7379
- line.replace(/^retry:\s*/, ""),
7380
- 10
7381
- );
7456
+ const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
7382
7457
  if (!Number.isNaN(parsed)) {
7383
7458
  retryDelay = parsed;
7384
7459
  }
@@ -7424,17 +7499,14 @@ var createSseClient = ({
7424
7499
  if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
7425
7500
  break;
7426
7501
  }
7427
- const backoff = Math.min(
7428
- retryDelay * 2 ** (attempt - 1),
7429
- sseMaxRetryDelay ?? 3e4
7430
- );
7502
+ const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
7431
7503
  await sleep4(backoff);
7432
7504
  }
7433
7505
  }
7434
7506
  };
7435
7507
  const stream = createStream();
7436
7508
  return { stream };
7437
- };
7509
+ }
7438
7510
 
7439
7511
  // src/lib/chat/toolLoop.ts
7440
7512
  init_clientConfig();
@@ -15260,12 +15332,12 @@ function createChunkVectorCache(maxSize = DEFAULT_CHUNK_CACHE_SIZE) {
15260
15332
 
15261
15333
  // src/lib/memory/decay.ts
15262
15334
  init_logger();
15263
- var DAY_MS2 = 24 * 60 * 60 * 1e3;
15264
- var SHORT_TTL_MS = 30 * DAY_MS2;
15265
- var MEDIUM_TTL_MS = 180 * DAY_MS2;
15335
+ var DAY_MS3 = 24 * 60 * 60 * 1e3;
15336
+ var SHORT_TTL_MS = 30 * DAY_MS3;
15337
+ var MEDIUM_TTL_MS = 180 * DAY_MS3;
15266
15338
  var NEVER_TTL_MS = Number.POSITIVE_INFINITY;
15267
- var HARD_DELETE_WINDOW_MS = 30 * DAY_MS2;
15268
- var PAST_EVENT_GRACE_MS = 7 * DAY_MS2;
15339
+ var HARD_DELETE_WINDOW_MS = 30 * DAY_MS3;
15340
+ var PAST_EVENT_GRACE_MS = 7 * DAY_MS3;
15269
15341
  var DEFAULT_DECAY_POLICY = {
15270
15342
  ttlByType: {
15271
15343
  identity: NEVER_TTL_MS,
@@ -15525,6 +15597,7 @@ function createDecaySweeper(options) {
15525
15597
 
15526
15598
  // src/lib/memory/index.ts
15527
15599
  init_graphTraversal();
15600
+ init_observationTrend();
15528
15601
  init_recall();
15529
15602
 
15530
15603
  // src/lib/memory/recallTool.ts
@@ -15891,6 +15964,7 @@ init_logger();
15891
15964
  init_constants();
15892
15965
  init_embeddings();
15893
15966
  init_vector();
15967
+ init_observationTrend();
15894
15968
  var DEFAULT_SYNTHESIS_MODEL = "inclusionai/ling-2.6-flash";
15895
15969
  var DEFAULT_FACET_RECALL_LIMIT = 20;
15896
15970
  var DEFAULT_FACET_MAX_TOKENS = 512;
@@ -15976,6 +16050,13 @@ async function synthesizeProfile(ctx, options = {}) {
15976
16050
  includeSuperseded: true
15977
16051
  });
15978
16052
  const watermark = computeVaultWatermark(memories);
16053
+ const observationTrends = summarizeObservationTrends(
16054
+ memories.filter((m) => !m.isDeleted && m.supersededBy === null).map((m) => ({
16055
+ createdAt: m.createdAt,
16056
+ lastObservedAt: m.lastObservedAt,
16057
+ proofCount: m.proofCount
16058
+ }))
16059
+ );
15979
16060
  const presentIds = new Set(memories.map((m) => m.uniqueId));
15980
16061
  const hasStaleSections = previous?.sections.some((s) => s.stale);
15981
16062
  const citesMissingFact = previous?.sections.some(
@@ -15983,10 +16064,14 @@ async function synthesizeProfile(ctx, options = {}) {
15983
16064
  );
15984
16065
  if (previous && previous.vaultWatermark === watermark && !hasStaleSections && !citesMissingFact) {
15985
16066
  const sameOrder = previous.sections.length === facets.length && facets.every((f, i) => previous.sections[i]?.key === f.key);
15986
- if (sameOrder) return previous;
16067
+ if (sameOrder) {
16068
+ if (trendsEqual(previous.observationTrends, observationTrends)) return previous;
16069
+ return { ...previous, observationTrends };
16070
+ }
15987
16071
  return {
15988
16072
  ...previous,
15989
- sections: facets.map((f) => previous.sections.find((s) => s.key === f.key))
16073
+ sections: facets.map((f) => previous.sections.find((s) => s.key === f.key)),
16074
+ observationTrends
15990
16075
  };
15991
16076
  }
15992
16077
  const staleKeys = await computeStaleFacetKeys(ctx, memories, facets, previous, watermark);
@@ -16019,6 +16104,7 @@ async function synthesizeProfile(ctx, options = {}) {
16019
16104
  sections,
16020
16105
  vaultWatermark: watermark,
16021
16106
  config,
16107
+ observationTrends,
16022
16108
  generatedAt: Date.now()
16023
16109
  };
16024
16110
  }
@@ -16029,6 +16115,10 @@ function configMatches(a, b) {
16029
16115
  function facetsSignature(facets) {
16030
16116
  return facets.map((f) => JSON.stringify([f.key, f.label, f.query, f.guidance])).sort().join("\n");
16031
16117
  }
16118
+ function trendsEqual(a, b) {
16119
+ if (!a) return false;
16120
+ return a.new === b.new && a.strengthening === b.strengthening && a.stable === b.stable && a.weakening === b.weakening && a.stale === b.stale;
16121
+ }
16032
16122
  function changeTime(m) {
16033
16123
  return Math.max(m.updatedAt.getTime(), m.supersededAt ?? 0, m.lastObservedAt ?? 0);
16034
16124
  }
@@ -24619,10 +24709,7 @@ var import_react14 = require("react");
24619
24709
 
24620
24710
  // src/client/core/bodySerializer.gen.ts
24621
24711
  var jsonBodySerializer = {
24622
- bodySerializer: (body) => JSON.stringify(
24623
- body,
24624
- (_key, value) => typeof value === "bigint" ? value.toString() : value
24625
- )
24712
+ bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
24626
24713
  };
24627
24714
 
24628
24715
  // src/client/core/pathSerializer.gen.ts
@@ -24724,11 +24811,7 @@ var serializeObjectParam = ({
24724
24811
  if (style !== "deepObject" && !explode) {
24725
24812
  let values = [];
24726
24813
  Object.entries(value).forEach(([key, v]) => {
24727
- values = [
24728
- ...values,
24729
- key,
24730
- allowReserved ? v : encodeURIComponent(v)
24731
- ];
24814
+ values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
24732
24815
  });
24733
24816
  const joinedValues2 = values.join(",");
24734
24817
  switch (style) {
@@ -24811,10 +24894,7 @@ var defaultPathSerializer = ({ path, url: _url }) => {
24811
24894
  continue;
24812
24895
  }
24813
24896
  if (Array.isArray(value)) {
24814
- url = url.replace(
24815
- match,
24816
- serializeArrayParam({ explode, name, style, value })
24817
- );
24897
+ url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
24818
24898
  continue;
24819
24899
  }
24820
24900
  if (typeof value === "object") {
@@ -24909,9 +24989,7 @@ var getParseAs = (contentType) => {
24909
24989
  if (cleanContent === "multipart/form-data") {
24910
24990
  return "formData";
24911
24991
  }
24912
- if (["application/", "audio/", "image/", "video/"].some(
24913
- (type) => cleanContent.startsWith(type)
24914
- )) {
24992
+ if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
24915
24993
  return "blob";
24916
24994
  }
24917
24995
  if (cleanContent.startsWith("text/")) {
@@ -24928,11 +25006,8 @@ var checkForExistence = (options, name) => {
24928
25006
  }
24929
25007
  return false;
24930
25008
  };
24931
- var setAuthParams = async ({
24932
- security,
24933
- ...options
24934
- }) => {
24935
- for (const auth of security) {
25009
+ async function setAuthParams(options) {
25010
+ for (const auth of options.security ?? []) {
24936
25011
  if (checkForExistence(options, auth.name)) {
24937
25012
  continue;
24938
25013
  }
@@ -24957,7 +25032,7 @@ var setAuthParams = async ({
24957
25032
  break;
24958
25033
  }
24959
25034
  }
24960
- };
25035
+ }
24961
25036
  var buildUrl = (options) => {
24962
25037
  const url = getUrl({
24963
25038
  baseUrl: options.baseUrl,
@@ -25109,10 +25184,7 @@ var createClient = (config = {}) => {
25109
25184
  serializedBody: void 0
25110
25185
  };
25111
25186
  if (opts.security) {
25112
- await setAuthParams({
25113
- ...opts,
25114
- security: opts.security
25115
- });
25187
+ await setAuthParams(opts);
25116
25188
  }
25117
25189
  if (opts.requestValidator) {
25118
25190
  await opts.requestValidator(opts);
@@ -25123,105 +25195,115 @@ var createClient = (config = {}) => {
25123
25195
  if (opts.body === void 0 || opts.serializedBody === "") {
25124
25196
  opts.headers.delete("Content-Type");
25125
25197
  }
25126
- const url = buildUrl(opts);
25127
- return { opts, url };
25198
+ const resolvedOpts = opts;
25199
+ const url = buildUrl(resolvedOpts);
25200
+ return { opts: resolvedOpts, url };
25128
25201
  };
25129
25202
  const request = async (options) => {
25130
- const { opts, url } = await beforeRequest(options);
25131
- for (const fn of interceptors.request.fns) {
25132
- if (fn) {
25133
- await fn(opts);
25203
+ const throwOnError = options.throwOnError ?? _config.throwOnError;
25204
+ let response;
25205
+ try {
25206
+ const { opts, url } = await beforeRequest(options);
25207
+ for (const fn of interceptors.request.fns) {
25208
+ if (fn) {
25209
+ await fn(opts);
25210
+ }
25134
25211
  }
25135
- }
25136
- const _fetch = opts.fetch;
25137
- const requestInit = {
25138
- ...opts,
25139
- body: getValidRequestBody(opts)
25140
- };
25141
- let response = await _fetch(url, requestInit);
25142
- for (const fn of interceptors.response.fns) {
25143
- if (fn) {
25144
- response = await fn(response, opts);
25212
+ const _fetch = opts.fetch;
25213
+ const requestInit = {
25214
+ ...opts,
25215
+ body: getValidRequestBody(opts)
25216
+ };
25217
+ response = await _fetch(url, requestInit);
25218
+ for (const fn of interceptors.response.fns) {
25219
+ if (fn) {
25220
+ response = await fn(response, opts);
25221
+ }
25145
25222
  }
25146
- }
25147
- const result = {
25148
- response
25149
- };
25150
- if (response.ok) {
25151
- const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
25152
- if (response.status === 204 || response.headers.get("Content-Length") === "0") {
25153
- let emptyData;
25223
+ const result = {
25224
+ response
25225
+ };
25226
+ if (response.ok) {
25227
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
25228
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
25229
+ let emptyData;
25230
+ switch (parseAs) {
25231
+ case "arrayBuffer":
25232
+ case "blob":
25233
+ case "text":
25234
+ emptyData = await response[parseAs]();
25235
+ break;
25236
+ case "formData":
25237
+ emptyData = new FormData();
25238
+ break;
25239
+ case "stream":
25240
+ emptyData = response.body;
25241
+ break;
25242
+ case "json":
25243
+ default:
25244
+ emptyData = {};
25245
+ break;
25246
+ }
25247
+ return {
25248
+ data: emptyData,
25249
+ ...result
25250
+ };
25251
+ }
25252
+ let data;
25154
25253
  switch (parseAs) {
25155
25254
  case "arrayBuffer":
25156
25255
  case "blob":
25256
+ case "formData":
25157
25257
  case "text":
25158
- emptyData = await response[parseAs]();
25258
+ data = await response[parseAs]();
25159
25259
  break;
25160
- case "formData":
25161
- emptyData = new FormData();
25260
+ case "json": {
25261
+ const text12 = await response.text();
25262
+ data = text12 ? JSON.parse(text12) : {};
25162
25263
  break;
25264
+ }
25163
25265
  case "stream":
25164
- emptyData = response.body;
25165
- break;
25166
- case "json":
25167
- default:
25168
- emptyData = {};
25169
- break;
25266
+ return {
25267
+ data: response.body,
25268
+ ...result
25269
+ };
25270
+ }
25271
+ if (parseAs === "json") {
25272
+ if (opts.responseValidator) {
25273
+ await opts.responseValidator(data);
25274
+ }
25275
+ if (opts.responseTransformer) {
25276
+ data = await opts.responseTransformer(data);
25277
+ }
25170
25278
  }
25171
25279
  return {
25172
- data: emptyData,
25280
+ data,
25173
25281
  ...result
25174
25282
  };
25175
25283
  }
25176
- let data;
25177
- switch (parseAs) {
25178
- case "arrayBuffer":
25179
- case "blob":
25180
- case "formData":
25181
- case "json":
25182
- case "text":
25183
- data = await response[parseAs]();
25184
- break;
25185
- case "stream":
25186
- return {
25187
- data: response.body,
25188
- ...result
25189
- };
25284
+ const textError = await response.text();
25285
+ let jsonError;
25286
+ try {
25287
+ jsonError = JSON.parse(textError);
25288
+ } catch {
25190
25289
  }
25191
- if (parseAs === "json") {
25192
- if (opts.responseValidator) {
25193
- await opts.responseValidator(data);
25194
- }
25195
- if (opts.responseTransformer) {
25196
- data = await opts.responseTransformer(data);
25290
+ throw jsonError ?? textError;
25291
+ } catch (error) {
25292
+ let finalError = error;
25293
+ for (const fn of interceptors.error.fns) {
25294
+ if (fn) {
25295
+ finalError = await fn(finalError, response, options);
25197
25296
  }
25198
25297
  }
25298
+ finalError = finalError || {};
25299
+ if (throwOnError) {
25300
+ throw finalError;
25301
+ }
25199
25302
  return {
25200
- data,
25201
- ...result
25303
+ error: finalError,
25304
+ response
25202
25305
  };
25203
25306
  }
25204
- const textError = await response.text();
25205
- let jsonError;
25206
- try {
25207
- jsonError = JSON.parse(textError);
25208
- } catch {
25209
- }
25210
- const error = jsonError ?? textError;
25211
- let finalError = error;
25212
- for (const fn of interceptors.error.fns) {
25213
- if (fn) {
25214
- finalError = await fn(error, response, opts);
25215
- }
25216
- }
25217
- finalError = finalError || {};
25218
- if (opts.throwOnError) {
25219
- throw finalError;
25220
- }
25221
- return {
25222
- error: finalError,
25223
- ...result
25224
- };
25225
25307
  };
25226
25308
  const makeMethodFn = (method) => (options) => request({ ...options, method });
25227
25309
  const makeSseFn = (method) => async (options) => {
@@ -25229,15 +25311,10 @@ var createClient = (config = {}) => {
25229
25311
  return createSseClient({
25230
25312
  ...opts,
25231
25313
  body: opts.body,
25232
- headers: opts.headers,
25233
25314
  method,
25234
25315
  onRequest: async (url2, init) => {
25235
25316
  let request2 = new Request(url2, init);
25236
- const requestInit = {
25237
- ...init,
25238
- method: init.method,
25239
- url: url2
25240
- };
25317
+ const requestInit = { ...init, url: url2 };
25241
25318
  for (const fn of interceptors.request.fns) {
25242
25319
  if (fn) {
25243
25320
  await fn(requestInit);
@@ -25246,11 +25323,13 @@ var createClient = (config = {}) => {
25246
25323
  }
25247
25324
  return request2;
25248
25325
  },
25326
+ serializedBody: getValidRequestBody(opts),
25249
25327
  url
25250
25328
  });
25251
25329
  };
25330
+ const _buildUrl = (options) => buildUrl({ ..._config, ...options });
25252
25331
  return {
25253
- buildUrl,
25332
+ buildUrl: _buildUrl,
25254
25333
  connect: makeMethodFn("CONNECT"),
25255
25334
  delete: makeMethodFn("DELETE"),
25256
25335
  get: makeMethodFn("GET"),
@@ -25283,156 +25362,88 @@ init_clientConfig();
25283
25362
  var client = createClient(createClientConfig(createConfig()));
25284
25363
 
25285
25364
  // src/client/sdk.gen.ts
25286
- var getApiV1Config = (options) => {
25287
- return (options?.client ?? client).get({
25288
- url: "/api/v1/config",
25289
- ...options
25290
- });
25291
- };
25292
- var getApiV1CreditsBalance = (options) => {
25293
- return (options?.client ?? client).get({
25294
- url: "/api/v1/credits/balance",
25295
- ...options
25296
- });
25297
- };
25298
- var getApiV1CreditsPacks = (options) => {
25299
- return (options?.client ?? client).get({
25300
- url: "/api/v1/credits/packs",
25301
- ...options
25302
- });
25303
- };
25304
- var postApiV1CreditsPurchase = (options) => {
25305
- return (options.client ?? client).post({
25306
- url: "/api/v1/credits/purchase",
25307
- ...options,
25308
- headers: {
25309
- "Content-Type": "application/json",
25310
- ...options.headers
25311
- }
25312
- });
25313
- };
25314
- var getApiV1Models = (options) => {
25315
- return (options?.client ?? client).get({
25316
- url: "/api/v1/models",
25317
- ...options
25318
- });
25319
- };
25320
- var postApiV1PhoneCalls = (options) => {
25321
- return (options.client ?? client).post({
25322
- url: "/api/v1/phone-calls",
25323
- ...options,
25324
- headers: {
25325
- "Content-Type": "application/json",
25326
- ...options.headers
25327
- }
25328
- });
25329
- };
25330
- var getApiV1PhoneCallsByCallId = (options) => {
25331
- return (options.client ?? client).get({
25332
- url: "/api/v1/phone-calls/{call_id}",
25333
- ...options
25334
- });
25335
- };
25336
- var postApiV1SubscriptionsCancel = (options) => {
25337
- return (options?.client ?? client).post({
25338
- url: "/api/v1/subscriptions/cancel",
25339
- ...options,
25340
- headers: {
25341
- "Content-Type": "application/json",
25342
- ...options?.headers
25343
- }
25344
- });
25345
- };
25346
- var postApiV1SubscriptionsCreateCheckoutSession = (options) => {
25347
- return (options.client ?? client).post({
25348
- url: "/api/v1/subscriptions/create-checkout-session",
25349
- ...options,
25350
- headers: {
25351
- "Content-Type": "application/json",
25352
- ...options.headers
25353
- }
25354
- });
25355
- };
25356
- var postApiV1SubscriptionsCustomerPortal = (options) => {
25357
- return (options.client ?? client).post({
25358
- url: "/api/v1/subscriptions/customer-portal",
25359
- ...options,
25360
- headers: {
25361
- "Content-Type": "application/json",
25362
- ...options.headers
25363
- }
25364
- });
25365
- };
25366
- var postApiV1SubscriptionsRenew = (options) => {
25367
- return (options?.client ?? client).post({
25368
- url: "/api/v1/subscriptions/renew",
25369
- ...options
25370
- });
25371
- };
25372
- var getApiV1SubscriptionsStatus = (options) => {
25373
- return (options?.client ?? client).get({
25374
- url: "/api/v1/subscriptions/status",
25375
- ...options
25376
- });
25377
- };
25378
- var getApiV1WalletsBinding = (options) => {
25379
- return (options?.client ?? client).get({
25380
- url: "/api/v1/wallets/binding",
25381
- ...options
25382
- });
25383
- };
25384
- var postApiV1WalletsBinding = (options) => {
25385
- return (options.client ?? client).post({
25386
- url: "/api/v1/wallets/binding",
25387
- ...options,
25388
- headers: {
25389
- "Content-Type": "application/json",
25390
- ...options.headers
25391
- }
25392
- });
25393
- };
25394
- var postApiV1WalletsBindingNonce = (options) => {
25395
- return (options?.client ?? client).post({
25396
- url: "/api/v1/wallets/binding/nonce",
25397
- ...options
25398
- });
25399
- };
25400
- var deleteApiV1WalletsBindingByAddress = (options) => {
25401
- return (options.client ?? client).delete({
25402
- url: "/api/v1/wallets/binding/{address}",
25403
- ...options
25404
- });
25405
- };
25406
- var postAuthOauthByProviderExchange = (options) => {
25407
- return (options.client ?? client).post({
25408
- url: "/auth/oauth/{provider}/exchange",
25409
- ...options,
25410
- headers: {
25411
- "Content-Type": "application/json",
25412
- ...options.headers
25413
- }
25414
- });
25415
- };
25416
- var postAuthOauthByProviderRefresh = (options) => {
25417
- return (options.client ?? client).post({
25418
- url: "/auth/oauth/{provider}/refresh",
25419
- ...options,
25420
- headers: {
25421
- "Content-Type": "application/json",
25422
- ...options.headers
25423
- }
25424
- });
25425
- };
25426
- var postAuthOauthByProviderRevoke = (options) => {
25427
- return (options.client ?? client).post({
25428
- url: "/auth/oauth/{provider}/revoke",
25429
- ...options,
25430
- headers: {
25431
- "Content-Type": "application/json",
25432
- ...options.headers
25433
- }
25434
- });
25435
- };
25365
+ var getApiV1Config = (options) => (options?.client ?? client).get({ url: "/api/v1/config", ...options });
25366
+ var getApiV1CreditsBalance = (options) => (options?.client ?? client).get({ url: "/api/v1/credits/balance", ...options });
25367
+ var getApiV1CreditsPacks = (options) => (options?.client ?? client).get({ url: "/api/v1/credits/packs", ...options });
25368
+ var postApiV1CreditsPurchase = (options) => (options.client ?? client).post({
25369
+ url: "/api/v1/credits/purchase",
25370
+ ...options,
25371
+ headers: {
25372
+ "Content-Type": "application/json",
25373
+ ...options.headers
25374
+ }
25375
+ });
25376
+ var getApiV1Models = (options) => (options?.client ?? client).get({ url: "/api/v1/models", ...options });
25377
+ var postApiV1PhoneCalls = (options) => (options.client ?? client).post({
25378
+ url: "/api/v1/phone-calls",
25379
+ ...options,
25380
+ headers: {
25381
+ "Content-Type": "application/json",
25382
+ ...options.headers
25383
+ }
25384
+ });
25385
+ var getApiV1PhoneCallsByCallId = (options) => (options.client ?? client).get({ url: "/api/v1/phone-calls/{call_id}", ...options });
25386
+ var postApiV1SubscriptionsCancel = (options) => (options?.client ?? client).post({
25387
+ url: "/api/v1/subscriptions/cancel",
25388
+ ...options,
25389
+ headers: {
25390
+ "Content-Type": "application/json",
25391
+ ...options?.headers
25392
+ }
25393
+ });
25394
+ var postApiV1SubscriptionsCreateCheckoutSession = (options) => (options.client ?? client).post({
25395
+ url: "/api/v1/subscriptions/create-checkout-session",
25396
+ ...options,
25397
+ headers: {
25398
+ "Content-Type": "application/json",
25399
+ ...options.headers
25400
+ }
25401
+ });
25402
+ var postApiV1SubscriptionsCustomerPortal = (options) => (options.client ?? client).post({
25403
+ url: "/api/v1/subscriptions/customer-portal",
25404
+ ...options,
25405
+ headers: {
25406
+ "Content-Type": "application/json",
25407
+ ...options.headers
25408
+ }
25409
+ });
25410
+ var postApiV1SubscriptionsRenew = (options) => (options?.client ?? client).post({ url: "/api/v1/subscriptions/renew", ...options });
25411
+ var getApiV1SubscriptionsStatus = (options) => (options?.client ?? client).get({ url: "/api/v1/subscriptions/status", ...options });
25412
+ var getApiV1WalletsBinding = (options) => (options?.client ?? client).get({ url: "/api/v1/wallets/binding", ...options });
25413
+ var postApiV1WalletsBinding = (options) => (options.client ?? client).post({
25414
+ url: "/api/v1/wallets/binding",
25415
+ ...options,
25416
+ headers: {
25417
+ "Content-Type": "application/json",
25418
+ ...options.headers
25419
+ }
25420
+ });
25421
+ var postApiV1WalletsBindingNonce = (options) => (options?.client ?? client).post({ url: "/api/v1/wallets/binding/nonce", ...options });
25422
+ var deleteApiV1WalletsBindingByAddress = (options) => (options.client ?? client).delete({ url: "/api/v1/wallets/binding/{address}", ...options });
25423
+ var postAuthOauthByProviderExchange = (options) => (options.client ?? client).post({
25424
+ url: "/auth/oauth/{provider}/exchange",
25425
+ ...options,
25426
+ headers: {
25427
+ "Content-Type": "application/json",
25428
+ ...options.headers
25429
+ }
25430
+ });
25431
+ var postAuthOauthByProviderRefresh = (options) => (options.client ?? client).post({
25432
+ url: "/auth/oauth/{provider}/refresh",
25433
+ ...options,
25434
+ headers: {
25435
+ "Content-Type": "application/json",
25436
+ ...options.headers
25437
+ }
25438
+ });
25439
+ var postAuthOauthByProviderRevoke = (options) => (options.client ?? client).post({
25440
+ url: "/auth/oauth/{provider}/revoke",
25441
+ ...options,
25442
+ headers: {
25443
+ "Content-Type": "application/json",
25444
+ ...options.headers
25445
+ }
25446
+ });
25436
25447
 
25437
25448
  // src/react/useCredits.ts
25438
25449
  init_clientConfig();
@@ -32169,6 +32180,8 @@ function renderAnumaJsx(jsx3) {
32169
32180
  THEME_ATTRS,
32170
32181
  TOPICS_EXTRACTION_VERSION,
32171
32182
  TOPIC_EXTRACTION_BATCH_SIZE,
32183
+ TREND_RECENT_WINDOW_DAYS,
32184
+ TREND_STALE_WINDOW_DAYS,
32172
32185
  TextProcessor,
32173
32186
  UIInteractionProvider,
32174
32187
  VAULT_SIZE_HOP_CAP,
@@ -32190,6 +32203,7 @@ function renderAnumaJsx(jsx3) {
32190
32203
  classifyCryptoPriceBatch,
32191
32204
  classifyDecay,
32192
32205
  classifyInjectionCandidates,
32206
+ classifyObservationTrend,
32193
32207
  classifyStockPrice,
32194
32208
  classifyStockPriceBatch,
32195
32209
  classifyWeather,
@@ -32459,6 +32473,7 @@ function renderAnumaJsx(jsx3) {
32459
32473
  storeNotionReturnUrl,
32460
32474
  streamCancelPath,
32461
32475
  streamReplayPath,
32476
+ summarizeObservationTrends,
32462
32477
  supersedeVaultMemoryOp,
32463
32478
  synthesizeProfile,
32464
32479
  traverseGraphLane,