risicare 0.9.1 → 0.9.2

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.
Files changed (90) hide show
  1. package/CHANGELOG.md +1236 -0
  2. package/dist/frameworks/instructor.cjs +20 -5
  3. package/dist/frameworks/instructor.cjs.map +1 -1
  4. package/dist/frameworks/instructor.js +20 -5
  5. package/dist/frameworks/instructor.js.map +1 -1
  6. package/dist/frameworks/langchain.cjs +20 -5
  7. package/dist/frameworks/langchain.cjs.map +1 -1
  8. package/dist/frameworks/langchain.js +20 -5
  9. package/dist/frameworks/langchain.js.map +1 -1
  10. package/dist/frameworks/langgraph.cjs +20 -5
  11. package/dist/frameworks/langgraph.cjs.map +1 -1
  12. package/dist/frameworks/langgraph.js +20 -5
  13. package/dist/frameworks/langgraph.js.map +1 -1
  14. package/dist/frameworks/llamaindex.cjs +20 -5
  15. package/dist/frameworks/llamaindex.cjs.map +1 -1
  16. package/dist/frameworks/llamaindex.js +20 -5
  17. package/dist/frameworks/llamaindex.js.map +1 -1
  18. package/dist/index.cjs +77 -13
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.js +77 -13
  21. package/dist/index.js.map +1 -1
  22. package/dist/providers/anthropic/index.cjs +25 -6
  23. package/dist/providers/anthropic/index.cjs.map +1 -1
  24. package/dist/providers/anthropic/index.d.cts +3 -0
  25. package/dist/providers/anthropic/index.d.ts +3 -0
  26. package/dist/providers/anthropic/index.js +25 -6
  27. package/dist/providers/anthropic/index.js.map +1 -1
  28. package/dist/providers/bedrock/index.cjs +25 -6
  29. package/dist/providers/bedrock/index.cjs.map +1 -1
  30. package/dist/providers/bedrock/index.d.cts +3 -0
  31. package/dist/providers/bedrock/index.d.ts +3 -0
  32. package/dist/providers/bedrock/index.js +25 -6
  33. package/dist/providers/bedrock/index.js.map +1 -1
  34. package/dist/providers/cerebras/index.cjs +25 -6
  35. package/dist/providers/cerebras/index.cjs.map +1 -1
  36. package/dist/providers/cerebras/index.d.cts +3 -0
  37. package/dist/providers/cerebras/index.d.ts +3 -0
  38. package/dist/providers/cerebras/index.js +25 -6
  39. package/dist/providers/cerebras/index.js.map +1 -1
  40. package/dist/providers/cohere/index.cjs +25 -6
  41. package/dist/providers/cohere/index.cjs.map +1 -1
  42. package/dist/providers/cohere/index.d.cts +3 -0
  43. package/dist/providers/cohere/index.d.ts +3 -0
  44. package/dist/providers/cohere/index.js +25 -6
  45. package/dist/providers/cohere/index.js.map +1 -1
  46. package/dist/providers/google/index.cjs +25 -6
  47. package/dist/providers/google/index.cjs.map +1 -1
  48. package/dist/providers/google/index.d.cts +3 -0
  49. package/dist/providers/google/index.d.ts +3 -0
  50. package/dist/providers/google/index.js +25 -6
  51. package/dist/providers/google/index.js.map +1 -1
  52. package/dist/providers/groq/index.cjs +25 -6
  53. package/dist/providers/groq/index.cjs.map +1 -1
  54. package/dist/providers/groq/index.d.cts +3 -0
  55. package/dist/providers/groq/index.d.ts +3 -0
  56. package/dist/providers/groq/index.js +25 -6
  57. package/dist/providers/groq/index.js.map +1 -1
  58. package/dist/providers/huggingface/index.cjs +23 -5
  59. package/dist/providers/huggingface/index.cjs.map +1 -1
  60. package/dist/providers/huggingface/index.js +23 -5
  61. package/dist/providers/huggingface/index.js.map +1 -1
  62. package/dist/providers/mistral/index.cjs +25 -6
  63. package/dist/providers/mistral/index.cjs.map +1 -1
  64. package/dist/providers/mistral/index.d.cts +3 -0
  65. package/dist/providers/mistral/index.d.ts +3 -0
  66. package/dist/providers/mistral/index.js +25 -6
  67. package/dist/providers/mistral/index.js.map +1 -1
  68. package/dist/providers/ollama/index.cjs +25 -6
  69. package/dist/providers/ollama/index.cjs.map +1 -1
  70. package/dist/providers/ollama/index.d.cts +3 -0
  71. package/dist/providers/ollama/index.d.ts +3 -0
  72. package/dist/providers/ollama/index.js +25 -6
  73. package/dist/providers/ollama/index.js.map +1 -1
  74. package/dist/providers/openai/index.cjs +25 -6
  75. package/dist/providers/openai/index.cjs.map +1 -1
  76. package/dist/providers/openai/index.d.cts +3 -0
  77. package/dist/providers/openai/index.d.ts +3 -0
  78. package/dist/providers/openai/index.js +25 -6
  79. package/dist/providers/openai/index.js.map +1 -1
  80. package/dist/providers/together/index.cjs +25 -6
  81. package/dist/providers/together/index.cjs.map +1 -1
  82. package/dist/providers/together/index.d.cts +3 -0
  83. package/dist/providers/together/index.d.ts +3 -0
  84. package/dist/providers/together/index.js +25 -6
  85. package/dist/providers/together/index.js.map +1 -1
  86. package/dist/providers/vercel-ai/index.cjs +20 -5
  87. package/dist/providers/vercel-ai/index.cjs.map +1 -1
  88. package/dist/providers/vercel-ai/index.js +20 -5
  89. package/dist/providers/vercel-ai/index.js.map +1 -1
  90. package/package.json +3 -2
