@temmo/cli 0.0.0 → 0.19.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 (445) hide show
  1. package/.claude-plugin/marketplace.json +14 -0
  2. package/.claude-plugin/plugin.json +16 -0
  3. package/.codex-plugin/plugin.json +30 -0
  4. package/.cursor-plugin/plugin.json +22 -0
  5. package/.mcp.json +18 -0
  6. package/LICENSE +202 -0
  7. package/README.md +82 -2
  8. package/THIRD_PARTY_NOTICES +32 -0
  9. package/commands/afk.md +17 -0
  10. package/deploy/build-ui.mjs +65 -0
  11. package/deploy/claude/README.md +16 -0
  12. package/deploy/claude/auto-mode.json +31 -0
  13. package/deploy/postgres/compose.yaml +26 -0
  14. package/deploy/temmo-runner.service +24 -0
  15. package/deploy/verify-ui.mjs +15 -0
  16. package/harness-core/README.md +27 -0
  17. package/harness-core/bin/harness.mjs +17 -0
  18. package/harness-core/package.json +10 -0
  19. package/harness-core/stage.mjs +108 -0
  20. package/harness-core/stages/commit.md +7 -0
  21. package/harness-core/stages/pr.md +7 -0
  22. package/harness-core/stages/push.md +7 -0
  23. package/hooks/codex-hooks.json +14 -0
  24. package/hooks/cursor-hooks.json +17 -0
  25. package/hooks/hooks.json +27 -0
  26. package/lib/acp/permission.js +72 -0
  27. package/lib/acp/sessionConfig.js +109 -0
  28. package/lib/activity.js +244 -0
  29. package/lib/agent-guard.js +72 -0
  30. package/lib/agents-route.js +55 -0
  31. package/lib/agents.js +213 -0
  32. package/lib/agui.js +255 -0
  33. package/lib/alerts.js +36 -0
  34. package/lib/analyze-otlp.js +46 -0
  35. package/lib/analyze-run-code.js +397 -0
  36. package/lib/analyze-sources.js +372 -0
  37. package/lib/approval-card.js +54 -0
  38. package/lib/approval-cli.js +53 -0
  39. package/lib/approval-request.js +81 -0
  40. package/lib/approval-signer.js +48 -0
  41. package/lib/approvals.js +295 -0
  42. package/lib/attachment-cache.js +236 -0
  43. package/lib/attachment.js +63 -0
  44. package/lib/blocked.js +20 -0
  45. package/lib/build-review.js +90 -0
  46. package/lib/builder/cli.js +90 -0
  47. package/lib/builder/policy.js +176 -0
  48. package/lib/builder/recover.js +189 -0
  49. package/lib/builder/run.js +240 -0
  50. package/lib/builder/settle.js +198 -0
  51. package/lib/builder/stage.js +240 -0
  52. package/lib/builder/state.js +73 -0
  53. package/lib/builder/supervisor.js +289 -0
  54. package/lib/builder-clean.js +223 -0
  55. package/lib/builder-code.cjs +67 -0
  56. package/lib/builder.js +9 -0
  57. package/lib/bus-postgres.js +281 -0
  58. package/lib/bus.js +349 -0
  59. package/lib/catalog/author.js +278 -0
  60. package/lib/catalog/dot.js +426 -0
  61. package/lib/catalog/pattern-model.js +193 -0
  62. package/lib/catalog/patterns.js +324 -0
  63. package/lib/catalog/projects.js +83 -0
  64. package/lib/catalog/records.js +2 -0
  65. package/lib/catalog/roster.js +70 -0
  66. package/lib/catalog/team-files.js +49 -0
  67. package/lib/catalog/teams.js +109 -0
  68. package/lib/claude-socket.js +333 -0
  69. package/lib/cli.js +741 -0
  70. package/lib/code-mode.js +45 -0
  71. package/lib/code-read-policy.yaml +9 -0
  72. package/lib/code-run.js +461 -0
  73. package/lib/codex-compact.js +141 -0
  74. package/lib/compaction.js +21 -0
  75. package/lib/config.js +424 -0
  76. package/lib/cursor-trace.js +248 -0
  77. package/lib/deep-link.js +20 -0
  78. package/lib/deliver-push.js +120 -0
  79. package/lib/delivery.js +28 -0
  80. package/lib/deploy-tree.js +227 -0
  81. package/lib/durable.js +404 -0
  82. package/lib/factory-tick.js +32 -0
  83. package/lib/family.js +63 -0
  84. package/lib/fetch-origin.js +53 -0
  85. package/lib/format.js +133 -0
  86. package/lib/harness-surface-cli.js +153 -0
  87. package/lib/harness-surface.js +486 -0
  88. package/lib/harness.js +271 -0
  89. package/lib/hook.mjs +291 -0
  90. package/lib/idle.js +40 -0
  91. package/lib/install-cursor.js +115 -0
  92. package/lib/install-opencode.js +105 -0
  93. package/lib/job.js +82 -0
  94. package/lib/land-cli.js +319 -0
  95. package/lib/land-member.js +64 -0
  96. package/lib/land.js +320 -0
  97. package/lib/lessons.js +223 -0
  98. package/lib/limit-alert.js +423 -0
  99. package/lib/limits.js +284 -0
  100. package/lib/machine-prompt.js +19 -0
  101. package/lib/merge-sweep.js +149 -0
  102. package/lib/messaging.js +1002 -0
  103. package/lib/mission-cli.js +103 -0
  104. package/lib/mission.js +241 -0
  105. package/lib/mode.js +215 -0
  106. package/lib/models.js +114 -0
  107. package/lib/names.js +86 -0
  108. package/lib/opencode-api.js +57 -0
  109. package/lib/opencode-plugin.mjs +313 -0
  110. package/lib/operator-token.js +78 -0
  111. package/lib/operator.js +187 -0
  112. package/lib/pad-activity.js +143 -0
  113. package/lib/pad-fresh.js +44 -0
  114. package/lib/pad.js +198 -0
  115. package/lib/pattern-cli.js +120 -0
  116. package/lib/pattern-compiler.js +68 -0
  117. package/lib/pattern-runs.js +795 -0
  118. package/lib/pattern-stall.js +58 -0
  119. package/lib/pattern-tick.js +45 -0
  120. package/lib/pattern-workflow.js +69 -0
  121. package/lib/pi-extension.mjs +98 -0
  122. package/lib/pi.js +57 -0
  123. package/lib/plugin-copy.js +76 -0
  124. package/lib/pm-review.js +32 -0
  125. package/lib/pm-workspace.js +87 -0
  126. package/lib/postgres.js +115 -0
  127. package/lib/pr-card.js +34 -0
  128. package/lib/probe.js +295 -0
  129. package/lib/process.js +67 -0
  130. package/lib/project-pause.js +23 -0
  131. package/lib/prune.js +793 -0
  132. package/lib/questions.js +250 -0
  133. package/lib/receipts.js +63 -0
  134. package/lib/reflect.js +962 -0
  135. package/lib/rename-migration.js +118 -0
  136. package/lib/run-terminal.js +437 -0
  137. package/lib/runner-request.js +33 -0
  138. package/lib/sandbox-app.js +120 -0
  139. package/lib/sandbox-claims.js +258 -0
  140. package/lib/sandbox-cli.js +188 -0
  141. package/lib/sandbox-hosts-cli.js +68 -0
  142. package/lib/sandbox-hosts.js +94 -0
  143. package/lib/sandbox-pr.js +102 -0
  144. package/lib/sandbox-proposal.js +367 -0
  145. package/lib/sandbox-tools.js +143 -0
  146. package/lib/sandbox.js +501 -0
  147. package/lib/schedule-session.js +68 -0
  148. package/lib/session-activity.js +67 -0
  149. package/lib/session-events.js +94 -0
  150. package/lib/sessions/control.js +244 -0
  151. package/lib/sessions/git-refs.js +265 -0
  152. package/lib/sessions/launch.js +359 -0
  153. package/lib/sessions/registry.js +450 -0
  154. package/lib/sessions/scope.js +111 -0
  155. package/lib/setup.js +377 -0
  156. package/lib/signed-approval.js +225 -0
  157. package/lib/slash.js +167 -0
  158. package/lib/spawn-cli.js +45 -0
  159. package/lib/spawn.js +107 -0
  160. package/lib/start-limit.js +58 -0
  161. package/lib/state.js +24 -0
  162. package/lib/stop.js +308 -0
  163. package/lib/store-read.js +62 -0
  164. package/lib/store.js +252 -0
  165. package/lib/subagent-guard.js +240 -0
  166. package/lib/surfaces/channel-post.js +43 -0
  167. package/lib/surfaces/instructions.js +15 -0
  168. package/lib/surfaces/mcp-reload.js +144 -0
  169. package/lib/surfaces/ops.js +629 -0
  170. package/lib/surfaces/render-mcp.js +33 -0
  171. package/lib/surfaces/run-terminal-ops.js +40 -0
  172. package/lib/surfaces/sandbox-ops.js +36 -0
  173. package/lib/surfaces/schema.js +7 -0
  174. package/lib/surfaces/task-view.js +90 -0
  175. package/lib/surfaces/types.js +4 -0
  176. package/lib/task-cli.js +274 -0
  177. package/lib/task-order.js +34 -0
  178. package/lib/task-order.mjs +2 -0
  179. package/lib/task-route.js +125 -0
  180. package/lib/tasks.js +631 -0
  181. package/lib/team-permission.js +34 -0
  182. package/lib/team-templates/blitz/team.dot +9 -0
  183. package/lib/team-templates/factory/team.dot +26 -0
  184. package/lib/team-templates/feature/team.dot +14 -0
  185. package/lib/team-templates/fix-and-review/team.dot +12 -0
  186. package/lib/team-templates/product/team.dot +16 -0
  187. package/lib/team-templates/release/team.dot +7 -0
  188. package/lib/team-templates/review/team.dot +6 -0
  189. package/lib/terminal-draft.js +42 -0
  190. package/lib/thread-branch.js +82 -0
  191. package/lib/thread-channel-store.js +181 -0
  192. package/lib/thread-channels.js +116 -0
  193. package/lib/thread-listening.js +20 -0
  194. package/lib/thread-routes.js +91 -0
  195. package/lib/threads.js +441 -0
  196. package/lib/tool-api.js +33 -0
  197. package/lib/transcript.js +98 -0
  198. package/lib/ui-build-output.js +19 -0
  199. package/lib/ui-capabilities.js +90 -0
  200. package/lib/usage.js +182 -0
  201. package/lib/vendor/mcp-sdk.d.mts +4 -0
  202. package/lib/vendor/mcp-sdk.mjs +17046 -0
  203. package/lib/waiter.js +127 -0
  204. package/lib/workflows.js +546 -0
  205. package/lib/worktree-setup.js +86 -0
  206. package/package.json +112 -1
  207. package/runner/adapters/claude.js +465 -0
  208. package/runner/adapters/cli-sandbox.js +277 -0
  209. package/runner/adapters/codex.js +675 -0
  210. package/runner/adapters/cursor.mjs +937 -0
  211. package/runner/adapters/fake.js +119 -0
  212. package/runner/adapters/opencode-sandbox.js +370 -0
  213. package/runner/adapters/opencode.js +486 -0
  214. package/runner/adapters/pi-sandbox.js +134 -0
  215. package/runner/adapters/pi.js +364 -0
  216. package/runner/client.js +40 -0
  217. package/runner/contract.js +129 -0
  218. package/runner/control.js +178 -0
  219. package/runner/delivery.js +184 -0
  220. package/runner/factory-tick.mjs +10 -0
  221. package/runner/lock.js +41 -0
  222. package/runner/main.mjs +118 -0
  223. package/runner/pattern-tick.mjs +16 -0
  224. package/runner/publish.js +113 -0
  225. package/runner/runner.js +2612 -0
  226. package/runner/sandbox-run.mjs +239 -0
  227. package/runner/schedules.js +294 -0
  228. package/runner/task-wake.js +59 -0
  229. package/scripts/ai-collab +3 -0
  230. package/scripts/ai-collab-bus.mjs +4 -0
  231. package/scripts/ai-collab-code-mcp.mjs +3 -0
  232. package/scripts/ai-collab-hook +3 -0
  233. package/scripts/ai-collab-hook.mjs +3 -0
  234. package/scripts/ai-collab-mcp-tools.mjs +2 -0
  235. package/scripts/ai-collab-mcp.mjs +3 -0
  236. package/scripts/ai-collab.mjs +3 -0
  237. package/scripts/install-cursor.mjs +11 -0
  238. package/scripts/install-opencode.mjs +10 -0
  239. package/scripts/temmo +3 -0
  240. package/scripts/temmo-bus.mjs +151 -0
  241. package/scripts/temmo-code-mcp.mjs +63 -0
  242. package/scripts/temmo-hook +3 -0
  243. package/scripts/temmo-hook.mjs +201 -0
  244. package/scripts/temmo-mcp-tools.mjs +22 -0
  245. package/scripts/temmo-mcp.mjs +27 -0
  246. package/scripts/temmo.mjs +4 -0
  247. package/skills/antislop/SKILL.md +701 -0
  248. package/skills/antislop/VERSION +1 -0
  249. package/skills/antislop-code/SKILL.md +128 -0
  250. package/skills/antislop-human/LICENSE-web-quality-skills +21 -0
  251. package/skills/antislop-human/SKILL.md +204 -0
  252. package/skills/antislop-human/contrast-check.py +168 -0
  253. package/skills/antislop-human/contrast-mcp.py +125 -0
  254. package/skills/antislop-human/references/A11Y-PATTERNS.md +249 -0
  255. package/skills/antislop-human/references/WCAG.md +127 -0
  256. package/skills/antislop-layoutmobile/SKILL.md +170 -0
  257. package/skills/antislop-ui/LICENSE-web-quality-skills +21 -0
  258. package/skills/antislop-ui/SKILL.md +351 -0
  259. package/skills/antislop-ui/references/CORE-WEB-VITALS.md +181 -0
  260. package/skills/antislop-ui/references/WEB-BASELINE.md +28 -0
  261. package/skills/harness-surface/SKILL.md +42 -0
  262. package/skills/land/SKILL.md +32 -0
  263. package/skills/memory-file/SKILL.md +39 -0
  264. package/skills/temmo/SKILL.md +101 -0
  265. package/skills/temmo/references/role-programs.md +47 -0
  266. package/skills/ui-sdk/SKILL.md +56 -0
  267. package/skills/ui-sdk/references/agent-ready.md +136 -0
  268. package/skills/ui-sdk/references/build-interface.md +187 -0
  269. package/skills/ui-sdk/references/create-component.md +88 -0
  270. package/skills/ui-sdk/references/patterns.md +246 -0
  271. package/skills/ui-sdk/references/styles.md +66 -0
  272. package/skills/ui-sdk/references/testing.md +172 -0
  273. package/skills/ui-sdk/references/web-components.md +78 -0
  274. package/tools/screen-state.mjs +119 -0
  275. package/tools/smoke-ui.mjs +540 -0
  276. package/web/app/activity.jsx +251 -0
  277. package/web/app/agent-mark.tsx +43 -0
  278. package/web/app/alert-level.jsx +16 -0
  279. package/web/app/api/[action]/route.js +8 -0
  280. package/web/app/api/auth/[step]/route.js +12 -0
  281. package/web/app/api/events/route.js +8 -0
  282. package/web/app/api/file/[name]/route.js +8 -0
  283. package/web/app/api/land/route.js +12 -0
  284. package/web/app/api/lessons/route.js +8 -0
  285. package/web/app/api/push/key/route.js +8 -0
  286. package/web/app/api/push/subscribe/route.js +12 -0
  287. package/web/app/api/push/test/route.js +8 -0
  288. package/web/app/api/refs/route.js +8 -0
  289. package/web/app/api/review-diff/route.js +8 -0
  290. package/web/app/api/schedules/route.js +8 -0
  291. package/web/app/api/thread-diff/route.js +8 -0
  292. package/web/app/api/version/route.js +6 -0
  293. package/web/app/cards.jsx +189 -0
  294. package/web/app/chat-api.js +82 -0
  295. package/web/app/chat-composer.jsx +313 -0
  296. package/web/app/chat-console.jsx +691 -0
  297. package/web/app/chat-image.tsx +61 -0
  298. package/web/app/chat-message.jsx +122 -0
  299. package/web/app/chat-shared.jsx +59 -0
  300. package/web/app/chat-sidebar.jsx +25 -0
  301. package/web/app/chat-stream.js +127 -0
  302. package/web/app/chat.jsx +31 -0
  303. package/web/app/compactions.jsx +57 -0
  304. package/web/app/composer-actions.tsx +87 -0
  305. package/web/app/decisions.jsx +53 -0
  306. package/web/app/fonts/OFL-hanken-grotesk.txt +93 -0
  307. package/web/app/fonts/OFL-ibm-plex-mono.txt +93 -0
  308. package/web/app/fonts/hanken-grotesk-latin-wght-normal.woff2 +0 -0
  309. package/web/app/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
  310. package/web/app/fonts/ibm-plex-mono-latin-500-normal.woff2 +0 -0
  311. package/web/app/globals.css +199 -0
  312. package/web/app/home.jsx +246 -0
  313. package/web/app/icon.svg +1 -0
  314. package/web/app/land-panel.jsx +63 -0
  315. package/web/app/land-reviews.jsx +20 -0
  316. package/web/app/layout.jsx +17 -0
  317. package/web/app/lessons.tsx +76 -0
  318. package/web/app/logo.tsx +13 -0
  319. package/web/app/logos.jsx +16 -0
  320. package/web/app/manifest.js +8 -0
  321. package/web/app/mode-menu.tsx +46 -0
  322. package/web/app/new-session.jsx +275 -0
  323. package/web/app/notify.jsx +180 -0
  324. package/web/app/outcomes.tsx +94 -0
  325. package/web/app/page.jsx +9 -0
  326. package/web/app/pattern-graph.jsx +75 -0
  327. package/web/app/patterns-page.jsx +293 -0
  328. package/web/app/phone-nav.tsx +36 -0
  329. package/web/app/progress-feed.tsx +33 -0
  330. package/web/app/providers.tsx +27 -0
  331. package/web/app/quote.jsx +15 -0
  332. package/web/app/run-card.tsx +200 -0
  333. package/web/app/run-requests.tsx +148 -0
  334. package/web/app/scheduled.jsx +105 -0
  335. package/web/app/session-panel.tsx +174 -0
  336. package/web/app/session-toolbar.tsx +180 -0
  337. package/web/app/shadcn.css +638 -0
  338. package/web/app/shipped.jsx +49 -0
  339. package/web/app/subagent-runs.jsx +31 -0
  340. package/web/app/task-graph.jsx +67 -0
  341. package/web/app/tasks-strip.tsx +36 -0
  342. package/web/app/tasks.jsx +375 -0
  343. package/web/app/team-author.jsx +145 -0
  344. package/web/app/team-editor.jsx +88 -0
  345. package/web/app/thread-agents.tsx +32 -0
  346. package/web/app/thread-place.tsx +9 -0
  347. package/web/app/thread-sessions.tsx +149 -0
  348. package/web/app/thread-sidebar.tsx +418 -0
  349. package/web/app/thread-switcher.tsx +27 -0
  350. package/web/app/tool-diff.jsx +94 -0
  351. package/web/components/a2ui/controls.jsx +36 -0
  352. package/web/components/a2ui/option-picker.jsx +23 -0
  353. package/web/components/a2ui/script.tsx +121 -0
  354. package/web/components/a2ui/surface.jsx +81 -0
  355. package/web/components/chat/thread.jsx +50 -0
  356. package/web/components/script-text.tsx +42 -0
  357. package/web/components/ui/avatar.jsx +115 -0
  358. package/web/components/ui/badge.jsx +47 -0
  359. package/web/components/ui/button.jsx +63 -0
  360. package/web/components/ui/chat-container.jsx +52 -0
  361. package/web/components/ui/choice-list.tsx +72 -0
  362. package/web/components/ui/code-block.jsx +60 -0
  363. package/web/components/ui/copy-button.tsx +41 -0
  364. package/web/components/ui/dropdown-menu.jsx +257 -0
  365. package/web/components/ui/markdown.jsx +84 -0
  366. package/web/components/ui/message.jsx +28 -0
  367. package/web/components/ui/popover.jsx +33 -0
  368. package/web/components/ui/scroll-button.jsx +34 -0
  369. package/web/components/ui/select.jsx +189 -0
  370. package/web/components/ui/sheet.jsx +152 -0
  371. package/web/components/ui/sonner.jsx +10 -0
  372. package/web/components/ui/tabs.jsx +88 -0
  373. package/web/components/ui/textarea.jsx +20 -0
  374. package/web/components/ui/tooltip.jsx +56 -0
  375. package/web/components.json +24 -0
  376. package/web/instrumentation.js +8 -0
  377. package/web/lib/a2ui-catalog.js +34 -0
  378. package/web/lib/a2ui-pr.js +76 -0
  379. package/web/lib/a2ui-run-catalog.js +18 -0
  380. package/web/lib/a2ui-run.js +93 -0
  381. package/web/lib/a2ui.js +262 -0
  382. package/web/lib/activity-rows.js +275 -0
  383. package/web/lib/agent-detail.js +5 -0
  384. package/web/lib/alert-level.js +44 -0
  385. package/web/lib/approval-mode.js +22 -0
  386. package/web/lib/chat-turns.js +174 -0
  387. package/web/lib/child-subagents.js +16 -0
  388. package/web/lib/compaction-view.js +48 -0
  389. package/web/lib/composer-actions.js +40 -0
  390. package/web/lib/context-view.js +57 -0
  391. package/web/lib/fuzzy.js +26 -0
  392. package/web/lib/highlight.js +44 -0
  393. package/web/lib/lessons-view.js +23 -0
  394. package/web/lib/mentions.js +16 -0
  395. package/web/lib/message-routing.js +105 -0
  396. package/web/lib/new-session.js +85 -0
  397. package/web/lib/operator-messages.js +28 -0
  398. package/web/lib/pattern-graph.js +165 -0
  399. package/web/lib/pattern-view.js +33 -0
  400. package/web/lib/pending-summary.js +18 -0
  401. package/web/lib/permission-modes.js +30 -0
  402. package/web/lib/project-feed.js +107 -0
  403. package/web/lib/quote.js +7 -0
  404. package/web/lib/reply-quote.js +31 -0
  405. package/web/lib/scheduled.js +79 -0
  406. package/web/lib/selection.js +110 -0
  407. package/web/lib/send-confirmation.js +22 -0
  408. package/web/lib/session-dead.js +10 -0
  409. package/web/lib/session-state.js +132 -0
  410. package/web/lib/sidebar.js +15 -0
  411. package/web/lib/slash-commands.js +164 -0
  412. package/web/lib/start-default.js +35 -0
  413. package/web/lib/start-mode.js +35 -0
  414. package/web/lib/stream-views.js +49 -0
  415. package/web/lib/subagent-state.js +20 -0
  416. package/web/lib/task-board.js +54 -0
  417. package/web/lib/task-graph.js +183 -0
  418. package/web/lib/task-tags.js +41 -0
  419. package/web/lib/team-editor.js +10 -0
  420. package/web/lib/thread-groups.js +86 -0
  421. package/web/lib/threads.js +28 -0
  422. package/web/lib/tool-diff.js +273 -0
  423. package/web/lib/ui-events.js +58 -0
  424. package/web/lib/utils.js +5 -0
  425. package/web/lib/view-memory.js +25 -0
  426. package/web/next.config.mjs +37 -0
  427. package/web/postcss.config.mjs +1 -0
  428. package/web/proxy.js +25 -0
  429. package/web/public/sw.js +39 -0
  430. package/web/server/auth.js +178 -0
  431. package/web/server/dispatch.js +293 -0
  432. package/web/server/history.js +56 -0
  433. package/web/server/hosted.js +58 -0
  434. package/web/server/hub.js +126 -0
  435. package/web/server/instance.js +5 -0
  436. package/web/server/land-reviews.js +64 -0
  437. package/web/server/push.js +148 -0
  438. package/web/server/run-terminal.js +79 -0
  439. package/web/server/schedules.js +38 -0
  440. package/web/server/shipped.js +51 -0
  441. package/web/server/task-board.js +71 -0
  442. package/web/server/threads.js +209 -0
  443. package/web/server/ui.js +2937 -0
  444. package/web/tsconfig.base.json +16 -0
  445. package/web/tsconfig.json +9 -0
