@anuma/sdk 3.10.0 → 3.11.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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  callPortalJsonCompletion,
3
3
  getLogger
4
- } from "./chunk-BOY27A2C.mjs";
4
+ } from "./chunk-ILAWDQDE.mjs";
5
5
  import {
6
6
  BASE_URL,
7
7
  createClientConfig
@@ -5728,7 +5728,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
5728
5728
  legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
5729
5729
  );
5730
5730
  }
5731
- const { recall: recall2 } = await import("./recall-34WI57Z7.mjs");
5731
+ const { recall: recall2 } = await import("./recall-IBGUFY4P.mjs");
5732
5732
  const result = await recall2(
5733
5733
  query,
5734
5734
  { vaultCtx, embeddingOptions, vaultCache: cache },
@@ -196,6 +196,7 @@ async function attemptPortalJson(req, endpoint) {
196
196
  return { kind: "retryable", reason: `response body parse failed: ${err.message}` };
197
197
  }
198
198
  clearTimeout(timer);
199
+ logPortalUsage(body, req.tag);
199
200
  const rawContent = extractCompletionContent(body);
200
201
  if (!rawContent) {
201
202
  return { kind: "retryable", reason: "portal response had no completion content" };
@@ -251,6 +252,29 @@ function extractJsonCandidate(raw) {
251
252
  }
252
253
  return body;
253
254
  }
255
+ function asRecord(value) {
256
+ return typeof value === "object" && value !== null ? value : void 0;
257
+ }
258
+ function asCount(value) {
259
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
260
+ }
261
+ function logPortalUsage(body, tag) {
262
+ try {
263
+ const root = asRecord(body);
264
+ if (!root) return;
265
+ const usage = asRecord(root.usage);
266
+ const promptTokens = asCount(usage?.prompt_tokens);
267
+ const completionTokens = asCount(usage?.completion_tokens);
268
+ if (promptTokens === void 0 && completionTokens === void 0) return;
269
+ const cachedTokens = asCount(asRecord(root.portal)?.cached_tokens) ?? asCount(asRecord(usage?.prompt_tokens_details)?.cached_tokens) ?? 0;
270
+ const parts = [];
271
+ if (promptTokens !== void 0) parts.push(`prompt=${promptTokens}`);
272
+ if (completionTokens !== void 0) parts.push(`completion=${completionTokens}`);
273
+ parts.push(`cached=${cachedTokens}`);
274
+ getLogger().debug(`[${tag}] usage ${parts.join(" ")}`);
275
+ } catch {
276
+ }
277
+ }
254
278
  function extractCompletionContent(body) {
255
279
  if (typeof body !== "object" || body === null) return null;
256
280
  const choices = body.choices;
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  callPortalJsonCompletion,
6
6
  getLogger
7
- } from "./chunk-BOY27A2C.mjs";
7
+ } from "./chunk-ILAWDQDE.mjs";
8
8
  import "./chunk-GYKJOWEO.mjs";
9
9
 
10
10
  // src/lib/memory/consolidate.ts
@@ -5344,6 +5344,7 @@ async function attemptPortalJson(req, endpoint) {
5344
5344
  return { kind: "retryable", reason: `response body parse failed: ${err.message}` };
5345
5345
  }
5346
5346
  clearTimeout(timer);
5347
+ logPortalUsage(body, req.tag);
5347
5348
  const rawContent = extractCompletionContent(body);
5348
5349
  if (!rawContent) {
5349
5350
  return { kind: "retryable", reason: "portal response had no completion content" };
@@ -5399,6 +5400,29 @@ function extractJsonCandidate(raw) {
5399
5400
  }
5400
5401
  return body;
5401
5402
  }
