agentlas 1.0.42 → 1.0.44

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.
Files changed (70) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/engine/agentlas-workforce.cjs +1 -1
  3. package/engine/hephaestus/runtime.cjs +1 -1
  4. package/engine/storm/storm.cjs +1 -1
  5. package/engine/storm/swarm.cjs +1 -1
  6. package/engine/ui/palette.cjs +1 -0
  7. package/engine/ui/repl.cjs +34 -4
  8. package/engine/ui/shell.cjs +22 -3
  9. package/engine/vendor/mermaid/LICENSE +205 -0
  10. package/engine/vendor/mermaid/ansi.js +23 -0
  11. package/engine/vendor/mermaid/canvas.js +366 -0
  12. package/engine/vendor/mermaid/graph.js +91 -0
  13. package/engine/vendor/mermaid/index.js +100 -0
  14. package/engine/vendor/mermaid/labels.js +324 -0
  15. package/engine/vendor/mermaid/layout-seq.js +194 -0
  16. package/engine/vendor/mermaid/layout.js +881 -0
  17. package/engine/vendor/mermaid/package.json +1 -0
  18. package/engine/vendor/mermaid/parse.js +1108 -0
  19. package/engine/vendor/mermaid/source-box.js +78 -0
  20. package/engine/vendor/mermaid/types.js +1 -0
  21. package/engine/vendor/mermaid/width-data.js +994 -0
  22. package/engine/vendor/mermaid/width.js +76 -0
  23. package/engine/vendor/tui/LICENSE +20 -0
  24. package/engine/vendor/tui/autocomplete.js +632 -0
  25. package/engine/vendor/tui/components/alt-screen-flash.js +37 -0
  26. package/engine/vendor/tui/components/box.js +104 -0
  27. package/engine/vendor/tui/components/cancellable-loader.js +35 -0
  28. package/engine/vendor/tui/components/editor.js +1961 -0
  29. package/engine/vendor/tui/components/h-stack.js +43 -0
  30. package/engine/vendor/tui/components/image.js +90 -0
  31. package/engine/vendor/tui/components/input.js +378 -0
  32. package/engine/vendor/tui/components/loader.js +69 -0
  33. package/engine/vendor/tui/components/markdown.js +806 -0
  34. package/engine/vendor/tui/components/scroll-view.js +173 -0
  35. package/engine/vendor/tui/components/select-list.js +159 -0
  36. package/engine/vendor/tui/components/settings-list.js +182 -0
  37. package/engine/vendor/tui/components/spacer.js +23 -0
  38. package/engine/vendor/tui/components/stack.js +111 -0
  39. package/engine/vendor/tui/components/text.js +89 -0
  40. package/engine/vendor/tui/components/truncated-text.js +51 -0
  41. package/engine/vendor/tui/components/v-stack.js +26 -0
  42. package/engine/vendor/tui/deps/east-asian-width/LICENSE +9 -0
  43. package/engine/vendor/tui/deps/east-asian-width/index.js +30 -0
  44. package/engine/vendor/tui/deps/east-asian-width/lookup-data.js +21 -0
  45. package/engine/vendor/tui/deps/east-asian-width/lookup.js +138 -0
  46. package/engine/vendor/tui/deps/east-asian-width/utilities.js +24 -0
  47. package/engine/vendor/tui/deps/marked/LICENSE +44 -0
  48. package/engine/vendor/tui/deps/marked/index.js +77 -0
  49. package/engine/vendor/tui/editor-component.js +2 -0
  50. package/engine/vendor/tui/fuzzy.js +110 -0
  51. package/engine/vendor/tui/index.js +42 -0
  52. package/engine/vendor/tui/keybindings.js +209 -0
  53. package/engine/vendor/tui/keys.js +1174 -0
  54. package/engine/vendor/tui/kill-ring.js +44 -0
  55. package/engine/vendor/tui/latex.js +1264 -0
  56. package/engine/vendor/tui/layout-node.js +6 -0
  57. package/engine/vendor/tui/layout.js +314 -0
  58. package/engine/vendor/tui/native-modifiers.js +60 -0
  59. package/engine/vendor/tui/package.json +1 -0
  60. package/engine/vendor/tui/stdin-buffer.js +361 -0
  61. package/engine/vendor/tui/terminal-colors.js +59 -0
  62. package/engine/vendor/tui/terminal-image.js +518 -0
  63. package/engine/vendor/tui/terminal.js +436 -0
  64. package/engine/vendor/tui/tui-alt-screen.js +902 -0
  65. package/engine/vendor/tui/tui-main-screen.js +533 -0
  66. package/engine/vendor/tui/tui.js +937 -0
  67. package/engine/vendor/tui/undo-stack.js +25 -0
  68. package/engine/vendor/tui/utils.js +1191 -0
  69. package/engine/vendor/tui/word-navigation.js +96 -0
  70. package/package.json +2 -6
