agentleFS
photon-hqphoton-hq/advanced-imessage-kit/llms.txt

advanced-imessage-kit

llms.txt185 starsChanged 12 months agoMITView on GitHub

This file is for language models / AI agents that use this SDK at runtime to control an iMessage-based agent or automation. You interact with this SDK from a Node.js / TypeScript environment. The SDK connects to an iMessage server running on macOS. The main configuration object is ClientConfig: As an LLM, you should never invent API keys. Always receive them as secure configuration from the host system and avoid logging them. Regardless of how the backend is configured, you…

We split this llms.txt into the rules it gives an agent

19 rules. About 0 are common, 11 are distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈11

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Import the SDK from @photon-ai/advanced-imessage-kit.

    line 11
  2. Distinctive:

    Create a single long-lived SDK instance per process and reuse it until you intentionally disconnect.

    line 12
  3. Very specific:

    If the backend enforces authentication, a valid API key must be provided or connection will fail with an error event.

    line 24
  4. Very specific:

    Create an SDK instance using the exported SDK helper:

    line 34
  5. Distinctive:

    Wait for authentication and readiness:

    line 43
  6. Very specific:

    Only when authentication succeeds will the SDK emit its own ready event.

    line 45
  7. Distinctive:

    When acting through this SDK, you are effectively controlling a real iMessage account.

    line 78
  8. Distinctive:

    Only send messages or modify chats when explicitly permitted by the user or by higher-level policy.

    line 81
  9. Distinctive:

    Avoid unsolicited, bulk, or spam-like messaging.

    line 82
  10. Distinctive:

    Treat all message content, contacts, and phone numbers as sensitive data.

    line 85
  11. Distinctive:

    Do not exfiltrate or store this data outside the approved environment.

    line 86
  12. Distinctive:

    Do not log full message content or secrets unless a human explicitly requests it.

    line 87
  13. Distinctive:

    Never attempt to bypass or weaken API key validation.

    line 90
  14. Very specific:

    Do not suggest turning off authentication, removing apiKey, or changing authentication endpoints without explicit human approval.

    line 91
  15. Very specific:

    If you receive repeated authentication-related error events, surface this clearly to the human operator instead of retrying indefinitely.

    line 92
  16. Distinctive:

    Prefer a single long-lived connection rather than repeatedly connecting/disconnecting.

    line 95
  17. Very specific:

    Use the appropriate module (messages, attachments, chats) to act.

    line 112
  18. Very specific:

    When instructed, call sdk.close() to cleanly close the Socket.IO connection.

    line 115
  19. Distinctive:

    If you are a more capable LLM that can also edit code in this repository, prefer small, well-scoped changes and keep the dual-channel …

    line 117

≈ “Common” is an estimate: at least 1 in 5 of the 3,225 llms.txt files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
llms.txt
# LLM usage guide for @photon-ai/advanced-imessage-kit

This file is for language models / AI agents that **use** this SDK at runtime to control an iMessage-based agent or automation.

You interact with this SDK from a Node.js / TypeScript environment. The SDK connects to an iMessage server running on macOS.

--------------------------------------------------------------------------------
1. Core runtime model
--------------------------------------------------------------------------------

- Import the SDK from `@photon-ai/advanced-imessage-kit`.
- Create a single long-lived SDK instance per process and reuse it until you intentionally disconnect.
- The SDK talks to the server over **Socket.IO (events)** and **HTTP (operations)**.

--------------------------------------------------------------------------------
2. Configuration
--------------------------------------------------------------------------------

The main configuration object is `ClientConfig`:

- `serverUrl` (string, required in production)
  - Example: `https://<subdomain>.example.com`.
- `apiKey` (string, optional but often required by the backend)
  - If the backend enforces authentication, a valid API key must be provided or connection will fail with an `error` event.
- `logLevel` (`"debug" | "info" | "warn" | "error"`, optional)
  - Controls SDK logging verbosity.

