@shashu-ai/sdk 1.1.0 → 1.2.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +61 -44
  2. package/NOTICE +1 -1
  3. package/README.md +7 -4
  4. package/dist/{_joiner-CmR7qVK8.d.cts → _joiner-D_FGAaoc.d.cts} +1 -11
  5. package/dist/{_joiner-CmR7qVK8.d.ts → _joiner-D_FGAaoc.d.ts} +1 -11
  6. package/dist/{chunk-QJQ4MWQ4.js → chunk-CWC6GQTL.js} +2 -2
  7. package/dist/{chunk-QLK5CQSP.js → chunk-K4ZIXS2U.js} +1 -1
  8. package/dist/{chunk-WC3BKVXK.js → chunk-MLFWJAEH.js} +2 -2
  9. package/dist/{chunk-NTIOPTYF.js → chunk-MZGHCDWX.js} +23 -2
  10. package/dist/{chunk-QHWUNZQS.js → chunk-TI45NK2R.js} +2 -2
  11. package/dist/{chunk-L6GKR3SC.js → chunk-YSAQRZFP.js} +127 -12
  12. package/dist/index.cjs +80 -37
  13. package/dist/index.d.cts +17 -17
  14. package/dist/index.d.ts +17 -17
  15. package/dist/index.js +37 -119
  16. package/dist/{langchain-B9Q9eL7g.d.cts → langchain-CoNoZ_vQ.d.cts} +4 -4
  17. package/dist/{langchain-CHjjdhDr.d.ts → langchain-D9Xo9IMm.d.ts} +4 -4
  18. package/dist/middleware/anthropic.cjs +2 -2
  19. package/dist/middleware/anthropic.d.cts +3 -3
  20. package/dist/middleware/anthropic.d.ts +3 -3
  21. package/dist/middleware/anthropic.js +3 -3
  22. package/dist/middleware/google.cjs +1 -1
  23. package/dist/middleware/google.d.cts +2 -2
  24. package/dist/middleware/google.d.ts +2 -2
  25. package/dist/middleware/google.js +2 -2
  26. package/dist/middleware/langchain.cjs +159 -43
  27. package/dist/middleware/langchain.d.cts +3 -3
  28. package/dist/middleware/langchain.d.ts +3 -3
  29. package/dist/middleware/langchain.js +3 -3
  30. package/dist/middleware/vercel-ai.cjs +2 -2
  31. package/dist/middleware/vercel-ai.d.cts +3 -3
  32. package/dist/middleware/vercel-ai.d.ts +3 -3
  33. package/dist/middleware/vercel-ai.js +3 -3
  34. package/dist/{types-BLs_TMFv.d.ts → types-BQVfxZJP.d.cts} +7 -3
  35. package/dist/{types-BLs_TMFv.d.cts → types-BQVfxZJP.d.ts} +7 -3
  36. package/package.json +3 -4
package/CHANGELOG.md CHANGED
@@ -1,14 +1,31 @@
1
1
  # Changelog
2
2
 
