@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.
- package/LICENSE +21 -0
- package/README.md +162 -2
- package/dist/agent-core.umd.js +266 -0
- package/dist/agent.d.ts +222 -0
- package/dist/agent.js +1331 -0
- package/dist/agent.umd.js +732 -0
- package/dist/browser.d.ts +2 -0
- package/dist/browser.js +4 -0
- package/dist/chat-theme.d.ts +24 -0
- package/dist/chat-theme.js +101 -0
- package/dist/chat.d.ts +271 -0
- package/dist/chat.js +4099 -0
- package/dist/compaction.d.ts +48 -0
- package/dist/compaction.js +208 -0
- package/dist/completion.d.ts +29 -0
- package/dist/completion.js +88 -0
- package/dist/context.d.ts +44 -0
- package/dist/context.js +177 -0
- package/dist/debug-panel.d.ts +40 -0
- package/dist/debug-panel.js +262 -0
- package/dist/dialogs.d.ts +7 -0
- package/dist/dialogs.js +231 -0
- package/dist/directory-fs.d.ts +5 -0
- package/dist/directory-fs.js +118 -0
- package/dist/dom.d.ts +83 -0
- package/dist/dom.js +163 -0
- package/dist/edit.d.ts +22 -0
- package/dist/edit.js +133 -0
- package/dist/file-guard.d.ts +46 -0
- package/dist/file-guard.js +153 -0
- package/dist/file-tools.d.ts +16 -0
- package/dist/file-tools.js +339 -0
- package/dist/files-panel.d.ts +60 -0
- package/dist/files-panel.js +613 -0
- package/dist/index.cjs +4848 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +44 -0
- package/dist/json-schema.d.ts +3 -0
- package/dist/json-schema.js +141 -0
- package/dist/llm.d.ts +95 -0
- package/dist/llm.js +5 -0
- package/dist/markdown.d.ts +4 -0
- package/dist/markdown.js +265 -0
- package/dist/mcp.d.ts +82 -0
- package/dist/mcp.js +325 -0
- package/dist/node.cjs +402 -0
- package/dist/node.d.ts +78 -0
- package/dist/node.js +432 -0
- package/dist/pdf.d.ts +52 -0
- package/dist/pdf.js +77 -0
- package/dist/provider.d.ts +135 -0
- package/dist/provider.js +181 -0
- package/dist/sandbox.d.ts +33 -0
- package/dist/sandbox.js +219 -0
- package/dist/select.d.ts +30 -0
- package/dist/select.js +185 -0
- package/dist/skill-zips.d.ts +28 -0
- package/dist/skill-zips.js +123 -0
- package/dist/skills.d.ts +20 -0
- package/dist/skills.js +111 -0
- package/dist/templates.d.ts +24 -0
- package/dist/templates.js +136 -0
- package/dist/tool.d.ts +28 -0
- package/dist/tool.js +102 -0
- package/dist/types.d.ts +571 -0
- package/dist/types.js +7 -0
- package/dist/ui.cjs +6247 -0
- package/dist/ui.d.ts +6 -0
- package/dist/ui.js +11 -0
- package/dist/vlist.d.ts +80 -0
- package/dist/vlist.js +277 -0
- package/dist/workspace.d.ts +343 -0
- package/dist/workspace.js +1203 -0
- package/dist/zip.d.ts +26 -0
- package/dist/zip.js +204 -0
- package/docs/agent.md +228 -0
- package/docs/chat-ui.md +307 -0
- package/docs/node.md +135 -0
- package/docs/providers.md +176 -0
- package/docs/reference.md +143 -0
- package/docs/skills.md +131 -0
- package/docs/tools.md +254 -0
- package/docs/workspace.md +198 -0
- package/package.json +59 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 RunJobs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,163 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @runappsai/agent
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An agent harness: the model ↔ tool loop, a file workspace with skills, saved sessions, context compaction, a JavaScript sandbox — and, separately, a complete chat UI for web pages and helpers for command-line tools. It works with any OpenAI-compatible model API ([RunApps](https://www.runapps.ai), OpenAI, DeepSeek, OpenRouter, your own proxy) and has no runtime dependencies.
|
|
4
|
+
|
|
5
|
+
| Import | What | Runs in |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| `@runappsai/agent` | The core: `createAgent`, `openWorkspace`, providers, tools, skills | Browsers, Node, Deno, workers |
|
|
8
|
+
| `@runappsai/agent/ui` | The chat UI: `renderChat`, dropdowns, themes | Browsers |
|
|
9
|
+
| `@runappsai/agent/node` | A folder as the workspace, storage on disk, terminal dialogs | Node 18+ |
|
|
10
|
+
|
|
11
|
+
Modelled on [pi](https://pi.dev) (MIT): the compaction prompts, edit matching, template arguments and skills wording come from it.
|
|
12
|
+
|
|
13
|
+
**Status: test phase** — the API may still change.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm i @runappsai/agent
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
import { createAgent, openWorkspace, defineTool, openAIProvider } from "@runappsai/agent";
|
|
23
|
+
import { renderChat } from "@runappsai/agent/ui"; // web pages
|
|
24
|
+
import { nodeFS, nodeStore, terminalUI } from "@runappsai/agent/node"; // Node
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or in a page, with no build step — the core and the UI in one script, on `window.RunAppsAgent`:
|
|
28
|
+
|
|
29
|
+
```html
|
|
30
|
+
<script src="https://www.runapps.ai/sdk/agent-latest.js"></script>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
(`dist/agent-core.umd.js`, also `@runappsai/agent/browser/core`, is the core alone.)
|
|
34
|
+
|
|
35
|
+
## Quick start: a chat in five minutes
|
|
36
|
+
|
|
37
|
+
```html
|
|
38
|
+
<div id="assistant" style="height: 640px"></div>
|
|
39
|
+
|
|
40
|
+
<script src="https://www.runapps.ai/sdk/agent-latest.js"></script>
|
|
41
|
+
<script type="module">
|
|
42
|
+
// With npm: import { openWorkspace, openAIProvider, defineTool } from "@runappsai/agent";
|
|
43
|
+
// import { renderChat } from "@runappsai/agent/ui";
|
|
44
|
+
const { renderChat, openWorkspace, openAIProvider, defineTool } = RunAppsAgent;
|
|
45
|
+
|
|
46
|
+
// 1. Where the model calls go. Keep API keys on your server: point at your own proxy.
|
|
47
|
+
const provider = openAIProvider({ baseURL: "/api/llm", models: "fetch" });
|
|
48
|
+
|
|
49
|
+
// 2. A tool of your app's (optional).
|
|
50
|
+
const getTime = defineTool({
|
|
51
|
+
name: "get_time",
|
|
52
|
+
description: "The current date and time in the user's timezone.",
|
|
53
|
+
execute: () => new Date().toString(),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// 3. The chat. Each conversation gets its own directory of files in IndexedDB.
|
|
57
|
+
const chat = renderChat(document.getElementById("assistant"), {
|
|
58
|
+
provider,
|
|
59
|
+
model: "gpt-4.1",
|
|
60
|
+
appName: "My app",
|
|
61
|
+
instructions: "You are the assistant inside My app. Be brief.",
|
|
62
|
+
tools: [getTime],
|
|
63
|
+
workspace: (sessionId) => openWorkspace(provider, { id: sessionId }),
|
|
64
|
+
suggestions: ["What time is it?", "Write a haiku about Mondays"],
|
|
65
|
+
});
|
|
66
|
+
await chat.ready;
|
|
67
|
+
</script>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
That is a full assistant: streaming Markdown replies, folded tool calls, a live "what it is doing" status, file attachments, a files panel, a skills menu, saved conversations, slash commands, settings (model, thinking level, limits), rewind, light/dark themes.
|
|
71
|
+
|
|
72
|
+
With [RunApps](https://www.runapps.ai) instead, users sign in and pay for their own usage — no proxy and no key on your side:
|
|
73
|
+
|
|
74
|
+
```html
|
|
75
|
+
<script src="https://www.runapps.ai/sdk/latest.js"></script>
|
|
76
|
+
<script src="https://www.runapps.ai/sdk/agent-latest.js"></script>
|
|
77
|
+
<script type="module">
|
|
78
|
+
const client = new RunApps({ project: "my-app" });
|
|
79
|
+
const chat = RunAppsAgent.renderChat(document.getElementById("assistant"), {
|
|
80
|
+
client,
|
|
81
|
+
workspace: (id) => RunAppsAgent.openWorkspace(client, { id }),
|
|
82
|
+
});
|
|
83
|
+
</script>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Quick start: a command-line agent
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
import { createAgent, openAIProvider, openWorkspace } from "@runappsai/agent";
|
|
90
|
+
import { nodeFS, nodeStore, terminalUI } from "@runappsai/agent/node";
|
|
91
|
+
|
|
92
|
+
const provider = openAIProvider({ baseURL: process.env.OPENAI_BASE_URL, apiKey: process.env.OPENAI_API_KEY, models: "fetch" });
|
|
93
|
+
const workspace = await openWorkspace(provider, {
|
|
94
|
+
id: "my-project",
|
|
95
|
+
dir: nodeFS(process.cwd()), // the agent works in this folder
|
|
96
|
+
store: nodeStore(), // sessions and skills in ~/.runapps-agent
|
|
97
|
+
});
|
|
98
|
+
const agent = createAgent(provider, { workspace, ui: terminalUI() }); // confirmations as y/N in the terminal
|
|
99
|
+
|
|
100
|
+
agent.on("text_delta", (e) => process.stdout.write(e.delta));
|
|
101
|
+
await agent.prompt(process.argv.slice(2).join(" "));
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
`examples/cli.mjs` is a complete terminal chat: streaming, tool calls, confirmations, sessions you can resume, Ctrl+C to stop. See [Node and the command line](docs/node.md).
|
|
105
|
+
|
|
106
|
+
## Quick start: an agent without any UI
|
|
107
|
+
|
|
108
|
+
```js
|
|
109
|
+
import { createAgent, defineTool, openAIProvider } from "@runappsai/agent";
|
|
110
|
+
|
|
111
|
+
const provider = openAIProvider({ baseURL: "https://api.deepseek.com/v1", apiKey: process.env.DEEPSEEK_KEY });
|
|
112
|
+
|
|
113
|
+
const addTodo = defineTool({
|
|
114
|
+
name: "add_todo",
|
|
115
|
+
description: "Add an item to the user's todo list.",
|
|
116
|
+
parameters: {
|
|
117
|
+
type: "object",
|
|
118
|
+
properties: { text: { type: "string" }, due: { type: "string", description: "YYYY-MM-DD" } },
|
|
119
|
+
required: ["text"],
|
|
120
|
+
additionalProperties: false,
|
|
121
|
+
},
|
|
122
|
+
execute: async ({ text, due }) => { await db.todos.add({ text, due }); return `Added "${text}".`; },
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
const agent = createAgent(provider, {
|
|
126
|
+
model: "deepseek-chat",
|
|
127
|
+
instructions: "You manage the user's todo list.",
|
|
128
|
+
tools: [addTodo],
|
|
129
|
+
sandbox: false, // no run_js
|
|
130
|
+
askUser: false, // no questions back to a user
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
agent.on("text_delta", (e) => process.stdout.write(e.delta));
|
|
134
|
+
const result = await agent.prompt("Add 'ship v2' for next Friday");
|
|
135
|
+
console.log(result.reason, result.usage);
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Documentation
|
|
139
|
+
|
|
140
|
+
| Guide | What is in it |
|
|
141
|
+
|---|---|
|
|
142
|
+
| [Providers](docs/providers.md) | Connecting a model API: `openAIProvider`, `runappsProvider`, writing your own, errors and retries |
|
|
143
|
+
| [The agent](docs/agent.md) | Runs, steering and queueing, stopping and continuing, events, permissions and dialogs, sessions, compaction, all options |
|
|
144
|
+
| [Tools](docs/tools.md) | `defineTool`, schemas, results, confirmations, progress, calls that go nowhere, MCP servers, the built-in tools |
|
|
145
|
+
| [Workspace and files](docs/workspace.md) | The virtual directory, mounting your app's data, a real folder, memory and project notes, prompt templates, PDFs, change events |
|
|
146
|
+
| [Skills](docs/skills.md) | Skill folders and zips, the app's skills, lazy skills, the user's skills, writing descriptions |
|
|
147
|
+
| [Chat UI](docs/chat-ui.md) | `renderChat` options and handle, what the UI does, commands, one-conversation mode, theming, dropdowns, debug |
|
|
148
|
+
| [Node and the command line](docs/node.md) | A folder as the workspace, storage on disk, terminal dialogs, PDFs, the CLI example |
|
|
149
|
+
| [API reference](docs/reference.md) | Every export in one place |
|
|
150
|
+
|
|
151
|
+
`examples/chat/index.html` is a complete page using everything (serve the package root and open `/examples/chat/index.html`); `examples/cli.mjs` is the terminal version.
|
|
152
|
+
|
|
153
|
+
## Development
|
|
154
|
+
|
|
155
|
+
```sh
|
|
156
|
+
npm install
|
|
157
|
+
npm run build # dist/*.js (ESM), dist/{index,ui,node}.cjs, dist/agent.umd.js + agent-core.umd.js (browser)
|
|
158
|
+
npm test # node:test on the built output, model calls mocked
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## License
|
|
162
|
+
|
|
163
|
+
MIT
|