@runappsai/agent 0.0.0-stage → 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.
Files changed (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +162 -2
  3. package/dist/agent-core.umd.js +266 -0
  4. package/dist/agent.d.ts +222 -0
  5. package/dist/agent.js +1331 -0
  6. package/dist/agent.umd.js +732 -0
  7. package/dist/browser.d.ts +2 -0
  8. package/dist/browser.js +4 -0
  9. package/dist/chat-theme.d.ts +24 -0
  10. package/dist/chat-theme.js +101 -0
  11. package/dist/chat.d.ts +271 -0
  12. package/dist/chat.js +4099 -0
  13. package/dist/compaction.d.ts +48 -0
  14. package/dist/compaction.js +208 -0
  15. package/dist/completion.d.ts +29 -0
  16. package/dist/completion.js +88 -0
  17. package/dist/context.d.ts +44 -0
  18. package/dist/context.js +177 -0
  19. package/dist/debug-panel.d.ts +40 -0
  20. package/dist/debug-panel.js +262 -0
  21. package/dist/dialogs.d.ts +7 -0
  22. package/dist/dialogs.js +231 -0
  23. package/dist/directory-fs.d.ts +5 -0
  24. package/dist/directory-fs.js +118 -0
  25. package/dist/dom.d.ts +83 -0
  26. package/dist/dom.js +163 -0
  27. package/dist/edit.d.ts +22 -0
  28. package/dist/edit.js +133 -0
  29. package/dist/file-guard.d.ts +46 -0
  30. package/dist/file-guard.js +153 -0
  31. package/dist/file-tools.d.ts +16 -0
  32. package/dist/file-tools.js +339 -0
  33. package/dist/files-panel.d.ts +60 -0
  34. package/dist/files-panel.js +613 -0
  35. package/dist/index.cjs +4848 -0
  36. package/dist/index.d.ts +37 -0
  37. package/dist/index.js +44 -0
  38. package/dist/json-schema.d.ts +3 -0
  39. package/dist/json-schema.js +141 -0
  40. package/dist/llm.d.ts +95 -0
  41. package/dist/llm.js +5 -0
  42. package/dist/markdown.d.ts +4 -0
  43. package/dist/markdown.js +265 -0
  44. package/dist/mcp.d.ts +82 -0
  45. package/dist/mcp.js +325 -0
  46. package/dist/node.cjs +402 -0
  47. package/dist/node.d.ts +78 -0
  48. package/dist/node.js +432 -0
  49. package/dist/pdf.d.ts +52 -0
  50. package/dist/pdf.js +77 -0
  51. package/dist/provider.d.ts +135 -0
  52. package/dist/provider.js +181 -0
  53. package/dist/sandbox.d.ts +33 -0
  54. package/dist/sandbox.js +219 -0
  55. package/dist/select.d.ts +30 -0
  56. package/dist/select.js +185 -0
  57. package/dist/skill-zips.d.ts +28 -0
  58. package/dist/skill-zips.js +123 -0
  59. package/dist/skills.d.ts +20 -0
  60. package/dist/skills.js +111 -0
  61. package/dist/templates.d.ts +24 -0
  62. package/dist/templates.js +136 -0
  63. package/dist/tool.d.ts +28 -0
  64. package/dist/tool.js +102 -0
  65. package/dist/types.d.ts +571 -0
  66. package/dist/types.js +7 -0
  67. package/dist/ui.cjs +6247 -0
  68. package/dist/ui.d.ts +6 -0
  69. package/dist/ui.js +11 -0
  70. package/dist/vlist.d.ts +80 -0
  71. package/dist/vlist.js +277 -0
  72. package/dist/workspace.d.ts +343 -0
  73. package/dist/workspace.js +1203 -0
  74. package/dist/zip.d.ts +26 -0
  75. package/dist/zip.js +204 -0
  76. package/docs/agent.md +228 -0
  77. package/docs/chat-ui.md +307 -0
  78. package/docs/node.md +135 -0
  79. package/docs/providers.md +176 -0
  80. package/docs/reference.md +143 -0
  81. package/docs/skills.md +131 -0
  82. package/docs/tools.md +254 -0
  83. package/docs/workspace.md +198 -0
  84. package/package.json +59 -4
package/dist/node.cjs ADDED
@@ -0,0 +1,402 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/node.ts
31
+ var node_exports = {};
32
+ __export(node_exports, {
33
+ lineReader: () => lineReader,
34
+ nodeFS: () => nodeFS,
35
+ nodePdf: () => nodePdf,
36
+ nodeStore: () => nodeStore,
37
+ terminalUI: () => terminalUI
38
+ });
39
+ module.exports = __toCommonJS(node_exports);
40
+ var import_node_fs = require("fs");
41
+ var path = __toESM(require("path"), 1);
42
+ var os = __toESM(require("os"), 1);
43
+ var import_promises = require("readline/promises");
44
+ var import_index = require("./index.cjs");
45
+ function contentOf(buf) {
46
+ const bytes = new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
47
+ for (const b of bytes) if (b < 32 && b !== 9 && b !== 10 && b !== 13 && b !== 12 && b !== 27) return bytes;
48
+ return (0, import_index.decodeText)(bytes) ?? bytes;
49
+ }
50
+ async function walkFiles(dir, skip = /* @__PURE__ */ new Set(), keep = () => true) {
51
+ const out = [];
52
+ const walk = async (d) => {
53
+ for (const e of await import_node_fs.promises.readdir(d, { withFileTypes: true }).catch(() => [])) {
54
+ const full = path.join(d, e.name);
55
+ if (e.isDirectory()) {
56
+ if (!skip.has(e.name)) await walk(full);
57
+ } else if (e.isFile() && keep(e.name)) out.push(full);
58
+ }
59
+ };
60
+ await walk(dir);
61
+ return out;
62
+ }
63
+ var within = (base, full) => full === base || full.startsWith(base.endsWith(path.sep) ? base : base + path.sep);
64
+ function nodeFS(root, opts = {}) {
65
+ const base = path.resolve(root);
66
+ const ignore = new Set(opts.ignore ?? [".git", "node_modules"]);
67
+ let realBase = null;
68
+ const abs = async (p) => {
69
+ const full = path.join(base, (0, import_index.normalizePath)(p));
70
+ if (!within(base, full)) throw new Error(`${p} is outside the folder`);
71
+ realBase ??= import_node_fs.promises.realpath(base).catch(() => base);
72
+ let probe = full;
73
+ for (; ; ) {
74
+ const real = await import_node_fs.promises.realpath(probe).catch(() => null);
75
+ if (real) {
76
+ if (!within(await realBase, real)) throw new Error(`${p} leads outside the folder`);
77
+ break;
78
+ }
79
+ const up = path.dirname(probe);
80
+ if (up === probe) break;
81
+ probe = up;
82
+ }
83
+ return full;
84
+ };
85
+ const rel = (full) => "/" + path.relative(base, full).split(path.sep).join("/");
86
+ const statOf = async (full) => {
87
+ const st = await import_node_fs.promises.stat(full).catch(() => null);
88
+ return st && st.isFile() ? { path: rel(full), size: st.size, mtime: st.mtimeMs, contentType: (0, import_index.guessType)(full, new Uint8Array()) } : null;
89
+ };
90
+ const fs = {
91
+ description: opts.description ?? `the folder ${base}`,
92
+ async list(prefix) {
93
+ const full = await abs(prefix);
94
+ const st = await import_node_fs.promises.stat(full).catch(() => null);
95
+ if (!st) return [];
96
+ if (st.isFile()) return [await statOf(full)];
97
+ const out = [];
98
+ for (const f of await walkFiles(full, ignore)) {
99
+ const s = await statOf(f);
100
+ if (s) out.push(s);
101
+ }
102
+ return out;
103
+ },
104
+ async stat(p) {
105
+ return statOf(await abs(p));
106
+ },
107
+ async read(p) {
108
+ const buf = await import_node_fs.promises.readFile(await abs(p)).catch((err) => {
109
+ throw new Error(err.code === "ENOENT" ? `No such file: ${(0, import_index.normalizePath)(p)}` : err.message);
110
+ });
111
+ return contentOf(buf);
112
+ }
113
+ };
114
+ if (!opts.readonly) {
115
+ fs.write = async (p, content) => {
116
+ const full = await abs(p);
117
+ await import_node_fs.promises.mkdir(path.dirname(full), { recursive: true });
118
+ await import_node_fs.promises.writeFile(full, content);
119
+ };
120
+ fs.delete = async (p) => {
121
+ await import_node_fs.promises.rm(await abs(p)).catch((err) => {
122
+ throw new Error(err.code === "ENOENT" ? `No such file: ${(0, import_index.normalizePath)(p)}` : err.message);
123
+ });
124
+ };
125
+ }
126
+ return fs;
127
+ }
128
+ var enc = (s) => encodeURIComponent(s).replace(/[.*!'()~]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`);
129
+ var dec = (s) => decodeURIComponent(s);
130
+ var toJSON = (v) => JSON.stringify(v, (_k, x) => x instanceof Uint8Array ? { __u8: Buffer.from(x).toString("base64") } : x);
131
+ var fromJSON = (s) => JSON.parse(s, (_k, x) => x && typeof x === "object" && typeof x.__u8 === "string" ? new Uint8Array(Buffer.from(x.__u8, "base64")) : x);
132
+ async function readJSON(file) {
133
+ try {
134
+ return fromJSON(await import_node_fs.promises.readFile(file, "utf8"));
135
+ } catch {
136
+ return void 0;
137
+ }
138
+ }
139
+ var tmpSeq = 0;
140
+ async function writeAtomic(file, data) {
141
+ await import_node_fs.promises.mkdir(path.dirname(file), { recursive: true });
142
+ const tmp = `${file}.${process.pid}.${Date.now().toString(36)}.${(tmpSeq++).toString(36)}.${Math.random().toString(36).slice(2, 8)}.tmp`;
143
+ try {
144
+ await import_node_fs.promises.writeFile(tmp, data);
145
+ await import_node_fs.promises.rename(tmp, file);
146
+ } catch (err) {
147
+ await import_node_fs.promises.rm(tmp, { force: true });
148
+ throw err;
149
+ }
150
+ }
151
+ var notTmp = (name) => !name.endsWith(".tmp");
152
+ function nodeStore(root = path.join(os.homedir(), ".runapps-agent")) {
153
+ const base = path.resolve(root);
154
+ return {
155
+ async open(dbName, space) {
156
+ const app = path.join(base, enc(dbName));
157
+ const spaceDir = (s) => path.join(app, "spaces", enc(s));
158
+ const filesDir = path.join(spaceDir(space), "files");
159
+ const metaDir = path.join(spaceDir(space), "meta");
160
+ const sessionsDir = path.join(app, "sessions");
161
+ const fileOf = (p) => path.join(filesDir, ...(0, import_index.normalizePath)(p).split("/").filter(Boolean).map(enc));
162
+ const pathOf = (full) => "/" + path.relative(filesDir, full).split(path.sep).map(dec).join("/");
163
+ const statOf = async (full) => {
164
+ const st = await import_node_fs.promises.stat(full).catch(() => null);
165
+ if (!st || !st.isFile()) return null;
166
+ const p = pathOf(full);
167
+ return { path: p, size: st.size, mtime: st.mtimeMs, contentType: (0, import_index.guessType)(p, new Uint8Array()) };
168
+ };
169
+ const recordOf = async (full) => {
170
+ const [buf, st] = await Promise.all([import_node_fs.promises.readFile(full).catch(() => null), statOf(full)]);
171
+ if (!buf || !st) return void 0;
172
+ const data = contentOf(buf);
173
+ return { space, path: st.path, data, contentType: (0, import_index.guessType)(st.path, data), mtime: st.mtime ?? Date.now(), layer: "work" };
174
+ };
175
+ const under = (prefix) => prefix === "/" ? filesDir : fileOf(prefix);
176
+ const filesUnder = async (prefix) => walkFiles(under(prefix), void 0, notTmp);
177
+ const metaFile = (key) => path.join(metaDir, `${enc(key)}.json`);
178
+ const metaKeys = async () => (await import_node_fs.promises.readdir(metaDir).catch(() => [])).filter((n) => n.endsWith(".json")).map((n) => dec(n.slice(0, -5)));
179
+ const sessionFile = (s, id) => path.join(sessionsDir, enc(s), `${enc(id)}.json`);
180
+ return {
181
+ get: async (p) => recordOf(fileOf(p)),
182
+ stat: async (p) => statOf(fileOf(p)),
183
+ put: async (rec) => {
184
+ await writeAtomic(fileOf(rec.path), rec.data);
185
+ },
186
+ delete: async (p) => {
187
+ await import_node_fs.promises.rm(fileOf(p), { force: true });
188
+ },
189
+ list: async (prefix) => {
190
+ const out = [];
191
+ for (const full of await filesUnder(prefix)) {
192
+ const r = await recordOf(full);
193
+ if (r) out.push(r);
194
+ }
195
+ return out;
196
+ },
197
+ listStats: async (prefix) => {
198
+ const out = [];
199
+ for (const full of await filesUnder(prefix)) {
200
+ const s = await statOf(full);
201
+ if (s) out.push(s);
202
+ }
203
+ return out;
204
+ },
205
+ getMeta: async (key) => readJSON(metaFile(key)),
206
+ putMeta: async (key, value) => {
207
+ await writeAtomic(metaFile(key), toJSON(value));
208
+ },
209
+ deleteMeta: async (key) => {
210
+ await import_node_fs.promises.rm(metaFile(key), { force: true });
211
+ },
212
+ listMeta: async (prefix) => {
213
+ const out = [];
214
+ for (const k of await metaKeys()) if (k.startsWith(prefix)) {
215
+ const v = await readJSON(metaFile(k));
216
+ if (v !== void 0) out.push(v);
217
+ }
218
+ return out;
219
+ },
220
+ listMetaKeys: async (prefix) => (await metaKeys()).filter((k) => k.startsWith(prefix)),
221
+ getSession: async (s, id) => readJSON(sessionFile(s, id)),
222
+ putSession: async (data) => {
223
+ await writeAtomic(sessionFile(data.space ?? space, data.id ?? "default"), toJSON({ ...data, space: data.space ?? space }));
224
+ },
225
+ deleteSession: async (s, id) => {
226
+ await import_node_fs.promises.rm(sessionFile(s, id), { force: true });
227
+ },
228
+ listSessions: async () => {
229
+ const out = [];
230
+ for (const full of await walkFiles(sessionsDir, void 0, (n) => n.endsWith(".json"))) {
231
+ const d = await readJSON(full);
232
+ if (d) out.push(d);
233
+ }
234
+ return out;
235
+ },
236
+ clear: async (s = space) => {
237
+ await import_node_fs.promises.rm(spaceDir(s), { recursive: true, force: true });
238
+ await import_node_fs.promises.rm(path.join(sessionsDir, enc(s)), { recursive: true, force: true });
239
+ },
240
+ close: () => {
241
+ }
242
+ };
243
+ }
244
+ };
245
+ }
246
+ var readers = /* @__PURE__ */ new WeakMap();
247
+ function lineReader(opts = {}) {
248
+ const input = opts.input ?? process.stdin;
249
+ const output = opts.output ?? process.stdout;
250
+ const known = readers.get(input);
251
+ if (known) return known;
252
+ const tty = !!input.isTTY;
253
+ const rl = (0, import_promises.createInterface)({ input, output, terminal: tty });
254
+ const queue = [];
255
+ const waiters = [];
256
+ let closed = false;
257
+ const handle = input;
258
+ const idle = () => {
259
+ rl.setPrompt("");
260
+ if (tty) handle.unref?.();
261
+ else rl.pause();
262
+ };
263
+ const activate = () => {
264
+ const w = waiters[0];
265
+ if (!w) return idle();
266
+ if (tty) handle.ref?.();
267
+ rl.setPrompt(w.prompt);
268
+ rl.prompt(true);
269
+ };
270
+ rl.on("line", (line) => {
271
+ const w = waiters.shift();
272
+ if (w) {
273
+ w.done(line);
274
+ activate();
275
+ } else {
276
+ queue.push(line);
277
+ idle();
278
+ }
279
+ });
280
+ rl.on("close", () => {
281
+ closed = true;
282
+ readers.delete(input);
283
+ for (const w of waiters.splice(0)) w.done(null);
284
+ });
285
+ idle();
286
+ const reader = {
287
+ rl,
288
+ ask(prompt, signal) {
289
+ return new Promise((done) => {
290
+ if (!waiters.length && queue.length) {
291
+ output.write(prompt);
292
+ return done(queue.shift());
293
+ }
294
+ if (closed || signal?.aborted) return done(null);
295
+ const w = { prompt, done };
296
+ waiters.push(w);
297
+ if (waiters.length === 1) activate();
298
+ signal?.addEventListener("abort", () => {
299
+ const i = waiters.indexOf(w);
300
+ if (i < 0) return;
301
+ waiters.splice(i, 1);
302
+ if (i === 0) {
303
+ output.write("\n");
304
+ activate();
305
+ }
306
+ done(null);
307
+ }, { once: true });
308
+ });
309
+ },
310
+ close() {
311
+ rl.close();
312
+ }
313
+ };
314
+ readers.set(input, reader);
315
+ return reader;
316
+ }
317
+ function terminalUI(opts = {}) {
318
+ const input = opts.input ?? process.stdin;
319
+ const output = opts.output ?? process.stdout;
320
+ const color = !!output.isTTY;
321
+ const paint = (code, s) => color ? `\x1B[${code}m${s}\x1B[0m` : s;
322
+ const write = (s) => {
323
+ output.write(s);
324
+ };
325
+ const viaRl = opts.rl;
326
+ const ask = opts.ask ?? (viaRl ? async (q, signal) => {
327
+ try {
328
+ return await viaRl.question(q, signal ? { signal } : {});
329
+ } catch {
330
+ return null;
331
+ }
332
+ } : (q, signal) => lineReader({ input, output }).ask(q, signal));
333
+ const head = (title, message) => {
334
+ write(`
335
+ ${paint("1", title)}
336
+ `);
337
+ if (message) write(`${paint("2", message)}
338
+ `);
339
+ };
340
+ return {
341
+ async confirm(title, message, o = {}) {
342
+ head(title, message);
343
+ const a = await ask(`${paint(o.danger ? "31" : "36", `${o.ok ?? "Yes"} / ${o.cancel ?? "No"}`)} [y/N] `, o.signal);
344
+ return !!a && /^(y|yes|ok|是|好)$/i.test(a.trim());
345
+ },
346
+ async select(title, options, o = {}) {
347
+ head(title, o.message);
348
+ options.forEach((opt, i) => write(` ${paint("36", String(i + 1))}) ${opt.label ?? opt.value}${opt.description ? paint("2", ` \u2014 ${opt.description}`) : ""}
349
+ `));
350
+ const hint = o.multi ? "numbers, comma-separated" : "a number";
351
+ for (; ; ) {
352
+ const a = await ask(`${hint}${o.allowOther ? ", or type an answer" : ""}: `, o.signal);
353
+ if (a === null || !a.trim()) return null;
354
+ const picks = a.split(",").map((x) => x.trim()).filter(Boolean);
355
+ const nums = picks.map((x) => Number(x));
356
+ if (nums.every((n) => Number.isInteger(n) && n >= 1 && n <= options.length) && (o.multi || nums.length === 1)) return nums.map((n) => options[n - 1].value);
357
+ if (o.allowOther) return [a.trim()];
358
+ write(paint("33", `Pick ${hint} from 1 to ${options.length}.
359
+ `));
360
+ }
361
+ },
362
+ async input(title, o = {}) {
363
+ head(title, o.message);
364
+ if (!o.multiline) {
365
+ const a = await ask(`${o.placeholder ? paint("2", `(${o.placeholder}) `) : ""}> `, o.signal);
366
+ return a === null ? null : a || o.initial || "";
367
+ }
368
+ write(paint("2", "(a blank line ends it)\n"));
369
+ const lines = [];
370
+ for (; ; ) {
371
+ const a = await ask("> ", o.signal);
372
+ if (a === null) return lines.length ? lines.join("\n") : null;
373
+ if (!a.length) return lines.join("\n");
374
+ lines.push(a);
375
+ }
376
+ },
377
+ notify(message, level = "info") {
378
+ write(`${level === "error" ? paint("31", "\u2717") : level === "warning" ? paint("33", "!") : paint("36", "i")} ${message}
379
+ `);
380
+ }
381
+ };
382
+ }
383
+ function nodePdf() {
384
+ const load = new Function("m", "return import(m)");
385
+ (0, import_index.configurePdf)({
386
+ load: async () => {
387
+ try {
388
+ return await load("pdfjs-dist/legacy/build/pdf.mjs");
389
+ } catch (err) {
390
+ throw new Error(`reading PDFs in Node needs the pdfjs-dist package (npm i pdfjs-dist): ${err.message}`);
391
+ }
392
+ }
393
+ });
394
+ }
395
+ // Annotate the CommonJS export names for ESM import in node:
396
+ 0 && (module.exports = {
397
+ lineReader,
398
+ nodeFS,
399
+ nodePdf,
400
+ nodeStore,
401
+ terminalUI
402
+ });
package/dist/node.d.ts ADDED
@@ -0,0 +1,78 @@
1
+ import { type Interface } from "node:readline/promises";
2
+ import type { Readable, Writable } from "node:stream";
3
+ import type { AgentFS, AgentUI, WorkspaceStoreFactory } from "./index.js";
4
+ export interface NodeFSOptions {
5
+ /** Shown to the model (default "the folder <root>"). */
6
+ description?: string;
7
+ /** No write or delete. */
8
+ readonly?: boolean;
9
+ /** Folder names never listed or searched (default `.git`, `node_modules`). Files in them can still be read by path. */
10
+ ignore?: string[];
11
+ }
12
+ /**
13
+ * A folder on disk as an `AgentFS`: give it to a workspace as `dir` and the
14
+ * agent works in that folder (`openWorkspace(provider, { dir: nodeFS(process.cwd()) })`).
15
+ * Paths cannot leave the folder — neither by `..` nor through a symbolic
16
+ * link pointing outside it.
17
+ */
18
+ export declare function nodeFS(root: string, opts?: NodeFSOptions): AgentFS;
19
+ /**
20
+ * The workspace's storage in a folder (default `~/.runapps-agent`): give it
21
+ * to a workspace as `store` and its sessions, meta data and the user's
22
+ * skills — and its files, when it has no `dir` — survive the process.
23
+ * Meant for one process at a time per folder.
24
+ *
25
+ * <root>/<app>/spaces/<directory id>/files/… the directory's files
26
+ * <root>/<app>/spaces/<directory id>/meta/… its meta data (JSON)
27
+ * <root>/<app>/sessions/<directory id>/<session id>.json
28
+ *
29
+ * (Names are percent-encoded, dots included.)
30
+ */
31
+ export declare function nodeStore(root?: string): WorkspaceStoreFactory;
32
+ /** One reader of an input's lines: `ask` writes a prompt and resolves the next line (null once the input ends or `signal` aborts). */
33
+ export interface LineReader {
34
+ ask(prompt: string, signal?: AbortSignal): Promise<string | null>;
35
+ /** The readline interface underneath (its "SIGINT" event, its history). */
36
+ readonly rl: Interface;
37
+ close(): void;
38
+ }
39
+ /**
40
+ * Lines of `input`, queued: a line that arrives while nobody asks (typed
41
+ * ahead, or piped in) waits for the next question instead of being lost,
42
+ * as it is with readline's own `question()`; questions asked at once are
43
+ * answered in turn. One reader per input stream — a program's prompt loop
44
+ * and `terminalUI` share it. The prompt goes through readline, so editing
45
+ * the line keeps it on screen. A terminal is read all the time (Ctrl+C
46
+ * reaches readline's "SIGINT" even while no question is open) but does not
47
+ * keep the process alive between questions; a pipe is paused between them.
48
+ */
49
+ export declare function lineReader(opts?: {
50
+ input?: Readable;
51
+ output?: Writable & {
52
+ isTTY?: boolean;
53
+ };
54
+ }): LineReader;
55
+ export interface TerminalUIOptions {
56
+ input?: Readable;
57
+ output?: Writable & {
58
+ isTTY?: boolean;
59
+ };
60
+ /** A readline interface the app already has: questions go through its question(). Prefer `ask` with a `lineReader`. */
61
+ rl?: Interface;
62
+ /**
63
+ * How a line is read, for an app with its own input loop: write `prompt`, resolve the line the
64
+ * user typed, or null when `signal` aborts or the input ends. Default: `lineReader({ input, output }).ask`.
65
+ */
66
+ ask?: (prompt: string, signal?: AbortSignal) => Promise<string | null>;
67
+ }
68
+ /**
69
+ * `AgentUI` in a terminal: confirmations as y/N, choices as a numbered
70
+ * list, free text on a line (a blank line ends multi-line text). A
71
+ * question whose run is stopped is dismissed.
72
+ */
73
+ export declare function terminalUI(opts?: TerminalUIOptions): AgentUI;
74
+ /**
75
+ * Reads PDFs with the pdfjs-dist package (`npm i pdfjs-dist`) instead of
76
+ * the CDN copy a browser loads.
77
+ */
78
+ export declare function nodePdf(): void;