@niadra/sdk 0.11.0 → 0.11.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 (68) hide show
  1. package/CHANGELOG.md +19 -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 +32 -10
  9. package/dist/cli.js.map +1 -1
  10. package/dist/{client-CG257pe3.d.cts → client-C0FxHZgk.d.cts} +12 -1
  11. package/dist/{client-CG257pe3.d.ts → client-C0FxHZgk.d.ts} +12 -1
  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 +39 -10
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +10 -3
  25. package/dist/index.d.ts +10 -3
  26. package/dist/index.js +39 -10
  27. package/dist/index.js.map +1 -1
  28. package/dist/{intercept-CvbXtKsU.d.cts → intercept--jszljK3.d.cts} +1 -1
  29. package/dist/{intercept-EqNiV5f2.d.ts → intercept-BTSgDwBp.d.ts} +1 -1
  30. package/dist/langchain.d.cts +3 -3
  31. package/dist/langchain.d.ts +3 -3
  32. package/dist/livekit.cjs +7 -0
  33. package/dist/livekit.cjs.map +1 -1
  34. package/dist/livekit.d.cts +3 -3
  35. package/dist/livekit.d.ts +3 -3
  36. package/dist/livekit.js +7 -0
  37. package/dist/livekit.js.map +1 -1
  38. package/dist/llamaindex.d.cts +3 -3
  39. package/dist/llamaindex.d.ts +3 -3
  40. package/dist/mastra.d.cts +3 -3
  41. package/dist/mastra.d.ts +3 -3
  42. package/dist/openai-agents.d.cts +3 -3
  43. package/dist/openai-agents.d.ts +3 -3
  44. package/dist/retell.d.cts +5 -5
  45. package/dist/retell.d.ts +5 -5
  46. package/dist/{shared-Dmo7pRV5.d.cts → shared-BgH4GypR.d.cts} +1 -1
  47. package/dist/{shared--OTV6MgP.d.ts → shared-DNEUVdMh.d.ts} +1 -1
  48. package/dist/strands.d.cts +3 -3
  49. package/dist/strands.d.ts +3 -3
  50. package/dist/twilio.cjs +7 -0
  51. package/dist/twilio.cjs.map +1 -1
  52. package/dist/twilio.d.cts +4 -4
  53. package/dist/twilio.d.ts +4 -4
  54. package/dist/twilio.js +7 -0
  55. package/dist/twilio.js.map +1 -1
  56. package/dist/vapi.d.cts +5 -5
  57. package/dist/vapi.d.ts +5 -5
  58. package/dist/voltagent.d.cts +3 -3
  59. package/dist/voltagent.d.ts +3 -3
  60. package/dist/{webhook-Bcgl38Nz.d.ts → webhook-CmjN8aRy.d.ts} +1 -1
  61. package/dist/{webhook-CPc6wZKf.d.cts → webhook-JVLjLq-R.d.cts} +1 -1
  62. package/dist/whatsapp.cjs +7 -0
  63. package/dist/whatsapp.cjs.map +1 -1
  64. package/dist/whatsapp.d.cts +2 -2
  65. package/dist/whatsapp.d.ts +2 -2
  66. package/dist/whatsapp.js +7 -0
  67. package/dist/whatsapp.js.map +1 -1
  68. package/package.json +1 -1
@@ -9,7 +9,7 @@ type Speaker = "customer" | "ai_agent" | "human_agent" | "system";
9
9
  /** `internal` events (notes between agents, system traces) never reach a customer-facing view. */
10
10
  type Visibility = "public" | "internal";
11
11
  /** Subjects are people by default; accounts and partners are organizations. */
12
- type SubjectKind = "person" | "account" | "partner";
12
+ type SubjectKind = "person" | "account" | "partner" | "staff";
13
13
  /**
14
14
  * How a handle identifies a subject. Scoped types (`wa_bsuid`, `system_id`, `gov_id_hmac`,
15
15
  * `org_registry_hmac`) need `scope` so the same value in two namespaces never collides.
@@ -6512,6 +6512,14 @@ interface Timeouts {
6512
6512
  * people's turns.
6513
6513
  */
6514
6514
  contextVoice: number;
6515
+ /**
6516
+ * The default budget of the first read of a conversation, task or object in this client, before the round
6517
+ * trip: the API compiles its pack on that read. One right after a customer's first message took 410 ms on
6518
+ * the server (05/10/2026: resolving the customer 153 ms, the pack 120 ms), more than `context`, and the
6519
+ * agent answered without memory. Later reads of the same key find the pack compiled. Only when `context`
6520
+ * is left at its default.
6521
+ */
6522
+ contextFirst: number;
6515
6523
  /**
6516
6524
  * The first read of a voice call, made while the phone rings or the inbound webhook runs
6517
6525
  * (`begin()`, `ready()`). A cold connection costs three round trips (TCP, TLS, the request)
@@ -6862,6 +6870,8 @@ declare class Niadra {
6862
6870
  private voiceStarted;
6863
6871
  /** A probe is on its way: until it ends, default read budgets get `timeouts.connect` on top. */
