@shashu-ai/sdk 1.0.0 → 1.1.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 (35) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +18 -18
  3. package/dist/{_joiner-p5LFxJcu.d.cts → _joiner-CmR7qVK8.d.cts} +1 -1
  4. package/dist/{_joiner-p5LFxJcu.d.ts → _joiner-CmR7qVK8.d.ts} +1 -1
  5. package/dist/{chunk-4CDQ7JMK.js → chunk-L6GKR3SC.js} +2 -2
  6. package/dist/{chunk-5TW3FISD.js → chunk-NTIOPTYF.js} +6 -6
  7. package/dist/{chunk-M4JDSAUC.js → chunk-QHWUNZQS.js} +2 -2
  8. package/dist/{chunk-IQYB5OZ6.js → chunk-QJQ4MWQ4.js} +33 -53
  9. package/dist/{chunk-BEU2UWW3.js → chunk-QLK5CQSP.js} +1 -1
  10. package/dist/{chunk-Z6DROYQA.js → chunk-WC3BKVXK.js} +2 -2
  11. package/dist/index.cjs +79 -77
  12. package/dist/index.d.cts +30 -30
  13. package/dist/index.d.ts +30 -30
  14. package/dist/index.js +47 -29
  15. package/dist/{langchain-DNOsiRna.d.ts → langchain-B9Q9eL7g.d.cts} +11 -11
  16. package/dist/{langchain-xCWwa1Ud.d.cts → langchain-CHjjdhDr.d.ts} +11 -11
  17. package/dist/middleware/anthropic.cjs +34 -52
  18. package/dist/middleware/anthropic.d.cts +5 -5
  19. package/dist/middleware/anthropic.d.ts +5 -5
  20. package/dist/middleware/anthropic.js +3 -3
  21. package/dist/middleware/google.cjs +28 -46
  22. package/dist/middleware/google.d.cts +5 -5
  23. package/dist/middleware/google.d.ts +5 -5
  24. package/dist/middleware/google.js +2 -2
  25. package/dist/middleware/langchain.cjs +34 -52
  26. package/dist/middleware/langchain.d.cts +3 -3
  27. package/dist/middleware/langchain.d.ts +3 -3
  28. package/dist/middleware/langchain.js +3 -3
  29. package/dist/middleware/vercel-ai.cjs +34 -52
  30. package/dist/middleware/vercel-ai.d.cts +8 -8
  31. package/dist/middleware/vercel-ai.d.ts +8 -8
  32. package/dist/middleware/vercel-ai.js +3 -3
  33. package/dist/{types-Rs49lJyD.d.ts → types-BLs_TMFv.d.cts} +18 -16
  34. package/dist/{types-Rs49lJyD.d.cts → types-BLs_TMFv.d.ts} +18 -16
  35. package/package.json +1 -1
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-Rs49lJyD.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-Rs49lJyD.js';
3
- import { F as FetchLike } from './_joiner-p5LFxJcu.js';
4
- export { w as withRetrievalJoiner } from './_joiner-p5LFxJcu.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-DNOsiRna.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-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-CmR7qVK8.js';
4
+ export { w as withRetrievalJoiner } from './_joiner-CmR7qVK8.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-CHjjdhDr.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';
@@ -35,7 +35,7 @@ export { createShashuGeminiConfig, getGeminiHeaders } from './middleware/google.
35
35
  interface AuditConversation {
36
36
  messages?: Record<string, unknown>[];
37
37
  response?: string;
38
- trustgate_metadata?: Record<string, unknown>;
38
+ shashu_metadata?: Record<string, unknown>;
39
39
  /** Free-form passthrough preserved alongside the canonical conversation. */
40
40
  extra?: Record<string, unknown>;
41
41
  }
