@kodizm/acp 0.5.3 → 0.5.4
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/index.js +55 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4646,6 +4646,17 @@ function mapAssistantMessage(sessionId, message) {
|
|
|
4646
4646
|
if (skillName !== undefined) {
|
|
4647
4647
|
events.push({ sessionId, type: "skill_activation", skillName, source: "invoked" });
|
|
4648
4648
|
}
|
|
4649
|
+
const subagentType = extractSubagentType(block);
|
|
4650
|
+
if (subagentType !== undefined) {
|
|
4651
|
+
events.push({
|
|
4652
|
+
sessionId,
|
|
4653
|
+
type: "subagent_spawn",
|
|
4654
|
+
childId: block.id,
|
|
4655
|
+
parentSessionId: sessionId,
|
|
4656
|
+
model: subagentType,
|
|
4657
|
+
tools: []
|
|
4658
|
+
});
|
|
4659
|
+
}
|
|
4649
4660
|
events.push({
|
|
4650
4661
|
sessionId,
|
|
4651
4662
|
type: "tool_call_begin",
|
|
@@ -4671,12 +4682,39 @@ function extractSkillName(block) {
|
|
|
4671
4682
|
}
|
|
4672
4683
|
return skill;
|
|
4673
4684
|
}
|
|
4685
|
+
function extractSubagentType(block) {
|
|
4686
|
+
if (block.name !== "Task" && block.name !== "Agent") {
|
|
4687
|
+
return;
|
|
4688
|
+
}
|
|
4689
|
+
const input = block.input;
|
|
4690
|
+
if (typeof input !== "object" || input === null) {
|
|
4691
|
+
return "general-purpose";
|
|
4692
|
+
}
|
|
4693
|
+
const subagentType = input.subagent_type;
|
|
4694
|
+
if (typeof subagentType === "string" && subagentType.length > 0) {
|
|
4695
|
+
return subagentType;
|
|
4696
|
+
}
|
|
4697
|
+
return "general-purpose";
|
|
4698
|
+
}
|
|
4674
4699
|
function mapUserMessage(sessionId, message) {
|
|
4675
4700
|
const events = [];
|
|
4676
4701
|
for (const block of message.message.content) {
|
|
4677
4702
|
if (block.type === "tool_result") {
|
|
4678
4703
|
const resultText = typeof block.content === "string" ? block.content : block.content.map((c) => c.text).join(`
|
|
4679
4704
|
`);
|
|
4705
|
+
const subagentUsage = extractTaskToolUsage(resultText);
|
|
4706
|
+
if (subagentUsage !== undefined) {
|
|
4707
|
+
events.push({
|
|
4708
|
+
sessionId,
|
|
4709
|
+
type: "subagent_complete",
|
|
4710
|
+
childId: block.tool_use_id,
|
|
4711
|
+
inputTokens: subagentUsage.totalTokens,
|
|
4712
|
+
outputTokens: 0,
|
|
4713
|
+
cacheReadTokens: 0,
|
|
4714
|
+
cacheCreationTokens: 0,
|
|
4715
|
+
costUsd: 0
|
|
4716
|
+
});
|
|
4717
|
+
}
|
|
4680
4718
|
events.push({
|
|
4681
4719
|
sessionId,
|
|
4682
4720
|
type: "tool_call_end",
|
|
@@ -4688,6 +4726,22 @@ function mapUserMessage(sessionId, message) {
|
|
|
4688
4726
|
}
|
|
4689
4727
|
return events;
|
|
4690
4728
|
}
|
|
4729
|
+
function extractTaskToolUsage(resultText) {
|
|
4730
|
+
if (!resultText.includes("agentId:")) {
|
|
4731
|
+
return;
|
|
4732
|
+
}
|
|
4733
|
+
const usageMatch = resultText.match(/<usage>([\s\S]*?)<\/usage>/);
|
|
4734
|
+
if (usageMatch === null) {
|
|
4735
|
+
return;
|
|
4736
|
+
}
|
|
4737
|
+
const totalMatch = usageMatch[1]?.match(/total_tokens:\s*(\d+)/);
|
|
4738
|
+
if (totalMatch === null || totalMatch === undefined) {
|
|
4739
|
+
return;
|
|
4740
|
+
}
|
|
4741
|
+
return {
|
|
4742
|
+
totalTokens: Number.parseInt(totalMatch[1] ?? "0", 10)
|
|
4743
|
+
};
|
|
4744
|
+
}
|
|
4691
4745
|
function mapResult(sessionId, message) {
|
|
4692
4746
|
const events = [];
|
|
4693
4747
|
const usage = message.usage;
|
|
@@ -29235,7 +29289,7 @@ async function buildClaudeBackend() {
|
|
|
29235
29289
|
const claudePath = process.env.CLAUDE_CODE_PATH ?? "/usr/local/bin/claude";
|
|
29236
29290
|
const driver = new ClaudeDriver2({
|
|
29237
29291
|
credentials: pickClaudeCredentials(process.env),
|
|
29238
|
-
agentInfo: { version: "0.5.
|
|
29292
|
+
agentInfo: { version: "0.5.4" },
|
|
29239
29293
|
sdk: {
|
|
29240
29294
|
async* query(args) {
|
|
29241
29295
|
const optsIn = args.options;
|