agentid-sdk 0.1.22 → 0.1.24
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 +73 -0
- package/dist/{agentid-BmsXTOCc.d.mts → agentid-BGCUoYV7.d.mts} +17 -2
- package/dist/{agentid-BmsXTOCc.d.ts → agentid-BGCUoYV7.d.ts} +17 -2
- package/dist/{chunk-FVTL572H.mjs → chunk-JLHAS2EE.mjs} +235 -32
- package/dist/index.d.mts +25 -2
- package/dist/index.d.ts +25 -2
- package/dist/index.js +396 -32
- package/dist/index.mjs +161 -1
- package/dist/langchain.d.mts +1 -1
- package/dist/langchain.d.ts +1 -1
- package/dist/langchain.js +50 -5
- package/dist/langchain.mjs +50 -5
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -109,6 +109,8 @@ const response = await secured.chat.completions.create({
|
|
|
109
109
|
console.log(response.choices[0]?.message?.content ?? "");
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
+
> Scope note: AgentID compliance/risk controls apply to the specific SDK-wrapped LLM calls (`guard()`, `wrapOpenAI()`, LangChain callback-wrapped flows). They do not automatically classify unrelated code paths in your whole monolithic application.
|
|
113
|
+
|
|
112
114
|
### LangChain Integration
|
|
113
115
|
|
|
114
116
|
```bash
|
|
@@ -159,6 +161,27 @@ await agent.log({
|
|
|
159
161
|
});
|
|
160
162
|
```
|
|
161
163
|
|
|
164
|
+
### Transparency Badge (Article 50 UI Evidence)
|
|
165
|
+
|
|
166
|
+
When rendering disclosure UI, log proof-of-render telemetry so you can demonstrate the end-user actually saw the badge.
|
|
167
|
+
|
|
168
|
+
```tsx
|
|
169
|
+
import { AgentIDTransparencyBadge } from "agentid-sdk";
|
|
170
|
+
|
|
171
|
+
<AgentIDTransparencyBadge
|
|
172
|
+
telemetry={{
|
|
173
|
+
systemId: process.env.NEXT_PUBLIC_AGENTID_SYSTEM_ID!,
|
|
174
|
+
// Prefer a backend relay endpoint so no secret key is exposed in browser code.
|
|
175
|
+
ingestUrl: "/api/agentid/transparency-render",
|
|
176
|
+
headers: { "x-agentid-system-id": process.env.NEXT_PUBLIC_AGENTID_SYSTEM_ID! },
|
|
177
|
+
userId: "customer-123",
|
|
178
|
+
}}
|
|
179
|
+
placement="chat-header"
|
|
180
|
+
/>;
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
On mount, the component asynchronously emits `event_type: "transparency_badge_rendered"` to the AgentID ingest endpoint.
|
|
184
|
+
|
|
162
185
|
## 6. Advanced Configuration
|
|
163
186
|
|
|
164
187
|
### Custom identity / role metadata
|
|
@@ -205,6 +228,56 @@ By default, AgentID is designed to keep your application running if the AgentID
|
|
|
205
228
|
- 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.
|
|
206
229
|
- Ingest retries transient failures (5xx/429) and logs warnings if persistence fails.
|
|
207
230
|
|
|
231
|
+
### Event Identity Model
|
|
232
|
+
|
|
233
|
+
For consistent lifecycle correlation in Activity/Prompts, use this model:
|
|
234
|
+
|
|
235
|
+
- `client_event_id`: external correlation ID for one end-to-end action.
|
|
236
|
+
- `guard_event_id`: ID of the preflight guard event returned by `guard()`.
|
|
237
|
+
- `event_id` on `log()`: idempotency key for ingest. In the JS SDK it is canonicalized to `client_event_id` for stable one-row lifecycle updates.
|
|
238
|
+
|
|
239
|
+
SDK behavior:
|
|
240
|
+
|
|
241
|
+
- `guard()` sends `client_event_id` and returns canonical `client_event_id` + `guard_event_id`.
|
|
242
|
+
- `log()` sends:
|
|
243
|
+
- `event_id = canonical client_event_id`
|
|
244
|
+
- `metadata.client_event_id`
|
|
245
|
+
- `metadata.guard_event_id` (when available from wrappers/callbacks)
|
|
246
|
+
- `x-correlation-id = client_event_id`
|
|
247
|
+
- SDK requests include `x-agentid-sdk-version` for telemetry/version diagnostics.
|
|
248
|
+
|
|
249
|
+
This keeps Guard + Complete linked under one correlation key while preserving internal event linkage in the dashboard.
|
|
250
|
+
|
|
251
|
+
### Policy-Pack Runtime Telemetry
|
|
252
|
+
|
|
253
|
+
When the backend uses compiled policy packs, runtime metadata includes:
|
|
254
|
+
|
|
255
|
+
- `policy_pack_version`: active compiled artifact version.
|
|
256
|
+
- `policy_pack_fallback`: `true` means fallback detector path was used.
|
|
257
|
+
- `policy_pack_details`: optional diagnostic detail for fallback/decision trace.
|
|
258
|
+
|
|
259
|
+
Latency interpretation:
|
|
260
|
+
|
|
261
|
+
- Activity `Latency (ms)` maps to synchronous processing (`processing_time_ms`).
|
|
262
|
+
- Async AI audit time is separate (`ai_audit_duration_ms`) and can be higher.
|
|
263
|
+
- First request after warm-up boundaries can be slower than steady-state requests.
|
|
264
|
+
|
|
265
|
+
### Monorepo QA Commands (Maintainers)
|
|
266
|
+
|
|
267
|
+
If you are validating runtime in the AgentID monorepo:
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
npm run qa:policy-pack-bootstrap -- --base-url=http://127.0.0.1:3000/api/v1 --system-id=<SYSTEM_UUID>
|
|
271
|
+
npm run bench:policy-pack-hotpath
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
PowerShell diagnostics:
|
|
275
|
+
|
|
276
|
+
```powershell
|
|
277
|
+
powershell -ExecutionPolicy Bypass -File .\scripts\qa\run-guard-diagnostic.ps1 -BaseUrl http://127.0.0.1:3000/api/v1 -ApiKey $env:AGENTID_API_KEY -SystemId $env:AGENTID_SYSTEM_ID -SkipBenchmark
|
|
278
|
+
powershell -ExecutionPolicy Bypass -File .\scripts\qa\run-ai-label-audit-check.ps1 -BaseUrl http://127.0.0.1:3000/api/v1 -ApiKey $env:AGENTID_API_KEY -SystemId $env:AGENTID_SYSTEM_ID -Model gpt-4o-mini
|
|
279
|
+
```
|
|
280
|
+
|
|
208
281
|
## 7. Security & Compliance
|
|
209
282
|
|
|
210
283
|
- Optional local PII masking and local policy enforcement before model dispatch.
|
|
@@ -3,6 +3,7 @@ type CapabilityConfig = {
|
|
|
3
3
|
strict_security_mode: boolean;
|
|
4
4
|
failure_mode: "fail_open" | "fail_close";
|
|
5
5
|
block_on_heuristic: boolean;
|
|
6
|
+
inject_transparency_metadata: boolean;
|
|
6
7
|
block_pii_leakage: boolean;
|
|
7
8
|
block_db_access: boolean;
|
|
8
9
|
block_code_execution: boolean;
|
|
@@ -15,6 +16,7 @@ interface GuardParams {
|
|
|
15
16
|
model?: string;
|
|
16
17
|
user_id?: string;
|
|
17
18
|
client_event_id?: string;
|
|
19
|
+
expected_languages?: string[];
|
|
18
20
|
client_capabilities?: {
|
|
19
21
|
capabilities: {
|
|
20
22
|
has_feedback_handler: boolean;
|
|
@@ -30,8 +32,21 @@ interface GuardResponse {
|
|
|
30
32
|
transformed_input?: string;
|
|
31
33
|
guard_event_id?: string;
|
|
32
34
|
client_event_id?: string;
|
|
35
|
+
guard_latency_ms?: number;
|
|
33
36
|
shadow_mode?: boolean;
|
|
34
37
|
simulated_decision?: "allowed" | "masked" | "blocked";
|
|
38
|
+
shadow_blocked?: boolean;
|
|
39
|
+
policy_pack_matcher_backend?: "rust_wasm" | "js_hybrid" | "legacy_fallback";
|
|
40
|
+
policy_pack_scan_profile?: "expected_languages" | "core_en_fallback";
|
|
41
|
+
policy_pack_scan_mode?: "full" | "segmented";
|
|
42
|
+
exotic_language_detected?: boolean;
|
|
43
|
+
transparency?: TransparencyMetadata;
|
|
44
|
+
}
|
|
45
|
+
interface TransparencyMetadata {
|
|
46
|
+
is_ai_generated: true;
|
|
47
|
+
disclosure: "You are interacting with an AI.";
|
|
48
|
+
article: "EU_AI_ACT_ARTICLE_50";
|
|
49
|
+
injection_mode: "deterministic";
|
|
35
50
|
}
|
|
36
51
|
interface RequestOptions {
|
|
37
52
|
apiKey?: string;
|
|
@@ -47,7 +62,7 @@ interface LogParams {
|
|
|
47
62
|
latency?: number;
|
|
48
63
|
user_id?: string;
|
|
49
64
|
metadata?: Record<string, unknown>;
|
|
50
|
-
event_type?: "start" | "complete" | "error" | "human_override" | "security_alert" | "security_block" | "security_policy_violation";
|
|
65
|
+
event_type?: "start" | "complete" | "error" | "human_override" | "security_alert" | "security_block" | "security_policy_violation" | "transparency_badge_rendered";
|
|
51
66
|
severity?: "info" | "warning" | "error" | "high";
|
|
52
67
|
timestamp?: string;
|
|
53
68
|
client_capabilities?: {
|
|
@@ -150,4 +165,4 @@ declare class AgentID {
|
|
|
150
165
|
}): T;
|
|
151
166
|
}
|
|
152
167
|
|
|
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 };
|
|
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 };
|
|
@@ -3,6 +3,7 @@ type CapabilityConfig = {
|
|
|
3
3
|
strict_security_mode: boolean;
|
|
4
4
|
failure_mode: "fail_open" | "fail_close";
|
|
5
5
|
block_on_heuristic: boolean;
|
|
6
|
+
inject_transparency_metadata: boolean;
|
|
6
7
|
block_pii_leakage: boolean;
|
|
7
8
|
block_db_access: boolean;
|
|
8
9
|
block_code_execution: boolean;
|
|
@@ -15,6 +16,7 @@ interface GuardParams {
|
|
|
15
16
|
model?: string;
|
|
16
17
|
user_id?: string;
|
|
17
18
|
client_event_id?: string;
|
|
19
|
+
expected_languages?: string[];
|
|
18
20
|
client_capabilities?: {
|
|
19
21
|
capabilities: {
|
|
20
22
|
has_feedback_handler: boolean;
|
|
@@ -30,8 +32,21 @@ interface GuardResponse {
|
|
|
30
32
|
transformed_input?: string;
|
|
31
33
|
guard_event_id?: string;
|
|
32
34
|
client_event_id?: string;
|
|
35
|
+
guard_latency_ms?: number;
|
|
33
36
|
shadow_mode?: boolean;
|
|
34
37
|
simulated_decision?: "allowed" | "masked" | "blocked";
|
|
38
|
+
shadow_blocked?: boolean;
|
|
39
|
+
policy_pack_matcher_backend?: "rust_wasm" | "js_hybrid" | "legacy_fallback";
|
|
40
|
+
policy_pack_scan_profile?: "expected_languages" | "core_en_fallback";
|
|
41
|
+
policy_pack_scan_mode?: "full" | "segmented";
|
|
42
|
+
exotic_language_detected?: boolean;
|
|
43
|
+
transparency?: TransparencyMetadata;
|
|
44
|
+
}
|
|
45
|
+
interface TransparencyMetadata {
|
|
46
|
+
is_ai_generated: true;
|
|
47
|
+
disclosure: "You are interacting with an AI.";
|
|
48
|
+
article: "EU_AI_ACT_ARTICLE_50";
|
|
49
|
+
injection_mode: "deterministic";
|
|
35
50
|
}
|
|
36
51
|
interface RequestOptions {
|
|
37
52
|
apiKey?: string;
|
|
@@ -47,7 +62,7 @@ interface LogParams {
|
|
|
47
62
|
latency?: number;
|
|
48
63
|
user_id?: string;
|
|
49
64
|
metadata?: Record<string, unknown>;
|
|
50
|
-
event_type?: "start" | "complete" | "error" | "human_override" | "security_alert" | "security_block" | "security_policy_violation";
|
|
65
|
+
event_type?: "start" | "complete" | "error" | "human_override" | "security_alert" | "security_block" | "security_policy_violation" | "transparency_badge_rendered";
|
|
51
66
|
severity?: "info" | "warning" | "error" | "high";
|
|
52
67
|
timestamp?: string;
|
|
53
68
|
client_capabilities?: {
|
|
@@ -150,4 +165,4 @@ declare class AgentID {
|
|
|
150
165
|
}): T;
|
|
151
166
|
}
|
|
152
167
|
|
|
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 };
|
|
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 };
|