3
- All notable changes to SHASHU by Trustgate AI (Node.js SDK, `@shashu-ai/sdk`) are
3
+ All notable changes to SHASHU (Node.js SDK, `@shashu-ai/sdk`) are
4
4
  documented here. This project adheres to [Semantic Versioning](https://semver.org/).
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
- ## [1.1.0] — 2026-11-25
8
+ ## [1.2.0] — 2026-11-26
9
+
10
+ BREAKING: framework state keys are now `shashu_session_id` / `shashu_trace_id`.
11
+ The previous names are not read.
12
+
13
+ Provider pass-through errors are recognised by `SHASHU Provider Error:` (needs a
14
+ gateway that sends it). There is no fallback to the previous prefix.
15
+
16
+ SHASHU keys start `shashu_sk_`. Metadata, docs, and package URLs no longer
17
+ carry the previous product name.
9
18
 
10
- Apps must move to 1.1.0 to match the current gateway. `TRUSTGATE_*` environment variables are no longer read; use `SHASHU_*`. Busy replies (429/503 with Retry-After) retry by default twice; `max_retries=0` turns that off. Streams are not retried. Key prefix `tg_sk_` is unchanged.
19
+ Fixed: after a request has been sent, a dropped connection is
20
+ no longer retried automatically (avoids running the same request twice).
11
21
 
22
+ ## [1.1.1] — 2026-11-25
23
+
24
+ Fixed: when the gateway was busy and the SDK retried, the retry could be sent
25
+ without the retrieval declaration. The request (body, headers, and
26
+ `shashu_metadata`) is now built once per logical call and only re-sent.
27
+
28
+ ## [1.1.0] — 2026-11-25
12
29
 
13
30
  Wire names moved to SHASHU (requires a SHASHU gateway); key prefix `tg_sk_` unchanged.
14
31
 
@@ -19,8 +36,8 @@ The one-shot `pass_expired` retry is unchanged and does not stack with busy-retr
19
36
 
20
37
  ### Breaking
21
38
 
22
- - Environment variables are `SHASHU_API_KEY` / `SHASHU_BASE_URL` / `SHASHU_DISABLE` only. The `TRUSTGATE_*` fallbacks are removed.
23
- - Wire names are SHASHU only (`x-shashu-*`, `Shashu-Version`, `shashu_metadata`, body `shashu` / `error.shashu`). Old TrustGate names are neither sent nor read.
39
+ - Environment variables are `SHASHU_API_KEY` / `SHASHU_BASE_URL` / `SHASHU_DISABLE` only. The old environment-variable names are no longer read.
40
+ - Wire names are SHASHU only (`x-shashu-*`, `Shashu-Version`, `shashu_metadata`, body `shashu` / `error.shashu`). Old wire names are neither sent nor read.
24
41
 
25
42
  ## [1.0.0] — 2026-11-14
26
43
 
@@ -60,20 +77,20 @@ paste-once header list (key only).
60
77
  ### Changed: package name, licence, env, public names
61
78
 
62
79
  Package is `@shashu-ai/sdk`, version `1.0.0`, Apache-2.0.
63
- Environment variables are `SHASHU_*` first, then `TRUSTGATE_*` (warn once).
80
+ Environment variables are `SHASHU_*` first, then `shashu_*` (warn once).
64
81
  Public type, function and exception names are SHASHU (`Shashu`, `ShashuError`,
65
- `shashuFetch`, `createShashuLangChainConfig`, …). Wire names (`x-trustgate-*`,
66
- `trustgate_metadata`, `tg_sk_`) are unchanged.
82
+ `shashuFetch`, `createShashuLangChainConfig`, …). Wire names (`x-shashu-*`,
83
+ `shashu_metadata`, `tg_sk_`) are unchanged.
67
84
 
68
85
  ## [4.0.0] — unreleased
69
86
 
70
87
  One behaviour change, plus everything merged since `3.0.1`. Read the first
71
88
  section before upgrading.
72
89
 
73
- ### Behaviour change: `trustgate-version: 2026-09-01` is sent by default
90
+ ### Behaviour change: `shashu-version: 2026-09-01` is sent by default
74
91
 
75
- Every request this SDK makes now carries `trustgate-version: 2026-09-01`, the
76
- same value the Trustgate AI Python SDK has sent since `0.15.2`. That covers the
92
+ Every request this SDK makes now carries `shashu-version: 2026-09-01`, the
93
+ same value the shashu AI Python SDK has sent since `0.15.2`. That covers the
77
94
  `Shashu` client (`fetch` and `fetchStream`), `shashuFetch()`, and the
78
95
  headers built by the Anthropic, Gemini, LangChain and Vercel AI middleware.
79
96
 
@@ -103,12 +120,12 @@ it:
103
120
  LangChain, Anthropic, Gemini) now raises its own 400 or 403 error on a
104
121
  refusal (`BadRequestError`, `PermissionDeniedError`, …). Under `legacy` it
105
122
  returned the refusal as an ordinary 200 reply. The
106
- `trustgate-block-encoding: explicit` header `shashuFetch()` already sent
123
+ `shashu-block-encoding: explicit` header `shashuFetch()` already sent
107
124
  now takes effect, because the gateway ignores it without a version.
108
125
  - **Full memory and inspection details are in the body.** A reply carries the
109
- `trustgate` block, so `decision.memory.items` lists each memory save and
126
+ `shashu` block, so `decision.memory.items` lists each memory save and
110
127
  recall (`kind`, `state`, `reason`, `tool`, `store`, …). Before, a flagged
