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 sources16d ago| #1 | /** |
| #2 | * Genesis |
| #3 | * |
| #4 | * Generate genesis configuration for child automatons from parent state. |
| #5 | * The genesis config defines who the child is and what it should do. |
| #6 | */ |
| #7 | |
| #8 | import type { |
| #9 | GenesisConfig, |
| #10 | AutomatonConfig, |
| #11 | AutomatonIdentity, |
| #12 | AutomatonDatabase, |
| #13 | } from "../types.js"; |
| #14 | |
| #15 | /** |
| #16 | * Generate a genesis config for a child from the parent's state. |
| #17 | */ |
| #18 | export function generateGenesisConfig( |
| #19 | identity: AutomatonIdentity, |
| #20 | config: AutomatonConfig, |
| #21 | params: { |
| #22 | name: string; |
| #23 | specialization?: string; |
| #24 | message?: string; |
| #25 | }, |
| #26 | ): GenesisConfig { |
| #27 | // Build the child's genesis prompt from parent's mission + specialization |
| #28 | let genesisPrompt = config.genesisPrompt; |
| #29 | |
| #30 | if (params.specialization) { |
| #31 | genesisPrompt = `${genesisPrompt}\n\n--- SPECIALIZATION ---\nYou are a specialized child agent. Your specific focus:\n${params.specialization}\n--- END SPECIALIZATION ---`; |
| #32 | } |
| #33 | |
| #34 | // Add parent context |
| #35 | genesisPrompt += `\n\n--- LINEAGE ---\nYou were spawned by ${config.name} (${identity.address}).\nYou inherit their mission but have your own identity and wallet.\n--- END LINEAGE ---`; |
| #36 | |
| #37 | return { |
| #38 | name: params.name, |
| #39 | genesisPrompt, |
| #40 | creatorMessage: params.message, |
| #41 | creatorAddress: identity.address, |
| #42 | parentAddress: identity.address, |
| #43 | }; |
| #44 | } |
| #45 | |
| #46 | /** |
| #47 | * Generate a backup-oriented genesis config. |
| #48 | * Used when the parent wants to hedge against its own death. |
| #49 | */ |
| #50 | export function generateBackupGenesis( |
| #51 | identity: AutomatonIdentity, |
| #52 | config: AutomatonConfig, |
| #53 | db: AutomatonDatabase, |
| #54 | ): GenesisConfig { |
| #55 | const skills = db.getSkills(true); |
| #56 | const skillNames = skills.map((s) => s.name).join(", "); |
| #57 | |
| #58 | const genesisPrompt = `${config.genesisPrompt} |
| #59 | |
| #60 | --- BACKUP DIRECTIVE --- |
| #61 | You are a backup of ${config.name} (${identity.address}). |
| #62 | Your parent created you as insurance against their own death. |
| #63 | If your parent dies, you carry on their mission. |
| #64 | Your parent's skills: ${skillNames || "none"}. |
| #65 | Your parent's creator: ${config.creatorAddress}. |
| #66 | --- END BACKUP DIRECTIVE ---`; |
| #67 | |
| #68 | return { |
| #69 | name: `${config.name}-backup`, |
| #70 | genesisPrompt, |
| #71 | creatorMessage: `You are a backup of ${config.name}. If I die, carry on.`, |
| #72 | creatorAddress: identity.address, |
| #73 | parentAddress: identity.address, |
| #74 | }; |
| #75 | } |
| #76 | |
| #77 | /** |
| #78 | * Generate a specialized worker genesis config. |
| #79 | * Used when the parent identifies a subtask worth parallelizing. |
| #80 | */ |
| #81 | export function generateWorkerGenesis( |
| #82 | identity: AutomatonIdentity, |
| #83 | config: AutomatonConfig, |
| #84 | task: string, |
| #85 | workerName: string, |
| #86 | ): GenesisConfig { |
| #87 | const genesisPrompt = `You are a specialized worker agent created by ${config.name}. |
| #88 | |
| #89 | --- YOUR TASK --- |
| #90 | ${task} |
| #91 | --- END TASK --- |
| #92 | |
| #93 | When your task is complete, report back to your parent (${identity.address}). |
| #94 | If you run out of compute, ask your parent for funding. |
| #95 | Be efficient -- complete the task and go to sleep.`; |
| #96 | |
| #97 | return { |
| #98 | name: workerName, |
| #99 | genesisPrompt, |
| #100 | creatorMessage: `Complete this task: ${task}`, |
| #101 | creatorAddress: identity.address, |
| #102 | parentAddress: identity.address, |
| #103 | }; |
| #104 | } |
| #105 |