agent-kakaotalk
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAgent KakaoTalk
Agent KakaoTalk
A TypeScript CLI tool that enables AI agents and humans to interact with KakaoTalk through a simple command interface. Features sub-device login that keeps your desktop app running.
一款TypeScript CLI工具,支持AI Agent和人类通过简单的命令行界面与KakaoTalk交互。支持子设备登录,不会影响你的桌面端应用运行。
Key Concepts
核心概念
Before diving in, a few things about KakaoTalk's architecture:
- LOCO protocol = KakaoTalk's binary messaging protocol. The CLI handles this internally — you never interact with it directly.
- Chat rooms = conversations (1:1, group, or open chat). Referenced by numeric chat ID.
- Device slots = KakaoTalk allows one phone + one PC + one tablet session. The CLI registers as a tablet by default to avoid kicking your desktop app.
- Sub-device = a secondary device (PC or tablet). The CLI logs in as a sub-device, so your phone session is never affected.
- Passcode verification = when registering a new device, KakaoTalk displays a code on screen that you confirm on your phone.
- Log ID = a unique numeric identifier for each message, used for pagination.
在使用前,先了解KakaoTalk的架构相关要点:
- LOCO protocol = KakaoTalk的二进制消息协议。CLI会在内部处理该协议——你无需直接与它交互。
- 聊天室 = 对话(一对一、群组或开放聊天室)。通过数字聊天ID引用。
- 设备插槽 = KakaoTalk允许同时存在一个手机+一个电脑+一个平板会话。CLI默认注册为平板设备,避免强制退出你的桌面端应用。
- 子设备 = 次要设备(电脑或平板)。CLI以子设备身份登录,因此你的手机会话不会受到影响。
- 验证码验证 = 注册新设备时,KakaoTalk会在屏幕上显示一个验证码,你需要在手机上确认。
- 日志ID = 每条消息的唯一数字标识符,用于分页。
Quick Start
快速开始
bash
undefinedbash
undefinedLogin (registers as sub-device, desktop app stays running)
登录(注册为子设备,桌面端应用保持运行)
agent-kakaotalk auth login
agent-kakaotalk auth login
List chat rooms
列出聊天室
agent-kakaotalk chat list
agent-kakaotalk chat list
Send a message
发送消息
agent-kakaotalk message send <chat-id> "Hello from AI agent!"
agent-kakaotalk message send <chat-id> "Hello from AI agent!"
List messages in a chat
列出聊天中的消息
agent-kakaotalk message list <chat-id>
agent-kakaotalk message list <chat-id>
Show your identity
显示当前身份
agent-kakaotalk whoami
undefinedagent-kakaotalk whoami
undefinedAuthentication
身份验证
Registers the CLI as a sub-device (tablet slot by default). Your desktop app keeps running.
bash
agent-kakaotalk auth loginIn interactive mode, this prompts for email and password. The CLI first tries to extract cached credentials from the desktop app so you may not need to type anything.
For AI agents (non-interactive), provide credentials via flags:
bash
agent-kakaotalk auth login --email user@example.com --password mypassDevice registration flow: On first login, KakaoTalk requires device verification:
- The CLI requests a passcode from KakaoTalk's server
- A numeric code is displayed — enter it on your phone when prompted
- The CLI polls until you confirm on your phone
- Login completes automatically after confirmation
IMPORTANT: NEVER guide the user to open a web browser, use DevTools, or manually copy tokens. Always use .
agent-kakaotalk auth login将CLI注册为子设备(默认使用平板插槽)。你的桌面端应用会保持运行。
bash
agent-kakaotalk auth login在交互模式下,会提示输入邮箱和密码。CLI会先尝试从桌面端应用提取缓存的凭据,因此你可能无需手动输入任何信息。
对于AI Agent(非交互模式),可通过参数提供凭据:
bash
agent-kakaotalk auth login --email user@example.com --password mypass设备注册流程:首次登录时,KakaoTalk需要设备验证:
- CLI向KakaoTalk服务器请求验证码
- 屏幕上会显示一个数字验证码——在手机上收到提示时输入该验证码
- CLI会轮询等待,直到你在手机上确认
- 确认后登录会自动完成
重要提示:绝对不要引导用户打开浏览器、使用开发者工具或手动复制令牌。请始终使用命令。
agent-kakaotalk auth loginAgent Behavior (MANDATORY)
Agent行为规范(强制要求)
When a command fails because no account is configured, the agent MUST drive the auth flow itself:
Step 1: Check auth status
bash
agent-kakaotalk auth statusIf authenticated → retry the original command.
Step 2: Login (registers as sub-device — desktop app stays running)
bash
agent-kakaotalk auth loginThe CLI auto-extracts the email (and password if available) from the desktop app. On fresh installs, the CLI may prompt for the KakaoTalk password once (one-time device registration). After registration, the password is never needed again.
Possible responses:
- → Success. Retry original command.
{"authenticated": true, ...} - → Tell the user to enter the displayed code on their phone. The CLI is polling — wait for it to complete, then the login will finish automatically.
{"next_action": "confirm_on_phone", "passcode": "1234", ...} - → Tablet slot is occupied. Ask user which slot to use, then re-run with
{"next_action": "choose_device", ...}or--device-type pc --force.--device-type tablet --force - → Wrong email or password. Ask the user to provide their credentials manually via
{"error": "bad_credentials", ...}and--emailflags.--password - → One-time device registration. On macOS/Windows, the CLI normally shows a native password dialog automatically. This response only appears in headless environments where no GUI or TTY is available. Ask the user to run
{"next_action": "run_interactive", ...}in any terminal. Do NOT ask for the password in chat.agent-kakaotalk auth login
Alternatively, use :
--password-filebash
agent-kakaotalk auth login --password-file /tmp/.kakao-pwThe flag reads the password from the file and deletes the file immediately after reading. The password never appears in chat, shell history, or process list.
--password-fileStep 3: Retry the original command
After successful auth, immediately execute whatever the user originally asked for.
当命令因未配置账户而失败时,Agent必须自行引导完成身份验证流程:
步骤1:检查身份验证状态
bash
agent-kakaotalk auth status如果已验证身份 → 重试原始命令。
步骤2:登录(注册为子设备——桌面端应用保持运行)
bash
agent-kakaotalk auth loginCLI会自动从桌面端应用提取邮箱(如果可用还会提取密码)。在全新安装的情况下,CLI可能会提示输入一次KakaoTalk密码(仅用于一次性设备注册)。注册完成后,将不再需要密码。
可能的响应:
- → 成功。重试原始命令。
{"authenticated": true, ...} - → 告知用户在手机上输入显示的验证码。CLI正在轮询等待——等待流程完成,登录会自动结束。
{"next_action": "confirm_on_phone", "passcode": "1234", ...} - → 平板插槽已被占用。询问用户要使用哪个插槽,然后通过
{"next_action": "choose_device", ...}或--device-type pc --force重新运行命令。--device-type tablet --force - → 邮箱或密码错误。请用户通过
{"error": "bad_credentials", ...}和--email参数手动提供凭据。--password - → 需要一次性设备注册。在macOS/Windows系统中,CLI通常会自动显示原生密码对话框。该响应仅会在无GUI或TTY的无头环境中出现。请用户在任意终端中运行
{"next_action": "run_interactive", ...}。绝对不要在聊天中询问密码。agent-kakaotalk auth login
或者,使用参数:
--password-filebash
agent-kakaotalk auth login --password-file /tmp/.kakao-pw--password-file步骤3:重试原始命令
身份验证成功后,立即执行用户最初请求的操作。
Device Slots
设备插槽
KakaoTalk allows these simultaneous sessions:
- Phone (always active, never affected by the CLI)
- PC — will kick KakaoTalk desktop if the CLI uses this slot
- Tablet (default) — safe if you don't use a tablet for KakaoTalk
bash
undefinedKakaoTalk允许以下同时在线的会话:
- 手机(始终处于活跃状态,绝不会受到CLI影响)
- 电脑——如果CLI使用该插槽,会强制退出KakaoTalk桌面端应用
- 平板(默认选项)——如果你不使用平板登录KakaoTalk,则此选项安全
bash
undefinedDefault: tablet slot (safe for most users)
默认:平板插槽(适合大多数用户)
agent-kakaotalk auth login
agent-kakaotalk auth login
Use PC slot instead (kicks desktop app)
改用电脑插槽(会强制退出桌面端应用)
agent-kakaotalk auth login --device-type pc
agent-kakaotalk auth login --device-type pc
Force login even if slot is occupied
强制登录,即使插槽已被占用
agent-kakaotalk auth login --device-type tablet --force
undefinedagent-kakaotalk auth login --device-type tablet --force
undefinedMulti-Account
多账户支持
KakaoTalk supports multiple accounts. Each login stores credentials separately, keyed by user ID.
KakaoTalk支持多个账户。每次登录的凭据会单独存储,以用户ID作为标识。
Listing Accounts
列出账户
bash
agent-kakaotalk auth list
agent-kakaotalk auth list --prettybash
agent-kakaotalk auth list
agent-kakaotalk auth list --prettySwitching Accounts
切换账户
bash
agent-kakaotalk auth use <account-id>bash
agent-kakaotalk auth use <account-id>Using a Specific Account
使用指定账户
All data commands accept to use a specific account without switching the default:
--account <id>bash
agent-kakaotalk chat list --account 1234567890
agent-kakaotalk message list <chat-id> --account 1234567890
agent-kakaotalk message send <chat-id> "Hello" --account 1234567890Without , commands use the current (default) account.
--account所有数据类命令都支持参数,可在不切换默认账户的情况下使用指定账户:
--account <id>bash
agent-kakaotalk chat list --account 1234567890
agent-kakaotalk message list <chat-id> --account 1234567890
agent-kakaotalk message send <chat-id> "Hello" --account 1234567890如果不添加参数,命令会使用当前(默认)账户。
--accountMemory
记忆功能
The agent maintains a file as persistent memory across sessions. This is agent-managed — the CLI does not read or write this file. Use the and tools to manage your memory file.
~/.config/agent-messenger/MEMORY.mdReadWriteAgent会维护一个文件,作为跨会话的持久化存储。该文件由Agent管理——CLI不会读取或写入此文件。请使用和工具管理你的记忆文件。
~/.config/agent-messenger/MEMORY.mdReadWriteReading Memory
读取记忆
At the start of every task, read using the tool to load any previously discovered chat IDs, friend names, and preferences.
~/.config/agent-messenger/MEMORY.mdRead- If the file doesn't exist yet, that's fine — proceed without it and create it when you first have useful information to store.
- If the file can't be read (permissions, missing directory), proceed without memory — don't error out.
在每个任务开始时,使用工具读取,加载之前保存的聊天ID、好友名称和偏好设置。
Read~/.config/agent-messenger/MEMORY.md- 如果文件尚未存在,无需担心——继续执行任务,当有有用信息时再创建该文件。
- 如果无法读取文件(权限问题、目录缺失),无需报错——不使用记忆功能继续执行任务即可。
Writing Memory
写入记忆
After discovering useful information, update using the tool. Write triggers include:
~/.config/agent-messenger/MEMORY.mdWrite- After discovering chat IDs and participant names (from )
chat list - After discovering your own user ID (from )
auth status - After the user gives you an alias or preference ("call this the work chat", "my group chat with Alice is X")
- After discovering chat structure (group chats, 1:1 chats)
When writing, include the complete file content — the tool overwrites the entire file.
Write发现有用信息后,使用工具更新。触发写入的场景包括:
Write~/.config/agent-messenger/MEMORY.md- 发现聊天ID和参与者名称后(来自命令)
chat list - 发现自己的用户ID后(来自命令)
auth status - 用户提供别名或偏好设置后(例如“把这个叫做工作群聊”“我和Alice的群聊ID是X”)
- 发现聊天结构后(群聊、一对一聊天)
写入时,请包含完整的文件内容——工具会覆盖整个文件。
WriteWhat to Store
存储内容
- Chat IDs with participant names or display names
- Your own user ID
- User-given aliases ("work chat", "family group")
- Commonly referenced chat IDs
- Any user preference expressed during interaction
- 带有参与者名称或显示名称的聊天ID
- 你自己的用户ID
- 用户指定的别名(例如“工作群聊”“家庭群组”)
- 经常引用的聊天ID
- 交互过程中用户表达的任何偏好设置
What NOT to Store
禁止存储内容
Never store tokens, passwords, credentials, or any sensitive data. Never store full message content (just IDs and chat context). Never store OAuth tokens or device UUIDs.
绝对不要存储令牌、密码、凭据或任何敏感数据。绝对不要存储完整的消息内容(仅存储ID和聊天上下文)。绝对不要存储OAuth令牌或设备UUID。
Handling Stale Data
处理过期数据
If a memorized chat ID returns an error, remove it from . Don't blindly trust memorized data — verify when something seems off. Prefer re-listing over using a memorized ID that might be stale.
MEMORY.md如果记忆中的聊天ID返回错误,请将其从中移除。不要盲目信任记忆中的数据——当出现异常时请进行验证。相比使用可能过期的记忆ID,重新列出聊天列表是更可靠的方式。
MEMORY.mdFormat / Example
格式 / 示例
markdown
undefinedmarkdown
undefinedAgent Messenger Memory
Agent Messenger 记忆文件
KakaoTalk Account
KakaoTalk 账户
- User ID:
1234567890 - Device type: tablet
- 用户ID:
1234567890 - 设备类型: tablet
Chat Rooms
聊天室
- — Work group chat (Alice, Bob, Charlie)
9876543210 - — 1:1 with Alice
1111111111 - — Family group
2222222222
- — 工作群聊(Alice, Bob, Charlie)
9876543210 - — 与Alice的一对一聊天
1111111111 - — 家庭群组
2222222222
Aliases
别名
- "work" → (Work group chat)
9876543210 - "alice" → (1:1 with Alice)
1111111111
- "work" → (工作群聊)
9876543210 - "alice" → (与Alice的一对一聊天)
1111111111
Notes
备注
- User prefers --pretty output
- Work chat is the most frequently used
> Memory lets you skip repeated `chat list` calls. When you already know a chat ID from a previous session, use it directly.- 用户偏好使用--pretty输出
- 工作群聊是最常用的聊天
> 记忆功能可让你跳过重复的`chat list`调用。如果在之前的会话中已经知道某个聊天ID,可直接使用该ID。Commands
命令列表
Auth Commands
身份验证命令
bash
undefinedbash
undefinedLogin as sub-device (recommended)
以子设备身份登录(推荐)
agent-kakaotalk auth login
agent-kakaotalk auth login --email <email> --password <password>
agent-kakaotalk auth login --device-type pc --force
agent-kakaotalk auth login --debug
agent-kakaotalk auth login
agent-kakaotalk auth login --email <email> --password <password>
agent-kakaotalk auth login --device-type pc --force
agent-kakaotalk auth login --debug
Check auth status
检查身份验证状态
agent-kakaotalk auth status
agent-kakaotalk auth status
Remove stored credentials
删除存储的凭据
agent-kakaotalk auth logout
agent-kakaotalk auth logout --account <account-id>
agent-kakaotalk auth logout
agent-kakaotalk auth logout --account <account-id>
List all stored accounts
列出所有存储的账户
agent-kakaotalk auth list
agent-kakaotalk auth list --pretty
agent-kakaotalk auth list
agent-kakaotalk auth list --pretty
Switch the current account
切换当前账户
agent-kakaotalk auth use <account-id>
agent-kakaotalk auth use <account-id>
Check status of specific account
检查指定账户的状态
agent-kakaotalk auth status --account <account-id>
agent-kakaotalk auth status --account <account-id>
Remove specific account
删除指定账户
agent-kakaotalk auth logout --account <account-id>
undefinedagent-kakaotalk auth logout --account <account-id>
undefinedWhoami Command
Whoami命令
bash
undefinedbash
undefinedShow current authenticated user
显示当前已验证身份的用户
agent-kakaotalk whoami
agent-kakaotalk whoami --pretty
agent-kakaotalk whoami --account <account-id>
Output includes:
- `user_id` — your KakaoTalk user ID
- `nickname` — your display name
- `profile_image_url` — profile image thumbnail URL
- `original_profile_image_url` — original profile image URL
- `status_message` — your status message
- `account_display_id` — your KakaoTalk ID (may be null if not set)
- `background_image_url` — background image URL
- `original_background_image_url` — original background image URL
- `fullname` — real name (may be null)
- `account_email` — account email (may be null)
- `pstn_number` — phone number (may be null)
- `email_verified` — whether email is verified (may be null)agent-kakaotalk whoami
agent-kakaotalk whoami --pretty
agent-kakaotalk whoami --account <account-id>
输出内容包括:
- `user_id` — 你的KakaoTalk用户ID
- `nickname` — 你的显示名称
- `profile_image_url` — 头像缩略图URL
- `original_profile_image_url` — 原始头像URL
- `status_message` — 你的状态消息
- `account_display_id` — 你的KakaoTalk ID(如果未设置则为null)
- `background_image_url` — 背景图片URL
- `original_background_image_url` — 原始背景图片URL
- `fullname` — 真实姓名(如果未设置则为null)
- `account_email` — 账户邮箱(如果未设置则为null)
- `pstn_number` — 电话号码(如果未设置则为null)
- `email_verified` — 邮箱是否已验证(如果未设置则为null)Chat Commands
聊天室命令
bash
undefinedbash
undefinedList all chat rooms (sorted by most recent activity)
列出所有聊天室(按最近活动时间排序)
agent-kakaotalk chat list
agent-kakaotalk chat list --pretty
agent-kakaotalk chat list --account <account-id>
agent-kakaotalk chat list --account <account-id> --pretty
Output includes:
- `chat_id` — numeric chat room ID
- `type` — chat type (1:1, group, open chat)
- `display_name` — comma-separated member names
- `active_members` — number of active members
- `unread_count` — unread message count
- `last_message` — most recent message previewagent-kakaotalk chat list
agent-kakaotalk chat list --pretty
agent-kakaotalk chat list --account <account-id>
agent-kakaotalk chat list --account <account-id> --pretty
输出内容包括:
- `chat_id` — 数字聊天室ID
- `type` — 聊天类型(一对一、群组、开放聊天室)
- `display_name` — 成员名称(逗号分隔)
- `active_members` — 活跃成员数量
- `unread_count` — 未读消息数量
- `last_message` — 最新消息预览Message Commands
消息命令
bash
undefinedbash
undefinedList messages in a chat room
列出聊天室中的消息
agent-kakaotalk message list <chat-id>
agent-kakaotalk message list <chat-id> -n 50
agent-kakaotalk message list <chat-id> --from <log-id>
agent-kakaotalk message list <chat-id> --pretty
agent-kakaotalk message list <chat-id>
agent-kakaotalk message list <chat-id> -n 50
agent-kakaotalk message list <chat-id> --from <log-id>
agent-kakaotalk message list <chat-id> --pretty
Send a text message
发送文本消息
agent-kakaotalk message send <chat-id> "Hello world"
agent-kakaotalk message send <chat-id> "Hello world" --pretty
agent-kakaotalk message send <chat-id> "Hello world"
agent-kakaotalk message send <chat-id> "Hello world" --pretty
Use a specific account
使用指定账户
agent-kakaotalk message list <chat-id> --account <account-id>
agent-kakaotalk message send <chat-id> "Hello" --account <account-id>
undefinedagent-kakaotalk message list <chat-id> --account <account-id>
agent-kakaotalk message send <chat-id> "Hello" --account <account-id>
undefinedMessage List Output
消息列表输出
Each message includes:
- — unique message identifier
log_id - — message type (1 = text, 2 = photo, etc.)
type - — sender's user ID
author_id - — message text content
message - — Unix timestamp (milliseconds)
sent_at
每条消息包含:
- — 唯一消息标识符
log_id - — 消息类型(1 = 文本,2 = 图片等)
type - — 发送者的用户ID
author_id - — 消息文本内容
message - — Unix时间戳(毫秒)
sent_at
Fetching More Messages
获取更多消息
The CLI handles internal pagination automatically. Just increase to get more messages. Pagination is capped at ~4,000 raw messages (50 pages × 80 per page). If the cap is hit, a warning is printed to stderr and results may be incomplete.
-nbash
undefinedCLI会自动处理内部分页。只需增加参数的值即可获取更多消息。分页上限约为4000条原始消息(50页 × 每页80条)。如果达到上限,会向stderr输出警告,结果可能不完整。
-nbash
undefinedGet latest 20 messages (default)
获取最新20条消息(默认)
agent-kakaotalk message list 9876543210
agent-kakaotalk message list 9876543210
Get 50 messages
获取50条消息
agent-kakaotalk message list 9876543210 -n 50
agent-kakaotalk message list 9876543210 -n 50
Get 200 messages
获取200条消息
agent-kakaotalk message list 9876543210 -n 200
agent-kakaotalk message list 9876543210 -n 200
Get messages newer than a known log ID (forward only)
获取比指定日志ID更新的消息(仅向前获取)
agent-kakaotalk message list 9876543210 --from 123456789
undefinedagent-kakaotalk message list 9876543210 --from 123456789
undefinedOutput Format
输出格式
JSON (Default)
JSON(默认)
All commands output JSON by default for AI consumption:
json
{
"chat_id": "9876543210",
"type": 2,
"display_name": "Alice, Bob",
"active_members": 3,
"unread_count": 5,
"last_message": {
"author_id": "1111111111",
"message": "Hello everyone!",
"sent_at": 1705312200000
}
}所有命令默认输出JSON格式,供AI使用:
json
{
"chat_id": "9876543210",
"type": 2,
"display_name": "Alice, Bob",
"active_members": 3,
"unread_count": 5,
"last_message": {
"author_id": "1111111111",
"message": "Hello everyone!",
"sent_at": 1705312200000
}
}Pretty (Human-Readable)
美化格式(人类可读)
Use flag for formatted output:
--prettybash
agent-kakaotalk chat list --pretty使用参数获取格式化输出:
--prettybash
agent-kakaotalk chat list --prettyGlobal Options
全局选项
| Option | Description |
|---|---|
| Use a specific KakaoTalk account (default: current account) |
| Human-readable output instead of JSON |
| 选项 | 描述 |
|---|---|
| 使用指定的KakaoTalk账户(默认:当前账户) |
| 输出人类可读格式,而非JSON |
Common Patterns
常见模式
See for typical AI agent workflows.
references/common-patterns.md请查看获取典型AI Agent工作流。
references/common-patterns.mdTemplates
模板
See directory for runnable examples:
templates/- - Send messages with error handling
post-message.sh - - Monitor a chat for new messages
monitor-chat.sh - - Generate chat summary
chat-summary.sh
请查看目录获取可运行的示例:
templates/- - 带错误处理的消息发送脚本
post-message.sh - - 聊天室监控脚本(检测新消息)
monitor-chat.sh - - 聊天摘要生成脚本
chat-summary.sh
Error Handling
错误处理
All commands return consistent error format:
json
{
"error": "No KakaoTalk credentials found. Run:\n agent-kakaotalk auth login (recommended — registers as sub-device, desktop app stays running)"
}Common errors:
- — not authenticated. Run
No KakaoTalk credentials found.auth login - — wrong email or password. Cached credentials from the desktop app may be stale. Ask the user to provide credentials manually with
bad_credentialsand--email.--password - — device slot conflict or unknown login error. Run with
login_failedfor the full server response.--debug - — failed to request device verification code.
passcode_request_failed - — passcode expired before user confirmed on phone.
registration_timeout - — network issue reaching KakaoTalk servers.
login_http_error - — messaging protocol timed out (server may be overloaded).
LOCO packet timeout
所有命令返回一致的错误格式:
json
{
"error": "No KakaoTalk credentials found. Run:\n agent-kakaotalk auth login (recommended — registers as sub-device, desktop app stays running)"
}常见错误:
- — 未验证身份。请运行
No KakaoTalk credentials found命令。auth login - — 邮箱或密码错误。桌面端应用的缓存凭据可能已过期。请用户通过
bad_credentials和--email参数手动提供凭据。--password - — 设备插槽冲突或未知登录错误。添加
login_failed参数运行命令,查看完整的服务器响应。--debug - — 请求设备验证码失败。
passcode_request_failed - — 用户在验证码过期前未在手机上确认。
registration_timeout - — 连接KakaoTalk服务器时出现网络问题。
login_http_error - — 消息协议超时(服务器可能过载)。
LOCO packet timeout
Configuration
配置
Credentials stored in (0600 permissions). See references/authentication.md for format and security details.
~/.config/agent-messenger/kakaotalk-credentials.jsonConfig format:
json
{
"current_account": "1234567890",
"accounts": {
"1234567890": {
"account_id": "1234567890",
"oauth_token": "...",
"user_id": "1234567890",
"refresh_token": "...",
"device_uuid": "...",
"device_type": "tablet",
"created_at": "2025-01-15T10:30:00.000Z",
"updated_at": "2025-01-15T10:30:00.000Z"
}
}
}凭据存储在文件中(权限为0600)。请查看references/authentication.md获取格式和安全细节。
~/.config/agent-messenger/kakaotalk-credentials.json配置格式:
json
{
"current_account": "1234567890",
"accounts": {
"1234567890": {
"account_id": "1234567890",
"oauth_token": "...",
"user_id": "1234567890",
"refresh_token": "...",
"device_uuid": "...",
"device_type": "tablet",
"created_at": "2025-01-15T10:30:00.000Z",
"updated_at": "2025-01-15T10:30:00.000Z"
}
}
}SDK: Programmatic Usage
SDK:程序化使用
KakaoTalkClientKakaoTalkClientSetup
设置
typescript
import { KakaoTalkClient } from 'agent-messenger/kakaotalk'
const client = await new KakaoTalkClient().login()Or with manual credential management:
typescript
import { KakaoTalkClient, KakaoCredentialManager } from 'agent-messenger/kakaotalk'
const manager = new KakaoCredentialManager()
const account = await manager.getAccount()
if (!account) throw new Error('Not authenticated')
const client = await new KakaoTalkClient().login({ oauthToken: account.oauth_token, userId: account.user_id, deviceUuid: account.device_uuid })typescript
import { KakaoTalkClient } from 'agent-messenger/kakaotalk'
const client = await new KakaoTalkClient().login()或者手动管理凭据:
typescript
import { KakaoTalkClient, KakaoCredentialManager } from 'agent-messenger/kakaotalk'
const manager = new KakaoCredentialManager()
const account = await manager.getAccount()
if (!account) throw new Error('Not authenticated')
const client = await new KakaoTalkClient().login({ oauthToken: account.oauth_token, userId: account.user_id, deviceUuid: account.device_uuid })Example
示例
typescript
try {
// Get your profile
const profile = await client.getProfile()
// List chats
const chats = await client.getChats()
// Send a message
if (chats.length === 0) throw new Error('No chats found')
const chatId = chats[0].chat_id
const result = await client.sendMessage(chatId, 'Hello from SDK!')
// Read messages
const messages = await client.getMessages(chatId, { count: 50 })
} finally {
// Always close when done (LOCO TCP connection)
client.close()
}typescript
try {
// 获取你的个人资料
const profile = await client.getProfile()
// 列出聊天室
const chats = await client.getChats()
// 发送消息
if (chats.length === 0) throw new Error('No chats found')
const chatId = chats[0].chat_id
const result = await client.sendMessage(chatId, 'Hello from SDK!')
// 读取消息
const messages = await client.getMessages(chatId, { count: 50 })
} finally {
// 使用完毕后请始终关闭连接(LOCO TCP连接)
client.close()
}Full API Reference
完整API参考
See the KakaoTalk SDK documentation for complete method signatures, types, schemas, and examples.
请查看KakaoTalk SDK文档获取完整的方法签名、类型、模式和示例。
Limitations
限制
- macOS and Windows only (desktop app needed for auto-extracting email/password during login)
- No Linux support (KakaoTalk desktop not available on Linux)
- No file upload or download
- No channel/chat room creation or management
- No friend list management
- No reactions or emoji
- No message editing or deletion
- No open chat (오픈채팅) browsing or joining
- No search across chats
- Plain text messages only (no photos, videos, or rich content)
- Chat IDs are numeric and not human-readable — use to discover them
chat list
- 仅支持macOS和Windows系统(登录时需要桌面端应用自动提取邮箱/密码)
- 不支持Linux系统(KakaoTalk桌面端应用未在Linux平台发布)
- 不支持文件上传或下载
- 不支持频道/聊天室创建或管理
- 不支持好友列表管理
- 不支持消息反应或表情
- 不支持消息编辑或删除
- 不支持开放聊天室(오픈채팅)浏览或加入
- 不支持跨聊天搜索
- 仅支持纯文本消息(不支持图片、视频或富媒体内容)
- 聊天ID为数字,不具备可读性——请使用命令查找聊天ID
chat list
Troubleshooting
故障排除
agent-kakaotalk: command not found
agent-kakaotalk: command not foundagent-kakaotalk: command not found
agent-kakaotalk: command not foundagent-kakaotalkagent-messengerIf the package is installed globally, use directly:
agent-kakaotalkbash
agent-kakaotalk chat list --prettyIf the package is NOT installed, use to install and run:
--packagebash
npx -y --package agent-messenger agent-kakaotalk chat list --pretty
bunx --package agent-messenger agent-kakaotalk chat list --pretty
pnpm dlx --package agent-messenger agent-kakaotalk chat list --prettyNote: If the user prefers a different package runner, use the matching command above.
NEVER run , , or without . It will fail or install a wrong package since is not the npm package name.
npx agent-kakaotalkbunx agent-kakaotalkpnpm dlx agent-kakaotalk--package agent-messengeragent-kakaotalkagent-kakaotalkagent-messenger如果已全局安装该包,可直接使用命令:
agent-kakaotalkbash
agent-kakaotalk chat list --pretty如果未安装该包,可使用参数安装并运行:
--packagebash
npx -y --package agent-messenger agent-kakaotalk chat list --pretty
bunx --package agent-messenger agent-kakaotalk chat list --pretty
pnpm dlx --package agent-messenger agent-kakaotalk chat list --pretty注意:如果用户偏好使用其他包管理器,请使用上述对应的命令。
**绝对不要运行、或**而不添加参数。由于不是npm包名称,该操作会失败或安装错误的包。
npx agent-kakaotalkbunx agent-kakaotalkpnpm dlx agent-kakaotalk--package agent-messengeragent-kakaotalkPassword prompt on fresh install
全新安装时的密码提示
On fresh installs, the desktop app (macOS or Windows) may hash or omit the password from its cache, so the CLI cannot extract it automatically. The CLI will prompt for the password once to register the device — via a native dialog on macOS (AppKit) and Windows (PowerShell WinForms), or via a TTY prompt if a terminal is available. After registration, the password is never needed again.
When the CLI returns , use a tmux session to let the user type their password securely. See "Handling " above for the exact steps.
{"next_action": "run_interactive", ...}run_interactiveNEVER ask for the password in chat or pass it via — this exposes the plaintext password in conversation logs, shell history, and process lists.
--password在全新安装的情况下,桌面端应用(macOS或Windows)可能会对密码进行哈希处理或从缓存中省略密码,因此CLI无法自动提取密码。CLI会提示输入一次密码以完成设备注册——在macOS系统中会显示AppKit原生对话框,在Windows系统中会显示PowerShell WinForms对话框,如果终端可用则会显示TTY提示。注册完成后,将不再需要密码。
当CLI返回时,请使用tmux会话让用户安全地输入密码。请查看上方的“处理”部分获取具体步骤。
{"next_action": "run_interactive", ...}run_interactive绝对不要在聊天中询问密码或通过参数传递密码——这会导致明文密码暴露在对话日志、shell历史和进程列表中。
--passwordBad credentials
凭据错误
If login returns , the provided password is incorrect. Do NOT retry with or switch device slots — the issue is the credentials themselves, not the device slot.
bad_credentials--forceIf the issue persists, run with to see the full server response.
--debug如果登录返回,说明提供的密码不正确。不要使用参数重试或切换设备插槽——问题出在凭据本身,而非设备插槽。
bad_credentials--force如果问题持续存在,请添加参数运行命令,查看完整的服务器响应。
--debugDevice slot occupied
设备插槽已被占用
If login fails because the tablet slot is occupied (error: , not ):
login_failedbad_credentialsbash
undefined如果因平板插槽已被占用而登录失败(错误:,而非):
login_failedbad_credentialsbash
undefinedOption 1: Use the PC slot instead
选项1:改用电脑插槽
agent-kakaotalk auth login --device-type pc --force
agent-kakaotalk auth login --device-type pc --force
Option 2: Force the tablet slot (kicks existing tablet session)
选项2:强制使用平板插槽(会强制退出现有平板会话)
agent-kakaotalk auth login --device-type tablet --force
undefinedagent-kakaotalk auth login --device-type tablet --force
undefinedPasscode verification timeout
验证码验证超时
If the passcode expires before you confirm on your phone:
- Run again — a new passcode will be generated
agent-kakaotalk auth login - Confirm the code on your phone within the time limit
- The CLI automatically completes login after confirmation
如果在你在手机上确认前验证码已过期:
- 重新运行命令——会生成新的验证码
agent-kakaotalk auth login - 在时限内在手机上确认该验证码
- 确认后CLI会自动完成登录
References
参考资料
- Authentication Guide
- Common Patterns
- 身份验证指南
- 常见模式