@rynx-ai/plugin-channel-lark 0.1.9
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/cli-mirror/mirror-index.d.ts +46 -0
- package/dist/cli-mirror/mirror-index.js +48 -0
- package/dist/cli-mirror/rollout-mirror.d.ts +85 -0
- package/dist/cli-mirror/rollout-mirror.js +333 -0
- package/dist/cli-mirror/rollout-watcher.d.ts +109 -0
- package/dist/cli-mirror/rollout-watcher.js +347 -0
- package/dist/host-adapters.d.ts +82 -0
- package/dist/host-adapters.js +404 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/lark-card-stream.d.ts +363 -0
- package/dist/lark-card-stream.js +1335 -0
- package/dist/lark-content.d.ts +30 -0
- package/dist/lark-content.js +138 -0
- package/dist/lark-conversation-directory.d.ts +65 -0
- package/dist/lark-conversation-directory.js +106 -0
- package/dist/lark-diff-card.d.ts +25 -0
- package/dist/lark-diff-card.js +58 -0
- package/dist/lark-fork-transcript.d.ts +16 -0
- package/dist/lark-fork-transcript.js +141 -0
- package/dist/lark-resume-card.d.ts +31 -0
- package/dist/lark-resume-card.js +105 -0
- package/dist/lark-sdk/client.d.ts +8 -0
- package/dist/lark-sdk/client.js +32 -0
- package/dist/lark-sdk/index.d.ts +1 -0
- package/dist/lark-sdk/index.js +1 -0
- package/dist/lark-sender.d.ts +114 -0
- package/dist/lark-sender.js +323 -0
- package/dist/lark-session-store.d.ts +13 -0
- package/dist/lark-session-store.js +14 -0
- package/dist/lark-settings-card.d.ts +55 -0
- package/dist/lark-settings-card.js +158 -0
- package/dist/lark-setup.d.ts +17 -0
- package/dist/lark-setup.js +86 -0
- package/dist/lark.d.ts +500 -0
- package/dist/lark.js +2010 -0
- package/dist/runtime.d.ts +16 -0
- package/dist/runtime.js +157 -0
- package/dist/runtime.mjs +130863 -0
- package/package.json +35 -0
- package/rynx-plugin.json +42 -0
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import type { AgentHarnessEvent } from "@rynx-ai/core";
|
|
2
|
+
import type { SessionEvent, TurnPlanStep } from "@rynx-ai/core";
|
|
3
|
+
export type CardStatus = "starting" | "running" | "completed" | "failed" | "cancelled";
|
|
4
|
+
export interface ToolCallSnapshot {
|
|
5
|
+
itemId: string;
|
|
6
|
+
kind: "command_execution" | "file_change" | "mcp_tool_call" | "dynamic_tool_call" | "web_search" | "other";
|
|
7
|
+
label: string;
|
|
8
|
+
status: "inProgress" | "completed" | "failed" | "declined";
|
|
9
|
+
command?: string;
|
|
10
|
+
output?: string;
|
|
11
|
+
exitCode?: number | null;
|
|
12
|
+
}
|
|
13
|
+
export interface TurnCardState {
|
|
14
|
+
status: CardStatus;
|
|
15
|
+
statusReason: string | null;
|
|
16
|
+
plan: TurnPlanStep[] | null;
|
|
17
|
+
reasoningSummary: string;
|
|
18
|
+
toolCalls: ToolCallSnapshot[];
|
|
19
|
+
/** Aggregated turn-level unified diff (`turn/diff/updated`). */
|
|
20
|
+
turnDiff: string | null;
|
|
21
|
+
agentMessage: string;
|
|
22
|
+
finalAnswer: string | null;
|
|
23
|
+
errorMessage: string | null;
|
|
24
|
+
localThreadId: string;
|
|
25
|
+
codexThreadId: string | null;
|
|
26
|
+
/** Stable `/resume <id>` short id for this conversation (= the conversation
|
|
27
|
+
* directory's `shortId`). Shown in the footer so what's displayed is exactly
|
|
28
|
+
* what the user types to jump back. Null when the conversation key is
|
|
29
|
+
* unknown at card-creation time. */
|
|
30
|
+
resumeShortId: string | null;
|
|
31
|
+
turnId: string | null;
|
|
32
|
+
/** Short runtime label shown in the status row (e.g. `codex` / `trae`). */
|
|
33
|
+
runtime: string | null;
|
|
34
|
+
model: string;
|
|
35
|
+
/** Reasoning effort shown in the status row (e.g. `xhigh`); null = follow model default. */
|
|
36
|
+
effort: string | null;
|
|
37
|
+
usage: Record<string, unknown> | null;
|
|
38
|
+
startedAt: string;
|
|
39
|
+
}
|
|
40
|
+
export interface CreateInitialStateOptions {
|
|
41
|
+
localThreadId: string;
|
|
42
|
+
model: string;
|
|
43
|
+
runtime?: string;
|
|
44
|
+
/** Stable `/resume <id>` short id for this conversation, shown in the footer. */
|
|
45
|
+
resumeShortId?: string;
|
|
46
|
+
/** Reasoning effort for this turn; omit to follow the model default (hidden). */
|
|
47
|
+
effort?: string;
|
|
48
|
+
startedAt?: string;
|
|
49
|
+
}
|
|
50
|
+
export declare function createInitialCardState({ localThreadId, model, runtime, resumeShortId, effort, startedAt, }: CreateInitialStateOptions): TurnCardState;
|
|
51
|
+
export declare function applyEventToCardState(state: TurnCardState, event: AgentHarnessEvent): TurnCardState;
|
|
52
|
+
declare const ELEMENT_IDS: {
|
|
53
|
+
readonly status_row: "status_row";
|
|
54
|
+
readonly status: "status";
|
|
55
|
+
readonly stop_column: "stop_column";
|
|
56
|
+
readonly plan: "plan";
|
|
57
|
+
readonly reasoning_panel: "reasoning_panel";
|
|
58
|
+
readonly reasoning: "reasoning";
|
|
59
|
+
readonly tools_panel: "tools_panel";
|
|
60
|
+
readonly tools: "tools";
|
|
61
|
+
readonly output: "output";
|
|
62
|
+
readonly diff_panel: "diff_panel";
|
|
63
|
+
readonly diff: "diff";
|
|
64
|
+
readonly message: "message";
|
|
65
|
+
readonly error: "error";
|
|
66
|
+
};
|
|
67
|
+
type ElementId = (typeof ELEMENT_IDS)[keyof typeof ELEMENT_IDS];
|
|
68
|
+
export declare function renderStatusMarkdown(state: TurnCardState): string;
|
|
69
|
+
export declare function renderPlanMarkdown(plan: TurnPlanStep[] | null): string;
|
|
70
|
+
export declare function renderReasoningMarkdown(summary: string): string;
|
|
71
|
+
export declare function renderToolsMarkdown(toolCalls: ToolCallSnapshot[]): string;
|
|
72
|
+
export declare function renderOutputMarkdown(toolCalls: ToolCallSnapshot[]): string;
|
|
73
|
+
export declare function renderDiffMarkdown(turnDiff: string | null): string;
|
|
74
|
+
export declare function renderMessageMarkdown(state: TurnCardState): string;
|
|
75
|
+
export declare function renderErrorMarkdown(state: TurnCardState): string;
|
|
76
|
+
interface CardMarkdownElement {
|
|
77
|
+
tag: "markdown";
|
|
78
|
+
element_id: ElementId;
|
|
79
|
+
content: string;
|
|
80
|
+
}
|
|
81
|
+
interface CardCollapsiblePanelElement {
|
|
82
|
+
tag: "collapsible_panel";
|
|
83
|
+
element_id: ElementId;
|
|
84
|
+
expanded: boolean;
|
|
85
|
+
header: {
|
|
86
|
+
title: {
|
|
87
|
+
tag: "plain_text";
|
|
88
|
+
content: string;
|
|
89
|
+
};
|
|
90
|
+
vertical_align?: "center" | "top" | "bottom";
|
|
91
|
+
icon: {
|
|
92
|
+
tag: "standard_icon";
|
|
93
|
+
token: string;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
elements: CardMarkdownElement[];
|
|
97
|
+
}
|
|
98
|
+
interface CardColumnElement {
|
|
99
|
+
tag: "column";
|
|
100
|
+
element_id?: ElementId;
|
|
101
|
+
width: "weighted" | "auto" | "fill";
|
|
102
|
+
weight?: number;
|
|
103
|
+
vertical_align?: "top" | "center" | "bottom";
|
|
104
|
+
elements: Array<CardMarkdownElement | CardStopButtonElement>;
|
|
105
|
+
}
|
|
106
|
+
interface CardColumnSetElement {
|
|
107
|
+
tag: "column_set";
|
|
108
|
+
element_id: ElementId;
|
|
109
|
+
flex_mode: "none";
|
|
110
|
+
horizontal_align?: "left" | "right" | "center";
|
|
111
|
+
columns: CardColumnElement[];
|
|
112
|
+
}
|
|
113
|
+
type CardBodyElement = CardMarkdownElement | CardCollapsiblePanelElement | CardColumnSetElement;
|
|
114
|
+
interface CardStopButtonElement {
|
|
115
|
+
tag: "button";
|
|
116
|
+
type: "text";
|
|
117
|
+
size: "small";
|
|
118
|
+
icon: {
|
|
119
|
+
tag: "standard_icon";
|
|
120
|
+
token: "stop_outlined";
|
|
121
|
+
};
|
|
122
|
+
hover_tips: {
|
|
123
|
+
tag: "plain_text";
|
|
124
|
+
content: string;
|
|
125
|
+
};
|
|
126
|
+
behaviors: Array<{
|
|
127
|
+
type: "callback";
|
|
128
|
+
value: {
|
|
129
|
+
kind: "stop_turn";
|
|
130
|
+
sessionKey: string;
|
|
131
|
+
};
|
|
132
|
+
}>;
|
|
133
|
+
}
|
|
134
|
+
export interface StopButtonOptions {
|
|
135
|
+
sessionKey: string;
|
|
136
|
+
/** Tooltip shown on hover. Defaults to "停止". */
|
|
137
|
+
hoverTip?: string;
|
|
138
|
+
}
|
|
139
|
+
export interface CreateInitialCardJsonResult {
|
|
140
|
+
cardJson: string;
|
|
141
|
+
mounted: Set<ElementId>;
|
|
142
|
+
}
|
|
143
|
+
export declare function createInitialCardJson(state: TurnCardState, opts?: {
|
|
144
|
+
stopButton?: StopButtonOptions;
|
|
145
|
+
}): CreateInitialCardJsonResult;
|
|
146
|
+
export type CardAction = {
|
|
147
|
+
action: "partial_update_element";
|
|
148
|
+
params: {
|
|
149
|
+
element_id: ElementId;
|
|
150
|
+
partial_element: {
|
|
151
|
+
content: string;
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
} | {
|
|
155
|
+
action: "add_elements";
|
|
156
|
+
params: {
|
|
157
|
+
type: "insert_before" | "insert_after" | "append";
|
|
158
|
+
target_element_id?: string;
|
|
159
|
+
elements: CardBodyElement[];
|
|
160
|
+
};
|
|
161
|
+
} | {
|
|
162
|
+
action: "delete_elements";
|
|
163
|
+
params: {
|
|
164
|
+
element_ids: string[];
|
|
165
|
+
};
|
|
166
|
+
} | {
|
|
167
|
+
action: "partial_update_setting";
|
|
168
|
+
params: {
|
|
169
|
+
settings: Record<string, unknown>;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
export declare function buildTerminalSettingsAction(): CardAction;
|
|
173
|
+
export declare function buildStopColumnDeleteAction(): CardAction;
|
|
174
|
+
export interface DiffCardActionsResult {
|
|
175
|
+
actions: CardAction[];
|
|
176
|
+
mounted: Set<ElementId>;
|
|
177
|
+
}
|
|
178
|
+
export declare function diffCardActions(prev: TurnCardState, next: TurnCardState, mounted: Set<ElementId>): DiffCardActionsResult;
|
|
179
|
+
export interface LarkCardSender {
|
|
180
|
+
createCard(args: {
|
|
181
|
+
cardJson: string;
|
|
182
|
+
}): Promise<{
|
|
183
|
+
cardId: string;
|
|
184
|
+
}>;
|
|
185
|
+
batchUpdateCard(args: {
|
|
186
|
+
cardId: string;
|
|
187
|
+
sequence: number;
|
|
188
|
+
actions: string;
|
|
189
|
+
uuid?: string;
|
|
190
|
+
}): Promise<void>;
|
|
191
|
+
sendInteractive(args: {
|
|
192
|
+
chatId: string;
|
|
193
|
+
cardId: string;
|
|
194
|
+
uuid: string;
|
|
195
|
+
}): Promise<{
|
|
196
|
+
messageId: string;
|
|
197
|
+
}>;
|
|
198
|
+
replyInteractive(args: {
|
|
199
|
+
messageId: string;
|
|
200
|
+
cardId: string;
|
|
201
|
+
uuid: string;
|
|
202
|
+
replyInThread: boolean;
|
|
203
|
+
}): Promise<{
|
|
204
|
+
messageId: string;
|
|
205
|
+
}>;
|
|
206
|
+
}
|
|
207
|
+
export interface LarkCardLogger {
|
|
208
|
+
log(entry: Record<string, unknown>): void;
|
|
209
|
+
}
|
|
210
|
+
export interface CardControllerSessionInfo {
|
|
211
|
+
chatId: string;
|
|
212
|
+
/** The inbound user message to quote-reply to (used by `start()`). Absent for
|
|
213
|
+
* CLI-mirrored turns, which post a standalone card via `startStandalone()`. */
|
|
214
|
+
messageId?: string;
|
|
215
|
+
threadId?: string;
|
|
216
|
+
}
|
|
217
|
+
export interface LarkTurnCardControllerOptions {
|
|
218
|
+
sender: LarkCardSender;
|
|
219
|
+
session: CardControllerSessionInfo;
|
|
220
|
+
initialState: TurnCardState;
|
|
221
|
+
throttleMs?: number;
|
|
222
|
+
logger?: LarkCardLogger;
|
|
223
|
+
stopButton?: StopButtonOptions;
|
|
224
|
+
}
|
|
225
|
+
export declare class LarkTurnCardController {
|
|
226
|
+
private readonly sender;
|
|
227
|
+
private readonly session;
|
|
228
|
+
private readonly throttleMs;
|
|
229
|
+
private readonly logger?;
|
|
230
|
+
private readonly stopButton;
|
|
231
|
+
private state;
|
|
232
|
+
private cardId;
|
|
233
|
+
private sequence;
|
|
234
|
+
private flushTimer;
|
|
235
|
+
private flushChain;
|
|
236
|
+
private lastFlushedState;
|
|
237
|
+
private mounted;
|
|
238
|
+
private dirty;
|
|
239
|
+
private closed;
|
|
240
|
+
private terminal;
|
|
241
|
+
private stopButtonMounted;
|
|
242
|
+
constructor({ sender, session, initialState, throttleMs, logger, stopButton, }: LarkTurnCardControllerOptions);
|
|
243
|
+
start(): Promise<void>;
|
|
244
|
+
/**
|
|
245
|
+
* Post the card as a standalone chat message instead of a quote-reply. Used
|
|
246
|
+
* to mirror a CLI-driven turn, where there is no inbound Feishu message to
|
|
247
|
+
* reply to. `sendInteractive` targets the chat (no thread-targeting param),
|
|
248
|
+
* so for topic-thread conversations the card lands at chat level.
|
|
249
|
+
*/
|
|
250
|
+
startStandalone(): Promise<void>;
|
|
251
|
+
ingestEvent(event: AgentHarnessEvent): Promise<void>;
|
|
252
|
+
finalize(opts: {
|
|
253
|
+
status: "completed" | "failed" | "cancelled";
|
|
254
|
+
finalAnswer?: string;
|
|
255
|
+
error?: string;
|
|
256
|
+
}): Promise<void>;
|
|
257
|
+
getState(): TurnCardState;
|
|
258
|
+
private scheduleFlush;
|
|
259
|
+
private flush;
|
|
260
|
+
}
|
|
261
|
+
/** Footer metadata shown in the status row (mirrors the legacy card's footer). */
|
|
262
|
+
export interface SessionCardMeta {
|
|
263
|
+
runtime: string | null;
|
|
264
|
+
model: string;
|
|
265
|
+
effort: string | null;
|
|
266
|
+
resumeShortId: string | null;
|
|
267
|
+
}
|
|
268
|
+
export interface LarkResponseCardControllerOptions {
|
|
269
|
+
sender: LarkCardSender;
|
|
270
|
+
chatId: string;
|
|
271
|
+
meta: SessionCardMeta;
|
|
272
|
+
throttleMs?: number;
|
|
273
|
+
logger?: LarkCardLogger;
|
|
274
|
+
stopButton?: StopButtonOptions;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Renders ONE response as a streaming Feishu card: a status row plus an ordered
|
|
278
|
+
* list of item blocks appended as they arrive. Keeps the legacy controller's
|
|
279
|
+
* throttle / sequence / serialized-flush machinery; only the state model + diff
|
|
280
|
+
* differ (an append-mostly ordered list rather than fixed panels).
|
|
281
|
+
*/
|
|
282
|
+
export declare class LarkResponseCardController {
|
|
283
|
+
private readonly sender;
|
|
284
|
+
private readonly chatId;
|
|
285
|
+
private readonly meta;
|
|
286
|
+
private readonly throttleMs;
|
|
287
|
+
private readonly logger?;
|
|
288
|
+
private readonly stopButton;
|
|
289
|
+
private cardId;
|
|
290
|
+
private sequence;
|
|
291
|
+
private flushTimer;
|
|
292
|
+
private flushChain;
|
|
293
|
+
private dirty;
|
|
294
|
+
private terminal;
|
|
295
|
+
private closed;
|
|
296
|
+
private stopButtonMounted;
|
|
297
|
+
private status;
|
|
298
|
+
/** Transient status banner (e.g. API-retry); cleared once progress resumes. */
|
|
299
|
+
private statusNote;
|
|
300
|
+
private elIdSeq;
|
|
301
|
+
private readonly items;
|
|
302
|
+
private readonly byItemId;
|
|
303
|
+
private readonly byCallId;
|
|
304
|
+
private readonly mounted;
|
|
305
|
+
private readonly lastRendered;
|
|
306
|
+
constructor(opts: LarkResponseCardControllerOptions);
|
|
307
|
+
/** Create the card (status row only) and reply/send it. Returns the posted
|
|
308
|
+
* message id so the orchestrator can chain the next response's card under it. */
|
|
309
|
+
start(replyTo: {
|
|
310
|
+
messageId?: string;
|
|
311
|
+
replyInThread: boolean;
|
|
312
|
+
}): Promise<{
|
|
313
|
+
messageId?: string;
|
|
314
|
+
}>;
|
|
315
|
+
applyEvent(event: SessionEvent): void;
|
|
316
|
+
/** Set/replace the transient status banner (amber note in the status row). */
|
|
317
|
+
setStatusNote(note: string | null): void;
|
|
318
|
+
private clearStatusNote;
|
|
319
|
+
finalize(status: "completed" | "failed" | "cancelled"): Promise<void>;
|
|
320
|
+
private applyItem;
|
|
321
|
+
/** A fresh, Feishu-legal element_id (letter-prefixed, ≤ 20 chars). */
|
|
322
|
+
private nextElId;
|
|
323
|
+
private ensureMessage;
|
|
324
|
+
private ensureReasoning;
|
|
325
|
+
private ensureTool;
|
|
326
|
+
private scheduleFlush;
|
|
327
|
+
private flush;
|
|
328
|
+
}
|
|
329
|
+
export interface LarkSessionCardControllerOptions {
|
|
330
|
+
sender: LarkCardSender;
|
|
331
|
+
session: CardControllerSessionInfo;
|
|
332
|
+
meta: SessionCardMeta;
|
|
333
|
+
throttleMs?: number;
|
|
334
|
+
logger?: LarkCardLogger;
|
|
335
|
+
stopButton?: StopButtonOptions;
|
|
336
|
+
/** Called once with the underlying runtime session id (for the CLI mirror). */
|
|
337
|
+
onRuntimeSession?: (runtimeSessionId: string) => void;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Orchestrates a turn's {@link SessionEvent} stream into a sequence of per-
|
|
341
|
+
* response cards. Each `response.created` opens a new card (replied under the
|
|
342
|
+
* previous one, forming a thread); item/lifecycle events route by `responseId`.
|
|
343
|
+
*/
|
|
344
|
+
export declare class LarkSessionCardController {
|
|
345
|
+
private readonly opts;
|
|
346
|
+
private readonly cards;
|
|
347
|
+
private current;
|
|
348
|
+
private anchorMessageId?;
|
|
349
|
+
private readonly replyInThread;
|
|
350
|
+
private notedRuntimeSession;
|
|
351
|
+
private started;
|
|
352
|
+
/** Accumulated assistant text, used only as a chat fallback if no card opened. */
|
|
353
|
+
private fallback;
|
|
354
|
+
constructor(opts: LarkSessionCardControllerOptions);
|
|
355
|
+
/** Whether at least one response card was successfully posted. */
|
|
356
|
+
get cardStarted(): boolean;
|
|
357
|
+
/** The assistant text (for a plain-text reply when no card could be shown). */
|
|
358
|
+
get fallbackText(): string;
|
|
359
|
+
ingest(event: SessionEvent): Promise<void>;
|
|
360
|
+
/** Finalize any still-open cards (safety net on stream end / throw). */
|
|
361
|
+
finalizeAll(status: "completed" | "failed" | "cancelled"): Promise<void>;
|
|
362
|
+
}
|
|
363
|
+
export {};
|