@agentproto/apps 0.10.0 → 0.12.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 (44) hide show
  1. package/dist/agents-overview/panel.mjs +43 -1
  2. package/dist/agents-overview/panel.mjs.map +1 -1
  3. package/dist/agents-overview.mjs +43 -1
  4. package/dist/agents-overview.mjs.map +1 -1
  5. package/dist/bureau-sessions/panel.mjs +43 -1
  6. package/dist/bureau-sessions/panel.mjs.map +1 -1
  7. package/dist/bureau-sessions.mjs +43 -1
  8. package/dist/bureau-sessions.mjs.map +1 -1
  9. package/dist/index.mjs +1116 -300
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/live-session/panel.mjs +43 -1
  12. package/dist/live-session/panel.mjs.map +1 -1
  13. package/dist/live-session.mjs +43 -1
  14. package/dist/live-session.mjs.map +1 -1
  15. package/dist/panel-bridge.d.ts +48 -0
  16. package/dist/panel-bridge.d.ts.map +1 -1
  17. package/dist/session-chat/blob-embed.d.ts +53 -0
  18. package/dist/session-chat/blob-embed.d.ts.map +1 -0
  19. package/dist/session-chat/index.d.ts +13 -0
  20. package/dist/session-chat/index.d.ts.map +1 -1
  21. package/dist/session-chat/panel.d.ts +38 -2
  22. package/dist/session-chat/panel.d.ts.map +1 -1
  23. package/dist/session-chat/panel.mjs +609 -6
  24. package/dist/session-chat/panel.mjs.map +1 -1
  25. package/dist/session-chat.mjs +631 -13
  26. package/dist/session-chat.mjs.map +1 -1
  27. package/dist/session-story/panel.mjs +43 -1
  28. package/dist/session-story/panel.mjs.map +1 -1
  29. package/dist/session-story.mjs +43 -1
  30. package/dist/session-story.mjs.map +1 -1
  31. package/dist/sessions-panel/panel.mjs +43 -1
  32. package/dist/sessions-panel/panel.mjs.map +1 -1
  33. package/dist/sessions-panel.mjs +43 -1
  34. package/dist/sessions-panel.mjs.map +1 -1
  35. package/dist/work-board/index.d.ts.map +1 -1
  36. package/dist/work-board/panel.d.ts +39 -6
  37. package/dist/work-board/panel.d.ts.map +1 -1
  38. package/dist/work-board/panel.generated.d.ts +13 -0
  39. package/dist/work-board/panel.generated.d.ts.map +1 -0
  40. package/dist/work-board/panel.mjs +494 -296
  41. package/dist/work-board/panel.mjs.map +1 -1
  42. package/dist/work-board.mjs +496 -298
  43. package/dist/work-board.mjs.map +1 -1
  44. package/package.json +12 -8
@@ -7,14 +7,44 @@ import { defineApp } from '@agentproto/app-kit';
7
7
  */
8
8
 
9
9
 
