@dexto/agent-management 1.5.8 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AgentFactory.cjs +5 -9
- package/dist/AgentFactory.d.ts +6 -5
- package/dist/AgentFactory.d.ts.map +1 -1
- package/dist/AgentFactory.js +5 -9
- package/dist/AgentManager.cjs +2 -2
- package/dist/AgentManager.d.ts +1 -1
- package/dist/AgentManager.d.ts.map +1 -1
- package/dist/AgentManager.js +4 -4
- package/dist/agent-creation.cjs +95 -0
- package/dist/agent-creation.d.ts +15 -0
- package/dist/agent-creation.d.ts.map +1 -0
- package/dist/agent-creation.js +78 -0
- package/dist/config/config-enrichment.cjs +0 -11
- package/dist/config/config-enrichment.d.ts +1 -1
- package/dist/config/config-enrichment.d.ts.map +1 -1
- package/dist/config/config-enrichment.js +0 -11
- package/dist/config/config-manager.cjs +4 -4
- package/dist/config/config-manager.d.ts +1 -1
- package/dist/config/config-manager.d.ts.map +1 -1
- package/dist/config/config-manager.js +3 -1
- package/dist/config/loader.d.ts +3 -3
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/images/image-store.cjs +256 -0
- package/dist/images/image-store.d.ts +70 -0
- package/dist/images/image-store.d.ts.map +1 -0
- package/dist/images/image-store.js +210 -0
- package/dist/index.cjs +32 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -1
- package/dist/plugins/discover-plugins.cjs +15 -31
- package/dist/plugins/discover-plugins.d.ts.map +1 -1
- package/dist/plugins/discover-plugins.js +15 -31
- package/dist/plugins/index.cjs +0 -2
- package/dist/plugins/index.d.ts +5 -6
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +0 -2
- package/dist/plugins/list-plugins.cjs +3 -1
- package/dist/plugins/list-plugins.d.ts.map +1 -1
- package/dist/plugins/list-plugins.js +3 -1
- package/dist/plugins/load-plugin.cjs +0 -13
- package/dist/plugins/load-plugin.d.ts +3 -5
- package/dist/plugins/load-plugin.d.ts.map +1 -1
- package/dist/plugins/load-plugin.js +0 -13
- package/dist/plugins/schemas.cjs +1 -11
- package/dist/plugins/schemas.d.ts +14 -69
- package/dist/plugins/schemas.d.ts.map +1 -1
- package/dist/plugins/schemas.js +1 -10
- package/dist/plugins/types.d.ts +2 -20
- package/dist/plugins/types.d.ts.map +1 -1
- package/dist/plugins/validate-plugin.cjs +7 -37
- package/dist/plugins/validate-plugin.d.ts +6 -24
- package/dist/plugins/validate-plugin.d.ts.map +1 -1
- package/dist/plugins/validate-plugin.js +8 -38
- package/dist/registry/registry.d.ts +4 -44
- package/dist/registry/registry.d.ts.map +1 -1
- package/dist/runtime/AgentPool.d.ts +2 -2
- package/dist/runtime/AgentPool.d.ts.map +1 -1
- package/dist/runtime/AgentRuntime.cjs +20 -15
- package/dist/runtime/AgentRuntime.d.ts +2 -2
- package/dist/runtime/AgentRuntime.d.ts.map +1 -1
- package/dist/runtime/AgentRuntime.js +20 -15
- package/dist/runtime/approval-delegation.d.ts +2 -2
- package/dist/runtime/approval-delegation.d.ts.map +1 -1
- package/dist/runtime/schemas.d.ts +1 -1
- package/dist/runtime/types.d.ts +2 -1
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/{tool-provider → tool-factories/agent-spawner}/error-codes.d.ts +1 -1
- package/dist/tool-factories/agent-spawner/error-codes.d.ts.map +1 -0
- package/dist/{tool-provider → tool-factories/agent-spawner}/errors.d.ts +1 -1
- package/dist/tool-factories/agent-spawner/errors.d.ts.map +1 -0
- package/dist/tool-factories/agent-spawner/factory.cjs +290 -0
- package/dist/tool-factories/agent-spawner/factory.d.ts +4 -0
- package/dist/tool-factories/agent-spawner/factory.d.ts.map +1 -0
- package/dist/tool-factories/agent-spawner/factory.js +279 -0
- package/dist/{tool-provider → tool-factories/agent-spawner}/index.cjs +9 -9
- package/dist/{tool-provider → tool-factories/agent-spawner}/index.d.ts +3 -3
- package/dist/tool-factories/agent-spawner/index.d.ts.map +1 -0
- package/dist/{tool-provider → tool-factories/agent-spawner}/index.js +4 -4
- package/dist/tool-factories/agent-spawner/llm-resolution.d.ts.map +1 -0
- package/dist/{tool-provider/runtime-service.cjs → tool-factories/agent-spawner/runtime.cjs} +33 -71
- package/dist/{tool-provider/runtime-service.d.ts → tool-factories/agent-spawner/runtime.d.ts} +6 -6
- package/dist/tool-factories/agent-spawner/runtime.d.ts.map +1 -0
- package/dist/{tool-provider/runtime-service.js → tool-factories/agent-spawner/runtime.js} +29 -67
- package/dist/{tool-provider → tool-factories/agent-spawner}/schemas.cjs +2 -2
- package/dist/{tool-provider → tool-factories/agent-spawner}/schemas.d.ts +4 -4
- package/dist/tool-factories/agent-spawner/schemas.d.ts.map +1 -0
- package/dist/{tool-provider → tool-factories/agent-spawner}/schemas.js +2 -2
- package/dist/{tool-provider → tool-factories/agent-spawner}/spawn-agent-tool.cjs +8 -7
- package/dist/tool-factories/agent-spawner/spawn-agent-tool.d.ts +11 -0
- package/dist/tool-factories/agent-spawner/spawn-agent-tool.d.ts.map +1 -0
- package/dist/{tool-provider → tool-factories/agent-spawner}/spawn-agent-tool.js +8 -7
- package/dist/tool-factories/agent-spawner/types.d.ts.map +1 -0
- package/dist/writer.d.ts +2 -1
- package/dist/writer.d.ts.map +1 -1
- package/package.json +6 -4
- package/dist/tool-provider/error-codes.d.ts.map +0 -1
- package/dist/tool-provider/errors.d.ts.map +0 -1
- package/dist/tool-provider/index.d.ts.map +0 -1
- package/dist/tool-provider/llm-resolution.d.ts.map +0 -1
- package/dist/tool-provider/runtime-service.d.ts.map +0 -1
- package/dist/tool-provider/schemas.d.ts.map +0 -1
- package/dist/tool-provider/spawn-agent-tool.d.ts +0 -10
- package/dist/tool-provider/spawn-agent-tool.d.ts.map +0 -1
- package/dist/tool-provider/tool-provider.cjs +0 -197
- package/dist/tool-provider/tool-provider.d.ts +0 -30
- package/dist/tool-provider/tool-provider.d.ts.map +0 -1
- package/dist/tool-provider/tool-provider.js +0 -180
- package/dist/tool-provider/types.d.ts.map +0 -1
- /package/dist/{tool-provider → tool-factories/agent-spawner}/error-codes.cjs +0 -0
- /package/dist/{tool-provider → tool-factories/agent-spawner}/error-codes.js +0 -0
- /package/dist/{tool-provider → tool-factories/agent-spawner}/errors.cjs +0 -0
- /package/dist/{tool-provider → tool-factories/agent-spawner}/errors.js +0 -0
- /package/dist/{tool-provider → tool-factories/agent-spawner}/llm-resolution.cjs +0 -0
- /package/dist/{tool-provider → tool-factories/agent-spawner}/llm-resolution.d.ts +0 -0
- /package/dist/{tool-provider → tool-factories/agent-spawner}/llm-resolution.js +0 -0
- /package/dist/{tool-provider → tool-factories/agent-spawner}/types.cjs +0 -0
- /package/dist/{tool-provider → tool-factories/agent-spawner}/types.d.ts +0 -0
- /package/dist/{tool-provider → tool-factories/agent-spawner}/types.js +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { DextoRuntimeError, ErrorType } from "@dexto/core";
|
|
2
|
-
import { AgentRuntime } from "
|
|
3
|
-
import { createDelegatingApprovalHandler } from "
|
|
4
|
-
import { loadAgentConfig } from "
|
|
5
|
-
import { getAgentRegistry } from "
|
|
6
|
-
import { deriveDisplayName } from "
|
|
7
|
-
import { resolveBundledScript } from "
|
|
2
|
+
import { AgentRuntime } from "../../runtime/AgentRuntime.js";
|
|
3
|
+
import { createDelegatingApprovalHandler } from "../../runtime/approval-delegation.js";
|
|
4
|
+
import { loadAgentConfig } from "../../config/loader.js";
|
|
5
|
+
import { getAgentRegistry } from "../../registry/registry.js";
|
|
6
|
+
import { deriveDisplayName } from "../../registry/types.js";
|
|
7
|
+
import { resolveBundledScript } from "../../utils/path.js";
|
|
8
8
|
import * as path from "path";
|
|
9
9
|
import { resolveSubAgentLLM } from "./llm-resolution.js";
|
|
10
|
-
class
|
|
10
|
+
class AgentSpawnerRuntime {
|
|
11
11
|
runtime;
|
|
12
12
|
parentId;
|
|
13
13
|
parentAgent;
|
|
@@ -57,7 +57,7 @@ class RuntimeService {
|
|
|
57
57
|
logger
|
|
58
58
|
});
|
|
59
59
|
this.logger.debug(
|
|
60
|
-
`
|
|
60
|
+
`AgentSpawnerRuntime initialized for parent '${this.parentId}' (maxAgents: ${config.maxConcurrentAgents})`
|
|
61
61
|
);
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
@@ -131,23 +131,7 @@ class RuntimeService {
|
|
|
131
131
|
* @param options.sessionId - Optional session ID for progress events
|
|
132
132
|
*/
|
|
133
133
|
async fork(options) {
|
|
134
|
-
|
|
135
|
-
task: options.task,
|
|
136
|
-
instructions: options.instructions
|
|
137
|
-
};
|
|
138
|
-
if (options.agentId) {
|
|
139
|
-
spawnOptions.agentId = options.agentId;
|
|
140
|
-
}
|
|
141
|
-
if (options.autoApprove !== void 0) {
|
|
142
|
-
spawnOptions.autoApprove = options.autoApprove;
|
|
143
|
-
}
|
|
144
|
-
if (options.toolCallId) {
|
|
145
|
-
spawnOptions.toolCallId = options.toolCallId;
|
|
146
|
-
}
|
|
147
|
-
if (options.sessionId) {
|
|
148
|
-
spawnOptions.sessionId = options.sessionId;
|
|
149
|
-
}
|
|
150
|
-
return this.spawnAndExecute(spawnOptions);
|
|
134
|
+
return this.spawnAndExecute(options);
|
|
151
135
|
}
|
|
152
136
|
/**
|
|
153
137
|
* Set up progress event emission for a sub-agent.
|
|
@@ -169,10 +153,8 @@ class RuntimeService {
|
|
|
169
153
|
let toolCount = 0;
|
|
170
154
|
const tokenUsage = { input: 0, output: 0, total: 0 };
|
|
171
155
|
let currentTool = "";
|
|
172
|
-
const subAgentBus = subAgentHandle.agent.agentEventBus;
|
|
173
|
-
const parentBus = this.parentAgent.agentEventBus;
|
|
174
156
|
const emitProgress = (tool, args) => {
|
|
175
|
-
|
|
157
|
+
this.parentAgent.emit("service:event", {
|
|
176
158
|
service: "agent-spawner",
|
|
177
159
|
event: "progress",
|
|
178
160
|
toolCallId,
|
|
@@ -190,15 +172,10 @@ class RuntimeService {
|
|
|
190
172
|
const toolCallHandler = (event) => {
|
|
191
173
|
toolCount++;
|
|
192
174
|
let displayToolName = event.toolName;
|
|
193
|
-
if (displayToolName.startsWith("
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
displayToolName =
|
|
197
|
-
} else if (displayToolName.startsWith("mcp--")) {
|
|
198
|
-
const parts = displayToolName.split("--");
|
|
199
|
-
if (parts.length >= 3) {
|
|
200
|
-
displayToolName = parts.slice(2).join("--");
|
|
201
|
-
}
|
|
175
|
+
if (displayToolName.startsWith("mcp--")) {
|
|
176
|
+
const trimmed = displayToolName.substring("mcp--".length);
|
|
177
|
+
const parts = trimmed.split("--");
|
|
178
|
+
displayToolName = parts.length >= 2 ? parts.slice(1).join("--") : trimmed;
|
|
202
179
|
}
|
|
203
180
|
currentTool = displayToolName;
|
|
204
181
|
this.logger.debug(
|
|
@@ -217,11 +194,11 @@ class RuntimeService {
|
|
|
217
194
|
emitProgress(currentTool || "processing");
|
|
218
195
|
}
|
|
219
196
|
};
|
|
220
|
-
|
|
221
|
-
|
|
197
|
+
subAgentHandle.agent.on("llm:tool-call", toolCallHandler);
|
|
198
|
+
subAgentHandle.agent.on("llm:response", responseHandler);
|
|
222
199
|
return () => {
|
|
223
|
-
|
|
224
|
-
|
|
200
|
+
subAgentHandle.agent.off("llm:tool-call", toolCallHandler);
|
|
201
|
+
subAgentHandle.agent.off("llm:response", responseHandler);
|
|
225
202
|
};
|
|
226
203
|
}
|
|
227
204
|
/**
|
|
@@ -434,12 +411,12 @@ class RuntimeService {
|
|
|
434
411
|
*/
|
|
435
412
|
async buildSubAgentConfig(options, sessionId) {
|
|
436
413
|
const { agentId, inheritLlm, autoApprove } = options;
|
|
437
|
-
const
|
|
414
|
+
const parentSettings = this.parentAgent.config;
|
|
438
415
|
const currentParentLLM = this.parentAgent.getCurrentLLMConfig(sessionId);
|
|
439
416
|
this.logger.debug(
|
|
440
|
-
`[
|
|
417
|
+
`[AgentSpawnerRuntime] Building sub-agent config with LLM: ${currentParentLLM.provider}/${currentParentLLM.model}` + (sessionId ? ` (sessionId: ${sessionId})` : " (no sessionId)")
|
|
441
418
|
);
|
|
442
|
-
const
|
|
419
|
+
const permissionsMode = autoApprove ? "auto-approve" : "manual";
|
|
443
420
|
if (agentId) {
|
|
444
421
|
let configPath = null;
|
|
445
422
|
try {
|
|
@@ -477,17 +454,13 @@ class RuntimeService {
|
|
|
477
454
|
this.logger.debug(`Sub-agent LLM resolution: ${resolution.reason}`);
|
|
478
455
|
llmConfig = resolution.llm;
|
|
479
456
|
}
|
|
480
|
-
const filteredCustomTools = loadedConfig.customTools ? loadedConfig.customTools.filter(
|
|
481
|
-
(tool) => typeof tool === "object" && tool !== null && "type" in tool && tool.type !== "agent-spawner"
|
|
482
|
-
) : void 0;
|
|
483
457
|
return {
|
|
484
458
|
...loadedConfig,
|
|
485
459
|
llm: llmConfig,
|
|
486
|
-
|
|
487
|
-
...loadedConfig.
|
|
488
|
-
mode:
|
|
460
|
+
permissions: {
|
|
461
|
+
...loadedConfig.permissions,
|
|
462
|
+
mode: permissionsMode
|
|
489
463
|
},
|
|
490
|
-
customTools: filteredCustomTools,
|
|
491
464
|
// Suppress sub-agent console logs entirely using silent transport
|
|
492
465
|
logger: {
|
|
493
466
|
level: "error",
|
|
@@ -503,22 +476,11 @@ class RuntimeService {
|
|
|
503
476
|
llm: { ...currentParentLLM },
|
|
504
477
|
// Default system prompt for sub-agents
|
|
505
478
|
systemPrompt: "You are a helpful sub-agent. Complete the task given to you efficiently and concisely.",
|
|
506
|
-
|
|
507
|
-
mode:
|
|
479
|
+
permissions: {
|
|
480
|
+
mode: permissionsMode
|
|
508
481
|
},
|
|
509
482
|
// Inherit MCP servers from parent so subagent has tool access
|
|
510
|
-
mcpServers:
|
|
511
|
-
// Inherit internal tools from parent, excluding tools that don't work in subagent context
|
|
512
|
-
// - ask_user: Subagents can't interact with the user directly
|
|
513
|
-
// - invoke_skill: Avoid nested skill invocations for simplicity
|
|
514
|
-
internalTools: parentConfig.internalTools ? parentConfig.internalTools.filter(
|
|
515
|
-
(tool) => tool !== "ask_user" && tool !== "invoke_skill"
|
|
516
|
-
) : [],
|
|
517
|
-
// Inherit custom tools from parent, excluding agent-spawner to prevent nested spawning (depth=1 limit)
|
|
518
|
-
// - agent-spawner: Sub-agents should not spawn their own sub-agents
|
|
519
|
-
customTools: parentConfig.customTools ? parentConfig.customTools.filter(
|
|
520
|
-
(tool) => typeof tool === "object" && tool !== null && "type" in tool && tool.type !== "agent-spawner"
|
|
521
|
-
) : [],
|
|
483
|
+
mcpServers: parentSettings.mcpServers ? { ...parentSettings.mcpServers } : {},
|
|
522
484
|
// Suppress sub-agent console logs entirely using silent transport
|
|
523
485
|
logger: {
|
|
524
486
|
level: "error",
|
|
@@ -559,10 +521,10 @@ class RuntimeService {
|
|
|
559
521
|
* Clean up all sub-agents (called when parent stops)
|
|
560
522
|
*/
|
|
561
523
|
async cleanup() {
|
|
562
|
-
this.logger.debug(`Cleaning up
|
|
524
|
+
this.logger.debug(`Cleaning up AgentSpawnerRuntime for parent '${this.parentId}'`);
|
|
563
525
|
await this.runtime.stopAll({ group: this.parentId });
|
|
564
526
|
}
|
|
565
527
|
}
|
|
566
528
|
export {
|
|
567
|
-
|
|
529
|
+
AgentSpawnerRuntime
|
|
568
530
|
};
|
|
@@ -24,7 +24,7 @@ __export(schemas_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(schemas_exports);
|
|
25
25
|
var import_zod = require("zod");
|
|
26
26
|
const AgentSpawnerConfigSchema = import_zod.z.object({
|
|
27
|
-
/** Type discriminator for the
|
|
27
|
+
/** Type discriminator for the factory */
|
|
28
28
|
type: import_zod.z.literal("agent-spawner"),
|
|
29
29
|
/** Maximum concurrent sub-agents this parent can spawn (default: 5) */
|
|
30
30
|
maxConcurrentAgents: import_zod.z.number().int().positive().default(5).describe("Maximum concurrent sub-agents"),
|
|
@@ -57,7 +57,7 @@ const AgentSpawnerConfigSchema = import_zod.z.object({
|
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
59
|
autoApproveAgents: import_zod.z.array(import_zod.z.string().min(1)).optional().describe("Agent IDs that should have tools auto-approved (read-only agents)")
|
|
60
|
-
}).strict().describe("Configuration for the agent spawner
|
|
60
|
+
}).strict().describe("Configuration for the agent spawner tools factory");
|
|
61
61
|
const SpawnAgentInputSchema = import_zod.z.object({
|
|
62
62
|
/** Short task description (shown in UI/logs) */
|
|
63
63
|
task: import_zod.z.string().min(1).describe("Short task description for UI/logs"),
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Agent Spawner
|
|
2
|
+
* Agent Spawner Tools Factory Schemas
|
|
3
3
|
*
|
|
4
|
-
* Zod schemas for the agent spawner
|
|
4
|
+
* Zod schemas for the agent spawner tools factory configuration and inputs.
|
|
5
5
|
*/
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
/**
|
|
8
|
-
* Configuration schema for the agent spawner
|
|
8
|
+
* Configuration schema for the agent spawner tools factory.
|
|
9
9
|
*/
|
|
10
10
|
export declare const AgentSpawnerConfigSchema: z.ZodObject<{
|
|
11
|
-
/** Type discriminator for the
|
|
11
|
+
/** Type discriminator for the factory */
|
|
12
12
|
type: z.ZodLiteral<"agent-spawner">;
|
|
13
13
|
/** Maximum concurrent sub-agents this parent can spawn (default: 5) */
|
|
14
14
|
maxConcurrentAgents: z.ZodDefault<z.ZodNumber>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/tool-factories/agent-spawner/schemas.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;GAEG;AACH,eAAO,MAAM,wBAAwB;IAE7B,yCAAyC;;IAGzC,uEAAuE;;IAQvE,mFAAmF;;IAQnF,kDAAkD;;IAGlD;;;;;;;;;;OAUG;;IAMH;;;;;;;;;;;OAWG;;;;;;;;;;;;;;;;EAOuD,CAAC;AAEnE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAM3E;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;IAE1B,gDAAgD;;IAGhD,8CAA8C;;IAM9C,qFAAqF;;;;;;;;;;EAGhF,CAAC;AAEd,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
const AgentSpawnerConfigSchema = z.object({
|
|
3
|
-
/** Type discriminator for the
|
|
3
|
+
/** Type discriminator for the factory */
|
|
4
4
|
type: z.literal("agent-spawner"),
|
|
5
5
|
/** Maximum concurrent sub-agents this parent can spawn (default: 5) */
|
|
6
6
|
maxConcurrentAgents: z.number().int().positive().default(5).describe("Maximum concurrent sub-agents"),
|
|
@@ -33,7 +33,7 @@ const AgentSpawnerConfigSchema = z.object({
|
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
35
|
autoApproveAgents: z.array(z.string().min(1)).optional().describe("Agent IDs that should have tools auto-approved (read-only agents)")
|
|
36
|
-
}).strict().describe("Configuration for the agent spawner
|
|
36
|
+
}).strict().describe("Configuration for the agent spawner tools factory");
|
|
37
37
|
const SpawnAgentInputSchema = z.object({
|
|
38
38
|
/** Short task description (shown in UI/logs) */
|
|
39
39
|
task: z.string().min(1).describe("Short task description for UI/logs"),
|
|
@@ -57,21 +57,22 @@ ${agentsList}
|
|
|
57
57
|
function createSpawnAgentTool(service) {
|
|
58
58
|
return {
|
|
59
59
|
id: "spawn_agent",
|
|
60
|
+
displayName: "Agent",
|
|
61
|
+
aliases: ["task"],
|
|
60
62
|
description: buildDescription(service),
|
|
61
63
|
inputSchema: import_schemas.SpawnAgentInputSchema,
|
|
62
64
|
execute: async (input, context) => {
|
|
63
|
-
const validatedInput = input;
|
|
64
65
|
const options = {
|
|
65
|
-
task:
|
|
66
|
-
instructions:
|
|
66
|
+
task: input.task,
|
|
67
|
+
instructions: input.instructions
|
|
67
68
|
};
|
|
68
|
-
if (
|
|
69
|
-
options.agentId =
|
|
69
|
+
if (input.agentId !== void 0) {
|
|
70
|
+
options.agentId = input.agentId;
|
|
70
71
|
}
|
|
71
|
-
if (context
|
|
72
|
+
if (context.toolCallId !== void 0) {
|
|
72
73
|
options.toolCallId = context.toolCallId;
|
|
73
74
|
}
|
|
74
|
-
if (context
|
|
75
|
+
if (context.sessionId !== void 0) {
|
|
75
76
|
options.sessionId = context.sessionId;
|
|
76
77
|
}
|
|
77
78
|
const result = await service.spawnAndExecute(options);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* spawn_agent Tool
|
|
3
|
+
*
|
|
4
|
+
* Spawns a sub-agent to handle a specific task.
|
|
5
|
+
* The sub-agent will execute the task and return the result.
|
|
6
|
+
*/
|
|
7
|
+
import type { Tool } from '@dexto/core';
|
|
8
|
+
import { SpawnAgentInputSchema } from './schemas.js';
|
|
9
|
+
import type { AgentSpawnerRuntime } from './runtime.js';
|
|
10
|
+
export declare function createSpawnAgentTool(service: AgentSpawnerRuntime): Tool<typeof SpawnAgentInputSchema>;
|
|
11
|
+
//# sourceMappingURL=spawn-agent-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spawn-agent-tool.d.ts","sourceRoot":"","sources":["../../../src/tool-factories/agent-spawner/spawn-agent-tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAwB,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AA4CxD,wBAAgB,oBAAoB,CAChC,OAAO,EAAE,mBAAmB,GAC7B,IAAI,CAAC,OAAO,qBAAqB,CAAC,CA0CpC"}
|
|
@@ -34,21 +34,22 @@ ${agentsList}
|
|
|
34
34
|
function createSpawnAgentTool(service) {
|
|
35
35
|
return {
|
|
36
36
|
id: "spawn_agent",
|
|
37
|
+
displayName: "Agent",
|
|
38
|
+
aliases: ["task"],
|
|
37
39
|
description: buildDescription(service),
|
|
38
40
|
inputSchema: SpawnAgentInputSchema,
|
|
39
41
|
execute: async (input, context) => {
|
|
40
|
-
const validatedInput = input;
|
|
41
42
|
const options = {
|
|
42
|
-
task:
|
|
43
|
-
instructions:
|
|
43
|
+
task: input.task,
|
|
44
|
+
instructions: input.instructions
|
|
44
45
|
};
|
|
45
|
-
if (
|
|
46
|
-
options.agentId =
|
|
46
|
+
if (input.agentId !== void 0) {
|
|
47
|
+
options.agentId = input.agentId;
|
|
47
48
|
}
|
|
48
|
-
if (context
|
|
49
|
+
if (context.toolCallId !== void 0) {
|
|
49
50
|
options.toolCallId = context.toolCallId;
|
|
50
51
|
}
|
|
51
|
-
if (context
|
|
52
|
+
if (context.sessionId !== void 0) {
|
|
52
53
|
options.sessionId = context.sessionId;
|
|
53
54
|
}
|
|
54
55
|
const result = await service.spawnAndExecute(options);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tool-factories/agent-spawner/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,8CAA8C;IAC9C,OAAO,EAAE,OAAO,CAAC;IAEjB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
package/dist/writer.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AgentConfig } from '@dexto/agent-config';
|
|
2
|
+
import type { LLMProvider } from '@dexto/core';
|
|
2
3
|
import { type GlobalPreferences } from './preferences/schemas.js';
|
|
3
4
|
export interface LLMOverrides {
|
|
4
5
|
provider?: LLMProvider;
|
package/dist/writer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../src/writer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../src/writer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAIlE,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAqB5F;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACrC,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,iBAAiB,EAC9B,SAAS,CAAC,EAAE,YAAY,GACzB,OAAO,CAAC,IAAI,CAAC,CA6Ff;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CACzC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,iBAAiB,EAC9B,SAAS,CAAC,EAAE,YAAY,GACzB,OAAO,CAAC,IAAI,CAAC,CAyBf"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dexto/agent-management",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -16,8 +16,10 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"yaml": "^2.7.1",
|
|
18
18
|
"zod": "^3.25.0",
|
|
19
|
-
"@dexto/
|
|
20
|
-
"@dexto/
|
|
19
|
+
"@dexto/agent-config": "1.6.0",
|
|
20
|
+
"@dexto/core": "1.6.0",
|
|
21
|
+
"@dexto/orchestration": "1.6.0",
|
|
22
|
+
"@dexto/tools-builtins": "1.6.0"
|
|
21
23
|
},
|
|
22
24
|
"devDependencies": {
|
|
23
25
|
"@types/node": "^22.13.5"
|
|
@@ -34,7 +36,7 @@
|
|
|
34
36
|
},
|
|
35
37
|
"sideEffects": false,
|
|
36
38
|
"scripts": {
|
|
37
|
-
"build": "cross-env NODE_OPTIONS='--max-old-space-size=4096' tsup && cross-env NODE_OPTIONS='--max-old-space-size=4096' tsc -
|
|
39
|
+
"build": "cross-env NODE_OPTIONS='--max-old-space-size=4096' tsup && cross-env NODE_OPTIONS='--max-old-space-size=4096' tsc -b tsconfig.json --force --emitDeclarationOnly && node scripts/fix-dist-aliases.mjs",
|
|
38
40
|
"dev": "tsup --watch",
|
|
39
41
|
"typecheck": "tsc -p tsconfig.typecheck.json --noEmit",
|
|
40
42
|
"lint": "eslint . --ext .ts"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../../src/tool-provider/error-codes.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,qBAAqB;IAE7B,iBAAiB,oCAAoC;IACrD,YAAY,+BAA+B;IAG3C,eAAe,kCAAkC;IAGjD,WAAW,8BAA8B;IAGzC,cAAc,iCAAiC;CAClD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/tool-provider/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAyB,MAAM,aAAa,CAAC;AAGvE;;GAEG;AACH,qBAAa,iBAAiB;IAC1B,MAAM,CAAC,gBAAgB;IAWvB,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM;;;IAWhC,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM;;;IAWpC,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;;;;IAWhD,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM;CAUvC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tool-provider/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAG/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGvD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAG7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"llm-resolution.d.ts","sourceRoot":"","sources":["../../src/tool-provider/llm-resolution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC,4CAA4C;IAC5C,GAAG,EAAE,SAAS,CAAC;IACf,wCAAwC;IACxC,UAAU,EACJ,mBAAmB,GACnB,eAAe,GACf,iBAAiB,CAAC;IACxB,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,yBAAyB;IACtC,gDAAgD;IAChD,WAAW,EAAE,SAAS,CAAC;IACvB,6EAA6E;IAC7E,SAAS,EAAE,SAAS,CAAC;IACrB,wCAAwC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,qBAAqB,CAmE5F"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-service.d.ts","sourceRoot":"","sources":["../../src/tool-provider/runtime-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAe,UAAU,EAAE,MAAM,aAAa,CAAC;AAMrF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAI/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnD,qBAAa,cAAe,YAAW,UAAU;IAC7C,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,MAAM,CAAe;IAE7B,OAAO,CAAC,yBAAyB;IAyBjC,OAAO,CAAC,2BAA2B;gBAYvB,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,YAAY;IAuBrF;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAIxB;;OAEG;IACH,OAAO,CAAC,QAAQ;IAIhB;;;;;;;;;;;;;;OAcG;IACG,eAAe,CAAC,KAAK,EAAE;QACzB,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA8C7B;;;;;;;;;;OAUG;IACG,IAAI,CAAC,OAAO,EAAE;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IA6BpE;;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;IAiH7B;;OAEG;IACH,OAAO,CAAC,UAAU;IAsBlB;;OAEG;YACW,oBAAoB;IAyPlC;;;;;;;OAOG;YACW,mBAAmB;IAoJjC;;;OAGG;IACH,kBAAkB,IAAI,kBAAkB,EAAE;IA6B1C;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAIjC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/tool-provider/schemas.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;GAEG;AACH,eAAO,MAAM,wBAAwB;IAE7B,0CAA0C;;IAG1C,uEAAuE;;IAQvE,mFAAmF;;IAQnF,kDAAkD;;IAGlD;;;;;;;;;;OAUG;;IAMH;;;;;;;;;;;OAWG;;;;;;;;;;;;;;;;EAOuD,CAAC;AAEnE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAM3E;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;IAE1B,gDAAgD;;IAGhD,8CAA8C;;IAM9C,qFAAqF;;;;;;;;;;EAGhF,CAAC;AAEd,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* spawn_agent Tool
|
|
3
|
-
*
|
|
4
|
-
* Spawns a sub-agent to handle a specific task.
|
|
5
|
-
* The sub-agent will execute the task and return the result.
|
|
6
|
-
*/
|
|
7
|
-
import type { InternalTool } from '@dexto/core';
|
|
8
|
-
import type { RuntimeService } from './runtime-service.js';
|
|
9
|
-
export declare function createSpawnAgentTool(service: RuntimeService): InternalTool;
|
|
10
|
-
//# sourceMappingURL=spawn-agent-tool.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spawn-agent-tool.d.ts","sourceRoot":"","sources":["../../src/tool-provider/spawn-agent-tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAwB,MAAM,aAAa,CAAC;AAEtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AA4C3D,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,cAAc,GAAG,YAAY,CA0C1E"}
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var tool_provider_exports = {};
|
|
20
|
-
__export(tool_provider_exports, {
|
|
21
|
-
agentSpawnerToolsProvider: () => agentSpawnerToolsProvider
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(tool_provider_exports);
|
|
24
|
-
var import_orchestration = require("@dexto/orchestration");
|
|
25
|
-
var import_schemas = require("./schemas.js");
|
|
26
|
-
var import_runtime_service = require("./runtime-service.js");
|
|
27
|
-
var import_spawn_agent_tool = require("./spawn-agent-tool.js");
|
|
28
|
-
function bindOrchestrationTool(tool, context) {
|
|
29
|
-
return {
|
|
30
|
-
id: tool.id,
|
|
31
|
-
description: tool.description,
|
|
32
|
-
inputSchema: tool.inputSchema,
|
|
33
|
-
execute: (input) => tool.execute(input, context)
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
const agentSpawnerToolsProvider = {
|
|
37
|
-
type: "agent-spawner",
|
|
38
|
-
configSchema: import_schemas.AgentSpawnerConfigSchema,
|
|
39
|
-
create: (config, context) => {
|
|
40
|
-
const { logger, agent } = context;
|
|
41
|
-
const signalBus = new import_orchestration.SignalBus();
|
|
42
|
-
const taskRegistry = new import_orchestration.TaskRegistry(signalBus);
|
|
43
|
-
const conditionEngine = new import_orchestration.ConditionEngine(taskRegistry, signalBus, logger);
|
|
44
|
-
const toolContext = {
|
|
45
|
-
taskRegistry,
|
|
46
|
-
conditionEngine,
|
|
47
|
-
signalBus
|
|
48
|
-
};
|
|
49
|
-
const service = new import_runtime_service.RuntimeService(agent, config, logger);
|
|
50
|
-
agent.toolManager.setTaskForker(service);
|
|
51
|
-
logger.debug("RuntimeService wired as taskForker for context:fork skill support");
|
|
52
|
-
const taskSessions = /* @__PURE__ */ new Map();
|
|
53
|
-
const emitTasksUpdate = (sessionId) => {
|
|
54
|
-
const tasks = taskRegistry.list({
|
|
55
|
-
status: ["running", "completed", "failed", "cancelled"]
|
|
56
|
-
});
|
|
57
|
-
const scopedTasks = sessionId ? tasks.filter((task) => taskSessions.get(task.taskId) === sessionId) : tasks;
|
|
58
|
-
const runningCount = scopedTasks.filter((task) => task.status === "running").length;
|
|
59
|
-
agent.agentEventBus.emit("service:event", {
|
|
60
|
-
service: "orchestration",
|
|
61
|
-
event: "tasks-updated",
|
|
62
|
-
sessionId: sessionId ?? "",
|
|
63
|
-
data: {
|
|
64
|
-
runningCount,
|
|
65
|
-
tasks: scopedTasks.map((task) => ({
|
|
66
|
-
taskId: task.taskId,
|
|
67
|
-
status: task.status,
|
|
68
|
-
...task.description !== void 0 && { description: task.description }
|
|
69
|
-
}))
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
const triggerBackgroundCompletion = (taskId, sessionId) => {
|
|
74
|
-
if (!sessionId) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
agent.agentEventBus.emit("tool:background-completed", {
|
|
78
|
-
toolCallId: taskId,
|
|
79
|
-
sessionId
|
|
80
|
-
});
|
|
81
|
-
const taskInfo = taskRegistry.getInfo(taskId);
|
|
82
|
-
const resultText = (() => {
|
|
83
|
-
if (taskInfo?.status === "failed") {
|
|
84
|
-
return taskInfo.error ?? "Unknown error.";
|
|
85
|
-
}
|
|
86
|
-
if (taskInfo?.result !== void 0) {
|
|
87
|
-
if (typeof taskInfo.result === "string") {
|
|
88
|
-
return taskInfo.result;
|
|
89
|
-
}
|
|
90
|
-
try {
|
|
91
|
-
return JSON.stringify(taskInfo.result, null, 2);
|
|
92
|
-
} catch {
|
|
93
|
-
return String(taskInfo.result ?? "<unserializable result>");
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return "No result available.";
|
|
97
|
-
})();
|
|
98
|
-
const sanitizeCdata = (value) => value.replace(/\]\]>/g, "]]]]><![CDATA[>");
|
|
99
|
-
const safeDescription = taskInfo?.description ? sanitizeCdata(taskInfo.description) : null;
|
|
100
|
-
const safeResultText = sanitizeCdata(resultText);
|
|
101
|
-
const descriptionTag = safeDescription ? ` <description><![CDATA[${safeDescription}]]></description>
|
|
102
|
-
` : "";
|
|
103
|
-
const statusTag = taskInfo?.status ? ` <status>${taskInfo.status}</status>
|
|
104
|
-
` : "";
|
|
105
|
-
const content = [
|
|
106
|
-
{
|
|
107
|
-
type: "text",
|
|
108
|
-
text: `<background-task-completion>
|
|
109
|
-
<origin>task</origin>
|
|
110
|
-
<note>The following response was reported by the background task (not user input).</note>
|
|
111
|
-
<taskId>${taskId}</taskId>
|
|
112
|
-
` + statusTag + descriptionTag + ` <result><![CDATA[${safeResultText}]]></result>
|
|
113
|
-
</background-task-completion>`
|
|
114
|
-
}
|
|
115
|
-
];
|
|
116
|
-
agent.isSessionBusy(sessionId).then((isBusy) => {
|
|
117
|
-
if (isBusy) {
|
|
118
|
-
agent.queueMessage(sessionId, {
|
|
119
|
-
content,
|
|
120
|
-
kind: "background"
|
|
121
|
-
}).catch(() => void 0);
|
|
122
|
-
} else {
|
|
123
|
-
agent.agentEventBus.emit("run:invoke", {
|
|
124
|
-
sessionId,
|
|
125
|
-
content,
|
|
126
|
-
source: "external",
|
|
127
|
-
metadata: { taskId }
|
|
128
|
-
});
|
|
129
|
-
agent.generate(content, sessionId).catch(() => void 0);
|
|
130
|
-
}
|
|
131
|
-
}).catch(() => {
|
|
132
|
-
});
|
|
133
|
-
};
|
|
134
|
-
const handleBackground = (event) => {
|
|
135
|
-
const taskId = event.toolCallId;
|
|
136
|
-
if (taskRegistry.has(taskId)) {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
if (event.sessionId) {
|
|
140
|
-
taskSessions.set(taskId, event.sessionId);
|
|
141
|
-
}
|
|
142
|
-
try {
|
|
143
|
-
taskRegistry.register(
|
|
144
|
-
{
|
|
145
|
-
type: "generic",
|
|
146
|
-
taskId,
|
|
147
|
-
description: event.description ?? `Tool ${event.toolName}`,
|
|
148
|
-
promise: event.promise
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
...event.timeoutMs !== void 0 && { timeout: event.timeoutMs },
|
|
152
|
-
...event.notifyOnComplete !== void 0 && {
|
|
153
|
-
notify: event.notifyOnComplete
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
);
|
|
157
|
-
} catch (error) {
|
|
158
|
-
taskSessions.delete(taskId);
|
|
159
|
-
event.promise.catch(() => void 0);
|
|
160
|
-
logger.warn(
|
|
161
|
-
`Failed to register background task ${taskId}: ${error instanceof Error ? error.message : String(error)}`,
|
|
162
|
-
{ color: "yellow" }
|
|
163
|
-
);
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
emitTasksUpdate(event.sessionId);
|
|
167
|
-
event.promise.finally(() => {
|
|
168
|
-
taskSessions.delete(taskId);
|
|
169
|
-
emitTasksUpdate(event.sessionId);
|
|
170
|
-
triggerBackgroundCompletion(taskId, event.sessionId);
|
|
171
|
-
});
|
|
172
|
-
};
|
|
173
|
-
const backgroundAbortController = new AbortController();
|
|
174
|
-
agent.agentEventBus.on("tool:background", handleBackground, {
|
|
175
|
-
signal: backgroundAbortController.signal
|
|
176
|
-
});
|
|
177
|
-
agent.agentEventBus.on("agent:stopped", () => {
|
|
178
|
-
backgroundAbortController.abort();
|
|
179
|
-
});
|
|
180
|
-
const tool = (0, import_spawn_agent_tool.createSpawnAgentTool)(service);
|
|
181
|
-
return [
|
|
182
|
-
tool,
|
|
183
|
-
bindOrchestrationTool((0, import_orchestration.createWaitForTool)(), toolContext),
|
|
184
|
-
bindOrchestrationTool((0, import_orchestration.createCheckTaskTool)(), toolContext),
|
|
185
|
-
bindOrchestrationTool((0, import_orchestration.createListTasksTool)(), toolContext)
|
|
186
|
-
];
|
|
187
|
-
},
|
|
188
|
-
metadata: {
|
|
189
|
-
displayName: "Agent Spawner",
|
|
190
|
-
description: "Spawn sub-agents for task delegation",
|
|
191
|
-
category: "agents"
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
195
|
-
0 && (module.exports = {
|
|
196
|
-
agentSpawnerToolsProvider
|
|
197
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent Spawner Tool Provider
|
|
3
|
-
*
|
|
4
|
-
* Custom tool provider that enables agents to spawn sub-agents for task delegation.
|
|
5
|
-
*/
|
|
6
|
-
import type { CustomToolProvider } from '@dexto/core';
|
|
7
|
-
import { type AgentSpawnerConfig } from './schemas.js';
|
|
8
|
-
/**
|
|
9
|
-
* Agent Spawner Tools Provider
|
|
10
|
-
*
|
|
11
|
-
* Provides tools for spawning and managing sub-agents:
|
|
12
|
-
* - spawn_agent: Spawn a sub-agent to handle a task
|
|
13
|
-
*
|
|
14
|
-
* Orchestration tools (for background task management):
|
|
15
|
-
* - wait_for: Wait for background task(s) to complete
|
|
16
|
-
* - check_task: Check status of a background task
|
|
17
|
-
* - list_tasks: List all tracked background tasks
|
|
18
|
-
*
|
|
19
|
-
* Configuration:
|
|
20
|
-
* ```yaml
|
|
21
|
-
* tools:
|
|
22
|
-
* customTools:
|
|
23
|
-
* - type: agent-spawner
|
|
24
|
-
* maxConcurrentAgents: 5
|
|
25
|
-
* defaultTimeout: 300000
|
|
26
|
-
* allowSpawning: true
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export declare const agentSpawnerToolsProvider: CustomToolProvider<'agent-spawner', AgentSpawnerConfig>;
|
|
30
|
-
//# sourceMappingURL=tool-provider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-provider.d.ts","sourceRoot":"","sources":["../../src/tool-provider/tool-provider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAgB,MAAM,aAAa,CAAC;AAYpE,OAAO,EAA4B,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAmBjF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,yBAAyB,EAAE,kBAAkB,CAAC,eAAe,EAAE,kBAAkB,CAsM7F,CAAC"}
|