5403
+ function asRecord(value) {
5404
+ return typeof value === "object" && value !== null ? value : void 0;
5405
+ }
5406
+ function asCount(value) {
5407
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
5408
+ }
5409
+ function logPortalUsage(body, tag) {
5410
+ try {
5411
+ const root = asRecord(body);
5412
+ if (!root) return;
5413
+ const usage = asRecord(root.usage);
5414
+ const promptTokens = asCount(usage?.prompt_tokens);
5415
+ const completionTokens = asCount(usage?.completion_tokens);
5416
+ if (promptTokens === void 0 && completionTokens === void 0) return;
5417
+ const cachedTokens = asCount(asRecord(root.portal)?.cached_tokens) ?? asCount(asRecord(usage?.prompt_tokens_details)?.cached_tokens) ?? 0;
5418
+ const parts = [];
5419
+ if (promptTokens !== void 0) parts.push(`prompt=${promptTokens}`);
5420
+ if (completionTokens !== void 0) parts.push(`completion=${completionTokens}`);
5421
+ parts.push(`cached=${cachedTokens}`);
5422
+ getLogger().debug(`[${tag}] usage ${parts.join(" ")}`);
5423
+ } catch {
5424
+ }
5425
+ }
5402
5426
  function extractCompletionContent(body) {
5403
5427
  if (typeof body !== "object" || body === null) return null;
5404
5428
  const choices = body.choices;
@@ -111,7 +111,7 @@ import {
111
111
  upsertMessageOp,
112
112
  useEncryption,
113
113
  vaultMemoryToStored
114
- } from "./chunk-CFGUZHAY.mjs";
114
+ } from "./chunk-7CTI3XR6.mjs";
115
115
  import {
116
116
  PII_PATTERNS,
117
117
  PiiRedactor,
@@ -129,7 +129,7 @@ import {
129
129
  setLogger,
130
130
  supportsResponseFormat,
131
131
  validateEndpointOverride
132
- } from "./chunk-BOY27A2C.mjs";
132
+ } from "./chunk-ILAWDQDE.mjs";
133
133
  import {
134
134
  BASE_URL,
135
135
  MCP_R2_DOMAIN,
@@ -6611,7 +6611,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
6611
6611
  content: m.content,
6612
6612
  similarity: m.similarity
6613
6613
  }));
6614
- const { consolidateMemory: doConsolidate } = await import("./consolidate-NC5DOC5J.mjs");
6614
+ const { consolidateMemory: doConsolidate } = await import("./consolidate-HYIEFPFA.mjs");
6615
6615
  const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
6616
6616
  if (decision.action === "create") return null;
6617
6617
  if (decision.action === "supersede" && decision.content) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  recall
3
- } from "./chunk-SCFNOAWH.mjs";
4
- import "./chunk-BOY27A2C.mjs";
3
+ } from "./chunk-7CTI3XR6.mjs";
4
+ import "./chunk-ILAWDQDE.mjs";
5
5
  import "./chunk-GYKJOWEO.mjs";
6
6
  export {
7
7
  recall
@@ -196,6 +196,7 @@ async function attemptPortalJson(req, endpoint) {
196
196
  return { kind: "retryable", reason: `response body parse failed: ${err.message}` };
197
197
  }
198
198
  clearTimeout(timer);
199
+ logPortalUsage(body, req.tag);
199
200
  const rawContent = extractCompletionContent(body);
200
201
  if (!rawContent) {
201
202
  return { kind: "retryable", reason: "portal response had no completion content" };
@@ -251,6 +252,29 @@ function extractJsonCandidate(raw) {
251
252
  }
252
253
  return body;
253
254
  }
255
+ function asRecord(value) {
256
+ return typeof value === "object" && value !== null ? value : void 0;
257
+ }
258
+ function asCount(value) {
259
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
260
+ }
261
+ function logPortalUsage(body, tag) {
262
+ try {
263
+ const root = asRecord(body);
264
+ if (!root) return;
265
+ const usage = asRecord(root.usage);
266
+ const promptTokens = asCount(usage?.prompt_tokens);
267
+ const completionTokens = asCount(usage?.completion_tokens);
268
+ if (promptTokens === void 0 && completionTokens === void 0) return;
269
+ const cachedTokens = asCount(asRecord(root.portal)?.cached_tokens) ?? asCount(asRecord(usage?.prompt_tokens_details)?.cached_tokens) ?? 0;
270
+ const parts = [];
271
+ if (promptTokens !== void 0) parts.push(`prompt=${promptTokens}`);
272
+ if (completionTokens !== void 0) parts.push(`completion=${completionTokens}`);
273
+ parts.push(`cached=${cachedTokens}`);
274
+ getLogger().debug(`[${tag}] usage ${parts.join(" ")}`);
275
+ } catch {
276
+ }
277
+ }
254
278
  function extractCompletionContent(body) {
255
279
  if (typeof body !== "object" || body === null) return null;
256
280
  const choices = body.choices;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  callPortalJsonCompletion,
3
3
  getLogger
4
- } from "./chunk-BOY27A2C.mjs";
4
+ } from "./chunk-ILAWDQDE.mjs";
5
5
  import {
6
6
  BASE_URL,
7
7
  createClientConfig
@@ -6029,7 +6029,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
6029
6029
  legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
6030
6030
  );
