macro-agent 0.0.16 → 0.0.17

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.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@sudocode-ai/claude-code-acp",
3
- "version": "0.13.8",
3
+ "version": "0.13.9",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@sudocode-ai/claude-code-acp",
9
- "version": "0.13.8",
9
+ "version": "0.13.9",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "@agentclientprotocol/sdk": "0.13.1",
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.13.8",
6
+ "version": "0.13.9",
7
7
  "description": "An ACP-compatible coding agent powered by the Claude Code SDK (TypeScript)",
8
8
  "main": "dist/lib.js",
9
9
  "types": "dist/lib.d.ts",
@@ -1635,7 +1635,7 @@ export class ClaudeAcpAgent implements Agent {
1635
1635
 
1636
1636
  // Fetch commands and models in the background to avoid blocking session creation.
1637
1637
  // These calls wait for the Claude Code subprocess to initialize, which can be slow.
1638
- // Results are sent via sessionUpdate notifications when ready.
1638
+ // Results are sent via sessionUpdate; models via extension notification (_model_state_update).
1639
1639
  void (async () => {
1640
1640
  try {
1641
1641
  const [availableCommands, models] = await Promise.all([
@@ -1649,12 +1649,9 @@ export class ClaudeAcpAgent implements Agent {
1649
1649
  availableCommands,
1650
1650
  },
1651
1651
  });
1652
- this.client.sessionUpdate({
1652
+ this.client.extNotification("_model_state_update", {
1653
1653
  sessionId,
1654
- update: {
1655
- sessionUpdate: "model_state_update",
1656
- models,
1657
- },
1654
+ models,
1658
1655
  });
1659
1656
  } catch (e) {
1660
1657
  this.logger.error("Failed to fetch session metadata:", e);
@@ -720,7 +720,7 @@ describe("AgentManager Integration (with mocked acp-factory)", () => {
720
720
  );
721
721
  });
722
722
 
723
- it("should fall back to session_id if provider_session_id is not set", async () => {
723
+ it("should create new session if provider_session_id is not set", async () => {
724
724
  // Create agent directly without provider_session_id
725
725
  const agentId = "agent_no_provider";
726
726
  const sessionId = "session_no_provider";
@@ -744,11 +744,9 @@ describe("AgentManager Integration (with mocked acp-factory)", () => {
744
744
 
745
745
  await agentManager.resume(agentId);
746
746
 
747
- // Should fall back to the macro-agent session_id
748
- expect(mockHandle.loadSession).toHaveBeenCalledWith(
749
- sessionId,
750
- "/tmp",
751
- );
747
+ // Should create a new session instead of loading with invalid macro-agent session_id
748
+ expect(mockHandle.createSession).toHaveBeenCalledWith("/tmp");
749
+ expect(mockHandle.loadSession).not.toHaveBeenCalled();
752
750
  });
753
751
  });
754
752
 
@@ -901,16 +901,34 @@ export function createAgentManager(
901
901
  );
902
902
  }
903
903
 
904
- // Spawn new process and load existing session
904
+ // Spawn new process
905
905
  const handle = await AgentFactory.spawn(defaultAgentType, {
906
906
  permissionMode: defaultPermissionMode,
907
907
  });
908
908
 
909
- // Load the existing session using the provider's session ID (e.g., Claude Code UUID)
910
- // Falls back to macro-agent session_id for backwards compatibility
911
- const loadSessionId = agent.provider_session_id ?? agent.session_id;
912
909
  const agentCwd = agent.cwd ?? defaultCwd;
913
- const session = await handle.loadSession(loadSessionId, agentCwd);
910
+ let session;
911
+
912
+ if (agent.provider_session_id) {
913
+ // Load existing session using the provider's session ID (e.g., Claude Code UUID)
914
+ session = await handle.loadSession(agent.provider_session_id, agentCwd);
915
+ } else {
916
+ // No provider session ID available (agent predates this feature or wasn't persisted).
917
+ // Create a new session instead of loading with the macro-agent session_id
918
+ // which is not a valid provider session ID (e.g., Claude Code expects UUIDs).
919
+ session = await handle.createSession(agentCwd);
920
+
921
+ // Store the provider session ID for future resumes
922
+ eventStore.emit({
923
+ type: "status",
924
+ source: { agent_id: agentId },
925
+ payload: {
926
+ status_type: "started",
927
+ summary: "Agent session created (no provider session to resume)",
928
+ provider_session_id: session.id,
929
+ },
930
+ });
931
+ }
914
932
 
915
933
  // Track active session
916
934
  const activeSession: ActiveSession = {
@@ -929,6 +947,7 @@ export function createAgentManager(
929
947
  payload: {
930
948
  status_type: "started",
931
949
  summary: "Agent session resumed",
950
+ provider_session_id: session.id,
932
951
  },
933
952
  });
934
953