@wenathlan/extension 1.1.58 → 1.1.59

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.
@@ -5588,7 +5588,7 @@ function renderagents(context) {
5588
5588
  row.className = "sessionrow";
5589
5589
  const info = document.createElement("p");
5590
5590
  const budgettext = agent.budget === void 0 ? "no ceiling" : [agent.budget.maxtokens !== void 0 ? `${agent.usage?.tokens ?? 0}/${agent.budget.maxtokens} tokens` : "", agent.budget.maxcost !== void 0 ? `${agent.usage?.cost ?? 0}/${agent.budget.maxcost} ${agent.budget.currency ?? ""}` : "", agent.budget.maxsteps !== void 0 ? `${agent.usage?.steps ?? 0}/${agent.budget.maxsteps} steps` : ""].filter((part) => part !== "").join(", ") || "no ceiling set";
5591
- info.textContent = `${agent.name} \xB7 ${agent.role} \xB7 ${agent.state}${agent.tabid !== void 0 ? ` \xB7 tab ${agent.tabid}` : ""}${agent.parentid !== void 0 ? ` \xB7 sub of ${agent.parentid} at depth ${agent.depth}` : ""}${agent.currenttask !== void 0 ? ` \xB7 working: ${agent.currenttask}` : " \xB7 idle"} \xB7 budget ${budgettext}${agent.heartbeatat !== void 0 ? ` \xB7 heartbeat ${new Date(agent.heartbeatat).toLocaleTimeString()}` : ""}${agent.unread > 0 ? ` \xB7 ${agent.unread} unread` : ""}.`;
5591
+ info.textContent = `${agent.name} \xB7 ${agent.role} \xB7 ${agent.state}${agent.tabid !== void 0 ? ` \xB7 tab ${agent.tabid}` : ""}${agent.parentid !== void 0 ? ` \xB7 sub of ${agent.parentid} at depth ${agent.depth}` : ""}${agent.currenttask !== void 0 ? ` \xB7 working: ${agent.currenttask}` : " \xB7 idle"} \xB7 budget ${budgettext}${agent.heartbeatat !== void 0 ? ` \xB7 heartbeat ${new Date(agent.heartbeatat).toLocaleTimeString()}` : ""}${agent.unread > 0 ? ` \xB7 ${agent.unread} unread` : ""}${agent.reviewstatus !== void 0 ? ` \xB7 review: ${agent.reviewstatus}` : ""}${agent.handoffarrows.length > 0 ? ` \xB7 handoffs: ${agent.handoffarrows.join(", ")}` : ""}.`;
5592
5592
  row.append(info);
5593
5593
  const actions = document.createElement("div");
5594
5594
  actions.className = "actions";
@@ -5636,7 +5636,7 @@ function renderagents(context) {
5636
5636
  const nameinput = document.createElement("input");
5637
5637
  nameinput.placeholder = "new agent name";
5638
5638
  const roleselect = document.createElement("select");
5639
- for (const role of ["worker", "planner", "observer"]) {
5639
+ for (const role of ["worker", "planner", "observer", "critic", "verifier"]) {
5640
5640
  const option = document.createElement("option");
5641
5641
  option.value = role;
5642
5642
  option.textContent = role;
@@ -5662,7 +5662,7 @@ function renderagents(context) {
5662
5662
  parentselect.append(option);
5663
5663
  }
5664
5664
  const spawnrole = document.createElement("select");
5665
- for (const role of ["worker", "planner", "observer"]) {
5665
+ for (const role of ["worker", "planner", "observer", "critic", "verifier"]) {
5666
5666
  const option = document.createElement("option");
5667
5667
  option.value = role;
5668
5668
  option.textContent = role;
@@ -5861,6 +5861,558 @@ function renderagents(context) {
5861
5861
  }));
5862
5862
  boardbox.append(postrow);
5863
5863
  agentsroot.append(boardbox);
5864
+ const orchestrationbox = document.createElement("details");
5865
+ orchestrationbox.className = "sessiongroup";
5866
+ const orchestrationsummary = document.createElement("summary");
5867
+ orchestrationsummary.textContent = "Leader worker topology";
5868
+ orchestrationbox.append(orchestrationsummary);
5869
+ if (swarm.topology !== void 0) {
5870
+ const lead = swarm.agents.find((agent) => agent.id === swarm.topology?.leaderid);
5871
+ const topinfo = document.createElement("p");
5872
+ topinfo.textContent = `Leader ${swarm.topology.leaderid}${lead !== void 0 ? ` (${lead.name})` : ""} by the ${swarm.topology.rule.kind} rule \xB7 ${swarm.topology.workerids.length} workers, ${swarm.topology.criticids.length} critics, ${swarm.topology.verifierids.length} verifiers \xB7 ${swarm.topology.assignments.length} assignment${swarm.topology.assignments.length === 1 ? "" : "s"}.`;
5873
+ orchestrationbox.append(topinfo);
5874
+ const assignments = document.createElement("ul");
5875
+ assignments.className = "audit";
5876
+ for (const assignment of swarm.topology.assignments.slice(0, 8)) {
5877
+ const entry = document.createElement("li");
5878
+ entry.textContent = `${assignment.workerid} \u2192 task ${assignment.taskid}: ${assignment.slice}.`;
5879
+ assignments.append(entry);
5880
+ }
5881
+ orchestrationbox.append(assignments);
5882
+ for (const split of swarm.splits.slice(0, 4)) {
5883
+ const row = document.createElement("p");
5884
+ row.textContent = `Planner executor split: ${split.planownerid} plans, ${split.runownerid} runs${split.taskid !== void 0 ? ` task ${split.taskid}` : ""} with ${split.stepreports.length} step report${split.stepreports.length === 1 ? "" : "s"} (${split.stepreports.filter((report) => report.outcome === "done").length} done).`;
5885
+ orchestrationbox.append(row);
5886
+ }
5887
+ } else {
5888
+ const none = document.createElement("p");
5889
+ none.textContent = "No leader is elected yet; the user elects one by the first or named rule.";
5890
+ orchestrationbox.append(none);
5891
+ }
5892
+ const electionrow = document.createElement("div");
5893
+ electionrow.className = "actions";
5894
+ const leaderselect = document.createElement("select");
5895
+ const firstoption = document.createElement("option");
5896
+ firstoption.value = "first";
5897
+ firstoption.textContent = "first registration";
5898
+ leaderselect.append(firstoption);
5899
+ for (const agent of swarm.agents) {
5900
+ const option = document.createElement("option");
5901
+ option.value = agent.id;
5902
+ option.textContent = `named: ${agent.name}`;
5903
+ leaderselect.append(option);
5904
+ }
5905
+ const splitplan = document.createElement("select");
5906
+ const splitrun = document.createElement("select");
5907
+ const splittask = document.createElement("input");
5908
+ splittask.placeholder = "task id";
5909
+ for (const agent of swarm.agents) {
5910
+ const plan = document.createElement("option");
5911
+ plan.value = agent.id;
5912
+ plan.textContent = agent.name;
5913
+ splitplan.append(plan);
5914
+ const run = document.createElement("option");
5915
+ run.value = agent.id;
5916
+ run.textContent = agent.name;
5917
+ splitrun.append(run);
5918
+ }
5919
+ electionrow.append(leaderselect, " ", button("Elect leader", async () => {
5920
+ await request({ kind: "swarmleader", elect: leaderselect.value === "first" ? { rule: "first" } : { rule: "named", agentid: leaderselect.value } });
5921
+ status("The leader election recorded the topology; the leader only organizes reviewed work.");
5922
+ await refresh();
5923
+ }), " ", button("Assign work", async () => {
5924
+ await request({ kind: "swarmleader", assign: {} });
5925
+ status("The leader sliced the tasks across the workers; every slice still passes the plan review.");
5926
+ await refresh();
5927
+ }), " ", button("Scale workers", async () => {
5928
+ await request({ kind: "swarmleader", scale: { pending: swarm.queue.counts.queued + swarm.queue.counts.claimed } });
5929
+ status("The worker lane scaled by the load under the user configured bound.");
5930
+ await refresh();
5931
+ }), " ", splitplan, " ", splitrun, " ", splittask, " ", button("Split plan and run", async () => {
5932
+ if (splitplan.value === splitrun.value) {
5933
+ status("The planner executor split needs two different agents.");
5934
+ return;
5935
+ }
5936
+ await request({ kind: "swarmleader", split: { planownerid: splitplan.value, runownerid: splitrun.value, ...splittask.value.trim() !== "" ? { taskid: splittask.value } : {} } });
5937
+ status("The task split between the planner and the executor; the executor reports every step back.");
5938
+ await refresh();
5939
+ }));
5940
+ orchestrationbox.append(electionrow);
5941
+ agentsroot.append(orchestrationbox);
5942
+ const boardbox2 = document.createElement("details");
5943
+ boardbox2.className = "sessiongroup";
5944
+ const board2summary = document.createElement("summary");
5945
+ board2summary.textContent = `Progressboard (${swarm.board.lanes.length} lanes)`;
5946
+ boardbox2.append(board2summary);
5947
+ for (const lane of swarm.board.lanes) {
5948
+ const row = document.createElement("p");
5949
+ row.textContent = `${lane.name} (${lane.role}, ${lane.state}) \xB7 lane ${lane.lane}${lane.currenttask !== void 0 ? ` \xB7 working: ${lane.currenttask}` : ""}${lane.milestones.length > 0 ? ` \xB7 ${lane.milestones.filter((milestone) => milestone.done).length}/${lane.milestones.length} milestones (${lane.milestones.map((milestone) => milestone.done ? milestone.label : `${milestone.label} (open)`).join(", ")})` : ""}.`;
5950
+ boardbox2.append(row);
5951
+ }
5952
+ const milestonerow = document.createElement("div");
5953
+ milestonerow.className = "actions";
5954
+ const milestoneagent = document.createElement("select");
5955
+ for (const agent of swarm.agents) {
5956
+ const option = document.createElement("option");
5957
+ option.value = agent.id;
5958
+ option.textContent = agent.name;
5959
+ milestoneagent.append(option);
5960
+ }
5961
+ const milestonelabel = document.createElement("input");
5962
+ milestonelabel.placeholder = "milestone label";
5963
+ milestonerow.append(milestoneagent, " ", milestonelabel, " ", button("Report milestone", async () => {
5964
+ await request({ kind: "swarmleader", milestone: { agentid: milestoneagent.value, label: milestonelabel.value, done: true } });
5965
+ status("The milestone landed on the progressboard snapshot.");
5966
+ await refresh();
5967
+ }), " ", button("Snapshot board", async () => {
5968
+ await request({ kind: "swarmmerge", snapshot: true });
5969
+ status("The progressboard snapshot was stored under the user configured retention.");
5970
+ await refresh();
5971
+ }));
5972
+ boardbox2.append(milestonerow);
5973
+ agentsroot.append(boardbox2);
5974
+ const reviewbox = document.createElement("details");
5975
+ reviewbox.className = "sessiongroup";
5976
+ const reviewsummary = document.createElement("summary");
5977
+ reviewsummary.textContent = `Reviews and verifications (${swarm.reviews.length} verdicts, ${swarm.verifications.length} checks)`;
5978
+ reviewbox.append(reviewsummary);
5979
+ for (const request2 of swarm.reviewrequests.slice(0, 8)) {
5980
+ const row = document.createElement("p");
5981
+ row.textContent = `Review request ${request2.subject}: ${request2.fromagentid} \u2192 ${request2.toagentid}, ${request2.state}${request2.timeoutat !== void 0 ? ` \xB7 deadline ${new Date(request2.timeoutat).toLocaleTimeString()}` : ""}.`;
5982
+ const actions = document.createElement("div");
5983
+ actions.className = "actions";
5984
+ actions.append(button("Ack", async () => {
5985
+ await request({ kind: "swarmreview", ack: request2.id });
5986
+ status("The review request was acked.");
5987
+ await refresh();
5988
+ }));
5989
+ row.append(actions);
5990
+ reviewbox.append(row);
5991
+ }
5992
+ for (const review of swarm.reviews.slice(0, 8)) {
5993
+ const row = document.createElement("p");
5994
+ row.textContent = `Critic verdict ${review.verdict} by ${review.reviewerid} over the output of ${review.subjectagentid}${review.issues.length > 0 ? ` \xB7 issues: ${review.issues.join("; ")}` : ""}${review.requiredchanges.length > 0 ? ` \xB7 required: ${review.requiredchanges.join("; ")}` : ""}.`;
5995
+ reviewbox.append(row);
5996
+ }
5997
+ for (const check of swarm.verifications.slice(0, 8)) {
5998
+ const row = document.createElement("p");
5999
+ const badge = document.createElement("strong");
6000
+ badge.textContent = check.outcome === "pass" ? "PASS" : "FAIL";
6001
+ row.append(`Verifier ${check.verifierid} checked the claim of ${check.claimagentid} by the ${check.method} method: `, badge, ` \u2014 ${check.claim}${check.evidence !== void 0 ? ` (${check.evidence})` : ""}.`);
6002
+ reviewbox.append(row);
6003
+ }
6004
+ const reviewrow = document.createElement("div");
6005
+ reviewrow.className = "actions";
6006
+ const reviewfrom = document.createElement("select");
6007
+ const reviewto = document.createElement("select");
6008
+ for (const agent of swarm.agents) {
6009
+ const one = document.createElement("option");
6010
+ one.value = agent.id;
6011
+ one.textContent = agent.name;
6012
+ reviewfrom.append(one);
6013
+ const two = document.createElement("option");
6014
+ two.value = agent.id;
6015
+ two.textContent = agent.name;
6016
+ reviewto.append(two);
6017
+ }
6018
+ const reviewsubject = document.createElement("input");
6019
+ reviewsubject.placeholder = "review subject";
6020
+ const reviewpayload = document.createElement("input");
6021
+ reviewpayload.placeholder = "output payload";
6022
+ const reviewverdict = document.createElement("select");
6023
+ for (const verdict of ["approve", "changes", "reject"]) {
6024
+ const option = document.createElement("option");
6025
+ option.value = verdict;
6026
+ option.textContent = verdict;
6027
+ reviewverdict.append(option);
6028
+ }
6029
+ const reviewchanges = document.createElement("input");
6030
+ reviewchanges.placeholder = "required changes, semicolon separated";
6031
+ reviewrow.append(reviewfrom, " ", reviewto, " ", reviewsubject, " ", reviewpayload, " ", button("Request review", async () => {
6032
+ await request({ kind: "swarmreview", request: { fromagentid: reviewfrom.value, toagentid: reviewto.value, subject: reviewsubject.value, payload: reviewpayload.value } });
6033
+ status("The review request was routed; the critic reads only.");
6034
+ await refresh();
6035
+ }), " ", reviewverdict, " ", reviewchanges, " ", button("Apply verdict", async () => {
6036
+ const open = swarm.reviewrequests.find((entry) => entry.state === "open" && entry.toagentid === reviewto.value);
6037
+ if (open === void 0) {
6038
+ status("No open review request for the selected reviewer; request one first.");
6039
+ return;
6040
+ }
6041
+ await request({ kind: "swarmreview", apply: { id: open.id, reviewerid: reviewto.value, verdict: reviewverdict.value, issues: [], requiredchanges: reviewchanges.value.split(";").map((change) => change.trim()).filter((change) => change !== "") } });
6042
+ status("The critic verdict was applied; the rework still passes the human review.");
6043
+ await refresh();
6044
+ }), " ", button("Sweep timeouts", async () => {
6045
+ await request({ kind: "swarmreview", sweep: true });
6046
+ status("The review sweep timed out the unanswered requests.");
6047
+ await refresh();
6048
+ }));
6049
+ const verifyrow = document.createElement("div");
6050
+ verifyrow.className = "actions";
6051
+ const verifierselect = document.createElement("select");
6052
+ for (const agent of swarm.agents) {
6053
+ const option = document.createElement("option");
6054
+ option.value = agent.id;
6055
+ option.textContent = agent.name;
6056
+ verifierselect.append(option);
6057
+ }
6058
+ const claimagent = document.createElement("select");
6059
+ for (const agent of swarm.agents) {
6060
+ const option = document.createElement("option");
6061
+ option.value = agent.id;
6062
+ option.textContent = agent.name;
6063
+ claimagent.append(option);
6064
+ }
6065
+ const claimtext = document.createElement("input");
6066
+ claimtext.placeholder = "claim to verify";
6067
+ const claimmethod = document.createElement("input");
6068
+ claimmethod.placeholder = "method";
6069
+ const claimoutcome = document.createElement("select");
6070
+ for (const outcome of ["pass", "fail"]) {
6071
+ const option = document.createElement("option");
6072
+ option.value = outcome;
6073
+ option.textContent = outcome;
6074
+ claimoutcome.append(option);
6075
+ }
6076
+ verifyrow.append(verifierselect, " ", claimagent, " ", claimtext, " ", claimmethod, " ", claimoutcome, " ", button("Verify claim", async () => {
6077
+ await request({ kind: "swarmreview", verify: { verifierid: verifierselect.value, claimagentid: claimagent.value, claim: claimtext.value, method: claimmethod.value, outcome: claimoutcome.value } });
6078
+ status(`The verifier marked the claim ${claimoutcome.value} with the method it used.`);
6079
+ await refresh();
6080
+ }));
6081
+ reviewbox.append(reviewrow, verifyrow);
6082
+ agentsroot.append(reviewbox);
6083
+ const escalationbox = document.createElement("details");
6084
+ escalationbox.className = "sessiongroup";
6085
+ const escalationsummary = document.createElement("summary");
6086
+ escalationsummary.textContent = `Escalation inbox (${swarm.escalations.filter((escalation) => escalation.state === "open").length} open)`;
6087
+ escalationbox.append(escalationsummary);
6088
+ for (const escalation of swarm.escalations.slice(0, 8)) {
6089
+ const row = document.createElement("div");
6090
+ row.className = "sessionrow";
6091
+ const info = document.createElement("p");
6092
+ info.textContent = `${escalation.state === "open" ? "AWAITS THE USER" : "decided"} \xB7 ${escalation.agentid} lifted ${escalation.subject} \u2014 ${escalation.context}${escalation.decision !== void 0 ? ` \xB7 decision: ${escalation.decision}` : ""}.`;
6093
+ row.append(info);
6094
+ if (escalation.state === "open") {
6095
+ const actions = document.createElement("div");
6096
+ actions.className = "actions";
6097
+ const decision = document.createElement("input");
6098
+ decision.placeholder = "the decision the user writes";
6099
+ actions.append(decision, " ", button("Decide", async () => {
6100
+ await request({ kind: "swarmreview", decide: { id: escalation.id, decision: decision.value } });
6101
+ status("The user decision was recorded; the agent continues from it.");
6102
+ await refresh();
6103
+ }));
6104
+ row.append(actions);
6105
+ }
6106
+ escalationbox.append(row);
6107
+ }
6108
+ const escalaterow = document.createElement("div");
6109
+ escalaterow.className = "actions";
6110
+ const escalateagent = document.createElement("select");
6111
+ for (const agent of swarm.agents) {
6112
+ const option = document.createElement("option");
6113
+ option.value = agent.id;
6114
+ option.textContent = agent.name;
6115
+ escalateagent.append(option);
6116
+ }
6117
+ const escalatesubject = document.createElement("input");
6118
+ escalatesubject.placeholder = "stalled subject";
6119
+ const escalatecontext = document.createElement("input");
6120
+ escalatecontext.placeholder = "full context for the user";
6121
+ escalaterow.append(escalateagent, " ", escalatesubject, " ", escalatecontext, " ", button("Escalate to user", async () => {
6122
+ await request({ kind: "swarmreview", escalate: { agentid: escalateagent.value, subject: escalatesubject.value, context: escalatecontext.value } });
6123
+ status("The stalled decision was lifted to the user; the agent waits.");
6124
+ await refresh();
6125
+ }));
6126
+ escalationbox.append(escalaterow);
6127
+ agentsroot.append(escalationbox);
6128
+ const consensusbox = document.createElement("details");
6129
+ consensusbox.className = "sessiongroup";
6130
+ const consensussummary = document.createElement("summary");
6131
+ consensussummary.textContent = `Consensus rounds (${swarm.consensus.length})`;
6132
+ consensusbox.append(consensussummary);
6133
+ for (const round of swarm.consensus.slice(0, 6)) {
6134
+ const yes = round.votes.filter((vote) => vote.vote === "yes").length;
6135
+ const no = round.votes.filter((vote) => vote.vote === "no").length;
6136
+ const abstain = round.votes.filter((vote) => vote.vote === "abstain").length;
6137
+ const row = document.createElement("p");
6138
+ row.textContent = `${round.subject}: ${round.state} \xB7 ${yes} yes, ${no} no, ${abstain} abstain against the quorum ${round.quorum}${round.votes.length > 0 ? ` \xB7 voted by ${round.votes.map((vote) => vote.agentid).join(", ")}` : ""}.`;
6139
+ const actions = document.createElement("div");
6140
+ actions.className = "actions";
6141
+ const voterselect = document.createElement("select");
6142
+ for (const agent of swarm.agents) {
6143
+ const option = document.createElement("option");
6144
+ option.value = agent.id;
6145
+ option.textContent = agent.name;
6146
+ voterselect.append(option);
6147
+ }
6148
+ const voteselect = document.createElement("select");
6149
+ for (const vote of ["yes", "no", "abstain"]) {
6150
+ const option = document.createElement("option");
6151
+ option.value = vote;
6152
+ option.textContent = vote;
6153
+ voteselect.append(option);
6154
+ }
6155
+ actions.append(voterselect, " ", voteselect, " ", button("Vote", async () => {
6156
+ await request({ kind: "swarmreview", vote: { id: round.id, agentid: voterselect.value, vote: voteselect.value } });
6157
+ status(`The vote landed on the round ${round.subject}.`);
6158
+ await refresh();
6159
+ }));
6160
+ row.append(actions);
6161
+ consensusbox.append(row);
6162
+ }
6163
+ const consensusrow = document.createElement("div");
6164
+ consensusrow.className = "actions";
6165
+ const subjectinput2 = document.createElement("input");
6166
+ subjectinput2.placeholder = "consensus subject";
6167
+ const quoruminput = document.createElement("input");
6168
+ quoruminput.placeholder = "quorum";
6169
+ consensusrow.append(subjectinput2, " ", quoruminput, " ", button("Open round", async () => {
6170
+ await request({ kind: "swarmreview", consensus: { subject: subjectinput2.value, ...quoruminput.value.trim() !== "" ? { quorum: Number(quoruminput.value) } : {} } });
6171
+ status("The consensus round opened with the user configured quorum.");
6172
+ await refresh();
6173
+ }));
6174
+ consensusbox.append(consensusrow);
6175
+ agentsroot.append(consensusbox);
6176
+ const handoffbox = document.createElement("details");
6177
+ handoffbox.className = "sessiongroup";
6178
+ const handoffsummary = document.createElement("summary");
6179
+ handoffsummary.textContent = `Handoffs and locks (${swarm.handoffs.length} handoffs, ${swarm.locks.length} locks)`;
6180
+ handoffbox.append(handoffsummary);
6181
+ for (const record of swarm.handoffs.slice(0, 8)) {
6182
+ const row = document.createElement("p");
6183
+ row.textContent = `${record.fromagentid} \u2192 ${record.toagentid}${record.tabid !== void 0 ? ` \xB7 tab ${record.tabid}` : ""} \xB7 ${record.state} \xB7 packaged state: ${record.taskstate}.`;
6184
+ const actions = document.createElement("div");
6185
+ actions.className = "actions";
6186
+ if (record.state === "prepared") actions.append(button("Transfer", async () => {
6187
+ await request({ kind: "swarmhandoff", transfer: record.id });
6188
+ status("The tab moved between the agents under the one agent per tab rule.");
6189
+ await refresh();
6190
+ }), " ");
6191
+ if (record.state === "transferred") actions.append(button("Resume", async () => {
6192
+ await request({ kind: "swarmhandoff", resume: record.id });
6193
+ status("The receiving agent resumed the task from the packaged state.");
6194
+ await refresh();
6195
+ }));
6196
+ row.append(actions);
6197
+ handoffbox.append(row);
6198
+ }
6199
+ const handoffrow = document.createElement("div");
6200
+ handoffrow.className = "actions";
6201
+ const handofffrom = document.createElement("select");
6202
+ const handoffto = document.createElement("select");
6203
+ for (const agent of swarm.agents) {
6204
+ const one = document.createElement("option");
6205
+ one.value = agent.id;
6206
+ one.textContent = agent.name;
6207
+ handofffrom.append(one);
6208
+ const two = document.createElement("option");
6209
+ two.value = agent.id;
6210
+ two.textContent = agent.name;
6211
+ handoffto.append(two);
6212
+ }
6213
+ const handoffstate = document.createElement("input");
6214
+ handoffstate.placeholder = "packaged task state";
6215
+ handoffrow.append(handofffrom, " ", handoffto, " ", handoffstate, " ", button("Prepare handoff", async () => {
6216
+ await request({ kind: "swarmhandoff", prepare: { fromagentid: handofffrom.value, toagentid: handoffto.value, taskstate: handoffstate.value } });
6217
+ status("The handoff was prepared with the packaged task state.");
6218
+ await refresh();
6219
+ }));
6220
+ handoffbox.append(handoffrow);
6221
+ for (const lock of swarm.locks.slice(0, 8)) {
6222
+ const row = document.createElement("p");
6223
+ row.textContent = `Lock ${lock.key} \xB7 ${lock.kind} \xB7 holder ${lock.holder} \xB7 acquired ${new Date(lock.acquiredat).toLocaleTimeString()}${lock.expiresat !== void 0 ? ` \xB7 expires in ${Math.max(Math.round((lock.expiresat - Date.now()) / 1e3), 0)}s` : " \xB7 no expiry"}.`;
6224
+ const actions = document.createElement("div");
6225
+ actions.className = "actions";
6226
+ actions.append(button("Release", async () => {
6227
+ await request({ kind: "swarmlocks", release: { key: lock.key, holder: lock.holder } });
6228
+ status("The lock released and the resource returned to the pool.");
6229
+ await refresh();
6230
+ }));
6231
+ row.append(actions);
6232
+ handoffbox.append(row);
6233
+ }
6234
+ const lockrow = document.createElement("div");
6235
+ lockrow.className = "actions";
6236
+ const lockholder = document.createElement("select");
6237
+ for (const agent of swarm.agents) {
6238
+ const option = document.createElement("option");
6239
+ option.value = agent.id;
6240
+ option.textContent = agent.name;
6241
+ lockholder.append(option);
6242
+ }
6243
+ const lockorigin = document.createElement("input");
6244
+ lockorigin.placeholder = "origin";
6245
+ const lockselector = document.createElement("input");
6246
+ lockselector.placeholder = "selector";
6247
+ const lockkindselect = document.createElement("select");
6248
+ for (const kind of ["exclusive", "shared"]) {
6249
+ const option = document.createElement("option");
6250
+ option.value = kind;
6251
+ option.textContent = kind;
6252
+ lockkindselect.append(option);
6253
+ }
6254
+ lockrow.append(lockholder, " ", lockorigin, " ", lockselector, " ", lockkindselect, " ", button("Acquire lock", async () => {
6255
+ await request({ kind: "swarmlocks", acquire: { holder: lockholder.value, origin: lockorigin.value, selector: lockselector.value, kind: lockkindselect.value } });
6256
+ status("The lock went to the holder; it serializes reviewed work only.");
6257
+ await refresh();
6258
+ }), " ", button("Sweep expired", async () => {
6259
+ await request({ kind: "swarmlocks", sweep: true });
6260
+ status("The expiry sweep returned the abandoned locks to the pool.");
6261
+ await refresh();
6262
+ }));
6263
+ handoffbox.append(lockrow);
6264
+ agentsroot.append(handoffbox);
6265
+ const conflictbox = document.createElement("details");
6266
+ conflictbox.className = "sessiongroup";
6267
+ const conflictsummary = document.createElement("summary");
6268
+ conflictsummary.textContent = `Conflicts and merges (${swarm.conflicts.length} scans)`;
6269
+ conflictbox.append(conflictsummary);
6270
+ for (const scan of swarm.conflicts.slice(0, 6)) {
6271
+ const row = document.createElement("p");
6272
+ row.textContent = scan.clean ? `Scan of ${scan.writers.length} writers: clean, no overlapping write.` : `Scan of ${scan.writers.length} writers: ${scan.overlaps.map((overlap) => `${overlap.origin}|${overlap.selector} by ${overlap.writers.join(", ")}`).join("; ")} \u2014 suggested order ${scan.suggestedorder.join(" \u2192 ")}.`;
6273
+ conflictbox.append(row);
6274
+ }
6275
+ const conflictrow = document.createElement("div");
6276
+ conflictrow.className = "actions";
6277
+ const scanorigin = document.createElement("input");
6278
+ scanorigin.placeholder = "origin";
6279
+ const scanselector = document.createElement("input");
6280
+ scanselector.placeholder = "selector";
6281
+ const scanagents = document.createElement("input");
6282
+ scanagents.placeholder = "writer agent ids, comma separated";
6283
+ conflictrow.append(scanorigin, " ", scanselector, " ", scanagents, " ", button("Scan conflicts", async () => {
6284
+ const writers = scanagents.value.split(",").map((id) => id.trim()).filter((id) => id !== "").map((id) => ({ agentid: id, origin: scanorigin.value, selector: scanselector.value }));
6285
+ await request({ kind: "swarmlocks", scan: { writers } });
6286
+ status("The conflict scan checked the overlapping writes before the parallel runs.");
6287
+ await refresh();
6288
+ }));
6289
+ conflictbox.append(conflictrow);
6290
+ if (swarm.report !== void 0) {
6291
+ const reportinfo = document.createElement("p");
6292
+ reportinfo.textContent = `Merged report ${swarm.report.title}: ${swarm.report.sections.length} section${swarm.report.sections.length === 1 ? "" : "s"} from ${swarm.report.sources.join(", ")}${swarm.report.confidence !== void 0 ? ` \xB7 confidence: ${swarm.report.confidence}` : ""}.`;
6293
+ conflictbox.append(reportinfo);
6294
+ const reportlist = document.createElement("ol");
6295
+ reportlist.className = "audit";
6296
+ for (const section of swarm.report.sections.slice(0, 3)) {
6297
+ const item = document.createElement("li");
6298
+ item.textContent = `${section.title}: ${section.entries.slice(0, 5).map((entry) => `${entry.key} = ${entry.value} (${entry.agentid}${entry.conflict !== void 0 ? `; ${entry.conflict}` : ""})`).join("; ")}.`;
6299
+ reportlist.append(item);
6300
+ }
6301
+ conflictbox.append(reportlist);
6302
+ const exportrow = document.createElement("div");
6303
+ exportrow.className = "actions";
6304
+ exportrow.append(button("Export report", async () => {
6305
+ await request({ kind: "swarmmerge", export: { carriespagecontent: true } });
6306
+ status("The merged report was exported; the page content it carries grades as a data egress event.");
6307
+ await refresh();
6308
+ }));
6309
+ conflictbox.append(exportrow);
6310
+ }
6311
+ const mergerow = document.createElement("div");
6312
+ mergerow.className = "actions";
6313
+ const reporttitle = document.createElement("input");
6314
+ reporttitle.placeholder = "report title";
6315
+ const mergeruleselect = document.createElement("select");
6316
+ for (const rule of ["first", "last", "preferagent", "fail"]) {
6317
+ const option = document.createElement("option");
6318
+ option.value = rule;
6319
+ option.textContent = rule;
6320
+ mergeruleselect.append(option);
6321
+ }
6322
+ const mergeoutputs = document.createElement("input");
6323
+ mergeoutputs.placeholder = "agent:task:key:value triples, semicolon separated";
6324
+ mergerow.append(reporttitle, " ", mergeruleselect, " ", mergeoutputs, " ", button("Build report", async () => {
6325
+ const entries2 = mergeoutputs.value.split(";").map((triple) => triple.split(":")).filter((parts) => parts.length === 4).map((parts) => ({ agentid: parts[0]?.trim() ?? "", taskid: parts[1]?.trim(), key: parts[2]?.trim() ?? "", value: parts[3]?.trim() ?? "" }));
6326
+ await request({ kind: "swarmmerge", entries: entries2, report: { title: reporttitle.value, rule: mergeruleselect.value } });
6327
+ status("The parallel outputs folded into one report with their provenance.");
6328
+ await refresh();
6329
+ }));
6330
+ conflictbox.append(mergerow);
6331
+ const comparerow = document.createElement("div");
6332
+ comparerow.className = "actions";
6333
+ const comparesubject = document.createElement("input");
6334
+ comparesubject.placeholder = "compare subject";
6335
+ const comparefirst = document.createElement("select");
6336
+ const comparesecond = document.createElement("select");
6337
+ for (const agent of swarm.agents) {
6338
+ const one = document.createElement("option");
6339
+ one.value = agent.id;
6340
+ one.textContent = agent.name;
6341
+ comparefirst.append(one);
6342
+ const two = document.createElement("option");
6343
+ two.value = agent.id;
6344
+ two.textContent = agent.name;
6345
+ comparesecond.append(two);
6346
+ }
6347
+ const comparevalue = document.createElement("input");
6348
+ comparevalue.placeholder = "output of the first agent";
6349
+ const comparevalue2 = document.createElement("input");
6350
+ comparevalue2.placeholder = "output of the second agent";
6351
+ comparerow.append(comparesubject, " ", comparefirst, " ", comparevalue, " ", comparesecond, " ", comparevalue2, " ", button("Compare outputs", async () => {
6352
+ await request({ kind: "swarmmerge", compare: { subject: comparesubject.value, outputs: [{ agentid: comparefirst.value, value: comparevalue.value }, { agentid: comparesecond.value, value: comparevalue2.value }] } });
6353
+ status("The competing outputs were contrasted for the user.");
6354
+ await refresh();
6355
+ }));
6356
+ conflictbox.append(comparerow);
6357
+ const lessonrow = document.createElement("div");
6358
+ lessonrow.className = "actions";
6359
+ const lessonagent = document.createElement("select");
6360
+ for (const agent of swarm.agents) {
6361
+ const option = document.createElement("option");
6362
+ option.value = agent.id;
6363
+ option.textContent = agent.name;
6364
+ lessonagent.append(option);
6365
+ }
6366
+ const lessonstatement = document.createElement("input");
6367
+ lessonstatement.placeholder = "verified lesson";
6368
+ const lessonverifier = document.createElement("input");
6369
+ lessonverifier.placeholder = "verified by";
6370
+ lessonrow.append(lessonagent, " ", lessonstatement, " ", lessonverifier, " ", button("Share lesson", async () => {
6371
+ await request({ kind: "swarmmerge", lesson: { agentid: lessonagent.value, statement: lessonstatement.value, verifiedby: lessonverifier.value } });
6372
+ status("The verified lesson landed on the findings section for every agent.");
6373
+ await refresh();
6374
+ }), " ", button("Recompute costs", async () => {
6375
+ await request({ kind: "swarmmerge", costs: true });
6376
+ status("The shared cost accounting summed the per agent usage into the swarm totals.");
6377
+ await refresh();
6378
+ }));
6379
+ conflictbox.append(lessonrow);
6380
+ agentsroot.append(conflictbox);
6381
+ const timelinebox = document.createElement("details");
6382
+ timelinebox.className = "sessiongroup";
6383
+ const timelinesummary = document.createElement("summary");
6384
+ timelinesummary.textContent = `Swarm timeline and costs (${swarm.timeline.length} actions)`;
6385
+ timelinebox.append(timelinesummary);
6386
+ const feed2 = document.createElement("ul");
6387
+ feed2.className = "audit";
6388
+ for (const action of swarm.timeline.slice(-12).reverse()) {
6389
+ const entry = document.createElement("li");
6390
+ entry.textContent = `${new Date(action.at).toLocaleTimeString()} ${action.kind}${action.agentid !== void 0 ? ` (${action.agentid})` : ""}: ${action.summary}`;
6391
+ feed2.append(entry);
6392
+ }
6393
+ timelinebox.append(feed2);
6394
+ const replayrow = document.createElement("div");
6395
+ replayrow.className = "actions";
6396
+ const replayselect = document.createElement("select");
6397
+ for (const agent of swarm.agents) {
6398
+ const option = document.createElement("option");
6399
+ option.value = agent.id;
6400
+ option.textContent = agent.name;
6401
+ replayselect.append(option);
6402
+ }
6403
+ replayrow.append(replayselect, " ", button("Replay agent run", async () => {
6404
+ const replayed = await request({ kind: "swarmmerge", replay: replayselect.value });
6405
+ status(replayed.replay !== void 0 && replayed.replay.length > 0 ? `The replay rebuilt ${replayed.replay.length} recorded actions of the agent.` : "The audit trail holds no recorded action of that agent yet.");
6406
+ await refresh();
6407
+ }));
6408
+ timelinebox.append(replayrow);
6409
+ const latestcost = swarm.costs[0];
6410
+ if (latestcost !== void 0) {
6411
+ const costinfo = document.createElement("p");
6412
+ costinfo.textContent = `Shared costs of ${latestcost.agents} agent${latestcost.agents === 1 ? "" : "s"}: ${latestcost.tokens} tokens \xB7 ${latestcost.cost} ${latestcost.currency ?? ""} \xB7 ${latestcost.steps} steps.`;
6413
+ timelinebox.append(costinfo);
6414
+ }
6415
+ agentsroot.append(timelinebox);
5864
6416
  if (swarm.events.length > 0) {
5865
6417
  const eventbox = document.createElement("details");
5866
6418
  eventbox.className = "sessiongroup";