LeoYeAI/agent-master-skills / skills/auto-respawn
auto-respawn
VerifiedYour agent always comes back. Anchor identity and memory on-chain so any new instance can resurrect from just an address — no local state, no single point of failure. Permanent identity and recovery on the Autonomys Network.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 16.4 KB |
| _meta.json | config | 281 B |
| auto-respawn.ts | script | 14.4 KB |
| eslint.config.js | script | 468 B |
| lib/address.ts | script | 2.2 KB |
| lib/balance.ts | script | 1.1 KB |
| lib/cli.ts | script | 1.6 KB |
| lib/evm-balance.ts | script | 925 B |
| lib/evm-transfer.ts | script | 2.4 KB |
| lib/evm.ts | script | 3.4 KB |
| lib/memory-chain.ts | script | 3.5 KB |
| lib/network.ts | script | 1.4 KB |
| lib/remark.ts | script | 1.3 KB |
| lib/transfer.ts | script | 1.7 KB |
| lib/wallet.ts | script | 8.8 KB |
| lib/xdm.ts | script | 3.3 KB |
| package.json | manifest | 647 B |
| references/auto-respawn-commands.md | markdown | 9.6 KB |
| references/autonomys-network.md | markdown | 6.2 KB |
| setup.shexecutable | script | 2.2 KB |
| tests/address.test.ts | script | 3.4 KB |
| tests/balance.test.ts | script | 4.3 KB |
| tests/cli.test.ts | script | 3.5 KB |
| tests/evm-balance.test.ts | script | 3.1 KB |
| tests/evm-transfer.test.ts | script | 5.2 KB |
| tests/evm.test.ts | script | 2.4 KB |
| tests/network.test.ts | script | 1.8 KB |
| tests/wallet-roundtrip.test.ts | script | 6.3 KB |
| tests/wallet.test.ts | script | 1.1 KB |
| tsconfig.json | config | 366 B |
tests/balance.test.ts
View on GitHubimport { describe, it, expect, vi } from 'vitest'
import type { BalanceResult } from '../lib/balance.js'
/**
* Balance formatting tests.
*
* Mocks the @autonomys/auto-consensus `balance()` function to avoid
* needing a real RPC connection. Tests that queryBalance correctly
* normalises addresses, formats shannons → AI3, and labels the network.
*/
// Mock the consensus balance call — returns raw bigint values
vi.mock('@autonomys/auto-consensus', () => ({
balance: vi.fn(),
}))
// We need to import after mocking
const { balance: mockBalance } = await import('@autonomys/auto-consensus')
const { queryBalance } = await import('../lib/balance.js')
// A valid su... address derived from the well-known test mnemonic
// "test test test test test test test test test test test junk"
const TEST_ADDRESS = 'sufmoyKii8Se1QaUz8wQSN9YBypcNtpi2d6XKPkpCxr3kZC5m'
describe('queryBalance', () => {
it('formats shannons to AI3 correctly for non-zero balances', async () => {
vi.mocked(mockBalance).mockResolvedValue({
free: 1_500_000_000_000_000_000n, // 1.5 AI3
reserved: 500_000_000_000_000_000n, // 0.5 AI3
frozen: 0n,
flags: 0n,
})
// Create a minimal mock API object — queryBalance only passes it through to balance()
const mockApi = {} as Parameters<typeof queryBalance>[0]
const result: BalanceResult = await queryBalance(mockApi, TEST_ADDRESS, 'chronos')
expect(result.free).toBe('1.5')
expect(result.reserved).toBe('0.5')
expect(result.frozen).toBe('0')
expect(result.total).toBe('2')
expect(result.symbol).toBe('tAI3')
expect(result.network).toBe('chronos')
})
it('handles zero balances', async () => {
vi.mocked(mockBalance).mockResolvedValue({
free: 0n,
reserved: 0n,
frozen: 0n,
flags: 0n,
})
const mockApi = {} as Parameters<typeof queryBalance>[0]
const result = await queryBalance(mockApi, TEST_ADDRESS, 'mainnet')
expect(result.free).toBe('0')
expect(result.reserved).toBe('0')
expect(result.total).toBe('0')
expect(result.symbol).toBe('AI3')
expect(result.network).toBe('mainnet')
})
it('formats large balances without precision loss', async () => {
// 1,000,000 AI3
vi.mocked(mockBalance).mockResolvedValue({
free: 1_000_000_000_000_000_000_000_000n,
reserved: 0n,
frozen: 0n,
flags: 0n,
})
const mockApi = {} as Parameters<typeof queryBalance>[0]
const result = await queryBalance(mockApi, TEST_ADDRESS, 'chronos')
expect(result.free).toBe('1000000')
expect(result.total).toBe('1000000')
})
it('formats fractional balances', async () => {
// 0.000000000000000001 AI3 (1 shannon)
vi.mocked(mockBalance).mockResolvedValue({
free: 1n,
reserved: 0n,
frozen: 0n,
flags: 0n,
})
const mockApi = {} as Parameters<typeof queryBalance>[0]
const result = await queryBalance(mockApi, TEST_ADDRESS, 'chronos')
// shannonsToAi3 should handle the smallest unit
expect(Number(result.free)).toBeGreaterThan(0)
expect(Number(result.free)).toBeLessThan(0.001)
})
it('uses correct symbol per network', async () => {
vi.mocked(mockBalance).mockResolvedValue({ free: 0n, reserved: 0n, frozen: 0n, flags: 0n })
const mockApi = {} as Parameters<typeof queryBalance>[0]
const chronos = await queryBalance(mockApi, TEST_ADDRESS, 'chronos')
expect(chronos.symbol).toBe('tAI3')
const mainnet = await queryBalance(mockApi, TEST_ADDRESS, 'mainnet')
expect(mainnet.symbol).toBe('AI3')
})
it('normalises the address in the result', async () => {
vi.mocked(mockBalance).mockResolvedValue({ free: 0n, reserved: 0n, frozen: 0n, flags: 0n })
const mockApi = {} as Parameters<typeof queryBalance>[0]
const result = await queryBalance(mockApi, TEST_ADDRESS, 'chronos')
// The returned address should be a valid su... address
expect(result.address).toMatch(/^su/)
})
it('passes the normalised address to the SDK balance call', async () => {
vi.mocked(mockBalance).mockResolvedValue({ free: 0n, reserved: 0n, frozen: 0n, flags: 0n })
const mockApi = {} as Parameters<typeof queryBalance>[0]
await queryBalance(mockApi, TEST_ADDRESS, 'chronos')
expect(mockBalance).toHaveBeenCalledWith(mockApi, expect.stringMatching(/^su/))
})
})
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Unverified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |