@niadra/sdk 0.10.5 → 0.11.1
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.
- package/CHANGELOG.md +29 -0
- package/README.md +1 -1
- package/dist/ai-sdk.cjs +1 -1
- package/dist/ai-sdk.cjs.map +1 -1
- package/dist/ai-sdk.d.cts +3 -3
- package/dist/ai-sdk.d.ts +3 -3
- package/dist/ai-sdk.js +1 -1
- package/dist/ai-sdk.js.map +1 -1
- package/dist/anthropic.d.cts +4 -4
- package/dist/anthropic.d.ts +4 -4
- package/dist/bedrock.d.cts +4 -4
- package/dist/bedrock.d.ts +4 -4
- package/dist/cli.js +39 -17
- package/dist/cli.js.map +1 -1
- package/dist/{client-DHPuVvHW.d.cts → client-CdkRzWz6.d.cts} +111 -21
- package/dist/{client-DHPuVvHW.d.ts → client-CdkRzWz6.d.ts} +111 -21
- package/dist/cloudflare-agents.d.cts +3 -3
- package/dist/cloudflare-agents.d.ts +3 -3
- package/dist/elevenlabs.cjs +3 -3
- package/dist/elevenlabs.cjs.map +1 -1
- package/dist/elevenlabs.d.cts +5 -5
- package/dist/elevenlabs.d.ts +5 -5
- package/dist/elevenlabs.js +3 -3
- package/dist/elevenlabs.js.map +1 -1
- package/dist/genkit.d.cts +3 -3
- package/dist/genkit.d.ts +3 -3
- package/dist/google-adk.cjs +3 -3
- package/dist/google-adk.cjs.map +1 -1
- package/dist/google-adk.d.cts +3 -3
- package/dist/google-adk.d.ts +3 -3
- package/dist/google-adk.js +3 -3
- package/dist/google-adk.js.map +1 -1
- package/dist/google-genai.d.cts +4 -4
- package/dist/google-genai.d.ts +4 -4
- package/dist/index.cjs +39 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +39 -17
- package/dist/index.js.map +1 -1
- package/dist/{intercept-ClZ9sP5g.d.cts → intercept-C_9uxSRY.d.cts} +1 -1
- package/dist/{intercept-CJWSHZk9.d.ts → intercept-tVhq4GNK.d.ts} +1 -1
- package/dist/langchain.cjs +1 -1
- package/dist/langchain.cjs.map +1 -1
- package/dist/langchain.d.cts +3 -3
- package/dist/langchain.d.ts +3 -3
- package/dist/langchain.js +1 -1
- package/dist/langchain.js.map +1 -1
- package/dist/livekit.d.cts +3 -3
- package/dist/livekit.d.ts +3 -3
- package/dist/llamaindex.d.cts +3 -3
- package/dist/llamaindex.d.ts +3 -3
- package/dist/mastra.cjs +1 -1
- package/dist/mastra.cjs.map +1 -1
- package/dist/mastra.d.cts +3 -3
- package/dist/mastra.d.ts +3 -3
- package/dist/mastra.js +1 -1
- package/dist/mastra.js.map +1 -1
- package/dist/openai-agents.d.cts +3 -3
- package/dist/openai-agents.d.ts +3 -3
- package/dist/retell.cjs +3 -3
- package/dist/retell.cjs.map +1 -1
- package/dist/retell.d.cts +5 -5
- package/dist/retell.d.ts +5 -5
- package/dist/retell.js +3 -3
- package/dist/retell.js.map +1 -1
- package/dist/{shared-Cf_vc6TD.d.cts → shared-DH_QGnci.d.cts} +1 -1
- package/dist/{shared-XhiKa4WA.d.ts → shared-SqZSrkls.d.ts} +1 -1
- package/dist/strands.d.cts +3 -3
- package/dist/strands.d.ts +3 -3
- package/dist/twilio.d.cts +4 -4
- package/dist/twilio.d.ts +4 -4
- package/dist/vapi.cjs +3 -3
- package/dist/vapi.cjs.map +1 -1
- package/dist/vapi.d.cts +5 -5
- package/dist/vapi.d.ts +5 -5
- package/dist/vapi.js +3 -3
- package/dist/vapi.js.map +1 -1
- package/dist/voltagent.d.cts +3 -3
- package/dist/voltagent.d.ts +3 -3
- package/dist/{webhook-CYcSCdKl.d.ts → webhook-BNvRGq0g.d.ts} +1 -1
- package/dist/{webhook-BI4lYE61.d.cts → webhook-DIHeQ7DO.d.cts} +1 -1
- package/dist/whatsapp.d.cts +2 -2
- package/dist/whatsapp.d.ts +2 -2
- package/package.json +1 -1
package/dist/google-genai.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { f as ModelUsage } from './client-
|
|
2
|
-
import { W as WrapOptions } from './intercept-
|
|
3
|
-
import { S as SessionResolver } from './shared-
|
|
4
|
-
export { A as AgentMemoryOption, P as Proof, a as ProofSource, b as Session, c as attestationProof } from './shared-
|
|
1
|
+
import { f as ModelUsage } from './client-CdkRzWz6.js';
|
|
2
|
+
import { W as WrapOptions } from './intercept-tVhq4GNK.js';
|
|
3
|
+
import { S as SessionResolver } from './shared-SqZSrkls.js';
|
|
4
|
+
export { A as AgentMemoryOption, P as Proof, a as ProofSource, b as Session, c as attestationProof } from './shared-SqZSrkls.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
|
@@ -129,7 +129,7 @@ function explain(error) {
|
|
|
129
129
|
var segment = (value) => encodeURIComponent(value);
|
|
130
130
|
function correction(profileId, params) {
|
|
131
131
|
const body = { profile_id: profileId, action: params.action };
|
|
132
|
-
if (params.fact_id) body.fact_id = params.fact_id
|
|
132
|
+
if (params.fact_id) body.fact_id = params.fact_id;
|
|
133
133
|
if (params.open_item_id) body.open_item_id = params.open_item_id;
|
|
134
134
|
if (params.value) body.value = params.value;
|
|
135
135
|
if (params.reason) body.reason = params.reason;
|
|
@@ -152,9 +152,9 @@ var Admin = class {
|
|
|
152
152
|
() => this.port.read("GET", `/v1/profiles/${segment(profileId)}/memory`, void 0, options)
|
|
153
153
|
);
|
|
154
154
|
}
|
|
155
|
-
/** Every value a fact's slot held, oldest first, with who replaced whom. Takes
|
|
155
|
+
/** Every value a fact's slot held, oldest first, with who replaced whom. Takes the fact's bare id. */
|
|
156
156
|
factHistory(profileId, factId, options = {}) {
|
|
157
|
-
const fact = segment(factId
|
|
157
|
+
const fact = segment(factId);
|
|
158
158
|
return this.port.send(
|
|
159
159
|
() => this.port.read("GET", `/v1/profiles/${segment(profileId)}/facts/${fact}/history`, void 0, options)
|
|
160
160
|
);
|
|
@@ -525,7 +525,7 @@ function internalRecord(span, ref, act) {
|
|
|
525
525
|
}
|
|
526
526
|
|
|
527
527
|
// src/version.ts
|
|
528
|
-
var VERSION = "0.
|
|
528
|
+
var VERSION = "0.11.1";
|
|
529
529
|
|
|
530
530
|
// src/transport.ts
|
|
531
531
|
var RETRYABLE_WRITE_STATUS = /* @__PURE__ */ new Set([408, 421, 429, 500, 502, 503, 504]);
|
|
@@ -3164,7 +3164,7 @@ function render(block, binding, call, mode = "advisory") {
|
|
|
3164
3164
|
if (mode === "apply") {
|
|
3165
3165
|
const disputed = new Set(conflicts2.map((c) => c.id));
|
|
3166
3166
|
const allowed = /* @__PURE__ */ new Set([
|
|
3167
|
-
...hard.filter((h) => SAID.has(h.source) && (h.scope === "turn" || h.scope === "session") && !disputed.has(h.id)).map((h) => h.id),
|
|
3167
|
+
...hard.filter((h) => SAID.has(h.source) && (h.scope === "turn" || h.scope === "session" || h.scope === "object") && !disputed.has(h.id)).map((h) => h.id),
|
|
3168
3168
|
...attributes.filter((a) => a.source === "stated" || a.source === "correction").map((a) => a.id)
|
|
3169
3169
|
]);
|
|
3170
3170
|
for (const [param, value] of suggested) {
|
|
@@ -7714,6 +7714,7 @@ var silentLogger = { debug: noop, warn: noop, error: noop };
|
|
|
7714
7714
|
// src/options.ts
|
|
7715
7715
|
var DEFAULT_TIMEOUTS = {
|
|
7716
7716
|
context: 300,
|
|
7717
|
+
contextFirst: 1e3,
|
|
7717
7718
|
contextVoice: 200,
|
|
7718
7719
|
contextVoiceStart: 1500,
|
|
7719
7720
|
navigation: 600,
|
|
@@ -7989,7 +7990,7 @@ var TOOL_DEFINITIONS = [
|
|
|
7989
7990
|
"type": "function",
|
|
7990
7991
|
"function": {
|
|
7991
7992
|
"name": "search_customer_history",
|
|
7992
|
-
"description": "Search everything that already happened with this customer: past conversations, promises, agent actions, orders and invoices. Use it when the customer refers to something earlier or asks whether a problem happened before. Do not call it when the answer is already in the context block, including its 'Hist\xF3rico' line, which already counts recurrences. Returns short items with date, channel and outcome, plus a recurrence count. Open a conversation (`episode
|
|
7993
|
+
"description": "Search everything that already happened with this customer: past conversations, promises, agent actions, orders and invoices. Use it when the customer refers to something earlier or asks whether a problem happened before. Do not call it when the answer is already in the context block, including its 'Hist\xF3rico' line, which already counts recurrences. Returns short items with date, channel and outcome, plus a recurrence count. Open a conversation (kind `episode`) or an object (kind `object`) by its id with open_history_item; the other items are complete as listed.",
|
|
7993
7994
|
"parameters": {
|
|
7994
7995
|
"type": "object",
|
|
7995
7996
|
"properties": {
|
|
@@ -8129,13 +8130,13 @@ var TOOL_DEFINITIONS = [
|
|
|
8129
8130
|
"type": "function",
|
|
8130
8131
|
"function": {
|
|
8131
8132
|
"name": "open_history_item",
|
|
8132
|
-
"description": "Open one conversation (`episode
|
|
8133
|
+
"description": "Open one conversation (kind `episode`) or business object (kind `object`) returned by search_customer_history or get_customer_timeline: what was asked, what was promised and by whom, the outcome and what memory came from it. Actions, events, facts and promises are complete as listed and do not open. Use it only after a search or timeline pointed to the item.",
|
|
8133
8134
|
"parameters": {
|
|
8134
8135
|
"type": "object",
|
|
8135
8136
|
"properties": {
|
|
8136
8137
|
"id": {
|
|
8137
8138
|
"type": "string",
|
|
8138
|
-
"description": "The item id
|
|
8139
|
+
"description": "The item's `id`, as listed."
|
|
8139
8140
|
}
|
|
8140
8141
|
},
|
|
8141
8142
|
"required": [
|
|
@@ -8524,6 +8525,7 @@ function rttWarnings(rttMs, timeouts) {
|
|
|
8524
8525
|
}
|
|
8525
8526
|
|
|
8526
8527
|
// src/client.ts
|
|
8528
|
+
var READ_KEYS_KEPT = 4096;
|
|
8527
8529
|
function readEnv(name) {
|
|
8528
8530
|
try {
|
|
8529
8531
|
const env = globalThis.process?.env;
|
|
@@ -8551,6 +8553,8 @@ var Niadra = class _Niadra {
|
|
|
8551
8553
|
voiceStarted = false;
|
|
8552
8554
|
/** A probe is on its way: until it ends, default read budgets get `timeouts.connect` on top. */
|
|
8553
8555
|
measuring = false;
|
|
8556
|
+
/** The keys whose read answered in this client, oldest first: a first read gets `timeouts.contextFirst`. */
|
|
8557
|
+
answeredReads = /* @__PURE__ */ new Map();
|
|
8554
8558
|
voiceWarned = false;
|
|
8555
8559
|
strict;
|
|
8556
8560
|
/** Where the client reports what it swallows in fail-open mode. */
|
|
@@ -8737,14 +8741,28 @@ var Niadra = class _Niadra {
|
|
|
8737
8741
|
if (this.content.registered && result2.state) result2.state = await this.content.fill(result2.state);
|
|
8738
8742
|
return result2;
|
|
8739
8743
|
}
|
|
8740
|
-
readContext(core, params, request, options) {
|
|
8741
|
-
const timeout = options.timeout ?? (request.view === "voice" ? this.timeouts.contextVoice : this.readBudget("context"));
|
|
8744
|
+
async readContext(core, params, request, options) {
|
|
8742
8745
|
const { query: own3, ...pinned2 } = request;
|
|
8743
8746
|
const query = turnText(own3 ?? params.turn);
|
|
8747
|
+
const readKey = cacheKey(pinned2);
|
|
8748
|
+
const first = !this.answeredReads.has(readKey);
|
|
8749
|
+
const timeout = options.timeout ?? (request.view === "voice" ? this.timeouts.contextVoice : this.readBudget("context", first));
|
|
8744
8750
|
const voiceCache = this.voiceCache(core, pinned2, options.cache);
|
|
8745
|
-
|
|
8746
|
-
if (
|
|
8747
|
-
|
|
8751
|
+
let result2;
|
|
8752
|
+
if (voiceCache) result2 = await this.voiceContext(core, voiceCache, pinned2, query, timeout, options);
|
|
8753
|
+
else if (query !== null) result2 = await this.turnContext(core, pinned2, query, timeout, options);
|
|
8754
|
+
else result2 = await this.pinnedContext(core, pinned2, timeout, options);
|
|
8755
|
+
if (result2.error === null) this.readAnswered(readKey);
|
|
8756
|
+
return result2;
|
|
8757
|
+
}
|
|
8758
|
+
readAnswered(key2) {
|
|
8759
|
+
this.answeredReads.delete(key2);
|
|
8760
|
+
this.answeredReads.set(key2, true);
|
|
8761
|
+
while (this.answeredReads.size > READ_KEYS_KEPT) {
|
|
8762
|
+
const oldest = this.answeredReads.keys().next().value;
|
|
8763
|
+
if (oldest === void 0) break;
|
|
8764
|
+
this.answeredReads.delete(oldest);
|
|
8765
|
+
}
|
|
8748
8766
|
}
|
|
8749
8767
|
/**
|
|
8750
8768
|
* The SDK profile of this key's space: the features it turned on, the claim contract and the summarized
|
|
@@ -9152,7 +9170,9 @@ var Niadra = class _Niadra {
|
|
|
9152
9170
|
const key2 = AgentMemoryCache.key(params);
|
|
9153
9171
|
const fresh = cache?.fresh(key2);
|
|
9154
9172
|
if (fresh) return blockResult(fresh, "cache");
|
|
9155
|
-
const
|
|
9173
|
+
const readKey = `agent-memory:${key2}`;
|
|
9174
|
+
const first = !this.answeredReads.has(readKey);
|
|
9175
|
+
const timeout = options.timeout ?? (params.view === "voice" ? this.timeouts.contextVoice : this.readBudget("context", first));
|
|
9156
9176
|
const spec = this.readSpec("GET", "/v1/agent-memory/block", void 0, timeout, options);
|
|
9157
9177
|
spec.query = {
|
|
9158
9178
|
max_tokens: String(params.max_tokens ?? 300),
|
|
@@ -9163,6 +9183,7 @@ var Niadra = class _Niadra {
|
|
|
9163
9183
|
if (etag) spec.headers = { ...options.headers, "if-none-match": etag };
|
|
9164
9184
|
try {
|
|
9165
9185
|
const response = await core.transport.request(spec);
|
|
9186
|
+
this.readAnswered(readKey);
|
|
9166
9187
|
cache?.store(key2, response.data);
|
|
9167
9188
|
return blockResult(response.data, "network");
|
|
9168
9189
|
} catch (error) {
|
|
@@ -9651,12 +9672,13 @@ var Niadra = class _Niadra {
|
|
|
9651
9672
|
* to the region goes on top, so an agent far from the region (Sao Paulo, 170 ms from us-east-2) is not
|
|
9652
9673
|
* timed out by the network; one the caller set is a ceiling.
|
|
9653
9674
|
*/
|
|
9654
|
-
readBudget(name) {
|
|
9675
|
+
readBudget(name, first = false) {
|
|
9655
9676
|
if (!this.defaultReads.has(name)) return this.timeouts[name];
|
|
9677
|
+
const base = first && name === "context" ? Math.max(this.timeouts.context, this.timeouts.contextFirst) : this.timeouts[name];
|
|
9656
9678
|
const rtt = this.voice.rtt;
|
|
9657
|
-
if (rtt !== null) return
|
|
9679
|
+
if (rtt !== null) return base + rtt;
|
|
9658
9680
|
const open = this.core?.transport.connectionOpen() ?? false;
|
|
9659
|
-
return this.measuring && open ?
|
|
9681
|
+
return this.measuring && open ? base + this.timeouts.connect : base;
|
|
9660
9682
|
}
|
|
9661
9683
|
/** The client reads in voice: the voice budgets' warnings matter from now on. */
|
|
9662
9684
|
startVoice(core) {
|