@bigmistqke/workpad 0.0.0-stage → 0.18.1

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 (277) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +781 -2
  3. package/bin/workpad.ts +1526 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/taggedTemplateLiteral.js +5 -0
  5. package/dist/bin/workpad.js +1202 -0
  6. package/dist/client/runtime.js +1194 -0
  7. package/dist/define.js +27 -0
  8. package/dist/plugins/alert/README.md +18 -0
  9. package/dist/plugins/alert/index.js +40 -0
  10. package/dist/plugins/alert/public/style.css +40 -0
  11. package/dist/plugins/ansi/README.md +36 -0
  12. package/dist/plugins/ansi/index.js +63 -0
  13. package/dist/plugins/ansi/public/style.css +28 -0
  14. package/dist/plugins/badge/README.md +32 -0
  15. package/dist/plugins/badge/index.js +28 -0
  16. package/dist/plugins/badge/public/style.css +30 -0
  17. package/dist/plugins/chat/README.md +81 -0
  18. package/dist/plugins/chat/index.js +96 -0
  19. package/dist/plugins/chat/public/client.js +3 -0
  20. package/dist/plugins/chat/public/style.css +143 -0
  21. package/dist/plugins/claude/README.md +116 -0
  22. package/dist/plugins/claude/channel.js +130 -0
  23. package/dist/plugins/claude/doctor.js +316 -0
  24. package/dist/plugins/claude/index.js +199 -0
  25. package/dist/plugins/claude/session.js +68 -0
  26. package/dist/plugins/code/README.md +54 -0
  27. package/dist/plugins/code/diff.js +75 -0
  28. package/dist/plugins/code/index.js +105 -0
  29. package/dist/plugins/code/public/client.js +1 -0
  30. package/dist/plugins/code/public/style.css +99 -0
  31. package/dist/plugins/comments/README.md +30 -0
  32. package/dist/plugins/comments/index.js +39 -0
  33. package/dist/plugins/comments/public/client.js +24 -0
  34. package/dist/plugins/comments/public/style.css +224 -0
  35. package/dist/plugins/details/README.md +24 -0
  36. package/dist/plugins/details/index.js +28 -0
  37. package/dist/plugins/details/public/style.css +7 -0
  38. package/dist/plugins/draft/README.md +14 -0
  39. package/dist/plugins/draft/index.js +27 -0
  40. package/dist/plugins/draft/public/style.css +21 -0
  41. package/dist/plugins/forge/README.md +22 -0
  42. package/dist/plugins/forge/index.js +83 -0
  43. package/dist/plugins/form/README.md +126 -0
  44. package/dist/plugins/form/index.js +179 -0
  45. package/dist/plugins/form/public/style.css +172 -0
  46. package/dist/plugins/grid/README.md +45 -0
  47. package/dist/plugins/grid/index.js +35 -0
  48. package/dist/plugins/grid/public/style.css +98 -0
  49. package/dist/plugins/iframe/README.md +18 -0
  50. package/dist/plugins/iframe/index.js +49 -0
  51. package/dist/plugins/iframe/public/style.css +28 -0
  52. package/dist/plugins/index.js +44 -0
  53. package/dist/plugins/lightbox/README.md +24 -0
  54. package/dist/plugins/lightbox/index.js +20 -0
  55. package/dist/plugins/lightbox/public/client.js +4 -0
  56. package/dist/plugins/lightbox/public/style.css +66 -0
  57. package/dist/plugins/mermaid/README.md +21 -0
  58. package/dist/plugins/mermaid/index.js +42 -0
  59. package/dist/plugins/mermaid/public/style.css +21 -0
  60. package/dist/plugins/opencode/README.md +48 -0
  61. package/dist/plugins/opencode/channel.js +92 -0
  62. package/dist/plugins/opencode/index.js +64 -0
  63. package/dist/plugins/opencode/shim.js +150 -0
  64. package/dist/plugins/quiet/README.md +26 -0
  65. package/dist/plugins/quiet/index.js +23 -0
  66. package/dist/plugins/tabs/README.md +44 -0
  67. package/dist/plugins/tabs/index.js +75 -0
  68. package/dist/plugins/tabs/public/client.js +1 -0
  69. package/dist/plugins/tabs/public/style.css +98 -0
  70. package/dist/plugins/terminal/README.md +63 -0
  71. package/dist/plugins/terminal/host.js +338 -0
  72. package/dist/plugins/terminal/index.js +170 -0
  73. package/dist/plugins/terminal/modes.js +32 -0
  74. package/dist/plugins/terminal/public/client.js +41 -0
  75. package/dist/plugins/terminal/public/style.css +511 -0
  76. package/dist/plugins/terminal/server.js +256 -0
  77. package/dist/plugins/terminal/sizes.js +58 -0
  78. package/dist/plugins/timeline/README.md +48 -0
  79. package/dist/plugins/timeline/index.js +83 -0
  80. package/dist/plugins/timeline/public/style.css +138 -0
  81. package/dist/plugins/toc/README.md +40 -0
  82. package/dist/plugins/toc/index.js +29 -0
  83. package/dist/plugins/toc/public/client.js +1 -0
  84. package/dist/plugins/toc/public/style.css +117 -0
  85. package/dist/plugins/window/README.md +51 -0
  86. package/dist/plugins/window/index.js +91 -0
  87. package/dist/solid/index.js +41 -0
  88. package/dist/src/agents.js +81 -0
  89. package/dist/src/anchors.js +52 -0
  90. package/dist/src/api.js +282 -0
  91. package/dist/src/archive.js +49 -0
  92. package/dist/src/auth.js +67 -0
  93. package/dist/src/build.js +159 -0
  94. package/dist/src/client/page/base.css +1762 -0
  95. package/dist/src/client/page/main.js +2121 -0
  96. package/dist/src/config.js +76 -0
  97. package/dist/src/document.js +93 -0
  98. package/dist/src/entries.js +264 -0
  99. package/dist/src/events.js +322 -0
  100. package/dist/src/files.js +47 -0
  101. package/dist/src/formstate.js +65 -0
  102. package/dist/src/help.js +213 -0
  103. package/dist/src/html.js +34 -0
  104. package/dist/src/hub.js +348 -0
  105. package/dist/src/icons.js +6 -0
  106. package/dist/src/listen.js +132 -0
  107. package/dist/src/listeners.js +64 -0
  108. package/dist/src/load.js +81 -0
  109. package/dist/src/loader.js +179 -0
  110. package/dist/src/migrate.js +314 -0
  111. package/dist/src/package.js +52 -0
  112. package/dist/src/pages/blocks.js +67 -0
  113. package/dist/src/pages/board.js +59 -0
  114. package/dist/src/pages/index.js +27 -0
  115. package/dist/src/pages/markdown.js +863 -0
  116. package/dist/src/pages/render.js +761 -0
  117. package/dist/src/pages/window.js +29 -0
  118. package/dist/src/plugins.js +283 -0
  119. package/dist/src/public.js +24 -0
  120. package/dist/src/rename.js +130 -0
  121. package/dist/src/running.js +146 -0
  122. package/dist/src/serve.js +188 -0
  123. package/dist/src/server.js +1105 -0
  124. package/dist/src/site.js +179 -0
  125. package/dist/src/state.js +155 -0
  126. package/dist/src/status.js +323 -0
  127. package/dist/src/thread.js +68 -0
  128. package/dist/src/watchdog.js +38 -0
  129. package/dist/src/ws.js +128 -0
  130. package/package.json +154 -4
  131. package/plugins/README.md +304 -0
  132. package/plugins/alert/README.md +18 -0
  133. package/plugins/alert/index.ts +50 -0
  134. package/plugins/alert/public/style.css +40 -0
  135. package/plugins/ansi/README.md +36 -0
  136. package/plugins/ansi/index.ts +95 -0
  137. package/plugins/ansi/public/style.css +28 -0
  138. package/plugins/badge/README.md +32 -0
  139. package/plugins/badge/index.ts +36 -0
  140. package/plugins/badge/public/style.css +30 -0
  141. package/plugins/chat/README.md +81 -0
  142. package/plugins/chat/autosize.ts +139 -0
  143. package/plugins/chat/client.tsx +187 -0
  144. package/plugins/chat/index.ts +146 -0
  145. package/plugins/chat/public/style.css +143 -0
  146. package/plugins/claude/README.md +116 -0
  147. package/plugins/claude/channel.ts +136 -0
  148. package/plugins/claude/doctor.ts +274 -0
  149. package/plugins/claude/index.ts +248 -0
  150. package/plugins/claude/session.ts +70 -0
  151. package/plugins/code/README.md +54 -0
  152. package/plugins/code/client.ts +73 -0
  153. package/plugins/code/diff.ts +96 -0
  154. package/plugins/code/index.ts +136 -0
  155. package/plugins/code/public/style.css +99 -0
  156. package/plugins/comments/README.md +30 -0
  157. package/plugins/comments/client.ts +723 -0
  158. package/plugins/comments/index.ts +48 -0
  159. package/plugins/comments/public/style.css +224 -0
  160. package/plugins/details/README.md +24 -0
  161. package/plugins/details/index.ts +30 -0
  162. package/plugins/details/public/style.css +7 -0
  163. package/plugins/draft/README.md +14 -0
  164. package/plugins/draft/index.ts +23 -0
  165. package/plugins/draft/public/style.css +21 -0
  166. package/plugins/forge/README.md +22 -0
  167. package/plugins/forge/index.ts +84 -0
  168. package/plugins/form/README.md +126 -0
  169. package/plugins/form/index.ts +199 -0
  170. package/plugins/form/public/style.css +172 -0
  171. package/plugins/grid/README.md +45 -0
  172. package/plugins/grid/index.ts +41 -0
  173. package/plugins/grid/public/style.css +98 -0
  174. package/plugins/iframe/README.md +18 -0
  175. package/plugins/iframe/index.ts +53 -0
  176. package/plugins/iframe/public/style.css +28 -0
  177. package/plugins/index.ts +49 -0
  178. package/plugins/lightbox/README.md +24 -0
  179. package/plugins/lightbox/client.ts +109 -0
  180. package/plugins/lightbox/index.ts +25 -0
  181. package/plugins/lightbox/public/style.css +66 -0
  182. package/plugins/mermaid/README.md +21 -0
  183. package/plugins/mermaid/index.ts +46 -0
  184. package/plugins/mermaid/public/style.css +21 -0
  185. package/plugins/opencode/README.md +48 -0
  186. package/plugins/opencode/channel.ts +112 -0
  187. package/plugins/opencode/index.ts +91 -0
  188. package/plugins/opencode/shim.ts +166 -0
  189. package/plugins/quiet/README.md +26 -0
  190. package/plugins/quiet/index.ts +28 -0
  191. package/plugins/tabs/README.md +44 -0
  192. package/plugins/tabs/client.ts +96 -0
  193. package/plugins/tabs/index.ts +103 -0
  194. package/plugins/tabs/public/style.css +98 -0
  195. package/plugins/terminal/README.md +63 -0
  196. package/plugins/terminal/client.ts +391 -0
  197. package/plugins/terminal/host.ts +434 -0
  198. package/plugins/terminal/index.ts +199 -0
  199. package/plugins/terminal/modes.ts +30 -0
  200. package/plugins/terminal/public/style.css +225 -0
  201. package/plugins/terminal/server.ts +266 -0
  202. package/plugins/terminal/sizes.ts +72 -0
  203. package/plugins/timeline/README.md +48 -0
  204. package/plugins/timeline/index.ts +82 -0
  205. package/plugins/timeline/public/style.css +138 -0
  206. package/plugins/toc/README.md +40 -0
  207. package/plugins/toc/client.ts +236 -0
  208. package/plugins/toc/index.ts +55 -0
  209. package/plugins/toc/public/style.css +117 -0
  210. package/plugins/window/README.md +51 -0
  211. package/plugins/window/index.ts +92 -0
  212. package/skills/workpad/SKILL.md +592 -0
  213. package/solid/index.tsx +80 -0
  214. package/src/agents.ts +134 -0
  215. package/src/anchors.ts +85 -0
  216. package/src/api.ts +444 -0
  217. package/src/archive.ts +75 -0
  218. package/src/auth.ts +99 -0
  219. package/src/build.ts +213 -0
  220. package/src/client/base.ts +19 -0
  221. package/src/client/forms.ts +420 -0
  222. package/src/client/markdown.ts +147 -0
  223. package/src/client/page/base.css +1762 -0
  224. package/src/client/page/board.ts +166 -0
  225. package/src/client/page/elsewhere.ts +153 -0
  226. package/src/client/page/fresh.ts +343 -0
  227. package/src/client/page/heading-link.ts +32 -0
  228. package/src/client/page/live.ts +134 -0
  229. package/src/client/page/main.ts +398 -0
  230. package/src/client/page/orphans.ts +64 -0
  231. package/src/client/page/place.ts +260 -0
  232. package/src/client/page/sort.ts +49 -0
  233. package/src/client/page/sticky.ts +58 -0
  234. package/src/client/page/theme.ts +36 -0
  235. package/src/client/page/view.ts +9 -0
  236. package/src/client/page/waiting.ts +278 -0
  237. package/src/client/page/window.ts +40 -0
  238. package/src/client/reactive.ts +19 -0
  239. package/src/client/read.ts +111 -0
  240. package/src/client/runtime.ts +499 -0
  241. package/src/client/scroll.ts +90 -0
  242. package/src/client/toast.ts +99 -0
  243. package/src/config.ts +111 -0
  244. package/src/define.ts +997 -0
  245. package/src/document.ts +191 -0
  246. package/src/entries.ts +352 -0
  247. package/src/events.ts +463 -0
  248. package/src/files.ts +74 -0
  249. package/src/formstate.ts +72 -0
  250. package/src/help.ts +240 -0
  251. package/src/html.ts +44 -0
  252. package/src/hub.ts +435 -0
  253. package/src/icons.ts +18 -0
  254. package/src/listen.ts +171 -0
  255. package/src/listeners.ts +89 -0
  256. package/src/load.ts +113 -0
  257. package/src/loader.ts +227 -0
  258. package/src/migrate.ts +352 -0
  259. package/src/package.ts +62 -0
  260. package/src/pages/blocks.ts +106 -0
  261. package/src/pages/board.ts +89 -0
  262. package/src/pages/index.ts +79 -0
  263. package/src/pages/markdown.ts +976 -0
  264. package/src/pages/render.ts +845 -0
  265. package/src/pages/window.ts +69 -0
  266. package/src/plugins.ts +319 -0
  267. package/src/public.ts +39 -0
  268. package/src/rename.ts +147 -0
  269. package/src/running.ts +171 -0
  270. package/src/serve.ts +221 -0
  271. package/src/server.ts +1385 -0
  272. package/src/site.ts +170 -0
  273. package/src/state.ts +327 -0
  274. package/src/status.ts +466 -0
  275. package/src/thread.ts +98 -0
  276. package/src/watchdog.ts +53 -0
  277. package/src/ws.ts +155 -0
