agentid-sdk 0.1.6 → 0.1.8

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.
@@ -1,4 +1,5 @@
1
1
  type CapabilityConfig = {
2
+ shadow_mode: boolean;
2
3
  block_pii_leakage: boolean;
3
4
  block_db_access: boolean;
4
5
  block_code_execution: boolean;
@@ -8,6 +9,7 @@ type CapabilityConfig = {
8
9
  interface GuardParams {
9
10
  input: string;
10
11
  system_id: string;
12
+ model?: string;
11
13
  user_id?: string;
12
14
  client_capabilities?: {
13
15
  capabilities: {
@@ -21,6 +23,9 @@ interface GuardResponse {
21
23
  allowed: boolean;
22
24
  reason?: string;
23
25
  detected_pii?: boolean;
26
+ transformed_input?: string;
27
+ shadow_mode?: boolean;
28
+ simulated_decision?: "allowed" | "masked" | "blocked";
24
29
  }
25
30
  interface RequestOptions {
26
31
  apiKey?: string;
@@ -88,12 +93,15 @@ declare class AgentID {
88
93
  scanPromptInjection(input: string, options?: RequestOptions): Promise<void>;
89
94
  private withMaskedOpenAIRequest;
90
95
  private logSecurityPolicyViolation;
96
+ private logGuardFallback;
91
97
  /**
92
98
  * GUARD: Checks limits, PII, and security before execution.
93
99
  * strictMode=false (default): FAIL-OPEN on connectivity/timeouts.
94
100
  * strictMode=true: FAIL-CLOSED and throws on connectivity/timeouts.
95
101
  */
96
102
  guard(params: GuardParams, options?: RequestOptions): Promise<GuardResponse>;
103
+ private extractStreamChunkText;
104
+ private wrapCompletion;
97
105
  /**
98
106
  * LOG: Sends telemetry after execution.
99
107
  * Non-blocking / Fire-and-forget.
@@ -1,4 +1,5 @@
1
1
  type CapabilityConfig = {
2
+ shadow_mode: boolean;
2
3
  block_pii_leakage: boolean;
3
4
  block_db_access: boolean;
4
5
  block_code_execution: boolean;
@@ -8,6 +9,7 @@ type CapabilityConfig = {
8
9
  interface GuardParams {
9
10
  input: string;
10
11
  system_id: string;
12
+ model?: string;
11
13
  user_id?: string;
12
14
  client_capabilities?: {
13
15
  capabilities: {
@@ -21,6 +23,9 @@ interface GuardResponse {
21
23
  allowed: boolean;
22
24
  reason?: string;
23
25
  detected_pii?: boolean;
26
+ transformed_input?: string;
27
+ shadow_mode?: boolean;
28
+ simulated_decision?: "allowed" | "masked" | "blocked";
24
29
  }
25
30
  interface RequestOptions {
26
31
  apiKey?: string;
@@ -88,12 +93,15 @@ declare class AgentID {
88
93
  scanPromptInjection(input: string, options?: RequestOptions): Promise<void>;
89
94
  private withMaskedOpenAIRequest;
90
95
  private logSecurityPolicyViolation;
96
+ private logGuardFallback;
91
97
  /**
92
98
  * GUARD: Checks limits, PII, and security before execution.
93
99
  * strictMode=false (default): FAIL-OPEN on connectivity/timeouts.
94
100
  * strictMode=true: FAIL-CLOSED and throws on connectivity/timeouts.
95
101
  */
96
102
  guard(params: GuardParams, options?: RequestOptions): Promise<GuardResponse>;
103
+ private extractStreamChunkText;
104
+ private wrapCompletion;
97
105
  /**
98
106
  * LOG: Sends telemetry after execution.
99
107
  * Non-blocking / Fire-and-forget.
@@ -1 +1 @@
1
- export { a as AgentIDCallbackHandler } from './langchain-C6HJAK2b.mjs';
1
+ export { a as AgentIDCallbackHandler } from './langchain-DPMzxdoO.mjs';
@@ -1 +1 @@
1
- export { a as AgentIDCallbackHandler } from './langchain-C6HJAK2b.js';
1
+ export { a as AgentIDCallbackHandler } from './langchain-DPMzxdoO.js';
package/dist/langchain.js CHANGED
@@ -193,8 +193,17 @@ var AgentIDCallbackHandler = class {
193
193
  if (!verdict.allowed) {
194
194
  throw new Error(`AgentID: Security Blocked (${verdict.reason ?? "guard_denied"})`);
195
195
  }
196
+ const transformedInput = typeof verdict.transformed_input === "string" && verdict.transformed_input.length > 0 ? verdict.transformed_input : sanitizedInput;
197
+ if (transformedInput !== sanitizedInput) {
198
+ const mutated = setPromptInPrompts(prompts, transformedInput);
199
+ if (!mutated) {
200
+ throw new Error(
201
+ "AgentID: Guard transformed input could not be applied to LangChain prompt payload."
202
+ );
203
+ }
204
+ }
196
205
  this.runs.set(id, {
197
- input: sanitizedInput,
206
+ input: transformedInput,
198
207
  startedAtMs: Date.now(),
199
208
  model: extractModel(serialized, extraParams)
200
209
  });
@@ -223,8 +232,17 @@ var AgentIDCallbackHandler = class {
223
232
  if (!verdict.allowed) {
224
233
  throw new Error(`AgentID: Security Blocked (${verdict.reason ?? "guard_denied"})`);
225
234
  }
235
+ const transformedInput = typeof verdict.transformed_input === "string" && verdict.transformed_input.length > 0 ? verdict.transformed_input : sanitizedInput;
236
+ if (transformedInput !== sanitizedInput) {
237
+ const mutated = setPromptInMessages(messages, transformedInput);
238
+ if (!mutated) {
239
+ throw new Error(
240
+ "AgentID: Guard transformed input could not be applied to LangChain message payload."
241
+ );
242
+ }
243
+ }
226
244
  this.runs.set(id, {
227
- input: sanitizedInput,
245
+ input: transformedInput,
228
246
  startedAtMs: Date.now(),
229
247
  model: extractModel(serialized, extraParams)
230
248
  });
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AgentIDCallbackHandler
3
- } from "./chunk-LWL2WG5B.mjs";
3
+ } from "./chunk-DXUA5DKG.mjs";
4
4
  export {
5
5
  AgentIDCallbackHandler
6
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentid-sdk",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "AgentID JavaScript/TypeScript SDK for guard, ingest, tracing, and analytics.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://agentid.ai",