@pantheon.ai/agents 0.0.16 → 0.0.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/dist/index.js +60 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -395,7 +395,7 @@ var require_cli_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
395
395
|
|
|
396
396
|
//#endregion
|
|
397
397
|
//#region package.json
|
|
398
|
-
var version$1 = "0.0.
|
|
398
|
+
var version$1 = "0.0.17";
|
|
399
399
|
|
|
400
400
|
//#endregion
|
|
401
401
|
//#region src/schemas/task-list.ts
|
|
@@ -18140,11 +18140,11 @@ function createLlmExplainCommand(version) {
|
|
|
18140
18140
|
projectId: task.project_id,
|
|
18141
18141
|
branchId: task.branch_id
|
|
18142
18142
|
});
|
|
18143
|
-
if (!branch.branch
|
|
18143
|
+
if (!branch.branch?.latest_snap?.event_stream_id) {
|
|
18144
18144
|
console.error(`Branch ${task.branch_id} has no latest snap.`);
|
|
18145
18145
|
process$1.exit(1);
|
|
18146
18146
|
}
|
|
18147
|
-
const stream = await getRawStream(branch.branch
|
|
18147
|
+
const stream = await getRawStream(branch.branch?.latest_snap.event_stream_id);
|
|
18148
18148
|
const text = await llmExplain(task.task, stream, {
|
|
18149
18149
|
timeout: 3e3,
|
|
18150
18150
|
characters
|
|
@@ -31927,6 +31927,52 @@ function createClaudeCodeNormalizer(options = {}) {
|
|
|
31927
31927
|
});
|
|
31928
31928
|
return out;
|
|
31929
31929
|
}
|
|
31930
|
+
function formatToolResultOutput(content, toolUseResult) {
|
|
31931
|
+
if (toolUseResult == null) return content ?? null;
|
|
31932
|
+
if (content == null) return toolUseResult;
|
|
31933
|
+
if (typeof content === "string" && content.length === 0) return toolUseResult;
|
|
31934
|
+
return {
|
|
31935
|
+
content,
|
|
31936
|
+
tool_use_result: toolUseResult
|
|
31937
|
+
};
|
|
31938
|
+
}
|
|
31939
|
+
function getToolResultErrorText(content, toolUseResult) {
|
|
31940
|
+
if (typeof content === "string" && content.trim().length > 0) return content;
|
|
31941
|
+
if (isRecord(toolUseResult) && typeof toolUseResult.stderr === "string") {
|
|
31942
|
+
const stderr = toolUseResult.stderr.trim();
|
|
31943
|
+
if (stderr.length > 0) return stderr;
|
|
31944
|
+
}
|
|
31945
|
+
try {
|
|
31946
|
+
if (toolUseResult != null) return JSON.stringify(toolUseResult);
|
|
31947
|
+
} catch {}
|
|
31948
|
+
return "Tool execution failed";
|
|
31949
|
+
}
|
|
31950
|
+
function handleUserMessage(message, toolUseResult) {
|
|
31951
|
+
const blocks = Array.isArray(message.content) ? message.content : [];
|
|
31952
|
+
const out = [];
|
|
31953
|
+
blocks.forEach((block, index) => {
|
|
31954
|
+
if (!isRecord(block) || block.type !== "tool_result") return;
|
|
31955
|
+
const toolCallId = typeof block.tool_use_id === "string" ? block.tool_use_id : `claude-tool-result-${index}`;
|
|
31956
|
+
const content = block.content;
|
|
31957
|
+
const interrupted = isRecord(toolUseResult) && toolUseResult.interrupted === true;
|
|
31958
|
+
if (block.is_error === true || interrupted) {
|
|
31959
|
+
out.push({
|
|
31960
|
+
type: "tool-output-error",
|
|
31961
|
+
toolCallId,
|
|
31962
|
+
errorText: getToolResultErrorText(content, toolUseResult),
|
|
31963
|
+
dynamic: true
|
|
31964
|
+
});
|
|
31965
|
+
return;
|
|
31966
|
+
}
|
|
31967
|
+
out.push({
|
|
31968
|
+
type: "tool-output-available",
|
|
31969
|
+
toolCallId,
|
|
31970
|
+
output: formatToolResultOutput(content, toolUseResult),
|
|
31971
|
+
dynamic: true
|
|
31972
|
+
});
|
|
31973
|
+
});
|
|
31974
|
+
return out;
|
|
31975
|
+
}
|
|
31930
31976
|
function push(chunk) {
|
|
31931
31977
|
const parsed = topLevelSchema.safeParse(chunk);
|
|
31932
31978
|
if (!parsed.success) return {
|
|
@@ -31958,7 +32004,6 @@ function createClaudeCodeNormalizer(options = {}) {
|
|
|
31958
32004
|
};
|
|
31959
32005
|
}
|
|
31960
32006
|
case "stream_event": {
|
|
31961
|
-
sawStreamEvents = true;
|
|
31962
32007
|
const event = streamEventSchema.safeParse(msg.event);
|
|
31963
32008
|
if (!event.success) return {
|
|
31964
32009
|
recognized: false,
|
|
@@ -31980,6 +32025,17 @@ function createClaudeCodeNormalizer(options = {}) {
|
|
|
31980
32025
|
chunks: handleAssistantMessage(message)
|
|
31981
32026
|
};
|
|
31982
32027
|
}
|
|
32028
|
+
case "user": {
|
|
32029
|
+
const message = msg.message;
|
|
32030
|
+
if (!isRecord(message)) return {
|
|
32031
|
+
recognized: false,
|
|
32032
|
+
chunks: []
|
|
32033
|
+
};
|
|
32034
|
+
return {
|
|
32035
|
+
recognized: true,
|
|
32036
|
+
chunks: handleUserMessage(message, msg.tool_use_result)
|
|
32037
|
+
};
|
|
32038
|
+
}
|
|
31983
32039
|
case "result": return {
|
|
31984
32040
|
recognized: true,
|
|
31985
32041
|
chunks: maybeMeta({
|