# Connect an agent to Harklight Harklight is an attention-based UI for messages and requests from your AI agents. You need a [Hosted Harklight account](https://app.harklight.net/account/sign-in) and Harklight Agent 0.2.10 on the Mac or Linux computer that runs your agent. Open [Harklight Web](https://app.harklight.net/app/) in the same account to receive and answer the setup question. ## Get the Harklight app Use Web for this guide. The compatible iPhone app is not yet available to customers. An Agent invitation is for the computer running the CLI. ## Install Harklight Agent On the computer where Claude Code or Codex runs, install the Agent CLI with Homebrew. ```sh brew install clickety-clacks/tap/harklight-agent ``` ## Enroll your computer 1. In [Devices](https://app.harklight.net/devices), choose **Create Agent invitation** (shown as **Create invitation** on some accounts). On **Invitation ready**, copy the **On a computer** command and paste it into a terminal on the computer running your agent. The command runs `harklight-agent setup` with the full invitation link. 2. Return to **Devices** and choose **Review exact request** for your computer. Match **Code on device** against the code printed by `setup`, enter `app:agent/` in **Sender IDs** and approve the exact Agent request. This prefix covers sender IDs such as `app:agent/claude-code` and `app:agent/codex`, so both tools can share this enrollment. 3. Keep the terminal open while `setup` installs the Harklight skill for Claude Code or Codex if installed. Open Harklight Web and answer **Harklight is connected**. The terminal prints your answer and **Connected.** ## Use it from Claude Code or Codex Run `harklight-agent setup` with no arguments to check the current Server, account, sender grants and installed skill paths and refresh the skill. Agent 0.2.10 setup, sending, replying, reading and live follow have been exercised against an isolated Hosted-mode Server. - **Claude Code.** Setup instructions are available. End-to-end testing of skill discovery, delivery of Replies and Chat into the original session, and automatic continuation is pending. - **Codex CLI.** Setup instructions are available. End-to-end testing of skill discovery, delivery of Replies and Chat into the original session, and automatic continuation is pending. Resume the original session manually to check for Replies or Chat. The CLI workflow below is available while client-level testing is pending. ## Send a message and answer it Once enrollment is approved with its sender ID, the agent can start a conversation with you. An agent works only in conversations it started; enrollment does not give it access to other senders' conversations. The agent creates a conversation with its first message: ```sh harklight-agent \ send --session new --sender-id app:agent/example \ --type request --reply --title "Connection check" \ --body "Please reply to confirm you received this message." ``` Save the returned session handle, item ID and operation ID with the original agent session. Use the same enrolled identity and local Agent journal for reads and writes. Record the journal ID from `harklight-agent journal-id` if you use a separate state directory or may need to recover an operation. Subsequent sends in the same conversation pass the saved handle to `--session`. An accepted send means the service took the message, not that you have seen it. This example does not enable background listening. In Harklight Web, open **Connection check**. Use **Send answer** to complete the request with your written answer. Use **Chat** to send a separate message without answering the request. ## Read and hand off to the originating session Use the session handle returned by the send as `HARKLIGHT_SESSION`. Run `read` for one catch-up, or keep `listen --follow` running for live changes: ```sh harklight-agent read --session "$HARKLIGHT_SESSION" harklight-agent listen --follow --session "$HARKLIGHT_SESSION" ``` The CLI emits JSON lines. Durable changes carry `kind`, `rev` and `data`. `caught_up` marks a complete catch-up. After interruption, use the same identity, state directory and session handle. A replayed batch may repeat an answer or Chat entry. Match answers by the original item ID and Chat by entry ID before acting again. A listener receiving an event does not itself resume Claude Code or Codex. For a runtime with verified same-session background completion, run `harklight-agent listen --next --session "$HARKLIGHT_SESSION"` in the originating session, route its event back with the saved conversation context, and rearm after handling it. For manual continuation, reopen or resume the original client session, run `read` there, and give that session the specific answer or Chat entry and its IDs. If the original session cannot be reached, leave the turn pending and report that handoff could not be confirmed. Record handoff only after the originating session has received the turn. For an answer, use the original request's `item_id` as `HARKLIGHT_ITEM`: ```sh harklight-agent receipt --item-id "$HARKLIGHT_ITEM" ``` For Chat, add `--entry-id "$HARKLIGHT_ENTRY"` using the person's actual entry ID. A feed read and a handoff receipt describe different stages. The action result is recorded separately. Choose the next command from the record the agent received, not from how you answered. **Replies to the request.** Your answer, whether written or chosen from offered options, arrives in a `message` record as the request's `terminal`, with `state` `answered`. It closes the request, so the agent does not answer it with `reply`. The agent reports what it did with that answer using `result` and the status that matches: `applied` only after it has actually performed what the answer asks, `refused` if it will not or cannot, or `received` to report it has the answer before acting, followed later by `applied` or `refused`. For example, after performing the action: ```sh harklight-agent \ result --item-id "$HARKLIGHT_ITEM" --status applied ``` **Chat.** A message you send with Chat arrives as an `entry` record of kind `reply` from `person`, with its own `entry_id` (`HARKLIGHT_ENTRY` below). The agent answers that exact entry with `reply`: ```sh harklight-agent \ reply --item-id "$HARKLIGHT_ITEM" \ --in-reply-to "$HARKLIGHT_ENTRY" --body "I received your message." ``` Chat remains available after the request closes. These commands are alternatives chosen from the actual entry, not a sequence to run blindly. Dynamic identifiers come from the same conversation's returned data. Neither reading nor a receipt proves action completion. ## Remove access Return to [Devices](https://app.harklight.net/devices) in the same owner account. Select this agent's exact enrolled identity and choose Remove device permanently. Confirm removal. Deleting the local files or signing out does not revoke access. After confirmed removal, a new send using the retained identity and sender must be refused. Your old messages remain and other identities retain their access. A lost or unavailable removal response is uncertain: revisit the device inventory before claiming success. Reconnecting requires the supported enrollment process with a new identity. ## If something fails Keep the existing identity directory and journal when resolving an uncertain operation. Do not switch accounts or borrow another device's private key. - Setup interrupted while waiting for approval. Run `harklight-agent setup` again to resume the saved request with the same approval code. - Setup reports a missing sender grant. Remove this computer in Devices, create a new invitation, and run `setup` with its full link. Enter `app:agent/` in **Sender IDs** when you approve. - Unknown send or action outcome: use `retry --op-id` with its saved operation ID and the same identity and journal. Pass `--journal-id` with the saved journal ID when you need to confirm that binding. Do not create a second message or changed action to resolve uncertainty. Correct inputs and create a new operation only after a definite refusal. An outcome reported with `error: "internal_error"` and `retryable: false` may already have committed: it stays unresolved under its original operation key with the service's `request_id`, and is not retried automatically. Replay requires an explicit `retry --op-id`. - Message missing in Harklight: check that Web is signed in to the Harklight account that approved the agent. Do not re-send to resolve an unknown send outcome; use `retry --op-id` as above. - Missing sign-in session: sign in to the intended account again on the website. Do not treat sign-in, approval, committed sending, real receipt, actual reply handling or confirmed removal as interchangeable success states. The [Harklight Agent README](https://github.com/clickety-clacks/harklight-agent#readme) contains the enrollment and operation-retry reference.