6864
6872
  private measuring;
6873
+ /** The keys whose read answered in this client, oldest first: a first read gets `timeouts.contextFirst`. */
6874
+ private readonly answeredReads;
6865
6875
  private voiceWarned;
6866
6876
  private readonly strict;
6867
6877
  /** Where the client reports what it swallows in fail-open mode. */
@@ -6922,6 +6932,7 @@ declare class Niadra {
6922
6932
  */
6923
6933
  context(params: ContextParams, options?: ContextOptions): Promise<ContextResult>;
6924
6934
  private readContext;
6935
+ private readAnswered;
6925
6936
  /**
6926
6937
  * The SDK profile of this key's space: the features it turned on, the claim contract and the summarized
6927
6938
  * type registry, from the local cache, read again once `valid_for_s` has passed. When Niadra does not
@@ -9,7 +9,7 @@ type Speaker = "customer" | "ai_agent" | "human_agent" | "system";
9
9
  /** `internal` events (notes between agents, system traces) never reach a customer-facing view. */
10
10
  type Visibility = "public" | "internal";
11
11
  /** Subjects are people by default; accounts and partners are organizations. */
12
- type SubjectKind = "person" | "account" | "partner";
12
+ type SubjectKind = "person" | "account" | "partner" | "staff";
13
13
  /**
14
14
  * How a handle identifies a subject. Scoped types (`wa_bsuid`, `system_id`, `gov_id_hmac`,
15
15
  * `org_registry_hmac`) need `scope` so the same value in two namespaces never collides.
@@ -6512,6 +6512,14 @@ interface Timeouts {
6512
6512
  * people's turns.
6513
6513
  */
6514
6514
  contextVoice: number;
6515
+ /**
6516
+ * The default budget of the first read of a conversation, task or object in this client, before the round
6517
+ * trip: the API compiles its pack on that read. One right after a customer's first message took 410 ms on
6518
+ * the server (05/10/2026: resolving the customer 153 ms, the pack 120 ms), more than `context`, and the
6519
+ * agent answered without memory. Later reads of the same key find the pack compiled. Only when `context`
6520
+ * is left at its default.
6521
+ */
6522
+ contextFirst: number;
6515
6523
  /**
6516
6524
  * The first read of a voice call, made while the phone rings or the inbound webhook runs
6517
6525
  * (`begin()`, `ready()`). A cold connection costs three round trips (TCP, TLS, the request)
@@ -6862,6 +6870,8 @@ declare class Niadra {
6862
6870
  private voiceStarted;
6863
6871
  /** A probe is on its way: until it ends, default read budgets get `timeouts.connect` on top. */
6864
6872
  private measuring;
6873
+ /** The keys whose read answered in this client, oldest first: a first read gets `timeouts.contextFirst`. */
6874
+ private readonly answeredReads;
6865
6875
  private voiceWarned;
6866
6876
  private readonly strict;
6867
6877
  /** Where the client reports what it swallows in fail-open mode. */
@@ -6922,6 +6932,7 @@ declare class Niadra {
6922
6932
  */
6923
6933
  context(params: ContextParams, options?: ContextOptions): Promise<ContextResult>;
6924
6934
  private readContext;
6935
+ private readAnswered;
6925
6936
  /**
6926
6937
  * The SDK profile of this key's space: the features it turned on, the claim contract and the summarized
6927
6938
  * type registry, from the local cache, read again once `valid_for_s` has passed. When Niadra does not
@@ -1,8 +1,8 @@
1
1
  import { ToolSet } from 'ai';
2
- import { c as Niadra, g as Handle, g8 as TurnOptions, f as ModelUsage } from './client-CG257pe3.cjs';
2
+ import { c as Niadra, g as Handle, g8 as TurnOptions, f as ModelUsage } from './client-C0FxHZgk.cjs';
3
3
  import { NiadraMiddleware } from './ai-sdk.cjs';
4
- import { b as Session, a as ProofSource, A as AgentMemoryOption } from './shared-Dmo7pRV5.cjs';
5
- export { P as Proof, c as attestationProof } from './shared-Dmo7pRV5.cjs';
4
+ import { b as Session, a as ProofSource, A as AgentMemoryOption } from './shared-BgH4GypR.cjs';
5
+ export { P as Proof, c as attestationProof } from './shared-BgH4GypR.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, g8 as TurnOptions, f as ModelUsage } from './client-CG257pe3.js';
2
+ import { c as Niadra, g as Handle, g8 as TurnOptions, f as ModelUsage } from './client-C0FxHZgk.js';
3
3
  import { NiadraMiddleware } from './ai-sdk.js';
4
- import { b as Session, a as ProofSource, A as AgentMemoryOption } from './shared--OTV6MgP.js';
5
- export { P as Proof, c as attestationProof } from './shared--OTV6MgP.js';
4
+ import { b as Session, a as ProofSource, A as AgentMemoryOption } from './shared-DNEUVdMh.js';
5
+ export { P as Proof, c as attestationProof } from './shared-DNEUVdMh.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-CG257pe3.cjs';
2
- import { P as Proof, A as AgentMemoryOption } from './shared-Dmo7pRV5.cjs';
3
- export { c as attestationProof } from './shared-Dmo7pRV5.cjs';
4
- import { H as HeadersLike, W as WebhookResponse, C as CallStore } from './webhook-CPc6wZKf.cjs';
5
- export { a as CallRecord, m as memoryCallStore } from './webhook-CPc6wZKf.cjs';
1
+ import { c as Niadra, g as Handle } from './client-C0FxHZgk.cjs';
2
+ import { P as Proof, A as AgentMemoryOption } from './shared-BgH4GypR.cjs';
3
+ export { c as attestationProof } from './shared-BgH4GypR.cjs';
4
+ import { H as HeadersLike, W as WebhookResponse, C as CallStore } from './webhook-JVLjLq-R.cjs';
5
+ export { a as CallRecord, m as memoryCallStore } from './webhook-JVLjLq-R.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-CG257pe3.js';
2
- import { P as Proof, A as AgentMemoryOption } from './shared--OTV6MgP.js';
3
- export { c as attestationProof } from './shared--OTV6MgP.js';
4
- import { H as HeadersLike, W as WebhookResponse, C as CallStore } from './webhook-Bcgl38Nz.js';
5
- export { a as CallRecord, m as memoryCallStore } from './webhook-Bcgl38Nz.js';
1
+ import { c as Niadra, g as Handle } from './client-C0FxHZgk.js';
2
+ import { P as Proof, A as AgentMemoryOption } from './shared-DNEUVdMh.js';
3
+ export { c as attestationProof } from './shared-DNEUVdMh.js';
4
+ import { H as HeadersLike, W as WebhookResponse, C as CallStore } from './webhook-CmjN8aRy.js';
5
+ export { a as CallRecord, m as memoryCallStore } from './webhook-CmjN8aRy.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-CG257pe3.cjs';
4
- import { a as ProofSource, A as AgentMemoryOption, S as SessionResolver, b as Session } from './shared-Dmo7pRV5.cjs';
5
- export { P as Proof, c as attestationProof } from './shared-Dmo7pRV5.cjs';
3
+ import { f as ModelUsage } from './client-C0FxHZgk.cjs';
4
+ import { a as ProofSource, A as AgentMemoryOption, S as SessionResolver, b as Session } from './shared-BgH4GypR.cjs';
5
+ export { P as Proof, c as attestationProof } from './shared-BgH4GypR.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-CG257pe3.js';
4
- import { a as ProofSource, A as AgentMemoryOption, S as SessionResolver, b as Session } from './shared--OTV6MgP.js';
5
- export { P as Proof, c as attestationProof } from './shared--OTV6MgP.js';
3
+ import { f as ModelUsage } from './client-C0FxHZgk.js';
4
+ import { a as ProofSource, A as AgentMemoryOption, S as SessionResolver, b as Session } from './shared-DNEUVdMh.js';
5
+ export { P as Proof, c as attestationProof } from './shared-DNEUVdMh.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-CG257pe3.cjs';
3
- import { b as Session, a as ProofSource, A as AgentMemoryOption } from './shared-Dmo7pRV5.cjs';
4
- export { P as Proof, c as attestationProof } from './shared-Dmo7pRV5.cjs';
2
+ import { f as ModelUsage } from './client-C0FxHZgk.cjs';
3
+ import { b as Session, a as ProofSource, A as AgentMemoryOption } from './shared-BgH4GypR.cjs';
4
+ export { P as Proof, c as attestationProof } from './shared-BgH4GypR.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-CG257pe3.js';
3
- import { b as Session, a as ProofSource, A as AgentMemoryOption } from './shared--OTV6MgP.js';
4
- export { P as Proof, c as attestationProof } from './shared--OTV6MgP.js';
2
+ import { f as ModelUsage } from './client-C0FxHZgk.js';
3
+ import { b as Session, a as ProofSource, A as AgentMemoryOption } from './shared-DNEUVdMh.js';
4
+ export { P as Proof, c as attestationProof } from './shared-DNEUVdMh.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-CG257pe3.cjs';
2
- import { W as WrapOptions } from './intercept-CvbXtKsU.cjs';
3
- import { S as SessionResolver } from './shared-Dmo7pRV5.cjs';
4
- export { A as AgentMemoryOption, P as Proof, a as ProofSource, b as Session, c as attestationProof } from './shared-Dmo7pRV5.cjs';
1
+ import { f as ModelUsage } from './client-C0FxHZgk.cjs';
2
+ import { W as WrapOptions } from './intercept--jszljK3.cjs';
3
+ import { S as SessionResolver } from './shared-BgH4GypR.cjs';
4
+ export { A as AgentMemoryOption, P as Proof, a as ProofSource, b as Session, c as attestationProof } from './shared-BgH4GypR.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-CG257pe3.js';
2
- import { W as WrapOptions } from './intercept-EqNiV5f2.js';
3
- import { S as SessionResolver } from './shared--OTV6MgP.js';
4
- export { A as AgentMemoryOption, P as Proof, a as ProofSource, b as Session, c as attestationProof } from './shared--OTV6MgP.js';
1
+ import { f as ModelUsage } from './client-C0FxHZgk.js';
2
+ import { W as WrapOptions } from './intercept-BTSgDwBp.js';
3
+ import { S as SessionResolver } from './shared-DNEUVdMh.js';
4
+ export { A as AgentMemoryOption, P as Proof, a as ProofSource, b as Session, c as attestationProof } from './shared-DNEUVdMh.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.11.0";
528
+ var VERSION = "0.11.2";
529
529
 
530
530
  // src/transport.ts
531
531
  var RETRYABLE_WRITE_STATUS = /* @__PURE__ */ new Set([408, 421, 429, 500, 502, 503, 504]);
@@ -5780,6 +5780,13 @@ var handles = {
5780
5780
  appUserId: (value, options) => build("app_user_id", value, void 0, options),
5781
5781
  /** The id of a person or organization in a system of record; `system` names that system, such as `crm`. */
5782
5782
  systemId: (value, system, options) => build("system_id", value, system, options),
5783
+ /**
5784
+ * Someone who works for your company, by the id one of your systems gives them: `staff("U-17", "hr")`.
5785
+ * A conversation with staff is internal: the agent reads what your team may read, and what the person says
5786
+ * is your company's word. A conversation with anyone else is customer-facing, whatever the key. Only a
5787
+ * system id names staff: a phone or an e-mail always names a customer.
5788
+ */
5789
+ staff: (value, system) => build("system_id", value, system, { subjectKind: "staff" }),
5783
5790
  /**
5784
5791
  * A person's national document, such as a CPF: `govIdHmac("529.982.247-25", "BR")`. Send the number
5785
5792
  * itself, never a hash of it: the server checks its check digits, then keeps only a keyed hash with your
@@ -7714,6 +7721,7 @@ var silentLogger = { debug: noop, warn: noop, error: noop };
7714
7721
  // src/options.ts
7715
7722
  var DEFAULT_TIMEOUTS = {
7716
7723
  context: 300,
7724
+ contextFirst: 1e3,
7717
7725
  contextVoice: 200,
7718
7726
  contextVoiceStart: 1500,
7719
7727
  navigation: 600,
@@ -8524,6 +8532,7 @@ function rttWarnings(rttMs, timeouts) {
8524
8532
  }
8525
8533
 
8526
8534
  // src/client.ts
8535
+ var READ_KEYS_KEPT = 4096;
8527
8536
  function readEnv(name) {
8528
8537
  try {
8529
8538
  const env = globalThis.process?.env;
@@ -8551,6 +8560,8 @@ var Niadra = class _Niadra {
8551
8560
  voiceStarted = false;
8552
8561
  /** A probe is on its way: until it ends, default read budgets get `timeouts.connect` on top. */
8553
8562
  measuring = false;
8563
+ /** The keys whose read answered in this client, oldest first: a first read gets `timeouts.contextFirst`. */
8564
+ answeredReads = /* @__PURE__ */ new Map();
8554
8565
  voiceWarned = false;
8555
8566
  strict;
8556
8567
  /** Where the client reports what it swallows in fail-open mode. */
@@ -8737,14 +8748,28 @@ var Niadra = class _Niadra {
8737
8748
  if (this.content.registered && result2.state) result2.state = await this.content.fill(result2.state);
8738
8749
  return result2;
8739
8750
  }
8740
- readContext(core, params, request, options) {
8741
- const timeout = options.timeout ?? (request.view === "voice" ? this.timeouts.contextVoice : this.readBudget("context"));
8751
+ async readContext(core, params, request, options) {
8742
8752
  const { query: own3, ...pinned2 } = request;
8743
8753
  const query = turnText(own3 ?? params.turn);
8754
+ const readKey = cacheKey(pinned2);
8755
+ const first = !this.answeredReads.has(readKey);
8756
+ const timeout = options.timeout ?? (request.view === "voice" ? this.timeouts.contextVoice : this.readBudget("context", first));
8744
8757
  const voiceCache = this.voiceCache(core, pinned2, options.cache);
8745
- if (voiceCache) return this.voiceContext(core, voiceCache, pinned2, query, timeout, options);
8746
- if (query !== null) return this.turnContext(core, pinned2, query, timeout, options);
8747
- return this.pinnedContext(core, pinned2, timeout, options);
8758
+ let result2;
8759
+ if (voiceCache) result2 = await this.voiceContext(core, voiceCache, pinned2, query, timeout, options);
8760
+ else if (query !== null) result2 = await this.turnContext(core, pinned2, query, timeout, options);
8761
+ else result2 = await this.pinnedContext(core, pinned2, timeout, options);
8762
+ if (result2.error === null) this.readAnswered(readKey);
8763
+ return result2;
8764
+ }
8765
+ readAnswered(key2) {
8766
+ this.answeredReads.delete(key2);
8767
+ this.answeredReads.set(key2, true);
8768
+ while (this.answeredReads.size > READ_KEYS_KEPT) {
8769
+ const oldest = this.answeredReads.keys().next().value;
8770
+ if (oldest === void 0) break;
8771
+ this.answeredReads.delete(oldest);
8772
+ }
8748
8773
  }
8749
8774
  /**
8750
8775
  * The SDK profile of this key's space: the features it turned on, the claim contract and the summarized
@@ -9152,7 +9177,9 @@ var Niadra = class _Niadra {
9152
9177
  const key2 = AgentMemoryCache.key(params);
9153
9178
  const fresh = cache?.fresh(key2);
9154
9179
  if (fresh) return blockResult(fresh, "cache");
9155
- const timeout = options.timeout ?? (params.view === "voice" ? this.timeouts.contextVoice : this.readBudget("context"));
9180
+ const readKey = `agent-memory:${key2}`;
9181
+ const first = !this.answeredReads.has(readKey);
9182
+ const timeout = options.timeout ?? (params.view === "voice" ? this.timeouts.contextVoice : this.readBudget("context", first));
9156
9183
  const spec = this.readSpec("GET", "/v1/agent-memory/block", void 0, timeout, options);
9157
9184
  spec.query = {
9158
9185
  max_tokens: String(params.max_tokens ?? 300),
@@ -9163,6 +9190,7 @@ var Niadra = class _Niadra {
9163
9190
  if (etag) spec.headers = { ...options.headers, "if-none-match": etag };
9164
9191
  try {
9165
9192
  const response = await core.transport.request(spec);
9193
+ this.readAnswered(readKey);
9166
9194
  cache?.store(key2, response.data);
9167
9195
  return blockResult(response.data, "network");
9168
9196
  } catch (error) {
@@ -9651,12 +9679,13 @@ var Niadra = class _Niadra {
9651
9679
  * to the region goes on top, so an agent far from the region (Sao Paulo, 170 ms from us-east-2) is not
9652
9680
  * timed out by the network; one the caller set is a ceiling.
9653
9681
  */
9654
- readBudget(name) {
9682
+ readBudget(name, first = false) {
9655
9683
  if (!this.defaultReads.has(name)) return this.timeouts[name];
9684
+ const base = first && name === "context" ? Math.max(this.timeouts.context, this.timeouts.contextFirst) : this.timeouts[name];
9656
9685
  const rtt = this.voice.rtt;
9657
- if (rtt !== null) return this.timeouts[name] + rtt;
9686
+ if (rtt !== null) return base + rtt;
9658
9687
  const open = this.core?.transport.connectionOpen() ?? false;
9659
- return this.measuring && open ? this.timeouts[name] + this.timeouts.connect : this.timeouts[name];
9688
+ return this.measuring && open ? base + this.timeouts.connect : base;
9660
9689
  }
9661
9690
  /** The client reads in voice: the voice budgets' warnings matter from now on. */
9662
9691
  startVoice(core) {