klyro 0.1.63 → 1.0.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/agent/anthropic-adapter.js +6 -1
- package/dist/agent/capabilities.d.ts +122 -0
- package/dist/agent/capabilities.js +150 -0
- package/dist/agent/orchestrator.d.ts +131 -0
- package/dist/agent/orchestrator.js +269 -0
- package/dist/agent/provider-adapter.d.ts +9 -0
- package/dist/agent/provider-adapter.js +24 -1
- package/dist/agent/registry.d.ts +1 -0
- package/dist/agent/registry.js +1 -0
- package/dist/agent/retry.d.ts +12 -1
- package/dist/agent/retry.js +19 -1
- package/dist/agent/runtime.d.ts +20 -0
- package/dist/agent/runtime.js +9 -1
- package/dist/agent/scoped-registry.d.ts +22 -0
- package/dist/agent/scoped-registry.js +42 -0
- package/dist/agent/task-manager.d.ts +115 -0
- package/dist/agent/task-manager.js +250 -0
- package/dist/agent/worker-spawner.d.ts +17 -12
- package/dist/agent/worker-spawner.js +26 -20
- package/dist/cli/dotenv.d.ts +3 -0
- package/dist/cli/dotenv.js +57 -0
- package/dist/cli/repl.js +41 -2
- package/dist/cli/run.d.ts +3 -0
- package/dist/cli/run.js +118 -7
- package/dist/context/klyro-md.d.ts +6 -0
- package/dist/context/klyro-md.js +21 -15
- package/dist/context/trust.d.ts +42 -0
- package/dist/context/trust.js +111 -0
- package/dist/events/catalog.d.ts +71 -0
- package/dist/index.js +4 -0
- package/dist/mcp/client.d.ts +53 -0
- package/dist/mcp/client.js +225 -0
- package/dist/mcp/config.d.ts +30 -0
- package/dist/mcp/config.js +82 -0
- package/dist/mcp/policy.d.ts +13 -0
- package/dist/mcp/policy.js +12 -0
- package/dist/mcp/registry.d.ts +50 -0
- package/dist/mcp/registry.js +172 -0
- package/dist/mcp/schema.d.ts +11 -0
- package/dist/mcp/schema.js +46 -0
- package/dist/policy/engine.js +3 -2
- package/dist/tools/agent/spawn-agent.d.ts +9 -0
- package/dist/tools/agent/spawn-agent.js +50 -0
- package/dist/tools/agent/task-get.d.ts +8 -0
- package/dist/tools/agent/task-get.js +40 -0
- package/dist/tools/agent/task-list.d.ts +4 -0
- package/dist/tools/agent/task-list.js +41 -0
- package/dist/tools/plan/todo-write.d.ts +1 -1
- package/dist/tools/registry.js +6 -0
- package/dist/tools/types.d.ts +12 -0
- package/package.json +1 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P1.1 — spawn_agent tool (6-10fix.md §5).
|
|
3
|
+
*
|
|
4
|
+
* Delegates to `AgentSpawnBridge.spawnAgent`, which runs the child to
|
|
5
|
+
* completion (P0/P1 scope: blocking) and returns a compact ChildSummary —
|
|
6
|
+
* never the child transcript. True background `task_wait` / `task_stop`
|
|
7
|
+
* arrives in P2.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { defineTool } from '../types.js';
|
|
11
|
+
import { toToolError } from '../normalize.js';
|
|
12
|
+
const InputSchema = z.object({
|
|
13
|
+
agent: z.string().min(1).describe('Agent id (e.g. explorer, implementer, tester, reviewer)'),
|
|
14
|
+
task: z.string().min(1).describe('Task brief for the child agent'),
|
|
15
|
+
cwd: z.string().optional().describe('Working directory override (defaults to parent cwd)'),
|
|
16
|
+
model: z.string().optional().describe('Model override for the child (must be honoured or error)'),
|
|
17
|
+
timeoutMs: z.number().int().positive().optional().describe('Child runtime timeout in ms'),
|
|
18
|
+
});
|
|
19
|
+
export const spawnAgentTool = defineTool({
|
|
20
|
+
name: 'spawn_agent',
|
|
21
|
+
description: 'Spawn a child agent and return its compact summary { taskId, status, ... }. Child transcript stays separate; use task_get for status.',
|
|
22
|
+
inputSchema: InputSchema,
|
|
23
|
+
permission: 'admin',
|
|
24
|
+
isConcurrencySafe: false,
|
|
25
|
+
renderCall: (input) => `spawn_agent(${input.agent}): ${input.task.slice(0, 80)}`,
|
|
26
|
+
execute: async (input, ctx) => {
|
|
27
|
+
try {
|
|
28
|
+
const bridge = ctx.agentBridge;
|
|
29
|
+
if (!bridge) {
|
|
30
|
+
return {
|
|
31
|
+
ok: false,
|
|
32
|
+
error: {
|
|
33
|
+
code: 'NO_ORCHESTRATOR',
|
|
34
|
+
message: 'spawn_agent requires an active orchestrator (run with --agent or via a parent agent)',
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return await bridge.spawnAgent({
|
|
39
|
+
agent: input.agent,
|
|
40
|
+
task: input.task,
|
|
41
|
+
...(input.cwd ? { cwd: input.cwd } : {}),
|
|
42
|
+
...(input.model ? { model: input.model } : {}),
|
|
43
|
+
...(input.timeoutMs ? { timeoutMs: input.timeoutMs } : {}),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
return { ok: false, error: toToolError(err) };
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P1.3 — task_get tool (6-10fix.md §5). Read-only + concurrency-safe.
|
|
3
|
+
* Returns one task's status and summary by id.
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { defineTool } from '../types.js';
|
|
7
|
+
import { toToolError } from '../normalize.js';
|
|
8
|
+
const InputSchema = z.object({
|
|
9
|
+
taskId: z.string().min(1).describe('Task id (e.g. task_1)'),
|
|
10
|
+
});
|
|
11
|
+
export const taskGetTool = defineTool({
|
|
12
|
+
name: 'task_get',
|
|
13
|
+
description: "Return one child-agent task's status and summary by id.",
|
|
14
|
+
inputSchema: InputSchema,
|
|
15
|
+
permission: 'read',
|
|
16
|
+
isConcurrencySafe: true,
|
|
17
|
+
renderCall: (input) => `task_get(${input.taskId})`,
|
|
18
|
+
execute: async (input, ctx) => {
|
|
19
|
+
try {
|
|
20
|
+
const bridge = ctx.agentBridge;
|
|
21
|
+
if (!bridge) {
|
|
22
|
+
return {
|
|
23
|
+
ok: false,
|
|
24
|
+
error: { code: 'NO_ORCHESTRATOR', message: 'task_get requires an active orchestrator' },
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const rec = bridge.getTask(input.taskId);
|
|
28
|
+
if (!rec) {
|
|
29
|
+
return {
|
|
30
|
+
ok: false,
|
|
31
|
+
error: { code: 'NOT_FOUND', message: `Unknown task: ${input.taskId}` },
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return { ok: true, value: rec };
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
return { ok: false, error: toToolError(err) };
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P1.2 — task_list tool (6-10fix.md §5). Read-only + concurrency-safe.
|
|
3
|
+
* Returns TaskSummary[] snapshots from the orchestrator's TaskManager.
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { defineTool } from '../types.js';
|
|
7
|
+
import { toToolError } from '../normalize.js';
|
|
8
|
+
const InputSchema = z.object({
|
|
9
|
+
parentTaskId: z.string().optional().describe('Filter by parent task id'),
|
|
10
|
+
status: z
|
|
11
|
+
.enum(['queued', 'running', 'succeeded', 'failed', 'cancelled', 'timed_out', 'blocked'])
|
|
12
|
+
.optional()
|
|
13
|
+
.describe('Filter by status'),
|
|
14
|
+
});
|
|
15
|
+
export const taskListTool = defineTool({
|
|
16
|
+
name: 'task_list',
|
|
17
|
+
description: 'List child-agent tasks (running and completed) with status summaries.',
|
|
18
|
+
inputSchema: InputSchema,
|
|
19
|
+
permission: 'read',
|
|
20
|
+
isConcurrencySafe: true,
|
|
21
|
+
renderCall: () => 'task_list',
|
|
22
|
+
execute: async (input, ctx) => {
|
|
23
|
+
try {
|
|
24
|
+
const bridge = ctx.agentBridge;
|
|
25
|
+
if (!bridge) {
|
|
26
|
+
return {
|
|
27
|
+
ok: false,
|
|
28
|
+
error: { code: 'NO_ORCHESTRATOR', message: 'task_list requires an active orchestrator' },
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const tasks = bridge.listTasks({
|
|
32
|
+
...(input.parentTaskId ? { parentTaskId: input.parentTaskId } : {}),
|
|
33
|
+
...(input.status ? { status: input.status } : {}),
|
|
34
|
+
});
|
|
35
|
+
return { ok: true, value: tasks };
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
return { ok: false, error: toToolError(err) };
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
});
|
|
@@ -2,7 +2,7 @@ export declare const todoWriteTool: import("../types.js").Tool<{
|
|
|
2
2
|
todos: {
|
|
3
3
|
id: string;
|
|
4
4
|
title: string;
|
|
5
|
-
status: "done" | "pending" | "
|
|
5
|
+
status: "done" | "pending" | "failed" | "in_progress" | "skipped";
|
|
6
6
|
files?: string[] | undefined;
|
|
7
7
|
}[];
|
|
8
8
|
}, {
|
package/dist/tools/registry.js
CHANGED
|
@@ -25,6 +25,9 @@ import { findSymbolTool } from './symbols/find-symbol.js';
|
|
|
25
25
|
import { lspDiagnosticsTool, lspGotoDefinitionTool } from './lsp/diagnostics.js';
|
|
26
26
|
import { expandResultTool } from './expand-result.js';
|
|
27
27
|
import { memoryWriteTool } from './memory-write.js';
|
|
28
|
+
import { spawnAgentTool } from './agent/spawn-agent.js';
|
|
29
|
+
import { taskListTool } from './agent/task-list.js';
|
|
30
|
+
import { taskGetTool } from './agent/task-get.js';
|
|
28
31
|
import { zodToJsonSchema } from './schema.js';
|
|
29
32
|
export class ToolRegistry {
|
|
30
33
|
tools = new Map();
|
|
@@ -107,5 +110,8 @@ export const builtinRegistry = () => {
|
|
|
107
110
|
r.register(lspGotoDefinitionTool);
|
|
108
111
|
r.register(expandResultTool);
|
|
109
112
|
r.register(memoryWriteTool);
|
|
113
|
+
r.register(spawnAgentTool);
|
|
114
|
+
r.register(taskListTool);
|
|
115
|
+
r.register(taskGetTool);
|
|
110
116
|
return r;
|
|
111
117
|
};
|
package/dist/tools/types.d.ts
CHANGED
|
@@ -48,6 +48,18 @@ export interface ToolContext {
|
|
|
48
48
|
};
|
|
49
49
|
/** Emit KlyroEvent */
|
|
50
50
|
emit?: (ev: import('../events/catalog.js').KlyroEvent) => void;
|
|
51
|
+
/** Delegation bridge (set when an orchestrator is active). Powers spawn_agent/task_* tools. */
|
|
52
|
+
agentBridge?: import('../agent/orchestrator.js').AgentSpawnBridge;
|
|
53
|
+
/** The task id this agent belongs to, when running under an orchestrator. */
|
|
54
|
+
parentTaskId?: string;
|
|
55
|
+
/** Depth of the current agent in the spawn tree (0 = root). Used to build ParentContextRef for spawn_agent. */
|
|
56
|
+
agentDepth?: number;
|
|
57
|
+
/** Max allowed spawn depth for this branch. */
|
|
58
|
+
agentMaxDepth?: number;
|
|
59
|
+
/** Effective tool allow-set of the current agent (null = all). Child can never exceed this. */
|
|
60
|
+
agentAllowedTools?: ReadonlySet<string> | null;
|
|
61
|
+
/** Model override active for the current agent. */
|
|
62
|
+
agentModel?: string;
|
|
51
63
|
}
|
|
52
64
|
/**
|
|
53
65
|
* A typed tool definition. TInput is the validated input shape; TOutput is
|