@shashu-ai/sdk 1.1.1 → 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 +56 -42
  2. package/NOTICE +1 -1
  3. package/README.md +7 -4
  4. package/dist/{_joiner-DGi8GsY7.d.cts → _joiner-D_FGAaoc.d.cts} +1 -1
  5. package/dist/{_joiner-DGi8GsY7.d.ts → _joiner-D_FGAaoc.d.ts} +1 -1
  6. package/dist/{chunk-TGD6KDWT.js → chunk-CWC6GQTL.js} +2 -2
  7. package/dist/{chunk-3JZXUKNA.js → chunk-K4ZIXS2U.js} +1 -1
  8. package/dist/{chunk-3GAMCQ6R.js → chunk-MLFWJAEH.js} +2 -2
  9. package/dist/{chunk-M7EMWSNS.js → chunk-MZGHCDWX.js} +2 -2
  10. package/dist/{chunk-3X5IUBIA.js → chunk-TI45NK2R.js} +2 -2
  11. package/dist/{chunk-F4CXDZQB.js → chunk-YSAQRZFP.js} +19 -6
  12. package/dist/index.cjs +26 -13
  13. package/dist/index.d.cts +17 -17
  14. package/dist/index.d.ts +17 -17
  15. package/dist/index.js +13 -13
  16. package/dist/{langchain-DKyrUjk4.d.cts → langchain-CoNoZ_vQ.d.cts} +4 -4
  17. package/dist/{langchain-QCATTIR4.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 +18 -5
  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.cts → types-BQVfxZJP.d.cts} +7 -3
  35. package/dist/{types-BLs_TMFv.d.ts → types-BQVfxZJP.d.ts} +7 -3
  36. package/package.json +3 -4
package/CHANGELOG.md CHANGED
@@ -1,10 +1,24 @@
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.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.
18
+
19
+ Fixed: after a request has been sent, a dropped connection is
20
+ no longer retried automatically (avoids running the same request twice).
21
+
8
22
  ## [1.1.1] — 2026-11-25
9
23
 
10
24
  Fixed: when the gateway was busy and the SDK retried, the retry could be sent
@@ -22,8 +36,8 @@ The one-shot `pass_expired` retry is unchanged and does not stack with busy-retr
22
36
 
23
37
  ### Breaking
24
38
 
25
- - Environment variables are `SHASHU_API_KEY` / `SHASHU_BASE_URL` / `SHASHU_DISABLE` only. The `TRUSTGATE_*` fallbacks are removed.
26
- - 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.
27
41
 
28
42
  ## [1.0.0] — 2026-11-14
29
43
 
@@ -63,20 +77,20 @@ paste-once header list (key only).
63
77
  ### Changed: package name, licence, env, public names
64
78
 
65
79
  Package is `@shashu-ai/sdk`, version `1.0.0`, Apache-2.0.
66
- Environment variables are `SHASHU_*` first, then `TRUSTGATE_*` (warn once).
80
+ Environment variables are `SHASHU_*` first, then `shashu_*` (warn once).
67
81
  Public type, function and exception names are SHASHU (`Shashu`, `ShashuError`,
68
- `shashuFetch`, `createShashuLangChainConfig`, …). Wire names (`x-trustgate-*`,
69
- `trustgate_metadata`, `tg_sk_`) are unchanged.
82
+ `shashuFetch`, `createShashuLangChainConfig`, …). Wire names (`x-shashu-*`,
83
+ `shashu_metadata`, `tg_sk_`) are unchanged.
70
84
 
71
85
  ## [4.0.0] — unreleased
72
86
 
73
87
  One behaviour change, plus everything merged since `3.0.1`. Read the first
74
88
  section before upgrading.
75
89
 
76
- ### Behaviour change: `trustgate-version: 2026-09-01` is sent by default
90
+ ### Behaviour change: `shashu-version: 2026-09-01` is sent by default
77
91
 
78
- Every request this SDK makes now carries `trustgate-version: 2026-09-01`, the
79
- 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
80
94
  `Shashu` client (`fetch` and `fetchStream`), `shashuFetch()`, and the
81
95
  headers built by the Anthropic, Gemini, LangChain and Vercel AI middleware.
