@zengxingyuan/aamp-feishu-task-bridge 0.1.1-dev.8
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/README.md +169 -0
- package/dist/ack.d.ts +12 -0
- package/dist/ack.d.ts.map +1 -0
- package/dist/ack.js +41 -0
- package/dist/ack.js.map +1 -0
- package/dist/config.d.ts +41 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +283 -0
- package/dist/config.js.map +1 -0
- package/dist/dispatch.d.ts +11 -0
- package/dist/dispatch.d.ts.map +1 -0
- package/dist/dispatch.js +220 -0
- package/dist/dispatch.js.map +1 -0
- package/dist/events.d.ts +3 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +21 -0
- package/dist/events.js.map +1 -0
- package/dist/feishu.d.ts +41 -0
- package/dist/feishu.d.ts.map +1 -0
- package/dist/feishu.js +479 -0
- package/dist/feishu.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +244 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime.d.ts +94 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1019 -0
- package/dist/runtime.js.map +1 -0
- package/dist/types.d.ts +151 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +30 -0
package/dist/dispatch.js
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
const EMPTY_DESCRIPTION = '(empty description)';
|
|
2
|
+
const DISPATCH_SOURCE = 'feishu-task';
|
|
3
|
+
function stableIdPart(value) {
|
|
4
|
+
return value.trim().replace(/[^a-zA-Z0-9._:-]+/g, '_') || 'unknown';
|
|
5
|
+
}
|
|
6
|
+
function nonEmpty(value) {
|
|
7
|
+
const trimmed = value?.trim();
|
|
8
|
+
return trimmed || undefined;
|
|
9
|
+
}
|
|
10
|
+
export function buildFeishuTaskDispatchContext(event, task, eventKind) {
|
|
11
|
+
return {
|
|
12
|
+
source: DISPATCH_SOURCE,
|
|
13
|
+
feishu_task_guid: task.guid,
|
|
14
|
+
...(task.taskId ? { feishu_task_id: task.taskId } : {}),
|
|
15
|
+
...(task.status ? { feishu_task_status: task.status } : {}),
|
|
16
|
+
feishu_task_event_id: event.eventId,
|
|
17
|
+
feishu_task_event_types: event.eventTypes.join(','),
|
|
18
|
+
feishu_event_kind: eventKind,
|
|
19
|
+
feishu_task_has_children: String(Boolean(task.subtasks?.length)),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function isHumanComment(authorType) {
|
|
23
|
+
if (!authorType)
|
|
24
|
+
return true;
|
|
25
|
+
return !['agent', 'assistant', 'bot', 'system'].includes(authorType.trim().toLowerCase());
|
|
26
|
+
}
|
|
27
|
+
function renderSubtasks(task) {
|
|
28
|
+
if (!task.subtasks?.length)
|
|
29
|
+
return ['- (none)'];
|
|
30
|
+
return task.subtasks.map((subtask, index) => {
|
|
31
|
+
const parts = [
|
|
32
|
+
`${index + 1}. ${subtask.summary || '(untitled)'}`,
|
|
33
|
+
`guid=${subtask.guid}`,
|
|
34
|
+
...(subtask.taskId ? [`task_id=${subtask.taskId}`] : []),
|
|
35
|
+
...(subtask.status ? [`status=${subtask.status}`] : []),
|
|
36
|
+
...(subtask.url ? [`url=${subtask.url}`] : []),
|
|
37
|
+
];
|
|
38
|
+
return `- ${parts.join(' | ')}`;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function renderComments(task) {
|
|
42
|
+
if (!task.comments?.length)
|
|
43
|
+
return ['- (none loaded)'];
|
|
44
|
+
return task.comments.map((comment, index) => {
|
|
45
|
+
const parts = [
|
|
46
|
+
`${index + 1}. ${comment.content.trim() || '(empty comment)'}`,
|
|
47
|
+
...(comment.id ? [`id=${comment.id}`] : []),
|
|
48
|
+
...(comment.authorType ? [`author=${comment.authorType}`] : []),
|
|
49
|
+
...(comment.createdAt ? [`created_at=${comment.createdAt}`] : []),
|
|
50
|
+
];
|
|
51
|
+
return `- ${parts.join(' | ')}`;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function getLatestEffectiveHumanComment(task) {
|
|
55
|
+
return [...(task.comments ?? [])]
|
|
56
|
+
.filter((comment) => isHumanComment(comment.authorType) && Boolean(nonEmpty(comment.content)))
|
|
57
|
+
.sort((a, b) => (a.createdAt ?? '').localeCompare(b.createdAt ?? ''))
|
|
58
|
+
.at(-1)
|
|
59
|
+
?.content.trim();
|
|
60
|
+
}
|
|
61
|
+
function renderEnvironmentGuidance(options) {
|
|
62
|
+
const env = options?.feishuEnv?.trim();
|
|
63
|
+
const mode = options?.feishuEnvMode ?? (options?.feishuBoe ? 'boe' : undefined);
|
|
64
|
+
if (!env || !mode)
|
|
65
|
+
return [];
|
|
66
|
+
const command = mode === 'boe'
|
|
67
|
+
? `source ~/lark-env.sh boe --boe-env-name ${env}`
|
|
68
|
+
: mode === 'pre'
|
|
69
|
+
? `source ~/lark-env.sh pre --ppe-env-name ${env}`
|
|
70
|
+
: `source ~/lark-env.sh --ppe-env-name ${env}`;
|
|
71
|
+
return [
|
|
72
|
+
'',
|
|
73
|
+
`${mode.toUpperCase()} environment requirement:`,
|
|
74
|
+
`- Before invoking any Feishu task high-level method, run \`${command}\` in the current shell/session.`,
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
function renderDeliverableGuidance() {
|
|
78
|
+
return [
|
|
79
|
+
'- Concrete deliverable write rules:',
|
|
80
|
+
' - For a file or image deliverable, first confirm the file is in the current working directory, uses a relative path, and is no larger than 50 MB. Then upload it with `lark-cli task +upload-attachment --as bot --resource-id "<task_guid>" --resource-type task_delivery --file "./<path>"`. If only `larksuite-cli` is available, use the same arguments with that command name. `--file` is a local file path, not a base64 string.',
|
|
81
|
+
' - For a link deliverable, write it to the parent task text deliveries with `lark-cli task +update --task-id "<task_guid>" --as bot --data \'{"text_deliveries":["<url>"]}\'`. If only `larksuite-cli` is available, use the same arguments with that command name.',
|
|
82
|
+
' - For a text or rich-text deliverable, convert the content to standard markdown, write it as a temporary .md file in the current working directory, extract a concise filename from the content, and upload that file with `lark-cli task +upload-attachment --as bot --resource-id "<task_guid>" --resource-type task_delivery --file "./<markdown_path>"`.',
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
function renderNewlineGuidance() {
|
|
86
|
+
return [
|
|
87
|
+
'- For any user-visible Feishu text, use actual LF newline characters (U+000A / 0x0A) for line breaks.',
|
|
88
|
+
'- Do not write visible literal `\\n`, `\\n\\n`, or double-escaped `\\\\n` text into Feishu comments, FEISHU_TASK_RESULT_JSON user-visible fields, markdown deliverable files, or delivery summaries.',
|
|
89
|
+
'- User-visible fields that may become Feishu comments, including summary, question, error, and deliverable_summary, must follow these newline rules; for need_help, the bridge will comment the question field.',
|
|
90
|
+
'- If using JSON or shell commands, ensure the final decoded comment body or file content contains real line breaks.',
|
|
91
|
+
'- For markdown/text deliverables, prefer heredoc-style file creation so the saved file contains actual newlines.',
|
|
92
|
+
];
|
|
93
|
+
}
|
|
94
|
+
function buildFinalResultExample(payload) {
|
|
95
|
+
return `AAMP_RESULT_JSON: ${JSON.stringify({
|
|
96
|
+
output: `FEISHU_TASK_RESULT_JSON: ${JSON.stringify(payload)}`,
|
|
97
|
+
})}`;
|
|
98
|
+
}
|
|
99
|
+
export function buildFeishuTaskPromptRules(options) {
|
|
100
|
+
const answeredExample = buildFinalResultExample({
|
|
101
|
+
status: 'answered',
|
|
102
|
+
task_flow_intent: 'complete_task',
|
|
103
|
+
summary: '今天是周二。',
|
|
104
|
+
});
|
|
105
|
+
const successExample = buildFinalResultExample({
|
|
106
|
+
status: 'success',
|
|
107
|
+
summary: 'Completed the requested deliverable.',
|
|
108
|
+
deliverable_written: true,
|
|
109
|
+
deliverable_summary: 'The deliverable was uploaded as a task_delivery attachment or linked through text_deliveries.',
|
|
110
|
+
});
|
|
111
|
+
const failureExample = buildFinalResultExample({
|
|
112
|
+
status: 'failed',
|
|
113
|
+
summary: 'Tried to execute the task but hit a blocker.',
|
|
114
|
+
error: '<exact blocker>',
|
|
115
|
+
});
|
|
116
|
+
const helpExample = buildFinalResultExample({
|
|
117
|
+
status: 'need_help',
|
|
118
|
+
summary: 'Need user input before continuing.',
|
|
119
|
+
question: '<question for the user>',
|
|
120
|
+
});
|
|
121
|
+
return [
|
|
122
|
+
'Feishu Task Rules:',
|
|
123
|
+
'- Treat the Description section as the complete Feishu task context.',
|
|
124
|
+
'- Use normalized_kind as the scenario to execute; raw_event_types are reference metadata only.',
|
|
125
|
+
'- This is an existing Feishu task delegation assigned to the app, not a plain chat message and not an ACP direct-answer shortcut.',
|
|
126
|
+
'- Infer intent only from the Feishu task summary, description, child tasks, comments, latest effective human comment, and event metadata in the Description section.',
|
|
127
|
+
'- Do not reconstruct missing intent from unrelated local files, account state, mailbox, credentials, or remote services.',
|
|
128
|
+
'',
|
|
129
|
+
'Intent Rules:',
|
|
130
|
+
'- For task_create or task_reminder_fire, execute the original delegated task intent. For task_reminder_fire, do not treat it as a follow-up question.',
|
|
131
|
+
'- For task_comment, classify task_flow_intent as exactly one of: complete_task, comment_reply.',
|
|
132
|
+
'- complete_task: the latest human comment asks any concrete question, asks for a direct answer, asks to execute, continue, retry, rerun, or otherwise expects this delegated task to be advanced to completion.',
|
|
133
|
+
'- comment_reply: the latest human comment is only an acknowledgement, thanks, status discussion, or comment-only action that should not close the task.',
|
|
134
|
+
'- Child tasks are context only: do not write child steps or child deliverables.',
|
|
135
|
+
'- If the intent is ambiguous or missing required information, use status=need_help.',
|
|
136
|
+
'',
|
|
137
|
+
'Feishu Write Contract:',
|
|
138
|
+
'- The target environment has either `lark-cli` or `larksuite-cli` available.',
|
|
139
|
+
'- Use those CLI tools to update existing Feishu tasks by guid. Include the parent task guid and child task guids explicitly in commands whenever operating on them.',
|
|
140
|
+
'- For task_create execution, task_reminder_fire execution, or task_flow_intent=complete_task, mark the parent task as in progress before material work. When setting agent_task_status=2, also set agent_task_progress to `正在执行`. If child tasks exist, mark each child task as in progress for context tracking only with the same progress text.',
|
|
141
|
+
'- For task_flow_intent=comment_reply, do not mark any task in progress and do not modify task status.',
|
|
142
|
+
'- Child tasks are context only: do not write child steps or child deliverables; only mark child tasks in progress for execution tracking and let the bridge complete them after the final result.',
|
|
143
|
+
'- Do not create a new top-level Feishu task.',
|
|
144
|
+
'- Do not complete parent or child tasks directly; the bridge completes them after parsing your final result.',
|
|
145
|
+
'- Do not write step updates directly. The bridge converts selected, throttled stream status/progress events into Feishu task steps.',
|
|
146
|
+
...renderEnvironmentGuidance(options),
|
|
147
|
+
'',
|
|
148
|
+
'Newline Rules:',
|
|
149
|
+
...renderNewlineGuidance(),
|
|
150
|
+
'',
|
|
151
|
+
'Outcome Rules:',
|
|
152
|
+
'- Normal successful outcomes have exactly two shapes: bridge-written direct answer comment (status=answered) or concrete deliverable (status=success).',
|
|
153
|
+
'- Use status=answered when the user-visible result is just a normal direct reply. Do not write a Feishu comment yourself; put the exact user-visible reply in summary and the bridge will write exactly one comment.',
|
|
154
|
+
'- Use status=success only when there is a concrete deliverable: file, image, document link, long-form text, or rich text. Write the deliverable to the parent task before the final result.',
|
|
155
|
+
'- Use status=need_help when user input is required before continuing. Do not write the help comment yourself; the bridge will comment the question field.',
|
|
156
|
+
'- Use status=failed only for exceptional execution failures. Do not write the failure comment yourself; the bridge will comment it.',
|
|
157
|
+
'- For task_comment events, task_flow_intent=complete_task lets the bridge complete the task; task_flow_intent=comment_reply leaves task status unchanged.',
|
|
158
|
+
'- Do not write normal Feishu task comments directly. For status=answered, the bridge comments the summary. For need_help and failed, the bridge comments the question or error.',
|
|
159
|
+
'- Do not put deliverable content in a normal Feishu task comment, including parent task comments.',
|
|
160
|
+
'',
|
|
161
|
+
'Deliverable Rules:',
|
|
162
|
+
...renderDeliverableGuidance(),
|
|
163
|
+
'- For status=success, include deliverable_written=true and a concise deliverable_summary. Do not paste large deliverable text into the final JSON.',
|
|
164
|
+
'',
|
|
165
|
+
'Final Result Contract:',
|
|
166
|
+
'- Always finish with a single AAMP_RESULT_JSON block whose JSON object contains only the output field.',
|
|
167
|
+
'- The output value must start with `FEISHU_TASK_RESULT_JSON:` followed by a compact JSON object.',
|
|
168
|
+
'- Use status=answered when the task only needs a direct reply and there is no separate deliverable. Put the exact reply text in summary.',
|
|
169
|
+
'- Use status=success only after you uploaded the concrete deliverable as a task_delivery attachment or wrote a link to text_deliveries.',
|
|
170
|
+
'- Use status=need_help when you need human input before continuing.',
|
|
171
|
+
'- Use status=failed only for exceptional execution failures.',
|
|
172
|
+
'- For task_comment events, include task_flow_intent as complete_task or comment_reply. Omit task_flow_intent for non-comment events.',
|
|
173
|
+
'- Include a concise summary. For success, include deliverable_written=true and deliverable_summary.',
|
|
174
|
+
'- Do not include structuredResult.',
|
|
175
|
+
'- Do not include ACP attachments or FILE references; if a deliverable is needed, upload it as task_delivery or write the URL to text_deliveries.',
|
|
176
|
+
`- Example answered task_comment: ${answeredExample}`,
|
|
177
|
+
`- Example success: ${successExample}`,
|
|
178
|
+
`- Example failure: ${failureExample}`,
|
|
179
|
+
`- Example need_help: ${helpExample}`,
|
|
180
|
+
].join('\n');
|
|
181
|
+
}
|
|
182
|
+
export function buildFeishuTaskContext(event, task, eventKind) {
|
|
183
|
+
const description = nonEmpty(task.description) ?? EMPTY_DESCRIPTION;
|
|
184
|
+
const taskUrl = nonEmpty(task.url);
|
|
185
|
+
const taskStatus = nonEmpty(task.status);
|
|
186
|
+
const latestHumanComment = getLatestEffectiveHumanComment(task);
|
|
187
|
+
return [
|
|
188
|
+
'Feishu Task:',
|
|
189
|
+
`- guid: ${task.guid}`,
|
|
190
|
+
...(task.taskId ? [`- task_id: ${task.taskId}`] : []),
|
|
191
|
+
`- summary: ${task.summary}`,
|
|
192
|
+
`- description: ${description}`,
|
|
193
|
+
...(taskStatus ? [`- status: ${taskStatus}`] : []),
|
|
194
|
+
...(task.parentGuid ? [`- parent_guid: ${task.parentGuid}`] : []),
|
|
195
|
+
...(taskUrl ? [`- url: ${taskUrl}`] : []),
|
|
196
|
+
'Child tasks:',
|
|
197
|
+
...renderSubtasks(task),
|
|
198
|
+
'Comments:',
|
|
199
|
+
...renderComments(task),
|
|
200
|
+
...(latestHumanComment ? [`- Latest effective human comment: ${latestHumanComment}`] : []),
|
|
201
|
+
'Event:',
|
|
202
|
+
`- normalized_kind: ${eventKind}`,
|
|
203
|
+
`- raw_event_types: ${event.eventTypes.join(',') || '(unknown)'}`,
|
|
204
|
+
`- event_id: ${event.eventId}`,
|
|
205
|
+
`- task_guid: ${event.taskGuid}`,
|
|
206
|
+
...(event.timestamp ? [`- timestamp: ${event.timestamp}`] : []),
|
|
207
|
+
].join('\n');
|
|
208
|
+
}
|
|
209
|
+
export function buildFeishuTaskDispatch(event, task, eventKind, options) {
|
|
210
|
+
const taskId = `feishu-task-${stableIdPart(event.taskGuid)}-${stableIdPart(event.eventId)}`;
|
|
211
|
+
return {
|
|
212
|
+
taskId,
|
|
213
|
+
sessionKey: `feishu-task:${task.guid}`,
|
|
214
|
+
title: `Feishu Task: ${task.summary || task.guid}`,
|
|
215
|
+
bodyText: buildFeishuTaskContext(event, task, eventKind),
|
|
216
|
+
dispatchContext: buildFeishuTaskDispatchContext(event, task, eventKind),
|
|
217
|
+
promptRules: buildFeishuTaskPromptRules(options),
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=dispatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAEA,MAAM,iBAAiB,GAAG,qBAAqB,CAAA;AAC/C,MAAM,eAAe,GAAG,aAAa,CAAA;AAQrC,SAAS,YAAY,CAAC,KAAa;IACjC,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,oBAAoB,EAAE,GAAG,CAAC,IAAI,SAAS,CAAA;AACrE,CAAC;AAED,SAAS,QAAQ,CAAC,KAAyB;IACzC,MAAM,OAAO,G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Ae,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAA;IAC3F,OAAO;QACL,MAAM;QACN,UAAU,EAAE,eAAe,IAAI,CAAC,IAAI,EAAE;QACtC,KAAK,EAAE,gBAAgB,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE;QAClD,QAAQ,EAAE,sBAAsB,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,CAAC;QACxD,eAAe,EAAE,8BAA8B,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,CAAC;QACvE,WAAW,EAAE,0BAA0B,CAAC,OAAO,CAAC;KACjD,CAAA;AACH,CAAC"}
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAUrD,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,GAAG,mBAAmB,GAAG,IAAI,CAYjG"}
|
package/dist/events.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const TASK_CREATE_EVENT = 'task_create';
|
|
2
|
+
const TASK_REMINDER_FIRE_EVENT = 'task_reminder_fire';
|
|
3
|
+
const TASK_COMMENT_EVENTS = new Set([
|
|
4
|
+
'task_comment_create',
|
|
5
|
+
'task_comment_reply',
|
|
6
|
+
'task_comment_update',
|
|
7
|
+
]);
|
|
8
|
+
export function classifyFeishuTaskEvent(eventTypes) {
|
|
9
|
+
const normalized = eventTypes.map((eventType) => eventType.trim()).filter(Boolean);
|
|
10
|
+
if (normalized.some((eventType) => TASK_COMMENT_EVENTS.has(eventType))) {
|
|
11
|
+
return 'task_comment';
|
|
12
|
+
}
|
|
13
|
+
if (normalized.includes(TASK_CREATE_EVENT)) {
|
|
14
|
+
return 'task_create';
|
|
15
|
+
}
|
|
16
|
+
if (normalized.includes(TASK_REMINDER_FIRE_EVENT)) {
|
|
17
|
+
return 'task_reminder_fire';
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAEA,MAAM,iBAAiB,GAAG,aAAa,CAAA;AACvC,MAAM,wBAAwB,GAAG,oBAAoB,CAAA;AACrD,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC;IAClC,qBAAqB;IACrB,oBAAoB;IACpB,qBAAqB;CACtB,CAAC,CAAA;AAEF,MAAM,UAAU,uBAAuB,CAAC,UAA6B;IACnE,MAAM,UAAU,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAClF,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,mBAAmB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;QACvE,OAAO,cAAc,CAAA;IACvB,CAAC;IACD,IAAI,UAAU,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAC3C,OAAO,aAAa,CAAA;IACtB,CAAC;IACD,IAAI,UAAU,CAAC,QAAQ,CAAC,wBAAwB,CAAC,EAAE,CAAC;QAClD,OAAO,oBAAoB,CAAA;IAC7B,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
|
package/dist/feishu.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type HttpInstance } from '@larksuiteoapi/node-sdk';
|
|
2
|
+
import type { BridgeConfig, FeishuTaskClient, FeishuTaskDetails, FeishuTaskEvent } from './types.js';
|
|
3
|
+
type FeishuConfig = BridgeConfig['feishu'];
|
|
4
|
+
type Logger = Pick<Console, 'error' | 'log'>;
|
|
5
|
+
interface OapiFeishuTaskClientOptions {
|
|
6
|
+
logger?: Logger;
|
|
7
|
+
}
|
|
8
|
+
export declare function createFeishuHttpInstance(headers: Record<string, string> | undefined): HttpInstance | undefined;
|
|
9
|
+
export declare function normalizeFeishuTaskEvent(raw: unknown, fallbackEventName: string): FeishuTaskEvent | null;
|
|
10
|
+
export declare class OapiFeishuTaskClient implements FeishuTaskClient {
|
|
11
|
+
private readonly client;
|
|
12
|
+
private readonly config;
|
|
13
|
+
private readonly httpInstance?;
|
|
14
|
+
private readonly logger;
|
|
15
|
+
private wsClient?;
|
|
16
|
+
constructor(config: FeishuConfig, options?: OapiFeishuTaskClientOptions);
|
|
17
|
+
registerAgent(): Promise<void>;
|
|
18
|
+
subscribeTaskEvents(): Promise<void>;
|
|
19
|
+
start(onEvent: (event: FeishuTaskEvent) => Promise<void>): Promise<void>;
|
|
20
|
+
stop(): Promise<void>;
|
|
21
|
+
getTask(taskGuid: string): Promise<FeishuTaskDetails>;
|
|
22
|
+
commentTask(taskGuid: string, content: string): Promise<void>;
|
|
23
|
+
appendTaskStep(taskGuid: string, content: string): Promise<void>;
|
|
24
|
+
appendTaskSteps(taskGuid: string, contents: string[]): Promise<void>;
|
|
25
|
+
completeTask(taskGuid: string): Promise<void>;
|
|
26
|
+
markTaskWaitingForHuman(taskGuid: string): Promise<void>;
|
|
27
|
+
private getV1Task;
|
|
28
|
+
private getV2Task;
|
|
29
|
+
private commentV1Task;
|
|
30
|
+
private commentV2Task;
|
|
31
|
+
private appendV2TaskSteps;
|
|
32
|
+
private appendV2TaskStepsWithRawRequest;
|
|
33
|
+
private registerV2AgentWithRawRequest;
|
|
34
|
+
private subscribeV2TaskEventsWithRawRequest;
|
|
35
|
+
private completeV2AgentTask;
|
|
36
|
+
private patchV2AgentTaskStatus;
|
|
37
|
+
private listV2Subtasks;
|
|
38
|
+
private listV2Comments;
|
|
39
|
+
}
|
|
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