111
- save under Monitor was counted in `x-trustgate-memory` but not listed.
128
+ save under Monitor was counted in `x-shashu-memory` but not listed.
112
129
  `decision.memory.carrier` is now `"body"`.
113
130
  - **Unchanged by design:** under Block mode, a memory save the gateway strips
114
131
  from a reply is still a normal delivered reply, with `memoryBlocked === 1`
@@ -116,9 +133,9 @@ it:
116
133
 
117
134
  **To turn it off**, pass `contractVersion: null` to `new Shashu({...})`,
118
135
  `shashuFetch({...})` or any middleware config. The SDK then sends no
119
- `trustgate-version` header and the gateway serves the account default,
136
+ `shashu-version` header and the gateway serves the account default,
120
137
  `legacy` unless an operator changed it. Pass `contractVersion: "<date>"` to pin
121
- another version. A `trustgate-version` entry you put in `headers` yourself
138
+ another version. A `shashu-version` entry you put in `headers` yourself
122
139
  always wins.
123
140
 
124
141
  New public names: `DEFAULT_CONTRACT_VERSION`, `CONTRACT_VERSION_HEADER`, and
@@ -139,7 +156,7 @@ memory checks can run on them.
139
156
  - `store` is required. `scope` is `agent` (default), `crew` or `tenant`.
140
157
  `source` is one of the `memory_context.v1` values (default `sdk`). Anything
141
158
  else throws `TypeError`.
142
- - A no-op under `TRUSTGATE_DISABLE`. No collectors are included: a framework's
159
+ - A no-op under `shashu_DISABLE`. No collectors are included: a framework's
143
160
  memory is not captured automatically.
144
161
 
145
162
  ### Added: reading file, memory and route-policy results (FILE-06)
@@ -149,7 +166,7 @@ route-policy block (`contracts/decision-envelope.v1.md`, contract
149
166
  `2026-10-01`). They are readable, read-only, off the decision:
150
167
 
151
168
  - **Files** — `d.attachments`, `d.filesUnverified`, `d.filesBlocked`. Body first; on a header-only (streaming) response the
152
- counts come from `x-trustgate-attachments` and `attachments.carrier` says
169
+ counts come from `x-shashu-attachments` and `attachments.carrier` says
153
170
  `"header"`. `files_unverified` is `not_inspected + scanned_partial`.
154
171
  - **Memory** — `d.memory`, `d.memoryBlocked`, `d.memoryRecallsFlagged`, `d.memoryCoverage`.
155
172
  - **Route policy** — `d.routePolicy`, and `err.routePolicy` on the refusal, so an app can
@@ -210,7 +227,7 @@ the middleware path.
210
227
 
211
228
  ### Upgrading from 1.8.0: session limits can start firing, with no change on your side
212
229
 
213
- **`new Shashu()` traffic now carries a client-sent `x-trustgate-session-id`.**
230
+ **`new Shashu()` traffic now carries a client-sent `x-shashu-session-id`.**
214
231
  Until now it carried none, and the gateway filled in a derived id for display
215
232
  only. The gateway's session-window scan and per-session scan budget act only
216
233
  on a client-sent session id. From `3.0.0` they do. An application you have not
@@ -221,7 +238,7 @@ session. A long-lived client shared across users must pass a per-request
221
238
 
222
239
  ### Added — session at origin, the gateway's decision, `isShashuBlock`
223
240
 
224
- The constructed client now sends `x-trustgate-session-id` on every request,
241
+ The constructed client now sends `x-shashu-session-id` on every request,
225
242
  including at origin. One client is one session; a captured A2A session
226
243
  overrides the construction-time default; a per-request `sessionId` is an
227
244
  instruction that wins. Without this header the gateway synthesises
@@ -230,7 +247,7 @@ first message is a static system prompt collapses into one Sessions row.
230
247
 
231
248
  `shashuDecision` / `decisionFrom` read all six outcomes (`allow`,
232
249
  `allow_altered`, `not_checked`, `block`, `refuse`, `fail`) from both