@@ -41,6 +41,9 @@ declare function deriveModelFamily(modelId: string): string;
41
41
  * Non-AI commands (ListFoundationModels, etc.) pass through unmodified.
42
42
  * The original client is NOT modified.
43
43
  *
44
+ * Patching a proxy that this function returned gives back the same proxy, so the
45
+ * second patch adds no second span.
46
+ *
44
47
  * @param client - A BedrockRuntimeClient instance
45
48
  * @returns A proxied client with automatic tracing
46
49
  */
@@ -41,6 +41,9 @@ declare function deriveModelFamily(modelId: string): string;
41
41
  * Non-AI commands (ListFoundationModels, etc.) pass through unmodified.
42
42
  * The original client is NOT modified.
43
43
  *
44
+ * Patching a proxy that this function returned gives back the same proxy, so the
45
+ * second patch adds no second span.
46
+ *
44
47
  * @param client - A BedrockRuntimeClient instance
45
48
  * @returns A proxied client with automatic tracing
46
49
  */
@@ -245,7 +245,7 @@ function getContext() {
245
245
  }
246
246
 
247
247
  // src/version.ts
248
- var SDK_VERSION = "0.9.1";
248
+ var SDK_VERSION = "0.9.2";
249
249
 
250
250
  // src/exporters/quota.ts
251
251
  var QUOTA_REASON = "monthly_quota_exceeded";
