@runappsai/agent 0.1.11 → 0.1.15
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 +1 -1
- package/dist/agent-core.umd.js +90 -87
- package/dist/agent.d.ts +5 -1
- package/dist/agent.js +11 -7
- package/dist/agent.umd.js +130 -104
- package/dist/chat.d.ts +40 -1
- package/dist/chat.js +375 -16
- package/dist/dom.d.ts +28 -1
- package/dist/dom.js +38 -1
- package/dist/files-panel.js +2 -2
- package/dist/index.cjs +514 -37
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/schedule.d.ts +152 -0
- package/dist/schedule.js +505 -0
- package/dist/types.d.ts +3 -0
- package/dist/ui.cjs +932 -13
- package/dist/ui.d.ts +1 -0
- package/docs/chat-ui.md +23 -1
- package/package.json +1 -1
package/dist/dom.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export declare function h<K extends keyof HTMLElementTagNameMap>(tag: K, cls?: string, text?: string): HTMLElementTagNameMap[K];
|
|
2
2
|
export declare const svg: (size: number, body: string, stroke?: number) => string;
|
|
3
3
|
export declare const I: {
|
|
4
|
+
clock: (s?: number) => string;
|
|
5
|
+
play: (s?: number) => string;
|
|
6
|
+
pause: (s?: number) => string;
|
|
7
|
+
pencil: (s?: number) => string;
|
|
4
8
|
tick: (s?: number) => string;
|
|
5
9
|
enter: (s?: number) => string;
|
|
6
10
|
lock: (s?: number) => string;
|
|
@@ -78,7 +82,30 @@ export declare function modalInput(root: HTMLElement, title: string, opts: {
|
|
|
78
82
|
initial?: string;
|
|
79
83
|
placeholder?: string;
|
|
80
84
|
}): Promise<string | null>;
|
|
81
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* A file dialog the chat uses instead of the browser's own chooser and
|
|
87
|
+
* downloads: on RunApps, the platform's dialog (the user's files or this
|
|
88
|
+
* device). Set by `renderChat({ fileDialog })`; otherwise the page's
|
|
89
|
+
* `puter.ui.openFiles` / `saveFile` when the RunApps shim is loaded.
|
|
90
|
+
*/
|
|
91
|
+
export interface FileDialog {
|
|
92
|
+
/** Files to open; [] when cancelled. */
|
|
93
|
+
openFiles(opts: {
|
|
94
|
+
accept?: string;
|
|
95
|
+
multiple?: boolean;
|
|
96
|
+
}): Promise<File[]>;
|
|
97
|
+
/** Save a file (the dialog may download it); resolves null when cancelled. */
|
|
98
|
+
saveFile(blob: Blob, name: string): Promise<unknown>;
|
|
99
|
+
}
|
|
100
|
+
/** Used by renderChat: the host's dialog, `false` for the browser's own, undefined to detect the platform's. */
|
|
101
|
+
export declare function setFileDialog(d: FileDialog | false | undefined): void;
|
|
102
|
+
/**
|
|
103
|
+
* Asks for files the way `input` would (its accept and multiple), through
|
|
104
|
+
* the file dialog when there is one, else by clicking the input (whose
|
|
105
|
+
* change handler takes over). `onFiles` hears the dialog's choice.
|
|
106
|
+
*/
|
|
107
|
+
export declare function chooseFiles(input: HTMLInputElement, onFiles: (files: File[]) => void): void;
|
|
108
|
+
/** Hands the user a file to save: the file dialog when there is one, else a download. */
|
|
82
109
|
export declare function downloadBlob(name: string, data: string | Uint8Array, type?: string): void;
|
|
83
110
|
/** Markdown → DOM, with a header (language, copy) on each code block and a scroll wrapper on tables. */
|
|
84
111
|
export declare function renderMD(el: HTMLElement, md: string, streaming: boolean): void;
|
package/dist/dom.js
CHANGED
|
@@ -12,6 +12,10 @@ export function h(tag, cls, text) {
|
|
|
12
12
|
}
|
|
13
13
|
export const svg = (size, body, stroke = 2) => `<svg width="${size}" height="${size}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${stroke}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${body}</svg>`;
|
|
14
14
|
export const I = {
|
|
15
|
+
clock: (s = 14) => svg(s, '<circle cx="12" cy="13" r="8"/><path d="M12 9v4l2 2"/><path d="M5 3 2 6"/><path d="m22 6-3-3"/>'),
|
|
16
|
+
play: (s = 13) => svg(s, '<polygon points="6 3 20 12 6 21 6 3"/>'),
|
|
17
|
+
pause: (s = 13) => svg(s, '<rect x="14" y="4" width="4" height="16" rx="1"/><rect x="6" y="4" width="4" height="16" rx="1"/>'),
|
|
18
|
+
pencil: (s = 13) => svg(s, '<path d="M21.17 6.81a1 1 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5z"/>'),
|
|
15
19
|
tick: (s = 14) => svg(s, '<path d="M20 6 9 17l-5-5"/>'),
|
|
16
20
|
enter: (s = 14) => svg(s, '<polyline points="9 10 4 15 9 20"/><path d="M20 4v7a4 4 0 0 1-4 4H4"/>'),
|
|
17
21
|
lock: (s = 12) => svg(s, '<rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/>'),
|
|
@@ -122,9 +126,42 @@ export async function modalInput(root, title, opts) {
|
|
|
122
126
|
const ok = await modal(root, { title, body: [field], ok: opts.ok, cancel: opts.cancel, focus: field, submitOnEnter: true });
|
|
123
127
|
return ok ? field.value.trim() || null : null;
|
|
124
128
|
}
|
|
125
|
-
|
|
129
|
+
let fileDialogOpt;
|
|
130
|
+
/** Used by renderChat: the host's dialog, `false` for the browser's own, undefined to detect the platform's. */
|
|
131
|
+
export function setFileDialog(d) { fileDialogOpt = d; }
|
|
132
|
+
function fileDialog() {
|
|
133
|
+
if (fileDialogOpt === false)
|
|
134
|
+
return undefined;
|
|
135
|
+
if (fileDialogOpt)
|
|
136
|
+
return fileDialogOpt;
|
|
137
|
+
const ui = globalThis.puter?.ui;
|
|
138
|
+
return typeof ui?.openFiles === "function" && typeof ui?.saveFile === "function" ? ui : undefined;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Asks for files the way `input` would (its accept and multiple), through
|
|
142
|
+
* the file dialog when there is one, else by clicking the input (whose
|
|
143
|
+
* change handler takes over). `onFiles` hears the dialog's choice.
|
|
144
|
+
*/
|
|
145
|
+
export function chooseFiles(input, onFiles) {
|
|
146
|
+
const d = fileDialog();
|
|
147
|
+
if (!d) {
|
|
148
|
+
input.click();
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
d.openFiles({ accept: input.accept || undefined, multiple: input.multiple }).then((files) => { if (files?.length)
|
|
152
|
+
onFiles(files); }, () => input.click());
|
|
153
|
+
}
|
|
154
|
+
/** Hands the user a file to save: the file dialog when there is one, else a download. */
|
|
126
155
|
export function downloadBlob(name, data, type) {
|
|
127
156
|
const blob = new Blob([data], { type: type || "application/octet-stream" });
|
|
157
|
+
const d = fileDialog();
|
|
158
|
+
if (d) {
|
|
159
|
+
void d.saveFile(blob, name).catch(() => plainDownload(blob, name));
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
plainDownload(blob, name);
|
|
163
|
+
}
|
|
164
|
+
function plainDownload(blob, name) {
|
|
128
165
|
const url = URL.createObjectURL(blob);
|
|
129
166
|
const a = h("a");
|
|
130
167
|
a.href = url;
|
package/dist/files-panel.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// delete. Modelled on the harness app's sidebar + editor pane, in one
|
|
5
5
|
// panel beside the transcript.
|
|
6
6
|
import { buildZip } from "./index.js";
|
|
7
|
-
import { h, I, modalConfirm, modalInput, downloadBlob, renderMD } from "./dom.js";
|
|
7
|
+
import { h, I, modalConfirm, modalInput, downloadBlob, chooseFiles, renderMD } from "./dom.js";
|
|
8
8
|
const IMAGE_RE = /\.(png|jpe?g|gif|webp|svg|bmp|avif)$/i;
|
|
9
9
|
const basename = (p) => p.slice(p.lastIndexOf("/") + 1);
|
|
10
10
|
const dirname = (p) => p.slice(0, p.lastIndexOf("/")) || "/";
|
|
@@ -69,7 +69,7 @@ export function filesPanel(opts) {
|
|
|
69
69
|
fileInput.type = "file";
|
|
70
70
|
fileInput.multiple = true;
|
|
71
71
|
fileInput.style.display = "none";
|
|
72
|
-
const uploadBtn = ibtn(I.upload(), t.upload, () => fileInput
|
|
72
|
+
const uploadBtn = ibtn(I.upload(), t.upload, () => chooseFiles(fileInput, (picked) => void upload(picked)));
|
|
73
73
|
const zipBtn = ibtn(I.download(), t.downloadZip, () => void downloadFolder("/"));
|
|
74
74
|
const newBtn = ibtn(I.filePlus(14), t.newFile, () => void newFile());
|
|
75
75
|
const refreshBtn = ibtn(I.refresh(), t.refresh, () => void refresh());
|