cortico 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (311) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +47 -0
  3. package/package.json +43 -0
  4. package/src/boot.ts +46 -0
  5. package/src/bot.ts +1342 -0
  6. package/src/config-file.ts +41 -0
  7. package/src/core/README.md +92 -0
  8. package/src/core/billing.ts +26 -0
  9. package/src/core/blobs.ts +106 -0
  10. package/src/core/bus.ts +311 -0
  11. package/src/core/config-schema.ts +201 -0
  12. package/src/core/config.ts +262 -0
  13. package/src/core/core.ts +699 -0
  14. package/src/core/cost.ts +244 -0
  15. package/src/core/event-store.ts +304 -0
  16. package/src/core/fork.ts +113 -0
  17. package/src/core/generation.ts +118 -0
  18. package/src/core/instance-lock.ts +215 -0
  19. package/src/core/ipc-logger.ts +105 -0
  20. package/src/core/language.ts +62 -0
  21. package/src/core/log-context.ts +38 -0
  22. package/src/core/loop.ts +1858 -0
  23. package/src/core/markers.ts +48 -0
  24. package/src/core/prefix.ts +121 -0
  25. package/src/core/run.ts +95 -0
  26. package/src/core/secrets.ts +18 -0
  27. package/src/core/session.ts +56 -0
  28. package/src/core/sessions.ts +261 -0
  29. package/src/core/state.ts +104 -0
  30. package/src/core/template.ts +72 -0
  31. package/src/core/timers.ts +129 -0
  32. package/src/core/tool-log.ts +135 -0
  33. package/src/core/transcript.ts +92 -0
  34. package/src/core/truncate.ts +121 -0
  35. package/src/core/types.ts +1140 -0
  36. package/src/core/usage-log.ts +79 -0
  37. package/src/core/util.ts +386 -0
  38. package/src/deploy-listing.ts +160 -0
  39. package/src/deploy.ts +162 -0
  40. package/src/extensions/README.md +72 -0
  41. package/src/extensions/dry-mount.ts +390 -0
  42. package/src/extensions/manifest.ts +153 -0
  43. package/src/extensions/runtime.ts +42 -0
  44. package/src/extensions.ts +519 -0
  45. package/src/launcher.ts +285 -0
  46. package/src/paths.ts +155 -0
  47. package/src/protocol/open-responses/LICENSE +201 -0
  48. package/src/protocol/open-responses/README.md +14 -0
  49. package/src/protocol/open-responses/context-helpers.ts +27 -0
  50. package/src/protocol/open-responses/context-log.ts +59 -0
  51. package/src/protocol/open-responses/context.ts +89 -0
  52. package/src/protocol/open-responses/generated.ts +115 -0
  53. package/src/protocol/open-responses/index.ts +33 -0
  54. package/src/protocol/open-responses/openapi.json +4230 -0
  55. package/src/protocol/open-responses/stream.ts +146 -0
  56. package/src/protocol/open-responses/tokens.ts +31 -0
  57. package/src/providers/README.md +86 -0
  58. package/src/providers/base.ts +111 -0
  59. package/src/providers/configuration.ts +97 -0
  60. package/src/providers/console/config.ts +21 -0
  61. package/src/providers/console/settings.ts +443 -0
  62. package/src/providers/console/strings.ts +74 -0
  63. package/src/providers/console/types.ts +11 -0
  64. package/src/providers/llamacpp/archive.ts +148 -0
  65. package/src/providers/llamacpp/catalog.ts +247 -0
  66. package/src/providers/llamacpp/config.ts +36 -0
  67. package/src/providers/llamacpp/console/client.ts +6 -0
  68. package/src/providers/llamacpp/console/models-panel.ts +120 -0
  69. package/src/providers/llamacpp/console/runtime-panel.ts +173 -0
  70. package/src/providers/llamacpp/console/server.ts +153 -0
  71. package/src/providers/llamacpp/index.ts +95 -0
  72. package/src/providers/llamacpp/native.ts +51 -0
  73. package/src/providers/llamacpp/options.ts +117 -0
  74. package/src/providers/llamacpp/runtime-store.ts +139 -0
  75. package/src/providers/llamacpp/runtime.ts +214 -0
  76. package/src/providers/llamacpp/server.ts +286 -0
  77. package/src/providers/llamacpp/strings.ts +230 -0
  78. package/src/providers/openai-responses-compat/config.ts +20 -0
  79. package/src/providers/openai-responses-compat/index.ts +89 -0
  80. package/src/providers/openai-responses-compat/native.ts +127 -0
  81. package/src/providers/openai-responses-compat/strings.ts +19 -0
  82. package/src/providers/pricebook.ts +75 -0
  83. package/src/providers/registry.ts +137 -0
  84. package/src/providers/strings.ts +71 -0
  85. package/src/providers/transport/chat.ts +156 -0
  86. package/src/providers/transport/errors.ts +48 -0
  87. package/src/providers/transport/history.ts +68 -0
  88. package/src/providers/transport/native-input.ts +83 -0
  89. package/src/providers/transport/native-types.ts +13 -0
  90. package/src/providers/transport/response-assembly.ts +191 -0
  91. package/src/providers/transport/response-http.ts +196 -0
  92. package/src/providers/transport/response-meters.ts +27 -0
  93. package/src/providers/transport/responses-input.ts +56 -0
  94. package/src/web/README.md +84 -0
  95. package/src/web/client/console-pages/builtins/llm-settings/panel.ts +625 -0
  96. package/src/web/client/console-pages/builtins/llm-settings/pricing-panel.ts +168 -0
  97. package/src/web/client/console-pages/builtins/llm-settings/strings.ts +213 -0
  98. package/src/web/client/console-pages/builtins.ts +10 -0
  99. package/src/web/client/console-pages/context.ts +135 -0
  100. package/src/web/client/console-pages/host.ts +633 -0
  101. package/src/web/client/console-pages/loader.ts +132 -0
  102. package/src/web/client/console-pages/strings.ts +90 -0
  103. package/src/web/client/console-pages/tools/strings.ts +49 -0
  104. package/src/web/client/console-pages/tools/view.ts +215 -0
  105. package/src/web/client/core/api.ts +200 -0
  106. package/src/web/client/core/language.ts +56 -0
  107. package/src/web/client/core/lifecycle.ts +132 -0
  108. package/src/web/client/core/router.ts +199 -0
  109. package/src/web/client/core/stream.ts +157 -0
  110. package/src/web/client/core/websocket.ts +82 -0
  111. package/src/web/client/features/appearance/index.ts +333 -0
  112. package/src/web/client/features/appearance/strings.ts +87 -0
  113. package/src/web/client/features/config/index.ts +11 -0
  114. package/src/web/client/features/config/strings.ts +41 -0
  115. package/src/web/client/features/config/view.ts +428 -0
  116. package/src/web/client/features/core/events.ts +197 -0
  117. package/src/web/client/features/core/index.ts +254 -0
  118. package/src/web/client/features/core/run.ts +56 -0
  119. package/src/web/client/features/core/runlog.ts +214 -0
  120. package/src/web/client/features/core/sessions.ts +53 -0
  121. package/src/web/client/features/core/strings.ts +157 -0
  122. package/src/web/client/features/extensions/index.ts +422 -0
  123. package/src/web/client/features/extensions/strings.ts +164 -0
  124. package/src/web/client/features/feature.ts +93 -0
  125. package/src/web/client/features/live/context.ts +280 -0
  126. package/src/web/client/features/live/fork.ts +156 -0
  127. package/src/web/client/features/live/index.ts +392 -0
  128. package/src/web/client/features/live/onboarding.ts +113 -0
  129. package/src/web/client/features/live/protocol.ts +122 -0
  130. package/src/web/client/features/live/sessions.ts +71 -0
  131. package/src/web/client/features/live/status.ts +68 -0
  132. package/src/web/client/features/live/strings.ts +252 -0
  133. package/src/web/client/features/live/timeline.ts +590 -0
  134. package/src/web/client/features/prompts/editor.ts +292 -0
  135. package/src/web/client/features/prompts/index.ts +346 -0
  136. package/src/web/client/features/prompts/strings.ts +136 -0
  137. package/src/web/client/features/prompts/view.ts +256 -0
  138. package/src/web/client/features/providers/index.ts +100 -0
  139. package/src/web/client/features/providers/strings.ts +23 -0
  140. package/src/web/client/features/settings/general.ts +28 -0
  141. package/src/web/client/features/settings/index.ts +82 -0
  142. package/src/web/client/features/settings/strings.ts +33 -0
  143. package/src/web/client/features/storage/index.ts +1 -0
  144. package/src/web/client/features/storage/strings.ts +45 -0
  145. package/src/web/client/features/storage/view.ts +154 -0
  146. package/src/web/client/features/usage/chart.ts +486 -0
  147. package/src/web/client/features/usage/index.ts +407 -0
  148. package/src/web/client/features/usage/labels.ts +46 -0
  149. package/src/web/client/features/usage/range.ts +36 -0
  150. package/src/web/client/features/usage/state.ts +37 -0
  151. package/src/web/client/features/usage/strings.ts +191 -0
  152. package/src/web/client/features/usage/tooltip.ts +86 -0
  153. package/src/web/client/features/usage/types.ts +96 -0
  154. package/src/web/client/features/worlds/index.ts +424 -0
  155. package/src/web/client/features/worlds/strings.ts +121 -0
  156. package/src/web/client/main.ts +273 -0
  157. package/src/web/client/shell/avatar.ts +233 -0
  158. package/src/web/client/shell/index.ts +549 -0
  159. package/src/web/client/shell/strings.ts +89 -0
  160. package/src/web/client/theme/handoff.ts +43 -0
  161. package/src/web/client/theme/palette.ts +109 -0
  162. package/src/web/client/theme/registry.ts +130 -0
  163. package/src/web/client/theme/storage.ts +72 -0
  164. package/src/web/client/theme/strings.ts +123 -0
  165. package/src/web/client/theme/studio.ts +366 -0
  166. package/src/web/client/ui/actions.ts +109 -0
  167. package/src/web/client/ui/data.ts +185 -0
  168. package/src/web/client/ui/dom.ts +23 -0
  169. package/src/web/client/ui/fields.ts +191 -0
  170. package/src/web/client/ui/format.ts +75 -0
  171. package/src/web/client/ui/icons.ts +183 -0
  172. package/src/web/client/ui/images.ts +91 -0
  173. package/src/web/client/ui/index.ts +89 -0
  174. package/src/web/client/ui/lamp.ts +125 -0
  175. package/src/web/client/ui/log.ts +98 -0
  176. package/src/web/client/ui/overlay.ts +184 -0
  177. package/src/web/client/ui/page.ts +8 -0
  178. package/src/web/client/ui/prompt-input.tsx +311 -0
  179. package/src/web/client/ui/sheet.ts +131 -0
  180. package/src/web/client/ui/strings.ts +71 -0
  181. package/src/web/console-pages.ts +367 -0
  182. package/src/web/files.ts +107 -0
  183. package/src/web/path-picker.ts +296 -0
  184. package/src/web/public/index.html +17 -0
  185. package/src/web/public/styles.css +1715 -0
  186. package/src/web/server.ts +1883 -0
  187. package/src/web/shared/client-panel.ts +603 -0
  188. package/src/web/shared/console-protocol.ts +560 -0
  189. package/src/web/shared/css.d.ts +1 -0
  190. package/src/web/shared/path-picker.ts +23 -0
  191. package/src/web/shared/theme.ts +256 -0
  192. package/src/web/theme-store.ts +37 -0
  193. package/src/world.ts +449 -0
  194. package/src/worlds/bilibili/ENV_PROMPT.md +5 -0
  195. package/src/worlds/bilibili/README.md +176 -0
  196. package/src/worlds/bilibili/audience-admission.ts +995 -0
  197. package/src/worlds/bilibili/client.ts +528 -0
  198. package/src/worlds/bilibili/coalescing-buffer.ts +125 -0
  199. package/src/worlds/bilibili/config.ts +185 -0
  200. package/src/worlds/bilibili/console/client.ts +202 -0
  201. package/src/worlds/bilibili/definition.ts +35 -0
  202. package/src/worlds/bilibili/gift-frame.ts +131 -0
  203. package/src/worlds/bilibili/normalize.ts +452 -0
  204. package/src/worlds/bilibili/overlay/announcement.ts +76 -0
  205. package/src/worlds/bilibili/overlay/assets.ts +82 -0
  206. package/src/worlds/bilibili/overlay/model.ts +494 -0
  207. package/src/worlds/bilibili/overlay/project.ts +202 -0
  208. package/src/worlds/bilibili/overlay/server.ts +286 -0
  209. package/src/worlds/bilibili/overlay/types.ts +217 -0
  210. package/src/worlds/bilibili/overlay/web/app.js +690 -0
  211. package/src/worlds/bilibili/overlay/web/editor.css +297 -0
  212. package/src/worlds/bilibili/overlay/web/editor.html +102 -0
  213. package/src/worlds/bilibili/overlay/web/editor.js +2116 -0
  214. package/src/worlds/bilibili/overlay/web/overlay.html +13 -0
  215. package/src/worlds/bilibili/overlay/web/styles.css +258 -0
  216. package/src/worlds/bilibili/protobuf.ts +123 -0
  217. package/src/worlds/bilibili/wire.ts +94 -0
  218. package/src/worlds/bilibili/world.ts +1389 -0
  219. package/src/worlds/console-fixture/ENV_PROMPT.md +1 -0
  220. package/src/worlds/console-fixture/console/client.ts +72 -0
  221. package/src/worlds/console-fixture/world.ts +73 -0
  222. package/src/worlds/index.ts +15 -0
  223. package/src/worlds/minecraft/ENV_PROMPT.md +32 -0
  224. package/src/worlds/minecraft/ENV_PROMPT_CAMERA.md +2 -0
  225. package/src/worlds/minecraft/LICENSE-mineflayer-pathfinder.txt +21 -0
  226. package/src/worlds/minecraft/README.md +917 -0
  227. package/src/worlds/minecraft/blueprint-plan.ts +915 -0
  228. package/src/worlds/minecraft/blueprint-registry.ts +566 -0
  229. package/src/worlds/minecraft/blueprint-repair.ts +236 -0
  230. package/src/worlds/minecraft/blueprint-resource.ts +272 -0
  231. package/src/worlds/minecraft/blueprint.ts +492 -0
  232. package/src/worlds/minecraft/body-lease.ts +340 -0
  233. package/src/worlds/minecraft/bridge.ts +749 -0
  234. package/src/worlds/minecraft/check.ts +651 -0
  235. package/src/worlds/minecraft/chests.ts +292 -0
  236. package/src/worlds/minecraft/client-launch.ts +272 -0
  237. package/src/worlds/minecraft/client-options.ts +85 -0
  238. package/src/worlds/minecraft/client-skins.ts +164 -0
  239. package/src/worlds/minecraft/client-window.ps1 +91 -0
  240. package/src/worlds/minecraft/client.ts +423 -0
  241. package/src/worlds/minecraft/combat-context.ts +109 -0
  242. package/src/worlds/minecraft/combat.ts +1552 -0
  243. package/src/worlds/minecraft/config.ts +499 -0
  244. package/src/worlds/minecraft/console/access.ts +218 -0
  245. package/src/worlds/minecraft/console/client.ts +244 -0
  246. package/src/worlds/minecraft/console/log.ts +110 -0
  247. package/src/worlds/minecraft/console/mount.ts +420 -0
  248. package/src/worlds/minecraft/console/skin.ts +257 -0
  249. package/src/worlds/minecraft/console/style.css +154 -0
  250. package/src/worlds/minecraft/console/world.ts +449 -0
  251. package/src/worlds/minecraft/deaths.ts +135 -0
  252. package/src/worlds/minecraft/definition.ts +18 -0
  253. package/src/worlds/minecraft/engine-child.ts +274 -0
  254. package/src/worlds/minecraft/engine-ipc.ts +98 -0
  255. package/src/worlds/minecraft/entity-facts.ts +132 -0
  256. package/src/worlds/minecraft/escape.ts +407 -0
  257. package/src/worlds/minecraft/executor.ts +14494 -0
  258. package/src/worlds/minecraft/explored.ts +156 -0
  259. package/src/worlds/minecraft/geometry.ts +205 -0
  260. package/src/worlds/minecraft/goal-plan.ts +647 -0
  261. package/src/worlds/minecraft/item-break.ts +126 -0
  262. package/src/worlds/minecraft/item-facts.ts +146 -0
  263. package/src/worlds/minecraft/item-pick.ts +67 -0
  264. package/src/worlds/minecraft/level-dat.ts +176 -0
  265. package/src/worlds/minecraft/log.ts +132 -0
  266. package/src/worlds/minecraft/mineflayer-fixes.ts +1180 -0
  267. package/src/worlds/minecraft/names.ts +377 -0
  268. package/src/worlds/minecraft/pathfinder-lib.d.ts +13 -0
  269. package/src/worlds/minecraft/pathfinder-perf.ts +796 -0
  270. package/src/worlds/minecraft/piglin.ts +49 -0
  271. package/src/worlds/minecraft/policy.ts +547 -0
  272. package/src/worlds/minecraft/precheck.ts +655 -0
  273. package/src/worlds/minecraft/proxy.ts +445 -0
  274. package/src/worlds/minecraft/ranged.ts +635 -0
  275. package/src/worlds/minecraft/readouts.ts +102 -0
  276. package/src/worlds/minecraft/round.ts +26 -0
  277. package/src/worlds/minecraft/search-observation.ts +92 -0
  278. package/src/worlds/minecraft/server-config.ts +467 -0
  279. package/src/worlds/minecraft/server.ts +658 -0
  280. package/src/worlds/minecraft/show.ts +84 -0
  281. package/src/worlds/minecraft/skills.ts +1763 -0
  282. package/src/worlds/minecraft/terrain.ts +1735 -0
  283. package/src/worlds/minecraft/window.ts +96 -0
  284. package/src/worlds/minecraft/works.ts +179 -0
  285. package/src/worlds/minecraft/world.ts +6438 -0
  286. package/src/worlds/qq/ENV_PROMPT.md +5 -0
  287. package/src/worlds/qq/config.ts +108 -0
  288. package/src/worlds/qq/console/client.ts +126 -0
  289. package/src/worlds/qq/console/events.ts +155 -0
  290. package/src/worlds/qq/console/gate.ts +232 -0
  291. package/src/worlds/qq/console/roster.ts +203 -0
  292. package/src/worlds/qq/console/style.css +65 -0
  293. package/src/worlds/qq/conversation.ts +28 -0
  294. package/src/worlds/qq/definition.ts +62 -0
  295. package/src/worlds/qq/driver.ts +375 -0
  296. package/src/worlds/qq/history-tools.ts +209 -0
  297. package/src/worlds/qq/normalize.ts +323 -0
  298. package/src/worlds/qq/qface-map.ts +282 -0
  299. package/src/worlds/qq/vision-prompt.ts +27 -0
  300. package/src/worlds/qq/vision.ts +642 -0
  301. package/src/worlds/qq/vlm.ts +142 -0
  302. package/src/worlds/qq/world.ts +1503 -0
  303. package/src/worlds/terminal/ENV_PROMPT.md +11 -0
  304. package/src/worlds/terminal/config.ts +9 -0
  305. package/src/worlds/terminal/definition.ts +14 -0
  306. package/src/worlds/terminal/world.ts +700 -0
  307. package/src/worlds/websearch/ENV_PROMPT.md +1 -0
  308. package/src/worlds/websearch/brave-client.ts +261 -0
  309. package/src/worlds/websearch/config.ts +75 -0
  310. package/src/worlds/websearch/definition.ts +20 -0
  311. package/src/worlds/websearch/world.ts +171 -0
