{"record":{"id":"c3c9007b15ccc6dc","repo":"can1357/oh-my-pi","slug":"unknown-daemon-name-names-length-availabl","errorCode":null,"errorMessage":"Unknown daemon ${name}${names.length ? `. Available: ${names.join(\", \")}` : \"\"}","messagePattern":"Unknown daemon (.+?)(.+?)` : \"\"\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/launch/broker.ts","lineNumber":1189,"sourceCode":"\t}\n\n\tasync #waitUntil(record: ManagedDaemon, condition: () => boolean, timeoutMs: number): Promise<boolean> {\n\t\tconst deadline = Date.now() + Math.max(0, timeoutMs);\n\t\twhile (Date.now() < deadline) {\n\t\t\tawait this.#refreshDetached(record);\n\t\t\tif (condition()) return true;\n\t\t\tif (this.#shuttingDown && terminalState(record.snapshot.state)) return condition();\n\t\t\tawait Bun.sleep(50);\n\t\t}\n\t\tawait this.#refreshDetached(record);\n\t\treturn condition();\n\t}\n\n\t#record(name: string): ManagedDaemon {\n\t\tconst record = this.#records.get(name);\n\t\tif (record) return record;\n\t\tconst names = [...this.#records.keys()];\n\t\tthrow new Error(`Unknown daemon ${name}${names.length ? `. Available: ${names.join(\", \")}` : \"\"}`);\n\t}\n\n\t#persist(record: ManagedDaemon): void {\n\t\tconst metaPath = path.join(record.dir, META_FILE);\n\t\tconst tempPath = `${metaPath}.${process.pid}.tmp`;\n\t\tconst metadata = {\n\t\t\tdaemon: { ...record.snapshot },\n\t\t\tspec: record.spec,\n\t\t\tcompletionEvents: record.completionCapable,\n\t\t\tcompletionSubscriptionId: record.completionSubscriptionId,\n\t\t\tcompletionPending: record.pendingCompletions.length > 0,\n\t\t\tpendingCompletion: record.pendingCompletions.at(-1)?.daemon,\n\t\t\tpendingCompletions: record.pendingCompletions.map(completion => ({\n\t\t\t\t...completion,\n\t\t\t\tdaemon: { ...completion.daemon },\n\t\t\t})),\n\t\t};\n\t\trecord.persistQueue = record.persistQueue","sourceCodeStart":1171,"sourceCodeEnd":1207,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/launch/broker.ts#L1171-L1207","documentation":"DaemonBroker.#record is the internal lookup for a managed daemon by name. When no record with that name exists, it throws this error listing all currently known daemon names (or nothing if the registry is empty). Every operation targeting an unregistered daemon funnels through here, making this the canonical 'unknown daemon name' error.","triggerScenarios":"Any daemon operation (send, wait, stop, get) with a name that was never started in this broker session, was already fully removed, or is misspelled. The registry is in-memory (#records), so records created by a previous broker process also won't be found.","commonSituations":"Typos in the daemon name; client pointing at a different runtimeDir than the broker that owns the daemon; broker process restarted and its in-memory registry re-seeded differently; operating on a daemon started in another project/runtime directory.","solutions":["Use a name from the 'Available:' list in the message, or run a list operation to see registered daemons.","Start the daemon with broker.start if it doesn't exist yet.","Verify the client and broker use the same runtimeDir so the registry matches what you expect."],"exampleFix":"// before\nawait broker.send({ name: \"buildr\", data: \"go\\n\" }); // typo\n// after\nconst daemons = await broker.list();\nconst name = daemons.find(d => d.name === \"builder\")?.name;\nif (name) await broker.send({ name, data: \"go\\n\" });","handlingStrategy":"validation","validationCode":"const daemons = await broker.list();\nif (!daemons.some(d => d.name === name)) {\n  throw new Error(`daemon '${name}' not registered; available: ${daemons.map(d => d.name).join(\", \")}`);\n}","typeGuard":"function knowsDaemon(daemons: { name: string }[], name: string): boolean {\n  return daemons.some(d => d.name === name);\n}","tryCatchPattern":"try {\n  await broker.send({ name, data });\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"Unknown daemon \")) {\n    const daemons = await broker.list();\n    // pick correct name from daemons or start the daemon\n  } else throw err;\n}","preventionTips":["Read daemon names from broker.list() instead of hardcoding them.","Use a shared constants module for daemon names to prevent typos.","Ensure client and broker agree on runtimeDir; check it after any broker restart."],"tags":["daemon","not-found","naming"],"backgroundTag":"unknown-resource-name","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}