jaxon-agents 0.2.0 → 0.3.0

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 (57) hide show
  1. package/README.agent.md +203 -168
  2. package/README.md +15 -6
  3. package/README.zh-CN.md +16 -7
  4. package/dist/BUILD_INFO.json +3 -3
  5. package/dist/PACKAGE_MANIFEST.json +56 -41
  6. package/dist/RELEASE_META.json +3 -3
  7. package/dist/agents/directory-store.js +66 -11
  8. package/dist/agents/jaxon-admin.entry.js +5 -3
  9. package/dist/agents/session-switch.js +6 -0
  10. package/dist/api/mcp-tools.js +75 -45
  11. package/dist/console/activity-client.js +84 -60
  12. package/dist/console/activity-topics.js +82 -24
  13. package/dist/console/activity.js +4 -4
  14. package/dist/console/assets.js +219 -257
  15. package/dist/console/chat-library.js +685 -0
  16. package/dist/console/console-info.js +30 -0
  17. package/dist/console/icons.js +14 -0
  18. package/dist/console/pages.js +71 -29
  19. package/dist/console/server.js +8 -4
  20. package/dist/console/station-pages.js +53 -29
  21. package/dist/daemon/host.js +14 -3
  22. package/dist/index.js +87 -8
  23. package/dist/launcher.js +17 -26
  24. package/dist/ops/catalog.js +18 -15
  25. package/dist/ops/core.js +85 -59
  26. package/dist/pi-host/mcp-bridge.entry.js +41 -10
  27. package/dist/platform/index.js +22 -0
  28. package/dist/platform/linux.js +64 -0
  29. package/dist/release/handoff.js +6 -8
  30. package/dist/release/store.js +3 -13
  31. package/dist/sessions/supervisor.js +61 -32
  32. package/dist/stations/activity.js +24 -28
  33. package/dist/stations/boards.js +10 -5
  34. package/dist/stations/cues.js +14 -2
  35. package/dist/stations/member-instructions.js +4 -6
  36. package/dist/stations/station-member.entry.js +28 -11
  37. package/examples/README.md +23 -8
  38. package/examples/agents/README.md +93 -35
  39. package/examples/agents/coder/README.md +37 -0
  40. package/examples/agents/custom-gateway/README.md +42 -0
  41. package/examples/agents/local-qwen/README.md +46 -0
  42. package/examples/agents/planner/README.md +39 -0
  43. package/examples/agents/reviewer/README.md +42 -0
  44. package/examples/mcp-clients/README.md +35 -16
  45. package/examples/stations/README.md +98 -21
  46. package/examples/stations/dev-loop/README.md +40 -0
  47. package/examples/stations/parallel-coders/README.md +40 -0
  48. package/examples/stations/parallel-coders/STATION.md +2 -2
  49. package/examples/stations/research-writer/README.md +39 -0
  50. package/examples/stations/research-writer/STATION.md +1 -1
  51. package/examples/workflows/01-dev-loop-e2e.md +27 -5
  52. package/examples/workflows/02-human-auth-and-roster-switch.md +25 -3
  53. package/examples/workflows/README.md +17 -0
  54. package/package.json +3 -3
  55. package/runtime/provenance.json +3 -3
  56. package/runtime/runtime-lock.json +2 -2
  57. package/runtime/runtime-package.json +1 -1
@@ -1,68 +1,70 @@
1
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
1
+ import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { CallToolRequestSchema, ListToolsRequestSchema, SubscribeRequestSchema, UnsubscribeRequestSchema } from "@modelcontextprotocol/sdk/types.js";
3
3
  import { z } from "zod";
4
4
  import { fail, errorData } from "../ops/errors.js";
5
5
  import { operationSchema } from "../ops/catalog.js";
6
6
  import { APP_VERSION } from "../root.js";
