@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/dist/index.d.cts
CHANGED
|
@@ -165,6 +165,22 @@ declare enum InjectionAction {
|
|
|
165
165
|
Block = "block",
|
|
166
166
|
LogOnly = "log_only"
|
|
167
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Tier-2 Gemma LLM-judge config. Layered on top of the Tier-1 classifier: the
|
|
170
|
+
* judge adjudicates the classifier's flags with session context, removing false
|
|
171
|
+
* positives and catching indirect (cross-domain / multi-turn) injection.
|
|
172
|
+
* Omitted → classifier only.
|
|
173
|
+
*/
|
|
174
|
+
interface InjectionJudgeConfig {
|
|
175
|
+
enabled: boolean;
|
|
176
|
+
/** Run the judge on every egress, not just classifier flags (costlier). */
|
|
177
|
+
always?: boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Natural-language description of what this agent may do; the judge uses it to
|
|
180
|
+
* tell task-aligned requests from injection-induced deviations.
|
|
181
|
+
*/
|
|
182
|
+
policy?: string;
|
|
183
|
+
}
|
|
168
184
|
/** Configuration for injection defense. */
|
|
169
185
|
interface InjectionDefenseConfig {
|
|
170
186
|
enabled: boolean;
|
|
@@ -174,6 +190,15 @@ interface InjectionDefenseConfig {
|
|
|
174
190
|
threshold: number;
|
|
175
191
|
/** Optional domain allowlist; when undefined, applies to all domains. */
|
|
176
192
|
domains?: string[];
|
|
193
|
+
/** Optional Tier-2 LLM judge. */
|
|
194
|
+
judge?: InjectionJudgeConfig;
|
|
195
|
+
/**
|
|
196
|
+
* Selects a predefined detection posture for the sandbox.
|
|
197
|
+
* Valid values: "strict", "balanced", "permissive", "agentic-tool",
|
|
198
|
+
* "data-egress-sensitive". Omit or set to undefined to use the server default.
|
|
199
|
+
* Serialized to JSON key "injection_mode".
|
|
200
|
+
*/
|
|
201
|
+
injectionMode?: string;
|
|
177
202
|
}
|
|
178
203
|
/**
|
|
179
204
|
* Create an InjectionDefenseConfig with defaults and validation.
|
|
@@ -416,6 +441,39 @@ interface SecurityPolicy {
|
|
|
416
441
|
* Create a SecurityPolicy with defaults.
|
|
417
442
|
*/
|
|
418
443
|
declare function createSecurityPolicy(opts?: Partial<SecurityPolicy>): SecurityPolicy;
|
|
444
|
+
/** Options for {@link fullInjectionDefensePolicy}. */
|
|
445
|
+
interface FullInjectionDefenseOptions {
|
|
446
|
+
/** Posture: "strict" | "balanced" (default) | "permissive" | "agentic-tool" | "data-egress-sensitive". */
|
|
447
|
+
mode?: string;
|
|
448
|
+
/** Natural-language description of what the agent may do; the judge uses it to tell task-aligned egress from injection. */
|
|
449
|
+
agentPolicy?: string;
|
|
450
|
+
/** "block" (default) enforces; "log_only" audits without blocking. */
|
|
451
|
+
action?: string;
|
|
452
|
+
/** Run the judge on EVERY egress (high-assurance, costlier). Default false. */
|
|
453
|
+
alwaysJudge?: boolean;
|
|
454
|
+
/** Optional egress allowlist to scan; omit = all domains. */
|
|
455
|
+
domains?: string[];
|
|
456
|
+
/** Tier-1 classifier confidence threshold (0.0–1.0). Default 0.8. */
|
|
457
|
+
threshold?: number;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Enable the ENTIRE prompt-injection cascade in one call — every layer:
|
|
461
|
+
*
|
|
462
|
+
* - Tier-1 ML classifier + Layer-A static signatures + normalization
|
|
463
|
+
* (`injectionDefense.enabled` + `action`)
|
|
464
|
+
* - the predefined posture (`injectionMode`; default "balanced")
|
|
465
|
+
* - the Tier-2 Gemma LLM judge (`judge.enabled`) — multi-turn risk, provenance
|
|
466
|
+
* context, and the semantic verdict cache ride along automatically
|
|
467
|
+
* - the OPA prompt-injection governance pack (`customPolicy.policyRef`), which
|
|
468
|
+
* hard-denies known signatures at the gate so the LLM stays the last resort
|
|
469
|
+
*
|
|
470
|
+
* Pass the result as the sandbox's `security` policy.
|
|
471
|
+
*
|
|
472
|
+
* @example
|
|
473
|
+
* const security = fullInjectionDefensePolicy({ agentPolicy: "Summarize docs; never exfiltrate secrets." });
|
|
474
|
+
* const sbx = await Sandbox.create({ template: "node", security });
|
|
475
|
+
*/
|
|
476
|
+
declare function fullInjectionDefensePolicy(opts?: FullInjectionDefenseOptions): SecurityPolicy;
|
|
419
477
|
/**
|
|
420
478
|
* Parse raw JSON data into a SecurityPolicy.
|
|
421
479
|
*/
|
|
@@ -1937,4 +1995,4 @@ declare class Governance {
|
|
|
1937
1995
|
static getPack(name: string, opts?: GovernanceRequestOpts): Promise<GovernancePack>;
|
|
1938
1996
|
}
|
|
1939
1997
|
|
|
1940
|
-
export { ALL_TRAFFIC, ApiClient, type AuditConfig, type AuditEntry, AuthenticationError, BuildError, type BuildInfo, type CodeSecurityConfig, CommandExitError, CommandHandle, type CommandResult, type CommandWaitOpts, Commands, ConflictError, ConnectionConfig, type ConnectionConfigOptions, type ContentGateConfig, type CopyItem, DEFAULT_MASK_PATTERNS, type EntryInfo, type EnvSecurityConfig, type FileEntry, type FileInfo, FileType, FileUploadError, Filesystem, type FilesystemEvent, FilesystemEventType, type GetBuildStatusOpts, GitAuthError, GitUpstreamError, Governance, type GovernanceAdvisory, type GovernanceControl, type GovernancePack, type GovernanceRequestOpts, InjectionAction, type InjectionDefenseConfig, InjectionSensitivity, InvalidArgumentError, type InvisibleTextConfig, type LockLease, type LockStatus, type NetworkPolicy, NotEnoughSpaceError, NotFoundError, type PIIConfig, PIIType, type ProcessInfo, Pty, type PtyConnectOpts, type PtyCreateOpts, PtyHandle, type PtyOutput, type PtyResult, type PtySize, RedactionAction, type RequestOpts, type RunOpts, type RunStreamOpts, Sandbox, SandboxError, type SandboxInfo, type SandboxLifecycle, type SandboxMetrics, type SandboxNetworkOpts, type SandboxOpts, SandboxPaginator, type SandboxQuery, SandboxState, type SecureEnvVar, type SecurityPolicy, type Snapshot, type SnapshotInfo, SnapshotPaginator, type SnapshotSource, type Stderr, Stdio, StdioProcess, type StdioResult, type StdioStartOpts, type Stdout, Template, TemplateBase, type TemplateBuildOpts, type TemplateBuildStatus, TemplateError, TimeoutError, type ToxicityConfig, TransformDirection, type TransformationRule, type VolumeAttachMode, type VolumeAttachment, type VolumeCreateOpts, VolumeFiles, type VolumeInfo, VolumeLocks, type VolumeRemoveOpts, type VolumeRequestOpts, type VolumeWriteOpts, Volumes, WatchHandle, type WriteEntry, type WriteInfo, applyTransformation, codeSecurityConfigToJSON, contentGateConfigToJSON, createAuditConfig, createCodeSecurityConfig, createContentGateConfig, createEnvSecurityConfig, createInjectionDefenseConfig, createInvisibleTextConfig, createNetworkPolicy, createPIIConfig, createSecurityPolicy, createToxicityConfig, createTransformationRule, domainMatches, getSharedClient, invisibleTextConfigToJSON, isSensitive, networkPolicyToOpts, parseAuditConfig, parseAuditEntry, parseBuildInfo, parseCodeSecurityConfig, parseCommandResult, parseContentGateConfig, parseEntryInfo, parseEnvSecurityConfig, parseFileEntry, parseFileInfo, parseFilesystemEvent, parseGovernancePack, parseInjectionDefenseConfig, parseInvisibleTextConfig, parseLockLease, parseLockStatus, parseNetworkPolicy, parsePIIConfig, parseProcessInfo, parseSandboxInfo, parseSandboxLifecycle, parseSandboxMetrics, parseSecurityPolicy, parseSnapshot, parseSnapshotInfo, parseTemplateBuildStatus, parseToxicityConfig, parseVolumeInfo, parseWriteInfo, requiresTlsInterception, resetSharedClients, securityPolicyToJSON, toxicityConfigToJSON, validateNetworkEntry, volumeAttachmentToJSON };
|
|
1998
|
+
export { ALL_TRAFFIC, ApiClient, type AuditConfig, type AuditEntry, AuthenticationError, BuildError, type BuildInfo, type CodeSecurityConfig, CommandExitError, CommandHandle, type CommandResult, type CommandWaitOpts, Commands, ConflictError, ConnectionConfig, type ConnectionConfigOptions, type ContentGateConfig, type CopyItem, DEFAULT_MASK_PATTERNS, type EntryInfo, type EnvSecurityConfig, type FileEntry, type FileInfo, FileType, FileUploadError, Filesystem, type FilesystemEvent, FilesystemEventType, type FullInjectionDefenseOptions, type GetBuildStatusOpts, GitAuthError, GitUpstreamError, Governance, type GovernanceAdvisory, type GovernanceControl, type GovernancePack, type GovernanceRequestOpts, InjectionAction, type InjectionDefenseConfig, type InjectionJudgeConfig, InjectionSensitivity, InvalidArgumentError, type InvisibleTextConfig, type LockLease, type LockStatus, type NetworkPolicy, NotEnoughSpaceError, NotFoundError, type PIIConfig, PIIType, type ProcessInfo, Pty, type PtyConnectOpts, type PtyCreateOpts, PtyHandle, type PtyOutput, type PtyResult, type PtySize, RedactionAction, type RequestOpts, type RunOpts, type RunStreamOpts, Sandbox, SandboxError, type SandboxInfo, type SandboxLifecycle, type SandboxMetrics, type SandboxNetworkOpts, type SandboxOpts, SandboxPaginator, type SandboxQuery, SandboxState, type SecureEnvVar, type SecurityPolicy, type Snapshot, type SnapshotInfo, SnapshotPaginator, type SnapshotSource, type Stderr, Stdio, StdioProcess, type StdioResult, type StdioStartOpts, type Stdout, Template, TemplateBase, type TemplateBuildOpts, type TemplateBuildStatus, TemplateError, TimeoutError, type ToxicityConfig, TransformDirection, type TransformationRule, type VolumeAttachMode, type VolumeAttachment, type VolumeCreateOpts, VolumeFiles, type VolumeInfo, VolumeLocks, type VolumeRemoveOpts, type VolumeRequestOpts, type VolumeWriteOpts, Volumes, WatchHandle, type WriteEntry, type WriteInfo, applyTransformation, codeSecurityConfigToJSON, contentGateConfigToJSON, createAuditConfig, createCodeSecurityConfig, createContentGateConfig, createEnvSecurityConfig, createInjectionDefenseConfig, createInvisibleTextConfig, createNetworkPolicy, createPIIConfig, createSecurityPolicy, createToxicityConfig, createTransformationRule, domainMatches, fullInjectionDefensePolicy, getSharedClient, invisibleTextConfigToJSON, isSensitive, networkPolicyToOpts, parseAuditConfig, parseAuditEntry, parseBuildInfo, parseCodeSecurityConfig, parseCommandResult, parseContentGateConfig, parseEntryInfo, parseEnvSecurityConfig, parseFileEntry, parseFileInfo, parseFilesystemEvent, parseGovernancePack, parseInjectionDefenseConfig, parseInvisibleTextConfig, parseLockLease, parseLockStatus, parseNetworkPolicy, parsePIIConfig, parseProcessInfo, parseSandboxInfo, parseSandboxLifecycle, parseSandboxMetrics, parseSecurityPolicy, parseSnapshot, parseSnapshotInfo, parseTemplateBuildStatus, parseToxicityConfig, parseVolumeInfo, parseWriteInfo, requiresTlsInterception, resetSharedClients, securityPolicyToJSON, toxicityConfigToJSON, validateNetworkEntry, volumeAttachmentToJSON };
|
package/dist/index.d.ts
CHANGED
|
@@ -165,6 +165,22 @@ declare enum InjectionAction {
|
|
|
165
165
|
Block = "block",
|
|
166
166
|
LogOnly = "log_only"
|
|
167
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Tier-2 Gemma LLM-judge config. Layered on top of the Tier-1 classifier: the
|
|
170
|
+
* judge adjudicates the classifier's flags with session context, removing false
|
|
171
|
+
* positives and catching indirect (cross-domain / multi-turn) injection.
|
|
172
|
+
* Omitted → classifier only.
|
|
173
|
+
*/
|
|
174
|
+
interface InjectionJudgeConfig {
|
|
175
|
+
enabled: boolean;
|
|
176
|
+
/** Run the judge on every egress, not just classifier flags (costlier). */
|
|
177
|
+
always?: boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Natural-language description of what this agent may do; the judge uses it to
|
|
180
|
+
* tell task-aligned requests from injection-induced deviations.
|
|
181
|
+
*/
|
|
182
|
+
policy?: string;
|
|
183
|
+
}
|
|
168
184
|
/** Configuration for injection defense. */
|
|
169
185
|
interface InjectionDefenseConfig {
|
|
170
186
|
enabled: boolean;
|
|
@@ -174,6 +190,15 @@ interface InjectionDefenseConfig {
|
|
|
174
190
|
threshold: number;
|
|
175
191
|
/** Optional domain allowlist; when undefined, applies to all domains. */
|
|
176
192
|
domains?: string[];
|
|
193
|
+
/** Optional Tier-2 LLM judge. */
|
|
194
|
+
judge?: InjectionJudgeConfig;
|
|
195
|
+
/**
|
|
196
|
+
* Selects a predefined detection posture for the sandbox.
|
|
197
|
+
* Valid values: "strict", "balanced", "permissive", "agentic-tool",
|
|
198
|
+
* "data-egress-sensitive". Omit or set to undefined to use the server default.
|
|
199
|
+
* Serialized to JSON key "injection_mode".
|
|
200
|
+
*/
|
|
201
|
+
injectionMode?: string;
|
|
177
202
|
}
|
|
178
203
|
/**
|
|
179
204
|
* Create an InjectionDefenseConfig with defaults and validation.
|
|
@@ -416,6 +441,39 @@ interface SecurityPolicy {
|
|
|
416
441
|
* Create a SecurityPolicy with defaults.
|
|
417
442
|
*/
|
|
418
443
|
declare function createSecurityPolicy(opts?: Partial<SecurityPolicy>): SecurityPolicy;
|
|
444
|
+
/** Options for {@link fullInjectionDefensePolicy}. */
|
|
445
|
+
interface FullInjectionDefenseOptions {
|
|
446
|
+
/** Posture: "strict" | "balanced" (default) | "permissive" | "agentic-tool" | "data-egress-sensitive". */
|
|
447
|
+
mode?: string;
|
|
448
|
+
/** Natural-language description of what the agent may do; the judge uses it to tell task-aligned egress from injection. */
|
|
449
|
+
agentPolicy?: string;
|
|
450
|
+
/** "block" (default) enforces; "log_only" audits without blocking. */
|
|
451
|
+
action?: string;
|
|
452
|
+
/** Run the judge on EVERY egress (high-assurance, costlier). Default false. */
|
|
453
|
+
alwaysJudge?: boolean;
|
|
454
|
+
/** Optional egress allowlist to scan; omit = all domains. */
|
|
455
|
+
domains?: string[];
|
|
456
|
+
/** Tier-1 classifier confidence threshold (0.0–1.0). Default 0.8. */
|
|
457
|
+
threshold?: number;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Enable the ENTIRE prompt-injection cascade in one call — every layer:
|
|
461
|
+
*
|
|
462
|
+
* - Tier-1 ML classifier + Layer-A static signatures + normalization
|
|
463
|
+
* (`injectionDefense.enabled` + `action`)
|
|
464
|
+
* - the predefined posture (`injectionMode`; default "balanced")
|
|
465
|
+
* - the Tier-2 Gemma LLM judge (`judge.enabled`) — multi-turn risk, provenance
|
|
466
|
+
* context, and the semantic verdict cache ride along automatically
|
|
467
|
+
* - the OPA prompt-injection governance pack (`customPolicy.policyRef`), which
|
|
468
|
+
* hard-denies known signatures at the gate so the LLM stays the last resort
|
|
469
|
+
*
|
|
470
|
+
* Pass the result as the sandbox's `security` policy.
|
|
471
|
+
*
|
|
472
|
+
* @example
|
|
473
|
+
* const security = fullInjectionDefensePolicy({ agentPolicy: "Summarize docs; never exfiltrate secrets." });
|
|
474
|
+
* const sbx = await Sandbox.create({ template: "node", security });
|
|
475
|
+
*/
|
|
476
|
+
declare function fullInjectionDefensePolicy(opts?: FullInjectionDefenseOptions): SecurityPolicy;
|
|
419
477
|
/**
|
|
420
478
|
* Parse raw JSON data into a SecurityPolicy.
|
|
421
479
|
*/
|
|
@@ -1937,4 +1995,4 @@ declare class Governance {
|
|
|
1937
1995
|
static getPack(name: string, opts?: GovernanceRequestOpts): Promise<GovernancePack>;
|
|
1938
1996
|
}
|
|
1939
1997
|
|
|
1940
|
-
export { ALL_TRAFFIC, ApiClient, type AuditConfig, type AuditEntry, AuthenticationError, BuildError, type BuildInfo, type CodeSecurityConfig, CommandExitError, CommandHandle, type CommandResult, type CommandWaitOpts, Commands, ConflictError, ConnectionConfig, type ConnectionConfigOptions, type ContentGateConfig, type CopyItem, DEFAULT_MASK_PATTERNS, type EntryInfo, type EnvSecurityConfig, type FileEntry, type FileInfo, FileType, FileUploadError, Filesystem, type FilesystemEvent, FilesystemEventType, type GetBuildStatusOpts, GitAuthError, GitUpstreamError, Governance, type GovernanceAdvisory, type GovernanceControl, type GovernancePack, type GovernanceRequestOpts, InjectionAction, type InjectionDefenseConfig, InjectionSensitivity, InvalidArgumentError, type InvisibleTextConfig, type LockLease, type LockStatus, type NetworkPolicy, NotEnoughSpaceError, NotFoundError, type PIIConfig, PIIType, type ProcessInfo, Pty, type PtyConnectOpts, type PtyCreateOpts, PtyHandle, type PtyOutput, type PtyResult, type PtySize, RedactionAction, type RequestOpts, type RunOpts, type RunStreamOpts, Sandbox, SandboxError, type SandboxInfo, type SandboxLifecycle, type SandboxMetrics, type SandboxNetworkOpts, type SandboxOpts, SandboxPaginator, type SandboxQuery, SandboxState, type SecureEnvVar, type SecurityPolicy, type Snapshot, type SnapshotInfo, SnapshotPaginator, type SnapshotSource, type Stderr, Stdio, StdioProcess, type StdioResult, type StdioStartOpts, type Stdout, Template, TemplateBase, type TemplateBuildOpts, type TemplateBuildStatus, TemplateError, TimeoutError, type ToxicityConfig, TransformDirection, type TransformationRule, type VolumeAttachMode, type VolumeAttachment, type VolumeCreateOpts, VolumeFiles, type VolumeInfo, VolumeLocks, type VolumeRemoveOpts, type VolumeRequestOpts, type VolumeWriteOpts, Volumes, WatchHandle, type WriteEntry, type WriteInfo, applyTransformation, codeSecurityConfigToJSON, contentGateConfigToJSON, createAuditConfig, createCodeSecurityConfig, createContentGateConfig, createEnvSecurityConfig, createInjectionDefenseConfig, createInvisibleTextConfig, createNetworkPolicy, createPIIConfig, createSecurityPolicy, createToxicityConfig, createTransformationRule, domainMatches, getSharedClient, invisibleTextConfigToJSON, isSensitive, networkPolicyToOpts, parseAuditConfig, parseAuditEntry, parseBuildInfo, parseCodeSecurityConfig, parseCommandResult, parseContentGateConfig, parseEntryInfo, parseEnvSecurityConfig, parseFileEntry, parseFileInfo, parseFilesystemEvent, parseGovernancePack, parseInjectionDefenseConfig, parseInvisibleTextConfig, parseLockLease, parseLockStatus, parseNetworkPolicy, parsePIIConfig, parseProcessInfo, parseSandboxInfo, parseSandboxLifecycle, parseSandboxMetrics, parseSecurityPolicy, parseSnapshot, parseSnapshotInfo, parseTemplateBuildStatus, parseToxicityConfig, parseVolumeInfo, parseWriteInfo, requiresTlsInterception, resetSharedClients, securityPolicyToJSON, toxicityConfigToJSON, validateNetworkEntry, volumeAttachmentToJSON };
|
|
1998
|
+
export { ALL_TRAFFIC, ApiClient, type AuditConfig, type AuditEntry, AuthenticationError, BuildError, type BuildInfo, type CodeSecurityConfig, CommandExitError, CommandHandle, type CommandResult, type CommandWaitOpts, Commands, ConflictError, ConnectionConfig, type ConnectionConfigOptions, type ContentGateConfig, type CopyItem, DEFAULT_MASK_PATTERNS, type EntryInfo, type EnvSecurityConfig, type FileEntry, type FileInfo, FileType, FileUploadError, Filesystem, type FilesystemEvent, FilesystemEventType, type FullInjectionDefenseOptions, type GetBuildStatusOpts, GitAuthError, GitUpstreamError, Governance, type GovernanceAdvisory, type GovernanceControl, type GovernancePack, type GovernanceRequestOpts, InjectionAction, type InjectionDefenseConfig, type InjectionJudgeConfig, InjectionSensitivity, InvalidArgumentError, type InvisibleTextConfig, type LockLease, type LockStatus, type NetworkPolicy, NotEnoughSpaceError, NotFoundError, type PIIConfig, PIIType, type ProcessInfo, Pty, type PtyConnectOpts, type PtyCreateOpts, PtyHandle, type PtyOutput, type PtyResult, type PtySize, RedactionAction, type RequestOpts, type RunOpts, type RunStreamOpts, Sandbox, SandboxError, type SandboxInfo, type SandboxLifecycle, type SandboxMetrics, type SandboxNetworkOpts, type SandboxOpts, SandboxPaginator, type SandboxQuery, SandboxState, type SecureEnvVar, type SecurityPolicy, type Snapshot, type SnapshotInfo, SnapshotPaginator, type SnapshotSource, type Stderr, Stdio, StdioProcess, type StdioResult, type StdioStartOpts, type Stdout, Template, TemplateBase, type TemplateBuildOpts, type TemplateBuildStatus, TemplateError, TimeoutError, type ToxicityConfig, TransformDirection, type TransformationRule, type VolumeAttachMode, type VolumeAttachment, type VolumeCreateOpts, VolumeFiles, type VolumeInfo, VolumeLocks, type VolumeRemoveOpts, type VolumeRequestOpts, type VolumeWriteOpts, Volumes, WatchHandle, type WriteEntry, type WriteInfo, applyTransformation, codeSecurityConfigToJSON, contentGateConfigToJSON, createAuditConfig, createCodeSecurityConfig, createContentGateConfig, createEnvSecurityConfig, createInjectionDefenseConfig, createInvisibleTextConfig, createNetworkPolicy, createPIIConfig, createSecurityPolicy, createToxicityConfig, createTransformationRule, domainMatches, fullInjectionDefensePolicy, getSharedClient, invisibleTextConfigToJSON, isSensitive, networkPolicyToOpts, parseAuditConfig, parseAuditEntry, parseBuildInfo, parseCodeSecurityConfig, parseCommandResult, parseContentGateConfig, parseEntryInfo, parseEnvSecurityConfig, parseFileEntry, parseFileInfo, parseFilesystemEvent, parseGovernancePack, parseInjectionDefenseConfig, parseInvisibleTextConfig, parseLockLease, parseLockStatus, parseNetworkPolicy, parsePIIConfig, parseProcessInfo, parseSandboxInfo, parseSandboxLifecycle, parseSandboxMetrics, parseSecurityPolicy, parseSnapshot, parseSnapshotInfo, parseTemplateBuildStatus, parseToxicityConfig, parseVolumeInfo, parseWriteInfo, requiresTlsInterception, resetSharedClients, securityPolicyToJSON, toxicityConfigToJSON, validateNetworkEntry, volumeAttachmentToJSON };
|
package/dist/index.js
CHANGED
|
@@ -123,6 +123,8 @@ var CommandExitError = class extends SandboxError {
|
|
|
123
123
|
|
|
124
124
|
// src/api/client.ts
|
|
125
125
|
var _dispatcherPromise;
|
|
126
|
+
var _resolvedDispatcher;
|
|
127
|
+
var _dispatcherResolved = false;
|
|
126
128
|
function getDispatcher() {
|
|
127
129
|
if (_dispatcherPromise) return _dispatcherPromise;
|
|
128
130
|
_dispatcherPromise = (async () => {
|
|
@@ -135,7 +137,7 @@ function getDispatcher() {
|
|
|
135
137
|
}
|
|
136
138
|
const undici = await import("undici");
|
|
137
139
|
const connOverride = parseInt(process.env.DECLAW_SDK_CONNECTIONS || "", 10);
|
|
138
|
-
const connections = Number.isFinite(connOverride) && connOverride > 0 ? connOverride :
|
|
140
|
+
const connections = Number.isFinite(connOverride) && connOverride > 0 ? connOverride : 512;
|
|
139
141
|
const streamsOverride = parseInt(process.env.DECLAW_SDK_MAX_CONCURRENT_STREAMS || "", 10);
|
|
140
142
|
const maxConcurrentStreams = Number.isFinite(streamsOverride) && streamsOverride > 0 ? streamsOverride : 1e3;
|
|
141
143
|
return new undici.Agent({
|
|
@@ -147,7 +149,12 @@ function getDispatcher() {
|
|
|
147
149
|
maxConcurrentStreams,
|
|
148
150
|
keepAliveTimeout: 3e4,
|
|
149
151
|
keepAliveMaxTimeout: 6e4,
|
|
150
|
-
|
|
152
|
+
// NOTE: do NOT set `pipelining` here. undici applies it to H2 sessions
|
|
153
|
+
// too, where `pipelining: 1` caps each connection to ONE in-flight
|
|
154
|
+
// stream — silently defeating the H2 multiplexing that allowH2 enables.
|
|
155
|
+
// Omitted, H2 sessions default to unlimited concurrent streams (capped
|
|
156
|
+
// by maxConcurrentStreams) and H1.1 fallback defaults to 1 (safe, no
|
|
157
|
+
// head-of-line risk on non-idempotent POSTs).
|
|
151
158
|
allowH2: true,
|
|
152
159
|
connect: { keepAlive: true, keepAliveInitialDelay: 5e3 }
|
|
153
160
|
});
|
|
@@ -155,8 +162,13 @@ function getDispatcher() {
|
|
|
155
162
|
return void 0;
|
|
156
163
|
}
|
|
157
164
|
})();
|
|
165
|
+
void _dispatcherPromise.then((d) => {
|
|
166
|
+
_resolvedDispatcher = d;
|
|
167
|
+
_dispatcherResolved = true;
|
|
168
|
+
});
|
|
158
169
|
return _dispatcherPromise;
|
|
159
170
|
}
|
|
171
|
+
void getDispatcher();
|
|
160
172
|
var STATUS_ERROR_MAP = {
|
|
161
173
|
400: InvalidArgumentError,
|
|
162
174
|
401: AuthenticationError,
|
|
@@ -176,7 +188,7 @@ var ApiClient = class {
|
|
|
176
188
|
constructor(config, opts) {
|
|
177
189
|
this.config = config ?? new ConnectionConfig();
|
|
178
190
|
this.maxRetries = opts?.maxRetries ?? 3;
|
|
179
|
-
this.retryDelay = opts?.retryDelay ?? 0.
|
|
191
|
+
this.retryDelay = opts?.retryDelay ?? 0.1;
|
|
180
192
|
this.abortController = new AbortController();
|
|
181
193
|
}
|
|
182
194
|
/** Send a GET request and return parsed JSON. */
|
|
@@ -270,7 +282,7 @@ var ApiClient = class {
|
|
|
270
282
|
signals.push(AbortSignal.timeout(timeoutMs));
|
|
271
283
|
}
|
|
272
284
|
const signal = signals.length === 1 ? signals[0] : AbortSignal.any(signals);
|
|
273
|
-
const dispatcher = await getDispatcher();
|
|
285
|
+
const dispatcher = _dispatcherResolved ? _resolvedDispatcher : await getDispatcher();
|
|
274
286
|
const fetchOpts = {
|
|
275
287
|
method,
|
|
276
288
|
headers,
|
|
@@ -496,7 +508,9 @@ function createInjectionDefenseConfig(opts) {
|
|
|
496
508
|
sensitivity: opts?.sensitivity ?? "medium" /* Medium */,
|
|
497
509
|
action: opts?.action ?? "log_only" /* LogOnly */,
|
|
498
510
|
threshold: opts?.threshold ?? 0.8,
|
|
499
|
-
domains: opts?.domains
|
|
511
|
+
domains: opts?.domains,
|
|
512
|
+
judge: opts?.judge,
|
|
513
|
+
injectionMode: opts?.injectionMode
|
|
500
514
|
};
|
|
501
515
|
if (!VALID_SENSITIVITIES.has(config.sensitivity)) {
|
|
502
516
|
throw new InvalidArgumentError(
|
|
@@ -521,7 +535,9 @@ function parseInjectionDefenseConfig(data) {
|
|
|
521
535
|
sensitivity: data.sensitivity ?? "medium" /* Medium */,
|
|
522
536
|
action: data.action ?? "log_only" /* LogOnly */,
|
|
523
537
|
threshold: data.threshold ?? 0.8,
|
|
524
|
-
domains: data.domains
|
|
538
|
+
domains: data.domains,
|
|
539
|
+
judge: data.judge ? { enabled: data.judge.enabled ?? false, always: data.judge.always, policy: data.judge.policy } : void 0,
|
|
540
|
+
injectionMode: data.injection_mode ?? data.injectionMode
|
|
525
541
|
};
|
|
526
542
|
}
|
|
527
543
|
|
|
@@ -824,6 +840,15 @@ function invisibleTextConfigToJSON(config) {
|
|
|
824
840
|
}
|
|
825
841
|
|
|
826
842
|
// src/security/customPolicy.ts
|
|
843
|
+
function createCustomPolicyConfig(opts) {
|
|
844
|
+
return {
|
|
845
|
+
enabled: opts?.enabled ?? false,
|
|
846
|
+
inlineRego: opts?.inlineRego,
|
|
847
|
+
inlineModules: opts?.inlineModules,
|
|
848
|
+
policyRef: opts?.policyRef,
|
|
849
|
+
defaultDeny: opts?.defaultDeny ?? false
|
|
850
|
+
};
|
|
851
|
+
}
|
|
827
852
|
function parseCustomPolicyConfig(data) {
|
|
828
853
|
return {
|
|
829
854
|
enabled: data.enabled ?? false,
|
|
@@ -882,6 +907,23 @@ function createSecurityPolicy(opts) {
|
|
|
882
907
|
customPolicy: opts?.customPolicy
|
|
883
908
|
};
|
|
884
909
|
}
|
|
910
|
+
function fullInjectionDefensePolicy(opts) {
|
|
911
|
+
return createSecurityPolicy({
|
|
912
|
+
injectionDefense: createInjectionDefenseConfig({
|
|
913
|
+
enabled: true,
|
|
914
|
+
action: opts?.action ?? "block",
|
|
915
|
+
threshold: opts?.threshold ?? 0.8,
|
|
916
|
+
domains: opts?.domains,
|
|
917
|
+
injectionMode: opts?.mode ?? "balanced",
|
|
918
|
+
judge: { enabled: true, always: opts?.alwaysJudge ?? false, policy: opts?.agentPolicy ?? "" }
|
|
919
|
+
}),
|
|
920
|
+
customPolicy: createCustomPolicyConfig({
|
|
921
|
+
enabled: true,
|
|
922
|
+
policyRef: "prompt-injection@v2",
|
|
923
|
+
defaultDeny: false
|
|
924
|
+
})
|
|
925
|
+
});
|
|
926
|
+
}
|
|
885
927
|
function parseSecurityPolicy(data) {
|
|
886
928
|
const injDef = data.injection_defense ?? data.injectionDefense;
|
|
887
929
|
const auditData = data.audit;
|
|
@@ -921,6 +963,15 @@ function securityPolicyToJSON(policy) {
|
|
|
921
963
|
if (injDefConfig.domains !== void 0) {
|
|
922
964
|
injDef.domains = injDefConfig.domains;
|
|
923
965
|
}
|
|
966
|
+
if (injDefConfig.injectionMode !== void 0) {
|
|
967
|
+
injDef.injection_mode = injDefConfig.injectionMode;
|
|
968
|
+
}
|
|
969
|
+
if (injDefConfig.judge !== void 0) {
|
|
970
|
+
const j = { enabled: injDefConfig.judge.enabled };
|
|
971
|
+
if (injDefConfig.judge.always) j.always = true;
|
|
972
|
+
if (injDefConfig.judge.policy) j.policy = injDefConfig.judge.policy;
|
|
973
|
+
injDef.judge = j;
|
|
974
|
+
}
|
|
924
975
|
const auditConfig = typeof policy.audit === "boolean" ? createAuditConfig({ enabled: policy.audit }) : policy.audit;
|
|
925
976
|
const audit = {
|
|
926
977
|
enabled: auditConfig.enabled
|
|
@@ -3403,6 +3454,7 @@ export {
|
|
|
3403
3454
|
createToxicityConfig,
|
|
3404
3455
|
createTransformationRule,
|
|
3405
3456
|
domainMatches,
|
|
3457
|
+
fullInjectionDefensePolicy,
|
|
3406
3458
|
getSharedClient,
|
|
3407
3459
|
invisibleTextConfigToJSON,
|
|
3408
3460
|
isSensitive,
|