6031
6031
  }
6032
- const { recall: recall2 } = await import("./recall-GCW2EV4V.mjs");
6032
+ const { recall: recall2 } = await import("./recall-Q5V5DN4L.mjs");
6033
6033
  const result = await recall2(
6034
6034
  query,
6035
6035
  { vaultCtx, embeddingOptions, vaultCache: cache },
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  callPortalJsonCompletion,
6
6
  getLogger
7
- } from "./chunk-BOY27A2C.mjs";
7
+ } from "./chunk-ILAWDQDE.mjs";
8
8
  import "./chunk-GYKJOWEO.mjs";
9
9
 
10
10
  // src/lib/memory/consolidate.ts
@@ -5645,6 +5645,7 @@ async function attemptPortalJson(req, endpoint) {
5645
5645
  return { kind: "retryable", reason: `response body parse failed: ${err.message}` };
5646
5646
  }
5647
5647
  clearTimeout(timer);
5648
+ logPortalUsage(body, req.tag);
5648
5649
  const rawContent = extractCompletionContent(body);
5649
5650
  if (!rawContent) {
5650
5651
  return { kind: "retryable", reason: "portal response had no completion content" };
@@ -5700,6 +5701,29 @@ function extractJsonCandidate(raw) {
5700
5701
  }
5701
5702
  return body;
5702
5703
  }
5704
+ function asRecord(value) {
5705
+ return typeof value === "object" && value !== null ? value : void 0;
5706
+ }
5707
+ function asCount(value) {
5708
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
5709
+ }
5710
+ function logPortalUsage(body, tag) {
5711
+ try {
5712
+ const root = asRecord(body);
5713
+ if (!root) return;
5714
+ const usage = asRecord(root.usage);
5715
+ const promptTokens = asCount(usage?.prompt_tokens);
5716
+ const completionTokens = asCount(usage?.completion_tokens);
5717
+ if (promptTokens === void 0 && completionTokens === void 0) return;
5718
+ const cachedTokens = asCount(asRecord(root.portal)?.cached_tokens) ?? asCount(asRecord(usage?.prompt_tokens_details)?.cached_tokens) ?? 0;
5719
+ const parts = [];
5720
+ if (promptTokens !== void 0) parts.push(`prompt=${promptTokens}`);
5721
+ if (completionTokens !== void 0) parts.push(`completion=${completionTokens}`);
5722
+ parts.push(`cached=${cachedTokens}`);
5723
+ getLogger().debug(`[${tag}] usage ${parts.join(" ")}`);
5724
+ } catch {
5725
+ }
5726
+ }
5703
5727
  function extractCompletionContent(body) {
5704
5728
  if (typeof body !== "object" || body === null) return null;
5705
5729
  const choices = body.choices;
@@ -156,7 +156,7 @@ import {
156
156
  updateVaultMemoryOp,
157
157
  useEncryption,
158
158
  vaultMemoryToStored
159
- } from "./chunk-SCFNOAWH.mjs";
159
+ } from "./chunk-LAFUCS4U.mjs";
160
160
  import {
161
161
  PiiRedactor,
162
162
  createStreamingDeAnonymizer,
@@ -173,7 +173,7 @@ import {
173
173
  setLogger,
174
174
  supportsResponseFormat,
175
175
  validateEndpointOverride
176
- } from "./chunk-BOY27A2C.mjs";
176
+ } from "./chunk-ILAWDQDE.mjs";
177
177
  import {
178
178
  BASE_URL,
179
179
  MCP_R2_DOMAIN,
@@ -7428,7 +7428,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
7428
7428
  content: m.content,
7429
7429
  similarity: m.similarity
7430
7430
  }));
