acrylblends 1.0.4 → 1.0.6
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.
- package/docs/framework/agents/index.md +7 -5
- package/lib/accept-CNNHu4Cf.js +193 -0
- package/lib/{accepts-XBuZPVRI.js → accepts-Btq83xPd.js} +1 -1
- package/lib/accepts.js +1 -1
- package/lib/acryl-base.js +1 -331
- package/lib/adapter-CaZ6FZUU.js +37 -0
- package/lib/adapter.js +1 -36
- package/lib/{app-BM0rTCp7.js → app-CQcGWjrk.js} +4 -4
- package/lib/app-base-CpRMZL4v.js +332 -0
- package/lib/{audit-D5z9uwOP.d.ts → audit-GcLtvNLV.d.ts} +4 -2
- package/lib/{base-NSN_SNv-.js → base-D_6kfOr-.js} +1 -1
- package/lib/basic-auth-C0HTRpXh.js +20 -0
- package/lib/basic-auth-DFLflXNe.js +95 -0
- package/lib/basic-auth.js +1 -94
- package/lib/bearer-auth-Cwxt-vgS.js +94 -0
- package/lib/bearer-auth.js +1 -93
- package/lib/body-D7f4e7w_.js +94 -0
- package/lib/body-limit-WmIjWRLt.js +66 -0
- package/lib/body-limit.js +1 -65
- package/lib/buffer-CkEOJCcY.js +51 -0
- package/lib/bun.js +3 -3
- package/lib/cache-B0bHH7s5.js +169 -0
- package/lib/cache.js +1 -168
- package/lib/{client-DDLXwhBo.js → client-BrMFnMEd.js} +1 -1
- package/lib/{client-modules-CLvWOjbd.js → client-modules-drj4mjhj.js} +4 -4
- package/lib/client.js +1 -1
- package/lib/color-COa3DplO.js +37 -0
- package/lib/combine-TWuGdcbC.js +137 -0
- package/lib/combine.js +1 -136
- package/lib/{components-cEW3ovK0.js → components-B2ka9Ax1.js} +4 -4
- package/lib/{components-JXVm45kK.js → components-PVXwaOaC.js} +2 -2
- package/lib/compress-BzWqsHF1.js +79 -0
- package/lib/compress-C-9vK4B2.d.ts +11 -0
- package/lib/compress-DCyrrQ5D.js +11 -0
- package/lib/compress.d.ts +1 -1
- package/lib/compress.js +2 -78
- package/lib/concurrent-DrF3d2c-.js +30 -0
- package/lib/conninfo-BCROmdnf.d.ts +11 -0
- package/lib/conninfo-CWJwieh4.js +19 -0
- package/lib/constants-CBSEudrb.js +7 -0
- package/lib/{context-DDO0cfuP.js → context-CkOh7Ygv.js} +2 -2
- package/lib/context-storage-iuPoI_CR.js +52 -0
- package/lib/context-storage.js +1 -51
- package/lib/cookie-B1LlkzOe.js +125 -0
- package/lib/cookie-BHIduy2T.js +82 -0
- package/lib/cookie.js +1 -81
- package/lib/cordis/db-sqlite.d.ts +1 -1
- package/lib/cordis/door.d.ts +99 -5
- package/lib/cordis/door.js +562 -20
- package/lib/cordis/inspect.js +4 -4
- package/lib/cordis/kv-db.d.ts +1 -1
- package/lib/cordis/kv-db.js +1 -1
- package/lib/cordis/kv-json.d.ts +1 -1
- package/lib/cordis/kv-json.js +1 -1
- package/lib/cordis/node-server.d.ts +1 -1
- package/lib/cordis/node-server.js +3 -116
- package/lib/cordis/router-http.js +2 -2
- package/lib/cordis/router.js +4 -4
- package/lib/cordis/state.js +7 -7
- package/lib/{core-CaY8XDZ6.js → core-BOu1jYua.js} +1 -1
- package/lib/cors-CbAQ-8qU.js +106 -0
- package/lib/cors.js +1 -105
- package/lib/crypto-iVP-N-tS.js +34 -0
- package/lib/csrf-DqqOZtgy.js +101 -0
- package/lib/csrf.js +1 -100
- package/lib/css-C5CPVMvM.js +134 -0
- package/lib/css.js +2 -133
- package/lib/db/sqlite.d.ts +1 -25
- package/lib/dev-CLgu-JRe.js +50 -0
- package/lib/dev.js +1 -49
- package/lib/dom-YjND9Jt3.js +74 -0
- package/lib/door/host.d.ts +2 -2
- package/lib/door/host.js +1 -1
- package/lib/door/page.d.ts +3 -1
- package/lib/door/page.js +2 -2
- package/lib/door/protocol.d.ts +1 -1
- package/lib/door/protocol.js +1 -212
- package/lib/encode-BhbNLrjp.js +33 -0
- package/lib/factory-CLdSf-xS.js +30 -0
- package/lib/factory.js +1 -29
- package/lib/handler-C0wZ0KwO.js +12 -0
- package/lib/helpers-BEjcdbgw.js +5 -0
- package/lib/{hooks-w72iLeFR.js → hooks-CfC07ri0.js} +1 -1
- package/lib/html-CgNa89xw.js +31 -0
- package/lib/html-DGExBFNg.js +103 -0
- package/lib/html.d.ts +2 -5
- package/lib/html.js +2 -30
- package/lib/http-exception-MjWkT89V.js +54 -0
- package/lib/http-exception.js +1 -53
- package/lib/index-dAzQsJG9.d.ts +6 -0
- package/lib/index.js +3 -3
- package/lib/ip-restriction-jKtKCRM_.js +166 -0
- package/lib/ip-restriction.js +1 -165
- package/lib/ipaddr-DCoIo528.js +238 -0
- package/lib/jsx/dom/client.js +1 -1
- package/lib/jsx/dom/jsx-dev-runtime.js +1 -1
- package/lib/jsx/dom/jsx-runtime.js +2 -1
- package/lib/jsx/dom/server.js +3 -3
- package/lib/jsx/dom.js +5 -73
- package/lib/jsx/jsx-dev-runtime.d.ts +2 -5
- package/lib/jsx/jsx-dev-runtime.js +2 -13
- package/lib/jsx/jsx-runtime.d.ts +2 -2
- package/lib/jsx/jsx-runtime.js +4 -4
- package/lib/jsx/streaming.js +1 -1
- package/lib/jsx-CUQgttxU.js +47 -0
- package/lib/jsx-dev-runtime-B4WTyq8r.js +14 -0
- package/lib/{jsx-dev-runtime-CWLRA2F3.js → jsx-dev-runtime-BLfA-EhI.js} +2 -2
- package/lib/jsx-dev-runtime-CGt4kNYr.d.ts +6 -0
- package/lib/jsx-renderer-CfifM4hT.js +99 -0
- package/lib/jsx-renderer.js +1 -98
- package/lib/jsx-runtime-COCRWBJ9.js +2 -0
- package/lib/jsx.js +5 -46
- package/lib/{jwk-LkzeoaU8.js → jwk-CDPpYQpD.js} +3 -3
- package/lib/jwk.js +1 -1
- package/lib/{jwt-BGJBw5AF.js → jwt-BXoIA2fQ.js} +2 -2
- package/lib/{jwt-CskdhEW9.js → jwt-lyS4Q3mT.js} +3 -3
- package/lib/jwt.js +2 -2
- package/lib/kv/db.d.ts +1 -10
- package/lib/kv/db.js +1 -56
- package/lib/kv/json.d.ts +1 -9
- package/lib/kv/json.js +1 -223
- package/lib/{language-D9a4zqvn.js → language-DeGRtLJt.js} +2 -2
- package/lib/language.js +1 -1
- package/lib/{linear-router-C3FPib6h.js → linear-router-CmZn_JLV.js} +2 -2
- package/lib/logger-Ckxu8diz.js +54 -0
- package/lib/logger.js +1 -53
- package/lib/loopback-only-BbasoF7R.js +90 -0
- package/lib/loopback-only.js +1 -89
- package/lib/method-not-allowed-TO2_hnfl.js +82 -0
- package/lib/method-not-allowed.js +1 -81
- package/lib/method-override-DnZKfJbV.js +103 -0
- package/lib/method-override.js +1 -102
- package/lib/middleware-BfG_fp8P.js +12 -0
- package/lib/mime-BnScXkQn.js +77 -0
- package/lib/mount-QkK_3NtJ.js +67 -0
- package/lib/mount.js +1 -66
- package/lib/node-server/conninfo.d.ts +1 -10
- package/lib/node-server/conninfo.js +1 -18
- package/lib/node-server/register.js +25 -2
- package/lib/node-server/serve-static.d.ts +1 -17
- package/lib/node-server/serve-static.js +1 -1
- package/lib/node-server.d.ts +2 -2
- package/lib/node-server.js +4 -4
- package/lib/open-BqK4D2Wn.d.ts +11 -0
- package/lib/open-But9E2rL.js +57 -0
- package/lib/open-CULVJgOc.d.ts +12 -0
- package/lib/open-Dp4sxspc.js +224 -0
- package/lib/open-T7kgbO2O.d.ts +27 -0
- package/lib/{pattern-router-HZxjDGEQ.js → pattern-router-CJBecJBd.js} +1 -1
- package/lib/powered-by-CXQNjNIX.js +24 -0
- package/lib/powered-by.js +1 -23
- package/lib/pretty-json-CeC1yvYt.js +39 -0
- package/lib/pretty-json.js +1 -38
- package/lib/{protocol-C37gPePD.d.ts → protocol-CR31M7K_.d.ts} +2 -0
- package/lib/protocol-Dt0AZBOz.js +213 -0
- package/lib/proxy-C2w_mH7k.js +121 -0
- package/lib/proxy.js +1 -120
- package/lib/quick.js +4 -4
- package/lib/{reg-exp-router-DC1R3qoY.js → reg-exp-router-C_WV84eV.js} +2 -2
- package/lib/request-DvMgGtlW.js +323 -0
- package/lib/request.js +1 -322
- package/lib/route-D8m-a2I1.js +126 -0
- package/lib/route.js +1 -125
- package/lib/router/linear-router.js +1 -1
- package/lib/router/pattern-router.js +1 -1
- package/lib/router/reg-exp-router.js +1 -1
- package/lib/router/smart-router.js +1 -1
- package/lib/router/trie-router.js +1 -1
- package/lib/router-Be_o6nFu.js +35 -0
- package/lib/router.js +1 -34
- package/lib/schema-validator-EK3cUUCt.js +22 -0
- package/lib/schema-validator.js +1 -21
- package/lib/{secure-headers-mP3j6Hm6.js → secure-headers-C5ZOcXqk.js} +1 -1
- package/lib/secure-headers.js +1 -1
- package/lib/serve-static-B7sqnftW.d.ts +18 -0
- package/lib/{serve-static-3uo_9rjF.js → serve-static-C1Nkj_xB.js} +2 -2
- package/lib/{serve-static-Cp5adzGo.js → serve-static-EiJf1zkO.js} +4 -4
- package/lib/serve-static.js +1 -1
- package/lib/{smart-router-C5CZ5XSM.js → smart-router-BjxkDQCE.js} +1 -1
- package/lib/{snapshot-text-BLz8nlSc.js → snapshot-text-CtQm3n8n.js} +23 -14
- package/lib/{src-dy3Fk9tA.js → src-BTBm4OPD.js} +6 -6
- package/lib/src-LX0E4ec4.js +117 -0
- package/lib/{ssg-BwjcA-Ge.js → ssg-BEl7MHqg.js} +5 -5
- package/lib/ssg.js +1 -1
- package/lib/stream-CzM_SHkq.js +88 -0
- package/lib/{streaming-DHST3Scg.js → streaming-BlDaph8U.js} +3 -3
- package/lib/streaming.js +1 -1
- package/lib/{test-websocket-D8WWqE5G.js → test-websocket-BLeEvybj.js} +2 -2
- package/lib/testing-BQx5T_UX.js +17 -0
- package/lib/testing.js +1 -16
- package/lib/timeout-FeqZ9A-0.js +42 -0
- package/lib/timeout.js +1 -41
- package/lib/tiny.js +2 -2
- package/lib/trailing-slash-DwTx-1sk.js +85 -0
- package/lib/trailing-slash.js +1 -84
- package/lib/{trie-router-CfFbapzL.js → trie-router-JydLKUa2.js} +2 -2
- package/lib/url-BPh4d6j-.js +197 -0
- package/lib/utils/accept.js +1 -192
- package/lib/utils/basic-auth.js +1 -19
- package/lib/utils/body.js +1 -93
- package/lib/utils/buffer.js +1 -50
- package/lib/utils/color.js +1 -36
- package/lib/utils/compress.d.ts +1 -10
- package/lib/utils/compress.js +1 -10
- package/lib/utils/concurrent.js +1 -29
- package/lib/utils/constants.js +1 -6
- package/lib/utils/cookie.js +1 -124
- package/lib/utils/crypto.js +1 -33
- package/lib/utils/encode.js +1 -32
- package/lib/utils/handler.js +1 -11
- package/lib/utils/html.js +1 -102
- package/lib/utils/ipaddr.js +1 -237
- package/lib/utils/jwt.js +1 -1
- package/lib/utils/mime.js +1 -76
- package/lib/utils/stream.js +1 -87
- package/lib/utils/url.js +1 -196
- package/lib/{validator-D84mq-dO.js → validator-Btiyt5VJ.js} +3 -3
- package/lib/validator.js +1 -1
- package/lib/websocket-DsyBIKVA.js +56 -0
- package/lib/ws.js +1 -55
- package/package.json +1 -1
- package/plugins/acryl-door/src/cli/acryl.ts +36 -5
- package/plugins/acryl-door/src/host/channel.ts +14 -6
- package/plugins/acryl-door/src/host/chat-tools.ts +2 -0
- package/plugins/acryl-door/src/host/door.ts +97 -12
- package/plugins/acryl-door/src/host/page-routes.ts +3 -1
- package/plugins/acryl-door/src/host/shell.ts +147 -0
- package/plugins/acryl-door/src/host/shim.ts +39 -3
- package/plugins/acryl-door/src/host/verbs.ts +39 -2
- package/plugins/acryl-door/src/index.ts +22 -3
- package/plugins/acryl-door/src/page/channel.ts +3 -1
- package/plugins/acryl-door/src/page/index.ts +2 -1
- package/plugins/acryl-door/src/page/protocol.ts +2 -0
- package/plugins/acryl-door/src/shell/protocol.ts +130 -0
- package/plugins/acryl-node-server/src/register.ts +29 -2
- package/plugins/agent/model.ts +6 -1
- package/plugins/agent/tools.ts +12 -2
- package/plugins/agent-panel/client/describe.ts +44 -0
- package/plugins/agent-panel/client/main.ts +4 -1
- package/plugins/agent-panel/headless.ts +29 -8
- package/plugins/agent-panel/index.ts +22 -10
- package/plugins/agent-panel/launch.ts +67 -0
- package/plugins/desktop/attach.ts +72 -0
- package/plugins/desktop/door-shell.ts +379 -0
- package/plugins/desktop/main.ts +82 -15
- package/plugins/extensions/index.ts +3 -4
- package/plugins/extensions/stage.ts +33 -5
- package/plugins/openai/index.ts +1 -1
- package/templates/agent/AGENTS.md +4 -0
- package/templates/agent/blend.yaml +4 -1
- package/templates/agent/src/app.ts +2 -0
- package/templates/agent/src/routes.ts +1 -1
- package/templates/agent/template.json +1 -0
- package/templates/agent/test/builder.test.ts +26 -21
- package/lib/helpers-CvTauQT5.js +0 -5
- package/lib/middleware-CPQ8himN.js +0 -12
- package/plugins/acryl-router/src/connection.d.ts +0 -25
- package/plugins/acryl-router/src/core/app-base.d.ts +0 -215
- package/plugins/acryl-router/src/core/app.d.ts +0 -19
- package/plugins/acryl-router/src/core/client/client.d.ts +0 -4
- package/plugins/acryl-router/src/core/client/fetch-result-please.d.ts +0 -35
- package/plugins/acryl-router/src/core/client/index.d.ts +0 -7
- package/plugins/acryl-router/src/core/client/types.d.ts +0 -229
- package/plugins/acryl-router/src/core/client/utils.d.ts +0 -18
- package/plugins/acryl-router/src/core/compose.d.ts +0 -14
- package/plugins/acryl-router/src/core/context.d.ts +0 -443
- package/plugins/acryl-router/src/core/helper/accepts/accepts.d.ts +0 -30
- package/plugins/acryl-router/src/core/helper/accepts/index.d.ts +0 -5
- package/plugins/acryl-router/src/core/helper/conninfo/index.d.ts +0 -5
- package/plugins/acryl-router/src/core/helper/conninfo/types.d.ts +0 -36
- package/plugins/acryl-router/src/core/helper/cookie/index.d.ts +0 -25
- package/plugins/acryl-router/src/core/helper/css/common.d.ts +0 -59
- package/plugins/acryl-router/src/core/helper/css/index.d.ts +0 -80
- package/plugins/acryl-router/src/core/helper/dev/index.d.ts +0 -20
- package/plugins/acryl-router/src/core/helper/factory/index.d.ts +0 -82
- package/plugins/acryl-router/src/core/helper/html/index.d.ts +0 -8
- package/plugins/acryl-router/src/core/helper/proxy/index.d.ts +0 -73
- package/plugins/acryl-router/src/core/helper/route/index.d.ts +0 -75
- package/plugins/acryl-router/src/core/helper/ssg/index.d.ts +0 -7
- package/plugins/acryl-router/src/core/helper/ssg/middleware.d.ts +0 -44
- package/plugins/acryl-router/src/core/helper/ssg/plugins.d.ts +0 -27
- package/plugins/acryl-router/src/core/helper/ssg/ssg.d.ts +0 -91
- package/plugins/acryl-router/src/core/helper/ssg/utils.d.ts +0 -16
- package/plugins/acryl-router/src/core/helper/streaming/index.d.ts +0 -8
- package/plugins/acryl-router/src/core/helper/streaming/sse.d.ts +0 -13
- package/plugins/acryl-router/src/core/helper/streaming/stream.d.ts +0 -3
- package/plugins/acryl-router/src/core/helper/streaming/text.d.ts +0 -3
- package/plugins/acryl-router/src/core/helper/streaming/utils.d.ts +0 -1
- package/plugins/acryl-router/src/core/helper/testing/index.d.ts +0 -13
- package/plugins/acryl-router/src/core/helper/websocket/index.d.ts +0 -70
- package/plugins/acryl-router/src/core/http-exception.d.ts +0 -58
- package/plugins/acryl-router/src/core/index.d.ts +0 -37
- package/plugins/acryl-router/src/core/jsx/base.d.ts +0 -61
- package/plugins/acryl-router/src/core/jsx/children.d.ts +0 -9
- package/plugins/acryl-router/src/core/jsx/components.d.ts +0 -15
- package/plugins/acryl-router/src/core/jsx/constants.d.ts +0 -6
- package/plugins/acryl-router/src/core/jsx/context.d.ts +0 -51
- package/plugins/acryl-router/src/core/jsx/dom/components.d.ts +0 -10
- package/plugins/acryl-router/src/core/jsx/dom/context.d.ts +0 -3
- package/plugins/acryl-router/src/core/jsx/dom/css.d.ts +0 -83
- package/plugins/acryl-router/src/core/jsx/dom/hooks/index.d.ts +0 -39
- package/plugins/acryl-router/src/core/jsx/dom/intrinsic-element/components.d.ts +0 -16
- package/plugins/acryl-router/src/core/jsx/dom/jsx-dev-runtime.d.ts +0 -8
- package/plugins/acryl-router/src/core/jsx/dom/jsx-runtime.d.ts +0 -7
- package/plugins/acryl-router/src/core/jsx/dom/render.d.ts +0 -73
- package/plugins/acryl-router/src/core/jsx/dom/utils.d.ts +0 -1
- package/plugins/acryl-router/src/core/jsx/hooks/index.d.ts +0 -47
- package/plugins/acryl-router/src/core/jsx/index.d.ts +0 -76
- package/plugins/acryl-router/src/core/jsx/intrinsic-element/common.d.ts +0 -6
- package/plugins/acryl-router/src/core/jsx/intrinsic-element/components.d.ts +0 -13
- package/plugins/acryl-router/src/core/jsx/intrinsic-elements.d.ts +0 -735
- package/plugins/acryl-router/src/core/jsx/streaming.d.ts +0 -36
- package/plugins/acryl-router/src/core/jsx/types.d.ts +0 -36
- package/plugins/acryl-router/src/core/jsx/utils.d.ts +0 -4
- package/plugins/acryl-router/src/core/request/constants.d.ts +0 -1
- package/plugins/acryl-router/src/core/request.d.ts +0 -306
- package/plugins/acryl-router/src/core/router/reg-exp-router/index.d.ts +0 -6
- package/plugins/acryl-router/src/core/router/reg-exp-router/matcher.d.ts +0 -7
- package/plugins/acryl-router/src/core/router/reg-exp-router/node.d.ts +0 -13
- package/plugins/acryl-router/src/core/router/reg-exp-router/prepared-router.d.ts +0 -17
- package/plugins/acryl-router/src/core/router/reg-exp-router/router.d.ts +0 -11
- package/plugins/acryl-router/src/core/router/reg-exp-router/trie.d.ts +0 -8
- package/plugins/acryl-router/src/core/router/smart-router/index.d.ts +0 -5
- package/plugins/acryl-router/src/core/router/smart-router/router.d.ts +0 -11
- package/plugins/acryl-router/src/core/router/trie-router/index.d.ts +0 -5
- package/plugins/acryl-router/src/core/router/trie-router/node.d.ts +0 -6
- package/plugins/acryl-router/src/core/router/trie-router/router.d.ts +0 -7
- package/plugins/acryl-router/src/core/router/utils.d.ts +0 -1
- package/plugins/acryl-router/src/core/router.d.ts +0 -97
- package/plugins/acryl-router/src/core/types.d.ts +0 -573
- package/plugins/acryl-router/src/core/utils/accept.d.ts +0 -6
- package/plugins/acryl-router/src/core/utils/body.d.ts +0 -79
- package/plugins/acryl-router/src/core/utils/buffer.d.ts +0 -17
- package/plugins/acryl-router/src/core/utils/color.d.ts +0 -21
- package/plugins/acryl-router/src/core/utils/concurrent.d.ts +0 -11
- package/plugins/acryl-router/src/core/utils/constants.d.ts +0 -4
- package/plugins/acryl-router/src/core/utils/cookie.d.ts +0 -41
- package/plugins/acryl-router/src/core/utils/crypto.d.ts +0 -15
- package/plugins/acryl-router/src/core/utils/handler.d.ts +0 -6
- package/plugins/acryl-router/src/core/utils/headers.d.ts +0 -8
- package/plugins/acryl-router/src/core/utils/html.d.ts +0 -44
- package/plugins/acryl-router/src/core/utils/http-status.d.ts +0 -32
- package/plugins/acryl-router/src/core/utils/mime.d.ts +0 -70
- package/plugins/acryl-router/src/core/utils/stream.d.ts +0 -31
- package/plugins/acryl-router/src/core/utils/types.d.ts +0 -128
- package/plugins/acryl-router/src/core/utils/url.d.ts +0 -44
- package/plugins/acryl-router/src/core/validator/index.d.ts +0 -7
- package/plugins/acryl-router/src/core/validator/utils.d.ts +0 -29
- package/plugins/acryl-router/src/core/validator/validator.d.ts +0 -16
- package/plugins/acryl-router/src/helpers/index.d.ts +0 -17
- package/plugins/acryl-router/src/helpers/schema-validator.d.ts +0 -54
|
@@ -5,32 +5,60 @@
|
|
|
5
5
|
* code; a copy at a new path has fresh URLs for the entry and everything it imports, so it is evaluated anew. The author's source folder
|
|
6
6
|
* is never modified. The hash makes an unchanged source recognisable; the stamp makes "newest" well defined.
|
|
7
7
|
*/
|
|
8
|
-
import { cpSync, existsSync, mkdirSync, readdirSync, rmSync } from 'node:fs'
|
|
8
|
+
import { cpSync, existsSync, mkdirSync, readdirSync, renameSync, rmSync } from 'node:fs'
|
|
9
9
|
import { basename, join } from 'node:path'
|
|
10
10
|
import { digestFolder, FOLDER_DIGEST_SKIPPED } from '@webboxes/blends-core'
|
|
11
11
|
|
|
12
12
|
/** A short content digest of a folder, so an unchanged source keeps its version. */
|
|
13
13
|
export const hashFolder = (dir: string, length = 12): string => digestFolder(dir, length)
|
|
14
14
|
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Whether `node --watch` runs this process. It watches every module the process has imported, and keeps watching the paths of the runs before; a staged copy that is deleted
|
|
17
|
+
* while it is watched restarts the app, and the restart stages and prunes again: a loop. So under the watcher a staged copy is never deleted (a later start without it prunes).
|
|
18
|
+
*/
|
|
19
|
+
export const watched = (): boolean => process.env.WATCH_REPORT_DEPENDENCIES === '1'
|
|
20
|
+
|
|
21
|
+
/** Delete a staged folder, unless the watcher would take the deletion for a change of the app. */
|
|
22
|
+
export function discard(dir: string): void {
|
|
23
|
+
if (!watched()) rmSync(dir, { recursive: true, force: true })
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** The newest complete staged copy of `version` (copies are finished under a temporary name and renamed, so a folder with the final name is whole). */
|
|
27
|
+
function staged(stageRoot: string, name: string, version: string): string | undefined {
|
|
28
|
+
const folder = join(stageRoot, name)
|
|
29
|
+
if (!existsSync(folder)) return undefined
|
|
30
|
+
const found = readdirSync(folder)
|
|
31
|
+
.filter((entry) => !entry.startsWith('.') && entry.endsWith(`-${version}`))
|
|
32
|
+
.sort()
|
|
33
|
+
.pop()
|
|
34
|
+
return found === undefined ? undefined : join(folder, found)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Copy `source` into a version folder under `stageRoot/<name>/` and return its path and version. An unchanged source reuses its copy: a restart stages nothing new. */
|
|
16
38
|
export function stage(
|
|
17
39
|
source: string,
|
|
18
40
|
stageRoot: string,
|
|
19
41
|
name: string,
|
|
20
42
|
): { dir: string; version: string } {
|
|
21
43
|
const version = hashFolder(source)
|
|
44
|
+
const existing = staged(stageRoot, name, version)
|
|
45
|
+
if (existing !== undefined) return { dir: existing, version }
|
|
22
46
|
const stamp = String(Date.now()).padStart(15, '0')
|
|
23
47
|
const dir = join(stageRoot, name, `${stamp}-${version}`)
|
|
24
|
-
|
|
25
|
-
|
|
48
|
+
const partial = join(stageRoot, name, `.${stamp}-${version}.partial`)
|
|
49
|
+
rmSync(partial, { recursive: true, force: true })
|
|
50
|
+
mkdirSync(partial, { recursive: true })
|
|
51
|
+
cpSync(source, partial, {
|
|
26
52
|
recursive: true,
|
|
27
53
|
filter: (path) => !FOLDER_DIGEST_SKIPPED.has(basename(path)),
|
|
28
54
|
})
|
|
55
|
+
renameSync(partial, dir)
|
|
29
56
|
return { dir, version }
|
|
30
57
|
}
|
|
31
58
|
|
|
32
|
-
/** Delete staged versions of `name` except the ones to keep (best effort). Modules already loaded stay in memory until the app restarts. */
|
|
59
|
+
/** Delete staged versions of `name` except the ones to keep (best effort; none under the watcher, see `watched`). Modules already loaded stay in memory until the app restarts. */
|
|
33
60
|
export function prune(stageRoot: string, name: string, keep: readonly string[]): void {
|
|
61
|
+
if (watched()) return
|
|
34
62
|
const folder = join(stageRoot, name)
|
|
35
63
|
if (!existsSync(folder)) return
|
|
36
64
|
if (keep.length === 0) {
|
package/plugins/openai/index.ts
CHANGED
|
@@ -102,7 +102,7 @@ export async function complete(
|
|
|
102
102
|
function: {
|
|
103
103
|
name: tool.name,
|
|
104
104
|
description: tool.description,
|
|
105
|
-
parameters: { type: 'object', additionalProperties: true },
|
|
105
|
+
parameters: tool.parameters ?? { type: 'object', additionalProperties: true },
|
|
106
106
|
},
|
|
107
107
|
})),
|
|
108
108
|
}),
|
|
@@ -5,4 +5,8 @@ Besides `src/routes.ts`, the app runs an agent (`POST /ask`) that can write plug
|
|
|
5
5
|
rollback; `GET /extensions` and `GET /tasks` show what it did. A plugin there is a folder with an `index.ts` exporting `name`, `inject`, `apply(ctx)`
|
|
6
6
|
and an optional `check(ctx)` that receives the plugin's own context (so `ctx.router` reads as in `apply`). It may import `acryl-router`.
|
|
7
7
|
|
|
8
|
+
**Write an extension, not a row.** A feature you build while the app runs is a folder `plugins/<name>/` installed with `.acryl/bin/acryl plugin add plugins/<name>` (the `extensions` plugin loads it again at every start). Add a row to `blend.yaml` and an entry to the `registry` of `src/app.ts` only when the person asks for a plugin that is part of the app itself. Both kinds may import the framework by name (`acrylblends`, `acrylblends/body-limit`, `acryl-router`); a row's relative imports of its sibling plugins also work.
|
|
9
|
+
|
|
10
|
+
**Drive the app you build.** `.acryl/bin/acryl look` reads the open page as text with refs, and `acryl act click|type|press|scroll|wait --ref <ref>` presses its buttons, opens its sidebars and fills its forms (look again before each act: the refs change). `act navigate --path /settings` goes to another page of the app; a path the app does not serve answers `404 at /nope` and the window shows a 404 page, so navigate on from there. In the desktop app (`npm run desktop`) the app's windows and menu are verbs too: `acryl window list`, `acryl window open --path /settings`, `acryl look --window <id>` (and `act ... --window <id>`) to drive that window's page, `acryl window resize|focus|close --id <id>`, `acryl menu list` and `acryl menu click --path "File>New Note"`. Closing the last window and Quit end the desktop app, so they need `--force`: do not use it unless the person asks. When a person asks for settings, build them as a page at `/settings`, so `acryl window open --path /settings` opens them in every app. Without a desktop app these answer "no desktop window is attached; run npm run desktop".
|
|
11
|
+
|
|
8
12
|
**Production.** The agent, the builder and the extensions are development tools: `POST /ask` spends the model key and runs tools, a plugin installed live runs in this process, and none of it is behind a login. With `NODE_ENV=production` `src/app.ts` leaves those three rows out, so `/ask`, `/extensions*` and `/tasks*` are not mounted; the page and `GET /health` stay. `ACRYL_PRODUCTION_KEEP=agent,builder,extensions` keeps the named rows, and each one kept prints a `WARNING` line at start.
|
|
@@ -14,7 +14,7 @@ spec:
|
|
|
14
14
|
# The address the server listens on.
|
|
15
15
|
hostname: { type: string, default: 127.0.0.1 }
|
|
16
16
|
# Steps an agent run may take.
|
|
17
|
-
steps: { type: number, default:
|
|
17
|
+
steps: { type: number, default: 12 }
|
|
18
18
|
# Where task records are kept: jsonl (a text file) or sqlite.
|
|
19
19
|
taskStore: { type: string, default: jsonl }
|
|
20
20
|
# When true, a plugin the agent installs waits for POST /extensions/approve.
|
|
@@ -48,6 +48,9 @@ spec:
|
|
|
48
48
|
name: builder
|
|
49
49
|
- id: save
|
|
50
50
|
name: save
|
|
51
|
+
# The panel: a chat button on every page in development (the app's own agent, or Codex, Claude or pi started in this folder). It starts nothing in production.
|
|
52
|
+
- id: agent-panel
|
|
53
|
+
name: agent-panel
|
|
51
54
|
- id: routes
|
|
52
55
|
name: routes
|
|
53
56
|
- id: server
|
|
@@ -7,6 +7,7 @@ import * as nodeServer from '../plugins/acryl-node-server/src/index.ts'
|
|
|
7
7
|
import * as router from '../plugins/acryl-router/src/index.ts'
|
|
8
8
|
import * as state from '../plugins/acryl-state/src/index.ts'
|
|
9
9
|
import { agent, memory, model, tools } from '../plugins/agent/index.ts'
|
|
10
|
+
import * as panel from '../plugins/agent-panel/index.ts'
|
|
10
11
|
import { builder } from '../plugins/builder/index.ts'
|
|
11
12
|
import { extensions } from '../plugins/extensions/index.ts'
|
|
12
13
|
import { type AppInstance, instance } from '../plugins/instance/index.ts'
|
|
@@ -37,6 +38,7 @@ export const registry = {
|
|
|
37
38
|
sandbox: sandboxPlugin,
|
|
38
39
|
routes,
|
|
39
40
|
'acryl-node-server': nodeServer,
|
|
41
|
+
'agent-panel': panel,
|
|
40
42
|
'acryl-door': door,
|
|
41
43
|
}
|
|
42
44
|
|
|
@@ -37,7 +37,7 @@ export const routes = {
|
|
|
37
37
|
.get('/', (c) =>
|
|
38
38
|
(c.req.header('accept') ?? '').includes('text/html')
|
|
39
39
|
? c.html(
|
|
40
|
-
`<!doctype html><html lang="en"><head><meta charset="utf-8"><title>${APP_NAME}</title></head><body><h1>${APP_NAME}</h1><p>This app runs an agent unless it is switched off (production switches it off, see ACRYL_PRODUCTION_KEEP in AGENTS.md). Ask it for a feature
|
|
40
|
+
`<!doctype html><html lang="en"><head><meta charset="utf-8"><title>${APP_NAME}</title></head><body><h1>${APP_NAME}</h1><p>This app runs an agent unless it is switched off (production switches it off, see ACRYL_PRODUCTION_KEEP in AGENTS.md). Ask it for a feature in the agent panel on this page (or with <code>POST /ask</code>).</p>${DOOR_TAG}</body></html>`,
|
|
41
41
|
)
|
|
42
42
|
: c.json({ app: APP_NAME, ok: true }),
|
|
43
43
|
)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import assert from 'node:assert/strict'
|
|
2
|
+
import { randomBytes } from 'node:crypto'
|
|
2
3
|
import { mkdirSync } from 'node:fs'
|
|
3
4
|
import { mkdtemp, rm } from 'node:fs/promises'
|
|
4
5
|
import { join } from 'node:path'
|
|
@@ -7,6 +8,9 @@ import { fileURLToPath } from 'node:url'
|
|
|
7
8
|
import { pinnedInstance, withPort } from '../plugins/instance/index.ts'
|
|
8
9
|
import { createApp } from '../src/app.ts'
|
|
9
10
|
|
|
11
|
+
/** The plugin this test has the agent build: a name of its own, so a route the app has (a person's /hello) can never shadow it and fail the template's tests. */
|
|
12
|
+
const NAME = `builder-probe-${randomBytes(3).toString('hex')}`
|
|
13
|
+
|
|
10
14
|
/** Throwaway homes live inside the project (`.acrylblends/` is ignored by git): a sandboxed agent may not write to the system temp folder. */
|
|
11
15
|
const scratch = join(fileURLToPath(new URL('..', import.meta.url)), '.acrylblends', 'test')
|
|
12
16
|
mkdirSync(scratch, { recursive: true })
|
|
@@ -24,28 +28,28 @@ test('the agent builds, updates, protects and removes a plugin in the running ap
|
|
|
24
28
|
})
|
|
25
29
|
return ((await response.json()) as { output: string }).output
|
|
26
30
|
}
|
|
27
|
-
const
|
|
28
|
-
const response = await app.root.router.request(
|
|
31
|
+
const served = async () => {
|
|
32
|
+
const response = await app.root.router.request(`/${NAME}`)
|
|
29
33
|
return response.status === 200
|
|
30
34
|
? ((await response.json()) as { text: string }).text
|
|
31
35
|
: response.status
|
|
32
36
|
}
|
|
33
37
|
try {
|
|
34
|
-
assert.equal(await ask(
|
|
35
|
-
assert.equal(await
|
|
36
|
-
assert.equal(await ask(
|
|
37
|
-
assert.equal(await
|
|
38
|
-
assert.match(await ask(
|
|
39
|
-
assert.equal(await
|
|
38
|
+
assert.equal(await ask(`create route ${NAME} /${NAME} Hello`), `${NAME}: installed, active.`)
|
|
39
|
+
assert.equal(await served(), 'Hello')
|
|
40
|
+
assert.equal(await ask(`update route ${NAME} /${NAME} Bonjour`), `${NAME}: updated, active.`)
|
|
41
|
+
assert.equal(await served(), 'Bonjour')
|
|
42
|
+
assert.match(await ask(`break plugin ${NAME}`), /Previous version restored: true/)
|
|
43
|
+
assert.equal(await served(), 'Bonjour')
|
|
40
44
|
|
|
41
45
|
// The broken version stays on disk, so put the working one back before restarting.
|
|
42
|
-
await ask(
|
|
46
|
+
await ask(`update route ${NAME} /${NAME} Bonjour`)
|
|
43
47
|
await app.stop()
|
|
44
48
|
app = await createApp(chosen, { listen: false })
|
|
45
|
-
assert.equal(await
|
|
49
|
+
assert.equal(await served(), 'Bonjour')
|
|
46
50
|
|
|
47
|
-
assert.equal(await ask(
|
|
48
|
-
assert.equal(await
|
|
51
|
+
assert.equal(await ask(`remove plugin ${NAME}`), `${NAME}: done.`)
|
|
52
|
+
assert.equal(await served(), 404)
|
|
49
53
|
|
|
50
54
|
// Every run is a durable task that owns its tool calls, and the records survived the restart.
|
|
51
55
|
const records = (await (await app.root.router.request(`/tasks`)).json()) as Array<{
|
|
@@ -81,22 +85,22 @@ test('with approval on, an install waits for the owner; approving it makes it li
|
|
|
81
85
|
).json()) as Record<string, unknown>
|
|
82
86
|
try {
|
|
83
87
|
assert.equal(
|
|
84
|
-
(await post('/ask', { question:
|
|
85
|
-
|
|
88
|
+
(await post('/ask', { question: `create route ${NAME} /${NAME} Hello` })).output,
|
|
89
|
+
`${NAME}: waiting for the owner's approval.`,
|
|
86
90
|
)
|
|
87
|
-
assert.equal((await app.root.router.request(
|
|
91
|
+
assert.equal((await app.root.router.request(`/${NAME}`)).status, 404)
|
|
88
92
|
const listed = (await (await app.root.router.request(`/extensions`)).json()) as {
|
|
89
93
|
waitingForApproval: Array<{ name: string }>
|
|
90
94
|
}
|
|
91
95
|
assert.deepEqual(
|
|
92
96
|
listed.waitingForApproval.map((request) => request.name),
|
|
93
|
-
[
|
|
97
|
+
[NAME],
|
|
94
98
|
)
|
|
95
99
|
assert.equal(
|
|
96
|
-
((await post('/extensions/approve', { name:
|
|
100
|
+
((await post('/extensions/approve', { name: NAME })) as { state?: string }).state,
|
|
97
101
|
'active',
|
|
98
102
|
)
|
|
99
|
-
assert.deepEqual(await (await app.root.router.request(
|
|
103
|
+
assert.deepEqual(await (await app.root.router.request(`/${NAME}`)).json(), { text: 'Hello' })
|
|
100
104
|
const tasks = (await (await app.root.router.request(`/tasks`)).json()) as Array<{
|
|
101
105
|
manifest?: string
|
|
102
106
|
}>
|
|
@@ -168,12 +172,13 @@ test('what happens is streamed from the state cells: the run as a task, and the
|
|
|
168
172
|
await app.root.router.request(`/ask`, {
|
|
169
173
|
method: 'POST',
|
|
170
174
|
headers: { 'content-type': 'application/json' },
|
|
171
|
-
body: JSON.stringify({ question:
|
|
175
|
+
body: JSON.stringify({ question: `create route ${NAME} /${NAME} Hello` }),
|
|
172
176
|
})
|
|
173
177
|
const arrived = (stream: { text: string }, what: RegExp) => what.test(stream.text)
|
|
174
178
|
for (
|
|
175
179
|
let waited = 0;
|
|
176
|
-
waited < 3000 &&
|
|
180
|
+
waited < 3000 &&
|
|
181
|
+
!arrived(extensionsStream.seen, new RegExp(`"name":"${NAME}"[^\\n]*"state":"active"`));
|
|
177
182
|
waited += 25
|
|
178
183
|
) {
|
|
179
184
|
await new Promise((done) => setTimeout(done, 25))
|
|
@@ -189,7 +194,7 @@ test('what happens is streamed from the state cells: the run as a task, and the
|
|
|
189
194
|
)
|
|
190
195
|
assert.ok(arrived(tasksStream.seen, /"kind":"tool:install_plugin"/), 'the install is a task')
|
|
191
196
|
assert.ok(
|
|
192
|
-
arrived(extensionsStream.seen,
|
|
197
|
+
arrived(extensionsStream.seen, new RegExp(`"name":"${NAME}"[^\\n]*"state":"active"`)),
|
|
193
198
|
'the extension is reported',
|
|
194
199
|
)
|
|
195
200
|
// In process there is no socket to close: the readers are cancelled, which ends the streams and lets the pumps finish.
|
package/lib/helpers-CvTauQT5.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import "./basic-auth.js";
|
|
2
|
-
import "./combine.js";
|
|
3
|
-
import "./context-storage.js";
|
|
4
|
-
import "./ip-restriction.js";
|
|
5
|
-
import "./jsx-renderer.js";
|
|
6
|
-
import "./jwk-LkzeoaU8.js";
|
|
7
|
-
import "./jwt-CskdhEW9.js";
|
|
8
|
-
import "./method-not-allowed.js";
|
|
9
|
-
import "./serve-static-Cp5adzGo.js";
|
|
10
|
-
import "./timeout.js";
|
|
11
|
-
import "./loopback-only.js";
|
|
12
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Transport facts: who is on the other end of the socket and which local port it reached. The caller of `router.fetch` supplies them
|
|
3
|
-
* (an HTTP adapter passes the socket's peer address and real port); they travel in `c.env.connection`, beside the request and never in a header.
|
|
4
|
-
*/
|
|
5
|
-
import type { Context } from './core/context.ts';
|
|
6
|
-
import type { GetConnInfo } from './core/helper/conninfo/types.ts';
|
|
7
|
-
/** An in-process caller (the terminal UI, a test) passes nothing, so a handler that needs a trusted peer must refuse an empty one. */
|
|
8
|
-
export interface ConnectionInfo {
|
|
9
|
-
/** The peer address of the socket, when the request came over one (for example `127.0.0.1`). */
|
|
10
|
-
readonly remoteAddress?: string | undefined;
|
|
11
|
-
/** The local port the socket is connected to, the real one a `Host` header should be checked against. */
|
|
12
|
-
readonly localPort?: number | undefined;
|
|
13
|
-
}
|
|
14
|
-
/** What the router puts in `c.env`. */
|
|
15
|
-
export interface RouterBindings {
|
|
16
|
-
readonly connection: ConnectionInfo;
|
|
17
|
-
}
|
|
18
|
-
/** The `Env` of an `Acryl` that wants `c.env.connection` typed: `new Acryl<RouterEnv>()`. */
|
|
19
|
-
export interface RouterEnv {
|
|
20
|
-
Bindings: RouterBindings;
|
|
21
|
-
}
|
|
22
|
-
/** The transport facts of this request; empty for an in-process call or an `Acryl` run outside the router. */
|
|
23
|
-
export declare function connectionOf(c: Context): ConnectionInfo;
|
|
24
|
-
/** The peer in the core's conninfo shape, for middleware written against it (for example `ipRestriction`). */
|
|
25
|
-
export declare const getConnInfo: GetConnInfo;
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module
|
|
3
|
-
* This module is the base module for the Acryl object.
|
|
4
|
-
*/
|
|
5
|
-
import { Context } from './context.ts';
|
|
6
|
-
import type { ExecutionContext } from './context.ts';
|
|
7
|
-
import type { Router } from './router.ts';
|
|
8
|
-
import type { Env, ErrorHandler, H, HandlerInterface, MergePath, MergeSchemaPath, MiddlewareHandlerInterface, NotFoundHandler, OnHandlerInterface, RouterRoute, Schema } from './types.ts';
|
|
9
|
-
type GetPath<E extends Env> = (request: Request, options?: {
|
|
10
|
-
env?: E['Bindings'];
|
|
11
|
-
}) => string;
|
|
12
|
-
export type AcrylOptions<E extends Env> = {
|
|
13
|
-
/**
|
|
14
|
-
* `router` option specifies which router to use.
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```ts
|
|
19
|
-
* const app = new Acryl({ router: new RegExpRouter() })
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
router?: Router<[H, RouterRoute]>;
|
|
23
|
-
} & ({
|
|
24
|
-
/**
|
|
25
|
-
* `strict` option specifies whether to distinguish whether the last path is a directory or not.
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* @default true
|
|
29
|
-
*/
|
|
30
|
-
strict?: true;
|
|
31
|
-
/**
|
|
32
|
-
* `getPath` can handle the host header value.
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```ts
|
|
37
|
-
* const app = new Acryl({
|
|
38
|
-
* getPath: (req) =>
|
|
39
|
-
* '/' + req.headers.get('host') + req.url.replace(/^https?:\/\/[^/]+(\/[^?]*)/, '$1'),
|
|
40
|
-
* })
|
|
41
|
-
*
|
|
42
|
-
* app.get('/www1.example.com/hello', () => c.text('hello www1'))
|
|
43
|
-
*
|
|
44
|
-
* // A following request will match the route:
|
|
45
|
-
* // new Request('http://www1.example.com/hello', {
|
|
46
|
-
* // headers: { host: 'www1.example.com' },
|
|
47
|
-
* // })
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
getPath?: GetPath<E>;
|
|
51
|
-
} | {
|
|
52
|
-
/**
|
|
53
|
-
* `strict` option specifies whether to distinguish whether the last path is a directory or not.
|
|
54
|
-
* When `strict` is `false`, `getPath` is not used.
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* @default true
|
|
58
|
-
*/
|
|
59
|
-
strict: false;
|
|
60
|
-
getPath?: never;
|
|
61
|
-
});
|
|
62
|
-
type MountOptionHandler = (c: Context) => unknown;
|
|
63
|
-
type MountReplaceRequest = (originalRequest: Request) => Request;
|
|
64
|
-
type MountOptions = MountOptionHandler | {
|
|
65
|
-
optionHandler?: MountOptionHandler;
|
|
66
|
-
replaceRequest?: MountReplaceRequest | false;
|
|
67
|
-
};
|
|
68
|
-
declare class Acryl<E extends Env = Env, S extends Schema = {}, BasePath extends string = '/', CurrentPath extends string = BasePath> {
|
|
69
|
-
#private;
|
|
70
|
-
get: HandlerInterface<E, 'get', S, BasePath, CurrentPath>;
|
|
71
|
-
post: HandlerInterface<E, 'post', S, BasePath, CurrentPath>;
|
|
72
|
-
put: HandlerInterface<E, 'put', S, BasePath, CurrentPath>;
|
|
73
|
-
delete: HandlerInterface<E, 'delete', S, BasePath, CurrentPath>;
|
|
74
|
-
options: HandlerInterface<E, 'options', S, BasePath, CurrentPath>;
|
|
75
|
-
patch: HandlerInterface<E, 'patch', S, BasePath, CurrentPath>;
|
|
76
|
-
query: HandlerInterface<E, 'query', S, BasePath, CurrentPath>;
|
|
77
|
-
all: HandlerInterface<E, 'all', S, BasePath, CurrentPath>;
|
|
78
|
-
on: OnHandlerInterface<E, S, BasePath>;
|
|
79
|
-
use: MiddlewareHandlerInterface<E, S, BasePath>;
|
|
80
|
-
router: Router<[H, RouterRoute]>;
|
|
81
|
-
readonly getPath: GetPath<E>;
|
|
82
|
-
private _basePath;
|
|
83
|
-
routes: RouterRoute[];
|
|
84
|
-
constructor(options?: AcrylOptions<E>);
|
|
85
|
-
private errorHandler;
|
|
86
|
-
/**
|
|
87
|
-
* `.route()` allows grouping other Acryl instance in routes.
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* @param {string} path - base Path
|
|
91
|
-
* @param {Acryl} app - other Acryl instance
|
|
92
|
-
* @returns {Acryl} routed Acryl instance
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* ```ts
|
|
96
|
-
* const app = new Acryl()
|
|
97
|
-
* const app2 = new Acryl()
|
|
98
|
-
*
|
|
99
|
-
* app2.get("/user", (c) => c.text("user"))
|
|
100
|
-
* app.route("/api", app2) // GET /api/user
|
|
101
|
-
* ```
|
|
102
|
-
*/
|
|
103
|
-
route<SubPath extends string, SubEnv extends Env, SubSchema extends Schema, SubBasePath extends string, SubCurrentPath extends string>(path: SubPath, app: Acryl<SubEnv, SubSchema, SubBasePath, SubCurrentPath>): Acryl<E, MergeSchemaPath<SubSchema, MergePath<BasePath, SubPath>> | S, BasePath, CurrentPath>;
|
|
104
|
-
/**
|
|
105
|
-
* `.basePath()` allows base paths to be specified.
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* @param {string} path - base Path
|
|
109
|
-
* @returns {Acryl} changed Acryl instance
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* ```ts
|
|
113
|
-
* const api = new Acryl().basePath('/api')
|
|
114
|
-
* ```
|
|
115
|
-
*/
|
|
116
|
-
basePath<SubPath extends string>(path: SubPath): Acryl<E, S, MergePath<BasePath, SubPath>, MergePath<BasePath, SubPath>>;
|
|
117
|
-
/**
|
|
118
|
-
* `.onError()` handles an error and returns a customized Response.
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
* @param {ErrorHandler} handler - request Handler for error
|
|
122
|
-
* @returns {Acryl} changed Acryl instance
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* ```ts
|
|
126
|
-
* app.onError((err, c) => {
|
|
127
|
-
* console.error(`${err}`)
|
|
128
|
-
* return c.text('Custom Error Message', 500)
|
|
129
|
-
* })
|
|
130
|
-
* ```
|
|
131
|
-
*/
|
|
132
|
-
onError: (handler: ErrorHandler<E>) => Acryl<E, S, BasePath, CurrentPath>;
|
|
133
|
-
/**
|
|
134
|
-
* `.notFound()` allows you to customize a Not Found Response.
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* @param {NotFoundHandler} handler - request handler for not-found
|
|
138
|
-
* @returns {Acryl} changed Acryl instance
|
|
139
|
-
*
|
|
140
|
-
* @example
|
|
141
|
-
* ```ts
|
|
142
|
-
* app.notFound((c) => {
|
|
143
|
-
* return c.text('Custom 404 Message', 404)
|
|
144
|
-
* })
|
|
145
|
-
* ```
|
|
146
|
-
*/
|
|
147
|
-
notFound: (handler: NotFoundHandler<E>) => Acryl<E, S, BasePath, CurrentPath>;
|
|
148
|
-
/**
|
|
149
|
-
* `.mount()` allows you to mount applications built with other frameworks into your Acryl application.
|
|
150
|
-
*
|
|
151
|
-
* @deprecated Use `mount()` from `acryl-router/mount` instead. `.mount()` will be removed in v5.
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
* @param {string} path - base Path
|
|
155
|
-
* @param {Function} applicationHandler - other Request Handler
|
|
156
|
-
* @param {MountOptions} [options] - options of `.mount()`
|
|
157
|
-
* @returns {Acryl} mounted Acryl instance
|
|
158
|
-
*
|
|
159
|
-
* @example
|
|
160
|
-
* ```ts
|
|
161
|
-
* import { Router as IttyRouter } from 'itty-router'
|
|
162
|
-
* import { Acryl } from 'acrylblends'
|
|
163
|
-
* // Create itty-router application
|
|
164
|
-
* const ittyRouter = IttyRouter()
|
|
165
|
-
* // GET /itty-router/hello
|
|
166
|
-
* ittyRouter.get('/hello', () => new Response('Hello from itty-router'))
|
|
167
|
-
*
|
|
168
|
-
* const app = new Acryl()
|
|
169
|
-
* app.mount('/itty-router', ittyRouter.handle)
|
|
170
|
-
* ```
|
|
171
|
-
*
|
|
172
|
-
* @example
|
|
173
|
-
* ```ts
|
|
174
|
-
* const app = new Acryl()
|
|
175
|
-
* // Send the request to another application without modification.
|
|
176
|
-
* app.mount('/app', anotherApp, {
|
|
177
|
-
* replaceRequest: (req) => req,
|
|
178
|
-
* })
|
|
179
|
-
* ```
|
|
180
|
-
*/
|
|
181
|
-
mount(path: string, applicationHandler: (request: Request, ...args: any) => Response | Promise<Response>, options?: MountOptions): Acryl<E, S, BasePath, CurrentPath>;
|
|
182
|
-
/**
|
|
183
|
-
* `.fetch()` will be entry point of your app.
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* @param {Request} request - request Object of request
|
|
187
|
-
* @param {Env} env - env Object
|
|
188
|
-
* @param {ExecutionContext} executionCtx - context of execution
|
|
189
|
-
* @returns {Response | Promise<Response>} response of request
|
|
190
|
-
*
|
|
191
|
-
*/
|
|
192
|
-
fetch: (request: Request, env?: E['Bindings'] | {}, executionCtx?: ExecutionContext) => Response | Promise<Response>;
|
|
193
|
-
/**
|
|
194
|
-
* `.request()` is a useful method for testing.
|
|
195
|
-
* You can pass a URL or pathname to send a GET request.
|
|
196
|
-
* app will return a Response object.
|
|
197
|
-
* ```ts
|
|
198
|
-
* test('GET /hello is ok', async () => {
|
|
199
|
-
* const res = await app.request('/hello')
|
|
200
|
-
* expect(res.status).toBe(200)
|
|
201
|
-
* })
|
|
202
|
-
* ```
|
|
203
|
-
*/
|
|
204
|
-
request: (input: Request | string | URL, requestInit?: RequestInit, Env?: E["Bindings"] | {}, executionCtx?: ExecutionContext) => Response | Promise<Response>;
|
|
205
|
-
/**
|
|
206
|
-
* `.fire()` automatically adds a global fetch event listener.
|
|
207
|
-
* This can be useful for environments that adhere to the Service Worker API, such as non-ES module Cloudflare Workers.
|
|
208
|
-
* @deprecated
|
|
209
|
-
* ACRYL ships no service-worker adapter: mount the app with `ctx.router.route(path, app)` and serve it through an ACRYL adapter instead.
|
|
210
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API
|
|
211
|
-
* @see https://developers.cloudflare.com/workers/reference/migrate-to-module-workers/
|
|
212
|
-
*/
|
|
213
|
-
fire: () => void;
|
|
214
|
-
}
|
|
215
|
-
export { Acryl as AcrylBase };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { AcrylBase } from './app-base.ts';
|
|
2
|
-
import type { AcrylOptions } from './app-base.ts';
|
|
3
|
-
import type { BlankEnv, BlankSchema, Env, Schema } from './types.ts';
|
|
4
|
-
/**
|
|
5
|
-
* The Acryl class extends the functionality of the AcrylBase class.
|
|
6
|
-
* It sets up routing and allows for custom options to be passed.
|
|
7
|
-
*
|
|
8
|
-
* @template E - The environment type.
|
|
9
|
-
* @template S - The schema type.
|
|
10
|
-
* @template BasePath - The base path type.
|
|
11
|
-
*/
|
|
12
|
-
export declare class Acryl<E extends Env = BlankEnv, S extends Schema = BlankSchema, BasePath extends string = '/'> extends AcrylBase<E, S, BasePath> {
|
|
13
|
-
/**
|
|
14
|
-
* Creates an instance of the Acryl class.
|
|
15
|
-
*
|
|
16
|
-
* @param options - Optional configuration options for the Acryl instance.
|
|
17
|
-
*/
|
|
18
|
-
constructor(options?: AcrylOptions<E>);
|
|
19
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Acryl } from '../app.ts';
|
|
2
|
-
import type { UnionToIntersection } from '../utils/types.ts';
|
|
3
|
-
import type { Client, ClientRequestOptions } from './types.ts';
|
|
4
|
-
export declare const hc: <T extends Acryl<any, any, any>, Prefix extends string = string>(baseUrl: Prefix, options?: ClientRequestOptions) => UnionToIntersection<Client<T, Prefix>>;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @description This file is a modified version of `fetch-result-please` (`ofetch`), minimalized and adapted to Acryl's custom needs.
|
|
3
|
-
*
|
|
4
|
-
* @link https://www.npmjs.com/package/fetch-result-please
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Smartly parses and return the consumable result from a fetch `Response`.
|
|
8
|
-
*
|
|
9
|
-
* Throwing a structured error if the response is not `ok`. ({@link DetailedError})
|
|
10
|
-
*/
|
|
11
|
-
export declare function fetchRP(fetchRes: Response | Promise<Response>): Promise<any>;
|
|
12
|
-
export declare class DetailedError extends Error {
|
|
13
|
-
/**
|
|
14
|
-
* Additional `message` that will be logged AND returned to client
|
|
15
|
-
*/
|
|
16
|
-
detail?: any;
|
|
17
|
-
/**
|
|
18
|
-
* Additional `code` that will be logged AND returned to client
|
|
19
|
-
*/
|
|
20
|
-
code?: any;
|
|
21
|
-
/**
|
|
22
|
-
* Additional value that will be logged AND NOT returned to client
|
|
23
|
-
*/
|
|
24
|
-
log?: any;
|
|
25
|
-
/**
|
|
26
|
-
* Optionally set the status code to return, in a web server context
|
|
27
|
-
*/
|
|
28
|
-
statusCode?: any;
|
|
29
|
-
constructor(message: string, options?: {
|
|
30
|
-
detail?: any;
|
|
31
|
-
code?: any;
|
|
32
|
-
statusCode?: number;
|
|
33
|
-
log?: any;
|
|
34
|
-
});
|
|
35
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module
|
|
3
|
-
* The HTTP Client for Acryl.
|
|
4
|
-
*/
|
|
5
|
-
export { hc } from './client.ts';
|
|
6
|
-
export { parseResponse, DetailedError } from './utils.ts';
|
|
7
|
-
export type { InferResponseType, InferRequestType, Fetch, ClientRequestOptions, ClientRequest, ClientResponse, ApplyGlobalResponse, PickResponseByStatusCode, } from './types.ts';
|