@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/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- import { R as RequestOptions, S as ShashuConfig, W as WorkflowContext, a as ShashuError, D as Decision, M as MemoryActivity, N as N8nHeaderSnippet } from './types-BLs_TMFv.cjs';
2
- export { A as Attachment, b as AttachmentFinding, c as AttachmentState, d as Attachments, B as BODY_KEY, e as DECISIONS, f as DECISION_ALLOW, g as DECISION_ALLOW_ALTERED, h as DECISION_BLOCK, i as DECISION_FAIL, j as DECISION_NOT_CHECKED, k as DECISION_REFUSE, l as DEFAULT_RETRY_POLICY, m as DELIVERED_DECISIONS, H as HEADER_ATTACHMENTS, n as HEADER_CODE, o as HEADER_DECISION, p as HEADER_INSPECTION, q as HEADER_MEMORY, r as HEADER_REQUEST_ID, s as HEADER_SHASHU_REQUEST_ID, t as HEADER_SHOULD_RETRY, u as HEADER_TRACE_ID, v as MemoryItem, P as Provider, w as RetryPolicy, x as RoutePolicy, y as RuntimeMetadata, z as decisionFrom, C as executeWithRetry, E as isShashuBlock, F as resolveRetryPolicy, G as shashuDecision } from './types-BLs_TMFv.cjs';
3
- import { F as FetchLike } from './_joiner-DGi8GsY7.cjs';
4
- export { w as withRetrievalJoiner } from './_joiner-DGi8GsY7.cjs';
5
- export { D as DeclareRetrievalOptions, R as RagContext, a as RagDoc, b as RagSource, S as SOURCES, c as attachRagContext, d as buildRagContext, e as createShashuLangChainConfig, f as declareRetrieval, m as makeRagContext, r as retrievalScope } from './langchain-DKyrUjk4.cjs';
1
+ import { R as RequestOptions, S as ShashuConfig, W as WorkflowContext, a as ShashuError, D as Decision, M as MemoryActivity, N as N8nHeaderSnippet } from './types-BQVfxZJP.cjs';
2
+ export { A as Attachment, b as AttachmentFinding, c as AttachmentState, d as Attachments, B as BODY_KEY, e as DECISIONS, f as DECISION_ALLOW, g as DECISION_ALLOW_ALTERED, h as DECISION_BLOCK, i as DECISION_FAIL, j as DECISION_NOT_CHECKED, k as DECISION_REFUSE, l as DEFAULT_RETRY_POLICY, m as DELIVERED_DECISIONS, H as HEADER_ATTACHMENTS, n as HEADER_CODE, o as HEADER_DECISION, p as HEADER_INSPECTION, q as HEADER_MEMORY, r as HEADER_REQUEST_ID, s as HEADER_SHASHU_REQUEST_ID, t as HEADER_SHOULD_RETRY, u as HEADER_TRACE_ID, v as MemoryItem, P as Provider, w as RetryPolicy, x as RoutePolicy, y as RuntimeMetadata, z as decisionFrom, C as executeWithRetry, E as isShashuBlock, F as resolveRetryPolicy, G as shashuDecision } from './types-BQVfxZJP.cjs';
3
+ import { F as FetchLike } from './_joiner-D_FGAaoc.cjs';
4
+ export { w as withRetrievalJoiner } from './_joiner-D_FGAaoc.cjs';
5
+ export { D as DeclareRetrievalOptions, R as RagContext, a as RagDoc, b as RagSource, S as SOURCES, c as attachRagContext, d as buildRagContext, e as createShashuLangChainConfig, f as declareRetrieval, m as makeRagContext, r as retrievalScope } from './langchain-CoNoZ_vQ.cjs';
6
6
  export { ShashuOpenAIOptions, createShashuOpenAIOptions, getShashuHeaders } from './middleware/vercel-ai.cjs';
7
7
  export { createShashuAnthropicConfig, getAnthropicHeaders } from './middleware/anthropic.cjs';
8
8
  export { createShashuGeminiConfig, getGeminiHeaders } from './middleware/google.cjs';
