open-azdo 0.1.4 → 0.1.5

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/open-azdo.js CHANGED
@@ -28476,6 +28476,49 @@ var buildOpenCodeConfig = (agentName) => ({
28476
28476
  });
28477
28477
  var extractFinalResponse = (output) => {
28478
28478
  const texts = [];
28479
+ const structuredCandidates = [];
28480
+ const maybeCollectStructuredCandidate = (value3) => {
28481
+ if (!value3 || typeof value3 !== "object" || Array.isArray(value3)) {
28482
+ return;
28483
+ }
28484
+ if ("summary" in value3 && "verdict" in value3 && "findings" in value3) {
28485
+ structuredCandidates.push(JSON.stringify(value3));
28486
+ }
28487
+ };
28488
+ const collectTextCandidates = (value3) => {
28489
+ if (!value3) {
28490
+ return;
28491
+ }
28492
+ if (typeof value3 === "string") {
28493
+ const trimmed = value3.trim();
28494
+ if (!trimmed) {
28495
+ return;
28496
+ }
28497
+ texts.push(trimmed);
28498
+ try {
28499
+ maybeCollectStructuredCandidate(JSON.parse(trimmed));
28500
+ } catch {}
28501
+ return;
28502
+ }
28503
+ if (Array.isArray(value3)) {
28504
+ for (const entry of value3) {
28505
+ collectTextCandidates(entry);
28506
+ }
28507
+ return;
28508
+ }
28509
+ if (typeof value3 !== "object") {
28510
+ return;
28511
+ }
28512
+ maybeCollectStructuredCandidate(value3);
28513
+ if ("type" in value3 && value3.type === "text" && "text" in value3 && typeof value3.text === "string") {
28514
+ texts.push(value3.text.trim());
28515
+ }
28516
+ for (const [key, nested] of Object.entries(value3)) {
28517
+ if ((key === "text" || key === "content" || key === "message" || key === "part" || key === "parts" || key === "delta" || key === "textDelta" || key === "response" || key === "result" || key === "data" || key === "info") && nested !== undefined) {
28518
+ collectTextCandidates(nested);
28519
+ }
28520
+ }
28521
+ };
28479
28522
  for (const line of output.split(`
28480
28523
  `)) {
28481
28524
  const trimmed = line.trim();
@@ -28488,23 +28531,15 @@ var extractFinalResponse = (output) => {
28488
28531
  texts.push(event);
28489
28532
  continue;
28490
28533
  }
28491
- if (typeof event.text === "string") {
28492
- texts.push(event.text);
28493
- }
28494
- if (typeof event.content === "string") {
28495
- texts.push(event.content);
28496
- }
28497
- if (Array.isArray(event.content)) {
28498
- for (const part of event.content) {
28499
- if (part && typeof part.text === "string") {
28500
- texts.push(part.text);
28501
- }
28502
- }
28503
- }
28534
+ collectTextCandidates(event);
28504
28535
  } catch {
28505
28536
  texts.push(trimmed);
28506
28537
  }
28507
28538
  }
28539
+ const structuredResponse = structuredCandidates.at(-1)?.trim();
28540
+ if (structuredResponse) {
28541
+ return structuredResponse;
28542
+ }
28508
28543
  const response = texts.join(`
28509
28544
  `).trim();
28510
28545
  if (!response) {
@@ -28589,7 +28624,11 @@ class OpenCodeService extends Service()("open-azdo/OpenCodeService") {
28589
28624
  message: "OpenCode did not return a valid final response.",
28590
28625
  output: String(error)
28591
28626
  })
28592
- });
28627
+ }).pipe(exports_Effect.tapError((error) => logError2("Failed to extract final OpenCode response.", {
28628
+ stdoutPreview: truncateForLog(result3.stdout),
28629
+ stderrPreview: truncateForLog(result3.stderr),
28630
+ detail: error.message
28631
+ })));
28593
28632
  yield* logInfo2("Extracted final OpenCode response.", {
28594
28633
  responseChars: response.length,
28595
28634
  responsePreview: truncateForLog(response)
@@ -29940,4 +29979,4 @@ var main = async (argv, env) => await exports_Effect.runPromise(runCliWithExitHa
29940
29979
  // bin/open-azdo.ts
29941
29980
  process.exitCode = await main(process.argv.slice(2), process.env);
29942
29981
 
29943
- //# debugId=E8A5D5E7CAA7554564756E2164756E21
29982
+ //# debugId=126A3153D9BFAE4A64756E2164756E21