@@ -0,0 +1,68 @@
1
+ /**
2
+ * 终端页只读状态条,使用 ui.chip 的统一 tone。控制动作归其他控制页;本 feature 仅更新 document.title,品牌名与面包屑由 host 根据状态渲染。
3
+ */
4
+
5
+ import type { ConsoleUi } from '../../../shared/client-panel.ts';
6
+ import { chipsOf, loopOf, type StatusSnapshot } from './protocol.ts';
7
+ import { S } from './strings.ts';
8
+
9
+ /** 一枚 chip:纯文本片段与要加粗的读数交替。 */
10
+ type ChipPart = string | { b: string | number };
11
+
12
+ function chipOf(ui: ConsoleUi, parts: readonly ChipPart[]): HTMLElement {
13
+ const c = ui.chip('');
14
+ for (const p of parts) {
15
+ if (typeof p === 'string') c.appendChild(ui.h('span', null, p));
16
+ else c.appendChild(ui.h('b', null, String(p.b)));
17
+ }
18
+ return c;
19
+ }
20
+
21
+ /**
22
+ * 展示名来自部署配置(`/api/status` 的 `displayName`)——**框架自己不预设身份**。
23
+ * 返回是否真的改了,免得每一帧心跳都去写一次 `document.title`。
24
+ */
25
+ export function applyDisplayName(doc: Document, name: string | undefined, current: string): boolean {
26
+ if (!name || name === current) return false;
27
+ doc.title = S.docTitle(name);
28
+ return true;
29
+ }
30
+
31
+ export interface StatusBand {
32
+ el: HTMLElement;
33
+ render(st: StatusSnapshot | null): void;
34
+ }
35
+
36
+ export function createStatusBand(ui: ConsoleUi): StatusBand {
37
+ const el = ui.h('div', 'chips');
38
+ return {
39
+ el,
40
+ render(st) {
41
+ while (el.children.length) el.children[0].remove();
42
+ if (!st) {
43
+ el.appendChild(ui.chip(S.chipDisconnected));
44
+ return;
45
+ }
46
+ const loop = loopOf(st);
47
+ if (loop.estTokens != null) {
48
+ el.appendChild(chipOf(ui, [{ b: ui.fmt.count(loop.estTokens) }, ' tok']));
49
+ }
50
+ if (loop.messageCount != null) el.appendChild(chipOf(ui, [{ b: loop.messageCount }, S.chipMsgs]));
51
+ const u = loop.lastUsage;
52
+ if (u && u.promptTokens) {
53
+ el.appendChild(
54
+ chipOf(ui, [S.chipCache, { b: ui.fmt.percent((u.cacheHitTokens || 0) / u.promptTokens) }]),
55
+ );
56
+ }
57
+ if (loop.batchesHandled != null) {
58
+ el.appendChild(chipOf(ui, [S.chipBatchesPre, { b: loop.batchesHandled }, S.chipBatchesPost]));
59
+ }
60
+ if (loop.paused) el.appendChild(ui.chip(S.chipPaused, 'warn'));
61
+ else if (loop.scheduleBlocked) el.appendChild(ui.chip(S.chipScheduleBlocked, 'warn'));
62
+ if (loop.truncating) el.appendChild(ui.chip(S.chipTruncating, 'accent'));
63
+ // 人格概念(「梦中」这类)由Persona自报文本,框架照画不解释。
64
+ for (const chip of chipsOf(st)) el.appendChild(ui.chip(chip.label, chip.tone));
65
+ if (st.terminalOnline != null) el.appendChild(chipOf(ui, [S.chipOnline, { b: st.terminalOnline }]));
66
+ },
67
+ };
68
+ }
@@ -0,0 +1,252 @@
1
+ import { pick } from '../../core/language.ts';
2
+
3
+ const zh = {
4
+ // index.ts
5
+ navLabel: '终端',
6
+ ctxOpenAria: '查看 token 分类',
7
+ ctxPanelAria: 'Token 分类',
8
+ netConnecting: '连接中…',
9
+ netOnline: '已连接',
10
+ netOffline: '接口不可达',
11
+ composerLabel: '终端消息输入',
12
+ composerPlaceholder: "输入消息…",
13
+ composerHint: 'Terminal · Enter 发送 · 可粘贴或拖入图片',
14
+ composerNoProvider: '当前无可用 Provider,请前往「模型提供商」页设置',
15
+ composerQueued: '终端通道正在重连,消息已排队',
16
+ emptyConnecting: '连接调试通道中…',
17
+ ctxTitle: (total: string, max: string | null) =>
18
+ `上下文 ${total}${max !== null ? ` / ${max}` : ''} tok · 点击查看分类`,
19
+ ctxWaiting: '等待上下文数据',
20
+ sessionResetNote: 'SESSION 已截断重建',
21
+ debugUnavailable: '调试通道不可用',
22
+ debugNotMounted: "调试通道不可用,无法显示时间线。",
23
+
24
+ // status.ts
25
+ docTitle: (name: string) => `控制台 · ${name}`,
26
+ chipDisconnected: '未连接',
27
+ chipMsgs: ' 条',
28
+ chipCache: '缓存 ',
29
+ chipBatchesPre: '累计 ',
30
+ chipBatchesPost: ' 批',
31
+ chipPaused: '⏸ 已暂停',
32
+ chipScheduleBlocked: '◷ 闹钟阻断',
33
+ chipTruncating: '截断中',
34
+ chipOnline: '在线 ',
35
+
36
+ // fork.ts
37
+ mainLabel: "主 session",
38
+ forkViewing: '◉ 正在查看 ',
39
+ forkInfo: (count: number, tok: string, ended: boolean, sec: number) =>
40
+ ` · ${count} 条 · ~${tok} tok · ` + (ended ? '已结束(定格)' : `进行中(${sec} 秒刷新)`),
41
+ forkBack: '⏎ 返回主 session',
42
+ forkEmpty: '(这个 session 还没有消息)',
43
+ forkFetchFailed: (msg: string) => `(拉取失败: ${msg})`,
44
+
45
+ // sessions.ts
46
+ sessionBandTitle: "Session 本次运行累计用量",
47
+ sessionCache: (pct: string) => `缓存${pct}`,
48
+ sessionCardTitle: (
49
+ label: string,
50
+ id: string,
51
+ running: boolean,
52
+ endedAt: string,
53
+ prompt: number,
54
+ completion: number,
55
+ hit: number,
56
+ ) =>
57
+ `${label} (${id})\n` +
58
+ `${running ? '进行中' : `已结束 ${endedAt}`}\n` +
59
+ `输入 ${prompt} / 输出 ${completion} / 命中 ${hit}`,
60
+
61
+ // timeline.ts
62
+ thinking: '思考中…',
63
+ jumpBottom: '↓ 回到底部',
64
+ foldHead: (open: boolean, n: number) => `${open ? '▾' : '▸'} ${n} 字`,
65
+ ordinalTitle: (index: number) => `session 第 ${index} 条 Item`,
66
+ userGlyphTitle: 'user 消息',
67
+ empty: '(空)',
68
+ visibleReasoning: (n: number) => `可见思考 ${n} 字`,
69
+ encryptedReasoning: (n: number) => `加密思考 ${n} 字符`,
70
+ summary: '摘要',
71
+ monologTitle: (phase: string) => `assistant 正文${phase ? ` · ${phase}` : ''}`,
72
+ refusal: '拒绝',
73
+ synthetic: '合成',
74
+ encryptedPayload: (n: number) => `加密载荷 ${n} 字符`,
75
+ rawItems: '原始 Item',
76
+ headStart: '合成开头 · 不落盘',
77
+ headEnd: '合成开头 · 结束',
78
+ sessionEmpty: 'session 为空',
79
+
80
+ // context.ts
81
+ groupPrefix: '系统前缀',
82
+ groupTools: '工具',
83
+ groupDialogue: '对话',
84
+ catOrient: 'ORIENTATION',
85
+ catConstitution: '宪法 CONSTITUTION',
86
+ catEnv: '环境描述 · World',
87
+ catToolsUsage: '工具用法说明',
88
+ catMemory: '记忆 MEMORY',
89
+ catPrefixMisc: '前言 / 分隔 / 结构',
90
+ catToolsSchema: '工具表 schema',
91
+ catHead: '合成开头',
92
+ catReasoning: '思维链',
93
+ catDialogue: '对话往来 · 事件',
94
+ catToolIO: '工具调用与结果',
95
+ ctxNone: "暂无上下文数据。",
96
+ ctxUsage: '上下文占用',
97
+ ctxSub: (budgetPct: string | null, keepOn: boolean) =>
98
+ `${budgetPct === null ? '预算未知' : `占预算 ${budgetPct}`} · 保留历史思维链:${keepOn ? '开' : '关'}`,
99
+ toolCount: (n: number) => ` ${n} 个`,
100
+ footCountedPre: '总数以上游计数为准(上一发已数 ',
101
+ footCountedPost: ',之后新增的本地估算);分类按本地估算等比分摊,只看比例。',
102
+ footEstimated: '还没有上游计数,整份按字数估算(中文≈0.6、其余≈0.3 token/字,每条 +8 结构开销);下一发调用后以上游计数为准。',
103
+ footSchemaB: '工具表 schema',
104
+ footSchemaPost: ' 作为 tools 参数随每次调用发送,与消息分开计。',
105
+ footStrippedPre: '历史思维链已丢弃约 ',
106
+ footStrippedPost: " tok,不发送。",
107
+ footHardPre: '越过 ',
108
+ footHardPost: '(模型物理上限)由 core 强制交接。',
109
+ footSoftPre: 'Persona 软阈值:',
110
+ footSoftPost: (max: string) => `;阶段预算 ${max}。`,
111
+
112
+ // onboarding.ts
113
+ obWho: 'Cortico',
114
+ obWelcome: '欢迎使用 Cortico。',
115
+ obProvider: '配置模型提供商后即可开始对话。',
116
+ obProviderNone: '尚未配置可用的模型提供商',
117
+ obProviderReady: '模型提供商已配置',
118
+ obWorlds: '按需启用 World,也可以仅使用终端对话。',
119
+ obWorldsState: (labels: readonly string[]) => `已启用 ${labels.length} 个 World:${labels.join('、')}`,
120
+ obPrompts: '系统提示词定义人格描述、行为规范和语言风格,可按需修改。',
121
+ obReady: '配置好后,可以邀请 bot 开口。',
122
+ obGoConfigure: '前往配置',
123
+ obGoEdit: '开始编辑',
124
+ obStart: '打个招呼?',
125
+ };
126
+
127
+ const en: typeof zh = {
128
+ // index.ts
129
+ navLabel: 'Terminal',
130
+ ctxOpenAria: 'View token breakdown',
131
+ ctxPanelAria: 'Token breakdown',
132
+ netConnecting: 'Connecting…',
133
+ netOnline: 'Connected',
134
+ netOffline: 'API unreachable',
135
+ composerLabel: 'Terminal message input',
136
+ composerPlaceholder: "Enter a message…",
137
+ composerHint: 'Terminal · Enter to send · paste or drop images',
138
+ composerNoProvider: 'No usable provider. Set one up on the LLM Provider page.',
139
+ composerQueued: 'Terminal channel is reconnecting; message queued',
140
+ emptyConnecting: 'Connecting to the debug channel…',
141
+ ctxTitle: (total: string, max: string | null) =>
142
+ `Context ${total}${max !== null ? ` / ${max}` : ''} tok · click for breakdown`,
143
+ ctxWaiting: 'Waiting for context data',
144
+ sessionResetNote: 'SESSION truncated and rebuilt',
145
+ debugUnavailable: 'Debug channel unavailable',
146
+ debugNotMounted: "Debug channel unavailable; the timeline cannot be displayed.",
147
+
148
+ // status.ts
149
+ docTitle: (name: string) => `Console · ${name}`,
150
+ chipDisconnected: 'Disconnected',
151
+ chipMsgs: ' msgs',
152
+ chipCache: 'cache ',
153
+ chipBatchesPre: 'total ',
154
+ chipBatchesPost: ' batches',
155
+ chipPaused: '⏸ Paused',
156
+ chipScheduleBlocked: '◷ Schedule blocked',
157
+ chipTruncating: 'Truncating',
158
+ chipOnline: 'online ',
159
+
160
+ // fork.ts
161
+ mainLabel: "Main session",
162
+ forkViewing: '◉ Viewing ',
163
+ forkInfo: (count: number, tok: string, ended: boolean, sec: number) =>
164
+ ` · ${count} msgs · ~${tok} tok · ` + (ended ? 'ended (frozen)' : `running (refreshes every ${sec} s)`),
165
+ forkBack: '⏎ Back to main session',
166
+ forkEmpty: '(This session has no messages yet)',
167
+ forkFetchFailed: (msg: string) => `(fetch failed: ${msg})`,
168
+
169
+ // sessions.ts
170
+ sessionBandTitle: "Session usage for this run",
171
+ sessionCache: (pct: string) => `cache ${pct}`,
172
+ sessionCardTitle: (
173
+ label: string,
174
+ id: string,
175
+ running: boolean,
176
+ endedAt: string,
177
+ prompt: number,
178
+ completion: number,
179
+ hit: number,
180
+ ) =>
181
+ `${label} (${id})\n` +
182
+ `${running ? 'running' : `ended ${endedAt}`}\n` +
183
+ `input ${prompt} / output ${completion} / cache hits ${hit}`,
184
+
185
+ // timeline.ts
186
+ thinking: 'Thinking…',
187
+ jumpBottom: '↓ Back to bottom',
188
+ foldHead: (open: boolean, n: number) => `${open ? '▾' : '▸'} ${n} chars`,
189
+ ordinalTitle: (index: number) => `Item #${index} in session`,
190
+ userGlyphTitle: 'user message',
191
+ empty: '(empty)',
192
+ visibleReasoning: (n: number) => `Visible reasoning ${n} chars`,
193
+ encryptedReasoning: (n: number) => `Encrypted reasoning ${n} chars`,
194
+ summary: 'Summary',
195
+ monologTitle: (phase: string) => `assistant text${phase ? ` · ${phase}` : ''}`,
196
+ refusal: 'Refusal',
197
+ synthetic: 'synthetic',
198
+ encryptedPayload: (n: number) => `Encrypted payload ${n} chars`,
199
+ rawItems: 'Raw Items',
200
+ headStart: 'Session head · not persisted',
201
+ headEnd: 'Session head · end',
202
+ sessionEmpty: 'session is empty',
203
+
204
+ // context.ts
205
+ groupPrefix: 'System prefix',
206
+ groupTools: 'Tools',
207
+ groupDialogue: 'Conversation',
208
+ catOrient: 'ORIENTATION',
209
+ catConstitution: 'CONSTITUTION',
210
+ catEnv: 'Environment · World',
211
+ catToolsUsage: 'Tool usage notes',
212
+ catMemory: 'MEMORY',
213
+ catPrefixMisc: 'Preamble / separators / structure',
214
+ catToolsSchema: 'Tool schemas',
215
+ catHead: 'Session head (synthetic)',
216
+ catReasoning: 'Reasoning',
217
+ catDialogue: 'Dialogue · events',
218
+ catToolIO: 'Tool calls and results',
219
+ ctxNone: "No context data yet.",
220
+ ctxUsage: 'Context usage',
221
+ ctxSub: (budgetPct: string | null, keepOn: boolean) =>
222
+ `${budgetPct === null ? 'Budget unknown' : `${budgetPct} of budget`} · Keep past reasoning: ${keepOn ? 'on' : 'off'}`,
223
+ toolCount: (n: number) => ` (${n})`,
224
+ footCountedPre: 'The total follows the upstream count (the last call counted ',
225
+ footCountedPost: '; later additions are local estimates); categories are prorated from local estimates — read them as ratios only.',
226
+ footEstimated: 'No upstream count yet; the whole context is estimated by characters (CJK ≈ 0.6, others ≈ 0.3 token/char, +8 structural overhead per item); the upstream count takes over after the next call.',
227
+ footSchemaB: 'Tool schemas',
228
+ footSchemaPost: ' are sent as the tools parameter with every call and counted separately from messages.',
229
+ footStrippedPre: 'About ',
230
+ footStrippedPost: " tok of past reasoning is excluded from requests.",
231
+ footHardPre: 'Beyond ',
232
+ footHardPost: ' (the model\'s hard limit) the core forces a handoff.',
233
+ footSoftPre: 'Persona soft threshold: ',
234
+ footSoftPost: (max: string) => `; stage budget ${max}.`,
235
+
236
+ // onboarding.ts
237
+ obWho: 'Cortico',
238
+ obWelcome: "Welcome to Cortico.",
239
+ obProvider: 'Configure a model provider to start chatting.',
240
+ obProviderNone: 'No usable model provider yet',
241
+ obProviderReady: 'Model provider configured',
242
+ obWorlds: 'Enable Worlds as needed, or use terminal chat alone.',
243
+ obWorldsState: (labels: readonly string[]) =>
244
+ `Currently ${labels.length} external environment${labels.length === 1 ? '' : 's'} enabled: ${labels.join(', ')}`,
245
+ obPrompts: 'You can edit the system prompt to set personality, behavior and language style.',
246
+ obReady: 'Once configured, you can invite the bot to speak.',
247
+ obGoConfigure: 'Configure',
248
+ obGoEdit: 'Edit',
249
+ obStart: 'Say hello?',
250
+ };
251
+
252
+ export const S = pick({ zh, en });