@@ -97,7 +97,7 @@ declare class Audit {
97
97
 
98
98
  /**
99
99
  * Shashu Node.js client. All traffic is sent to the Shashu gateway with
100
- * Bearer auth (tg_sk_...). The gateway routes to OpenAI/Anthropic based on
100
+ * Bearer auth (shashu_sk_...). The gateway routes to OpenAI/Anthropic based on
101
101
  * the `model` field in the request body.
102
102
  */
103
103
  declare class Shashu {
@@ -262,7 +262,7 @@ declare const HEADER_PREFIX = "x-shashu";
262
262
  declare const SOURCE_TOOL_HEADER = "x-shashu-source-tool";
263
263
  /**
264
264
  * The contract generation this SDK speaks, declared on every request — the
265
- * same value the Python SDK sends (`trustgate.context.DEFAULT_CONTRACT_VERSION`).
265
+ * same value the Python SDK sends (`shashu.context.DEFAULT_CONTRACT_VERSION`).
266
266
  *
267
267
  * The gateway resolves an ABSENT `shashu-version` header to its legacy
268
268
  * contract: a refusal is a 200 with prose in `message.content`, the body
@@ -337,7 +337,7 @@ declare function buildInvocationHeaders(opts: InvocationHeaderOptions): Record<s
337
337
  * Shashu SDK exception hierarchy (mirrors the Python SDK).
338
338
  *
339
339
  * Every shape named below is a verbatim capture from a running gateway, taken
340
- * with `sdks/e2e/capture_error_contract.py` in the trustgate-ai repo. That
340
+ * with `sdks/e2e/capture_error_contract.py` in the gateway repo. That
341
341
  * harness is the source of truth for this module; a claim that cannot be
342
342
  * reproduced with it does not belong here. The previous version of this header
343
343
  * was derived from an investigation write-up and got three things wrong — see
@@ -373,11 +373,11 @@ declare function buildInvocationHeaders(opts: InvocationHeaderOptions): Record<s
373
373
  * not the discriminator this module once called it.
374
374
  *
375
375
  * **A 401 is not always about your key.** The gateway's own auth failure sends
376
- * `type="invalid_request_error"` with message `"Invalid TrustGate API Key"` or
376
+ * `type="invalid_request_error"` with message `"Invalid SHASHU API Key"` or
377
377
  * `"Not authenticated"` (the latter with a `WWW-Authenticate: Bearer` header).
378
378
  * A 401 carrying `type="authentication_error"` and a message prefixed
379
- * `"TrustGate Provider Error: "` is a **pass-through**: the gateway's own stored
380
- * provider credential was rejected upstream. Your `tg_sk_` key is fine and
379
+ * `"SHASHU Provider Error: "` is a **pass-through**: the gateway's own stored
380
+ * provider credential was rejected upstream. Your `shashu_sk_` key is fine and
381
381
  * rotating it changes nothing — a gateway operator has to fix the provider
382
382
  * secret. The same is true of 403 (`ProviderPermissionError`), 404, 429 and the
383
383
  * 5xx family. This module used to attribute `authentication_error` to the
@@ -400,7 +400,7 @@ declare function buildInvocationHeaders(opts: InvocationHeaderOptions): Record<s
400
400
  * still exported so existing `catch` clauses type-check, but nothing throws it —
401
401
  * every 403 is a `ShashuPolicyViolation`. Catch `ShashuPermissionError` to
402
402
  * cover both. It becomes reachable again if the gateway ships a real
403
- * discriminator (ticket TRUSTGATE-403-DISCRIMINATOR).
403
+ * discriminator (the 403 discriminator ticket).
404
404
  *
405
405
  * `ShashuError` remains the base (re-exported from "./types.js" for
406
406
  * backward compatibility), so existing `catch (e) { e instanceof ShashuError }`
@@ -440,11 +440,11 @@ declare class ShashuConfigError extends ShashuError {
440
440
  * Two different producers land here and they need opposite fixes:
441
441
  *
442
442
  * - the **gateway's own** agent-key check — missing, unknown, deactivated or
443
- * rotated `tg_sk_` key. `type="invalid_request_error"`, message
444
- * `"Invalid TrustGate API Key"` or `"Not authenticated"`. Fix: your key.
443
+ * rotated `shashu_sk_` key. `type="invalid_request_error"`, message
444
+ * `"Invalid SHASHU API Key"` or `"Not authenticated"`. Fix: your key.
445
445
  * - a **provider pass-through** — the gateway's stored provider credential was
446
446
  * rejected upstream. `type="authentication_error"`, message prefixed
447
- * `"TrustGate Provider Error: "`. Your key is fine; rotating it changes
447
+ * `"SHASHU Provider Error: "`. Your key is fine; rotating it changes
448
448
  * nothing. Fix: a gateway operator replaces the provider secret.
449
449
  *
450
450
  * {@link isProviderPassthrough} tells them apart.
@@ -492,8 +492,8 @@ declare class ShashuPermissionError extends ShashuError {
492
492
  * Kept exported so existing `catch` clauses still type-check. Catch
493
493
  * {@link ShashuPermissionError} to cover budget and policy together. This
494
494
  * class becomes reachable again if the gateway ships a real discriminator
495
- * (ticket TRUSTGATE-403-DISCRIMINATOR,
496
- * https://github.com/aisquad001/trustgate-ai/issues/736).
495
+ * (the 403 discriminator ticket,
496
+ * the gateway issue tracker (403 discriminator)).
497
497
  */
498
498
  declare class ShashuBudgetExceededError extends ShashuPermissionError {
499
499
  constructor(message: string, status: number, body?: unknown, details?: ErrorDetails);
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { R as RequestOptions, S as ShashuConfig, W as WorkflowContext, a as ShashuError, D as Decision, M as MemoryActivity, N as N8nHeaderSnippet } from './types-BLs_TMFv.js';
2
- export { A as Attachment, b as AttachmentFinding, c as AttachmentState, d as Attachments, B as BODY_KEY, e as DECISIONS, f as DECISION_ALLOW, g as DECISION_ALLOW_ALTERED, h as DECISION_BLOCK, i as DECISION_FAIL, j as DECISION_NOT_CHECKED, k as DECISION_REFUSE, l as DEFAULT_RETRY_POLICY, m as DELIVERED_DECISIONS, H as HEADER_ATTACHMENTS, n as HEADER_CODE, o as HEADER_DECISION, p as HEADER_INSPECTION, q as HEADER_MEMORY, r as HEADER_REQUEST_ID, s as HEADER_SHASHU_REQUEST_ID, t as HEADER_SHOULD_RETRY, u as HEADER_TRACE_ID, v as MemoryItem, P as Provider, w as RetryPolicy, x as RoutePolicy, y as RuntimeMetadata, z as decisionFrom, C as executeWithRetry, E as isShashuBlock, F as resolveRetryPolicy, G as shashuDecision } from './types-BLs_TMFv.js';
3
- import { F as FetchLike } from './_joiner-DGi8GsY7.js';
4
- export { w as withRetrievalJoiner } from './_joiner-DGi8GsY7.js';
5
- export { D as DeclareRetrievalOptions, R as RagContext, a as RagDoc, b as RagSource, S as SOURCES, c as attachRagContext, d as buildRagContext, e as createShashuLangChainConfig, f as declareRetrieval, m as makeRagContext, r as retrievalScope } from './langchain-QCATTIR4.js';
1
+ import { R as RequestOptions, S as ShashuConfig, W as WorkflowContext, a as ShashuError, D as Decision, M as MemoryActivity, N as N8nHeaderSnippet } from './types-BQVfxZJP.js';
2
+ export { A as Attachment, b as AttachmentFinding, c as AttachmentState, d as Attachments, B as BODY_KEY, e as DECISIONS, f as DECISION_ALLOW, g as DECISION_ALLOW_ALTERED, h as DECISION_BLOCK, i as DECISION_FAIL, j as DECISION_NOT_CHECKED, k as DECISION_REFUSE, l as DEFAULT_RETRY_POLICY, m as DELIVERED_DECISIONS, H as HEADER_ATTACHMENTS, n as HEADER_CODE, o as HEADER_DECISION, p as HEADER_INSPECTION, q as HEADER_MEMORY, r as HEADER_REQUEST_ID, s as HEADER_SHASHU_REQUEST_ID, t as HEADER_SHOULD_RETRY, u as HEADER_TRACE_ID, v as MemoryItem, P as Provider, w as RetryPolicy, x as RoutePolicy, y as RuntimeMetadata, z as decisionFrom, C as executeWithRetry, E as isShashuBlock, F as resolveRetryPolicy, G as shashuDecision } from './types-BQVfxZJP.js';
3
+ import { F as FetchLike } from './_joiner-D_FGAaoc.js';
4
+ export { w as withRetrievalJoiner } from './_joiner-D_FGAaoc.js';
5
+ export { D as DeclareRetrievalOptions, R as RagContext, a as RagDoc, b as RagSource, S as SOURCES, c as attachRagContext, d as buildRagContext, e as createShashuLangChainConfig, f as declareRetrieval, m as makeRagContext, r as retrievalScope } from './langchain-D9Xo9IMm.js';
6
6
  export { ShashuOpenAIOptions, createShashuOpenAIOptions, getShashuHeaders } from './middleware/vercel-ai.js';
7
7
  export { createShashuAnthropicConfig, getAnthropicHeaders } from './middleware/anthropic.js';
8
8
  export { createShashuGeminiConfig, getGeminiHeaders } from './middleware/google.js';
@@ -97,7 +97,7 @@ declare class Audit {
97
97
 
98
98
  /**
99
99
  * Shashu Node.js client. All traffic is sent to the Shashu gateway with
100
- * Bearer auth (tg_sk_...). The gateway routes to OpenAI/Anthropic based on
100
+ * Bearer auth (shashu_sk_...). The gateway routes to OpenAI/Anthropic based on
101
101
  * the `model` field in the request body.
102
102
  */
103
103
  declare class Shashu {
@@ -262,7 +262,7 @@ declare const HEADER_PREFIX = "x-shashu";
262
262
  declare const SOURCE_TOOL_HEADER = "x-shashu-source-tool";
263
263
  /**
264
264
  * The contract generation this SDK speaks, declared on every request — the
265
- * same value the Python SDK sends (`trustgate.context.DEFAULT_CONTRACT_VERSION`).
265
+ * same value the Python SDK sends (`shashu.context.DEFAULT_CONTRACT_VERSION`).
266
266
  *
267
267
  * The gateway resolves an ABSENT `shashu-version` header to its legacy
268
268
  * contract: a refusal is a 200 with prose in `message.content`, the body
@@ -337,7 +337,7 @@ declare function buildInvocationHeaders(opts: InvocationHeaderOptions): Record<s
337
337
  * Shashu SDK exception hierarchy (mirrors the Python SDK).
338
338
  *
339
339
  * Every shape named below is a verbatim capture from a running gateway, taken
340
- * with `sdks/e2e/capture_error_contract.py` in the trustgate-ai repo. That
340
+ * with `sdks/e2e/capture_error_contract.py` in the gateway repo. That
341
341
  * harness is the source of truth for this module; a claim that cannot be
342
342
  * reproduced with it does not belong here. The previous version of this header
343
343
  * was derived from an investigation write-up and got three things wrong — see
@@ -373,11 +373,11 @@ declare function buildInvocationHeaders(opts: InvocationHeaderOptions): Record<s
373
373
  * not the discriminator this module once called it.
374
374
  *
375
375
  * **A 401 is not always about your key.** The gateway's own auth failure sends
376
- * `type="invalid_request_error"` with message `"Invalid TrustGate API Key"` or
376
+ * `type="invalid_request_error"` with message `"Invalid SHASHU API Key"` or
377
377
  * `"Not authenticated"` (the latter with a `WWW-Authenticate: Bearer` header).
378
378
  * A 401 carrying `type="authentication_error"` and a message prefixed
379
- * `"TrustGate Provider Error: "` is a **pass-through**: the gateway's own stored
380
- * provider credential was rejected upstream. Your `tg_sk_` key is fine and
379
+ * `"SHASHU Provider Error: "` is a **pass-through**: the gateway's own stored
380
+ * provider credential was rejected upstream. Your `shashu_sk_` key is fine and
381
381
  * rotating it changes nothing — a gateway operator has to fix the provider
382
382
  * secret. The same is true of 403 (`ProviderPermissionError`), 404, 429 and the
383
383
  * 5xx family. This module used to attribute `authentication_error` to the
@@ -400,7 +400,7 @@ declare function buildInvocationHeaders(opts: InvocationHeaderOptions): Record<s
400
400
  * still exported so existing `catch` clauses type-check, but nothing throws it —
401
401
  * every 403 is a `ShashuPolicyViolation`. Catch `ShashuPermissionError` to
402
402
  * cover both. It becomes reachable again if the gateway ships a real
403
- * discriminator (ticket TRUSTGATE-403-DISCRIMINATOR).
403
+ * discriminator (the 403 discriminator ticket).
404
404
  *
405
405
  * `ShashuError` remains the base (re-exported from "./types.js" for
406
406
  * backward compatibility), so existing `catch (e) { e instanceof ShashuError }`
@@ -440,11 +440,11 @@ declare class ShashuConfigError extends ShashuError {
440
440
  * Two different producers land here and they need opposite fixes:
441
441
  *
442
442
  * - the **gateway's own** agent-key check — missing, unknown, deactivated or
443
- * rotated `tg_sk_` key. `type="invalid_request_error"`, message
444
- * `"Invalid TrustGate API Key"` or `"Not authenticated"`. Fix: your key.
443
+ * rotated `shashu_sk_` key. `type="invalid_request_error"`, message
444
+ * `"Invalid SHASHU API Key"` or `"Not authenticated"`. Fix: your key.
445
445
  * - a **provider pass-through** — the gateway's stored provider credential was
446
446
  * rejected upstream. `type="authentication_error"`, message prefixed
447
- * `"TrustGate Provider Error: "`. Your key is fine; rotating it changes
447
+ * `"SHASHU Provider Error: "`. Your key is fine; rotating it changes
448
448
  * nothing. Fix: a gateway operator replaces the provider secret.
449
449
  *
450
450
  * {@link isProviderPassthrough} tells them apart.
@@ -492,8 +492,8 @@ declare class ShashuPermissionError extends ShashuError {
492
492
  * Kept exported so existing `catch` clauses still type-check. Catch
493
493
  * {@link ShashuPermissionError} to cover budget and policy together. This
494
494
  * class becomes reachable again if the gateway ships a real discriminator
495
- * (ticket TRUSTGATE-403-DISCRIMINATOR,
496
- * https://github.com/aisquad001/trustgate-ai/issues/736).
495
+ * (the 403 discriminator ticket,
496
+ * the gateway issue tracker (403 discriminator)).
497
497
  */
498
498
  declare class ShashuBudgetExceededError extends ShashuPermissionError {
499
499
  constructor(message: string, status: number, body?: unknown, details?: ErrorDetails);
package/dist/index.js CHANGED
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  createShashuAnthropicConfig,
3
3
  getAnthropicHeaders
4
- } from "./chunk-3GAMCQ6R.js";
4
+ } from "./chunk-MLFWJAEH.js";
5
5
  import {
6
6
  createShashuGeminiConfig,
7
7
  getGeminiHeaders
8
- } from "./chunk-3JZXUKNA.js";
8
+ } from "./chunk-K4ZIXS2U.js";
9
9
  import {
10
10
  DEFAULT_RETRY_POLICY,
11
11
  createShashuLangChainConfig,
12
12
  executeWithRetry,
13
13
  resolveRetryPolicy
14
- } from "./chunk-F4CXDZQB.js";
14
+ } from "./chunk-YSAQRZFP.js";
15
15
  import {
16
16
  createShashuOpenAIOptions,
17
17
  getShashuHeaders
18
- } from "./chunk-3X5IUBIA.js";
18
+ } from "./chunk-TI45NK2R.js";
19
19
  import {
20
20
  SOURCES,
21
21
  attachRagContext,
@@ -27,7 +27,7 @@ import {
27
27
  pinOutgoing,
28
28
  retrievalScope,
29
29
  withRetrievalJoiner
30
- } from "./chunk-M7EMWSNS.js";
30
+ } from "./chunk-MZGHCDWX.js";
31
31
  import {
32
32
  API_KEY_ENV,
33
33
  BASE_URL_ENV,
@@ -72,7 +72,7 @@ import {
72
72
  requireBaseUrl,
73
73
  shouldRetryPassRefused,
74
74
  tracer
75
- } from "./chunk-TGD6KDWT.js";
75
+ } from "./chunk-CWC6GQTL.js";
76
76
 
77
77
  // src/client.ts
78
78
  import { randomUUID } from "crypto";
@@ -376,10 +376,10 @@ function blockSource(bodyEnv, headers) {
376
376
  }
377
377
  return headers != null ? { headers } : void 0;
378
378
  }