82
96
 
@@ -106,12 +120,12 @@ it:
106
120
  LangChain, Anthropic, Gemini) now raises its own 400 or 403 error on a
107
121
  refusal (`BadRequestError`, `PermissionDeniedError`, …). Under `legacy` it
108
122
  returned the refusal as an ordinary 200 reply. The
109
- `trustgate-block-encoding: explicit` header `shashuFetch()` already sent
123
+ `shashu-block-encoding: explicit` header `shashuFetch()` already sent
110
124
  now takes effect, because the gateway ignores it without a version.
111
125
  - **Full memory and inspection details are in the body.** A reply carries the
112
- `trustgate` block, so `decision.memory.items` lists each memory save and
126
+ `shashu` block, so `decision.memory.items` lists each memory save and
113
127
  recall (`kind`, `state`, `reason`, `tool`, `store`, …). Before, a flagged
114
- 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.
115
129
  `decision.memory.carrier` is now `"body"`.
116
130
  - **Unchanged by design:** under Block mode, a memory save the gateway strips
117
131
  from a reply is still a normal delivered reply, with `memoryBlocked === 1`
@@ -119,9 +133,9 @@ it:
119
133
 
120
134
  **To turn it off**, pass `contractVersion: null` to `new Shashu({...})`,
121
135
  `shashuFetch({...})` or any middleware config. The SDK then sends no
122
- `trustgate-version` header and the gateway serves the account default,
136
+ `shashu-version` header and the gateway serves the account default,
123
137
  `legacy` unless an operator changed it. Pass `contractVersion: "<date>"` to pin
124
- another version. A `trustgate-version` entry you put in `headers` yourself
138
+ another version. A `shashu-version` entry you put in `headers` yourself
125
139
  always wins.
126
140
 
127
141
  New public names: `DEFAULT_CONTRACT_VERSION`, `CONTRACT_VERSION_HEADER`, and
@@ -142,7 +156,7 @@ memory checks can run on them.
142
156
  - `store` is required. `scope` is `agent` (default), `crew` or `tenant`.
143
157
  `source` is one of the `memory_context.v1` values (default `sdk`). Anything
144
158
  else throws `TypeError`.
145
- - 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
146
160
  memory is not captured automatically.
147
161
 
148
162
  ### Added: reading file, memory and route-policy results (FILE-06)
@@ -152,7 +166,7 @@ route-policy block (`contracts/decision-envelope.v1.md`, contract
152
166
  `2026-10-01`). They are readable, read-only, off the decision:
153
167
 
154
168
  - **Files** — `d.attachments`, `d.filesUnverified`, `d.filesBlocked`. Body first; on a header-only (streaming) response the
155
- counts come from `x-trustgate-attachments` and `attachments.carrier` says
169
+ counts come from `x-shashu-attachments` and `attachments.carrier` says
156
170
  `"header"`. `files_unverified` is `not_inspected + scanned_partial`.
157
171
  - **Memory** — `d.memory`, `d.memoryBlocked`, `d.memoryRecallsFlagged`, `d.memoryCoverage`.
158
172
  - **Route policy** — `d.routePolicy`, and `err.routePolicy` on the refusal, so an app can
@@ -213,7 +227,7 @@ the middleware path.
213
227
 
214
228
  ### Upgrading from 1.8.0: session limits can start firing, with no change on your side
215
229
 
216
- **`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`.**
217
231
  Until now it carried none, and the gateway filled in a derived id for display
218
232
  only. The gateway's session-window scan and per-session scan budget act only
219
233
  on a client-sent session id. From `3.0.0` they do. An application you have not
@@ -224,7 +238,7 @@ session. A long-lived client shared across users must pass a per-request
224
238
 
225
239
  ### Added — session at origin, the gateway's decision, `isShashuBlock`
226
240
 
227
- 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,
228
242
  including at origin. One client is one session; a captured A2A session
229
243
  overrides the construction-time default; a per-request `sessionId` is an
230
244
  instruction that wins. Without this header the gateway synthesises
@@ -233,7 +247,7 @@ first message is a static system prompt collapses into one Sessions row.
233
247
 
