@declaw/sdk 1.2.0 → 1.2.2
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 +26 -0
- package/dist/index.cjs +59 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +59 -1
- package/dist/index.d.ts +59 -1
- package/dist/index.js +58 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,32 @@ All notable changes to the Declaw TypeScript / JavaScript SDK are documented in
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.2.2]
|
|
9
|
+
|
|
10
|
+
_Higher default connection ceiling._
|
|
11
|
+
|
|
12
|
+
### Performance
|
|
13
|
+
|
|
14
|
+
- Raised the default connection-pool ceiling from 64 to 512 so a
|
|
15
|
+
high-concurrency workload from a single client process is no longer queued
|
|
16
|
+
behind the connection cap. Still overridable via `DECLAW_SDK_CONNECTIONS`.
|
|
17
|
+
No public API change.
|
|
18
|
+
|
|
19
|
+
## [1.2.1]
|
|
20
|
+
|
|
21
|
+
_HTTP/2 burst performance._
|
|
22
|
+
|
|
23
|
+
### Performance
|
|
24
|
+
|
|
25
|
+
- Unblocked HTTP/2 multiplexing on burst create: removed `pipelining: 1`
|
|
26
|
+
from the undici Agent, which was capping each H2 connection to a single
|
|
27
|
+
in-flight stream and silently defeating `allowH2` — a 100-concurrent burst
|
|
28
|
+
queued ~36 requests behind the connection cap. Also: eagerly initialize the
|
|
29
|
+
undici dispatcher at module load (the lazy `import('undici')` was blocking
|
|
30
|
+
the first burst), cache the resolved dispatcher synchronously (skips a
|
|
31
|
+
per-request microtask yield), and lower the retry backoff base from 0.5s to
|
|
32
|
+
0.1s. No public API change (#359).
|
|
33
|
+
|
|
8
34
|
## [1.2.0]
|
|
9
35
|
|
|
10
36
|
_2026-06 train: file-granular volumes, OPA governance._
|
package/dist/index.cjs
CHANGED
|
@@ -87,6 +87,7 @@ __export(index_exports, {
|
|
|
87
87
|
createToxicityConfig: () => createToxicityConfig,
|
|
88
88
|
createTransformationRule: () => createTransformationRule,
|
|
89
89
|
domainMatches: () => domainMatches,
|
|
90
|
+
fullInjectionDefensePolicy: () => fullInjectionDefensePolicy,
|
|
90
91
|
getSharedClient: () => getSharedClient,
|
|
91
92
|
invisibleTextConfigToJSON: () => invisibleTextConfigToJSON,
|
|
92
93
|
isSensitive: () => isSensitive,
|
|
@@ -254,6 +255,8 @@ var CommandExitError = class extends SandboxError {
|
|
|
254
255
|
|
|
255
256
|
// src/api/client.ts
|
|
256
257
|
var _dispatcherPromise;
|
|
258
|
+
var _resolvedDispatcher;
|
|
259
|
+
var _dispatcherResolved = false;
|
|
257
260
|
function getDispatcher() {
|
|
258
261
|
if (_dispatcherPromise) return _dispatcherPromise;
|
|
259
262
|
_dispatcherPromise = (async () => {
|
|
@@ -266,7 +269,7 @@ function getDispatcher() {
|
|
|
266
269
|
}
|
|
267
270
|
const undici = await import("undici");
|
|
268
271
|
const connOverride = parseInt(process.env.DECLAW_SDK_CONNECTIONS || "", 10);
|
|
269
|
-
const connections = Number.isFinite(connOverride) && connOverride > 0 ? connOverride :
|
|
272
|
+
const connections = Number.isFinite(connOverride) && connOverride > 0 ? connOverride : 512;
|
|
270
273
|
const streamsOverride = parseInt(process.env.DECLAW_SDK_MAX_CONCURRENT_STREAMS || "", 10);
|
|
271
274
|
const maxConcurrentStreams = Number.isFinite(streamsOverride) && streamsOverride > 0 ? streamsOverride : 1e3;
|
|
272
275
|
return new undici.Agent({
|
|
@@ -278,7 +281,12 @@ function getDispatcher() {
|
|
|
278
281
|
maxConcurrentStreams,
|
|
279
282
|
keepAliveTimeout: 3e4,
|
|
280
283
|
keepAliveMaxTimeout: 6e4,
|
|
281
|
-
|
|
284
|
+
// NOTE: do NOT set `pipelining` here. undici applies it to H2 sessions
|
|
285
|
+
// too, where `pipelining: 1` caps each connection to ONE in-flight
|
|
286
|
+
// stream — silently defeating the H2 multiplexing that allowH2 enables.
|
|
287
|
+
// Omitted, H2 sessions default to unlimited concurrent streams (capped
|
|
288
|
+
// by maxConcurrentStreams) and H1.1 fallback defaults to 1 (safe, no
|
|
289
|
+
// head-of-line risk on non-idempotent POSTs).
|
|
282
290
|
allowH2: true,
|
|
283
291
|
connect: { keepAlive: true, keepAliveInitialDelay: 5e3 }
|
|
284
292
|
});
|
|
@@ -286,8 +294,13 @@ function getDispatcher() {
|
|
|
286
294
|
return void 0;
|
|
287
295
|
}
|
|
288
296
|
})();
|
|
297
|
+
void _dispatcherPromise.then((d) => {
|
|
298
|
+
_resolvedDispatcher = d;
|
|
299
|
+
_dispatcherResolved = true;
|
|
300
|
+
});
|
|
289
301
|
return _dispatcherPromise;
|
|
290
302
|
}
|
|
303
|
+
void getDispatcher();
|
|
291
304
|
var STATUS_ERROR_MAP = {
|
|
292
305
|
400: InvalidArgumentError,
|
|
293
306
|
401: AuthenticationError,
|
|
@@ -307,7 +320,7 @@ var ApiClient = class {
|
|
|
307
320
|
constructor(config, opts) {
|
|
308
321
|
this.config = config ?? new ConnectionConfig();
|
|
309
322
|
this.maxRetries = opts?.maxRetries ?? 3;
|
|
310
|
-
this.retryDelay = opts?.retryDelay ?? 0.
|
|
323
|
+
this.retryDelay = opts?.retryDelay ?? 0.1;
|
|
311
324
|
this.abortController = new AbortController();
|
|
312
325
|
}
|
|
313
326
|
/** Send a GET request and return parsed JSON. */
|
|
@@ -401,7 +414,7 @@ var ApiClient = class {
|
|
|
401
414
|
signals.push(AbortSignal.timeout(timeoutMs));
|
|
402
415
|
}
|
|
403
416
|
const signal = signals.length === 1 ? signals[0] : AbortSignal.any(signals);
|
|
404
|
-
const dispatcher = await getDispatcher();
|
|
417
|
+
const dispatcher = _dispatcherResolved ? _resolvedDispatcher : await getDispatcher();
|
|
405
418
|
const fetchOpts = {
|
|
406
419
|
method,
|
|
407
420
|
headers,
|
|
@@ -627,7 +640,9 @@ function createInjectionDefenseConfig(opts) {
|
|
|
627
640
|
sensitivity: opts?.sensitivity ?? "medium" /* Medium */,
|
|
628
641
|
action: opts?.action ?? "log_only" /* LogOnly */,
|
|
629
642
|
threshold: opts?.threshold ?? 0.8,
|
|
630
|
-
domains: opts?.domains
|
|
643
|
+
domains: opts?.domains,
|
|
644
|
+
judge: opts?.judge,
|
|
645
|
+
injectionMode: opts?.injectionMode
|
|
631
646
|
};
|
|
632
647
|
if (!VALID_SENSITIVITIES.has(config.sensitivity)) {
|
|
633
648
|
throw new InvalidArgumentError(
|
|
@@ -652,7 +667,9 @@ function parseInjectionDefenseConfig(data) {
|
|
|
652
667
|
sensitivity: data.sensitivity ?? "medium" /* Medium */,
|
|
653
668
|
action: data.action ?? "log_only" /* LogOnly */,
|
|
654
669
|
threshold: data.threshold ?? 0.8,
|
|
655
|
-
domains: data.domains
|
|
670
|
+
domains: data.domains,
|
|
671
|
+
judge: data.judge ? { enabled: data.judge.enabled ?? false, always: data.judge.always, policy: data.judge.policy } : void 0,
|
|
672
|
+
injectionMode: data.injection_mode ?? data.injectionMode
|
|
656
673
|
};
|
|
657
674
|
}
|
|
658
675
|
|
|
@@ -955,6 +972,15 @@ function invisibleTextConfigToJSON(config) {
|
|
|
955
972
|
}
|
|
956
973
|
|
|
957
974
|
// src/security/customPolicy.ts
|
|
975
|
+
function createCustomPolicyConfig(opts) {
|
|
976
|
+
return {
|
|
977
|
+
enabled: opts?.enabled ?? false,
|
|
978
|
+
inlineRego: opts?.inlineRego,
|
|
979
|
+
inlineModules: opts?.inlineModules,
|
|
980
|
+
policyRef: opts?.policyRef,
|
|
981
|
+
defaultDeny: opts?.defaultDeny ?? false
|
|
982
|
+
};
|
|
983
|
+
}
|
|
958
984
|
function parseCustomPolicyConfig(data) {
|
|
959
985
|
return {
|
|
960
986
|
enabled: data.enabled ?? false,
|
|
@@ -1013,6 +1039,23 @@ function createSecurityPolicy(opts) {
|
|
|
1013
1039
|
customPolicy: opts?.customPolicy
|
|
1014
1040
|
};
|
|
1015
1041
|
}
|
|
1042
|
+
function fullInjectionDefensePolicy(opts) {
|
|
1043
|
+
return createSecurityPolicy({
|
|
1044
|
+
injectionDefense: createInjectionDefenseConfig({
|
|
1045
|
+
enabled: true,
|
|
1046
|
+
action: opts?.action ?? "block",
|
|
1047
|
+
threshold: opts?.threshold ?? 0.8,
|
|
1048
|
+
domains: opts?.domains,
|
|
1049
|
+
injectionMode: opts?.mode ?? "balanced",
|
|
1050
|
+
judge: { enabled: true, always: opts?.alwaysJudge ?? false, policy: opts?.agentPolicy ?? "" }
|
|
1051
|
+
}),
|
|
1052
|
+
customPolicy: createCustomPolicyConfig({
|
|
1053
|
+
enabled: true,
|
|
1054
|
+
policyRef: "prompt-injection@v2",
|
|
1055
|
+
defaultDeny: false
|
|
1056
|
+
})
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1016
1059
|
function parseSecurityPolicy(data) {
|
|
1017
1060
|
const injDef = data.injection_defense ?? data.injectionDefense;
|
|
1018
1061
|
const auditData = data.audit;
|
|
@@ -1052,6 +1095,15 @@ function securityPolicyToJSON(policy) {
|
|
|
1052
1095
|
if (injDefConfig.domains !== void 0) {
|
|
1053
1096
|
injDef.domains = injDefConfig.domains;
|
|
1054
1097
|
}
|
|
1098
|
+
if (injDefConfig.injectionMode !== void 0) {
|
|
1099
|
+
injDef.injection_mode = injDefConfig.injectionMode;
|
|
1100
|
+
}
|
|
1101
|
+
if (injDefConfig.judge !== void 0) {
|
|
1102
|
+
const j = { enabled: injDefConfig.judge.enabled };
|
|
1103
|
+
if (injDefConfig.judge.always) j.always = true;
|
|
1104
|
+
if (injDefConfig.judge.policy) j.policy = injDefConfig.judge.policy;
|
|
1105
|
+
injDef.judge = j;
|
|
1106
|
+
}
|
|
1055
1107
|
const auditConfig = typeof policy.audit === "boolean" ? createAuditConfig({ enabled: policy.audit }) : policy.audit;
|
|
1056
1108
|
const audit = {
|
|
1057
1109
|
enabled: auditConfig.enabled
|
|
@@ -3535,6 +3587,7 @@ var Governance = class {
|
|
|
3535
3587
|
createToxicityConfig,
|
|
3536
3588
|
createTransformationRule,
|
|
3537
3589
|
domainMatches,
|
|
3590
|
+
fullInjectionDefensePolicy,
|
|
3538
3591
|
getSharedClient,
|
|
3539
3592
|
invisibleTextConfigToJSON,
|
|
3540
3593
|
isSensitive,
|