@declaw/sdk 1.2.1 → 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 +11 -0
- package/dist/index.cjs +45 -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 +44 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,17 @@ 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
|
+
|
|
8
19
|
## [1.2.1]
|
|
9
20
|
|
|
10
21
|
_HTTP/2 burst performance._
|
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,
|
|
@@ -268,7 +269,7 @@ function getDispatcher() {
|
|
|
268
269
|
}
|
|
269
270
|
const undici = await import("undici");
|
|
270
271
|
const connOverride = parseInt(process.env.DECLAW_SDK_CONNECTIONS || "", 10);
|
|
271
|
-
const connections = Number.isFinite(connOverride) && connOverride > 0 ? connOverride :
|
|
272
|
+
const connections = Number.isFinite(connOverride) && connOverride > 0 ? connOverride : 512;
|
|
272
273
|
const streamsOverride = parseInt(process.env.DECLAW_SDK_MAX_CONCURRENT_STREAMS || "", 10);
|
|
273
274
|
const maxConcurrentStreams = Number.isFinite(streamsOverride) && streamsOverride > 0 ? streamsOverride : 1e3;
|
|
274
275
|
return new undici.Agent({
|
|
@@ -285,9 +286,7 @@ function getDispatcher() {
|
|
|
285
286
|
// stream — silently defeating the H2 multiplexing that allowH2 enables.
|
|
286
287
|
// Omitted, H2 sessions default to unlimited concurrent streams (capped
|
|
287
288
|
// by maxConcurrentStreams) and H1.1 fallback defaults to 1 (safe, no
|
|
288
|
-
// head-of-line risk on non-idempotent POSTs).
|
|
289
|
-
// biggest burst-latency lever: with pipelining:1 a 100-concurrent burst
|
|
290
|
-
// queued ~36 requests behind the `connections` cap.
|
|
289
|
+
// head-of-line risk on non-idempotent POSTs).
|
|
291
290
|
allowH2: true,
|
|
292
291
|
connect: { keepAlive: true, keepAliveInitialDelay: 5e3 }
|
|
293
292
|
});
|
|
@@ -641,7 +640,9 @@ function createInjectionDefenseConfig(opts) {
|
|
|
641
640
|
sensitivity: opts?.sensitivity ?? "medium" /* Medium */,
|
|
642
641
|
action: opts?.action ?? "log_only" /* LogOnly */,
|
|
643
642
|
threshold: opts?.threshold ?? 0.8,
|
|
644
|
-
domains: opts?.domains
|
|
643
|
+
domains: opts?.domains,
|
|
644
|
+
judge: opts?.judge,
|
|
645
|
+
injectionMode: opts?.injectionMode
|
|
645
646
|
};
|
|
646
647
|
if (!VALID_SENSITIVITIES.has(config.sensitivity)) {
|
|
647
648
|
throw new InvalidArgumentError(
|
|
@@ -666,7 +667,9 @@ function parseInjectionDefenseConfig(data) {
|
|
|
666
667
|
sensitivity: data.sensitivity ?? "medium" /* Medium */,
|
|
667
668
|
action: data.action ?? "log_only" /* LogOnly */,
|
|
668
669
|
threshold: data.threshold ?? 0.8,
|
|
669
|
-
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
|
|
670
673
|
};
|
|
671
674
|
}
|
|
672
675
|
|
|
@@ -969,6 +972,15 @@ function invisibleTextConfigToJSON(config) {
|
|
|
969
972
|
}
|
|
970
973
|
|
|
971
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
|
+
}
|
|
972
984
|
function parseCustomPolicyConfig(data) {
|
|
973
985
|
return {
|
|
974
986
|
enabled: data.enabled ?? false,
|
|
@@ -1027,6 +1039,23 @@ function createSecurityPolicy(opts) {
|
|
|
1027
1039
|
customPolicy: opts?.customPolicy
|
|
1028
1040
|
};
|
|
1029
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
|
+
}
|
|
1030
1059
|
function parseSecurityPolicy(data) {
|
|
1031
1060
|
const injDef = data.injection_defense ?? data.injectionDefense;
|
|
1032
1061
|
const auditData = data.audit;
|
|
@@ -1066,6 +1095,15 @@ function securityPolicyToJSON(policy) {
|
|
|
1066
1095
|
if (injDefConfig.domains !== void 0) {
|
|
1067
1096
|
injDef.domains = injDefConfig.domains;
|
|
1068
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
|
+
}
|
|
1069
1107
|
const auditConfig = typeof policy.audit === "boolean" ? createAuditConfig({ enabled: policy.audit }) : policy.audit;
|
|
1070
1108
|
const audit = {
|
|
1071
1109
|
enabled: auditConfig.enabled
|
|
@@ -3549,6 +3587,7 @@ var Governance = class {
|
|
|
3549
3587
|
createToxicityConfig,
|
|
3550
3588
|
createTransformationRule,
|
|
3551
3589
|
domainMatches,
|
|
3590
|
+
fullInjectionDefensePolicy,
|
|
3552
3591
|
getSharedClient,
|
|
3553
3592
|
invisibleTextConfigToJSON,
|
|
3554
3593
|
isSensitive,
|