@mutagent/cli 0.1.85 → 0.1.87
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/bin/cli.js +45 -5
- package/dist/bin/cli.js.map +6 -5
- package/package.json +1 -1
package/dist/bin/cli.js
CHANGED
|
@@ -3710,6 +3710,30 @@ import { Command as Command4 } from "commander";
|
|
|
3710
3710
|
import chalk8 from "chalk";
|
|
3711
3711
|
init_errors();
|
|
3712
3712
|
|
|
3713
|
+
// src/lib/resolve-prompt-id.ts
|
|
3714
|
+
async function resolveNumericPromptId(client, promptGroupId) {
|
|
3715
|
+
if (!promptGroupId)
|
|
3716
|
+
return null;
|
|
3717
|
+
let prompts;
|
|
3718
|
+
try {
|
|
3719
|
+
prompts = await client.listPrompts();
|
|
3720
|
+
} catch {
|
|
3721
|
+
return null;
|
|
3722
|
+
}
|
|
3723
|
+
const matches = prompts.filter((p) => p.promptGroupId === promptGroupId);
|
|
3724
|
+
if (matches.length === 0)
|
|
3725
|
+
return null;
|
|
3726
|
+
const latestFlagged = matches.find((p) => p.isLatest);
|
|
3727
|
+
if (latestFlagged)
|
|
3728
|
+
return latestFlagged.id;
|
|
3729
|
+
const sorted = [...matches].sort((a, b) => {
|
|
3730
|
+
const ta = a.updatedAt ? new Date(a.updatedAt).getTime() : 0;
|
|
3731
|
+
const tb = b.updatedAt ? new Date(b.updatedAt).getTime() : 0;
|
|
3732
|
+
return tb - ta;
|
|
3733
|
+
});
|
|
3734
|
+
return sorted[0]?.id ?? null;
|
|
3735
|
+
}
|
|
3736
|
+
|
|
3713
3737
|
// src/commands/prompts/guided-workflow.ts
|
|
3714
3738
|
init_sdk_client();
|
|
3715
3739
|
async function buildGuidedWorkflow(promptId) {
|
|
@@ -3876,10 +3900,16 @@ Examples:
|
|
|
3876
3900
|
try {
|
|
3877
3901
|
const client = await getSDKClient();
|
|
3878
3902
|
const evalObj = await client.getEvaluation(evaluationId);
|
|
3903
|
+
const numericPromptId = await resolveNumericPromptId(client, evalObj.promptGroupId);
|
|
3904
|
+
if (numericPromptId === null) {
|
|
3905
|
+
if (process.env.DEBUG) {
|
|
3906
|
+
console.error(`[debug] Evaluation ${String(evalObj.id)} references promptGroupId ${evalObj.promptGroupId} but no prompts were found in that group. Falling back to prompts dashboard.`);
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3879
3909
|
if (isJson) {
|
|
3880
3910
|
output.output({
|
|
3881
3911
|
...evalObj,
|
|
3882
|
-
_links: evaluationLinks(evalObj.
|
|
3912
|
+
_links: numericPromptId !== null ? evaluationLinks(numericPromptId, evalObj.id) : { dashboard: promptsDashboardLink(), api: `/api/prompts/${evalObj.promptGroupId}/evaluations/${String(evalObj.id)}` }
|
|
3883
3913
|
});
|
|
3884
3914
|
} else {
|
|
3885
3915
|
output.success(`Evaluation: ${evalObj.name} (ID: ${String(evalObj.id)})`);
|
|
@@ -3913,7 +3943,8 @@ Examples:
|
|
|
3913
3943
|
}
|
|
3914
3944
|
console.log("");
|
|
3915
3945
|
}
|
|
3916
|
-
|
|
3946
|
+
const dashboardUrl = numericPromptId !== null ? evaluationLink(numericPromptId, evalObj.id) : promptsDashboardLink();
|
|
3947
|
+
output.info(`View in dashboard: ${dashboardUrl}`);
|
|
3917
3948
|
}
|
|
3918
3949
|
} catch (error) {
|
|
3919
3950
|
handleError(error, isJson);
|
|
@@ -8651,6 +8682,11 @@ function getString(input, ...keys) {
|
|
|
8651
8682
|
}
|
|
8652
8683
|
return "";
|
|
8653
8684
|
}
|
|
8685
|
+
function serializePayload(value) {
|
|
8686
|
+
if (value === undefined || value === null)
|
|
8687
|
+
return;
|
|
8688
|
+
return typeof value === "string" ? value : JSON.stringify(value);
|
|
8689
|
+
}
|
|
8654
8690
|
async function handleSessionStart() {
|
|
8655
8691
|
const input = await readStdin();
|
|
8656
8692
|
const sessionId = getString(input, "session_id", "sessionId");
|
|
@@ -8720,6 +8756,7 @@ async function handlePreToolUse() {
|
|
|
8720
8756
|
toolName
|
|
8721
8757
|
};
|
|
8722
8758
|
writeState(sessionId, state);
|
|
8759
|
+
const toolInput = serializePayload(input.tool_input ?? input.toolInput);
|
|
8723
8760
|
await sendBatchTrace([
|
|
8724
8761
|
{
|
|
8725
8762
|
traceId: state.traceId,
|
|
@@ -8734,7 +8771,8 @@ async function handlePreToolUse() {
|
|
|
8734
8771
|
name: toolName,
|
|
8735
8772
|
kind: "tool",
|
|
8736
8773
|
startTime: now,
|
|
8737
|
-
status: "running"
|
|
8774
|
+
status: "running",
|
|
8775
|
+
input: toolInput
|
|
8738
8776
|
}
|
|
8739
8777
|
]
|
|
8740
8778
|
}
|
|
@@ -8769,6 +8807,7 @@ async function handlePostToolUse() {
|
|
|
8769
8807
|
state.openSpans = Object.fromEntries(Object.entries(state.openSpans).filter(([k]) => k !== matchedKey));
|
|
8770
8808
|
writeState(sessionId, state);
|
|
8771
8809
|
}
|
|
8810
|
+
const toolOutput = serializePayload(input.tool_output ?? input.toolOutput ?? input.tool_result ?? input.toolResult);
|
|
8772
8811
|
await sendBatchTrace([
|
|
8773
8812
|
{
|
|
8774
8813
|
traceId,
|
|
@@ -8784,7 +8823,8 @@ async function handlePostToolUse() {
|
|
|
8784
8823
|
kind: "tool",
|
|
8785
8824
|
startTime: spanStartTime,
|
|
8786
8825
|
endTime: now,
|
|
8787
|
-
status: "completed"
|
|
8826
|
+
status: "completed",
|
|
8827
|
+
output: toolOutput
|
|
8788
8828
|
}
|
|
8789
8829
|
]
|
|
8790
8830
|
}
|
|
@@ -9116,5 +9156,5 @@ program.addCommand(createHooksCommand());
|
|
|
9116
9156
|
program.addCommand(createFeedbackCommand());
|
|
9117
9157
|
program.parse();
|
|
9118
9158
|
|
|
9119
|
-
//# debugId=
|
|
9159
|
+
//# debugId=2CB8DD62F405DABB64756E2164756E21
|
|
9120
9160
|
//# sourceMappingURL=cli.js.map
|