7
+ import { consoleInfoFrom, consoleUrl } from "../console/console-info.js";
7
8
  export const SERVER_INSTRUCTIONS = `jaxon-agents hosts isolated Pi sub-agent sessions. Start work with session_start,
8
9
  follow up with session_send, answer blocking prompts with session_reply, and close
9
10
  sessions you no longer need. Delegate authority: pass the goal, hard boundaries and
10
- board references, never micromanage steps, specify which sections/lines to edit, or
11
- pre-write checklists—leave how to plan, code, test or review to the sub-agent.
11
+ board references, and leave how to plan, code, test or review to the sub-agent.
12
12
 
13
13
  Waiting policy
14
- - Do not block right after starting or sending to a sub-agent. First start other
15
- independent sub-agents or do your own parallel work.
16
- - Block only when nothing else can proceed: session_read(after=<latest cursor>,
17
- wait_ms) or session_list(wait_ms). Both return on turn end, input or failure,
18
- so a generous wait costs nothing when work finishes early.
14
+ - session_list returns an immediate snapshot of all sessions; read it whenever you
15
+ need the collective state.
16
+ - session_read(after=<latest cursor>, wait_ms) waits for one member: it returns on
17
+ turn end, input, failure or close, so a generous wait costs nothing when work
18
+ finishes early.
19
+ - After starting or sending, first start other independent sub-agents or do your own
20
+ parallel work; block only when nothing else can proceed.
19
21
  - wait_ms is unlimited: try 60-120 s for research/coding and 20-40 s for a short
20
- follow-up. After a timeout, roughly double during early/mid-stage work; shorten
21
- to 20-30 s when history shows final checks, a report or a closing summary.
22
- - While tools continue without a wrap-up, lengthen the next wait (60 -> 120 ->
23
- 240 s), never merely because time passed. A board_write alone is not a wrap-up;
24
- shorten only for final checks, delivery or a closing summary.
25
- - Never poll in a tight loop and always pass the latest cursor. If your client
26
- times out a wait, simply call it again with the same cursor.
22
+ follow-up. After a timeout, roughly double during early/mid-stage work and shorten
23
+ to 20-30 s for final checks, a report or a closing summary.
24
+ - While tools continue without a wrap-up, lengthen the next wait (60 -> 120 -> 240 s).
25
+ A board_write alone signals a normal step; shorten the wait for a closing summary.
26
+ - Pass the latest cursor on every wait; after a client timeout, call again with the
27
+ same cursor.
27
28
 
28
29
  What you see
29
- - History omits thinking by default (counted in thinking_omitted). Avoid
30
- include_thinking for context minimization; track actions, boards and results.
30
+ - History omits thinking by default and counts it in thinking_omitted. include_thinking
31
+ opts in; thinking greatly enlarges the context, so prefer actions, boards and results.
31
32
  Usage includes reasoning tokens.
32
33
 
33
34
  Human-only blocks and retries
34
35
  - On NEEDS_HUMAN_AUTH, relay user_action and console_url to the user, then retry
35
- resume.operation with resume.arguments unchanged. Never ask for secrets.
36
+ resume.operation with resume.arguments unchanged. Credentials stay out of context;
37
+ never ask for secrets.
38
+ - Console address: read resource jaxon://console or service_status.console_url.
36
39
  - Write operations accept client_request_id; reuse it when retrying after
37
40
  DAEMON_RESTARTED. Reads can simply be retried.
38
41
 
39
42
  Stations
40
43
  - Run specialised agents inside a Station: find it with station_search and pass
41
- station=<id or name> to session_start. Running without a station works but is
42
- not recommended.
43
- - You and every member share the same Station description. When no member of a
44
- Station is active, your first call for that Station also returns the full
45
- description as station_context; read it before dispatching. Later calls do not
46
- repeat it; use station_get to read it again.
47
- - All sessions of one preset share its role board. Every turn injects the full
48
- master and own boards; read others with board_read. With peers open, merge the
49
- latest board before rewriting; a version conflict returns its current content.
50
- Put goals, constraints, acceptance criteria, the final plan and decisions on master
51
- before dispatching. Update boards at phase changes, key steps, blockers and wrap-up.
52
- Writes never alter a running turn; the next turn sees the latest boards. Dispatch
53
- short instructions pointing to boards instead of pasting plans or reports.
54
- - Use session_send to continue seat work; busy calls queue, and delivery=steer redirects.
55
- Use session_start(seat=none) for clean parallel work or seat=renew for stale context.
56
- Members use cue to remind peers to read boards, waking idle peers without interrupting
57
- busy turns. Write conclusions on boards first.
58
- - While several members are busy, wait with session_list(station=..., wait_ms)
59
- sized by the member expected to finish first.
60
- - A result carrying station_pending means a roster change is queued. It applies
61
- by itself once no member turn is in flight and every leaving member's session
62
- is closed. Stop dispatching new turns, let busy turns finish, answer or close
63
- the blocked_by sessions, then read station_context(reason=revised). Remove
64
- temporary members once the task is done.
65
- - You alone decide every next step; boards never trigger anything.`;
44
+ station=<id or name> to session_start. Prefer a Station over running without one.
45
+ - You and every member share the same Station description. When no member of a Station
46
+ is active, your first call for that Station also returns the full description as
47
+ station_context; read it before dispatching, and use station_get to read it again.
48
+ - All sessions of one preset share its role board. Every turn injects the full master
49
+ and own boards; read others with board_read and merge peers' latest content before
50
+ rewriting (a version conflict returns the current content). Put goals, constraints,
51
+ acceptance criteria, the final plan and decisions on master before dispatching, and
52
+ update boards at phase changes, key steps, blockers and wrap-up. Writes apply to the
53
+ next turn: dispatch short instructions that point to boards instead of pasting plans
54
+ or reports.
55
+ - Use session_send to continue a session; busy calls queue, and delivery=steer
56
+ redirects the current turn. Use session_start for a fresh, parallel context; a role
57
+ may hold several equal sessions that all share its board. Members use cue to remind
58
+ peers to read boards; it wakes an idle peer, and a cue chain stops waking after 5
59
+ hops. Write conclusions on boards first.
60
+ - While several members are busy, wait on the member expected to finish first with
61
+ session_read(after=<its cursor>, wait_ms).
62
+ - A result carrying station_pending means a roster change is queued. It applies by
63
+ itself once no member turn is in flight and every leaving member's session is closed.
64
+ Stop dispatching new turns, let busy turns finish, answer or close the blocked_by
65
+ sessions, then read station_context(reason=revised). Remove temporary members once the
66
+ task is done.
67
+ - You alone decide every next step; boards inform that decision.`;
66
68
  const ok = (data, images = []) => ({
67
69
  content: [{ type: "text", text: JSON.stringify(data, null, 2) }, ...images],
68
70
  structuredContent: data,
@@ -75,7 +77,7 @@ const err = (e) => {
75
77
  export function createMcpServer(ops, connectionSignal) {
76
78
  const server = new McpServer({ name: "jaxon-agents", version: APP_VERSION }, {
77
79
  instructions: SERVER_INSTRUCTIONS,
78
- capabilities: { tools: { listChanged: true } },
80
+ capabilities: { tools: { listChanged: true }, resources: { listChanged: true, subscribe: true } },
79
81
  });
80
82
  const tools = ops.publicOperationMetadata().map(({ name, description, schema }) => ({ name, description,
81
83
  inputSchema: z.toJSONSchema(operationSchema({ name, schema }), { target: "draft-07", io: "input" }),
@@ -107,5 +109,33 @@ export function createMcpServer(ops, connectionSignal) {
107
109
  return err(e);
108
110
  }
109
111
  });
112
+ // jaxon://console: the master's reference entry to the local console (PLAN §20.2.2).
113
+ // It carries no credentials; tools/list stays at 25 because a resource is not a tool.
114
+ const subscriptions = new Set();
115
+ const consoleInfo = () => consoleInfoFrom(ops.serviceInfo?.() ?? { console_url: ops.connections.consoleUrl });
116
+ server.registerResource("JaXon console", "jaxon://console", {
117
+ mimeType: "application/json",
118
+ description: "Local JaXon console address for reference: when human action is needed, relay the relevant page link to the user; do not push it repeatedly. The human entry point is `jaxon-agents console`.",
119
+ }, (uri) => ({ contents: [{ uri: uri.href, mimeType: "application/json", text: JSON.stringify(consoleInfo(), null, 2) }] }));
120
+ server.registerResource("JaXon console station", new ResourceTemplate("jaxon://console/stations/{station}", { list: undefined }), {
121
+ mimeType: "application/json",
122
+ description: "Same as jaxon://console, plus the full URL of one Station page.",
123
+ }, (uri, variables) => {
124
+ const info = consoleInfo();
125
+ const station = String(variables.station ?? "");
126
+ return { contents: [{ uri: uri.href, mimeType: "application/json",
127
+ text: JSON.stringify({ ...info, station, station_url: consoleUrl(info, "/stations/" + encodeURIComponent(station)) }, null, 2) }] };
128
+ });
129
+ server.server.setRequestHandler(SubscribeRequestSchema, async ({ params }) => { subscriptions.add(params.uri); return {}; });
130
+ server.server.setRequestHandler(UnsubscribeRequestSchema, async ({ params }) => { subscriptions.delete(params.uri); return {}; });
131
+ // A relay replay of notifications/initialized (daemon restart, possibly a new port) must
132
+ // refresh tools and resources, and re-notify anyone subscribed to the console resource.
133
+ server.server.oninitialized = () => {
134
+ const send = (action) => { void action.catch(() => { }); };
135
+ send(server.server.sendToolListChanged());
136
+ send(server.server.sendResourceListChanged());
137
+ for (const uri of subscriptions)
138
+ send(server.server.sendResourceUpdated({ uri }));
139
+ };
110
140
  return server;
111
141
  }
@@ -1,3 +1,4 @@
1
+ import { consoleIcon } from "./icons.js";
1
2
  export const ACTIVITY_JS = String.raw `
