@niadra/sdk 0.10.3 → 0.10.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/ai-sdk.d.cts +3 -3
  3. package/dist/ai-sdk.d.ts +3 -3
  4. package/dist/anthropic.d.cts +4 -4
  5. package/dist/anthropic.d.ts +4 -4
  6. package/dist/bedrock.d.cts +4 -4
  7. package/dist/bedrock.d.ts +4 -4
  8. package/dist/cli.js +14 -2
  9. package/dist/cli.js.map +1 -1
  10. package/dist/{client-rmWhZJOx.d.cts → client-7mkrdRI0.d.cts} +4 -2
  11. package/dist/{client-rmWhZJOx.d.ts → client-7mkrdRI0.d.ts} +4 -2
  12. package/dist/cloudflare-agents.d.cts +3 -3
  13. package/dist/cloudflare-agents.d.ts +3 -3
  14. package/dist/elevenlabs.d.cts +5 -5
  15. package/dist/elevenlabs.d.ts +5 -5
  16. package/dist/genkit.d.cts +3 -3
  17. package/dist/genkit.d.ts +3 -3
  18. package/dist/google-adk.d.cts +3 -3
  19. package/dist/google-adk.d.ts +3 -3
  20. package/dist/google-genai.d.cts +4 -4
  21. package/dist/google-genai.d.ts +4 -4
  22. package/dist/index.cjs +14 -2
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +3 -3
  25. package/dist/index.d.ts +3 -3
  26. package/dist/index.js +14 -2
  27. package/dist/index.js.map +1 -1
  28. package/dist/{intercept-C0XODsy9.d.cts → intercept-CGQhwAom.d.cts} +1 -1
  29. package/dist/{intercept-veMDudKV.d.ts → intercept-CT0vglsd.d.ts} +1 -1
  30. package/dist/langchain.d.cts +3 -3
  31. package/dist/langchain.d.ts +3 -3
  32. package/dist/livekit.d.cts +3 -3
  33. package/dist/livekit.d.ts +3 -3
  34. package/dist/llamaindex.d.cts +3 -3
  35. package/dist/llamaindex.d.ts +3 -3
  36. package/dist/mastra.d.cts +3 -3
  37. package/dist/mastra.d.ts +3 -3
  38. package/dist/openai-agents.d.cts +3 -3
  39. package/dist/openai-agents.d.ts +3 -3
  40. package/dist/retell.d.cts +5 -5
  41. package/dist/retell.d.ts +5 -5
  42. package/dist/{shared-Cs7h5C4Y.d.ts → shared-Bf84jr3Y.d.ts} +1 -1
  43. package/dist/{shared-zaTBum17.d.cts → shared-CxAwOcZI.d.cts} +1 -1
  44. package/dist/strands.d.cts +3 -3
  45. package/dist/strands.d.ts +3 -3
  46. package/dist/twilio.d.cts +4 -4
  47. package/dist/twilio.d.ts +4 -4
  48. package/dist/vapi.d.cts +5 -5
  49. package/dist/vapi.d.ts +5 -5
  50. package/dist/voltagent.d.cts +3 -3
  51. package/dist/voltagent.d.ts +3 -3
  52. package/dist/{webhook-CX7nvQig.d.cts → webhook-DE3HsGkb.d.cts} +1 -1
  53. package/dist/{webhook-2V5QgnKI.d.ts → webhook-QxYgxE6_.d.ts} +1 -1
  54. package/dist/whatsapp.d.cts +2 -2
  55. package/dist/whatsapp.d.ts +2 -2
  56. package/package.json +1 -1
