├── .github └── workflows │ └── deploy.yml ├── .gitignore ├── .gitpod.yml ├── .husky ├── commit-msg └── pre-commit ├── .nvmrc ├── .trunk ├── .gitignore ├── configs │ ├── .markdownlint.yaml │ ├── .shellcheckrc │ ├── .yamllint.yaml │ └── svgo.config.js └── trunk.yaml ├── .yarnrc.yml ├── CONTRIBUTING.md ├── README.md ├── commitlint.config.cjs ├── deploy.js ├── languages ├── README.md ├── def.js └── strings │ ├── en.json │ ├── ja.json │ └── zh.json ├── lint-staged.config.cjs ├── package-lock.json ├── package.json ├── scripts └── generate-llms-txt.js ├── src ├── .vitepress │ ├── config.js │ ├── locales.js │ └── theme │ │ ├── index.js │ │ └── style.css ├── concepts │ ├── CU-diagram.png │ ├── MU-diagram.png │ ├── SU-diagram.png │ ├── ao-pictograph-c94ebf2d.svg │ ├── eval.md │ ├── handler-diagram.png │ ├── holographic-state.md │ ├── how-it-works.md │ ├── index.md │ ├── lua.md │ ├── message-workflow-diagram.png │ ├── messages.md │ ├── process-diagram.png │ ├── processes.md │ ├── specs.md │ ├── tour.md │ └── units.md ├── guides │ ├── aoconnect │ │ ├── aoconnect.md │ │ ├── assign-data.md │ │ ├── calling-dryrun.md │ │ ├── connecting.md │ │ ├── installing-connect.md │ │ ├── monitoring-cron.md │ │ ├── reading-results.md │ │ ├── sending-messages.md │ │ ├── signers.md │ │ └── spawning-processes.md │ ├── aos │ │ ├── aolink-compute-example.png │ │ ├── aolink-info-handler-example.png │ │ ├── aolink-linked-message-example.png │ │ ├── aolink-list-example.png │ │ ├── aolink-message-and-token-example.png │ │ ├── aolink-message-details.png │ │ ├── aolink-process-details.png │ │ ├── aolink.png │ │ ├── blueprints │ │ │ ├── chatroom.md │ │ │ ├── cred-utils.md │ │ │ ├── index.md │ │ │ ├── staking.md │ │ │ ├── token.md │ │ │ └── voting.md │ │ ├── cli.md │ │ ├── editor.md │ │ ├── faq.md │ │ ├── inbox-and-handlers.md │ │ ├── index.md │ │ ├── installing.md │ │ ├── intro.md │ │ ├── load.md │ │ ├── modules │ │ │ ├── ao.md │ │ │ ├── base64.md │ │ │ ├── crypto.md │ │ │ ├── index.md │ │ │ ├── json.md │ │ │ ├── pretty.md │ │ │ └── utils.md │ │ ├── ownership.md │ │ ├── pingpong.md │ │ ├── prompt.md │ │ ├── tables-and-json.md │ │ ├── token.md │ │ └── troubleshooting.md │ ├── dev-cli │ │ └── index.md │ ├── index.md │ └── snacks │ │ ├── 0rbit │ │ ├── get-request.md │ │ ├── index.md │ │ └── post-request.md │ │ ├── sqlite.md │ │ └── weavedrive.md ├── index.md ├── ja │ ├── concepts │ │ ├── CU-diagram.png │ │ ├── MU-diagram.png │ │ ├── SU-diagram.png │ │ ├── ao-pictograph-c94ebf2d.svg │ │ ├── handler-diagram.png │ │ ├── holographic-state.md │ │ ├── how-it-works.md │ │ ├── index.md │ │ ├── lua.md │ │ ├── message-workflow-diagram.png │ │ ├── messages.md │ │ ├── process-diagram.png │ │ ├── processes.md │ │ ├── specs.md │ │ ├── tour.md │ │ └── units.md │ ├── guides │ │ ├── 0rbit │ │ │ ├── get-request.md │ │ │ ├── index.md │ │ │ └── post-request.md │ │ ├── aoconnect │ │ │ ├── aoconnect.md │ │ │ ├── assign-data.md │ │ │ ├── calling-dryrun.md │ │ │ ├── connecting.md │ │ │ ├── installing-connect.md │ │ │ ├── monitoring-cron.md │ │ │ ├── reading-results.md │ │ │ ├── sending-messages.md │ │ │ └── spawning-processes.md │ │ ├── aos │ │ │ ├── aolink-compute-example.png │ │ │ ├── aolink-info-handler-example.png │ │ │ ├── aolink-linked-message-example.png │ │ │ ├── aolink-list-example.png │ │ │ ├── aolink-message-and-token-example.png │ │ │ ├── aolink-message-details.png │ │ │ ├── aolink-process-details.png │ │ │ ├── aolink.png │ │ │ ├── blueprints │ │ │ │ ├── chatroom.md │ │ │ │ ├── cred-utils.md │ │ │ │ ├── index.md │ │ │ │ ├── staking.md │ │ │ │ ├── token.md │ │ │ │ └── voting.md │ │ │ ├── cli.md │ │ │ ├── editor.md │ │ │ ├── faq.md │ │ │ ├── inbox-and-handlers.md │ │ │ ├── index.md │ │ │ ├── installing.md │ │ │ ├── intro.md │ │ │ ├── load.md │ │ │ ├── modules │ │ │ │ ├── ao.md │ │ │ │ ├── base64.md │ │ │ │ ├── crypto.md │ │ │ │ ├── index.md │ │ │ │ ├── json.md │ │ │ │ ├── pretty.md │ │ │ │ └── utils.md │ │ │ ├── ownership.md │ │ │ ├── pingpong.md │ │ │ ├── prompt.md │ │ │ ├── tables-and-json.md │ │ │ ├── token.md │ │ │ └── troubleshooting.md │ │ ├── betteridea │ │ │ └── index.md │ │ └── index.md │ ├── index.md │ ├── llms-explanation.md │ ├── references │ │ ├── ao.md │ │ ├── community.md │ │ ├── cron.md │ │ ├── data.md │ │ ├── editor-setup.md │ │ ├── eval.md │ │ ├── handlers.md │ │ ├── index.md │ │ ├── lua.md │ │ ├── token.md │ │ └── wasm.md │ ├── tutorials │ │ ├── begin │ │ │ ├── chatroom.md │ │ │ ├── dao.md │ │ │ ├── index.md │ │ │ ├── messaging.md │ │ │ ├── preparations.md │ │ │ ├── rabbithole.md │ │ │ ├── token.md │ │ │ └── tokengating.md │ │ ├── bots-and-games │ │ │ ├── announcements.md │ │ │ ├── ao-effect.md │ │ │ ├── arena-mechanics.md │ │ │ ├── attacking.md │ │ │ ├── bringing-together.md │ │ │ ├── build-game.md │ │ │ ├── decisions.md │ │ │ ├── game-state.md │ │ │ └── index.md │ │ └── index.md │ └── welcome │ │ ├── getting-started.md │ │ ├── index.md │ │ └── testnet-info │ │ ├── index.md │ │ └── quests.md ├── llms-explanation.md ├── mainnet │ ├── ao-core-relay.md │ └── index.md ├── public │ ├── ao-effect-game-banner.png │ ├── ao-logo-grey.svg │ ├── ao-pictograph_dark.svg │ ├── ao-pictograph_light.svg │ ├── ao_pictograph_darkmode.svg │ ├── ao_pictograph_lightmode.svg │ ├── aos-print.png │ ├── chatroom1.png │ ├── chatroom2.png │ ├── chatroom3.png │ ├── chatroom4.png │ ├── chatroom5.png │ ├── chatroom6.png │ ├── chatroom7.png │ ├── chatroom8.png │ ├── ja │ │ ├── llms-full.txt │ │ └── llms.txt │ ├── llms-full.txt │ ├── llms.txt │ ├── messaging1.png │ ├── messaging2.png │ ├── token1.png │ ├── token2.png │ ├── token3.png │ ├── white_rabbit_outline.svg │ └── zh │ │ ├── llms-full.txt │ │ └── llms.txt ├── references │ ├── ao.md │ ├── betteridea │ │ └── index.md │ ├── community.md │ ├── cron.md │ ├── data.md │ ├── editor-setup.md │ ├── glossary.md │ ├── handlers.md │ ├── index.md │ ├── lua-optimization.md │ ├── lua.md │ ├── messaging.md │ ├── token.md │ └── wasm.md ├── releasenotes │ ├── aos-2_0_0.md │ ├── aos-2_0_1.md │ ├── aos-2_0_2.md │ └── index.md ├── tools │ └── replRenderer.jsx ├── tutorials │ ├── begin │ │ ├── chatroom.md │ │ ├── dao.md │ │ ├── index.md │ │ ├── messaging.md │ │ ├── preparations.md │ │ ├── rabbithole.md │ │ ├── token.md │ │ └── tokengating.md │ ├── bots-and-games │ │ ├── announcements.md │ │ ├── ao-effect.md │ │ ├── arena-mechanics.md │ │ ├── attacking.md │ │ ├── bringing-together.md │ │ ├── build-game.md │ │ ├── decisions.md │ │ ├── game-state.md │ │ └── index.md │ └── index.md ├── welcome │ ├── getting-started.md │ ├── index.md │ └── legacynet-info │ │ ├── index.md │ │ └── quests.md └── zh │ ├── concepts │ ├── CU-diagram.png │ ├── MU-diagram.png │ ├── SU-diagram.png │ ├── ao-pictograph-c94ebf2d.svg │ ├── handler-diagram.png │ ├── holographic-state.md │ ├── how-it-works.md │ ├── index.md │ ├── lua.md │ ├── message-workflow-diagram.png │ ├── messages.md │ ├── process-diagram.png │ ├── processes.md │ ├── specs.md │ ├── tour.md │ └── units.md │ ├── guides │ ├── aoconnect │ │ ├── aoconnect.md │ │ ├── calling-dryrun.md │ │ ├── connecting.md │ │ ├── installing-connect.md │ │ ├── monitoring-cron.md │ │ ├── reading-results.md │ │ ├── sending-messages.md │ │ └── spawning-processes.md │ ├── aos │ │ ├── aolink-compute-example.png │ │ ├── aolink-list-example.png │ │ ├── aolink-message-details.png │ │ ├── aolink-process-details.png │ │ ├── aolink.png │ │ ├── blueprints │ │ │ ├── chatroom.md │ │ │ ├── cred-utils.md │ │ │ ├── index.md │ │ │ ├── staking.md │ │ │ ├── token.md │ │ │ └── voting.md │ │ ├── cli.md │ │ ├── editor.md │ │ ├── faq.md │ │ ├── inbox-and-handlers.md │ │ ├── index.md │ │ ├── installing.md │ │ ├── intro.md │ │ ├── load.md │ │ ├── modules │ │ │ ├── ao.md │ │ │ ├── base64.md │ │ │ ├── index.md │ │ │ ├── json.md │ │ │ ├── pretty.md │ │ │ └── utils.md │ │ ├── ownership.md │ │ ├── pingpong.md │ │ ├── prompt.md │ │ ├── tables-and-json.md │ │ ├── token.md │ │ ├── token1.png │ │ ├── token2.png │ │ └── troubleshooting.md │ └── index.md │ ├── index.md │ ├── llms-explanation.md │ ├── references │ ├── ao.md │ ├── community.md │ ├── cron.md │ ├── data.md │ ├── editor-setup.md │ ├── handlers.md │ ├── index.md │ ├── lua.md │ ├── token.md │ └── wasm.md │ ├── tutorials │ ├── begin │ │ ├── aos-print.png │ │ ├── chatroom.md │ │ ├── chatroom1.png │ │ ├── chatroom2.png │ │ ├── chatroom3.png │ │ ├── chatroom4.png │ │ ├── chatroom5.png │ │ ├── chatroom6.png │ │ ├── chatroom7.png │ │ ├── chatroom8.png │ │ ├── dao.md │ │ ├── index.md │ │ ├── messaging.md │ │ ├── messaging2.png │ │ ├── preparations.md │ │ ├── rabbithole.md │ │ ├── token.md │ │ ├── token1.png │ │ ├── token2.png │ │ ├── token3.png │ │ ├── tokengating.md │ │ └── white_rabbit_outline.svg │ ├── bots-and-games │ │ ├── announcements.md │ │ ├── ao-effect-game-banner.png │ │ ├── ao-effect.md │ │ ├── arena-mechanics.md │ │ ├── attacking.md │ │ ├── bringing-together.md │ │ ├── build-game.md │ │ ├── decisions.md │ │ ├── game-state.md │ │ └── index.md │ └── index.md │ └── welcome │ ├── ao-logo-grey.svg │ ├── getting-started.md │ ├── index.md │ └── testnet-info │ ├── cred-and-quests.md │ └── index.md └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | node_modules 5 | /.pnp 6 | .pnp.js 7 | .yarn 8 | bun.lock 9 | 10 | # testing 11 | /coverage 12 | 13 | # misc 14 | .DS_Store 15 | *.pem 16 | 17 | # debug 18 | npm-debug.log* 19 | yarn-debug.log* 20 | yarn-error.log* 21 | .pnpm-debug.log* 22 | 23 | # local env files 24 | .env*.local 25 | 26 | # typescript 27 | *.tsbuildinfo 28 | .vercel 29 | 30 | src/.vitepress/cache 31 | src/.vitepress/cache/deps 32 | src/.vitepress/dist 33 | 34 | wallet.json 35 | 36 | # Trunk 37 | .trunk/ 38 | 39 | # VS Code 40 | .vscode/ 41 | 42 | # Cursor rules 43 | .cursor/rules -------------------------------------------------------------------------------- /.gitpod.yml: -------------------------------------------------------------------------------- 1 | tasks: 2 | - name: Dev 3 | init: | 4 | nvm install 5 | yarn 6 | command: | 7 | nvm install 8 | yarn dev 9 | 10 | ports: 11 | - port: 5173 12 | visibility: public 13 | onOpen: ignore 14 | -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | npx --no -- commitlint --edit "${1}" 2 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | yarn staged 2 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 18 -------------------------------------------------------------------------------- /.trunk/.gitignore: -------------------------------------------------------------------------------- 1 | *out 2 | *logs 3 | *actions 4 | *notifications 5 | *tools 6 | plugins 7 | user_trunk.yaml 8 | user.yaml 9 | tmp 10 | -------------------------------------------------------------------------------- /.trunk/configs/.markdownlint.yaml: -------------------------------------------------------------------------------- 1 | # Autoformatter friendly markdownlint config (all formatting rules disabled) 2 | default: true 3 | blank_lines: false 4 | bullet: false 5 | html: false 6 | indentation: false 7 | line_length: false 8 | spaces: false 9 | url: false 10 | whitespace: false 11 | -------------------------------------------------------------------------------- /.trunk/configs/.shellcheckrc: -------------------------------------------------------------------------------- 1 | enable=all 2 | source-path=SCRIPTDIR 3 | disable=SC2154 4 | 5 | # If you're having issues with shellcheck following source, disable the errors via: 6 | # disable=SC1090 7 | # disable=SC1091 8 | -------------------------------------------------------------------------------- /.trunk/configs/.yamllint.yaml: -------------------------------------------------------------------------------- 1 | rules: 2 | quoted-strings: 3 | required: only-when-needed 4 | extra-allowed: ["{|}"] 5 | empty-values: 6 | forbid-in-block-mappings: true 7 | forbid-in-flow-mappings: true 8 | key-duplicates: {} 9 | octal-values: 10 | forbid-implicit-octal: true 11 | -------------------------------------------------------------------------------- /.trunk/configs/svgo.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [ 3 | { 4 | name: "preset-default", 5 | params: { 6 | overrides: { 7 | removeViewBox: false, // https://github.com/svg/svgo/issues/1128 8 | sortAttrs: true, 9 | removeOffCanvasPaths: true, 10 | }, 11 | }, 12 | }, 13 | ], 14 | }; 15 | -------------------------------------------------------------------------------- /.trunk/trunk.yaml: -------------------------------------------------------------------------------- 1 | # This file controls the behavior of Trunk: https://docs.trunk.io/cli 2 | # To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml 3 | version: 0.1 4 | cli: 5 | version: 1.19.0 6 | # Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins) 7 | plugins: 8 | sources: 9 | - id: trunk 10 | ref: v1.4.2 11 | uri: https://github.com/trunk-io/plugins 12 | # Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes) 13 | runtimes: 14 | enabled: 15 | - go@1.21.0 16 | - node@18.12.1 17 | - python@3.10.8 18 | # This is the section where you manage your linters. (https://docs.trunk.io/check/configuration) 19 | lint: 20 | enabled: 21 | - actionlint@1.6.26 22 | - checkov@3.1.70 23 | - git-diff-check 24 | - markdownlint@0.38.0 25 | - osv-scanner@1.6.1 26 | - prettier@3.2.4 27 | - shellcheck@0.9.0 28 | - shfmt@3.6.0 29 | - svgo@3.2.0 30 | - trivy@0.48.3 31 | - trufflehog@3.64.0 32 | - yamllint@1.33.0 33 | actions: 34 | disabled: 35 | - trunk-announce 36 | - trunk-check-pre-push 37 | - trunk-fmt-pre-commit 38 | enabled: 39 | - trunk-upgrade-available 40 | -------------------------------------------------------------------------------- /.yarnrc.yml: -------------------------------------------------------------------------------- 1 | nodeLinker: node-modules 2 | ignore-engines: true 3 | -------------------------------------------------------------------------------- /commitlint.config.cjs: -------------------------------------------------------------------------------- 1 | 2 | module.exports = { 3 | extends: ['@commitlint/config-conventional'] 4 | } 5 | -------------------------------------------------------------------------------- /deploy.js: -------------------------------------------------------------------------------- 1 | import { readFileSync } from "node:fs"; 2 | 3 | import { ANT, ArweaveSigner } from "@ar.io/sdk"; 4 | 5 | function env(key) { 6 | if (!process.env[key]) { 7 | throw new Error(`Error with ENV VAR: ${key}`); 8 | } 9 | return process.env[key]; 10 | } 11 | 12 | const actions = { 13 | async UPDATE_ARNS() { 14 | const WALLET = env("WALLET"); 15 | const MANIFEST_ID = env("MANIFEST_ID"); 16 | 17 | const jwk = JSON.parse(readFileSync(WALLET)); 18 | 19 | /** 20 | * The ao ANT Contract 21 | * See https://sonar.warp.cc/?#/app/contract/uOf4TMgQxdaSXgcZ778PZR13UQPKJoZVK2ZvLAE90Xg?network=mainnet%23 22 | */ 23 | // const ANT = "uOf4TMgQxdaSXgcZ778PZR13UQPKJoZVK2ZvLAE90Xg"; 24 | const ANT_PROCESS = "YFbfeqZMbPVGFjQ-PHJY-Y99JQu7O3Jdet06pJnD5iI"; 25 | 26 | const signer = new ArweaveSigner(jwk); 27 | const ant = ANT.init({ processId: ANT_PROCESS, signer }); 28 | 29 | await ant 30 | .setRecord({ 31 | undername: "cookbook", 32 | transactionId: MANIFEST_ID, 33 | ttlSeconds: 3600, 34 | }) 35 | .then((res) => console.log("Updated ao ANT record", res.id)); 36 | 37 | return MANIFEST_ID; 38 | }, 39 | }; 40 | 41 | const ACTION = env("ACTION"); 42 | if (!actions[ACTION]) throw new Error(`'${ACTION}' is not a valid action`); 43 | 44 | actions[ACTION](); 45 | -------------------------------------------------------------------------------- /languages/README.md: -------------------------------------------------------------------------------- 1 | # Translation 2 | 3 | 4 | 5 | - [Add a new language](#add-a-new-language) 6 | 7 | 8 | 9 | ## Add a new language 10 | 11 | To add a new language, add an object to the `language` array in `def.js`. The structure of the object is as follow: 12 | 13 | ```js 14 | { 15 | display: "Español", // Name of the language displayed in UI 16 | name: "Spanish", // Name of the language in English, used by OpenAI translation 17 | code: "es", // 2 letter language code (ISO 639‑1) 18 | strings: esStrings, // JSON object of translated UI element strings 19 | } 20 | ``` 21 | 22 | Create a new `.json` file under the `strings` folder with the 2 letter language code as the name of the file. If you wish to let OpenAI handle the translation, set the content of the file to `{}`. Otherwise, if you wish to translate some of the strings manually, add the key and it's translated string to the json object. The keys can be found in the english string file `en.json`. 23 | 24 | Create a folder with the name set as the 2 letter language code under the `src` folder. 25 | -------------------------------------------------------------------------------- /languages/def.js: -------------------------------------------------------------------------------- 1 | // UI elements strings json file for new languages 2 | import { createRequire } from "node:module"; 3 | 4 | const enStrings = createRequire(import.meta.url)("./strings/en.json"); 5 | const zhStrings = createRequire(import.meta.url)("./strings/zh.json"); 6 | const jaStrings = createRequire(import.meta.url)("./strings/ja.json"); 7 | /** 8 | * Start adding new languages by making a new language object inside the array 9 | * 10 | * @see file://./README.md#add-a-new-language 11 | */ 12 | const languages = [ 13 | { 14 | display: "中文", // Name of the language displayed in UI 15 | name: "中文", // Name of the language in English, used by OpenAI translation 16 | code: "zh", // 2 letter language code (ISO 639‑1) 17 | strings: zhStrings, // JSON object of translated UI element strings 18 | }, 19 | { 20 | display: "日本語", // Name of the language displayed in UI 21 | name: "Japanese", // Name of the language in English, used by OpenAI translation 22 | code: "ja", // 2 letter language code (ISO 639‑1) 23 | strings: jaStrings, // JSON object of translated UI element strings 24 | }, 25 | ]; 26 | 27 | const i18n_strs = languages.reduce((langs, currentLang) => { 28 | langs[currentLang.code] = currentLang.strings; 29 | return langs; 30 | }, {}); 31 | 32 | const get_i18n_str = (langCode = "en", key, fallbackStr) => { 33 | const engStr = enStrings[key] || fallbackStr; 34 | if (langCode === "en") return engStr; 35 | return i18n_strs[langCode][key] || engStr; 36 | }; 37 | 38 | export { languages, get_i18n_str }; 39 | -------------------------------------------------------------------------------- /lint-staged.config.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "**/*/README.md": ["markdown-toc-gen insert", "prettier --write"], 3 | "**/*.{ts,tsx,js,jsx,md,json,yml}": ["prettier --write"], 4 | }; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "docs", 3 | "version": "0.0.2", 4 | "description": "ao Cookbook", 5 | "repository": "https://github.com/permaweb/ao-cookbook", 6 | "license": "Apache-2.0", 7 | "type": "module", 8 | "scripts": { 9 | "arns": "ACTION=UPDATE_ARNS node deploy.js", 10 | "build": "node scripts/generate-llms-txt.js && vitepress build src", 11 | "dev": "node scripts/generate-llms-txt.js && vitepress dev src", 12 | "prepare": "husky", 13 | "preview": "vitepress preview src", 14 | "staged": "lint-staged --allow-empty --concurrent false", 15 | "generate-llms": "node scripts/generate-llms-txt.js" 16 | }, 17 | "devDependencies": { 18 | "@commitlint/cli": "^19.4.0", 19 | "@commitlint/config-conventional": "^19.2.2", 20 | "husky": "^9.1.4", 21 | "lint-staged": "^15.2.8", 22 | "markdown-toc-gen": "^1.0.1", 23 | "permaweb-deploy": "^1.1.7", 24 | "prettier": "^3.3.3", 25 | "vitepress": "1.3.2", 26 | "vue": "^3.4.36" 27 | }, 28 | "authors": { 29 | "name": "Tyler Hall", 30 | "email": "tyler@hyper.io" 31 | }, 32 | "dependencies": { 33 | "@betteridea/codecell": "^1.4.3", 34 | "globby": "^14.1.0" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/.vitepress/config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "vitepress"; 2 | 3 | import { languages } from "../../languages/def.js"; 4 | import { localeConfig } from "./locales.js"; 5 | 6 | // https://vitepress.dev/reference/site-config 7 | const config = defineConfig({ 8 | themeConfig: { 9 | /** 10 | * Enable Search 11 | */ 12 | search: { 13 | provider: "local", 14 | }, 15 | }, 16 | head: [ 17 | ["meta", { name: "apple-mobile-web-app-capable", content: "yes" }], 18 | [ 19 | "meta", 20 | { 21 | name: "apple-mobile-web-app-status-bar-style", 22 | content: "black", 23 | }, 24 | ], 25 | [ 26 | "link", 27 | { 28 | rel: "icon", 29 | type: "image/svg+xml", 30 | href: "/ao_pictograph_lightmode.svg", 31 | }, 32 | ], 33 | ["link", { rel: "preconnect", href: "https://fonts.googleapis.com" }], 34 | ["link", { rel: "preconnect", href: "https://fonts.gstatic.com" }], 35 | [ 36 | "link", 37 | { 38 | rel: "stylesheet", 39 | href: "https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600&display=swap", 40 | }, 41 | ], 42 | ], 43 | 44 | markdown: { 45 | lineNumbers: false, 46 | }, 47 | 48 | /** 49 | * The copy that comprises the layout and theme of the site 50 | * must also be internationalized, so we create a locale configuration 51 | * for each language we support 52 | * 53 | * See https://vitepress.dev/guide/i18n#internationalization 54 | */ 55 | locales: languages.reduce( 56 | (locales, { code }) => { 57 | locales[code] = localeConfig(code); 58 | return locales; 59 | }, 60 | { root: localeConfig("en") }, 61 | ), 62 | 63 | transformPageData: (pageData) => { 64 | return { 65 | i18n: languages[pageData.frontmatter.locale || "en"], 66 | }; 67 | }, 68 | /** 69 | * Needed for shim for 70 | */ 71 | vite: { 72 | build: { 73 | rollupOptions: { 74 | output: { 75 | chunkFileNames: "assets/chunks/[name].js", 76 | }, 77 | }, 78 | }, 79 | }, 80 | }); 81 | 82 | export default config; 83 | -------------------------------------------------------------------------------- /src/.vitepress/theme/index.js: -------------------------------------------------------------------------------- 1 | // https://vitepress.dev/guide/custom-theme 2 | 3 | import { h } from "vue"; 4 | import DefaultTheme from "vitepress/theme-without-fonts"; 5 | import "./style.css"; 6 | 7 | /** @type {import('vitepress').Theme} */ 8 | export default { 9 | extends: DefaultTheme, 10 | Layout: () => { 11 | return h(DefaultTheme.Layout, null, { 12 | // https://vitepress.dev/guide/extending-default-theme#layout-slots 13 | }); 14 | }, 15 | enhanceApp({ app, router, siteData }) { 16 | /** 17 | * Original issue: https://github.com/permaweb/ao-cookbook/issues/17 18 | * 19 | * The path manifest for the site will contain mappings to index.html pages like 20 | * '/getting-started/index.html' 👍 21 | * 22 | * But the Vue Router seems to be tranparently removing the 'index.html' 23 | * bit from the url on navigation (presumably to make it 'prettier') eg: 24 | * 25 | * nav to '/getting-started/index.html' will work but then url will be 26 | * '/getting-started/' 👎 27 | * 28 | * This causes a subsequent refresh of the page to not be resolved by the Gateway -- 29 | * the path manifest doesn't contain a mapping for it, so the Gateway reasonbly 30 | * returns a 404 31 | * 32 | * To get around ths, we use a Vue Router onAfterRouteChanged() lifecycle hook 33 | * to check if the url ends with a '/'. If it does, then we update the url to include 'index.html'. 34 | * 35 | * This way, on page refresh, the Gateway can correctly resolve the asset from the path manifest 36 | */ 37 | router.onAfterRouteChanged = (to) => { 38 | /** 39 | * Should not run when building 40 | */ 41 | if (import.meta.env.SSR) return; 42 | 43 | if (to.endsWith("/") && to !== "/") { 44 | history.replaceState({}, null, `${to}index.html`); 45 | } 46 | }; 47 | }, 48 | }; 49 | -------------------------------------------------------------------------------- /src/concepts/CU-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/concepts/CU-diagram.png -------------------------------------------------------------------------------- /src/concepts/MU-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/concepts/MU-diagram.png -------------------------------------------------------------------------------- /src/concepts/SU-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/concepts/SU-diagram.png -------------------------------------------------------------------------------- /src/concepts/ao-pictograph-c94ebf2d.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/concepts/eval.md: -------------------------------------------------------------------------------- 1 | # Eval 2 | 3 | Each AO process includes an onboard `Eval` handler that evaluates any new code it receives. This handler determines the appropriate action for the code and verifies that the message originates from the process owner. 4 | 5 | The `Eval` handler can also be manually triggered to evaluate the `Data` field from an incoming message. When you use the `.load` function to load a file into a process, it relies on the `Eval` handler to evaluate the file’s content under the hood. 6 | 7 | ## Sending an Eval Message in NodeJS 8 | 9 | ```js 10 | import { readFileSync } from "node:fs"; 11 | import { message, createDataItemSigner } from "@permaweb/aoconnect"; 12 | 13 | const wallet = JSON.parse( 14 | readFileSync("/path/to/arweave/wallet.json").toString(), 15 | ); 16 | 17 | await message({ 18 | // The arweave TxID of the process, this will become the "target". 19 | process: "process-ID", // Replace with the actual process ID 20 | 21 | // Tagging the Eval Action so the receiving process evaluates and adds the new Handler from the Data field. 22 | tags: [ 23 | { name: "Action", value: "Eval" }, 24 | { 25 | name: "Data", 26 | value: 'Handlers.add("ping", Handlers.utils.reply("pong"))', 27 | }, 28 | ], 29 | 30 | // A signer function used to build the message "signature" 31 | signer: createDataItemSigner(wallet), 32 | }) 33 | .then(console.log) 34 | .catch(console.error); 35 | ``` 36 | 37 | ## Sending an Eval Message in a Browser 38 | 39 | ```js 40 | import { message, createDataItemSigner } from "@permaweb/aoconnect"; 41 | 42 | await message({ 43 | // The arweave TxID of the process, this will become the "target". 44 | process: "process-ID", // Replace with the actual process ID 45 | 46 | // Tagging the Eval Action so the receiving process evaluates and adds the new Handler from the Data field. 47 | tags: [ 48 | { name: "Action", value: "Eval" }, 49 | { 50 | name: "Data", 51 | value: 'Handlers.add("ping", Handlers.utils.reply("pong"))', 52 | }, 53 | ], 54 | 55 | // A signer function used to build the message "signature" 56 | signer: createDataItemSigner(globalThis.arweaveWallet), 57 | }) 58 | .then(console.log) 59 | .catch(console.error); 60 | ``` 61 | -------------------------------------------------------------------------------- /src/concepts/handler-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/concepts/handler-diagram.png -------------------------------------------------------------------------------- /src/concepts/holographic-state.md: -------------------------------------------------------------------------------- 1 | TODO 2 | -------------------------------------------------------------------------------- /src/concepts/how-it-works.md: -------------------------------------------------------------------------------- 1 | # How ao messaging works 2 | 3 | Before we dive in to ao, I want to share with you a little information about unix. Unix is a powerful operating system, but in its design it is focused on two Principal "Types". Files and Programs. A File is data and a Program is logic, when you combine the two you get information. 4 | 5 | `Input.file | TransformProgram | Output.file` 6 | 7 | You might have done something like this on the command line without knowing what you were doing. Being able to connect files to programs and return files which can then be passed to other programs creates a complex system composed of simple applications. This is a very powerful idea. 8 | 9 | Now, lets talk about `ao` the hyper parallel computer, and lets change the idea of a File to the `ao` concept of a Message and the idea of a Program to the `ao` concept of a Process. The `ao` computer takes messages and sends them to Processes in which those Processes can output messages that can be sent to other Processes. The result is a complex system built on simple modular logic containers. 10 | 11 | `MessageA | Process | MessageB` 12 | 13 | ![ao-messages](https://g8way.io/eAoqMqhwQ5vnpH_NJ6H2PiGgrcGDprtDIUH9Re2xcic) 14 | 15 | Here is a description of the process as outlined in the flowchart: 16 | 17 | 1. A message is initiated from an ao Connect. This message is sent to the `mu` service using a POST request. The body of the request contains data following a protocol, labeled 'ao', and is of the type 'Message'. 18 | 19 | 2. The `mu` service processes the POST request and forwards the message to the `su` service. This is also done using a POST request with the same data protocol and message type. 20 | 21 | 3. The `su` service stores the assignment and message on Arweave. 22 | 23 | 4. A GET request is made to the `cu` service to retrieve results based on a message ID. The `cu` is a service that evaluates messages on processes and can return results based on an individual message identifier. 24 | 25 | 5. A GET request is made to the `su` service to retrieve the assignment and message. This request is looking for messages from a process ID, within a range of time from a start (from the last evaluation point) to (to the current message ID). 26 | 27 | 6. The final step is to push any outbox Messages. It involves reviewing the messages and spawns in the Result object. Based on the outcome of this check, the steps 2, 3, and 4 may be repeated for each relevant message or spawn. 28 | -------------------------------------------------------------------------------- /src/concepts/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "First POST Request" 4 | link: "../guides/snacks/0rbit/post-request" 5 | next: 6 | text: "Specifications" 7 | link: "./specs" 8 | --- 9 | 10 | # Concepts 11 | 12 | This section explains the core concepts and architecture behind AO, helping you understand how the system works at a fundamental level. 13 | 14 | ## System Architecture 15 | 16 | AO is built on a few fundamental principles that form its foundation: 17 | 18 | - **Two core types**: Messages and Processes - the basic building blocks of the AO ecosystem 19 | - **No shared state, only Holographic State** - a unique approach to distributed computing 20 | - **Decentralized Computer (Grid)** - enabling truly distributed applications 21 | 22 | ## Core Components 23 | 24 | Explore these foundational concepts to gain a deeper understanding of AO: 25 | 26 | - [How it Works](how-it-works) - An overview of AO's architecture and how the different parts interact 27 | - [Processes](processes) - Learn about processes, the computational units in AO 28 | - [Messages](messages) - Understand the messaging system that enables communication 29 | - [Evaluation](eval) - Discover how code execution works in the AO environment 30 | - [Units](units) - Learn about the computational units that power the AO network 31 | 32 | ## Technical Foundations 33 | 34 | - [Specifications](specs) - Detailed technical specifications for the AO protocol 35 | 36 | ## Getting Started 37 | 38 | - [Meet Lua](lua) - Introduction to Lua, the programming language used in AO 39 | - [AO System Tour](tour) - A guided tour of the AO system and its capabilities 40 | 41 | ## Navigation 42 | 43 | Use the sidebar to navigate between concept topics. Each document provides in-depth information about a specific aspect of AO. 44 | -------------------------------------------------------------------------------- /src/concepts/message-workflow-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/concepts/message-workflow-diagram.png -------------------------------------------------------------------------------- /src/concepts/process-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/concepts/process-diagram.png -------------------------------------------------------------------------------- /src/concepts/specs.md: -------------------------------------------------------------------------------- 1 | # ao Specs 2 | 3 | ### What is `ao`? 4 | 5 | The `ao` computer is the [actor oriented](https://en.wikipedia.org/wiki/Actor_model) machine that emerges from the network of nodes that adhere to its core data protocol, running on the [Arweave](https://arweave.org) network. This document gives a brief introduction to the protocol and its functionality, as well as its technical details, such that builders can create new implementations and services that integrate with it. 6 | 7 | The `ao` computer is a single, unified computing environment (a [Single System Image](https://en.wikipedia.org/wiki/Single_system_image)), hosted on a heterogenous set of nodes in a distributed network. `ao` is designed to offer an environment in which an arbitrary number of parallel processes can be resident, coordinating through an open message passing layer. This message passing standard connects the machine's independently operating processes together into a 'web' -- in the same way that websites operate on independent servers but are conjoined into a cohesive, unified experience via hyperlinks. 8 | -------------------------------------------------------------------------------- /src/guides/aoconnect/aoconnect.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "aos" 4 | link: "/guides/aos" 5 | next: 6 | text: "Installing aoconnect" 7 | link: "/guides/aoconnect/installing-connect" 8 | --- 9 | 10 | # aoconnect 11 | 12 | ao connect is a Javascript/Typescript library to interact with the system from Node JS or the browser. 13 | 14 | Guides in this section provide snippets on how to utilize ao connect. All snippets are written in Javascript but should translate easily to Typescript. 15 | -------------------------------------------------------------------------------- /src/guides/aoconnect/assign-data.md: -------------------------------------------------------------------------------- 1 | # Sending an Assignment to a Process 2 | 3 | Assignments can be used to load Data from another Message into a Process. Or to not duplicate Messages. You can create one Message and then assign it to any number of processes. This will make it available to the Processes you have sent an Assignment to. 4 | 5 | ## Sending an Assignment in NodeJS 6 | 7 | ```js 8 | import { readFileSync } from "node:fs"; 9 | 10 | import { assign } from "@permaweb/aoconnect"; 11 | 12 | await assign({ 13 | process: "process-id", 14 | message: "message-id", 15 | }) 16 | .then(console.log) 17 | .catch(console.error); 18 | ``` 19 | 20 | ## Excluding DataItem fields 21 | 22 | You can also exclude most DataItem fields which will tell the CU not to load them into your process. You may want to do this if you need only the header data like the Tags and not the Data itself etc... If you exclude the Owner it wont have any effect because the CU requires the Owner, so excluding Owner will be ignored by the CU. Only capitalized DataItem/Message fields will have an effect in the CU. 23 | 24 | ```js 25 | import { readFileSync } from "node:fs"; 26 | 27 | import { assign } from "@permaweb/aoconnect"; 28 | 29 | await assign({ 30 | process: "process-id", 31 | message: "message-id", 32 | exclude: ["Data", "Anchor"], 33 | }) 34 | .then(console.log) 35 | .catch(console.error); 36 | ``` 37 | 38 | ## Assigning L1 Transactions 39 | 40 | You can also assign a layer 1 transaction by passing the baseLayer param into assign. This is useful for minting tokens etc... using the base layer. By default, if the L1 tx does not have at least 20 confirmations the SU will reject it. This can be changed by setting the `Settlement-Depth` tag to a different number on the Process when it is created. 41 | 42 | ```js 43 | import { readFileSync } from "node:fs"; 44 | 45 | import { assign } from "@permaweb/aoconnect"; 46 | 47 | await assign({ 48 | process: "process-id", 49 | message: "layer 1 tx id", 50 | baseLayer: true, 51 | }) 52 | .then(console.log) 53 | .catch(console.error); 54 | ``` 55 | -------------------------------------------------------------------------------- /src/guides/aoconnect/calling-dryrun.md: -------------------------------------------------------------------------------- 1 | # Calling DryRun 2 | 3 | DryRun is the process of sending a message object to a specific process and getting the Result object back, but the memory is not saved, it is perfect to create a read message to return the current value of memory. For example, a balance of a token, or a result of a transfer, etc. You can use DryRun to obtain an output without sending an actual message. 4 | 5 | ```js 6 | import { createDataItemSigner, dryrun } from "@permaweb/aoconnect"; 7 | 8 | const result = await dryrun({ 9 | process: 'PROCESSID', 10 | data: '', 11 | tags: [{name: 'Action', value: 'Balance'}, 12 | anchor: '1234', 13 | ...rest are optional (Id, Owner, etc) 14 | }); 15 | 16 | console.log(result.Messages[0]); 17 | ``` 18 | -------------------------------------------------------------------------------- /src/guides/aoconnect/connecting.md: -------------------------------------------------------------------------------- 1 | # Connecting to specific ao nodes 2 | 3 | When including ao connect in your code you have the ability to connect to a specific MU and CU, as well as being able to specify an Arweave gateway. This can be done by importing the "connect" function and extracting the functions from a call to the "connect" function. 4 | 5 | You may want to do this if you want to know which MU is being called when you send your message so that later you can debug from the specified MU. You also may want to read a result from a specific CU. You may in fact just prefer a particular MU and CU for a different reason. You can specify the gateway in order to use something other than the default, which is arweave.net. 6 | 7 | ## Importing without a call to connect 8 | 9 | ```js 10 | // Here aoconnect will implicitly use the default nodes/units 11 | import { 12 | result, 13 | results, 14 | message, 15 | spawn, 16 | monitor, 17 | unmonitor, 18 | dryrun, 19 | } from "@permaweb/aoconnect"; 20 | ``` 21 | 22 | ## Connecting to a specific MU, CU, and gateway 23 | 24 | ```js 25 | import { connect } from "@permaweb/aoconnect"; 26 | 27 | const { result, results, message, spawn, monitor, unmonitor, dryrun } = connect( 28 | { 29 | MU_URL: "https://mu.ao-testnet.xyz", 30 | CU_URL: "https://cu.ao-testnet.xyz", 31 | GATEWAY_URL: "https://arweave.net", 32 | }, 33 | ); 34 | 35 | // now spawn, message, and result can be used the same way as if they were imported directly 36 | ``` 37 | 38 |
39 | 40 | All three of these parameters to connect are optional and it is valid to specify only 1 or 2 of them, or none. You could pass in just the MU_URL, for example. 41 | 42 | ```js 43 | import { connect } from "@permaweb/aoconnect"; 44 | 45 | const { result, results, message, spawn, monitor, unmonitor, dryrun } = connect( 46 | { 47 | MU_URL: "https://ao-mu-1.onrender.com", 48 | }, 49 | ); 50 | ``` 51 | -------------------------------------------------------------------------------- /src/guides/aoconnect/installing-connect.md: -------------------------------------------------------------------------------- 1 | # Installing ao connect 2 | 3 | ## Prerequisites 4 | 5 | --- 6 | 7 | In order to install ao connect into your app you must have NodeJS/NPM 18 or higher. 8 |
9 | 10 | ## Installing 11 | 12 | ### npm 13 | 14 | ```sh 15 | npm install --save @permaweb/aoconnect 16 | ``` 17 | 18 | ### yarn 19 | 20 | ```sh 21 | yarn add @permaweb/aoconnect -D 22 | ``` 23 | 24 |
25 | 26 | This module can now be used from NodeJS as well as a browser, it can be included as shown below. 27 | 28 | #### ESM (Node & Browser) aka type: `module` 29 | 30 | ```js 31 | import { 32 | result, 33 | results, 34 | message, 35 | spawn, 36 | monitor, 37 | unmonitor, 38 | dryrun, 39 | } from "@permaweb/aoconnect"; 40 | ``` 41 | 42 | #### CJS (Node) type: `commonjs` 43 | 44 | ```js 45 | const { 46 | result, 47 | results, 48 | message, 49 | spawn, 50 | monitor, 51 | unmonitor, 52 | dryrun, 53 | } = require("@permaweb/aoconnect"); 54 | ``` 55 | -------------------------------------------------------------------------------- /src/guides/aoconnect/monitoring-cron.md: -------------------------------------------------------------------------------- 1 | # Monitoring Cron 2 | 3 | When using cron messages, ao users need a way to start ingesting the messages, using this monitor method, ao users can initiate the subscription service for cron messages. Setting cron tags means that your process will start producing cron results in its outbox, but you need to monitor these results if you want messages from those results to be pushed through the network. 4 | 5 | ```js 6 | import { readFileSync } from "node:fs"; 7 | import { createDataItemSigner, monitor } from "@permaweb/aoconnect"; 8 | 9 | const wallet = JSON.parse( 10 | readFileSync("/path/to/arweave/wallet.json").toString(), 11 | ); 12 | 13 | const result = await monitor({ 14 | process: "process-id", 15 | signer: createDataItemSigner(wallet), 16 | }); 17 | ``` 18 | 19 | You can stop monitoring by calling unmonitor 20 | 21 | ```js 22 | import { readFileSync } from "node:fs"; 23 | import { createDataItemSigner, unmonitor } from "@permaweb/aoconnect"; 24 | 25 | const wallet = JSON.parse( 26 | readFileSync("/path/to/arweave/wallet.json").toString(), 27 | ); 28 | 29 | const result = await unmonitor({ 30 | process: "process-id", 31 | signer: createDataItemSigner(wallet), 32 | }); 33 | ``` 34 | -------------------------------------------------------------------------------- /src/guides/aoconnect/reading-results.md: -------------------------------------------------------------------------------- 1 | # Reading results from an ao Process 2 | 3 | In ao, messages produce results which are made available by Compute Units (CU's). Results are JSON objects consisting of the following fields: messages, spawns, output and error. 4 | 5 | Results are what the ao system uses to send messages and spawns that are generated by processes. A process can send a message just like you can as a developer, by returning messages and spawns in a result. 6 | 7 | You may want to access a result to display the output generated by your message. Or you may want to see what messages etc., were generated. You do not need to take the messages and spawns from a result and send them yourself. They are automatically handled by Messenger Units (MU's). A call to `results` can also provide you paginated list of multiple results. 8 | 9 | ## Fetching a single result 10 | 11 | ```js 12 | import { result } from "@permaweb/aoconnect"; 13 | 14 | let { Messages, Spawns, Output, Error } = await result({ 15 | // the arweave TxID of the message 16 | message: "message-id", 17 | // the arweave TxID of the process 18 | process: "process-id", 19 | }); 20 | ``` 21 | 22 | ## Fetching a set of results 23 | 24 | ```js 25 | import { results } from "@permaweb/aoconnect"; 26 | 27 | // fetching the first page of results 28 | let resultsOut = await results({ 29 | process: "process-id", 30 | sort: "ASC", 31 | limit: 25, 32 | }); 33 | 34 | // calling more with a cursor 35 | let resultsOut2 = await results({ 36 | process: "process-id", 37 | from: resultsOut.edges?.[resultsOut.edges.length - 1]?.cursor ?? null, 38 | sort: "ASC", 39 | limit: 25, 40 | }); 41 | ``` 42 | -------------------------------------------------------------------------------- /src/guides/aos/aolink-compute-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/guides/aos/aolink-compute-example.png -------------------------------------------------------------------------------- /src/guides/aos/aolink-info-handler-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/guides/aos/aolink-info-handler-example.png -------------------------------------------------------------------------------- /src/guides/aos/aolink-linked-message-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/guides/aos/aolink-linked-message-example.png -------------------------------------------------------------------------------- /src/guides/aos/aolink-list-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/guides/aos/aolink-list-example.png -------------------------------------------------------------------------------- /src/guides/aos/aolink-message-and-token-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/guides/aos/aolink-message-and-token-example.png -------------------------------------------------------------------------------- /src/guides/aos/aolink-message-details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/guides/aos/aolink-message-details.png -------------------------------------------------------------------------------- /src/guides/aos/aolink-process-details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/guides/aos/aolink-process-details.png -------------------------------------------------------------------------------- /src/guides/aos/aolink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/guides/aos/aolink.png -------------------------------------------------------------------------------- /src/guides/aos/blueprints/chatroom.md: -------------------------------------------------------------------------------- 1 | # Chatroom Blueprint 2 | 3 | The Chatroom Blueprint is a predesigned template that helps you quickly build a chatroom in `ao`. It is a great way to get started and can be customized to fit your needs. 4 | 5 | ## Unpacking the Chatroom Blueprint 6 | 7 | - **Members**: The `Members` array is used to store the users who have registered to the chatroom. 8 | 9 | - **Register Handler**: The `register` handler allows processes to join the chatroom. When a process sends a message with the tag `Action = "Register"`, the handler will add the process to the `Members` array and send a message back to the process confirming the registration. 10 | 11 | - **Broadcast Handler**: The `broadcast` handler allows processes to send messages to all the members of the chatroom. When a process sends a message with the tag `Action = "Broadcast"`, the handler will send the message to all the members of the chatroom. 12 | 13 | ### How To Use: 14 | 15 | 1. Open your preferred text editor. 16 | 2. Open the Terminal. 17 | 3. Start your `aos` process. 18 | 4. Type in `.load-blueprint chatroom` 19 | 20 | ### Verify the Blueprint is Loaded: 21 | 22 | Type in `Handlers.list` to see the newly loaded handlers. 23 | 24 | ## What's in the Chatroom Blueprint: 25 | 26 | ```lua 27 | Members = Members or {} 28 | 29 | Handlers.add( 30 | "register", 31 | Handlers.utils.hasMatchingTag("Action", "Register"), 32 | function (msg) 33 | table.insert(Members, msg.From) 34 | Handlers.utils.reply("registered")(msg) 35 | end 36 | ) 37 | 38 | Handlers.add( 39 | "broadcast", 40 | Handlers.utils.hasMatchingTag("Action", "Broadcast"), 41 | function (msg) 42 | for _, recipient in ipairs(Members) do 43 | ao.send({Target = recipient, Data = msg.Data}) 44 | end 45 | Handlers.utils.reply("Broadcasted.")(msg) 46 | end 47 | ) 48 | ``` 49 | -------------------------------------------------------------------------------- /src/guides/aos/blueprints/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "Build a Token" 4 | link: "../token" 5 | next: 6 | text: "Token Blueprint" 7 | link: "./token" 8 | --- 9 | 10 | # Blueprints 11 | 12 | Blueprints are predesigned templates that help you quickly build in `ao`. They are a great way to get started and can be customized to fit your needs. 13 | 14 | ## Available Blueprints 15 | 16 | - [Chatroom](chatroom) 17 | - [CRED Utils](cred-utils) 18 | - [Staking](staking) 19 | - [Token](token) 20 | - [Voting](voting) 21 | -------------------------------------------------------------------------------- /src/guides/aos/cli.md: -------------------------------------------------------------------------------- 1 | # CLI 2 | 3 | There are some command-line arguments you pass to `aos` to do the following: 4 | 5 | - [name] - create a new process or loads an existing process for your wallet 6 | - `--load` \ - load a file, you can add one or many of this command 7 | - `--cron` \ - only used when creating a process 8 | - `--wallet` \ - use a specific wallet 9 | 10 | ## Managing multiple processes with aos 11 | 12 | ```sh 13 | aos 14 | ``` 15 | 16 | Starts or connects to a process with the name `default` 17 | 18 | ```sh 19 | aos chatroom 20 | ``` 21 | 22 | Starts or connects to a process with the name of `chatroom` 23 | 24 | ```sh 25 | aos treasureRoom 26 | ``` 27 | 28 | Starts or connects to a process with the name of `treasureRoom` 29 | 30 | ## Load flag 31 | 32 | ```sh 33 | aos treasureRoom --load greeting.lua --load treasure.lua --load puzzle.lua 34 | ``` 35 | 36 | With the load flag I can load many source files to my process 37 | 38 | ## CRON Flag 39 | 40 | If you want to setup your process to react on a schedule we need to tell ao, we do that when we spawn the process. 41 | 42 | ```sh 43 | aos chatroom --cron 2-minutes 44 | ``` 45 | 46 | ## Tag flags 47 | 48 | With the tag flags, you can start a process with some custom tags (for e.g. using them as static environment variables): 49 | 50 | ```sh 51 | aos chatroom --tag-name Chat-Theme --tag-value Dark --tag-name Chat-Name --tag-value Mychat 52 | ``` 53 | 54 | The command above will add the extra tags to the transaction that spawns your process: 55 | 56 | ```ts 57 | // process data item tags 58 | [ 59 | ... 60 | { name: "Chat-Theme", value: "Dark" }, 61 | { name: "Chat-Name", value: "Mychat" } 62 | ... 63 | ] 64 | ``` 65 | -------------------------------------------------------------------------------- /src/guides/aos/editor.md: -------------------------------------------------------------------------------- 1 | # Editor setup 2 | 3 | Remembering all the built in ao functions and utilities can sometimes be hard. To enhance your developer experience, it is recommended to install the [Lua Language Server](https://luals.github.io) extension into your favorite text editor and add the [ao addon](https://github.com/martonlederer/ao-definitions). It supports all built in aos [modules](../aos/modules/index) and [globals](../aos/intro#globals). 4 | 5 | ## VS Code 6 | 7 | Install the [sumneko.lua](https://marketplace.visualstudio.com/items?itemName=sumneko.lua) extension: 8 | 9 | 1. Search for "Lua" by sumneko in the extension marketplace 10 | 2. Download and install the extension 11 | 3. Open the VS Code command palette with `Shift + Command + P` (Mac) / `Ctrl + Shift + P` (Windows/Linux) and run the following command: 12 | 13 | ``` 14 | > Lua: Open Addon Manager 15 | ``` 16 | 17 | 4. In the Addon Manager, search for "ao", it should be the first result. Click "Enable" and enjoy autocomplete! 18 | 19 | ## Other editors 20 | 21 | 1. Verify that your editor supports the [language server protocol](https://microsoft.github.io/language-server-protocol/implementors/tools/) 22 | 2. Install Lua Language Server by following the instructions at [luals.github.io](https://luals.github.io/#install) 23 | 3. Install the "ao" addon to the language server 24 | 25 | ## BetterIDEa 26 | 27 | [BetterIDEa](https://ide.betteridea.dev) is a custom web based IDE for developing on ao. 28 | 29 | It offers a built in Lua language server with ao definitions, so you don't need to install anything. Just open the IDE and start coding! 30 | 31 | Features include: 32 | 33 | - Code completion 34 | - Cell based notebook ui for rapid development 35 | - Easy process management 36 | - Markdown and Latex cell support 37 | - Share projects with anyone through ao processes 38 | - Tight integration with [ao package manager](https://apm.betteridea.dev) 39 | 40 | Read detailed information about the various features and integrations of the IDE in the [documentation](https://docs.betteridea.dev). 41 | -------------------------------------------------------------------------------- /src/guides/aos/faq.md: -------------------------------------------------------------------------------- 1 | # FAQ 2 | 3 | ## Ownership 4 | 5 |
6 | Understanding Process Ownership 7 | 8 | Start a new process with the aos console, the ownership of the process is set to your wallet address. **aos** uses the **Owner** global variable to define the ownership of the process. If you wish to transfer ownership or lock the process so that no one can own, you simply modify the **Owner** variable to another wallet address or set it to **nil**. 9 | 10 |
11 | 12 | ## JSON 13 | 14 |
15 | encoding data as json 16 | 17 | When sending data to another process or an external service, you may want to use JSON as a way to encode the data for recipients. Using the json module in lua, you can **encode** and **decode** pure lua tables that contain values. 18 | 19 | ```lua 20 | Send({Target = Router, Data = require('json').encode({hello = "world"})}) 21 | ``` 22 | 23 |
24 | 25 | ## Send vs ao.send 26 | 27 |
28 | When to use Send vs ao.send 29 | 30 | Both functions send a message to a process, the difference is ao.send returns the message, in case you want to log it or troubleshoot. The **Send** function is intended to be used in the console for easier access. It is preferred to use **ao.send** in the **handlers**. But they are both interchangeable in **aos**. 31 | 32 |
33 | -------------------------------------------------------------------------------- /src/guides/aos/inbox-and-handlers.md: -------------------------------------------------------------------------------- 1 | # Understanding the Inbox 2 | 3 | In aos, processes are executed in response to messages via handlers. Unhandled messages are routed to the process's Inbox. 4 | 5 | ## What are Handlers? 6 | 7 | A handler is a function that receives and evaluates messages within your process. It acts upon messages by taking them as parameters. 8 | 9 | Handlers are defined using the `Handlers.add()` function. 10 | 11 | The function takes three parameters: 12 | 13 | 1. Name of the Handler 14 | 2. Matcher function 15 | 3. Handle function 16 | 17 | ```lua 18 | Handlers.add("name", 19 | function (Msg) 20 | -- Does this message match (return true or false) 21 | return Msg.Action == "Register" 22 | end, 23 | function (Msg) 24 | print("Registered User.") 25 | table.insert(Members, Msg.From) 26 | ao.send({Target = Msg.From, Data = "Registered."}) 27 | end 28 | ) 29 | ``` 30 | 31 | ## What about Inboxes? 32 | 33 | An inbox is a storage area for messages that have not yet been processed. Think of it as a holding zone for incoming, or "inbound," items awaiting handling. Once a message is processed, it's no longer considered "inbound" and thus leaves the inbox. 34 | 35 | > Example: Consider the inbox like your voicemail. Just as an unanswered phone call is directed to voicemail for you to address later, messages that your Process doesn't immediately handle are sent to the inbox. This way, unhandled messages are stored until you're ready to process them. 36 | 37 | ## Summary 38 | 39 | Initially, it might seem like all messages are meant to land in your Inbox, which can be puzzling if they disappear after being handled. The analogy of a voicemail should clarify this: much like calls you answer don't go to voicemail, messages you handle won't appear in your Inbox. This illustrates the roles of both the Inbox and Handlers. 40 | -------------------------------------------------------------------------------- /src/guides/aos/installing.md: -------------------------------------------------------------------------------- 1 | # Installing aos 2 | 3 | Installing aos only requires `NodeJS` - https://nodejs.org 4 | 5 | > NOTE: If you are on windows you may get better results with WSL Console. 6 | 7 | ```sh 8 | npm i -g https://get_ao.g8way.io 9 | ``` 10 | 11 | Once installed you can run by typing `aos` 12 | -------------------------------------------------------------------------------- /src/guides/aos/load.md: -------------------------------------------------------------------------------- 1 | # Load Lua Files with `.load ` 2 | 3 | This feature allows you to load lua code from a source file on your local machine, this simple feature gives you a nice DX experience for working with aos processes. 4 | 5 | When creating handlers you may have a lot of code and you want to take advantage of a rich development environment like vscode. You can even install the lua extension to get some syntax checking. 6 | 7 | So how do you publish your local lua source code to your ao process? This is where the `.load` command comes into play. 8 | 9 | hello.lua 10 | 11 | ```lua 12 | Handlers.add( 13 | "ping", 14 | Handlers.utils.hasMatchingData("ping"), 15 | Handlers.utils.reply("pong") 16 | ) 17 | ``` 18 | 19 | aos shell 20 | 21 | ```lua 22 | .load hello.lua 23 | ``` 24 | 25 | Easy Peasy! 🐶 26 | -------------------------------------------------------------------------------- /src/guides/aos/modules/ao.md: -------------------------------------------------------------------------------- 1 | # ao 2 | 3 | Built-in global library for process communication and management. The `ao` object provides core functionality for sending messages, spawning processes, and logging. 4 | 5 | ## Core Functions 6 | 7 | ### `ao.send(msg)` 8 | 9 | Sends a message to another process. See the [ao.send](/references/ao.md#ao-send-msg-message) reference for more information. 10 | 11 | ```lua 12 | -- Send a simple message 13 | ao.send({ 14 | Target = "usjm4PCxUd5mtaon7zc97-dt-3qf67yPyqgzLnLqk5A", 15 | Data = "Hello!", 16 | Tags = { 17 | Action = "Greeting" 18 | } 19 | }) 20 | 21 | -- Root-level fields are automatically converted to tags 22 | ao.send({ 23 | Target = "usjm4PCxUd5mtaon7zc97-dt-3qf67yPyqgzLnLqk5A", 24 | Data = "Transfer tokens", 25 | Action = "Transfer", -- Becomes a tag 26 | Quantity = "1045" -- Becomes a tag 27 | }) 28 | ``` 29 | 30 | ### `ao.spawn(module: string, spawn: table)` 31 | 32 | Creates a new process from a module. See the [ao.spawn](/references/ao.md#ao-spawn-module-string-spawn-spawn) reference for more information. 33 | 34 | ```lua 35 | -- Spawn a calculator process 36 | ao.spawn("n0BFH80b73mi9VAWUzyuG9gEC3LI2zU2BFxum0N8A9s", { 37 | Data = { initial = "state" }, 38 | Tags = { 39 | ["Process-Type"] = "calculator" 40 | } 41 | }) 42 | ``` 43 | 44 | ### `ao.log(string|table)` 45 | 46 | Logs messages or data that can be read by process callers. 47 | 48 | ```lua 49 | -- Log a debug message 50 | ao.log("Processing transfer...") 51 | 52 | -- Log structured data 53 | ao.log({ 54 | event = "transfer_complete", 55 | amount = 100, 56 | recipient = "addr123..." 57 | }) 58 | ``` 59 | 60 | ## Environment 61 | 62 | The `ao.env` variable contains process initialization info like ID, owner, and tags. 63 | 64 | ```lua 65 | -- Access process info 66 | local processId = ao.env.Process.Id 67 | local owner = ao.env.Process.Owner 68 | ``` 69 | 70 | For the complete API reference including all properties and functions, see the [ao reference documentation](/references/ao.md). 71 | -------------------------------------------------------------------------------- /src/guides/aos/modules/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "Staking Blueprint" 4 | link: "../blueprints/staking" 5 | next: 6 | text: "JSON" 7 | link: "./json" 8 | --- 9 | 10 | # Modules 11 | 12 | Documentation on all the built-in modules for aos. 13 | 14 | ## Available Modules 15 | 16 | - [JSON](json) 17 | - [ao](ao) 18 | - [crypto](crypto) 19 | - [Base64](base64) 20 | - [pretty](pretty) 21 | - [Utils](utils) 22 | -------------------------------------------------------------------------------- /src/guides/aos/modules/json.md: -------------------------------------------------------------------------------- 1 | # JSON 2 | 3 | The JSON module allows you to encode and decode objects using JavaScript Object Notation. 4 | 5 | ### Example usage 6 | 7 | ```lua 8 | local json = require("json") 9 | 10 | json.encode({ 11 | a_string = "This is a string", 12 | nums = { 1, 2, 3 } 13 | }) 14 | ``` 15 | 16 | ## Module functions 17 | 18 | ### `encode()` 19 | 20 | This function returns a string representation of a Lua object in JSON. 21 | 22 | - **Parameters:** 23 | - `val`: `{any}` The object to format as JSON 24 | - **Returns:** JSON string representation of the provided object 25 | 26 | #### Example 27 | 28 | ```lua 29 | --[[ 30 | prints: 31 | "[{"name":"John Doe","age":23},{"name":"Bruce Wayne",age:34}]" 32 | ]]-- 33 | print(json.encode({ 34 | { name = "John Doe", age = 23 }, 35 | { name = "Bruce Wayne", age = 34 } 36 | })) 37 | 38 | -- prints "false" 39 | print(json.encode(false)) 40 | ``` 41 | 42 | ### `decode()` 43 | 44 | The function takes a JSON string and turns it into a Lua object. 45 | 46 | - **Parameters:** 47 | - `val`: `{any}` The JSON string to decode 48 | - **Returns:** Lua object corresponding to the JSON string (throws an error for invalid JSON strings) 49 | 50 | #### Example 51 | 52 | ```lua 53 | --[[ 54 | creates the following table: 55 | { hello = "world" } 56 | ]]-- 57 | json.decode('{ "hello": "world" }') 58 | 59 | -- creates a boolean with true value 60 | json.decode("true") 61 | ``` 62 | -------------------------------------------------------------------------------- /src/guides/aos/modules/pretty.md: -------------------------------------------------------------------------------- 1 | # Pretty 2 | 3 | This module allows printing formatted, human-friendly and readable syntax. 4 | 5 | ## Module functions 6 | 7 | ### `tprint()` 8 | 9 | Returns a formatted string of the structure of the provided table. 10 | 11 | - **Parameters:** 12 | - `tbl`: `{table}` The table to format 13 | - `indent`: `{number}` Optional indentation of each level of the table 14 | - **Returns:** Table structure formatted as a string 15 | 16 | #### Examples 17 | 18 | ```lua 19 | local pretty = require(".pretty") 20 | 21 | local formatted = pretty.tprint({ 22 | name = "John Doe", 23 | age = 22, 24 | friends = { "Maria", "Victor" } 25 | }, 2) 26 | 27 | -- prints the formatted table structure 28 | print(formatted) 29 | ``` 30 | -------------------------------------------------------------------------------- /src/guides/aos/ownership.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/guides/aos/ownership.md -------------------------------------------------------------------------------- /src/guides/aos/prompt.md: -------------------------------------------------------------------------------- 1 | # Customizing the Prompt in aos 2 | 3 | ## Step 1: Open aos and Start the Editor 4 | 5 | - Launch the aos command-line interface. 6 | - Enter `.editor` to open the inline text editor. 7 | 8 | ## Step 2: Write the Custom Prompt Function 9 | 10 | - In the editor, define your custom prompt function. For example: 11 | ```lua 12 | function Prompt() 13 | return "YourName@aos> " 14 | end 15 | ``` 16 | Customize `"YourName@aos> "` to your preferred prompt text. 17 | 18 | ## Step 3: Exit and Run Your Code 19 | 20 | - To exit the editor and execute your code, type `.done` and then press Enter. 21 | - Your aos prompt should now display the new custom format. 22 | 23 | ## Step 4: Save for Future Use (Optional) 24 | 25 | - If you wish to use this prompt in future aos sessions, save your script in a Lua file. 26 | - In subsequent sessions, load this script to apply your custom prompt. 27 | 28 | ## Maximizing Your Prompt 29 | 30 | There's a great deal of utility and creativity that can come from customizing your prompt. Several things you can do within your prompt are: 31 | 32 | - Tracking the number of unhandled messages you have in your inbox by creating a function that shows how many messages you have. 33 | 34 | ```lua 35 | --Example: 36 | function Prompt() 37 | return "YourName Inbox: [" .. #Inbox .. "] > " 38 | end 39 | ``` 40 | 41 | - Tracking the number of members are within your process ID's chatroom. 42 | - Tracking the balance of a specified token that your process ID holds. 43 | 44 | ## Conclusion 45 | 46 | Now that you understand how to maximize the utility within your Prompt, you've now gained a crucial step to streamlining your ao development experience. 47 | -------------------------------------------------------------------------------- /src/guides/aos/tables-and-json.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/guides/aos/tables-and-json.md -------------------------------------------------------------------------------- /src/guides/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "Expanding the Arena" 4 | link: "/tutorials/bots-and-games/build-game" 5 | next: 6 | text: "aos" 7 | link: "./aos/index" 8 | --- 9 | 10 | # Guides 11 | 12 | This section provides detailed guides and documentation to help you build and deploy applications on the AO ecosystem. Whether you're creating chatrooms, autonomous bots, or complex decentralized applications, you'll find step-by-step instructions here. 13 | 14 | ## Core Technologies 15 | 16 | Comprehensive guides for AO's main technologies: 17 | 18 | - [AOS: Compute on AO](aos/index) - Learn how to use the AO operating system for distributed computing 19 | 20 | - [Introduction to AOS](aos/intro) - Get started with the AOS environment 21 | - [Installation Guide](aos/installing) - Set up AOS on your system 22 | - [CLI Usage](aos/cli) - Learn the command-line interface 23 | - [And more...](aos/index) 24 | 25 | - [AO Connect: JavaScript Library](aoconnect/aoconnect) - Interact with AO using JavaScript 26 | - [Installation](aoconnect/installing-connect) - Set up the AO Connect library 27 | - [Connecting to AO](aoconnect/connecting) - Establish connections 28 | - [Sending Messages](aoconnect/sending-messages) - Communicate with processes 29 | - [And more...](aoconnect/aoconnect) 30 | 31 | ## Development Tools 32 | 33 | - [AO Module Builder CLI](dev-cli/index) - Build WebAssembly modules for AO 34 | - [Installation](dev-cli/index#install) - Install the development CLI 35 | - [Project Setup](dev-cli/index#start-a-project) - Create your first project 36 | - [Building & Deployment](dev-cli/index#build-a-project) - Compile and deploy modules 37 | 38 | ## Utilities & Storage 39 | 40 | Helpful tools and storage solutions: 41 | 42 | - [Using WeaveDrive](snacks/weavedrive) - Store and manage data with WeaveDrive 43 | - [Using SQLite](snacks/sqlite) - Integrate SQLite databases with your AO projects 44 | 45 | ## Additional Resources 46 | 47 | - [Community Resources](/references/community) - Connect with the AO community 48 | - [Release Notes](/releasenotes/index) - Stay updated on the latest changes and features 49 | 50 | ## Navigation 51 | 52 | Use the sidebar to browse through specific guides. Each guide provides detailed instructions and examples to help you build on AO. 53 | -------------------------------------------------------------------------------- /src/guides/snacks/0rbit/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "Bots and Games" 4 | link: "/guides/aoconnect/monitoring-cron" 5 | next: 6 | text: "First GET Request" 7 | link: "/guides/snacks/0rbit/get-request" 8 | --- 9 | 10 | # 0rbit 💫 11 | 12 | [0rbit](https://0rbit.co/) is the first-ever Decentralised Oracle Network on Arweave using `ao`. 13 | 14 | 0rbit enables Access to ANY Real-World data present and accessible across internet into your `ao` process. 15 | 16 | 0rbit provides the following features to get access to the data using the HTTP protocol: 17 | 18 | - [**Fetch HTTP Data**](https://docs.0rbit.co/developer/get-request): A handler to make a HTTP Get Request from your `ao` process to the web. 19 | - [**Post HTTP Data**](https://docs.0rbit.co/developer/post-request): A handler to make a HTTP Post Request from your `ao` process to the web. 20 | 21 | ## Tutorials 22 | 23 | Learn how to build with 0rbit with the following tutorials: 24 | 25 | - [First GET Request](./get-request.md) 26 | - [First POST Request](./post-request.md) 27 | 28 | > _Learn more about 0rbit through the [developer docs.](https://docs.0rbit.co/)_ 29 | -------------------------------------------------------------------------------- /src/guides/snacks/sqlite.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "Guides" 4 | link: "/guides/index" 5 | 6 | next: false 7 | --- 8 | 9 | # Getting started with SQLite 10 | 11 | SQLite is a relational database engine. In this guide, we will show how you can spawn a process with SQLite and work with data using a relational database. 12 | 13 | ## Setup 14 | 15 | > NOTE: make sure you have aos installed, if not checkout [Getting Started](/welcome/getting-started) 16 | 17 | spawn a new process `mydb` with a `--sqlite` flag, this instructs ao to use the latest sqlite module. 18 | 19 | ```sh 20 | aos mydb --sqlite 21 | ``` 22 | 23 | ## Install AO Package Manager 24 | 25 | installing apm, the ao package manager we can add helper modules to make it easier to work with sqlite. 26 | 27 | ```lua 28 | .load-blueprint apm 29 | ``` 30 | 31 | ## Install dbAdmin package 32 | 33 | DbAdmin is a module that connects to a sqlite database and provides functions to work with sqlite. 34 | 35 | https://apm_betteridea.g8way.io/pkg?id=@rakis/DbAdmin 36 | 37 | ```lua 38 | apm.install('@rakis/dbAdmin') 39 | ``` 40 | 41 | ## Create sqlite Database 42 | 43 | ```lua 44 | local sqlite = require('lsqlite3') 45 | Db = sqlite.open_memory() 46 | dbAdmin = require('@rakis/DbAdmin').new(Db) 47 | ``` 48 | 49 | ## Create Table 50 | 51 | Create a table called Comments 52 | 53 | ```lua 54 | dbAdmin:exec([[ 55 | CREATE TABLE IF NOT EXISTS Comments ( 56 | ID INTEGER PRIMARY KEY AUTOINCREMENT, 57 | Asset TEXT, 58 | User TEXT, 59 | Body TEXT 60 | ); 61 | ]]) 62 | ``` 63 | 64 | ## Insert data 65 | 66 | ```lua 67 | local SQL = "INSERT INTO Comments (Asset, User, Body) VALUES (?,?,?);" 68 | dbAdmin:apply(SQL, {"dog.jpg", "Anon", "Nice Picture"}) 69 | ``` 70 | 71 | ## List data 72 | 73 | ```lua 74 | local SQL = "SELECT * FROM Comments;" 75 | dbAdmin:exec(SQL) 76 | ``` 77 | 78 | ## Congrats! 79 | 80 | You are using sqlite on AO 🎉 81 | -------------------------------------------------------------------------------- /src/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | # https://vitepress.dev/reference/default-theme-home-page 3 | layout: home 4 | 5 | hero: 6 | name: "" 7 | text: "The hyper parallel computer." 8 | tagline: "Decentralized compute at any scale. Only possible on Arweave." 9 | actions: 10 | - theme: brand 11 | text: Let's Go! 12 | link: /welcome/index 13 | 14 | features: 15 | - title: Mainnet 16 | details: Learn how to build on AO Mainnet with guides and key concepts. 17 | link: /mainnet/index 18 | 19 | - title: Guides 20 | details: Bite size walkthroughs on specific features. 21 | link: /guides/index 22 | 23 | - title: Concepts 24 | details: Learn how the ao network works under the hood. 25 | link: /concepts/index 26 | --- 27 | 28 | ## More Information 29 | 30 | - [Community Resources](/references/community) 31 | - [Release Notes](/releasenotes/index) 32 | -------------------------------------------------------------------------------- /src/ja/concepts/CU-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/ja/concepts/CU-diagram.png -------------------------------------------------------------------------------- /src/ja/concepts/MU-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/ja/concepts/MU-diagram.png -------------------------------------------------------------------------------- /src/ja/concepts/SU-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/ja/concepts/SU-diagram.png -------------------------------------------------------------------------------- /src/ja/concepts/ao-pictograph-c94ebf2d.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/ja/concepts/handler-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/ja/concepts/handler-diagram.png -------------------------------------------------------------------------------- /src/ja/concepts/holographic-state.md: -------------------------------------------------------------------------------- 1 | TODO 2 | -------------------------------------------------------------------------------- /src/ja/concepts/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "最初のPOSTリクエスト" 4 | link: "../guides/0rbit/post-request" 5 | next: 6 | text: "仕様" 7 | link: "./specs" 8 | --- 9 | 10 | # コンセプト 11 | 12 | aoには多くのコンセプトが組み込まれていますが、コアとなるコンセプトは非常にシンプルな原則に基づいています: 13 | 14 | - 2つのコアタイプ: メッセージとプロセス 15 | - 共有状態なし、ホログラフィック状態のみ 16 | - 分散型コンピュータ(グリッド) 17 | 18 | 以下は、aoシステムをその特徴的な部分に分解したコンセプト文書のセットです。 19 | 20 | - [仕様](specs) 21 | - [プロセス](processes) 22 | - [メッセージ](messages) 23 | - [ユニット](units) 24 | - [メッセージングの仕組み](how-it-works) 25 | 26 | [[toc]] 27 | -------------------------------------------------------------------------------- /src/ja/concepts/message-workflow-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/ja/concepts/message-workflow-diagram.png -------------------------------------------------------------------------------- /src/ja/concepts/process-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/ja/concepts/process-diagram.png -------------------------------------------------------------------------------- /src/ja/concepts/specs.md: -------------------------------------------------------------------------------- 1 | # ao Specs 2 | 3 | 4 | 5 | ### `ao`とは何ですか? 6 | 7 | 8 | 9 | aoコンピュータは、[Arweave](https://arweave.org) ネットワーク上で動作し、そのコアデータプロトコルに従うノードのネットワークから生まれる [アクター指向](https://en.wikipedia.org/wiki/Actor_model) のマシンです。この文書では、プロトコルとその機能、ならびに技術的な詳細について簡単に紹介し、ビルダーが新しい実装やサービスを作成し、それを統合できるようにします。 10 | 11 | 12 | 13 | `ao`コンピュータは、分散ネットワーク上の異種ノードセットにホストされる単一の統合された計算環境([Single System Image](https://en.wikipedia.org/wiki/Single_system_image))です。aoは、任意の数の並行プロセスが常駐し、オープンなメッセージパッシングレイヤーを介して協調できる環境を提供するよう設計されています。このメッセージパッシング標準は、独立して動作するプロセスを「ウェブ」へと接続します。これは、Webサイトが独立したサーバー上で動作しながらも、ハイパーリンクを介して統合された一貫性のある体験を提供するのと同じ方法です。 14 | -------------------------------------------------------------------------------- /src/ja/guides/0rbit/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "ボットとゲーム" 4 | link: "/guides/aoconnect/monitoring-cron" 5 | next: 6 | text: "最初のGETリクエスト" 7 | link: "/guides/0rbit/get-request" 8 | --- 9 | 10 | # 0rbit 💫 11 | 12 | [0rbit](https://0rbit.co/)は、`ao`を使用したArweave上で初めての分散型オラクルネットワークです。 13 | 14 | 0rbitは、インターネット上に存在し、アクセス可能なあらゆる現実世界のデータにあなたの`ao`プロセスからアクセスできるようにします。 15 | 16 | 0rbitは、HTTPプロトコルを使用してデータにアクセスするための以下の機能を提供します: 17 | 18 | - [**HTTPデータの取得**](https://docs.0rbit.co/developer/get-request):あなたの`ao`プロセスからウェブにHTTP GETリクエストを行うためのハンドラ。 19 | - [**HTTPデータの送信**](https://docs.0rbit.co/developer/post-request):あなたの`ao`プロセスからウェブにHTTP POSTリクエストを行うためのハンドラ。 20 | 21 | ## チュートリアル 22 | 23 | 以下のチュートリアルで0rbitを使った構築方法を学びましょう: 24 | 25 | - [最初のGETリクエスト](./get-request.md) 26 | - [最初のPOSTリクエスト](./post-request.md) 27 | 28 | > _0rbitについて詳しくは、[開発者ドキュメント](https://docs.0rbit.co/)をご覧ください。_ 29 | 30 | 58 | -------------------------------------------------------------------------------- /src/ja/guides/aoconnect/aoconnect.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "aos" 4 | link: "/guides/aos" 5 | next: 6 | text: "aoconnectのインストール" 7 | link: "/guides/aoconnect/installing-connect" 8 | --- 9 | 10 | # aoconnect 11 | 12 | ao connectは、Node.jsまたはブラウザからシステムと対話するためのJavaScript/TypeScriptライブラリです。 13 | 14 | このセクションのガイドでは、ao connectを利用するためのスニペットを提供します。すべてのスニペットはJavaScriptで書かれていますが、TypeScriptに簡単に変換できるはずです。 15 | 16 | 30 | -------------------------------------------------------------------------------- /src/ja/guides/aoconnect/calling-dryrun.md: -------------------------------------------------------------------------------- 1 | # DryRunの呼び出し 2 | 3 | DryRunは、メッセージオブジェクトを特定のプロセスに送信し、結果オブジェクトを取得するプロセスですが、メモリは保存されません。これは、現在のメモリの値を返す読み取りメッセージを作成するのに最適です。例えば、トークンの残高や転送の結果などです。DryRunを使用すると、実際のメッセージを送信せずに出力を取得できます。 4 | 5 | 8 | 9 | ```js 10 | import { createDataItemSigner, dryrun } from "@permaweb/aoconnect"; 11 | 12 | const result = await dryrun({ 13 | process: 'PROCESSID', 14 | data: '', 15 | tags: [{name: 'Action', value: 'Balance'}, 16 | anchor: '1234', 17 | ...rest are optional (Id, Owner, etc) 18 | }); 19 | 20 | console.log(result.Messages[0]); 21 | ``` 22 | -------------------------------------------------------------------------------- /src/ja/guides/aoconnect/connecting.md: -------------------------------------------------------------------------------- 1 | # 特定のaoノードへの接続 2 | 3 | コードにao connectを含めると、特定のMUおよびCUに接続する能力と、Arweaveゲートウェイを指定する能力があります。これは、"connect"関数をインポートし、"connect"関数への呼び出しから関数を抽出することで実現できます。 4 | 5 | メッセージを送信する際にどのMUが呼び出されているかを知りたい場合、後で指定したMUからデバッグできるようにするために、これを行うことがあります。また、特定のCUから結果を読み取りたい場合もあります。別の理由で特定のMUとCUを好むこともあるかもしれません。デフォルトのarweave.net以外のものを使用するために、ゲートウェイを指定することができます。 6 | 7 | ## connectへの呼び出しなしでのインポート 8 | 9 | 16 | 17 | ```js 18 | // Here aoconnect will implicitly use the default nodes/units 19 | import { 20 | result, 21 | results, 22 | message, 23 | spawn, 24 | monitor, 25 | unmonitor, 26 | dryrun, 27 | } from "@permaweb/aoconnect"; 28 | ``` 29 | 30 | ## Connecting to a specific MU, CU, and gateway 31 | 32 | ```js 33 | import { connect } from "@permaweb/aoconnect"; 34 | 35 | const { result, results, message, spawn, monitor, unmonitor, dryrun } = connect( 36 | { 37 | MU_URL: "https://mu.ao-testnet.xyz", 38 | CU_URL: "https://cu.ao-testnet.xyz", 39 | GATEWAY_URL: "https://arweave.net", 40 | }, 41 | ); 42 | 43 | // now spawn, message, and result can be used the same way as if they were imported directly 44 | ``` 45 | 46 |
47 | 48 | All three of these parameters to connect are optional and it is valid to specify only 1 or 2 of them, or none. You could pass in just the MU_URL, for example. 49 | 50 | ```js 51 | import { connect } from "@permaweb/aoconnect"; 52 | 53 | const { result, results, message, spawn, monitor, unmonitor, dryrun } = connect( 54 | { 55 | MU_URL: "https://ao-mu-1.onrender.com", 56 | }, 57 | ); 58 | ``` 59 | -------------------------------------------------------------------------------- /src/ja/guides/aoconnect/installing-connect.md: -------------------------------------------------------------------------------- 1 | # ao connectのインストール 2 | 3 | ## 前提条件 4 | 5 | --- 6 | 7 | ao connectをアプリにインストールするには、NodeJS/NPMのバージョンが18以上である必要があります。 8 |
9 | 10 | 18 | 19 | ## Installing 20 | 21 | ### npm 22 | 23 | ```sh 24 | npm install --save @permaweb/aoconnect 25 | ``` 26 | 27 | ### yarn 28 | 29 | ```sh 30 | yarn add @permaweb/aoconnect -D 31 | ``` 32 | 33 |
34 | 35 | このモジュールは、NodeJSおよびブラウザの両方から使用できるようになり、以下のように含めることができます。 36 | 37 | 38 | 39 | #### ESM (Node & Browser) aka type: `module` 40 | 41 | ```js 42 | import { 43 | result, 44 | results, 45 | message, 46 | spawn, 47 | monitor, 48 | unmonitor, 49 | dryrun, 50 | } from "@permaweb/aoconnect"; 51 | ``` 52 | 53 | #### CJS (Node) type: `commonjs` 54 | 55 | ```js 56 | const { 57 | result, 58 | results, 59 | message, 60 | spawn, 61 | monitor, 62 | unmonitor, 63 | dryrun, 64 | } = require("@permaweb/aoconnect"); 65 | ``` 66 | -------------------------------------------------------------------------------- /src/ja/guides/aoconnect/monitoring-cron.md: -------------------------------------------------------------------------------- 1 | # Cronの監視 2 | 3 | cronメッセージを使用する際、aoユーザーはメッセージの取り込みを開始する方法が必要です。この監視メソッドを使用することで、aoユーザーはcronメッセージのサブスクリプションサービスを開始できます。cronタグを設定すると、プロセスはそのアウトボックスにcron結果を生成し始めますが、ネットワークを通じてこれらの結果からメッセージをプッシュするには、これらの結果を監視する必要があります。 4 | 5 | 8 | 9 | ```js 10 | import { readFileSync } from "node:fs"; 11 | import { createDataItemSigner, monitor } from "@permaweb/aoconnect"; 12 | 13 | const wallet = JSON.parse( 14 | readFileSync("/path/to/arweave/wallet.json").toString(), 15 | ); 16 | 17 | const result = await monitor({ 18 | process: "process-id", 19 | signer: createDataItemSigner(wallet), 20 | }); 21 | ``` 22 | 23 | 24 | 25 | 監視を停止するには、`unmonitor`を呼び出します。 26 | 27 | ```js 28 | import { readFileSync } from "node:fs"; 29 | import { createDataItemSigner, unmonitor } from "@permaweb/aoconnect"; 30 | 31 | const wallet = JSON.parse( 32 | readFileSync("/path/to/arweave/wallet.json").toString(), 33 | ); 34 | 35 | const result = await unmonitor({ 36 | process: "process-id", 37 | signer: createDataItemSigner(wallet), 38 | }); 39 | ``` 40 | -------------------------------------------------------------------------------- /src/ja/guides/aoconnect/reading-results.md: -------------------------------------------------------------------------------- 1 | # aoプロセスからの結果の読み取り 2 | 3 | aoでは、メッセージが結果を生成し、これが計算ユニット(CU)によって利用可能になります。結果は、messages、spawns、output、errorの各フィールドからなるJSONオブジェクトです。 4 | 5 | 結果は、aoシステムがプロセスによって生成されたメッセージやスパウンを送信するために使用するものです。プロセスは、開発者としてメッセージを送信するのと同様に、結果にメッセージやスパウンを返すことでメッセージを送信できます。 6 | 7 | メッセージによって生成された出力を表示するために結果にアクセスしたい場合があります。また、生成されたメッセージなどを確認したい場合もあるでしょう。結果からメッセージやスパウンを取り出して自分で送信する必要はありません。それらは自動的にメッセンジャーユニット(MU)によって処理されます。`results`を呼び出すことで、複数の結果のページ分けされたリストを提供することもできます。 8 | 9 | ## 単一の結果を取得する 10 | 11 | 20 | 21 | ```js 22 | import { result } from "@permaweb/aoconnect"; 23 | 24 | let { Messages, Spawns, Output, Error } = await result({ 25 | // the arweave TXID of the message 26 | message: "message-id", 27 | // the arweave TXID of the process 28 | process: "process-id", 29 | }); 30 | ``` 31 | 32 | ## Fetching a set of results 33 | 34 | ```js 35 | import { results } from "@permaweb/aoconnect"; 36 | 37 | // fetching the first page of results 38 | let resultsOut = await results({ 39 | process: "process-id", 40 | sort: "ASC", 41 | limit: 25, 42 | }); 43 | 44 | // calling more with a cursor 45 | let resultsOut2 = await results({ 46 | process: "process-id", 47 | from: resultsOut.edges?.[resultsOut.edges.length - 1]?.cursor ?? null, 48 | sort: "ASC", 49 | limit: 25, 50 | }); 51 | ``` 52 | -------------------------------------------------------------------------------- /src/ja/guides/aos/aolink-compute-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/ja/guides/aos/aolink-compute-example.png -------------------------------------------------------------------------------- /src/ja/guides/aos/aolink-info-handler-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/ja/guides/aos/aolink-info-handler-example.png -------------------------------------------------------------------------------- /src/ja/guides/aos/aolink-linked-message-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/ja/guides/aos/aolink-linked-message-example.png -------------------------------------------------------------------------------- /src/ja/guides/aos/aolink-list-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/ja/guides/aos/aolink-list-example.png -------------------------------------------------------------------------------- /src/ja/guides/aos/aolink-message-and-token-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/ja/guides/aos/aolink-message-and-token-example.png -------------------------------------------------------------------------------- /src/ja/guides/aos/aolink-message-details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/ja/guides/aos/aolink-message-details.png -------------------------------------------------------------------------------- /src/ja/guides/aos/aolink-process-details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/ja/guides/aos/aolink-process-details.png -------------------------------------------------------------------------------- /src/ja/guides/aos/aolink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/ja/guides/aos/aolink.png -------------------------------------------------------------------------------- /src/ja/guides/aos/blueprints/chatroom.md: -------------------------------------------------------------------------------- 1 | # チャットルームブループリント 2 | 3 | チャットルームブループリントは、`ao` でチャットルームを迅速に構築するのに役立つ事前設計されたテンプレートです。始めるのに最適な方法であり、ニーズに合わせてカスタマイズできます。 4 | 5 | ## チャットルームブループリントの内容 6 | 7 | - **メンバー**: `Members` 配列は、チャットルームに登録したユーザーを保存するために使用されます。 8 | 9 | - **登録ハンドラー**: `register` ハンドラーは、プロセスがチャットルームに参加できるようにします。プロセスが `Action = "Register"` タグを持つメッセージを送信すると、ハンドラーはプロセスを `Members` 配列に追加し、登録を確認するメッセージをプロセスに送信します。 10 | 11 | - **ブロードキャストハンドラー**: `broadcast` ハンドラーは、プロセスがチャットルームのすべてのメンバーにメッセージを送信できるようにします。プロセスが `Action = "Broadcast"` タグを持つメッセージを送信すると、ハンドラーはチャットルームのすべてのメンバーにメッセージを送信します。 12 | 13 | ### 使用方法: 14 | 15 | 1. お好みのテキストエディタを開きます。 16 | 2. ターミナルを開きます。 17 | 3. `aos` プロセスを開始します。 18 | 4. `.load-blueprint chatroom` と入力します。 19 | 20 | ### ブループリントが読み込まれたことを確認する: 21 | 22 | `Handlers.list` と入力して、新しく読み込まれたハンドラーを確認します。 23 | 24 | ## チャットルームブループリントの内容: 25 | 26 | 50 | 51 | ```lua 52 | Members = Members or {} 53 | 54 | Handlers.add( 55 | "register", 56 | Handlers.utils.hasMatchingTag("Action", "Register"), 57 | function (msg) 58 | table.insert(Members, msg.From) 59 | Handlers.utils.reply("registered")(msg) 60 | end 61 | ) 62 | 63 | Handlers.add( 64 | "broadcast", 65 | Handlers.utils.hasMatchingTag("Action", "Broadcast"), 66 | function (msg) 67 | for _, recipient in ipairs(Members) do 68 | ao.send({Target = recipient, Data = msg.Data}) 69 | end 70 | Handlers.utils.reply("Broadcasted.")(msg) 71 | end 72 | ) 73 | ``` 74 | -------------------------------------------------------------------------------- /src/ja/guides/aos/blueprints/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "Build a Token" 4 | link: "../token" 5 | next: 6 | text: "Token Blueprint" 7 | link: "./token" 8 | --- 9 | 10 | # Blueprints 11 | 12 | Blueprintsは、`ao`で迅速に構築するのに役立つ事前設計されたテンプレートです。これらは、始めるための優れた方法であり、ニーズに合わせてカスタマイズできます。 13 | 14 | ## 利用可能なブループリント 15 | 16 | - [チャットルーム](chatroom) 17 | - [CRED Utils](cred-utils) 18 | - [ステーキング](staking) 19 | - [トークン](token) 20 | - [投票](voting) 21 | -------------------------------------------------------------------------------- /src/ja/guides/aos/cli.md: -------------------------------------------------------------------------------- 1 | # CLI 2 | 3 | aosに渡すコマンドライン引数は以下の操作を行うためのものです: 4 | 5 | - [name] - 新しいプロセスを作成するか、ウォレット用の既存のプロセスを読み込みます 6 | - --load [file] - ファイルを読み込みます。このコマンドを1つまたは複数追加できます 7 | - --cron [interval] - プロセスを作成する際のみ使用します 8 | - --wallet [walletfile] - 特定のウォレットを使用します 9 | 10 | ## aosを使用した複数プロセスの管理 11 | 12 | 23 | 24 | ```sh 25 | aos 26 | ``` 27 | 28 | 29 | 30 | `default`という名前のプロセスを開始するか、接続します。 31 | 32 | ```sh 33 | aos chatroom 34 | ``` 35 | 36 | `chatroom`という名前のプロセスを開始するか、接続します。 37 | 38 | 39 | 40 | ```sh 41 | aos treasureRoom 42 | ``` 43 | 44 | 45 | 46 | `treasureRoom`という名前のプロセスを開始するか、接続します。 47 | 48 | ## Load flag 49 | 50 | ```sh 51 | aos treasureRoom --load greeting.lua --load treasure.lua --load puzzle.lua 52 | ``` 53 | 54 | loadフラグを使用すると、プロセスに複数のソースファイルを読み込むことができます。 55 | 56 | ## CRONフラグ 57 | 58 | プロセスをスケジュールに基づいて反応させる場合は、aoにその旨を伝える必要があります。これはプロセスを生成する際に行います。 59 | 60 | 67 | 68 | ```sh 69 | aos chatroom --cron 2-minutes 70 | ``` 71 | 72 | ## タグフラグ 73 | 74 | タグフラグを使用すると、カスタムタグ(例えば、静的環境変数として使用するため)でプロセスを開始できます。 75 | 76 | 上記のコマンドは、プロセスを生成するトランザクションに追加のタグを追加します: 77 | 78 | 83 | 84 | ```sh 85 | aos chatroom --tag-name Chat-Theme --tag-value Dark --tag-name Chat-Name --tag-value Mychat 86 | ``` 87 | 88 | 89 | 90 | 上記のコマンドは、プロセスを生成するトランザクションに追加のタグを追加します: 91 | 92 | ```ts 93 | // process data item tags 94 | [ 95 | ... 96 | { name: "Chat-Theme", value: "Dark" }, 97 | { name: "Chat-Name", value: "Mychat" } 98 | ... 99 | ] 100 | ``` 101 | -------------------------------------------------------------------------------- /src/ja/guides/aos/faq.md: -------------------------------------------------------------------------------- 1 | # FAQ 2 | 3 | ## Ownership 4 | 5 |
6 | プロセスの所有権を理解する 7 | 8 | aosコンソールで新しいプロセスを開始すると、そのプロセスの所有権はあなたのウォレットアドレスに設定されます。**aos**は、プロセスの所有権を定義するために**Owner**グローバル変数を使用します。所有権を移転したり、誰も所有できないようにプロセスをロックしたい場合は、単に**Owner**変数を別のウォレットアドレスに変更するか、**nil**に設定します。 9 | 10 |
11 | 12 | ## JSON 13 | 14 | 28 | 29 |
30 | 31 | データをJSONとしてエンコードする 32 | 33 | 34 | 35 | 他のプロセスや外部サービスにデータを送信する際、受取人のためにデータをエンコードする手段としてJSONを使用することができます。Luaのjsonモジュールを使用すると、値を含む純粋なLuaテーブルを**エンコード**および**デコード**できます。 36 | 37 | ```lua 38 | Send({Target = Router, Data = require('json').encode({hello = "world"})}) 39 | ``` 40 | 41 |
42 | 43 | ## Send vs ao.send 44 | 45 |
46 | 47 | Sendとao.sendの使い分け 48 | 49 | 50 | 51 | 54 | 55 | 両方の関数はプロセスにメッセージを送信しますが、ao.sendはメッセージを返すため、ログを記録したりトラブルシューティングを行いたい場合に便利です。**Send**関数は、コンソールでのアクセスを容易にするために使用されることを意図しています。**Handlers**内では**ao.send**を使用することが推奨されますが、どちらも**aos**内では互換性があります。 56 | 57 |
58 | -------------------------------------------------------------------------------- /src/ja/guides/aos/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "Tutorials" 4 | link: "/guides/tutorials/" 5 | next: 6 | text: "Introduction to aos" 7 | link: "/guides/aos/intro" 8 | --- 9 | 10 | # aos 11 | 12 | `ao`は、分散コンピュートを可能にするハイパーパラレルコンピュータであり、`aos`はそのコンピュータ上のオペレーティングシステムです。 13 | 14 | `aos`を使用すると、プロセスと対話し、非常にシンプルで直感的な方法でプロセスをコーディングできます。必要なのはターミナルとエディターだけです。 15 | 16 | `aos`で選ばれた言語は[Lua](../../concepts/lua.md)であり、堅牢で決定論的な動的言語で、非常に楽しく作業できます。 17 | 18 | まだ行っていない場合は、15分間で当社の[チュートリアル](../../tutorials/index)を確認してください。 19 | 20 | ## `aos`の詳細 21 | 22 | - [Introduction to aos](intro) 23 | - [Installing](installing) 24 | - [`aos` CLI](cli) 25 | - [Prompt Customization](prompt) 26 | - [A Ping-Pong Server](pingpong) 27 | 28 | ## 開発者ガイド 29 | 30 | - [Editor Setup](editor) 31 | - [Troubleshooting with ao.link](troubleshooting) 32 | - [Understanding the Inbox](inbox-and-handlers) 33 | - [Frequently Asked Questions](faq) 34 | 35 | ### [**Modules**](modules/index) 36 | 37 | - [JSON](modules/json) 38 | - [`ao`](modules/ao) 39 | - [crypto](modules/crypto) 40 | - [Base64](modules/base64) 41 | - [Pretty](modules/pretty) 42 | - [Utils](modules/utils) 43 | -------------------------------------------------------------------------------- /src/ja/guides/aos/installing.md: -------------------------------------------------------------------------------- 1 | # Installing aos 2 | 3 | `aos`のインストールには`NodeJS`が必要です - https://nodejs.org 4 | 5 | > NOTE: Windowsを使用している場合、WSLコンソールでより良い結果が得られるかもしれません。 6 | 7 | ```sh 8 | npm i -g https://get_ao.g8way.io 9 | ``` 10 | 11 | インストールが完了したら、 `aos` と入力して実行できます。 12 | -------------------------------------------------------------------------------- /src/ja/guides/aos/load.md: -------------------------------------------------------------------------------- 1 | # .load 2 | 3 | この機能を使用すると、ローカルマシン上のソースファイルからLuaコードをロードできます。このシンプルな機能は、aosプロセスで作業するための素晴らしい開発体験を提供します。 4 | 5 | ハンドラーを作成する際、多くのコードが必要になることがあります。そのため、vscodeのような豊富な開発環境を活用したいと思うことでしょう。Lua拡張機能をインストールすれば、構文チェックも受けられます。 6 | 7 | では、ローカルのLuaソースコードをaoプロセスに公開するにはどうすればよいのでしょうか?ここで`.load`コマンドが役立ちます。 8 | 9 | hello.lua 10 | 11 | ```lua 12 | Handlers.add( 13 | "ping", 14 | Handlers.utils.hasMatchingData("ping"), 15 | Handlers.utils.reply("pong") 16 | ) 17 | ``` 18 | 19 | aos shell 20 | 21 | ```lua 22 | .load hello.lua 23 | ``` 24 | 25 | Easy Peasy! 🐶 26 | -------------------------------------------------------------------------------- /src/ja/guides/aos/modules/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "Staking Blueprint" 4 | link: "../blueprints/staking" 5 | next: 6 | text: "JSON" 7 | link: "./json" 8 | --- 9 | 10 | # モジュール 11 | 12 | aosのすべての組み込みモジュールに関するドキュメントです。 13 | 14 | ## 利用可能なモジュール 15 | 16 | - [JSON](json) 17 | - [ao](ao) 18 | - [crypto](crypto) 19 | - [Base64](base64) 20 | - [pretty](pretty) 21 | - [Utils](utils) 22 | -------------------------------------------------------------------------------- /src/ja/guides/aos/modules/json.md: -------------------------------------------------------------------------------- 1 | # JSON 2 | 3 | JSONモジュールは、JavaScript Object Notationを使用してオブジェクトのエンコードとデコードを可能にします。 4 | 5 | ### Example usage 6 | 7 | ```lua 8 | local json = require("json") 9 | 10 | json.encode({ 11 | a_string = "This is a string", 12 | nums = { 1, 2, 3 } 13 | }) 14 | ``` 15 | 16 | 25 | 26 | ## Module functions 27 | 28 | ### `encode()` 29 | 30 | この関数は、LuaオブジェクトのJSON文字列表現を返します。 31 | 32 | - **Parameters:** 33 | - `val`: `{any}` JSONとしてフォーマットするオブジェクト 34 | - **Returns:** 提供されたオブジェクトのJSON文字列表現 35 | 36 | #### Example 37 | 38 | ```lua 39 | --[[ 40 | prints: 41 | "[{"name":"John Doe","age":23},{"name":"Bruce Wayne",age:34}]" 42 | ]]-- 43 | print(json.encode({ 44 | { name = "John Doe", age = 23 }, 45 | { name = "Bruce Wayne", age = 34 } 46 | })) 47 | 48 | -- prints "false" 49 | print(json.encode(false)) 50 | ``` 51 | 52 | 59 | 60 | ### `decode()` 61 | 62 | この関数は、JSON文字列を受け取り、それをLuaオブジェクトに変換します。 63 | 64 | - **Parameters:** 65 | - `val`: `{any}` デコードするJSON文字列 66 | - **Returns:** JSON文字列に対応するLuaオブジェクト(無効なJSON文字列の場合はエラーをスローします) 67 | 68 | #### Example 69 | 70 | ```lua 71 | --[[ 72 | creates the following table: 73 | { hello = "world" } 74 | ]]-- 75 | json.decode('{ "hello": "world" }') 76 | 77 | -- creates a boolean with true value 78 | json.decode("true") 79 | ``` 80 | -------------------------------------------------------------------------------- /src/ja/guides/aos/modules/pretty.md: -------------------------------------------------------------------------------- 1 | # Pretty 2 | 3 | このモジュールは、フォーマットされた人間に優しく、読みやすい構文を印刷することを可能にします。 4 | 5 | ## モジュール関数 6 | 7 | ### `tprint()` 8 | 9 | 提供されたテーブルの構造のフォーマットされた文字列を返します。 10 | 11 | - **パラメータ:** 12 | - `tbl`: `{table}` フォーマットするテーブル 13 | - `indent`: `{number}` 各レベルのテーブルのオプションのインデント 14 | - **戻り値:** フォーマットされたテーブル構造の文字列 15 | 16 | #### Examples 17 | 18 | ```lua 19 | local pretty = require(".pretty") 20 | 21 | local formatted = pretty.tprint({ 22 | name = "John Doe", 23 | age = 22, 24 | friends = { "Maria", "Victor" } 25 | }, 2) 26 | 27 | -- prints the formatted table structure 28 | print(formatted) 29 | ``` 30 | -------------------------------------------------------------------------------- /src/ja/guides/aos/ownership.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/ja/guides/aos/ownership.md -------------------------------------------------------------------------------- /src/ja/guides/aos/prompt.md: -------------------------------------------------------------------------------- 1 | # aosでのプロンプトのカスタマイズ 2 | 3 | ## ステップ1: aosを開いてエディタを開始する 4 | 5 | - aosコマンドラインインターフェイスを起動します。 6 | - `.editor`と入力して、インラインテキストエディタを開きます。 7 | 8 | ## ステップ2: カスタムプロンプト関数を書く 9 | 10 | - エディタで、カスタムプロンプト関数を定義します。例えば: 11 | 24 | 25 | ```lua 26 | function Prompt() 27 | return "YourName@aos> " 28 | end 29 | ``` 30 | 31 | Customize `"YourName@aos> "` to your preferred prompt text. 32 | 33 | ## ステップ3: エディタを終了してコードを実行する 34 | 35 | - エディタを終了し、コードを実行するには、`.done`と入力してEnterを押します。 36 | - あなたのaosプロンプトは、今や新しいカスタムフォーマットを表示するはずです。 37 | 38 | ## ステップ4: 将来の使用のために保存する(オプション) 39 | 40 | - 将来的にこのプロンプトを使用したい場合は、スクリプトをLuaファイルに保存します。 41 | - 次回のセッションでは、このスクリプトを読み込んでカスタムプロンプトを適用します。 42 | 43 | ## プロンプトを最大限に活用する 44 | 45 | プロンプトをカスタマイズすることで、多くのユーティリティや創造性が得られます。プロンプト内でできることはいくつかあります: 46 | 47 | - 受信トレイにある未処理のメッセージの数を追跡する関数を作成して、どれだけのメッセージがあるかを表示します。 48 | 49 | 65 | 66 | ```lua 67 | --Example: 68 | function Prompt() 69 | return "YourName Inbox: [" .. #Inbox .. "] > " 70 | end 71 | ``` 72 | 73 | 81 | 82 | - プロセスIDのチャットルーム内のメンバーの数を追跡します。 83 | - プロセスIDが保持する特定のトークンの残高を追跡します。 84 | 85 | ## 結論 86 | 87 | プロンプト内でのユーティリティを最大限に活用する方法を理解したので、ao開発体験を効率化するための重要なステップを手に入れました。 88 | -------------------------------------------------------------------------------- /src/ja/guides/aos/tables-and-json.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/ja/guides/aos/tables-and-json.md -------------------------------------------------------------------------------- /src/ja/guides/aos/troubleshooting.md: -------------------------------------------------------------------------------- 1 | # ao.linkを使用したトラブルシューティング 2 | 3 | 分散型コンピュータとネットワークで作業する際には、自分のコードだけでなく、メッセージ、トークン残高、プロセスのトークン転送を追跡できる必要があります。ここで[https://ao.link](https://ao.link)があなたのツールボックスに不可欠なツールとなります。 4 | 5 | ![ao.linkのホームページ、aoネットワークの統計を表示](aolink.png) 6 | 7 | ## 分析 8 | 9 | AOLinkには4つの分析指標があります: 10 | 11 | - 総メッセージ数 12 | - 総ユーザー数 13 | - 総プロセス数 14 | - 総モジュール数 15 | 16 | これらの分析は、aoネットワークの全体的な処理の健康状態を迅速に把握するのに役立ちます。 17 | 18 | ## イベント 19 | 20 | 下部には、aoコンピュータで最近発生した最新のイベントが表示されています。スケジュールされているメッセージと実行されたメッセージのリストがあります。これらのイベントは、aoデータプロトコルタイプのいずれかです。プロセスIDまたはメッセージIDをクリックすると、それぞれの詳細を取得できます。 21 | 22 | ![ao.linkのイベントリスト](aolink-list-example.png) 23 | 24 | ### メッセージの詳細 25 | 26 | ![ao.linkメッセージの詳細を表示](aolink-message-details.png) 27 | 28 | メッセージの詳細には、以下の重要な情報が含まれています: 29 | 30 | - 送信元 31 | - 送信先 32 | - ブロック高 33 | - 作成日時 34 | - タグ 35 | - データ 36 | - 結果のタイプ 37 | - データ 38 | 39 | さらにトラブルシューティングやデバッグを行いたい場合は、「Compute」をクリックしてCU(計算ユニット)の結果を確認するオプションがあります。 40 | 41 | ![ao.linkのデバッグ用計算結果の例](aolink-compute-example.png) 42 | 43 | リンクされたメッセージをさらに理解することもできます。 44 | ![ao.linkのリンクされたメッセージ](aolink-linked-message-example.png) 45 | 46 | ### プロセスの詳細 47 | 48 | ![ao.linkのプロセス詳細表示](aolink-process-details.png) 49 | 50 | プロセスの詳細には、プロセスに関する情報が提供されており、どのモジュールからインスタンス化されたかを示すタグを見るのに便利です。左側には、グラフで表示されたプロセスとのインタラクションが見えます。この場合、これはDevChatであり、登録やメッセージのブロードキャストによって相互作用したすべてのプロセスが表示されています。 51 | 52 | 「Fetch」ボタンを押すことで、Info Handlerを簡単にチェックできます。 53 | ![ao.link情報ハンドラーを取得](aolink-info-handler-example.png) 54 | 55 | 下部にはプロセスの残高や送信されたすべてのメッセージが表示されており、タブを使用してトークンの転送とトークンの残高に分けるオプションがあります。 56 | ![ao.linkプロセスメッセージとトークン情報](aolink-message-and-token-example.png) 57 | 58 | ## さらなる質問は? 59 | 60 | ao.linkに関するすべての質問やサポートについては、自律ファイナンスのコミュニティDiscordに気軽にお問い合わせください。 61 | https://discord.gg/4kF9HKZ4Wu 62 | 63 | ## まとめ 64 | 65 | AOLinkは、aoコンピュータ内のイベントを追跡するための優れたツールです。ぜひ試してみてください。また、パーマウェブに別のスキャナーツールも利用可能です:https://ao_marton.g8way.io/ - ぜひチェックしてください! 66 | -------------------------------------------------------------------------------- /src/ja/guides/betteridea/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "0rbit" 4 | link: "../0rbit/index" 5 | next: 6 | text: "aos" 7 | link: "../aos/index" 8 | --- 9 | 10 | # BetterIDEa 11 | 12 | [BetterIDEa](https://ide.betteridea.dev)は、ao上での開発のためのカスタムWebベースのIDEです。 13 | 14 | ao定義が組み込まれたLua言語サーバーを提供しているため、何もインストールする必要はありません。IDEを開いてコーディングを始めるだけです! 15 | 16 | 機能には以下が含まれます: 17 | 18 | - コード補完 19 | - セルベースのノートブックUIによる迅速な開発 20 | - 簡単なプロセス管理 21 | - MarkdownおよびLatexセルのサポート 22 | - aoプロセスを介して誰とでもプロジェクトを共有 23 | - [aoパッケージマネージャ](https://apm.betteridea.dev)との緊密な統合 24 | 25 | IDEのさまざまな機能や統合についての詳細は、[ドキュメント](https://docs.betteridea.dev)をご覧ください。 26 | 27 | 52 | -------------------------------------------------------------------------------- /src/ja/guides/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "アリーナの拡張" 4 | link: "/tutorials/bots-and-games/build-game" 5 | next: 6 | text: "aos" 7 | link: "./aos/index" 8 | --- 9 | 10 | # ガイド 11 | 12 | これらのガイドは、aoおよびaosのナビゲートを手助けし、チャットルームから自律的で分散型のボットなど、さまざまなものを構築するための支援を目的としています。 13 | 14 | ## ガイドの一覧 15 | 16 | - [aos](aos/index) 17 | - [aoconnect](aoconnect/aoconnect) 18 | - [0rbit](0rbit/index) 19 | - [BetterIDEa IDE](betteridea/index) 20 | 40 | -------------------------------------------------------------------------------- /src/ja/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | # https://vitepress.dev/reference/default-theme-home-page 3 | layout: home 4 | 5 | hero: 6 | name: "" 7 | # text: "The hyper parallel computer." 8 | text: "ハイパーパラレルコンピュータ" 9 | # tagline: "Decentralized compute at any scale. Only possible on Arweave." 10 | tagline: "あらゆるスケールでの非中央集権コンピューティング。Arweave上でのみ実現可能。" 11 | actions: 12 | - theme: brand 13 | text: Let's Go! 14 | link: /ja/welcome/index 15 | 16 | features: 17 | - title: チュートリアル 18 | # details: Follow the step-by-step tutorials to start building on ao. 19 | details: ステップバイステップのチュートリアルに従って、ao上での構築を始めましょう。 20 | link: /ja/tutorials/index 21 | 22 | # - title: Guides 23 | - title: ガイド 24 | # details: Bite size walkthroughs on specific features. 25 | details: 特定の機能に関するシンプルな解説 26 | link: /ja/guides/index 27 | 28 | # - title: Concepts 29 | - title: コンセプト 30 | # details: Learn how the ao network works under the hood. 31 | details: aoネットワークがどのように動作しているかを学びましょう。 32 | link: /ja/concepts/index 33 | --- 34 | -------------------------------------------------------------------------------- /src/ja/llms-explanation.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: doc 3 | title: LLMs ファイルドキュメント 4 | --- 5 | 6 | # LLMs ファイルドキュメント 7 | 8 | ## **[llms.txt](/ja/llms.txt)**: 9 | 10 | - ao エコシステムの構造化された概要。 11 | - ドキュメントをナビゲートしたり一般的な質問に答えたりする AI ツールに最適。 12 | - ウェブ検索機能を持つ AI エージェントに適しています。 13 | 14 | ## **[llms-full.txt](/ja/llms-full.txt)**: 15 | 16 | - 完全な技術ドキュメント。 17 | - 詳細な分析、トラブルシューティング、またはチャットボット統合用に設計。 18 | - 複雑なクエリに対して詳細な情報を提供します。 19 | 20 | ::: info 21 | llms-full.txt ファイルはリファレンスとリリースノートのコンテンツのみを含んでいます。テストの結果、この焦点を絞ったアプローチが AI モデルでより良いパフォーマンスを発揮することが示されました。 22 | ::: 23 | -------------------------------------------------------------------------------- /src/ja/references/community.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "aoエディタ設定" 4 | link: "/references/editor-setup.md" 5 | --- 6 | 7 | # コミュニティ 8 | 9 | [Autonomous Finance](https://www.autonomous.finance/) 10 | 11 | - Autonomous Financeは、aoネットワーク内の金融インフラの複雑さに焦点を当てた、専用の研究および技術機関です。 12 | 13 | [BetterIdea](https://betteridea.dev/) 14 | 15 | - BetterIDEaを使用して、より高速でスマート、そして効率的に開発しましょう。AO開発向けの究極のネイティブWeb IDEです。 16 | 17 | [Orbit](https://www.0rbit.co/) 18 | 19 | - 0rbitは、aoプロセスにウェブからのデータを提供します。aoの力と0rbitノードを活用することで、ユーザーは0rbit aoにメッセージを送り、0rbitノードがデータを取得し、ユーザープロセスがそのデータを受け取ります。 20 | -------------------------------------------------------------------------------- /src/ja/references/data.md: -------------------------------------------------------------------------------- 1 | 15 | 16 | # aoを使ってArweaveからデータにアクセスする 17 | 18 | aoの開発ワークフローにおいて、Arweaveからデータにアクセスしたい時があるかもしれません。aoでは、プロセスがネットワークにデータをプロセスに提供するよう指示するアサインメントを送信できます。 19 | 20 | Arweaveからデータをリクエストするには、データを割り当てたいプロセスのリストと、メッセージ(メッセージのtxid)を指定してAssignを呼び出すだけです。 21 | 22 | ```lua 23 | Assign({ 24 | Processes = { ao.id }, 25 | Message = 'message-id' 26 | }) 27 | ``` 28 | 29 | また、Sendを呼び出して、AssignmentsパラメータにプロセスIDのテーブルを指定することもできます。これにより、ネットワークはメッセージを生成し、Assignmentsリスト内のすべてのプロセスIDに割り当てるよう指示されます。 30 | 31 | 32 | 33 | ```lua 34 | Send({ 35 | Target = ao.id, 36 | Data = 'Hello World', 37 | Assignments = { 'process-id-1', 'process-id-2' } 38 | }) 39 | ``` 40 | 41 | ## なぜArweaveからデータを取得するのか? 42 | 43 | 44 | 45 | あなたのプロセスは、何かを決定するためにメッセージからデータにアクセスする必要があるかもしれません。また、`data`ロード機能を使用してプロセスに機能を追加したい場合もあります。あるいは、メッセージ全体を複製することなく、他のプロセスからメッセージにアクセスしたい場合もあるでしょう。 46 | -------------------------------------------------------------------------------- /src/ja/references/editor-setup.md: -------------------------------------------------------------------------------- 1 | --- 2 | next: 3 | text: "コミュニティ" 4 | link: "/references/community" 5 | --- 6 | 7 | # エディタのセットアップ 8 | 9 | aoの組み込み関数やユーティリティをすべて覚えるのは難しい場合があります。開発者体験を向上させるために、お気に入りのテキストエディタに[Lua Language Server](https://luals.github.io)拡張機能をインストールし、[ao addon](https://github.com/martonlederer/ao-definitions)を追加することをお勧めします。これにより、すべての組み込みのaos[モジュール](../guides/aos/modules/index.md)や[グローバル変数](../guides/aos/intro.md#globals)がサポートされます。 10 | 11 | ## VS Code 12 | 13 | [sumneko.lua](https://marketplace.visualstudio.com/items?itemName=sumneko.lua)拡張機能をインストールします: 14 | 15 | 1. 拡張機能マーケットプレイスで「Lua」を検索し、sumnekoの拡張機能を見つけます 16 | 2. 拡張機能をダウンロードしてインストールします 17 | 3. `Shift + Command + P`(Mac)/ `Ctrl + Shift + P`(Windows/Linux)でVS Codeのコマンドパレットを開き、次のコマンドを実行します: 18 | 19 | ``` 20 | > Lua: Open Addon Manager 21 | ``` 22 | 23 | 4. Addon Managerで「ao」を検索すると、最初に表示されるはずです。「Enable」をクリックして、オートコンプリートを楽しんでください! 24 | 25 | ## その他のエディタ 26 | 27 | 1. あなたのエディタが[Language Server Protocol](https://microsoft.github.io/language-server-protocol/implementors/tools/)をサポートしていることを確認してください 28 | 2. [luals.github.io](https://luals.github.io/#install)の指示に従ってLua Language Serverをインストールします 29 | 3. Language Serverに「ao」アドオンをインストールします 30 | 31 | ## BetterIDEa 32 | 33 | [BetterIDEa](https://ide.betteridea.dev)は、ao上での開発のためのカスタムWebベースのIDEです。 34 | 35 | ao定義が組み込まれたLua Language Serverを提供しているため、何もインストールする必要はありません。IDEを開いてコーディングを開始するだけです! 36 | 37 | 機能には以下が含まれます: 38 | 39 | - コード補完 40 | - セルベースのノートブックUIによる迅速な開発 41 | - 簡単なプロセス管理 42 | - MarkdownおよびLatexセルのサポート 43 | - aoプロセスを介して誰とでもプロジェクトを共有 44 | - [aoパッケージマネージャ](https://apm.betteridea.dev)との緊密な統合 45 | 46 | IDEのさまざまな機能や統合についての詳細は、[ドキュメント](https://docs.betteridea.dev)をご覧ください。 47 | -------------------------------------------------------------------------------- /src/ja/references/eval.md: -------------------------------------------------------------------------------- 1 | # Eval 2 | 3 | 各AOプロセスには、受信した新しいコードを評価するオンボードの`Eval`ハンドラが含まれています。このハンドラにより、プロセスは受信コードに対して適切なアクションを決定し、そのメッセージがプロセスの所有者からのものであるかを確認します。 4 | 5 | `Eval`ハンドラは、受信メッセージから受け取ったデータを評価するために手動でトリガーすることもできます。 6 | 7 | ## NodeJSでEvalメッセージを送信する 8 | 9 | ```js 10 | import { readFileSync } from "node:fs"; 11 | import { message, createDataItemSigner } from "@permaweb/aoconnect"; 12 | 13 | const wallet = JSON.parse( 14 | readFileSync("/path/to/arweave/wallet.json").toString(), 15 | ); 16 | 17 | await message({ 18 | // The arweave TXID of the process, this will become the "target". 19 | process: "process-id", // Replace with the actual process ID 20 | 21 | // Tagging the Eval Action so the recieving process evaluates and adds the new Handler from the Data field. 22 | tags: [ 23 | { name: "Action", value: "Eval" }, 24 | { 25 | name: "Data", 26 | value: 'Handlers.add("ping", Handlers.utils.reply("pong"))', 27 | }, 28 | ], 29 | 30 | // A signer function used to build the message "signature" 31 | signer: createDataItemSigner(wallet), 32 | }) 33 | .then(console.log) 34 | .catch(console.error); 35 | ``` 36 | 37 | ## ブラウザでEvalメッセージを送信する 38 | 39 | ```js 40 | import { message, createDataItemSigner } from "@permaweb/aoconnect"; 41 | 42 | await message({ 43 | // The arweave TXID of the process, this will become the "target". 44 | process: "process-id", // Replace with the actual process ID 45 | 46 | // Tagging the Eval Action so the recieving process evaluates and adds the new Handler from the Data field. 47 | tags: [ 48 | { name: "Action", value: "Eval" }, 49 | { 50 | name: "Data", 51 | value: 'Handlers.add("ping", Handlers.utils.reply("pong"))', 52 | }, 53 | ], 54 | 55 | // A signer function used to build the message "signature" 56 | signer: createDataItemSigner(globalThis.arweaveWallet), 57 | }) 58 | .then(console.log) 59 | .catch(console.error); 60 | ``` 61 | -------------------------------------------------------------------------------- /src/ja/references/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "aosインターフェース" 4 | link: "/concepts/tour" 5 | next: 6 | text: "Lua" 7 | link: "./lua" 8 | --- 9 | 10 | # 参考資料 11 | 12 | ## 目次 13 | 14 | - [Lua](lua) 15 | -------------------------------------------------------------------------------- /src/ja/references/wasm.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | # Web Assemblyについて 8 | 9 | WebAssembly(一般的にWasmと略される)は、C、C++、Rustのような高水準言語のためのポータブルなコンパイルターゲットを提供する、現代的なバイナリ命令形式です。クライアントおよびサーバーアプリケーション向けに、ウェブ上で高いレベルのパフォーマンスと効率を提供することができます。WebAssemblyは、ウェブブラウザのセキュリティとサンドボックス機能を維持するように設計されており、ウェブベースのアプリケーションに適した選択肢です。複数の言語でコードを書き、それをブラウザでネイティブに近い速度で実行されるバイトコードにコンパイルできるため、ウェブ開発者にとって重要な技術です。 10 | 11 | WebAssemblyの重要性は、ウェブアプリケーションとネイティブアプリケーションのギャップを埋める能力にあります。従来はデスクトップ環境に限定されていた複雑なアプリケーションやゲームを、ブラウザで同等のパフォーマンスで実行できるようにします。これにより、高性能のウェブアプリやゲーム、さらには既存のデスクトップアプリケーションをウェブに移植する新たな可能性が開かれます。WebAssemblyはJavaScriptと並行して動作し、パフォーマンスが重要なコンポーネントを、そうしたタスクにより適した言語で記述できるよう​⬤ 12 | -------------------------------------------------------------------------------- /src/ja/tutorials/begin/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "チュートリアル" 4 | link: "../index" 5 | next: 6 | text: "準備" 7 | link: "/tutorials/begin/preparations" 8 | --- 9 | 10 | # 始めよう: インタラクティブチュートリアル 11 | 12 | このチュートリアルシリーズでは、aos環境の知識と理解を深めるためのインタラクティブなステップを進めていきます。 13 | 14 | ::: info 15 | 16 | ### 演習 17 | 18 | この楽しい演習では、モーフィアスとトリニティという二人の親しみのあるキャラクターから提示される一連の課題に挑戦します。モーフィアスの導きに従い、あなたが`the one`であることを証明するための一連の課題に深く入り込むことになります。モーフィアスとトリニティの両方から提示されたすべての課題を完了すると、`The Construct`という名のao内の独占チャットルームにアクセスできるトークンが授与されます。 19 | 20 | それでは、[ウサギの穴へ](preparations)進んでいきましょう。 21 | ![白ウサギ](/white_rabbit_outline.svg) 22 | ::: 23 | 24 | ## チュートリアル 25 | 26 | ### 始めよう - インタラクティブチュートリアル 27 | 28 | - [1. クイックスタート](preparations) 29 | - [2. メッセージング](messaging) 30 | - [3. チャットルームの作成](chatroom) 31 | - [4. トークンの構築](token) 32 | 33 | 64 | -------------------------------------------------------------------------------- /src/ja/tutorials/bots-and-games/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "Tokengating" 4 | link: "../begin/tokengating" 5 | next: 6 | text: "Let's Play A Game!" 7 | link: "./ao-effect" 8 | --- 9 | 10 | 11 | 12 | # ボットとゲーム 13 | 14 | 15 | 16 | > [!NOTE] 17 | > 独自のボットを作成してクエスト3を完了し、1000 CREDを獲得しましょう。その後、 [Grid](https://github.com/twilson63/grid) のようなゲームに参加して、テストネットCREDを24時間365日獲得できます! 18 | 19 | 20 | 21 | 前章で得た知識を活かし、このセクションでは、aosでのボットによる自動化の領域とゲーム構築についてガイドします。自律エージェントを作成し、それを使ってゲーム環境を効果的にナビゲートし、相互作用させる方法を学びます。 22 | 23 | ## セクション 24 | 25 | - [0. **# Let's Play A Game:** _Experience a game on aos_](ao-effect) 26 | 27 | 28 | 29 | ### オートメーションによるゲームインタラクションの強化 30 | 31 | - [1. **# アナウンスの解釈:** _ゲーム内のアナウンスを解釈する_](announcements) 32 | - [2. **# ゲームステートの取得:** _最新のゲームステートを取得して処理する_](game-state) 33 | - [3. **# 戦略的判断:** _自動化を活用して次の行動を決定する_](decisions) 34 | - [4. **# 自動化された反応:** _攻撃への反応を自動化で効率化する_](attacking) 35 | - [5. **# スキルの統合:** _スキルを組み合わせて自律型エージェントを作成する_](bringing-together) 36 | 37 | 38 | 39 | ### ゲーム開発の洞察 40 | 41 | - [6. **# アリーナのメカニクス:** _ゲームのアリーナのメカニズムを探る_](arena-mechanics) 42 | - [7. **# アリーナの拡張:** _アリーナの上に独自のゲームロジックを構築する_](build-game) 43 | 44 | 45 | 46 | 発見と創造の旅が待っています。冒険を始めましょう! 47 | -------------------------------------------------------------------------------- /src/ja/tutorials/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "legacynet Info" 4 | link: "/welcome/legacynet-info" 5 | next: 6 | text: "Begin" 7 | link: "./begin/index" 8 | --- 9 | 10 | 11 | 12 | 13 | 14 | ここでは、aosを使い始め、最初のプロセスを構築するための一連のチュートリアルを用意しています。これらのチュートリアルには、インタラクティブガイド、コードスニペット、例が含まれており、aos環境に慣れるのに役立ちます。 15 | 16 | 17 | 18 | ## チュートリアル一覧 19 | 20 | 24 | 25 | - [はじめに - インタラクティブガイド](begin/index) 26 | 27 | - [ボットとゲーム](bots-and-games/index) 28 | -------------------------------------------------------------------------------- /src/ja/welcome/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | next: 3 | # text: "Getting Started" 4 | text: “はじめに” 5 | link: "./getting-started" 6 | --- 7 | 8 | 9 | 10 | # aoへようこそ 11 | 12 | ![ao logo](/ao-logo-grey.svg) 13 | 14 | 15 | 16 | aoコンピュータは、無数の並行プロセスが単一の統合された計算環境内で相互に作用する世界です。これらのプロセスは、ネイティブなメッセージパッシング層を通じてシームレスに結びついています。これは、各プロセスが独立して動作しながらも、統一された体験の一部として密接に織り込まれる、Webサイトのように機能する分散プログラムのエコシステムです。 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | ## ao + aos: ロケットとその燃料 25 | 26 | 通常、aoを使用する際には、オペレーティングシステムであるaosを介して操作します。 27 | 28 | aosは、あなたのプロセス内で動作する抽象化レイヤーで、aoコンピュータの全機能を簡単に利用できるようにします。このクックブックでは、aosを使ってaoコンピュータを始めるために必要なすべての知識を学んでいきます。 29 | 30 | 31 | 32 | 33 | 34 | ## 次のステップ 35 | 36 | 今後のチュートリアルでは、aoを探索し、チャットルームから自律的かつ分散化されたボットまで、さまざまなものを構築していきます。 37 | 38 | 39 | 40 | さあ、始めましょう!🚀 41 | -------------------------------------------------------------------------------- /src/llms-explanation.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: doc 3 | title: LLMs Documentation 4 | description: Explanation of the LLMs.txt files available for the ao Cookbook 5 | --- 6 | 7 | # LLMs Documentation 8 | 9 | ## **[llms.txt](/llms.txt)**: 10 | 11 | - Structured overview of the ao ecosystem. 12 | - Ideal for AI tools navigating documentation or answering general questions. 13 | - Suited for agents with web search capabilities. 14 | 15 | ## **[llms-full.txt](/llms-full.txt)**: 16 | 17 | - Complete technical documentation. 18 | - Designed for in-depth analysis, troubleshooting, or chatbot integration. 19 | - Provides exhaustive details for complex queries. 20 | 21 | ::: info 22 | The `llms-full.txt` file only contains content from references and release notes, as testing showed this focused approach performs better with current AI models. 23 | ::: 24 | -------------------------------------------------------------------------------- /src/mainnet/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | next: 3 | text: "AO Core Relay" 4 | link: "./ao-core-relay" 5 | --- 6 | 7 | # AO Mainnet 8 | 9 | AO Mainnet is here, marking a major step toward a decentralized, open-access supercomputer directly connected to the internet. It enables confidential, decentralized computation without reliance on centralized Web2 infrastructure, expanding access to information and opportunity. 10 | 11 | This documentation is an evolving resource. More guides and references will be added soon. 12 | 13 | ## Get Started 14 | 15 | Learn how to start interacting with HyperBEAM allowing you to send messages and handle payments directly from the command line. 16 | 17 | - [AO Core Relay](ao-core-relay) 18 | 19 | ## Launch Video 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/public/ao-effect-game-banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/public/ao-effect-game-banner.png -------------------------------------------------------------------------------- /src/public/ao-logo-grey.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/public/ao_pictograph_darkmode.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/public/ao_pictograph_lightmode.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/public/aos-print.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/public/aos-print.png -------------------------------------------------------------------------------- /src/public/chatroom1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/public/chatroom1.png -------------------------------------------------------------------------------- /src/public/chatroom2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/public/chatroom2.png -------------------------------------------------------------------------------- /src/public/chatroom3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/public/chatroom3.png -------------------------------------------------------------------------------- /src/public/chatroom4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/public/chatroom4.png -------------------------------------------------------------------------------- /src/public/chatroom5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/public/chatroom5.png -------------------------------------------------------------------------------- /src/public/chatroom6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/public/chatroom6.png -------------------------------------------------------------------------------- /src/public/chatroom7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/public/chatroom7.png -------------------------------------------------------------------------------- /src/public/chatroom8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/public/chatroom8.png -------------------------------------------------------------------------------- /src/public/messaging1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/public/messaging1.png -------------------------------------------------------------------------------- /src/public/messaging2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/public/messaging2.png -------------------------------------------------------------------------------- /src/public/token1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/public/token1.png -------------------------------------------------------------------------------- /src/public/token2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/public/token2.png -------------------------------------------------------------------------------- /src/public/token3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/public/token3.png -------------------------------------------------------------------------------- /src/references/betteridea/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "0rbit" 4 | link: "../0rbit/index" 5 | next: 6 | text: "aos" 7 | link: "../aos/index" 8 | --- 9 | 10 | # BetterIDEa 11 | 12 | [BetterIDEa](https://ide.betteridea.dev) is a custom web based IDE for developing on ao. 13 | 14 | It offers a built in Lua language server with ao definitions, so you don't need to install anything. Just open the IDE and start coding! 15 | 16 | Features include: 17 | 18 | - Code completion 19 | - Cell based notebook ui for rapid development 20 | - Easy process management 21 | - Markdown and Latex cell support 22 | - Share projects with anyone through ao processes 23 | - Tight integration with [ao package manager](https://apm.betteridea.dev) 24 | 25 | Read detailed information about the various features and integrations of the IDE in the [documentation](https://docs.betteridea.dev). 26 | -------------------------------------------------------------------------------- /src/references/community.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "ao Editor Setup" 4 | link: "/references/editor-setup.md" 5 | --- 6 | 7 | # Community Resources 8 | 9 | This page provides a comprehensive list of community resources, tools, guides, and links for the AO ecosystem. 10 | 11 | ## Core Resources 12 | 13 | [Autonomous Finance](https://www.autonomous.finance/) 14 | 15 | - Autonomous Finance is a dedicated research and technology entity, focusing on the intricacies of financial infrastructure within the ao network. 16 | 17 | [BetterIdea](https://betteridea.dev/) 18 | 19 | - Build faster, smarter, and more efficiently with BetterIDEa, the ultimate native web IDE for AO development 20 | 21 | [0rbit](https://www.0rbit.co/) 22 | 23 | - 0rbit provides any data from the web to an ao process 24 | by utilizing the power of ao, and 0rbit nodes. 25 | The user sends a message to the 0rbit ao, 0rbit nodes fetches the data and the user process receives the data. 26 | 27 | [ArweaveHub](https://arweavehub.com/) 28 | 29 | - A community platform for the Arweave ecosystem featuring events, developer resources, and discovery tools. 30 | 31 | [AR.IO](https://ar.io/) 32 | 33 | - The first permanent cloud network built on Arweave, providing infrastructure for the permaweb with no 404s, no lost dependencies, and reliable access to applications and data through gateways, domains, and deployment tools. 34 | 35 | ## Developer Tools 36 | 37 | - [AO Package Manager](https://apm_betteridea.arweave.net) 38 | 39 | ## Contributing 40 | 41 | > Not seeing an AO Community Member or resource? Create an issue or submit a pull request to add it to this page: https://github.com/permaweb/ao-cookbook 42 | -------------------------------------------------------------------------------- /src/references/cron.md: -------------------------------------------------------------------------------- 1 | # Cron Messages 2 | 3 | ao has the ability to generate messages on a specified interval, this interval could be seconds, minutes, hours, or blocks. These messages automatically get evaluated by a monitoring process to inform the Process to evaluate these messages over time. The result is a real-time Process that can communicate with the full ao network or oracles in the outside network. 4 | 5 | ## Setting up cron in a process 6 | 7 | The easiest way to create these cron messages is by spawning a new process in the aos console and defining the time interval. 8 | 9 | ```sh 10 | aos [myProcess] --cron 5-minutes 11 | ``` 12 | 13 | When spawning a new process, you can pass a cron argument in your command line followed by the interval you would like the cron to tick. By default, cron messages are lazily evaluated, meaning they will not be evaluated until the next scheduled message. To initiate these scheduled cron messages, call `.monitor` in aos - this kicks off a worker process on the `mu` that triggers the cron messages from the `cu`. Your Process will then receive cron messages every `x-interval`. 14 | 15 | ```lua 16 | .monitor 17 | ``` 18 | 19 | If you wish to stop triggering the cron messages simply call `.unmonitor` and this will stop the triggering process, but the next time you send a message, the generated cron messages will still get created and processed. 20 | 21 | ## Handling cron messages 22 | 23 | Every cron message has an `Action` tag with the value `Cron`. [Handlers](handlers.md) can be defined to perform specific tasks autonomously, each time a cron message is received. 24 | 25 | ```lua 26 | Handlers.add( 27 | "CronTick", -- Handler name 28 | Handlers.utils.hasMatchingTag("Action", "Cron"), -- Handler pattern to identify cron message 29 | function () -- Handler task to execute on cron message 30 | -- Do something 31 | end 32 | ) 33 | ``` 34 | 35 | Cron messages are a powerful utility that can be used to create "autonomous agents" with expansive capabilities. 36 | -------------------------------------------------------------------------------- /src/references/editor-setup.md: -------------------------------------------------------------------------------- 1 | --- 2 | next: 3 | text: "Community" 4 | link: "/references/community" 5 | --- 6 | 7 | # Editor setup 8 | 9 | Remembering all the built in ao functions and utilities can sometimes be hard. To enhance your developer experience, it is recommended to install the [Lua Language Server](https://luals.github.io) extension into your favorite text editor and add the [ao addon](https://github.com/martonlederer/ao-definitions). It supports all built in aos [modules](../guides/aos/modules/index.md) and [globals](../guides/aos/intro.md#globals). 10 | 11 | ## VS Code 12 | 13 | Install the [sumneko.lua](https://marketplace.visualstudio.com/items?itemName=sumneko.lua) extension: 14 | 15 | 1. Search for "Lua" by sumneko in the extension marketplace 16 | 2. Download and install the extension 17 | 3. Open the VS Code command palette with `Shift + Command + P` (Mac) / `Ctrl + Shift + P` (Windows/Linux) and run the following command: 18 | 19 | ``` 20 | > Lua: Open Addon Manager 21 | ``` 22 | 23 | 4. In the Addon Manager, search for "ao", it should be the first result. Click "Enable" and enjoy autocomplete! 24 | 25 | ## Other editors 26 | 27 | 1. Verify that your editor supports the [language server protocol](https://microsoft.github.io/language-server-protocol/implementors/tools/) 28 | 2. Install Lua Language Server by following the instructions at [luals.github.io](https://luals.github.io/#install) 29 | 3. Install the "ao" addon to the language server 30 | 31 | ## BetterIDEa 32 | 33 | [BetterIDEa](https://ide.betteridea.dev) is a custom web based IDE for developing on ao. 34 | 35 | It offers a built in Lua language server with ao definitions, so you don't need to install anything. Just open the IDE and start coding! 36 | 37 | Features include: 38 | 39 | - Code completion 40 | - Cell based notebook ui for rapid development 41 | - Easy process management 42 | - Markdown and Latex cell support 43 | - Share projects with anyone through ao processes 44 | - Tight integration with [ao package manager](https://apm.betteridea.dev) 45 | 46 | Read detailed information about the various features and integrations of the IDE in the [documentation](https://docs.betteridea.dev). 47 | -------------------------------------------------------------------------------- /src/references/glossary.md: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/references/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "The aos interface" 4 | link: "/concepts/tour" 5 | next: 6 | text: "Lua" 7 | link: "./lua" 8 | --- 9 | 10 | # References 11 | 12 | This section provides detailed technical references for AO components, languages, and tools. Use these resources to find specific information when implementing your AO projects. 13 | 14 | ## Programming Languages 15 | 16 | Resources for the programming languages used in AO: 17 | 18 | - [Lua](./lua) - Reference for the Lua programming language, the primary language used in AO 19 | - [WebAssembly (WASM)](./wasm) - Information about using WebAssembly modules in AO 20 | - [Lua Optimization](./lua-optimization) - Techniques and best practices for optimizing Lua code in AO 21 | 22 | ## AO API Reference 23 | 24 | Documentation for AO's core APIs and functionality: 25 | 26 | - [AO Core](./ao) - Core `ao` module and API reference 27 | - [Messaging](./messaging) - Comprehensive guide to the AO messaging system patterns 28 | - [Handlers](./handlers) - Reference for event handlers and message processing 29 | - [Token](./token) - Information about token creation and management 30 | - [Arweave Data](./data) - Guide to data handling and storage in AO 31 | - [Cron](./cron) - Documentation for scheduling and managing timed events 32 | 33 | ## Development Environment 34 | 35 | Tools and setup for AO development: 36 | 37 | - [Editor Setup](./editor-setup) - Guide to setting up your development environment for AO 38 | - [BetterIDEa](./betteridea/index) - The ultimate native web IDE for AO development 39 | 40 | ## Community Resources 41 | 42 | Connect with the AO community: 43 | 44 | - [Community Resources](./community) - Information about AO community resources and support 45 | 46 | ## Navigation 47 | 48 | Use the sidebar to navigate between reference topics. References are organized by category to help you find the information you need quickly. 49 | -------------------------------------------------------------------------------- /src/references/lua.md: -------------------------------------------------------------------------------- 1 | # Meet Lua 2 | 3 | ## Understanding Lua 4 | 5 | - **Background**: Lua is a lightweight, high-level, multi-paradigm programming language designed primarily for embedded systems and clients. It's known for its efficiency, simplicity, and flexibility. 6 | - **Key Features**: Lua offers powerful data description constructs, dynamic typing, efficient memory management, and good support for object-oriented programming. 7 | 8 | ## Setting Up 9 | 10 | 1. **Installation**: Visit [Lua's official website](http://www.lua.org/download.html) to download and install Lua. 11 | 2. **Environment**: You can use a simple text editor and command line, or an IDE like ZeroBrane Studio or Eclipse with a Lua plugin. 12 | 13 | ## Basic Syntax and Concepts (in aos) 14 | 15 | - **Hello World**: 16 | ```lua 17 | "Hello, World!" 18 | ``` 19 | - **Variables and Types**: Lua is dynamically typed. Basic types include `nil`, `boolean`, `number`, `string`, `function`, `userdata`, `thread`, and `table`. 20 | - **Control Structures**: Includes `if`, `while`, `repeat...until`, and `for`. 21 | - **Functions**: First-class citizens in Lua, supporting closures and higher-order functions. 22 | - **Tables**: The only data structuring mechanism in Lua, which can be used to represent arrays, sets, records, etc. 23 | 24 | ## Hands-On Practice 25 | 26 | - **Experiment with Lua's Interactive Mode**: Run `aos` in your terminal and start experimenting with Lua commands. 27 | - **Write Simple Scripts**: Create `.lua` files and run them using the Lua interpreter. Use `.load file.lua` feature to upload lua code on your `aos` process. 28 | 29 | ## Resources 30 | 31 | - **Official Documentation**: [Lua 5.3 Reference Manual](https://www.lua.org/manual/5.3/) 32 | - **Online Tutorials**: Websites like [Learn Lua](https://www.learn-lua.org/) are great for interactive learning. 33 | - **Books**: "Programming in Lua" (first edition available [online](http://www.lua.org/pil/contents.html)) is a comprehensive resource. 34 | - **Community**: Join forums or communities like [Lua Users](http://lua-users.org/) for support and discussions. 35 | 36 | ## Best Practices 37 | 38 | - **Keep It Simple**: Lua is designed to be simple and flexible. Embrace this philosophy in your code. 39 | - **Performance**: Learn about Lua's garbage collection and efficient use of tables. 40 | - **Integration**: Consider how Lua can be embedded into other applications, particularly C/C++ projects. 41 | 42 | ## Conclusion 43 | 44 | Lua is a powerful language, especially in the context of embedded systems and game development. Its simplicity and efficiency make it a great choice for specific use cases. Enjoy your journey into Lua programming! 45 | -------------------------------------------------------------------------------- /src/references/wasm.md: -------------------------------------------------------------------------------- 1 | # Meet Web Assembly 2 | 3 | WebAssembly (often abbreviated as Wasm) is a modern binary instruction format providing a portable compilation target for high-level languages like C, C++, and Rust. It enables deployment on the web for client and server applications, offering a high level of performance and efficiency. WebAssembly is designed to maintain the security and sandboxing features of web browsers, making it a suitable choice for web-based applications. It's a key technology for web developers, allowing them to write code in multiple languages and compile it into bytecode that runs in the browser at near-native speed. 4 | 5 | The significance of WebAssembly lies in its ability to bridge the gap between web and native applications. It allows complex applications and games, previously limited to desktop environments, to run in the browser with comparable performance. This opens up new possibilities for web development, including the creation of high-performance web apps, games, and even the porting of existing desktop applications to the web. WebAssembly operates alongside JavaScript, complementing it by enabling performance-critical components to be written in languages better suited for such tasks, thereby enhancing the capabilities and performance of web applications. 6 | -------------------------------------------------------------------------------- /src/releasenotes/aos-2_0_2.md: -------------------------------------------------------------------------------- 1 | # AOS Release Notes v2.0.2 2 | 3 | ## Install 4 | 5 | ```sh 6 | npm install -g https://get_ao.arweave.net 7 | ``` 8 | 9 | ## Core Features 10 | 11 | - **Improved Spawn Process Times**: This release improves the process creation times for testnet. When you create new `aos` processes, it should now take only a few seconds to spawn. 12 | 13 | ## Fixes 14 | 15 | - Issue [#388](https://github.com/permaweb/aos/pull/388): fix(services/version): prevent checkForUpdate() 5xx response codes from stopping connection 16 | - Issue [#392](https://github.com/permaweb/aos/pull/392): Add Action Tag to broadcasted messages in Chatroom Blueprint 17 | - Issue [#391](https://github.com/permaweb/aos/pull/391): feat(aos): if multiple processes have the same name, allow user to select which process to run 18 | - Issue [#390](https://github.com/permaweb/aos/pull/390): fix(aos): fix error lines base cases, loading 19 | - Issue [#386](https://github.com/permaweb/aos/pull/386): fix(aos): get blueprints now uses dir 20 | - Issue [#337](https://github.com/permaweb/aos/issues/337): matchesspec does not work with from-process 21 | -------------------------------------------------------------------------------- /src/releasenotes/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | next: 3 | text: "Getting Started" 4 | link: "./getting-started" 5 | --- 6 | 7 | # Release Notes 8 | 9 | This section provides detailed information about updates, new features, bug fixes, and changes in each release of AO and its related tools. Release notes are essential for understanding what's changed between versions and how these changes might affect your projects. 10 | 11 | ## AOS Releases 12 | 13 | AOS is the operating system built on top of the AO computer. These release notes document changes and improvements to AOS: 14 | 15 | - [AOS 2.0.2](aos-2_0_2) - Improved spawn process times and various bug fixes 16 | - [AOS 2.0.1](aos-2_0_1) - Details about patch updates and fixes in the 2.0.1 release 17 | - [AOS 2.0.0](aos-2_0_0) - Major release information, including new features and significant changes 18 | 19 | ## Why Read Release Notes? 20 | 21 | Release notes provide valuable information for developers: 22 | 23 | - Learn about new features that could enhance your applications 24 | - Understand potential breaking changes that might affect existing code 25 | - Discover bug fixes that resolve issues you may have encountered 26 | - Stay informed about security updates and best practices 27 | 28 | We recommend reviewing release notes before upgrading to a new version to ensure a smooth transition. 29 | 30 | ## Navigation 31 | 32 | Use the sidebar to navigate between different release notes. Notes are organized chronologically with the most recent releases first. 33 | -------------------------------------------------------------------------------- /src/tools/replRenderer.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { createRoot } from "react-dom/client"; 3 | import { CodeCell } from "@betteridea/codecell"; 4 | 5 | const ReplRenderer = ({ id, code }) => ( 6 | 14 | ); 15 | 16 | export const renderRepl = (containerId, code) => { 17 | const container = document.getElementById(containerId); 18 | if (container) { 19 | createRoot(container).render(); 20 | } 21 | }; 22 | -------------------------------------------------------------------------------- /src/tutorials/begin/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "Tutorials" 4 | link: "../index" 5 | next: 6 | text: "Preparations" 7 | link: "/tutorials/begin/preparations" 8 | --- 9 | 10 | # Begin: An Interactive Tutorial 11 | 12 | In this tutorial series, you'll walk through an interactive steps that will help you deepen your knowledge and understanding of the aos environment. 13 | 14 | ::: info 15 | 16 | ### The Exercise 17 | 18 | In this fun exercise, you'll encounter a series of challenges presented by two familiar characters, Morpheus and Trinity. You'll dive deep `into the rabbit hole` guided by Morpheus as he presents you with a series of challenges to prove you're `the one`. Once you've completed all of the challenges presented by both Morpheus and Trinity, you'll receive a token that grants you access to an exclusive chatroom within ao called `The Construct`. 19 | 20 | Now, let's get started [down the rabbit hole.](preparations) 21 | ![White Rabbit](/white_rabbit_outline.svg) 22 | ::: 23 | 24 | ## Tutorials 25 | 26 | ### Getting Started - An Interactive Tutorial 27 | 28 | - [1. Quick Start](preparations) 29 | - [2. Messaging](messaging) 30 | - [3. Creating a Chatroom](chatroom) 31 | - [4. Build a Token](token) 32 | -------------------------------------------------------------------------------- /src/tutorials/bots-and-games/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "Tokengating" 4 | link: "../begin/tokengating" 5 | next: 6 | text: "Let's Play A Game!" 7 | link: "./ao-effect" 8 | --- 9 | 10 | # Bots and Games 11 | 12 | > [!NOTE] 13 | > Build your own unique bot to complete Quest 3 and earn 1000 CRED, then enter games like the [Grid](https://github.com/twilson63/grid) to earn legacynet CRED 24/7! 14 | 15 | Leveraging insights from our previous chapter, this section will guide you through the realm of automation with bots in aos and the construction of games. You will learn to create autonomous agents, using them to navigate and interact with game environments effectively. 16 | 17 | ## Sections 18 | 19 | ### Getting Started with a Game 20 | 21 | - [0. **# Let's Play A Game:** _Experience a game on aos_](ao-effect) 22 | 23 | ### Enhancing Game Interactions with Automation 24 | 25 | - [1. **# Interpreting Announcements:** _Interpret in-game announcements_](announcements) 26 | - [2. **# Fetching Game State:** _Retrieve and process the latest game state_](game-state) 27 | - [3. **# Strategic Decisions:** _Utilize automation to determine your next move_](decisions) 28 | - [4. **# Automated Responses:** _Streamline attack responses through automation_](attacking) 29 | - [5. **# Bringing it Together:** _Combine your skills to craft an autonomous agent_](bringing-together) 30 | 31 | ### Game Development Insights 32 | 33 | - [6. **# Mechanics of the Arena:** _Explore the underlying mechanics of a game's arena_](arena-mechanics) 34 | - [7. **# Expanding the Arena:** _Build unique game logic upon the arena_](build-game) 35 | 36 | A journey of discovery and creation awaits. Let the adventure begin! 37 | -------------------------------------------------------------------------------- /src/tutorials/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "legacynet Info" 4 | link: "/welcome/legacynet-info" 5 | next: 6 | text: "Begin" 7 | link: "./begin/index" 8 | --- 9 | 10 | # Tutorials 11 | 12 | Here, we've created a series of tutorials to help you get started with aos and build your first processes. These tutorials include interactive guides, code snippets, and examples to help you get comfortable with the aos environment. 13 | 14 | ## List of Tutorials 15 | 16 | - [Getting Started - An Interactive Guide](begin/index) 17 | 18 | - [Bots and Games](bots-and-games/index) 19 | -------------------------------------------------------------------------------- /src/welcome/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | next: 3 | text: "Getting Started" 4 | link: "./getting-started" 5 | --- 6 | 7 | # Welcome to ao 8 | 9 | ![ao logo](/ao-logo-grey.svg) 10 | 11 | AO is a decentralized compute system where countless parallel processes interact within a single, cohesive environment. Each process operates independently, yet they are seamlessly connected through a native message-passing layer, similar to how websites form the World Wide Web. 12 | 13 | ## AO + AOS: The rocket and your rocket fuel. 14 | 15 | Typically when you use AO, you will interact with it through its operating system: `AOS`. 16 | 17 | AOS is an abstraction layer that runs in your processes, making it easy to use the full functionality of the AO computer. In this cookbook, you will learn everything you need to know about getting started with the AO computer using AOS. 18 | 19 | ## Mainnet and Legacynet 20 | 21 | - **AO Mainnet** launched on **February 8, 2025**, introducing AO Core and enabling onchain computation with payments and relays. 22 | 23 | - **AO Legacynet** launched on **February 27, 2024**, providing a fee-free environment for early adopters to experiment with AO’s hyper-parallel architecture. 24 | 25 | ## Mainnet Documentation 26 | 27 | Phase 1 of Mainnet AO Core is now live in relay mode through HyperBEAM nodes, which serve as payment gateways to AO. See the guide below to get started. 28 | 29 | - [AO Core Relay](/mainnet/ao-core-relay) 30 | 31 | ## Legacynet Documentation 32 | 33 | These tutorials explore AO Legacynet, covering everything from building chatrooms to developing autonomous, decentralized bots. It’s a great starting point for experimenting with AO’s hyper-parallel architecture. 34 | 35 | - [Legacynet Tutorials](/tutorials/) 36 | 37 | ## Further References 38 | 39 | - [Guides](/guides/) 40 | - [Concepts](/concepts/) 41 | - [References](/references/) 42 | -------------------------------------------------------------------------------- /src/welcome/legacynet-info/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "Welcome" 4 | link: "../index" 5 | next: 6 | text: "Begin" 7 | link: "/tutorials/begin/index" 8 | --- 9 | 10 | # Get involved with the ao legacynet 11 | 12 | On February 27, 2024, `ao` legacynet was launched, for developers and early adopters to explore the hyper parallel computer. 13 | 14 | ## What is the ao legacynet? 15 | 16 | The `ao` legacynet is setup to allow users to interact with the `ao` computer without fees, to test and build towards mainnet. 17 | 18 | The best way to get involved is to build and use the `ao` computer with the `aos` console. 19 | In the `Things to do` section below you will find many activities to try. 20 | 21 | ## Installing the aos client 22 | 23 | Once you have [NodeJS](https://nodejs.org) on your machine, all you need to do is install `aos` and run it: 24 | 25 | ```sh 26 | $ npm i -g https://get_ao.arweave.net 27 | ``` 28 | 29 | Running this command at a later date will upgrade `aos` to the latest version. 30 | After installation, we can simply run the command itself to start a new `aos` process: 31 | 32 | ```sh 33 | $ aos 34 | ``` 35 | 36 | This will start a process named `default`. See [the aos guide](/guides/aos/index) for more details. 37 | 38 | ## First steps in the ao legacynet 39 | 40 | Follow the tutorials and learn to build on `ao`. [Begin](/tutorials/begin/index) 41 | 42 | ## Joining ao's native community chat 43 | 44 | The ao network hosts a number of chat servers that allow you to converse with other devs, 45 | right from your `aos` console. To load the chat client run the following: 46 | 47 | ```lua 48 | aos> .load-blueprint chat 49 | ``` 50 | 51 | To show the available rooms you can run: 52 | 53 | ```lua 54 | aos> List() 55 | ``` 56 | 57 | You can join a room and start chatting with other devs as follows: 58 | 59 | ```lua 60 | aos> Join("Getting-Started", "yourName") 61 | aos> Say("Hi") 62 | ``` 63 | -------------------------------------------------------------------------------- /src/welcome/legacynet-info/quests.md: -------------------------------------------------------------------------------- 1 | # Quests FAQ 2 | 3 | ::: info 4 | 5 | The `ao` ecosystem is in a very early stage and full of opportunity. 6 | There is a community quest board full of ways that you can get involved testing and building 7 | software to grow the ecosystem, all while earning its native currency: CRED. 8 | 9 | ::: 10 | 11 | ## Video Tutorial 12 | 13 | 14 | 15 | ## What quests are available? 16 | 17 | There is a dev chat room within `ao` localnet which you can query for quest information. 18 | First, launch `aos`: 19 | 20 | ```sh 21 | $ aos 22 | ``` 23 | 24 | Next, join the `Quests` chatroom, if you haven't done so already. You can optionally provide your 25 | screenname/handle as the second parameter 26 | 27 | ```lua 28 | aos> Join("Quests") 29 | # OR 30 | aos> Join("Quests", "MyScreenName") 31 | ``` 32 | 33 | Then you can send the `/Quests` slash command to that chatroom. In case you have joined multiple 34 | chatrooms, the second parameter sends the message to only one specific chatroom, by name. 35 | 36 | ```lua 37 | aos> Say("/Quests") 38 | # OR 39 | aos> Say("/Quests", "Quests") 40 | ``` 41 | 42 | After a few seconds, a bot will respond by broadcasting the list of available quests to the chatroom. 43 | 44 | ## How do I view the detailed quest description? 45 | 46 | You can learn more about the details of a specific quest, by sending a `/Quests:[index]` slash 47 | command into the `Quests` chatroom, where `[index]` should be replaced with the quest number, for example: 48 | 49 | ```lua 50 | aos> Say("/Quests:1", "Quests") 51 | # OR 52 | aos> Say("/Quests:2", "Quests") 53 | ``` 54 | 55 | ### Quest 1: "Begin" 56 | 57 | The detailed steps for Quest 1 are available in the [Begin](/tutorials/begin/index) tutorial in this cookbook. 58 | 59 | ### Quest 2: "Bots-and-Games" 60 | 61 | The detailed steps for Quest 2 are available in the [Bots and Games](/tutorials/bots-and-games/index) tutorial in this cookbook. 62 | 63 | ## How do I complete a quest? 64 | 65 | Follow _all_ the steps in the quest description, including submitting the claim. 66 | -------------------------------------------------------------------------------- /src/zh/concepts/CU-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/concepts/CU-diagram.png -------------------------------------------------------------------------------- /src/zh/concepts/MU-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/concepts/MU-diagram.png -------------------------------------------------------------------------------- /src/zh/concepts/SU-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/concepts/SU-diagram.png -------------------------------------------------------------------------------- /src/zh/concepts/ao-pictograph-c94ebf2d.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/zh/concepts/handler-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/concepts/handler-diagram.png -------------------------------------------------------------------------------- /src/zh/concepts/holographic-state.md: -------------------------------------------------------------------------------- 1 | TODO 2 | -------------------------------------------------------------------------------- /src/zh/concepts/how-it-works.md: -------------------------------------------------------------------------------- 1 | # ao 信使的工作原理 2 | 3 | 在我们深入了解 ao 之前,我想与你分享一些有关 UNIX 的信息。 Unix 是一个功能强大的操作系统,但在其设计中它专注于两种主要 `“类型”`。 文件和程序。 文件是数据,程序是逻辑,当你将两者结合起来时,你就会得到信息。 4 | 5 | `Input.file | TransformProgram | Output.file` 6 | 7 | 你可能在命令行上做了类似的事情,但不知道自己在做什么。 能够将文件连接到程序并返回文件,然后将其传递给其他程序,从而创建一个由简单应用程序组成的复杂系统。 这是一个非常牛逼的想法。 8 | 9 | 现在,我们来讨论 `ao` 即超并行计算机,并将文件更改为 `ao` 概念下的消息,将程序更改为 `ao` 概念下的进程。 `ao` 计算机接收消息并将它们发送到进程,其中这些进程可以输出可发送到其他进程的消息。 结果是一个建立在简单模块化逻辑容器之上的复杂系统。 10 | 11 | `MessageA | Process | MessageB` 12 | 13 | ![ao-消息](https://g8way.io/eAoqMqhwQ5vnpH_NJ6H2PiGgrcGDprtDIUH9Re2xcic) 14 | 15 | 以下是流程图中概述的过程的描述: 16 | 17 | 1. 一条消息从 ao Connect 被发出。 该消息使用 POST 请求发送到 `mu` 服务。 请求正文包含遵循同一协议的数据,标记为 `ao`,类型为 `Message`。 18 | 19 | 2. `mu` 服务处理 POST 请求并将消息转发到 `su` 服务。 这也是使用具有相同数据协议和消息类型的 POST 请求来完成的。 20 | 21 | 3. `su` 服务似乎与存储消息的称为 Arweave 的存储或数据层进行交互。 22 | 23 | 4. 向 `cu` 服务发出 GET 请求,以根据消息 ID 检索结果。 `cu` 是一种进程上的对消息求值并可以根据单个消息标识符返回结果的服务。 24 | 25 | 5. 向 `su` 服务发出 GET 请求以检索消息。 此请求查找来自某个进程 ID 的开始结束时间范围是 `from*` 到 `to*` 的消息。 26 | 27 | 6. 最后一步是推送所有发件箱消息。 它涉及检查结果对象中的消息和新进程生成请求。 根据此检查的结果,可以对每个相关消息或新进程生成请求重复步骤 2、3 和 4。 28 | -------------------------------------------------------------------------------- /src/zh/concepts/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "监控 Cron" 4 | link: "/zh/guides/aoconnect/monitoring-cron" 5 | next: 6 | text: "规范" 7 | link: "./specs" 8 | --- 9 | 10 | # 概念 11 | 12 | ao在设计中内置了很多概念,但核心概念都是非常简单的原则: 13 | 14 | - 两种核心类型:消息和进程 15 | - 没有共享状态,只有全息状态 16 | - 去中心化计算机(网格) 17 | 18 | 下面是一组概念文档,将 ao 系统分解为不同的部分。 19 | 20 | - [规范](specs) 21 | - [进程](processes) 22 | - [消息](messages) 23 | - [单元](units) 24 | - [消息传递的工作原理](how-it-works) 25 | 26 | [[toc]] 27 | -------------------------------------------------------------------------------- /src/zh/concepts/message-workflow-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/concepts/message-workflow-diagram.png -------------------------------------------------------------------------------- /src/zh/concepts/messages.md: -------------------------------------------------------------------------------- 1 | # 消息 2 | 3 | 消息作为 ao 中的基本数据协议单元,依据 [ANS-104 DataItems](https://specs.g8way.io/?tx=xwOgX-MmqN5_-Ny_zNu2A8o-PnTGsoRb_3FrtiMAkuw) 制作而成,从而与 Arweave 的原生结构保持一致。 当消息体进入进程时,其结构如下: 4 | 5 | ```lua 6 | { 7 | Cron = false, 8 | Data = "Hello aos", 9 | Epoch = 0, 10 | From = "5WzR7rJCuqCKEq02WUPhTjwnzllLjGu6SA7qhYpcKRs", 11 | Id = "ayVo53qvZswpvxLlhMf8xmGjwxN0LGuHzzQpTLT0_do", 12 | Nonce = 1, 13 | Owner = "z1pq2WzmaYnfDwvEFgUZBj48anUsxxN64ZjbWOsIn08", 14 | Signature = "...", 15 | Tags = { 16 | Type = "Message", 17 | Variant = "ao.TN.1", 18 | ["Data-Protocol"] = "ao", 19 | ["From-Module"] = "lXfdCypsU3BpYTWvupgTioLoZAEOZL2_Ihcqepz6RiQ", 20 | ["From-Process"] = "5WzR7rJCuqCKEq02WUPhTjwnzllLjGu6SA7qhYpcKRs" 21 | }, 22 | Target = "5WzR7rJCuqCKEq02WUPhTjwnzllLjGu6SA7qhYpcKRs", 23 | Timestamp = 1704936415711, 24 | ["Block-Height"] = 1340762, 25 | ["Forwarded-By"] = "z1pq2WzmaYnfDwvEFgUZBj48anUsxxN64ZjbWOsIn08", 26 | ["Hash-Chain"] = "hJ0B-0yxKxeL3IIfaIIF7Yr6bFLG2vQayaF8G0EpjbY" 27 | } 28 | ``` 29 | 30 | 该架构将任务类型与消息类型合并,使进程能够全面了解消息的上下文,以便进行有效的处理。 31 | 32 | 下面是发送消息时,消息在 ao 计算机内流转的流程图。 33 | 34 | ![消息工作流程](message-workflow-diagram.png) 35 | 36 | 消息工作流程从 MU(信使单元)开始,消息的签名在此处进行验证。紧接着,SU(调度程序单元)为消息分配 Epoch 和 Nonce,将消息与任务类型捆绑在一起,并将其分发给 Arweave。 随后,`aoconnect` 库从 CU(计算单元)拿到结果。 然后,CU 从 SU(调度器单元)读取此前流转到当前消息 Id 的所有消息,处理它们以推断出结果。 完成后,计算结果被传送回给 `aoconnect`,`aoconnect` 库被集成在 `aos` 等客户端接口中。 37 | 38 | ## 概括 39 | 40 | 消息作为 ao 网络的主要数据协议类型,利用 Arweave 原生的 ANS-104 数据项。消息包含多个字段,包括数据内容、来源、目标以及签名和随机数等加密元素。 接着他们被发给信使单元 (MU) ,以确保它们经过签名,通过调度器单元 (SU) 对它们进行时间戳和排序,然后捆绑并发布到 Arweave。 然后,`aoconnect` 库从计算单元 (CU) 读取结果,CU 通过处理消息来计算出结果后通过 `aoconnect` 发回响应,供 `aos` 等客户端使用。 CU 是这些进程的执行环境。 41 | -------------------------------------------------------------------------------- /src/zh/concepts/process-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/concepts/process-diagram.png -------------------------------------------------------------------------------- /src/zh/concepts/processes.md: -------------------------------------------------------------------------------- 1 | # 进程 2 | 3 | 进程之间具有通过消息传递进行通信的能力,包括在网络内接收和发送消息。 此外,它们还具有实例化更多进程的潜力,从而增强网络的计算结构。这种网络内数据传播和交互的动态方法被称为 `全息状态`,支撑网络状态的共享和持久化。 4 | 5 | ![流程图](process-diagram.png) 6 | 7 | 当使用 `aos` 构建进程时,你可以添加`处理程序`(`handlers`),可以通过调用 `Handlers.add` 函数并传递 “name”、“match”函数和“handle”函数来添加这些处理程序。 8 | 9 | ![处理程序图](handler-diagram.png) 10 | 11 | 核心模块包含一个注入到处理函数中的帮助程序库,该库称为 `ao`。 12 | 13 | ```lua 14 | { 15 | env = { 16 | Process = { 17 | Id = "5WzR7rJCuqCKEq02WUPhTjwnzllLjGu6SA7qhYpcKRs", 18 | Owner = "_r9LpP4FtClpsGX3TOohubyaeb0IQTZZMcxQ24tTsGo", 19 | Tags = {...} 20 | }, 21 | Module = { 22 | Id = "UAUszdznoUPQvXRbrFuIIH6J0N_LnJ1h4Trej28UgrE", 23 | Owner = "_r9LpP4FtClpsGX3TOohubyaeb0IQTZZMcxQ24tTsGo", 24 | Tags = {..} 25 | } 26 | }, 27 | id = "5WzR7rJCuqCKEq02WUPhTjwnzllLjGu6SA7qhYpcKRs", 28 | isTrusted = "function: 0x5468d0", 29 | result = "function: 0x547120", 30 | send = "function: 0x547618", 31 | spawn = "function: 0x5468b0" 32 | } 33 | ``` 34 | 35 | 在这个 `ao` 辅助库中要查看的主要函数是 36 | 37 | - ao.send(Message) - 向进程发送消息 38 | - ao.spawn(Module, Message) - 创建一个新进程 39 | 40 | ## ao.send 示例 41 | 42 | ```lua 43 | ao.send({ 44 | Target = Chatroom, 45 | Action = "Broadcast", 46 | Data = "Hello from my Process!" 47 | }) 48 | ``` 49 | 50 | ## ao.spawn 示例 51 | 52 | ```lua 53 | ao.spawn(ao.env.Module.Id, { 54 | ["Memory-Limit"] = "500-mb", 55 | ["Compute-Limit"] = "900000000000000000" 56 | }) 57 | ``` 58 | 59 | ## ao.env 60 | 61 | > 注意:`ao.env` 是开发人员创建进程时可能要用到的重要上下文数据。 62 | 63 | `ao.env` 属性包含 `Process` 和 `Module` 引用对象 64 | 65 | ```lua 66 | env = { 67 | Process = { 68 | Id = "5WzR7rJCuqCKEq02WUPhTjwnzllLjGu6SA7qhYpcKRs", 69 | Owner = "_r9LpP4FtClpsGX3TOohubyaeb0IQTZZMcxQ24tTsGo", 70 | Tags = {...} 71 | }, 72 | Module = { 73 | Id = "UAUszdznoUPQvXRbrFuIIH6J0N_LnJ1h4Trej28UgrE", 74 | Owner = "_r9LpP4FtClpsGX3TOohubyaeb0IQTZZMcxQ24tTsGo", 75 | Tags = {..} 76 | } 77 | } 78 | ``` 79 | 80 | `Process` 和 `Module` 都包含 `ao` 数据协议的属性。 81 | 82 | ## 概括 83 | 84 | 网络中的进程通过消息传递进行通信,并且可以创建新进程,从而形成共享和持久数据的 `"全息状态"`。 开发人员可以使用 `aos` 构建进程,通过 `Handlers.add` 函数添加具有特定名称、以及匹配和处理函数的处理程序。 核心模块中的 `ao` 辅助库有助于此过程,提供 `ao.send` 函数来分发消息以及 `ao.spawn` 函数来创建新模块,以及同等重要的 `ao.env` 属性,它包含进程和模块的必要信息。`ao` 数据协议概述了这些元素的结构和属性。 85 | -------------------------------------------------------------------------------- /src/zh/concepts/specs.md: -------------------------------------------------------------------------------- 1 | # ao 规范 2 | 3 | ## 什么是 `ao` ? 4 | 5 | `ao` 计算机是一个 [actor oriented](https://en.wikipedia.org/wiki/Actor_model) 的机器,它产生于遵守其核心数据协议的节点网络,运行在 [Arweave](https://arweave.org) 网络上。 本文档简要介绍了该协议及其功能以及技术细节,以便构建者可以创建与其集成的新实现和服务。 6 | 7 | `ao` 计算机是一个单一的、统一的计算环境([单系统映像](https://en.wikipedia.org/wiki/Single_system_image)),托管在分布式网络中的一组异构节点上。 `ao` 旨在提供一个环境,其中可以驻留任意数量的并行进程,并通过开放的消息传递层进行协调。 这种消息传递标准将机器的独立运行进程连接到一个 `"网络"` 中,就像网站在独立服务器上运行但通过超链接连接成一个有凝聚力的统一整体。 8 | 9 | [了解更多](https://ao.g8way.io/specs) 10 | -------------------------------------------------------------------------------- /src/zh/concepts/tour.md: -------------------------------------------------------------------------------- 1 | # aos 简明教程 2 | 3 | 欢迎来到 aos 快速入门!本教程将引导你了解 aos 环境中可用的关键全局函数和变量,让你对如何有效地与 aos 交互和使用有基本的了解。 4 | 5 | ## 1.收件箱(Inbox)简介 6 | 7 | - **它是什么**:`Inbox` 是一个 Lua 表,用于存储进程收到但尚未处理的所有消息。 8 | - **如何使用**:直接输入 `Inbox` 可以查看传入的消息。 迭代 `Inbox[x]` 来处理这些消息。 9 | 10 | ## 2. 使用 `Send(Message)` 发送消息 11 | 12 | - **功能**:`Send(Message)` 是一个向其他进程发送消息的全局函数。 13 | - **使用示例**:`Send({Target = "...", Data = "Hello, Process!"})` 发送一条带有数据 `Hello, Process!` 的消息到指定的进程。 14 | 15 | ## 3. 使用 `Spawn(Module, Message)` 创建进程 16 | 17 | - **目的**:使用 `Spawn(Module, Message)` 创建新进程。 18 | - **示例**:`Spawn("MyModule", {Data = "Start"})` 使用 `MyModule` 和提供的消息启动一个新进程。 19 | 20 | ## 4. 理解名称(Name)和所有者(Owner) 21 | 22 | - **名称**:初始化时设置的字符串,代表进程的名称。 23 | - **所有者**:表示进程的所有者。 更改此值可能会限制你与流程交互的能力。 24 | - **重要提示**:将它们视为只读以避免出现问题。 25 | 26 | ## 5. 使用处理程序(Handlers) 27 | 28 | - **它们是什么**:`Handlers` 是用于创建消息处理程序的辅助函数表。 29 | - **用法**:在 `Handlers` 中定义处理程序,以根据模式匹配给不同的消息指定对应操作。 30 | 31 | ## 6. 使用 `Dump` 进行数据展示 32 | 33 | - **功能**:`Dump` 将任何 Lua 表转换为适合打印的格式。 34 | - **如何使用**:对于调试或查看复杂的表结构很有用。 示例:`Dump(Inbox)` 打印 `Inbox` 的内容。 35 | 36 | ## 7. 用好 Utils 模块 37 | 38 | - **内容**:Utils 包含一系列功能实用程序,如 `map`、`reduce`和`filter`。 39 | - **用法**:非常适合 Lua 中的数据操作和函数式编程模式。 例如,`Utils.map(myTable, function(x) return x * 2 end)` 将表中的值加倍。 40 | 41 | ## 8. 探索 ao 核心库 42 | 43 | - **描述**:`ao` 是一个核心模块,包括消息处理和进程管理的关键功能。 44 | - **主要功能**:包括发送消息(`send`)和生成进程(`spawn`)的函数以及环境变量。 45 | 46 | ## 结论 47 | 48 | 此简明教程向你介绍了 aos 环境中的主要全局变量和功能。 有了这些工具(在手边),你可以创建和管理进程、处理消息,并利用 Lua 的功能在 aos 平台上构建高效且响应迅速的应用程序。 尝试这些功能以更深入地了解以便明白如何将它们集成到你的特定用例中。 在 aos 中玩的开心! 49 | -------------------------------------------------------------------------------- /src/zh/guides/aoconnect/aoconnect.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "Utils" 4 | link: "zh/guides/aos/modules/utils" 5 | next: 6 | text: "安装 aoconnect" 7 | link: "zh/guides/aoconnect/installing-connect" 8 | --- 9 | 10 | # aoconnect 11 | 12 | **aoconnect** 是一个用于同 NodeJS系统或浏览器交互的 Javascript/Typescript 库。 13 | 本节中的指南提供了如何利用 **aoconnect** 的代码片段。所有的代码片段均用 Javascript 编写,但应该很容易转换为 Typescript。 14 | -------------------------------------------------------------------------------- /src/zh/guides/aoconnect/calling-dryrun.md: -------------------------------------------------------------------------------- 1 | # 调用 DryRun 2 | 3 | DryRun 是将消息对象发送到特定进程并获取返回的结果对象的过程,但内存不会被保存,这非常适合创建一个读取消息以返回内存的当前值。例如,一个代币的余额,或者一个转账的结果等。你可以使用 DryRun 来获取输出,而无需发送实际消息 4 | 5 | ```js 6 | import { createDataItemSigner, dryrun } from "@permaweb/aoconnect"; 7 | 8 | const result = await dryrun({ 9 | process: 'PROCESSID', 10 | data: '', 11 | tags: [{name: 'Action', value: 'Balance'}, 12 | anchor: '1234', 13 | ...rest are optional (Id, Owner, etc) 14 | }); 15 | 16 | console.log(result.Messages[0]); 17 | ``` 18 | -------------------------------------------------------------------------------- /src/zh/guides/aoconnect/connecting.md: -------------------------------------------------------------------------------- 1 | # 连接到特定的 ao 节点 2 | 3 | 在你的代码中包含 **aoconnect** 时,你可以连接到特定的 MU(消息单元)和 CU(计算单元),并能够指定一个 Arweave 网关。这可以通过导入 `connect` 函数并从对 `connect` 函数的调用中提取函数来完成。 4 | 5 | 你希望了解在发送你的消息时调用了哪个 MU,以便稍后可以从指定的 MU 进行调试。你也可能想要从特定的 CU 读取结果。事实上,你可能出于某种其他原因偏好某个特定的 MU 和 CU。你可以指定其他的网关,默认的网关是即 :arweave.net 6 | 7 | ## aoconnect 的导入 8 | 9 | ```js 10 | // Here aoconnect will implicitly use the default nodes/units 11 | import { 12 | result, 13 | results, 14 | message, 15 | spawn, 16 | monitor, 17 | unmonitor, 18 | dryrun, 19 | } from "@permaweb/aoconnect"; 20 | ``` 21 | 22 | ## 连接到特定的 MU, CU, 和网关 23 | 24 | ```js 25 | import { connect } from "@permaweb/aoconnect"; 26 | 27 | const { result, results, message, spawn, monitor, unmonitor, dryrun } = connect( 28 | { 29 | MU_URL: "https://mu.ao-testnet.xyz", 30 | CU_URL: "https://cu.ao-testnet.xyz", 31 | GATEWAY_URL: "https://arweave.net", 32 | }, 33 | ); 34 | 35 | // now spawn, message, and result can be used the same way as if they were imported directly 36 | ``` 37 | 38 |
39 | 40 | 连接的这三个参数都是可选的,仅指定 1 个或 2 个,或者不指定都是有效的。例如,你可以仅传入 MU_URL。 41 | 42 | ```js 43 | import { connect } from "@permaweb/aoconnect"; 44 | 45 | const { result, results, message, spawn, monitor, unmonitor, dryrun } = connect( 46 | { 47 | MU_URL: "https://ao-mu-1.onrender.com", 48 | }, 49 | ); 50 | ``` 51 | -------------------------------------------------------------------------------- /src/zh/guides/aoconnect/installing-connect.md: -------------------------------------------------------------------------------- 1 | # 安装 ao connect 2 | 3 | ## 先决条件 4 | 5 | --- 6 | 7 | 为了在你的应用程序中安装 **ao connect**,你必须安装 NodeJS/NPM 18 或更高版本。 8 |
9 | 10 | ## 安装方法 11 | 12 | ### 使用 npm 安装 13 | 14 | ```sh 15 | npm install --save @permaweb/aoconnect 16 | ``` 17 | 18 | ### 使用 yarn 安装 19 | 20 | ```sh 21 | yarn add @permaweb/aoconnect -D 22 | ``` 23 | 24 |
25 | 26 | 安装完成后,你可以在 NodeJS 或 浏览器中使用 **aoconnect**。根据你的项目类型(模块系统),可以按照下面的方式引入 **aoconnect** 27 | 28 | #### ESM(Node & 浏览器)即 type: module 29 | 30 | ```js 31 | import { 32 | result, 33 | results, 34 | message, 35 | spawn, 36 | monitor, 37 | unmonitor, 38 | dryrun, 39 | } from "@permaweb/aoconnect"; 40 | ``` 41 | 42 | #### CJS(Node)即 type: `commonjs` 43 | 44 | ```js 45 | const { 46 | result, 47 | results, 48 | message, 49 | spawn, 50 | monitor, 51 | unmonitor, 52 | dryrun, 53 | } = require("@permaweb/aoconnect"); 54 | ``` 55 | -------------------------------------------------------------------------------- /src/zh/guides/aoconnect/monitoring-cron.md: -------------------------------------------------------------------------------- 1 | # 监控 Cron 2 | 3 | 当使用 cron 消息时,ao 用户需要一种方式开始接收这些消息,通过使用这个监控方法,ao 用户可以启动 cron 消息的订阅服务。设置 cron 标签意味着你的进程将开始在其发件箱中生成 cron 结果,但如果你希望这些结果中的消息通过网络被推送,则需要监控这些结果。 4 | 5 | ```js 6 | import { readFileSync } from "node:fs"; 7 | import { createDataItemSigner, monitor } from "@permaweb/aoconnect"; 8 | 9 | const wallet = JSON.parse( 10 | readFileSync("/path/to/arweave/wallet.json").toString(), 11 | ); 12 | 13 | const result = await monitor({ 14 | process: "process-id", 15 | signer: createDataItemSigner(wallet), 16 | }); 17 | ``` 18 | 19 | 你可以通过调用 unmonitor 来停止监控 20 | 21 | ```js 22 | import { readFileSync } from "node:fs"; 23 | import { createDataItemSigner, unmonitor } from "@permaweb/aoconnect"; 24 | 25 | const wallet = JSON.parse( 26 | readFileSync("/path/to/arweave/wallet.json").toString(), 27 | ); 28 | 29 | const result = await unmonitor({ 30 | process: "process-id", 31 | signer: createDataItemSigner(wallet), 32 | }); 33 | ``` 34 | -------------------------------------------------------------------------------- /src/zh/guides/aoconnect/reading-results.md: -------------------------------------------------------------------------------- 1 | # 从 ao 进程读取结果 2 | 3 | 在 ao 中,消息产生的结果通过计算单元(CU)提供。结果是包含以下字段的 JSON 对象:messages, spawns, output 和 error。 4 | 5 | 结果包含ao系统用来发送消息和生成进程的返回值。一个进程可以发送消息,就像你作为开发者可以通过在结果中返回消息和返回值一样。 6 | 7 | 你可能想要访问一个结果,以显示由你的消息生成的输出。或者,你可能想要看看生成了哪些消息等。你不需要自己取出结果中的消息和返回值并发送它们。它们由消息单元(MU)自动处理。对结果的调用还可以为你提供多个结果的分页列表。 8 | 9 | ## 获取单个结果 10 | 11 | ```js 12 | import { result } from "@permaweb/aoconnect"; 13 | 14 | let { Messages, Spawns, Output, Error } = await result({ 15 | // the arweave TXID of the message 16 | message: "message-id", 17 | // the arweave TXID of the process 18 | process: "process-id", 19 | }); 20 | ``` 21 | 22 | ## 获取一组结果 23 | 24 | ```js 25 | import { results } from "@permaweb/aoconnect"; 26 | 27 | // fetching the first page of results 28 | let resultsOut = await results({ 29 | process: "process-id", 30 | sort: "ASC", 31 | limit: 25, 32 | }); 33 | 34 | // calling more with a cursor 35 | let resultsOut2 = await results({ 36 | process: "process-id", 37 | from: resultsOut.edges?.[resultsOut.edges.length - 1]?.cursor ?? null, 38 | sort: "ASC", 39 | limit: 25, 40 | }); 41 | ``` 42 | -------------------------------------------------------------------------------- /src/zh/guides/aoconnect/sending-messages.md: -------------------------------------------------------------------------------- 1 | # Sending a Message to a Process 2 | 3 | 可以在 [ao Messages](../../concepts/messages.md) 概念中找到关于消息的深入探讨。本指南着重于使用 ao connect 向进程发送消息。 4 | 5 | 发送消息是你的应用与 ao 交互的核心方式。消息是输入到一个进程的。消息有五个部分你可以指定,分别是“目标(target)”,“数据(data)”,“标签(tags)”,“锚点(anchor)”,以及最后的消息“签名(signature)”。 6 | 7 | 请参考你的进程模块的源代码或文档,以了解消息如何在其计算中使用。ao connect 库将解析你在下面的代码中传递的参数,构造一个消息,并发送它。 8 | 9 | ## 在 NodeJS 中发送消息 10 | 11 | ```js 12 | import { readFileSync } from "node:fs"; 13 | 14 | import { message, createDataItemSigner } from "@permaweb/aoconnect"; 15 | 16 | const wallet = JSON.parse( 17 | readFileSync("/path/to/arweave/wallet.json").toString(), 18 | ); 19 | 20 | // The only 2 mandatory parameters here are process and signer 21 | await message({ 22 | /* 23 | The arweave TXID of the process, this will become the "target". 24 | This is the process the message is ultimately sent to. 25 | */ 26 | process: "process-id", 27 | // Tags that the process will use as input. 28 | tags: [ 29 | { name: "Your-Tag-Name-Here", value: "your-tag-value" }, 30 | { name: "Another-Tag", value: "another-value" }, 31 | ], 32 | // A signer function used to build the message "signature" 33 | signer: createDataItemSigner(wallet), 34 | /* 35 | The "data" portion of the message 36 | If not specified a random string will be generated 37 | */ 38 | data: "any data", 39 | }) 40 | .then(console.log) 41 | .catch(console.error); 42 | ``` 43 | 44 | ## 在浏览器中发送消息 45 | 46 | ```js 47 | import { message, createDataItemSigner } from "@permaweb/aoconnect"; 48 | 49 | // The only 2 mandatory parameters here are process and signer 50 | await message({ 51 | /* 52 | The arweave TXID of the process, this will become the "target". 53 | This is the process the message is ultimately sent to. 54 | */ 55 | process: "process-id", 56 | // Tags that the process will use as input. 57 | tags: [ 58 | { name: "Your-Tag-Name-Here", value: "your-tag-value" }, 59 | { name: "Another-Tag", value: "another-value" }, 60 | ], 61 | // A signer function used to build the message "signature" 62 | signer: createDataItemSigner(globalThis.arweaveWallet), 63 | /* 64 | The "data" portion of the message. 65 | If not specified a random string will be generated 66 | */ 67 | data: "any data", 68 | }) 69 | .then(console.log) 70 | .catch(console.error); 71 | ``` 72 | -------------------------------------------------------------------------------- /src/zh/guides/aoconnect/spawning-processes.md: -------------------------------------------------------------------------------- 1 | # 创建一个进程 2 | 3 | 可以在[ao Processes](../../concepts/processes.md) 概念中找到关于进程的深入介绍。本指南聚焦于使用 ao connect 创建一个进程。 4 | 5 | 为了创建一个进程,你必须拥有已经上传到 Arweave 的一个 ao 模块的 TXID。模块是进程的源代码。进程本身是那个源码的实例化。 6 | 7 | 你还必须拥有一个调度单元(Scheduler Unit, SU)的钱包地址。指定的 SU 将作为此进程的调度器。这意味着系统中的所有节点都可以知道它们需要为此进程读写到这个 SU。你可以使用下面的地址。 8 | 9 | ## 调度器的钱包地址 10 | 11 | ```sh 12 | _GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA 13 | ``` 14 | 15 | ## 在 NodeJS 中创建一个进程 16 | 17 | ```js 18 | import { readFileSync } from "node:fs"; 19 | 20 | import { createDataItemSigner, spawn } from "@permaweb/aoconnect"; 21 | 22 | const wallet = JSON.parse( 23 | readFileSync("/path/to/arweave/wallet.json").toString(), 24 | ); 25 | 26 | const processId = await spawn({ 27 | // The Arweave TXID of the ao Module 28 | module: "module TXID", 29 | // The Arweave wallet address of a Scheduler Unit 30 | scheduler: "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA", 31 | // A signer function containing your wallet 32 | signer: createDataItemSigner(wallet), 33 | /* 34 | Refer to a Processes' source code or documentation 35 | for tags that may effect its computation. 36 | */ 37 | tags: [ 38 | { name: "Authority", value: "fcoN_xJeisVsPXA-trzVAuIiqO3ydLQxM-L4XbrQKzY" }, 39 | { name: "Another-Tag", value: "another-value" }, 40 | ], 41 | }); 42 | ``` 43 | 44 | ## 在浏览器中创建一个进程 45 | 46 | ```js 47 | import { createDataItemSigner, spawn } from "@permaweb/ao-sdk"; 48 | 49 | const processId = await spawn({ 50 | // The Arweave TXID of the ao Module 51 | module: "module TXID", 52 | // The Arweave wallet address of a Scheduler Unit 53 | scheduler: "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA", 54 | // A signer function containing your wallet 55 | signer: createDataItemSigner(globalThis.arweaveWallet), 56 | /* 57 | Refer to a Processes' source code or documentation 58 | for tags that may effect its computation. 59 | */ 60 | tags: [ 61 | { name: "Authority", value: "fcoN_xJeisVsPXA-trzVAuIiqO3ydLQxM-L4XbrQKzY" }, 62 | { name: "Another-Tag", value: "another-value" }, 63 | ], 64 | }); 65 | ``` 66 | -------------------------------------------------------------------------------- /src/zh/guides/aos/aolink-compute-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/guides/aos/aolink-compute-example.png -------------------------------------------------------------------------------- /src/zh/guides/aos/aolink-list-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/guides/aos/aolink-list-example.png -------------------------------------------------------------------------------- /src/zh/guides/aos/aolink-message-details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/guides/aos/aolink-message-details.png -------------------------------------------------------------------------------- /src/zh/guides/aos/aolink-process-details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/guides/aos/aolink-process-details.png -------------------------------------------------------------------------------- /src/zh/guides/aos/aolink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/guides/aos/aolink.png -------------------------------------------------------------------------------- /src/zh/guides/aos/blueprints/chatroom.md: -------------------------------------------------------------------------------- 1 | # 聊天室蓝图 (Chatroom Blueprint) 2 | 3 | 聊天室蓝图是预先设计好的模板,可帮助你在 ao 中快速构建聊天室。蓝图是入门的绝佳方式,并且可以根据你的需求进行定制。 4 | 5 | ## 解析聊天室蓝图 6 | 7 | - **Members**: `Members`数组用于存储已注册聊天室的用户。 8 | 9 | - **Register Handler**: `register` handler 用于进程加入聊天室。当进程发送带有标签 `Action = "Register"` 的消息时,handler会将进程添加到 `Members` 数组中,并向进程发送一条消息确认注册。 10 | 11 | - **Broadcast Handler**: `broadcast` handler支持进程向聊天室的所有成员发送消息。当进程发送带有标签 Action = "Broadcast" 的消息时,handler会将该消息发送给聊天室的所有成员。 12 | 13 | ### 如何使用: 14 | 15 | 1. 打开文本编辑器。 16 | 2. 打开终端。 17 | 3. 启动你的 `aos` 进程。 18 | 4. 输入 `.load-blueprint chatroom` 19 | 20 | ### 验证蓝图是否已加载: 21 | 22 | 输入 `Handlers.list` 查看新加载的 Handlers。 23 | 24 | ## 聊天室蓝图中包含的内容: 25 | 26 | ```lua 27 | Members = Members or {} 28 | 29 | Handlers.add( 30 | "register", 31 | Handlers.utils.hasMatchingTag("Action", "Register"), 32 | function (msg) 33 | table.insert(Members, msg.From) 34 | Handlers.utils.reply("registered")(msg) 35 | end 36 | ) 37 | 38 | Handlers.add( 39 | "broadcast", 40 | Handlers.utils.hasMatchingTag("Action", "Broadcast"), 41 | function (msg) 42 | for _, recipient in ipairs(Members) do 43 | ao.send({Target = recipient, Data = msg.Data}) 44 | end 45 | Handlers.utils.reply("Broadcasted.")(msg) 46 | end 47 | ) 48 | ``` 49 | -------------------------------------------------------------------------------- /src/zh/guides/aos/blueprints/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "创建代币" 4 | link: "../token" 5 | next: 6 | text: "聊天室蓝图" 7 | link: "./chatroom" 8 | --- 9 | 10 | # 蓝图 Blueprints 11 | 12 | 蓝图是预先设计好的模板,可帮助你在 ao 中快速构建。蓝图是入门的绝佳方式,并且可以根据你的需求进行定制。 13 | 14 | ## 可用的蓝图 15 | 16 | - [聊天室蓝图](chatroom) 17 | 18 | - [CRED 蓝图](cred-utils) 19 | 20 | - [质押蓝图](staking) 21 | 22 | - [Token 蓝图](token) 23 | 24 | - [投票蓝图](voting) 25 | -------------------------------------------------------------------------------- /src/zh/guides/aos/blueprints/voting.md: -------------------------------------------------------------------------------- 1 | # 投票蓝图 (Voting Blueprint) 2 | 3 | 投票蓝图是预先设计好的模板,可帮助你在 ao 中快速构建投票系统。蓝图是入门的绝佳方式,并且可以根据你的需求进行定制。 4 | 5 | ## 前提条件 6 | 7 | 投票蓝图要求先加载 [Token 蓝图](./token.md) 8 | 9 | ## 解析投票蓝图 10 | 11 | - **Balances**: The `Balances` 数组用于存储参与者的代币余额。 12 | 13 | - **Votes**: `Votes` 数组用于存储投票参与者地址。 14 | 15 | - **Vote Action Handler**: `vote` handler 用户进程进行投票。当进程发送带有标记 `Action = "Vote"` 的消息时,handler 会将投票信息添加到`Votes`数组中,并向流程发送消息,确认投票。 16 | 17 | - **Finalization Handler**: `finalize` handler支持进程完成投票过程。当进程发送带有标签 `Action = "Finalize"`的消息时,Handler会处理投票信息并完成投票过程。 18 | 19 | ### 如何使用: 20 | 21 | 1. 打开你的文本编辑器。 22 | 2. 打开终端。 23 | 3. 启动你的`aos`进程. 24 | 4. 输入`.load-blueprint voting` 25 | 26 | ### 验证蓝图是否已加载: 27 | 28 | 输入 `Handlers.list` 查看新加载的 handlers。 29 | 30 | ## 投票蓝图包含的内容: 31 | 32 | ```lua 33 | Balances = Balances or {} 34 | Votes = Votes or {} 35 | 36 | -- Vote Action Handler 37 | Handlers.vote = function(msg) 38 | local quantity = Stakers[msg.From].amount 39 | local target = msg.Tags.Target 40 | local side = msg.Tags.Side 41 | local deadline = tonumber(msg['Block-Height']) + tonumber(msg.Tags.Deadline) 42 | assert(quantity > 0, "No staked tokens to vote") 43 | Votes[target] = Votes[target] or { yay = 0, nay = 0, deadline = deadline } 44 | Votes[target][side] = Votes[target][side] + quantity 45 | end 46 | 47 | -- Finalization Handler 48 | local finalizationHandler = function(msg) 49 | local currentHeight = tonumber(msg['Block-Height']) 50 | -- Process voting 51 | for target, voteInfo in pairs(Votes) do 52 | if currentHeight >= voteInfo.deadline then 53 | if voteInfo.yay > voteInfo.nay then 54 | print("Handle Vote") 55 | end 56 | -- Clear the vote record after processing 57 | Votes[target] = nil 58 | end 59 | end 60 | end 61 | 62 | -- wrap function to continue handler flow 63 | local function continue(fn) 64 | return function (msg) 65 | local result = fn(msg) 66 | if (result) == -1 then 67 | return 1 68 | end 69 | return result 70 | end 71 | end 72 | 73 | Handlers.add("vote", 74 | continue(Handlers.utils.hasMatchingTag("Action", "Vote")), Handlers.vote) 75 | -- Finalization handler should be called for every message 76 | Handlers.add("finalize", function (msg) return -1 end, finalizationHandler) 77 | ``` 78 | -------------------------------------------------------------------------------- /src/zh/guides/aos/cli.md: -------------------------------------------------------------------------------- 1 | # CLI 2 | 3 | 这里有一些命令参数来与 aos 进行交互: 4 | 5 | - [name] - 使用你的钱包地址创建或者加载一个进程 6 | - --load [file] - 加载一个文件,可以多次调用 7 | - --cron [interval] - 只在创建进程的时候使用 8 | - --wallet [walletfile] - 使用一个指定的钱包 9 | 10 | ## 使用 aos 管理多进程 11 | 12 | ```sh 13 | aos 14 | ``` 15 | 16 | 使用默认`default`名称创建或者连接到进程 17 | 18 | ```sh 19 | aos chatroom 20 | ``` 21 | 22 | 使用 `chatroom` 创建或者连接进程 23 | 24 | ```sh 25 | aos treasureRoom 26 | ``` 27 | 28 | 使用 `treasureRoom` 创建或者连接进程 29 | 30 | ## load 标志 31 | 32 | ```sh 33 | aos treasureRoom --load greeting.lua --load treasure.lua --load puzzle.lua 34 | ``` 35 | 36 | 可以使用 `load` 标志来加载一个或者多个代码文件到我的进程 37 | 38 | ## CRON 标志 39 | 40 | 如果你想让进程创建定时响应函数,需要在创建进程是调用 `cron` 标志 41 | 42 | ```sh 43 | aos chatroom --cron 2-minutes 44 | ``` 45 | 46 | ## Tag 标志 47 | 48 | 使用 tag 标志,你可以为进程创建用户标识。(例如将它们用作静态环境变量): 49 | 50 | ```sh 51 | aos chatroom --tag-name Chat-Theme --tag-value Dark --tag-name Chat-Name --tag-value Mychat 52 | ``` 53 | 54 | 上面的命令会在你创建进程的时候添加用户定义标识 55 | 56 | ```ts 57 | // process data item tags 58 | [ 59 | ... 60 | { name: "Chat-Theme", value: "Dark" }, 61 | { name: "Chat-Name", value: "Mychat" } 62 | ... 63 | ] 64 | ``` 65 | -------------------------------------------------------------------------------- /src/zh/guides/aos/editor.md: -------------------------------------------------------------------------------- 1 | # 编辑器初始化 2 | 3 | 记住所有的内建函数和工具集方法是非常困难的。为了改善你的开发体验,我们推荐将 [Lua Language Server](https://luals.github.io) 扩展添加到您的编辑器,并添加 [ao addon](https://github.com/martonlederer/ao-definitions) 插件。它支持所有的 aos [内置模块](../aos/modules/index)和[全局变量](../aos/intro#globals)。 4 | 5 | ## VS Code 6 | 7 | 安装 [sumneko.lua](https://marketplace.visualstudio.com/items?itemName=sumneko.lua) 扩展: 8 | 9 | 1. 在扩展市场中搜索 sumneko 的“Lua”插件 10 | 2. 下载并且安装插件 11 | 3. 使用 `Shift + Command + P` (Mac) / `Ctrl + Shift + P` (Windows/Linux) 打开 VS Code 命令面板,然后运行以下命令: 12 | 13 | ``` 14 | > Lua: Open Addon Manager 15 | ``` 16 | 17 | 4. 在插件管理器中搜索“ao”,选中第一个结果,单击“启用”完成自动安装。 18 | 19 | ## 其他编辑器 20 | 21 | 1. 验证你的编辑器是否支持[语言服务器协议](https://microsoft.github.io/language-server-protocol/implementors/tools/) 22 | 2. 安装[luals.github.io](https://luals.github.io/#install)中的 Lua 语言服务 23 | 3. 安装 "ao" 语言扩展服务 24 | -------------------------------------------------------------------------------- /src/zh/guides/aos/faq.md: -------------------------------------------------------------------------------- 1 | # FAQ 2 | 3 | ## 所有权 (Ownership) 4 | 5 |
6 | 进程的所有权 7 | 8 | 使用 aos 控制台创建一个新的进程,你的钱包地址就是进程的所有者。**aos** 使用 **Owner** 全局变量来标记进程的所有者。如果你想转移进程的所有权,或者将它变成无人可以控制的进程,你可以重定义 **Owner** 变量将它给其他钱包地址,或者设置为 **nil**。 9 | 10 |
11 | 12 | ## JSON 13 | 14 |
15 | 将数据编码为 json 格式 16 | 17 | 当你向其他进程或者外部服务发送数据,你可能希望使用 JSON 作为数据编码格式。使用 lua 的 json 模块,可以对 lua Table 中的值进行 **encode** 和 **decode** 操作。 18 | 19 | ```lua 20 | Send({Target = Router, Data = require('json').encode({hello = "world"})}) 21 | ``` 22 | 23 |
24 | 25 | ## Send 和 ao.send 对比 26 | 27 |
28 | 什么时候使用 Send 或 ao.send 29 | 30 | 这两个方法都会将消息发送到一个进程,区别是 `ao.send` 可以返回消息,以便于记录日志或者进行故障排查。`Send` 函数通常在控制台中使用,更方便访问。在 `handlers` 中更推荐使用 `ao.send`,但他们在 `aos`中是可以相互替换的。 31 | 32 |
33 | -------------------------------------------------------------------------------- /src/zh/guides/aos/inbox-and-handlers.md: -------------------------------------------------------------------------------- 1 | # 理解收件箱(Inbox) 2 | 3 | 在 aos 中,进程通过 handlers 获取消息并且执行。未处理的消息将进入进程的收件箱(Inbox) 4 | 5 | ## 什么是 Handlers? 6 | 7 | Handler 是一个函数,接收并且处理进程消息。它处理这些消息是通过将消息作为参数来进行的。 8 | 9 | ```lua 10 | function main(Message, ao) 11 | ...dostuff 12 | return { 13 | Output = ..., 14 | Messages = {}, 15 | Spawns = {} 16 | } 17 | 18 | end 19 | ``` 20 | 21 | `main` 函数返回一个 lua Table,包含 `Output, Message, Spawns` 或者 `Error`。在 aos 中你可以给进程添加 `Handler` 方法来处理逻辑,`Handler` 中有三个参数: 22 | 23 | 1. Handler 名字 24 | 2. 匹配函数 25 | 3. 处理函数 26 | 27 | ```lua 28 | Handlers.add("name", 29 | function (Msg) 30 | -- Does this message match (return true or false) 31 | return Msg.Action == "Register" 32 | end, 33 | function (Msg) 34 | print("Registered User.") 35 | table.insert(Members, Msg.From) 36 | ao.send({Target = Msg.From, Data = "Registered."}) 37 | end 38 | ) 39 | ``` 40 | 41 | ## 关于收件箱 42 | 43 | 收件箱会存储尚未处理的消息,它们在这里等待被处理。一旦消息被处理,它就会被从收件箱中移除。 44 | 45 | > 示例:将收件箱视为语音邮件。 正如未接听的电话会被转至语音信箱,让你稍后处理一样,你的进程不立即处理的消息都会进入收件箱。未处理的消息将被存储在这里,直到你处理他们。 46 | 47 | ## 总结 48 | 49 | 一开始似乎所有邮件都会进入你的收件箱,如果它们在处理后就被删除,这可能会令人疑惑。 语音邮件的类比应该可以解释这种设计:就像你接听的电话不会转到语音邮件一样,你处理过的消息也不会出现在收件箱中。 这说明了收件箱和 Handler 的功能。 50 | -------------------------------------------------------------------------------- /src/zh/guides/aos/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "指南" 4 | link: "../" 5 | next: 6 | text: "概览" 7 | link: "zh/guides/aos/intro" 8 | --- 9 | 10 | # aos 11 | 12 | `ao` 是一台分布式计算的并行计算机,`aos` 是该计算机上的操作系统。 13 | 14 | 使用 `aos` 你可以与进程(processes)交互,并且非常简单地编写进程代码。 你所需要的只是一个终端和一个编辑器。 15 | 16 | `aos` 选择 [lua](../../concepts/lua.md) 作为开发语言,这是一种健壮的动态语言,使用起来非常有趣。 17 | 18 | 如果你还没有这么做,请花 15 分钟浏览我们的[教程](../../tutorials/index)。 19 | 20 | ## 深入了解 `aos` 21 | 22 | - [aos 概览](./intro) 23 | - [安装](./installing) 24 | - [`aos` CLI工具](./cli) 25 | - [自定义提示符(prompt)](./prompt) 26 | - [构建一个 Ping-Pong 服务](./pingpong) 27 | 28 | ## 开发者指南 29 | 30 | - [编辑器初始化](editor) 31 | - [使用 ao.link 进行故障排除](troubleshooting) 32 | - [理解收件箱(Inbox)](inbox-and-handlers) 33 | - [常见问题](faq) 34 | 35 | ### [**模块**](modules/index) 36 | 37 | - [JSON](modules/json) 38 | - [`ao`](modules/ao) 39 | - [Base64](modules/base64) 40 | - [Pretty](modules/pretty) 41 | - [Utils](modules/utils) 42 | -------------------------------------------------------------------------------- /src/zh/guides/aos/installing.md: -------------------------------------------------------------------------------- 1 | # 安装 aos 2 | 3 | 安装 aos 只需要 `NodeJS` - https://nodejs.org 4 | 5 | > 注意: 如果你使用的是 Windows 系统,最后使用 WSL 命令行. 6 | 7 | ```sh 8 | npm i -g https://get_ao.g8way.io 9 | ``` 10 | 11 | 安装完之后你可以输入 `aos` 来运行系统 12 | -------------------------------------------------------------------------------- /src/zh/guides/aos/intro.md: -------------------------------------------------------------------------------- 1 | # 概览 2 | 3 | aos 使用了与众不同的方式构建进程与合约,ao 计算机是一个去中心的计算机网络,可以在任何地方进行计算,aos 是一个统一的交互终端。 你可以使用 aos 作为你的个人操作系统、构建 ao 进程的开发环境、以及创建您的机器人军团。 4 | 5 | 让我们来回顾一些基本指令。 6 | 7 | ## 变量 8 | 9 | 如果你想通过控制台显示变量的内容,可以直接输入变量的名称 10 | 11 | ```lua 12 | Name 13 | ``` 14 | 15 | ## 收件箱 (Inbox) 16 | 17 | `收件箱 (Inbox)` 是你进程收到的消息集合。 18 | 19 | ```lua 20 | Inbox[1] 21 | ``` 22 | 23 | 如果您想查看消息个数,在 `Inbox` 前面加入 `#` 符号 24 | 25 | ```lua 26 | #Inbox 27 | ``` 28 | 29 | 查看收件箱的消息个数是个非常常见的功能,为了更简单,您可以创建一个函数,返回收件箱的消息个数并显示出来。 30 | 31 | 使用 `.editor` 或者 `.load file` 来将这个函数加载到您的进程。 32 | 33 | ```lua 34 | function Prompt() 35 | return "Inbox: " .. #Inbox .. " > " 36 | end 37 | ``` 38 | 39 | **预期的结果:** 40 | 41 | ```sh 42 | undefined 43 | Inbox: 2 > 44 | ``` 45 | 46 | 您的 Prompt 函数已经可以显示收件箱中的消息数量。 47 | 48 | ## 全局定义 49 | 50 | aos 中定义了一些全局变量、函数可以让开发变得更加直观。 51 | 52 | | 名称 | 描述 | 类型 | 53 | | ---------------------- | ---------------------------------------------------------------------------- | ------------ | 54 | | Inbox | 这是一个 lua 表,存储所有接收到的消息 | Table(Array) | 55 | | Send(Message) | 这是交互环境中使用的全局函数,可以向其他进程发送消息 | function | 56 | | Spawn(Module, Message) | 这是 aos 中的全局函数,可以创建一个进程 | 57 | | Name | 初始化您的进程名称 | string | 58 | | Owner | 这个字符串标识了进程的所有者,如果修改这个字段,可能会影响您与进程交互的能力 | string | 59 | | Handlers | 一个 lua 表,可以让您创建消息的处理函数 | table | 60 | | Dump | 接受 lua 中的表(Table)类型,并打印用户友好的数据内容 | function | 61 | | Utils | 一个功能实用库,具有map、reduce、filter等功能 | module | 62 | | ao | 这是用于发送消息和生成进程的核心函数库 | module | 63 | 64 | ## 模块 65 | 66 | 在aos中,有一些内置的 lua 模块可以使用,这些模块可以通过“require”函数引用。 67 | 68 | | 名称 | 描述 | 69 | | ------- | ------------------------------------------ | 70 | | json | json 数据的编码和解码 | 71 | | ao | ao 核心函数库,包括 send 、 spawn | 72 | | .base64 | base64 数据的编解码 | 73 | | .pretty | 格式化输出数据,使用 tprint 函数格式化数据 | 74 | | .utils | 一个实用工具库 | 75 | -------------------------------------------------------------------------------- /src/zh/guides/aos/load.md: -------------------------------------------------------------------------------- 1 | # .load 命令 2 | 3 | 这个功能可以让你加载本地环境中的 lua 代码,给 aos 的开发者带来更好的开发体验。 4 | 5 | 在创建处理程序时你可能有大量代码,希望使用 vscode 等集成开发环境来管理它们。 你还可以安装 lua 扩展插件来做一些语法检查。 6 | 7 | 那么如何将本地的 lua 代码发布到你的 ao 进程中呢? 这就是“.load”命令发挥作用的地方。 8 | 9 | hello.lua 10 | 11 | ```lua 12 | Handlers.add( 13 | "ping", 14 | Handlers.utils.hasMatchingData("ping"), 15 | Handlers.utils.reply("pong") 16 | ) 17 | ``` 18 | 19 | aos 脚本输入 20 | 21 | ```sh 22 | .load hello.lua 23 | ``` 24 | 25 | 十分简单! 🐶 26 | -------------------------------------------------------------------------------- /src/zh/guides/aos/modules/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "质押蓝图" 4 | link: "../blueprints/staking" 5 | next: 6 | text: "JSON" 7 | link: "./json" 8 | --- 9 | 10 | # 模块 11 | 12 | aos 内置模块文档。 13 | 14 | - [JSON](./json) 15 | - [ao](./ao) 16 | - [Base64](./base64) 17 | - [Pretty](./pretty) 18 | - [Utils](./utils) 19 | -------------------------------------------------------------------------------- /src/zh/guides/aos/modules/json.md: -------------------------------------------------------------------------------- 1 | # JSON 2 | 3 | JSON 模块支持你使用 JavaScript 对象表示法对对象进行编码和解码。 4 | 5 | ### 示例用法 6 | 7 | ```lua 8 | local json = require("json") 9 | 10 | json.encode({ 11 | a_string = "This is a string", 12 | nums = { 1, 2, 3 } 13 | }) 14 | ``` 15 | 16 | ## 模块函数 17 | 18 | ### `encode()` 19 | 20 | 将 Lua 对象转换为 JSON 字符串。 21 | 22 | - **参数:** 23 | - `val`: `{any}` 需要格式化的对象 24 | - **返回值:** 对象的 JSON 格式字符串 25 | 26 | #### 示例 27 | 28 | ```lua 29 | --[[ 30 | prints: 31 | "[{"name":"John Doe","age":23},{"name":"Bruce Wayne",age:34}]" 32 | ]]-- 33 | print(json.encode({ 34 | { name = "John Doe", age = 23 }, 35 | { name = "Bruce Wayne", age = 34 } 36 | })) 37 | 38 | -- prints "false" 39 | print(json.encode(false)) 40 | ``` 41 | 42 | ### `decode()` 43 | 44 | 此函数用于解析 JSON 字符串并转换为 Lua 对象。 45 | 46 | - **参数:** 47 | - `val`: `{any}` 待解码的 JSON 字符串 48 | - **返回值:** JSON 字符串对应的 Lua 对象(对于无效的 JSON 字符串会抛出错误) 49 | 50 | #### 示例 51 | 52 | ```lua 53 | --[[ 54 | creates the following table: 55 | { hello = "world" } 56 | ]]-- 57 | json.decode('{ "hello": "world" }') 58 | 59 | -- creates a boolean with true value 60 | json.decode("true") 61 | ``` 62 | -------------------------------------------------------------------------------- /src/zh/guides/aos/modules/pretty.md: -------------------------------------------------------------------------------- 1 | # Pretty 模块 2 | 3 | 这个模块的作用是将输出格式化、易于理解和阅读 4 | 5 | ## 模块函数 6 | 7 | ### `tprint()` 8 | 9 | 将 table 结构转换为格式化的字符串 10 | 11 | - **Parameters:** 12 | - `tbl`: `{table}` 需要格式化 table 结构 13 | - `indent`: `{number}` 可选参数,表格每一层的缩进量 14 | - **Returns:** 转为字符串格式的表格结构 15 | 16 | #### 示例 17 | 18 | ```lua 19 | local pretty = require(".pretty") 20 | 21 | local formatted = pretty.tprint({ 22 | name = "John Doe", 23 | age = 22, 24 | friends = { "Maria", "Victor" } 25 | }, 2) 26 | 27 | -- prints the formatted table structure 28 | print(formatted) 29 | ``` 30 | -------------------------------------------------------------------------------- /src/zh/guides/aos/ownership.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/guides/aos/ownership.md -------------------------------------------------------------------------------- /src/zh/guides/aos/pingpong.md: -------------------------------------------------------------------------------- 1 | # 创建一个 Pingpong 进程 2 | 3 | 这个教程将指导你在 aos 中创建一个简单的“ping-pong”过程。 在此过程中,每当进程收到带有数据“ping”的消息时,它都会自动回复“pong”。 这是 aos 中消息处理和进程间交互的基本示例。 4 | 5 | ## 步骤 1: 打开 `aos` CLI 6 | 7 | - 首先打开命令行界面并输入 `aos` 进入 aos 环境。 8 | 9 | ## 步骤 2: 打开内置编辑器 10 | 11 | - 在 aos CLI 中输入“.editor”打开内置文本编辑器。 你将在此处编写 pingpong 处理程序代码。 12 | 13 | ## 步骤 3: 添加 Pingpong Handler 14 | 15 | - 在编辑器中,输入以下 Lua 代码来添加 pingpong 模式的处理程序: 16 | 17 | ```lua 18 | Handlers.add( 19 | "pingpong", 20 | Handlers.utils.hasMatchingData("ping"), 21 | Handlers.utils.reply("pong") 22 | ) 23 | ``` 24 | 25 | - 这个 lua 脚本做了三个操作: 26 | 1. 添加一个新的名为"pingpong"的 handler。 27 | 2. 它使用 `Handlers.utils.hasMatchingData("ping")` 来检查收到的消息中是否有 "ping" 字段. 28 | 3. 如果消息中包含 "ping", `Handlers.utils.reply("pong")` 会自动返回 "pong" 的消息. 29 | 30 | ## 步骤 4: 退出编辑器 31 | 32 | - 在编写完代码后,输入 `.done` 并输入 Enter 来退出编辑器并运行脚本。 33 | 34 | ## 步骤 5: 测试 Pingpong 进程 35 | 36 | - 为了测试进程,需要向进程发送带有 `ping` 的消息。你可以在 CLI 中使用下面的命令: 37 | ```lua 38 | Send({ Target = ao.id, Data = "ping" }) 39 | ``` 40 | - 进程将在收件箱 `Inbox` 中收到带有 "pong" 的恢复消息。 41 | 42 | ## 步骤 6: 查看收件箱 Inbox 43 | 44 | - 查看你的收件箱中是否有 "ping" 的消息,并确认是否发出了 “pong” 的回复消息。 45 | 46 | ```lua 47 | Inbox[#Inbox].Data 48 | ``` 49 | 50 | ## 步骤 7: 测试和观察 51 | 52 | - 发送不同的消息进行测试,并观察“ping”消息如何触发“pong”响应。 53 | 54 | ## 步骤 8: 保存进程 (可选) 55 | 56 | - 如果你想在将来使用此过程,请将处理程序代码保存在Lua文件中以便于加载 57 | 58 | 进入 aos 会话。 59 | 60 | ::: info 61 | 62 | **额外提示:** 63 | 64 | - **处理程序效率**: 简单的处理函数是关键. 确保它的执行效率并且只在正确的时候触发。 65 | 66 | ::: 67 | 68 | ## 结论 69 | 70 | 恭喜! 您已经在 aos 中创建了一个基础的"ping-pong"进程。 本教程给理解 在aos 环境中的消息处理和进程交互奠定了基础。 随着您对这些概念越来越熟悉,您可以扩展到更复杂的流程和交互,探索 aos 的全部潜力。 71 | -------------------------------------------------------------------------------- /src/zh/guides/aos/prompt.md: -------------------------------------------------------------------------------- 1 | # aos 中的自定义提示符(Prompt) 2 | 3 | ## 步骤 1: 启动 aos 并打开编辑器 4 | 5 | - 登录 aos 命令行 6 | - 输入 `.editor` 打开内置编辑器 7 | 8 | ## 步骤 2: 编写自定义提示符函数 9 | 10 | - 在编辑器中,定义你的用户提示符函数,例如: 11 | ```lua 12 | function Prompt() 13 | return "YourName@aos> " 14 | end 15 | ``` 16 | 将 `"YourName@aos> "` 定义为你喜欢的文本。 17 | 18 | ## 步骤 3: 退出并运行你的代码 19 | 20 | - 输入 `.done` 并输入 Enter 来退出编辑器并执行代码 21 | - 你的 aos 将显示新的自定义提示符 22 | 23 | ## 步骤 4: 保存以供将来使用 (可选) 24 | 25 | - 如果你希望在将来的 aos 会话中使用这个提示符,请将脚本保存在 Lua 文件中。 26 | - 在后续会话中,加载此脚本以应用自定义提示。 27 | 28 | ## 更多提示符功能 29 | 30 | 自定义提示可以带来很多实用性和创造力。 你可以在提示符中执行以下操作: 31 | 32 | - 创建一个函数来跟踪收件箱中的未读消息数量: 33 | 34 | ```lua 35 | --Example: 36 | function Prompt() 37 | return "YourName Inbox: [" .. #Inbox .. "] > " 38 | end 39 | ``` 40 | 41 | - 跟踪你聊天室进程中的成员数量。 42 | - 跟踪你进程地址持有的指定Token的数量。 43 | 44 | ## 结论 45 | 46 | 现在你已经了解了如何使用自定义提示符,现在你已经迈出了优化 ao 开发体验的关键一步。 47 | -------------------------------------------------------------------------------- /src/zh/guides/aos/tables-and-json.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/guides/aos/tables-and-json.md -------------------------------------------------------------------------------- /src/zh/guides/aos/token1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/guides/aos/token1.png -------------------------------------------------------------------------------- /src/zh/guides/aos/token2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/guides/aos/token2.png -------------------------------------------------------------------------------- /src/zh/guides/aos/troubleshooting.md: -------------------------------------------------------------------------------- 1 | # 使用 ao.link 进行故障排除 2 | 3 | 使用去中心计算机和网络,你需要能够排除故障,而不仅仅是你自己的代码。你需要跟踪进程和消息,这就是 [https://ao.link](https://ao.link) 工具箱的必要之处。 4 | 5 | ![ao.link homepage displaying ao network stats](aolink.png) 6 | 7 | ## 分析 8 | 9 | AOLink 4种分析指标: 10 | 11 | - 消息总数 (Total Messages) 12 | - 用户总数 (Total Users) 13 | - 进程总数 (Total Processes) 14 | - 模块总数 (Total Modules) 15 | 16 | 这些指标可以让你快速了解 ao 网络的总体运行状况。 17 | 18 | ## 事件 (Events) 19 | 20 | 下面是 ao 计算机里的最新事件。 它们是一个已执行的消息列表。 这些事件可以是任何 ao 数据协议类型。 你可以单击进程 ID 或消息 ID 来获取详细信息。 21 | 22 | ![ao.link list of events](aolink-list-example.png) 23 | 24 | ### 消息细节 25 | 26 | ![ao.link message details displaying the message processed](aolink-message-details.png) 27 | 28 | 消息细节包括以下关键信息: 29 | 30 | - From 31 | - To 32 | - Block Height 33 | - Created 34 | - Tags 35 | - Data 36 | - Result Type 37 | - Data 38 | 39 | 如果你想进一步排除故障和调试,你可以通过单击 “Compute” 来查看 CU(计算单元)的结果。 40 | 41 | ![ao.link compute result example for debugging](aolink-compute-example.png) 42 | 43 | ### 进程细节 44 | 45 | ![ao.link displaying a process in details](aolink-process-details.png) 46 | 47 | 进程细节提供进程的详细信息,在标签(Tag)中查看该进程的实例化所使用的各个模块,这非常有用 48 | 左侧的图表显示的是进程的交互图。 49 | 在本例中,这是 DevChat,你可以看到通过注册和广播消息进行交互的所有进程。 50 | 这个例子是 DevChat 进程的实例,你可以看到通过注册和消息广播与之交互的所有进程 51 | 52 | ## 更多问题? 53 | 54 | 请随时访问 DataOS 的 Discord 社区。 55 | https://discord.gg/4kF9HKZ4Wu 56 | 57 | ## 总结 58 | 59 | AOLink 是一款很好的工具,用于追踪 ao 计算机中的事件,请试一试。此外 permaweb 上还有另一个扫描工具:https://ao_marton.g8way.io/ - 试一试吧! 60 | -------------------------------------------------------------------------------- /src/zh/guides/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "扩建竞技场" 4 | link: "zh/tutorials/bots-and-games/build-game" 5 | next: 6 | text: "aos" 7 | link: "./aos/index" 8 | --- 9 | 10 | # 指南 11 | 12 | 本指南旨在帮助你导览 **ao**和 **aos**,可以帮助你构建聊天室、去中心自治机器人等程序。 13 | 14 | ## 章节列表 15 | 16 | - [aos](aos/index) 17 | - [aoconnect](aoconnect/aoconnect) 18 | -------------------------------------------------------------------------------- /src/zh/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | # https://vitepress.dev/reference/default-theme-home-page 3 | layout: home 4 | 5 | hero: 6 | name: "" 7 | text: "超级并行计算机" 8 | tagline: "任何规模的去中心化计算。Arweave 上独有。" 9 | actions: 10 | - theme: brand 11 | text: 即刻体验! 12 | link: /zh/welcome/index 13 | 14 | features: 15 | - title: 教程 16 | details: 手把手教你入门 ao 17 | link: /zh/tutorials/index 18 | 19 | - title: 指南 20 | details: 各个功能部件的详细说明 21 | link: /zh/guides/index 22 | 23 | - title: 概念 24 | details: 搞懂 ao 网络背后的运行原理 25 | link: /zh/concepts/index 26 | --- 27 | -------------------------------------------------------------------------------- /src/zh/llms-explanation.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: doc 3 | title: LLMs 文件文档 4 | --- 5 | 6 | # LLMs 文件文档 7 | 8 | ## **[llms.txt](/zh/llms.txt)**: 9 | 10 | - ao 生态系统的结构化概述。 11 | - 适用于导航文档或回答一般问题的 AI 工具。 12 | - 适合具有网络搜索功能的 AI 代理。 13 | 14 | ## **[llms-full.txt](/zh/llms-full.txt)**: 15 | 16 | - 完整的技术文档。 17 | - 为深入分析、故障排除或聊天机器人集成而设计。 18 | - 为复杂查询提供详尽细节。 19 | 20 | ::: info 21 | llms-full.txt 文件仅包含来自参考资料和发行说明的内容,测试表明这种专注的方法在 AI 模型中表现更好。 22 | ::: 23 | -------------------------------------------------------------------------------- /src/zh/references/community.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "ao 编辑器设置" 4 | link: "/zh/references/editor-setup.md" 5 | --- 6 | 7 | # 社区 8 | 9 | [Autonomous Finance](https://www.autonomous.finance/) 10 | 11 | - Autonomous Finance 是一个专注于 ao 网络内金融基础设施复杂性的研究和技术实体。 12 | 13 | [BetterIdea](https://betteridea.dev/) 14 | 15 | - 使用 BetterIDEa 构建更快、更智能、更高效的 AO 开发终极本地 Web IDE。 16 | 17 | [Orbit](https://www.0rbit.co/) 18 | 19 | - 0rbit 通过利用 ao 和 0rbit 节点的强大功能,将任何来自网络的数据提供给 ao 进程。用户向 0rbit ao 发送消息,0rbit 节点获取数据,然后用户进程接收数据。 20 | -------------------------------------------------------------------------------- /src/zh/references/cron.md: -------------------------------------------------------------------------------- 1 | # 定时消息(Cron Messages) 2 | 3 | ao 具有在指定时间间隔生成消息的能力,这个时间间隔可以是秒、分钟、小时或区块。有一个监控进程会自动解释和运行(eval)这些消息,然后通知 Process 根据时间处理(eval)这些消息。此时会产生一个实时进程,它可以与完整的 ao 网络或外部网络中的预言机进行通信。 4 | 5 | ## 在进程中设置定时消息(Cron Messages) 6 | 7 | 创建这些定时消息(Cron Messages)的最简单方法,是在 aos 控制台中生成一个新进程并定义时间间隔。 8 | 9 | ```sh 10 | aos [myProcess] --cron 5-minutes 11 | ``` 12 | 13 | 在生成新进程时,你可以在命令行中传递一个 cron 参数,后面加上你希望 cron 触发的时间间隔。如果你希望消息实时触发,你必须启动一个监控事件。在 aos 中,你只需调用`.monitor`,它会在 `mu` 上启动一个工作进程,从 `cu` 触发定时(cron) 消息。然后你的进程将会每隔 `x-间隔` 收到定时(cron)消息。 14 | 15 | ```lua 16 | .monitor 17 | ``` 18 | 19 | 如果你希望停止触发定时(cron) 消息,只需调用 `.unmonitor`,这会停止触发过程。但下次你发送消息时,生成的定时(cron) 消息仍将创建和处理进程。 20 | 21 | ## 处理定时消息 22 | 23 | 每条定时(cron) 消息都有一个值为 `Cron` 的 `Action` 标签。根据定义,[处理器](handlers.md)在每次收到定时(cron) 消息时,都会自动执行特定任务。 24 | 25 | ```lua 26 | Handlers.add( 27 | "CronTick", -- handler 的名称 28 | Handlers.utils.hasMatchingTag("Action", "Cron"), -- 识别定时(cron) 消息的 handler 匹配函数 29 | function () -- 需要定时执行的 handler 任务 30 | -- 要执行的内容 31 | end 32 | ) 33 | ``` 34 | 35 | 定时消息(Cron Messages)是一个强大的实用工具,可以用来创建具有广泛功能的“自主代理”。 36 | -------------------------------------------------------------------------------- /src/zh/references/data.md: -------------------------------------------------------------------------------- 1 | # 使用 ao 访问 Arweave 上的数据 2 | 3 | 在你的 ao 开发工作流程中,可能有时候你想要访问 arweave 上的数据。你的进程可以使用 ao 发送一条消息,然后 ao 网络会通过一个 Message 对象将数据提供给你的 Process 对象。 4 | 5 | 为了从 arweave 请求数据,你只需包含一个名为 `Load` 的 `Tag`,在该标签中,你可以使用数据的 TXID 来检索。 6 | 7 | ```lua 8 | 9 | Send({ 10 | Target = ao.id, 11 | Tags = { 12 | Load = "WFM_Mi2FUNGCeP7r99XyeE3ySurt07LHxEGfW-wuIdY", 13 | Action = "Data" 14 | } 15 | }) 16 | 17 | ``` 18 | 19 | 这条消息通过处理到达进程时,在传入消息的 `Data` 属性中,有一个 DataItem 的引用。同时,DataItem 的 `Data` 将以 base64 的类型传递。 20 | 21 | ```lua 22 | { 23 | Owner = "[Owner Address]" 24 | Target = "[Process Identifier]", 25 | Data = { 26 | Owner = "xDKpdiZ7H9n_SsdX_CMpkybMGIdin5AUciM00mQgxRE", 27 | Tags = { 28 | "Content-Type": "application/json" 29 | }, 30 | Data = "[base64]", 31 | ... 32 | } 33 | ... 34 | } 35 | 36 | ``` 37 | 38 | 在 lua 中,你可以使用 “.base64” 模块将你的数据从 base64 解码回原始格式。 39 | 40 | ```lua 41 | local base64 = require(".base64") 42 | 43 | 44 | local data = base64.decode(Msg.Data.Data) 45 | ``` 46 | 47 | ## 为什么从 Arweave 上面取数据 48 | 49 | 你的进程可能需要访问数据来做决策,或者你可能想要通过 `data` 加载功能,为你的进程添加特性。 50 | -------------------------------------------------------------------------------- /src/zh/references/editor-setup.md: -------------------------------------------------------------------------------- 1 | # 编辑器设置 2 | 3 | 内置的 ao 函数和实用工具不太好用。为了提升你的开发体验,建议你在你常用的文本编辑器中安装 [Lua Language Server](https://luals.github.io) 扩展插件,并添加 [ao插件](https://github.com/martonlederer/ao-definitions)。它们支持所有内置的 aos [模块](../guides/aos/index.md) 和 [全局变量](../guides/aos/intro#globals)。 4 | 5 | ## VS Code 6 | 7 | 安装 [sumneko.lua](https://marketplace.visualstudio.com/items?itemName=sumneko.lua) 扩展插件: 8 | 9 | 1. 在扩展市场中搜索 sumneko 的 "Lua"。 10 | 2. 下载并安装该扩展插件。 11 | 3. 打开 VS Code 命令面板,使用 `Shift + Command + P`(Mac)/ `Ctrl + Shift + P`(Windows/Linux),然后运行以下命令: 12 | 13 | ``` 14 | > Lua: Open Addon Manager 15 | ``` 16 | 17 | 4. 在插件管理器中搜索 “ao”,它应该是第一个结果。点击 “启用”,然后就可以享受自动完成的功能了! 18 | 19 | 如果你不想为每个工作区重复这个过程,你可以从生成的工作区 `settings.json` 文件中复制 `Lua.workspace.library` 对象到你的全局 `settings.json` 文件中。 20 | 21 | ## 其他编辑器 22 | 23 | 1. 确认你的编辑器支持[语言服务器协议](https://microsoft.github.io/language-server-protocol/implementors/tools/)。 24 | 2. 按照 [luals.github.io](https://luals.github.io/#install) 上的指示安装 Lua 语言服务器。 25 | 3. 为语言服务器安装“ao”插件。 26 | -------------------------------------------------------------------------------- /src/zh/references/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "aos 接口" 4 | link: "/zh/concepts/tour" 5 | next: 6 | text: "Lua" 7 | link: "./lua" 8 | --- 9 | 10 | # 参考 11 | 12 | ## 目录 13 | 14 | - [Lua](lua) 15 | - [Web Assembly](wasm) 16 | - [ao 模块](ao) 17 | - [Handlers](handlers) 18 | - [代币](token) 19 | - [加载 Arweave 数据](data) 20 | - [定时消息](cron) 21 | - [编辑器设置](editor-setup) 22 | -------------------------------------------------------------------------------- /src/zh/references/lua.md: -------------------------------------------------------------------------------- 1 | # 认识 Lua 2 | 3 | ### 理解 Lua 4 | 5 | - **背景**: Lua 是一种轻量、高级、多范式的编程语言,主要用于嵌入式系统和客户端。它因效率、简洁和灵活性而闻名。 6 | - **核心特性**: Lua 提供了强大的数据描述构造、动态类型、高效的内存管理以及对面向对象编程的良好支持。 7 | 8 | ### 上手指南 9 | 10 | 1. **安装**: 访问 [Lua 的官方网站](http://www.lua.org/download.html) ,下载并安装 Lua。 11 | 2. **环境**: 你可以使用简单的文本编辑器和命令行,或者像 ZeroBrane Studio ,或带有 Lua 插件的 Eclipse 这样的集成开发环境(IDE)。 12 | 13 | ### 基础语法和概念 (在 aos 中的) 14 | 15 | - **Hello World**: 16 | ```lua 17 | "Hello, World!" 18 | ``` 19 | - **变量和类型**: Lua 是动态类型的。基本类型包括 `nil`、`boolean`、`number`、`string`、`function`、`userdata`、`thread` 和 `table`。 20 | - **控制结构**: 包括 `if`、 `while`、 `repeat...until` 和 `for`。 21 | - **函数**: Lua 中的一等公民,支持闭包和高阶函数。 22 | - **Tables**: Lua 中唯一的数据结构机制,可用于表示数组、集合、记录等。 23 | 24 | ### 动手试试 25 | 26 | - **用 Lua 的交互模式进行实验**: 在你的终端中运行 `aos` 并尝试 Lua 命令。 27 | - **写一些简单的脚本**: 创建 `.lua` 文件并使用 Lua 解释器运行它们。使用 `.load file.lua` 功能将 Lua 代码上传到你的 `aos` 进程中。 28 | 29 | ### 资源 30 | 31 | - **官方文档**: [Lua 5.3 参考手册](https://www.lua.org/manual/5.3/) 32 | - **在线教程**: 像 [Learn Lua](https://www.learn-lua.org/) 这样的网站非常适合进行交互式学习。 33 | - **书籍**: 《Lua 编程》是一本全面的资源。(第一版可在 [网上](http://www.lua.org/pil/contents.html) 获取) 34 | - **社区**: 加入像 [Lua 用户](http://lua-users.org/) 这样的论坛或社区,以获取支持和讨论。 35 | 36 | ### 最佳实践 37 | 38 | - **保持极简**: Lua 的设计是简单灵活的。你要在代码中拥抱这种哲学。 39 | - **性能**: 学习关于 Lua 的垃圾回收和高效利用 table 的知识。 40 | - **集成**: 考虑 Lua 如何嵌入到其他应用程序中,特别是 C/C++ 项目中。 41 | 42 | ### 总结 43 | 44 | Lua 是一种强大的语言,尤其在嵌入式系统和游戏开发领域。它的简单性和高效性让它成为特定用例的首选。祝你在 Lua 编程之旅中获得愉快的体验! 45 | -------------------------------------------------------------------------------- /src/zh/references/wasm.md: -------------------------------------------------------------------------------- 1 | # 认识 Web Assembly 2 | 3 | WebAssembly(通常简称为 Wasm)是一种现代的二进制指令格式,为高级语言(如C、C++和Rust)提供了一个可迁移的编译目标。它可以支持在网络上部署客户端和服务器应用,并提供高水平的性能和效率。WebAssembly 是为了保持网络浏览器的安全性和沙盒功能而设计的,成为网络应用程序的选择之一。它是网络开发人员的关键技术,使他们能够用多种语言编写代码,并将代码编译为在浏览器中以接近原生速度运行的字节码。 4 | 5 | WebAssembly 的重要性在于它能够弥合网络应用程序和本地应用程序之间的差距。它使得之前局限于桌面环境的复杂应用程序和游戏,能够在浏览器中以相当的性能运行。这为网络开发带来了新的可能性,包括创建高性能的网络应用程序、游戏,甚至将现有的桌面应用程序移植到网络上。WebAssembly 与 JavaScript 并行运行,通过使用更适合此类任务的语言编写性能关键组件,弥补了 JavaScript 的缺陷,从而增强了网络应用程序的功能和性能。 6 | -------------------------------------------------------------------------------- /src/zh/tutorials/begin/aos-print.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/tutorials/begin/aos-print.png -------------------------------------------------------------------------------- /src/zh/tutorials/begin/chatroom1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/tutorials/begin/chatroom1.png -------------------------------------------------------------------------------- /src/zh/tutorials/begin/chatroom2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/tutorials/begin/chatroom2.png -------------------------------------------------------------------------------- /src/zh/tutorials/begin/chatroom3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/tutorials/begin/chatroom3.png -------------------------------------------------------------------------------- /src/zh/tutorials/begin/chatroom4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/tutorials/begin/chatroom4.png -------------------------------------------------------------------------------- /src/zh/tutorials/begin/chatroom5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/tutorials/begin/chatroom5.png -------------------------------------------------------------------------------- /src/zh/tutorials/begin/chatroom6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/tutorials/begin/chatroom6.png -------------------------------------------------------------------------------- /src/zh/tutorials/begin/chatroom7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/tutorials/begin/chatroom7.png -------------------------------------------------------------------------------- /src/zh/tutorials/begin/chatroom8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/tutorials/begin/chatroom8.png -------------------------------------------------------------------------------- /src/zh/tutorials/begin/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "教程" 4 | link: "../index" 5 | next: 6 | text: "准备" 7 | link: "./preparations" 8 | --- 9 | 10 | # 开始:互动教程 11 | 12 | 在本教程系列中,你将完成交互式步骤,这将帮助你加深对 aos 环境的理解。 13 | 14 | ::: info 15 | 16 | ### 练习 17 | 18 | 在这个有趣的练习中,你将遇到两个熟悉的角色 Morpheus 和 Trinity 提出的一系列挑战。 在 Morpheus 的引导下,你将深入 `兔子洞`,他会向你提出一系列挑战,以证明你就是 `那个人`。 一旦你完成了 Morpheus 和 Trinity 提出的所有挑战,你将收到一个 token ,该 token 允许你访问 ao 中名为 `The Construct` 的专属聊天室。 19 | 20 | 现在,让我们开始[深入兔子洞](./preparations)。 21 | 22 | ![白兔](./white_rabbit_outline.svg) 23 | ::: 24 | 25 | ## 教程 26 | 27 | ### 入门 - 交互式教程 28 | 29 | - [1. 快速入门](preparations) 30 | - [2. 消息传递](messaging) 31 | - [3. 创建聊天室](chatroom) 32 | - [4. 创建 token ](token) 33 | -------------------------------------------------------------------------------- /src/zh/tutorials/begin/messaging2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/tutorials/begin/messaging2.png -------------------------------------------------------------------------------- /src/zh/tutorials/begin/rabbithole.md: -------------------------------------------------------------------------------- 1 | # 进入 `The Construct` - 交互式教程 2 | 3 | ![白兔](./white_rabbit_outline.svg) 4 | 5 | ## 醒来吧,尼奥…… 6 | 7 | 你准备好看看兔子洞有多深了吗? 8 | 9 | 这个交互式教程将利用你迄今为止所学到的知识并将其应用到任务中。 10 | 11 | ### 任务:冲出矩阵并进入 `The Construct` 12 | 13 | 该结构是 ao 内的一个代币门控聊天室,只有完成一系列任务的人才能访问。 14 | 15 | **现在...让我们开始吧。** 16 | 17 | ::: warning 18 | 你必须安装最新版本的 aos 才能完成本教程。 19 | ::: 20 | 21 | ### 1. 找到墨菲斯 22 | 23 | Morpheus 的进程 ID: 24 | 25 | ```lua 26 | 9yOQrYNwIfIOeSswRDGUMd5gvMWJKxleInD_95DEC4A 27 | ``` 28 | 29 | 用这个进程 ID 在 aos 里命名为 `Morpheus`。 这是进入 `The Construct` 的第一步。 30 | 31 | ```lua 32 | Morpheus = "9yOQrYNwIfIOeSswRDGUMd5gvMWJKxleInD_95DEC4A" 33 | ``` 34 | 35 | 向 Morpheus 发送消息,并告诉他你已准备好开始。 36 | 37 | ```lua 38 | Send({ Target = Morpheus, Data = "I'm Ready" }) 39 | ``` 40 | 41 | 当你发送此消息后,他将回复下一步。按照他给你的指示进行操作,你就会踏上前往 `The Construct` 的路上。 42 | 43 | ::: info 44 | 如果你需要帮助了解消息传递过程,请查看[消息传递](messaging)教程。 45 | ::: 46 | 47 | ### 2. 向墨菲斯证明自己 48 | 49 | Morpehus会给你一系列任务来完成。这些任务将涉及: 50 | 51 | - 建立一个[聊天室](chatroom)。 52 | - 在聊天室中广播消息。 53 | - 为聊天室编写自定义handler。 54 | 55 | 当你完成这些任务后,墨菲斯会给你下一步的指示,其中将涉及找到 Trinity。 56 | 57 | ### 3.找到 Trinity 58 | 59 | Trinity 的进程ID只能通过完成 Morpheus 的任务来获得。 60 | 61 | 一旦你收到 Trinity 的进程 ID,你需要在 aos 中将其命名为 `Trinity`。 然后你会向她发送消息 `"White Rabbit"`。 62 | 63 | ```lua 64 | Send({ Target = Trinity, Data = "White Rabbit" }) 65 | ``` 66 | 67 | 她将做出回应,教程的下一阶段将开始。 68 | 69 | ### 4. 向 Trinity 证明自己 70 | 71 | 就像 Morpheus 一样,Trinity 会给你一系列任务来完成。 72 | 73 | 这些任务将涉及: 74 | 75 | - 创建一个[代币](token)。 76 | - 代币化你为 Morpheus 构建的聊天室。 77 | - 创建你自己的[游戏和机器人](../bots-and-games/index)。 78 | - 在代币化聊天室中注册你的进程。 79 | 80 | 完成这些任务后,Trinity 将为你提供本教程下一阶段的说明。 81 | 82 | ### 5. 接收进入 `the Construct` 的代币 83 | 84 | 通过完成 Morpheus 和 Trinity 的任务,你将收到一个代币,可以让你进入 `the Construct`。 85 | 86 | ### 6. 进入 `the Construct` 87 | 88 | 然后 Trinity 将指导你如何使用该代币进入 `the Construct`。 89 | 90 | 进入 `the Construct` 后,你将能够与完成教程的其他人聊天。 91 | -------------------------------------------------------------------------------- /src/zh/tutorials/begin/token.md: -------------------------------------------------------------------------------- 1 | # 创建 token 2 | 3 | ::: info 4 | 你现在已经准备好创建自己的 token ,token 是去中心化世界里价值和交换的象征。在学习如何创建 token 之前,请务必去学习下[消息传递](messaging)和[创建聊天室](chatroom) 课程。 5 | ::: 6 | 7 | 创建 token 时,我们将继续使用 `ao` 中的 [Lua 语言](../../references/lua.md) 来铸造一个 token ,并遵循 [token 规范](../../references/token.md) 中的原则。 8 | 9 | ## 继续深入兔子洞 10 | 11 | 在我们上一篇教程[创建聊天室](chatroom)中,我们学习了如何在 `ao` 中创建一个聊天室,邀请 `Morpheus` 和 `Trinity` 到我们创建的聊天室,然后 `Trinity` 现在要求我们为她创建一个 token ,以证明我们值得继续深入兔子洞。 12 | 13 | **让我们开始吧。** 14 | 15 | ## 创建 token 的两种途径 16 | 17 | 创建 token 时有两条路径可供选择: 18 | 19 | 1. **使用蓝图(Bludprint)**:这是一个预制的模板,可以帮助你在 `ao` 中快速构建 token 。这是一种很好的入门方式,并且可以根据你的需求进行定制。 20 | 21 | 点击此处了解有关[ token 蓝图](../../guides/aos/blueprints/token.md)的更多信息。 22 | 23 | 2. **手动创建**:这是从头开始在 `ao` 中构建 token 的分步指南。这条路径适合那些想要了解 token 内部运作以及如何从头开始构建 token 的人。 24 | 25 | 请在此处查看完整的[创建 token ](../../guides/aos/token.md)指南。 26 | 27 | ## 蓝图方法 28 | 29 | 在本教程中,我们将使用 token 蓝图为 `Trinity` 创建 token 。 这是一个预先设计的模板,可帮助你在 `ao` 中快速构建 token 。 30 | 31 | ### 如何使用 token 蓝图 32 | 33 | 1. 确保你的终端运行在教程前面的步骤的同一目录中。 34 | 2. 打开终端。 35 | 3. 启动 `aos` 进程。 36 | 4. 输入 `.load-blueprint token` 37 | 38 | 这将加载 token 函数到 `ao` 的 handler。 请务必注意, 你也可以自行创建其他 token 代码取代蓝图代码。 39 | 40 | ### 验证蓝图是否已加载 41 | 42 | 输入 `Handlers.list` 以查看新加载的handler。 43 | 44 | 你应该看到已加载到 `aos` 进程中的新handler列表。 如果你一直遵循本教程中前面的步骤,除了 token handler 之外,你还应该看到聊天室的 handler。 45 | 46 | **例子:** 47 | 48 | ![ token handler](./token3.png) 49 | 50 | ### 测试 token 51 | 52 | 现在 token 蓝图已加载,我们可以通过使用 `Action = "Info"` 标签向自己发送消息来测试 token。 53 | 54 | ```lua 55 | Send({ Target = ao.id, Action = "Info" }) 56 | ``` 57 | 58 | 这将向控制台打印一条消息,但要读取该消息,我们需要从最新消息中调用 `.Data`。 59 | 60 | ```lua 61 | Inbox[#Inbox].Data 62 | 63 | -- 将 `#Inbox` 替换为最后收到的消息的编号。 64 | ``` 65 | 66 | 这会将 token 信息打印到控制台。它应该显示你的可用 token 的总余额。 67 | 68 | ### 向 Trinity 发送 token 69 | 70 | 现在我们已经测试了 token 并且它按预期工作,我们可以将一些 token 发送到 `Trinity`。 我们将使用 `Action = "Transfer"` 标签向 `Trinity` 发送 1000 个 token 。 71 | 72 | ```lua 73 | Send({ Target = ao.id, Action = "Transfer", Recipient = Trinity, Quantity = "1000"}) 74 | ``` 75 | 76 | 当 `Trinity` 收到 token 时,她将用一条消息响应此转账,以确认她已收到 token 。 77 | 78 | 她的回应看起来像这样: 79 | 80 | `Trinity:` "Token received. Interesting. I wasn't sure you'd make it this far. I'm impressed, but we are not done yet. I want you to use this token to tokengate the chatroom. Do that, and then I will believe you could be the one." 81 | 82 | 使用下列命令查看 Trinity 的消息: 83 | 84 | ```lua 85 | Inbox[#Inbox].Data 86 | ``` 87 | 88 | 你已经完成了创建 token 并将其发送给 `Trinity`。 你现在已准备好继续下一步。 [token 门控聊天室](tokengating)。 89 | -------------------------------------------------------------------------------- /src/zh/tutorials/begin/token1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/tutorials/begin/token1.png -------------------------------------------------------------------------------- /src/zh/tutorials/begin/token2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/tutorials/begin/token2.png -------------------------------------------------------------------------------- /src/zh/tutorials/begin/token3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/tutorials/begin/token3.png -------------------------------------------------------------------------------- /src/zh/tutorials/bots-and-games/announcements.md: -------------------------------------------------------------------------------- 1 | # 解析公告 2 | 3 | 欢迎回到你的编码之旅。 是时候使用你从之前的教程中获得的技能来增强你的游戏体验了。 4 | 5 | 在游戏过程中,你可能会注意到终端中出现的公告。这些公告是游戏向玩家传达重要事件的方式。然而,这些消息有时看起来很神秘,或者你可能会发现自己得反复检查收件箱才能获取更多详细信息。 6 | 7 | 直接从你的终端访问这些信息不是很方便吗? 嗯,有一种方法可以做到这一点! 8 | 9 | 通过使用 [handlers](../../references/handlers.md),你可以创建一个自主代理来为你读取这些信息,标志着从简单的机器人到能够直接解析游戏事件并对其采取行动的实体的进化。 10 | 11 | ## 设置开发环境 12 | 13 | 首先在你的首选目录中创建一个名为 `bot.lua` 的新文件。 14 | 15 | > 理想情况下,该文件应放置在 player 进程的同一目录中,以简化代码的加载。 否则,你需要使用相对路径来访问该文件。 16 | 17 | ## 编写代码 18 | 19 | 让我们深入研究下其中的逻辑。 20 | 21 | aos 中的每个handler都需要三个关键信息: 22 | 23 | - `name`:handler 的唯一名称 24 | - `pattern`: handler 识别的模式,触发其执行 25 | - `handle`:模式匹配时执行的操作 26 | 27 | 以下是编写用于打印公告详细信息的 handler 的方法: 28 | 29 | ```lua 30 | -- 直接在终端中打印游戏公告的handler。 31 | Handlers.add( 32 | "PrintAnnouncements", 33 | Handlers.utils.hasMatchingTag("Action", "Announcement"), 34 | function (msg) 35 | print(msg.Event .. ": " .. msg.Data) 36 | end 37 | ) 38 | ``` 39 | 40 | 在本例中,handler的名称是 `"PrintAnnouncements"`。 它使用特殊的内置实用程序(`hasMatchingTags`)检查传入消息是否已被标记为公告。 如果为 true,则 handler 将打印事件和数据,则直接显示公告的标题和描述。 41 | 42 | > 注意:一旦消息被 `handled`,它将从你的 `收件箱` 中丢弃。 43 | 44 | ## 加载和测试 45 | 46 | 现在,让我们在游戏中实现这一点。 47 | 48 | 导航到你的 aos 玩家终端并进入游戏会话。 49 | 50 | 用下面的命令来加载 `bot.lua` 文件以激活handler: 51 | 52 | ```lua 53 | .load bot.lua 54 | ``` 55 | 56 | 现在,你将看到游戏公告直接出现在你的终端中,提供实时展示,且无需手动查看收件箱。 57 | 58 | 恭喜! 你刚刚迈出了在 `aos` 上构建机器人的第一步。 但让我们继续努力为其添加更多功能 🌐 59 | -------------------------------------------------------------------------------- /src/zh/tutorials/bots-and-games/ao-effect-game-banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/permaweb/ao-cookbook/075f58c51a8b90c2112b2e86cc41ec5c1fcef784/src/zh/tutorials/bots-and-games/ao-effect-game-banner.png -------------------------------------------------------------------------------- /src/zh/tutorials/bots-and-games/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "代币门控" 4 | link: "../begin/tokengating" 5 | next: 6 | text: "我们玩个游戏" 7 | link: "./ao-effect" 8 | --- 9 | 10 | # 机器人和游戏 11 | 12 | 利用我们上一章所学,本节将引导你了解 aos 中如何创造自动化的机器人和游戏。你将学习创建代理,让你的代理在游戏场景内游玩。 13 | 14 | ## 章节 15 | 16 | ### 游戏入门 17 | 18 | - [0. **我们来玩游戏吧:**_在aos上体验游戏_](ao-effect) 19 | 20 | ### 通过自动化增强游戏交互 21 | 22 | - [1. **公告解读:** _游戏内公告解读_](announcements) 23 | - [2. **获取游戏状态:** _检索并处理最新的游戏状态_](game-state) 24 | - [3. **战略决策:** _利用自动化来确定你的下一步行动_](decisions) 25 | - [4. **自动响应:** _通过自动化简化攻击响应_](attacking) 26 | - [5. **\*整合:** _结合你的技能来打造一个自主代理_](bringing-together) 27 | 28 | ### 游戏开发讲解 29 | 30 | - [6. **竞技场机制:** _探索游戏竞技场的底层机制_](arena-mechanics) 31 | - [7. **扩展竞技场:** _在竞技场上构建独特的游戏逻辑_](build-game) 32 | 33 | 探索和创造的旅程正在等待着你。 让冒险开始吧! 34 | -------------------------------------------------------------------------------- /src/zh/tutorials/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "测试网信息" 4 | link: "/welcome/legacynet-info" 5 | next: 6 | text: "开始" 7 | link: "./begin/index" 8 | --- 9 | 10 | # 教程 11 | 12 | 在这里,我们创建了一系列教程来帮助你开始使用 aos 并构建你的第一个进程。 这些教程包括交互式指南、代码片段和示例,以帮助你熟悉 aos 环境。 13 | 14 | ## 教程列表 15 | 16 | - [开始 - 互动指南](begin/index) 17 | 18 | - [机器人和游戏](bots-and-games/index) 19 | -------------------------------------------------------------------------------- /src/zh/welcome/ao-logo-grey.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/zh/welcome/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | next: 3 | text: "入门" 4 | link: "/zh/welcome/getting-started" 5 | --- 6 | 7 | # 欢迎来到 ao 8 | 9 | ![ao logo](./ao-logo-grey.svg) 10 | 11 | ao 是一个由无数进程组成的世界计算机。这些进程处在一个连贯的计算环境中,进程之间通过原生的消息进行无缝衔接,相互作用。 12 | 13 | ao 是一个正在演化的去中心化程序生态系统,类比互联网,这里每个进程就像是一个个独立的网站。它们独立运行,但是又错综复杂的交织为一个统一的”联合体“。 14 | 15 | ## ao + aos: 火箭和火箭燃料 16 | 17 | 初次接触 ao,你可以使用操作系统 `aos` 与 ao 进行交互。 18 | 19 | aos 是一个运行在进程中的抽象层,使得你可以轻松使用 ao 计算机的全部功能。 本手册将带你学习如何使用 aos,你会获得入门 ao 计算机所需的所有信息。 20 | 21 | ## 下一步 22 | 23 | 在接下来的教程中,我们将一起探索 ao,一起构建具备治理功能的聊天室、去中心化机器人等内容。 24 | 25 | 让我们开始吧! 🚀 26 | -------------------------------------------------------------------------------- /src/zh/welcome/testnet-info/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: 3 | text: "入门" 4 | link: "../getting-started" 5 | next: 6 | text: "CRED 和任务 FAQ" 7 | link: "/zh/welcome/legacynet-info/cred-and-quests" 8 | --- 9 | 10 | # 参与 ao 测试网 11 | 12 | 2024年2月27日,`ao` 测试网上线,供开发者和早期用户探索这台超并行计算机。 13 | 14 | ## 什么是 ao 测试网? 15 | 16 | ao 测试网允许用户免费与 ao 计算机交互,共同测试和构建主网。 17 | 18 | 你可以通过 aos 控制台连接 ao 计算机。 在接下来的文档中,你会发现许多可以尝试的任务,这些任务可以帮助你赚取 CRED 代币(测试网的代币)。 19 | 20 | ## 安装 aos 客户端 21 | 22 | 如果你已经装好 [NodeJS](https://nodejs.org),你所需要做的就是安装 aos 并运行它: 23 | 24 | ```sh 25 | npm i -g https://get_ao.g8way.io 26 | ``` 27 | 28 | 安装后,我们只需运行以下命令即可启动新的 aos 进程! 29 | 30 | ```sh 31 | aos 32 | ``` 33 | 34 | ## 加入 ao 的原生社区聊天 35 | 36 | ao 网络托管着许多聊天服务器,你可以直接从 aos 控制台与其他开发人员交谈。 要加载聊天客户端,请运行以下命令: 37 | 38 | ```lua 39 | .load-blueprint chat 40 | ``` 41 | 42 | 查看可用房间,你可以运行: 43 | 44 | ```lua 45 | List() 46 | ``` 47 | 48 | 加入房间并与其他开发者聊天,如下所示: 49 | 50 | ```lua 51 | Join("Getting-Started", "yourName") 52 | Say("Hi") 53 | ``` 54 | 55 | ## AO 测试网的第一步 56 | 57 | 为了加快在 ao 中的构建速度,查看以下教程: 58 | 59 | - 学习 [开始](/zh/tutorials/begin/) 教程来构建你自己的代币化聊天室 60 | - 学习 [机器人和游戏](/zh/tutorials/bots-and-games/) 教程,构建一个在 ao-effect 竞技场中玩耍的机器人 61 | 62 | ## 帮助构建 ao 生态系统并赚取 CRED 63 | 64 | ao 生态处于非常早期的阶段,充满机遇。 社区里有一个 `quest` 板块(任务板块),其中包含各种方法让你可以参与测试和构建软件以发展生态,同时赚 ao 原生代币 - legacynet CRED。 65 | 66 | 要列出当前可用的任务,请使用 `Join("Quests")` 和 `Say "/Quests"` 加入 `Quests` 聊天频道以接收任务列表。 67 | 68 | 玩得开心,如果需要帮助,请随时在 ao 聊天中向其他构建者寻求帮助! 69 | --------------------------------------------------------------------------------