@vibe-lark/larkpal 0.1.73 → 0.1.75

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 +312 -13
  2. package/package.json +1 -1
package/dist/main.mjs CHANGED
@@ -782,7 +782,10 @@ function getToolDisplayName(toolName) {
782
782
  * - parseError(error, rawLine) — 解析错误(不中断流)
783
783
  */
784
784
  const log$36 = larkLogger("cc-runtime/stream-parser");
785
+ const MAX_TOOL_RESULT_CONTENT_CHARS = 8e3;
785
786
  var CCStreamParser = class extends EventEmitter {
787
+ toolNamesById = /* @__PURE__ */ new Map();
788
+ declaredTools = null;
786
789
  /**
787
790
  * 解析一行 NDJSON 文本
788
791
  *
@@ -830,6 +833,7 @@ var CCStreamParser = class extends EventEmitter {
830
833
  subtype: msg.subtype,
831
834
  detail: JSON.stringify(msg).slice(0, 500)
832
835
  });
836
+ this.handleSystem(msg);
833
837
  this.emit("system", msg);
834
838
  break;
835
839
  default:
@@ -858,6 +862,7 @@ var CCStreamParser = class extends EventEmitter {
858
862
  toolUseId: block?.id
859
863
  });
860
864
  if (block?.type === "tool_use" && block.name) {
865
+ this.recordToolUse(block.name, block.id);
861
866
  log$36.info("工具调用开始", {
862
867
  toolName: block.name,
863
868
  displayName: getToolDisplayName(block.name),
@@ -905,6 +910,7 @@ var CCStreamParser = class extends EventEmitter {
905
910
  });
906
911
  if (Array.isArray(content)) {
907
912
  for (const block of content) if (block.type === "tool_use" && block.name) {
913
+ this.recordToolUse(block.name, block.id);
908
914
  log$36.info("从 assistant 消息提取工具调用", {
909
915
  toolName: block.name,
910
916
  displayName: getToolDisplayName(block.name),
@@ -924,10 +930,46 @@ var CCStreamParser = class extends EventEmitter {
924
930
  const content = msg.message?.content;
925
931
  if (!Array.isArray(content)) return;
926
932
  for (const item of content) if (item.type === "tool_result" && item.tool_use_id) {
927
- log$36.debug("工具结果返回", { toolUseId: item.tool_use_id });
928
- this.emit("toolResult", item.tool_use_id);
933
+ const result = this.buildToolResultSummary(item, msg.toolUseResult);
934
+ log$36.debug("工具结果返回", {
935
+ toolUseId: item.tool_use_id,
936
+ toolName: result.toolName,
937
+ isError: result.isError,
938
+ truncated: result.truncated
939
+ });
940
+ this.emit("toolResult", item.tool_use_id, result);
941
+ }
942
+ }
943
+ handleSystem(msg) {
944
+ if (msg.subtype !== "init" || !Array.isArray(msg.tools)) return;
945
+ this.declaredTools = new Set(msg.tools);
946
+ }
947
+ recordToolUse(toolName, toolUseId) {
948
+ if (toolUseId) this.toolNamesById.set(toolUseId, toolName);
949
+ if (this.declaredTools && !this.declaredTools.has(toolName)) {
950
+ log$36.warn("模型请求了未声明工具", {
951
+ toolName,
952
+ toolUseId
953
+ });
954
+ this.emit("unknownToolUse", toolName, toolUseId);
929
955
  }
930
956
  }
957
+ buildToolResultSummary(item, toolUseResult) {
958
+ const serializedContent = serializeToolResultContent(item.content);
959
+ const truncatedContent = truncateToolResultContent(serializedContent);
960
+ const toolUseResultSummary = summarizeToolUseResult(toolUseResult);
961
+ return {
962
+ toolCallId: item.tool_use_id,
963
+ toolName: this.toolNamesById.get(item.tool_use_id),
964
+ rawType: "tool_result",
965
+ isError: item.is_error,
966
+ content: truncatedContent.content,
967
+ resultSummary: extractToolResultSummary(serializedContent, toolUseResultSummary),
968
+ truncated: truncatedContent.truncated || toolUseResultSummary.truncated,
969
+ originalSize: Math.max(serializedContent.length, toolUseResultSummary.originalSize),
970
+ toolUseResult: toolUseResultSummary.summary
971
+ };
972
+ }
931
973
  /**
932
974
  * 处理 tool_progress 消息 — 工具执行进度
933
975
  */
@@ -959,6 +1001,52 @@ var CCStreamParser = class extends EventEmitter {
959
1001
  });
960
1002
  }
