agentid-sdk 0.1.24 → 0.1.25

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/README.md CHANGED
@@ -99,6 +99,7 @@ const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY! });
99
99
  const secured = agent.wrapOpenAI(openai, {
100
100
  system_id: process.env.AGENTID_SYSTEM_ID!,
101
101
  user_id: "customer-123",
102
+ expected_languages: ["en"],
102
103
  });
103
104
 
104
105
  const response = await secured.chat.completions.create({
@@ -127,6 +128,7 @@ import { StringOutputParser } from "@langchain/core/output_parsers";
127
128
  const agent = new AgentID();
128
129
  const handler = new AgentIDCallbackHandler(agent, {
129
130
  system_id: process.env.AGENTID_SYSTEM_ID!,
131
+ expected_languages: ["en"],
130
132
  });
131
133
 
132
134
  const prompt = ChatPromptTemplate.fromTemplate("Answer in one sentence: {question}");
@@ -5,6 +5,7 @@ type CapabilityConfig = {
5
5
  block_on_heuristic: boolean;
6
6
  inject_transparency_metadata: boolean;
7
7
  block_pii_leakage: boolean;
8
+ enable_sdk_pii_masking?: boolean;
8
9
  block_db_access: boolean;
9
10
  block_code_execution: boolean;
10
11
  block_toxicity: boolean;
@@ -37,9 +38,14 @@ interface GuardResponse {
37
38
  simulated_decision?: "allowed" | "masked" | "blocked";
38
39
  shadow_blocked?: boolean;
39
40
  policy_pack_matcher_backend?: "rust_wasm" | "js_hybrid" | "legacy_fallback";
40
- policy_pack_scan_profile?: "expected_languages" | "core_en_fallback";
41
+ policy_pack_scan_profile?: "expected_languages" | "auto_detected" | "global_high_priority" | "core_en_fallback";
41
42
  policy_pack_scan_mode?: "full" | "segmented";
42
43
  exotic_language_detected?: boolean;
44
+ langid_primary?: string;
45
+ langid_confidence?: "high" | "medium" | "low";
46
+ langid_secondary?: string[];
47
+ langid_mixed?: boolean;
48
+ langid_source?: "input_detection" | "input_detection_with_hint";
43
49
  transparency?: TransparencyMetadata;
44
50
  }
45
51
  interface TransparencyMetadata {
@@ -51,6 +57,10 @@ interface TransparencyMetadata {
51
57
  interface RequestOptions {
52
58
  apiKey?: string;
53
59
  }
60
+ type InjectionScanRequestOptions = RequestOptions & {
61
+ clientEventId?: string;
62
+ systemId?: string;
63
+ };
54
64
  interface LogParams {
55
65
  event_id?: string;
56
66
  system_id?: string;
@@ -81,6 +91,7 @@ type AgentIDConfig = {
81
91
  aiScanEnabled?: boolean;
82
92
  storePii?: boolean;
83
93
  strictMode?: boolean;
94
+ failureMode?: "fail_open" | "fail_close";
84
95
  guardTimeoutMs?: number;
85
96
  ingestTimeoutMs?: number;
86
97
  };
@@ -93,14 +104,25 @@ declare class SecurityBlockError extends Error {
93
104
  reason: string;
94
105
  constructor(reason?: string);
95
106
  }
107
+ declare class DependencyError extends Error {
108
+ dependency: "ingest";
109
+ reason: string;
110
+ status: number | null;
111
+ constructor(params: {
112
+ dependency: "ingest";
113
+ reason: string;
114
+ status: number | null;
115
+ });
116
+ }
96
117
  declare class AgentID {
97
118
  private baseUrl;
98
119
  private apiKey;
99
- private piiMasking;
120
+ private configuredPiiMasking;
100
121
  private checkInjection;
101
122
  private aiScanEnabled;
102
123
  private storePii;
103
124
  private strictMode;
125
+ private configuredFailureMode;
104
126
  private guardTimeoutMs;
105
127
  private ingestTimeoutMs;
106
128
  private pii;
@@ -108,6 +130,9 @@ declare class AgentID {
108
130
  private injectionScanner;
109
131
  private recentGuardVerdicts;
110
132
  constructor(config?: AgentIDConfig);
133
+ get piiMasking(): boolean | undefined;
134
+ private resolveEffectivePiiMasking;
135
+ getEffectivePiiMasking(options?: RequestOptions): boolean;
111
136
  private buildClientCapabilities;
112
137
  private resolveApiKey;
113
138
  private resolveClientEventId;
@@ -117,6 +142,7 @@ declare class AgentID {
117
142
  getCapabilityConfig(force?: boolean, options?: RequestOptions): Promise<CapabilityConfig>;
118
143
  private getCachedCapabilityConfig;
119
144
  private resolveEffectiveStrictMode;
145
+ private maybeRaiseStrictIngestDependencyError;
120
146
  private shouldRunLocalInjectionScan;
121
147
  prepareInputForDispatch(params: {
122
148
  input: string;
@@ -124,7 +150,7 @@ declare class AgentID {
124
150
  stream: boolean;
125
151
  skipInjectionScan?: boolean;
126
152
  }, options?: RequestOptions): Promise<PreparedInput>;
127
- scanPromptInjection(input: string, options?: RequestOptions): Promise<void>;
153
+ scanPromptInjection(input: string, options?: InjectionScanRequestOptions): Promise<void>;
128
154
  private withMaskedOpenAIRequest;
129
155
  private logSecurityPolicyViolation;
130
156
  private logGuardFallback;
@@ -159,10 +185,12 @@ declare class AgentID {
159
185
  wrapOpenAI<T>(openai: T, options: {
160
186
  system_id: string;
161
187
  user_id?: string;
188
+ expected_languages?: string[];
189
+ expectedLanguages?: string[];
162
190
  apiKey?: string;
163
191
  api_key?: string;
164
192
  resolveApiKey?: (request: Record<string, unknown>) => string | undefined;
165
193
  }): T;
166
194
  }
167
195
 
168
- export { AgentID as A, type GuardParams as G, type LogParams as L, type PreparedInput as P, type RequestOptions as R, SecurityBlockError as S, type TransparencyMetadata as T, type GuardResponse as a };
196
+ export { AgentID as A, DependencyError as D, type GuardParams as G, type LogParams as L, type PreparedInput as P, type RequestOptions as R, SecurityBlockError as S, type TransparencyMetadata as T, type GuardResponse as a };
@@ -5,6 +5,7 @@ type CapabilityConfig = {
5
5
  block_on_heuristic: boolean;
6
6
  inject_transparency_metadata: boolean;
7
7
  block_pii_leakage: boolean;
8
+ enable_sdk_pii_masking?: boolean;
8
9
  block_db_access: boolean;
9
10
  block_code_execution: boolean;
10
11
  block_toxicity: boolean;
@@ -37,9 +38,14 @@ interface GuardResponse {
37
38
  simulated_decision?: "allowed" | "masked" | "blocked";
38
39
  shadow_blocked?: boolean;
39
40
  policy_pack_matcher_backend?: "rust_wasm" | "js_hybrid" | "legacy_fallback";
40
- policy_pack_scan_profile?: "expected_languages" | "core_en_fallback";
41
+ policy_pack_scan_profile?: "expected_languages" | "auto_detected" | "global_high_priority" | "core_en_fallback";
41
42
  policy_pack_scan_mode?: "full" | "segmented";
42
43
  exotic_language_detected?: boolean;
44
+ langid_primary?: string;
45
+ langid_confidence?: "high" | "medium" | "low";
46
+ langid_secondary?: string[];
47
+ langid_mixed?: boolean;
48
+ langid_source?: "input_detection" | "input_detection_with_hint";
43
49
  transparency?: TransparencyMetadata;
44
50
  }
45
51
  interface TransparencyMetadata {
@@ -51,6 +57,10 @@ interface TransparencyMetadata {
51
57
  interface RequestOptions {
52
58
  apiKey?: string;
53
59
  }
60
+ type InjectionScanRequestOptions = RequestOptions & {
61
+ clientEventId?: string;
62
+ systemId?: string;
63
+ };
54
64
  interface LogParams {
55
65
  event_id?: string;
56
66
  system_id?: string;
@@ -81,6 +91,7 @@ type AgentIDConfig = {
81
91
  aiScanEnabled?: boolean;
82
92
  storePii?: boolean;
83
93
  strictMode?: boolean;
94
+ failureMode?: "fail_open" | "fail_close";
84
95
  guardTimeoutMs?: number;
85
96
  ingestTimeoutMs?: number;
86
97
  };
@@ -93,14 +104,25 @@ declare class SecurityBlockError extends Error {
93
104
  reason: string;
94
105
  constructor(reason?: string);
95
106
  }
107
+ declare class DependencyError extends Error {
108
+ dependency: "ingest";
109
+ reason: string;
110
+ status: number | null;
111
+ constructor(params: {
112
+ dependency: "ingest";
113
+ reason: string;
114
+ status: number | null;
115
+ });
116
+ }
96
117
  declare class AgentID {
97
118
  private baseUrl;
98
119
  private apiKey;
99
- private piiMasking;
120
+ private configuredPiiMasking;
100
121
  private checkInjection;
101
122
  private aiScanEnabled;
102
123
  private storePii;
103
124
  private strictMode;
125
+ private configuredFailureMode;
104
126
  private guardTimeoutMs;
105
127
  private ingestTimeoutMs;
106
128
  private pii;
@@ -108,6 +130,9 @@ declare class AgentID {
108
130
  private injectionScanner;
109
131
  private recentGuardVerdicts;
110
132
  constructor(config?: AgentIDConfig);
133
+ get piiMasking(): boolean | undefined;
134
+ private resolveEffectivePiiMasking;
135
+ getEffectivePiiMasking(options?: RequestOptions): boolean;
111
136
  private buildClientCapabilities;
112
137
  private resolveApiKey;
113
138
  private resolveClientEventId;
@@ -117,6 +142,7 @@ declare class AgentID {
117
142
  getCapabilityConfig(force?: boolean, options?: RequestOptions): Promise<CapabilityConfig>;
118
143
  private getCachedCapabilityConfig;
119
144
  private resolveEffectiveStrictMode;
145
+ private maybeRaiseStrictIngestDependencyError;
120
146
  private shouldRunLocalInjectionScan;
121
147
  prepareInputForDispatch(params: {
122
148
  input: string;
@@ -124,7 +150,7 @@ declare class AgentID {
124
150
  stream: boolean;
125
151
  skipInjectionScan?: boolean;
126
152
  }, options?: RequestOptions): Promise<PreparedInput>;
127
- scanPromptInjection(input: string, options?: RequestOptions): Promise<void>;
153
+ scanPromptInjection(input: string, options?: InjectionScanRequestOptions): Promise<void>;
128
154
  private withMaskedOpenAIRequest;
129
155
  private logSecurityPolicyViolation;
130
156
  private logGuardFallback;
@@ -159,10 +185,12 @@ declare class AgentID {
159
185
  wrapOpenAI<T>(openai: T, options: {
160
186
  system_id: string;
161
187
  user_id?: string;
188
+ expected_languages?: string[];
189
+ expectedLanguages?: string[];
162
190
  apiKey?: string;
163
191
  api_key?: string;
164
192
  resolveApiKey?: (request: Record<string, unknown>) => string | undefined;
165
193
  }): T;
166
194
  }
167
195
 
168
- export { AgentID as A, type GuardParams as G, type LogParams as L, type PreparedInput as P, type RequestOptions as R, SecurityBlockError as S, type TransparencyMetadata as T, type GuardResponse as a };
196
+ export { AgentID as A, DependencyError as D, type GuardParams as G, type LogParams as L, type PreparedInput as P, type RequestOptions as R, SecurityBlockError as S, type TransparencyMetadata as T, type GuardResponse as a };