@runappsai/agent 0.1.11 → 0.2.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 +1 -1
- package/dist/agent-core.umd.js +90 -87
- package/dist/agent.d.ts +25 -1
- package/dist/agent.js +11 -7
- package/dist/agent.umd.js +140 -107
- package/dist/chat.d.ts +77 -8
- package/dist/chat.js +526 -49
- package/dist/debug-panel.d.ts +1 -1
- package/dist/debug-panel.js +1 -1
- package/dist/dialogs.js +43 -1
- package/dist/dom.d.ts +28 -1
- package/dist/dom.js +38 -1
- package/dist/files-panel.js +2 -2
- package/dist/index.cjs +555 -38
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -0
- package/dist/schedule.d.ts +152 -0
- package/dist/schedule.js +505 -0
- package/dist/types.d.ts +39 -2
- package/dist/ui.cjs +1094 -43
- package/dist/ui.d.ts +2 -0
- package/dist/vlist.d.ts +6 -0
- package/dist/vlist.js +16 -0
- package/docs/chat-ui.md +72 -1
- package/docs/tools.md +1 -0
- package/package.json +1 -1
package/dist/chat.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { type FileDialog } from "./dom.js";
|
|
1
2
|
import { type SelectBox } from "./select.js";
|
|
3
|
+
import { type ScheduleStore, type ScheduleLimits } from "./schedule.js";
|
|
2
4
|
import { CHAT_PALETTES, type ChatPalette, type ChatVars } from "./chat-theme.js";
|
|
3
|
-
import {
|
|
4
|
-
import type { ModelProvider, RunAppsClientLike, Workspace, AgentOptions, AgentUI, RunResult } from "./index.js";
|
|
5
|
+
import type { ChatAgent, ModelProvider, RunAppsClientLike, Workspace, AgentOptions, AgentUI, RunResult } from "./index.js";
|
|
5
6
|
export interface ChatOptions extends Omit<AgentOptions, "workspace"> {
|
|
6
7
|
/**
|
|
7
8
|
* Where the model calls go (required unless `agent` is given): a
|
|
@@ -18,7 +19,7 @@ export interface ChatOptions extends Omit<AgentOptions, "workspace"> {
|
|
|
18
19
|
*/
|
|
19
20
|
workspace?: Workspace | null | ((sessionId: string) => Workspace | Promise<Workspace>);
|
|
20
21
|
/** An agent the host made itself; its own `ui` answers questions, and the session menu is off. */
|
|
21
|
-
agent?:
|
|
22
|
+
agent?: ChatAgent;
|
|
22
23
|
/**
|
|
23
24
|
* Which session to open: `true` (default) continues the one this app
|
|
24
25
|
* last had open in this browser (a new chat when there is none), a
|
|
@@ -102,6 +103,16 @@ export interface ChatOptions extends Omit<AgentOptions, "workspace"> {
|
|
|
102
103
|
* text files go inline. `false` turns the feature off.
|
|
103
104
|
*/
|
|
104
105
|
attachments?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* The dialog for picking files (attach, upload, skill zips) and saving
|
|
108
|
+
* them (downloads from the Files panel, the transcript). Default: the
|
|
109
|
+
* RunApps platform's dialog when the page has it (`puter.ui.openFiles` /
|
|
110
|
+
* `saveFile`, from the shim), which offers the user's files and this
|
|
111
|
+
* device; else the browser's own chooser and downloads. An app that
|
|
112
|
+
* loads the shim on first use passes its own; `false` keeps the
|
|
113
|
+
* browser's.
|
|
114
|
+
*/
|
|
115
|
+
fileDialog?: FileDialog | false;
|
|
105
116
|
/** Where attached files are saved in the directory (default `/uploads`). */
|
|
106
117
|
uploadsDir?: string;
|
|
107
118
|
/**
|
|
@@ -112,6 +123,24 @@ export interface ChatOptions extends Omit<AgentOptions, "workspace"> {
|
|
|
112
123
|
* own; `false` hides it, `true` shows it anyway.
|
|
113
124
|
*/
|
|
114
125
|
webSearch?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Scheduled tasks (default off): a *Scheduled* button in the header lists
|
|
128
|
+
* them (add, edit, pause, run now, delete, open a task's conversation),
|
|
129
|
+
* and the agent gets tools to list, add, change and remove them. A task
|
|
130
|
+
* is a prompt run at set times — once, every N minutes, daily at a time
|
|
131
|
+
* (on chosen weekdays), or by cron — in a conversation of its own. They
|
|
132
|
+
* run only while the app is open, each when it is due and the chat is
|
|
133
|
+
* idle (nothing running, no question open, the user not typing); one
|
|
134
|
+
* missed while the page was closed runs once on the next visit. Kept per
|
|
135
|
+
* app in localStorage unless `store` is given. `minMinutes` (default 5)
|
|
136
|
+
* is the shortest repeat, `maxTasks` (default 20) the most tasks;
|
|
137
|
+
* `tools: false` leaves the agent without the tools (the user manages
|
|
138
|
+
* them alone).
|
|
139
|
+
*/
|
|
140
|
+
schedule?: boolean | (ScheduleLimits & {
|
|
141
|
+
store?: ScheduleStore;
|
|
142
|
+
tools?: boolean;
|
|
143
|
+
});
|
|
115
144
|
/**
|
|
116
145
|
* Called when a link in the conversation (a reply, its thinking, a tool
|
|
117
146
|
* card) is clicked, before the chat's own handling: return `true` when you
|
|
@@ -121,7 +150,16 @@ export interface ChatOptions extends Omit<AgentOptions, "workspace"> {
|
|
|
121
150
|
onLink?: (href: string, text: string) => boolean | void;
|
|
122
151
|
/** A tool card's file path becomes a link that calls this. */
|
|
123
152
|
onOpenFile?: (path: string) => void;
|
|
124
|
-
/**
|
|
153
|
+
/**
|
|
154
|
+
* The user's say over tool permissions (default on): an "Always allow
|
|
155
|
+
* (this app)" answer on each permission question, which lets every tool
|
|
156
|
+
* run without asking from then on, and the "Tool permissions" choice in
|
|
157
|
+
* the settings panel, where it is turned off again. The choice is kept per app; the app's `permissions`
|
|
158
|
+
* ("ask" by default, "auto" to start in auto) is what a user who never
|
|
159
|
+
* chose gets. `false` for an app that decides when to ask itself (its own
|
|
160
|
+
* settings, its tools' `confirm`); hidden as well when `permissions` is a
|
|
161
|
+
* function or the chat was given its own `agent`.
|
|
162
|
+
*/
|
|
125
163
|
permissionsSetting?: boolean;
|
|
126
164
|
/**
|
|
127
165
|
* Your app's own state to put back on a rewind (an editor's text, a form):
|
|
@@ -168,7 +206,36 @@ export interface ChatOptions extends Omit<AgentOptions, "workspace"> {
|
|
|
168
206
|
*/
|
|
169
207
|
composerActions?: Array<HTMLElement | ComposerAction>;
|
|
170
208
|
/** Called with each session's agent as the chat opens it (the first one, a new chat, a resumed one). */
|
|
171
|
-
onSession?: (agent:
|
|
209
|
+
onSession?: (agent: ChatAgent) => void;
|
|
210
|
+
/**
|
|
211
|
+
* Steering and queueing while a run is going (default on). `false`: the
|
|
212
|
+
* composer offers only Stop then, Enter sends nothing and what is typed
|
|
213
|
+
* stays in the box — for an agent that takes one message at a time.
|
|
214
|
+
*/
|
|
215
|
+
queue?: boolean;
|
|
216
|
+
/**
|
|
217
|
+
* The actions under a message, each on unless `false`: `rewind` (a user
|
|
218
|
+
* message: back to it, its text in the composer), `retry` ("Answer again"
|
|
219
|
+
* under a reply) and `delete` (remove the turn, which needs the agent's `remove`).
|
|
220
|
+
*/
|
|
221
|
+
replyActions?: {
|
|
222
|
+
rewind?: boolean;
|
|
223
|
+
retry?: boolean;
|
|
224
|
+
delete?: boolean;
|
|
225
|
+
};
|
|
226
|
+
/** Elements of your own at the start of the header, before the title (a button that opens the host's list of conversations). */
|
|
227
|
+
headerStart?: HTMLElement[];
|
|
228
|
+
/** The header's Clear button of a one-chat chat (default on); `false` when the host clears or deletes conversations itself. */
|
|
229
|
+
clearButton?: boolean;
|
|
230
|
+
/** The built-in slash commands to keep, by name ("help", "compact", "model", "context", "export", …). Default: all that apply. */
|
|
231
|
+
commands?: string[];
|
|
232
|
+
/**
|
|
233
|
+
* Uploads an attached image and returns its address: the message then
|
|
234
|
+
* carries that address instead of the image's bytes as a data URL (small
|
|
235
|
+
* messages; the host's server reads the image from where it was put).
|
|
236
|
+
* A rejection drops the image and tells the user why.
|
|
237
|
+
*/
|
|
238
|
+
uploadImage?: (file: File) => Promise<string>;
|
|
172
239
|
}
|
|
173
240
|
/** A setting of the host's in the gear's panel. */
|
|
174
241
|
export type SettingsField = {
|
|
@@ -214,7 +281,7 @@ export interface ComposerAction {
|
|
|
214
281
|
}
|
|
215
282
|
export interface ChatHandle {
|
|
216
283
|
/** The current session's agent (set once `ready` resolves when the workspace is made per session). */
|
|
217
|
-
readonly agent:
|
|
284
|
+
readonly agent: ChatAgent;
|
|
218
285
|
/** Resolves once the first session is open and drawn. */
|
|
219
286
|
readonly ready: Promise<void>;
|
|
220
287
|
readonly element: HTMLElement;
|
|
@@ -226,9 +293,9 @@ export interface ChatHandle {
|
|
|
226
293
|
/** Puts `text` into the composer at the cursor (spaced from what is around it), keeping what was typed. */
|
|
227
294
|
insertText(text: string): void;
|
|
228
295
|
/** Starts a fresh conversation (a new agent with the same options). */
|
|
229
|
-
newSession(): Promise<
|
|
296
|
+
newSession(): Promise<ChatAgent>;
|
|
230
297
|
/** Continues a saved session of the workspace. */
|
|
231
|
-
resume(id: string): Promise<
|
|
298
|
+
resume(id: string): Promise<ChatAgent>;
|
|
232
299
|
/** Deletes a saved session (and the directory made for it); the current one is replaced by a new chat. */
|
|
233
300
|
deleteSession(id: string): Promise<void>;
|
|
234
301
|
/**
|
|
@@ -255,6 +322,8 @@ export interface ChatHandle {
|
|
|
255
322
|
setDebug(on: boolean): void;
|
|
256
323
|
/** Changes a `composerActions` button by its id: label, icon, title, hidden, disabled, onClick. */
|
|
257
324
|
updateComposerAction(id: string, patch: Partial<Omit<ComposerAction, "id">>): void;
|
|
325
|
+
/** Changes the header's title while mounted (a conversation the host names once it knows what it is about). */
|
|
326
|
+
setTitle(title: string): void;
|
|
258
327
|
/** Changes the look while mounted: light/dark, palette, token overrides (each left out stays). */
|
|
259
328
|
setAppearance(opts: {
|
|
260
329
|
theme?: "auto" | "light" | "dark";
|