agentid-sdk 0.1.3 → 0.1.5
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 +11 -3
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +94 -11
- package/dist/index.mjs +94 -11
- package/dist/{langchain-ranVjrg4.d.mts → langchain-CIIL2j4R.d.mts} +5 -1
- package/dist/{langchain-ranVjrg4.d.ts → langchain-CIIL2j4R.d.ts} +5 -1
- package/dist/langchain.d.mts +1 -1
- package/dist/langchain.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,9 +39,16 @@ import { AgentID } from "agentid-sdk";
|
|
|
39
39
|
import OpenAI from "openai";
|
|
40
40
|
|
|
41
41
|
const openai = new OpenAI();
|
|
42
|
-
const agent = new AgentID({
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
const agent = new AgentID({
|
|
43
|
+
apiKey: "ag_prod_...",
|
|
44
|
+
strictMode: false, // default (fail-open on timeout/unreachable AgentID API)
|
|
45
|
+
// strictMode: true, // fail-closed for high-risk workloads
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const proxiedOpenAI = agent.wrapOpenAI(openai, {
|
|
49
|
+
system_id: "sys_...",
|
|
50
|
+
user_id: "system-auto-summary", // optional service/user identity
|
|
51
|
+
});
|
|
45
52
|
```
|
|
46
53
|
|
|
47
54
|
## 🔒 Klíčové vlastnosti
|
|
@@ -49,3 +56,4 @@ const proxiedOpenAI = agent.wrapOpenAI(openai, { system_id: "sys_..." });
|
|
|
49
56
|
- PII Scrubbing: Automatická redakce e-mailů, rodných čísel a hesel před odesláním do cloudu.
|
|
50
57
|
- Crypto-Shredding: Možnost nenávratně smazat citlivá data z logů na žádost uživatele (GDPR).
|
|
51
58
|
- Fail-Safe architektura: Inteligentní přepínání mezi bezpečností a dostupností (Fail-Open/Closed).
|
|
59
|
+
- Strict mode: při timeoutu Guard API můžeš vynutit fail-closed (`strictMode: true`).
|
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-CIIL2j4R.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-CIIL2j4R.js';
|
|
2
2
|
|
|
3
3
|
type PIIMapping = Record<string, string>;
|
|
4
4
|
declare class PIIManager {
|
package/dist/index.js
CHANGED
|
@@ -389,9 +389,19 @@ var LocalSecurityEnforcer = class {
|
|
|
389
389
|
|
|
390
390
|
// src/capability-config.ts
|
|
391
391
|
var CONFIG_TTL_MS = 5 * 60 * 1e3;
|
|
392
|
-
var CONFIG_TIMEOUT_MS =
|
|
392
|
+
var CONFIG_TIMEOUT_MS = 8e3;
|
|
393
|
+
var CONFIG_RETRY_DELAY_MS = 1e3;
|
|
393
394
|
var MAX_CAPABILITY_CACHE_ENTRIES = 500;
|
|
394
395
|
var AGENTID_SDK_VERSION_HEADER = "js-1.0.4";
|
|
396
|
+
var CapabilityConfigFetchError = class extends Error {
|
|
397
|
+
constructor(message, params) {
|
|
398
|
+
super(message);
|
|
399
|
+
this.name = "CapabilityConfigFetchError";
|
|
400
|
+
this.status = params.status;
|
|
401
|
+
this.retryable = params.retryable;
|
|
402
|
+
this.timeout = params.timeout;
|
|
403
|
+
}
|
|
404
|
+
};
|
|
395
405
|
function normalizeBaseUrl(baseUrl) {
|
|
396
406
|
return baseUrl.replace(/\/+$/, "");
|
|
397
407
|
}
|
|
@@ -447,10 +457,13 @@ function enforceCacheBound(cache) {
|
|
|
447
457
|
}
|
|
448
458
|
cache.clear();
|
|
449
459
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
460
|
+
function sleep(ms) {
|
|
461
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
462
|
+
}
|
|
463
|
+
function isAbortError(error) {
|
|
464
|
+
return !!error && typeof error === "object" && error.name === "AbortError";
|
|
465
|
+
}
|
|
466
|
+
async function fetchCapabilityConfigAttempt(params) {
|
|
454
467
|
const controller = new AbortController();
|
|
455
468
|
const timeoutId = setTimeout(() => controller.abort(), params.timeoutMs);
|
|
456
469
|
try {
|
|
@@ -465,13 +478,52 @@ async function fetchCapabilityConfigWithTimeout(params) {
|
|
|
465
478
|
});
|
|
466
479
|
const payload = await safeReadJson(res);
|
|
467
480
|
if (!res.ok) {
|
|
468
|
-
|
|
481
|
+
const retryable = res.status >= 500 || res.status === 429 || res.status === 408;
|
|
482
|
+
throw new CapabilityConfigFetchError(`Config API Error ${res.status}`, {
|
|
483
|
+
status: res.status,
|
|
484
|
+
retryable,
|
|
485
|
+
timeout: false
|
|
486
|
+
});
|
|
469
487
|
}
|
|
470
488
|
return normalizeCapabilityConfig(payload);
|
|
489
|
+
} catch (error) {
|
|
490
|
+
if (error instanceof CapabilityConfigFetchError) {
|
|
491
|
+
throw error;
|
|
492
|
+
}
|
|
493
|
+
if (isAbortError(error)) {
|
|
494
|
+
throw new CapabilityConfigFetchError(
|
|
495
|
+
"AgentID SDK failed to initialize: Connection timeout during configuration fetch. Please check your network or AgentID API status.",
|
|
496
|
+
{
|
|
497
|
+
retryable: true,
|
|
498
|
+
timeout: true
|
|
499
|
+
}
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
throw new CapabilityConfigFetchError(
|
|
503
|
+
error instanceof Error ? error.message : "Configuration fetch failed.",
|
|
504
|
+
{
|
|
505
|
+
retryable: true,
|
|
506
|
+
timeout: false
|
|
507
|
+
}
|
|
508
|
+
);
|
|
471
509
|
} finally {
|
|
472
510
|
clearTimeout(timeoutId);
|
|
473
511
|
}
|
|
474
512
|
}
|
|
513
|
+
async function fetchCapabilityConfigWithTimeout(params) {
|
|
514
|
+
if (typeof fetch !== "function") {
|
|
515
|
+
throw new Error("fetch is unavailable in this runtime");
|
|
516
|
+
}
|
|
517
|
+
try {
|
|
518
|
+
return await fetchCapabilityConfigAttempt(params);
|
|
519
|
+
} catch (firstError) {
|
|
520
|
+
if (firstError instanceof CapabilityConfigFetchError && firstError.retryable) {
|
|
521
|
+
await sleep(CONFIG_RETRY_DELAY_MS);
|
|
522
|
+
return await fetchCapabilityConfigAttempt(params);
|
|
523
|
+
}
|
|
524
|
+
throw firstError;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
475
527
|
function getCachedCapabilityConfig(params) {
|
|
476
528
|
const key = getCacheKey(params.apiKey, params.baseUrl);
|
|
477
529
|
const entry = getGlobalCache().get(key);
|
|
@@ -503,7 +555,8 @@ async function ensureCapabilityConfig(params) {
|
|
|
503
555
|
enforceCacheBound(cache);
|
|
504
556
|
return resolved;
|
|
505
557
|
}).catch((error) => {
|
|
506
|
-
|
|
558
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
559
|
+
console.warn("AgentID Config unreachable. Defaulting to STRICT MODE.", message);
|
|
507
560
|
cache.set(key, {
|
|
508
561
|
config: DEFAULT_STRICT_CONFIG,
|
|
509
562
|
expiresAt: Date.now() + ttlMs,
|
|
@@ -931,6 +984,10 @@ var AGENTID_SDK_VERSION_HEADER2 = "js-1.0.4";
|
|
|
931
984
|
function normalizeBaseUrl3(baseUrl) {
|
|
932
985
|
return baseUrl.replace(/\/+$/, "");
|
|
933
986
|
}
|
|
987
|
+
function isInfrastructureGuardReason(reason) {
|
|
988
|
+
if (!reason) return false;
|
|
989
|
+
return reason === "system_failure" || reason === "system_failure_db_unavailable" || reason === "logging_failed" || reason === "server_error" || reason === "guard_unreachable" || reason === "api_key_pepper_missing" || reason === "encryption_key_missing";
|
|
990
|
+
}
|
|
934
991
|
async function safeReadJson2(response) {
|
|
935
992
|
try {
|
|
936
993
|
return await response.json();
|
|
@@ -947,6 +1004,7 @@ var AgentID = class {
|
|
|
947
1004
|
this.checkInjection = config.checkInjection !== false;
|
|
948
1005
|
this.aiScanEnabled = config.aiScanEnabled !== false;
|
|
949
1006
|
this.storePii = config.storePii === true;
|
|
1007
|
+
this.strictMode = config.strictMode === true;
|
|
950
1008
|
this.pii = new PIIManager();
|
|
951
1009
|
this.localEnforcer = new LocalSecurityEnforcer(this.pii);
|
|
952
1010
|
void this.getCapabilityConfig();
|
|
@@ -1093,7 +1151,8 @@ var AgentID = class {
|
|
|
1093
1151
|
}
|
|
1094
1152
|
/**
|
|
1095
1153
|
* GUARD: Checks limits, PII, and security before execution.
|
|
1096
|
-
*
|
|
1154
|
+
* strictMode=false (default): FAIL-OPEN on connectivity/timeouts.
|
|
1155
|
+
* strictMode=true: FAIL-CLOSED and throws on connectivity/timeouts.
|
|
1097
1156
|
*/
|
|
1098
1157
|
async guard(params, options) {
|
|
1099
1158
|
const effectiveApiKey = this.resolveApiKey(options?.apiKey);
|
|
@@ -1116,15 +1175,37 @@ var AgentID = class {
|
|
|
1116
1175
|
});
|
|
1117
1176
|
const responseBody = await safeReadJson2(res);
|
|
1118
1177
|
if (responseBody && typeof responseBody.allowed === "boolean") {
|
|
1119
|
-
|
|
1178
|
+
const verdict = responseBody;
|
|
1179
|
+
if (!this.strictMode && verdict.allowed === false && (isInfrastructureGuardReason(verdict.reason) || res.status >= 500)) {
|
|
1180
|
+
console.warn(
|
|
1181
|
+
`[AgentID] Guard API infrastructure fallback in fail-open mode (${verdict.reason ?? `http_${res.status}`}).`
|
|
1182
|
+
);
|
|
1183
|
+
return { allowed: true, reason: "system_failure_fail_open" };
|
|
1184
|
+
}
|
|
1185
|
+
return verdict;
|
|
1120
1186
|
}
|
|
1121
1187
|
if (!res.ok) {
|
|
1122
1188
|
throw new Error(`API Error ${res.status}`);
|
|
1123
1189
|
}
|
|
1124
1190
|
throw new Error("Invalid guard response");
|
|
1125
1191
|
} catch (error) {
|
|
1126
|
-
|
|
1127
|
-
|
|
1192
|
+
const isAbortError2 = error && typeof error === "object" && error.name === "AbortError";
|
|
1193
|
+
if (isAbortError2) {
|
|
1194
|
+
const timeoutMessage = "AgentID API Warning: Connection timeout exceeded.";
|
|
1195
|
+
if (this.strictMode) {
|
|
1196
|
+
throw new Error(timeoutMessage);
|
|
1197
|
+
}
|
|
1198
|
+
console.warn(timeoutMessage);
|
|
1199
|
+
return { allowed: true, reason: "timeout_fallback" };
|
|
1200
|
+
}
|
|
1201
|
+
if (this.strictMode) {
|
|
1202
|
+
if (error instanceof Error) {
|
|
1203
|
+
throw error;
|
|
1204
|
+
}
|
|
1205
|
+
throw new Error("AgentID API Error: Guard request failed.");
|
|
1206
|
+
}
|
|
1207
|
+
console.warn("[AgentID] Guard check failed (Fail-Open active):", error);
|
|
1208
|
+
return { allowed: true, reason: "guard_unreachable" };
|
|
1128
1209
|
} finally {
|
|
1129
1210
|
clearTimeout(timeoutId);
|
|
1130
1211
|
}
|
|
@@ -1255,6 +1336,7 @@ var AgentID = class {
|
|
|
1255
1336
|
const verdict = await this.guard({
|
|
1256
1337
|
input: maskedText,
|
|
1257
1338
|
system_id: systemId,
|
|
1339
|
+
user_id: options.user_id,
|
|
1258
1340
|
client_capabilities: this.buildClientCapabilities("openai", false)
|
|
1259
1341
|
}, requestOptions);
|
|
1260
1342
|
if (!verdict.allowed) {
|
|
@@ -1277,6 +1359,7 @@ var AgentID = class {
|
|
|
1277
1359
|
const usage = adapter.getTokenUsage(res);
|
|
1278
1360
|
this.log({
|
|
1279
1361
|
system_id: systemId,
|
|
1362
|
+
user_id: options.user_id,
|
|
1280
1363
|
input: maskedText,
|
|
1281
1364
|
output,
|
|
1282
1365
|
model,
|
package/dist/index.mjs
CHANGED
|
@@ -351,9 +351,19 @@ var LocalSecurityEnforcer = class {
|
|
|
351
351
|
|
|
352
352
|
// src/capability-config.ts
|
|
353
353
|
var CONFIG_TTL_MS = 5 * 60 * 1e3;
|
|
354
|
-
var CONFIG_TIMEOUT_MS =
|
|
354
|
+
var CONFIG_TIMEOUT_MS = 8e3;
|
|
355
|
+
var CONFIG_RETRY_DELAY_MS = 1e3;
|
|
355
356
|
var MAX_CAPABILITY_CACHE_ENTRIES = 500;
|
|
356
357
|
var AGENTID_SDK_VERSION_HEADER = "js-1.0.4";
|
|
358
|
+
var CapabilityConfigFetchError = class extends Error {
|
|
359
|
+
constructor(message, params) {
|
|
360
|
+
super(message);
|
|
361
|
+
this.name = "CapabilityConfigFetchError";
|
|
362
|
+
this.status = params.status;
|
|
363
|
+
this.retryable = params.retryable;
|
|
364
|
+
this.timeout = params.timeout;
|
|
365
|
+
}
|
|
366
|
+
};
|
|
357
367
|
function normalizeBaseUrl(baseUrl) {
|
|
358
368
|
return baseUrl.replace(/\/+$/, "");
|
|
359
369
|
}
|
|
@@ -409,10 +419,13 @@ function enforceCacheBound(cache) {
|
|
|
409
419
|
}
|
|
410
420
|
cache.clear();
|
|
411
421
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
422
|
+
function sleep(ms) {
|
|
423
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
424
|
+
}
|
|
425
|
+
function isAbortError(error) {
|
|
426
|
+
return !!error && typeof error === "object" && error.name === "AbortError";
|
|
427
|
+
}
|
|
428
|
+
async function fetchCapabilityConfigAttempt(params) {
|
|
416
429
|
const controller = new AbortController();
|
|
417
430
|
const timeoutId = setTimeout(() => controller.abort(), params.timeoutMs);
|
|
418
431
|
try {
|
|
@@ -427,13 +440,52 @@ async function fetchCapabilityConfigWithTimeout(params) {
|
|
|
427
440
|
});
|
|
428
441
|
const payload = await safeReadJson(res);
|
|
429
442
|
if (!res.ok) {
|
|
430
|
-
|
|
443
|
+
const retryable = res.status >= 500 || res.status === 429 || res.status === 408;
|
|
444
|
+
throw new CapabilityConfigFetchError(`Config API Error ${res.status}`, {
|
|
445
|
+
status: res.status,
|
|
446
|
+
retryable,
|
|
447
|
+
timeout: false
|
|
448
|
+
});
|
|
431
449
|
}
|
|
432
450
|
return normalizeCapabilityConfig(payload);
|
|
451
|
+
} catch (error) {
|
|
452
|
+
if (error instanceof CapabilityConfigFetchError) {
|
|
453
|
+
throw error;
|
|
454
|
+
}
|
|
455
|
+
if (isAbortError(error)) {
|
|
456
|
+
throw new CapabilityConfigFetchError(
|
|
457
|
+
"AgentID SDK failed to initialize: Connection timeout during configuration fetch. Please check your network or AgentID API status.",
|
|
458
|
+
{
|
|
459
|
+
retryable: true,
|
|
460
|
+
timeout: true
|
|
461
|
+
}
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
throw new CapabilityConfigFetchError(
|
|
465
|
+
error instanceof Error ? error.message : "Configuration fetch failed.",
|
|
466
|
+
{
|
|
467
|
+
retryable: true,
|
|
468
|
+
timeout: false
|
|
469
|
+
}
|
|
470
|
+
);
|
|
433
471
|
} finally {
|
|
434
472
|
clearTimeout(timeoutId);
|
|
435
473
|
}
|
|
436
474
|
}
|
|
475
|
+
async function fetchCapabilityConfigWithTimeout(params) {
|
|
476
|
+
if (typeof fetch !== "function") {
|
|
477
|
+
throw new Error("fetch is unavailable in this runtime");
|
|
478
|
+
}
|
|
479
|
+
try {
|
|
480
|
+
return await fetchCapabilityConfigAttempt(params);
|
|
481
|
+
} catch (firstError) {
|
|
482
|
+
if (firstError instanceof CapabilityConfigFetchError && firstError.retryable) {
|
|
483
|
+
await sleep(CONFIG_RETRY_DELAY_MS);
|
|
484
|
+
return await fetchCapabilityConfigAttempt(params);
|
|
485
|
+
}
|
|
486
|
+
throw firstError;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
437
489
|
function getCachedCapabilityConfig(params) {
|
|
438
490
|
const key = getCacheKey(params.apiKey, params.baseUrl);
|
|
439
491
|
const entry = getGlobalCache().get(key);
|
|
@@ -465,7 +517,8 @@ async function ensureCapabilityConfig(params) {
|
|
|
465
517
|
enforceCacheBound(cache);
|
|
466
518
|
return resolved;
|
|
467
519
|
}).catch((error) => {
|
|
468
|
-
|
|
520
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
521
|
+
console.warn("AgentID Config unreachable. Defaulting to STRICT MODE.", message);
|
|
469
522
|
cache.set(key, {
|
|
470
523
|
config: DEFAULT_STRICT_CONFIG,
|
|
471
524
|
expiresAt: Date.now() + ttlMs,
|
|
@@ -893,6 +946,10 @@ var AGENTID_SDK_VERSION_HEADER2 = "js-1.0.4";
|
|
|
893
946
|
function normalizeBaseUrl3(baseUrl) {
|
|
894
947
|
return baseUrl.replace(/\/+$/, "");
|
|
895
948
|
}
|
|
949
|
+
function isInfrastructureGuardReason(reason) {
|
|
950
|
+
if (!reason) return false;
|
|
951
|
+
return reason === "system_failure" || reason === "system_failure_db_unavailable" || reason === "logging_failed" || reason === "server_error" || reason === "guard_unreachable" || reason === "api_key_pepper_missing" || reason === "encryption_key_missing";
|
|
952
|
+
}
|
|
896
953
|
async function safeReadJson2(response) {
|
|
897
954
|
try {
|
|
898
955
|
return await response.json();
|
|
@@ -909,6 +966,7 @@ var AgentID = class {
|
|
|
909
966
|
this.checkInjection = config.checkInjection !== false;
|
|
910
967
|
this.aiScanEnabled = config.aiScanEnabled !== false;
|
|
911
968
|
this.storePii = config.storePii === true;
|
|
969
|
+
this.strictMode = config.strictMode === true;
|
|
912
970
|
this.pii = new PIIManager();
|
|
913
971
|
this.localEnforcer = new LocalSecurityEnforcer(this.pii);
|
|
914
972
|
void this.getCapabilityConfig();
|
|
@@ -1055,7 +1113,8 @@ var AgentID = class {
|
|
|
1055
1113
|
}
|
|
1056
1114
|
/**
|
|
1057
1115
|
* GUARD: Checks limits, PII, and security before execution.
|
|
1058
|
-
*
|
|
1116
|
+
* strictMode=false (default): FAIL-OPEN on connectivity/timeouts.
|
|
1117
|
+
* strictMode=true: FAIL-CLOSED and throws on connectivity/timeouts.
|
|
1059
1118
|
*/
|
|
1060
1119
|
async guard(params, options) {
|
|
1061
1120
|
const effectiveApiKey = this.resolveApiKey(options?.apiKey);
|
|
@@ -1078,15 +1137,37 @@ var AgentID = class {
|
|
|
1078
1137
|
});
|
|
1079
1138
|
const responseBody = await safeReadJson2(res);
|
|
1080
1139
|
if (responseBody && typeof responseBody.allowed === "boolean") {
|
|
1081
|
-
|
|
1140
|
+
const verdict = responseBody;
|
|
1141
|
+
if (!this.strictMode && verdict.allowed === false && (isInfrastructureGuardReason(verdict.reason) || res.status >= 500)) {
|
|
1142
|
+
console.warn(
|
|
1143
|
+
`[AgentID] Guard API infrastructure fallback in fail-open mode (${verdict.reason ?? `http_${res.status}`}).`
|
|
1144
|
+
);
|
|
1145
|
+
return { allowed: true, reason: "system_failure_fail_open" };
|
|
1146
|
+
}
|
|
1147
|
+
return verdict;
|
|
1082
1148
|
}
|
|
1083
1149
|
if (!res.ok) {
|
|
1084
1150
|
throw new Error(`API Error ${res.status}`);
|
|
1085
1151
|
}
|
|
1086
1152
|
throw new Error("Invalid guard response");
|
|
1087
1153
|
} catch (error) {
|
|
1088
|
-
|
|
1089
|
-
|
|
1154
|
+
const isAbortError2 = error && typeof error === "object" && error.name === "AbortError";
|
|
1155
|
+
if (isAbortError2) {
|
|
1156
|
+
const timeoutMessage = "AgentID API Warning: Connection timeout exceeded.";
|
|
1157
|
+
if (this.strictMode) {
|
|
1158
|
+
throw new Error(timeoutMessage);
|
|
1159
|
+
}
|
|
1160
|
+
console.warn(timeoutMessage);
|
|
1161
|
+
return { allowed: true, reason: "timeout_fallback" };
|
|
1162
|
+
}
|
|
1163
|
+
if (this.strictMode) {
|
|
1164
|
+
if (error instanceof Error) {
|
|
1165
|
+
throw error;
|
|
1166
|
+
}
|
|
1167
|
+
throw new Error("AgentID API Error: Guard request failed.");
|
|
1168
|
+
}
|
|
1169
|
+
console.warn("[AgentID] Guard check failed (Fail-Open active):", error);
|
|
1170
|
+
return { allowed: true, reason: "guard_unreachable" };
|
|
1090
1171
|
} finally {
|
|
1091
1172
|
clearTimeout(timeoutId);
|
|
1092
1173
|
}
|
|
@@ -1217,6 +1298,7 @@ var AgentID = class {
|
|
|
1217
1298
|
const verdict = await this.guard({
|
|
1218
1299
|
input: maskedText,
|
|
1219
1300
|
system_id: systemId,
|
|
1301
|
+
user_id: options.user_id,
|
|
1220
1302
|
client_capabilities: this.buildClientCapabilities("openai", false)
|
|
1221
1303
|
}, requestOptions);
|
|
1222
1304
|
if (!verdict.allowed) {
|
|
@@ -1239,6 +1321,7 @@ var AgentID = class {
|
|
|
1239
1321
|
const usage = adapter.getTokenUsage(res);
|
|
1240
1322
|
this.log({
|
|
1241
1323
|
system_id: systemId,
|
|
1324
|
+
user_id: options.user_id,
|
|
1242
1325
|
input: maskedText,
|
|
1243
1326
|
output,
|
|
1244
1327
|
model,
|
|
@@ -54,6 +54,7 @@ type AgentIDConfig = {
|
|
|
54
54
|
checkInjection?: boolean;
|
|
55
55
|
aiScanEnabled?: boolean;
|
|
56
56
|
storePii?: boolean;
|
|
57
|
+
strictMode?: boolean;
|
|
57
58
|
};
|
|
58
59
|
|
|
59
60
|
type PreparedInput = {
|
|
@@ -67,6 +68,7 @@ declare class AgentID {
|
|
|
67
68
|
private checkInjection;
|
|
68
69
|
private aiScanEnabled;
|
|
69
70
|
private storePii;
|
|
71
|
+
private strictMode;
|
|
70
72
|
private pii;
|
|
71
73
|
private localEnforcer;
|
|
72
74
|
private injectionScanner;
|
|
@@ -86,7 +88,8 @@ declare class AgentID {
|
|
|
86
88
|
private logSecurityPolicyViolation;
|
|
87
89
|
/**
|
|
88
90
|
* GUARD: Checks limits, PII, and security before execution.
|
|
89
|
-
*
|
|
91
|
+
* strictMode=false (default): FAIL-OPEN on connectivity/timeouts.
|
|
92
|
+
* strictMode=true: FAIL-CLOSED and throws on connectivity/timeouts.
|
|
90
93
|
*/
|
|
91
94
|
guard(params: GuardParams, options?: RequestOptions): Promise<GuardResponse>;
|
|
92
95
|
/**
|
|
@@ -110,6 +113,7 @@ declare class AgentID {
|
|
|
110
113
|
*/
|
|
111
114
|
wrapOpenAI<T>(openai: T, options: {
|
|
112
115
|
system_id: string;
|
|
116
|
+
user_id?: string;
|
|
113
117
|
apiKey?: string;
|
|
114
118
|
api_key?: string;
|
|
115
119
|
resolveApiKey?: (request: Record<string, unknown>) => string | undefined;
|
|
@@ -54,6 +54,7 @@ type AgentIDConfig = {
|
|
|
54
54
|
checkInjection?: boolean;
|
|
55
55
|
aiScanEnabled?: boolean;
|
|
56
56
|
storePii?: boolean;
|
|
57
|
+
strictMode?: boolean;
|
|
57
58
|
};
|
|
58
59
|
|
|
59
60
|
type PreparedInput = {
|
|
@@ -67,6 +68,7 @@ declare class AgentID {
|
|
|
67
68
|
private checkInjection;
|
|
68
69
|
private aiScanEnabled;
|
|
69
70
|
private storePii;
|
|
71
|
+
private strictMode;
|
|
70
72
|
private pii;
|
|
71
73
|
private localEnforcer;
|
|
72
74
|
private injectionScanner;
|
|
@@ -86,7 +88,8 @@ declare class AgentID {
|
|
|
86
88
|
private logSecurityPolicyViolation;
|
|
87
89
|
/**
|
|
88
90
|
* GUARD: Checks limits, PII, and security before execution.
|
|
89
|
-
*
|
|
91
|
+
* strictMode=false (default): FAIL-OPEN on connectivity/timeouts.
|
|
92
|
+
* strictMode=true: FAIL-CLOSED and throws on connectivity/timeouts.
|
|
90
93
|
*/
|
|
91
94
|
guard(params: GuardParams, options?: RequestOptions): Promise<GuardResponse>;
|
|
92
95
|
/**
|
|
@@ -110,6 +113,7 @@ declare class AgentID {
|
|
|
110
113
|
*/
|
|
111
114
|
wrapOpenAI<T>(openai: T, options: {
|
|
112
115
|
system_id: string;
|
|
116
|
+
user_id?: string;
|
|
113
117
|
apiKey?: string;
|
|
114
118
|
api_key?: string;
|
|
115
119
|
resolveApiKey?: (request: Record<string, unknown>) => string | undefined;
|
package/dist/langchain.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { a as AgentIDCallbackHandler } from './langchain-
|
|
1
|
+
export { a as AgentIDCallbackHandler } from './langchain-CIIL2j4R.mjs';
|
package/dist/langchain.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { a as AgentIDCallbackHandler } from './langchain-
|
|
1
|
+
export { a as AgentIDCallbackHandler } from './langchain-CIIL2j4R.js';
|