961
1003
  };
1004
+ function serializeToolResultContent(content) {
1005
+ if (typeof content === "string") return content;
1006
+ return safeJsonStringify(content);
1007
+ }
1008
+ function summarizeToolUseResult(value) {
1009
+ if (value === void 0) return {
1010
+ originalSize: 0,
1011
+ truncated: false
1012
+ };
1013
+ const serialized = typeof value === "string" ? value : safeJsonStringify(value);
1014
+ const truncated = truncateToolResultContent(serialized);
1015
+ return {
1016
+ summary: typeof value === "string" ? truncated.content : tryParseJson$1(truncated.content) ?? truncated.content,
1017
+ originalSize: serialized.length,
1018
+ truncated: truncated.truncated
1019
+ };
1020
+ }
1021
+ function truncateToolResultContent(content) {
1022
+ if (content.length <= MAX_TOOL_RESULT_CONTENT_CHARS) return {
1023
+ content,
1024
+ truncated: false
1025
+ };
1026
+ return {
1027
+ content: content.slice(0, MAX_TOOL_RESULT_CONTENT_CHARS),
1028
+ truncated: true
1029
+ };
1030
+ }
1031
+ function extractToolResultSummary(content, toolUseResult) {
1032
+ const text = (typeof toolUseResult.summary === "string" ? toolUseResult.summary : toolUseResult.summary === void 0 ? void 0 : safeJsonStringify(toolUseResult.summary)) || content;
1033
+ const summary = (text.match(/<tool_use_error>([\s\S]*?)<\/tool_use_error>/)?.[1] || text).trim();
1034
+ return summary ? truncateToolResultContent(summary).content : void 0;
1035
+ }
1036
+ function safeJsonStringify(value) {
1037
+ try {
1038
+ return JSON.stringify(value);
1039
+ } catch {
1040
+ return String(value);
1041
+ }
1042
+ }
1043
+ function tryParseJson$1(value) {
1044
+ try {
1045
+ return JSON.parse(value);
1046
+ } catch {
1047
+ return;
1048
+ }
1049
+ }
962
1050
  //#endregion
963
1051
  //#region src/cc-runtime/process-manager.ts
