agentid-sdk 0.1.19 → 0.1.21
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 +34 -4
- package/dist/{langchain-DJDqqpbT.d.mts → agentid-BmsXTOCc.d.mts} +9 -29
- package/dist/{langchain-DJDqqpbT.d.ts → agentid-BmsXTOCc.d.ts} +9 -29
- package/dist/chunk-4FSHABTE.mjs +2831 -0
- package/dist/index.d.mts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +75 -433
- package/dist/index.mjs +9 -2762
- package/dist/langchain.d.mts +30 -2
- package/dist/langchain.d.ts +30 -2
- package/dist/langchain.js +190 -2
- package/dist/langchain.mjs +423 -2
- package/package.json +1 -1
- package/dist/chunk-6YR4ECGB.mjs +0 -424
package/README.md
CHANGED
|
@@ -9,6 +9,23 @@
|
|
|
9
9
|
|
|
10
10
|
`agentid-sdk` is the official Node.js/TypeScript SDK for AgentID, an AI security and compliance System of Record. It allows you to gate LLM traffic through guard checks, enforce policy before execution, and capture durable telemetry for audit and governance workflows.
|
|
11
11
|
|
|
12
|
+
### The Mental Model
|
|
13
|
+
|
|
14
|
+
AgentID sits between your application and the LLM runtime:
|
|
15
|
+
|
|
16
|
+
```text
|
|
17
|
+
User Input -> guard() -> [AgentID Policy] -> verdict
|
|
18
|
+
| allowed
|
|
19
|
+
v
|
|
20
|
+
LLM Provider
|
|
21
|
+
v
|
|
22
|
+
log() -> [Immutable Ledger]
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
- `guard()`: evaluates prompt and context before model execution.
|
|
26
|
+
- Model call: executes only if guard verdict is allowed.
|
|
27
|
+
- `log()`: persists immutable telemetry (prompt, output, latency) for audit and compliance.
|
|
28
|
+
|
|
12
29
|
## 2. Installation
|
|
13
30
|
|
|
14
31
|
```bash
|
|
@@ -30,6 +47,12 @@ export AGENTID_SYSTEM_ID="00000000-0000-0000-0000-000000000000"
|
|
|
30
47
|
export OPENAI_API_KEY="sk-proj-..."
|
|
31
48
|
```
|
|
32
49
|
|
|
50
|
+
### Compatibility
|
|
51
|
+
|
|
52
|
+
- **Node.js:** v18+ / **Python:** 3.9+ (cross-SDK matrix)
|
|
53
|
+
- **Thread Safety:** AgentID clients are thread-safe and intended to be instantiated once and reused across concurrent requests.
|
|
54
|
+
- **Latency:** async `log()` is non-blocking for model execution paths; sync `guard()` typically adds network latency (commonly ~50-100ms, environment-dependent).
|
|
55
|
+
|
|
33
56
|
## 4. Quickstart
|
|
34
57
|
|
|
35
58
|
```ts
|
|
@@ -163,16 +186,23 @@ await agent.log({
|
|
|
163
186
|
const agent = new AgentID({
|
|
164
187
|
strictMode: true, // fail-closed on guard connectivity/timeouts
|
|
165
188
|
guardTimeoutMs: 10000, // default guard timeout is 10000ms
|
|
189
|
+
ingestTimeoutMs: 10000 // default ingest timeout is 10000ms
|
|
166
190
|
});
|
|
167
191
|
```
|
|
168
192
|
|
|
169
|
-
### Error
|
|
193
|
+
### Error Handling & Strict Mode
|
|
194
|
+
|
|
195
|
+
By default, AgentID is designed to keep your application running if the AgentID API has a timeout or is temporarily unreachable.
|
|
196
|
+
|
|
197
|
+
| Mode | Connectivity Failure | LLM Execution | Best For |
|
|
198
|
+
| :--- | :--- | :--- | :--- |
|
|
199
|
+
| **Default** (Strict Off) | API Timeout / Unreachable | **Fail-Open** (continues) | Standard SaaS, chatbots |
|
|
200
|
+
| **Strict Mode** (`strictMode: true`) | API Timeout / Unreachable | **Fail-Closed** (blocks) | Healthcare, FinTech, high-risk |
|
|
170
201
|
|
|
171
202
|
- `guard()` returns a verdict (`allowed`, `reason`); handle deny paths explicitly.
|
|
172
|
-
- `wrapOpenAI()`
|
|
173
|
-
- Default mode is fail-open for connectivity/timeouts (`timeout_fallback`, `guard_unreachable`, `system_failure_fail_open`).
|
|
203
|
+
- `wrapOpenAI()` and LangChain handlers throw `SecurityBlockError` when a prompt is blocked.
|
|
174
204
|
- If `strictMode` is not explicitly set in SDK code, runtime behavior follows the system configuration from AgentID (`strict_security_mode` / `failure_mode`).
|
|
175
|
-
-
|
|
205
|
+
- Local prompt-injection heuristics are enabled only when dashboard policy enables injection blocking (`block_on_heuristic` / legacy injection flags). `strictMode` does not force local heuristic blocking.
|
|
176
206
|
- Ingest retries transient failures (5xx/429) and logs warnings if persistence fails.
|
|
177
207
|
|
|
178
208
|
## 7. Security & Compliance
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { BaseCallbackHandler } from '@langchain/core/callbacks/base';
|
|
2
|
-
|
|
3
1
|
type CapabilityConfig = {
|
|
4
2
|
shadow_mode: boolean;
|
|
5
3
|
strict_security_mode: boolean;
|
|
6
4
|
failure_mode: "fail_open" | "fail_close";
|
|
5
|
+
block_on_heuristic: boolean;
|
|
7
6
|
block_pii_leakage: boolean;
|
|
8
7
|
block_db_access: boolean;
|
|
9
8
|
block_code_execution: boolean;
|
|
@@ -68,12 +67,17 @@ type AgentIDConfig = {
|
|
|
68
67
|
storePii?: boolean;
|
|
69
68
|
strictMode?: boolean;
|
|
70
69
|
guardTimeoutMs?: number;
|
|
70
|
+
ingestTimeoutMs?: number;
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
type PreparedInput = {
|
|
74
74
|
sanitizedInput: string;
|
|
75
75
|
capabilityConfig: CapabilityConfig;
|
|
76
76
|
};
|
|
77
|
+
declare class SecurityBlockError extends Error {
|
|
78
|
+
reason: string;
|
|
79
|
+
constructor(reason?: string);
|
|
80
|
+
}
|
|
77
81
|
declare class AgentID {
|
|
78
82
|
private baseUrl;
|
|
79
83
|
private apiKey;
|
|
@@ -83,6 +87,7 @@ declare class AgentID {
|
|
|
83
87
|
private storePii;
|
|
84
88
|
private strictMode;
|
|
85
89
|
private guardTimeoutMs;
|
|
90
|
+
private ingestTimeoutMs;
|
|
86
91
|
private pii;
|
|
87
92
|
private localEnforcer;
|
|
88
93
|
private injectionScanner;
|
|
@@ -97,6 +102,7 @@ declare class AgentID {
|
|
|
97
102
|
getCapabilityConfig(force?: boolean, options?: RequestOptions): Promise<CapabilityConfig>;
|
|
98
103
|
private getCachedCapabilityConfig;
|
|
99
104
|
private resolveEffectiveStrictMode;
|
|
105
|
+
private shouldRunLocalInjectionScan;
|
|
100
106
|
prepareInputForDispatch(params: {
|
|
101
107
|
input: string;
|
|
102
108
|
systemId: string;
|
|
@@ -144,30 +150,4 @@ declare class AgentID {
|
|
|
144
150
|
}): T;
|
|
145
151
|
}
|
|
146
152
|
|
|
147
|
-
|
|
148
|
-
* LangChainJS callback handler (dependency-free shape).
|
|
149
|
-
*
|
|
150
|
-
* Usage (LangChain):
|
|
151
|
-
* callbacks: [new AgentIDCallbackHandler(agent, { system_id: "..." })]
|
|
152
|
-
*/
|
|
153
|
-
declare class AgentIDCallbackHandler extends BaseCallbackHandler {
|
|
154
|
-
name: string;
|
|
155
|
-
private agent;
|
|
156
|
-
private systemId;
|
|
157
|
-
private apiKeyOverride?;
|
|
158
|
-
private runs;
|
|
159
|
-
constructor(agent: AgentID, options: {
|
|
160
|
-
system_id: string;
|
|
161
|
-
apiKey?: string;
|
|
162
|
-
api_key?: string;
|
|
163
|
-
});
|
|
164
|
-
private get requestOptions();
|
|
165
|
-
private getLangchainCapabilities;
|
|
166
|
-
private preflight;
|
|
167
|
-
handleLLMStart(serialized: unknown, prompts: unknown, runId?: string, _parentRunId?: string, extraParams?: unknown): Promise<void>;
|
|
168
|
-
handleChatModelStart(serialized: unknown, messages: unknown, runId?: string, _parentRunId?: string, extraParams?: unknown): Promise<void>;
|
|
169
|
-
handleLLMEnd(output: unknown, runId?: string): Promise<void>;
|
|
170
|
-
handleLLMError(err: unknown, runId?: string): Promise<void>;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export { AgentID as A, type GuardParams as G, type LogParams as L, type PreparedInput as P, type RequestOptions as R, AgentIDCallbackHandler as a, type GuardResponse as b };
|
|
153
|
+
export { AgentID as A, type GuardParams as G, type LogParams as L, type PreparedInput as P, type RequestOptions as R, SecurityBlockError as S, type GuardResponse as a };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { BaseCallbackHandler } from '@langchain/core/callbacks/base';
|
|
2
|
-
|
|
3
1
|
type CapabilityConfig = {
|
|
4
2
|
shadow_mode: boolean;
|
|
5
3
|
strict_security_mode: boolean;
|
|
6
4
|
failure_mode: "fail_open" | "fail_close";
|
|
5
|
+
block_on_heuristic: boolean;
|
|
7
6
|
block_pii_leakage: boolean;
|
|
8
7
|
block_db_access: boolean;
|
|
9
8
|
block_code_execution: boolean;
|
|
@@ -68,12 +67,17 @@ type AgentIDConfig = {
|
|
|
68
67
|
storePii?: boolean;
|
|
69
68
|
strictMode?: boolean;
|
|
70
69
|
guardTimeoutMs?: number;
|
|
70
|
+
ingestTimeoutMs?: number;
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
type PreparedInput = {
|
|
74
74
|
sanitizedInput: string;
|
|
75
75
|
capabilityConfig: CapabilityConfig;
|
|
76
76
|
};
|
|
77
|
+
declare class SecurityBlockError extends Error {
|
|
78
|
+
reason: string;
|
|
79
|
+
constructor(reason?: string);
|
|
80
|
+
}
|
|
77
81
|
declare class AgentID {
|
|
78
82
|
private baseUrl;
|
|
79
83
|
private apiKey;
|
|
@@ -83,6 +87,7 @@ declare class AgentID {
|
|
|
83
87
|
private storePii;
|
|
84
88
|
private strictMode;
|
|
85
89
|
private guardTimeoutMs;
|
|
90
|
+
private ingestTimeoutMs;
|
|
86
91
|
private pii;
|
|
87
92
|
private localEnforcer;
|
|
88
93
|
private injectionScanner;
|
|
@@ -97,6 +102,7 @@ declare class AgentID {
|
|
|
97
102
|
getCapabilityConfig(force?: boolean, options?: RequestOptions): Promise<CapabilityConfig>;
|
|
98
103
|
private getCachedCapabilityConfig;
|
|
99
104
|
private resolveEffectiveStrictMode;
|
|
105
|
+
private shouldRunLocalInjectionScan;
|
|
100
106
|
prepareInputForDispatch(params: {
|
|
101
107
|
input: string;
|
|
102
108
|
systemId: string;
|
|
@@ -144,30 +150,4 @@ declare class AgentID {
|
|
|
144
150
|
}): T;
|
|
145
151
|
}
|
|
146
152
|
|
|
147
|
-
|
|
148
|
-
* LangChainJS callback handler (dependency-free shape).
|
|
149
|
-
*
|
|
150
|
-
* Usage (LangChain):
|
|
151
|
-
* callbacks: [new AgentIDCallbackHandler(agent, { system_id: "..." })]
|
|
152
|
-
*/
|
|
153
|
-
declare class AgentIDCallbackHandler extends BaseCallbackHandler {
|
|
154
|
-
name: string;
|
|
155
|
-
private agent;
|
|
156
|
-
private systemId;
|
|
157
|
-
private apiKeyOverride?;
|
|
158
|
-
private runs;
|
|
159
|
-
constructor(agent: AgentID, options: {
|
|
160
|
-
system_id: string;
|
|
161
|
-
apiKey?: string;
|
|
162
|
-
api_key?: string;
|
|
163
|
-
});
|
|
164
|
-
private get requestOptions();
|
|
165
|
-
private getLangchainCapabilities;
|
|
166
|
-
private preflight;
|
|
167
|
-
handleLLMStart(serialized: unknown, prompts: unknown, runId?: string, _parentRunId?: string, extraParams?: unknown): Promise<void>;
|
|
168
|
-
handleChatModelStart(serialized: unknown, messages: unknown, runId?: string, _parentRunId?: string, extraParams?: unknown): Promise<void>;
|
|
169
|
-
handleLLMEnd(output: unknown, runId?: string): Promise<void>;
|
|
170
|
-
handleLLMError(err: unknown, runId?: string): Promise<void>;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export { AgentID as A, type GuardParams as G, type LogParams as L, type PreparedInput as P, type RequestOptions as R, AgentIDCallbackHandler as a, type GuardResponse as b };
|
|
153
|
+
export { AgentID as A, type GuardParams as G, type LogParams as L, type PreparedInput as P, type RequestOptions as R, SecurityBlockError as S, type GuardResponse as a };
|