agentid-sdk 0.1.0 → 0.1.2
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/dist/{chunk-5VHWMLV2.mjs → chunk-LWL2WG5B.mjs} +20 -4
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +51 -12
- package/dist/index.mjs +32 -9
- package/dist/{langchain-BdIOZZVq.d.mts → langchain-ranVjrg4.d.mts} +16 -0
- package/dist/{langchain-BdIOZZVq.d.ts → langchain-ranVjrg4.d.ts} +16 -0
- package/dist/langchain.d.mts +1 -1
- package/dist/langchain.d.ts +1 -1
- package/dist/langchain.js +20 -4
- package/dist/langchain.mjs +1 -1
- package/package.json +1 -1
|
@@ -123,6 +123,18 @@ var AgentIDCallbackHandler = class {
|
|
|
123
123
|
get requestOptions() {
|
|
124
124
|
return this.apiKeyOverride ? { apiKey: this.apiKeyOverride } : void 0;
|
|
125
125
|
}
|
|
126
|
+
getLangchainCapabilities() {
|
|
127
|
+
const piiMaskingEnabled = Boolean(
|
|
128
|
+
this.agent.piiMasking
|
|
129
|
+
);
|
|
130
|
+
return {
|
|
131
|
+
capabilities: {
|
|
132
|
+
has_feedback_handler: true,
|
|
133
|
+
pii_masking_enabled: piiMaskingEnabled,
|
|
134
|
+
framework: "langchain"
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
126
138
|
async preflight(input, stream) {
|
|
127
139
|
await this.agent.scanPromptInjection(input, this.requestOptions);
|
|
128
140
|
const prepared = await this.agent.prepareInputForDispatch({
|
|
@@ -151,7 +163,8 @@ var AgentIDCallbackHandler = class {
|
|
|
151
163
|
}
|
|
152
164
|
const verdict = await this.agent.guard({
|
|
153
165
|
input: sanitizedInput,
|
|
154
|
-
system_id: this.systemId
|
|
166
|
+
system_id: this.systemId,
|
|
167
|
+
client_capabilities: this.getLangchainCapabilities()
|
|
155
168
|
}, this.requestOptions);
|
|
156
169
|
if (!verdict.allowed) {
|
|
157
170
|
throw new Error(`AgentID: Security Blocked (${verdict.reason ?? "guard_denied"})`);
|
|
@@ -180,7 +193,8 @@ var AgentIDCallbackHandler = class {
|
|
|
180
193
|
}
|
|
181
194
|
const verdict = await this.agent.guard({
|
|
182
195
|
input: sanitizedInput,
|
|
183
|
-
system_id: this.systemId
|
|
196
|
+
system_id: this.systemId,
|
|
197
|
+
client_capabilities: this.getLangchainCapabilities()
|
|
184
198
|
}, this.requestOptions);
|
|
185
199
|
if (!verdict.allowed) {
|
|
186
200
|
throw new Error(`AgentID: Security Blocked (${verdict.reason ?? "guard_denied"})`);
|
|
@@ -205,7 +219,8 @@ var AgentIDCallbackHandler = class {
|
|
|
205
219
|
output: outText,
|
|
206
220
|
model: state.model ?? "unknown",
|
|
207
221
|
usage,
|
|
208
|
-
latency
|
|
222
|
+
latency,
|
|
223
|
+
client_capabilities: this.getLangchainCapabilities()
|
|
209
224
|
}, this.requestOptions);
|
|
210
225
|
}
|
|
211
226
|
async handleLLMError(err, runId) {
|
|
@@ -222,7 +237,8 @@ var AgentIDCallbackHandler = class {
|
|
|
222
237
|
severity: "error",
|
|
223
238
|
metadata: {
|
|
224
239
|
error_message: message
|
|
225
|
-
}
|
|
240
|
+
},
|
|
241
|
+
client_capabilities: this.getLangchainCapabilities()
|
|
226
242
|
}, this.requestOptions);
|
|
227
243
|
}
|
|
228
244
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AgentID, a as AgentIDCallbackHandler, G as GuardParams, b as GuardResponse, L as LogParams, P as PreparedInput, R as RequestOptions } from './langchain-
|
|
1
|
+
export { A as AgentID, a as AgentIDCallbackHandler, G as GuardParams, b as GuardResponse, L as LogParams, P as PreparedInput, R as RequestOptions } from './langchain-ranVjrg4.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, a as AgentIDCallbackHandler, G as GuardParams, b as GuardResponse, L as LogParams, P as PreparedInput, R as RequestOptions } from './langchain-
|
|
1
|
+
export { A as AgentID, a as AgentIDCallbackHandler, G as GuardParams, b as GuardResponse, L as LogParams, P as PreparedInput, R as RequestOptions } from './langchain-ranVjrg4.js';
|
|
2
2
|
|
|
3
3
|
type PIIMapping = Record<string, string>;
|
|
4
4
|
declare class PIIManager {
|
package/dist/index.js
CHANGED
|
@@ -942,7 +942,7 @@ var AgentID = class {
|
|
|
942
942
|
constructor(config) {
|
|
943
943
|
this.injectionScanner = getInjectionScanner();
|
|
944
944
|
this.apiKey = config.apiKey.trim();
|
|
945
|
-
this.baseUrl = normalizeBaseUrl3(config.baseUrl ?? "https://
|
|
945
|
+
this.baseUrl = normalizeBaseUrl3(config.baseUrl ?? "https://app.getagentid.com/api/v1");
|
|
946
946
|
this.piiMasking = Boolean(config.piiMasking);
|
|
947
947
|
this.checkInjection = config.checkInjection !== false;
|
|
948
948
|
this.aiScanEnabled = config.aiScanEnabled !== false;
|
|
@@ -951,6 +951,15 @@ var AgentID = class {
|
|
|
951
951
|
this.localEnforcer = new LocalSecurityEnforcer(this.pii);
|
|
952
952
|
void this.getCapabilityConfig();
|
|
953
953
|
}
|
|
954
|
+
buildClientCapabilities(framework = "js_sdk", hasFeedbackHandler = false) {
|
|
955
|
+
return {
|
|
956
|
+
capabilities: {
|
|
957
|
+
has_feedback_handler: hasFeedbackHandler,
|
|
958
|
+
pii_masking_enabled: this.piiMasking,
|
|
959
|
+
framework
|
|
960
|
+
}
|
|
961
|
+
};
|
|
962
|
+
}
|
|
954
963
|
resolveApiKey(overrideApiKey) {
|
|
955
964
|
const trimmed = overrideApiKey?.trim();
|
|
956
965
|
if (trimmed) {
|
|
@@ -1088,6 +1097,10 @@ var AgentID = class {
|
|
|
1088
1097
|
*/
|
|
1089
1098
|
async guard(params, options) {
|
|
1090
1099
|
const effectiveApiKey = this.resolveApiKey(options?.apiKey);
|
|
1100
|
+
const payload = {
|
|
1101
|
+
...params,
|
|
1102
|
+
client_capabilities: params.client_capabilities ?? this.buildClientCapabilities()
|
|
1103
|
+
};
|
|
1091
1104
|
const controller = new AbortController();
|
|
1092
1105
|
const timeoutId = setTimeout(() => controller.abort(), 2e3);
|
|
1093
1106
|
try {
|
|
@@ -1098,12 +1111,12 @@ var AgentID = class {
|
|
|
1098
1111
|
"x-agentid-api-key": effectiveApiKey,
|
|
1099
1112
|
"X-AgentID-SDK-Version": AGENTID_SDK_VERSION_HEADER2
|
|
1100
1113
|
},
|
|
1101
|
-
body: JSON.stringify(
|
|
1114
|
+
body: JSON.stringify(payload),
|
|
1102
1115
|
signal: controller.signal
|
|
1103
1116
|
});
|
|
1104
|
-
const
|
|
1105
|
-
if (
|
|
1106
|
-
return
|
|
1117
|
+
const responseBody = await safeReadJson2(res);
|
|
1118
|
+
if (responseBody && typeof responseBody.allowed === "boolean") {
|
|
1119
|
+
return responseBody;
|
|
1107
1120
|
}
|
|
1108
1121
|
if (!res.ok) {
|
|
1109
1122
|
throw new Error(`API Error ${res.status}`);
|
|
@@ -1125,6 +1138,12 @@ var AgentID = class {
|
|
|
1125
1138
|
const eventId = params.event_id ?? (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function" ? crypto.randomUUID() : `evt_${Date.now()}_${Math.random().toString(36).slice(2)}`);
|
|
1126
1139
|
const timestamp = params.timestamp ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
1127
1140
|
void this.getCapabilityConfig(false, { apiKey: effectiveApiKey }).catch(() => void 0);
|
|
1141
|
+
const metadata = {
|
|
1142
|
+
...params.metadata ?? {}
|
|
1143
|
+
};
|
|
1144
|
+
if (!Object.prototype.hasOwnProperty.call(metadata, "agentid_base_url")) {
|
|
1145
|
+
metadata.agentid_base_url = this.baseUrl;
|
|
1146
|
+
}
|
|
1128
1147
|
void fetch(`${this.baseUrl}/ingest`, {
|
|
1129
1148
|
method: "POST",
|
|
1130
1149
|
headers: {
|
|
@@ -1135,7 +1154,9 @@ var AgentID = class {
|
|
|
1135
1154
|
body: JSON.stringify({
|
|
1136
1155
|
...params,
|
|
1137
1156
|
event_id: eventId,
|
|
1138
|
-
timestamp
|
|
1157
|
+
timestamp,
|
|
1158
|
+
metadata,
|
|
1159
|
+
client_capabilities: params.client_capabilities ?? this.buildClientCapabilities()
|
|
1139
1160
|
})
|
|
1140
1161
|
}).catch((error) => {
|
|
1141
1162
|
console.error("[AgentID] Log failed:", error);
|
|
@@ -1233,7 +1254,8 @@ var AgentID = class {
|
|
|
1233
1254
|
}
|
|
1234
1255
|
const verdict = await this.guard({
|
|
1235
1256
|
input: maskedText,
|
|
1236
|
-
system_id: systemId
|
|
1257
|
+
system_id: systemId,
|
|
1258
|
+
client_capabilities: this.buildClientCapabilities("openai", false)
|
|
1237
1259
|
}, requestOptions);
|
|
1238
1260
|
if (!verdict.allowed) {
|
|
1239
1261
|
throw new Error(
|
|
@@ -1259,7 +1281,8 @@ var AgentID = class {
|
|
|
1259
1281
|
output,
|
|
1260
1282
|
model,
|
|
1261
1283
|
usage,
|
|
1262
|
-
latency
|
|
1284
|
+
latency,
|
|
1285
|
+
client_capabilities: this.buildClientCapabilities("openai", false)
|
|
1263
1286
|
}, requestOptions);
|
|
1264
1287
|
}
|
|
1265
1288
|
if (!capabilityConfig.block_pii_leakage && this.piiMasking && shouldDeanonymize) {
|
|
@@ -1423,6 +1446,18 @@ var AgentIDCallbackHandler = class {
|
|
|
1423
1446
|
get requestOptions() {
|
|
1424
1447
|
return this.apiKeyOverride ? { apiKey: this.apiKeyOverride } : void 0;
|
|
1425
1448
|
}
|
|
1449
|
+
getLangchainCapabilities() {
|
|
1450
|
+
const piiMaskingEnabled = Boolean(
|
|
1451
|
+
this.agent.piiMasking
|
|
1452
|
+
);
|
|
1453
|
+
return {
|
|
1454
|
+
capabilities: {
|
|
1455
|
+
has_feedback_handler: true,
|
|
1456
|
+
pii_masking_enabled: piiMaskingEnabled,
|
|
1457
|
+
framework: "langchain"
|
|
1458
|
+
}
|
|
1459
|
+
};
|
|
1460
|
+
}
|
|
1426
1461
|
async preflight(input, stream) {
|
|
1427
1462
|
await this.agent.scanPromptInjection(input, this.requestOptions);
|
|
1428
1463
|
const prepared = await this.agent.prepareInputForDispatch({
|
|
@@ -1451,7 +1486,8 @@ var AgentIDCallbackHandler = class {
|
|
|
1451
1486
|
}
|
|
1452
1487
|
const verdict = await this.agent.guard({
|
|
1453
1488
|
input: sanitizedInput,
|
|
1454
|
-
system_id: this.systemId
|
|
1489
|
+
system_id: this.systemId,
|
|
1490
|
+
client_capabilities: this.getLangchainCapabilities()
|
|
1455
1491
|
}, this.requestOptions);
|
|
1456
1492
|
if (!verdict.allowed) {
|
|
1457
1493
|
throw new Error(`AgentID: Security Blocked (${verdict.reason ?? "guard_denied"})`);
|
|
@@ -1480,7 +1516,8 @@ var AgentIDCallbackHandler = class {
|
|
|
1480
1516
|
}
|
|
1481
1517
|
const verdict = await this.agent.guard({
|
|
1482
1518
|
input: sanitizedInput,
|
|
1483
|
-
system_id: this.systemId
|
|
1519
|
+
system_id: this.systemId,
|
|
1520
|
+
client_capabilities: this.getLangchainCapabilities()
|
|
1484
1521
|
}, this.requestOptions);
|
|
1485
1522
|
if (!verdict.allowed) {
|
|
1486
1523
|
throw new Error(`AgentID: Security Blocked (${verdict.reason ?? "guard_denied"})`);
|
|
@@ -1505,7 +1542,8 @@ var AgentIDCallbackHandler = class {
|
|
|
1505
1542
|
output: outText,
|
|
1506
1543
|
model: state.model ?? "unknown",
|
|
1507
1544
|
usage,
|
|
1508
|
-
latency
|
|
1545
|
+
latency,
|
|
1546
|
+
client_capabilities: this.getLangchainCapabilities()
|
|
1509
1547
|
}, this.requestOptions);
|
|
1510
1548
|
}
|
|
1511
1549
|
async handleLLMError(err, runId) {
|
|
@@ -1522,7 +1560,8 @@ var AgentIDCallbackHandler = class {
|
|
|
1522
1560
|
severity: "error",
|
|
1523
1561
|
metadata: {
|
|
1524
1562
|
error_message: message
|
|
1525
|
-
}
|
|
1563
|
+
},
|
|
1564
|
+
client_capabilities: this.getLangchainCapabilities()
|
|
1526
1565
|
}, this.requestOptions);
|
|
1527
1566
|
}
|
|
1528
1567
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentIDCallbackHandler
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LWL2WG5B.mjs";
|
|
4
4
|
|
|
5
5
|
// src/adapters.ts
|
|
6
6
|
var OpenAIAdapter = class {
|
|
@@ -904,7 +904,7 @@ var AgentID = class {
|
|
|
904
904
|
constructor(config) {
|
|
905
905
|
this.injectionScanner = getInjectionScanner();
|
|
906
906
|
this.apiKey = config.apiKey.trim();
|
|
907
|
-
this.baseUrl = normalizeBaseUrl3(config.baseUrl ?? "https://
|
|
907
|
+
this.baseUrl = normalizeBaseUrl3(config.baseUrl ?? "https://app.getagentid.com/api/v1");
|
|
908
908
|
this.piiMasking = Boolean(config.piiMasking);
|
|
909
909
|
this.checkInjection = config.checkInjection !== false;
|
|
910
910
|
this.aiScanEnabled = config.aiScanEnabled !== false;
|
|
@@ -913,6 +913,15 @@ var AgentID = class {
|
|
|
913
913
|
this.localEnforcer = new LocalSecurityEnforcer(this.pii);
|
|
914
914
|
void this.getCapabilityConfig();
|
|
915
915
|
}
|
|
916
|
+
buildClientCapabilities(framework = "js_sdk", hasFeedbackHandler = false) {
|
|
917
|
+
return {
|
|
918
|
+
capabilities: {
|
|
919
|
+
has_feedback_handler: hasFeedbackHandler,
|
|
920
|
+
pii_masking_enabled: this.piiMasking,
|
|
921
|
+
framework
|
|
922
|
+
}
|
|
923
|
+
};
|
|
924
|
+
}
|
|
916
925
|
resolveApiKey(overrideApiKey) {
|
|
917
926
|
const trimmed = overrideApiKey?.trim();
|
|
918
927
|
if (trimmed) {
|
|
@@ -1050,6 +1059,10 @@ var AgentID = class {
|
|
|
1050
1059
|
*/
|
|
1051
1060
|
async guard(params, options) {
|
|
1052
1061
|
const effectiveApiKey = this.resolveApiKey(options?.apiKey);
|
|
1062
|
+
const payload = {
|
|
1063
|
+
...params,
|
|
1064
|
+
client_capabilities: params.client_capabilities ?? this.buildClientCapabilities()
|
|
1065
|
+
};
|
|
1053
1066
|
const controller = new AbortController();
|
|
1054
1067
|
const timeoutId = setTimeout(() => controller.abort(), 2e3);
|
|
1055
1068
|
try {
|
|
@@ -1060,12 +1073,12 @@ var AgentID = class {
|
|
|
1060
1073
|
"x-agentid-api-key": effectiveApiKey,
|
|
1061
1074
|
"X-AgentID-SDK-Version": AGENTID_SDK_VERSION_HEADER2
|
|
1062
1075
|
},
|
|
1063
|
-
body: JSON.stringify(
|
|
1076
|
+
body: JSON.stringify(payload),
|
|
1064
1077
|
signal: controller.signal
|
|
1065
1078
|
});
|
|
1066
|
-
const
|
|
1067
|
-
if (
|
|
1068
|
-
return
|
|
1079
|
+
const responseBody = await safeReadJson2(res);
|
|
1080
|
+
if (responseBody && typeof responseBody.allowed === "boolean") {
|
|
1081
|
+
return responseBody;
|
|
1069
1082
|
}
|
|
1070
1083
|
if (!res.ok) {
|
|
1071
1084
|
throw new Error(`API Error ${res.status}`);
|
|
@@ -1087,6 +1100,12 @@ var AgentID = class {
|
|
|
1087
1100
|
const eventId = params.event_id ?? (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function" ? crypto.randomUUID() : `evt_${Date.now()}_${Math.random().toString(36).slice(2)}`);
|
|
1088
1101
|
const timestamp = params.timestamp ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
1089
1102
|
void this.getCapabilityConfig(false, { apiKey: effectiveApiKey }).catch(() => void 0);
|
|
1103
|
+
const metadata = {
|
|
1104
|
+
...params.metadata ?? {}
|
|
1105
|
+
};
|
|
1106
|
+
if (!Object.prototype.hasOwnProperty.call(metadata, "agentid_base_url")) {
|
|
1107
|
+
metadata.agentid_base_url = this.baseUrl;
|
|
1108
|
+
}
|
|
1090
1109
|
void fetch(`${this.baseUrl}/ingest`, {
|
|
1091
1110
|
method: "POST",
|
|
1092
1111
|
headers: {
|
|
@@ -1097,7 +1116,9 @@ var AgentID = class {
|
|
|
1097
1116
|
body: JSON.stringify({
|
|
1098
1117
|
...params,
|
|
1099
1118
|
event_id: eventId,
|
|
1100
|
-
timestamp
|
|
1119
|
+
timestamp,
|
|
1120
|
+
metadata,
|
|
1121
|
+
client_capabilities: params.client_capabilities ?? this.buildClientCapabilities()
|
|
1101
1122
|
})
|
|
1102
1123
|
}).catch((error) => {
|
|
1103
1124
|
console.error("[AgentID] Log failed:", error);
|
|
@@ -1195,7 +1216,8 @@ var AgentID = class {
|
|
|
1195
1216
|
}
|
|
1196
1217
|
const verdict = await this.guard({
|
|
1197
1218
|
input: maskedText,
|
|
1198
|
-
system_id: systemId
|
|
1219
|
+
system_id: systemId,
|
|
1220
|
+
client_capabilities: this.buildClientCapabilities("openai", false)
|
|
1199
1221
|
}, requestOptions);
|
|
1200
1222
|
if (!verdict.allowed) {
|
|
1201
1223
|
throw new Error(
|
|
@@ -1221,7 +1243,8 @@ var AgentID = class {
|
|
|
1221
1243
|
output,
|
|
1222
1244
|
model,
|
|
1223
1245
|
usage,
|
|
1224
|
-
latency
|
|
1246
|
+
latency,
|
|
1247
|
+
client_capabilities: this.buildClientCapabilities("openai", false)
|
|
1225
1248
|
}, requestOptions);
|
|
1226
1249
|
}
|
|
1227
1250
|
if (!capabilityConfig.block_pii_leakage && this.piiMasking && shouldDeanonymize) {
|
|
@@ -9,6 +9,13 @@ interface GuardParams {
|
|
|
9
9
|
input: string;
|
|
10
10
|
system_id: string;
|
|
11
11
|
user_id?: string;
|
|
12
|
+
client_capabilities?: {
|
|
13
|
+
capabilities: {
|
|
14
|
+
has_feedback_handler: boolean;
|
|
15
|
+
pii_masking_enabled: boolean;
|
|
16
|
+
framework: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
12
19
|
}
|
|
13
20
|
interface GuardResponse {
|
|
14
21
|
allowed: boolean;
|
|
@@ -32,6 +39,13 @@ interface LogParams {
|
|
|
32
39
|
event_type?: "start" | "complete" | "error" | "human_override" | "security_alert" | "security_block" | "security_policy_violation";
|
|
33
40
|
severity?: "info" | "warning" | "error" | "high";
|
|
34
41
|
timestamp?: string;
|
|
42
|
+
client_capabilities?: {
|
|
43
|
+
capabilities: {
|
|
44
|
+
has_feedback_handler: boolean;
|
|
45
|
+
pii_masking_enabled: boolean;
|
|
46
|
+
framework: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
35
49
|
}
|
|
36
50
|
type AgentIDConfig = {
|
|
37
51
|
apiKey: string;
|
|
@@ -57,6 +71,7 @@ declare class AgentID {
|
|
|
57
71
|
private localEnforcer;
|
|
58
72
|
private injectionScanner;
|
|
59
73
|
constructor(config: AgentIDConfig);
|
|
74
|
+
private buildClientCapabilities;
|
|
60
75
|
private resolveApiKey;
|
|
61
76
|
getCapabilityConfig(force?: boolean, options?: RequestOptions): Promise<CapabilityConfig>;
|
|
62
77
|
private getCachedCapabilityConfig;
|
|
@@ -118,6 +133,7 @@ declare class AgentIDCallbackHandler {
|
|
|
118
133
|
api_key?: string;
|
|
119
134
|
});
|
|
120
135
|
private get requestOptions();
|
|
136
|
+
private getLangchainCapabilities;
|
|
121
137
|
private preflight;
|
|
122
138
|
handleLLMStart(serialized: unknown, prompts: unknown, runId?: string, _parentRunId?: string, extraParams?: unknown): Promise<void>;
|
|
123
139
|
handleChatModelStart(serialized: unknown, messages: unknown, runId?: string, _parentRunId?: string, extraParams?: unknown): Promise<void>;
|
|
@@ -9,6 +9,13 @@ interface GuardParams {
|
|
|
9
9
|
input: string;
|
|
10
10
|
system_id: string;
|
|
11
11
|
user_id?: string;
|
|
12
|
+
client_capabilities?: {
|
|
13
|
+
capabilities: {
|
|
14
|
+
has_feedback_handler: boolean;
|
|
15
|
+
pii_masking_enabled: boolean;
|
|
16
|
+
framework: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
12
19
|
}
|
|
13
20
|
interface GuardResponse {
|
|
14
21
|
allowed: boolean;
|
|
@@ -32,6 +39,13 @@ interface LogParams {
|
|
|
32
39
|
event_type?: "start" | "complete" | "error" | "human_override" | "security_alert" | "security_block" | "security_policy_violation";
|
|
33
40
|
severity?: "info" | "warning" | "error" | "high";
|
|
34
41
|
timestamp?: string;
|
|
42
|
+
client_capabilities?: {
|
|
43
|
+
capabilities: {
|
|
44
|
+
has_feedback_handler: boolean;
|
|
45
|
+
pii_masking_enabled: boolean;
|
|
46
|
+
framework: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
35
49
|
}
|
|
36
50
|
type AgentIDConfig = {
|
|
37
51
|
apiKey: string;
|
|
@@ -57,6 +71,7 @@ declare class AgentID {
|
|
|
57
71
|
private localEnforcer;
|
|
58
72
|
private injectionScanner;
|
|
59
73
|
constructor(config: AgentIDConfig);
|
|
74
|
+
private buildClientCapabilities;
|
|
60
75
|
private resolveApiKey;
|
|
61
76
|
getCapabilityConfig(force?: boolean, options?: RequestOptions): Promise<CapabilityConfig>;
|
|
62
77
|
private getCachedCapabilityConfig;
|
|
@@ -118,6 +133,7 @@ declare class AgentIDCallbackHandler {
|
|
|
118
133
|
api_key?: string;
|
|
119
134
|
});
|
|
120
135
|
private get requestOptions();
|
|
136
|
+
private getLangchainCapabilities;
|
|
121
137
|
private preflight;
|
|
122
138
|
handleLLMStart(serialized: unknown, prompts: unknown, runId?: string, _parentRunId?: string, extraParams?: unknown): Promise<void>;
|
|
123
139
|
handleChatModelStart(serialized: unknown, messages: unknown, runId?: string, _parentRunId?: string, extraParams?: unknown): Promise<void>;
|
package/dist/langchain.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { a as AgentIDCallbackHandler } from './langchain-
|
|
1
|
+
export { a as AgentIDCallbackHandler } from './langchain-ranVjrg4.mjs';
|
package/dist/langchain.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { a as AgentIDCallbackHandler } from './langchain-
|
|
1
|
+
export { a as AgentIDCallbackHandler } from './langchain-ranVjrg4.js';
|
package/dist/langchain.js
CHANGED
|
@@ -147,6 +147,18 @@ var AgentIDCallbackHandler = class {
|
|
|
147
147
|
get requestOptions() {
|
|
148
148
|
return this.apiKeyOverride ? { apiKey: this.apiKeyOverride } : void 0;
|
|
149
149
|
}
|
|
150
|
+
getLangchainCapabilities() {
|
|
151
|
+
const piiMaskingEnabled = Boolean(
|
|
152
|
+
this.agent.piiMasking
|
|
153
|
+
);
|
|
154
|
+
return {
|
|
155
|
+
capabilities: {
|
|
156
|
+
has_feedback_handler: true,
|
|
157
|
+
pii_masking_enabled: piiMaskingEnabled,
|
|
158
|
+
framework: "langchain"
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
150
162
|
async preflight(input, stream) {
|
|
151
163
|
await this.agent.scanPromptInjection(input, this.requestOptions);
|
|
152
164
|
const prepared = await this.agent.prepareInputForDispatch({
|
|
@@ -175,7 +187,8 @@ var AgentIDCallbackHandler = class {
|
|
|
175
187
|
}
|
|
176
188
|
const verdict = await this.agent.guard({
|
|
177
189
|
input: sanitizedInput,
|
|
178
|
-
system_id: this.systemId
|
|
190
|
+
system_id: this.systemId,
|
|
191
|
+
client_capabilities: this.getLangchainCapabilities()
|
|
179
192
|
}, this.requestOptions);
|
|
180
193
|
if (!verdict.allowed) {
|
|
181
194
|
throw new Error(`AgentID: Security Blocked (${verdict.reason ?? "guard_denied"})`);
|
|
@@ -204,7 +217,8 @@ var AgentIDCallbackHandler = class {
|
|
|
204
217
|
}
|
|
205
218
|
const verdict = await this.agent.guard({
|
|
206
219
|
input: sanitizedInput,
|
|
207
|
-
system_id: this.systemId
|
|
220
|
+
system_id: this.systemId,
|
|
221
|
+
client_capabilities: this.getLangchainCapabilities()
|
|
208
222
|
}, this.requestOptions);
|
|
209
223
|
if (!verdict.allowed) {
|
|
210
224
|
throw new Error(`AgentID: Security Blocked (${verdict.reason ?? "guard_denied"})`);
|
|
@@ -229,7 +243,8 @@ var AgentIDCallbackHandler = class {
|
|
|
229
243
|
output: outText,
|
|
230
244
|
model: state.model ?? "unknown",
|
|
231
245
|
usage,
|
|
232
|
-
latency
|
|
246
|
+
latency,
|
|
247
|
+
client_capabilities: this.getLangchainCapabilities()
|
|
233
248
|
}, this.requestOptions);
|
|
234
249
|
}
|
|
235
250
|
async handleLLMError(err, runId) {
|
|
@@ -246,7 +261,8 @@ var AgentIDCallbackHandler = class {
|
|
|
246
261
|
severity: "error",
|
|
247
262
|
metadata: {
|
|
248
263
|
error_message: message
|
|
249
|
-
}
|
|
264
|
+
},
|
|
265
|
+
client_capabilities: this.getLangchainCapabilities()
|
|
250
266
|
}, this.requestOptions);
|
|
251
267
|
}
|
|
252
268
|
};
|
package/dist/langchain.mjs
CHANGED