@penguinharness/use-bento-slides 0.2.17 → 0.2.19

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 (33) hide show
  1. package/README.md +37 -0
  2. package/README.zh.md +37 -0
  3. package/THIRD-PARTY-NOTICES.md +30 -0
  4. package/ifaces.json +63 -0
  5. package/package.json +19 -21
  6. package/skills/bento-slides/SKILL.md +89 -29
  7. package/skills/bento-slides/references/bento-agents.md +511 -0
  8. package/workbenches/slides/index.ts +677 -0
  9. package/workbenches/slides/package.json +43 -0
  10. package/workbenches/slides/ui/app.js +1101 -0
  11. package/workbenches/slides/ui/bridge.js +190 -0
  12. package/workbenches/slides/ui/conversation-view.js +206 -0
  13. package/workbenches/slides/ui/conversation.css +95 -0
  14. package/workbenches/slides/ui/conversation.js +115 -0
  15. package/workbenches/slides/ui/deck-files.css +279 -0
  16. package/workbenches/slides/ui/deck-files.js +189 -0
  17. package/workbenches/slides/ui/file-menu.js +72 -0
  18. package/workbenches/slides/ui/icon.svg +9 -0
  19. package/workbenches/slides/ui/index.html +252 -0
  20. package/workbenches/slides/ui/model-choice.js +298 -0
  21. package/workbenches/slides/ui/model-control.tsx +90 -0
  22. package/workbenches/slides/ui/powerpoint.js +196 -0
  23. package/workbenches/slides/ui/sample.bento.json +33 -0
  24. package/workbenches/slides/ui/strings.js +184 -0
  25. package/workbenches/slides/ui/style.css +505 -0
  26. package/workbenches/slides/ui/sync.js +268 -0
  27. package/workbenches/slides/ui/template-picker.js +128 -0
  28. package/workbenches/slides/ui/templates.js +256 -0
  29. package/workbenches/slides/ui/vendor/LICENSE-bento.txt +21 -0
  30. package/workbenches/slides/ui/vendor/LICENSE-jszip.txt +25 -0
  31. package/workbenches/slides/ui/vendor/LICENSE-pptxgen.txt +21 -0
  32. package/workbenches/slides/ui/vendor/bento-slides-1.2.13.runtime.txt +310 -0
  33. package/workbenches/slides/ui/vendor/pptxgen-4.0.1.bundle.js +96 -0