379
- var SOURCE = /* @__PURE__ */ Symbol("trustgate.decision.blocks");
380
- var ATTACHMENTS = /* @__PURE__ */ Symbol("trustgate.decision.attachments");
381
- var MEMORY = /* @__PURE__ */ Symbol("trustgate.decision.memory");
382
- var UNREAD = /* @__PURE__ */ Symbol("trustgate.decision.unread");
379
+ var SOURCE = /* @__PURE__ */ Symbol("shashu.decision.blocks");
380
+ var ATTACHMENTS = /* @__PURE__ */ Symbol("shashu.decision.attachments");
381
+ var MEMORY = /* @__PURE__ */ Symbol("shashu.decision.memory");
382
+ var UNREAD = /* @__PURE__ */ Symbol("shashu.decision.unread");
383
383
  var _a, _b;
384
384
  SOURCE, _b = ATTACHMENTS, _a = MEMORY;
385
385
  var DecisionRecord = class {
@@ -559,14 +559,14 @@ function isShashuBlock(err) {
559
559
  }
560
560
 
561
561
  // src/client.ts
562
- var USER_AGENT = `trustgate-node/${SDK_VERSION}`;
562
+ var USER_AGENT = `shashu-node/${SDK_VERSION}`;
563
563
  var joiningFetch = withRetrievalJoiner();
564
564
  var streamingInertWarningEmitted = false;
565
565
  function warnStreamingInert() {
566
566
  if (streamingInertWarningEmitted) return;
567
567
  streamingInertWarningEmitted = true;
568
568
  console.warn(
569
- "[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)"
569
+ "[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)"
570
570
  );
571
571
  }
572
572
  function resolveContext(config, options) {
@@ -829,7 +829,7 @@ function shashuFetch(options = {}) {
829
829
  if (options.headers) {
830
830
  for (const [k, v] of Object.entries(options.headers)) baked[k.toLowerCase()] = v;
831
831
  }
832
- return async function trustgateFetching(input, init) {
832
+ return async function shashuFetching(input, init) {
833
833
  const send = async () => {
834
834
  const headers = { ...baked };
835
835
  const extra = init?.headers;
@@ -1,5 +1,5 @@
1
- import { S as ShashuConfig } from './types-BLs_TMFv.cjs';
2
- import { F as FetchLike } from './_joiner-DGi8GsY7.cjs';
1
+ import { S as ShashuConfig } from './types-BQVfxZJP.cjs';
2
+ import { F as FetchLike } from './_joiner-D_FGAaoc.cjs';
3
3
 
4
4
  /** One document as `rag_context.v1` spells it. */
5
5
  interface BusDoc {
@@ -32,7 +32,7 @@ interface RetrievalEvent {
32
32
  * the LLM provider, so the upstream model never sees the control plane.
33
33
  *
34
34
  * @example
35
- * import { attachRagContext } from "@trustgateai/sdk";
35
+ * import { attachRagContext } from "@shashu-ai/sdk";
36
36
  * const body = { model: "gpt-4o-mini", messages: [...] };
37
37
  * attachRagContext(body, {
38
38
  * corpus: "policy_docs_v2",
@@ -234,7 +234,7 @@ declare function buildRagContext(events: readonly RetrievalEvent[]): RagContext
234
234
  * Returns `{}` when SHASHU_DISABLE is set: the provider client is then left
235
235
  * exactly as it was — its own endpoint, its own credential, no Shashu context
236
236
  * headers — which is the same no-op the Python SDK's patchers perform. The
237
- * caller's tg_sk_ key is deliberately NOT handed back, since it would be sent to
237
+ * caller's shashu_sk_ key is deliberately NOT handed back, since it would be sent to
238
238
  * the provider directly.
239
239
  *
240
240
  * @throws {ShashuConfigError} when no address is configured and the SDK is
@@ -1,5 +1,5 @@
1
- import { S as ShashuConfig } from './types-BLs_TMFv.js';
2
- import { F as FetchLike } from './_joiner-DGi8GsY7.js';
1
+ import { S as ShashuConfig } from './types-BQVfxZJP.js';
2
+ import { F as FetchLike } from './_joiner-D_FGAaoc.js';
3
3
 
4
4
  /** One document as `rag_context.v1` spells it. */
5
5
  interface BusDoc {
@@ -32,7 +32,7 @@ interface RetrievalEvent {
32
32
  * the LLM provider, so the upstream model never sees the control plane.
33
33
  *
34
34
  * @example
35
- * import { attachRagContext } from "@trustgateai/sdk";
35
+ * import { attachRagContext } from "@shashu-ai/sdk";
36
36
  * const body = { model: "gpt-4o-mini", messages: [...] };
37
37
  * attachRagContext(body, {
38
38
  * corpus: "policy_docs_v2",
@@ -234,7 +234,7 @@ declare function buildRagContext(events: readonly RetrievalEvent[]): RagContext
234
234
  * Returns `{}` when SHASHU_DISABLE is set: the provider client is then left
235
235
  * exactly as it was — its own endpoint, its own credential, no Shashu context
236
236
  * headers — which is the same no-op the Python SDK's patchers perform. The
237
- * caller's tg_sk_ key is deliberately NOT handed back, since it would be sent to
237
+ * caller's shashu_sk_ key is deliberately NOT handed back, since it would be sent to
238
238
  * the provider directly.
239
239
  *
240
240
  * @throws {ShashuConfigError} when no address is configured and the SDK is
@@ -99,7 +99,7 @@ function requireBaseUrl(baseUrl, opts) {
99
99
  var import_node_crypto2 = require("crypto");
100
100
 
101
101
  // src/version.ts
102
- var SDK_VERSION = "1.1.1";
102
+ var SDK_VERSION = "1.2.0";
103
103
 
104
104
  // src/tracer.ts
105
105
  var import_node_async_hooks = require("async_hooks");
@@ -744,7 +744,7 @@ function takeContextFor(body) {
744
744
  return mutated ? body : void 0;
745
745
  }
746
746
  function withRetrievalJoiner(underlying = globalFetch) {
747
- return async function trustgateJoiningFetch(input, init) {
747
+ return async function shashuJoiningFetch(input, init) {
748
748
  if (!hasEvents()) return underlying(input, init);
749
749
  if (isDisabled()) {
750
750
  clear();
@@ -1,5 +1,5 @@
1
- import { S as ShashuConfig } from '../types-BLs_TMFv.cjs';
2
- import { F as FetchLike } from '../_joiner-DGi8GsY7.cjs';
1
+ import { S as ShashuConfig } from '../types-BQVfxZJP.cjs';
2
+ import { F as FetchLike } from '../_joiner-D_FGAaoc.cjs';
3
3
 
4
4
  /**
5
5
  * Anthropic middleware: use Shashu as the base URL for @anthropic-ai/sdk.
@@ -33,7 +33,7 @@ declare function getAnthropicHeaders(config: ShashuConfig): Record<string, strin
33
33
  * Returns `{}` when SHASHU_DISABLE is set: the provider client is then left
34
34
  * exactly as it was — its own endpoint, its own credential, no Shashu context
35
35
  * headers — which is the same no-op the Python SDK's patchers perform. The
36
- * caller's tg_sk_ key is deliberately NOT handed back, since it would be sent to
36
+ * caller's shashu_sk_ key is deliberately NOT handed back, since it would be sent to
37
37
  * the provider directly.
38
38
  *
39
39
  * @throws {ShashuConfigError} when no address is configured and the SDK is
@@ -1,5 +1,5 @@
1
- import { S as ShashuConfig } from '../types-BLs_TMFv.js';
2
- import { F as FetchLike } from '../_joiner-DGi8GsY7.js';
1
+ import { S as ShashuConfig } from '../types-BQVfxZJP.js';
2
+ import { F as FetchLike } from '../_joiner-D_FGAaoc.js';
3
3
 
4
4
  /**
5
5
  * Anthropic middleware: use Shashu as the base URL for @anthropic-ai/sdk.
@@ -33,7 +33,7 @@ declare function getAnthropicHeaders(config: ShashuConfig): Record<string, strin
33
33
  * Returns `{}` when SHASHU_DISABLE is set: the provider client is then left
34
34
  * exactly as it was — its own endpoint, its own credential, no Shashu context
35
35
  * headers — which is the same no-op the Python SDK's patchers perform. The
36
- * caller's tg_sk_ key is deliberately NOT handed back, since it would be sent to
36
+ * caller's shashu_sk_ key is deliberately NOT handed back, since it would be sent to
37
37
  * the provider directly.
38
38
  *
39
39
  * @throws {ShashuConfigError} when no address is configured and the SDK is
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  createShashuAnthropicConfig,
3
3
  getAnthropicHeaders
4
- } from "../chunk-3GAMCQ6R.js";
5
- import "../chunk-M7EMWSNS.js";
6
- import "../chunk-TGD6KDWT.js";
4
+ } from "../chunk-MLFWJAEH.js";
5
+ import "../chunk-MZGHCDWX.js";
6
+ import "../chunk-CWC6GQTL.js";
7
7
  export {
8
8
  createShashuAnthropicConfig,
9
9
  getAnthropicHeaders
@@ -107,7 +107,7 @@ function rejectKeyOnly(name, tokenProvider) {
107
107
  var import_node_crypto2 = require("crypto");
108
108
 
109
109
  // src/version.ts
110
- var SDK_VERSION = "1.1.1";
110
+ var SDK_VERSION = "1.2.0";
111
111
 
112
112
  // src/tracer.ts
113
113
  var import_node_async_hooks = require("async_hooks");
@@ -1,4 +1,4 @@
1
- import { S as ShashuConfig } from '../types-BLs_TMFv.cjs';
1
+ import { S as ShashuConfig } from '../types-BQVfxZJP.cjs';
2
2
 
3
3
  /**
4
4
  * Google Gemini middleware: use Shashu with @google/generative-ai.
@@ -39,7 +39,7 @@ declare function getGeminiHeaders(config: ShashuConfig): Record<string, string>;
39
39
  * Returns `{}` when SHASHU_DISABLE is set: the provider client is then left
40
40
  * exactly as it was — its own endpoint, its own credential, no Shashu context
41
41
  * headers — which is the same no-op the Python SDK's patchers perform. The
42
- * caller's tg_sk_ key is deliberately NOT handed back, since it would be sent to
42
+ * caller's shashu_sk_ key is deliberately NOT handed back, since it would be sent to
43
43
  * the provider directly.
44
44
  *
45
45
  * @throws {ShashuConfigError} when no address is configured and the SDK is
@@ -1,4 +1,4 @@
1
- import { S as ShashuConfig } from '../types-BLs_TMFv.js';
1
+ import { S as ShashuConfig } from '../types-BQVfxZJP.js';
2
2
 
3
3
  /**
4
4
  * Google Gemini middleware: use Shashu with @google/generative-ai.
@@ -39,7 +39,7 @@ declare function getGeminiHeaders(config: ShashuConfig): Record<string, string>;
39
39
  * Returns `{}` when SHASHU_DISABLE is set: the provider client is then left
40
40
  * exactly as it was — its own endpoint, its own credential, no Shashu context
41
41
  * headers — which is the same no-op the Python SDK's patchers perform. The
42
- * caller's tg_sk_ key is deliberately NOT handed back, since it would be sent to
42
+ * caller's shashu_sk_ key is deliberately NOT handed back, since it would be sent to
43
43
  * the provider directly.
44
44
  *
45
45
  * @throws {ShashuConfigError} when no address is configured and the SDK is
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  createShashuGeminiConfig,
3
3
  getGeminiHeaders
4
- } from "../chunk-3JZXUKNA.js";
5
- import "../chunk-TGD6KDWT.js";
4
+ } from "../chunk-K4ZIXS2U.js";
5
+ import "../chunk-CWC6GQTL.js";
6
6
  export {
7
7
  createShashuGeminiConfig,
8
8
  getGeminiHeaders
@@ -138,7 +138,7 @@ function requireBaseUrl(baseUrl, opts) {
138
138
  var import_node_crypto2 = require("crypto");
139
139
 
140
140
  // src/version.ts
141
- var SDK_VERSION = "1.1.1";
141
+ var SDK_VERSION = "1.2.0";
142
142
 
143
143
  // src/tracer.ts
144
144
  var import_node_async_hooks = require("async_hooks");
@@ -986,8 +986,21 @@ function delayFor(policy, attempt, res, retryAfter) {
986
986
  }
987
987
  return jitter(policy.backoffBaseSeconds * 2 ** attempt);
988
988
  }
989
- function isConnectionError(err) {
990
- return err instanceof TypeError;
989
+ var UNSENT_CODES = /* @__PURE__ */ new Set([
990
+ "ECONNREFUSED",
991
+ "ENOTFOUND",
992
+ "EAI_AGAIN",
993
+ "ENETUNREACH",
994
+ "EHOSTUNREACH",
995
+ "UND_ERR_CONNECT",
996
+ "UND_ERR_CONNECT_TIMEOUT"
997
+ ]);
998
+ function requestNeverLeft(err) {
999
+ if (!(err instanceof TypeError)) return false;
1000
+ const cause = err.cause;
1001
+ const code = cause?.code ?? "";
1002
+ if (UNSENT_CODES.has(code)) return true;
1003
+ return cause?.name === "ConnectTimeoutError" || cause?.name === "ConnectError";
991
1004
  }
992
1005
  var defaultSleep = (seconds) => new Promise((resolve) => setTimeout(resolve, seconds * 1e3));
993
1006
  async function peekJson(res) {
@@ -1005,7 +1018,7 @@ async function executeWithRetry(send, policy, sleep = defaultSleep) {
1005
1018
  try {
1006
1019
  res = await send();
1007
1020
  } catch (err) {
1008
- if (policy.retryOnConnectionErrors && isConnectionError(err) && attempt < policy.maxRetries) {
1021
+ if (policy.retryOnConnectionErrors && requestNeverLeft(err) && attempt < policy.maxRetries) {
1009
1022
  await sleep(delayFor(policy, attempt, null, void 0));
1010
1023
  attempt += 1;
1011
1024
  continue;
@@ -1188,7 +1201,7 @@ var SOURCE = "langchain";
1188
1201
  var DEFAULT_CORPUS = "langchain-retriever";
1189
1202
  var MAX_TRACKED_RUNS = 64;
1190
1203
  var captured = /* @__PURE__ */ new Map();
1191
- var QUERY = /* @__PURE__ */ Symbol.for("trustgate.langchain.query");
1204
+ var QUERY = /* @__PURE__ */ Symbol.for("shashu.langchain.query");
1192
1205
  var enabled = false;
1193
1206
  var patched = false;
1194
1207
  var corpusName = DEFAULT_CORPUS;
@@ -1,3 +1,3 @@
1
- import '../types-BLs_TMFv.cjs';
2
- import '../_joiner-DGi8GsY7.cjs';
3
- export { g as DEFAULT_CORPUS, h as SOURCE, i as ShashuLangChainCallback, e as createShashuLangChainConfig, j as install, k as isInstalled, l as lcDocumentsToRagContext, u as uninstall } from '../langchain-DKyrUjk4.cjs';
1
+ import '../types-BQVfxZJP.cjs';
2
+ import '../_joiner-D_FGAaoc.cjs';
3
+ export { g as DEFAULT_CORPUS, h as SOURCE, i as ShashuLangChainCallback, e as createShashuLangChainConfig, j as install, k as isInstalled, l as lcDocumentsToRagContext, u as uninstall } from '../langchain-CoNoZ_vQ.cjs';
@@ -1,3 +1,3 @@
1
- import '../types-BLs_TMFv.js';
2
- import '../_joiner-DGi8GsY7.js';
3
- export { g as DEFAULT_CORPUS, h as SOURCE, i as ShashuLangChainCallback, e as createShashuLangChainConfig, j as install, k as isInstalled, l as lcDocumentsToRagContext, u as uninstall } from '../langchain-QCATTIR4.js';
1
+ import '../types-BQVfxZJP.js';
2
+ import '../_joiner-D_FGAaoc.js';
3
+ export { g as DEFAULT_CORPUS, h as SOURCE, i as ShashuLangChainCallback, e as createShashuLangChainConfig, j as install, k as isInstalled, l as lcDocumentsToRagContext, u as uninstall } from '../langchain-D9Xo9IMm.js';
@@ -7,9 +7,9 @@ import {
7
7
  isInstalled,
8
8
  lcDocumentsToRagContext,
9
9
  uninstall
10
- } from "../chunk-F4CXDZQB.js";
11
- import "../chunk-M7EMWSNS.js";
12
- import "../chunk-TGD6KDWT.js";
10
+ } from "../chunk-YSAQRZFP.js";
11
+ import "../chunk-MZGHCDWX.js";
12
+ import "../chunk-CWC6GQTL.js";
13
13
  export {
14
14
  DEFAULT_CORPUS,
15
15
  SOURCE,
@@ -99,7 +99,7 @@ function requireBaseUrl(baseUrl, opts) {
99
99
  var import_node_crypto2 = require("crypto");
100
100
 
101
101
  // src/version.ts
102
- var SDK_VERSION = "1.1.1";
102
+ var SDK_VERSION = "1.2.0";
103
103
 
104
104
  // src/tracer.ts
105
105
  var import_node_async_hooks = require("async_hooks");
@@ -744,7 +744,7 @@ function takeContextFor(body) {
744
744
  return mutated ? body : void 0;
745
745
  }
746
746
  function withRetrievalJoiner(underlying = globalFetch) {
747
- return async function trustgateJoiningFetch(input, init) {
747
+ return async function shashuJoiningFetch(input, init) {
748
748
  if (!hasEvents()) return underlying(input, init);
749
749
  if (isDisabled()) {
750
750
  clear();
@@ -1,5 +1,5 @@
1
- import { S as ShashuConfig } from '../types-BLs_TMFv.cjs';
2
- import { F as FetchLike } from '../_joiner-DGi8GsY7.cjs';
1
+ import { S as ShashuConfig } from '../types-BQVfxZJP.cjs';
2
+ import { F as FetchLike } from '../_joiner-D_FGAaoc.cjs';
3
3
 
4
4
  /**
5
5
  * Vercel AI SDK middleware: swap the provider to Shashu with one line.
@@ -54,7 +54,7 @@ declare function getShashuHeaders(workflowContext?: ShashuConfig['workflowContex
54
54
  * Returns `{}` when SHASHU_DISABLE is set: the provider client is then left
55
55
  * exactly as it was — its own endpoint, its own credential, no Shashu context
56
56
  * headers — which is the same no-op the Python SDK's patchers perform. The
57
- * caller's tg_sk_ key is deliberately NOT handed back, since it would be sent to
57
+ * caller's shashu_sk_ key is deliberately NOT handed back, since it would be sent to
58
58
  * the provider directly.
59
59
  *
60
60
  * @throws {ShashuConfigError} when no address is configured and the SDK is
@@ -1,5 +1,5 @@
1
- import { S as ShashuConfig } from '../types-BLs_TMFv.js';
2
- import { F as FetchLike } from '../_joiner-DGi8GsY7.js';
1
+ import { S as ShashuConfig } from '../types-BQVfxZJP.js';
2
+ import { F as FetchLike } from '../_joiner-D_FGAaoc.js';
3
3
 
4
4
  /**
5
5
  * Vercel AI SDK middleware: swap the provider to Shashu with one line.
@@ -54,7 +54,7 @@ declare function getShashuHeaders(workflowContext?: ShashuConfig['workflowContex
54
54
  * Returns `{}` when SHASHU_DISABLE is set: the provider client is then left
55
55
  * exactly as it was — its own endpoint, its own credential, no Shashu context
56
56
  * headers — which is the same no-op the Python SDK's patchers perform. The
57
- * caller's tg_sk_ key is deliberately NOT handed back, since it would be sent to
57
+ * caller's shashu_sk_ key is deliberately NOT handed back, since it would be sent to
58
58
  * the provider directly.
59
59
  *
60
60
  * @throws {ShashuConfigError} when no address is configured and the SDK is
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  createShashuOpenAIOptions,
3
3
  getShashuHeaders
4
- } from "../chunk-3X5IUBIA.js";
5
- import "../chunk-M7EMWSNS.js";
6
- import "../chunk-TGD6KDWT.js";
4
+ } from "../chunk-TI45NK2R.js";
5
+ import "../chunk-MZGHCDWX.js";
6
+ import "../chunk-CWC6GQTL.js";
7
7
  export {
8
8
  createShashuOpenAIOptions,
9
9
  getShashuHeaders
@@ -29,9 +29,13 @@
29
29
  * has already spent its own three attempts on it.
30
30
  *
31
31
  * By default the SDK retries:
32
- * - connection-level failures reaching the gateway (the request never landed), and
32
+ * - transport failures before any request byte is sent (ECONNREFUSED, DNS,
33
+ * connect timeout), and
33
34
  * - HTTP 429 **that carries a retry time**, honoring it.
34
35
  *
36
+ * A dropped connection after the request has left is raised, not retried —
37
+ * the gateway may already have run the call.
38
+ *
35
39
  * 401/400/403/404, a 429 with no retry time, and 200-`content_filter` are never
36
40
  * retried — they are decisions, not transient failures.
37
41
  */
@@ -42,7 +46,7 @@ interface RetryPolicy {
42
46
  backoffBaseSeconds: number;
43
47
  /** Cap on any single backoff (seconds). Default 30. */
44
48
  backoffMaxSeconds: number;
45
- /** Retry connection-level failures (fetch TypeError). Default true. */
49
+ /** Retry transport failures that happen before any request byte is sent. Default true. */
46
50
  retryOnConnectionErrors: boolean;
47
51
  /** Retry HTTP 429. Default true. */
48
52
  retryOn429: boolean;
@@ -369,7 +373,7 @@ interface ShashuConfig {
369
373
  * ShashuConfigError, never a vendor host. See ./config.ts.
370
374
  */
371
375
  baseUrl?: string;
372
- /** API key (e.g. tg_sk_...). Sent as Authorization: Bearer <apiKey>; gateway handles provider routing. */
376
+ /** API key (e.g. shashu_sk_...). Sent as Authorization: Bearer <apiKey>; gateway handles provider routing. */
373
377
  apiKey?: string;
374
378
  /**
375
379
  * Callable returning the current cloud pass (string or Promise). Mutually