forgecraft 1.3.0 → 1.3.1
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.
|
@@ -695,31 +695,58 @@ ${context.existingFiles.map((f) => ` - ${f}`).join("\n")}` : "";
|
|
|
695
695
|
}
|
|
696
696
|
async executeQuery(prompt, opts = {}) {
|
|
697
697
|
let resultText = "";
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
})) {
|
|
707
|
-
if (msg.type === "result") {
|
|
708
|
-
if ("result" in msg && typeof msg.result === "string") {
|
|
709
|
-
resultText = msg.result;
|
|
710
|
-
} else if ("errors" in msg && Array.isArray(msg.errors)) {
|
|
711
|
-
throw new Error(`Agent error: ${msg.errors.join(", ")}`);
|
|
698
|
+
try {
|
|
699
|
+
for await (const msg of query({
|
|
700
|
+
prompt,
|
|
701
|
+
options: {
|
|
702
|
+
model: this.config.model,
|
|
703
|
+
systemPrompt: ORCHESTRATOR_SYSTEM_PROMPT,
|
|
704
|
+
maxTurns: opts.maxTurns,
|
|
705
|
+
allowedTools: []
|
|
712
706
|
}
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
707
|
+
})) {
|
|
708
|
+
if (msg.type === "result") {
|
|
709
|
+
const hasError = "is_error" in msg && msg.is_error;
|
|
710
|
+
const errors = "errors" in msg && Array.isArray(msg.errors) ? msg.errors : [];
|
|
711
|
+
const subtype = "subtype" in msg ? String(msg.subtype) : "";
|
|
712
|
+
if (hasError || errors.length > 0) {
|
|
713
|
+
const errorParts = [];
|
|
714
|
+
if (subtype) errorParts.push(subtype);
|
|
715
|
+
for (const e of errors) {
|
|
716
|
+
const eStr = typeof e === "string" ? e : JSON.stringify(e);
|
|
717
|
+
if (eStr && eStr.length > 0) errorParts.push(eStr);
|
|
718
|
+
}
|
|
719
|
+
const errorMsg = errorParts.length > 0 ? errorParts.join(" \u2014 ") : "Unknown error from Claude. Check your auth with: claude login";
|
|
720
|
+
throw new Error(errorMsg);
|
|
721
|
+
}
|
|
722
|
+
if ("result" in msg && typeof msg.result === "string") {
|
|
723
|
+
resultText = msg.result;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
if (msg.type === "assistant" && msg.message?.content) {
|
|
727
|
+
const textBlocks = msg.message.content.filter((b) => b.type === "text").map((b) => b.text);
|
|
728
|
+
if (textBlocks.length > 0) {
|
|
729
|
+
resultText = textBlocks.join("\n");
|
|
730
|
+
}
|
|
718
731
|
}
|
|
719
732
|
}
|
|
733
|
+
} catch (error) {
|
|
734
|
+
if (error instanceof Error && !error.message.includes("EPIPE") && !error.message.includes("ENOENT")) {
|
|
735
|
+
throw error;
|
|
736
|
+
}
|
|
737
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
738
|
+
throw new Error(
|
|
739
|
+
`Failed to communicate with Claude. ${msg}
|
|
740
|
+
Possible fixes:
|
|
741
|
+
1. Run: claude login
|
|
742
|
+
2. Check your internet connection
|
|
743
|
+
3. Run: forge doctor`
|
|
744
|
+
);
|
|
720
745
|
}
|
|
721
746
|
if (!resultText) {
|
|
722
|
-
throw new Error(
|
|
747
|
+
throw new Error(
|
|
748
|
+
"No response from Claude.\n Possible fixes:\n 1. Run: claude login\n 2. Check your internet connection\n 3. Run: forge doctor"
|
|
749
|
+
);
|
|
723
750
|
}
|
|
724
751
|
return resultText;
|
|
725
752
|
}
|
|
@@ -1072,11 +1099,19 @@ var Worker = class {
|
|
|
1072
1099
|
if ("result" in msg && typeof msg.result === "string") {
|
|
1073
1100
|
result.summary = msg.result;
|
|
1074
1101
|
}
|
|
1075
|
-
|
|
1076
|
-
|
|
1102
|
+
const hasError = "is_error" in msg && msg.is_error;
|
|
1103
|
+
const errors = "errors" in msg && Array.isArray(msg.errors) ? msg.errors : [];
|
|
1104
|
+
const subtype = "subtype" in msg ? String(msg.subtype || "") : "";
|
|
1105
|
+
if (errors.length > 0) {
|
|
1106
|
+
for (const e of errors) {
|
|
1107
|
+
const eStr = typeof e === "string" ? e : JSON.stringify(e);
|
|
1108
|
+
if (eStr && eStr.length > 0) result.errors.push(eStr);
|
|
1109
|
+
}
|
|
1077
1110
|
}
|
|
1078
|
-
if (
|
|
1079
|
-
result.errors.push(
|
|
1111
|
+
if (hasError && result.errors.length === 0) {
|
|
1112
|
+
result.errors.push(
|
|
1113
|
+
subtype || "Claude encountered an error. Run: claude login"
|
|
1114
|
+
);
|
|
1080
1115
|
}
|
|
1081
1116
|
if (msg.usage) {
|
|
1082
1117
|
result.usage.inputTokens = msg.usage.input_tokens || 0;
|
|
@@ -2276,9 +2311,13 @@ var AutoPipeline = class {
|
|
|
2276
2311
|
this.activeSpinner = null;
|
|
2277
2312
|
const msg = err instanceof Error ? err.message : String(err);
|
|
2278
2313
|
console.log(chalk4.red(`
|
|
2279
|
-
${msg}
|
|
2280
|
-
|
|
2281
|
-
|
|
2314
|
+
${msg}
|
|
2315
|
+
`));
|
|
2316
|
+
if (!msg.includes("Possible fixes")) {
|
|
2317
|
+
console.log(chalk4.dim(" Possible fixes:"));
|
|
2318
|
+
console.log(chalk4.dim(" 1. Run: claude login"));
|
|
2319
|
+
console.log(chalk4.dim(" 2. Check your internet connection"));
|
|
2320
|
+
console.log(chalk4.dim(" 3. Run: forge doctor\n"));
|
|
2282
2321
|
}
|
|
2283
2322
|
this.stopChatListener();
|
|
2284
2323
|
return { success: false, plan: null, errors: [`Plan: ${msg}`] };
|
|
@@ -3037,4 +3076,4 @@ export {
|
|
|
3037
3076
|
validateConfig,
|
|
3038
3077
|
loadAndValidateConfig
|
|
3039
3078
|
};
|
|
3040
|
-
//# sourceMappingURL=chunk-
|
|
3079
|
+
//# sourceMappingURL=chunk-M5MX6CAQ.js.map
|