2
3
  function mountStationActivity() {
3
4
  const root = document.querySelector('[data-station-activity]');
@@ -6,7 +7,6 @@ function mountStationActivity() {
6
7
  const overview = root.hasAttribute('data-overview-activity');
7
8
  const find = selector => root.querySelector(selector);
8
9
  const stage = find('[data-activity-stage]'), scene = stage.parentElement;
9
- const nodesTarget = find('[data-activity-nodes]');
10
10
  const hub = find('.activity-hub'), lanes = [...root.querySelectorAll('.activity-lane')];
11
11
  const svg = find('[data-activity-edges]'), trails = find('[data-activity-trails]'), pulseLayer = find('[data-activity-pulses]');
12
12
  const status = find('[data-activity-status]'), empty = find('[data-activity-empty]'), title = find('[data-activity-title]');
@@ -17,7 +17,16 @@ function mountStationActivity() {
17
17
  let windowName = '10m', snapshot, cursor, clock = 0, offline = false, ghost, tooltipOwner;
18
18
  let generation = 0, controller, timer, lastStart = -Infinity, failures = 0, frame = 0, needsLayout = false, motionUntil = 0;
19
19
  const svgNode = name => document.createElementNS('http://www.w3.org/2000/svg', name);
20
- const label = (en, zh) => snapshot?.topic_language === 'zh-CN' ? zh : en;
20
+ const icons = {
21
+ spark: ${JSON.stringify(consoleIcon("spark"))},
22
+ settings: ${JSON.stringify(consoleIcon("settings"))},
23
+ cue: ${JSON.stringify(consoleIcon("cue"))},
24
+ };
25
+ const icon = name => {
26
+ const template = document.createElement('template');
27
+ template.innerHTML = icons[name];
28
+ return template.content.firstElementChild;
29
+ };
21
30
  const setText = (node, text) => { if (node.textContent !== text) node.textContent = text; };
22
31
  const dates = value => Date.parse(value) || 0;
23
32
  const edgeKey = edge => [edge.from, edge.to, edge.kind].join('\0');
@@ -73,8 +82,8 @@ function mountStationActivity() {
73
82
  function hideTooltip() { tooltip.hidden = true; tooltipOwner = undefined; }
74
83
  function locateTooltip() {
75
84
  if (!tooltipOwner) return;
76
- const box = tooltipOwner.link.getBoundingClientRect(), bounds = root.getBoundingClientRect();
77
- const clip = tooltipOwner.link.closest('.activity-sessions').getBoundingClientRect();
85
+ const box = tooltipOwner.trigger.getBoundingClientRect(), bounds = root.getBoundingClientRect();
86
+ const clip = tooltipOwner.trigger.closest('.activity-sessions').getBoundingClientRect();
78
87
  if (box.bottom < clip.top || box.top > clip.bottom) { hideTooltip(); return; }
79
88
  tooltip.style.left = Math.max(10, Math.min(box.left - bounds.left, bounds.width - tooltip.offsetWidth - 10)) + 'px';
80
89
  tooltip.style.top = Math.min(bounds.height - tooltip.offsetHeight - 8, box.bottom - bounds.top + 6) + 'px';
@@ -105,46 +114,52 @@ function mountStationActivity() {
105
114
  resize.observe(stage);
106
115
 
107
116
  function sessionState(session) {
108
- if (session.status === 'closed') return ['closed', label('Closed', '已关闭')];
109
- if (session.status === 'waiting_input') return ['waiting_input', label('Waiting for input', '等待输入')];
110
- if (running.has(session.status)) return ['running', label('Running', '运行中')];
111
- if (session.queued_turns > 0) return ['queued', label('Queued', '排队中')];
112
- if (session.status === 'failed') return ['failed', label('Failed', '失败')];
113
- return ['idle', label('Idle', '空闲')];
117
+ if (session.status === 'closed') return ['closed', 'Closed'];
118
+ if (session.status === 'waiting_input') return ['waiting_input', 'Waiting for input'];
119
+ if (running.has(session.status)) return ['running', 'Running'];
120
+ if (session.queued_turns > 0) return ['queued', 'Queued'];
121
+ if (session.status === 'failed') return ['failed', 'Failed'];
122
+ return ['idle', 'Idle'];
114
123
  }
115
124
  const cueLabels = {
116
- scheduled: ['Will be delivered on the next turn', '将在下一轮送达'], cooldown: ['Wake cooling down', '唤醒冷却中'],
117
- rate_limited: ['Wake limit reached', '已达唤醒上限'], deferred_cap: ['Wake deferred', '唤醒已延后'],
118
- hop_limit: ['No wake: relay limit', '转发上限:仅送达'], blocked: ['Wake blocked', '唤醒受阻'],
119
- not_runnable: ['Session cannot run', '会话暂不可运行'],
125
+ scheduled: 'Will be delivered on the next turn', cooldown: 'Wake cooling down',
126
+ rate_limited: 'Wake limit reached', deferred_cap: 'Wake deferred',
127
+ hop_limit: 'No wake: relay limit', blocked: 'Wake blocked',
128
+ not_runnable: 'Session cannot run',
120
129
  };
121
- const unread = count => count + label(' unread cues', ' 条待读提醒');
130
+ const unread = count => count + ' unread cues';
122
131
  function cueDescription(cue) {
123
132
  if (!cue?.count) return '';
124
133
  const state = cueLabels[cue.wake];
125
- return [unread(cue.count), cue.senders?.join(', '), state && label(...state)].filter(Boolean).join(' · ');
134
+ return [unread(cue.count), cue.senders?.join(', '), state].filter(Boolean).join(' · ');
126
135
  }
127
136
 
137
+ function setChatTarget(trigger, agent, session) {
138
+ trigger.href = '/sessions/' + encodeURIComponent(session.session_id);
139
+ trigger.dataset.jaxonChat = session.session_id;
140
+ trigger.dataset.jaxonChatAgent = agent;
141
+ }
128
142
  function sessionRow(session) {
129
143
  const badge = el('span', {className:'activity-state-dot', attrs:{'aria-hidden':'true'}});
130
144
  const track = el('span', {className:'activity-topic-track'});
131
145
  const viewport = el('span', {className:'activity-topic-viewport'}, [track]);
132
146
  const cueBadge = el('span', {className:'cue-badge activity-cue-count'}); cueBadge.hidden = true;
133
- const cueIcon = el('span', {className:'activity-cue-origin', text:'↯', attrs:{'aria-hidden':'true'}}); cueIcon.hidden = true;
134
- const link = el('a', {className:'activity-session', attrs:{'data-session-id':session.session_id,
135
- href:session.url, target:'_blank', rel:'noopener'}}, [badge, cueBadge, cueIcon, viewport]);
136
- const row = {link, badge, cueBadge, cueIcon, track, viewport};
137
- link.addEventListener('pointerenter', () => toggleTopic(row, true));
138
- link.addEventListener('pointerleave', () => toggleTopic(row, false));
139
- link.addEventListener('focus', () => toggleTopic(row, undefined, true));
140
- link.addEventListener('blur', () => toggleTopic(row, undefined, false));
147
+ const cueIcon = el('span', {className:'activity-cue-origin'}, [icon('cue')]); cueIcon.hidden = true;
148
+ const trigger = el('a', {className:'activity-session', attrs:{
149
+ 'data-session-id':session.session_id, 'aria-haspopup':'dialog'}}, [badge, cueBadge, cueIcon, viewport]);
150
+ const row = {trigger, badge, cueBadge, cueIcon, track, viewport};
151
+ trigger.addEventListener('pointerenter', () => toggleTopic(row, true));
152
+ trigger.addEventListener('pointerleave', () => toggleTopic(row, false));
153
+ trigger.addEventListener('focus', () => toggleTopic(row, undefined, true));
154
+ trigger.addEventListener('blur', () => toggleTopic(row, undefined, false));
155
+ trigger.addEventListener('click', () => { if (tooltipOwner === row) hideTooltip(); });
141
156
  watchTopics.set(viewport, row); resize.observe(viewport);
142
157
  return row;
143
158
  }
144
159
  function clearRow(row) {
145
160
  if (tooltipOwner === row) hideTooltip();
146
161
  resize.unobserve(row.viewport); watchTopics.delete(row.viewport);
147
- row.scroll?.cancel(); row.link.remove();
162
+ row.scroll?.cancel(); row.trigger.remove();
148
163
  }
149
164
  function updateRow(row, session, arriving = false) {
150
165
  row.latestSession = session;
@@ -158,30 +173,28 @@ function mountStationActivity() {
158
173
  return false;
159
174
  }
160
175
  const [state, name] = sessionState(session), topic = session.topic;
161
- const topicText = topic?.text || label('Session', '会话');
162
- const summary = topic?.state === 'generating' || topic?.stale ? label('Updating summary', '正在更新主题')
163
- : topic?.source === 'fallback' ? label('No model summary yet', '暂无模型主题') : '';
164
- row.link.dataset.state = row.badge.dataset.state = state;
165
- row.link.classList.toggle('closed', state === 'closed');
166
- row.link.classList.toggle('activity-fallback', topic?.source === 'fallback');
167
- row.link.dataset.topicSource = topic?.source ?? 'fallback';
176
+ const topicText = topic?.text || 'Session';
177
+ const summary = topic?.state === 'generating' || topic?.stale ? 'Updating summary'
178
+ : topic?.source === 'fallback' ? 'No model summary yet' : '';
179
+ row.trigger.dataset.state = row.badge.dataset.state = state;
180
+ row.trigger.classList.toggle('closed', state === 'closed');
181
+ row.trigger.classList.toggle('activity-fallback', topic?.source === 'fallback');
182
+ row.trigger.dataset.topicSource = topic?.source ?? 'fallback';
168
183
  row.cueCount = cue?.count ?? 0;
169
184
  row.cueOrigin = session.origin === 'cue';
170
185
  row.cueBadge.hidden = !row.cueCount;
171
186
  if (row.cueCount) setText(row.cueBadge, String(row.cueCount));
172
187
  row.cueIcon.hidden = !row.cueOrigin;
173
188
  const cueText = cueDescription(cue);
174
- const origin = row.cueOrigin ? label('Woken by a cue', '由同事提醒唤醒') : '';
189
+ const origin = row.cueOrigin ? 'Woken by a cue' : '';
175
190
  row.cueBadge.title = cueText; row.cueIcon.title = origin;
176
191
  if (arriving && rise) animate(row.cueBadge, [{transform:'scale(1.22)', color:'#fff'}, {transform:'scale(1)'}], {duration:340, easing:'ease-out'});
177
192
  row.description = [topicText, name, cueText, origin, summary, session.session_id].filter(Boolean).join(' · ');
178
- row.link.setAttribute('aria-label', [topicText, name, cueText, origin, label('opens in a new tab', '在新标签页打开')].filter(Boolean).join(' · '));
193
+ row.trigger.setAttribute('aria-label', ['Open chat', topicText, name, cueText, origin].filter(Boolean).join(' · '));
179
194
  if (row.text !== topicText) {
180
- const changed = row.text !== undefined;
181
195
  row.text = topicText;
182
196
  setText(row.track, topicText);
183
197
  row.distance = undefined;
184
- if (changed) fadeIn(row.track);
185
198
  }
186
199
  if (tooltipOwner === row) setText(tooltip, row.description);
187
200
  return true;
@@ -190,10 +203,10 @@ function mountStationActivity() {
190
203
  function createCard(node) {
191
204
  const master = node.kind === 'master';
192
205
  const light = el('div', {className:'activity-light', attrs:{'aria-hidden':'true'}});
193
- const badge = el('span', {className:'activity-emblem', attrs:{'aria-hidden':'true'}}, [el('span', {text:master ? '✦' : [...node.id][0]?.toUpperCase() ?? '•'})]);
194
- const name = el('span', {text:master ? label('Master', '主控') : node.id});
195
- const openSession = el('a', {text:node.id, attrs:{target:'_blank', rel:'noopener'}}); openSession.hidden = true;
196
- const heading = el('h3', {className:'activity-name'}, [name, openSession]);
206
+ const badge = el('span', {className:'activity-emblem', attrs:{'aria-hidden':'true'}},
207
+ [master ? icon('spark') : el('span', {text:[...node.id][0]?.toUpperCase() ?? ''})]);
208
+ const name = el('span', {text:master ? 'Master' : node.id});
209
+ const heading = el('h3', {className:'activity-name'}, [name]);
197
210
  const count = el('small', {className:'activity-count'});
198
211
  const identity = el('div', {className:'activity-identity'}, [heading, count]);
199
212
  const top = el('div', {className:'activity-node-head'}, [badge, identity]);
@@ -201,7 +214,11 @@ function mountStationActivity() {
201
214
  card.style.setProperty('--role-hue', String(master ? 42 : hueFor(node.id)));
202
215
  const rows = new Map();
203
216
  if (master) { hub.append(card); return {card, name, count, rows}; }
204
- const gear = el('a', {className:'activity-gear', text:'⚙', attrs:{href:node.url}});
217
+ const openSession = el('a', {className:'activity-name-chat', text:node.id,
218
+ attrs:{'aria-haspopup':'dialog'}});
219
+ openSession.hidden = true;
220
+ heading.append(openSession);
221
+ const gear = el('a', {className:'activity-gear', attrs:{href:node.url}}, [icon('settings')]);
205
222
  const cueCount = el('span', {className:'cue-badge'}); cueCount.hidden = true;
206
223
  top.append(cueCount, gear);
207
224
  const list = el('div', {className:'activity-sessions'});
@@ -231,17 +248,23 @@ function mountStationActivity() {
231
248
  function updateCard(view, node, first) {
232
249
  view.node = node;
233
250
  if (node.kind === 'master') {
234
- setText(view.name, label('Master', '主控'));
235
- setText(view.count, label('Station coordinator', 'Station 协调者'));
251
+ setText(view.name, 'Master');
252
+ setText(view.count, 'Station coordinator');
236
253
  return;
237
254
  }
238
255
  view.card.classList.toggle('former', !node.in_roster);
239
- const count = node.active_sessions + label(' active', ' 活跃') + ' / ' + node.window_sessions + label(' in window', ' 个窗口内会话');
240
- setText(view.count, count + (node.in_roster ? '' : label(' · former', ' · 已退出')));
256
+ const count = node.active_sessions + ' active' + ' / ' + node.window_sessions + ' in window';
257
+ setText(view.count, count + (node.in_roster ? '' : ' · former'));
241
258
  const single = node.window_sessions === 1 && node.sessions.length === 1;
242
259
  view.openSession.hidden = !single; view.name.hidden = single;
243
- if (single) view.openSession.href = node.sessions[0].url;
244
- view.gear.title = label('Open agent settings', '打开角色设置');
260
+ if (single) {
261
+ setChatTarget(view.openSession, node.id, node.sessions[0]);
262
+ view.openSession.setAttribute('aria-label', 'Open chat with ' + node.id);
263
+ } else {
264
+ delete view.openSession.dataset.jaxonChat;
265
+ view.openSession.removeAttribute('href');
266
+ }
267
+ view.gear.title = 'Open agent settings';
245
268
  view.gear.setAttribute('aria-label', view.gear.title + ': ' + node.id);
246
269
  view.cueCount.hidden = !node.pending_cues;
247
270
  if (node.pending_cues) {
@@ -251,23 +274,24 @@ function mountStationActivity() {
251
274
  fitSessions(view, () => {
252
275
  const truncated = node.window_sessions - node.sessions.length;
253
276
  view.more.hidden = truncated <= 0;
254
- if (truncated > 0) setText(view.more, label('View all sessions →', '查看全部会话 →'));
277
+ if (truncated > 0) setText(view.more, 'View all sessions →');
255
278
  const ids = new Set(node.sessions.map(session => session.session_id));
256
279
  for (const [id, row] of view.rows) {
257
280
  if (!ids.has(id)) {
258
281
  const clear = () => { clearRow(row); view.rows.delete(id); };
259
282
  if (motion.matches) clear();
260
- else leave(row.link, () => fitSessions(view, clear));
283
+ else leave(row.trigger, () => fitSessions(view, clear));
261
284
  }
262
285
  }
263
286
  for (const session of node.sessions) {
264
287
  let row = view.rows.get(session.session_id);
265
288
  const fresh = !row;
266
289
  if (fresh) { row = sessionRow(session); view.rows.set(session.session_id, row); }
267
- revive(row.link);
290
+ revive(row.trigger);
291
+ setChatTarget(row.trigger, node.id, session);
268
292
  if (!updateRow(row, session)) cueArrivals.get(session.session_id).view = view;
269
293
  // Keep the relative order of existing rows; scrolling and focus stay in place.
270
- if (fresh) { view.stack.insertBefore(row.link, view.more); fadeIn(row.link); measureTopic(row); }
294
+ if (fresh) { view.stack.insertBefore(row.trigger, view.more); fadeIn(row.trigger); measureTopic(row); }
271
295
  else if (row.distance === undefined) measureTopic(row);
272
296
  }
273
297
  }, first);
@@ -297,7 +321,7 @@ function mountStationActivity() {
297
321
  return transform === 'none' ? 0 : new DOMMatrixReadOnly(transform).m42;
298
322
  }
299
323
  function disposeCard(view) {
300
- for (const row of view.rows.values()) { departures.get(row.link)?.animation.cancel(); departures.delete(row.link); clearRow(row); }
324
+ for (const row of view.rows.values()) { departures.get(row.trigger)?.animation.cancel(); departures.delete(row.trigger); clearRow(row); }
301
325
  view.listMotion?.animation.cancel();
302
326
  moves.get(view.card)?.cancel(); moves.delete(view.card);
303
327
  view.card.remove(); cards.delete(view.node.id);
@@ -364,7 +388,7 @@ function mountStationActivity() {
364
388
  if (!arrival || cueArrivals.get(arrival.sessionId) !== arrival) return;
365
389
  cueArrivals.delete(arrival.sessionId);
366
390
  const { row, view } = arrival;
367
- if (row?.link.isConnected) {
391
+ if (row?.trigger.isConnected) {
368
392
  updateRow(row, row.latestSession, highlight);
369
393
  if (row.distance === undefined) measureTopic(row);
370
394
  }
@@ -496,9 +520,9 @@ function mountStationActivity() {
496
520
  }
497
521
  function updateStatus() {
498
522
  const batch = snapshot?.topics_batch;
499
- setText(status, offline ? label('Offline · retrying', '离线 · 正在重试') : batch?.pending
500
- ? label('Updating topics', '正在更新主题') + ' · ' + batch.pending : batch?.state === 'off'
501
- ? label('Topics off', '主题已关闭') : '');
523
+ setText(status, offline ? 'Offline · retrying' : batch?.pending
524
+ ? 'Updating topics' + ' · ' + batch.pending : batch?.state === 'off'
525
+ ? 'Topics off' : '');
502
526
  root.classList.toggle('activity-offline', offline);
503
527
  }
504
528
  function render(previous, effects) {
@@ -510,10 +534,10 @@ function mountStationActivity() {
510
534
  }
511
535
  stage.hidden = !snapshot.nodes.length;
512
536
  empty.hidden = false;
513
- if (!snapshot.nodes.length) empty.replaceChildren(label('No Stations yet. ', '还没有 Station。'),
514
- el('a', {text:label('Create a Station →', '新建 Station →'), attrs:{href:'/stations?view=new'}}));
537
+ if (!snapshot.nodes.length) empty.replaceChildren('No Stations yet. ',
538
+ el('a', {text:'Create a Station →', attrs:{href:'/stations?view=new'}}));
515
539
  else if (!snapshot.edges.length && !snapshot.nodes.some(node => node.window_sessions)) {
516
- setText(empty, label('No activity in this window.', '该窗口内没有活动。'));
540
+ setText(empty, 'No activity in this window.');
517
541
  } else empty.hidden = true;
518
542
  if (effects && !motion.matches) {
519
543
  const prior = new Map(previous.edges.map(edge => [edgeKey(edge), edge]));
@@ -577,7 +601,7 @@ function mountStationActivity() {
577
601
  offline = true; updateStatus();
578
602
  if (!snapshot) {
579
603
  empty.hidden = false;
580
- setText(empty, label('Activity is temporarily unavailable.', '活动图暂时不可用。'));
604
+ setText(empty, 'Activity is temporarily unavailable.');
581
605
  }
582
606
  queue([5000, 15000, 60000][Math.min(2, failures++)]);
583
607
  }