@botcord/daemon 0.2.13 → 0.2.15

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.
Files changed (34) hide show
  1. package/dist/agent-workspace.js +47 -1
  2. package/dist/gateway/channels/botcord.js +39 -0
  3. package/dist/gateway/dispatcher.d.ts +6 -0
  4. package/dist/gateway/dispatcher.js +207 -9
  5. package/dist/gateway/runtimes/acp-stream.d.ts +7 -1
  6. package/dist/gateway/runtimes/acp-stream.js +19 -0
  7. package/dist/gateway/runtimes/claude-code.js +34 -0
  8. package/dist/gateway/runtimes/codex.js +50 -0
  9. package/dist/gateway/runtimes/hermes-agent.d.ts +8 -3
  10. package/dist/gateway/runtimes/hermes-agent.js +36 -6
  11. package/dist/gateway/runtimes/ndjson-stream.d.ts +8 -1
  12. package/dist/gateway/runtimes/ndjson-stream.js +8 -0
  13. package/dist/gateway/types.d.ts +54 -2
  14. package/dist/index.js +72 -5
  15. package/dist/provision.js +63 -1
  16. package/package.json +1 -1
  17. package/src/__tests__/agent-workspace.test.ts +25 -0
  18. package/src/__tests__/provision.test.ts +68 -1
  19. package/src/agent-workspace.ts +47 -0
  20. package/src/gateway/__tests__/botcord-channel.test.ts +97 -0
  21. package/src/gateway/__tests__/claude-code-adapter.test.ts +35 -0
  22. package/src/gateway/__tests__/codex-adapter.test.ts +44 -0
  23. package/src/gateway/__tests__/dispatcher.test.ts +552 -1
  24. package/src/gateway/__tests__/hermes-agent-adapter.test.ts +39 -0
  25. package/src/gateway/channels/botcord.ts +38 -0
  26. package/src/gateway/dispatcher.ts +217 -15
  27. package/src/gateway/runtimes/acp-stream.ts +24 -0
  28. package/src/gateway/runtimes/claude-code.ts +41 -1
  29. package/src/gateway/runtimes/codex.ts +58 -0
  30. package/src/gateway/runtimes/hermes-agent.ts +45 -5
  31. package/src/gateway/runtimes/ndjson-stream.ts +15 -0
  32. package/src/gateway/types.ts +55 -2
  33. package/src/index.ts +88 -5
  34. package/src/provision.ts +62 -1
@@ -85,6 +85,41 @@ for (const l of lines) process.stdout.write(JSON.stringify(l) + "\\n");
85
85
  expect(seen).toContain("system");
86
86
  });
87
87
 
88
+ it("emits thinking onStatus events for system init, tool_use, text, and result", async () => {
89
+ const script = makeScript(
90
+ "thinkflow.js",
91
+ `
92
+ const lines = [
93
+ {type:"system", subtype:"init", session_id:"sid-thk"},
94
+ {type:"assistant", message:{content:[{type:"tool_use", id:"tu1", name:"Bash", input:{}}]}},
95
+ {type:"assistant", message:{content:[{type:"text", text:"done"}]}},
96
+ {type:"result", subtype:"success", session_id:"sid-thk", result:"done"},
97
+ ];
98
+ for (const l of lines) process.stdout.write(JSON.stringify(l) + "\\n");
99
+ `,
100
+ );
101
+ const adapter = new ClaudeCodeAdapter({ binary: script });
102
+ const ctrl = new AbortController();
103
+ const status: Array<{ phase: string; label?: string }> = [];
104
+ await adapter.run({
105
+ text: "x",
106
+ sessionId: null,
107
+ accountId: "ag_test",
108
+ cwd: tmpRoot,
109
+ signal: ctrl.signal,
110
+ trustLevel: "owner",
111
+ onStatus: (e) => {
112
+ if (e.kind === "thinking") status.push({ phase: e.phase, label: e.label });
113
+ },
114
+ });
115
+ expect(status).toEqual([
116
+ { phase: "started", label: "Starting session" },
117
+ { phase: "updated", label: "Bash" },
118
+ { phase: "stopped", label: undefined },
119
+ { phase: "stopped", label: undefined },
120
+ ]);
121
+ });
122
+
88
123
  it("skips non-JSON stdout lines and still returns result", async () => {
89
124
  const script = makeScript(
90
125
  "nonjson.js",
@@ -107,6 +107,50 @@ for (const l of lines) process.stdout.write(JSON.stringify(l) + "\\n");
107
107
  expect(seen).toContain("system");
108
108
  });
109
109
 
110
+ it("emits thinking onStatus events for thread.started, turn.started, tool item, and assistant_message", async () => {
111
+ const script = makeScript(
112
+ "thinkflow.js",
113
+ `
114
+ const lines = [
115
+ {type:"thread.started", thread_id:"01234567-89ab-7def-8123-456789abcde2"},
116
+ {type:"turn.started"},
117
+ {type:"item.started", item:{id:"i0", type:"web_search", query:"x"}},
118
+ {type:"item.completed", item:{id:"i1", type:"agent_message", text:"ok"}},
119
+ {type:"turn.completed", usage:{}},
120
+ ];
121
+ for (const l of lines) process.stdout.write(JSON.stringify(l) + "\\n");
122
+ `,
123
+ );
124
+ const adapter = new CodexAdapter({ binary: script });
125
+ const ctrl = new AbortController();
126
+ const status: Array<{ phase: string; label?: string }> = [];
127
+ await adapter.run({
128
+ text: "x",
129
+ sessionId: null,
130
+ accountId: "ag_test",
131
+ cwd: tmpRoot,
132
+ signal: ctrl.signal,
133
+ trustLevel: "owner",
134
+ onStatus: (e) => {
135
+ if (e.kind === "thinking") {
136
+ status.push({ phase: e.phase, label: e.label });
137
+ }
138
+ },
139
+ });
140
+ // thread.started → started/Starting session
141
+ // turn.started → started/Thinking
142
+ // item.started(web_search) → updated/Searching web
143
+ // item.completed(agent_message) → stopped
144
+ // turn.completed → stopped
145
+ expect(status).toEqual([
146
+ { phase: "started", label: "Starting session" },
147
+ { phase: "started", label: "Thinking" },
148
+ { phase: "updated", label: "Searching web" },
149
+ { phase: "stopped", label: undefined },
150
+ { phase: "stopped", label: undefined },
151
+ ]);
152
+ });
153
+
110
154
  it("no sessionId → `exec` subcommand (no resume)", async () => {
111
155
  const script = makeScript(
112
156
  "fresh-argv.js",