吸收数字员工通知回复任务输入
This commit is contained in:
@@ -1517,14 +1517,22 @@ describe("digital employee state service", () => {
|
||||
runId: "run-governance",
|
||||
stepId: "step-governance",
|
||||
accepted: true,
|
||||
payload: { input: "继续使用最新客户名单" },
|
||||
payload: {
|
||||
input: "继续使用最新客户名单",
|
||||
source: "notification_reply",
|
||||
notification_id: "input:task-governance",
|
||||
},
|
||||
});
|
||||
|
||||
expect(mockState.db?.tasks.get("task-governance")).toMatchObject({ status: "paused" });
|
||||
expect(JSON.parse(mockState.db?.tasks.get("task-governance")?.payload ?? "{}")).toMatchObject({
|
||||
lastGovernanceCommand: {
|
||||
commandKind: "provide_task_input",
|
||||
payload: { input: "继续使用最新客户名单" },
|
||||
payload: {
|
||||
input: "继续使用最新客户名单",
|
||||
source: "notification_reply",
|
||||
notification_id: "input:task-governance",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1545,6 +1553,10 @@ describe("digital employee state service", () => {
|
||||
expect(mockState.db?.events.get("run-governance:provide_task_input:command-provide-input")).toMatchObject({
|
||||
kind: "governance_provide_task_input",
|
||||
});
|
||||
expect(mockState.db?.outbox.get("event:insert:run-governance:provide_task_input:command-provide-input")).toMatchObject({
|
||||
entity_type: "event",
|
||||
entity_id: "run-governance:provide_task_input:command-provide-input",
|
||||
});
|
||||
expect(mockState.db?.events.get("run-governance:resume_task:command-resume-task")).toMatchObject({
|
||||
kind: "governance_resume_task",
|
||||
});
|
||||
|
||||
@@ -533,6 +533,27 @@ describe("digital employee sync service", () => {
|
||||
status: "failed",
|
||||
reason: "computer chat failed",
|
||||
});
|
||||
insertEventEntity("event-governance-input", "governance_provide_task_input", {
|
||||
commandKind: "provide_task_input",
|
||||
commandId: "command-provide-input",
|
||||
planId: "plan-1",
|
||||
taskId: "task-1",
|
||||
runId: "run-1",
|
||||
accepted: true,
|
||||
payload: {
|
||||
input: "请改用客户备用手机号",
|
||||
source: "notification_reply",
|
||||
notification_id: "input:task-1",
|
||||
plan_id: "plan-1",
|
||||
task_id: "task-1",
|
||||
},
|
||||
result: {
|
||||
plan_id: "plan-1",
|
||||
task_id: "task-1",
|
||||
run_id: "run-1",
|
||||
source: "qimingclaw-task-agent",
|
||||
},
|
||||
});
|
||||
insertEventEntity("event-notification-read", "digital_workday_notification_read", {
|
||||
metadata: {
|
||||
notification_id: "task:task-1",
|
||||
@@ -604,6 +625,7 @@ describe("digital employee sync service", () => {
|
||||
{ entity_type: "event", entity_id: "event-artifact" },
|
||||
{ entity_type: "event", entity_id: "event-skill" },
|
||||
{ entity_type: "event", entity_id: "event-dispatch" },
|
||||
{ entity_type: "event", entity_id: "event-governance-input" },
|
||||
{ entity_type: "event", entity_id: "event-notification-read" },
|
||||
{ entity_type: "event", entity_id: "event-notification-dismiss" },
|
||||
{ entity_type: "event", entity_id: "event-notification-reply" },
|
||||
@@ -668,6 +690,16 @@ describe("digital employee sync service", () => {
|
||||
status: "failed",
|
||||
reason: "computer chat failed",
|
||||
});
|
||||
expect(businessView("event-governance-input")).toMatchObject({
|
||||
category: "governance",
|
||||
command_kind: "provide_task_input",
|
||||
plan_id: "plan-1",
|
||||
task_id: "task-1",
|
||||
source: "notification_reply",
|
||||
notification_id: "input:task-1",
|
||||
input_length: 10,
|
||||
});
|
||||
expect(businessView("event-governance-input")).not.toHaveProperty("input");
|
||||
expect(businessView("event-notification-read")).toMatchObject({
|
||||
category: "notification",
|
||||
notification_id: "task:task-1",
|
||||
|
||||
@@ -568,6 +568,7 @@ function eventSpecificBusinessView(
|
||||
}
|
||||
if (kind.startsWith("skill_call_")) return skillCallBusinessView(payload);
|
||||
if (kind.startsWith("plan_step_dispatch_")) return planStepDispatchBusinessView(payload);
|
||||
if (kind === "governance_provide_task_input") return governanceProvideTaskInputBusinessView(payload);
|
||||
if (isNotificationEvent(kind)) return notificationBusinessView(payload);
|
||||
return {};
|
||||
}
|
||||
@@ -638,6 +639,20 @@ function planStepDispatchBusinessView(payload: Record<string, unknown>): Record<
|
||||
};
|
||||
}
|
||||
|
||||
function governanceProvideTaskInputBusinessView(payload: Record<string, unknown>): Record<string, unknown> {
|
||||
const commandPayload = objectRecord(payload.payload) ?? {};
|
||||
const result = objectRecord(payload.result) ?? {};
|
||||
const input = stringField(commandPayload.input ?? payload.input);
|
||||
return {
|
||||
command_kind: stringField(payload.commandKind ?? payload.command_kind) || "provide_task_input",
|
||||
plan_id: stringField(payload.planId ?? payload.plan_id ?? commandPayload.plan_id ?? result.plan_id) || null,
|
||||
task_id: stringField(payload.taskId ?? payload.task_id ?? commandPayload.task_id ?? result.task_id) || null,
|
||||
source: stringField(commandPayload.source ?? result.source ?? payload.source) || null,
|
||||
notification_id: stringField(commandPayload.notification_id ?? payload.notification_id) || null,
|
||||
input_length: input ? input.length : null,
|
||||
};
|
||||
}
|
||||
|
||||
function notificationBusinessView(payload: Record<string, unknown>): Record<string, unknown> {
|
||||
const metadata = objectRecord(payload.metadata) ?? {};
|
||||
const state = objectRecord(payload.state) ?? {};
|
||||
|
||||
Reference in New Issue
Block a user