@@ -0,0 +1,6 @@
1
+ export const LAYOUT_NODE = Symbol.for("@earendil-works/pi-tui/layout-node");
2
+ export function getLayoutNode(component) {
3
+ const candidate = component;
4
+ return typeof candidate[LAYOUT_NODE] === "function" ? candidate[LAYOUT_NODE]() : undefined;
5
+ }
6
+ //# sourceMappingURL=layout-node.js.map
@@ -0,0 +1,314 @@
1
+ import { allocateStackSizes, visibleStackEntries } from "./components/stack.js";
2
+ import { getLayoutNode } from "./layout-node.js";
3
+ import { cropKittyImageLine, getKittyImageMetadata, isImageLine } from "./terminal-image.js";
4
+ import { CURSOR_MARKER, compositeTuiLine } from "./tui.js";
5
+ import { extractAnsiCode, getGraphemeCellRange, sliceByColumn, visibleWidth } from "./utils.js";
6
+ const OSC133_ZONE_PREFIX = /^(?:\x1b\]133;[ABC](?:\x07|\x1b\\))+/;
7
+ function intersect(a, b) {
8
+ const x = Math.max(a.x, b.x);
9
+ const y = Math.max(a.y, b.y);
10
+ const right = Math.min(a.x + a.width, b.x + b.width);
11
+ const bottom = Math.min(a.y + a.height, b.y + b.height);
12
+ return { x, y, width: Math.max(0, right - x), height: Math.max(0, bottom - y) };
13
+ }
14
+ function renderCached(context, component, width) {
15
+ const safeWidth = Math.max(1, Math.floor(width));
16
+ let widths = context.renderCache.get(component);
17
+ if (!widths) {
18
+ widths = new Map();
19
+ context.renderCache.set(component, widths);
20
+ }
21
+ let lines = widths.get(safeWidth);
22
+ if (!lines) {
23
+ lines = component.render(safeWidth);
24
+ widths.set(safeWidth, lines);
25
+ }
26
+ return lines;
27
+ }
28
+ function measureHeight(context, component, width) {
29
+ return renderCached(context, component, width).length;
30
+ }
31
+ function measureWidth(context, component, width) {
32
+ return renderCached(context, component, width).reduce((max, line) => Math.max(max, visibleWidth(line)), 0);
33
+ }
34
+ function withParent(box, parent) {
35
+ box.parent = parent;
36
+ return box;
37
+ }
38
+ function translateBox(box, deltaY) {
39
+ box.rect.y += deltaY;
40
+ for (const child of box.children)
41
+ translateBox(child, deltaY);
42
+ }
43
+ function updateClips(box, parentClip) {
44
+ box.clip = intersect(parentClip, box.rect);
45
+ for (const child of box.children)
46
+ updateClips(child, box.clip);
47
+ }
48
+ function layoutComponent(context, component, x, y, width, height, clip) {
49
+ const safeWidth = Math.max(1, Math.floor(width));
50
+ const node = getLayoutNode(component);
51
+ if (!node) {
52
+ const lines = renderCached(context, component, safeWidth);
53
+ const allocatedHeight = height === undefined ? lines.length : Math.max(0, Math.floor(height));
54
+ let lineOffset = 0;
55
+ if (lines.length > allocatedHeight && allocatedHeight > 0) {
56
+ const cursorLine = lines.findIndex((line) => line.includes(CURSOR_MARKER));
57
+ if (cursorLine >= allocatedHeight)
58
+ lineOffset = cursorLine - allocatedHeight + 1;
59
+ }
60
+ return {
61
+ component,
62
+ rect: { x, y, width: safeWidth, height: allocatedHeight },
63
+ clip: intersect(clip, { x, y, width: safeWidth, height: allocatedHeight }),
64
+ children: [],
65
+ lines,
66
+ lineOffset,
67
+ layer: 0,
68
+ };
69
+ }
70
+ if (node.type === "scroll") {
71
+ const previousScrollTop = node.state.scrollTop;
72
+ const contentWidth = node.state.getContentWidth(safeWidth);
73
+ const childBox = layoutComponent(context, node.component, x, y - previousScrollTop, contentWidth, undefined, clip);
74
+ const contentHeight = childBox.rect.height;
75
+ const viewportHeight = height === undefined ? contentHeight : Math.max(0, Math.floor(height));
76
+ node.state.updateLayout(contentHeight, viewportHeight, context.requestRender);
77
+ translateBox(childBox, previousScrollTop - node.state.scrollTop);
78
+ const scrollView = node.state;
79
+ if (node.state.primary || !context.primaryScrollView)
80
+ context.primaryScrollView = scrollView;
81
+ const rect = { x, y, width: safeWidth, height: viewportHeight };
82
+ const childClip = intersect(clip, rect);
83
+ const box = {
84
+ component,
85
+ rect,
86
+ clip: childClip,
87
+ children: [childBox],
88
+ scrollView,
89
+ scrollContentLines: renderCached(context, node.component, contentWidth),
90
+ layer: 0,
91
+ };
92
+ childBox.parent = box;
93
+ updateClips(childBox, childClip);
94
+ return box;
95
+ }
96
+ const entries = visibleStackEntries(node.entries, context.viewport);
97
+ const gapTotal = Math.max(0, entries.length - 1) * node.gap;
98
+ if (node.type === "vstack") {
99
+ const intrinsicHeights = entries.map((entry) => typeof entry.basis === "number" ? entry.basis : measureHeight(context, entry.component, safeWidth));
100
+ const sizes = allocateStackSizes(entries, intrinsicHeights, height, node.gap);
101
+ const naturalHeight = sizes.reduce((sum, size) => sum + size, 0) + gapTotal;
102
+ const allocatedHeight = height === undefined ? naturalHeight : Math.max(0, Math.floor(height));
103
+ const rect = { x, y, width: safeWidth, height: allocatedHeight };
104
+ const box = {
105
+ component,
106
+ rect,
107
+ clip: intersect(clip, rect),
108
+ children: [],
109
+ layer: 0,
110
+ };
111
+ let childY = y;
112
+ for (let index = 0; index < entries.length; index++) {
113
+ box.children.push(withParent(layoutComponent(context, entries[index].component, x, childY, safeWidth, sizes[index], box.clip), box));
114
+ childY += sizes[index] + node.gap;
115
+ }
116
+ return box;
117
+ }
118
+ const intrinsicWidths = entries.map((entry) => typeof entry.basis === "number" ? entry.basis : measureWidth(context, entry.component, safeWidth));
119
+ const widths = allocateStackSizes(entries, intrinsicWidths, safeWidth, node.gap);
120
+ const intrinsicHeights = entries.map((entry, index) => measureHeight(context, entry.component, Math.max(1, widths[index])));
121
+ const allocatedHeight = height === undefined
122
+ ? intrinsicHeights.reduce((max, childHeight) => Math.max(max, childHeight), 0)
123
+ : Math.max(0, height);
124
+ const rect = { x, y, width: safeWidth, height: allocatedHeight };
125
+ const box = {
126
+ component,
127
+ rect,
128
+ clip: intersect(clip, rect),
129
+ children: [],
130
+ layer: 0,
131
+ };
132
+ let childX = x;
133
+ for (let index = 0; index < entries.length; index++) {
134
+ const naturalChildHeight = intrinsicHeights[index];
135
+ const childHeight = node.align === "stretch" ? allocatedHeight : Math.min(allocatedHeight, naturalChildHeight);
136
+ let childY = y;
137
+ if (node.align === "center")
138
+ childY += Math.floor((allocatedHeight - childHeight) / 2);
139
+ else if (node.align === "end")
140
+ childY += allocatedHeight - childHeight;
141
+ const childWidth = widths[index];
142
+ if (childWidth === 0) {
143
+ box.children.push({
144
+ component: entries[index].component,
145
+ rect: { x: childX, y: childY, width: 0, height: childHeight },
146
+ clip: { x: childX, y: childY, width: 0, height: 0 },
147
+ children: [],
148
+ parent: box,
149
+ layer: 0,
150
+ });
151
+ }
152
+ else {
153
+ box.children.push(withParent(layoutComponent(context, entries[index].component, childX, childY, childWidth, childHeight, box.clip), box));
154
+ }
155
+ childX += childWidth + node.gap;
156
+ }
157
+ return box;
158
+ }
159
+ function styleScrollbarCell(line, column, totalWidth, style) {
160
+ if (isImageLine(line))
161
+ return line;
162
+ const graphemeRange = getGraphemeCellRange(line, column);
163
+ const start = graphemeRange?.start ?? column;
164
+ const end = graphemeRange?.end ?? column + 1;
165
+ const before = sliceByColumn(line, 0, start, true);
166
+ const target = sliceByColumn(line, start, end - start, true);
167
+ const after = sliceByColumn(line, end, Math.max(0, totalWidth - end), true);
168
+ let targetPrefix = "";
169
+ let targetIndex = 0;
170
+ while (targetIndex < target.length) {
171
+ const ansi = extractAnsiCode(target, targetIndex);
172
+ if (!ansi)
173
+ break;
174
+ targetPrefix += ansi.code;
175
+ targetIndex += ansi.length;
176
+ }
177
+ const targetText = target.slice(targetIndex) || " ".repeat(end - start);
178
+ const beforePadding = " ".repeat(Math.max(0, start - visibleWidth(before)));
179
+ return `${before}${beforePadding}${targetPrefix}${style(targetText)}${after}`;
180
+ }
181
+ export function getScrollbarGeometry(box) {
182
+ if (!box.scrollView?.isScrollbarVisible || box.rect.width <= 0 || box.rect.height <= 0)
183
+ return undefined;
184
+ const contentHeight = box.children[0]?.rect.height ?? box.scrollContentLines?.length ?? 0;
185
+ const trackHeight = box.rect.height;
186
+ const minThumbHeight = Math.min(2, trackHeight);
187
+ const thumbHeight = Math.max(minThumbHeight, Math.min(trackHeight, Math.round((trackHeight * trackHeight) / contentHeight)));
188
+ const maxScrollTop = Math.max(0, contentHeight - trackHeight);
189
+ const maxThumbTop = trackHeight - thumbHeight;
190
+ const thumbOffset = maxScrollTop === 0 ? 0 : Math.round((box.scrollView.scrollTop / maxScrollTop) * maxThumbTop);
191
+ const column = box.rect.x + box.rect.width - 1;
192
+ if (column < box.clip.x || column >= box.clip.x + box.clip.width)
193
+ return undefined;
194
+ return {
195
+ column,
196
+ trackTop: box.rect.y,
197
+ trackHeight,
198
+ thumbTop: box.rect.y + thumbOffset,
199
+ thumbHeight,
200
+ maxScrollTop,
201
+ };
202
+ }
203
+ function paintScrollbar(box, screen, totalWidth) {
204
+ const geometry = getScrollbarGeometry(box);
205
+ if (!geometry || !box.scrollView)
206
+ return;
207
+ for (let offset = 0; offset < geometry.thumbHeight; offset++) {
208
+ const row = geometry.thumbTop + offset;
209
+ if (row < box.clip.y || row >= box.clip.y + box.clip.height || row < 0 || row >= screen.length)
210
+ continue;
211
+ screen[row] = styleScrollbarCell(screen[row] ?? "", geometry.column, totalWidth, box.scrollView.scrollbarStyle);
212
+ }
213
+ }
214
+ function paintBox(box, screen, totalWidth) {
215
+ if (box.lines) {
216
+ const offset = box.lineOffset ?? 0;
217
+ const firstRow = Math.max(box.rect.y, box.clip.y, 0);
218
+ const lastRow = Math.min(box.rect.y + box.rect.height, box.clip.y + box.clip.height, screen.length);
219
+ for (let row = firstRow; row < lastRow; row++) {
220
+ const sourceLine = box.lines[offset + row - box.rect.y];
221
+ if (sourceLine === undefined)
222
+ continue;
223
+ let line = sourceLine.replace(OSC133_ZONE_PREFIX, "");
224
+ const imageMetadata = getKittyImageMetadata(line);
225
+ if (imageMetadata) {
226
+ const clipBottom = Math.min(screen.length, box.clip.y + box.clip.height);
227
+ const visibleRows = Math.min(imageMetadata.rows, clipBottom - row);
228
+ if (visibleRows < imageMetadata.rows)
229
+ line = cropKittyImageLine(line, 0, visibleRows);
230
+ }
231
+ if (isImageLine(line) && box.rect.x === 0 && box.rect.width >= totalWidth)
232
+ screen[row] = line;
233
+ else
234
+ screen[row] = compositeTuiLine(screen[row] ?? "", line, box.rect.x, box.rect.width, totalWidth);
235
+ }
236
+ }
237
+ for (const child of box.children)
238
+ paintBox(child, screen, totalWidth);
239
+ if (box.scrollView && box.scrollContentLines && box.scrollView.scrollTop > 0 && box.rect.height > 0) {
240
+ for (let imageRow = box.scrollView.scrollTop - 1; imageRow >= 0; imageRow--) {
241
+ const imageLine = box.scrollContentLines[imageRow] ?? "";
242
+ const metadata = getKittyImageMetadata(imageLine);
243
+ if (metadata) {
244
+ const hiddenRows = box.scrollView.scrollTop - imageRow;
245
+ if (hiddenRows < metadata.rows) {
246
+ const visibleRows = Math.min(box.rect.height, metadata.rows - hiddenRows);
247
+ const cropped = cropKittyImageLine(imageLine, hiddenRows, visibleRows);
248
+ if (box.rect.x === 0 && box.rect.width >= totalWidth)
249
+ screen[box.rect.y] = cropped;
250
+ }
251
+ break;
252
+ }
253
+ if (imageLine !== "")
254
+ break;
255
+ }
256
+ }
257
+ paintScrollbar(box, screen, totalWidth);
258
+ }
259
+ export function renderLayoutFrame(root, width, height, requestRender) {
260
+ const safeWidth = Math.max(1, Math.floor(width));
261
+ const safeHeight = Math.max(1, Math.floor(height));
262
+ const context = {
263
+ viewport: { width: safeWidth, height: safeHeight },
264
+ renderCache: new Map(),
265
+ requestRender,
266
+ primaryScrollView: undefined,
267
+ };
268
+ const rootBox = layoutComponent(context, root, 0, 0, safeWidth, safeHeight, {
269
+ x: 0,
270
+ y: 0,
271
+ width: safeWidth,
272
+ height: safeHeight,
273
+ });
274
+ const lines = Array.from({ length: safeHeight }, () => "");
275
+ paintBox(rootBox, lines, safeWidth);
276
+ return {
277
+ root: rootBox,
278
+ width: safeWidth,
279
+ height: safeHeight,
280
+ lines,
281
+ ...(context.primaryScrollView === undefined ? {} : { primaryScrollView: context.primaryScrollView }),
282
+ };
283
+ }
284
+ function containsPoint(rect, x, y) {
285
+ return x >= rect.x && x < rect.x + rect.width && y >= rect.y && y < rect.y + rect.height;
286
+ }
287
+ export function getScrollViewBox(frame, scrollView) {
288
+ const visit = (box) => {
289
+ if (box.scrollView === scrollView)
290
+ return box;
291
+ for (const child of box.children) {
292
+ const match = visit(child);
293
+ if (match)
294
+ return match;
295
+ }
296
+ return undefined;
297
+ };
298
+ return visit(frame.root);
299
+ }
300
+ export function getScrollViewsAt(frame, x, y) {
301
+ const result = [];
302
+ const visit = (box, depth) => {
303
+ if (!containsPoint(box.clip, x, y))
304
+ return;
305
+ if (box.scrollView && containsPoint(box.rect, x, y))
306
+ result.push({ scrollView: box.scrollView, depth });
307
+ for (const child of box.children)
308
+ visit(child, depth + 1);
309
+ };
310
+ visit(frame.root, 0);
311
+ result.sort((a, b) => b.depth - a.depth);
312
+ return result.map((entry) => entry.scrollView);
313
+ }
314
+ //# sourceMappingURL=layout.js.map
@@ -0,0 +1,60 @@
1
+ import { createRequire } from "node:module";
2
+ import * as path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ const cjsRequire = createRequire(import.meta.url);
5
+ let nativeModifiersHelper;
6
+ function isNativeModifiersHelper(value) {
7
+ if (typeof value !== "object" || value === null)
8
+ return false;
9
+ const candidate = value.isModifierPressed;
10
+ return typeof candidate === "function";
11
+ }
12
+ function loadNativeModifiersHelper() {
13
+ if (nativeModifiersHelper !== undefined)
14
+ return nativeModifiersHelper ?? undefined;
15
+ nativeModifiersHelper = null;
16
+ const arch = process.arch;
17
+ if (arch !== "x64" && arch !== "arm64")
18
+ return undefined;
19
+ let nativePath;
20
+ if (process.platform === "darwin") {
21
+ nativePath = path.join("native", "darwin", "prebuilds", `darwin-${arch}`, "darwin-modifiers.node");
22
+ }
23
+ else if (process.platform === "win32") {
24
+ nativePath = path.join("native", "win32", "prebuilds", `win32-${arch}`, "win32-console-mode.node");
25
+ }
26
+ else {
27
+ return undefined;
28
+ }
29
+ const moduleDir = path.dirname(fileURLToPath(import.meta.url));
30
+ const candidates = [
31
+ path.join(moduleDir, "..", nativePath),
32
+ path.join(moduleDir, nativePath),
33
+ path.join(path.dirname(process.execPath), nativePath),
34
+ ];
35
+ for (const modulePath of candidates) {
36
+ try {
37
+ const helper = cjsRequire(modulePath);
38
+ if (isNativeModifiersHelper(helper)) {
39
+ nativeModifiersHelper = helper;
40
+ return helper;
41
+ }
42
+ }
43
+ catch {
44
+ // Try the next possible packaging location.
45
+ }
46
+ }
47
+ return undefined;
48
+ }
49
+ export function isNativeModifierPressed(key) {
50
+ const helper = loadNativeModifiersHelper();
51
+ if (!helper)
52
+ return false;
53
+ try {
54
+ return helper.isModifierPressed(key) === true;
55
+ }
56
+ catch {
57
+ return false;
58
+ }
59
+ }
60
+ //# sourceMappingURL=native-modifiers.js.map
@@ -0,0 +1 @@
1
+ { "type": "module" }