7431
- const { consolidateMemory: doConsolidate } = await import("./consolidate-54UWIMP6.mjs");
7431
+ const { consolidateMemory: doConsolidate } = await import("./consolidate-DOY3ZWTE.mjs");
7432
7432
  const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
7433
7433
  if (decision.action === "create") return null;
7434
7434
  if (decision.action === "supersede" && decision.content) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  recall
3
- } from "./chunk-CFGUZHAY.mjs";
4
- import "./chunk-BOY27A2C.mjs";
3
+ } from "./chunk-LAFUCS4U.mjs";
4
+ import "./chunk-ILAWDQDE.mjs";
5
5
  import "./chunk-GYKJOWEO.mjs";
6
6
  export {
7
7
  recall
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  callPortalJsonCompletion,
3
3
  getLogger
4
- } from "./chunk-MIXEASUP.mjs";
4
+ } from "./chunk-OBDRKQQI.mjs";
5
5
  import {
6
6
  BASE_URL,
7
7
  __commonJS,
@@ -19919,7 +19919,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
19919
19919
  legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
19920
19920
  );
19921
19921
  }
19922
- const { recall: recall2 } = await import("./recall-XO6QTDMG.mjs");
19922
+ const { recall: recall2 } = await import("./recall-AN7HBEFS.mjs");
19923
19923
  const result = await recall2(
19924
19924
  query,
19925
19925
  { vaultCtx, embeddingOptions, vaultCache: cache },
@@ -183,6 +183,7 @@ async function attemptPortalJson(req, endpoint) {
183
183
  return { kind: "retryable", reason: `response body parse failed: ${err.message}` };
184
184
  }
185
185
  clearTimeout(timer);
186
+ logPortalUsage(body, req.tag);
186
187
  const rawContent = extractCompletionContent(body);
187
188
  if (!rawContent) {
188
189
  return { kind: "retryable", reason: "portal response had no completion content" };
@@ -238,6 +239,29 @@ function extractJsonCandidate(raw) {
238
239
  }
239
240
  return body;
240
241
  }
242
+ function asRecord(value) {
243
+ return typeof value === "object" && value !== null ? value : void 0;
244
+ }
245
+ function asCount(value) {
246
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
247
+ }
248
+ function logPortalUsage(body, tag) {
249
+ try {
250
+ const root = asRecord(body);
251
+ if (!root) return;
252
+ const usage = asRecord(root.usage);
253
+ const promptTokens = asCount(usage?.prompt_tokens);
254
+ const completionTokens = asCount(usage?.completion_tokens);
255
+ if (promptTokens === void 0 && completionTokens === void 0) return;
256
+ const cachedTokens = asCount(asRecord(root.portal)?.cached_tokens) ?? asCount(asRecord(usage?.prompt_tokens_details)?.cached_tokens) ?? 0;
257
+ const parts = [];
258
+ if (promptTokens !== void 0) parts.push(`prompt=${promptTokens}`);
259
+ if (completionTokens !== void 0) parts.push(`completion=${completionTokens}`);
260
+ parts.push(`cached=${cachedTokens}`);
261
+ getLogger().debug(`[${tag}] usage ${parts.join(" ")}`);
262
+ } catch {
263
+ }
264
+ }
241
265
  function extractCompletionContent(body) {
242
266
  if (typeof body !== "object" || body === null) return null;
243
267
  const choices = body.choices;
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  callPortalJsonCompletion,
6
6
  getLogger
7
- } from "./chunk-MIXEASUP.mjs";
7
+ } from "./chunk-OBDRKQQI.mjs";
8
8
  import "./chunk-3RPGXXPZ.mjs";
