@runappsai/agent 0.0.0-stage → 0.1.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.
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 +4097 -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 +6246 -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/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
- # Temporary Holding Version
1
+ # @runappsai/agent
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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