@vibe-lark/larkpal 0.1.52 → 0.1.54
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/dist/main.mjs +245 -12
- package/package.json +2 -2
package/dist/main.mjs
CHANGED
|
@@ -2326,6 +2326,8 @@ function buildAgentRuntimeConfig(input) {
|
|
|
2326
2326
|
userName: input.identity?.userName,
|
|
2327
2327
|
cwd,
|
|
2328
2328
|
authHeaders,
|
|
2329
|
+
attachments: input.attachments,
|
|
2330
|
+
sourceArtifacts: input.sourceArtifacts,
|
|
2329
2331
|
llmConfig: input.llmConfig,
|
|
2330
2332
|
policy,
|
|
2331
2333
|
metadata
|
|
@@ -2341,6 +2343,8 @@ function buildAgentRuntimeConfig(input) {
|
|
|
2341
2343
|
userContext,
|
|
2342
2344
|
tenantContext: { tenantKey },
|
|
2343
2345
|
authHeaders,
|
|
2346
|
+
attachments: input.attachments,
|
|
2347
|
+
sourceArtifacts: input.sourceArtifacts,
|
|
2344
2348
|
llmConfig: input.llmConfig,
|
|
2345
2349
|
policy,
|
|
2346
2350
|
requestContext,
|
|
@@ -2359,6 +2363,9 @@ function buildAgentRuntimeConfig(input) {
|
|
|
2359
2363
|
metadata
|
|
2360
2364
|
};
|
|
2361
2365
|
}
|
|
2366
|
+
function getRunInputValue(...values) {
|
|
2367
|
+
return values.find((value) => value !== void 0);
|
|
2368
|
+
}
|
|
2362
2369
|
function summarizeForAudit(value) {
|
|
2363
2370
|
if (value == null) return value;
|
|
2364
2371
|
if (typeof value === "string") return summarizeString(value);
|
|
@@ -2419,6 +2426,39 @@ function buildVerifierAuditMetadata(result) {
|
|
|
2419
2426
|
if (result.missingArtifacts) metadata.missingArtifacts = summarizeForAudit(result.missingArtifacts);
|
|
2420
2427
|
return metadata;
|
|
2421
2428
|
}
|
|
2429
|
+
function buildRunInputAuditMetadata(config) {
|
|
2430
|
+
const metadata = {};
|
|
2431
|
+
if (config.attachments !== void 0) metadata.attachments = summarizeForAudit(config.attachments);
|
|
2432
|
+
if (config.sourceArtifacts !== void 0) metadata.sourceArtifacts = summarizeForAudit(config.sourceArtifacts);
|
|
2433
|
+
return metadata;
|
|
2434
|
+
}
|
|
2435
|
+
function buildRuntimeEventAuditMetadata(event) {
|
|
2436
|
+
const metadata = {
|
|
2437
|
+
runtimeEventType: event.type,
|
|
2438
|
+
runtimeEvent: summarizeForAudit(event)
|
|
2439
|
+
};
|
|
2440
|
+
for (const key of [
|
|
2441
|
+
"scenarioId",
|
|
2442
|
+
"traceId",
|
|
2443
|
+
"phaseId",
|
|
2444
|
+
"artifactName",
|
|
2445
|
+
"artifactNames",
|
|
2446
|
+
"capabilityId",
|
|
2447
|
+
"repairActionId",
|
|
2448
|
+
"repairAttempt",
|
|
2449
|
+
"targetPhase",
|
|
2450
|
+
"requiredNextPhases",
|
|
2451
|
+
"plannerInstruction",
|
|
2452
|
+
"reasonCode",
|
|
2453
|
+
"verifierReasonCode",
|
|
2454
|
+
"missingPhases",
|
|
2455
|
+
"failedGates",
|
|
2456
|
+
"missingArtifacts",
|
|
2457
|
+
"status",
|
|
2458
|
+
"finalStatus"
|
|
2459
|
+
]) if (event[key] !== void 0) metadata[key] = summarizeForAudit(event[key]);
|
|
2460
|
+
return metadata;
|
|
2461
|
+
}
|
|
2422
2462
|
function buildAuthHeaders(params) {
|
|
2423
2463
|
const headers = {
|
|
2424
2464
|
"x-tenant-key": params.tenantKey,
|
|
@@ -2571,6 +2611,8 @@ async function handleExecute(req, res, processManager) {
|
|
|
2571
2611
|
const traceId = body.traceId || body.trace_id || getGatewayTraceId(req.headers, requestId);
|
|
2572
2612
|
const conversationId = body.conversationId || body.conversation_id || body.session_id;
|
|
2573
2613
|
const scenarioId = getScenarioId(body.scenarioId || body.scenario_id, body.metadata);
|
|
2614
|
+
const attachments = getRunInputValue(body.attachments, body.metadata?.attachments);
|
|
2615
|
+
const sourceArtifacts = getRunInputValue(body.sourceArtifacts, body.source_artifacts, body.metadata?.sourceArtifacts, body.metadata?.source_artifacts);
|
|
2574
2616
|
const identity = resolveExecuteIdentity(req, body);
|
|
2575
2617
|
const missingIdentityFields = getMissingIdentityFields(identity);
|
|
2576
2618
|
if (missingIdentityFields.length > 0) {
|
|
@@ -2615,6 +2657,8 @@ async function handleExecute(req, res, processManager) {
|
|
|
2615
2657
|
model: body.llm_config.model
|
|
2616
2658
|
} : void 0,
|
|
2617
2659
|
authHeaders: body.auth_headers,
|
|
2660
|
+
attachments,
|
|
2661
|
+
sourceArtifacts,
|
|
2618
2662
|
policy: body.policy,
|
|
2619
2663
|
metadata: body.metadata,
|
|
2620
2664
|
identity
|
|
@@ -2669,6 +2713,7 @@ async function handleExecute(req, res, processManager) {
|
|
|
2669
2713
|
try {
|
|
2670
2714
|
logRunStarted(config);
|
|
2671
2715
|
const result = await executeAndWaitResult$1(taskId, config, processManager);
|
|
2716
|
+
const completedTask = taskStore.get(taskId);
|
|
2672
2717
|
logger$8.info("同步任务执行完成", {
|
|
2673
2718
|
taskId,
|
|
2674
2719
|
resultSubtype: result?.subtype
|
|
@@ -2676,10 +2721,12 @@ async function handleExecute(req, res, processManager) {
|
|
|
2676
2721
|
res.status(200).json({
|
|
2677
2722
|
task_id: taskId,
|
|
2678
2723
|
status: result?.isError ? "failed" : "completed",
|
|
2679
|
-
result
|
|
2724
|
+
result,
|
|
2725
|
+
...completedTask?.runtimeEvents?.length ? { runtime_events: completedTask.runtimeEvents } : {}
|
|
2680
2726
|
});
|
|
2681
2727
|
} catch (err) {
|
|
2682
2728
|
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
2729
|
+
const failedTask = taskStore.get(taskId);
|
|
2683
2730
|
logger$8.error("同步任务执行失败", {
|
|
2684
2731
|
taskId,
|
|
2685
2732
|
error: errorMsg
|
|
@@ -2687,7 +2734,8 @@ async function handleExecute(req, res, processManager) {
|
|
|
2687
2734
|
res.status(500).json({
|
|
2688
2735
|
task_id: taskId,
|
|
2689
2736
|
status: "failed",
|
|
2690
|
-
error: errorMsg
|
|
2737
|
+
error: errorMsg,
|
|
2738
|
+
...failedTask?.runtimeEvents?.length ? { runtime_events: failedTask.runtimeEvents } : {}
|
|
2691
2739
|
});
|
|
2692
2740
|
} finally {
|
|
2693
2741
|
releaseTaskIfRunning(taskId);
|
|
@@ -2737,6 +2785,8 @@ async function handleBatchExecute(req, res, processManager) {
|
|
|
2737
2785
|
const batchRequestId = getGatewayRequestId(req.headers);
|
|
2738
2786
|
const traceId = getGatewayTraceId(req.headers, batchRequestId);
|
|
2739
2787
|
const scenarioId = getScenarioId(body.scenarioId || body.scenario_id, body.metadata);
|
|
2788
|
+
const batchAttachments = getRunInputValue(body.attachments, body.metadata?.attachments);
|
|
2789
|
+
const batchSourceArtifacts = getRunInputValue(body.sourceArtifacts, body.source_artifacts, body.metadata?.sourceArtifacts, body.metadata?.source_artifacts);
|
|
2740
2790
|
const concurrency = body.concurrency ?? 3;
|
|
2741
2791
|
const taskIds = [];
|
|
2742
2792
|
const taskConfigs = [];
|
|
@@ -2744,6 +2794,14 @@ async function handleBatchExecute(req, res, processManager) {
|
|
|
2744
2794
|
const taskId = v4();
|
|
2745
2795
|
taskIds.push(taskId);
|
|
2746
2796
|
try {
|
|
2797
|
+
const taskMetadata = {
|
|
2798
|
+
...body.metadata,
|
|
2799
|
+
...task.metadata,
|
|
2800
|
+
batchId,
|
|
2801
|
+
batchTaskIndex: index
|
|
2802
|
+
};
|
|
2803
|
+
const taskAttachments = getRunInputValue(task.attachments, task.metadata?.attachments, batchAttachments);
|
|
2804
|
+
const taskSourceArtifacts = getRunInputValue(task.sourceArtifacts, task.source_artifacts, task.metadata?.sourceArtifacts, task.metadata?.source_artifacts, batchSourceArtifacts);
|
|
2747
2805
|
const config = buildAgentRuntimeConfig({
|
|
2748
2806
|
requestId: `${batchRequestId}:${index}`,
|
|
2749
2807
|
traceId,
|
|
@@ -2754,12 +2812,10 @@ async function handleBatchExecute(req, res, processManager) {
|
|
|
2754
2812
|
cwd: task.cwd,
|
|
2755
2813
|
prompt: task.prompt,
|
|
2756
2814
|
authHeaders: body.auth_headers,
|
|
2815
|
+
attachments: taskAttachments,
|
|
2816
|
+
sourceArtifacts: taskSourceArtifacts,
|
|
2757
2817
|
policy: body.policy,
|
|
2758
|
-
metadata:
|
|
2759
|
-
...body.metadata,
|
|
2760
|
-
batchId,
|
|
2761
|
-
batchTaskIndex: index
|
|
2762
|
-
},
|
|
2818
|
+
metadata: taskMetadata,
|
|
2763
2819
|
identity
|
|
2764
2820
|
});
|
|
2765
2821
|
const taskInfo = {
|
|
@@ -2826,6 +2882,7 @@ function handleGetTask(req, res) {
|
|
|
2826
2882
|
};
|
|
2827
2883
|
if (taskInfo.result) response.result = taskInfo.result;
|
|
2828
2884
|
if (taskInfo.error) response.error = taskInfo.error;
|
|
2885
|
+
if (taskInfo.runtimeEvents?.length) response.runtime_events = taskInfo.runtimeEvents;
|
|
2829
2886
|
res.status(200).json(response);
|
|
2830
2887
|
}
|
|
2831
2888
|
/**
|
|
@@ -2916,12 +2973,36 @@ function logRunStarted(config) {
|
|
|
2916
2973
|
traceId: config.runContext?.traceId,
|
|
2917
2974
|
requestId: config.runContext?.requestId,
|
|
2918
2975
|
entrypoint: config.runContext?.entrypoint,
|
|
2919
|
-
scenarioId: config.runContext?.scenarioId
|
|
2976
|
+
scenarioId: config.runContext?.scenarioId,
|
|
2977
|
+
...buildRunInputAuditMetadata(config)
|
|
2920
2978
|
} }));
|
|
2921
2979
|
}
|
|
2922
2980
|
function logAuditEvent(event) {
|
|
2923
2981
|
logger$8.info("Agent audit event", { ...event });
|
|
2924
2982
|
}
|
|
2983
|
+
function recordRuntimeEvent(taskId, config, event) {
|
|
2984
|
+
const eventSummary = summarizeForAudit(event);
|
|
2985
|
+
const taskInfo = taskStore.get(taskId);
|
|
2986
|
+
if (taskInfo) {
|
|
2987
|
+
taskInfo.runtimeEvents = taskInfo.runtimeEvents || [];
|
|
2988
|
+
taskInfo.runtimeEvents.push({
|
|
2989
|
+
type: event.type,
|
|
2990
|
+
event: eventSummary
|
|
2991
|
+
});
|
|
2992
|
+
}
|
|
2993
|
+
logger$8.info("Agent runtime event", {
|
|
2994
|
+
taskId,
|
|
2995
|
+
type: event.type,
|
|
2996
|
+
traceId: config.runContext?.traceId,
|
|
2997
|
+
scenarioId: event.scenarioId || config.runContext?.scenarioId,
|
|
2998
|
+
phaseId: event.phaseId,
|
|
2999
|
+
reasonCode: event.reasonCode || event.verifierReasonCode
|
|
3000
|
+
});
|
|
3001
|
+
if (config.requestContext) logAuditEvent(buildAuditEvent(config.requestContext, "runtime_event", {
|
|
3002
|
+
resultSummary: eventSummary,
|
|
3003
|
+
metadata: buildRuntimeEventAuditMetadata(event)
|
|
3004
|
+
}));
|
|
3005
|
+
}
|
|
2925
3006
|
/**
|
|
2926
3007
|
* 创建任务级别的流回调
|
|
2927
3008
|
*
|
|
@@ -3021,6 +3102,12 @@ function createTaskCallbacks(taskId, config) {
|
|
|
3021
3102
|
metadata: buildVerifierAuditMetadata(result)
|
|
3022
3103
|
}));
|
|
3023
3104
|
},
|
|
3105
|
+
onRuntimeEvent: (event) => {
|
|
3106
|
+
recordRuntimeEvent(taskId, config, event);
|
|
3107
|
+
},
|
|
3108
|
+
onScenarioEvent: (event) => {
|
|
3109
|
+
recordRuntimeEvent(taskId, config, event);
|
|
3110
|
+
},
|
|
3024
3111
|
onBlocked: handleBlockedEvent,
|
|
3025
3112
|
onBlockedEvent: handleBlockedEvent
|
|
3026
3113
|
};
|
|
@@ -4825,6 +4912,27 @@ function isChatSessionRunning(sessionId, processManager) {
|
|
|
4825
4912
|
function logChatAudit(event) {
|
|
4826
4913
|
log$25.info("[stream] Agent audit event", { ...event });
|
|
4827
4914
|
}
|
|
4915
|
+
function buildRuntimeEventMessageMetadata(event, runtimeConfig) {
|
|
4916
|
+
return {
|
|
4917
|
+
runtimeEventType: event.type,
|
|
4918
|
+
requestId: runtimeConfig.runContext?.requestId,
|
|
4919
|
+
traceId: runtimeConfig.runContext?.traceId,
|
|
4920
|
+
scenarioId: event.scenarioId || runtimeConfig.runContext?.scenarioId,
|
|
4921
|
+
phaseId: event.phaseId,
|
|
4922
|
+
artifactName: event.artifactName,
|
|
4923
|
+
artifactNames: event.artifactNames,
|
|
4924
|
+
targetPhase: event.targetPhase,
|
|
4925
|
+
requiredNextPhases: event.requiredNextPhases,
|
|
4926
|
+
plannerInstruction: event.plannerInstruction,
|
|
4927
|
+
verifierReasonCode: event.verifierReasonCode,
|
|
4928
|
+
reasonCode: event.reasonCode,
|
|
4929
|
+
missingPhases: event.missingPhases,
|
|
4930
|
+
failedGates: event.failedGates,
|
|
4931
|
+
missingArtifacts: event.missingArtifacts,
|
|
4932
|
+
repairAttempt: event.repairAttempt,
|
|
4933
|
+
finalStatus: event.finalStatus
|
|
4934
|
+
};
|
|
4935
|
+
}
|
|
4828
4936
|
/**
|
|
4829
4937
|
* 创建 Chat 流式对话 + 历史查询路由
|
|
4830
4938
|
*
|
|
@@ -4852,12 +4960,16 @@ function createChatRouter(config) {
|
|
|
4852
4960
|
const requestId = getGatewayRequestId(req.headers);
|
|
4853
4961
|
const traceId = getGatewayTraceId(req.headers, requestId);
|
|
4854
4962
|
const scenarioId = getScenarioId(body.options?.scenarioId, body.options?.metadata);
|
|
4963
|
+
const attachments = getRunInputValue(body.attachments, body.options?.attachments, body.options?.metadata?.attachments);
|
|
4964
|
+
const sourceArtifacts = getRunInputValue(body.sourceArtifacts, body.source_artifacts, body.options?.sourceArtifacts, body.options?.source_artifacts, body.options?.metadata?.sourceArtifacts, body.options?.metadata?.source_artifacts);
|
|
4855
4965
|
log$25.info("[stream] 收到流式对话请求", {
|
|
4856
4966
|
userId,
|
|
4857
4967
|
sessionId: body.session_id,
|
|
4858
4968
|
requestId,
|
|
4859
4969
|
traceId,
|
|
4860
4970
|
scenarioId,
|
|
4971
|
+
hasAttachments: attachments !== void 0,
|
|
4972
|
+
hasSourceArtifacts: sourceArtifacts !== void 0,
|
|
4861
4973
|
promptLength: body.prompt.length
|
|
4862
4974
|
});
|
|
4863
4975
|
let sessionId = body.session_id;
|
|
@@ -4895,7 +5007,16 @@ function createChatRouter(config) {
|
|
|
4895
5007
|
sessionId,
|
|
4896
5008
|
role: "user",
|
|
4897
5009
|
content: body.prompt,
|
|
4898
|
-
channel: "web"
|
|
5010
|
+
channel: "web",
|
|
5011
|
+
metadata: {
|
|
5012
|
+
requestId,
|
|
5013
|
+
traceId,
|
|
5014
|
+
scenarioId,
|
|
5015
|
+
...buildRunInputAuditMetadata({
|
|
5016
|
+
attachments,
|
|
5017
|
+
sourceArtifacts
|
|
5018
|
+
})
|
|
5019
|
+
}
|
|
4899
5020
|
});
|
|
4900
5021
|
} catch (err) {
|
|
4901
5022
|
activeStreamSessions.delete(sessionId);
|
|
@@ -4924,6 +5045,8 @@ function createChatRouter(config) {
|
|
|
4924
5045
|
maxTurns: body.options?.maxTurns,
|
|
4925
5046
|
maxBudgetUsd: body.options?.maxBudgetUsd,
|
|
4926
5047
|
model: process.env.CLAUDE_MODEL || void 0,
|
|
5048
|
+
attachments,
|
|
5049
|
+
sourceArtifacts,
|
|
4927
5050
|
policy: body.options?.policy,
|
|
4928
5051
|
metadata: body.options?.metadata,
|
|
4929
5052
|
identity: {
|
|
@@ -4953,6 +5076,32 @@ function createChatRouter(config) {
|
|
|
4953
5076
|
clientDisconnected = true;
|
|
4954
5077
|
log$25.info("[stream] 客户端断开连接", { sessionId });
|
|
4955
5078
|
});
|
|
5079
|
+
const handleRuntimeEvent = (event) => {
|
|
5080
|
+
const eventSummary = summarizeForAudit(event);
|
|
5081
|
+
if (runtimeConfig.requestContext) logChatAudit(buildAuditEvent(runtimeConfig.requestContext, "runtime_event", {
|
|
5082
|
+
resultSummary: eventSummary,
|
|
5083
|
+
metadata: buildRuntimeEventAuditMetadata(event)
|
|
5084
|
+
}));
|
|
5085
|
+
messageStore.appendMessage({
|
|
5086
|
+
sessionId,
|
|
5087
|
+
role: "tool",
|
|
5088
|
+
content: JSON.stringify({
|
|
5089
|
+
runtimeEventType: event.type,
|
|
5090
|
+
event: eventSummary
|
|
5091
|
+
}),
|
|
5092
|
+
channel: "web",
|
|
5093
|
+
metadata: buildRuntimeEventMessageMetadata(event, runtimeConfig)
|
|
5094
|
+
}).catch((err) => {
|
|
5095
|
+
log$25.error("[stream] 保存 runtime event 消息失败", {
|
|
5096
|
+
sessionId,
|
|
5097
|
+
error: err
|
|
5098
|
+
});
|
|
5099
|
+
});
|
|
5100
|
+
if (!clientDisconnected) sendSSE(res, "runtime-event", {
|
|
5101
|
+
type: event.type,
|
|
5102
|
+
event: eventSummary
|
|
5103
|
+
});
|
|
5104
|
+
};
|
|
4956
5105
|
const callbacks = {
|
|
4957
5106
|
onTextDelta: (text) => {
|
|
4958
5107
|
accumText += text;
|
|
@@ -5091,6 +5240,8 @@ function createChatRouter(config) {
|
|
|
5091
5240
|
}));
|
|
5092
5241
|
if (!clientDisconnected) sendSSE(res, "verifier-result", { result: resultSummary });
|
|
5093
5242
|
},
|
|
5243
|
+
onRuntimeEvent: handleRuntimeEvent,
|
|
5244
|
+
onScenarioEvent: handleRuntimeEvent,
|
|
5094
5245
|
onBlocked: handleBlockedEvent,
|
|
5095
5246
|
onBlockedEvent: handleBlockedEvent
|
|
5096
5247
|
};
|
|
@@ -5103,7 +5254,8 @@ function createChatRouter(config) {
|
|
|
5103
5254
|
traceId: runtimeConfig.runContext?.traceId,
|
|
5104
5255
|
requestId: runtimeConfig.runContext?.requestId,
|
|
5105
5256
|
entrypoint: runtimeConfig.runContext?.entrypoint,
|
|
5106
|
-
scenarioId: runtimeConfig.runContext?.scenarioId
|
|
5257
|
+
scenarioId: runtimeConfig.runContext?.scenarioId,
|
|
5258
|
+
...buildRunInputAuditMetadata(runtimeConfig)
|
|
5107
5259
|
} }));
|
|
5108
5260
|
log$25.info("[stream] 开始执行 prompt", {
|
|
5109
5261
|
sessionId,
|
|
@@ -11117,6 +11269,8 @@ function buildAuthCard(ctx) {
|
|
|
11117
11269
|
const openPlatformHost = ctx.brand === "lark" ? "https://open.larksuite.com" : "https://open.feishu.cn";
|
|
11118
11270
|
const scopeQuery = ctx.scopes.join(",");
|
|
11119
11271
|
const authUrl = `${openPlatformHost}/app/${ctx.appId}/auth?q=${encodeURIComponent(scopeQuery)}`;
|
|
11272
|
+
const scopeList = ctx.scopes.map((s) => `• \`${s}\``).join("\n");
|
|
11273
|
+
const reason = ctx.reason?.trim();
|
|
11120
11274
|
const card = {
|
|
11121
11275
|
schema: "2.0",
|
|
11122
11276
|
config: {
|
|
@@ -11131,8 +11285,12 @@ function buildAuthCard(ctx) {
|
|
|
11131
11285
|
},
|
|
11132
11286
|
{
|
|
11133
11287
|
tag: "markdown",
|
|
11134
|
-
content: `当前操作需要以下飞书权限,请应用管理员前往开放平台申请:\n\n${
|
|
11288
|
+
content: `当前操作需要以下飞书权限,请应用管理员前往开放平台申请:\n\n${scopeList}`
|
|
11135
11289
|
},
|
|
11290
|
+
...reason ? [{
|
|
11291
|
+
tag: "markdown",
|
|
11292
|
+
content: `**申请原因:** ${reason}`
|
|
11293
|
+
}] : [],
|
|
11136
11294
|
{ tag: "hr" },
|
|
11137
11295
|
{
|
|
11138
11296
|
tag: "markdown",
|
|
@@ -11140,11 +11298,13 @@ function buildAuthCard(ctx) {
|
|
|
11140
11298
|
},
|
|
11141
11299
|
{
|
|
11142
11300
|
tag: "button",
|
|
11301
|
+
name: getAuthButtonName("open"),
|
|
11143
11302
|
text: {
|
|
11144
11303
|
tag: "plain_text",
|
|
11145
11304
|
content: "去申请权限 ↗"
|
|
11146
11305
|
},
|
|
11147
11306
|
type: "primary",
|
|
11307
|
+
width: "default",
|
|
11148
11308
|
multi_url: {
|
|
11149
11309
|
url: authUrl,
|
|
11150
11310
|
pc_url: authUrl,
|
|
@@ -11158,12 +11318,14 @@ function buildAuthCard(ctx) {
|
|
|
11158
11318
|
},
|
|
11159
11319
|
{
|
|
11160
11320
|
tag: "button",
|
|
11321
|
+
name: getAuthButtonName("complete"),
|
|
11161
11322
|
text: {
|
|
11162
11323
|
tag: "plain_text",
|
|
11163
11324
|
content: "✓ 已完成权限配置"
|
|
11164
11325
|
},
|
|
11165
11326
|
type: "text",
|
|
11166
11327
|
size: "small",
|
|
11328
|
+
width: "default",
|
|
11167
11329
|
behaviors: [{
|
|
11168
11330
|
type: "callback",
|
|
11169
11331
|
value: {
|
|
@@ -11195,6 +11357,9 @@ function buildAuthCard(ctx) {
|
|
|
11195
11357
|
operationId
|
|
11196
11358
|
};
|
|
11197
11359
|
}
|
|
11360
|
+
function getAuthButtonName(action) {
|
|
11361
|
+
return `auth_${action}`;
|
|
11362
|
+
}
|
|
11198
11363
|
/**
|
|
11199
11364
|
* 构建多 phase 提问卡片(CardKit v2 格式)
|
|
11200
11365
|
*
|
|
@@ -12091,6 +12256,49 @@ async function dispatchToCC(params) {
|
|
|
12091
12256
|
log$12.warn("记录飞书 assistant 消息到 store 失败", { error: String(err) });
|
|
12092
12257
|
});
|
|
12093
12258
|
};
|
|
12259
|
+
const appendRuntimeEventMessage = (event) => {
|
|
12260
|
+
const eventSummary = summarizeForAudit(event);
|
|
12261
|
+
log$12.info("CC onRuntimeEvent", {
|
|
12262
|
+
sessionId: route.sessionId,
|
|
12263
|
+
type: event.type,
|
|
12264
|
+
traceId: runtimeConfig.runContext?.traceId,
|
|
12265
|
+
scenarioId: event.scenarioId || runtimeConfig.runContext?.scenarioId,
|
|
12266
|
+
phaseId: event.phaseId,
|
|
12267
|
+
reasonCode: event.reasonCode || event.verifierReasonCode,
|
|
12268
|
+
event: eventSummary
|
|
12269
|
+
});
|
|
12270
|
+
if (!params.messageStore) return;
|
|
12271
|
+
params.messageStore.appendMessage({
|
|
12272
|
+
sessionId: route.sessionId,
|
|
12273
|
+
role: "tool",
|
|
12274
|
+
content: JSON.stringify({
|
|
12275
|
+
runtimeEventType: event.type,
|
|
12276
|
+
event: eventSummary
|
|
12277
|
+
}),
|
|
12278
|
+
channel: "feishu-bot",
|
|
12279
|
+
metadata: {
|
|
12280
|
+
runtimeEventType: event.type,
|
|
12281
|
+
requestId: runtimeConfig.runContext?.requestId,
|
|
12282
|
+
traceId: runtimeConfig.runContext?.traceId,
|
|
12283
|
+
scenarioId: event.scenarioId || runtimeConfig.runContext?.scenarioId,
|
|
12284
|
+
phaseId: event.phaseId,
|
|
12285
|
+
artifactName: event.artifactName,
|
|
12286
|
+
artifactNames: event.artifactNames,
|
|
12287
|
+
targetPhase: event.targetPhase,
|
|
12288
|
+
requiredNextPhases: event.requiredNextPhases,
|
|
12289
|
+
plannerInstruction: event.plannerInstruction,
|
|
12290
|
+
verifierReasonCode: event.verifierReasonCode,
|
|
12291
|
+
reasonCode: event.reasonCode,
|
|
12292
|
+
missingPhases: event.missingPhases,
|
|
12293
|
+
failedGates: event.failedGates,
|
|
12294
|
+
missingArtifacts: event.missingArtifacts,
|
|
12295
|
+
repairAttempt: event.repairAttempt,
|
|
12296
|
+
finalStatus: event.finalStatus
|
|
12297
|
+
}
|
|
12298
|
+
}).catch((err) => {
|
|
12299
|
+
log$12.warn("记录飞书 runtime event 到 store 失败", { error: String(err) });
|
|
12300
|
+
});
|
|
12301
|
+
};
|
|
12094
12302
|
const handleResult = async (result) => {
|
|
12095
12303
|
log$12.info("CC onResult", {
|
|
12096
12304
|
sessionId: route.sessionId,
|
|
@@ -12228,6 +12436,8 @@ async function dispatchToCC(params) {
|
|
|
12228
12436
|
resultSummary: summarizeForAudit(event.resultSummary)
|
|
12229
12437
|
});
|
|
12230
12438
|
},
|
|
12439
|
+
onRuntimeEvent: appendRuntimeEventMessage,
|
|
12440
|
+
onScenarioEvent: appendRuntimeEventMessage,
|
|
12231
12441
|
onBlocked: handleBlockedEvent,
|
|
12232
12442
|
onBlockedEvent: handleBlockedEvent
|
|
12233
12443
|
};
|
|
@@ -12505,6 +12715,28 @@ async function dispatchTeammateEval(params) {
|
|
|
12505
12715
|
resultSummary: summarizeForAudit(event.resultSummary)
|
|
12506
12716
|
});
|
|
12507
12717
|
},
|
|
12718
|
+
onRuntimeEvent: (event) => {
|
|
12719
|
+
log$12.info("teammate onRuntimeEvent", {
|
|
12720
|
+
type: event.type,
|
|
12721
|
+
chatId,
|
|
12722
|
+
traceId: runtimeConfig.runContext?.traceId,
|
|
12723
|
+
scenarioId: event.scenarioId || runtimeConfig.runContext?.scenarioId,
|
|
12724
|
+
phaseId: event.phaseId,
|
|
12725
|
+
reasonCode: event.reasonCode || event.verifierReasonCode,
|
|
12726
|
+
event: summarizeForAudit(event)
|
|
12727
|
+
});
|
|
12728
|
+
},
|
|
12729
|
+
onScenarioEvent: (event) => {
|
|
12730
|
+
log$12.info("teammate onScenarioEvent", {
|
|
12731
|
+
type: event.type,
|
|
12732
|
+
chatId,
|
|
12733
|
+
traceId: runtimeConfig.runContext?.traceId,
|
|
12734
|
+
scenarioId: event.scenarioId || runtimeConfig.runContext?.scenarioId,
|
|
12735
|
+
phaseId: event.phaseId,
|
|
12736
|
+
reasonCode: event.reasonCode || event.verifierReasonCode,
|
|
12737
|
+
event: summarizeForAudit(event)
|
|
12738
|
+
});
|
|
12739
|
+
},
|
|
12508
12740
|
onBlocked: (event) => {
|
|
12509
12741
|
const sanitized = sanitizeBlockedEvent(event);
|
|
12510
12742
|
log$12.warn("teammate onBlocked", {
|
|
@@ -12587,6 +12819,7 @@ async function handleMcpToolCallback(req, ctx) {
|
|
|
12587
12819
|
sessionId: req.sessionId,
|
|
12588
12820
|
appId: ctx.appId,
|
|
12589
12821
|
scopes: params.scopes,
|
|
12822
|
+
reason: params.reason,
|
|
12590
12823
|
brand: ctx.brand
|
|
12591
12824
|
});
|
|
12592
12825
|
mcpOperationMap.set(operationId, req.requestId);
|
|
@@ -15442,7 +15675,7 @@ function enqueueFeishuChatTask(params) {
|
|
|
15442
15675
|
*/
|
|
15443
15676
|
const log$1 = larkLogger("channel/interactive-card-handler");
|
|
15444
15677
|
async function handleAuthCompleteAction(_ctx, data) {
|
|
15445
|
-
const operationId = data?.
|
|
15678
|
+
const operationId = extractActionValue$1(data)?.operationId;
|
|
15446
15679
|
if (!operationId) return { toast: {
|
|
15447
15680
|
type: "error",
|
|
15448
15681
|
content: "操作参数缺失"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibe-lark/larkpal",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.54",
|
|
4
4
|
"description": "LarkPal - Lark/Feishu bot service",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/main.mjs",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"zod": "^4.3.6"
|
|
51
51
|
},
|
|
52
52
|
"optionalDependencies": {
|
|
53
|
-
"@vibe-lark/larkpal-agent": "^0.1.
|
|
53
|
+
"@vibe-lark/larkpal-agent": "^0.1.16"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@eslint/js": "^10.0.1",
|