234
248
  `shashuDecision` / `decisionFrom` read all six outcomes (`allow`,
235
249
  `allow_altered`, `not_checked`, `block`, `refuse`, `fail`) from both
236
- carriers (`body.trustgate` and the `x-trustgate-*` headers). Absence is
250
+ carriers (`body.shashu` and the `x-shashu-*` headers). Absence is
237
251
  today's behaviour: a response with neither carrier is unchanged.
238
252
  `isShashuBlock(err)` inspects an error and answers yes or no. It
239
253
  replaces nothing and fails closed; `raiseForResponse` still fails open as
@@ -314,7 +328,7 @@ the gateway on 2026-09-07 it is one of four:
314
328
  - a §3 **reason** — `jailbreak`, `dlp`, `egress_denied`, `auth_expired`, … — on
315
329
  every path served under contract `2026-09-01`;
316
330
  - the **HTTP status as a string** — still live, and still the default: an
317
- 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
318
332
  the gateway's `HTTPException` handler renders carries `str(status_code)`
319
333
  whatever the version;
320
334
  - the literal `"invalid_request"`, on a schema-invalid body on the LLM wire;
@@ -390,7 +404,7 @@ awaited.
390
404
 
391
405
  `declareRetrieval(docs, { corpus, query })` records what a retrieval returned
392
406
  wherever it happened, and the SDK attaches it to the next model call as
393
- `trustgate_metadata.rag_context`. `retrievalScope()` bounds one declaration to a
407
+ `shashu_metadata.rag_context`. `retrievalScope()` bounds one declaration to a
394
408
  block, including a `Promise.all` fan-out where each task declares before its
395
409
  first `await`. The contract
396
410
  (`contracts/rag_context.v1.schema.json`) is vendored byte-for-byte from the
@@ -458,7 +472,7 @@ adding protection is a separate change.
458
472
  > `DEFAULT_GATEWAY_URL` export that held that host is gone.
459
473
 
460
474
  Sibling of the Python SDK's `b3a92fb`, which made the same change there. The
461
- Python `trustgate/_config.py` is the reference this implementation matches,
475
+ Python `shashu/_config.py` is the reference this implementation matches,
462
476
  down to the error wording.
463
477
 
464
478
  ### Removed — the default gateway host, at all seven sites
@@ -483,7 +497,7 @@ than six copies of the same expression that had already drifted — only the
483
497
  client guarded `typeof process !== "undefined"`; the other five would throw in
484
498
  an edge runtime. Resolution is now, everywhere:
485
499
 
486
- **explicit `baseUrl` option → `TRUSTGATE_BASE_URL` → `ShashuConfigError`.**
500
+ **explicit `baseUrl` option → `shashu_BASE_URL` → `ShashuConfigError`.**
487
501
 
488
502
  A blank or whitespace-only env var counts as unset. Trailing slashes are still
489
503
  stripped.
@@ -501,12 +515,12 @@ dead code. The behaviour change above is breaking on its own, so removing the
501
515
  export costs no additional version increment.
502
516
 
503
517
  If you were importing it, replace it with your own gateway address — passed as
504
- `baseUrl` or set as `TRUSTGATE_BASE_URL`.
518
+ `baseUrl` or set as `shashu_BASE_URL`.
505
519
 
506
520
  ### Added — `ShashuConfigError`
507
521
 
508
522
  ```ts
509
- import { ShashuConfigError } from '@trustgateai/sdk';
523
+ import { ShashuConfigError } from '@shashu-ai/sdk';
510
524
  ```
511
525
 
512
526
  A `ShashuError` subclass, so existing `catch (e) { e instanceof ShashuError }`
@@ -518,9 +532,9 @@ statement that nothing was sent.
518
532
  Its message names the environment variable, the option and the entry point, and
519
533
  deliberately names **no hostname**: there is no address to suggest.
520
534
 
521
- ### Added — `TRUSTGATE_DISABLE`
535
+ ### Added — `shashu_DISABLE`
522
536
 
523
- 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
524
538
  no-op without a code change, matching the Python SDK. The four middleware
525
539
  helpers then return `{}` and throw nothing even with no address configured —
526
540
  your provider client keeps its own endpoint, its own credential and no Shashu