@@ -0,0 +1,196 @@
1
+ // Bento uses pixels on a fixed canvas. PowerPoint uses inches and point sizes.
2
+ const unit = (px) => px / 96;
3
+ const color = (value, fallback) => (/^#[\da-f]{6}$/i.test(value) ? value.slice(1) : fallback);
4
+ const font = (family) =>
5
+ family
6
+ ?.split(",")[0]
7
+ .replace(/["']/g, "")
8
+ .replace(/system-ui|sans-serif/i, "Aptos") || "Aptos";
9
+ const content = (html) => {
10
+ const t = document.createElement("template");
11
+ t.innerHTML = String(html ?? "");
12
+ return t.content;
13
+ };
14
+ function textRuns(html) {
15
+ const out = [];
16
+ function visit(node, style) {
17
+ if (node.nodeType === Node.TEXT_NODE) {
18
+ out.push({ text: node.nodeValue, options: style });
19
+ return;
20
+ }
21
+ if (node.localName === "br") {
22
+ out.push({ text: "\n", options: style });
23
+ return;
24
+ }
25
+ if (["script", "style"].includes(node.localName)) return;
26
+ const next = { ...style };
27
+ if (["b", "strong"].includes(node.localName)) next.bold = true;
28
+ if (["em", "i"].includes(node.localName)) next.italic = true;
29
+ if (node.localName === "u") next.underline = true;
30
+ for (const child of node.childNodes) visit(child, next);
31
+ if (["p", "div"].includes(node.localName)) out.push({ text: "\n", options: style });
32
+ }
33
+ visit(content(html), {});
34
+ return out;
35
+ }
36
+ const asset = (value, doc) =>
37
+ String(value ?? "").startsWith("asset:") ? doc.assets?.[value.slice(6)] : value;
38
+ let vendor;
39
+ async function library() {
40
+ if (!vendor)
41
+ vendor = new Promise((resolve, reject) => {
42
+ const script = document.createElement("script");
43
+ script.src = "./vendor/pptxgen-4.0.1.bundle.js";
44
+ script.onload = () => resolve(window.PptxGenJS);
45
+ script.onerror = () => {
46
+ vendor = null;
47
+ script.remove();
48
+ reject(new Error("PptxGenJS"));
49
+ };
50
+ document.head.append(script);
51
+ });
52
+ return vendor;
53
+ }
54
+ function addElement(ppt, slide, e, doc) {
55
+ const box = {
56
+ x: unit(e.x || 0),
57
+ y: unit(e.y || 0),
58
+ w: unit(e.w),
59
+ h: unit(e.h),
60
+ rotate: (e.rotation || 0) % 360,
61
+ };
62
+ const transparency = Math.round((1 - (e.opacity ?? 1)) * 100);
63
+ const theme = doc.theme || {};
64
+ if (e.type === "text") {
65
+ slide.addText(textRuns(e.html), {
66
+ ...box,
67
+ margin: 0,
68
+ breakLine: false,
69
+ align: e.align,
70
+ valign: e.valign === "middle" ? "mid" : e.valign || "top",
71
+ fontFace: font(e.fontFamily || theme.fontFamily),
72
+ fontSize: (e.fontSize || 24) * 0.75,
73
+ bold: Number(e.fontWeight) >= 600,
74
+ color: color(e.color, color(theme.color, "222222")),
75
+ transparency,
76
+ });
77
+ } else if (e.type === "shape" && e.shape !== "path") {
78
+ const shape = {
79
+ rect: e.radius ? "roundRect" : "rect",
80
+ ellipse: "ellipse",
81
+ triangle: "triangle",
82
+ arrow: "rightArrow",
83
+ line: "line",
84
+ }[e.shape || "rect"];
85
+ if (!shape) return false;
86
+ const fill = color(e.fillGradient?.stops?.[0]?.color || e.fill);
87
+ const stroke = color(e.stroke, e.shape === "line" ? fill : undefined);
88
+ slide.addShape(ppt.ShapeType[shape], {
89
+ ...box,
90
+ fill: fill ? { color: fill, transparency } : { transparency: 100 },
91
+ line: stroke
92
+ ? { color: stroke, width: (e.strokeWidth || 1) * 0.75, transparency }
93
+ : { transparency: 100 },
94
+ });
95
+ } else if (e.type === "table") {
96
+ const style = e.style || {};
97
+ const rows = e.rows.map((r, index) =>
98
+ r.cells.map((c) => ({
99
+ text: textRuns(c.html),
100
+ options: {
101
+ align: c.align,
102
+ bold: c.bold || (e.header && index === 0),
103
+ color: color(
104
+ c.color,
105
+ index === 0 && e.header ? color(style.headerColor) : color(style.color),
106
+ ),
107
+ fill: {
108
+ color: color(
109
+ c.bg,
110
+ index === 0 && e.header ? color(style.headerBg, "EAEAEA") : "FFFFFF",
111
+ ),
112
+ },
113
+ },
114
+ })),
115
+ );
116
+ slide.addTable(rows, {
117
+ ...box,
118
+ margin: 0.05,
119
+ fontSize: (style.fontSize || 20) * 0.75,
120
+ border: { type: "solid", color: color(style.borderColor, "CCCCCC"), pt: 1 },
121
+ autoPage: false,
122
+ });
123
+ } else if (e.type === "chart") {
124
+ const opt = e.option || {},
125
+ series = opt.series || [];
126
+ const groups = series.map((s) => {
127
+ const data = s.data || [];
128
+ const values = data.map((v) =>
129
+ Number((typeof v === "object" && v !== null ? v.value : v) ?? 0),
130
+ );
131
+ const axis =
132
+ (Array.isArray(opt.xAxis) ? opt.xAxis[0] : opt.xAxis)?.data ||
133
+ (Array.isArray(opt.yAxis) ? opt.yAxis[0] : opt.yAxis)?.data;
134
+ const labels = axis || data.map((v, i) => v?.name || String(i + 1));
135
+ const type = { line: "line", bar: "bar", pie: "pie", scatter: "scatter", radar: "radar" }[
136
+ s.type || e.preset
137
+ ];
138
+ if (!type || values.some((v) => !Number.isFinite(v))) return null;
139
+ return {
140
+ type,
141
+ data: [{ name: s.name || "", labels, values }],
142
+ options: { chartColors: [color(s.itemStyle?.color, color(theme.accent, "356B69"))] },
143
+ };
144
+ });
145
+ if (!groups.length || groups.includes(null)) return false;
146
+ slide.addChart(groups, {
147
+ ...box,
148
+ barDir: opt.yAxis?.type === "category" ? "bar" : "col",
149
+ showLegend: !!opt.legend,
150
+ showTitle: false,
151
+ showCatName: false,
152
+ catAxisLabelColor: color(opt.xAxis?.axisLabel?.color, "444444"),
153
+ valAxisLabelColor: color(opt.yAxis?.axisLabel?.color, "444444"),
154
+ });
155
+ } else if (e.type === "image" || e.type === "svg" || e.type === "shape") {
156
+ let data = asset(e.src || e.asset, doc);
157
+ if (e.type === "svg" && doc.assets?.[e.asset]) data = doc.assets[e.asset];
158
+ let markup = e.type === "svg" ? e.markup : null;
159
+ if (e.type === "shape") {
160
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
161
+ svg.setAttribute("viewBox", (e.pathBox || [0, 0, e.w, e.h]).join(" "));
162
+ svg.setAttribute("xmlns", svg.namespaceURI);
163
+ const path = document.createElementNS(svg.namespaceURI, "path");
164
+ path.setAttribute("d", e.d || "");
165
+ path.setAttribute("fill", e.fill || "none");
166
+ path.setAttribute("stroke", e.stroke || "none");
167
+ path.setAttribute("stroke-width", e.strokeWidth || 1);
168
+ svg.append(path);
169
+ markup = svg.outerHTML;
170
+ }
171
+ if (markup)
172
+ data =
173
+ "data:image/svg+xml;base64," +
174
+ btoa(Array.from(new TextEncoder().encode(markup), (v) => String.fromCharCode(v)).join(""));
175
+ if (!/^data:image\/(?:png|jpe?g|gif|svg\+xml);base64,/i.test(data)) return false;
176
+ slide.addImage({ ...box, data, transparency });
177
+ } else return false;
178
+ return true;
179
+ }
180
+ export async function exportPowerPoint(doc) {
181
+ const Constructor = await library();
182
+ const ppt = new Constructor(),
183
+ size = doc.size || { width: 1280, height: 720 };
184
+ ppt.defineLayout({ name: "Bento", width: unit(size.width), height: unit(size.height) });
185
+ ppt.layout = "Bento";
186
+ ppt.title = doc.title;
187
+ for (const s of doc.slides) {
188
+ const slide = ppt.addSlide();
189
+ slide.hidden = Boolean(s.hidden);
190
+ slide.background = { color: color(s.background, color(doc.theme?.background, "FFFFFF")) };
191
+ if (s.notes) slide.addNotes(s.notes);
192
+ for (const e of s.elements || [])
193
+ if (!addElement(ppt, slide, e, doc)) throw new Error("unsupportedPowerPoint");
194
+ }
195
+ return ppt.write({ outputType: "blob", compression: true });
196
+ }
@@ -0,0 +1,33 @@
1
+ {"format":"bento/slides","version":1,"title":"PenguinHarness in four slides","size":{"width":1280,"height":720},"theme":{"background":"#0F1720","color":"#F2F0EA","accent":"#FF9E8A","fontFamily":"system-ui, sans-serif"},"slides":[
2
+ {"id":"cover","background":"#0F1720","transition":"none","notes":"Open with the one-line promise. Pause on the headline.","elements":[
3
+ {"id":"kicker","type":"text","role":"kicker","x":96,"y":150,"w":800,"h":40,"rotation":0,"opacity":1,"html":"PENGUINHARNESS","fontSize":22,"fontFamily":"system-ui, sans-serif","fontWeight":700,"color":"#FF9E8A","align":"left","valign":"top","lineHeight":1.2,"letterSpacing":4},
4
+ {"id":"headline","type":"text","role":"title","x":96,"y":210,"w":1000,"h":220,"rotation":0,"opacity":1,"html":"An agent that keeps getting better at your work.","fontSize":84,"fontFamily":"system-ui, sans-serif","fontWeight":800,"color":"#F2F0EA","align":"left","valign":"top","lineHeight":1.05,"fx":{"enter":"fade-up","order":0}},
5
+ {"id":"bar","type":"shape","shape":"rect","x":96,"y":470,"w":320,"h":14,"rotation":0,"opacity":1,"fill":"#FF9E8A","stroke":"none","strokeWidth":0,"radius":7},
6
+ {"id":"orbit","type":"shape","shape":"ellipse","x":1010,"y":470,"w":120,"h":120,"rotation":0,"opacity":0.9,"fill":"#1F3350","stroke":"#FF9E8A","strokeWidth":2,"radius":0,"fx":{"loop":{"type":"motion-path","path":"M0,0 C40,-50 110,-30 90,30 C70,80 -10,60 0,0","duration":14,"ease":"none"}}}
7
+ ]},
8
+ {"id":"what","background":"#0F1720","transition":"morph","notes":"Three things it does, one line each.","elements":[
9
+ {"id":"headline","type":"text","role":"title","x":96,"y":72,"w":900,"h":84,"rotation":0,"opacity":1,"html":"What it does","fontSize":48,"fontFamily":"system-ui, sans-serif","fontWeight":800,"color":"#F2F0EA","align":"left","valign":"top","lineHeight":1.1},
10
+ {"id":"bar","type":"shape","shape":"rect","x":96,"y":166,"w":96,"h":8,"rotation":0,"opacity":1,"fill":"#FF9E8A","stroke":"none","strokeWidth":0,"radius":4},
11
+ {"id":"card-1","type":"shape","shape":"rect","x":96,"y":220,"w":340,"h":360,"rotation":0,"opacity":1,"fill":"#172536","stroke":"#26384F","strokeWidth":1,"radius":16},
12
+ {"id":"card-1-title","type":"text","x":124,"y":250,"w":284,"h":44,"rotation":0,"opacity":1,"html":"Works","fontSize":30,"fontFamily":"system-ui, sans-serif","fontWeight":700,"color":"#FF9E8A","align":"left","valign":"top","lineHeight":1.2},
13
+ {"id":"card-1-body","type":"text","role":"body","x":124,"y":306,"w":284,"h":240,"rotation":0,"opacity":1,"html":"Runs tasks in your Workspace with tools, Skills and a sandbox you control.","fontSize":22,"fontFamily":"system-ui, sans-serif","fontWeight":400,"color":"#C9D3DF","align":"left","valign":"top","lineHeight":1.45},
14
+ {"id":"card-2","type":"shape","shape":"rect","x":470,"y":220,"w":340,"h":360,"rotation":0,"opacity":1,"fill":"#172536","stroke":"#26384F","strokeWidth":1,"radius":16},
15
+ {"id":"card-2-title","type":"text","x":498,"y":250,"w":284,"h":44,"rotation":0,"opacity":1,"html":"Remembers","fontSize":30,"fontFamily":"system-ui, sans-serif","fontWeight":700,"color":"#FF9E8A","align":"left","valign":"top","lineHeight":1.2},
16
+ {"id":"card-2-body","type":"text","role":"body","x":498,"y":306,"w":284,"h":240,"rotation":0,"opacity":1,"html":"Keeps what it learns in its own Agent State: Skills, memory and apps like this one.","fontSize":22,"fontFamily":"system-ui, sans-serif","fontWeight":400,"color":"#C9D3DF","align":"left","valign":"top","lineHeight":1.45},
17
+ {"id":"card-3","type":"shape","shape":"rect","x":844,"y":220,"w":340,"h":360,"rotation":0,"opacity":1,"fill":"#172536","stroke":"#26384F","strokeWidth":1,"radius":16},
18
+ {"id":"card-3-title","type":"text","x":872,"y":250,"w":284,"h":44,"rotation":0,"opacity":1,"html":"Improves","fontSize":30,"fontFamily":"system-ui, sans-serif","fontWeight":700,"color":"#FF9E8A","align":"left","valign":"top","lineHeight":1.2},
19
+ {"id":"card-3-body","type":"text","role":"body","x":872,"y":306,"w":284,"h":240,"rotation":0,"opacity":1,"html":"Measures itself on a Benchmark and keeps only the changes that score higher.","fontSize":22,"fontFamily":"system-ui, sans-serif","fontWeight":400,"color":"#C9D3DF","align":"left","valign":"top","lineHeight":1.45}
20
+ ]},
21
+ {"id":"numbers","background":"#0F1720","transition":"morph","notes":"Placeholder figures: ask the AI to replace them with yours.","elements":[
22
+ {"id":"headline","type":"text","role":"title","x":96,"y":72,"w":900,"h":84,"rotation":0,"opacity":1,"html":"Rounds of self-improvement","fontSize":48,"fontFamily":"system-ui, sans-serif","fontWeight":800,"color":"#F2F0EA","align":"left","valign":"top","lineHeight":1.1},
23
+ {"id":"bar","type":"shape","shape":"rect","x":96,"y":166,"w":96,"h":8,"rotation":0,"opacity":1,"fill":"#FF9E8A","stroke":"none","strokeWidth":0,"radius":4},
24
+ {"id":"chart","type":"chart","x":96,"y":220,"w":1088,"h":400,"rotation":0,"opacity":1,"preset":"bar","option":{"xAxis":{"type":"category","data":["Round 0","Round 1","Round 2","Round 3"],"axisLabel":{"color":"#C9D3DF","fontSize":16}},"yAxis":{"type":"value","axisLabel":{"color":"#C9D3DF","fontSize":14},"splitLine":{"lineStyle":{"color":"#26384F"}}},"series":[{"type":"bar","name":"Example score","data":[42,55,63,71],"itemStyle":{"color":"#FF9E8A","borderRadius":6},"barWidth":90}],"tooltip":{"trigger":"item","formatter":"{b}: {c}"}},"fx":{"enter":"fade-up"}}
25
+ ]},
26
+ {"id":"start","background":"#0F1720","transition":"morph","notes":"Close on the three steps.","elements":[
27
+ {"id":"headline","type":"text","role":"title","x":96,"y":72,"w":900,"h":84,"rotation":0,"opacity":1,"html":"Get started","fontSize":48,"fontFamily":"system-ui, sans-serif","fontWeight":800,"color":"#F2F0EA","align":"left","valign":"top","lineHeight":1.1},
28
+ {"id":"bar","type":"shape","shape":"rect","x":96,"y":166,"w":96,"h":8,"rotation":0,"opacity":1,"fill":"#FF9E8A","stroke":"none","strokeWidth":0,"radius":4},
29
+ {"id":"step-1","type":"text","x":96,"y":240,"w":1088,"h":70,"rotation":0,"opacity":1,"html":"<b>1.</b> Install the desktop app or the CLI.","fontSize":36,"fontFamily":"system-ui, sans-serif","fontWeight":500,"color":"#F2F0EA","align":"left","valign":"top","lineHeight":1.3,"fx":{"enter":"fade-up","order":0}},
30
+ {"id":"step-2","type":"text","x":96,"y":340,"w":1088,"h":70,"rotation":0,"opacity":1,"html":"<b>2.</b> Add a model and start a conversation.","fontSize":36,"fontFamily":"system-ui, sans-serif","fontWeight":500,"color":"#F2F0EA","align":"left","valign":"top","lineHeight":1.3,"fx":{"enter":"fade-up","order":1}},
31
+ {"id":"step-3","type":"text","x":96,"y":440,"w":1088,"h":70,"rotation":0,"opacity":1,"html":"<b>3.</b> Install a plugin from the market, like this one.","fontSize":36,"fontFamily":"system-ui, sans-serif","fontWeight":500,"color":"#F2F0EA","align":"left","valign":"top","lineHeight":1.3,"fx":{"enter":"fade-up","order":2}}
32
+ ]}
33
+ ]}
@@ -0,0 +1,184 @@
1
+ // The page's copy, in the two languages the app speaks. The page follows the app's language
2
+ // (the `lang` of the document that frames it) and falls back to the browser's.
3
+
4
+ const en = {
5
+ fileMenu: "File",
6
+ newDeck: "New",
7
+ saveDeck: "Save presentation",
8
+ saveFailed: (why) => `Could not save this presentation (${why}). Your edits are still open.`,
9
+ notSaved: "Not saved",
10
+ pptx: "Export as PowerPoint file (.pptx)",
11
+ unsupportedPowerPoint:
12
+ "This deck contains media or a graphic PowerPoint export cannot reproduce. Download HTML to keep the complete deck.",
13
+ present: "Present",
14
+ backToEdit: "Back to editor",
15
+ deckName: "Deck title",
16
+ layout: "Starting layout",
17
+ previousSlide: "Previous",
18
+ nextSlide: "Next",
19
+ createFailed: "Couldn’t create this presentation. Try again.",
20
+ newTitle: "New presentation",
21
+ create: "Create",
22
+ cancel: "Cancel",
23
+ transferFailed: "The editor could not complete that action. Your deck is still open.",
24
+ frameTitle: "Bento Slides editor",
25
+ importDeck: "Import a presentation…",
26
+ exportDeck: "Download as a web page (.html)",
27
+ history: "Version history",
28
+ close: "Close",
29
+ historyLoading: "Loading versions…",
30
+ historyFailed: "Couldn’t load earlier versions. Reopen version history to try again.",
31
+ restoreVersion: "Restore",
32
+ askAi: "AI chat",
33
+ railTitle: "Ask AI to change this deck",
34
+ newChat: "New conversation",
35
+ chooseModel: "Choose chat model",
36
+ modelUnsupported: "Open this presentation in the updated PenguinHarness app to choose a model.",
37
+ defaultModel: "Project default",
38
+ pickModel: "Choose a model",
39
+ noModel:
40
+ "This Project has no default model yet. Choose a model with the model button, then send again.",
41
+ choiceReadFailed: "Could not refresh the model selection.",
42
+ handoffFailed: "The model switch failed.",
43
+ modelFailed: (reason) => `Could not select a model. ${reason}`,
44
+ choiceCancel: "Cancel",
45
+ choiceApply: "Switch",
46
+ effortCost:
47
+ "Changing the thinking level can invalidate the cached conversation prefix and increase input costs.",
48
+ modelCost: (target) =>
49
+ `Switch this conversation to ${target}? The handoff may summarize the current conversation using the previous model.`,
50
+ choiceFailed: (reason) => `Could not update the conversation settings. ${reason}`,
51
+ send: "Send",
52
+ stop: "Stop",
53
+ promptPlaceholder: "Describe the change, for example: make this slide a bar chart of the numbers",
54
+ startTitle: "AI Slides",
55
+ startLead:
56
+ "Edit a deck here while the Agent edits the same deck. Each of you sees the other's changes as they are saved.",
57
+ startPlaceholder: "What is the deck about? For example: a five-slide introduction to our Q4 plan",
58
+ startGo: "Create with AI",
59
+ sampleDeck: "Open the sample deck",
60
+ blankDeck: "Blank deck",
61
+ unsupportedTitle: "This workbench needs a newer PenguinHarness",
62
+ unsupportedBody:
63
+ "Slides keeps each deck in a file the editor and the Agent both write, which this server does not offer yet. Update PenguinHarness, then reload.",
64
+ untitled: "Untitled deck",
65
+ slides: (n) => (n === 1 ? "1 slide" : `${n} slides`),
66
+ opening: "Opening editor…",
67
+ synced: "Saved",
68
+ saving: "Saving…",
69
+ theirs: "The Agent updated the deck",
70
+ merged: "The Agent updated the deck; your edits were kept",
71
+ offline: "Not saved: the server cannot be reached",
72
+ hintEmpty:
73
+ "Ask for a change in plain words. The Agent edits the deck file and the slides update here as it saves. You can keep editing meanwhile.",
74
+ contextSlide: (n, total) => `Slide ${n} of ${total}`,
75
+ contextSelection: (n) => (n === 1 ? "1 element selected" : `${n} elements selected`),
76
+ clashes: (n) =>
77
+ n === 1
78
+ ? "You and the Agent changed the same property; yours was kept. The Agent's version is in the deck's history."
79
+ : `You and the Agent changed the same ${n} properties; yours were kept. The Agent's version is in the deck's history.`,
80
+ badFile: (why) =>
81
+ `The deck file cannot be read right now (${why}). It loads again as soon as it is valid.`,
82
+ gone: "This deck's file was removed.",
83
+ keepCopy: "Keep what you see as a new deck",
84
+ historyEmpty:
85
+ "No earlier versions yet. When a save replaces the other side's version, that version is kept here.",
86
+ versionBy: { agent: "The Agent's version", editor: "Your version" },
87
+ restoreFailed: (why) => `That version could not be restored: ${why}.`,
88
+ importFailed: (why) => `That file could not be imported: ${why}.`,
89
+ askFailed: (why) => `The request could not be sent: ${why}`,
90
+ aiFailed: "The Agent stopped without an answer.",
91
+ };
92
+
93
+ const zh = {
94
+ fileMenu: "文件",
95
+ newDeck: "新建",
96
+ saveDeck: "保存演示文稿",
97
+ saveFailed: (why) => `无法保存这份文稿(${why}),编辑内容仍保留在这里。`,
98
+ notSaved: "未保存",
99
+ pptx: "导出为 PowerPoint 文件(.pptx)",
100
+ unsupportedPowerPoint: "文稿含有尚不能导出到 PowerPoint 的媒体或图形。下载 HTML 可保留整份文稿。",
101
+ present: "放映",
102
+ backToEdit: "返回编辑",
103
+ deckName: "文稿标题",
104
+ layout: "起始版式",
105
+ previousSlide: "上一页",
106
+ nextSlide: "下一页",
107
+ createFailed: "未能创建演示文稿,请重试。",
108
+ newTitle: "新建演示文稿",
109
+ create: "创建",
110
+ cancel: "取消",
111
+ transferFailed: "操作未完成,文稿仍在编辑器中。",
112
+ frameTitle: "Bento 幻灯片编辑器",
113
+ importDeck: "导入演示文稿…",
114
+ exportDeck: "下载为网页文件(.html)",
115
+ history: "历史版本",
116
+ close: "关闭",
117
+ historyLoading: "正在读取历史版本…",
118
+ historyFailed: "无法读取历史版本。重新打开历史版本即可重试。",
119
+ restoreVersion: "恢复",
120
+ askAi: "AI 对话",
121
+ railTitle: "让 AI 修改这份文稿",
122
+ newChat: "新对话",
123
+ chooseModel: "选择对话模型",
124
+ modelUnsupported: "在新版 PenguinHarness 应用中打开文稿即可选择模型。",
125
+ defaultModel: "项目默认模型",
126
+ pickModel: "选择模型",
127
+ noModel: "这个项目还没有默认模型。点模型按钮选一个模型,再发送。",
128
+ choiceReadFailed: "未能刷新模型选择。",
129
+ handoffFailed: "模型切换失败。",
130
+ modelFailed: (reason) => `未能选择对话模型。${reason}`,
131
+ choiceCancel: "取消",
132
+ choiceApply: "切换",
133
+ effortCost: "切换思考等级可能使已有对话的前缀缓存失效,增加输入费用。",
134
+ modelCost: (target) => `切换这段对话到 ${target}?交接时可能使用原模型生成对话摘要。`,
135
+ choiceFailed: (reason) => `未能更新对话设置。${reason}`,
136
+ send: "发送",
137
+ stop: "停止",
138
+ promptPlaceholder: "描述要改什么,例如:把这一页的数字做成柱状图",
139
+ startTitle: "AI PPT",
140
+ startLead: "你在这里编辑文稿,Agent 同时修改同一份文稿;任何一方保存后,另一方立即看到。",
141
+ startPlaceholder: "这份文稿讲什么?例如:用五页介绍我们的第四季度计划",
142
+ startGo: "让 AI 生成",
143
+ sampleDeck: "打开示例文稿",
144
+ blankDeck: "空白文稿",
145
+ unsupportedTitle: "这个工作台需要更新的 PenguinHarness",
146
+ unsupportedBody:
147
+ "幻灯片工作台把每份文稿存成一个编辑器与 Agent 都能写的文件,当前服务端还不提供这项能力。请更新 PenguinHarness 后重新载入。",
148
+ untitled: "未命名文稿",
149
+ slides: (n) => `${n} 页`,
150
+ opening: "正在打开编辑器…",
151
+ synced: "已保存",
152
+ saving: "正在保存…",
153
+ theirs: "Agent 更新了文稿",
154
+ merged: "Agent 更新了文稿,你的修改已保留",
155
+ offline: "未保存:连不上服务端",
156
+ hintEmpty:
157
+ "用一句话说出要改什么。Agent 修改文稿文件,保存后这里的幻灯片随即更新;其间你可以继续编辑。",
158
+ contextSlide: (n, total) => `第 ${n} 页,共 ${total} 页`,
159
+ contextSelection: (n) => `已选 ${n} 个元素`,
160
+ clashes: (n) => `你和 Agent 改了同样的 ${n} 处属性,已保留你的修改;Agent 的版本在文稿历史里。`,
161
+ badFile: (why) => `文稿文件暂时读不出来(${why});文件恢复合法后会自动载入。`,
162
+ gone: "这份文稿的文件已被删除。",
163
+ keepCopy: "把眼前这份另存为新文稿",
164
+ historyEmpty: "还没有历史版本。一方保存时替换了另一方的版本,被替换的版本会留在这里。",
165
+ versionBy: { agent: "Agent 的版本", editor: "你的版本" },
166
+ restoreFailed: (why) => `无法恢复这个版本:${why}。`,
167
+ importFailed: (why) => `无法导入这个文件:${why}。`,
168
+ askFailed: (why) => `请求没有发出:${why}`,
169
+ aiFailed: "Agent 没有给出回答就停止了。",
170
+ };
171
+
172
+ /** The language of the app framing this page, else the browser's. */
173
+ function language() {
174
+ try {
175
+ const lang = window.parent !== window ? window.parent.document.documentElement.lang : "";
176
+ if (lang) return lang;
177
+ } catch {
178
+ // A cross-origin parent: fall through to the browser.
179
+ }
180
+ return navigator.language || "en";
181
+ }
182
+
183
+ export const locale = language().toLowerCase().startsWith("zh") ? "zh" : "en";
184
+ export const S = locale === "zh" ? zh : en;