@galaxy-stack/blackhole-cli 2.4.0 → 3.0.0
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 +78 -47
- package/dist/application.d.ts.map +1 -1
- package/dist/application.js +13 -2
- package/dist/application.js.map +1 -1
- package/dist/cli-meta.d.ts +8 -0
- package/dist/cli-meta.d.ts.map +1 -1
- package/dist/cli-meta.js +11 -0
- package/dist/cli-meta.js.map +1 -1
- package/dist/cli.js +26 -9
- package/dist/cli.js.map +1 -1
- package/dist/config-command.d.ts +11 -14
- package/dist/config-command.d.ts.map +1 -1
- package/dist/config-command.js +41 -118
- package/dist/config-command.js.map +1 -1
- package/dist/doctor.d.ts +8 -2
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +11 -15
- package/dist/doctor.js.map +1 -1
- package/dist/file-index.d.ts +50 -0
- package/dist/file-index.d.ts.map +1 -1
- package/dist/file-index.js +124 -0
- package/dist/file-index.js.map +1 -1
- package/dist/harness/boot.d.ts +87 -0
- package/dist/harness/boot.d.ts.map +1 -0
- package/dist/harness/boot.js +111 -0
- package/dist/harness/boot.js.map +1 -0
- package/dist/harness/catalogs.d.ts +50 -0
- package/dist/harness/catalogs.d.ts.map +1 -0
- package/dist/harness/catalogs.js +34 -0
- package/dist/harness/catalogs.js.map +1 -0
- package/dist/harness/chat.d.ts +90 -0
- package/dist/harness/chat.d.ts.map +1 -0
- package/dist/harness/chat.js +260 -0
- package/dist/harness/chat.js.map +1 -0
- package/dist/harness/client.d.ts +72 -0
- package/dist/harness/client.d.ts.map +1 -0
- package/dist/harness/client.js +173 -0
- package/dist/harness/client.js.map +1 -0
- package/dist/harness/command.d.ts +22 -0
- package/dist/harness/command.d.ts.map +1 -0
- package/dist/harness/command.js +142 -0
- package/dist/harness/command.js.map +1 -0
- package/dist/harness/composer.d.ts +46 -0
- package/dist/harness/composer.d.ts.map +1 -0
- package/dist/harness/composer.js +127 -0
- package/dist/harness/composer.js.map +1 -0
- package/dist/harness/conversation.d.ts +75 -0
- package/dist/harness/conversation.d.ts.map +1 -0
- package/dist/harness/conversation.js +196 -0
- package/dist/harness/conversation.js.map +1 -0
- package/dist/harness/help.d.ts +56 -0
- package/dist/harness/help.d.ts.map +1 -0
- package/dist/harness/help.js +85 -0
- package/dist/harness/help.js.map +1 -0
- package/dist/harness/history.d.ts +108 -0
- package/dist/harness/history.d.ts.map +1 -0
- package/dist/harness/history.js +268 -0
- package/dist/harness/history.js.map +1 -0
- package/dist/harness/labels.d.ts +164 -0
- package/dist/harness/labels.d.ts.map +1 -0
- package/dist/harness/labels.js +271 -0
- package/dist/harness/labels.js.map +1 -0
- package/dist/harness/locate.d.ts +24 -0
- package/dist/harness/locate.d.ts.map +1 -0
- package/dist/harness/locate.js +69 -0
- package/dist/harness/locate.js.map +1 -0
- package/dist/harness/menus.d.ts +74 -0
- package/dist/harness/menus.d.ts.map +1 -0
- package/dist/harness/menus.js +140 -0
- package/dist/harness/menus.js.map +1 -0
- package/dist/harness/model-name.d.ts +73 -0
- package/dist/harness/model-name.d.ts.map +1 -0
- package/dist/harness/model-name.js +101 -0
- package/dist/harness/model-name.js.map +1 -0
- package/dist/harness/parts.d.ts +239 -0
- package/dist/harness/parts.d.ts.map +1 -0
- package/dist/harness/parts.js +266 -0
- package/dist/harness/parts.js.map +1 -0
- package/dist/harness/preset.d.ts +124 -0
- package/dist/harness/preset.d.ts.map +1 -0
- package/dist/harness/preset.js +197 -0
- package/dist/harness/preset.js.map +1 -0
- package/dist/harness/process.d.ts +55 -0
- package/dist/harness/process.d.ts.map +1 -0
- package/dist/harness/process.js +119 -0
- package/dist/harness/process.js.map +1 -0
- package/dist/harness/screen.d.ts +33 -0
- package/dist/harness/screen.d.ts.map +1 -0
- package/dist/harness/screen.js +1070 -0
- package/dist/harness/screen.js.map +1 -0
- package/dist/harness/sessions.d.ts +55 -0
- package/dist/harness/sessions.d.ts.map +1 -0
- package/dist/harness/sessions.js +92 -0
- package/dist/harness/sessions.js.map +1 -0
- package/dist/harness/skills.d.ts +90 -0
- package/dist/harness/skills.d.ts.map +1 -0
- package/dist/harness/skills.js +133 -0
- package/dist/harness/skills.js.map +1 -0
- package/dist/harness/slash-palette.d.ts +32 -0
- package/dist/harness/slash-palette.d.ts.map +1 -0
- package/dist/harness/slash-palette.js +48 -0
- package/dist/harness/slash-palette.js.map +1 -0
- package/dist/harness/slash.d.ts +113 -0
- package/dist/harness/slash.d.ts.map +1 -0
- package/dist/harness/slash.js +187 -0
- package/dist/harness/slash.js.map +1 -0
- package/dist/harness/trajectory.d.ts +74 -0
- package/dist/harness/trajectory.d.ts.map +1 -0
- package/dist/harness/trajectory.js +270 -0
- package/dist/harness/trajectory.js.map +1 -0
- package/dist/harness/tui.d.ts +28 -0
- package/dist/harness/tui.d.ts.map +1 -0
- package/dist/harness/tui.js +143 -0
- package/dist/harness/tui.js.map +1 -0
- package/dist/manual-config.d.ts +23 -10
- package/dist/manual-config.d.ts.map +1 -1
- package/dist/manual-config.js +45 -37
- package/dist/manual-config.js.map +1 -1
- package/dist/migrate.d.ts +32 -0
- package/dist/migrate.d.ts.map +1 -0
- package/dist/migrate.js +155 -0
- package/dist/migrate.js.map +1 -0
- package/dist/options.d.ts +5 -1
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +23 -4
- package/dist/options.js.map +1 -1
- package/dist/setup.d.ts +14 -10
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +25 -92
- package/dist/setup.js.map +1 -1
- package/dist/timeline.d.ts.map +1 -1
- package/dist/timeline.js +11 -0
- package/dist/timeline.js.map +1 -1
- package/dist/web/command.d.ts +5 -1
- package/dist/web/command.d.ts.map +1 -1
- package/dist/web/command.js +22 -6
- package/dist/web/command.js.map +1 -1
- package/dist/web/credentials.d.ts +7 -5
- package/dist/web/credentials.d.ts.map +1 -1
- package/dist/web/credentials.js +13 -48
- package/dist/web/credentials.js.map +1 -1
- package/dist/web/doctor.d.ts +1 -1
- package/dist/web/doctor.d.ts.map +1 -1
- package/dist/web/doctor.js +42 -64
- package/dist/web/doctor.js.map +1 -1
- package/dist/web/options.d.ts +26 -2
- package/dist/web/options.d.ts.map +1 -1
- package/dist/web/options.js +54 -18
- package/dist/web/options.js.map +1 -1
- package/dist/web/paths.d.ts +1 -1
- package/dist/web/paths.d.ts.map +1 -1
- package/dist/web/paths.js +2 -2
- package/dist/web/paths.js.map +1 -1
- package/dist/web/web.d.ts +38 -16
- package/dist/web/web.d.ts.map +1 -1
- package/dist/web/web.js +166 -168
- package/dist/web/web.js.map +1 -1
- package/package.json +4 -3
- package/web/brand/lib/client.js +4 -4
- package/web/patches/gbh-ui.patch.yml +6 -24
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading a conversation back from the harness log.
|
|
3
|
+
*
|
|
4
|
+
* Opening a session in the sidebar must show what that conversation already
|
|
5
|
+
* said. The follow stream's opening snapshot is message-aligned durable events,
|
|
6
|
+
* so folding it needs no second protocol: `user/message` starts a human turn,
|
|
7
|
+
* `assistant/message` adds prose or reasoning, and tool calls/results join the
|
|
8
|
+
* same assistant message the live path builds. Injected context (runtime
|
|
9
|
+
* snapshots, time, session titles) is user-role bookkeeping with a non-user
|
|
10
|
+
* source and never reaches the transcript.
|
|
11
|
+
*
|
|
12
|
+
* Two rows are folded from data rather than prose:
|
|
13
|
+
*
|
|
14
|
+
* - a tool call is labelled by `toolTitle`, exactly as the live path labels it,
|
|
15
|
+
* so an old session reads "Chạy lệnh Bash" and never the raw `bash`; its
|
|
16
|
+
* result goes through `cleanToolResult`, which is where the harness's
|
|
17
|
+
* `<path>`/`<content>` envelope is stripped;
|
|
18
|
+
* - `todo/write` (and a `todo_write` call's own arguments) become ONE "Tác vụ"
|
|
19
|
+
* data part that always holds the newest list, so reopening a long session
|
|
20
|
+
* shows the plan as it last stood instead of one block per update.
|
|
21
|
+
*/
|
|
22
|
+
import type { ThreadAssistantMessagePart } from "@assistant-ui/react-ink";
|
|
23
|
+
import type { FollowRecord, HarnessClient } from "./client.js";
|
|
24
|
+
/** One rendered conversation row; the shape `transcriptRows` consumes. */
|
|
25
|
+
export interface TranscriptMessage {
|
|
26
|
+
readonly role: "user" | "assistant";
|
|
27
|
+
content: ThreadAssistantMessagePart[];
|
|
28
|
+
}
|
|
29
|
+
/** A folded history page. */
|
|
30
|
+
export interface LoadedHistory {
|
|
31
|
+
readonly messages: readonly TranscriptMessage[];
|
|
32
|
+
readonly cursor?: number;
|
|
33
|
+
readonly hasMore: boolean;
|
|
34
|
+
}
|
|
35
|
+
/** One task of the "Tác vụ" block the transcript draws. */
|
|
36
|
+
export interface TodoItem {
|
|
37
|
+
/** What has to be done, as the model wrote it. */
|
|
38
|
+
readonly content: string;
|
|
39
|
+
/** Where the task stands; the block prints ✓ when it is done and ○ while it is not. */
|
|
40
|
+
readonly status: "pending" | "in_progress" | "completed";
|
|
41
|
+
/** Present-continuous wording the tool sent, for a row that is running. */
|
|
42
|
+
readonly activeForm?: string;
|
|
43
|
+
}
|
|
44
|
+
/** What one "Tác vụ" block carries. */
|
|
45
|
+
export interface TodoState {
|
|
46
|
+
/** The newest list, in the order the model wrote it. */
|
|
47
|
+
readonly todos: readonly TodoItem[];
|
|
48
|
+
}
|
|
49
|
+
/** The data-part name the transcript renderer keys the task block on. */
|
|
50
|
+
export declare const TODO_PART = "galaxy-todos";
|
|
51
|
+
/**
|
|
52
|
+
* Parse a task list out of a `todo/write` payload or a `todo_write` call's arguments.
|
|
53
|
+
* @param value - the `todos` array the host event or the tool call carries.
|
|
54
|
+
* @returns the tasks, or undefined when the value is not a list at all.
|
|
55
|
+
*/
|
|
56
|
+
export declare function todoItems(value: unknown): readonly TodoItem[] | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* The glyph a task row starts with.
|
|
59
|
+
* @param status - where the task stands.
|
|
60
|
+
* @returns ✓ when it is done, ○ while it is not.
|
|
61
|
+
*/
|
|
62
|
+
export declare function todoGlyph(status: TodoItem["status"]): string;
|
|
63
|
+
/**
|
|
64
|
+
* The block's count, as its header prints it.
|
|
65
|
+
* @param todos - the task list.
|
|
66
|
+
* @returns how many are done, how many there are, and "2/3 đã xong".
|
|
67
|
+
*/
|
|
68
|
+
export declare function todoProgress(todos: readonly TodoItem[]): Readonly<{
|
|
69
|
+
done: number;
|
|
70
|
+
total: number;
|
|
71
|
+
label: string;
|
|
72
|
+
}>;
|
|
73
|
+
/**
|
|
74
|
+
* One data part carrying the newest task list.
|
|
75
|
+
* @param todos - the list the block draws.
|
|
76
|
+
* @returns the part a renderer keys on `galaxy-todos`.
|
|
77
|
+
*/
|
|
78
|
+
export declare function todoPart(todos: readonly TodoItem[]): {
|
|
79
|
+
readonly type: "data";
|
|
80
|
+
readonly name: string;
|
|
81
|
+
readonly data: TodoState;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Replace the "Tác vụ" block in a transcript with the newest list.
|
|
85
|
+
*
|
|
86
|
+
* The reducer path needs the same rule the snapshot path does — one block, always
|
|
87
|
+
* the latest list — so it is a pure function over rows: drop the old block from
|
|
88
|
+
* wherever it sits, then attach the new one to the assistant message being built.
|
|
89
|
+
* @param messages - the rows to rewrite; they are never mutated.
|
|
90
|
+
* @param todos - the list the block should hold; an empty list removes the block.
|
|
91
|
+
* @returns the next rows.
|
|
92
|
+
*/
|
|
93
|
+
export declare function withTodoBlock(messages: readonly TranscriptMessage[], todos: readonly TodoItem[]): readonly TranscriptMessage[];
|
|
94
|
+
/**
|
|
95
|
+
* Fold the opening snapshot into renderable messages.
|
|
96
|
+
* @param records - durable events the follow snapshot carried, in sequence order.
|
|
97
|
+
* @returns one user message per human prompt and one assistant message per turn.
|
|
98
|
+
*/
|
|
99
|
+
export declare function foldHistory(records: readonly FollowRecord[]): readonly TranscriptMessage[];
|
|
100
|
+
/**
|
|
101
|
+
* Read one session's current page of history without resuming its Agent.
|
|
102
|
+
* @param client - the authenticated harness connection.
|
|
103
|
+
* @param sessionId - the conversation to read.
|
|
104
|
+
* @param signal - caller cancellation; the stream is closed after its snapshot.
|
|
105
|
+
* @returns the folded page, newest watermark and whether older history remains.
|
|
106
|
+
*/
|
|
107
|
+
export declare function loadHistory(client: HarnessClient, sessionId: string, signal: AbortSignal): Promise<LoadedHistory>;
|
|
108
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/harness/history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAI/D,0EAA0E;AAC1E,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IACpC,OAAO,EAAE,0BAA0B,EAAE,CAAC;CACvC;AAED,6BAA6B;AAC7B,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAChD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED,2DAA2D;AAC3D,MAAM,WAAW,QAAQ;IACvB,kDAAkD;IAClD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,uFAAuF;IACvF,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,aAAa,GAAG,WAAW,CAAC;IACzD,2EAA2E;IAC3E,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,uCAAuC;AACvC,MAAM,WAAW,SAAS;IACxB,wDAAwD;IACxD,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;CACrC;AAED,yEAAyE;AACzE,eAAO,MAAM,SAAS,iBAAiB,CAAC;AA+DxC;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,QAAQ,EAAE,GAAG,SAAS,CAezE;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,MAAM,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAGjH;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CAE/H;AAOD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,SAAS,iBAAiB,EAAE,EAAE,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,SAAS,iBAAiB,EAAE,CAU9H;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,iBAAiB,EAAE,CAsF1F;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CAkBvH"}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { cleanToolResult, toolTitle } from "./labels.js";
|
|
2
|
+
/** The data-part name the transcript renderer keys the task block on. */
|
|
3
|
+
export const TODO_PART = "galaxy-todos";
|
|
4
|
+
const TODO_STATUSES = ["pending", "in_progress", "completed"];
|
|
5
|
+
function record(value) {
|
|
6
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : undefined;
|
|
7
|
+
}
|
|
8
|
+
function text(value) {
|
|
9
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
10
|
+
}
|
|
11
|
+
function number(value) {
|
|
12
|
+
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
13
|
+
}
|
|
14
|
+
/** Visible text blocks of one message. */
|
|
15
|
+
function messageText(value) {
|
|
16
|
+
const content = record(value)?.["content"];
|
|
17
|
+
if (!Array.isArray(content))
|
|
18
|
+
return typeof content === "string" ? content : "";
|
|
19
|
+
return content.map(part => {
|
|
20
|
+
const block = record(part);
|
|
21
|
+
return block?.["type"] === "text" ? text(block["text"]) ?? "" : "";
|
|
22
|
+
}).join("");
|
|
23
|
+
}
|
|
24
|
+
/** Reasoning blocks of one assistant message. */
|
|
25
|
+
function messageReasoning(value) {
|
|
26
|
+
const content = record(value)?.["content"];
|
|
27
|
+
if (!Array.isArray(content))
|
|
28
|
+
return "";
|
|
29
|
+
return content.map(part => {
|
|
30
|
+
const block = record(part);
|
|
31
|
+
return block?.["type"] === "reasoning" ? text(block["text"]) ?? "" : "";
|
|
32
|
+
}).join("");
|
|
33
|
+
}
|
|
34
|
+
/** Tool arguments arrive as a JSON string and are parsed for the row's label. */
|
|
35
|
+
function toolArguments(value) {
|
|
36
|
+
if (typeof value === "string") {
|
|
37
|
+
try {
|
|
38
|
+
const parsed = JSON.parse(value);
|
|
39
|
+
return record(parsed) ?? { raw: value };
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return { raw: value };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return record(value) ?? {};
|
|
46
|
+
}
|
|
47
|
+
/** The human prompts worth drawing: every injected surface has a non-user source kind. */
|
|
48
|
+
function humanPrompt(value) {
|
|
49
|
+
const message = record(value);
|
|
50
|
+
const kind = text(record(message?.["source"])?.["kind"]);
|
|
51
|
+
if (kind !== "user")
|
|
52
|
+
return undefined;
|
|
53
|
+
const body = messageText(message);
|
|
54
|
+
return body.trim().length === 0 ? undefined : body;
|
|
55
|
+
}
|
|
56
|
+
/** One recorded status, or `pending` for anything the host did not name. */
|
|
57
|
+
function todoStatus(value) {
|
|
58
|
+
return TODO_STATUSES.find(status => status === value) ?? "pending";
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Parse a task list out of a `todo/write` payload or a `todo_write` call's arguments.
|
|
62
|
+
* @param value - the `todos` array the host event or the tool call carries.
|
|
63
|
+
* @returns the tasks, or undefined when the value is not a list at all.
|
|
64
|
+
*/
|
|
65
|
+
export function todoItems(value) {
|
|
66
|
+
if (!Array.isArray(value))
|
|
67
|
+
return undefined;
|
|
68
|
+
const todos = [];
|
|
69
|
+
for (const item of value) {
|
|
70
|
+
const row = record(item);
|
|
71
|
+
const content = text(row?.["content"]);
|
|
72
|
+
if (content === undefined)
|
|
73
|
+
continue;
|
|
74
|
+
const activeForm = text(row?.["activeForm"]);
|
|
75
|
+
todos.push(Object.freeze({
|
|
76
|
+
content,
|
|
77
|
+
status: todoStatus(row?.["status"]),
|
|
78
|
+
...(activeForm === undefined ? {} : { activeForm }),
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
return Object.freeze(todos);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The glyph a task row starts with.
|
|
85
|
+
* @param status - where the task stands.
|
|
86
|
+
* @returns ✓ when it is done, ○ while it is not.
|
|
87
|
+
*/
|
|
88
|
+
export function todoGlyph(status) {
|
|
89
|
+
return status === "completed" ? "✓" : "○";
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The block's count, as its header prints it.
|
|
93
|
+
* @param todos - the task list.
|
|
94
|
+
* @returns how many are done, how many there are, and "2/3 đã xong".
|
|
95
|
+
*/
|
|
96
|
+
export function todoProgress(todos) {
|
|
97
|
+
const done = todos.filter(todo => todo.status === "completed").length;
|
|
98
|
+
return Object.freeze({ done, total: todos.length, label: String(done) + "/" + String(todos.length) + " đã xong" });
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* One data part carrying the newest task list.
|
|
102
|
+
* @param todos - the list the block draws.
|
|
103
|
+
* @returns the part a renderer keys on `galaxy-todos`.
|
|
104
|
+
*/
|
|
105
|
+
export function todoPart(todos) {
|
|
106
|
+
return { type: "data", name: TODO_PART, data: Object.freeze({ todos }) };
|
|
107
|
+
}
|
|
108
|
+
/** True for the one part that holds a task list. */
|
|
109
|
+
function isTodoPart(part) {
|
|
110
|
+
return part.type === "data" && part.name === TODO_PART;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Replace the "Tác vụ" block in a transcript with the newest list.
|
|
114
|
+
*
|
|
115
|
+
* The reducer path needs the same rule the snapshot path does — one block, always
|
|
116
|
+
* the latest list — so it is a pure function over rows: drop the old block from
|
|
117
|
+
* wherever it sits, then attach the new one to the assistant message being built.
|
|
118
|
+
* @param messages - the rows to rewrite; they are never mutated.
|
|
119
|
+
* @param todos - the list the block should hold; an empty list removes the block.
|
|
120
|
+
* @returns the next rows.
|
|
121
|
+
*/
|
|
122
|
+
export function withTodoBlock(messages, todos) {
|
|
123
|
+
const cleaned = messages.map(message => {
|
|
124
|
+
const content = message.content.filter(part => !isTodoPart(part));
|
|
125
|
+
return content.length === message.content.length ? message : { role: message.role, content };
|
|
126
|
+
});
|
|
127
|
+
if (todos.length === 0)
|
|
128
|
+
return cleaned;
|
|
129
|
+
const last = cleaned.at(-1);
|
|
130
|
+
const body = [...(last !== undefined && last.role === "assistant" ? last.content : []), todoPart(todos)];
|
|
131
|
+
const block = { role: "assistant", content: body };
|
|
132
|
+
return last !== undefined && last.role === "assistant" ? [...cleaned.slice(0, -1), block] : [...cleaned, block];
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Fold the opening snapshot into renderable messages.
|
|
136
|
+
* @param records - durable events the follow snapshot carried, in sequence order.
|
|
137
|
+
* @returns one user message per human prompt and one assistant message per turn.
|
|
138
|
+
*/
|
|
139
|
+
export function foldHistory(records) {
|
|
140
|
+
const messages = [];
|
|
141
|
+
let assistant;
|
|
142
|
+
const assistantMessage = () => {
|
|
143
|
+
if (assistant === undefined) {
|
|
144
|
+
assistant = { role: "assistant", content: [] };
|
|
145
|
+
messages.push(assistant);
|
|
146
|
+
}
|
|
147
|
+
return assistant;
|
|
148
|
+
};
|
|
149
|
+
const append = (type, body) => {
|
|
150
|
+
if (body.length === 0)
|
|
151
|
+
return;
|
|
152
|
+
const message = assistantMessage();
|
|
153
|
+
const previous = message.content.at(-1);
|
|
154
|
+
if (previous?.type === type)
|
|
155
|
+
message.content[message.content.length - 1] = { ...previous, text: previous.text + body };
|
|
156
|
+
else
|
|
157
|
+
message.content.push({ type, text: body });
|
|
158
|
+
};
|
|
159
|
+
// One task block, holding the newest list: every update replaces the previous block rather than
|
|
160
|
+
// stacking another one, so a reopened session reads like the panel the desktop app shows.
|
|
161
|
+
const placeTodos = (todos) => {
|
|
162
|
+
const next = withTodoBlock(messages, todos);
|
|
163
|
+
messages.splice(0, messages.length, ...next);
|
|
164
|
+
// The block may have replaced the message that was being appended to; follow the new last row
|
|
165
|
+
// so prose written after a task update lands under the block instead of in a detached object.
|
|
166
|
+
const last = messages.at(-1);
|
|
167
|
+
assistant = last?.role === "assistant" ? last : undefined;
|
|
168
|
+
};
|
|
169
|
+
for (const item of records) {
|
|
170
|
+
const event = item.event;
|
|
171
|
+
const data = record(event.data);
|
|
172
|
+
if (event.type === "turn/start") {
|
|
173
|
+
assistant = undefined;
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
if (event.type === "user/message") {
|
|
177
|
+
const prompt = humanPrompt(data);
|
|
178
|
+
if (prompt !== undefined)
|
|
179
|
+
messages.push({ role: "user", content: [{ type: "text", text: prompt }] });
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
if (event.type === "assistant/message") {
|
|
183
|
+
const message = record(data?.["message"]);
|
|
184
|
+
if (message === undefined)
|
|
185
|
+
continue;
|
|
186
|
+
append("reasoning", messageReasoning(message));
|
|
187
|
+
append("text", messageText(message));
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (event.type === "todo/write") {
|
|
191
|
+
const todos = todoItems(data?.["todos"]);
|
|
192
|
+
if (todos !== undefined)
|
|
193
|
+
placeTodos(todos);
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
if (event.type === "tool/call") {
|
|
197
|
+
const id = text(data?.["callId"]);
|
|
198
|
+
const name = text(data?.["name"]);
|
|
199
|
+
if (id === undefined || name === undefined)
|
|
200
|
+
continue;
|
|
201
|
+
const args = toolArguments(data?.["arguments"]);
|
|
202
|
+
// The label is the same Vietnamese one the live path prints, so an opened conversation
|
|
203
|
+
// never shows the wire name ("bash") the model called.
|
|
204
|
+
const tool = { id, label: toolTitle(name, args), status: "running", summary: "", details: JSON.stringify({ arguments: args }) };
|
|
205
|
+
assistantMessage().content.push({ type: "data", name: "galaxy-tool", data: tool });
|
|
206
|
+
// A planning tool carries the whole list in its own arguments; folding it here too means a
|
|
207
|
+
// session recorded before the `todo/write` event existed still shows its plan.
|
|
208
|
+
const planned = todoItems(args["todos"]);
|
|
209
|
+
if (planned !== undefined)
|
|
210
|
+
placeTodos(planned);
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
if (event.type === "tool/result") {
|
|
214
|
+
const message = record(data?.["message"]);
|
|
215
|
+
const id = text(message?.["toolCallId"]);
|
|
216
|
+
if (id === undefined)
|
|
217
|
+
continue;
|
|
218
|
+
for (const row of messages) {
|
|
219
|
+
const index = row.content.findIndex(part => part.type === "data" && part.name === "galaxy-tool" && part.data.id === id);
|
|
220
|
+
const part = index < 0 ? undefined : row.content[index];
|
|
221
|
+
if (part?.type !== "data")
|
|
222
|
+
continue;
|
|
223
|
+
const tool = part.data;
|
|
224
|
+
row.content[index] = {
|
|
225
|
+
...part,
|
|
226
|
+
data: {
|
|
227
|
+
...tool,
|
|
228
|
+
status: message?.["isError"] === true || data?.["error"] !== undefined ? "error" : "success",
|
|
229
|
+
summary: cleanToolResult(messageText(message)).slice(0, 800),
|
|
230
|
+
},
|
|
231
|
+
};
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (event.type === "turn/end")
|
|
236
|
+
assistant = undefined;
|
|
237
|
+
}
|
|
238
|
+
return messages;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Read one session's current page of history without resuming its Agent.
|
|
242
|
+
* @param client - the authenticated harness connection.
|
|
243
|
+
* @param sessionId - the conversation to read.
|
|
244
|
+
* @param signal - caller cancellation; the stream is closed after its snapshot.
|
|
245
|
+
* @returns the folded page, newest watermark and whether older history remains.
|
|
246
|
+
*/
|
|
247
|
+
export async function loadHistory(client, sessionId, signal) {
|
|
248
|
+
const controller = new AbortController();
|
|
249
|
+
const combined = AbortSignal.any([signal, controller.signal]);
|
|
250
|
+
try {
|
|
251
|
+
for await (const frame of client.stream("session/follow", { request: { address: { kind: "session", sessionId } } }, combined)) {
|
|
252
|
+
if (frame.type !== "snapshot")
|
|
253
|
+
continue;
|
|
254
|
+
const cursor = number(frame.cursor);
|
|
255
|
+
const more = frame.hasMore === true;
|
|
256
|
+
return Object.freeze({
|
|
257
|
+
messages: Object.freeze(foldHistory(frame.records ?? [])),
|
|
258
|
+
...(cursor === undefined ? {} : { cursor }),
|
|
259
|
+
hasMore: more,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
return Object.freeze({ messages: Object.freeze([]), hasMore: false });
|
|
263
|
+
}
|
|
264
|
+
finally {
|
|
265
|
+
controller.abort();
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/harness/history.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;A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,CAAC,CAAC;YACpC,MAAM,IAAI,GAAI,KAAwC,CAAC,OAAO,KAAK,IAAI,CAAC;YACxE,OAAO,MAAM,CAAC,MAAM,CAAC;gBACnB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;gBACzD,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;gBAC3C,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;QACL,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IACxE,CAAC;YAAS,CAAC;QACT,UAAU,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Vietnamese surface of the `blackhole chat` terminal.
|
|
3
|
+
*
|
|
4
|
+
* The desktop app owns the wording. Every string here is copied from its locale
|
|
5
|
+
* table (`blackhole-tauri/tools/locale/gbh-locale-vi.json`) so the terminal and
|
|
6
|
+
* the window name the same things the same way: "Phiên mới", "Hội thoại",
|
|
7
|
+
* "Luồng chạy", "Đang suy nghĩ…", "Toàn quyền", "Ghi trong workspace", "Chỉ đọc".
|
|
8
|
+
* Keeping the copy in one module also keeps the screen components about layout,
|
|
9
|
+
* not about language.
|
|
10
|
+
*/
|
|
11
|
+
/** The fixed words the screen uses; interpolation lives in the helpers below. */
|
|
12
|
+
export declare const UI: Readonly<{
|
|
13
|
+
readonly brand: "Galaxy Blackhole";
|
|
14
|
+
readonly preview: "Bản xem trước";
|
|
15
|
+
readonly newSession: "Phiên mới";
|
|
16
|
+
readonly conversation: "Hội thoại";
|
|
17
|
+
readonly trajectory: "Luồng chạy";
|
|
18
|
+
readonly workspace: "Không gian";
|
|
19
|
+
readonly sessions: "Phiên";
|
|
20
|
+
readonly plugins: "Plugin";
|
|
21
|
+
readonly automations: "Tác vụ tự động";
|
|
22
|
+
readonly more: "Thêm";
|
|
23
|
+
readonly untitled: "Chưa đặt tên";
|
|
24
|
+
readonly noSessions: "Chưa có phiên nào";
|
|
25
|
+
readonly emptyHero: "Bước vào vùng chưa biết";
|
|
26
|
+
readonly emptyBody: "Bắt đầu hội thoại mới với Galaxy Blackhole.";
|
|
27
|
+
readonly emptyHint: "Mô tả việc bạn muốn làm, gõ / để mở lệnh, hoặc @ để chọn tệp.";
|
|
28
|
+
readonly placeholder: "Gửi tin nhắn hoặc tạo tác vụ, / gọi lệnh, @ tệp hoặc hội thoại";
|
|
29
|
+
readonly send: "Gửi tin nhắn";
|
|
30
|
+
readonly stop: "Dừng tạo";
|
|
31
|
+
readonly attach: "Thêm tệp đính kèm";
|
|
32
|
+
readonly commandMenu: "Mở menu lệnh";
|
|
33
|
+
readonly model: "Model";
|
|
34
|
+
readonly reasoning: "Mức suy luận";
|
|
35
|
+
readonly defaultEffort: "Mặc định";
|
|
36
|
+
readonly accessMode: "Chế độ truy cập";
|
|
37
|
+
readonly accessMenu: "Chọn chế độ quyền";
|
|
38
|
+
readonly modelMenu: "Chọn model";
|
|
39
|
+
readonly effortMenu: "Mức suy luận";
|
|
40
|
+
readonly plusMenu: "Thêm";
|
|
41
|
+
readonly chooseWorkspace: "Chọn workspace";
|
|
42
|
+
readonly filePicker: "Chọn tệp";
|
|
43
|
+
readonly workspacePicker: "Chọn workspace";
|
|
44
|
+
readonly pickerHint: "↑/↓ · Enter · Esc";
|
|
45
|
+
readonly noFiles: "Không có tệp khớp";
|
|
46
|
+
readonly noWorkspaces: "Không có workspace nào khác";
|
|
47
|
+
readonly effortApplied: "Mức suy luận";
|
|
48
|
+
readonly effortFailed: "Không đổi được mức suy luận";
|
|
49
|
+
readonly chipsHint: "Tab: chip";
|
|
50
|
+
readonly chipsHintFocused: "←/→ · Enter mở";
|
|
51
|
+
readonly loadingTrajectory: "Đang đọc Luồng chạy…";
|
|
52
|
+
readonly thinking: "Đang suy nghĩ…";
|
|
53
|
+
readonly thinkingDone: "Đã suy nghĩ";
|
|
54
|
+
readonly reasoningCollapsed: "Suy nghĩ · đã thu gọn";
|
|
55
|
+
readonly reasoningExpanded: "Suy nghĩ";
|
|
56
|
+
readonly running: "Đang chạy";
|
|
57
|
+
readonly idle: "Rảnh";
|
|
58
|
+
readonly ready: "Sẵn sàng";
|
|
59
|
+
readonly completed: "Hoàn thành";
|
|
60
|
+
readonly stopped: "Đã dừng";
|
|
61
|
+
readonly failed: "Thất bại";
|
|
62
|
+
readonly error: "Có lỗi";
|
|
63
|
+
readonly working: "Đã làm việc";
|
|
64
|
+
readonly took: "Xong sau ";
|
|
65
|
+
readonly steps: "bước";
|
|
66
|
+
readonly tokens: "token";
|
|
67
|
+
readonly stepCalls: "lệnh gọi công cụ";
|
|
68
|
+
readonly connected: "Đã kết nối harness";
|
|
69
|
+
readonly connecting: "Đang kết nối…";
|
|
70
|
+
readonly disconnected: "Mất kết nối";
|
|
71
|
+
readonly harness: "Harness";
|
|
72
|
+
readonly waitingApproval: "Chờ phê duyệt";
|
|
73
|
+
readonly planReview: "Kế hoạch chờ duyệt";
|
|
74
|
+
readonly you: "Bạn";
|
|
75
|
+
readonly assistant: "Trợ lý";
|
|
76
|
+
readonly turn: "Lượt";
|
|
77
|
+
readonly help: "Trợ giúp";
|
|
78
|
+
readonly sessionInfo: "Thông tin phiên";
|
|
79
|
+
readonly close: "Đóng";
|
|
80
|
+
readonly menuHint: "↑/↓ chọn · Enter áp dụng · Esc đóng";
|
|
81
|
+
readonly helpHint: "esc đóng";
|
|
82
|
+
readonly showThinking: "hiện suy nghĩ";
|
|
83
|
+
readonly hideThinking: "ẩn suy nghĩ";
|
|
84
|
+
readonly showTools: "chi tiết công cụ";
|
|
85
|
+
readonly hideTools: "ẩn chi tiết công cụ";
|
|
86
|
+
readonly noMatches: "Không có kết quả";
|
|
87
|
+
readonly loadingSessions: "Đang tải phiên…";
|
|
88
|
+
readonly loadingHistory: "Đang mở phiên…";
|
|
89
|
+
readonly historyFailed: "Không mở được phiên";
|
|
90
|
+
readonly trajectoryFailed: "Không đọc được luồng chạy";
|
|
91
|
+
readonly events: "sự kiện";
|
|
92
|
+
readonly sessionsFailed: "Không tải được danh sách phiên";
|
|
93
|
+
readonly catalogFailed: "Không tải được danh sách model";
|
|
94
|
+
readonly accessFailed: "Không đổi được chế độ quyền";
|
|
95
|
+
readonly modelFailed: "Không chọn được model";
|
|
96
|
+
readonly permissionApplied: "Chế độ quyền";
|
|
97
|
+
readonly modelApplied: "Model";
|
|
98
|
+
readonly noModel: "Theo cấu hình";
|
|
99
|
+
readonly noMessages: "Chưa có tin nhắn";
|
|
100
|
+
readonly scrollHint: "PgUp/PgDn cuộn lịch sử";
|
|
101
|
+
readonly sidebarHint: "↑/↓ chọn phiên · Enter mở · Tab về ô soạn";
|
|
102
|
+
readonly composerHint: "Enter gửi · Esc dừng lượt · Tab chọn phiên · Ctrl+C thoát";
|
|
103
|
+
readonly expandedHint: "Ctrl+L ẩn/hiện suy nghĩ · Ctrl+O chi tiết công cụ";
|
|
104
|
+
}>;
|
|
105
|
+
/** One selectable access preset, worded the way the composer chip words it. */
|
|
106
|
+
export interface AccessPreset {
|
|
107
|
+
/** Wire value the harness projects and the /permission command accepts. */
|
|
108
|
+
readonly value: string;
|
|
109
|
+
readonly label: string;
|
|
110
|
+
readonly description: string;
|
|
111
|
+
}
|
|
112
|
+
/** The three named presets the app ships; `auto` is appended when the host offers it. */
|
|
113
|
+
export declare const ACCESS_PRESETS: readonly AccessPreset[];
|
|
114
|
+
/**
|
|
115
|
+
* The access presets to offer for a host catalog.
|
|
116
|
+
* @param values - values the host advertises, in contribution order.
|
|
117
|
+
* @returns the named presets plus `auto` when the host offers it.
|
|
118
|
+
*/
|
|
119
|
+
export declare function accessPresets(values: readonly string[] | undefined): readonly AccessPreset[];
|
|
120
|
+
/**
|
|
121
|
+
* The Vietnamese label of one access value.
|
|
122
|
+
* @param value - preset key or `custom`.
|
|
123
|
+
* @returns the label the chip shows.
|
|
124
|
+
*/
|
|
125
|
+
export declare function accessLabel(value: string | undefined): string;
|
|
126
|
+
/**
|
|
127
|
+
* A tool call as one Vietnamese row: "Đọc · src/app.ts".
|
|
128
|
+
* @param name - the tool identifier the harness reported.
|
|
129
|
+
* @param args - its parsed arguments, when they parsed.
|
|
130
|
+
* @returns a one-line label safe for the transcript.
|
|
131
|
+
*/
|
|
132
|
+
export declare function toolTitle(name: string, args?: Readonly<Record<string, unknown>>): string;
|
|
133
|
+
/**
|
|
134
|
+
* Strip the harness's result envelope from a tool result before it reaches a row.
|
|
135
|
+
* A `read` answers with `<path>`, `<type>` and `<content>` blocks; the path is
|
|
136
|
+
* already the row's label, and the tags are transport, not prose.
|
|
137
|
+
* @param summary - the text the harness returned for the call.
|
|
138
|
+
*/
|
|
139
|
+
export declare function cleanToolResult(summary: string): string;
|
|
140
|
+
/** Whole tokens as the app writes them: 942, 1,2k, 3,4M. */
|
|
141
|
+
export declare function formatTokens(count: number): string;
|
|
142
|
+
/**
|
|
143
|
+
* A wall time as the turn footer writes it: 320ms, 4,2s, 2m 05s.
|
|
144
|
+
* @param milliseconds - elapsed time.
|
|
145
|
+
*/
|
|
146
|
+
export declare function formatDuration(milliseconds: number): string;
|
|
147
|
+
/**
|
|
148
|
+
* When a session last moved, in the sidebar's own words ("4 giờ trước").
|
|
149
|
+
* @param updatedAt - epoch milliseconds from the harness.
|
|
150
|
+
* @param now - the reading clock.
|
|
151
|
+
*/
|
|
152
|
+
export declare function formatAgo(updatedAt: number | undefined, now?: number): string;
|
|
153
|
+
/**
|
|
154
|
+
* A workspace's sidebar name: its folder, never a full path.
|
|
155
|
+
* @param cwd - absolute directory the harness session owns.
|
|
156
|
+
* @param home - the user's home directory, when known.
|
|
157
|
+
*/
|
|
158
|
+
export declare function workspaceName(cwd: string, home?: string): string;
|
|
159
|
+
/**
|
|
160
|
+
* A session row title, bounded to what a sidebar row can show.
|
|
161
|
+
* @param title - the harness's normalized title, or null before the first one lands.
|
|
162
|
+
*/
|
|
163
|
+
export declare function sessionTitle(title: string | null | undefined): string;
|
|
164
|
+
//# sourceMappingURL=labels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"labels.d.ts","sourceRoot":"","sources":["../../src/harness/labels.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,iFAAiF;AACjF,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4FJ,CAAC;AAEZ,+EAA+E;AAC/E,MAAM,WAAW,YAAY;IAC3B,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,yFAAyF;AACzF,eAAO,MAAM,cAAc,EAAE,SAAS,YAAY,EAIhD,CAAC;AAKH;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GAAG,SAAS,YAAY,EAAE,CAK5F;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAG7D;AA8CD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM,GAAG,MAAM,CAI5F;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMvD;AAED,4DAA4D;AAC5D,wBAAgB,YAAY,CAAC,KAAK,EAAE,M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