wao 0.41.3 → 0.41.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc-cjs +5 -0
- package/.babelrc-esm +5 -0
- package/.gitmodules +4 -0
- package/.prettierrc +6 -0
- package/README.md +90 -0
- package/app/.eslintrc.json +3 -0
- package/app/.mocharc.cjs +6 -0
- package/app/arweave.mjs +87 -0
- package/app/components/Footer.js +76 -0
- package/app/components/Global.js +1128 -0
- package/app/components/Header.js +306 -0
- package/app/components/Left.js +28 -0
- package/app/components/Logo.js +34 -0
- package/app/components/Middle.js +37 -0
- package/app/components/Sidebar.js +93 -0
- package/app/components/Tags.js +42 -0
- package/app/components/editor/Editor.js +322 -0
- package/app/components/editor/FilePath.js +42 -0
- package/app/components/editor/MonacoEditor.js +44 -0
- package/app/components/left/LeftMessages.js +85 -0
- package/app/components/left/LeftModules.js +86 -0
- package/app/components/left/LeftNetworks.js +438 -0
- package/app/components/left/LeftProcesses.js +98 -0
- package/app/components/left/LeftProjects.js +397 -0
- package/app/components/left/LeftTests.js +189 -0
- package/app/components/middle/MiddleBlocks.js +79 -0
- package/app/components/middle/MiddleEntity.js +16 -0
- package/app/components/middle/MiddleEntityAccount.js +264 -0
- package/app/components/middle/MiddleEntityAssignment.js +104 -0
- package/app/components/middle/MiddleEntityBlock.js +148 -0
- package/app/components/middle/MiddleEntityMessage.js +430 -0
- package/app/components/middle/MiddleEntityModule.js +183 -0
- package/app/components/middle/MiddleEntityProcess.js +323 -0
- package/app/components/middle/MiddleEntityTx.js +211 -0
- package/app/components/middle/MiddleMessages.js +87 -0
- package/app/components/middle/MiddleModules.js +89 -0
- package/app/components/middle/MiddleNetworks.js +516 -0
- package/app/components/middle/MiddleProcesses.js +87 -0
- package/app/components/middle/MiddleTests.js +134 -0
- package/app/components/modals/CreateFileModal.js +115 -0
- package/app/components/modals/CreateFolderModal.js +83 -0
- package/app/components/modals/CreateProjectModal.js +63 -0
- package/app/components/modals/FSModal.js +141 -0
- package/app/components/modals/ImportModal.js +105 -0
- package/app/components/modals/LaunchNetworkModal.js +95 -0
- package/app/components/modals/Modal.js +38 -0
- package/app/components/modals/ProxyModal.js +122 -0
- package/app/components/modals/RenameFileModal.js +95 -0
- package/app/components/styles/EditorScrollbarStyle.js +29 -0
- package/app/components/styles/EntityScrollbarStyle.js +29 -0
- package/app/components/styles/GlobalStyle.js +102 -0
- package/app/components/styles/XtermStyle.js +37 -0
- package/app/components/terminal/Terminal.js +132 -0
- package/app/components/terminal/Xterm.js +160 -0
- package/app/components/ui/avatar.jsx +49 -0
- package/app/components/ui/checkbox.jsx +17 -0
- package/app/components/ui/close-button.jsx +20 -0
- package/app/components/ui/color-mode.jsx +61 -0
- package/app/components/ui/dialog.jsx +54 -0
- package/app/components/ui/drawer.jsx +44 -0
- package/app/components/ui/field.jsx +22 -0
- package/app/components/ui/input-group.jsx +39 -0
- package/app/components/ui/popover.jsx +49 -0
- package/app/components/ui/provider.jsx +12 -0
- package/app/components/ui/radio.jsx +17 -0
- package/app/components/ui/slider.jsx +107 -0
- package/app/components/ui/toaster.jsx +69 -0
- package/app/components/ui/tooltip.jsx +35 -0
- package/app/index.js +10 -0
- package/app/jsconfig.json +7 -0
- package/app/lib/GithubCSS.js +1218 -0
- package/app/lib/addon-fit.js +72 -0
- package/app/lib/data.js +31 -0
- package/app/lib/github-markdown.css +1169 -0
- package/app/lib/global.js +1 -0
- package/app/lib/guide.js +82 -0
- package/app/lib/hub.js +109 -0
- package/app/lib/scripts.js +47 -0
- package/app/lib/store.js +34 -0
- package/app/lib/use.js +64 -0
- package/app/lib/utils.js +387 -0
- package/app/lib/webrtc.js +217 -0
- package/app/next.config.js +25 -0
- package/app/package.json +62 -0
- package/app/pages/404.js +9 -0
- package/app/pages/_app.js +10 -0
- package/app/pages/_document.js +14 -0
- package/app/pages/index.js +121 -0
- package/app/playwright.config.mjs +41 -0
- package/app/proxy.mjs +21 -0
- package/app/public/assets/cover.png +0 -0
- package/app/public/blueprints/apm.lua +91 -0
- package/app/public/blueprints/arena.lua +345 -0
- package/app/public/blueprints/arns.lua +318 -0
- package/app/public/blueprints/chat.lua +210 -0
- package/app/public/blueprints/chatroom.lua +56 -0
- package/app/public/blueprints/patch-legacy-reply.lua +13 -0
- package/app/public/blueprints/staking.lua +93 -0
- package/app/public/blueprints/token.lua +298 -0
- package/app/public/blueprints/voting.lua +45 -0
- package/app/public/favicon.ico +0 -0
- package/app/public/logo.png +0 -0
- package/cli-esm.js +55 -0
- package/cli.js +54 -0
- package/devnet/app/api.js +129 -0
- package/devnet/app/components/layout.js +89 -0
- package/devnet/app/components/pagination.js +144 -0
- package/devnet/app/components/search.js +159 -0
- package/devnet/app/components/table.js +124 -0
- package/devnet/app/components/tags.js +89 -0
- package/devnet/app/index.html +14 -0
- package/devnet/app/main.js +215 -0
- package/devnet/app/router.js +59 -0
- package/devnet/app/state.js +19 -0
- package/devnet/app/style.css +1606 -0
- package/devnet/app/utils.js +77 -0
- package/devnet/app/views/blocks.js +75 -0
- package/devnet/app/views/dashboard.js +127 -0
- package/devnet/app/views/entity.js +1473 -0
- package/devnet/app/views/messages.js +90 -0
- package/devnet/app/views/modules.js +165 -0
- package/devnet/app/views/processes.js +90 -0
- package/devnet/app/views/schedulers.js +90 -0
- package/devnet/app/views/transactions.js +88 -0
- package/devnet/migrations/0001_initial.sql +51 -0
- package/devnet/package.json +26 -0
- package/devnet/playwright.config.js +7 -0
- package/devnet/src/cu-worker.js +166 -0
- package/devnet/src/index.js +309 -0
- package/devnet/vite.config.js +17 -0
- package/devnet/vitest.config.js +10 -0
- package/devnet/wrangler-cu.toml +32 -0
- package/devnet/wrangler.toml +38 -0
- package/dhfs-tutorial-app/package.json +15 -0
- package/dist/esm/workspace/dashboard/public/favicon.png +0 -0
- package/dist/esm/workspace/src/counter.lua +14 -0
- package/dist/package.json +82 -0
- package/hb.sh +18 -0
- package/hbsig/.babelrc-cjs +5 -0
- package/hbsig/.babelrc-esm +5 -0
- package/hbsig/README.md +1 -0
- package/hbsig/dist/cjs/bin_to_str.js +44 -0
- package/hbsig/dist/cjs/collect-body-keys.js +470 -0
- package/hbsig/dist/cjs/commit.js +330 -0
- package/hbsig/dist/cjs/encode-array-item.js +110 -0
- package/hbsig/dist/cjs/encode-utils.js +242 -0
- package/hbsig/dist/cjs/encode.js +1365 -0
- package/hbsig/dist/cjs/erl_json.js +326 -0
- package/hbsig/dist/cjs/erl_str.js +1042 -0
- package/hbsig/dist/cjs/flat.js +279 -0
- package/hbsig/dist/cjs/http-message-signatures/httpbis.js +489 -0
- package/hbsig/dist/cjs/http-message-signatures/index.js +25 -0
- package/hbsig/dist/cjs/http-message-signatures/structured-header.js +129 -0
- package/hbsig/dist/cjs/httpsig.js +861 -0
- package/hbsig/dist/cjs/id.js +470 -0
- package/hbsig/dist/cjs/index.js +174 -0
- package/hbsig/dist/cjs/nocrypto.js +51 -0
- package/hbsig/dist/cjs/parser.js +201 -0
- package/hbsig/dist/cjs/send-utils.js +1231 -0
- package/hbsig/dist/cjs/send.js +211 -0
- package/hbsig/dist/cjs/signer-utils.js +494 -0
- package/hbsig/dist/cjs/signer.js +436 -0
- package/hbsig/dist/cjs/structured.js +515 -0
- package/hbsig/dist/cjs/test.js +12 -0
- package/hbsig/dist/cjs/utils.js +44 -0
- package/hbsig/dist/esm/bin_to_str.js +46 -0
- package/hbsig/dist/esm/collect-body-keys.js +436 -0
- package/hbsig/dist/esm/commit.js +219 -0
- package/hbsig/dist/esm/encode-array-item.js +112 -0
- package/hbsig/dist/esm/encode-utils.js +191 -0
- package/hbsig/dist/esm/encode.js +1256 -0
- package/hbsig/dist/esm/erl_json.js +292 -0
- package/hbsig/dist/esm/erl_str.js +1144 -0
- package/hbsig/dist/esm/flat.js +250 -0
- package/hbsig/dist/esm/http-message-signatures/httpbis.js +438 -0
- package/hbsig/dist/esm/http-message-signatures/index.js +4 -0
- package/hbsig/dist/esm/http-message-signatures/structured-header.js +105 -0
- package/hbsig/dist/esm/httpsig.js +866 -0
- package/hbsig/dist/esm/id.js +459 -0
- package/hbsig/dist/esm/index.js +13 -0
- package/hbsig/dist/esm/nocrypto.js +4 -0
- package/hbsig/dist/esm/package.json +3 -0
- package/hbsig/dist/esm/parser.js +171 -0
- package/hbsig/dist/esm/send-utils.js +1132 -0
- package/hbsig/dist/esm/send.js +142 -0
- package/hbsig/dist/esm/signer-utils.js +375 -0
- package/hbsig/dist/esm/signer.js +312 -0
- package/hbsig/dist/esm/structured.js +496 -0
- package/hbsig/dist/esm/test.js +2 -0
- package/hbsig/dist/esm/utils.js +29 -0
- package/hbsig/dist/package.json +39 -0
- package/hbsig/make.js +36 -0
- package/hbsig/package.json +39 -0
- package/hbsig/src/bin_to_str.js +46 -0
- package/hbsig/src/collect-body-keys.js +436 -0
- package/hbsig/src/commit.js +219 -0
- package/hbsig/src/encode-array-item.js +112 -0
- package/hbsig/src/encode-utils.js +191 -0
- package/hbsig/src/encode.js +1256 -0
- package/hbsig/src/erl_json.js +292 -0
- package/hbsig/src/erl_str.js +1144 -0
- package/hbsig/src/flat.js +250 -0
- package/hbsig/src/http-message-signatures/httpbis.js +438 -0
- package/hbsig/src/http-message-signatures/index.js +4 -0
- package/hbsig/src/http-message-signatures/structured-header.js +105 -0
- package/hbsig/src/httpsig.js +866 -0
- package/hbsig/src/id.js +459 -0
- package/hbsig/src/index.js +13 -0
- package/hbsig/src/nocrypto.js +4 -0
- package/hbsig/src/parser.js +171 -0
- package/hbsig/src/send-utils.js +1132 -0
- package/hbsig/src/send.js +142 -0
- package/hbsig/src/signer-utils.js +375 -0
- package/hbsig/src/signer.js +312 -0
- package/hbsig/src/structured.js +496 -0
- package/hbsig/src/test.js +2 -0
- package/hbsig/src/utils.js +29 -0
- package/lp/index.html +25 -0
- package/lp/package.json +19 -0
- package/lp/public/cover.png +0 -0
- package/lp/public/favicon.ico +0 -0
- package/lp/public/favicon.png +0 -0
- package/lp/public/images/book.jpg +0 -0
- package/lp/public/images/dashboard.png +0 -0
- package/lp/public/images/devnet.png +0 -0
- package/lp/public/images/hero-bg.png +0 -0
- package/lp/public/images/hyperadd.png +0 -0
- package/lp/public/images/message-flow.png +0 -0
- package/lp/public/images/mobile.png +0 -0
- package/lp/public/images/og-cover.png +0 -0
- package/lp/public/images/scan.png +0 -0
- package/lp/public/images/wao-hub.png +0 -0
- package/lp/public/images/wao-web.png +0 -0
- package/lp/public/logo.png +0 -0
- package/lp/src/App.jsx +29 -0
- package/lp/src/components/CodeBlock.jsx +37 -0
- package/lp/src/components/CodeBlock.module.css +89 -0
- package/lp/src/components/Footer.jsx +22 -0
- package/lp/src/components/Footer.module.css +60 -0
- package/lp/src/components/Nav.jsx +80 -0
- package/lp/src/components/Nav.module.css +177 -0
- package/lp/src/components/SectionWrapper.jsx +15 -0
- package/lp/src/hooks/useReveal.js +25 -0
- package/lp/src/hooks/useScrolled.js +14 -0
- package/lp/src/main.jsx +10 -0
- package/lp/src/sections/Book.jsx +60 -0
- package/lp/src/sections/Book.module.css +204 -0
- package/lp/src/sections/Browser.jsx +46 -0
- package/lp/src/sections/Browser.module.css +67 -0
- package/lp/src/sections/Devnet.jsx +55 -0
- package/lp/src/sections/Devnet.module.css +136 -0
- package/lp/src/sections/GetStarted.jsx +51 -0
- package/lp/src/sections/GetStarted.module.css +128 -0
- package/lp/src/sections/Hero.jsx +67 -0
- package/lp/src/sections/Hero.module.css +202 -0
- package/lp/src/sections/HyperADD.jsx +46 -0
- package/lp/src/sections/HyperADD.module.css +113 -0
- package/lp/src/sections/SDK.jsx +90 -0
- package/lp/src/sections/SDK.module.css +122 -0
- package/lp/src/sections/Testing.jsx +47 -0
- package/lp/src/sections/Testing.module.css +124 -0
- package/lp/src/sections/Vision.jsx +93 -0
- package/lp/src/sections/Vision.module.css +147 -0
- package/lp/src/styles/globals.css +285 -0
- package/lp/src/utils/scrollTo.js +4 -0
- package/lp/vite.config.js +7 -0
- package/make.js +39 -0
- package/package.json +17 -12
- package/patches/@permaweb+ao-loader+0.0.44.patch +64 -0
- package/plan.md +435 -0
- package/rebar.lock +1 -0
- package/src/accounts-web.js +128 -0
- package/src/accounts.js +124 -0
- package/src/adaptor-base.js +622 -0
- package/src/adaptor-cf.js +11 -0
- package/src/adaptor-web.js +11 -0
- package/src/adaptor.js +10 -0
- package/src/ao-loader.js +30660 -0
- package/src/ao.js +1173 -0
- package/src/aoconnect-base.js +1098 -0
- package/src/aoconnect-cf.js +9 -0
- package/src/aoconnect-web.js +8 -0
- package/src/aoconnect.js +8 -0
- package/src/aos_wamr.js +1 -0
- package/src/ar-remote.js +87 -0
- package/src/ar.js +276 -0
- package/src/armem-base.js +529 -0
- package/src/armem-cf.js +67 -0
- package/src/armem-web.js +19 -0
- package/src/armem.js +26 -0
- package/src/bao.js +141 -0
- package/src/bar.js +366 -0
- package/src/build.js +7 -0
- package/src/bundler.js +119 -0
- package/src/car.js +10 -0
- package/src/cf-env.js +29 -0
- package/src/cf.js +11 -0
- package/src/cli.js +561 -0
- package/src/compress.js +112 -0
- package/src/create.js +415 -0
- package/src/devs.js +86 -0
- package/src/dirname.js +1 -0
- package/src/dodb.js +26 -0
- package/src/erl_json.js +289 -0
- package/src/erl_str.js +1139 -0
- package/src/gql.js +229 -0
- package/src/hb.js +967 -0
- package/src/helpers.js +203 -0
- package/src/http.js +619 -0
- package/src/hub/bundler.js +123 -0
- package/src/hub/cu.js +74 -0
- package/src/hub/fs.js +157 -0
- package/src/hub/index.js +85 -0
- package/src/hub/utils.js +64 -0
- package/src/hub/ws-proxy.js +67 -0
- package/src/hyper-aos.js +1 -0
- package/src/hyperbeam-server.js +21 -0
- package/src/hyperbeam.js +585 -0
- package/src/index.js +5 -0
- package/src/keygen.js +47 -0
- package/src/lfdb.js +67 -0
- package/src/lua/aos.wasm +0 -0
- package/src/lua/aos2_0_1.js +1 -0
- package/src/lua/aos2_0_1.wasm +0 -0
- package/src/lua/aos2_0_3.js +1 -0
- package/src/lua/aos2_0_3.wasm +0 -0
- package/src/lua/aos2_0_4_32.js +1 -0
- package/src/lua/aos2_0_4_32.wasm +0 -0
- package/src/lua/aos2_0_6.wasm +0 -0
- package/src/lua/apm.lua +61 -0
- package/src/lua/llama.wasm +0 -0
- package/src/lua/process.wasm +0 -0
- package/src/lua/sqlite.js +1 -0
- package/src/lua/sqlite.wasm +0 -0
- package/src/lua/weavedb_mock.lua +44 -0
- package/src/lua/weavedrive.lua +53 -0
- package/src/run.js +25 -0
- package/src/server.js +173 -0
- package/src/storage-multi.js +183 -0
- package/src/tao.js +12 -0
- package/src/tar.js +10 -0
- package/src/test.js +42 -0
- package/src/tgql-d1.js +407 -0
- package/src/tgql.js +310 -0
- package/src/toerl.js +162 -0
- package/src/utils.js +777 -0
- package/src/wao.js +29 -0
- package/src/waosm/README.md +81 -0
- package/src/waosm/waosm.d.ts +40 -0
- package/src/waosm/waosm.js +240 -0
- package/src/waosm/waosm_bg.wasm +0 -0
- package/src/waosm/waosm_bg.wasm.d.ts +8 -0
- package/src/waosm-node/README.md +81 -0
- package/src/waosm-node/waosm.d.ts +8 -0
- package/src/waosm-node/waosm.js +4 -0
- package/src/waosm-node/waosm_bg.js +147 -0
- package/src/waosm-node/waosm_bg.wasm +0 -0
- package/src/waosm-node/waosm_bg.wasm.d.ts +8 -0
- package/src/waosm-node/waosm_bg.wasm.js +14 -0
- package/src/waosm-node.js +9 -0
- package/src/war.js +10 -0
- package/src/weavedrive.js +376 -0
- package/src/web.js +11 -0
- package/src/workspace/.mcp.json +8 -0
- package/src/workspace/CLAUDE.md +258 -0
- package/src/workspace/README.md +85 -0
- package/src/workspace/dashboard/index.html +163 -0
- package/src/workspace/dashboard/package.json +18 -0
- package/src/workspace/dashboard/public/favicon.ico +0 -0
- package/src/workspace/dashboard/public/favicon.png +0 -0
- package/src/workspace/dashboard/server.js +224 -0
- package/src/workspace/dashboard/src/App.jsx +2350 -0
- package/{cjs/workspace/frontend → src/workspace/dashboard}/vite.config.js +6 -0
- package/src/workspace/package.json +18 -0
- package/src/workspace/src/counter.lua +14 -0
- package/tsconfig.json +18 -0
- package/types/index.d.ts +329 -0
- package/waollama/.eslintrc.json +3 -0
- package/waollama/README.md +19 -0
- package/waollama/arweave.mjs +87 -0
- package/waollama/components/ui/avatar.jsx +49 -0
- package/waollama/components/ui/checkbox.jsx +17 -0
- package/waollama/components/ui/close-button.jsx +20 -0
- package/waollama/components/ui/color-mode.jsx +61 -0
- package/waollama/components/ui/dialog.jsx +54 -0
- package/waollama/components/ui/drawer.jsx +44 -0
- package/waollama/components/ui/field.jsx +22 -0
- package/waollama/components/ui/input-group.jsx +39 -0
- package/waollama/components/ui/popover.jsx +49 -0
- package/waollama/components/ui/provider.jsx +12 -0
- package/waollama/components/ui/radio.jsx +17 -0
- package/waollama/components/ui/slider.jsx +107 -0
- package/waollama/components/ui/tooltip.jsx +35 -0
- package/waollama/index.js +10 -0
- package/waollama/jsconfig.json +7 -0
- package/waollama/lib/ao-loader.js +30654 -0
- package/waollama/lib/client.js +1 -0
- package/waollama/lib/wasm.js +1 -0
- package/waollama/next.config.js +25 -0
- package/waollama/package.json +43 -0
- package/waollama/pages/404.js +9 -0
- package/waollama/pages/_app.js +9 -0
- package/waollama/pages/_document.js +14 -0
- package/waollama/pages/index.js +212 -0
- package/waollama/playwright.config.js +31 -0
- package/waollama/proxy.mjs +21 -0
- package/waollama/public/favicon.ico +0 -0
- package/waollama/public/human.png +0 -0
- package/waollama/public/llama.png +0 -0
- package/waosm/Cargo.toml +11 -0
- package/waosm/README.md +81 -0
- package/waosm/compress.js +112 -0
- package/waosm/make.js +33 -0
- package/waosm/package.json +10 -0
- package/waosm/src/lib.rs +180 -0
- package/waosm/test.js +16 -0
- package/cjs/workspace/.claude/agents/builder.md +0 -99
- package/cjs/workspace/.claude/agents/device-builder.md +0 -86
- package/cjs/workspace/.claude/agents/tester.md +0 -90
- package/cjs/workspace/.claude/mcp/dashboard/server.js +0 -128
- package/cjs/workspace/.claude/rules/deploy.md +0 -45
- package/cjs/workspace/.claude/rules/frontend.md +0 -69
- package/cjs/workspace/.claude/rules/hyperbeam.md +0 -104
- package/cjs/workspace/.claude/rules/lua.md +0 -108
- package/cjs/workspace/.claude/rules/testing.md +0 -257
- package/cjs/workspace/.claude/settings.json +0 -109
- package/cjs/workspace/.claude/skills/build/SKILL.md +0 -214
- package/cjs/workspace/.claude/skills/build-aos/SKILL.md +0 -129
- package/cjs/workspace/.claude/skills/build-device/SKILL.md +0 -192
- package/cjs/workspace/.claude/skills/build-frontend/SKILL.md +0 -134
- package/cjs/workspace/.claude/skills/build-module/SKILL.md +0 -281
- package/cjs/workspace/.claude/skills/create-aos/SKILL.md +0 -63
- package/cjs/workspace/.claude/skills/create-device/SKILL.md +0 -87
- package/cjs/workspace/.claude/skills/create-module/SKILL.md +0 -162
- package/cjs/workspace/.claude/skills/debug/SKILL.md +0 -57
- package/cjs/workspace/.claude/skills/deploy/SKILL.md +0 -85
- package/cjs/workspace/.claude/skills/dev/SKILL.md +0 -32
- package/cjs/workspace/.claude/skills/plan/SKILL.md +0 -176
- package/cjs/workspace/.claude/skills/readme/SKILL.md +0 -186
- package/cjs/workspace/.claude/skills/report/SKILL.md +0 -49
- package/cjs/workspace/.claude/skills/team/SKILL.md +0 -101
- package/cjs/workspace/.claude/skills/test/SKILL.md +0 -56
- package/cjs/workspace/.claude/skills/test-device/SKILL.md +0 -114
- package/cjs/workspace/.claude/skills/test-e2e/SKILL.md +0 -103
- package/cjs/workspace/.claude/skills/test-hb/SKILL.md +0 -76
- package/cjs/workspace/.claude/skills/validate/SKILL.md +0 -96
- package/cjs/workspace/.claude/skills/validate/scripts/check-lua.sh +0 -41
- package/cjs/workspace/docs/aos-lua.md +0 -428
- package/cjs/workspace/docs/debug.md +0 -230
- package/cjs/workspace/docs/hyperbeam-dev.md +0 -606
- package/cjs/workspace/docs/hyperbeam-devices.md +0 -618
- package/cjs/workspace/docs/wao-sdk.md +0 -807
- package/cjs/workspace/frontend/e2e/.gitkeep +0 -0
- package/cjs/workspace/frontend/index.html +0 -12
- package/cjs/workspace/frontend/package.json +0 -24
- package/cjs/workspace/frontend/playwright.config.js +0 -10
- package/cjs/workspace/frontend/src/App.jsx +0 -24
- package/cjs/workspace/frontend/test/.gitkeep +0 -0
- package/cjs/workspace/frontend/vitest.config.js +0 -10
- package/cjs/workspace/scripts/deploy.js +0 -140
- package/cjs/workspace/scripts/keygen.js +0 -52
- package/cjs/workspace/test/aos.test.js +0 -98
- package/cjs/workspace/test/hyperbeam.test.js +0 -80
- package/esm/compiler/native +0 -0
- package/esm/workspace/.claude/agents/builder.md +0 -99
- package/esm/workspace/.claude/agents/device-builder.md +0 -86
- package/esm/workspace/.claude/agents/tester.md +0 -90
- package/esm/workspace/.claude/mcp/dashboard/server.js +0 -128
- package/esm/workspace/.claude/rules/deploy.md +0 -45
- package/esm/workspace/.claude/rules/frontend.md +0 -69
- package/esm/workspace/.claude/rules/hyperbeam.md +0 -104
- package/esm/workspace/.claude/rules/lua.md +0 -108
- package/esm/workspace/.claude/rules/testing.md +0 -257
- package/esm/workspace/.claude/settings.json +0 -109
- package/esm/workspace/.claude/skills/build/SKILL.md +0 -214
- package/esm/workspace/.claude/skills/build-aos/SKILL.md +0 -129
- package/esm/workspace/.claude/skills/build-device/SKILL.md +0 -192
- package/esm/workspace/.claude/skills/build-frontend/SKILL.md +0 -134
- package/esm/workspace/.claude/skills/build-module/SKILL.md +0 -281
- package/esm/workspace/.claude/skills/create-aos/SKILL.md +0 -63
- package/esm/workspace/.claude/skills/create-device/SKILL.md +0 -87
- package/esm/workspace/.claude/skills/create-module/SKILL.md +0 -162
- package/esm/workspace/.claude/skills/debug/SKILL.md +0 -57
- package/esm/workspace/.claude/skills/deploy/SKILL.md +0 -85
- package/esm/workspace/.claude/skills/dev/SKILL.md +0 -32
- package/esm/workspace/.claude/skills/plan/SKILL.md +0 -176
- package/esm/workspace/.claude/skills/readme/SKILL.md +0 -186
- package/esm/workspace/.claude/skills/report/SKILL.md +0 -49
- package/esm/workspace/.claude/skills/team/SKILL.md +0 -101
- package/esm/workspace/.claude/skills/test/SKILL.md +0 -56
- package/esm/workspace/.claude/skills/test-device/SKILL.md +0 -114
- package/esm/workspace/.claude/skills/test-e2e/SKILL.md +0 -103
- package/esm/workspace/.claude/skills/test-hb/SKILL.md +0 -76
- package/esm/workspace/.claude/skills/validate/SKILL.md +0 -96
- package/esm/workspace/.claude/skills/validate/scripts/check-lua.sh +0 -41
- package/esm/workspace/docs/aos-lua.md +0 -428
- package/esm/workspace/docs/debug.md +0 -230
- package/esm/workspace/docs/hyperbeam-dev.md +0 -606
- package/esm/workspace/docs/hyperbeam-devices.md +0 -618
- package/esm/workspace/docs/wao-sdk.md +0 -807
- package/esm/workspace/frontend/e2e/.gitkeep +0 -0
- package/esm/workspace/frontend/index.html +0 -12
- package/esm/workspace/frontend/package.json +0 -24
- package/esm/workspace/frontend/playwright.config.js +0 -10
- package/esm/workspace/frontend/src/App.jsx +0 -24
- package/esm/workspace/frontend/src/main.jsx +0 -9
- package/esm/workspace/frontend/test/.gitkeep +0 -0
- package/esm/workspace/frontend/vite.config.js +0 -6
- package/esm/workspace/frontend/vitest.config.js +0 -10
- package/esm/workspace/scripts/deploy.js +0 -140
- package/esm/workspace/scripts/keygen.js +0 -52
- package/esm/workspace/test/aos.test.js +0 -98
- package/esm/workspace/test/hyperbeam.test.js +0 -80
- /package/{cjs/workspace/dashboard/public → devnet/app}/favicon.ico +0 -0
- /package/{cjs/workspace → dhfs-tutorial-app}/src/counter.lua +0 -0
- /package/{cjs → dist/cjs}/accounts-web.js +0 -0
- /package/{cjs → dist/cjs}/accounts.js +0 -0
- /package/{cjs → dist/cjs}/adaptor-base.js +0 -0
- /package/{cjs → dist/cjs}/adaptor-cf.js +0 -0
- /package/{cjs → dist/cjs}/adaptor-web.js +0 -0
- /package/{cjs → dist/cjs}/adaptor.js +0 -0
- /package/{cjs → dist/cjs}/ao-loader.js +0 -0
- /package/{cjs → dist/cjs}/ao.js +0 -0
- /package/{cjs → dist/cjs}/aoconnect-base.js +0 -0
- /package/{cjs → dist/cjs}/aoconnect-cf.js +0 -0
- /package/{cjs → dist/cjs}/aoconnect-web.js +0 -0
- /package/{cjs → dist/cjs}/aoconnect.js +0 -0
- /package/{cjs → dist/cjs}/aos_wamr.js +0 -0
- /package/{cjs → dist/cjs}/ar-remote.js +0 -0
- /package/{cjs → dist/cjs}/ar.js +0 -0
- /package/{cjs → dist/cjs}/armem-base.js +0 -0
- /package/{cjs → dist/cjs}/armem-cf.js +0 -0
- /package/{cjs → dist/cjs}/armem-web.js +0 -0
- /package/{cjs → dist/cjs}/armem.js +0 -0
- /package/{cjs → dist/cjs}/bao.js +0 -0
- /package/{cjs → dist/cjs}/bar.js +0 -0
- /package/{cjs → dist/cjs}/build.js +0 -0
- /package/{cjs → dist/cjs}/bundler.js +0 -0
- /package/{cjs → dist/cjs}/car.js +0 -0
- /package/{cjs → dist/cjs}/cf-env.js +0 -0
- /package/{cjs → dist/cjs}/cf.js +0 -0
- /package/{cjs → dist/cjs}/cli.js +0 -0
- /package/{cjs → dist/cjs}/compress.js +0 -0
- /package/{cjs → dist/cjs}/create.js +0 -0
- /package/{cjs → dist/cjs}/devs.js +0 -0
- /package/{cjs → dist/cjs}/dirname.js +0 -0
- /package/{cjs → dist/cjs}/dodb.js +0 -0
- /package/{cjs → dist/cjs}/erl_json.js +0 -0
- /package/{cjs → dist/cjs}/erl_str.js +0 -0
- /package/{cjs → dist/cjs}/gql.js +0 -0
- /package/{cjs → dist/cjs}/hb.js +0 -0
- /package/{cjs → dist/cjs}/helpers.js +0 -0
- /package/{cjs → dist/cjs}/http.js +0 -0
- /package/{cjs → dist/cjs}/hub/bundler.js +0 -0
- /package/{cjs → dist/cjs}/hub/cu.js +0 -0
- /package/{cjs → dist/cjs}/hub/fs.js +0 -0
- /package/{cjs → dist/cjs}/hub/index.js +0 -0
- /package/{cjs → dist/cjs}/hub/utils.js +0 -0
- /package/{cjs → dist/cjs}/hub/ws-proxy.js +0 -0
- /package/{cjs → dist/cjs}/hyper-aos.js +0 -0
- /package/{cjs → dist/cjs}/hyperbeam-server.js +0 -0
- /package/{cjs → dist/cjs}/hyperbeam.js +0 -0
- /package/{cjs → dist/cjs}/index.js +0 -0
- /package/{cjs → dist/cjs}/keygen.js +0 -0
- /package/{cjs → dist/cjs}/lfdb.js +0 -0
- /package/{cjs → dist/cjs}/lua/aos.wasm +0 -0
- /package/{cjs → dist/cjs}/lua/aos2_0_1.js +0 -0
- /package/{cjs → dist/cjs}/lua/aos2_0_1.wasm +0 -0
- /package/{cjs → dist/cjs}/lua/aos2_0_3.js +0 -0
- /package/{cjs → dist/cjs}/lua/aos2_0_3.wasm +0 -0
- /package/{cjs → dist/cjs}/lua/aos2_0_4_32.js +0 -0
- /package/{cjs → dist/cjs}/lua/aos2_0_4_32.wasm +0 -0
- /package/{cjs → dist/cjs}/lua/aos2_0_6.wasm +0 -0
- /package/{cjs → dist/cjs}/lua/apm.lua +0 -0
- /package/{cjs → dist/cjs}/lua/llama.wasm +0 -0
- /package/{cjs → dist/cjs}/lua/process.wasm +0 -0
- /package/{cjs → dist/cjs}/lua/sqlite.js +0 -0
- /package/{cjs → dist/cjs}/lua/sqlite.wasm +0 -0
- /package/{cjs → dist/cjs}/lua/weavedb_mock.lua +0 -0
- /package/{cjs → dist/cjs}/lua/weavedrive.lua +0 -0
- /package/{cjs → dist/cjs}/run.js +0 -0
- /package/{cjs → dist/cjs}/server.js +0 -0
- /package/{cjs → dist/cjs}/storage-multi.js +0 -0
- /package/{cjs → dist/cjs}/tao.js +0 -0
- /package/{cjs → dist/cjs}/tar.js +0 -0
- /package/{cjs → dist/cjs}/test.js +0 -0
- /package/{cjs → dist/cjs}/tgql-d1.js +0 -0
- /package/{cjs → dist/cjs}/tgql.js +0 -0
- /package/{cjs → dist/cjs}/toerl.js +0 -0
- /package/{cjs → dist/cjs}/utils.js +0 -0
- /package/{cjs → dist/cjs}/wao.js +0 -0
- /package/{cjs → dist/cjs}/waosm/waosm.js +0 -0
- /package/{cjs → dist/cjs}/waosm-node/waosm.js +0 -0
- /package/{cjs → dist/cjs}/waosm-node/waosm_bg.js +0 -0
- /package/{cjs → dist/cjs}/waosm-node/waosm_bg.wasm +0 -0
- /package/{cjs → dist/cjs}/waosm-node/waosm_bg.wasm.js +0 -0
- /package/{cjs → dist/cjs}/waosm-node.js +0 -0
- /package/{cjs → dist/cjs}/war.js +0 -0
- /package/{cjs → dist/cjs}/weavedrive.js +0 -0
- /package/{cjs → dist/cjs}/web.js +0 -0
- /package/{cjs → dist/cjs}/workspace/.mcp.json +0 -0
- /package/{cjs → dist/cjs}/workspace/CLAUDE.md +0 -0
- /package/{cjs → dist/cjs}/workspace/README.md +0 -0
- /package/{cjs → dist/cjs}/workspace/dashboard/index.html +0 -0
- /package/{cjs → dist/cjs}/workspace/dashboard/package.json +0 -0
- /package/{esm → dist/cjs}/workspace/dashboard/public/favicon.ico +0 -0
- /package/{cjs → dist/cjs}/workspace/dashboard/public/favicon.png +0 -0
- /package/{cjs → dist/cjs}/workspace/dashboard/server.js +0 -0
- /package/{cjs → dist/cjs}/workspace/dashboard/src/App.jsx +0 -0
- /package/{cjs → dist/cjs}/workspace/dashboard/src/main.jsx +0 -0
- /package/{cjs → dist/cjs}/workspace/dashboard/vite.config.js +0 -0
- /package/{cjs → dist/cjs}/workspace/package.json +0 -0
- /package/{esm → dist/cjs}/workspace/src/counter.lua +0 -0
- /package/{esm → dist/esm}/accounts-web.js +0 -0
- /package/{esm → dist/esm}/accounts.js +0 -0
- /package/{esm → dist/esm}/adaptor-base.js +0 -0
- /package/{esm → dist/esm}/adaptor-cf.js +0 -0
- /package/{esm → dist/esm}/adaptor-web.js +0 -0
- /package/{esm → dist/esm}/adaptor.js +0 -0
- /package/{esm → dist/esm}/ao-loader.js +0 -0
- /package/{esm → dist/esm}/ao.js +0 -0
- /package/{esm → dist/esm}/aoconnect-base.js +0 -0
- /package/{esm → dist/esm}/aoconnect-cf.js +0 -0
- /package/{esm → dist/esm}/aoconnect-web.js +0 -0
- /package/{esm → dist/esm}/aoconnect.js +0 -0
- /package/{esm → dist/esm}/aos_wamr.js +0 -0
- /package/{esm → dist/esm}/ar-remote.js +0 -0
- /package/{esm → dist/esm}/ar.js +0 -0
- /package/{esm → dist/esm}/armem-base.js +0 -0
- /package/{esm → dist/esm}/armem-cf.js +0 -0
- /package/{esm → dist/esm}/armem-web.js +0 -0
- /package/{esm → dist/esm}/armem.js +0 -0
- /package/{esm → dist/esm}/bao.js +0 -0
- /package/{esm → dist/esm}/bar.js +0 -0
- /package/{esm → dist/esm}/build.js +0 -0
- /package/{esm → dist/esm}/bundler.js +0 -0
- /package/{esm → dist/esm}/car.js +0 -0
- /package/{esm → dist/esm}/cf-env.js +0 -0
- /package/{esm → dist/esm}/cf.js +0 -0
- /package/{esm → dist/esm}/cli.js +0 -0
- /package/{esm → dist/esm}/compress.js +0 -0
- /package/{esm → dist/esm}/create.js +0 -0
- /package/{esm → dist/esm}/devs.js +0 -0
- /package/{esm → dist/esm}/dirname.js +0 -0
- /package/{esm → dist/esm}/dodb.js +0 -0
- /package/{esm → dist/esm}/erl_json.js +0 -0
- /package/{esm → dist/esm}/erl_str.js +0 -0
- /package/{esm → dist/esm}/gql.js +0 -0
- /package/{esm → dist/esm}/hb.js +0 -0
- /package/{esm → dist/esm}/helpers.js +0 -0
- /package/{esm → dist/esm}/http.js +0 -0
- /package/{esm → dist/esm}/hub/bundler.js +0 -0
- /package/{esm → dist/esm}/hub/cu.js +0 -0
- /package/{esm → dist/esm}/hub/fs.js +0 -0
- /package/{esm → dist/esm}/hub/index.js +0 -0
- /package/{esm → dist/esm}/hub/utils.js +0 -0
- /package/{esm → dist/esm}/hub/ws-proxy.js +0 -0
- /package/{esm → dist/esm}/hyper-aos.js +0 -0
- /package/{esm → dist/esm}/hyperbeam-server.js +0 -0
- /package/{esm → dist/esm}/hyperbeam.js +0 -0
- /package/{esm → dist/esm}/index.js +0 -0
- /package/{esm → dist/esm}/keygen.js +0 -0
- /package/{esm → dist/esm}/lfdb.js +0 -0
- /package/{esm → dist/esm}/lua/aos.wasm +0 -0
- /package/{esm → dist/esm}/lua/aos2_0_1.js +0 -0
- /package/{esm → dist/esm}/lua/aos2_0_1.wasm +0 -0
- /package/{esm → dist/esm}/lua/aos2_0_3.js +0 -0
- /package/{esm → dist/esm}/lua/aos2_0_3.wasm +0 -0
- /package/{esm → dist/esm}/lua/aos2_0_4_32.js +0 -0
- /package/{esm → dist/esm}/lua/aos2_0_4_32.wasm +0 -0
- /package/{esm → dist/esm}/lua/aos2_0_6.wasm +0 -0
- /package/{esm → dist/esm}/lua/apm.lua +0 -0
- /package/{esm → dist/esm}/lua/llama.wasm +0 -0
- /package/{esm → dist/esm}/lua/process.wasm +0 -0
- /package/{esm → dist/esm}/lua/sqlite.js +0 -0
- /package/{esm → dist/esm}/lua/sqlite.wasm +0 -0
- /package/{esm → dist/esm}/lua/weavedb_mock.lua +0 -0
- /package/{esm → dist/esm}/lua/weavedrive.lua +0 -0
- /package/{esm → dist/esm}/package.json +0 -0
- /package/{esm → dist/esm}/run.js +0 -0
- /package/{esm → dist/esm}/server.js +0 -0
- /package/{esm → dist/esm}/storage-multi.js +0 -0
- /package/{esm → dist/esm}/tao.js +0 -0
- /package/{esm → dist/esm}/tar.js +0 -0
- /package/{esm → dist/esm}/test.js +0 -0
- /package/{esm → dist/esm}/tgql-d1.js +0 -0
- /package/{esm → dist/esm}/tgql.js +0 -0
- /package/{esm → dist/esm}/toerl.js +0 -0
- /package/{esm → dist/esm}/utils.js +0 -0
- /package/{esm → dist/esm}/wao.js +0 -0
- /package/{esm → dist/esm}/waosm/README.md +0 -0
- /package/{esm → dist/esm}/waosm/waosm.d.ts +0 -0
- /package/{esm → dist/esm}/waosm/waosm.js +0 -0
- /package/{esm → dist/esm}/waosm/waosm_bg.wasm +0 -0
- /package/{esm → dist/esm}/waosm/waosm_bg.wasm.d.ts +0 -0
- /package/{esm → dist/esm}/waosm-node/README.md +0 -0
- /package/{esm → dist/esm}/waosm-node/waosm.d.ts +0 -0
- /package/{esm → dist/esm}/waosm-node/waosm.js +0 -0
- /package/{esm → dist/esm}/waosm-node/waosm_bg.js +0 -0
- /package/{esm → dist/esm}/waosm-node/waosm_bg.wasm +0 -0
- /package/{esm → dist/esm}/waosm-node/waosm_bg.wasm.d.ts +0 -0
- /package/{esm → dist/esm}/waosm-node/waosm_bg.wasm.js +0 -0
- /package/{esm → dist/esm}/waosm-node.js +0 -0
- /package/{esm → dist/esm}/war.js +0 -0
- /package/{esm → dist/esm}/weavedrive.js +0 -0
- /package/{esm → dist/esm}/web.js +0 -0
- /package/{esm → dist/esm}/workspace/.mcp.json +0 -0
- /package/{esm → dist/esm}/workspace/CLAUDE.md +0 -0
- /package/{esm → dist/esm}/workspace/README.md +0 -0
- /package/{esm → dist/esm}/workspace/dashboard/index.html +0 -0
- /package/{esm → dist/esm}/workspace/dashboard/package.json +0 -0
- /package/{esm/workspace/dashboard/public/favicon.png → dist/esm/workspace/dashboard/public/favicon.ico} +0 -0
- /package/{esm → dist/esm}/workspace/dashboard/server.js +0 -0
- /package/{esm → dist/esm}/workspace/dashboard/src/App.jsx +0 -0
- /package/{cjs/workspace/frontend → dist/esm/workspace/dashboard}/src/main.jsx +0 -0
- /package/{esm → dist/esm}/workspace/dashboard/vite.config.js +0 -0
- /package/{esm → dist/esm}/workspace/package.json +0 -0
- /package/{postinstall.cjs → dist/postinstall.cjs} +0 -0
- /package/{esm → src}/workspace/dashboard/src/main.jsx +0 -0
package/src/ao.js
ADDED
|
@@ -0,0 +1,1173 @@
|
|
|
1
|
+
import * as WarpArBundles from "warp-arbundles"
|
|
2
|
+
const pkg = WarpArBundles.default ?? WarpArBundles
|
|
3
|
+
const { createData, ArweaveSigner } = pkg
|
|
4
|
+
import AR from "./ar.js"
|
|
5
|
+
import HB from "./hb.js"
|
|
6
|
+
import md5 from "md5"
|
|
7
|
+
import {
|
|
8
|
+
createDataItemSigner,
|
|
9
|
+
connect,
|
|
10
|
+
assign,
|
|
11
|
+
result,
|
|
12
|
+
results,
|
|
13
|
+
message,
|
|
14
|
+
spawn,
|
|
15
|
+
dryrun,
|
|
16
|
+
monitor,
|
|
17
|
+
unmonitor,
|
|
18
|
+
} from "@permaweb/aoconnect-69"
|
|
19
|
+
|
|
20
|
+
import {
|
|
21
|
+
dissoc,
|
|
22
|
+
equals,
|
|
23
|
+
concat,
|
|
24
|
+
is,
|
|
25
|
+
mergeLeft,
|
|
26
|
+
o,
|
|
27
|
+
uniqBy,
|
|
28
|
+
prop,
|
|
29
|
+
isNil,
|
|
30
|
+
includes,
|
|
31
|
+
map,
|
|
32
|
+
reverse,
|
|
33
|
+
last,
|
|
34
|
+
} from "ramda"
|
|
35
|
+
|
|
36
|
+
import {
|
|
37
|
+
allChecked,
|
|
38
|
+
searchTag,
|
|
39
|
+
checkTag,
|
|
40
|
+
wait,
|
|
41
|
+
isLocalhost,
|
|
42
|
+
tag,
|
|
43
|
+
tags as _tags,
|
|
44
|
+
ltags,
|
|
45
|
+
action,
|
|
46
|
+
isData,
|
|
47
|
+
getTagVal,
|
|
48
|
+
srcs,
|
|
49
|
+
buildTags,
|
|
50
|
+
isRegExp,
|
|
51
|
+
mergeChecks,
|
|
52
|
+
isCheckComplete,
|
|
53
|
+
mergeOut,
|
|
54
|
+
isOutComplete,
|
|
55
|
+
jsonToStr,
|
|
56
|
+
optAO,
|
|
57
|
+
} from "./utils.js"
|
|
58
|
+
|
|
59
|
+
const getHash = res =>
|
|
60
|
+
md5(
|
|
61
|
+
JSON.stringify({
|
|
62
|
+
Messages: res.Messages ?? [],
|
|
63
|
+
Spawns: res.Spawns ?? [],
|
|
64
|
+
Assignments: res.Assignments ?? [],
|
|
65
|
+
})
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
function createDataItemSigner2(wallet) {
|
|
69
|
+
const signer = async ({ data, tags, target, anchor }) => {
|
|
70
|
+
const signer = new ArweaveSigner(wallet)
|
|
71
|
+
const dataItem = createData(data, signer, { tags, target, anchor })
|
|
72
|
+
const sig = dataItem.sign(signer).then(async () => {
|
|
73
|
+
return { id: await dataItem.id, raw: await dataItem.getRaw() }
|
|
74
|
+
})
|
|
75
|
+
return sig
|
|
76
|
+
}
|
|
77
|
+
return signer
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
class AO {
|
|
81
|
+
constructor(opt = {}) {
|
|
82
|
+
let _port = null
|
|
83
|
+
if (typeof opt === "number") {
|
|
84
|
+
_port = opt
|
|
85
|
+
opt = {}
|
|
86
|
+
}
|
|
87
|
+
let {
|
|
88
|
+
hb: _hb,
|
|
89
|
+
mode,
|
|
90
|
+
authority = srcs.authority,
|
|
91
|
+
module,
|
|
92
|
+
module_type = "aos2",
|
|
93
|
+
scheduler = srcs.scheduler,
|
|
94
|
+
aoconnect,
|
|
95
|
+
ar,
|
|
96
|
+
in_memory = false,
|
|
97
|
+
port,
|
|
98
|
+
} = opt
|
|
99
|
+
if (_hb) {
|
|
100
|
+
this.format = _hb === "ans104" ? _hb : "httpsig"
|
|
101
|
+
const _hbOpt = { format: this.format }
|
|
102
|
+
// `hb` can be "ans104" / "httpsig" (format selector with default URL),
|
|
103
|
+
// or an actual URL string. Only treat it as a URL when it looks like one.
|
|
104
|
+
if (
|
|
105
|
+
typeof _hb === "string" &&
|
|
106
|
+
_hb !== "ans104" &&
|
|
107
|
+
_hb !== "httpsig" &&
|
|
108
|
+
/^(https?:\/\/|\/\/|[a-zA-Z0-9_.-]+:\d+)/.test(_hb)
|
|
109
|
+
)
|
|
110
|
+
_hbOpt.url = _hb
|
|
111
|
+
this.hb = new HB(_hbOpt)
|
|
112
|
+
this.mode = mode ?? "legacy"
|
|
113
|
+
}
|
|
114
|
+
if (!_port && port) _port = port
|
|
115
|
+
if (!aoconnect && _port) aoconnect = optAO(_port)
|
|
116
|
+
if (!ar && _port) ar = { port: _port }
|
|
117
|
+
this.wao = opt.wao
|
|
118
|
+
this.variant = opt.variant
|
|
119
|
+
this.module_type = module_type
|
|
120
|
+
if (isNil(this.wao)) this.wao = in_memory || !isNil(ar?.port)
|
|
121
|
+
if (!module) {
|
|
122
|
+
switch (module_type) {
|
|
123
|
+
case "sqlite":
|
|
124
|
+
module = srcs.module_sqlite
|
|
125
|
+
break
|
|
126
|
+
case "aos2":
|
|
127
|
+
module = srcs.module_aos2
|
|
128
|
+
break
|
|
129
|
+
case "mainnet":
|
|
130
|
+
module = srcs.module_mainnet
|
|
131
|
+
break
|
|
132
|
+
|
|
133
|
+
default:
|
|
134
|
+
module = srcs.module
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
this.__type__ = "ao"
|
|
138
|
+
if (ar?.__type__ === "ar") this.ar = ar
|
|
139
|
+
else {
|
|
140
|
+
let _ar = typeof ar === "object" ? ar : {}
|
|
141
|
+
this.ar = new AR(_ar)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (!in_memory && aoconnect) {
|
|
145
|
+
const {
|
|
146
|
+
results,
|
|
147
|
+
assign,
|
|
148
|
+
result,
|
|
149
|
+
message,
|
|
150
|
+
spawn,
|
|
151
|
+
dryrun,
|
|
152
|
+
monitor,
|
|
153
|
+
unmonitor,
|
|
154
|
+
} = connect(aoconnect)
|
|
155
|
+
this.assign = assign
|
|
156
|
+
this.result = result
|
|
157
|
+
this.results = results
|
|
158
|
+
this.message = message
|
|
159
|
+
this.spawn = spawn
|
|
160
|
+
this.dryrun = dryrun
|
|
161
|
+
this.monitor = monitor
|
|
162
|
+
this.unmonitor = unmonitor
|
|
163
|
+
} else {
|
|
164
|
+
this.assign = assign
|
|
165
|
+
this.result = result
|
|
166
|
+
this.results = results
|
|
167
|
+
this.message = message
|
|
168
|
+
this.spawn = spawn
|
|
169
|
+
this.dryrun = dryrun
|
|
170
|
+
this.monitor = monitor
|
|
171
|
+
this.unmonitor = unmonitor
|
|
172
|
+
}
|
|
173
|
+
if (this.wao) {
|
|
174
|
+
this.module = module ?? srcs.module_wao
|
|
175
|
+
this.scheduler = srcs.scheduler_wao
|
|
176
|
+
this.authority = srcs.authority_wao
|
|
177
|
+
} else if (this.module_type === "mainnet") {
|
|
178
|
+
this.module = module ?? srcs.module_mainnet
|
|
179
|
+
} else {
|
|
180
|
+
this.module = module
|
|
181
|
+
this.scheduler = scheduler
|
|
182
|
+
this.authority = authority
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async init(jwk) {
|
|
187
|
+
await this.ar.init(jwk)
|
|
188
|
+
if (this.hb) await this.hb.init(this.ar.jwk)
|
|
189
|
+
return this
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
toSigner(wallet) {
|
|
193
|
+
if (wallet?.n && typeof window !== "undefined") {
|
|
194
|
+
return createDataItemSigner2(wallet)
|
|
195
|
+
} else if (wallet.test) {
|
|
196
|
+
return createDataItemSigner(wallet.jwk)
|
|
197
|
+
} else {
|
|
198
|
+
return createDataItemSigner(wallet)
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
async pipe({ jwk, fns = [], cb }) {
|
|
203
|
+
let [_, out, res, i] = [{}, {}, [], 0]
|
|
204
|
+
let nextArgs = fns[0].args ?? {}
|
|
205
|
+
let [ret, err, pid, mid, id] = [null, null, null, null, null]
|
|
206
|
+
if (!jwk) fns.unshift({ fn: "checkWallet" })
|
|
207
|
+
const copy = ({ _, inp, out, args, from, to, pid, mid, id }) => {
|
|
208
|
+
const _from = from.split(".")
|
|
209
|
+
const _to = to.split(".")
|
|
210
|
+
let [field, val, target] = [null, null, null]
|
|
211
|
+
if (_to[0] === "_") {
|
|
212
|
+
target = _
|
|
213
|
+
field = _to.slice(1).join(".")
|
|
214
|
+
} else if (_to[0] === "args") {
|
|
215
|
+
target = args
|
|
216
|
+
field = _to.slice(1).join(".")
|
|
217
|
+
} else if (_to[0] === "out") {
|
|
218
|
+
target = out
|
|
219
|
+
field = _to.slice(1).join(".")
|
|
220
|
+
} else {
|
|
221
|
+
target = out
|
|
222
|
+
field = _to.join(".")
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (from === "inp") val = inp
|
|
226
|
+
else if (from === "mid") val = mid
|
|
227
|
+
else if (from === "id") val = id
|
|
228
|
+
else if (from === "pid") val = pid
|
|
229
|
+
else if (_from[0] === "args") val = args[_from.slice(1).join(".")] ?? null
|
|
230
|
+
else if (_from[0] === "out") val = out[_from.slice(1).join(".")] ?? null
|
|
231
|
+
else if (_from[0] === "inp") val = inp[_from.slice(1).join(".")] ?? null
|
|
232
|
+
else val = inp[from] ?? null
|
|
233
|
+
|
|
234
|
+
if (target) target[field] = val
|
|
235
|
+
}
|
|
236
|
+
const binds = {
|
|
237
|
+
post: this.ar,
|
|
238
|
+
bundle: this.ar,
|
|
239
|
+
postTx: this.ar,
|
|
240
|
+
checkWallet: this.ar,
|
|
241
|
+
transfer: this.ar,
|
|
242
|
+
}
|
|
243
|
+
for (let v of fns) {
|
|
244
|
+
let bind = null
|
|
245
|
+
if (typeof v.fn === "string" && !v.bind) bind = binds[v.fn] ?? this
|
|
246
|
+
else bind = v.bind ?? this
|
|
247
|
+
|
|
248
|
+
const name =
|
|
249
|
+
(v.name ?? typeof !v.fn)
|
|
250
|
+
? "msg"
|
|
251
|
+
: typeof v.fn === "string"
|
|
252
|
+
? v.fn
|
|
253
|
+
: null
|
|
254
|
+
const fn = typeof v.fn === "string" ? bind[v.fn] : (v.fn ?? this.msg)
|
|
255
|
+
|
|
256
|
+
const _fn = fn.bind(bind)
|
|
257
|
+
const _res = await _fn({ jwk, ...nextArgs })
|
|
258
|
+
res.push(_res)
|
|
259
|
+
if (_res.err) {
|
|
260
|
+
err = _res.err
|
|
261
|
+
break
|
|
262
|
+
}
|
|
263
|
+
if (typeof v.err === "function") {
|
|
264
|
+
const _err = await v.err({
|
|
265
|
+
name,
|
|
266
|
+
_,
|
|
267
|
+
jwk,
|
|
268
|
+
res: _res.res,
|
|
269
|
+
args: nextArgs,
|
|
270
|
+
out,
|
|
271
|
+
pid,
|
|
272
|
+
inp: _res.out,
|
|
273
|
+
mid,
|
|
274
|
+
id,
|
|
275
|
+
})
|
|
276
|
+
if (_err) {
|
|
277
|
+
err = _err
|
|
278
|
+
break
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
if (_res.pid) pid = _res.pid
|
|
282
|
+
if (_res.mid) mid = _res.mid
|
|
283
|
+
if (_res.id) id = _res.id
|
|
284
|
+
if (_res.jwk) jwk = _res.jwk
|
|
285
|
+
nextArgs = fns[i + 1]?.args ?? {}
|
|
286
|
+
if (typeof v.then === "function") {
|
|
287
|
+
const _ret = await v.then({
|
|
288
|
+
name,
|
|
289
|
+
_,
|
|
290
|
+
jwk,
|
|
291
|
+
res: _res.res,
|
|
292
|
+
args: nextArgs,
|
|
293
|
+
out,
|
|
294
|
+
pid,
|
|
295
|
+
inp: _res.out,
|
|
296
|
+
mid,
|
|
297
|
+
id,
|
|
298
|
+
})
|
|
299
|
+
if (typeof _ret !== "undefined") {
|
|
300
|
+
ret = _ret
|
|
301
|
+
break
|
|
302
|
+
}
|
|
303
|
+
} else if (is(Object, v.then)) {
|
|
304
|
+
for (const k in v.then) {
|
|
305
|
+
copy({
|
|
306
|
+
name,
|
|
307
|
+
_,
|
|
308
|
+
inp: _res.out,
|
|
309
|
+
out,
|
|
310
|
+
args: nextArgs,
|
|
311
|
+
pid,
|
|
312
|
+
mid,
|
|
313
|
+
from: v.then[k],
|
|
314
|
+
to: k,
|
|
315
|
+
id,
|
|
316
|
+
})
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
if (typeof cb === "function") {
|
|
320
|
+
cb({
|
|
321
|
+
name,
|
|
322
|
+
fns,
|
|
323
|
+
i: i + 1,
|
|
324
|
+
_,
|
|
325
|
+
jwk,
|
|
326
|
+
res: _res.res,
|
|
327
|
+
args: nextArgs,
|
|
328
|
+
out,
|
|
329
|
+
pid,
|
|
330
|
+
inp: _res.out,
|
|
331
|
+
mid,
|
|
332
|
+
id,
|
|
333
|
+
})
|
|
334
|
+
}
|
|
335
|
+
i++
|
|
336
|
+
}
|
|
337
|
+
return ret ?? { jwk, err, res, out, pid, mid, id, ..._ }
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
async postModule({ data, jwk, tags = {}, overwrite = false }) {
|
|
341
|
+
const _tags = mergeLeft(tags, {
|
|
342
|
+
"Data-Protocol": this.protocol ?? "ao",
|
|
343
|
+
Variant:
|
|
344
|
+
(this.variant ?? this.module_type === "mainnet")
|
|
345
|
+
? "ao.TN.1"
|
|
346
|
+
: "ao.TN.1",
|
|
347
|
+
Type: "Module",
|
|
348
|
+
"Module-Format": "wasm64-unknown-emscripten-draft_2024_02_15",
|
|
349
|
+
"Input-Encoding": "JSON-1",
|
|
350
|
+
"Output-Encoding": "JSON-1",
|
|
351
|
+
"Memory-Limit": "1-gb",
|
|
352
|
+
"Compute-Limit": "9000000000000",
|
|
353
|
+
Extension: "WeaveDrive",
|
|
354
|
+
})
|
|
355
|
+
|
|
356
|
+
const fns = [
|
|
357
|
+
{
|
|
358
|
+
fn: "post",
|
|
359
|
+
args: { data, tags: _tags },
|
|
360
|
+
then: ({ id }) => {
|
|
361
|
+
if (!this.module || overwrite) this.module = id
|
|
362
|
+
},
|
|
363
|
+
},
|
|
364
|
+
]
|
|
365
|
+
return await this.pipe({ jwk, fns })
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
async postScheduler({ jwk, url, tags = {}, overwrite = false }) {
|
|
369
|
+
const _tags = mergeLeft(tags, {
|
|
370
|
+
"Data-Protocol": this.protocol ?? "ao",
|
|
371
|
+
Variant:
|
|
372
|
+
(this.variant ?? this.module_type === "mainnet")
|
|
373
|
+
? "ao.TN.1"
|
|
374
|
+
: "ao.TN.1",
|
|
375
|
+
Type: "Scheduler-Location",
|
|
376
|
+
Url: url,
|
|
377
|
+
"Time-To-Live": "3600000",
|
|
378
|
+
})
|
|
379
|
+
const then = async ({ jwk, out, _ }) => {
|
|
380
|
+
_.scheduler = await this.ar.toAddr(jwk)
|
|
381
|
+
if (!this.scheduler || overwrite) this.scheduler = _.scheduler
|
|
382
|
+
}
|
|
383
|
+
const fns = [{ fn: "post", args: { tags: _tags }, then }]
|
|
384
|
+
return await this.pipe({ jwk, fns })
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
async spwn({
|
|
388
|
+
boot,
|
|
389
|
+
module,
|
|
390
|
+
scheduler = this.scheduler,
|
|
391
|
+
memory,
|
|
392
|
+
jwk,
|
|
393
|
+
tags = {},
|
|
394
|
+
data,
|
|
395
|
+
auth,
|
|
396
|
+
} = {}) {
|
|
397
|
+
let err = null
|
|
398
|
+
;({ jwk, err } = await this.ar.checkWallet({ jwk }))
|
|
399
|
+
if (err) return { err }
|
|
400
|
+
let pid = null
|
|
401
|
+
try {
|
|
402
|
+
if (boot) tags["On-Boot"] = boot
|
|
403
|
+
if (auth) tags.Authority = auth
|
|
404
|
+
if (this.hb) {
|
|
405
|
+
switch (this.mode) {
|
|
406
|
+
case "aos":
|
|
407
|
+
case "wasm":
|
|
408
|
+
;({ pid } = await this.hb.spawnAOS({ module }))
|
|
409
|
+
break
|
|
410
|
+
case "lua":
|
|
411
|
+
;({ pid } = await this.hb.spawnLua())
|
|
412
|
+
break
|
|
413
|
+
default:
|
|
414
|
+
;({ pid } = await this.hb.spawnLegacy({ module, tags, data }))
|
|
415
|
+
try {
|
|
416
|
+
await this.hb.computeLegacy({ pid, slot: 0 })
|
|
417
|
+
} catch (_e) {}
|
|
418
|
+
}
|
|
419
|
+
} else {
|
|
420
|
+
module ??= this.module
|
|
421
|
+
if (!tags.Authority && this.authority) tags.Authority = this.authority
|
|
422
|
+
let _tags = buildTags(null, tags)
|
|
423
|
+
pid = await this.spawn({
|
|
424
|
+
variant: this.variant,
|
|
425
|
+
memory,
|
|
426
|
+
module,
|
|
427
|
+
scheduler,
|
|
428
|
+
signer: this.toSigner(jwk),
|
|
429
|
+
tags: _tags,
|
|
430
|
+
data: jsonToStr(data),
|
|
431
|
+
})
|
|
432
|
+
}
|
|
433
|
+
} catch (e) {
|
|
434
|
+
err = e
|
|
435
|
+
}
|
|
436
|
+
const p = pid ? this.p(pid) : null
|
|
437
|
+
return { err, pid, p }
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
async res({
|
|
441
|
+
jwk,
|
|
442
|
+
pid,
|
|
443
|
+
mid,
|
|
444
|
+
check = [],
|
|
445
|
+
get,
|
|
446
|
+
timeout = 5000,
|
|
447
|
+
mode = "aoconnect",
|
|
448
|
+
limit = 25,
|
|
449
|
+
}) {
|
|
450
|
+
let err = null
|
|
451
|
+
let hash = null
|
|
452
|
+
const getNewTxs = async (pid, _txs, _txmap) => {
|
|
453
|
+
let exists = false
|
|
454
|
+
if (mode === "gql") {
|
|
455
|
+
const txs = await this.ar.gql.txs({
|
|
456
|
+
recipient: pid,
|
|
457
|
+
limit,
|
|
458
|
+
fields: ["id", "recipient", "tags", { owner: ["address"] }],
|
|
459
|
+
})
|
|
460
|
+
for (const v of reverse(txs)) {
|
|
461
|
+
if (v.id === mid) exists = true
|
|
462
|
+
else if (exists) {
|
|
463
|
+
if (isNil(_txmap[v.id])) {
|
|
464
|
+
const t = ltags(v.tags)
|
|
465
|
+
if (t.type === "Message") {
|
|
466
|
+
v.from = t["from-process"] ?? v.owner?.address
|
|
467
|
+
_txs.unshift(v)
|
|
468
|
+
_txmap[v.id] = { checked: false, ref: t["x-reference"] }
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
} else {
|
|
474
|
+
const _ress = await this.ress({ pid, limit })
|
|
475
|
+
for (let v of reverse(_ress?.out ?? [])) {
|
|
476
|
+
const hash2 = getHash(v)
|
|
477
|
+
if (!exists) {
|
|
478
|
+
if (hash2 === hash) exists = true
|
|
479
|
+
} else {
|
|
480
|
+
if (isNil(_txmap[v.cursor + pid])) {
|
|
481
|
+
_txmap[v.cursor + pid] = { checked: false, res: v }
|
|
482
|
+
_txs.unshift({ id: v.cursor + pid })
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
const checkOut = async (get, _txs, _txmap, out) => {
|
|
489
|
+
for (let v of _txs) {
|
|
490
|
+
if (isNil(_txmap[v.id].res)) {
|
|
491
|
+
const res = await this.result({ process: pid, message: v.id })
|
|
492
|
+
if (!hash) console.log(res)
|
|
493
|
+
_txmap[v.id].res = res
|
|
494
|
+
}
|
|
495
|
+
if (!isNil(_txmap[v.id].res) && _txmap[v.id].out !== true) {
|
|
496
|
+
_txmap[v.id].out = true
|
|
497
|
+
const _out = getTagVal(get, _txmap[v.id].res, v.from)
|
|
498
|
+
out = mergeOut(out, _out, get)
|
|
499
|
+
if (isOutComplete(out, get)) break
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
return out
|
|
503
|
+
}
|
|
504
|
+
let [res, out, results] = [null, null, []]
|
|
505
|
+
let start = Date.now()
|
|
506
|
+
try {
|
|
507
|
+
if (!is(Array, check)) check = [check]
|
|
508
|
+
let _txs = [{ id: mid, from: await this.ar.toAddr(jwk) }]
|
|
509
|
+
if (this.hb) {
|
|
510
|
+
try {
|
|
511
|
+
switch (this.mode) {
|
|
512
|
+
case "aos":
|
|
513
|
+
case "wasm":
|
|
514
|
+
res = await this.hb.computeAOS({ pid, slot: mid })
|
|
515
|
+
try {
|
|
516
|
+
const { slot: pushSlot, outbox: pushOutbox } =
|
|
517
|
+
await this.hb.pushAOS({ pid, slot: mid, outbox: res })
|
|
518
|
+
if (pushSlot > Number(mid) && pushOutbox) {
|
|
519
|
+
res = pushOutbox
|
|
520
|
+
}
|
|
521
|
+
} catch (_e2) {}
|
|
522
|
+
break
|
|
523
|
+
case "lua":
|
|
524
|
+
res = await this.hb.computeLua({ pid, slot: mid })
|
|
525
|
+
try {
|
|
526
|
+
await this.hb.get({ path: `/${pid}/push`, slot: mid })
|
|
527
|
+
} catch (_e2) {}
|
|
528
|
+
break
|
|
529
|
+
default:
|
|
530
|
+
res = await this.hb.computeLegacy({ pid, slot: mid })
|
|
531
|
+
try {
|
|
532
|
+
await this.hb.get({ path: `/${pid}/push`, slot: mid })
|
|
533
|
+
} catch (_e2) {}
|
|
534
|
+
const _callerAddr = this.hb.addr
|
|
535
|
+
const _hasCallerReply = res?.Messages?.some(
|
|
536
|
+
m =>
|
|
537
|
+
m?.Data != null &&
|
|
538
|
+
m?.Data !== "" &&
|
|
539
|
+
m?.Target === _callerAddr,
|
|
540
|
+
)
|
|
541
|
+
if (!_hasCallerReply) {
|
|
542
|
+
try {
|
|
543
|
+
const raw = await this.hb.getJSON({
|
|
544
|
+
path: `/${pid}/now/results/json/body`,
|
|
545
|
+
})
|
|
546
|
+
const parsed =
|
|
547
|
+
typeof raw === "string" ? JSON.parse(raw) : raw
|
|
548
|
+
if (parsed?.Messages || parsed?.Output) res = parsed
|
|
549
|
+
} catch (_e2) {}
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
if (res) res = this._normalizeHBResult(res)
|
|
553
|
+
} catch (_e) {}
|
|
554
|
+
} else {
|
|
555
|
+
res = await this.result({ process: pid, message: mid })
|
|
556
|
+
}
|
|
557
|
+
hash = getHash(res)
|
|
558
|
+
let _txmap = { [mid]: { checked: false, res } }
|
|
559
|
+
results.push({ mid, res })
|
|
560
|
+
let checked = false
|
|
561
|
+
if (this.hb && !isNil(check) && check.length > 0) {
|
|
562
|
+
// HB mode: push device handles recursive coroutine resolution.
|
|
563
|
+
// After push resolves, poll now/results for the final result.
|
|
564
|
+
const nowPath =
|
|
565
|
+
this.mode === "aos" || this.mode === "wasm"
|
|
566
|
+
? `/${pid}/now/results/outbox`
|
|
567
|
+
: this.mode === "lua"
|
|
568
|
+
? `/${pid}/now/results`
|
|
569
|
+
: `/${pid}/now/results/json/body`
|
|
570
|
+
checked = res ? allChecked(check, res) : false
|
|
571
|
+
while (!checked && Date.now() - start < timeout) {
|
|
572
|
+
try {
|
|
573
|
+
let parsed
|
|
574
|
+
if (this.mode === "legacy" || !this.mode) {
|
|
575
|
+
const raw = await this.hb.getJSON({ path: nowPath })
|
|
576
|
+
parsed = typeof raw === "string" ? JSON.parse(raw) : raw
|
|
577
|
+
} else {
|
|
578
|
+
const nowRes = await this.hb.get({ path: nowPath })
|
|
579
|
+
parsed = this._parseHBOutbox(nowRes)
|
|
580
|
+
}
|
|
581
|
+
if (parsed) {
|
|
582
|
+
const nextRes = this._normalizeHBResult(parsed)
|
|
583
|
+
if (nextRes) {
|
|
584
|
+
res = nextRes
|
|
585
|
+
results.push({ mid: "now", res: nextRes })
|
|
586
|
+
checked = allChecked(check, nextRes)
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
} catch (_e) {}
|
|
590
|
+
if (!checked) await wait(1000)
|
|
591
|
+
}
|
|
592
|
+
if (checked && !isNil(get)) out = getTagVal(get, res)
|
|
593
|
+
if (!checked) err = "something went wrong!"
|
|
594
|
+
} else {
|
|
595
|
+
do {
|
|
596
|
+
for (let v of _txs) {
|
|
597
|
+
if (!_txmap[v.id].checked) {
|
|
598
|
+
_txmap[v.id].checked = true
|
|
599
|
+
if (isNil(_txmap[v.id].res)) {
|
|
600
|
+
try {
|
|
601
|
+
const _res = await this.result({
|
|
602
|
+
process: pid,
|
|
603
|
+
message: v.id,
|
|
604
|
+
})
|
|
605
|
+
_txmap[v.id].res = _res
|
|
606
|
+
} catch (_e) {}
|
|
607
|
+
}
|
|
608
|
+
if (!isNil(check) && check.length > 0) {
|
|
609
|
+
checked = allChecked(check, _txmap[v.id].res, v.from)
|
|
610
|
+
} else {
|
|
611
|
+
checked = true
|
|
612
|
+
}
|
|
613
|
+
if (checked) break
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
if (checked) break
|
|
617
|
+
await wait(1000)
|
|
618
|
+
try {
|
|
619
|
+
await getNewTxs(pid, _txs, _txmap)
|
|
620
|
+
} catch (_e) {}
|
|
621
|
+
} while (Date.now() - start < timeout)
|
|
622
|
+
|
|
623
|
+
if (!checked) {
|
|
624
|
+
err = "something went wrong!"
|
|
625
|
+
} else {
|
|
626
|
+
out = mergeOut(out, await checkOut(get, _txs, _txmap, out), get)
|
|
627
|
+
if (!isOutComplete(out, get) && !isNil(get)) {
|
|
628
|
+
while (Date.now() - start < timeout) {
|
|
629
|
+
await getNewTxs(pid, _txs, _txmap)
|
|
630
|
+
out = mergeOut(out, await checkOut(get, _txs, _txmap, out), get)
|
|
631
|
+
if (isOutComplete(out, get)) break
|
|
632
|
+
await wait(1000)
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
} catch (e) {
|
|
638
|
+
err = e
|
|
639
|
+
}
|
|
640
|
+
return { mid, res, err, out, results }
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
async msg({
|
|
644
|
+
pid,
|
|
645
|
+
jwk,
|
|
646
|
+
data,
|
|
647
|
+
act = "Eval",
|
|
648
|
+
tags = {},
|
|
649
|
+
check = [],
|
|
650
|
+
get,
|
|
651
|
+
timeout = 5000,
|
|
652
|
+
mode = "aoconnect",
|
|
653
|
+
limit = 25,
|
|
654
|
+
}) {
|
|
655
|
+
let err
|
|
656
|
+
;({ jwk, err } = await this.ar.checkWallet({ jwk }))
|
|
657
|
+
if (err) return { err }
|
|
658
|
+
if (this.hb) {
|
|
659
|
+
let mid, res = null
|
|
660
|
+
const schedArgs = { pid, tags: tags ?? {}, action: act, data }
|
|
661
|
+
switch (this.mode) {
|
|
662
|
+
case "aos":
|
|
663
|
+
case "wasm":
|
|
664
|
+
mid = (await this.hb.scheduleAOS(schedArgs)).slot
|
|
665
|
+
try {
|
|
666
|
+
res = await this.hb.computeAOS({ pid, slot: mid })
|
|
667
|
+
try {
|
|
668
|
+
const { slot: pushSlot, outbox: pushOutbox } =
|
|
669
|
+
await this.hb.pushAOS({ pid, slot: mid, outbox: res })
|
|
670
|
+
if (pushSlot > Number(mid) && pushOutbox) {
|
|
671
|
+
res = pushOutbox
|
|
672
|
+
mid = pushSlot
|
|
673
|
+
}
|
|
674
|
+
} catch (_e2) {}
|
|
675
|
+
} catch (_e) {}
|
|
676
|
+
break
|
|
677
|
+
case "lua":
|
|
678
|
+
mid = (await this.hb.scheduleLua(schedArgs)).slot
|
|
679
|
+
try {
|
|
680
|
+
res = await this.hb.computeLua({ pid, slot: mid })
|
|
681
|
+
try {
|
|
682
|
+
await this.hb.get({ path: `/${pid}/push`, slot: mid })
|
|
683
|
+
} catch (_e2) {}
|
|
684
|
+
} catch (_e) {}
|
|
685
|
+
break
|
|
686
|
+
default:
|
|
687
|
+
mid = (await this.hb.scheduleLegacy(schedArgs)).slot
|
|
688
|
+
try {
|
|
689
|
+
res = await this.hb.computeLegacy({ pid, slot: mid })
|
|
690
|
+
// v0.9-FINAL's push device can enter long-running recursive loops
|
|
691
|
+
// for cross-process Send().receive() coroutines. Race the push
|
|
692
|
+
// call against a 20s timeout so msg() can return rather than
|
|
693
|
+
// wait forever; the now/results probe below still has a chance
|
|
694
|
+
// to pick up a partial reply.
|
|
695
|
+
const _pushTimeoutMs = 20000
|
|
696
|
+
try {
|
|
697
|
+
await Promise.race([
|
|
698
|
+
this.hb.get({ path: `/${pid}/push`, slot: mid }),
|
|
699
|
+
new Promise((_r, rej) =>
|
|
700
|
+
setTimeout(() => rej(new Error("push timeout")), _pushTimeoutMs)
|
|
701
|
+
),
|
|
702
|
+
])
|
|
703
|
+
} catch (_e2) {}
|
|
704
|
+
// Push updates now/ to its recursive resolution result, which may
|
|
705
|
+
// include errors from other processes (cross-process trust errors).
|
|
706
|
+
// Only use now/results when the compute result has no reply to the
|
|
707
|
+
// caller — i.e. the handler used Send().receive() and the reply is
|
|
708
|
+
// deferred until push resolves the coroutine.
|
|
709
|
+
const callerAddr = this.hb.addr
|
|
710
|
+
const hasCallerReply = res?.Messages?.some(
|
|
711
|
+
m =>
|
|
712
|
+
m?.Data != null &&
|
|
713
|
+
m?.Data !== "" &&
|
|
714
|
+
m?.Target === callerAddr,
|
|
715
|
+
)
|
|
716
|
+
if (!hasCallerReply) {
|
|
717
|
+
try {
|
|
718
|
+
const raw = await this.hb.getJSON({
|
|
719
|
+
path: `/${pid}/now/results/json/body`,
|
|
720
|
+
})
|
|
721
|
+
const parsed =
|
|
722
|
+
typeof raw === "string" ? JSON.parse(raw) : raw
|
|
723
|
+
if (parsed?.Messages || parsed?.Output) res = parsed
|
|
724
|
+
} catch (_e2) {}
|
|
725
|
+
}
|
|
726
|
+
} catch (_e) {}
|
|
727
|
+
}
|
|
728
|
+
if (res) res = this._normalizeHBResult(res)
|
|
729
|
+
if (!isNil(check) && is(Array, check) ? check.length > 0 : true) {
|
|
730
|
+
return await this.res({ pid, mid, jwk, check, get, timeout, mode, limit })
|
|
731
|
+
}
|
|
732
|
+
let out = null
|
|
733
|
+
if (res && !isNil(get)) out = getTagVal(get, res)
|
|
734
|
+
return { mid, res, err: null, out, results: [{ mid, res }] }
|
|
735
|
+
} else {
|
|
736
|
+
let _tags = buildTags(act, tags)
|
|
737
|
+
const mid = await this.message({
|
|
738
|
+
variant: this.variant,
|
|
739
|
+
process: pid,
|
|
740
|
+
signer: this.toSigner(jwk),
|
|
741
|
+
tags: _tags,
|
|
742
|
+
data: jsonToStr(data),
|
|
743
|
+
})
|
|
744
|
+
return await this.res({
|
|
745
|
+
pid,
|
|
746
|
+
mid,
|
|
747
|
+
jwk,
|
|
748
|
+
check,
|
|
749
|
+
get,
|
|
750
|
+
timeout,
|
|
751
|
+
mode,
|
|
752
|
+
limit,
|
|
753
|
+
})
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
async asgn({ pid, mid, jwk, check = [], get }) {
|
|
758
|
+
let err = null
|
|
759
|
+
;({ jwk, err } = await this.ar.checkWallet({ jwk }))
|
|
760
|
+
if (err) return { err }
|
|
761
|
+
|
|
762
|
+
let [res, out] = [null, null]
|
|
763
|
+
try {
|
|
764
|
+
mid = await this.assign({
|
|
765
|
+
process: pid,
|
|
766
|
+
message: mid,
|
|
767
|
+
signer: this.toSigner(jwk),
|
|
768
|
+
})
|
|
769
|
+
res = await this.result({ process: pid, message: mid })
|
|
770
|
+
if (!res) err = "something went wrong"
|
|
771
|
+
if (res.Error) err = res.Error
|
|
772
|
+
else {
|
|
773
|
+
if (!is(Array, check)) check = [check]
|
|
774
|
+
if (!allChecked(check, res)) err = "something went wrong"
|
|
775
|
+
if (!err && !isNil(get)) out = getTagVal(get, res) // todo: from
|
|
776
|
+
}
|
|
777
|
+
} catch (e) {
|
|
778
|
+
err = e
|
|
779
|
+
}
|
|
780
|
+
return { mid, res, err, out }
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
async dry({ pid, jwk, data, act = "Eval", tags = {}, check = [], get }) {
|
|
784
|
+
let err = null
|
|
785
|
+
;({ jwk, err } = await this.ar.checkWallet({ jwk }))
|
|
786
|
+
if (err) return { err }
|
|
787
|
+
let [res, out] = [null, null]
|
|
788
|
+
let _tags = buildTags(act, tags)
|
|
789
|
+
try {
|
|
790
|
+
if (this.hb) {
|
|
791
|
+
res = await this.hb.dryrun({
|
|
792
|
+
action: act,
|
|
793
|
+
pid,
|
|
794
|
+
tags,
|
|
795
|
+
data: jsonToStr(data),
|
|
796
|
+
})
|
|
797
|
+
} else {
|
|
798
|
+
res = await this.dryrun({
|
|
799
|
+
process: pid,
|
|
800
|
+
signer: this.toSigner(jwk),
|
|
801
|
+
tags: _tags,
|
|
802
|
+
data: jsonToStr(data),
|
|
803
|
+
})
|
|
804
|
+
}
|
|
805
|
+
let checks = []
|
|
806
|
+
if (!is(Array, check)) check = [check]
|
|
807
|
+
if (!allChecked(check, res)) err = "something went wrong"
|
|
808
|
+
if (!err && !isNil(get)) out = getTagVal(get, res)
|
|
809
|
+
} catch (e) {
|
|
810
|
+
err = e
|
|
811
|
+
}
|
|
812
|
+
return { res, err, out }
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
async ress({ pid, limit, asc, from }) {
|
|
816
|
+
let err = null
|
|
817
|
+
let msgs = null
|
|
818
|
+
let next = null
|
|
819
|
+
let res = null
|
|
820
|
+
try {
|
|
821
|
+
let sort = asc ? "ASC" : "DESC"
|
|
822
|
+
if (this.hb) {
|
|
823
|
+
res = await this.hb.results({ process: pid, limit, sort, from })
|
|
824
|
+
} else {
|
|
825
|
+
res = await this.results({ process: pid, limit, sort, from })
|
|
826
|
+
}
|
|
827
|
+
if (!res.edges) return null
|
|
828
|
+
msgs = map(v => ({ cursor: v.cursor, ...v.node }))(res.edges)
|
|
829
|
+
if (res.page_info.has_next_page) {
|
|
830
|
+
next = async () => {
|
|
831
|
+
return await this.results({
|
|
832
|
+
process: pid,
|
|
833
|
+
limit,
|
|
834
|
+
sort,
|
|
835
|
+
from: last(res.edges).cursor,
|
|
836
|
+
})
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
} catch (e) {
|
|
840
|
+
err = e
|
|
841
|
+
}
|
|
842
|
+
return { err, out: msgs, res }
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
async eval({ pid, jwk, data }) {
|
|
846
|
+
const fns = [
|
|
847
|
+
{
|
|
848
|
+
args: { pid, data, act: "Eval" },
|
|
849
|
+
err: ({ res }) => {
|
|
850
|
+
if (this.hb) return false
|
|
851
|
+
return (
|
|
852
|
+
typeof res?.Output?.data !== "object" &&
|
|
853
|
+
!(
|
|
854
|
+
typeof res?.Output?.prompt === "string" &&
|
|
855
|
+
/aos\-/.test(res?.Output?.prompt)
|
|
856
|
+
)
|
|
857
|
+
)
|
|
858
|
+
},
|
|
859
|
+
},
|
|
860
|
+
]
|
|
861
|
+
return await this.pipe({ jwk, fns })
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
async transform({ src, data, fills }) {
|
|
865
|
+
let [err, out] = [null, null]
|
|
866
|
+
let _data = data ?? (await this.ar.data(src, true))
|
|
867
|
+
|
|
868
|
+
if (!_data) err = "data doesn't exist"
|
|
869
|
+
else {
|
|
870
|
+
for (const k in fills ?? {}) {
|
|
871
|
+
let text = fills[k]
|
|
872
|
+
if (typeof text === "number") text = Number(text).toString()
|
|
873
|
+
_data = _data.replace(
|
|
874
|
+
new RegExp(`\<${k}\>`, "g"),
|
|
875
|
+
text.replace(/'/g, "\\'")
|
|
876
|
+
)
|
|
877
|
+
}
|
|
878
|
+
out = _data
|
|
879
|
+
}
|
|
880
|
+
return { err, out }
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
async load({ src, data, fills, pid, jwk }) {
|
|
884
|
+
let fns = [
|
|
885
|
+
{
|
|
886
|
+
fn: this.transform,
|
|
887
|
+
args: { src, fills, data },
|
|
888
|
+
then: { "args.data": "inp" },
|
|
889
|
+
},
|
|
890
|
+
{ fn: this.eval, args: { pid } },
|
|
891
|
+
]
|
|
892
|
+
return await this.pipe({ jwk, fns })
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
async wait({ pid, attempts = 10 }) {
|
|
896
|
+
if (this.hb) return { err: null, pid }
|
|
897
|
+
let exist = false
|
|
898
|
+
let err = null
|
|
899
|
+
while (attempts > 0) {
|
|
900
|
+
if (!this.in_memory) await wait(1000)
|
|
901
|
+
const { res, err: _err } = await this.dry({ pid, data: "#Inbox" })
|
|
902
|
+
if (res?.error) return { err: res.error, pid }
|
|
903
|
+
if (typeof res?.Output === "object") break
|
|
904
|
+
attempts -= 1
|
|
905
|
+
if (attempts === 0) err = "timeout"
|
|
906
|
+
}
|
|
907
|
+
return { err, pid }
|
|
908
|
+
}
|
|
909
|
+
async attest({ id, jwk, tags }) {
|
|
910
|
+
return await this.ar.post({
|
|
911
|
+
tags: mergeLeft(tags, {
|
|
912
|
+
"Data-Protocol": "ao",
|
|
913
|
+
Type: "Attestation",
|
|
914
|
+
Message: id,
|
|
915
|
+
}),
|
|
916
|
+
jwk,
|
|
917
|
+
})
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
async avail({ ids, jwk, tags }) {
|
|
921
|
+
return await this.ar.post({
|
|
922
|
+
tags: mergeLeft(tags, {
|
|
923
|
+
"Data-Protocol": "WeaveDrive",
|
|
924
|
+
Variant: "WeaveDrive.tn.1",
|
|
925
|
+
Type: "Available",
|
|
926
|
+
ID: ids,
|
|
927
|
+
}),
|
|
928
|
+
jwk,
|
|
929
|
+
})
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
async deploy({
|
|
933
|
+
boot,
|
|
934
|
+
loads,
|
|
935
|
+
src,
|
|
936
|
+
src_data,
|
|
937
|
+
fills = {},
|
|
938
|
+
module = this.module,
|
|
939
|
+
scheduler = this.scheduler,
|
|
940
|
+
jwk,
|
|
941
|
+
tags = {},
|
|
942
|
+
data,
|
|
943
|
+
} = {}) {
|
|
944
|
+
let [fns, isBoot] = [[], false]
|
|
945
|
+
// AOS/Lua HB modes don't support On-Boot in spawn, so always load via eval
|
|
946
|
+
const hbNonLegacy = this.hb && this.mode && this.mode !== "legacy"
|
|
947
|
+
if (boot === true && !data && !hbNonLegacy) {
|
|
948
|
+
isBoot = true
|
|
949
|
+
fns = [
|
|
950
|
+
{
|
|
951
|
+
fn: this.transform,
|
|
952
|
+
args: { src, fills, data: src_data },
|
|
953
|
+
then: { "args.data": "inp" },
|
|
954
|
+
},
|
|
955
|
+
{
|
|
956
|
+
fn: this.spwn,
|
|
957
|
+
args: { boot: "Data", module, scheduler, tags },
|
|
958
|
+
then: { "args.pid": "pid" },
|
|
959
|
+
},
|
|
960
|
+
]
|
|
961
|
+
} else {
|
|
962
|
+
fns = [
|
|
963
|
+
{
|
|
964
|
+
fn: this.spwn,
|
|
965
|
+
args: { boot, module, scheduler, tags, data },
|
|
966
|
+
then: { "args.pid": "pid" },
|
|
967
|
+
},
|
|
968
|
+
]
|
|
969
|
+
}
|
|
970
|
+
fns.push({ fn: this.wait, then: { "args.pid": "pid" } })
|
|
971
|
+
let i = 0
|
|
972
|
+
for (const v of !loads
|
|
973
|
+
? src_data
|
|
974
|
+
? [{ data: src_data, src, fills }]
|
|
975
|
+
: []
|
|
976
|
+
: loads) {
|
|
977
|
+
if (!isBoot || i !== 0) {
|
|
978
|
+
let args = v
|
|
979
|
+
if (typeof args === "string") args = { data: v }
|
|
980
|
+
fns.push({ fn: this.load, args, then: { "args.pid": "pid" } })
|
|
981
|
+
}
|
|
982
|
+
i++
|
|
983
|
+
}
|
|
984
|
+
let result = await this.pipe({ jwk, fns })
|
|
985
|
+
if (result.pid) result.p = this.p(result.pid)
|
|
986
|
+
return result
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
async var({ pid, data, json = true, pretty = false }) {
|
|
990
|
+
if (json) {
|
|
991
|
+
const _var = (
|
|
992
|
+
await this.dry({ data: `require("json").encode(${data})`, pid })
|
|
993
|
+
)?.res?.Output?.data
|
|
994
|
+
if (_var) {
|
|
995
|
+
try {
|
|
996
|
+
return JSON.parse(strip(_var))
|
|
997
|
+
} catch (e) {
|
|
998
|
+
return strip(_var)
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
return _var
|
|
1002
|
+
} else {
|
|
1003
|
+
const _var = (await this.dry({ data, pid }))?.res?.Output?.data
|
|
1004
|
+
return pretty ? _var : strip(_var)
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
// Find the deepest slot from a push response's nested resulted-in structure.
|
|
1008
|
+
// Push resolves coroutines by scheduling responses to progressively deeper slots.
|
|
1009
|
+
_findDeepestSlot(pushOut, initial) {
|
|
1010
|
+
let max = initial
|
|
1011
|
+
const search = obj => {
|
|
1012
|
+
if (!obj || typeof obj !== "object") return
|
|
1013
|
+
if (obj.slot != null && Number(obj.slot) > max) max = Number(obj.slot)
|
|
1014
|
+
if (obj["resulted-in"]) search(obj["resulted-in"])
|
|
1015
|
+
for (const k of Object.keys(obj)) {
|
|
1016
|
+
if (/^\d+$/.test(k)) search(obj[k])
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
search(pushOut)
|
|
1020
|
+
return max
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
// Parse HB outbox from either a structured object or raw multipart response.
|
|
1024
|
+
// Returns a numbered-key outbox object compatible with _normalizeHBResult,
|
|
1025
|
+
// or null if parsing fails.
|
|
1026
|
+
_parseHBOutbox(hbRes) {
|
|
1027
|
+
if (!hbRes) return null
|
|
1028
|
+
const out = hbRes.out
|
|
1029
|
+
// Already a structured object with numbered keys
|
|
1030
|
+
if (out && typeof out === "object" && !Array.isArray(out)) {
|
|
1031
|
+
const numKeys = Object.keys(out).filter(k => /^\d+$/.test(k))
|
|
1032
|
+
if (numKeys.length > 0) return out
|
|
1033
|
+
}
|
|
1034
|
+
// Raw multipart string — extract messages from part headers
|
|
1035
|
+
const raw = typeof out === "string" ? out : hbRes.body
|
|
1036
|
+
if (!raw || typeof raw !== "string") return null
|
|
1037
|
+
const messages = {}
|
|
1038
|
+
// Split on multipart boundary
|
|
1039
|
+
const parts = raw.split(/--[A-Za-z0-9_-]+/)
|
|
1040
|
+
for (const part of parts) {
|
|
1041
|
+
if (!part?.trim()) continue
|
|
1042
|
+
// Match parts named "body/N", "body/outbox/N", or just "N"
|
|
1043
|
+
const nameMatch = part.match(
|
|
1044
|
+
/content-disposition:\s*(?:form-data|inline)\s*;?\s*name="?(?:body\/)?(?:outbox\/)?(\d+)"?/i,
|
|
1045
|
+
)
|
|
1046
|
+
if (!nameMatch) continue
|
|
1047
|
+
const idx = nameMatch[1]
|
|
1048
|
+
if (messages[idx]) continue // skip sub-parts like Tags
|
|
1049
|
+
// Extract Data from header line
|
|
1050
|
+
const dataMatch = part.match(/[\r\n]Data:\s*(.*?)(?:\r?\n|$)/i)
|
|
1051
|
+
if (dataMatch) {
|
|
1052
|
+
messages[idx] = {
|
|
1053
|
+
data: dataMatch[1].trim(),
|
|
1054
|
+
Tags: [],
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
if (Object.keys(messages).length > 0) return messages
|
|
1059
|
+
return null
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
_normalizeHBResult(res) {
|
|
1063
|
+
if (!res || this.mode === "legacy" || !this.mode) return res
|
|
1064
|
+
// After push, compute results may come back as raw multipart strings.
|
|
1065
|
+
// Parse them into numbered-key objects before extracting messages.
|
|
1066
|
+
if (typeof res === "string") {
|
|
1067
|
+
const parsed = this._parseHBOutbox({ out: res, body: res })
|
|
1068
|
+
if (parsed) res = parsed
|
|
1069
|
+
else return { Messages: [], Output: { data: "" }, Spawns: [] }
|
|
1070
|
+
}
|
|
1071
|
+
let messages = []
|
|
1072
|
+
if (this.mode === "aos" || this.mode === "wasm") {
|
|
1073
|
+
const keys = Object.keys(res)
|
|
1074
|
+
.filter(k => /^\d+$/.test(k))
|
|
1075
|
+
.sort((a, b) => Number(a) - Number(b))
|
|
1076
|
+
messages = keys.map(k => {
|
|
1077
|
+
const m = res[k]
|
|
1078
|
+
return { Data: m?.data ?? m?.Data ?? "", Tags: [] }
|
|
1079
|
+
})
|
|
1080
|
+
} else if (this.mode === "lua") {
|
|
1081
|
+
// Handle both array format (from computeLua) and numbered-key format
|
|
1082
|
+
// (from _parseHBOutbox after push resolution).
|
|
1083
|
+
const numKeys = Object.keys(res)
|
|
1084
|
+
.filter(k => /^\d+$/.test(k))
|
|
1085
|
+
.sort((a, b) => Number(a) - Number(b))
|
|
1086
|
+
if (numKeys.length > 0) {
|
|
1087
|
+
messages = numKeys.map(k => {
|
|
1088
|
+
const m = res[k]
|
|
1089
|
+
return { Data: m?.data ?? m?.Data ?? "", Tags: [] }
|
|
1090
|
+
})
|
|
1091
|
+
} else {
|
|
1092
|
+
const outbox = Array.isArray(res) ? res : res?.outbox ?? []
|
|
1093
|
+
messages = (Array.isArray(outbox) ? outbox : []).map(m => ({
|
|
1094
|
+
Data: m?.data ?? m?.Data ?? "",
|
|
1095
|
+
Tags: [],
|
|
1096
|
+
}))
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
return { Messages: messages, Output: { data: "" }, Spawns: [] }
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
p(pid) {
|
|
1103
|
+
return new Process(pid, this)
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
function strip(str) {
|
|
1108
|
+
return str.replace(/\x1B\[[0-9;]*[JKmsu]/g, "")
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
const getParams = (tags, opts) => {
|
|
1112
|
+
let _tags = tags
|
|
1113
|
+
let _opts = opts
|
|
1114
|
+
|
|
1115
|
+
if (
|
|
1116
|
+
(!isNil(tags?.get) ||
|
|
1117
|
+
!isNil(tags?.check) ||
|
|
1118
|
+
!isNil(tags?.jwk) ||
|
|
1119
|
+
!isNil(tags?.data) ||
|
|
1120
|
+
is(Boolean, tags) ||
|
|
1121
|
+
is(String, tags)) &&
|
|
1122
|
+
isNil(opts)
|
|
1123
|
+
) {
|
|
1124
|
+
_opts = tags
|
|
1125
|
+
_tags = {}
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
if (isNil(_opts)) _opts = { get: false }
|
|
1129
|
+
else if (is(Boolean, _opts) || is(String, _opts)) _opts = { get: _opts }
|
|
1130
|
+
return { _tags, _opts }
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
class Process {
|
|
1134
|
+
constructor(pid, ao) {
|
|
1135
|
+
this.ao = ao
|
|
1136
|
+
this.pid = pid
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
async load(opt = {}) {
|
|
1140
|
+
return await this.ao.load({ pid: this.pid, ...opt })
|
|
1141
|
+
}
|
|
1142
|
+
async msg(act, tags, opts) {
|
|
1143
|
+
const { _tags, _opts } = getParams(tags, opts)
|
|
1144
|
+
return await this.ao.msg({ pid: this.pid, act, tags: _tags, ..._opts })
|
|
1145
|
+
}
|
|
1146
|
+
async dry(act, tags, opts) {
|
|
1147
|
+
const { _tags, _opts } = getParams(tags, opts)
|
|
1148
|
+
return await this.ao.dry({ pid: this.pid, act, tags: _tags, ..._opts })
|
|
1149
|
+
}
|
|
1150
|
+
async res(opts) {
|
|
1151
|
+
const { _opts } = getParams(null, opts)
|
|
1152
|
+
return await this.ao.res({ pid: this.pid, ..._opts })
|
|
1153
|
+
}
|
|
1154
|
+
async o(name, opt) {
|
|
1155
|
+
const res = await this[name](...opt)
|
|
1156
|
+
if (res.err) throw Error(res.err)
|
|
1157
|
+
return res.out
|
|
1158
|
+
}
|
|
1159
|
+
async m(...opt) {
|
|
1160
|
+
return this.o("msg", opt)
|
|
1161
|
+
}
|
|
1162
|
+
async d(...opt) {
|
|
1163
|
+
return this.o("dry", opt)
|
|
1164
|
+
}
|
|
1165
|
+
async v(data, json = true, pretty = false) {
|
|
1166
|
+
return await this.ao.var({ pid: this.pid, data, json, pretty })
|
|
1167
|
+
}
|
|
1168
|
+
async r(...opt) {
|
|
1169
|
+
return this.o("res", opt)
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
export default AO
|