@niadra/sdk 0.7.0 → 0.9.0
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 +46 -0
- package/README.md +15 -6
- package/dist/ai-sdk.cjs +3 -4
- 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 +3 -4
- package/dist/ai-sdk.js.map +1 -1
- package/dist/anthropic.cjs +1 -1
- package/dist/anthropic.cjs.map +1 -1
- package/dist/anthropic.d.cts +4 -4
- package/dist/anthropic.d.ts +4 -4
- package/dist/anthropic.js +1 -1
- package/dist/anthropic.js.map +1 -1
- package/dist/bedrock.cjs +1 -1
- package/dist/bedrock.cjs.map +1 -1
- package/dist/bedrock.d.cts +4 -4
- package/dist/bedrock.d.ts +4 -4
- package/dist/bedrock.js +1 -1
- package/dist/bedrock.js.map +1 -1
- package/dist/cli.js +107 -51
- package/dist/cli.js.map +1 -1
- package/dist/{client-DsIxZxZk.d.cts → client-B_ip8T2o.d.cts} +69 -14
- package/dist/{client-DsIxZxZk.d.ts → client-B_ip8T2o.d.ts} +69 -14
- package/dist/cloudflare-agents.cjs +1 -1
- package/dist/cloudflare-agents.cjs.map +1 -1
- package/dist/cloudflare-agents.d.cts +3 -3
- package/dist/cloudflare-agents.d.ts +3 -3
- package/dist/cloudflare-agents.js +1 -1
- package/dist/cloudflare-agents.js.map +1 -1
- package/dist/elevenlabs.cjs +1 -1
- 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 +1 -1
- package/dist/elevenlabs.js.map +1 -1
- package/dist/genkit.cjs +1 -1
- package/dist/genkit.cjs.map +1 -1
- package/dist/genkit.d.cts +3 -3
- package/dist/genkit.d.ts +3 -3
- package/dist/genkit.js +1 -1
- package/dist/genkit.js.map +1 -1
- package/dist/google-adk.cjs +1 -1
- 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 +1 -1
- package/dist/google-adk.js.map +1 -1
- package/dist/google-genai.cjs +1 -1
- package/dist/google-genai.cjs.map +1 -1
- package/dist/google-genai.d.cts +4 -4
- package/dist/google-genai.d.ts +4 -4
- package/dist/google-genai.js +1 -1
- package/dist/google-genai.js.map +1 -1
- package/dist/index.cjs +106 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -8
- package/dist/index.d.ts +6 -8
- package/dist/index.js +106 -48
- package/dist/index.js.map +1 -1
- package/dist/{intercept-D7qFCaRb.d.ts → intercept-CBaPK_-k.d.ts} +1 -1
- package/dist/{intercept-0_lJE6k1.d.cts → intercept-CxmBLfoj.d.cts} +1 -1
- package/dist/langchain.cjs +3 -4
- 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 +3 -4
- package/dist/langchain.js.map +1 -1
- package/dist/livekit.cjs +1 -1
- package/dist/livekit.cjs.map +1 -1
- package/dist/livekit.d.cts +3 -3
- package/dist/livekit.d.ts +3 -3
- package/dist/livekit.js +1 -1
- package/dist/livekit.js.map +1 -1
- package/dist/llamaindex.cjs +1 -1
- package/dist/llamaindex.cjs.map +1 -1
- package/dist/llamaindex.d.cts +3 -3
- package/dist/llamaindex.d.ts +3 -3
- package/dist/llamaindex.js +1 -1
- package/dist/llamaindex.js.map +1 -1
- package/dist/mastra.cjs +3 -4
- 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 +3 -4
- package/dist/mastra.js.map +1 -1
- package/dist/openai-agents.cjs +1 -1
- package/dist/openai-agents.cjs.map +1 -1
- package/dist/openai-agents.d.cts +3 -3
- package/dist/openai-agents.d.ts +3 -3
- package/dist/openai-agents.js +1 -1
- package/dist/openai-agents.js.map +1 -1
- package/dist/retell.cjs +1 -1
- 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 +1 -1
- package/dist/retell.js.map +1 -1
- package/dist/{shared-Bb5B59Bu.d.ts → shared-BLkAbvuf.d.ts} +1 -1
- package/dist/{shared-DTPWVlWm.d.cts → shared-DEkF2Y_z.d.cts} +1 -1
- package/dist/strands.cjs +1 -1
- package/dist/strands.cjs.map +1 -1
- package/dist/strands.d.cts +3 -3
- package/dist/strands.d.ts +3 -3
- package/dist/strands.js +1 -1
- package/dist/strands.js.map +1 -1
- package/dist/twilio.d.cts +4 -4
- package/dist/twilio.d.ts +4 -4
- package/dist/vapi.cjs +1 -1
- 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 +1 -1
- package/dist/vapi.js.map +1 -1
- package/dist/voltagent.cjs +1 -1
- package/dist/voltagent.cjs.map +1 -1
- package/dist/voltagent.d.cts +3 -3
- package/dist/voltagent.d.ts +3 -3
- package/dist/voltagent.js +1 -1
- package/dist/voltagent.js.map +1 -1
- package/dist/{webhook-1ozGyksG.d.ts → webhook-BaraTaA9.d.ts} +1 -1
- package/dist/{webhook-CG4om_DK.d.cts → webhook-CuR0Wckd.d.cts} +1 -1
- package/dist/whatsapp.d.cts +2 -2
- package/dist/whatsapp.d.ts +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,52 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this package are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the package follows [Semantic Versioning](https://semver.org/).
|
|
4
4
|
|
|
5
|
+
## [Unreleased]
|
|
6
|
+
|
|
7
|
+
## [0.9.0] - 2026-09-30
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `ContextResult.ageMs`: how long ago Niadra sent or confirmed the pack a read served. It is 0 for an answer
|
|
12
|
+
just received and grows while the cache serves the pack (`cache`, `stale`, or `fallback` with Niadra down).
|
|
13
|
+
- The chaos test (`test/chaos.test.ts`): Niadra's process killed, its network gone silent, answering 503 and
|
|
14
|
+
answering past the deadline, in the middle of a conversation.
|
|
15
|
+
- A state read's objects carry `derived`: the type's derived fields over its related objects (a look's
|
|
16
|
+
`all_pieces_available`), computed at the read, each with `v`, `logic`, `over` and `unknown`
|
|
17
|
+
(`DerivedState`). A shared object of a derived type carries `derived_status`, and its push's `inputs` name
|
|
18
|
+
shared objects.
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- The local copy of the suppression list is read to its end against the server: a page shorter than the limit
|
|
23
|
+
ends a read, and its cursor is where the next read starts. The server names the cursor on the last page
|
|
24
|
+
too, so the copy read 50 pages of nothing and was never held: `mayContact()` and a check that Niadra did not
|
|
25
|
+
answer fell back on the purpose's direction. The stand-in cell answers as the server does.
|
|
26
|
+
- A batch of events that still fails after its attempts with an error that may pass goes back to the front of
|
|
27
|
+
the queue and leaves again after a pause, doubling up to a minute, instead of being dropped: what an agent
|
|
28
|
+
said during an outage longer than a few seconds reached Niadra only in part.
|
|
29
|
+
- A check about an outbound contact keeps the local copy of the suppression list, read in the background once
|
|
30
|
+
a minute. Before, only `mayContact()` read it, so an agent that only called `check()` had no copy when Niadra
|
|
31
|
+
went down, and a purpose that fails open (`service`, `transactional`) went out to a customer who had opted
|
|
32
|
+
out of it.
|
|
33
|
+
|
|
34
|
+
## [0.8.0] - 2026-09-30
|
|
35
|
+
|
|
36
|
+
### Added
|
|
37
|
+
|
|
38
|
+
- The claim guard takes the offers a context read served as evidence: each object in the constraints block's
|
|
39
|
+
`already_presented` carries the numbers it was last shown with (`values`: price, total, discount,
|
|
40
|
+
installment), each with its role and whether it may be claimed now, and `blockValues()` turns them into
|
|
41
|
+
values the guard checks a number against, as it checks a tool's result. An offer shown too long ago to claim makes the
|
|
42
|
+
number `stale`, and a price only the pack's text states is still `unsupported`. The constraints block's
|
|
43
|
+
`Shown` model gains `values` (`ShownValue`).
|
|
44
|
+
|
|
45
|
+
### Removed
|
|
46
|
+
|
|
47
|
+
- `tool(..., { binding })`, `new Counterfactual(..., { bindings })` and `niadra counterfactual --bindings`: a
|
|
48
|
+
tool's binding comes only from the space's `tool-bindings` document, which the SDK profile serves. A
|
|
49
|
+
counterfactual for a tool the space does not bind stops before calling it.
|
|
50
|
+
|
|
5
51
|
## [0.7.0] - 2026-09-30
|
|
6
52
|
|
|
7
53
|
The agent core. Every turn an agent takes is recorded in its own process; what it says is checked against
|
package/README.md
CHANGED
|
@@ -691,10 +691,11 @@ await convo.turn({ build: Niadra.build({ prompts: { store: "v16" }, model: "gpt-
|
|
|
691
691
|
without `include` keeps its suffix. With Niadra down, the last good blocks serve.
|
|
692
692
|
- **Coordination** decides by each purpose's direction when Niadra does not answer within 200 ms: a
|
|
693
693
|
customer's message and service go, marketing, retention, collection and an effect with a key wait, and
|
|
694
|
-
the local copy of the opt-out list always holds.
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
694
|
+
the local copy of the opt-out list always holds. Every check about an outbound contact keeps that copy,
|
|
695
|
+
read again in the background once a minute.
|
|
696
|
+
- **Tool bindings** live in the space's `tool-bindings` document and come in the SDK profile, never in code: a
|
|
697
|
+
tool measures the constraints block through the one served for its name, the counterfactual runs through it,
|
|
698
|
+
and its `capabilities.mask_output` decides the masking when the code leaves `maskOutput` unset.
|
|
698
699
|
- **The `niadra` command** (Node) runs `replay`, `counterfactual`, `resolver-worker` (the space's refresh
|
|
699
700
|
requests, read with your resolvers inside your boundary; a watch fires only on a value the worker
|
|
700
701
|
confirmed, and a resolver returns `NOT_FOUND` when the source no longer has the object), `types derive` and
|
|
@@ -714,10 +715,16 @@ Memory should make an agent better, never make it fail. By default:
|
|
|
714
715
|
| 401 or 403 | Not treated as an outage: the cached packs are dropped (all of them on 401, the one requested on 403) and `context()` returns empty. Revoking a key also stops what the process had cached. |
|
|
715
716
|
| 421 (the space moved to another cell) | Retried at once, up to three attempts. |
|
|
716
717
|
| 429 on a batch | Retried after `Retry-After`. |
|
|
717
|
-
| Batch failure | Retried with exponential backoff and jitter, three attempts. 4xx answers other than 408, 421 and 429 are never retried. A batch that still fails
|
|
718
|
+
| Batch failure | Retried with exponential backoff and jitter, three attempts. 4xx answers other than 408, 421 and 429 are never retried. A batch that still fails goes back to the front of the queue and leaves again after a pause that doubles, up to a minute, while Niadra stays down; each event keeps its idempotency key, so it is stored once. |
|
|
718
719
|
| Queue full (10,000 items) | New events are dropped and logged. |
|
|
719
720
|
| Server rejects one item of a batch (207) | Only that item fails; the rest are stored. |
|
|
720
721
|
|
|
722
|
+
With Niadra down, a read serves the conversation's last good pack (`source: "fallback"`) with `ageMs`
|
|
723
|
+
saying how old it is; the opt-out holds by the local copy of the suppression list; turn records, events
|
|
724
|
+
and declarations wait in their queues and leave once Niadra answers again, each stored once.
|
|
725
|
+
`test/chaos.test.ts` kills Niadra's process, silences its network, answers 503 and answers late in the
|
|
726
|
+
middle of a conversation, and checks all of it.
|
|
727
|
+
|
|
721
728
|
Every call you wait for has its own time budget for the whole call, retries and waits included, independent of your platform's:
|
|
722
729
|
|
|
723
730
|
| Call | Default |
|
|
@@ -729,7 +736,7 @@ Every call you wait for has its own time budget for the whole call, retries and
|
|
|
729
736
|
| `identify()`, `verify()`, `handoff()`, `feedback()` and the reservation in `uploadMedia()` | 5 s |
|
|
730
737
|
| The transfer in `uploadMedia()` | 60 s |
|
|
731
738
|
|
|
732
|
-
An `identify()`, `verify()` or `handoff()` that runs out of time resolves with
|
|
739
|
+
An `identify()`, `verify()` or `handoff()` that runs out of time, or that Niadra cannot take for now (a network error, a 5xx), resolves with that error and stays in the queue, which keeps sending it. `track()` never waits; each attempt of a background batch has 5 s. Override them with `timeouts`, or per call with `{ timeout }`. Pass `{ signal }` to cancel a call.
|
|
733
740
|
|
|
734
741
|
### The context cache
|
|
735
742
|
|
|
@@ -740,6 +747,8 @@ Inside a conversation or task, packs are cached in memory:
|
|
|
740
747
|
- when a request fails: the last good pack, if it is less than 30 minutes old;
|
|
741
748
|
- at most 1,000 packs, the least recently used evicted first.
|
|
742
749
|
|
|
750
|
+
`source` says which of these served the read, and `ageMs` how long ago Niadra sent or confirmed that pack.
|
|
751
|
+
|
|
743
752
|
Refreshes send the cached ETag, so an unchanged pack costs a `not_modified` answer instead of the
|
|
744
753
|
full text, and only one background refresh per pack runs at a time. A 401 or 403 is not an
|
|
745
754
|
outage: the cached packs go (all of them on 401, the one requested on 403), so cutting a vendor's
|
package/dist/ai-sdk.cjs
CHANGED
|
@@ -385,7 +385,7 @@ function thenable(value) {
|
|
|
385
385
|
function tool(name, fn, options = {}) {
|
|
386
386
|
const isAsync = isAsyncFunction(fn);
|
|
387
387
|
function bindingOf(frame) {
|
|
388
|
-
return
|
|
388
|
+
return (options.served ?? frame?.profile.bindings)?.(name) ?? null;
|
|
389
389
|
}
|
|
390
390
|
function masks(frame) {
|
|
391
391
|
return options.maskOutput ?? bindingOf(frame)?.capabilities?.mask_output ?? false;
|
|
@@ -500,8 +500,7 @@ function tool(name, fn, options = {}) {
|
|
|
500
500
|
const marker = {
|
|
501
501
|
name,
|
|
502
502
|
dryRun: options.dryRun ?? false,
|
|
503
|
-
provenance: options.provenance ?? null
|
|
504
|
-
binding: options.binding ?? null
|
|
503
|
+
provenance: options.provenance ?? null
|
|
505
504
|
};
|
|
506
505
|
Object.defineProperty(wrapped, RECORDED, { value: marker });
|
|
507
506
|
return wrapped;
|
|
@@ -527,7 +526,7 @@ function measure(frame, raw, args) {
|
|
|
527
526
|
|
|
528
527
|
// src/context.ts
|
|
529
528
|
function emptyResult(error) {
|
|
530
|
-
return { text: "", suffix: "", variables: {}, pack: null, source: "none", response: null, error, constraints: null, state: null, coordination: null };
|
|
529
|
+
return { text: "", suffix: "", variables: {}, pack: null, source: "none", ageMs: null, response: null, error, constraints: null, state: null, coordination: null };
|
|
531
530
|
}
|
|
532
531
|
|
|
533
532
|
// src/integrations/shared.ts
|