orbitx 0.2.0 → 0.2.3
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.map +1 -1
- package/dist/core/base-agent.js +7 -3
- package/dist/core/base-agent.js.map +1 -1
- package/dist/core/deepseek-provider.d.ts +1 -0
- package/dist/core/deepseek-provider.d.ts.map +1 -1
- package/dist/core/deepseek-provider.js +51 -1
- package/dist/core/deepseek-provider.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 +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.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/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/docs/agents.md +163 -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 +148 -0
- package/docs/skills.md +68 -0
- package/docs/streaming.md +116 -0
- package/docs/tools.md +174 -0
- package/package.json +4 -3
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { MCPTool } from "../../core/mcp.js";
|
|
2
|
+
import { AgentInteraction } from "./interaction.js";
|
|
3
|
+
export const AgentPromptTool = (registry) => new MCPTool({
|
|
4
|
+
name: "agent-prompt",
|
|
5
|
+
description: "send a prompt to a hired worker agent and wait for its response. The worker runs its own full turn (its own reasoning, its own tools) and either calls agent-report to hand back a result, or just stops on its own — either way this returns once it's done. You can call this again later on the same agent to continue the conversation (it remembers everything from earlier prompts), or move on and never call it again if its report says the work is finished.",
|
|
6
|
+
inputs: [
|
|
7
|
+
{
|
|
8
|
+
name: "name",
|
|
9
|
+
type: "string",
|
|
10
|
+
description: "the hired worker agent's name, exactly as shown by agent-list",
|
|
11
|
+
required: true,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: "prompt",
|
|
15
|
+
type: "string",
|
|
16
|
+
description: "the message to send to the worker agent",
|
|
17
|
+
required: true,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
customClass: new AgentInteraction(),
|
|
21
|
+
execute: async (_envID, inputs, _mcp, customClass) => {
|
|
22
|
+
const { name, prompt } = inputs;
|
|
23
|
+
if (!name || typeof name !== "string") {
|
|
24
|
+
throw new Error("name must be a non-empty string");
|
|
25
|
+
}
|
|
26
|
+
if (!prompt || typeof prompt !== "string") {
|
|
27
|
+
throw new Error("prompt must be a non-empty string");
|
|
28
|
+
}
|
|
29
|
+
const agent = registry.get(name);
|
|
30
|
+
if (!agent) {
|
|
31
|
+
throw new Error(`no worker agent named "${name}" — check agent-list for available names.`);
|
|
32
|
+
}
|
|
33
|
+
if (!registry.isHired(name)) {
|
|
34
|
+
throw new Error(`worker agent "${name}" is not hired yet — call agent-hire first.`);
|
|
35
|
+
}
|
|
36
|
+
customClass?.emitAgentEvent({ type: "prompted", name, prompt });
|
|
37
|
+
const beforeLength = agent.getCurrentAgentStates().messagesFull.length;
|
|
38
|
+
await agent.run(prompt);
|
|
39
|
+
// Only look at messages this specific call produced — otherwise a
|
|
40
|
+
// worker that answers in plain text (no fresh agent-report) could
|
|
41
|
+
// surface a stale report left over from an earlier prompt.
|
|
42
|
+
const newMessages = agent.getCurrentAgentStates().messagesFull.slice(beforeLength);
|
|
43
|
+
let report;
|
|
44
|
+
let reported = false;
|
|
45
|
+
for (let i = newMessages.length - 1; i >= 0; i--) {
|
|
46
|
+
const msg = newMessages[i];
|
|
47
|
+
if (msg.role === "tool" && msg.toolName === "agent-report") {
|
|
48
|
+
try {
|
|
49
|
+
report = JSON.parse(msg.content || "{}").report;
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
report = msg.content;
|
|
53
|
+
}
|
|
54
|
+
reported = true;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (!reported) {
|
|
59
|
+
for (let i = newMessages.length - 1; i >= 0; i--) {
|
|
60
|
+
const msg = newMessages[i];
|
|
61
|
+
if (msg.role === "assistant" && msg.content) {
|
|
62
|
+
report = msg.content;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
report ??= "(worker agent produced no output this turn)";
|
|
68
|
+
customClass?.emitAgentEvent({ type: "reported", name, reported, report });
|
|
69
|
+
return { report, reported };
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
export default AgentPromptTool;
|
|
73
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../src/tools/agent/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAY,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGpD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAAuB,EAAE,EAAE,CAAC,IAAI,OAAO,CAAmB;IACtF,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,wcAAwc;IACrd,MAAM,EAAE;QACJ;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,CAAC,CAAC;QAE1E,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IAChC,CAAC;CACJ,CAAC,CAAC;AAEH,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type WorkerAgent from "../../core/worker-agent.js";
|
|
2
|
+
import type { WorkerAgentRating } from "../../core/worker-agent.js";
|
|
3
|
+
export interface AgentInfo {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
rating: WorkerAgentRating;
|
|
7
|
+
hired: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* In-memory catalog of WorkerAgents a planner can see/hire/prompt, plus
|
|
11
|
+
* which of them are currently "active" (hired). Scoped to one AgentTools()
|
|
12
|
+
* call — not a process-wide singleton — so multiple independent planners in
|
|
13
|
+
* the same process each get their own roster and hire state.
|
|
14
|
+
*
|
|
15
|
+
* WorkerAgent instances are live objects (their own AI provider, message
|
|
16
|
+
* history, etc.), not serializable data, so — unlike MCPTool state such as
|
|
17
|
+
* TodoTools' lists — this can't live in MCPStorage. The roster itself is
|
|
18
|
+
* fixed at construction (only the developer can safely wire up a worker's
|
|
19
|
+
* provider/instruction/tools); the model can only hire/prompt from what's
|
|
20
|
+
* already here, never create new ones.
|
|
21
|
+
*/
|
|
22
|
+
export declare class AgentRegistry {
|
|
23
|
+
#private;
|
|
24
|
+
constructor(agents: WorkerAgent[], maxHired?: number);
|
|
25
|
+
getMaxHired(): number | undefined;
|
|
26
|
+
getHiredCount(): number;
|
|
27
|
+
list(): AgentInfo[];
|
|
28
|
+
hire(name: string): void;
|
|
29
|
+
isHired(name: string): boolean;
|
|
30
|
+
get(name: string): WorkerAgent | undefined;
|
|
31
|
+
}
|
|
32
|
+
export default AgentRegistry;
|
|
33
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/tools/agent/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,4BAA4B,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,MAAM,WAAW,SAAS;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,KAAK,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,aAAa;;gBAKV,MAAM,EAAE,WAAW,EAAE,EAAE,QAAQ,CAAC,EAAE,MAAM;IAepD,WAAW,IAAI,MAAM,GAAG,SAAS;IAIjC,aAAa,IAAI,MAAM;IAIvB,IAAI,IAAI,SAAS,EAAE;IASnB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAkBxB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI9B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;CAG7C;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory catalog of WorkerAgents a planner can see/hire/prompt, plus
|
|
3
|
+
* which of them are currently "active" (hired). Scoped to one AgentTools()
|
|
4
|
+
* call — not a process-wide singleton — so multiple independent planners in
|
|
5
|
+
* the same process each get their own roster and hire state.
|
|
6
|
+
*
|
|
7
|
+
* WorkerAgent instances are live objects (their own AI provider, message
|
|
8
|
+
* history, etc.), not serializable data, so — unlike MCPTool state such as
|
|
9
|
+
* TodoTools' lists — this can't live in MCPStorage. The roster itself is
|
|
10
|
+
* fixed at construction (only the developer can safely wire up a worker's
|
|
11
|
+
* provider/instruction/tools); the model can only hire/prompt from what's
|
|
12
|
+
* already here, never create new ones.
|
|
13
|
+
*/
|
|
14
|
+
export class AgentRegistry {
|
|
15
|
+
#agents = new Map();
|
|
16
|
+
#hired = new Set();
|
|
17
|
+
#maxHired;
|
|
18
|
+
constructor(agents, maxHired) {
|
|
19
|
+
if (maxHired !== undefined && (!Number.isInteger(maxHired) || maxHired < 1)) {
|
|
20
|
+
throw new Error(`AgentTools: maxHired must be a positive integer when given, got ${maxHired}.`);
|
|
21
|
+
}
|
|
22
|
+
this.#maxHired = maxHired;
|
|
23
|
+
for (const agent of agents) {
|
|
24
|
+
const name = agent.getName();
|
|
25
|
+
if (this.#agents.has(name)) {
|
|
26
|
+
throw new Error(`AgentTools: duplicate worker agent name "${name}" — names must be unique across the roster.`);
|
|
27
|
+
}
|
|
28
|
+
this.#agents.set(name, agent);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
getMaxHired() {
|
|
32
|
+
return this.#maxHired;
|
|
33
|
+
}
|
|
34
|
+
getHiredCount() {
|
|
35
|
+
return this.#hired.size;
|
|
36
|
+
}
|
|
37
|
+
list() {
|
|
38
|
+
return [...this.#agents.values()].map(agent => ({
|
|
39
|
+
name: agent.getName(),
|
|
40
|
+
description: agent.getDescription(),
|
|
41
|
+
rating: agent.getRating(),
|
|
42
|
+
hired: this.#hired.has(agent.getName()),
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
hire(name) {
|
|
46
|
+
if (!this.#agents.has(name)) {
|
|
47
|
+
throw new Error(`no worker agent named "${name}" — check agent-list for available names.`);
|
|
48
|
+
}
|
|
49
|
+
// Re-hiring an already-hired agent is a no-op — it must never count
|
|
50
|
+
// against the limit a second time.
|
|
51
|
+
if (this.#hired.has(name)) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (this.#maxHired !== undefined && this.#hired.size >= this.#maxHired) {
|
|
55
|
+
throw new Error(`cannot hire "${name}" — maximum of ${this.#maxHired} hired agent(s) already reached ` +
|
|
56
|
+
`(currently hired: ${[...this.#hired].join(", ") || "none"}).`);
|
|
57
|
+
}
|
|
58
|
+
this.#hired.add(name);
|
|
59
|
+
}
|
|
60
|
+
isHired(name) {
|
|
61
|
+
return this.#hired.has(name);
|
|
62
|
+
}
|
|
63
|
+
get(name) {
|
|
64
|
+
return this.#agents.get(name);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export default AgentRegistry;
|
|
68
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/tools/agent/registry.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,aAAa;IACtB,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;IACzC,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IAC3B,SAAS,CAAU;IAEnB,YAAY,MAAqB,EAAE,QAAiB;QAChD,IAAI,QAAQ,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,CAAC,CAAC,EAAE,CAAC;YAC1E,MAAM,IAAI,KAAK,CAAC,mEAAmE,QAAQ,GAAG,CAAC,CAAC;QACpG,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAE1B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YACzB,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;YAC7B,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CAAC,4CAA4C,IAAI,6CAA6C,CAAC,CAAC;YACnH,CAAC;YACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAClC,CAAC;IACL,CAAC;IAED,WAAW;QACP,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,aAAa;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC5B,CAAC;IAED,IAAI;QACA,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC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C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MCPTool } from "../../core/mcp.js";
|
|
2
|
+
/**
|
|
3
|
+
* For WorkerAgents, not planners: include this in a worker's own
|
|
4
|
+
* `allowedTools` (and register it on whatever MCPServer that worker uses)
|
|
5
|
+
* so it can hand a result back to whoever hired and prompted it. Calling
|
|
6
|
+
* this always ends the worker's current turn immediately
|
|
7
|
+
* (stopIterationAfterUsingThisTool) — AgentPromptTool picks the reported
|
|
8
|
+
* text back up on the hiring agent's side once agent.run() resolves.
|
|
9
|
+
*/
|
|
10
|
+
export declare const AgentReportTool: () => MCPTool<undefined>;
|
|
11
|
+
export default AgentReportTool;
|
|
12
|
+
//# sourceMappingURL=report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../src/tools/agent/report.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,0BAqB1B,CAAC;AAEH,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { MCPTool } from "../../core/mcp.js";
|
|
2
|
+
/**
|
|
3
|
+
* For WorkerAgents, not planners: include this in a worker's own
|
|
4
|
+
* `allowedTools` (and register it on whatever MCPServer that worker uses)
|
|
5
|
+
* so it can hand a result back to whoever hired and prompted it. Calling
|
|
6
|
+
* this always ends the worker's current turn immediately
|
|
7
|
+
* (stopIterationAfterUsingThisTool) — AgentPromptTool picks the reported
|
|
8
|
+
* text back up on the hiring agent's side once agent.run() resolves.
|
|
9
|
+
*/
|
|
10
|
+
export const AgentReportTool = () => new MCPTool({
|
|
11
|
+
name: "agent-report",
|
|
12
|
+
description: "report your result back to whichever agent hired and prompted you, then stop. This ends your current turn immediately — do not call any other tool or add commentary after this. The hiring agent decides what happens next: it may prompt you again to continue this same task, or move on and not call you again if your report shows you're done.",
|
|
13
|
+
inputs: [
|
|
14
|
+
{
|
|
15
|
+
name: "report",
|
|
16
|
+
type: "string",
|
|
17
|
+
description: "the result/findings/answer to hand back — write it so it's understandable on its own, without the hiring agent needing to see your internal reasoning",
|
|
18
|
+
required: true,
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
stopIterationAfterUsingThisTool: true,
|
|
22
|
+
execute: async (_envID, inputs) => {
|
|
23
|
+
const { report } = inputs;
|
|
24
|
+
if (!report || typeof report !== "string") {
|
|
25
|
+
throw new Error("report must be a non-empty string");
|
|
26
|
+
}
|
|
27
|
+
return { report };
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
export default AgentReportTool;
|
|
31
|
+
//# sourceMappingURL=report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../../src/tools/agent/report.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,IAAI,OAAO,CAAC;IAC7C,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,sVAAsV;IACnW,MAAM,EAAE;QACJ;YACI,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,uJAAuJ;YACpK,QAAQ,EAAE,IAAI;SACjB;KACJ;IACD,+BAA+B,EAAE,IAAI;IACrC,OAAO,EAAE,KAAK,EAAE,MAAc,EAAE,MAA2B,EAAgB,EAAE;QACzE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;QAE1B,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACzD,CAAC;QAED,OAAO,EAAE,MAAM,EAAE,CAAC;IACtB,CAAC;CACJ,CAAC,CAAC;AAEH,eAAe,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-dir.d.ts","sourceRoot":"","sources":["../../../src/tools/fs/list-dir.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAY,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAmEjD,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"list-dir.d.ts","sourceRoot":"","sources":["../../../src/tools/fs/list-dir.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAY,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAmEjD,eAAO,MAAM,aAAa,8BAsFxB,CAAC;AAEH,eAAe,aAAa,CAAC"}
|
|
@@ -109,7 +109,6 @@ export const FsListDirTool = () => new MCPTool({
|
|
|
109
109
|
const end = Math.max(start, Math.min(start + limitResult, totalResult));
|
|
110
110
|
const page = entries.slice(start, end);
|
|
111
111
|
return {
|
|
112
|
-
entries: page,
|
|
113
112
|
result: page,
|
|
114
113
|
total: totalResult,
|
|
115
114
|
totalResult,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-dir.js","sourceRoot":"","sources":["../../../src/tools/fs/list-dir.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAY,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,qBAAqB,GAAG;IAC1B,cAAc;IACd,MAAM;IACN,OAAO;IACP,QAAQ;IACR,MAAM;IACN,OAAO;IACP,QAAQ;IACR,UAAU;IACV,SAA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K,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC;QAC/D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;QACxE,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAEvC,OAAO;YACH,MAAM,EAAE,IAAI;YACZ,KAAK,EAAE,WAAW;YAClB,WAAW;YACX,YAAY,EAAE,KAAK;YACnB,WAAW;SACd,CAAC;IACN,CAAC;CACJ,CAAC,CAAC;AAEH,eAAe,aAAa,CAAC"}
|
package/docs/agents.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Agents
|
|
2
|
+
|
|
3
|
+
## `BaseAgent` vs `SimpleAgent`
|
|
4
|
+
|
|
5
|
+
- **`BaseAgent`** (`src/core/base-agent.ts`) is the real engine — the run loop, memory compaction, tool dispatch, token accounting. It requires you to bring your own `MCPClient` (and therefore your own `MCPServer`/connection), which is what gives you the choice of in-process, IPC, or WebSocket execution (see [MCP Architecture](./mcp-architecture.md)).
|
|
6
|
+
- **`SimpleAgent`** (`src/templates/simple.ts`) is a thin subclass that wires up an in-process `MCPConnection` + `MCPServer` + `MCPClient` for you from a flat `tools`/`skills` list. Use this unless you specifically need a different transport.
|
|
7
|
+
- **`WorkerAgent`** *(experimental)* (`src/core/worker-agent.ts`) is a `BaseAgent` with an identity — name, description, per-task-type rating — so another agent can list, compare, hire, and prompt it as a sub-agent. See [Multi-agent: WorkerAgent](#multi-agent-workeragent-experimental) below.
|
|
8
|
+
|
|
9
|
+
## `BaseAgent` constructor
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
new BaseAgent({
|
|
13
|
+
instruction: string;
|
|
14
|
+
allowedTools: MCPTool<any>[];
|
|
15
|
+
aiProvider: AIProvider | AgentProviderEntry[]; // see Providers doc
|
|
16
|
+
mcpClient: MCPClient;
|
|
17
|
+
skills?: Skill[];
|
|
18
|
+
maxMemorizeToken?: number; // default: derived from the main provider's contextWindow * safeUsageRatio
|
|
19
|
+
initData?: {
|
|
20
|
+
memory: string;
|
|
21
|
+
messagesFull: Message[];
|
|
22
|
+
fullInputMissTokens: number;
|
|
23
|
+
fullInputHitTokens: number;
|
|
24
|
+
fullOutputTokens: number;
|
|
25
|
+
messagesCompact: Message[];
|
|
26
|
+
currentInputMissTokens: number;
|
|
27
|
+
currentInputHitTokens: number;
|
|
28
|
+
currentOutputTokens: number;
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`SimpleAgent`'s constructor is the same shape minus `mcpClient`/`allowedTools` (it builds those from `tools`), plus `tools?: MCPTool<any>[]` and `maxMemorizeToken` defaulting to `16000` instead of being derived.
|
|
34
|
+
|
|
35
|
+
## The run loop
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
await agent.run(prompt: string, streamCallback?: StreamCallback): Promise<void>;
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Each call to `run()`:
|
|
42
|
+
|
|
43
|
+
1. Pushes the user prompt onto the message history and emits it as a `role: "user"` stream chunk.
|
|
44
|
+
2. Sends `[system, ...history]` plus the full tool schema list to the main provider's `chat()`.
|
|
45
|
+
3. If the model requested tool calls, dispatches each one (via the `MCPClient` this agent was built with), pushes a `role: "tool"` message + stream chunk per result, and loops back to step 2.
|
|
46
|
+
4. Repeats until the model's turn produces no tool calls (or a tool marked `stopIterationAfterUsingThisTool` fired — see [Tools](./tools.md)).
|
|
47
|
+
|
|
48
|
+
If `run()` is called again while a previous call is still in flight, the new call is queued and resolves once the current run finishes (or times out after 4 minutes) — it does not run concurrently or interleave.
|
|
49
|
+
|
|
50
|
+
`stop()` requests the current run stop at the next safe point; it resolves once the loop has actually stopped, or rejects if it doesn't stop within 4 minutes.
|
|
51
|
+
|
|
52
|
+
### Native tool-calling is required
|
|
53
|
+
|
|
54
|
+
`run()` throws immediately if the main provider's `getCapabilities().supportsTools` is `false`. There is no legacy JSON-in-text fallback in the main loop anymore — pick a provider/model combination (or pass `{ supportsTools: true }`) that supports native function calling.
|
|
55
|
+
|
|
56
|
+
## Memory compaction
|
|
57
|
+
|
|
58
|
+
OrbitX never truncates or deletes conversation history. Instead, `BaseAgent` tracks two token totals per run: `currentInputMissTokens` (uncached input) and `currentLastOutputTokens` (the last turn's output). When their sum exceeds `maxMemorizeToken`:
|
|
59
|
+
|
|
60
|
+
1. The agent asks the main provider to summarize the conversation so far into a single JSON tool call (`{"tool":"set_memory","inputs":{"new_memory":"..."}}`), which becomes the running `memory` string injected into every future system prompt (`MEMORY:` section).
|
|
61
|
+
2. `messagesCompact` — the *working* context sent to the provider each turn — is cleared.
|
|
62
|
+
3. `messagesFull` — the complete, ever-appended history — is untouched, so nothing is lost; it's just no longer replayed to the model every turn.
|
|
63
|
+
4. If no tool was called this turn (i.e. compaction happened on an otherwise-idle turn), the agent auto-continues with a synthetic "Continue where you left off, using MEMORY above for context." prompt so the model doesn't just stop mid-task.
|
|
64
|
+
|
|
65
|
+
`maxMemorizeToken`, if not passed explicitly, is derived as `contextWindow * safeUsageRatio` (default ratio `0.5`) from the main provider's `getCapabilities()` — so it scales automatically with whatever model you plug in.
|
|
66
|
+
|
|
67
|
+
## Persisting and resuming state
|
|
68
|
+
|
|
69
|
+
`getCurrentAgentStates()` returns exactly the shape expected by the `initData` constructor option — `memory`, `messagesFull`, `messagesCompact`, and all six token counters. Serialize it (it's plain JSON) after any `run()` call, and pass it back into a fresh `BaseAgent`/`SimpleAgent` to resume — same conversation, same memory, same token history. See the example in [Getting Started](./getting-started.md#recovering-an-agents-state).
|
|
70
|
+
|
|
71
|
+
## Token accounting
|
|
72
|
+
|
|
73
|
+
Three read methods, all returning `{ total, inputHit, inputMiss, output }`:
|
|
74
|
+
|
|
75
|
+
- `getCurrentTotalTokens()` — tokens used since the last memory compaction.
|
|
76
|
+
- `getFullTotalTokens()` — tokens used across all *prior* compacted segments.
|
|
77
|
+
- `getTotalTokens()` — the sum of both (lifetime total for this agent instance).
|
|
78
|
+
|
|
79
|
+
`inputHit`/`inputMiss` track cached vs. uncached input tokens, since the compacted-context-replay pattern means most of a long conversation's prefix is a cache hit on providers that support prompt caching.
|
|
80
|
+
|
|
81
|
+
## Instructions, skills, and memory in the system prompt
|
|
82
|
+
|
|
83
|
+
The system prompt is built once (lazily, on first use) and never changes for the lifetime of an agent instance — a stable prefix, which matters for provider-side prompt caching. It's assembled from: a fixed "you have tools" preamble, each skill's name/description/instructions (see [Skills](./skills.md)), the current `MEMORY:` block, and your `instruction` string, in that order.
|
|
84
|
+
|
|
85
|
+
## Multi-agent: `WorkerAgent` *(experimental)*
|
|
86
|
+
|
|
87
|
+
**Experimental:** this whole feature (`WorkerAgent`, `AgentTools`, `AgentReportTool`) is new and still settling — names, the hire/prompt/report shape, and the fallback behavior when a worker never reports may change in a future release. Treat it as unstable if you're building something you don't want to have to revisit.
|
|
88
|
+
|
|
89
|
+
`WorkerAgent` (`src/core/worker-agent.ts`) is a `BaseAgent` with three extra fields on top of the usual constructor options:
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
new WorkerAgent({
|
|
93
|
+
name: string; // unique id used to hire/prompt this worker
|
|
94
|
+
description: string; // persona/specialty, written for a hiring agent to judge fit from
|
|
95
|
+
rating?: Record<string, number>; // per-task-type fit score, e.g. { backend: 9, "3d-web": 10 }, convention 0-10
|
|
96
|
+
// ...plus every BaseAgent option: instruction, allowedTools, aiProvider, mcpClient, skills?, maxMemorizeToken?, initData?
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
worker.getName();
|
|
100
|
+
worker.getDescription();
|
|
101
|
+
worker.getRating();
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
It's a raw building block, same as `BaseAgent` — you still bring your own `mcpClient`/`allowedTools` for it. The only thing `WorkerAgent` adds is identity metadata; running it (`.run()`, streaming, memory, tokens) is unchanged.
|
|
105
|
+
|
|
106
|
+
### The `agent-*` tools
|
|
107
|
+
|
|
108
|
+
`AgentTools(availableAgents: WorkerAgent[], options?: { maxHired?: number })` (from `src/tools/agent/`) builds a fixed roster of hireable workers into three planner-facing tools:
|
|
109
|
+
|
|
110
|
+
| Tool | Purpose |
|
|
111
|
+
|---|---|
|
|
112
|
+
| `agent-list` | List every worker in the roster — name, description, rating, and whether it's currently hired. Also returns `hiredCount` and (when set) `maxHired`. |
|
|
113
|
+
| `agent-hire` | Hire a worker by name, making it eligible for `agent-prompt`. Hiring an already-hired worker is a no-op. |
|
|
114
|
+
| `agent-prompt` | Send a prompt to a hired worker and wait for its response. |
|
|
115
|
+
|
|
116
|
+
`maxHired` caps how many workers can be hired at once — omit it for no limit. When set, it's woven directly into `agent-hire`'s own tool description (so the model learns the constraint from the tool itself, not out-of-band instructions) and exceeding it throws a clear error naming the current limit and who's currently hired. Re-hiring an already-hired worker is still a free no-op and never counts against the cap.
|
|
117
|
+
|
|
118
|
+
Give these to your **planner** agent (the one that decides which workers to use), not to the workers themselves:
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
import { AgentTools, SimpleAgent, WorkerAgent, AnthropicProvider, AgentReportTool, MCPConnection, MCPServer, MCPClient } from "orbitx";
|
|
122
|
+
|
|
123
|
+
function buildWorker(name: string, description: string, rating: Record<string, number>) {
|
|
124
|
+
const connection = new MCPConnection();
|
|
125
|
+
const server = new MCPServer(connection);
|
|
126
|
+
const reportTool = AgentReportTool();
|
|
127
|
+
server.registerTool(reportTool);
|
|
128
|
+
// ...register whatever other tools this worker needs on `server` too...
|
|
129
|
+
|
|
130
|
+
return new WorkerAgent({
|
|
131
|
+
name,
|
|
132
|
+
description,
|
|
133
|
+
rating,
|
|
134
|
+
instruction: `You are the ${name} specialist.`,
|
|
135
|
+
aiProvider: new AnthropicProvider("api-key", "claude-sonnet-5"),
|
|
136
|
+
mcpClient: new MCPClient(name, connection),
|
|
137
|
+
allowedTools: [reportTool /* , ...other tools registered above */],
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const backendWorker = buildWorker("backend-worker", "Node.js APIs, databases, servers.", { backend: 9, frontend: 2 });
|
|
142
|
+
const frontendWorker = buildWorker("frontend-worker", "React UI work.", { backend: 2, frontend: 9 });
|
|
143
|
+
|
|
144
|
+
const planner = new SimpleAgent({
|
|
145
|
+
aiProvider: new AnthropicProvider("api-key", "claude-sonnet-5"),
|
|
146
|
+
instruction: "You coordinate work across specialist worker agents.",
|
|
147
|
+
// At most 1 hired at a time here, just as an example constraint.
|
|
148
|
+
tools: AgentTools([backendWorker, frontendWorker], { maxHired: 1 }),
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### `agent-report` — for workers, not the planner
|
|
153
|
+
|
|
154
|
+
Include `AgentReportTool()` in each **worker's own** `allowedTools` (and register it on that worker's own `MCPServer`, as in the example above) — it's what lets a worker hand a result back once it's done. Calling it always ends the worker's current turn immediately (`stopIterationAfterUsingThisTool`), so a worker should call it and stop, not keep reasoning afterward.
|
|
155
|
+
|
|
156
|
+
### How a prompt/report round-trip actually works
|
|
157
|
+
|
|
158
|
+
1. Planner calls `agent-hire`, then `agent-prompt` with a task.
|
|
159
|
+
2. `agent-prompt`'s implementation calls `workerAgent.run(prompt)` and waits for it to resolve — the worker runs its own full turn (its own reasoning, its own tools), completely independently of the planner's own loop.
|
|
160
|
+
3. Once the worker's `run()` resolves, `agent-prompt` looks at only the messages that turn produced: if the worker called `agent-report`, that report text is returned (`{ report, reported: true }`); otherwise it falls back to the worker's last plain-text answer (`{ report, reported: false }`).
|
|
161
|
+
4. The planner sees this as a normal tool result. It's the planner's call what happens next — prompt the same worker again to continue (its message history persists across `agent-prompt` calls, same as any agent's `run()`), or move on and never call it again if the report shows the work is done. Nothing about the worker's lifecycle is automatic.
|
|
162
|
+
|
|
163
|
+
`AgentTools(...)` state (which agents are hired) is scoped to that one call — building a second, independent planner with its own `AgentTools([...])` call gets its own hire state, even in the same process.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# API Reference
|
|
2
|
+
|
|
3
|
+
Flat index of every public export from `orbitx` (see `src/index.ts`), grouped by area. Each links to the doc page with the actual explanation and examples.
|
|
4
|
+
|
|
5
|
+
## Core / Providers — see [Providers](./providers.md)
|
|
6
|
+
|
|
7
|
+
- `AIProvider` (abstract base class)
|
|
8
|
+
- `OpenAIProvider`, `AnthropicProvider`, `DeepSeekProvider`, `OllamaProvider`
|
|
9
|
+
- `resolveAgentProviders()`
|
|
10
|
+
- Types: `AgentProviderRole`, `AgentProviderEntry`, `AgentProvidersInput`, `ResolvedAgentProviders`
|
|
11
|
+
- Types: `ChatResponse`, `Message`, `StreamCallback`, `ToolSchema`, `ToolCallRequest`, `MessageContentPart`, `ProviderCapabilities`
|
|
12
|
+
- `resolveThinkEffortLevel()`, `clampThinkEffort()` — the universal 0-1 `thinkEffort` → provider-native-level mapping helpers; see [Providers](./providers.md#think-effort)
|
|
13
|
+
- Type: `ThinkEffortLevel`
|
|
14
|
+
- `ImageDescriber` — used internally by `BaseAgent` to describe image tool output via the `image` provider role; exported for direct use if you want to describe an image outside the agent loop.
|
|
15
|
+
- `toOpenAIFunctionTools()` — translates a `ToolSchema[]` into OpenAI's function-calling format; exported for building custom providers.
|
|
16
|
+
|
|
17
|
+
## Agents — see [Agents](./agents.md)
|
|
18
|
+
|
|
19
|
+
- `BaseAgent`
|
|
20
|
+
- `SimpleAgent`
|
|
21
|
+
- `WorkerAgent` *(experimental)*, type `WorkerAgentRating`
|
|
22
|
+
- Types: `ExtractedSegment`, `ParsedToolCall`
|
|
23
|
+
|
|
24
|
+
## Tools — see [Tools](./tools.md)
|
|
25
|
+
|
|
26
|
+
- `MCPTool`, `MCPCustomClass`, `generateRefId()`, `normalizeToolOutput()`
|
|
27
|
+
- Types: `MCP`, `MCPToolOutput`
|
|
28
|
+
|
|
29
|
+
Built-in tool factories, grouped by domain (each domain also exports a `*Tools()` array and a `*Interaction` EventEmitter):
|
|
30
|
+
|
|
31
|
+
| Domain | Exports |
|
|
32
|
+
|---|---|
|
|
33
|
+
| Filesystem | `FsReadFileTool`, `FsWriteFileTool`, `FsEditFileTool`, `FsListDirTool`, `FsCreateDirTool`, `FsDeleteTool`, `FsMoveTool`, `FsStatTool`, `FsTools`, `FsInteraction`, type `FsEvent` |
|
|
34
|
+
| Bash | `BashRunTool`, `BashWaitTool`, `BashLogsTool`, `BashListTool`, `BashWriteInputTool`, `BashTerminateTool`, `BashTools`, `BashInteraction`, type `BashEvent` |
|
|
35
|
+
| Browser | `BrowserCreateSessionTool`, `BrowserRemoveSessionTool`, `BrowserGetSessionsTool`, `BrowserNavigateTool`, `BrowserConsoleTool`, `BrowserInjectTool`, `BrowserReadTool`, `BrowserClickTool`, `BrowserFillTool`, `BrowserScrollInfoTool`, `BrowserScrollTool`, `BrowserNetworkStatusTool`, `BrowserNetworkTool`, `BrowserSubmitFormTool`, `BrowserScreenshotTool`, `BrowserTools`, `BrowserInteraction`, type `BrowserEvent` |
|
|
36
|
+
| Todo | `TodoCreateListTool`, `TodoRemoveListTool`, `TodoGetListsTool`, `TodoGetListTool`, `TodoCreateTaskTool`, `TodoRemoveTaskTool`, `TodoCheckTaskTool`, `TodoTools`, `TodoInteraction`, types `TodoTask`, `TodoList`, `TodoEvent` |
|
|
37
|
+
| Present | `PresentAddTool`, `PresentClearTool`, `PresentGetListTool`, `PresentTools`, `getPresentFolder()`, `PresentInteraction`, type `PresentEvent` |
|
|
38
|
+
| Question/Answer | `QuestionAnswerTool`, `QuestionAnswerTools`, `QuestionAnswerInteraction`, type `QuestionAnswerEvent` |
|
|
39
|
+
| Utility | `GetCurrentTimeTool`, `DelayTool`, `UtilTools` |
|
|
40
|
+
| Multi-agent *(experimental)* | `AgentTools(availableAgents, options?)`, `AgentListTool`, `AgentHireTool`, `AgentPromptTool`, `AgentReportTool`, `AgentRegistry`, `AgentInteraction`, type `AgentInfo`, type `AgentEvent`, type `AgentToolsOptions` — see [Agents](./agents.md#multi-agent-workeragent-experimental) |
|
|
41
|
+
|
|
42
|
+
## Skills — see [Skills](./skills.md)
|
|
43
|
+
|
|
44
|
+
- `Skill`
|
|
45
|
+
- `BackendSecuritySkill`, `BigTaskSkill`, `CodeVerificationSkill`, `LongTaskEfficiencySkill`, `NodeBackendSkill`, `PlannerSkill`, `PresentSkill`, `QuestionAnswerSkill`, `ReactFrontendSkill`, `ResearchSkill`, `ShoppingSkill`, `UiUxDesignSkill`, `WebEndToEndTestSkill`
|
|
46
|
+
|
|
47
|
+
## MCP transport — see [MCP Architecture](./mcp-architecture.md)
|
|
48
|
+
|
|
49
|
+
- `MCPServer`, `MCPClient`
|
|
50
|
+
- `MCPConnection`, `MCPIPCConnection`, `MCPWSConnection`
|
|
51
|
+
- `MCPComputer` *(experimental)*
|
|
52
|
+
- `MCPStorage`, `MCPFSStorage`
|
|
53
|
+
- `MCPRNG`
|
|
54
|
+
- `MCPFilter`
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Getting Started
|
|
2
|
+
|
|
3
|
+
## Install
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install orbitx
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Your first agent
|
|
10
|
+
|
|
11
|
+
The fastest path is `SimpleAgent`: give it a provider, an instruction, and a list of tools/skills. It wires up an in-process MCP server/client for you automatically.
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { OllamaProvider, SimpleAgent, GetCurrentTimeTool } from "orbitx";
|
|
15
|
+
|
|
16
|
+
const provider = new OllamaProvider("gemma4:e4b");
|
|
17
|
+
|
|
18
|
+
const agent = new SimpleAgent({
|
|
19
|
+
aiProvider: provider,
|
|
20
|
+
instruction: "You are a helpful assistant.",
|
|
21
|
+
tools: [GetCurrentTimeTool()],
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
await agent.run("what is current time?", (chunk) => {
|
|
25
|
+
process.stdout.write(chunk.content);
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`agent.run(prompt, streamCallback)` resolves once the model has stopped calling tools and produced a final answer. The `streamCallback` is optional — omit it if you only care about the eventual message history via `getCurrentAgentStates()`.
|
|
30
|
+
|
|
31
|
+
See [Streaming](./streaming.md) for the full chunk shape (roles, tool call/result chunks, `done` flag).
|
|
32
|
+
|
|
33
|
+
## Choosing a provider
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { OllamaProvider, DeepSeekProvider, AnthropicProvider, OpenAIProvider } from "orbitx";
|
|
37
|
+
|
|
38
|
+
new OllamaProvider("gemma4:e4b"); // local, via Ollama
|
|
39
|
+
new DeepSeekProvider("api-key", "deepseek-v4-flash"); // hosted
|
|
40
|
+
new AnthropicProvider("api-key", "claude-sonnet-5"); // hosted
|
|
41
|
+
new OpenAIProvider("api-key", "gpt-5"); // hosted
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Every provider implements the same `AIProvider` interface, so switching models is a one-line change to your agent's `aiProvider`. Details, capability flags, and the main/image role split are in [Providers](./providers.md).
|
|
45
|
+
|
|
46
|
+
## Tools and skills up front
|
|
47
|
+
|
|
48
|
+
`SimpleAgent`'s `tools` and `skills` lists are baked into the system prompt once, at construction time — there's no per-turn tool selection/routing step deciding what the model is allowed to see. If you want the model to be able to call something, put it in `tools` (or bundle it inside a `Skill`). See [Tools](./tools.md) and [Skills](./skills.md).
|
|
49
|
+
|
|
50
|
+
## Recovering an agent's state
|
|
51
|
+
|
|
52
|
+
`getCurrentAgentStates()` returns a plain JSON-serializable snapshot: message history, running memory summary, and token counters. Persist it anywhere; pass it back in as `initData` to resume the exact same agent later (after a process restart, in a new request handler, etc.):
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
import { writeFileSync, existsSync, readFileSync } from "fs";
|
|
56
|
+
|
|
57
|
+
const initData = existsSync("./state.json")
|
|
58
|
+
? JSON.parse(readFileSync("./state.json", "utf-8"))
|
|
59
|
+
: undefined;
|
|
60
|
+
|
|
61
|
+
const agent = new SimpleAgent({
|
|
62
|
+
aiProvider: provider,
|
|
63
|
+
instruction: "You are a helpful assistant.",
|
|
64
|
+
tools: [GetCurrentTimeTool()],
|
|
65
|
+
...(initData ? { initData } : {}),
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// after any run() call:
|
|
69
|
+
writeFileSync("./state.json", JSON.stringify(agent.getCurrentAgentStates()));
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Messages are only ever appended, never rewritten. When the conversation grows past the memory threshold, OrbitX keeps the full history on disk (`messagesFull`) but resets the model's *working* context from a running summary, so an agent can keep going indefinitely without losing the ability to act on what happened earlier. Mechanics are covered in [Agents](./agents.md#memory-compaction).
|
|
73
|
+
|
|
74
|
+
## Next steps
|
|
75
|
+
|
|
76
|
+
- Full control over the MCP transport (custom server/client, IPC, WebSocket, sandboxed Docker execution): [MCP Architecture](./mcp-architecture.md).
|
|
77
|
+
- Writing your own tool or skill: [Tools](./tools.md#writing-a-custom-tool), [Skills](./skills.md#writing-a-custom-skill).
|
|
78
|
+
- Every public export: [API Reference](./api-reference.md).
|
package/docs/index.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# OrbitX Docs
|
|
2
|
+
|
|
3
|
+
OrbitX is a TypeScript SDK for building AI agents: pluggable model providers, a tool/skill system, an MCP-based execution layer (in-process, IPC, or WebSocket), and a resumable agent loop with automatic memory compaction.
|
|
4
|
+
|
|
5
|
+
This directory is written for two audiences at once:
|
|
6
|
+
|
|
7
|
+
- **Humans** learning the library for the first time — read top to bottom.
|
|
8
|
+
- **AI coding agents** working inside a project that depends on `orbitx` — each page is self-contained enough to be read on its own when you only need one topic (e.g. "how do I define a tool").
|
|
9
|
+
|
|
10
|
+
## Pages
|
|
11
|
+
|
|
12
|
+
1. [Getting Started](./getting-started.md) — install, first agent, streaming output, resuming state.
|
|
13
|
+
2. [Providers](./providers.md) — `AIProvider`, the four built-in providers, capabilities, main/image roles.
|
|
14
|
+
3. [Agents](./agents.md) — `BaseAgent` vs `SimpleAgent`, the run loop, memory compaction, tokens, and multi-agent (`WorkerAgent`/`AgentTools`).
|
|
15
|
+
4. [Tools](./tools.md) — the `MCPTool` shape, built-in tool catalog, writing your own tools.
|
|
16
|
+
5. [Skills](./skills.md) — bundling instructions + tools, built-in skill catalog, writing your own.
|
|
17
|
+
6. [MCP Architecture](./mcp-architecture.md) — `MCPServer`/`MCPClient`/connections, in-process vs IPC vs WS, `MCPComputer` sandbox.
|
|
18
|
+
7. [Streaming](./streaming.md) — the `StreamCallback` chunk shape and how to consume it.
|
|
19
|
+
8. [API Reference](./api-reference.md) — flat index of every public export from `orbitx`.
|
|
20
|
+
|
|
21
|
+
## The shape of the library, in one paragraph
|
|
22
|
+
|
|
23
|
+
You construct one or more `AIProvider` instances (OpenAI, Anthropic, DeepSeek, or Ollama), a list of `MCPTool`s and/or `Skill`s (a skill is just instructions + tools bundled together), and hand them to `SimpleAgent` (or `BaseAgent` for full control over the underlying MCP transport). Calling `agent.run(prompt, streamCallback)` drives a loop: send the conversation + tool schemas to the provider, dispatch any tool calls the model requests, feed results back, repeat until the model stops calling tools. Everything the model can see (tools, skills, instructions) is decided once, up front — there's no dynamic tool routing/selection step. Long conversations are handled by summarizing into a running `memory` string instead of ever deleting messages; the full history is preserved in `getCurrentAgentStates()` for persistence/resume.
|