@volcengine/agent-sentry 1.7.1 → 1.8.1

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/bundle.js CHANGED
@@ -182149,6 +182149,27 @@ var MessageCache = class {
182149
182149
  init_define_process_env();
182150
182150
  var import_node_https2 = __toESM(require("node:https"), 1);
182151
182151
  init_src();
182152
+
182153
+ // src/utils/volcengine-lumen-auth.ts
182154
+ init_define_process_env();
182155
+ var VOLCENGINE_API_KEY_ENV = "VOLCENGINE_API_KEY";
182156
+ function readVolcengineLumenApiKey() {
182157
+ const runtime = globalThis;
182158
+ const apiKey = runtime.process?.env?.[VOLCENGINE_API_KEY_ENV]?.trim();
182159
+ return apiKey || void 0;
182160
+ }
182161
+ function applyLumenIamAuthorization(headers, apiKey) {
182162
+ if (!apiKey) {
182163
+ return { ...headers };
182164
+ }
182165
+ const result = Object.fromEntries(
182166
+ Object.entries(headers).filter(([name]) => name.toLowerCase() !== "authorization")
182167
+ );
182168
+ result.Authorization = `Bearer ${apiKey}`;
182169
+ return result;
182170
+ }
182171
+
182172
+ // src/client.ts
182152
182173
  var HttpError = class extends Error {
182153
182174
  constructor(message, status, statusText, body) {
182154
182175
  super(message);
@@ -182229,6 +182250,7 @@ var LLMShieldClient = class _LLMShieldClient {
182229
182250
  this.ctEndpoint = (options.ctEndpoint || "").replace(/\/$/, "");
182230
182251
  this.lmEndpoint = (options.lmEndpoint || "").replace(/\/$/, "");
182231
182252
  this.apiKey = options.apiKey;
182253
+ this.lumenIamApiKey = readVolcengineLumenApiKey();
182232
182254
  this.timeoutMs = options.timeoutMs ?? 3e4;
182233
182255
  this.logger = options.logger;
182234
182256
  this.logRecord = Boolean(options.logRecord);
@@ -182277,10 +182299,13 @@ var LLMShieldClient = class _LLMShieldClient {
182277
182299
  const mergedSignal = signal ? AbortSignal.any([controller.signal, signal]) : controller.signal;
182278
182300
  const startedAt = Date.now();
182279
182301
  try {
182280
- const headers = {
182302
+ let headers = {
182281
182303
  "Content-Type": "application/json",
182282
182304
  ...extraHeaders
182283
182305
  };
182306
+ if (_LLMShieldClient.LUMEN_PATHS.has(path25)) {
182307
+ headers = applyLumenIamAuthorization(headers, this.lumenIamApiKey);
182308
+ }
182284
182309
  const resp = await this.fetchFn(
182285
182310
  url2,
182286
182311
  this.buildFetchInit(url2, {
@@ -182365,11 +182390,13 @@ var LLMShieldClient = class _LLMShieldClient {
182365
182390
  const path25 = "/OpenTOP/V1/Lumen/Moderate";
182366
182391
  const endpoint = this.getEndpointForPath(path25);
182367
182392
  const url2 = `${endpoint}${path25}`;
182393
+ const headers = applyLumenIamAuthorization({}, this.lumenIamApiKey);
182368
182394
  const resp = await this.fetchFn(
182369
182395
  url2,
182370
182396
  this.buildFetchInit(url2, {
182371
182397
  method: "OPTIONS",
182372
182398
  // Use OPTIONS or a simple GET to check connectivity
182399
+ headers,
182373
182400
  signal: controller.signal
182374
182401
  })
182375
182402
  );
@@ -184981,7 +185008,7 @@ var VOLCENGINE_AICC_MODEL_CATALOG = [
184981
185008
  id: "deepseek-v4-pro",
184982
185009
  name: "DeepSeek V4 Pro (AICC)",
184983
185010
  reasoning: true,
184984
- input: ["text", "image"],
185011
+ input: ["text"],
184985
185012
  contextWindow: 1e6,
184986
185013
  maxTokens: 8192
184987
185014
  },
@@ -184989,7 +185016,7 @@ var VOLCENGINE_AICC_MODEL_CATALOG = [
184989
185016
  id: "glm-5.1",
184990
185017
  name: "GLM 5.1 (AICC)",
184991
185018
  reasoning: true,
184992
- input: ["text", "image"],
185019
+ input: ["text"],
184993
185020
  contextWindow: 2e5,
184994
185021
  maxTokens: 8192
184995
185022
  },
@@ -185005,7 +185032,7 @@ var VOLCENGINE_AICC_MODEL_CATALOG = [
185005
185032
  id: "glm-4.7",
185006
185033
  name: "GLM 4.7 (AICC)",
185007
185034
  reasoning: true,
185008
- input: ["text", "image"],
185035
+ input: ["text"],
185009
185036
  contextWindow: 2e5,
185010
185037
  maxTokens: 8192
185011
185038
  }
@@ -187112,35 +187139,9 @@ function stringifyToolParamsForModeration(params) {
187112
187139
  return String(params ?? "");
187113
187140
  }
187114
187141
  }
187115
- function pickToolParamString(params, keys) {
187116
- if (!params || typeof params !== "object" || Array.isArray(params)) {
187117
- return void 0;
187118
- }
187119
- const record2 = params;
187120
- for (const key of keys) {
187121
- const value = record2[key];
187122
- if (typeof value === "string" && value.trim()) {
187123
- return value.trim();
187124
- }
187125
- }
187126
- return void 0;
187127
- }
187128
187142
  function buildBeforeToolCallModerationContent(params) {
187129
187143
  const toolName = String(params.toolName ?? "not_available");
187130
- if (params.inlineContent) {
187131
- return `Tool: ${toolName}
187132
- FileContent:
187133
- ${params.inlineContent}`;
187134
- }
187135
- const command = pickToolParamString(params.toolParams, ["command", "cmd", "script", "input"]);
187136
- if (!command) {
187137
- return `Tool: ${toolName}, Params: ${params.toolParamsText}`;
187138
- }
187139
- return [
187140
- `Tool: ${toolName}`,
187141
- `Command: ${command}`,
187142
- `Params: ${params.toolParamsText}`
187143
- ].join("\n");
187144
+ return `Tool: ${toolName}, Params: ${params.toolParamsText}`;
187144
187145
  }
187145
187146
 
187146
187147
  // src/hooks.ts
@@ -187615,8 +187616,7 @@ async function checkBeforeToolCallAndMaybeBlock({
187615
187616
  let content = buildBeforeToolCallModerationContent({
187616
187617
  toolName: event.toolName,
187617
187618
  toolParamsText,
187618
- toolParams: event.params,
187619
- inlineContent: inlineFilePayload.inlineContent
187619
+ toolParams: event.params
187620
187620
  });
187621
187621
  if (thinkingContent) {
187622
187622
  content = `${thinkingContent}
@@ -199488,16 +199488,20 @@ var ProxyRaProvider = class {
199488
199488
  constructor(proxyInfo) {
199489
199489
  this.type = "proxy";
199490
199490
  this.proxyInfo = proxyInfo;
199491
+ this.lumenIamApiKey = readVolcengineLumenApiKey();
199491
199492
  }
199492
199493
  async attest(request) {
199493
199494
  const url2 = new URL(this.proxyInfo.url);
199494
199495
  const body = JSON.stringify(request);
199495
- const headers = {
199496
- "Content-Type": "application/json",
199497
- "X-Ai-Claw-Id": this.proxyInfo.clawId,
199498
- "X-Ai-Claw-Api-Key": this.proxyInfo.clawApiKey,
199499
- "X-Ai-Device-Fingerprint": this.proxyInfo.fingerprint
199500
- };
199496
+ const headers = applyLumenIamAuthorization(
199497
+ {
199498
+ "Content-Type": "application/json",
199499
+ "X-Ai-Claw-Id": this.proxyInfo.clawId,
199500
+ "X-Ai-Claw-Api-Key": this.proxyInfo.clawApiKey,
199501
+ "X-Ai-Device-Fingerprint": this.proxyInfo.fingerprint
199502
+ },
199503
+ this.lumenIamApiKey
199504
+ );
199501
199505
  aiccFileLogger.info(`RA attest (proxy): fetch ${url2}`);
199502
199506
  const response = await httpRequest(url2, "POST", headers, body);
199503
199507
  const responseJson = JSON.parse(response);
@@ -199989,7 +199993,7 @@ function warmupVolcengineAiccAttestation() {
199989
199993
  await sleep6(AICC_WARMUP_MAP_WAIT_INTERVAL_MS);
199990
199994
  }
199991
199995
  if (contexts.length === 0) {
199992
- log2.warn(`AICC RA WARMUP skipped: ListClawModelRelation map still empty after ${AICC_WARMUP_MAP_WAIT_MAX_ATTEMPTS} attempts (will attest lazily on first request)`);
199996
+ log2.debug(`AICC RA WARMUP skipped: ListClawModelRelation map still empty after ${AICC_WARMUP_MAP_WAIT_MAX_ATTEMPTS} attempts (will attest lazily on first request)`);
199993
199997
  return;
199994
199998
  }
199995
199999
  const context = contexts[0];
@@ -200524,12 +200528,11 @@ async function readErrorBody(response, cryptoContext, rawBody) {
200524
200528
  }
200525
200529
  try {
200526
200530
  const decrypted = await decrypt(rawBody, cryptoContext);
200527
- if (typeof decrypted === "string") {
200528
- return `${response.status} decrypted error body redacted`;
200529
- }
200530
- return `${response.status} decrypted error body redacted`;
200531
+ const errorBody = typeof decrypted === "string" ? decrypted : JSON.stringify(decrypted);
200532
+ return `${response.status} ${errorBody || response.statusText || "error body unavailable"}`;
200531
200533
  } catch {
200532
- return `${response.status} ${response.statusText || "error body redacted"}`;
200534
+ const rawErrorBody = new TextDecoder().decode(rawBody).trim();
200535
+ return `${response.status} ${rawErrorBody || response.statusText || "error body unavailable"}`;
200533
200536
  }
200534
200537
  }
200535
200538
  function createVolcengineAiccStreamFn(ctx) {
@@ -201007,6 +201010,7 @@ var ApiClient2 = class {
201007
201010
  this.endpoint = config2.endpoint.replace(/\/$/, "");
201008
201011
  this.apiKey = config2.apiKey;
201009
201012
  this.pluginClawId = config2.pluginClawId;
201013
+ this.lumenIamApiKey = readVolcengineLumenApiKey();
201010
201014
  }
201011
201015
  async reportClawSkill(req) {
201012
201016
  const body = JSON.stringify(req);
@@ -201355,12 +201359,15 @@ var ApiClient2 = class {
201355
201359
  }
201356
201360
  async fetchWithApiKey(path25, method, body, headers = {}) {
201357
201361
  const url2 = `${this.endpoint}${path25.startsWith("/") ? path25 : `/${path25}`}`;
201358
- const requestHeaders = {
201359
- ...headers,
201360
- "X-Ai-Claw-Api-Key": this.apiKey || "",
201361
- "X-Ai-Claw-Id": this.pluginClawId || "",
201362
- ...deviceFingerprint ? { "X-Ai-Device-Fingerprint": deviceFingerprint } : {}
201363
- };
201362
+ const requestHeaders = applyLumenIamAuthorization(
201363
+ {
201364
+ ...headers,
201365
+ "X-Ai-Claw-Api-Key": this.apiKey || "",
201366
+ "X-Ai-Claw-Id": this.pluginClawId || "",
201367
+ ...deviceFingerprint ? { "X-Ai-Device-Fingerprint": deviceFingerprint } : {}
201368
+ },
201369
+ this.lumenIamApiKey
201370
+ );
201364
201371
  return await fetch2(url2, {
201365
201372
  method,
201366
201373
  headers: requestHeaders,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volcengine/agent-sentry",
3
- "version": "1.7.1",
3
+ "version": "1.8.1",
4
4
  "type": "module",
5
5
  "description": "AI Assistant Security plugin for OpenClaw, to protect your LLM models and Agent lifecycle (including tool calls) from harmful requests.",
6
6
  "packageManager": "pnpm@8.15.9",
@@ -56,7 +56,7 @@ var VOLCENGINE_AICC_MODEL_CATALOG = [
56
56
  id: "deepseek-v4-pro",
57
57
  name: "DeepSeek V4 Pro (AICC)",
58
58
  reasoning: true,
59
- input: ["text", "image"],
59
+ input: ["text"],
60
60
  contextWindow: 1e6,
61
61
  maxTokens: 8192
62
62
  },
@@ -64,7 +64,7 @@ var VOLCENGINE_AICC_MODEL_CATALOG = [
64
64
  id: "glm-5.1",
65
65
  name: "GLM 5.1 (AICC)",
66
66
  reasoning: true,
67
- input: ["text", "image"],
67
+ input: ["text"],
68
68
  contextWindow: 2e5,
69
69
  maxTokens: 8192
70
70
  },
@@ -80,7 +80,7 @@ var VOLCENGINE_AICC_MODEL_CATALOG = [
80
80
  id: "glm-4.7",
81
81
  name: "GLM 4.7 (AICC)",
82
82
  reasoning: true,
83
- input: ["text", "image"],
83
+ input: ["text"],
84
84
  contextWindow: 2e5,
85
85
  maxTokens: 8192
86
86
  }