open-azdo 0.1.3 → 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/README.md CHANGED
@@ -37,6 +37,7 @@ Common Azure Pipeline defaults:
37
37
 
38
38
  Optional flags:
39
39
 
40
+ - `--opencode-timeout-ms <milliseconds>` default `300000`
40
41
  - `--workspace <path>`
41
42
  - `--organization <name>`
42
43
  - `--project <name>`
@@ -96,6 +97,7 @@ steps:
96
97
  env:
97
98
  SYSTEM_ACCESSTOKEN: $(System.AccessToken)
98
99
  OPENAI_API_KEY: $(OpenAIApiKey)
100
+ OPEN_AZDO_OPENCODE_TIMEOUT_MS: "300000"
99
101
  ```
100
102
 
101
103
  ## Development
package/dist/open-azdo.js CHANGED
@@ -26790,6 +26790,7 @@ var ReviewConfigValue = Service("open-azdo/ReviewConfigValue");
26790
26790
  var RawReviewConfigSchema = exports_Schema.Struct({
26791
26791
  command: exports_Schema.Literal("review"),
26792
26792
  model: NonEmptyString2,
26793
+ opencodeTimeoutMs: PositiveInt,
26793
26794
  workspace: NonEmptyString2,
26794
26795
  organization: NonEmptyString2,
26795
26796
  project: NonEmptyString2,
@@ -26821,6 +26822,7 @@ var loadReviewConfig = exports_Effect.fn("config.loadReviewConfig")(function* (a
26821
26822
  try: () => exports_Schema.decodeUnknownSync(RawReviewConfigSchema)(compactOptionalKeys({
26822
26823
  command: "review",
26823
26824
  model: readStringFlag(parsedArgs.flags, "model") ?? env.OPEN_AZDO_MODEL,
26825
+ opencodeTimeoutMs: toPositiveInt(readStringFlag(parsedArgs.flags, "opencode-timeout-ms") ?? env.OPEN_AZDO_OPENCODE_TIMEOUT_MS ?? "300000"),
26824
26826
  workspace: readStringFlag(parsedArgs.flags, "workspace") ?? env.OPEN_AZDO_WORKSPACE ?? env.BUILD_SOURCESDIRECTORY,
26825
26827
  organization,
26826
26828
  project: readStringFlag(parsedArgs.flags, "project") ?? env.OPEN_AZDO_PROJECT ?? env.SYSTEM_TEAMPROJECT,
@@ -26902,6 +26904,7 @@ var parseArgs = (argv) => {
26902
26904
  var toReviewConfig = (rawConfig) => ({
26903
26905
  command: rawConfig.command,
26904
26906
  model: rawConfig.model,
26907
+ opencodeTimeoutMs: rawConfig.opencodeTimeoutMs,
26905
26908
  workspace: rawConfig.workspace,
26906
26909
  organization: rawConfig.organization,
26907
26910
  project: rawConfig.project,
@@ -28473,6 +28476,49 @@ var buildOpenCodeConfig = (agentName) => ({
28473
28476
  });
28474
28477
  var extractFinalResponse = (output) => {
28475
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
+ };
28476
28522
  for (const line of output.split(`
28477
28523
  `)) {
28478
28524
  const trimmed = line.trim();
@@ -28485,23 +28531,15 @@ var extractFinalResponse = (output) => {
28485
28531
  texts.push(event);
28486
28532
  continue;
28487
28533
  }
28488
- if (typeof event.text === "string") {
28489
- texts.push(event.text);
28490
- }
28491
- if (typeof event.content === "string") {
28492
- texts.push(event.content);
28493
- }
28494
- if (Array.isArray(event.content)) {
28495
- for (const part of event.content) {
28496
- if (part && typeof part.text === "string") {
28497
- texts.push(part.text);
28498
- }
28499
- }
28500
- }
28534
+ collectTextCandidates(event);
28501
28535
  } catch {
28502
28536
  texts.push(trimmed);
28503
28537
  }
28504
28538
  }
28539
+ const structuredResponse = structuredCandidates.at(-1)?.trim();
28540
+ if (structuredResponse) {
28541
+ return structuredResponse;
28542
+ }
28505
28543
  const response = texts.join(`
28506
28544
  `).trim();
28507
28545
  if (!response) {
@@ -28552,6 +28590,7 @@ class OpenCodeService extends Service()("open-azdo/OpenCodeService") {
28552
28590
  command: "opencode",
28553
28591
  args: ["run", "--format", "json", "--agent", config.agent, "--model", config.model, prompt],
28554
28592
  cwd: config.workspace,
28593
+ timeoutMs: config.opencodeTimeoutMs,
28555
28594
  env: {
28556
28595
  ...runtimeInput.env,
28557
28596
  OPENCODE_CONFIG: configPath,
@@ -28585,7 +28624,11 @@ class OpenCodeService extends Service()("open-azdo/OpenCodeService") {
28585
28624
  message: "OpenCode did not return a valid final response.",
28586
28625
  output: String(error)
28587
28626
  })
28588
- });
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
+ })));
28589
28632
  yield* logInfo2("Extracted final OpenCode response.", {
28590
28633
  responseChars: response.length,
28591
28634
  responsePreview: truncateForLog(response)
@@ -28668,6 +28711,7 @@ var writeStdout = exports_Effect.fn("cli.writeStdout")(function* (text) {
28668
28711
  var reviewLogFields = (config) => ({
28669
28712
  command: config.command,
28670
28713
  model: config.model,
28714
+ opencodeTimeoutMs: config.opencodeTimeoutMs,
28671
28715
  workspace: config.workspace,
28672
28716
  organization: config.organization,
28673
28717
  project: config.project,
@@ -29935,4 +29979,4 @@ var main = async (argv, env) => await exports_Effect.runPromise(runCliWithExitHa
29935
29979
  // bin/open-azdo.ts
29936
29980
  process.exitCode = await main(process.argv.slice(2), process.env);
29937
29981
 
29938
- //# debugId=3D47738376EA848764756E2164756E21
29982
+ //# debugId=126A3153D9BFAE4A64756E2164756E21