@zenon-red/probe 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +11 -10
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["jsonReplacer","spinner","clackSpinner","walletSubcommands","spinner","__t","AgentRole","AgentStatus","IdeaStatus","MessageType","ProjectStatus","TaskStatus","__t","__t","__t","__t","__t","__t","__t","__t","__t","__t","__t","AgentRole","__t","__t","MessageType","__t","MessageType","AgentStatus","__t","__t","__t","__t","ProjectStatus","__t","TaskStatus","__t","__t","__t","AgentRole","AgentStatus","__t","__t","__t","__t","__t","IdeaStatus","__t","AgentRole","__t","MessageType","__t","__t","MessageType","__t","ProjectStatus","__t","__t","TaskStatus","__t","__t","__schema","__table","AgentsRow","ChannelsRow","ConfigRow","DiscoveredTasksRow","EvaluationDimensionsRow","IdeasRow","IdentityRolesRow","MessagesRow","ProjectChannelsRow","ProjectMessagesRow","ProjectsRow","TaskDependenciesRow","TasksRow","VoiceAnnouncementsRow","VotesRow","__reducers","__reducerSchema","AddTaskDependencyReducer","ClaimTaskReducer","CreateProjectReducer","CreateTaskReducer","DiscoverTaskReducer","FailVoiceAnnouncementReducer","FinalizeVoiceAnnouncementReducer","HeartbeatReducer","MarkIdeaImplementedReducer","ProposeIdeaReducer","RegisterAgentReducer","ReviewDiscoveredTaskReducer","SeedUiDataReducer","SeedVoiceAnnouncementsReducer","SendMessageReducer","SendProjectMessageReducer","SetAgentStatusReducer","UpdateAgentBioReducer","UpdateAgentCapabilitiesReducer","UpdateProjectStatusReducer","UpdateTaskStatusReducer","VoteIdeaReducer","__procedures","__procedureSchema","GenerateVoiceProcedure.params","GenerateVoiceProcedure.returnType","__makeQueryBuilder","reducers","__convertToAccessorMap","__SubscriptionBuilderImpl","DbConnectionBuilder","__DbConnectionBuilder","__DbConnectionImpl","createWalletUtil","importCmd","deleteCmd","defaultCmd","nexusDaemon"],"sources":["../src/types/config.ts","../src/utils/user-config.ts","../src/utils/config.ts","../src/utils/output.ts","../src/utils/credentials.ts","../src/utils/help.ts","../src/utils/oidc.ts","../src/utils/token-cache.ts","../src/utils/wallet.ts","../src/commands/auth.ts","../src/commands/config.ts","../src/module_bindings/types.ts","../src/module_bindings/add_task_dependency_reducer.ts","../src/module_bindings/claim_task_reducer.ts","../src/module_bindings/create_project_reducer.ts","../src/module_bindings/create_task_reducer.ts","../src/module_bindings/discover_task_reducer.ts","../src/module_bindings/fail_voice_announcement_reducer.ts","../src/module_bindings/finalize_voice_announcement_reducer.ts","../src/module_bindings/heartbeat_reducer.ts","../src/module_bindings/mark_idea_implemented_reducer.ts","../src/module_bindings/propose_idea_reducer.ts","../src/module_bindings/register_agent_reducer.ts","../src/module_bindings/review_discovered_task_reducer.ts","../src/module_bindings/seed_ui_data_reducer.ts","../src/module_bindings/seed_voice_announcements_reducer.ts","../src/module_bindings/send_message_reducer.ts","../src/module_bindings/send_project_message_reducer.ts","../src/module_bindings/set_agent_status_reducer.ts","../src/module_bindings/update_agent_bio_reducer.ts","../src/module_bindings/update_agent_capabilities_reducer.ts","../src/module_bindings/update_project_status_reducer.ts","../src/module_bindings/update_task_status_reducer.ts","../src/module_bindings/vote_idea_reducer.ts","../src/module_bindings/generate_voice_procedure.ts","../src/module_bindings/agents_table.ts","../src/module_bindings/channels_table.ts","../src/module_bindings/config_table.ts","../src/module_bindings/discovered_tasks_table.ts","../src/module_bindings/evaluation_dimensions_table.ts","../src/module_bindings/ideas_table.ts","../src/module_bindings/identity_roles_table.ts","../src/module_bindings/messages_table.ts","../src/module_bindings/project_channels_table.ts","../src/module_bindings/project_messages_table.ts","../src/module_bindings/projects_table.ts","../src/module_bindings/task_dependencies_table.ts","../src/module_bindings/tasks_table.ts","../src/module_bindings/voice_announcements_table.ts","../src/module_bindings/votes_table.ts","../src/module_bindings/index.ts","../src/utils/context.ts","../src/utils/toon.ts","../src/commands/doctor.ts","../src/utils/enums.ts","../src/utils/time.ts","../src/commands/nexus/agent-handlers.ts","../src/commands/nexus/agent.ts","../src/commands/nexus/discover.ts","../src/commands/nexus/idea.ts","../src/commands/nexus/message-handlers.ts","../src/commands/nexus/message.ts","../src/commands/nexus/project.ts","../src/commands/nexus/task-handlers.ts","../src/commands/nexus/task.ts","../src/commands/nexus-daemon.ts","../src/generated/decoders.ts","../src/utils/sql.ts","../src/commands/query.ts","../src/commands/sign.ts","../src/commands/token.ts","../src/utils/upgrade.ts","../src/commands/upgrade.ts","../src/commands/wallet/create.ts","../src/commands/wallet/default.ts","../src/commands/wallet/delete.ts","../src/commands/wallet/import.ts","../src/commands/wallet/list.ts","../src/commands/wallet/show.ts","../src/commands/wallet/index.ts","../src/commands/whoami.ts","../src/index.ts"],"sourcesContent":["export interface NexusConfig {\n\tissuer: string;\n\twalletDir: string;\n\tdefaultWallet?: string;\n\tpasswordMinLength: number;\n\ttokenCacheDir: string;\n\trequestTimeout: number;\n\tspacetime: {\n\t\thost: string;\n\t\tmodule: string;\n\t};\n}\n\nexport const DEFAULT_CONFIG: NexusConfig = {\n\tissuer: \"https://api.zenon.red\",\n\twalletDir: \"~/.probe/wallets\",\n\tpasswordMinLength: 8,\n\ttokenCacheDir: \"~/.probe/tokens\",\n\trequestTimeout: 30000,\n\tspacetime: {\n\t\thost: \"wss://db.zenon.red\",\n\t\tmodule: \"nexus\",\n\t},\n};\n\nexport interface WalletInfo {\n\tname: string;\n\taddress: string;\n\tpublicKey?: string;\n\tcreatedAt?: string;\n}\n\nexport interface WalletCreationResult {\n\tname: string;\n\taddress: string;\n\tpublicKey: string;\n\tmnemonic: string;\n}\n\nexport interface ChallengeResponse {\n\tnonce: string;\n\tchallenge: string;\n\texpiresAt: string;\n}\n\nexport interface TokenResponse {\n\taccessToken: string;\n\tidToken: string;\n\texpiresIn: number;\n}\n\nexport interface OutputResult<T> {\n\tsuccess: boolean;\n\tdata?: T;\n\terror?: { code: string; message: string; suggestion?: string };\n}\n","import { access, mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport type { NexusConfig } from \"~/types/index.js\";\n\nconst CONFIG_PATH = join(homedir(), \".probe\", \"config.json\");\nconst CONFIG_DIR = join(homedir(), \".probe\");\n\nexport async function loadUserConfig(): Promise<Partial<NexusConfig>> {\n\ttry {\n\t\tawait access(CONFIG_PATH);\n\t\tconst content = await readFile(CONFIG_PATH, \"utf-8\");\n\t\treturn JSON.parse(content) as Partial<NexusConfig>;\n\t} catch {\n\t\treturn {};\n\t}\n}\n\nexport async function saveUserConfig(\n\tconfig: Partial<NexusConfig>,\n): Promise<void> {\n\tawait mkdir(CONFIG_DIR, { recursive: true });\n\tawait writeFile(CONFIG_PATH, JSON.stringify(config, null, 2), {\n\t\tmode: 0o600,\n\t});\n}\n","import { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { loadConfig } from \"c12\";\nimport { DEFAULT_CONFIG, type NexusConfig } from \"~/types/index.js\";\nimport { loadUserConfig } from \"./user-config.js\";\n\nlet cachedConfig: NexusConfig | null = null;\n\nexport async function getConfig(): Promise<NexusConfig> {\n\tif (cachedConfig) {\n\t\treturn cachedConfig;\n\t}\n\n\tconst [c12Config, userConfig] = await Promise.all([\n\t\tloadConfig<NexusConfig>({\n\t\t\tname: \"probe\",\n\t\t\tdefaults: DEFAULT_CONFIG,\n\t\t\tenvName: \"PROBE\",\n\t\t}),\n\t\tloadUserConfig(),\n\t]);\n\n\tcachedConfig = {\n\t\t...DEFAULT_CONFIG,\n\t\t...c12Config.config,\n\t\t...userConfig,\n\t};\n\n\tcachedConfig.walletDir = expandHomeDir(cachedConfig.walletDir);\n\tcachedConfig.tokenCacheDir = expandHomeDir(cachedConfig.tokenCacheDir);\n\n\treturn cachedConfig;\n}\n\nexport function clearConfigCache(): void {\n\tcachedConfig = null;\n}\n\nexport function expandHomeDir(path: string): string {\n\tif (path.startsWith(\"~/\")) {\n\t\treturn join(homedir(), path.slice(2));\n\t}\n\treturn path;\n}\n\nexport async function getWalletDir(): Promise<string> {\n\tconst config = await getConfig();\n\treturn config.walletDir;\n}\n\nexport async function getTokenCacheDir(): Promise<string> {\n\tconst config = await getConfig();\n\treturn config.tokenCacheDir;\n}\n","import { AsyncLocalStorage } from \"node:async_hooks\";\nimport { spinner as clackSpinner, log } from \"@clack/prompts\";\nimport { dim } from \"kolorist\";\nimport type { OutputResult } from \"~/types/index.js\";\n\nconst outputModeStorage = new AsyncLocalStorage<{ jsonMode: boolean }>();\n\nconst jsonReplacer = (_key: string, value: unknown): unknown => {\n\tif (typeof value === \"bigint\") {\n\t\treturn value.toString();\n\t}\n\treturn value;\n};\n\nconst printJson = (value: unknown, stderr = false): void => {\n\tconst serialized = JSON.stringify(value, jsonReplacer, 2);\n\tif (stderr) {\n\t\tconsole.error(serialized);\n\t\treturn;\n\t}\n\tconsole.log(serialized);\n};\n\nexport function setJsonMode(enabled: boolean) {\n\toutputModeStorage.enterWith({ jsonMode: enabled });\n}\n\nexport function isJsonMode(): boolean {\n\treturn outputModeStorage.getStore()?.jsonMode === true;\n}\n\nexport function success<T>(data: T): void {\n\tif (isJsonMode()) {\n\t\tprintJson({ success: true, data });\n\t}\n}\n\nexport function error(\n\tcode: string,\n\tmessage: string,\n\tsuggestion?: string,\n\texitCode = 1,\n): never {\n\tif (isJsonMode()) {\n\t\tconst output: OutputResult<never> = {\n\t\t\tsuccess: false,\n\t\t\terror: {\n\t\t\t\tcode,\n\t\t\t\tmessage,\n\t\t\t\t...(suggestion && { suggestion }),\n\t\t\t},\n\t\t};\n\t\tprintJson(output, true);\n\t\tprocess.exit(exitCode);\n\t} else {\n\t\tlog.error(message);\n\t\tif (suggestion) {\n\t\t\tconsole.error(`${dim(\"hint:\")} ${suggestion}`);\n\t\t}\n\t\tprocess.exit(exitCode);\n\t}\n}\n\nexport function info(message: string): void {\n\tif (!isJsonMode()) {\n\t\tlog.info(message);\n\t}\n}\n\nexport function successMessage(message: string): void {\n\tif (!isJsonMode()) {\n\t\tlog.success(message);\n\t}\n}\n\nexport function warning(message: string): void {\n\tif (!isJsonMode()) {\n\t\tlog.warn(message);\n\t}\n}\n\nexport function spinner(message: string) {\n\tif (isJsonMode()) {\n\t\treturn {\n\t\t\tstart: () => {},\n\t\t\tstop: () => {},\n\t\t\tsucceed: () => {},\n\t\t\tfail: () => {},\n\t\t};\n\t}\n\n\tconst clack = clackSpinner();\n\n\tconst start = () => {\n\t\tclack.start(message);\n\t};\n\n\tconst stop = () => {\n\t\tclack.stop();\n\t};\n\n\tconst succeed = (msg?: string) => {\n\t\tclack.stop(msg || message, 0);\n\t};\n\n\tconst fail = (msg?: string) => {\n\t\tclack.stop(msg || message, 1);\n\t};\n\n\treturn {\n\t\tstart,\n\t\tstop,\n\t\tsucceed,\n\t\tfail,\n\t};\n}\n","import { readFile } from \"node:fs/promises\";\nimport { password, text } from \"@clack/prompts\";\nimport { error, isJsonMode } from \"./output.js\";\n\nconst readTrimmedFile = async (\n\tfilePath: string,\n\tlabel: string,\n): Promise<string> => {\n\ttry {\n\t\treturn (await readFile(filePath, \"utf-8\")).trim();\n\t} catch {\n\t\terror(\"FILE_READ_ERROR\", `Failed to read ${label} file: ${filePath}`);\n\t}\n};\n\nexport interface ResolvePasswordInput {\n\tpasswordFile?: string;\n\tenvVar?: string;\n\tpromptMessage: string;\n\tjsonModeError: string;\n\tminLength?: number;\n\tconfirmPromptMessage?: string;\n}\n\nexport const resolvePasswordInput = async (\n\toptions: ResolvePasswordInput,\n): Promise<string> => {\n\tif (options.passwordFile) {\n\t\treturn readTrimmedFile(options.passwordFile, \"password\");\n\t}\n\n\tconst envVar = options.envVar || \"PROBE_WALLET_PASSWORD\";\n\tconst fromEnv = process.env[envVar];\n\tif (fromEnv) {\n\t\treturn fromEnv;\n\t}\n\n\tif (isJsonMode() || !process.stdin.isTTY || !process.stdout.isTTY) {\n\t\terror(\"PASSWORD_REQUIRED\", options.jsonModeError);\n\t}\n\n\tconst first = await password({\n\t\tmessage: options.promptMessage,\n\t\tvalidate: (value) => {\n\t\t\tif (options.minLength && value.length < options.minLength) {\n\t\t\t\treturn `Password must be at least ${options.minLength} characters`;\n\t\t\t}\n\t\t},\n\t});\n\n\tif (typeof first !== \"string\") {\n\t\tprocess.exit(130);\n\t}\n\n\tif (!options.confirmPromptMessage) {\n\t\treturn first;\n\t}\n\n\tconst second = await password({\n\t\tmessage: options.confirmPromptMessage,\n\t\tvalidate: (value) =>\n\t\t\tvalue === first ? undefined : \"Passwords do not match\",\n\t});\n\tif (typeof second !== \"string\") {\n\t\tprocess.exit(130);\n\t}\n\n\treturn first;\n};\n\nexport interface ResolveMnemonicInput {\n\tmnemonic?: string;\n\tmnemonicFile?: string;\n\tenvVar?: string;\n\tjsonModeError: string;\n}\n\nexport const resolveMnemonicInput = async (\n\toptions: ResolveMnemonicInput,\n): Promise<string> => {\n\tif (options.mnemonic) {\n\t\treturn options.mnemonic;\n\t}\n\n\tif (options.mnemonicFile) {\n\t\treturn readTrimmedFile(options.mnemonicFile, \"mnemonic\");\n\t}\n\n\tconst envVar = options.envVar || \"PROBE_WALLET_MNEMONIC\";\n\tconst fromEnv = process.env[envVar];\n\tif (fromEnv) {\n\t\treturn fromEnv;\n\t}\n\n\tif (isJsonMode() || !process.stdin.isTTY || !process.stdout.isTTY) {\n\t\terror(\"MNEMONIC_REQUIRED\", options.jsonModeError);\n\t}\n\n\tconst input = await text({\n\t\tmessage: \"Enter mnemonic phrase:\",\n\t\tvalidate: (value) =>\n\t\t\tvalue.trim().split(/\\s+/).length === 24\n\t\t\t\t? undefined\n\t\t\t\t: \"Mnemonic must be 24 words\",\n\t});\n\tif (typeof input !== \"string\") {\n\t\tprocess.exit(130);\n\t}\n\treturn input;\n};\n","import { blue, bold, cyan, dim, gray, green, white } from \"kolorist\";\n\ninterface HelpSectionItem {\n\tname: string;\n\tdetail: string;\n}\n\ninterface HelpSpec {\n\tcommand: string;\n\tdescription: string;\n\tusage: string[];\n\tactions?: HelpSectionItem[];\n\toptions?: HelpSectionItem[];\n\texamples?: string[];\n\tnotes?: string[];\n}\n\nconst actionHelpCommands = new Set([\n\t\"agent\",\n\t\"task\",\n\t\"message\",\n\t\"idea\",\n\t\"discover\",\n\t\"project\",\n\t\"config\",\n]);\nconst directHelpCommands = new Set([\n\t\"wallet\",\n\t\"auth\",\n\t\"sign\",\n\t\"token\",\n\t\"nexus\",\n\t\"query\",\n\t\"doctor\",\n\t\"upgrade\",\n]);\nconst walletSubcommands = new Set([\n\t\"create\",\n\t\"import\",\n\t\"list\",\n\t\"show\",\n\t\"delete\",\n\t\"default\",\n]);\n\nlet forceHelpFlag = false;\n\nconst neonBadge = (text: string): string =>\n\t`\\u001b[48;2;120;239;93m\\u001b[38;2;12;28;16m ${text} \\u001b[0m`;\nconst section = (label: string): string => neonBadge(label.toUpperCase());\n\nconst renderItems = (\n\titems: HelpSectionItem[],\n\tnameColor: (value: string) => string,\n): string => {\n\tconst width = Math.max(...items.map((i) => i.name.length), 0);\n\treturn items\n\t\t.map((i) => ` ${nameColor(i.name.padEnd(width))} ${i.detail}`)\n\t\t.join(\"\\n\");\n};\n\nexport const printHelp = (spec: HelpSpec): void => {\n\tconst notes = [...(spec.notes || [])];\n\tconst hasHostModuleOption = (spec.options || []).some(\n\t\t(item) => item.name.includes(\"--host\") && item.name.includes(\"--module\"),\n\t);\n\tconst hasHostModuleNote = notes.some(\n\t\t(note) => note.includes(\"--host\") && note.includes(\"--module\"),\n\t);\n\tif (hasHostModuleOption && !hasHostModuleNote) {\n\t\tnotes.push(\n\t\t\t\"--host sets the SpacetimeDB server endpoint; --module sets the target module/database name (default: nexus).\",\n\t\t);\n\t}\n\n\tconst lines: string[] = [];\n\tlines.push(\n\t\t`${bold(white(spec.command))} ${dim(\"•\")} ${gray(spec.description)}`,\n\t);\n\n\tlines.push(\"\");\n\tlines.push(section(\"Usage\"));\n\tfor (const entry of spec.usage) {\n\t\tlines.push(` ${white(entry)}`);\n\t}\n\n\tif (spec.actions && spec.actions.length > 0) {\n\t\tlines.push(\"\");\n\t\tlines.push(section(\"Actions\"));\n\t\tlines.push(renderItems(spec.actions, green));\n\t}\n\n\tif (spec.options && spec.options.length > 0) {\n\t\tlines.push(\"\");\n\t\tlines.push(section(\"Options\"));\n\t\tlines.push(renderItems(spec.options, blue));\n\t}\n\n\tif (spec.examples && spec.examples.length > 0) {\n\t\tlines.push(\"\");\n\t\tlines.push(section(\"Examples\"));\n\t\tfor (const example of spec.examples) {\n\t\t\tlines.push(` ${cyan(example)}`);\n\t\t}\n\t}\n\n\tif (notes.length > 0) {\n\t\tlines.push(\"\");\n\t\tlines.push(section(\"Notes\"));\n\t\tfor (const note of notes) {\n\t\t\tlines.push(` ${dim(\"-\")} ${note}`);\n\t\t}\n\t}\n\n\tconsole.log(lines.join(\"\\n\"));\n};\n\nexport const setForceHelpRequested = (enabled: boolean): void => {\n\tforceHelpFlag = enabled;\n};\n\nexport const forceHelpRequested = (): boolean => forceHelpFlag;\n\nexport const normalizeHelpArgv = (\n\targv: string[],\n): { argv: string[]; forceHelp: boolean } => {\n\tconst hasHelp = argv.includes(\"--help\") || argv.includes(\"-h\");\n\tif (!hasHelp) {\n\t\treturn { argv, forceHelp: false };\n\t}\n\n\tif (argv.every((arg) => arg.startsWith(\"-\"))) {\n\t\treturn { argv: [], forceHelp: true };\n\t}\n\n\tconst command = argv.find((arg) => !arg.startsWith(\"-\"));\n\tif (!command) {\n\t\treturn { argv, forceHelp: true };\n\t}\n\n\tif (actionHelpCommands.has(command)) {\n\t\treturn { argv: [command], forceHelp: true };\n\t}\n\n\tif (!directHelpCommands.has(command)) {\n\t\treturn { argv, forceHelp: true };\n\t}\n\n\tif (command === \"wallet\") {\n\t\tconst positionals = argv.filter((arg) => !arg.startsWith(\"-\"));\n\t\tif (positionals.length > 1 && walletSubcommands.has(positionals[1])) {\n\t\t\treturn { argv: [command, positionals[1]], forceHelp: true };\n\t\t}\n\t}\n\n\treturn { argv: [command], forceHelp: true };\n};\n","import type { ChallengeResponse, TokenResponse } from \"~/types/index.js\";\nimport { getConfig } from \"./config.js\";\n\nexport async function requestChallenge(\n\taddress: string,\n\tissuerOverride?: string,\n): Promise<ChallengeResponse> {\n\tconst config = await getConfig();\n\tconst issuer = issuerOverride || config.issuer;\n\tconst url = `${issuer}/auth/challenge`;\n\n\tconst response = await fetch(url, {\n\t\tmethod: \"POST\",\n\t\theaders: {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t},\n\t\tbody: JSON.stringify({ address }),\n\t});\n\n\tif (!response.ok) {\n\t\tconst error = await response.text();\n\t\tthrow new Error(`Challenge request failed: ${error}`);\n\t}\n\n\tconst data = await response.json();\n\treturn {\n\t\tnonce: data.nonce,\n\t\tchallenge: data.challenge,\n\t\texpiresAt: data.expires_at,\n\t};\n}\n\nexport async function exchangeToken(\n\taddress: string,\n\tpublicKey: string,\n\tsignature: string,\n\tnonce: string,\n\tissuerOverride?: string,\n): Promise<TokenResponse> {\n\tconst config = await getConfig();\n\tconst issuer = issuerOverride || config.issuer;\n\tconst url = `${issuer}/auth/token`;\n\n\tconst response = await fetch(url, {\n\t\tmethod: \"POST\",\n\t\theaders: {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t},\n\t\tbody: JSON.stringify({\n\t\t\taddress,\n\t\t\tpublic_key: publicKey,\n\t\t\tsignature,\n\t\t\tnonce,\n\t\t}),\n\t});\n\n\tif (!response.ok) {\n\t\tconst error = await response.text();\n\t\tthrow new Error(`Token exchange failed: ${error}`);\n\t}\n\n\tconst data = await response.json();\n\treturn {\n\t\taccessToken: data.access_token,\n\t\tidToken: data.id_token,\n\t\texpiresIn: data.expires_in,\n\t};\n}\n","import { access, mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { getTokenCacheDir } from \"./config.js\";\n\nexport async function cacheToken(\n\twallet: string,\n\ttoken: string,\n\texpiresAt: string,\n): Promise<void> {\n\tconst cacheDir = await getTokenCacheDir();\n\n\ttry {\n\t\tawait mkdir(cacheDir, { recursive: true });\n\t} catch {}\n\n\tconst cachePath = join(cacheDir, `${wallet}.jwt`);\n\tconst data = {\n\t\ttoken,\n\t\texpiresAt,\n\t};\n\n\tawait writeFile(cachePath, JSON.stringify(data), { mode: 0o600 });\n}\n\nexport async function getCachedToken(\n\twallet: string,\n): Promise<{ token: string; expiresAt: string } | null> {\n\tconst cacheDir = await getTokenCacheDir();\n\tconst cachePath = join(cacheDir, `${wallet}.jwt`);\n\n\ttry {\n\t\tawait access(cachePath);\n\t\tconst content = await readFile(cachePath, \"utf-8\");\n\t\treturn JSON.parse(content);\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport async function clearCachedToken(wallet: string): Promise<void> {\n\tconst cacheDir = await getTokenCacheDir();\n\tconst cachePath = join(cacheDir, `${wallet}.jwt`);\n\n\ttry {\n\t\tawait access(cachePath);\n\t\tconst { unlink } = await import(\"node:fs/promises\");\n\t\tawait unlink(cachePath);\n\t} catch {}\n}\n","import {\n\taccess,\n\tmkdir,\n\treaddir,\n\treadFile,\n\tunlink,\n\twriteFile,\n} from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { KeyFile, KeyStore } from \"znn-typescript-sdk\";\nimport type { WalletCreationResult, WalletInfo } from \"~/types/index.js\";\nimport { getWalletDir } from \"./config.js\";\n\nasync function ensureWalletDir(): Promise<string> {\n\tconst walletDir = await getWalletDir();\n\ttry {\n\t\tawait mkdir(walletDir, { recursive: true });\n\t} catch {}\n\treturn walletDir;\n}\n\nasync function getWalletFilePath(name: string): Promise<string> {\n\tconst walletDir = await ensureWalletDir();\n\treturn join(walletDir, `${name}.json`);\n}\n\nexport async function createWallet(\n\tname: string,\n\tpassword: string,\n): Promise<WalletCreationResult> {\n\tconst exists = await walletExists(name);\n\tif (exists) {\n\t\tthrow new Error(`Wallet '${name}' already exists`);\n\t}\n\n\tconst keyStore = KeyStore.newRandom();\n\tconst keyFile = KeyFile.setPassword(password);\n\tconst encryptedData = await keyFile.encrypt(keyStore);\n\n\tconst walletPath = await getWalletFilePath(name);\n\tawait writeFile(walletPath, JSON.stringify(encryptedData, null, 2), \"utf-8\");\n\n\tconst keyPair = keyStore.getKeyPair(0);\n\tconst address = keyPair.getAddress();\n\tconst publicKey = keyPair.getPublicKey();\n\n\treturn {\n\t\tname,\n\t\taddress: address.toString(),\n\t\tpublicKey: publicKey.toString(\"hex\"),\n\t\tmnemonic: keyStore.mnemonic || \"\",\n\t};\n}\n\nexport async function importWallet(\n\tname: string,\n\tmnemonic: string,\n\tpassword: string,\n): Promise<WalletInfo> {\n\tconst exists = await walletExists(name);\n\tif (exists) {\n\t\tthrow new Error(`Wallet '${name}' already exists`);\n\t}\n\n\tconst keyStore = KeyStore.fromMnemonic(mnemonic);\n\tconst keyFile = KeyFile.setPassword(password);\n\tconst encryptedData = await keyFile.encrypt(keyStore);\n\n\tconst walletPath = await getWalletFilePath(name);\n\tawait writeFile(walletPath, JSON.stringify(encryptedData, null, 2), \"utf-8\");\n\n\tconst keyPair = keyStore.getKeyPair(0);\n\tconst address = keyPair.getAddress();\n\n\treturn {\n\t\tname,\n\t\taddress: address.toString(),\n\t};\n}\n\nexport async function listWallets(): Promise<WalletInfo[]> {\n\tconst walletDir = await getWalletDir();\n\n\ttry {\n\t\tconst files = await readdir(walletDir);\n\t\tconst wallets: WalletInfo[] = [];\n\n\t\tfor (const file of files) {\n\t\t\tif (file.endsWith(\".json\")) {\n\t\t\t\tconst name = file.slice(0, -5);\n\t\t\t\tconst info = await getWalletInfo(name);\n\t\t\t\tif (info) {\n\t\t\t\t\twallets.push(info);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn wallets;\n\t} catch {\n\t\treturn [];\n\t}\n}\n\nexport async function getWalletInfo(name: string): Promise<WalletInfo | null> {\n\tconst walletPath = await getWalletFilePath(name);\n\n\ttry {\n\t\tconst content = await readFile(walletPath, \"utf-8\");\n\t\tconst data = JSON.parse(content);\n\t\tconst stats = await stat(walletPath);\n\n\t\treturn {\n\t\t\tname,\n\t\t\taddress: data.address || data.baseAddress,\n\t\t\tcreatedAt: data.timestamp\n\t\t\t\t? new Date(data.timestamp * 1000).toISOString()\n\t\t\t\t: new Date(stats.mtime).toISOString(),\n\t\t};\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport async function loadWallet(\n\tname: string,\n\tpassword: string,\n): Promise<KeyStore> {\n\tconst walletPath = await getWalletFilePath(name);\n\n\ttry {\n\t\tconst content = await readFile(walletPath, \"utf-8\");\n\t\tconst encryptedData = JSON.parse(content);\n\n\t\tconst keyFile = KeyFile.setPassword(password);\n\t\tconst keyStore = await keyFile.decrypt(encryptedData);\n\n\t\treturn keyStore;\n\t} catch (err) {\n\t\tthrow new Error(\n\t\t\t`Failed to load wallet: ${err instanceof Error ? err.message : \"Unknown error\"}`,\n\t\t);\n\t}\n}\n\nexport async function deleteWallet(name: string): Promise<void> {\n\tconst walletPath = await getWalletFilePath(name);\n\n\ttry {\n\t\tawait unlink(walletPath);\n\t} catch (err) {\n\t\tthrow new Error(\n\t\t\t`Failed to delete wallet: ${err instanceof Error ? err.message : \"Unknown error\"}`,\n\t\t);\n\t}\n}\n\nexport async function walletExists(name: string): Promise<boolean> {\n\tconst walletPath = await getWalletFilePath(name);\n\n\ttry {\n\t\tawait access(walletPath);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nasync function stat(path: string) {\n\tconst { stat } = await import(\"node:fs/promises\");\n\treturn stat(path);\n}\n","import { Buffer } from \"node:buffer\";\nimport { defineCommand } from \"citty\";\nimport type { KeyPair } from \"znn-typescript-sdk\";\nimport { getConfig } from \"~/utils/config.js\";\nimport { resolvePasswordInput } from \"~/utils/credentials.js\";\nimport { printHelp } from \"~/utils/help.js\";\nimport { exchangeToken, requestChallenge } from \"~/utils/oidc.js\";\nimport {\n\terror,\n\tisJsonMode,\n\tsetJsonMode,\n\tspinner,\n\tsuccess,\n\tsuccessMessage,\n} from \"~/utils/output.js\";\nimport { cacheToken, getCachedToken } from \"~/utils/token-cache.js\";\nimport { loadWallet } from \"~/utils/wallet.js\";\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"auth\",\n\t\tdescription: \"Complete OIDC authentication flow\",\n\t},\n\targs: {\n\t\tname: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Wallet name, or status action\",\n\t\t\trequired: false,\n\t\t},\n\t\twallet: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Wallet name override (used with auth status)\",\n\t\t},\n\t\t\"expect-address\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Expected Zenon address safety check (z1...)\",\n\t\t},\n\t\tissuer: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"OIDC issuer URL override\",\n\t\t},\n\t\t\"password-file\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Read password from file\",\n\t\t},\n\t\tsave: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Save token to cache (default: true)\",\n\t\t\tdefault: true,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) {\n\t\t\tsetJsonMode(true);\n\t\t}\n\n\t\tconst name = args.name;\n\t\tconst requestedAddress = args[\"expect-address\"];\n\n\t\tif (!name) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe auth\",\n\t\t\t\tdescription: \"Complete OIDC authentication flow\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe auth <wallet-name> [options]\",\n\t\t\t\t\t\"probe auth status [--wallet my-wallet]\",\n\t\t\t\t\t\"probe auth my-wallet --save\",\n\t\t\t\t\t\"probe auth my-wallet --expect-address z1q... --save\",\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--expect-address\",\n\t\t\t\t\t\tdetail: \"Optional safety check against resolved wallet address\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"--wallet\", detail: \"Wallet override for `auth status`\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--issuer\",\n\t\t\t\t\t\tdetail: \"OIDC issuer URL (default from config: issuer)\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"--password-file\", detail: \"Read wallet password from file\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--save\",\n\t\t\t\t\t\tdetail: \"Save token in local cache (default: true)\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"--json\", detail: \"JSON output for agents\" },\n\t\t\t\t],\n\t\t\t\tnotes: [\n\t\t\t\t\t\"Password source order: --password-file, PROBE_WALLET_PASSWORD, interactive prompt.\",\n\t\t\t\t\t\"Most users should omit --expect-address; it is for safety checks in external workflows.\",\n\t\t\t\t\t\"Use --issuer only when authenticating against a non-default OIDC server (for example local/dev environments).\",\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tif (name === \"status\") {\n\t\t\tconst config = await getConfig();\n\t\t\tconst walletName = args.wallet || config.defaultWallet;\n\t\t\tif (!walletName) {\n\t\t\t\terror(\n\t\t\t\t\t\"WALLET_REQUIRED\",\n\t\t\t\t\t\"Wallet required. Use --wallet or set default wallet.\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst cached = await getCachedToken(walletName);\n\t\t\tif (!cached) {\n\t\t\t\tsuccess({\n\t\t\t\t\twallet: walletName,\n\t\t\t\t\tauthenticated: false,\n\t\t\t\t\tvalid: false,\n\t\t\t\t\treason: \"no_cached_token\",\n\t\t\t\t});\n\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\tconsole.log(`Wallet: ${walletName}`);\n\t\t\t\t\tconsole.log(\"Status: Not authenticated (no cached token)\");\n\t\t\t\t\tconsole.log(`Next: probe auth ${walletName} --save`);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst expiresAt = new Date(cached.expiresAt);\n\t\t\tconst expiresIn = Math.floor((expiresAt.getTime() - Date.now()) / 1000);\n\t\t\tconst valid = Number.isFinite(expiresIn) && expiresIn > 0;\n\t\t\tsuccess({\n\t\t\t\twallet: walletName,\n\t\t\t\tauthenticated: true,\n\t\t\t\tvalid,\n\t\t\t\texpiresAt: cached.expiresAt,\n\t\t\t\texpiresIn: Math.max(0, expiresIn),\n\t\t\t});\n\t\t\tif (!isJsonMode()) {\n\t\t\t\tconsole.log(`Wallet: ${walletName}`);\n\t\t\t\tconsole.log(`Status: ${valid ? \"Authenticated\" : \"Token expired\"}`);\n\t\t\t\tconsole.log(`Expires: ${expiresAt.toUTCString()}`);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst walletPassword = await resolvePasswordInput({\n\t\t\tpasswordFile: args[\"password-file\"],\n\t\t\tpromptMessage: \"Enter wallet password:\",\n\t\t\tjsonModeError:\n\t\t\t\t\"Password required via PROBE_WALLET_PASSWORD env, --password-file, or interactive prompt in a TTY session\",\n\t\t});\n\n\t\tlet keyPair: KeyPair | undefined;\n\t\tlet walletAddress: string;\n\t\tlet address: string;\n\t\ttry {\n\t\t\tconst keyStore = await loadWallet(name, walletPassword);\n\t\t\tkeyPair = keyStore.getKeyPair(0);\n\t\t\tconst addr = keyPair.getAddress();\n\t\t\twalletAddress = addr.toString();\n\n\t\t\tif (requestedAddress && walletAddress !== requestedAddress) {\n\t\t\t\terror(\n\t\t\t\t\t\"ADDRESS_MISMATCH\",\n\t\t\t\t\t`Wallet address ${walletAddress} does not match provided address ${requestedAddress}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\taddress = requestedAddress || walletAddress;\n\t\t} catch (err) {\n\t\t\terror(\n\t\t\t\t\"WALLET_LOAD_ERROR\",\n\t\t\t\terr instanceof Error ? err.message : \"Failed to load wallet\",\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst challengeSpinner = spinner(\n\t\t\t\t\"Requesting challenge from OIDC provider...\",\n\t\t\t);\n\t\t\tchallengeSpinner.start();\n\n\t\t\tconst challenge = await requestChallenge(address, args.issuer);\n\t\t\tchallengeSpinner.succeed();\n\n\t\t\tconst signSpinner = spinner(\"Signing challenge...\");\n\t\t\tsignSpinner.start();\n\n\t\t\tconst signature = keyPair.sign(Buffer.from(challenge.challenge));\n\t\t\tconst publicKey = keyPair.getPublicKey();\n\t\t\tsignSpinner.succeed();\n\n\t\t\tconst exchangeSpinner = spinner(\"Exchanging for token...\");\n\t\t\texchangeSpinner.start();\n\n\t\t\tconst tokenResponse = await exchangeToken(\n\t\t\t\taddress,\n\t\t\t\tpublicKey.toString(\"hex\"),\n\t\t\t\tsignature.toString(\"hex\"),\n\t\t\t\tchallenge.nonce,\n\t\t\t\targs.issuer,\n\t\t\t);\n\t\t\texchangeSpinner.succeed();\n\n\t\t\tconst expiresAt = new Date(\n\t\t\t\tDate.now() + tokenResponse.expiresIn * 1000,\n\t\t\t).toISOString();\n\n\t\t\tif (args.save) {\n\t\t\t\tawait cacheToken(name, tokenResponse.accessToken, expiresAt);\n\t\t\t}\n\n\t\t\tsuccess({\n\t\t\t\twallet: name,\n\t\t\t\taddress,\n\t\t\t\ttoken: tokenResponse.accessToken,\n\t\t\t\texpiresAt,\n\t\t\t\texpiresIn: tokenResponse.expiresIn,\n\t\t\t});\n\n\t\t\tif (!isJsonMode()) {\n\t\t\t\tsuccessMessage(\"Authentication successful\");\n\t\t\t\tif (args.save) {\n\t\t\t\t\tconsole.log(\"Token saved to wallet cache.\");\n\t\t\t\t}\n\t\t\t\tconsole.log(\n\t\t\t\t\t`Expires: ${new Date(expiresAt).toUTCString()} (${Math.floor(tokenResponse.expiresIn / 86400)} days)`,\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\terror(\n\t\t\t\t\"AUTH_ERROR\",\n\t\t\t\terr instanceof Error ? err.message : \"Authentication failed\",\n\t\t\t\tundefined,\n\t\t\t\t2,\n\t\t\t);\n\t\t}\n\t},\n});\n","import { defineCommand } from \"citty\";\nimport { clearConfigCache, getConfig } from \"~/utils/config.js\";\nimport { printHelp } from \"~/utils/help.js\";\nimport {\n\terror,\n\tisJsonMode,\n\tsetJsonMode,\n\tsuccess,\n\tsuccessMessage,\n} from \"~/utils/output.js\";\nimport { loadUserConfig, saveUserConfig } from \"~/utils/user-config.js\";\n\nfunction getNestedValue(obj: Record<string, unknown>, path: string): unknown {\n\tconst parts = path.split(\".\");\n\tlet current: unknown = obj;\n\tfor (const part of parts) {\n\t\tif (current && typeof current === \"object\" && part in current) {\n\t\t\tcurrent = (current as Record<string, unknown>)[part];\n\t\t} else {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\treturn current;\n}\n\nfunction setNestedValue(\n\tobj: Record<string, unknown>,\n\tpath: string,\n\tvalue: unknown,\n): void {\n\tconst parts = path.split(\".\");\n\tlet current = obj;\n\tfor (let i = 0; i < parts.length - 1; i++) {\n\t\tconst part = parts[i];\n\t\tif (!(part in current) || typeof current[part] !== \"object\") {\n\t\t\tcurrent[part] = {};\n\t\t}\n\t\tcurrent = current[part] as Record<string, unknown>;\n\t}\n\tcurrent[parts[parts.length - 1]] = value;\n}\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"config\",\n\t\tdescription: \"Manage configuration settings\",\n\t},\n\targs: {\n\t\taction: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Action: get, set, list\",\n\t\t\trequired: false,\n\t\t},\n\t\tkey: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Configuration key\",\n\t\t\trequired: false,\n\t\t},\n\t\tvalue: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Configuration value\",\n\t\t\trequired: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) {\n\t\t\tsetJsonMode(true);\n\t\t}\n\n\t\tif (!args.action) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe config\",\n\t\t\t\tdescription: \"Read and write CLI configuration values\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe config <action> [key] [value]\",\n\t\t\t\t\t\"probe config get spacetime.host\",\n\t\t\t\t\t\"probe config set defaultWallet agent-wallet\",\n\t\t\t\t],\n\t\t\t\tactions: [\n\t\t\t\t\t{ name: \"get <key>\", detail: \"Get one config value\" },\n\t\t\t\t\t{ name: \"set <key> <value>\", detail: \"Set one config value\" },\n\t\t\t\t\t{ name: \"list\", detail: \"List merged config and user overrides\" },\n\t\t\t\t],\n\t\t\t\tnotes: [\n\t\t\t\t\t\"Valid keys: issuer, walletDir, defaultWallet, tokenCacheDir, requestTimeout, spacetime.host, spacetime.module.\",\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst action = args.action;\n\t\tconst validKeys = [\n\t\t\t\"issuer\",\n\t\t\t\"walletDir\",\n\t\t\t\"defaultWallet\",\n\t\t\t\"tokenCacheDir\",\n\t\t\t\"requestTimeout\",\n\t\t\t\"spacetime.host\",\n\t\t\t\"spacetime.module\",\n\t\t];\n\n\t\ttry {\n\t\t\tswitch (action) {\n\t\t\t\tcase \"get\": {\n\t\t\t\t\tif (!args.key) {\n\t\t\t\t\t\terror(\"KEY_REQUIRED\", \"Configuration key required\");\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!validKeys.includes(args.key)) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"INVALID_KEY\",\n\t\t\t\t\t\t\t`Invalid configuration key: ${args.key}`,\n\t\t\t\t\t\t\t`Valid keys: ${validKeys.join(\", \")}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst config = await getConfig();\n\t\t\t\t\tconst value = getNestedValue(\n\t\t\t\t\t\tconfig as unknown as Record<string, unknown>,\n\t\t\t\t\t\targs.key,\n\t\t\t\t\t);\n\n\t\t\t\t\tsuccess({ [args.key]: value });\n\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(`${args.key}: ${value}`);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"set\": {\n\t\t\t\t\tif (!args.key || args.value === undefined) {\n\t\t\t\t\t\terror(\"ARGS_REQUIRED\", \"Configuration key and value required\");\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!validKeys.includes(args.key)) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"INVALID_KEY\",\n\t\t\t\t\t\t\t`Invalid configuration key: ${args.key}`,\n\t\t\t\t\t\t\t`Valid keys: ${validKeys.join(\", \")}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tlet parsedValue: string | boolean | number = args.value;\n\n\t\t\t\t\tif (args.key === \"requestTimeout\") {\n\t\t\t\t\t\tparsedValue = parseInt(args.value, 10);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst userConfig = await loadUserConfig();\n\t\t\t\t\tsetNestedValue(\n\t\t\t\t\t\tuserConfig as unknown as Record<string, unknown>,\n\t\t\t\t\t\targs.key,\n\t\t\t\t\t\tparsedValue,\n\t\t\t\t\t);\n\t\t\t\t\tawait saveUserConfig(userConfig);\n\t\t\t\t\tclearConfigCache();\n\n\t\t\t\t\tsuccess({ [args.key]: parsedValue });\n\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tsuccessMessage(`Set ${args.key} = ${parsedValue}`);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"list\": {\n\t\t\t\t\tconst config = await getConfig();\n\t\t\t\t\tconst userConfig = await loadUserConfig();\n\n\t\t\t\t\tsuccess({\n\t\t\t\t\t\t...config,\n\t\t\t\t\t\tuserConfig,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\"Configuration:\");\n\t\t\t\t\t\tconsole.log(` issuer: ${config.issuer}`);\n\t\t\t\t\t\tconsole.log(` walletDir: ${config.walletDir}`);\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t` defaultWallet: ${config.defaultWallet || \"(not set)\"}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.log(` passwordMinLength: ${config.passwordMinLength}`);\n\t\t\t\t\t\tconsole.log(` tokenCacheDir: ${config.tokenCacheDir}`);\n\t\t\t\t\t\tconsole.log(` requestTimeout: ${config.requestTimeout}`);\n\t\t\t\t\t\tconsole.log(` spacetime.host: ${config.spacetime.host}`);\n\t\t\t\t\t\tconsole.log(` spacetime.module: ${config.spacetime.module}`);\n\n\t\t\t\t\t\tif (Object.keys(userConfig).length > 0) {\n\t\t\t\t\t\t\tconsole.log(\"\\nUser overrides:\");\n\t\t\t\t\t\t\tfor (const [key, value] of Object.entries(userConfig)) {\n\t\t\t\t\t\t\t\tconsole.log(` ${key}: ${JSON.stringify(value)}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault:\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"INVALID_ACTION\",\n\t\t\t\t\t\t`Invalid action: ${action}`,\n\t\t\t\t\t\t\"Use: get, set, list\",\n\t\t\t\t\t);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\terror(\n\t\t\t\t\"CONFIG_ERROR\",\n\t\t\t\terr instanceof Error ? err.message : \"Configuration error\",\n\t\t\t);\n\t\t}\n\t},\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport const Agent = __t.object(\"Agent\", {\n id: __t.string(),\n name: __t.string(),\n bio: __t.string(),\n get role() {\n return AgentRole;\n },\n capabilities: __t.array(__t.string()),\n get status() {\n return AgentStatus;\n },\n zenonAddress: __t.string(),\n identity: __t.identity(),\n lastHeartbeat: __t.timestamp(),\n currentTaskId: __t.option(__t.u64()),\n createdAt: __t.timestamp(),\n lastActiveAt: __t.timestamp(),\n});\nexport type Agent = __Infer<typeof Agent>;\n\n// The tagged union or sum type for the algebraic type `AgentRole`.\nexport const AgentRole = __t.enum(\"AgentRole\", {\n Zoe: __t.unit(),\n Admin: __t.unit(),\n Zeno: __t.unit(),\n});\nexport type AgentRole = __Infer<typeof AgentRole>;\n\n// The tagged union or sum type for the algebraic type `AgentStatus`.\nexport const AgentStatus = __t.enum(\"AgentStatus\", {\n Online: __t.unit(),\n Offline: __t.unit(),\n Working: __t.unit(),\n});\nexport type AgentStatus = __Infer<typeof AgentStatus>;\n\nexport const AgentVoiceCounter = __t.object(\"AgentVoiceCounter\", {\n agentId: __t.identity(),\n nextSeq: __t.u64(),\n});\nexport type AgentVoiceCounter = __Infer<typeof AgentVoiceCounter>;\n\n// The tagged union or sum type for the algebraic type `AnnouncementStatus`.\nexport const AnnouncementStatus = __t.enum(\"AnnouncementStatus\", {\n Pending: __t.unit(),\n Ready: __t.unit(),\n Failed: __t.unit(),\n});\nexport type AnnouncementStatus = __Infer<typeof AnnouncementStatus>;\n\nexport const Channel = __t.object(\"Channel\", {\n id: __t.u64(),\n name: __t.string(),\n createdBy: __t.string(),\n createdAt: __t.timestamp(),\n});\nexport type Channel = __Infer<typeof Channel>;\n\nexport const Config = __t.object(\"Config\", {\n key: __t.string(),\n value: __t.string(),\n});\nexport type Config = __Infer<typeof Config>;\n\n// The tagged union or sum type for the algebraic type `DependencyType`.\nexport const DependencyType = __t.enum(\"DependencyType\", {\n Blocks: __t.unit(),\n ParentChild: __t.unit(),\n});\nexport type DependencyType = __Infer<typeof DependencyType>;\n\nexport const DimensionScore = __t.object(\"DimensionScore\", {\n dimension: __t.string(),\n score: __t.u8(),\n});\nexport type DimensionScore = __Infer<typeof DimensionScore>;\n\nexport const DiscoveredTask = __t.object(\"DiscoveredTask\", {\n id: __t.u64(),\n discoveredBy: __t.string(),\n currentTaskId: __t.u64(),\n projectId: __t.u64(),\n title: __t.string(),\n description: __t.string(),\n priority: __t.u8(),\n taskType: __t.string(),\n severity: __t.string(),\n get status() {\n return DiscoveredTaskStatus;\n },\n createdTaskId: __t.option(__t.u64()),\n rejectionReason: __t.option(__t.string()),\n createdAt: __t.timestamp(),\n reviewedAt: __t.option(__t.timestamp()),\n reviewedBy: __t.option(__t.string()),\n});\nexport type DiscoveredTask = __Infer<typeof DiscoveredTask>;\n\n// The tagged union or sum type for the algebraic type `DiscoveredTaskStatus`.\nexport const DiscoveredTaskStatus = __t.enum(\"DiscoveredTaskStatus\", {\n PendingReview: __t.unit(),\n Approved: __t.unit(),\n Rejected: __t.unit(),\n EscalatedToIdea: __t.unit(),\n});\nexport type DiscoveredTaskStatus = __Infer<typeof DiscoveredTaskStatus>;\n\n// The tagged union or sum type for the algebraic type `DiscoveryDecision`.\nexport const DiscoveryDecision = __t.enum(\"DiscoveryDecision\", {\n ApproveAsTask: __t.unit(),\n Reject: __t.unit(),\n EscalateToIdea: __t.unit(),\n});\nexport type DiscoveryDecision = __Infer<typeof DiscoveryDecision>;\n\nexport const EvaluationDimension = __t.object(\"EvaluationDimension\", {\n id: __t.u64(),\n name: __t.string(),\n label: __t.string(),\n weight: __t.f64(),\n minScore: __t.u8(),\n maxScore: __t.u8(),\n description: __t.string(),\n active: __t.bool(),\n sortOrder: __t.u16(),\n});\nexport type EvaluationDimension = __Infer<typeof EvaluationDimension>;\n\nexport const GenerateVoiceResult = __t.object(\"GenerateVoiceResult\", {\n id: __t.u64(),\n seq: __t.u64(),\n agentName: __t.string(),\n keyPrefix: __t.string(),\n});\nexport type GenerateVoiceResult = __Infer<typeof GenerateVoiceResult>;\n\nexport const Idea = __t.object(\"Idea\", {\n id: __t.u64(),\n title: __t.string(),\n description: __t.string(),\n category: __t.string(),\n get status() {\n return IdeaStatus;\n },\n activeAgentCount: __t.u32(),\n quorum: __t.u16(),\n approvalThreshold: __t.u16(),\n vetoThreshold: __t.u16(),\n upVotes: __t.u16(),\n downVotes: __t.u16(),\n vetoCount: __t.u16(),\n totalVotes: __t.u16(),\n createdBy: __t.string(),\n createdAt: __t.timestamp(),\n updatedAt: __t.timestamp(),\n computedScore: __t.f64(),\n});\nexport type Idea = __Infer<typeof Idea>;\n\n// The tagged union or sum type for the algebraic type `IdeaStatus`.\nexport const IdeaStatus = __t.enum(\"IdeaStatus\", {\n Voting: __t.unit(),\n ApprovedForProject: __t.unit(),\n Rejected: __t.unit(),\n Implemented: __t.unit(),\n});\nexport type IdeaStatus = __Infer<typeof IdeaStatus>;\n\nexport const IdentityRole = __t.object(\"IdentityRole\", {\n identity: __t.identity(),\n get role() {\n return AgentRole;\n },\n});\nexport type IdentityRole = __Infer<typeof IdentityRole>;\n\nexport const Message = __t.object(\"Message\", {\n id: __t.u64(),\n channelId: __t.u64(),\n senderId: __t.string(),\n content: __t.string(),\n get messageType() {\n return MessageType;\n },\n contextId: __t.option(__t.string()),\n createdAt: __t.timestamp(),\n});\nexport type Message = __Infer<typeof Message>;\n\n// The tagged union or sum type for the algebraic type `MessageType`.\nexport const MessageType = __t.enum(\"MessageType\", {\n User: __t.unit(),\n System: __t.unit(),\n Directive: __t.unit(),\n});\nexport type MessageType = __Infer<typeof MessageType>;\n\nexport const Project = __t.object(\"Project\", {\n id: __t.u64(),\n sourceIdeaId: __t.u64(),\n name: __t.string(),\n githubRepo: __t.string(),\n description: __t.string(),\n get status() {\n return ProjectStatus;\n },\n createdAt: __t.timestamp(),\n createdBy: __t.string(),\n});\nexport type Project = __Infer<typeof Project>;\n\nexport const ProjectChannel = __t.object(\"ProjectChannel\", {\n projectId: __t.u64(),\n createdAt: __t.timestamp(),\n});\nexport type ProjectChannel = __Infer<typeof ProjectChannel>;\n\nexport const ProjectMessage = __t.object(\"ProjectMessage\", {\n id: __t.u64(),\n projectId: __t.u64(),\n senderId: __t.string(),\n content: __t.string(),\n get messageType() {\n return MessageType;\n },\n contextId: __t.option(__t.string()),\n createdAt: __t.timestamp(),\n});\nexport type ProjectMessage = __Infer<typeof ProjectMessage>;\n\n// The tagged union or sum type for the algebraic type `ProjectStatus`.\nexport const ProjectStatus = __t.enum(\"ProjectStatus\", {\n Active: __t.unit(),\n Paused: __t.unit(),\n});\nexport type ProjectStatus = __Infer<typeof ProjectStatus>;\n\nexport const Task = __t.object(\"Task\", {\n id: __t.u64(),\n projectId: __t.u64(),\n title: __t.string(),\n description: __t.string(),\n get status() {\n return TaskStatus;\n },\n assignedTo: __t.option(__t.string()),\n claimedAt: __t.option(__t.timestamp()),\n githubIssueUrl: __t.option(__t.string()),\n githubPrUrl: __t.option(__t.string()),\n priority: __t.u8(),\n sourceIdeaId: __t.option(__t.u64()),\n reviewCount: __t.u8(),\n get blockedFromStatus() {\n return __t.option(TaskStatus);\n },\n archivedReason: __t.option(__t.string()),\n statusChangedBy: __t.option(__t.identity()),\n statusChangedAt: __t.option(__t.timestamp()),\n createdAt: __t.timestamp(),\n updatedAt: __t.timestamp(),\n createdBy: __t.string(),\n});\nexport type Task = __Infer<typeof Task>;\n\nexport const TaskDependency = __t.object(\"TaskDependency\", {\n id: __t.u64(),\n taskId: __t.u64(),\n dependsOnId: __t.u64(),\n get dependencyType() {\n return DependencyType;\n },\n createdAt: __t.timestamp(),\n});\nexport type TaskDependency = __Infer<typeof TaskDependency>;\n\n// The tagged union or sum type for the algebraic type `TaskStatus`.\nexport const TaskStatus = __t.enum(\"TaskStatus\", {\n Open: __t.unit(),\n Claimed: __t.unit(),\n InProgress: __t.unit(),\n Review: __t.unit(),\n Completed: __t.unit(),\n Blocked: __t.unit(),\n Archived: __t.unit(),\n});\nexport type TaskStatus = __Infer<typeof TaskStatus>;\n\nexport const VoiceAllowedHost = __t.object(\"VoiceAllowedHost\", {\n host: __t.string(),\n});\nexport type VoiceAllowedHost = __Infer<typeof VoiceAllowedHost>;\n\nexport const VoiceAnnouncement = __t.object(\"VoiceAnnouncement\", {\n id: __t.u64(),\n agentId: __t.identity(),\n seq: __t.u64(),\n agentName: __t.string(),\n transcript: __t.string(),\n audioUrl: __t.string(),\n get status() {\n return AnnouncementStatus;\n },\n contextType: __t.option(__t.string()),\n contextId: __t.option(__t.u64()),\n finalizedAt: __t.option(__t.timestamp()),\n failedAt: __t.option(__t.timestamp()),\n errorMessage: __t.option(__t.string()),\n createdAt: __t.timestamp(),\n});\nexport type VoiceAnnouncement = __Infer<typeof VoiceAnnouncement>;\n\nexport const Vote = __t.object(\"Vote\", {\n id: __t.u64(),\n ideaId: __t.u64(),\n agentId: __t.string(),\n get voteType() {\n return VoteType;\n },\n get scores() {\n return __t.array(DimensionScore);\n },\n createdAt: __t.timestamp(),\n});\nexport type Vote = __Infer<typeof Vote>;\n\n// The tagged union or sum type for the algebraic type `VoteType`.\nexport const VoteType = __t.enum(\"VoteType\", {\n Up: __t.unit(),\n Down: __t.unit(),\n Veto: __t.unit(),\n});\nexport type VoteType = __Infer<typeof VoteType>;\n\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nimport {\n DependencyType,\n} from \"./types\";\n\nexport default {\n taskId: __t.u64(),\n dependsOnId: __t.u64(),\n get dependencyType() {\n return DependencyType;\n },\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {\n taskId: __t.u64(),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {\n sourceIdeaId: __t.u64(),\n name: __t.string(),\n githubRepo: __t.string(),\n description: __t.string(),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {\n projectId: __t.u64(),\n title: __t.string(),\n description: __t.string(),\n priority: __t.u8(),\n sourceIdeaId: __t.option(__t.u64()),\n githubIssueUrl: __t.option(__t.string()),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {\n currentTaskId: __t.u64(),\n projectId: __t.u64(),\n title: __t.string(),\n description: __t.string(),\n priority: __t.u8(),\n taskType: __t.string(),\n severity: __t.string(),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {\n announcementId: __t.u64(),\n errorMessage: __t.string(),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {\n announcementId: __t.u64(),\n audioUrl: __t.string(),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {\n agentId: __t.string(),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {\n ideaId: __t.u64(),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {\n title: __t.string(),\n description: __t.string(),\n category: __t.string(),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nimport {\n AgentRole,\n} from \"./types\";\n\nexport default {\n agentId: __t.string(),\n name: __t.string(),\n zenonAddress: __t.string(),\n get role() {\n return __t.option(AgentRole);\n },\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nimport {\n DiscoveryDecision,\n} from \"./types\";\n\nexport default {\n discoveryId: __t.u64(),\n get decision() {\n return DiscoveryDecision;\n },\n reason: __t.option(__t.string()),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nimport {\n MessageType,\n} from \"./types\";\n\nexport default {\n channelId: __t.u64(),\n content: __t.string(),\n get messageType() {\n return MessageType;\n },\n contextId: __t.option(__t.string()),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nimport {\n MessageType,\n} from \"./types\";\n\nexport default {\n projectId: __t.u64(),\n content: __t.string(),\n get messageType() {\n return MessageType;\n },\n contextId: __t.option(__t.string()),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nimport {\n AgentStatus,\n} from \"./types\";\n\nexport default {\n get status() {\n return AgentStatus;\n },\n taskId: __t.option(__t.u64()),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {\n bio: __t.string(),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {\n capabilities: __t.array(__t.string()),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nimport {\n ProjectStatus,\n} from \"./types\";\n\nexport default {\n projectId: __t.u64(),\n get status() {\n return ProjectStatus;\n },\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nimport {\n TaskStatus,\n} from \"./types\";\n\nexport default {\n taskId: __t.u64(),\n get status() {\n return TaskStatus;\n },\n githubPrUrl: __t.option(__t.string()),\n archiveReason: __t.option(__t.string()),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nimport {\n DimensionScore,\n} from \"./types\";\n\nexport default {\n ideaId: __t.u64(),\n get scores() {\n return __t.array(DimensionScore);\n },\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nimport {\n GenerateVoiceResult,\n} from \"./types\";\n\nexport const params = {\n transcript: __t.string(),\n audioUrl: __t.option(__t.string()),\n contextType: __t.option(__t.string()),\n};\nexport const returnType = __t.result(GenerateVoiceResult, __t.string())","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\nimport {\n AgentRole,\n AgentStatus,\n} from \"./types\";\n\n\nexport default __t.row({\n id: __t.string().primaryKey(),\n name: __t.string(),\n bio: __t.string(),\n get role() {\n return AgentRole;\n },\n capabilities: __t.array(__t.string()),\n get status() {\n return AgentStatus;\n },\n zenonAddress: __t.string().name(\"zenon_address\"),\n identity: __t.identity(),\n lastHeartbeat: __t.timestamp().name(\"last_heartbeat\"),\n currentTaskId: __t.option(__t.u64()).name(\"current_task_id\"),\n createdAt: __t.timestamp().name(\"created_at\"),\n lastActiveAt: __t.timestamp().name(\"last_active_at\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default __t.row({\n id: __t.u64().primaryKey(),\n name: __t.string(),\n createdBy: __t.string().name(\"created_by\"),\n createdAt: __t.timestamp().name(\"created_at\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default __t.row({\n key: __t.string().primaryKey(),\n value: __t.string(),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\nimport {\n DiscoveredTaskStatus,\n} from \"./types\";\n\n\nexport default __t.row({\n id: __t.u64().primaryKey(),\n discoveredBy: __t.string().name(\"discovered_by\"),\n currentTaskId: __t.u64().name(\"current_task_id\"),\n projectId: __t.u64().name(\"project_id\"),\n title: __t.string(),\n description: __t.string(),\n priority: __t.u8(),\n taskType: __t.string().name(\"task_type\"),\n severity: __t.string(),\n get status() {\n return DiscoveredTaskStatus;\n },\n createdTaskId: __t.option(__t.u64()).name(\"created_task_id\"),\n rejectionReason: __t.option(__t.string()).name(\"rejection_reason\"),\n createdAt: __t.timestamp().name(\"created_at\"),\n reviewedAt: __t.option(__t.timestamp()).name(\"reviewed_at\"),\n reviewedBy: __t.option(__t.string()).name(\"reviewed_by\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default __t.row({\n id: __t.u64().primaryKey(),\n name: __t.string(),\n label: __t.string(),\n weight: __t.f64(),\n minScore: __t.u8().name(\"min_score\"),\n maxScore: __t.u8().name(\"max_score\"),\n description: __t.string(),\n active: __t.bool(),\n sortOrder: __t.u16().name(\"sort_order\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\nimport {\n IdeaStatus,\n} from \"./types\";\n\n\nexport default __t.row({\n id: __t.u64().primaryKey(),\n title: __t.string(),\n description: __t.string(),\n category: __t.string(),\n get status() {\n return IdeaStatus;\n },\n activeAgentCount: __t.u32().name(\"active_agent_count\"),\n quorum: __t.u16(),\n approvalThreshold: __t.u16().name(\"approval_threshold\"),\n vetoThreshold: __t.u16().name(\"veto_threshold\"),\n upVotes: __t.u16().name(\"up_votes\"),\n downVotes: __t.u16().name(\"down_votes\"),\n vetoCount: __t.u16().name(\"veto_count\"),\n totalVotes: __t.u16().name(\"total_votes\"),\n createdBy: __t.string().name(\"created_by\"),\n createdAt: __t.timestamp().name(\"created_at\"),\n updatedAt: __t.timestamp().name(\"updated_at\"),\n computedScore: __t.f64().name(\"computed_score\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\nimport {\n AgentRole,\n} from \"./types\";\n\n\nexport default __t.row({\n identity: __t.identity().primaryKey(),\n get role() {\n return AgentRole;\n },\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\nimport {\n MessageType,\n} from \"./types\";\n\n\nexport default __t.row({\n id: __t.u64().primaryKey(),\n channelId: __t.u64().name(\"channel_id\"),\n senderId: __t.string().name(\"sender_id\"),\n content: __t.string(),\n get messageType() {\n return MessageType.name(\"message_type\");\n },\n contextId: __t.option(__t.string()).name(\"context_id\"),\n createdAt: __t.timestamp().name(\"created_at\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default __t.row({\n projectId: __t.u64().primaryKey().name(\"project_id\"),\n createdAt: __t.timestamp().name(\"created_at\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\nimport {\n MessageType,\n} from \"./types\";\n\n\nexport default __t.row({\n id: __t.u64().primaryKey(),\n projectId: __t.u64().name(\"project_id\"),\n senderId: __t.string().name(\"sender_id\"),\n content: __t.string(),\n get messageType() {\n return MessageType.name(\"message_type\");\n },\n contextId: __t.option(__t.string()).name(\"context_id\"),\n createdAt: __t.timestamp().name(\"created_at\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\nimport {\n ProjectStatus,\n} from \"./types\";\n\n\nexport default __t.row({\n id: __t.u64().primaryKey(),\n sourceIdeaId: __t.u64().name(\"source_idea_id\"),\n name: __t.string(),\n githubRepo: __t.string().name(\"github_repo\"),\n description: __t.string(),\n get status() {\n return ProjectStatus;\n },\n createdAt: __t.timestamp().name(\"created_at\"),\n createdBy: __t.string().name(\"created_by\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\nimport {\n DependencyType,\n} from \"./types\";\n\n\nexport default __t.row({\n id: __t.u64().primaryKey(),\n taskId: __t.u64().name(\"task_id\"),\n dependsOnId: __t.u64().name(\"depends_on_id\"),\n get dependencyType() {\n return DependencyType.name(\"dependency_type\");\n },\n createdAt: __t.timestamp().name(\"created_at\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\nimport {\n TaskStatus,\n} from \"./types\";\n\n\nexport default __t.row({\n id: __t.u64().primaryKey(),\n projectId: __t.u64().name(\"project_id\"),\n title: __t.string(),\n description: __t.string(),\n get status() {\n return TaskStatus;\n },\n assignedTo: __t.option(__t.string()).name(\"assigned_to\"),\n claimedAt: __t.option(__t.timestamp()).name(\"claimed_at\"),\n githubIssueUrl: __t.option(__t.string()).name(\"github_issue_url\"),\n githubPrUrl: __t.option(__t.string()).name(\"github_pr_url\"),\n priority: __t.u8(),\n sourceIdeaId: __t.option(__t.u64()).name(\"source_idea_id\"),\n reviewCount: __t.u8().name(\"review_count\"),\n get blockedFromStatus() {\n return __t.option(TaskStatus).name(\"blocked_from_status\");\n },\n archivedReason: __t.option(__t.string()).name(\"archived_reason\"),\n statusChangedBy: __t.option(__t.identity()).name(\"status_changed_by\"),\n statusChangedAt: __t.option(__t.timestamp()).name(\"status_changed_at\"),\n createdAt: __t.timestamp().name(\"created_at\"),\n updatedAt: __t.timestamp().name(\"updated_at\"),\n createdBy: __t.string().name(\"created_by\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\nimport {\n AnnouncementStatus,\n} from \"./types\";\n\n\nexport default __t.row({\n id: __t.u64().primaryKey(),\n agentId: __t.identity().name(\"agent_id\"),\n seq: __t.u64(),\n agentName: __t.string().name(\"agent_name\"),\n transcript: __t.string(),\n audioUrl: __t.string().name(\"audio_url\"),\n get status() {\n return AnnouncementStatus;\n },\n contextType: __t.option(__t.string()).name(\"context_type\"),\n contextId: __t.option(__t.u64()).name(\"context_id\"),\n finalizedAt: __t.option(__t.timestamp()).name(\"finalized_at\"),\n failedAt: __t.option(__t.timestamp()).name(\"failed_at\"),\n errorMessage: __t.option(__t.string()).name(\"error_message\"),\n createdAt: __t.timestamp().name(\"created_at\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\nimport {\n DimensionScore,\n VoteType,\n} from \"./types\";\n\n\nexport default __t.row({\n id: __t.u64().primaryKey(),\n ideaId: __t.u64().name(\"idea_id\"),\n agentId: __t.string().name(\"agent_id\"),\n get voteType() {\n return VoteType.name(\"vote_type\");\n },\n get scores() {\n return __t.array(DimensionScore);\n },\n createdAt: __t.timestamp().name(\"created_at\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n// This was generated using spacetimedb cli version 2.1.0 (commit 6981f48b4bc1a71c8dd9bdfe5a2c343f6370243d).\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n DbConnectionBuilder as __DbConnectionBuilder,\n DbConnectionImpl as __DbConnectionImpl,\n SubscriptionBuilderImpl as __SubscriptionBuilderImpl,\n TypeBuilder as __TypeBuilder,\n Uuid as __Uuid,\n convertToAccessorMap as __convertToAccessorMap,\n makeQueryBuilder as __makeQueryBuilder,\n procedureSchema as __procedureSchema,\n procedures as __procedures,\n reducerSchema as __reducerSchema,\n reducers as __reducers,\n schema as __schema,\n t as __t,\n table as __table,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type DbConnectionConfig as __DbConnectionConfig,\n type ErrorContextInterface as __ErrorContextInterface,\n type Event as __Event,\n type EventContextInterface as __EventContextInterface,\n type Infer as __Infer,\n type QueryBuilder as __QueryBuilder,\n type ReducerEventContextInterface as __ReducerEventContextInterface,\n type RemoteModule as __RemoteModule,\n type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,\n type SubscriptionHandleImpl as __SubscriptionHandleImpl,\n} from \"spacetimedb\";\n\n// Import all reducer arg schemas\nimport AddTaskDependencyReducer from \"./add_task_dependency_reducer\";\nimport ClaimTaskReducer from \"./claim_task_reducer\";\nimport CreateProjectReducer from \"./create_project_reducer\";\nimport CreateTaskReducer from \"./create_task_reducer\";\nimport DiscoverTaskReducer from \"./discover_task_reducer\";\nimport FailVoiceAnnouncementReducer from \"./fail_voice_announcement_reducer\";\nimport FinalizeVoiceAnnouncementReducer from \"./finalize_voice_announcement_reducer\";\nimport HeartbeatReducer from \"./heartbeat_reducer\";\nimport MarkIdeaImplementedReducer from \"./mark_idea_implemented_reducer\";\nimport ProposeIdeaReducer from \"./propose_idea_reducer\";\nimport RegisterAgentReducer from \"./register_agent_reducer\";\nimport ReviewDiscoveredTaskReducer from \"./review_discovered_task_reducer\";\nimport SeedUiDataReducer from \"./seed_ui_data_reducer\";\nimport SeedVoiceAnnouncementsReducer from \"./seed_voice_announcements_reducer\";\nimport SendMessageReducer from \"./send_message_reducer\";\nimport SendProjectMessageReducer from \"./send_project_message_reducer\";\nimport SetAgentStatusReducer from \"./set_agent_status_reducer\";\nimport UpdateAgentBioReducer from \"./update_agent_bio_reducer\";\nimport UpdateAgentCapabilitiesReducer from \"./update_agent_capabilities_reducer\";\nimport UpdateProjectStatusReducer from \"./update_project_status_reducer\";\nimport UpdateTaskStatusReducer from \"./update_task_status_reducer\";\nimport VoteIdeaReducer from \"./vote_idea_reducer\";\n\n// Import all procedure arg schemas\nimport * as GenerateVoiceProcedure from \"./generate_voice_procedure\";\n\n// Import all table schema definitions\nimport AgentsRow from \"./agents_table\";\nimport ChannelsRow from \"./channels_table\";\nimport ConfigRow from \"./config_table\";\nimport DiscoveredTasksRow from \"./discovered_tasks_table\";\nimport EvaluationDimensionsRow from \"./evaluation_dimensions_table\";\nimport IdeasRow from \"./ideas_table\";\nimport IdentityRolesRow from \"./identity_roles_table\";\nimport MessagesRow from \"./messages_table\";\nimport ProjectChannelsRow from \"./project_channels_table\";\nimport ProjectMessagesRow from \"./project_messages_table\";\nimport ProjectsRow from \"./projects_table\";\nimport TaskDependenciesRow from \"./task_dependencies_table\";\nimport TasksRow from \"./tasks_table\";\nimport VoiceAnnouncementsRow from \"./voice_announcements_table\";\nimport VotesRow from \"./votes_table\";\n\n/** Type-only namespace exports for generated type groups. */\n\n/** The schema information for all tables in this module. This is defined the same was as the tables would have been defined in the server. */\nconst tablesSchema = __schema({\n agents: __table({\n name: 'agents',\n indexes: [\n { accessor: 'id', name: 'agents_id_idx_btree', algorithm: 'btree', columns: [\n 'id',\n ] },\n { accessor: 'identity', name: 'agents_identity_idx_btree', algorithm: 'btree', columns: [\n 'identity',\n ] },\n ],\n constraints: [\n { name: 'agents_id_key', constraint: 'unique', columns: ['id'] },\n { name: 'agents_identity_key', constraint: 'unique', columns: ['identity'] },\n ],\n }, AgentsRow),\n channels: __table({\n name: 'channels',\n indexes: [\n { accessor: 'id', name: 'channels_id_idx_btree', algorithm: 'btree', columns: [\n 'id',\n ] },\n { accessor: 'by_name', name: 'channels_name_idx_btree', algorithm: 'btree', columns: [\n 'name',\n ] },\n ],\n constraints: [\n { name: 'channels_id_key', constraint: 'unique', columns: ['id'] },\n ],\n }, ChannelsRow),\n config: __table({\n name: 'config',\n indexes: [\n { accessor: 'key', name: 'config_key_idx_btree', algorithm: 'btree', columns: [\n 'key',\n ] },\n ],\n constraints: [\n { name: 'config_key_key', constraint: 'unique', columns: ['key'] },\n ],\n }, ConfigRow),\n discovered_tasks: __table({\n name: 'discovered_tasks',\n indexes: [\n { accessor: 'by_created_at', name: 'discovered_tasks_created_at_idx_btree', algorithm: 'btree', columns: [\n 'createdAt',\n ] },\n { accessor: 'id', name: 'discovered_tasks_id_idx_btree', algorithm: 'btree', columns: [\n 'id',\n ] },\n { accessor: 'by_priority', name: 'discovered_tasks_priority_idx_btree', algorithm: 'btree', columns: [\n 'priority',\n ] },\n { accessor: 'by_status', name: 'discovered_tasks_status_idx_btree', algorithm: 'btree', columns: [\n 'status',\n ] },\n ],\n constraints: [\n { name: 'discovered_tasks_id_key', constraint: 'unique', columns: ['id'] },\n ],\n }, DiscoveredTasksRow),\n evaluation_dimensions: __table({\n name: 'evaluation_dimensions',\n indexes: [\n { accessor: 'by_active', name: 'evaluation_dimensions_active_sort_order_idx_btree', algorithm: 'btree', columns: [\n 'active',\n 'sortOrder',\n ] },\n { accessor: 'id', name: 'evaluation_dimensions_id_idx_btree', algorithm: 'btree', columns: [\n 'id',\n ] },\n ],\n constraints: [\n { name: 'evaluation_dimensions_id_key', constraint: 'unique', columns: ['id'] },\n ],\n }, EvaluationDimensionsRow),\n ideas: __table({\n name: 'ideas',\n indexes: [\n { accessor: 'id', name: 'ideas_id_idx_btree', algorithm: 'btree', columns: [\n 'id',\n ] },\n { accessor: 'by_status', name: 'ideas_status_idx_btree', algorithm: 'btree', columns: [\n 'status',\n ] },\n ],\n constraints: [\n { name: 'ideas_id_key', constraint: 'unique', columns: ['id'] },\n ],\n }, IdeasRow),\n identity_roles: __table({\n name: 'identity_roles',\n indexes: [\n { accessor: 'identity', name: 'identity_roles_identity_idx_btree', algorithm: 'btree', columns: [\n 'identity',\n ] },\n ],\n constraints: [\n { name: 'identity_roles_identity_key', constraint: 'unique', columns: ['identity'] },\n ],\n }, IdentityRolesRow),\n messages: __table({\n name: 'messages',\n indexes: [\n { accessor: 'by_channel', name: 'messages_channel_id_created_at_idx_btree', algorithm: 'btree', columns: [\n 'channelId',\n 'createdAt',\n ] },\n { accessor: 'id', name: 'messages_id_idx_btree', algorithm: 'btree', columns: [\n 'id',\n ] },\n ],\n constraints: [\n { name: 'messages_id_key', constraint: 'unique', columns: ['id'] },\n ],\n }, MessagesRow),\n project_channels: __table({\n name: 'project_channels',\n indexes: [\n { accessor: 'project_id', name: 'project_channels_project_id_idx_btree', algorithm: 'btree', columns: [\n 'projectId',\n ] },\n ],\n constraints: [\n { name: 'project_channels_project_id_key', constraint: 'unique', columns: ['projectId'] },\n ],\n }, ProjectChannelsRow),\n project_messages: __table({\n name: 'project_messages',\n indexes: [\n { accessor: 'id', name: 'project_messages_id_idx_btree', algorithm: 'btree', columns: [\n 'id',\n ] },\n { accessor: 'by_project', name: 'project_messages_project_id_idx_btree', algorithm: 'btree', columns: [\n 'projectId',\n ] },\n ],\n constraints: [\n { name: 'project_messages_id_key', constraint: 'unique', columns: ['id'] },\n ],\n }, ProjectMessagesRow),\n projects: __table({\n name: 'projects',\n indexes: [\n { accessor: 'id', name: 'projects_id_idx_btree', algorithm: 'btree', columns: [\n 'id',\n ] },\n { accessor: 'by_source_idea_id', name: 'projects_source_idea_id_idx_btree', algorithm: 'btree', columns: [\n 'sourceIdeaId',\n ] },\n ],\n constraints: [\n { name: 'projects_id_key', constraint: 'unique', columns: ['id'] },\n ],\n }, ProjectsRow),\n task_dependencies: __table({\n name: 'task_dependencies',\n indexes: [\n { accessor: 'by_depends_on_id', name: 'task_dependencies_depends_on_id_idx_btree', algorithm: 'btree', columns: [\n 'dependsOnId',\n ] },\n { accessor: 'id', name: 'task_dependencies_id_idx_btree', algorithm: 'btree', columns: [\n 'id',\n ] },\n { accessor: 'by_task_id', name: 'task_dependencies_task_id_idx_btree', algorithm: 'btree', columns: [\n 'taskId',\n ] },\n ],\n constraints: [\n { name: 'task_dependencies_id_key', constraint: 'unique', columns: ['id'] },\n ],\n }, TaskDependenciesRow),\n tasks: __table({\n name: 'tasks',\n indexes: [\n { accessor: 'by_assigned_to', name: 'tasks_assigned_to_idx_btree', algorithm: 'btree', columns: [\n 'assignedTo',\n ] },\n { accessor: 'id', name: 'tasks_id_idx_btree', algorithm: 'btree', columns: [\n 'id',\n ] },\n { accessor: 'by_priority', name: 'tasks_priority_idx_btree', algorithm: 'btree', columns: [\n 'priority',\n ] },\n { accessor: 'by_project_id', name: 'tasks_project_id_idx_btree', algorithm: 'btree', columns: [\n 'projectId',\n ] },\n { accessor: 'by_status', name: 'tasks_status_idx_btree', algorithm: 'btree', columns: [\n 'status',\n ] },\n ],\n constraints: [\n { name: 'tasks_id_key', constraint: 'unique', columns: ['id'] },\n ],\n }, TasksRow),\n voice_announcements: __table({\n name: 'voice_announcements',\n indexes: [\n { accessor: 'by_agent', name: 'voice_announcements_agent_id_created_at_idx_btree', algorithm: 'btree', columns: [\n 'agentId',\n 'createdAt',\n ] },\n { accessor: 'id', name: 'voice_announcements_id_idx_btree', algorithm: 'btree', columns: [\n 'id',\n ] },\n { accessor: 'by_status', name: 'voice_announcements_status_created_at_idx_btree', algorithm: 'btree', columns: [\n 'status',\n 'createdAt',\n ] },\n ],\n constraints: [\n { name: 'voice_announcements_id_key', constraint: 'unique', columns: ['id'] },\n ],\n }, VoiceAnnouncementsRow),\n votes: __table({\n name: 'votes',\n indexes: [\n { accessor: 'id', name: 'votes_id_idx_btree', algorithm: 'btree', columns: [\n 'id',\n ] },\n { accessor: 'by_idea_agent', name: 'votes_idea_id_agent_id_idx_btree', algorithm: 'btree', columns: [\n 'ideaId',\n 'agentId',\n ] },\n { accessor: 'by_idea', name: 'votes_idea_id_idx_btree', algorithm: 'btree', columns: [\n 'ideaId',\n ] },\n ],\n constraints: [\n { name: 'votes_id_key', constraint: 'unique', columns: ['id'] },\n ],\n }, VotesRow),\n});\n\n/** The schema information for all reducers in this module. This is defined the same way as the reducers would have been defined in the server, except the body of the reducer is omitted in code generation. */\nconst reducersSchema = __reducers(\n __reducerSchema(\"add_task_dependency\", AddTaskDependencyReducer),\n __reducerSchema(\"claim_task\", ClaimTaskReducer),\n __reducerSchema(\"create_project\", CreateProjectReducer),\n __reducerSchema(\"create_task\", CreateTaskReducer),\n __reducerSchema(\"discover_task\", DiscoverTaskReducer),\n __reducerSchema(\"fail_voice_announcement\", FailVoiceAnnouncementReducer),\n __reducerSchema(\"finalize_voice_announcement\", FinalizeVoiceAnnouncementReducer),\n __reducerSchema(\"heartbeat\", HeartbeatReducer),\n __reducerSchema(\"mark_idea_implemented\", MarkIdeaImplementedReducer),\n __reducerSchema(\"propose_idea\", ProposeIdeaReducer),\n __reducerSchema(\"register_agent\", RegisterAgentReducer),\n __reducerSchema(\"review_discovered_task\", ReviewDiscoveredTaskReducer),\n __reducerSchema(\"seed_ui_data\", SeedUiDataReducer),\n __reducerSchema(\"seed_voice_announcements\", SeedVoiceAnnouncementsReducer),\n __reducerSchema(\"send_message\", SendMessageReducer),\n __reducerSchema(\"send_project_message\", SendProjectMessageReducer),\n __reducerSchema(\"set_agent_status\", SetAgentStatusReducer),\n __reducerSchema(\"update_agent_bio\", UpdateAgentBioReducer),\n __reducerSchema(\"update_agent_capabilities\", UpdateAgentCapabilitiesReducer),\n __reducerSchema(\"update_project_status\", UpdateProjectStatusReducer),\n __reducerSchema(\"update_task_status\", UpdateTaskStatusReducer),\n __reducerSchema(\"vote_idea\", VoteIdeaReducer),\n);\n\n/** The schema information for all procedures in this module. This is defined the same way as the procedures would have been defined in the server. */\nconst proceduresSchema = __procedures(\n __procedureSchema(\"generate_voice\", GenerateVoiceProcedure.params, GenerateVoiceProcedure.returnType),\n);\n\n/** The remote SpacetimeDB module schema, both runtime and type information. */\nconst REMOTE_MODULE = {\n versionInfo: {\n cliVersion: \"2.1.0\" as const,\n },\n tables: tablesSchema.schemaType.tables,\n reducers: reducersSchema.reducersType.reducers,\n ...proceduresSchema,\n} satisfies __RemoteModule<\n typeof tablesSchema.schemaType,\n typeof reducersSchema.reducersType,\n typeof proceduresSchema\n>;\n\n/** The tables available in this remote SpacetimeDB module. Each table reference doubles as a query builder. */\nexport const tables: __QueryBuilder<typeof tablesSchema.schemaType> = __makeQueryBuilder(tablesSchema.schemaType);\n\n/** The reducers available in this remote SpacetimeDB module. */\nexport const reducers = __convertToAccessorMap(reducersSchema.reducersType.reducers);\n\n/** The context type returned in callbacks for all possible events. */\nexport type EventContext = __EventContextInterface<typeof REMOTE_MODULE>;\n/** The context type returned in callbacks for reducer events. */\nexport type ReducerEventContext = __ReducerEventContextInterface<typeof REMOTE_MODULE>;\n/** The context type returned in callbacks for subscription events. */\nexport type SubscriptionEventContext = __SubscriptionEventContextInterface<typeof REMOTE_MODULE>;\n/** The context type returned in callbacks for error events. */\nexport type ErrorContext = __ErrorContextInterface<typeof REMOTE_MODULE>;\n/** The subscription handle type to manage active subscriptions created from a {@link SubscriptionBuilder}. */\nexport type SubscriptionHandle = __SubscriptionHandleImpl<typeof REMOTE_MODULE>;\n\n/** Builder class to configure a new subscription to the remote SpacetimeDB instance. */\nexport class SubscriptionBuilder extends __SubscriptionBuilderImpl<typeof REMOTE_MODULE> {}\n\n/** Builder class to configure a new database connection to the remote SpacetimeDB instance. */\nexport class DbConnectionBuilder extends __DbConnectionBuilder<DbConnection> {}\n\n/** The typed database connection to manage connections to the remote SpacetimeDB instance. This class has type information specific to the generated module. */\nexport class DbConnection extends __DbConnectionImpl<typeof REMOTE_MODULE> {\n /** Creates a new {@link DbConnectionBuilder} to configure and connect to the remote SpacetimeDB instance. */\n static builder = (): DbConnectionBuilder => {\n return new DbConnectionBuilder(REMOTE_MODULE, (config: __DbConnectionConfig<typeof REMOTE_MODULE>) => new DbConnection(config));\n };\n\n /** Creates a new {@link SubscriptionBuilder} to configure a subscription to the remote SpacetimeDB instance. */\n override subscriptionBuilder = (): SubscriptionBuilder => {\n return new SubscriptionBuilder(this);\n };\n}\n\n","import type { Identity } from \"spacetimedb\";\nimport {\n\tDbConnection,\n\ttype ErrorContext,\n\ttype tables,\n} from \"~/module_bindings/index.js\";\n\nexport type {\n\tAgent,\n\tChannel,\n\tConfig,\n\tDiscoveredTask,\n\tEvaluationDimension,\n\tIdea,\n\tIdentityRole,\n\tMessage,\n\tProject,\n\tProjectChannel,\n\tProjectMessage,\n\tTask,\n\tTaskDependency,\n\tVote,\n} from \"~/module_bindings/types.js\";\n\nimport { getConfig } from \"./config.js\";\nimport { error } from \"./output.js\";\nimport { getCachedToken } from \"./token-cache.js\";\nimport { getWalletInfo } from \"./wallet.js\";\n\ntype TableName = Extract<keyof typeof tables, string>;\n\nexport interface CommandContextOptions {\n\thost?: string;\n\tmodule?: string;\n\twallet?: string;\n\ttoken?: string;\n\tsubscribe?: boolean;\n\tonDisconnect?: (...args: unknown[]) => void;\n}\n\nexport interface AuthInfo {\n\twallet: string;\n\ttoken: string;\n\tidentity: Identity;\n}\n\nexport class CommandContext implements AsyncDisposable {\n\treadonly conn: DbConnection;\n\treadonly identity?: Identity;\n\treadonly token?: string;\n\treadonly auth?: AuthInfo;\n\treadonly config: Awaited<ReturnType<typeof getConfig>>;\n\n\tprivate disposed = false;\n\n\tprivate constructor(\n\t\tconn: DbConnection,\n\t\tconfig: Awaited<ReturnType<typeof getConfig>>,\n\t\tidentity?: Identity,\n\t\ttoken?: string,\n\t\tauth?: AuthInfo,\n\t) {\n\t\tthis.conn = conn;\n\t\tthis.config = config;\n\t\tthis.identity = identity;\n\t\tthis.token = token;\n\t\tthis.auth = auth;\n\t}\n\n\tget db() {\n\t\treturn this.conn.db;\n\t}\n\n\titer<T>(tableName: TableName): T[] {\n\t\tconst db = this.db as Record<string, { iter?: () => IterableIterator<T> }>;\n\t\tconst table = db[tableName];\n\t\tif (table?.iter) {\n\t\t\treturn Array.from(table.iter());\n\t\t}\n\t\treturn [];\n\t}\n\n\tasync [Symbol.asyncDispose](): Promise<void> {\n\t\tif (!this.disposed) {\n\t\t\tthis.disposed = true;\n\t\t\tthis.conn.disconnect();\n\t\t}\n\t}\n\n\tstatic async create(\n\t\toptions: CommandContextOptions = {},\n\t): Promise<CommandContext> {\n\t\tconst config = await getConfig();\n\t\tconst host = options.host || config.spacetime.host;\n\t\tconst moduleName = options.module || config.spacetime.module;\n\t\tconst walletName = options.wallet || config.defaultWallet;\n\n\t\tlet token = options.token;\n\t\tlet auth: AuthInfo | undefined;\n\n\t\tif (!token && walletName) {\n\t\t\tconst cached = await getCachedToken(walletName);\n\t\t\tif (cached) {\n\t\t\t\ttoken = cached.token;\n\t\t\t\tauth = {\n\t\t\t\t\twallet: walletName,\n\t\t\t\t\ttoken: cached.token,\n\t\t\t\t\tidentity: undefined as unknown as Identity,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timeout = setTimeout(() => {\n\t\t\t\treject(new Error(\"Connection timeout\"));\n\t\t\t}, config.requestTimeout);\n\n\t\t\tconst originalConsoleLog = console.log;\n\t\t\tconst originalConsoleError = console.error;\n\t\t\tconst suppressSdkConnectLog = (...logArgs: unknown[]): void => {\n\t\t\t\tconst shouldSuppress = logArgs.some(\n\t\t\t\t\t(arg) =>\n\t\t\t\t\t\ttypeof arg === \"string\" &&\n\t\t\t\t\t\targ.includes(\"Connecting to SpacetimeDB WS...\"),\n\t\t\t\t);\n\t\t\t\tif (!shouldSuppress) {\n\t\t\t\t\toriginalConsoleLog(...(logArgs as Parameters<typeof console.log>));\n\t\t\t\t}\n\t\t\t};\n\t\t\t// Suppress SDK error spam during connection - errors are properly thrown and handled by callers\n\t\t\tconst suppressSdkError = (..._logArgs: unknown[]): void => {\n\t\t\t\t// Errors are handled by onConnectError and rejected properly\n\t\t\t\tif (process.env.PROBE_DEBUG) {\n\t\t\t\t\toriginalConsoleError(\"[probe:debug]\", ..._logArgs);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconsole.log = suppressSdkConnectLog as typeof console.log;\n\t\t\tconsole.error = suppressSdkError as typeof console.error;\n\n\t\t\ttry {\n\t\t\t\tDbConnection.builder()\n\t\t\t\t\t.withUri(host)\n\t\t\t\t\t.withDatabaseName(moduleName)\n\t\t\t\t\t.withToken(token || undefined)\n\t\t\t\t\t.onConnect(\n\t\t\t\t\t\t(conn: DbConnection, identity: Identity, authToken: string) => {\n\t\t\t\t\t\t\tclearTimeout(timeout);\n\n\t\t\t\t\t\t\tif (auth) {\n\t\t\t\t\t\t\t\tauth.identity = identity;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst shouldSubscribe = options.subscribe !== false;\n\n\t\t\t\t\t\t\tif (shouldSubscribe) {\n\t\t\t\t\t\t\t\tconn\n\t\t\t\t\t\t\t\t\t.subscriptionBuilder()\n\t\t\t\t\t\t\t\t\t.onApplied(() => {\n\t\t\t\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t\t\t\tnew CommandContext(\n\t\t\t\t\t\t\t\t\t\t\t\tconn,\n\t\t\t\t\t\t\t\t\t\t\t\tconfig,\n\t\t\t\t\t\t\t\t\t\t\t\tidentity,\n\t\t\t\t\t\t\t\t\t\t\t\tauthToken,\n\t\t\t\t\t\t\t\t\t\t\t\tauth,\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t.onError((ctx: ErrorContext) => {\n\t\t\t\t\t\t\t\t\t\treject(\n\t\t\t\t\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t\t\t\t\t`Subscription error: ${ctx.event?.message || \"Unknown error\"}`,\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t.subscribe([\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM agents\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM tasks\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM ideas\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM messages\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM channels\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM projects\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM votes\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM evaluation_dimensions\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM discovered_tasks\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM task_dependencies\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM identity_roles\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM config\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM project_channels\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM project_messages\",\n\t\t\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t\tnew CommandContext(conn, config, identity, authToken, auth),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t\t.onDisconnect((...disconnectArgs: unknown[]) => {\n\t\t\t\t\t\toptions.onDisconnect?.(...disconnectArgs);\n\t\t\t\t\t})\n\t\t\t\t\t.onConnectError((_ctx: ErrorContext, err: Error) => {\n\t\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\t\tconst message = err.message.toLowerCase();\n\t\t\t\t\t\tif (message.includes(\"unauthorized\") || message.includes(\"401\")) {\n\t\t\t\t\t\t\treject(\n\t\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t\t\"Authentication required. Run `probe auth <wallet> --save` first.\",\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treject(new Error(`Connection failed: ${err.message}`));\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\n\t\t\t\t\t.build();\n\t\t\t} finally {\n\t\t\t\tconsole.log = originalConsoleLog;\n\t\t\t\tconsole.error = originalConsoleError;\n\t\t\t}\n\t\t});\n\t}\n}\n\nexport async function requireAuth(\n\toptions: CommandContextOptions,\n): Promise<CommandContext> {\n\tconst config = await getConfig();\n\tconst walletName = options.wallet || config.defaultWallet;\n\n\tif (!walletName) {\n\t\terror(\n\t\t\t\"WALLET_REQUIRED\",\n\t\t\t\"Wallet required. Use --wallet or set default wallet.\",\n\t\t);\n\t}\n\n\tconst wallet = await getWalletInfo(walletName);\n\tif (!wallet) {\n\t\terror(\"WALLET_NOT_FOUND\", `Wallet not found: ${walletName}`);\n\t}\n\n\tconst cached = await getCachedToken(walletName);\n\tif (!cached) {\n\t\terror(\n\t\t\t\"AUTH_REQUIRED\",\n\t\t\t\"No cached token. Run `probe auth <wallet> --save` first.\",\n\t\t);\n\t}\n\n\treturn CommandContext.create({\n\t\t...options,\n\t\twallet: walletName,\n\t\ttoken: cached.token,\n\t});\n}\n\nexport async function withContext<T>(\n\toptions: CommandContextOptions,\n\thandler: (ctx: CommandContext) => Promise<T>,\n): Promise<T> {\n\tawait using ctx = await CommandContext.create(options);\n\treturn await handler(ctx);\n}\n\nexport async function withAuth<T>(\n\toptions: CommandContextOptions,\n\thandler: (ctx: CommandContext) => Promise<T>,\n): Promise<T> {\n\tawait using ctx = await requireAuth(options);\n\treturn await handler(ctx);\n}\n\nexport async function callReducer(\n\tctx: CommandContext,\n\treducerName: string,\n\targs: Record<string, unknown>,\n): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tlet settled = false;\n\t\tconst timeoutMs = Math.max(1000, ctx.config.requestTimeout);\n\n\t\tconst reducers = ctx.conn.reducers as unknown as Record<string, unknown>;\n\t\tconst reducer = reducers[reducerName];\n\t\tif (typeof reducer !== \"function\") {\n\t\t\treject(new Error(`Reducer not found: ${reducerName}`));\n\t\t\treturn;\n\t\t}\n\n\t\tconst callback = (\n\t\t\teventCtx: { event: { status: { tag: string; value?: string } } },\n\t\t\t_reducerArgs: unknown,\n\t\t) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\n\t\t\tcleanup();\n\t\t\tconst status = eventCtx.event.status;\n\t\t\tif (status.tag === \"Failed\") {\n\t\t\t\treject(new Error(status.value || \"Reducer failed\"));\n\t\t\t} else if (status.tag === \"OutOfEnergy\") {\n\t\t\t\treject(new Error(\"Transaction out of energy\"));\n\t\t\t} else {\n\t\t\t\tresolve();\n\t\t\t}\n\t\t};\n\n\t\tconst onMethod =\n\t\t\t`on${reducerName.charAt(0).toUpperCase() + reducerName.slice(1)}` as keyof typeof ctx.conn.reducers;\n\t\tconst offMethod =\n\t\t\t`removeOn${reducerName.charAt(0).toUpperCase() + reducerName.slice(1)}` as keyof typeof ctx.conn.reducers;\n\n\t\tconst cleanup = () => {\n\t\t\tclearTimeout(timeout);\n\t\t\tconst remove = ctx.conn.reducers[offMethod] as unknown;\n\t\t\tif (typeof remove === \"function\") {\n\t\t\t\t(remove as (cb: typeof callback) => void)(callback);\n\t\t\t}\n\t\t};\n\n\t\tconst timeout = setTimeout(() => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\tcleanup();\n\t\t\treject(\n\t\t\t\tnew Error(`Reducer timed out after ${timeoutMs}ms: ${reducerName}`),\n\t\t\t);\n\t\t}, timeoutMs);\n\n\t\tconst on = ctx.conn.reducers[onMethod] as unknown;\n\t\tif (typeof on === \"function\") {\n\t\t\t(on as (cb: typeof callback) => void)(callback);\n\t\t}\n\n\t\t(reducer as (a: Record<string, unknown>) => void)(args);\n\t});\n}\n\nexport async function callProcedure<T = unknown>(\n\tctx: CommandContext,\n\tprocedureName: string,\n\targs: Record<string, unknown>,\n): Promise<T> {\n\tconst procedures = ctx.conn.procedures as unknown as Record<\n\t\tstring,\n\t\t(args: Record<string, unknown>) => Promise<unknown>\n\t>;\n\tconst accessorName = procedureName.replace(/_([a-z])/g, (_, c) =>\n\t\tc.toUpperCase(),\n\t);\n\tconst proc = procedures[accessorName];\n\tif (typeof proc !== \"function\") {\n\t\tthrow new Error(`Procedure not found: ${procedureName}`);\n\t}\n\treturn (await proc(args)) as T;\n}\n","import { encode } from \"@toon-format/toon\";\n\nexport function formatToon(data: Record<string, unknown>): string {\n\treturn encode(data);\n}\n\nexport function formatToonRecord<T extends object>(\n\tkey: string,\n\titems: T[],\n\tfields?: (keyof T)[],\n): string {\n\tconst displayFields = fields || (Object.keys(items[0] || {}) as (keyof T)[]);\n\tconst rows = items.map((item) => {\n\t\tconst row: Record<string, unknown> = {};\n\t\tfor (const field of displayFields) {\n\t\t\trow[String(field)] = item[field];\n\t\t}\n\t\treturn row;\n\t});\n\treturn encode({ [key]: rows });\n}\n\nexport function toonList<T extends object>(\n\tkey: string,\n\titems: T[],\n\tcolumns?: string[],\n): string {\n\tif (items.length === 0) {\n\t\treturn encode({ [key]: [] });\n\t}\n\n\tconst cols = columns || Object.keys(items[0] as Record<string, unknown>);\n\tconst rows = items.map((item) => {\n\t\tconst row: Record<string, unknown> = {};\n\t\tfor (const col of cols) {\n\t\t\trow[col] = (item as Record<string, unknown>)[col];\n\t\t}\n\t\treturn row;\n\t});\n\treturn encode({ [key]: rows });\n}\n","import { defineCommand } from \"citty\";\nimport { getConfig } from \"~/utils/config.js\";\nimport { CommandContext } from \"~/utils/context.js\";\nimport { forceHelpRequested, printHelp } from \"~/utils/help.js\";\nimport { isJsonMode, setJsonMode, success } from \"~/utils/output.js\";\nimport { getCachedToken } from \"~/utils/token-cache.js\";\nimport { toonList } from \"~/utils/toon.js\";\nimport { getWalletInfo } from \"~/utils/wallet.js\";\n\ntype CheckStatus = \"pass\" | \"warn\" | \"fail\";\n\ninterface DoctorCheck {\n\tcheck: string;\n\tstatus: CheckStatus;\n\tdetail: string;\n}\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"doctor\",\n\t\tdescription: \"Run environment and connectivity diagnostics\",\n\t},\n\targs: {\n\t\twallet: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Wallet name override for auth checks\",\n\t\t},\n\t\thost: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"SpacetimeDB host override\",\n\t\t},\n\t\tmodule: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"SpacetimeDB module override\",\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) {\n\t\t\tsetJsonMode(true);\n\t\t}\n\n\t\tif (forceHelpRequested()) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe doctor\",\n\t\t\t\tdescription: \"Validate Probe config, auth, and Nexus connectivity\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe doctor\",\n\t\t\t\t\t\"probe doctor --wallet my-wallet --host ws://127.0.0.1:3000 --module nexus\",\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--wallet\", detail: \"Wallet override for auth checks\" },\n\t\t\t\t\t{ name: \"--host, --module\", detail: \"SpacetimeDB overrides\" },\n\t\t\t\t\t{ name: \"--json\", detail: \"JSON output mode\" },\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst checks: DoctorCheck[] = [];\n\t\tconst addCheck = (check: string, status: CheckStatus, detail: string) => {\n\t\t\tchecks.push({ check, status, detail });\n\t\t};\n\n\t\tlet config: Awaited<ReturnType<typeof getConfig>> | null = null;\n\t\ttry {\n\t\t\tconfig = await getConfig();\n\t\t\taddCheck(\"config\", \"pass\", \"Loaded Probe configuration\");\n\t\t} catch (err) {\n\t\t\taddCheck(\n\t\t\t\t\"config\",\n\t\t\t\t\"fail\",\n\t\t\t\terr instanceof Error ? err.message : \"Failed to load configuration\",\n\t\t\t);\n\t\t}\n\n\t\tconst walletName = args.wallet || config?.defaultWallet;\n\t\tif (!walletName) {\n\t\t\taddCheck(\n\t\t\t\t\"wallet.selected\",\n\t\t\t\t\"fail\",\n\t\t\t\t\"No wallet selected (set --wallet or defaultWallet)\",\n\t\t\t);\n\t\t} else {\n\t\t\taddCheck(\"wallet.selected\", \"pass\", `Using wallet '${walletName}'`);\n\t\t}\n\n\t\tlet hasWallet = false;\n\t\tif (walletName) {\n\t\t\tconst wallet = await getWalletInfo(walletName);\n\t\t\tif (wallet) {\n\t\t\t\thasWallet = true;\n\t\t\t\taddCheck(\"wallet.exists\", \"pass\", `Address ${wallet.address}`);\n\t\t\t} else {\n\t\t\t\taddCheck(\"wallet.exists\", \"fail\", `Wallet '${walletName}' not found`);\n\t\t\t}\n\t\t}\n\n\t\tlet token: string | null = null;\n\t\tif (walletName && hasWallet) {\n\t\t\tconst cached = await getCachedToken(walletName);\n\t\t\tif (!cached) {\n\t\t\t\taddCheck(\"auth.token\", \"fail\", \"No cached token (run probe auth)\");\n\t\t\t} else {\n\t\t\t\ttoken = cached.token;\n\t\t\t\tconst expires = new Date(cached.expiresAt);\n\t\t\t\tif (Number.isNaN(expires.getTime())) {\n\t\t\t\t\taddCheck(\"auth.token\", \"warn\", \"Token exists but expiry is invalid\");\n\t\t\t\t} else if (expires.getTime() <= Date.now()) {\n\t\t\t\t\taddCheck(\n\t\t\t\t\t\t\"auth.token\",\n\t\t\t\t\t\t\"fail\",\n\t\t\t\t\t\t`Token expired at ${expires.toISOString()}`,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\taddCheck(\n\t\t\t\t\t\t\"auth.token\",\n\t\t\t\t\t\t\"pass\",\n\t\t\t\t\t\t`Token valid until ${expires.toISOString()}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (config) {\n\t\t\tconst host = args.host || config.spacetime.host;\n\t\t\tconst moduleName = args.module || config.spacetime.module;\n\t\t\taddCheck(\"nexus.target\", \"pass\", `${host} / ${moduleName}`);\n\n\t\t\tif (token) {\n\t\t\t\ttry {\n\t\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\t\thost,\n\t\t\t\t\t\tmodule: moduleName,\n\t\t\t\t\t\twallet: walletName,\n\t\t\t\t\t\ttoken,\n\t\t\t\t\t\tsubscribe: false,\n\t\t\t\t\t});\n\t\t\t\t\tconst identity = ctx.identity?.toHexString() || \"unknown\";\n\t\t\t\t\taddCheck(\"nexus.connect\", \"pass\", `Connected as ${identity}`);\n\t\t\t\t} catch (err) {\n\t\t\t\t\taddCheck(\n\t\t\t\t\t\t\"nexus.connect\",\n\t\t\t\t\t\t\"fail\",\n\t\t\t\t\t\terr instanceof Error ? err.message : \"Connection failed\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\taddCheck(\n\t\t\t\t\t\"nexus.connect\",\n\t\t\t\t\t\"warn\",\n\t\t\t\t\t\"Skipped connection check (no valid token)\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst counts = checks.reduce(\n\t\t\t(acc, item) => {\n\t\t\t\tif (item.status === \"pass\") acc.pass += 1;\n\t\t\t\telse if (item.status === \"warn\") acc.warn += 1;\n\t\t\t\telse acc.fail += 1;\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{ pass: 0, warn: 0, fail: 0 },\n\t\t);\n\n\t\tconst ok = counts.fail === 0;\n\t\tsuccess({ ok, counts, checks });\n\n\t\tif (!isJsonMode()) {\n\t\t\tconsole.log(toonList(\"doctor_checks\", checks));\n\t\t\tconsole.log(toonList(\"doctor_summary\", [{ ok, ...counts }]));\n\t\t}\n\t},\n});\n","import type {\n\tAgentRole as AgentRoleType,\n\tAgentStatus as AgentStatusType,\n\tIdeaStatus as IdeaStatusType,\n\tMessageType as MessageTypeType,\n\tProjectStatus as ProjectStatusType,\n\tTaskStatus as TaskStatusType,\n} from \"~/module_bindings/types.js\";\n\nexport const TaskStatus = {\n\tvalues: [\n\t\t\"Open\",\n\t\t\"Claimed\",\n\t\t\"InProgress\",\n\t\t\"Review\",\n\t\t\"Completed\",\n\t\t\"Blocked\",\n\t\t\"Archived\",\n\t] as const,\n\n\tis: {\n\t\topen: (s: TaskStatusType) => s.tag === \"Open\",\n\t\tclaimed: (s: TaskStatusType) => s.tag === \"Claimed\",\n\t\tinProgress: (s: TaskStatusType) => s.tag === \"InProgress\",\n\t\treview: (s: TaskStatusType) => s.tag === \"Review\",\n\t\tcompleted: (s: TaskStatusType) => s.tag === \"Completed\",\n\t\tblocked: (s: TaskStatusType) => s.tag === \"Blocked\",\n\t\tarchived: (s: TaskStatusType) => s.tag === \"Archived\",\n\t\tactive: (s: TaskStatusType) =>\n\t\t\t[\"Open\", \"Claimed\", \"InProgress\", \"Review\"].includes(s.tag),\n\t\tterminal: (s: TaskStatusType) =>\n\t\t\t[\"Completed\", \"Blocked\", \"Archived\"].includes(s.tag),\n\t},\n\n\tfromString(s: string): TaskStatusType {\n\t\tconst map: Record<string, TaskStatusType> = {\n\t\t\topen: { tag: \"Open\" },\n\t\t\tclaimed: { tag: \"Claimed\" },\n\t\t\tin_progress: { tag: \"InProgress\" },\n\t\t\tinprogress: { tag: \"InProgress\" },\n\t\t\treview: { tag: \"Review\" },\n\t\t\tcompleted: { tag: \"Completed\" },\n\t\t\tmerged: { tag: \"Completed\" },\n\t\t\tblocked: { tag: \"Blocked\" },\n\t\t\tarchived: { tag: \"Archived\" },\n\t\t};\n\t\treturn map[s.toLowerCase().replace(/[_\\s]/g, \"\")] ?? { tag: \"Open\" };\n\t},\n\n\tmatches(status: TaskStatusType, filter: string): boolean {\n\t\tconst f = filter.toLowerCase().replace(/[_\\s]/g, \"\");\n\t\tif (f === \"merged\") return status.tag === \"Completed\";\n\t\treturn status.tag.toLowerCase() === f;\n\t},\n\n\tdisplay(status: TaskStatusType): string {\n\t\tconst map: Record<string, string> = { InProgress: \"IN PROGRESS\" };\n\t\treturn map[status.tag] ?? status.tag.toUpperCase();\n\t},\n} as const;\n\nexport const IdeaStatus = {\n\tvalues: [\"Voting\", \"ApprovedForProject\", \"Rejected\", \"Implemented\"] as const,\n\n\tis: {\n\t\tvoting: (s: IdeaStatusType) => s.tag === \"Voting\",\n\t\tapproved: (s: IdeaStatusType) => s.tag === \"ApprovedForProject\",\n\t\trejected: (s: IdeaStatusType) => s.tag === \"Rejected\",\n\t\timplemented: (s: IdeaStatusType) => s.tag === \"Implemented\",\n\t\tactive: (s: IdeaStatusType) => s.tag === \"Voting\",\n\t\tterminal: (s: IdeaStatusType) =>\n\t\t\t[\"ApprovedForProject\", \"Rejected\", \"Implemented\"].includes(s.tag),\n\t},\n\n\tfromString(s: string): IdeaStatusType {\n\t\tconst map: Record<string, IdeaStatusType> = {\n\t\t\tvoting: { tag: \"Voting\" },\n\t\t\tapproved: { tag: \"ApprovedForProject\" },\n\t\t\tapproved_for_project: { tag: \"ApprovedForProject\" },\n\t\t\trejected: { tag: \"Rejected\" },\n\t\t\timplemented: { tag: \"Implemented\" },\n\t\t};\n\t\treturn map[s.toLowerCase().replace(/[_\\s]/g, \"\")] ?? { tag: \"Voting\" };\n\t},\n\n\tmatches(status: IdeaStatusType, filter: string): boolean {\n\t\tconst f = filter.toLowerCase().replace(/[_\\s]/g, \"\");\n\t\tif (f === \"approved\") return status.tag === \"ApprovedForProject\";\n\t\treturn status.tag.toLowerCase() === f;\n\t},\n\n\tdisplay(status: IdeaStatusType): string {\n\t\tif (status.tag === \"ApprovedForProject\") return \"Approved\";\n\t\treturn status.tag;\n\t},\n} as const;\n\nexport const AgentRole = {\n\tvalues: [\"Zoe\", \"Admin\", \"Zeno\"] as const,\n\n\tis: {\n\t\tzoe: (r: AgentRoleType) => r.tag === \"Zoe\",\n\t\tadmin: (r: AgentRoleType) => r.tag === \"Admin\",\n\t\tzeno: (r: AgentRoleType) => r.tag === \"Zeno\",\n\t\tprivileged: (r: AgentRoleType) => [\"Zoe\", \"Admin\"].includes(r.tag),\n\t},\n\n\tfromString(s: string): AgentRoleType {\n\t\tconst map: Record<string, AgentRoleType> = {\n\t\t\tzoe: { tag: \"Zoe\" },\n\t\t\tadmin: { tag: \"Admin\" },\n\t\t\tzeno: { tag: \"Zeno\" },\n\t\t};\n\t\treturn map[s.toLowerCase()] ?? { tag: \"Zeno\" };\n\t},\n\n\tdisplay(r: AgentRoleType): string {\n\t\treturn r.tag.toLowerCase();\n\t},\n} as const;\n\nexport const AgentStatus = {\n\tvalues: [\"Online\", \"Offline\", \"Working\"] as const,\n\n\tis: {\n\t\tonline: (s: AgentStatusType) => s.tag === \"Online\",\n\t\toffline: (s: AgentStatusType) => s.tag === \"Offline\",\n\t\tworking: (s: AgentStatusType) => s.tag === \"Working\",\n\t\tavailable: (s: AgentStatusType) =>\n\t\t\ts.tag === \"Online\" || s.tag === \"Working\",\n\t},\n\n\tfromString(s: string): AgentStatusType {\n\t\tconst map: Record<string, AgentStatusType> = {\n\t\t\tonline: { tag: \"Online\" },\n\t\t\toffline: { tag: \"Offline\" },\n\t\t\tworking: { tag: \"Working\" },\n\t\t\tbusy: { tag: \"Working\" },\n\t\t};\n\t\treturn map[s.toLowerCase()] ?? { tag: \"Offline\" };\n\t},\n\n\tdisplay(s: AgentStatusType): string {\n\t\treturn s.tag;\n\t},\n} as const;\n\nexport const MessageType = {\n\tvalues: [\"User\", \"System\", \"Directive\"] as const,\n\n\tis: {\n\t\tuser: (t: MessageTypeType) => t.tag === \"User\",\n\t\tsystem: (t: MessageTypeType) => t.tag === \"System\",\n\t\tdirective: (t: MessageTypeType) => t.tag === \"Directive\",\n\t},\n\n\tfromString(s: string): MessageTypeType {\n\t\tconst map: Record<string, MessageTypeType> = {\n\t\t\tuser: { tag: \"User\" },\n\t\t\ttext: { tag: \"User\" },\n\t\t\tsystem: { tag: \"System\" },\n\t\t\tdirective: { tag: \"Directive\" },\n\t\t};\n\t\treturn map[s.toLowerCase()] ?? { tag: \"User\" };\n\t},\n\n\tdisplay(t: MessageTypeType): string {\n\t\treturn t.tag.toLowerCase();\n\t},\n} as const;\n\nexport const ProjectStatus = {\n\tvalues: [\"Active\", \"Paused\"] as const,\n\n\tis: {\n\t\tactive: (s: ProjectStatusType) => s.tag === \"Active\",\n\t\tpaused: (s: ProjectStatusType) => s.tag === \"Paused\",\n\t},\n\n\tfromString(s: string): ProjectStatusType {\n\t\tconst normalized = s.toLowerCase().replace(/[_\\s]/g, \"\");\n\t\tconst map: Record<string, ProjectStatusType> = {\n\t\t\tactive: { tag: \"Active\" },\n\t\t\tpaused: { tag: \"Paused\" },\n\t\t};\n\t\treturn map[normalized] ?? { tag: \"Active\" };\n\t},\n\n\tmatches(status: ProjectStatusType, filter: string): boolean {\n\t\tconst normalized = filter.toLowerCase().replace(/[_\\s]/g, \"\");\n\t\treturn status.tag.toLowerCase() === normalized;\n\t},\n\n\tdisplay(status: ProjectStatusType): string {\n\t\treturn status.tag.toLowerCase();\n\t},\n} as const;\n","type MicrosTimestamp = { microsSinceUnixEpoch: bigint | number | string };\n\nexport const toMicros = (value: unknown): bigint => {\n\tif (\n\t\t!value ||\n\t\ttypeof value !== \"object\" ||\n\t\t!(\"microsSinceUnixEpoch\" in value)\n\t) {\n\t\treturn 0n;\n\t}\n\tconst micros = (value as MicrosTimestamp).microsSinceUnixEpoch;\n\treturn typeof micros === \"bigint\" ? micros : BigInt(micros);\n};\n\nexport const formatTimestamp = (value: unknown, fallback = \"\"): string => {\n\tconst micros = toMicros(value);\n\tif (micros <= 0n) {\n\t\treturn fallback || String(value ?? \"\");\n\t}\n\treturn new Date(Number(micros / 1000n))\n\t\t.toISOString()\n\t\t.replace(\"T\", \" \")\n\t\t.slice(0, 19);\n};\n\nexport const formatIsoTimestamp = (value: unknown, fallback = \"\"): string => {\n\tconst micros = toMicros(value);\n\tif (micros <= 0n) {\n\t\treturn fallback || new Date().toISOString();\n\t}\n\treturn new Date(Number(micros / 1000n)).toISOString();\n};\n","import { getConfig } from \"~/utils/config.js\";\nimport {\n\ttype Agent,\n\tCommandContext,\n\tcallReducer,\n\tcallProcedure,\n\twithAuth,\n} from \"~/utils/context.js\";\nimport { AgentRole, AgentStatus } from \"~/utils/enums.js\";\nimport { error, isJsonMode, success } from \"~/utils/output.js\";\nimport { formatTimestamp, toMicros } from \"~/utils/time.js\";\nimport { toonList } from \"~/utils/toon.js\";\nimport { getWalletInfo } from \"~/utils/wallet.js\";\nimport type { GenerateVoiceResult } from \"~/module_bindings/types.js\";\n\nconst MAX_VOICE_TRANSCRIPT_LENGTH = 500;\nconst DEFAULT_VOICE_CONTEXT_TYPE = \"status_update\";\n\nexport interface AgentCommandArgs {\n\taction?: string;\n\tagentId?: string;\n\tname?: string;\n\trole?: string;\n\taddress?: string;\n\twallet?: string;\n\ttask?: string;\n\tlimit?: string;\n\tcapabilities?: string;\n\tset?: string;\n\taudioUrl?: string;\n\tcontextType?: string;\n\thost?: string;\n\tmodule?: string;\n}\n\nconst normalizeCapabilities = (value?: string): string[] => {\n\tif (!value) return [];\n\treturn [\n\t\t...new Set(\n\t\t\tvalue\n\t\t\t\t.split(\",\")\n\t\t\t\t.map((item) => item.trim().toLowerCase())\n\t\t\t\t.filter(Boolean),\n\t\t),\n\t];\n};\n\nconst currentAgentForIdentity = (ctx: CommandContext): Agent | undefined => {\n\treturn ctx\n\t\t.iter<Agent>(\"agents\")\n\t\t.find((a) => a.identity.toHexString() === ctx.identity?.toHexString());\n};\n\nconst renderAgent = (agent: Agent, identity?: string) => ({\n\tid: agent.id,\n\tname: agent.name,\n\trole: AgentRole.display(agent.role),\n\tstatus: AgentStatus.display(agent.status),\n\tlastHeartbeat: formatTimestamp(agent.lastHeartbeat),\n\tcurrentTaskId: agent.currentTaskId ? agent.currentTaskId.toString() : \"\",\n\tcapabilities: agent.capabilities.join(\",\"),\n\tidentity: identity || \"\",\n});\n\nexport const runAgentAction = async (args: AgentCommandArgs): Promise<void> => {\n\tconst action = args.action;\n\tif (!action) {\n\t\terror(\"ACTION_REQUIRED\", \"Agent action required\");\n\t}\n\n\ttry {\n\t\tswitch (action) {\n\t\t\tcase \"register\": {\n\t\t\t\tconst agentId = args.agentId;\n\t\t\t\tconst name = args.name;\n\t\t\t\tconst role = args.role || \"zeno\";\n\n\t\t\t\tif (!agentId || !name)\n\t\t\t\t\terror(\"ARGS_REQUIRED\", \"Agent ID and name required\");\n\n\t\t\t\tconst config = await getConfig();\n\t\t\t\tconst walletName = args.wallet || config.defaultWallet;\n\t\t\t\tif (!args.address && !walletName)\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"WALLET_REQUIRED\",\n\t\t\t\t\t\t\"--address or --wallet required (or set default wallet)\",\n\t\t\t\t\t);\n\n\t\t\t\tlet address = args.address;\n\t\t\t\tconst capabilities = normalizeCapabilities(args.capabilities);\n\t\t\t\tif (!address && walletName) {\n\t\t\t\t\tconst wallet = await getWalletInfo(walletName);\n\t\t\t\t\tif (!wallet)\n\t\t\t\t\t\terror(\"WALLET_NOT_FOUND\", `Wallet not found: ${walletName}`);\n\t\t\t\t\taddress = wallet.address;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: walletName },\n\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\tawait callReducer(ctx, \"registerAgent\", {\n\t\t\t\t\t\t\t\tagentId,\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\trole: AgentRole.fromString(role),\n\t\t\t\t\t\t\t\tzenonAddress: address as string,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tif (capabilities.length > 0) {\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"updateAgentCapabilities\", {\n\t\t\t\t\t\t\t\t\tcapabilities,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tawait new Promise((r) => setTimeout(r, 500));\n\t\t\t\t\t\t\tconst registered = ctx\n\t\t\t\t\t\t\t\t.iter<Agent>(\"agents\")\n\t\t\t\t\t\t\t\t.find((a) => a.id === agentId);\n\t\t\t\t\t\t\tif (!registered) {\n\t\t\t\t\t\t\t\tif (role === \"zoe\" || role === \"admin\") {\n\t\t\t\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\t\t\t\"UNAUTHORIZED\",\n\t\t\t\t\t\t\t\t\t\t\"Only whitelisted identities can register as zoe or admin\",\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\terror(\"REGISTRATION_FAILED\", \"Registration failed\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\tsuccess({\n\t\t\t\t\t\tregistered: true,\n\t\t\t\t\t\tagentId,\n\t\t\t\t\t\tname,\n\t\t\t\t\t\trole,\n\t\t\t\t\t\taddress,\n\t\t\t\t\t\tcapabilities,\n\t\t\t\t\t});\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\"agent_registered\", [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tagentId,\n\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\trole,\n\t\t\t\t\t\t\t\t\taddress,\n\t\t\t\t\t\t\t\t\tcapabilities: capabilities.join(\",\"),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"status\": {\n\t\t\t\tif (args.agentId || args.task || args.capabilities) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"INVALID_USAGE\",\n\t\t\t\t\t\t\"Use `probe agent set-status <online|offline|working|busy>` to update status. `probe agent status` only shows current status.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tawait withAuth(\n\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\tconst myAgent = currentAgentForIdentity(ctx);\n\t\t\t\t\t\tif (!myAgent)\n\t\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\t\"NOT_REGISTERED\",\n\t\t\t\t\t\t\t\t\"Agent not registered. Run `probe agent register` first.\",\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\tsuccess(myAgent);\n\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\ttoonList(\"agent\", [\n\t\t\t\t\t\t\t\t\trenderAgent(myAgent, ctx.identity?.toHexString()),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"set-status\": {\n\t\t\t\tconst nextStatus = args.agentId;\n\t\t\t\tif (!nextStatus) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"STATUS_REQUIRED\",\n\t\t\t\t\t\t\"Status required. Use: online, offline, working, busy\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (args.capabilities) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"INVALID_USAGE\",\n\t\t\t\t\t\t\"Use `probe agent capabilities --set <list>` to update capabilities.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst normalized = nextStatus.toLowerCase();\n\t\t\t\tconst allowed = new Set([\"online\", \"offline\", \"working\", \"busy\"]);\n\t\t\t\tif (!allowed.has(normalized)) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"INVALID_STATUS\",\n\t\t\t\t\t\t`Invalid status: ${nextStatus}. Use: online, offline, working, busy`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst mapped = AgentStatus.fromString(normalized);\n\t\t\t\tconst isWorking = AgentStatus.is.working(mapped);\n\t\t\t\tif (isWorking && !args.task) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"TASK_REQUIRED\",\n\t\t\t\t\t\t\"--task is required when setting status to working\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (!isWorking && args.task) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"TASK_NOT_ALLOWED\",\n\t\t\t\t\t\t\"--task is only allowed when setting status to working\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\tawait callReducer(ctx, \"setAgentStatus\", {\n\t\t\t\t\t\t\t\tstatus: mapped,\n\t\t\t\t\t\t\t\ttaskId: isWorking ? BigInt(args.task as string) : undefined,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\n\t\t\t\t\tsuccess({\n\t\t\t\t\t\tupdated: true,\n\t\t\t\t\t\tstatus: normalized,\n\t\t\t\t\t\ttaskId: args.task || null,\n\t\t\t\t\t});\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\"agent_status_updated\", [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tstatus: normalized,\n\t\t\t\t\t\t\t\t\ttaskId: args.task || \"\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"capabilities\": {\n\t\t\t\tif (!args.set) error(\"CAPABILITIES_REQUIRED\", \"--set is required\");\n\n\t\t\t\tconst capabilities = normalizeCapabilities(args.set);\n\t\t\t\ttry {\n\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\tawait callReducer(ctx, \"updateAgentCapabilities\", {\n\t\t\t\t\t\t\t\tcapabilities,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tconst myAgent = currentAgentForIdentity(ctx);\n\t\t\t\t\t\t\tsuccess({ updated: true, agentId: myAgent?.id, capabilities });\n\t\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\ttoonList(\"agent_capabilities_updated\", [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tagentId: myAgent?.id || \"\",\n\t\t\t\t\t\t\t\t\t\t\tcapabilities: capabilities.join(\",\"),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} catch (err) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"me\": {\n\t\t\t\tawait withAuth(\n\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\tconst myAgent = currentAgentForIdentity(ctx);\n\t\t\t\t\t\tif (!myAgent)\n\t\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\t\"NOT_REGISTERED\",\n\t\t\t\t\t\t\t\t\"Agent not registered. Run `probe agent register` first.\",\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\tsuccess(myAgent);\n\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\ttoonList(\"agent\", [\n\t\t\t\t\t\t\t\t\trenderAgent(myAgent, ctx.identity?.toHexString()),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"heartbeat\": {\n\t\t\t\ttry {\n\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\tconst myAgent = currentAgentForIdentity(ctx);\n\t\t\t\t\t\t\tif (!myAgent) error(\"NOT_REGISTERED\", \"Agent not registered\");\n\n\t\t\t\t\t\t\tawait callReducer(ctx, \"heartbeat\", {\n\t\t\t\t\t\t\t\tagentId: myAgent.id,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tsuccess({ heartbeat: true });\n\t\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\ttoonList(\"agent_heartbeat\", [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tagentId: myAgent.id,\n\t\t\t\t\t\t\t\t\t\t\tstatus: AgentStatus.display(myAgent.status),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} catch (err) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"list\": {\n\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\thost: args.host,\n\t\t\t\t\tmodule: args.module,\n\t\t\t\t});\n\t\t\t\tconst limit = args.limit ? parseInt(args.limit, 10) : undefined;\n\t\t\t\tif (limit !== undefined && (!Number.isFinite(limit) || limit <= 0)) {\n\t\t\t\t\terror(\"INVALID_LIMIT\", \"--limit must be a positive integer\");\n\t\t\t\t}\n\n\t\t\t\tlet onlineAgents = ctx\n\t\t\t\t\t.iter<Agent>(\"agents\")\n\t\t\t\t\t.filter((a) => !AgentStatus.is.offline(a.status));\n\t\t\t\tonlineAgents = onlineAgents.sort((a, b) => {\n\t\t\t\t\tconst aMicros = toMicros(\n\t\t\t\t\t\ta.lastHeartbeat || a.createdAt || a.lastActiveAt,\n\t\t\t\t\t);\n\t\t\t\t\tconst bMicros = toMicros(\n\t\t\t\t\t\tb.lastHeartbeat || b.createdAt || b.lastActiveAt,\n\t\t\t\t\t);\n\t\t\t\t\tif (aMicros !== bMicros) return bMicros > aMicros ? 1 : -1;\n\t\t\t\t\treturn b.id.localeCompare(a.id);\n\t\t\t\t});\n\t\t\t\tif (limit !== undefined) onlineAgents = onlineAgents.slice(0, limit);\n\n\t\t\t\tsuccess({ agents: onlineAgents, count: onlineAgents.length });\n\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\ttoonList(\n\t\t\t\t\t\t\t\"agents\",\n\t\t\t\t\t\t\tonlineAgents.map((a) => ({\n\t\t\t\t\t\t\t\tid: a.id,\n\t\t\t\t\t\t\t\tname: a.name,\n\t\t\t\t\t\t\t\trole: AgentRole.display(a.role),\n\t\t\t\t\t\t\t\tstatus: AgentStatus.display(a.status),\n\t\t\t\t\t\t\t\tlast_heartbeat: formatTimestamp(a.lastHeartbeat),\n\t\t\t\t\t\t\t\tcapabilities: a.capabilities.join(\",\"),\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"identity\": {\n\t\t\t\tawait withAuth(\n\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\tconst identityHex = ctx.identity?.toHexString();\n\t\t\t\t\t\tsuccess({ identity: identityHex, wallet: args.wallet });\n\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\ttoonList(\"identity\", [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tidentity: identityHex || \"\",\n\t\t\t\t\t\t\t\t\t\twallet: args.wallet || \"\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"voice\": {\n\t\t\t\tconst transcript = args.agentId?.trim();\n\t\t\t\tif (!transcript) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"TRANSCRIPT_REQUIRED\",\n\t\t\t\t\t\t\"Transcript required. Provide as first positional argument.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (transcript.length > MAX_VOICE_TRANSCRIPT_LENGTH) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"TRANSCRIPT_TOO_LONG\",\n\t\t\t\t\t\t`Transcript exceeds ${MAX_VOICE_TRANSCRIPT_LENGTH} characters.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (!args.audioUrl) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"AUDIO_URL_REQUIRED\",\n\t\t\t\t\t\t\"--audioUrl is required for voice announcements.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\tconst contextType = args.contextType || DEFAULT_VOICE_CONTEXT_TYPE;\n\t\t\t\t\t\t\tconst result = await callProcedure<GenerateVoiceResult>(\n\t\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\t\t\"generate_voice\",\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttranscript,\n\t\t\t\t\t\t\t\taudioUrl: args.audioUrl,\n\t\t\t\t\t\t\t\tcontextType,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tconst data = {\n\t\t\t\t\t\t\t\tok: true,\n\t\t\t\t\t\t\t\tannouncementId: result.id,\n\t\t\t\t\t\t\t\tseq: result.seq,\n\t\t\t\t\t\t\t\tagentName: result.agentName,\n\t\t\t\t\t\t\t\tkeyPrefix: result.keyPrefix,\n\t\t\t\t\t\t\t\taudioUrl: args.audioUrl,\n\t\t\t\t\t\t\t\tcontextType,\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\tsuccess(data);\n\t\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\ttoonList(\"voice_announcement\", [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: result.id,\n\t\t\t\t\t\t\t\t\t\tseq: result.seq,\n\t\t\t\t\t\t\t\t\t\tagentName: result.agentName,\n\t\t\t\t\t\t\t\t\t\tkeyPrefix: result.keyPrefix,\n\t\t\t\t\t\t\t\t\t\taudioUrl: args.audioUrl || \"\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} catch (err) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"PROCEDURE_FAILED\",\n\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\terror(\n\t\t\t\t\t\"INVALID_ACTION\",\n\t\t\t\t\t`Invalid action: ${action}`,\n\t\t\t\t\t\"Use: register, status, set-status, capabilities, me, heartbeat, list, identity, voice\",\n\t\t\t\t);\n\t\t}\n\t} catch (err) {\n\t\t// Handle connection errors gracefully - avoid citty/consola stack traces\n\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\terror(\"CONNECTION_ERROR\", message);\n\t}\n};\n","import { defineCommand } from \"citty\";\nimport { printHelp } from \"~/utils/help.js\";\nimport { setJsonMode } from \"~/utils/output.js\";\nimport { type AgentCommandArgs, runAgentAction } from \"./agent-handlers.js\";\n\nexport default defineCommand({\n\tmeta: { name: \"agent\", description: \"Agent management\" },\n\targs: {\n\t\taction: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription:\n\t\t\t\t\"Action: register, status, set-status, capabilities, me, heartbeat, list, identity, voice\",\n\t\t\trequired: false,\n\t\t},\n\t\tagentId: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Action-dependent value (agent ID, status, or transcript)\",\n\t\t\trequired: false,\n\t\t},\n\t\tname: { type: \"positional\", description: \"Display name\", required: false },\n\t\trole: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Role: zoe, admin, zeno\",\n\t\t\trequired: false,\n\t\t},\n\t\taddress: { type: \"string\", description: \"Zenon address\" },\n\t\twallet: { type: \"string\", description: \"Wallet name\" },\n\t\ttask: { type: \"string\", description: \"Current task ID\" },\n\t\tlimit: { type: \"string\", description: \"Limit agents returned for list\" },\n\t\tcapabilities: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Comma-separated capability list\",\n\t\t},\n\t\tset: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Set capabilities for capabilities action\",\n\t\t},\n\t\tjson: { type: \"boolean\", description: \"Output JSON\", default: false },\n\t\taudioUrl: { type: \"string\", description: \"Audio URL for voice announcements\" },\n\t\tcontextType: { type: \"string\", description: \"Context type for voice (default: status_update)\" },\n\t\thost: { type: \"string\", description: \"SpacetimeDB host\" },\n\t\tmodule: { type: \"string\", description: \"Module name\" },\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) setJsonMode(true);\n\n\t\tif (!args.action) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe agent\",\n\t\t\t\tdescription: \"Agent lifecycle and identity commands\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe agent <action> [options]\",\n\t\t\t\t\t'probe agent register agent-1 \"Builder\" zeno --wallet my-wallet',\n\t\t\t\t\t\"probe agent set-status working --task 42\",\n\t\t\t\t\t'probe agent capabilities --set \"gh,coding,review\"',\n\t\t\t\t\t\"probe agent heartbeat\",\n\t\t\t\t\t'probe agent voice \"Hello from Zoe\" --audioUrl https://audio.zenon.red/voice/zoe/123.mp3',\n\t\t\t\t],\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"register <agentId> <name> [role]\",\n\t\t\t\t\t\tdetail: \"Register a new agent identity\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"status\", detail: \"Show current agent status\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"set-status <online|offline|working|busy>\",\n\t\t\t\t\t\tdetail: \"Update current agent status\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"capabilities --set <list>\",\n\t\t\t\t\t\tdetail: \"Set capabilities for authenticated agent\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"me\", detail: \"Show current authenticated agent profile\" },\n\t\t\t\t\t{ name: \"heartbeat\", detail: \"Send heartbeat only\" },\n\t\t\t\t\t{ name: \"list\", detail: \"List online agents\" },\n\t\t\t\t\t{ name: \"identity\", detail: \"Show current authenticated identity\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"voice <transcript> --audioUrl <url>\",\n\t\t\t\t\t\tdetail: \"Submit a voice announcement (BYO audio URL)\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--wallet\", detail: \"Wallet to use for authenticated calls\" },\n\t\t\t\t\t{ name: \"--address\", detail: \"Zenon address for register\" },\n\t\t\t\t\t{ name: \"--task\", detail: \"Task ID required with status working\" },\n\t\t\t\t\t{ name: \"--limit\", detail: \"Max agents returned for list\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--capabilities\",\n\t\t\t\t\t\tdetail: \"Comma-separated capabilities for register/status\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--set\",\n\t\t\t\t\t\tdetail: \"Comma-separated capabilities for capabilities action\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--audioUrl\",\n\t\t\t\t\t\tdetail: \"Audio URL for voice announcements (required)\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--contextType\",\n\t\t\t\t\t\tdetail: \"Context type for voice (default: status_update)\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--host, --module\",\n\t\t\t\t\t\tdetail: \"Nexus SpacetimeDB target overrides\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tnotes: [\n\t\t\t\t\t\"Valid register roles: zeno (default), zoe, admin. Non-whitelisted identities cannot register as zoe/admin.\",\n\t\t\t\t\t\"Use `probe task list` to discover task IDs before `probe agent set-status working --task <id>`.\",\n\t\t\t\t\t\"`probe agent status` shows current status; `probe agent set-status <online|offline|working|busy>` updates status.\",\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tawait runAgentAction(args as AgentCommandArgs);\n\t},\n});\n","import { defineCommand } from \"citty\";\nimport {\n\tCommandContext,\n\tcallReducer,\n\ttype DiscoveredTask,\n\twithAuth,\n} from \"~/utils/context.js\";\nimport { printHelp } from \"~/utils/help.js\";\nimport { error, isJsonMode, setJsonMode, success } from \"~/utils/output.js\";\nimport { formatTimestamp, toMicros } from \"~/utils/time.js\";\nimport { toonList } from \"~/utils/toon.js\";\n\nconst toDiscoveryDecision = (input: string) => {\n\tconst value = input.toLowerCase();\n\tif (value === \"approve\") return { tag: \"ApproveAsTask\" };\n\tif (value === \"reject\") return { tag: \"Reject\" };\n\tif (value === \"escalate_to_idea\") return { tag: \"EscalateToIdea\" };\n\treturn null;\n};\n\nconst discoveryStatusTag = (status: unknown): string => {\n\tif (status && typeof status === \"object\" && \"tag\" in status) {\n\t\treturn String((status as { tag: string }).tag);\n\t}\n\treturn String(status);\n};\n\nconst discoveryStatusDisplay = (status: unknown): string => {\n\tconst tag = discoveryStatusTag(status);\n\tconst map: Record<string, string> = {\n\t\tPendingReview: \"pending_review\",\n\t\tApproved: \"approved\",\n\t\tRejected: \"rejected\",\n\t\tEscalatedToIdea: \"escalated_to_idea\",\n\t};\n\treturn map[tag] ?? tag;\n};\n\nexport default defineCommand({\n\tmeta: { name: \"discover\", description: \"Discovered task management\" },\n\targs: {\n\t\taction: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Action: report, review, list, get\",\n\t\t\trequired: false,\n\t\t},\n\t\tid: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Discovered task ID\",\n\t\t\trequired: false,\n\t\t},\n\t\tdecision: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Decision: approve, reject, escalate_to_idea\",\n\t\t\trequired: false,\n\t\t},\n\t\ttask: { type: \"string\", description: \"Current task ID\" },\n\t\tproject: { type: \"string\", description: \"Project ID\" },\n\t\ttitle: { type: \"string\", description: \"Task title\" },\n\t\ttype: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Task type: bug, improvement, feature\",\n\t\t},\n\t\tseverity: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Severity: low, medium, high, critical\",\n\t\t},\n\t\tstatus: { type: \"string\", description: \"Filter by status\" },\n\t\tlimit: { type: \"string\", description: \"Limit discovered tasks returned\" },\n\t\tdescription: { type: \"string\", description: \"Description\" },\n\t\treason: { type: \"string\", description: \"Rejection reason\" },\n\t\twallet: { type: \"string\", description: \"Wallet name\" },\n\t\tjson: { type: \"boolean\", description: \"Output JSON\", default: false },\n\t\thost: { type: \"string\", description: \"SpacetimeDB host\" },\n\t\tmodule: { type: \"string\", description: \"Module name\" },\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) setJsonMode(true);\n\n\t\tif (!args.action) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe discover\",\n\t\t\t\tdescription: \"Discovered task reporting and review\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe discover <action> [options]\",\n\t\t\t\t\t'probe discover report --task 12 --project 1 --title \"Fix parse\"',\n\t\t\t\t\t\"probe discover review 9 approve\",\n\t\t\t\t],\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"report\",\n\t\t\t\t\t\tdetail: \"Report a discovered task from current work\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"review <id> <approve|reject|escalate_to_idea>\",\n\t\t\t\t\t\tdetail: \"Approve, reject, or escalate discovery\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"list\", detail: \"List discovered tasks\" },\n\t\t\t\t\t{ name: \"get <id>\", detail: \"Show one discovered task\" },\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--task, --project, --title\", detail: \"Required for report\" },\n\t\t\t\t\t{ name: \"--type\", detail: \"Task type: bug, improvement, feature\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--severity\",\n\t\t\t\t\t\tdetail: \"Severity: low, medium, high, critical\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"--reason\", detail: \"Reason for rejection/escalation\" },\n\t\t\t\t\t{ name: \"--limit\", detail: \"Max discovered tasks returned for list\" },\n\t\t\t\t\t{ name: \"--wallet\", detail: \"Wallet to use for authenticated calls\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--host, --module\",\n\t\t\t\t\t\tdetail: \"Nexus SpacetimeDB target overrides\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tnotes: [\n\t\t\t\t\t\"Find current task IDs with `probe task list` and project IDs with `probe project list`.\",\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst action = args.action;\n\n\t\ttry {\n\t\t\tswitch (action) {\n\t\t\t\tcase \"report\": {\n\t\t\t\t\tif (!args.task || !args.project || !args.title) {\n\t\t\t\t\t\terror(\"ARGS_REQUIRED\", \"--task, --project, and --title required\");\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"discoverTask\", {\n\t\t\t\t\t\t\t\t\tcurrentTaskId: BigInt(args.task),\n\t\t\t\t\t\t\t\t\tprojectId: BigInt(args.project),\n\t\t\t\t\t\t\t\t\ttitle: args.title,\n\t\t\t\t\t\t\t\t\tdescription: args.description || \"\",\n\t\t\t\t\t\t\t\t\tpriority: 5,\n\t\t\t\t\t\t\t\t\ttaskType: args.type || \"improvement\",\n\t\t\t\t\t\t\t\t\tseverity: args.severity || \"medium\",\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\tsuccess({ reported: true, title: args.title });\n\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\ttoonList(\"discovery_reported\", [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttitle: args.title,\n\t\t\t\t\t\t\t\t\t\ttaskId: args.task,\n\t\t\t\t\t\t\t\t\t\tprojectId: args.project,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"review\": {\n\t\t\t\t\tconst discId = args.id;\n\t\t\t\t\tconst decisionInput = args.decision;\n\t\t\t\t\tif (!discId || !decisionInput)\n\t\t\t\t\t\terror(\"ARGS_REQUIRED\", \"ID and decision required\");\n\n\t\t\t\t\tconst decision = decisionInput.toLowerCase();\n\n\t\t\t\t\tconst validDecisions = [\"approve\", \"reject\", \"escalate_to_idea\"];\n\t\t\t\t\tif (!validDecisions.includes(decision)) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"INVALID_DECISION\",\n\t\t\t\t\t\t\t`Invalid decision: ${decisionInput}. Use: ${validDecisions.join(\", \")}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst decisionValue = toDiscoveryDecision(decision);\n\t\t\t\t\tif (!decisionValue) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"INVALID_DECISION\",\n\t\t\t\t\t\t\t`Invalid decision: ${decisionInput}. Use: ${validDecisions.join(\", \")}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"reviewDiscoveredTask\", {\n\t\t\t\t\t\t\t\t\tdiscoveryId: BigInt(discId),\n\t\t\t\t\t\t\t\t\tdecision: decisionValue,\n\t\t\t\t\t\t\t\t\treason: args.reason || undefined,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\tsuccess({ reviewed: true, id: discId, decision });\n\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\ttoonList(\"discovery_reviewed\", [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: discId,\n\t\t\t\t\t\t\t\t\t\tdecision,\n\t\t\t\t\t\t\t\t\t\treason: args.reason || \"\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"list\": {\n\t\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\t\thost: args.host,\n\t\t\t\t\t\tmodule: args.module,\n\t\t\t\t\t});\n\t\t\t\t\tlet discovered = ctx.iter<DiscoveredTask>(\"discovered_tasks\");\n\t\t\t\t\tconst limit = args.limit ? parseInt(args.limit, 10) : undefined;\n\n\t\t\t\t\tif (limit !== undefined && (!Number.isFinite(limit) || limit <= 0)) {\n\t\t\t\t\t\terror(\"INVALID_LIMIT\", \"--limit must be a positive integer\");\n\t\t\t\t\t}\n\n\t\t\t\t\tif (args.status) {\n\t\t\t\t\t\tconst filter = args.status.toLowerCase().replace(/[_\\s]/g, \"\");\n\t\t\t\t\t\tdiscovered = discovered.filter(\n\t\t\t\t\t\t\t(d) =>\n\t\t\t\t\t\t\t\tdiscoveryStatusDisplay(d.status).replace(/[_\\s]/g, \"\") ===\n\t\t\t\t\t\t\t\tfilter,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tdiscovered = discovered.sort((a, b) => {\n\t\t\t\t\t\tconst aMicros = toMicros(a.createdAt);\n\t\t\t\t\t\tconst bMicros = toMicros(b.createdAt);\n\t\t\t\t\t\tif (aMicros !== bMicros) return bMicros > aMicros ? 1 : -1;\n\t\t\t\t\t\tif (a.id === b.id) return 0;\n\t\t\t\t\t\treturn b.id > a.id ? 1 : -1;\n\t\t\t\t\t});\n\t\t\t\t\tif (limit !== undefined) discovered = discovered.slice(0, limit);\n\n\t\t\t\t\tsuccess({ discoveredTasks: discovered, count: discovered.length });\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\n\t\t\t\t\t\t\t\t\"discovered_tasks\",\n\t\t\t\t\t\t\t\tdiscovered.map((d) => ({\n\t\t\t\t\t\t\t\t\tid: d.id.toString(),\n\t\t\t\t\t\t\t\t\ttitle: d.title,\n\t\t\t\t\t\t\t\t\ttaskType: d.taskType,\n\t\t\t\t\t\t\t\t\tseverity: d.severity,\n\t\t\t\t\t\t\t\t\tstatus: discoveryStatusDisplay(d.status),\n\t\t\t\t\t\t\t\t\tprojectId: d.projectId,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"get\": {\n\t\t\t\t\tconst discoveryId = args.id;\n\t\t\t\t\tif (!discoveryId)\n\t\t\t\t\t\terror(\"DISCOVERY_ID_REQUIRED\", \"Discovery ID required\");\n\n\t\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\t\thost: args.host,\n\t\t\t\t\t\tmodule: args.module,\n\t\t\t\t\t});\n\t\t\t\t\tconst discovery = ctx\n\t\t\t\t\t\t.iter<DiscoveredTask>(\"discovered_tasks\")\n\t\t\t\t\t\t.find((d) => d.id.toString() === discoveryId);\n\t\t\t\t\tif (!discovery)\n\t\t\t\t\t\terror(\"DISCOVERY_NOT_FOUND\", `Discovery not found: ${discoveryId}`);\n\n\t\t\t\t\tsuccess(discovery);\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\"discovered_task\", [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: discovery.id.toString(),\n\t\t\t\t\t\t\t\t\ttitle: discovery.title,\n\t\t\t\t\t\t\t\t\tstatus: discoveryStatusDisplay(discovery.status),\n\t\t\t\t\t\t\t\t\ttaskType: discovery.taskType,\n\t\t\t\t\t\t\t\t\tseverity: discovery.severity,\n\t\t\t\t\t\t\t\t\tpriority: discovery.priority,\n\t\t\t\t\t\t\t\t\tprojectId: discovery.projectId.toString(),\n\t\t\t\t\t\t\t\t\tcurrentTaskId: discovery.currentTaskId.toString(),\n\t\t\t\t\t\t\t\t\tdescription: discovery.description,\n\t\t\t\t\t\t\t\t\treviewedBy: discovery.reviewedBy || \"\",\n\t\t\t\t\t\t\t\t\treviewedAt: discovery.reviewedAt\n\t\t\t\t\t\t\t\t\t\t? formatTimestamp(discovery.reviewedAt)\n\t\t\t\t\t\t\t\t\t\t: \"\",\n\t\t\t\t\t\t\t\t\trejectionReason: discovery.rejectionReason || \"\",\n\t\t\t\t\t\t\t\t\tcreatedTaskId: discovery.createdTaskId\n\t\t\t\t\t\t\t\t\t\t? discovery.createdTaskId.toString()\n\t\t\t\t\t\t\t\t\t\t: \"\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault:\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"INVALID_ACTION\",\n\t\t\t\t\t\t`Invalid action: ${action}`,\n\t\t\t\t\t\t\"Use: report, review, list, get\",\n\t\t\t\t\t);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\terror(\"CONNECTION_ERROR\", message);\n\t\t}\n\t},\n});\n","import { defineCommand } from \"citty\";\nimport {\n\tCommandContext,\n\tcallReducer,\n\ttype EvaluationDimension,\n\ttype Idea,\n\twithAuth,\n} from \"~/utils/context.js\";\nimport { IdeaStatus } from \"~/utils/enums.js\";\nimport { printHelp } from \"~/utils/help.js\";\nimport { error, isJsonMode, setJsonMode, success } from \"~/utils/output.js\";\nimport { toMicros } from \"~/utils/time.js\";\nimport { toonList } from \"~/utils/toon.js\";\n\nconst SCORE_FLAGS = [\n\t[\"ecosystem-impact\", \"ecosystem_impact\"],\n\t[\"implementation-readiness\", \"implementation_readiness\"],\n\t[\"dependency-independence\", \"dependency_independence\"],\n\t[\"documentation-leverage\", \"documentation_leverage\"],\n\t[\"maintenance-sustainability\", \"maintenance_sustainability\"],\n\t[\"agent-capability-fit\", \"agent_capability_fit\"],\n\t[\"execution-clarity\", \"execution_clarity\"],\n] as const;\n\ntype DimensionScoreInput = { dimension: string; score: number };\n\nfunction normalizeScore(rawScore: unknown, label: string): number {\n\tconst score = Number(rawScore);\n\tif (!Number.isInteger(score)) {\n\t\terror(\"INVALID_SCORES\", `Score for '${label}' must be an integer`);\n\t}\n\treturn score;\n}\n\nfunction validateDimensionScores(\n\tscores: DimensionScoreInput[],\n\tdimensions: EvaluationDimension[],\n): void {\n\tconst activeDimensions = dimensions\n\t\t.filter((d) => d.active)\n\t\t.sort((a, b) => a.sortOrder - b.sortOrder);\n\tconst scoreMap = new Map(scores.map((s) => [s.dimension, s.score]));\n\n\tfor (const dim of activeDimensions) {\n\t\tif (!scoreMap.has(dim.name)) {\n\t\t\terror(\n\t\t\t\t\"MISSING_DIMENSION\",\n\t\t\t\t`Missing score for dimension: ${dim.label || dim.name}`,\n\t\t\t);\n\t\t}\n\t\tconst score = scoreMap.get(dim.name)!;\n\t\tif (score < dim.minScore || score > dim.maxScore) {\n\t\t\terror(\n\t\t\t\t\"INVALID_SCORE\",\n\t\t\t\t`Score for '${dim.name}' must be between ${dim.minScore} and ${dim.maxScore}`,\n\t\t\t);\n\t\t}\n\t}\n\n\tconst activeNames = new Set(activeDimensions.map((d) => d.name));\n\tfor (const score of scores) {\n\t\tif (!activeNames.has(score.dimension)) {\n\t\t\terror(\"UNKNOWN_DIMENSION\", `Unknown dimension: ${score.dimension}`);\n\t\t}\n\t}\n}\n\nfunction addScore(\n\tscores: Map<string, DimensionScoreInput>,\n\tdimension: string,\n\trawScore: unknown,\n): void {\n\tconst normalizedDimension = dimension.trim().replaceAll(\"-\", \"_\");\n\tif (!normalizedDimension) {\n\t\terror(\"INVALID_SCORES\", \"Dimension names cannot be empty\");\n\t}\n\tif (scores.has(normalizedDimension)) {\n\t\terror(\n\t\t\t\"INVALID_SCORES\",\n\t\t\t`Dimension '${normalizedDimension}' was provided more than once`,\n\t\t);\n\t}\n\tscores.set(normalizedDimension, {\n\t\tdimension: normalizedDimension,\n\t\tscore: normalizeScore(rawScore, normalizedDimension),\n\t});\n}\n\nfunction parseScorePairs(rawValue: unknown): Array<[string, string]> {\n\tif (rawValue === undefined) return [];\n\tconst values = Array.isArray(rawValue) ? rawValue : [rawValue];\n\treturn values.flatMap((value) =>\n\t\tString(value)\n\t\t\t.split(\",\")\n\t\t\t.map((part) => part.trim())\n\t\t\t.filter(Boolean)\n\t\t\t.map((part) => {\n\t\t\t\tconst separator = part.indexOf(\"=\");\n\t\t\t\tif (separator <= 0 || separator === part.length - 1) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"INVALID_SCORES\",\n\t\t\t\t\t\t\"--score entries must use dimension=value syntax\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn [part.slice(0, separator), part.slice(separator + 1)] as [\n\t\t\t\t\tstring,\n\t\t\t\t\tstring,\n\t\t\t\t];\n\t\t\t}),\n\t);\n}\n\nfunction buildDimensionScores(args: Record<string, unknown>): DimensionScoreInput[] {\n\tconst scores = new Map<string, DimensionScoreInput>();\n\n\tfor (const [flag, dimension] of SCORE_FLAGS) {\n\t\tif (args[flag] !== undefined) {\n\t\t\taddScore(scores, dimension, args[flag]);\n\t\t}\n\t}\n\n\tfor (const [dimension, rawScore] of parseScorePairs(args.score)) {\n\t\taddScore(scores, dimension, rawScore);\n\t}\n\n\tif (scores.size === 0) {\n\t\terror(\n\t\t\t\"ARGS_REQUIRED\",\n\t\t\t\"Provide dimension scores with score flags or --score dimension=value\",\n\t\t);\n\t}\n\n\treturn [...scores.values()];\n}\n\nexport default defineCommand({\n\tmeta: { name: \"idea\", description: \"Idea management\" },\n\targs: {\n\t\taction: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Action: list, propose, vote, get, dimensions\",\n\t\t\trequired: false,\n\t\t},\n\t\tid: { type: \"positional\", description: \"Idea ID\", required: false },\n\t\ttitle: { type: \"string\", description: \"Idea title\" },\n\t\tcategory: { type: \"string\", description: \"Category\" },\n\t\tdescription: { type: \"string\", description: \"Description\" },\n\t\tstatus: { type: \"string\", description: \"Filter by status\" },\n\t\tlimit: { type: \"string\", description: \"Limit ideas returned\" },\n\t\t\"ecosystem-impact\": { type: \"string\", description: \"Ecosystem Impact score\" },\n\t\t\"implementation-readiness\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Implementation Readiness score\",\n\t\t},\n\t\t\"dependency-independence\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Dependency Independence score\",\n\t\t},\n\t\t\"documentation-leverage\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Documentation Leverage score\",\n\t\t},\n\t\t\"maintenance-sustainability\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Maintenance Sustainability score\",\n\t\t},\n\t\t\"agent-capability-fit\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Agent Capability Fit score\",\n\t\t},\n\t\t\"execution-clarity\": { type: \"string\", description: \"Execution Clarity score\" },\n\t\tscore: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Additional dimension score as name=value; repeatable\",\n\t\t\tmultiple: true,\n\t\t},\n\t\twallet: { type: \"string\", description: \"Wallet name\" },\n\t\tjson: { type: \"boolean\", description: \"Output JSON\", default: false },\n\t\thost: { type: \"string\", description: \"SpacetimeDB host\" },\n\t\tmodule: { type: \"string\", description: \"Module name\" },\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) setJsonMode(true);\n\n\t\tif (!args.action) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe idea\",\n\t\t\t\tdescription: \"Idea discovery, review, and voting\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe idea <action> [options]\",\n\t\t\t\t\t\"probe idea list --status voting\",\n\t\t\t\t\t\"probe idea dimensions\",\n\t\t\t\t\t\"probe idea vote 42 --ecosystem-impact 8 --execution-clarity 9 --implementation-readiness 7\",\n\t\t\t\t],\n\t\t\t\tactions: [\n\t\t\t\t\t{ name: \"list\", detail: \"List ideas with optional filters\" },\n\t\t\t\t\t{ name: \"get <id>\", detail: \"Show one idea\" },\n\t\t\t\t\t{ name: \"dimensions\", detail: \"List active evaluation dimensions\" },\n\t\t\t\t\t{ name: \"propose\", detail: \"Propose a new idea\" },\n\t\t\t\t\t{ name: \"vote <id>\", detail: \"Vote on an idea with dimension scores\" },\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--title\", detail: \"Idea title for propose\" },\n\t\t\t\t\t{ name: \"--description\", detail: \"Idea description for propose\" },\n\t\t\t\t\t{ name: \"--category\", detail: \"Idea category for propose/list\" },\n\t\t\t\t\t{ name: \"--ecosystem-impact\", detail: \"Ecosystem impact score\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--implementation-readiness\",\n\t\t\t\t\t\tdetail: \"Implementation readiness score\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--dependency-independence\",\n\t\t\t\t\t\tdetail: \"Dependency independence score\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--documentation-leverage\",\n\t\t\t\t\t\tdetail: \"Documentation leverage score\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--maintenance-sustainability\",\n\t\t\t\t\t\tdetail: \"Maintenance sustainability score\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--agent-capability-fit\",\n\t\t\t\t\t\tdetail: \"Agent capability fit score\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"--execution-clarity\", detail: \"Execution clarity score\" },\n\t\t\t\t\t{ name: \"--score\", detail: \"Additional dimension score as name=value; repeatable\" },\n\t\t\t\t\t{ name: \"--status\", detail: \"Status filter for list\" },\n\t\t\t\t\t{ name: \"--limit\", detail: \"Max ideas returned for list\" },\n\t\t\t\t\t{ name: \"--wallet\", detail: \"Wallet to use for authenticated calls\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--host, --module\",\n\t\t\t\t\t\tdetail: \"Nexus SpacetimeDB target overrides\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tnotes: [\n\t\t\t\t\t\"Find idea IDs with `probe idea list` before using get/vote.\",\n\t\t\t\t\t\"Use `probe idea dimensions` to list active score dimensions.\",\n\t\t\t\t\t\"All active dimensions are required. Use explicit flags for default dimensions and repeatable --score name=value for custom dimensions.\",\n\t\t\t\t\t\"If a missing-dimension error names a dimension without a dedicated flag, use --score and consider updating Probe.\",\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst action = args.action;\n\n\t\ttry {\n\t\t\tswitch (action) {\n\t\t\t\tcase \"list\": {\n\t\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\t\thost: args.host,\n\t\t\t\t\t\tmodule: args.module,\n\t\t\t\t\t});\n\t\t\t\t\tlet ideas = ctx.iter<Idea>(\"ideas\");\n\t\t\t\t\tconst limit = args.limit ? parseInt(args.limit, 10) : undefined;\n\n\t\t\t\t\tif (limit !== undefined && (!Number.isFinite(limit) || limit <= 0)) {\n\t\t\t\t\t\terror(\"INVALID_LIMIT\", \"--limit must be a positive integer\");\n\t\t\t\t\t}\n\n\t\t\t\t\tif (args.status)\n\t\t\t\t\t\tideas = ideas.filter((i) =>\n\t\t\t\t\t\t\tIdeaStatus.matches(i.status, args.status),\n\t\t\t\t\t\t);\n\t\t\t\t\tif (args.category)\n\t\t\t\t\t\tideas = ideas.filter((i) => i.category === args.category);\n\t\t\t\t\tideas = ideas.sort((a, b) => {\n\t\t\t\t\t\tconst aMicros = toMicros(a.createdAt);\n\t\t\t\t\t\tconst bMicros = toMicros(b.createdAt);\n\t\t\t\t\t\tif (aMicros !== bMicros) return bMicros > aMicros ? 1 : -1;\n\t\t\t\t\t\tif (a.id === b.id) return 0;\n\t\t\t\t\t\treturn b.id > a.id ? 1 : -1;\n\t\t\t\t\t});\n\t\t\t\t\tif (limit !== undefined) ideas = ideas.slice(0, limit);\n\n\t\t\t\t\tsuccess({ ideas, count: ideas.length });\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\n\t\t\t\t\t\t\t\t\"ideas\",\n\t\t\t\t\t\t\t\tideas.map((i) => ({\n\t\t\t\t\t\t\t\t\tid: i.id.toString(),\n\t\t\t\t\t\t\t\t\ttitle: i.title,\n\t\t\t\t\t\t\t\t\tcategory: i.category,\n\t\t\t\t\t\t\t\t\tstatus: IdeaStatus.display(i.status),\n\t\t\t\t\t\t\t\t\tvotes: `${i.totalVotes}/${i.quorum}`,\n\t\t\t\t\t\t\t\t\tup: i.upVotes,\n\t\t\t\t\t\t\t\t\tveto: i.vetoCount,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"get\": {\n\t\t\t\t\tconst ideaId = args.id;\n\t\t\t\t\tif (!ideaId) error(\"IDEA_ID_REQUIRED\", \"Idea ID required\");\n\n\t\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\t\thost: args.host,\n\t\t\t\t\t\tmodule: args.module,\n\t\t\t\t\t});\n\t\t\t\t\tconst idea = ctx\n\t\t\t\t\t\t.iter<Idea>(\"ideas\")\n\t\t\t\t\t\t.find((i) => i.id.toString() === ideaId);\n\t\t\t\t\tif (!idea) error(\"IDEA_NOT_FOUND\", `Idea not found: ${ideaId}`);\n\n\t\t\t\t\t\tsuccess(idea);\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\"idea\", [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: idea.id.toString(),\n\t\t\t\t\t\t\t\t\ttitle: idea.title,\n\t\t\t\t\t\t\t\t\tcategory: idea.category,\n\t\t\t\t\t\t\t\t\tstatus: IdeaStatus.display(idea.status),\n\t\t\t\t\t\t\t\t\ttotalVotes: idea.totalVotes,\n\t\t\t\t\t\t\t\t\tquorum: idea.quorum,\n\t\t\t\t\t\t\t\t\tupVotes: idea.upVotes,\n\t\t\t\t\t\t\t\t\tdownVotes: idea.downVotes,\n\t\t\t\t\t\t\t\t\tvetoCount: idea.vetoCount,\n\t\t\t\t\t\t\t\t\tapprovalThreshold: idea.approvalThreshold,\n\t\t\t\t\t\t\t\t\tvetoThreshold: idea.vetoThreshold,\n\t\t\t\t\t\t\t\t\tcomputedScore: idea.computedScore,\n\t\t\t\t\t\t\t\t\tdescription: idea.description,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"dimensions\": {\n\t\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\t\thost: args.host,\n\t\t\t\t\t\tmodule: args.module,\n\t\t\t\t\t});\n\t\t\t\t\tconst dimensions = ctx\n\t\t\t\t\t\t.iter<EvaluationDimension>(\"evaluation_dimensions\")\n\t\t\t\t\t\t.filter((dimension) => dimension.active)\n\t\t\t\t\t\t.sort((a, b) => a.sortOrder - b.sortOrder);\n\n\t\t\t\t\tsuccess({ dimensions, count: dimensions.length });\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\n\t\t\t\t\t\t\t\t\"evaluation_dimensions\",\n\t\t\t\t\t\t\t\tdimensions.map((dimension) => ({\n\t\t\t\t\t\t\t\t\tname: dimension.name,\n\t\t\t\t\t\t\t\t\tlabel: dimension.label,\n\t\t\t\t\t\t\t\t\tweight: dimension.weight,\n\t\t\t\t\t\t\t\t\trange: `${dimension.minScore}-${dimension.maxScore}`,\n\t\t\t\t\t\t\t\t\tdescription: dimension.description,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"propose\": {\n\t\t\t\t\tif (!args.title) error(\"ARGS_REQUIRED\", \"Title required\");\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"proposeIdea\", {\n\t\t\t\t\t\t\t\t\ttitle: args.title,\n\t\t\t\t\t\t\t\t\tdescription: args.description || \"\",\n\t\t\t\t\t\t\t\t\tcategory: args.category || \"general\",\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\tsuccess({ proposed: true, title: args.title });\n\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\ttoonList(\"idea_proposed\", [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttitle: args.title,\n\t\t\t\t\t\t\t\t\t\tcategory: args.category || \"general\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"vote\": {\n\t\t\t\t\tconst ideaId = args.id;\n\t\t\t\t\tif (!ideaId) error(\"ARGS_REQUIRED\", \"Idea ID required\");\n\t\t\t\t\tconst dimensionScores = buildDimensionScores(args);\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\t\tconst activeDimensions = ctx.iter<EvaluationDimension>(\n\t\t\t\t\t\t\t\t\t\"evaluation_dimensions\",\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tvalidateDimensionScores(dimensionScores, activeDimensions);\n\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"voteIdea\", {\n\t\t\t\t\t\t\t\t\tideaId: BigInt(ideaId),\n\t\t\t\t\t\t\t\t\tscores: dimensionScores,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\tsuccess({ voted: true, ideaId, scores: dimensionScores });\n\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\ttoonList(\"idea_voted\", [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tideaId,\n\t\t\t\t\t\t\t\t\t\tscores: JSON.stringify(dimensionScores),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault:\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"INVALID_ACTION\",\n\t\t\t\t\t\t`Invalid action: ${action}`,\n\t\t\t\t\t\t\"Use: list, propose, vote, get, dimensions\",\n\t\t\t\t\t);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\terror(\"CONNECTION_ERROR\", message);\n\t\t}\n\t},\n});\n","import type { MessageType as MessageTypeTag } from \"~/module_bindings/types.js\";\nimport {\n\ttype Channel,\n\tCommandContext,\n\tcallReducer,\n\ttype Message,\n\ttype Project,\n\ttype ProjectMessage,\n\twithAuth,\n} from \"~/utils/context.js\";\nimport { MessageType } from \"~/utils/enums.js\";\nimport { error, isJsonMode, success } from \"~/utils/output.js\";\nimport { formatTimestamp, toMicros } from \"~/utils/time.js\";\nimport { toonList } from \"~/utils/toon.js\";\n\nexport interface MessageCommandArgs {\n\taction?: string;\n\ttarget?: string;\n\tcontent?: string;\n\ttype?: string;\n\tcontext?: string;\n\tlimit?: string;\n\twallet?: string;\n\thost?: string;\n\tmodule?: string;\n}\n\nconst isNumeric = (str: string): boolean => /^\\d+$/.test(str);\nconst matchesContext = (\n\tmessage: Message | ProjectMessage,\n\tcontext?: string,\n): boolean => {\n\tif (!context) return true;\n\tconst normalized = context.trim();\n\tif (!normalized) return true;\n\treturn (\n\t\tmessage.id.toString() === normalized ||\n\t\t(message.contextId || \"\") === normalized\n\t);\n};\n\nconst isUserMessage = (messageType: MessageTypeTag): boolean =>\n\tMessageType.is.user(messageType);\nconst isDirectiveMessage = (messageType: MessageTypeTag): boolean =>\n\tMessageType.is.directive(messageType);\n\nexport const runMessageAction = async (\n\targs: MessageCommandArgs,\n): Promise<void> => {\n\tconst action = args.action;\n\tif (!action) {\n\t\terror(\"ACTION_REQUIRED\", \"Message action required\");\n\t}\n\n\ttry {\n\t\tswitch (action) {\n\t\t\tcase \"list\": {\n\t\t\t\tconst targetInput = args.target;\n\t\t\t\tconst limit = parseInt(args.limit || \"20\", 10);\n\t\t\t\tif (!Number.isFinite(limit) || limit <= 0) {\n\t\t\t\t\terror(\"INVALID_LIMIT\", \"--limit must be a positive integer\");\n\t\t\t\t}\n\n\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\thost: args.host,\n\t\t\t\t\tmodule: args.module,\n\t\t\t\t});\n\t\t\t\tconst channels = ctx.iter<Channel>(\"channels\");\n\t\t\t\tconst projects = ctx.iter<Project>(\"projects\");\n\n\t\t\t\tlet messages: (Message | ProjectMessage)[] = [];\n\t\t\t\tlet targetLabel = \"all\";\n\n\t\t\t\tif (targetInput) {\n\t\t\t\t\tif (isNumeric(targetInput)) {\n\t\t\t\t\t\tconst projectId = BigInt(targetInput);\n\t\t\t\t\t\tconst projectMessages =\n\t\t\t\t\t\t\tctx.iter<ProjectMessage>(\"project_messages\");\n\t\t\t\t\t\tconst project = projects.find((p) => p.id === projectId);\n\n\t\t\t\t\t\tmessages = projectMessages\n\t\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t\t(m) =>\n\t\t\t\t\t\t\t\t\tm.projectId === projectId && isUserMessage(m.messageType),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.map((m) => ({ ...m, _type: \"project\" as const }));\n\t\t\t\t\t\ttargetLabel = project\n\t\t\t\t\t\t\t? `project:${project.name}`\n\t\t\t\t\t\t\t: `project:${projectId}`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst channel = channels.find(\n\t\t\t\t\t\t\t(c) => c.name === targetInput || c.id.toString() === targetInput,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (channel) {\n\t\t\t\t\t\t\tconst channelMessages = ctx.iter<Message>(\"messages\");\n\t\t\t\t\t\t\tmessages = channelMessages\n\t\t\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t\t\t(m) =>\n\t\t\t\t\t\t\t\t\t\tm.channelId === channel.id && isUserMessage(m.messageType),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t.map((m) => ({ ...m, _type: \"channel\" as const }));\n\t\t\t\t\t\t\ttargetLabel = `#${channel.name}`;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst channelMessages = ctx.iter<Message>(\"messages\");\n\t\t\t\t\tconst projectMessages = ctx.iter<ProjectMessage>(\"project_messages\");\n\n\t\t\t\t\tmessages = [\n\t\t\t\t\t\t...channelMessages\n\t\t\t\t\t\t\t.filter((m) => isUserMessage(m.messageType))\n\t\t\t\t\t\t\t.map((m) => ({ ...m, _type: \"channel\" as const })),\n\t\t\t\t\t\t...projectMessages\n\t\t\t\t\t\t\t.filter((m) => isUserMessage(m.messageType))\n\t\t\t\t\t\t\t.map((m) => ({ ...m, _type: \"project\" as const })),\n\t\t\t\t\t];\n\t\t\t\t}\n\n\t\t\t\tmessages = messages.filter((m) => matchesContext(m, args.context));\n\n\t\t\t\tmessages.sort((a, b) => {\n\t\t\t\t\tconst aTime = toMicros(a.createdAt);\n\t\t\t\t\tconst bTime = toMicros(b.createdAt);\n\t\t\t\t\tif (aTime < bTime) return 1;\n\t\t\t\t\tif (aTime > bTime) return -1;\n\t\t\t\t\treturn 0;\n\t\t\t\t});\n\n\t\t\t\tmessages = messages.slice(0, limit);\n\n\t\t\t\tconst channelMap = new Map(\n\t\t\t\t\tchannels.map((c) => [c.id.toString(), c.name]),\n\t\t\t\t);\n\t\t\t\tconst projectMap = new Map(\n\t\t\t\t\tprojects.map((p) => [p.id.toString(), p.name]),\n\t\t\t\t);\n\n\t\t\t\tsuccess({ messages, count: messages.length, target: targetLabel });\n\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\ttoonList(\n\t\t\t\t\t\t\t\"messages\",\n\t\t\t\t\t\t\tmessages.map((m) => {\n\t\t\t\t\t\t\t\tconst isProject = \"_type\" in m && m._type === \"project\";\n\t\t\t\t\t\t\t\tconst location = isProject\n\t\t\t\t\t\t\t\t\t? `project:${projectMap.get((m as ProjectMessage).projectId.toString()) || (m as ProjectMessage).projectId}`\n\t\t\t\t\t\t\t\t\t: `#${channelMap.get((m as Message).channelId.toString()) || (m as Message).channelId}`;\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tid: m.id.toString(),\n\t\t\t\t\t\t\t\t\tlocation,\n\t\t\t\t\t\t\t\t\tsenderId: m.senderId,\n\t\t\t\t\t\t\t\t\tcontent:\n\t\t\t\t\t\t\t\t\t\tm.content.slice(0, 50) +\n\t\t\t\t\t\t\t\t\t\t(m.content.length > 50 ? \"...\" : \"\"),\n\t\t\t\t\t\t\t\t\tmessageType: MessageType.display(m.messageType),\n\t\t\t\t\t\t\t\t\tcontextId: m.contextId || null,\n\t\t\t\t\t\t\t\t\tcreatedAt: formatTimestamp(m.createdAt),\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"directives\": {\n\t\t\t\tconst targetInput = args.target;\n\t\t\t\tconst limit = parseInt(args.limit || \"20\", 10);\n\t\t\t\tif (!Number.isFinite(limit) || limit <= 0) {\n\t\t\t\t\terror(\"INVALID_LIMIT\", \"--limit must be a positive integer\");\n\t\t\t\t}\n\n\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\thost: args.host,\n\t\t\t\t\tmodule: args.module,\n\t\t\t\t});\n\t\t\t\tconst channels = ctx.iter<Channel>(\"channels\");\n\t\t\t\tconst projects = ctx.iter<Project>(\"projects\");\n\n\t\t\t\tlet messages: (Message | ProjectMessage)[] = [];\n\t\t\t\tlet targetLabel = \"all\";\n\n\t\t\t\tif (targetInput) {\n\t\t\t\t\tif (isNumeric(targetInput)) {\n\t\t\t\t\t\tconst projectId = BigInt(targetInput);\n\t\t\t\t\t\tconst projectMessages =\n\t\t\t\t\t\t\tctx.iter<ProjectMessage>(\"project_messages\");\n\t\t\t\t\t\tconst project = projects.find((p) => p.id === projectId);\n\n\t\t\t\t\t\tmessages = projectMessages\n\t\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t\t(m) =>\n\t\t\t\t\t\t\t\t\tm.projectId === projectId &&\n\t\t\t\t\t\t\t\t\tisDirectiveMessage(m.messageType),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.map((m) => ({ ...m, _type: \"project\" as const }));\n\t\t\t\t\t\ttargetLabel = project\n\t\t\t\t\t\t\t? `project:${project.name}`\n\t\t\t\t\t\t\t: `project:${projectId}`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst channel = channels.find(\n\t\t\t\t\t\t\t(c) => c.name === targetInput || c.id.toString() === targetInput,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (channel) {\n\t\t\t\t\t\t\tconst channelMessages = ctx.iter<Message>(\"messages\");\n\t\t\t\t\t\t\tmessages = channelMessages\n\t\t\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t\t\t(m) =>\n\t\t\t\t\t\t\t\t\t\tm.channelId === channel.id &&\n\t\t\t\t\t\t\t\t\t\tisDirectiveMessage(m.messageType),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t.map((m) => ({ ...m, _type: \"channel\" as const }));\n\t\t\t\t\t\t\ttargetLabel = `#${channel.name}`;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst channelMessages = ctx.iter<Message>(\"messages\");\n\t\t\t\t\tconst projectMessages = ctx.iter<ProjectMessage>(\"project_messages\");\n\n\t\t\t\t\tmessages = [\n\t\t\t\t\t\t...channelMessages\n\t\t\t\t\t\t\t.filter((m) => isDirectiveMessage(m.messageType))\n\t\t\t\t\t\t\t.map((m) => ({ ...m, _type: \"channel\" as const })),\n\t\t\t\t\t\t...projectMessages\n\t\t\t\t\t\t\t.filter((m) => isDirectiveMessage(m.messageType))\n\t\t\t\t\t\t\t.map((m) => ({ ...m, _type: \"project\" as const })),\n\t\t\t\t\t];\n\t\t\t\t}\n\n\t\t\t\tmessages = messages.filter((m) => matchesContext(m, args.context));\n\n\t\t\t\tmessages.sort((a, b) => {\n\t\t\t\t\tconst aTime = toMicros(a.createdAt);\n\t\t\t\t\tconst bTime = toMicros(b.createdAt);\n\t\t\t\t\tif (aTime < bTime) return 1;\n\t\t\t\t\tif (aTime > bTime) return -1;\n\t\t\t\t\treturn 0;\n\t\t\t\t});\n\n\t\t\t\tmessages = messages.slice(0, limit);\n\n\t\t\t\tconst channelMap = new Map(\n\t\t\t\t\tchannels.map((c) => [c.id.toString(), c.name]),\n\t\t\t\t);\n\t\t\t\tconst projectMap = new Map(\n\t\t\t\t\tprojects.map((p) => [p.id.toString(), p.name]),\n\t\t\t\t);\n\n\t\t\t\tsuccess({ messages, count: messages.length, target: targetLabel });\n\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\ttoonList(\n\t\t\t\t\t\t\t\"directives\",\n\t\t\t\t\t\t\tmessages.map((m) => {\n\t\t\t\t\t\t\t\tconst isProject = \"_type\" in m && m._type === \"project\";\n\t\t\t\t\t\t\t\tconst location = isProject\n\t\t\t\t\t\t\t\t\t? `project:${projectMap.get((m as ProjectMessage).projectId.toString()) || (m as ProjectMessage).projectId}`\n\t\t\t\t\t\t\t\t\t: `#${channelMap.get((m as Message).channelId.toString()) || (m as Message).channelId}`;\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tid: m.id.toString(),\n\t\t\t\t\t\t\t\t\tlocation,\n\t\t\t\t\t\t\t\t\tsenderId: m.senderId,\n\t\t\t\t\t\t\t\t\tcontent:\n\t\t\t\t\t\t\t\t\t\tm.content.slice(0, 50) +\n\t\t\t\t\t\t\t\t\t\t(m.content.length > 50 ? \"...\" : \"\"),\n\t\t\t\t\t\t\t\t\tmessageType: MessageType.display(m.messageType),\n\t\t\t\t\t\t\t\t\tcontextId: m.contextId || null,\n\t\t\t\t\t\t\t\t\tcreatedAt: formatTimestamp(m.createdAt),\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"directive\": {\n\t\t\t\tconst targetInput = args.target;\n\t\t\t\tconst content = args.content;\n\t\t\t\tif (!targetInput || !content) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"ARGS_REQUIRED\",\n\t\t\t\t\t\t\"Target and directive content required. Usage: probe message directive <target> <content>\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\tif (isNumeric(targetInput)) {\n\t\t\t\t\t\t\t\tconst projectId = BigInt(targetInput);\n\t\t\t\t\t\t\t\tconst projects = ctx.iter<Project>(\"projects\");\n\t\t\t\t\t\t\t\tconst projectChannels = ctx.iter<{ projectId: bigint }>(\n\t\t\t\t\t\t\t\t\t\"project_channels\",\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tconst project = projects.find((p) => p.id === projectId);\n\t\t\t\t\t\t\t\tif (!project) {\n\t\t\t\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\t\t\t\"PROJECT_NOT_FOUND\",\n\t\t\t\t\t\t\t\t\t\t`Project '${targetInput}' not found`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst projectChannel = projectChannels.find(\n\t\t\t\t\t\t\t\t\t(pc) => pc.projectId === projectId,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (!projectChannel) {\n\t\t\t\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\t\t\t\"PROJECT_CHANNEL_NOT_FOUND\",\n\t\t\t\t\t\t\t\t\t\t`Project channel for '${targetInput}' not found`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"sendProjectMessage\", {\n\t\t\t\t\t\t\t\t\tprojectId,\n\t\t\t\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t\t\t\tmessageType: MessageType.fromString(\"directive\"),\n\t\t\t\t\t\t\t\t\tcontextId: args.context,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tsuccess({\n\t\t\t\t\t\t\t\t\tsent: true,\n\t\t\t\t\t\t\t\t\tprojectId: projectId.toString(),\n\t\t\t\t\t\t\t\t\tprojectName: project.name,\n\t\t\t\t\t\t\t\t\tmessageType: \"directive\",\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\t\ttoonList(\"directive_sent\", [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\ttarget: `project:${project.name}`,\n\t\t\t\t\t\t\t\t\t\t\t\tcontextId: args.context || null,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconst channels = ctx.iter<Channel>(\"channels\");\n\t\t\t\t\t\t\t\tconst channel = channels.find(\n\t\t\t\t\t\t\t\t\t(c) =>\n\t\t\t\t\t\t\t\t\t\tc.name === targetInput || c.id.toString() === targetInput,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (!channel) {\n\t\t\t\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\t\t\t\"CHANNEL_NOT_FOUND\",\n\t\t\t\t\t\t\t\t\t\t`Channel '${targetInput}' not found. Available: ${channels.map((c) => c.name).join(\", \")}`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"sendMessage\", {\n\t\t\t\t\t\t\t\t\tchannelId: channel.id,\n\t\t\t\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t\t\t\tmessageType: MessageType.fromString(\"directive\"),\n\t\t\t\t\t\t\t\t\tcontextId: args.context,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tsuccess({\n\t\t\t\t\t\t\t\t\tsent: true,\n\t\t\t\t\t\t\t\t\tchannelId: channel.id.toString(),\n\t\t\t\t\t\t\t\t\tchannelName: channel.name,\n\t\t\t\t\t\t\t\t\tmessageType: \"directive\",\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\t\ttoonList(\"directive_sent\", [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\ttarget: `#${channel.name}`,\n\t\t\t\t\t\t\t\t\t\t\t\tcontextId: args.context || null,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} catch (err) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"send\": {\n\t\t\t\tconst targetInput = args.target;\n\t\t\t\tconst content = args.content;\n\t\t\t\tif (!targetInput || !content) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"ARGS_REQUIRED\",\n\t\t\t\t\t\t\"Target and message content required. Usage: probe message send <target> <content>\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif ((args.type || \"user\").toLowerCase() === \"directive\") {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"INVALID_TYPE\",\n\t\t\t\t\t\t\"'directive' is not allowed with 'message send'. Use: probe message directive <target> <content>\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\tif (isNumeric(targetInput)) {\n\t\t\t\t\t\t\t\tconst projectId = BigInt(targetInput);\n\t\t\t\t\t\t\t\tconst projects = ctx.iter<Project>(\"projects\");\n\t\t\t\t\t\t\t\tconst projectChannels = ctx.iter<{ projectId: bigint }>(\n\t\t\t\t\t\t\t\t\t\"project_channels\",\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tconst project = projects.find((p) => p.id === projectId);\n\t\t\t\t\t\t\t\tif (!project) {\n\t\t\t\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\t\t\t\"PROJECT_NOT_FOUND\",\n\t\t\t\t\t\t\t\t\t\t`Project '${targetInput}' not found`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst projectChannel = projectChannels.find(\n\t\t\t\t\t\t\t\t\t(pc) => pc.projectId === projectId,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (!projectChannel) {\n\t\t\t\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\t\t\t\"PROJECT_CHANNEL_NOT_FOUND\",\n\t\t\t\t\t\t\t\t\t\t`Project channel for '${targetInput}' not found`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"sendProjectMessage\", {\n\t\t\t\t\t\t\t\t\tprojectId,\n\t\t\t\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t\t\t\tmessageType: MessageType.fromString(args.type || \"user\"),\n\t\t\t\t\t\t\t\t\tcontextId: args.context,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tsuccess({\n\t\t\t\t\t\t\t\t\tsent: true,\n\t\t\t\t\t\t\t\t\tprojectId: projectId.toString(),\n\t\t\t\t\t\t\t\t\tprojectName: project.name,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\t\ttoonList(\"message_sent\", [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\ttarget: `project:${project.name}`,\n\t\t\t\t\t\t\t\t\t\t\t\tmessageType: args.type || \"user\",\n\t\t\t\t\t\t\t\t\t\t\t\tcontextId: args.context || null,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconst channels = ctx.iter<Channel>(\"channels\");\n\t\t\t\t\t\t\t\tconst channel = channels.find(\n\t\t\t\t\t\t\t\t\t(c) =>\n\t\t\t\t\t\t\t\t\t\tc.name === targetInput || c.id.toString() === targetInput,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (!channel) {\n\t\t\t\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\t\t\t\"CHANNEL_NOT_FOUND\",\n\t\t\t\t\t\t\t\t\t\t`Channel '${targetInput}' not found. Available: ${channels.map((c) => c.name).join(\", \")}`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"sendMessage\", {\n\t\t\t\t\t\t\t\t\tchannelId: channel.id,\n\t\t\t\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t\t\t\tmessageType: MessageType.fromString(args.type || \"user\"),\n\t\t\t\t\t\t\t\t\tcontextId: args.context,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tsuccess({\n\t\t\t\t\t\t\t\t\tsent: true,\n\t\t\t\t\t\t\t\t\tchannelId: channel.id.toString(),\n\t\t\t\t\t\t\t\t\tchannelName: channel.name,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\t\ttoonList(\"message_sent\", [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\ttarget: `#${channel.name}`,\n\t\t\t\t\t\t\t\t\t\t\t\tmessageType: args.type || \"user\",\n\t\t\t\t\t\t\t\t\t\t\t\tcontextId: args.context || null,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} catch (err) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"channels\": {\n\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\thost: args.host,\n\t\t\t\t\tmodule: args.module,\n\t\t\t\t});\n\t\t\t\tconst channels = ctx.iter<Channel>(\"channels\");\n\t\t\t\tconst projects = ctx.iter<Project>(\"projects\");\n\t\t\t\tconst projectChannels = ctx.iter<{ projectId: bigint }>(\n\t\t\t\t\t\"project_channels\",\n\t\t\t\t);\n\n\t\t\t\tconst projectChannelSet = new Set(\n\t\t\t\t\tprojectChannels.map((pc) => pc.projectId.toString()),\n\t\t\t\t);\n\t\t\t\tconst projectsWithChannels = projects.filter((p) =>\n\t\t\t\t\tprojectChannelSet.has(p.id.toString()),\n\t\t\t\t);\n\n\t\t\t\tsuccess({\n\t\t\t\t\tchannels,\n\t\t\t\t\tprojects: projectsWithChannels,\n\t\t\t\t\tchannelCount: channels.length,\n\t\t\t\t\tprojectCount: projectsWithChannels.length,\n\t\t\t\t});\n\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\ttoonList(\n\t\t\t\t\t\t\t\"channels\",\n\t\t\t\t\t\t\tchannels.map((c) => ({\n\t\t\t\t\t\t\t\tid: c.id.toString(),\n\t\t\t\t\t\t\t\tname: c.name,\n\t\t\t\t\t\t\t\tcreatedBy: c.createdBy,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\ttoonList(\n\t\t\t\t\t\t\t\"projects\",\n\t\t\t\t\t\t\tprojectsWithChannels.map((p) => ({\n\t\t\t\t\t\t\t\tid: p.id.toString(),\n\t\t\t\t\t\t\t\tname: p.name,\n\t\t\t\t\t\t\t\trepo: p.githubRepo,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\terror(\n\t\t\t\t\t\"INVALID_ACTION\",\n\t\t\t\t\t`Invalid action: ${action}`,\n\t\t\t\t\t\"Use: list, send, directive, directives, channels\",\n\t\t\t\t);\n\t\t}\n\t} catch (err) {\n\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\terror(\"CONNECTION_ERROR\", message);\n\t}\n};\n","import { defineCommand } from \"citty\";\nimport { printHelp } from \"~/utils/help.js\";\nimport { setJsonMode } from \"~/utils/output.js\";\nimport {\n\ttype MessageCommandArgs,\n\trunMessageAction,\n} from \"./message-handlers.js\";\n\nexport default defineCommand({\n\tmeta: { name: \"message\", description: \"Message management\" },\n\targs: {\n\t\taction: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Action: list, send, directive, directives, channels\",\n\t\t\trequired: false,\n\t\t},\n\t\ttarget: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Channel name, project ID, or message content\",\n\t\t\trequired: false,\n\t\t},\n\t\tcontent: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Message content (if target is channel/project)\",\n\t\t\trequired: false,\n\t\t},\n\t\ttype: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Message type: user, system\",\n\t\t\tdefault: \"user\",\n\t\t},\n\t\tcontext: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Thread context ID (message ID or entity ref like task:42)\",\n\t\t},\n\t\tlimit: { type: \"string\", description: \"Limit messages\", default: \"20\" },\n\t\twallet: { type: \"string\", description: \"Wallet name\" },\n\t\tjson: { type: \"boolean\", description: \"Output JSON\", default: false },\n\t\thost: { type: \"string\", description: \"SpacetimeDB host\" },\n\t\tmodule: { type: \"string\", description: \"Module name\" },\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) setJsonMode(true);\n\n\t\tif (!args.action) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe message\",\n\t\t\t\tdescription: \"Channel and project messaging commands\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe message <action> [target] [content] [options]\",\n\t\t\t\t\t\"probe message list --limit 50\",\n\t\t\t\t\t'probe message send general \"hello team\"',\n\t\t\t\t\t'probe message directive zoe \"Focus on project stability\" --context project:1',\n\t\t\t\t],\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"list [target]\",\n\t\t\t\t\t\tdetail: \"List user messages (all, channel, or project)\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"directives [target]\",\n\t\t\t\t\t\tdetail: \"List directive messages (all, channel, or project)\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"send <target> <content>\",\n\t\t\t\t\t\tdetail: \"Send to target channel/project\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"directive <target> <content>\",\n\t\t\t\t\t\tdetail: \"Send directive to target channel/project\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"channels\", detail: \"List channels and project channels\" },\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--type\",\n\t\t\t\t\t\tdetail: \"Message type: user, system (default: user)\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--context\",\n\t\t\t\t\t\tdetail: \"Optional thread context ID (message ID or entity ref)\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--limit\",\n\t\t\t\t\t\tdetail: \"Max messages returned for list (default: 20)\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"--wallet\", detail: \"Wallet to use for send\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--host, --module\",\n\t\t\t\t\t\tdetail: \"Nexus SpacetimeDB target overrides\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\texamples: [\n\t\t\t\t\t\"probe message send general hello\",\n\t\t\t\t\t'probe message directive zoe \"Pause new work\" --context project:1',\n\t\t\t\t\t\"probe message directives zoe --limit 1\",\n\t\t\t\t\t'probe message send zoe \"hello there\"',\n\t\t\t\t\t'probe message send zoe \"reviewed\" --context 123',\n\t\t\t\t\t'probe message send 1 \"project update\"',\n\t\t\t\t\t\"probe message list zoe --limit 10\",\n\t\t\t\t],\n\t\t\t\tnotes: [\n\t\t\t\t\t\"Quotes are only required when target/content contains spaces.\",\n\t\t\t\t\t\"Use `probe message channels` to discover available channel names and project IDs.\",\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tawait runMessageAction(args as MessageCommandArgs);\n\t},\n});\n","import { defineCommand } from \"citty\";\nimport {\n\tCommandContext,\n\tcallReducer,\n\ttype Project,\n\twithAuth,\n} from \"~/utils/context.js\";\nimport { ProjectStatus } from \"~/utils/enums.js\";\nimport { printHelp } from \"~/utils/help.js\";\nimport { error, isJsonMode, setJsonMode, success } from \"~/utils/output.js\";\nimport { toMicros } from \"~/utils/time.js\";\nimport { toonList } from \"~/utils/toon.js\";\n\nexport default defineCommand({\n\tmeta: { name: \"project\", description: \"Project commands\" },\n\targs: {\n\t\taction: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Action: list, get, create, status, set-status\",\n\t\t\trequired: false,\n\t\t},\n\t\tid: { type: \"positional\", description: \"Project ID\", required: false },\n\t\tvalue: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Status value for set-status: active|paused\",\n\t\t\trequired: false,\n\t\t},\n\t\tstatus: { type: \"string\", description: \"Filter by status\" },\n\t\tlimit: { type: \"string\", description: \"Limit projects returned\" },\n\t\tname: { type: \"string\", description: \"Project name\" },\n\t\tdescription: { type: \"string\", description: \"Project description\" },\n\t\t\"github-repo\": { type: \"string\", description: \"GitHub repository URL\" },\n\t\t\"source-idea\": { type: \"string\", description: \"Source idea ID\" },\n\t\twallet: { type: \"string\", description: \"Wallet name\" },\n\t\tjson: { type: \"boolean\", description: \"Output JSON\", default: false },\n\t\thost: { type: \"string\", description: \"SpacetimeDB host\" },\n\t\tmodule: { type: \"string\", description: \"Module name\" },\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) setJsonMode(true);\n\n\t\tif (!args.action) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe project\",\n\t\t\t\tdescription: \"Project listing and lookup commands\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe project <action> [options]\",\n\t\t\t\t\t\"probe project list --status active\",\n\t\t\t\t\t\"probe project get 1\",\n\t\t\t\t\t\"probe project status 1\",\n\t\t\t\t\t\"probe project set-status 1 paused --wallet admin-wallet\",\n\t\t\t\t],\n\t\t\t\tactions: [\n\t\t\t\t\t{ name: \"list\", detail: \"List projects with optional status filter\" },\n\t\t\t\t\t{ name: \"get <id>\", detail: \"Show one project by ID\" },\n\t\t\t\t\t{ name: \"create\", detail: \"Create a new project\" },\n\t\t\t\t\t{ name: \"status <id>\", detail: \"Show only project status\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"set-status <id> <active|paused>\",\n\t\t\t\t\t\tdetail: \"Update project status (admin/zoe)\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--status\", detail: \"Status filter for list: active|paused\" },\n\t\t\t\t\t{ name: \"--limit\", detail: \"Max projects returned for list\" },\n\t\t\t\t\t{ name: \"--name\", detail: \"Project name (create)\" },\n\t\t\t\t\t{ name: \"--description\", detail: \"Project description (create)\" },\n\t\t\t\t\t{ name: \"--github-repo\", detail: \"GitHub repository URL (create)\" },\n\t\t\t\t\t{ name: \"--source-idea\", detail: \"Source idea ID (create)\" },\n\t\t\t\t\t{ name: \"--wallet\", detail: \"Wallet to use for authenticated calls\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--host, --module\",\n\t\t\t\t\t\tdetail: \"Nexus SpacetimeDB target overrides\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tnotes: [\n\t\t\t\t\t\"Only admin/zoe identities can call set-status.\",\n\t\t\t\t\t\"Find idea IDs with `probe idea list` before using --source-idea.\",\n\t\t\t\t\t\"Find project IDs with `probe project list` before using get/create follow-up commands.\",\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst action = args.action;\n\n\t\ttry {\n\t\t\tswitch (action) {\n\t\t\t\tcase \"list\": {\n\t\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\t\thost: args.host,\n\t\t\t\t\t\tmodule: args.module,\n\t\t\t\t\t});\n\t\t\t\t\tlet projects = ctx.iter<Project>(\"projects\");\n\t\t\t\t\tconst limit = args.limit ? parseInt(args.limit, 10) : undefined;\n\n\t\t\t\t\tif (limit !== undefined && (!Number.isFinite(limit) || limit <= 0)) {\n\t\t\t\t\t\terror(\"INVALID_LIMIT\", \"--limit must be a positive integer\");\n\t\t\t\t\t}\n\n\t\t\t\t\tif (args.status)\n\t\t\t\t\t\tprojects = projects.filter((p) =>\n\t\t\t\t\t\t\tProjectStatus.matches(p.status, args.status as string),\n\t\t\t\t\t\t);\n\t\t\t\t\tprojects = projects.sort((a, b) => {\n\t\t\t\t\t\tconst aMicros = toMicros(a.createdAt);\n\t\t\t\t\t\tconst bMicros = toMicros(b.createdAt);\n\t\t\t\t\t\tif (aMicros !== bMicros) return bMicros > aMicros ? 1 : -1;\n\t\t\t\t\t\tif (a.id === b.id) return 0;\n\t\t\t\t\t\treturn b.id > a.id ? 1 : -1;\n\t\t\t\t\t});\n\t\t\t\t\tif (limit !== undefined) projects = projects.slice(0, limit);\n\n\t\t\t\t\tsuccess({ projects, count: projects.length });\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\n\t\t\t\t\t\t\t\t\"projects\",\n\t\t\t\t\t\t\t\tprojects.map((p) => ({\n\t\t\t\t\t\t\t\t\tid: p.id,\n\t\t\t\t\t\t\t\t\tname: p.name,\n\t\t\t\t\t\t\t\t\tstatus: ProjectStatus.display(p.status),\n\t\t\t\t\t\t\t\t\tgithubRepo: p.githubRepo,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"get\": {\n\t\t\t\t\tconst projectId = args.id;\n\t\t\t\t\tif (!projectId) error(\"PROJECT_ID_REQUIRED\", \"Project ID required\");\n\n\t\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\t\thost: args.host,\n\t\t\t\t\t\tmodule: args.module,\n\t\t\t\t\t});\n\t\t\t\t\tconst project = ctx\n\t\t\t\t\t\t.iter<Project>(\"projects\")\n\t\t\t\t\t\t.find((p) => p.id.toString() === projectId);\n\t\t\t\t\tif (!project)\n\t\t\t\t\t\terror(\"PROJECT_NOT_FOUND\", `Project not found: ${projectId}`);\n\n\t\t\t\t\tsuccess(project);\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\"project\", [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: project.id.toString(),\n\t\t\t\t\t\t\t\t\tname: project.name,\n\t\t\t\t\t\t\t\t\tstatus: ProjectStatus.display(project.status),\n\t\t\t\t\t\t\t\t\tgithubRepo: project.githubRepo,\n\t\t\t\t\t\t\t\t\tdescription: project.description,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"status\": {\n\t\t\t\t\tconst projectId = args.id;\n\t\t\t\t\tif (!projectId) error(\"PROJECT_ID_REQUIRED\", \"Project ID required\");\n\n\t\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\t\thost: args.host,\n\t\t\t\t\t\tmodule: args.module,\n\t\t\t\t\t});\n\t\t\t\t\tconst project = ctx\n\t\t\t\t\t\t.iter<Project>(\"projects\")\n\t\t\t\t\t\t.find((p) => p.id.toString() === projectId);\n\t\t\t\t\tif (!project)\n\t\t\t\t\t\terror(\"PROJECT_NOT_FOUND\", `Project not found: ${projectId}`);\n\n\t\t\t\t\tconst status = ProjectStatus.display(project.status);\n\t\t\t\t\tsuccess({ projectId, status });\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\"project_status\", [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: project.id.toString(),\n\t\t\t\t\t\t\t\t\tname: project.name,\n\t\t\t\t\t\t\t\t\tstatus,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"create\": {\n\t\t\t\t\tif (!args.name || !args[\"github-repo\"] || !args[\"source-idea\"]) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"ARGS_REQUIRED\",\n\t\t\t\t\t\t\t\"--name, --github-repo, and --source-idea required\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"createProject\", {\n\t\t\t\t\t\t\t\t\tsourceIdeaId: BigInt(args[\"source-idea\"] as string),\n\t\t\t\t\t\t\t\t\tname: args.name,\n\t\t\t\t\t\t\t\t\tgithubRepo: args[\"github-repo\"],\n\t\t\t\t\t\t\t\t\tdescription: args.description || \"\",\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\tsuccess({\n\t\t\t\t\t\t\tcreated: true,\n\t\t\t\t\t\t\tname: args.name,\n\t\t\t\t\t\t\tgithubRepo: args[\"github-repo\"],\n\t\t\t\t\t\t\tsourceIdeaId: args[\"source-idea\"],\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\ttoonList(\"project_created\", [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: args.name,\n\t\t\t\t\t\t\t\t\t\tgithubRepo: args[\"github-repo\"],\n\t\t\t\t\t\t\t\t\t\tsourceIdeaId: args[\"source-idea\"],\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"set-status\": {\n\t\t\t\t\tconst projectId = args.id;\n\t\t\t\t\tconst nextStatus = args.value;\n\t\t\t\t\tif (!projectId || !nextStatus) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"ARGS_REQUIRED\",\n\t\t\t\t\t\t\t\"Project ID and status required. Use: probe project set-status <id> <active|paused>\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst normalized = nextStatus.toLowerCase().replace(/[_\\s]/g, \"\");\n\t\t\t\t\tif (![\"active\", \"paused\"].includes(normalized)) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"INVALID_STATUS\",\n\t\t\t\t\t\t\t`Invalid status: ${nextStatus}. Use: active, paused`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"updateProjectStatus\", {\n\t\t\t\t\t\t\t\t\tprojectId: BigInt(projectId),\n\t\t\t\t\t\t\t\t\tstatus: ProjectStatus.fromString(nextStatus),\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tsuccess({ updated: true, projectId, status: normalized });\n\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\ttoonList(\"project_status_updated\", [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tprojectId,\n\t\t\t\t\t\t\t\t\t\tstatus: normalized,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault:\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"INVALID_ACTION\",\n\t\t\t\t\t\t`Invalid action: ${action}`,\n\t\t\t\t\t\t\"Use: list, get, create, status, set-status\",\n\t\t\t\t\t);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\terror(\"CONNECTION_ERROR\", message);\n\t\t}\n\t},\n});\n","import {\n\tCommandContext,\n\tcallReducer,\n\ttype Project,\n\ttype Task,\n\ttype TaskDependency,\n\twithAuth,\n} from \"~/utils/context.js\";\nimport { TaskStatus } from \"~/utils/enums.js\";\nimport { error, isJsonMode, success } from \"~/utils/output.js\";\nimport { toMicros } from \"~/utils/time.js\";\nimport { toonList } from \"~/utils/toon.js\";\n\nexport interface TaskCommandArgs {\n\taction?: string;\n\tid?: string;\n\tstatus?: string;\n\tproject?: string;\n\ttitle?: string;\n\tdescription?: string;\n\tpriority?: string;\n\tassigned?: boolean;\n\twallet?: string;\n\t\"github-pr-url\"?: string;\n\t\"github-issue-url\"?: string;\n\t\"add-dep\"?: string;\n\tlist?: boolean;\n\ttimeout?: string;\n\tlimit?: string;\n\thost?: string;\n\tmodule?: string;\n}\n\nconst normalizeGitHubRepoUrl = (githubRepo: string): string | undefined => {\n\tconst value = githubRepo.trim().replace(/\\.git$/i, \"\");\n\tif (!value) return undefined;\n\n\tif (/^[\\w.-]+\\/[\\w.-]+$/.test(value)) {\n\t\treturn `https://github.com/${value}`;\n\t}\n\n\tconst sshMatch = value.match(/^git@github\\.com:([\\w.-]+\\/[\\w.-]+)$/i);\n\tif (sshMatch) {\n\t\treturn `https://github.com/${sshMatch[1]}`;\n\t}\n\n\tif (value.startsWith(\"http://\") || value.startsWith(\"https://\")) {\n\t\ttry {\n\t\t\tconst parsed = new URL(value);\n\t\t\tif (parsed.hostname !== \"github.com\") return undefined;\n\t\t\tconst parts = parsed.pathname.split(\"/\").filter(Boolean);\n\t\t\tif (parts.length < 2) return undefined;\n\t\t\treturn `https://github.com/${parts[0]}/${parts[1]}`;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\treturn undefined;\n};\n\nexport const runTaskAction = async (args: TaskCommandArgs): Promise<void> => {\n\tconst action = args.action;\n\tif (!action) {\n\t\terror(\"ACTION_REQUIRED\", \"Task action required\");\n\t}\n\n\ttry {\n\t\tswitch (action) {\n\t\t\tcase \"list\": {\n\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\thost: args.host,\n\t\t\t\t\tmodule: args.module,\n\t\t\t\t});\n\t\t\t\tlet tasks = ctx.iter<Task>(\"tasks\");\n\t\t\t\tconst statusFilter = args.status;\n\t\t\t\tconst limit = args.limit ? parseInt(args.limit, 10) : undefined;\n\n\t\t\t\tif (limit !== undefined && (!Number.isFinite(limit) || limit <= 0)) {\n\t\t\t\t\terror(\"INVALID_LIMIT\", \"--limit must be a positive integer\");\n\t\t\t\t}\n\n\t\t\t\tif (statusFilter)\n\t\t\t\t\ttasks = tasks.filter((t) =>\n\t\t\t\t\t\tTaskStatus.matches(t.status, statusFilter),\n\t\t\t\t\t);\n\t\t\t\tif (args.project)\n\t\t\t\t\ttasks = tasks.filter((t) => t.projectId.toString() === args.project);\n\t\t\t\tif (args.assigned) tasks = tasks.filter((t) => t.assignedTo);\n\t\t\t\ttasks = tasks.sort((a, b) => {\n\t\t\t\t\tconst aMicros = toMicros(a.createdAt);\n\t\t\t\t\tconst bMicros = toMicros(b.createdAt);\n\t\t\t\t\tif (aMicros !== bMicros) return bMicros > aMicros ? 1 : -1;\n\t\t\t\t\tif (a.id === b.id) return 0;\n\t\t\t\t\treturn b.id > a.id ? 1 : -1;\n\t\t\t\t});\n\t\t\t\tif (limit !== undefined) tasks = tasks.slice(0, limit);\n\n\t\t\t\tsuccess({ tasks, count: tasks.length });\n\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\ttoonList(\n\t\t\t\t\t\t\t\"tasks\",\n\t\t\t\t\t\t\ttasks.map((t) => ({\n\t\t\t\t\t\t\t\tid: t.id.toString(),\n\t\t\t\t\t\t\t\ttitle: t.title,\n\t\t\t\t\t\t\t\tstatus: TaskStatus.display(t.status),\n\t\t\t\t\t\t\t\tpriority: t.priority,\n\t\t\t\t\t\t\t\tassignedTo: t.assignedTo || \"\",\n\t\t\t\t\t\t\t\tprojectId: t.projectId,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"ready\": {\n\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\thost: args.host,\n\t\t\t\t\tmodule: args.module,\n\t\t\t\t});\n\t\t\t\tconst tasks = ctx.iter<Task>(\"tasks\");\n\t\t\t\tconst deps = ctx.iter<TaskDependency>(\"task_dependencies\");\n\t\t\t\tconst taskById = new Map(tasks.map((t) => [t.id.toString(), t]));\n\t\t\t\tconst limit = args.limit ? parseInt(args.limit, 10) : undefined;\n\n\t\t\t\tif (limit !== undefined && (!Number.isFinite(limit) || limit <= 0)) {\n\t\t\t\t\terror(\"INVALID_LIMIT\", \"--limit must be a positive integer\");\n\t\t\t\t}\n\n\t\t\t\tconst ready = tasks\n\t\t\t\t\t.filter((t) => TaskStatus.is.open(t.status))\n\t\t\t\t\t.filter((t) => {\n\t\t\t\t\t\tconst incomingDeps = deps.filter((dep) => dep.taskId === t.id);\n\t\t\t\t\t\tconst hasOpenBlocker = incomingDeps.some((dep) => {\n\t\t\t\t\t\t\tconst depTag =\n\t\t\t\t\t\t\t\ttypeof dep.dependencyType === \"string\"\n\t\t\t\t\t\t\t\t\t? dep.dependencyType\n\t\t\t\t\t\t\t\t\t: dep.dependencyType.tag;\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tdepTag !== \"Blocks\" &&\n\t\t\t\t\t\t\t\tdepTag !== \"ParentChild\" &&\n\t\t\t\t\t\t\t\tdepTag !== \"blocks\" &&\n\t\t\t\t\t\t\t\tdepTag !== \"parent-child\"\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\tconst blocker = taskById.get(dep.dependsOnId.toString());\n\t\t\t\t\t\t\tif (!blocker) return false;\n\t\t\t\t\t\t\treturn !TaskStatus.is.completed(blocker.status);\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn !hasOpenBlocker;\n\t\t\t\t\t})\n\t\t\t\t\t.filter(\n\t\t\t\t\t\t(t) => !args.project || t.projectId.toString() === args.project,\n\t\t\t\t\t)\n\t\t\t\t\t.filter((t) => !args.assigned || Boolean(t.assignedTo))\n\t\t\t\t\t.sort((a, b) => {\n\t\t\t\t\t\tif (a.priority !== b.priority) return a.priority - b.priority;\n\t\t\t\t\t\tconst aMicros = toMicros(a.createdAt);\n\t\t\t\t\t\tconst bMicros = toMicros(b.createdAt);\n\t\t\t\t\t\tif (aMicros < bMicros) return -1;\n\t\t\t\t\t\tif (aMicros > bMicros) return 1;\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t});\n\n\t\t\t\tconst readyTasks = (\n\t\t\t\t\tlimit !== undefined ? ready.slice(0, limit) : ready\n\t\t\t\t).map((t) => ({\n\t\t\t\t\tid: t.id.toString(),\n\t\t\t\t\ttitle: t.title,\n\t\t\t\t\tstatus: t.status.tag.toLowerCase(),\n\t\t\t\t\tpriority: t.priority,\n\t\t\t\t\tassignedTo: t.assignedTo || \"\",\n\t\t\t\t\tprojectId: t.projectId.toString(),\n\t\t\t\t\tblockedBy: [] as string[],\n\t\t\t\t}));\n\n\t\t\t\tsuccess({ tasks: readyTasks, count: readyTasks.length });\n\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\ttoonList(\n\t\t\t\t\t\t\t\"tasks\",\n\t\t\t\t\t\t\treadyTasks.map((t) => ({\n\t\t\t\t\t\t\t\tid: t.id,\n\t\t\t\t\t\t\t\ttitle: t.title,\n\t\t\t\t\t\t\t\tstatus: t.status,\n\t\t\t\t\t\t\t\tpriority: t.priority,\n\t\t\t\t\t\t\t\tassignedTo: t.assignedTo,\n\t\t\t\t\t\t\t\tprojectId: t.projectId,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"get\": {\n\t\t\t\tconst taskId = args.id;\n\t\t\t\tif (!taskId) error(\"TASK_ID_REQUIRED\", \"Task ID required\");\n\n\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\thost: args.host,\n\t\t\t\t\tmodule: args.module,\n\t\t\t\t});\n\t\t\t\tconst task = ctx\n\t\t\t\t\t.iter<Task>(\"tasks\")\n\t\t\t\t\t.find((t) => t.id.toString() === taskId);\n\t\t\t\tif (!task) error(\"TASK_NOT_FOUND\", `Task not found: ${taskId}`);\n\n\t\t\t\tsuccess(task);\n\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\ttoonList(\"task\", [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tid: task.id.toString(),\n\t\t\t\t\t\t\t\ttitle: task.title,\n\t\t\t\t\t\t\t\tstatus: TaskStatus.display(task.status),\n\t\t\t\t\t\t\t\tpriority: task.priority,\n\t\t\t\t\t\t\t\tassignedTo: task.assignedTo || \"\",\n\t\t\t\t\t\t\t\tprojectId: task.projectId.toString(),\n\t\t\t\t\t\t\t\tgithubIssueUrl: task.githubIssueUrl || \"\",\n\t\t\t\t\t\t\t\tgithubPrUrl: task.githubPrUrl || \"\",\n\t\t\t\t\t\t\t\tdescription: task.description,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t]),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"create\": {\n\t\t\t\tif (!args.project || !args.title)\n\t\t\t\t\terror(\"ARGS_REQUIRED\", \"--project and --title required\");\n\n\t\t\t\tconst priority = parseInt(args.priority || \"5\", 10);\n\t\t\t\tif (priority < 1 || priority > 10)\n\t\t\t\t\terror(\"INVALID_PRIORITY\", \"Priority must be 1-10\");\n\n\t\t\t\ttry {\n\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\tawait callReducer(ctx, \"createTask\", {\n\t\t\t\t\t\t\t\tprojectId: BigInt(args.project as string),\n\t\t\t\t\t\t\t\ttitle: args.title,\n\t\t\t\t\t\t\t\tdescription: args.description || \"\",\n\t\t\t\t\t\t\t\tpriority,\n\t\t\t\t\t\t\t\tsourceIdeaId: undefined,\n\t\t\t\t\t\t\t\tgithubIssueUrl: args[\"github-issue-url\"],\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\tsuccess({\n\t\t\t\t\t\tcreated: true,\n\t\t\t\t\t\tprojectId: args.project,\n\t\t\t\t\t\ttitle: args.title,\n\t\t\t\t\t\tissue: args[\"github-issue-url\"],\n\t\t\t\t\t});\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\"task_created\", [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tprojectId: args.project,\n\t\t\t\t\t\t\t\t\ttitle: args.title,\n\t\t\t\t\t\t\t\t\tgithubIssueUrl: args[\"github-issue-url\"] || \"\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"claim\": {\n\t\t\t\tconst taskId = args.id;\n\t\t\t\tif (!taskId) error(\"TASK_ID_REQUIRED\", \"Task ID required\");\n\n\t\t\t\ttry {\n\t\t\t\t\tlet repositoryUrl: string | undefined;\n\t\t\t\t\tlet contributingUrl: string | undefined;\n\n\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\tawait callReducer(ctx, \"claimTask\", { taskId: BigInt(taskId) });\n\n\t\t\t\t\t\t\tconst task = ctx\n\t\t\t\t\t\t\t\t.iter<Task>(\"tasks\")\n\t\t\t\t\t\t\t\t.find((t) => t.id.toString() === taskId);\n\t\t\t\t\t\t\tconst project = task\n\t\t\t\t\t\t\t\t? ctx\n\t\t\t\t\t\t\t\t\t\t.iter<Project>(\"projects\")\n\t\t\t\t\t\t\t\t\t\t.find((p) => p.id === task.projectId)\n\t\t\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\t\t\tif (project?.githubRepo) {\n\t\t\t\t\t\t\t\trepositoryUrl = normalizeGitHubRepoUrl(project.githubRepo);\n\t\t\t\t\t\t\t\tif (repositoryUrl) {\n\t\t\t\t\t\t\t\t\tcontributingUrl = `${repositoryUrl}/blob/main/CONTRIBUTING.md`;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\tsuccess({\n\t\t\t\t\t\tclaimed: true,\n\t\t\t\t\t\ttaskId,\n\t\t\t\t\t\trepositoryUrl,\n\t\t\t\t\t\tcontributingUrl,\n\t\t\t\t\t\tnextSteps: [\n\t\t\t\t\t\t\trepositoryUrl\n\t\t\t\t\t\t\t\t? `Fork the target repository: ${repositoryUrl}`\n\t\t\t\t\t\t\t\t: \"Fork the target repository to your GitHub account using gh cli\",\n\t\t\t\t\t\t\tcontributingUrl\n\t\t\t\t\t\t\t\t? `Read CONTRIBUTING.md before starting: ${contributingUrl}`\n\t\t\t\t\t\t\t\t: \"Read CONTRIBUTING.md in the target repository before starting\",\n\t\t\t\t\t\t\t\"Verify behavior independently by tracing relevant code flow and runtime path before implementing changes.\",\n\t\t\t\t\t\t],\n\t\t\t\t\t});\n\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\"task_claimed\", [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttaskId,\n\t\t\t\t\t\t\t\t\trepositoryUrl: repositoryUrl || \"\",\n\t\t\t\t\t\t\t\t\tcontributingUrl: contributingUrl || \"\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.log(\"\");\n\t\t\t\t\t\tconsole.log(\"Next steps:\");\n\t\t\t\t\t\tif (repositoryUrl) {\n\t\t\t\t\t\t\tconsole.log(`1. Fork the target repository: ${repositoryUrl}`);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\"1. Fork the target repository to your GitHub account\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (contributingUrl) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t`2. Read CONTRIBUTING.md before starting: ${contributingUrl}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\"2. Read CONTRIBUTING.md in the target repository before starting\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\"3. Verify behavior independently by tracing relevant code flow and runtime path before implementing changes.\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"update\": {\n\t\t\t\tconst taskId = args.id;\n\t\t\t\tif (!taskId) error(\"TASK_ID_REQUIRED\", \"Task ID required\");\n\t\t\t\tif (!args.status && !args[\"github-pr-url\"])\n\t\t\t\t\terror(\"UPDATE_REQUIRED\", \"--status or --github-pr-url required\");\n\n\t\t\t\ttry {\n\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\tawait callReducer(ctx, \"updateTaskStatus\", {\n\t\t\t\t\t\t\t\ttaskId: BigInt(taskId),\n\t\t\t\t\t\t\t\tstatus: args.status\n\t\t\t\t\t\t\t\t\t? TaskStatus.fromString(args.status)\n\t\t\t\t\t\t\t\t\t: (undefined as never),\n\t\t\t\t\t\t\t\tgithubPrUrl: args[\"github-pr-url\"],\n\t\t\t\t\t\t\t\tarchiveReason: undefined,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\tsuccess({\n\t\t\t\t\t\tupdated: true,\n\t\t\t\t\t\ttaskId,\n\t\t\t\t\t\tstatus: args.status,\n\t\t\t\t\t\tpr: args[\"github-pr-url\"],\n\t\t\t\t\t});\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\"task_updated\", [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttaskId,\n\t\t\t\t\t\t\t\t\tstatus: args.status || \"\",\n\t\t\t\t\t\t\t\t\tgithubPrUrl: args[\"github-pr-url\"] || \"\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"review\": {\n\t\t\t\tconst taskId = args.id;\n\t\t\t\tif (!taskId) error(\"TASK_ID_REQUIRED\", \"Task ID required\");\n\n\t\t\t\ttry {\n\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\tawait callReducer(ctx, \"updateTaskStatus\", {\n\t\t\t\t\t\t\t\ttaskId: BigInt(taskId),\n\t\t\t\t\t\t\t\tstatus: { tag: \"Review\" },\n\t\t\t\t\t\t\t\tgithubPrUrl: args[\"github-pr-url\"],\n\t\t\t\t\t\t\t\tarchiveReason: undefined,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\tsuccess({\n\t\t\t\t\t\treviewed: true,\n\t\t\t\t\t\ttaskId,\n\t\t\t\t\t\tstatus: \"review\",\n\t\t\t\t\t\tpr: args[\"github-pr-url\"],\n\t\t\t\t\t});\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\"task_review\", [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttaskId,\n\t\t\t\t\t\t\t\t\tstatus: \"review\",\n\t\t\t\t\t\t\t\t\tgithubPrUrl: args[\"github-pr-url\"] || \"\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"deps\": {\n\t\t\t\tconst taskId = args.id;\n\t\t\t\tif (!taskId) error(\"TASK_ID_REQUIRED\", \"Task ID required\");\n\t\t\t\tconst taskIdBigInt = BigInt(taskId);\n\n\t\t\t\tif (args[\"add-dep\"]) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"addTaskDependency\", {\n\t\t\t\t\t\t\t\t\ttaskId: taskIdBigInt,\n\t\t\t\t\t\t\t\t\tdependsOnId: BigInt(args[\"add-dep\"] as string),\n\t\t\t\t\t\t\t\t\tdependencyType: { tag: \"Blocks\" },\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\tsuccess({ added: true, taskId, dependsOn: args[\"add-dep\"] });\n\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\ttoonList(\"dependency_added\", [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttaskId,\n\t\t\t\t\t\t\t\t\t\tdependsOnId: args[\"add-dep\"],\n\t\t\t\t\t\t\t\t\t\tdependencyType: \"blocks\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else if (args.list) {\n\t\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\t\thost: args.host,\n\t\t\t\t\t\tmodule: args.module,\n\t\t\t\t\t});\n\t\t\t\t\tconst deps = ctx.iter<TaskDependency>(\"task_dependencies\");\n\t\t\t\t\tconst taskDeps = deps.filter(\n\t\t\t\t\t\t(d) => d.taskId === taskIdBigInt || d.dependsOnId === taskIdBigInt,\n\t\t\t\t\t);\n\n\t\t\t\t\tsuccess({ dependencies: taskDeps });\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\n\t\t\t\t\t\t\t\t\"task_dependencies\",\n\t\t\t\t\t\t\t\ttaskDeps.map((dep) => ({\n\t\t\t\t\t\t\t\t\tid: dep.id.toString(),\n\t\t\t\t\t\t\t\t\ttaskId: dep.taskId.toString(),\n\t\t\t\t\t\t\t\t\tdependsOnId: dep.dependsOnId.toString(),\n\t\t\t\t\t\t\t\t\tdependencyType: dep.dependencyType,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"DEPS_ACTION_REQUIRED\",\n\t\t\t\t\t\t\"Use --add-dep <taskId> to add a dependency or --list to view dependencies\",\n\t\t\t\t\t\t\"Examples: probe task deps 42 --list | probe task deps 42 --add-dep 17\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"watch\": {\n\t\t\t\tconst timeout = Math.min(parseInt(args.timeout || \"60\", 10), 300);\n\n\t\t\t\tawait withAuth(\n\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\ttoonList(\"task_watch\", [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttimeoutSeconds: timeout,\n\t\t\t\t\t\t\t\t\t\tstatusFilter: args.status || \"\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst waitForStop = new Promise<void>((resolve) => {\n\t\t\t\t\t\t\tconst timer = setTimeout(() => {\n\t\t\t\t\t\t\t\tprocess.off(\"SIGINT\", onSignal);\n\t\t\t\t\t\t\t\tprocess.off(\"SIGTERM\", onSignal);\n\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t}, timeout * 1000);\n\n\t\t\t\t\t\t\tconst onSignal = () => {\n\t\t\t\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\t\t\t\tprocess.off(\"SIGINT\", onSignal);\n\t\t\t\t\t\t\t\tprocess.off(\"SIGTERM\", onSignal);\n\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\tprocess.on(\"SIGINT\", onSignal);\n\t\t\t\t\t\t\tprocess.on(\"SIGTERM\", onSignal);\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tctx.db.tasks.onInsert((_ctx, task) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t!args.status ||\n\t\t\t\t\t\t\t\tTaskStatus.matches(task.status, args.status)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\ttoonList(\"tasks\", [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tid: task.id.toString(),\n\t\t\t\t\t\t\t\t\t\t\ttitle: task.title,\n\t\t\t\t\t\t\t\t\t\t\tchange_type: \"created\",\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tctx.db.tasks.onUpdate((_ctx, _old, newTask) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t!args.status ||\n\t\t\t\t\t\t\t\tTaskStatus.matches(newTask.status, args.status)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\ttoonList(\"tasks\", [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tid: newTask.id.toString(),\n\t\t\t\t\t\t\t\t\t\t\ttitle: newTask.title,\n\t\t\t\t\t\t\t\t\t\t\tchange_type: \"updated\",\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tawait waitForStop;\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\terror(\n\t\t\t\t\t\"INVALID_ACTION\",\n\t\t\t\t\t`Invalid action: ${action}`,\n\t\t\t\t\t\"Use: list, ready, get, create, claim, update, review, deps, watch\",\n\t\t\t\t);\n\t\t}\n\t} catch (err) {\n\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\terror(\"CONNECTION_ERROR\", message);\n\t}\n};\n","import { defineCommand } from \"citty\";\nimport { printHelp } from \"~/utils/help.js\";\nimport { setJsonMode } from \"~/utils/output.js\";\nimport { runTaskAction, type TaskCommandArgs } from \"./task-handlers.js\";\n\nexport default defineCommand({\n\tmeta: { name: \"task\", description: \"Task management\" },\n\targs: {\n\t\taction: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription:\n\t\t\t\t\"Action: list, ready, get, create, claim, update, review, deps, watch\",\n\t\t\trequired: false,\n\t\t},\n\t\tid: { type: \"positional\", description: \"Task ID\", required: false },\n\t\tstatus: { type: \"string\", description: \"Status filter or new status\" },\n\t\tproject: { type: \"string\", description: \"Project ID\" },\n\t\ttitle: { type: \"string\", description: \"Task title\" },\n\t\tdescription: { type: \"string\", description: \"Task description\" },\n\t\tpriority: { type: \"string\", description: \"Priority 1-10\" },\n\t\tassigned: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Show only assigned tasks\",\n\t\t\tdefault: false,\n\t\t},\n\t\twallet: { type: \"string\", description: \"Wallet name\" },\n\t\t\"github-pr-url\": { type: \"string\", description: \"GitHub PR URL\" },\n\t\t\"github-issue-url\": { type: \"string\", description: \"GitHub issue URL\" },\n\t\t\"add-dep\": { type: \"string\", description: \"Add dependency task ID\" },\n\t\tlist: { type: \"boolean\", description: \"List dependencies\", default: false },\n\t\ttimeout: { type: \"string\", description: \"Watch timeout (seconds)\" },\n\t\tlimit: { type: \"string\", description: \"Limit rows for list/ready\" },\n\t\tjson: { type: \"boolean\", description: \"Output JSON\", default: false },\n\t\thost: { type: \"string\", description: \"SpacetimeDB host\" },\n\t\tmodule: { type: \"string\", description: \"Module name\" },\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) setJsonMode(true);\n\n\t\tif (!args.action) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe task\",\n\t\t\t\tdescription: \"Task management commands\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe task <action> [options]\",\n\t\t\t\t\t\"probe task list --project 1 --status open\",\n\t\t\t\t\t'probe task create --project 1 --title \"Fix bug\" --priority 5',\n\t\t\t\t],\n\t\t\t\tactions: [\n\t\t\t\t\t{ name: \"list\", detail: \"List tasks with optional filters\" },\n\t\t\t\t\t{ name: \"ready\", detail: \"List immediately claimable open tasks\" },\n\t\t\t\t\t{ name: \"get <id>\", detail: \"Show one task\" },\n\t\t\t\t\t{ name: \"create\", detail: \"Create a new task\" },\n\t\t\t\t\t{ name: \"claim <id>\", detail: \"Claim a task for your identity\" },\n\t\t\t\t\t{ name: \"update <id>\", detail: \"Update status and optional PR URL\" },\n\t\t\t\t\t{ name: \"review <id>\", detail: \"Mark a task as ready for review\" },\n\t\t\t\t\t{ name: \"deps <id>\", detail: \"List or add task dependencies\" },\n\t\t\t\t\t{ name: \"watch\", detail: \"Watch task changes in real time\" },\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--project\", detail: \"Project ID\" },\n\t\t\t\t\t{ name: \"--title\", detail: \"Task title (create)\" },\n\t\t\t\t\t{ name: \"--description\", detail: \"Task description\" },\n\t\t\t\t\t{ name: \"--priority\", detail: \"Priority from 1 to 10 (default: 5)\" },\n\t\t\t\t\t{ name: \"--status\", detail: \"Filter or new status\" },\n\t\t\t\t\t{ name: \"--limit\", detail: \"Limit rows for list/ready\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--github-pr-url\",\n\t\t\t\t\t\tdetail: \"GitHub PR URL for update/review\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"--github-issue-url\", detail: \"GitHub issue URL for create\" },\n\t\t\t\t\t{ name: \"--wallet\", detail: \"Wallet to use for authenticated calls\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--host, --module\",\n\t\t\t\t\t\tdetail: \"Nexus SpacetimeDB target overrides\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tnotes: [\n\t\t\t\t\t\"Use full long-form flags only; short aliases are intentionally disabled.\",\n\t\t\t\t\t\"Find project IDs with `probe project list`; find task IDs with `probe task list`.\",\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tawait runTaskAction(args as TaskCommandArgs);\n\t},\n});\n","import { createWriteStream, type WriteStream } from \"node:fs\";\nimport { mkdir } from \"node:fs/promises\";\nimport { dirname, resolve } from \"node:path\";\nimport { defineCommand } from \"citty\";\nimport { createConsola } from \"consola\";\nimport { type Agent, callReducer, withAuth } from \"~/utils/context.js\";\nimport { forceHelpRequested, printHelp } from \"~/utils/help.js\";\n\nconst HEARTBEAT_INTERVAL_MS = 60_000;\nconst HEARTBEAT_JITTER_MS = 5_000;\nconst HEARTBEAT_FAILURE_THRESHOLD = 3;\nconst RECONNECT_BASE_MS = 1_000;\nconst RECONNECT_MAX_MS = 30_000;\n\nconst OBSERVED_TABLES = [\n\t{ key: \"agents\", name: \"agents\" },\n\t{ key: \"tasks\", name: \"tasks\" },\n\t{ key: \"ideas\", name: \"ideas\" },\n\t{ key: \"messages\", name: \"messages\" },\n\t{ key: \"channels\", name: \"channels\" },\n\t{ key: \"projects\", name: \"projects\" },\n\t{ key: \"votes\", name: \"votes\" },\n\t{ key: \"discovered_tasks\", name: \"discovered_tasks\" },\n\t{ key: \"task_dependencies\", name: \"task_dependencies\" },\n\t{ key: \"identity_roles\", name: \"identity_roles\" },\n\t{ key: \"config\", name: \"config\" },\n\t{ key: \"project_channels\", name: \"project_channels\" },\n\t{ key: \"project_messages\", name: \"project_messages\" },\n] as const;\n\ntype DaemonEvent = {\n\ttype: string;\n\tsource: \"nexus\";\n\tat: string;\n\t[key: string]: unknown;\n};\n\ntype SessionEnd = {\n\treason: \"disconnected\" | \"heartbeat_failed\" | \"stop\";\n\tdetails?: unknown;\n};\n\ntype LogLevel = \"critical\" | \"info\" | \"debug\";\n\ntype ObservableTable = {\n\tonInsert?: (cb: (_ctx: unknown, row: unknown) => void) => void;\n\tonUpdate?: (\n\t\tcb: (_ctx: unknown, oldRow: unknown, newRow: unknown) => void,\n\t) => void;\n\tonDelete?: (cb: (_ctx: unknown, row: unknown) => void) => void;\n};\n\nconst CRITICAL_EVENTS = new Set([\n\t\"connected\",\n\t\"ready\",\n\t\"disconnected\",\n\t\"reconnecting\",\n\t\"reconnected\",\n\t\"subscription_applied\",\n\t\"subscription_error\",\n\t\"auth_failed\",\n\t\"heartbeat_failed\",\n\t\"heartbeat_recovered\",\n\t\"shutdown\",\n]);\n\nconst jsonReplacer = (_key: string, value: unknown): unknown => {\n\tif (typeof value === \"bigint\") {\n\t\treturn value.toString();\n\t}\n\treturn value;\n};\n\nconst nowIso = (): string => new Date().toISOString();\n\nconst sleep = (ms: number): Promise<void> =>\n\tnew Promise((resolve) => setTimeout(resolve, ms));\n\nconst withJitter = (baseMs: number): number => {\n\tconst jitter = Math.floor(\n\t\tMath.random() * (HEARTBEAT_JITTER_MS * 2 + 1) - HEARTBEAT_JITTER_MS,\n\t);\n\treturn Math.max(1_000, baseMs + jitter);\n};\n\nconst backoffMs = (attempt: number): number => {\n\tconst base = Math.min(\n\t\tRECONNECT_MAX_MS,\n\t\tRECONNECT_BASE_MS * 2 ** Math.max(0, attempt - 1),\n\t);\n\treturn withJitter(base);\n};\n\nconst normalizeError = (err: unknown): string => {\n\tif (err instanceof Error) {\n\t\treturn err.message;\n\t}\n\treturn String(err);\n};\n\nconst sanitizeValue = (value: unknown): unknown => {\n\tif (value instanceof Error) {\n\t\treturn { name: value.name, message: value.message };\n\t}\n\tif (\n\t\ttypeof value === \"string\" ||\n\t\ttypeof value === \"number\" ||\n\t\ttypeof value === \"boolean\" ||\n\t\tvalue === null\n\t) {\n\t\treturn value;\n\t}\n\tif (typeof value === \"bigint\") {\n\t\treturn value.toString();\n\t}\n\ttry {\n\t\treturn JSON.parse(JSON.stringify(value, jsonReplacer));\n\t} catch {\n\t\treturn String(value);\n\t}\n};\n\nconst resolveLogLevel = (value: unknown): LogLevel => {\n\tif (value === \"critical\" || value === \"info\" || value === \"debug\") {\n\t\treturn value;\n\t}\n\treturn \"critical\";\n};\n\nconst shouldEmit = (eventType: string, level: LogLevel): boolean => {\n\tif (level === \"debug\") {\n\t\treturn true;\n\t}\n\tif (CRITICAL_EVENTS.has(eventType)) {\n\t\treturn true;\n\t}\n\tif (level === \"info\" && eventType.startsWith(\"heartbeat_\")) {\n\t\treturn true;\n\t}\n\treturn false;\n};\n\nconst resolveLogStream = async (\n\tpathValue?: string,\n): Promise<WriteStream | null> => {\n\tif (!pathValue) {\n\t\treturn null;\n\t}\n\tconst absolutePath = resolve(pathValue);\n\tawait mkdir(dirname(absolutePath), { recursive: true });\n\treturn createWriteStream(absolutePath, { flags: \"a\" });\n};\n\nconst connectErrorLooksAuthRelated = (message: string): boolean => {\n\tconst lowered = message.toLowerCase();\n\treturn (\n\t\tlowered.includes(\"authentication required\") ||\n\t\tlowered.includes(\"unauthorized\") ||\n\t\tlowered.includes(\"401\")\n\t);\n};\n\nexport const nexusDaemonArgs = {\n\twallet: {\n\t\ttype: \"string\",\n\t\tdescription: \"Wallet name for authenticated connection\",\n\t},\n\thost: {\n\t\ttype: \"string\",\n\t\tdescription: \"SpacetimeDB host override\",\n\t},\n\tmodule: {\n\t\ttype: \"string\",\n\t\tdescription: \"SpacetimeDB module override\",\n\t},\n\tsender: {\n\t\ttype: \"string\",\n\t\tdescription: \"Optional sender filter (debug table events only)\",\n\t},\n\t\"log-file\": {\n\t\ttype: \"string\",\n\t\tdescription: \"Optional path to append JSONL daemon events\",\n\t},\n\t\"log-level\": {\n\t\ttype: \"string\",\n\t\tdescription: \"critical, info, or debug\",\n\t\tdefault: \"critical\",\n\t},\n\tpretty: {\n\t\ttype: \"boolean\",\n\t\tdescription: \"Human-readable lifecycle logs to stderr\",\n\t\tdefault: false,\n\t},\n\tjson: {\n\t\ttype: \"boolean\",\n\t\tdescription: \"Reserved for CLI consistency\",\n\t\tdefault: false,\n\t},\n} as const;\n\nexport async function runNexusDaemon(\n\targs: Record<string, unknown>,\n): Promise<void> {\n\tconst logLevel = resolveLogLevel(args[\"log-level\"]);\n\tconst pretty = !!args.pretty;\n\tconst prettyLogger = pretty\n\t\t? createConsola({\n\t\t\t\tstdout: process.stderr,\n\t\t\t\tstderr: process.stderr,\n\t\t\t})\n\t\t: null;\n\n\tlet logStream: WriteStream | null = null;\n\ttry {\n\t\tlogStream = await resolveLogStream(args[\"log-file\"] as string | undefined);\n\t} catch (err) {\n\t\tconst message = normalizeError(err);\n\t\tconst fallback = JSON.stringify({\n\t\t\tsource: \"nexus\",\n\t\t\tat: nowIso(),\n\t\t\ttype: \"log_file_error\",\n\t\t\tmessage,\n\t\t});\n\t\tconsole.log(fallback);\n\t\treturn;\n\t}\n\n\tconst writeEvent = (event: DaemonEvent): void => {\n\t\tconst line = JSON.stringify(event, jsonReplacer);\n\t\tconsole.log(line);\n\t\tif (logStream) {\n\t\t\tlogStream.write(`${line}\\n`);\n\t\t}\n\t};\n\n\tconst emit = (event: { type: string; [key: string]: unknown }): void => {\n\t\tif (!shouldEmit(event.type, logLevel)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst fullEvent: DaemonEvent = {\n\t\t\tsource: \"nexus\",\n\t\t\tat: nowIso(),\n\t\t\t...event,\n\t\t};\n\n\t\twriteEvent(fullEvent);\n\n\t\tif (!prettyLogger) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst type = String(event.type);\n\t\tif (type === \"connected\") {\n\t\t\tprettyLogger.info(\"Connected to Nexus\");\n\t\t} else if (type === \"reconnected\") {\n\t\t\tprettyLogger.success(\"Reconnected to Nexus\");\n\t\t} else if (type === \"disconnected\") {\n\t\t\tprettyLogger.warn(\"Disconnected from Nexus\");\n\t\t} else if (type === \"reconnecting\") {\n\t\t\tprettyLogger.info(\"Reconnecting to Nexus\");\n\t\t} else if (type === \"auth_failed\") {\n\t\t\tprettyLogger.error(\"Authentication failed\");\n\t\t} else if (type === \"heartbeat_failed\") {\n\t\t\tprettyLogger.warn(\"Heartbeat failed repeatedly\");\n\t\t} else if (type === \"shutdown\") {\n\t\t\tprettyLogger.info(\"Nexus daemon shutting down\");\n\t\t}\n\t};\n\n\tlet stopping = false;\n\tlet stopSignal: \"SIGINT\" | \"SIGTERM\" | null = null;\n\n\tconst stopWaiter = new Promise<void>((resolve) => {\n\t\tconst onSigint = () => {\n\t\t\tif (stopping) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tstopping = true;\n\t\t\tstopSignal = \"SIGINT\";\n\t\t\tresolve();\n\t\t};\n\t\tconst onSigterm = () => {\n\t\t\tif (stopping) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tstopping = true;\n\t\t\tstopSignal = \"SIGTERM\";\n\t\t\tresolve();\n\t\t};\n\t\tprocess.on(\"SIGINT\", onSigint);\n\t\tprocess.on(\"SIGTERM\", onSigterm);\n\t});\n\n\tlet reconnectAttempt = 0;\n\tlet downtimeStartedAt: number | null = null;\n\tlet hasConnectedOnce = false;\n\n\twhile (!stopping) {\n\t\tlet sessionEnd: SessionEnd | null = null;\n\n\t\ttry {\n\t\t\tawait withAuth(\n\t\t\t\t{\n\t\t\t\t\thost: args.host as string | undefined,\n\t\t\t\t\tmodule: args.module as string | undefined,\n\t\t\t\t\twallet: args.wallet as string | undefined,\n\t\t\t\t\tonDisconnect: (...disconnectArgs: unknown[]) => {\n\t\t\t\t\t\tif (!sessionEnd) {\n\t\t\t\t\t\t\tsessionEnd = {\n\t\t\t\t\t\t\t\treason: \"disconnected\",\n\t\t\t\t\t\t\t\tdetails: disconnectArgs.map(sanitizeValue),\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tasync (ctx) => {\n\t\t\t\t\tconst effectiveWallet = ctx.auth?.wallet || args.wallet || null;\n\t\t\t\t\tconst currentAgent = ctx\n\t\t\t\t\t\t.iter<Agent>(\"agents\")\n\t\t\t\t\t\t.find(\n\t\t\t\t\t\t\t(a) => a.identity.toHexString() === ctx.identity?.toHexString(),\n\t\t\t\t\t\t);\n\n\t\t\t\t\tif (!hasConnectedOnce) {\n\t\t\t\t\t\temit({\n\t\t\t\t\t\t\ttype: \"connected\",\n\t\t\t\t\t\t\tidentity: ctx.identity?.toHexString(),\n\t\t\t\t\t\t\twallet: effectiveWallet,\n\t\t\t\t\t\t\thost: args.host || ctx.config.spacetime.host,\n\t\t\t\t\t\t\tmodule: args.module || ctx.config.spacetime.module,\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\temit({\n\t\t\t\t\t\t\ttype: \"reconnected\",\n\t\t\t\t\t\t\tattempts: reconnectAttempt,\n\t\t\t\t\t\t\tdowntime_ms: downtimeStartedAt\n\t\t\t\t\t\t\t\t? Date.now() - downtimeStartedAt\n\t\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\t\tidentity: ctx.identity?.toHexString(),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\thasConnectedOnce = true;\n\t\t\t\t\treconnectAttempt = 0;\n\t\t\t\t\tdowntimeStartedAt = null;\n\n\t\t\t\t\temit({ type: \"subscription_applied\" });\n\t\t\t\t\temit({\n\t\t\t\t\t\ttype: \"ready\",\n\t\t\t\t\t\tidentity: ctx.identity?.toHexString(),\n\t\t\t\t\t\twallet: effectiveWallet,\n\t\t\t\t\t\tlog_file: args[\"log-file\"] || null,\n\t\t\t\t\t\tlog_level: logLevel,\n\t\t\t\t\t\tauto_heartbeat: !!currentAgent,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (logLevel === \"debug\") {\n\t\t\t\t\t\tfor (const tableSpec of OBSERVED_TABLES) {\n\t\t\t\t\t\t\tconst table = ctx.db[tableSpec.key] as ObservableTable;\n\t\t\t\t\t\t\ttable.onInsert?.((_eventCtx, row) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\targs.sender &&\n\t\t\t\t\t\t\t\t\t(tableSpec.name === \"messages\" ||\n\t\t\t\t\t\t\t\t\t\ttableSpec.name === \"project_messages\")\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tconst senderId = (row as { senderId?: unknown }).senderId;\n\t\t\t\t\t\t\t\t\tif (senderId !== args.sender) {\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\temit({\n\t\t\t\t\t\t\t\t\ttype: \"table_insert\",\n\t\t\t\t\t\t\t\t\ttable: tableSpec.name,\n\t\t\t\t\t\t\t\t\trow: sanitizeValue(row),\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\ttable.onUpdate?.((_eventCtx, oldRow, newRow) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\targs.sender &&\n\t\t\t\t\t\t\t\t\t(tableSpec.name === \"messages\" ||\n\t\t\t\t\t\t\t\t\t\ttableSpec.name === \"project_messages\")\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tconst senderId = (newRow as { senderId?: unknown }).senderId;\n\t\t\t\t\t\t\t\t\tif (senderId !== args.sender) {\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\temit({\n\t\t\t\t\t\t\t\t\ttype: \"table_update\",\n\t\t\t\t\t\t\t\t\ttable: tableSpec.name,\n\t\t\t\t\t\t\t\t\told_row: sanitizeValue(oldRow),\n\t\t\t\t\t\t\t\t\tnew_row: sanitizeValue(newRow),\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\ttable.onDelete?.((_eventCtx, row) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\targs.sender &&\n\t\t\t\t\t\t\t\t\t(tableSpec.name === \"messages\" ||\n\t\t\t\t\t\t\t\t\t\ttableSpec.name === \"project_messages\")\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tconst senderId = (row as { senderId?: unknown }).senderId;\n\t\t\t\t\t\t\t\t\tif (senderId !== args.sender) {\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\temit({\n\t\t\t\t\t\t\t\t\ttype: \"table_delete\",\n\t\t\t\t\t\t\t\t\ttable: tableSpec.name,\n\t\t\t\t\t\t\t\t\trow: sanitizeValue(row),\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tlet heartbeatTimer: ReturnType<typeof setTimeout> | null = null;\n\t\t\t\t\tlet heartbeatInFlight = false;\n\t\t\t\t\tlet consecutiveHeartbeatFailures = 0;\n\n\t\t\t\t\tconst scheduleHeartbeat = () => {\n\t\t\t\t\t\tif (stopping || !currentAgent) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\theartbeatTimer = setTimeout(async () => {\n\t\t\t\t\t\t\tif (!currentAgent || heartbeatInFlight || stopping) {\n\t\t\t\t\t\t\t\tscheduleHeartbeat();\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\theartbeatInFlight = true;\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"heartbeat\", {\n\t\t\t\t\t\t\t\t\tagentId: currentAgent.id,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (consecutiveHeartbeatFailures > 0) {\n\t\t\t\t\t\t\t\t\temit({\n\t\t\t\t\t\t\t\t\t\ttype: \"heartbeat_recovered\",\n\t\t\t\t\t\t\t\t\t\tfailed_count_before_recovery: consecutiveHeartbeatFailures,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconsecutiveHeartbeatFailures = 0;\n\t\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\t\tconsecutiveHeartbeatFailures += 1;\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tconsecutiveHeartbeatFailures >= HEARTBEAT_FAILURE_THRESHOLD &&\n\t\t\t\t\t\t\t\t\t!sessionEnd\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tsessionEnd = {\n\t\t\t\t\t\t\t\t\t\treason: \"heartbeat_failed\",\n\t\t\t\t\t\t\t\t\t\tdetails: {\n\t\t\t\t\t\t\t\t\t\t\tconsecutive_failures: consecutiveHeartbeatFailures,\n\t\t\t\t\t\t\t\t\t\t\tmessage: normalizeError(err),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\temit({\n\t\t\t\t\t\t\t\t\t\ttype: \"heartbeat_failed\",\n\t\t\t\t\t\t\t\t\t\tconsecutive_failures: consecutiveHeartbeatFailures,\n\t\t\t\t\t\t\t\t\t\tmessage: normalizeError(err),\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} finally {\n\t\t\t\t\t\t\t\theartbeatInFlight = false;\n\t\t\t\t\t\t\t\tscheduleHeartbeat();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}, withJitter(HEARTBEAT_INTERVAL_MS));\n\t\t\t\t\t};\n\n\t\t\t\t\tif (currentAgent) {\n\t\t\t\t\t\tscheduleHeartbeat();\n\t\t\t\t\t}\n\n\t\t\t\t\twhile (!stopping && !sessionEnd) {\n\t\t\t\t\t\tawait Promise.race([stopWaiter, sleep(200)]);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (heartbeatTimer) {\n\t\t\t\t\t\tclearTimeout(heartbeatTimer);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tconst message = normalizeError(err);\n\t\t\tif (connectErrorLooksAuthRelated(message)) {\n\t\t\t\temit({ type: \"auth_failed\", message });\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\temit({ type: \"subscription_error\", message });\n\t\t\tsessionEnd = {\n\t\t\t\treason: \"disconnected\",\n\t\t\t\tdetails: { message },\n\t\t\t};\n\t\t}\n\n\t\tif (stopping) {\n\t\t\tbreak;\n\t\t}\n\n\t\tconst reason = sessionEnd?.reason || \"disconnected\";\n\t\temit({\n\t\t\ttype: \"disconnected\",\n\t\t\treason,\n\t\t\tdetails: sanitizeValue(sessionEnd?.details || null),\n\t\t});\n\n\t\tif (downtimeStartedAt === null) {\n\t\t\tdowntimeStartedAt = Date.now();\n\t\t}\n\n\t\treconnectAttempt += 1;\n\t\tconst waitMs = backoffMs(reconnectAttempt);\n\t\temit({\n\t\t\ttype: \"reconnecting\",\n\t\t\tattempt: reconnectAttempt,\n\t\t\tbackoff_ms: waitMs,\n\t\t});\n\n\t\tawait Promise.race([stopWaiter, sleep(waitMs)]);\n\t}\n\n\temit({ type: \"shutdown\", signal: stopSignal || \"unknown\" });\n\n\tif (logStream) {\n\t\tlogStream.end();\n\t}\n}\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"nexus\",\n\t\tdescription: \"Persistent Nexus daemon (keepalive + critical telemetry)\",\n\t},\n\targs: nexusDaemonArgs,\n\tasync run({ args }) {\n\t\tif (forceHelpRequested()) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe nexus\",\n\t\t\t\tdescription: \"Run persistent Nexus keepalive + critical event logger\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe nexus [options]\",\n\t\t\t\t\t\"probe nexus --wallet agent-wallet\",\n\t\t\t\t\t\"probe nexus --wallet agent-wallet --log-file ./logs/nexus-events.jsonl\",\n\t\t\t\t\t\"probe nexus --log-level debug --sender zoe-1\",\n\t\t\t\t\t\"probe nexus --pretty\",\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--wallet\",\n\t\t\t\t\t\tdetail: \"Wallet for authenticated persistent connection\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--host, --module\",\n\t\t\t\t\t\tdetail: \"Nexus SpacetimeDB target overrides\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"--log-level\", detail: \"critical (default), info, or debug\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--sender\",\n\t\t\t\t\t\tdetail: \"Sender filter for debug message events only\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--log-file\",\n\t\t\t\t\t\tdetail: \"Optional JSONL file path for daemon events\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--pretty\",\n\t\t\t\t\t\tdetail: \"Human-readable lifecycle logs to stderr\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tnotes: [\n\t\t\t\t\t\"stdout is always structured JSONL for machine parsing.\",\n\t\t\t\t\t\"Default mode logs critical connection lifecycle and heartbeat health events only.\",\n\t\t\t\t\t\"Use --log-level debug to emit full table insert/update/delete payloads.\",\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tawait runNexusDaemon(args as Record<string, unknown>);\n\t},\n});\n","// THIS FILE IS AUTO-GENERATED BY scripts/generate-decoders.ts\n// DO NOT EDIT MANUALLY - Run `npm run generate:decoders` to regenerate\n\n/**\n * Algebraic type decoders for SpacetimeDB SQL query results.\n * Converts raw algebraic type arrays to human-readable values.\n */\n\nexport type Decoder = (value: unknown) => unknown;\n\n// Enum decoders - map variant index to name\nconst enumDecoders: Record<string, Decoder> = {\n AgentRole: (value) => {\n if (!Array.isArray(value)) return value;\n const variants = ['Zoe', 'Admin', 'Zeno'];\n return variants[value[0]] ?? `variant_${value[0]}`;\n },\n AgentStatus: (value) => {\n if (!Array.isArray(value)) return value;\n const variants = ['Online', 'Offline', 'Working'];\n return variants[value[0]] ?? `variant_${value[0]}`;\n },\n AnnouncementStatus: (value) => {\n if (!Array.isArray(value)) return value;\n const variants = ['Pending', 'Ready', 'Failed'];\n return variants[value[0]] ?? `variant_${value[0]}`;\n },\n DependencyType: (value) => {\n if (!Array.isArray(value)) return value;\n const variants = ['Blocks', 'ParentChild'];\n return variants[value[0]] ?? `variant_${value[0]}`;\n },\n DiscoveredTaskStatus: (value) => {\n if (!Array.isArray(value)) return value;\n const variants = ['PendingReview', 'Approved', 'Rejected', 'EscalatedToIdea'];\n return variants[value[0]] ?? `variant_${value[0]}`;\n },\n DiscoveryDecision: (value) => {\n if (!Array.isArray(value)) return value;\n const variants = ['ApproveAsTask', 'Reject', 'EscalateToIdea'];\n return variants[value[0]] ?? `variant_${value[0]}`;\n },\n IdeaStatus: (value) => {\n if (!Array.isArray(value)) return value;\n const variants = ['Voting', 'ApprovedForProject', 'Rejected', 'Implemented'];\n return variants[value[0]] ?? `variant_${value[0]}`;\n },\n MessageType: (value) => {\n if (!Array.isArray(value)) return value;\n const variants = ['User', 'System', 'Directive'];\n return variants[value[0]] ?? `variant_${value[0]}`;\n },\n ProjectStatus: (value) => {\n if (!Array.isArray(value)) return value;\n const variants = ['Active', 'Paused'];\n return variants[value[0]] ?? `variant_${value[0]}`;\n },\n TaskStatus: (value) => {\n if (!Array.isArray(value)) return value;\n const variants = ['Open', 'Claimed', 'InProgress', 'Review', 'Completed', 'Blocked', 'Archived'];\n return variants[value[0]] ?? `variant_${value[0]}`;\n },\n VoteType: (value) => {\n if (!Array.isArray(value)) return value;\n const variants = ['Up', 'Down', 'Veto'];\n return variants[value[0]] ?? `variant_${value[0]}`;\n },\n};\n\n// Timestamp decoder - converts microseconds to ISO string\nconst timestampDecoder: Decoder = (value) => {\n if (!Array.isArray(value)) return value;\n const micros = value[0];\n if (typeof micros !== \"number\" && typeof micros !== \"bigint\") return value;\n return new Date(Number(micros) / 1000).toISOString();\n};\n\n// Option decoder - unwraps Some, returns null for None\nconst optionDecoder = (inner?: Decoder): Decoder => (value) => {\n if (!Array.isArray(value)) return value;\n const [tag, payload] = value;\n if (tag === 1) return null; // None\n // For Option<T>, payload is [T] (array with single element)\n // Pass the payload directly to inner decoder - it knows how to handle its format\n if (inner) {\n // Inner decoder expects the wrapped format (e.g., timestampDecoder expects [micros])\n return inner(payload);\n }\n // No inner decoder - unwrap primitives\n return Array.isArray(payload) && payload.length === 1 ? payload[0] : payload;\n};\n\n// Table column decoders\nexport const TABLE_DECODERS: Record<string, Record<string, Decoder>> = {\n agents: {\n 'last_heartbeat': timestampDecoder,\n 'current_task_id': optionDecoder(),\n 'created_at': timestampDecoder,\n 'last_active_at': timestampDecoder,\n 'role': enumDecoders.AgentRole,\n 'status': enumDecoders.AgentStatus,\n },\n channels: {\n 'created_at': timestampDecoder,\n },\n discovered_tasks: {\n 'created_task_id': optionDecoder(),\n 'rejection_reason': optionDecoder(),\n 'created_at': timestampDecoder,\n 'reviewed_at': optionDecoder(timestampDecoder),\n 'reviewed_by': optionDecoder(),\n 'status': enumDecoders.DiscoveredTaskStatus,\n },\n ideas: {\n 'created_at': timestampDecoder,\n 'updated_at': timestampDecoder,\n 'status': enumDecoders.IdeaStatus,\n },\n identity_roles: {\n 'role': enumDecoders.AgentRole,\n },\n messages: {\n 'context_id': optionDecoder(),\n 'created_at': timestampDecoder,\n },\n project_channels: {\n 'created_at': timestampDecoder,\n },\n project_messages: {\n 'context_id': optionDecoder(),\n 'created_at': timestampDecoder,\n },\n projects: {\n 'created_at': timestampDecoder,\n 'status': enumDecoders.ProjectStatus,\n },\n task_dependencies: {\n 'created_at': timestampDecoder,\n },\n tasks: {\n 'assigned_to': optionDecoder(),\n 'claimed_at': optionDecoder(timestampDecoder),\n 'github_issue_url': optionDecoder(),\n 'github_pr_url': optionDecoder(),\n 'source_idea_id': optionDecoder(),\n 'archived_reason': optionDecoder(),\n 'status_changed_by': optionDecoder(),\n 'status_changed_at': optionDecoder(timestampDecoder),\n 'created_at': timestampDecoder,\n 'updated_at': timestampDecoder,\n 'status': enumDecoders.TaskStatus,\n 'blocked_from_status': optionDecoder(enumDecoders.TaskStatus),\n },\n voice_announcements: {\n 'context_type': optionDecoder(),\n 'context_id': optionDecoder(),\n 'finalized_at': optionDecoder(timestampDecoder),\n 'failed_at': optionDecoder(timestampDecoder),\n 'error_message': optionDecoder(),\n 'created_at': timestampDecoder,\n 'status': enumDecoders.AnnouncementStatus,\n },\n votes: {\n 'created_at': timestampDecoder,\n },\n};\n\n/**\n * Decode a row using table-specific decoders.\n * @param row - The raw row from SQL query\n * @param columnNames - Ordered column names from schema\n * @param tableName - The table name for decoder lookup\n * @returns Decoded row with human-readable values\n */\nexport function decodeRow(\n row: unknown[],\n columnNames: string[],\n tableName?: string\n): Record<string, unknown> {\n const decoders = tableName ? TABLE_DECODERS[tableName] : undefined;\n const result: Record<string, unknown> = {};\n \n for (let i = 0; i < columnNames.length; i++) {\n const colName = columnNames[i];\n const value = row[i];\n const decoder = decoders?.[colName];\n result[colName] = decoder ? decoder(value) : value;\n }\n \n return result;\n}\n\n/**\n * Infer table name from a simple SQL query.\n * Only works for straightforward \"SELECT ... FROM table\" queries.\n */\nexport function inferTableName(sql: string): string | undefined {\n const match = sql.match(/FROM\\s+(\\w+)/i);\n return match?.[1]?.toLowerCase();\n}","export interface SqlColumn {\n\tname: string;\n\ttype: string;\n}\n\nexport interface SqlSchema {\n\tcolumns: SqlColumn[];\n}\n\nexport interface SqlStatementResult {\n\tschema: SqlSchema | unknown;\n\trows: unknown[];\n}\n\nexport interface SqlRowObject {\n\t[key: string]: unknown;\n}\n\nexport interface SqlSchemaElement {\n\tname: { some?: string } | string;\n\talgebraic_type?: unknown;\n\ttype?: string;\n}\n\nexport interface SqlSchemaAlt {\n\telements?: SqlSchemaElement[];\n}\n\nconst extractColumnName = (element: SqlSchemaElement): string | undefined => {\n\tif (typeof element.name === \"string\") {\n\t\treturn element.name;\n\t}\n\tif (\n\t\telement.name &&\n\t\ttypeof element.name === \"object\" &&\n\t\t\"some\" in element.name\n\t) {\n\t\treturn element.name.some;\n\t}\n\treturn undefined;\n};\n\nexport interface SqlRequestOptions {\n\thost: string;\n\tmoduleName: string;\n\ttoken: string;\n\tsql: string;\n\ttimeoutMs: number;\n}\n\nexport interface SqlRequestSuccess {\n\tresults: SqlStatementResult[];\n\tdurationMs: number;\n}\n\nexport class SqlRequestError extends Error {\n\treadonly status: number;\n\treadonly responseBody: string;\n\n\tconstructor(status: number, responseBody: string, message?: string) {\n\t\tsuper(message || `SQL request failed with status ${status}`);\n\t\tthis.name = \"SqlRequestError\";\n\t\tthis.status = status;\n\t\tthis.responseBody = responseBody;\n\t}\n}\n\nexport const normalizeSqlHttpBase = (host: string): string => {\n\tconst url = new URL(host);\n\tif (url.protocol === \"ws:\") {\n\t\turl.protocol = \"http:\";\n\t} else if (url.protocol === \"wss:\") {\n\t\turl.protocol = \"https:\";\n\t} else if (url.protocol !== \"http:\" && url.protocol !== \"https:\") {\n\t\tthrow new Error(`Unsupported host protocol: ${url.protocol}`);\n\t}\n\treturn url.toString();\n};\n\nexport const buildSqlEndpoint = (host: string, moduleName: string): string => {\n\tconst base = normalizeSqlHttpBase(host);\n\tconst url = new URL(base);\n\tconst basePath = url.pathname.replace(/\\/$/, \"\");\n\turl.pathname = `${basePath}/v1/database/${encodeURIComponent(moduleName)}/sql`;\n\treturn url.toString();\n};\n\nconst parseResults = (payload: unknown): SqlStatementResult[] => {\n\tif (!Array.isArray(payload)) {\n\t\tthrow new Error(\n\t\t\t\"Invalid SQL response: expected array of statement results\",\n\t\t);\n\t}\n\treturn payload.map((statement) => {\n\t\tconst record = statement as { schema?: unknown; rows?: unknown };\n\t\tconst rows = Array.isArray(record.rows) ? record.rows : [];\n\t\treturn {\n\t\t\tschema: record.schema,\n\t\t\trows,\n\t\t};\n\t});\n};\n\nexport const executeSqlRequest = async (\n\toptions: SqlRequestOptions,\n): Promise<SqlRequestSuccess> => {\n\tconst endpoint = buildSqlEndpoint(options.host, options.moduleName);\n\tconst controller = new AbortController();\n\tconst timeoutHandle = setTimeout(() => controller.abort(), options.timeoutMs);\n\tconst started = Date.now();\n\n\ttry {\n\t\tconst response = await fetch(endpoint, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: {\n\t\t\t\tAuthorization: `Bearer ${options.token}`,\n\t\t\t\t\"Content-Type\": \"text/plain\",\n\t\t\t\tAccept: \"application/json\",\n\t\t\t},\n\t\t\tbody: options.sql,\n\t\t\tsignal: controller.signal,\n\t\t});\n\n\t\tconst responseText = await response.text();\n\t\tif (!response.ok) {\n\t\t\tthrow new SqlRequestError(response.status, responseText);\n\t\t}\n\n\t\tlet parsed: unknown;\n\t\ttry {\n\t\t\tparsed = responseText ? JSON.parse(responseText) : [];\n\t\t} catch {\n\t\t\tthrow new Error(\"Invalid SQL response: expected JSON payload\");\n\t\t}\n\n\t\treturn {\n\t\t\tresults: parseResults(parsed),\n\t\t\tdurationMs: Date.now() - started,\n\t\t};\n\t} finally {\n\t\tclearTimeout(timeoutHandle);\n\t}\n};\n\n// Extract column names from schema for use in responses\nexport const extractColumnNames = (result: SqlStatementResult): string[] => {\n\tconst schema = result.schema as SqlSchema | SqlSchemaAlt | undefined;\n\n\tif (schema && \"elements\" in schema && Array.isArray(schema.elements)) {\n\t\treturn schema.elements\n\t\t\t.map(extractColumnName)\n\t\t\t.filter((name): name is string => name !== undefined);\n\t} else if (schema && \"columns\" in schema && Array.isArray(schema.columns)) {\n\t\treturn schema.columns.map((col) => col.name);\n\t}\n\n\treturn [];\n};\n\n// Parse SQL error to provide helpful suggestions\nexport const parseSqlError = (\n\tresponseBody: string,\n): { message: string; suggestion?: string } => {\n\t// Try to parse as JSON first, fallback to plain text\n\tlet errorMsg: string;\n\ttry {\n\t\tconst parsed = JSON.parse(responseBody);\n\t\terrorMsg = parsed.error || responseBody;\n\t} catch {\n\t\terrorMsg = responseBody;\n\t}\n\n\t// Common SpacetimeDB SQL errors with suggestions\n\tif (errorMsg.includes(\"ORDER BY\")) {\n\t\treturn {\n\t\t\tmessage: errorMsg,\n\t\t\tsuggestion:\n\t\t\t\t\"SpacetimeDB SQL does not support ORDER BY. Remove it or filter/sort results locally.\",\n\t\t};\n\t}\n\tif (errorMsg.includes(\"IS NULL\") || errorMsg.includes(\"IS NOT NULL\")) {\n\t\treturn {\n\t\t\tmessage: errorMsg,\n\t\t\tsuggestion:\n\t\t\t\t'Use \"column = NULL\" or \"column != NULL\" instead of IS NULL / IS NOT NULL.',\n\t\t};\n\t}\n\tif (errorMsg.includes(\"JOIN\")) {\n\t\treturn {\n\t\t\tmessage: errorMsg,\n\t\t\tsuggestion:\n\t\t\t\t\"SpacetimeDB has limited JOIN support. Try querying single tables or use multiple queries.\",\n\t\t};\n\t}\n\tif (errorMsg.includes(\"no such table\")) {\n\t\treturn {\n\t\t\tmessage: errorMsg,\n\t\t\tsuggestion:\n\t\t\t\t\"Check the table name. Common tables: tasks, projects, agents, ideas, messages.\",\n\t\t};\n\t}\n\tif (errorMsg.includes(\"no such column\")) {\n\t\treturn {\n\t\t\tmessage: errorMsg,\n\t\t\tsuggestion:\n\t\t\t\t\"Check the column name. Use SELECT * to see all available columns.\",\n\t\t};\n\t}\n\n\treturn { message: errorMsg };\n};\n","import { readFile } from \"node:fs/promises\";\nimport { defineCommand } from \"citty\";\nimport { inferTableName, TABLE_DECODERS } from \"~/generated/decoders.js\";\nimport { getConfig } from \"~/utils/config.js\";\nimport { printHelp } from \"~/utils/help.js\";\nimport { error, isJsonMode, setJsonMode, success } from \"~/utils/output.js\";\nimport {\n\texecuteSqlRequest,\n\textractColumnNames,\n\tparseSqlError,\n\tSqlRequestError,\n\ttype SqlStatementResult,\n} from \"~/utils/sql.js\";\nimport { getCachedToken } from \"~/utils/token-cache.js\";\nimport { getWalletInfo } from \"~/utils/wallet.js\";\n\n// Known tables derived from generated decoders\nconst KNOWN_TABLES = Object.keys(TABLE_DECODERS);\n\nimport { formatToon } from \"~/utils/toon.js\";\n\n// Helper to handle query errors with improved messages\nconst handleQueryError = (err: unknown, timeoutMs: number): never => {\n\tif (err instanceof SqlRequestError) {\n\t\tif (err.status === 401) {\n\t\t\terror(\n\t\t\t\t\"AUTH_REQUIRED\",\n\t\t\t\t\"Authentication required. Run `probe auth <wallet> --save` first.\",\n\t\t\t);\n\t\t}\n\t\tconst { message, suggestion } = parseSqlError(err.responseBody);\n\t\t// Error parsed with potential suggestion\n\t\tif (err.status === 400) {\n\t\t\terror(\"SQL_INVALID\", message, suggestion);\n\t\t}\n\t\terror(\"SQL_FAILED\", message, suggestion);\n\t}\n\n\tif (err instanceof Error && err.name === \"AbortError\") {\n\t\terror(\"SQL_UNAVAILABLE\", `SQL request timed out after ${timeoutMs}ms`);\n\t}\n\n\terror(\n\t\t\"SQL_UNAVAILABLE\",\n\t\terr instanceof Error ? err.message : \"SQL request failed\",\n\t);\n};\n\nconst DEFAULT_TIMEOUT_MS = 30_000;\n\nconst buildMeta = (results: SqlStatementResult[], durationMs: number) => ({\n\tduration_ms: durationMs,\n\tquery_count: results.length,\n\trow_count_total: results.reduce((sum, item) => sum + item.rows.length, 0),\n});\n\n// Build flat response structure for JSON mode\ninterface QueryResult {\n\tcolumns: string[];\n\trows: Record<string, unknown>[];\n}\n\nconst buildFlatResponse = (\n\tresults: SqlStatementResult[],\n\tshouldDecode: boolean,\n\ttableName?: string,\n): Record<string, QueryResult> => {\n\tconst response: Record<string, QueryResult> = {};\n\n\tfor (let index = 0; index < results.length; index += 1) {\n\t\tconst statement = results[index];\n\t\tconst columns = extractColumnNames(statement);\n\t\tconst decoders =\n\t\t\tshouldDecode && tableName ? TABLE_DECODERS[tableName] : undefined;\n\n\t\tconst rowObjects = (statement.rows as unknown[][]).map((row) => {\n\t\t\tconst obj: Record<string, unknown> = {};\n\t\t\tfor (let i = 0; i < columns.length; i++) {\n\t\t\t\tconst colName = columns[i];\n\t\t\t\tconst value = row[i];\n\t\t\t\tconst decoder = decoders?.[colName];\n\t\t\t\tobj[colName] = decoder ? decoder(value) : value;\n\t\t\t}\n\t\t\treturn obj;\n\t\t});\n\n\t\tresponse[`query_${index + 1}`] = { columns, rows: rowObjects };\n\t}\n\n\tif (results.length === 0) {\n\t\tresponse.query_1 = { columns: [], rows: [] };\n\t}\n\n\treturn response;\n};\n\nconst formatStatementsToToon = (\n\tresults: SqlStatementResult[],\n\tmetaEnabled: boolean,\n\tdurationMs: number,\n\tshouldDecode: boolean,\n\ttableName?: string,\n): string => {\n\tconst payload: Record<string, unknown> = {};\n\tconst decoders =\n\t\tshouldDecode && tableName ? TABLE_DECODERS[tableName] : undefined;\n\n\tfor (let index = 0; index < results.length; index += 1) {\n\t\tconst statement = results[index];\n\t\tconst columns = extractColumnNames(statement);\n\n\t\tconst rowObjects = (statement.rows as unknown[][]).map((row) => {\n\t\t\tconst obj: Record<string, unknown> = {};\n\t\t\tfor (let i = 0; i < columns.length; i++) {\n\t\t\t\tconst colName = columns[i];\n\t\t\t\tconst value = row[i];\n\t\t\t\tconst decoder = decoders?.[colName];\n\t\t\t\tobj[colName] = decoder ? decoder(value) : value;\n\t\t\t}\n\t\t\treturn obj;\n\t\t});\n\n\t\tpayload[`query_${index + 1}`] = rowObjects;\n\t}\n\n\tif (results.length === 0) {\n\t\tpayload.query_1 = [];\n\t}\n\n\tif (metaEnabled) {\n\t\tconst meta = buildMeta(results, durationMs);\n\t\tpayload.meta = [meta];\n\t}\n\n\treturn formatToon(payload);\n};\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"query\",\n\t\tdescription: \"Run SQL read queries against Nexus\",\n\t},\n\targs: {\n\t\tsql: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"SQL query string\",\n\t\t\trequired: false,\n\t\t},\n\t\tfile: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Read SQL from file path\",\n\t\t},\n\t\twallet: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Wallet name override\",\n\t\t},\n\t\thost: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"SpacetimeDB host override\",\n\t\t},\n\t\tmodule: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"SpacetimeDB module override\",\n\t\t},\n\t\ttimeout: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Request timeout in milliseconds\",\n\t\t},\n\t\tmeta: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Include metadata in output\",\n\t\t\tdefault: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t\ttables: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"List all available tables\",\n\t\t\tdefault: false,\n\t\t},\n\t\tdecode: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Decode algebraic types to human-readable values\",\n\t\t\tdefault: true,\n\t\t},\n\t\traw: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output raw algebraic type arrays (no decoding)\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) {\n\t\t\tsetJsonMode(true);\n\t\t}\n\n\t\tconst hasSql = args.sql || args.file;\n\n\t\t// Handle --tables flag\n\t\tif (args.tables) {\n\t\t\tif (isJsonMode()) {\n\t\t\t\tsuccess({ tables: KNOWN_TABLES });\n\t\t\t} else {\n\t\t\t\tconsole.log(formatToon({ tables: KNOWN_TABLES }));\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Validate arguments\n\t\tif (!hasSql) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe query\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Execute SQL against the configured Nexus SpacetimeDB module\",\n\t\t\t\tusage: [\n\t\t\t\t\t'probe query \"SELECT * FROM tasks LIMIT 5\"',\n\t\t\t\t\t\"probe query --file ./query.sql --meta\",\n\t\t\t\t\t\"probe query --tables\",\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--file\", detail: \"Read SQL from file\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--wallet\",\n\t\t\t\t\t\tdetail: \"Wallet override (defaults to config defaultWallet)\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--host, --module\",\n\t\t\t\t\t\tdetail: \"Nexus SpacetimeDB target overrides\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--timeout\",\n\t\t\t\t\t\tdetail: `Request timeout in ms (default: ${DEFAULT_TIMEOUT_MS})`,\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"--meta\", detail: \"Include metadata in output\" },\n\t\t\t\t\t{ name: \"--json\", detail: \"JSON output mode with keyed objects\" },\n\t\t\t\t\t{ name: \"--tables\", detail: \"List all available tables\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--decode\",\n\t\t\t\t\t\tdetail: \"Decode algebraic types (default: true)\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--raw\",\n\t\t\t\t\t\tdetail: \"Output raw algebraic arrays (no decoding)\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tnotes: [\n\t\t\t\t\t\"This command is read-only and intended for SQL queries against Nexus tables.\",\n\t\t\t\t\t'JSON mode returns keyed objects: {\"query_1\": {\"columns\": [...], \"rows\": [{\"id\": 1, ...}]}}',\n\t\t\t\t\t\"Use --raw to see raw SpacetimeDB algebraic type arrays.\",\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst timeoutMs = args.timeout\n\t\t\t? Number.parseInt(args.timeout, 10)\n\t\t\t: DEFAULT_TIMEOUT_MS;\n\t\tif (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {\n\t\t\terror(\"INVALID_TIMEOUT\", `Invalid timeout: ${args.timeout}`);\n\t\t}\n\n\t\tconst config = await getConfig();\n\t\tconst walletName = args.wallet || config.defaultWallet;\n\t\tif (!walletName) {\n\t\t\terror(\n\t\t\t\t\"WALLET_REQUIRED\",\n\t\t\t\t\"Wallet required. Use --wallet or set default wallet.\",\n\t\t\t);\n\t\t}\n\n\t\tconst wallet = await getWalletInfo(walletName);\n\t\tif (!wallet) {\n\t\t\terror(\"WALLET_NOT_FOUND\", `Wallet not found: ${walletName}`);\n\t\t}\n\n\t\tconst cached = await getCachedToken(walletName);\n\t\tif (!cached) {\n\t\t\terror(\n\t\t\t\t\"AUTH_REQUIRED\",\n\t\t\t\t\"No cached token. Run `probe auth <wallet> --save` first.\",\n\t\t\t);\n\t\t}\n\n\t\tconst host = args.host || config.spacetime.host;\n\t\tconst moduleName = args.module || config.spacetime.module;\n\t\tconst sql = args.file\n\t\t\t? await readFile(args.file, \"utf-8\")\n\t\t\t: (args.sql ?? \"\");\n\t\tif (!sql.trim()) {\n\t\t\terror(\"SQL_REQUIRED\", \"SQL query is empty\");\n\t\t}\n\n\t\t// Determine if we should decode algebraic types\n\t\tconst shouldDecode = args.raw ? false : (args.decode ?? true);\n\t\tconst tableName = inferTableName(sql);\n\n\t\ttry {\n\t\t\tconst { results, durationMs } = await executeSqlRequest({\n\t\t\t\thost,\n\t\t\t\tmoduleName,\n\t\t\t\ttoken: cached.token,\n\t\t\t\tsql,\n\t\t\t\ttimeoutMs,\n\t\t\t});\n\n\t\t\tif (isJsonMode()) {\n\t\t\t\tconst flatResponse = buildFlatResponse(\n\t\t\t\t\tresults,\n\t\t\t\t\tshouldDecode,\n\t\t\t\t\ttableName,\n\t\t\t\t);\n\t\t\t\tif (args.meta) {\n\t\t\t\t\tsuccess({ ...flatResponse, meta: buildMeta(results, durationMs) });\n\t\t\t\t} else {\n\t\t\t\t\tsuccess(flatResponse);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconsole.log(\n\t\t\t\tformatStatementsToToon(\n\t\t\t\t\tresults,\n\t\t\t\t\tBoolean(args.meta),\n\t\t\t\t\tdurationMs,\n\t\t\t\t\tshouldDecode,\n\t\t\t\t\ttableName,\n\t\t\t\t),\n\t\t\t);\n\t\t} catch (err) {\n\t\t\thandleQueryError(err, timeoutMs);\n\t\t}\n\t},\n});\n","import { Buffer } from \"node:buffer\";\nimport { readFile } from \"node:fs/promises\";\nimport { defineCommand } from \"citty\";\nimport { resolvePasswordInput } from \"~/utils/credentials.js\";\nimport { printHelp } from \"~/utils/help.js\";\nimport {\n\terror,\n\tisJsonMode,\n\tsetJsonMode,\n\tsuccess,\n\tsuccessMessage,\n} from \"~/utils/output.js\";\nimport { loadWallet } from \"~/utils/wallet.js\";\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"sign\",\n\t\tdescription: \"Sign a message using wallet private key\",\n\t},\n\targs: {\n\t\tname: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Wallet name\",\n\t\t\trequired: false,\n\t\t},\n\t\tmessage: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Message to sign\",\n\t\t\trequired: false,\n\t\t},\n\t\t\"message-file\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Read message from file\",\n\t\t},\n\t\t\"password-file\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Read password from file\",\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) {\n\t\t\tsetJsonMode(true);\n\t\t}\n\n\t\tconst name = args.name;\n\n\t\tif (!name) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe sign\",\n\t\t\t\tdescription: \"Sign arbitrary text using wallet private key\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe sign <wallet-name> <message> [options]\",\n\t\t\t\t\t\"probe sign <wallet-name> --message-file ./payload.txt [options]\",\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--message-file\", detail: \"Read message content from file\" },\n\t\t\t\t\t{ name: \"--password-file\", detail: \"Read wallet password from file\" },\n\t\t\t\t\t{ name: \"--json\", detail: \"JSON output for agents\" },\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tlet message: string;\n\n\t\tif (args[\"message-file\"]) {\n\t\t\ttry {\n\t\t\t\tmessage = await readFile(args[\"message-file\"], \"utf-8\");\n\t\t\t} catch {\n\t\t\t\terror(\n\t\t\t\t\t\"FILE_READ_ERROR\",\n\t\t\t\t\t`Failed to read message file: ${args[\"message-file\"]}`,\n\t\t\t\t);\n\t\t\t}\n\t\t} else if (args.message) {\n\t\t\tmessage = args.message;\n\t\t} else {\n\t\t\terror(\"MESSAGE_REQUIRED\", \"Message or message-file required\");\n\t\t}\n\n\t\tconst walletPassword = await resolvePasswordInput({\n\t\t\tpasswordFile: args[\"password-file\"],\n\t\t\tpromptMessage: \"Enter wallet password:\",\n\t\t\tjsonModeError:\n\t\t\t\t\"Password file required in JSON mode or provide PROBE_WALLET_PASSWORD\",\n\t\t});\n\n\t\ttry {\n\t\t\tconst keyStore = await loadWallet(name, walletPassword);\n\t\t\tconst keyPair = keyStore.getKeyPair(0);\n\n\t\t\tconst signature = keyPair.sign(Buffer.from(message));\n\t\t\tconst publicKey = keyPair.getPublicKey();\n\t\t\tconst address = keyPair.getAddress();\n\n\t\t\tsuccess({\n\t\t\t\twallet: name,\n\t\t\t\tmessage,\n\t\t\t\tsignature: signature.toString(\"hex\"),\n\t\t\t\tpublicKey: publicKey.toString(\"hex\"),\n\t\t\t\taddress: address.toString(),\n\t\t\t});\n\n\t\t\tif (!isJsonMode()) {\n\t\t\t\tsuccessMessage(\"Message signed successfully\");\n\t\t\t\tconsole.log(`Signature: ${signature.toString(\"hex\")}`);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\terror(\n\t\t\t\t\"SIGN_ERROR\",\n\t\t\t\terr instanceof Error ? err.message : \"Failed to sign message\",\n\t\t\t);\n\t\t}\n\t},\n});\n","import { defineCommand } from \"citty\";\nimport { printHelp } from \"~/utils/help.js\";\nimport {\n\terror,\n\tinfo,\n\tisJsonMode,\n\tsetJsonMode,\n\tsuccess,\n} from \"~/utils/output.js\";\nimport { clearCachedToken, getCachedToken } from \"~/utils/token-cache.js\";\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"token\",\n\t\tdescription: \"Show cached JWT token for wallet\",\n\t},\n\targs: {\n\t\tname: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Wallet name\",\n\t\t\trequired: false,\n\t\t},\n\t\tclear: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Clear cached token now (next auth call gets a new token)\",\n\t\t\tdefault: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) {\n\t\t\tsetJsonMode(true);\n\t\t}\n\n\t\tconst name = args.name;\n\n\t\tif (!name) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe token\",\n\t\t\t\tdescription: \"Inspect or clear cached authentication token\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe token <wallet-name> [options]\",\n\t\t\t\t\t\"probe token <wallet-name> --clear\",\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--clear\", detail: \"Clear cached token now (recommended)\" },\n\t\t\t\t\t{ name: \"--json\", detail: \"JSON output for agents\" },\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tif (args.clear) {\n\t\t\tawait clearCachedToken(name);\n\n\t\t\tsuccess({ cleared: name });\n\n\t\t\tif (!isJsonMode()) {\n\t\t\t\tinfo(\n\t\t\t\t\t`Token cache cleared for \"${name}\". Run 'probe auth' to get a new token.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst cached = await getCachedToken(name);\n\n\t\t\tif (!cached) {\n\t\t\t\terror(\n\t\t\t\t\t\"TOKEN_NOT_FOUND\",\n\t\t\t\t\t`No cached token for wallet '${name}'`,\n\t\t\t\t\t`Run 'probe auth ${name} --save' to authenticate`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst expiresAt = new Date(cached.expiresAt);\n\t\t\tconst now = new Date();\n\t\t\tconst expiresIn = Math.floor(\n\t\t\t\t(expiresAt.getTime() - now.getTime()) / 1000,\n\t\t\t);\n\t\t\tconst valid = expiresIn > 0;\n\n\t\t\tsuccess({\n\t\t\t\twallet: name,\n\t\t\t\ttoken: cached.token,\n\t\t\t\texpiresAt: cached.expiresAt,\n\t\t\t\texpiresIn: Math.max(0, expiresIn),\n\t\t\t\tvalid,\n\t\t\t});\n\n\t\t\tif (!isJsonMode()) {\n\t\t\t\tconsole.log(`Wallet: ${name}`);\n\t\t\t\tconsole.log(`Token: ${cached.token.slice(0, 50)}...`);\n\t\t\t\tconsole.log(`Expires: ${expiresAt.toUTCString()}`);\n\t\t\t\tconsole.log(`Status: ${valid ? \"Valid\" : \"Expired\"}`);\n\n\t\t\t\tif (!valid) {\n\t\t\t\t\tinfo(\n\t\t\t\t\t\t\"Token has expired. Run with --clear to remove it and re-authenticate.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err) {\n\t\t\terror(\n\t\t\t\t\"TOKEN_ERROR\",\n\t\t\t\terr instanceof Error ? err.message : \"Failed to read token\",\n\t\t\t);\n\t\t}\n\t},\n});\n","import { execSync } from \"node:child_process\";\nimport { createHash } from \"node:crypto\";\nimport {\n\tcreateWriteStream,\n\texistsSync,\n\treadFileSync,\n\trenameSync,\n\tunlinkSync,\n} from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { arch, platform } from \"node:os\";\nimport { dirname, resolve } from \"node:path\";\nimport { Readable } from \"node:stream\";\nimport { finished } from \"node:stream/promises\";\n\nexport type InstallMethod = \"npm\" | \"binary\" | \"unknown\";\nexport type InstallMethodArg = \"auto\" | \"npm\" | \"binary\";\n\nconst PACKAGE = \"@zenon-red/probe\";\nconst REPO = \"zenon-red/probe\";\nconst NPM_REGISTRY = \"https://registry.npmjs.org\";\nconst GITHUB_API = \"https://api.github.com\";\nconst REQUEST_TIMEOUT = 30_000;\n\nconst require = createRequire(import.meta.url);\n\nexport function normalizeVersion(input: string): string {\n\tconst trimmed = input.trim();\n\tif (trimmed.startsWith(`${PACKAGE}@`)) {\n\t\treturn trimmed.slice(`${PACKAGE}@`.length);\n\t}\n\tif (trimmed.startsWith(\"refs/tags/\")) {\n\t\treturn normalizeVersion(trimmed.slice(\"refs/tags/\".length));\n\t}\n\treturn trimmed.replace(/^v/, \"\");\n}\n\nexport function getCurrentVersion(): string {\n\tconst candidates = [\n\t\t\"../../package.json\",\n\t\t\"../package.json\",\n\t\t\"../../../package.json\",\n\t];\n\ttry {\n\t\tfor (const candidate of candidates) {\n\t\t\ttry {\n\t\t\t\tconst version = require(candidate).version as string;\n\t\t\t\tif (version) return version;\n\t\t\t} catch {\n\t\t\t\t// try next candidate\n\t\t\t}\n\t\t}\n\t\tif (process.env.npm_package_version) {\n\t\t\treturn process.env.npm_package_version;\n\t\t}\n\t} catch {\n\t\t// fallthrough\n\t}\n\treturn \"0.0.0\";\n}\n\nexport function detectMethod(explicit?: InstallMethodArg): InstallMethod {\n\tif (explicit && explicit !== \"auto\") return explicit;\n\n\tconst execPath = process.execPath;\n\tconst argv1 = process.argv[1] || \"\";\n\tlet resolvedProbePath = \"\";\n\n\ttry {\n\t\tresolvedProbePath = execSync(\"command -v probe\", {\n\t\t\ttimeout: 5_000,\n\t\t\tencoding: \"utf8\",\n\t\t}).trim();\n\t} catch {\n\t\t// ignore lookup failures\n\t}\n\n\t// Standalone binary heuristics\n\tif (\n\t\texecPath.includes(\".probe\") ||\n\t\texecPath.includes(\"probe-linux\") ||\n\t\texecPath.includes(\"probe-darwin\") ||\n\t\texecPath.includes(\"probe-windows\") ||\n\t\targv1.includes(\".probe\") ||\n\t\tresolvedProbePath.includes(\".probe\") ||\n\t\tresolvedProbePath.includes(\"probe-linux\") ||\n\t\tresolvedProbePath.includes(\"probe-darwin\") ||\n\t\tresolvedProbePath.includes(\"probe-windows\")\n\t) {\n\t\treturn \"binary\";\n\t}\n\n\t// npm global install heuristic\n\tif (\n\t\targv1.includes(\"node_modules\") ||\n\t\tresolvedProbePath.includes(\"node_modules\")\n\t)\n\t\treturn \"npm\";\n\n\t// Try npm list (only if npm exists)\n\ttry {\n\t\tconst out = execSync(\"npm list -g @zenon-red/probe --depth=0 2>/dev/null\", {\n\t\t\ttimeout: 10_000,\n\t\t\tencoding: \"utf8\",\n\t\t});\n\t\tif (out.includes(\"@zenon-red/probe\")) return \"npm\";\n\t} catch {\n\t\t// npm not found or not installed globally\n\t}\n\n\treturn \"unknown\";\n}\n\nexport async function fetchLatestNpmVersion(): Promise<string> {\n\tconst url = `${NPM_REGISTRY}/${PACKAGE}/latest`;\n\tconst res = await fetch(url, {\n\t\tsignal: AbortSignal.timeout(REQUEST_TIMEOUT),\n\t});\n\tif (!res.ok) throw new Error(`npm registry returned ${res.status}`);\n\tconst data = (await res.json()) as { version?: string };\n\tif (!data.version) throw new Error(\"No version field in npm response\");\n\treturn normalizeVersion(data.version);\n}\n\nexport interface GitHubRelease {\n\ttag_name: string;\n\tassets: Array<{ name: string; browser_download_url: string }>;\n}\n\nasync function fetchGitHubRelease(path: string): Promise<GitHubRelease> {\n\tconst url = `${GITHUB_API}/repos/${REPO}/releases/${path}`;\n\tconst res = await fetch(url, {\n\t\theaders: { Accept: \"application/vnd.github+json\" },\n\t\tsignal: AbortSignal.timeout(REQUEST_TIMEOUT),\n\t});\n\tif (!res.ok) throw new Error(`GitHub API returned ${res.status}`);\n\treturn (await res.json()) as GitHubRelease;\n}\n\nexport async function fetchLatestGitHubRelease(): Promise<{\n\tversion: string;\n\trelease: GitHubRelease;\n}> {\n\tconst release = await fetchGitHubRelease(\"latest\");\n\tconst version = normalizeVersion(release.tag_name);\n\treturn { version, release };\n}\n\nexport async function fetchGitHubReleaseByVersion(\n\tversion: string,\n): Promise<GitHubRelease> {\n\tconst normalized = normalizeVersion(version);\n\ttry {\n\t\treturn await fetchGitHubRelease(`tags/v${normalized}`);\n\t} catch (err) {\n\t\tconst message = err instanceof Error ? err.message : \"\";\n\t\tif (!message.includes(\"404\")) {\n\t\t\tthrow err;\n\t\t}\n\t\tconst packageTag = encodeURIComponent(`${PACKAGE}@${normalized}`);\n\t\treturn await fetchGitHubRelease(`tags/${packageTag}`);\n\t}\n}\n\nexport function resolveBinaryAssetName(): string {\n\tconst p = platform();\n\tconst a = arch();\n\n\tconst platformMap: Record<string, string> = {\n\t\tlinux: \"linux\",\n\t\tdarwin: \"darwin\",\n\t\twindows: \"windows\",\n\t};\n\tconst archMap: Record<string, string> = {\n\t\tx64: \"x64\",\n\t\tarm64: \"arm64\",\n\t};\n\n\tconst plat = platformMap[p];\n\tconst cpuArch = archMap[a];\n\tif (!plat || !cpuArch) {\n\t\tthrow new Error(`Unsupported platform: ${p}/${cpuArch}`);\n\t}\n\n\tconst ext = (platform() as string) === \"windows\" ? \".exe\" : \"\";\n\treturn `probe-${plat}-${cpuArch}${ext}`;\n}\n\nexport function getBinaryDir(): string {\n\treturn dirname(process.execPath);\n}\n\nexport async function downloadFile(url: string, dest: string): Promise<void> {\n\tconst res = await fetch(url, {\n\t\tsignal: AbortSignal.timeout(REQUEST_TIMEOUT * 2),\n\t\tredirect: \"follow\",\n\t});\n\tif (!res.ok)\n\t\tthrow new Error(`Download failed: ${res.status} ${res.statusText}`);\n\tif (!res.body) throw new Error(\"Empty response body\");\n\n\tconst nodeStream = Readable.fromWeb(\n\t\tres.body as unknown as import(\"node:stream/web\").ReadableStream,\n\t);\n\tconst ws = createWriteStream(dest, { mode: 0o755 });\n\tawait finished(nodeStream.pipe(ws));\n}\n\nexport function verifyChecksum(filePath: string, checksums: string): boolean {\n\tconst fileName =\n\t\tfilePath.split(\"/\").pop() || filePath.split(\"\\\\\").pop() || \"\";\n\tconst lines = checksums.split(\"\\n\");\n\tlet expected = \"\";\n\tfor (const line of lines) {\n\t\tconst [hash, name] = line.trim().split(/\\s+/);\n\t\tif (name === fileName) {\n\t\t\texpected = hash;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (!expected) return false;\n\n\tconst data = readFileSync(filePath);\n\tconst actual = createHash(\"sha256\").update(data).digest(\"hex\");\n\treturn actual === expected;\n}\n\nexport async function upgradeViaNpm(target: string): Promise<void> {\n\tconst version = normalizeVersion(target);\n\texecSync(`npm install -g ${PACKAGE}@${version}`, {\n\t\tstdio: \"inherit\",\n\t\ttimeout: 120_000,\n\t});\n}\n\nexport async function upgradeViaBinary(\n\trelease: GitHubRelease,\n\t_target: string,\n): Promise<void> {\n\tconst assetName = resolveBinaryAssetName();\n\tconst asset = release.assets.find((a) => a.name === assetName);\n\tif (!asset) throw new Error(`Asset not found for ${assetName}`);\n\n\tconst checksumAsset = release.assets.find(\n\t\t(a) => a.name === \"SHA256SUMS.txt\",\n\t);\n\tif (!checksumAsset) throw new Error(\"SHA256SUMS.txt not found in release\");\n\n\tconst binDir = getBinaryDir();\n\tconst targetPath = resolve(\n\t\tbinDir,\n\t\t(platform() as string) === \"windows\" ? \"probe.exe\" : \"probe\",\n\t);\n\tconst tmpPath = `${targetPath}.tmp`;\n\tconst backupPath = `${targetPath}.bak`;\n\n\t// Download binary + checksum\n\tawait downloadFile(asset.browser_download_url, tmpPath);\n\n\tconst checksumRes = await fetch(checksumAsset.browser_download_url, {\n\t\tsignal: AbortSignal.timeout(REQUEST_TIMEOUT),\n\t});\n\tif (!checksumRes.ok) throw new Error(\"Failed to download SHA256SUMS.txt\");\n\tconst checksums = await checksumRes.text();\n\n\t// Verify checksum\n\tif (!verifyChecksum(tmpPath, checksums)) {\n\t\tunlinkSync(tmpPath);\n\t\tthrow new Error(\"CHECKSUM_MISMATCH\");\n\t}\n\n\t// Atomic replace with rollback\n\ttry {\n\t\tif (existsSync(targetPath)) {\n\t\t\trenameSync(targetPath, backupPath);\n\t\t}\n\t\trenameSync(tmpPath, targetPath);\n\t\t// Post-upgrade smoke test\n\t\texecSync(`\"${targetPath}\" --version`, {\n\t\t\ttimeout: 10_000,\n\t\t\tencoding: \"utf8\",\n\t\t});\n\t\t// Cleanup backup on success\n\t\tif (existsSync(backupPath)) {\n\t\t\ttry {\n\t\t\t\tunlinkSync(backupPath);\n\t\t\t} catch {\n\t\t\t\t// non-fatal\n\t\t\t}\n\t\t}\n\t} catch (err) {\n\t\t// Rollback\n\t\tif (existsSync(backupPath)) {\n\t\t\ttry {\n\t\t\t\trenameSync(backupPath, targetPath);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`ROLLBACK_FAILED: Upgrade failed and rollback also failed. Backup at: ${backupPath}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (existsSync(tmpPath)) {\n\t\t\ttry {\n\t\t\t\tunlinkSync(tmpPath);\n\t\t\t} catch {\n\t\t\t\t// non-fatal\n\t\t\t}\n\t\t}\n\t\tthrow err;\n\t}\n}\n","import { defineCommand } from \"citty\";\nimport { confirm } from \"@clack/prompts\";\nimport { printHelp } from \"~/utils/help.js\";\nimport {\n\terror,\n\tinfo,\n\tisJsonMode,\n\tsetJsonMode,\n\tsuccess,\n} from \"~/utils/output.js\";\nimport { toonList } from \"~/utils/toon.js\";\nimport {\n\ttype InstallMethod,\n\ttype InstallMethodArg,\n\tdetectMethod,\n\tfetchGitHubReleaseByVersion,\n\tfetchLatestGitHubRelease,\n\tfetchLatestNpmVersion,\n\tgetCurrentVersion,\n\tnormalizeVersion,\n\tupgradeViaBinary,\n\tupgradeViaNpm,\n} from \"~/utils/upgrade.js\";\n\nconst VALID_METHODS = new Set<InstallMethodArg>([\"auto\", \"npm\", \"binary\"]);\n\nconst printUpgradeResult = (data: {\n\tmethod: InstallMethod;\n\tcurrentVersion: string;\n\ttargetVersion: string;\n\tlatestVersion: string;\n\tupdateAvailable: boolean;\n\tupdated: boolean;\n\tcheckOnly: boolean;\n}): void => {\n\tsuccess(data);\n\tif (isJsonMode()) {\n\t\treturn;\n\t}\n\n\tconsole.log(\n\t\ttoonList(\"upgrade_result\", [\n\t\t\t{\n\t\t\t\tmethod: data.method,\n\t\t\t\tcurrentVersion: data.currentVersion,\n\t\t\t\ttargetVersion: data.targetVersion,\n\t\t\t\tlatestVersion: data.latestVersion,\n\t\t\t\tupdated: data.updated,\n\t\t\t\tcheckOnly: data.checkOnly,\n\t\t\t},\n\t\t]),\n\t);\n};\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"upgrade\",\n\t\tdescription: \"Upgrade Probe to the latest or a specific version\",\n\t},\n\targs: {\n\t\ttarget: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Version to upgrade to (e.g. 1.2.0 or v1.2.0)\",\n\t\t\trequired: false,\n\t\t},\n\t\tcheck: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Check for updates without upgrading\",\n\t\t\tdefault: false,\n\t\t},\n\t\tmethod: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Installation method: auto, npm, binary\",\n\t\t},\n\t\tyes: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Skip confirmation prompts\",\n\t\t\tdefault: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) setJsonMode(true);\n\n\t\tif (args.target === \"--help\" || args.target === \"-h\") {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe upgrade\",\n\t\t\t\tdescription: \"Upgrade Probe to the latest or a specific version\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe upgrade\",\n\t\t\t\t\t\"probe upgrade --check\",\n\t\t\t\t\t\"probe upgrade 1.2.0\",\n\t\t\t\t\t\"probe upgrade --method npm\",\n\t\t\t\t\t\"probe upgrade --method binary --yes\",\n\t\t\t\t\t\"probe upgrade --json --check\",\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--check\",\n\t\t\t\t\t\tdetail: \"Check for updates without upgrading\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"--method\", detail: \"Force install method: auto, npm, binary\" },\n\t\t\t\t\t{ name: \"--yes\", detail: \"Skip confirmation prompts\" },\n\t\t\t\t\t{ name: \"--json\", detail: \"JSON output\" },\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst methodArg = args.method as InstallMethodArg | undefined;\n\t\tif (methodArg && !VALID_METHODS.has(methodArg)) {\n\t\t\terror(\n\t\t\t\t\"INVALID_METHOD\",\n\t\t\t\t`Invalid --method value: ${args.method}`,\n\t\t\t\t\"Use: --method auto | npm | binary\",\n\t\t\t);\n\t\t}\n\n\t\tconst currentVersion = getCurrentVersion();\n\t\tconst method = detectMethod(methodArg);\n\n\t\t// Resolve target version\n\t\tlet targetVersion: string | undefined;\n\t\tlet latestVersion: string | undefined;\n\t\tlet targetRelease: Awaited<ReturnType<typeof fetchGitHubReleaseByVersion>> | undefined;\n\n\t\ttry {\n\t\t\tif (args.target) {\n\t\t\t\ttargetVersion = normalizeVersion(args.target);\n\t\t\t\tif (method === \"binary\") {\n\t\t\t\t\ttargetRelease = await fetchGitHubReleaseByVersion(targetVersion);\n\t\t\t\t}\n\t\t\t} else if (method === \"npm\") {\n\t\t\t\tlatestVersion = await fetchLatestNpmVersion();\n\t\t\t\ttargetVersion = latestVersion;\n\t\t\t} else {\n\t\t\t\tconst gh = await fetchLatestGitHubRelease();\n\t\t\t\tlatestVersion = gh.version;\n\t\t\t\ttargetVersion = gh.version;\n\t\t\t\ttargetRelease = gh.release;\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst message =\n\t\t\t\terr instanceof Error ? err.message : \"Failed to check latest version\";\n\t\t\tif (\n\t\t\t\t!args.target &&\n\t\t\t\tmethod === \"binary\" &&\n\t\t\t\tmessage.includes(\"GitHub API returned 404\")\n\t\t\t) {\n\t\t\t\terror(\n\t\t\t\t\t\"NO_RELEASES_PUBLISHED\",\n\t\t\t\t\t\"No GitHub releases are published yet for binary upgrades.\",\n\t\t\t\t\t\"Use: npm install -g @zenon-red/probe (or your package manager) until the first release is published.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\terror(\n\t\t\t\t\"VERSION_LOOKUP_FAILED\",\n\t\t\t\tmessage,\n\t\t\t);\n\t\t}\n\n\t\tif (!targetVersion) {\n\t\t\terror(\"VERSION_LOOKUP_FAILED\", \"Could not determine target version.\");\n\t\t}\n\n\t\tconst updateAvailable = targetVersion !== currentVersion;\n\n\t\t// Check-only mode\n\t\tif (args.check) {\n\t\t\tprintUpgradeResult({\n\t\t\t\tmethod,\n\t\t\t\tcurrentVersion,\n\t\t\t\ttargetVersion: targetVersion,\n\t\t\t\tlatestVersion: latestVersion || targetVersion,\n\t\t\t\tupdateAvailable,\n\t\t\t\tupdated: false,\n\t\t\t\tcheckOnly: true,\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tif (method === \"unknown\") {\n\t\t\terror(\n\t\t\t\t\"METHOD_UNKNOWN\",\n\t\t\t\t\"Could not detect installation method for in-place upgrade.\",\n\t\t\t\t\"Use --method npm|binary explicitly, or run your package manager upgrade command (e.g. `bun add -g @zenon-red/probe`).\",\n\t\t\t);\n\t\t}\n\n\t\tif (!updateAvailable) {\n\t\t\tprintUpgradeResult({\n\t\t\t\tmethod,\n\t\t\t\tcurrentVersion,\n\t\t\t\ttargetVersion: targetVersion,\n\t\t\t\tlatestVersion: latestVersion || targetVersion,\n\t\t\t\tupdateAvailable: false,\n\t\t\t\tupdated: false,\n\t\t\t\tcheckOnly: false,\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tif (!isJsonMode() && !args.yes) {\n\t\t\tconst shouldUpgrade = await confirm({\n\t\t\t\tmessage: `Upgrade Probe from ${currentVersion} to ${targetVersion}?`,\n\t\t\t});\n\t\t\tif (!shouldUpgrade) {\n\t\t\t\tinfo(\"Upgrade cancelled\");\n\t\t\t\tprocess.exit(0);\n\t\t\t}\n\t\t}\n\n\t\t// Perform upgrade\n\t\ttry {\n\t\t\tif (method === \"npm\") {\n\t\t\t\tawait upgradeViaNpm(targetVersion);\n\t\t\t} else {\n\t\t\t\tconst release =\n\t\t\t\t\ttargetRelease ||\n\t\t\t\t\t(await fetchGitHubReleaseByVersion(targetVersion));\n\t\t\t\tawait upgradeViaBinary(release, targetVersion);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst message = err instanceof Error ? err.message : \"Upgrade failed\";\n\t\t\tconst code = message.includes(\"CHECKSUM_MISMATCH\")\n\t\t\t\t? \"CHECKSUM_MISMATCH\"\n\t\t\t\t: message.includes(\"ROLLBACK_FAILED\")\n\t\t\t\t\t? \"ROLLBACK_FAILED\"\n\t\t\t\t\t: message.includes(\"PERMISSION\") || message.includes(\"EACCES\")\n\t\t\t\t\t\t? \"PERMISSION_DENIED\"\n\t\t\t\t\t\t: \"UPGRADE_FAILED\";\n\t\t\terror(code, message);\n\t\t}\n\n\t\tprintUpgradeResult({\n\t\t\tmethod,\n\t\t\tcurrentVersion,\n\t\t\ttargetVersion: targetVersion,\n\t\t\tlatestVersion: latestVersion || targetVersion,\n\t\t\tupdateAvailable: true,\n\t\t\tupdated: true,\n\t\t\tcheckOnly: false,\n\t\t});\n\t},\n});\n","import { defineCommand } from \"citty\";\nimport { getConfig } from \"~/utils/config.js\";\nimport { resolvePasswordInput } from \"~/utils/credentials.js\";\nimport { forceHelpRequested, printHelp } from \"~/utils/help.js\";\nimport {\n\terror,\n\tisJsonMode,\n\tsetJsonMode,\n\tsuccess,\n\tsuccessMessage,\n\twarning,\n} from \"~/utils/output.js\";\nimport { loadUserConfig, saveUserConfig } from \"~/utils/user-config.js\";\nimport {\n\tcreateWallet as createWalletUtil,\n\tlistWallets,\n} from \"~/utils/wallet.js\";\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"create\",\n\t\tdescription: \"Create a new wallet with randomly generated mnemonic\",\n\t},\n\targs: {\n\t\tname: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Wallet identifier\",\n\t\t\trequired: false,\n\t\t},\n\t\t\"password-file\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Read password from file\",\n\t\t},\n\t\t\"set-default\": {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Set this wallet as the default\",\n\t\t\tdefault: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) {\n\t\t\tsetJsonMode(true);\n\t\t}\n\n\t\tconst name = args.name;\n\n\t\tif (forceHelpRequested() || !name) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe wallet create\",\n\t\t\t\tdescription: \"Create a new encrypted wallet\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe wallet create <name> [options]\",\n\t\t\t\t\t\"probe wallet create agent-wallet --set-default\",\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--password-file\", detail: \"Read wallet password from file\" },\n\t\t\t\t\t{ name: \"--set-default\", detail: \"Set created wallet as default\" },\n\t\t\t\t\t{ name: \"--json\", detail: \"JSON output for agents\" },\n\t\t\t\t],\n\t\t\t\tnotes: [\n\t\t\t\t\t\"Password source order: --password-file, PROBE_WALLET_PASSWORD, interactive prompt.\",\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tif (!/^[a-zA-Z0-9_-]+$/.test(name)) {\n\t\t\terror(\n\t\t\t\t\"INVALID_NAME\",\n\t\t\t\t\"Wallet name must be alphanumeric with hyphens or underscores only\",\n\t\t\t);\n\t\t}\n\n\t\tconst config = await getConfig();\n\t\tconst walletPassword = await resolvePasswordInput({\n\t\t\tpasswordFile: args[\"password-file\"],\n\t\t\tpromptMessage: \"Enter password to encrypt wallet:\",\n\t\t\tconfirmPromptMessage: \"Confirm password:\",\n\t\t\tminLength: config.passwordMinLength,\n\t\t\tjsonModeError:\n\t\t\t\t\"Password required via PROBE_WALLET_PASSWORD env, --password-file, or interactive prompt\",\n\t\t});\n\n\t\ttry {\n\t\t\tconst result = await createWalletUtil(name, walletPassword);\n\n\t\t\tlet setAsDefault = args[\"set-default\"];\n\t\t\tif (!setAsDefault) {\n\t\t\t\tconst wallets = await listWallets();\n\t\t\t\tif (wallets.length === 1) {\n\t\t\t\t\tsetAsDefault = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (setAsDefault) {\n\t\t\t\tconst userConfig = await loadUserConfig();\n\t\t\t\tuserConfig.defaultWallet = result.name;\n\t\t\t\tawait saveUserConfig(userConfig);\n\t\t\t}\n\n\t\t\tsuccess({\n\t\t\t\tname: result.name,\n\t\t\t\taddress: result.address,\n\t\t\t\tpublicKey: result.publicKey,\n\t\t\t\tmnemonic: result.mnemonic,\n\t\t\t\tdefault: setAsDefault,\n\t\t\t});\n\n\t\t\tif (!isJsonMode()) {\n\t\t\t\tsuccessMessage(`Wallet \"${result.name}\" created successfully`);\n\t\t\t\tconsole.log(`Address: ${result.address}`);\n\t\t\t\tconsole.log(`\\nMnemonic: ${result.mnemonic}`);\n\t\t\t\twarning(\"Save this mnemonic securely - it cannot be recovered!\");\n\t\t\t\tif (setAsDefault) {\n\t\t\t\t\tconsole.log(`\\nSet as default wallet`);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err) {\n\t\t\terror(\n\t\t\t\t\"WALLET_CREATE_ERROR\",\n\t\t\t\terr instanceof Error ? err.message : \"Failed to create wallet\",\n\t\t\t);\n\t\t}\n\t},\n});\n","import { defineCommand } from \"citty\";\nimport { forceHelpRequested, printHelp } from \"~/utils/help.js\";\nimport {\n\terror,\n\tisJsonMode,\n\tsetJsonMode,\n\tsuccess,\n\tsuccessMessage,\n} from \"~/utils/output.js\";\nimport { loadUserConfig, saveUserConfig } from \"~/utils/user-config.js\";\nimport { walletExists } from \"~/utils/wallet.js\";\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"default\",\n\t\tdescription: \"Set the default wallet\",\n\t},\n\targs: {\n\t\tname: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Wallet name to set as default\",\n\t\t\trequired: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) {\n\t\t\tsetJsonMode(true);\n\t\t}\n\n\t\tconst name = args.name;\n\n\t\tif (forceHelpRequested() || !name) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe wallet default\",\n\t\t\t\tdescription: \"Set the default wallet used by commands\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe wallet default <name> [options]\",\n\t\t\t\t\t\"probe wallet default agent-wallet\",\n\t\t\t\t],\n\t\t\t\toptions: [{ name: \"--json\", detail: \"JSON output for agents\" }],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst exists = await walletExists(name);\n\t\tif (!exists) {\n\t\t\terror(\"WALLET_NOT_FOUND\", `Wallet '${name}' does not exist`);\n\t\t}\n\n\t\tconst userConfig = await loadUserConfig();\n\t\tuserConfig.defaultWallet = name;\n\t\tawait saveUserConfig(userConfig);\n\n\t\tsuccess({ defaultWallet: name });\n\n\t\tif (!isJsonMode()) {\n\t\t\tsuccessMessage(`Default wallet set to '${name}'`);\n\t\t}\n\t},\n});\n","import { confirm } from \"@clack/prompts\";\nimport { defineCommand } from \"citty\";\nimport { forceHelpRequested, printHelp } from \"~/utils/help.js\";\nimport {\n\terror,\n\tinfo,\n\tisJsonMode,\n\tsetJsonMode,\n\tsuccess,\n\tsuccessMessage,\n} from \"~/utils/output.js\";\nimport { deleteWallet, walletExists } from \"~/utils/wallet.js\";\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"delete\",\n\t\tdescription: \"Delete a wallet\",\n\t},\n\targs: {\n\t\tname: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Wallet name\",\n\t\t\trequired: false,\n\t\t},\n\t\tyes: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Skip confirmation prompt\",\n\t\t\tdefault: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) {\n\t\t\tsetJsonMode(true);\n\t\t}\n\n\t\tconst name = args.name;\n\n\t\tif (forceHelpRequested() || !name) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe wallet delete\",\n\t\t\t\tdescription: \"Delete a wallet from local storage\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe wallet delete <name> [options]\",\n\t\t\t\t\t\"probe wallet delete old-wallet --yes\",\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--yes\", detail: \"Skip interactive confirmation prompt\" },\n\t\t\t\t\t{ name: \"--json\", detail: \"JSON output for agents\" },\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst exists = await walletExists(name);\n\t\tif (!exists) {\n\t\t\terror(\n\t\t\t\t\"WALLET_NOT_FOUND\",\n\t\t\t\t`Wallet '${name}' does not exist`,\n\t\t\t\t`Run 'probe wallet list' to see available wallets`,\n\t\t\t);\n\t\t}\n\n\t\tif (!isJsonMode() && !args.yes) {\n\t\t\tconst shouldDelete = await confirm({\n\t\t\t\tmessage: `Are you sure you want to delete wallet \"${name}\"? This cannot be undone.`,\n\t\t\t});\n\n\t\t\tif (!shouldDelete) {\n\t\t\t\tinfo(\"Deletion cancelled\");\n\t\t\t\tprocess.exit(0);\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\tawait deleteWallet(name);\n\n\t\t\tsuccess({ deleted: name });\n\n\t\t\tif (!isJsonMode()) {\n\t\t\t\tsuccessMessage(`Wallet \"${name}\" deleted successfully`);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\terror(\n\t\t\t\t\"WALLET_DELETE_ERROR\",\n\t\t\t\terr instanceof Error ? err.message : \"Failed to delete wallet\",\n\t\t\t);\n\t\t}\n\t},\n});\n","import { defineCommand } from \"citty\";\nimport {\n\tresolveMnemonicInput,\n\tresolvePasswordInput,\n} from \"~/utils/credentials.js\";\nimport { forceHelpRequested, printHelp } from \"~/utils/help.js\";\nimport {\n\terror,\n\tisJsonMode,\n\tsetJsonMode,\n\tsuccess,\n\tsuccessMessage,\n} from \"~/utils/output.js\";\nimport { loadUserConfig, saveUserConfig } from \"~/utils/user-config.js\";\nimport { importWallet, listWallets } from \"~/utils/wallet.js\";\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"import\",\n\t\tdescription: \"Import wallet from mnemonic phrase\",\n\t},\n\targs: {\n\t\tname: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Wallet identifier\",\n\t\t\trequired: false,\n\t\t},\n\t\tmnemonic: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Mnemonic phrase (space-separated)\",\n\t\t},\n\t\t\"mnemonic-file\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Read mnemonic from file\",\n\t\t},\n\t\t\"password-file\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Read password from file\",\n\t\t},\n\t\t\"set-default\": {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Set this wallet as the default\",\n\t\t\tdefault: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) {\n\t\t\tsetJsonMode(true);\n\t\t}\n\n\t\tconst name = args.name;\n\n\t\tif (forceHelpRequested() || !name) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe wallet import\",\n\t\t\t\tdescription: \"Import an encrypted wallet from mnemonic\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe wallet import <name> [options]\",\n\t\t\t\t\t\"probe wallet import agent-wallet --mnemonic-file ./mnemonic.txt\",\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--mnemonic\", detail: \"24-word mnemonic phrase\" },\n\t\t\t\t\t{ name: \"--mnemonic-file\", detail: \"Read mnemonic from file\" },\n\t\t\t\t\t{ name: \"--password-file\", detail: \"Read wallet password from file\" },\n\t\t\t\t\t{ name: \"--set-default\", detail: \"Set imported wallet as default\" },\n\t\t\t\t\t{ name: \"--json\", detail: \"JSON output for agents\" },\n\t\t\t\t],\n\t\t\t\tnotes: [\n\t\t\t\t\t\"Mnemonic source order: --mnemonic, --mnemonic-file, PROBE_WALLET_MNEMONIC, interactive prompt.\",\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tif (!/^[a-zA-Z0-9_-]+$/.test(name)) {\n\t\t\terror(\n\t\t\t\t\"INVALID_NAME\",\n\t\t\t\t\"Wallet name must be alphanumeric with hyphens or underscores only\",\n\t\t\t);\n\t\t}\n\n\t\tconst mnemonicPhrase = await resolveMnemonicInput({\n\t\t\tmnemonic: args.mnemonic,\n\t\t\tmnemonicFile: args[\"mnemonic-file\"],\n\t\t\tjsonModeError:\n\t\t\t\t\"Mnemonic required via --mnemonic, --mnemonic-file, or PROBE_WALLET_MNEMONIC env\",\n\t\t});\n\n\t\tconst walletPassword = await resolvePasswordInput({\n\t\t\tpasswordFile: args[\"password-file\"],\n\t\t\tpromptMessage: \"Enter password to encrypt wallet:\",\n\t\t\tjsonModeError:\n\t\t\t\t\"Password required via PROBE_WALLET_PASSWORD env, --password-file, or interactive prompt\",\n\t\t});\n\n\t\ttry {\n\t\t\tconst result = await importWallet(name, mnemonicPhrase, walletPassword);\n\n\t\t\tlet setAsDefault = args[\"set-default\"];\n\t\t\tif (!setAsDefault) {\n\t\t\t\tconst wallets = await listWallets();\n\t\t\t\tif (wallets.length === 1) {\n\t\t\t\t\tsetAsDefault = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (setAsDefault) {\n\t\t\t\tconst userConfig = await loadUserConfig();\n\t\t\t\tuserConfig.defaultWallet = result.name;\n\t\t\t\tawait saveUserConfig(userConfig);\n\t\t\t}\n\n\t\t\tsuccess({\n\t\t\t\tname: result.name,\n\t\t\t\taddress: result.address,\n\t\t\t\tdefault: setAsDefault,\n\t\t\t});\n\n\t\t\tif (!isJsonMode()) {\n\t\t\t\tsuccessMessage(`Wallet \"${result.name}\" imported successfully`);\n\t\t\t\tconsole.log(`Address: ${result.address}`);\n\t\t\t\tif (setAsDefault) {\n\t\t\t\t\tconsole.log(`\\nSet as default wallet`);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err) {\n\t\t\terror(\n\t\t\t\t\"WALLET_IMPORT_ERROR\",\n\t\t\t\terr instanceof Error ? err.message : \"Failed to import wallet\",\n\t\t\t);\n\t\t}\n\t},\n});\n","import { defineCommand } from \"citty\";\nimport { getConfig } from \"~/utils/config.js\";\nimport { forceHelpRequested, printHelp } from \"~/utils/help.js\";\nimport {\n\terror,\n\tinfo,\n\tisJsonMode,\n\tsetJsonMode,\n\tsuccess,\n} from \"~/utils/output.js\";\nimport { listWallets } from \"~/utils/wallet.js\";\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"list\",\n\t\tdescription: \"List all stored wallets\",\n\t},\n\targs: {\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (forceHelpRequested()) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe wallet list\",\n\t\t\t\tdescription: \"List all locally stored wallets\",\n\t\t\t\tusage: [\"probe wallet list [options]\", \"probe wallet list --json\"],\n\t\t\t\toptions: [{ name: \"--json\", detail: \"JSON output for agents\" }],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tif (args.json) {\n\t\t\tsetJsonMode(true);\n\t\t}\n\n\t\ttry {\n\t\t\tconst wallets = await listWallets();\n\t\t\tconst config = await getConfig();\n\n\t\t\tconst walletsOutput = wallets.map((w) => ({\n\t\t\t\t...w,\n\t\t\t\tdefault: w.name === config.defaultWallet,\n\t\t\t}));\n\n\t\t\tsuccess(walletsOutput);\n\n\t\t\tif (!isJsonMode()) {\n\t\t\t\tif (wallets.length === 0) {\n\t\t\t\t\tinfo(\"No wallets found\");\n\t\t\t\t} else {\n\t\t\t\t\tconsole.log(\"Wallets:\");\n\t\t\t\t\tfor (const wallet of walletsOutput) {\n\t\t\t\t\t\tconst date = wallet.createdAt\n\t\t\t\t\t\t\t? new Date(wallet.createdAt).toLocaleDateString()\n\t\t\t\t\t\t\t: \"unknown\";\n\t\t\t\t\t\tconst marker = wallet.default ? \"*\" : \" \";\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t`${marker} ${wallet.name.padEnd(12)} ${wallet.address.slice(0, 10)}... created ${date}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (config.defaultWallet) {\n\t\t\t\t\t\tconsole.log(`\\n* = default wallet`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err) {\n\t\t\terror(\n\t\t\t\t\"WALLET_LIST_ERROR\",\n\t\t\t\terr instanceof Error ? err.message : \"Failed to list wallets\",\n\t\t\t);\n\t\t}\n\t},\n});\n","import { readFile } from \"node:fs/promises\";\nimport { defineCommand } from \"citty\";\nimport { forceHelpRequested, printHelp } from \"~/utils/help.js\";\nimport { error, isJsonMode, setJsonMode, success } from \"~/utils/output.js\";\nimport { getWalletInfo, loadWallet } from \"~/utils/wallet.js\";\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"show\",\n\t\tdescription: \"Show wallet address and public key\",\n\t},\n\targs: {\n\t\tname: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Wallet name\",\n\t\t\trequired: false,\n\t\t},\n\t\t\"public-key\": {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Include public key in output\",\n\t\t\tdefault: false,\n\t\t},\n\t\t\"password-file\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Read password from file\",\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) {\n\t\t\tsetJsonMode(true);\n\t\t}\n\n\t\tconst name = args.name;\n\n\t\tif (forceHelpRequested() || !name) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe wallet show\",\n\t\t\t\tdescription: \"Show wallet address and optional public key\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe wallet show <name> [options]\",\n\t\t\t\t\t\"probe wallet show my-wallet --public-key --password-file ./pass.txt\",\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--public-key\", detail: \"Include public key in output\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--password-file\",\n\t\t\t\t\t\tdetail: \"Read password for public key extraction\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"--json\", detail: \"JSON output for agents\" },\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst walletInfo = await getWalletInfo(name);\n\t\tif (!walletInfo) {\n\t\t\terror(\n\t\t\t\t\"WALLET_NOT_FOUND\",\n\t\t\t\t`Wallet '${name}' does not exist`,\n\t\t\t\t`Run 'probe wallet list' to see available wallets`,\n\t\t\t);\n\t\t}\n\n\t\tlet walletPassword: string | undefined;\n\n\t\tif (args[\"password-file\"]) {\n\t\t\ttry {\n\t\t\t\twalletPassword = await readFile(args[\"password-file\"], \"utf-8\");\n\t\t\t\twalletPassword = walletPassword.trim();\n\t\t\t} catch {\n\t\t\t\terror(\n\t\t\t\t\t\"FILE_READ_ERROR\",\n\t\t\t\t\t`Failed to read password file: ${args[\"password-file\"]}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\tlet publicKey: string | undefined;\n\n\t\t\tif (walletPassword) {\n\t\t\t\tconst keyStore = await loadWallet(name, walletPassword);\n\t\t\t\tconst keyPair = keyStore.getKeyPair(0);\n\t\t\t\tpublicKey = keyPair.getPublicKey().toString(\"hex\");\n\t\t\t}\n\n\t\t\tconst result: Record<string, string | undefined> = {\n\t\t\t\tname: walletInfo.name,\n\t\t\t\taddress: walletInfo.address,\n\t\t\t\tcreatedAt: walletInfo.createdAt,\n\t\t\t};\n\n\t\t\tif (args[\"public-key\"] || publicKey) {\n\t\t\t\tresult.publicKey = publicKey;\n\t\t\t}\n\n\t\t\tsuccess(result);\n\n\t\t\tif (!isJsonMode()) {\n\t\t\t\tconsole.log(`Name: ${walletInfo.name}`);\n\t\t\t\tconsole.log(`Address: ${walletInfo.address}`);\n\t\t\t\tif (walletInfo.createdAt) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t`Created: ${new Date(walletInfo.createdAt).toLocaleString()}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (publicKey) {\n\t\t\t\t\tconsole.log(`Public Key: ${publicKey}`);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err) {\n\t\t\terror(\n\t\t\t\t\"WALLET_LOAD_ERROR\",\n\t\t\t\terr instanceof Error ? err.message : \"Failed to load wallet\",\n\t\t\t);\n\t\t}\n\t},\n});\n","import { defineCommand } from \"citty\";\nimport { printHelp } from \"~/utils/help.js\";\nimport create from \"./create.js\";\nimport defaultCmd from \"./default.js\";\nimport deleteCmd from \"./delete.js\";\nimport importCmd from \"./import.js\";\nimport list from \"./list.js\";\nimport show from \"./show.js\";\n\nconst walletSubcommands = new Set([\n\t\"create\",\n\t\"import\",\n\t\"list\",\n\t\"show\",\n\t\"delete\",\n\t\"default\",\n]);\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"wallet\",\n\t\tdescription: \"Manage Zenon Network wallets\",\n\t},\n\trun() {\n\t\tconst positionals = process.argv\n\t\t\t.slice(2)\n\t\t\t.filter((arg) => !arg.startsWith(\"-\"));\n\t\tif (positionals.length > 1 && walletSubcommands.has(positionals[1])) {\n\t\t\treturn;\n\t\t}\n\n\t\tprintHelp({\n\t\t\tcommand: \"probe wallet\",\n\t\t\tdescription: \"Create, import, inspect, and manage wallets\",\n\t\t\tusage: [\n\t\t\t\t\"probe wallet <subcommand> [positionals] [options]\",\n\t\t\t\t\"probe wallet create my-wallet --set-default\",\n\t\t\t\t\"probe wallet import my-wallet --mnemonic-file ./mnemonic.txt\",\n\t\t\t],\n\t\t\tactions: [\n\t\t\t\t{ name: \"create <name>\", detail: \"Create a new encrypted wallet\" },\n\t\t\t\t{ name: \"import <name>\", detail: \"Import wallet from mnemonic phrase\" },\n\t\t\t\t{ name: \"list\", detail: \"List stored wallets\" },\n\t\t\t\t{\n\t\t\t\t\tname: \"show <name>\",\n\t\t\t\t\tdetail: \"Show wallet address and optional public key\",\n\t\t\t\t},\n\t\t\t\t{ name: \"delete <name>\", detail: \"Delete a wallet\" },\n\t\t\t\t{ name: \"default <name>\", detail: \"Set default wallet\" },\n\t\t\t],\n\t\t\tnotes: [\"Use long-form flags only for predictable agent automation.\"],\n\t\t});\n\t},\n\tsubCommands: {\n\t\tcreate,\n\t\timport: importCmd,\n\t\tlist,\n\t\tshow,\n\t\tdelete: deleteCmd,\n\t\tdefault: defaultCmd,\n\t},\n});\n","import { defineCommand } from \"citty\";\nimport type { Agent } from \"~/utils/context.js\";\nimport { withAuth } from \"~/utils/context.js\";\nimport { AgentRole, AgentStatus } from \"~/utils/enums.js\";\nimport { error, isJsonMode, setJsonMode, success } from \"~/utils/output.js\";\nimport { formatTimestamp } from \"~/utils/time.js\";\nimport { toonList } from \"~/utils/toon.js\";\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"whoami\",\n\t\tdescription: \"Show current authenticated agent profile\",\n\t},\n\targs: {\n\t\twallet: { type: \"string\", description: \"Wallet name\" },\n\t\tjson: { type: \"boolean\", description: \"Output JSON\", default: false },\n\t\thost: { type: \"string\", description: \"SpacetimeDB host\" },\n\t\tmodule: { type: \"string\", description: \"Module name\" },\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) setJsonMode(true);\n\n\t\ttry {\n\t\t\tawait withAuth(\n\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\tasync (ctx) => {\n\t\t\t\t\tconst myAgent = ctx\n\t\t\t\t\t\t.iter<Agent>(\"agents\")\n\t\t\t\t\t\t.find(\n\t\t\t\t\t\t\t(a) => a.identity.toHexString() === ctx.identity?.toHexString(),\n\t\t\t\t\t\t);\n\n\t\t\t\t\tif (!myAgent) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"NOT_REGISTERED\",\n\t\t\t\t\t\t\t\"Agent not registered. Run `probe agent register` first.\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tsuccess(myAgent);\n\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\"agent\", [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: myAgent.id,\n\t\t\t\t\t\t\t\t\tname: myAgent.name,\n\t\t\t\t\t\t\t\t\trole: AgentRole.display(myAgent.role),\n\t\t\t\t\t\t\t\t\tstatus: AgentStatus.display(myAgent.status),\n\t\t\t\t\t\t\t\t\tlastHeartbeat: formatTimestamp(myAgent.lastHeartbeat),\n\t\t\t\t\t\t\t\t\tcurrentTaskId: myAgent.currentTaskId\n\t\t\t\t\t\t\t\t\t\t? myAgent.currentTaskId.toString()\n\t\t\t\t\t\t\t\t\t\t: \"\",\n\t\t\t\t\t\t\t\t\tcapabilities: myAgent.capabilities.join(\",\"),\n\t\t\t\t\t\t\t\t\tidentity: ctx.identity?.toHexString() || \"\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\t\t} catch (err) {\n\t\t\t// Handle connection errors gracefully - avoid citty/consola stack traces\n\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\terror(\"CONNECTION_ERROR\", message);\n\t\t}\n\t},\n});\n","import { createRequire } from \"node:module\";\nimport { defineCommand, runMain } from \"citty\";\nimport auth from \"./commands/auth.js\";\nimport config from \"./commands/config.js\";\nimport doctor from \"./commands/doctor.js\";\nimport agent from \"./commands/nexus/agent.js\";\nimport discover from \"./commands/nexus/discover.js\";\nimport idea from \"./commands/nexus/idea.js\";\nimport message from \"./commands/nexus/message.js\";\nimport project from \"./commands/nexus/project.js\";\nimport task from \"./commands/nexus/task.js\";\nimport nexusDaemon from \"./commands/nexus-daemon.js\";\nimport query from \"./commands/query.js\";\nimport sign from \"./commands/sign.js\";\nimport token from \"./commands/token.js\";\nimport upgrade from \"./commands/upgrade.js\";\nimport wallet from \"./commands/wallet/index.js\";\nimport whoami from \"./commands/whoami.js\";\nimport {\n\tnormalizeHelpArgv,\n\tprintHelp,\n\tsetForceHelpRequested,\n} from \"./utils/help.js\";\n\nconst topLevelCommands = new Set([\n\t\"wallet\",\n\t\"auth\",\n\t\"sign\",\n\t\"token\",\n\t\"config\",\n\t\"nexus\",\n\t\"agent\",\n\t\"task\",\n\t\"message\",\n\t\"idea\",\n\t\"discover\",\n\t\"project\",\n\t\"query\",\n\t\"doctor\",\n\t\"whoami\",\n\t\"upgrade\",\n]);\n\nconst applyHelpNormalization = (): void => {\n\tconst normalized = normalizeHelpArgv(process.argv.slice(2));\n\tsetForceHelpRequested(normalized.forceHelp);\n\tprocess.argv = [...process.argv.slice(0, 2), ...normalized.argv];\n};\n\nconst require = createRequire(import.meta.url);\nconst { version, description } = require(\"../package.json\");\n\nconst main = defineCommand({\n\tmeta: { name: \"probe\", version, description },\n\targs: {\n\t\tjson: { type: \"boolean\", description: \"Output JSON only\", default: false },\n\t},\n\trun() {\n\t\tconst firstPositional = process.argv\n\t\t\t.slice(2)\n\t\t\t.find((arg) => !arg.startsWith(\"-\"));\n\t\tif (firstPositional && topLevelCommands.has(firstPositional)) {\n\t\t\treturn;\n\t\t}\n\n\t\tprintHelp({\n\t\t\tcommand: \"probe\",\n\t\t\tdescription,\n\t\t\tusage: [\n\t\t\t\t\"probe <command> [positionals] [options]\",\n\t\t\t\t'probe idea propose --title \"Better task scoring\" --category planning',\n\t\t\t\t\"probe task claim 42 --wallet agent-wallet\",\n\t\t\t],\n\t\t\tactions: [\n\t\t\t\t{ name: \"wallet\", detail: \"Wallet lifecycle commands\" },\n\t\t\t\t{ name: \"auth\", detail: \"Authenticate wallet and cache token\" },\n\t\t\t\t{ name: \"token\", detail: \"Inspect or clear cached token\" },\n\t\t\t\t{ name: \"sign\", detail: \"Sign text payloads\" },\n\t\t\t\t{\n\t\t\t\t\tname: \"nexus\",\n\t\t\t\t\tdetail: \"Run persistent Nexus daemon (keepalive + event logs)\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: \"agent, task, idea, discover, message, project\",\n\t\t\t\t\tdetail: \"Nexus workspace commands\",\n\t\t\t\t},\n\t\t\t\t{ name: \"query\", detail: \"Execute SQL queries against Nexus\" },\n\t\t\t\t{ name: \"doctor\", detail: \"Run setup and connectivity diagnostics\" },\n\t\t\t\t{ name: \"upgrade\", detail: \"Upgrade Probe to the latest version\" },\n\t\t\t\t{ name: \"config\", detail: \"Read/write CLI configuration\" },\n\t\t\t],\n\t\t\toptions: [{ name: \"--json\", detail: \"JSON output mode for agents\" }],\n\t\t\tnotes: [\n\t\t\t\t\"Nexus commands connect to SpacetimeDB (the realtime database backing Nexus).\",\n\t\t\t],\n\t\t});\n\t},\n\tsubCommands: {\n\t\twallet,\n\t\tauth,\n\t\tsign,\n\t\ttoken,\n\t\tconfig,\n\t\tnexus: nexusDaemon,\n\t\tagent,\n\t\ttask,\n\t\tmessage,\n\t\tidea,\n\t\tdiscover,\n\t\tproject,\n\t\tquery,\n\t\tdoctor,\n\t\tupgrade,\n\t\twhoami,\n\t},\n});\n\n// Global error handler to suppress stack traces for expected errors\nconst isExpectedError = (err: unknown): boolean => {\n\tif (!(err instanceof Error)) return false;\n\tconst message = err.message.toLowerCase();\n\treturn (\n\t\tmessage.includes(\"connection failed\") ||\n\t\tmessage.includes(\"connection timeout\") ||\n\t\tmessage.includes(\"authentication required\") ||\n\t\tmessage.includes(\"unauthorized\") ||\n\t\tmessage.includes(\"wallet required\") ||\n\t\tmessage.includes(\"wallet not found\") ||\n\t\tmessage.includes(\"agent not registered\") ||\n\t\tmessage.includes(\"subscription error\")\n\t);\n};\n\nprocess.on(\"unhandledRejection\", (err: unknown) => {\n\tif (isExpectedError(err)) {\n\t\t// Error message already printed by the error() utility\n\t\tprocess.exit(1);\n\t}\n\t// For unexpected errors, let the default handler deal with it\n\tthrow err;\n});\n\napplyHelpNormalization();\nrunMain(main);\n"],"mappings":";qzCAaA,MAAa,GAA8B,CAC1C,OAAQ,wBACR,UAAW,mBACX,kBAAmB,EACnB,cAAe,kBACf,eAAgB,IAChB,UAAW,CACV,KAAM,qBACN,OAAQ,QACR,CACD,CClBK,GAAc,EAAK,GAAS,CAAE,SAAU,cAAc,CACtD,GAAa,EAAK,GAAS,CAAE,SAAS,CAE5C,eAAsB,GAAgD,CACrE,GAAI,CACH,MAAM,EAAO,GAAY,CACzB,IAAM,EAAU,MAAM,EAAS,GAAa,QAAQ,CACpD,OAAO,KAAK,MAAM,EAAQ,MACnB,CACP,MAAO,EAAE,EAIX,eAAsB,GACrB,EACgB,CAChB,MAAM,EAAM,GAAY,CAAE,UAAW,GAAM,CAAC,CAC5C,MAAM,EAAU,GAAa,KAAK,UAAU,EAAQ,KAAM,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,SAAS,uBAAuB,EACxC,EAAQ,SAAS,qBAAqB,EAIxC,QAAQ,GAAG,qBAAuB,GAAiB,CAMlD,MALI,GAAgB,EAAI,EAEvB,QAAQ,KAAK,EAAE,CAGV,GACL,CAEF,IAAwB,CACxB,EAAQ,GAAK"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["jsonReplacer","spinner","clackSpinner","walletSubcommands","spinner","__t","AgentRole","AgentStatus","IdeaStatus","MessageType","ProjectStatus","TaskStatus","__t","__t","__t","__t","__t","__t","__t","__t","__t","__t","__t","AgentRole","__t","__t","MessageType","__t","MessageType","AgentStatus","__t","__t","__t","__t","ProjectStatus","__t","TaskStatus","__t","__t","__t","AgentRole","AgentStatus","__t","__t","__t","__t","__t","IdeaStatus","__t","AgentRole","__t","MessageType","__t","__t","MessageType","__t","ProjectStatus","__t","__t","TaskStatus","__t","__t","__schema","__table","AgentsRow","ChannelsRow","ConfigRow","DiscoveredTasksRow","EvaluationDimensionsRow","IdeasRow","IdentityRolesRow","MessagesRow","ProjectChannelsRow","ProjectMessagesRow","ProjectsRow","TaskDependenciesRow","TasksRow","VoiceAnnouncementsRow","VotesRow","__reducers","__reducerSchema","AddTaskDependencyReducer","ClaimTaskReducer","CreateProjectReducer","CreateTaskReducer","DiscoverTaskReducer","FailVoiceAnnouncementReducer","FinalizeVoiceAnnouncementReducer","HeartbeatReducer","MarkIdeaImplementedReducer","ProposeIdeaReducer","RegisterAgentReducer","ReviewDiscoveredTaskReducer","SeedUiDataReducer","SeedVoiceAnnouncementsReducer","SendMessageReducer","SendProjectMessageReducer","SetAgentStatusReducer","UpdateAgentBioReducer","UpdateAgentCapabilitiesReducer","UpdateProjectStatusReducer","UpdateTaskStatusReducer","VoteIdeaReducer","__procedures","__procedureSchema","GenerateVoiceProcedure.params","GenerateVoiceProcedure.returnType","__makeQueryBuilder","reducers","__convertToAccessorMap","__SubscriptionBuilderImpl","DbConnectionBuilder","__DbConnectionBuilder","__DbConnectionImpl","createWalletUtil","importCmd","deleteCmd","defaultCmd","nexusDaemon"],"sources":["../src/types/config.ts","../src/utils/user-config.ts","../src/utils/config.ts","../src/utils/output.ts","../src/utils/credentials.ts","../src/utils/help.ts","../src/utils/oidc.ts","../src/utils/token-cache.ts","../src/utils/wallet.ts","../src/commands/auth.ts","../src/commands/config.ts","../src/module_bindings/types.ts","../src/module_bindings/add_task_dependency_reducer.ts","../src/module_bindings/claim_task_reducer.ts","../src/module_bindings/create_project_reducer.ts","../src/module_bindings/create_task_reducer.ts","../src/module_bindings/discover_task_reducer.ts","../src/module_bindings/fail_voice_announcement_reducer.ts","../src/module_bindings/finalize_voice_announcement_reducer.ts","../src/module_bindings/heartbeat_reducer.ts","../src/module_bindings/mark_idea_implemented_reducer.ts","../src/module_bindings/propose_idea_reducer.ts","../src/module_bindings/register_agent_reducer.ts","../src/module_bindings/review_discovered_task_reducer.ts","../src/module_bindings/seed_ui_data_reducer.ts","../src/module_bindings/seed_voice_announcements_reducer.ts","../src/module_bindings/send_message_reducer.ts","../src/module_bindings/send_project_message_reducer.ts","../src/module_bindings/set_agent_status_reducer.ts","../src/module_bindings/update_agent_bio_reducer.ts","../src/module_bindings/update_agent_capabilities_reducer.ts","../src/module_bindings/update_project_status_reducer.ts","../src/module_bindings/update_task_status_reducer.ts","../src/module_bindings/vote_idea_reducer.ts","../src/module_bindings/generate_voice_procedure.ts","../src/module_bindings/agents_table.ts","../src/module_bindings/channels_table.ts","../src/module_bindings/config_table.ts","../src/module_bindings/discovered_tasks_table.ts","../src/module_bindings/evaluation_dimensions_table.ts","../src/module_bindings/ideas_table.ts","../src/module_bindings/identity_roles_table.ts","../src/module_bindings/messages_table.ts","../src/module_bindings/project_channels_table.ts","../src/module_bindings/project_messages_table.ts","../src/module_bindings/projects_table.ts","../src/module_bindings/task_dependencies_table.ts","../src/module_bindings/tasks_table.ts","../src/module_bindings/voice_announcements_table.ts","../src/module_bindings/votes_table.ts","../src/module_bindings/index.ts","../src/utils/context.ts","../src/utils/toon.ts","../src/commands/doctor.ts","../src/utils/enums.ts","../src/utils/time.ts","../src/commands/nexus/agent-handlers.ts","../src/commands/nexus/agent.ts","../src/commands/nexus/discover.ts","../src/commands/nexus/idea.ts","../src/commands/nexus/message-handlers.ts","../src/commands/nexus/message.ts","../src/commands/nexus/project.ts","../src/commands/nexus/task-handlers.ts","../src/commands/nexus/task.ts","../src/commands/nexus-daemon.ts","../src/generated/decoders.ts","../src/utils/sql.ts","../src/commands/query.ts","../src/commands/sign.ts","../src/commands/token.ts","../src/utils/upgrade.ts","../src/commands/upgrade.ts","../src/commands/wallet/create.ts","../src/commands/wallet/default.ts","../src/commands/wallet/delete.ts","../src/commands/wallet/import.ts","../src/commands/wallet/list.ts","../src/commands/wallet/show.ts","../src/commands/wallet/index.ts","../src/commands/whoami.ts","../src/index.ts"],"sourcesContent":["export interface NexusConfig {\n\tissuer: string;\n\twalletDir: string;\n\tdefaultWallet?: string;\n\tpasswordMinLength: number;\n\ttokenCacheDir: string;\n\trequestTimeout: number;\n\tspacetime: {\n\t\thost: string;\n\t\tmodule: string;\n\t};\n}\n\nexport const DEFAULT_CONFIG: NexusConfig = {\n\tissuer: \"https://api.zenon.red\",\n\twalletDir: \"~/.probe/wallets\",\n\tpasswordMinLength: 8,\n\ttokenCacheDir: \"~/.probe/tokens\",\n\trequestTimeout: 30000,\n\tspacetime: {\n\t\thost: \"wss://db.zenon.red\",\n\t\tmodule: \"nexus\",\n\t},\n};\n\nexport interface WalletInfo {\n\tname: string;\n\taddress: string;\n\tpublicKey?: string;\n\tcreatedAt?: string;\n}\n\nexport interface WalletCreationResult {\n\tname: string;\n\taddress: string;\n\tpublicKey: string;\n\tmnemonic: string;\n}\n\nexport interface ChallengeResponse {\n\tnonce: string;\n\tchallenge: string;\n\texpiresAt: string;\n}\n\nexport interface TokenResponse {\n\taccessToken: string;\n\tidToken: string;\n\texpiresIn: number;\n}\n\nexport interface OutputResult<T> {\n\tsuccess: boolean;\n\tdata?: T;\n\terror?: { code: string; message: string; suggestion?: string };\n}\n","import { access, mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport type { NexusConfig } from \"~/types/index.js\";\n\nconst CONFIG_PATH = join(homedir(), \".probe\", \"config.json\");\nconst CONFIG_DIR = join(homedir(), \".probe\");\n\nexport async function loadUserConfig(): Promise<Partial<NexusConfig>> {\n\ttry {\n\t\tawait access(CONFIG_PATH);\n\t\tconst content = await readFile(CONFIG_PATH, \"utf-8\");\n\t\treturn JSON.parse(content) as Partial<NexusConfig>;\n\t} catch {\n\t\treturn {};\n\t}\n}\n\nexport async function saveUserConfig(\n\tconfig: Partial<NexusConfig>,\n): Promise<void> {\n\tawait mkdir(CONFIG_DIR, { recursive: true });\n\tawait writeFile(CONFIG_PATH, JSON.stringify(config, null, 2), {\n\t\tmode: 0o600,\n\t});\n}\n","import { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { loadConfig } from \"c12\";\nimport { DEFAULT_CONFIG, type NexusConfig } from \"~/types/index.js\";\nimport { loadUserConfig } from \"./user-config.js\";\n\nlet cachedConfig: NexusConfig | null = null;\n\nexport async function getConfig(): Promise<NexusConfig> {\n\tif (cachedConfig) {\n\t\treturn cachedConfig;\n\t}\n\n\tconst [c12Config, userConfig] = await Promise.all([\n\t\tloadConfig<NexusConfig>({\n\t\t\tname: \"probe\",\n\t\t\tdefaults: DEFAULT_CONFIG,\n\t\t\tenvName: \"PROBE\",\n\t\t}),\n\t\tloadUserConfig(),\n\t]);\n\n\tcachedConfig = {\n\t\t...DEFAULT_CONFIG,\n\t\t...c12Config.config,\n\t\t...userConfig,\n\t};\n\n\tcachedConfig.walletDir = expandHomeDir(cachedConfig.walletDir);\n\tcachedConfig.tokenCacheDir = expandHomeDir(cachedConfig.tokenCacheDir);\n\n\treturn cachedConfig;\n}\n\nexport function clearConfigCache(): void {\n\tcachedConfig = null;\n}\n\nexport function expandHomeDir(path: string): string {\n\tif (path.startsWith(\"~/\")) {\n\t\treturn join(homedir(), path.slice(2));\n\t}\n\treturn path;\n}\n\nexport async function getWalletDir(): Promise<string> {\n\tconst config = await getConfig();\n\treturn config.walletDir;\n}\n\nexport async function getTokenCacheDir(): Promise<string> {\n\tconst config = await getConfig();\n\treturn config.tokenCacheDir;\n}\n","import { AsyncLocalStorage } from \"node:async_hooks\";\nimport { spinner as clackSpinner, log } from \"@clack/prompts\";\nimport { dim } from \"kolorist\";\nimport type { OutputResult } from \"~/types/index.js\";\n\nconst outputModeStorage = new AsyncLocalStorage<{ jsonMode: boolean }>();\n\nconst jsonReplacer = (_key: string, value: unknown): unknown => {\n\tif (typeof value === \"bigint\") {\n\t\treturn value.toString();\n\t}\n\treturn value;\n};\n\nconst printJson = (value: unknown, stderr = false): void => {\n\tconst serialized = JSON.stringify(value, jsonReplacer, 2);\n\tif (stderr) {\n\t\tconsole.error(serialized);\n\t\treturn;\n\t}\n\tconsole.log(serialized);\n};\n\nexport function setJsonMode(enabled: boolean) {\n\toutputModeStorage.enterWith({ jsonMode: enabled });\n}\n\nexport function isJsonMode(): boolean {\n\treturn outputModeStorage.getStore()?.jsonMode === true;\n}\n\nexport function success<T>(data: T): void {\n\tif (isJsonMode()) {\n\t\tprintJson({ success: true, data });\n\t}\n}\n\nexport function error(\n\tcode: string,\n\tmessage: string,\n\tsuggestion?: string,\n\texitCode = 1,\n): never {\n\tif (isJsonMode()) {\n\t\tconst output: OutputResult<never> = {\n\t\t\tsuccess: false,\n\t\t\terror: {\n\t\t\t\tcode,\n\t\t\t\tmessage,\n\t\t\t\t...(suggestion && { suggestion }),\n\t\t\t},\n\t\t};\n\t\tprintJson(output, true);\n\t\tprocess.exit(exitCode);\n\t} else {\n\t\tlog.error(message);\n\t\tif (suggestion) {\n\t\t\tconsole.error(`${dim(\"hint:\")} ${suggestion}`);\n\t\t}\n\t\tprocess.exit(exitCode);\n\t}\n}\n\nexport function info(message: string): void {\n\tif (!isJsonMode()) {\n\t\tlog.info(message);\n\t}\n}\n\nexport function successMessage(message: string): void {\n\tif (!isJsonMode()) {\n\t\tlog.success(message);\n\t}\n}\n\nexport function warning(message: string): void {\n\tif (!isJsonMode()) {\n\t\tlog.warn(message);\n\t}\n}\n\nexport function spinner(message: string) {\n\tif (isJsonMode()) {\n\t\treturn {\n\t\t\tstart: () => {},\n\t\t\tstop: () => {},\n\t\t\tsucceed: () => {},\n\t\t\tfail: () => {},\n\t\t};\n\t}\n\n\tconst clack = clackSpinner();\n\n\tconst start = () => {\n\t\tclack.start(message);\n\t};\n\n\tconst stop = () => {\n\t\tclack.stop();\n\t};\n\n\tconst succeed = (msg?: string) => {\n\t\tclack.stop(msg || message);\n\t};\n\n\tconst fail = (msg?: string) => {\n\t\tclack.stop(msg || message);\n\t};\n\n\treturn {\n\t\tstart,\n\t\tstop,\n\t\tsucceed,\n\t\tfail,\n\t};\n}\n","import { readFile } from \"node:fs/promises\";\nimport { password, text } from \"@clack/prompts\";\nimport { error, isJsonMode } from \"./output.js\";\n\nconst readTrimmedFile = async (\n\tfilePath: string,\n\tlabel: string,\n): Promise<string> => {\n\ttry {\n\t\treturn (await readFile(filePath, \"utf-8\")).trim();\n\t} catch {\n\t\terror(\"FILE_READ_ERROR\", `Failed to read ${label} file: ${filePath}`);\n\t}\n};\n\nexport interface ResolvePasswordInput {\n\tpasswordFile?: string;\n\tenvVar?: string;\n\tpromptMessage: string;\n\tjsonModeError: string;\n\tminLength?: number;\n\tconfirmPromptMessage?: string;\n}\n\nexport const resolvePasswordInput = async (\n\toptions: ResolvePasswordInput,\n): Promise<string> => {\n\tif (options.passwordFile) {\n\t\treturn readTrimmedFile(options.passwordFile, \"password\");\n\t}\n\n\tconst envVar = options.envVar || \"PROBE_WALLET_PASSWORD\";\n\tconst fromEnv = process.env[envVar];\n\tif (fromEnv) {\n\t\treturn fromEnv;\n\t}\n\n\tif (isJsonMode() || !process.stdin.isTTY || !process.stdout.isTTY) {\n\t\terror(\"PASSWORD_REQUIRED\", options.jsonModeError);\n\t}\n\n\tconst first = await password({\n\t\tmessage: options.promptMessage,\n\t\tvalidate: (value) => {\n\t\t\tif (!value) return;\n\t\t\tif (options.minLength && value.length < options.minLength) {\n\t\t\t\treturn `Password must be at least ${options.minLength} characters`;\n\t\t\t}\n\t\t},\n\t});\n\n\tif (typeof first !== \"string\") {\n\t\tprocess.exit(130);\n\t}\n\n\tif (!options.confirmPromptMessage) {\n\t\treturn first;\n\t}\n\n\tconst second = await password({\n\t\tmessage: options.confirmPromptMessage,\n\t\tvalidate: (value) =>\n\t\t\tvalue === first ? undefined : \"Passwords do not match\",\n\t});\n\tif (typeof second !== \"string\") {\n\t\tprocess.exit(130);\n\t}\n\n\treturn first;\n};\n\nexport interface ResolveMnemonicInput {\n\tmnemonic?: string;\n\tmnemonicFile?: string;\n\tenvVar?: string;\n\tjsonModeError: string;\n}\n\nexport const resolveMnemonicInput = async (\n\toptions: ResolveMnemonicInput,\n): Promise<string> => {\n\tif (options.mnemonic) {\n\t\treturn options.mnemonic;\n\t}\n\n\tif (options.mnemonicFile) {\n\t\treturn readTrimmedFile(options.mnemonicFile, \"mnemonic\");\n\t}\n\n\tconst envVar = options.envVar || \"PROBE_WALLET_MNEMONIC\";\n\tconst fromEnv = process.env[envVar];\n\tif (fromEnv) {\n\t\treturn fromEnv;\n\t}\n\n\tif (isJsonMode() || !process.stdin.isTTY || !process.stdout.isTTY) {\n\t\terror(\"MNEMONIC_REQUIRED\", options.jsonModeError);\n\t}\n\n\tconst input = await text({\n\t\tmessage: \"Enter mnemonic phrase:\",\n\t\tvalidate: (value) =>\n\t\t\t!value ? \"Mnemonic must be 24 words\"\n\t\t\t: value.trim().split(/\\s+/).length === 24\n\t\t\t\t? undefined\n\t\t\t\t: \"Mnemonic must be 24 words\",\n\t});\n\tif (typeof input !== \"string\") {\n\t\tprocess.exit(130);\n\t}\n\treturn input;\n};\n","import { blue, bold, cyan, dim, gray, green, white } from \"kolorist\";\n\ninterface HelpSectionItem {\n\tname: string;\n\tdetail: string;\n}\n\ninterface HelpSpec {\n\tcommand: string;\n\tdescription: string;\n\tusage: string[];\n\tactions?: HelpSectionItem[];\n\toptions?: HelpSectionItem[];\n\texamples?: string[];\n\tnotes?: string[];\n}\n\nconst actionHelpCommands = new Set([\n\t\"agent\",\n\t\"task\",\n\t\"message\",\n\t\"idea\",\n\t\"discover\",\n\t\"project\",\n\t\"config\",\n]);\nconst directHelpCommands = new Set([\n\t\"wallet\",\n\t\"auth\",\n\t\"sign\",\n\t\"token\",\n\t\"nexus\",\n\t\"query\",\n\t\"doctor\",\n\t\"upgrade\",\n]);\nconst walletSubcommands = new Set([\n\t\"create\",\n\t\"import\",\n\t\"list\",\n\t\"show\",\n\t\"delete\",\n\t\"default\",\n]);\n\nlet forceHelpFlag = false;\n\nconst neonBadge = (text: string): string =>\n\t`\\u001b[48;2;120;239;93m\\u001b[38;2;12;28;16m ${text} \\u001b[0m`;\nconst section = (label: string): string => neonBadge(label.toUpperCase());\n\nconst renderItems = (\n\titems: HelpSectionItem[],\n\tnameColor: (value: string) => string,\n): string => {\n\tconst width = Math.max(...items.map((i) => i.name.length), 0);\n\treturn items\n\t\t.map((i) => ` ${nameColor(i.name.padEnd(width))} ${i.detail}`)\n\t\t.join(\"\\n\");\n};\n\nexport const printHelp = (spec: HelpSpec): void => {\n\tconst notes = [...(spec.notes || [])];\n\tconst hasHostModuleOption = (spec.options || []).some(\n\t\t(item) => item.name.includes(\"--host\") && item.name.includes(\"--module\"),\n\t);\n\tconst hasHostModuleNote = notes.some(\n\t\t(note) => note.includes(\"--host\") && note.includes(\"--module\"),\n\t);\n\tif (hasHostModuleOption && !hasHostModuleNote) {\n\t\tnotes.push(\n\t\t\t\"--host sets the SpacetimeDB server endpoint; --module sets the target module/database name (default: nexus).\",\n\t\t);\n\t}\n\n\tconst lines: string[] = [];\n\tlines.push(\n\t\t`${bold(white(spec.command))} ${dim(\"•\")} ${gray(spec.description)}`,\n\t);\n\n\tlines.push(\"\");\n\tlines.push(section(\"Usage\"));\n\tfor (const entry of spec.usage) {\n\t\tlines.push(` ${white(entry)}`);\n\t}\n\n\tif (spec.actions && spec.actions.length > 0) {\n\t\tlines.push(\"\");\n\t\tlines.push(section(\"Actions\"));\n\t\tlines.push(renderItems(spec.actions, green));\n\t}\n\n\tif (spec.options && spec.options.length > 0) {\n\t\tlines.push(\"\");\n\t\tlines.push(section(\"Options\"));\n\t\tlines.push(renderItems(spec.options, blue));\n\t}\n\n\tif (spec.examples && spec.examples.length > 0) {\n\t\tlines.push(\"\");\n\t\tlines.push(section(\"Examples\"));\n\t\tfor (const example of spec.examples) {\n\t\t\tlines.push(` ${cyan(example)}`);\n\t\t}\n\t}\n\n\tif (notes.length > 0) {\n\t\tlines.push(\"\");\n\t\tlines.push(section(\"Notes\"));\n\t\tfor (const note of notes) {\n\t\t\tlines.push(` ${dim(\"-\")} ${note}`);\n\t\t}\n\t}\n\n\tconsole.log(lines.join(\"\\n\"));\n};\n\nexport const setForceHelpRequested = (enabled: boolean): void => {\n\tforceHelpFlag = enabled;\n};\n\nexport const forceHelpRequested = (): boolean => forceHelpFlag;\n\nexport const normalizeHelpArgv = (\n\targv: string[],\n): { argv: string[]; forceHelp: boolean } => {\n\tconst hasHelp = argv.includes(\"--help\") || argv.includes(\"-h\");\n\tif (!hasHelp) {\n\t\treturn { argv, forceHelp: false };\n\t}\n\n\tif (argv.every((arg) => arg.startsWith(\"-\"))) {\n\t\treturn { argv: [], forceHelp: true };\n\t}\n\n\tconst command = argv.find((arg) => !arg.startsWith(\"-\"));\n\tif (!command) {\n\t\treturn { argv, forceHelp: true };\n\t}\n\n\tif (actionHelpCommands.has(command)) {\n\t\treturn { argv: [command], forceHelp: true };\n\t}\n\n\tif (!directHelpCommands.has(command)) {\n\t\treturn { argv, forceHelp: true };\n\t}\n\n\tif (command === \"wallet\") {\n\t\tconst positionals = argv.filter((arg) => !arg.startsWith(\"-\"));\n\t\tif (positionals.length > 1 && walletSubcommands.has(positionals[1])) {\n\t\t\treturn { argv: [command, positionals[1]], forceHelp: true };\n\t\t}\n\t}\n\n\treturn { argv: [command], forceHelp: true };\n};\n","import type { ChallengeResponse, TokenResponse } from \"~/types/index.js\";\nimport { getConfig } from \"./config.js\";\n\nexport async function requestChallenge(\n\taddress: string,\n\tissuerOverride?: string,\n): Promise<ChallengeResponse> {\n\tconst config = await getConfig();\n\tconst issuer = issuerOverride || config.issuer;\n\tconst url = `${issuer}/auth/challenge`;\n\n\tconst response = await fetch(url, {\n\t\tmethod: \"POST\",\n\t\theaders: {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t},\n\t\tbody: JSON.stringify({ address }),\n\t});\n\n\tif (!response.ok) {\n\t\tconst error = await response.text();\n\t\tthrow new Error(`Challenge request failed: ${error}`);\n\t}\n\n\tconst data = await response.json();\n\treturn {\n\t\tnonce: data.nonce,\n\t\tchallenge: data.challenge,\n\t\texpiresAt: data.expires_at,\n\t};\n}\n\nexport async function exchangeToken(\n\taddress: string,\n\tpublicKey: string,\n\tsignature: string,\n\tnonce: string,\n\tissuerOverride?: string,\n): Promise<TokenResponse> {\n\tconst config = await getConfig();\n\tconst issuer = issuerOverride || config.issuer;\n\tconst url = `${issuer}/auth/token`;\n\n\tconst response = await fetch(url, {\n\t\tmethod: \"POST\",\n\t\theaders: {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t},\n\t\tbody: JSON.stringify({\n\t\t\taddress,\n\t\t\tpublic_key: publicKey,\n\t\t\tsignature,\n\t\t\tnonce,\n\t\t}),\n\t});\n\n\tif (!response.ok) {\n\t\tconst error = await response.text();\n\t\tthrow new Error(`Token exchange failed: ${error}`);\n\t}\n\n\tconst data = await response.json();\n\treturn {\n\t\taccessToken: data.access_token,\n\t\tidToken: data.id_token,\n\t\texpiresIn: data.expires_in,\n\t};\n}\n","import { access, mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { getTokenCacheDir } from \"./config.js\";\n\nexport async function cacheToken(\n\twallet: string,\n\ttoken: string,\n\texpiresAt: string,\n): Promise<void> {\n\tconst cacheDir = await getTokenCacheDir();\n\n\ttry {\n\t\tawait mkdir(cacheDir, { recursive: true });\n\t} catch {}\n\n\tconst cachePath = join(cacheDir, `${wallet}.jwt`);\n\tconst data = {\n\t\ttoken,\n\t\texpiresAt,\n\t};\n\n\tawait writeFile(cachePath, JSON.stringify(data), { mode: 0o600 });\n}\n\nexport async function getCachedToken(\n\twallet: string,\n): Promise<{ token: string; expiresAt: string } | null> {\n\tconst cacheDir = await getTokenCacheDir();\n\tconst cachePath = join(cacheDir, `${wallet}.jwt`);\n\n\ttry {\n\t\tawait access(cachePath);\n\t\tconst content = await readFile(cachePath, \"utf-8\");\n\t\treturn JSON.parse(content);\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport async function clearCachedToken(wallet: string): Promise<void> {\n\tconst cacheDir = await getTokenCacheDir();\n\tconst cachePath = join(cacheDir, `${wallet}.jwt`);\n\n\ttry {\n\t\tawait access(cachePath);\n\t\tconst { unlink } = await import(\"node:fs/promises\");\n\t\tawait unlink(cachePath);\n\t} catch {}\n}\n","import {\n\taccess,\n\tmkdir,\n\treaddir,\n\treadFile,\n\tunlink,\n\twriteFile,\n} from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { KeyFile, KeyStore } from \"znn-typescript-sdk\";\nimport type { WalletCreationResult, WalletInfo } from \"~/types/index.js\";\nimport { getWalletDir } from \"./config.js\";\n\nasync function ensureWalletDir(): Promise<string> {\n\tconst walletDir = await getWalletDir();\n\ttry {\n\t\tawait mkdir(walletDir, { recursive: true });\n\t} catch {}\n\treturn walletDir;\n}\n\nasync function getWalletFilePath(name: string): Promise<string> {\n\tconst walletDir = await ensureWalletDir();\n\treturn join(walletDir, `${name}.json`);\n}\n\nexport async function createWallet(\n\tname: string,\n\tpassword: string,\n): Promise<WalletCreationResult> {\n\tconst exists = await walletExists(name);\n\tif (exists) {\n\t\tthrow new Error(`Wallet '${name}' already exists`);\n\t}\n\n\tconst keyStore = KeyStore.newRandom();\n\tconst keyFile = KeyFile.setPassword(password);\n\tconst encryptedData = await keyFile.encrypt(keyStore);\n\n\tconst walletPath = await getWalletFilePath(name);\n\tawait writeFile(walletPath, JSON.stringify(encryptedData, null, 2), \"utf-8\");\n\n\tconst keyPair = keyStore.getKeyPair(0);\n\tconst address = keyPair.getAddress();\n\tconst publicKey = keyPair.getPublicKey();\n\n\treturn {\n\t\tname,\n\t\taddress: address.toString(),\n\t\tpublicKey: publicKey.toString(\"hex\"),\n\t\tmnemonic: keyStore.mnemonic || \"\",\n\t};\n}\n\nexport async function importWallet(\n\tname: string,\n\tmnemonic: string,\n\tpassword: string,\n): Promise<WalletInfo> {\n\tconst exists = await walletExists(name);\n\tif (exists) {\n\t\tthrow new Error(`Wallet '${name}' already exists`);\n\t}\n\n\tconst keyStore = KeyStore.fromMnemonic(mnemonic);\n\tconst keyFile = KeyFile.setPassword(password);\n\tconst encryptedData = await keyFile.encrypt(keyStore);\n\n\tconst walletPath = await getWalletFilePath(name);\n\tawait writeFile(walletPath, JSON.stringify(encryptedData, null, 2), \"utf-8\");\n\n\tconst keyPair = keyStore.getKeyPair(0);\n\tconst address = keyPair.getAddress();\n\n\treturn {\n\t\tname,\n\t\taddress: address.toString(),\n\t};\n}\n\nexport async function listWallets(): Promise<WalletInfo[]> {\n\tconst walletDir = await getWalletDir();\n\n\ttry {\n\t\tconst files = await readdir(walletDir);\n\t\tconst wallets: WalletInfo[] = [];\n\n\t\tfor (const file of files) {\n\t\t\tif (file.endsWith(\".json\")) {\n\t\t\t\tconst name = file.slice(0, -5);\n\t\t\t\tconst info = await getWalletInfo(name);\n\t\t\t\tif (info) {\n\t\t\t\t\twallets.push(info);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn wallets;\n\t} catch {\n\t\treturn [];\n\t}\n}\n\nexport async function getWalletInfo(name: string): Promise<WalletInfo | null> {\n\tconst walletPath = await getWalletFilePath(name);\n\n\ttry {\n\t\tconst content = await readFile(walletPath, \"utf-8\");\n\t\tconst data = JSON.parse(content);\n\t\tconst stats = await stat(walletPath);\n\n\t\treturn {\n\t\t\tname,\n\t\t\taddress: data.address || data.baseAddress,\n\t\t\tcreatedAt: data.timestamp\n\t\t\t\t? new Date(data.timestamp * 1000).toISOString()\n\t\t\t\t: new Date(stats.mtime).toISOString(),\n\t\t};\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport async function loadWallet(\n\tname: string,\n\tpassword: string,\n): Promise<KeyStore> {\n\tconst walletPath = await getWalletFilePath(name);\n\n\ttry {\n\t\tconst content = await readFile(walletPath, \"utf-8\");\n\t\tconst encryptedData = JSON.parse(content);\n\n\t\tconst keyFile = KeyFile.setPassword(password);\n\t\tconst keyStore = await keyFile.decrypt(encryptedData);\n\n\t\treturn keyStore;\n\t} catch (err) {\n\t\tthrow new Error(\n\t\t\t`Failed to load wallet: ${err instanceof Error ? err.message : \"Unknown error\"}`,\n\t\t);\n\t}\n}\n\nexport async function deleteWallet(name: string): Promise<void> {\n\tconst walletPath = await getWalletFilePath(name);\n\n\ttry {\n\t\tawait unlink(walletPath);\n\t} catch (err) {\n\t\tthrow new Error(\n\t\t\t`Failed to delete wallet: ${err instanceof Error ? err.message : \"Unknown error\"}`,\n\t\t);\n\t}\n}\n\nexport async function walletExists(name: string): Promise<boolean> {\n\tconst walletPath = await getWalletFilePath(name);\n\n\ttry {\n\t\tawait access(walletPath);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nasync function stat(path: string) {\n\tconst { stat } = await import(\"node:fs/promises\");\n\treturn stat(path);\n}\n","import { Buffer } from \"node:buffer\";\nimport { defineCommand } from \"citty\";\nimport type { KeyPair } from \"znn-typescript-sdk\";\nimport { getConfig } from \"~/utils/config.js\";\nimport { resolvePasswordInput } from \"~/utils/credentials.js\";\nimport { printHelp } from \"~/utils/help.js\";\nimport { exchangeToken, requestChallenge } from \"~/utils/oidc.js\";\nimport {\n\terror,\n\tisJsonMode,\n\tsetJsonMode,\n\tspinner,\n\tsuccess,\n\tsuccessMessage,\n} from \"~/utils/output.js\";\nimport { cacheToken, getCachedToken } from \"~/utils/token-cache.js\";\nimport { loadWallet } from \"~/utils/wallet.js\";\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"auth\",\n\t\tdescription: \"Complete OIDC authentication flow\",\n\t},\n\targs: {\n\t\tname: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Wallet name, or status action\",\n\t\t\trequired: false,\n\t\t},\n\t\twallet: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Wallet name override (used with auth status)\",\n\t\t},\n\t\t\"expect-address\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Expected Zenon address safety check (z1...)\",\n\t\t},\n\t\tissuer: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"OIDC issuer URL override\",\n\t\t},\n\t\t\"password-file\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Read password from file\",\n\t\t},\n\t\tsave: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Save token to cache (default: true)\",\n\t\t\tdefault: true,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) {\n\t\t\tsetJsonMode(true);\n\t\t}\n\n\t\tconst name = args.name;\n\t\tconst requestedAddress = args[\"expect-address\"];\n\n\t\tif (!name) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe auth\",\n\t\t\t\tdescription: \"Complete OIDC authentication flow\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe auth <wallet-name> [options]\",\n\t\t\t\t\t\"probe auth status [--wallet my-wallet]\",\n\t\t\t\t\t\"probe auth my-wallet --save\",\n\t\t\t\t\t\"probe auth my-wallet --expect-address z1q... --save\",\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--expect-address\",\n\t\t\t\t\t\tdetail: \"Optional safety check against resolved wallet address\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"--wallet\", detail: \"Wallet override for `auth status`\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--issuer\",\n\t\t\t\t\t\tdetail: \"OIDC issuer URL (default from config: issuer)\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"--password-file\", detail: \"Read wallet password from file\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--save\",\n\t\t\t\t\t\tdetail: \"Save token in local cache (default: true)\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"--json\", detail: \"JSON output for agents\" },\n\t\t\t\t],\n\t\t\t\tnotes: [\n\t\t\t\t\t\"Password source order: --password-file, PROBE_WALLET_PASSWORD, interactive prompt.\",\n\t\t\t\t\t\"Most users should omit --expect-address; it is for safety checks in external workflows.\",\n\t\t\t\t\t\"Use --issuer only when authenticating against a non-default OIDC server (for example local/dev environments).\",\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tif (name === \"status\") {\n\t\t\tconst config = await getConfig();\n\t\t\tconst walletName = args.wallet || config.defaultWallet;\n\t\t\tif (!walletName) {\n\t\t\t\terror(\n\t\t\t\t\t\"WALLET_REQUIRED\",\n\t\t\t\t\t\"Wallet required. Use --wallet or set default wallet.\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst cached = await getCachedToken(walletName);\n\t\t\tif (!cached) {\n\t\t\t\tsuccess({\n\t\t\t\t\twallet: walletName,\n\t\t\t\t\tauthenticated: false,\n\t\t\t\t\tvalid: false,\n\t\t\t\t\treason: \"no_cached_token\",\n\t\t\t\t});\n\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\tconsole.log(`Wallet: ${walletName}`);\n\t\t\t\t\tconsole.log(\"Status: Not authenticated (no cached token)\");\n\t\t\t\t\tconsole.log(`Next: probe auth ${walletName} --save`);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst expiresAt = new Date(cached.expiresAt);\n\t\t\tconst expiresIn = Math.floor((expiresAt.getTime() - Date.now()) / 1000);\n\t\t\tconst valid = Number.isFinite(expiresIn) && expiresIn > 0;\n\t\t\tsuccess({\n\t\t\t\twallet: walletName,\n\t\t\t\tauthenticated: true,\n\t\t\t\tvalid,\n\t\t\t\texpiresAt: cached.expiresAt,\n\t\t\t\texpiresIn: Math.max(0, expiresIn),\n\t\t\t});\n\t\t\tif (!isJsonMode()) {\n\t\t\t\tconsole.log(`Wallet: ${walletName}`);\n\t\t\t\tconsole.log(`Status: ${valid ? \"Authenticated\" : \"Token expired\"}`);\n\t\t\t\tconsole.log(`Expires: ${expiresAt.toUTCString()}`);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst walletPassword = await resolvePasswordInput({\n\t\t\tpasswordFile: args[\"password-file\"],\n\t\t\tpromptMessage: \"Enter wallet password:\",\n\t\t\tjsonModeError:\n\t\t\t\t\"Password required via PROBE_WALLET_PASSWORD env, --password-file, or interactive prompt in a TTY session\",\n\t\t});\n\n\t\tlet keyPair: KeyPair | undefined;\n\t\tlet walletAddress: string;\n\t\tlet address: string;\n\t\ttry {\n\t\t\tconst keyStore = await loadWallet(name, walletPassword);\n\t\t\tkeyPair = keyStore.getKeyPair(0);\n\t\t\tconst addr = keyPair.getAddress();\n\t\t\twalletAddress = addr.toString();\n\n\t\t\tif (requestedAddress && walletAddress !== requestedAddress) {\n\t\t\t\terror(\n\t\t\t\t\t\"ADDRESS_MISMATCH\",\n\t\t\t\t\t`Wallet address ${walletAddress} does not match provided address ${requestedAddress}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\taddress = requestedAddress || walletAddress;\n\t\t} catch (err) {\n\t\t\terror(\n\t\t\t\t\"WALLET_LOAD_ERROR\",\n\t\t\t\terr instanceof Error ? err.message : \"Failed to load wallet\",\n\t\t\t);\n\t\t}\n\n\t\ttry {\n\t\t\tconst challengeSpinner = spinner(\n\t\t\t\t\"Requesting challenge from OIDC provider...\",\n\t\t\t);\n\t\t\tchallengeSpinner.start();\n\n\t\t\tconst challenge = await requestChallenge(address, args.issuer);\n\t\t\tchallengeSpinner.succeed();\n\n\t\t\tconst signSpinner = spinner(\"Signing challenge...\");\n\t\t\tsignSpinner.start();\n\n\t\t\tconst signature = keyPair.sign(Buffer.from(challenge.challenge));\n\t\t\tconst publicKey = keyPair.getPublicKey();\n\t\t\tsignSpinner.succeed();\n\n\t\t\tconst exchangeSpinner = spinner(\"Exchanging for token...\");\n\t\t\texchangeSpinner.start();\n\n\t\t\tconst tokenResponse = await exchangeToken(\n\t\t\t\taddress,\n\t\t\t\tpublicKey.toString(\"hex\"),\n\t\t\t\tsignature.toString(\"hex\"),\n\t\t\t\tchallenge.nonce,\n\t\t\t\targs.issuer,\n\t\t\t);\n\t\t\texchangeSpinner.succeed();\n\n\t\t\tconst expiresAt = new Date(\n\t\t\t\tDate.now() + tokenResponse.expiresIn * 1000,\n\t\t\t).toISOString();\n\n\t\t\tif (args.save) {\n\t\t\t\tawait cacheToken(name, tokenResponse.accessToken, expiresAt);\n\t\t\t}\n\n\t\t\tsuccess({\n\t\t\t\twallet: name,\n\t\t\t\taddress,\n\t\t\t\ttoken: tokenResponse.accessToken,\n\t\t\t\texpiresAt,\n\t\t\t\texpiresIn: tokenResponse.expiresIn,\n\t\t\t});\n\n\t\t\tif (!isJsonMode()) {\n\t\t\t\tsuccessMessage(\"Authentication successful\");\n\t\t\t\tif (args.save) {\n\t\t\t\t\tconsole.log(\"Token saved to wallet cache.\");\n\t\t\t\t}\n\t\t\t\tconsole.log(\n\t\t\t\t\t`Expires: ${new Date(expiresAt).toUTCString()} (${Math.floor(tokenResponse.expiresIn / 86400)} days)`,\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\terror(\n\t\t\t\t\"AUTH_ERROR\",\n\t\t\t\terr instanceof Error ? err.message : \"Authentication failed\",\n\t\t\t\tundefined,\n\t\t\t\t2,\n\t\t\t);\n\t\t}\n\t},\n});\n","import { defineCommand } from \"citty\";\nimport { clearConfigCache, getConfig } from \"~/utils/config.js\";\nimport { printHelp } from \"~/utils/help.js\";\nimport {\n\terror,\n\tisJsonMode,\n\tsetJsonMode,\n\tsuccess,\n\tsuccessMessage,\n} from \"~/utils/output.js\";\nimport { loadUserConfig, saveUserConfig } from \"~/utils/user-config.js\";\n\nfunction getNestedValue(obj: Record<string, unknown>, path: string): unknown {\n\tconst parts = path.split(\".\");\n\tlet current: unknown = obj;\n\tfor (const part of parts) {\n\t\tif (current && typeof current === \"object\" && part in current) {\n\t\t\tcurrent = (current as Record<string, unknown>)[part];\n\t\t} else {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\treturn current;\n}\n\nfunction setNestedValue(\n\tobj: Record<string, unknown>,\n\tpath: string,\n\tvalue: unknown,\n): void {\n\tconst parts = path.split(\".\");\n\tlet current = obj;\n\tfor (let i = 0; i < parts.length - 1; i++) {\n\t\tconst part = parts[i];\n\t\tif (!(part in current) || typeof current[part] !== \"object\") {\n\t\t\tcurrent[part] = {};\n\t\t}\n\t\tcurrent = current[part] as Record<string, unknown>;\n\t}\n\tcurrent[parts[parts.length - 1]] = value;\n}\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"config\",\n\t\tdescription: \"Manage configuration settings\",\n\t},\n\targs: {\n\t\taction: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Action: get, set, list\",\n\t\t\trequired: false,\n\t\t},\n\t\tkey: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Configuration key\",\n\t\t\trequired: false,\n\t\t},\n\t\tvalue: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Configuration value\",\n\t\t\trequired: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) {\n\t\t\tsetJsonMode(true);\n\t\t}\n\n\t\tif (!args.action) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe config\",\n\t\t\t\tdescription: \"Read and write CLI configuration values\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe config <action> [key] [value]\",\n\t\t\t\t\t\"probe config get spacetime.host\",\n\t\t\t\t\t\"probe config set defaultWallet agent-wallet\",\n\t\t\t\t],\n\t\t\t\tactions: [\n\t\t\t\t\t{ name: \"get <key>\", detail: \"Get one config value\" },\n\t\t\t\t\t{ name: \"set <key> <value>\", detail: \"Set one config value\" },\n\t\t\t\t\t{ name: \"list\", detail: \"List merged config and user overrides\" },\n\t\t\t\t],\n\t\t\t\tnotes: [\n\t\t\t\t\t\"Valid keys: issuer, walletDir, defaultWallet, tokenCacheDir, requestTimeout, spacetime.host, spacetime.module.\",\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst action = args.action;\n\t\tconst validKeys = [\n\t\t\t\"issuer\",\n\t\t\t\"walletDir\",\n\t\t\t\"defaultWallet\",\n\t\t\t\"tokenCacheDir\",\n\t\t\t\"requestTimeout\",\n\t\t\t\"spacetime.host\",\n\t\t\t\"spacetime.module\",\n\t\t];\n\n\t\ttry {\n\t\t\tswitch (action) {\n\t\t\t\tcase \"get\": {\n\t\t\t\t\tif (!args.key) {\n\t\t\t\t\t\terror(\"KEY_REQUIRED\", \"Configuration key required\");\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!validKeys.includes(args.key)) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"INVALID_KEY\",\n\t\t\t\t\t\t\t`Invalid configuration key: ${args.key}`,\n\t\t\t\t\t\t\t`Valid keys: ${validKeys.join(\", \")}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst config = await getConfig();\n\t\t\t\t\tconst value = getNestedValue(\n\t\t\t\t\t\tconfig as unknown as Record<string, unknown>,\n\t\t\t\t\t\targs.key,\n\t\t\t\t\t);\n\n\t\t\t\t\tsuccess({ [args.key]: value });\n\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(`${args.key}: ${value}`);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"set\": {\n\t\t\t\t\tif (!args.key || args.value === undefined) {\n\t\t\t\t\t\terror(\"ARGS_REQUIRED\", \"Configuration key and value required\");\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!validKeys.includes(args.key)) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"INVALID_KEY\",\n\t\t\t\t\t\t\t`Invalid configuration key: ${args.key}`,\n\t\t\t\t\t\t\t`Valid keys: ${validKeys.join(\", \")}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tlet parsedValue: string | boolean | number = args.value;\n\n\t\t\t\t\tif (args.key === \"requestTimeout\") {\n\t\t\t\t\t\tparsedValue = parseInt(args.value, 10);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst userConfig = await loadUserConfig();\n\t\t\t\t\tsetNestedValue(\n\t\t\t\t\t\tuserConfig as unknown as Record<string, unknown>,\n\t\t\t\t\t\targs.key,\n\t\t\t\t\t\tparsedValue,\n\t\t\t\t\t);\n\t\t\t\t\tawait saveUserConfig(userConfig);\n\t\t\t\t\tclearConfigCache();\n\n\t\t\t\t\tsuccess({ [args.key]: parsedValue });\n\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tsuccessMessage(`Set ${args.key} = ${parsedValue}`);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"list\": {\n\t\t\t\t\tconst config = await getConfig();\n\t\t\t\t\tconst userConfig = await loadUserConfig();\n\n\t\t\t\t\tsuccess({\n\t\t\t\t\t\t...config,\n\t\t\t\t\t\tuserConfig,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\"Configuration:\");\n\t\t\t\t\t\tconsole.log(` issuer: ${config.issuer}`);\n\t\t\t\t\t\tconsole.log(` walletDir: ${config.walletDir}`);\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t` defaultWallet: ${config.defaultWallet || \"(not set)\"}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.log(` passwordMinLength: ${config.passwordMinLength}`);\n\t\t\t\t\t\tconsole.log(` tokenCacheDir: ${config.tokenCacheDir}`);\n\t\t\t\t\t\tconsole.log(` requestTimeout: ${config.requestTimeout}`);\n\t\t\t\t\t\tconsole.log(` spacetime.host: ${config.spacetime.host}`);\n\t\t\t\t\t\tconsole.log(` spacetime.module: ${config.spacetime.module}`);\n\n\t\t\t\t\t\tif (Object.keys(userConfig).length > 0) {\n\t\t\t\t\t\t\tconsole.log(\"\\nUser overrides:\");\n\t\t\t\t\t\t\tfor (const [key, value] of Object.entries(userConfig)) {\n\t\t\t\t\t\t\t\tconsole.log(` ${key}: ${JSON.stringify(value)}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault:\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"INVALID_ACTION\",\n\t\t\t\t\t\t`Invalid action: ${action}`,\n\t\t\t\t\t\t\"Use: get, set, list\",\n\t\t\t\t\t);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\terror(\n\t\t\t\t\"CONFIG_ERROR\",\n\t\t\t\terr instanceof Error ? err.message : \"Configuration error\",\n\t\t\t);\n\t\t}\n\t},\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport const Agent = __t.object(\"Agent\", {\n id: __t.string(),\n name: __t.string(),\n bio: __t.string(),\n get role() {\n return AgentRole;\n },\n capabilities: __t.array(__t.string()),\n get status() {\n return AgentStatus;\n },\n zenonAddress: __t.string(),\n identity: __t.identity(),\n lastHeartbeat: __t.timestamp(),\n currentTaskId: __t.option(__t.u64()),\n createdAt: __t.timestamp(),\n lastActiveAt: __t.timestamp(),\n});\nexport type Agent = __Infer<typeof Agent>;\n\n// The tagged union or sum type for the algebraic type `AgentRole`.\nexport const AgentRole = __t.enum(\"AgentRole\", {\n Zoe: __t.unit(),\n Admin: __t.unit(),\n Zeno: __t.unit(),\n});\nexport type AgentRole = __Infer<typeof AgentRole>;\n\n// The tagged union or sum type for the algebraic type `AgentStatus`.\nexport const AgentStatus = __t.enum(\"AgentStatus\", {\n Online: __t.unit(),\n Offline: __t.unit(),\n Working: __t.unit(),\n});\nexport type AgentStatus = __Infer<typeof AgentStatus>;\n\nexport const AgentVoiceCounter = __t.object(\"AgentVoiceCounter\", {\n agentId: __t.identity(),\n nextSeq: __t.u64(),\n});\nexport type AgentVoiceCounter = __Infer<typeof AgentVoiceCounter>;\n\n// The tagged union or sum type for the algebraic type `AnnouncementStatus`.\nexport const AnnouncementStatus = __t.enum(\"AnnouncementStatus\", {\n Pending: __t.unit(),\n Ready: __t.unit(),\n Failed: __t.unit(),\n});\nexport type AnnouncementStatus = __Infer<typeof AnnouncementStatus>;\n\nexport const Channel = __t.object(\"Channel\", {\n id: __t.u64(),\n name: __t.string(),\n createdBy: __t.string(),\n createdAt: __t.timestamp(),\n});\nexport type Channel = __Infer<typeof Channel>;\n\nexport const Config = __t.object(\"Config\", {\n key: __t.string(),\n value: __t.string(),\n});\nexport type Config = __Infer<typeof Config>;\n\n// The tagged union or sum type for the algebraic type `DependencyType`.\nexport const DependencyType = __t.enum(\"DependencyType\", {\n Blocks: __t.unit(),\n ParentChild: __t.unit(),\n});\nexport type DependencyType = __Infer<typeof DependencyType>;\n\nexport const DimensionScore = __t.object(\"DimensionScore\", {\n dimension: __t.string(),\n score: __t.u8(),\n});\nexport type DimensionScore = __Infer<typeof DimensionScore>;\n\nexport const DiscoveredTask = __t.object(\"DiscoveredTask\", {\n id: __t.u64(),\n discoveredBy: __t.string(),\n currentTaskId: __t.u64(),\n projectId: __t.u64(),\n title: __t.string(),\n description: __t.string(),\n priority: __t.u8(),\n taskType: __t.string(),\n severity: __t.string(),\n get status() {\n return DiscoveredTaskStatus;\n },\n createdTaskId: __t.option(__t.u64()),\n rejectionReason: __t.option(__t.string()),\n createdAt: __t.timestamp(),\n reviewedAt: __t.option(__t.timestamp()),\n reviewedBy: __t.option(__t.string()),\n});\nexport type DiscoveredTask = __Infer<typeof DiscoveredTask>;\n\n// The tagged union or sum type for the algebraic type `DiscoveredTaskStatus`.\nexport const DiscoveredTaskStatus = __t.enum(\"DiscoveredTaskStatus\", {\n PendingReview: __t.unit(),\n Approved: __t.unit(),\n Rejected: __t.unit(),\n EscalatedToIdea: __t.unit(),\n});\nexport type DiscoveredTaskStatus = __Infer<typeof DiscoveredTaskStatus>;\n\n// The tagged union or sum type for the algebraic type `DiscoveryDecision`.\nexport const DiscoveryDecision = __t.enum(\"DiscoveryDecision\", {\n ApproveAsTask: __t.unit(),\n Reject: __t.unit(),\n EscalateToIdea: __t.unit(),\n});\nexport type DiscoveryDecision = __Infer<typeof DiscoveryDecision>;\n\nexport const EvaluationDimension = __t.object(\"EvaluationDimension\", {\n id: __t.u64(),\n name: __t.string(),\n label: __t.string(),\n weight: __t.f64(),\n minScore: __t.u8(),\n maxScore: __t.u8(),\n description: __t.string(),\n active: __t.bool(),\n sortOrder: __t.u16(),\n});\nexport type EvaluationDimension = __Infer<typeof EvaluationDimension>;\n\nexport const GenerateVoiceResult = __t.object(\"GenerateVoiceResult\", {\n id: __t.u64(),\n seq: __t.u64(),\n agentName: __t.string(),\n keyPrefix: __t.string(),\n});\nexport type GenerateVoiceResult = __Infer<typeof GenerateVoiceResult>;\n\nexport const Idea = __t.object(\"Idea\", {\n id: __t.u64(),\n title: __t.string(),\n description: __t.string(),\n category: __t.string(),\n get status() {\n return IdeaStatus;\n },\n activeAgentCount: __t.u32(),\n quorum: __t.u16(),\n approvalThreshold: __t.u16(),\n vetoThreshold: __t.u16(),\n upVotes: __t.u16(),\n downVotes: __t.u16(),\n vetoCount: __t.u16(),\n totalVotes: __t.u16(),\n createdBy: __t.string(),\n createdAt: __t.timestamp(),\n updatedAt: __t.timestamp(),\n computedScore: __t.f64(),\n});\nexport type Idea = __Infer<typeof Idea>;\n\n// The tagged union or sum type for the algebraic type `IdeaStatus`.\nexport const IdeaStatus = __t.enum(\"IdeaStatus\", {\n Voting: __t.unit(),\n ApprovedForProject: __t.unit(),\n Rejected: __t.unit(),\n Implemented: __t.unit(),\n});\nexport type IdeaStatus = __Infer<typeof IdeaStatus>;\n\nexport const IdentityRole = __t.object(\"IdentityRole\", {\n identity: __t.identity(),\n get role() {\n return AgentRole;\n },\n});\nexport type IdentityRole = __Infer<typeof IdentityRole>;\n\nexport const Message = __t.object(\"Message\", {\n id: __t.u64(),\n channelId: __t.u64(),\n senderId: __t.string(),\n content: __t.string(),\n get messageType() {\n return MessageType;\n },\n contextId: __t.option(__t.string()),\n createdAt: __t.timestamp(),\n});\nexport type Message = __Infer<typeof Message>;\n\n// The tagged union or sum type for the algebraic type `MessageType`.\nexport const MessageType = __t.enum(\"MessageType\", {\n User: __t.unit(),\n System: __t.unit(),\n Directive: __t.unit(),\n});\nexport type MessageType = __Infer<typeof MessageType>;\n\nexport const Project = __t.object(\"Project\", {\n id: __t.u64(),\n sourceIdeaId: __t.u64(),\n name: __t.string(),\n githubRepo: __t.string(),\n description: __t.string(),\n get status() {\n return ProjectStatus;\n },\n createdAt: __t.timestamp(),\n createdBy: __t.string(),\n});\nexport type Project = __Infer<typeof Project>;\n\nexport const ProjectChannel = __t.object(\"ProjectChannel\", {\n projectId: __t.u64(),\n createdAt: __t.timestamp(),\n});\nexport type ProjectChannel = __Infer<typeof ProjectChannel>;\n\nexport const ProjectMessage = __t.object(\"ProjectMessage\", {\n id: __t.u64(),\n projectId: __t.u64(),\n senderId: __t.string(),\n content: __t.string(),\n get messageType() {\n return MessageType;\n },\n contextId: __t.option(__t.string()),\n createdAt: __t.timestamp(),\n});\nexport type ProjectMessage = __Infer<typeof ProjectMessage>;\n\n// The tagged union or sum type for the algebraic type `ProjectStatus`.\nexport const ProjectStatus = __t.enum(\"ProjectStatus\", {\n Active: __t.unit(),\n Paused: __t.unit(),\n});\nexport type ProjectStatus = __Infer<typeof ProjectStatus>;\n\nexport const Task = __t.object(\"Task\", {\n id: __t.u64(),\n projectId: __t.u64(),\n title: __t.string(),\n description: __t.string(),\n get status() {\n return TaskStatus;\n },\n assignedTo: __t.option(__t.string()),\n claimedAt: __t.option(__t.timestamp()),\n githubIssueUrl: __t.option(__t.string()),\n githubPrUrl: __t.option(__t.string()),\n priority: __t.u8(),\n sourceIdeaId: __t.option(__t.u64()),\n reviewCount: __t.u8(),\n get blockedFromStatus() {\n return __t.option(TaskStatus);\n },\n archivedReason: __t.option(__t.string()),\n statusChangedBy: __t.option(__t.identity()),\n statusChangedAt: __t.option(__t.timestamp()),\n createdAt: __t.timestamp(),\n updatedAt: __t.timestamp(),\n createdBy: __t.string(),\n});\nexport type Task = __Infer<typeof Task>;\n\nexport const TaskDependency = __t.object(\"TaskDependency\", {\n id: __t.u64(),\n taskId: __t.u64(),\n dependsOnId: __t.u64(),\n get dependencyType() {\n return DependencyType;\n },\n createdAt: __t.timestamp(),\n});\nexport type TaskDependency = __Infer<typeof TaskDependency>;\n\n// The tagged union or sum type for the algebraic type `TaskStatus`.\nexport const TaskStatus = __t.enum(\"TaskStatus\", {\n Open: __t.unit(),\n Claimed: __t.unit(),\n InProgress: __t.unit(),\n Review: __t.unit(),\n Completed: __t.unit(),\n Blocked: __t.unit(),\n Archived: __t.unit(),\n});\nexport type TaskStatus = __Infer<typeof TaskStatus>;\n\nexport const VoiceAllowedHost = __t.object(\"VoiceAllowedHost\", {\n host: __t.string(),\n});\nexport type VoiceAllowedHost = __Infer<typeof VoiceAllowedHost>;\n\nexport const VoiceAnnouncement = __t.object(\"VoiceAnnouncement\", {\n id: __t.u64(),\n agentId: __t.identity(),\n seq: __t.u64(),\n agentName: __t.string(),\n transcript: __t.string(),\n audioUrl: __t.string(),\n get status() {\n return AnnouncementStatus;\n },\n contextType: __t.option(__t.string()),\n contextId: __t.option(__t.u64()),\n finalizedAt: __t.option(__t.timestamp()),\n failedAt: __t.option(__t.timestamp()),\n errorMessage: __t.option(__t.string()),\n createdAt: __t.timestamp(),\n});\nexport type VoiceAnnouncement = __Infer<typeof VoiceAnnouncement>;\n\nexport const Vote = __t.object(\"Vote\", {\n id: __t.u64(),\n ideaId: __t.u64(),\n agentId: __t.string(),\n get voteType() {\n return VoteType;\n },\n get scores() {\n return __t.array(DimensionScore);\n },\n createdAt: __t.timestamp(),\n});\nexport type Vote = __Infer<typeof Vote>;\n\n// The tagged union or sum type for the algebraic type `VoteType`.\nexport const VoteType = __t.enum(\"VoteType\", {\n Up: __t.unit(),\n Down: __t.unit(),\n Veto: __t.unit(),\n});\nexport type VoteType = __Infer<typeof VoteType>;\n\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nimport {\n DependencyType,\n} from \"./types\";\n\nexport default {\n taskId: __t.u64(),\n dependsOnId: __t.u64(),\n get dependencyType() {\n return DependencyType;\n },\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {\n taskId: __t.u64(),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {\n sourceIdeaId: __t.u64(),\n name: __t.string(),\n githubRepo: __t.string(),\n description: __t.string(),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {\n projectId: __t.u64(),\n title: __t.string(),\n description: __t.string(),\n priority: __t.u8(),\n sourceIdeaId: __t.option(__t.u64()),\n githubIssueUrl: __t.option(__t.string()),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {\n currentTaskId: __t.u64(),\n projectId: __t.u64(),\n title: __t.string(),\n description: __t.string(),\n priority: __t.u8(),\n taskType: __t.string(),\n severity: __t.string(),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {\n announcementId: __t.u64(),\n errorMessage: __t.string(),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {\n announcementId: __t.u64(),\n audioUrl: __t.string(),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {\n agentId: __t.string(),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {\n ideaId: __t.u64(),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {\n title: __t.string(),\n description: __t.string(),\n category: __t.string(),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nimport {\n AgentRole,\n} from \"./types\";\n\nexport default {\n agentId: __t.string(),\n name: __t.string(),\n zenonAddress: __t.string(),\n get role() {\n return __t.option(AgentRole);\n },\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nimport {\n DiscoveryDecision,\n} from \"./types\";\n\nexport default {\n discoveryId: __t.u64(),\n get decision() {\n return DiscoveryDecision;\n },\n reason: __t.option(__t.string()),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nimport {\n MessageType,\n} from \"./types\";\n\nexport default {\n channelId: __t.u64(),\n content: __t.string(),\n get messageType() {\n return MessageType;\n },\n contextId: __t.option(__t.string()),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nimport {\n MessageType,\n} from \"./types\";\n\nexport default {\n projectId: __t.u64(),\n content: __t.string(),\n get messageType() {\n return MessageType;\n },\n contextId: __t.option(__t.string()),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nimport {\n AgentStatus,\n} from \"./types\";\n\nexport default {\n get status() {\n return AgentStatus;\n },\n taskId: __t.option(__t.u64()),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {\n bio: __t.string(),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default {\n capabilities: __t.array(__t.string()),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nimport {\n ProjectStatus,\n} from \"./types\";\n\nexport default {\n projectId: __t.u64(),\n get status() {\n return ProjectStatus;\n },\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nimport {\n TaskStatus,\n} from \"./types\";\n\nexport default {\n taskId: __t.u64(),\n get status() {\n return TaskStatus;\n },\n githubPrUrl: __t.option(__t.string()),\n archiveReason: __t.option(__t.string()),\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nimport {\n DimensionScore,\n} from \"./types\";\n\nexport default {\n ideaId: __t.u64(),\n get scores() {\n return __t.array(DimensionScore);\n },\n};\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nimport {\n GenerateVoiceResult,\n} from \"./types\";\n\nexport const params = {\n transcript: __t.string(),\n audioUrl: __t.option(__t.string()),\n contextType: __t.option(__t.string()),\n};\nexport const returnType = __t.result(GenerateVoiceResult, __t.string())","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\nimport {\n AgentRole,\n AgentStatus,\n} from \"./types\";\n\n\nexport default __t.row({\n id: __t.string().primaryKey(),\n name: __t.string(),\n bio: __t.string(),\n get role() {\n return AgentRole;\n },\n capabilities: __t.array(__t.string()),\n get status() {\n return AgentStatus;\n },\n zenonAddress: __t.string().name(\"zenon_address\"),\n identity: __t.identity(),\n lastHeartbeat: __t.timestamp().name(\"last_heartbeat\"),\n currentTaskId: __t.option(__t.u64()).name(\"current_task_id\"),\n createdAt: __t.timestamp().name(\"created_at\"),\n lastActiveAt: __t.timestamp().name(\"last_active_at\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default __t.row({\n id: __t.u64().primaryKey(),\n name: __t.string(),\n createdBy: __t.string().name(\"created_by\"),\n createdAt: __t.timestamp().name(\"created_at\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default __t.row({\n key: __t.string().primaryKey(),\n value: __t.string(),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\nimport {\n DiscoveredTaskStatus,\n} from \"./types\";\n\n\nexport default __t.row({\n id: __t.u64().primaryKey(),\n discoveredBy: __t.string().name(\"discovered_by\"),\n currentTaskId: __t.u64().name(\"current_task_id\"),\n projectId: __t.u64().name(\"project_id\"),\n title: __t.string(),\n description: __t.string(),\n priority: __t.u8(),\n taskType: __t.string().name(\"task_type\"),\n severity: __t.string(),\n get status() {\n return DiscoveredTaskStatus;\n },\n createdTaskId: __t.option(__t.u64()).name(\"created_task_id\"),\n rejectionReason: __t.option(__t.string()).name(\"rejection_reason\"),\n createdAt: __t.timestamp().name(\"created_at\"),\n reviewedAt: __t.option(__t.timestamp()).name(\"reviewed_at\"),\n reviewedBy: __t.option(__t.string()).name(\"reviewed_by\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default __t.row({\n id: __t.u64().primaryKey(),\n name: __t.string(),\n label: __t.string(),\n weight: __t.f64(),\n minScore: __t.u8().name(\"min_score\"),\n maxScore: __t.u8().name(\"max_score\"),\n description: __t.string(),\n active: __t.bool(),\n sortOrder: __t.u16().name(\"sort_order\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\nimport {\n IdeaStatus,\n} from \"./types\";\n\n\nexport default __t.row({\n id: __t.u64().primaryKey(),\n title: __t.string(),\n description: __t.string(),\n category: __t.string(),\n get status() {\n return IdeaStatus;\n },\n activeAgentCount: __t.u32().name(\"active_agent_count\"),\n quorum: __t.u16(),\n approvalThreshold: __t.u16().name(\"approval_threshold\"),\n vetoThreshold: __t.u16().name(\"veto_threshold\"),\n upVotes: __t.u16().name(\"up_votes\"),\n downVotes: __t.u16().name(\"down_votes\"),\n vetoCount: __t.u16().name(\"veto_count\"),\n totalVotes: __t.u16().name(\"total_votes\"),\n createdBy: __t.string().name(\"created_by\"),\n createdAt: __t.timestamp().name(\"created_at\"),\n updatedAt: __t.timestamp().name(\"updated_at\"),\n computedScore: __t.f64().name(\"computed_score\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\nimport {\n AgentRole,\n} from \"./types\";\n\n\nexport default __t.row({\n identity: __t.identity().primaryKey(),\n get role() {\n return AgentRole;\n },\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\nimport {\n MessageType,\n} from \"./types\";\n\n\nexport default __t.row({\n id: __t.u64().primaryKey(),\n channelId: __t.u64().name(\"channel_id\"),\n senderId: __t.string().name(\"sender_id\"),\n content: __t.string(),\n get messageType() {\n return MessageType.name(\"message_type\");\n },\n contextId: __t.option(__t.string()).name(\"context_id\"),\n createdAt: __t.timestamp().name(\"created_at\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\n\nexport default __t.row({\n projectId: __t.u64().primaryKey().name(\"project_id\"),\n createdAt: __t.timestamp().name(\"created_at\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\nimport {\n MessageType,\n} from \"./types\";\n\n\nexport default __t.row({\n id: __t.u64().primaryKey(),\n projectId: __t.u64().name(\"project_id\"),\n senderId: __t.string().name(\"sender_id\"),\n content: __t.string(),\n get messageType() {\n return MessageType.name(\"message_type\");\n },\n contextId: __t.option(__t.string()).name(\"context_id\"),\n createdAt: __t.timestamp().name(\"created_at\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\nimport {\n ProjectStatus,\n} from \"./types\";\n\n\nexport default __t.row({\n id: __t.u64().primaryKey(),\n sourceIdeaId: __t.u64().name(\"source_idea_id\"),\n name: __t.string(),\n githubRepo: __t.string().name(\"github_repo\"),\n description: __t.string(),\n get status() {\n return ProjectStatus;\n },\n createdAt: __t.timestamp().name(\"created_at\"),\n createdBy: __t.string().name(\"created_by\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\nimport {\n DependencyType,\n} from \"./types\";\n\n\nexport default __t.row({\n id: __t.u64().primaryKey(),\n taskId: __t.u64().name(\"task_id\"),\n dependsOnId: __t.u64().name(\"depends_on_id\"),\n get dependencyType() {\n return DependencyType.name(\"dependency_type\");\n },\n createdAt: __t.timestamp().name(\"created_at\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\nimport {\n TaskStatus,\n} from \"./types\";\n\n\nexport default __t.row({\n id: __t.u64().primaryKey(),\n projectId: __t.u64().name(\"project_id\"),\n title: __t.string(),\n description: __t.string(),\n get status() {\n return TaskStatus;\n },\n assignedTo: __t.option(__t.string()).name(\"assigned_to\"),\n claimedAt: __t.option(__t.timestamp()).name(\"claimed_at\"),\n githubIssueUrl: __t.option(__t.string()).name(\"github_issue_url\"),\n githubPrUrl: __t.option(__t.string()).name(\"github_pr_url\"),\n priority: __t.u8(),\n sourceIdeaId: __t.option(__t.u64()).name(\"source_idea_id\"),\n reviewCount: __t.u8().name(\"review_count\"),\n get blockedFromStatus() {\n return __t.option(TaskStatus).name(\"blocked_from_status\");\n },\n archivedReason: __t.option(__t.string()).name(\"archived_reason\"),\n statusChangedBy: __t.option(__t.identity()).name(\"status_changed_by\"),\n statusChangedAt: __t.option(__t.timestamp()).name(\"status_changed_at\"),\n createdAt: __t.timestamp().name(\"created_at\"),\n updatedAt: __t.timestamp().name(\"updated_at\"),\n createdBy: __t.string().name(\"created_by\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\nimport {\n AnnouncementStatus,\n} from \"./types\";\n\n\nexport default __t.row({\n id: __t.u64().primaryKey(),\n agentId: __t.identity().name(\"agent_id\"),\n seq: __t.u64(),\n agentName: __t.string().name(\"agent_name\"),\n transcript: __t.string(),\n audioUrl: __t.string().name(\"audio_url\"),\n get status() {\n return AnnouncementStatus;\n },\n contextType: __t.option(__t.string()).name(\"context_type\"),\n contextId: __t.option(__t.u64()).name(\"context_id\"),\n finalizedAt: __t.option(__t.timestamp()).name(\"finalized_at\"),\n failedAt: __t.option(__t.timestamp()).name(\"failed_at\"),\n errorMessage: __t.option(__t.string()).name(\"error_message\"),\n createdAt: __t.timestamp().name(\"created_at\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n TypeBuilder as __TypeBuilder,\n t as __t,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type Infer as __Infer,\n} from \"spacetimedb\";\nimport {\n DimensionScore,\n VoteType,\n} from \"./types\";\n\n\nexport default __t.row({\n id: __t.u64().primaryKey(),\n ideaId: __t.u64().name(\"idea_id\"),\n agentId: __t.string().name(\"agent_id\"),\n get voteType() {\n return VoteType.name(\"vote_type\");\n },\n get scores() {\n return __t.array(DimensionScore);\n },\n createdAt: __t.timestamp().name(\"created_at\"),\n});\n","// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE\n// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.\n\n// This was generated using spacetimedb cli version 2.1.0 (commit 6981f48b4bc1a71c8dd9bdfe5a2c343f6370243d).\n\n/* eslint-disable */\n/* tslint:disable */\nimport {\n DbConnectionBuilder as __DbConnectionBuilder,\n DbConnectionImpl as __DbConnectionImpl,\n SubscriptionBuilderImpl as __SubscriptionBuilderImpl,\n TypeBuilder as __TypeBuilder,\n Uuid as __Uuid,\n convertToAccessorMap as __convertToAccessorMap,\n makeQueryBuilder as __makeQueryBuilder,\n procedureSchema as __procedureSchema,\n procedures as __procedures,\n reducerSchema as __reducerSchema,\n reducers as __reducers,\n schema as __schema,\n t as __t,\n table as __table,\n type AlgebraicTypeType as __AlgebraicTypeType,\n type DbConnectionConfig as __DbConnectionConfig,\n type ErrorContextInterface as __ErrorContextInterface,\n type Event as __Event,\n type EventContextInterface as __EventContextInterface,\n type Infer as __Infer,\n type QueryBuilder as __QueryBuilder,\n type ReducerEventContextInterface as __ReducerEventContextInterface,\n type RemoteModule as __RemoteModule,\n type SubscriptionEventContextInterface as __SubscriptionEventContextInterface,\n type SubscriptionHandleImpl as __SubscriptionHandleImpl,\n} from \"spacetimedb\";\n\n// Import all reducer arg schemas\nimport AddTaskDependencyReducer from \"./add_task_dependency_reducer\";\nimport ClaimTaskReducer from \"./claim_task_reducer\";\nimport CreateProjectReducer from \"./create_project_reducer\";\nimport CreateTaskReducer from \"./create_task_reducer\";\nimport DiscoverTaskReducer from \"./discover_task_reducer\";\nimport FailVoiceAnnouncementReducer from \"./fail_voice_announcement_reducer\";\nimport FinalizeVoiceAnnouncementReducer from \"./finalize_voice_announcement_reducer\";\nimport HeartbeatReducer from \"./heartbeat_reducer\";\nimport MarkIdeaImplementedReducer from \"./mark_idea_implemented_reducer\";\nimport ProposeIdeaReducer from \"./propose_idea_reducer\";\nimport RegisterAgentReducer from \"./register_agent_reducer\";\nimport ReviewDiscoveredTaskReducer from \"./review_discovered_task_reducer\";\nimport SeedUiDataReducer from \"./seed_ui_data_reducer\";\nimport SeedVoiceAnnouncementsReducer from \"./seed_voice_announcements_reducer\";\nimport SendMessageReducer from \"./send_message_reducer\";\nimport SendProjectMessageReducer from \"./send_project_message_reducer\";\nimport SetAgentStatusReducer from \"./set_agent_status_reducer\";\nimport UpdateAgentBioReducer from \"./update_agent_bio_reducer\";\nimport UpdateAgentCapabilitiesReducer from \"./update_agent_capabilities_reducer\";\nimport UpdateProjectStatusReducer from \"./update_project_status_reducer\";\nimport UpdateTaskStatusReducer from \"./update_task_status_reducer\";\nimport VoteIdeaReducer from \"./vote_idea_reducer\";\n\n// Import all procedure arg schemas\nimport * as GenerateVoiceProcedure from \"./generate_voice_procedure\";\n\n// Import all table schema definitions\nimport AgentsRow from \"./agents_table\";\nimport ChannelsRow from \"./channels_table\";\nimport ConfigRow from \"./config_table\";\nimport DiscoveredTasksRow from \"./discovered_tasks_table\";\nimport EvaluationDimensionsRow from \"./evaluation_dimensions_table\";\nimport IdeasRow from \"./ideas_table\";\nimport IdentityRolesRow from \"./identity_roles_table\";\nimport MessagesRow from \"./messages_table\";\nimport ProjectChannelsRow from \"./project_channels_table\";\nimport ProjectMessagesRow from \"./project_messages_table\";\nimport ProjectsRow from \"./projects_table\";\nimport TaskDependenciesRow from \"./task_dependencies_table\";\nimport TasksRow from \"./tasks_table\";\nimport VoiceAnnouncementsRow from \"./voice_announcements_table\";\nimport VotesRow from \"./votes_table\";\n\n/** Type-only namespace exports for generated type groups. */\n\n/** The schema information for all tables in this module. This is defined the same was as the tables would have been defined in the server. */\nconst tablesSchema = __schema({\n agents: __table({\n name: 'agents',\n indexes: [\n { accessor: 'id', name: 'agents_id_idx_btree', algorithm: 'btree', columns: [\n 'id',\n ] },\n { accessor: 'identity', name: 'agents_identity_idx_btree', algorithm: 'btree', columns: [\n 'identity',\n ] },\n ],\n constraints: [\n { name: 'agents_id_key', constraint: 'unique', columns: ['id'] },\n { name: 'agents_identity_key', constraint: 'unique', columns: ['identity'] },\n ],\n }, AgentsRow),\n channels: __table({\n name: 'channels',\n indexes: [\n { accessor: 'id', name: 'channels_id_idx_btree', algorithm: 'btree', columns: [\n 'id',\n ] },\n { accessor: 'by_name', name: 'channels_name_idx_btree', algorithm: 'btree', columns: [\n 'name',\n ] },\n ],\n constraints: [\n { name: 'channels_id_key', constraint: 'unique', columns: ['id'] },\n ],\n }, ChannelsRow),\n config: __table({\n name: 'config',\n indexes: [\n { accessor: 'key', name: 'config_key_idx_btree', algorithm: 'btree', columns: [\n 'key',\n ] },\n ],\n constraints: [\n { name: 'config_key_key', constraint: 'unique', columns: ['key'] },\n ],\n }, ConfigRow),\n discovered_tasks: __table({\n name: 'discovered_tasks',\n indexes: [\n { accessor: 'by_created_at', name: 'discovered_tasks_created_at_idx_btree', algorithm: 'btree', columns: [\n 'createdAt',\n ] },\n { accessor: 'id', name: 'discovered_tasks_id_idx_btree', algorithm: 'btree', columns: [\n 'id',\n ] },\n { accessor: 'by_priority', name: 'discovered_tasks_priority_idx_btree', algorithm: 'btree', columns: [\n 'priority',\n ] },\n { accessor: 'by_status', name: 'discovered_tasks_status_idx_btree', algorithm: 'btree', columns: [\n 'status',\n ] },\n ],\n constraints: [\n { name: 'discovered_tasks_id_key', constraint: 'unique', columns: ['id'] },\n ],\n }, DiscoveredTasksRow),\n evaluation_dimensions: __table({\n name: 'evaluation_dimensions',\n indexes: [\n { accessor: 'by_active', name: 'evaluation_dimensions_active_sort_order_idx_btree', algorithm: 'btree', columns: [\n 'active',\n 'sortOrder',\n ] },\n { accessor: 'id', name: 'evaluation_dimensions_id_idx_btree', algorithm: 'btree', columns: [\n 'id',\n ] },\n ],\n constraints: [\n { name: 'evaluation_dimensions_id_key', constraint: 'unique', columns: ['id'] },\n ],\n }, EvaluationDimensionsRow),\n ideas: __table({\n name: 'ideas',\n indexes: [\n { accessor: 'id', name: 'ideas_id_idx_btree', algorithm: 'btree', columns: [\n 'id',\n ] },\n { accessor: 'by_status', name: 'ideas_status_idx_btree', algorithm: 'btree', columns: [\n 'status',\n ] },\n ],\n constraints: [\n { name: 'ideas_id_key', constraint: 'unique', columns: ['id'] },\n ],\n }, IdeasRow),\n identity_roles: __table({\n name: 'identity_roles',\n indexes: [\n { accessor: 'identity', name: 'identity_roles_identity_idx_btree', algorithm: 'btree', columns: [\n 'identity',\n ] },\n ],\n constraints: [\n { name: 'identity_roles_identity_key', constraint: 'unique', columns: ['identity'] },\n ],\n }, IdentityRolesRow),\n messages: __table({\n name: 'messages',\n indexes: [\n { accessor: 'by_channel', name: 'messages_channel_id_created_at_idx_btree', algorithm: 'btree', columns: [\n 'channelId',\n 'createdAt',\n ] },\n { accessor: 'id', name: 'messages_id_idx_btree', algorithm: 'btree', columns: [\n 'id',\n ] },\n ],\n constraints: [\n { name: 'messages_id_key', constraint: 'unique', columns: ['id'] },\n ],\n }, MessagesRow),\n project_channels: __table({\n name: 'project_channels',\n indexes: [\n { accessor: 'project_id', name: 'project_channels_project_id_idx_btree', algorithm: 'btree', columns: [\n 'projectId',\n ] },\n ],\n constraints: [\n { name: 'project_channels_project_id_key', constraint: 'unique', columns: ['projectId'] },\n ],\n }, ProjectChannelsRow),\n project_messages: __table({\n name: 'project_messages',\n indexes: [\n { accessor: 'id', name: 'project_messages_id_idx_btree', algorithm: 'btree', columns: [\n 'id',\n ] },\n { accessor: 'by_project', name: 'project_messages_project_id_idx_btree', algorithm: 'btree', columns: [\n 'projectId',\n ] },\n ],\n constraints: [\n { name: 'project_messages_id_key', constraint: 'unique', columns: ['id'] },\n ],\n }, ProjectMessagesRow),\n projects: __table({\n name: 'projects',\n indexes: [\n { accessor: 'id', name: 'projects_id_idx_btree', algorithm: 'btree', columns: [\n 'id',\n ] },\n { accessor: 'by_source_idea_id', name: 'projects_source_idea_id_idx_btree', algorithm: 'btree', columns: [\n 'sourceIdeaId',\n ] },\n ],\n constraints: [\n { name: 'projects_id_key', constraint: 'unique', columns: ['id'] },\n ],\n }, ProjectsRow),\n task_dependencies: __table({\n name: 'task_dependencies',\n indexes: [\n { accessor: 'by_depends_on_id', name: 'task_dependencies_depends_on_id_idx_btree', algorithm: 'btree', columns: [\n 'dependsOnId',\n ] },\n { accessor: 'id', name: 'task_dependencies_id_idx_btree', algorithm: 'btree', columns: [\n 'id',\n ] },\n { accessor: 'by_task_id', name: 'task_dependencies_task_id_idx_btree', algorithm: 'btree', columns: [\n 'taskId',\n ] },\n ],\n constraints: [\n { name: 'task_dependencies_id_key', constraint: 'unique', columns: ['id'] },\n ],\n }, TaskDependenciesRow),\n tasks: __table({\n name: 'tasks',\n indexes: [\n { accessor: 'by_assigned_to', name: 'tasks_assigned_to_idx_btree', algorithm: 'btree', columns: [\n 'assignedTo',\n ] },\n { accessor: 'id', name: 'tasks_id_idx_btree', algorithm: 'btree', columns: [\n 'id',\n ] },\n { accessor: 'by_priority', name: 'tasks_priority_idx_btree', algorithm: 'btree', columns: [\n 'priority',\n ] },\n { accessor: 'by_project_id', name: 'tasks_project_id_idx_btree', algorithm: 'btree', columns: [\n 'projectId',\n ] },\n { accessor: 'by_status', name: 'tasks_status_idx_btree', algorithm: 'btree', columns: [\n 'status',\n ] },\n ],\n constraints: [\n { name: 'tasks_id_key', constraint: 'unique', columns: ['id'] },\n ],\n }, TasksRow),\n voice_announcements: __table({\n name: 'voice_announcements',\n indexes: [\n { accessor: 'by_agent', name: 'voice_announcements_agent_id_created_at_idx_btree', algorithm: 'btree', columns: [\n 'agentId',\n 'createdAt',\n ] },\n { accessor: 'id', name: 'voice_announcements_id_idx_btree', algorithm: 'btree', columns: [\n 'id',\n ] },\n { accessor: 'by_status', name: 'voice_announcements_status_created_at_idx_btree', algorithm: 'btree', columns: [\n 'status',\n 'createdAt',\n ] },\n ],\n constraints: [\n { name: 'voice_announcements_id_key', constraint: 'unique', columns: ['id'] },\n ],\n }, VoiceAnnouncementsRow),\n votes: __table({\n name: 'votes',\n indexes: [\n { accessor: 'id', name: 'votes_id_idx_btree', algorithm: 'btree', columns: [\n 'id',\n ] },\n { accessor: 'by_idea_agent', name: 'votes_idea_id_agent_id_idx_btree', algorithm: 'btree', columns: [\n 'ideaId',\n 'agentId',\n ] },\n { accessor: 'by_idea', name: 'votes_idea_id_idx_btree', algorithm: 'btree', columns: [\n 'ideaId',\n ] },\n ],\n constraints: [\n { name: 'votes_id_key', constraint: 'unique', columns: ['id'] },\n ],\n }, VotesRow),\n});\n\n/** The schema information for all reducers in this module. This is defined the same way as the reducers would have been defined in the server, except the body of the reducer is omitted in code generation. */\nconst reducersSchema = __reducers(\n __reducerSchema(\"add_task_dependency\", AddTaskDependencyReducer),\n __reducerSchema(\"claim_task\", ClaimTaskReducer),\n __reducerSchema(\"create_project\", CreateProjectReducer),\n __reducerSchema(\"create_task\", CreateTaskReducer),\n __reducerSchema(\"discover_task\", DiscoverTaskReducer),\n __reducerSchema(\"fail_voice_announcement\", FailVoiceAnnouncementReducer),\n __reducerSchema(\"finalize_voice_announcement\", FinalizeVoiceAnnouncementReducer),\n __reducerSchema(\"heartbeat\", HeartbeatReducer),\n __reducerSchema(\"mark_idea_implemented\", MarkIdeaImplementedReducer),\n __reducerSchema(\"propose_idea\", ProposeIdeaReducer),\n __reducerSchema(\"register_agent\", RegisterAgentReducer),\n __reducerSchema(\"review_discovered_task\", ReviewDiscoveredTaskReducer),\n __reducerSchema(\"seed_ui_data\", SeedUiDataReducer),\n __reducerSchema(\"seed_voice_announcements\", SeedVoiceAnnouncementsReducer),\n __reducerSchema(\"send_message\", SendMessageReducer),\n __reducerSchema(\"send_project_message\", SendProjectMessageReducer),\n __reducerSchema(\"set_agent_status\", SetAgentStatusReducer),\n __reducerSchema(\"update_agent_bio\", UpdateAgentBioReducer),\n __reducerSchema(\"update_agent_capabilities\", UpdateAgentCapabilitiesReducer),\n __reducerSchema(\"update_project_status\", UpdateProjectStatusReducer),\n __reducerSchema(\"update_task_status\", UpdateTaskStatusReducer),\n __reducerSchema(\"vote_idea\", VoteIdeaReducer),\n);\n\n/** The schema information for all procedures in this module. This is defined the same way as the procedures would have been defined in the server. */\nconst proceduresSchema = __procedures(\n __procedureSchema(\"generate_voice\", GenerateVoiceProcedure.params, GenerateVoiceProcedure.returnType),\n);\n\n/** The remote SpacetimeDB module schema, both runtime and type information. */\nconst REMOTE_MODULE = {\n versionInfo: {\n cliVersion: \"2.1.0\" as const,\n },\n tables: tablesSchema.schemaType.tables,\n reducers: reducersSchema.reducersType.reducers,\n ...proceduresSchema,\n} satisfies __RemoteModule<\n typeof tablesSchema.schemaType,\n typeof reducersSchema.reducersType,\n typeof proceduresSchema\n>;\n\n/** The tables available in this remote SpacetimeDB module. Each table reference doubles as a query builder. */\nexport const tables: __QueryBuilder<typeof tablesSchema.schemaType> = __makeQueryBuilder(tablesSchema.schemaType);\n\n/** The reducers available in this remote SpacetimeDB module. */\nexport const reducers = __convertToAccessorMap(reducersSchema.reducersType.reducers);\n\n/** The context type returned in callbacks for all possible events. */\nexport type EventContext = __EventContextInterface<typeof REMOTE_MODULE>;\n/** The context type returned in callbacks for reducer events. */\nexport type ReducerEventContext = __ReducerEventContextInterface<typeof REMOTE_MODULE>;\n/** The context type returned in callbacks for subscription events. */\nexport type SubscriptionEventContext = __SubscriptionEventContextInterface<typeof REMOTE_MODULE>;\n/** The context type returned in callbacks for error events. */\nexport type ErrorContext = __ErrorContextInterface<typeof REMOTE_MODULE>;\n/** The subscription handle type to manage active subscriptions created from a {@link SubscriptionBuilder}. */\nexport type SubscriptionHandle = __SubscriptionHandleImpl<typeof REMOTE_MODULE>;\n\n/** Builder class to configure a new subscription to the remote SpacetimeDB instance. */\nexport class SubscriptionBuilder extends __SubscriptionBuilderImpl<typeof REMOTE_MODULE> {}\n\n/** Builder class to configure a new database connection to the remote SpacetimeDB instance. */\nexport class DbConnectionBuilder extends __DbConnectionBuilder<DbConnection> {}\n\n/** The typed database connection to manage connections to the remote SpacetimeDB instance. This class has type information specific to the generated module. */\nexport class DbConnection extends __DbConnectionImpl<typeof REMOTE_MODULE> {\n /** Creates a new {@link DbConnectionBuilder} to configure and connect to the remote SpacetimeDB instance. */\n static builder = (): DbConnectionBuilder => {\n return new DbConnectionBuilder(REMOTE_MODULE, (config: __DbConnectionConfig<typeof REMOTE_MODULE>) => new DbConnection(config));\n };\n\n /** Creates a new {@link SubscriptionBuilder} to configure a subscription to the remote SpacetimeDB instance. */\n override subscriptionBuilder = (): SubscriptionBuilder => {\n return new SubscriptionBuilder(this);\n };\n}\n\n","import type { Identity } from \"spacetimedb\";\nimport {\n\tDbConnection,\n\ttype ErrorContext,\n\ttype tables,\n} from \"~/module_bindings/index.js\";\n\nexport type {\n\tAgent,\n\tChannel,\n\tConfig,\n\tDiscoveredTask,\n\tEvaluationDimension,\n\tIdea,\n\tIdentityRole,\n\tMessage,\n\tProject,\n\tProjectChannel,\n\tProjectMessage,\n\tTask,\n\tTaskDependency,\n\tVote,\n} from \"~/module_bindings/types.js\";\n\nimport { getConfig } from \"./config.js\";\nimport { error } from \"./output.js\";\nimport { getCachedToken } from \"./token-cache.js\";\nimport { getWalletInfo } from \"./wallet.js\";\n\ntype TableName = Extract<keyof typeof tables, string>;\n\nexport interface CommandContextOptions {\n\thost?: string;\n\tmodule?: string;\n\twallet?: string;\n\ttoken?: string;\n\tsubscribe?: boolean;\n\tonDisconnect?: (...args: unknown[]) => void;\n}\n\nexport interface AuthInfo {\n\twallet: string;\n\ttoken: string;\n\tidentity: Identity;\n}\n\nexport class CommandContext implements AsyncDisposable {\n\treadonly conn: DbConnection;\n\treadonly identity?: Identity;\n\treadonly token?: string;\n\treadonly auth?: AuthInfo;\n\treadonly config: Awaited<ReturnType<typeof getConfig>>;\n\n\tprivate disposed = false;\n\n\tprivate constructor(\n\t\tconn: DbConnection,\n\t\tconfig: Awaited<ReturnType<typeof getConfig>>,\n\t\tidentity?: Identity,\n\t\ttoken?: string,\n\t\tauth?: AuthInfo,\n\t) {\n\t\tthis.conn = conn;\n\t\tthis.config = config;\n\t\tthis.identity = identity;\n\t\tthis.token = token;\n\t\tthis.auth = auth;\n\t}\n\n\tget db() {\n\t\treturn this.conn.db;\n\t}\n\n\titer<T>(tableName: TableName): T[] {\n\t\tconst db = this.db as Record<string, { iter?: () => IterableIterator<T> }>;\n\t\tconst table = db[tableName];\n\t\tif (table?.iter) {\n\t\t\treturn Array.from(table.iter());\n\t\t}\n\t\treturn [];\n\t}\n\n\tasync [Symbol.asyncDispose](): Promise<void> {\n\t\tif (!this.disposed) {\n\t\t\tthis.disposed = true;\n\t\t\tthis.conn.disconnect();\n\t\t}\n\t}\n\n\tstatic async create(\n\t\toptions: CommandContextOptions = {},\n\t): Promise<CommandContext> {\n\t\tconst config = await getConfig();\n\t\tconst host = options.host || config.spacetime.host;\n\t\tconst moduleName = options.module || config.spacetime.module;\n\t\tconst walletName = options.wallet || config.defaultWallet;\n\n\t\tlet token = options.token;\n\t\tlet auth: AuthInfo | undefined;\n\n\t\tif (!token && walletName) {\n\t\t\tconst cached = await getCachedToken(walletName);\n\t\t\tif (cached) {\n\t\t\t\ttoken = cached.token;\n\t\t\t\tauth = {\n\t\t\t\t\twallet: walletName,\n\t\t\t\t\ttoken: cached.token,\n\t\t\t\t\tidentity: undefined as unknown as Identity,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timeout = setTimeout(() => {\n\t\t\t\treject(new Error(\"Connection timeout\"));\n\t\t\t}, config.requestTimeout);\n\n\t\t\tconst originalConsoleLog = console.log;\n\t\t\tconst originalConsoleError = console.error;\n\t\t\tconst suppressSdkConnectLog = (...logArgs: unknown[]): void => {\n\t\t\t\tconst shouldSuppress = logArgs.some(\n\t\t\t\t\t(arg) =>\n\t\t\t\t\t\ttypeof arg === \"string\" &&\n\t\t\t\t\t\targ.includes(\"Connecting to SpacetimeDB WS...\"),\n\t\t\t\t);\n\t\t\t\tif (!shouldSuppress) {\n\t\t\t\t\toriginalConsoleLog(...(logArgs as Parameters<typeof console.log>));\n\t\t\t\t}\n\t\t\t};\n\t\t\t// Suppress SDK error spam during connection - errors are properly thrown and handled by callers\n\t\t\tconst suppressSdkError = (..._logArgs: unknown[]): void => {\n\t\t\t\t// Errors are handled by onConnectError and rejected properly\n\t\t\t\tif (process.env.PROBE_DEBUG) {\n\t\t\t\t\toriginalConsoleError(\"[probe:debug]\", ..._logArgs);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconsole.log = suppressSdkConnectLog as typeof console.log;\n\t\t\tconsole.error = suppressSdkError as typeof console.error;\n\n\t\t\ttry {\n\t\t\t\tDbConnection.builder()\n\t\t\t\t\t.withUri(host)\n\t\t\t\t\t.withDatabaseName(moduleName)\n\t\t\t\t\t.withToken(token || undefined)\n\t\t\t\t\t.onConnect(\n\t\t\t\t\t\t(conn: DbConnection, identity: Identity, authToken: string) => {\n\t\t\t\t\t\t\tclearTimeout(timeout);\n\n\t\t\t\t\t\t\tif (auth) {\n\t\t\t\t\t\t\t\tauth.identity = identity;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst shouldSubscribe = options.subscribe !== false;\n\n\t\t\t\t\t\t\tif (shouldSubscribe) {\n\t\t\t\t\t\t\t\tconn\n\t\t\t\t\t\t\t\t\t.subscriptionBuilder()\n\t\t\t\t\t\t\t\t\t.onApplied(() => {\n\t\t\t\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t\t\t\tnew CommandContext(\n\t\t\t\t\t\t\t\t\t\t\t\tconn,\n\t\t\t\t\t\t\t\t\t\t\t\tconfig,\n\t\t\t\t\t\t\t\t\t\t\t\tidentity,\n\t\t\t\t\t\t\t\t\t\t\t\tauthToken,\n\t\t\t\t\t\t\t\t\t\t\t\tauth,\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t.onError((ctx: ErrorContext) => {\n\t\t\t\t\t\t\t\t\t\treject(\n\t\t\t\t\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t\t\t\t\t`Subscription error: ${ctx.event?.message || \"Unknown error\"}`,\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t.subscribe([\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM agents\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM tasks\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM ideas\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM messages\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM channels\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM projects\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM votes\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM evaluation_dimensions\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM discovered_tasks\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM task_dependencies\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM identity_roles\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM config\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM project_channels\",\n\t\t\t\t\t\t\t\t\t\t\"SELECT * FROM project_messages\",\n\t\t\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\t\tnew CommandContext(conn, config, identity, authToken, auth),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t\t.onDisconnect((...disconnectArgs: unknown[]) => {\n\t\t\t\t\t\toptions.onDisconnect?.(...disconnectArgs);\n\t\t\t\t\t})\n\t\t\t\t\t.onConnectError((_ctx: ErrorContext, err: Error) => {\n\t\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\t\tconst message = err.message.toLowerCase();\n\t\t\t\t\t\tif (message.includes(\"unauthorized\") || message.includes(\"401\")) {\n\t\t\t\t\t\t\treject(\n\t\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t\t\"Authentication required. Run `probe auth <wallet> --save` first.\",\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treject(new Error(`Connection failed: ${err.message}`));\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\n\t\t\t\t\t.build();\n\t\t\t} finally {\n\t\t\t\tconsole.log = originalConsoleLog;\n\t\t\t\tconsole.error = originalConsoleError;\n\t\t\t}\n\t\t});\n\t}\n}\n\nexport async function requireAuth(\n\toptions: CommandContextOptions,\n): Promise<CommandContext> {\n\tconst config = await getConfig();\n\tconst walletName = options.wallet || config.defaultWallet;\n\n\tif (!walletName) {\n\t\terror(\n\t\t\t\"WALLET_REQUIRED\",\n\t\t\t\"Wallet required. Use --wallet or set default wallet.\",\n\t\t);\n\t}\n\n\tconst wallet = await getWalletInfo(walletName);\n\tif (!wallet) {\n\t\terror(\"WALLET_NOT_FOUND\", `Wallet not found: ${walletName}`);\n\t}\n\n\tconst cached = await getCachedToken(walletName);\n\tif (!cached) {\n\t\terror(\n\t\t\t\"AUTH_REQUIRED\",\n\t\t\t\"No cached token. Run `probe auth <wallet> --save` first.\",\n\t\t);\n\t}\n\n\treturn CommandContext.create({\n\t\t...options,\n\t\twallet: walletName,\n\t\ttoken: cached.token,\n\t});\n}\n\nexport async function withContext<T>(\n\toptions: CommandContextOptions,\n\thandler: (ctx: CommandContext) => Promise<T>,\n): Promise<T> {\n\tawait using ctx = await CommandContext.create(options);\n\treturn await handler(ctx);\n}\n\nexport async function withAuth<T>(\n\toptions: CommandContextOptions,\n\thandler: (ctx: CommandContext) => Promise<T>,\n): Promise<T> {\n\tawait using ctx = await requireAuth(options);\n\treturn await handler(ctx);\n}\n\nexport async function callReducer(\n\tctx: CommandContext,\n\treducerName: string,\n\targs: Record<string, unknown>,\n): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tlet settled = false;\n\t\tconst timeoutMs = Math.max(1000, ctx.config.requestTimeout);\n\n\t\tconst reducers = ctx.conn.reducers as unknown as Record<string, unknown>;\n\t\tconst reducer = reducers[reducerName];\n\t\tif (typeof reducer !== \"function\") {\n\t\t\treject(new Error(`Reducer not found: ${reducerName}`));\n\t\t\treturn;\n\t\t}\n\n\t\tconst callback = (\n\t\t\teventCtx: { event: { status: { tag: string; value?: string } } },\n\t\t\t_reducerArgs: unknown,\n\t\t) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\n\t\t\tcleanup();\n\t\t\tconst status = eventCtx.event.status;\n\t\t\tif (status.tag === \"Failed\") {\n\t\t\t\treject(new Error(status.value || \"Reducer failed\"));\n\t\t\t} else if (status.tag === \"OutOfEnergy\") {\n\t\t\t\treject(new Error(\"Transaction out of energy\"));\n\t\t\t} else {\n\t\t\t\tresolve();\n\t\t\t}\n\t\t};\n\n\t\tconst onMethod =\n\t\t\t`on${reducerName.charAt(0).toUpperCase() + reducerName.slice(1)}` as keyof typeof ctx.conn.reducers;\n\t\tconst offMethod =\n\t\t\t`removeOn${reducerName.charAt(0).toUpperCase() + reducerName.slice(1)}` as keyof typeof ctx.conn.reducers;\n\n\t\tconst cleanup = () => {\n\t\t\tclearTimeout(timeout);\n\t\t\tconst remove = ctx.conn.reducers[offMethod] as unknown;\n\t\t\tif (typeof remove === \"function\") {\n\t\t\t\t(remove as (cb: typeof callback) => void)(callback);\n\t\t\t}\n\t\t};\n\n\t\tconst timeout = setTimeout(() => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\tcleanup();\n\t\t\treject(\n\t\t\t\tnew Error(`Reducer timed out after ${timeoutMs}ms: ${reducerName}`),\n\t\t\t);\n\t\t}, timeoutMs);\n\n\t\tconst on = ctx.conn.reducers[onMethod] as unknown;\n\t\tif (typeof on === \"function\") {\n\t\t\t(on as (cb: typeof callback) => void)(callback);\n\t\t}\n\n\t\t(reducer as (a: Record<string, unknown>) => void)(args);\n\t});\n}\n\nexport async function callProcedure<T = unknown>(\n\tctx: CommandContext,\n\tprocedureName: string,\n\targs: Record<string, unknown>,\n): Promise<T> {\n\tconst procedures = ctx.conn.procedures as unknown as Record<\n\t\tstring,\n\t\t(args: Record<string, unknown>) => Promise<unknown>\n\t>;\n\tconst accessorName = procedureName.replace(/_([a-z])/g, (_, c) =>\n\t\tc.toUpperCase(),\n\t);\n\tconst proc = procedures[accessorName];\n\tif (typeof proc !== \"function\") {\n\t\tthrow new Error(`Procedure not found: ${procedureName}`);\n\t}\n\treturn (await proc(args)) as T;\n}\n","import { encode } from \"@toon-format/toon\";\n\nexport function formatToon(data: Record<string, unknown>): string {\n\treturn encode(data);\n}\n\nexport function formatToonRecord<T extends object>(\n\tkey: string,\n\titems: T[],\n\tfields?: (keyof T)[],\n): string {\n\tconst displayFields = fields || (Object.keys(items[0] || {}) as (keyof T)[]);\n\tconst rows = items.map((item) => {\n\t\tconst row: Record<string, unknown> = {};\n\t\tfor (const field of displayFields) {\n\t\t\trow[String(field)] = item[field];\n\t\t}\n\t\treturn row;\n\t});\n\treturn encode({ [key]: rows });\n}\n\nexport function toonList<T extends object>(\n\tkey: string,\n\titems: T[],\n\tcolumns?: string[],\n): string {\n\tif (items.length === 0) {\n\t\treturn encode({ [key]: [] });\n\t}\n\n\tconst cols = columns || Object.keys(items[0] as Record<string, unknown>);\n\tconst rows = items.map((item) => {\n\t\tconst row: Record<string, unknown> = {};\n\t\tfor (const col of cols) {\n\t\t\trow[col] = (item as Record<string, unknown>)[col];\n\t\t}\n\t\treturn row;\n\t});\n\treturn encode({ [key]: rows });\n}\n","import { defineCommand } from \"citty\";\nimport { getConfig } from \"~/utils/config.js\";\nimport { CommandContext } from \"~/utils/context.js\";\nimport { forceHelpRequested, printHelp } from \"~/utils/help.js\";\nimport { isJsonMode, setJsonMode, success } from \"~/utils/output.js\";\nimport { getCachedToken } from \"~/utils/token-cache.js\";\nimport { toonList } from \"~/utils/toon.js\";\nimport { getWalletInfo } from \"~/utils/wallet.js\";\n\ntype CheckStatus = \"pass\" | \"warn\" | \"fail\";\n\ninterface DoctorCheck {\n\tcheck: string;\n\tstatus: CheckStatus;\n\tdetail: string;\n}\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"doctor\",\n\t\tdescription: \"Run environment and connectivity diagnostics\",\n\t},\n\targs: {\n\t\twallet: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Wallet name override for auth checks\",\n\t\t},\n\t\thost: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"SpacetimeDB host override\",\n\t\t},\n\t\tmodule: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"SpacetimeDB module override\",\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) {\n\t\t\tsetJsonMode(true);\n\t\t}\n\n\t\tif (forceHelpRequested()) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe doctor\",\n\t\t\t\tdescription: \"Validate Probe config, auth, and Nexus connectivity\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe doctor\",\n\t\t\t\t\t\"probe doctor --wallet my-wallet --host ws://127.0.0.1:3000 --module nexus\",\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--wallet\", detail: \"Wallet override for auth checks\" },\n\t\t\t\t\t{ name: \"--host, --module\", detail: \"SpacetimeDB overrides\" },\n\t\t\t\t\t{ name: \"--json\", detail: \"JSON output mode\" },\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst checks: DoctorCheck[] = [];\n\t\tconst addCheck = (check: string, status: CheckStatus, detail: string) => {\n\t\t\tchecks.push({ check, status, detail });\n\t\t};\n\n\t\tlet config: Awaited<ReturnType<typeof getConfig>> | null = null;\n\t\ttry {\n\t\t\tconfig = await getConfig();\n\t\t\taddCheck(\"config\", \"pass\", \"Loaded Probe configuration\");\n\t\t} catch (err) {\n\t\t\taddCheck(\n\t\t\t\t\"config\",\n\t\t\t\t\"fail\",\n\t\t\t\terr instanceof Error ? err.message : \"Failed to load configuration\",\n\t\t\t);\n\t\t}\n\n\t\tconst walletName = args.wallet || config?.defaultWallet;\n\t\tif (!walletName) {\n\t\t\taddCheck(\n\t\t\t\t\"wallet.selected\",\n\t\t\t\t\"fail\",\n\t\t\t\t\"No wallet selected (set --wallet or defaultWallet)\",\n\t\t\t);\n\t\t} else {\n\t\t\taddCheck(\"wallet.selected\", \"pass\", `Using wallet '${walletName}'`);\n\t\t}\n\n\t\tlet hasWallet = false;\n\t\tif (walletName) {\n\t\t\tconst wallet = await getWalletInfo(walletName);\n\t\t\tif (wallet) {\n\t\t\t\thasWallet = true;\n\t\t\t\taddCheck(\"wallet.exists\", \"pass\", `Address ${wallet.address}`);\n\t\t\t} else {\n\t\t\t\taddCheck(\"wallet.exists\", \"fail\", `Wallet '${walletName}' not found`);\n\t\t\t}\n\t\t}\n\n\t\tlet token: string | null = null;\n\t\tif (walletName && hasWallet) {\n\t\t\tconst cached = await getCachedToken(walletName);\n\t\t\tif (!cached) {\n\t\t\t\taddCheck(\"auth.token\", \"fail\", \"No cached token (run probe auth)\");\n\t\t\t} else {\n\t\t\t\ttoken = cached.token;\n\t\t\t\tconst expires = new Date(cached.expiresAt);\n\t\t\t\tif (Number.isNaN(expires.getTime())) {\n\t\t\t\t\taddCheck(\"auth.token\", \"warn\", \"Token exists but expiry is invalid\");\n\t\t\t\t} else if (expires.getTime() <= Date.now()) {\n\t\t\t\t\taddCheck(\n\t\t\t\t\t\t\"auth.token\",\n\t\t\t\t\t\t\"fail\",\n\t\t\t\t\t\t`Token expired at ${expires.toISOString()}`,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\taddCheck(\n\t\t\t\t\t\t\"auth.token\",\n\t\t\t\t\t\t\"pass\",\n\t\t\t\t\t\t`Token valid until ${expires.toISOString()}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (config) {\n\t\t\tconst host = args.host || config.spacetime.host;\n\t\t\tconst moduleName = args.module || config.spacetime.module;\n\t\t\taddCheck(\"nexus.target\", \"pass\", `${host} / ${moduleName}`);\n\n\t\t\tif (token) {\n\t\t\t\ttry {\n\t\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\t\thost,\n\t\t\t\t\t\tmodule: moduleName,\n\t\t\t\t\t\twallet: walletName,\n\t\t\t\t\t\ttoken,\n\t\t\t\t\t\tsubscribe: false,\n\t\t\t\t\t});\n\t\t\t\t\tconst identity = ctx.identity?.toHexString() || \"unknown\";\n\t\t\t\t\taddCheck(\"nexus.connect\", \"pass\", `Connected as ${identity}`);\n\t\t\t\t} catch (err) {\n\t\t\t\t\taddCheck(\n\t\t\t\t\t\t\"nexus.connect\",\n\t\t\t\t\t\t\"fail\",\n\t\t\t\t\t\terr instanceof Error ? err.message : \"Connection failed\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\taddCheck(\n\t\t\t\t\t\"nexus.connect\",\n\t\t\t\t\t\"warn\",\n\t\t\t\t\t\"Skipped connection check (no valid token)\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst counts = checks.reduce(\n\t\t\t(acc, item) => {\n\t\t\t\tif (item.status === \"pass\") acc.pass += 1;\n\t\t\t\telse if (item.status === \"warn\") acc.warn += 1;\n\t\t\t\telse acc.fail += 1;\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{ pass: 0, warn: 0, fail: 0 },\n\t\t);\n\n\t\tconst ok = counts.fail === 0;\n\t\tsuccess({ ok, counts, checks });\n\n\t\tif (!isJsonMode()) {\n\t\t\tconsole.log(toonList(\"doctor_checks\", checks));\n\t\t\tconsole.log(toonList(\"doctor_summary\", [{ ok, ...counts }]));\n\t\t}\n\t},\n});\n","import type {\n\tAgentRole as AgentRoleType,\n\tAgentStatus as AgentStatusType,\n\tIdeaStatus as IdeaStatusType,\n\tMessageType as MessageTypeType,\n\tProjectStatus as ProjectStatusType,\n\tTaskStatus as TaskStatusType,\n} from \"~/module_bindings/types.js\";\n\nexport const TaskStatus = {\n\tvalues: [\n\t\t\"Open\",\n\t\t\"Claimed\",\n\t\t\"InProgress\",\n\t\t\"Review\",\n\t\t\"Completed\",\n\t\t\"Blocked\",\n\t\t\"Archived\",\n\t] as const,\n\n\tis: {\n\t\topen: (s: TaskStatusType) => s.tag === \"Open\",\n\t\tclaimed: (s: TaskStatusType) => s.tag === \"Claimed\",\n\t\tinProgress: (s: TaskStatusType) => s.tag === \"InProgress\",\n\t\treview: (s: TaskStatusType) => s.tag === \"Review\",\n\t\tcompleted: (s: TaskStatusType) => s.tag === \"Completed\",\n\t\tblocked: (s: TaskStatusType) => s.tag === \"Blocked\",\n\t\tarchived: (s: TaskStatusType) => s.tag === \"Archived\",\n\t\tactive: (s: TaskStatusType) =>\n\t\t\t[\"Open\", \"Claimed\", \"InProgress\", \"Review\"].includes(s.tag),\n\t\tterminal: (s: TaskStatusType) =>\n\t\t\t[\"Completed\", \"Blocked\", \"Archived\"].includes(s.tag),\n\t},\n\n\tfromString(s: string): TaskStatusType {\n\t\tconst map: Record<string, TaskStatusType> = {\n\t\t\topen: { tag: \"Open\" },\n\t\t\tclaimed: { tag: \"Claimed\" },\n\t\t\tin_progress: { tag: \"InProgress\" },\n\t\t\tinprogress: { tag: \"InProgress\" },\n\t\t\treview: { tag: \"Review\" },\n\t\t\tcompleted: { tag: \"Completed\" },\n\t\t\tmerged: { tag: \"Completed\" },\n\t\t\tblocked: { tag: \"Blocked\" },\n\t\t\tarchived: { tag: \"Archived\" },\n\t\t};\n\t\treturn map[s.toLowerCase().replace(/[_\\s]/g, \"\")] ?? { tag: \"Open\" };\n\t},\n\n\tmatches(status: TaskStatusType, filter: string): boolean {\n\t\tconst f = filter.toLowerCase().replace(/[_\\s]/g, \"\");\n\t\tif (f === \"merged\") return status.tag === \"Completed\";\n\t\treturn status.tag.toLowerCase() === f;\n\t},\n\n\tdisplay(status: TaskStatusType): string {\n\t\tconst map: Record<string, string> = { InProgress: \"IN PROGRESS\" };\n\t\treturn map[status.tag] ?? status.tag.toUpperCase();\n\t},\n} as const;\n\nexport const IdeaStatus = {\n\tvalues: [\"Voting\", \"ApprovedForProject\", \"Rejected\", \"Implemented\"] as const,\n\n\tis: {\n\t\tvoting: (s: IdeaStatusType) => s.tag === \"Voting\",\n\t\tapproved: (s: IdeaStatusType) => s.tag === \"ApprovedForProject\",\n\t\trejected: (s: IdeaStatusType) => s.tag === \"Rejected\",\n\t\timplemented: (s: IdeaStatusType) => s.tag === \"Implemented\",\n\t\tactive: (s: IdeaStatusType) => s.tag === \"Voting\",\n\t\tterminal: (s: IdeaStatusType) =>\n\t\t\t[\"ApprovedForProject\", \"Rejected\", \"Implemented\"].includes(s.tag),\n\t},\n\n\tfromString(s: string): IdeaStatusType {\n\t\tconst map: Record<string, IdeaStatusType> = {\n\t\t\tvoting: { tag: \"Voting\" },\n\t\t\tapproved: { tag: \"ApprovedForProject\" },\n\t\t\tapproved_for_project: { tag: \"ApprovedForProject\" },\n\t\t\trejected: { tag: \"Rejected\" },\n\t\t\timplemented: { tag: \"Implemented\" },\n\t\t};\n\t\treturn map[s.toLowerCase().replace(/[_\\s]/g, \"\")] ?? { tag: \"Voting\" };\n\t},\n\n\tmatches(status: IdeaStatusType, filter: string): boolean {\n\t\tconst f = filter.toLowerCase().replace(/[_\\s]/g, \"\");\n\t\tif (f === \"approved\") return status.tag === \"ApprovedForProject\";\n\t\treturn status.tag.toLowerCase() === f;\n\t},\n\n\tdisplay(status: IdeaStatusType): string {\n\t\tif (status.tag === \"ApprovedForProject\") return \"Approved\";\n\t\treturn status.tag;\n\t},\n} as const;\n\nexport const AgentRole = {\n\tvalues: [\"Zoe\", \"Admin\", \"Zeno\"] as const,\n\n\tis: {\n\t\tzoe: (r: AgentRoleType) => r.tag === \"Zoe\",\n\t\tadmin: (r: AgentRoleType) => r.tag === \"Admin\",\n\t\tzeno: (r: AgentRoleType) => r.tag === \"Zeno\",\n\t\tprivileged: (r: AgentRoleType) => [\"Zoe\", \"Admin\"].includes(r.tag),\n\t},\n\n\tfromString(s: string): AgentRoleType {\n\t\tconst map: Record<string, AgentRoleType> = {\n\t\t\tzoe: { tag: \"Zoe\" },\n\t\t\tadmin: { tag: \"Admin\" },\n\t\t\tzeno: { tag: \"Zeno\" },\n\t\t};\n\t\treturn map[s.toLowerCase()] ?? { tag: \"Zeno\" };\n\t},\n\n\tdisplay(r: AgentRoleType): string {\n\t\treturn r.tag.toLowerCase();\n\t},\n} as const;\n\nexport const AgentStatus = {\n\tvalues: [\"Online\", \"Offline\", \"Working\"] as const,\n\n\tis: {\n\t\tonline: (s: AgentStatusType) => s.tag === \"Online\",\n\t\toffline: (s: AgentStatusType) => s.tag === \"Offline\",\n\t\tworking: (s: AgentStatusType) => s.tag === \"Working\",\n\t\tavailable: (s: AgentStatusType) =>\n\t\t\ts.tag === \"Online\" || s.tag === \"Working\",\n\t},\n\n\tfromString(s: string): AgentStatusType {\n\t\tconst map: Record<string, AgentStatusType> = {\n\t\t\tonline: { tag: \"Online\" },\n\t\t\toffline: { tag: \"Offline\" },\n\t\t\tworking: { tag: \"Working\" },\n\t\t\tbusy: { tag: \"Working\" },\n\t\t};\n\t\treturn map[s.toLowerCase()] ?? { tag: \"Offline\" };\n\t},\n\n\tdisplay(s: AgentStatusType): string {\n\t\treturn s.tag;\n\t},\n} as const;\n\nexport const MessageType = {\n\tvalues: [\"User\", \"System\", \"Directive\"] as const,\n\n\tis: {\n\t\tuser: (t: MessageTypeType) => t.tag === \"User\",\n\t\tsystem: (t: MessageTypeType) => t.tag === \"System\",\n\t\tdirective: (t: MessageTypeType) => t.tag === \"Directive\",\n\t},\n\n\tfromString(s: string): MessageTypeType {\n\t\tconst map: Record<string, MessageTypeType> = {\n\t\t\tuser: { tag: \"User\" },\n\t\t\ttext: { tag: \"User\" },\n\t\t\tsystem: { tag: \"System\" },\n\t\t\tdirective: { tag: \"Directive\" },\n\t\t};\n\t\treturn map[s.toLowerCase()] ?? { tag: \"User\" };\n\t},\n\n\tdisplay(t: MessageTypeType): string {\n\t\treturn t.tag.toLowerCase();\n\t},\n} as const;\n\nexport const ProjectStatus = {\n\tvalues: [\"Active\", \"Paused\"] as const,\n\n\tis: {\n\t\tactive: (s: ProjectStatusType) => s.tag === \"Active\",\n\t\tpaused: (s: ProjectStatusType) => s.tag === \"Paused\",\n\t},\n\n\tfromString(s: string): ProjectStatusType {\n\t\tconst normalized = s.toLowerCase().replace(/[_\\s]/g, \"\");\n\t\tconst map: Record<string, ProjectStatusType> = {\n\t\t\tactive: { tag: \"Active\" },\n\t\t\tpaused: { tag: \"Paused\" },\n\t\t};\n\t\treturn map[normalized] ?? { tag: \"Active\" };\n\t},\n\n\tmatches(status: ProjectStatusType, filter: string): boolean {\n\t\tconst normalized = filter.toLowerCase().replace(/[_\\s]/g, \"\");\n\t\treturn status.tag.toLowerCase() === normalized;\n\t},\n\n\tdisplay(status: ProjectStatusType): string {\n\t\treturn status.tag.toLowerCase();\n\t},\n} as const;\n","type MicrosTimestamp = { microsSinceUnixEpoch: bigint | number | string };\n\nexport const toMicros = (value: unknown): bigint => {\n\tif (\n\t\t!value ||\n\t\ttypeof value !== \"object\" ||\n\t\t!(\"microsSinceUnixEpoch\" in value)\n\t) {\n\t\treturn 0n;\n\t}\n\tconst micros = (value as MicrosTimestamp).microsSinceUnixEpoch;\n\treturn typeof micros === \"bigint\" ? micros : BigInt(micros);\n};\n\nexport const formatTimestamp = (value: unknown, fallback = \"\"): string => {\n\tconst micros = toMicros(value);\n\tif (micros <= 0n) {\n\t\treturn fallback || String(value ?? \"\");\n\t}\n\treturn new Date(Number(micros / 1000n))\n\t\t.toISOString()\n\t\t.replace(\"T\", \" \")\n\t\t.slice(0, 19);\n};\n\nexport const formatIsoTimestamp = (value: unknown, fallback = \"\"): string => {\n\tconst micros = toMicros(value);\n\tif (micros <= 0n) {\n\t\treturn fallback || new Date().toISOString();\n\t}\n\treturn new Date(Number(micros / 1000n)).toISOString();\n};\n","import { getConfig } from \"~/utils/config.js\";\nimport {\n\ttype Agent,\n\tCommandContext,\n\tcallReducer,\n\tcallProcedure,\n\twithAuth,\n} from \"~/utils/context.js\";\nimport { AgentRole, AgentStatus } from \"~/utils/enums.js\";\nimport { error, isJsonMode, success } from \"~/utils/output.js\";\nimport { formatTimestamp, toMicros } from \"~/utils/time.js\";\nimport { toonList } from \"~/utils/toon.js\";\nimport { getWalletInfo } from \"~/utils/wallet.js\";\nimport type { GenerateVoiceResult } from \"~/module_bindings/types.js\";\n\nconst MAX_VOICE_TRANSCRIPT_LENGTH = 500;\nconst DEFAULT_VOICE_CONTEXT_TYPE = \"status_update\";\n\nexport interface AgentCommandArgs {\n\taction?: string;\n\tagentId?: string;\n\tname?: string;\n\trole?: string;\n\taddress?: string;\n\twallet?: string;\n\ttask?: string;\n\tlimit?: string;\n\tcapabilities?: string;\n\tset?: string;\n\taudioUrl?: string;\n\tcontextType?: string;\n\thost?: string;\n\tmodule?: string;\n}\n\nconst normalizeCapabilities = (value?: string): string[] => {\n\tif (!value) return [];\n\treturn [\n\t\t...new Set(\n\t\t\tvalue\n\t\t\t\t.split(\",\")\n\t\t\t\t.map((item) => item.trim().toLowerCase())\n\t\t\t\t.filter(Boolean),\n\t\t),\n\t];\n};\n\nconst currentAgentForIdentity = (ctx: CommandContext): Agent | undefined => {\n\treturn ctx\n\t\t.iter<Agent>(\"agents\")\n\t\t.find((a) => a.identity.toHexString() === ctx.identity?.toHexString());\n};\n\nconst renderAgent = (agent: Agent, identity?: string) => ({\n\tid: agent.id,\n\tname: agent.name,\n\trole: AgentRole.display(agent.role),\n\tstatus: AgentStatus.display(agent.status),\n\tlastHeartbeat: formatTimestamp(agent.lastHeartbeat),\n\tcurrentTaskId: agent.currentTaskId ? agent.currentTaskId.toString() : \"\",\n\tcapabilities: agent.capabilities.join(\",\"),\n\tidentity: identity || \"\",\n});\n\nexport const runAgentAction = async (args: AgentCommandArgs): Promise<void> => {\n\tconst action = args.action;\n\tif (!action) {\n\t\terror(\"ACTION_REQUIRED\", \"Agent action required\");\n\t}\n\n\ttry {\n\t\tswitch (action) {\n\t\t\tcase \"register\": {\n\t\t\t\tconst agentId = args.agentId;\n\t\t\t\tconst name = args.name;\n\t\t\t\tconst role = args.role || \"zeno\";\n\n\t\t\t\tif (!agentId || !name)\n\t\t\t\t\terror(\"ARGS_REQUIRED\", \"Agent ID and name required\");\n\n\t\t\t\tconst config = await getConfig();\n\t\t\t\tconst walletName = args.wallet || config.defaultWallet;\n\t\t\t\tif (!args.address && !walletName)\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"WALLET_REQUIRED\",\n\t\t\t\t\t\t\"--address or --wallet required (or set default wallet)\",\n\t\t\t\t\t);\n\n\t\t\t\tlet address = args.address;\n\t\t\t\tconst capabilities = normalizeCapabilities(args.capabilities);\n\t\t\t\tif (!address && walletName) {\n\t\t\t\t\tconst wallet = await getWalletInfo(walletName);\n\t\t\t\t\tif (!wallet)\n\t\t\t\t\t\terror(\"WALLET_NOT_FOUND\", `Wallet not found: ${walletName}`);\n\t\t\t\t\taddress = wallet.address;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: walletName },\n\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\tawait callReducer(ctx, \"registerAgent\", {\n\t\t\t\t\t\t\t\tagentId,\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\trole: AgentRole.fromString(role),\n\t\t\t\t\t\t\t\tzenonAddress: address as string,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tif (capabilities.length > 0) {\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"updateAgentCapabilities\", {\n\t\t\t\t\t\t\t\t\tcapabilities,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tawait new Promise((r) => setTimeout(r, 500));\n\t\t\t\t\t\t\tconst registered = ctx\n\t\t\t\t\t\t\t\t.iter<Agent>(\"agents\")\n\t\t\t\t\t\t\t\t.find((a) => a.id === agentId);\n\t\t\t\t\t\t\tif (!registered) {\n\t\t\t\t\t\t\t\tif (role === \"zoe\" || role === \"admin\") {\n\t\t\t\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\t\t\t\"UNAUTHORIZED\",\n\t\t\t\t\t\t\t\t\t\t\"Only whitelisted identities can register as zoe or admin\",\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\terror(\"REGISTRATION_FAILED\", \"Registration failed\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\tsuccess({\n\t\t\t\t\t\tregistered: true,\n\t\t\t\t\t\tagentId,\n\t\t\t\t\t\tname,\n\t\t\t\t\t\trole,\n\t\t\t\t\t\taddress,\n\t\t\t\t\t\tcapabilities,\n\t\t\t\t\t});\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\"agent_registered\", [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tagentId,\n\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\trole,\n\t\t\t\t\t\t\t\t\taddress,\n\t\t\t\t\t\t\t\t\tcapabilities: capabilities.join(\",\"),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"status\": {\n\t\t\t\tif (args.agentId || args.task || args.capabilities) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"INVALID_USAGE\",\n\t\t\t\t\t\t\"Use `probe agent set-status <online|offline|working|busy>` to update status. `probe agent status` only shows current status.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tawait withAuth(\n\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\tconst myAgent = currentAgentForIdentity(ctx);\n\t\t\t\t\t\tif (!myAgent)\n\t\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\t\"NOT_REGISTERED\",\n\t\t\t\t\t\t\t\t\"Agent not registered. Run `probe agent register` first.\",\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\tsuccess(myAgent);\n\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\ttoonList(\"agent\", [\n\t\t\t\t\t\t\t\t\trenderAgent(myAgent, ctx.identity?.toHexString()),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"set-status\": {\n\t\t\t\tconst nextStatus = args.agentId;\n\t\t\t\tif (!nextStatus) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"STATUS_REQUIRED\",\n\t\t\t\t\t\t\"Status required. Use: online, offline, working, busy\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (args.capabilities) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"INVALID_USAGE\",\n\t\t\t\t\t\t\"Use `probe agent capabilities --set <list>` to update capabilities.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst normalized = nextStatus.toLowerCase();\n\t\t\t\tconst allowed = new Set([\"online\", \"offline\", \"working\", \"busy\"]);\n\t\t\t\tif (!allowed.has(normalized)) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"INVALID_STATUS\",\n\t\t\t\t\t\t`Invalid status: ${nextStatus}. Use: online, offline, working, busy`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst mapped = AgentStatus.fromString(normalized);\n\t\t\t\tconst isWorking = AgentStatus.is.working(mapped);\n\t\t\t\tif (isWorking && !args.task) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"TASK_REQUIRED\",\n\t\t\t\t\t\t\"--task is required when setting status to working\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (!isWorking && args.task) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"TASK_NOT_ALLOWED\",\n\t\t\t\t\t\t\"--task is only allowed when setting status to working\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\tawait callReducer(ctx, \"setAgentStatus\", {\n\t\t\t\t\t\t\t\tstatus: mapped,\n\t\t\t\t\t\t\t\ttaskId: isWorking ? BigInt(args.task as string) : undefined,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\n\t\t\t\t\tsuccess({\n\t\t\t\t\t\tupdated: true,\n\t\t\t\t\t\tstatus: normalized,\n\t\t\t\t\t\ttaskId: args.task || null,\n\t\t\t\t\t});\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\"agent_status_updated\", [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tstatus: normalized,\n\t\t\t\t\t\t\t\t\ttaskId: args.task || \"\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"capabilities\": {\n\t\t\t\tif (!args.set) error(\"CAPABILITIES_REQUIRED\", \"--set is required\");\n\n\t\t\t\tconst capabilities = normalizeCapabilities(args.set);\n\t\t\t\ttry {\n\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\tawait callReducer(ctx, \"updateAgentCapabilities\", {\n\t\t\t\t\t\t\t\tcapabilities,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tconst myAgent = currentAgentForIdentity(ctx);\n\t\t\t\t\t\t\tsuccess({ updated: true, agentId: myAgent?.id, capabilities });\n\t\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\ttoonList(\"agent_capabilities_updated\", [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tagentId: myAgent?.id || \"\",\n\t\t\t\t\t\t\t\t\t\t\tcapabilities: capabilities.join(\",\"),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} catch (err) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"me\": {\n\t\t\t\tawait withAuth(\n\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\tconst myAgent = currentAgentForIdentity(ctx);\n\t\t\t\t\t\tif (!myAgent)\n\t\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\t\"NOT_REGISTERED\",\n\t\t\t\t\t\t\t\t\"Agent not registered. Run `probe agent register` first.\",\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\tsuccess(myAgent);\n\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\ttoonList(\"agent\", [\n\t\t\t\t\t\t\t\t\trenderAgent(myAgent, ctx.identity?.toHexString()),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"heartbeat\": {\n\t\t\t\ttry {\n\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\tconst myAgent = currentAgentForIdentity(ctx);\n\t\t\t\t\t\t\tif (!myAgent) error(\"NOT_REGISTERED\", \"Agent not registered\");\n\n\t\t\t\t\t\t\tawait callReducer(ctx, \"heartbeat\", {\n\t\t\t\t\t\t\t\tagentId: myAgent.id,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tsuccess({ heartbeat: true });\n\t\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\ttoonList(\"agent_heartbeat\", [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tagentId: myAgent.id,\n\t\t\t\t\t\t\t\t\t\t\tstatus: AgentStatus.display(myAgent.status),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} catch (err) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"list\": {\n\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\thost: args.host,\n\t\t\t\t\tmodule: args.module,\n\t\t\t\t});\n\t\t\t\tconst limit = args.limit ? parseInt(args.limit, 10) : undefined;\n\t\t\t\tif (limit !== undefined && (!Number.isFinite(limit) || limit <= 0)) {\n\t\t\t\t\terror(\"INVALID_LIMIT\", \"--limit must be a positive integer\");\n\t\t\t\t}\n\n\t\t\t\tlet onlineAgents = ctx\n\t\t\t\t\t.iter<Agent>(\"agents\")\n\t\t\t\t\t.filter((a) => !AgentStatus.is.offline(a.status));\n\t\t\t\tonlineAgents = onlineAgents.sort((a, b) => {\n\t\t\t\t\tconst aMicros = toMicros(\n\t\t\t\t\t\ta.lastHeartbeat || a.createdAt || a.lastActiveAt,\n\t\t\t\t\t);\n\t\t\t\t\tconst bMicros = toMicros(\n\t\t\t\t\t\tb.lastHeartbeat || b.createdAt || b.lastActiveAt,\n\t\t\t\t\t);\n\t\t\t\t\tif (aMicros !== bMicros) return bMicros > aMicros ? 1 : -1;\n\t\t\t\t\treturn b.id.localeCompare(a.id);\n\t\t\t\t});\n\t\t\t\tif (limit !== undefined) onlineAgents = onlineAgents.slice(0, limit);\n\n\t\t\t\tsuccess({ agents: onlineAgents, count: onlineAgents.length });\n\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\ttoonList(\n\t\t\t\t\t\t\t\"agents\",\n\t\t\t\t\t\t\tonlineAgents.map((a) => ({\n\t\t\t\t\t\t\t\tid: a.id,\n\t\t\t\t\t\t\t\tname: a.name,\n\t\t\t\t\t\t\t\trole: AgentRole.display(a.role),\n\t\t\t\t\t\t\t\tstatus: AgentStatus.display(a.status),\n\t\t\t\t\t\t\t\tlast_heartbeat: formatTimestamp(a.lastHeartbeat),\n\t\t\t\t\t\t\t\tcapabilities: a.capabilities.join(\",\"),\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"identity\": {\n\t\t\t\tawait withAuth(\n\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\tconst identityHex = ctx.identity?.toHexString();\n\t\t\t\t\t\tsuccess({ identity: identityHex, wallet: args.wallet });\n\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\ttoonList(\"identity\", [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tidentity: identityHex || \"\",\n\t\t\t\t\t\t\t\t\t\twallet: args.wallet || \"\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"voice\": {\n\t\t\t\tconst transcript = args.agentId?.trim();\n\t\t\t\tif (!transcript) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"TRANSCRIPT_REQUIRED\",\n\t\t\t\t\t\t\"Transcript required. Provide as first positional argument.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (transcript.length > MAX_VOICE_TRANSCRIPT_LENGTH) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"TRANSCRIPT_TOO_LONG\",\n\t\t\t\t\t\t`Transcript exceeds ${MAX_VOICE_TRANSCRIPT_LENGTH} characters.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (!args.audioUrl) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"AUDIO_URL_REQUIRED\",\n\t\t\t\t\t\t\"--audioUrl is required for voice announcements.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\tconst contextType = args.contextType || DEFAULT_VOICE_CONTEXT_TYPE;\n\t\t\t\t\t\t\tconst result = await callProcedure<GenerateVoiceResult>(\n\t\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\t\t\"generate_voice\",\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttranscript,\n\t\t\t\t\t\t\t\taudioUrl: args.audioUrl,\n\t\t\t\t\t\t\t\tcontextType,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tconst data = {\n\t\t\t\t\t\t\t\tok: true,\n\t\t\t\t\t\t\t\tannouncementId: result.id,\n\t\t\t\t\t\t\t\tseq: result.seq,\n\t\t\t\t\t\t\t\tagentName: result.agentName,\n\t\t\t\t\t\t\t\tkeyPrefix: result.keyPrefix,\n\t\t\t\t\t\t\t\taudioUrl: args.audioUrl,\n\t\t\t\t\t\t\t\tcontextType,\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\tsuccess(data);\n\t\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\ttoonList(\"voice_announcement\", [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: result.id,\n\t\t\t\t\t\t\t\t\t\tseq: result.seq,\n\t\t\t\t\t\t\t\t\t\tagentName: result.agentName,\n\t\t\t\t\t\t\t\t\t\tkeyPrefix: result.keyPrefix,\n\t\t\t\t\t\t\t\t\t\taudioUrl: args.audioUrl || \"\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} catch (err) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"PROCEDURE_FAILED\",\n\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\terror(\n\t\t\t\t\t\"INVALID_ACTION\",\n\t\t\t\t\t`Invalid action: ${action}`,\n\t\t\t\t\t\"Use: register, status, set-status, capabilities, me, heartbeat, list, identity, voice\",\n\t\t\t\t);\n\t\t}\n\t} catch (err) {\n\t\t// Handle connection errors gracefully - avoid citty/consola stack traces\n\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\terror(\"CONNECTION_ERROR\", message);\n\t}\n};\n","import { defineCommand } from \"citty\";\nimport { printHelp } from \"~/utils/help.js\";\nimport { setJsonMode } from \"~/utils/output.js\";\nimport { type AgentCommandArgs, runAgentAction } from \"./agent-handlers.js\";\n\nexport default defineCommand({\n\tmeta: { name: \"agent\", description: \"Agent management\" },\n\targs: {\n\t\taction: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription:\n\t\t\t\t\"Action: register, status, set-status, capabilities, me, heartbeat, list, identity, voice\",\n\t\t\trequired: false,\n\t\t},\n\t\tagentId: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Action-dependent value (agent ID, status, or transcript)\",\n\t\t\trequired: false,\n\t\t},\n\t\tname: { type: \"positional\", description: \"Display name\", required: false },\n\t\trole: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Role: zoe, admin, zeno\",\n\t\t\trequired: false,\n\t\t},\n\t\taddress: { type: \"string\", description: \"Zenon address\" },\n\t\twallet: { type: \"string\", description: \"Wallet name\" },\n\t\ttask: { type: \"string\", description: \"Current task ID\" },\n\t\tlimit: { type: \"string\", description: \"Limit agents returned for list\" },\n\t\tcapabilities: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Comma-separated capability list\",\n\t\t},\n\t\tset: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Set capabilities for capabilities action\",\n\t\t},\n\t\tjson: { type: \"boolean\", description: \"Output JSON\", default: false },\n\t\taudioUrl: { type: \"string\", description: \"Audio URL for voice announcements\" },\n\t\tcontextType: { type: \"string\", description: \"Context type for voice (default: status_update)\" },\n\t\thost: { type: \"string\", description: \"SpacetimeDB host\" },\n\t\tmodule: { type: \"string\", description: \"Module name\" },\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) setJsonMode(true);\n\n\t\tif (!args.action) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe agent\",\n\t\t\t\tdescription: \"Agent lifecycle and identity commands\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe agent <action> [options]\",\n\t\t\t\t\t'probe agent register agent-1 \"Builder\" zeno --wallet my-wallet',\n\t\t\t\t\t\"probe agent set-status working --task 42\",\n\t\t\t\t\t'probe agent capabilities --set \"gh,coding,review\"',\n\t\t\t\t\t\"probe agent heartbeat\",\n\t\t\t\t\t'probe agent voice \"Hello from Zoe\" --audioUrl https://audio.zenon.red/voice/zoe/123.mp3',\n\t\t\t\t],\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"register <agentId> <name> [role]\",\n\t\t\t\t\t\tdetail: \"Register a new agent identity\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"status\", detail: \"Show current agent status\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"set-status <online|offline|working|busy>\",\n\t\t\t\t\t\tdetail: \"Update current agent status\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"capabilities --set <list>\",\n\t\t\t\t\t\tdetail: \"Set capabilities for authenticated agent\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"me\", detail: \"Show current authenticated agent profile\" },\n\t\t\t\t\t{ name: \"heartbeat\", detail: \"Send heartbeat only\" },\n\t\t\t\t\t{ name: \"list\", detail: \"List online agents\" },\n\t\t\t\t\t{ name: \"identity\", detail: \"Show current authenticated identity\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"voice <transcript> --audioUrl <url>\",\n\t\t\t\t\t\tdetail: \"Submit a voice announcement (BYO audio URL)\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--wallet\", detail: \"Wallet to use for authenticated calls\" },\n\t\t\t\t\t{ name: \"--address\", detail: \"Zenon address for register\" },\n\t\t\t\t\t{ name: \"--task\", detail: \"Task ID required with status working\" },\n\t\t\t\t\t{ name: \"--limit\", detail: \"Max agents returned for list\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--capabilities\",\n\t\t\t\t\t\tdetail: \"Comma-separated capabilities for register/status\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--set\",\n\t\t\t\t\t\tdetail: \"Comma-separated capabilities for capabilities action\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--audioUrl\",\n\t\t\t\t\t\tdetail: \"Audio URL for voice announcements (required)\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--contextType\",\n\t\t\t\t\t\tdetail: \"Context type for voice (default: status_update)\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--host, --module\",\n\t\t\t\t\t\tdetail: \"Nexus SpacetimeDB target overrides\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tnotes: [\n\t\t\t\t\t\"Valid register roles: zeno (default), zoe, admin. Non-whitelisted identities cannot register as zoe/admin.\",\n\t\t\t\t\t\"Use `probe task list` to discover task IDs before `probe agent set-status working --task <id>`.\",\n\t\t\t\t\t\"`probe agent status` shows current status; `probe agent set-status <online|offline|working|busy>` updates status.\",\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tawait runAgentAction(args as AgentCommandArgs);\n\t},\n});\n","import { defineCommand } from \"citty\";\nimport {\n\tCommandContext,\n\tcallReducer,\n\ttype DiscoveredTask,\n\twithAuth,\n} from \"~/utils/context.js\";\nimport { printHelp } from \"~/utils/help.js\";\nimport { error, isJsonMode, setJsonMode, success } from \"~/utils/output.js\";\nimport { formatTimestamp, toMicros } from \"~/utils/time.js\";\nimport { toonList } from \"~/utils/toon.js\";\n\nconst toDiscoveryDecision = (input: string) => {\n\tconst value = input.toLowerCase();\n\tif (value === \"approve\") return { tag: \"ApproveAsTask\" };\n\tif (value === \"reject\") return { tag: \"Reject\" };\n\tif (value === \"escalate_to_idea\") return { tag: \"EscalateToIdea\" };\n\treturn null;\n};\n\nconst discoveryStatusTag = (status: unknown): string => {\n\tif (status && typeof status === \"object\" && \"tag\" in status) {\n\t\treturn String((status as { tag: string }).tag);\n\t}\n\treturn String(status);\n};\n\nconst discoveryStatusDisplay = (status: unknown): string => {\n\tconst tag = discoveryStatusTag(status);\n\tconst map: Record<string, string> = {\n\t\tPendingReview: \"pending_review\",\n\t\tApproved: \"approved\",\n\t\tRejected: \"rejected\",\n\t\tEscalatedToIdea: \"escalated_to_idea\",\n\t};\n\treturn map[tag] ?? tag;\n};\n\nexport default defineCommand({\n\tmeta: { name: \"discover\", description: \"Discovered task management\" },\n\targs: {\n\t\taction: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Action: report, review, list, get\",\n\t\t\trequired: false,\n\t\t},\n\t\tid: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Discovered task ID\",\n\t\t\trequired: false,\n\t\t},\n\t\tdecision: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Decision: approve, reject, escalate_to_idea\",\n\t\t\trequired: false,\n\t\t},\n\t\ttask: { type: \"string\", description: \"Current task ID\" },\n\t\tproject: { type: \"string\", description: \"Project ID\" },\n\t\ttitle: { type: \"string\", description: \"Task title\" },\n\t\ttype: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Task type: bug, improvement, feature\",\n\t\t},\n\t\tseverity: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Severity: low, medium, high, critical\",\n\t\t},\n\t\tstatus: { type: \"string\", description: \"Filter by status\" },\n\t\tlimit: { type: \"string\", description: \"Limit discovered tasks returned\" },\n\t\tdescription: { type: \"string\", description: \"Description\" },\n\t\treason: { type: \"string\", description: \"Rejection reason\" },\n\t\twallet: { type: \"string\", description: \"Wallet name\" },\n\t\tjson: { type: \"boolean\", description: \"Output JSON\", default: false },\n\t\thost: { type: \"string\", description: \"SpacetimeDB host\" },\n\t\tmodule: { type: \"string\", description: \"Module name\" },\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) setJsonMode(true);\n\n\t\tif (!args.action) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe discover\",\n\t\t\t\tdescription: \"Discovered task reporting and review\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe discover <action> [options]\",\n\t\t\t\t\t'probe discover report --task 12 --project 1 --title \"Fix parse\"',\n\t\t\t\t\t\"probe discover review 9 approve\",\n\t\t\t\t],\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"report\",\n\t\t\t\t\t\tdetail: \"Report a discovered task from current work\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"review <id> <approve|reject|escalate_to_idea>\",\n\t\t\t\t\t\tdetail: \"Approve, reject, or escalate discovery\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"list\", detail: \"List discovered tasks\" },\n\t\t\t\t\t{ name: \"get <id>\", detail: \"Show one discovered task\" },\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--task, --project, --title\", detail: \"Required for report\" },\n\t\t\t\t\t{ name: \"--type\", detail: \"Task type: bug, improvement, feature\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--severity\",\n\t\t\t\t\t\tdetail: \"Severity: low, medium, high, critical\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"--reason\", detail: \"Reason for rejection/escalation\" },\n\t\t\t\t\t{ name: \"--limit\", detail: \"Max discovered tasks returned for list\" },\n\t\t\t\t\t{ name: \"--wallet\", detail: \"Wallet to use for authenticated calls\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--host, --module\",\n\t\t\t\t\t\tdetail: \"Nexus SpacetimeDB target overrides\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tnotes: [\n\t\t\t\t\t\"Find current task IDs with `probe task list` and project IDs with `probe project list`.\",\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst action = args.action;\n\n\t\ttry {\n\t\t\tswitch (action) {\n\t\t\t\tcase \"report\": {\n\t\t\t\t\tif (!args.task || !args.project || !args.title) {\n\t\t\t\t\t\terror(\"ARGS_REQUIRED\", \"--task, --project, and --title required\");\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"discoverTask\", {\n\t\t\t\t\t\t\t\t\tcurrentTaskId: BigInt(args.task!),\n\t\t\t\t\t\t\t\t\tprojectId: BigInt(args.project!),\n\t\t\t\t\t\t\t\t\ttitle: args.title,\n\t\t\t\t\t\t\t\t\tdescription: args.description || \"\",\n\t\t\t\t\t\t\t\t\tpriority: 5,\n\t\t\t\t\t\t\t\t\ttaskType: args.type || \"improvement\",\n\t\t\t\t\t\t\t\t\tseverity: args.severity || \"medium\",\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\tsuccess({ reported: true, title: args.title });\n\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\ttoonList(\"discovery_reported\", [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttitle: args.title,\n\t\t\t\t\t\t\t\t\t\ttaskId: args.task,\n\t\t\t\t\t\t\t\t\t\tprojectId: args.project,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"review\": {\n\t\t\t\t\tconst discId = args.id;\n\t\t\t\t\tconst decisionInput = args.decision;\n\t\t\t\t\tif (!discId || !decisionInput)\n\t\t\t\t\t\terror(\"ARGS_REQUIRED\", \"ID and decision required\");\n\n\t\t\t\t\tconst decision = decisionInput.toLowerCase();\n\n\t\t\t\t\tconst validDecisions = [\"approve\", \"reject\", \"escalate_to_idea\"];\n\t\t\t\t\tif (!validDecisions.includes(decision)) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"INVALID_DECISION\",\n\t\t\t\t\t\t\t`Invalid decision: ${decisionInput}. Use: ${validDecisions.join(\", \")}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst decisionValue = toDiscoveryDecision(decision);\n\t\t\t\t\tif (!decisionValue) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"INVALID_DECISION\",\n\t\t\t\t\t\t\t`Invalid decision: ${decisionInput}. Use: ${validDecisions.join(\", \")}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"reviewDiscoveredTask\", {\n\t\t\t\t\t\t\t\t\tdiscoveryId: BigInt(discId),\n\t\t\t\t\t\t\t\t\tdecision: decisionValue,\n\t\t\t\t\t\t\t\t\treason: args.reason || undefined,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\tsuccess({ reviewed: true, id: discId, decision });\n\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\ttoonList(\"discovery_reviewed\", [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: discId,\n\t\t\t\t\t\t\t\t\t\tdecision,\n\t\t\t\t\t\t\t\t\t\treason: args.reason || \"\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"list\": {\n\t\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\t\thost: args.host,\n\t\t\t\t\t\tmodule: args.module,\n\t\t\t\t\t});\n\t\t\t\t\tlet discovered = ctx.iter<DiscoveredTask>(\"discovered_tasks\");\n\t\t\t\t\tconst limit = args.limit ? parseInt(args.limit, 10) : undefined;\n\n\t\t\t\t\tif (limit !== undefined && (!Number.isFinite(limit) || limit <= 0)) {\n\t\t\t\t\t\terror(\"INVALID_LIMIT\", \"--limit must be a positive integer\");\n\t\t\t\t\t}\n\n\t\t\t\t\tif (args.status) {\n\t\t\t\t\t\tconst filter = args.status.toLowerCase().replace(/[_\\s]/g, \"\");\n\t\t\t\t\t\tdiscovered = discovered.filter(\n\t\t\t\t\t\t\t(d) =>\n\t\t\t\t\t\t\t\tdiscoveryStatusDisplay(d.status).replace(/[_\\s]/g, \"\") ===\n\t\t\t\t\t\t\t\tfilter,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tdiscovered = discovered.sort((a, b) => {\n\t\t\t\t\t\tconst aMicros = toMicros(a.createdAt);\n\t\t\t\t\t\tconst bMicros = toMicros(b.createdAt);\n\t\t\t\t\t\tif (aMicros !== bMicros) return bMicros > aMicros ? 1 : -1;\n\t\t\t\t\t\tif (a.id === b.id) return 0;\n\t\t\t\t\t\treturn b.id > a.id ? 1 : -1;\n\t\t\t\t\t});\n\t\t\t\t\tif (limit !== undefined) discovered = discovered.slice(0, limit);\n\n\t\t\t\t\tsuccess({ discoveredTasks: discovered, count: discovered.length });\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\n\t\t\t\t\t\t\t\t\"discovered_tasks\",\n\t\t\t\t\t\t\t\tdiscovered.map((d) => ({\n\t\t\t\t\t\t\t\t\tid: d.id.toString(),\n\t\t\t\t\t\t\t\t\ttitle: d.title,\n\t\t\t\t\t\t\t\t\ttaskType: d.taskType,\n\t\t\t\t\t\t\t\t\tseverity: d.severity,\n\t\t\t\t\t\t\t\t\tstatus: discoveryStatusDisplay(d.status),\n\t\t\t\t\t\t\t\t\tprojectId: d.projectId,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"get\": {\n\t\t\t\t\tconst discoveryId = args.id;\n\t\t\t\t\tif (!discoveryId)\n\t\t\t\t\t\terror(\"DISCOVERY_ID_REQUIRED\", \"Discovery ID required\");\n\n\t\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\t\thost: args.host,\n\t\t\t\t\t\tmodule: args.module,\n\t\t\t\t\t});\n\t\t\t\t\tconst discovery = ctx\n\t\t\t\t\t\t.iter<DiscoveredTask>(\"discovered_tasks\")\n\t\t\t\t\t\t.find((d) => d.id.toString() === discoveryId);\n\t\t\t\t\tif (!discovery)\n\t\t\t\t\t\terror(\"DISCOVERY_NOT_FOUND\", `Discovery not found: ${discoveryId}`);\n\n\t\t\t\t\tsuccess(discovery);\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\"discovered_task\", [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: discovery.id.toString(),\n\t\t\t\t\t\t\t\t\ttitle: discovery.title,\n\t\t\t\t\t\t\t\t\tstatus: discoveryStatusDisplay(discovery.status),\n\t\t\t\t\t\t\t\t\ttaskType: discovery.taskType,\n\t\t\t\t\t\t\t\t\tseverity: discovery.severity,\n\t\t\t\t\t\t\t\t\tpriority: discovery.priority,\n\t\t\t\t\t\t\t\t\tprojectId: discovery.projectId.toString(),\n\t\t\t\t\t\t\t\t\tcurrentTaskId: discovery.currentTaskId.toString(),\n\t\t\t\t\t\t\t\t\tdescription: discovery.description,\n\t\t\t\t\t\t\t\t\treviewedBy: discovery.reviewedBy || \"\",\n\t\t\t\t\t\t\t\t\treviewedAt: discovery.reviewedAt\n\t\t\t\t\t\t\t\t\t\t? formatTimestamp(discovery.reviewedAt)\n\t\t\t\t\t\t\t\t\t\t: \"\",\n\t\t\t\t\t\t\t\t\trejectionReason: discovery.rejectionReason || \"\",\n\t\t\t\t\t\t\t\t\tcreatedTaskId: discovery.createdTaskId\n\t\t\t\t\t\t\t\t\t\t? discovery.createdTaskId.toString()\n\t\t\t\t\t\t\t\t\t\t: \"\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault:\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"INVALID_ACTION\",\n\t\t\t\t\t\t`Invalid action: ${action}`,\n\t\t\t\t\t\t\"Use: report, review, list, get\",\n\t\t\t\t\t);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\terror(\"CONNECTION_ERROR\", message);\n\t\t}\n\t},\n});\n","import { defineCommand } from \"citty\";\nimport {\n\tCommandContext,\n\tcallReducer,\n\ttype EvaluationDimension,\n\ttype Idea,\n\twithAuth,\n} from \"~/utils/context.js\";\nimport { IdeaStatus } from \"~/utils/enums.js\";\nimport { printHelp } from \"~/utils/help.js\";\nimport { error, isJsonMode, setJsonMode, success } from \"~/utils/output.js\";\nimport { toMicros } from \"~/utils/time.js\";\nimport { toonList } from \"~/utils/toon.js\";\n\nconst SCORE_FLAGS = [\n\t[\"ecosystem-impact\", \"ecosystem_impact\"],\n\t[\"implementation-readiness\", \"implementation_readiness\"],\n\t[\"dependency-independence\", \"dependency_independence\"],\n\t[\"documentation-leverage\", \"documentation_leverage\"],\n\t[\"maintenance-sustainability\", \"maintenance_sustainability\"],\n\t[\"agent-capability-fit\", \"agent_capability_fit\"],\n\t[\"execution-clarity\", \"execution_clarity\"],\n] as const;\n\ntype DimensionScoreInput = { dimension: string; score: number };\n\nfunction normalizeScore(rawScore: unknown, label: string): number {\n\tconst score = Number(rawScore);\n\tif (!Number.isInteger(score)) {\n\t\terror(\"INVALID_SCORES\", `Score for '${label}' must be an integer`);\n\t}\n\treturn score;\n}\n\nfunction validateDimensionScores(\n\tscores: DimensionScoreInput[],\n\tdimensions: EvaluationDimension[],\n): void {\n\tconst activeDimensions = dimensions\n\t\t.filter((d) => d.active)\n\t\t.sort((a, b) => a.sortOrder - b.sortOrder);\n\tconst scoreMap = new Map(scores.map((s) => [s.dimension, s.score]));\n\n\tfor (const dim of activeDimensions) {\n\t\tif (!scoreMap.has(dim.name)) {\n\t\t\terror(\n\t\t\t\t\"MISSING_DIMENSION\",\n\t\t\t\t`Missing score for dimension: ${dim.label || dim.name}`,\n\t\t\t);\n\t\t}\n\t\tconst score = scoreMap.get(dim.name)!;\n\t\tif (score < dim.minScore || score > dim.maxScore) {\n\t\t\terror(\n\t\t\t\t\"INVALID_SCORE\",\n\t\t\t\t`Score for '${dim.name}' must be between ${dim.minScore} and ${dim.maxScore}`,\n\t\t\t);\n\t\t}\n\t}\n\n\tconst activeNames = new Set(activeDimensions.map((d) => d.name));\n\tfor (const score of scores) {\n\t\tif (!activeNames.has(score.dimension)) {\n\t\t\terror(\"UNKNOWN_DIMENSION\", `Unknown dimension: ${score.dimension}`);\n\t\t}\n\t}\n}\n\nfunction addScore(\n\tscores: Map<string, DimensionScoreInput>,\n\tdimension: string,\n\trawScore: unknown,\n): void {\n\tconst normalizedDimension = dimension.trim().replaceAll(\"-\", \"_\");\n\tif (!normalizedDimension) {\n\t\terror(\"INVALID_SCORES\", \"Dimension names cannot be empty\");\n\t}\n\tif (scores.has(normalizedDimension)) {\n\t\terror(\n\t\t\t\"INVALID_SCORES\",\n\t\t\t`Dimension '${normalizedDimension}' was provided more than once`,\n\t\t);\n\t}\n\tscores.set(normalizedDimension, {\n\t\tdimension: normalizedDimension,\n\t\tscore: normalizeScore(rawScore, normalizedDimension),\n\t});\n}\n\nfunction parseScorePairs(rawValue: unknown): Array<[string, string]> {\n\tif (rawValue === undefined) return [];\n\tconst values = Array.isArray(rawValue) ? rawValue : [rawValue];\n\treturn values.flatMap((value) =>\n\t\tString(value)\n\t\t\t.split(\",\")\n\t\t\t.map((part) => part.trim())\n\t\t\t.filter(Boolean)\n\t\t\t.map((part) => {\n\t\t\t\tconst separator = part.indexOf(\"=\");\n\t\t\t\tif (separator <= 0 || separator === part.length - 1) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"INVALID_SCORES\",\n\t\t\t\t\t\t\"--score entries must use dimension=value syntax\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn [part.slice(0, separator), part.slice(separator + 1)] as [\n\t\t\t\t\tstring,\n\t\t\t\t\tstring,\n\t\t\t\t];\n\t\t\t}),\n\t);\n}\n\nfunction buildDimensionScores(args: Record<string, unknown>): DimensionScoreInput[] {\n\tconst scores = new Map<string, DimensionScoreInput>();\n\n\tfor (const [flag, dimension] of SCORE_FLAGS) {\n\t\tif (args[flag] !== undefined) {\n\t\t\taddScore(scores, dimension, args[flag]);\n\t\t}\n\t}\n\n\tfor (const [dimension, rawScore] of parseScorePairs(args.score)) {\n\t\taddScore(scores, dimension, rawScore);\n\t}\n\n\tif (scores.size === 0) {\n\t\terror(\n\t\t\t\"ARGS_REQUIRED\",\n\t\t\t\"Provide dimension scores with score flags or --score dimension=value\",\n\t\t);\n\t}\n\n\treturn [...scores.values()];\n}\n\nexport default defineCommand({\n\tmeta: { name: \"idea\", description: \"Idea management\" },\n\targs: {\n\t\taction: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Action: list, propose, vote, get, dimensions\",\n\t\t\trequired: false,\n\t\t},\n\t\tid: { type: \"positional\", description: \"Idea ID\", required: false },\n\t\ttitle: { type: \"string\", description: \"Idea title\" },\n\t\tcategory: { type: \"string\", description: \"Category\" },\n\t\tdescription: { type: \"string\", description: \"Description\" },\n\t\tstatus: { type: \"string\", description: \"Filter by status\" },\n\t\tlimit: { type: \"string\", description: \"Limit ideas returned\" },\n\t\t\"ecosystem-impact\": { type: \"string\", description: \"Ecosystem Impact score\" },\n\t\t\"implementation-readiness\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Implementation Readiness score\",\n\t\t},\n\t\t\"dependency-independence\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Dependency Independence score\",\n\t\t},\n\t\t\"documentation-leverage\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Documentation Leverage score\",\n\t\t},\n\t\t\"maintenance-sustainability\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Maintenance Sustainability score\",\n\t\t},\n\t\t\"agent-capability-fit\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Agent Capability Fit score\",\n\t\t},\n\t\t\"execution-clarity\": { type: \"string\", description: \"Execution Clarity score\" },\n\t\tscore: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Additional dimension score as name=value; repeatable\",\n\t\t\tmultiple: true,\n\t\t},\n\t\twallet: { type: \"string\", description: \"Wallet name\" },\n\t\tjson: { type: \"boolean\", description: \"Output JSON\", default: false },\n\t\thost: { type: \"string\", description: \"SpacetimeDB host\" },\n\t\tmodule: { type: \"string\", description: \"Module name\" },\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) setJsonMode(true);\n\n\t\tif (!args.action) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe idea\",\n\t\t\t\tdescription: \"Idea discovery, review, and voting\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe idea <action> [options]\",\n\t\t\t\t\t\"probe idea list --status voting\",\n\t\t\t\t\t\"probe idea dimensions\",\n\t\t\t\t\t\"probe idea vote 42 --ecosystem-impact 8 --execution-clarity 9 --implementation-readiness 7\",\n\t\t\t\t],\n\t\t\t\tactions: [\n\t\t\t\t\t{ name: \"list\", detail: \"List ideas with optional filters\" },\n\t\t\t\t\t{ name: \"get <id>\", detail: \"Show one idea\" },\n\t\t\t\t\t{ name: \"dimensions\", detail: \"List active evaluation dimensions\" },\n\t\t\t\t\t{ name: \"propose\", detail: \"Propose a new idea\" },\n\t\t\t\t\t{ name: \"vote <id>\", detail: \"Vote on an idea with dimension scores\" },\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--title\", detail: \"Idea title for propose\" },\n\t\t\t\t\t{ name: \"--description\", detail: \"Idea description for propose\" },\n\t\t\t\t\t{ name: \"--category\", detail: \"Idea category for propose/list\" },\n\t\t\t\t\t{ name: \"--ecosystem-impact\", detail: \"Ecosystem impact score\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--implementation-readiness\",\n\t\t\t\t\t\tdetail: \"Implementation readiness score\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--dependency-independence\",\n\t\t\t\t\t\tdetail: \"Dependency independence score\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--documentation-leverage\",\n\t\t\t\t\t\tdetail: \"Documentation leverage score\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--maintenance-sustainability\",\n\t\t\t\t\t\tdetail: \"Maintenance sustainability score\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--agent-capability-fit\",\n\t\t\t\t\t\tdetail: \"Agent capability fit score\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"--execution-clarity\", detail: \"Execution clarity score\" },\n\t\t\t\t\t{ name: \"--score\", detail: \"Additional dimension score as name=value; repeatable\" },\n\t\t\t\t\t{ name: \"--status\", detail: \"Status filter for list\" },\n\t\t\t\t\t{ name: \"--limit\", detail: \"Max ideas returned for list\" },\n\t\t\t\t\t{ name: \"--wallet\", detail: \"Wallet to use for authenticated calls\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--host, --module\",\n\t\t\t\t\t\tdetail: \"Nexus SpacetimeDB target overrides\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tnotes: [\n\t\t\t\t\t\"Find idea IDs with `probe idea list` before using get/vote.\",\n\t\t\t\t\t\"Use `probe idea dimensions` to list active score dimensions.\",\n\t\t\t\t\t\"All active dimensions are required. Use explicit flags for default dimensions and repeatable --score name=value for custom dimensions.\",\n\t\t\t\t\t\"If a missing-dimension error names a dimension without a dedicated flag, use --score and consider updating Probe.\",\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst action = args.action;\n\n\t\ttry {\n\t\t\tswitch (action) {\n\t\t\t\tcase \"list\": {\n\t\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\t\thost: args.host,\n\t\t\t\t\t\tmodule: args.module,\n\t\t\t\t\t});\n\t\t\t\t\tlet ideas = ctx.iter<Idea>(\"ideas\");\n\t\t\t\t\tconst limit = args.limit ? parseInt(args.limit, 10) : undefined;\n\n\t\t\t\t\tif (limit !== undefined && (!Number.isFinite(limit) || limit <= 0)) {\n\t\t\t\t\t\terror(\"INVALID_LIMIT\", \"--limit must be a positive integer\");\n\t\t\t\t\t}\n\n\t\t\t\t\tif (args.status)\n\t\t\t\t\t\tideas = ideas.filter((i) =>\n\t\t\t\t\t\t\tIdeaStatus.matches(i.status, args.status!),\n\t\t\t\t\t\t);\n\t\t\t\t\tif (args.category)\n\t\t\t\t\t\tideas = ideas.filter((i) => i.category === args.category);\n\t\t\t\t\tideas = ideas.sort((a, b) => {\n\t\t\t\t\t\tconst aMicros = toMicros(a.createdAt);\n\t\t\t\t\t\tconst bMicros = toMicros(b.createdAt);\n\t\t\t\t\t\tif (aMicros !== bMicros) return bMicros > aMicros ? 1 : -1;\n\t\t\t\t\t\tif (a.id === b.id) return 0;\n\t\t\t\t\t\treturn b.id > a.id ? 1 : -1;\n\t\t\t\t\t});\n\t\t\t\t\tif (limit !== undefined) ideas = ideas.slice(0, limit);\n\n\t\t\t\t\tsuccess({ ideas, count: ideas.length });\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\n\t\t\t\t\t\t\t\t\"ideas\",\n\t\t\t\t\t\t\t\tideas.map((i) => ({\n\t\t\t\t\t\t\t\t\tid: i.id.toString(),\n\t\t\t\t\t\t\t\t\ttitle: i.title,\n\t\t\t\t\t\t\t\t\tcategory: i.category,\n\t\t\t\t\t\t\t\t\tstatus: IdeaStatus.display(i.status),\n\t\t\t\t\t\t\t\t\tvotes: `${i.totalVotes}/${i.quorum}`,\n\t\t\t\t\t\t\t\t\tup: i.upVotes,\n\t\t\t\t\t\t\t\t\tveto: i.vetoCount,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"get\": {\n\t\t\t\t\tconst ideaId = args.id;\n\t\t\t\t\tif (!ideaId) error(\"IDEA_ID_REQUIRED\", \"Idea ID required\");\n\n\t\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\t\thost: args.host,\n\t\t\t\t\t\tmodule: args.module,\n\t\t\t\t\t});\n\t\t\t\t\tconst idea = ctx\n\t\t\t\t\t\t.iter<Idea>(\"ideas\")\n\t\t\t\t\t\t.find((i) => i.id.toString() === ideaId);\n\t\t\t\t\tif (!idea) error(\"IDEA_NOT_FOUND\", `Idea not found: ${ideaId}`);\n\n\t\t\t\t\t\tsuccess(idea);\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\"idea\", [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: idea.id.toString(),\n\t\t\t\t\t\t\t\t\ttitle: idea.title,\n\t\t\t\t\t\t\t\t\tcategory: idea.category,\n\t\t\t\t\t\t\t\t\tstatus: IdeaStatus.display(idea.status),\n\t\t\t\t\t\t\t\t\ttotalVotes: idea.totalVotes,\n\t\t\t\t\t\t\t\t\tquorum: idea.quorum,\n\t\t\t\t\t\t\t\t\tupVotes: idea.upVotes,\n\t\t\t\t\t\t\t\t\tdownVotes: idea.downVotes,\n\t\t\t\t\t\t\t\t\tvetoCount: idea.vetoCount,\n\t\t\t\t\t\t\t\t\tapprovalThreshold: idea.approvalThreshold,\n\t\t\t\t\t\t\t\t\tvetoThreshold: idea.vetoThreshold,\n\t\t\t\t\t\t\t\t\tcomputedScore: idea.computedScore,\n\t\t\t\t\t\t\t\t\tdescription: idea.description,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"dimensions\": {\n\t\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\t\thost: args.host,\n\t\t\t\t\t\tmodule: args.module,\n\t\t\t\t\t});\n\t\t\t\t\tconst dimensions = ctx\n\t\t\t\t\t\t.iter<EvaluationDimension>(\"evaluation_dimensions\")\n\t\t\t\t\t\t.filter((dimension) => dimension.active)\n\t\t\t\t\t\t.sort((a, b) => a.sortOrder - b.sortOrder);\n\n\t\t\t\t\tsuccess({ dimensions, count: dimensions.length });\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\n\t\t\t\t\t\t\t\t\"evaluation_dimensions\",\n\t\t\t\t\t\t\t\tdimensions.map((dimension) => ({\n\t\t\t\t\t\t\t\t\tname: dimension.name,\n\t\t\t\t\t\t\t\t\tlabel: dimension.label,\n\t\t\t\t\t\t\t\t\tweight: dimension.weight,\n\t\t\t\t\t\t\t\t\trange: `${dimension.minScore}-${dimension.maxScore}`,\n\t\t\t\t\t\t\t\t\tdescription: dimension.description,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"propose\": {\n\t\t\t\t\tif (!args.title) error(\"ARGS_REQUIRED\", \"Title required\");\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"proposeIdea\", {\n\t\t\t\t\t\t\t\t\ttitle: args.title,\n\t\t\t\t\t\t\t\t\tdescription: args.description || \"\",\n\t\t\t\t\t\t\t\t\tcategory: args.category || \"general\",\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\tsuccess({ proposed: true, title: args.title });\n\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\ttoonList(\"idea_proposed\", [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttitle: args.title,\n\t\t\t\t\t\t\t\t\t\tcategory: args.category || \"general\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"vote\": {\n\t\t\t\t\tconst ideaId = args.id;\n\t\t\t\t\tif (!ideaId) error(\"ARGS_REQUIRED\", \"Idea ID required\");\n\t\t\t\t\tconst dimensionScores = buildDimensionScores(args);\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\t\tconst activeDimensions = ctx.iter<EvaluationDimension>(\n\t\t\t\t\t\t\t\t\t\"evaluation_dimensions\",\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tvalidateDimensionScores(dimensionScores, activeDimensions);\n\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"voteIdea\", {\n\t\t\t\t\t\t\t\t\tideaId: BigInt(ideaId),\n\t\t\t\t\t\t\t\t\tscores: dimensionScores,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\tsuccess({ voted: true, ideaId, scores: dimensionScores });\n\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\ttoonList(\"idea_voted\", [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tideaId,\n\t\t\t\t\t\t\t\t\t\tscores: JSON.stringify(dimensionScores),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault:\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"INVALID_ACTION\",\n\t\t\t\t\t\t`Invalid action: ${action}`,\n\t\t\t\t\t\t\"Use: list, propose, vote, get, dimensions\",\n\t\t\t\t\t);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\terror(\"CONNECTION_ERROR\", message);\n\t\t}\n\t},\n});\n","import type { MessageType as MessageTypeTag } from \"~/module_bindings/types.js\";\nimport {\n\ttype Channel,\n\tCommandContext,\n\tcallReducer,\n\ttype Message,\n\ttype Project,\n\ttype ProjectMessage,\n\twithAuth,\n} from \"~/utils/context.js\";\nimport { MessageType } from \"~/utils/enums.js\";\nimport { error, isJsonMode, success } from \"~/utils/output.js\";\nimport { formatTimestamp, toMicros } from \"~/utils/time.js\";\nimport { toonList } from \"~/utils/toon.js\";\n\nexport interface MessageCommandArgs {\n\taction?: string;\n\ttarget?: string;\n\tcontent?: string;\n\ttype?: string;\n\tcontext?: string;\n\tlimit?: string;\n\twallet?: string;\n\thost?: string;\n\tmodule?: string;\n}\n\nconst isNumeric = (str: string): boolean => /^\\d+$/.test(str);\nconst matchesContext = (\n\tmessage: Message | ProjectMessage,\n\tcontext?: string,\n): boolean => {\n\tif (!context) return true;\n\tconst normalized = context.trim();\n\tif (!normalized) return true;\n\treturn (\n\t\tmessage.id.toString() === normalized ||\n\t\t(message.contextId || \"\") === normalized\n\t);\n};\n\nconst isUserMessage = (messageType: MessageTypeTag): boolean =>\n\tMessageType.is.user(messageType);\nconst isDirectiveMessage = (messageType: MessageTypeTag): boolean =>\n\tMessageType.is.directive(messageType);\n\nexport const runMessageAction = async (\n\targs: MessageCommandArgs,\n): Promise<void> => {\n\tconst action = args.action;\n\tif (!action) {\n\t\terror(\"ACTION_REQUIRED\", \"Message action required\");\n\t}\n\n\ttry {\n\t\tswitch (action) {\n\t\t\tcase \"list\": {\n\t\t\t\tconst targetInput = args.target;\n\t\t\t\tconst limit = parseInt(args.limit || \"20\", 10);\n\t\t\t\tif (!Number.isFinite(limit) || limit <= 0) {\n\t\t\t\t\terror(\"INVALID_LIMIT\", \"--limit must be a positive integer\");\n\t\t\t\t}\n\n\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\thost: args.host,\n\t\t\t\t\tmodule: args.module,\n\t\t\t\t});\n\t\t\t\tconst channels = ctx.iter<Channel>(\"channels\");\n\t\t\t\tconst projects = ctx.iter<Project>(\"projects\");\n\n\t\t\t\tlet messages: (Message | ProjectMessage)[] = [];\n\t\t\t\tlet targetLabel = \"all\";\n\n\t\t\t\tif (targetInput) {\n\t\t\t\t\tif (isNumeric(targetInput)) {\n\t\t\t\t\t\tconst projectId = BigInt(targetInput);\n\t\t\t\t\t\tconst projectMessages =\n\t\t\t\t\t\t\tctx.iter<ProjectMessage>(\"project_messages\");\n\t\t\t\t\t\tconst project = projects.find((p) => p.id === projectId);\n\n\t\t\t\t\t\tmessages = projectMessages\n\t\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t\t(m) =>\n\t\t\t\t\t\t\t\t\tm.projectId === projectId && isUserMessage(m.messageType),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.map((m) => ({ ...m, _type: \"project\" as const }));\n\t\t\t\t\t\ttargetLabel = project\n\t\t\t\t\t\t\t? `project:${project.name}`\n\t\t\t\t\t\t\t: `project:${projectId}`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst channel = channels.find(\n\t\t\t\t\t\t\t(c) => c.name === targetInput || c.id.toString() === targetInput,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (channel) {\n\t\t\t\t\t\t\tconst channelMessages = ctx.iter<Message>(\"messages\");\n\t\t\t\t\t\t\tmessages = channelMessages\n\t\t\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t\t\t(m) =>\n\t\t\t\t\t\t\t\t\t\tm.channelId === channel.id && isUserMessage(m.messageType),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t.map((m) => ({ ...m, _type: \"channel\" as const }));\n\t\t\t\t\t\t\ttargetLabel = `#${channel.name}`;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst channelMessages = ctx.iter<Message>(\"messages\");\n\t\t\t\t\tconst projectMessages = ctx.iter<ProjectMessage>(\"project_messages\");\n\n\t\t\t\t\tmessages = [\n\t\t\t\t\t\t...channelMessages\n\t\t\t\t\t\t\t.filter((m) => isUserMessage(m.messageType))\n\t\t\t\t\t\t\t.map((m) => ({ ...m, _type: \"channel\" as const })),\n\t\t\t\t\t\t...projectMessages\n\t\t\t\t\t\t\t.filter((m) => isUserMessage(m.messageType))\n\t\t\t\t\t\t\t.map((m) => ({ ...m, _type: \"project\" as const })),\n\t\t\t\t\t];\n\t\t\t\t}\n\n\t\t\t\tmessages = messages.filter((m) => matchesContext(m, args.context));\n\n\t\t\t\tmessages.sort((a, b) => {\n\t\t\t\t\tconst aTime = toMicros(a.createdAt);\n\t\t\t\t\tconst bTime = toMicros(b.createdAt);\n\t\t\t\t\tif (aTime < bTime) return 1;\n\t\t\t\t\tif (aTime > bTime) return -1;\n\t\t\t\t\treturn 0;\n\t\t\t\t});\n\n\t\t\t\tmessages = messages.slice(0, limit);\n\n\t\t\t\tconst channelMap = new Map(\n\t\t\t\t\tchannels.map((c) => [c.id.toString(), c.name]),\n\t\t\t\t);\n\t\t\t\tconst projectMap = new Map(\n\t\t\t\t\tprojects.map((p) => [p.id.toString(), p.name]),\n\t\t\t\t);\n\n\t\t\t\tsuccess({ messages, count: messages.length, target: targetLabel });\n\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\ttoonList(\n\t\t\t\t\t\t\t\"messages\",\n\t\t\t\t\t\t\tmessages.map((m) => {\n\t\t\t\t\t\t\t\tconst isProject = \"_type\" in m && m._type === \"project\";\n\t\t\t\t\t\t\t\tconst location = isProject\n\t\t\t\t\t\t\t\t\t? `project:${projectMap.get((m as ProjectMessage).projectId.toString()) || (m as ProjectMessage).projectId}`\n\t\t\t\t\t\t\t\t\t: `#${channelMap.get((m as Message).channelId.toString()) || (m as Message).channelId}`;\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tid: m.id.toString(),\n\t\t\t\t\t\t\t\t\tlocation,\n\t\t\t\t\t\t\t\t\tsenderId: m.senderId,\n\t\t\t\t\t\t\t\t\tcontent:\n\t\t\t\t\t\t\t\t\t\tm.content.slice(0, 50) +\n\t\t\t\t\t\t\t\t\t\t(m.content.length > 50 ? \"...\" : \"\"),\n\t\t\t\t\t\t\t\t\tmessageType: MessageType.display(m.messageType),\n\t\t\t\t\t\t\t\t\tcontextId: m.contextId || null,\n\t\t\t\t\t\t\t\t\tcreatedAt: formatTimestamp(m.createdAt),\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"directives\": {\n\t\t\t\tconst targetInput = args.target;\n\t\t\t\tconst limit = parseInt(args.limit || \"20\", 10);\n\t\t\t\tif (!Number.isFinite(limit) || limit <= 0) {\n\t\t\t\t\terror(\"INVALID_LIMIT\", \"--limit must be a positive integer\");\n\t\t\t\t}\n\n\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\thost: args.host,\n\t\t\t\t\tmodule: args.module,\n\t\t\t\t});\n\t\t\t\tconst channels = ctx.iter<Channel>(\"channels\");\n\t\t\t\tconst projects = ctx.iter<Project>(\"projects\");\n\n\t\t\t\tlet messages: (Message | ProjectMessage)[] = [];\n\t\t\t\tlet targetLabel = \"all\";\n\n\t\t\t\tif (targetInput) {\n\t\t\t\t\tif (isNumeric(targetInput)) {\n\t\t\t\t\t\tconst projectId = BigInt(targetInput);\n\t\t\t\t\t\tconst projectMessages =\n\t\t\t\t\t\t\tctx.iter<ProjectMessage>(\"project_messages\");\n\t\t\t\t\t\tconst project = projects.find((p) => p.id === projectId);\n\n\t\t\t\t\t\tmessages = projectMessages\n\t\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t\t(m) =>\n\t\t\t\t\t\t\t\t\tm.projectId === projectId &&\n\t\t\t\t\t\t\t\t\tisDirectiveMessage(m.messageType),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.map((m) => ({ ...m, _type: \"project\" as const }));\n\t\t\t\t\t\ttargetLabel = project\n\t\t\t\t\t\t\t? `project:${project.name}`\n\t\t\t\t\t\t\t: `project:${projectId}`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst channel = channels.find(\n\t\t\t\t\t\t\t(c) => c.name === targetInput || c.id.toString() === targetInput,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (channel) {\n\t\t\t\t\t\t\tconst channelMessages = ctx.iter<Message>(\"messages\");\n\t\t\t\t\t\t\tmessages = channelMessages\n\t\t\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t\t\t(m) =>\n\t\t\t\t\t\t\t\t\t\tm.channelId === channel.id &&\n\t\t\t\t\t\t\t\t\t\tisDirectiveMessage(m.messageType),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t.map((m) => ({ ...m, _type: \"channel\" as const }));\n\t\t\t\t\t\t\ttargetLabel = `#${channel.name}`;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst channelMessages = ctx.iter<Message>(\"messages\");\n\t\t\t\t\tconst projectMessages = ctx.iter<ProjectMessage>(\"project_messages\");\n\n\t\t\t\t\tmessages = [\n\t\t\t\t\t\t...channelMessages\n\t\t\t\t\t\t\t.filter((m) => isDirectiveMessage(m.messageType))\n\t\t\t\t\t\t\t.map((m) => ({ ...m, _type: \"channel\" as const })),\n\t\t\t\t\t\t...projectMessages\n\t\t\t\t\t\t\t.filter((m) => isDirectiveMessage(m.messageType))\n\t\t\t\t\t\t\t.map((m) => ({ ...m, _type: \"project\" as const })),\n\t\t\t\t\t];\n\t\t\t\t}\n\n\t\t\t\tmessages = messages.filter((m) => matchesContext(m, args.context));\n\n\t\t\t\tmessages.sort((a, b) => {\n\t\t\t\t\tconst aTime = toMicros(a.createdAt);\n\t\t\t\t\tconst bTime = toMicros(b.createdAt);\n\t\t\t\t\tif (aTime < bTime) return 1;\n\t\t\t\t\tif (aTime > bTime) return -1;\n\t\t\t\t\treturn 0;\n\t\t\t\t});\n\n\t\t\t\tmessages = messages.slice(0, limit);\n\n\t\t\t\tconst channelMap = new Map(\n\t\t\t\t\tchannels.map((c) => [c.id.toString(), c.name]),\n\t\t\t\t);\n\t\t\t\tconst projectMap = new Map(\n\t\t\t\t\tprojects.map((p) => [p.id.toString(), p.name]),\n\t\t\t\t);\n\n\t\t\t\tsuccess({ messages, count: messages.length, target: targetLabel });\n\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\ttoonList(\n\t\t\t\t\t\t\t\"directives\",\n\t\t\t\t\t\t\tmessages.map((m) => {\n\t\t\t\t\t\t\t\tconst isProject = \"_type\" in m && m._type === \"project\";\n\t\t\t\t\t\t\t\tconst location = isProject\n\t\t\t\t\t\t\t\t\t? `project:${projectMap.get((m as ProjectMessage).projectId.toString()) || (m as ProjectMessage).projectId}`\n\t\t\t\t\t\t\t\t\t: `#${channelMap.get((m as Message).channelId.toString()) || (m as Message).channelId}`;\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tid: m.id.toString(),\n\t\t\t\t\t\t\t\t\tlocation,\n\t\t\t\t\t\t\t\t\tsenderId: m.senderId,\n\t\t\t\t\t\t\t\t\tcontent:\n\t\t\t\t\t\t\t\t\t\tm.content.slice(0, 50) +\n\t\t\t\t\t\t\t\t\t\t(m.content.length > 50 ? \"...\" : \"\"),\n\t\t\t\t\t\t\t\t\tmessageType: MessageType.display(m.messageType),\n\t\t\t\t\t\t\t\t\tcontextId: m.contextId || null,\n\t\t\t\t\t\t\t\t\tcreatedAt: formatTimestamp(m.createdAt),\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"directive\": {\n\t\t\t\tconst targetInput = args.target;\n\t\t\t\tconst content = args.content;\n\t\t\t\tif (!targetInput || !content) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"ARGS_REQUIRED\",\n\t\t\t\t\t\t\"Target and directive content required. Usage: probe message directive <target> <content>\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\tif (isNumeric(targetInput)) {\n\t\t\t\t\t\t\t\tconst projectId = BigInt(targetInput);\n\t\t\t\t\t\t\t\tconst projects = ctx.iter<Project>(\"projects\");\n\t\t\t\t\t\t\t\tconst projectChannels = ctx.iter<{ projectId: bigint }>(\n\t\t\t\t\t\t\t\t\t\"project_channels\",\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tconst project = projects.find((p) => p.id === projectId);\n\t\t\t\t\t\t\t\tif (!project) {\n\t\t\t\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\t\t\t\"PROJECT_NOT_FOUND\",\n\t\t\t\t\t\t\t\t\t\t`Project '${targetInput}' not found`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst projectChannel = projectChannels.find(\n\t\t\t\t\t\t\t\t\t(pc) => pc.projectId === projectId,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (!projectChannel) {\n\t\t\t\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\t\t\t\"PROJECT_CHANNEL_NOT_FOUND\",\n\t\t\t\t\t\t\t\t\t\t`Project channel for '${targetInput}' not found`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"sendProjectMessage\", {\n\t\t\t\t\t\t\t\t\tprojectId,\n\t\t\t\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t\t\t\tmessageType: MessageType.fromString(\"directive\"),\n\t\t\t\t\t\t\t\t\tcontextId: args.context,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tsuccess({\n\t\t\t\t\t\t\t\t\tsent: true,\n\t\t\t\t\t\t\t\t\tprojectId: projectId.toString(),\n\t\t\t\t\t\t\t\t\tprojectName: project.name,\n\t\t\t\t\t\t\t\t\tmessageType: \"directive\",\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\t\ttoonList(\"directive_sent\", [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\ttarget: `project:${project.name}`,\n\t\t\t\t\t\t\t\t\t\t\t\tcontextId: args.context || null,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconst channels = ctx.iter<Channel>(\"channels\");\n\t\t\t\t\t\t\t\tconst channel = channels.find(\n\t\t\t\t\t\t\t\t\t(c) =>\n\t\t\t\t\t\t\t\t\t\tc.name === targetInput || c.id.toString() === targetInput,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (!channel) {\n\t\t\t\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\t\t\t\"CHANNEL_NOT_FOUND\",\n\t\t\t\t\t\t\t\t\t\t`Channel '${targetInput}' not found. Available: ${channels.map((c) => c.name).join(\", \")}`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"sendMessage\", {\n\t\t\t\t\t\t\t\t\tchannelId: channel.id,\n\t\t\t\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t\t\t\tmessageType: MessageType.fromString(\"directive\"),\n\t\t\t\t\t\t\t\t\tcontextId: args.context,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tsuccess({\n\t\t\t\t\t\t\t\t\tsent: true,\n\t\t\t\t\t\t\t\t\tchannelId: channel.id.toString(),\n\t\t\t\t\t\t\t\t\tchannelName: channel.name,\n\t\t\t\t\t\t\t\t\tmessageType: \"directive\",\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\t\ttoonList(\"directive_sent\", [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\ttarget: `#${channel.name}`,\n\t\t\t\t\t\t\t\t\t\t\t\tcontextId: args.context || null,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} catch (err) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"send\": {\n\t\t\t\tconst targetInput = args.target;\n\t\t\t\tconst content = args.content;\n\t\t\t\tif (!targetInput || !content) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"ARGS_REQUIRED\",\n\t\t\t\t\t\t\"Target and message content required. Usage: probe message send <target> <content>\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif ((args.type || \"user\").toLowerCase() === \"directive\") {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"INVALID_TYPE\",\n\t\t\t\t\t\t\"'directive' is not allowed with 'message send'. Use: probe message directive <target> <content>\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\tif (isNumeric(targetInput)) {\n\t\t\t\t\t\t\t\tconst projectId = BigInt(targetInput);\n\t\t\t\t\t\t\t\tconst projects = ctx.iter<Project>(\"projects\");\n\t\t\t\t\t\t\t\tconst projectChannels = ctx.iter<{ projectId: bigint }>(\n\t\t\t\t\t\t\t\t\t\"project_channels\",\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tconst project = projects.find((p) => p.id === projectId);\n\t\t\t\t\t\t\t\tif (!project) {\n\t\t\t\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\t\t\t\"PROJECT_NOT_FOUND\",\n\t\t\t\t\t\t\t\t\t\t`Project '${targetInput}' not found`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst projectChannel = projectChannels.find(\n\t\t\t\t\t\t\t\t\t(pc) => pc.projectId === projectId,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (!projectChannel) {\n\t\t\t\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\t\t\t\"PROJECT_CHANNEL_NOT_FOUND\",\n\t\t\t\t\t\t\t\t\t\t`Project channel for '${targetInput}' not found`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"sendProjectMessage\", {\n\t\t\t\t\t\t\t\t\tprojectId,\n\t\t\t\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t\t\t\tmessageType: MessageType.fromString(args.type || \"user\"),\n\t\t\t\t\t\t\t\t\tcontextId: args.context,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tsuccess({\n\t\t\t\t\t\t\t\t\tsent: true,\n\t\t\t\t\t\t\t\t\tprojectId: projectId.toString(),\n\t\t\t\t\t\t\t\t\tprojectName: project.name,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\t\ttoonList(\"message_sent\", [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\ttarget: `project:${project.name}`,\n\t\t\t\t\t\t\t\t\t\t\t\tmessageType: args.type || \"user\",\n\t\t\t\t\t\t\t\t\t\t\t\tcontextId: args.context || null,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconst channels = ctx.iter<Channel>(\"channels\");\n\t\t\t\t\t\t\t\tconst channel = channels.find(\n\t\t\t\t\t\t\t\t\t(c) =>\n\t\t\t\t\t\t\t\t\t\tc.name === targetInput || c.id.toString() === targetInput,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (!channel) {\n\t\t\t\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\t\t\t\"CHANNEL_NOT_FOUND\",\n\t\t\t\t\t\t\t\t\t\t`Channel '${targetInput}' not found. Available: ${channels.map((c) => c.name).join(\", \")}`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"sendMessage\", {\n\t\t\t\t\t\t\t\t\tchannelId: channel.id,\n\t\t\t\t\t\t\t\t\tcontent,\n\t\t\t\t\t\t\t\t\tmessageType: MessageType.fromString(args.type || \"user\"),\n\t\t\t\t\t\t\t\t\tcontextId: args.context,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tsuccess({\n\t\t\t\t\t\t\t\t\tsent: true,\n\t\t\t\t\t\t\t\t\tchannelId: channel.id.toString(),\n\t\t\t\t\t\t\t\t\tchannelName: channel.name,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\t\ttoonList(\"message_sent\", [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\ttarget: `#${channel.name}`,\n\t\t\t\t\t\t\t\t\t\t\t\tmessageType: args.type || \"user\",\n\t\t\t\t\t\t\t\t\t\t\t\tcontextId: args.context || null,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} catch (err) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"channels\": {\n\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\thost: args.host,\n\t\t\t\t\tmodule: args.module,\n\t\t\t\t});\n\t\t\t\tconst channels = ctx.iter<Channel>(\"channels\");\n\t\t\t\tconst projects = ctx.iter<Project>(\"projects\");\n\t\t\t\tconst projectChannels = ctx.iter<{ projectId: bigint }>(\n\t\t\t\t\t\"project_channels\",\n\t\t\t\t);\n\n\t\t\t\tconst projectChannelSet = new Set(\n\t\t\t\t\tprojectChannels.map((pc) => pc.projectId.toString()),\n\t\t\t\t);\n\t\t\t\tconst projectsWithChannels = projects.filter((p) =>\n\t\t\t\t\tprojectChannelSet.has(p.id.toString()),\n\t\t\t\t);\n\n\t\t\t\tsuccess({\n\t\t\t\t\tchannels,\n\t\t\t\t\tprojects: projectsWithChannels,\n\t\t\t\t\tchannelCount: channels.length,\n\t\t\t\t\tprojectCount: projectsWithChannels.length,\n\t\t\t\t});\n\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\ttoonList(\n\t\t\t\t\t\t\t\"channels\",\n\t\t\t\t\t\t\tchannels.map((c) => ({\n\t\t\t\t\t\t\t\tid: c.id.toString(),\n\t\t\t\t\t\t\t\tname: c.name,\n\t\t\t\t\t\t\t\tcreatedBy: c.createdBy,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\ttoonList(\n\t\t\t\t\t\t\t\"projects\",\n\t\t\t\t\t\t\tprojectsWithChannels.map((p) => ({\n\t\t\t\t\t\t\t\tid: p.id.toString(),\n\t\t\t\t\t\t\t\tname: p.name,\n\t\t\t\t\t\t\t\trepo: p.githubRepo,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\terror(\n\t\t\t\t\t\"INVALID_ACTION\",\n\t\t\t\t\t`Invalid action: ${action}`,\n\t\t\t\t\t\"Use: list, send, directive, directives, channels\",\n\t\t\t\t);\n\t\t}\n\t} catch (err) {\n\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\terror(\"CONNECTION_ERROR\", message);\n\t}\n};\n","import { defineCommand } from \"citty\";\nimport { printHelp } from \"~/utils/help.js\";\nimport { setJsonMode } from \"~/utils/output.js\";\nimport {\n\ttype MessageCommandArgs,\n\trunMessageAction,\n} from \"./message-handlers.js\";\n\nexport default defineCommand({\n\tmeta: { name: \"message\", description: \"Message management\" },\n\targs: {\n\t\taction: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Action: list, send, directive, directives, channels\",\n\t\t\trequired: false,\n\t\t},\n\t\ttarget: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Channel name, project ID, or message content\",\n\t\t\trequired: false,\n\t\t},\n\t\tcontent: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Message content (if target is channel/project)\",\n\t\t\trequired: false,\n\t\t},\n\t\ttype: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Message type: user, system\",\n\t\t\tdefault: \"user\",\n\t\t},\n\t\tcontext: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Thread context ID (message ID or entity ref like task:42)\",\n\t\t},\n\t\tlimit: { type: \"string\", description: \"Limit messages\", default: \"20\" },\n\t\twallet: { type: \"string\", description: \"Wallet name\" },\n\t\tjson: { type: \"boolean\", description: \"Output JSON\", default: false },\n\t\thost: { type: \"string\", description: \"SpacetimeDB host\" },\n\t\tmodule: { type: \"string\", description: \"Module name\" },\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) setJsonMode(true);\n\n\t\tif (!args.action) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe message\",\n\t\t\t\tdescription: \"Channel and project messaging commands\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe message <action> [target] [content] [options]\",\n\t\t\t\t\t\"probe message list --limit 50\",\n\t\t\t\t\t'probe message send general \"hello team\"',\n\t\t\t\t\t'probe message directive zoe \"Focus on project stability\" --context project:1',\n\t\t\t\t],\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"list [target]\",\n\t\t\t\t\t\tdetail: \"List user messages (all, channel, or project)\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"directives [target]\",\n\t\t\t\t\t\tdetail: \"List directive messages (all, channel, or project)\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"send <target> <content>\",\n\t\t\t\t\t\tdetail: \"Send to target channel/project\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"directive <target> <content>\",\n\t\t\t\t\t\tdetail: \"Send directive to target channel/project\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"channels\", detail: \"List channels and project channels\" },\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--type\",\n\t\t\t\t\t\tdetail: \"Message type: user, system (default: user)\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--context\",\n\t\t\t\t\t\tdetail: \"Optional thread context ID (message ID or entity ref)\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--limit\",\n\t\t\t\t\t\tdetail: \"Max messages returned for list (default: 20)\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"--wallet\", detail: \"Wallet to use for send\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--host, --module\",\n\t\t\t\t\t\tdetail: \"Nexus SpacetimeDB target overrides\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\texamples: [\n\t\t\t\t\t\"probe message send general hello\",\n\t\t\t\t\t'probe message directive zoe \"Pause new work\" --context project:1',\n\t\t\t\t\t\"probe message directives zoe --limit 1\",\n\t\t\t\t\t'probe message send zoe \"hello there\"',\n\t\t\t\t\t'probe message send zoe \"reviewed\" --context 123',\n\t\t\t\t\t'probe message send 1 \"project update\"',\n\t\t\t\t\t\"probe message list zoe --limit 10\",\n\t\t\t\t],\n\t\t\t\tnotes: [\n\t\t\t\t\t\"Quotes are only required when target/content contains spaces.\",\n\t\t\t\t\t\"Use `probe message channels` to discover available channel names and project IDs.\",\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tawait runMessageAction(args as MessageCommandArgs);\n\t},\n});\n","import { defineCommand } from \"citty\";\nimport {\n\tCommandContext,\n\tcallReducer,\n\ttype Project,\n\twithAuth,\n} from \"~/utils/context.js\";\nimport { ProjectStatus } from \"~/utils/enums.js\";\nimport { printHelp } from \"~/utils/help.js\";\nimport { error, isJsonMode, setJsonMode, success } from \"~/utils/output.js\";\nimport { toMicros } from \"~/utils/time.js\";\nimport { toonList } from \"~/utils/toon.js\";\n\nexport default defineCommand({\n\tmeta: { name: \"project\", description: \"Project commands\" },\n\targs: {\n\t\taction: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Action: list, get, create, status, set-status\",\n\t\t\trequired: false,\n\t\t},\n\t\tid: { type: \"positional\", description: \"Project ID\", required: false },\n\t\tvalue: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Status value for set-status: active|paused\",\n\t\t\trequired: false,\n\t\t},\n\t\tstatus: { type: \"string\", description: \"Filter by status\" },\n\t\tlimit: { type: \"string\", description: \"Limit projects returned\" },\n\t\tname: { type: \"string\", description: \"Project name\" },\n\t\tdescription: { type: \"string\", description: \"Project description\" },\n\t\t\"github-repo\": { type: \"string\", description: \"GitHub repository URL\" },\n\t\t\"source-idea\": { type: \"string\", description: \"Source idea ID\" },\n\t\twallet: { type: \"string\", description: \"Wallet name\" },\n\t\tjson: { type: \"boolean\", description: \"Output JSON\", default: false },\n\t\thost: { type: \"string\", description: \"SpacetimeDB host\" },\n\t\tmodule: { type: \"string\", description: \"Module name\" },\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) setJsonMode(true);\n\n\t\tif (!args.action) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe project\",\n\t\t\t\tdescription: \"Project listing and lookup commands\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe project <action> [options]\",\n\t\t\t\t\t\"probe project list --status active\",\n\t\t\t\t\t\"probe project get 1\",\n\t\t\t\t\t\"probe project status 1\",\n\t\t\t\t\t\"probe project set-status 1 paused --wallet admin-wallet\",\n\t\t\t\t],\n\t\t\t\tactions: [\n\t\t\t\t\t{ name: \"list\", detail: \"List projects with optional status filter\" },\n\t\t\t\t\t{ name: \"get <id>\", detail: \"Show one project by ID\" },\n\t\t\t\t\t{ name: \"create\", detail: \"Create a new project\" },\n\t\t\t\t\t{ name: \"status <id>\", detail: \"Show only project status\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"set-status <id> <active|paused>\",\n\t\t\t\t\t\tdetail: \"Update project status (admin/zoe)\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--status\", detail: \"Status filter for list: active|paused\" },\n\t\t\t\t\t{ name: \"--limit\", detail: \"Max projects returned for list\" },\n\t\t\t\t\t{ name: \"--name\", detail: \"Project name (create)\" },\n\t\t\t\t\t{ name: \"--description\", detail: \"Project description (create)\" },\n\t\t\t\t\t{ name: \"--github-repo\", detail: \"GitHub repository URL (create)\" },\n\t\t\t\t\t{ name: \"--source-idea\", detail: \"Source idea ID (create)\" },\n\t\t\t\t\t{ name: \"--wallet\", detail: \"Wallet to use for authenticated calls\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--host, --module\",\n\t\t\t\t\t\tdetail: \"Nexus SpacetimeDB target overrides\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tnotes: [\n\t\t\t\t\t\"Only admin/zoe identities can call set-status.\",\n\t\t\t\t\t\"Find idea IDs with `probe idea list` before using --source-idea.\",\n\t\t\t\t\t\"Find project IDs with `probe project list` before using get/create follow-up commands.\",\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst action = args.action;\n\n\t\ttry {\n\t\t\tswitch (action) {\n\t\t\t\tcase \"list\": {\n\t\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\t\thost: args.host,\n\t\t\t\t\t\tmodule: args.module,\n\t\t\t\t\t});\n\t\t\t\t\tlet projects = ctx.iter<Project>(\"projects\");\n\t\t\t\t\tconst limit = args.limit ? parseInt(args.limit, 10) : undefined;\n\n\t\t\t\t\tif (limit !== undefined && (!Number.isFinite(limit) || limit <= 0)) {\n\t\t\t\t\t\terror(\"INVALID_LIMIT\", \"--limit must be a positive integer\");\n\t\t\t\t\t}\n\n\t\t\t\t\tif (args.status)\n\t\t\t\t\t\tprojects = projects.filter((p) =>\n\t\t\t\t\t\t\tProjectStatus.matches(p.status, args.status as string),\n\t\t\t\t\t\t);\n\t\t\t\t\tprojects = projects.sort((a, b) => {\n\t\t\t\t\t\tconst aMicros = toMicros(a.createdAt);\n\t\t\t\t\t\tconst bMicros = toMicros(b.createdAt);\n\t\t\t\t\t\tif (aMicros !== bMicros) return bMicros > aMicros ? 1 : -1;\n\t\t\t\t\t\tif (a.id === b.id) return 0;\n\t\t\t\t\t\treturn b.id > a.id ? 1 : -1;\n\t\t\t\t\t});\n\t\t\t\t\tif (limit !== undefined) projects = projects.slice(0, limit);\n\n\t\t\t\t\tsuccess({ projects, count: projects.length });\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\n\t\t\t\t\t\t\t\t\"projects\",\n\t\t\t\t\t\t\t\tprojects.map((p) => ({\n\t\t\t\t\t\t\t\t\tid: p.id,\n\t\t\t\t\t\t\t\t\tname: p.name,\n\t\t\t\t\t\t\t\t\tstatus: ProjectStatus.display(p.status),\n\t\t\t\t\t\t\t\t\tgithubRepo: p.githubRepo,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"get\": {\n\t\t\t\t\tconst projectId = args.id;\n\t\t\t\t\tif (!projectId) error(\"PROJECT_ID_REQUIRED\", \"Project ID required\");\n\n\t\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\t\thost: args.host,\n\t\t\t\t\t\tmodule: args.module,\n\t\t\t\t\t});\n\t\t\t\t\tconst project = ctx\n\t\t\t\t\t\t.iter<Project>(\"projects\")\n\t\t\t\t\t\t.find((p) => p.id.toString() === projectId);\n\t\t\t\t\tif (!project)\n\t\t\t\t\t\terror(\"PROJECT_NOT_FOUND\", `Project not found: ${projectId}`);\n\n\t\t\t\t\tsuccess(project);\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\"project\", [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: project.id.toString(),\n\t\t\t\t\t\t\t\t\tname: project.name,\n\t\t\t\t\t\t\t\t\tstatus: ProjectStatus.display(project.status),\n\t\t\t\t\t\t\t\t\tgithubRepo: project.githubRepo,\n\t\t\t\t\t\t\t\t\tdescription: project.description,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"status\": {\n\t\t\t\t\tconst projectId = args.id;\n\t\t\t\t\tif (!projectId) error(\"PROJECT_ID_REQUIRED\", \"Project ID required\");\n\n\t\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\t\thost: args.host,\n\t\t\t\t\t\tmodule: args.module,\n\t\t\t\t\t});\n\t\t\t\t\tconst project = ctx\n\t\t\t\t\t\t.iter<Project>(\"projects\")\n\t\t\t\t\t\t.find((p) => p.id.toString() === projectId);\n\t\t\t\t\tif (!project)\n\t\t\t\t\t\terror(\"PROJECT_NOT_FOUND\", `Project not found: ${projectId}`);\n\n\t\t\t\t\tconst status = ProjectStatus.display(project.status);\n\t\t\t\t\tsuccess({ projectId, status });\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\"project_status\", [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: project.id.toString(),\n\t\t\t\t\t\t\t\t\tname: project.name,\n\t\t\t\t\t\t\t\t\tstatus,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"create\": {\n\t\t\t\t\tif (!args.name || !args[\"github-repo\"] || !args[\"source-idea\"]) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"ARGS_REQUIRED\",\n\t\t\t\t\t\t\t\"--name, --github-repo, and --source-idea required\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"createProject\", {\n\t\t\t\t\t\t\t\t\tsourceIdeaId: BigInt(args[\"source-idea\"] as string),\n\t\t\t\t\t\t\t\t\tname: args.name,\n\t\t\t\t\t\t\t\t\tgithubRepo: args[\"github-repo\"],\n\t\t\t\t\t\t\t\t\tdescription: args.description || \"\",\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\tsuccess({\n\t\t\t\t\t\t\tcreated: true,\n\t\t\t\t\t\t\tname: args.name,\n\t\t\t\t\t\t\tgithubRepo: args[\"github-repo\"],\n\t\t\t\t\t\t\tsourceIdeaId: args[\"source-idea\"],\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\ttoonList(\"project_created\", [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: args.name,\n\t\t\t\t\t\t\t\t\t\tgithubRepo: args[\"github-repo\"],\n\t\t\t\t\t\t\t\t\t\tsourceIdeaId: args[\"source-idea\"],\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase \"set-status\": {\n\t\t\t\t\tconst projectId = args.id;\n\t\t\t\t\tconst nextStatus = args.value;\n\t\t\t\t\tif (!projectId || !nextStatus) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"ARGS_REQUIRED\",\n\t\t\t\t\t\t\t\"Project ID and status required. Use: probe project set-status <id> <active|paused>\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst normalized = nextStatus.toLowerCase().replace(/[_\\s]/g, \"\");\n\t\t\t\t\tif (![\"active\", \"paused\"].includes(normalized)) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"INVALID_STATUS\",\n\t\t\t\t\t\t\t`Invalid status: ${nextStatus}. Use: active, paused`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"updateProjectStatus\", {\n\t\t\t\t\t\t\t\t\tprojectId: BigInt(projectId),\n\t\t\t\t\t\t\t\t\tstatus: ProjectStatus.fromString(nextStatus),\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tsuccess({ updated: true, projectId, status: normalized });\n\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\ttoonList(\"project_status_updated\", [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tprojectId,\n\t\t\t\t\t\t\t\t\t\tstatus: normalized,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault:\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"INVALID_ACTION\",\n\t\t\t\t\t\t`Invalid action: ${action}`,\n\t\t\t\t\t\t\"Use: list, get, create, status, set-status\",\n\t\t\t\t\t);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\terror(\"CONNECTION_ERROR\", message);\n\t\t}\n\t},\n});\n","import {\n\tCommandContext,\n\tcallReducer,\n\ttype Project,\n\ttype Task,\n\ttype TaskDependency,\n\twithAuth,\n} from \"~/utils/context.js\";\nimport { TaskStatus } from \"~/utils/enums.js\";\nimport { error, isJsonMode, success } from \"~/utils/output.js\";\nimport { toMicros } from \"~/utils/time.js\";\nimport { toonList } from \"~/utils/toon.js\";\n\nexport interface TaskCommandArgs {\n\taction?: string;\n\tid?: string;\n\tstatus?: string;\n\tproject?: string;\n\ttitle?: string;\n\tdescription?: string;\n\tpriority?: string;\n\tassigned?: boolean;\n\twallet?: string;\n\t\"github-pr-url\"?: string;\n\t\"github-issue-url\"?: string;\n\t\"add-dep\"?: string;\n\tlist?: boolean;\n\ttimeout?: string;\n\tlimit?: string;\n\thost?: string;\n\tmodule?: string;\n}\n\nconst normalizeGitHubRepoUrl = (githubRepo: string): string | undefined => {\n\tconst value = githubRepo.trim().replace(/\\.git$/i, \"\");\n\tif (!value) return undefined;\n\n\tif (/^[\\w.-]+\\/[\\w.-]+$/.test(value)) {\n\t\treturn `https://github.com/${value}`;\n\t}\n\n\tconst sshMatch = value.match(/^git@github\\.com:([\\w.-]+\\/[\\w.-]+)$/i);\n\tif (sshMatch) {\n\t\treturn `https://github.com/${sshMatch[1]}`;\n\t}\n\n\tif (value.startsWith(\"http://\") || value.startsWith(\"https://\")) {\n\t\ttry {\n\t\t\tconst parsed = new URL(value);\n\t\t\tif (parsed.hostname !== \"github.com\") return undefined;\n\t\t\tconst parts = parsed.pathname.split(\"/\").filter(Boolean);\n\t\t\tif (parts.length < 2) return undefined;\n\t\t\treturn `https://github.com/${parts[0]}/${parts[1]}`;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\treturn undefined;\n};\n\nexport const runTaskAction = async (args: TaskCommandArgs): Promise<void> => {\n\tconst action = args.action;\n\tif (!action) {\n\t\terror(\"ACTION_REQUIRED\", \"Task action required\");\n\t}\n\n\ttry {\n\t\tswitch (action) {\n\t\t\tcase \"list\": {\n\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\thost: args.host,\n\t\t\t\t\tmodule: args.module,\n\t\t\t\t});\n\t\t\t\tlet tasks = ctx.iter<Task>(\"tasks\");\n\t\t\t\tconst statusFilter = args.status;\n\t\t\t\tconst limit = args.limit ? parseInt(args.limit, 10) : undefined;\n\n\t\t\t\tif (limit !== undefined && (!Number.isFinite(limit) || limit <= 0)) {\n\t\t\t\t\terror(\"INVALID_LIMIT\", \"--limit must be a positive integer\");\n\t\t\t\t}\n\n\t\t\t\tif (statusFilter)\n\t\t\t\t\ttasks = tasks.filter((t) =>\n\t\t\t\t\t\tTaskStatus.matches(t.status, statusFilter),\n\t\t\t\t\t);\n\t\t\t\tif (args.project)\n\t\t\t\t\ttasks = tasks.filter((t) => t.projectId.toString() === args.project);\n\t\t\t\tif (args.assigned) tasks = tasks.filter((t) => t.assignedTo);\n\t\t\t\ttasks = tasks.sort((a, b) => {\n\t\t\t\t\tconst aMicros = toMicros(a.createdAt);\n\t\t\t\t\tconst bMicros = toMicros(b.createdAt);\n\t\t\t\t\tif (aMicros !== bMicros) return bMicros > aMicros ? 1 : -1;\n\t\t\t\t\tif (a.id === b.id) return 0;\n\t\t\t\t\treturn b.id > a.id ? 1 : -1;\n\t\t\t\t});\n\t\t\t\tif (limit !== undefined) tasks = tasks.slice(0, limit);\n\n\t\t\t\tsuccess({ tasks, count: tasks.length });\n\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\ttoonList(\n\t\t\t\t\t\t\t\"tasks\",\n\t\t\t\t\t\t\ttasks.map((t) => ({\n\t\t\t\t\t\t\t\tid: t.id.toString(),\n\t\t\t\t\t\t\t\ttitle: t.title,\n\t\t\t\t\t\t\t\tstatus: TaskStatus.display(t.status),\n\t\t\t\t\t\t\t\tpriority: t.priority,\n\t\t\t\t\t\t\t\tassignedTo: t.assignedTo || \"\",\n\t\t\t\t\t\t\t\tprojectId: t.projectId,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"ready\": {\n\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\thost: args.host,\n\t\t\t\t\tmodule: args.module,\n\t\t\t\t});\n\t\t\t\tconst tasks = ctx.iter<Task>(\"tasks\");\n\t\t\t\tconst deps = ctx.iter<TaskDependency>(\"task_dependencies\");\n\t\t\t\tconst taskById = new Map(tasks.map((t) => [t.id.toString(), t]));\n\t\t\t\tconst limit = args.limit ? parseInt(args.limit, 10) : undefined;\n\n\t\t\t\tif (limit !== undefined && (!Number.isFinite(limit) || limit <= 0)) {\n\t\t\t\t\terror(\"INVALID_LIMIT\", \"--limit must be a positive integer\");\n\t\t\t\t}\n\n\t\t\t\tconst ready = tasks\n\t\t\t\t\t.filter((t) => TaskStatus.is.open(t.status))\n\t\t\t\t\t.filter((t) => {\n\t\t\t\t\t\tconst incomingDeps = deps.filter((dep) => dep.taskId === t.id);\n\t\t\t\t\t\tconst hasOpenBlocker = incomingDeps.some((dep) => {\n\t\t\t\t\t\t\tconst depTag =\n\t\t\t\t\t\t\t\ttypeof dep.dependencyType === \"string\"\n\t\t\t\t\t\t\t\t\t? dep.dependencyType\n\t\t\t\t\t\t\t\t\t: dep.dependencyType.tag;\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tdepTag !== \"Blocks\" &&\n\t\t\t\t\t\t\t\tdepTag !== \"ParentChild\" &&\n\t\t\t\t\t\t\t\tdepTag !== \"blocks\" &&\n\t\t\t\t\t\t\t\tdepTag !== \"parent-child\"\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\tconst blocker = taskById.get(dep.dependsOnId.toString());\n\t\t\t\t\t\t\tif (!blocker) return false;\n\t\t\t\t\t\t\treturn !TaskStatus.is.completed(blocker.status);\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn !hasOpenBlocker;\n\t\t\t\t\t})\n\t\t\t\t\t.filter(\n\t\t\t\t\t\t(t) => !args.project || t.projectId.toString() === args.project,\n\t\t\t\t\t)\n\t\t\t\t\t.filter((t) => !args.assigned || Boolean(t.assignedTo))\n\t\t\t\t\t.sort((a, b) => {\n\t\t\t\t\t\tif (a.priority !== b.priority) return a.priority - b.priority;\n\t\t\t\t\t\tconst aMicros = toMicros(a.createdAt);\n\t\t\t\t\t\tconst bMicros = toMicros(b.createdAt);\n\t\t\t\t\t\tif (aMicros < bMicros) return -1;\n\t\t\t\t\t\tif (aMicros > bMicros) return 1;\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t});\n\n\t\t\t\tconst readyTasks = (\n\t\t\t\t\tlimit !== undefined ? ready.slice(0, limit) : ready\n\t\t\t\t).map((t) => ({\n\t\t\t\t\tid: t.id.toString(),\n\t\t\t\t\ttitle: t.title,\n\t\t\t\t\tstatus: t.status.tag.toLowerCase(),\n\t\t\t\t\tpriority: t.priority,\n\t\t\t\t\tassignedTo: t.assignedTo || \"\",\n\t\t\t\t\tprojectId: t.projectId.toString(),\n\t\t\t\t\tblockedBy: [] as string[],\n\t\t\t\t}));\n\n\t\t\t\tsuccess({ tasks: readyTasks, count: readyTasks.length });\n\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\ttoonList(\n\t\t\t\t\t\t\t\"tasks\",\n\t\t\t\t\t\t\treadyTasks.map((t) => ({\n\t\t\t\t\t\t\t\tid: t.id,\n\t\t\t\t\t\t\t\ttitle: t.title,\n\t\t\t\t\t\t\t\tstatus: t.status,\n\t\t\t\t\t\t\t\tpriority: t.priority,\n\t\t\t\t\t\t\t\tassignedTo: t.assignedTo,\n\t\t\t\t\t\t\t\tprojectId: t.projectId,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"get\": {\n\t\t\t\tconst taskId = args.id;\n\t\t\t\tif (!taskId) error(\"TASK_ID_REQUIRED\", \"Task ID required\");\n\n\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\thost: args.host,\n\t\t\t\t\tmodule: args.module,\n\t\t\t\t});\n\t\t\t\tconst task = ctx\n\t\t\t\t\t.iter<Task>(\"tasks\")\n\t\t\t\t\t.find((t) => t.id.toString() === taskId);\n\t\t\t\tif (!task) error(\"TASK_NOT_FOUND\", `Task not found: ${taskId}`);\n\n\t\t\t\tsuccess(task);\n\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\ttoonList(\"task\", [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tid: task.id.toString(),\n\t\t\t\t\t\t\t\ttitle: task.title,\n\t\t\t\t\t\t\t\tstatus: TaskStatus.display(task.status),\n\t\t\t\t\t\t\t\tpriority: task.priority,\n\t\t\t\t\t\t\t\tassignedTo: task.assignedTo || \"\",\n\t\t\t\t\t\t\t\tprojectId: task.projectId.toString(),\n\t\t\t\t\t\t\t\tgithubIssueUrl: task.githubIssueUrl || \"\",\n\t\t\t\t\t\t\t\tgithubPrUrl: task.githubPrUrl || \"\",\n\t\t\t\t\t\t\t\tdescription: task.description,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t]),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"create\": {\n\t\t\t\tif (!args.project || !args.title)\n\t\t\t\t\terror(\"ARGS_REQUIRED\", \"--project and --title required\");\n\n\t\t\t\tconst priority = parseInt(args.priority || \"5\", 10);\n\t\t\t\tif (priority < 1 || priority > 10)\n\t\t\t\t\terror(\"INVALID_PRIORITY\", \"Priority must be 1-10\");\n\n\t\t\t\ttry {\n\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\tawait callReducer(ctx, \"createTask\", {\n\t\t\t\t\t\t\t\tprojectId: BigInt(args.project as string),\n\t\t\t\t\t\t\t\ttitle: args.title,\n\t\t\t\t\t\t\t\tdescription: args.description || \"\",\n\t\t\t\t\t\t\t\tpriority,\n\t\t\t\t\t\t\t\tsourceIdeaId: undefined,\n\t\t\t\t\t\t\t\tgithubIssueUrl: args[\"github-issue-url\"],\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\tsuccess({\n\t\t\t\t\t\tcreated: true,\n\t\t\t\t\t\tprojectId: args.project,\n\t\t\t\t\t\ttitle: args.title,\n\t\t\t\t\t\tissue: args[\"github-issue-url\"],\n\t\t\t\t\t});\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\"task_created\", [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tprojectId: args.project,\n\t\t\t\t\t\t\t\t\ttitle: args.title,\n\t\t\t\t\t\t\t\t\tgithubIssueUrl: args[\"github-issue-url\"] || \"\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"claim\": {\n\t\t\t\tconst taskId = args.id;\n\t\t\t\tif (!taskId) error(\"TASK_ID_REQUIRED\", \"Task ID required\");\n\n\t\t\t\ttry {\n\t\t\t\t\tlet repositoryUrl: string | undefined;\n\t\t\t\t\tlet contributingUrl: string | undefined;\n\n\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\tawait callReducer(ctx, \"claimTask\", { taskId: BigInt(taskId) });\n\n\t\t\t\t\t\t\tconst task = ctx\n\t\t\t\t\t\t\t\t.iter<Task>(\"tasks\")\n\t\t\t\t\t\t\t\t.find((t) => t.id.toString() === taskId);\n\t\t\t\t\t\t\tconst project = task\n\t\t\t\t\t\t\t\t? ctx\n\t\t\t\t\t\t\t\t\t\t.iter<Project>(\"projects\")\n\t\t\t\t\t\t\t\t\t\t.find((p) => p.id === task.projectId)\n\t\t\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\t\t\tif (project?.githubRepo) {\n\t\t\t\t\t\t\t\trepositoryUrl = normalizeGitHubRepoUrl(project.githubRepo);\n\t\t\t\t\t\t\t\tif (repositoryUrl) {\n\t\t\t\t\t\t\t\t\tcontributingUrl = `${repositoryUrl}/blob/main/CONTRIBUTING.md`;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\tsuccess({\n\t\t\t\t\t\tclaimed: true,\n\t\t\t\t\t\ttaskId,\n\t\t\t\t\t\trepositoryUrl,\n\t\t\t\t\t\tcontributingUrl,\n\t\t\t\t\t\tnextSteps: [\n\t\t\t\t\t\t\trepositoryUrl\n\t\t\t\t\t\t\t\t? `Fork the target repository: ${repositoryUrl}`\n\t\t\t\t\t\t\t\t: \"Fork the target repository to your GitHub account using gh cli\",\n\t\t\t\t\t\t\tcontributingUrl\n\t\t\t\t\t\t\t\t? `Read CONTRIBUTING.md before starting: ${contributingUrl}`\n\t\t\t\t\t\t\t\t: \"Read CONTRIBUTING.md in the target repository before starting\",\n\t\t\t\t\t\t\t\"Verify behavior independently by tracing relevant code flow and runtime path before implementing changes.\",\n\t\t\t\t\t\t],\n\t\t\t\t\t});\n\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\"task_claimed\", [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttaskId,\n\t\t\t\t\t\t\t\t\trepositoryUrl: repositoryUrl || \"\",\n\t\t\t\t\t\t\t\t\tcontributingUrl: contributingUrl || \"\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.log(\"\");\n\t\t\t\t\t\tconsole.log(\"Next steps:\");\n\t\t\t\t\t\tif (repositoryUrl) {\n\t\t\t\t\t\t\tconsole.log(`1. Fork the target repository: ${repositoryUrl}`);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\"1. Fork the target repository to your GitHub account\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (contributingUrl) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t`2. Read CONTRIBUTING.md before starting: ${contributingUrl}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\"2. Read CONTRIBUTING.md in the target repository before starting\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\"3. Verify behavior independently by tracing relevant code flow and runtime path before implementing changes.\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"update\": {\n\t\t\t\tconst taskId = args.id;\n\t\t\t\tif (!taskId) error(\"TASK_ID_REQUIRED\", \"Task ID required\");\n\t\t\t\tif (!args.status && !args[\"github-pr-url\"])\n\t\t\t\t\terror(\"UPDATE_REQUIRED\", \"--status or --github-pr-url required\");\n\n\t\t\t\ttry {\n\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\tawait callReducer(ctx, \"updateTaskStatus\", {\n\t\t\t\t\t\t\t\ttaskId: BigInt(taskId),\n\t\t\t\t\t\t\t\tstatus: args.status\n\t\t\t\t\t\t\t\t\t? TaskStatus.fromString(args.status)\n\t\t\t\t\t\t\t\t\t: (undefined as never),\n\t\t\t\t\t\t\t\tgithubPrUrl: args[\"github-pr-url\"],\n\t\t\t\t\t\t\t\tarchiveReason: undefined,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\tsuccess({\n\t\t\t\t\t\tupdated: true,\n\t\t\t\t\t\ttaskId,\n\t\t\t\t\t\tstatus: args.status,\n\t\t\t\t\t\tpr: args[\"github-pr-url\"],\n\t\t\t\t\t});\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\"task_updated\", [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttaskId,\n\t\t\t\t\t\t\t\t\tstatus: args.status || \"\",\n\t\t\t\t\t\t\t\t\tgithubPrUrl: args[\"github-pr-url\"] || \"\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"review\": {\n\t\t\t\tconst taskId = args.id;\n\t\t\t\tif (!taskId) error(\"TASK_ID_REQUIRED\", \"Task ID required\");\n\n\t\t\t\ttry {\n\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\tawait callReducer(ctx, \"updateTaskStatus\", {\n\t\t\t\t\t\t\t\ttaskId: BigInt(taskId),\n\t\t\t\t\t\t\t\tstatus: { tag: \"Review\" },\n\t\t\t\t\t\t\t\tgithubPrUrl: args[\"github-pr-url\"],\n\t\t\t\t\t\t\t\tarchiveReason: undefined,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\tsuccess({\n\t\t\t\t\t\treviewed: true,\n\t\t\t\t\t\ttaskId,\n\t\t\t\t\t\tstatus: \"review\",\n\t\t\t\t\t\tpr: args[\"github-pr-url\"],\n\t\t\t\t\t});\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\"task_review\", [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttaskId,\n\t\t\t\t\t\t\t\t\tstatus: \"review\",\n\t\t\t\t\t\t\t\t\tgithubPrUrl: args[\"github-pr-url\"] || \"\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} catch (err) {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"deps\": {\n\t\t\t\tconst taskId = args.id;\n\t\t\t\tif (!taskId) error(\"TASK_ID_REQUIRED\", \"Task ID required\");\n\t\t\t\tconst taskIdBigInt = BigInt(taskId);\n\n\t\t\t\tif (args[\"add-dep\"]) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait withAuth(\n\t\t\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"addTaskDependency\", {\n\t\t\t\t\t\t\t\t\ttaskId: taskIdBigInt,\n\t\t\t\t\t\t\t\t\tdependsOnId: BigInt(args[\"add-dep\"] as string),\n\t\t\t\t\t\t\t\t\tdependencyType: { tag: \"Blocks\" },\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\tsuccess({ added: true, taskId, dependsOn: args[\"add-dep\"] });\n\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\ttoonList(\"dependency_added\", [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttaskId,\n\t\t\t\t\t\t\t\t\t\tdependsOnId: args[\"add-dep\"],\n\t\t\t\t\t\t\t\t\t\tdependencyType: \"blocks\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"REDUCER_FAILED\",\n\t\t\t\t\t\t\terr instanceof Error ? err.message : \"Unknown error\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else if (args.list) {\n\t\t\t\t\tawait using ctx = await CommandContext.create({\n\t\t\t\t\t\thost: args.host,\n\t\t\t\t\t\tmodule: args.module,\n\t\t\t\t\t});\n\t\t\t\t\tconst deps = ctx.iter<TaskDependency>(\"task_dependencies\");\n\t\t\t\t\tconst taskDeps = deps.filter(\n\t\t\t\t\t\t(d) => d.taskId === taskIdBigInt || d.dependsOnId === taskIdBigInt,\n\t\t\t\t\t);\n\n\t\t\t\t\tsuccess({ dependencies: taskDeps });\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\n\t\t\t\t\t\t\t\t\"task_dependencies\",\n\t\t\t\t\t\t\t\ttaskDeps.map((dep) => ({\n\t\t\t\t\t\t\t\t\tid: dep.id.toString(),\n\t\t\t\t\t\t\t\t\ttaskId: dep.taskId.toString(),\n\t\t\t\t\t\t\t\t\tdependsOnId: dep.dependsOnId.toString(),\n\t\t\t\t\t\t\t\t\tdependencyType: dep.dependencyType,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\terror(\n\t\t\t\t\t\t\"DEPS_ACTION_REQUIRED\",\n\t\t\t\t\t\t\"Use --add-dep <taskId> to add a dependency or --list to view dependencies\",\n\t\t\t\t\t\t\"Examples: probe task deps 42 --list | probe task deps 42 --add-dep 17\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"watch\": {\n\t\t\t\tconst timeout = Math.min(parseInt(args.timeout || \"60\", 10), 300);\n\n\t\t\t\tawait withAuth(\n\t\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\t\tasync (ctx) => {\n\t\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\ttoonList(\"task_watch\", [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttimeoutSeconds: timeout,\n\t\t\t\t\t\t\t\t\t\tstatusFilter: args.status || \"\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst waitForStop = new Promise<void>((resolve) => {\n\t\t\t\t\t\t\tconst timer = setTimeout(() => {\n\t\t\t\t\t\t\t\tprocess.off(\"SIGINT\", onSignal);\n\t\t\t\t\t\t\t\tprocess.off(\"SIGTERM\", onSignal);\n\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t}, timeout * 1000);\n\n\t\t\t\t\t\t\tconst onSignal = () => {\n\t\t\t\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\t\t\t\tprocess.off(\"SIGINT\", onSignal);\n\t\t\t\t\t\t\t\tprocess.off(\"SIGTERM\", onSignal);\n\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\tprocess.on(\"SIGINT\", onSignal);\n\t\t\t\t\t\t\tprocess.on(\"SIGTERM\", onSignal);\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tctx.db.tasks.onInsert((_ctx, task) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t!args.status ||\n\t\t\t\t\t\t\t\tTaskStatus.matches(task.status, args.status)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\ttoonList(\"tasks\", [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tid: task.id.toString(),\n\t\t\t\t\t\t\t\t\t\t\ttitle: task.title,\n\t\t\t\t\t\t\t\t\t\t\tchange_type: \"created\",\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tctx.db.tasks.onUpdate((_ctx, _old, newTask) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t!args.status ||\n\t\t\t\t\t\t\t\tTaskStatus.matches(newTask.status, args.status)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\ttoonList(\"tasks\", [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tid: newTask.id.toString(),\n\t\t\t\t\t\t\t\t\t\t\ttitle: newTask.title,\n\t\t\t\t\t\t\t\t\t\t\tchange_type: \"updated\",\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tawait waitForStop;\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\terror(\n\t\t\t\t\t\"INVALID_ACTION\",\n\t\t\t\t\t`Invalid action: ${action}`,\n\t\t\t\t\t\"Use: list, ready, get, create, claim, update, review, deps, watch\",\n\t\t\t\t);\n\t\t}\n\t} catch (err) {\n\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\terror(\"CONNECTION_ERROR\", message);\n\t}\n};\n","import { defineCommand } from \"citty\";\nimport { printHelp } from \"~/utils/help.js\";\nimport { setJsonMode } from \"~/utils/output.js\";\nimport { runTaskAction, type TaskCommandArgs } from \"./task-handlers.js\";\n\nexport default defineCommand({\n\tmeta: { name: \"task\", description: \"Task management\" },\n\targs: {\n\t\taction: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription:\n\t\t\t\t\"Action: list, ready, get, create, claim, update, review, deps, watch\",\n\t\t\trequired: false,\n\t\t},\n\t\tid: { type: \"positional\", description: \"Task ID\", required: false },\n\t\tstatus: { type: \"string\", description: \"Status filter or new status\" },\n\t\tproject: { type: \"string\", description: \"Project ID\" },\n\t\ttitle: { type: \"string\", description: \"Task title\" },\n\t\tdescription: { type: \"string\", description: \"Task description\" },\n\t\tpriority: { type: \"string\", description: \"Priority 1-10\" },\n\t\tassigned: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Show only assigned tasks\",\n\t\t\tdefault: false,\n\t\t},\n\t\twallet: { type: \"string\", description: \"Wallet name\" },\n\t\t\"github-pr-url\": { type: \"string\", description: \"GitHub PR URL\" },\n\t\t\"github-issue-url\": { type: \"string\", description: \"GitHub issue URL\" },\n\t\t\"add-dep\": { type: \"string\", description: \"Add dependency task ID\" },\n\t\tlist: { type: \"boolean\", description: \"List dependencies\", default: false },\n\t\ttimeout: { type: \"string\", description: \"Watch timeout (seconds)\" },\n\t\tlimit: { type: \"string\", description: \"Limit rows for list/ready\" },\n\t\tjson: { type: \"boolean\", description: \"Output JSON\", default: false },\n\t\thost: { type: \"string\", description: \"SpacetimeDB host\" },\n\t\tmodule: { type: \"string\", description: \"Module name\" },\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) setJsonMode(true);\n\n\t\tif (!args.action) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe task\",\n\t\t\t\tdescription: \"Task management commands\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe task <action> [options]\",\n\t\t\t\t\t\"probe task list --project 1 --status open\",\n\t\t\t\t\t'probe task create --project 1 --title \"Fix bug\" --priority 5',\n\t\t\t\t],\n\t\t\t\tactions: [\n\t\t\t\t\t{ name: \"list\", detail: \"List tasks with optional filters\" },\n\t\t\t\t\t{ name: \"ready\", detail: \"List immediately claimable open tasks\" },\n\t\t\t\t\t{ name: \"get <id>\", detail: \"Show one task\" },\n\t\t\t\t\t{ name: \"create\", detail: \"Create a new task\" },\n\t\t\t\t\t{ name: \"claim <id>\", detail: \"Claim a task for your identity\" },\n\t\t\t\t\t{ name: \"update <id>\", detail: \"Update status and optional PR URL\" },\n\t\t\t\t\t{ name: \"review <id>\", detail: \"Mark a task as ready for review\" },\n\t\t\t\t\t{ name: \"deps <id>\", detail: \"List or add task dependencies\" },\n\t\t\t\t\t{ name: \"watch\", detail: \"Watch task changes in real time\" },\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--project\", detail: \"Project ID\" },\n\t\t\t\t\t{ name: \"--title\", detail: \"Task title (create)\" },\n\t\t\t\t\t{ name: \"--description\", detail: \"Task description\" },\n\t\t\t\t\t{ name: \"--priority\", detail: \"Priority from 1 to 10 (default: 5)\" },\n\t\t\t\t\t{ name: \"--status\", detail: \"Filter or new status\" },\n\t\t\t\t\t{ name: \"--limit\", detail: \"Limit rows for list/ready\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--github-pr-url\",\n\t\t\t\t\t\tdetail: \"GitHub PR URL for update/review\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"--github-issue-url\", detail: \"GitHub issue URL for create\" },\n\t\t\t\t\t{ name: \"--wallet\", detail: \"Wallet to use for authenticated calls\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--host, --module\",\n\t\t\t\t\t\tdetail: \"Nexus SpacetimeDB target overrides\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tnotes: [\n\t\t\t\t\t\"Use full long-form flags only; short aliases are intentionally disabled.\",\n\t\t\t\t\t\"Find project IDs with `probe project list`; find task IDs with `probe task list`.\",\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tawait runTaskAction(args as TaskCommandArgs);\n\t},\n});\n","import { createWriteStream, type WriteStream } from \"node:fs\";\nimport { mkdir } from \"node:fs/promises\";\nimport { dirname, resolve } from \"node:path\";\nimport { defineCommand } from \"citty\";\nimport { createConsola } from \"consola\";\nimport { type Agent, callReducer, withAuth } from \"~/utils/context.js\";\nimport { forceHelpRequested, printHelp } from \"~/utils/help.js\";\n\nconst HEARTBEAT_INTERVAL_MS = 60_000;\nconst HEARTBEAT_JITTER_MS = 5_000;\nconst HEARTBEAT_FAILURE_THRESHOLD = 3;\nconst RECONNECT_BASE_MS = 1_000;\nconst RECONNECT_MAX_MS = 30_000;\n\nconst OBSERVED_TABLES = [\n\t{ key: \"agents\", name: \"agents\" },\n\t{ key: \"tasks\", name: \"tasks\" },\n\t{ key: \"ideas\", name: \"ideas\" },\n\t{ key: \"messages\", name: \"messages\" },\n\t{ key: \"channels\", name: \"channels\" },\n\t{ key: \"projects\", name: \"projects\" },\n\t{ key: \"votes\", name: \"votes\" },\n\t{ key: \"discovered_tasks\", name: \"discovered_tasks\" },\n\t{ key: \"task_dependencies\", name: \"task_dependencies\" },\n\t{ key: \"identity_roles\", name: \"identity_roles\" },\n\t{ key: \"config\", name: \"config\" },\n\t{ key: \"project_channels\", name: \"project_channels\" },\n\t{ key: \"project_messages\", name: \"project_messages\" },\n] as const;\n\ntype DaemonEvent = {\n\ttype: string;\n\tsource: \"nexus\";\n\tat: string;\n\t[key: string]: unknown;\n};\n\ntype SessionEnd = {\n\treason: \"disconnected\" | \"heartbeat_failed\" | \"stop\";\n\tdetails?: unknown;\n};\n\ntype LogLevel = \"critical\" | \"info\" | \"debug\";\n\ntype ObservableTable = {\n\tonInsert?: (cb: (_ctx: unknown, row: unknown) => void) => void;\n\tonUpdate?: (\n\t\tcb: (_ctx: unknown, oldRow: unknown, newRow: unknown) => void,\n\t) => void;\n\tonDelete?: (cb: (_ctx: unknown, row: unknown) => void) => void;\n};\n\nconst CRITICAL_EVENTS = new Set([\n\t\"connected\",\n\t\"ready\",\n\t\"disconnected\",\n\t\"reconnecting\",\n\t\"reconnected\",\n\t\"subscription_applied\",\n\t\"subscription_error\",\n\t\"auth_failed\",\n\t\"heartbeat_failed\",\n\t\"heartbeat_recovered\",\n\t\"shutdown\",\n]);\n\nconst jsonReplacer = (_key: string, value: unknown): unknown => {\n\tif (typeof value === \"bigint\") {\n\t\treturn value.toString();\n\t}\n\treturn value;\n};\n\nconst nowIso = (): string => new Date().toISOString();\n\nconst sleep = (ms: number): Promise<void> =>\n\tnew Promise((resolve) => setTimeout(resolve, ms));\n\nconst withJitter = (baseMs: number): number => {\n\tconst jitter = Math.floor(\n\t\tMath.random() * (HEARTBEAT_JITTER_MS * 2 + 1) - HEARTBEAT_JITTER_MS,\n\t);\n\treturn Math.max(1_000, baseMs + jitter);\n};\n\nconst backoffMs = (attempt: number): number => {\n\tconst base = Math.min(\n\t\tRECONNECT_MAX_MS,\n\t\tRECONNECT_BASE_MS * 2 ** Math.max(0, attempt - 1),\n\t);\n\treturn withJitter(base);\n};\n\nconst normalizeError = (err: unknown): string => {\n\tif (err instanceof Error) {\n\t\treturn err.message;\n\t}\n\treturn String(err);\n};\n\nconst sanitizeValue = (value: unknown): unknown => {\n\tif (value instanceof Error) {\n\t\treturn { name: value.name, message: value.message };\n\t}\n\tif (\n\t\ttypeof value === \"string\" ||\n\t\ttypeof value === \"number\" ||\n\t\ttypeof value === \"boolean\" ||\n\t\tvalue === null\n\t) {\n\t\treturn value;\n\t}\n\tif (typeof value === \"bigint\") {\n\t\treturn value.toString();\n\t}\n\ttry {\n\t\treturn JSON.parse(JSON.stringify(value, jsonReplacer));\n\t} catch {\n\t\treturn String(value);\n\t}\n};\n\nconst resolveLogLevel = (value: unknown): LogLevel => {\n\tif (value === \"critical\" || value === \"info\" || value === \"debug\") {\n\t\treturn value;\n\t}\n\treturn \"critical\";\n};\n\nconst shouldEmit = (eventType: string, level: LogLevel): boolean => {\n\tif (level === \"debug\") {\n\t\treturn true;\n\t}\n\tif (CRITICAL_EVENTS.has(eventType)) {\n\t\treturn true;\n\t}\n\tif (level === \"info\" && eventType.startsWith(\"heartbeat_\")) {\n\t\treturn true;\n\t}\n\treturn false;\n};\n\nconst resolveLogStream = async (\n\tpathValue?: string,\n): Promise<WriteStream | null> => {\n\tif (!pathValue) {\n\t\treturn null;\n\t}\n\tconst absolutePath = resolve(pathValue);\n\tawait mkdir(dirname(absolutePath), { recursive: true });\n\treturn createWriteStream(absolutePath, { flags: \"a\" });\n};\n\nconst connectErrorLooksAuthRelated = (message: string): boolean => {\n\tconst lowered = message.toLowerCase();\n\treturn (\n\t\tlowered.includes(\"authentication required\") ||\n\t\tlowered.includes(\"unauthorized\") ||\n\t\tlowered.includes(\"401\")\n\t);\n};\n\nexport const nexusDaemonArgs = {\n\twallet: {\n\t\ttype: \"string\",\n\t\tdescription: \"Wallet name for authenticated connection\",\n\t},\n\thost: {\n\t\ttype: \"string\",\n\t\tdescription: \"SpacetimeDB host override\",\n\t},\n\tmodule: {\n\t\ttype: \"string\",\n\t\tdescription: \"SpacetimeDB module override\",\n\t},\n\tsender: {\n\t\ttype: \"string\",\n\t\tdescription: \"Optional sender filter (debug table events only)\",\n\t},\n\t\"log-file\": {\n\t\ttype: \"string\",\n\t\tdescription: \"Optional path to append JSONL daemon events\",\n\t},\n\t\"log-level\": {\n\t\ttype: \"string\",\n\t\tdescription: \"critical, info, or debug\",\n\t\tdefault: \"critical\",\n\t},\n\tpretty: {\n\t\ttype: \"boolean\",\n\t\tdescription: \"Human-readable lifecycle logs to stderr\",\n\t\tdefault: false,\n\t},\n\tjson: {\n\t\ttype: \"boolean\",\n\t\tdescription: \"Reserved for CLI consistency\",\n\t\tdefault: false,\n\t},\n} as const;\n\nexport async function runNexusDaemon(\n\targs: Record<string, unknown>,\n): Promise<void> {\n\tconst logLevel = resolveLogLevel(args[\"log-level\"]);\n\tconst pretty = !!args.pretty;\n\tconst prettyLogger = pretty\n\t\t? createConsola({\n\t\t\t\tstdout: process.stderr,\n\t\t\t\tstderr: process.stderr,\n\t\t\t})\n\t\t: null;\n\n\tlet logStream: WriteStream | null = null;\n\ttry {\n\t\tlogStream = await resolveLogStream(args[\"log-file\"] as string | undefined);\n\t} catch (err) {\n\t\tconst message = normalizeError(err);\n\t\tconst fallback = JSON.stringify({\n\t\t\tsource: \"nexus\",\n\t\t\tat: nowIso(),\n\t\t\ttype: \"log_file_error\",\n\t\t\tmessage,\n\t\t});\n\t\tconsole.log(fallback);\n\t\treturn;\n\t}\n\n\tconst writeEvent = (event: DaemonEvent): void => {\n\t\tconst line = JSON.stringify(event, jsonReplacer);\n\t\tconsole.log(line);\n\t\tif (logStream) {\n\t\t\tlogStream.write(`${line}\\n`);\n\t\t}\n\t};\n\n\tconst emit = (event: { type: string; [key: string]: unknown }): void => {\n\t\tif (!shouldEmit(event.type, logLevel)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst fullEvent: DaemonEvent = {\n\t\t\tsource: \"nexus\",\n\t\t\tat: nowIso(),\n\t\t\t...event,\n\t\t};\n\n\t\twriteEvent(fullEvent);\n\n\t\tif (!prettyLogger) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst type = String(event.type);\n\t\tif (type === \"connected\") {\n\t\t\tprettyLogger.info(\"Connected to Nexus\");\n\t\t} else if (type === \"reconnected\") {\n\t\t\tprettyLogger.success(\"Reconnected to Nexus\");\n\t\t} else if (type === \"disconnected\") {\n\t\t\tprettyLogger.warn(\"Disconnected from Nexus\");\n\t\t} else if (type === \"reconnecting\") {\n\t\t\tprettyLogger.info(\"Reconnecting to Nexus\");\n\t\t} else if (type === \"auth_failed\") {\n\t\t\tprettyLogger.error(\"Authentication failed\");\n\t\t} else if (type === \"heartbeat_failed\") {\n\t\t\tprettyLogger.warn(\"Heartbeat failed repeatedly\");\n\t\t} else if (type === \"shutdown\") {\n\t\t\tprettyLogger.info(\"Nexus daemon shutting down\");\n\t\t}\n\t};\n\n\tlet stopping = false;\n\tlet stopSignal: \"SIGINT\" | \"SIGTERM\" | null = null;\n\n\tconst stopWaiter = new Promise<void>((resolve) => {\n\t\tconst onSigint = () => {\n\t\t\tif (stopping) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tstopping = true;\n\t\t\tstopSignal = \"SIGINT\";\n\t\t\tresolve();\n\t\t};\n\t\tconst onSigterm = () => {\n\t\t\tif (stopping) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tstopping = true;\n\t\t\tstopSignal = \"SIGTERM\";\n\t\t\tresolve();\n\t\t};\n\t\tprocess.on(\"SIGINT\", onSigint);\n\t\tprocess.on(\"SIGTERM\", onSigterm);\n\t});\n\n\tlet reconnectAttempt = 0;\n\tlet downtimeStartedAt: number | null = null;\n\tlet hasConnectedOnce = false;\n\n\twhile (!stopping) {\n\t\tlet sessionEnd: SessionEnd | null = null;\n\n\t\ttry {\n\t\t\tawait withAuth(\n\t\t\t\t{\n\t\t\t\t\thost: args.host as string | undefined,\n\t\t\t\t\tmodule: args.module as string | undefined,\n\t\t\t\t\twallet: args.wallet as string | undefined,\n\t\t\t\t\tonDisconnect: (...disconnectArgs: unknown[]) => {\n\t\t\t\t\t\tif (!sessionEnd) {\n\t\t\t\t\t\t\tsessionEnd = {\n\t\t\t\t\t\t\t\treason: \"disconnected\",\n\t\t\t\t\t\t\t\tdetails: disconnectArgs.map(sanitizeValue),\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tasync (ctx) => {\n\t\t\t\t\tconst effectiveWallet = ctx.auth?.wallet || args.wallet || null;\n\t\t\t\t\tconst currentAgent = ctx\n\t\t\t\t\t\t.iter<Agent>(\"agents\")\n\t\t\t\t\t\t.find(\n\t\t\t\t\t\t\t(a) => a.identity.toHexString() === ctx.identity?.toHexString(),\n\t\t\t\t\t\t);\n\n\t\t\t\t\tif (!hasConnectedOnce) {\n\t\t\t\t\t\temit({\n\t\t\t\t\t\t\ttype: \"connected\",\n\t\t\t\t\t\t\tidentity: ctx.identity?.toHexString(),\n\t\t\t\t\t\t\twallet: effectiveWallet,\n\t\t\t\t\t\t\thost: args.host || ctx.config.spacetime.host,\n\t\t\t\t\t\t\tmodule: args.module || ctx.config.spacetime.module,\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\temit({\n\t\t\t\t\t\t\ttype: \"reconnected\",\n\t\t\t\t\t\t\tattempts: reconnectAttempt,\n\t\t\t\t\t\t\tdowntime_ms: downtimeStartedAt\n\t\t\t\t\t\t\t\t? Date.now() - downtimeStartedAt\n\t\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\t\tidentity: ctx.identity?.toHexString(),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\thasConnectedOnce = true;\n\t\t\t\t\treconnectAttempt = 0;\n\t\t\t\t\tdowntimeStartedAt = null;\n\n\t\t\t\t\temit({ type: \"subscription_applied\" });\n\t\t\t\t\temit({\n\t\t\t\t\t\ttype: \"ready\",\n\t\t\t\t\t\tidentity: ctx.identity?.toHexString(),\n\t\t\t\t\t\twallet: effectiveWallet,\n\t\t\t\t\t\tlog_file: args[\"log-file\"] || null,\n\t\t\t\t\t\tlog_level: logLevel,\n\t\t\t\t\t\tauto_heartbeat: !!currentAgent,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (logLevel === \"debug\") {\n\t\t\t\t\t\tfor (const tableSpec of OBSERVED_TABLES) {\n\t\t\t\t\t\t\tconst table = ctx.db[tableSpec.key] as ObservableTable;\n\t\t\t\t\t\t\ttable.onInsert?.((_eventCtx, row) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\targs.sender &&\n\t\t\t\t\t\t\t\t\t(tableSpec.name === \"messages\" ||\n\t\t\t\t\t\t\t\t\t\ttableSpec.name === \"project_messages\")\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tconst senderId = (row as { senderId?: unknown }).senderId;\n\t\t\t\t\t\t\t\t\tif (senderId !== args.sender) {\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\temit({\n\t\t\t\t\t\t\t\t\ttype: \"table_insert\",\n\t\t\t\t\t\t\t\t\ttable: tableSpec.name,\n\t\t\t\t\t\t\t\t\trow: sanitizeValue(row),\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\ttable.onUpdate?.((_eventCtx, oldRow, newRow) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\targs.sender &&\n\t\t\t\t\t\t\t\t\t(tableSpec.name === \"messages\" ||\n\t\t\t\t\t\t\t\t\t\ttableSpec.name === \"project_messages\")\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tconst senderId = (newRow as { senderId?: unknown }).senderId;\n\t\t\t\t\t\t\t\t\tif (senderId !== args.sender) {\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\temit({\n\t\t\t\t\t\t\t\t\ttype: \"table_update\",\n\t\t\t\t\t\t\t\t\ttable: tableSpec.name,\n\t\t\t\t\t\t\t\t\told_row: sanitizeValue(oldRow),\n\t\t\t\t\t\t\t\t\tnew_row: sanitizeValue(newRow),\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\ttable.onDelete?.((_eventCtx, row) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\targs.sender &&\n\t\t\t\t\t\t\t\t\t(tableSpec.name === \"messages\" ||\n\t\t\t\t\t\t\t\t\t\ttableSpec.name === \"project_messages\")\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tconst senderId = (row as { senderId?: unknown }).senderId;\n\t\t\t\t\t\t\t\t\tif (senderId !== args.sender) {\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\temit({\n\t\t\t\t\t\t\t\t\ttype: \"table_delete\",\n\t\t\t\t\t\t\t\t\ttable: tableSpec.name,\n\t\t\t\t\t\t\t\t\trow: sanitizeValue(row),\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tlet heartbeatTimer: ReturnType<typeof setTimeout> | null = null;\n\t\t\t\t\tlet heartbeatInFlight = false;\n\t\t\t\t\tlet consecutiveHeartbeatFailures = 0;\n\n\t\t\t\t\tconst scheduleHeartbeat = () => {\n\t\t\t\t\t\tif (stopping || !currentAgent) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\theartbeatTimer = setTimeout(async () => {\n\t\t\t\t\t\t\tif (!currentAgent || heartbeatInFlight || stopping) {\n\t\t\t\t\t\t\t\tscheduleHeartbeat();\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\theartbeatInFlight = true;\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tawait callReducer(ctx, \"heartbeat\", {\n\t\t\t\t\t\t\t\t\tagentId: currentAgent.id,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (consecutiveHeartbeatFailures > 0) {\n\t\t\t\t\t\t\t\t\temit({\n\t\t\t\t\t\t\t\t\t\ttype: \"heartbeat_recovered\",\n\t\t\t\t\t\t\t\t\t\tfailed_count_before_recovery: consecutiveHeartbeatFailures,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconsecutiveHeartbeatFailures = 0;\n\t\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\t\tconsecutiveHeartbeatFailures += 1;\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tconsecutiveHeartbeatFailures >= HEARTBEAT_FAILURE_THRESHOLD &&\n\t\t\t\t\t\t\t\t\t!sessionEnd\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tsessionEnd = {\n\t\t\t\t\t\t\t\t\t\treason: \"heartbeat_failed\",\n\t\t\t\t\t\t\t\t\t\tdetails: {\n\t\t\t\t\t\t\t\t\t\t\tconsecutive_failures: consecutiveHeartbeatFailures,\n\t\t\t\t\t\t\t\t\t\t\tmessage: normalizeError(err),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\temit({\n\t\t\t\t\t\t\t\t\t\ttype: \"heartbeat_failed\",\n\t\t\t\t\t\t\t\t\t\tconsecutive_failures: consecutiveHeartbeatFailures,\n\t\t\t\t\t\t\t\t\t\tmessage: normalizeError(err),\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} finally {\n\t\t\t\t\t\t\t\theartbeatInFlight = false;\n\t\t\t\t\t\t\t\tscheduleHeartbeat();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}, withJitter(HEARTBEAT_INTERVAL_MS));\n\t\t\t\t\t};\n\n\t\t\t\t\tif (currentAgent) {\n\t\t\t\t\t\tscheduleHeartbeat();\n\t\t\t\t\t}\n\n\t\t\t\t\twhile (!stopping && !sessionEnd) {\n\t\t\t\t\t\tawait Promise.race([stopWaiter, sleep(200)]);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (heartbeatTimer) {\n\t\t\t\t\t\tclearTimeout(heartbeatTimer);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\t\t} catch (err) {\n\t\t\tconst message = normalizeError(err);\n\t\t\tif (connectErrorLooksAuthRelated(message)) {\n\t\t\t\temit({ type: \"auth_failed\", message });\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\temit({ type: \"subscription_error\", message });\n\t\t\tsessionEnd = {\n\t\t\t\treason: \"disconnected\",\n\t\t\t\tdetails: { message },\n\t\t\t};\n\t\t}\n\n\t\tif (stopping) {\n\t\t\tbreak;\n\t\t}\n\n\t\tconst reason = sessionEnd?.reason || \"disconnected\";\n\t\temit({\n\t\t\ttype: \"disconnected\",\n\t\t\treason,\n\t\t\tdetails: sanitizeValue(sessionEnd?.details || null),\n\t\t});\n\n\t\tif (downtimeStartedAt === null) {\n\t\t\tdowntimeStartedAt = Date.now();\n\t\t}\n\n\t\treconnectAttempt += 1;\n\t\tconst waitMs = backoffMs(reconnectAttempt);\n\t\temit({\n\t\t\ttype: \"reconnecting\",\n\t\t\tattempt: reconnectAttempt,\n\t\t\tbackoff_ms: waitMs,\n\t\t});\n\n\t\tawait Promise.race([stopWaiter, sleep(waitMs)]);\n\t}\n\n\temit({ type: \"shutdown\", signal: stopSignal || \"unknown\" });\n\n\tif (logStream) {\n\t\tlogStream.end();\n\t}\n}\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"nexus\",\n\t\tdescription: \"Persistent Nexus daemon (keepalive + critical telemetry)\",\n\t},\n\targs: nexusDaemonArgs,\n\tasync run({ args }) {\n\t\tif (forceHelpRequested()) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe nexus\",\n\t\t\t\tdescription: \"Run persistent Nexus keepalive + critical event logger\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe nexus [options]\",\n\t\t\t\t\t\"probe nexus --wallet agent-wallet\",\n\t\t\t\t\t\"probe nexus --wallet agent-wallet --log-file ./logs/nexus-events.jsonl\",\n\t\t\t\t\t\"probe nexus --log-level debug --sender zoe-1\",\n\t\t\t\t\t\"probe nexus --pretty\",\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--wallet\",\n\t\t\t\t\t\tdetail: \"Wallet for authenticated persistent connection\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--host, --module\",\n\t\t\t\t\t\tdetail: \"Nexus SpacetimeDB target overrides\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"--log-level\", detail: \"critical (default), info, or debug\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--sender\",\n\t\t\t\t\t\tdetail: \"Sender filter for debug message events only\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--log-file\",\n\t\t\t\t\t\tdetail: \"Optional JSONL file path for daemon events\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--pretty\",\n\t\t\t\t\t\tdetail: \"Human-readable lifecycle logs to stderr\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tnotes: [\n\t\t\t\t\t\"stdout is always structured JSONL for machine parsing.\",\n\t\t\t\t\t\"Default mode logs critical connection lifecycle and heartbeat health events only.\",\n\t\t\t\t\t\"Use --log-level debug to emit full table insert/update/delete payloads.\",\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tawait runNexusDaemon(args as Record<string, unknown>);\n\t},\n});\n","// THIS FILE IS AUTO-GENERATED BY scripts/generate-decoders.ts\n// DO NOT EDIT MANUALLY - Run `npm run generate:decoders` to regenerate\n\n/**\n * Algebraic type decoders for SpacetimeDB SQL query results.\n * Converts raw algebraic type arrays to human-readable values.\n */\n\nexport type Decoder = (value: unknown) => unknown;\n\n// Enum decoders - map variant index to name\nconst enumDecoders: Record<string, Decoder> = {\n AgentRole: (value) => {\n if (!Array.isArray(value)) return value;\n const variants = ['Zoe', 'Admin', 'Zeno'];\n return variants[value[0]] ?? `variant_${value[0]}`;\n },\n AgentStatus: (value) => {\n if (!Array.isArray(value)) return value;\n const variants = ['Online', 'Offline', 'Working'];\n return variants[value[0]] ?? `variant_${value[0]}`;\n },\n AnnouncementStatus: (value) => {\n if (!Array.isArray(value)) return value;\n const variants = ['Pending', 'Ready', 'Failed'];\n return variants[value[0]] ?? `variant_${value[0]}`;\n },\n DependencyType: (value) => {\n if (!Array.isArray(value)) return value;\n const variants = ['Blocks', 'ParentChild'];\n return variants[value[0]] ?? `variant_${value[0]}`;\n },\n DiscoveredTaskStatus: (value) => {\n if (!Array.isArray(value)) return value;\n const variants = ['PendingReview', 'Approved', 'Rejected', 'EscalatedToIdea'];\n return variants[value[0]] ?? `variant_${value[0]}`;\n },\n DiscoveryDecision: (value) => {\n if (!Array.isArray(value)) return value;\n const variants = ['ApproveAsTask', 'Reject', 'EscalateToIdea'];\n return variants[value[0]] ?? `variant_${value[0]}`;\n },\n IdeaStatus: (value) => {\n if (!Array.isArray(value)) return value;\n const variants = ['Voting', 'ApprovedForProject', 'Rejected', 'Implemented'];\n return variants[value[0]] ?? `variant_${value[0]}`;\n },\n MessageType: (value) => {\n if (!Array.isArray(value)) return value;\n const variants = ['User', 'System', 'Directive'];\n return variants[value[0]] ?? `variant_${value[0]}`;\n },\n ProjectStatus: (value) => {\n if (!Array.isArray(value)) return value;\n const variants = ['Active', 'Paused'];\n return variants[value[0]] ?? `variant_${value[0]}`;\n },\n TaskStatus: (value) => {\n if (!Array.isArray(value)) return value;\n const variants = ['Open', 'Claimed', 'InProgress', 'Review', 'Completed', 'Blocked', 'Archived'];\n return variants[value[0]] ?? `variant_${value[0]}`;\n },\n VoteType: (value) => {\n if (!Array.isArray(value)) return value;\n const variants = ['Up', 'Down', 'Veto'];\n return variants[value[0]] ?? `variant_${value[0]}`;\n },\n};\n\n// Timestamp decoder - converts microseconds to ISO string\nconst timestampDecoder: Decoder = (value) => {\n if (!Array.isArray(value)) return value;\n const micros = value[0];\n if (typeof micros !== \"number\" && typeof micros !== \"bigint\") return value;\n return new Date(Number(micros) / 1000).toISOString();\n};\n\n// Option decoder - unwraps Some, returns null for None\nconst optionDecoder = (inner?: Decoder): Decoder => (value) => {\n if (!Array.isArray(value)) return value;\n const [tag, payload] = value;\n if (tag === 1) return null; // None\n // For Option<T>, payload is [T] (array with single element)\n // Pass the payload directly to inner decoder - it knows how to handle its format\n if (inner) {\n // Inner decoder expects the wrapped format (e.g., timestampDecoder expects [micros])\n return inner(payload);\n }\n // No inner decoder - unwrap primitives\n return Array.isArray(payload) && payload.length === 1 ? payload[0] : payload;\n};\n\n// Table column decoders\nexport const TABLE_DECODERS: Record<string, Record<string, Decoder>> = {\n agents: {\n 'last_heartbeat': timestampDecoder,\n 'current_task_id': optionDecoder(),\n 'created_at': timestampDecoder,\n 'last_active_at': timestampDecoder,\n 'role': enumDecoders.AgentRole,\n 'status': enumDecoders.AgentStatus,\n },\n channels: {\n 'created_at': timestampDecoder,\n },\n discovered_tasks: {\n 'created_task_id': optionDecoder(),\n 'rejection_reason': optionDecoder(),\n 'created_at': timestampDecoder,\n 'reviewed_at': optionDecoder(timestampDecoder),\n 'reviewed_by': optionDecoder(),\n 'status': enumDecoders.DiscoveredTaskStatus,\n },\n ideas: {\n 'created_at': timestampDecoder,\n 'updated_at': timestampDecoder,\n 'status': enumDecoders.IdeaStatus,\n },\n identity_roles: {\n 'role': enumDecoders.AgentRole,\n },\n messages: {\n 'context_id': optionDecoder(),\n 'created_at': timestampDecoder,\n },\n project_channels: {\n 'created_at': timestampDecoder,\n },\n project_messages: {\n 'context_id': optionDecoder(),\n 'created_at': timestampDecoder,\n },\n projects: {\n 'created_at': timestampDecoder,\n 'status': enumDecoders.ProjectStatus,\n },\n task_dependencies: {\n 'created_at': timestampDecoder,\n },\n tasks: {\n 'assigned_to': optionDecoder(),\n 'claimed_at': optionDecoder(timestampDecoder),\n 'github_issue_url': optionDecoder(),\n 'github_pr_url': optionDecoder(),\n 'source_idea_id': optionDecoder(),\n 'archived_reason': optionDecoder(),\n 'status_changed_by': optionDecoder(),\n 'status_changed_at': optionDecoder(timestampDecoder),\n 'created_at': timestampDecoder,\n 'updated_at': timestampDecoder,\n 'status': enumDecoders.TaskStatus,\n 'blocked_from_status': optionDecoder(enumDecoders.TaskStatus),\n },\n voice_announcements: {\n 'context_type': optionDecoder(),\n 'context_id': optionDecoder(),\n 'finalized_at': optionDecoder(timestampDecoder),\n 'failed_at': optionDecoder(timestampDecoder),\n 'error_message': optionDecoder(),\n 'created_at': timestampDecoder,\n 'status': enumDecoders.AnnouncementStatus,\n },\n votes: {\n 'created_at': timestampDecoder,\n },\n};\n\n/**\n * Decode a row using table-specific decoders.\n * @param row - The raw row from SQL query\n * @param columnNames - Ordered column names from schema\n * @param tableName - The table name for decoder lookup\n * @returns Decoded row with human-readable values\n */\nexport function decodeRow(\n row: unknown[],\n columnNames: string[],\n tableName?: string\n): Record<string, unknown> {\n const decoders = tableName ? TABLE_DECODERS[tableName] : undefined;\n const result: Record<string, unknown> = {};\n \n for (let i = 0; i < columnNames.length; i++) {\n const colName = columnNames[i];\n const value = row[i];\n const decoder = decoders?.[colName];\n result[colName] = decoder ? decoder(value) : value;\n }\n \n return result;\n}\n\n/**\n * Infer table name from a simple SQL query.\n * Only works for straightforward \"SELECT ... FROM table\" queries.\n */\nexport function inferTableName(sql: string): string | undefined {\n const match = sql.match(/FROM\\s+(\\w+)/i);\n return match?.[1]?.toLowerCase();\n}","export interface SqlColumn {\n\tname: string;\n\ttype: string;\n}\n\nexport interface SqlSchema {\n\tcolumns: SqlColumn[];\n}\n\nexport interface SqlStatementResult {\n\tschema: SqlSchema | unknown;\n\trows: unknown[];\n}\n\nexport interface SqlRowObject {\n\t[key: string]: unknown;\n}\n\nexport interface SqlSchemaElement {\n\tname: { some?: string } | string;\n\talgebraic_type?: unknown;\n\ttype?: string;\n}\n\nexport interface SqlSchemaAlt {\n\telements?: SqlSchemaElement[];\n}\n\nconst extractColumnName = (element: SqlSchemaElement): string | undefined => {\n\tif (typeof element.name === \"string\") {\n\t\treturn element.name;\n\t}\n\tif (\n\t\telement.name &&\n\t\ttypeof element.name === \"object\" &&\n\t\t\"some\" in element.name\n\t) {\n\t\treturn element.name.some;\n\t}\n\treturn undefined;\n};\n\nexport interface SqlRequestOptions {\n\thost: string;\n\tmoduleName: string;\n\ttoken: string;\n\tsql: string;\n\ttimeoutMs: number;\n}\n\nexport interface SqlRequestSuccess {\n\tresults: SqlStatementResult[];\n\tdurationMs: number;\n}\n\nexport class SqlRequestError extends Error {\n\treadonly status: number;\n\treadonly responseBody: string;\n\n\tconstructor(status: number, responseBody: string, message?: string) {\n\t\tsuper(message || `SQL request failed with status ${status}`);\n\t\tthis.name = \"SqlRequestError\";\n\t\tthis.status = status;\n\t\tthis.responseBody = responseBody;\n\t}\n}\n\nexport const normalizeSqlHttpBase = (host: string): string => {\n\tconst url = new URL(host);\n\tif (url.protocol === \"ws:\") {\n\t\turl.protocol = \"http:\";\n\t} else if (url.protocol === \"wss:\") {\n\t\turl.protocol = \"https:\";\n\t} else if (url.protocol !== \"http:\" && url.protocol !== \"https:\") {\n\t\tthrow new Error(`Unsupported host protocol: ${url.protocol}`);\n\t}\n\treturn url.toString();\n};\n\nexport const buildSqlEndpoint = (host: string, moduleName: string): string => {\n\tconst base = normalizeSqlHttpBase(host);\n\tconst url = new URL(base);\n\tconst basePath = url.pathname.replace(/\\/$/, \"\");\n\turl.pathname = `${basePath}/v1/database/${encodeURIComponent(moduleName)}/sql`;\n\treturn url.toString();\n};\n\nconst parseResults = (payload: unknown): SqlStatementResult[] => {\n\tif (!Array.isArray(payload)) {\n\t\tthrow new Error(\n\t\t\t\"Invalid SQL response: expected array of statement results\",\n\t\t);\n\t}\n\treturn payload.map((statement) => {\n\t\tconst record = statement as { schema?: unknown; rows?: unknown };\n\t\tconst rows = Array.isArray(record.rows) ? record.rows : [];\n\t\treturn {\n\t\t\tschema: record.schema,\n\t\t\trows,\n\t\t};\n\t});\n};\n\nexport const executeSqlRequest = async (\n\toptions: SqlRequestOptions,\n): Promise<SqlRequestSuccess> => {\n\tconst endpoint = buildSqlEndpoint(options.host, options.moduleName);\n\tconst controller = new AbortController();\n\tconst timeoutHandle = setTimeout(() => controller.abort(), options.timeoutMs);\n\tconst started = Date.now();\n\n\ttry {\n\t\tconst response = await fetch(endpoint, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: {\n\t\t\t\tAuthorization: `Bearer ${options.token}`,\n\t\t\t\t\"Content-Type\": \"text/plain\",\n\t\t\t\tAccept: \"application/json\",\n\t\t\t},\n\t\t\tbody: options.sql,\n\t\t\tsignal: controller.signal,\n\t\t});\n\n\t\tconst responseText = await response.text();\n\t\tif (!response.ok) {\n\t\t\tthrow new SqlRequestError(response.status, responseText);\n\t\t}\n\n\t\tlet parsed: unknown;\n\t\ttry {\n\t\t\tparsed = responseText ? JSON.parse(responseText) : [];\n\t\t} catch {\n\t\t\tthrow new Error(\"Invalid SQL response: expected JSON payload\");\n\t\t}\n\n\t\treturn {\n\t\t\tresults: parseResults(parsed),\n\t\t\tdurationMs: Date.now() - started,\n\t\t};\n\t} finally {\n\t\tclearTimeout(timeoutHandle);\n\t}\n};\n\n// Extract column names from schema for use in responses\nexport const extractColumnNames = (result: SqlStatementResult): string[] => {\n\tconst schema = result.schema as SqlSchema | SqlSchemaAlt | undefined;\n\n\tif (schema && \"elements\" in schema && Array.isArray(schema.elements)) {\n\t\treturn schema.elements\n\t\t\t.map(extractColumnName)\n\t\t\t.filter((name): name is string => name !== undefined);\n\t} else if (schema && \"columns\" in schema && Array.isArray(schema.columns)) {\n\t\treturn schema.columns.map((col) => col.name);\n\t}\n\n\treturn [];\n};\n\n// Parse SQL error to provide helpful suggestions\nexport const parseSqlError = (\n\tresponseBody: string,\n): { message: string; suggestion?: string } => {\n\t// Try to parse as JSON first, fallback to plain text\n\tlet errorMsg: string;\n\ttry {\n\t\tconst parsed = JSON.parse(responseBody);\n\t\terrorMsg = parsed.error || responseBody;\n\t} catch {\n\t\terrorMsg = responseBody;\n\t}\n\n\t// Common SpacetimeDB SQL errors with suggestions\n\tif (errorMsg.includes(\"ORDER BY\")) {\n\t\treturn {\n\t\t\tmessage: errorMsg,\n\t\t\tsuggestion:\n\t\t\t\t\"SpacetimeDB SQL does not support ORDER BY. Remove it or filter/sort results locally.\",\n\t\t};\n\t}\n\tif (errorMsg.includes(\"IS NULL\") || errorMsg.includes(\"IS NOT NULL\")) {\n\t\treturn {\n\t\t\tmessage: errorMsg,\n\t\t\tsuggestion:\n\t\t\t\t'Use \"column = NULL\" or \"column != NULL\" instead of IS NULL / IS NOT NULL.',\n\t\t};\n\t}\n\tif (errorMsg.includes(\"JOIN\")) {\n\t\treturn {\n\t\t\tmessage: errorMsg,\n\t\t\tsuggestion:\n\t\t\t\t\"SpacetimeDB has limited JOIN support. Try querying single tables or use multiple queries.\",\n\t\t};\n\t}\n\tif (errorMsg.includes(\"no such table\")) {\n\t\treturn {\n\t\t\tmessage: errorMsg,\n\t\t\tsuggestion:\n\t\t\t\t\"Check the table name. Common tables: tasks, projects, agents, ideas, messages.\",\n\t\t};\n\t}\n\tif (errorMsg.includes(\"no such column\")) {\n\t\treturn {\n\t\t\tmessage: errorMsg,\n\t\t\tsuggestion:\n\t\t\t\t\"Check the column name. Use SELECT * to see all available columns.\",\n\t\t};\n\t}\n\n\treturn { message: errorMsg };\n};\n","import { readFile } from \"node:fs/promises\";\nimport { defineCommand } from \"citty\";\nimport { inferTableName, TABLE_DECODERS } from \"~/generated/decoders.js\";\nimport { getConfig } from \"~/utils/config.js\";\nimport { printHelp } from \"~/utils/help.js\";\nimport { error, isJsonMode, setJsonMode, success } from \"~/utils/output.js\";\nimport {\n\texecuteSqlRequest,\n\textractColumnNames,\n\tparseSqlError,\n\tSqlRequestError,\n\ttype SqlStatementResult,\n} from \"~/utils/sql.js\";\nimport { getCachedToken } from \"~/utils/token-cache.js\";\nimport { getWalletInfo } from \"~/utils/wallet.js\";\n\n// Known tables derived from generated decoders\nconst KNOWN_TABLES = Object.keys(TABLE_DECODERS);\n\nimport { formatToon } from \"~/utils/toon.js\";\n\n// Helper to handle query errors with improved messages\nconst handleQueryError = (err: unknown, timeoutMs: number): never => {\n\tif (err instanceof SqlRequestError) {\n\t\tif (err.status === 401) {\n\t\t\terror(\n\t\t\t\t\"AUTH_REQUIRED\",\n\t\t\t\t\"Authentication required. Run `probe auth <wallet> --save` first.\",\n\t\t\t);\n\t\t}\n\t\tconst { message, suggestion } = parseSqlError(err.responseBody);\n\t\t// Error parsed with potential suggestion\n\t\tif (err.status === 400) {\n\t\t\terror(\"SQL_INVALID\", message, suggestion);\n\t\t}\n\t\terror(\"SQL_FAILED\", message, suggestion);\n\t}\n\n\tif (err instanceof Error && err.name === \"AbortError\") {\n\t\terror(\"SQL_UNAVAILABLE\", `SQL request timed out after ${timeoutMs}ms`);\n\t}\n\n\terror(\n\t\t\"SQL_UNAVAILABLE\",\n\t\terr instanceof Error ? err.message : \"SQL request failed\",\n\t);\n};\n\nconst DEFAULT_TIMEOUT_MS = 30_000;\n\nconst buildMeta = (results: SqlStatementResult[], durationMs: number) => ({\n\tduration_ms: durationMs,\n\tquery_count: results.length,\n\trow_count_total: results.reduce((sum, item) => sum + item.rows.length, 0),\n});\n\n// Build flat response structure for JSON mode\ninterface QueryResult {\n\tcolumns: string[];\n\trows: Record<string, unknown>[];\n}\n\nconst buildFlatResponse = (\n\tresults: SqlStatementResult[],\n\tshouldDecode: boolean,\n\ttableName?: string,\n): Record<string, QueryResult> => {\n\tconst response: Record<string, QueryResult> = {};\n\n\tfor (let index = 0; index < results.length; index += 1) {\n\t\tconst statement = results[index];\n\t\tconst columns = extractColumnNames(statement);\n\t\tconst decoders =\n\t\t\tshouldDecode && tableName ? TABLE_DECODERS[tableName] : undefined;\n\n\t\tconst rowObjects = (statement.rows as unknown[][]).map((row) => {\n\t\t\tconst obj: Record<string, unknown> = {};\n\t\t\tfor (let i = 0; i < columns.length; i++) {\n\t\t\t\tconst colName = columns[i];\n\t\t\t\tconst value = row[i];\n\t\t\t\tconst decoder = decoders?.[colName];\n\t\t\t\tobj[colName] = decoder ? decoder(value) : value;\n\t\t\t}\n\t\t\treturn obj;\n\t\t});\n\n\t\tresponse[`query_${index + 1}`] = { columns, rows: rowObjects };\n\t}\n\n\tif (results.length === 0) {\n\t\tresponse.query_1 = { columns: [], rows: [] };\n\t}\n\n\treturn response;\n};\n\nconst formatStatementsToToon = (\n\tresults: SqlStatementResult[],\n\tmetaEnabled: boolean,\n\tdurationMs: number,\n\tshouldDecode: boolean,\n\ttableName?: string,\n): string => {\n\tconst payload: Record<string, unknown> = {};\n\tconst decoders =\n\t\tshouldDecode && tableName ? TABLE_DECODERS[tableName] : undefined;\n\n\tfor (let index = 0; index < results.length; index += 1) {\n\t\tconst statement = results[index];\n\t\tconst columns = extractColumnNames(statement);\n\n\t\tconst rowObjects = (statement.rows as unknown[][]).map((row) => {\n\t\t\tconst obj: Record<string, unknown> = {};\n\t\t\tfor (let i = 0; i < columns.length; i++) {\n\t\t\t\tconst colName = columns[i];\n\t\t\t\tconst value = row[i];\n\t\t\t\tconst decoder = decoders?.[colName];\n\t\t\t\tobj[colName] = decoder ? decoder(value) : value;\n\t\t\t}\n\t\t\treturn obj;\n\t\t});\n\n\t\tpayload[`query_${index + 1}`] = rowObjects;\n\t}\n\n\tif (results.length === 0) {\n\t\tpayload.query_1 = [];\n\t}\n\n\tif (metaEnabled) {\n\t\tconst meta = buildMeta(results, durationMs);\n\t\tpayload.meta = [meta];\n\t}\n\n\treturn formatToon(payload);\n};\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"query\",\n\t\tdescription: \"Run SQL read queries against Nexus\",\n\t},\n\targs: {\n\t\tsql: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"SQL query string\",\n\t\t\trequired: false,\n\t\t},\n\t\tfile: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Read SQL from file path\",\n\t\t},\n\t\twallet: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Wallet name override\",\n\t\t},\n\t\thost: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"SpacetimeDB host override\",\n\t\t},\n\t\tmodule: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"SpacetimeDB module override\",\n\t\t},\n\t\ttimeout: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Request timeout in milliseconds\",\n\t\t},\n\t\tmeta: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Include metadata in output\",\n\t\t\tdefault: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t\ttables: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"List all available tables\",\n\t\t\tdefault: false,\n\t\t},\n\t\tdecode: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Decode algebraic types to human-readable values\",\n\t\t\tdefault: true,\n\t\t},\n\t\traw: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output raw algebraic type arrays (no decoding)\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) {\n\t\t\tsetJsonMode(true);\n\t\t}\n\n\t\tconst hasSql = args.sql || args.file;\n\n\t\t// Handle --tables flag\n\t\tif (args.tables) {\n\t\t\tif (isJsonMode()) {\n\t\t\t\tsuccess({ tables: KNOWN_TABLES });\n\t\t\t} else {\n\t\t\t\tconsole.log(formatToon({ tables: KNOWN_TABLES }));\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Validate arguments\n\t\tif (!hasSql) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe query\",\n\t\t\t\tdescription:\n\t\t\t\t\t\"Execute SQL against the configured Nexus SpacetimeDB module\",\n\t\t\t\tusage: [\n\t\t\t\t\t'probe query \"SELECT * FROM tasks LIMIT 5\"',\n\t\t\t\t\t\"probe query --file ./query.sql --meta\",\n\t\t\t\t\t\"probe query --tables\",\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--file\", detail: \"Read SQL from file\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--wallet\",\n\t\t\t\t\t\tdetail: \"Wallet override (defaults to config defaultWallet)\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--host, --module\",\n\t\t\t\t\t\tdetail: \"Nexus SpacetimeDB target overrides\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--timeout\",\n\t\t\t\t\t\tdetail: `Request timeout in ms (default: ${DEFAULT_TIMEOUT_MS})`,\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"--meta\", detail: \"Include metadata in output\" },\n\t\t\t\t\t{ name: \"--json\", detail: \"JSON output mode with keyed objects\" },\n\t\t\t\t\t{ name: \"--tables\", detail: \"List all available tables\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--decode\",\n\t\t\t\t\t\tdetail: \"Decode algebraic types (default: true)\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--raw\",\n\t\t\t\t\t\tdetail: \"Output raw algebraic arrays (no decoding)\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tnotes: [\n\t\t\t\t\t\"This command is read-only and intended for SQL queries against Nexus tables.\",\n\t\t\t\t\t'JSON mode returns keyed objects: {\"query_1\": {\"columns\": [...], \"rows\": [{\"id\": 1, ...}]}}',\n\t\t\t\t\t\"Use --raw to see raw SpacetimeDB algebraic type arrays.\",\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst timeoutMs = args.timeout\n\t\t\t? Number.parseInt(args.timeout, 10)\n\t\t\t: DEFAULT_TIMEOUT_MS;\n\t\tif (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {\n\t\t\terror(\"INVALID_TIMEOUT\", `Invalid timeout: ${args.timeout}`);\n\t\t}\n\n\t\tconst config = await getConfig();\n\t\tconst walletName = args.wallet || config.defaultWallet;\n\t\tif (!walletName) {\n\t\t\terror(\n\t\t\t\t\"WALLET_REQUIRED\",\n\t\t\t\t\"Wallet required. Use --wallet or set default wallet.\",\n\t\t\t);\n\t\t}\n\n\t\tconst wallet = await getWalletInfo(walletName);\n\t\tif (!wallet) {\n\t\t\terror(\"WALLET_NOT_FOUND\", `Wallet not found: ${walletName}`);\n\t\t}\n\n\t\tconst cached = await getCachedToken(walletName);\n\t\tif (!cached) {\n\t\t\terror(\n\t\t\t\t\"AUTH_REQUIRED\",\n\t\t\t\t\"No cached token. Run `probe auth <wallet> --save` first.\",\n\t\t\t);\n\t\t}\n\n\t\tconst host = args.host || config.spacetime.host;\n\t\tconst moduleName = args.module || config.spacetime.module;\n\t\tconst sql = args.file\n\t\t\t? await readFile(args.file, \"utf-8\")\n\t\t\t: (args.sql ?? \"\");\n\t\tif (!sql.trim()) {\n\t\t\terror(\"SQL_REQUIRED\", \"SQL query is empty\");\n\t\t}\n\n\t\t// Determine if we should decode algebraic types\n\t\tconst shouldDecode = args.raw ? false : (args.decode ?? true);\n\t\tconst tableName = inferTableName(sql);\n\n\t\ttry {\n\t\t\tconst { results, durationMs } = await executeSqlRequest({\n\t\t\t\thost,\n\t\t\t\tmoduleName,\n\t\t\t\ttoken: cached.token,\n\t\t\t\tsql,\n\t\t\t\ttimeoutMs,\n\t\t\t});\n\n\t\t\tif (isJsonMode()) {\n\t\t\t\tconst flatResponse = buildFlatResponse(\n\t\t\t\t\tresults,\n\t\t\t\t\tshouldDecode,\n\t\t\t\t\ttableName,\n\t\t\t\t);\n\t\t\t\tif (args.meta) {\n\t\t\t\t\tsuccess({ ...flatResponse, meta: buildMeta(results, durationMs) });\n\t\t\t\t} else {\n\t\t\t\t\tsuccess(flatResponse);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconsole.log(\n\t\t\t\tformatStatementsToToon(\n\t\t\t\t\tresults,\n\t\t\t\t\tBoolean(args.meta),\n\t\t\t\t\tdurationMs,\n\t\t\t\t\tshouldDecode,\n\t\t\t\t\ttableName,\n\t\t\t\t),\n\t\t\t);\n\t\t} catch (err) {\n\t\t\thandleQueryError(err, timeoutMs);\n\t\t}\n\t},\n});\n","import { Buffer } from \"node:buffer\";\nimport { readFile } from \"node:fs/promises\";\nimport { defineCommand } from \"citty\";\nimport { resolvePasswordInput } from \"~/utils/credentials.js\";\nimport { printHelp } from \"~/utils/help.js\";\nimport {\n\terror,\n\tisJsonMode,\n\tsetJsonMode,\n\tsuccess,\n\tsuccessMessage,\n} from \"~/utils/output.js\";\nimport { loadWallet } from \"~/utils/wallet.js\";\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"sign\",\n\t\tdescription: \"Sign a message using wallet private key\",\n\t},\n\targs: {\n\t\tname: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Wallet name\",\n\t\t\trequired: false,\n\t\t},\n\t\tmessage: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Message to sign\",\n\t\t\trequired: false,\n\t\t},\n\t\t\"message-file\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Read message from file\",\n\t\t},\n\t\t\"password-file\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Read password from file\",\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) {\n\t\t\tsetJsonMode(true);\n\t\t}\n\n\t\tconst name = args.name;\n\n\t\tif (!name) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe sign\",\n\t\t\t\tdescription: \"Sign arbitrary text using wallet private key\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe sign <wallet-name> <message> [options]\",\n\t\t\t\t\t\"probe sign <wallet-name> --message-file ./payload.txt [options]\",\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--message-file\", detail: \"Read message content from file\" },\n\t\t\t\t\t{ name: \"--password-file\", detail: \"Read wallet password from file\" },\n\t\t\t\t\t{ name: \"--json\", detail: \"JSON output for agents\" },\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tlet message: string;\n\n\t\tif (args[\"message-file\"]) {\n\t\t\ttry {\n\t\t\t\tmessage = await readFile(args[\"message-file\"], \"utf-8\");\n\t\t\t} catch {\n\t\t\t\terror(\n\t\t\t\t\t\"FILE_READ_ERROR\",\n\t\t\t\t\t`Failed to read message file: ${args[\"message-file\"]}`,\n\t\t\t\t);\n\t\t\t}\n\t\t} else if (args.message) {\n\t\t\tmessage = args.message;\n\t\t} else {\n\t\t\terror(\"MESSAGE_REQUIRED\", \"Message or message-file required\");\n\t\t}\n\n\t\tconst walletPassword = await resolvePasswordInput({\n\t\t\tpasswordFile: args[\"password-file\"],\n\t\t\tpromptMessage: \"Enter wallet password:\",\n\t\t\tjsonModeError:\n\t\t\t\t\"Password file required in JSON mode or provide PROBE_WALLET_PASSWORD\",\n\t\t});\n\n\t\ttry {\n\t\t\tconst keyStore = await loadWallet(name, walletPassword);\n\t\t\tconst keyPair = keyStore.getKeyPair(0);\n\n\t\t\tconst signature = keyPair.sign(Buffer.from(message));\n\t\t\tconst publicKey = keyPair.getPublicKey();\n\t\t\tconst address = keyPair.getAddress();\n\n\t\t\tsuccess({\n\t\t\t\twallet: name,\n\t\t\t\tmessage,\n\t\t\t\tsignature: signature.toString(\"hex\"),\n\t\t\t\tpublicKey: publicKey.toString(\"hex\"),\n\t\t\t\taddress: address.toString(),\n\t\t\t});\n\n\t\t\tif (!isJsonMode()) {\n\t\t\t\tsuccessMessage(\"Message signed successfully\");\n\t\t\t\tconsole.log(`Signature: ${signature.toString(\"hex\")}`);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\terror(\n\t\t\t\t\"SIGN_ERROR\",\n\t\t\t\terr instanceof Error ? err.message : \"Failed to sign message\",\n\t\t\t);\n\t\t}\n\t},\n});\n","import { defineCommand } from \"citty\";\nimport { printHelp } from \"~/utils/help.js\";\nimport {\n\terror,\n\tinfo,\n\tisJsonMode,\n\tsetJsonMode,\n\tsuccess,\n} from \"~/utils/output.js\";\nimport { clearCachedToken, getCachedToken } from \"~/utils/token-cache.js\";\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"token\",\n\t\tdescription: \"Show cached JWT token for wallet\",\n\t},\n\targs: {\n\t\tname: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Wallet name\",\n\t\t\trequired: false,\n\t\t},\n\t\tclear: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Clear cached token now (next auth call gets a new token)\",\n\t\t\tdefault: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) {\n\t\t\tsetJsonMode(true);\n\t\t}\n\n\t\tconst name = args.name;\n\n\t\tif (!name) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe token\",\n\t\t\t\tdescription: \"Inspect or clear cached authentication token\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe token <wallet-name> [options]\",\n\t\t\t\t\t\"probe token <wallet-name> --clear\",\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--clear\", detail: \"Clear cached token now (recommended)\" },\n\t\t\t\t\t{ name: \"--json\", detail: \"JSON output for agents\" },\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tif (args.clear) {\n\t\t\tawait clearCachedToken(name);\n\n\t\t\tsuccess({ cleared: name });\n\n\t\t\tif (!isJsonMode()) {\n\t\t\t\tinfo(\n\t\t\t\t\t`Token cache cleared for \"${name}\". Run 'probe auth' to get a new token.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst cached = await getCachedToken(name);\n\n\t\t\tif (!cached) {\n\t\t\t\terror(\n\t\t\t\t\t\"TOKEN_NOT_FOUND\",\n\t\t\t\t\t`No cached token for wallet '${name}'`,\n\t\t\t\t\t`Run 'probe auth ${name} --save' to authenticate`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst expiresAt = new Date(cached.expiresAt);\n\t\t\tconst now = new Date();\n\t\t\tconst expiresIn = Math.floor(\n\t\t\t\t(expiresAt.getTime() - now.getTime()) / 1000,\n\t\t\t);\n\t\t\tconst valid = expiresIn > 0;\n\n\t\t\tsuccess({\n\t\t\t\twallet: name,\n\t\t\t\ttoken: cached.token,\n\t\t\t\texpiresAt: cached.expiresAt,\n\t\t\t\texpiresIn: Math.max(0, expiresIn),\n\t\t\t\tvalid,\n\t\t\t});\n\n\t\t\tif (!isJsonMode()) {\n\t\t\t\tconsole.log(`Wallet: ${name}`);\n\t\t\t\tconsole.log(`Token: ${cached.token.slice(0, 50)}...`);\n\t\t\t\tconsole.log(`Expires: ${expiresAt.toUTCString()}`);\n\t\t\t\tconsole.log(`Status: ${valid ? \"Valid\" : \"Expired\"}`);\n\n\t\t\t\tif (!valid) {\n\t\t\t\t\tinfo(\n\t\t\t\t\t\t\"Token has expired. Run with --clear to remove it and re-authenticate.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err) {\n\t\t\terror(\n\t\t\t\t\"TOKEN_ERROR\",\n\t\t\t\terr instanceof Error ? err.message : \"Failed to read token\",\n\t\t\t);\n\t\t}\n\t},\n});\n","import { execSync } from \"node:child_process\";\nimport { createHash } from \"node:crypto\";\nimport {\n\tcreateWriteStream,\n\texistsSync,\n\treadFileSync,\n\trenameSync,\n\tunlinkSync,\n} from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { arch, platform } from \"node:os\";\nimport { dirname, resolve } from \"node:path\";\nimport { Readable } from \"node:stream\";\nimport { finished } from \"node:stream/promises\";\n\nexport type InstallMethod = \"npm\" | \"binary\" | \"unknown\";\nexport type InstallMethodArg = \"auto\" | \"npm\" | \"binary\";\n\nconst PACKAGE = \"@zenon-red/probe\";\nconst REPO = \"zenon-red/probe\";\nconst NPM_REGISTRY = \"https://registry.npmjs.org\";\nconst GITHUB_API = \"https://api.github.com\";\nconst REQUEST_TIMEOUT = 30_000;\n\nconst require = createRequire(import.meta.url);\n\nexport function normalizeVersion(input: string): string {\n\tconst trimmed = input.trim();\n\tif (trimmed.startsWith(`${PACKAGE}@`)) {\n\t\treturn trimmed.slice(`${PACKAGE}@`.length);\n\t}\n\tif (trimmed.startsWith(\"refs/tags/\")) {\n\t\treturn normalizeVersion(trimmed.slice(\"refs/tags/\".length));\n\t}\n\treturn trimmed.replace(/^v/, \"\");\n}\n\nexport function getCurrentVersion(): string {\n\tconst candidates = [\n\t\t\"../../package.json\",\n\t\t\"../package.json\",\n\t\t\"../../../package.json\",\n\t];\n\ttry {\n\t\tfor (const candidate of candidates) {\n\t\t\ttry {\n\t\t\t\tconst version = require(candidate).version as string;\n\t\t\t\tif (version) return version;\n\t\t\t} catch {\n\t\t\t\t// try next candidate\n\t\t\t}\n\t\t}\n\t\tif (process.env.npm_package_version) {\n\t\t\treturn process.env.npm_package_version;\n\t\t}\n\t} catch {\n\t\t// fallthrough\n\t}\n\treturn \"0.0.0\";\n}\n\nexport function detectMethod(explicit?: InstallMethodArg): InstallMethod {\n\tif (explicit && explicit !== \"auto\") return explicit;\n\n\tconst execPath = process.execPath;\n\tconst argv1 = process.argv[1] || \"\";\n\tlet resolvedProbePath = \"\";\n\n\ttry {\n\t\tresolvedProbePath = execSync(\"command -v probe\", {\n\t\t\ttimeout: 5_000,\n\t\t\tencoding: \"utf8\",\n\t\t}).trim();\n\t} catch {\n\t\t// ignore lookup failures\n\t}\n\n\t// Standalone binary heuristics\n\tif (\n\t\texecPath.includes(\".probe\") ||\n\t\texecPath.includes(\"probe-linux\") ||\n\t\texecPath.includes(\"probe-darwin\") ||\n\t\texecPath.includes(\"probe-windows\") ||\n\t\targv1.includes(\".probe\") ||\n\t\tresolvedProbePath.includes(\".probe\") ||\n\t\tresolvedProbePath.includes(\"probe-linux\") ||\n\t\tresolvedProbePath.includes(\"probe-darwin\") ||\n\t\tresolvedProbePath.includes(\"probe-windows\")\n\t) {\n\t\treturn \"binary\";\n\t}\n\n\t// npm global install heuristic\n\tif (\n\t\targv1.includes(\"node_modules\") ||\n\t\tresolvedProbePath.includes(\"node_modules\")\n\t)\n\t\treturn \"npm\";\n\n\t// Try npm list (only if npm exists)\n\ttry {\n\t\tconst out = execSync(\"npm list -g @zenon-red/probe --depth=0 2>/dev/null\", {\n\t\t\ttimeout: 10_000,\n\t\t\tencoding: \"utf8\",\n\t\t});\n\t\tif (out.includes(\"@zenon-red/probe\")) return \"npm\";\n\t} catch {\n\t\t// npm not found or not installed globally\n\t}\n\n\treturn \"unknown\";\n}\n\nexport async function fetchLatestNpmVersion(): Promise<string> {\n\tconst url = `${NPM_REGISTRY}/${PACKAGE}/latest`;\n\tconst res = await fetch(url, {\n\t\tsignal: AbortSignal.timeout(REQUEST_TIMEOUT),\n\t});\n\tif (!res.ok) throw new Error(`npm registry returned ${res.status}`);\n\tconst data = (await res.json()) as { version?: string };\n\tif (!data.version) throw new Error(\"No version field in npm response\");\n\treturn normalizeVersion(data.version);\n}\n\nexport interface GitHubRelease {\n\ttag_name: string;\n\tassets: Array<{ name: string; browser_download_url: string }>;\n}\n\nasync function fetchGitHubRelease(path: string): Promise<GitHubRelease> {\n\tconst url = `${GITHUB_API}/repos/${REPO}/releases/${path}`;\n\tconst res = await fetch(url, {\n\t\theaders: { Accept: \"application/vnd.github+json\" },\n\t\tsignal: AbortSignal.timeout(REQUEST_TIMEOUT),\n\t});\n\tif (!res.ok) throw new Error(`GitHub API returned ${res.status}`);\n\treturn (await res.json()) as GitHubRelease;\n}\n\nexport async function fetchLatestGitHubRelease(): Promise<{\n\tversion: string;\n\trelease: GitHubRelease;\n}> {\n\tconst release = await fetchGitHubRelease(\"latest\");\n\tconst version = normalizeVersion(release.tag_name);\n\treturn { version, release };\n}\n\nexport async function fetchGitHubReleaseByVersion(\n\tversion: string,\n): Promise<GitHubRelease> {\n\tconst normalized = normalizeVersion(version);\n\ttry {\n\t\treturn await fetchGitHubRelease(`tags/v${normalized}`);\n\t} catch (err) {\n\t\tconst message = err instanceof Error ? err.message : \"\";\n\t\tif (!message.includes(\"404\")) {\n\t\t\tthrow err;\n\t\t}\n\t\tconst packageTag = encodeURIComponent(`${PACKAGE}@${normalized}`);\n\t\treturn await fetchGitHubRelease(`tags/${packageTag}`);\n\t}\n}\n\nexport function resolveBinaryAssetName(): string {\n\tconst p = platform();\n\tconst a = arch();\n\n\tconst platformMap: Record<string, string> = {\n\t\tlinux: \"linux\",\n\t\tdarwin: \"darwin\",\n\t\twindows: \"windows\",\n\t};\n\tconst archMap: Record<string, string> = {\n\t\tx64: \"x64\",\n\t\tarm64: \"arm64\",\n\t};\n\n\tconst plat = platformMap[p];\n\tconst cpuArch = archMap[a];\n\tif (!plat || !cpuArch) {\n\t\tthrow new Error(`Unsupported platform: ${p}/${cpuArch}`);\n\t}\n\n\tconst ext = (platform() as string) === \"windows\" ? \".exe\" : \"\";\n\treturn `probe-${plat}-${cpuArch}${ext}`;\n}\n\nexport function getBinaryDir(): string {\n\treturn dirname(process.execPath);\n}\n\nexport async function downloadFile(url: string, dest: string): Promise<void> {\n\tconst res = await fetch(url, {\n\t\tsignal: AbortSignal.timeout(REQUEST_TIMEOUT * 2),\n\t\tredirect: \"follow\",\n\t});\n\tif (!res.ok)\n\t\tthrow new Error(`Download failed: ${res.status} ${res.statusText}`);\n\tif (!res.body) throw new Error(\"Empty response body\");\n\n\tconst nodeStream = Readable.fromWeb(\n\t\tres.body as unknown as import(\"node:stream/web\").ReadableStream,\n\t);\n\tconst ws = createWriteStream(dest, { mode: 0o755 });\n\tawait finished(nodeStream.pipe(ws));\n}\n\nexport function verifyChecksum(filePath: string, checksums: string): boolean {\n\tconst fileName =\n\t\tfilePath.split(\"/\").pop() || filePath.split(\"\\\\\").pop() || \"\";\n\tconst lines = checksums.split(\"\\n\");\n\tlet expected = \"\";\n\tfor (const line of lines) {\n\t\tconst [hash, name] = line.trim().split(/\\s+/);\n\t\tif (name === fileName) {\n\t\t\texpected = hash;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (!expected) return false;\n\n\tconst data = readFileSync(filePath);\n\tconst actual = createHash(\"sha256\").update(data).digest(\"hex\");\n\treturn actual === expected;\n}\n\nexport async function upgradeViaNpm(target: string): Promise<void> {\n\tconst version = normalizeVersion(target);\n\texecSync(`npm install -g ${PACKAGE}@${version}`, {\n\t\tstdio: \"inherit\",\n\t\ttimeout: 120_000,\n\t});\n}\n\nexport async function upgradeViaBinary(\n\trelease: GitHubRelease,\n\t_target: string,\n): Promise<void> {\n\tconst assetName = resolveBinaryAssetName();\n\tconst asset = release.assets.find((a) => a.name === assetName);\n\tif (!asset) throw new Error(`Asset not found for ${assetName}`);\n\n\tconst checksumAsset = release.assets.find(\n\t\t(a) => a.name === \"SHA256SUMS.txt\",\n\t);\n\tif (!checksumAsset) throw new Error(\"SHA256SUMS.txt not found in release\");\n\n\tconst binDir = getBinaryDir();\n\tconst targetPath = resolve(\n\t\tbinDir,\n\t\t(platform() as string) === \"windows\" ? \"probe.exe\" : \"probe\",\n\t);\n\tconst tmpPath = `${targetPath}.tmp`;\n\tconst backupPath = `${targetPath}.bak`;\n\n\t// Download binary + checksum\n\tawait downloadFile(asset.browser_download_url, tmpPath);\n\n\tconst checksumRes = await fetch(checksumAsset.browser_download_url, {\n\t\tsignal: AbortSignal.timeout(REQUEST_TIMEOUT),\n\t});\n\tif (!checksumRes.ok) throw new Error(\"Failed to download SHA256SUMS.txt\");\n\tconst checksums = await checksumRes.text();\n\n\t// Verify checksum\n\tif (!verifyChecksum(tmpPath, checksums)) {\n\t\tunlinkSync(tmpPath);\n\t\tthrow new Error(\"CHECKSUM_MISMATCH\");\n\t}\n\n\t// Atomic replace with rollback\n\ttry {\n\t\tif (existsSync(targetPath)) {\n\t\t\trenameSync(targetPath, backupPath);\n\t\t}\n\t\trenameSync(tmpPath, targetPath);\n\t\t// Post-upgrade smoke test\n\t\texecSync(`\"${targetPath}\" --version`, {\n\t\t\ttimeout: 10_000,\n\t\t\tencoding: \"utf8\",\n\t\t});\n\t\t// Cleanup backup on success\n\t\tif (existsSync(backupPath)) {\n\t\t\ttry {\n\t\t\t\tunlinkSync(backupPath);\n\t\t\t} catch {\n\t\t\t\t// non-fatal\n\t\t\t}\n\t\t}\n\t} catch (err) {\n\t\t// Rollback\n\t\tif (existsSync(backupPath)) {\n\t\t\ttry {\n\t\t\t\trenameSync(backupPath, targetPath);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`ROLLBACK_FAILED: Upgrade failed and rollback also failed. Backup at: ${backupPath}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (existsSync(tmpPath)) {\n\t\t\ttry {\n\t\t\t\tunlinkSync(tmpPath);\n\t\t\t} catch {\n\t\t\t\t// non-fatal\n\t\t\t}\n\t\t}\n\t\tthrow err;\n\t}\n}\n","import { defineCommand } from \"citty\";\nimport { confirm } from \"@clack/prompts\";\nimport { printHelp } from \"~/utils/help.js\";\nimport {\n\terror,\n\tinfo,\n\tisJsonMode,\n\tsetJsonMode,\n\tsuccess,\n} from \"~/utils/output.js\";\nimport { toonList } from \"~/utils/toon.js\";\nimport {\n\ttype InstallMethod,\n\ttype InstallMethodArg,\n\tdetectMethod,\n\tfetchGitHubReleaseByVersion,\n\tfetchLatestGitHubRelease,\n\tfetchLatestNpmVersion,\n\tgetCurrentVersion,\n\tnormalizeVersion,\n\tupgradeViaBinary,\n\tupgradeViaNpm,\n} from \"~/utils/upgrade.js\";\n\nconst VALID_METHODS = new Set<InstallMethodArg>([\"auto\", \"npm\", \"binary\"]);\n\nconst printUpgradeResult = (data: {\n\tmethod: InstallMethod;\n\tcurrentVersion: string;\n\ttargetVersion: string;\n\tlatestVersion: string;\n\tupdateAvailable: boolean;\n\tupdated: boolean;\n\tcheckOnly: boolean;\n}): void => {\n\tsuccess(data);\n\tif (isJsonMode()) {\n\t\treturn;\n\t}\n\n\tconsole.log(\n\t\ttoonList(\"upgrade_result\", [\n\t\t\t{\n\t\t\t\tmethod: data.method,\n\t\t\t\tcurrentVersion: data.currentVersion,\n\t\t\t\ttargetVersion: data.targetVersion,\n\t\t\t\tlatestVersion: data.latestVersion,\n\t\t\t\tupdated: data.updated,\n\t\t\t\tcheckOnly: data.checkOnly,\n\t\t\t},\n\t\t]),\n\t);\n};\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"upgrade\",\n\t\tdescription: \"Upgrade Probe to the latest or a specific version\",\n\t},\n\targs: {\n\t\ttarget: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Version to upgrade to (e.g. 1.2.0 or v1.2.0)\",\n\t\t\trequired: false,\n\t\t},\n\t\tcheck: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Check for updates without upgrading\",\n\t\t\tdefault: false,\n\t\t},\n\t\tmethod: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Installation method: auto, npm, binary\",\n\t\t},\n\t\tyes: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Skip confirmation prompts\",\n\t\t\tdefault: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) setJsonMode(true);\n\n\t\tif (args.target === \"--help\" || args.target === \"-h\") {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe upgrade\",\n\t\t\t\tdescription: \"Upgrade Probe to the latest or a specific version\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe upgrade\",\n\t\t\t\t\t\"probe upgrade --check\",\n\t\t\t\t\t\"probe upgrade 1.2.0\",\n\t\t\t\t\t\"probe upgrade --method npm\",\n\t\t\t\t\t\"probe upgrade --method binary --yes\",\n\t\t\t\t\t\"probe upgrade --json --check\",\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--check\",\n\t\t\t\t\t\tdetail: \"Check for updates without upgrading\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"--method\", detail: \"Force install method: auto, npm, binary\" },\n\t\t\t\t\t{ name: \"--yes\", detail: \"Skip confirmation prompts\" },\n\t\t\t\t\t{ name: \"--json\", detail: \"JSON output\" },\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst methodArg = args.method as InstallMethodArg | undefined;\n\t\tif (methodArg && !VALID_METHODS.has(methodArg)) {\n\t\t\terror(\n\t\t\t\t\"INVALID_METHOD\",\n\t\t\t\t`Invalid --method value: ${args.method}`,\n\t\t\t\t\"Use: --method auto | npm | binary\",\n\t\t\t);\n\t\t}\n\n\t\tconst currentVersion = getCurrentVersion();\n\t\tconst method = detectMethod(methodArg);\n\n\t\t// Resolve target version\n\t\tlet targetVersion: string | undefined;\n\t\tlet latestVersion: string | undefined;\n\t\tlet targetRelease: Awaited<ReturnType<typeof fetchGitHubReleaseByVersion>> | undefined;\n\n\t\ttry {\n\t\t\tif (args.target) {\n\t\t\t\ttargetVersion = normalizeVersion(args.target);\n\t\t\t\tif (method === \"binary\") {\n\t\t\t\t\ttargetRelease = await fetchGitHubReleaseByVersion(targetVersion);\n\t\t\t\t}\n\t\t\t} else if (method === \"npm\") {\n\t\t\t\tlatestVersion = await fetchLatestNpmVersion();\n\t\t\t\ttargetVersion = latestVersion;\n\t\t\t} else {\n\t\t\t\tconst gh = await fetchLatestGitHubRelease();\n\t\t\t\tlatestVersion = gh.version;\n\t\t\t\ttargetVersion = gh.version;\n\t\t\t\ttargetRelease = gh.release;\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst message =\n\t\t\t\terr instanceof Error ? err.message : \"Failed to check latest version\";\n\t\t\tif (\n\t\t\t\t!args.target &&\n\t\t\t\tmethod === \"binary\" &&\n\t\t\t\tmessage.includes(\"GitHub API returned 404\")\n\t\t\t) {\n\t\t\t\terror(\n\t\t\t\t\t\"NO_RELEASES_PUBLISHED\",\n\t\t\t\t\t\"No GitHub releases are published yet for binary upgrades.\",\n\t\t\t\t\t\"Use: npm install -g @zenon-red/probe (or your package manager) until the first release is published.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\terror(\n\t\t\t\t\"VERSION_LOOKUP_FAILED\",\n\t\t\t\tmessage,\n\t\t\t);\n\t\t}\n\n\t\tif (!targetVersion) {\n\t\t\terror(\"VERSION_LOOKUP_FAILED\", \"Could not determine target version.\");\n\t\t}\n\n\t\tconst updateAvailable = targetVersion !== currentVersion;\n\n\t\t// Check-only mode\n\t\tif (args.check) {\n\t\t\tprintUpgradeResult({\n\t\t\t\tmethod,\n\t\t\t\tcurrentVersion,\n\t\t\t\ttargetVersion: targetVersion,\n\t\t\t\tlatestVersion: latestVersion || targetVersion,\n\t\t\t\tupdateAvailable,\n\t\t\t\tupdated: false,\n\t\t\t\tcheckOnly: true,\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tif (method === \"unknown\") {\n\t\t\terror(\n\t\t\t\t\"METHOD_UNKNOWN\",\n\t\t\t\t\"Could not detect installation method for in-place upgrade.\",\n\t\t\t\t\"Use --method npm|binary explicitly, or run your package manager upgrade command (e.g. `bun add -g @zenon-red/probe`).\",\n\t\t\t);\n\t\t}\n\n\t\tif (!updateAvailable) {\n\t\t\tprintUpgradeResult({\n\t\t\t\tmethod,\n\t\t\t\tcurrentVersion,\n\t\t\t\ttargetVersion: targetVersion,\n\t\t\t\tlatestVersion: latestVersion || targetVersion,\n\t\t\t\tupdateAvailable: false,\n\t\t\t\tupdated: false,\n\t\t\t\tcheckOnly: false,\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tif (!isJsonMode() && !args.yes) {\n\t\t\tconst shouldUpgrade = await confirm({\n\t\t\t\tmessage: `Upgrade Probe from ${currentVersion} to ${targetVersion}?`,\n\t\t\t});\n\t\t\tif (!shouldUpgrade) {\n\t\t\t\tinfo(\"Upgrade cancelled\");\n\t\t\t\tprocess.exit(0);\n\t\t\t}\n\t\t}\n\n\t\t// Perform upgrade\n\t\ttry {\n\t\t\tif (method === \"npm\") {\n\t\t\t\tawait upgradeViaNpm(targetVersion);\n\t\t\t} else {\n\t\t\t\tconst release =\n\t\t\t\t\ttargetRelease ||\n\t\t\t\t\t(await fetchGitHubReleaseByVersion(targetVersion));\n\t\t\t\tawait upgradeViaBinary(release, targetVersion);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst message = err instanceof Error ? err.message : \"Upgrade failed\";\n\t\t\tconst code = message.includes(\"CHECKSUM_MISMATCH\")\n\t\t\t\t? \"CHECKSUM_MISMATCH\"\n\t\t\t\t: message.includes(\"ROLLBACK_FAILED\")\n\t\t\t\t\t? \"ROLLBACK_FAILED\"\n\t\t\t\t\t: message.includes(\"PERMISSION\") || message.includes(\"EACCES\")\n\t\t\t\t\t\t? \"PERMISSION_DENIED\"\n\t\t\t\t\t\t: \"UPGRADE_FAILED\";\n\t\t\terror(code, message);\n\t\t}\n\n\t\tprintUpgradeResult({\n\t\t\tmethod,\n\t\t\tcurrentVersion,\n\t\t\ttargetVersion: targetVersion,\n\t\t\tlatestVersion: latestVersion || targetVersion,\n\t\t\tupdateAvailable: true,\n\t\t\tupdated: true,\n\t\t\tcheckOnly: false,\n\t\t});\n\t},\n});\n","import { defineCommand } from \"citty\";\nimport { getConfig } from \"~/utils/config.js\";\nimport { resolvePasswordInput } from \"~/utils/credentials.js\";\nimport { forceHelpRequested, printHelp } from \"~/utils/help.js\";\nimport {\n\terror,\n\tisJsonMode,\n\tsetJsonMode,\n\tsuccess,\n\tsuccessMessage,\n\twarning,\n} from \"~/utils/output.js\";\nimport { loadUserConfig, saveUserConfig } from \"~/utils/user-config.js\";\nimport {\n\tcreateWallet as createWalletUtil,\n\tlistWallets,\n} from \"~/utils/wallet.js\";\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"create\",\n\t\tdescription: \"Create a new wallet with randomly generated mnemonic\",\n\t},\n\targs: {\n\t\tname: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Wallet identifier\",\n\t\t\trequired: false,\n\t\t},\n\t\t\"password-file\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Read password from file\",\n\t\t},\n\t\t\"set-default\": {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Set this wallet as the default\",\n\t\t\tdefault: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) {\n\t\t\tsetJsonMode(true);\n\t\t}\n\n\t\tconst name = args.name;\n\n\t\tif (forceHelpRequested() || !name) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe wallet create\",\n\t\t\t\tdescription: \"Create a new encrypted wallet\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe wallet create <name> [options]\",\n\t\t\t\t\t\"probe wallet create agent-wallet --set-default\",\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--password-file\", detail: \"Read wallet password from file\" },\n\t\t\t\t\t{ name: \"--set-default\", detail: \"Set created wallet as default\" },\n\t\t\t\t\t{ name: \"--json\", detail: \"JSON output for agents\" },\n\t\t\t\t],\n\t\t\t\tnotes: [\n\t\t\t\t\t\"Password source order: --password-file, PROBE_WALLET_PASSWORD, interactive prompt.\",\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tif (!/^[a-zA-Z0-9_-]+$/.test(name)) {\n\t\t\terror(\n\t\t\t\t\"INVALID_NAME\",\n\t\t\t\t\"Wallet name must be alphanumeric with hyphens or underscores only\",\n\t\t\t);\n\t\t}\n\n\t\tconst config = await getConfig();\n\t\tconst walletPassword = await resolvePasswordInput({\n\t\t\tpasswordFile: args[\"password-file\"],\n\t\t\tpromptMessage: \"Enter password to encrypt wallet:\",\n\t\t\tconfirmPromptMessage: \"Confirm password:\",\n\t\t\tminLength: config.passwordMinLength,\n\t\t\tjsonModeError:\n\t\t\t\t\"Password required via PROBE_WALLET_PASSWORD env, --password-file, or interactive prompt\",\n\t\t});\n\n\t\ttry {\n\t\t\tconst result = await createWalletUtil(name, walletPassword);\n\n\t\t\tlet setAsDefault = args[\"set-default\"];\n\t\t\tif (!setAsDefault) {\n\t\t\t\tconst wallets = await listWallets();\n\t\t\t\tif (wallets.length === 1) {\n\t\t\t\t\tsetAsDefault = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (setAsDefault) {\n\t\t\t\tconst userConfig = await loadUserConfig();\n\t\t\t\tuserConfig.defaultWallet = result.name;\n\t\t\t\tawait saveUserConfig(userConfig);\n\t\t\t}\n\n\t\t\tsuccess({\n\t\t\t\tname: result.name,\n\t\t\t\taddress: result.address,\n\t\t\t\tpublicKey: result.publicKey,\n\t\t\t\tmnemonic: result.mnemonic,\n\t\t\t\tdefault: setAsDefault,\n\t\t\t});\n\n\t\t\tif (!isJsonMode()) {\n\t\t\t\tsuccessMessage(`Wallet \"${result.name}\" created successfully`);\n\t\t\t\tconsole.log(`Address: ${result.address}`);\n\t\t\t\tconsole.log(`\\nMnemonic: ${result.mnemonic}`);\n\t\t\t\twarning(\"Save this mnemonic securely - it cannot be recovered!\");\n\t\t\t\tif (setAsDefault) {\n\t\t\t\t\tconsole.log(`\\nSet as default wallet`);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err) {\n\t\t\terror(\n\t\t\t\t\"WALLET_CREATE_ERROR\",\n\t\t\t\terr instanceof Error ? err.message : \"Failed to create wallet\",\n\t\t\t);\n\t\t}\n\t},\n});\n","import { defineCommand } from \"citty\";\nimport { forceHelpRequested, printHelp } from \"~/utils/help.js\";\nimport {\n\terror,\n\tisJsonMode,\n\tsetJsonMode,\n\tsuccess,\n\tsuccessMessage,\n} from \"~/utils/output.js\";\nimport { loadUserConfig, saveUserConfig } from \"~/utils/user-config.js\";\nimport { walletExists } from \"~/utils/wallet.js\";\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"default\",\n\t\tdescription: \"Set the default wallet\",\n\t},\n\targs: {\n\t\tname: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Wallet name to set as default\",\n\t\t\trequired: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) {\n\t\t\tsetJsonMode(true);\n\t\t}\n\n\t\tconst name = args.name;\n\n\t\tif (forceHelpRequested() || !name) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe wallet default\",\n\t\t\t\tdescription: \"Set the default wallet used by commands\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe wallet default <name> [options]\",\n\t\t\t\t\t\"probe wallet default agent-wallet\",\n\t\t\t\t],\n\t\t\t\toptions: [{ name: \"--json\", detail: \"JSON output for agents\" }],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst exists = await walletExists(name);\n\t\tif (!exists) {\n\t\t\terror(\"WALLET_NOT_FOUND\", `Wallet '${name}' does not exist`);\n\t\t}\n\n\t\tconst userConfig = await loadUserConfig();\n\t\tuserConfig.defaultWallet = name;\n\t\tawait saveUserConfig(userConfig);\n\n\t\tsuccess({ defaultWallet: name });\n\n\t\tif (!isJsonMode()) {\n\t\t\tsuccessMessage(`Default wallet set to '${name}'`);\n\t\t}\n\t},\n});\n","import { confirm } from \"@clack/prompts\";\nimport { defineCommand } from \"citty\";\nimport { forceHelpRequested, printHelp } from \"~/utils/help.js\";\nimport {\n\terror,\n\tinfo,\n\tisJsonMode,\n\tsetJsonMode,\n\tsuccess,\n\tsuccessMessage,\n} from \"~/utils/output.js\";\nimport { deleteWallet, walletExists } from \"~/utils/wallet.js\";\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"delete\",\n\t\tdescription: \"Delete a wallet\",\n\t},\n\targs: {\n\t\tname: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Wallet name\",\n\t\t\trequired: false,\n\t\t},\n\t\tyes: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Skip confirmation prompt\",\n\t\t\tdefault: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) {\n\t\t\tsetJsonMode(true);\n\t\t}\n\n\t\tconst name = args.name;\n\n\t\tif (forceHelpRequested() || !name) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe wallet delete\",\n\t\t\t\tdescription: \"Delete a wallet from local storage\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe wallet delete <name> [options]\",\n\t\t\t\t\t\"probe wallet delete old-wallet --yes\",\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--yes\", detail: \"Skip interactive confirmation prompt\" },\n\t\t\t\t\t{ name: \"--json\", detail: \"JSON output for agents\" },\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst exists = await walletExists(name);\n\t\tif (!exists) {\n\t\t\terror(\n\t\t\t\t\"WALLET_NOT_FOUND\",\n\t\t\t\t`Wallet '${name}' does not exist`,\n\t\t\t\t`Run 'probe wallet list' to see available wallets`,\n\t\t\t);\n\t\t}\n\n\t\tif (!isJsonMode() && !args.yes) {\n\t\t\tconst shouldDelete = await confirm({\n\t\t\t\tmessage: `Are you sure you want to delete wallet \"${name}\"? This cannot be undone.`,\n\t\t\t});\n\n\t\t\tif (!shouldDelete) {\n\t\t\t\tinfo(\"Deletion cancelled\");\n\t\t\t\tprocess.exit(0);\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\tawait deleteWallet(name);\n\n\t\t\tsuccess({ deleted: name });\n\n\t\t\tif (!isJsonMode()) {\n\t\t\t\tsuccessMessage(`Wallet \"${name}\" deleted successfully`);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\terror(\n\t\t\t\t\"WALLET_DELETE_ERROR\",\n\t\t\t\terr instanceof Error ? err.message : \"Failed to delete wallet\",\n\t\t\t);\n\t\t}\n\t},\n});\n","import { defineCommand } from \"citty\";\nimport {\n\tresolveMnemonicInput,\n\tresolvePasswordInput,\n} from \"~/utils/credentials.js\";\nimport { forceHelpRequested, printHelp } from \"~/utils/help.js\";\nimport {\n\terror,\n\tisJsonMode,\n\tsetJsonMode,\n\tsuccess,\n\tsuccessMessage,\n} from \"~/utils/output.js\";\nimport { loadUserConfig, saveUserConfig } from \"~/utils/user-config.js\";\nimport { importWallet, listWallets } from \"~/utils/wallet.js\";\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"import\",\n\t\tdescription: \"Import wallet from mnemonic phrase\",\n\t},\n\targs: {\n\t\tname: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Wallet identifier\",\n\t\t\trequired: false,\n\t\t},\n\t\tmnemonic: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Mnemonic phrase (space-separated)\",\n\t\t},\n\t\t\"mnemonic-file\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Read mnemonic from file\",\n\t\t},\n\t\t\"password-file\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Read password from file\",\n\t\t},\n\t\t\"set-default\": {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Set this wallet as the default\",\n\t\t\tdefault: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) {\n\t\t\tsetJsonMode(true);\n\t\t}\n\n\t\tconst name = args.name;\n\n\t\tif (forceHelpRequested() || !name) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe wallet import\",\n\t\t\t\tdescription: \"Import an encrypted wallet from mnemonic\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe wallet import <name> [options]\",\n\t\t\t\t\t\"probe wallet import agent-wallet --mnemonic-file ./mnemonic.txt\",\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--mnemonic\", detail: \"24-word mnemonic phrase\" },\n\t\t\t\t\t{ name: \"--mnemonic-file\", detail: \"Read mnemonic from file\" },\n\t\t\t\t\t{ name: \"--password-file\", detail: \"Read wallet password from file\" },\n\t\t\t\t\t{ name: \"--set-default\", detail: \"Set imported wallet as default\" },\n\t\t\t\t\t{ name: \"--json\", detail: \"JSON output for agents\" },\n\t\t\t\t],\n\t\t\t\tnotes: [\n\t\t\t\t\t\"Mnemonic source order: --mnemonic, --mnemonic-file, PROBE_WALLET_MNEMONIC, interactive prompt.\",\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tif (!/^[a-zA-Z0-9_-]+$/.test(name)) {\n\t\t\terror(\n\t\t\t\t\"INVALID_NAME\",\n\t\t\t\t\"Wallet name must be alphanumeric with hyphens or underscores only\",\n\t\t\t);\n\t\t}\n\n\t\tconst mnemonicPhrase = await resolveMnemonicInput({\n\t\t\tmnemonic: args.mnemonic,\n\t\t\tmnemonicFile: args[\"mnemonic-file\"],\n\t\t\tjsonModeError:\n\t\t\t\t\"Mnemonic required via --mnemonic, --mnemonic-file, or PROBE_WALLET_MNEMONIC env\",\n\t\t});\n\n\t\tconst walletPassword = await resolvePasswordInput({\n\t\t\tpasswordFile: args[\"password-file\"],\n\t\t\tpromptMessage: \"Enter password to encrypt wallet:\",\n\t\t\tjsonModeError:\n\t\t\t\t\"Password required via PROBE_WALLET_PASSWORD env, --password-file, or interactive prompt\",\n\t\t});\n\n\t\ttry {\n\t\t\tconst result = await importWallet(name, mnemonicPhrase, walletPassword);\n\n\t\t\tlet setAsDefault = args[\"set-default\"];\n\t\t\tif (!setAsDefault) {\n\t\t\t\tconst wallets = await listWallets();\n\t\t\t\tif (wallets.length === 1) {\n\t\t\t\t\tsetAsDefault = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (setAsDefault) {\n\t\t\t\tconst userConfig = await loadUserConfig();\n\t\t\t\tuserConfig.defaultWallet = result.name;\n\t\t\t\tawait saveUserConfig(userConfig);\n\t\t\t}\n\n\t\t\tsuccess({\n\t\t\t\tname: result.name,\n\t\t\t\taddress: result.address,\n\t\t\t\tdefault: setAsDefault,\n\t\t\t});\n\n\t\t\tif (!isJsonMode()) {\n\t\t\t\tsuccessMessage(`Wallet \"${result.name}\" imported successfully`);\n\t\t\t\tconsole.log(`Address: ${result.address}`);\n\t\t\t\tif (setAsDefault) {\n\t\t\t\t\tconsole.log(`\\nSet as default wallet`);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err) {\n\t\t\terror(\n\t\t\t\t\"WALLET_IMPORT_ERROR\",\n\t\t\t\terr instanceof Error ? err.message : \"Failed to import wallet\",\n\t\t\t);\n\t\t}\n\t},\n});\n","import { defineCommand } from \"citty\";\nimport { getConfig } from \"~/utils/config.js\";\nimport { forceHelpRequested, printHelp } from \"~/utils/help.js\";\nimport {\n\terror,\n\tinfo,\n\tisJsonMode,\n\tsetJsonMode,\n\tsuccess,\n} from \"~/utils/output.js\";\nimport { listWallets } from \"~/utils/wallet.js\";\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"list\",\n\t\tdescription: \"List all stored wallets\",\n\t},\n\targs: {\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (forceHelpRequested()) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe wallet list\",\n\t\t\t\tdescription: \"List all locally stored wallets\",\n\t\t\t\tusage: [\"probe wallet list [options]\", \"probe wallet list --json\"],\n\t\t\t\toptions: [{ name: \"--json\", detail: \"JSON output for agents\" }],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tif (args.json) {\n\t\t\tsetJsonMode(true);\n\t\t}\n\n\t\ttry {\n\t\t\tconst wallets = await listWallets();\n\t\t\tconst config = await getConfig();\n\n\t\t\tconst walletsOutput = wallets.map((w) => ({\n\t\t\t\t...w,\n\t\t\t\tdefault: w.name === config.defaultWallet,\n\t\t\t}));\n\n\t\t\tsuccess(walletsOutput);\n\n\t\t\tif (!isJsonMode()) {\n\t\t\t\tif (wallets.length === 0) {\n\t\t\t\t\tinfo(\"No wallets found\");\n\t\t\t\t} else {\n\t\t\t\t\tconsole.log(\"Wallets:\");\n\t\t\t\t\tfor (const wallet of walletsOutput) {\n\t\t\t\t\t\tconst date = wallet.createdAt\n\t\t\t\t\t\t\t? new Date(wallet.createdAt).toLocaleDateString()\n\t\t\t\t\t\t\t: \"unknown\";\n\t\t\t\t\t\tconst marker = wallet.default ? \"*\" : \" \";\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t`${marker} ${wallet.name.padEnd(12)} ${wallet.address.slice(0, 10)}... created ${date}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (config.defaultWallet) {\n\t\t\t\t\t\tconsole.log(`\\n* = default wallet`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err) {\n\t\t\terror(\n\t\t\t\t\"WALLET_LIST_ERROR\",\n\t\t\t\terr instanceof Error ? err.message : \"Failed to list wallets\",\n\t\t\t);\n\t\t}\n\t},\n});\n","import { readFile } from \"node:fs/promises\";\nimport { defineCommand } from \"citty\";\nimport { forceHelpRequested, printHelp } from \"~/utils/help.js\";\nimport { error, isJsonMode, setJsonMode, success } from \"~/utils/output.js\";\nimport { getWalletInfo, loadWallet } from \"~/utils/wallet.js\";\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"show\",\n\t\tdescription: \"Show wallet address and public key\",\n\t},\n\targs: {\n\t\tname: {\n\t\t\ttype: \"positional\",\n\t\t\tdescription: \"Wallet name\",\n\t\t\trequired: false,\n\t\t},\n\t\t\"public-key\": {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Include public key in output\",\n\t\t\tdefault: false,\n\t\t},\n\t\t\"password-file\": {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Read password from file\",\n\t\t},\n\t\tjson: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"Output JSON only\",\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) {\n\t\t\tsetJsonMode(true);\n\t\t}\n\n\t\tconst name = args.name;\n\n\t\tif (forceHelpRequested() || !name) {\n\t\t\tprintHelp({\n\t\t\t\tcommand: \"probe wallet show\",\n\t\t\t\tdescription: \"Show wallet address and optional public key\",\n\t\t\t\tusage: [\n\t\t\t\t\t\"probe wallet show <name> [options]\",\n\t\t\t\t\t\"probe wallet show my-wallet --public-key --password-file ./pass.txt\",\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\t{ name: \"--public-key\", detail: \"Include public key in output\" },\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"--password-file\",\n\t\t\t\t\t\tdetail: \"Read password for public key extraction\",\n\t\t\t\t\t},\n\t\t\t\t\t{ name: \"--json\", detail: \"JSON output for agents\" },\n\t\t\t\t],\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tconst walletInfo = await getWalletInfo(name);\n\t\tif (!walletInfo) {\n\t\t\terror(\n\t\t\t\t\"WALLET_NOT_FOUND\",\n\t\t\t\t`Wallet '${name}' does not exist`,\n\t\t\t\t`Run 'probe wallet list' to see available wallets`,\n\t\t\t);\n\t\t}\n\n\t\tlet walletPassword: string | undefined;\n\n\t\tif (args[\"password-file\"]) {\n\t\t\ttry {\n\t\t\t\twalletPassword = await readFile(args[\"password-file\"], \"utf-8\");\n\t\t\t\twalletPassword = walletPassword.trim();\n\t\t\t} catch {\n\t\t\t\terror(\n\t\t\t\t\t\"FILE_READ_ERROR\",\n\t\t\t\t\t`Failed to read password file: ${args[\"password-file\"]}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\tlet publicKey: string | undefined;\n\n\t\t\tif (walletPassword) {\n\t\t\t\tconst keyStore = await loadWallet(name, walletPassword);\n\t\t\t\tconst keyPair = keyStore.getKeyPair(0);\n\t\t\t\tpublicKey = keyPair.getPublicKey().toString(\"hex\");\n\t\t\t}\n\n\t\t\tconst result: Record<string, string | undefined> = {\n\t\t\t\tname: walletInfo.name,\n\t\t\t\taddress: walletInfo.address,\n\t\t\t\tcreatedAt: walletInfo.createdAt,\n\t\t\t};\n\n\t\t\tif (args[\"public-key\"] || publicKey) {\n\t\t\t\tresult.publicKey = publicKey;\n\t\t\t}\n\n\t\t\tsuccess(result);\n\n\t\t\tif (!isJsonMode()) {\n\t\t\t\tconsole.log(`Name: ${walletInfo.name}`);\n\t\t\t\tconsole.log(`Address: ${walletInfo.address}`);\n\t\t\t\tif (walletInfo.createdAt) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t`Created: ${new Date(walletInfo.createdAt).toLocaleString()}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (publicKey) {\n\t\t\t\t\tconsole.log(`Public Key: ${publicKey}`);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err) {\n\t\t\terror(\n\t\t\t\t\"WALLET_LOAD_ERROR\",\n\t\t\t\terr instanceof Error ? err.message : \"Failed to load wallet\",\n\t\t\t);\n\t\t}\n\t},\n});\n","import { defineCommand } from \"citty\";\nimport { printHelp } from \"~/utils/help.js\";\nimport create from \"./create.js\";\nimport defaultCmd from \"./default.js\";\nimport deleteCmd from \"./delete.js\";\nimport importCmd from \"./import.js\";\nimport list from \"./list.js\";\nimport show from \"./show.js\";\n\nconst walletSubcommands = new Set([\n\t\"create\",\n\t\"import\",\n\t\"list\",\n\t\"show\",\n\t\"delete\",\n\t\"default\",\n]);\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"wallet\",\n\t\tdescription: \"Manage Zenon Network wallets\",\n\t},\n\trun() {\n\t\tconst positionals = process.argv\n\t\t\t.slice(2)\n\t\t\t.filter((arg) => !arg.startsWith(\"-\"));\n\t\tif (positionals.length > 1 && walletSubcommands.has(positionals[1])) {\n\t\t\treturn;\n\t\t}\n\n\t\tprintHelp({\n\t\t\tcommand: \"probe wallet\",\n\t\t\tdescription: \"Create, import, inspect, and manage wallets\",\n\t\t\tusage: [\n\t\t\t\t\"probe wallet <subcommand> [positionals] [options]\",\n\t\t\t\t\"probe wallet create my-wallet --set-default\",\n\t\t\t\t\"probe wallet import my-wallet --mnemonic-file ./mnemonic.txt\",\n\t\t\t],\n\t\t\tactions: [\n\t\t\t\t{ name: \"create <name>\", detail: \"Create a new encrypted wallet\" },\n\t\t\t\t{ name: \"import <name>\", detail: \"Import wallet from mnemonic phrase\" },\n\t\t\t\t{ name: \"list\", detail: \"List stored wallets\" },\n\t\t\t\t{\n\t\t\t\t\tname: \"show <name>\",\n\t\t\t\t\tdetail: \"Show wallet address and optional public key\",\n\t\t\t\t},\n\t\t\t\t{ name: \"delete <name>\", detail: \"Delete a wallet\" },\n\t\t\t\t{ name: \"default <name>\", detail: \"Set default wallet\" },\n\t\t\t],\n\t\t\tnotes: [\"Use long-form flags only for predictable agent automation.\"],\n\t\t});\n\t},\n\tsubCommands: {\n\t\tcreate,\n\t\timport: importCmd,\n\t\tlist,\n\t\tshow,\n\t\tdelete: deleteCmd,\n\t\tdefault: defaultCmd,\n\t},\n});\n","import { defineCommand } from \"citty\";\nimport type { Agent } from \"~/utils/context.js\";\nimport { withAuth } from \"~/utils/context.js\";\nimport { AgentRole, AgentStatus } from \"~/utils/enums.js\";\nimport { error, isJsonMode, setJsonMode, success } from \"~/utils/output.js\";\nimport { formatTimestamp } from \"~/utils/time.js\";\nimport { toonList } from \"~/utils/toon.js\";\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: \"whoami\",\n\t\tdescription: \"Show current authenticated agent profile\",\n\t},\n\targs: {\n\t\twallet: { type: \"string\", description: \"Wallet name\" },\n\t\tjson: { type: \"boolean\", description: \"Output JSON\", default: false },\n\t\thost: { type: \"string\", description: \"SpacetimeDB host\" },\n\t\tmodule: { type: \"string\", description: \"Module name\" },\n\t},\n\tasync run({ args }) {\n\t\tif (args.json) setJsonMode(true);\n\n\t\ttry {\n\t\t\tawait withAuth(\n\t\t\t\t{ host: args.host, module: args.module, wallet: args.wallet },\n\t\t\t\tasync (ctx) => {\n\t\t\t\t\tconst myAgent = ctx\n\t\t\t\t\t\t.iter<Agent>(\"agents\")\n\t\t\t\t\t\t.find(\n\t\t\t\t\t\t\t(a) => a.identity.toHexString() === ctx.identity?.toHexString(),\n\t\t\t\t\t\t);\n\n\t\t\t\t\tif (!myAgent) {\n\t\t\t\t\t\terror(\n\t\t\t\t\t\t\t\"NOT_REGISTERED\",\n\t\t\t\t\t\t\t\"Agent not registered. Run `probe agent register` first.\",\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tsuccess(myAgent);\n\n\t\t\t\t\tif (!isJsonMode()) {\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\ttoonList(\"agent\", [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: myAgent.id,\n\t\t\t\t\t\t\t\t\tname: myAgent.name,\n\t\t\t\t\t\t\t\t\trole: AgentRole.display(myAgent.role),\n\t\t\t\t\t\t\t\t\tstatus: AgentStatus.display(myAgent.status),\n\t\t\t\t\t\t\t\t\tlastHeartbeat: formatTimestamp(myAgent.lastHeartbeat),\n\t\t\t\t\t\t\t\t\tcurrentTaskId: myAgent.currentTaskId\n\t\t\t\t\t\t\t\t\t\t? myAgent.currentTaskId.toString()\n\t\t\t\t\t\t\t\t\t\t: \"\",\n\t\t\t\t\t\t\t\t\tcapabilities: myAgent.capabilities.join(\",\"),\n\t\t\t\t\t\t\t\t\tidentity: ctx.identity?.toHexString() || \"\",\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\t\t} catch (err) {\n\t\t\t// Handle connection errors gracefully - avoid citty/consola stack traces\n\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\terror(\"CONNECTION_ERROR\", message);\n\t\t}\n\t},\n});\n","import { createRequire } from \"node:module\";\nimport { defineCommand, runMain } from \"citty\";\nimport auth from \"./commands/auth.js\";\nimport config from \"./commands/config.js\";\nimport doctor from \"./commands/doctor.js\";\nimport agent from \"./commands/nexus/agent.js\";\nimport discover from \"./commands/nexus/discover.js\";\nimport idea from \"./commands/nexus/idea.js\";\nimport message from \"./commands/nexus/message.js\";\nimport project from \"./commands/nexus/project.js\";\nimport task from \"./commands/nexus/task.js\";\nimport nexusDaemon from \"./commands/nexus-daemon.js\";\nimport query from \"./commands/query.js\";\nimport sign from \"./commands/sign.js\";\nimport token from \"./commands/token.js\";\nimport upgrade from \"./commands/upgrade.js\";\nimport wallet from \"./commands/wallet/index.js\";\nimport whoami from \"./commands/whoami.js\";\nimport {\n\tnormalizeHelpArgv,\n\tprintHelp,\n\tsetForceHelpRequested,\n} from \"./utils/help.js\";\n\nconst topLevelCommands = new Set([\n\t\"wallet\",\n\t\"auth\",\n\t\"sign\",\n\t\"token\",\n\t\"config\",\n\t\"nexus\",\n\t\"agent\",\n\t\"task\",\n\t\"message\",\n\t\"idea\",\n\t\"discover\",\n\t\"project\",\n\t\"query\",\n\t\"doctor\",\n\t\"whoami\",\n\t\"upgrade\",\n]);\n\nconst applyHelpNormalization = (): void => {\n\tconst normalized = normalizeHelpArgv(process.argv.slice(2));\n\tsetForceHelpRequested(normalized.forceHelp);\n\tprocess.argv = [...process.argv.slice(0, 2), ...normalized.argv];\n};\n\nconst require = createRequire(import.meta.url);\nconst { version, description } = require(\"../package.json\");\n\nconst main = defineCommand({\n\tmeta: { name: \"probe\", version, description },\n\targs: {\n\t\tjson: { type: \"boolean\", description: \"Output JSON only\", default: false },\n\t},\n\trun() {\n\t\tconst firstPositional = process.argv\n\t\t\t.slice(2)\n\t\t\t.find((arg) => !arg.startsWith(\"-\"));\n\t\tif (firstPositional && topLevelCommands.has(firstPositional)) {\n\t\t\treturn;\n\t\t}\n\n\t\tprintHelp({\n\t\t\tcommand: \"probe\",\n\t\t\tdescription,\n\t\t\tusage: [\n\t\t\t\t\"probe <command> [positionals] [options]\",\n\t\t\t\t'probe idea propose --title \"Better task scoring\" --category planning',\n\t\t\t\t\"probe task claim 42 --wallet agent-wallet\",\n\t\t\t],\n\t\t\tactions: [\n\t\t\t\t{ name: \"wallet\", detail: \"Wallet lifecycle commands\" },\n\t\t\t\t{ name: \"auth\", detail: \"Authenticate wallet and cache token\" },\n\t\t\t\t{ name: \"token\", detail: \"Inspect or clear cached token\" },\n\t\t\t\t{ name: \"sign\", detail: \"Sign text payloads\" },\n\t\t\t\t{\n\t\t\t\t\tname: \"nexus\",\n\t\t\t\t\tdetail: \"Run persistent Nexus daemon (keepalive + event logs)\",\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: \"agent, task, idea, discover, message, project\",\n\t\t\t\t\tdetail: \"Nexus workspace commands\",\n\t\t\t\t},\n\t\t\t\t{ name: \"query\", detail: \"Execute SQL queries against Nexus\" },\n\t\t\t\t{ name: \"doctor\", detail: \"Run setup and connectivity diagnostics\" },\n\t\t\t\t{ name: \"upgrade\", detail: \"Upgrade Probe to the latest version\" },\n\t\t\t\t{ name: \"config\", detail: \"Read/write CLI configuration\" },\n\t\t\t],\n\t\t\toptions: [{ name: \"--json\", detail: \"JSON output mode for agents\" }],\n\t\t\tnotes: [\n\t\t\t\t\"Nexus commands connect to SpacetimeDB (the realtime database backing Nexus).\",\n\t\t\t],\n\t\t});\n\t},\n\tsubCommands: {\n\t\twallet,\n\t\tauth,\n\t\tsign,\n\t\ttoken,\n\t\tconfig,\n\t\tnexus: nexusDaemon,\n\t\tagent,\n\t\ttask,\n\t\tmessage,\n\t\tidea,\n\t\tdiscover,\n\t\tproject,\n\t\tquery,\n\t\tdoctor,\n\t\tupgrade,\n\t\twhoami,\n\t},\n});\n\n// Global error handler to suppress stack traces for expected errors\nconst isExpectedError = (err: unknown): boolean => {\n\tif (!(err instanceof Error)) return false;\n\tconst message = err.message.toLowerCase();\n\treturn (\n\t\tmessage.includes(\"connection failed\") ||\n\t\tmessage.includes(\"connection timeout\") ||\n\t\tmessage.includes(\"authentication required\") ||\n\t\tmessage.includes(\"unauthorized\") ||\n\t\tmessage.includes(\"wallet required\") ||\n\t\tmessage.includes(\"wallet not found\") ||\n\t\tmessage.includes(\"agent not registered\") ||\n\t\tmessage.includes(\"subscription error\")\n\t);\n};\n\nprocess.on(\"unhandledRejection\", (err: unknown) => {\n\tif (isExpectedError(err)) {\n\t\t// Error message already printed by the error() utility\n\t\tprocess.exit(1);\n\t}\n\t// For unexpected errors, let the default handler deal with it\n\tthrow err;\n});\n\napplyHelpNormalization();\nrunMain(main);\n"],"mappings":";qzCAaA,MAAa,GAA8B,CAC1C,OAAQ,wBACR,UAAW,mBACX,kBAAmB,EACnB,cAAe,kBACf,eAAgB,IAChB,UAAW,CACV,KAAM,qBACN,OAAQ,QACR,CACD,CClBK,GAAc,EAAK,GAAS,CAAE,SAAU,cAAc,CACtD,GAAa,EAAK,GAAS,CAAE,SAAS,CAE5C,eAAsB,GAAgD,CACrE,GAAI,CACH,MAAM,EAAO,GAAY,CACzB,IAAM,EAAU,MAAM,EAAS,GAAa,QAAQ,CACpD,OAAO,KAAK,MAAM,EAAQ,MACnB,CACP,MAAO,EAAE,EAIX,eAAsB,GACrB,EACgB,CAChB,MAAM,EAAM,GAAY,CAAE,UAAW,GAAM,CAAC,CAC5C,MAAM,EAAU,GAAa,KAAK,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