wtagent 0.1.0-alpha.4 → 0.1.0-alpha.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wtagent",
3
- "version": "0.1.0-alpha.4",
3
+ "version": "0.1.0-alpha.5",
4
4
  "description": "Turn your own web AI session into a local tool-using agent.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -813,23 +813,33 @@ export class ChatGPTWebAdapter {
813
813
  }
814
814
 
815
815
  async #assistantText(message) {
816
- // ChatGPT may render the model's XML inside one of several code blocks,
817
- // alongside rich cards (weather, charts, etc.) or other markdown. Search
818
- // every code block for the envelope first; if none contains it, fall back
819
- // to the full message text so the protocol layer can extract the envelope
820
- // from wherever it landed.
816
+ // Read the whole assistant turn first. A long XML response can contain
817
+ // Markdown fences inside CDATA; ChatGPT then splits the rendered response
818
+ // into many <pre><code> nodes and the first node contains the opening tag
819
+ // but not the closing tag. The parent innerText keeps the complete envelope
820
+ // and avoids one CDP round trip per nested code block on every poll.
821
+ const fullText = await message.innerText().catch(() => "");
822
+ if (fullText.includes("<agent_response")) {
823
+ return fullText;
824
+ }
825
+
826
+ // Rare fallback for alternate renderers where the parent text omits code
827
+ // contents: prefer a complete code-block envelope, but retain a partial
828
+ // one so streaming progress remains visible until its closing tag arrives.
821
829
  const codeBlocks = message.locator("pre code");
822
830
  const codeBlockCount = await codeBlocks.count();
831
+ let partialEnvelope = "";
823
832
  for (let index = 0; index < codeBlockCount; index += 1) {
824
833
  const code = await codeBlocks.nth(index).innerText().catch(() => "");
825
- if (code.includes("<agent_response")) {
834
+ if (hasCompleteAgentEnvelope(code)) {
826
835
  return code;
827
836
  }
837
+ if (!partialEnvelope && code.includes("<agent_response")) {
838
+ partialEnvelope = code;
839
+ }
828
840
  }
829
-
830
- const fullText = await message.innerText().catch(() => "");
831
- if (fullText.includes("<agent_response")) {
832
- return fullText;
841
+ if (partialEnvelope) {
842
+ return partialEnvelope;
833
843
  }
834
844
 
835
845
  const markdown = message.locator(".markdown");
package/src/cli/main.js CHANGED
@@ -611,7 +611,7 @@ async function runExport(sessionId, options) {
611
611
  const program = new Command()
612
612
  .name("wtagent")
613
613
  .description("Turn your web AI session into a local tool-using agent.")
614
- .version("0.1.0-alpha.4")
614
+ .version("0.1.0-alpha.5")
615
615
  .option("--home <path>", "Application data directory")
616
616
  .option("--profile-dir <path>", "Dedicated Chrome profile directory")
617
617
  .option("--chrome-path <path>", "Chrome/Chromium executable")