acrylblends 1.0.3 → 1.0.5

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 (256) hide show
  1. package/docs/framework/agents/index.md +6 -4
  2. package/docs/framework/workshop/README.md +3 -3
  3. package/docs/framework/workshop/facilitator.md +1 -0
  4. package/lib/accept-CNNHu4Cf.js +193 -0
  5. package/lib/{accepts-XBuZPVRI.js → accepts-Btq83xPd.js} +1 -1
  6. package/lib/accepts.js +1 -1
  7. package/lib/acryl-base.js +1 -331
  8. package/lib/adapter-CaZ6FZUU.js +37 -0
  9. package/lib/adapter.js +1 -36
  10. package/lib/{app-BM0rTCp7.js → app-CQcGWjrk.js} +4 -4
  11. package/lib/app-base-CpRMZL4v.js +332 -0
  12. package/lib/{audit-BXnYsLge.d.ts → audit-D5z9uwOP.d.ts} +14 -1
  13. package/lib/{base-NSN_SNv-.js → base-D_6kfOr-.js} +1 -1
  14. package/lib/basic-auth-C0HTRpXh.js +20 -0
  15. package/lib/basic-auth-DFLflXNe.js +95 -0
  16. package/lib/basic-auth.js +1 -94
  17. package/lib/bearer-auth-Cwxt-vgS.js +94 -0
  18. package/lib/bearer-auth.js +1 -93
  19. package/lib/body-D7f4e7w_.js +94 -0
  20. package/lib/body-limit-WmIjWRLt.js +66 -0
  21. package/lib/body-limit.js +1 -65
  22. package/lib/buffer-CkEOJCcY.js +51 -0
  23. package/lib/bun.js +3 -3
  24. package/lib/cache-B0bHH7s5.js +169 -0
  25. package/lib/cache.js +1 -168
  26. package/lib/{client-DDLXwhBo.js → client-BrMFnMEd.js} +1 -1
  27. package/lib/{client-modules-CLvWOjbd.js → client-modules-drj4mjhj.js} +4 -4
  28. package/lib/client.js +1 -1
  29. package/lib/color-COa3DplO.js +37 -0
  30. package/lib/combine-TWuGdcbC.js +137 -0
  31. package/lib/combine.js +1 -136
  32. package/lib/{components-cEW3ovK0.js → components-B2ka9Ax1.js} +4 -4
  33. package/lib/{components-JXVm45kK.js → components-PVXwaOaC.js} +2 -2
  34. package/lib/compress-BzWqsHF1.js +79 -0
  35. package/lib/compress-C-9vK4B2.d.ts +11 -0
  36. package/lib/compress-DCyrrQ5D.js +11 -0
  37. package/lib/compress.d.ts +1 -1
  38. package/lib/compress.js +2 -78
  39. package/lib/concurrent-DrF3d2c-.js +30 -0
  40. package/lib/conninfo-BCROmdnf.d.ts +11 -0
  41. package/lib/conninfo-CWJwieh4.js +19 -0
  42. package/lib/constants-CBSEudrb.js +7 -0
  43. package/lib/{context-DDO0cfuP.js → context-CkOh7Ygv.js} +2 -2
  44. package/lib/context-storage-iuPoI_CR.js +52 -0
  45. package/lib/context-storage.js +1 -51
  46. package/lib/cookie-B1LlkzOe.js +125 -0
  47. package/lib/cookie-BHIduy2T.js +82 -0
  48. package/lib/cookie.js +1 -81
  49. package/lib/cordis/db-sqlite.d.ts +1 -1
  50. package/lib/cordis/door.d.ts +17 -3
  51. package/lib/cordis/door.js +123 -16
  52. package/lib/cordis/inspect.js +4 -4
  53. package/lib/cordis/kv-db.d.ts +1 -1
  54. package/lib/cordis/kv-db.js +1 -1
  55. package/lib/cordis/kv-json.d.ts +1 -1
  56. package/lib/cordis/kv-json.js +1 -1
  57. package/lib/cordis/node-server.d.ts +1 -1
  58. package/lib/cordis/node-server.js +3 -116
  59. package/lib/cordis/router-http.d.ts +1 -1
  60. package/lib/cordis/router-http.js +2 -2
  61. package/lib/cordis/router.d.ts +1 -1
  62. package/lib/cordis/router.js +4 -4
  63. package/lib/cordis/state.js +7 -7
  64. package/lib/{core-CaY8XDZ6.js → core-BOu1jYua.js} +1 -1
  65. package/lib/cors-CbAQ-8qU.js +106 -0
  66. package/lib/cors.js +1 -105
  67. package/lib/crypto-iVP-N-tS.js +34 -0
  68. package/lib/csrf-DqqOZtgy.js +101 -0
  69. package/lib/csrf.js +1 -100
  70. package/lib/css-C5CPVMvM.js +134 -0
  71. package/lib/css.js +2 -133
  72. package/lib/db/sqlite.d.ts +1 -25
  73. package/lib/dev-CLgu-JRe.js +50 -0
  74. package/lib/dev.js +1 -49
  75. package/lib/dom-YjND9Jt3.js +74 -0
  76. package/lib/door/host.d.ts +2 -2
  77. package/lib/door/host.js +1 -1
  78. package/lib/door/page.d.ts +12 -1
  79. package/lib/door/page.js +22 -1
  80. package/lib/door/protocol.d.ts +2 -2
  81. package/lib/door/protocol.js +2 -197
  82. package/lib/encode-BhbNLrjp.js +33 -0
  83. package/lib/factory-CLdSf-xS.js +30 -0
  84. package/lib/factory.js +1 -29
  85. package/lib/handler-C0wZ0KwO.js +12 -0
  86. package/lib/helpers-BEjcdbgw.js +5 -0
  87. package/lib/{hooks-w72iLeFR.js → hooks-CfC07ri0.js} +1 -1
  88. package/lib/html-CgNa89xw.js +31 -0
  89. package/lib/html-DGExBFNg.js +103 -0
  90. package/lib/html.d.ts +2 -5
  91. package/lib/html.js +2 -30
  92. package/lib/http-exception-MjWkT89V.js +54 -0
  93. package/lib/http-exception.js +1 -53
  94. package/lib/{index-D4nVR3wu.d.ts → index-DMOtA-NJ.d.ts} +7 -1
  95. package/lib/index-dAzQsJG9.d.ts +6 -0
  96. package/lib/index.js +3 -3
  97. package/lib/ip-restriction-jKtKCRM_.js +166 -0
  98. package/lib/ip-restriction.js +1 -165
  99. package/lib/ipaddr-DCoIo528.js +238 -0
  100. package/lib/jsx/dom/client.js +1 -1
  101. package/lib/jsx/dom/jsx-dev-runtime.js +1 -1
  102. package/lib/jsx/dom/jsx-runtime.js +2 -1
  103. package/lib/jsx/dom/server.js +3 -3
  104. package/lib/jsx/dom.js +5 -73
  105. package/lib/jsx/jsx-dev-runtime.d.ts +2 -5
  106. package/lib/jsx/jsx-dev-runtime.js +2 -13
  107. package/lib/jsx/jsx-runtime.d.ts +2 -2
  108. package/lib/jsx/jsx-runtime.js +4 -4
  109. package/lib/jsx/streaming.js +1 -1
  110. package/lib/jsx-CUQgttxU.js +47 -0
  111. package/lib/jsx-dev-runtime-B4WTyq8r.js +14 -0
  112. package/lib/{jsx-dev-runtime-CWLRA2F3.js → jsx-dev-runtime-BLfA-EhI.js} +2 -2
  113. package/lib/jsx-dev-runtime-CGt4kNYr.d.ts +6 -0
  114. package/lib/jsx-renderer-CfifM4hT.js +99 -0
  115. package/lib/jsx-renderer.js +1 -98
  116. package/lib/jsx-runtime-COCRWBJ9.js +2 -0
  117. package/lib/jsx.js +5 -46
  118. package/lib/{jwk-LkzeoaU8.js → jwk-CDPpYQpD.js} +3 -3
  119. package/lib/jwk.js +1 -1
  120. package/lib/{jwt-BGJBw5AF.js → jwt-BXoIA2fQ.js} +2 -2
  121. package/lib/{jwt-CskdhEW9.js → jwt-lyS4Q3mT.js} +3 -3
  122. package/lib/jwt.js +2 -2
  123. package/lib/kv/db.d.ts +1 -10
  124. package/lib/kv/db.js +1 -56
  125. package/lib/kv/json.d.ts +1 -9
  126. package/lib/kv/json.js +1 -223
  127. package/lib/{language-D9a4zqvn.js → language-DeGRtLJt.js} +2 -2
  128. package/lib/language.js +1 -1
  129. package/lib/{linear-router-C3FPib6h.js → linear-router-CmZn_JLV.js} +2 -2
  130. package/lib/logger-Ckxu8diz.js +54 -0
  131. package/lib/logger.js +1 -53
  132. package/lib/loopback-only-BbasoF7R.js +90 -0
  133. package/lib/loopback-only.js +1 -89
  134. package/lib/method-not-allowed-TO2_hnfl.js +82 -0
  135. package/lib/method-not-allowed.js +1 -81
  136. package/lib/method-override-DnZKfJbV.js +103 -0
  137. package/lib/method-override.js +1 -102
  138. package/lib/middleware-BfG_fp8P.js +12 -0
  139. package/lib/mime-BnScXkQn.js +77 -0
  140. package/lib/mount-QkK_3NtJ.js +67 -0
  141. package/lib/mount.js +1 -66
  142. package/lib/node-server/conninfo.d.ts +1 -10
  143. package/lib/node-server/conninfo.js +1 -18
  144. package/lib/node-server/register.js +25 -2
  145. package/lib/node-server/serve-static.d.ts +1 -17
  146. package/lib/node-server/serve-static.js +1 -1
  147. package/lib/node-server.d.ts +2 -2
  148. package/lib/node-server.js +4 -4
  149. package/lib/open-BqK4D2Wn.d.ts +11 -0
  150. package/lib/open-But9E2rL.js +57 -0
  151. package/lib/open-CULVJgOc.d.ts +12 -0
  152. package/lib/open-Dp4sxspc.js +224 -0
  153. package/lib/open-T7kgbO2O.d.ts +27 -0
  154. package/lib/{pattern-router-HZxjDGEQ.js → pattern-router-CJBecJBd.js} +1 -1
  155. package/lib/powered-by-CXQNjNIX.js +24 -0
  156. package/lib/powered-by.js +1 -23
  157. package/lib/pretty-json-CeC1yvYt.js +39 -0
  158. package/lib/pretty-json.js +1 -38
  159. package/lib/{protocol-BizVt4J6.d.ts → protocol-C37gPePD.d.ts} +9 -2
  160. package/lib/protocol-Dt0AZBOz.js +213 -0
  161. package/lib/proxy-C2w_mH7k.js +121 -0
  162. package/lib/proxy.js +1 -120
  163. package/lib/quick.js +4 -4
  164. package/lib/{reg-exp-router-DC1R3qoY.js → reg-exp-router-C_WV84eV.js} +2 -2
  165. package/lib/request-DvMgGtlW.js +323 -0
  166. package/lib/request.js +1 -322
  167. package/lib/route-D8m-a2I1.js +126 -0
  168. package/lib/route.js +1 -125
  169. package/lib/router/linear-router.js +1 -1
  170. package/lib/router/pattern-router.js +1 -1
  171. package/lib/router/reg-exp-router.js +1 -1
  172. package/lib/router/smart-router.js +1 -1
  173. package/lib/router/trie-router.js +1 -1
  174. package/lib/router-Be_o6nFu.js +35 -0
  175. package/lib/router.js +1 -34
  176. package/lib/schema-validator-EK3cUUCt.js +22 -0
  177. package/lib/schema-validator.js +1 -21
  178. package/lib/{secure-headers-mP3j6Hm6.js → secure-headers-C5ZOcXqk.js} +1 -1
  179. package/lib/secure-headers.js +1 -1
  180. package/lib/serve-static-B7sqnftW.d.ts +18 -0
  181. package/lib/{serve-static-3uo_9rjF.js → serve-static-C1Nkj_xB.js} +2 -2
  182. package/lib/{serve-static-Cp5adzGo.js → serve-static-EiJf1zkO.js} +4 -4
  183. package/lib/serve-static.js +1 -1
  184. package/lib/{smart-router-C5CZ5XSM.js → smart-router-BjxkDQCE.js} +1 -1
  185. package/lib/{snapshot-text-DmE0YfeZ.js → snapshot-text-Bbx43mN0.js} +57 -9
  186. package/lib/{src-2Z4mJg0x.js → src-BTBm4OPD.js} +22 -6
  187. package/lib/src-LX0E4ec4.js +117 -0
  188. package/lib/{ssg-BwjcA-Ge.js → ssg-BEl7MHqg.js} +5 -5
  189. package/lib/ssg.js +1 -1
  190. package/lib/stream-CzM_SHkq.js +88 -0
  191. package/lib/{streaming-DHST3Scg.js → streaming-BlDaph8U.js} +3 -3
  192. package/lib/streaming.js +1 -1
  193. package/lib/{test-websocket-D8WWqE5G.js → test-websocket-BLeEvybj.js} +2 -2
  194. package/lib/testing-BQx5T_UX.js +17 -0
  195. package/lib/testing.js +1 -16
  196. package/lib/timeout-FeqZ9A-0.js +42 -0
  197. package/lib/timeout.js +1 -41
  198. package/lib/tiny.js +2 -2
  199. package/lib/trailing-slash-DwTx-1sk.js +85 -0
  200. package/lib/trailing-slash.js +1 -84
  201. package/lib/{trie-router-CfFbapzL.js → trie-router-JydLKUa2.js} +2 -2
  202. package/lib/url-BPh4d6j-.js +197 -0
  203. package/lib/utils/accept.js +1 -192
  204. package/lib/utils/basic-auth.js +1 -19
  205. package/lib/utils/body.js +1 -93
  206. package/lib/utils/buffer.js +1 -50
  207. package/lib/utils/color.js +1 -36
  208. package/lib/utils/compress.d.ts +1 -10
  209. package/lib/utils/compress.js +1 -10
  210. package/lib/utils/concurrent.js +1 -29
  211. package/lib/utils/constants.js +1 -6
  212. package/lib/utils/cookie.js +1 -124
  213. package/lib/utils/crypto.js +1 -33
  214. package/lib/utils/encode.js +1 -32
  215. package/lib/utils/handler.js +1 -11
  216. package/lib/utils/html.js +1 -102
  217. package/lib/utils/ipaddr.js +1 -237
  218. package/lib/utils/jwt.js +1 -1
  219. package/lib/utils/mime.js +1 -76
  220. package/lib/utils/stream.js +1 -87
  221. package/lib/utils/url.js +1 -196
  222. package/lib/{validator-D84mq-dO.js → validator-Btiyt5VJ.js} +3 -3
  223. package/lib/validator.js +1 -1
  224. package/lib/websocket-DsyBIKVA.js +56 -0
  225. package/lib/ws.js +1 -55
  226. package/package.json +1 -1
  227. package/plugins/acryl-door/src/cli/acryl.ts +5 -3
  228. package/plugins/acryl-door/src/host/channel.ts +36 -0
  229. package/plugins/acryl-door/src/host/chat-tools.ts +2 -0
  230. package/plugins/acryl-door/src/host/door.ts +44 -5
  231. package/plugins/acryl-door/src/host/shim.ts +23 -0
  232. package/plugins/acryl-door/src/host/verbs.ts +4 -3
  233. package/plugins/acryl-door/src/index.ts +39 -3
  234. package/plugins/acryl-door/src/page/driver/driver.ts +22 -1
  235. package/plugins/acryl-door/src/page/protocol.ts +13 -2
  236. package/plugins/acryl-node-server/src/register.ts +29 -2
  237. package/plugins/acryl-router/src/service.ts +19 -1
  238. package/plugins/agent/model.ts +6 -1
  239. package/plugins/agent/tools.ts +12 -2
  240. package/plugins/agent-panel/client/describe.ts +44 -0
  241. package/plugins/agent-panel/client/main.ts +67 -35
  242. package/plugins/agent-panel/index.ts +137 -35
  243. package/plugins/desktop/attach.ts +72 -0
  244. package/plugins/desktop/main.ts +17 -4
  245. package/plugins/extensions/index.ts +3 -4
  246. package/plugins/extensions/stage.ts +33 -5
  247. package/plugins/openai/index.ts +1 -1
  248. package/shared/DEFAULTS.md +4 -0
  249. package/templates/agent/AGENTS.md +2 -0
  250. package/templates/agent/blend.yaml +4 -1
  251. package/templates/agent/src/app.ts +2 -0
  252. package/templates/agent/src/routes.ts +1 -1
  253. package/templates/agent/template.json +1 -0
  254. package/templates/agent/test/builder.test.ts +26 -21
  255. package/lib/helpers-CvTauQT5.js +0 -5
  256. package/lib/middleware-CPQ8himN.js +0 -12