@@ -6377,8 +6377,8 @@ interface ObjectTimelineParams {
6377
6377
  * the round trip to the region once when it starts (`VoiceOptions.probe`) and adds it on top, so an
6378
6378
  * agent far from the region (Sao Paulo is 170 ms from us-east-2) is not timed out by the network.
6379
6379
  * A value you set is a ceiling the SDK keeps; when the measured round trip plus 50 ms exceeds it,
6380
- * the client logs one warning, since every such read would run out of time. Before the measurement
6381
- * ends, the defaults apply as they are (with `connect` on top while no connection is open).
6380
+ * the client logs one warning, since every such read would run out of time. While the probe is on its
6381
+ * way, `connect` goes on top of them instead; a probe that failed, or `probe: false`, leaves them as they are.
6382
6382
  */
6383
6383
  interface Timeouts {
6384
6384
  /** `context()` for every view except `voice`. */
@@ -6743,6 +6743,8 @@ declare class Niadra {
6743
6743
  /** The read budgets the caller left at their defaults: they take the measured round trip on top. */
6744
6744
  private readonly defaultReads;
6745
6745
  private voiceStarted;
6746
+ /** A probe is on its way: until it ends, default read budgets get `timeouts.connect` on top. */
6747
+ private measuring;
6746
6748
  private voiceWarned;
6747
6749
  private readonly strict;
6748
6750
  /** Where the client reports what it swallows in fail-open mode. */
@@ -6377,8 +6377,8 @@ interface ObjectTimelineParams {
6377
6377
  * the round trip to the region once when it starts (`VoiceOptions.probe`) and adds it on top, so an
6378
6378
  * agent far from the region (Sao Paulo is 170 ms from us-east-2) is not timed out by the network.
6379
6379
  * A value you set is a ceiling the SDK keeps; when the measured round trip plus 50 ms exceeds it,
6380
- * the client logs one warning, since every such read would run out of time. Before the measurement
6381
- * ends, the defaults apply as they are (with `connect` on top while no connection is open).
6380
+ * the client logs one warning, since every such read would run out of time. While the probe is on its
6381
+ * way, `connect` goes on top of them instead; a probe that failed, or `probe: false`, leaves them as they are.
6382
6382
  */
6383
6383
  interface Timeouts {
6384
6384
  /** `context()` for every view except `voice`. */
@@ -6743,6 +6743,8 @@ declare class Niadra {
6743
6743
  /** The read budgets the caller left at their defaults: they take the measured round trip on top. */
6744
6744
  private readonly defaultReads;
6745
6745
  private voiceStarted;
6746
+ /** A probe is on its way: until it ends, default read budgets get `timeouts.connect` on top. */
6747
+ private measuring;
6746
6748
  private voiceWarned;
6747
6749
  private readonly strict;
6748
6750
  /** Where the client reports what it swallows in fail-open mode. */
@@ -1,8 +1,8 @@
1
1
  import { ToolSet } from 'ai';
2
- import { c as Niadra, g as Handle, g3 as TurnOptions, f as ModelUsage } from './client-rmWhZJOx.cjs';
2
+ import { c as Niadra, g as Handle, g3 as TurnOptions, f as ModelUsage } from './client-7mkrdRI0.cjs';
3
3
  import { NiadraMiddleware } from './ai-sdk.cjs';
4
- import { b as Session, a as ProofSource, A as AgentMemoryOption } from './shared-zaTBum17.cjs';
5
- export { P as Proof, c as attestationProof } from './shared-zaTBum17.cjs';
4
+ import { b as Session, a as ProofSource, A as AgentMemoryOption } from './shared-CxAwOcZI.cjs';
5
+ export { P as Proof, c as attestationProof } from './shared-CxAwOcZI.cjs';
6
6
 
7
7
  /**
8
8
  * Niadra for the Cloudflare Agents SDK (`agents` 0.x): one helper per `Agent` instance (a Durable
@@ -1,8 +1,8 @@
1
1
  import { ToolSet } from 'ai';
2
- import { c as Niadra, g as Handle, g3 as TurnOptions, f as ModelUsage } from './client-rmWhZJOx.js';
2
+ import { c as Niadra, g as Handle, g3 as TurnOptions, f as ModelUsage } from './client-7mkrdRI0.js';
3
3
  import { NiadraMiddleware } from './ai-sdk.js';
4
- import { b as Session, a as ProofSource, A as AgentMemoryOption } from './shared-Cs7h5C4Y.js';
5
- export { P as Proof, c as attestationProof } from './shared-Cs7h5C4Y.js';
4
+ import { b as Session, a as ProofSource, A as AgentMemoryOption } from './shared-Bf84jr3Y.js';
5
+ export { P as Proof, c as attestationProof } from './shared-Bf84jr3Y.js';
6
6
 
7
7
  /**
8
8
  * Niadra for the Cloudflare Agents SDK (`agents` 0.x): one helper per `Agent` instance (a Durable
@@ -1,8 +1,8 @@
1
- import { c as Niadra, g as Handle } from './client-rmWhZJOx.cjs';
2
- import { P as Proof, A as AgentMemoryOption } from './shared-zaTBum17.cjs';
3
- export { c as attestationProof } from './shared-zaTBum17.cjs';
4
- import { H as HeadersLike, W as WebhookResponse, C as CallStore } from './webhook-CX7nvQig.cjs';
5
- export { a as CallRecord, m as memoryCallStore } from './webhook-CX7nvQig.cjs';
1
+ import { c as Niadra, g as Handle } from './client-7mkrdRI0.cjs';
2
+ import { P as Proof, A as AgentMemoryOption } from './shared-CxAwOcZI.cjs';
3
+ export { c as attestationProof } from './shared-CxAwOcZI.cjs';
4
+ import { H as HeadersLike, W as WebhookResponse, C as CallStore } from './webhook-DE3HsGkb.cjs';
5
+ export { a as CallRecord, m as memoryCallStore } from './webhook-DE3HsGkb.cjs';
6
6
 
7
7
  /**
8
8
  * Niadra for the ElevenLabs Agents Platform, on the server side: a phone call reaches ElevenLabs,
@@ -1,8 +1,8 @@
1
- import { c as Niadra, g as Handle } from './client-rmWhZJOx.js';
2
- import { P as Proof, A as AgentMemoryOption } from './shared-Cs7h5C4Y.js';
3
- export { c as attestationProof } from './shared-Cs7h5C4Y.js';
4
- import { H as HeadersLike, W as WebhookResponse, C as CallStore } from './webhook-2V5QgnKI.js';
5
- export { a as CallRecord, m as memoryCallStore } from './webhook-2V5QgnKI.js';
1
+ import { c as Niadra, g as Handle } from './client-7mkrdRI0.js';
2
+ import { P as Proof, A as AgentMemoryOption } from './shared-Bf84jr3Y.js';
3
+ export { c as attestationProof } from './shared-Bf84jr3Y.js';
4
+ import { H as HeadersLike, W as WebhookResponse, C as CallStore } from './webhook-QxYgxE6_.js';
5
+ export { a as CallRecord, m as memoryCallStore } from './webhook-QxYgxE6_.js';
6
6
 
7
7
  /**
8
8
  * Niadra for the ElevenLabs Agents Platform, on the server side: a phone call reaches ElevenLabs,
package/dist/genkit.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { ModelMiddleware } from 'genkit/model';
2
2
  import { ToolAction } from 'genkit/tool';
3
- import { f as ModelUsage } from './client-rmWhZJOx.cjs';
4
- import { a as ProofSource, A as AgentMemoryOption, S as SessionResolver, b as Session } from './shared-zaTBum17.cjs';
5
- export { P as Proof, c as attestationProof } from './shared-zaTBum17.cjs';
3
+ import { f as ModelUsage } from './client-7mkrdRI0.cjs';
4
+ import { a as ProofSource, A as AgentMemoryOption, S as SessionResolver, b as Session } from './shared-CxAwOcZI.cjs';
5
+ export { P as Proof, c as attestationProof } from './shared-CxAwOcZI.cjs';
6
6
 
7
7
  /**
8
8
  * Niadra for Genkit (`genkit` 1.x, Firebase Genkit for JavaScript): a model middleware for
package/dist/genkit.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { ModelMiddleware } from 'genkit/model';
2
2
  import { ToolAction } from 'genkit/tool';
3
- import { f as ModelUsage } from './client-rmWhZJOx.js';
4
- import { a as ProofSource, A as AgentMemoryOption, S as SessionResolver, b as Session } from './shared-Cs7h5C4Y.js';
5
- export { P as Proof, c as attestationProof } from './shared-Cs7h5C4Y.js';
3
+ import { f as ModelUsage } from './client-7mkrdRI0.js';
4
+ import { a as ProofSource, A as AgentMemoryOption, S as SessionResolver, b as Session } from './shared-Bf84jr3Y.js';
5
+ export { P as Proof, c as attestationProof } from './shared-Bf84jr3Y.js';
6
6
 
7
7
  /**
8
8
  * Niadra for Genkit (`genkit` 1.x, Firebase Genkit for JavaScript): a model middleware for
@@ -1,7 +1,7 @@
1
1
  import { Context, LlmRequest, LlmResponse, BaseTool, ReadonlyContext } from '@google/adk';
2
- import { f as ModelUsage } from './client-rmWhZJOx.cjs';
3
- import { b as Session, a as ProofSource, A as AgentMemoryOption } from './shared-zaTBum17.cjs';
4
- export { P as Proof, c as attestationProof } from './shared-zaTBum17.cjs';
2
+ import { f as ModelUsage } from './client-7mkrdRI0.cjs';
3
+ import { b as Session, a as ProofSource, A as AgentMemoryOption } from './shared-CxAwOcZI.cjs';
4
+ export { P as Proof, c as attestationProof } from './shared-CxAwOcZI.cjs';
5
5
 
6
6
  /**
7
7
  * Niadra for the Agent Development Kit for TypeScript (`@google/adk` 2.x): model callbacks and the
@@ -1,7 +1,7 @@
1
1
  import { Context, LlmRequest, LlmResponse, BaseTool, ReadonlyContext } from '@google/adk';
2
- import { f as ModelUsage } from './client-rmWhZJOx.js';
3
- import { b as Session, a as ProofSource, A as AgentMemoryOption } from './shared-Cs7h5C4Y.js';
4
- export { P as Proof, c as attestationProof } from './shared-Cs7h5C4Y.js';
2
+ import { f as ModelUsage } from './client-7mkrdRI0.js';
3
+ import { b as Session, a as ProofSource, A as AgentMemoryOption } from './shared-Bf84jr3Y.js';
4
+ export { P as Proof, c as attestationProof } from './shared-Bf84jr3Y.js';
5
5
 
6
6
  /**
7
7
  * Niadra for the Agent Development Kit for TypeScript (`@google/adk` 2.x): model callbacks and the
@@ -1,7 +1,7 @@
1
- import { f as ModelUsage } from './client-rmWhZJOx.cjs';
2
- import { W as WrapOptions } from './intercept-C0XODsy9.cjs';
3
- import { S as SessionResolver } from './shared-zaTBum17.cjs';
4
- export { A as AgentMemoryOption, P as Proof, a as ProofSource, b as Session, c as attestationProof } from './shared-zaTBum17.cjs';
1
+ import { f as ModelUsage } from './client-7mkrdRI0.cjs';
2
+ import { W as WrapOptions } from './intercept-CGQhwAom.cjs';
3
+ import { S as SessionResolver } from './shared-CxAwOcZI.cjs';
4
+ export { A as AgentMemoryOption, P as Proof, a as ProofSource, b as Session, c as attestationProof } from './shared-CxAwOcZI.cjs';
5
5
 
6
6
  /**
7
7
  * Niadra for the Google Gen AI SDK (`@google/genai`), as `wrap()` is for OpenAI.
@@ -1,7 +1,7 @@
1
- import { f as ModelUsage } from './client-rmWhZJOx.js';
2
- import { W as WrapOptions } from './intercept-veMDudKV.js';
3
- import { S as SessionResolver } from './shared-Cs7h5C4Y.js';
4
- export { A as AgentMemoryOption, P as Proof, a as ProofSource, b as Session, c as attestationProof } from './shared-Cs7h5C4Y.js';
1
+ import { f as ModelUsage } from './client-7mkrdRI0.js';
2
+ import { W as WrapOptions } from './intercept-CT0vglsd.js';
3
+ import { S as SessionResolver } from './shared-Bf84jr3Y.js';
4
+ export { A as AgentMemoryOption, P as Proof, a as ProofSource, b as Session, c as attestationProof } from './shared-Bf84jr3Y.js';
5
5
 
6
6
  /**
7
7
  * Niadra for the Google Gen AI SDK (`@google/genai`), as `wrap()` is for OpenAI.
package/dist/index.cjs CHANGED
@@ -525,7 +525,7 @@ function internalRecord(span, ref, act) {
525
525
  }
526
526
 
527
527
  // src/version.ts
528
- var VERSION = "0.10.3";
528
+ var VERSION = "0.10.4";
529
529
 
530
530
  // src/transport.ts
531
531
  var RETRYABLE_WRITE_STATUS = /* @__PURE__ */ new Set([408, 421, 429, 500, 502, 503, 504]);
@@ -543,6 +543,10 @@ var Transport = class {
543
543
  grantedAt;
544
544
  /** When the client last sent a request of its own (`RequestSpec.activity`), in epoch milliseconds. */
545
545
  lastActivityAt;
546
+ /** Likely: an answer came within `keepAliveMs`. When not, the next budgeted call gets `coldAllowanceMs`. */
547
+ connectionOpen() {
548
+ return this.answeredAt !== void 0 && Date.now() - this.answeredAt <= (this.config.keepAliveMs ?? 0);
549
+ }
546
550
  async request(spec) {
547
551
  if (spec.activity !== false) this.lastActivityAt = Date.now();
548
552
  const budgeted = this.withAllowance(spec);
@@ -8545,6 +8549,8 @@ var Niadra = class _Niadra {
8545
8549
  /** The read budgets the caller left at their defaults: they take the measured round trip on top. */
8546
8550
  defaultReads;
8547
8551
  voiceStarted = false;
8552
+ /** A probe is on its way: until it ends, default read budgets get `timeouts.connect` on top. */
8553
+ measuring = false;
8548
8554
  voiceWarned = false;
8549
8555
  strict;
8550
8556
  /** Where the client reports what it swallows in fail-open mode. */
@@ -9612,6 +9618,7 @@ var Niadra = class _Niadra {
9612
9618
  /** Measures the round trip to the region once per client, in the background. */
9613
9619
  probe(core) {
9614
9620
  if (!this.voice.claimProbe()) return;
9621
+ this.measuring = true;
9615
9622
  void (async () => {
9616
9623
  const samples = [];
9617
9624
  for (let i = 0; i < 2; i++) {
@@ -9625,12 +9632,14 @@ var Niadra = class _Niadra {
9625
9632
  });
9626
9633
  } catch (error) {
9627
9634
  this.logger.debug(`round trip probe failed: ${describe(toNiadraError(error))}`);
9635
+ this.measuring = false;
9628
9636
  return;
9629
9637
  }
9630
9638
  samples.push(Date.now() - started);
9631
9639
  }
9632
9640
  const rtt = Math.min(...samples);
9633
9641
  this.voice.rtt = rtt;
9642
+ this.measuring = false;
9634
9643
  this.logger.debug(`round trip to the region ${Math.round(rtt)} ms`);
9635
9644
  const explicit = ["context", "navigation"].filter((name) => !this.defaultReads.has(name));
9636
9645
  for (const warning of budgetWarnings(rtt, this.timeouts, explicit)) this.logger.warn(warning);
@@ -9643,8 +9652,11 @@ var Niadra = class _Niadra {
9643
9652
  * timed out by the network; one the caller set is a ceiling.
9644
9653
  */
9645
9654
  readBudget(name) {
9655
+ if (!this.defaultReads.has(name)) return this.timeouts[name];
9646
9656
  const rtt = this.voice.rtt;
9647
- return rtt !== null && this.defaultReads.has(name) ? this.timeouts[name] + rtt : this.timeouts[name];
9657
+ if (rtt !== null) return this.timeouts[name] + rtt;
9658
+ const open = this.core?.transport.connectionOpen() ?? false;
9659
+ return this.measuring && open ? this.timeouts[name] + this.timeouts.connect : this.timeouts[name];
9648
9660
  }
9649
9661
  /** The client reads in voice: the voice budgets' warnings matter from now on. */
9650
9662
  startVoice(core) {