@acryldev/blends 1.7.1 → 1.7.3
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/README.md +1 -1
- package/dist/index.js +1 -1
- package/docs/framework/LICENSE +23 -0
- package/docs/framework/README.md +70 -0
- package/docs/framework/agents/index.md +59 -0
- package/docs/framework/api/acryl.md +247 -0
- package/docs/framework/api/context.md +478 -0
- package/docs/framework/api/exception.md +80 -0
- package/docs/framework/api/index.md +12 -0
- package/docs/framework/api/presets.md +62 -0
- package/docs/framework/api/request.md +396 -0
- package/docs/framework/api/routing.md +303 -0
- package/docs/framework/api/summary.md +143 -0
- package/docs/framework/concepts/benchmarks.md +26 -0
- package/docs/framework/concepts/developer-experience.md +5 -0
- package/docs/framework/concepts/middleware.md +21 -0
- package/docs/framework/concepts/motivation.md +14 -0
- package/docs/framework/concepts/routers.md +63 -0
- package/docs/framework/concepts/stacks.md +235 -0
- package/docs/framework/concepts/web-standard.md +27 -0
- package/docs/framework/cordis/acryl-in-a-cordis-app.md +160 -0
- package/docs/framework/cordis/concepts.md +105 -0
- package/docs/framework/cordis/middleware.md +8 -0
- package/docs/framework/cordis/migration-from-0-3.md +111 -0
- package/docs/framework/cordis/migration-from-0-4.md +14 -0
- package/docs/framework/cordis/migration-from-dsh-webserver.md +109 -0
- package/docs/framework/cordis/migration-to-1-0.md +46 -0
- package/docs/framework/cordis/mounting.md +85 -0
- package/docs/framework/cordis/node-server.md +100 -0
- package/docs/framework/cordis/plugin-lifecycle.md +111 -0
- package/docs/framework/cordis/surfaces.md +71 -0
- package/docs/framework/cordis/transport-and-cancellation.md +57 -0
- package/docs/framework/cordis/validation.md +135 -0
- package/docs/framework/getting-started/basic.md +201 -0
- package/docs/framework/getting-started/bun.md +219 -0
- package/docs/framework/getting-started/deploy.md +133 -0
- package/docs/framework/getting-started/desktop.md +80 -0
- package/docs/framework/getting-started/nodejs.md +365 -0
- package/docs/framework/getting-started/other-runtimes.md +30 -0
- package/docs/framework/guides/best-practices.md +231 -0
- package/docs/framework/guides/bring-your-own-tool.md +218 -0
- package/docs/framework/guides/client-modules.md +210 -0
- package/docs/framework/guides/create-acrylblends.md +143 -0
- package/docs/framework/guides/data.md +314 -0
- package/docs/framework/guides/examples.md +3 -0
- package/docs/framework/guides/faq.md +19 -0
- package/docs/framework/guides/forms-and-sessions.md +235 -0
- package/docs/framework/guides/helpers.md +33 -0
- package/docs/framework/guides/jsx-dom.md +301 -0
- package/docs/framework/guides/jsx.md +487 -0
- package/docs/framework/guides/middleware.md +253 -0
- package/docs/framework/guides/production.md +80 -0
- package/docs/framework/guides/rpc.md +878 -0
- package/docs/framework/guides/testing.md +133 -0
- package/docs/framework/guides/validation.md +470 -0
- package/docs/framework/helpers/accepts.md +60 -0
- package/docs/framework/helpers/adapter.md +57 -0
- package/docs/framework/helpers/conninfo.md +77 -0
- package/docs/framework/helpers/cookie.md +232 -0
- package/docs/framework/helpers/css.md +282 -0
- package/docs/framework/helpers/dev.md +64 -0
- package/docs/framework/helpers/factory.md +180 -0
- package/docs/framework/helpers/html.md +123 -0
- package/docs/framework/helpers/jwt.md +184 -0
- package/docs/framework/helpers/proxy.md +115 -0
- package/docs/framework/helpers/route.md +143 -0
- package/docs/framework/helpers/ssg.md +390 -0
- package/docs/framework/helpers/streaming.md +224 -0
- package/docs/framework/helpers/testing.md +118 -0
- package/docs/framework/helpers/websocket.md +208 -0
- package/docs/framework/middleware/builtin/basic-auth.md +165 -0
- package/docs/framework/middleware/builtin/bearer-auth.md +138 -0
- package/docs/framework/middleware/builtin/body-limit.md +71 -0
- package/docs/framework/middleware/builtin/cache.md +99 -0
- package/docs/framework/middleware/builtin/combine.md +94 -0
- package/docs/framework/middleware/builtin/compress.md +59 -0
- package/docs/framework/middleware/builtin/context-storage.md +74 -0
- package/docs/framework/middleware/builtin/cors.md +134 -0
- package/docs/framework/middleware/builtin/csrf.md +105 -0
- package/docs/framework/middleware/builtin/etag.md +54 -0
- package/docs/framework/middleware/builtin/ip-restriction.md +69 -0
- package/docs/framework/middleware/builtin/jsx-renderer.md +283 -0
- package/docs/framework/middleware/builtin/jwk.md +192 -0
- package/docs/framework/middleware/builtin/jwt.md +145 -0
- package/docs/framework/middleware/builtin/language.md +232 -0
- package/docs/framework/middleware/builtin/logger.md +74 -0
- package/docs/framework/middleware/builtin/loopback-only.md +31 -0
- package/docs/framework/middleware/builtin/method-not-allowed.md +48 -0
- package/docs/framework/middleware/builtin/method-override.md +80 -0
- package/docs/framework/middleware/builtin/mount.md +103 -0
- package/docs/framework/middleware/builtin/pretty-json.md +53 -0
- package/docs/framework/middleware/builtin/request-id.md +87 -0
- package/docs/framework/middleware/builtin/secure-headers.md +247 -0
- package/docs/framework/middleware/builtin/timeout.md +98 -0
- package/docs/framework/middleware/builtin/timing.md +100 -0
- package/docs/framework/middleware/builtin/trailing-slash.md +74 -0
- package/docs/framework/middleware/third-party.md +4 -0
- package/docs/framework/workshop/README.md +294 -0
- package/docs/framework/workshop/facilitator.md +101 -0
- package/lib/node-server/register.js +2 -5
- package/package.json +1 -1
- package/plugins/agent/LICENSE +21 -0
- package/plugins/agent/agent.ts +229 -0
- package/plugins/agent/index.ts +20 -0
- package/plugins/agent/memory.ts +24 -0
- package/plugins/agent/model.ts +94 -0
- package/plugins/agent/package.json +41 -0
- package/plugins/agent/plugin.json +13 -0
- package/plugins/agent/tools.ts +67 -0
- package/plugins/agent-panel/LICENSE +21 -0
- package/plugins/agent-panel/client/describe.ts +101 -0
- package/plugins/agent-panel/client/driver-pick.ts +22 -0
- package/plugins/agent-panel/client/frame.ts +51 -0
- package/plugins/agent-panel/client/main.ts +707 -0
- package/plugins/agent-panel/client/markdown.ts +219 -0
- package/plugins/agent-panel/headless.ts +220 -0
- package/plugins/agent-panel/index.ts +523 -0
- package/plugins/agent-panel/launch.ts +67 -0
- package/plugins/agent-panel/mount.ts +27 -0
- package/plugins/agent-panel/package.json +65 -0
- package/plugins/agent-panel/plugin.json +28 -0
- package/plugins/agent-panel/registry.ts +17 -0
- package/plugins/agent-panel/visitors.ts +231 -0
- package/plugins/app-settings/LICENSE +21 -0
- package/plugins/app-settings/index.ts +270 -0
- package/plugins/app-settings/merge.ts +79 -0
- package/plugins/app-settings/package.json +45 -0
- package/plugins/app-settings/plugin.json +16 -0
- package/plugins/builder/LICENSE +21 -0
- package/plugins/builder/index.ts +171 -0
- package/plugins/builder/package.json +52 -0
- package/plugins/builder/plugin.json +17 -0
- package/plugins/builder/script.ts +158 -0
- package/plugins/db/LICENSE +47 -0
- package/plugins/db/package.json +67 -0
- package/plugins/db/plugin.json +25 -0
- package/plugins/db/src/conformance.ts +224 -0
- package/plugins/db/src/cordis.ts +13 -0
- package/plugins/db/src/facade/database.ts +41 -0
- package/plugins/db/src/facade/migrations.ts +50 -0
- package/plugins/db/src/facade/schema.ts +9 -0
- package/plugins/db/src/index.ts +19 -0
- package/plugins/db/src/migration-files.ts +31 -0
- package/plugins/db-sqlite/LICENSE +47 -0
- package/plugins/db-sqlite/package.json +89 -0
- package/plugins/db-sqlite/plugin.json +29 -0
- package/plugins/db-sqlite/src/facade/node.ts +199 -0
- package/plugins/db-sqlite/src/index.ts +95 -0
- package/plugins/db-sqlite/src/open.ts +61 -0
- package/plugins/desktop-shell/LICENSE +21 -0
- package/plugins/desktop-shell/app-page.ts +151 -0
- package/plugins/desktop-shell/app-root.ts +19 -0
- package/plugins/desktop-shell/assets/acrylblends-logo.png +0 -0
- package/plugins/desktop-shell/attach.ts +72 -0
- package/plugins/desktop-shell/bin.ts +5 -0
- package/plugins/desktop-shell/brand.ts +166 -0
- package/plugins/desktop-shell/door-shell.ts +385 -0
- package/plugins/desktop-shell/frame.ts +320 -0
- package/plugins/desktop-shell/git.ts +44 -0
- package/plugins/desktop-shell/host-supervisor.ts +63 -0
- package/plugins/desktop-shell/launch.ts +106 -0
- package/plugins/desktop-shell/main.ts +545 -0
- package/plugins/desktop-shell/menu.ts +60 -0
- package/plugins/desktop-shell/package.json +59 -0
- package/plugins/desktop-shell/plugin.json +20 -0
- package/plugins/desktop-shell/preload.cjs +8 -0
- package/plugins/desktop-shell/product.ts +164 -0
- package/plugins/desktop-shell/shutdown.ts +177 -0
- package/plugins/desktop-shell/update-menu.ts +126 -0
- package/plugins/desktop-shell/updater.ts +228 -0
- package/plugins/desktop-shell/user-data.ts +38 -0
- package/plugins/desktop-shell/watch-host.d.mts +10 -0
- package/plugins/desktop-shell/watch-host.mjs +130 -0
- package/plugins/desktop-shell/window.ts +119 -0
- package/plugins/desktop-web/LICENSE +21 -0
- package/plugins/desktop-web/app-root.ts +12 -0
- package/plugins/desktop-web/launch.ts +54 -0
- package/plugins/desktop-web/main.ts +108 -0
- package/plugins/desktop-web/package.json +49 -0
- package/plugins/desktop-web/plugin.json +21 -0
- package/plugins/desktop-web/shutdown.ts +177 -0
- package/plugins/desktop-web/user-data.ts +38 -0
- package/plugins/desktop-web/window.ts +29 -0
- package/plugins/door/LICENSE +47 -0
- package/plugins/door/package.json +116 -0
- package/plugins/door/plugin.json +39 -0
- package/plugins/door/src/cli/acryl.ts +335 -0
- package/plugins/door/src/host/api.ts +9 -0
- package/plugins/door/src/host/audit.ts +64 -0
- package/plugins/door/src/host/channel.ts +407 -0
- package/plugins/door/src/host/chat-tools.ts +76 -0
- package/plugins/door/src/host/door-file.ts +99 -0
- package/plugins/door/src/host/door.ts +492 -0
- package/plugins/door/src/host/http.ts +80 -0
- package/plugins/door/src/host/mcp-routes.ts +83 -0
- package/plugins/door/src/host/operator-routes.ts +58 -0
- package/plugins/door/src/host/page-routes.ts +69 -0
- package/plugins/door/src/host/page-socket.ts +88 -0
- package/plugins/door/src/host/shell.ts +147 -0
- package/plugins/door/src/host/shim.ts +125 -0
- package/plugins/door/src/host/verbs.ts +160 -0
- package/plugins/door/src/index.ts +337 -0
- package/plugins/door/src/page/api.ts +9 -0
- package/plugins/door/src/page/base.ts +32 -0
- package/plugins/door/src/page/channel.ts +209 -0
- package/plugins/door/src/page/driver/accessibility.ts +177 -0
- package/plugins/door/src/page/driver/actions.ts +207 -0
- package/plugins/door/src/page/driver/driver.ts +216 -0
- package/plugins/door/src/page/driver/ref-table.ts +78 -0
- package/plugins/door/src/page/driver/sensitivity.ts +85 -0
- package/plugins/door/src/page/driver/snapshot.ts +135 -0
- package/plugins/door/src/page/index.ts +100 -0
- package/plugins/door/src/page/indicator.ts +80 -0
- package/plugins/door/src/page/main.ts +7 -0
- package/plugins/door/src/page/outline.ts +56 -0
- package/plugins/door/src/page/protocol.ts +233 -0
- package/plugins/door/src/page/snapshot-text.ts +19 -0
- package/plugins/door/src/page/socket-source.ts +75 -0
- package/plugins/door/src/page/user-input.ts +24 -0
- package/plugins/door/src/shell/protocol.ts +133 -0
- package/plugins/driver-acp/LICENSE +21 -0
- package/plugins/driver-acp/README.md +53 -0
- package/plugins/driver-acp/chat.ts +258 -0
- package/plugins/driver-acp/connection.ts +239 -0
- package/plugins/driver-acp/index.ts +67 -0
- package/plugins/driver-acp/package.json +52 -0
- package/plugins/driver-acp/plugin.json +15 -0
- package/plugins/driver-acp/provenance.json +20 -0
- package/plugins/driver-pty/LICENSE +21 -0
- package/plugins/driver-pty/client/terminal.ts +191 -0
- package/plugins/driver-pty/client/vendor/LICENSE +21 -0
- package/plugins/driver-pty/client/vendor/LICENSE-addon-fit +19 -0
- package/plugins/driver-pty/client/vendor/VERSION +4 -0
- package/plugins/driver-pty/client/vendor/addon-fit.d.mts +6 -0
- package/plugins/driver-pty/client/vendor/addon-fit.mjs +18 -0
- package/plugins/driver-pty/client/vendor/xterm-css.d.mts +2 -0
- package/plugins/driver-pty/client/vendor/xterm-css.mjs +2 -0
- package/plugins/driver-pty/client/vendor/xterm.d.mts +17 -0
- package/plugins/driver-pty/client/vendor/xterm.mjs +53 -0
- package/plugins/driver-pty/index.ts +280 -0
- package/plugins/driver-pty/package.json +55 -0
- package/plugins/driver-pty/plugin.json +16 -0
- package/plugins/driver-pty/spawn.ts +74 -0
- package/plugins/driver-pty/terminal.ts +86 -0
- package/plugins/drivers/LICENSE +21 -0
- package/plugins/drivers/index.ts +75 -0
- package/plugins/drivers/package.json +37 -0
- package/plugins/drivers/plugin.json +11 -0
- package/plugins/extensions/LICENSE +21 -0
- package/plugins/extensions/browser.ts +100 -0
- package/plugins/extensions/index.ts +991 -0
- package/plugins/extensions/ledger.ts +39 -0
- package/plugins/extensions/package.json +48 -0
- package/plugins/extensions/plugin-store.ts +27 -0
- package/plugins/extensions/plugin.json +15 -0
- package/plugins/extensions/resolve.ts +169 -0
- package/plugins/extensions/routes.ts +92 -0
- package/plugins/extensions/stage.ts +82 -0
- package/plugins/feedback/LICENSE +21 -0
- package/plugins/feedback/client.d.ts +22 -0
- package/plugins/feedback/client.js +471 -0
- package/plugins/feedback/index.ts +143 -0
- package/plugins/feedback/package.json +44 -0
- package/plugins/feedback/plugin.json +14 -0
- package/plugins/feedback/store.ts +307 -0
- package/plugins/home/LICENSE +21 -0
- package/plugins/home/index.ts +124 -0
- package/plugins/home/package.json +41 -0
- package/plugins/home/plugin.json +14 -0
- package/plugins/inspect/LICENSE +21 -0
- package/plugins/inspect/package.json +84 -0
- package/plugins/inspect/plugin.json +24 -0
- package/plugins/inspect/src/index.ts +3 -0
- package/plugins/inspect/src/report.ts +131 -0
- package/plugins/inspect/src/service.ts +68 -0
- package/plugins/instance/LICENSE +21 -0
- package/plugins/instance/archive.ts +395 -0
- package/plugins/instance/bundle-overlay.ts +11 -0
- package/plugins/instance/bundle.ts +230 -0
- package/plugins/instance/home.ts +395 -0
- package/plugins/instance/index.ts +290 -0
- package/plugins/instance/package.json +65 -0
- package/plugins/instance/plugin.json +17 -0
- package/plugins/instance/storage.ts +463 -0
- package/plugins/kv/LICENSE +47 -0
- package/plugins/kv/package.json +67 -0
- package/plugins/kv/plugin.json +26 -0
- package/plugins/kv/src/check.ts +58 -0
- package/plugins/kv/src/conformance.ts +226 -0
- package/plugins/kv/src/copy.ts +39 -0
- package/plugins/kv/src/cordis.ts +13 -0
- package/plugins/kv/src/index.ts +14 -0
- package/plugins/kv/src/kv.ts +37 -0
- package/plugins/kv-db/LICENSE +47 -0
- package/plugins/kv-db/package.json +91 -0
- package/plugins/kv-db/plugin.json +31 -0
- package/plugins/kv-db/src/index.ts +37 -0
- package/plugins/kv-db/src/open.ts +80 -0
- package/plugins/kv-json/LICENSE +47 -0
- package/plugins/kv-json/package.json +89 -0
- package/plugins/kv-json/plugin.json +29 -0
- package/plugins/kv-json/src/index.ts +78 -0
- package/plugins/kv-json/src/open.ts +249 -0
- package/plugins/manifest/LICENSE +21 -0
- package/plugins/manifest/app-plugins.ts +86 -0
- package/plugins/manifest/index.ts +645 -0
- package/plugins/manifest/lock.ts +115 -0
- package/plugins/manifest/package.json +57 -0
- package/plugins/manifest/plugin.json +19 -0
- package/plugins/manifest/snapshot.ts +275 -0
- package/plugins/manifest/upgrade-cli.ts +70 -0
- package/plugins/manifest/upgrade.ts +97 -0
- package/plugins/node-server/LICENSE +47 -0
- package/plugins/node-server/package.json +94 -0
- package/plugins/node-server/plugin.json +32 -0
- package/plugins/node-server/src/adapter/conninfo.ts +23 -0
- package/plugins/node-server/src/adapter/early-hints.ts +55 -0
- package/plugins/node-server/src/adapter/error.ts +11 -0
- package/plugins/node-server/src/adapter/headers.ts +249 -0
- package/plugins/node-server/src/adapter/index.ts +6 -0
- package/plugins/node-server/src/adapter/listener.ts +549 -0
- package/plugins/node-server/src/adapter/raw.ts +18 -0
- package/plugins/node-server/src/adapter/request.ts +798 -0
- package/plugins/node-server/src/adapter/response.ts +186 -0
- package/plugins/node-server/src/adapter/serve-static.ts +238 -0
- package/plugins/node-server/src/adapter/server.ts +59 -0
- package/plugins/node-server/src/adapter/types.ts +94 -0
- package/plugins/node-server/src/adapter/url.ts +42 -0
- package/plugins/node-server/src/adapter/utils/response/constants.ts +1 -0
- package/plugins/node-server/src/adapter/utils/response.ts +4 -0
- package/plugins/node-server/src/adapter/utils/stream.ts +88 -0
- package/plugins/node-server/src/adapter/utils.ts +96 -0
- package/plugins/node-server/src/adapter/websocket-types.ts +49 -0
- package/plugins/node-server/src/adapter/websocket.ts +409 -0
- package/plugins/node-server/src/client-modules.ts +300 -0
- package/plugins/node-server/src/index.ts +440 -0
- package/plugins/node-server/src/register.ts +61 -0
- package/plugins/node-server/src/test-websocket.ts +110 -0
- package/plugins/node-server/src/transpile.ts +139 -0
- package/plugins/node-server/src/upgrade-hub.ts +152 -0
- package/plugins/openai/LICENSE +21 -0
- package/plugins/openai/index.ts +218 -0
- package/plugins/openai/package.json +43 -0
- package/plugins/openai/plugin.json +14 -0
- package/plugins/openai/prompt.ts +60 -0
- package/plugins/page/package.json +51 -0
- package/plugins/page/plugin.json +16 -0
- package/plugins/page/src/favicon.ts +19 -0
- package/plugins/page/src/index.ts +168 -0
- package/plugins/plugin-share/LICENSE +21 -0
- package/plugins/plugin-share/README.md +86 -0
- package/plugins/plugin-share/index.ts +791 -0
- package/plugins/plugin-share/native.ts +290 -0
- package/plugins/plugin-share/package.json +54 -0
- package/plugins/plugin-share/package.ts +186 -0
- package/plugins/plugin-share/plugin.json +19 -0
- package/plugins/plugin-share/publish.ts +79 -0
- package/plugins/plugin-share/pull-check.ts +142 -0
- package/plugins/plugin-share/pull-list.ts +71 -0
- package/plugins/plugin-share/pulled-records.ts +70 -0
- package/plugins/router/LICENSE +47 -0
- package/plugins/router/package.json +118 -0
- package/plugins/router/plugin.json +31 -0
- package/plugins/router/src/browser/client.ts +3 -0
- package/plugins/router/src/browser/jsx-dom.ts +9 -0
- package/plugins/router/src/browser/read-sse.ts +3 -0
- package/plugins/router/src/client.ts +2 -0
- package/plugins/router/src/connection.ts +42 -0
- package/plugins/router/src/core/adapter/aws-lambda/conninfo.ts +73 -0
- package/plugins/router/src/core/adapter/aws-lambda/handler.ts +682 -0
- package/plugins/router/src/core/adapter/aws-lambda/index.ts +14 -0
- package/plugins/router/src/core/adapter/aws-lambda/types.ts +173 -0
- package/plugins/router/src/core/adapter/bun/conninfo.ts +43 -0
- package/plugins/router/src/core/adapter/bun/index.ts +11 -0
- package/plugins/router/src/core/adapter/bun/serve-static.ts +32 -0
- package/plugins/router/src/core/adapter/bun/server.ts +14 -0
- package/plugins/router/src/core/adapter/bun/ssg.ts +26 -0
- package/plugins/router/src/core/adapter/bun/websocket.ts +113 -0
- package/plugins/router/src/core/adapter/cloudflare-pages/conninfo.ts +26 -0
- package/plugins/router/src/core/adapter/cloudflare-pages/handler.ts +122 -0
- package/plugins/router/src/core/adapter/cloudflare-pages/index.ts +11 -0
- package/plugins/router/src/core/adapter/cloudflare-workers/conninfo.ts +7 -0
- package/plugins/router/src/core/adapter/cloudflare-workers/index.ts +8 -0
- package/plugins/router/src/core/adapter/cloudflare-workers/serve-static-module.ts +12 -0
- package/plugins/router/src/core/adapter/cloudflare-workers/serve-static.ts +41 -0
- package/plugins/router/src/core/adapter/cloudflare-workers/utils.ts +50 -0
- package/plugins/router/src/core/adapter/cloudflare-workers/websocket.ts +52 -0
- package/plugins/router/src/core/adapter/lambda-edge/conninfo.ts +15 -0
- package/plugins/router/src/core/adapter/lambda-edge/handler.ts +239 -0
- package/plugins/router/src/core/adapter/lambda-edge/index.ts +14 -0
- package/plugins/router/src/core/adapter/netlify/conninfo.ts +57 -0
- package/plugins/router/src/core/adapter/netlify/handler.ts +10 -0
- package/plugins/router/src/core/adapter/netlify/index.ts +6 -0
- package/plugins/router/src/core/adapter/netlify/mod.ts +2 -0
- package/plugins/router/src/core/adapter/service-worker/handler.ts +37 -0
- package/plugins/router/src/core/adapter/service-worker/index.ts +36 -0
- package/plugins/router/src/core/adapter/service-worker/types.ts +14 -0
- package/plugins/router/src/core/adapter/vercel/conninfo.ts +8 -0
- package/plugins/router/src/core/adapter/vercel/handler.ts +8 -0
- package/plugins/router/src/core/adapter/vercel/index.ts +7 -0
- package/plugins/router/src/core/app-base.ts +544 -0
- package/plugins/router/src/core/app.ts +34 -0
- package/plugins/router/src/core/client/client.ts +249 -0
- package/plugins/router/src/core/client/fetch-result-please.ts +95 -0
- package/plugins/router/src/core/client/index.ts +17 -0
- package/plugins/router/src/core/client/types.ts +393 -0
- package/plugins/router/src/core/client/utils.ts +117 -0
- package/plugins/router/src/core/compose.ts +73 -0
- package/plugins/router/src/core/context.ts +781 -0
- package/plugins/router/src/core/helper/accepts/accepts.ts +96 -0
- package/plugins/router/src/core/helper/accepts/index.ts +6 -0
- package/plugins/router/src/core/helper/adapter/index.ts +90 -0
- package/plugins/router/src/core/helper/conninfo/index.ts +6 -0
- package/plugins/router/src/core/helper/conninfo/types.ts +45 -0
- package/plugins/router/src/core/helper/cookie/index.ts +146 -0
- package/plugins/router/src/core/helper/css/common.ts +337 -0
- package/plugins/router/src/core/helper/css/index.ts +262 -0
- package/plugins/router/src/core/helper/dev/index.ts +79 -0
- package/plugins/router/src/core/helper/factory/index.ts +375 -0
- package/plugins/router/src/core/helper/html/index.ts +57 -0
- package/plugins/router/src/core/helper/proxy/index.ts +203 -0
- package/plugins/router/src/core/helper/route/index.ts +144 -0
- package/plugins/router/src/core/helper/ssg/index.ts +14 -0
- package/plugins/router/src/core/helper/ssg/middleware.ts +83 -0
- package/plugins/router/src/core/helper/ssg/plugins.ts +72 -0
- package/plugins/router/src/core/helper/ssg/ssg.ts +471 -0
- package/plugins/router/src/core/helper/ssg/utils.ts +118 -0
- package/plugins/router/src/core/helper/streaming/index.ts +9 -0
- package/plugins/router/src/core/helper/streaming/sse.ts +101 -0
- package/plugins/router/src/core/helper/streaming/stream.ts +45 -0
- package/plugins/router/src/core/helper/streaming/text.ts +15 -0
- package/plugins/router/src/core/helper/streaming/utils.ts +11 -0
- package/plugins/router/src/core/helper/testing/index.ts +28 -0
- package/plugins/router/src/core/helper/websocket/index.ts +146 -0
- package/plugins/router/src/core/http-exception.ts +77 -0
- package/plugins/router/src/core/index.ts +53 -0
- package/plugins/router/src/core/jsx/base.ts +490 -0
- package/plugins/router/src/core/jsx/children.ts +20 -0
- package/plugins/router/src/core/jsx/components.ts +257 -0
- package/plugins/router/src/core/jsx/constants.ts +6 -0
- package/plugins/router/src/core/jsx/context.ts +266 -0
- package/plugins/router/src/core/jsx/dom/client.ts +89 -0
- package/plugins/router/src/core/jsx/dom/components.ts +39 -0
- package/plugins/router/src/core/jsx/dom/context.ts +52 -0
- package/plugins/router/src/core/jsx/dom/css.ts +263 -0
- package/plugins/router/src/core/jsx/dom/hooks/index.ts +91 -0
- package/plugins/router/src/core/jsx/dom/index.ts +170 -0
- package/plugins/router/src/core/jsx/dom/intrinsic-element/components.ts +438 -0
- package/plugins/router/src/core/jsx/dom/jsx-dev-runtime.ts +23 -0
- package/plugins/router/src/core/jsx/dom/jsx-runtime.ts +8 -0
- package/plugins/router/src/core/jsx/dom/render.ts +879 -0
- package/plugins/router/src/core/jsx/dom/server.ts +76 -0
- package/plugins/router/src/core/jsx/dom/utils.ts +7 -0
- package/plugins/router/src/core/jsx/hooks/index.ts +437 -0
- package/plugins/router/src/core/jsx/index.ts +115 -0
- package/plugins/router/src/core/jsx/intrinsic-element/common.ts +23 -0
- package/plugins/router/src/core/jsx/intrinsic-element/components.ts +210 -0
- package/plugins/router/src/core/jsx/intrinsic-elements.ts +938 -0
- package/plugins/router/src/core/jsx/jsx-dev-runtime.ts +26 -0
- package/plugins/router/src/core/jsx/jsx-runtime.ts +51 -0
- package/plugins/router/src/core/jsx/streaming.ts +231 -0
- package/plugins/router/src/core/jsx/types.ts +41 -0
- package/plugins/router/src/core/jsx/utils.ts +202 -0
- package/plugins/router/src/core/middleware/basic-auth/index.ts +152 -0
- package/plugins/router/src/core/middleware/bearer-auth/index.ts +220 -0
- package/plugins/router/src/core/middleware/body-limit/index.ts +110 -0
- package/plugins/router/src/core/middleware/cache/index.ts +323 -0
- package/plugins/router/src/core/middleware/combine/index.ts +171 -0
- package/plugins/router/src/core/middleware/compress/index.ts +142 -0
- package/plugins/router/src/core/middleware/context-storage/index.ts +58 -0
- package/plugins/router/src/core/middleware/cors/index.ts +163 -0
- package/plugins/router/src/core/middleware/csrf/index.ts +150 -0
- package/plugins/router/src/core/middleware/etag/digest.ts +95 -0
- package/plugins/router/src/core/middleware/etag/index.ts +135 -0
- package/plugins/router/src/core/middleware/ip-restriction/index.ts +278 -0
- package/plugins/router/src/core/middleware/jsx-renderer/index.ts +162 -0
- package/plugins/router/src/core/middleware/jwk/index.ts +1 -0
- package/plugins/router/src/core/middleware/jwk/jwk.ts +196 -0
- package/plugins/router/src/core/middleware/jwt/index.ts +9 -0
- package/plugins/router/src/core/middleware/jwt/jwt.ts +190 -0
- package/plugins/router/src/core/middleware/language/index.ts +12 -0
- package/plugins/router/src/core/middleware/language/language.ts +314 -0
- package/plugins/router/src/core/middleware/logger/index.ts +95 -0
- package/plugins/router/src/core/middleware/method-not-allowed/index.ts +141 -0
- package/plugins/router/src/core/middleware/method-override/index.ts +147 -0
- package/plugins/router/src/core/middleware/mount/index.ts +108 -0
- package/plugins/router/src/core/middleware/powered-by/index.ts +35 -0
- package/plugins/router/src/core/middleware/pretty-json/index.ts +67 -0
- package/plugins/router/src/core/middleware/request-id/index.ts +7 -0
- package/plugins/router/src/core/middleware/request-id/request-id.ts +59 -0
- package/plugins/router/src/core/middleware/secure-headers/index.ts +8 -0
- package/plugins/router/src/core/middleware/secure-headers/permissions-policy.ts +101 -0
- package/plugins/router/src/core/middleware/secure-headers/secure-headers.ts +340 -0
- package/plugins/router/src/core/middleware/serve-static/index.ts +135 -0
- package/plugins/router/src/core/middleware/serve-static/path.ts +25 -0
- package/plugins/router/src/core/middleware/timeout/index.ts +58 -0
- package/plugins/router/src/core/middleware/timing/index.ts +8 -0
- package/plugins/router/src/core/middleware/timing/timing.ts +256 -0
- package/plugins/router/src/core/middleware/trailing-slash/index.ts +156 -0
- package/plugins/router/src/core/preset/quick.ts +24 -0
- package/plugins/router/src/core/preset/tiny.ts +20 -0
- package/plugins/router/src/core/request/constants.ts +1 -0
- package/plugins/router/src/core/request.ts +502 -0
- package/plugins/router/src/core/router/linear-router/index.ts +6 -0
- package/plugins/router/src/core/router/linear-router/router.ts +152 -0
- package/plugins/router/src/core/router/pattern-router/index.ts +6 -0
- package/plugins/router/src/core/router/pattern-router/router.ts +54 -0
- package/plugins/router/src/core/router/reg-exp-router/index.ts +7 -0
- package/plugins/router/src/core/router/reg-exp-router/matcher.ts +33 -0
- package/plugins/router/src/core/router/reg-exp-router/node.ts +170 -0
- package/plugins/router/src/core/router/reg-exp-router/prepared-router.ts +165 -0
- package/plugins/router/src/core/router/reg-exp-router/router.ts +174 -0
- package/plugins/router/src/core/router/reg-exp-router/trie.ts +84 -0
- package/plugins/router/src/core/router/smart-router/index.ts +6 -0
- package/plugins/router/src/core/router/smart-router/router.ts +70 -0
- package/plugins/router/src/core/router/trie-router/index.ts +6 -0
- package/plugins/router/src/core/router/trie-router/node.ts +221 -0
- package/plugins/router/src/core/router/trie-router/router.ts +18 -0
- package/plugins/router/src/core/router/utils.ts +1 -0
- package/plugins/router/src/core/router.ts +103 -0
- package/plugins/router/src/core/types.ts +2782 -0
- package/plugins/router/src/core/utils/accept.ts +268 -0
- package/plugins/router/src/core/utils/basic-auth.ts +26 -0
- package/plugins/router/src/core/utils/body.ts +263 -0
- package/plugins/router/src/core/utils/buffer.ts +117 -0
- package/plugins/router/src/core/utils/color.ts +56 -0
- package/plugins/router/src/core/utils/compress.ts +10 -0
- package/plugins/router/src/core/utils/concurrent.ts +55 -0
- package/plugins/router/src/core/utils/constants.ts +4 -0
- package/plugins/router/src/core/utils/cookie.ts +281 -0
- package/plugins/router/src/core/utils/crypto.ts +58 -0
- package/plugins/router/src/core/utils/encode.ts +34 -0
- package/plugins/router/src/core/utils/filepath.ts +60 -0
- package/plugins/router/src/core/utils/handler.ts +15 -0
- package/plugins/router/src/core/utils/headers.ts +355 -0
- package/plugins/router/src/core/utils/html.ts +182 -0
- package/plugins/router/src/core/utils/http-status.ts +72 -0
- package/plugins/router/src/core/utils/ipaddr.ts +374 -0
- package/plugins/router/src/core/utils/jwt/index.ts +7 -0
- package/plugins/router/src/core/utils/jwt/jwa.ts +38 -0
- package/plugins/router/src/core/utils/jwt/jws.ts +235 -0
- package/plugins/router/src/core/utils/jwt/jwt.ts +292 -0
- package/plugins/router/src/core/utils/jwt/types.ts +157 -0
- package/plugins/router/src/core/utils/jwt/utf8.ts +7 -0
- package/plugins/router/src/core/utils/mime.ts +94 -0
- package/plugins/router/src/core/utils/stream.ts +107 -0
- package/plugins/router/src/core/utils/types.ts +174 -0
- package/plugins/router/src/core/utils/url.ts +337 -0
- package/plugins/router/src/core/validator/index.ts +8 -0
- package/plugins/router/src/core/validator/utils.ts +69 -0
- package/plugins/router/src/core/validator/validator.ts +185 -0
- package/plugins/router/src/helpers/index.ts +17 -0
- package/plugins/router/src/helpers/read-sse.ts +111 -0
- package/plugins/router/src/helpers/schema-validator.ts +62 -0
- package/plugins/router/src/index.ts +6 -0
- package/plugins/router/src/middleware/index.ts +28 -0
- package/plugins/router/src/middleware/loopback-only.ts +183 -0
- package/plugins/router/src/service.ts +477 -0
- package/plugins/router-http/LICENSE +21 -0
- package/plugins/router-http/package.json +87 -0
- package/plugins/router-http/plugin.json +23 -0
- package/plugins/router-http/src/bridge.ts +54 -0
- package/plugins/router-http/src/index.ts +141 -0
- package/plugins/router-http/src/serve.ts +55 -0
- package/plugins/sandbox/LICENSE +21 -0
- package/plugins/sandbox/index.ts +150 -0
- package/plugins/sandbox/package.json +41 -0
- package/plugins/sandbox/plugin.json +13 -0
- package/plugins/sandbox/runner.mjs +18 -0
- package/plugins/save/LICENSE +21 -0
- package/plugins/save/cli.ts +19 -0
- package/plugins/save/index.ts +55 -0
- package/plugins/save/package.json +43 -0
- package/plugins/save/plugin.json +15 -0
- package/plugins/save/share-cli.ts +114 -0
- package/plugins/save/share.ts +204 -0
- package/plugins/showcase/LICENSE +21 -0
- package/plugins/showcase/cards.ts +162 -0
- package/plugins/showcase/index.ts +117 -0
- package/plugins/showcase/package.json +49 -0
- package/plugins/showcase/plugin.json +14 -0
- package/plugins/state/LICENSE +21 -0
- package/plugins/state/package.json +104 -0
- package/plugins/state/plugin.json +27 -0
- package/plugins/state/src/cell.ts +67 -0
- package/plugins/state/src/client-source.ts +244 -0
- package/plugins/state/src/index.ts +3 -0
- package/plugins/state/src/service.ts +146 -0
- package/plugins/state/src/socket.ts +96 -0
- package/plugins/tasks/LICENSE +21 -0
- package/plugins/tasks/index.ts +246 -0
- package/plugins/tasks/package.json +45 -0
- package/plugins/tasks/plugin.json +14 -0
- package/plugins/tasks/store.ts +86 -0
- package/plugins/web-server/package.json +52 -0
- package/plugins/web-server/plugin.json +20 -0
- package/plugins/web-server/src/index.ts +164 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Facilitator notes: building inside the ACRYL frame
|
|
2
|
+
|
|
3
|
+
Read the handout first (`docs/framework/workshop/README.md`); this page is the room around it. The workshop changed shape again for the frame: the
|
|
4
|
+
app is created, then **opened inside ACRYL's IDE** (projects on the left, the app's page in the canvas, files/changes/terminals on the right), a
|
|
5
|
+
chat model works on the app from inside the frame, and coding agents run in terminal tabs in the same folder. The data layer, the desktop window and
|
|
6
|
+
the panel-first flow of the previous handout are gone.
|
|
7
|
+
|
|
8
|
+
The handout is written for **acrylblends 1.3.0 or newer** (the release whose `create --desktop` makes the framed app). A room on an older release is on the previous handout;
|
|
9
|
+
check with `npx acrylblends@latest --version` before the day.
|
|
10
|
+
|
|
11
|
+
## Before the room: put this on every machine
|
|
12
|
+
|
|
13
|
+
| What | Why | How |
|
|
14
|
+
| --- | --- | --- |
|
|
15
|
+
| The preflight passing | it checks Node, npm, git, an agent with its login or key, a free port, and on Windows PowerShell and long paths | `npx acrylblends@latest preflight` ends with `Ready for the workshop.` |
|
|
16
|
+
| Node.js 22.19 or newer (24 and 26 tested) | the app runs TypeScript directly | `node -v`; the app's `scripts/check-node.cjs` refuses an older Node with a clear line |
|
|
17
|
+
| git, and a GitHub account with `gh auth login` | the first `npm run dev` makes the folder a git repository (Files and Changes need one); the last block forks the registry | `git --version`, `gh auth status` |
|
|
18
|
+
| One coding agent, logged in | block 5 starts it in a terminal tab; `claude`, `codex` and `pi` all worked | `codex login` once, or run `claude` once, or pi with `DEEPSEEK_API_KEY` in the terminal that starts `npm run dev` |
|
|
19
|
+
| One model key | block 3 adds it in Settings > Models; without it the chat shows a connect card | a DeepSeek key from <https://platform.deepseek.com>, or a Claude/ChatGPT subscription through Sign in with an account |
|
|
20
|
+
| A prepared app with `npm install` done | the first install brings the frame and the chat engine (about 500 MB together); a room on one Wi-Fi should not do it 20 times | run the handout's block 1 once per machine and keep the folder as `~/acryl-workshop/prepared/` |
|
|
21
|
+
| A warm npm cache | the first install dominates block 1 | the prepared app does it |
|
|
22
|
+
|
|
23
|
+
**The agent setting that decides the day.** The agents are configured to act rather than describe. Check on every machine that a plain request
|
|
24
|
+
produces files, not a plan: ask the prepared app's chat "add a line to the app's page" and watch the Changes panel. If it only describes, the model
|
|
25
|
+
is waiting for permission; the handout's sentence is "do it now".
|
|
26
|
+
|
|
27
|
+
**Agent-specific checks.** Codex answering `model_not_found` means the account does not have the default model: pick one it supports (`/model` in
|
|
28
|
+
codex, or `model = "..."` in `~/.codex/config.toml`). pi with DeepSeek needs `DEEPSEEK_API_KEY` in the environment of the terminal that runs `npm
|
|
29
|
+
run dev` (the terminal tabs inherit it); the preflight reports `PASS agent pi (DeepSeek key found)`. The package is
|
|
30
|
+
`@earendil-works/pi-coding-agent`.
|
|
31
|
+
|
|
32
|
+
## Timings, from the rehearsal (this Mac, packed CLI, isolated HOME)
|
|
33
|
+
|
|
34
|
+
| Minutes | Block | Measured | If late |
|
|
35
|
+
| --- | --- | --- | --- |
|
|
36
|
+
| 0-10 | preflight and setup | preflight ~15 s; the prepared app skips create and install | never cut |
|
|
37
|
+
| 10-20 | create and open the frame | the first `npm install` dominates (the frame and the chat engine); the frame's first page is up in a few seconds after that | use the prepared app and open its frame |
|
|
38
|
+
| 20-25 | the first change at /app | the Files view opens `src/routes.ts`; stop and `npm run dev` reconnects the frame in a few seconds; the page shows the edit | cut `npm test` to the take-home |
|
|
39
|
+
| 25-30 | Settings > Models | the key saves with Apply (`Saved DeepSeek (deepseek-official).`); the page uses it after a reload | paste the key in the first-run card instead, Save and continue |
|
|
40
|
+
| 30-50 | chat builds the board | the chat writes into the app folder and Changes fills; the restart loop shows it at /app/board | if the model is slow, cut the board to one column |
|
|
41
|
+
| 50-65 | a coding agent in a terminal | the agent tab starts in the app folder (its prompt is `my-app`); `.acryl/bin/acryl look` prints the page in the frame's tile | demo one agent and let the room follow |
|
|
42
|
+
| 65-80 | upgrade an older app | `npx acrylblends@latest upgrade` reports every file it changed (the `frame` line is the new layout), then `npm install` and `npm run dev` | keep the report, skip the second app |
|
|
43
|
+
| 80-90 | publish (take-home) | the registry check merges in about two minutes | leave it as the take-home |
|
|
44
|
+
|
|
45
|
+
What the rehearsal verified end to end on this Mac: a packed CLI in an isolated HOME, the app opened by the frame with the app's page in a tab
|
|
46
|
+
(the first-run tile), the Preview Notice dismissed once, Settings > Models saving a key and the chat sending with it (against a local mock), a
|
|
47
|
+
terminal tab running commands in the app folder, the app's page edited and shown after a restart, the door seeing the page (`acryl look`), and an
|
|
48
|
+
app made by the previous release upgraded and opened by the frame.
|
|
49
|
+
|
|
50
|
+
## What to say in the room
|
|
51
|
+
|
|
52
|
+
- **The frame is the product.** The point is not "an app with a chat sidebar"; it is that ACRYL's IDE hosts the app you are building: the app is
|
|
53
|
+
the page in the middle, its folder is the workspace, and the agents work in that folder.
|
|
54
|
+
- **Settings > Models is the key's home.** The key goes to the frame's own credentials store in the app's data folder (`~/.acryl/apps/<id>/data/`), never the app folder. The
|
|
55
|
+
first-run card writes the same store; either path is fine.
|
|
56
|
+
- **The loop is stop, start, look.** A source change needs `npm run dev` again; the port is stable per app, so the frame reconnects on the same
|
|
57
|
+
address and the app's tab is still there. If a chat tab comes to the front after the restart, press the `my-app` tab.
|
|
58
|
+
- **Two kinds of agent.** The chat (DSH's own, in the frame) and the coding agents in terminal tabs are different hands on the same folder; show
|
|
59
|
+
both and let people pick.
|
|
60
|
+
- **The door.** `.acryl/bin/acryl look` prints the page with refs, `act` clicks and types. In the frame the page is the tile, and the door sees
|
|
61
|
+
it. This is how an agent checks its own work.
|
|
62
|
+
- **Production is unchanged.** The frame, the chat and the agents are development tools; `NODE_ENV=production npm start` serves the app alone.
|
|
63
|
+
|
|
64
|
+
## Windows
|
|
65
|
+
|
|
66
|
+
Windows PowerShell 5.1 has no `&&` (two lines, or `;`); PowerShell sets variables with `$env:NAME="value"`; cmd.exe's `Ctrl-C` asks `Terminate
|
|
67
|
+
batch job (Y/N)?` (answer `Y`); cmd.exe does not expand `~` (use `%USERPROFILE%`). `npm install` needs the "Desktop development with C++" workload
|
|
68
|
+
of Visual Studio Build Tools for the terminal package; the preflight notes it.
|
|
69
|
+
|
|
70
|
+
## The no-network fallback
|
|
71
|
+
|
|
72
|
+
1. Prepared apps with `npm install` done cover blocks 1, 2 and the frame; the models (chat and agents) still need a connection or a demo.
|
|
73
|
+
2. Block 7's registry needs GitHub; if the venue is offline, publish from your machine on a hotspot at the end, or show the recording.
|
|
74
|
+
3. Keep one phone hotspot for the room.
|
|
75
|
+
|
|
76
|
+
## Demo script (five minutes, if the room is behind)
|
|
77
|
+
|
|
78
|
+
1. Prepared app, frame open on the app's page: press `+`, open **AcrylDSH Chat**, ask for a sentence on the page. Narrate the Changes panel and
|
|
79
|
+
the restart loop.
|
|
80
|
+
2. Open a **files** tab in the right panel and show the edit the model made.
|
|
81
|
+
3. `+` → **Pi** (or Claude): the agent starts in the app folder; ask it for a route; run `.acryl/bin/acryl look` in that terminal and show the
|
|
82
|
+
page's snapshot.
|
|
83
|
+
4. Settings > Models: show where the key lives and that it is not in the app folder.
|
|
84
|
+
5. Show the registry listing with an app already published.
|
|
85
|
+
|
|
86
|
+
## Resetting between sessions
|
|
87
|
+
|
|
88
|
+
Everything a person makes lives inside their app folder, its data folder in `~/.acryl/apps/` and `~/acryl-workshop`. To reset a machine, delete the app
|
|
89
|
+
folders and their data folders, and copy the prepared one back without its `.acryl/` folder; nothing is installed globally except the agent, `gh` and Node.
|
|
90
|
+
An app's data, the model key's credentials store included, lives in `~/.acryl/apps/<id>/data/`, outside the app folder. The `<id>` is written once into
|
|
91
|
+
the app folder's `.acryl/app.json` (gitignored): a copy that keeps that file shares the original's data and key, and a copy without it gets its own id
|
|
92
|
+
and an empty data folder.
|
|
93
|
+
|
|
94
|
+
## What is still open
|
|
95
|
+
|
|
96
|
+
- The frame's chat tab takes the focus when it binds its session after a restart; the app's tab is one click away and the guide says so.
|
|
97
|
+
- The frame's address is stable across restarts: the launcher keeps the token in the app home (owner-only, atomic) and reuses it, so an open page
|
|
98
|
+
comes back by reloading its URL even if the browser lost its cookie. `npx acrylblends open` prints the address of the running frame;
|
|
99
|
+
`npx acrylblends open --new` rotates it (the old address stops working at once and the new one is printed). The frame-side banner that names the
|
|
100
|
+
command is still to come (after the 120 gate work).
|
|
101
|
+
- The one-click WebBoxes.ai deploy and the browser-only section stay TODO(M9) until that workspace is live.
|
|
@@ -35,11 +35,8 @@ registerHooks({ load(url, context, nextLoad) {
|
|
|
35
35
|
*/
|
|
36
36
|
const plugins = new URL("../../", import.meta.url);
|
|
37
37
|
const appRoot = new URL("../", plugins).href;
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
const { appTree } = await import(family.href);
|
|
41
|
-
if (appTree(process.env, fileURLToPath(appRoot)) !== void 0) usePackagesOfProgram(fileURLToPath(appRoot));
|
|
42
|
-
}
|
|
38
|
+
const program = process.env.ACRYLBLENDS_PROGRAM?.trim();
|
|
39
|
+
if (program) usePackagesOfProgram(program);
|
|
43
40
|
const resolver = new URL("extensions/resolve.ts", plugins);
|
|
44
41
|
if (existsSync(fileURLToPath(new URL("router/src/index.ts", plugins))) && existsSync(fileURLToPath(resolver))) {
|
|
45
42
|
const { routerAliases } = await import(resolver.href);
|
package/package.json
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 acrylblends
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis'
|
|
2
|
+
import type {} from './memory.ts'
|
|
3
|
+
import type { Step } from './model.ts'
|
|
4
|
+
import type {} from './tools.ts'
|
|
5
|
+
|
|
6
|
+
/** One tool call made during a run. */
|
|
7
|
+
export interface ToolCall {
|
|
8
|
+
readonly tool: string
|
|
9
|
+
readonly input: unknown
|
|
10
|
+
readonly result?: unknown
|
|
11
|
+
readonly error?: string
|
|
12
|
+
/** The thinking model's reasoning for this call, kept so the next step can send it back. */
|
|
13
|
+
readonly reasoning?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** How a run ended, with every tool call it made. `task` is its durable record's id when the app records tasks. */
|
|
17
|
+
export type RunResult = (
|
|
18
|
+
| { readonly status: 'completed'; readonly output: string }
|
|
19
|
+
| { readonly status: 'budget_exceeded' }
|
|
20
|
+
| { readonly status: 'cancelled' }
|
|
21
|
+
) & { readonly steps: number; readonly trace: readonly ToolCall[]; readonly task?: string }
|
|
22
|
+
|
|
23
|
+
/** What a caller may pass to one run. */
|
|
24
|
+
export interface RunOptions {
|
|
25
|
+
/** Aborting it stops the run: the model call or tool in flight is dropped and the run ends `{ status: 'cancelled' }`. */
|
|
26
|
+
readonly signal?: AbortSignal
|
|
27
|
+
/** The door's id of the page the run was asked from: every tool call carries it, so the page tools drive that page and no other (a production assistant serves many visitors). */
|
|
28
|
+
readonly page?: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface Agent {
|
|
32
|
+
run(question: string, options?: RunOptions): Promise<RunResult>
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The step budget of one run, provided inside the run's own fiber. */
|
|
36
|
+
export interface Budget {
|
|
37
|
+
steps: number
|
|
38
|
+
readonly limit: number
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface AgentConfig {
|
|
42
|
+
/** Steps per run before it stops. */
|
|
43
|
+
steps?: number
|
|
44
|
+
/**
|
|
45
|
+
* The only tools a run may see and call; absent: every tool in the registry. A production assistant gets the page tools alone (`door_look`, `door_act`), so whatever
|
|
46
|
+
* a visitor asks, the agent can use the app and never change it. A call to any other name fails as an unknown tool would.
|
|
47
|
+
*/
|
|
48
|
+
tools?: readonly string[]
|
|
49
|
+
/**
|
|
50
|
+
* The tool whose result an answer must come right after. When the model answers after another tool call (it acted and did not look), the agent calls this tool
|
|
51
|
+
* itself, once, and asks the model again with what it shows. The production assistant sets `door_look`, so what it tells a visitor is what the page shows now.
|
|
52
|
+
*/
|
|
53
|
+
answerAfter?: string
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The part of a task recorder the agent uses. Optional: when an app mounts the `tasks` plugin, each run is a durable task and each
|
|
58
|
+
* tool call a task it owns; without it, runs work the same and leave no record.
|
|
59
|
+
*/
|
|
60
|
+
interface TaskRecorder {
|
|
61
|
+
start(
|
|
62
|
+
kind: string,
|
|
63
|
+
input: unknown,
|
|
64
|
+
options?: { parent?: string },
|
|
65
|
+
): {
|
|
66
|
+
readonly id: string
|
|
67
|
+
readonly signal: AbortSignal
|
|
68
|
+
progress(detail: unknown): void
|
|
69
|
+
complete(result: unknown, detail?: unknown): void
|
|
70
|
+
fail(error: unknown, detail?: unknown): void
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
declare module '@deepseek-ai/cordis' {
|
|
75
|
+
interface Context {
|
|
76
|
+
agent: Agent
|
|
77
|
+
budget: Budget
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const message = (error: unknown) => (error instanceof Error ? error.message : String(error))
|
|
82
|
+
|
|
83
|
+
/** Thrown inside a run when its signal aborts; the run turns it into `cancelled`. */
|
|
84
|
+
class Cancelled extends Error {}
|
|
85
|
+
|
|
86
|
+
/** The promise, or a rejection with `Cancelled` as soon as the signal aborts (a model or tool that ignores the signal cannot hold the run). */
|
|
87
|
+
function until<T>(work: Promise<T>, signal: AbortSignal): Promise<T> {
|
|
88
|
+
if (signal.aborted) return Promise.reject(new Cancelled())
|
|
89
|
+
return new Promise<T>((resolve, reject) => {
|
|
90
|
+
const onAbort = () => reject(new Cancelled())
|
|
91
|
+
signal.addEventListener('abort', onAbort, { once: true })
|
|
92
|
+
work.then(resolve, reject).finally(() => signal.removeEventListener('abort', onAbort))
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The agent. Every run is its own child fiber that holds the run's budget and is disposed when the run ends, however it ends: a
|
|
98
|
+
* scope per task, written with plain Cordis plugins. A tool that throws does not end the run: the model sees the error as the result.
|
|
99
|
+
* When the app records tasks, the run's record is written before the answer is returned, and cancelling it stops the run.
|
|
100
|
+
*/
|
|
101
|
+
export const agent = {
|
|
102
|
+
name: 'agent',
|
|
103
|
+
inject: ['model', 'tools', 'memory'],
|
|
104
|
+
apply(ctx: Context, config?: AgentConfig) {
|
|
105
|
+
const limit = config?.steps ?? 6
|
|
106
|
+
const allowed = config?.tools === undefined ? undefined : new Set(config.tools)
|
|
107
|
+
const answerAfter = config?.answerAfter
|
|
108
|
+
let runs = 0
|
|
109
|
+
ctx.provide('agent', {
|
|
110
|
+
async run(question, options) {
|
|
111
|
+
runs += 1
|
|
112
|
+
const trace: ToolCall[] = []
|
|
113
|
+
const recorder = (ctx.get as (name: string) => unknown)('tasks') as TaskRecorder | undefined
|
|
114
|
+
const record = recorder?.start('agent-run', { question })
|
|
115
|
+
// The run stops when its task is cancelled or the caller's signal aborts.
|
|
116
|
+
const signal = AbortSignal.any(
|
|
117
|
+
[record?.signal, options?.signal].filter((s): s is AbortSignal => s !== undefined),
|
|
118
|
+
)
|
|
119
|
+
// Assigned inside the run's fiber; `as` keeps TypeScript from narrowing it to this first value.
|
|
120
|
+
let result = { status: 'budget_exceeded', steps: 0, trace } as RunResult
|
|
121
|
+
// Each run's `budget` is its own: runs may overlap (the production Assistant serves visitors at once), and a service name is shared unless isolated.
|
|
122
|
+
const task = ctx.isolate('budget').plugin({
|
|
123
|
+
name: `task-${runs}`,
|
|
124
|
+
inject: ['model', 'tools', 'memory'],
|
|
125
|
+
async apply(scope: Context) {
|
|
126
|
+
scope.provide('budget', { steps: 0, limit } satisfies Budget)
|
|
127
|
+
const budget = scope.budget
|
|
128
|
+
let toolResult: unknown
|
|
129
|
+
let looked = false
|
|
130
|
+
while (budget.steps < budget.limit) {
|
|
131
|
+
if (signal.aborted) {
|
|
132
|
+
result = { status: 'cancelled', steps: budget.steps, trace }
|
|
133
|
+
return
|
|
134
|
+
}
|
|
135
|
+
let step: Step
|
|
136
|
+
try {
|
|
137
|
+
step = await until(
|
|
138
|
+
scope.model.complete({
|
|
139
|
+
question,
|
|
140
|
+
step: budget.steps,
|
|
141
|
+
toolResult,
|
|
142
|
+
trace: [...trace],
|
|
143
|
+
tools: scope.tools.list().filter((tool) => allowed?.has(tool.name) ?? true),
|
|
144
|
+
signal,
|
|
145
|
+
}),
|
|
146
|
+
signal,
|
|
147
|
+
)
|
|
148
|
+
} catch (error) {
|
|
149
|
+
if (!(error instanceof Cancelled)) throw error
|
|
150
|
+
result = { status: 'cancelled', steps: budget.steps, trace }
|
|
151
|
+
return
|
|
152
|
+
}
|
|
153
|
+
budget.steps += 1
|
|
154
|
+
if (step.tool === undefined) {
|
|
155
|
+
const last = trace.at(-1)
|
|
156
|
+
const unseen =
|
|
157
|
+
answerAfter !== undefined &&
|
|
158
|
+
last !== undefined &&
|
|
159
|
+
last.tool !== answerAfter &&
|
|
160
|
+
!looked
|
|
161
|
+
if (!unseen) {
|
|
162
|
+
scope.memory.remember(`${question} => ${step.text}`)
|
|
163
|
+
result = { status: 'completed', output: step.text, steps: budget.steps, trace }
|
|
164
|
+
return
|
|
165
|
+
}
|
|
166
|
+
step = { tool: answerAfter, input: {} }
|
|
167
|
+
looked = true
|
|
168
|
+
} else looked = false
|
|
169
|
+
const call = record
|
|
170
|
+
? recorder?.start(`tool:${step.tool}`, step.input, { parent: record.id })
|
|
171
|
+
: undefined
|
|
172
|
+
try {
|
|
173
|
+
if (allowed !== undefined && !allowed.has(step.tool))
|
|
174
|
+
throw new Error(`no tool named "${step.tool}" is allowed in this run`)
|
|
175
|
+
toolResult = await until(
|
|
176
|
+
scope.tools.call(step.tool, step.input, {
|
|
177
|
+
signal,
|
|
178
|
+
...(options?.page === undefined ? {} : { page: options.page }),
|
|
179
|
+
}),
|
|
180
|
+
signal,
|
|
181
|
+
)
|
|
182
|
+
trace.push({
|
|
183
|
+
tool: step.tool,
|
|
184
|
+
input: step.input,
|
|
185
|
+
result: toolResult,
|
|
186
|
+
...(step.reasoning !== undefined ? { reasoning: step.reasoning } : {}),
|
|
187
|
+
})
|
|
188
|
+
call?.complete(toolResult)
|
|
189
|
+
} catch (error) {
|
|
190
|
+
if (error instanceof Cancelled) {
|
|
191
|
+
trace.push({ tool: step.tool, input: step.input, error: 'cancelled' })
|
|
192
|
+
call?.fail('the run was cancelled')
|
|
193
|
+
result = { status: 'cancelled', steps: budget.steps, trace }
|
|
194
|
+
return
|
|
195
|
+
}
|
|
196
|
+
toolResult = { error: message(error) }
|
|
197
|
+
trace.push({
|
|
198
|
+
tool: step.tool,
|
|
199
|
+
input: step.input,
|
|
200
|
+
error: message(error),
|
|
201
|
+
...(step.reasoning !== undefined ? { reasoning: step.reasoning } : {}),
|
|
202
|
+
})
|
|
203
|
+
call?.fail(error)
|
|
204
|
+
}
|
|
205
|
+
record?.progress({ steps: budget.steps, trace })
|
|
206
|
+
}
|
|
207
|
+
result = { status: 'budget_exceeded', steps: budget.steps, trace }
|
|
208
|
+
},
|
|
209
|
+
})
|
|
210
|
+
try {
|
|
211
|
+
await task.await()
|
|
212
|
+
} catch (error) {
|
|
213
|
+
record?.fail(error, { trace })
|
|
214
|
+
throw error
|
|
215
|
+
} finally {
|
|
216
|
+
await task.dispose()
|
|
217
|
+
}
|
|
218
|
+
if (result.status === 'completed')
|
|
219
|
+
record?.complete(result.output, { steps: result.steps, trace })
|
|
220
|
+
else if (result.status === 'cancelled') {
|
|
221
|
+
if (!record?.signal.aborted)
|
|
222
|
+
record?.fail('the run was cancelled', { steps: result.steps, trace })
|
|
223
|
+
} else if (result.status === 'budget_exceeded')
|
|
224
|
+
record?.fail('the run used its whole step budget', { steps: result.steps, trace })
|
|
225
|
+
return record ? { ...result, task: record.id } : result
|
|
226
|
+
},
|
|
227
|
+
} satisfies Agent)
|
|
228
|
+
},
|
|
229
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** The offline agent: a scripted model, a tool registry, in-process memory, and one child fiber per run. */
|
|
2
|
+
export {
|
|
3
|
+
type Agent,
|
|
4
|
+
type AgentConfig,
|
|
5
|
+
agent,
|
|
6
|
+
type Budget,
|
|
7
|
+
type RunResult,
|
|
8
|
+
type ToolCall,
|
|
9
|
+
} from './agent.ts'
|
|
10
|
+
export { type Memory, memory } from './memory.ts'
|
|
11
|
+
export {
|
|
12
|
+
type Model,
|
|
13
|
+
type ModelInput,
|
|
14
|
+
model,
|
|
15
|
+
type Rule,
|
|
16
|
+
type ScriptedModel,
|
|
17
|
+
type Step,
|
|
18
|
+
scripted,
|
|
19
|
+
} from './model.ts'
|
|
20
|
+
export { type CallOptions, type Tool, type Tools, tools } from './tools.ts'
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis'
|
|
2
|
+
|
|
3
|
+
/** Long-term memory for the agent. */
|
|
4
|
+
export interface Memory {
|
|
5
|
+
remember(text: string): void
|
|
6
|
+
recall(): string[]
|
|
7
|
+
size(): number
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare module '@deepseek-ai/cordis' {
|
|
11
|
+
interface Context {
|
|
12
|
+
memory: Memory
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** In-process memory. Replace it with a plugin backed by storage when you need persistence. */
|
|
17
|
+
export function memory(ctx: Context) {
|
|
18
|
+
const items: string[] = []
|
|
19
|
+
ctx.provide('memory', {
|
|
20
|
+
remember: (text) => void items.push(text),
|
|
21
|
+
recall: () => [...items],
|
|
22
|
+
size: () => items.length,
|
|
23
|
+
} satisfies Memory)
|
|
24
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis'
|
|
2
|
+
|
|
3
|
+
/** One model step: final text, or a tool to call with its input. `reasoning` is a thinking model's reasoning for the call; it must be given back on the next step, so the run keeps it. */
|
|
4
|
+
export type Step =
|
|
5
|
+
| { readonly text: string; readonly tool?: undefined }
|
|
6
|
+
| { readonly tool: string; readonly input: unknown; readonly reasoning?: string }
|
|
7
|
+
|
|
8
|
+
/** What a model sees at each step of a run. */
|
|
9
|
+
export interface ModelInput {
|
|
10
|
+
readonly question: string
|
|
11
|
+
/** 0 for the first step of a run. */
|
|
12
|
+
readonly step: number
|
|
13
|
+
/** The previous tool's result, if the previous step called one. */
|
|
14
|
+
readonly toolResult?: unknown
|
|
15
|
+
/** Every tool call of this run so far, in order: a real model rebuilds the conversation from it. */
|
|
16
|
+
readonly trace?: ReadonlyArray<{
|
|
17
|
+
readonly tool: string
|
|
18
|
+
readonly input: unknown
|
|
19
|
+
readonly result?: unknown
|
|
20
|
+
readonly error?: string
|
|
21
|
+
readonly reasoning?: string
|
|
22
|
+
}>
|
|
23
|
+
/** The tools the model may call. */
|
|
24
|
+
readonly tools?: ReadonlyArray<{
|
|
25
|
+
readonly name: string
|
|
26
|
+
readonly description: string
|
|
27
|
+
/** The JSON Schema of the tool's input, when it has one. */
|
|
28
|
+
readonly parameters?: Readonly<Record<string, unknown>>
|
|
29
|
+
}>
|
|
30
|
+
/** Aborts when the run is cancelled: a provider that can stop its request passes this on. */
|
|
31
|
+
readonly signal?: AbortSignal
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** What the agent needs from a model. Replace this plugin with a real provider when you have one. */
|
|
35
|
+
export interface Model {
|
|
36
|
+
complete(input: ModelInput): Promise<Step>
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** A rule of the scripted model: a step for the input, or `undefined` when it does not apply. */
|
|
40
|
+
export type Rule = (input: ModelInput) => Step | undefined
|
|
41
|
+
|
|
42
|
+
/** The deterministic model. Other plugins teach it rules for their commands, so whole flows are tested without a network. */
|
|
43
|
+
export interface ScriptedModel extends Model {
|
|
44
|
+
/** Add a rule, tried before the built-in ones. Returns the function that removes it. */
|
|
45
|
+
teach(rule: Rule): () => void
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
declare module '@deepseek-ai/cordis' {
|
|
49
|
+
interface Context {
|
|
50
|
+
model: Model
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const builtIn: Rule[] = [
|
|
55
|
+
({ toolResult, step }) => {
|
|
56
|
+
if (step === 0) return undefined
|
|
57
|
+
// A failed call comes back as `{ error }`: say what failed, not "[object Object]".
|
|
58
|
+
const failed = typeof toolResult === 'object' && toolResult !== null && 'error' in toolResult
|
|
59
|
+
return {
|
|
60
|
+
text: failed
|
|
61
|
+
? `That did not work: ${String(toolResult.error)}.`
|
|
62
|
+
: `The answer is ${String(toolResult)}.`,
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
({ question }) => {
|
|
66
|
+
const sum = /^add\s+(-?\d+)\s+(-?\d+)$/.exec(question.trim())
|
|
67
|
+
return sum ? { tool: 'add', input: [Number(sum[1]), Number(sum[2])] } : undefined
|
|
68
|
+
},
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
/** A deterministic model: no keys, no network, the same answer every time. */
|
|
72
|
+
export function model(ctx: Context) {
|
|
73
|
+
const taught: Rule[] = []
|
|
74
|
+
ctx.provide('model', {
|
|
75
|
+
teach(rule) {
|
|
76
|
+
taught.push(rule)
|
|
77
|
+
return () => void taught.splice(taught.indexOf(rule), 1)
|
|
78
|
+
},
|
|
79
|
+
complete(input) {
|
|
80
|
+
for (const rule of [...taught, ...builtIn]) {
|
|
81
|
+
const step = rule(input)
|
|
82
|
+
if (step) return Promise.resolve(step)
|
|
83
|
+
}
|
|
84
|
+
return Promise.resolve({ text: `You said: ${input.question}` })
|
|
85
|
+
},
|
|
86
|
+
} satisfies ScriptedModel)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** The scripted model, when the app runs one (a real provider has no `teach`). */
|
|
90
|
+
export function scripted(model: Model | undefined): ScriptedModel | undefined {
|
|
91
|
+
return model && typeof (model as Partial<ScriptedModel>).teach === 'function'
|
|
92
|
+
? (model as ScriptedModel)
|
|
93
|
+
: undefined
|
|
94
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@acryldev/agent",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "An offline agent: deterministic model, tools, memory, and a child fiber per run that holds the run's step budget.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/acryldev/acryl.git",
|
|
9
|
+
"directory": "plugins/agent"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/acryldev/acryl/tree/main/plugins/agent#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/acryldev/acryl/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": "^22.19.0 || >=24.0.0"
|
|
18
|
+
},
|
|
19
|
+
"main": "./lib/index.js",
|
|
20
|
+
"types": "./lib/types/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./lib/types/index.d.ts",
|
|
24
|
+
"default": "./lib/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@deepseek-ai/cordis": "^4.0.2"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@deepseek-ai/cordis": "4.0.4",
|
|
34
|
+
"@types/node": "^22.20.0",
|
|
35
|
+
"tsdown": "0.22.2",
|
|
36
|
+
"typescript": "6.0.3"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsdown && tsc -p tsconfig.json --emitDeclarationOnly"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "agent",
|
|
3
|
+
"description": "An offline agent: deterministic model, tools, memory, and a child fiber per run that holds the run's step budget.",
|
|
4
|
+
"requires": [],
|
|
5
|
+
"inject": ["model", "tools", "memory"],
|
|
6
|
+
"provides": ["agent", "model", "tools", "memory"],
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@deepseek-ai/cordis": "4.0.4"
|
|
9
|
+
},
|
|
10
|
+
"entries": {
|
|
11
|
+
"": "index.ts"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis'
|
|
2
|
+
|
|
3
|
+
/** What a run passes with each call: its signal, and the door's id of the page it was asked from (the page tools drive only that page). */
|
|
4
|
+
export interface CallOptions {
|
|
5
|
+
readonly signal?: AbortSignal
|
|
6
|
+
readonly page?: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** One tool: what it does (for the model) and how to run it. */
|
|
10
|
+
export interface Tool {
|
|
11
|
+
readonly description: string
|
|
12
|
+
/** The JSON Schema of the input (an object schema), sent to a real model so it knows which fields the tool takes. A tool without one takes any object. */
|
|
13
|
+
readonly parameters?: Readonly<Record<string, unknown>>
|
|
14
|
+
/** `options.signal` aborts when the run is cancelled; a tool that can stop its work listens to it. `options.page` is the page the run was asked from, when it was. */
|
|
15
|
+
run(input: unknown, options?: CallOptions): unknown | Promise<unknown>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** The tool registry. A plugin registers its tools inside `ctx.effect`, so they leave with it. */
|
|
19
|
+
export interface Tools {
|
|
20
|
+
/** Register a tool. Returns the function that removes it. */
|
|
21
|
+
register(name: string, tool: Tool): () => void
|
|
22
|
+
list(): Array<{
|
|
23
|
+
name: string
|
|
24
|
+
description: string
|
|
25
|
+
parameters?: Readonly<Record<string, unknown>>
|
|
26
|
+
}>
|
|
27
|
+
call(name: string, input: unknown, options?: CallOptions): Promise<unknown>
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
declare module '@deepseek-ai/cordis' {
|
|
31
|
+
interface Context {
|
|
32
|
+
tools: Tools
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Provides the registry, with one example tool (`add`). */
|
|
37
|
+
export function tools(ctx: Context) {
|
|
38
|
+
const table = new Map<string, Tool>()
|
|
39
|
+
const registry: Tools = {
|
|
40
|
+
register(name, tool) {
|
|
41
|
+
if (table.has(name)) throw new Error(`tool "${name}" is already registered`)
|
|
42
|
+
table.set(name, tool)
|
|
43
|
+
return () => void table.delete(name)
|
|
44
|
+
},
|
|
45
|
+
list: () =>
|
|
46
|
+
[...table.entries()].map(([name, tool]) => ({
|
|
47
|
+
name,
|
|
48
|
+
description: tool.description,
|
|
49
|
+
...(tool.parameters === undefined ? {} : { parameters: tool.parameters }),
|
|
50
|
+
})),
|
|
51
|
+
async call(name, input, options) {
|
|
52
|
+
const tool = table.get(name)
|
|
53
|
+
if (!tool) throw new Error(`unknown tool "${name}"`)
|
|
54
|
+
return await tool.run(input, options)
|
|
55
|
+
},
|
|
56
|
+
}
|
|
57
|
+
ctx.provide('tools', registry)
|
|
58
|
+
ctx.effect(() =>
|
|
59
|
+
registry.register('add', {
|
|
60
|
+
description: 'Add two numbers: input [a, b].',
|
|
61
|
+
run: (input) => {
|
|
62
|
+
const [a = 0, b = 0] = Array.isArray(input) ? (input as number[]) : []
|
|
63
|
+
return a + b
|
|
64
|
+
},
|
|
65
|
+
}),
|
|
66
|
+
)
|
|
67
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 acrylblends
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|