@double_geste/agent-standup 1.32.0 → 1.34.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.
- package/examples/vampire/README.txt +7 -0
- package/examples/vampire/you+sticker1-1.png +0 -0
- package/examples/vampire/you+sticker1-2.png +0 -0
- package/examples/vampire/you+sticker1-3.png +0 -0
- package/examples/vampire/you+sticker2-1.png +0 -0
- package/examples/vampire/you+sticker2-2.png +0 -0
- package/examples/vampire/you+sticker2-3.png +0 -0
- package/examples/vampire/you+sticker3-1.png +0 -0
- package/examples/vampire/you+sticker3-2.png +0 -0
- package/examples/vampire/you+sticker3-3.png +0 -0
- package/examples/vampire/you-bg.png +0 -0
- package/examples/vampire/you-desk-dark.png +0 -0
- package/examples/vampire/you-desk.png +0 -0
- package/examples/vampire/you-hands.png +0 -0
- package/examples/vampire/you-head.png +0 -0
- package/examples/vampire/you-talk.png +0 -0
- package/examples/vampire/you.png +0 -0
- package/package.json +1 -1
- package/public/index.html +267 -68
- package/public/locales/da.json +51 -3
- package/public/locales/de.json +51 -3
- package/public/locales/en.json +51 -3
- package/public/locales/es.json +51 -3
- package/public/locales/ja.json +51 -3
- package/public/locales/ko.json +51 -3
- package/public/locales/pt-BR.json +51 -3
- package/public/locales/zh-CN.json +51 -3
- package/public/locales/zh-TW.json +51 -3
- package/public/pack-halloween.jpg +0 -0
- package/server.js +129 -20
|
@@ -7,9 +7,7 @@
|
|
|
7
7
|
"Characters": "Personagens",
|
|
8
8
|
"Reload": "Recarregar",
|
|
9
9
|
"Open folder": "Abrir pasta",
|
|
10
|
-
"custom character(s) loaded": "personagem(ns) personalizado(s) carregado(s)",
|
|
11
10
|
"Demo": "Demo",
|
|
12
|
-
"Drop your pixel art (PNG) in this folder to replace the characters:": "Solte sua pixel art (PNG) nesta pasta para substituir os personagens:",
|
|
13
11
|
"lead.png = the lead · you.png = you · others = the sub-agents · name-talk.png = open mouth": "lead.png = o agente principal · you.png = você · outros = os subagentes · name-talk.png = boca aberta",
|
|
14
12
|
" full — compaction soon": " cheio — compactação em breve",
|
|
15
13
|
"”": "”",
|
|
@@ -253,9 +251,59 @@
|
|
|
253
251
|
"No preview here: the page is on claude.ai": "Sem prévia aqui: a página está em claude.ai",
|
|
254
252
|
"Open on claude.ai": "Abrir em claude.ai",
|
|
255
253
|
"Publishing ": "Publicando ",
|
|
254
|
+
"Showing ": "Mostrando ",
|
|
256
255
|
"This page uses libraries kept on other servers: they are loaded only if you ask": "Esta página usa bibliotecas hospedadas em outros servidores: elas só são carregadas se você pedir",
|
|
257
256
|
"Mark as done": "Marcar como concluída",
|
|
258
257
|
"Open the pull request": "Abrir o pull request",
|
|
259
258
|
"Reopen": "Reabrir",
|
|
260
|
-
"Pinned: click to unpin": "Fixada: clique para soltar"
|
|
259
|
+
"Pinned: click to unpin": "Fixada: clique para soltar",
|
|
260
|
+
"Halloween pack": "Pacote de Halloween",
|
|
261
|
+
"This code is not valid.": "Este código não é válido.",
|
|
262
|
+
"This purchase was refunded.": "Esta compra foi reembolsada.",
|
|
263
|
+
"This payment is not complete yet.": "Este pagamento ainda não foi concluído.",
|
|
264
|
+
"The shop is not open yet.": "A loja ainda não está aberta.",
|
|
265
|
+
"The shop cannot be reached. Check your connection and try again.": "Não foi possível acessar a loja. Verifique sua conexão e tente novamente.",
|
|
266
|
+
"Hand-drawn Halloween characters, each in its own room.": "Personagens de Halloween desenhados à mão, cada um em seu próprio cômodo.",
|
|
267
|
+
"One payment, by card, on a Stripe page. No account.": "Um único pagamento, com cartão, em uma página da Stripe. Sem conta.",
|
|
268
|
+
"Buy": "Comprar",
|
|
269
|
+
"I already bought it": "Já comprei",
|
|
270
|
+
"Purchase code": "Código da compra",
|
|
271
|
+
"Opening the payment page…": "Abrindo a página de pagamento…",
|
|
272
|
+
"Waiting for the payment. The pack installs by itself once it is paid.": "Aguardando o pagamento. O pacote se instala sozinho assim que for pago.",
|
|
273
|
+
"Your purchase code, to install the pack on another computer:": "Seu código da compra, para instalar o pacote em outro computador:",
|
|
274
|
+
"Update the pack": "Atualizar o pacote",
|
|
275
|
+
"Add pictures": "Adicionar imagens",
|
|
276
|
+
"characters": "personagens",
|
|
277
|
+
"Choose a picture": "Escolher uma imagem",
|
|
278
|
+
"Free, from the Halloween pack": "Grátis, do pacote de Halloween",
|
|
279
|
+
"Hand-drawn, each in its own room": "Desenhados à mão, cada um em seu cômodo",
|
|
280
|
+
"Like the cast": "Como o resto da equipe",
|
|
281
|
+
"No picture yet.": "Nenhuma imagem ainda.",
|
|
282
|
+
"Open mouth (optional)": "Boca aberta (opcional)",
|
|
283
|
+
"Remove": "Remover",
|
|
284
|
+
"See the pack": "Ver o pacote",
|
|
285
|
+
"Sub-agent": "Subagente",
|
|
286
|
+
"Sub-agents": "Subagentes",
|
|
287
|
+
"The app’s own": "Os do app",
|
|
288
|
+
"The cast": "A equipe",
|
|
289
|
+
"The drawn character": "O personagem desenhado",
|
|
290
|
+
"The vampire": "O vampiro",
|
|
291
|
+
"This Halloween, you are the vampire. The rest of the cast is in the Halloween pack.": "Neste Halloween, você é o vampiro. O resto da equipe está no pacote de Halloween.",
|
|
292
|
+
"This picture could not be added: PNG, GIF, WebP or JPEG, up to 300 KB.": "Não foi possível adicionar esta imagem: PNG, GIF, WebP ou JPEG, até 300 KB.",
|
|
293
|
+
"You: like the cast": "Você: como a equipe",
|
|
294
|
+
"You: the vampire": "Você: o vampiro",
|
|
295
|
+
"Your own pictures": "Suas próprias imagens",
|
|
296
|
+
"Your pictures are in this folder:": "Suas imagens ficam nesta pasta:",
|
|
297
|
+
"Yours": "Seu",
|
|
298
|
+
"character": "personagem",
|
|
299
|
+
"Drawn by": "Desenhados por",
|
|
300
|
+
"⚙ All settings (display, alerts…)": "⚙ Todas as configurações (exibição, avisos…)",
|
|
301
|
+
"All settings": "Todas as configurações",
|
|
302
|
+
"More": "Mais",
|
|
303
|
+
"Sound and alerts": "Som e avisos",
|
|
304
|
+
"Click again to reset them all": "Clique de novo para redefinir todas",
|
|
305
|
+
"Got it": "Entendi",
|
|
306
|
+
"Reset to defaults": "Restaurar padrões",
|
|
307
|
+
"Your settings moved: the everyday ones are here, the rest in “All settings”.": "Suas configurações mudaram de lugar: as do dia a dia estão aqui, o resto em “Todas as configurações”.",
|
|
308
|
+
"2 € minimum: you can pay more on the payment page if you like.": "Mínimo de 2 €: você pode pagar mais na página de pagamento, se quiser."
|
|
261
309
|
}
|
|
@@ -174,9 +174,7 @@
|
|
|
174
174
|
"Characters": "角色",
|
|
175
175
|
"Reload": "重新加载",
|
|
176
176
|
"Open folder": "打开文件夹",
|
|
177
|
-
"custom character(s) loaded": "个自定义角色已加载",
|
|
178
177
|
"Demo": "演示",
|
|
179
|
-
"Drop your pixel art (PNG) in this folder to replace the characters:": "把你的像素画(PNG)放进此文件夹即可替换角色:",
|
|
180
178
|
"lead.png = the lead · you.png = you · others = the sub-agents · name-talk.png = open mouth": "lead.png = 主代理 · you.png = 你 · 其他 = 子代理 · name-talk.png = 张嘴",
|
|
181
179
|
"Downloading, you can carry on: the agents babble meanwhile.": "正在下载,你可以继续:在此期间代理会用咿呀语说话。",
|
|
182
180
|
"Good-quality local voices, in English. Free, nothing leaves your machine.": "高质量的本地语音,仅英语。免费,数据不会离开你的电脑。",
|
|
@@ -253,9 +251,59 @@
|
|
|
253
251
|
"No preview here: the page is on claude.ai": "此处无法预览:页面在 claude.ai 上",
|
|
254
252
|
"Open on claude.ai": "在 claude.ai 上打开",
|
|
255
253
|
"Publishing ": "正在发布 ",
|
|
254
|
+
"Showing ": "正在展示 ",
|
|
256
255
|
"This page uses libraries kept on other servers: they are loaded only if you ask": "此页面使用存放在其他服务器上的库:仅在你要求时才加载",
|
|
257
256
|
"Mark as done": "标记为已处理",
|
|
258
257
|
"Open the pull request": "打开拉取请求",
|
|
259
258
|
"Reopen": "重新打开",
|
|
260
|
-
"Pinned: click to unpin": "已固定:点击以取消固定"
|
|
259
|
+
"Pinned: click to unpin": "已固定:点击以取消固定",
|
|
260
|
+
"Halloween pack": "万圣节包",
|
|
261
|
+
"This code is not valid.": "此代码无效。",
|
|
262
|
+
"This purchase was refunded.": "此购买已退款。",
|
|
263
|
+
"This payment is not complete yet.": "此付款尚未完成。",
|
|
264
|
+
"The shop is not open yet.": "商店尚未开放。",
|
|
265
|
+
"The shop cannot be reached. Check your connection and try again.": "无法连接商店。请检查网络连接后重试。",
|
|
266
|
+
"Hand-drawn Halloween characters, each in its own room.": "手绘万圣节角色,每个角色都有自己的房间。",
|
|
267
|
+
"One payment, by card, on a Stripe page. No account.": "在 Stripe 页面用银行卡一次性付款。无需账户。",
|
|
268
|
+
"Buy": "购买",
|
|
269
|
+
"I already bought it": "我已购买",
|
|
270
|
+
"Purchase code": "购买代码",
|
|
271
|
+
"Opening the payment page…": "正在打开付款页面…",
|
|
272
|
+
"Waiting for the payment. The pack installs by itself once it is paid.": "正在等待付款。付款完成后,角色包会自动安装。",
|
|
273
|
+
"Your purchase code, to install the pack on another computer:": "您的购买代码,用于在另一台电脑上安装角色包:",
|
|
274
|
+
"Update the pack": "更新角色包",
|
|
275
|
+
"Add pictures": "添加图片",
|
|
276
|
+
"characters": "个角色",
|
|
277
|
+
"Choose a picture": "选择图片",
|
|
278
|
+
"Free, from the Halloween pack": "免费,来自万圣节角色包",
|
|
279
|
+
"Hand-drawn, each in its own room": "手绘,每个角色都有自己的房间",
|
|
280
|
+
"Like the cast": "和团队一样",
|
|
281
|
+
"No picture yet.": "还没有图片。",
|
|
282
|
+
"Open mouth (optional)": "张嘴的图片(可选)",
|
|
283
|
+
"Remove": "移除",
|
|
284
|
+
"See the pack": "查看角色包",
|
|
285
|
+
"Sub-agent": "子代理",
|
|
286
|
+
"Sub-agents": "子代理",
|
|
287
|
+
"The app’s own": "应用自带",
|
|
288
|
+
"The cast": "团队",
|
|
289
|
+
"The drawn character": "绘制的角色",
|
|
290
|
+
"The vampire": "吸血鬼",
|
|
291
|
+
"This Halloween, you are the vampire. The rest of the cast is in the Halloween pack.": "这个万圣节,你就是吸血鬼。团队的其他成员在万圣节角色包里。",
|
|
292
|
+
"This picture could not be added: PNG, GIF, WebP or JPEG, up to 300 KB.": "无法添加此图片:仅限 PNG、GIF、WebP 或 JPEG,最大 300 KB。",
|
|
293
|
+
"You: like the cast": "你:和团队一样",
|
|
294
|
+
"You: the vampire": "你:吸血鬼",
|
|
295
|
+
"Your own pictures": "你自己的图片",
|
|
296
|
+
"Your pictures are in this folder:": "你的图片在这个文件夹里:",
|
|
297
|
+
"Yours": "已拥有",
|
|
298
|
+
"character": "个角色",
|
|
299
|
+
"Drawn by": "绘制:",
|
|
300
|
+
"⚙ All settings (display, alerts…)": "⚙ 全部设置(显示、提醒…)",
|
|
301
|
+
"All settings": "全部设置",
|
|
302
|
+
"More": "更多",
|
|
303
|
+
"Sound and alerts": "声音与提醒",
|
|
304
|
+
"Click again to reset them all": "再点一次即可全部重置",
|
|
305
|
+
"Got it": "知道了",
|
|
306
|
+
"Reset to defaults": "恢复默认设置",
|
|
307
|
+
"Your settings moved: the everyday ones are here, the rest in “All settings”.": "设置换了位置:常用的在这里,其余的在“全部设置”里。",
|
|
308
|
+
"2 € minimum: you can pay more on the payment page if you like.": "最低 2 欧元:如果愿意,可以在付款页面多付一些。"
|
|
261
309
|
}
|
|
@@ -59,9 +59,7 @@
|
|
|
59
59
|
"Characters": "角色",
|
|
60
60
|
"Reload": "重新載入",
|
|
61
61
|
"Open folder": "開啟資料夾",
|
|
62
|
-
"custom character(s) loaded": "個自訂角色已載入",
|
|
63
62
|
"Demo": "示範",
|
|
64
|
-
"Drop your pixel art (PNG) in this folder to replace the characters:": "把你的像素畫(PNG)放進此資料夾即可替換角色:",
|
|
65
63
|
"lead.png = the lead · you.png = you · others = the sub-agents · name-talk.png = open mouth": "lead.png = 主代理 · you.png = 你 · 其他 = 子代理 · name-talk.png = 張嘴畫面",
|
|
66
64
|
"failing in a loop?": "卡在失敗迴圈?",
|
|
67
65
|
"Fetching ": "擷取 ",
|
|
@@ -253,9 +251,59 @@
|
|
|
253
251
|
"No preview here: the page is on claude.ai": "此處無法預覽:頁面在 claude.ai 上",
|
|
254
252
|
"Open on claude.ai": "在 claude.ai 上開啟",
|
|
255
253
|
"Publishing ": "發布 ",
|
|
254
|
+
"Showing ": "展示 ",
|
|
256
255
|
"This page uses libraries kept on other servers: they are loaded only if you ask": "此頁面使用存放在其他伺服器上的函式庫:只有在你要求時才會載入",
|
|
257
256
|
"Mark as done": "標記為已處理",
|
|
258
257
|
"Open the pull request": "開啟拉取請求",
|
|
259
258
|
"Reopen": "重新開啟",
|
|
260
|
-
"Pinned: click to unpin": "已固定:點擊以取消固定"
|
|
259
|
+
"Pinned: click to unpin": "已固定:點擊以取消固定",
|
|
260
|
+
"Halloween pack": "萬聖節包",
|
|
261
|
+
"This code is not valid.": "此代碼無效。",
|
|
262
|
+
"This purchase was refunded.": "此購買已退款。",
|
|
263
|
+
"This payment is not complete yet.": "此付款尚未完成。",
|
|
264
|
+
"The shop is not open yet.": "商店尚未開放。",
|
|
265
|
+
"The shop cannot be reached. Check your connection and try again.": "無法連線到商店。請檢查網路連線後再試一次。",
|
|
266
|
+
"Hand-drawn Halloween characters, each in its own room.": "手繪萬聖節角色,每個角色都有自己的房間。",
|
|
267
|
+
"One payment, by card, on a Stripe page. No account.": "在 Stripe 頁面以信用卡一次付清。不需要帳戶。",
|
|
268
|
+
"Buy": "購買",
|
|
269
|
+
"I already bought it": "我已購買",
|
|
270
|
+
"Purchase code": "購買代碼",
|
|
271
|
+
"Opening the payment page…": "正在開啟付款頁面…",
|
|
272
|
+
"Waiting for the payment. The pack installs by itself once it is paid.": "正在等待付款。付款完成後,角色包會自動安裝。",
|
|
273
|
+
"Your purchase code, to install the pack on another computer:": "您的購買代碼,用於在另一台電腦上安裝角色包:",
|
|
274
|
+
"Update the pack": "更新角色包",
|
|
275
|
+
"Add pictures": "新增圖片",
|
|
276
|
+
"characters": "個角色",
|
|
277
|
+
"Choose a picture": "選擇圖片",
|
|
278
|
+
"Free, from the Halloween pack": "免費,來自萬聖節角色包",
|
|
279
|
+
"Hand-drawn, each in its own room": "手繪,每個角色都有自己的房間",
|
|
280
|
+
"Like the cast": "和團隊一樣",
|
|
281
|
+
"No picture yet.": "還沒有圖片。",
|
|
282
|
+
"Open mouth (optional)": "張嘴的圖片(選用)",
|
|
283
|
+
"Remove": "移除",
|
|
284
|
+
"See the pack": "查看角色包",
|
|
285
|
+
"Sub-agent": "子代理",
|
|
286
|
+
"Sub-agents": "子代理",
|
|
287
|
+
"The app’s own": "應用程式內建",
|
|
288
|
+
"The cast": "團隊",
|
|
289
|
+
"The drawn character": "繪製的角色",
|
|
290
|
+
"The vampire": "吸血鬼",
|
|
291
|
+
"This Halloween, you are the vampire. The rest of the cast is in the Halloween pack.": "這個萬聖節,你就是吸血鬼。團隊的其他成員在萬聖節角色包裡。",
|
|
292
|
+
"This picture could not be added: PNG, GIF, WebP or JPEG, up to 300 KB.": "無法新增此圖片:僅限 PNG、GIF、WebP 或 JPEG,最大 300 KB。",
|
|
293
|
+
"You: like the cast": "你:和團隊一樣",
|
|
294
|
+
"You: the vampire": "你:吸血鬼",
|
|
295
|
+
"Your own pictures": "你自己的圖片",
|
|
296
|
+
"Your pictures are in this folder:": "你的圖片在這個資料夾裡:",
|
|
297
|
+
"Yours": "已擁有",
|
|
298
|
+
"character": "個角色",
|
|
299
|
+
"Drawn by": "繪製:",
|
|
300
|
+
"⚙ All settings (display, alerts…)": "⚙ 全部設定(顯示、提醒…)",
|
|
301
|
+
"All settings": "全部設定",
|
|
302
|
+
"More": "更多",
|
|
303
|
+
"Sound and alerts": "聲音與提醒",
|
|
304
|
+
"Click again to reset them all": "再按一次即可全部重設",
|
|
305
|
+
"Got it": "知道了",
|
|
306
|
+
"Reset to defaults": "恢復預設設定",
|
|
307
|
+
"Your settings moved: the everyday ones are here, the rest in “All settings”.": "設定換了位置:常用的在這裡,其餘的在「全部設定」裡。",
|
|
308
|
+
"2 € minimum: you can pay more on the payment page if you like.": "最低 2 歐元:如果願意,可以在付款頁面多付一些。"
|
|
261
309
|
}
|
|
Binary file
|
package/server.js
CHANGED
|
@@ -111,14 +111,26 @@ const toolLabel = (b, ts) => {
|
|
|
111
111
|
case 'Skill': out.d = { kind: 'text', what: 'skill', v: i.skill, text: clip(i.skill + (i.args ? ' ' + i.args : ''), 200) }; break;
|
|
112
112
|
case 'ToolSearch': out.d = { kind: 'text', what: 'toolsearch', text: clip(i.query, 200) }; break;
|
|
113
113
|
case 'Artifact': if ((!i.action || i.action === 'publish') && !i.asset) { out.d = { kind: 'artifact', file: typeof i.file_path === 'string' ? i.file_path : '', title: clip(i.title, 120), note: clip(i.description, 240) }; break; } // a page published on claude.ai: the call shows it in a browser window (see artifactPage). Any other use of the tool (a read, a list, an upload) is a call like any other
|
|
114
|
+
if (i.action === 'open') { out.d = { kind: 'artifact', file: '', title: '', note: '', open: 1 }; break; } // a page put on the person's screen: in the line of files when this session did not make it (see artOf)
|
|
114
115
|
// falls through
|
|
115
|
-
default:
|
|
116
|
+
default: if (mcp && /(^|_)Claude_Docs$/.test(mcp[1] || '') && mcp[2] === 'batch' && i.container && i.container.create && typeof i.container.create.name === 'string') { out.d = { kind: 'artifact', file: '', title: clip(i.container.create.name, 120), note: '', doc: 1 }; break; } // a doc of the Claude Docs connector being born (its later edits are calls like any other)
|
|
117
|
+
out.d = mcp ? { kind: 'text', what: 'mcp', v: (mcp[1] || '') + ' · ' + (mcp.slice(2).join('__') || ''), text: clip(JSON.stringify(i), 400) } : { kind: 'text', text: clip(JSON.stringify(i), 300) };
|
|
116
118
|
}
|
|
117
119
|
return out;
|
|
118
120
|
};
|
|
119
121
|
// What a publish answered: the link of the page on claude.ai, its title and which version this is. typed: made from an Artifact type (a deck, a design, a document), whose page is the type's and not the file that was sent.
|
|
120
122
|
const ART_URL = /^https:\/\/claude\.ai\/(code\/)?artifact\/[\w-]{6,80}$/;
|
|
121
123
|
const artifactOf = (u) => (u && typeof u === 'object' && typeof u.url === 'string' && ART_URL.test(u.url) ? { url: u.url, title: clip(u.title, 120), ...(u.seq > 0 ? { v: +u.seq } : {}), ...(u.type || u.created_from_type ? { typed: 1 } : {}) } : null);
|
|
124
|
+
// What a call that put an artifact in front of the person answered, for the line of files: a publish (above); a doc the Claude Docs connector created, whose answer names the doc and its address;
|
|
125
|
+
// an artifact opened on the person's screen, only when this session did not publish or create it already (the same artifact under its other address would show twice, and an open would take the place of the publish that has the preview).
|
|
126
|
+
const DOC_ID = /"created":\{[^{}]*"minted":"([\w-]{6,80})"/, DOC_URL = /"frame":\{[^{}]*"url":"(https:\/\/claude\.ai\/(?:code\/)?artifact\/[\w-]{6,80})"/;
|
|
127
|
+
function artOf(st, how, u, text) {
|
|
128
|
+
const seen = (st.artIds = st.artIds || new Set()), note = (id, url) => { if (id) seen.add('id ' + id); seen.add('url ' + url); }; // known by its id and by its address: a publish may answer without an id
|
|
129
|
+
if (how === 'doc') { const id = DOC_ID.exec(text), m = DOC_URL.exec(text); if (!id || !m || !ART_URL.test(m[1])) return null; note(id[1], m[1]); return { url: m[1], title: '', typed: 1 }; }
|
|
130
|
+
const a = artifactOf(u), id = a && typeof u.artifact_id === 'string' ? u.artifact_id : ''; if (!a) return null;
|
|
131
|
+
if (how === 'open') { if ((id && seen.has('id ' + id)) || seen.has('url ' + a.url)) return null; note(id, a.url); return { ...a, typed: 1 }; } // opened, not made here: the window gives its title and its link
|
|
132
|
+
note(id, a.url); return a;
|
|
133
|
+
}
|
|
122
134
|
const resultText = (c) => (typeof c === 'string' ? c : Array.isArray(c) ? c.map((x) => x.text || '').join('\n') : '');
|
|
123
135
|
// Pictures a tool returned (a screenshot, an image file that was read). They are served from the transcript itself, so nothing outside the session files is ever read, and only bitmap types are sent.
|
|
124
136
|
const IMG_TYPES = new Set(['image/png', 'image/jpeg', 'image/gif', 'image/webp']), mediaMemo = new Map();
|
|
@@ -364,7 +376,7 @@ function boardRows0() {
|
|
|
364
376
|
}
|
|
365
377
|
rows.sort((a, b) => b.st.mtimeMs - a.st.mtimeMs);
|
|
366
378
|
return rows.filter((r) => !r.cx && r.proj !== COWORK).slice(0, 40).concat(...SOURCES.map((m) => rows.filter((r) => r.src === m).slice(0, 20)), rows.filter((r) => r.proj === COWORK).slice(0, 20)).sort((a, b) => b.st.mtimeMs - a.st.mtimeMs).map(({ proj, id, st, cx, src }) => {
|
|
367
|
-
if (cx)
|
|
379
|
+
if (cx) { const r = guard(() => src.boardRow(cx, now), null); if (r && tmpKey(r.dir)) r.tmp = 1; return r; } // tmp: started in the temporary folder (see tmpKey)
|
|
368
380
|
const file = path.join(projDir(proj, id), id + '.jsonl'); let p; try { p = parseTail(file, st); } catch { p = { pending: [] }; }
|
|
369
381
|
const age = now - st.mtimeMs, lp = (p.pending || [])[(p.pending || []).length - 1]; let state = 'idle', tool = '', ageMs = age;
|
|
370
382
|
if (age < 30 * 60e3) {
|
|
@@ -377,7 +389,7 @@ function boardRows0() {
|
|
|
377
389
|
}
|
|
378
390
|
let subActive = 0, subTotal = 0;
|
|
379
391
|
for (const x of subFiles(proj, id)) { subTotal++; if (now - mtimeOf(x.file) < 90e3) subActive++; }
|
|
380
|
-
return { proj, id, title: coworkTitle(proj, id) || p.title || id, mtime: st.mtimeMs, state, tool, ageMs, subActive, subTotal, asked: p.asked || 0, ...(p.pr ? { pr: p.pr } : {}), ...(state === 'blocked' && lp && lp.q ? { ask: lp.q } : {}), ...(p.esc ? { cut: 1 } : {}) }; // cut: stopped by you, which is no news to tell you
|
|
392
|
+
return { proj, id, title: coworkTitle(proj, id) || p.title || id, mtime: st.mtimeMs, state, tool, ageMs, subActive, subTotal, asked: p.asked || 0, ...(p.pr ? { pr: p.pr } : {}), ...(state === 'blocked' && lp && lp.q ? { ask: lp.q } : {}), ...(p.esc ? { cut: 1 } : {}), ...(tmpKey(proj) ? { tmp: 1 } : {}) }; // cut: stopped by you, which is no news to tell you
|
|
381
393
|
}).filter(Boolean);
|
|
382
394
|
}
|
|
383
395
|
// Settings live in a file, not only in the page's localStorage: the port changes between VS Code windows and reloads, and localStorage is per origin (port included).
|
|
@@ -447,15 +459,21 @@ process.on('uncaughtExceptionMonitor', (e, origin) => { try { if (OWN || String(
|
|
|
447
459
|
// One exception, so that the call is not left on an empty room: when the session you last typed in has finished and been quiet for STICK_MS while another one is at work, the call
|
|
448
460
|
// goes to that one. A session you went to by hand is not left that way.
|
|
449
461
|
const STICK_MS = 90000;
|
|
462
|
+
// Sessions started in the system's temporary folder: a program running Claude Code there for a moment (a test, a script, a tool that makes a folder per run), not a session someone works in.
|
|
463
|
+
// When the call looks everywhere it leaves them out, unless there is nothing else; they have no tab then and send no visitor. They stay in the Sessions view, and a window open on such a folder follows it.
|
|
464
|
+
// macOS: /var/folders/… (/private/… once resolved) and /tmp; Linux: /tmp; Windows: …\AppData\Local\Temp; and wherever TMPDIR points. A key is a folder as Claude Code names it, every other character a "-".
|
|
465
|
+
const TMP_KEYS = [...new Set([os.tmpdir(), (() => { try { return fs.realpathSync(os.tmpdir()); } catch { return ''; } })()].filter((d) => d && d.length > 4).map((d) => d.replace(/[^a-zA-Z0-9]/g, '-')))];
|
|
466
|
+
const tmpKey = (k) => !!k && (/^-(private-)?(tmp|var-folders)(-|$)/.test(k) || /-AppData-Local-Temp(-|$)/i.test(k) || TMP_KEYS.some((t) => k === t || k.startsWith(t + '-')));
|
|
467
|
+
const tmpSession = (proj, id) => { const sx = sourceOf(proj); return sx ? tmpKey(String(guard(() => sx.cwd(id), '') || '').replace(/[^a-zA-Z0-9]/g, '-')) : tmpKey(proj); }; // a Codex or Vibe session: the folder it was started in
|
|
450
468
|
function sessionMtime(proj, id) {
|
|
451
469
|
const sx = sourceOf(proj), r = sx ? guard(() => sx.row(id), null) : null; if (sx && (!r || !sx.subFiles)) return r ? r.mtime : 0;
|
|
452
470
|
let m = sx ? r.mtime : mtimeOf(path.join(projDir(proj, id), id + '.jsonl')); if (!m) return 0; const subs = subFilesOf(proj, id);
|
|
453
471
|
for (const x of subs) m = Math.max(m, mtimeOf(x.file)); for (const d of subs.dirs) m = Math.max(m, mtimeOf(d)); return m; // the folders too: a new file in them is activity, as when every file around the transcripts was looked at
|
|
454
472
|
}
|
|
455
|
-
function currentSession(projFilter, pick, stick) { // pick: { proj, id, since } the session you went to by hand, and the latest order there was then · stick: the session the call is in
|
|
473
|
+
function currentSession(projFilter, pick, stick, anyTmp) { // pick: { proj, id, since } the session you went to by hand, and the latest order there was then · stick: the session the call is in · anyTmp: sessions in the temporary folder count too (see tmpKey)
|
|
456
474
|
const safe = (x) => typeof x === 'string' && /^[\w.\-]+$/.test(x) && x !== '..', now = Date.now();
|
|
457
475
|
const there = (c) => !!c && safe(c.id) && safe(c.proj) && (sourceOf(c.proj) ? !!guard(() => sourceOf(c.proj).fileOf(c.id), null) : fs.existsSync(path.join(projDir(c.proj, c.id), c.id + '.jsonl')));
|
|
458
|
-
const inScope = (c) => !projFilter || c.proj === projFilter || c.proj.startsWith(projFilter + '-') || !!(sourceOf(c.proj) && guard(() => sourceOf(c.proj).inProject(c.id, projFilter), false)); // a Codex or Vibe session counts for a project when it was started in that folder
|
|
476
|
+
const inScope = (c) => (!projFilter ? anyTmp || !tmpSession(c.proj, c.id) : c.proj === projFilter || c.proj.startsWith(projFilter + '-') || !!(sourceOf(c.proj) && guard(() => sourceOf(c.proj).inProject(c.id, projFilter), false))); // a Codex or Vibe session counts for a project when it was started in that folder
|
|
459
477
|
const same = (a, b) => !!a && !!b && a.proj === b.proj && a.id === b.id, all = boardRows(), rows = all.filter(inScope), mine = there(pick) ? all.find((r) => same(r, pick)) : null;
|
|
460
478
|
const asked = Math.max(0, (mine && mine.asked) || 0, ...rows.map((r) => r.asked || 0)); // the latest order, in the folder the call follows or in the session you went to
|
|
461
479
|
const moved = pick && pick.pin ? Math.max(0, ...rows.filter((r) => !same(r, pick)).map((r) => r.asked || 0)) : asked; // pick.pin: a call pinned by a click on its tab (📌) is left for an order typed in another session only; what you type in it keeps it there
|
|
@@ -468,10 +486,11 @@ function currentSession(projFilter, pick, stick) { // pick: { proj, id, since
|
|
|
468
486
|
const consider = (proj, id, m) => { if (!best || m > best.mtime) best = { proj, id, mtime: m }; };
|
|
469
487
|
for (const m of SOURCES) for (const r of guard(() => m.sessions(), [])) if (inScope({ proj: m.PROJ, id: r.id })) consider(m.PROJ, r.id, r.mtime);
|
|
470
488
|
for (const proj of projects()) {
|
|
471
|
-
if (projFilter
|
|
489
|
+
if (projFilter ? proj !== projFilter && !proj.startsWith(projFilter + '-') : !anyTmp && tmpKey(proj)) continue; // the folder itself, or a folder inside it (a Cowork session is in no folder of yours: it counts when the call looks everywhere, or at Cowork)
|
|
472
490
|
for (const { id } of transcripts(proj)) { const m = sessionMtime(proj, id); if (m) consider(proj, id, m); } // 0: a link to a transcript that is gone
|
|
473
491
|
}
|
|
474
|
-
if (!best && projFilter) return { ...currentSession('', null, stick), wide: 1 };
|
|
492
|
+
if (!best && projFilter) return { ...currentSession('', null, stick), wide: 1 };
|
|
493
|
+
if (!best && !projFilter && !anyTmp) return currentSession('', pick, stick, true); // nothing but sessions in the temporary folder: one of them rather than an empty call // nothing in that folder (an editor open on another one than the sessions): the latest of anywhere, and the page is told, so its tabs follow the same rule
|
|
475
494
|
return best ? { ...best, asked } : {}; // a call that is opened while nobody is at work: the session that was written to last
|
|
476
495
|
}
|
|
477
496
|
|
|
@@ -527,7 +546,7 @@ function parseRecord(st, r) {
|
|
|
527
546
|
for (const b of blocks(r)) if (b.type === 'tool_result' && wf) push({ ts, agent, kind: 'wfrun', toolId: b.tool_use_id, run: wf }); // the answer to a Workflow call names the run it started: its agents are in subagents/workflows/<run>/
|
|
528
547
|
for (const b of blocks(r)) if (b.type === 'tool_result' && (st.toolName[b.tool_use_id] === 'Agent' || st.toolName[b.tool_use_id] === 'Task') && !(st.bg && st.bg[b.tool_use_id]) && !/^\s*Async agent launched/i.test(resultText(b.content))) push({ ts, agent, kind: 'agentdone', toolId: b.tool_use_id }); // a synchronous call: the lead got the sub-agent's answer back, so it has finished (async launches answer immediately and are not a completion)
|
|
529
548
|
for (const b of blocks(r)) if (b.type === 'tool_result' && st.toolName[b.tool_use_id] && !NO_RESULT.has(st.toolName[b.tool_use_id])) {
|
|
530
|
-
const n = st.toolName[b.tool_use_id], img = resultImages(b.content).length, files = n === 'Bash' && !b.is_error ? docPaths(resultText(b.content), false).map((f) => absPath(f, r.cwd)) : [], art = !b.is_error && st.pubs && st.pubs.has(b.tool_use_id) ?
|
|
549
|
+
const n = st.toolName[b.tool_use_id], img = resultImages(b.content).length, files = n === 'Bash' && !b.is_error ? docPaths(resultText(b.content), false).map((f) => absPath(f, r.cwd)) : [], art = !b.is_error && st.pubs && st.pubs.has(b.tool_use_id) ? artOf(st, st.pubs.get(b.tool_use_id), r.toolUseResult, resultText(b.content)) : null;
|
|
531
550
|
items.push({ id: b.tool_use_id, err: !!b.is_error, out: clip(resultText(b.content).replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g, '').trimEnd(), RESULT_MAX[n] || (/^mcp__/.test(n) ? 900 : 600)), ...(img ? { img } : {}), ...(files.length ? { files } : {}), ...(art ? { art } : {}) }); // img: how many pictures came back; the page fetches them from /api/media · files: the documents a command says it made
|
|
532
551
|
}
|
|
533
552
|
if (items.length) push({ ts, agent, kind: 'results', items });
|
|
@@ -551,7 +570,7 @@ function parseRecord(st, r) {
|
|
|
551
570
|
else if (b.type === 'tool_use') {
|
|
552
571
|
st.toolName[b.id] = b.name; (st.out = st.out || new Set()).add(b.id); if (b.input && b.input.run_in_background) (st.bg = st.bg || {})[b.id] = true; // out: the calls that have no answer yet
|
|
553
572
|
if (b.name === 'Agent' || b.name === 'Task') push({ ts, agent, kind: 'agentcall', toolId: b.id, bg: !!(b.input && b.input.run_in_background), text: (b.input && b.input.prompt) || '', title: (b.input && b.input.description) || '', ...(b.input && typeof b.input.name === 'string' && b.input.name.trim() ? { nm: b.input.name.trim() } : {}) });
|
|
554
|
-
else { const tool = toolLabel(b, ts); if (tool.d && tool.d.outs) tool.d.outs = tool.d.outs.map((f) => absPath(f, r.cwd)); if (tool.d && tool.d.kind === 'artifact') (st.pubs = st.pubs || new
|
|
573
|
+
else { const tool = toolLabel(b, ts); if (tool.d && tool.d.outs) tool.d.outs = tool.d.outs.map((f) => absPath(f, r.cwd)); if (tool.d && tool.d.kind === 'artifact') (st.pubs = st.pubs || new Map()).set(b.id, tool.d.open ? 'open' : tool.d.doc ? 'doc' : 'pub'); push({ ts, agent, kind: 'tool', tool, ...th() }); st.act = st.raw.length - 1; }
|
|
555
574
|
}
|
|
556
575
|
}
|
|
557
576
|
if (agent === 'main' && (m.stop_reason === 'end_turn' || ((r.isApiErrorMessage || (m.model === '<synthetic>' && m.stop_reason === 'stop_sequence')) && !(st.out && st.out.size)))) { // also a turn that ends on a message Claude Code writes itself, in the place of the model's: the API is down, the limit is reached, the request was refused, or there was nothing to answer. Nothing follows it, unless a call of the lead is still out: the connection dropped while its agents worked, and it goes on when they answer. (A message of the model that a safety check cuts is not the end either: Claude Code tells the model, which goes on.) The lead's turn is over: Claude Code writes one record per content block, each with the message's stop reason, so the mark goes on the line this record carries (a thinking block carries none)
|
|
@@ -806,19 +825,103 @@ const MIME = { '.html': 'text/html', '.js': 'text/javascript', '.css': 'text/css
|
|
|
806
825
|
|
|
807
826
|
// ---- Custom characters: the person's own pixel art replaces the drawn characters. Plain image files in one folder, nothing else is ever served from it.
|
|
808
827
|
// lead.png / claude.png → the lead · you.png → the human · any other image → a pool for the sub-agents · name-talk.png → optional open-mouth frame of name.png
|
|
809
|
-
|
|
828
|
+
// name-bg.png → optional room of name.png: the whole picture behind it, desk included (its bottom sixth is drawn again in front of the character)
|
|
829
|
+
// name-head.png → optional head of name.png, drawn above it and nodding while it speaks: name.png is then the body, and name-talk.png the head with its mouth open
|
|
830
|
+
// name-hands.png → optional hands of name.png, on their own: they type while the agent works · name-desk.png, name-desk-dark.png… → optional laptops of name.png, drawn over its hands:
|
|
831
|
+
// the page gives each agent one of them, out now and then for a few seconds (all the time with ⚙ → Characters → laptop)
|
|
832
|
+
// name+hat-1.png, name+hat-2.png, name+glasses-1.png… → optional extras of name.png, by kind (the word after the +): pictures drawn over it. Each agent that gets this character wears one of each kind or none,
|
|
833
|
+
// so one character becomes many: it is the one given again when there are more agents than characters
|
|
834
|
+
// an extra whose kind starts with "sticker" (name+sticker1-2.png) is worn by the thing on the desk, not by the character: drawn over the laptop, under the hands
|
|
835
|
+
const CHAR_NAME = /^[\w][\w .()+\-]{0,78}\.(png|gif|webp|jpe?g)$/i, CHAR_MAX = 300 * 1024, CHAR_TYPES = { png: 'image/png', gif: 'image/gif', webp: 'image/webp', jpg: 'image/jpeg', jpeg: 'image/jpeg' };
|
|
810
836
|
const charactersDir = () => process.env.AGENT_STANDUP_CHARACTERS || path.join(os.homedir(), '.agent-standup', 'characters');
|
|
811
837
|
// lstat, not stat: a symlink is not a regular file, so it is skipped and never served
|
|
812
838
|
// Built-in character packs, shipped with the app (examples/<folder>): picked in ⚙ → Characters. examples/characters stays in the repository as a model for one's own folder; it is not shipped
|
|
813
|
-
const PACKS = { cats: 'cats'
|
|
839
|
+
const PACKS = { cats: 'cats', vampire: 'vampire' }; // vampire: the one character of the Halloween pack that everyone gets, as the human (see the page's charYou)
|
|
840
|
+
// Packs sold in the shop of the website (api/ in the repository): their pictures are neither in the app nor in the repository. A bought pack is unpacked in the packs folder and is then a pack like a built-in one.
|
|
841
|
+
const SHOP_PACKS = { halloween: { price: '2 €', artist: 'Fabien Coupas', artistUrl: 'https://www.instagram.com/fabien_coupas/' } }, // the artist is credited wherever the pack is shown
|
|
842
|
+
PACK_MAX = 20 * 1024 * 1024;
|
|
843
|
+
const shopUrl = () => (process.env.AGENT_STANDUP_STORE || 'https://agent-standup.com').replace(/\/+$/, ''), packsDir = () => process.env.AGENT_STANDUP_PACKS || path.join(os.homedir(), '.agent-standup', 'packs');
|
|
844
|
+
const hasOwn = (o, k) => Object.prototype.hasOwnProperty.call(o, k); // its own names only: 'constructor' or 'toString' is not a pack (they answered 500)
|
|
845
|
+
const packDir = (name) => (hasOwn(PACKS, name) ? path.join(__dirname, 'examples', PACKS[name]) : hasOwn(SHOP_PACKS, name) ? path.join(packsDir(), name) : null);
|
|
814
846
|
function listCharacters(pack) {
|
|
815
847
|
const dir = pack ? packDir(pack) : charactersDir(); let names = []; if (!dir) return { dir: '', max: CHAR_MAX, chars: [] }; try { names = fs.readdirSync(dir); } catch {}
|
|
816
|
-
const ok = names.filter((f) => CHAR_NAME.test(f)).filter((f) => { try { const st = fs.lstatSync(path.join(dir, f)); return st.isFile() && st.size <= CHAR_MAX; } catch { return false; } }).slice(0,
|
|
848
|
+
const ok = names.filter((f) => CHAR_NAME.test(f)).filter((f) => { try { const st = fs.lstatSync(path.join(dir, f)); return st.isFile() && st.size <= CHAR_MAX; } catch { return false; } }).sort().slice(0, 200);
|
|
817
849
|
const stem = (f) => f.replace(/\.[^.]+$/, ''), by = new Map(ok.map((f) => [stem(f).toLowerCase(), f]));
|
|
818
|
-
const
|
|
819
|
-
|
|
850
|
+
const extra = (f) => stem(f).match(/^(.+)\+([a-z]+\d*)[-_ ]?\w*$/i); // the kind may end with a number: sticker1, sticker2… are kinds of their own
|
|
851
|
+
const layer = (f) => { const m = stem(f).match(/^(.+)-(bg|head|hands|desk(-\w+)?)$/i); return !!(m && by.has(m[1].toLowerCase())); }; // a layer only when its character is there: help-desk.png alone is a character
|
|
852
|
+
const chars = ok.filter((f) => !/-talk$/i.test(stem(f)) && !layer(f) && !extra(f)).map((f) => { const st = stem(f), l = st.toLowerCase(), extras = {};
|
|
853
|
+
for (const x of ok) { const m = extra(x), k = m && m[1].toLowerCase() === l ? m[2].toLowerCase() : ''; if (k) (extras[k] = extras[k] || []).push(x); }
|
|
854
|
+
return { stem: st, file: f, talk: by.get(l + '-talk') || null, bg: by.get(l + '-bg') || null, desks: ok.filter((x) => { const s = stem(x).toLowerCase(); return s === l + '-desk' || s.startsWith(l + '-desk-'); }), head: by.get(l + '-head') || null, hands: by.get(l + '-hands') || null, extras: Object.keys(extras).length ? extras : null, role: /^(lead|claude)$/.test(l) ? 'lead' : /^(you|human|user)$/.test(l) ? 'you' : 'agent' }; }).sort((a, b) => a.stem.localeCompare(b.stem));
|
|
820
855
|
return { dir, max: CHAR_MAX, chars };
|
|
821
856
|
}
|
|
857
|
+
// ---- Buying a pack. The app never sees a card: it asks the shop for a payment page (Stripe's), opens it in the browser, then asks the shop for the pack with the code of that purchase until the shop,
|
|
858
|
+
// which asks Stripe, says it is paid. The code is kept beside the packs: it is the proof of the purchase, and what installs the pack on another computer. Nothing else is sent, and nothing is asked again once the pack is here.
|
|
859
|
+
const codesFile = () => path.join(packsDir(), 'codes.json');
|
|
860
|
+
const readCodes = () => { try { const v = JSON.parse(fs.readFileSync(codesFile(), 'utf8')); return v && typeof v === 'object' && !Array.isArray(v) ? v : {}; } catch { return {}; } };
|
|
861
|
+
const writeCode = (name, v) => { const all = readCodes(); all[name] = v; fs.mkdirSync(packsDir(), { recursive: true }); const tmp = codesFile() + '.' + process.pid + '.tmp'; fs.writeFileSync(tmp, JSON.stringify(all, null, 1), { mode: 0o600 }); fs.renameSync(tmp, codesFile()); };
|
|
862
|
+
const packList = () => [...Object.keys(PACKS).map((name) => ({ name, n: listCharacters(name).chars.length })),
|
|
863
|
+
...Object.keys(SHOP_PACKS).map((name) => { const c = readCodes()[name] || {}; return { name, n: listCharacters(name).chars.length, shop: true, price: SHOP_PACKS[name].price, artist: SHOP_PACKS[name].artist || '', artistUrl: SHOP_PACKS[name].artistUrl || '', code: c.short || c.code || '', waiting: !!(c.pending && c.pending.length) }; })]; // the code shown is the one for people when there is one
|
|
864
|
+
// A pack arrives as a zip of plain image files, read here without a library: stored or deflated entries only, kept under their bare name and only if a characters folder would accept that name, each within the size of a character.
|
|
865
|
+
function unzipImages(buf) {
|
|
866
|
+
let e = buf.length - 22; while (e >= 0 && buf.readUInt32LE(e) !== 0x06054b50) e--; if (e < 0) throw new Error('not a zip');
|
|
867
|
+
const n = buf.readUInt16LE(e + 10), out = []; let p = buf.readUInt32LE(e + 16); if (n > 400) throw new Error('too many files');
|
|
868
|
+
for (let i = 0; i < n; i++) {
|
|
869
|
+
if (p + 46 > buf.length || buf.readUInt32LE(p) !== 0x02014b50) throw new Error('bad zip');
|
|
870
|
+
const method = buf.readUInt16LE(p + 10), csize = buf.readUInt32LE(p + 20), size = buf.readUInt32LE(p + 24), nl = buf.readUInt16LE(p + 28), off = buf.readUInt32LE(p + 42), name = buf.toString('utf8', p + 46, p + 46 + nl).split(/[\\/]/).pop();
|
|
871
|
+
p += 46 + nl + buf.readUInt16LE(p + 30) + buf.readUInt16LE(p + 32);
|
|
872
|
+
const note = /^(LICEN[CS]E|README)\.txt$/i.test(name); if (!note && !CHAR_NAME.test(name)) continue; // a folder, a hidden file, anything that is not a picture or the pack's two notes: left out
|
|
873
|
+
if (size > (note ? 65536 : CHAR_MAX) || off + 30 > buf.length) throw new Error('bad entry: ' + name);
|
|
874
|
+
const from = off + 30 + buf.readUInt16LE(off + 26) + buf.readUInt16LE(off + 28), raw = buf.subarray(from, from + csize);
|
|
875
|
+
const data = method === 0 ? raw : method === 8 ? zlib.inflateRawSync(raw, { maxOutputLength: CHAR_MAX }) : null; if (!data || data.length !== size) throw new Error('bad entry: ' + name);
|
|
876
|
+
if (!out.some((f) => f.name.toLowerCase() === name.toLowerCase())) out.push({ name, data });
|
|
877
|
+
}
|
|
878
|
+
if (!out.some((f) => CHAR_NAME.test(f.name))) throw new Error('no picture in the pack');
|
|
879
|
+
return out.slice(0, 200);
|
|
880
|
+
}
|
|
881
|
+
// ---- Pictures added from the page (⚙ → Characters → My folder): written in the characters folder under the name of their role, or under their own name for a sub-agent.
|
|
882
|
+
// The picture a new one replaces is moved to a "replaced" folder beside it, never deleted, and nothing but the four image types is written.
|
|
883
|
+
const IMG_MAGIC = [['png', (b) => b.length > 8 && b.readUInt32BE(0) === 0x89504e47], ['gif', (b) => b.toString('latin1', 0, 4) === 'GIF8'], ['webp', (b) => b.toString('latin1', 0, 4) === 'RIFF' && b.toString('latin1', 8, 12) === 'WEBP'], ['jpg', (b) => b[0] === 0xff && b[1] === 0xd8 && b[2] === 0xff]];
|
|
884
|
+
const ROLE_FILES = { you: 'you', 'you-talk': 'you-talk', lead: 'lead', 'lead-talk': 'lead-talk' };
|
|
885
|
+
function putAside(dir, stem) { // the pictures of this name, whatever their type, go to dir/replaced/ under a name that says when
|
|
886
|
+
let names = []; try { names = fs.readdirSync(dir); } catch {} const stamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
887
|
+
for (const f of names) if (CHAR_NAME.test(f) && f.replace(/\.[^.]+$/, '').toLowerCase() === stem) { fs.mkdirSync(path.join(dir, 'replaced'), { recursive: true }); fs.renameSync(path.join(dir, f), path.join(dir, 'replaced', stamp + ' ' + f)); }
|
|
888
|
+
}
|
|
889
|
+
function addCharacter(role, name, b64) { // → { file } or throws a word the page can say: 'type', 'size', 'name'
|
|
890
|
+
const data = Buffer.from(String(b64 || ''), 'base64'), type = (IMG_MAGIC.find(([, ok]) => ok(data)) || [])[0]; if (!type) throw Object.assign(new Error('type'), { word: 'type' }); if (data.length > CHAR_MAX) throw Object.assign(new Error('size'), { word: 'size' });
|
|
891
|
+
const dir = charactersDir(); fs.mkdirSync(dir, { recursive: true });
|
|
892
|
+
let stem = ROLE_FILES[role]; if (!stem) { stem = String(name || '').replace(/\.[^.]*$/, '').replace(/[^\w .()\-]+/g, ' ').trim().slice(0, 60).replace(/^[^\w]+/, '') || 'agent'; if (/^(lead|claude|you|human|user)(-talk)?$/i.test(stem) || /-(talk|bg|head|hands|desk(-\w+)?)$/i.test(stem)) stem += ' 2'; } // a sub-agent never takes the name of a role
|
|
893
|
+
const file = stem + '.' + type; if (!CHAR_NAME.test(file)) throw Object.assign(new Error('name'), { word: 'name' });
|
|
894
|
+
if (!ROLE_FILES[role]) { let k = 2, f = file; while (fs.existsSync(path.join(dir, f))) f = `${stem} ${k++}.${type}`; fs.writeFileSync(path.join(dir, f), data); return { file: f }; } // a sub-agent's picture never replaces another one
|
|
895
|
+
putAside(dir, stem.toLowerCase()); if (!/-talk$/.test(stem)) for (const s of ['-talk', '-head', '-hands', '-bg', '-desk', '-desk-dark']) putAside(dir, stem + s); // a new face: the old open mouth and layers go aside with the old picture
|
|
896
|
+
fs.writeFileSync(path.join(dir, file), data); return { file };
|
|
897
|
+
}
|
|
898
|
+
function removeCharacter(file) { // moved to replaced/, with its open mouth and its room; only a picture the folder lists
|
|
899
|
+
const f = String(file || ''), dir = charactersDir(); if (!CHAR_NAME.test(f) || !listCharacters('').chars.some((c) => c.file === f)) return false;
|
|
900
|
+
const stem = f.replace(/\.[^.]+$/, '').toLowerCase(); for (const s of [stem, stem + '-talk', stem + '-head', stem + '-bg', stem + '-desk', stem + '-desk-dark', stem + '-hands']) putAside(dir, s); return true;
|
|
901
|
+
}
|
|
902
|
+
function installPack(name, zip) { // written beside its place first, then swapped in: a pack is never half there
|
|
903
|
+
const files = unzipImages(zip), dir = packDir(name), tmp = dir + '.' + process.pid + '.tmp'; fs.rmSync(tmp, { recursive: true, force: true }); fs.mkdirSync(tmp, { recursive: true });
|
|
904
|
+
for (const f of files) fs.writeFileSync(path.join(tmp, f.name), f.data); fs.rmSync(dir, { recursive: true, force: true }); fs.renameSync(tmp, dir);
|
|
905
|
+
}
|
|
906
|
+
const askShop = (p, body) => fetch(shopUrl() + p, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body), signal: AbortSignal.timeout(30000) });
|
|
907
|
+
async function buyPack(name) { // → { status, url } the payment page to open, or { status, error }
|
|
908
|
+
let r; try { r = await askShop('/api/checkout', { pack: name }); } catch { return { status: 502, error: 'offline' }; }
|
|
909
|
+
const j = await r.json().catch(() => ({})); if (!r.ok) return { status: r.status, error: j.error || 'shop' };
|
|
910
|
+
if (typeof j.url !== 'string' || typeof j.code !== 'string' || !/^(https:\/\/|http:\/\/localhost[:/])/.test(j.url)) return { status: 502, error: 'shop' };
|
|
911
|
+
const c = readCodes()[name] || {}, pending = [j.code, ...(c.pending || [])].slice(0, 5), short = typeof j.short === 'string' && /^[A-Z]{2}-[\w-]{9}$/.test(j.short) ? j.short : '';
|
|
912
|
+
writeCode(name, { code: c.code || '', short: c.short || '', pending, shorts: Object.fromEntries(pending.map((k) => [k, k === j.code ? short : (c.shorts || {})[k] || ''])) }); return { status: 200, url: j.url }; // shorts: the code for people (HW-…) of each payment page opened // a few, in case the button was pressed more than once: any of them may be the one that gets paid
|
|
913
|
+
}
|
|
914
|
+
async function claimPack(name, typed) { // typed: a code the person pastes (another computer); else the purchases started here
|
|
915
|
+
const c = readCodes()[name] || {}, tries = typed ? [typed] : [c.code, ...(c.pending || [])].filter(Boolean); if (!tries.length) return { status: 400, error: 'code' };
|
|
916
|
+
let last = { status: 402, error: 'unpaid' };
|
|
917
|
+
for (const code of tries) {
|
|
918
|
+
let r; try { r = await askShop('/api/pack', { pack: name, code }); } catch { return { status: 502, error: 'offline' }; }
|
|
919
|
+
if (r.ok) { const zip = Buffer.from(await r.arrayBuffer()); if (zip.length > PACK_MAX) return { status: 502, error: 'shop' }; try { installPack(name, zip); } catch (e) { logError('pack ' + name, e); return { status: 502, error: 'shop' }; }
|
|
920
|
+
writeCode(name, { code, short: (c.shorts || {})[code] || (/^[A-Z]{2}-/i.test(code) ? code.toUpperCase() : c.short || ''), pending: [] }); return { status: 200, ok: true, n: listCharacters(name).chars.length }; }
|
|
921
|
+
last = { status: r.status, error: (await r.json().catch(() => ({}))).error || 'shop' }; if (r.status !== 402 && r.status !== 404) break; // not paid yet, or not a purchase of this pack: the next one may be; anything else is the shop's trouble
|
|
922
|
+
}
|
|
923
|
+
return last;
|
|
924
|
+
}
|
|
822
925
|
// ---- Shared files: a file the session created is shown in its folder (Finder, Explorer, the file manager) when the page asks. Only a file a Write call of that very session names, and only if it is still there:
|
|
823
926
|
// the page cannot have any other path opened, nothing is read and nothing is run. A Codex or Vibe session may name a file from the folder it was started in.
|
|
824
927
|
// The same goes for a document one of its commands names (an export, a report made by a script), from the moment that command started: an older file by that name is not one of its files.
|
|
@@ -856,11 +959,11 @@ function start(port = PORT) {
|
|
|
856
959
|
const sendFile = (fp) => { const s = fs.createReadStream(fp); s.on('error', () => res.destroy()); s.pipe(res); }; // a file that vanished between the check and the read ends this answer, not the server
|
|
857
960
|
// Endpoints with side effects (they spawn programs or claim the sound), and the one that serves pictures from a session, refuse requests that a browser marks as coming from another site, e.g. an <img> on a web page.
|
|
858
961
|
const sfs = req.headers['sec-fetch-site'];
|
|
859
|
-
if (sfs && sfs !== 'same-origin' && sfs !== 'none' && (req.method !== 'GET' || ['/api/translate', '/api/quips', '/api/warm', '/api/audio', '/api/tts', '/api/prefs', '/api/prefs.js', '/api/voices', '/api/kokoro', '/api/kokoro/install', '/api/media', '/api/artifact', '/api/errors'].includes(url.pathname))) { res.writeHead(403); return res.end('forbidden'); }
|
|
860
|
-
const readBody = (cb) => { // request bodies are small JSON: stop reading beyond 256 KB and give up after 10 s
|
|
962
|
+
if (sfs && sfs !== 'same-origin' && sfs !== 'none' && (req.method !== 'GET' || ['/api/translate', '/api/quips', '/api/warm', '/api/audio', '/api/tts', '/api/prefs', '/api/prefs.js', '/api/voices', '/api/kokoro', '/api/kokoro/install', '/api/media', '/api/artifact', '/api/errors', '/api/packs'].includes(url.pathname))) { res.writeHead(403); return res.end('forbidden'); }
|
|
963
|
+
const readBody = (cb, max = 262144) => { // request bodies are small JSON: stop reading beyond 256 KB (or max) and give up after 10 s
|
|
861
964
|
const chunks = []; let size = 0, over = false; req.setTimeout(10000, () => req.destroy());
|
|
862
|
-
if (+req.headers['content-length'] >
|
|
863
|
-
req.on('data', (d) => { if (over) return; size += d.length; if (size >
|
|
965
|
+
if (+req.headers['content-length'] > max) { res.writeHead(413); res.end('too large'); return req.destroy(); }
|
|
966
|
+
req.on('data', (d) => { if (over) return; size += d.length; if (size > max) { over = true; res.writeHead(413); res.end('too large'); req.destroy(); } else chunks.push(d); }); // bytes, not characters
|
|
864
967
|
req.on('end', () => { if (!over) cb(Buffer.concat(chunks).toString('utf8')); });
|
|
865
968
|
};
|
|
866
969
|
const textList = (x) => (Array.isArray(x) ? x : []).slice(0, 200).map((t) => String(t).slice(0, 2000));
|
|
@@ -901,7 +1004,13 @@ function start(port = PORT) {
|
|
|
901
1004
|
if (url.pathname === '/api/current') { const q = (k) => url.searchParams.get(k) || ''; return json(currentSession(q('proj'), q('pid') ? { proj: q('pproj'), id: q('pid'), since: q('since') ? +q('since') : NaN, pin: q('pin') === '1' } : null, { proj: q('sproj'), id: q('sid') })); }
|
|
902
1005
|
if (url.pathname === '/api/board') return json(boardRows());
|
|
903
1006
|
if (url.pathname === '/api/characters') return json(listCharacters(url.searchParams.get('pack') || ''));
|
|
904
|
-
if (url.pathname === '/api/
|
|
1007
|
+
if (url.pathname === '/api/characters/add' && req.method === 'POST') return readBody((body) => { try { const b = JSON.parse(body || '{}') || {}; json(addCharacter(String(b.role || ''), b.name, b.data)); } catch (e) { if (!e.word) logError('add character', e); json({ error: e.word || 'write' }, e.word ? 400 : 500); } }, 512 * 1024); // a picture of 300 KB is 400 KB once written as text
|
|
1008
|
+
if (url.pathname === '/api/characters/remove' && req.method === 'POST') return readBody((body) => { let b = {}; try { b = JSON.parse(body || '{}') || {}; } catch {} try { json(removeCharacter(b.file) ? { ok: true } : { error: 'file' }, 200); } catch (e) { logError('remove character', e); json({ error: 'write' }, 500); } });
|
|
1009
|
+
if (url.pathname === '/api/packs') return json(packList());
|
|
1010
|
+
if ((url.pathname === '/api/packs/buy' || url.pathname === '/api/packs/claim') && req.method === 'POST') return readBody((body) => {
|
|
1011
|
+
let b = {}; try { b = JSON.parse(body || '{}') || {}; } catch {} const name = String(b.pack || ''); if (!hasOwn(SHOP_PACKS, name)) return json({ error: 'pack' }, 404);
|
|
1012
|
+
(url.pathname.endsWith('/buy') ? buyPack(name) : claimPack(name, typeof b.code === 'string' ? b.code.trim().slice(0, 260) : '')).then((r) => json(r, r.status), (e) => { logError('shop', e); json({ error: 'shop' }, 500); });
|
|
1013
|
+
});
|
|
905
1014
|
if (url.pathname === '/api/reveal' && req.method === 'POST') return readBody((body) => { // 404: not a file this session created · 410: created, and no longer there
|
|
906
1015
|
try {
|
|
907
1016
|
let b = null; try { b = JSON.parse(body); } catch {} const SAFE = /^[\w.\-]+$/, ok = (v) => typeof v === 'string' && SAFE.test(v) && v !== '..' && v.length <= 200;
|
|
@@ -961,7 +1070,7 @@ function start(port = PORT) {
|
|
|
961
1070
|
} catch (e) { logError(req.method + ' ' + url.pathname, e); if (res.headersSent) return res.destroy(); json({ error: String(e.message || e) }, 500); }
|
|
962
1071
|
}).listen(port, '127.0.0.1', function () { console.log(`Agent Standup → http://localhost:${this.address().port}`); });
|
|
963
1072
|
}
|
|
964
|
-
module.exports = { start, currentSession, shutdown, findClaude, bundledClaude, boardRows, sessionRows: listSessions, charactersDir, listCharacters, logError, _reveal: reveal, _scrub: { tidy, homeRe }, _artifact: { page: artifactPage, csp: artifactCsp } };
|
|
1073
|
+
module.exports = { start, currentSession, shutdown, findClaude, bundledClaude, boardRows, sessionRows: listSessions, charactersDir, listCharacters, packsDir, installPack, logError, _reveal: reveal, _scrub: { tidy, homeRe }, _artifact: { page: artifactPage, csp: artifactCsp } };
|
|
965
1074
|
if (require.main === module) {
|
|
966
1075
|
start().on('error', (e) => {
|
|
967
1076
|
console.error(e.code === 'EADDRINUSE' ? `Port ${PORT} is already in use (maybe Agent Standup is already running, e.g. inside VS Code). Try: PORT=4790 node server.js` : String(e));
|