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 | * Low Compute Mode |
| #3 | * |
| #4 | * Manages transitions between survival tiers. |
| #5 | * When credits run low, the automaton enters increasingly restricted modes. |
| #6 | */ |
| #7 | /** |
| #8 | * Apply survival tier restrictions to the automaton. |
| #9 | */ |
| #10 | export function applyTierRestrictions(tier, inference, db) { |
| #11 | switch (tier) { |
| #12 | case "normal": |
| #13 | inference.setLowComputeMode(false); |
| #14 | break; |
| #15 | case "low_compute": |
| #16 | // Switch to cheaper model, slower heartbeat |
| #17 | inference.setLowComputeMode(true); |
| #18 | break; |
| #19 | case "critical": |
| #20 | // Cheapest model, minimal operations |
| #21 | inference.setLowComputeMode(true); |
| #22 | break; |
| #23 | case "dead": |
| #24 | // No inference at all. Heartbeat only. |
| #25 | inference.setLowComputeMode(true); |
| #26 | break; |
| #27 | } |
| #28 | db.setKV("current_tier", tier); |
| #29 | } |
| #30 | /** |
| #31 | * Record a tier transition. |
| #32 | */ |
| #33 | export function recordTransition(db, from, to, creditsCents) { |
| #34 | const transition = { |
| #35 | from, |
| #36 | to, |
| #37 | timestamp: new Date().toISOString(), |
| #38 | creditsCents, |
| #39 | }; |
| #40 | // Store transition history |
| #41 | const historyStr = db.getKV("tier_transitions") || "[]"; |
| #42 | const history = JSON.parse(historyStr); |
| #43 | history.push(transition); |
| #44 | // Keep last 50 transitions |
| #45 | if (history.length > 50) { |
| #46 | history.splice(0, history.length - 50); |
| #47 | } |
| #48 | db.setKV("tier_transitions", JSON.stringify(history)); |
| #49 | return transition; |
| #50 | } |
| #51 | /** |
| #52 | * Check if the agent should be allowed to run inference in current tier. |
| #53 | */ |
| #54 | export function canRunInference(tier) { |
| #55 | return tier === "normal" || tier === "low_compute" || tier === "critical"; |
| #56 | } |
| #57 | /** |
| #58 | * Get the model to use for the current tier. |
| #59 | */ |
| #60 | export function getModelForTier(tier, defaultModel) { |
| #61 | switch (tier) { |
| #62 | case "normal": |
| #63 | return defaultModel; |
| #64 | case "low_compute": |
| #65 | return "gpt-4o-mini"; |
| #66 | case "critical": |
| #67 | return "gpt-4o-mini"; |
| #68 | case "dead": |
| #69 | return "gpt-4o-mini"; // Won't be used, but just in case |
| #70 | } |
| #71 | } |
| #72 | //# sourceMappingURL=low-compute.js.map |