agentid-sdk 0.1.30 → 0.1.32
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/LICENSE +20 -20
- package/README.md +337 -337
- package/dist/{agentid-agvYW2vW.d.mts → agentid-BgahmiuN.d.mts} +2 -0
- package/dist/{agentid-agvYW2vW.d.ts → agentid-BgahmiuN.d.ts} +2 -0
- package/dist/{chunk-W3LROAHO.mjs → chunk-Z2M5A4YZ.mjs} +52 -11
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +52 -11
- package/dist/index.mjs +1 -1
- package/dist/langchain.d.mts +1 -1
- package/dist/langchain.d.ts +1 -1
- package/dist/langchain.js +3 -2
- package/dist/langchain.mjs +1 -1
- package/dist/transparency-badge.d.mts +1 -1
- package/dist/transparency-badge.d.ts +1 -1
- package/package.json +69 -69
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 AgentID
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AgentID
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,337 +1,337 @@
|
|
|
1
|
-
# agentid-sdk (Node.js / TypeScript)
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/agentid-sdk)
|
|
4
|
-
[](https://www.npmjs.com/package/agentid-sdk)
|
|
5
|
-
[](https://nodejs.org/)
|
|
6
|
-
[](LICENSE)
|
|
7
|
-
|
|
8
|
-
## 1. Introduction
|
|
9
|
-
|
|
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
|
-
|
|
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
|
-
|
|
29
|
-
## 2. Installation
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
npm install agentid-sdk
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## 3. Prerequisites
|
|
36
|
-
|
|
37
|
-
1. Create an account at `https://app.getagentid.com`.
|
|
38
|
-
2. Create an AI system and copy:
|
|
39
|
-
- `AGENTID_API_KEY` (for example `sk_live_...`)
|
|
40
|
-
- `AGENTID_SYSTEM_ID` (UUID)
|
|
41
|
-
3. If using OpenAI/LangChain, set:
|
|
42
|
-
- `OPENAI_API_KEY`
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
export AGENTID_API_KEY="sk_live_..."
|
|
46
|
-
export AGENTID_SYSTEM_ID="00000000-0000-0000-0000-000000000000"
|
|
47
|
-
export OPENAI_API_KEY="sk-proj-..."
|
|
48
|
-
```
|
|
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
|
-
|
|
56
|
-
## 4. Quickstart
|
|
57
|
-
|
|
58
|
-
```ts
|
|
59
|
-
import { AgentID } from "agentid-sdk";
|
|
60
|
-
|
|
61
|
-
const agent = new AgentID(); // auto-loads AGENTID_API_KEY
|
|
62
|
-
const systemId = process.env.AGENTID_SYSTEM_ID!;
|
|
63
|
-
|
|
64
|
-
const verdict = await agent.guard({
|
|
65
|
-
system_id: systemId,
|
|
66
|
-
input: "Summarize this ticket in one sentence.",
|
|
67
|
-
model: "gpt-4o-mini",
|
|
68
|
-
user_id: "quickstart-user",
|
|
69
|
-
});
|
|
70
|
-
if (!verdict.allowed) throw new Error(`Blocked: ${verdict.reason}`);
|
|
71
|
-
|
|
72
|
-
await agent.log({
|
|
73
|
-
system_id: systemId,
|
|
74
|
-
event_id: verdict.client_event_id,
|
|
75
|
-
model: "gpt-4o-mini",
|
|
76
|
-
input: "Summarize this ticket in one sentence.",
|
|
77
|
-
output: "Summary generated.",
|
|
78
|
-
metadata: { agent_role: "support-assistant" },
|
|
79
|
-
});
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
## 5. Core Integrations
|
|
83
|
-
|
|
84
|
-
### OpenAI Wrapper
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
npm install agentid-sdk openai
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
```ts
|
|
91
|
-
import OpenAI from "openai";
|
|
92
|
-
import { AgentID } from "agentid-sdk";
|
|
93
|
-
|
|
94
|
-
const agent = new AgentID({
|
|
95
|
-
piiMasking: true,
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY! });
|
|
99
|
-
const secured = agent.wrapOpenAI(openai, {
|
|
100
|
-
system_id: process.env.AGENTID_SYSTEM_ID!,
|
|
101
|
-
user_id: "customer-123",
|
|
102
|
-
expected_languages: ["en"],
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
const response = await secured.chat.completions.create({
|
|
106
|
-
model: "gpt-4o-mini",
|
|
107
|
-
messages: [{ role: "user", content: "What is the capital of the Czech Republic?" }],
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
console.log(response.choices[0]?.message?.content ?? "");
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
Wrapped OpenAI calls persist telemetry for both regular and streamed completions. For `stream: true`, logging happens when the stream finishes.
|
|
114
|
-
|
|
115
|
-
> 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.
|
|
116
|
-
|
|
117
|
-
### Vercel AI SDK Wrapper
|
|
118
|
-
|
|
119
|
-
If your app already uses Vercel AI SDK primitives such as `generateText()` or `streamText()`, prefer the dedicated wrapper package instead of rebuilding the lifecycle manually:
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
npm install ai agentid-vercel-sdk @ai-sdk/openai
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
`agentid-vercel-sdk` keeps AgentID backend-first by default, blocks before provider billing on denied prompts, and finalizes telemetry after completion or stream close.
|
|
126
|
-
|
|
127
|
-
### LangChain Integration
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
npm install agentid-sdk openai @langchain/core @langchain/openai
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
```ts
|
|
134
|
-
import { AgentID } from "agentid-sdk";
|
|
135
|
-
import { AgentIDCallbackHandler } from "agentid-sdk/langchain";
|
|
136
|
-
import { ChatOpenAI } from "@langchain/openai";
|
|
137
|
-
import { ChatPromptTemplate } from "@langchain/core/prompts";
|
|
138
|
-
import { StringOutputParser } from "@langchain/core/output_parsers";
|
|
139
|
-
|
|
140
|
-
const agent = new AgentID();
|
|
141
|
-
const handler = new AgentIDCallbackHandler(agent, {
|
|
142
|
-
system_id: process.env.AGENTID_SYSTEM_ID!,
|
|
143
|
-
expected_languages: ["en"],
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
const prompt = ChatPromptTemplate.fromTemplate("Answer in one sentence: {question}");
|
|
147
|
-
const model = new ChatOpenAI({
|
|
148
|
-
apiKey: process.env.OPENAI_API_KEY!,
|
|
149
|
-
model: "gpt-4o-mini",
|
|
150
|
-
});
|
|
151
|
-
const chain = prompt.pipe(model).pipe(new StringOutputParser());
|
|
152
|
-
|
|
153
|
-
const result = await chain.invoke(
|
|
154
|
-
{ question: "What is the capital of the Czech Republic?" },
|
|
155
|
-
{ callbacks: [handler] }
|
|
156
|
-
);
|
|
157
|
-
console.log(result);
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
LangChain callbacks log on run completion. Token/cost telemetry for streamed chains depends on the provider exposing usage in the final LangChain result.
|
|
161
|
-
|
|
162
|
-
### Raw Ingest API (Telemetry Only)
|
|
163
|
-
|
|
164
|
-
```ts
|
|
165
|
-
import { AgentID } from "agentid-sdk";
|
|
166
|
-
|
|
167
|
-
const agent = new AgentID();
|
|
168
|
-
|
|
169
|
-
await agent.log({
|
|
170
|
-
system_id: process.env.AGENTID_SYSTEM_ID!,
|
|
171
|
-
event_type: "complete",
|
|
172
|
-
severity: "info",
|
|
173
|
-
model: "gpt-4o-mini",
|
|
174
|
-
input: "Raw telemetry prompt",
|
|
175
|
-
output: '{"ok": true}',
|
|
176
|
-
metadata: { agent_role: "batch-worker", channel: "manual_ingest" },
|
|
177
|
-
});
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
### Transparency Badge (Article 50 UI Evidence)
|
|
181
|
-
|
|
182
|
-
When rendering disclosure UI, log proof-of-render telemetry so you can demonstrate the end-user actually saw the badge.
|
|
183
|
-
|
|
184
|
-
```tsx
|
|
185
|
-
import { AgentIDTransparencyBadge } from "agentid-sdk/transparency-badge";
|
|
186
|
-
|
|
187
|
-
<AgentIDTransparencyBadge
|
|
188
|
-
telemetry={{
|
|
189
|
-
systemId: process.env.NEXT_PUBLIC_AGENTID_SYSTEM_ID!,
|
|
190
|
-
// Prefer a backend relay endpoint so no secret key is exposed in browser code.
|
|
191
|
-
ingestUrl: "/api/agentid/transparency-render",
|
|
192
|
-
headers: { "x-agentid-system-id": process.env.NEXT_PUBLIC_AGENTID_SYSTEM_ID! },
|
|
193
|
-
userId: "customer-123",
|
|
194
|
-
}}
|
|
195
|
-
placement="chat-header"
|
|
196
|
-
/>;
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
On mount, the component asynchronously emits `event_type: "transparency_badge_rendered"` to the AgentID ingest endpoint.
|
|
200
|
-
|
|
201
|
-
## 6. Advanced Configuration
|
|
202
|
-
|
|
203
|
-
### Custom identity / role metadata
|
|
204
|
-
|
|
205
|
-
```ts
|
|
206
|
-
await agent.guard({
|
|
207
|
-
system_id: process.env.AGENTID_SYSTEM_ID!,
|
|
208
|
-
input: "Process user request",
|
|
209
|
-
user_id: "service:billing-agent",
|
|
210
|
-
model: "gpt-4o-mini",
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
await agent.log({
|
|
214
|
-
system_id: process.env.AGENTID_SYSTEM_ID!,
|
|
215
|
-
model: "gpt-4o-mini",
|
|
216
|
-
input: "Process user request",
|
|
217
|
-
output: "Done",
|
|
218
|
-
metadata: { agent_role: "billing-agent", environment: "prod" },
|
|
219
|
-
});
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
### Strict mode and timeout tuning
|
|
223
|
-
|
|
224
|
-
```ts
|
|
225
|
-
const agent = new AgentID({
|
|
226
|
-
strictMode: true, // fail-closed on guard connectivity/timeouts
|
|
227
|
-
guardTimeoutMs: 10000, // default guard timeout is 10000ms
|
|
228
|
-
ingestTimeoutMs: 10000 // default ingest timeout is 10000ms
|
|
229
|
-
});
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
### Optional client-side fast fail
|
|
233
|
-
|
|
234
|
-
```ts
|
|
235
|
-
const agent = new AgentID({
|
|
236
|
-
failureMode: "fail_close",
|
|
237
|
-
clientFastFail: true, // opt-in local preflight before /guard
|
|
238
|
-
});
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
### Error Handling & Strict Mode
|
|
242
|
-
|
|
243
|
-
By default, AgentID is designed to keep your application running if the AgentID API has a timeout or is temporarily unreachable.
|
|
244
|
-
|
|
245
|
-
| Mode | Connectivity Failure | LLM Execution | Best For |
|
|
246
|
-
| :--- | :--- | :--- | :--- |
|
|
247
|
-
| **Default** (Strict Off) | API Timeout / Unreachable | **Fail-Open** (continues) | Standard SaaS, chatbots |
|
|
248
|
-
| **Strict Mode** (`strictMode: true`) | API Timeout / Unreachable | Direct `guard()` denies; wrapped flows can apply local fallback first | Healthcare, FinTech, high-risk |
|
|
249
|
-
|
|
250
|
-
- `guard()` returns a verdict (`allowed`, `reason`); handle deny paths explicitly.
|
|
251
|
-
- `wrapOpenAI()` and LangChain handlers throw `SecurityBlockError` when a prompt is blocked.
|
|
252
|
-
- Backend `/guard` is the default authority for prompt injection, DB access, code execution, and PII leakage in SDK-wrapped flows.
|
|
253
|
-
- `clientFastFail` / `client_fast_fail` is optional and disabled by default. Enable it only when you explicitly want local preflight before the backend call.
|
|
254
|
-
- If backend guard is unreachable and the effective failure mode is `fail_close`, wrapped OpenAI/LangChain flows can run local fallback enforcement. Local hits still block; otherwise the request can continue with fallback telemetry attached.
|
|
255
|
-
- If `strictMode` is not explicitly set in SDK code, runtime behavior follows the system configuration from AgentID (`strict_security_mode` / `failure_mode`).
|
|
256
|
-
- Ingest retries transient failures (5xx/429) and logs warnings if persistence fails.
|
|
257
|
-
|
|
258
|
-
### Event Identity Model
|
|
259
|
-
|
|
260
|
-
For consistent lifecycle correlation in Activity/Prompts, use this model:
|
|
261
|
-
|
|
262
|
-
- `client_event_id`: external correlation ID for one end-to-end action.
|
|
263
|
-
- `guard_event_id`: ID of the preflight guard event returned by `guard()`.
|
|
264
|
-
- `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.
|
|
265
|
-
|
|
266
|
-
SDK behavior:
|
|
267
|
-
|
|
268
|
-
- `guard()` sends `client_event_id` and returns canonical `client_event_id` + `guard_event_id`.
|
|
269
|
-
- `log()` sends:
|
|
270
|
-
- `event_id = canonical client_event_id`
|
|
271
|
-
- `metadata.client_event_id`
|
|
272
|
-
- `metadata.guard_event_id` (when available from wrappers/callbacks)
|
|
273
|
-
- `x-correlation-id = client_event_id`
|
|
274
|
-
- after a successful primary ingest, SDK wrappers can call `/ingest/finalize` with the same `client_event_id` to attach `sdk_ingest_ms`
|
|
275
|
-
- SDK requests include `x-agentid-sdk-version` for telemetry/version diagnostics.
|
|
276
|
-
|
|
277
|
-
This keeps Guard + Complete linked under one correlation key while preserving internal event linkage in the dashboard.
|
|
278
|
-
|
|
279
|
-
### SDK Timing Telemetry
|
|
280
|
-
|
|
281
|
-
SDK-managed metadata can include:
|
|
282
|
-
|
|
283
|
-
- `sdk_config_fetch_ms`: capability/config fetch time before dispatch.
|
|
284
|
-
- `sdk_local_scan_ms`: optional local enforcement time (`clientFastFail` or fail-close fallback path).
|
|
285
|
-
- `sdk_guard_ms`: backend `/guard` round-trip time observed by the SDK wrapper.
|
|
286
|
-
- `sdk_ingest_ms`: post-ingest transport timing finalized by the SDK through `/ingest/finalize` after a successful primary `/ingest`.
|
|
287
|
-
|
|
288
|
-
### Policy-Pack Runtime Telemetry
|
|
289
|
-
|
|
290
|
-
When the backend uses compiled policy packs, runtime metadata includes:
|
|
291
|
-
|
|
292
|
-
- `policy_pack_version`: active compiled artifact version.
|
|
293
|
-
- `policy_pack_fallback`: `true` means fallback detector path was used.
|
|
294
|
-
- `policy_pack_details`: optional diagnostic detail for fallback/decision trace.
|
|
295
|
-
|
|
296
|
-
Latency interpretation:
|
|
297
|
-
|
|
298
|
-
- Activity `Latency (ms)` maps to synchronous processing (`processing_time_ms`).
|
|
299
|
-
- Async AI audit time is separate (`ai_audit_duration_ms`) and can be higher.
|
|
300
|
-
- First request after warm-up boundaries can be slower than steady-state requests.
|
|
301
|
-
|
|
302
|
-
### Monorepo QA Commands (Maintainers)
|
|
303
|
-
|
|
304
|
-
If you are validating runtime in the AgentID monorepo:
|
|
305
|
-
|
|
306
|
-
```bash
|
|
307
|
-
npm run qa:policy-pack-bootstrap -- --base-url=http://127.0.0.1:3000/api/v1 --system-id=<SYSTEM_UUID>
|
|
308
|
-
npm run bench:policy-pack-hotpath
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
PowerShell diagnostics:
|
|
312
|
-
|
|
313
|
-
```powershell
|
|
314
|
-
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
|
|
315
|
-
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
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
## 7. Security & Compliance
|
|
319
|
-
|
|
320
|
-
- Backend `/guard` remains the primary enforcement authority by default.
|
|
321
|
-
- Optional local PII masking and opt-in `clientFastFail` are available for edge cases.
|
|
322
|
-
- Guard checks run pre-execution; ingest + finalize telemetry captures prompt/output lifecycle and SDK timing breakdowns.
|
|
323
|
-
- Safe for server and serverless runtimes (including async completion flows).
|
|
324
|
-
- Supports compliance and forensics workflows with durable event records.
|
|
325
|
-
|
|
326
|
-
## 8. Support
|
|
327
|
-
|
|
328
|
-
- Dashboard: `https://app.getagentid.com`
|
|
329
|
-
- Repository: `https://github.com/ondrejsukac-rgb/agentid/tree/main/js-sdk`
|
|
330
|
-
- Issues: `https://github.com/ondrejsukac-rgb/agentid/issues`
|
|
331
|
-
|
|
332
|
-
## 9. Publishing Notes (NPM)
|
|
333
|
-
|
|
334
|
-
NPM automatically renders `README.md` from the package root during `npm publish`.
|
|
335
|
-
|
|
336
|
-
- File location: next to `package.json` in `js-sdk/`.
|
|
337
|
-
- No additional NPM config is required for README rendering.
|
|
1
|
+
# agentid-sdk (Node.js / TypeScript)
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/agentid-sdk)
|
|
4
|
+
[](https://www.npmjs.com/package/agentid-sdk)
|
|
5
|
+
[](https://nodejs.org/)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
## 1. Introduction
|
|
9
|
+
|
|
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
|
+
|
|
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
|
+
|
|
29
|
+
## 2. Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install agentid-sdk
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 3. Prerequisites
|
|
36
|
+
|
|
37
|
+
1. Create an account at `https://app.getagentid.com`.
|
|
38
|
+
2. Create an AI system and copy:
|
|
39
|
+
- `AGENTID_API_KEY` (for example `sk_live_...`)
|
|
40
|
+
- `AGENTID_SYSTEM_ID` (UUID)
|
|
41
|
+
3. If using OpenAI/LangChain, set:
|
|
42
|
+
- `OPENAI_API_KEY`
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
export AGENTID_API_KEY="sk_live_..."
|
|
46
|
+
export AGENTID_SYSTEM_ID="00000000-0000-0000-0000-000000000000"
|
|
47
|
+
export OPENAI_API_KEY="sk-proj-..."
|
|
48
|
+
```
|
|
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
|
+
|
|
56
|
+
## 4. Quickstart
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { AgentID } from "agentid-sdk";
|
|
60
|
+
|
|
61
|
+
const agent = new AgentID(); // auto-loads AGENTID_API_KEY
|
|
62
|
+
const systemId = process.env.AGENTID_SYSTEM_ID!;
|
|
63
|
+
|
|
64
|
+
const verdict = await agent.guard({
|
|
65
|
+
system_id: systemId,
|
|
66
|
+
input: "Summarize this ticket in one sentence.",
|
|
67
|
+
model: "gpt-4o-mini",
|
|
68
|
+
user_id: "quickstart-user",
|
|
69
|
+
});
|
|
70
|
+
if (!verdict.allowed) throw new Error(`Blocked: ${verdict.reason}`);
|
|
71
|
+
|
|
72
|
+
await agent.log({
|
|
73
|
+
system_id: systemId,
|
|
74
|
+
event_id: verdict.client_event_id,
|
|
75
|
+
model: "gpt-4o-mini",
|
|
76
|
+
input: "Summarize this ticket in one sentence.",
|
|
77
|
+
output: "Summary generated.",
|
|
78
|
+
metadata: { agent_role: "support-assistant" },
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## 5. Core Integrations
|
|
83
|
+
|
|
84
|
+
### OpenAI Wrapper
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npm install agentid-sdk openai
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
import OpenAI from "openai";
|
|
92
|
+
import { AgentID } from "agentid-sdk";
|
|
93
|
+
|
|
94
|
+
const agent = new AgentID({
|
|
95
|
+
piiMasking: true,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY! });
|
|
99
|
+
const secured = agent.wrapOpenAI(openai, {
|
|
100
|
+
system_id: process.env.AGENTID_SYSTEM_ID!,
|
|
101
|
+
user_id: "customer-123",
|
|
102
|
+
expected_languages: ["en"],
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const response = await secured.chat.completions.create({
|
|
106
|
+
model: "gpt-4o-mini",
|
|
107
|
+
messages: [{ role: "user", content: "What is the capital of the Czech Republic?" }],
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
console.log(response.choices[0]?.message?.content ?? "");
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Wrapped OpenAI calls persist telemetry for both regular and streamed completions. For `stream: true`, logging happens when the stream finishes.
|
|
114
|
+
|
|
115
|
+
> 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.
|
|
116
|
+
|
|
117
|
+
### Vercel AI SDK Wrapper
|
|
118
|
+
|
|
119
|
+
If your app already uses Vercel AI SDK primitives such as `generateText()` or `streamText()`, prefer the dedicated wrapper package instead of rebuilding the lifecycle manually:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
npm install ai agentid-vercel-sdk @ai-sdk/openai
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
`agentid-vercel-sdk` keeps AgentID backend-first by default, blocks before provider billing on denied prompts, and finalizes telemetry after completion or stream close.
|
|
126
|
+
|
|
127
|
+
### LangChain Integration
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
npm install agentid-sdk openai @langchain/core @langchain/openai
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
import { AgentID } from "agentid-sdk";
|
|
135
|
+
import { AgentIDCallbackHandler } from "agentid-sdk/langchain";
|
|
136
|
+
import { ChatOpenAI } from "@langchain/openai";
|
|
137
|
+
import { ChatPromptTemplate } from "@langchain/core/prompts";
|
|
138
|
+
import { StringOutputParser } from "@langchain/core/output_parsers";
|
|
139
|
+
|
|
140
|
+
const agent = new AgentID();
|
|
141
|
+
const handler = new AgentIDCallbackHandler(agent, {
|
|
142
|
+
system_id: process.env.AGENTID_SYSTEM_ID!,
|
|
143
|
+
expected_languages: ["en"],
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
const prompt = ChatPromptTemplate.fromTemplate("Answer in one sentence: {question}");
|
|
147
|
+
const model = new ChatOpenAI({
|
|
148
|
+
apiKey: process.env.OPENAI_API_KEY!,
|
|
149
|
+
model: "gpt-4o-mini",
|
|
150
|
+
});
|
|
151
|
+
const chain = prompt.pipe(model).pipe(new StringOutputParser());
|
|
152
|
+
|
|
153
|
+
const result = await chain.invoke(
|
|
154
|
+
{ question: "What is the capital of the Czech Republic?" },
|
|
155
|
+
{ callbacks: [handler] }
|
|
156
|
+
);
|
|
157
|
+
console.log(result);
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
LangChain callbacks log on run completion. Token/cost telemetry for streamed chains depends on the provider exposing usage in the final LangChain result.
|
|
161
|
+
|
|
162
|
+
### Raw Ingest API (Telemetry Only)
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
import { AgentID } from "agentid-sdk";
|
|
166
|
+
|
|
167
|
+
const agent = new AgentID();
|
|
168
|
+
|
|
169
|
+
await agent.log({
|
|
170
|
+
system_id: process.env.AGENTID_SYSTEM_ID!,
|
|
171
|
+
event_type: "complete",
|
|
172
|
+
severity: "info",
|
|
173
|
+
model: "gpt-4o-mini",
|
|
174
|
+
input: "Raw telemetry prompt",
|
|
175
|
+
output: '{"ok": true}',
|
|
176
|
+
metadata: { agent_role: "batch-worker", channel: "manual_ingest" },
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Transparency Badge (Article 50 UI Evidence)
|
|
181
|
+
|
|
182
|
+
When rendering disclosure UI, log proof-of-render telemetry so you can demonstrate the end-user actually saw the badge.
|
|
183
|
+
|
|
184
|
+
```tsx
|
|
185
|
+
import { AgentIDTransparencyBadge } from "agentid-sdk/transparency-badge";
|
|
186
|
+
|
|
187
|
+
<AgentIDTransparencyBadge
|
|
188
|
+
telemetry={{
|
|
189
|
+
systemId: process.env.NEXT_PUBLIC_AGENTID_SYSTEM_ID!,
|
|
190
|
+
// Prefer a backend relay endpoint so no secret key is exposed in browser code.
|
|
191
|
+
ingestUrl: "/api/agentid/transparency-render",
|
|
192
|
+
headers: { "x-agentid-system-id": process.env.NEXT_PUBLIC_AGENTID_SYSTEM_ID! },
|
|
193
|
+
userId: "customer-123",
|
|
194
|
+
}}
|
|
195
|
+
placement="chat-header"
|
|
196
|
+
/>;
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
On mount, the component asynchronously emits `event_type: "transparency_badge_rendered"` to the AgentID ingest endpoint.
|
|
200
|
+
|
|
201
|
+
## 6. Advanced Configuration
|
|
202
|
+
|
|
203
|
+
### Custom identity / role metadata
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
await agent.guard({
|
|
207
|
+
system_id: process.env.AGENTID_SYSTEM_ID!,
|
|
208
|
+
input: "Process user request",
|
|
209
|
+
user_id: "service:billing-agent",
|
|
210
|
+
model: "gpt-4o-mini",
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
await agent.log({
|
|
214
|
+
system_id: process.env.AGENTID_SYSTEM_ID!,
|
|
215
|
+
model: "gpt-4o-mini",
|
|
216
|
+
input: "Process user request",
|
|
217
|
+
output: "Done",
|
|
218
|
+
metadata: { agent_role: "billing-agent", environment: "prod" },
|
|
219
|
+
});
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Strict mode and timeout tuning
|
|
223
|
+
|
|
224
|
+
```ts
|
|
225
|
+
const agent = new AgentID({
|
|
226
|
+
strictMode: true, // fail-closed on guard connectivity/timeouts
|
|
227
|
+
guardTimeoutMs: 10000, // default guard timeout is 10000ms
|
|
228
|
+
ingestTimeoutMs: 10000 // default ingest timeout is 10000ms
|
|
229
|
+
});
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Optional client-side fast fail
|
|
233
|
+
|
|
234
|
+
```ts
|
|
235
|
+
const agent = new AgentID({
|
|
236
|
+
failureMode: "fail_close",
|
|
237
|
+
clientFastFail: true, // opt-in local preflight before /guard
|
|
238
|
+
});
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Error Handling & Strict Mode
|
|
242
|
+
|
|
243
|
+
By default, AgentID is designed to keep your application running if the AgentID API has a timeout or is temporarily unreachable.
|
|
244
|
+
|
|
245
|
+
| Mode | Connectivity Failure | LLM Execution | Best For |
|
|
246
|
+
| :--- | :--- | :--- | :--- |
|
|
247
|
+
| **Default** (Strict Off) | API Timeout / Unreachable | **Fail-Open** (continues) | Standard SaaS, chatbots |
|
|
248
|
+
| **Strict Mode** (`strictMode: true`) | API Timeout / Unreachable | Direct `guard()` denies; wrapped flows can apply local fallback first | Healthcare, FinTech, high-risk |
|
|
249
|
+
|
|
250
|
+
- `guard()` returns a verdict (`allowed`, `reason`); handle deny paths explicitly.
|
|
251
|
+
- `wrapOpenAI()` and LangChain handlers throw `SecurityBlockError` when a prompt is blocked.
|
|
252
|
+
- Backend `/guard` is the default authority for prompt injection, DB access, code execution, and PII leakage in SDK-wrapped flows.
|
|
253
|
+
- `clientFastFail` / `client_fast_fail` is optional and disabled by default. Enable it only when you explicitly want local preflight before the backend call.
|
|
254
|
+
- If backend guard is unreachable and the effective failure mode is `fail_close`, wrapped OpenAI/LangChain flows can run local fallback enforcement. Local hits still block; otherwise the request can continue with fallback telemetry attached.
|
|
255
|
+
- If `strictMode` is not explicitly set in SDK code, runtime behavior follows the system configuration from AgentID (`strict_security_mode` / `failure_mode`).
|
|
256
|
+
- Ingest retries transient failures (5xx/429) and logs warnings if persistence fails.
|
|
257
|
+
|
|
258
|
+
### Event Identity Model
|
|
259
|
+
|
|
260
|
+
For consistent lifecycle correlation in Activity/Prompts, use this model:
|
|
261
|
+
|
|
262
|
+
- `client_event_id`: external correlation ID for one end-to-end action.
|
|
263
|
+
- `guard_event_id`: ID of the preflight guard event returned by `guard()`.
|
|
264
|
+
- `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.
|
|
265
|
+
|
|
266
|
+
SDK behavior:
|
|
267
|
+
|
|
268
|
+
- `guard()` sends `client_event_id` and returns canonical `client_event_id` + `guard_event_id`.
|
|
269
|
+
- `log()` sends:
|
|
270
|
+
- `event_id = canonical client_event_id`
|
|
271
|
+
- `metadata.client_event_id`
|
|
272
|
+
- `metadata.guard_event_id` (when available from wrappers/callbacks)
|
|
273
|
+
- `x-correlation-id = client_event_id`
|
|
274
|
+
- after a successful primary ingest, SDK wrappers can call `/ingest/finalize` with the same `client_event_id` to attach `sdk_ingest_ms`
|
|
275
|
+
- SDK requests include `x-agentid-sdk-version` for telemetry/version diagnostics.
|
|
276
|
+
|
|
277
|
+
This keeps Guard + Complete linked under one correlation key while preserving internal event linkage in the dashboard.
|
|
278
|
+
|
|
279
|
+
### SDK Timing Telemetry
|
|
280
|
+
|
|
281
|
+
SDK-managed metadata can include:
|
|
282
|
+
|
|
283
|
+
- `sdk_config_fetch_ms`: capability/config fetch time before dispatch.
|
|
284
|
+
- `sdk_local_scan_ms`: optional local enforcement time (`clientFastFail` or fail-close fallback path).
|
|
285
|
+
- `sdk_guard_ms`: backend `/guard` round-trip time observed by the SDK wrapper.
|
|
286
|
+
- `sdk_ingest_ms`: post-ingest transport timing finalized by the SDK through `/ingest/finalize` after a successful primary `/ingest`.
|
|
287
|
+
|
|
288
|
+
### Policy-Pack Runtime Telemetry
|
|
289
|
+
|
|
290
|
+
When the backend uses compiled policy packs, runtime metadata includes:
|
|
291
|
+
|
|
292
|
+
- `policy_pack_version`: active compiled artifact version.
|
|
293
|
+
- `policy_pack_fallback`: `true` means fallback detector path was used.
|
|
294
|
+
- `policy_pack_details`: optional diagnostic detail for fallback/decision trace.
|
|
295
|
+
|
|
296
|
+
Latency interpretation:
|
|
297
|
+
|
|
298
|
+
- Activity `Latency (ms)` maps to synchronous processing (`processing_time_ms`).
|
|
299
|
+
- Async AI audit time is separate (`ai_audit_duration_ms`) and can be higher.
|
|
300
|
+
- First request after warm-up boundaries can be slower than steady-state requests.
|
|
301
|
+
|
|
302
|
+
### Monorepo QA Commands (Maintainers)
|
|
303
|
+
|
|
304
|
+
If you are validating runtime in the AgentID monorepo:
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
npm run qa:policy-pack-bootstrap -- --base-url=http://127.0.0.1:3000/api/v1 --system-id=<SYSTEM_UUID>
|
|
308
|
+
npm run bench:policy-pack-hotpath
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
PowerShell diagnostics:
|
|
312
|
+
|
|
313
|
+
```powershell
|
|
314
|
+
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
|
|
315
|
+
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
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
## 7. Security & Compliance
|
|
319
|
+
|
|
320
|
+
- Backend `/guard` remains the primary enforcement authority by default.
|
|
321
|
+
- Optional local PII masking and opt-in `clientFastFail` are available for edge cases.
|
|
322
|
+
- Guard checks run pre-execution; ingest + finalize telemetry captures prompt/output lifecycle and SDK timing breakdowns.
|
|
323
|
+
- Safe for server and serverless runtimes (including async completion flows).
|
|
324
|
+
- Supports compliance and forensics workflows with durable event records.
|
|
325
|
+
|
|
326
|
+
## 8. Support
|
|
327
|
+
|
|
328
|
+
- Dashboard: `https://app.getagentid.com`
|
|
329
|
+
- Repository: `https://github.com/ondrejsukac-rgb/agentid/tree/main/js-sdk`
|
|
330
|
+
- Issues: `https://github.com/ondrejsukac-rgb/agentid/issues`
|
|
331
|
+
|
|
332
|
+
## 9. Publishing Notes (NPM)
|
|
333
|
+
|
|
334
|
+
NPM automatically renders `README.md` from the package root during `npm publish`.
|
|
335
|
+
|
|
336
|
+
- File location: next to `package.json` in `js-sdk/`.
|
|
337
|
+
- No additional NPM config is required for README rendering.
|
|
@@ -152,6 +152,8 @@ declare class AgentID {
|
|
|
152
152
|
private resolveEffectiveStrictMode;
|
|
153
153
|
private maybeRaiseStrictIngestDependencyError;
|
|
154
154
|
private shouldRunLocalInjectionScan;
|
|
155
|
+
private shouldRefreshCapabilityConfigBeforeLocalEnforcement;
|
|
156
|
+
private refreshCapabilityConfigBeforeLocalEnforcement;
|
|
155
157
|
private applyLocalPolicyChecks;
|
|
156
158
|
prepareInputForDispatch(params: {
|
|
157
159
|
input: string;
|
|
@@ -152,6 +152,8 @@ declare class AgentID {
|
|
|
152
152
|
private resolveEffectiveStrictMode;
|
|
153
153
|
private maybeRaiseStrictIngestDependencyError;
|
|
154
154
|
private shouldRunLocalInjectionScan;
|
|
155
|
+
private shouldRefreshCapabilityConfigBeforeLocalEnforcement;
|
|
156
|
+
private refreshCapabilityConfigBeforeLocalEnforcement;
|
|
155
157
|
private applyLocalPolicyChecks;
|
|
156
158
|
prepareInputForDispatch(params: {
|
|
157
159
|
input: string;
|
|
@@ -1810,7 +1810,7 @@ function getInjectionScanner() {
|
|
|
1810
1810
|
|
|
1811
1811
|
// src/sdk-version.ts
|
|
1812
1812
|
var FALLBACK_SDK_VERSION = "js-0.0.0-dev";
|
|
1813
|
-
var AGENTID_SDK_VERSION_HEADER = "js-0.1.
|
|
1813
|
+
var AGENTID_SDK_VERSION_HEADER = "js-0.1.32".trim().length > 0 ? "js-0.1.32" : FALLBACK_SDK_VERSION;
|
|
1814
1814
|
|
|
1815
1815
|
// src/local-security-enforcer.ts
|
|
1816
1816
|
var DEFAULT_FAIL_OPEN_CONFIG = {
|
|
@@ -1922,7 +1922,8 @@ var LocalSecurityEnforcer = class {
|
|
|
1922
1922
|
};
|
|
1923
1923
|
|
|
1924
1924
|
// src/capability-config.ts
|
|
1925
|
-
var CONFIG_TTL_MS =
|
|
1925
|
+
var CONFIG_TTL_MS = 15 * 1e3;
|
|
1926
|
+
var CONFIG_FAILURE_FALLBACK_TTL_MS = 2 * 1e3;
|
|
1926
1927
|
var CONFIG_TIMEOUT_MS = 1500;
|
|
1927
1928
|
var CONFIG_RETRY_DELAY_MS = 150;
|
|
1928
1929
|
var MAX_CAPABILITY_CACHE_ENTRIES = 500;
|
|
@@ -2057,8 +2058,11 @@ async function fetchCapabilityConfigAttempt(params) {
|
|
|
2057
2058
|
try {
|
|
2058
2059
|
const res = await fetch(`${normalizeBaseUrl2(params.baseUrl)}/agent/config`, {
|
|
2059
2060
|
method: "GET",
|
|
2061
|
+
cache: "no-store",
|
|
2060
2062
|
headers: {
|
|
2061
2063
|
"Content-Type": "application/json",
|
|
2064
|
+
"Cache-Control": "no-cache, no-store, max-age=0",
|
|
2065
|
+
Pragma: "no-cache",
|
|
2062
2066
|
"x-agentid-api-key": params.apiKey,
|
|
2063
2067
|
"X-AgentID-SDK-Version": AGENTID_SDK_VERSION_HEADER
|
|
2064
2068
|
},
|
|
@@ -2145,10 +2149,11 @@ async function ensureCapabilityConfig(params) {
|
|
|
2145
2149
|
}).catch((error) => {
|
|
2146
2150
|
const message = error instanceof Error ? error.message : String(error);
|
|
2147
2151
|
const fallbackConfig = existing?.config ?? DEFAULT_FAIL_OPEN_CONFIG;
|
|
2152
|
+
const fallbackTtlMs = Math.min(ttlMs, CONFIG_FAILURE_FALLBACK_TTL_MS);
|
|
2148
2153
|
console.warn("AgentID Config unreachable. Defaulting to FAIL-OPEN MODE.", message);
|
|
2149
2154
|
cache.set(key, {
|
|
2150
2155
|
config: fallbackConfig,
|
|
2151
|
-
expiresAt: Date.now() +
|
|
2156
|
+
expiresAt: Date.now() + fallbackTtlMs,
|
|
2152
2157
|
promise: null
|
|
2153
2158
|
});
|
|
2154
2159
|
enforceCacheBound(cache);
|
|
@@ -2657,6 +2662,25 @@ var AgentID = class {
|
|
|
2657
2662
|
}
|
|
2658
2663
|
return config.block_on_heuristic;
|
|
2659
2664
|
}
|
|
2665
|
+
shouldRefreshCapabilityConfigBeforeLocalEnforcement(config) {
|
|
2666
|
+
if (config.shadow_mode) {
|
|
2667
|
+
return false;
|
|
2668
|
+
}
|
|
2669
|
+
return this.shouldRunLocalInjectionScan(config) || config.block_db_access || config.block_code_execution || config.block_pii_leakage;
|
|
2670
|
+
}
|
|
2671
|
+
async refreshCapabilityConfigBeforeLocalEnforcement(params) {
|
|
2672
|
+
if (!this.shouldRefreshCapabilityConfigBeforeLocalEnforcement(params.capabilityConfig)) {
|
|
2673
|
+
return {
|
|
2674
|
+
capabilityConfig: params.capabilityConfig,
|
|
2675
|
+
sdkConfigFetchMs: params.sdkConfigFetchMs
|
|
2676
|
+
};
|
|
2677
|
+
}
|
|
2678
|
+
const refreshed = await this.getCapabilityConfigWithTelemetry(true, params.options);
|
|
2679
|
+
return {
|
|
2680
|
+
capabilityConfig: refreshed.capabilityConfig,
|
|
2681
|
+
sdkConfigFetchMs: params.sdkConfigFetchMs + refreshed.sdkConfigFetchMs
|
|
2682
|
+
};
|
|
2683
|
+
}
|
|
2660
2684
|
async applyLocalPolicyChecks(params) {
|
|
2661
2685
|
const localScanStartedAt = Date.now();
|
|
2662
2686
|
if (params.runPromptInjectionCheck && params.input && this.shouldRunLocalInjectionScan(params.capabilityConfig)) {
|
|
@@ -2713,7 +2737,7 @@ var AgentID = class {
|
|
|
2713
2737
|
}
|
|
2714
2738
|
async prepareInputForDispatch(params, options) {
|
|
2715
2739
|
const effectiveApiKey = this.resolveApiKey(options?.apiKey);
|
|
2716
|
-
|
|
2740
|
+
let { capabilityConfig, sdkConfigFetchMs } = await this.getCapabilityConfigWithTelemetry(
|
|
2717
2741
|
false,
|
|
2718
2742
|
options
|
|
2719
2743
|
);
|
|
@@ -2725,6 +2749,13 @@ var AgentID = class {
|
|
|
2725
2749
|
sdkLocalScanMs: 0
|
|
2726
2750
|
};
|
|
2727
2751
|
}
|
|
2752
|
+
const refreshedConfig = await this.refreshCapabilityConfigBeforeLocalEnforcement({
|
|
2753
|
+
capabilityConfig,
|
|
2754
|
+
sdkConfigFetchMs,
|
|
2755
|
+
options
|
|
2756
|
+
});
|
|
2757
|
+
capabilityConfig = refreshedConfig.capabilityConfig;
|
|
2758
|
+
sdkConfigFetchMs = refreshedConfig.sdkConfigFetchMs;
|
|
2728
2759
|
const enforced = await this.applyLocalPolicyChecks({
|
|
2729
2760
|
input: params.input,
|
|
2730
2761
|
systemId: params.systemId,
|
|
@@ -2748,20 +2779,25 @@ var AgentID = class {
|
|
|
2748
2779
|
capabilityConfig: params.capabilityConfig,
|
|
2749
2780
|
sdkConfigFetchMs: params.sdkConfigFetchMs
|
|
2750
2781
|
} : await this.getCapabilityConfigWithTelemetry(false, options);
|
|
2782
|
+
const refreshedConfig = await this.refreshCapabilityConfigBeforeLocalEnforcement({
|
|
2783
|
+
capabilityConfig: resolvedConfig.capabilityConfig,
|
|
2784
|
+
sdkConfigFetchMs: resolvedConfig.sdkConfigFetchMs,
|
|
2785
|
+
options
|
|
2786
|
+
});
|
|
2751
2787
|
const enforced = await this.applyLocalPolicyChecks({
|
|
2752
2788
|
input: params.input,
|
|
2753
2789
|
systemId: params.systemId,
|
|
2754
2790
|
stream: params.stream,
|
|
2755
|
-
capabilityConfig:
|
|
2791
|
+
capabilityConfig: refreshedConfig.capabilityConfig,
|
|
2756
2792
|
apiKey: effectiveApiKey,
|
|
2757
2793
|
clientEventId: params.clientEventId,
|
|
2758
|
-
sdkConfigFetchMs:
|
|
2794
|
+
sdkConfigFetchMs: refreshedConfig.sdkConfigFetchMs,
|
|
2759
2795
|
runPromptInjectionCheck: true
|
|
2760
2796
|
});
|
|
2761
2797
|
return {
|
|
2762
2798
|
sanitizedInput: enforced.sanitizedInput,
|
|
2763
|
-
capabilityConfig:
|
|
2764
|
-
sdkConfigFetchMs:
|
|
2799
|
+
capabilityConfig: refreshedConfig.capabilityConfig,
|
|
2800
|
+
sdkConfigFetchMs: refreshedConfig.sdkConfigFetchMs,
|
|
2765
2801
|
sdkLocalScanMs: enforced.sdkLocalScanMs
|
|
2766
2802
|
};
|
|
2767
2803
|
}
|
|
@@ -2769,11 +2805,16 @@ var AgentID = class {
|
|
|
2769
2805
|
if (!input) {
|
|
2770
2806
|
return;
|
|
2771
2807
|
}
|
|
2772
|
-
const
|
|
2808
|
+
const initialConfig = await this.getCapabilityConfigWithTelemetry(
|
|
2773
2809
|
false,
|
|
2774
2810
|
options
|
|
2775
2811
|
);
|
|
2776
|
-
|
|
2812
|
+
const refreshedConfig = await this.refreshCapabilityConfigBeforeLocalEnforcement({
|
|
2813
|
+
capabilityConfig: initialConfig.capabilityConfig,
|
|
2814
|
+
sdkConfigFetchMs: initialConfig.sdkConfigFetchMs,
|
|
2815
|
+
options
|
|
2816
|
+
});
|
|
2817
|
+
if (!this.shouldRunLocalInjectionScan(refreshedConfig.capabilityConfig)) {
|
|
2777
2818
|
return;
|
|
2778
2819
|
}
|
|
2779
2820
|
const effectiveApiKey = this.resolveApiKey(options?.apiKey);
|
|
@@ -2789,7 +2830,7 @@ var AgentID = class {
|
|
|
2789
2830
|
eventId: options?.clientEventId,
|
|
2790
2831
|
clientEventId: options?.clientEventId,
|
|
2791
2832
|
telemetryMetadata: buildSdkTimingMetadata({
|
|
2792
|
-
sdkConfigFetchMs
|
|
2833
|
+
sdkConfigFetchMs: refreshedConfig.sdkConfigFetchMs
|
|
2793
2834
|
})
|
|
2794
2835
|
});
|
|
2795
2836
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AgentID, D as DependencyError, G as GuardParams, a as GuardResponse, L as LogParams, P as PreparedInput, R as RequestOptions, S as SecurityBlockError, T as TransparencyMetadata } from './agentid-
|
|
1
|
+
export { A as AgentID, D as DependencyError, G as GuardParams, a as GuardResponse, L as LogParams, P as PreparedInput, R as RequestOptions, S as SecurityBlockError, T as TransparencyMetadata } from './agentid-BgahmiuN.mjs';
|
|
2
2
|
|
|
3
3
|
type PIIMapping = Record<string, string>;
|
|
4
4
|
declare class PIIManager {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AgentID, D as DependencyError, G as GuardParams, a as GuardResponse, L as LogParams, P as PreparedInput, R as RequestOptions, S as SecurityBlockError, T as TransparencyMetadata } from './agentid-
|
|
1
|
+
export { A as AgentID, D as DependencyError, G as GuardParams, a as GuardResponse, L as LogParams, P as PreparedInput, R as RequestOptions, S as SecurityBlockError, T as TransparencyMetadata } from './agentid-BgahmiuN.js';
|
|
2
2
|
|
|
3
3
|
type PIIMapping = Record<string, string>;
|
|
4
4
|
declare class PIIManager {
|
package/dist/index.js
CHANGED
|
@@ -75,7 +75,7 @@ var OpenAIAdapter = class {
|
|
|
75
75
|
|
|
76
76
|
// src/sdk-version.ts
|
|
77
77
|
var FALLBACK_SDK_VERSION = "js-0.0.0-dev";
|
|
78
|
-
var AGENTID_SDK_VERSION_HEADER = "js-0.1.
|
|
78
|
+
var AGENTID_SDK_VERSION_HEADER = "js-0.1.32".trim().length > 0 ? "js-0.1.32" : FALLBACK_SDK_VERSION;
|
|
79
79
|
|
|
80
80
|
// src/pii-national-identifiers.ts
|
|
81
81
|
var MAX_CANDIDATES_PER_RULE = 256;
|
|
@@ -1296,7 +1296,8 @@ var LocalSecurityEnforcer = class {
|
|
|
1296
1296
|
};
|
|
1297
1297
|
|
|
1298
1298
|
// src/capability-config.ts
|
|
1299
|
-
var CONFIG_TTL_MS =
|
|
1299
|
+
var CONFIG_TTL_MS = 15 * 1e3;
|
|
1300
|
+
var CONFIG_FAILURE_FALLBACK_TTL_MS = 2 * 1e3;
|
|
1300
1301
|
var CONFIG_TIMEOUT_MS = 1500;
|
|
1301
1302
|
var CONFIG_RETRY_DELAY_MS = 150;
|
|
1302
1303
|
var MAX_CAPABILITY_CACHE_ENTRIES = 500;
|
|
@@ -1431,8 +1432,11 @@ async function fetchCapabilityConfigAttempt(params) {
|
|
|
1431
1432
|
try {
|
|
1432
1433
|
const res = await fetch(`${normalizeBaseUrl(params.baseUrl)}/agent/config`, {
|
|
1433
1434
|
method: "GET",
|
|
1435
|
+
cache: "no-store",
|
|
1434
1436
|
headers: {
|
|
1435
1437
|
"Content-Type": "application/json",
|
|
1438
|
+
"Cache-Control": "no-cache, no-store, max-age=0",
|
|
1439
|
+
Pragma: "no-cache",
|
|
1436
1440
|
"x-agentid-api-key": params.apiKey,
|
|
1437
1441
|
"X-AgentID-SDK-Version": AGENTID_SDK_VERSION_HEADER
|
|
1438
1442
|
},
|
|
@@ -1519,10 +1523,11 @@ async function ensureCapabilityConfig(params) {
|
|
|
1519
1523
|
}).catch((error) => {
|
|
1520
1524
|
const message = error instanceof Error ? error.message : String(error);
|
|
1521
1525
|
const fallbackConfig = existing?.config ?? DEFAULT_FAIL_OPEN_CONFIG;
|
|
1526
|
+
const fallbackTtlMs = Math.min(ttlMs, CONFIG_FAILURE_FALLBACK_TTL_MS);
|
|
1522
1527
|
console.warn("AgentID Config unreachable. Defaulting to FAIL-OPEN MODE.", message);
|
|
1523
1528
|
cache.set(key, {
|
|
1524
1529
|
config: fallbackConfig,
|
|
1525
|
-
expiresAt: Date.now() +
|
|
1530
|
+
expiresAt: Date.now() + fallbackTtlMs,
|
|
1526
1531
|
promise: null
|
|
1527
1532
|
});
|
|
1528
1533
|
enforceCacheBound(cache);
|
|
@@ -2690,6 +2695,25 @@ var AgentID = class {
|
|
|
2690
2695
|
}
|
|
2691
2696
|
return config.block_on_heuristic;
|
|
2692
2697
|
}
|
|
2698
|
+
shouldRefreshCapabilityConfigBeforeLocalEnforcement(config) {
|
|
2699
|
+
if (config.shadow_mode) {
|
|
2700
|
+
return false;
|
|
2701
|
+
}
|
|
2702
|
+
return this.shouldRunLocalInjectionScan(config) || config.block_db_access || config.block_code_execution || config.block_pii_leakage;
|
|
2703
|
+
}
|
|
2704
|
+
async refreshCapabilityConfigBeforeLocalEnforcement(params) {
|
|
2705
|
+
if (!this.shouldRefreshCapabilityConfigBeforeLocalEnforcement(params.capabilityConfig)) {
|
|
2706
|
+
return {
|
|
2707
|
+
capabilityConfig: params.capabilityConfig,
|
|
2708
|
+
sdkConfigFetchMs: params.sdkConfigFetchMs
|
|
2709
|
+
};
|
|
2710
|
+
}
|
|
2711
|
+
const refreshed = await this.getCapabilityConfigWithTelemetry(true, params.options);
|
|
2712
|
+
return {
|
|
2713
|
+
capabilityConfig: refreshed.capabilityConfig,
|
|
2714
|
+
sdkConfigFetchMs: params.sdkConfigFetchMs + refreshed.sdkConfigFetchMs
|
|
2715
|
+
};
|
|
2716
|
+
}
|
|
2693
2717
|
async applyLocalPolicyChecks(params) {
|
|
2694
2718
|
const localScanStartedAt = Date.now();
|
|
2695
2719
|
if (params.runPromptInjectionCheck && params.input && this.shouldRunLocalInjectionScan(params.capabilityConfig)) {
|
|
@@ -2746,7 +2770,7 @@ var AgentID = class {
|
|
|
2746
2770
|
}
|
|
2747
2771
|
async prepareInputForDispatch(params, options) {
|
|
2748
2772
|
const effectiveApiKey = this.resolveApiKey(options?.apiKey);
|
|
2749
|
-
|
|
2773
|
+
let { capabilityConfig, sdkConfigFetchMs } = await this.getCapabilityConfigWithTelemetry(
|
|
2750
2774
|
false,
|
|
2751
2775
|
options
|
|
2752
2776
|
);
|
|
@@ -2758,6 +2782,13 @@ var AgentID = class {
|
|
|
2758
2782
|
sdkLocalScanMs: 0
|
|
2759
2783
|
};
|
|
2760
2784
|
}
|
|
2785
|
+
const refreshedConfig = await this.refreshCapabilityConfigBeforeLocalEnforcement({
|
|
2786
|
+
capabilityConfig,
|
|
2787
|
+
sdkConfigFetchMs,
|
|
2788
|
+
options
|
|
2789
|
+
});
|
|
2790
|
+
capabilityConfig = refreshedConfig.capabilityConfig;
|
|
2791
|
+
sdkConfigFetchMs = refreshedConfig.sdkConfigFetchMs;
|
|
2761
2792
|
const enforced = await this.applyLocalPolicyChecks({
|
|
2762
2793
|
input: params.input,
|
|
2763
2794
|
systemId: params.systemId,
|
|
@@ -2781,20 +2812,25 @@ var AgentID = class {
|
|
|
2781
2812
|
capabilityConfig: params.capabilityConfig,
|
|
2782
2813
|
sdkConfigFetchMs: params.sdkConfigFetchMs
|
|
2783
2814
|
} : await this.getCapabilityConfigWithTelemetry(false, options);
|
|
2815
|
+
const refreshedConfig = await this.refreshCapabilityConfigBeforeLocalEnforcement({
|
|
2816
|
+
capabilityConfig: resolvedConfig.capabilityConfig,
|
|
2817
|
+
sdkConfigFetchMs: resolvedConfig.sdkConfigFetchMs,
|
|
2818
|
+
options
|
|
2819
|
+
});
|
|
2784
2820
|
const enforced = await this.applyLocalPolicyChecks({
|
|
2785
2821
|
input: params.input,
|
|
2786
2822
|
systemId: params.systemId,
|
|
2787
2823
|
stream: params.stream,
|
|
2788
|
-
capabilityConfig:
|
|
2824
|
+
capabilityConfig: refreshedConfig.capabilityConfig,
|
|
2789
2825
|
apiKey: effectiveApiKey,
|
|
2790
2826
|
clientEventId: params.clientEventId,
|
|
2791
|
-
sdkConfigFetchMs:
|
|
2827
|
+
sdkConfigFetchMs: refreshedConfig.sdkConfigFetchMs,
|
|
2792
2828
|
runPromptInjectionCheck: true
|
|
2793
2829
|
});
|
|
2794
2830
|
return {
|
|
2795
2831
|
sanitizedInput: enforced.sanitizedInput,
|
|
2796
|
-
capabilityConfig:
|
|
2797
|
-
sdkConfigFetchMs:
|
|
2832
|
+
capabilityConfig: refreshedConfig.capabilityConfig,
|
|
2833
|
+
sdkConfigFetchMs: refreshedConfig.sdkConfigFetchMs,
|
|
2798
2834
|
sdkLocalScanMs: enforced.sdkLocalScanMs
|
|
2799
2835
|
};
|
|
2800
2836
|
}
|
|
@@ -2802,11 +2838,16 @@ var AgentID = class {
|
|
|
2802
2838
|
if (!input) {
|
|
2803
2839
|
return;
|
|
2804
2840
|
}
|
|
2805
|
-
const
|
|
2841
|
+
const initialConfig = await this.getCapabilityConfigWithTelemetry(
|
|
2806
2842
|
false,
|
|
2807
2843
|
options
|
|
2808
2844
|
);
|
|
2809
|
-
|
|
2845
|
+
const refreshedConfig = await this.refreshCapabilityConfigBeforeLocalEnforcement({
|
|
2846
|
+
capabilityConfig: initialConfig.capabilityConfig,
|
|
2847
|
+
sdkConfigFetchMs: initialConfig.sdkConfigFetchMs,
|
|
2848
|
+
options
|
|
2849
|
+
});
|
|
2850
|
+
if (!this.shouldRunLocalInjectionScan(refreshedConfig.capabilityConfig)) {
|
|
2810
2851
|
return;
|
|
2811
2852
|
}
|
|
2812
2853
|
const effectiveApiKey = this.resolveApiKey(options?.apiKey);
|
|
@@ -2822,7 +2863,7 @@ var AgentID = class {
|
|
|
2822
2863
|
eventId: options?.clientEventId,
|
|
2823
2864
|
clientEventId: options?.clientEventId,
|
|
2824
2865
|
telemetryMetadata: buildSdkTimingMetadata({
|
|
2825
|
-
sdkConfigFetchMs
|
|
2866
|
+
sdkConfigFetchMs: refreshedConfig.sdkConfigFetchMs
|
|
2826
2867
|
})
|
|
2827
2868
|
});
|
|
2828
2869
|
}
|
package/dist/index.mjs
CHANGED
package/dist/langchain.d.mts
CHANGED
package/dist/langchain.d.ts
CHANGED
package/dist/langchain.js
CHANGED
|
@@ -27,7 +27,7 @@ var import_base = require("@langchain/core/callbacks/base");
|
|
|
27
27
|
|
|
28
28
|
// src/sdk-version.ts
|
|
29
29
|
var FALLBACK_SDK_VERSION = "js-0.0.0-dev";
|
|
30
|
-
var AGENTID_SDK_VERSION_HEADER = "js-0.1.
|
|
30
|
+
var AGENTID_SDK_VERSION_HEADER = "js-0.1.32".trim().length > 0 ? "js-0.1.32" : FALLBACK_SDK_VERSION;
|
|
31
31
|
|
|
32
32
|
// src/pii-national-identifiers.ts
|
|
33
33
|
var REGION_ANCHORS = {
|
|
@@ -200,7 +200,8 @@ var PHONE_CONTEXT_RE = new RegExp(
|
|
|
200
200
|
);
|
|
201
201
|
|
|
202
202
|
// src/capability-config.ts
|
|
203
|
-
var CONFIG_TTL_MS =
|
|
203
|
+
var CONFIG_TTL_MS = 15 * 1e3;
|
|
204
|
+
var CONFIG_FAILURE_FALLBACK_TTL_MS = 2 * 1e3;
|
|
204
205
|
|
|
205
206
|
// src/agentid.ts
|
|
206
207
|
var SecurityBlockError = class extends Error {
|
package/dist/langchain.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "agentid-sdk",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "AgentID JavaScript/TypeScript SDK for guard, ingest, tracing, and analytics.",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"homepage": "https://agentid.ai",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/ondrejsukac-rgb/agentid.git",
|
|
10
|
-
"directory": "js-sdk"
|
|
11
|
-
},
|
|
12
|
-
"bugs": {
|
|
13
|
-
"url": "https://github.com/ondrejsukac-rgb/agentid/issues"
|
|
14
|
-
},
|
|
15
|
-
"main": "dist/index.js",
|
|
16
|
-
"module": "dist/index.mjs",
|
|
17
|
-
"types": "dist/index.d.ts",
|
|
18
|
-
"exports": {
|
|
19
|
-
".": {
|
|
20
|
-
"types": "./dist/index.d.ts",
|
|
21
|
-
"import": "./dist/index.mjs",
|
|
22
|
-
"require": "./dist/index.js"
|
|
23
|
-
},
|
|
24
|
-
"./langchain": {
|
|
25
|
-
"types": "./dist/langchain.d.ts",
|
|
26
|
-
"import": "./dist/langchain.mjs",
|
|
27
|
-
"require": "./dist/langchain.js"
|
|
28
|
-
},
|
|
29
|
-
"./transparency-badge": {
|
|
30
|
-
"types": "./dist/transparency-badge.d.ts",
|
|
31
|
-
"import": "./dist/transparency-badge.mjs",
|
|
32
|
-
"require": "./dist/transparency-badge.js"
|
|
33
|
-
},
|
|
34
|
-
"./package.json": "./package.json"
|
|
35
|
-
},
|
|
36
|
-
"files": [
|
|
37
|
-
"dist"
|
|
38
|
-
],
|
|
39
|
-
"scripts": {
|
|
40
|
-
"build": "tsup --config tsup.config.ts",
|
|
41
|
-
"release:check": "npm run build && npm pack --dry-run",
|
|
42
|
-
"prepublishOnly": "npm run build"
|
|
43
|
-
},
|
|
44
|
-
"publishConfig": {
|
|
45
|
-
"access": "public"
|
|
46
|
-
},
|
|
47
|
-
"peerDependencies": {
|
|
48
|
-
"@langchain/core": "^0.3.0 || ^1.0.0",
|
|
49
|
-
"langchain": "^0.1.0",
|
|
50
|
-
"openai": "^4.0.0 || ^5.0.0 || ^6.0.0",
|
|
51
|
-
"react": "^18.0.0 || ^19.0.0"
|
|
52
|
-
},
|
|
53
|
-
"peerDependenciesMeta": {
|
|
54
|
-
"@langchain/core": {
|
|
55
|
-
"optional": true
|
|
56
|
-
},
|
|
57
|
-
"langchain": {
|
|
58
|
-
"optional": true
|
|
59
|
-
},
|
|
60
|
-
"react": {
|
|
61
|
-
"optional": true
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
"devDependencies": {
|
|
65
|
-
"@types/react": "^19.2.2",
|
|
66
|
-
"tsup": "^8.3.5",
|
|
67
|
-
"typescript": "^5.0.0"
|
|
68
|
-
}
|
|
69
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "agentid-sdk",
|
|
3
|
+
"version": "0.1.32",
|
|
4
|
+
"description": "AgentID JavaScript/TypeScript SDK for guard, ingest, tracing, and analytics.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://agentid.ai",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/ondrejsukac-rgb/agentid.git",
|
|
10
|
+
"directory": "js-sdk"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/ondrejsukac-rgb/agentid/issues"
|
|
14
|
+
},
|
|
15
|
+
"main": "dist/index.js",
|
|
16
|
+
"module": "dist/index.mjs",
|
|
17
|
+
"types": "dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.mjs",
|
|
22
|
+
"require": "./dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./langchain": {
|
|
25
|
+
"types": "./dist/langchain.d.ts",
|
|
26
|
+
"import": "./dist/langchain.mjs",
|
|
27
|
+
"require": "./dist/langchain.js"
|
|
28
|
+
},
|
|
29
|
+
"./transparency-badge": {
|
|
30
|
+
"types": "./dist/transparency-badge.d.ts",
|
|
31
|
+
"import": "./dist/transparency-badge.mjs",
|
|
32
|
+
"require": "./dist/transparency-badge.js"
|
|
33
|
+
},
|
|
34
|
+
"./package.json": "./package.json"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsup --config tsup.config.ts",
|
|
41
|
+
"release:check": "npm run build && npm pack --dry-run",
|
|
42
|
+
"prepublishOnly": "npm run build"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@langchain/core": "^0.3.0 || ^1.0.0",
|
|
49
|
+
"langchain": "^0.1.0 || ^1.0.0",
|
|
50
|
+
"openai": "^4.0.0 || ^5.0.0 || ^6.0.0",
|
|
51
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
52
|
+
},
|
|
53
|
+
"peerDependenciesMeta": {
|
|
54
|
+
"@langchain/core": {
|
|
55
|
+
"optional": true
|
|
56
|
+
},
|
|
57
|
+
"langchain": {
|
|
58
|
+
"optional": true
|
|
59
|
+
},
|
|
60
|
+
"react": {
|
|
61
|
+
"optional": true
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@types/react": "^19.2.2",
|
|
66
|
+
"tsup": "^8.3.5",
|
|
67
|
+
"typescript": "^5.0.0"
|
|
68
|
+
}
|
|
69
|
+
}
|