@@ -541,7 +555,7 @@ return types, because `{}` is what a disabled SDK returns. Code that read
541
555
 
542
556
  The tracer resolves its address **optionally**, unlike every other entry point.
543
557
  It is constructed when the module is imported (`export const tracer = new Tracer()`),
544
- 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
545
559
  not set the variable — a far worse failure than the one being fixed. Unconfigured,
546
560
  it holds no address and posts no span telemetry. Same shape as the Python SDK's
547
561
  telemetry path.
@@ -576,7 +590,7 @@ _[If you built against the old behaviour](#if-you-built-against-the-old-behaviou
576
590
  below.
577
591
 
578
592
  Error-contract corrections. Everything below was verified against
579
- `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
580
594
  live gateway and records what it actually sends. Nothing here is asserted from
581
595
  reading gateway source. Sibling of the Python SDK 0.10.0 change.
582
596
 
@@ -642,18 +656,18 @@ exported and still extends `ShashuPermissionError`, so imports and
642
656
  nothing throws it any more. Code that checks _only_ for the budget subclass will
643
657
  now see `ShashuPolicyViolation`. Check the parent to cover both. The class
644
658
  becomes reachable again if the gateway ships a real discriminator (ticket
645
- [`TRUSTGATE-403-DISCRIMINATOR`](https://github.com/aisquad001/trustgate-ai/issues/736)).
659
+ [`the 403 discriminator ticket`](https://the gateway repository/issues/736)).
646
660
 
647
661
  ### Fixed — a 401 was documented as the gateway's own auth failure
648
662
 
649
663
  The module header mapped `401 -> type="authentication_error"`. That is backwards.
650
664
  The gateway's own agent-key failure sends `type="invalid_request_error"` with
651
- message `"Invalid TrustGate API Key"` (or `"Not authenticated"`, plus a
665
+ message `"Invalid SHASHU API Key"` (or `"Not authenticated"`, plus a
652
666
  `WWW-Authenticate: Bearer` header). Both captured.
653
667
 
654
668
  `authentication_error` is what a **provider pass-through** carries: the gateway's
655
669
  own stored provider credential was rejected upstream, and the message is prefixed
656
- `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
657
671
  rotating it fixes nothing — a gateway operator has to replace the provider
658
672
  secret. The old header pointed every reader at the wrong credential. The same
659
673
  applies to 403 (`ProviderPermissionError`), 404, 429 and the 5xx family.
@@ -771,7 +785,7 @@ happens only when the gateway named a time to come back, via the newly exported
771
785
 
772
786
  **5. A 401 does not mean your API key is wrong.** The module header mapped
773
787
  `401 -> type="authentication_error"`; backwards. Your own key failing sends
774
- `type="invalid_request_error"` with `"Invalid TrustGate API Key"`.
788
+ `type="invalid_request_error"` with `"Invalid SHASHU API Key"`.
775
789
  `authentication_error` means the **gateway's stored provider credential** was
776
790
  rejected upstream — rotating your `tg_sk_` key fixes nothing, an operator has to
777
791
  replace the provider secret. Use the new
@@ -784,17 +798,17 @@ receives is unconsumed. Covered by a test.
784
798
 
785
799
  ## [1.7.2] — 2026-07-30
786
800
 
787
- Wire-parity fixes vs the Python SDK reference (`trustgate` `context.py`).
801
+ Wire-parity fixes vs the Python SDK reference (`shashu` `context.py`).
788
802
 
789
803
  ### Fixed
790
804
 
791
- - **`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
792
806
  block set both to the current span's id, so every span reported itself as its
793
- 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
794
808
  span id via the new `tracer.parentSpanId` getter — `""` for a root span
795
809
  (Python parity).
796
810
  - **A trace id is now ALWAYS emitted at origin.** With no active span and no
797
- 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
798
812
  resolves one mirroring Python `_get_trace_id()`: `N8N_EXECUTION_ID` →
799
813
  `GITHUB_RUN_ID` → `CI_PIPELINE_ID` (when `GITLAB_CI` is set) → a fresh UUID.
800
814
  The mid-flow (`isA2aHop`) and in-span branches are unchanged.
@@ -827,19 +841,19 @@ locked ADR-007 §4.1 caller semantics.
827
841
  request, capture the inbound flow so a downstream call through the SDK PROPAGATES
828
842
  it (one lineage / one session across hops) instead of minting a fresh trace per process.
829
843
  - `captureIncoming(headers)` and the scoped `tracer.incoming(headers, fn)` read
830
- `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`**
831
845
  (the upstream invoker) into the `AsyncLocalStorage` tracer (case-insensitive;
832
846
  plain objects, `Headers`, `Map`, or pair-arrays).
833
847
  - The outbound **gateway** call propagates the captured trace (minted only at
834
- origin), and attaches `x-trustgate-session-id`, `x-trustgate-hop-depth` (inbound+1),
835
- 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
836
850
  invoker, NEVER this agent's own id (so the gateway records the real invoker→callee
837
851
  edge, not a self-edge). Origin / caller-stripped ⇒ the caller header is omitted.
838
852
  - `buildInvocationHeaders({ callerAgentId })` (and `Shashu.buildInvocationHeaders()`,
839
853
  which uses the client's cached self-id) build the lineage headers for the **invoking**
840
854
  side — the one place caller = self: the message this agent sends to a downstream agent.
841
855
  - `Shashu` gained an `agentId` option; the client caches this agent's id from each
842
- 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.
843
857
 
844
858
  ### Notes
845
859
 
@@ -887,7 +901,7 @@ Mirrors the Python SDK v0.8.0 (typed exceptions + conservative retries).
887
901
  - **403 budget-vs-policy split is best-effort** (matches `/budget/i` in the
888
902
  message) because every soft-block 403 shares
889
903
  `{type:"invalid_request_error", code:"403"}`. Replaced once the gateway emits a
890
- stable discriminator (ticket `TRUSTGATE-403-DISCRIMINATOR`).
904
+ stable discriminator (ticket `the 403 discriminator ticket`).
891
905
  - Streaming (`fetchStream`) remains inert against the current gateway (it
892
906
  force-buffers chat responses and emits no chat SSE regardless of the `stream`
893
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,7 +29,7 @@
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>;
@@ -29,7 +29,7 @@
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>;
@@ -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.1";
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-TGD6KDWT.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-M7EMWSNS.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-TGD6KDWT.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-TGD6KDWT.js";
3
+ } from "./chunk-CWC6GQTL.js";
4
4
 
5
5
  // src/_bus.ts
6
6
  import { AsyncLocalStorage } from "async_hooks";
@@ -477,7 +477,7 @@ function pinOutgoing(input, init) {
477
477
  };
478
478
  }
479
479
  function withRetrievalJoiner(underlying = globalFetch) {
480
- return async function trustgateJoiningFetch(input, init) {
480
+ return async function shashuJoiningFetch(input, init) {
481
481
  if (!hasEvents()) return underlying(input, init);
482
482
  if (isDisabled()) {
483
483
  clear();
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  withRetrievalJoiner
3
- } from "./chunk-M7EMWSNS.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-TGD6KDWT.js";
13
+ } from "./chunk-CWC6GQTL.js";
14
14
 
15
15
  // src/middleware/vercel-ai.ts
16
16
  import { randomUUID } from "crypto";
@@ -2,7 +2,7 @@ import {
2
2
  MAX_EVENTS,
3
3
  declareRetrieval,
4
4
  pinOutgoing
5
- } from "./chunk-M7EMWSNS.js";
5
+ } from "./chunk-MZGHCDWX.js";
6
6
  import {
7
7
  CredentialResolver,
8
8
  applyContractVersion,
@@ -13,7 +13,7 @@ import {
13
13
  passRefusalCodeFromText,
14
14
  requireBaseUrl,
15
15
  shouldRetryPassRefused
16
- } from "./chunk-TGD6KDWT.js";
16
+ } from "./chunk-CWC6GQTL.js";
17
17
 
18
18
  // src/middleware/langchain.ts
19
19
  import { randomUUID } from "crypto";
@@ -71,8 +71,21 @@ function delayFor(policy, attempt, res, retryAfter) {
71
71
  }
72
72
  return jitter(policy.backoffBaseSeconds * 2 ** attempt);
73
73
  }
74
- function isConnectionError(err) {
75
- return err instanceof TypeError;
74
+ var UNSENT_CODES = /* @__PURE__ */ new Set([
75
+ "ECONNREFUSED",
76
+ "ENOTFOUND",
77
+ "EAI_AGAIN",
78
+ "ENETUNREACH",
79
+ "EHOSTUNREACH",
80
+ "UND_ERR_CONNECT",
81
+ "UND_ERR_CONNECT_TIMEOUT"
82
+ ]);
83
+ function requestNeverLeft(err) {
84
+ if (!(err instanceof TypeError)) return false;
85
+ const cause = err.cause;
86
+ const code = cause?.code ?? "";
87
+ if (UNSENT_CODES.has(code)) return true;
88
+ return cause?.name === "ConnectTimeoutError" || cause?.name === "ConnectError";
76
89
  }
77
90
  var defaultSleep = (seconds) => new Promise((resolve) => setTimeout(resolve, seconds * 1e3));
78
91
  async function peekJson(res) {
@@ -90,7 +103,7 @@ async function executeWithRetry(send, policy, sleep = defaultSleep) {
90
103
  try {
91
104
  res = await send();
92
105
  } catch (err) {
93
- if (policy.retryOnConnectionErrors && isConnectionError(err) && attempt < policy.maxRetries) {
106
+ if (policy.retryOnConnectionErrors && requestNeverLeft(err) && attempt < policy.maxRetries) {
94
107
  await sleep(delayFor(policy, attempt, null, void 0));
95
108
  attempt += 1;
96
109
  continue;
@@ -186,7 +199,7 @@ var SOURCE = "langchain";
186
199
  var DEFAULT_CORPUS = "langchain-retriever";
187
200
  var MAX_TRACKED_RUNS = 64;
188
201
  var captured = /* @__PURE__ */ new Map();
189
- var QUERY = /* @__PURE__ */ Symbol.for("trustgate.langchain.query");
202
+ var QUERY = /* @__PURE__ */ Symbol.for("shashu.langchain.query");
190
203
  var enabled = false;
191
204
  var patched = false;
192
205
  var corpusName = DEFAULT_CORPUS;
package/dist/index.cjs CHANGED
@@ -130,7 +130,7 @@ var ShashuError = class _ShashuError extends Error {
130
130
  };
131
131
 
132
132
  // src/exceptions.ts
133
- var PROVIDER_ERROR_PREFIX = "TrustGate Provider Error:";
133
+ var PROVIDER_ERROR_PREFIX = "SHASHU Provider Error:";
134
134
  var ShashuConfigError = class _ShashuConfigError extends ShashuError {
135
135
  constructor(message) {
136
136
  super(message, 0);
@@ -360,7 +360,7 @@ function requireBaseUrl(baseUrl, opts) {
360
360
  var import_node_crypto2 = require("crypto");
361
361
 
362
362
  // src/version.ts
363
- var SDK_VERSION = "1.1.1";
363
+ var SDK_VERSION = "1.2.0";
364
364
 
365
365
  // src/tracer.ts
366
366
  var import_node_async_hooks = require("async_hooks");
@@ -866,8 +866,21 @@ function delayFor(policy, attempt, res, retryAfter) {
866
866
  }
867
867
  return jitter(policy.backoffBaseSeconds * 2 ** attempt);
868
868
  }
869
- function isConnectionError(err) {
870
- return err instanceof TypeError;
869
+ var UNSENT_CODES = /* @__PURE__ */ new Set([
870
+ "ECONNREFUSED",
871
+ "ENOTFOUND",
872
+ "EAI_AGAIN",
873
+ "ENETUNREACH",
874
+ "EHOSTUNREACH",
875
+ "UND_ERR_CONNECT",
876
+ "UND_ERR_CONNECT_TIMEOUT"
877
+ ]);
878
+ function requestNeverLeft(err) {
879
+ if (!(err instanceof TypeError)) return false;
880
+ const cause = err.cause;
881
+ const code = cause?.code ?? "";
882
+ if (UNSENT_CODES.has(code)) return true;
883
+ return cause?.name === "ConnectTimeoutError" || cause?.name === "ConnectError";
871
884
  }
872
885
  var defaultSleep = (seconds) => new Promise((resolve) => setTimeout(resolve, seconds * 1e3));
873
886
  async function peekJson(res) {
@@ -885,7 +898,7 @@ async function executeWithRetry(send, policy, sleep = defaultSleep) {
885
898
  try {
886
899
  res = await send();
887
900
  } catch (err) {
888
- if (policy.retryOnConnectionErrors && isConnectionError(err) && attempt < policy.maxRetries) {
901
+ if (policy.retryOnConnectionErrors && requestNeverLeft(err) && attempt < policy.maxRetries) {
889
902
  await sleep(delayFor(policy, attempt, null, void 0));
890
903
  attempt += 1;
891
904
  continue;
@@ -1377,7 +1390,7 @@ function pinOutgoing(input, init) {
1377
1390
  };
1378
1391
  }
1379
1392
  function withRetrievalJoiner(underlying = globalFetch) {
1380
- return async function trustgateJoiningFetch(input, init) {
1393
+ return async function shashuJoiningFetch(input, init) {
1381
1394
  if (!hasEvents()) return underlying(input, init);
1382
1395
  if (isDisabled()) {
1383
1396
  clear();
@@ -1667,10 +1680,10 @@ function blockSource(bodyEnv, headers) {
1667
1680
  }
1668
1681
  return headers != null ? { headers } : void 0;
1669
1682
  }
1670
- var SOURCE = /* @__PURE__ */ Symbol("trustgate.decision.blocks");
1671
- var ATTACHMENTS = /* @__PURE__ */ Symbol("trustgate.decision.attachments");
1672
- var MEMORY = /* @__PURE__ */ Symbol("trustgate.decision.memory");
1673
- var UNREAD = /* @__PURE__ */ Symbol("trustgate.decision.unread");
1683
+ var SOURCE = /* @__PURE__ */ Symbol("shashu.decision.blocks");
1684
+ var ATTACHMENTS = /* @__PURE__ */ Symbol("shashu.decision.attachments");
1685
+ var MEMORY = /* @__PURE__ */ Symbol("shashu.decision.memory");
1686
+ var UNREAD = /* @__PURE__ */ Symbol("shashu.decision.unread");
1674
1687
  var _a, _b;
1675
1688
  SOURCE, _b = ATTACHMENTS, _a = MEMORY;
1676
1689
  var DecisionRecord = class {
@@ -1943,14 +1956,14 @@ var CredentialResolver = class {
1943
1956
  };
1944
1957
 
1945
1958
  // src/client.ts
1946
- var USER_AGENT = `trustgate-node/${SDK_VERSION}`;
1959
+ var USER_AGENT = `shashu-node/${SDK_VERSION}`;
1947
1960
  var joiningFetch = withRetrievalJoiner();
1948
1961
  var streamingInertWarningEmitted = false;
1949
1962
  function warnStreamingInert() {
1950
1963
  if (streamingInertWarningEmitted) return;
1951
1964
  streamingInertWarningEmitted = true;
1952
1965
  console.warn(
1953
- "[trustgate] Streaming is not yet supported end-to-end: the gateway buffers /v1/chat/completions and returns full JSON regardless of the `stream` flag, so no incremental tokens are produced. fetchStream() will fall back to the buffered response. (warned once per process)"
1966
+ "[shashu] Streaming is not yet supported end-to-end: the gateway buffers /v1/chat/completions and returns full JSON regardless of the `stream` flag, so no incremental tokens are produced. fetchStream() will fall back to the buffered response. (warned once per process)"
1954
1967
  );
1955
1968
  }
1956
1969
  function resolveContext(config, options) {
@@ -2213,7 +2226,7 @@ function shashuFetch(options = {}) {
2213
2226
  if (options.headers) {
2214
2227
  for (const [k, v] of Object.entries(options.headers)) baked[k.toLowerCase()] = v;
2215
2228
  }
2216
- return async function trustgateFetching(input, init) {
2229
+ return async function shashuFetching(input, init) {
2217
2230
  const send = async () => {
2218
2231
  const headers = { ...baked };
2219
2232
  const extra = init?.headers;