@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.
- package/CHANGELOG.md +17 -0
- package/README.md +18 -18
- package/dist/{_joiner-p5LFxJcu.d.cts → _joiner-CmR7qVK8.d.cts} +1 -1
- package/dist/{_joiner-p5LFxJcu.d.ts → _joiner-CmR7qVK8.d.ts} +1 -1
- package/dist/{chunk-4CDQ7JMK.js → chunk-L6GKR3SC.js} +2 -2
- package/dist/{chunk-5TW3FISD.js → chunk-NTIOPTYF.js} +6 -6
- package/dist/{chunk-M4JDSAUC.js → chunk-QHWUNZQS.js} +2 -2
- package/dist/{chunk-IQYB5OZ6.js → chunk-QJQ4MWQ4.js} +33 -53
- package/dist/{chunk-BEU2UWW3.js → chunk-QLK5CQSP.js} +1 -1
- package/dist/{chunk-Z6DROYQA.js → chunk-WC3BKVXK.js} +2 -2
- package/dist/index.cjs +79 -77
- package/dist/index.d.cts +30 -30
- package/dist/index.d.ts +30 -30
- package/dist/index.js +47 -29
- package/dist/{langchain-DNOsiRna.d.ts → langchain-B9Q9eL7g.d.cts} +11 -11
- package/dist/{langchain-xCWwa1Ud.d.cts → langchain-CHjjdhDr.d.ts} +11 -11
- package/dist/middleware/anthropic.cjs +34 -52
- package/dist/middleware/anthropic.d.cts +5 -5
- package/dist/middleware/anthropic.d.ts +5 -5
- package/dist/middleware/anthropic.js +3 -3
- package/dist/middleware/google.cjs +28 -46
- package/dist/middleware/google.d.cts +5 -5
- package/dist/middleware/google.d.ts +5 -5
- package/dist/middleware/google.js +2 -2
- package/dist/middleware/langchain.cjs +34 -52
- package/dist/middleware/langchain.d.cts +3 -3
- package/dist/middleware/langchain.d.ts +3 -3
- package/dist/middleware/langchain.js +3 -3
- package/dist/middleware/vercel-ai.cjs +34 -52
- package/dist/middleware/vercel-ai.d.cts +8 -8
- package/dist/middleware/vercel-ai.d.ts +8 -8
- package/dist/middleware/vercel-ai.js +3 -3
- package/dist/{types-Rs49lJyD.d.ts → types-BLs_TMFv.d.cts} +18 -16
- package/dist/{types-Rs49lJyD.d.cts → types-BLs_TMFv.d.ts} +18 -16
- package/package.json +1 -1
|
@@ -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 = "
|
|
106
|
-
declare const HEADER_DECISION = "x-
|
|
107
|
-
declare const HEADER_CODE = "x-
|
|
108
|
-
declare const HEADER_INSPECTION = "x-
|
|
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-
|
|
112
|
-
declare const HEADER_TRACE_ID = "x-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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.
|
|
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-
|
|
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
|
-
* `
|
|
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 `
|
|
405
|
+
* A `shashu-version` entry in `headers` wins over this.
|
|
404
406
|
*/
|
|
405
407
|
contractVersion?: string | null;
|
|
406
408
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shashu-ai/sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"description": "Node.js client for SHASHU by Trustgate AI, a self-hosted AI security gateway. Point it at your own gateway; there is no default endpoint.",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.js",
|