orbitx 0.2.1 → 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 +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -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,43 @@
|
|
|
1
|
+
import BaseAgent from "./base-agent.js";
|
|
2
|
+
/**
|
|
3
|
+
* Per-task-type fit score for a WorkerAgent, e.g. `{ backend: 9, frontend: 4,
|
|
4
|
+
* "3d-web": 10 }`. Keys are free-form task-type labels chosen by whoever
|
|
5
|
+
* builds the roster; there's no fixed enum since "what counts as a task
|
|
6
|
+
* type" is app-specific. Convention (not enforced): 0-10, higher is a
|
|
7
|
+
* better fit. AgentListTool hands this straight to the hiring agent so it
|
|
8
|
+
* can judge which worker fits a given task.
|
|
9
|
+
*/
|
|
10
|
+
export type WorkerAgentRating = Record<string, number>;
|
|
11
|
+
/**
|
|
12
|
+
* EXPERIMENTAL: this class, and the agent-management tools built on it
|
|
13
|
+
* (src/tools/agent/), are new and still settling — names and behavior may
|
|
14
|
+
* change in a future release.
|
|
15
|
+
*
|
|
16
|
+
* A BaseAgent with an identity a *hiring* agent can reason about — name,
|
|
17
|
+
* description (persona/specialty), and a rating per task type — so it can
|
|
18
|
+
* be listed, compared against other workers, and hired via the tools in
|
|
19
|
+
* `src/tools/agent/` (see AgentTools()). Everything about running it (tool
|
|
20
|
+
* dispatch, memory, streaming) is unchanged from BaseAgent; WorkerAgent only
|
|
21
|
+
* adds metadata on top.
|
|
22
|
+
*
|
|
23
|
+
* Like BaseAgent, this is a raw building block: you still bring your own
|
|
24
|
+
* `mcpClient`/`allowedTools`. If you want this worker to be able to report
|
|
25
|
+
* back to whoever hired it, include AgentReportTool() (from
|
|
26
|
+
* `src/tools/agent/`) in its own tools, same as any other tool.
|
|
27
|
+
*/
|
|
28
|
+
export declare class WorkerAgent extends BaseAgent {
|
|
29
|
+
#private;
|
|
30
|
+
constructor({ name, description, rating, ...baseAgentOptions }: {
|
|
31
|
+
/** Unique identifier used by AgentTools() to hire/prompt this worker — must be unique across whatever roster it's included in. */
|
|
32
|
+
name: string;
|
|
33
|
+
/** Persona/specialty shown to the hiring agent via agent-list — what this worker is good at, written for the model to judge fit from, not just a human label. */
|
|
34
|
+
description: string;
|
|
35
|
+
/** Per-task-type fit score — see WorkerAgentRating. Defaults to empty (no stated specialty). */
|
|
36
|
+
rating?: WorkerAgentRating;
|
|
37
|
+
} & ConstructorParameters<typeof BaseAgent>[0]);
|
|
38
|
+
getName(): string;
|
|
39
|
+
getDescription(): string;
|
|
40
|
+
getRating(): WorkerAgentRating;
|
|
41
|
+
}
|
|
42
|
+
export default WorkerAgent;
|
|
43
|
+
//# sourceMappingURL=worker-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-agent.d.ts","sourceRoot":"","sources":["../../src/core/worker-agent.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,iBAAiB,CAAC;AAExC;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEvD;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,WAAY,SAAQ,SAAS;;gBAK1B,EACR,IAAI,EACJ,WAAW,EACX,MAAW,EACX,GAAG,gBAAgB,EACtB,EAAE;QACC,kIAAkI;QAClI,IAAI,EAAE,MAAM,CAAC;QACb,iKAAiK;QACjK,WAAW,EAAE,MAAM,CAAC;QACpB,gGAAgG;QAChG,MAAM,CAAC,EAAE,iBAAiB,CAAC;KAC9B,GAAG,qBAAqB,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC;IAO9C,OAAO,IAAI,MAAM;IAIjB,cAAc,IAAI,MAAM;IAIxB,SAAS,IAAI,iBAAiB;CAGjC;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import BaseAgent from "./base-agent.js";
|
|
2
|
+
/**
|
|
3
|
+
* EXPERIMENTAL: this class, and the agent-management tools built on it
|
|
4
|
+
* (src/tools/agent/), are new and still settling — names and behavior may
|
|
5
|
+
* change in a future release.
|
|
6
|
+
*
|
|
7
|
+
* A BaseAgent with an identity a *hiring* agent can reason about — name,
|
|
8
|
+
* description (persona/specialty), and a rating per task type — so it can
|
|
9
|
+
* be listed, compared against other workers, and hired via the tools in
|
|
10
|
+
* `src/tools/agent/` (see AgentTools()). Everything about running it (tool
|
|
11
|
+
* dispatch, memory, streaming) is unchanged from BaseAgent; WorkerAgent only
|
|
12
|
+
* adds metadata on top.
|
|
13
|
+
*
|
|
14
|
+
* Like BaseAgent, this is a raw building block: you still bring your own
|
|
15
|
+
* `mcpClient`/`allowedTools`. If you want this worker to be able to report
|
|
16
|
+
* back to whoever hired it, include AgentReportTool() (from
|
|
17
|
+
* `src/tools/agent/`) in its own tools, same as any other tool.
|
|
18
|
+
*/
|
|
19
|
+
export class WorkerAgent extends BaseAgent {
|
|
20
|
+
#name;
|
|
21
|
+
#description;
|
|
22
|
+
#rating;
|
|
23
|
+
constructor({ name, description, rating = {}, ...baseAgentOptions }) {
|
|
24
|
+
super(baseAgentOptions);
|
|
25
|
+
this.#name = name;
|
|
26
|
+
this.#description = description;
|
|
27
|
+
this.#rating = rating;
|
|
28
|
+
}
|
|
29
|
+
getName() {
|
|
30
|
+
return this.#name;
|
|
31
|
+
}
|
|
32
|
+
getDescription() {
|
|
33
|
+
return this.#description;
|
|
34
|
+
}
|
|
35
|
+
getRating() {
|
|
36
|
+
return this.#rating;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export default WorkerAgent;
|
|
40
|
+
//# sourceMappingURL=worker-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-agent.js","sourceRoot":"","sources":["../../src/core/worker-agent.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,iBAAiB,CAAC;AAYxC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,WAAY,SAAQ,SAAS;IACtC,KAAK,CAAS;IACd,YAAY,CAAS;IACrB,OAAO,CAAoB;IAE3B,YAAY,EACR,IAAI,EACJ,WAAW,EACX,MAAM,GAAG,EAAE,EACX,GAAG,gBAAgB,EAQuB;QAC1C,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAC1B,CAAC;IAED,OAAO;QACH,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,cAAc;QACV,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED,SAAS;QACL,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;CACJ;AAED,eAAe,WAAW,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { AIProvider } from "./core/ai-provider.js";
|
|
2
2
|
export type { ChatResponse, Message, StreamCallback, ToolSchema, ToolCallRequest, MessageContentPart, ProviderCapabilities } from "./core/ai-provider.js";
|
|
3
|
+
export { resolveThinkEffortLevel, clampThinkEffort } from "./core/think-effort.js";
|
|
4
|
+
export type { ThinkEffortLevel } from "./core/think-effort.js";
|
|
3
5
|
export { BaseAgent } from "./core/base-agent.js";
|
|
4
6
|
export type { ExtractedSegment, ParsedToolCall } from "./core/base-agent.js";
|
|
5
7
|
export { DeepSeekProvider } from "./core/deepseek-provider.js";
|
|
@@ -24,6 +26,10 @@ export { MCPStorage } from "./core/mcp-storage.js";
|
|
|
24
26
|
export { MCPFSStorage } from "./core/mcp-fs-storage.js";
|
|
25
27
|
export { MCPFilter } from "./core/mcp-filter.js";
|
|
26
28
|
export { SimpleAgent } from "./templates/simple.js";
|
|
29
|
+
export { WorkerAgent } from "./core/worker-agent.js";
|
|
30
|
+
export type { WorkerAgentRating } from "./core/worker-agent.js";
|
|
31
|
+
export { AgentTools, AgentListTool, AgentHireTool, AgentPromptTool, AgentReportTool, AgentRegistry, AgentInteraction, } from "./tools/agent/index.js";
|
|
32
|
+
export type { AgentInfo, AgentEvent, AgentToolsOptions } from "./tools/agent/index.js";
|
|
27
33
|
export { GetCurrentTimeTool, DelayTool, UtilTools } from "./tools/utils/index.js";
|
|
28
34
|
export { TodoCreateListTool, TodoRemoveListTool, TodoGetListsTool, TodoGetListTool, TodoCreateTaskTool, TodoRemoveTaskTool, TodoCheckTaskTool, TodoTools, TodoInteraction, } from "./tools/todo/index.js";
|
|
29
35
|
export type { TodoTask, TodoList, TodoEvent } from "./tools/todo/index.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,eAAe,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC1J,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC5F,YAAY,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,eAAe,CAA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BAAuB,CAAC;AAEvD,OAAO,EACH,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EACrB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EACH,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,EAC5B,MAAM,kCAAkC,CAAC;AAC1C,YAAY,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { AIProvider } from "./core/ai-provider.js";
|
|
2
|
+
export { resolveThinkEffortLevel, clampThinkEffort } from "./core/think-effort.js";
|
|
2
3
|
export { BaseAgent } from "./core/base-agent.js";
|
|
3
4
|
export { DeepSeekProvider } from "./core/deepseek-provider.js";
|
|
4
5
|
export { OpenAIProvider } from "./core/openai-provider.js";
|
|
@@ -20,6 +21,8 @@ export { MCPStorage } from "./core/mcp-storage.js";
|
|
|
20
21
|
export { MCPFSStorage } from "./core/mcp-fs-storage.js";
|
|
21
22
|
export { MCPFilter } from "./core/mcp-filter.js";
|
|
22
23
|
export { SimpleAgent } from "./templates/simple.js";
|
|
24
|
+
export { WorkerAgent } from "./core/worker-agent.js";
|
|
25
|
+
export { AgentTools, AgentListTool, AgentHireTool, AgentPromptTool, AgentReportTool, AgentRegistry, AgentInteraction, } from "./tools/agent/index.js";
|
|
23
26
|
export { GetCurrentTimeTool, DelayTool, UtilTools } from "./tools/utils/index.js";
|
|
24
27
|
export { TodoCreateListTool, TodoRemoveListTool, TodoGetListsTool, TodoGetListTool, TodoCreateTaskTool, TodoRemoveTaskTool, TodoCheckTaskTool, TodoTools, TodoInteraction, } from "./tools/todo/index.js";
|
|
25
28
|
export { BrowserCreateSessionTool, BrowserRemoveSessionTool, BrowserGetSessionsTool, BrowserNavigateTool, BrowserConsoleTool, BrowserInjectTool, BrowserReadTool, BrowserClickTool, BrowserFillTool, BrowserScrollInfoTool, BrowserScrollTool, BrowserNetworkStatusTool, BrowserNetworkTool, BrowserSubmitFormTool, BrowserScreenshotTool, BrowserTools, BrowserInteraction, } from "./tools/browser/index.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB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M,qBAAqB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC"}
|
package/dist/tests/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tests/index.ts"],"names":[],"mappings":"AAAA,OAAO,6BAA6B,CAAC;AACrC,OAAO,+BAA+B,CAAC;AACvC,OAAO,mCAAmC,CAAC;AAC3C,OAAO,kCAAkC,CAAC;AAG1C,OAAO,6BAA6B,CAAC;AACrC,OAAO,wCAAwC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tests/index.ts"],"names":[],"mappings":"AAAA,OAAO,6BAA6B,CAAC;AACrC,OAAO,+BAA+B,CAAC;AACvC,OAAO,mCAAmC,CAAC;AAC3C,OAAO,kCAAkC,CAAC;AAG1C,OAAO,6BAA6B,CAAC;AACrC,OAAO,wCAAwC,CAAC;AAChD,OAAO,mCAAmC,CAAC"}
|
package/dist/tests/index.js
CHANGED
package/dist/tests/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tests/index.ts"],"names":[],"mappings":"AAAA,OAAO,6BAA6B,CAAC;AACrC,OAAO,+BAA+B,CAAC;AACvC,OAAO,mCAAmC,CAAC;AAC3C,OAAO,kCAAkC,CAAC;AAG1C,OAAO,6BAA6B,CAAC;AACrC,OAAO,wCAAwC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tests/index.ts"],"names":[],"mappings":"AAAA,OAAO,6BAA6B,CAAC;AACrC,OAAO,+BAA+B,CAAC;AACvC,OAAO,mCAAmC,CAAC;AAC3C,OAAO,kCAAkC,CAAC;AAG1C,OAAO,6BAA6B,CAAC;AACrC,OAAO,wCAAwC,CAAC;AAChD,OAAO,mCAAmC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-tools.test.d.ts","sourceRoot":"","sources":["../../../../src/tests/tools/agent/agent-tools.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { AIProvider, AgentReportTool, AgentTools, MCPClient, MCPConnection, MCPServer, WorkerAgent, } from "../../../index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Returns a fixed, scripted response (or repeats the last one once
|
|
6
|
+
* exhausted) instead of calling a real model — lets the agent-management
|
|
7
|
+
* tools be tested end to end (hire -> prompt -> worker's own tool loop ->
|
|
8
|
+
* report) with no network access.
|
|
9
|
+
*/
|
|
10
|
+
class ScriptedProvider extends AIProvider {
|
|
11
|
+
#responses;
|
|
12
|
+
#calls = 0;
|
|
13
|
+
constructor(responses) {
|
|
14
|
+
super();
|
|
15
|
+
this.#responses = responses;
|
|
16
|
+
}
|
|
17
|
+
async chat(_messages, streamCallback, _tools) {
|
|
18
|
+
const response = this.#responses[Math.min(this.#calls, this.#responses.length - 1)];
|
|
19
|
+
this.#calls++;
|
|
20
|
+
if (streamCallback) {
|
|
21
|
+
if (response.content) {
|
|
22
|
+
await streamCallback({ role: "assistant", content: response.content, done: false });
|
|
23
|
+
}
|
|
24
|
+
await streamCallback({
|
|
25
|
+
role: "assistant",
|
|
26
|
+
content: "",
|
|
27
|
+
done: true,
|
|
28
|
+
...(response.toolCalls?.length ? { toolCalls: response.toolCalls } : {}),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return response;
|
|
32
|
+
}
|
|
33
|
+
getCapabilities() {
|
|
34
|
+
return { supportsTools: true, supportsImages: false, contextWindow: 200_000, safeUsageRatio: 0.9 };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function buildWorker(name, description, responses) {
|
|
38
|
+
const connection = new MCPConnection();
|
|
39
|
+
const server = new MCPServer(connection);
|
|
40
|
+
const reportTool = AgentReportTool();
|
|
41
|
+
server.registerTool(reportTool);
|
|
42
|
+
const mcpClient = new MCPClient(`worker-${name}`, connection);
|
|
43
|
+
return new WorkerAgent({
|
|
44
|
+
name,
|
|
45
|
+
description,
|
|
46
|
+
rating: { backend: 8, frontend: 3 },
|
|
47
|
+
instruction: "You are a worker agent.",
|
|
48
|
+
aiProvider: new ScriptedProvider(responses),
|
|
49
|
+
mcpClient,
|
|
50
|
+
allowedTools: [reportTool],
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
test("AgentTools: agent-list shows every worker, unhired by default", async () => {
|
|
54
|
+
const worker = buildWorker("backend-worker", "Handles backend tasks.", [{ content: "unused", inputTokens: 0, outputTokens: 0 }]);
|
|
55
|
+
const [listTool] = AgentTools([worker]);
|
|
56
|
+
const result = await listTool.getOptions().execute("env", {});
|
|
57
|
+
assert.strictEqual(result.agents.length, 1);
|
|
58
|
+
assert.strictEqual(result.agents[0].name, "backend-worker");
|
|
59
|
+
assert.strictEqual(result.agents[0].description, "Handles backend tasks.");
|
|
60
|
+
assert.deepStrictEqual(result.agents[0].rating, { backend: 8, frontend: 3 });
|
|
61
|
+
assert.strictEqual(result.agents[0].hired, false);
|
|
62
|
+
});
|
|
63
|
+
test("AgentTools: agent-hire marks a worker hired, reflected in agent-list", async () => {
|
|
64
|
+
const worker = buildWorker("backend-worker", "Handles backend tasks.", [{ content: "unused", inputTokens: 0, outputTokens: 0 }]);
|
|
65
|
+
const [listTool, hireTool] = AgentTools([worker]);
|
|
66
|
+
const hireResult = await hireTool.getOptions().execute("env", { name: "backend-worker" });
|
|
67
|
+
assert.deepStrictEqual(hireResult, { hired: true, name: "backend-worker" });
|
|
68
|
+
const listResult = await listTool.getOptions().execute("env", {});
|
|
69
|
+
assert.strictEqual(listResult.agents[0].hired, true);
|
|
70
|
+
});
|
|
71
|
+
test("AgentTools: agent-hire on an unknown name throws", async () => {
|
|
72
|
+
const worker = buildWorker("backend-worker", "Handles backend tasks.", [{ content: "unused", inputTokens: 0, outputTokens: 0 }]);
|
|
73
|
+
const [, hireTool] = AgentTools([worker]);
|
|
74
|
+
await assert.rejects(() => hireTool.getOptions().execute("env", { name: "nonexistent" }), /no worker agent named "nonexistent"/);
|
|
75
|
+
});
|
|
76
|
+
test("AgentTools: agent-prompt on a worker that isn't hired yet throws", async () => {
|
|
77
|
+
const worker = buildWorker("backend-worker", "Handles backend tasks.", [{ content: "unused", inputTokens: 0, outputTokens: 0 }]);
|
|
78
|
+
const [, , promptTool] = AgentTools([worker]);
|
|
79
|
+
await assert.rejects(() => promptTool.getOptions().execute("env", { name: "backend-worker", prompt: "do it" }), /is not hired yet/);
|
|
80
|
+
});
|
|
81
|
+
test("AgentTools: agent-prompt runs the worker and returns its agent-report text", async () => {
|
|
82
|
+
const reportCall = { id: "call-1", name: "agent-report", inputs: { report: "answer is 42" } };
|
|
83
|
+
const worker = buildWorker("backend-worker", "Handles backend tasks.", [
|
|
84
|
+
{ content: "", inputTokens: 10, outputTokens: 5, toolCalls: [reportCall] },
|
|
85
|
+
]);
|
|
86
|
+
const [, hireTool, promptTool] = AgentTools([worker]);
|
|
87
|
+
await hireTool.getOptions().execute("env", { name: "backend-worker" });
|
|
88
|
+
const result = await promptTool.getOptions().execute("env", { name: "backend-worker", prompt: "what is the answer?" });
|
|
89
|
+
assert.strictEqual(result.reported, true);
|
|
90
|
+
assert.strictEqual(result.report, "answer is 42");
|
|
91
|
+
});
|
|
92
|
+
test("AgentTools: agent-prompt falls back to the worker's last assistant text when it never calls agent-report", async () => {
|
|
93
|
+
const worker = buildWorker("backend-worker", "Handles backend tasks.", [
|
|
94
|
+
{ content: "I looked into it, no tool needed.", inputTokens: 10, outputTokens: 5 },
|
|
95
|
+
]);
|
|
96
|
+
const [, hireTool, promptTool] = AgentTools([worker]);
|
|
97
|
+
await hireTool.getOptions().execute("env", { name: "backend-worker" });
|
|
98
|
+
const result = await promptTool.getOptions().execute("env", { name: "backend-worker", prompt: "check something" });
|
|
99
|
+
assert.strictEqual(result.reported, false);
|
|
100
|
+
assert.strictEqual(result.report, "I looked into it, no tool needed.");
|
|
101
|
+
});
|
|
102
|
+
test("AgentTools: a second agent-prompt call doesn't resurface a stale report from the first call", async () => {
|
|
103
|
+
const reportCall = { id: "call-1", name: "agent-report", inputs: { report: "first answer" } };
|
|
104
|
+
const worker = buildWorker("backend-worker", "Handles backend tasks.", [
|
|
105
|
+
{ content: "", inputTokens: 10, outputTokens: 5, toolCalls: [reportCall] },
|
|
106
|
+
{ content: "just acknowledging, no report this time", inputTokens: 10, outputTokens: 5 },
|
|
107
|
+
]);
|
|
108
|
+
const [, hireTool, promptTool] = AgentTools([worker]);
|
|
109
|
+
await hireTool.getOptions().execute("env", { name: "backend-worker" });
|
|
110
|
+
await promptTool.getOptions().execute("env", { name: "backend-worker", prompt: "first task" });
|
|
111
|
+
const second = await promptTool.getOptions().execute("env", { name: "backend-worker", prompt: "second task" });
|
|
112
|
+
assert.strictEqual(second.reported, false);
|
|
113
|
+
assert.strictEqual(second.report, "just acknowledging, no report this time");
|
|
114
|
+
});
|
|
115
|
+
test("AgentTools: duplicate worker names are rejected at construction", async () => {
|
|
116
|
+
const workerA = buildWorker("dup", "A", [{ content: "x", inputTokens: 0, outputTokens: 0 }]);
|
|
117
|
+
const workerB = buildWorker("dup", "B", [{ content: "x", inputTokens: 0, outputTokens: 0 }]);
|
|
118
|
+
assert.throws(() => AgentTools([workerA, workerB]), /duplicate worker agent name "dup"/);
|
|
119
|
+
});
|
|
120
|
+
test("AgentTools: maxHired is mentioned dynamically in agent-hire's description", async () => {
|
|
121
|
+
const worker = buildWorker("backend-worker", "Handles backend tasks.", [{ content: "x", inputTokens: 0, outputTokens: 0 }]);
|
|
122
|
+
const [, hireTool] = AgentTools([worker], { maxHired: 2 });
|
|
123
|
+
assert.match(hireTool.getOptions().description, /At most 2 worker agents may be hired at once/);
|
|
124
|
+
});
|
|
125
|
+
test("AgentTools: agent-hire has no limit note when maxHired is omitted", async () => {
|
|
126
|
+
const worker = buildWorker("backend-worker", "Handles backend tasks.", [{ content: "x", inputTokens: 0, outputTokens: 0 }]);
|
|
127
|
+
const [, hireTool] = AgentTools([worker]);
|
|
128
|
+
assert.doesNotMatch(hireTool.getOptions().description, /At most/);
|
|
129
|
+
});
|
|
130
|
+
test("AgentTools: hiring beyond maxHired throws, but re-hiring an already-hired worker doesn't count against it", async () => {
|
|
131
|
+
const workerA = buildWorker("worker-a", "A", [{ content: "x", inputTokens: 0, outputTokens: 0 }]);
|
|
132
|
+
const workerB = buildWorker("worker-b", "B", [{ content: "x", inputTokens: 0, outputTokens: 0 }]);
|
|
133
|
+
const workerC = buildWorker("worker-c", "C", [{ content: "x", inputTokens: 0, outputTokens: 0 }]);
|
|
134
|
+
const [listTool, hireTool] = AgentTools([workerA, workerB, workerC], { maxHired: 1 });
|
|
135
|
+
await hireTool.getOptions().execute("env", { name: "worker-a" });
|
|
136
|
+
// re-hiring the same worker is a no-op, must not count twice against the limit
|
|
137
|
+
await hireTool.getOptions().execute("env", { name: "worker-a" });
|
|
138
|
+
await assert.rejects(() => hireTool.getOptions().execute("env", { name: "worker-b" }), /maximum of 1 hired agent\(s\) already reached/);
|
|
139
|
+
const listResult = await listTool.getOptions().execute("env", {});
|
|
140
|
+
assert.strictEqual(listResult.hiredCount, 1);
|
|
141
|
+
assert.strictEqual(listResult.maxHired, 1);
|
|
142
|
+
});
|
|
143
|
+
test("AgentTools: agent-list omits maxHired when no limit was configured", async () => {
|
|
144
|
+
const worker = buildWorker("backend-worker", "Handles backend tasks.", [{ content: "x", inputTokens: 0, outputTokens: 0 }]);
|
|
145
|
+
const [listTool] = AgentTools([worker]);
|
|
146
|
+
const result = await listTool.getOptions().execute("env", {});
|
|
147
|
+
assert.strictEqual(result.hiredCount, 0);
|
|
148
|
+
assert.strictEqual("maxHired" in result, false);
|
|
149
|
+
});
|
|
150
|
+
test("AgentTools: maxHired must be a positive integer when given", async () => {
|
|
151
|
+
const worker = buildWorker("backend-worker", "Handles backend tasks.", [{ content: "x", inputTokens: 0, outputTokens: 0 }]);
|
|
152
|
+
assert.throws(() => AgentTools([worker], { maxHired: 0 }), /maxHired must be a positive integer/);
|
|
153
|
+
assert.throws(() => AgentTools([worker], { maxHired: -1 }), /maxHired must be a positive integer/);
|
|
154
|
+
assert.throws(() => AgentTools([worker], { maxHired: 1.5 }), /maxHired must be a positive integer/);
|
|
155
|
+
});
|
|
156
|
+
//# sourceMappingURL=agent-tools.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-tools.test.js","sourceRoot":"","sources":["../../../../src/tests/tools/agent/agent-tools.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EACH,UAAU,EACV,eAAe,EACf,UAAU,EACV,SAAS,EACT,aAAa,EACb,SAAS,EACT,WAAW,GAOd,MAAM,mBAAmB,CAAC;AAE3B;;;;;GAKG;AACH,MAAM,gBAAiB,SAAQ,UAAU;IACrC,UAAU,CAAiB;IAC3B,MAAM,GAAG,CAAC,CAAC;IAEX,YAAY,SAAyB;QACjC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,SAAoB,EAAE,cAA+B,EAAE,MAAqB;QACnF,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,C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@@
|
|
|
1
|
+
import { MCPTool } from "../../core/mcp.js";
|
|
2
|
+
import { AgentInteraction } from "./interaction.js";
|
|
3
|
+
import type AgentRegistry from "./registry.js";
|
|
4
|
+
export declare const AgentHireTool: (registry: AgentRegistry) => MCPTool<AgentInteraction>;
|
|
5
|
+
export default AgentHireTool;
|
|
6
|
+
//# sourceMappingURL=hire.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hire.d.ts","sourceRoot":"","sources":["../../../src/tools/agent/hire.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAY,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,aAAa,MAAM,eAAe,CAAC;AAE/C,eAAO,MAAM,aAAa,GAAI,UAAU,aAAa,8BAoCpD,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { MCPTool } from "../../core/mcp.js";
|
|
2
|
+
import { AgentInteraction } from "./interaction.js";
|
|
3
|
+
export const AgentHireTool = (registry) => {
|
|
4
|
+
const maxHired = registry.getMaxHired();
|
|
5
|
+
const limitNote = maxHired !== undefined
|
|
6
|
+
? ` At most ${maxHired} worker agent${maxHired === 1 ? "" : "s"} may be hired at once — hiring beyond that will fail until fewer than ${maxHired} are currently hired, so choose which agent(s) to hire carefully.`
|
|
7
|
+
: "";
|
|
8
|
+
return new MCPTool({
|
|
9
|
+
name: "agent-hire",
|
|
10
|
+
description: `hire a worker agent by name (see agent-list), making it active. Required once per agent before agent-prompt will work on it — hiring the same agent again is a harmless no-op.${limitNote}`,
|
|
11
|
+
inputs: [
|
|
12
|
+
{
|
|
13
|
+
name: "name",
|
|
14
|
+
type: "string",
|
|
15
|
+
description: "the worker agent's name, exactly as shown by agent-list",
|
|
16
|
+
required: true,
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
customClass: new AgentInteraction(),
|
|
20
|
+
execute: async (_envID, inputs, _mcp, customClass) => {
|
|
21
|
+
const { name } = inputs;
|
|
22
|
+
if (!name || typeof name !== "string") {
|
|
23
|
+
throw new Error("name must be a non-empty string");
|
|
24
|
+
}
|
|
25
|
+
registry.hire(name);
|
|
26
|
+
customClass?.emitAgentEvent({ type: "hired", name });
|
|
27
|
+
return { hired: true, name };
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
export default AgentHireTool;
|
|
32
|
+
//# sourceMappingURL=hire.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hire.js","sourceRoot":"","sources":["../../../src/tools/agent/hire.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAY,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGpD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,QAAuB,EAAE,EAAE;IACrD,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IACxC,MAAM,SAAS,GAAG,QAAQ,KAAK,SAAS;QACpC,CAAC,CAAC,YAAY,QAAQ,gBAAgB,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,yEAAyE,QAAQ,mEAAmE;QACnN,CAAC,CAAC,EAAE,CAAC;IAET,OAAO,IAAI,OAAO,CAAmB;QACjC,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,iLAAiL,SAAS,EAAE;QACzM,MAAM,EAAE;YACJ;gBACI,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,yDAAyD;gBACtE,QAAQ,EAAE,IAAI;aACjB;SACJ;QACD,WAAW,EAAE,IAAI,gBAAgB,EAAE;QACnC,OAAO,EAAE,KAAK,EACV,MAAc,EACd,MAA2B,EAC3B,IAAU,EACV,WAA8B,EAClB,EAAE;YACd,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;YAExB,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACpC,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;YACvD,CAAC;YAED,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACpB,WAAW,EAAE,cAAc,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;YAErD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACjC,CAAC;KACJ,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { AgentListTool } from "./list.js";
|
|
2
|
+
export { AgentHireTool } from "./hire.js";
|
|
3
|
+
export { AgentPromptTool } from "./prompt.js";
|
|
4
|
+
export { AgentReportTool } from "./report.js";
|
|
5
|
+
export { AgentRegistry } from "./registry.js";
|
|
6
|
+
export { AgentInteraction } from "./interaction.js";
|
|
7
|
+
export type { AgentInfo } from "./registry.js";
|
|
8
|
+
export type { AgentEvent } from "./interaction.js";
|
|
9
|
+
import type WorkerAgent from "../../core/worker-agent.js";
|
|
10
|
+
export interface AgentToolsOptions {
|
|
11
|
+
/** Cap on how many workers may be hired at once. Omit for no limit. Surfaced dynamically in agent-hire's own description (and in agent-list's output) so the model knows the constraint without being told out of band. */
|
|
12
|
+
maxHired?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* EXPERIMENTAL — see the note on WorkerAgent (src/core/worker-agent.ts).
|
|
16
|
+
*
|
|
17
|
+
* Planner-side tools for a fixed roster of WorkerAgents: list them, hire
|
|
18
|
+
* one, and prompt a hired one. Each call builds its own AgentRegistry, so
|
|
19
|
+
* separate AgentTools(...) calls (e.g. for two different planners in the
|
|
20
|
+
* same process) never share hire state.
|
|
21
|
+
*
|
|
22
|
+
* Not included here: AgentReportTool — that one goes on each *worker's*
|
|
23
|
+
* own tool list instead, not the planner's. Import it separately.
|
|
24
|
+
*/
|
|
25
|
+
export declare const AgentTools: (availableAgents: WorkerAgent[], options?: AgentToolsOptions) => (import("../../index.js").MCPTool<undefined> | import("../../index.js").MCPTool<import("./interaction.js").AgentInteraction>)[];
|
|
26
|
+
export default AgentTools;
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/agent/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,WAAW,MAAM,4BAA4B,CAAC;AAM1D,MAAM,WAAW,iBAAiB;IAC9B,2NAA2N;IAC3N,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,GAAI,iBAAiB,WAAW,EAAE,EAAE,UAAS,iBAAsB,oIAOzF,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export { AgentListTool } from "./list.js";
|
|
2
|
+
export { AgentHireTool } from "./hire.js";
|
|
3
|
+
export { AgentPromptTool } from "./prompt.js";
|
|
4
|
+
export { AgentReportTool } from "./report.js";
|
|
5
|
+
export { AgentRegistry } from "./registry.js";
|
|
6
|
+
export { AgentInteraction } from "./interaction.js";
|
|
7
|
+
import { AgentListTool } from "./list.js";
|
|
8
|
+
import { AgentHireTool } from "./hire.js";
|
|
9
|
+
import { AgentPromptTool } from "./prompt.js";
|
|
10
|
+
import { AgentRegistry } from "./registry.js";
|
|
11
|
+
/**
|
|
12
|
+
* EXPERIMENTAL — see the note on WorkerAgent (src/core/worker-agent.ts).
|
|
13
|
+
*
|
|
14
|
+
* Planner-side tools for a fixed roster of WorkerAgents: list them, hire
|
|
15
|
+
* one, and prompt a hired one. Each call builds its own AgentRegistry, so
|
|
16
|
+
* separate AgentTools(...) calls (e.g. for two different planners in the
|
|
17
|
+
* same process) never share hire state.
|
|
18
|
+
*
|
|
19
|
+
* Not included here: AgentReportTool — that one goes on each *worker's*
|
|
20
|
+
* own tool list instead, not the planner's. Import it separately.
|
|
21
|
+
*/
|
|
22
|
+
export const AgentTools = (availableAgents, options = {}) => {
|
|
23
|
+
const registry = new AgentRegistry(availableAgents, options.maxHired);
|
|
24
|
+
return [
|
|
25
|
+
AgentListTool(registry),
|
|
26
|
+
AgentHireTool(registry),
|
|
27
|
+
AgentPromptTool(registry),
|
|
28
|
+
];
|
|
29
|
+
};
|
|
30
|
+
export default AgentTools;
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/agent/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAKpD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAO9C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,eAA8B,EAAE,UAA6B,EAAE,EAAE,EAAE;IAC1F,MAAM,QAAQ,GAAG,IAAI,aAAa,CAAC,eAAe,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtE,OAAO;QACH,aAAa,CAAC,QAAQ,CAAC;QACvB,aAAa,CAAC,QAAQ,CAAC;QACvB,eAAe,CAAC,QAAQ,CAAC;KAC5B,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { MCPCustomClass } from "../../core/mcp.js";
|
|
2
|
+
export type AgentEvent = {
|
|
3
|
+
type: "hired";
|
|
4
|
+
name: string;
|
|
5
|
+
} | {
|
|
6
|
+
type: "prompted";
|
|
7
|
+
name: string;
|
|
8
|
+
prompt: string;
|
|
9
|
+
} | {
|
|
10
|
+
type: "reported";
|
|
11
|
+
name: string;
|
|
12
|
+
reported: boolean;
|
|
13
|
+
report: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Shared custom interaction class for the agent-management tools. A
|
|
17
|
+
* frontend can listen on getEvents() to show live status (e.g. "Hiring
|
|
18
|
+
* backend-worker...", "backend-worker is working...") while the planner
|
|
19
|
+
* hires and prompts worker agents.
|
|
20
|
+
*/
|
|
21
|
+
export declare class AgentInteraction extends MCPCustomClass {
|
|
22
|
+
emitAgentEvent(event: AgentEvent): void;
|
|
23
|
+
}
|
|
24
|
+
export default AgentInteraction;
|
|
25
|
+
//# sourceMappingURL=interaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interaction.d.ts","sourceRoot":"","sources":["../../../src/tools/agent/interaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,MAAM,UAAU,GAChB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5E;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,cAAc;IAChD,cAAc,CAAC,KAAK,EAAE,UAAU;CAGnC;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MCPCustomClass } from "../../core/mcp.js";
|
|
2
|
+
/**
|
|
3
|
+
* Shared custom interaction class for the agent-management tools. A
|
|
4
|
+
* frontend can listen on getEvents() to show live status (e.g. "Hiring
|
|
5
|
+
* backend-worker...", "backend-worker is working...") while the planner
|
|
6
|
+
* hires and prompts worker agents.
|
|
7
|
+
*/
|
|
8
|
+
export class AgentInteraction extends MCPCustomClass {
|
|
9
|
+
emitAgentEvent(event) {
|
|
10
|
+
this.getEvents().emit("agent", event);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export default AgentInteraction;
|
|
14
|
+
//# sourceMappingURL=interaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interaction.js","sourceRoot":"","sources":["../../../src/tools/agent/interaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAOnD;;;;;GAKG;AACH,MAAM,OAAO,gBAAiB,SAAQ,cAAc;IAChD,cAAc,CAAC,KAAiB;QAC5B,IAAI,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;CACJ;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/tools/agent/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,aAAa,MAAM,eAAe,CAAC;AAE/C,eAAO,MAAM,aAAa,GAAI,UAAU,aAAa,uBAYnD,CAAC;AAEH,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MCPTool } from "../../core/mcp.js";
|
|
2
|
+
export const AgentListTool = (registry) => new MCPTool({
|
|
3
|
+
name: "agent-list",
|
|
4
|
+
description: "list every worker agent available to hire, with their name, description/persona, per-task-type rating, and whether they're already hired. Check this before hiring — pick whichever agent's rating best fits the task at hand, and check hiredCount against maxHired if there's a hiring limit.",
|
|
5
|
+
inputs: [],
|
|
6
|
+
execute: async () => {
|
|
7
|
+
const maxHired = registry.getMaxHired();
|
|
8
|
+
return {
|
|
9
|
+
agents: registry.list(),
|
|
10
|
+
hiredCount: registry.getHiredCount(),
|
|
11
|
+
...(maxHired !== undefined ? { maxHired } : {}),
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
export default AgentListTool;
|
|
16
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/tools/agent/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,QAAuB,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC;IAClE,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,iSAAiS;IAC9S,MAAM,EAAE,EAAE;IACV,OAAO,EAAE,KAAK,IAAkB,EAAE;QAC9B,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;QACxC,OAAO;YACH,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE;YACvB,UAAU,EAAE,QAAQ,CAAC,aAAa,EAAE;YACpC,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAClD,CAAC;IACN,CAAC;CACJ,CAAC,CAAC;AAEH,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MCPTool } from "../../core/mcp.js";
|
|
2
|
+
import { AgentInteraction } from "./interaction.js";
|
|
3
|
+
import type AgentRegistry from "./registry.js";
|
|
4
|
+
export declare const AgentPromptTool: (registry: AgentRegistry) => MCPTool<AgentInteraction>;
|
|
5
|
+
export default AgentPromptTool;
|
|
6
|
+
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","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;AACpD,OAAO,KAAK,aAAa,MAAM,eAAe,CAAC;AAE/C,eAAO,MAAM,eAAe,GAAI,UAAU,aAAa,8BAkFrD,CAAC;AAEH,eAAe,eAAe,CAAC"}
|