orbitx 0.2.1 → 0.2.4
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 +26 -0
- package/dist/core/ai-provider.d.ts +31 -1
- package/dist/core/ai-provider.d.ts.map +1 -1
- package/dist/core/ai-provider.js.map +1 -1
- package/dist/core/anthropic-provider.d.ts +1 -0
- package/dist/core/anthropic-provider.d.ts.map +1 -1
- package/dist/core/anthropic-provider.js +83 -3
- package/dist/core/anthropic-provider.js.map +1 -1
- package/dist/core/base-agent.d.ts +13 -0
- package/dist/core/base-agent.d.ts.map +1 -1
- package/dist/core/base-agent.js +77 -109
- package/dist/core/base-agent.js.map +1 -1
- package/dist/core/deepseek-provider.d.ts +2 -0
- package/dist/core/deepseek-provider.d.ts.map +1 -1
- package/dist/core/deepseek-provider.js +56 -2
- package/dist/core/deepseek-provider.js.map +1 -1
- package/dist/core/image-describer.d.ts +7 -1
- package/dist/core/image-describer.d.ts.map +1 -1
- package/dist/core/image-describer.js +5 -1
- package/dist/core/image-describer.js.map +1 -1
- package/dist/core/ollama-provider.d.ts +1 -0
- package/dist/core/ollama-provider.d.ts.map +1 -1
- package/dist/core/ollama-provider.js +45 -1
- package/dist/core/ollama-provider.js.map +1 -1
- package/dist/core/openai-provider.d.ts +1 -0
- package/dist/core/openai-provider.d.ts.map +1 -1
- package/dist/core/openai-provider.js +54 -1
- package/dist/core/openai-provider.js.map +1 -1
- package/dist/core/think-effort.d.ts +21 -0
- package/dist/core/think-effort.d.ts.map +1 -0
- package/dist/core/think-effort.js +19 -0
- package/dist/core/think-effort.js.map +1 -0
- package/dist/core/worker-agent.d.ts +43 -0
- package/dist/core/worker-agent.d.ts.map +1 -0
- package/dist/core/worker-agent.js +40 -0
- package/dist/core/worker-agent.js.map +1 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/templates/simple.d.ts +2 -0
- package/dist/templates/simple.d.ts.map +1 -1
- package/dist/templates/simple.js.map +1 -1
- package/dist/tests/index.d.ts +1 -0
- package/dist/tests/index.d.ts.map +1 -1
- package/dist/tests/index.js +1 -0
- package/dist/tests/index.js.map +1 -1
- package/dist/tests/tools/agent/agent-tools.test.d.ts +2 -0
- package/dist/tests/tools/agent/agent-tools.test.d.ts.map +1 -0
- package/dist/tests/tools/agent/agent-tools.test.js +156 -0
- package/dist/tests/tools/agent/agent-tools.test.js.map +1 -0
- package/dist/tools/agent/hire.d.ts +6 -0
- package/dist/tools/agent/hire.d.ts.map +1 -0
- package/dist/tools/agent/hire.js +32 -0
- package/dist/tools/agent/hire.js.map +1 -0
- package/dist/tools/agent/index.d.ts +27 -0
- package/dist/tools/agent/index.d.ts.map +1 -0
- package/dist/tools/agent/index.js +31 -0
- package/dist/tools/agent/index.js.map +1 -0
- package/dist/tools/agent/interaction.d.ts +25 -0
- package/dist/tools/agent/interaction.d.ts.map +1 -0
- package/dist/tools/agent/interaction.js +14 -0
- package/dist/tools/agent/interaction.js.map +1 -0
- package/dist/tools/agent/list.d.ts +5 -0
- package/dist/tools/agent/list.d.ts.map +1 -0
- package/dist/tools/agent/list.js +16 -0
- package/dist/tools/agent/list.js.map +1 -0
- package/dist/tools/agent/prompt.d.ts +6 -0
- package/dist/tools/agent/prompt.d.ts.map +1 -0
- package/dist/tools/agent/prompt.js +73 -0
- package/dist/tools/agent/prompt.js.map +1 -0
- package/dist/tools/agent/registry.d.ts +33 -0
- package/dist/tools/agent/registry.d.ts.map +1 -0
- package/dist/tools/agent/registry.js +68 -0
- package/dist/tools/agent/registry.js.map +1 -0
- package/dist/tools/agent/report.d.ts +12 -0
- package/dist/tools/agent/report.d.ts.map +1 -0
- package/dist/tools/agent/report.js +31 -0
- package/dist/tools/agent/report.js.map +1 -0
- package/dist/tools/fs/edit-file.d.ts.map +1 -1
- package/dist/tools/fs/edit-file.js +9 -8
- package/dist/tools/fs/edit-file.js.map +1 -1
- package/dist/tools/fs/list-dir.d.ts.map +1 -1
- package/dist/tools/fs/list-dir.js +0 -1
- package/dist/tools/fs/list-dir.js.map +1 -1
- package/dist/tools/fs/read-file.js +3 -3
- package/dist/tools/fs/read-file.js.map +1 -1
- package/dist/tools/fs/utils.d.ts +7 -0
- package/dist/tools/fs/utils.d.ts.map +1 -1
- package/dist/tools/fs/utils.js +9 -2
- package/dist/tools/fs/utils.js.map +1 -1
- package/dist/tools/utils/index.d.ts +1 -0
- package/dist/tools/utils/index.d.ts.map +1 -1
- package/dist/tools/utils/index.js +4 -1
- package/dist/tools/utils/index.js.map +1 -1
- package/dist/tools/utils/read-image.d.ts +12 -0
- package/dist/tools/utils/read-image.d.ts.map +1 -0
- package/dist/tools/utils/read-image.js +70 -0
- package/dist/tools/utils/read-image.js.map +1 -0
- package/docs/agents.md +181 -0
- package/docs/api-reference.md +54 -0
- package/docs/getting-started.md +78 -0
- package/docs/index.md +23 -0
- package/docs/mcp-architecture.md +103 -0
- package/docs/providers.md +151 -0
- package/docs/skills.md +68 -0
- package/docs/streaming.md +116 -0
- package/docs/tools.md +179 -0
- package/package.json +4 -3
- package/dist/tests/mcp.test.d.ts +0 -2
- package/dist/tests/mcp.test.d.ts.map +0 -1
- package/dist/tests/mcp.test.js +0 -3
- package/dist/tests/mcp.test.js.map +0 -1
package/docs/tools.md
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# Tools
|
|
2
|
+
|
|
3
|
+
## The `MCPTool` shape
|
|
4
|
+
|
|
5
|
+
Every tool — built-in or custom — is an `MCPTool` instance (`src/core/mcp.ts`):
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
new MCPTool({
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
inputs: {
|
|
12
|
+
name: string;
|
|
13
|
+
type: "number" | "string" | "boolean" | "object" | "array";
|
|
14
|
+
description: string;
|
|
15
|
+
required?: boolean;
|
|
16
|
+
default?: any;
|
|
17
|
+
}[];
|
|
18
|
+
stopIterationAfterUsingThisTool?: boolean; // default false
|
|
19
|
+
customClass?: MCPCustomClass; // optional stateful helper, see below
|
|
20
|
+
execute: (
|
|
21
|
+
envID: string,
|
|
22
|
+
inputs: Record<string, any>,
|
|
23
|
+
mcp?: MCP,
|
|
24
|
+
customClass?: typeof customClass
|
|
25
|
+
) => Promise<any>;
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- `inputs` doubles as both the JSON-schema-like description sent to the model (translated per-provider by `src/core/tool-schema-translator.ts`) and the shape `execute` should expect on `inputs`.
|
|
30
|
+
- `stopIterationAfterUsingThisTool: true` ends the agent's run loop immediately after this tool fires, even if the model didn't naturally stop calling tools — useful for a "final answer" or "hand off" style tool.
|
|
31
|
+
- `execute`'s return value is normalized via `normalizeToolOutput()` into either `{ type: "text", output: {...} }` or `{ type: "image", output: { image, mimeType, ... } }`. Return `{ type: "image", output: {...} }` explicitly to hand back an image (it gets routed through the agent's image provider — see [Providers](./providers.md#two-provider-roles-main--image)); anything else is treated as a plain JSON text result.
|
|
32
|
+
- `envID` identifies which "environment" (in-process client id, IPC/WS session) the call came from — most tools ignore it unless they need per-environment isolated state (see `MCPStorage`/`MCPFSStorage` in [MCP Architecture](./mcp-architecture.md)).
|
|
33
|
+
- `customClass` (a subclass of `MCPCustomClass`) is a way to give a tool its own persistent helper object with access to the owning `MCP` instance (`getMCP()`) and an `EventEmitter` (`getEvents()`) for progress/status events — see how the built-in `*Interaction` classes are used (e.g. `FsInteraction`, `BrowserInteraction`) if you want to expose live progress to a UI. **Experimental:** `customClass` is still settling — its name and shape may change (or it may be removed) in a future release, so avoid depending on it for anything beyond the built-in `*Interaction` pattern until it stabilizes.
|
|
34
|
+
|
|
35
|
+
Tools are registered on an `MCPServer` and invoked through an `MCPClient`; `SimpleAgent` does this wiring for you from a flat `tools` array.
|
|
36
|
+
|
|
37
|
+
One tool schema the model sees isn't an `MCPTool` at all: `BaseAgent` always appends a built-in `compact_memory` tool to the schema list, handled internally rather than routed through the `MCPClient`. See [Memory compaction](./agents.md#memory-compaction).
|
|
38
|
+
|
|
39
|
+
## Built-in tool catalog
|
|
40
|
+
|
|
41
|
+
Import a whole domain's tools at once (e.g. `FsTools()`), or import individual tools by name. Every domain also exports a `*Interaction` `EventEmitter` for subscribing to that domain's live progress events (e.g. `FsInteraction`, `BashInteraction`).
|
|
42
|
+
|
|
43
|
+
### Filesystem — `FsTools()`
|
|
44
|
+
|
|
45
|
+
> ⚠️ `FsWriteFileTool` and `FsDeleteTool` can permanently overwrite, delete, or corrupt existing files — no undo. Prefer routing filesystem access through `MCPComputer`'s sandbox (see [MCP Architecture](./mcp-architecture.md#mcpcomputer-sandboxed-execution)) to protect the host system.
|
|
46
|
+
|
|
47
|
+
| Tool | Purpose |
|
|
48
|
+
|---|---|
|
|
49
|
+
| `FsReadFileTool` | Read a text file, paging through large files by line. |
|
|
50
|
+
| `FsWriteFileTool` | Write/overwrite a file's full content (creates parent dirs as needed). ⚠️ No undo. |
|
|
51
|
+
| `FsEditFileTool` | Replace a specific line range in an existing file without rewriting the whole thing. |
|
|
52
|
+
| `FsListDirTool` | List a directory's entries, paged by index for large directories. |
|
|
53
|
+
| `FsCreateDirTool` | Create a directory, including missing parents. |
|
|
54
|
+
| `FsDeleteTool` | Permanently delete a file or directory (recursive optional). ⚠️ No undo. |
|
|
55
|
+
| `FsMoveTool` | Move or rename a file or directory. |
|
|
56
|
+
|
|
57
|
+
`FsReadFileTool` and `FsEditFileTool` both use **1-indexed** line numbers (line 1 is the first line of the file) for their `offsetLine` input — matching the convention most models already default to (`cat -n`, most editors). This is deliberate: a line number reported by `fs-read-file`'s `startLine`/`endLine` can be passed straight into `fs-edit-file`'s `offsetLine` without an off-by-one conversion. `limitLine` on both is a plain count, not a line number, so it isn't affected by the indexing.
|
|
58
|
+
| `FsStatTool` | Check whether a path exists and get its metadata (type, size, modified time). |
|
|
59
|
+
|
|
60
|
+
### Bash / processes — `BashTools()`
|
|
61
|
+
|
|
62
|
+
> ⚠️ Shell commands can permanently delete files, corrupt data, modify system settings, or execute harmful operations — no undo. Same sandboxing recommendation as above.
|
|
63
|
+
|
|
64
|
+
| Tool | Purpose |
|
|
65
|
+
|---|---|
|
|
66
|
+
| `BashRunTool` | Launch a shell command as a background process; returns immediately if it's still running after `waitMs` (e.g. a dev server). |
|
|
67
|
+
| `BashWaitTool` | Wait again on a previously started process and get its latest status/output. |
|
|
68
|
+
| `BashLogsTool` | Read a process's combined stdout/stderr, paged by line. |
|
|
69
|
+
| `BashListTool` | List every process launched so far with its status. |
|
|
70
|
+
| `BashWriteInputTool` | Send text to a running process's stdin (answer an interactive prompt like `(y/n)`). |
|
|
71
|
+
| `BashTerminateTool` | Terminate a running process. |
|
|
72
|
+
|
|
73
|
+
### Browser — `BrowserTools()`
|
|
74
|
+
|
|
75
|
+
Drives a real headless browser session.
|
|
76
|
+
|
|
77
|
+
| Tool | Purpose |
|
|
78
|
+
|---|---|
|
|
79
|
+
| `BrowserCreateSessionTool` | Open a new headless browser session at a URL, returns its `sessionId`. |
|
|
80
|
+
| `BrowserRemoveSessionTool` | Close and remove a browser session. |
|
|
81
|
+
| `BrowserGetSessionsTool` | List all currently open session ids. |
|
|
82
|
+
| `BrowserNavigateTool` | Navigate an existing session to a new URL. |
|
|
83
|
+
| `BrowserReadTool` | Read the page as a text outline (headings, tables, links, forms), assigning ref ids to clickable/fillable elements. |
|
|
84
|
+
| `BrowserClickTool` | Click a `[CLICKABLE]` element by ref id. |
|
|
85
|
+
| `BrowserFillTool` | Type into a `[FILLABLE]` element by ref id; can submit via Enter if the field's form has no visible submit button. |
|
|
86
|
+
| `BrowserSubmitFormTool` | Submit a `[FORM]` ref directly — for forms with no visible submit button. |
|
|
87
|
+
| `BrowserScrollInfoTool` | Get total scrollable length and current scroll position. |
|
|
88
|
+
| `BrowserScrollTool` | Scroll to a given vertical pixel position. |
|
|
89
|
+
| `BrowserConsoleTool` | Read captured browser console log messages. |
|
|
90
|
+
| `BrowserNetworkTool` | Read captured network request/response activity. |
|
|
91
|
+
| `BrowserNetworkStatusTool` | Check whether the page currently has in-flight network activity. |
|
|
92
|
+
| `BrowserInjectTool` | Evaluate arbitrary JS in the page and return the result. |
|
|
93
|
+
| `BrowserScreenshotTool` | Capture a screenshot; can be described by the `image` provider instead of passed raw to the main model. |
|
|
94
|
+
|
|
95
|
+
### Todo lists — `TodoTools()`
|
|
96
|
+
|
|
97
|
+
Backs the `PlannerSkill` (see [Skills](./skills.md)), but usable standalone.
|
|
98
|
+
|
|
99
|
+
| Tool | Purpose |
|
|
100
|
+
|---|---|
|
|
101
|
+
| `TodoCreateListTool` | Create a new todo list, returns its `todoListId`. |
|
|
102
|
+
| `TodoRemoveListTool` | Remove one or more todo lists (and their tasks). |
|
|
103
|
+
| `TodoGetListsTool` | Get all existing todo list ids. |
|
|
104
|
+
| `TodoGetListTool` | Get all tasks belonging to a list. |
|
|
105
|
+
| `TodoCreateTaskTool` | Create one or more tasks inside a list. |
|
|
106
|
+
| `TodoRemoveTaskTool` | Remove one or more tasks by id. |
|
|
107
|
+
| `TodoCheckTaskTool` | Set the checked/unchecked state of one or more tasks. |
|
|
108
|
+
|
|
109
|
+
### Present / deliverables — `PresentTools()`
|
|
110
|
+
|
|
111
|
+
| Tool | Purpose |
|
|
112
|
+
|---|---|
|
|
113
|
+
| `PresentAddTool` | Present a file to the user by copying it into the present folder (zip folders first — this only accepts single files). |
|
|
114
|
+
| `PresentClearTool` | Clear out every file currently presented. |
|
|
115
|
+
| `PresentGetListTool` | Get the list of files currently presented. |
|
|
116
|
+
|
|
117
|
+
### Question / answer — `QuestionAnswerTools()`
|
|
118
|
+
|
|
119
|
+
| Tool | Purpose |
|
|
120
|
+
|---|---|
|
|
121
|
+
| `QuestionAnswerTool` | Ask the human operator a clarifying question and wait for their answer. |
|
|
122
|
+
|
|
123
|
+
### Utility — `UtilTools()`
|
|
124
|
+
|
|
125
|
+
| Tool | Purpose |
|
|
126
|
+
|---|---|
|
|
127
|
+
| `GetCurrentTimeTool` | Get the current date/time (ISO string, unix timestamp, timezone). |
|
|
128
|
+
| `DelayTool` | Wait a given number of milliseconds (max 60000ms) before continuing. |
|
|
129
|
+
| `ReadImageTool` | Read an image file off disk and hand it to the agent as an image tool-output — same handling as `BrowserScreenshotTool` (raw bytes to the model, or described by the image provider first, depending on config). |
|
|
130
|
+
|
|
131
|
+
### Multi-agent — `AgentTools(availableAgents, options?)` *(experimental)*
|
|
132
|
+
|
|
133
|
+
**Experimental** — see the note in [Agents](./agents.md#multi-agent-workeragent-experimental).
|
|
134
|
+
|
|
135
|
+
Unlike every other domain above, this one takes parameters: a fixed roster of `WorkerAgent` instances (see [Agents](./agents.md#multi-agent-workeragent-experimental)) you build ahead of time, and an optional `{ maxHired?: number }` cap on how many can be hired at once. Give the result to your **planner** agent.
|
|
136
|
+
|
|
137
|
+
| Tool | Purpose |
|
|
138
|
+
|---|---|
|
|
139
|
+
| `agent-list` | List every worker in the roster — name, description, rating, and hired status. Also returns `hiredCount` and (when set) `maxHired`. |
|
|
140
|
+
| `agent-hire` | Hire a worker by name, making it eligible for `agent-prompt`. |
|
|
141
|
+
| `agent-prompt` | Send a prompt to a hired worker and return its response once it's done. |
|
|
142
|
+
|
|
143
|
+
`AgentReportTool` is a separate, standalone factory in the same module — put it on each **worker's own** tool list instead (not the planner's), so a worker can hand a result back and end its turn. See [Agents](./agents.md#agent-report--for-workers-not-the-planner) for the full walkthrough.
|
|
144
|
+
|
|
145
|
+
## Writing a custom tool
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
import { MCPTool } from "orbitx";
|
|
149
|
+
|
|
150
|
+
export const SumTool = () => new MCPTool({
|
|
151
|
+
name: "math-sum",
|
|
152
|
+
description: "get two numbers and sum them",
|
|
153
|
+
inputs: [
|
|
154
|
+
{ name: "first", type: "number", description: "first number", required: true },
|
|
155
|
+
{ name: "second", type: "number", description: "second number", required: true },
|
|
156
|
+
],
|
|
157
|
+
execute: async (_envID: string, inputs: Record<string, any>) => {
|
|
158
|
+
const { first, second } = inputs;
|
|
159
|
+
if (typeof first !== "number") throw new Error("first must be a number");
|
|
160
|
+
if (typeof second !== "number") throw new Error("second must be a number");
|
|
161
|
+
return { output: first + second };
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Use it exactly like a built-in tool:
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
const agent = new SimpleAgent({
|
|
170
|
+
aiProvider: provider,
|
|
171
|
+
instruction: "You are a helpful assistant.",
|
|
172
|
+
tools: [SumTool()],
|
|
173
|
+
});
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Conventions worth following, based on the built-in tools:
|
|
177
|
+
- Export a **factory function** (`SumTool()`), not the `MCPTool` instance itself — this keeps each agent's tool list made of fresh instances.
|
|
178
|
+
- Throw inside `execute` for invalid input rather than returning an error object — thrown errors are caught by `BaseAgent` and turned into a `Error: ...` result the model sees, which is usually what you want.
|
|
179
|
+
- Keep `description` and each input's `description` written for the model, not for a human reader of your source — they go straight into the tool schema.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orbitx",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "An AI SDK providing agents, swarms, planners, skills, MCP tools, workflows, and multi-provider AI integrations.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
|
-
"dist"
|
|
25
|
+
"dist",
|
|
26
|
+
"docs"
|
|
26
27
|
],
|
|
27
28
|
"scripts": {
|
|
28
29
|
"build": "tsc",
|
|
@@ -54,4 +55,4 @@
|
|
|
54
55
|
"tsx": "^4.22.4",
|
|
55
56
|
"typescript": "^6.0.3"
|
|
56
57
|
}
|
|
57
|
-
}
|
|
58
|
+
}
|
package/dist/tests/mcp.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.test.d.ts","sourceRoot":"","sources":["../../src/tests/mcp.test.ts"],"names":[],"mappings":""}
|
package/dist/tests/mcp.test.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.test.js","sourceRoot":"","sources":["../../src/tests/mcp.test.ts"],"names":[],"mappings":";AAAA,0CAA0C"}
|