@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,68 @@
1
+ import { fromReader, isQuestionName } from "./status.js";
2
+ import { chatForms, formSource } from "./pages/markdown.js";
3
+ // src/thread.ts
4
+ const who = (e) => fromReader(e) ? "reader" : "agent";
5
+ const when = (e) => e.ts.replace("T", " ").slice(0, 16);
6
+ const indent = (text) => text.split("\n").map((l) => ` ${l}`).join("\n");
7
+ /** What was chosen or written in an answer, as the reader gave it. */
8
+ function said(e) {
9
+ const d = e.data ?? {};
10
+ const parts = Object.entries(d).filter(([, v]) => v !== "" && v != null && !(Array.isArray(v) && !v.length)).map(([k, v]) => `${k}: ${JSON.stringify(v)}`);
11
+ if (e.action && e.action !== "send") parts.unshift(`pressed ${e.action}`);
12
+ return parts.join(", ") || `pressed ${e.action ?? "send"}`;
13
+ }
14
+ /**
15
+ * The form as written, each option the answer chose marked: `:radio[…]{name=x value=a}` is chosen
16
+ * when the answer's `x` is `a` (or holds it, for a check).
17
+ */
18
+ function marked(markdown, answer) {
19
+ if (!answer) return markdown;
20
+ const d = answer.data ?? {};
21
+ return markdown.split("\n").map((line) => {
22
+ return [...line.matchAll(/:(?:radio|check)\[[^\]]*\]\{([^}]*)\}/g)].some((m) => {
23
+ const name = /\bname=("([^"]*)"|(\S+))/.exec(m[1]);
24
+ const value = /\bvalue=("([^"]*)"|(\S+))/.exec(m[1]);
25
+ if (!name || !value) return false;
26
+ const got = d[name[2] ?? name[3]];
27
+ const want = value[2] ?? value[3];
28
+ return Array.isArray(got) ? got.map(String).includes(want) : String(got) === want;
29
+ }) ? `${line} ← chosen` : line;
30
+ }).join("\n");
31
+ }
32
+ /**
33
+ * The thread of `id` on its page, as lines to print: the event, its form and its chat. `source` is
34
+ * the page's markdown ('' when it is gone); `events` the page's events.
35
+ */
36
+ function thread(id, events, source) {
37
+ const event = events.find((e) => e.id === id);
38
+ if (!event) throw new Error(`no event ${id}`);
39
+ const d = event.data ?? {};
40
+ const name = isQuestionName(event.type) ? event.type : typeof d.chat === "string" ? d.chat : null;
41
+ const out = [`page ${event.page}`];
42
+ if (!name) {
43
+ out.push("", `${who(event)} ${when(event)} ${event.type} (${event.id}):`, indent(JSON.stringify(d)));
44
+ return out.join("\n");
45
+ }
46
+ const chat = name.includes("/") ? name.slice(0, name.indexOf("/")) : name;
47
+ const inChat = chat !== name ? chatForms(events, event.page, chat).find((f) => f.name === name) : void 0;
48
+ const form = inChat ? {
49
+ heading: null,
50
+ markdown: inChat.markdown
51
+ } : formSource(source, name);
52
+ const answers = events.filter((e) => e.type === name && fromReader(e));
53
+ if (form) out.push("", `form ${name}${inChat ? `, in a message of the chat ${chat}` : form.heading ? `, under "${form.heading}"` : ""}:`, indent(marked(form.markdown, answers.includes(event) ? event : answers.at(-1))));
54
+ else if (isQuestionName(event.type)) out.push("", `form ${name}: no longer on the page`);
55
+ if (answers.length) {
56
+ out.push("", answers.length > 1 ? "answers:" : "answer:");
57
+ for (const a of answers) out.push(` ${when(a)}${a.id === id ? " (this one)" : ""}: ${said(a)}`);
58
+ }
59
+ const messages = events.filter((e) => e.type === "chat:message" && e.data?.chat === chat);
60
+ const replaced = new Set(messages.map((m) => m.data?.replaces).filter(Boolean).map(String));
61
+ const shown = messages.filter((m) => !replaced.has(m.id));
62
+ if (shown.length) {
63
+ out.push("", `chat ${chat}:`);
64
+ for (const m of shown) out.push(` ${who(m)} ${when(m)}${m.id === id ? " (this one)" : ""}:`, indent(indent(String(m.data?.text ?? ""))));
65
+ }
66
+ return out.join("\n");
67
+ }
68
+ export { thread };
@@ -0,0 +1,38 @@
1
+ import { performance } from "node:perf_hooks";
2
+ // src/watchdog.ts
3
+ /** How often the loop is checked, and from how late on a check counts as a stall. */
4
+ const TICK_MS = 500;
5
+ const STALL_MS = 1e3;
6
+ /** A request answered slower than this is logged (streams, such as server-sent events, aren't). */
7
+ const SLOW_MS = 2e3;
8
+ const stderr = (message) => console.error(`${(/* @__PURE__ */ new Date()).toISOString()} workpad: ${message}`);
9
+ /** Watch the event loop: a check that comes late by more than STALL_MS is logged. */
10
+ function watchStalls(log = stderr, { tick = TICK_MS, stall = STALL_MS } = {}) {
11
+ let last = performance.now();
12
+ const timer = setInterval(() => {
13
+ const now = performance.now();
14
+ const late = now - last - tick;
15
+ if (late > stall) log(`the event loop was blocked for ${Math.round(late)}ms: nothing was answered meanwhile`);
16
+ last = now;
17
+ }, tick);
18
+ timer.unref();
19
+ return () => clearInterval(timer);
20
+ }
21
+ /** Log a server's slow requests and its socket's errors. */
22
+ function watchServer(server, log = stderr, { slow = SLOW_MS } = {}) {
23
+ server.on("request", (req, res) => {
24
+ const start = performance.now();
25
+ res.on("finish", () => {
26
+ const took = performance.now() - start;
27
+ const head = String(res.getHeader("content-type") ?? "") + String(res._header ?? "");
28
+ if (took <= slow || head.includes("text/event-stream")) return;
29
+ log(`slow request: ${req.method} ${req.url} took ${Math.round(took)}ms`);
30
+ });
31
+ });
32
+ server.on("error", (err) => log(`the server's socket: ${err.message}`));
33
+ server.on("clientError", (err, socket) => {
34
+ if (err.code !== "ECONNRESET" && err.code !== "EPIPE") log(`a client's request: ${err.message}`);
35
+ if (socket.writable) socket.end("HTTP/1.1 400 Bad Request\r\n\r\n");
36
+ });
37
+ }
38
+ export { watchServer, watchStalls };
package/dist/src/ws.js ADDED
@@ -0,0 +1,128 @@
1
+ import crypto from "node:crypto";
2
+ // src/ws.ts
3
+ const GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
4
+ const PING_EVERY = 25e3;
5
+ /** Is this request asking to become a WebSocket? */
6
+ const isUpgrade = (req) => (req.headers.upgrade ?? "").toLowerCase() === "websocket" && !!req.headers["sec-websocket-key"];
7
+ /** Answer the handshake and give the socket; null (and the connection refused) if it isn't one. */
8
+ function accept(req, conn) {
9
+ const key = req.headers["sec-websocket-key"];
10
+ if (!isUpgrade(req) || typeof key !== "string" || req.headers["sec-websocket-version"] !== "13") {
11
+ refuse(conn, 400, "Bad Request");
12
+ return null;
13
+ }
14
+ const hash = crypto.createHash("sha1").update(key + GUID).digest("base64");
15
+ conn.write(`HTTP/1.1 101 Switching Protocols\r
16
+ Upgrade: websocket\r
17
+ Connection: Upgrade\r
18
+ Sec-WebSocket-Accept: ${hash}\r\n\r\n`);
19
+ if ("setNoDelay" in conn && typeof conn.setNoDelay === "function") conn.setNoDelay(true);
20
+ let open = true;
21
+ const closers = [];
22
+ const ended = () => {
23
+ if (!open) return;
24
+ open = false;
25
+ clearInterval(ping);
26
+ for (const fn of closers.splice(0)) fn();
27
+ };
28
+ const write = (opcode, payload) => {
29
+ if (!open || conn.destroyed) return;
30
+ conn.write(Buffer.concat([header(opcode, payload.length), payload]));
31
+ };
32
+ let alive = true;
33
+ const ping = setInterval(() => {
34
+ if (!alive) return void conn.destroy();
35
+ alive = false;
36
+ write(9, Buffer.alloc(0));
37
+ }, PING_EVERY);
38
+ ping.unref?.();
39
+ let buf = Buffer.alloc(0);
40
+ conn.on("data", (chunk) => {
41
+ buf = Buffer.concat([buf, chunk]);
42
+ for (;;) {
43
+ const frame = parse(buf);
44
+ if (!frame) break;
45
+ buf = buf.subarray(frame.size);
46
+ alive = true;
47
+ if (frame.opcode === 8) {
48
+ write(8, frame.payload.subarray(0, 2));
49
+ ended();
50
+ conn.end();
51
+ return;
52
+ }
53
+ if (frame.opcode === 9) write(10, frame.payload);
54
+ }
55
+ if (buf.length > 1 << 20) conn.destroy();
56
+ });
57
+ conn.on("close", ended);
58
+ conn.on("error", () => conn.destroy());
59
+ return {
60
+ send: (text) => write(1, Buffer.from(text, "utf8")),
61
+ close() {
62
+ if (!open) return;
63
+ write(8, Buffer.from([3, 232]));
64
+ ended();
65
+ conn.end();
66
+ setTimeout(() => conn.destroy(), 1e3).unref?.();
67
+ },
68
+ onClose(fn) {
69
+ if (open) closers.push(fn);
70
+ else fn();
71
+ }
72
+ };
73
+ }
74
+ /** Turn an upgrade down with a plain HTTP response. */
75
+ function refuse(conn, status, text) {
76
+ if (conn.destroyed) return;
77
+ conn.end(`HTTP/1.1 ${status} ${text}\r\nConnection: close\r\nContent-Length: 0\r\n\r\n`);
78
+ }
79
+ /** A frame's header, unmasked as the server sends them, FIN set. */
80
+ function header(opcode, length) {
81
+ if (length < 126) return Buffer.from([128 | opcode, length]);
82
+ if (length < 65536) {
83
+ const h = Buffer.alloc(4);
84
+ h[0] = 128 | opcode;
85
+ h[1] = 126;
86
+ h.writeUInt16BE(length, 2);
87
+ return h;
88
+ }
89
+ const h = Buffer.alloc(10);
90
+ h[0] = 128 | opcode;
91
+ h[1] = 127;
92
+ h.writeBigUInt64BE(BigInt(length), 2);
93
+ return h;
94
+ }
95
+ /** One whole frame at the start of `buf` (unmasked), or null while it hasn't all arrived. */
96
+ function parse(buf) {
97
+ if (buf.length < 2) return null;
98
+ const opcode = buf[0] & 15;
99
+ const masked = (buf[1] & 128) !== 0;
100
+ let length = buf[1] & 127;
101
+ let at = 2;
102
+ if (length === 126) {
103
+ if (buf.length < 4) return null;
104
+ length = buf.readUInt16BE(2);
105
+ at = 4;
106
+ } else if (length === 127) {
107
+ if (buf.length < 10) return null;
108
+ const big = buf.readBigUInt64BE(2);
109
+ if (big > BigInt(1 << 20)) return {
110
+ opcode: 8,
111
+ payload: Buffer.alloc(0),
112
+ size: buf.length
113
+ };
114
+ length = Number(big);
115
+ at = 10;
116
+ }
117
+ const mask = masked ? buf.subarray(at, at + 4) : null;
118
+ if (masked) at += 4;
119
+ if (buf.length < at + length) return null;
120
+ const payload = Buffer.from(buf.subarray(at, at + length));
121
+ if (mask) for (let i = 0; i < payload.length; i++) payload[i] = payload[i] ^ mask[i % 4];
122
+ return {
123
+ opcode,
124
+ payload,
125
+ size: at + length
126
+ };
127
+ }
128
+ export { accept, isUpgrade, refuse };
package/package.json CHANGED
@@ -1,6 +1,156 @@
1
1
  {
2
2
  "name": "@bigmistqke/workpad",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.18.1",
4
+ "description": "A workpad for you and your agent: it writes markdown pages you read live in the browser, you answer through forms it waits on",
5
+ "keywords": [
6
+ "agent",
7
+ "ai",
8
+ "markdown",
9
+ "live-reload",
10
+ "forms",
11
+ "workpad",
12
+ "agent-skills",
13
+ "skill",
14
+ "cli"
15
+ ],
16
+ "license": "MIT",
17
+ "author": "bigmistqke",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/bigmistqke/workpad.git"
21
+ },
22
+ "homepage": "https://github.com/bigmistqke/workpad#readme",
23
+ "bugs": "https://github.com/bigmistqke/workpad/issues",
24
+ "type": "module",
25
+ "bin": {
26
+ "workpad": "dist/bin/workpad.js"
27
+ },
28
+ "exports": {
29
+ ".": {
30
+ "source": "./src/define.ts",
31
+ "types": "./src/define.ts",
32
+ "default": "./dist/define.js"
33
+ },
34
+ "./log": {
35
+ "source": "./src/events.ts",
36
+ "types": "./src/events.ts",
37
+ "default": "./dist/src/events.js"
38
+ },
39
+ "./api": {
40
+ "source": "./src/api.ts",
41
+ "types": "./src/api.ts",
42
+ "default": "./dist/src/api.js"
43
+ },
44
+ "./terminal": {
45
+ "source": "./plugins/terminal/index.ts",
46
+ "types": "./plugins/terminal/index.ts",
47
+ "default": "./dist/plugins/terminal/index.js"
48
+ },
49
+ "./claude": {
50
+ "source": "./plugins/claude/index.ts",
51
+ "types": "./plugins/claude/index.ts",
52
+ "default": "./dist/plugins/claude/index.js"
53
+ },
54
+ "./opencode": {
55
+ "source": "./plugins/opencode/index.ts",
56
+ "types": "./plugins/opencode/index.ts",
57
+ "default": "./dist/plugins/opencode/index.js"
58
+ },
59
+ "./comments": {
60
+ "source": "./plugins/comments/index.ts",
61
+ "types": "./plugins/comments/index.ts",
62
+ "default": "./dist/plugins/comments/index.js"
63
+ },
64
+ "./forge": {
65
+ "source": "./plugins/forge/index.ts",
66
+ "types": "./plugins/forge/index.ts",
67
+ "default": "./dist/plugins/forge/index.js"
68
+ },
69
+ "./toc": {
70
+ "source": "./plugins/toc/index.ts",
71
+ "types": "./plugins/toc/index.ts",
72
+ "default": "./dist/plugins/toc/index.js"
73
+ },
74
+ "./solid": {
75
+ "types": "./solid/index.tsx",
76
+ "default": "./dist/solid/index.js"
77
+ },
78
+ "./plugins": {
79
+ "source": "./plugins/index.ts",
80
+ "types": "./plugins/index.ts",
81
+ "default": "./dist/plugins/index.js"
82
+ },
83
+ "./code": {
84
+ "source": "./plugins/code/index.ts",
85
+ "types": "./plugins/code/index.ts",
86
+ "default": "./dist/plugins/code/index.js"
87
+ }
88
+ },
89
+ "files": [
90
+ "bin",
91
+ "src",
92
+ "dist",
93
+ "plugins",
94
+ "solid",
95
+ "skills",
96
+ "!**/*.test.ts"
97
+ ],
98
+ "scripts": {
99
+ "build": "node build.ts",
100
+ "dev": "node build.ts --watch",
101
+ "prepare": "node build.ts",
102
+ "prepublishOnly": "npm run check && npm test",
103
+ "release": "npm run check && npm test && bumpp --commit 'Release v%s' && npm publish --access public",
104
+ "start": "node bin/workpad.ts serve",
105
+ "check": "tsc -p tsconfig.json",
106
+ "format": "prettier --write .",
107
+ "test": "node --test --test-force-exit 'src/**/*.test.ts' 'plugins/**/*.test.ts'",
108
+ "test:browser": "node --test --test-force-exit --test-concurrency=1 'test/browser/*.test.ts'"
109
+ },
110
+ "engines": {
111
+ "node": ">=22.18"
112
+ },
113
+ "dependencies": {
114
+ "@xterm/addon-serialize": "^0.14.0",
115
+ "@xterm/headless": "^6.0.0",
116
+ "mdast-util-to-string": "^4.0.0",
117
+ "pele": "^1.13.0",
118
+ "rehype-stringify": "^10.0.1",
119
+ "remark-directive": "^4.0.0",
120
+ "remark-gfm": "^4.0.1",
121
+ "remark-parse": "^11.0.0",
122
+ "remark-rehype": "^11.1.2",
123
+ "shiki": "^4.6.0",
124
+ "unified": "^11.0.5",
125
+ "yaml": "^2.9.1"
126
+ },
127
+ "peerDependencies": {
128
+ "@solidjs/web": "^2.0.0-rc.21",
129
+ "solid-js": "^2.0.0-rc.21"
130
+ },
131
+ "peerDependenciesMeta": {
132
+ "solid-js": {
133
+ "optional": true
134
+ },
135
+ "@solidjs/web": {
136
+ "optional": true
137
+ }
138
+ },
139
+ "devDependencies": {
140
+ "@solidjs/compiler": "^2.0.0-rc.21",
141
+ "@solidjs/web": "^2.0.0-rc.21",
142
+ "@types/node": "^26.6.6",
143
+ "@xterm/addon-fit": "^0.11.0",
144
+ "@xterm/xterm": "^6.0.0",
145
+ "bumpp": "^12.3.0",
146
+ "morphdom": "^2.7.7",
147
+ "playwright": "^1.60.0",
148
+ "prettier": "^3.10.1",
149
+ "rolldown": "^1.2.19",
150
+ "solid-js": "^2.0.0-rc.21",
151
+ "typescript": "^7.0.2"
152
+ },
153
+ "optionalDependencies": {
154
+ "node-pty": "^1.1.0"
155
+ }
156
+ }