@engineeros/connector 0.8.7 → 0.8.9

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/src/runner.mjs CHANGED
@@ -485,7 +485,12 @@ export async function executeConnectedPrompt(assignment, config, callbacks) {
485
485
  callbacks,
486
486
  execution.profile,
487
487
  previousSessionId,
488
+ {
489
+ persistentAcp: true,
490
+ sessionKey: execution.sessionKey,
491
+ },
488
492
  );
493
+ callbacks.onController?.(controller);
489
494
  callbacks.onProcess?.(controller.child);
490
495
  const completed = await controller.completed;
491
496
  const content = completed.finalMessage.trim();
@@ -510,7 +515,7 @@ export async function inspectCodingAgent(config, workspace = process.cwd()) {
510
515
  return {
511
516
  protocol: "acp",
512
517
  name: config.agent_name || path.basename(config.agent_command),
513
- version: "ACP v1",
518
+ version: config.agent_version || "ACP v1",
514
519
  };
515
520
  }
516
521
  const codex = await inspectCodexCli(workspace);
@@ -587,25 +592,43 @@ export function promptProgressMessage(event) {
587
592
  if (event.type === "item.completed" && event.item?.type === "agent_message") {
588
593
  return "Preparing the response";
589
594
  }
590
- if (event.type === "agent.connected") return "Connected to the coding agent";
595
+ if (event.type === "agent.connected") return "Agent connected";
591
596
  if (event.type === "acp.tool_call" || event.type === "acp.tool_call_update") {
592
- return "Inspecting the workspace with the coding agent";
597
+ return "Agent is inspecting the workspace";
593
598
  }
594
599
  if (event.type === "acp.agent_message_chunk") return "Preparing the response";
595
600
  return null;
596
601
  }
597
602
 
598
- export function promptQueueMessage(activeKind) {
599
- if (activeKind === "assessment") {
600
- return "Queued: coding agent is finishing the workspace assessment";
603
+ export function promptStreamEvent(event) {
604
+ if (!event || typeof event !== "object") return null;
605
+ if (
606
+ event.type === "acp.agent_message_chunk" &&
607
+ event.update?.content?.type === "text"
608
+ ) {
609
+ return { kind: "message", delta: event.update.content.text };
610
+ }
611
+ if (event.type === "acp.agent_thought_chunk") {
612
+ return {
613
+ kind: "thought",
614
+ message: "Agent is reasoning through the request",
615
+ };
616
+ }
617
+ if (event.type === "acp.plan") {
618
+ return { kind: "plan", message: "Agent updated the working plan" };
601
619
  }
602
- if (activeKind === "goal") {
603
- return "Queued: coding agent is finishing an active Goal";
620
+ if (event.type === "acp.tool_call" || event.type === "acp.tool_call_update") {
621
+ return {
622
+ kind: "tool",
623
+ message: event.update?.title || "Agent is inspecting the workspace",
624
+ status: event.update?.status,
625
+ };
604
626
  }
605
- if (activeKind === "prompt") {
606
- return "Queued: coding agent is finishing another request";
627
+ if (event.type === "item.completed" && event.item?.type === "agent_message") {
628
+ return { kind: "message", delta: event.item.text };
607
629
  }
608
- return "Coding agent accepted the request";
630
+ const message = promptProgressMessage(event);
631
+ return message ? { kind: "status", message } : null;
609
632
  }
610
633
 
611
634
  function assessmentCommandMilestone(command) {
@@ -657,9 +680,13 @@ export function connectorExecution(assignment) {
657
680
  prompt,
658
681
  sandboxMode,
659
682
  sessionKey:
660
- typeof assignment.session_key === "string" && assignment.session_key.trim()
683
+ typeof assignment.session_key === "string" &&
684
+ assignment.session_key.trim()
661
685
  ? assignment.session_key.trim()
662
- : `project-${String(assignment.purpose || "general").toLowerCase().replace(/[^a-z0-9]+/g, "-").slice(0, 80)}`,
686
+ : `project-${String(assignment.purpose || "general")
687
+ .toLowerCase()
688
+ .replace(/[^a-z0-9]+/g, "-")
689
+ .slice(0, 80)}`,
663
690
  profile: {
664
691
  ...(model ? { model } : {}),
665
692
  ...(reasoningEffort ? { reasoning_effort: reasoningEffort } : {}),
@@ -830,7 +857,10 @@ function launchCodexProcess(
830
857
  if (!line.trim()) continue;
831
858
  try {
832
859
  const event = JSON.parse(line);
833
- if (event.type === "thread.started" && typeof event.thread_id === "string") {
860
+ if (
861
+ event.type === "thread.started" &&
862
+ typeof event.thread_id === "string"
863
+ ) {
834
864
  sessionId = event.thread_id;
835
865
  }
836
866
  if (
@@ -860,8 +890,14 @@ function launchCodexProcess(
860
890
  const completed = new Promise((resolve, reject) => {
861
891
  child.once("error", reject);
862
892
  child.once("close", (code) => {
863
- if (code === 0 && sessionId) resolve({ output: output.slice(-20_000), finalMessage, sessionId });
864
- else if (code === 0) reject(new Error("Codex completed without announcing a resumable session id."));
893
+ if (code === 0 && sessionId)
894
+ resolve({ output: output.slice(-20_000), finalMessage, sessionId });
895
+ else if (code === 0)
896
+ reject(
897
+ new Error(
898
+ "Codex completed without announcing a resumable session id.",
899
+ ),
900
+ );
865
901
  else reject(new Error(codexFailureMessage(output, code)));
866
902
  });
867
903
  });
@@ -937,12 +973,13 @@ function launchAgentProcess(
937
973
  mcpContext,
938
974
  ) {
939
975
  if (config.agent_protocol === "acp") {
940
- if (profile.model || profile.reasoning_effort) {
941
- throw new Error(
942
- "This ACP coding agent does not advertise execution-profile support.",
943
- );
944
- }
945
- return launchAcpAgent(workspace, prompt, config, callbacks);
976
+ return launchAcpAgent(workspace, prompt, config, callbacks, {
977
+ persistent: mcpContext?.persistentAcp === true,
978
+ sessionKey: mcpContext?.sessionKey,
979
+ previousSessionId,
980
+ sandbox,
981
+ profile,
982
+ });
946
983
  }
947
984
  return launchCodexProcess(
948
985
  workspace,