@akanjs/cli 3.0.0-beta.16 → 3.0.0-beta.17
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/.build-stamp +1 -1
- package/{CodeAgent-zgccwajm.js → CodeAgent-gjqnc2mg.js} +2 -2
- package/{CodeTui-993tx7gf.js → CodeTui-nd9hqvrw.js} +196 -11
- package/akanCode.js +9 -9
- package/{cloud.command-4x35k1z6.js → cloud.command-dk5tj39k.js} +2 -2
- package/{cloud.script-3k8nbbpn.js → cloud.script-ch3xrw3s.js} +2 -2
- package/{code.command-mrfb7a1g.js → code.command-88sebgnn.js} +5 -5
- package/{index-5405kc0x.js → index-2sq06vv0.js} +169 -199
- package/{index-sxg87a8f.js → index-bzakk0c2.js} +160 -96
- package/{index-wfwknnje.js → index-jwrpsrg3.js} +8 -6
- package/{index-zg0v1zte.js → index-n8kt2wh6.js} +1 -1
- package/{index-018dszb3.js → index-p0tew3fq.js} +2 -0
- package/index-qt8dqgnf.js +250 -0
- package/index.js +6 -6
- package/{localRegistry.command-tt00nwwg.js → localRegistry.command-yppdqrxv.js} +1 -1
- package/{package.command-8sy6jjwy.js → package.command-cgp2p2v5.js} +1 -1
- package/package.json +8 -6
- package/{subspace.command-x9897gj4.js → subspace.command-jqv5n79w.js} +1 -1
- package/{workspace.command-ayqa1rgt.js → workspace.command-txv1yv5e.js} +2 -2
- package/index-jgrnpt6y.js +0 -121
|
@@ -49,14 +49,14 @@ import"./index-7md2g9vw.js";
|
|
|
49
49
|
import"./index-kcxmv48c.js";
|
|
50
50
|
import {
|
|
51
51
|
PackageScript
|
|
52
|
-
} from "./index-
|
|
52
|
+
} from "./index-p0tew3fq.js";
|
|
53
53
|
import {
|
|
54
54
|
getNpmRegistryUrl,
|
|
55
55
|
getLatestPackageVersion
|
|
56
56
|
} from "./index-57p9p179.js";
|
|
57
57
|
import {
|
|
58
58
|
CloudScript2
|
|
59
|
-
} from "./index-
|
|
59
|
+
} from "./index-n8kt2wh6.js";
|
|
60
60
|
import"./index-g9zghs4h.js";
|
|
61
61
|
import"./index-3cymrzsb.js";
|
|
62
62
|
import"./index-4cvpzkq6.js";
|
package/index-jgrnpt6y.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// pkgs/@akanjs/devkit/codeAgent/agent/SubagentPool.ts
|
|
3
|
-
import { codeAgentReadOnlyBuiltins } from "akanjs/common";
|
|
4
|
-
import { Type } from "typebox";
|
|
5
|
-
var maxResultChars = 8000;
|
|
6
|
-
|
|
7
|
-
class SubagentPool2 {
|
|
8
|
-
static kinds = {
|
|
9
|
-
explore: {
|
|
10
|
-
readOnly: true,
|
|
11
|
-
desc: "reads, searches and reports back. It cannot write a file or run a command."
|
|
12
|
-
},
|
|
13
|
-
code: {
|
|
14
|
-
readOnly: false,
|
|
15
|
-
desc: "makes the change itself, with the same tools as this session."
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
static defaultKind = "explore";
|
|
19
|
-
#options;
|
|
20
|
-
#running = 0;
|
|
21
|
-
#spent = 0;
|
|
22
|
-
constructor(options) {
|
|
23
|
-
this.#options = options;
|
|
24
|
-
}
|
|
25
|
-
static extensionFor(options) {
|
|
26
|
-
if (!options.parent.tools.subagent)
|
|
27
|
-
return;
|
|
28
|
-
if (options.depth >= options.parent.tools.subagent.maxDepth)
|
|
29
|
-
return;
|
|
30
|
-
const pool = new SubagentPool2(options);
|
|
31
|
-
return { name: "akan-subagent", factory: (pi) => pool.#register(pi) };
|
|
32
|
-
}
|
|
33
|
-
static toolName = "task";
|
|
34
|
-
#register(pi) {
|
|
35
|
-
pi.registerTool({
|
|
36
|
-
name: SubagentPool2.toolName,
|
|
37
|
-
label: "Task",
|
|
38
|
-
description: "Run a focused sub-agent on one self-contained question and get back its answer. Use it for searching and reading that would otherwise fill this conversation \u2014 the sub-agent's own reading does not come back, only its answer. Give it everything it needs: it cannot see this conversation.",
|
|
39
|
-
promptSnippet: "task: run a sub-agent on one self-contained question and get back only its answer",
|
|
40
|
-
parameters: Type.Object({
|
|
41
|
-
description: Type.String({ description: "Three to five words naming the task, for the activity log." }),
|
|
42
|
-
prompt: Type.String({
|
|
43
|
-
description: "The complete instruction. The sub-agent sees nothing of this conversation."
|
|
44
|
-
}),
|
|
45
|
-
type: Type.Optional(Type.Union(Object.entries(SubagentPool2.kinds).map(([kind, spec]) => Type.Literal(kind, { description: spec.desc })), { description: `What the sub-agent may do. Defaults to ${SubagentPool2.defaultKind}.` }))
|
|
46
|
-
}),
|
|
47
|
-
execute: async (_id, params, signal) => {
|
|
48
|
-
const kind = params.type ?? SubagentPool2.defaultKind;
|
|
49
|
-
const refusal = this.#refuse();
|
|
50
|
-
if (refusal)
|
|
51
|
-
return { content: [{ type: "text", text: refusal }], details: undefined, isError: true };
|
|
52
|
-
this.#running += 1;
|
|
53
|
-
this.#options.onNotice?.(`${kind} sub-agent \xB7 ${params.description}`);
|
|
54
|
-
try {
|
|
55
|
-
const text = await this.#run(kind, params.prompt, signal);
|
|
56
|
-
return { content: [{ type: "text", text }], details: undefined };
|
|
57
|
-
} finally {
|
|
58
|
-
this.#running -= 1;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
#refuse() {
|
|
64
|
-
const budget = this.#options.parent.tools.subagent;
|
|
65
|
-
if (!budget)
|
|
66
|
-
return "Sub-agents are disabled by this profile.";
|
|
67
|
-
if (this.#running >= budget.maxConcurrent)
|
|
68
|
-
return `Too many sub-agents are already running (limit ${budget.maxConcurrent}). Wait for one to finish.`;
|
|
69
|
-
if (this.#spent >= budget.budget)
|
|
70
|
-
return `The sub-agent token budget (${budget.budget}) is spent. Do the rest of this work yourself.`;
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
static childOf(parent, kind) {
|
|
74
|
-
const budget = parent.tools.subagent;
|
|
75
|
-
return {
|
|
76
|
-
...parent,
|
|
77
|
-
name: `${parent.name}:${kind}`,
|
|
78
|
-
tools: {
|
|
79
|
-
...parent.tools,
|
|
80
|
-
builtin: SubagentPool2.kinds[kind].readOnly ? parent.tools.builtin.filter((tool) => codeAgentReadOnlyBuiltins.includes(tool)) : parent.tools.builtin,
|
|
81
|
-
subagent: budget ? { ...budget, maxDepth: budget.maxDepth } : false
|
|
82
|
-
},
|
|
83
|
-
session: { store: "memory", crossSession: false },
|
|
84
|
-
ui: { canPrompt: false },
|
|
85
|
-
context: { projectFiles: false, skills: parent.context.skills }
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
async#run(kind, prompt, signal) {
|
|
89
|
-
const { CodeAgent } = await import("./CodeAgent-zgccwajm.js");
|
|
90
|
-
const budget = this.#options.parent.tools.subagent;
|
|
91
|
-
const child = SubagentPool2.childOf(this.#options.parent, kind);
|
|
92
|
-
const agent = await CodeAgent.create({
|
|
93
|
-
workspace: this.#options.workspace,
|
|
94
|
-
cwd: this.#options.cwd,
|
|
95
|
-
profile: child,
|
|
96
|
-
apps: [],
|
|
97
|
-
depth: this.#options.depth + 1
|
|
98
|
-
});
|
|
99
|
-
const abort = () => void agent.abort();
|
|
100
|
-
signal?.addEventListener("abort", abort, { once: true });
|
|
101
|
-
try {
|
|
102
|
-
let answer = "";
|
|
103
|
-
agent.on((event) => {
|
|
104
|
-
if (event.type === "message" && event.role === "assistant")
|
|
105
|
-
answer = event.text;
|
|
106
|
-
});
|
|
107
|
-
await agent.prompt(prompt);
|
|
108
|
-
await agent.waitForIdle();
|
|
109
|
-
this.#spent += agent.tokensUsed;
|
|
110
|
-
const ceiling = budget ? budget.budget : 0;
|
|
111
|
-
this.#options.onNotice?.(`${kind} sub-agent finished, ${agent.tokensUsed} tokens (${this.#spent} of ${ceiling} spent)`);
|
|
112
|
-
return answer.length > maxResultChars ? `${answer.slice(0, maxResultChars)}
|
|
113
|
-
\u2026(truncated)` : answer || "(no answer)";
|
|
114
|
-
} finally {
|
|
115
|
-
signal?.removeEventListener("abort", abort);
|
|
116
|
-
agent.dispose();
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export { SubagentPool2 };
|