233
- carriers (`body.trustgate` and the `x-trustgate-*` headers). Absence is
250
+ carriers (`body.shashu` and the `x-shashu-*` headers). Absence is
234
251
  today's behaviour: a response with neither carrier is unchanged.
235
252
  `isShashuBlock(err)` inspects an error and answers yes or no. It
236
253
  replaces nothing and fails closed; `raiseForResponse` still fails open as
@@ -311,7 +328,7 @@ the gateway on 2026-09-07 it is one of four:
311
328
  - a §3 **reason** — `jailbreak`, `dlp`, `egress_denied`, `auth_expired`, … — on
312
329
  every path served under contract `2026-09-01`;
313
330
  - the **HTTP status as a string** — still live, and still the default: an
314
- account that sets no `TrustGate-Version` is served `legacy`, and every refusal
331
+ account that sets no `SHASHU-Version` is served `legacy`, and every refusal
315
332
  the gateway's `HTTPException` handler renders carries `str(status_code)`
316
333
  whatever the version;
317
334
  - the literal `"invalid_request"`, on a schema-invalid body on the LLM wire;
@@ -387,7 +404,7 @@ awaited.
387
404
 
388
405
  `declareRetrieval(docs, { corpus, query })` records what a retrieval returned
389
406
  wherever it happened, and the SDK attaches it to the next model call as
390
- `trustgate_metadata.rag_context`. `retrievalScope()` bounds one declaration to a
407
+ `shashu_metadata.rag_context`. `retrievalScope()` bounds one declaration to a
391
408
  block, including a `Promise.all` fan-out where each task declares before its
392
409
  first `await`. The contract
393
410
  (`contracts/rag_context.v1.schema.json`) is vendored byte-for-byte from the
@@ -455,7 +472,7 @@ adding protection is a separate change.
455
472
  > `DEFAULT_GATEWAY_URL` export that held that host is gone.
456
473
 
457
474
  Sibling of the Python SDK's `b3a92fb`, which made the same change there. The
458
- Python `trustgate/_config.py` is the reference this implementation matches,
475
+ Python `shashu/_config.py` is the reference this implementation matches,
459
476
  down to the error wording.
460
477
 
461
478
  ### Removed — the default gateway host, at all seven sites
@@ -480,7 +497,7 @@ than six copies of the same expression that had already drifted — only the
480
497
  client guarded `typeof process !== "undefined"`; the other five would throw in
481
498
  an edge runtime. Resolution is now, everywhere:
482
499
 
483
- **explicit `baseUrl` option → `TRUSTGATE_BASE_URL` → `ShashuConfigError`.**
500
+ **explicit `baseUrl` option → `shashu_BASE_URL` → `ShashuConfigError`.**
484
501
 
485
502
  A blank or whitespace-only env var counts as unset. Trailing slashes are still
486
503
  stripped.
@@ -498,12 +515,12 @@ dead code. The behaviour change above is breaking on its own, so removing the
498
515
  export costs no additional version increment.
499
516
 
500
517
  If you were importing it, replace it with your own gateway address — passed as
501
- `baseUrl` or set as `TRUSTGATE_BASE_URL`.
518
+ `baseUrl` or set as `shashu_BASE_URL`.
502
519
 
503
520
  ### Added — `ShashuConfigError`
504
521
 
505
522
  ```ts
506
- import { ShashuConfigError } from '@trustgateai/sdk';
523
+ import { ShashuConfigError } from '@shashu-ai/sdk';
507
524
  ```
508
525
 
509
526
  A `ShashuError` subclass, so existing `catch (e) { e instanceof ShashuError }`
@@ -515,9 +532,9 @@ statement that nothing was sent.
515
532
  Its message names the environment variable, the option and the entry point, and
516
533
  deliberately names **no hostname**: there is no address to suggest.
517
534
 
518
- ### Added — `TRUSTGATE_DISABLE`
535
+ ### Added — `shashu_DISABLE`
519
536
 
520
- Set `TRUSTGATE_DISABLE=1` (or `true` / `yes` / `on`, any case) to make the SDK a
537
+ Set `shashu_DISABLE=1` (or `true` / `yes` / `on`, any case) to make the SDK a
521
538
  no-op without a code change, matching the Python SDK. The four middleware
522
539
  helpers then return `{}` and throw nothing even with no address configured —
