@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/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
@@ -137,7 +137,7 @@ function getDispatcher() {
137
137
  }
138
138
  const undici = await import("undici");
139
139
  const connOverride = parseInt(process.env.DECLAW_SDK_CONNECTIONS || "", 10);
140
- const connections = Number.isFinite(connOverride) && connOverride > 0 ? connOverride : 64;
140
+ const connections = Number.isFinite(connOverride) && connOverride > 0 ? connOverride : 512;
141
141
  const streamsOverride = parseInt(process.env.DECLAW_SDK_MAX_CONCURRENT_STREAMS || "", 10);
142
142
  const maxConcurrentStreams = Number.isFinite(streamsOverride) && streamsOverride > 0 ? streamsOverride : 1e3;
143
143
  return new undici.Agent({
@@ -154,9 +154,7 @@ function getDispatcher() {
154
154
  // stream — silently defeating the H2 multiplexing that allowH2 enables.
155
155
  // Omitted, H2 sessions default to unlimited concurrent streams (capped
156
156
  // by maxConcurrentStreams) and H1.1 fallback defaults to 1 (safe, no
157
- // head-of-line risk on non-idempotent POSTs). This is the single
158
- // biggest burst-latency lever: with pipelining:1 a 100-concurrent burst
159
- // queued ~36 requests behind the `connections` cap.
157
+ // head-of-line risk on non-idempotent POSTs).
160
158
  allowH2: true,
161
159
  connect: { keepAlive: true, keepAliveInitialDelay: 5e3 }
162
160
  });
@@ -510,7 +508,9 @@ function createInjectionDefenseConfig(opts) {
510
508
  sensitivity: opts?.sensitivity ?? "medium" /* Medium */,
511
509
  action: opts?.action ?? "log_only" /* LogOnly */,
512
510
  threshold: opts?.threshold ?? 0.8,
513
- domains: opts?.domains
511
+ domains: opts?.domains,
512
+ judge: opts?.judge,
513
+ injectionMode: opts?.injectionMode
514
514
  };
515
515
  if (!VALID_SENSITIVITIES.has(config.sensitivity)) {
516
516
  throw new InvalidArgumentError(
@@ -535,7 +535,9 @@ function parseInjectionDefenseConfig(data) {
535
535
  sensitivity: data.sensitivity ?? "medium" /* Medium */,
536
536
  action: data.action ?? "log_only" /* LogOnly */,
537
537
  threshold: data.threshold ?? 0.8,
538
- 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
539
541
  };
540
542
  }
541
543
 
@@ -838,6 +840,15 @@ function invisibleTextConfigToJSON(config) {
838
840
  }
839
841
 
840
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
+ }
841
852
  function parseCustomPolicyConfig(data) {
842
853
  return {
843
854
  enabled: data.enabled ?? false,
@@ -896,6 +907,23 @@ function createSecurityPolicy(opts) {
896
907
  customPolicy: opts?.customPolicy
897
908
  };
898
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
+ }
899
927
  function parseSecurityPolicy(data) {
900
928
  const injDef = data.injection_defense ?? data.injectionDefense;
901
929
  const auditData = data.audit;
@@ -935,6 +963,15 @@ function securityPolicyToJSON(policy) {
935
963
  if (injDefConfig.domains !== void 0) {
936
964
  injDef.domains = injDefConfig.domains;
937
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
+ }
938
975
  const auditConfig = typeof policy.audit === "boolean" ? createAuditConfig({ enabled: policy.audit }) : policy.audit;
939
976
  const audit = {
940
977
  enabled: auditConfig.enabled
@@ -3417,6 +3454,7 @@ export {
3417
3454
  createToxicityConfig,
3418
3455
  createTransformationRule,
3419
3456
  domainMatches,
3457
+ fullInjectionDefensePolicy,
3420
3458
  getSharedClient,
3421
3459
  invisibleTextConfigToJSON,
3422
3460
  isSensitive,