@@ -0,0 +1,143 @@
1
+ /* A chat: the reader's messages on the right, the agent's on the left; never part of an answer. */
2
+ .wp-chat {
3
+ display: flex;
4
+ flex-direction: column;
5
+ gap: var(--space-lg);
6
+ font: var(--ui-text)/var(--ui-line-height) var(--sans);
7
+ }
8
+ /* under a form: set off from the question by a dashed rule */
9
+ .wp-chat[data-under-form] {
10
+ margin-top: var(--space-xs);
11
+ padding-top: var(--space-xl);
12
+ border-top: var(--hairline) dashed var(--border);
13
+ }
14
+ .wp-chat-message {
15
+ display: flex;
16
+ flex-direction: column;
17
+ gap: var(--space-2xs);
18
+ max-width: 85%;
19
+ align-self: flex-start;
20
+ align-items: flex-start;
21
+ }
22
+ /* an agent's message holding blocks (a form, a details, a diagram: Api.message) takes the whole width a
23
+ message may, so they are laid out as on the page, not squeezed to its text */
24
+ .wp-chat-message:has(> .wp-chat-bubble > :is(form, details, figure, section, .wp-window, [data-block])) {
25
+ width: 85%;
26
+ }
27
+ .wp-chat-message:has(> .wp-chat-bubble > :is(form, details, figure, section, .wp-window, [data-block]))
28
+ > .wp-chat-bubble {
29
+ align-self: stretch;
30
+ }
31
+ /* a form in a message: its ring inside the bubble, not out past it */
32
+ .wp-chat-bubble form.wp-form {
33
+ --wp-ring-at: 6px;
34
+ margin-inline: 6px;
35
+ }
36
+ /* one that starts or ends the message: as far in from the bubble's edge there as from its sides
37
+ (the bubble is padded less above and below than beside) */
38
+ .wp-chat-bubble[data-md] > form.wp-form:first-child {
39
+ margin-top: calc(var(--space-xl) - var(--space-md) + 6px);
40
+ }
41
+ .wp-chat-bubble[data-md] > form.wp-form:last-child {
42
+ margin-bottom: calc(var(--space-xl) - var(--space-md) + 6px);
43
+ }
44
+ /* inside the form, its last line (the buttons) as close to its ring as its sides are: the bubble's
45
+ paragraph spacing stops before it, as the bubble's own last child's does */
46
+ .wp-chat-bubble[data-md] form.wp-form > :last-child {
47
+ margin-bottom: 0;
48
+ }
49
+ .wp-chat-message[data-from='you'] {
50
+ align-self: flex-end;
51
+ align-items: flex-end;
52
+ }
53
+ /* shown at once, grey until the server has it */
54
+ .wp-chat-message[data-from='you'][data-sending] .wp-chat-bubble {
55
+ background: var(--wp-sending, #9a9fa7);
56
+ border-color: var(--wp-sending, #9a9fa7);
57
+ color: var(--bg);
58
+ transition:
59
+ background-color 0.2s,
60
+ border-color 0.2s;
61
+ }
62
+ .wp-chat-who {
63
+ font: var(--weight-strong) var(--ui-tiny)/1.3 var(--sans);
64
+ letter-spacing: var(--caps-spacing);
65
+ text-transform: uppercase;
66
+ color: var(--muted);
67
+ padding: 0 var(--space-xs);
68
+ }
69
+ .wp-chat-message[data-from='agent'] .wp-chat-who {
70
+ color: var(--accent);
71
+ }
72
+ .wp-chat-bubble {
73
+ max-width: 100%;
74
+ min-width: 0;
75
+ box-sizing: border-box;
76
+ white-space: pre-wrap;
77
+ padding: var(--space-md) var(--space-xl);
78
+ border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-sm);
79
+ background: var(--tint);
80
+ border: var(--hairline) solid var(--border);
81
+ }
82
+ /* rendered from markdown: its paragraphs and code carry the spacing */
83
+ .wp-chat-bubble[data-md] {
84
+ white-space: normal;
85
+ overflow-wrap: anywhere;
86
+ }
87
+ .wp-chat-bubble[data-md] > :first-child {
88
+ margin-top: 0;
89
+ }
90
+ .wp-chat-bubble[data-md] > :last-child {
91
+ margin-bottom: 0;
92
+ }
93
+ .wp-chat-bubble[data-md] :is(p, ul, ol, pre, blockquote, table) {
94
+ margin: 0 0 0.5em;
95
+ }
96
+ /* a table's cells wrap between words, not inside them (the bubble's own wrapping anywhere would
97
+ squeeze its columns down to a letter); one too wide for the bubble scrolls sideways */
98
+ .wp-chat-bubble[data-md] table {
99
+ overflow-wrap: normal;
100
+ }
101
+ /* code keeps its lines whole and scrolls sideways, as on a page (code/style.css: {wrap} wraps it) */
102
+ .wp-chat-bubble[data-md] pre {
103
+ font-size: var(--ui-small);
104
+ padding: var(--space-md) var(--space-lg);
105
+ border-radius: var(--radius-sm);
106
+ }
107
+ .wp-chat-message[data-from='you'] .wp-chat-bubble[data-md] a {
108
+ color: inherit;
109
+ }
110
+ .wp-chat-message[data-from='you'] .wp-chat-bubble {
111
+ border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg);
112
+ background: var(--accent);
113
+ border-color: var(--accent);
114
+ color: var(--accent-text);
115
+ }
116
+ .wp-chat-new {
117
+ display: flex;
118
+ gap: var(--space-md);
119
+ align-items: flex-start;
120
+ }
121
+ .wp-chat-new textarea {
122
+ flex: 1;
123
+ resize: none;
124
+ font: inherit;
125
+ }
126
+
127
+ /* :::chat on its own: set off from the article like a form, hairlines above and below */
128
+ .wp-chat-block {
129
+ margin: var(--gap-block) 0;
130
+ padding: 1.6em 0 1.7em;
131
+ border-top: var(--hairline) solid var(--border);
132
+ border-bottom: var(--hairline) solid var(--border);
133
+ display: grid;
134
+ /* one column, as wide as the block: wide content (a code block) scrolls inside it, not past it */
135
+ grid-template-columns: minmax(0, 1fr);
136
+ gap: var(--space-2xl);
137
+ }
138
+ .wp-chat-block > :first-child {
139
+ margin-top: 0;
140
+ }
141
+ .wp-chat-block > :is(p, ul, ol) {
142
+ margin: 0;
143
+ }
@@ -0,0 +1,116 @@
1
+ # Claude Code
2
+
3
+ The Claude Code plugin brings your answers to an agent session without the
4
+ agent having to wait for them, and tells it what is open on its pages:
5
+
6
+ ```ts
7
+ import claude from '@bigmistqke/workpad/claude'
8
+
9
+ export default defineConfig({
10
+ plugins: [claude()],
11
+ })
12
+ ```
13
+
14
+ With it, the Claude Code session is who runs workpad's commands (unless
15
+ `WORKPAD_AGENT` names it otherwise): `workpad new` subscribes it to the
16
+ page it makes, and `workpad status` marks that session's pages.
17
+ `workpad claude install` sets it up for the project: the channel, which
18
+ pushes your answers into the session, and the turn-end check, which sends a
19
+ turn on once when it ends with something left on its pages. `uninstall`
20
+ takes them out again, leaving other servers, hooks and settings as they
21
+ are. What they write runs the project's own copy of workpad when it
22
+ depends on one, so the files can be committed for everyone who works on it.
23
+
24
+ ## Setting it up, in order
25
+
26
+ In a project where an agent should get your answers without waiting for
27
+ them:
28
+
29
+ 1. `workpad init`, then add `claude()` to the plugins in
30
+ `.workpad/config.ts` (example above).
31
+ 2. `workpad claude install`: the channel in `.mcp.json`, the hooks in
32
+ `.claude/settings.json`.
33
+ 3. Start Claude Code with the channel:
34
+ `claude --dangerously-load-development-channels server:workpad`. A
35
+ session started before step 2 has no channel to load: start it again.
36
+ At "New MCP server found", choose to use it; Esc disables it.
37
+ 4. In the session, the agent runs `workpad agent ping`, and confirms the
38
+ pong with `workpad agent ping <code>`.
39
+ 5. The channel then follows the session's pages: those it makes with
40
+ `workpad new`, also later ones. `workpad claude doctor` says what
41
+ is missing when answers don't arrive.
42
+
43
+ ## The channel
44
+
45
+ An MCP server, `workpad claude channel`, that Claude Code starts
46
+ with each session. Once the agent has checked that it works (below), it
47
+ listens on the pages that session is subscribed to (also ones it subscribes
48
+ to later), as a `listen` does, and pushes each answer you give there into the session, as a
49
+ message:
50
+
51
+ ```text
52
+ <channel source="workpad" page="plan" id="mwv…" type="scope">plan: form scope: "Smaller" (id mwv…; …)</channel>
53
+ ```
54
+
55
+ No `listen` needs to run for the agent, and it gets your answer while it
56
+ works; the answer counts as received once it is sent, and the form folds.
57
+ The session's pages are those it made or listened on; `workpad listen
58
+ --channel` makes more its own (every page without `--page`, also later
59
+ ones) and exits at once.
60
+
61
+ Claude Code starts the server also when the session was started without
62
+ the channel (without the flag below, with `-p`, or when an organisation's
63
+ policy turns channels off), and then drops what it sends without a word.
64
+ So the channel listens on nothing until the agent has run `workpad
65
+ ping`: the channel pushes a pong into the session, with a code, and the
66
+ agent confirms it with `workpad agent ping <code>`. Until then your pages say
67
+ nobody listens.
68
+
69
+ Channels are a research preview of Claude Code: a session loads one only
70
+ when started with
71
+
72
+ ```sh
73
+ claude --dangerously-load-development-channels server:workpad
74
+ ```
75
+
76
+ (an alias saves typing it). It works with Claude Code only: the push is
77
+ Claude Code's own extension of MCP. With many projects under one shared
78
+ server, registering it once for your user covers them all:
79
+ `claude mcp add --scope user workpad -- workpad claude channel`.
80
+ Problems (a hand-out that failed, say) are written to
81
+ `.workpad/claude/channel.log`.
82
+
83
+ It is two parts: the server in the project's `.mcp.json`, and a silent
84
+ SessionStart hook in its `.claude/settings.json` that tells it which
85
+ session it serves (on a resume, Claude Code starts it with an id the
86
+ conversation then leaves).
87
+
88
+ ### When answers don't arrive
89
+
90
+ ```sh
91
+ workpad claude doctor
92
+ ```
93
+
94
+ checks, in the session, everything the channel needs, a line each with
95
+ what to do about one that fails: the channel in `.mcp.json` and that its
96
+ command answers; the server approved and disabled in no settings file
97
+ (`.claude/settings.json`, `settings.local.json`, `~/.claude/settings.json`,
98
+ the project in `~/.claude.json`, and in a git worktree without its own
99
+ `settings.local.json`, the main checkout's, where Claude Code writes an Esc
100
+ on "New MCP server found"); the session started with the flag above, in
101
+ the project's folder; the server up at the project's version; a channel
102
+ for this session; and its ping confirmed. `/mcp` doesn't list a disabled
103
+ server at all, so this is where to look. It changes nothing, and exits 1
104
+ when something is to fix.
105
+
106
+ ## The turn-end check
107
+
108
+ A Stop hook in the project's `.claude/settings.json`: when a turn ends with
109
+ something left on the session's pages (a question nobody listens for, an
110
+ answer the agent didn't handle, a chat waiting for its reply), the turn
111
+ goes on once, telling the agent what to do about it (agents forget). A turn
112
+ the hook already continued ends, and you see what is open. It is the safety
113
+ net for a session started without the channel, and for an answer the agent
114
+ received and then forgot. An answer the channel sent that hasn't reached
115
+ the conversation yet (Claude Code holds a channel's message until the turn
116
+ ends) doesn't count: it comes as a turn of its own.
@@ -0,0 +1,130 @@
1
+ import { channelSince } from "../../src/status.js";
2
+ import { ANSWERS_NOTE, answerLine, identity, pong } from "../../src/agents.js";
3
+ import { read } from "../../src/events.js";
4
+ import { claudeProcess, recordedSession } from "./session.js";
5
+ import fs from "node:fs";
6
+ import path from "node:path";
7
+ import readline from "node:readline";
8
+ // plugins/claude/channel.ts
9
+ const INSTRUCTIONS = ["Messages from workpad arrive as <channel source=\"workpad\">: a pong for `workpad agent ping`, which says how to confirm it, and once confirmed the reader's answers on your workpad pages (a form, a chat message, a comment), received already.", ANSWERS_NOTE].join(" ");
10
+ async function channel(ctx) {
11
+ const problem = (what, data) => {
12
+ fs.mkdirSync(ctx.dataDir, { recursive: true });
13
+ fs.appendFileSync(path.join(ctx.dataDir, "channel.log"), `${(/* @__PURE__ */ new Date()).toISOString()} ${what}${data === void 0 ? "" : " " + JSON.stringify(data)}\n`);
14
+ };
15
+ const send = (msg) => process.stdout.write(JSON.stringify({
16
+ jsonrpc: "2.0",
17
+ ...msg
18
+ }) + "\n");
19
+ const claude = claudeProcess();
20
+ const started = process.env.CLAUDE_CODE_SESSION_ID || null;
21
+ let session = null;
22
+ /** The conversation now, and a line in the log when it changed after start (a resume). */
23
+ const current = () => {
24
+ const now = identity(recordedSession(ctx.dataDir, claude) ?? started);
25
+ if (now !== session) {
26
+ if (!now) problem("no CLAUDE_CODE_SESSION_ID: no pages to follow");
27
+ else if (now !== started || session) problem("following another session than at start", {
28
+ started,
29
+ now
30
+ });
31
+ session = now;
32
+ }
33
+ return session;
34
+ };
35
+ let ready = false;
36
+ const queue = [];
37
+ const notify = (content, meta) => {
38
+ const msg = {
39
+ method: "notifications/claude/channel",
40
+ params: {
41
+ content,
42
+ meta
43
+ }
44
+ };
45
+ if (!ready) return void queue.push(msg);
46
+ send(msg);
47
+ };
48
+ let confirmed = false;
49
+ let line = null;
50
+ const hold = (session) => {
51
+ if (!session) return;
52
+ if (line) return line.move(session);
53
+ line = ctx.channel(session, {
54
+ onPing: (code) => notify(pong(code), { type: "pong" }),
55
+ onConfirmed: () => {
56
+ confirmed = true;
57
+ round();
58
+ }
59
+ });
60
+ };
61
+ const followed = /* @__PURE__ */ new Set();
62
+ const follow = async () => {
63
+ const session = current();
64
+ hold(session);
65
+ if (!confirmed || !session) return;
66
+ const pages = (await ctx.status()).filter((p) => p.subscribers.includes(session)).map((p) => p.page);
67
+ for (const page of pages) {
68
+ if (followed.has(page)) continue;
69
+ followed.add(page);
70
+ await ctx.listen(page, { agent: session });
71
+ const push = (e, again) => notify(answerLine(e, again), {
72
+ page: e.page,
73
+ id: e.id,
74
+ type: e.type
75
+ });
76
+ const since = channelSince(read(ctx.eventsFile).events, session, page) ?? void 0;
77
+ ctx.handOut({
78
+ page,
79
+ exact: true
80
+ }, push, {
81
+ agent: session,
82
+ skipReceivedBefore: since
83
+ }).catch((err) => problem("handing out failed", {
84
+ page,
85
+ err: String(err)
86
+ }));
87
+ }
88
+ };
89
+ const rl = readline.createInterface({ input: process.stdin });
90
+ rl.on("line", (line) => {
91
+ let msg;
92
+ try {
93
+ msg = JSON.parse(line);
94
+ } catch {
95
+ return;
96
+ }
97
+ if (msg.method === "initialize") send({
98
+ id: msg.id,
99
+ result: {
100
+ protocolVersion: msg.params?.protocolVersion ?? "2025-06-18",
101
+ capabilities: { experimental: { "claude/channel": {} } },
102
+ serverInfo: {
103
+ name: "workpad",
104
+ version: "1"
105
+ },
106
+ instructions: INSTRUCTIONS
107
+ }
108
+ });
109
+ else if (msg.method === "notifications/initialized") {
110
+ ready = true;
111
+ for (const m of queue.splice(0)) send(m);
112
+ } else if (msg.method === "ping") send({
113
+ id: msg.id,
114
+ result: {}
115
+ });
116
+ else if (msg.id !== void 0) send({
117
+ id: msg.id,
118
+ error: {
119
+ code: -32601,
120
+ message: `no method ${msg.method}`
121
+ }
122
+ });
123
+ });
124
+ rl.on("close", () => process.exit(0));
125
+ const round = () => follow().catch((err) => problem("finding the session’s pages failed", String(err)));
126
+ await round();
127
+ setInterval(() => void round(), 5e3);
128
+ await new Promise(() => {});
129
+ }
130
+ export { channel };