package/lib/compress.js CHANGED
@@ -1,79 +1,3 @@
1
- import { parseAccept } from "./utils/accept.js";
2
- import { COMPRESSIBLE_CONTENT_TYPE_REGEX } from "./utils/compress.js";
3
- //#region ../../plugins/acryl-router/src/core/middleware/compress/index.ts
4
- const ENCODING_TYPES = ["gzip", "deflate"];
5
- const cacheControlNoTransformRegExp = /(?:^|,)\s*?no-transform\s*?(?:,|$)/i;
6
- const selectEncoding = (header, candidates) => {
7
- if (header === void 0) return;
8
- const accepts = parseAccept(header);
9
- const wildcardQ = accepts.find((a) => a.type === "*")?.q;
10
- let best;
11
- for (const enc of candidates) {
12
- const explicit = accepts.find((a) => a.type.toLowerCase() === enc);
13
- const q = explicit ? explicit.q : wildcardQ ?? 0;
14
- if (q === 1) return enc;
15
- else if (q > 0 && (!best || q > best.q)) best = {
16
- encoding: enc,
17
- q
18
- };
19
- }
20
- return best?.encoding;
21
- };
22
- const varyAcceptEncodingRegExp = /(?:^|,)\s*accept-encoding\s*(?:,|$)/i;
23
- /**
24
- * Compress Middleware for Acryl.
25
- *
26
- *
27
- * @param {CompressionOptions} [options] - The options for the compress middleware.
28
- * @param {'gzip' | 'deflate'} [options.encoding] - The compression scheme to allow for response compression. Either 'gzip' or 'deflate'. If not defined, both are allowed and will be used based on the Accept-Encoding header. 'gzip' is prioritized if this option is not provided and the client provides both in the Accept-Encoding header.
29
- * @param {number} [options.threshold=1024] - The minimum size in bytes to compress. Defaults to 1024 bytes.
30
- * @param {RegExp | Function} [options.contentTypeFilter=COMPRESSIBLE_CONTENT_TYPE_REGEX] - A RegExp or function to determine if the response Content-Type should be compressed.
31
- * @returns {MiddlewareHandler} The middleware handler function.
32
- *
33
- * @example
34
- * ```ts
35
- * const app = new Acryl()
36
- *
37
- * app.use(compress())
38
- *
39
- * // Compress only JSON responses
40
- * app.use(compress({ contentTypeFilter: /^application\/json/ }))
41
- *
42
- * // Compress based on custom Content-Type logic
43
- * app.use(compress({ contentTypeFilter: (type) => COMPRESSIBLE_CONTENT_TYPE_REGEX.test(type) || type === "application/x-myformat" }))
44
- * ```
45
- */
46
- const compress = (options) => {
47
- const threshold = options?.threshold ?? 1024;
48
- const candidates = options?.encoding ? [options.encoding] : ENCODING_TYPES;
49
- const contentTypeFilter = options?.contentTypeFilter ?? COMPRESSIBLE_CONTENT_TYPE_REGEX;
50
- const shouldCompress = typeof contentTypeFilter === "function" ? (res) => {
51
- const type = res.headers.get("Content-Type");
52
- return type && contentTypeFilter(type);
53
- } : (res) => {
54
- const type = res.headers.get("Content-Type");
55
- return type && contentTypeFilter.test(type);
56
- };
57
- return async function compress(ctx, next) {
58
- await next();
59
- const contentLength = ctx.res.headers.get("Content-Length");
60
- if (ctx.res.status === 206 || ctx.res.headers.has("Content-Encoding") || ctx.res.headers.has("Transfer-Encoding") || ctx.req.method === "HEAD" || contentLength && Number(contentLength) < threshold || !shouldCompress(ctx.res) || !shouldTransform(ctx.res)) return;
61
- const current = ctx.res.headers.get("Vary");
62
- if (current !== "*" && !(current && varyAcceptEncodingRegExp.test(current))) ctx.header("Vary", current ? `${current}, Accept-Encoding` : "Accept-Encoding");
63
- const accepted = ctx.req.header("Accept-Encoding");
64
- const encoding = selectEncoding(accepted, candidates);
65
- if (!encoding || !ctx.res.body) return;
66
- const stream = new CompressionStream(encoding);
67
- ctx.res = new Response(ctx.res.body.pipeThrough(stream), ctx.res);
68
- ctx.res.headers.delete("Content-Length");
69
- ctx.res.headers.set("Content-Encoding", encoding);
70
- const etag = ctx.res.headers.get("ETag");
71
- if (etag && !etag.startsWith("W/")) ctx.res.headers.set("ETag", `W/${etag}`);
72
- };
73
- };
74
- const shouldTransform = (res) => {
75
- const cacheControl = res.headers.get("Cache-Control");
76
- return !cacheControl || !cacheControlNoTransformRegExp.test(cacheControl);
77
- };
78
- //#endregion
1
+ import { t as COMPRESSIBLE_CONTENT_TYPE_REGEX } from "./compress-DCyrrQ5D.js";
2
+ import { t as compress } from "./compress-BzWqsHF1.js";
79
3
  export { COMPRESSIBLE_CONTENT_TYPE_REGEX, compress };