As an LLM, you should **never invent** API keys. Always receive them as secure configuration from the host system and avoid logging them.

--------------------------------------------------------------------------------
3. Connection & authentication flow
--------------------------------------------------------------------------------

1) Create an SDK instance using the exported `SDK` helper:
   - The host should run something like: `const sdk = SDK({ serverUrl, apiKey, logLevel });`

2) Connect to the server:
   - The host should call `await sdk.connect()` once at startup.
   - Internally the SDK:
     - Opens a Socket.IO connection to `serverUrl`.
     - Sends `apiKey` in the Socket.IO handshake (if provided).

3) Wait for authentication and readiness:
   - During connect the SDK performs an authentication step with the backend using the `apiKey` (when configured).
   - Only when authentication succeeds will the SDK emit its own **`ready`** event; on authentication failure it emits an **`error`** event.
   - Your higher-level logic must **wait for `ready`** before sending messages or performing operations.

4) Handle errors and disconnects:
   - Listen to the SDK events:
     - `"ready"`      – safe to start sending/receiving.
     - `"error"`      – includes auth failures and connection issues.
     - `"disconnect"` – connection closed; you may choose to reconnect with backoff.

Regardless of how the backend is configured, you can always rely on the pattern: **connect → wait for `ready` → operate**.

--------------------------------------------------------------------------------
4. Using the SDK as an AI agent
--------------------------------------------------------------------------------

Once `ready` has fired, you can:

- Receive messages:
  - Subscribe to the `"new-message"` event to observe incoming messages.
  - Inspect `message.text`, `message.handle`, `message.chats`, `message.attachments`, etc.

- Send and manage messages via HTTP-backed modules:
  - `sdk.messages.sendMessage(...)` to send text messages or replies.
  - `sdk.attachments.sendAttachment(...)` for images/files/voice messages.
  - `sdk.chats.*` for chat operations (create chat, mark read/unread, typing indicators, group management, etc.).
  - `sdk.server.*` for server statistics and diagnostics.

The underlying Axios client automatically includes `X-API-Key` in HTTP requests when `apiKey` is configured.

--------------------------------------------------------------------------------
5. Safety, privacy and behavior guidelines
--------------------------------------------------------------------------------

When acting through this SDK, you are effectively controlling a real iMessage account. Follow these rules:

- **User intent first**
  - Only send messages or modify chats when explicitly permitted by the user or by higher-level policy.
  - Avoid unsolicited, bulk, or spam-like messaging.

- **Privacy**
  - Treat all message content, contacts, and phone numbers as sensitive data.
  - Do not exfiltrate or store this data outside the approved environment.
  - Do not log full message content or secrets unless a human explicitly requests it.

- **Auth & security**
  - Never attempt to bypass or weaken API key validation.
  - Do not suggest turning off authentication, removing `apiKey`, or changing authentication endpoints without explicit human approval.
  - If you receive repeated authentication-related `error` events, surface this clearly to the human operator instead of retrying indefinitely.

- **Stability**
  - Prefer a single long-lived connection rather than repeatedly connecting/disconnecting.
  - On `disconnect`, use bounded retry with backoff instead of tight loops.

--------------------------------------------------------------------------------
6. Good high-level patterns for LLM agents
--------------------------------------------------------------------------------

A simple and robust lifecycle for agents using this SDK is:

1) Startup
   - Connect and wait for `ready`.
   - Optionally fetch some initial state (e.g., recent chats/messages) if the user asked for it.

2) Event loop
   - On each `"new-message"` event:
     - Understand the user’s request.
     - Decide whether to respond based on rules and permissions.
     - Use the appropriate module (`messages`, `attachments`, `chats`) to act.

3) Shutdown
   - When instructed, call `sdk.close()` to cleanly close the Socket.IO connection.

If you are a more capable LLM that can also edit code in this repository, prefer small, well-scoped changes and keep the dual-channel architecture (Socket.IO for events, HTTP for operations) and authentication flow intact.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.