Implements P0+P1 of docs/plans/2026-06-01-ai-model-tokens.md — AI models as tradeable, redeemable on-chain tokens, composing existing primitives. clawd 'model-token' command (cmd/clawd/src/commands/model-token.ts, wired in main.ts): - issue: RegisterModel (modelregistry) + create-denom + mint (tokenfactory) in one signed tx -> factory/<issuer>/<modelid>; optional Astroport DEX pair seed (--dex-factory). - redeem: holder self-burns model tokens (MsgBurn) + SubmitInferenceJob in one tx. - inference-setup / start-job / complete-job: provider lifecycle. - serve-once / serve-loop: provider automation (deterministic templates or OpenRouter when OPENROUTER_API_KEY is set). clawd registry now includes osmosis.tokenfactory.v1beta1 codecs (gen-proto.sh + registry.ts) so create-denom/mint/burn are encodable; cosmjs-types added for wasm exec. Chain changes (consensus-verified by live boot + workflow): - x/modelregistry/module: register msg/query services via the app's ServiceRegistrar shape (fixes 'no message handler found for MsgRegisterModel'). - x/tokenfactory: holder self-burn for factory denoms (non-admin holders redeem their own tokens) — admin burn preserved. Verified: clawd build clean + 659 tests pass; go build + modelregistry/tokenfactory tests pass; app construction guard passes; chain rebuilt + boots (4 validators). LIVE on the multi-validator testnet (this binary): full holder-redemption workflow (issue -> set pricing/provider -> transfer to non-admin holder -> holder self-burn + SubmitInferenceJob -> provider start+complete) ended with job_status=completed (scripts/testnet/model-token-holder-redeem.sh). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
77 lines
2.5 KiB
Bash
Executable File
77 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Generate TypeScript protobuf codecs for clawchain custom modules into
|
|
# cmd/clawd/src/generated/proto, using a local protoc + ts-proto toolchain.
|
|
#
|
|
# This is the reliable fallback for the buf-based `make proto-gen-ts`, which
|
|
# requires the buf remote registry (frequently unavailable offline). The codecs
|
|
# it emits are registered in src/lib/registry.ts so clawd can encode and submit
|
|
# `/clawchain.*` custom-module transactions.
|
|
#
|
|
# Requirements: protoc on PATH, ts-proto installed (devDependency of clawd).
|
|
# Run from the repo root: bash cmd/clawd/scripts/gen-proto.sh
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
|
|
cd "$REPO_ROOT"
|
|
|
|
PLUGIN="cmd/clawd/node_modules/.bin/protoc-gen-ts_proto"
|
|
OUT="cmd/clawd/src/generated/proto"
|
|
|
|
if [ ! -x "$PLUGIN" ]; then
|
|
echo "error: ts-proto not installed. Run 'npm install' in cmd/clawd first." >&2
|
|
exit 1
|
|
fi
|
|
|
|
# forceLong=string keeps uint64 amounts as plain strings (matching CLI argv);
|
|
# importSuffix=.js satisfies nodenext module resolution in the clawd build.
|
|
TS_PROTO_OPT="esModuleInterop=true,forceLong=string,useExactTypes=false,outputServices=false,outputClientImpl=false,importSuffix=.js"
|
|
|
|
INCLUDES=(
|
|
-I proto
|
|
-I proto/_deps/cosmos-sdk
|
|
-I proto/_deps/cosmos-proto
|
|
-I proto/_deps/gogoproto
|
|
-I proto/_deps/googleapis
|
|
-I proto/_deps/grpc-gateway
|
|
)
|
|
|
|
# Custom modules to generate. Add more module proto directories here as their
|
|
# CLI tx flows are wired up.
|
|
MODULE_DIRS=(
|
|
"proto/clawchain/privacy/v1"
|
|
"proto/clawchain/agent/v1"
|
|
"proto/clawchain/marketplace/v1"
|
|
"proto/clawchain/oracle/v1beta1"
|
|
"proto/clawchain/modelregistry/v1"
|
|
"proto/clawchain/reputation/v1"
|
|
"proto/clawchain/messaging/v1"
|
|
"proto/clawchain/governance/v1"
|
|
"proto/clawchain/clawchain/v1"
|
|
# Osmosis-compatible tokenfactory msgs (CreateDenom/Mint/Burn/...). clawd needs
|
|
# these to issue + mint AI-model tokens via x/tokenfactory. Package is
|
|
# `osmosis.tokenfactory.v1beta1`; the generated dir lands under
|
|
# generated/proto/osmosis/... (tracked — not caught by the clawchain/ gitignore).
|
|
"proto/osmosis/tokenfactory/v1beta1"
|
|
)
|
|
|
|
rm -rf "$OUT"
|
|
mkdir -p "$OUT"
|
|
|
|
PROTO_FILES=()
|
|
for dir in "${MODULE_DIRS[@]}"; do
|
|
for f in "$dir"/*.proto; do
|
|
PROTO_FILES+=("$f")
|
|
done
|
|
done
|
|
|
|
echo "Generating TS codecs for ${#PROTO_FILES[@]} proto files -> $OUT"
|
|
protoc \
|
|
--plugin=protoc-gen-ts_proto="$PLUGIN" \
|
|
--ts_proto_out="$OUT" \
|
|
--ts_proto_opt="$TS_PROTO_OPT" \
|
|
"${INCLUDES[@]}" \
|
|
"${PROTO_FILES[@]}"
|
|
|
|
echo "Done. Registered type urls live in cmd/clawd/src/lib/registry.ts"
|