@@ -0,0 +1,30 @@
1
+ //#region ../../plugins/acryl-router/src/core/utils/concurrent.ts
2
+ /**
3
+ * @module
4
+ * Concurrent utility.
5
+ */
6
+ const DEFAULT_CONCURRENCY = 1024;
7
+ const createPool = ({ concurrency, interval } = {}) => {
8
+ concurrency ||= DEFAULT_CONCURRENCY;
9
+ if (concurrency === Infinity) return { run: async (fn) => fn() };
10
+ const pool = /* @__PURE__ */ new Set();
11
+ const run = async (fn, promise, resolve) => {
12
+ if (pool.size >= concurrency) {
13
+ promise ||= new Promise((r) => resolve = r);
14
+ setTimeout(() => run(fn, promise, resolve));
15
+ return promise;
16
+ }
17
+ const marker = {};
18
+ pool.add(marker);
19
+ const result = await fn();
20
+ if (interval) setTimeout(() => pool.delete(marker), interval);
21
+ else pool.delete(marker);
22
+ if (resolve) {
23
+ resolve(result);
24
+ return promise;
25
+ } else return result;
26
+ };
27
+ return { run };
28
+ };
29
+ //#endregion
30
+ export { createPool as t };
@@ -0,0 +1,11 @@
1
+ import { r as GetConnInfo } from "./types-Dv_nV2cv.js";
2
+
3
+ //#region ../../plugins/acryl-node-server/src/adapter/conninfo.d.ts
4
+ /**
5
+ * ConnInfo Helper for Node.js
6
+ * @param c Context
7
+ * @returns ConnInfo
8
+ */
9
+ declare const getConnInfo: GetConnInfo;
10
+ //#endregion
11
+ export { getConnInfo as t };
@@ -0,0 +1,19 @@
1
+ //#region ../../plugins/acryl-node-server/src/adapter/conninfo.ts
2
+ /**
3
+ * ConnInfo Helper for Node.js
4
+ * @param c Context
5
+ * @returns ConnInfo
6
+ */
7
+ const getConnInfo = (c) => {
8
+ const bindings = c.env.server ? c.env.server : c.env;
9
+ const address = bindings.incoming.socket.remoteAddress;
10
+ const port = bindings.incoming.socket.remotePort;
11
+ const family = bindings.incoming.socket.remoteFamily;
12
+ return { remote: {
13
+ address,
14
+ port,
15
+ addressType: family === "IPv4" ? "IPv4" : family === "IPv6" ? "IPv6" : void 0
16
+ } };
17
+ };
18
+ //#endregion
19
+ export { getConnInfo as t };
@@ -0,0 +1,7 @@
1
+ //#region ../../plugins/acryl-router/src/core/utils/constants.ts
2
+ /**
3
+ * Constant used to mark a composed handler.
4
+ */
5
+ const COMPOSED_HANDLER = "__COMPOSED_HANDLER";
6
+ //#endregion
7
+ export { COMPOSED_HANDLER as t };
@@ -1,5 +1,5 @@
1
- import { AcrylRequest } from "./request.js";
2
- import { HtmlEscapedCallbackPhase, resolveCallback } from "./utils/html.js";
1
+ import { t as AcrylRequest } from "./request-DvMgGtlW.js";
2
+ import { i as resolveCallback, t as HtmlEscapedCallbackPhase } from "./html-DGExBFNg.js";
3
3
  //#region ../../plugins/acryl-router/src/core/context.ts
