@coda-console/claude 1.6.2 → 1.6.3

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 (2) hide show
  1. package/agent/waits.mjs +14 -19
  2. package/package.json +1 -1
package/agent/waits.mjs CHANGED
@@ -144,24 +144,24 @@ export class ClaudeWaits {
144
144
  takeUp({ origin, text } = {}) {
145
145
  const pending = [...this.tasks.values()].filter(task => task.final !== undefined && task.state === 'waiting');
146
146
  const crons = [...this.crons.values()].filter(cron => open(cron.state));
147
- let handled = [];
148
- if (origin?.kind === 'task-notification') handled = origin.subkind === 'scheduled-trigger' ? crons.filter(cron => cron.prompt && cron.prompt === text)
149
- : [...this.tasks.values()].filter(task => origin.runId && task.runId === origin.runId && open(task.state));
150
- // A message a subagent sent (SendMessage: its report handed back, or word of how it goes) is that subagent's. Taken up for
151
- // what it said, not for its end (`messaged`): the subagent ends as its end is told, not with this turn.
152
- if (origin?.kind === 'peer') {
153
- handled = [...this.tasks.values()].filter(task => origin.senderTaskId && task.taskId === origin.senderTaskId && open(task.state));
154
- for (const task of handled) task.messaged = true;
155
- }
156
- if (!handled.length) handled = pending.sort((a, b) => a.endedAt - b.endedAt);
157
- if (!handled.length) {
147
+ // What its opening message names: the wakeup that fired, the run a notice is of, the subagent a message is from.
148
+ const named = origin?.kind === 'task-notification' ? origin.subkind === 'scheduled-trigger' ? crons.filter(cron => cron.prompt && cron.prompt === text)
149
+ : [...this.tasks.values()].filter(task => origin.runId && task.runId === origin.runId)
150
+ : origin?.kind === 'peer' ? [...this.tasks.values()].filter(task => origin.senderTaskId && task.taskId === origin.senderTaskId) : [];
151
+ // Handled means ended (Coda places its card there and lets it be stopped no more): a subagent's message is the report it
152
+ // handed back only once it has ended; one still running says how it goes (SendMessage).
153
+ let handled = origin?.kind === 'peer' ? named.filter(task => pending.includes(task)) : named.filter(wait => open(wait.state));
154
+ // One that names nothing known is taken for what else ended, else the one wakeup due. One that names what was taken in
155
+ // already (Claude Code's turn for the notice of a subagent whose report an earlier turn read) or what still runs is not.
156
+ if (!named.length) handled = pending.sort((a, b) => a.endedAt - b.endedAt);
157
+ if (!named.length && !handled.length) {
158
158
  // Which came due is not told: the one due, or else the only one there is.
159
159
  const due = crons.filter(cron => cron.at !== null && cron.at <= this.now() + 60_000);
160
160
  if ((due.length || crons.length) === 1) handled = due.length ? due : crons;
161
161
  }
162
162
  if (handled.length) for (const wait of handled) this.report(wait, 'handling');
163
- // Nothing it names: told as a wait of its own once it says or asks something. One that says nothing is not told at all,
164
- // as Claude Code's turn for the notice of a subagent whose report an earlier turn took in, which reaches no model.
163
+ // Nothing to take up: told as a wait of its own once it says or asks something. One that says nothing is not told at
164
+ // all, as that turn for a notice, which reaches no model.
165
165
  else this.unclaimed = true;
166
166
  }
167
167
  claim() { if (this.unclaimed) { this.unclaimed = false; this.hold(); } }
@@ -176,12 +176,7 @@ export class ClaudeWaits {
176
176
  // outcome, and leave recurring wakeups scheduled. There may already be a turn-owned activity (hold).
177
177
  this.unclaimed = false;
178
178
  if (error && !this.own.size) this.hold();
179
- for (const task of this.tasks.values()) {
180
- if (task.state !== 'handling') continue;
181
- const messaged = task.messaged; task.messaged = false;
182
- if (messaged && task.final === undefined) { this.report(task, 'waiting'); continue; }
183
- this.report(task, task.final ?? 'done'); task.final = undefined;
184
- }
179
+ for (const task of this.tasks.values()) if (task.state === 'handling') { this.report(task, task.final ?? 'done'); task.final = undefined; }
185
180
  for (const cron of this.crons.values()) {
186
181
  if (cron.state !== 'handling') continue;
187
182
  if (cron.final !== undefined || !cron.recurring) { this.report(cron, 'done'); continue; }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "id": "claude",
4
4
  "displayName": "Claude",
5
5
  "description": "Claude SDK Agent:Coda 基于 Claude Agent SDK 写的 ACP 入口,一个进程一个 SDK 会话;资源页的「Claude」面板显示会话报告的额度,可从 Coda 登录。",
6
- "version": "1.6.2",
6
+ "version": "1.6.3",
7
7
  "categories": ["Agent"],
8
8
  "dependencies": {
9
9
  "@agentclientprotocol/sdk": "1.4.0",