9
9
 
10
10
  // src/lib/memory/consolidate.ts
@@ -19921,6 +19921,7 @@ async function attemptPortalJson(req, endpoint) {
19921
19921
  return { kind: "retryable", reason: `response body parse failed: ${err.message}` };
19922
19922
  }
19923
19923
  clearTimeout(timer);
19924
+ logPortalUsage(body, req.tag);
19924
19925
  const rawContent = extractCompletionContent(body);
19925
19926
  if (!rawContent) {
19926
19927
  return { kind: "retryable", reason: "portal response had no completion content" };
@@ -19976,6 +19977,29 @@ function extractJsonCandidate(raw) {
19976
19977
  }
19977
19978
  return body;
19978
19979
  }
19980
+ function asRecord(value) {
19981
+ return typeof value === "object" && value !== null ? value : void 0;
19982
+ }
19983
+ function asCount(value) {
19984
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
19985
+ }
19986
+ function logPortalUsage(body, tag) {
19987
+ try {
19988
+ const root = asRecord(body);
19989
+ if (!root) return;
19990
+ const usage = asRecord(root.usage);
19991
+ const promptTokens = asCount(usage?.prompt_tokens);
19992
+ const completionTokens = asCount(usage?.completion_tokens);
19993
+ if (promptTokens === void 0 && completionTokens === void 0) return;
19994
+ const cachedTokens = asCount(asRecord(root.portal)?.cached_tokens) ?? asCount(asRecord(usage?.prompt_tokens_details)?.cached_tokens) ?? 0;
19995
+ const parts = [];
19996
+ if (promptTokens !== void 0) parts.push(`prompt=${promptTokens}`);
19997
+ if (completionTokens !== void 0) parts.push(`completion=${completionTokens}`);
19998
+ parts.push(`cached=${cachedTokens}`);
19999
+ getLogger().debug(`[${tag}] usage ${parts.join(" ")}`);
20000
+ } catch {
20001
+ }
20002
+ }
19979
20003
  function extractCompletionContent(body) {
19980
20004
  if (typeof body !== "object" || body === null) return null;
19981
20005
  const choices = body.choices;
@@ -128,7 +128,7 @@ import {
128
128
  updateVaultMemoryOp,
129
129
  upsertMessageOp,
130
130
  vaultMemoryToStored
131
- } from "./chunk-Q4ACA4RO.mjs";
131
+ } from "./chunk-NCKDSZPQ.mjs";
132
132
  import {
133
133
  createStreamingDeAnonymizer,
134
134
  resolvePiiRedactor
@@ -140,7 +140,7 @@ import {
140
140
  resolvePortalAuthHeaders,
141
141
  supportsResponseFormat,
142
142
  validateEndpointOverride
143
- } from "./chunk-MIXEASUP.mjs";
143
+ } from "./chunk-OBDRKQQI.mjs";
144
144
  import {
145
145
  BASE_URL,
146
146
  __commonJS,
@@ -5549,7 +5549,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
5549
5549
  content: m.content,
5550
5550
  similarity: m.similarity
5551
5551
  }));
5552
- const { consolidateMemory: doConsolidate } = await import("./consolidate-YCD45CXO.mjs");
5552
+ const { consolidateMemory: doConsolidate } = await import("./consolidate-JMGL3MXG.mjs");
5553
5553
  const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
5554
5554
  if (decision.action === "create") return null;
5555
5555
  if (decision.action === "supersede" && decision.content) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  recall
3
- } from "./chunk-Q4ACA4RO.mjs";
4
- import "./chunk-MIXEASUP.mjs";
3
+ } from "./chunk-NCKDSZPQ.mjs";
4
+ import "./chunk-OBDRKQQI.mjs";
5
5
  import "./chunk-3RPGXXPZ.mjs";
6
6
  export {
7
7
  recall
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anuma/sdk",
3
- "version": "3.10.0",
3
+ "version": "3.11.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",