@evandu/super-pi-server 0.0.0-stage → 0.1.259

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 (370) hide show
  1. package/README.md +248 -3
  2. package/agents/code-auditor.md +64 -0
  3. package/agents/code-designer.md +64 -0
  4. package/agents/coder.md +24 -0
  5. package/agents/critic.md +24 -0
  6. package/agents/document-organizer.md +48 -0
  7. package/agents/patcher.md +27 -0
  8. package/agents/planner.md +30 -0
  9. package/agents/project-leader.md +28 -0
  10. package/agents/reviewer.md +27 -0
  11. package/agents/scout.md +27 -0
  12. package/agents/solution-designer.md +62 -0
  13. package/agents/super-pi-documents/index.ts +92 -0
  14. package/agents/super-pi-feishu/index.ts +88 -0
  15. package/agents/super-pi-knowledge/index.ts +70 -0
  16. package/agents/super-pi-managed-model/index.ts +9 -0
  17. package/agents/super-pi-memory/index.ts +75 -0
  18. package/agents/super-pi-native-tools/index.ts +1 -0
  19. package/agents/super-pi-task/core.ts +2262 -0
  20. package/agents/super-pi-task/index.ts +814 -0
  21. package/agents/super-pi-task/workflow-schema.ts +34 -0
  22. package/agents/super-pi-web/index.ts +32 -0
  23. package/agents/verifier.md +25 -0
  24. package/assets/fonts/LICENSE +92 -0
  25. package/assets/fonts/NotoSansSC-Bold.otf +0 -0
  26. package/assets/fonts/NotoSansSC-Regular.otf +0 -0
  27. package/assets/knowledge-model/README.md +37 -0
  28. package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/config.json +31 -0
  29. package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/onnx/model_quantized.onnx +0 -0
  30. package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/special_tokens_map.json +7 -0
  31. package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/tokenizer.json +21278 -0
  32. package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/tokenizer_config.json +15 -0
  33. package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/vocab.txt +21128 -0
  34. package/bin/npm-prefix.d.ts +1 -0
  35. package/bin/npm-prefix.js +10 -0
  36. package/bin/super-pi.js +349 -0
  37. package/dist/client/.super-pi-client-sources.json +82 -0
  38. package/dist/client/assets/CodeMirrorEditor-mi9rGUce.js +2 -0
  39. package/dist/client/assets/GitDiffEditor-CpoDDQrA.css +1 -0
  40. package/dist/client/assets/GitDiffEditor-FQBfGxOY.js +29 -0
  41. package/dist/client/assets/diff-ChtP43wD.js +1 -0
  42. package/dist/client/assets/dist-AW5lyI3I.js +1 -0
  43. package/dist/client/assets/dist-B3-a6uF0.js +7 -0
  44. package/dist/client/assets/dist-BGxkyh6e.js +1 -0
  45. package/dist/client/assets/dist-BJxfd7yb.js +11 -0
  46. package/dist/client/assets/dist-BRVQKlcp.js +1 -0
  47. package/dist/client/assets/dist-BV64A9Ji.js +1 -0
  48. package/dist/client/assets/dist-BXAOrsjq.js +1 -0
  49. package/dist/client/assets/dist-CKF2Jksy.js +1 -0
  50. package/dist/client/assets/dist-CX_Hm4GS.js +1 -0
  51. package/dist/client/assets/dist-Cus6_oaF.js +2 -0
  52. package/dist/client/assets/dist-Cx00EZKR.js +23 -0
  53. package/dist/client/assets/dist-D71y2EI1.js +1 -0
  54. package/dist/client/assets/dist-D978o95T.js +5 -0
  55. package/dist/client/assets/dist-Dc1MBGAG.js +1 -0
  56. package/dist/client/assets/dist-Dds-qLxY.js +9 -0
  57. package/dist/client/assets/dist-DeD9copn.js +1 -0
  58. package/dist/client/assets/dist-DuvGReu-.js +6 -0
  59. package/dist/client/assets/dist-Dvb0SqcK.js +2 -0
  60. package/dist/client/assets/dist-J6XWqRpB.js +3 -0
  61. package/dist/client/assets/dist-QzbOCAU6.js +1 -0
  62. package/dist/client/assets/dist-moiMRpw_.js +1 -0
  63. package/dist/client/assets/dist-scBkrwv-.js +2 -0
  64. package/dist/client/assets/dockerfile-BDePf5PZ.js +1 -0
  65. package/dist/client/assets/index-Cn7hdrDw.js +350 -0
  66. package/dist/client/assets/index-UfzqdECL.css +1 -0
  67. package/dist/client/assets/powershell-D8WpQPaX.js +1 -0
  68. package/dist/client/assets/properties-C357ku5U.js +1 -0
  69. package/dist/client/assets/rolldown-runtime-XKyaHtl9.js +1 -0
  70. package/dist/client/assets/ruby-ChfNwlCY.js +1 -0
  71. package/dist/client/assets/shell-DwuoZtxw.js +1 -0
  72. package/dist/client/assets/swift-DKB6_1j6.js +1 -0
  73. package/dist/client/assets/toml-BPTmHmyx.js +1 -0
  74. package/dist/client/favicon.ico +0 -0
  75. package/dist/client/favicon.png +0 -0
  76. package/dist/client/favicon.svg +10 -0
  77. package/dist/client/index.html +18 -0
  78. package/dist/extension.d.ts +15 -0
  79. package/dist/extension.js +126 -0
  80. package/dist/server/active-memory.d.ts +247 -0
  81. package/dist/server/active-memory.js +669 -0
  82. package/dist/server/agents.d.ts +245 -0
  83. package/dist/server/agents.js +701 -0
  84. package/dist/server/application/catalog-service.d.ts +98 -0
  85. package/dist/server/application/catalog-service.js +245 -0
  86. package/dist/server/application/conversation-service.d.ts +245 -0
  87. package/dist/server/application/conversation-service.js +654 -0
  88. package/dist/server/application/document-service.d.ts +68 -0
  89. package/dist/server/application/document-service.js +120 -0
  90. package/dist/server/application/extension-ui-service.d.ts +44 -0
  91. package/dist/server/application/extension-ui-service.js +135 -0
  92. package/dist/server/application/feishu-service.d.ts +179 -0
  93. package/dist/server/application/feishu-service.js +358 -0
  94. package/dist/server/application/group-chat-service.d.ts +75 -0
  95. package/dist/server/application/group-chat-service.js +953 -0
  96. package/dist/server/application/group-execution.d.ts +15 -0
  97. package/dist/server/application/group-execution.js +77 -0
  98. package/dist/server/application/project-service.d.ts +464 -0
  99. package/dist/server/application/project-service.js +2523 -0
  100. package/dist/server/application/provider-service.d.ts +174 -0
  101. package/dist/server/application/provider-service.js +510 -0
  102. package/dist/server/application/run-service.d.ts +547 -0
  103. package/dist/server/application/run-service.js +2683 -0
  104. package/dist/server/application/scheduled-task-service.d.ts +184 -0
  105. package/dist/server/application/scheduled-task-service.js +391 -0
  106. package/dist/server/application/session-orchestrator-service.d.ts +388 -0
  107. package/dist/server/application/session-orchestrator-service.js +1146 -0
  108. package/dist/server/application/session-reminder-service.d.ts +59 -0
  109. package/dist/server/application/session-reminder-service.js +141 -0
  110. package/dist/server/application/session-watchdog.d.ts +171 -0
  111. package/dist/server/application/session-watchdog.js +284 -0
  112. package/dist/server/application/workspace-service.d.ts +52 -0
  113. package/dist/server/application/workspace-service.js +186 -0
  114. package/dist/server/application/worktree-service.d.ts +13 -0
  115. package/dist/server/application/worktree-service.js +76 -0
  116. package/dist/server/browser-access.d.ts +34 -0
  117. package/dist/server/browser-access.js +89 -0
  118. package/dist/server/capability.d.ts +105 -0
  119. package/dist/server/capability.js +170 -0
  120. package/dist/server/command-handler.d.ts +93 -0
  121. package/dist/server/command-handler.js +540 -0
  122. package/dist/server/content-search.d.ts +16 -0
  123. package/dist/server/content-search.js +235 -0
  124. package/dist/server/conversation-usage.d.ts +22 -0
  125. package/dist/server/conversation-usage.js +43 -0
  126. package/dist/server/documents.d.ts +152 -0
  127. package/dist/server/documents.js +998 -0
  128. package/dist/server/engineering-learning.d.ts +30 -0
  129. package/dist/server/engineering-learning.js +106 -0
  130. package/dist/server/exec-service.d.ts +45 -0
  131. package/dist/server/exec-service.js +167 -0
  132. package/dist/server/explicit-file-open.d.ts +34 -0
  133. package/dist/server/explicit-file-open.js +105 -0
  134. package/dist/server/failure-text.d.ts +18 -0
  135. package/dist/server/failure-text.js +44 -0
  136. package/dist/server/feishu-cli.d.ts +223 -0
  137. package/dist/server/feishu-cli.js +464 -0
  138. package/dist/server/file-changes.d.ts +119 -0
  139. package/dist/server/file-changes.js +280 -0
  140. package/dist/server/file-diff.d.ts +41 -0
  141. package/dist/server/file-diff.js +97 -0
  142. package/dist/server/file-index.d.ts +100 -0
  143. package/dist/server/file-index.js +296 -0
  144. package/dist/server/file-name-index.d.ts +160 -0
  145. package/dist/server/file-name-index.js +411 -0
  146. package/dist/server/files.d.ts +269 -0
  147. package/dist/server/files.js +748 -0
  148. package/dist/server/git.d.ts +245 -0
  149. package/dist/server/git.js +903 -0
  150. package/dist/server/http-server.d.ts +45 -0
  151. package/dist/server/http-server.js +3830 -0
  152. package/dist/server/index.d.ts +1 -0
  153. package/dist/server/index.js +485 -0
  154. package/dist/server/inline-thinking.d.ts +90 -0
  155. package/dist/server/inline-thinking.js +181 -0
  156. package/dist/server/json-comments.d.ts +14 -0
  157. package/dist/server/json-comments.js +71 -0
  158. package/dist/server/knowledge-embedding-worker.d.ts +1 -0
  159. package/dist/server/knowledge-embedding-worker.js +27 -0
  160. package/dist/server/knowledge-vectors.d.ts +150 -0
  161. package/dist/server/knowledge-vectors.js +385 -0
  162. package/dist/server/knowledge.d.ts +273 -0
  163. package/dist/server/knowledge.js +848 -0
  164. package/dist/server/length-continuation.d.ts +83 -0
  165. package/dist/server/length-continuation.js +118 -0
  166. package/dist/server/logging.d.ts +32 -0
  167. package/dist/server/logging.js +185 -0
  168. package/dist/server/managed-http-tunnel.d.ts +6 -0
  169. package/dist/server/managed-http-tunnel.js +85 -0
  170. package/dist/server/managed-http.d.ts +4 -0
  171. package/dist/server/managed-http.js +85 -0
  172. package/dist/server/managed-model-adapter.d.ts +17 -0
  173. package/dist/server/managed-model-adapter.js +75 -0
  174. package/dist/server/managed-model-gateway.d.ts +49 -0
  175. package/dist/server/managed-model-gateway.js +73 -0
  176. package/dist/server/managed-servers.d.ts +55 -0
  177. package/dist/server/managed-servers.js +392 -0
  178. package/dist/server/managed-ssh.d.ts +26 -0
  179. package/dist/server/managed-ssh.js +73 -0
  180. package/dist/server/manager-vault.d.ts +11 -0
  181. package/dist/server/manager-vault.js +67 -0
  182. package/dist/server/memory-recall.d.ts +25 -0
  183. package/dist/server/memory-recall.js +45 -0
  184. package/dist/server/memory.d.ts +67 -0
  185. package/dist/server/memory.js +216 -0
  186. package/dist/server/message-media.d.ts +7 -0
  187. package/dist/server/message-media.js +54 -0
  188. package/dist/server/model-context-window.d.ts +186 -0
  189. package/dist/server/model-context-window.js +444 -0
  190. package/dist/server/model-filter.d.ts +23 -0
  191. package/dist/server/model-filter.js +48 -0
  192. package/dist/server/models-store.d.ts +36 -0
  193. package/dist/server/models-store.js +132 -0
  194. package/dist/server/native-tool-settings.d.ts +25 -0
  195. package/dist/server/native-tool-settings.js +41 -0
  196. package/dist/server/native-tools-extension.d.ts +2 -0
  197. package/dist/server/native-tools-extension.js +39 -0
  198. package/dist/server/native-tools-service.d.ts +39 -0
  199. package/dist/server/native-tools-service.js +240 -0
  200. package/dist/server/persistence/app-state-repository.d.ts +65 -0
  201. package/dist/server/persistence/app-state-repository.js +1 -0
  202. package/dist/server/persistence/json-state-repository.d.ts +14 -0
  203. package/dist/server/persistence/json-state-repository.js +43 -0
  204. package/dist/server/persistence/open-state-store.d.ts +3 -0
  205. package/dist/server/persistence/open-state-store.js +35 -0
  206. package/dist/server/persistence/rename.d.ts +22 -0
  207. package/dist/server/persistence/rename.js +44 -0
  208. package/dist/server/persistence/sqlite-state-repository.d.ts +12 -0
  209. package/dist/server/persistence/sqlite-state-repository.js +264 -0
  210. package/dist/server/pi-command.d.ts +94 -0
  211. package/dist/server/pi-command.js +265 -0
  212. package/dist/server/pi-native.d.ts +12 -0
  213. package/dist/server/pi-native.js +16 -0
  214. package/dist/server/pi-session-events.d.ts +158 -0
  215. package/dist/server/pi-session-events.js +373 -0
  216. package/dist/server/pi-session-pool.d.ts +233 -0
  217. package/dist/server/pi-session-pool.js +382 -0
  218. package/dist/server/pi-session.d.ts +642 -0
  219. package/dist/server/pi-session.js +655 -0
  220. package/dist/server/presentations/schema.d.ts +120 -0
  221. package/dist/server/presentations/schema.js +128 -0
  222. package/dist/server/provider-network.d.ts +16 -0
  223. package/dist/server/provider-network.js +106 -0
  224. package/dist/server/provider-proxy.d.ts +18 -0
  225. package/dist/server/provider-proxy.js +200 -0
  226. package/dist/server/providers.d.ts +333 -0
  227. package/dist/server/providers.js +989 -0
  228. package/dist/server/remote-bootstrap.d.ts +17 -0
  229. package/dist/server/remote-bootstrap.js +119 -0
  230. package/dist/server/rpc-channel.d.ts +131 -0
  231. package/dist/server/rpc-channel.js +135 -0
  232. package/dist/server/runtime.d.ts +1393 -0
  233. package/dist/server/runtime.js +3286 -0
  234. package/dist/server/scheduled-tasks.d.ts +101 -0
  235. package/dist/server/scheduled-tasks.js +138 -0
  236. package/dist/server/server-context.d.ts +119 -0
  237. package/dist/server/server-context.js +1 -0
  238. package/dist/server/session-cwd.d.ts +19 -0
  239. package/dist/server/session-cwd.js +58 -0
  240. package/dist/server/session-ledger.d.ts +67 -0
  241. package/dist/server/session-ledger.js +76 -0
  242. package/dist/server/session-memory-scope.d.ts +4 -0
  243. package/dist/server/session-memory-scope.js +30 -0
  244. package/dist/server/session-repository.d.ts +100 -0
  245. package/dist/server/session-repository.js +246 -0
  246. package/dist/server/session-tree-scope.d.ts +125 -0
  247. package/dist/server/session-tree-scope.js +337 -0
  248. package/dist/server/skills.d.ts +23 -0
  249. package/dist/server/skills.js +190 -0
  250. package/dist/server/store.d.ts +1062 -0
  251. package/dist/server/store.js +3305 -0
  252. package/dist/server/subagent-runs.d.ts +185 -0
  253. package/dist/server/subagent-runs.js +383 -0
  254. package/dist/server/subagents.d.ts +200 -0
  255. package/dist/server/subagents.js +619 -0
  256. package/dist/server/task-tool.d.ts +282 -0
  257. package/dist/server/task-tool.js +507 -0
  258. package/dist/server/tavily.d.ts +32 -0
  259. package/dist/server/tavily.js +136 -0
  260. package/dist/server/team-context.d.ts +12 -0
  261. package/dist/server/team-context.js +180 -0
  262. package/dist/server/terminal.d.ts +163 -0
  263. package/dist/server/terminal.js +557 -0
  264. package/dist/server/thinking-level-discovery.d.ts +38 -0
  265. package/dist/server/thinking-level-discovery.js +183 -0
  266. package/dist/server/time-zone.d.ts +20 -0
  267. package/dist/server/time-zone.js +32 -0
  268. package/dist/server/tool-calls.d.ts +130 -0
  269. package/dist/server/tool-calls.js +341 -0
  270. package/dist/server/tool-llm.d.ts +72 -0
  271. package/dist/server/tool-llm.js +146 -0
  272. package/dist/server/tool-registry.d.ts +129 -0
  273. package/dist/server/tool-registry.js +249 -0
  274. package/dist/server/tool-runner.d.ts +112 -0
  275. package/dist/server/tool-runner.js +306 -0
  276. package/dist/server/turn-failure.d.ts +48 -0
  277. package/dist/server/turn-failure.js +148 -0
  278. package/dist/server/types.d.ts +2315 -0
  279. package/dist/server/types.js +11 -0
  280. package/dist/server/update-status.d.ts +14 -0
  281. package/dist/server/update-status.js +69 -0
  282. package/dist/server/update.d.ts +46 -0
  283. package/dist/server/update.js +104 -0
  284. package/dist/server/upload.d.ts +35 -0
  285. package/dist/server/upload.js +177 -0
  286. package/dist/server/version.d.ts +33 -0
  287. package/dist/server/version.js +111 -0
  288. package/dist/server/web.d.ts +27 -0
  289. package/dist/server/web.js +183 -0
  290. package/dist/server/workflow-engine.d.ts +47 -0
  291. package/dist/server/workflow-engine.js +255 -0
  292. package/dist/server/workflow.d.ts +329 -0
  293. package/dist/server/workflow.js +469 -0
  294. package/dist/server/workspace-file-indexes.d.ts +2 -0
  295. package/dist/server/workspace-file-indexes.js +61 -0
  296. package/dist/server/workspace-file-operations.d.ts +36 -0
  297. package/dist/server/workspace-file-operations.js +281 -0
  298. package/dist/server/workspace-file-response.d.ts +7 -0
  299. package/dist/server/workspace-file-response.js +79 -0
  300. package/dist/server/ws-server.d.ts +149 -0
  301. package/dist/server/ws-server.js +640 -0
  302. package/dist/shared/agent-order.d.ts +44 -0
  303. package/dist/shared/agent-order.js +50 -0
  304. package/dist/shared/archive-decisions.d.ts +44 -0
  305. package/dist/shared/archive-decisions.js +98 -0
  306. package/dist/shared/background-task.d.ts +25 -0
  307. package/dist/shared/background-task.js +183 -0
  308. package/dist/shared/child-session-lock.d.ts +37 -0
  309. package/dist/shared/child-session-lock.js +59 -0
  310. package/dist/shared/content-search.d.ts +22 -0
  311. package/dist/shared/content-search.js +1 -0
  312. package/dist/shared/conversation-title.d.ts +4 -0
  313. package/dist/shared/conversation-title.js +4 -0
  314. package/dist/shared/file-mentions.d.ts +17 -0
  315. package/dist/shared/file-mentions.js +91 -0
  316. package/dist/shared/git-commit.d.ts +11 -0
  317. package/dist/shared/git-commit.js +1 -0
  318. package/dist/shared/git-graph.d.ts +42 -0
  319. package/dist/shared/git-graph.js +30 -0
  320. package/dist/shared/group-chat.d.ts +132 -0
  321. package/dist/shared/group-chat.js +6 -0
  322. package/dist/shared/managed-servers.d.ts +36 -0
  323. package/dist/shared/managed-servers.js +1 -0
  324. package/dist/shared/message-media.d.ts +12 -0
  325. package/dist/shared/message-media.js +27 -0
  326. package/dist/shared/model-window-label.d.ts +39 -0
  327. package/dist/shared/model-window-label.js +55 -0
  328. package/dist/shared/native-tools.d.ts +43 -0
  329. package/dist/shared/native-tools.js +1 -0
  330. package/dist/shared/pi-cache-warming.d.ts +9 -0
  331. package/dist/shared/pi-cache-warming.js +4 -0
  332. package/dist/shared/project-overview.d.ts +107 -0
  333. package/dist/shared/project-overview.js +92 -0
  334. package/dist/shared/project-presentation.d.ts +55 -0
  335. package/dist/shared/project-presentation.js +111 -0
  336. package/dist/shared/provider-network.d.ts +30 -0
  337. package/dist/shared/provider-network.js +1 -0
  338. package/dist/shared/session-reporting.d.ts +40 -0
  339. package/dist/shared/session-reporting.js +97 -0
  340. package/dist/shared/session-search.d.ts +14 -0
  341. package/dist/shared/session-search.js +1 -0
  342. package/dist/shared/team-context-view.d.ts +33 -0
  343. package/dist/shared/team-context-view.js +49 -0
  344. package/dist/shared/team-context.d.ts +59 -0
  345. package/dist/shared/team-context.js +3 -0
  346. package/dist/shared/terminal-protocol.d.ts +71 -0
  347. package/dist/shared/terminal-protocol.js +1 -0
  348. package/dist/shared/thinking-levels.d.ts +53 -0
  349. package/dist/shared/thinking-levels.js +85 -0
  350. package/dist/shared/tool-glyph.d.ts +7 -0
  351. package/dist/shared/tool-glyph.js +19 -0
  352. package/dist/shared/transcript-order.d.ts +7 -0
  353. package/dist/shared/transcript-order.js +12 -0
  354. package/dist/shared/update-status.d.ts +28 -0
  355. package/dist/shared/update-status.js +1 -0
  356. package/dist/shared/workspace-file-preview.d.ts +4 -0
  357. package/dist/shared/workspace-file-preview.js +28 -0
  358. package/package.json +448 -4
  359. package/scripts/diagnose.mjs +603 -0
  360. package/scripts/patch-brace-expansion.mjs +260 -0
  361. package/scripts/restart-server.mjs +104 -0
  362. package/skills/presentation/SKILL.md +30 -0
  363. package/skills/presentation/references/data.md +10 -0
  364. package/skills/presentation/references/quality.md +12 -0
  365. package/skills/presentation/references/story.md +12 -0
  366. package/skills/presentation/references/templates-and-editing.md +11 -0
  367. package/skills/presentation/references/visual-system.md +10 -0
  368. package/skills/super-pi-agent-development/SKILL.md +25 -0
  369. package/skills/super-pi-development/SKILL.md +31 -0
  370. package/skills/super-pi-tool-development/SKILL.md +39 -0
