@chatpanel/events 0.81.0 → 0.81.1

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/package.json +1 -1
  2. package/team-tool.js +7 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatpanel/events",
3
- "version": "0.81.0",
3
+ "version": "0.81.1",
4
4
  "description": "The canonical ChatPanel event-log and capability contracts \u2014 typed durable facts, clock-free deterministic linearization, schema upcasting, and the invariants the replay harness asserts. Pure, dependency-free ESM shared by the ChatPanel extension, gateway and bridge.",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/team-tool.js CHANGED
@@ -116,9 +116,12 @@ export function teamToolProvider({ teams = [], run = null, appoint = null, confi
116
116
  if (action === 'run') {
117
117
  if (!request) return json({ error: 'run needs a request — what should the team do?' });
118
118
  if (typeof run !== 'function') return json({ error: 'This surface cannot run a team.' });
119
- const key = `${team.name}\n${request}`;
119
+ // ONE run per team per turn — keyed by the team, not the request: a model that
120
+ // re-runs after a partial result rephrases the request each time, and that was a
121
+ // second circle. Its partial result stands; the person decides what happens next.
122
+ const key = team.name;
120
123
  const prior = ran.get(key);
121
- if (prior) return json({ error: `The "${team.name}" team already ran this request in this turn (run ${prior.runId}, ${prior.status}). Do not run it again: tell the user what happened — ${prior.summary} — and ask how to proceed.`, runId: prior.runId, status: prior.status, tasks: prior.tasks });
124
+ if (prior) return json({ error: `The "${team.name}" team already ran in this turn (run ${prior.runId}, ${prior.status}). Do not run it again, even with a different request: report what it produced — ${prior.summary} — with its proposal, and ask the user how to proceed.`, runId: prior.runId, status: prior.status, tasks: prior.tasks, proposal: prior.proposal });
122
125
  const dry = dryRunTeam(team, request, { appoint });
123
126
  if (!dry.ok) return json({ error: `No model is available for role(s): ${dry.missing.join(', ')}.`, roles: dry.roles });
124
127
  const result = await run({ team, request, toolset: bound });
@@ -126,10 +129,10 @@ export function teamToolProvider({ teams = [], run = null, appoint = null, confi
126
129
  const tasks = (result.tasks || []).map((x) => ({ id: x.id, role: x.role, status: x.status, ms: x.ms, findings: (x.findings || []).length, error: x.error || undefined }));
127
130
  const failed = tasks.filter((x) => x.status !== 'ok');
128
131
  const summary = failed.length ? failed.map((x) => `${x.role} ${x.status}${x.error ? ` (${x.error})` : ''}`).join('; ') : `${findings.length} findings`;
129
- ran.set(key, { runId: result.runId, status: result.status, summary, tasks });
132
+ ran.set(key, { runId: result.runId, status: result.status, summary, tasks, proposal: result.proposal });
130
133
  const hint = result.status === 'over-budget' ? 'The team stopped at its budget; the proposal is what it had. Say so.'
131
134
  : result.status === 'failed' ? `The run FAILED — ${summary}. Do not run the team again this turn. Tell the user exactly which role failed and why, and ask whether to retry, change the team\'s models in Settings → Teams, or answer without the team.`
132
- : failed.length ? `Some roles did not finish — ${summary}. Say so alongside the proposal.` : undefined;
135
+ : failed.length ? `Some roles did not finish — ${summary}. Present the proposal as the team's answer and say which role did not finish; do NOT run the team again this turn.` : undefined;
133
136
  return json({ name: team.name, runId: result.runId, status: result.status, proposal: result.proposal, tasks, findings, usage: result.usage, hint });
134
137
  }
135
138
  return json({ error: `Unknown action "${action}". Use run, dry_run or save.` });