@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
@@ -76,50 +76,32 @@ var ShashuConfigError = class _ShashuConfigError extends ShashuError {
76
76
 
77
77
  // src/config.ts
78
78
  var BASE_URL_ENV = "SHASHU_BASE_URL";
79
- var BASE_URL_ENV_LEGACY = "TRUSTGATE_BASE_URL";
80
79
  var API_KEY_ENV = "SHASHU_API_KEY";
81
- var API_KEY_ENV_LEGACY = "TRUSTGATE_API_KEY";
82
80
  var DISABLE_ENV = "SHASHU_DISABLE";
83
- var DISABLE_ENV_LEGACY = "TRUSTGATE_DISABLE";
84
- var fallbackWarned = /* @__PURE__ */ new Set();
85
81
  var TRUTHY = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
86
82
  function env() {
87
83
  return typeof process !== "undefined" && process.env ? process.env : {};
88
84
  }
89
- function envGet(current2, legacy) {
90
- const e = env();
91
- const now = (e[current2] ?? "").trim();
92
- if (now) return now;
93
- const old = (e[legacy] ?? "").trim();
94
- if (old) {
95
- if (!fallbackWarned.has(legacy)) {
96
- fallbackWarned.add(legacy);
97
- console.warn(
98
- `${legacy} is deprecated; set ${current2} instead. The TRUSTGATE_* name still works for this release.`
99
- );
100
- }
101
- return old;
102
- }
103
- return void 0;
85
+ function envGet(current2, _legacy) {
86
+ const now = (env()[current2] ?? "").trim();
87
+ return now || void 0;
104
88
  }
105
89
  function isDisabled() {
106
- return TRUTHY.has((envGet(DISABLE_ENV, DISABLE_ENV_LEGACY) ?? "").trim().toLowerCase());
90
+ return TRUTHY.has((envGet(DISABLE_ENV) ?? "").trim().toLowerCase());
107
91
  }
108
92
  function firstConfigured(baseUrl, envVars) {
109
93
  if (baseUrl && baseUrl.trim()) return baseUrl.trim().replace(/\/+$/, "");
110
94
  for (const name of envVars) {
111
- const current2 = name.startsWith("TRUSTGATE_") ? name.replace("TRUSTGATE_", "SHASHU_") : name;
112
- const legacy = name.startsWith("SHASHU_") ? name.replace("SHASHU_", "TRUSTGATE_") : name.startsWith("TRUSTGATE_") ? name : "";
113
- const value = legacy && legacy !== current2 ? envGet(current2, legacy) : env()[name]?.trim();
95
+ const value = env()[name]?.trim();
114
96
  if (value) return value.replace(/\/+$/, "");
115
97
  }
116
98
  return void 0;
117
99
  }
118
- function optionalBaseUrl(baseUrl, envVars = [BASE_URL_ENV, BASE_URL_ENV_LEGACY]) {
100
+ function optionalBaseUrl(baseUrl, envVars = [BASE_URL_ENV]) {
119
101
  return firstConfigured(baseUrl, envVars);
120
102
  }
121
103
  function requireBaseUrl(baseUrl, opts) {
122
- const envVars = opts.envVars ?? [BASE_URL_ENV, BASE_URL_ENV_LEGACY];
104
+ const envVars = opts.envVars ?? [BASE_URL_ENV];
123
105
  const resolved = firstConfigured(baseUrl, envVars);
124
106
  if (resolved) return resolved;
125
107
  const option = opts.option ?? "baseUrl";
@@ -133,7 +115,7 @@ function requireBaseUrl(baseUrl, opts) {
133
115
  var import_node_crypto2 = require("crypto");
134
116
 
135
117
  // src/version.ts
136
- var SDK_VERSION = "1.0.0";
118
+ var SDK_VERSION = "1.1.0";
137
119
 
138
120
  // src/tracer.ts
139
121
  var import_node_async_hooks = require("async_hooks");
@@ -177,14 +159,14 @@ function parseHopDepth(raw) {
177
159
  return Number.isFinite(n) && n > 0 ? n : 0;
178
160
  }
179
161
  function captureFromHeaders(h) {
180
- const trace = (h["x-trustgate-trace-id"] ?? "").trim();
162
+ const trace = (h["x-shashu-trace-id"] ?? "").trim();
181
163
  if (!trace) return void 0;
182
- const session = (h["x-trustgate-session-id"] ?? "").trim();
183
- const caller = (h["x-trustgate-caller-agent-id"] ?? "").trim();
164
+ const session = (h["x-shashu-session-id"] ?? "").trim();
165
+ const caller = (h["x-shashu-caller-agent-id"] ?? "").trim();
184
166
  return {
185
167
  traceId: trace,
186
168
  sessionId: session || void 0,
187
- inboundHopDepth: parseHopDepth(h["x-trustgate-hop-depth"]),
169
+ inboundHopDepth: parseHopDepth(h["x-shashu-hop-depth"]),
188
170
  inboundCallerAgentId: caller || void 0
189
171
  };
190
172
  }
@@ -204,7 +186,7 @@ var Tracer = class {
204
186
  this.buffer = [];
205
187
  this.flushTimer = null;
206
188
  this._gatewayUrl = optionalBaseUrl();
207
- this._apiKey = envGet(API_KEY_ENV, API_KEY_ENV_LEGACY);
189
+ this._apiKey = envGet(API_KEY_ENV);
208
190
  }
209
191
  /**
210
192
  * Current gateway base URL (respects configure()), or undefined when none is
@@ -257,7 +239,7 @@ var Tracer = class {
257
239
  get sessionId() {
258
240
  return a2aStorage.getStore()?.sessionId || void 0;
259
241
  }
260
- /** Advisory inbound hop depth captured from x-trustgate-hop-depth (0 if absent). */
242
+ /** Advisory inbound hop depth captured from x-shashu-hop-depth (0 if absent). */
261
243
  get inboundHopDepth() {
262
244
  return a2aStorage.getStore()?.inboundHopDepth ?? 0;
263
245
  }
@@ -266,7 +248,7 @@ var Tracer = class {
266
248
  get outboundHopDepth() {
267
249
  return this.inboundHopDepth + 1;
268
250
  }
269
- /** The captured inbound x-trustgate-caller-agent-id — the upstream agent that INVOKED
251
+ /** The captured inbound x-shashu-caller-agent-id — the upstream agent that INVOKED
270
252
  * this hop. The SDK FORWARDS this on the outbound gateway call so the gateway records
271
253
  * the real (invoker -> this agent) edge, NEVER this agent's own id (§4.1). undefined at
272
254
  * origin / caller-stripped. */
@@ -276,7 +258,7 @@ var Tracer = class {
276
258
  /**
277
259
  * Capture an inbound flow from the headers of a request this agent is SERVING into the
278
260
  * AsyncLocalStorage store, so a downstream call made through the SDK propagates the SAME
279
- * flow (WP-A2A-4 / ADR-007 §0). Reads (case-insensitively) x-trustgate-trace-id (the flow
261
+ * flow (WP-A2A-4 / ADR-007 §0). Reads (case-insensitively) x-shashu-trace-id (the flow
280
262
  * id), -session-id, -hop-depth, and -caller-agent-id (the upstream INVOKER). The captured
281
263
  * trace is PROPAGATED on the next outbound call (never re-minted); the session, inbound hop
282
264
  * depth, and inbound caller ride along — the caller is FORWARDED on the gateway call (§4.1),
@@ -373,10 +355,10 @@ var Tracer = class {
373
355
  var tracer = new Tracer();
374
356
 
375
357
  // src/context.ts
376
- var HEADER_PREFIX = "x-trustgate";
377
- var SOURCE_TOOL_HEADER = "x-trustgate-source-tool";
358
+ var HEADER_PREFIX = "x-shashu";
359
+ var SOURCE_TOOL_HEADER = "x-shashu-source-tool";
378
360
  var DEFAULT_CONTRACT_VERSION = "2026-09-01";
379
- var CONTRACT_VERSION_HEADER = "trustgate-version";
361
+ var CONTRACT_VERSION_HEADER = "shashu-version";
380
362
  function applyContractVersion(headers, contractVersion) {
381
363
  if (contractVersion === null) return headers;
382
364
  const named = Object.keys(headers).some((k) => k.toLowerCase() === CONTRACT_VERSION_HEADER);
@@ -495,20 +477,20 @@ function buildContextHeaders(ctx, session) {
495
477
  if (v) h[`${TRUSTLOG_HEADER_PREFIX}${k.replace(/_/g, "-")}`] = String(v);
496
478
  }
497
479
  if (tracer.isActive) {
498
- if (tracer.traceId) h["x-trustgate-trace-id"] = tracer.traceId;
499
- h["x-trustgate-span-id"] = tracer.currentSpanId ?? "";
500
- h["x-trustgate-parent-id"] = tracer.parentSpanId ?? "";
480
+ if (tracer.traceId) h["x-shashu-trace-id"] = tracer.traceId;
481
+ h["x-shashu-span-id"] = tracer.currentSpanId ?? "";
482
+ h["x-shashu-parent-id"] = tracer.parentSpanId ?? "";
501
483
  } else if (tracer.isA2aHop) {
502
- if (tracer.traceId) h["x-trustgate-trace-id"] = tracer.traceId;
503
- } else if (!h["x-trustgate-trace-id"]) {
504
- h["x-trustgate-trace-id"] = resolveOriginTraceId();
484
+ if (tracer.traceId) h["x-shashu-trace-id"] = tracer.traceId;
485
+ } else if (!h["x-shashu-trace-id"]) {
486
+ h["x-shashu-trace-id"] = resolveOriginTraceId();
505
487
  }
506
488
  const sessionId = resolveSessionId(session);
507
- if (sessionId) h["x-trustgate-session-id"] = sessionId;
489
+ if (sessionId) h["x-shashu-session-id"] = sessionId;
508
490
  if (tracer.isA2aHop) {
509
491
  const inboundCaller = tracer.inboundCallerAgentId;
510
- if (inboundCaller) h["x-trustgate-caller-agent-id"] = inboundCaller;
511
- h["x-trustgate-hop-depth"] = String(tracer.outboundHopDepth);
492
+ if (inboundCaller) h["x-shashu-caller-agent-id"] = inboundCaller;
493
+ h["x-shashu-hop-depth"] = String(tracer.outboundHopDepth);
512
494
  }
513
495
  return lowercaseHeaderKeys(h);
514
496
  }
@@ -587,10 +569,10 @@ function attachRagContext(body, ragContext) {
587
569
  if (ragContext === null || typeof ragContext !== "object") {
588
570
  throw new TypeError("ragContext must be an object");
589
571
  }
590
- const existing = body.trustgate_metadata;
572
+ const existing = body.shashu_metadata;
591
573
  const meta = existing !== null && typeof existing === "object" ? existing : {};
592
574
  meta.rag_context = ragContext;
593
- body.trustgate_metadata = meta;
575
+ body.shashu_metadata = meta;
594
576
  return body;
595
577
  }
596
578
  var SOURCES = [
@@ -817,9 +799,9 @@ function buildMemoryContext(events) {
817
799
  }
818
800
  function attachMemoryContext(body, memoryContext) {
819
801
  const bag = body;
820
- const existing = bag.trustgate_metadata;
802
+ const existing = bag.shashu_metadata;
821
803
  const metadata = existing !== null && typeof existing === "object" ? existing : {};
822
- bag.trustgate_metadata = { ...metadata, memory_context: memoryContext };
804
+ bag.shashu_metadata = { ...metadata, memory_context: memoryContext };
823
805
  return body;
824
806
  }
825
807
 
@@ -836,7 +818,7 @@ function parseJsonObject(body) {
836
818
  }
837
819
  }
838
820
  function metadataBag(body) {
839
- const metadata = body.trustgate_metadata;
821
+ const metadata = body.shashu_metadata;
840
822
  if (metadata !== null && typeof metadata === "object") {
841
823
  return metadata;
842
824
  }
@@ -992,7 +974,7 @@ function shouldRetryPassRefused(opts) {
992
974
  }
993
975
  var CredentialResolver = class {
994
976
  constructor(opts) {
995
- const envKey = envGet(API_KEY_ENV, API_KEY_ENV_LEGACY) ?? void 0;
977
+ const envKey = envGet(API_KEY_ENV) ?? void 0;
996
978
  const hasKeyArg = opts.apiKey !== void 0;
997
979
  const hasProvider = opts.tokenProvider !== void 0;
998
980
  if (hasKeyArg && hasProvider) throw new ShashuConfigError(BOTH_OR_NEITHER);
@@ -1,3 +1,3 @@
1
- import '../types-Rs49lJyD.cjs';
2
- import '../_joiner-p5LFxJcu.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-xCWwa1Ud.cjs';
1
+ import '../types-BLs_TMFv.cjs';
2
+ import '../_joiner-CmR7qVK8.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-B9Q9eL7g.cjs';
@@ -1,3 +1,3 @@
1
- import '../types-Rs49lJyD.js';
2
- import '../_joiner-p5LFxJcu.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-DNOsiRna.js';
1
+ import '../types-BLs_TMFv.js';
2
+ import '../_joiner-CmR7qVK8.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-CHjjdhDr.js';
@@ -7,9 +7,9 @@ import {
7
7
  isInstalled,
8
8
  lcDocumentsToRagContext,
9
9
  uninstall
10
- } from "../chunk-4CDQ7JMK.js";
11
- import "../chunk-5TW3FISD.js";
12
- import "../chunk-IQYB5OZ6.js";
10
+ } from "../chunk-L6GKR3SC.js";
11
+ import "../chunk-NTIOPTYF.js";
12
+ import "../chunk-QJQ4MWQ4.js";
13
13
  export {
14
14
  DEFAULT_CORPUS,
15
15
  SOURCE,
@@ -60,50 +60,32 @@ var ShashuConfigError = class _ShashuConfigError extends ShashuError {
60
60
 
61
61
  // src/config.ts
62
62
  var BASE_URL_ENV = "SHASHU_BASE_URL";
63
- var BASE_URL_ENV_LEGACY = "TRUSTGATE_BASE_URL";
64
63
  var API_KEY_ENV = "SHASHU_API_KEY";
65
- var API_KEY_ENV_LEGACY = "TRUSTGATE_API_KEY";
66
64
  var DISABLE_ENV = "SHASHU_DISABLE";
67
- var DISABLE_ENV_LEGACY = "TRUSTGATE_DISABLE";
68
- var fallbackWarned = /* @__PURE__ */ new Set();
69
65
  var TRUTHY = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
70
66
  function env() {
71
67
  return typeof process !== "undefined" && process.env ? process.env : {};
72
68
  }
73
- function envGet(current2, legacy) {
74
- const e = env();
75
- const now = (e[current2] ?? "").trim();
76
- if (now) return now;
77
- const old = (e[legacy] ?? "").trim();
78
- if (old) {
79
- if (!fallbackWarned.has(legacy)) {
80
- fallbackWarned.add(legacy);
81
- console.warn(
82
- `${legacy} is deprecated; set ${current2} instead. The TRUSTGATE_* name still works for this release.`
83
- );
84
- }
85
- return old;
86
- }
87
- return void 0;
69
+ function envGet(current2, _legacy) {
70
+ const now = (env()[current2] ?? "").trim();
71
+ return now || void 0;
88
72
  }
89
73
  function isDisabled() {
90
- return TRUTHY.has((envGet(DISABLE_ENV, DISABLE_ENV_LEGACY) ?? "").trim().toLowerCase());
74
+ return TRUTHY.has((envGet(DISABLE_ENV) ?? "").trim().toLowerCase());
91
75
  }
92
76
  function firstConfigured(baseUrl, envVars) {
93
77
  if (baseUrl && baseUrl.trim()) return baseUrl.trim().replace(/\/+$/, "");
94
78
  for (const name of envVars) {
95
- const current2 = name.startsWith("TRUSTGATE_") ? name.replace("TRUSTGATE_", "SHASHU_") : name;
96
- const legacy = name.startsWith("SHASHU_") ? name.replace("SHASHU_", "TRUSTGATE_") : name.startsWith("TRUSTGATE_") ? name : "";
97
- const value = legacy && legacy !== current2 ? envGet(current2, legacy) : env()[name]?.trim();
79
+ const value = env()[name]?.trim();
98
80
  if (value) return value.replace(/\/+$/, "");
99
81
  }
100
82
  return void 0;
101
83
  }
102
- function optionalBaseUrl(baseUrl, envVars = [BASE_URL_ENV, BASE_URL_ENV_LEGACY]) {
84
+ function optionalBaseUrl(baseUrl, envVars = [BASE_URL_ENV]) {
103
85
  return firstConfigured(baseUrl, envVars);
104
86
  }
105
87
  function requireBaseUrl(baseUrl, opts) {
106
- const envVars = opts.envVars ?? [BASE_URL_ENV, BASE_URL_ENV_LEGACY];
88
+ const envVars = opts.envVars ?? [BASE_URL_ENV];
107
89
  const resolved = firstConfigured(baseUrl, envVars);
108
90
  if (resolved) return resolved;
109
91
  const option = opts.option ?? "baseUrl";
@@ -117,7 +99,7 @@ function requireBaseUrl(baseUrl, opts) {
117
99
  var import_node_crypto2 = require("crypto");
118
100
 
119
101
  // src/version.ts
120
- var SDK_VERSION = "1.0.0";
102
+ var SDK_VERSION = "1.1.0";
121
103
 
122
104
  // src/tracer.ts
123
105
  var import_node_async_hooks = require("async_hooks");
@@ -161,14 +143,14 @@ function parseHopDepth(raw) {
161
143
  return Number.isFinite(n) && n > 0 ? n : 0;
162
144
  }
163
145
  function captureFromHeaders(h) {
164
- const trace = (h["x-trustgate-trace-id"] ?? "").trim();
146
+ const trace = (h["x-shashu-trace-id"] ?? "").trim();
165
147
  if (!trace) return void 0;
166
- const session = (h["x-trustgate-session-id"] ?? "").trim();
167
- const caller = (h["x-trustgate-caller-agent-id"] ?? "").trim();
148
+ const session = (h["x-shashu-session-id"] ?? "").trim();
149
+ const caller = (h["x-shashu-caller-agent-id"] ?? "").trim();
168
150
  return {
169
151
  traceId: trace,
170
152
  sessionId: session || void 0,
171
- inboundHopDepth: parseHopDepth(h["x-trustgate-hop-depth"]),
153
+ inboundHopDepth: parseHopDepth(h["x-shashu-hop-depth"]),
172
154
  inboundCallerAgentId: caller || void 0
173
155
  };
174
156
  }
@@ -188,7 +170,7 @@ var Tracer = class {
188
170
  this.buffer = [];
189
171
  this.flushTimer = null;
190
172
  this._gatewayUrl = optionalBaseUrl();
191
- this._apiKey = envGet(API_KEY_ENV, API_KEY_ENV_LEGACY);
173
+ this._apiKey = envGet(API_KEY_ENV);
192
174
  }
193
175
  /**
194
176
  * Current gateway base URL (respects configure()), or undefined when none is
@@ -241,7 +223,7 @@ var Tracer = class {
241
223
  get sessionId() {
242
224
  return a2aStorage.getStore()?.sessionId || void 0;
243
225
  }
244
- /** Advisory inbound hop depth captured from x-trustgate-hop-depth (0 if absent). */
226
+ /** Advisory inbound hop depth captured from x-shashu-hop-depth (0 if absent). */
245
227
  get inboundHopDepth() {
246
228
  return a2aStorage.getStore()?.inboundHopDepth ?? 0;
247
229
  }
@@ -250,7 +232,7 @@ var Tracer = class {
250
232
  get outboundHopDepth() {
251
233
  return this.inboundHopDepth + 1;
252
234
  }
253
- /** The captured inbound x-trustgate-caller-agent-id — the upstream agent that INVOKED
235
+ /** The captured inbound x-shashu-caller-agent-id — the upstream agent that INVOKED
254
236
  * this hop. The SDK FORWARDS this on the outbound gateway call so the gateway records
255
237
  * the real (invoker -> this agent) edge, NEVER this agent's own id (§4.1). undefined at
256
238
  * origin / caller-stripped. */
@@ -260,7 +242,7 @@ var Tracer = class {
260
242
  /**
261
243
  * Capture an inbound flow from the headers of a request this agent is SERVING into the
262
244
  * AsyncLocalStorage store, so a downstream call made through the SDK propagates the SAME
263
- * flow (WP-A2A-4 / ADR-007 §0). Reads (case-insensitively) x-trustgate-trace-id (the flow
245
+ * flow (WP-A2A-4 / ADR-007 §0). Reads (case-insensitively) x-shashu-trace-id (the flow
264
246
  * id), -session-id, -hop-depth, and -caller-agent-id (the upstream INVOKER). The captured
265
247
  * trace is PROPAGATED on the next outbound call (never re-minted); the session, inbound hop
266
248
  * depth, and inbound caller ride along — the caller is FORWARDED on the gateway call (§4.1),
@@ -357,10 +339,10 @@ var Tracer = class {
357
339
  var tracer = new Tracer();
358
340
 
359
341
  // src/context.ts
360
- var HEADER_PREFIX = "x-trustgate";
361
- var SOURCE_TOOL_HEADER = "x-trustgate-source-tool";
342
+ var HEADER_PREFIX = "x-shashu";
343
+ var SOURCE_TOOL_HEADER = "x-shashu-source-tool";
362
344
  var DEFAULT_CONTRACT_VERSION = "2026-09-01";
363
- var CONTRACT_VERSION_HEADER = "trustgate-version";
345
+ var CONTRACT_VERSION_HEADER = "shashu-version";
364
346
  function applyContractVersion(headers, contractVersion) {
365
347
  if (contractVersion === null) return headers;
366
348
  const named = Object.keys(headers).some((k) => k.toLowerCase() === CONTRACT_VERSION_HEADER);
@@ -479,20 +461,20 @@ function buildContextHeaders(ctx, session) {
479
461
  if (v) h[`${TRUSTLOG_HEADER_PREFIX}${k.replace(/_/g, "-")}`] = String(v);
480
462
  }
481
463
  if (tracer.isActive) {
482
- if (tracer.traceId) h["x-trustgate-trace-id"] = tracer.traceId;
483
- h["x-trustgate-span-id"] = tracer.currentSpanId ?? "";
484
- h["x-trustgate-parent-id"] = tracer.parentSpanId ?? "";
464
+ if (tracer.traceId) h["x-shashu-trace-id"] = tracer.traceId;
465
+ h["x-shashu-span-id"] = tracer.currentSpanId ?? "";
466
+ h["x-shashu-parent-id"] = tracer.parentSpanId ?? "";
485
467
  } else if (tracer.isA2aHop) {
486
- if (tracer.traceId) h["x-trustgate-trace-id"] = tracer.traceId;
487
- } else if (!h["x-trustgate-trace-id"]) {
488
- h["x-trustgate-trace-id"] = resolveOriginTraceId();
468
+ if (tracer.traceId) h["x-shashu-trace-id"] = tracer.traceId;
469
+ } else if (!h["x-shashu-trace-id"]) {
470
+ h["x-shashu-trace-id"] = resolveOriginTraceId();
489
471
  }
490
472
  const sessionId = resolveSessionId(session);
491
- if (sessionId) h["x-trustgate-session-id"] = sessionId;
473
+ if (sessionId) h["x-shashu-session-id"] = sessionId;
492
474
  if (tracer.isA2aHop) {
493
475
  const inboundCaller = tracer.inboundCallerAgentId;
494
- if (inboundCaller) h["x-trustgate-caller-agent-id"] = inboundCaller;
495
- h["x-trustgate-hop-depth"] = String(tracer.outboundHopDepth);
476
+ if (inboundCaller) h["x-shashu-caller-agent-id"] = inboundCaller;
477
+ h["x-shashu-hop-depth"] = String(tracer.outboundHopDepth);
496
478
  }
497
479
  return lowercaseHeaderKeys(h);
498
480
  }
@@ -540,10 +522,10 @@ function attachRagContext(body, ragContext) {
540
522
  if (ragContext === null || typeof ragContext !== "object") {
541
523
  throw new TypeError("ragContext must be an object");
542
524
  }
543
- const existing = body.trustgate_metadata;
525
+ const existing = body.shashu_metadata;
544
526
  const meta = existing !== null && typeof existing === "object" ? existing : {};
545
527
  meta.rag_context = ragContext;
546
- body.trustgate_metadata = meta;
528
+ body.shashu_metadata = meta;
547
529
  return body;
548
530
  }
549
531
  var PREVIEW_KEYS = ["preview", "text", "content", "pageContent", "page_content", "body"];
@@ -673,9 +655,9 @@ function buildMemoryContext(events) {
673
655
  }
674
656
  function attachMemoryContext(body, memoryContext) {
675
657
  const bag = body;
676
- const existing = bag.trustgate_metadata;
658
+ const existing = bag.shashu_metadata;
677
659
  const metadata = existing !== null && typeof existing === "object" ? existing : {};
678
- bag.trustgate_metadata = { ...metadata, memory_context: memoryContext };
660
+ bag.shashu_metadata = { ...metadata, memory_context: memoryContext };
679
661
  return body;
680
662
  }
681
663
 
@@ -692,7 +674,7 @@ function parseJsonObject(body) {
692
674
  }
693
675
  }
694
676
  function metadataBag(body) {
695
- const metadata = body.trustgate_metadata;
677
+ const metadata = body.shashu_metadata;
696
678
  if (metadata !== null && typeof metadata === "object") {
697
679
  return metadata;
698
680
  }
@@ -848,7 +830,7 @@ function shouldRetryPassRefused(opts) {
848
830
  }
849
831
  var CredentialResolver = class {
850
832
  constructor(opts) {
851
- const envKey = envGet(API_KEY_ENV, API_KEY_ENV_LEGACY) ?? void 0;
833
+ const envKey = envGet(API_KEY_ENV) ?? void 0;
852
834
  const hasKeyArg = opts.apiKey !== void 0;
853
835
  const hasProvider = opts.tokenProvider !== void 0;
854
836
  if (hasKeyArg && hasProvider) throw new ShashuConfigError(BOTH_OR_NEITHER);
@@ -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.cjs';
2
+ import { F as FetchLike } from '../_joiner-CmR7qVK8.cjs';
3
3
 
4
4
  /**
5
5
  * Vercel AI SDK middleware: swap the provider to Shashu with one line.
@@ -14,8 +14,8 @@ import { F as FetchLike } from '../_joiner-p5LFxJcu.cjs';
14
14
  * import { createShashuOpenAI } from '@shashu-ai/sdk/middleware/vercel-ai';
15
15
  *
16
16
  * const openai = createShashuOpenAI({
17
- * baseUrl: process.env.TRUSTGATE_BASE_URL!,
18
- * apiKey: process.env.TRUSTGATE_API_KEY,
17
+ * baseUrl: process.env.SHASHU_BASE_URL!,
18
+ * apiKey: process.env.SHASHU_API_KEY,
19
19
  * });
20
20
  *
21
21
  * // Then use `openai` with streamText() as usual — requests go through Shashu.
@@ -30,7 +30,7 @@ interface ShashuOpenAIOptions extends ShashuConfig {
30
30
  }
31
31
  /**
32
32
  * Returns extra headers (lowercase keys) to pass to the Vercel AI SDK OpenAI provider
33
- * so that requests sent to Shashu include workflow context and x-trustgate-source-tool
33
+ * so that requests sent to Shashu include workflow context and x-shashu-source-tool
34
34
  * JSON for Shadow AI detection. Use with createOpenAI({ baseURL, headers: getShashuHeaders() }).
35
35
  */
36
36
  declare function getShashuHeaders(workflowContext?: ShashuConfig['workflowContext'], sessionId?: string, contractVersion?: ShashuConfig['contractVersion']): Record<string, string>;
@@ -44,14 +44,14 @@ declare function getShashuHeaders(workflowContext?: ShashuConfig['workflowContex
44
44
  * import { createShashuOpenAIOptions } from '@shashu-ai/sdk/middleware/vercel-ai';
45
45
  *
46
46
  * const openaiOptions = createShashuOpenAIOptions({
47
- * baseUrl: process.env.TRUSTGATE_BASE_URL!,
48
- * apiKey: process.env.TRUSTGATE_API_KEY,
47
+ * baseUrl: process.env.SHASHU_BASE_URL!,
48
+ * apiKey: process.env.SHASHU_API_KEY,
49
49
  * });
50
50
  *
51
51
  * const openai = createOpenAI(openaiOptions);
52
52
  * // use openai('gpt-4') with streamText()
53
53
  *
54
- * Returns `{}` when TRUSTGATE_DISABLE is set: the provider client is then left
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
57
  * 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.js';
2
- import { F as FetchLike } from '../_joiner-p5LFxJcu.js';
1
+ import { S as ShashuConfig } from '../types-BLs_TMFv.js';
2
+ import { F as FetchLike } from '../_joiner-CmR7qVK8.js';
3
3
 
4
4
  /**
5
5
  * Vercel AI SDK middleware: swap the provider to Shashu with one line.
@@ -14,8 +14,8 @@ import { F as FetchLike } from '../_joiner-p5LFxJcu.js';
14
14
  * import { createShashuOpenAI } from '@shashu-ai/sdk/middleware/vercel-ai';
15
15
  *
16
16
  * const openai = createShashuOpenAI({
17
- * baseUrl: process.env.TRUSTGATE_BASE_URL!,
18
- * apiKey: process.env.TRUSTGATE_API_KEY,
17
+ * baseUrl: process.env.SHASHU_BASE_URL!,
18
+ * apiKey: process.env.SHASHU_API_KEY,
19
19
  * });
20
20
  *
21
21
  * // Then use `openai` with streamText() as usual — requests go through Shashu.
@@ -30,7 +30,7 @@ interface ShashuOpenAIOptions extends ShashuConfig {
30
30
  }
31
31
  /**
32
32
  * Returns extra headers (lowercase keys) to pass to the Vercel AI SDK OpenAI provider
33
- * so that requests sent to Shashu include workflow context and x-trustgate-source-tool
33
+ * so that requests sent to Shashu include workflow context and x-shashu-source-tool
34
34
  * JSON for Shadow AI detection. Use with createOpenAI({ baseURL, headers: getShashuHeaders() }).
35
35
  */
36
36
  declare function getShashuHeaders(workflowContext?: ShashuConfig['workflowContext'], sessionId?: string, contractVersion?: ShashuConfig['contractVersion']): Record<string, string>;
@@ -44,14 +44,14 @@ declare function getShashuHeaders(workflowContext?: ShashuConfig['workflowContex
44
44
  * import { createShashuOpenAIOptions } from '@shashu-ai/sdk/middleware/vercel-ai';
45
45
  *
46
46
  * const openaiOptions = createShashuOpenAIOptions({
47
- * baseUrl: process.env.TRUSTGATE_BASE_URL!,
48
- * apiKey: process.env.TRUSTGATE_API_KEY,
47
+ * baseUrl: process.env.SHASHU_BASE_URL!,
48
+ * apiKey: process.env.SHASHU_API_KEY,
49
49
  * });
50
50
  *
51
51
  * const openai = createOpenAI(openaiOptions);
52
52
  * // use openai('gpt-4') with streamText()
53
53
  *
54
- * Returns `{}` when TRUSTGATE_DISABLE is set: the provider client is then left
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
57
  * caller's tg_sk_ key is deliberately NOT handed back, since it would be sent to
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  createShashuOpenAIOptions,
3
3
  getShashuHeaders
4
- } from "../chunk-M4JDSAUC.js";
5
- import "../chunk-5TW3FISD.js";
6
- import "../chunk-IQYB5OZ6.js";
4
+ } from "../chunk-QHWUNZQS.js";
5
+ import "../chunk-NTIOPTYF.js";
6
+ import "../chunk-QJQ4MWQ4.js";
7
7
  export {
8
8
  createShashuOpenAIOptions,
9
9
  getShashuHeaders
@@ -50,8 +50,10 @@ interface RetryPolicy {
50
50
  retryOn5xx: boolean;
51
51
  /** Statuses that are never retried, even if a flag above would allow it. */
52
52
  neverRetryStatus: number[];
53
- /** Ignore the Retry-After header on 429 and use exponential backoff instead. */
53
+ /** Ignore the Retry-After header on 429/503 and use exponential backoff instead. */
54
54
  ignoreRetryAfter: boolean;
55
+ /** Extra wait as a fraction of the chosen delay (0–20% by default). */
56
+ jitterFraction: number;
55
57
  }
56
58
  declare const DEFAULT_RETRY_POLICY: RetryPolicy;
57
59
  /** Resolve a config's retryPolicy: undefined -> default; null -> disabled; object -> merged over defaults. */
@@ -102,18 +104,18 @@ declare const DECISIONS: readonly ["allow", "allow_altered", "not_checked", "blo
102
104
  /** The three where the caller is holding the provider's content. */
103
105
  declare const DELIVERED_DECISIONS: ReadonlySet<string>;
104
106
  /** Top-level on a 200 body; nested INSIDE `error` on an error body. */
105
- declare const BODY_KEY = "trustgate";
106
- declare const HEADER_DECISION = "x-trustgate-decision";
107
- declare const HEADER_CODE = "x-trustgate-code";
108
- declare const HEADER_INSPECTION = "x-trustgate-inspection";
107
+ declare const BODY_KEY = "shashu";
108
+ declare const HEADER_DECISION = "x-shashu-decision";
109
+ declare const HEADER_CODE = "x-shashu-code";
110
+ declare const HEADER_INSPECTION = "x-shashu-inspection";
109
111
  declare const HEADER_SHOULD_RETRY = "x-should-retry";
110
112
  declare const HEADER_REQUEST_ID = "x-request-id";
111
- declare const HEADER_SHASHU_REQUEST_ID = "x-trustgate-request-id";
112
- declare const HEADER_TRACE_ID = "x-trustgate-trace-id";
113
+ declare const HEADER_SHASHU_REQUEST_ID = "x-shashu-request-id";
114
+ declare const HEADER_TRACE_ID = "x-shashu-trace-id";
113
115
  /** Counts only (`total=N;scanned=N;not_inspected=N;blocked=N`), only when one is above zero. */
114
- declare const HEADER_ATTACHMENTS = "x-trustgate-attachments";
116
+ declare const HEADER_ATTACHMENTS = "x-shashu-attachments";
115
117
  /** Counts only (`writes=N;blocked=N;recalls=N;flagged=N`), only when one is above zero. */
116
- declare const HEADER_MEMORY = "x-trustgate-memory";
118
+ declare const HEADER_MEMORY = "x-shashu-memory";
117
119
  /**
118
120
  * What happened to one attached file. A closed set on the gateway; a value
119
121
  * this SDK does not know arrives as `"unknown"`, with the wire string kept on
@@ -202,7 +204,7 @@ interface Decision {
202
204
  readonly retryable: boolean;
203
205
  /** Resolves to the stored audit record. Same value as `x-request-id`. */
204
206
  readonly id: string | undefined;
205
- /** The per-hop request id (`x-trustgate-request-id`), or undefined. */
207
+ /** The per-hop request id (`x-shashu-request-id`), or undefined. */
206
208
  readonly requestId: string | undefined;
207
209
  /** The flow's trace id — the same value as `id`, under its own name. */
208
210
  readonly traceId: string | undefined;
@@ -219,7 +221,7 @@ interface Decision {
219
221
  readonly carrierDisagreement: Record<string, [unknown, unknown]>;
220
222
  /**
221
223
  * What happened to each attached file; undefined when the request had none.
222
- * Read off the body; off the `x-trustgate-attachments` counts when the body
224
+ * Read off the body; off the `x-shashu-attachments` counts when the body
223
225
  * carried no envelope. `attachments.carrier` says which.
224
226
  */
225
227
  readonly attachments: Attachments | undefined;
@@ -284,7 +286,7 @@ declare function isShashuBlock(err: unknown): boolean;
284
286
 
285
287
  /**
286
288
  * Runtime metadata included in every context for parity with the Python SDK.
287
- * Sent in x-trustgate-source-tool and in x-trustgate-meta-* headers.
289
+ * Sent in x-shashu-source-tool and in x-shashu-meta-* headers.
288
290
  */
289
291
  interface RuntimeMetadata {
290
292
  /** SDK version (e.g. "1.0.0"). */
@@ -362,7 +364,7 @@ type Provider = 'openai' | 'anthropic' | 'google';
362
364
  */
363
365
  interface ShashuConfig {
364
366
  /**
365
- * Shashu gateway base URL. Falls back to process.env.TRUSTGATE_BASE_URL.
367
+ * Shashu gateway base URL. Falls back to process.env.SHASHU_BASE_URL.
366
368
  * There is NO default: SHASHU is self-hosted, so an unset address is a
367
369
  * ShashuConfigError, never a vendor host. See ./config.ts.
368
370
  */
@@ -378,7 +380,7 @@ interface ShashuConfig {
378
380
  * This agent's OWN id (ADR-007 §4.1). NOT sent on the gateway call (that FORWARDS the
379
381
  * captured inbound caller); used by `buildInvocationHeaders()` to stamp caller = self when
380
382
  * THIS agent invokes a downstream agent. Seeds the self-id cache, which is then refreshed
381
- * from each gateway response's `x-trustgate-agent-id` header. Advisory lineage only —
383
+ * from each gateway response's `x-shashu-agent-id` header. Advisory lineage only —
382
384
  * NEVER an auth credential.
383
385
  */
384
386
  agentId?: string;
@@ -395,12 +397,12 @@ interface ShashuConfig {
395
397
  /** Extra headers sent with every request */
396
398
  headers?: Record<string, string>;
397
399
  /**
398
- * `trustgate-version`: the contract generation to ask the gateway for.
400
+ * `shashu-version`: the contract generation to ask the gateway for.
399
401
  * Default `DEFAULT_CONTRACT_VERSION` (`"2026-09-01"`, the Python SDK's
400
402
  * value): refusals arrive as errors and the body carries the full decision.
401
403
  * Pass `null` to send no such header — the gateway then serves the account
402
404
  * default, which is the legacy contract unless an operator moved it.
403
- * A `trustgate-version` entry in `headers` wins over this.
405
+ * A `shashu-version` entry in `headers` wins over this.
404
406
  */
405
407
  contractVersion?: string | null;
406
408
  /**