10
- // src/panel-bridge.ts
11
- function panelBridgeScript(appName) {
12
- return `// \u2500\u2500 MCP Apps bridge (shared: panel-bridge.ts) \u2500\u2500
10
+ // src/work-board/panel.generated.ts
11
+ var WORK_BOARD_HTML_GENERATED = `<!DOCTYPE html>
12
+ <html lang="en">
13
+ <head>
14
+ <meta charset="UTF-8" />
15
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
16
+ <title>agentproto work board</title>
17
+ <!-- PANEL_BRIDGE: replaced with the inline panelBridgeScript() output by
18
+ vite.config.ts's injectPanelBridge plugin \u2014 a classic (non-module)
19
+ script so its \`initBridge\`/\`callTool\` land as globals before the
20
+ deferred module script below runs. -->
21
+ <script>// \u2500\u2500 MCP Apps bridge (shared: panel-bridge.ts) \u2500\u2500
13
22
  // JSON-RPC 2.0 over window.parent.postMessage \xB7 spec 2026-01-26
14
23
  var _nextId = 1, _pending = {}, _notifyHandlers = [];
15
24
  var _hostContext = null, _hostContextHandlers = [];
25
+ var _hostCaps = null;
26
+ var _standaloneApp = null;
27
+ function _isStandalone(){
28
+ return window.parent === window && !!window.McpApp && typeof window.McpApp.connect === 'function';
29
+ }
30
+ // \u2500\u2500 Per-boot embed token (runtime embed-tokens.ts) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
31
+ // Panels that iframe the daemon's standalone app host carry this proof so
32
+ // GET /apps/:appId/ui?embed=1&et=... can drop its anti-framing headers for
33
+ // MCP-Apps hosts whose widget context is an opaque origin (Claude Desktop).
34
+ // registerMcpApps replaces the placeholder with a real per-boot token when
35
+ // serving the panel as a resource; every other render (tests, standalone
36
+ // tab, VS Code HTTP-iframe panel \u2014 the latter two already pass
37
+ // iframeEmbedAllowed's origin checks) keeps the literal, and
38
+ // withEmbedToken() then degrades to an identity function.
39
+ window.__AGENPROTO_EMBED_TOKEN__ = "__AGENPROTO_EMBED_TOKEN__";
40
+ function withEmbedToken(url){
41
+ var t = window.__AGENPROTO_EMBED_TOKEN__;
42
+ if (!t || t === '__AGENPROTO_EMBED_TOKEN__') return url;
43
+ return url + (url.indexOf('?') >= 0 ? '&' : '?') + 'et=' + encodeURIComponent(t);
44
+ }
16
45
  function post(msg){ window.parent.postMessage(msg, '*'); }
17
46
  function getHostContext(){ return _hostContext; }
47
+ function getHostCapabilities(){ return _hostCaps; }
18
48
  function onHostContext(cb){
19
49
  _hostContextHandlers.push(cb);
20
50
  // Replay the last context so a late subscriber isn't stuck blind.
@@ -59,22 +89,43 @@ window.addEventListener('message', function(evt){
59
89
  }
60
90
  });
61
91
  function initBridge(){
92
+ if (_isStandalone()){
93
+ return window.McpApp.connect().then(function(conn){
94
+ _standaloneApp = conn;
95
+ // No host to advertise a hostContext \u2014 default to inline with no
96
+ // other modes available, which keeps the #dm/#pin toggle buttons
97
+ // hidden (they only show for modes hostContext.availableDisplayModes
98
+ // lists) instead of rendering two buttons with nothing to switch to.
99
+ _setHostContext({displayMode: 'inline', availableDisplayModes: []});
100
+ });
101
+ }
62
102
  return rpcRequest('ui/initialize', {
63
- appInfo: {name: ${JSON.stringify(appName)}, version: '0.1.0'},
103
+ appInfo: {name: "agentproto-work-board-panel", version: '0.1.0'},
64
104
  appCapabilities: {availableDisplayModes: ['inline', 'fullscreen', 'pip']},
65
105
  protocolVersion: '2026-01-26'
66
106
  }).then(function(result){
67
107
  // The initialize result carries the initial hostContext (displayMode +
68
108
  // availableDisplayModes) \u2014 capture it before notifying the host.
69
109
  if (result && result.hostContext) _setHostContext(result.hostContext);
110
+ // McpUiInitializeResult.hostCapabilities (ext-apps spec) \u2014 e.g. openLinks,
111
+ // "Host supports opening external URLs". Captured once, read via
112
+ // getHostCapabilities() by panels that need to branch on it.
113
+ if (result && result.hostCapabilities) _hostCaps = result.hostCapabilities;
70
114
  rpcNotify('ui/notifications/initialized', {});
71
115
  });
72
116
  }
73
117
  function requestDisplayMode(mode){
74
118
  return rpcRequest('ui/request-display-mode', {mode: mode});
75
119
  }
120
+ function openLink(url){
121
+ if (_standaloneApp && typeof _standaloneApp.openLink === 'function') return _standaloneApp.openLink(url);
122
+ return rpcRequest('ui/open-link', {url: url});
123
+ }
76
124
  function callTool(name, args){
77
- return rpcRequest('tools/call', {name: name, arguments: args || {}}).then(function(result){
125
+ var raw = _standaloneApp
126
+ ? _standaloneApp.callTool(name, args || {})
127
+ : rpcRequest('tools/call', {name: name, arguments: args || {}});
128
+ return raw.then(function(result){
78
129
  if (result.isError){
79
130
  var e = (result.content && result.content[0] && result.content[0].text) || 'tool error';
80
131
  throw new Error(e);
@@ -148,320 +199,467 @@ function callTool(name, args){
148
199
  }
149
200
  if (document.body) mount();
150
201
  else document.addEventListener('DOMContentLoaded', mount);
151
- })();`;
152
- }
153
-
154
- // src/work-board/panel.ts
155
- var WORK_BOARD_HTML = `<!DOCTYPE html>
156
- <html lang="en">
157
- <head>
158
- <meta charset="UTF-8">
159
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
160
- <title>agentproto work board</title>
161
- <style>
162
- *{box-sizing:border-box;margin:0;padding:0}
163
- :root{
164
- --bg:#0d1117;--bg2:#161b22;--bg3:#21262d;--border:#30363d;
165
- --text:#e6edf3;--text2:#8b949e;
166
- --green:#3fb950;--yellow:#d29922;--red:#f85149;--blue:#58a6ff;--purple:#bc8cff;
167
- }
168
- html,body{height:100%;font-family:Menlo,Monaco,'Courier New',monospace;font-size:13px;background:var(--bg);color:var(--text);overflow:hidden}
169
- #app{display:flex;flex-direction:column;height:100%}
170
- #toolbar{padding:8px 12px;border-bottom:1px solid var(--border);display:flex;align-items:center;gap:8px;background:var(--bg2);flex-shrink:0}
171
- #board-label{font-size:11px;color:var(--text2)}
172
- #board-id{font-weight:600;color:var(--text);font-size:12px}
173
- #board-input{background:var(--bg3);border:1px solid var(--border);color:var(--text);padding:4px 8px;border-radius:4px;font-size:12px;font-family:inherit;width:220px}
174
- .tbtn{background:var(--bg3);border:1px solid var(--border);color:var(--text);padding:4px 10px;border-radius:4px;cursor:pointer;font-size:12px;font-family:inherit}
175
- .tbtn:hover{background:var(--border)}
176
- #new-title{flex:1;min-width:120px;background:var(--bg3);border:1px solid var(--border);color:var(--text);padding:4px 8px;border-radius:4px;font-size:12px;font-family:inherit}
177
- #columns{flex:1;display:flex;overflow-x:auto;overflow-y:hidden}
178
- .col{width:260px;min-width:220px;flex-shrink:0;display:flex;flex-direction:column;border-right:1px solid var(--border)}
179
- .col-hdr{padding:8px 10px;border-bottom:1px solid var(--border);background:var(--bg2);font-size:11px;font-weight:600;color:var(--text2);text-transform:uppercase;letter-spacing:.05em;display:flex;justify-content:space-between}
180
- .col-body{flex:1;overflow-y:auto;padding:8px;display:flex;flex-direction:column;gap:8px}
181
- .card{background:var(--bg2);border:1px solid var(--border);border-radius:6px;padding:8px 10px}
182
- .c-title{font-size:12px;font-weight:500;margin-bottom:4px;word-break:break-word}
183
- .c-id{font-size:10px;color:var(--text2);margin-bottom:6px}
184
- .c-row{display:flex;flex-wrap:wrap;gap:4px;align-items:center;margin-bottom:6px}
185
- .tag{display:inline-block;padding:1px 6px;border-radius:10px;font-size:10px;font-weight:600;white-space:nowrap}
186
- .t-unclaimed{background:rgba(139,148,158,.15);color:var(--text2);border:1px dashed var(--text2)}
187
- .t-owner{background:rgba(88,166,255,.15);color:var(--blue)}
188
- .t-gate{background:rgba(63,185,80,.18);color:var(--green)}
189
- .t-self{background:rgba(210,153,34,.18);color:var(--yellow)}
190
- .t-human{background:rgba(88,166,255,.18);color:var(--blue)}
191
- .t-gated{background:rgba(139,148,158,.12);color:var(--text2)}
192
- .t-cancelled{background:rgba(139,148,158,.12);color:var(--text2)}
193
- .c-err{font-size:10px;color:var(--red);margin-bottom:6px;word-break:break-word}
194
- .c-actions{display:flex;flex-wrap:wrap;gap:4px}
195
- .abtn{background:var(--bg3);border:1px solid var(--border);color:var(--text);padding:3px 8px;border-radius:4px;cursor:pointer;font-size:11px;font-family:inherit}
196
- .abtn:hover{background:var(--border)}
197
- .abtn.danger{border-color:var(--red);color:var(--red)}
198
- .abtn.primary{border-color:var(--green);color:var(--green)}
199
- #statusbar{padding:4px 12px;font-size:11px;color:var(--text2);border-top:1px solid var(--border);background:var(--bg2);flex-shrink:0}
200
- .empty{padding:16px 8px;color:var(--text2);font-size:11px;text-align:center}
201
- </style>
202
- </head>
203
- <body>
204
- <div id="app">
205
- <div id="toolbar">
206
- <span id="board-label">Board:</span>
207
- <span id="board-id">\u2014</span>
208
- <input id="board-input" type="text" placeholder="tree:&lt;sessionId&gt; or ws:&lt;slug&gt;">
209
- <button class="tbtn" id="go-btn">Go</button>
210
- <button class="tbtn" id="refresh-btn" title="Refresh">&#8635;</button>
211
- <input id="new-title" type="text" placeholder="New task title&#8230;">
212
- <button class="tbtn" id="add-btn">+ Add</button>
213
- </div>
214
- <div id="columns"></div>
215
- <div id="statusbar">Connecting to bridge&#8230;</div>
216
- </div>
217
- <script>
218
- ${panelBridgeScript("agentproto-work-board-panel")}
219
-
220
- // ============================================================
221
- // State
222
- // ============================================================
223
-
224
- var COLUMNS = [
225
- {key: 'pending', label: 'Pending'},
226
- {key: 'in_progress', label: 'In Progress'},
227
- {key: 'done', label: 'Done'},
228
- {key: 'failed', label: 'Failed'}
229
- ];
230
-
231
- var boardId = null;
232
- var tasks = [];
233
- var pollTimer = null;
234
- var pollActive = false;
235
-
236
- function setStatus(msg) {
237
- document.getElementById('statusbar').textContent = msg;
238
- }
239
-
240
- function esc(s) {
241
- return String(s == null ? '' : s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
242
- }
243
-
244
- // A cancelled task folds into the Failed column, tagged distinctly \u2014 v1
245
- // treats both as terminal scrap, and a fifth column for a rarely-used
246
- // status isn't worth the width.
247
- function columnOf(status) {
248
- if (status === 'cancelled') return 'failed';
249
- return status;
250
- }
251
-
252
- // ============================================================
253
- // Verification tell \u2014 never render an unverified done as gate-passed.
254
- // ============================================================
255
-
256
- function verificationTag(t) {
257
- var v = t.verification;
258
- if (v) {
259
- if (v.kind === 'gate') return '<span class="tag t-gate">&#10003; gate</span>';
260
- if (v.kind === 'self-report') return '<span class="tag t-self">self-report</span>';
261
- if (v.kind === 'human') return '<span class="tag t-human">human</span>';
202
+ })();</script>
203
+ <script>(function() {
204
+ "use strict";
205
+ const COLUMN_STATUSES = ["pending", "in_progress", "done", "failed"];
206
+ const COLUMN_LABELS = {
207
+ pending: "Pending",
208
+ in_progress: "In Progress",
209
+ done: "Done",
210
+ failed: "Failed"
211
+ };
212
+ function esc(value) {
213
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
262
214
  }
263
- if (t.status === 'in_progress' && t.verify) {
264
- return '<span class="tag t-gated">gated</span>';
215
+ function columnOf(status) {
216
+ return status === "cancelled" ? "failed" : status;
265
217
  }
266
- return '';
267
- }
268
-
269
- function ownerTag(t) {
270
- if (!t.owner) return '<span class="tag t-unclaimed">Unclaimed</span>';
271
- return '<span class="tag t-owner">' + esc(t.owner) + '</span>';
272
- }
273
-
274
- // ============================================================
275
- // Card actions \u2014 explicit status moves, no drag-and-drop (read-only-safe
276
- // first: see module docblock).
277
- // ============================================================
278
-
279
- function actionsFor(t) {
280
- var a = [];
281
- if (t.status === 'pending') {
282
- if (!t.owner) a.push({label: 'Claim', action: 'claim', cls: 'primary'});
283
- else a.push({label: 'Start', action: 'start', cls: 'primary'});
284
- a.push({label: 'Cancel', action: 'cancel', cls: 'danger'});
285
- } else if (t.status === 'in_progress') {
286
- a.push({label: 'Done', action: 'done', cls: 'primary'});
287
- a.push({label: 'Fail', action: 'fail', cls: 'danger'});
288
- a.push({label: 'Release', action: 'release', cls: ''});
289
- a.push({label: 'Cancel', action: 'cancel', cls: 'danger'});
290
- } else if (t.status === 'done') {
291
- a.push({label: 'Reopen', action: 'reopen', cls: ''});
218
+ function verificationTag(task) {
219
+ const v = task.verification;
220
+ if (v) {
221
+ if (v.kind === "gate") return '<span class="tag t-gate">&#10003; gate</span>';
222
+ if (v.kind === "self-report") return '<span class="tag t-self">self-report</span>';
223
+ if (v.kind === "human") return '<span class="tag t-human">human</span>';
224
+ }
225
+ if (task.status === "in_progress" && task.verify) {
226
+ return '<span class="tag t-gated">gated</span>';
227
+ }
228
+ return "";
292
229
  }
293
- return a;
294
- }
295
-
296
- function applyAction(taskId, action) {
297
- var t = null;
298
- for (var i = 0; i < tasks.length; i++) {
299
- if (tasks[i].taskId === taskId) { t = tasks[i]; break; }
230
+ function ownerTag(task) {
231
+ if (!task.owner) return '<span class="tag t-unclaimed">Unclaimed</span>';
232
+ return \`<span class="tag t-owner">\${esc(task.owner)}</span>\`;
300
233
  }
301
- if (!t) return;
302
- var p;
303
- if (action === 'claim') {
304
- p = callTool('task_claim', {taskId: t.taskId, rev: t.rev});
305
- } else if (action === 'start') {
306
- p = callTool('task_update', {taskId: t.taskId, rev: t.rev, status: 'in_progress'});
307
- } else if (action === 'done') {
308
- p = callTool('task_update', {taskId: t.taskId, rev: t.rev, status: 'done'});
309
- } else if (action === 'fail') {
310
- p = callTool('task_update', {taskId: t.taskId, rev: t.rev, status: 'failed'});
311
- } else if (action === 'release') {
312
- p = callTool('task_update', {taskId: t.taskId, rev: t.rev, owner: null});
313
- } else if (action === 'cancel') {
314
- p = callTool('task_update', {taskId: t.taskId, rev: t.rev, status: 'cancelled'});
315
- } else if (action === 'reopen') {
316
- p = callTool('task_update', {taskId: t.taskId, rev: t.rev, status: 'pending'});
317
- } else {
318
- return;
234
+ function actionsFor(task) {
235
+ if (task.status === "pending") {
236
+ return [
237
+ task.owner ? { label: "Start", action: "start", cls: "primary" } : { label: "Claim", action: "claim", cls: "primary" },
238
+ { label: "Cancel", action: "cancel", cls: "danger" }
239
+ ];
240
+ }
241
+ if (task.status === "in_progress") {
242
+ return [
243
+ { label: "Done", action: "done", cls: "primary" },
244
+ { label: "Fail", action: "fail", cls: "danger" },
245
+ { label: "Release", action: "release", cls: "" },
246
+ { label: "Cancel", action: "cancel", cls: "danger" }
247
+ ];
248
+ }
249
+ if (task.status === "done") {
250
+ return [{ label: "Reopen", action: "reopen", cls: "" }];
251
+ }
252
+ return [];
319
253
  }
320
- p.then(function (result) {
321
- if (result && result.conflict) {
322
- setStatus('Someone else moved "' + t.title + '" first \u2014 refreshed.');
323
- } else if (result && result.error) {
324
- setStatus('Action failed: ' + result.error);
325
- } else {
326
- setStatus('Updated "' + t.title + '".');
254
+ function renderCard(task) {
255
+ let html = \`<div class="card" data-taskid="\${esc(task.taskId)}">\`;
256
+ html += \`<div class="c-title">\${esc(task.title)}</div>\`;
257
+ html += \`<div class="c-id">#\${esc(task.taskId)}</div>\`;
258
+ html += \`<div class="c-row">\${ownerTag(task)}\${verificationTag(task)}\`;
259
+ if (task.status === "cancelled") html += '<span class="tag t-cancelled">cancelled</span>';
260
+ html += "</div>";
261
+ if (task.lastVerifyError) {
262
+ html += \`<div class="c-err">verify failed: \${esc(task.lastVerifyError)}</div>\`;
327
263
  }
328
- return loadBoard();
329
- }).catch(function (e) {
330
- setStatus('Action failed: ' + e.message);
331
- });
332
- }
333
-
334
- // ============================================================
335
- // Render
336
- // ============================================================
337
-
338
- function renderCard(t) {
339
- var html = '<div class="card" data-taskid="' + esc(t.taskId) + '">';
340
- html += '<div class="c-title">' + esc(t.title) + '</div>';
341
- html += '<div class="c-id">#' + esc(t.taskId) + '</div>';
342
- html += '<div class="c-row">' + ownerTag(t) + verificationTag(t);
343
- if (t.status === 'cancelled') html += '<span class="tag t-cancelled">cancelled</span>';
344
- html += '</div>';
345
- if (t.lastVerifyError) {
346
- html += '<div class="c-err">verify failed: ' + esc(t.lastVerifyError) + '</div>';
264
+ const actions = actionsFor(task);
265
+ if (actions.length > 0) {
266
+ html += '<div class="c-actions">';
267
+ for (const a of actions) {
268
+ html += \`<button class="abtn \${a.cls}" data-taskid="\${esc(task.taskId)}" data-action="\${a.action}">\${a.label}</button>\`;
269
+ }
270
+ html += "</div>";
271
+ }
272
+ html += "</div>";
273
+ return html;
347
274
  }
348
- var actions = actionsFor(t);
349
- if (actions.length > 0) {
350
- html += '<div class="c-actions">';
351
- for (var i = 0; i < actions.length; i++) {
352
- var a = actions[i];
353
- html += '<button class="abtn ' + a.cls + '" data-taskid="' + esc(t.taskId) + '" data-action="' + a.action + '">' + a.label + '</button>';
275
+ function renderColumns(tasks2) {
276
+ let html = "";
277
+ for (const status of COLUMN_STATUSES) {
278
+ const rows = tasks2.filter((t) => columnOf(t.status) === status);
279
+ html += \`<div class="col"><div class="col-hdr"><span>\${COLUMN_LABELS[status]}</span><span>\${rows.length}</span></div><div class="col-body">\`;
280
+ html += rows.length === 0 ? '<div class="empty">No tasks</div>' : rows.map(renderCard).join("");
281
+ html += "</div></div>";
354
282
  }
355
- html += '</div>';
283
+ return html;
356
284
  }
357
- html += '</div>';
358
- return html;
359
- }
360
-
361
- function render() {
362
- document.getElementById('board-id').textContent = boardId || '\u2014';
363
- if (!document.getElementById('board-input').value) {
364
- document.getElementById('board-input').value = boardId || '';
285
+ function getEl(id) {
286
+ const el = document.getElementById(id);
287
+ if (!el) throw new Error(\`work board: missing #\${id}\`);
288
+ return el;
289
+ }
290
+ function getInput(id) {
291
+ const el = document.getElementById(id);
292
+ if (!(el instanceof HTMLInputElement)) throw new Error(\`work board: missing input #\${id}\`);
293
+ return el;
294
+ }
295
+ function isCardAction(value) {
296
+ switch (value) {
297
+ case "claim":
298
+ case "start":
299
+ case "done":
300
+ case "fail":
301
+ case "release":
302
+ case "cancel":
303
+ case "reopen":
304
+ return true;
305
+ default:
306
+ return false;
307
+ }
365
308
  }
366
- var el = document.getElementById('columns');
367
- var html = '';
368
- for (var c = 0; c < COLUMNS.length; c++) {
369
- var col = COLUMNS[c];
370
- var rows = tasks.filter(function (t) { return columnOf(t.status) === col.key; });
371
- html += '<div class="col"><div class="col-hdr"><span>' + col.label + '</span><span>' + rows.length + '</span></div><div class="col-body">';
372
- if (rows.length === 0) {
373
- html += '<div class="empty">No tasks</div>';
374
- } else {
375
- for (var i = 0; i < rows.length; i++) html += renderCard(rows[i]);
309
+ let boardId = null;
310
+ let tasks = [];
311
+ let pollActive = false;
312
+ function boot() {
313
+ const columnsEl = getEl("columns");
314
+ const statusbarEl = getEl("statusbar");
315
+ const boardIdEl = getEl("board-id");
316
+ const boardInputEl = getInput("board-input");
317
+ const newTitleEl = getInput("new-title");
318
+ function setStatus(msg) {
319
+ statusbarEl.textContent = msg;
320
+ }
321
+ function render() {
322
+ boardIdEl.textContent = boardId ?? "\u2014";
323
+ if (!boardInputEl.value) boardInputEl.value = boardId ?? "";
324
+ columnsEl.innerHTML = renderColumns(tasks);
325
+ }
326
+ function findTask(taskId) {
327
+ return tasks.find((t) => t.taskId === taskId);
328
+ }
329
+ function loadBoard() {
330
+ const args = {
331
+ includeClosed: true,
332
+ full: true,
333
+ ...boardId ? { boardId } : {}
334
+ };
335
+ return callTool("task_list", args).then((data) => {
336
+ boardId = data.boardId ?? boardId;
337
+ tasks = data.tasks ?? [];
338
+ render();
339
+ setStatus(\`\${tasks.length} task\${tasks.length === 1 ? "" : "s"} \xB7 \${(/* @__PURE__ */ new Date()).toLocaleTimeString()}\`);
340
+ }).catch((e) => {
341
+ setStatus(\`Error: \${e.message}\`);
342
+ });
343
+ }
344
+ function applyAction(taskId, action) {
345
+ const task = findTask(taskId);
346
+ if (!task) return;
347
+ const base = { taskId: task.taskId, rev: task.rev };
348
+ let promise;
349
+ if (action === "claim") {
350
+ promise = callTool("task_claim", base);
351
+ } else if (action === "start") {
352
+ promise = callTool("task_update", { ...base, status: "in_progress" });
353
+ } else if (action === "done") {
354
+ promise = callTool("task_update", { ...base, status: "done" });
355
+ } else if (action === "fail") {
356
+ promise = callTool("task_update", { ...base, status: "failed" });
357
+ } else if (action === "release") {
358
+ promise = callTool("task_update", { ...base, owner: null });
359
+ } else if (action === "cancel") {
360
+ promise = callTool("task_update", { ...base, status: "cancelled" });
361
+ } else {
362
+ promise = callTool("task_update", { ...base, status: "pending" });
363
+ }
364
+ promise.then((result) => {
365
+ if ("conflict" in result) {
366
+ setStatus(\`Someone else moved "\${task.title}" first \u2014 refreshed.\`);
367
+ } else if ("error" in result) {
368
+ setStatus(\`Action failed: \${result.error}\`);
369
+ } else {
370
+ setStatus(\`Updated "\${task.title}".\`);
371
+ }
372
+ return loadBoard();
373
+ }).catch((e) => {
374
+ setStatus(\`Action failed: \${e.message}\`);
375
+ });
376
376
  }
377
- html += '</div></div>';
377
+ function doPoll() {
378
+ if (pollActive) return;
379
+ pollActive = true;
380
+ loadBoard().finally(() => {
381
+ pollActive = false;
382
+ setTimeout(doPoll, 4e3);
383
+ });
384
+ }
385
+ columnsEl.addEventListener("click", (evt) => {
386
+ if (!(evt.target instanceof Element)) return;
387
+ const btn = evt.target.closest("button[data-action]");
388
+ if (!(btn instanceof HTMLButtonElement)) return;
389
+ const taskId = btn.getAttribute("data-taskid");
390
+ const action = btn.getAttribute("data-action");
391
+ if (!taskId || !action || !isCardAction(action)) return;
392
+ applyAction(taskId, action);
393
+ });
394
+ getEl("refresh-btn").addEventListener("click", () => {
395
+ void loadBoard();
396
+ });
397
+ getEl("go-btn").addEventListener("click", () => {
398
+ const value = boardInputEl.value.trim();
399
+ if (!value) return;
400
+ boardId = value;
401
+ void loadBoard();
402
+ });
403
+ getEl("add-btn").addEventListener("click", () => {
404
+ const title = newTitleEl.value.trim();
405
+ if (!title) return;
406
+ const args = boardId ? { title, boardId } : { title };
407
+ callTool("task_create", args).then((result) => {
408
+ if (result.error) {
409
+ setStatus(\`Create failed: \${result.error}\`);
410
+ return void 0;
411
+ }
412
+ newTitleEl.value = "";
413
+ setStatus(\`Created "\${title}".\`);
414
+ return loadBoard();
415
+ }).catch((e) => {
416
+ setStatus(\`Create failed: \${e.message}\`);
417
+ });
418
+ });
419
+ initBridge().then(() => loadBoard()).then(() => {
420
+ setTimeout(doPoll, 4e3);
421
+ }).catch((e) => {
422
+ setStatus(\`Bridge error: \${e.message}\`);
423
+ });
424
+ }
425
+ if (document.readyState === "loading") {
426
+ document.addEventListener("DOMContentLoaded", boot);
427
+ } else {
428
+ boot();
378
429
  }
379
- el.innerHTML = html;
430
+ })();</script>
431
+ <style rel="stylesheet" crossorigin>/* \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
432
+ Semantic tokens + runtime mapping sheets.
433
+
434
+ Every rule below the next section reads ONLY the --wb-* custom
435
+ properties. Each one resolves through TWO mapping sheets, chosen at
436
+ PAINT time via plain CSS var() fallback \u2014 no build step, no JS, so a
437
+ host that swaps its theme live (VS Code) is never frozen at whatever
438
+ theme happened to be active when this bundle was built:
439
+
440
+ 1. embedded \u2014 VS Code injects a live --vscode-* custom-property set
441
+ into the webview and swaps it on theme change. Whenever the
442
+ relevant --vscode-* variable exists, it wins \u2014 in a VS Code
443
+ \`srcdoc\` relay panel AND (structurally identically) any other host
444
+ that happened to expose the same names, though none is known to.
445
+ 2. standalone \u2014 the agentproto brand tokens (see
446
+ projects/agentproto/site/src/app/brand.css), used whenever no
447
+ --vscode-* variable is set \u2014 a plain MCP-Apps host or the daemon's
448
+ own \`/apps/.../ui\` tab. \`--phos\`/\`--amber\`/\`--crimson\` are
449
+ THEME-INVARIANT in brand.css (the phosphor terminal palette), so
450
+ they're identical in both blocks below; the rest follow brand.css's
451
+ light/dark split via \`prefers-color-scheme\` \u2014 a standalone tab has
452
+ no host to pick a theme for it, unlike VS Code's own.
453
+ \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550 */
454
+
455
+ :root {
456
+ --wb-bg: var(--vscode-editor-background, #f5f6f3);
457
+ --wb-surface: var(--vscode-sideBar-background, #ffffff);
458
+ --wb-ink: var(--vscode-editor-foreground, #171a1e);
459
+ --wb-ink-muted: var(--vscode-descriptionForeground, #5c6470);
460
+ --wb-border: var(--vscode-panel-border, #dde0da);
461
+ --wb-accent: var(--vscode-button-background, #0f62fe);
462
+
463
+ /* Status colors \u2014 phos/amber/crimson are the theme-invariant terminal
464
+ palette in brand.css, so light and dark standalone fallbacks match. */
465
+ --wb-status-pending: var(--vscode-descriptionForeground, #5c6470);
466
+ --wb-status-in-progress: var(--vscode-charts-yellow, #f0b429);
467
+ --wb-status-done: var(--vscode-charts-green, #3edc81);
468
+ --wb-status-failed: var(--vscode-charts-red, #fa4d56);
469
+ --wb-status-cancelled: var(--vscode-descriptionForeground, #5c6470);
470
+ --wb-status-cancelled-weak: color-mix(in srgb, var(--wb-status-cancelled) 55%, transparent);
380
471
  }
381
472
 
382
- // ============================================================
383
- // Data
384
- // ============================================================
385
-
386
- function loadBoard() {
387
- var args = {includeClosed: true, full: true};
388
- if (boardId) args.boardId = boardId;
389
- return callTool('task_list', args).then(function (data) {
390
- boardId = data.boardId || boardId;
391
- tasks = data.tasks || [];
392
- render();
393
- setStatus(tasks.length + ' task' + (tasks.length === 1 ? '' : 's') + ' \xB7 ' + new Date().toLocaleTimeString());
394
- }).catch(function (e) {
395
- setStatus('Error: ' + e.message);
396
- });
473
+ @media (prefers-color-scheme: dark) {
474
+ :root {
475
+ --wb-bg: var(--vscode-editor-background, #101214);
476
+ --wb-surface: var(--vscode-sideBar-background, #16191d);
477
+ --wb-ink: var(--vscode-editor-foreground, #e8eaed);
478
+ --wb-ink-muted: var(--vscode-descriptionForeground, #99a2ad);
479
+ --wb-border: var(--vscode-panel-border, #272c33);
480
+ --wb-accent: var(--vscode-button-background, #4589ff);
481
+
482
+ --wb-status-pending: var(--vscode-descriptionForeground, #99a2ad);
483
+ --wb-status-in-progress: var(--vscode-charts-yellow, #f0b429);
484
+ --wb-status-done: var(--vscode-charts-green, #3edc81);
485
+ --wb-status-failed: var(--vscode-charts-red, #fa4d56);
486
+ --wb-status-cancelled: var(--vscode-descriptionForeground, #99a2ad);
487
+ --wb-status-cancelled-weak: color-mix(in srgb, var(--wb-status-cancelled) 55%, transparent);
488
+ }
397
489
  }
398
490
 
399
- function doPoll() {
400
- if (pollActive) return;
401
- pollActive = true;
402
- loadBoard().then(function () {
403
- pollActive = false;
404
- pollTimer = setTimeout(doPoll, 4000);
405
- }).catch(function () {
406
- pollActive = false;
407
- pollTimer = setTimeout(doPoll, 4000);
408
- });
409
- }
491
+ /* \u2500\u2500 Base \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
410
492
 
411
- // ============================================================
412
- // Toolbar wiring
413
- // ============================================================
493
+ * { box-sizing: border-box; margin: 0; padding: 0; }
414
494
 
415
- document.getElementById('columns').addEventListener('click', function (evt) {
416
- var btn = evt.target.closest ? evt.target.closest('button[data-action]') : null;
417
- if (!btn) return;
418
- applyAction(btn.getAttribute('data-taskid'), btn.getAttribute('data-action'));
419
- });
495
+ html, body {
496
+ height: 100%;
497
+ font-family: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
498
+ font-size: 13px;
499
+ background: var(--wb-bg);
500
+ color: var(--wb-ink);
501
+ overflow: hidden;
502
+ }
420
503
 
421
- document.getElementById('refresh-btn').addEventListener('click', function () {
422
- loadBoard();
423
- });
504
+ .mono {
505
+ font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, "Courier New", monospace;
506
+ }
424
507
 
425
- document.getElementById('go-btn').addEventListener('click', function () {
426
- var v = document.getElementById('board-input').value.trim();
427
- if (!v) return;
428
- boardId = v;
429
- loadBoard();
430
- });
508
+ #app { display: flex; flex-direction: column; height: 100%; }
431
509
 
432
- document.getElementById('add-btn').addEventListener('click', function () {
433
- var input = document.getElementById('new-title');
434
- var title = input.value.trim();
435
- if (!title) return;
436
- var args = {title: title};
437
- if (boardId) args.boardId = boardId;
438
- callTool('task_create', args).then(function (result) {
439
- if (result && result.error) {
440
- setStatus('Create failed: ' + result.error);
441
- return;
442
- }
443
- input.value = '';
444
- setStatus('Created "' + title + '".');
445
- return loadBoard();
446
- }).catch(function (e) {
447
- setStatus('Create failed: ' + e.message);
448
- });
449
- });
510
+ #toolbar {
511
+ padding: 8px 12px;
512
+ border-bottom: 1px solid var(--wb-border);
513
+ display: flex;
514
+ align-items: center;
515
+ gap: 8px;
516
+ background: var(--wb-surface);
517
+ flex-shrink: 0;
518
+ }
519
+ #board-label { font-size: 11px; color: var(--wb-ink-muted); }
520
+ #board-id { font-weight: 600; color: var(--wb-ink); font-size: 12px; font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, "Courier New", monospace; }
521
+ #board-input {
522
+ background: var(--wb-bg);
523
+ border: 1px solid var(--wb-border);
524
+ color: var(--wb-ink);
525
+ padding: 4px 8px;
526
+ border-radius: 4px;
527
+ font-size: 12px;
528
+ font-family: inherit;
529
+ width: 220px;
530
+ }
531
+ .tbtn {
532
+ background: var(--wb-bg);
533
+ border: 1px solid var(--wb-border);
534
+ color: var(--wb-ink);
535
+ padding: 4px 10px;
536
+ border-radius: 4px;
537
+ cursor: pointer;
538
+ font-size: 12px;
539
+ font-family: inherit;
540
+ }
541
+ .tbtn:hover { background: var(--wb-border); }
542
+ #new-title {
543
+ flex: 1;
544
+ min-width: 120px;
545
+ background: var(--wb-bg);
546
+ border: 1px solid var(--wb-border);
547
+ color: var(--wb-ink);
548
+ padding: 4px 8px;
549
+ border-radius: 4px;
550
+ font-size: 12px;
551
+ font-family: inherit;
552
+ }
450
553
 
451
- // ============================================================
452
- // Boot
453
- // ============================================================
554
+ #columns { flex: 1; display: flex; overflow-x: auto; overflow-y: hidden; }
555
+ .col {
556
+ width: 260px;
557
+ min-width: 220px;
558
+ flex-shrink: 0;
559
+ display: flex;
560
+ flex-direction: column;
561
+ border-right: 1px solid var(--wb-border);
562
+ }
563
+ .col-hdr {
564
+ padding: 8px 10px;
565
+ border-bottom: 1px solid var(--wb-border);
566
+ background: var(--wb-surface);
567
+ font-size: 11px;
568
+ font-weight: 600;
569
+ color: var(--wb-ink-muted);
570
+ text-transform: uppercase;
571
+ letter-spacing: 0.05em;
572
+ display: flex;
573
+ justify-content: space-between;
574
+ }
575
+ .col-body { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
454
576
 
455
- initBridge().then(function () {
456
- return loadBoard();
457
- }).then(function () {
458
- pollTimer = setTimeout(doPoll, 4000);
459
- }).catch(function (e) {
460
- setStatus('Bridge error: ' + e.message);
461
- });
462
- </script>
577
+ .card {
578
+ background: var(--wb-surface);
579
+ border: 1px solid var(--wb-border);
580
+ border-radius: 6px;
581
+ padding: 8px 10px;
582
+ }
583
+ .c-title { font-size: 12px; font-weight: 500; margin-bottom: 4px; word-break: break-word; }
584
+ .c-id {
585
+ font-size: 10px;
586
+ color: var(--wb-ink-muted);
587
+ margin-bottom: 6px;
588
+ font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, "Courier New", monospace;
589
+ }
590
+ .c-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 6px; }
591
+
592
+ .tag { display: inline-block; padding: 1px 6px; border-radius: 10px; font-size: 10px; font-weight: 600; white-space: nowrap; }
593
+ .t-unclaimed { background: color-mix(in srgb, var(--wb-ink-muted) 15%, transparent); color: var(--wb-ink-muted); border: 1px dashed var(--wb-ink-muted); }
594
+ .t-owner { background: color-mix(in srgb, var(--wb-accent) 15%, transparent); color: var(--wb-accent); }
595
+
596
+ /* Verification tell: gate solid green, self-report amber outline, human
597
+ blue, a declared verify with no verification yet grey "gated" \u2014 never
598
+ render an unverified done as gate-passed (see render.ts's verificationTag). */
599
+ .t-gate { background: color-mix(in srgb, var(--wb-status-done) 18%, transparent); color: var(--wb-status-done); }
600
+ .t-self { background: transparent; color: var(--wb-status-in-progress); border: 1px solid var(--wb-status-in-progress); }
601
+ .t-human { background: color-mix(in srgb, var(--wb-accent) 18%, transparent); color: var(--wb-accent); }
602
+ .t-gated { background: color-mix(in srgb, var(--wb-ink-muted) 12%, transparent); color: var(--wb-ink-muted); }
603
+ .t-cancelled {
604
+ background: color-mix(in srgb, var(--wb-status-cancelled) 10%, transparent);
605
+ color: var(--wb-status-cancelled-weak);
606
+ border: 1px dashed color-mix(in srgb, var(--wb-status-cancelled) 40%, transparent);
607
+ }
608
+
609
+ .c-err { font-size: 10px; color: var(--wb-status-failed); margin-bottom: 6px; word-break: break-word; }
610
+ .c-actions { display: flex; flex-wrap: wrap; gap: 4px; }
611
+ .abtn {
612
+ background: var(--wb-bg);
613
+ border: 1px solid var(--wb-border);
614
+ color: var(--wb-ink);
615
+ padding: 3px 8px;
616
+ border-radius: 4px;
617
+ cursor: pointer;
618
+ font-size: 11px;
619
+ font-family: inherit;
620
+ }
621
+ .abtn:hover { background: var(--wb-border); }
622
+ .abtn.danger { border-color: var(--wb-status-failed); color: var(--wb-status-failed); }
623
+ .abtn.primary { border-color: var(--wb-status-done); color: var(--wb-status-done); }
624
+
625
+ #statusbar {
626
+ padding: 4px 12px;
627
+ font-size: 11px;
628
+ color: var(--wb-ink-muted);
629
+ border-top: 1px solid var(--wb-border);
630
+ background: var(--wb-surface);
631
+ flex-shrink: 0;
632
+ }
633
+ .empty { padding: 16px 8px; color: var(--wb-ink-muted); font-size: 11px; text-align: center; }</style>
634
+ </head>
635
+ <body>
636
+ <div id="app">
637
+ <div id="toolbar">
638
+ <span id="board-label">Board:</span>
639
+ <span id="board-id">\u2014</span>
640
+ <input id="board-input" type="text" placeholder="tree:&lt;sessionId&gt; or ws:&lt;slug&gt;">
641
+ <button class="tbtn" id="go-btn">Go</button>
642
+ <button class="tbtn" id="refresh-btn" title="Refresh">&#8635;</button>
643
+ <input id="new-title" type="text" placeholder="New task title&#8230;">
644
+ <button class="tbtn" id="add-btn">+ Add</button>
645
+ </div>
646
+ <div id="columns"></div>
647
+ <div id="statusbar">Connecting to bridge&#8230;</div>
648
+ </div>
463
649
  </body>
464
- </html>`;
650
+ </html>
651
+ `;
652
+
653
+ // src/work-board/panel.ts
654
+ var WORK_BOARD_APP_ID = "@agentproto/work-board";
655
+ var WORK_BOARD_TOOL_ID = "agentproto_work_board";
656
+ var WORK_BOARD_UI_TOOLS = [
657
+ "task_list",
658
+ "task_claim",
659
+ "task_update",
660
+ "task_create"
661
+ ];
662
+ var WORK_BOARD_HTML = WORK_BOARD_HTML_GENERATED;
465
663
 
466
664
  // src/work-board/index.ts
467
665
  var workBoardInputSchema = z.object({
@@ -471,7 +669,7 @@ var workBoardInputSchema = z.object({
471
669
  });
472
670
  function makeWorkBoardApp(ops) {
473
671
  return {
474
- id: "agentproto_work_board",
672
+ id: WORK_BOARD_TOOL_ID,
475
673
  title: "Work Board",
476
674
  description: "Open the agentproto work board \u2014 a kanban over the daemon's Task ledger (columns: pending/in_progress/done/failed, cancelled folded into failed). Swimlane is the ledger's own board id (`tree:<root>` or `ws:<slug>`). Each card shows its owner (or \"Unclaimed\") and the verification tell \u2014 a gate-passed done reads visually distinct from a self-reported one. Pass `boardId` to open a specific board.",
477
675
  inputSchema: workBoardInputSchema,
@@ -480,14 +678,14 @@ function makeWorkBoardApp(ops) {
480
678
  };
481
679
  }
482
680
  var workBoardApp = defineApp({
483
- id: "@agentproto/work-board",
681
+ id: WORK_BOARD_APP_ID,
484
682
  name: "Work Board",
485
683
  description: "Open the agentproto work board \u2014 a kanban over the daemon's Task ledger, scoped by board id (`tree:<rootSessionId>` or `ws:<slug>`), with an explicit status action per card.",
486
684
  agents: [],
487
685
  ui: {
488
686
  html: WORK_BOARD_HTML,
489
687
  title: "Work Board",
490
- tools: ["task_list", "task_claim", "task_update", "task_create"]
688
+ tools: [...WORK_BOARD_UI_TOOLS]
491
689
  }
492
690
  });
493
691