agentid-sdk 0.1.4 → 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 CHANGED
@@ -45,7 +45,10 @@ const agent = new AgentID({
45
45
  // strictMode: true, // fail-closed for high-risk workloads
46
46
  });
47
47
 
48
- const proxiedOpenAI = agent.wrapOpenAI(openai, { system_id: "sys_..." });
48
+ const proxiedOpenAI = agent.wrapOpenAI(openai, {
49
+ system_id: "sys_...",
50
+ user_id: "system-auto-summary", // optional service/user identity
51
+ });
49
52
  ```
50
53
 
51
54
  ## 🔒 Klíčové vlastnosti
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-Cn7doPo2.mjs';
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-Cn7doPo2.js';
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
@@ -984,6 +984,10 @@ var AGENTID_SDK_VERSION_HEADER2 = "js-1.0.4";
984
984
  function normalizeBaseUrl3(baseUrl) {
985
985
  return baseUrl.replace(/\/+$/, "");
986
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
+ }
987
991
  async function safeReadJson2(response) {
988
992
  try {
989
993
  return await response.json();
@@ -1171,7 +1175,14 @@ var AgentID = class {
1171
1175
  });
1172
1176
  const responseBody = await safeReadJson2(res);
1173
1177
  if (responseBody && typeof responseBody.allowed === "boolean") {
1174
- return responseBody;
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;
1175
1186
  }
1176
1187
  if (!res.ok) {
1177
1188
  throw new Error(`API Error ${res.status}`);
@@ -1325,6 +1336,7 @@ var AgentID = class {
1325
1336
  const verdict = await this.guard({
1326
1337
  input: maskedText,
1327
1338
  system_id: systemId,
1339
+ user_id: options.user_id,
1328
1340
  client_capabilities: this.buildClientCapabilities("openai", false)
1329
1341
  }, requestOptions);
1330
1342
  if (!verdict.allowed) {
@@ -1347,6 +1359,7 @@ var AgentID = class {
1347
1359
  const usage = adapter.getTokenUsage(res);
1348
1360
  this.log({
1349
1361
  system_id: systemId,
1362
+ user_id: options.user_id,
1350
1363
  input: maskedText,
1351
1364
  output,
1352
1365
  model,
package/dist/index.mjs CHANGED
@@ -946,6 +946,10 @@ var AGENTID_SDK_VERSION_HEADER2 = "js-1.0.4";
946
946
  function normalizeBaseUrl3(baseUrl) {
947
947
  return baseUrl.replace(/\/+$/, "");
948
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
+ }
949
953
  async function safeReadJson2(response) {
950
954
  try {
951
955
  return await response.json();
@@ -1133,7 +1137,14 @@ var AgentID = class {
1133
1137
  });
1134
1138
  const responseBody = await safeReadJson2(res);
1135
1139
  if (responseBody && typeof responseBody.allowed === "boolean") {
1136
- return responseBody;
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;
1137
1148
  }
1138
1149
  if (!res.ok) {
1139
1150
  throw new Error(`API Error ${res.status}`);
@@ -1287,6 +1298,7 @@ var AgentID = class {
1287
1298
  const verdict = await this.guard({
1288
1299
  input: maskedText,
1289
1300
  system_id: systemId,
1301
+ user_id: options.user_id,
1290
1302
  client_capabilities: this.buildClientCapabilities("openai", false)
1291
1303
  }, requestOptions);
1292
1304
  if (!verdict.allowed) {
@@ -1309,6 +1321,7 @@ var AgentID = class {
1309
1321
  const usage = adapter.getTokenUsage(res);
1310
1322
  this.log({
1311
1323
  system_id: systemId,
1324
+ user_id: options.user_id,
1312
1325
  input: maskedText,
1313
1326
  output,
1314
1327
  model,
@@ -113,6 +113,7 @@ declare class AgentID {
113
113
  */
114
114
  wrapOpenAI<T>(openai: T, options: {
115
115
  system_id: string;
116
+ user_id?: string;
116
117
  apiKey?: string;
117
118
  api_key?: string;
118
119
  resolveApiKey?: (request: Record<string, unknown>) => string | undefined;
@@ -113,6 +113,7 @@ declare class AgentID {
113
113
  */
114
114
  wrapOpenAI<T>(openai: T, options: {
115
115
  system_id: string;
116
+ user_id?: string;
116
117
  apiKey?: string;
117
118
  api_key?: string;
118
119
  resolveApiKey?: (request: Record<string, unknown>) => string | undefined;
@@ -1 +1 @@
1
- export { a as AgentIDCallbackHandler } from './langchain-Cn7doPo2.mjs';
1
+ export { a as AgentIDCallbackHandler } from './langchain-CIIL2j4R.mjs';
@@ -1 +1 @@
1
- export { a as AgentIDCallbackHandler } from './langchain-Cn7doPo2.js';
1
+ export { a as AgentIDCallbackHandler } from './langchain-CIIL2j4R.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentid-sdk",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "AgentID JavaScript/TypeScript SDK for guard, ingest, tracing, and analytics.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://agentid.ai",