@relace-ai/jacq 0.1.1-beta.1 → 0.1.1
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/actions/messages.d.ts +41 -0
- package/dist/actions/messages.js +77 -0
- package/dist/actions/messages.js.map +1 -0
- package/dist/actions/prompts.d.ts +6 -0
- package/dist/actions/prompts.js +18 -0
- package/dist/actions/prompts.js.map +1 -0
- package/dist/actions/tasks.d.ts +13 -0
- package/dist/actions/tasks.js +66 -0
- package/dist/actions/tasks.js.map +1 -0
- package/dist/auth.d.ts +12 -0
- package/dist/auth.js +131 -0
- package/dist/auth.js.map +1 -0
- package/dist/clipboard.d.ts +21 -0
- package/dist/clipboard.js +126 -0
- package/dist/clipboard.js.map +1 -0
- package/dist/commands.d.ts +15 -0
- package/dist/commands.js +23 -0
- package/dist/commands.js.map +1 -0
- package/dist/config.d.ts +12 -0
- package/dist/config.js +63 -0
- package/dist/config.js.map +1 -0
- package/dist/connection.d.ts +43 -0
- package/dist/connection.js +231 -0
- package/dist/connection.js.map +1 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +3 -0
- package/dist/constants.js.map +1 -0
- package/dist/debug.d.ts +96 -0
- package/dist/debug.js +144 -0
- package/dist/debug.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +390 -0
- package/dist/index.js.map +1 -0
- package/dist/markdown/index.d.ts +11 -0
- package/dist/markdown/index.js +12 -0
- package/dist/markdown/index.js.map +1 -0
- package/dist/markdown/parser.d.ts +22 -0
- package/dist/markdown/parser.js +310 -0
- package/dist/markdown/parser.js.map +1 -0
- package/dist/markdown/renderer.d.ts +23 -0
- package/dist/markdown/renderer.js +358 -0
- package/dist/markdown/renderer.js.map +1 -0
- package/dist/markdown/types.d.ts +74 -0
- package/dist/markdown/types.js +12 -0
- package/dist/markdown/types.js.map +1 -0
- package/dist/protocol.d.ts +46 -0
- package/dist/protocol.js +608 -0
- package/dist/protocol.js.map +1 -0
- package/dist/renderer.d.ts +46 -0
- package/dist/renderer.js +144 -0
- package/dist/renderer.js.map +1 -0
- package/dist/screen.d.ts +34 -0
- package/dist/screen.js +167 -0
- package/dist/screen.js.map +1 -0
- package/dist/state.d.ts +6 -0
- package/dist/state.js +77 -0
- package/dist/state.js.map +1 -0
- package/dist/styles.d.ts +16 -0
- package/dist/styles.js +68 -0
- package/dist/styles.js.map +1 -0
- package/dist/terminal.d.ts +46 -0
- package/dist/terminal.js +67 -0
- package/dist/terminal.js.map +1 -0
- package/dist/tools/executor.d.ts +8 -0
- package/dist/tools/executor.js +20 -0
- package/dist/tools/executor.js.map +1 -0
- package/dist/tools/index.d.ts +5 -0
- package/dist/tools/index.js +6 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/registry.d.ts +32 -0
- package/dist/tools/registry.js +344 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/types.d.ts +200 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/backgroundTasks.d.ts +7 -0
- package/dist/ui/backgroundTasks.js +192 -0
- package/dist/ui/backgroundTasks.js.map +1 -0
- package/dist/ui/filePicker.d.ts +9 -0
- package/dist/ui/filePicker.js +315 -0
- package/dist/ui/filePicker.js.map +1 -0
- package/dist/ui/index.d.ts +33 -0
- package/dist/ui/index.js +289 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/input.d.ts +7 -0
- package/dist/ui/input.js +320 -0
- package/dist/ui/input.js.map +1 -0
- package/dist/ui/messages.d.ts +9 -0
- package/dist/ui/messages.js +329 -0
- package/dist/ui/messages.js.map +1 -0
- package/dist/ui/primitives.d.ts +35 -0
- package/dist/ui/primitives.js +94 -0
- package/dist/ui/primitives.js.map +1 -0
- package/dist/ui/promptInput.d.ts +8 -0
- package/dist/ui/promptInput.js +198 -0
- package/dist/ui/promptInput.js.map +1 -0
- package/dist/ui/promptPicker.d.ts +7 -0
- package/dist/ui/promptPicker.js +214 -0
- package/dist/ui/promptPicker.js.map +1 -0
- package/dist/ui/sessions.d.ts +6 -0
- package/dist/ui/sessions.js +214 -0
- package/dist/ui/sessions.js.map +1 -0
- package/dist/ui/welcome.d.ts +6 -0
- package/dist/ui/welcome.js +114 -0
- package/dist/ui/welcome.js.map +1 -0
- package/package.json +1 -1
package/dist/renderer.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renderer - Double-buffered full-screen renderer
|
|
3
|
+
*
|
|
4
|
+
* The render loop:
|
|
5
|
+
* 1. App draws to Screen (front buffer)
|
|
6
|
+
* 2. Diff against previous Screen (back buffer)
|
|
7
|
+
* 3. Generate minimal cursor movements + character writes
|
|
8
|
+
* 4. Write to terminal wrapped in SYNC
|
|
9
|
+
* 5. Swap buffers
|
|
10
|
+
*/
|
|
11
|
+
import { Screen, diffScreens } from './screen.js';
|
|
12
|
+
import { StylePool, RESET } from './styles.js';
|
|
13
|
+
import * as term from './terminal.js';
|
|
14
|
+
export class Renderer {
|
|
15
|
+
stdout;
|
|
16
|
+
width;
|
|
17
|
+
height;
|
|
18
|
+
front;
|
|
19
|
+
back;
|
|
20
|
+
stylePool;
|
|
21
|
+
cursorX;
|
|
22
|
+
cursorY;
|
|
23
|
+
stats;
|
|
24
|
+
constructor(stdout) {
|
|
25
|
+
this.stdout = stdout;
|
|
26
|
+
this.width = stdout.columns || 80;
|
|
27
|
+
this.height = stdout.rows || 24;
|
|
28
|
+
this.front = new Screen(this.width, this.height);
|
|
29
|
+
this.back = null;
|
|
30
|
+
this.stylePool = new StylePool();
|
|
31
|
+
this.cursorX = 0;
|
|
32
|
+
this.cursorY = 0;
|
|
33
|
+
this.stats = { frames: 0, cellsChanged: 0, bytesWritten: 0 };
|
|
34
|
+
}
|
|
35
|
+
getScreen() {
|
|
36
|
+
return this.front;
|
|
37
|
+
}
|
|
38
|
+
getStylePool() {
|
|
39
|
+
return this.stylePool;
|
|
40
|
+
}
|
|
41
|
+
render() {
|
|
42
|
+
const startTime = performance.now();
|
|
43
|
+
const changes = diffScreens(this.back, this.front);
|
|
44
|
+
let output = term.syncStart;
|
|
45
|
+
let currentStyleId = 0;
|
|
46
|
+
let currentLink = '';
|
|
47
|
+
changes.sort((a, b) => {
|
|
48
|
+
if (a.y !== b.y)
|
|
49
|
+
return a.y - b.y;
|
|
50
|
+
return a.x - b.x;
|
|
51
|
+
});
|
|
52
|
+
for (const change of changes) {
|
|
53
|
+
if (this.cursorX !== change.x || this.cursorY !== change.y) {
|
|
54
|
+
// Close link before cursor jump (terminal link state doesn't survive moves)
|
|
55
|
+
if (currentLink) {
|
|
56
|
+
output += term.linkEnd;
|
|
57
|
+
currentLink = '';
|
|
58
|
+
}
|
|
59
|
+
const dx = Math.abs(change.x - this.cursorX);
|
|
60
|
+
const dy = Math.abs(change.y - this.cursorY);
|
|
61
|
+
if (dx + dy > 6) {
|
|
62
|
+
output += term.cursorToAbs(change.x, change.y);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
output += term.moveCursor(this.cursorX, this.cursorY, change.x, change.y);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (change.styleId !== currentStyleId) {
|
|
69
|
+
if (currentStyleId !== 0) {
|
|
70
|
+
output += RESET;
|
|
71
|
+
}
|
|
72
|
+
if (change.styleId !== 0) {
|
|
73
|
+
output += this.stylePool.toAnsi(change.styleId);
|
|
74
|
+
}
|
|
75
|
+
currentStyleId = change.styleId;
|
|
76
|
+
}
|
|
77
|
+
const changeLink = change.linkUrl || '';
|
|
78
|
+
if (changeLink !== currentLink) {
|
|
79
|
+
if (currentLink) {
|
|
80
|
+
output += term.linkEnd;
|
|
81
|
+
}
|
|
82
|
+
if (changeLink) {
|
|
83
|
+
output += term.linkStart(changeLink);
|
|
84
|
+
}
|
|
85
|
+
currentLink = changeLink;
|
|
86
|
+
}
|
|
87
|
+
output += change.char;
|
|
88
|
+
this.cursorX = change.x + 1;
|
|
89
|
+
this.cursorY = change.y;
|
|
90
|
+
}
|
|
91
|
+
if (currentLink) {
|
|
92
|
+
output += term.linkEnd;
|
|
93
|
+
}
|
|
94
|
+
if (currentStyleId !== 0) {
|
|
95
|
+
output += RESET;
|
|
96
|
+
}
|
|
97
|
+
output += term.syncEnd;
|
|
98
|
+
if (changes.length > 0) {
|
|
99
|
+
this.stdout.write(output);
|
|
100
|
+
}
|
|
101
|
+
if (!this.back) {
|
|
102
|
+
this.back = new Screen(this.width, this.height);
|
|
103
|
+
}
|
|
104
|
+
this.back.copyFrom(this.front);
|
|
105
|
+
this.front.clearDamage();
|
|
106
|
+
this.stats.frames++;
|
|
107
|
+
this.stats.cellsChanged += changes.length;
|
|
108
|
+
this.stats.bytesWritten += output.length;
|
|
109
|
+
const elapsed = performance.now() - startTime;
|
|
110
|
+
return {
|
|
111
|
+
changes: changes.length,
|
|
112
|
+
bytes: output.length,
|
|
113
|
+
time: elapsed,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
clear() {
|
|
117
|
+
this.stdout.write(term.syncStart + term.clearScreen + term.cursorTo(0, 0) + term.syncEnd);
|
|
118
|
+
this.front.clearAll();
|
|
119
|
+
this.back = null;
|
|
120
|
+
this.cursorX = 0;
|
|
121
|
+
this.cursorY = 0;
|
|
122
|
+
}
|
|
123
|
+
setup() {
|
|
124
|
+
this.stdout.write(term.altScreenEnter);
|
|
125
|
+
this.stdout.write(term.cursorHide);
|
|
126
|
+
this.clear();
|
|
127
|
+
this.stdout.on?.('resize', () => {
|
|
128
|
+
this.width = this.stdout.columns || 80;
|
|
129
|
+
this.height = this.stdout.rows || 24;
|
|
130
|
+
this.front = new Screen(this.width, this.height);
|
|
131
|
+
this.back = null;
|
|
132
|
+
this.clear();
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
cleanup() {
|
|
136
|
+
this.stdout.write(term.cursorShow);
|
|
137
|
+
this.stdout.write(term.altScreenLeave);
|
|
138
|
+
}
|
|
139
|
+
getStats() {
|
|
140
|
+
return { ...this.stats };
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
export default Renderer;
|
|
144
|
+
//# sourceMappingURL=renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AAStC,MAAM,OAAO,QAAQ;IACjB,MAAM,CAAc;IACpB,KAAK,CAAS;IACd,MAAM,CAAS;IACf,KAAK,CAAS;IACd,IAAI,CAAgB;IACpB,SAAS,CAAY;IACrB,OAAO,CAAS;IAChB,OAAO,CAAS;IAChB,KAAK,CAAiE;IAEtE,YAAY,MAAmB;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QAChC,IAAI,CAAC,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACjD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;IACjE,CAAC;IAED,SAAS;QACL,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,YAAY;QACR,OAAO,IAAI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AM,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACnC,IAAI,CAAC,KAAK,EAAE,CAAC;QAEb,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;YAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;YACvC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;YACrC,IAAI,CAAC,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YACjD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YACjB,IAAI,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;IACP,CAAC;IAED,OAAO;QACH,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC3C,CAAC;IAED,QAAQ;QACJ,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;CACJ;AAED,eAAe,QAAQ,CAAC"}
|
package/dist/screen.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Screen - Minimal TypedArray-based cell buffer
|
|
3
|
+
*
|
|
4
|
+
* Each cell has:
|
|
5
|
+
* - char: the character to display (stored as index into string pool)
|
|
6
|
+
* - styleId: reference to StylePool (0 = no style)
|
|
7
|
+
*
|
|
8
|
+
* Uses TypedArrays for cache-friendly contiguous memory and fast comparison.
|
|
9
|
+
*/
|
|
10
|
+
import type { DamageRect, CellInfo, CellChange } from './types.js';
|
|
11
|
+
export declare class Screen {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
chars: Uint16Array;
|
|
15
|
+
styles: Uint16Array;
|
|
16
|
+
links: Uint16Array;
|
|
17
|
+
linkPool: string[];
|
|
18
|
+
linkMap: Map<string, number>;
|
|
19
|
+
charPool: string[];
|
|
20
|
+
charMap: Map<string, number>;
|
|
21
|
+
damage: DamageRect | null;
|
|
22
|
+
constructor(width: number, height: number);
|
|
23
|
+
internChar(char: string): number;
|
|
24
|
+
internLink(url: string): number;
|
|
25
|
+
get(x: number, y: number): CellInfo | null;
|
|
26
|
+
set(x: number, y: number, char: string, styleId?: number, linkUrl?: string): void;
|
|
27
|
+
clear(x: number, y: number): void;
|
|
28
|
+
clearAll(): void;
|
|
29
|
+
markDamage(x: number, y: number): void;
|
|
30
|
+
clearDamage(): void;
|
|
31
|
+
copyFrom(other: Screen): void;
|
|
32
|
+
}
|
|
33
|
+
export declare function diffScreens(prev: Screen | null, next: Screen): CellChange[];
|
|
34
|
+
export default Screen;
|
package/dist/screen.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Screen - Minimal TypedArray-based cell buffer
|
|
3
|
+
*
|
|
4
|
+
* Each cell has:
|
|
5
|
+
* - char: the character to display (stored as index into string pool)
|
|
6
|
+
* - styleId: reference to StylePool (0 = no style)
|
|
7
|
+
*
|
|
8
|
+
* Uses TypedArrays for cache-friendly contiguous memory and fast comparison.
|
|
9
|
+
*/
|
|
10
|
+
const SPACE = 0;
|
|
11
|
+
export class Screen {
|
|
12
|
+
width;
|
|
13
|
+
height;
|
|
14
|
+
chars;
|
|
15
|
+
styles;
|
|
16
|
+
links;
|
|
17
|
+
linkPool;
|
|
18
|
+
linkMap;
|
|
19
|
+
charPool;
|
|
20
|
+
charMap;
|
|
21
|
+
damage;
|
|
22
|
+
constructor(width, height) {
|
|
23
|
+
this.width = width;
|
|
24
|
+
this.height = height;
|
|
25
|
+
const size = width * height;
|
|
26
|
+
this.chars = new Uint16Array(size);
|
|
27
|
+
this.styles = new Uint16Array(size);
|
|
28
|
+
this.links = new Uint16Array(size);
|
|
29
|
+
this.charPool = [' ', '']; // 0=space, 1=empty
|
|
30
|
+
this.charMap = new Map([[' ', SPACE], ['', 1]]);
|
|
31
|
+
this.linkPool = ['']; // 0 = no link
|
|
32
|
+
this.linkMap = new Map([['', 0]]);
|
|
33
|
+
this.chars.fill(SPACE);
|
|
34
|
+
this.styles.fill(0);
|
|
35
|
+
this.links.fill(0);
|
|
36
|
+
this.damage = null;
|
|
37
|
+
}
|
|
38
|
+
internChar(char) {
|
|
39
|
+
let id = this.charMap.get(char);
|
|
40
|
+
if (id === undefined) {
|
|
41
|
+
id = this.charPool.length;
|
|
42
|
+
this.charPool.push(char);
|
|
43
|
+
this.charMap.set(char, id);
|
|
44
|
+
}
|
|
45
|
+
return id;
|
|
46
|
+
}
|
|
47
|
+
internLink(url) {
|
|
48
|
+
if (!url)
|
|
49
|
+
return 0;
|
|
50
|
+
let id = this.linkMap.get(url);
|
|
51
|
+
if (id === undefined) {
|
|
52
|
+
id = this.linkPool.length;
|
|
53
|
+
this.linkPool.push(url);
|
|
54
|
+
this.linkMap.set(url, id);
|
|
55
|
+
}
|
|
56
|
+
return id;
|
|
57
|
+
}
|
|
58
|
+
get(x, y) {
|
|
59
|
+
if (x < 0 || y < 0 || x >= this.width || y >= this.height) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const i = y * this.width + x;
|
|
63
|
+
return {
|
|
64
|
+
char: this.charPool[this.chars[i]],
|
|
65
|
+
styleId: this.styles[i]
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
set(x, y, char, styleId = 0, linkUrl) {
|
|
69
|
+
if (x < 0 || y < 0 || x >= this.width || y >= this.height) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const i = y * this.width + x;
|
|
73
|
+
const charId = this.internChar(char);
|
|
74
|
+
const linkId = linkUrl ? this.internLink(linkUrl) : 0;
|
|
75
|
+
if (this.chars[i] !== charId || this.styles[i] !== styleId || this.links[i] !== linkId) {
|
|
76
|
+
this.chars[i] = charId;
|
|
77
|
+
this.styles[i] = styleId;
|
|
78
|
+
this.links[i] = linkId;
|
|
79
|
+
this.markDamage(x, y);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
clear(x, y) {
|
|
83
|
+
this.set(x, y, ' ', 0);
|
|
84
|
+
}
|
|
85
|
+
clearAll() {
|
|
86
|
+
this.chars.fill(SPACE);
|
|
87
|
+
this.styles.fill(0);
|
|
88
|
+
this.links.fill(0);
|
|
89
|
+
this.damage = { x: 0, y: 0, w: this.width, h: this.height };
|
|
90
|
+
}
|
|
91
|
+
markDamage(x, y) {
|
|
92
|
+
if (this.damage) {
|
|
93
|
+
const x2 = Math.max(this.damage.x + this.damage.w, x + 1);
|
|
94
|
+
const y2 = Math.max(this.damage.y + this.damage.h, y + 1);
|
|
95
|
+
this.damage.x = Math.min(this.damage.x, x);
|
|
96
|
+
this.damage.y = Math.min(this.damage.y, y);
|
|
97
|
+
this.damage.w = x2 - this.damage.x;
|
|
98
|
+
this.damage.h = y2 - this.damage.y;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
this.damage = { x, y, w: 1, h: 1 };
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
clearDamage() {
|
|
105
|
+
this.damage = null;
|
|
106
|
+
}
|
|
107
|
+
copyFrom(other) {
|
|
108
|
+
if (other.width !== this.width || other.height !== this.height) {
|
|
109
|
+
throw new Error('Screen dimensions must match');
|
|
110
|
+
}
|
|
111
|
+
this.chars.set(other.chars);
|
|
112
|
+
this.styles.set(other.styles);
|
|
113
|
+
this.links.set(other.links);
|
|
114
|
+
this.charPool = [...other.charPool];
|
|
115
|
+
this.charMap = new Map(other.charMap);
|
|
116
|
+
this.linkPool = [...other.linkPool];
|
|
117
|
+
this.linkMap = new Map(other.linkMap);
|
|
118
|
+
this.damage = other.damage ? { ...other.damage } : null;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export function diffScreens(prev, next) {
|
|
122
|
+
const changes = [];
|
|
123
|
+
let region;
|
|
124
|
+
if (!prev || prev.width === 0) {
|
|
125
|
+
region = { x: 0, y: 0, w: next.width, h: next.height };
|
|
126
|
+
}
|
|
127
|
+
else if (next.damage) {
|
|
128
|
+
region = { ...next.damage };
|
|
129
|
+
if (prev.damage) {
|
|
130
|
+
const x2 = Math.max(region.x + region.w, prev.damage.x + prev.damage.w);
|
|
131
|
+
const y2 = Math.max(region.y + region.h, prev.damage.y + prev.damage.h);
|
|
132
|
+
region.x = Math.min(region.x, prev.damage.x);
|
|
133
|
+
region.y = Math.min(region.y, prev.damage.y);
|
|
134
|
+
region.w = x2 - region.x;
|
|
135
|
+
region.h = y2 - region.y;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
return changes;
|
|
140
|
+
}
|
|
141
|
+
for (let y = region.y; y < region.y + region.h && y < next.height; y++) {
|
|
142
|
+
for (let x = region.x; x < region.x + region.w && x < next.width; x++) {
|
|
143
|
+
const i = y * next.width + x;
|
|
144
|
+
const prevChar = prev ? prev.chars[i] : SPACE;
|
|
145
|
+
const prevStyle = prev ? prev.styles[i] : 0;
|
|
146
|
+
const prevLink = prev ? prev.links[i] : 0;
|
|
147
|
+
const nextChar = next.chars[i];
|
|
148
|
+
const nextStyle = next.styles[i];
|
|
149
|
+
const nextLink = next.links[i];
|
|
150
|
+
if (prevChar !== nextChar || prevStyle !== nextStyle || prevLink !== nextLink) {
|
|
151
|
+
const change = {
|
|
152
|
+
x,
|
|
153
|
+
y,
|
|
154
|
+
char: next.charPool[nextChar],
|
|
155
|
+
styleId: nextStyle
|
|
156
|
+
};
|
|
157
|
+
if (nextLink > 0) {
|
|
158
|
+
change.linkUrl = next.linkPool[nextLink];
|
|
159
|
+
}
|
|
160
|
+
changes.push(change);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return changes;
|
|
165
|
+
}
|
|
166
|
+
export default Screen;
|
|
167
|
+
//# sourceMappingURL=screen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screen.js","sourceRoot":"","sources":["../src/screen.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,MAAM,KAAK,GAAG,CAAC,CAAC;AAEhB,MAAM,OAAO,MAAM;IACf,KAAK,CAAS;IACd,MAAM,CAAS;IACf,KAAK,CAAc;IACnB,MAAM,CAAc;IACpB,KAAK,CAAc;IACnB,QAAQ,CAAW;IACnB,OAAO,CAAsB;IAC7B,QAAQ,CAAW;IACnB,OAAO,CAAsB;IAC7B,MAAM,CAAoB;IAE1B,YAAY,KAAa,EAAE,MAAc;QACrC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,MAAM,IAAI,GAAG,KAAK,GAAG,MAAM,CAAC;QAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,KAAK,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;QAEnC,IAAI,CAAC,QAAQ,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAE,mBAAmB;QAC/C,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAChD,IAAI,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC,CAAC,CAAE,cAAc;QACrC,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAElC,IAAI,CAAC,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AC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBAC7C,CAAC;gBACD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACzB,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,eAAe,MAAM,CAAC"}
|
package/dist/state.d.ts
ADDED
package/dist/state.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Application state - single source of truth
|
|
3
|
+
*/
|
|
4
|
+
import { API_WS_URL } from './constants.js';
|
|
5
|
+
export const state = {
|
|
6
|
+
// Input
|
|
7
|
+
input: '',
|
|
8
|
+
cursor: 0,
|
|
9
|
+
pastedBlocks: [],
|
|
10
|
+
nextPasteId: 1,
|
|
11
|
+
// Connection
|
|
12
|
+
connected: false,
|
|
13
|
+
serverUrl: API_WS_URL,
|
|
14
|
+
clientId: null,
|
|
15
|
+
serverStatus: null,
|
|
16
|
+
// Messages
|
|
17
|
+
messages: [],
|
|
18
|
+
streamBuffer: '',
|
|
19
|
+
// Tasks
|
|
20
|
+
tasksLoaded: false,
|
|
21
|
+
tasks: [],
|
|
22
|
+
currentTaskId: null,
|
|
23
|
+
submitting: false,
|
|
24
|
+
activityPhase: 'idle',
|
|
25
|
+
// Prompts
|
|
26
|
+
pendingPrompt: null,
|
|
27
|
+
promptPickerIndex: 0,
|
|
28
|
+
promptPickerPage: 0,
|
|
29
|
+
promptFreeInput: false,
|
|
30
|
+
promptInputText: '',
|
|
31
|
+
promptInputCursor: 0,
|
|
32
|
+
// Scrolling (full-screen model)
|
|
33
|
+
scrollOffset: 0,
|
|
34
|
+
isPinned: true,
|
|
35
|
+
// UI
|
|
36
|
+
showWelcome: true,
|
|
37
|
+
dirty: true,
|
|
38
|
+
forceFullRedraw: false,
|
|
39
|
+
statusMessage: null,
|
|
40
|
+
pendingEscapeClear: false,
|
|
41
|
+
overlay: null,
|
|
42
|
+
sessionPickerIndex: 0,
|
|
43
|
+
sessionPickerPage: 0,
|
|
44
|
+
// File picker
|
|
45
|
+
filePickerDir: null,
|
|
46
|
+
filePickerIndex: 0,
|
|
47
|
+
filePickerScroll: 0,
|
|
48
|
+
filePickerSelected: new Set(),
|
|
49
|
+
filePickerEntries: [],
|
|
50
|
+
filePickerError: null,
|
|
51
|
+
attachedFiles: [],
|
|
52
|
+
// Widgets
|
|
53
|
+
widgets: [],
|
|
54
|
+
widgetsIndex: 0,
|
|
55
|
+
widgetsPage: 0,
|
|
56
|
+
widgetsLoaded: false,
|
|
57
|
+
// Auth
|
|
58
|
+
authenticated: false,
|
|
59
|
+
authInProgress: false,
|
|
60
|
+
authMessage: null,
|
|
61
|
+
userName: null,
|
|
62
|
+
// Animation
|
|
63
|
+
blinkVisible: true,
|
|
64
|
+
lastBlinkTime: 0,
|
|
65
|
+
// Layout
|
|
66
|
+
layout: {
|
|
67
|
+
width: 80,
|
|
68
|
+
height: 24,
|
|
69
|
+
inputY: 0,
|
|
70
|
+
messagesY: 0,
|
|
71
|
+
messagesHeight: 0,
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
export function markDirty() {
|
|
75
|
+
state.dirty = true;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAG5C,MAAM,CAAC,MAAM,KAAK,GAAa;IAC3B,QAAQ;IACR,KAAK,EAAE,EAAE;IACT,MAAM,EAAE,CAAC;IACT,YAAY,EAAE,EAAE;IAChB,WAAW,EAAE,CAAC;IAEd,aAAa;IACb,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,UAAU;IACrB,QAAQ,EAAE,IAAI;IACd,YAAY,EAAE,IAAI;IAElB,WAAW;IACX,QAAQ,EAAE,EAAE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AAEF,MAAM,UAAU,SAAS;IACrB,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC;AACvB,CAAC"}
|
package/dist/styles.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StylePool - Interns styles for efficient comparison
|
|
3
|
+
*/
|
|
4
|
+
import type { StyleSpec } from './types.js';
|
|
5
|
+
export declare class StylePool {
|
|
6
|
+
styles: (StyleSpec | null)[];
|
|
7
|
+
cache: Map<string, number>;
|
|
8
|
+
ansiCache: string[];
|
|
9
|
+
constructor();
|
|
10
|
+
intern(style: StyleSpec): number;
|
|
11
|
+
get(id: number): StyleSpec | null;
|
|
12
|
+
toAnsi(id: number): string;
|
|
13
|
+
buildAnsi(style: StyleSpec): string;
|
|
14
|
+
}
|
|
15
|
+
export declare const RESET = "\u001B[0m";
|
|
16
|
+
export default StylePool;
|
package/dist/styles.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StylePool - Interns styles for efficient comparison
|
|
3
|
+
*/
|
|
4
|
+
const COLORS = {
|
|
5
|
+
black: 30, red: 31, green: 32, yellow: 33, blue: 34,
|
|
6
|
+
magenta: 35, cyan: 36, white: 37, gray: 90,
|
|
7
|
+
brightRed: 91, brightGreen: 92, brightYellow: 93, brightBlue: 94,
|
|
8
|
+
brightMagenta: 95, brightCyan: 96, brightWhite: 97,
|
|
9
|
+
};
|
|
10
|
+
const BG_COLORS = {
|
|
11
|
+
bgBlack: 40, bgRed: 41, bgGreen: 42, bgYellow: 43,
|
|
12
|
+
bgBlue: 44, bgMagenta: 45, bgCyan: 46, bgWhite: 47,
|
|
13
|
+
};
|
|
14
|
+
const MODIFIERS = {
|
|
15
|
+
bold: 1, dim: 2, italic: 3, underline: 4, inverse: 7, strikethrough: 9,
|
|
16
|
+
};
|
|
17
|
+
export class StylePool {
|
|
18
|
+
styles;
|
|
19
|
+
cache;
|
|
20
|
+
ansiCache;
|
|
21
|
+
constructor() {
|
|
22
|
+
this.styles = [null];
|
|
23
|
+
this.cache = new Map();
|
|
24
|
+
this.ansiCache = [''];
|
|
25
|
+
}
|
|
26
|
+
intern(style) {
|
|
27
|
+
if (!style || Object.keys(style).length === 0) {
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
const key = JSON.stringify(style, Object.keys(style).sort());
|
|
31
|
+
let id = this.cache.get(key);
|
|
32
|
+
if (id !== undefined) {
|
|
33
|
+
return id;
|
|
34
|
+
}
|
|
35
|
+
id = this.styles.length;
|
|
36
|
+
this.styles.push(style);
|
|
37
|
+
this.cache.set(key, id);
|
|
38
|
+
this.ansiCache.push(this.buildAnsi(style));
|
|
39
|
+
return id;
|
|
40
|
+
}
|
|
41
|
+
get(id) {
|
|
42
|
+
return this.styles[id] || null;
|
|
43
|
+
}
|
|
44
|
+
toAnsi(id) {
|
|
45
|
+
return this.ansiCache[id] || '';
|
|
46
|
+
}
|
|
47
|
+
buildAnsi(style) {
|
|
48
|
+
const codes = [];
|
|
49
|
+
for (const [name, code] of Object.entries(MODIFIERS)) {
|
|
50
|
+
if (style[name]) {
|
|
51
|
+
codes.push(code);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (style.color && COLORS[style.color]) {
|
|
55
|
+
codes.push(COLORS[style.color]);
|
|
56
|
+
}
|
|
57
|
+
if (style.bg && BG_COLORS[style.bg]) {
|
|
58
|
+
codes.push(BG_COLORS[style.bg]);
|
|
59
|
+
}
|
|
60
|
+
if (codes.length === 0) {
|
|
61
|
+
return '';
|
|
62
|
+
}
|
|
63
|
+
return `\x1b[${codes.join(';')}m`;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export const RESET = '\x1b[0m';
|
|
67
|
+
export default StylePool;
|
|
68
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH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KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QACpC,CAAC;QAED,IAAI,KAAK,CAAC,EAAE,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;YAClC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;QACpC,CAAC;QAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrB,OAAO,EAAE,CAAC;QACd,CAAC;QAED,OAAO,QAAQ,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACtC,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAC;AAE/B,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal - ANSI escape sequences for cursor control
|
|
3
|
+
*/
|
|
4
|
+
export declare const cursorUp: (n?: number) => string;
|
|
5
|
+
export declare const cursorDown: (n?: number) => string;
|
|
6
|
+
export declare const cursorRight: (n?: number) => string;
|
|
7
|
+
export declare const cursorLeft: (n?: number) => string;
|
|
8
|
+
export declare const cursorTo: (x: number, y: number) => string;
|
|
9
|
+
export declare const cursorToColumn: (x: number) => string;
|
|
10
|
+
export declare const cursorHide = "\u001B[?25l";
|
|
11
|
+
export declare const cursorShow = "\u001B[?25h";
|
|
12
|
+
export declare const clearLine = "\u001B[2K";
|
|
13
|
+
export declare const clearToEndOfLine = "\u001B[K";
|
|
14
|
+
export declare const clearScreen = "\u001B[2J";
|
|
15
|
+
export declare const clearScrollback = "\u001B[3J";
|
|
16
|
+
export declare const altScreenEnter = "\u001B[?1049h";
|
|
17
|
+
export declare const altScreenLeave = "\u001B[?1049l";
|
|
18
|
+
export declare const syncStart = "\u001B[?2026h";
|
|
19
|
+
export declare const syncEnd = "\u001B[?2026l";
|
|
20
|
+
export declare const styleReset = "\u001B[0m";
|
|
21
|
+
export declare function moveCursor(fromX: number, fromY: number, toX: number, toY: number): string;
|
|
22
|
+
export declare function cursorToAbs(x: number, y: number): string;
|
|
23
|
+
export declare const linkStart: (url: string) => string;
|
|
24
|
+
export declare const linkEnd = "\u001B]8;;\u001B\\";
|
|
25
|
+
declare const _default: {
|
|
26
|
+
cursorUp: (n?: number) => string;
|
|
27
|
+
cursorDown: (n?: number) => string;
|
|
28
|
+
cursorRight: (n?: number) => string;
|
|
29
|
+
cursorLeft: (n?: number) => string;
|
|
30
|
+
cursorTo: (x: number, y: number) => string;
|
|
31
|
+
cursorToColumn: (x: number) => string;
|
|
32
|
+
cursorHide: string;
|
|
33
|
+
cursorShow: string;
|
|
34
|
+
clearLine: string;
|
|
35
|
+
clearToEndOfLine: string;
|
|
36
|
+
clearScreen: string;
|
|
37
|
+
clearScrollback: string;
|
|
38
|
+
altScreenEnter: string;
|
|
39
|
+
altScreenLeave: string;
|
|
40
|
+
syncStart: string;
|
|
41
|
+
syncEnd: string;
|
|
42
|
+
styleReset: string;
|
|
43
|
+
moveCursor: typeof moveCursor;
|
|
44
|
+
cursorToAbs: typeof cursorToAbs;
|
|
45
|
+
};
|
|
46
|
+
export default _default;
|
package/dist/terminal.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal - ANSI escape sequences for cursor control
|
|
3
|
+
*/
|
|
4
|
+
const ESC = '\x1b';
|
|
5
|
+
const CSI = `${ESC}[`;
|
|
6
|
+
export const cursorUp = (n = 1) => n > 0 ? `${CSI}${n}A` : '';
|
|
7
|
+
export const cursorDown = (n = 1) => n > 0 ? `${CSI}${n}B` : '';
|
|
8
|
+
export const cursorRight = (n = 1) => n > 0 ? `${CSI}${n}C` : '';
|
|
9
|
+
export const cursorLeft = (n = 1) => n > 0 ? `${CSI}${n}D` : '';
|
|
10
|
+
export const cursorTo = (x, y) => `${CSI}${y + 1};${x + 1}H`;
|
|
11
|
+
export const cursorToColumn = (x) => `${CSI}${x + 1}G`;
|
|
12
|
+
export const cursorHide = `${CSI}?25l`;
|
|
13
|
+
export const cursorShow = `${CSI}?25h`;
|
|
14
|
+
export const clearLine = `${CSI}2K`;
|
|
15
|
+
export const clearToEndOfLine = `${CSI}K`;
|
|
16
|
+
export const clearScreen = `${CSI}2J`;
|
|
17
|
+
export const clearScrollback = `${CSI}3J`;
|
|
18
|
+
export const altScreenEnter = `${CSI}?1049h`;
|
|
19
|
+
export const altScreenLeave = `${CSI}?1049l`;
|
|
20
|
+
export const syncStart = `${CSI}?2026h`;
|
|
21
|
+
export const syncEnd = `${CSI}?2026l`;
|
|
22
|
+
export const styleReset = `${CSI}0m`;
|
|
23
|
+
export function moveCursor(fromX, fromY, toX, toY) {
|
|
24
|
+
const dx = toX - fromX;
|
|
25
|
+
const dy = toY - fromY;
|
|
26
|
+
let seq = '';
|
|
27
|
+
if (dy < 0) {
|
|
28
|
+
seq += cursorUp(-dy);
|
|
29
|
+
}
|
|
30
|
+
else if (dy > 0) {
|
|
31
|
+
seq += cursorDown(dy);
|
|
32
|
+
}
|
|
33
|
+
if (dx < 0) {
|
|
34
|
+
seq += cursorLeft(-dx);
|
|
35
|
+
}
|
|
36
|
+
else if (dx > 0) {
|
|
37
|
+
seq += cursorRight(dx);
|
|
38
|
+
}
|
|
39
|
+
return seq;
|
|
40
|
+
}
|
|
41
|
+
export function cursorToAbs(x, y) {
|
|
42
|
+
return `${CSI}${y + 1};${x + 1}H`;
|
|
43
|
+
}
|
|
44
|
+
export const linkStart = (url) => `${ESC}]8;;${url}${ESC}\\`;
|
|
45
|
+
export const linkEnd = `${ESC}]8;;${ESC}\\`;
|
|
46
|
+
export default {
|
|
47
|
+
cursorUp,
|
|
48
|
+
cursorDown,
|
|
49
|
+
cursorRight,
|
|
50
|
+
cursorLeft,
|
|
51
|
+
cursorTo,
|
|
52
|
+
cursorToColumn,
|
|
53
|
+
cursorHide,
|
|
54
|
+
cursorShow,
|
|
55
|
+
clearLine,
|
|
56
|
+
clearToEndOfLine,
|
|
57
|
+
clearScreen,
|
|
58
|
+
clearScrollback,
|
|
59
|
+
altScreenEnter,
|
|
60
|
+
altScreenLeave,
|
|
61
|
+
syncStart,
|
|
62
|
+
syncEnd,
|
|
63
|
+
styleReset,
|
|
64
|
+
moveCursor,
|
|
65
|
+
cursorToAbs,
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=terminal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal.js","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,GAAG,GAAG,MAAM,CAAC;AACnB,MAAM,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAEtB,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAY,CAAC,EAAU,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;AAC9E,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,CAAC,EAAU,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;AAChF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAY,CAAC,EAAU,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;AACjF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,CAAC,EAAU,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;AAEhF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,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