(err?: Error)
| 303 | ): Promise<{ kildId?: string; handle?: string }> { |
| 304 | if (id && handle) return { kildId: id, handle }; |
| 305 | const session = harnessSession(); |
| 306 | // Deliberately NOT guarded. An unreadable record means "there may be an attachment and I |
| 307 | // cannot read it", and a `kild send` that swallowed that would post the message with no |
| 308 | // credential — silently unattributed, which is the exact bug this file exists to fix. The |
| 309 | // one caller allowed to degrade to silence is the turn-end hook, and it does so at its own |
| 310 | // call site where it knows it is a hook. |
| 311 | const record = session ? await findAttachment(session) : null; |
| 312 | return { |
| 313 | kildId: id ?? record?.kildId ?? process.env.KILD_KILD_ID ?? undefined, |
| 314 | handle: handle ?? record?.handle ?? process.env.KILD_HANDLE ?? undefined, |
| 315 | }; |
| 316 | } |
| 317 | |
| 318 | /** `kild attach <id> --as <handle>` — register an ATTACHED agent: a harness kild |
| 319 | * does not own (the Claude Code session you are driving) claiming a `@handle` in the |
no test coverage detected