@@ -0,0 +1,90 @@
1
+ // The UI capability map: each runner capability and every phone control that drives it (test/ui-capabilities.test.mjs).
2
+ // Add a control here when the UI gains one; add a capability when runner/types.d.ts or an adapter gains one.
3
+ const GAPS = "docs/development.md#";
4
+ export const UI_CAPABILITIES = [
5
+ {
6
+ name: "setModel", kind: "method", controls: [
7
+ { id: "slash-model", label: "/model", source: "web/lib/slash-commands.js:13", offer: { slash: "model" }, route: { action: "command", body: { command: "/model sonnet" }, runner: "setModel" } },
8
+ { id: "actions-model", label: "Actions menu: /model", source: "web/app/composer-actions.tsx", offer: { actionsMenu: "model" }, route: { action: "command", body: { command: "/model sonnet" }, runner: "setModel" } },
9
+ { id: "header-model-picker", label: "Header model picker", source: "web/app/chat-console.jsx:510", offer: { modelPicker: true }, route: { action: "model", body: { model: "sonnet" }, runner: "setModel" } },
10
+ ],
11
+ },
12
+ {
13
+ name: "setPermissionMode", kind: "method", controls: [
14
+ { id: "slash-mode", label: "/mode", source: "web/lib/slash-commands.js:16", offer: { slash: "mode" }, route: { action: "command", body: { command: "/mode supervised" }, runner: "setMode" } },
15
+ { id: "slash-permission", label: "/permission", source: "web/lib/slash-commands.js:15", offer: { slash: "permission" }, route: { action: "command", body: { command: "/permission default" }, runner: "setMode" } },
16
+ { id: "actions-mode", label: "Actions menu: /mode", source: "web/app/composer-actions.tsx", offer: { actionsMenu: "mode" }, route: { action: "command", body: { command: "/mode supervised" }, runner: "setMode" } },
17
+ { id: "actions-permission", label: "Actions menu: /permission", source: "web/app/composer-actions.tsx", offer: { actionsMenu: "permission" }, route: { action: "command", body: { command: "/permission default" }, runner: "setMode" } },
18
+ { id: "card-mode-menu", label: "Mode menu on approval cards", source: "web/app/mode-menu.tsx", offer: { cardModes: true }, route: { action: "command", body: { command: "/mode supervised" }, runner: "setMode" } },
19
+ ],
20
+ },
21
+ {
22
+ name: "compact", kind: "method", controls: [
23
+ { id: "slash-compact", label: "/compact", source: "web/lib/slash-commands.js:12", offer: { slash: "compact" }, route: { action: "command", body: { command: "/compact" }, runner: "compact" } },
24
+ { id: "actions-compact", label: "Actions menu: /compact", source: "web/app/composer-actions.tsx", offer: { actionsMenu: "compact" }, route: { action: "command", body: { command: "/compact" }, runner: "compact" } },
25
+ { id: "session-menu-compact", label: "Session menu: Compact", source: "web/app/chat-console.jsx:523", offer: { always: true }, route: { action: "compact", body: {}, runner: "compact" } },
26
+ ],
27
+ },
28
+ {
29
+ name: "interrupt", kind: "method", controls: [
30
+ { id: "stop-button", label: "Header Stop button", source: "web/app/chat-console.jsx:519", offer: { stopButton: true }, route: { action: "interrupt", body: {}, runner: "interrupt" } },
31
+ { id: "session-menu-interrupt", label: "Session menu: Interrupt", source: "web/app/chat-console.jsx:524", offer: { stopButton: true }, route: { action: "interrupt", body: {}, runner: "interrupt" } },
32
+ ],
33
+ },
34
+ {
35
+ name: "respond", kind: "method", controls: [
36
+ { id: "approval-allow", label: "Allow on approval cards", source: "web/app/cards.jsx:102", offer: { always: true }, route: { action: "approve", bus: "reply <id> allow, read by runner/runner.ts replyDecision", coveredBy: "test/runner.test.mjs" } },
37
+ { id: "approval-deny", label: "Deny on approval cards", source: "web/app/cards.jsx:104", offer: { always: true }, route: { action: "approve", bus: "reply <id> deny, read by runner/runner.ts replyDecision", coveredBy: "test/runner.test.mjs" } },
38
+ ],
39
+ },
40
+ {
41
+ name: "steer", kind: "capability", controls: [
42
+ { id: "send-now", label: "Composer Send now", source: "web/app/chat-composer.jsx:276", offer: { always: true }, route: { action: "send", bus: "urgent message, delivered with steer by runner/runner.ts deliver", coveredBy: "test/runner-steer-direct.test.mjs" },
43
+ fallback: "runner/runner.ts send queues the message for the next turn when the adapter cannot steer" },
44
+ { id: "queue-prioritize", label: "Queue: Prioritize", source: "web/app/chat-console.jsx:629", offer: { always: true }, route: { action: "queue", bus: "marks the queued message urgent", coveredBy: "test/runner-steer-direct.test.mjs" },
45
+ fallback: "runner/runner.ts send queues the message for the next turn when the adapter cannot steer" },
46
+ ],
47
+ },
48
+ {
49
+ name: "images", kind: "capability", controls: [
50
+ { id: "image-attach", label: "Composer image attach", source: "web/app/chat-composer.jsx:266", offer: { always: true }, route: { action: "send", bus: "attachment event; runner/runner.ts deliver puts the cached file's path in the text", coveredBy: "test/attachment-cache.test.mjs" },
51
+ fallback: "the message text names the cached image file, which the agent reads with its own tools" },
52
+ ],
53
+ },
54
+ {
55
+ name: "contextUsage", kind: "method", controls: [
56
+ { id: "context-chip", label: "Header context chip", source: "web/app/chat-console.jsx:518", offer: { always: true }, route: { display: "runner/runner.ts writes contextUsage() into the state file web/server/ui.ts readContext shows" },
57
+ fallback: "the chip shows the usage the session's hooks report, or nothing" },
58
+ ],
59
+ },
60
+ {
61
+ name: "permissionModes", kind: "capability", controls: [
62
+ { id: "mode-values", label: "/mode values and the card mode menu", source: "web/lib/permission-modes.js:8", offer: { modeList: true }, route: { display: "the values /mode, /permission and the card mode menu offer" } },
63
+ ],
64
+ },
65
+ {
66
+ name: "places", kind: "capability", controls: [
67
+ { id: "new-session-openshell", label: "New session: OpenShell place", source: "web/app/new-session.jsx:179", offer: { openshellStart: true }, route: { action: "start", bus: "runner start with place openshell", coveredBy: "test/runner-spawn-openshell.test.mjs" } },
68
+ ],
69
+ },
70
+ ];
71
+ export const EXPECTED_FAILURES = [
72
+ { harness: "cursor", capability: "setModel", control: "header-model-picker", check: "a", followUp: GAPS + "cursor-model-switch",
73
+ reason: "web/server/ui.ts sets modelControl only for Claude, so the header picker never reaches the Cursor handle's setModel (/model does, since #62)" },
74
+ { harness: "opencode", capability: "setModel", control: "slash-model", check: "b", followUp: GAPS + "opencode-model-bypasses-the-runner",
75
+ reason: "lib/slash.ts posts /model to the OpenCode service directly; the runner-owned handle has no setModel, so the runner's record keeps the old model" },
76
+ { harness: "opencode", capability: "setModel", control: "actions-model", check: "b", followUp: GAPS + "opencode-model-bypasses-the-runner",
77
+ reason: "the Actions menu offers /model from SUPPORT.opencode.model; see slash-model" },
78
+ { harness: "opencode", capability: "setModel", control: "slash-model", check: "c", followUp: GAPS + "opencode-model-bypasses-the-runner",
79
+ reason: "/model on a runner-owned OpenCode session goes to the OpenCode service, never to runner setModel" },
80
+ { harness: "opencode", capability: "setModel", control: "actions-model", check: "c", followUp: GAPS + "opencode-model-bypasses-the-runner",
81
+ reason: "the Actions menu posts the same /model command; see slash-model" },
82
+ { harness: "cursor", capability: "compact", control: "session-menu-compact", check: "b", followUp: GAPS + "compact-on-a-runner-owned-cursor-session",
83
+ reason: "Compact shows for a runner-owned Cursor session; the runner answers unsupported and web/server/ui.ts runnerCompact returns that without the request fallback" },
84
+ { harness: "claude", capability: "images", control: "image-attach", check: "c", followUp: GAPS + "claude-and-pi-image-input",
85
+ reason: "runner/runner.ts never sets UserInput.images, so the Claude adapter's image input (claude.ts userMessage) is never used; the image reaches Claude as a file path" },
86
+ { harness: "pi", capability: "images", control: "image-attach", check: "c", followUp: GAPS + "claude-and-pi-image-input",
87
+ reason: "runner/runner.ts never sets UserInput.images, so pi.ts imagesOf always sends none; the image reaches pi as a file path" },
88
+ { harness: "pi", capability: "setModel", control: "header-model-picker", check: "a", followUp: GAPS + "pi-model-switch-and-permission",
89
+ reason: "web/server/ui.ts sets modelControl only for Claude, so the header picker is missing (/model works since #62)" },
90
+ ];
package/lib/usage.js ADDED
@@ -0,0 +1,182 @@
1
+ import { alertPriority, readAlertLevel } from "./alerts.js";
2
+ /**
3
+ * Current-context telemetry from harness-reported counters, read locally; only the session label and token count leave the host.
4
+ * Claude: last assistant message usage in the transcript (input + cache_read + cache_creation).
5
+ * Codex: last token_count event's info.last_token_usage.total_tokens and info.model_context_window in the rollout.
6
+ * Cursor: preCompact hook's context_tokens. OpenCode: context_tokens from the plugin (last step's input + cache tokens).
7
+ * Claude, Cursor and OpenCode report no window, so their window is null.
8
+ * Per session, the .context.json state keeps the last tokens, window and time, and the instruction files Claude loaded
9
+ * (InstructionsLoaded hook: file_path, memory_type, load_reason).
10
+ */
11
+ import { closeSync, fstatSync, openSync, readFileSync, readSync } from "node:fs";
12
+ import { encodeEnvelope } from "./agui.js";
13
+ import { broadcastTopic } from "./config.js";
14
+ import { publish } from "./messaging.js";
15
+ import { writeState, statePath, withLock } from "./state.js";
16
+ export const CONTEXT_ALERT_TOKENS = 200_000;
17
+ const TAIL_BYTES = 512 * 1024;
18
+ const CONTEXT_FILES_MAX = 50;
19
+ const MEMORY_TYPES = new Set(["User", "Project", "Local", "Managed"]);
20
+ /** Instruction loads a compaction drops from the context (lib/usage.ts recordInstructions). */
21
+ export const ON_DEMAND_LOADS = new Set(["nested_traversal", "path_glob_match"]);
22
+ const LOAD_REASONS = new Set(["session_start", "nested_traversal", "path_glob_match", "include", "compact"]);
23
+ function tailLines(file) {
24
+ const fd = openSync(file, "r");
25
+ try {
26
+ const size = fstatSync(fd).size;
27
+ const length = Math.min(size, TAIL_BYTES);
28
+ const buffer = Buffer.alloc(length);
29
+ readSync(fd, buffer, 0, length, size - length);
30
+ return buffer.toString("utf8").split("\n").reverse();
31
+ }
32
+ finally {
33
+ closeSync(fd);
34
+ }
35
+ }
36
+ function count(value) {
37
+ return Number.isSafeInteger(value) && value >= 0 ? value : null;
38
+ }
39
+ function contextStatePath(cfg) {
40
+ return statePath(cfg).replace(/\.json$/, ".context.json");
41
+ }
42
+ /** {tokens, window} from the harness's last usage report; each is null when unknown. */
43
+ export function contextUsage(host, msg) {
44
+ if (host === "cursor" || host === "opencode" || host === "pi")
45
+ return { tokens: count(msg.context_tokens), window: null };
46
+ const none = { tokens: null, window: null };
47
+ const file = msg.transcript_path;
48
+ if (typeof file !== "string" || !file.endsWith(".jsonl"))
49
+ return none;
50
+ let lines;
51
+ try {
52
+ lines = tailLines(file);
53
+ }
54
+ catch {
55
+ return none;
56
+ }
57
+ for (const line of lines) {
58
+ let entry;
59
+ try {
60
+ entry = JSON.parse(line);
61
+ }
62
+ catch {
63
+ continue;
64
+ }
65
+ if (host === "claude" && entry?.type === "assistant" && entry.message?.usage) {
66
+ const u = entry.message.usage;
67
+ const parts = [u.input_tokens, u.cache_read_input_tokens ?? 0, u.cache_creation_input_tokens ?? 0].map(count);
68
+ return { tokens: parts.includes(null) ? null : parts.reduce((a, b) => a + b, 0), window: null };
69
+ }
70
+ if (host === "codex" && entry?.type === "event_msg" && entry.payload?.type === "token_count" && entry.payload.info) {
71
+ return {
72
+ tokens: count(entry.payload.info.last_token_usage?.total_tokens),
73
+ window: count(entry.payload.info.model_context_window),
74
+ };
75
+ }
76
+ }
77
+ return none;
78
+ }
79
+ export function contextTokens(host, msg) {
80
+ return contextUsage(host, msg).tokens;
81
+ }
82
+ /** Alert once per crossing above the threshold; a failed publish stays armed so the next sample retries; ≤ threshold re-arms. */
83
+ export async function reportContext(cfg, tokens, { send = publish, window = null } = {}) {
84
+ if (!cfg.enabled || !cfg.session || tokens === null)
85
+ return { alerted: false };
86
+ const file = contextStatePath(cfg);
87
+ const result = await withLock(file, async () => {
88
+ let state = {};
89
+ try {
90
+ state = JSON.parse(readFileSync(file, "utf8"));
91
+ }
92
+ catch { /* missing: armed */ }
93
+ // The file is rewritten only when the tokens or window change; contextAt is the time of that change.
94
+ if (state.contextTokens !== tokens || state.contextWindow !== window) {
95
+ state.contextTokens = tokens;
96
+ state.contextWindow = window;
97
+ state.contextAt = Date.now();
98
+ writeState(file, state);
99
+ }
100
+ const armed = state.contextAlertArmed !== false;
101
+ if (tokens <= CONTEXT_ALERT_TOKENS) {
102
+ if (!armed) {
103
+ state.contextAlertArmed = true;
104
+ writeState(file, state);
105
+ }
106
+ return false;
107
+ }
108
+ if (!armed)
109
+ return false;
110
+ const who = `${cfg.peer}#${cfg.session}`;
111
+ const message = encodeEnvelope("alert", { from: cfg.peer, session: cfg.session, contextTokens: tokens, threshold: CONTEXT_ALERT_TOKENS }, cfg.wire);
112
+ await send(cfg, broadcastTopic(cfg.project), message, { title: `temmo: ${who} context ${tokens} tokens (> ${CONTEXT_ALERT_TOKENS})`, priority: alertPriority(readAlertLevel(), "other") });
113
+ state.contextAlertArmed = false;
114
+ writeState(file, state);
115
+ return true;
116
+ });
117
+ return { alerted: Boolean(result.locked && result.value) };
118
+ }
119
+ /** Drops the on-demand instruction files from the state once a compaction has finished; resolves true when any was dropped. */
120
+ export async function dropOnDemandFiles(cfg) {
121
+ if (!cfg.enabled || !cfg.session)
122
+ return false;
123
+ const file = contextStatePath(cfg);
124
+ const result = await withLock(file, async () => {
125
+ let state;
126
+ try {
127
+ state = JSON.parse(readFileSync(file, "utf8"));
128
+ }
129
+ catch {
130
+ return false;
131
+ }
132
+ const files = Array.isArray(state.contextFiles) ? state.contextFiles : [];
133
+ const kept = files.filter((entry) => !ON_DEMAND_LOADS.has(entry.load));
134
+ if (kept.length === files.length)
135
+ return false;
136
+ state.contextFiles = kept;
137
+ writeState(file, state);
138
+ return true;
139
+ });
140
+ return Boolean(result.locked && result.value);
141
+ }
142
+ /** Records one instruction file from the InstructionsLoaded hook; a later load of the same path replaces its entry. */
143
+ export async function recordInstructions(cfg, msg) {
144
+ const { file_path: path, memory_type: memory, load_reason: load } = msg;
145
+ if (!cfg.enabled || !cfg.session || typeof path !== "string" || !path.startsWith("/") || !MEMORY_TYPES.has(memory) || !LOAD_REASONS.has(load))
146
+ return false;
147
+ const file = contextStatePath(cfg);
148
+ const result = await withLock(file, async () => {
149
+ let state = {};
150
+ try {
151
+ state = JSON.parse(readFileSync(file, "utf8"));
152
+ }
153
+ catch { /* missing: none loaded yet */ }
154
+ // A compaction drops the files that were loaded on demand (nested or glob-matched) from the context; the rest reload.
155
+ const kept = (Array.isArray(state.contextFiles) ? state.contextFiles : []).filter((entry) => entry.path !== path);
156
+ const others = load === "compact" ? kept.filter(entry => !ON_DEMAND_LOADS.has(entry.load)) : kept;
157
+ state.contextFiles = [...others, { path, memory, load, at: Date.now() }].slice(-CONTEXT_FILES_MAX);
158
+ writeState(file, state);
159
+ return true;
160
+ });
161
+ return Boolean(result.locked && result.value);
162
+ }
163
+ /** The session's context from its state file: {tokens, window, at, files}; absent parts are null or []. */
164
+ export function readContext(cfg) {
165
+ const empty = { tokens: null, window: null, at: null, files: [] };
166
+ if (!cfg.session)
167
+ return empty;
168
+ let state;
169
+ try {
170
+ state = JSON.parse(readFileSync(contextStatePath(cfg), "utf8"));
171
+ }
172
+ catch {
173
+ return empty;
174
+ }
175
+ const files = Array.isArray(state.contextFiles) ? state.contextFiles.filter((entry) => typeof entry?.path === "string") : [];
176
+ return {
177
+ tokens: count(state.contextTokens),
178
+ window: count(state.contextWindow),
179
+ at: Number.isFinite(state.contextAt) ? state.contextAt : null,
180
+ files,
181
+ };
182
+ }
@@ -0,0 +1,4 @@
1
+ // Types for the bundled SDK: the same exports as the package it was built from.
2
+ export { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
+ export { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ export { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";