episoda 0.2.114 → 0.2.115

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.
@@ -2815,7 +2815,7 @@ var require_package = __commonJS({
2815
2815
  "package.json"(exports2, module2) {
2816
2816
  module2.exports = {
2817
2817
  name: "episoda",
2818
- version: "0.2.113",
2818
+ version: "0.2.114",
2819
2819
  description: "CLI tool for Episoda local development workflow orchestration",
2820
2820
  main: "dist/index.js",
2821
2821
  types: "dist/index.d.ts",
@@ -8714,7 +8714,7 @@ var AgentManager = class {
8714
8714
  * EP1173: Added autonomousMode parameter for permission-free execution
8715
8715
  */
8716
8716
  async startSession(options) {
8717
- const { sessionId, moduleId, moduleUid, projectPath, provider = "claude", autonomousMode = true, canWrite = true, readOnlyReason, mcpMode = "standard", message, credentials, systemPrompt, onChunk, onComplete, onError } = options;
8717
+ const { sessionId, moduleId, moduleUid, projectPath, provider = "claude", autonomousMode = true, canWrite = true, readOnlyReason, mcpMode = "standard", message, credentials, systemPrompt, onChunk, onToolUse, onComplete, onError } = options;
8718
8718
  const existingSession = this.sessions.get(sessionId);
8719
8719
  if (existingSession) {
8720
8720
  if (existingSession.provider === provider && existingSession.moduleId === moduleId) {
@@ -8727,6 +8727,8 @@ var AgentManager = class {
8727
8727
  canWrite,
8728
8728
  readOnlyReason,
8729
8729
  onChunk,
8730
+ onToolUse,
8731
+ // EP1236: Pass tool use callback
8730
8732
  onComplete,
8731
8733
  onError
8732
8734
  });
@@ -8788,6 +8790,8 @@ var AgentManager = class {
8788
8790
  message,
8789
8791
  isFirstMessage: true,
8790
8792
  onChunk,
8793
+ onToolUse,
8794
+ // EP1236: Pass tool use callback
8791
8795
  onComplete,
8792
8796
  onError
8793
8797
  });
@@ -8799,7 +8803,7 @@ var AgentManager = class {
8799
8803
  * EP1133: Supports both Claude Code and Codex CLI with provider-specific handling.
8800
8804
  */
8801
8805
  async sendMessage(options) {
8802
- const { sessionId, message, isFirstMessage, canWrite, readOnlyReason, agentSessionId, claudeSessionId, onChunk, onComplete, onError } = options;
8806
+ const { sessionId, message, isFirstMessage, canWrite, readOnlyReason, agentSessionId, claudeSessionId, onChunk, onToolUse, onComplete, onError } = options;
8803
8807
  const session = this.sessions.get(sessionId);
8804
8808
  if (!session) {
8805
8809
  return { success: false, error: "Session not found" };
@@ -9099,6 +9103,7 @@ If changes are needed, explain what needs to be done.`;
9099
9103
  let stdoutEventCount = 0;
9100
9104
  let chunksSent = 0;
9101
9105
  const streamStartTime = Date.now();
9106
+ let hasContent = false;
9102
9107
  childProcess.stdout?.on("data", (data) => {
9103
9108
  const rawData = data.toString();
9104
9109
  stdoutBuffer += rawData;
@@ -9148,13 +9153,25 @@ If changes are needed, explain what needs to be done.`;
9148
9153
  switch (parsed.type) {
9149
9154
  case "assistant":
9150
9155
  if (parsed.message?.content) {
9156
+ if (hasContent) {
9157
+ onChunk("\n\n");
9158
+ }
9151
9159
  for (const block of parsed.message.content) {
9152
9160
  if (block.type === "text" && block.text) {
9161
+ hasContent = true;
9153
9162
  chunksSent++;
9154
9163
  if (chunksSent <= 5) {
9155
9164
  console.log(`[AgentManager] EP1191: Sending chunk ${chunksSent} via assistant event - ${block.text.length} chars`);
9156
9165
  }
9157
9166
  onChunk(block.text);
9167
+ } else if (block.type === "tool_use" && options.onToolUse) {
9168
+ const toolEvent = {
9169
+ id: block.id,
9170
+ name: block.name,
9171
+ input: block.input || {}
9172
+ };
9173
+ console.log(`[AgentManager] EP1236: Tool invoked - ${toolEvent.name} (${toolEvent.id})`);
9174
+ options.onToolUse(toolEvent);
9158
9175
  }
9159
9176
  }
9160
9177
  }
@@ -10681,6 +10698,7 @@ var Daemon = class _Daemon {
10681
10698
  console.log(`[Daemon] EP912: Received agent command for ${projectId}:`, cmd.action);
10682
10699
  client.updateActivity();
10683
10700
  let daemonChunkCount = 0;
10701
+ let daemonToolUseCount = 0;
10684
10702
  const daemonStreamStart = Date.now();
10685
10703
  const createStreamingCallbacks = (sessionId, commandId) => ({
10686
10704
  onChunk: async (chunk) => {
@@ -10698,9 +10716,28 @@ var Daemon = class _Daemon {
10698
10716
  console.error(`[Daemon] EP912: Failed to send chunk (WebSocket may be disconnected):`, sendError);
10699
10717
  }
10700
10718
  },
10719
+ // EP1236: Forward tool invocations to platform for chat UI visibility
10720
+ onToolUse: async (event) => {
10721
+ daemonToolUseCount++;
10722
+ console.log(`[Daemon] EP1236: Forwarding tool_use ${daemonToolUseCount} via WebSocket - ${event.name}`);
10723
+ try {
10724
+ await client.send({
10725
+ type: "agent_result",
10726
+ commandId,
10727
+ result: {
10728
+ success: true,
10729
+ status: "tool_use",
10730
+ sessionId,
10731
+ toolUse: event
10732
+ }
10733
+ });
10734
+ } catch (sendError) {
10735
+ console.error(`[Daemon] EP1236: Failed to send tool_use (WebSocket may be disconnected):`, sendError);
10736
+ }
10737
+ },
10701
10738
  onComplete: async (claudeSessionId) => {
10702
10739
  const duration = Date.now() - daemonStreamStart;
10703
- console.log(`[Daemon] EP1191: Stream complete - ${daemonChunkCount} chunks forwarded in ${duration}ms`);
10740
+ console.log(`[Daemon] EP1191: Stream complete - ${daemonChunkCount} chunks, ${daemonToolUseCount} tool uses forwarded in ${duration}ms`);
10704
10741
  try {
10705
10742
  await client.send({
10706
10743
  type: "agent_result",