@@ -51,7 +51,7 @@ interface AuditEventInput {
51
51
  userContext?: Record<string, unknown>;
52
52
  /**
53
53
  * Distributed trace ID linking related connector events. If absent, the
54
- * gateway falls back to the x-trustgate-trace-id header (auto-detected
54
+ * gateway falls back to the x-shashu-trace-id header (auto-detected
55
55
  * from env or tracer context); without either, the AuditLog row will only
56
56
  * have transaction_id.
57
57
  */
@@ -109,7 +109,7 @@ declare class Shashu {
109
109
  private readonly _sessionId;
110
110
  /**
111
111
  * This agent's OWN id (ADR-007 §4.1). Seeded by the `agentId` option and refreshed from
112
- * each gateway response's `x-trustgate-agent-id` header (read on EVERY response, incl.
112
+ * each gateway response's `x-shashu-agent-id` header (read on EVERY response, incl.
113
113
  * 4xx). Used by {@link buildInvocationHeaders} to stamp caller = self when invoking a
114
114
  * downstream agent — never sent as the gateway call's caller. Advisory lineage, never auth.
115
115
  */
@@ -128,7 +128,7 @@ declare class Shashu {
128
128
  */
129
129
  get sessionId(): string;
130
130
  /**
131
- * Cache this agent's own id from the gateway's `x-trustgate-agent-id` response header
131
+ * Cache this agent's own id from the gateway's `x-shashu-agent-id` response header
132
132
  * (delivered by WP-A2A-1). Used by {@link buildInvocationHeaders} to stamp caller = self
133
133
  * on a downstream invocation. Read on EVERY response — including non-2xx — so even a
134
134
  * blocked response seeds the self-id. NEVER an auth credential. Fail-soft: never throws.
@@ -140,7 +140,7 @@ declare class Shashu {
140
140
  * refreshed from gateway responses); trace / hop / session default from the tracer so the
141
141
  * served flow is propagated. The downstream agent calls `captureIncoming()` on these
142
142
  * headers. Throws if self-id is not known yet — set the `agentId` option or make one
143
- * gateway call first so the `x-trustgate-agent-id` response header can seed it.
143
+ * gateway call first so the `x-shashu-agent-id` response header can seed it.
144
144
  */
145
145
  buildInvocationHeaders(opts?: {
146
146
  traceId?: string;
@@ -207,7 +207,7 @@ declare class Shashu {
207
207
  /** How the gateway should encode a block. A default, not a hardcode. */
208
208
  declare const DEFAULT_BLOCK_ENCODING = "explicit";
209
209
  /** The header `DEFAULT_BLOCK_ENCODING` is sent under. Lowercase. */
210
- declare const BLOCK_ENCODING_HEADER = "trustgate-block-encoding";
210
+ declare const BLOCK_ENCODING_HEADER = "shashu-block-encoding";
211
211
  interface ShashuFetchOptions {
212
212
  /** Session every request this fetch makes joins. Minted once when omitted. */
213
213
  sessionId?: string;
@@ -222,12 +222,12 @@ interface ShashuFetchOptions {
222
222
  /** Callable returning the current cloud pass. Mutually exclusive with apiKey. */
223
223
  tokenProvider?: () => string | Promise<string>;
224
224
  /**
225
- * `TrustGate-Block-Encoding`. Default `explicit`. Pass `null` to send no
225
+ * `Shashu-Block-Encoding`. Default `explicit`. Pass `null` to send no
226
226
  * such header.
227
227
  */
228
228
  blockEncoding?: string | null;
229
229
  /**
230
- * `trustgate-version`. Default `DEFAULT_CONTRACT_VERSION` (`"2026-09-01"`).
230
+ * `shashu-version`. Default `DEFAULT_CONTRACT_VERSION` (`"2026-09-01"`).
231
231
  * Without it the gateway serves its legacy contract and discards the block
232
232
  * encoding above. Pass `null` to send no such header.
233
233
  */
@@ -236,7 +236,7 @@ interface ShashuFetchOptions {
236
236
  /**
237
237
  * A `fetch` to hand to a provider SDK's `fetch` option.
238
238
  *
239
- * Carries the retrieval joiner and the `x-trustgate-*` header set, so a
239
+ * Carries the retrieval joiner and the `x-shashu-*` header set, so a
240
240
  * LangChain / Vercel AI / raw-`openai` call made through it is attributed,
241
241
  * traced and able to declare its retrieval — with nothing patched.
242
242
  */
@@ -257,17 +257,17 @@ declare const PASS_CODES: readonly ["pass_provider_not_set_up", "pass_not_licens
257
257
  type PassRefusalCode = (typeof PASS_CODES)[number];
258
258
 
259
259
  /** Lowercase header prefix for proxy/gateway parity with Python SDK. */
260
- declare const HEADER_PREFIX = "x-trustgate";
260
+ declare const HEADER_PREFIX = "x-shashu";
261
261
  /** Header carrying the full context JSON (structurally identical to Python SDK). */
262
- declare const SOURCE_TOOL_HEADER = "x-trustgate-source-tool";
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
265
  * same value the Python SDK sends (`trustgate.context.DEFAULT_CONTRACT_VERSION`).
266
266
  *
267
- * The gateway resolves an ABSENT `trustgate-version` header to its legacy
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
269
269
  * carries no envelope (so memory and file items reach a caller as header
270
- * counts only), and the `trustgate-block-encoding` header `shashuFetch`
270
+ * counts only), and the `shashu-block-encoding` header `shashuFetch`
271
271
  * sends is read and discarded.
272
272
  *
273
273
  * A documented default, not a hardcode: pass `contractVersion` to pin another,
@@ -276,7 +276,7 @@ declare const SOURCE_TOOL_HEADER = "x-trustgate-source-tool";
276
276
  */
277
277
  declare const DEFAULT_CONTRACT_VERSION = "2026-09-01";
278
278
  /** The header {@link DEFAULT_CONTRACT_VERSION} is sent under. Lowercase. */
279
- declare const CONTRACT_VERSION_HEADER = "trustgate-version";
279
+ declare const CONTRACT_VERSION_HEADER = "shashu-version";
280
280
  /**
281
281
  * Searches process.env for workflow metadata from n8n, Vercel, or GitHub.
282
282
  * If no managed environment is detected, returns context with source "local_script"
@@ -285,7 +285,7 @@ declare const CONTRACT_VERSION_HEADER = "trustgate-version";
285
285
  */
286
286
  declare function getWorkflowContextFromEnv(): WorkflowContext;
287
287
  /**
288
- * JSON payload for x-trustgate-source-tool header (structurally identical to Python SDK).
288
+ * JSON payload for x-shashu-source-tool header (structurally identical to Python SDK).
289
289
  */
290
290
  declare function buildSourceToolJson(ctx: WorkflowContext): string;
291
291
  /** Prefix for runtime/metadata headers (e.g. x-trustlog-node-version). */
@@ -529,9 +529,9 @@ declare class ShashuProviderError extends ShashuError {
529
529
  * The gateway blocked the content. ONE type, both encodings.
530
530
  *
531
531
  * A security block reaches the caller in one of two shapes, and which one
532
- * depends on request headers (`trustgate-version`, `trustgate-block-encoding`)
532
+ * depends on request headers (`shashu-version`, `shashu-block-encoding`)
533
533
  * or an account default the caller may not control. Since 4.0.0 this SDK
534
- * sends `trustgate-version: 2026-09-01` by default, so the 400 is what a
534
+ * sends `shashu-version: 2026-09-01` by default, so the 400 is what a
535
535
  * caller sees unless they pass `contractVersion: null`:
536
536
  *
537
537
  * - `compatible` / legacy — **HTTP 200**, `finish_reason "content_filter"`.
@@ -607,9 +607,9 @@ interface A2ACapture {
607
607
  traceId: string;
608
608
  /** The captured inbound session id, if any. */
609
609
  sessionId?: string;
610
- /** Advisory inbound hop depth from x-trustgate-hop-depth (0 if absent). */
610
+ /** Advisory inbound hop depth from x-shashu-hop-depth (0 if absent). */
611
611
  inboundHopDepth: number;
612
- /** The upstream agent that INVOKED this hop (x-trustgate-caller-agent-id), FORWARDED
612
+ /** The upstream agent that INVOKED this hop (x-shashu-caller-agent-id), FORWARDED
613
613
  * on the outbound gateway call — never this agent's own id (§4.1). */
614
614
  inboundCallerAgentId?: string;
615
615
  }
@@ -656,12 +656,12 @@ declare class Tracer {
656
656
  get isA2aHop(): boolean;
657
657
  /** The captured inbound session id, or undefined when none was propagated. */
658
658
  get sessionId(): string | undefined;
659
- /** Advisory inbound hop depth captured from x-trustgate-hop-depth (0 if absent). */
659
+ /** Advisory inbound hop depth captured from x-shashu-hop-depth (0 if absent). */
660
660
  get inboundHopDepth(): number;
661
661
  /** Hop depth to advertise on the next downstream call = inbound + 1 (advisory; the
662
662
  * gateway recounts authoritatively). */
663
663
  get outboundHopDepth(): number;
664
- /** The captured inbound x-trustgate-caller-agent-id — the upstream agent that INVOKED
664
+ /** The captured inbound x-shashu-caller-agent-id — the upstream agent that INVOKED
665
665
  * this hop. The SDK FORWARDS this on the outbound gateway call so the gateway records
666
666
  * the real (invoker -> this agent) edge, NEVER this agent's own id (§4.1). undefined at
667
667
  * origin / caller-stripped. */
@@ -669,7 +669,7 @@ declare class Tracer {
669
669
  /**
670
670
  * Capture an inbound flow from the headers of a request this agent is SERVING into the
671
671
  * AsyncLocalStorage store, so a downstream call made through the SDK propagates the SAME
672
- * flow (WP-A2A-4 / ADR-007 §0). Reads (case-insensitively) x-trustgate-trace-id (the flow
672
+ * flow (WP-A2A-4 / ADR-007 §0). Reads (case-insensitively) x-shashu-trace-id (the flow
673
673
  * id), -session-id, -hop-depth, and -caller-agent-id (the upstream INVOKER). The captured
674
674
  * trace is PROPAGATED on the next outbound call (never re-minted); the session, inbound hop
675
675
  * depth, and inbound caller ride along — the caller is FORWARDED on the gateway call (§4.1),
@@ -718,11 +718,11 @@ declare function captureIncoming(headers: unknown): boolean;
718
718
  /**
719
719
  * Returns a pre-formatted JSON object of headers for use in n8n "HTTP Request" nodes.
720
720
  * Header keys are lowercase for gateway parity. Includes Shashu auth and workflow
721
- * context (workflow_id, execution_id, source, x-trustgate-source-tool JSON).
721
+ * context (workflow_id, execution_id, source, x-shashu-source-tool JSON).
722
722
  *
723
723
  * Resolution order: (1) arguments apiKey/baseUrl, (2) tracer.configure() values, (3) process.env.
724
- * When tracer.isActive, context headers include x-trustgate-trace-id, x-trustgate-span-id,
725
- * and x-trustgate-parent-id so the n8n workflow appears as a child of the current span.
724
+ * When tracer.isActive, context headers include x-shashu-trace-id, x-shashu-span-id,
725
+ * and x-shashu-parent-id so the n8n workflow appears as a child of the current span.
726
726
  *
727
727
  * Use in n8n:
728
728
  * 1. Add an "HTTP Request" node.
package/dist/index.js CHANGED
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  createShashuAnthropicConfig,
3
3
  getAnthropicHeaders
4
- } from "./chunk-Z6DROYQA.js";
4
+ } from "./chunk-WC3BKVXK.js";
5
5
  import {
6
6
  createShashuGeminiConfig,
7
7
  getGeminiHeaders
8
- } from "./chunk-BEU2UWW3.js";
8
+ } from "./chunk-QLK5CQSP.js";
9
9
  import {
10
10
  createShashuLangChainConfig
11
- } from "./chunk-4CDQ7JMK.js";
11
+ } from "./chunk-L6GKR3SC.js";
12
12
  import {
13
13
  createShashuOpenAIOptions,
14
14
  getShashuHeaders
15
- } from "./chunk-M4JDSAUC.js";
15
+ } from "./chunk-QHWUNZQS.js";
16
16
  import {
17
17
  SOURCES,
18
18
  attachRagContext,
@@ -23,12 +23,10 @@ import {
23
23
  memoryScope,
24
24
  retrievalScope,
25
25
  withRetrievalJoiner
26
- } from "./chunk-5TW3FISD.js";
26
+ } from "./chunk-NTIOPTYF.js";
27
27
  import {
28
28
  API_KEY_ENV,
29
- API_KEY_ENV_LEGACY,
30
29
  BASE_URL_ENV,
31
- BASE_URL_ENV_LEGACY,
32
30
  CONTRACT_VERSION_HEADER,
33
31
  CredentialResolver,
34
32
  DEFAULT_CONTRACT_VERSION,
@@ -70,7 +68,7 @@ import {
70
68
  requireBaseUrl,
71
69
  shouldRetryPassRefused,
72
70
  tracer
73
- } from "./chunk-IQYB5OZ6.js";
71
+ } from "./chunk-QJQ4MWQ4.js";
74
72
 
75
73
  // src/client.ts
76
74
  import { randomUUID } from "crypto";
@@ -131,7 +129,8 @@ var DEFAULT_RETRY_POLICY = {
131
129
  retryOn429: true,
132
130
  retryOn5xx: false,
133
131
  neverRetryStatus: [400, 401, 403, 404],
134
- ignoreRetryAfter: false
132
+ ignoreRetryAfter: false,
133
+ jitterFraction: 0.2
135
134
  };
136
135
  function resolveRetryPolicy(policy) {
137
136
  if (policy === null) return null;
@@ -141,19 +140,38 @@ function resolveRetryPolicy(policy) {
141
140
  function shouldRetryStatus(policy, status) {
142
141
  if (policy.neverRetryStatus.includes(status)) return false;
143
142
  if (status === 429) return policy.retryOn429;
143
+ if (status === 503) return true;
144
144
  if (status >= 500 && status <= 599) return policy.retryOn5xx;
145
145
  return false;
146
146
  }
147
+ function truthyHeader(value) {
148
+ return ["1", "true", "yes", "on"].includes((value ?? "").trim().toLowerCase());
149
+ }
150
+ function gatewaySaysBusyRetry(res, retryAfter) {
151
+ if (res.status !== 429 && res.status !== 503) return false;
152
+ if (truthyHeader(res.headers.get("x-should-retry"))) return true;
153
+ return retryAfter !== void 0;
154
+ }
147
155
  function shouldRetryResponse(policy, res, retryAfter) {
156
+ if (policy.neverRetryStatus.includes(res.status)) return false;
157
+ if (res.status === 429 || res.status === 503) {
158
+ if (res.status === 429 && !policy.retryOn429) return false;
159
+ return gatewaySaysBusyRetry(res, retryAfter);
160
+ }
148
161
  if (!shouldRetryStatus(policy, res.status)) return false;
149
- if (res.status === 429) return retryAfter !== void 0;
150
162
  return true;
151
163
  }
152
164
  function delayFor(policy, attempt, res, retryAfter) {
153
- if (res !== null && res.status === 429 && !policy.ignoreRetryAfter && retryAfter !== void 0) {
154
- return Math.min(policy.backoffMaxSeconds, retryAfter);
165
+ const jitter = (seconds) => {
166
+ const frac = policy.jitterFraction ?? 0.2;
167
+ const capped = Math.min(policy.backoffMaxSeconds, seconds);
168
+ if (frac <= 0) return capped;
169
+ return Math.min(policy.backoffMaxSeconds, capped * (1 + Math.random() * frac));
170
+ };
171
+ if (res !== null && (res.status === 429 || res.status === 503) && !policy.ignoreRetryAfter && retryAfter !== void 0) {
172
+ return jitter(retryAfter);
155
173
  }
156
- return Math.min(policy.backoffMaxSeconds, policy.backoffBaseSeconds * 2 ** attempt);
174
+ return jitter(policy.backoffBaseSeconds * 2 ** attempt);
157
175
  }
158
176
  function isConnectionError(err) {
159
177
  return err instanceof TypeError;
@@ -181,7 +199,7 @@ async function executeWithRetry(send, policy, sleep = defaultSleep) {
181
199
  }
182
200
  throw err;
183
201
  }
184
- const retryAfter = res.status === 429 ? gatewayRetryAfter(res, await peekJson(res)) : void 0;
202
+ const retryAfter = res.status === 429 || res.status === 503 ? gatewayRetryAfter(res, await peekJson(res)) : void 0;
185
203
  if (attempt < policy.maxRetries && shouldRetryResponse(policy, res, retryAfter)) {
186
204
  await sleep(delayFor(policy, attempt, res, retryAfter));
187
205
  attempt += 1;
@@ -211,16 +229,16 @@ var DELIVERED_DECISIONS = /* @__PURE__ */ new Set([
211
229
  DECISION_ALLOW_ALTERED,
212
230
  DECISION_NOT_CHECKED
213
231
  ]);
214
- var BODY_KEY = "trustgate";
215
- var HEADER_DECISION = "x-trustgate-decision";
216
- var HEADER_CODE = "x-trustgate-code";
217
- var HEADER_INSPECTION = "x-trustgate-inspection";
232
+ var BODY_KEY = "shashu";
233
+ var HEADER_DECISION = "x-shashu-decision";
234
+ var HEADER_CODE = "x-shashu-code";
235
+ var HEADER_INSPECTION = "x-shashu-inspection";
218
236
  var HEADER_SHOULD_RETRY = "x-should-retry";
219
237
  var HEADER_REQUEST_ID = "x-request-id";
220
- var HEADER_SHASHU_REQUEST_ID = "x-trustgate-request-id";
221
- var HEADER_TRACE_ID = "x-trustgate-trace-id";
222
- var HEADER_ATTACHMENTS = "x-trustgate-attachments";
223
- var HEADER_MEMORY = "x-trustgate-memory";
238
+ var HEADER_SHASHU_REQUEST_ID = "x-shashu-request-id";
239
+ var HEADER_TRACE_ID = "x-shashu-trace-id";
240
+ var HEADER_ATTACHMENTS = "x-shashu-attachments";
241
+ var HEADER_MEMORY = "x-shashu-memory";
224
242
  var ATTACHMENT_STATES = /* @__PURE__ */ new Set([
225
243
  "scanned",
226
244
  "scanned_partial",
@@ -689,14 +707,14 @@ var Shashu = class {
689
707
  return this._sessionId;
690
708
  }
691
709
  /**
692
- * Cache this agent's own id from the gateway's `x-trustgate-agent-id` response header
710
+ * Cache this agent's own id from the gateway's `x-shashu-agent-id` response header
693
711
  * (delivered by WP-A2A-1). Used by {@link buildInvocationHeaders} to stamp caller = self
694
712
  * on a downstream invocation. Read on EVERY response — including non-2xx — so even a
695
713
  * blocked response seeds the self-id. NEVER an auth credential. Fail-soft: never throws.
696
714
  */
697
715
  captureAgentId(res) {
698
716
  try {
699
- const aid = res.headers.get("x-trustgate-agent-id");
717
+ const aid = res.headers.get("x-shashu-agent-id");
700
718
  if (aid) this._agentId = aid;
701
719
  } catch {
702
720
  }
@@ -707,12 +725,12 @@ var Shashu = class {
707
725
  * refreshed from gateway responses); trace / hop / session default from the tracer so the
708
726
  * served flow is propagated. The downstream agent calls `captureIncoming()` on these
709
727
  * headers. Throws if self-id is not known yet — set the `agentId` option or make one
710
- * gateway call first so the `x-trustgate-agent-id` response header can seed it.
728
+ * gateway call first so the `x-shashu-agent-id` response header can seed it.
711
729
  */
712
730
  buildInvocationHeaders(opts) {
713
731
  if (!this._agentId) {
714
732
  throw new Error(
715
- "self agent id is unknown \u2014 set the agentId option or make one gateway call first so the x-trustgate-agent-id response header can seed it."
733
+ "self agent id is unknown \u2014 set the agentId option or make one gateway call first so the x-shashu-agent-id response header can seed it."
716
734
  );
717
735
  }
718
736
  return buildInvocationHeaders({ callerAgentId: this._agentId, ...opts });
@@ -875,7 +893,7 @@ var Shashu = class {
875
893
  // src/fetch.ts
876
894
  import { randomUUID as randomUUID2 } from "crypto";
877
895
  var DEFAULT_BLOCK_ENCODING = "explicit";
878
- var BLOCK_ENCODING_HEADER = "trustgate-block-encoding";
896
+ var BLOCK_ENCODING_HEADER = "shashu-block-encoding";
879
897
  function shashuFetch(options = {}) {
880
898
  const resolver = new CredentialResolver({
881
899
  apiKey: options.apiKey,
@@ -929,8 +947,8 @@ function shashuFetch(options = {}) {
929
947
 
930
948
  // src/n8n.ts
931
949
  function getN8nHeaderSnippet(apiKey, baseUrl) {
932
- const key = apiKey ?? tracer.apiKey ?? envGet(API_KEY_ENV, API_KEY_ENV_LEGACY) ?? "";
933
- const url = baseUrl ?? tracer.gatewayUrl ?? envGet(BASE_URL_ENV, BASE_URL_ENV_LEGACY) ?? "";
950
+ const key = apiKey ?? tracer.apiKey ?? envGet(API_KEY_ENV) ?? "";
951
+ const url = baseUrl ?? tracer.gatewayUrl ?? envGet(BASE_URL_ENV) ?? "";
934
952
  const ctx = getWorkflowContextFromEnv();
935
953
  const contextHeaders = buildContextHeaders(ctx);
936
954
  const headers = [];
@@ -1,5 +1,5 @@
1
- import { S as ShashuConfig } from './types-Rs49lJyD.js';
2
- import { F as FetchLike } from './_joiner-p5LFxJcu.js';
1
+ import { S as ShashuConfig } from './types-BLs_TMFv.cjs';
2
+ import { F as FetchLike } from './_joiner-CmR7qVK8.cjs';
3
3
 
4
4
  /** One document as `rag_context.v1` spells it. */
5
5
  interface BusDoc {
@@ -22,13 +22,13 @@ interface RetrievalEvent {
22
22
  * Helpers for attaching structured RAG context to a chat-completion request body.
23
23
  *
24
24
  * The Shashu gateway scans retrieved documents on a dedicated `ingress-rag`
25
- * surface when the request body carries `trustgate_metadata.rag_context`.
25
+ * surface when the request body carries `shashu_metadata.rag_context`.
26
26
  * This is materially better than letting retrieved documents be scanned as
27
27
  * plain user text — the rag scanner has access to corpus + per-doc scores +
28
28
  * per-doc previews, which dramatically reduces false-positives on legitimate
29
29
  * RAG flows.
30
30
  *
31
- * The gateway pops `trustgate_metadata` from the body before forwarding to
31
+ * The gateway pops `shashu_metadata` from the body before forwarding to
32
32
  * the LLM provider, so the upstream model never sees the control plane.
33
33
  *
34
34
  * @example
@@ -60,8 +60,8 @@ interface RagContext {
60
60
  }
61
61
  declare function makeRagContext(input: RagContext): RagContext;
62
62
  /**
63
- * Merge a rag_context dict into `body.trustgate_metadata.rag_context`
64
- * without clobbering other trustgate_metadata fields the caller may have set.
63
+ * Merge a rag_context dict into `body.shashu_metadata.rag_context`
64
+ * without clobbering other shashu_metadata fields the caller may have set.
65
65
  *
66
66
  * Returns the same body object (mutated) for chaining convenience.
67
67
  */
@@ -103,7 +103,7 @@ interface DeclareRetrievalOptions {
103
103
  * can be seen -- the alternative is a payload the gateway rejects at the far end
104
104
  * of a customer's stack.
105
105
  *
106
- * A no-op when `TRUSTGATE_DISABLE=1`.
106
+ * A no-op when `SHASHU_DISABLE=1`.
107
107
  */
108
108
  declare function declareRetrieval(docs: unknown, options: DeclareRetrievalOptions): void;
109
109
  /**
@@ -124,7 +124,7 @@ declare function declareRetrieval(docs: unknown, options: DeclareRetrievalOption
124
124
  * leak into the frame that started the task, where `enterWith` does. See
125
125
  * `_bus.ts` for the measured table.
126
126
  *
127
- * A no-op wrapper when `TRUSTGATE_DISABLE=1`: `fn` still runs, nothing is
127
+ * A no-op wrapper when `SHASHU_DISABLE=1`: `fn` still runs, nothing is
128
128
  * declared.
129
129
  */
130
130
  declare function retrievalScope<T>(docs: unknown, options: DeclareRetrievalOptions, fn: () => T | Promise<T>): Promise<T>;
@@ -209,7 +209,7 @@ declare function buildRagContext(events: readonly RetrievalEvent[]): RagContext
209
209
  * `handleLLMStart`, which run inline in the model step's own async context --
210
210
  * the same context the HTTP call is made in. Delivery calls
211
211
  * {@link declareRetrieval}, so the caps, the coercion table and
212
- * `TRUSTGATE_DISABLE` are the one implementation shared with the manual path.
212
+ * `SHASHU_DISABLE` are the one implementation shared with the manual path.
213
213
  *
214
214
  * `install()` also has to force a `CallbackManager` to exist at all:
215
215
  * `CallbackManager.configure()` returns `undefined` when a chain is invoked with
@@ -228,10 +228,10 @@ declare function buildRagContext(events: readonly RetrievalEvent[]): RagContext
228
228
  /**
229
229
  * Configuration to pass to LangChain's ChatOpenAI (or other OpenAI-based classes).
230
230
  * Sets baseURL and defaultHeaders (lowercase keys) so requests go through Shashu
231
- * with workflow context and x-trustgate-source-tool JSON for Shadow AI detection,
231
+ * with workflow context and x-shashu-source-tool JSON for Shadow AI detection,
232
232
  * and a `fetch` that attaches any declared retrieval to the outgoing body.
233
233
  *
234
- * Returns `{}` when TRUSTGATE_DISABLE is set: the provider client is then left
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
237
  * caller's tg_sk_ key is deliberately NOT handed back, since it would be sent to
@@ -1,5 +1,5 @@
1
- import { S as ShashuConfig } from './types-Rs49lJyD.cjs';
2
- import { F as FetchLike } from './_joiner-p5LFxJcu.cjs';
1
+ import { S as ShashuConfig } from './types-BLs_TMFv.js';
2
+ import { F as FetchLike } from './_joiner-CmR7qVK8.js';
3
3
 
4
4
  /** One document as `rag_context.v1` spells it. */
5
5
  interface BusDoc {
@@ -22,13 +22,13 @@ interface RetrievalEvent {
22
22
  * Helpers for attaching structured RAG context to a chat-completion request body.
23
23
  *
24
24
  * The Shashu gateway scans retrieved documents on a dedicated `ingress-rag`
25
- * surface when the request body carries `trustgate_metadata.rag_context`.
25
+ * surface when the request body carries `shashu_metadata.rag_context`.
26
26
  * This is materially better than letting retrieved documents be scanned as
27
27
  * plain user text — the rag scanner has access to corpus + per-doc scores +
28
28
  * per-doc previews, which dramatically reduces false-positives on legitimate
29
29
  * RAG flows.
30
30
  *
31
- * The gateway pops `trustgate_metadata` from the body before forwarding to
31
+ * The gateway pops `shashu_metadata` from the body before forwarding to
32
32
  * the LLM provider, so the upstream model never sees the control plane.
33
33
  *
34
34
  * @example
@@ -60,8 +60,8 @@ interface RagContext {
60
60
  }
61
61
  declare function makeRagContext(input: RagContext): RagContext;
62
62
  /**
63
- * Merge a rag_context dict into `body.trustgate_metadata.rag_context`
64
- * without clobbering other trustgate_metadata fields the caller may have set.
63
+ * Merge a rag_context dict into `body.shashu_metadata.rag_context`
64
+ * without clobbering other shashu_metadata fields the caller may have set.
65
65
  *
66
66
  * Returns the same body object (mutated) for chaining convenience.
67
67
  */
@@ -103,7 +103,7 @@ interface DeclareRetrievalOptions {
103
103
  * can be seen -- the alternative is a payload the gateway rejects at the far end
104
104
  * of a customer's stack.
105
105
  *
106
- * A no-op when `TRUSTGATE_DISABLE=1`.
106
+ * A no-op when `SHASHU_DISABLE=1`.
107
107
  */
108
108
  declare function declareRetrieval(docs: unknown, options: DeclareRetrievalOptions): void;
109
109
  /**
@@ -124,7 +124,7 @@ declare function declareRetrieval(docs: unknown, options: DeclareRetrievalOption
124
124
  * leak into the frame that started the task, where `enterWith` does. See
125
125
  * `_bus.ts` for the measured table.
126
126
  *
127
- * A no-op wrapper when `TRUSTGATE_DISABLE=1`: `fn` still runs, nothing is
127
+ * A no-op wrapper when `SHASHU_DISABLE=1`: `fn` still runs, nothing is
128
128
  * declared.
129
129
  */
130
130
  declare function retrievalScope<T>(docs: unknown, options: DeclareRetrievalOptions, fn: () => T | Promise<T>): Promise<T>;
@@ -209,7 +209,7 @@ declare function buildRagContext(events: readonly RetrievalEvent[]): RagContext
209
209
  * `handleLLMStart`, which run inline in the model step's own async context --
210
210
  * the same context the HTTP call is made in. Delivery calls
211
211
  * {@link declareRetrieval}, so the caps, the coercion table and
212
- * `TRUSTGATE_DISABLE` are the one implementation shared with the manual path.
212
+ * `SHASHU_DISABLE` are the one implementation shared with the manual path.
213
213
  *
214
214
  * `install()` also has to force a `CallbackManager` to exist at all:
215
215
  * `CallbackManager.configure()` returns `undefined` when a chain is invoked with
@@ -228,10 +228,10 @@ declare function buildRagContext(events: readonly RetrievalEvent[]): RagContext
228
228
  /**
229
229
  * Configuration to pass to LangChain's ChatOpenAI (or other OpenAI-based classes).
230
230
  * Sets baseURL and defaultHeaders (lowercase keys) so requests go through Shashu
231
- * with workflow context and x-trustgate-source-tool JSON for Shadow AI detection,
231
+ * with workflow context and x-shashu-source-tool JSON for Shadow AI detection,
232
232
  * and a `fetch` that attaches any declared retrieval to the outgoing body.
233
233
  *
234
- * Returns `{}` when TRUSTGATE_DISABLE is set: the provider client is then left
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
237
  * caller's tg_sk_ key is deliberately NOT handed back, since it would be sent to