@declaw/sdk 1.2.1 → 1.2.3

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
@@ -510,7 +510,9 @@ function createInjectionDefenseConfig(opts) {
510
510
  sensitivity: opts?.sensitivity ?? "medium" /* Medium */,
511
511
  action: opts?.action ?? "log_only" /* LogOnly */,
512
512
  threshold: opts?.threshold ?? 0.8,
513
- domains: opts?.domains
513
+ domains: opts?.domains,
514
+ judge: opts?.judge,
515
+ injectionMode: opts?.injectionMode
514
516
  };
515
517
  if (!VALID_SENSITIVITIES.has(config.sensitivity)) {
516
518
  throw new InvalidArgumentError(
@@ -535,7 +537,9 @@ function parseInjectionDefenseConfig(data) {
535
537
  sensitivity: data.sensitivity ?? "medium" /* Medium */,
536
538
  action: data.action ?? "log_only" /* LogOnly */,
537
539
  threshold: data.threshold ?? 0.8,
538
- domains: data.domains
540
+ domains: data.domains,
541
+ judge: data.judge ? { enabled: data.judge.enabled ?? false, always: data.judge.always, policy: data.judge.policy } : void 0,
542
+ injectionMode: data.injection_mode ?? data.injectionMode
539
543
  };
540
544
  }
541
545
 
@@ -838,6 +842,15 @@ function invisibleTextConfigToJSON(config) {
838
842
  }
839
843
 
840
844
  // src/security/customPolicy.ts
845
+ function createCustomPolicyConfig(opts) {
846
+ return {
847
+ enabled: opts?.enabled ?? false,
848
+ inlineRego: opts?.inlineRego,
849
+ inlineModules: opts?.inlineModules,
850
+ policyRef: opts?.policyRef,
851
+ defaultDeny: opts?.defaultDeny ?? false
852
+ };
853
+ }
841
854
  function parseCustomPolicyConfig(data) {
842
855
  return {
843
856
  enabled: data.enabled ?? false,
@@ -896,6 +909,23 @@ function createSecurityPolicy(opts) {
896
909
  customPolicy: opts?.customPolicy
897
910
  };
898
911
  }
912
+ function fullInjectionDefensePolicy(opts) {
913
+ return createSecurityPolicy({
914
+ injectionDefense: createInjectionDefenseConfig({
915
+ enabled: true,
916
+ action: opts?.action ?? "block",
917
+ threshold: opts?.threshold ?? 0.8,
918
+ domains: opts?.domains,
919
+ injectionMode: opts?.mode ?? "balanced",
920
+ judge: { enabled: true, always: opts?.alwaysJudge ?? false, policy: opts?.agentPolicy ?? "" }
921
+ }),
922
+ customPolicy: createCustomPolicyConfig({
923
+ enabled: true,
924
+ policyRef: "prompt-injection@v2",
925
+ defaultDeny: false
926
+ })
927
+ });
928
+ }
899
929
  function parseSecurityPolicy(data) {
900
930
  const injDef = data.injection_defense ?? data.injectionDefense;
901
931
  const auditData = data.audit;
@@ -935,6 +965,15 @@ function securityPolicyToJSON(policy) {
935
965
  if (injDefConfig.domains !== void 0) {
936
966
  injDef.domains = injDefConfig.domains;
937
967
  }
968
+ if (injDefConfig.injectionMode !== void 0) {
969
+ injDef.injection_mode = injDefConfig.injectionMode;
970
+ }
971
+ if (injDefConfig.judge !== void 0) {
972
+ const j = { enabled: injDefConfig.judge.enabled };
973
+ if (injDefConfig.judge.always) j.always = true;
974
+ if (injDefConfig.judge.policy) j.policy = injDefConfig.judge.policy;
975
+ injDef.judge = j;
976
+ }
938
977
  const auditConfig = typeof policy.audit === "boolean" ? createAuditConfig({ enabled: policy.audit }) : policy.audit;
939
978
  const audit = {
940
979
  enabled: auditConfig.enabled
@@ -3417,6 +3456,7 @@ export {
3417
3456
  createToxicityConfig,
3418
3457
  createTransformationRule,
3419
3458
  domainMatches,
3459
+ fullInjectionDefensePolicy,
3420
3460
  getSharedClient,
3421
3461
  invisibleTextConfigToJSON,
3422
3462
  isSensitive,