@@ -390,6 +390,8 @@ var HttpExporter = class {
390
390
  _calls = /* @__PURE__ */ new Map();
391
391
  /** The ack of each finished call, by its batch. Read once by `takeAck(spans)`. */
392
392
  _acks = /* @__PURE__ */ new WeakMap();
393
+ /** The requests that each finished call sent, by its batch. Read once by `takeAttempts(spans)`. */
394
+ _requests = /* @__PURE__ */ new WeakMap();
393
395
  /** The batch processor dropped span(s) from a full queue in the quota pause (S-1). */
394
396
  noteQuotaDrop(count = 1) {
395
397
  this._quota.addDrops(count);
@@ -441,6 +443,18 @@ var HttpExporter = class {
441
443
  get attemptsPerExport() {
442
444
  return this._maxRetries;
443
445
  }
446
+ /**
447
+ * Returns the number of HTTP requests that the `export()` call for `spans` sent, and clears
448
+ * it. This is the number that was sent, not the most that the call may send
449
+ * (`attemptsPerExport`): a 401 or 403 stops the loop after one request, and an open circuit
450
+ * breaker sends none. Returns `null` when no call is on record for `spans`. The answer is
451
+ * kept per batch, as `takeAck` keeps the ack.
452
+ */
453
+ takeAttempts(spans) {
454
+ const n = this._requests.get(spans) ?? null;
455
+ this._requests.delete(spans);
456
+ return n;
457
+ }
444
458
  /**
445
459
  * Returns the counts of the ack that the `export()` call for `spans` received, and clears
446
460
  * them. The answer is kept per batch, not on the instance: two processors that share this
@@ -485,13 +499,15 @@ var HttpExporter = class {
485
499
  misroute: null,
486
500
  noRetry: false,
487
501
  status: null,
488
- error: null
502
+ error: null,
503
+ attempts: 0
489
504
  };
490
505
  this._calls.set(spans, call);
491
506
  try {
492
507
  return await this._export(spans, call);
493
508
  } finally {
494
509
  this._calls.delete(spans);
510
+ this._requests.set(spans, this._endpointHasCredentials ? 0 : call.attempts);
495
511
  }
496
512
  }
497
513
  async _export(spans, call) {
@@ -531,14 +547,13 @@ var HttpExporter = class {
531
547
  isHalfOpen = true;
532
548
  }
533
549
  const maxAttempts = isHalfOpen ? 1 : this._maxRetries;
534
- let attempts = 0;
535
550
  for (let attempt = 0; attempt < maxAttempts; attempt++) {
536
551
  call.refusalAfterMs = null;
537
552
  call.misroute = null;
538
553
  call.noRetry = false;
539
554
  call.status = null;
540
555
  call.error = null;
541
- attempts++;
556
+ call.attempts++;
542
557
  const result = await this._sendRequest(payload, parts.length, call, spans);
543
558
  if (cancelled.aborted) {
544
559
  this._acks.delete(spans);
@@ -560,7 +575,7 @@ var HttpExporter = class {
560
575
  }
561
576
  if (call.refusalAfterMs !== null) {
562
577
  warn(
563
- `Risicare: the ingest endpoint refused this batch for capacity (HTTP 429/503) after ${attempts} attempt(s). This is a healthy server shedding load, not an outage. This export of the batch failed; the circuit breaker does not count it. Reduce batch size or export rate if it persists.`
578
+ `Risicare: the ingest endpoint refused this batch for capacity (HTTP 429/503) after ${call.attempts} attempt(s). This is a healthy server shedding load, not an outage. This export of the batch failed; the circuit breaker does not count it. Reduce batch size or export rate if it persists.`
564
579
  );
565
580
  return "failure" /* FAILURE */;
566
581
  }
@@ -1315,9 +1330,11 @@ function createSendProxy(originalSend) {
1315
1330
  );
1316
1331
  };
1317
1332
  }
1333
+ var PATCHED = /* @__PURE__ */ new WeakSet();
1318
1334
  function patchBedrock(client) {
1319
1335
  assertClient("patchBedrock", client);
1320
- return new Proxy(client, {
1336
+ if (PATCHED.has(client)) return client;
1337
+ const proxy = new Proxy(client, {
1321
1338
  get(target, prop, receiver) {
1322
1339
  const value = Reflect.get(target, prop, receiver);
1323
1340
  if (prop === "send" && typeof value === "function") {
@@ -1326,6 +1343,8 @@ function patchBedrock(client) {
1326
1343
  return value;
1327
1344
  }
1328
1345
  });
1346
+ PATCHED.add(proxy);
1347
+ return proxy;
1329
1348
  }
1330
1349
  export {
1331
1350
  deriveModelFamily,