@vibe-lark/larkpal 0.1.69 → 0.1.70

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.
Files changed (2) hide show
  1. package/dist/main.mjs +11 -56
  2. package/package.json +1 -1
package/dist/main.mjs CHANGED
@@ -3011,7 +3011,7 @@ function wrapLarkpalAgentAdapter(adapter) {
3011
3011
  return adapter.name;
3012
3012
  },
3013
3013
  executePrompt(config, callbacks) {
3014
- return adapter.executePrompt(normalizeLarkpalAgentConfig(config), callbacks);
3014
+ return adapter.executePrompt(config, callbacks);
3015
3015
  },
3016
3016
  stopProcess(sessionId) {
3017
3017
  return adapter.stopProcess(sessionId);
@@ -3030,59 +3030,6 @@ function wrapLarkpalAgentAdapter(adapter) {
3030
3030
  }
3031
3031
  };
3032
3032
  }
3033
- function normalizeLarkpalAgentConfig(config) {
3034
- if (!Array.isArray(config.prompt)) return config;
3035
- const textParts = [];
3036
- const imageArtifacts = [];
3037
- const imageLines = [];
3038
- config.prompt.forEach((block, index) => {
3039
- if (block.type === "text") {
3040
- if (block.text.trim()) textParts.push(block.text);
3041
- return;
3042
- }
3043
- if (block.type !== "image") return;
3044
- const artifact = toAgentImageArtifact(block, index);
3045
- const label = artifact?.assetId ?? block.fileKey ?? `image_${index + 1}`;
3046
- if (artifact) imageArtifacts.push(artifact);
3047
- imageLines.push(artifact ? `- ${label}: ${artifact.path} (${artifact.mimeType})` : `- ${label}: inline image omitted from text prompt (${block.source.media_type})`);
3048
- });
3049
- if (imageLines.length === 0) return config;
3050
- const prompt = [
3051
- textParts.join("\n\n").trim(),
3052
- "[Images]",
3053
- ...imageLines,
3054
- "The user is asking about these image attachments. Use visual or file tools to inspect the image pixels when needed; do not infer image content from the file name alone."
3055
- ].filter(Boolean).join("\n");
3056
- return {
3057
- ...config,
3058
- prompt,
3059
- sourceArtifacts: mergeSourceArtifacts(config.sourceArtifacts, imageArtifacts),
3060
- metadata: {
3061
- ...config.metadata,
3062
- inboundImageCount: imageLines.length,
3063
- visualAllowedDirs: [config.cwd]
3064
- }
3065
- };
3066
- }
3067
- function toAgentImageArtifact(block, index) {
3068
- if (!block.filePath) return null;
3069
- return {
3070
- type: "image_asset",
3071
- assetId: block.fileKey ?? `inbound_image_${index + 1}`,
3072
- path: block.filePath,
3073
- mimeType: block.source.media_type.split(";", 1)[0] || "image/png",
3074
- metadata: {
3075
- source: "feishu-message",
3076
- fileKey: block.fileKey
3077
- }
3078
- };
3079
- }
3080
- function mergeSourceArtifacts(existing, imageArtifacts) {
3081
- if (imageArtifacts.length === 0) return existing;
3082
- if (existing === void 0) return imageArtifacts;
3083
- if (Array.isArray(existing)) return [...existing, ...imageArtifacts];
3084
- return [existing, ...imageArtifacts];
3085
- }
3086
3033
  function getArtifactId(artifact) {
3087
3034
  const artifactId = typeof artifact.artifactId === "string" ? artifact.artifactId.trim() : "";
3088
3035
  if (artifactId.startsWith("art_")) return artifactId;
@@ -9121,6 +9068,7 @@ function getUserFacingErrorMessage(error) {
9121
9068
  const log$21 = larkLogger("card/cc-stream-bridge");
9122
9069
  const CC_INTERNAL_PLACEHOLDER = "No response requested.";
9123
9070
  const CLAUDE_INVALID_PARAMETER_PATTERN = /API Error:\s*400\b.*parameter specified in the request is not valid/i;
9071
+ const TOOL_PROGRESS_CARD_REFRESH_INTERVAL_MS = 15e3;
9124
9072
  function buildClaudeCodeUserFacingError(errorMessage, hasImages) {
9125
9073
  if (hasImages && CLAUDE_INVALID_PARAMETER_PATTERN.test(errorMessage)) return createUserFacingError([
9126
9074
  "当前运行时无法处理这条图片消息。",
@@ -9144,6 +9092,8 @@ var CCStreamBridge = class {
9144
9092
  activeTools = /* @__PURE__ */ new Map();
9145
9093
  /** 最近一次 toolUseStart 的工具名(用于 toolResult 时查找) */
9146
9094
  lastToolName = null;
9095
+ /** 最近一次由 tool_progress 推动卡片刷新的时间 */
9096
+ lastToolProgressCardRefreshAt = 0;
9147
9097
  controller;
9148
9098
  options;
9149
9099
  constructor(controller, options) {
@@ -9232,13 +9182,18 @@ var CCStreamBridge = class {
9232
9182
  });
9233
9183
  this.controller.onToolPayload({ text: `✅ ${displayName} 完成` });
9234
9184
  }
9235
- /** 工具执行进度 → 记录日志 */
9185
+ /** 工具执行进度 → 节流刷新卡片,避免长工具执行期间卡片长时间无可见更新 */
9236
9186
  onToolProgress(toolName, elapsedSeconds) {
9187
+ const displayName = getToolDisplayName(toolName);
9237
9188
  log$21.debug("toolProgress 事件", {
9238
9189
  toolName,
9239
- displayName: getToolDisplayName(toolName),
9190
+ displayName,
9240
9191
  elapsedSeconds
9241
9192
  });
9193
+ const now = Date.now();
9194
+ if (now - this.lastToolProgressCardRefreshAt < TOOL_PROGRESS_CARD_REFRESH_INTERVAL_MS) return;
9195
+ this.lastToolProgressCardRefreshAt = now;
9196
+ this.controller.onToolPayload({ text: `${displayName} running for ${Math.max(0, Math.floor(elapsedSeconds))}s` });
9242
9197
  }
9243
9198
  /** 轮次结束 → 仅在 end_turn 时标记完成 + 触发 onIdle */
9244
9199
  onTurnEnd(stopReason) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibe-lark/larkpal",
3
- "version": "0.1.69",
3
+ "version": "0.1.70",
4
4
  "description": "LarkPal - Lark/Feishu bot service",
5
5
  "type": "module",
6
6
  "main": "./dist/main.mjs",