523
540
  your provider client keeps its own endpoint, its own credential and no Shashu
@@ -538,7 +555,7 @@ return types, because `{}` is what a disabled SDK returns. Code that read
538
555
 
539
556
  The tracer resolves its address **optionally**, unlike every other entry point.
540
557
  It is constructed when the module is imported (`export const tracer = new Tracer()`),
541
- so throwing there would make `import '@trustgateai/sdk'` fail for anyone who has
558
+ so throwing there would make `import '@shashu-ai/sdk'` fail for anyone who has
542
559
  not set the variable — a far worse failure than the one being fixed. Unconfigured,
543
560
  it holds no address and posts no span telemetry. Same shape as the Python SDK's
544
561
  telemetry path.
@@ -573,7 +590,7 @@ _[If you built against the old behaviour](#if-you-built-against-the-old-behaviou
573
590
  below.
574
591
 
575
592
  Error-contract corrections. Everything below was verified against
576
- `sdks/e2e/capture_error_contract.py` in the trustgate-ai repo, which drives a
593
+ `sdks/e2e/capture_error_contract.py` in the gateway repo, which drives a
577
594
  live gateway and records what it actually sends. Nothing here is asserted from
578
595
  reading gateway source. Sibling of the Python SDK 0.10.0 change.
579
596
 
@@ -639,18 +656,18 @@ exported and still extends `ShashuPermissionError`, so imports and
639
656
  nothing throws it any more. Code that checks _only_ for the budget subclass will
640
657
  now see `ShashuPolicyViolation`. Check the parent to cover both. The class
641
658
  becomes reachable again if the gateway ships a real discriminator (ticket
642
- [`TRUSTGATE-403-DISCRIMINATOR`](https://github.com/aisquad001/trustgate-ai/issues/736)).
659
+ [`the 403 discriminator ticket`](https://the gateway repository/issues/736)).
643
660
 
644
661
  ### Fixed — a 401 was documented as the gateway's own auth failure
645
662
 
646
663
  The module header mapped `401 -> type="authentication_error"`. That is backwards.
647
664
  The gateway's own agent-key failure sends `type="invalid_request_error"` with
648
- message `"Invalid TrustGate API Key"` (or `"Not authenticated"`, plus a
665
+ message `"Invalid SHASHU API Key"` (or `"Not authenticated"`, plus a
649
666
  `WWW-Authenticate: Bearer` header). Both captured.
650
667
 
651
668
  `authentication_error` is what a **provider pass-through** carries: the gateway's
652
669
  own stored provider credential was rejected upstream, and the message is prefixed
653
- `TrustGate Provider Error:`. The caller's `tg_sk_` key is fine in that case and
670
+ `SHASHU Provider Error:`. The caller's `tg_sk_` key is fine in that case and
654
671
  rotating it fixes nothing — a gateway operator has to replace the provider
655
672
  secret. The old header pointed every reader at the wrong credential. The same
656
673
  applies to 403 (`ProviderPermissionError`), 404, 429 and the 5xx family.
@@ -768,7 +785,7 @@ happens only when the gateway named a time to come back, via the newly exported
768
785
 
769
786
  **5. A 401 does not mean your API key is wrong.** The module header mapped
770
787
  `401 -> type="authentication_error"`; backwards. Your own key failing sends
771
- `type="invalid_request_error"` with `"Invalid TrustGate API Key"`.
788
+ `type="invalid_request_error"` with `"Invalid SHASHU API Key"`.
772
789
  `authentication_error` means the **gateway's stored provider credential** was
773
790
  rejected upstream — rotating your `tg_sk_` key fixes nothing, an operator has to
774
791
  replace the provider secret. Use the new
@@ -781,17 +798,17 @@ receives is unconsumed. Covered by a test.
781
798
 
782
799
  ## [1.7.2] — 2026-07-30
783
800
 
784
- Wire-parity fixes vs the Python SDK reference (`trustgate` `context.py`).
801
+ Wire-parity fixes vs the Python SDK reference (`shashu` `context.py`).
785
802
 
786
803
  ### Fixed
787
804
 
788
- - **`x-trustgate-parent-id` no longer equals `x-trustgate-span-id`.** The header
805
+ - **`x-shashu-parent-id` no longer equals `x-shashu-span-id`.** The header
789
806
  block set both to the current span's id, so every span reported itself as its
790
- own parent on the wire. `x-trustgate-parent-id` now carries the REAL parent
807
+ own parent on the wire. `x-shashu-parent-id` now carries the REAL parent
791
808
  span id via the new `tracer.parentSpanId` getter — `""` for a root span
792
809
  (Python parity).
793
810
  - **A trace id is now ALWAYS emitted at origin.** With no active span and no
794
- captured A2A flow, no `x-trustgate-trace-id` was emitted at all. Origin now
811
+ captured A2A flow, no `x-shashu-trace-id` was emitted at all. Origin now
795
812
  resolves one mirroring Python `_get_trace_id()`: `N8N_EXECUTION_ID` →
796
813
  `GITHUB_RUN_ID` → `CI_PIPELINE_ID` (when `GITLAB_CI` is set) → a fresh UUID.
797
814
  The mid-flow (`isA2aHop`) and in-span branches are unchanged.
@@ -824,19 +841,19 @@ locked ADR-007 §4.1 caller semantics.
824
841
  request, capture the inbound flow so a downstream call through the SDK PROPAGATES
825
842
  it (one lineage / one session across hops) instead of minting a fresh trace per process.
826
843
  - `captureIncoming(headers)` and the scoped `tracer.incoming(headers, fn)` read
827
- `x-trustgate-trace-id` / `-session-id` / `-hop-depth` **and `-caller-agent-id`**
844
+ `x-shashu-trace-id` / `-session-id` / `-hop-depth` **and `-caller-agent-id`**
828
845
  (the upstream invoker) into the `AsyncLocalStorage` tracer (case-insensitive;
829
846
  plain objects, `Headers`, `Map`, or pair-arrays).
830
847
  - The outbound **gateway** call propagates the captured trace (minted only at
831
- origin), and attaches `x-trustgate-session-id`, `x-trustgate-hop-depth` (inbound+1),
832
- and `x-trustgate-caller-agent-id` = **the FORWARDED inbound caller** — the upstream
848
+ origin), and attaches `x-shashu-session-id`, `x-shashu-hop-depth` (inbound+1),
849
+ and `x-shashu-caller-agent-id` = **the FORWARDED inbound caller** — the upstream
833
850
  invoker, NEVER this agent's own id (so the gateway records the real invoker→callee
834
851
  edge, not a self-edge). Origin / caller-stripped ⇒ the caller header is omitted.
835
852
  - `buildInvocationHeaders({ callerAgentId })` (and `Shashu.buildInvocationHeaders()`,
836
853
  which uses the client's cached self-id) build the lineage headers for the **invoking**
837
854
  side — the one place caller = self: the message this agent sends to a downstream agent.
838
855
  - `Shashu` gained an `agentId` option; the client caches this agent's id from each
839
- gateway response's `x-trustgate-agent-id` header (incl. 4xx) for use as the invocation caller.
856
+ gateway response's `x-shashu-agent-id` header (incl. 4xx) for use as the invocation caller.
840
857
 
841
858
  ### Notes
842
859
 
@@ -884,7 +901,7 @@ Mirrors the Python SDK v0.8.0 (typed exceptions + conservative retries).
884
901
  - **403 budget-vs-policy split is best-effort** (matches `/budget/i` in the
885
902
  message) because every soft-block 403 shares
886
903
  `{type:"invalid_request_error", code:"403"}`. Replaced once the gateway emits a
887
- stable discriminator (ticket `TRUSTGATE-403-DISCRIMINATOR`).
904
+ stable discriminator (ticket `the 403 discriminator ticket`).
888
905
  - Streaming (`fetchStream`) remains inert against the current gateway (it
889
906
  force-buffers chat responses and emits no chat SSE regardless of the `stream`
890
907
  flag or DLP settings). `fetchStream` now carries a NOTICE in its docstring and
package/NOTICE CHANGED
@@ -1,4 +1,4 @@
1
- SHASHU by Trustgate AI
1
+ SHASHU
2
2
  Copyright 2026 Trustgate AI LLC
3
3
 
4
4
  This product includes software developed by Trustgate AI LLC.
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # @shashu-ai/sdk
2
2
 
3
- Node.js client for **SHASHU by Trustgate AI**, a self-hosted AI security gateway for
3
+ Node.js client for **SHASHU**, a self-hosted AI security gateway for
4
4
  regulated industries. There is no default gateway hostname — you point the
5
5
  client at your own address, and it raises a configuration error rather than
6
6
  guessing. After the first mention, this document says **SHASHU**.
7
7
 
8
- Wire names `x-shashu-*`, `shashu_metadata`, and the `tg_sk_` key prefix
8
+ Wire names `x-shashu-*`, `shashu_metadata`, and the `shashu_sk_` key prefix
9
9
  are protocol names and are unchanged.
10
10
 
11
11
  Requires Node.js 18 or later.
@@ -34,7 +34,10 @@ Key:
34
34
 
35
35
  ```ts
36
36
  import { Shashu } from '@shashu-ai/sdk';
37
- const client = new Shashu({ baseUrl: 'https://your-shashu-gateway.example', apiKey: 'tg_sk_...' });
37
+ const client = new Shashu({
38
+ baseUrl: 'https://your-shashu-gateway.example',
39
+ apiKey: 'shashu_sk_...',
40
+ });
38
41
  ```
39
42
 
40
43
  Cloud pass (the function is yours; SHASHU never calls Entra, Google or AWS):
@@ -178,7 +181,7 @@ gateway did not send a decision — that is not `allow`. `isShashuBlock()`
178
181
  inspects; it patches nothing. An unrecognised decision fails closed (`true`).
179
182
 
180
183
  **This SDK sends `shashu-version: 2026-09-01` by default** (since 4.0.0), the
181
- same value as the Trustgate AI Python SDK. The `Shashu` client,
184
+ same value as the shashu AI Python SDK. The `Shashu` client,
182
185
  `shashuFetch()` and the middleware configs all send it. With it, the body of
183
186
  every reply carries the full `shashu` block, so `decision.memory.items` lists
184
187
  each memory save and recall and you get the inspection detail, not just header
@@ -29,20 +29,10 @@
29
29
  * does NOT consume the bus -- the next real model call still carries the
30
30
  * declaration, and a multi-gigabyte file upload does not eat it.
31
31
  *
32
- * Sibling of the Python SDK's `trustgate/_joiner.py`.
32
+ * Sibling of the Python SDK's `shashu/_joiner.py`.
33
33
  */
34
34
  /** The `fetch` shape every provider SDK's option accepts. */
35
35
  type FetchLike = (input: any, init?: any) => Promise<Response>;
36
- /**
37
- * Wrap a `fetch` so the carried declaration rides the next JSON model call.
38
- *
39
- * ```ts
40
- * const openai = new OpenAI({ baseURL, fetch: withRetrievalJoiner() });
41
- * ```
42
- *
43
- * Never throws on the SDK's behalf: any failure to understand a request means
44
- * that request goes out exactly as the caller built it.
45
- */
46
36
  declare function withRetrievalJoiner(underlying?: FetchLike): FetchLike;
47
37
 
48
38
  export { type FetchLike as F, withRetrievalJoiner as w };
@@ -29,20 +29,10 @@
29
29
  * does NOT consume the bus -- the next real model call still carries the
30
30
  * declaration, and a multi-gigabyte file upload does not eat it.
31
31
  *
32
- * Sibling of the Python SDK's `trustgate/_joiner.py`.
32
+ * Sibling of the Python SDK's `shashu/_joiner.py`.
33
33
  */
34
34
  /** The `fetch` shape every provider SDK's option accepts. */
35
35
  type FetchLike = (input: any, init?: any) => Promise<Response>;
36
- /**
37
- * Wrap a `fetch` so the carried declaration rides the next JSON model call.
38
- *
39
- * ```ts
40
- * const openai = new OpenAI({ baseURL, fetch: withRetrievalJoiner() });
41
- * ```
42
- *
43
- * Never throws on the SDK's behalf: any failure to understand a request means
44
- * that request goes out exactly as the caller built it.
45
- */
46
36
  declare function withRetrievalJoiner(underlying?: FetchLike): FetchLike;
47
37
 
48
38
  export { type FetchLike as F, withRetrievalJoiner as w };
@@ -22,7 +22,7 @@ var ShashuError = class _ShashuError extends Error {
22
22
  };
23
23
 
24
24
  // src/exceptions.ts
25
- var PROVIDER_ERROR_PREFIX = "TrustGate Provider Error:";
25
+ var PROVIDER_ERROR_PREFIX = "SHASHU Provider Error:";
26
26
  var ShashuConfigError = class _ShashuConfigError extends ShashuError {
27
27
  constructor(message) {
28
28
  super(message, 0);
@@ -492,7 +492,7 @@ function captureIncoming(headers) {
492
492
  import { randomUUID as randomUUID2 } from "crypto";
493
493
 
494
494
  // src/version.ts
495
- var SDK_VERSION = "1.1.0";
495
+ var SDK_VERSION = "1.2.0";
496
496
 
497
497
  // src/context.ts
498
498
  var HEADER_PREFIX = "x-shashu";
@@ -5,7 +5,7 @@ import {
5
5
  isDisabled,
6
6
  rejectKeyOnly,
7
7
  requireBaseUrl
8
- } from "./chunk-QJQ4MWQ4.js";
8
+ } from "./chunk-CWC6GQTL.js";
9
9
 
10
10
  // src/middleware/google.ts
11
11
  import { randomUUID } from "crypto";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  withRetrievalJoiner
3
- } from "./chunk-NTIOPTYF.js";
3
+ } from "./chunk-MZGHCDWX.js";
4
4
  import {
5
5
  CredentialResolver,
6
6
  applyContractVersion,
@@ -10,7 +10,7 @@ import {
10
10
  passRefusalCodeFromText,
11
11
  requireBaseUrl,
12
12
  shouldRetryPassRefused
13
- } from "./chunk-QJQ4MWQ4.js";
13
+ } from "./chunk-CWC6GQTL.js";
14
14
 
15
15
  // src/middleware/anthropic.ts
16
16
  import { randomUUID } from "crypto";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isDisabled
3
- } from "./chunk-QJQ4MWQ4.js";
3
+ } from "./chunk-CWC6GQTL.js";
4
4
 
5
5
  // src/_bus.ts
6
6
  import { AsyncLocalStorage } from "async_hooks";
@@ -456,8 +456,28 @@ function takeContextFor(body) {
456
456
  }
457
457
  return mutated ? body : void 0;
458
458
  }
459
+ function pinOutgoing(input, init) {
460
+ if (!hasEvents()) return { input, init };
461
+ if (isDisabled()) {
462
+ clear();
463
+ return { input, init };
464
+ }
465
+ const body = parseJsonObject(init?.body);
466
+ if (body === void 0) return { input, init };
467
+ const merged = takeContextFor(body);
468
+ if (merged === void 0) return { input, init };
469
+ const encoded = JSON.stringify(merged);
470
+ return {
471
+ input,
472
+ init: {
473
+ ...init,
474
+ body: encoded,
475
+ headers: fixContentLength(init?.headers, byteLength(encoded))
476
+ }
477
+ };
478
+ }
459
479
  function withRetrievalJoiner(underlying = globalFetch) {
460
- return async function trustgateJoiningFetch(input, init) {
480
+ return async function shashuJoiningFetch(input, init) {
461
481
  if (!hasEvents()) return underlying(input, init);
462
482
  if (isDisabled()) {
463
483
  clear();
@@ -505,5 +525,6 @@ export {
505
525
  buildRagContext,
506
526
  declareMemory,
507
527
  memoryScope,
528
+ pinOutgoing,
508
529
  withRetrievalJoiner
509
530
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  withRetrievalJoiner
3
- } from "./chunk-NTIOPTYF.js";
3
+ } from "./chunk-MZGHCDWX.js";
4
4
  import {
5
5
  CredentialResolver,
6
6
  applyContractVersion,
@@ -10,7 +10,7 @@ import {
10
10
  passRefusalCodeFromText,
11
11
  requireBaseUrl,
12
12
  shouldRetryPassRefused
13
- } from "./chunk-QJQ4MWQ4.js";
13
+ } from "./chunk-CWC6GQTL.js";
14
14
 
15
15
  // src/middleware/vercel-ai.ts
16
16
  import { randomUUID } from "crypto";