4
4
  const TEXT_PLAIN = "text/plain; charset=UTF-8";
5
5
  const setDefaultContentType = (contentType, headers) => {
@@ -0,0 +1,52 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ //#region ../../plugins/acryl-router/src/core/middleware/context-storage/index.ts
3
+ /**
4
+ * @module
5
+ * Context Storage Middleware for Acryl.
6
+ */
7
+ const asyncLocalStorage = new AsyncLocalStorage();
8
+ /**
9
+ * Context Storage Middleware for Acryl.
10
+ *
11
+ *
12
+ * @returns {MiddlewareHandler} The middleware handler function.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * type Env = {
17
+ * Variables: {
18
+ * message: string
19
+ * }
20
+ * }
21
+ *
22
+ * const app = new Acryl<Env>()
23
+ *
24
+ * app.use(contextStorage())
25
+ *
26
+ * app.use(async (c, next) => {
27
+ * c.set('message', 'Acryl is hot!!')
28
+ * await next()
29
+ * })
30
+ *
31
+ * app.get('/', async (c) => c.text(getMessage()))
32
+ *
33
+ * const getMessage = () => {
34
+ * return getContext<Env>().var.message
35
+ * }
36
+ * ```
37
+ */
38
+ const contextStorage = () => {
39
+ return async function contextStorage(c, next) {
40
+ await asyncLocalStorage.run(c, next);
41
+ };
42
+ };
43
+ const tryGetContext = () => {
44
+ return asyncLocalStorage.getStore();
45
+ };
46
+ const getContext = () => {
47
+ const context = tryGetContext();
48
+ if (!context) throw new Error("Context is not available");
49
+ return context;
50
+ };
51
+ //#endregion
52
+ export { getContext as n, tryGetContext as r, contextStorage as t };
@@ -1,52 +1,2 @@
1
- import { AsyncLocalStorage } from "node:async_hooks";
2
- //#region ../../plugins/acryl-router/src/core/middleware/context-storage/index.ts
3
- /**
4
- * @module
5
- * Context Storage Middleware for Acryl.
6
- */
7
- const asyncLocalStorage = new AsyncLocalStorage();
8
- /**
9
- * Context Storage Middleware for Acryl.
10
- *
11
- *
12
- * @returns {MiddlewareHandler} The middleware handler function.
13
- *
14
- * @example
15
- * ```ts
16
- * type Env = {
17
- * Variables: {
18
- * message: string
19
- * }
20
- * }
21
- *
22
- * const app = new Acryl<Env>()
23
- *
24
- * app.use(contextStorage())
25
- *
26
- * app.use(async (c, next) => {
27
- * c.set('message', 'Acryl is hot!!')
28
- * await next()
29
- * })
30
- *
31
- * app.get('/', async (c) => c.text(getMessage()))
32
- *
33
- * const getMessage = () => {
34
- * return getContext<Env>().var.message
35
- * }
36
- * ```
37
- */
38
- const contextStorage = () => {
39
- return async function contextStorage(c, next) {
40
- await asyncLocalStorage.run(c, next);
41
- };
42
- };
43
- const tryGetContext = () => {
44
- return asyncLocalStorage.getStore();
45
- };
46
- const getContext = () => {
47
- const context = tryGetContext();
48
- if (!context) throw new Error("Context is not available");
49
- return context;
50
- };
51
- //#endregion
1
+ import { n as getContext, r as tryGetContext, t as contextStorage } from "./context-storage-iuPoI_CR.js";
52
2
  export { contextStorage, getContext, tryGetContext };
@@ -0,0 +1,125 @@
1
+ import { m as tryDecodeURIComponent } from "./url-BPh4d6j-.js";
2
+ //#region ../../plugins/acryl-router/src/core/utils/cookie.ts
3
+ /**
4
+ * @module
5
+ * Cookie utility.
6
+ */
7
+ const algorithm = {
8
+ name: "HMAC",
9
+ hash: "SHA-256"
10
+ };
11
+ const getCryptoKey = async (secret) => {
12
+ const secretBuf = typeof secret === "string" ? new TextEncoder().encode(secret) : secret;
13
+ return await crypto.subtle.importKey("raw", secretBuf, algorithm, false, ["sign", "verify"]);
14
+ };
15
+ const makeSignature = async (value, secret) => {
16
+ const key = await getCryptoKey(secret);
17
+ const signature = await crypto.subtle.sign(algorithm.name, key, new TextEncoder().encode(value));
18
+ return btoa(String.fromCharCode(...new Uint8Array(signature)));
19
+ };
20
+ const verifySignature = async (base64Signature, value, secret) => {
21
+ try {
22
+ const signatureBinStr = atob(base64Signature);
23
+ const signature = new Uint8Array(signatureBinStr.length);
24
+ for (let i = 0, len = signatureBinStr.length; i < len; i++) signature[i] = signatureBinStr.charCodeAt(i);
25
+ return await crypto.subtle.verify(algorithm, secret, signature, new TextEncoder().encode(value));
26
+ } catch {
27
+ return false;
28
+ }
29
+ };
30
+ const validCookieNameRegEx = /^[\w!#$%&'*.^`|~+-]+$/;
31
+ const relaxedCookieNameRegEx = /^[!#-:<>-[\]-~]+$/;
32
+ const validCookieValueRegEx = /^[ !#-:<-[\]-~]*$/;
33
+ const trimCookieWhitespace = (value) => {
34
+ let start = 0;
35
+ let end = value.length;
36
+ while (start < end) {
37
+ const charCode = value.charCodeAt(start);
38
+ if (charCode !== 32 && charCode !== 9) break;
39
+ start++;
40
+ }
41
+ while (end > start) {
42
+ const charCode = value.charCodeAt(end - 1);
43
+ if (charCode !== 32 && charCode !== 9) break;
44
+ end--;
45
+ }
46
+ return start === 0 && end === value.length ? value : value.slice(start, end);
47
+ };
48
+ const parse = (cookie, name) => {
49
+ if (name && cookie.indexOf(name) === -1) return {};
50
+ const pairs = cookie.split(";");
51
+ const parsedCookie = Object.create(null);
52
+ for (const pairStr of pairs) {
53
+ const valueStartPos = pairStr.indexOf("=");
54
+ if (valueStartPos === -1) continue;
55
+ const cookieName = trimCookieWhitespace(pairStr.substring(0, valueStartPos));
56
+ if (name && name !== cookieName || !relaxedCookieNameRegEx.test(cookieName) || cookieName in parsedCookie) continue;
57
+ let cookieValue = trimCookieWhitespace(pairStr.substring(valueStartPos + 1));
58
+ if (cookieValue.startsWith("\"") && cookieValue.endsWith("\"")) cookieValue = cookieValue.slice(1, -1);
59
+ if (validCookieValueRegEx.test(cookieValue)) {
60
+ parsedCookie[cookieName] = tryDecodeURIComponent(cookieValue);
61
+ if (name) break;
62
+ }
63
+ }
64
+ return parsedCookie;
65
+ };
66
+ const parseSigned = async (cookie, secret, name) => {
67
+ const parsedCookie = Object.create(null);
68
+ const secretKey = await getCryptoKey(secret);
69
+ for (const [key, value] of Object.entries(parse(cookie, name))) {
70
+ const signatureStartPos = value.lastIndexOf(".");
71
+ if (signatureStartPos < 0) continue;
72
+ const signedValue = value.substring(0, signatureStartPos);
73
+ const signature = value.substring(signatureStartPos + 1);
74
+ if (signature.length !== 44 || !signature.endsWith("=")) continue;
75
+ parsedCookie[key] = await verifySignature(signature, signedValue, secretKey) ? signedValue : false;
76
+ }
77
+ return parsedCookie;
78
+ };
79
+ const _serialize = (name, value, opt = {}) => {
80
+ if (!validCookieNameRegEx.test(name)) throw new Error("Invalid cookie name");
81
+ let cookie = `${name}=${value}`;
82
+ if (name.startsWith("__Secure-") && !opt.secure) throw new Error("__Secure- Cookie must have Secure attributes");
83
+ if (name.startsWith("__Host-")) {
84
+ if (!opt.secure) throw new Error("__Host- Cookie must have Secure attributes");
85
+ if (opt.path !== "/") throw new Error("__Host- Cookie must have Path attributes with \"/\"");
86
+ if (opt.domain) throw new Error("__Host- Cookie must not have Domain attributes");
87
+ }
88
+ for (const key of [
89
+ "domain",
90
+ "path",
91
+ "sameSite",
92
+ "priority"
93
+ ]) if (opt[key] && /[;\r\n]/.test(opt[key])) throw new Error(`${key} must not contain ";", "\\r", or "\\n"`);
94
+ if (opt && typeof opt.maxAge === "number" && opt.maxAge >= 0) {
95
+ if (opt.maxAge > 3456e4) throw new Error("Cookies Max-Age SHOULD NOT be greater than 400 days (34560000 seconds) in duration.");
96
+ cookie += `; Max-Age=${opt.maxAge | 0}`;
97
+ }
98
+ if (opt.domain && opt.prefix !== "host") cookie += `; Domain=${opt.domain}`;
99
+ if (opt.path) cookie += `; Path=${opt.path}`;
100
+ if (opt.expires) {
101
+ if (opt.expires.getTime() - Date.now() > 3456e7) throw new Error("Cookies Expires SHOULD NOT be greater than 400 days (34560000 seconds) in the future.");
102
+ cookie += `; Expires=${opt.expires.toUTCString()}`;
103
+ }
104
+ if (opt.httpOnly) cookie += "; HttpOnly";
105
+ if (opt.secure) cookie += "; Secure";
106
+ if (opt.sameSite) cookie += `; SameSite=${opt.sameSite.charAt(0).toUpperCase() + opt.sameSite.slice(1)}`;
107
+ if (opt.priority) cookie += `; Priority=${opt.priority.charAt(0).toUpperCase() + opt.priority.slice(1)}`;
108
+ if (opt.partitioned) {
109
+ if (!opt.secure) throw new Error("Partitioned Cookie must have Secure attributes");
110
+ cookie += "; Partitioned";
111
+ }
112
+ return cookie;
113
+ };
114
+ const serialize = (name, value, opt) => {
115
+ value = encodeURIComponent(value);
116
+ return _serialize(name, value, opt);
117
+ };
118
+ const serializeSigned = async (name, value, secret, opt = {}) => {
119
+ const signature = await makeSignature(value, secret);
120
+ value = `${value}.${signature}`;
121
+ value = encodeURIComponent(value);
122
+ return _serialize(name, value, opt);
123
+ };
124
+ //#endregion
125
+ export { serializeSigned as i, parseSigned as n, serialize as r, parse as t };
@@ -0,0 +1,82 @@
1
+ import { i as serializeSigned, n as parseSigned, r as serialize, t as parse } from "./cookie-B1LlkzOe.js";
2
+ //#region ../../plugins/acryl-router/src/core/helper/cookie/index.ts
3
+ const getCookie = (c, key, prefix) => {
4
+ const cookie = c.req.raw.headers.get("Cookie");
5
+ if (typeof key === "string") {
6
+ if (!cookie) return;
7
+ let finalKey = key;
8
+ if (prefix === "secure") finalKey = "__Secure-" + key;
9
+ else if (prefix === "host") finalKey = "__Host-" + key;
10
+ return parse(cookie, finalKey)[finalKey];
11
+ }
12
+ if (!cookie) return {};
13
+ return parse(cookie);
14
+ };
15
+ const getSignedCookie = async (c, secret, key, prefix) => {
16
+ const cookie = c.req.raw.headers.get("Cookie");
17
+ if (typeof key === "string") {
18
+ if (!cookie) return;
19
+ let finalKey = key;
20
+ if (prefix === "secure") finalKey = "__Secure-" + key;
21
+ else if (prefix === "host") finalKey = "__Host-" + key;
22
+ return (await parseSigned(cookie, secret, finalKey))[finalKey];
23
+ }
24
+ if (!cookie) return {};
25
+ return await parseSigned(cookie, secret);
26
+ };
27
+ const generateCookie = (name, value, opt) => {
28
+ let cookie;
29
+ if (opt?.prefix === "secure") cookie = serialize("__Secure-" + name, value, {
30
+ path: "/",
31
+ ...opt,
32
+ secure: true
33
+ });
34
+ else if (opt?.prefix === "host") cookie = serialize("__Host-" + name, value, {
35
+ ...opt,
36
+ path: "/",
37
+ secure: true,
38
+ domain: void 0
39
+ });
40
+ else cookie = serialize(name, value, {
41
+ path: "/",
42
+ ...opt
43
+ });
44
+ return cookie;
45
+ };
46
+ const setCookie = (c, name, value, opt) => {
47
+ const cookie = generateCookie(name, value, opt);
48
+ c.header("Set-Cookie", cookie, { append: true });
49
+ };
50
+ const generateSignedCookie = async (name, value, secret, opt) => {
51
+ let cookie;
52
+ if (opt?.prefix === "secure") cookie = await serializeSigned("__Secure-" + name, value, secret, {
53
+ path: "/",
54
+ ...opt,
55
+ secure: true
56
+ });
57
+ else if (opt?.prefix === "host") cookie = await serializeSigned("__Host-" + name, value, secret, {
58
+ ...opt,
59
+ path: "/",
60
+ secure: true,
61
+ domain: void 0
62
+ });
63
+ else cookie = await serializeSigned(name, value, secret, {
64
+ path: "/",
65
+ ...opt
66
+ });
67
+ return cookie;
68
+ };
69
+ const setSignedCookie = async (c, name, value, secret, opt) => {
70
+ const cookie = await generateSignedCookie(name, value, secret, opt);
71
+ c.header("set-cookie", cookie, { append: true });
72
+ };
73
+ const deleteCookie = (c, name, opt) => {
74
+ const deletedCookie = getCookie(c, name, opt?.prefix);
75
+ setCookie(c, name, "", {
76
+ ...opt,
77
+ maxAge: 0
78
+ });
79
+ return deletedCookie;
80
+ };
81
+ //#endregion
82
+ export { getSignedCookie as a, getCookie as i, generateCookie as n, setCookie as o, generateSignedCookie as r, setSignedCookie as s, deleteCookie as t };
package/lib/cookie.js CHANGED
@@ -1,82 +1,2 @@
1
- import { parse, parseSigned, serialize, serializeSigned } from "./utils/cookie.js";
2
- //#region ../../plugins/acryl-router/src/core/helper/cookie/index.ts
3
- const getCookie = (c, key, prefix) => {
4
- const cookie = c.req.raw.headers.get("Cookie");
5
- if (typeof key === "string") {
6
- if (!cookie) return;
7
- let finalKey = key;
8
- if (prefix === "secure") finalKey = "__Secure-" + key;
9
- else if (prefix === "host") finalKey = "__Host-" + key;
10
- return parse(cookie, finalKey)[finalKey];
11
- }
12
- if (!cookie) return {};
13
- return parse(cookie);
14
- };
15
- const getSignedCookie = async (c, secret, key, prefix) => {
16
- const cookie = c.req.raw.headers.get("Cookie");
17
- if (typeof key === "string") {
18
- if (!cookie) return;
19
- let finalKey = key;
20
- if (prefix === "secure") finalKey = "__Secure-" + key;
21
- else if (prefix === "host") finalKey = "__Host-" + key;
22
- return (await parseSigned(cookie, secret, finalKey))[finalKey];
23
- }
24
- if (!cookie) return {};
25
- return await parseSigned(cookie, secret);
26
- };
27
- const generateCookie = (name, value, opt) => {
28
- let cookie;
29
- if (opt?.prefix === "secure") cookie = serialize("__Secure-" + name, value, {
30
- path: "/",
31
- ...opt,
32
- secure: true
33
- });
34
- else if (opt?.prefix === "host") cookie = serialize("__Host-" + name, value, {
35
- ...opt,
36
- path: "/",
37
- secure: true,
38
- domain: void 0
39
- });
40
- else cookie = serialize(name, value, {
41
- path: "/",
42
- ...opt
43
- });
44
- return cookie;
45
- };
46
- const setCookie = (c, name, value, opt) => {
47
- const cookie = generateCookie(name, value, opt);
48
- c.header("Set-Cookie", cookie, { append: true });
49
- };
50
- const generateSignedCookie = async (name, value, secret, opt) => {
51
- let cookie;
52
- if (opt?.prefix === "secure") cookie = await serializeSigned("__Secure-" + name, value, secret, {
53
- path: "/",
54
- ...opt,
55
- secure: true
56
- });
57
- else if (opt?.prefix === "host") cookie = await serializeSigned("__Host-" + name, value, secret, {
58
- ...opt,
59
- path: "/",
60
- secure: true,
61
- domain: void 0
62
- });
63
- else cookie = await serializeSigned(name, value, secret, {
64
- path: "/",
65
- ...opt
66
- });
67
- return cookie;
68
- };
69
- const setSignedCookie = async (c, name, value, secret, opt) => {
70
- const cookie = await generateSignedCookie(name, value, secret, opt);
71
- c.header("set-cookie", cookie, { append: true });
72
- };
73
- const deleteCookie = (c, name, opt) => {
74
- const deletedCookie = getCookie(c, name, opt?.prefix);
75
- setCookie(c, name, "", {
76
- ...opt,
77
- maxAge: 0
78
- });
79
- return deletedCookie;
80
- };
81
- //#endregion
1
+ import { a as getSignedCookie, i as getCookie, n as generateCookie, o as setCookie, r as generateSignedCookie, s as setSignedCookie, t as deleteCookie } from "./cookie-BHIduy2T.js";
82
2
  export { deleteCookie, generateCookie, generateSignedCookie, getCookie, getSignedCookie, setCookie, setSignedCookie };
@@ -1,5 +1,5 @@
1
1
  import { n as DbExecutor, r as SqlValue, t as Db } from "../database-DBHdwefi.js";
2
- import { OpenDb, OpenDbOptions, openDb } from "../db/sqlite.js";
2
+ import { n as OpenDbOptions, r as openDb, t as OpenDb } from "../open-T7kgbO2O.js";
3
3
  import { DatabaseSync, StatementSync } from "node:sqlite";
4
4
  import { Context } from "@deepseek-ai/cordis";
5
5
  import z from "@deepseek-ai/schemastery";
@@ -1,5 +1,5 @@
1
- import { d as UiActionResult, v as UiSnapshot } from "../protocol-BizVt4J6.js";
2
- import { i as UiChannel, t as AuditLog } from "../audit-BXnYsLge.js";
1
+ import { f as UiActionResult, y as UiSnapshot } from "../protocol-C37gPePD.js";
2
+ import { i as UiChannel, t as AuditLog } from "../audit-D5z9uwOP.js";
3
3
  import { Context } from "@deepseek-ai/cordis";
4
4
  import z from "@deepseek-ai/schemastery";
5
5
 
@@ -21,6 +21,7 @@ interface ToolsPort {
21
21
  /** @returns the function that removes the tool. @throws when the name is taken. */
22
22
  register(name: string, tool: {
23
23
  readonly description: string;
24
+ readonly parameters?: Readonly<Record<string, unknown>>;
24
25
  run(input: unknown): unknown;
25
26
  }): () => void;
26
27
  list(): ReadonlyArray<{
@@ -43,6 +44,10 @@ interface DoorDeps {
43
44
  readonly tools: () => ToolsPort | undefined;
44
45
  /** The app tools the door offers; anything else is refused before it reaches the registry. */
45
46
  readonly expose: readonly string[];
47
+ /** Reload the open pages after a plugin was added, removed or reloaded, so the page an agent looks at next is the new one. Default: true. */
48
+ readonly reloadOnChange?: boolean;
49
+ /** How long a reload or a move may take before the new page has connected again (tests shorten it). Default 15 s. */
50
+ readonly pageBackMs?: number;
46
51
  }
47
52
  /** What one verb answered: the value for `--json` and programs, the text for an agent reading a terminal. */
48
53
  interface VerbAnswer {
@@ -57,6 +62,11 @@ declare class Door {
57
62
  brief(): VerbAnswer;
58
63
  look(input: Record<string, unknown>, signal: AbortSignal): Promise<UiSnapshot>;
59
64
  act(input: Record<string, unknown>, signal: AbortSignal): Promise<UiActionResult>;
65
+ /**
66
+ * What the app answers at a path the page was sent to, so an agent that mistyped one is told ("404 at /nope") and not left to find out from a page it did not expect.
67
+ * A second GET of the same path (a page is read-only); nothing when the app has no address or does not answer in time.
68
+ */
69
+ private statusAt;
60
70
  private parse;
61
71
  /** Run one call on the page and record it. The audit holds which control was touched and how it ended, never what was typed. */
62
72
  private callPage;
@@ -158,8 +168,12 @@ interface Config {
158
168
  * run it in production (a packaged desktop app whose user drives it with an agent) says so here; `ACRYL_DOOR=off` still wins.
159
169
  */
160
170
  allowInProduction?: boolean;
171
+ /** Reload the open pages after a live plugin change, so an agent that built a feature sees it on the page it has open. Default: true. */
172
+ reloadOnChange?: boolean;
161
173
  }
162
174
  declare const Config: z<Config>;
175
+ /** The page of a path the app does not serve, development only: what is missing, a way back, and the door's script. */
176
+ declare function notFoundPage(path: string, scriptTag: string): string;
163
177
  declare function apply(ctx: Context, rawConfig?: Config): void;
164
178
  //#endregion
165
- export { type CallResponse, Config, DOOR_PREFIX, Door, DoorError, type DoorFile, STATE_DIR, VERBS, VERB_SPECS, type Verb, type VerbAnswer, type VerbSpec, apply, chatToolName, doorFilePath, inject, mcpTools, name, readDoorFile };
179
+ export { type CallResponse, Config, DOOR_PREFIX, Door, DoorError, type DoorFile, STATE_DIR, VERBS, VERB_SPECS, type Verb, type VerbAnswer, type VerbSpec, apply, chatToolName, doorFilePath, inject, mcpTools, name, notFoundPage, readDoorFile };