@@ -0,0 +1,91 @@
1
+ /** Only a standalone @ token opens completion; email addresses and escaped @ stay literal. */
2
+ export function findMentionToken(text, caret, selectionEnd = caret) {
3
+ if (caret !== selectionEnd || caret < 0 || caret > text.length)
4
+ return undefined;
5
+ const match = /(?:^|[\s([{])@(?:"([^"\n]*)|([^\s@"\n]*))$/u.exec(text.slice(0, caret));
6
+ if (!match)
7
+ return undefined;
8
+ const start = match.index + match[0].indexOf("@");
9
+ const tail = text.slice(caret);
10
+ const remaining = match[1] !== undefined ? /^[^"\n]*(?:"|$)/u.exec(tail)?.[0] : /^[^\s@"\n]*/u.exec(tail)?.[0];
11
+ return { start, end: caret + (remaining?.length ?? 0), query: match[1] ?? match[2] ?? "" };
12
+ }
13
+ var MatchRank;
14
+ (function (MatchRank) {
15
+ MatchRank[MatchRank["ExactPath"] = 0] = "ExactPath";
16
+ MatchRank[MatchRank["FoldedPath"] = 1] = "FoldedPath";
17
+ MatchRank[MatchRank["ExactName"] = 2] = "ExactName";
18
+ MatchRank[MatchRank["NamePrefix"] = 3] = "NamePrefix";
19
+ MatchRank[MatchRank["NameSubstring"] = 4] = "NameSubstring";
20
+ MatchRank[MatchRank["NameSubsequence"] = 5] = "NameSubsequence";
21
+ MatchRank[MatchRank["PathSubstring"] = 6] = "PathSubstring";
22
+ MatchRank[MatchRank["PathSubsequence"] = 7] = "PathSubsequence";
23
+ })(MatchRank || (MatchRank = {}));
24
+ function subsequenceScore(text, query, rank) {
25
+ let start = -1;
26
+ let end = 0;
27
+ for (const character of query) {
28
+ const position = text.indexOf(character, end);
29
+ if (position < 0)
30
+ return;
31
+ if (start < 0)
32
+ start = position;
33
+ end = position + character.length;
34
+ }
35
+ // Count gaps within the match. Long directories should never improve a sparse match.
36
+ return [rank, end - start - query.length, start];
37
+ }
38
+ function fuzzyScore(path, query) {
39
+ if (path === query)
40
+ return [MatchRank.FoldedPath];
41
+ const name = path.slice(path.lastIndexOf("/") + 1);
42
+ if (name === query)
43
+ return [MatchRank.ExactName];
44
+ const nameStart = name.indexOf(query);
45
+ if (nameStart === 0)
46
+ return [MatchRank.NamePrefix, name.length];
47
+ if (nameStart > 0)
48
+ return [MatchRank.NameSubstring, nameStart, name.length];
49
+ const nameMatch = subsequenceScore(name, query, MatchRank.NameSubsequence);
50
+ if (nameMatch)
51
+ return nameMatch;
52
+ const pathStart = path.indexOf(query);
53
+ return pathStart >= 0 ? [MatchRank.PathSubstring, pathStart] : subsequenceScore(path, query, MatchRank.PathSubsequence);
54
+ }
55
+ function compareScores(a, b) {
56
+ return a[0] - b[0] || (a[1] ?? 0) - (b[1] ?? 0) || (a[2] ?? 0) - (b[2] ?? 0);
57
+ }
58
+ export function rankPathMatches(entries, query) {
59
+ const normalized = query.trim().replaceAll("\\", "/");
60
+ const needle = normalized.toLowerCase();
61
+ const matches = [];
62
+ for (const entry of entries) {
63
+ if (!entry.path || entry.path.startsWith("/") || /^[a-z]:/iu.test(entry.path) || entry.path.split("/").includes(".."))
64
+ continue;
65
+ const path = entry.path.toLowerCase();
66
+ const score = !needle || entry.path === normalized
67
+ ? [MatchRank.ExactPath] : fuzzyScore(path, needle);
68
+ if (score !== undefined)
69
+ matches.push({ entry, score, depth: entry.path.split("/").length });
70
+ }
71
+ matches.sort((a, b) => {
72
+ const order = compareScores(a.score, b.score);
73
+ if (order)
74
+ return order;
75
+ const directoriesFirst = Number(b.entry.kind === "directory") - Number(a.entry.kind === "directory");
76
+ // Keep files ahead of tied fuzzy directory suggestions in path mentions.
77
+ return (a.score[0] === MatchRank.PathSubsequence ? -directoriesFirst : 0)
78
+ || a.depth - b.depth || directoriesFirst
79
+ || (a.entry.path < b.entry.path ? -1 : a.entry.path > b.entry.path ? 1 : 0);
80
+ });
81
+ return matches.map(item => item.entry);
82
+ }
83
+ export function matchPathMentions(entries, query, limit = 30) {
84
+ return rankPathMatches(entries, query).slice(0, Math.max(0, Math.min(100, limit)));
85
+ }
86
+ export function insertPathMention(text, token, entry) {
87
+ const path = entry.path + (entry.kind === "directory" && !entry.path.endsWith("/") ? "/" : "");
88
+ const reference = "@" + (/^[^\s@"\\]+$/u.test(path) ? path : JSON.stringify(path));
89
+ const insertion = reference + " ";
90
+ return { text: text.slice(0, token.start) + insertion + text.slice(token.end), caret: token.start + insertion.length };
91
+ }
@@ -0,0 +1,11 @@
1
+ export type GitCommitFile = {
2
+ path: string;
3
+ previousPath?: string;
4
+ status: string;
5
+ };
6
+ export type GitCommitDetail = {
7
+ hash: string;
8
+ parents: string[];
9
+ message: string;
10
+ files: GitCommitFile[];
11
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,42 @@
1
+ export type GitGraphRef = {
2
+ kind: "head" | "worktree" | "branch" | "remote" | "tag" | "stash";
3
+ name: string;
4
+ checkoutId?: string;
5
+ };
6
+ export type GitGraphCommit = {
7
+ hash: string;
8
+ short: string;
9
+ parents: string[];
10
+ subject: string;
11
+ author: string;
12
+ date: string;
13
+ refs: GitGraphRef[];
14
+ };
15
+ export type GitGraphResponse = GitGraphPage | {
16
+ unchanged: true;
17
+ snapshot: string;
18
+ };
19
+ export type GitGraphPage = {
20
+ commits: GitGraphCommit[];
21
+ snapshot: string;
22
+ hasMore: boolean;
23
+ };
24
+ type Lane = {
25
+ index: number;
26
+ color: number;
27
+ };
28
+ type ParentLine = {
29
+ hash: string;
30
+ lane: Lane;
31
+ };
32
+ export type GitGraphRow = {
33
+ node: Lane;
34
+ incoming: boolean;
35
+ through: Lane[];
36
+ parents: ParentLine[];
37
+ };
38
+ export declare function layoutGitGraph(commits: readonly Pick<GitGraphCommit, "hash" | "parents">[]): {
39
+ columns: number;
40
+ rows: GitGraphRow[];
41
+ };
42
+ export {};
@@ -0,0 +1,30 @@
1
+ export function layoutGitGraph(commits) {
2
+ const pending = new Map();
3
+ const occupied = [];
4
+ let nextColor = 0;
5
+ let columns = 1;
6
+ const reserve = (color, preferred) => {
7
+ const free = preferred ?? occupied.indexOf(false);
8
+ const index = free < 0 ? occupied.length : free;
9
+ occupied[index] = true;
10
+ columns = Math.max(columns, index + 1);
11
+ return { index, color };
12
+ };
13
+ const rows = commits.map(({ hash, parents }) => {
14
+ const previous = pending.get(hash);
15
+ const node = previous ?? reserve(nextColor++);
16
+ pending.delete(hash);
17
+ occupied[node.index] = false;
18
+ const through = [...pending.values()];
19
+ const edges = [...new Set(parents)].map((parent, order) => {
20
+ let lane = pending.get(parent);
21
+ if (!lane) {
22
+ lane = order === 0 ? reserve(node.color, node.index) : reserve(nextColor++);
23
+ pending.set(parent, lane);
24
+ }
25
+ return { hash: parent, lane };
26
+ });
27
+ return { node, incoming: previous !== undefined, through, parents: edges };
28
+ });
29
+ return { columns, rows };
30
+ }
@@ -0,0 +1,132 @@
1
+ import { type SessionDisplayState } from "./session-reporting.js";
2
+ export type GroupModel = {
3
+ provider: string;
4
+ modelId: string;
5
+ label: string;
6
+ };
7
+ export type GroupModerator = {
8
+ model?: GroupModel;
9
+ prompt: string;
10
+ cloneLimit?: number;
11
+ };
12
+ export declare const DEFAULT_GROUP_MEMBER_IDS: readonly ["solution-designer", "code-designer", "code-auditor", "document-organizer"];
13
+ export type GroupMember = {
14
+ id: string;
15
+ name: string;
16
+ description: string;
17
+ agentId?: string;
18
+ worktreePath?: string;
19
+ };
20
+ export type GroupCloneRequest = {
21
+ id: string;
22
+ topicId: string;
23
+ memberId: string;
24
+ assignment: string;
25
+ reason: string;
26
+ createdAt: string;
27
+ status: "pending" | "created" | "waiting" | "expired";
28
+ cloneId?: string;
29
+ automatic?: boolean;
30
+ };
31
+ export type GroupStatus = "queued" | "running" | "completed" | "failed" | "cancelled" | "interrupted";
32
+ export type GroupExecutionActivity = {
33
+ kind: "thinking";
34
+ } | {
35
+ kind: "tool";
36
+ name: string;
37
+ detail?: string;
38
+ };
39
+ type GroupExecutionStepBase = {
40
+ id: string;
41
+ startedAt: string;
42
+ status: "running" | "completed" | "failed" | "interrupted";
43
+ };
44
+ export type GroupExecutionStep = GroupExecutionStepBase & ({
45
+ kind: "thinking";
46
+ text: string;
47
+ } | {
48
+ kind: "tool";
49
+ name: string;
50
+ detail?: string;
51
+ lastUpdateAt?: string;
52
+ durationMs?: number;
53
+ });
54
+ export type GroupExecutionTrace = {
55
+ steps: GroupExecutionStep[];
56
+ truncated?: true;
57
+ };
58
+ export type GroupExecutionSnapshot = GroupExecutionTrace & {
59
+ status: GroupStatus;
60
+ revision: string;
61
+ };
62
+ type GroupPost = {
63
+ id: string;
64
+ content: string;
65
+ createdAt: string;
66
+ status: GroupStatus;
67
+ error?: string;
68
+ };
69
+ export type GroupFileReference = {
70
+ path: string;
71
+ excerpt: string;
72
+ };
73
+ export type GroupUserPost = GroupPost & {
74
+ role: "user";
75
+ memberIds: string[];
76
+ replyTo?: string;
77
+ clientId: string;
78
+ files?: GroupFileReference[];
79
+ memoryNotice?: string;
80
+ };
81
+ export type GroupReply = GroupPost & {
82
+ role: "assistant";
83
+ memberId: string;
84
+ memberName?: string;
85
+ topicId: string;
86
+ replyTo: string;
87
+ assignment?: string;
88
+ routeReason?: string;
89
+ background?: boolean;
90
+ settledAt?: string;
91
+ executionActivity?: GroupExecutionActivity;
92
+ handoff?: {
93
+ memberId: string;
94
+ assignment: string;
95
+ };
96
+ };
97
+ export type GroupMessage = GroupUserPost | GroupReply;
98
+ export type GroupActivity = {
99
+ status: "idle" | "running" | "awaiting_background" | "completed" | "failed";
100
+ revision: number;
101
+ lastReplyAt?: string;
102
+ };
103
+ export declare function groupDisplayState(activity: GroupActivity, readAt?: string): SessionDisplayState;
104
+ export type GroupActivityUpdate = {
105
+ id: string;
106
+ workspaceId: string;
107
+ activity: GroupActivity;
108
+ cloneRequests?: GroupCloneRequest[];
109
+ };
110
+ type GroupIdentity = {
111
+ id: string;
112
+ workspaceId: string;
113
+ title: string;
114
+ updatedAt: string;
115
+ archivedAt?: string;
116
+ };
117
+ export type GroupSummary = GroupIdentity & {
118
+ activity: GroupActivity;
119
+ cloneRequests?: GroupCloneRequest[];
120
+ };
121
+ export type GroupRoom = GroupIdentity & {
122
+ members: GroupMember[];
123
+ moderator: GroupModerator;
124
+ revision: number;
125
+ messages: GroupMessage[];
126
+ cloneRequests?: GroupCloneRequest[];
127
+ };
128
+ export type GroupSnapshot = Omit<GroupRoom, "revision"> & {
129
+ revision: string;
130
+ activity: GroupActivity;
131
+ };
132
+ export {};
@@ -0,0 +1,6 @@
1
+ import { deriveSessionState } from "./session-reporting.js";
2
+ export const DEFAULT_GROUP_MEMBER_IDS = ["solution-designer", "code-designer", "code-auditor", "document-organizer"];
3
+ export function groupDisplayState(activity, readAt) {
4
+ return deriveSessionState({ status: activity.status, quietWhenRead: true,
5
+ reportingState: activity.lastReplyAt && activity.lastReplyAt > (readAt ?? "") ? "unread" : null });
6
+ }
@@ -0,0 +1,36 @@
1
+ export interface ManagedServerProfile {
2
+ id: string;
3
+ name: string;
4
+ host: string;
5
+ sshPort: number;
6
+ username: string;
7
+ servicePort: number;
8
+ authentication: "agent" | "password" | "privateKey";
9
+ identityFile?: string;
10
+ fingerprint?: string;
11
+ observedFingerprint?: string;
12
+ enabled: boolean;
13
+ identity?: string;
14
+ deployedAt?: string;
15
+ remoteRoot?: string;
16
+ ssh: "offline" | "connecting" | "online" | "needsTrust";
17
+ service: "unknown" | "offline" | "online";
18
+ modelChannel: "offline" | "online";
19
+ phase: "idle" | "connecting" | "needsTrust" | "deploying" | "ready" | "failed";
20
+ step?: string;
21
+ error?: string;
22
+ log?: string[];
23
+ }
24
+ export interface ManagedServerInput {
25
+ id?: string;
26
+ name: string;
27
+ host: string;
28
+ sshPort: number;
29
+ username: string;
30
+ servicePort: number;
31
+ authentication: ManagedServerProfile["authentication"];
32
+ identityFile?: string;
33
+ password?: string;
34
+ privateKey?: string;
35
+ passphrase?: string;
36
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ /** Only workspace-backed artifacts are embedded automatically; remote images remain links. */
2
+ export type MessageMediaKind = "image" | "html";
3
+ export declare const MESSAGE_HTML_CSP = "default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval'; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; connect-src 'none'; frame-src 'none'; object-src 'none'; form-action 'none'; base-uri 'none'";
4
+ /** The trusted outer document also prevents the untrusted child from navigating to another origin. */
5
+ export declare const MESSAGE_FRAME_CSP: string;
6
+ export declare const MAX_MESSAGE_MEDIA_BYTES: number;
7
+ export declare function messageMediaType(path: string): {
8
+ kind: MessageMediaKind;
9
+ mime: string;
10
+ } | undefined;
11
+ export declare function localMessageMedia(path: string): MessageMediaKind | undefined;
12
+ export declare function messageMediaUrl(workspaceId: string, conversationId: string, path: string): string;
@@ -0,0 +1,27 @@
1
+ export const MESSAGE_HTML_CSP = "default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval'; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; connect-src 'none'; frame-src 'none'; object-src 'none'; form-action 'none'; base-uri 'none'";
2
+ /** The trusted outer document also prevents the untrusted child from navigating to another origin. */
3
+ export const MESSAGE_FRAME_CSP = MESSAGE_HTML_CSP.replace("frame-src 'none'", "frame-src 'self'");
4
+ export const MAX_MESSAGE_MEDIA_BYTES = 20 * 1024 * 1024;
5
+ const TYPES = {
6
+ png: { kind: "image", mime: "image/png" },
7
+ jpg: { kind: "image", mime: "image/jpeg" },
8
+ jpeg: { kind: "image", mime: "image/jpeg" },
9
+ gif: { kind: "image", mime: "image/gif" },
10
+ webp: { kind: "image", mime: "image/webp" },
11
+ svg: { kind: "image", mime: "image/svg+xml" },
12
+ html: { kind: "html", mime: "text/html; charset=utf-8" },
13
+ htm: { kind: "html", mime: "text/html; charset=utf-8" },
14
+ };
15
+ export function messageMediaType(path) {
16
+ return TYPES[/\.([a-z]+)$/i.exec(path)?.[1].toLowerCase() ?? ""];
17
+ }
18
+ export function localMessageMedia(path) {
19
+ if (!path || /[\u0000-\u001f\u007f]/.test(path) || /^[\\/]{2}/.test(path))
20
+ return;
21
+ if (/^[a-z][a-z\d+.-]*:/i.test(path) && !/^[a-z]:[\\/]/i.test(path))
22
+ return;
23
+ return messageMediaType(path)?.kind;
24
+ }
25
+ export function messageMediaUrl(workspaceId, conversationId, path) {
26
+ return `/api/message-artifact?${new URLSearchParams({ workspaceId, conversationId, path })}`;
27
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * How big a model's context window is, in the words a reader uses: 「1M」, 「205K」, 「128K」.
3
+ *
4
+ * WHY THIS IS A SEPARATE FILE. The window of a model is the one number that decides whether a long
5
+ * task can finish at all, and it is the one number a reader cannot see. A model that really has a
6
+ * million tokens and one that really has a hundred and twenty-eight thousand are the same line of
7
+ * text in a picker, so the reader picks the second one and then watches a two-hundred-thousand-token
8
+ * session report 156%. The number was already in the data - `ModelOption.contextWindow` carries the
9
+ * value the session will actually be measured against - so all this does is put it in front of the
10
+ * reader where they choose the model.
11
+ *
12
+ * WHY THE ROUNDING IS DECIMAL. People say 「128k」 and 「1M」, and the sizes that show up here are
13
+ * written that way: 128000, 512000, 1000000. 204800 is the awkward one - it is 200 of the binary
14
+ * unit and 204.8 of the decimal one - and it is printed as 「205K」, because a label that is off by
15
+ * one percent is a label that is honest. A picker is not where rounding gets to be pretty.
16
+ */
17
+ /**
18
+ * The window size as a reader-facing label, or the empty string when there is no window to show.
19
+ *
20
+ * The empty string is a real case, not a defensive one: a model the provider never published a
21
+ * window for has no window to print, and printing 「0 上下文」 would be a fact the reader would
22
+ * believe.
23
+ */
24
+ export declare function formatModelWindow(window: number): string;
25
+ /**
26
+ * How long a SINGLE answer may be, in the same words as the window: 「512K」, 「16K」, 「1M」.
27
+ *
28
+ * WHY THIS IS A SECOND NUMBER. The window is how much conversation fits; the output limit is how much
29
+ * one answer may be. They are different facts about the same model, and they fail differently: a
30
+ * window that is too small compacts the conversation, while an output limit that is too small TRUNCATES
31
+ * THE ANSWER - the long report comes back cut off at the limit, and the turn is wasted. So a model
32
+ * whose output limit was stamped with Super Pi's own 16,384 placeholder can never produce the long
33
+ * report it was asked for.
34
+ *
35
+ * THE ROUNDING IS THE SAME RULE, ON PURPOSE. A reader who has learned 「128K」 for a window has
36
+ * learned one scale, and a second scale for the other number on the same line would be a puzzle
37
+ * rather than a fact.
38
+ */
39
+ export declare function formatModelOutput(maxTokens: number): string;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * How big a model's context window is, in the words a reader uses: 「1M」, 「205K」, 「128K」.
3
+ *
4
+ * WHY THIS IS A SEPARATE FILE. The window of a model is the one number that decides whether a long
5
+ * task can finish at all, and it is the one number a reader cannot see. A model that really has a
6
+ * million tokens and one that really has a hundred and twenty-eight thousand are the same line of
7
+ * text in a picker, so the reader picks the second one and then watches a two-hundred-thousand-token
8
+ * session report 156%. The number was already in the data - `ModelOption.contextWindow` carries the
9
+ * value the session will actually be measured against - so all this does is put it in front of the
10
+ * reader where they choose the model.
11
+ *
12
+ * WHY THE ROUNDING IS DECIMAL. People say 「128k」 and 「1M」, and the sizes that show up here are
13
+ * written that way: 128000, 512000, 1000000. 204800 is the awkward one - it is 200 of the binary
14
+ * unit and 204.8 of the decimal one - and it is printed as 「205K」, because a label that is off by
15
+ * one percent is a label that is honest. A picker is not where rounding gets to be pretty.
16
+ */
17
+ /**
18
+ * The window size as a reader-facing label, or the empty string when there is no window to show.
19
+ *
20
+ * The empty string is a real case, not a defensive one: a model the provider never published a
21
+ * window for has no window to print, and printing 「0 上下文」 would be a fact the reader would
22
+ * believe.
23
+ */
24
+ export function formatModelWindow(window) {
25
+ if (!Number.isFinite(window) || window <= 0)
26
+ return "";
27
+ if (window >= 1_000_000)
28
+ return `${Math.round(window / 1_000_000)}M`;
29
+ if (window >= 1000)
30
+ return `${Math.round(window / 1000)}K`;
31
+ return String(window);
32
+ }
33
+ /**
34
+ * How long a SINGLE answer may be, in the same words as the window: 「512K」, 「16K」, 「1M」.
35
+ *
36
+ * WHY THIS IS A SECOND NUMBER. The window is how much conversation fits; the output limit is how much
37
+ * one answer may be. They are different facts about the same model, and they fail differently: a
38
+ * window that is too small compacts the conversation, while an output limit that is too small TRUNCATES
39
+ * THE ANSWER - the long report comes back cut off at the limit, and the turn is wasted. So a model
40
+ * whose output limit was stamped with Super Pi's own 16,384 placeholder can never produce the long
41
+ * report it was asked for.
42
+ *
43
+ * THE ROUNDING IS THE SAME RULE, ON PURPOSE. A reader who has learned 「128K」 for a window has
44
+ * learned one scale, and a second scale for the other number on the same line would be a puzzle
45
+ * rather than a fact.
46
+ */
47
+ export function formatModelOutput(maxTokens) {
48
+ if (!Number.isFinite(maxTokens) || maxTokens <= 0)
49
+ return "";
50
+ if (maxTokens >= 1_000_000)
51
+ return `${Math.round(maxTokens / 1_000_000)}M`;
52
+ if (maxTokens >= 1000)
53
+ return `${Math.round(maxTokens / 1000)}K`;
54
+ return String(maxTokens);
55
+ }
@@ -0,0 +1,43 @@
1
+ export type NativeToolSettings = {
2
+ mcp: boolean;
3
+ toolSearch: boolean;
4
+ codemode: boolean;
5
+ };
6
+ export declare const DEFAULT_NATIVE_TOOLS: NativeToolSettings;
7
+ export type McpExposure = "deferred" | "direct" | "codemode" | "hidden";
8
+ export type PublicMcpServer = {
9
+ name: string;
10
+ transport: "stdio" | "http";
11
+ enabled: boolean;
12
+ exposure: McpExposure;
13
+ description?: string;
14
+ hasCredentials: boolean;
15
+ authenticated: boolean;
16
+ supportsLogin: boolean;
17
+ };
18
+ export type McpDiagnostic = {
19
+ name: string;
20
+ scope: string;
21
+ state: string;
22
+ tools: string[];
23
+ error?: string;
24
+ };
25
+ export type McpLogin = {
26
+ id: string;
27
+ name: string;
28
+ state: "starting" | "authorizing" | "completed" | "failed" | "cancelled";
29
+ url?: string;
30
+ error?: string;
31
+ };
32
+ export type NativeToolsSnapshot = {
33
+ settings: NativeToolSettings;
34
+ servers: PublicMcpServer[];
35
+ logins: McpLogin[];
36
+ configurationWarning?: string;
37
+ diagnostics?: {
38
+ running: boolean;
39
+ total: number;
40
+ servers: McpDiagnostic[];
41
+ error?: string;
42
+ };
43
+ };
@@ -0,0 +1 @@
1
+ export const DEFAULT_NATIVE_TOOLS = { mcp: true, toolSearch: true, codemode: true };
@@ -0,0 +1,9 @@
1
+ export declare const PI_CACHE_WARMING_MODES: readonly ["off", "streaming", "idle"];
2
+ export type PiCacheWarmingMode = typeof PI_CACHE_WARMING_MODES[number];
3
+ export interface PiCacheWarmingSettings {
4
+ mode: PiCacheWarmingMode;
5
+ liveSessions: number;
6
+ scheduled: number;
7
+ refreshing: number;
8
+ }
9
+ export declare function isPiCacheWarmingMode(value: unknown): value is PiCacheWarmingMode;
@@ -0,0 +1,4 @@
1
+ export const PI_CACHE_WARMING_MODES = ["off", "streaming", "idle"];
2
+ export function isPiCacheWarmingMode(value) {
3
+ return PI_CACHE_WARMING_MODES.includes(value);
4
+ }
@@ -0,0 +1,107 @@
1
+ export type OverviewReport = {
2
+ id: string;
3
+ kind?: string;
4
+ taskId?: string;
5
+ authorConversationId?: string;
6
+ progress?: string;
7
+ summary?: string;
8
+ evidenceRefs?: string[];
9
+ acceptedTaskIds?: string[];
10
+ createdAt?: string;
11
+ };
12
+ export type OverviewDecision = {
13
+ id: string;
14
+ status?: "open" | "resolved" | "dismissed" | "returned";
15
+ audience?: "boss" | "supervisor";
16
+ title?: string;
17
+ reason?: string;
18
+ severity?: string;
19
+ requestedByConversationId?: string;
20
+ createdAt?: string;
21
+ /** What the case was answered with - the reader's own words, or the words the archive wrote on
22
+ * their behalf. Either way the record keeps it, because a decision nobody can read is a
23
+ * decision that never happened. */
24
+ decision?: string;
25
+ resolvedAt?: string;
26
+ };
27
+ export type OverviewProject = {
28
+ id: string;
29
+ title: string;
30
+ objective?: string;
31
+ status: string;
32
+ mode?: string;
33
+ summary?: string;
34
+ ownerConversationId?: string;
35
+ reports?: OverviewReport[];
36
+ escalations?: OverviewDecision[];
37
+ resources?: {
38
+ activeWorkers?: number;
39
+ sessions?: {
40
+ id: string;
41
+ status?: string;
42
+ }[];
43
+ };
44
+ };
45
+ /**
46
+ * IS THIS CASE STILL A DECISION THE READER OWES?
47
+ *
48
+ * One predicate, used everywhere: the case is still OPEN, and it is addressed to the BOSS (or it
49
+ * carries no audience at all - that was the default audience back then). A supervisor-level case
50
+ * is the team's business: the reader was never asked, so it is not theirs to answer.
51
+ */
52
+ export declare function isOpenUserDecision(item: OverviewDecision): boolean;
53
+ /** Internal coordination is not a request for the user's attention. */
54
+ export declare function userProjectDecisions(project: OverviewProject): OverviewDecision[];
55
+ /**
56
+ * HOW MANY PROJECTS NEED THE USER - counted by project, not by case.
57
+ *
58
+ * The notice above the project tab says "N projects need you to decide". One project with two
59
+ * open boss-level cases is still ONE project to decide about, and a notice that says "2 projects"
60
+ * above a list that shows one is simply wrong. The count therefore goes over the PROJECTS that
61
+ * have at least one such case, and the cases themselves are counted separately.
62
+ */
63
+ export declare function projectsNeedingUserDecision(projects: OverviewProject[]): {
64
+ projects: number;
65
+ cases: number;
66
+ };
67
+ /**
68
+ * IS THIS PROJECT STILL THE READER'S BUSINESS?
69
+ *
70
+ * Two ways a project stops being the reader's business: it ENDED (cancelled or failed), or its
71
+ * OWNER SESSION WAS ARCHIVED - and a project whose owner sits in the archive has nobody left to
72
+ * run it. The second case is not a status: the record still says 「进行中」, but the session that
73
+ * was supposed to drive it is gone, so the panel cannot even offer 「让负责人继续」. A project
74
+ * like that is history with its records intact, not work in progress.
75
+ *
76
+ * A project that has NO owner yet is NOT over: it simply has not started, and the reader is the
77
+ * one who can start it. Only an owner that EXISTS and is archived makes a project unmanaged.
78
+ */
79
+ export declare function projectIsOver(project: {
80
+ status?: string;
81
+ }, ownerArchived?: boolean): boolean;
82
+ /**
83
+ * WHICH VIEW A PROJECT BELONGS TO - the server decides, the client re-applies the same rule.
84
+ *
85
+ * The split is not 「ended / not ended」 - it is 「still owed something / nothing left to say」.
86
+ * A project that still owes the reader a decision stays in the current list, because hiding it
87
+ * would leave that decision with nobody. Everything else that is over goes to history.
88
+ */
89
+ export declare function projectInView(project: OverviewProject, ownerArchived: boolean, view: "current" | "history"): boolean;
90
+ export declare function ownerProjectReports(project: OverviewProject): OverviewReport[];
91
+ export declare function latestProjectDelivery<T extends OverviewReport>(project: {
92
+ ownerConversationId?: string;
93
+ reports?: T[];
94
+ }): T | undefined;
95
+ export declare function deliveryCoversTasks(delivery: OverviewReport | undefined, tasks: {
96
+ id: string;
97
+ updatedAt?: string;
98
+ }[]): boolean;
99
+ export declare function projectUserOverview(project: OverviewProject): {
100
+ label: string;
101
+ summary: string;
102
+ progress: OverviewReport | undefined;
103
+ delivery: OverviewReport | undefined;
104
+ decisions: OverviewDecision[];
105
+ ended: boolean;
106
+ deliveryLabel: string;
107
+ };