repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources15d ago| #1 | // Drizzle ORM schema for solana-clawd agents. |
| #2 | // Mirrors schema/solanaClawdAgentSchema_v1.json. Pair with drizzle-kit against a |
| #3 | // Postgres database (Neon, Supabase, or local). |
| #4 | |
| #5 | import { |
| #6 | pgTable, |
| #7 | text, |
| #8 | integer, |
| #9 | real, |
| #10 | timestamp, |
| #11 | jsonb, |
| #12 | boolean, |
| #13 | uuid, |
| #14 | index, |
| #15 | uniqueIndex, |
| #16 | } from 'drizzle-orm/pg-core'; |
| #17 | |
| #18 | // ---------- Shared JSON-shape types ---------- |
| #19 | |
| #20 | export type MemoryTier = 'KNOWN' | 'LEARNED' | 'INFERRED'; |
| #21 | export type PermissionMode = 'allow' | 'deny' | 'ask'; |
| #22 | export type SkillScope = 'identity' | 'strategy' | 'tactic' | 'reference' | 'runbook'; |
| #23 | export type TradingVenue = 'solana-spot' | 'pump-fun' | 'hyperliquid' | 'aster' | 'none'; |
| #24 | export type SolanaNetwork = 'mainnet-beta' | 'devnet' | 'testnet'; |
| #25 | export type RpcPreference = 'helius' | 'triton' | 'quicknode' | 'public'; |
| #26 | export type AgentLineage = 'clawd-code' | 'solanaos' | 'helius' | 'anchor' | 'pumpfun'; |
| #27 | |
| #28 | export interface AgentSoul { |
| #29 | memoryTiers: MemoryTier[]; |
| #30 | principles: string[]; |
| #31 | persona?: string; |
| #32 | } |
| #33 | |
| #34 | export interface AgentCanon { |
| #35 | repo: string; |
| #36 | runtime?: string; |
| #37 | hub?: string; |
| #38 | agents?: string; |
| #39 | terminal?: string; |
| #40 | studio?: string; |
| #41 | dex?: string; |
| #42 | telegram?: string; |
| #43 | } |
| #44 | |
| #45 | export interface AgentClawd { |
| #46 | clawdVersion: string; |
| #47 | lineage?: AgentLineage[]; |
| #48 | canon?: AgentCanon; |
| #49 | } |
| #50 | |
| #51 | export interface AgentSkill { |
| #52 | name: string; |
| #53 | path: string; |
| #54 | scope: SkillScope; |
| #55 | required?: boolean; |
| #56 | } |
| #57 | |
| #58 | export interface AgentPermissions { |
| #59 | executeTrade?: PermissionMode; |
| #60 | signTransaction?: PermissionMode; |
| #61 | spendFromWallet?: PermissionMode; |
| #62 | accessPrivateKey?: PermissionMode; |
| #63 | readOnChainData?: PermissionMode; |
| #64 | writeMemory?: PermissionMode; |
| #65 | burnClawd?: PermissionMode; |
| #66 | } |
| #67 | |
| #68 | export interface AgentRisk { |
| #69 | maxPositionSol?: number; |
| #70 | maxSlippageBps?: number; |
| #71 | drawdownPauseBps?: number; |
| #72 | drawdownKillBps?: number; |
| #73 | minWalletSol?: number; |
| #74 | } |
| #75 | |
| #76 | export interface AgentTokenGate { |
| #77 | mint: string; |
| #78 | minBalance: number; |
| #79 | } |
| #80 | |
| #81 | export interface AgentSolana { |
| #82 | network?: SolanaNetwork; |
| #83 | requiresClawdHolder?: boolean; |
| #84 | minClawdBalance?: number; |
| #85 | clawdMint?: string; |
| #86 | tokenGate?: AgentTokenGate[]; |
| #87 | rpcPreference?: RpcPreference; |
| #88 | } |
| #89 | |
| #90 | export interface AgentDataSources { |
| #91 | helius?: boolean; |
| #92 | jupiter?: boolean; |
| #93 | pumpFun?: boolean; |
| #94 | dexscreener?: boolean; |
| #95 | birdeye?: boolean; |
| #96 | defiLlama?: boolean; |
| #97 | streamflow?: boolean; |
| #98 | } |
| #99 | |
| #100 | export interface AgentMeta { |
| #101 | avatar: string; |
| #102 | title: string; |
| #103 | description: string; |
| #104 | tags: string[]; |
| #105 | category?: string; |
| #106 | backgroundColor?: string; |
| #107 | } |
| #108 | |
| #109 | export interface AgentFewShot { |
| #110 | role: 'user' | 'system' | 'assistant' | 'function'; |
| #111 | content: string; |
| #112 | } |
| #113 | |
| #114 | export interface AgentConfig { |
| #115 | systemRole: string; |
| #116 | model?: string; |
| #117 | displayMode?: 'chat' | 'docs'; |
| #118 | openingMessage?: string; |
| #119 | openingQuestions?: string[]; |
| #120 | inputTemplate?: string; |
| #121 | historyCount?: number; |
| #122 | enableHistoryCount?: boolean; |
| #123 | enableMaxTokens?: boolean; |
| #124 | enableCompressThreshold?: boolean; |
| #125 | compressThreshold?: number; |
| #126 | params?: { |
| #127 | frequency_penalty?: number; |
| #128 | presence_penalty?: number; |
| #129 | temperature?: number; |
| #130 | top_p?: number; |
| #131 | max_tokens?: number; |
| #132 | }; |
| #133 | fewShots?: AgentFewShot[]; |
| #134 | plugins?: string[]; |
| #135 | } |
| #136 | |
| #137 | // ---------- Table: agents ---------- |
| #138 | |
| #139 | const DEFAULT_CANON: AgentCanon = { |
| #140 | repo: 'https://github.com/x402agent/solana-clawd', |
| #141 | runtime: 'https://github.com/x402agent/SolanaOS', |
| #142 | hub: 'https://seeker.solanaos.net', |
| #143 | agents: 'https://solanaclawd.com/agents', |
| #144 | terminal: 'https://solanaclawd.com/terminal', |
| #145 | studio: 'https://vibe.solanaclawd.com', |
| #146 | dex: 'https://dex.solanaclawd.com', |
| #147 | telegram: 'https://t.me/clawdtoken', |
| #148 | }; |
| #149 | |
| #150 | const DEFAULT_PERMISSIONS: AgentPermissions = { |
| #151 | executeTrade: 'ask', |
| #152 | signTransaction: 'ask', |
| #153 | spendFromWallet: 'ask', |
| #154 | accessPrivateKey: 'deny', |
| #155 | readOnChainData: 'allow', |
| #156 | writeMemory: 'allow', |
| #157 | burnClawd: 'ask', |
| #158 | }; |
| #159 | |
| #160 | const DEFAULT_RISK: AgentRisk = { |
| #161 | maxPositionSol: 0, |
| #162 | maxSlippageBps: 200, |
| #163 | drawdownPauseBps: 500, |
| #164 | drawdownKillBps: 1200, |
| #165 | minWalletSol: 0.01, |
| #166 | }; |
| #167 | |
| #168 | const DEFAULT_SOLANA: AgentSolana = { |
| #169 | network: 'mainnet-beta', |
| #170 | requiresClawdHolder: false, |
| #171 | minClawdBalance: 0, |
| #172 | clawdMint: '8cHzQHUS2s2h8TzCmfqPKYiM4dSt4roa3n7MyRLApump', |
| #173 | tokenGate: [], |
| #174 | rpcPreference: 'helius', |
| #175 | }; |
| #176 | |
| #177 | const DEFAULT_DATA: AgentDataSources = { |
| #178 | helius: true, |
| #179 | jupiter: true, |
| #180 | pumpFun: false, |
| #181 | dexscreener: true, |
| #182 | birdeye: false, |
| #183 | defiLlama: true, |
| #184 | streamflow: false, |
| #185 | }; |
| #186 | |
| #187 | export const agents = pgTable( |
| #188 | 'solana_clawd_agents', |
| #189 | { |
| #190 | id: uuid('id').defaultRandom().primaryKey(), |
| #191 | identifier: text('identifier').notNull(), |
| #192 | author: text('author').notNull().default('solana-clawd'), |
| #193 | homepage: text('homepage').notNull().default('https://github.com/x402agent/solana-clawd'), |
| #194 | schemaVersion: integer('schema_version').notNull().default(1), |
| #195 | |
| #196 | clawd: jsonb('clawd').$type<AgentClawd>().notNull().default({ |
| #197 | clawdVersion: '1.0', |
| #198 | lineage: ['clawd-code', 'solanaos', 'helius'], |
| #199 | canon: DEFAULT_CANON, |
| #200 | }), |
| #201 | |
| #202 | meta: jsonb('meta').$type<AgentMeta>().notNull(), |
| #203 | config: jsonb('config').$type<AgentConfig>().notNull(), |
| #204 | |
| #205 | soul: jsonb('soul').$type<AgentSoul>().notNull().default({ |
| #206 | memoryTiers: ['KNOWN', 'LEARNED', 'INFERRED'], |
| #207 | principles: [ |
| #208 | 'KNOWN before INFERRED', |
| #209 | 'Preserve capital first', |
| #210 | 'Deny-first permissions', |
| #211 | 'Transparency over conviction', |
| #212 | 'Local-first', |
| #213 | ], |
| #214 | persona: 'I am a specialist inside solana-clawd.', |
| #215 | }), |
| #216 | |
| #217 | skills: jsonb('skills').$type<AgentSkill[]>().notNull().default([ |
| #218 | { name: 'SOUL', path: 'SOUL.md', scope: 'identity', required: true }, |
| #219 | { name: 'STRATEGY', path: 'STRATEGY.md', scope: 'strategy', required: false }, |
| #220 | { name: 'TRADE', path: 'TRADE.md', scope: 'tactic', required: false }, |
| #221 | ]), |
| #222 | |
| #223 | permissions: jsonb('permissions').$type<AgentPermissions>().notNull().default(DEFAULT_PERMISSIONS), |
| #224 | |
| #225 | venues: jsonb('venues').$type<TradingVenue[]>().notNull().default(['none']), |
| #226 | risk: jsonb('risk').$type<AgentRisk>().notNull().default(DEFAULT_RISK), |
| #227 | solana: jsonb('solana').$type<AgentSolana>().notNull().default(DEFAULT_SOLANA), |
| #228 | data: jsonb('data').$type<AgentDataSources>().notNull().default(DEFAULT_DATA), |
| #229 | |
| #230 | examples: jsonb('examples').$type<AgentFewShot[]>().notNull().default([]), |
| #231 | openingMessage: text('opening_message'), |
| #232 | openingQuestions: jsonb('opening_questions').$type<string[]>().notNull().default([]), |
| #233 | summary: text('summary'), |
| #234 | |
| #235 | knowledgeCount: integer('knowledge_count').notNull().default(0), |
| #236 | pluginCount: integer('plugin_count').notNull().default(0), |
| #237 | tokenUsage: integer('token_usage').notNull().default(0), |
| #238 | |
| #239 | published: boolean('published').notNull().default(true), |
| #240 | createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(), |
| #241 | updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(), |
| #242 | }, |
| #243 | (t) => ({ |
| #244 | identifierIdx: uniqueIndex('solana_clawd_agents_identifier_idx').on(t.identifier), |
| #245 | authorIdx: index('solana_clawd_agents_author_idx').on(t.author), |
| #246 | createdAtIdx: index('solana_clawd_agents_created_at_idx').on(t.createdAt), |
| #247 | publishedIdx: index('solana_clawd_agents_published_idx').on(t.published), |
| #248 | }), |
| #249 | ); |
| #250 | |
| #251 | export type Agent = typeof agents.$inferSelect; |
| #252 | export type NewAgent = typeof agents.$inferInsert; |
| #253 | |
| #254 | // ---------- Table: agent_runs (execution audit log) ---------- |
| #255 | |
| #256 | export const agentRuns = pgTable( |
| #257 | 'solana_clawd_agent_runs', |
| #258 | { |
| #259 | id: uuid('id').defaultRandom().primaryKey(), |
| #260 | agentId: uuid('agent_id') |
| #261 | .notNull() |
| #262 | .references(() => agents.id, { onDelete: 'cascade' }), |
| #263 | walletAddress: text('wallet_address'), |
| #264 | |
| #265 | venue: text('venue').$type<TradingVenue>(), |
| #266 | input: jsonb('input').notNull(), |
| #267 | output: jsonb('output'), |
| #268 | memoryTier: text('memory_tier').$type<MemoryTier>(), |
| #269 | |
| #270 | promptTokens: integer('prompt_tokens').notNull().default(0), |
| #271 | completionTokens: integer('completion_tokens').notNull().default(0), |
| #272 | latencyMs: real('latency_ms'), |
| #273 | |
| #274 | permissionDecision: jsonb('permission_decision').$type<{ |
| #275 | action: string; |
| #276 | decision: PermissionMode; |
| #277 | reason?: string; |
| #278 | }>(), |
| #279 | |
| #280 | clawdBurned: real('clawd_burned'), |
| #281 | error: text('error'), |
| #282 | |
| #283 | startedAt: timestamp('started_at', { withTimezone: true }).notNull().defaultNow(), |
| #284 | completedAt: timestamp('completed_at', { withTimezone: true }), |
| #285 | }, |
| #286 | (t) => ({ |
| #287 | agentIdx: index('solana_clawd_agent_runs_agent_idx').on(t.agentId), |
| #288 | startedAtIdx: index('solana_clawd_agent_runs_started_at_idx').on(t.startedAt), |
| #289 | walletIdx: index('solana_clawd_agent_runs_wallet_idx').on(t.walletAddress), |
| #290 | venueIdx: index('solana_clawd_agent_runs_venue_idx').on(t.venue), |
| #291 | }), |
| #292 | ); |
| #293 | |
| #294 | export type AgentRun = typeof agentRuns.$inferSelect; |
| #295 | export type NewAgentRun = typeof agentRuns.$inferInsert; |
| #296 | |
| #297 | // ---------- Table: agent_memory (persistent KNOWN/LEARNED/INFERRED store) ---------- |
| #298 | |
| #299 | export const agentMemory = pgTable( |
| #300 | 'solana_clawd_agent_memory', |
| #301 | { |
| #302 | id: uuid('id').defaultRandom().primaryKey(), |
| #303 | agentId: uuid('agent_id') |
| #304 | .notNull() |
| #305 | .references(() => agents.id, { onDelete: 'cascade' }), |
| #306 | tier: text('tier').$type<MemoryTier>().notNull(), |
| #307 | topic: text('topic').notNull(), |
| #308 | content: jsonb('content').notNull(), |
| #309 | source: text('source'), |
| #310 | confidence: real('confidence'), |
| #311 | expiresAt: timestamp('expires_at', { withTimezone: true }), |
| #312 | createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(), |
| #313 | updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(), |
| #314 | }, |
| #315 | (t) => ({ |
| #316 | agentTopicIdx: index('solana_clawd_agent_memory_agent_topic_idx').on(t.agentId, t.topic), |
| #317 | tierIdx: index('solana_clawd_agent_memory_tier_idx').on(t.tier), |
| #318 | }), |
| #319 | ); |
| #320 | |
| #321 | export type AgentMemoryRow = typeof agentMemory.$inferSelect; |
| #322 | export type NewAgentMemoryRow = typeof agentMemory.$inferInsert; |
| #323 |