@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/anthropic.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { W as WrapOptions } from './intercept-
|
|
2
|
-
import { S as SessionResolver } from './shared-
|
|
3
|
-
export { A as AgentMemoryOption, P as Proof, a as ProofSource, b as Session, c as attestationProof } from './shared-
|
|
4
|
-
import './client-
|
|
1
|
+
import { W as WrapOptions } from './intercept-C_9uxSRY.cjs';
|
|
2
|
+
import { S as SessionResolver } from './shared-DH_QGnci.cjs';
|
|
3
|
+
export { A as AgentMemoryOption, P as Proof, a as ProofSource, b as Session, c as attestationProof } from './shared-DH_QGnci.cjs';
|
|
4
|
+
import './client-CdkRzWz6.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Niadra for the Anthropic TypeScript SDK (`@anthropic-ai/sdk`), as `wrap()` is for OpenAI.
|
package/dist/anthropic.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { W as WrapOptions } from './intercept-
|
|
2
|
-
import { S as SessionResolver } from './shared-
|
|
3
|
-
export { A as AgentMemoryOption, P as Proof, a as ProofSource, b as Session, c as attestationProof } from './shared-
|
|
4
|
-
import './client-
|
|
1
|
+
import { W as WrapOptions } from './intercept-tVhq4GNK.js';
|
|
2
|
+
import { S as SessionResolver } from './shared-SqZSrkls.js';
|
|
3
|
+
export { A as AgentMemoryOption, P as Proof, a as ProofSource, b as Session, c as attestationProof } from './shared-SqZSrkls.js';
|
|
4
|
+
import './client-CdkRzWz6.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Niadra for the Anthropic TypeScript SDK (`@anthropic-ai/sdk`), as `wrap()` is for OpenAI.
|
package/dist/bedrock.d.cts
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.cjs';
|
|
2
|
+
import { W as WrapOptions } from './intercept-C_9uxSRY.cjs';
|
|
3
|
+
import { S as SessionResolver } from './shared-DH_QGnci.cjs';
|
|
4
|
+
export { A as AgentMemoryOption, P as Proof, a as ProofSource, b as Session, c as attestationProof } from './shared-DH_QGnci.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Niadra for Amazon Bedrock's Converse API (`@aws-sdk/client-bedrock-runtime`), as `wrap()` is for
|
package/dist/bedrock.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 Amazon Bedrock's Converse API (`@aws-sdk/client-bedrock-runtime`), as `wrap()` is for
|
package/dist/cli.js
CHANGED
|
@@ -120,7 +120,7 @@ function explain(error) {
|
|
|
120
120
|
var segment = (value) => encodeURIComponent(value);
|
|
121
121
|
function correction(profileId, params) {
|
|
122
122
|
const body = { profile_id: profileId, action: params.action };
|
|
123
|
-
if (params.fact_id) body.fact_id = params.fact_id
|
|
123
|
+
if (params.fact_id) body.fact_id = params.fact_id;
|
|
124
124
|
if (params.open_item_id) body.open_item_id = params.open_item_id;
|
|
125
125
|
if (params.value) body.value = params.value;
|
|
126
126
|
if (params.reason) body.reason = params.reason;
|
|
@@ -143,9 +143,9 @@ var Admin = class {
|
|
|
143
143
|
() => this.port.read("GET", `/v1/profiles/${segment(profileId)}/memory`, void 0, options)
|
|
144
144
|
);
|
|
145
145
|
}
|
|
146
|
-
/** Every value a fact's slot held, oldest first, with who replaced whom. Takes
|
|
146
|
+
/** Every value a fact's slot held, oldest first, with who replaced whom. Takes the fact's bare id. */
|
|
147
147
|
factHistory(profileId, factId, options = {}) {
|
|
148
|
-
const fact = segment(factId
|
|
148
|
+
const fact = segment(factId);
|
|
149
149
|
return this.port.send(
|
|
150
150
|
() => this.port.read("GET", `/v1/profiles/${segment(profileId)}/facts/${fact}/history`, void 0, options)
|
|
151
151
|
);
|
|
@@ -510,7 +510,7 @@ function internalRecord(span, ref, act) {
|
|
|
510
510
|
}
|
|
511
511
|
|
|
512
512
|
// src/version.ts
|
|
513
|
-
var VERSION = "0.
|
|
513
|
+
var VERSION = "0.11.1";
|
|
514
514
|
|
|
515
515
|
// src/transport.ts
|
|
516
516
|
var RETRYABLE_WRITE_STATUS = /* @__PURE__ */ new Set([408, 421, 429, 500, 502, 503, 504]);
|
|
@@ -3145,7 +3145,7 @@ function render(block, binding, call, mode = "advisory") {
|
|
|
3145
3145
|
if (mode === "apply") {
|
|
3146
3146
|
const disputed = new Set(conflicts2.map((c) => c.id));
|
|
3147
3147
|
const allowed = /* @__PURE__ */ new Set([
|
|
3148
|
-
...hard.filter((h) => SAID.has(h.source) && (h.scope === "turn" || h.scope === "session") && !disputed.has(h.id)).map((h) => h.id),
|
|
3148
|
+
...hard.filter((h) => SAID.has(h.source) && (h.scope === "turn" || h.scope === "session" || h.scope === "object") && !disputed.has(h.id)).map((h) => h.id),
|
|
3149
3149
|
...attributes.filter((a) => a.source === "stated" || a.source === "correction").map((a) => a.id)
|
|
3150
3150
|
]);
|
|
3151
3151
|
for (const [param, value] of suggested) {
|
|
@@ -7657,6 +7657,7 @@ var consoleLogger = {
|
|
|
7657
7657
|
// src/options.ts
|
|
7658
7658
|
var DEFAULT_TIMEOUTS = {
|
|
7659
7659
|
context: 300,
|
|
7660
|
+
contextFirst: 1e3,
|
|
7660
7661
|
contextVoice: 200,
|
|
7661
7662
|
contextVoiceStart: 1500,
|
|
7662
7663
|
navigation: 600,
|
|
@@ -7932,7 +7933,7 @@ var TOOL_DEFINITIONS = [
|
|
|
7932
7933
|
"type": "function",
|
|
7933
7934
|
"function": {
|
|
7934
7935
|
"name": "search_customer_history",
|
|
7935
|
-
"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
|
|
7936
|
+
"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.",
|
|
7936
7937
|
"parameters": {
|
|
7937
7938
|
"type": "object",
|
|
7938
7939
|
"properties": {
|
|
@@ -8072,13 +8073,13 @@ var TOOL_DEFINITIONS = [
|
|
|
8072
8073
|
"type": "function",
|
|
8073
8074
|
"function": {
|
|
8074
8075
|
"name": "open_history_item",
|
|
8075
|
-
"description": "Open one conversation (`episode
|
|
8076
|
+
"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.",
|
|
8076
8077
|
"parameters": {
|
|
8077
8078
|
"type": "object",
|
|
8078
8079
|
"properties": {
|
|
8079
8080
|
"id": {
|
|
8080
8081
|
"type": "string",
|
|
8081
|
-
"description": "The item id
|
|
8082
|
+
"description": "The item's `id`, as listed."
|
|
8082
8083
|
}
|
|
8083
8084
|
},
|
|
8084
8085
|
"required": [
|
|
@@ -8467,6 +8468,7 @@ function rttWarnings(rttMs, timeouts) {
|
|
|
8467
8468
|
}
|
|
8468
8469
|
|
|
8469
8470
|
// src/client.ts
|
|
8471
|
+
var READ_KEYS_KEPT = 4096;
|
|
8470
8472
|
function readEnv(name) {
|
|
8471
8473
|
try {
|
|
8472
8474
|
const env = globalThis.process?.env;
|
|
@@ -8494,6 +8496,8 @@ var Niadra = class _Niadra {
|
|
|
8494
8496
|
voiceStarted = false;
|
|
8495
8497
|
/** A probe is on its way: until it ends, default read budgets get `timeouts.connect` on top. */
|
|
8496
8498
|
measuring = false;
|
|
8499
|
+
/** The keys whose read answered in this client, oldest first: a first read gets `timeouts.contextFirst`. */
|
|
8500
|
+
answeredReads = /* @__PURE__ */ new Map();
|
|
8497
8501
|
voiceWarned = false;
|
|
8498
8502
|
strict;
|
|
8499
8503
|
/** Where the client reports what it swallows in fail-open mode. */
|
|
@@ -8680,14 +8684,28 @@ var Niadra = class _Niadra {
|
|
|
8680
8684
|
if (this.content.registered && result2.state) result2.state = await this.content.fill(result2.state);
|
|
8681
8685
|
return result2;
|
|
8682
8686
|
}
|
|
8683
|
-
readContext(core, params, request, options) {
|
|
8684
|
-
const timeout = options.timeout ?? (request.view === "voice" ? this.timeouts.contextVoice : this.readBudget("context"));
|
|
8687
|
+
async readContext(core, params, request, options) {
|
|
8685
8688
|
const { query: own2, ...pinned2 } = request;
|
|
8686
8689
|
const query = turnText(own2 ?? params.turn);
|
|
8690
|
+
const readKey = cacheKey(pinned2);
|
|
8691
|
+
const first = !this.answeredReads.has(readKey);
|
|
8692
|
+
const timeout = options.timeout ?? (request.view === "voice" ? this.timeouts.contextVoice : this.readBudget("context", first));
|
|
8687
8693
|
const voiceCache = this.voiceCache(core, pinned2, options.cache);
|
|
8688
|
-
|
|
8689
|
-
if (
|
|
8690
|
-
|
|
8694
|
+
let result2;
|
|
8695
|
+
if (voiceCache) result2 = await this.voiceContext(core, voiceCache, pinned2, query, timeout, options);
|
|
8696
|
+
else if (query !== null) result2 = await this.turnContext(core, pinned2, query, timeout, options);
|
|
8697
|
+
else result2 = await this.pinnedContext(core, pinned2, timeout, options);
|
|
8698
|
+
if (result2.error === null) this.readAnswered(readKey);
|
|
8699
|
+
return result2;
|
|
8700
|
+
}
|
|
8701
|
+
readAnswered(key2) {
|
|
8702
|
+
this.answeredReads.delete(key2);
|
|
8703
|
+
this.answeredReads.set(key2, true);
|
|
8704
|
+
while (this.answeredReads.size > READ_KEYS_KEPT) {
|
|
8705
|
+
const oldest = this.answeredReads.keys().next().value;
|
|
8706
|
+
if (oldest === void 0) break;
|
|
8707
|
+
this.answeredReads.delete(oldest);
|
|
8708
|
+
}
|
|
8691
8709
|
}
|
|
8692
8710
|
/**
|
|
8693
8711
|
* The SDK profile of this key's space: the features it turned on, the claim contract and the summarized
|
|
@@ -9095,7 +9113,9 @@ var Niadra = class _Niadra {
|
|
|
9095
9113
|
const key2 = AgentMemoryCache.key(params);
|
|
9096
9114
|
const fresh = cache?.fresh(key2);
|
|
9097
9115
|
if (fresh) return blockResult(fresh, "cache");
|
|
9098
|
-
const
|
|
9116
|
+
const readKey = `agent-memory:${key2}`;
|
|
9117
|
+
const first = !this.answeredReads.has(readKey);
|
|
9118
|
+
const timeout = options.timeout ?? (params.view === "voice" ? this.timeouts.contextVoice : this.readBudget("context", first));
|
|
9099
9119
|
const spec = this.readSpec("GET", "/v1/agent-memory/block", void 0, timeout, options);
|
|
9100
9120
|
spec.query = {
|
|
9101
9121
|
max_tokens: String(params.max_tokens ?? 300),
|
|
@@ -9106,6 +9126,7 @@ var Niadra = class _Niadra {
|
|
|
9106
9126
|
if (etag) spec.headers = { ...options.headers, "if-none-match": etag };
|
|
9107
9127
|
try {
|
|
9108
9128
|
const response = await core.transport.request(spec);
|
|
9129
|
+
this.readAnswered(readKey);
|
|
9109
9130
|
cache?.store(key2, response.data);
|
|
9110
9131
|
return blockResult(response.data, "network");
|
|
9111
9132
|
} catch (error) {
|
|
@@ -9594,12 +9615,13 @@ var Niadra = class _Niadra {
|
|
|
9594
9615
|
* to the region goes on top, so an agent far from the region (Sao Paulo, 170 ms from us-east-2) is not
|
|
9595
9616
|
* timed out by the network; one the caller set is a ceiling.
|
|
9596
9617
|
*/
|
|
9597
|
-
readBudget(name) {
|
|
9618
|
+
readBudget(name, first = false) {
|
|
9598
9619
|
if (!this.defaultReads.has(name)) return this.timeouts[name];
|
|
9620
|
+
const base = first && name === "context" ? Math.max(this.timeouts.context, this.timeouts.contextFirst) : this.timeouts[name];
|
|
9599
9621
|
const rtt = this.voice.rtt;
|
|
9600
|
-
if (rtt !== null) return
|
|
9622
|
+
if (rtt !== null) return base + rtt;
|
|
9601
9623
|
const open = this.core?.transport.connectionOpen() ?? false;
|
|
9602
|
-
return this.measuring && open ?
|
|
9624
|
+
return this.measuring && open ? base + this.timeouts.connect : base;
|
|
9603
9625
|
}
|
|
9604
9626
|
/** The client reads in voice: the voice budgets' warnings matter from now on. */
|
|
9605
9627
|
startVoice(core) {
|