diff --git a/packages/agent-office/CHANGELOG.md b/packages/agent-office/CHANGELOG.md index 69c74a6..09cd808 100644 --- a/packages/agent-office/CHANGELOG.md +++ b/packages/agent-office/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.3.0 · 2026-11-02 + +### Added + +- Library, cyberlab, greenhouse, arctic and rainy night scenes with themed 3D decorations. + ## 0.2.4 · 2026-11-01 ### Fixed diff --git a/packages/agent-office/README.md b/packages/agent-office/README.md index be8353b..d465629 100644 --- a/packages/agent-office/README.md +++ b/packages/agent-office/README.md @@ -126,7 +126,7 @@ bun bin/agent-office.mjs --json # 一次性快照,适合让 Agent 在聊天 |---|---| | `mode` | `office` 或 `list` | | `dim` | `3d`(WebGL)、`iso`(等距画布)或 `2d`(俯视) | -| `scene` | `office`、`station`、`cafe`、`castle`、`pirate`、`graveyard` | +| `scene` | `office`、`station`、`cafe`、`castle`、`pirate`、`graveyard`、`library`、`cyberlab`、`greenhouse`、`arctic`、`rainynight` | | `quality` | `low`、`medium`、`high`(3D 阴影与 DPR) | | `showDone` | 保留已完成的 Agent | | `hideAfter` | 完成后多久离开:`1h`、`6h`、`24h`、`never` | diff --git a/packages/agent-office/cli.test.mjs b/packages/agent-office/cli.test.mjs index 68eabff..90ad3cb 100644 --- a/packages/agent-office/cli.test.mjs +++ b/packages/agent-office/cli.test.mjs @@ -119,7 +119,7 @@ test("the authenticated standalone page, bridge, live data and JSON options work try { const ping = await (await fetch(s.url + "api/ping")).json() expect(ping.name).toBe("agent-office") - expect(ping.version).toBe("0.2.4") + expect(ping.version).toBe("0.3.0") const page = await fetch(s.url) expect(page.status).toBe(200) expect(await page.text()).toContain('src="_magpie/bridge.js"') diff --git a/packages/agent-office/package.json b/packages/agent-office/package.json index 6cd7156..2ccd828 100644 --- a/packages/agent-office/package.json +++ b/packages/agent-office/package.json @@ -1,7 +1,7 @@ { "name": "@magpie-community/page-agent-office", - "version": "0.2.4", - "description": "我的 Agent 在干嘛:读取本机 Claude Code、Codex、Copilot CLI、Kimi Code、DeepSeek Harness、Gemini CLI、Qwen Code、Pi、omp、Qoder、WorkBuddy、CodeBuddy、Grok Build 的会话文件,把每个会话画成真 3D / 等距 / 2D 办公室里的小人,或分组工作台。Live agent activity dashboard for magpie, with a real WebGL office and six scenes.", + "version": "0.3.0", + "description": "我的 Agent 在干嘛:读取本机 Claude Code、Codex、Copilot CLI、Kimi Code、DeepSeek Harness、Gemini CLI、Qwen Code、Pi、omp、Qoder、WorkBuddy、CodeBuddy、Grok Build 的会话文件,把每个会话画成真 3D / 等距 / 2D 办公室里的小人,或分组工作台。Live agent activity dashboard for magpie, with a real WebGL office and eleven scenes.", "type": "module", "files": [ "page/index.html", diff --git a/packages/agent-office/page/app.js b/packages/agent-office/page/app.js index 64f6bfe..f363fae 100644 --- a/packages/agent-office/page/app.js +++ b/packages/agent-office/page/app.js @@ -24,10 +24,12 @@ let themeLang = theme.lang let opts = {} try { opts = (await magpie.options.get()) || {} } catch {} + // ISO and 2D keep their original palette for the six original scenes; only the new ones are themed. + const NEW_CANVAS_THEMES = ["library", "cyberlab", "greenhouse", "arctic", "rainynight"] const view = { mode: opts.mode === "list" ? "list" : "office", dim: ["2d", "iso", "3d"].includes(opts.dim) ? opts.dim : "3d", - scene: ["office", "station", "cafe", "castle", "pirate", "graveyard"].includes(opts.scene) ? opts.scene : "office", + scene: (Scene3D?.SCENE_IDS || ["office", "station", "cafe", "castle", "pirate", "graveyard"]).includes(opts.scene) ? opts.scene : "office", quality: ["low", "medium", "high"].includes(opts.quality) ? opts.quality : "medium", demo: opts.demo === true, showDone: opts.showDone !== false, @@ -85,7 +87,7 @@ syncLangSelect() if (typeof scene2 !== "undefined") scene2.lang = lang if ($("optScene")) { - for (const option of $("optScene").options) option.textContent = t()["scene" + ({office:"Office",station:"Station",cafe:"Cafe",castle:"Castle",pirate:"Pirate",graveyard:"Graveyard"})[option.value]] + for (const option of $("optScene").options) option.textContent = t()["scene" + ({office:"Office",station:"Station",cafe:"Cafe",castle:"Castle",pirate:"Pirate",graveyard:"Graveyard",library:"Library",cyberlab:"Cyberlab",greenhouse:"Greenhouse",arctic:"Arctic",rainynight:"Rainynight"})[option.value]] } } @@ -172,6 +174,7 @@ if (scene3) scene3.stop() scene = scene2 office2.hidden = false; office3.hidden = true + scene2.theme = NEW_CANVAS_THEMES.includes(view.scene) ? Scene3D?.SCENES?.[view.scene] : null scene2.setDim(view.dim === "2d" ? "2d" : "3d") return scene2 } @@ -1088,6 +1091,8 @@ const SCENE_OPTIONS = [ ["office", "sceneOffice"], ["station", "sceneStation"], ["cafe", "sceneCafe"], ["castle", "sceneCastle"], ["pirate", "scenePirate"], ["graveyard", "sceneGraveyard"], + ["library", "sceneLibrary"], ["cyberlab", "sceneCyberlab"], ["greenhouse", "sceneGreenhouse"], + ["arctic", "sceneArctic"], ["rainynight", "sceneRainynight"], ] if ($("optScene")) { $("optScene").replaceChildren(...SCENE_OPTIONS.map(([id, name]) => { const o = el("option", "", t()[name]); o.value = id; return o })) diff --git a/packages/agent-office/page/model.js b/packages/agent-office/page/model.js index e78485b..d6da89c 100644 --- a/packages/agent-office/page/model.js +++ b/packages/agent-office/page/model.js @@ -282,6 +282,11 @@ "Castle", "Pirate cove", "Haunted hollow", + "Library", + "Cyberlab", + "Greenhouse", + "Arctic base", + "Rainy night", "Low", "Medium", "High", @@ -301,6 +306,11 @@ "城堡", "海盗湾", "幽灵谷", + "图书馆", + "赛博实验室", + "温室", + "极地", + "雨夜", "低", "中", "高", @@ -320,6 +330,11 @@ "城堡", "海盜灣", "幽靈谷", + "圖書館", + "賽博實驗室", + "溫室", + "極地", + "雨夜", "低", "中", "高", @@ -339,6 +354,11 @@ "城", "海賊の入り江", "幽霊の谷", + "図書館", + "サイバーラボ", + "温室", + "極地", + "雨の夜", "低", "中", "高", @@ -358,6 +378,11 @@ "성", "해적 만", "유령 골짜기", + "도서관", + "사이버랩", + "온실", + "극지", + "비 오는 밤", "낮음", "중간", "높음", @@ -377,6 +402,11 @@ "Castillo", "Bahía pirata", "Valle encantado", + "Biblioteca", + "Cibelaboratorio", + "Invernadero", + "Ártico", + "Noche de lluvia", "Baja", "Media", "Alta", @@ -396,6 +426,11 @@ "Château", "Baie pirate", "Vallée hantée", + "Bibliothèque", + "Cyberlabo", + "Serre", + "Arctique", + "Nuit pluvieuse", "Basse", "Moyenne", "Haute", @@ -415,6 +450,11 @@ "Burg", "Piratenbucht", "Geistertal", + "Bibliothek", + "Cyberlabor", + "Gewächshaus", + "Arktis", + "Regennacht", "Niedrig", "Mittel", "Hoch", @@ -434,6 +474,11 @@ "Castelo", "Baía pirata", "Vale assombrado", + "Biblioteca", + "Ciberlaboratório", + "Estufa", + "Ártico", + "Noite chuvosa", "Baixa", "Média", "Alta", @@ -458,7 +503,7 @@ de: { jumpTo: "↗ {n}", jumpingTo: "↗ Öffne {n}…", jumpFail: "Wechsel fehlgeschlagen · erneut", host: "Host: {n}", jumpTip: "Zum Terminal-Tab, Pane oder Fenster dieser Sitzung wechseln (oder Doppelklick)" }, pt: { jumpTo: "↗ {n}", jumpingTo: "↗ Abrindo {n}…", jumpFail: "Falha ao abrir · tente novamente", host: "Host: {n}", jumpTip: "Alternar para a aba, painel ou janela onde esta sessão está rodando (ou clique duplo)" }, } - const EXTRA_KEYS = ["sceneOffice", "sceneStation", "sceneCafe", "sceneCastle", "scenePirate", "sceneGraveyard", "qLow", "qMedium", "qHigh", "webglFallback", "you", "venueReading", "venueArcade", "venueMeeting", "venuePingpong", "venueCoffee", "stationSign"] + const EXTRA_KEYS = ["sceneOffice", "sceneStation", "sceneCafe", "sceneCastle", "scenePirate", "sceneGraveyard", "sceneLibrary", "sceneCyberlab", "sceneGreenhouse", "sceneArctic", "sceneRainynight", "qLow", "qMedium", "qHigh", "webglFallback", "you", "venueReading", "venueArcade", "venueMeeting", "venuePingpong", "venueCoffee", "stationSign"] for (const [code, values] of Object.entries(EXTRA_TEXT)) EXTRA_KEYS.forEach((key, i) => { TEXT[code][key] = values[i] }) for (const [code, map] of Object.entries(JUMP_TEXT)) Object.assign(TEXT[code], map) const LANGS = ["en", "zh-CN", "zh-TW", "ja", "ko", "es", "fr", "de", "pt"] diff --git a/packages/agent-office/page/scene.js b/packages/agent-office/page/scene.js index 65f1280..5baafc1 100644 --- a/packages/agent-office/page/scene.js +++ b/packages/agent-office/page/scene.js @@ -623,7 +623,7 @@ } floor() { - const dark = "#262932", light = "#2d313b" + const dark = this.theme ? shade(this.theme.floor, -0.08) : "#262932", light = this.theme ? this.theme.floor : "#2d313b" for (let x = 0; x < ROOM.w; x++) for (let y = 0; y < ROOM.d; y++) { const P = (a, b) => this.P(a, b, 0) this.poly([P(x, y), P(x + 1, y), P(x + 1, y + 1), P(x, y + 1)], (x + y) % 2 ? dark : light) @@ -683,8 +683,8 @@ const H = ROOM.wall const day = this.dayState || dayPhase() if (this.dim !== "3d") { - this.box(-0.35, -0.35, 0, ROOM.w + 0.35, 0.35, 0.9, "#9aa1ad") - this.box(-0.35, 0, 0, 0.35, ROOM.d, 0.9, "#8a919c") + this.box(-0.35, -0.35, 0, ROOM.w + 0.35, 0.35, 0.9, this.theme?.wall || "#9aa1ad") + this.box(-0.35, 0, 0, 0.35, ROOM.d, 0.9, this.theme?.wall || "#8a919c") return } const g = this.g @@ -702,7 +702,7 @@ for (const p of pts.slice(1)) g.lineTo(p[0], p[1]) g.closePath() } - g.fillStyle = "#c9ccd3" + g.fillStyle = this.theme?.wall || "#c9ccd3" g.fill("evenodd") g.restore() for (const [a, b] of wins) { @@ -714,7 +714,7 @@ this.poly([this.P(0, -0.25, H), this.P(ROOM.w, -0.25, H), this.P(ROOM.w, 0, H), this.P(0, 0, H)], "#e6e8ec") // the left wall (x = 0): the airlock and small portholes const left = (y0, y1, z0, z1) => [this.P(0, y0, z0), this.P(0, y1, z0), this.P(0, y1, z1), this.P(0, y0, z1)] - this.poly(left(0, ROOM.d, 0, H), "#a9aeb8") + this.poly(left(0, ROOM.d, 0, H), this.theme?.wall || "#a9aeb8") this.poly(left(0, ROOM.d, 0, 0.32), "#80868f") this.poly([this.P(-0.25, 0, H), this.P(0, 0, H), this.P(0, ROOM.d, H), this.P(-0.25, ROOM.d, H)], "#d7d9de") // airlock door @@ -774,8 +774,8 @@ const who = this.atSeat?.[i] add(dk.x, dk.y, dk.w, dk.d, () => { // desk - S.box(dk.x, dk.y, 0, dk.w, dk.d, 0.62, "#e5e7eb") - S.box(dk.x + 0.06, dk.y + 0.06, 0.62, dk.w - 0.12, dk.d - 0.12, 0.05, "#f6c453") + S.box(dk.x, dk.y, 0, dk.w, dk.d, 0.62, S.theme?.wood || "#e5e7eb") + S.box(dk.x + 0.06, dk.y + 0.06, 0.62, dk.w - 0.12, dk.d - 0.12, 0.05, S.theme?.desk || "#f6c453") // The monitor stands on the desk's far edge and its screen faces // the sitter: a north-facing sitter reads the +y face, a // south-facing one the -y face. diff --git a/packages/agent-office/page/scene3d.js b/packages/agent-office/page/scene3d.js index aab5deb..1d5d158 100644 --- a/packages/agent-office/page/scene3d.js +++ b/packages/agent-office/page/scene3d.js @@ -227,9 +227,44 @@ fog: "#05070b", ambient: "#cfd6e8", props: ["tombstones", "deadtrees", "candles", "bookshelf", "arcade"], }, + library: { + id: "library", label: "Library", note: "twilight reading hall", + floor: "#554438", floorStyle: "plank", wall: "#746354", trim: "#b5a080", accent: "#4f8a5b", + desk: "#947655", chair: "#594a40", metal: "#b5a080", wood: "#493d35", sofa: "#80434b", + plant: "#4f8a5b", skyDay: "#88758d", skyNight: "#2a3157", windowDay: "#d9b58b", windowNight: "#9db4e8", + fog: "#29303c", ambient: "#e9dcc3", props: ["bookshelf", "ornaments"], + }, + cyberlab: { + id: "cyberlab", label: "Cyberlab", note: "neon research cells", + floor: "#293544", floorStyle: "metal", wall: "#40536a", trim: "#839aac", accent: "#39ced6", + desk: "#617b90", chair: "#344759", metal: "#839aac", wood: "#40536a", sofa: "#536584", + plant: "#39ced6", skyDay: "#40536a", skyNight: "#1d2330", windowDay: "#8de5e8", windowNight: "#5784ac", + fog: "#1d2330", ambient: "#c9e3ed", props: ["coffee", "ornaments"], + }, + greenhouse: { + id: "greenhouse", label: "Greenhouse", note: "sunlit botanical conservatory", + floor: "#617466", floorStyle: "stone", wall: "#91a898", trim: "#d4dfc4", accent: "#73a66a", + desk: "#a5b18b", chair: "#526d5a", metal: "#9bafaa", wood: "#63734d", sofa: "#899a65", + plant: "#4f8a5b", skyDay: "#b9d8df", skyNight: "#344757", windowDay: "#e4ebcb", windowNight: "#9db4e8", + fog: "#344757", ambient: "#e4ebcb", props: ["coffee", "ornaments"], + }, + arctic: { + id: "arctic", label: "Arctic", note: "polar field station", + floor: "#778e9f", floorStyle: "metal", wall: "#a2b9c7", trim: "#d8e6eb", accent: "#e2b04a", + desk: "#b2c4cb", chair: "#526a80", metal: "#8198ab", wood: "#637c8b", sofa: "#738eaa", + plant: "#8aaab0", skyDay: "#d8e6eb", skyNight: "#526a80", windowDay: "#e7eff0", windowNight: "#9db4e8", + fog: "#526a80", ambient: "#d8e6eb", props: ["coffee", "ornaments"], + }, + rainynight: { + id: "rainynight", label: "Rainy Night", note: "rain-soaked midnight studio", + floor: "#536071", floorStyle: "plank", wall: "#526173", trim: "#8294a5", accent: "#e3a85c", + desk: "#b08a63", chair: "#6a7180", metal: "#687b8c", wood: "#765943", sofa: "#aa765a", + plant: "#688a78", skyDay: "#101b2c", skyNight: "#101b2c", windowDay: "#7492a9", windowNight: "#7492a9", + fog: "#101b2c", ambient: "#d7d8d2", props: ["coffee", "ornaments"], + }, } - const SCENE_IDS = ["office", "station", "cafe", "castle", "pirate", "graveyard"] + const SCENE_IDS = ["office", "station", "cafe", "castle", "pirate", "graveyard", "library", "cyberlab", "greenhouse", "arctic", "rainynight"] const SCENES = {} for (const id of SCENE_IDS) SCENES[id] = THEMES[id] const themeFor = (id) => (THEMES[id] ? THEMES[id] : THEMES.office) @@ -1317,6 +1352,59 @@ // ---- scene-specific props ------------------------------------------ + // Part coordinates are local to each ornament; placement reserves their + // actual body-height bounds against furniture, routes and other decorations. + const part = (color, x, y, z, w, h, d, glow = false, shape = "box") => ({ color, x, y, z, w, h, d, glow, shape }) + const ornament = (name, x, z, w, d, parts) => ({ name, x, z, w, d, parts }) + const ORNAMENTS = { + library: [ + ornament("book-wall", 9, 11, 1.5, .4, [part("wood", .75, 1, .2, 1.5, 2, .4), ...Array.from({ length: 24 }, (_, i) => part(i % 2 ? "sofa" : "trim", .13 + i % 6 * .25, .3 + Math.floor(i / 6) * .45, .42, .18, .3, .04))]), + ornament("sliding-ladder", 11, 11, .6, .4, [part("wood", .05, 1, .2, .08, 2, .12), part("wood", .55, 1, .2, .08, 2, .12), ...Array.from({ length: 6 }, (_, i) => part("trim", .3, .15 + i * .32, .2, .55, .06, .16))]), + ornament("globe", 12, 11, .7, .7, [part("wood", .35, .08, .35, .7, .16, .7), part("metal", .35, .45, .35, .08, .75, .08), part("accent", .35, 1.05, .35, .65, .65, .65, false, "sphere")]), + ornament("fireplace", 14, 11, 1.2, .6, [part("wood", .6, .1, .3, 1.2, .2, .6), part("wall", .12, .65, .3, .24, 1.3, .6), part("wall", 1.08, .65, .3, .24, 1.3, .6), part("trim", .6, 1.3, .3, 1.2, .16, .6), part("#efaf61", .6, .4, .32, .55, .4, .35, true)]), + ], + cyberlab: [ + ornament("server-rack", 9, 11, .9, .55, [part("metal", .45, .9, .25, .9, 1.8, .5), ...Array.from({ length: 5 }, (_, i) => part("wood", .45, .2 + i * .3, .51, .75, .2, .04)), part("accent", .08, .9, .54, .04, 1.6, .03, true)]), + ornament("hologram-table", 11, 11, .7, .7, [part("metal", .35, .4, .35, .6, .8, .6), part("accent", .35, .84, .35, .7, .08, .7), part("#39ced6", .35, 1.2, .35, .55, .55, .55, true, "sphere")]), + ornament("cable-bank", 12, 11, .6, .7, [part("wood", .3, .12, .35, .6, .24, .7), ...Array.from({ length: 3 }, (_, i) => part("metal", .1 + i * .2, .27, .35, .08, .08, .7))]), + ornament("neon-pylon", 14, 11, .6, .6, [part("metal", .3, .08, .3, .6, .16, .6), part("#d778bd", .3, 1, .3, .12, 1.8, .12, true)]), + ], + greenhouse: [ + ornament("flower-island", 9, 11, 1.2, .6, [part("wood", .6, .16, .3, 1.2, .32, .6), ...Array.from({ length: 3 }, (_, i) => part("plant", .22 + i * .38, .52, .3, .38, .38, .38, false, "sphere"))]), + ornament("pond", 11, 11, .8, .8, [part("metal", .4, .13, .4, .8, .26, .8), part("#72b8c7", .4, .27, .4, .68, .02, .68, true)]), + ornament("flower-rack", 12, 11, 1, .5, [part("wood", .06, .7, .25, .12, 1.4, .5), part("wood", .94, .7, .25, .12, 1.4, .5), part("trim", .5, .35, .25, 1, .08, .5), part("trim", .5, 1, .25, 1, .08, .5), part("plant", .5, 1.3, .25, .8, .5, .4)]), + ornament("watering-can", 14, 11, .65, .5, [part("accent", .25, .3, .25, .5, .6, .5), part("metal", .53, .4, .25, .3, .12, .12), part("metal", .25, .7, .25, .12, .25, .12)]), + ], + arctic: [ + ornament("heater", 9, 11, 1, .55, [part("metal", .5, .5, .25, 1, 1, .5), ...Array.from({ length: 5 }, (_, i) => part("#e2b04a", .15 + i * .18, .5, .51, .07, .65, .02, true))]), + ornament("instrument-case", 11, 11, .7, .6, [part("wood", .35, .35, .3, .7, .7, .6), part("trim", .35, .72, .3, .7, .08, .6), part("metal", .35, .8, .3, .4, .08, .1)]), + ornament("radio", 12, 11, .8, .5, [part("metal", .4, .4, .25, .8, .8, .5), part("accent", .25, .5, .51, .3, .25, .04, true), part("trim", .68, 1.15, .25, .04, .7, .04)]), + ornament("supply-crates", 14, 11, .7, .6, [part("wood", .35, .3, .3, .7, .6, .6), part("trim", .35, .63, .3, .7, .06, .6), part("metal", .35, .76, .3, .4, .2, .4)]), + ], + rainynight: [ + ornament("coffee-bar", 9, 11, 1, .6, [part("wood", .5, .48, .3, 1, .96, .6), part("trim", .5, 1, .3, 1, .08, .6), part("metal", .5, 1.25, .3, .4, .45, .4), part("#ffc66f", .15, 1.08, .3, .12, .12, .12, true)]), + ornament("umbrella-stand", 11, 11, .5, .5, [part("metal", .25, .3, .25, .5, .6, .5), part("accent", .16, .9, .25, .08, 1.2, .08), part("wood", .34, .8, .25, .08, 1, .08)]), + ornament("floor-lamp", 12, 11, .5, .5, [part("metal", .25, .04, .25, .5, .08, .5), part("metal", .25, .85, .25, .06, 1.7, .06), part("accent", .25, 1.7, .25, .5, .22, .5), part("#ffcf8a", .25, 1.57, .25, .35, .06, .35, true)]), + ornament("side-table", 14, 11, .7, .5, [part("wood", .35, .36, .25, .7, .08, .5), part("metal", .08, .18, .08, .08, .36, .08), part("metal", .62, .18, .42, .08, .36, .08)]), + ornament("coffee-shelf", 13, 10, .6, .5, [part("wood", .3, .38, .25, .6, .76, .5), part("trim", .3, .8, .25, .6, .08, .5), part("accent", .3, .95, .25, .3, .22, .3)]), + ], + } + + AgentOfficeScene3D.prototype._propBuilders.ornaments = function (env, theme) { + for (const item of ORNAMENTS[theme.id]) { + const g = new THREE.Group() + g.name = item.name + g.position.set(item.x, 0, item.z) + env.add(g) + for (const p of item.parts) { + const color = theme[p.color] || p.color + const options = p.glow ? { emissive: color, ei: .65 } : {} + if (p.shape === "sphere") this._sphere(g, color, p.x, p.y, p.z, p.w / 2, options) + else this._box(g, color, p.x, p.y, p.z, p.w, p.h, p.d, options) + } + } + } + AgentOfficeScene3D.prototype._propBuilders.console = function (env, theme) { const g = new THREE.Group() g.position.set(13.1, 0, 3.3) diff --git a/packages/agent-office/scene-extra.test.mjs b/packages/agent-office/scene-extra.test.mjs index fbec354..6a0349a 100644 --- a/packages/agent-office/scene-extra.test.mjs +++ b/packages/agent-office/scene-extra.test.mjs @@ -263,6 +263,39 @@ test('local time is a pure dawn/day/dusk/night palette', () => { }) // ---- drawing ----------------------------------------------------------- +test('every theme draws in both canvas views with finite coordinates and colours', () => { + const themes = {} + new Function('globalThis', readFileSync(new URL('./page/scene3d.js', import.meta.url), 'utf8'))(themes) + for (const dim of ['2d', '3d']) for (const id of themes.AgentOfficeScene3D.SCENE_IDS) { + const canvas = fakeCanvas() + const colours = [] + const ctx = new Proxy(fakeCtx(), { + get(target, key) { + const value = target[key] + if (typeof value !== 'function') return value + return (...args) => { + for (const arg of args) if (typeof arg === 'number') expect(Number.isFinite(arg), `${id} ${dim} ${String(key)}`).toBe(true) + return value(...args) + } + }, + set(target, key, value) { + if (key === 'fillStyle' && typeof value === 'string') { + expect(value).not.toContain('NaN') + colours.push(value) + } + target[key] = value + return true + }, + }) + canvas.getContext = () => ctx + const scene = new Scene(canvas, { dim }) + scene.theme = themes.AgentOfficeScene3D.SCENES[id] + scene.draw() + expect(colours).toContain(scene.theme.floor) + expect(colours).toContain(scene.theme.wall) + } +}) + for (const dim of ['2d', '3d']) { test(`${dim}: venues, the cat and the clock draw without a real canvas`, () => { diff --git a/packages/agent-office/scene3d.test.mjs b/packages/agent-office/scene3d.test.mjs index 3521736..f8fd7df 100644 --- a/packages/agent-office/scene3d.test.mjs +++ b/packages/agent-office/scene3d.test.mjs @@ -38,8 +38,8 @@ describe("bundle and registry", () => { expect(src).toContain("Copyright © 2010-2024 three.js authors") }) - test("six scenes are registered with palettes and props", () => { - expect(S.SCENE_IDS).toEqual(["office", "station", "cafe", "castle", "pirate", "graveyard"]) + test("registered scenes have palettes and props", () => { + expect(S.SCENE_IDS).toEqual(["office", "station", "cafe", "castle", "pirate", "graveyard", "library", "cyberlab", "greenhouse", "arctic", "rainynight"]) expect(Object.keys(S.SCENES).sort()).toEqual(S.SCENE_IDS.slice().sort()) for (const id of S.SCENE_IDS) { const theme = S.SCENES[id] @@ -546,7 +546,7 @@ describe("THREE renderer path", () => { f.scene.dispose() }) - test("six THREE environments keep decorations off seats and walking routes", () => { + test("all THREE environments keep decorations off seats and walking routes", () => { const f = requireThree(threeFixture()) for (const id of S.SCENE_IDS) { const previous = f.scene.env @@ -558,6 +558,12 @@ describe("THREE renderer path", () => { expect(group.children.length).toBeGreaterThan(0) expect(group.children.every((object) => object.visible), `${id} retains ${prop}`).toBe(true) } + if (["library", "cyberlab", "greenhouse", "arctic", "rainynight"].includes(id)) { + const ornaments = f.scene.env.getObjectByName("props:ornaments").children + expect(ornaments.length).toBeGreaterThanOrEqual(4) + expect(new Set(ornaments.map((object) => object.name)).size).toBe(ornaments.length) + expect(ornaments.every((object) => object.visible && object.userData.decoration)).toBe(true) + } f.scene.env.updateMatrixWorld(true) let checked = 0 f.scene.env.traverse((object) => { diff --git a/packages/agent-office/test/browser.mjs b/packages/agent-office/test/browser.mjs index b008a66..a10d893 100644 --- a/packages/agent-office/test/browser.mjs +++ b/packages/agent-office/test/browser.mjs @@ -76,7 +76,7 @@ for(const engine of (process.env.OFFICE_BROWSERS||'chromium,webkit').split(',')) } if(width===1440) { await frame.locator('#settingsBtn').click() - for(const scene of ['office','station','cafe','castle','pirate','graveyard']) { + for(const scene of ['office','station','cafe','castle','pirate','graveyard','library','cyberlab','greenhouse','arctic','rainynight']) { await frame.locator('#optScene').selectOption(scene) for(const quality of ['low','medium','high']) { await frame.locator('#optQuality').selectOption(quality) diff --git a/registry.json b/registry.json index 350beb7..5d41dac 100644 --- a/registry.json +++ b/registry.json @@ -120,7 +120,7 @@ { "package": "@magpie-community/page-chat", "name": "Chat", "kind": "page", "community": true, "summary": { "en": "A chat page in magpie's window by Magic_zero: talk to magpie's own models with your MCP servers, instructions and skills, images and LaTeX. Runs a local service on 127.0.0.1 that only its own page can use.", "zh": "Magic_zero 做的 magpie 窗口内「对话」页面:用 magpie 自己的模型聊天,带上你的 MCP 服务器、指令和技能,支持图片与 LaTeX。本地服务只在 127.0.0.1,只给自己的页面用。" } }, { "package": "@magpie-community/page-agent-office", "name": "Agent Office", "kind": "page", "community": true, - "summary": { "en": "Reads the session files of Claude Code, Codex, Copilot CLI, Kimi Code, DeepSeek Harness, Gemini CLI, Qwen Code, Pi, omp, Qoder, WorkBuddy, CodeBuddy and Grok Build on this computer (prompts, replies and tool commands; text can be turned off). Shows them in a real WebGL 3D office with six scenes, an isometric/2D office, or a grouped workbench with Today usage, recent conversations and approvals.", "zh": "读取本机 Claude Code、Codex、Copilot CLI、Kimi Code、DeepSeek Harness、Gemini CLI、Qwen Code、Pi、omp、Qoder、WorkBuddy、CodeBuddy、Grok Build 的会话文件(含提问、回复与工具命令,可关闭文本),用真 3D 办公室(六种场景)、等距/2D 办公室或分组工作台展示,带今日用量、最近对话与批准状态。" } }, + "summary": { "en": "Reads the session files of Claude Code, Codex, Copilot CLI, Kimi Code, DeepSeek Harness, Gemini CLI, Qwen Code, Pi, omp, Qoder, WorkBuddy, CodeBuddy and Grok Build on this computer (prompts, replies and tool commands; text can be turned off). Shows them in a real WebGL 3D office with eleven scenes, an isometric/2D office, or a grouped workbench with Today usage, recent conversations and approvals.", "zh": "读取本机 Claude Code、Codex、Copilot CLI、Kimi Code、DeepSeek Harness、Gemini CLI、Qwen Code、Pi、omp、Qoder、WorkBuddy、CodeBuddy、Grok Build 的会话文件(含提问、回复与工具命令,可关闭文本),用真 3D 办公室(十一种场景)、等距/2D 办公室或分组工作台展示,带今日用量、最近对话与批准状态。" } }, {"package": "@magpie-community/agent-kimi-desktop", "name": "Kimi", "kind": "agent", "community": true, "summary": {"en": "Kimi desktop Work on Magpie's Agents page: select a model from Magpie, then disconnect to restore the original service. Not Kimi Code CLI.", "zh": "把普通 Kimi 桌面版 Work 接入 Magpie Agent 页,使用已配置的模型;断开恢复原连接。不是 Kimi Code CLI。"}}, { "package": "@magpie-community/gateway-notify", "name": "Notify", "kind": "middleware", "community": true, "summary": { "en": "A push when an agent's turn is done or fails, after it ran long enough to be worth one: ntfy, Bark, Gotify, Server酱, Feishu, DingTalk, WeCom, Telegram or your own webhook. Agent, project, model and time only by default; the reply's text is opt-in.", "zh": "agent 一轮任务跑完或失败时推送提醒(只提醒跑够设定时长的任务):支持 ntfy、Bark、Gotify、Server酱、飞书、钉钉、企业微信、Telegram 和自定义 webhook。默认只发 agent、项目、模型和用时,回复正文需手动开启。" } },