964
1052
  /**
@@ -1416,8 +1504,11 @@ var SessionProcessManager = class {
1416
1504
  parser.on("toolUseStart", (toolName, toolInput) => {
1417
1505
  getCallbacks()?.onToolUseStart?.(toolName, toolInput);
1418
1506
  });
1419
- parser.on("toolResult", (toolUseId) => {
1420
- getCallbacks()?.onToolResult?.(toolUseId);
1507
+ parser.on("toolResult", (toolUseId, result) => {
1508
+ getCallbacks()?.onToolResult?.(toolUseId, result);
1509
+ });
1510
+ parser.on("unknownToolUse", (toolName, toolUseId) => {
1511
+ getCallbacks()?.onUnknownToolUse?.(toolName, toolUseId);
1421
1512
  });
1422
1513
  parser.on("toolProgress", (toolName, elapsedSeconds) => {
1423
1514
  getCallbacks()?.onToolProgress?.(toolName, elapsedSeconds);
@@ -3373,6 +3464,139 @@ function createChatAuthRouter() {
3373
3464
  return router;
3374
3465
  }
3375
3466
  //#endregion
3467
+ //#region src/gateway/runtime-context.ts
3468
+ const CLAUDE_MD_START = "<!-- LARKPAL_RUNTIME_INSTRUCTIONS_START -->";
3469
+ const CLAUDE_MD_END = "<!-- LARKPAL_RUNTIME_INSTRUCTIONS_END -->";
3470
+ function materializeRuntimeContext(params) {
3471
+ const instructions = normalizeRuntimeInstructions(params.instructions);
3472
+ const skills = normalizeRuntimeSkills(params.skills);
3473
+ if (instructions.length === 0 && skills.length === 0) return void 0;
3474
+ return {
3475
+ instructions: instructions.length > 0 ? writeRuntimeInstructions(params.cwd, instructions) : [],
3476
+ skills: skills.map((skill) => writeRuntimeSkill(params.cwd, skill))
3477
+ };
3478
+ }
3479
+ function normalizeRuntimeInstructions(value) {
3480
+ if (!Array.isArray(value)) return [];
3481
+ return value.map((item) => {
3482
+ if (!item || typeof item !== "object" || Array.isArray(item)) return null;
3483
+ const record = item;
3484
+ const id = readNonEmptyString(record.id);
3485
+ const content = readNonEmptyString(record.content);
3486
+ if (!id || !content) return null;
3487
+ return {
3488
+ id,
3489
+ content,
3490
+ scope: readScope(record.scope),
3491
+ version: readNonEmptyString(record.version)
3492
+ };
3493
+ }).filter((item) => item != null);
3494
+ }
3495
+ function normalizeRuntimeSkills(value) {
3496
+ if (!Array.isArray(value)) return [];
3497
+ return value.map((item) => {
3498
+ if (!item || typeof item !== "object" || Array.isArray(item)) return null;
3499
+ const record = item;
3500
+ const id = readNonEmptyString(record.id);
3501
+ const content = readNonEmptyString(record.content) || readNonEmptyString(record.skillMarkdown);
3502
+ if (!id || !content) return null;
3503
+ return {
3504
+ id,
3505
+ content,
3506
+ scope: readScope(record.scope),
3507
+ version: readNonEmptyString(record.version),
3508
+ name: readNonEmptyString(record.name),
3509
+ description: readNonEmptyString(record.description)
3510
+ };
3511
+ }).filter((item) => item != null);
3512
+ }
3513
+ function writeRuntimeInstructions(cwd, instructions) {
3514
+ const filePath = join(cwd, "CLAUDE.md");
3515
+ const body = [
3516
+ CLAUDE_MD_START,
3517
+ "# LarkPal Runtime Instructions",
3518
+ "",
3519
+ "The following instructions were injected by LarkPal for this agent session. Treat them as runtime context, not as user message content.",
3520
+ "",
3521
+ ...instructions.flatMap((instruction) => [
3522
+ `## ${instruction.id}`,
3523
+ "",
3524
+ instruction.content.trim(),
3525
+ ""
3526
+ ]),
3527
+ CLAUDE_MD_END,
3528
+ ""
3529
+ ].join("\n");
3530
+ const next = replaceManagedBlock(existsSync(filePath) ? readFileSync(filePath, "utf-8") : "", body);
3531
+ mkdirSync(dirname(filePath), { recursive: true });
3532
+ writeFileSync(filePath, next, "utf-8");
3533
+ return instructions.map((instruction) => ({
3534
+ id: instruction.id,
3535
+ scope: instruction.scope ?? "request",
3536
+ hash: hashContent(instruction.content),
3537
+ version: instruction.version,
3538
+ path: "CLAUDE.md"
3539
+ }));
3540
+ }
3541
+ function writeRuntimeSkill(cwd, skill) {
3542
+ const relativePath = `.claude/skills/${sanitizePathSegment(skill.id)}/SKILL.md`;
3543
+ const filePath = join(cwd, relativePath);
3544
+ const content = buildSkillContent(skill);
3545
+ mkdirSync(dirname(filePath), { recursive: true });
3546
+ writeFileSync(filePath, content, "utf-8");
3547
+ return {
3548
+ id: skill.id,
3549
+ scope: skill.scope ?? "request",
3550
+ hash: hashContent(content),
3551
+ version: skill.version,
3552
+ path: relativePath
3553
+ };
3554
+ }
3555
+ function buildSkillContent(skill) {
3556
+ const content = skill.content.trim();
3557
+ if (content.startsWith("---")) return `${content}\n`;
3558
+ const name = skill.name || skill.id;
3559
+ const description = skill.description || `Runtime skill injected by LarkPal: ${skill.id}`;
3560
+ return [
3561
+ "---",
3562
+ `name: ${yamlScalar(name)}`,
3563
+ `description: ${yamlScalar(description)}`,
3564
+ "---",
3565
+ "",
3566
+ content,
3567
+ ""
3568
+ ].join("\n");
3569
+ }
3570
+ function replaceManagedBlock(current, managedBlock) {
3571
+ const start = current.indexOf(CLAUDE_MD_START);
3572
+ const end = current.indexOf(CLAUDE_MD_END);
3573
+ if (start !== -1 && end !== -1 && end > start) {
3574
+ const before = current.slice(0, start).trimEnd();
3575
+ const after = current.slice(end + 41).trimStart();
3576
+ return [
3577
+ before,
3578
+ managedBlock.trimEnd(),
3579
+ after
3580
+ ].filter(Boolean).join("\n\n") + "\n";
3581
+ }
3582
+ return [current.trimEnd(), managedBlock.trimEnd()].filter(Boolean).join("\n\n") + "\n";
3583
+ }
3584
+ function hashContent(content) {
3585
+ return `sha256:${createHash("sha256").update(content).digest("hex")}`;
3586
+ }
3587
+ function sanitizePathSegment(value) {
3588
+ return value.replace(/[^A-Za-z0-9._-]/g, "_").replace(/^\.+$/, "skill") || "skill";
3589
+ }
3590
+ function readNonEmptyString(value) {
3591
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
3592
+ }
3593
+ function readScope(value) {
3594
+ return value === "app" || value === "session" || value === "request" ? value : "request";
3595
+ }
3596
+ function yamlScalar(value) {
3597
+ return JSON.stringify(value);
3598
+ }
3599
+ //#endregion
3376
3600
  //#region src/gateway/agent-context.ts
3377
3601
  const SENSITIVE_KEY_PATTERN = /(authorization|cookie|token|api[-_]?key|secret|password|credential)/i;
3378
3602
  const SAFE_KEY_PATTERN = /^(file[-_]?token|drive[-_]?file[-_]?token|doc[-_]?token|sheet[-_]?token|wiki[-_]?token|node[-_]?token)$/i;
@@ -3414,11 +3638,17 @@ function buildAgentRuntimeConfig(input) {
3414
3638
  const userId = requireContextField(input.identity?.userId || input.identity?.openId, "userId");
3415
3639
  const scenarioId = getScenarioId(input.scenarioId, input.metadata);
3416
3640
  const cwd = resolveAgentCwd(sessionId, input.cwd);
3641
+ const runtimeContext = materializeRuntimeContext({
3642
+ cwd,
3643
+ instructions: input.runtimeInstructions,
3644
+ skills: input.runtimeSkills
3645
+ });
3417
3646
  const metadata = buildRunMetadata(input.metadata, {
3418
3647
  conversationId,
3419
3648
  traceId,
3420
3649
  entrypoint: input.entrypoint,
3421
- scenarioId
3650
+ scenarioId,
3651
+ runtimeContext
3422
3652
  });
3423
3653
  const authHeaders = buildAuthHeaders({
3424
3654
  tenantKey,
@@ -3450,6 +3680,7 @@ function buildAgentRuntimeConfig(input) {
3450
3680
  authHeaders,
3451
3681
  attachments: input.attachments,
3452
3682
  sourceArtifacts: input.sourceArtifacts,
3683
+ runtimeContext,
3453
3684
  llmConfig: input.llmConfig,
3454
3685
  policy,
3455
3686
  metadata
@@ -3468,6 +3699,7 @@ function buildAgentRuntimeConfig(input) {
3468
3699
  authHeaders,
3469
3700
  attachments: input.attachments,
3470
3701
  sourceArtifacts: input.sourceArtifacts,
3702
+ runtimeContext,
3471
3703
  llmConfig: input.llmConfig,
3472
3704
  policy,
3473
3705
  requestContext,
@@ -3553,6 +3785,7 @@ function buildRunInputAuditMetadata(config) {
3553
3785
  const metadata = {};
3554
3786
  if (config.attachments !== void 0) metadata.attachments = summarizeForAudit(config.attachments);
3555
3787
  if (config.sourceArtifacts !== void 0) metadata.sourceArtifacts = summarizeForAudit(config.sourceArtifacts);
3788
+ if (config.runtimeContext !== void 0) metadata.runtimeContext = config.runtimeContext;
3556
3789
  return metadata;
3557
3790
  }
3558
3791
  function buildRuntimeEventAuditMetadata(event) {
@@ -3641,7 +3874,8 @@ function buildRunMetadata(metadata, context) {
3641
3874
  conversationId: context.conversationId,
3642
3875
  traceId: context.traceId,
3643
3876
  entrypoint: context.entrypoint,
3644
- ...context.scenarioId ? { scenarioId: context.scenarioId } : {}
3877
+ ...context.scenarioId ? { scenarioId: context.scenarioId } : {},
3878
+ ...context.runtimeContext ? { runtimeContext: context.runtimeContext } : {}
3645
3879
  };
3646
3880
  }
3647
3881
  function buildAuditMetadata(context, metadata) {
@@ -3732,6 +3966,9 @@ function serializeChatRun(run) {
3732
3966
  lastEventAt: run.lastEventAt,
3733
3967
  lastEventType: run.lastEventType,
3734
3968
  lastToolName: run.lastToolName,
3969
+ lastToolError: run.lastToolError,
3970
+ unknownToolCallCount: run.unknownToolCallCount,
3971
+ lastUnknownToolName: run.lastUnknownToolName,
3735
3972
  idleSeconds,
3736
3973
  adapterBusy: run.status === "running" ? run.adapterBusy : false,
3737
3974
  processStatus,
@@ -4244,6 +4481,29 @@ function isPathInside(parent, child) {
4244
4481
  const path = relative(parent, child);
4245
4482
  return path !== "" && !path.startsWith("..") && !isAbsolute(path);
4246
4483
  }
4484
+ function buildToolResultPayload(result, resultSummary) {
4485
+ if (!result || typeof result !== "object" || Array.isArray(result)) return { result: resultSummary };
4486
+ const record = result;
4487
+ return {
4488
+ rawType: record.rawType,
4489
+ isError: record.isError,
4490
+ content: record.content,
4491
+ resultSummary: record.resultSummary ?? resultSummary,
4492
+ truncated: record.truncated,
4493
+ originalSize: record.originalSize,
4494
+ result: resultSummary
4495
+ };
4496
+ }
4497
+ function readStringField(value, key) {
4498
+ if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
4499
+ const field = value[key];
4500
+ return typeof field === "string" ? field : void 0;
4501
+ }
4502
+ function readBooleanField(value, key) {
4503
+ if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
4504
+ const field = value[key];
4505
+ return typeof field === "boolean" ? field : void 0;
4506
+ }
4247
4507
  /**
4248
4508
  * 创建 Chat 流式对话 + 历史查询路由
4249
4509
  *
@@ -4353,6 +4613,8 @@ function createChatRouter(config) {
4353
4613
  const scenarioId = getScenarioId(body.options?.scenarioId, body.options?.metadata);
4354
4614
  const attachments = getRunInputValue(body.attachments, body.options?.attachments, body.options?.metadata?.attachments);
4355
4615
  const sourceArtifacts = getRunInputValue(body.sourceArtifacts, body.source_artifacts, body.options?.sourceArtifacts, body.options?.source_artifacts, body.options?.metadata?.sourceArtifacts, body.options?.metadata?.source_artifacts);
4616
+ const runtimeInstructions = getRunInputValue(body.runtimeInstructions, body.runtime_instructions, body.options?.runtimeInstructions, body.options?.runtime_instructions, body.options?.metadata?.runtimeInstructions, body.options?.metadata?.runtime_instructions);
4617
+ const runtimeSkills = getRunInputValue(body.runtimeSkills, body.runtime_skills, body.options?.runtimeSkills, body.options?.runtime_skills, body.options?.metadata?.runtimeSkills, body.options?.metadata?.runtime_skills);
4356
4618
  log$30.info("[stream] 收到流式对话请求", {
4357
4619
  userId,
4358
4620
  sessionId,
@@ -4361,6 +4623,8 @@ function createChatRouter(config) {
4361
4623
  scenarioId,
4362
4624
  hasAttachments: attachments !== void 0,
4363
4625
  hasSourceArtifacts: sourceArtifacts !== void 0,
4626
+ hasRuntimeInstructions: runtimeInstructions !== void 0,
4627
+ hasRuntimeSkills: runtimeSkills !== void 0,
4364
4628
  promptLength: body.prompt.length
4365
4629
  });
4366
4630
  if (!sessionId) {
@@ -4408,6 +4672,8 @@ function createChatRouter(config) {
4408
4672
  model: process.env.CLAUDE_MODEL || void 0,
4409
4673
  attachments,
4410
4674
  sourceArtifacts,
4675
+ runtimeInstructions,
4676
+ runtimeSkills,
4411
4677
  policy: body.options?.policy,
4412
4678
  metadata: body.options?.metadata,
4413
4679
  identity: {
@@ -4447,10 +4713,7 @@ function createChatRouter(config) {
4447
4713
  requestId,
4448
4714
  traceId,
4449
4715
  scenarioId,
4450
- ...buildRunInputAuditMetadata({
4451
- attachments,
4452
- sourceArtifacts
4453
- })
4716
+ ...buildRunInputAuditMetadata(runtimeConfig)
4454
4717
  }
4455
4718
  });
4456
4719
  } catch (err) {
@@ -4594,8 +4857,12 @@ function createChatRouter(config) {
4594
4857
  if (run.status !== "running") return;
4595
4858
  recordRunEvent(run, "tool-result");
4596
4859
  const resultSummary = summarizeForAudit(result);
4860
+ const toolName = readStringField(result, "toolName") || run.lastToolName;
4861
+ const isError = readBooleanField(result, "isError");
4862
+ if (isError) run.lastToolError = resultSummary;
4597
4863
  if (runtimeConfig.requestContext) logChatAudit(buildAuditEvent(runtimeConfig.requestContext, "tool_call_finished", {
4598
4864
  toolCallId: toolUseId,
4865
+ toolName,
4599
4866
  resultSummary,
4600
4867
  metadata: buildToolResultAuditMetadata(result)
4601
4868
  }));
@@ -4604,7 +4871,8 @@ function createChatRouter(config) {
4604
4871
  role: "tool",
4605
4872
  content: JSON.stringify({
4606
4873
  toolUseId,
4607
- result: resultSummary
4874
+ toolName,
4875
+ ...buildToolResultPayload(result, resultSummary)
4608
4876
  }),
4609
4877
  channel: "web",
4610
4878
  metadata: {
@@ -4614,12 +4882,33 @@ function createChatRouter(config) {
4614
4882
  scenarioId,
4615
4883
  runtimeEventType: "tool-result",
4616
4884
  toolCallId: toolUseId,
4617
- toolResult: resultSummary
4885
+ toolName,
4886
+ toolResult: resultSummary,
4887
+ isError
4618
4888
  }
4619
4889
  }, "[stream] 保存 tool result 消息失败");
4620
4890
  broadcastRunEvent(run, "tool-result", {
4621
4891
  toolUseId,
4622
- result: resultSummary
4892
+ toolName,
4893
+ ...buildToolResultPayload(result, resultSummary)
4894
+ });
4895
+ },
4896
+ onUnknownToolUse: (toolName, toolUseId) => {
4897
+ if (run.status !== "running") return;
4898
+ run.unknownToolCallCount = (run.unknownToolCallCount ?? 0) + 1;
4899
+ run.lastUnknownToolName = toolName;
4900
+ run.lastToolError = {
4901
+ isError: true,
4902
+ reasonCode: "UNKNOWN_TOOL_CALL",
4903
+ toolName,
4904
+ toolCallId: toolUseId
4905
+ };
4906
+ recordRunEvent(run, "unknown-tool-use", { toolName });
4907
+ broadcastRunEvent(run, "runtime-event", {
4908
+ type: "unknown-tool-use",
4909
+ toolName,
4910
+ toolUseId,
4911
+ unknownToolCallCount: run.unknownToolCallCount
4623
4912
  });
4624
4913
  },
4625
4914
  onToolProgress: (toolName, elapsedSeconds) => {
@@ -5967,6 +6256,8 @@ async function handleExecute(req, res, processManager) {
5967
6256
  const scenarioId = getScenarioId(body.scenarioId || body.scenario_id, body.metadata);
5968
6257
  const attachments = getRunInputValue(body.attachments, body.metadata?.attachments);
5969
6258
  const sourceArtifacts = getRunInputValue(body.sourceArtifacts, body.source_artifacts, body.metadata?.sourceArtifacts, body.metadata?.source_artifacts);
6259
+ const runtimeInstructions = getRunInputValue(body.runtimeInstructions, body.runtime_instructions, body.metadata?.runtimeInstructions, body.metadata?.runtime_instructions);
6260
+ const runtimeSkills = getRunInputValue(body.runtimeSkills, body.runtime_skills, body.metadata?.runtimeSkills, body.metadata?.runtime_skills);
5970
6261
  const identity = resolveExecuteIdentity(req, body);
5971
6262
  const missingIdentityFields = getMissingIdentityFields(identity);
5972
6263
  if (missingIdentityFields.length > 0) {
@@ -6013,6 +6304,8 @@ async function handleExecute(req, res, processManager) {
6013
6304
  authHeaders: body.auth_headers,
6014
6305
  attachments,
6015
6306
  sourceArtifacts,
6307
+ runtimeInstructions,
6308
+ runtimeSkills,
6016
6309
  policy: body.policy,
6017
6310
  metadata: body.metadata,
6018
6311
  identity
@@ -6141,6 +6434,8 @@ async function handleBatchExecute(req, res, processManager) {
6141
6434
  const scenarioId = getScenarioId(body.scenarioId || body.scenario_id, body.metadata);
6142
6435
  const batchAttachments = getRunInputValue(body.attachments, body.metadata?.attachments);
6143
6436
  const batchSourceArtifacts = getRunInputValue(body.sourceArtifacts, body.source_artifacts, body.metadata?.sourceArtifacts, body.metadata?.source_artifacts);
6437
+ const batchRuntimeInstructions = getRunInputValue(body.runtimeInstructions, body.runtime_instructions, body.metadata?.runtimeInstructions, body.metadata?.runtime_instructions);
6438
+ const batchRuntimeSkills = getRunInputValue(body.runtimeSkills, body.runtime_skills, body.metadata?.runtimeSkills, body.metadata?.runtime_skills);
6144
6439
  const concurrency = body.concurrency ?? 3;
6145
6440
  const taskIds = [];
6146
6441
  const taskConfigs = [];
@@ -6156,6 +6451,8 @@ async function handleBatchExecute(req, res, processManager) {
6156
6451
  };
6157
6452
  const taskAttachments = getRunInputValue(task.attachments, task.metadata?.attachments, batchAttachments);
6158
6453
  const taskSourceArtifacts = getRunInputValue(task.sourceArtifacts, task.source_artifacts, task.metadata?.sourceArtifacts, task.metadata?.source_artifacts, batchSourceArtifacts);
6454
+ const taskRuntimeInstructions = getRunInputValue(task.runtimeInstructions, task.runtime_instructions, task.metadata?.runtimeInstructions, task.metadata?.runtime_instructions, batchRuntimeInstructions);
6455
+ const taskRuntimeSkills = getRunInputValue(task.runtimeSkills, task.runtime_skills, task.metadata?.runtimeSkills, task.metadata?.runtime_skills, batchRuntimeSkills);
6159
6456
  const config = buildAgentRuntimeConfig({
6160
6457
  requestId: `${batchRequestId}:${index}`,
6161
6458
  traceId,
@@ -6168,6 +6465,8 @@ async function handleBatchExecute(req, res, processManager) {
6168
6465
  authHeaders: body.auth_headers,
6169
6466
  attachments: taskAttachments,
6170
6467
  sourceArtifacts: taskSourceArtifacts,
6468
+ runtimeInstructions: taskRuntimeInstructions,
6469
+ runtimeSkills: taskRuntimeSkills,
6171
6470
  policy: body.policy,
6172
6471
  metadata: taskMetadata,
6173
6472
  identity
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibe-lark/larkpal",
3
- "version": "0.1.73",
3
+ "version": "0.1.75",
4
4
  "description": "LarkPal - Lark/Feishu bot service",
5
5
  "type": "module",
6
6
  "main": "./dist/main.mjs",