@agentfield/sdk 0.1.64-rc.5 → 0.1.64-rc.6
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 +20 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -570,17 +570,30 @@ var init_opencode = __esm({
|
|
|
570
570
|
this.bin = binPath;
|
|
571
571
|
}
|
|
572
572
|
async execute(prompt, options) {
|
|
573
|
-
const cmd = [this.bin
|
|
573
|
+
const cmd = [this.bin];
|
|
574
|
+
if (options.cwd && typeof options.cwd === "string") {
|
|
575
|
+
cmd.push("-c", options.cwd);
|
|
576
|
+
} else if (options.project_dir && typeof options.project_dir === "string") {
|
|
577
|
+
cmd.push("-c", options.project_dir);
|
|
578
|
+
}
|
|
579
|
+
const env = { ...options.env };
|
|
574
580
|
if (options.model) {
|
|
575
|
-
|
|
581
|
+
env["MODEL"] = String(options.model);
|
|
576
582
|
}
|
|
577
|
-
|
|
583
|
+
let effectivePrompt = prompt;
|
|
584
|
+
if (options.system_prompt && typeof options.system_prompt === "string" && options.system_prompt.trim()) {
|
|
585
|
+
effectivePrompt = `SYSTEM INSTRUCTIONS:
|
|
586
|
+
${options.system_prompt.trim()}
|
|
587
|
+
|
|
588
|
+
---
|
|
589
|
+
|
|
590
|
+
USER REQUEST:
|
|
591
|
+
${prompt}`;
|
|
592
|
+
}
|
|
593
|
+
cmd.push("-p", effectivePrompt);
|
|
578
594
|
const startApi = Date.now();
|
|
579
595
|
try {
|
|
580
|
-
const { stdout, stderr, exitCode } = await runCli(cmd, {
|
|
581
|
-
env: options.env,
|
|
582
|
-
cwd: options.cwd
|
|
583
|
-
});
|
|
596
|
+
const { stdout, stderr, exitCode } = await runCli(cmd, { env });
|
|
584
597
|
const resultText = stdout.trim() || void 0;
|
|
585
598
|
const isError = exitCode !== 0 && !resultText;
|
|
586
599
|
return createRawResult({
|