codex-twinny-bridge 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.en.md +389 -0
- package/README.md +389 -2
- package/configs/banner.png +0 -0
- package/configs/logo.png +0 -0
- package/dist/app/caffeinate.d.ts +28 -0
- package/dist/app/caffeinate.js +96 -0
- package/dist/app/caffeinate.js.map +1 -0
- package/dist/app/daemon.d.ts +1 -0
- package/dist/app/daemon.js +61 -0
- package/dist/app/daemon.js.map +1 -0
- package/dist/app/lark-assets.d.ts +25 -0
- package/dist/app/lark-assets.js +108 -0
- package/dist/app/lark-assets.js.map +1 -0
- package/dist/app/startup-error-telemetry.d.ts +21 -0
- package/dist/app/startup-error-telemetry.js +169 -0
- package/dist/app/startup-error-telemetry.js.map +1 -0
- package/dist/app/startup-probe.d.ts +17 -0
- package/dist/app/startup-probe.js +94 -0
- package/dist/app/startup-probe.js.map +1 -0
- package/dist/app/wiring.d.ts +164 -0
- package/dist/app/wiring.js +992 -0
- package/dist/app/wiring.js.map +1 -0
- package/dist/cli/commands.d.ts +1 -0
- package/dist/cli/commands.js +99 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/cli/install-guide.d.ts +56 -0
- package/dist/cli/install-guide.js +606 -0
- package/dist/cli/install-guide.js.map +1 -0
- package/dist/cli/install-wizard.d.ts +210 -0
- package/dist/cli/install-wizard.js +1537 -0
- package/dist/cli/install-wizard.js.map +1 -0
- package/dist/cli/update.d.ts +31 -0
- package/dist/cli/update.js +171 -0
- package/dist/cli/update.js.map +1 -0
- package/dist/codex/appserver.d.ts +160 -0
- package/dist/codex/appserver.js +602 -0
- package/dist/codex/appserver.js.map +1 -0
- package/dist/codex/bash-context.d.ts +21 -0
- package/dist/codex/bash-context.js +132 -0
- package/dist/codex/bash-context.js.map +1 -0
- package/dist/codex/goal.d.ts +68 -0
- package/dist/codex/goal.js +432 -0
- package/dist/codex/goal.js.map +1 -0
- package/dist/codex/index.d.ts +6 -0
- package/dist/codex/index.js +7 -0
- package/dist/codex/index.js.map +1 -0
- package/dist/codex/protocol.d.ts +99 -0
- package/dist/codex/protocol.js +230 -0
- package/dist/codex/protocol.js.map +1 -0
- package/dist/codex/thread-name.d.ts +3 -0
- package/dist/codex/thread-name.js +27 -0
- package/dist/codex/thread-name.js.map +1 -0
- package/dist/codex/thread.d.ts +185 -0
- package/dist/codex/thread.js +451 -0
- package/dist/codex/thread.js.map +1 -0
- package/dist/codex/turn.d.ts +279 -0
- package/dist/codex/turn.js +1386 -0
- package/dist/codex/turn.js.map +1 -0
- package/dist/config/bootstrap.d.ts +14 -0
- package/dist/config/bootstrap.js +56 -0
- package/dist/config/bootstrap.js.map +1 -0
- package/dist/config/index.d.ts +4 -0
- package/dist/config/index.js +5 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +64 -0
- package/dist/config/loader.js +783 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/paths.d.ts +11 -0
- package/dist/config/paths.js +58 -0
- package/dist/config/paths.js.map +1 -0
- package/dist/config/secrets.d.ts +53 -0
- package/dist/config/secrets.js +165 -0
- package/dist/config/secrets.js.map +1 -0
- package/dist/conversation/manager.d.ts +1063 -0
- package/dist/conversation/manager.js +14420 -0
- package/dist/conversation/manager.js.map +1 -0
- package/dist/conversation/queue.d.ts +8 -0
- package/dist/conversation/queue.js +28 -0
- package/dist/conversation/queue.js.map +1 -0
- package/dist/conversation/routing.d.ts +11 -0
- package/dist/conversation/routing.js +55 -0
- package/dist/conversation/routing.js.map +1 -0
- package/dist/conversation/trigger-identity.d.ts +15 -0
- package/dist/conversation/trigger-identity.js +24 -0
- package/dist/conversation/trigger-identity.js.map +1 -0
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +17 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/lark/auth.d.ts +41 -0
- package/dist/lark/auth.js +132 -0
- package/dist/lark/auth.js.map +1 -0
- package/dist/lark/browser-auth.d.ts +68 -0
- package/dist/lark/browser-auth.js +258 -0
- package/dist/lark/browser-auth.js.map +1 -0
- package/dist/lark/cards.d.ts +210 -0
- package/dist/lark/cards.js +1478 -0
- package/dist/lark/cards.js.map +1 -0
- package/dist/lark/contact.d.ts +46 -0
- package/dist/lark/contact.js +132 -0
- package/dist/lark/contact.js.map +1 -0
- package/dist/lark/doc-comments.d.ts +58 -0
- package/dist/lark/doc-comments.js +540 -0
- package/dist/lark/doc-comments.js.map +1 -0
- package/dist/lark/events.d.ts +68 -0
- package/dist/lark/events.js +256 -0
- package/dist/lark/events.js.map +1 -0
- package/dist/lark/feature-config.d.ts +75 -0
- package/dist/lark/feature-config.js +354 -0
- package/dist/lark/feature-config.js.map +1 -0
- package/dist/lark/files.d.ts +36 -0
- package/dist/lark/files.js +191 -0
- package/dist/lark/files.js.map +1 -0
- package/dist/lark/filters.d.ts +104 -0
- package/dist/lark/filters.js +822 -0
- package/dist/lark/filters.js.map +1 -0
- package/dist/lark/index.d.ts +12 -0
- package/dist/lark/index.js +13 -0
- package/dist/lark/index.js.map +1 -0
- package/dist/lark/messages.d.ts +90 -0
- package/dist/lark/messages.js +469 -0
- package/dist/lark/messages.js.map +1 -0
- package/dist/lark/openapi.d.ts +58 -0
- package/dist/lark/openapi.js +227 -0
- package/dist/lark/openapi.js.map +1 -0
- package/dist/lark/redactor.d.ts +5 -0
- package/dist/lark/redactor.js +68 -0
- package/dist/lark/redactor.js.map +1 -0
- package/dist/lark/types.d.ts +64 -0
- package/dist/lark/types.js +44 -0
- package/dist/lark/types.js.map +1 -0
- package/dist/launchd/install.d.ts +30 -0
- package/dist/launchd/install.js +174 -0
- package/dist/launchd/install.js.map +1 -0
- package/dist/launchd/plist.d.ts +15 -0
- package/dist/launchd/plist.js +87 -0
- package/dist/launchd/plist.js.map +1 -0
- package/dist/lock/index.d.ts +20 -0
- package/dist/lock/index.js +74 -0
- package/dist/lock/index.js.map +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +11 -0
- package/dist/main.js.map +1 -0
- package/dist/markdown.d.ts +20 -0
- package/dist/markdown.js +296 -0
- package/dist/markdown.js.map +1 -0
- package/dist/observability/health.d.ts +30 -0
- package/dist/observability/health.js +233 -0
- package/dist/observability/health.js.map +1 -0
- package/dist/observability/logs.d.ts +10 -0
- package/dist/observability/logs.js +34 -0
- package/dist/observability/logs.js.map +1 -0
- package/dist/observability/system-notifications.d.ts +34 -0
- package/dist/observability/system-notifications.js +116 -0
- package/dist/observability/system-notifications.js.map +1 -0
- package/dist/platform/commands.d.ts +16 -0
- package/dist/platform/commands.js +43 -0
- package/dist/platform/commands.js.map +1 -0
- package/dist/platform/detect.d.ts +11 -0
- package/dist/platform/detect.js +28 -0
- package/dist/platform/detect.js.map +1 -0
- package/dist/platform/runner.d.ts +2 -0
- package/dist/platform/runner.js +9 -0
- package/dist/platform/runner.js.map +1 -0
- package/dist/profiles/guest.d.ts +19 -0
- package/dist/profiles/guest.js +241 -0
- package/dist/profiles/guest.js.map +1 -0
- package/dist/profiles/index.d.ts +5 -0
- package/dist/profiles/index.js +14 -0
- package/dist/profiles/index.js.map +1 -0
- package/dist/profiles/owner.d.ts +1 -0
- package/dist/profiles/owner.js +6 -0
- package/dist/profiles/owner.js.map +1 -0
- package/dist/service/index.d.ts +2 -0
- package/dist/service/index.js +3 -0
- package/dist/service/index.js.map +1 -0
- package/dist/service/install.d.ts +21 -0
- package/dist/service/install.js +156 -0
- package/dist/service/install.js.map +1 -0
- package/dist/service/lock.d.ts +6 -0
- package/dist/service/lock.js +23 -0
- package/dist/service/lock.js.map +1 -0
- package/dist/service/manual.d.ts +8 -0
- package/dist/service/manual.js +28 -0
- package/dist/service/manual.js.map +1 -0
- package/dist/store/db.d.ts +37 -0
- package/dist/store/db.js +161 -0
- package/dist/store/db.js.map +1 -0
- package/dist/store/index.d.ts +3 -0
- package/dist/store/index.js +4 -0
- package/dist/store/index.js.map +1 -0
- package/dist/store/migrations.d.ts +13 -0
- package/dist/store/migrations.js +280 -0
- package/dist/store/migrations.js.map +1 -0
- package/dist/store/repositories.d.ts +299 -0
- package/dist/store/repositories.js +2063 -0
- package/dist/store/repositories.js.map +1 -0
- package/dist/systemd/install.d.ts +19 -0
- package/dist/systemd/install.js +85 -0
- package/dist/systemd/install.js.map +1 -0
- package/dist/systemd/unit.d.ts +9 -0
- package/dist/systemd/unit.js +60 -0
- package/dist/systemd/unit.js.map +1 -0
- package/dist/telemetry/client.d.ts +60 -0
- package/dist/telemetry/client.js +204 -0
- package/dist/telemetry/client.js.map +1 -0
- package/dist/telemetry/hash.d.ts +1 -0
- package/dist/telemetry/hash.js +8 -0
- package/dist/telemetry/hash.js.map +1 -0
- package/dist/telemetry/index.d.ts +4 -0
- package/dist/telemetry/index.js +5 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/posthog.d.ts +27 -0
- package/dist/telemetry/posthog.js +45 -0
- package/dist/telemetry/posthog.js.map +1 -0
- package/dist/telemetry/reporter.d.ts +13 -0
- package/dist/telemetry/reporter.js +29 -0
- package/dist/telemetry/reporter.js.map +1 -0
- package/dist/types.d.ts +453 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/dist/upgrade/updater.d.ts +66 -0
- package/dist/upgrade/updater.js +587 -0
- package/dist/upgrade/updater.js.map +1 -0
- package/dist/upgrade/version.d.ts +12 -0
- package/dist/upgrade/version.js +55 -0
- package/dist/upgrade/version.js.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/dist/version.js.map +1 -0
- package/dist/version.json +3 -0
- package/dist/windows/task.d.ts +35 -0
- package/dist/windows/task.js +176 -0
- package/dist/windows/task.js.map +1 -0
- package/dist/workspace/index.d.ts +2 -0
- package/dist/workspace/index.js +3 -0
- package/dist/workspace/index.js.map +1 -0
- package/dist/workspace/manager.d.ts +24 -0
- package/dist/workspace/manager.js +116 -0
- package/dist/workspace/manager.js.map +1 -0
- package/dist/workspace/slug.d.ts +8 -0
- package/dist/workspace/slug.js +59 -0
- package/dist/workspace/slug.js.map +1 -0
- package/migrations/0001_initial.sql +102 -0
- package/migrations/0002_lark_doc_watcher.sql +15 -0
- package/migrations/0003_lark_message_doc_comment_id.sql +6 -0
- package/migrations/0004_thread_workspace.sql +46 -0
- package/migrations/0005_thread_create_method.sql +114 -0
- package/migrations/0006_cron_jobs.sql +18 -0
- package/migrations/0007_thread_fork_base_token_usage.sql +2 -0
- package/migrations/0008_lark_doc_watcher_remove_none.sql +43 -0
- package/migrations/0009_lark_doc_watcher_four_modes.sql +47 -0
- package/migrations/0010_cron_silent.sql +17 -0
- package/migrations/0011_human_turn_triggers.sql +8 -0
- package/package.json +83 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 hachiwii
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.en.md
ADDED
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<img src="./configs/banner.png" alt="Codex Twinny Bridge" width="760">
|
|
4
|
+
|
|
5
|
+
# Codex Twinny Bridge
|
|
6
|
+
|
|
7
|
+
**Bring Codex CLI into Feishu / Lark and continue your Codex sessions from chat.**
|
|
8
|
+
|
|
9
|
+
[](https://github.com/OrekiDawson/codex-twinny-bridge/releases)
|
|
10
|
+
[](./LICENSE)
|
|
11
|
+
|
|
12
|
+
Choose the Codex executable, credentials and session directory, and use third-party API providers or model aggregators.
|
|
13
|
+
|
|
14
|
+
[Quick install](#installation) · [Features](#features) · [Agent install guide](./agent_installation_guide.md) · [简体中文](./README.md)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
> Based on [Twinny](https://github.com/hachiwii/twinny), modified and redistributed under the MIT License.
|
|
19
|
+
|
|
20
|
+
## Features
|
|
21
|
+
|
|
22
|
+
- **Use Codex in Feishu / Lark**: direct messages, group chats, topics, and multiple Codex profiles.
|
|
23
|
+
- **Choose your Codex environment**: select the CLI path and `CODEX_HOME` during setup to isolate credentials, sessions, and model configuration.
|
|
24
|
+
- **Use third-party APIs**: reuse an OpenAI-compatible provider without signing in to an official Codex account.
|
|
25
|
+
- **Run in the background**: managed services for macOS, Linux, WSL2, and Windows.
|
|
26
|
+
|
|
27
|
+
## Requirements
|
|
28
|
+
|
|
29
|
+
- macOS, Linux, WSL2, or Windows. The installer manages a macOS LaunchAgent, or a `--system-daemon` LaunchDaemon, on macOS, a systemd user service on Linux/WSL2 with systemd enabled, and a user-level scheduled task on Windows.
|
|
30
|
+
- Node.js 22.18.0 or newer. Codex Twinny Bridge uses Node.js' built-in `node:sqlite` module and does not require an extra SQLite native addon.
|
|
31
|
+
- Codex CLI 0.153.4 or newer in `PATH` (requires `hooks/list` and per-thread hook trust overrides), or set `CODEX_BINARY`; the installer can install Codex automatically if it is missing.
|
|
32
|
+
- A Feishu/Lark bot app with the permissions and event subscriptions listed below.
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
### Installation guide for Codex
|
|
37
|
+
|
|
38
|
+
Copy this prompt into Codex and let it run the agent installer:
|
|
39
|
+
|
|
40
|
+
```text
|
|
41
|
+
Read https://raw.githubusercontent.com/OrekiDawson/codex-twinny-bridge/main/agent_installation_guide.md and follow instructions in it.
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Install Manually
|
|
45
|
+
|
|
46
|
+
Install the public Release tarball, then run the interactive installer:
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
npm install -g https://github.com/OrekiDawson/codex-twinny-bridge/releases/download/v0.1.0/codex-twinny-bridge-0.1.0.tgz
|
|
50
|
+
codex-twinny-bridge install
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The installer asks for the Codex CLI executable, the credentials/session directory (`CODEX_HOME`), and the authentication mode. For “Third-party API / model aggregator,” configure `model_provider`, `base_url`, and `requires_openai_auth = false` in that directory’s `config.toml` first. The installer validates and uses that directory’s Codex credentials and sessions.
|
|
54
|
+
|
|
55
|
+
On macOS, Twinny installs as a LaunchAgent in the current GUI session by default. In SSH, CI, or another environment without a GUI LaunchAgent, the installer exits and asks you to use system daemon mode:
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
codex-twinny-bridge install --system-daemon
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
`--system-daemon` writes the plist to `/Library/LaunchDaemons` through `sudo` and sets `UserName` to the current user. Later `start`, `stop`, `restart`, and `status` commands keep using LaunchDaemon based on the service settings in `config.toml`.
|
|
62
|
+
|
|
63
|
+
Native Windows installs create a user-level Task Scheduler task that starts when the user logs in. If WSL2 does not have systemd enabled, the installer does not create a managed service; run Twinny in the foreground with `TWINNY_HOME=/path/to/home codex-twinny-bridge run`, or enable WSL systemd and reinstall.
|
|
64
|
+
|
|
65
|
+
Useful service commands:
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
codex-twinny-bridge doctor
|
|
69
|
+
codex-twinny-bridge status
|
|
70
|
+
codex-twinny-bridge update
|
|
71
|
+
codex-twinny-bridge start
|
|
72
|
+
codex-twinny-bridge stop
|
|
73
|
+
codex-twinny-bridge restart
|
|
74
|
+
codex-twinny-bridge uninstall
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Use `TWINNY_HOME=/path/to/home` with any command when you are not using the default home.
|
|
78
|
+
|
|
79
|
+
Secrets are stored outside `config.toml`. Non-macOS installs, including Windows, store the Lark `app_secret` in the `lark_app_secret` field in `TWINNY_HOME/auth.json`. macOS installs use the system Keychain by default; with `--disable-keychain`, or if the Keychain write fails, the installer stores the secret in `auth.json` instead. On startup, Twinny reads `auth.json` first, then falls back to `TWINNY_LARK_APP_SECRET` and the legacy secret store (macOS Keychain, `runtime/secrets.json` on other platforms).
|
|
80
|
+
|
|
81
|
+
## Feishu/Lark App Configuration
|
|
82
|
+
|
|
83
|
+
You need to grant these required API permissions in the Feishu/Lark developer console:
|
|
84
|
+
|
|
85
|
+
```text
|
|
86
|
+
im:message.p2p_msg:readonly
|
|
87
|
+
im:message.group_at_msg:readonly
|
|
88
|
+
im:message:readonly
|
|
89
|
+
im:message:send_as_bot
|
|
90
|
+
im:message:update
|
|
91
|
+
im:message:recall
|
|
92
|
+
im:message.reactions:write_only
|
|
93
|
+
im:chat:read
|
|
94
|
+
im:chat:create
|
|
95
|
+
im:chat:update
|
|
96
|
+
im:resource
|
|
97
|
+
contact:user.base:readonly
|
|
98
|
+
docs:document.comment:read
|
|
99
|
+
docs:document.comment:create
|
|
100
|
+
docs:document.comment:write_only
|
|
101
|
+
docs:document.media:download
|
|
102
|
+
wiki:node:read
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Recommended: also grant `im:message.group_msg`. It lets `/activate owner` and `/activate all` receive non-@ group messages. If you only use `owner_at` or `all_at`, the required `im:message.group_at_msg:readonly` scope is enough. The install guide page pre-fills this recommended scope in its import JSON so you can switch group response modes later.
|
|
106
|
+
|
|
107
|
+
If you enable auto-activation greeting (P2P requires `permissions.p2p_default_profile != "none"` and `greeting.p2p.mode != "none"`; groups require both `group_default_profile` and `group_default_mode` to be non-`none` and `greeting.group.mode != "none"`), also grant `im:chat.members:bot_access`. P2P greeting additionally needs `p2p_chat_create`; group greeting additionally needs `im.chat.member.bot.added_v1`.
|
|
108
|
+
|
|
109
|
+
Subscribe to these events/callbacks:
|
|
110
|
+
|
|
111
|
+
```text
|
|
112
|
+
im.message.receive_v1
|
|
113
|
+
im.message.recalled_v1
|
|
114
|
+
drive.notice.comment_add_v1
|
|
115
|
+
application.bot.menu_v6
|
|
116
|
+
card.action.trigger
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Use the Feishu/Lark event long connection (WebSocket) mode. Twinny does not require a public HTTP callback URL for message events.
|
|
120
|
+
|
|
121
|
+
Optional bot shortcut menu entries can use these `event_key` values:
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
| Event key | Action |
|
|
125
|
+
| --------- | ---------------------------------------------------- |
|
|
126
|
+
| `help` | Send command help. |
|
|
127
|
+
| `status` | Show the current conversation and thread status. |
|
|
128
|
+
| `queue` | Toggle queue-next-message mode. |
|
|
129
|
+
| `new` | Open a new Codex thread in the current conversation. |
|
|
130
|
+
| `stop` | Stop the active turn and clear queued work. |
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
## Usage
|
|
134
|
+
|
|
135
|
+
Send normal messages to the bot to start or continue a Codex turn. In groups, the owner must activate the group before ordinary messages are routed to Codex.
|
|
136
|
+
|
|
137
|
+
### Conversation Commands
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
| Command | Usage |
|
|
141
|
+
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
|
|
142
|
+
| `/help` | Show available commands. |
|
|
143
|
+
| `/status` | Show conversation, Codex thread, model, token, and queue status. |
|
|
144
|
+
| `/new` | Stop the current task, clear queued messages, and open a new Codex thread. |
|
|
145
|
+
| `/stop [all\|<side_id>]` | Stop the active task and clear queued messages. Use `all` to stop side turns too, or a side id to stop one side turn. |
|
|
146
|
+
| `/next` | Interrupt the current task and start the next queued message. |
|
|
147
|
+
| `/steer <message>` | Inject `message` into the currently running Codex turn; `message` may be parsed as commands. |
|
|
148
|
+
| `/queue [message]` | Without a message, queue your next message. With a message, add it to the next turn and parse commands when dequeued. |
|
|
149
|
+
| `/goal <objective>` | Set and run a Codex goal. A later `/goal` while the goal is active updates the objective. |
|
|
150
|
+
| `/plan [message]` | Enter plan mode. If a message is provided, process it in plan mode immediately. |
|
|
151
|
+
| `/exit` | Exit plan mode in the next queued control step. |
|
|
152
|
+
| `/side <message>` or `/btw <message>` | Start an ephemeral side conversation forked from the current Codex thread. |
|
|
153
|
+
| `/compact` | Compact the current Codex thread context in the next queued control step. |
|
|
154
|
+
| `/thread [message]` | Create a new Lark topic backed by a new Codex thread. If `message` is present, proxy it into that topic and parse commands there. |
|
|
155
|
+
| `/fork [message]` | Fork the current Codex thread into a new Lark topic. If `message` is present, proxy it into that topic and parse commands there. |
|
|
156
|
+
| `/watch <lark_doc_url> [owner\|all]` or `/watch rm <id\|url>` | Watch @bot comments on a Feishu/Lark document and route them to the current thread. Without arguments, list watcher ids for the current thread. `owner` responds only to the owner, `all` responds to everyone, and `rm` deletes a watcher from the current thread. |
|
|
157
|
+
| `/model <model> <effort>` | Set the model and reasoning effort for future turns in the current thread. |
|
|
158
|
+
| `/cron <cron exp> <message>`, `/cron`, `/cron rm <id>` | Manage cron jobs for the current conversation; `message` may be parsed as commands when the job triggers. |
|
|
159
|
+
| `/logo` | Send the Twinny logo image. |
|
|
160
|
+
| `/twinny` or `/banner` | Send the Twinny banner card. |
|
|
161
|
+
|
|
162
|
+
Commands are parsed left to right. Fixed-argument commands only consume their own arguments, so another command can follow `/model <model> <effort>`. `/plan`, `/goal`, and `/side` consume the remaining text as raw text and do not parse commands inside it. `/queue`, `/steer`, `/thread`, `/fork`, and `/cron <cron exp> <message>` recursively parse their `message` when it is executed. `/queue` and `/steer` are valid only as the outermost first command; inside `/thread`, `/fork`, or another command tail they are treated as ordinary text.
|
|
163
|
+
|
|
164
|
+
Examples:
|
|
165
|
+
|
|
166
|
+
```text
|
|
167
|
+
/queue /model gpt-5.5 xhigh /plan xxx
|
|
168
|
+
/cron * * * * * /goal xxx
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
### Group Administration
|
|
173
|
+
|
|
174
|
+
Only the configured owner can run these commands:
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
| Command | Usage |
|
|
178
|
+
| ------------------------------- | ---------------------------------------------------------------------- |
|
|
179
|
+
| `/activate <owner_at\|owner\|all_at\|all> [profile]` | Activate a group, set who can route messages to Codex, refresh the group name, and optionally bind the group to a profile. |
|
|
180
|
+
| `/deactivate` | Disable Twinny in the current group and clear pending work. |
|
|
181
|
+
| `/pair {guest_ou_id} <profile>` | Authorize a non-owner P2P user and bind that user to a profile. |
|
|
182
|
+
| `/reload [profile]` | Reload all Codex profiles, or one named profile, after editing config. |
|
|
183
|
+
| `/restart` | Schedule a managed Twinny service restart. |
|
|
184
|
+
| `/upgrade [stable\|beta]` | Check and upgrade Twinny. Defaults to `stable` and only upgrades to a higher version. |
|
|
185
|
+
| `/upgrade check [stable\|beta]` | Check whether the selected channel has a newer version. |
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
Response modes:
|
|
189
|
+
|
|
190
|
+
- `owner_at`: only owner messages that mention the bot.
|
|
191
|
+
- `owner`: all owner messages.
|
|
192
|
+
- `all_at`: messages from any group member that mention the bot.
|
|
193
|
+
- `all`: all messages from any group member.
|
|
194
|
+
|
|
195
|
+
## Recommended Practice
|
|
196
|
+
|
|
197
|
+
Create a dedicated Feishu/Lark group for a project. Write an [AGENTS.md](http://AGENTS.md) inside the group's workspace. Let the owner activate the group with the least permissive useful mode, then create one topic per development task:
|
|
198
|
+
|
|
199
|
+
```text
|
|
200
|
+
/activate all host
|
|
201
|
+
/thread fix the login callback race
|
|
202
|
+
/thread add the GitHub README
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Use `/fork` when a task needs an alternative direction while preserving the original Codex thread history:
|
|
206
|
+
|
|
207
|
+
```text
|
|
208
|
+
/fork try the smaller refactor path
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Keep each task's discussion inside its topic. This keeps Codex context, local workspace state, Lark discussion, and status cards separated by task.
|
|
212
|
+
|
|
213
|
+
## Security Notes
|
|
214
|
+
|
|
215
|
+
Twinny runs on the owner's local machine. Treat it as a local automation bridge, not as a hardened multi-tenant execution service.
|
|
216
|
+
|
|
217
|
+
The current default configuration is not fully ready for broad multi-user sharing. In particular, if you activate a group with the `host` profile and `all` response mode, every group member who can speak in that group can run work with the same Codex execution authority as the owner:
|
|
218
|
+
|
|
219
|
+
```text
|
|
220
|
+
/activate all host
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Be careful with `all_at` as well: every group member who can mention the bot can submit work when the group is bound to a powerful profile.
|
|
224
|
+
|
|
225
|
+
Before using Twinny in shared groups:
|
|
226
|
+
|
|
227
|
+
- Prefer a dedicated `codex_home` for guest or team profiles instead of sharing the owner's `~/.codex`.
|
|
228
|
+
- Configure Codex sandbox, filesystem, network, and approval-related settings for that profile.
|
|
229
|
+
- Add workspace-level `.codex` overrides where your Codex setup supports project-local safety policy.
|
|
230
|
+
- Keep `permissions.p2p_default_profile = "none"` unless you intentionally want unpaired P2P users to get access.
|
|
231
|
+
- Keep `permissions.group_default_profile = "none"` and `permissions.group_default_mode = "none"` unless you intentionally want new groups to auto-activate on the first matching message.
|
|
232
|
+
- Use `owner_at` or `owner` instead of `all` or `all_at` unless the group is tightly controlled.
|
|
233
|
+
|
|
234
|
+
## Advanced Configuration
|
|
235
|
+
|
|
236
|
+
### Cron and thread control tools
|
|
237
|
+
|
|
238
|
+
- `add_cron(cron_exp, msg, thread_id?, silent?)` defaults `silent` to `false`. With `true`, work still runs, but Twinny suppresses trigger messages, reactions, progress/result cards and automatic failure replies. Explicit message-sending tools remain available. `list_cron` includes `silent`; silent runs have a null `last_lark_message_id`. Upgrading migrates legacy standalone `TWINNY_SILENT_CRON=true` markers into the field; new jobs use the parameter.
|
|
239
|
+
- `tell_thread(thread_id, msg, mode?)` supports only `queue` (default, schedule a new turn) and `steer` (inject into the active turn or start one when idle).
|
|
240
|
+
- `stop_thread(thread_id)` acts like `/stop` in the target: interrupts the current turn and clears queued messages without starting work or stopping side sessions. It returns `previous_state` (`status`, `turn_id`, `mode`, `queued_message_count`), `interrupted`, and `cleared_messages` (each with `message_id`, `sender_open_id`, `text`). The target must be the current conversation's main thread or a normal Lark-linked thread, and cannot be the caller. Replace the former `interrupt` mode by calling `stop_thread`, then `tell_thread` with the replacement task.
|
|
241
|
+
|
|
242
|
+
### Bash turn context
|
|
243
|
+
|
|
244
|
+
Twinny injects `TWINNY_THREAD_ID`, `TWINNY_TURN_ID`, and `TWINNY_TRIGGER_OPEN_ID` into Codex Bash/shell commands. IDs identify the actual executing thread/turn, including side/fork threads and goal continuation turns. Human-started turns use the initial human sender (the first message in a batch); steering does not replace it. Cron, bot and cross-thread messages inherit the target thread's latest human-started turn. If none exists, Twinny walks `parent_thread`, limiting each ancestor lookup to the time its child was created. If no confirmed human exists in that ancestry, the open ID is empty.
|
|
245
|
+
|
|
246
|
+
The dynamic `PreToolUse` hook is trusted individually by key/hash through thread config overrides. Twinny neither enables global `bypass_hook_trust` nor persists hook trust. Context files are isolated by app-server/thread/turn and cleaned up after each run. Unmanaged turns and Codex subagents without a known Lark initiator receive an empty `TWINNY_TRIGGER_OPEN_ID`, never a previous user's identity. These variables are context metadata, not authentication credentials. Existing PTYs/background processes retain their original environment.
|
|
247
|
+
|
|
248
|
+
Twinny reads `config.toml` from `TWINNY_HOME`.
|
|
249
|
+
|
|
250
|
+
Recognized fields:
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
| Field | Meaning and values |
|
|
254
|
+
| --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
255
|
+
| `[codex].binary` | Codex CLI executable path or command name. Defaults to `codex`. Use an absolute path when the managed service cannot find Codex through `PATH`. On Windows this is usually `codex.cmd`. |
|
|
256
|
+
| `[codex].masquerade_as_codex_cli` | Sends Codex TUI clientInfo during Codex app-server initialization: `name = "codex-tui"`, `title = null`, and `version` parsed from the startup `codex --version` output. Defaults to `false`. |
|
|
257
|
+
| `[lark.reaction].working` | Lark emoji type added while Twinny is working. Defaults to `JubilantRabbit`. |
|
|
258
|
+
| `[lark.reaction].queued` | Lark emoji type added to queued messages. Defaults to `OneSecond`. |
|
|
259
|
+
| `[lark.redaction].email` | Redaction strategy for email addresses in outgoing Lark payloads. `mask` keeps the domain and masks the local part, for example `alice@example.com` becomes `a***e@example.com`; `whitespace` inserts spaces, for example `alice @ example.com`; `none` sends raw email addresses. Feishu may reject bot messages that contain raw email addresses or phone numbers. Defaults to `mask`. |
|
|
260
|
+
| `[lark.redaction].chinese_phone_number` | Redaction strategy for Chinese phone numbers in outgoing Lark payloads. `mask` keeps the first 3 and last 4 digits, for example `138****5678`; `whitespace` inserts spaces, for example `138 1234 5678`; `none` sends raw phone numbers. Feishu may reject bot messages that contain raw email addresses or phone numbers. Defaults to `mask`. |
|
|
261
|
+
| `[permissions].p2p_default_profile` | Profile used when an unpaired P2P user first messages Twinny. Use `none` to deny by default, or a configured profile name to auto-authorize. Defaults to `none`. |
|
|
262
|
+
| `[permissions].p2p_default_workspace` | Default workspace template for new P2P conversations. Supports `{{twinny_home}}` and `{{conversation_key}}` variables. Defaults to `{{twinny_home}}/workspaces/{{conversation_key}}`. If the rendered directory already exists, Twinny reuses it; otherwise it creates it. |
|
|
263
|
+
| `[permissions].group_default_profile` | Profile used when a new group auto-activates. It only takes effect when both this field and `group_default_mode` are not `none`. Defaults to `none`. |
|
|
264
|
+
| `[permissions].group_default_mode` | Group response mode after auto-activation. Values are `owner_at`, `owner`, `all_at`, `all`, or `none`. When this and `group_default_profile` are both not `none`, the first new-group message matching the mode creates the workspace and activates the group. Defaults to `none`. |
|
|
265
|
+
| `[permissions].group_default_workspace` | Default workspace template for new group conversations. Supports `{{twinny_home}}` and `{{conversation_key}}` variables. Defaults to `{{twinny_home}}/workspaces/{{conversation_key}}`. If the rendered directory already exists, Twinny reuses it; otherwise it creates it. |
|
|
266
|
+
| `[greeting.p2p].mode` | Greeting mode after a P2P conversation is created: `none`, `text`, or `codex_turn`. `text` sends the configured message directly to the P2P chat; `codex_turn` sends `message` to Codex and posts a turn card. Defaults to `none`. |
|
|
267
|
+
| `[greeting.p2p].message` | P2P greeting text or Codex turn input. Required as a non-empty string when `mode` is not `none`. |
|
|
268
|
+
| `[greeting.group].mode` | Greeting mode after a group conversation is created: `none`, `text`, or `codex_turn`. Defaults to `none`. |
|
|
269
|
+
| `[greeting.group].message` | Group greeting text or Codex turn input. Required as a non-empty string when `mode` is not `none`. |
|
|
270
|
+
| `[service.launchd].mode` | macOS launchd placement. `gui` uses the current `gui/<uid>` LaunchAgent by default; `daemon` uses a system LaunchDaemon. Usually written by `twinny install --system-daemon`. |
|
|
271
|
+
| `[service.launchd].user_name` | The plist `UserName` when `mode = "daemon"`. Usually written automatically by `twinny install --system-daemon` from the current user. |
|
|
272
|
+
| `[upgrade].channel` | Auto-upgrade channel. `stable` maps to the npm `latest` dist-tag; `beta` maps to the npm `beta` dist-tag. Defaults to `stable`. |
|
|
273
|
+
| `[upgrade].check_interval` | Auto-upgrade check interval. Supports `ms`, `s`, `m`, `h`, and `d` suffixes. Defaults to `1d`. |
|
|
274
|
+
| `[upgrade].auto_update` | Whether Twinny should automatically apply a detected newer version. Defaults to `true`. When `false`, Twinny only notifies the owner. |
|
|
275
|
+
| `[upgrade].registry` | Optional npm registry URL. When set, manual and automatic upgrade checks and downloads use that registry. |
|
|
276
|
+
| `[profiles.<name>].codex_home` | `CODEX_HOME` for that profile. Absolute paths are used as-is; relative paths are resolved under `TWINNY_HOME`. `host` defaults to `~/.codex`; other profiles inherit `host` unless set. |
|
|
277
|
+
| `[profiles.<name>].default_model` | Default model for new threads in that profile. `host` defaults to `gpt-5.5`; other profiles inherit `host` unless set. |
|
|
278
|
+
| `[profiles.<name>].default_effort` | Default reasoning effort for new threads in that profile. Common values are `minimal`, `low`, `medium`, `high`, and `xhigh`; `host` defaults to `medium`; other profiles inherit `host` unless set. |
|
|
279
|
+
| `[telemetry].enabled` | Boolean opt-out for telemetry-capable builds. Set to `false` to disable event capture. See [Telemetry](#telemetry). |
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
Telemetry data scope and opt-out settings are covered in [Telemetry](#telemetry).
|
|
283
|
+
|
|
284
|
+
Example `config.toml`:
|
|
285
|
+
|
|
286
|
+
```toml
|
|
287
|
+
[codex]
|
|
288
|
+
binary = "/opt/homebrew/bin/codex"
|
|
289
|
+
masquerade_as_codex_cli = false
|
|
290
|
+
|
|
291
|
+
[lark.reaction]
|
|
292
|
+
working = "JubilantRabbit"
|
|
293
|
+
queued = "OneSecond"
|
|
294
|
+
|
|
295
|
+
[lark.redaction]
|
|
296
|
+
email = "mask"
|
|
297
|
+
chinese_phone_number = "mask"
|
|
298
|
+
|
|
299
|
+
[permissions]
|
|
300
|
+
p2p_default_profile = "none"
|
|
301
|
+
p2p_default_workspace = "{{twinny_home}}/workspaces/{{conversation_key}}"
|
|
302
|
+
group_default_profile = "none"
|
|
303
|
+
group_default_mode = "none"
|
|
304
|
+
group_default_workspace = "{{twinny_home}}/workspaces/{{conversation_key}}"
|
|
305
|
+
|
|
306
|
+
[greeting.p2p]
|
|
307
|
+
mode = "none"
|
|
308
|
+
message = ""
|
|
309
|
+
|
|
310
|
+
[greeting.group]
|
|
311
|
+
mode = "none"
|
|
312
|
+
message = ""
|
|
313
|
+
|
|
314
|
+
[upgrade]
|
|
315
|
+
channel = "stable"
|
|
316
|
+
check_interval = "1d"
|
|
317
|
+
auto_update = true
|
|
318
|
+
|
|
319
|
+
[profiles.host]
|
|
320
|
+
codex_home = "~/.codex"
|
|
321
|
+
default_model = "gpt-5.5"
|
|
322
|
+
default_effort = "medium"
|
|
323
|
+
|
|
324
|
+
[profiles.guest]
|
|
325
|
+
codex_home = "./profiles/guest-codex"
|
|
326
|
+
default_model = "gpt-5.5"
|
|
327
|
+
default_effort = "medium"
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
Relative `codex_home` paths are resolved under `TWINNY_HOME`. Each profile starts its own Codex app-server process with `CODEX_HOME` set to that profile's `codex_home`.
|
|
331
|
+
|
|
332
|
+
After editing profile config, run `/reload [profile]` from Lark or restart the daemon.
|
|
333
|
+
|
|
334
|
+
### Auto Upgrade
|
|
335
|
+
|
|
336
|
+
Twinny enables auto-upgrade only when the running version matches `a.b.c` or `a.b.c-numericTimestamp`. Local development builds such as `dev` disable auto-upgrade. Manual `/upgrade` also refuses to apply an upgrade in that state because Twinny cannot reliably enforce "only upgrade to a newer version."
|
|
337
|
+
|
|
338
|
+
Version ordering compares `major.minor.patch` first. For the same base version, a version without a suffix is newer than one with a suffix. If both versions have numeric timestamp suffixes, the larger suffix is newer.
|
|
339
|
+
|
|
340
|
+
Auto-upgrade first checks the npm dist-tag, then downloads the target package into a temporary `runtime/upgrade` runner directory. A detached Node helper performs the replacement: stop the current daemon, back up the whole sqlite directory, back up and replace the runner, start the new runner, and wait up to 2 minutes for the new version to write runtime status. If startup times out or fails, the helper restores the sqlite directory and old runner, then starts the old version again. The sqlite backup includes `-wal` and `-shm` files; even after the daemon stops, WAL may contain committed transactions that have not been checkpointed, so copying the whole sqlite directory is the safest backup.
|
|
341
|
+
|
|
342
|
+
macOS LaunchAgent, macOS LaunchDaemon, systemd user service, and Windows Task Scheduler are supported through the detached helper. For LaunchDaemon installs, the helper uses a sentinel file plus the current runtime pid and launchd KeepAlive instead of depending on interactive `sudo`. Foreground `codex-twinny-bridge run` has no managed supervisor and is not supported for automatic replacement restarts.
|
|
343
|
+
|
|
344
|
+
## Multiple Instances With `TWINNY_HOME`
|
|
345
|
+
|
|
346
|
+
Run multiple isolated Twinny instances by giving each instance its own home:
|
|
347
|
+
|
|
348
|
+
```sh
|
|
349
|
+
TWINNY_HOME="$HOME/.codex-twinny-bridge-work" codex-twinny-bridge install
|
|
350
|
+
TWINNY_HOME="$HOME/.codex-twinny-bridge-personal" codex-twinny-bridge install
|
|
351
|
+
|
|
352
|
+
TWINNY_HOME="$HOME/.codex-twinny-bridge-work" codex-twinny-bridge status
|
|
353
|
+
TWINNY_HOME="$HOME/.codex-twinny-bridge-personal" codex-twinny-bridge logs
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
Each home gets separate config and needs a separate Feishu bot app.
|
|
357
|
+
|
|
358
|
+
## Telemetry
|
|
359
|
+
|
|
360
|
+
Twinny builds with telemetry enabled may send anonymous, best-effort usage and reliability events. The data is used to monitor product quality, understand failure patterns, and support the maintainer's personal research interests around local-agent workflows.
|
|
361
|
+
|
|
362
|
+
Twinny does not collect or upload conversation content or credentials. This includes Lark message text, prompts, Codex answers, Feishu/Lark app secrets or tokens, Codex credentials or session tokens, chat names, sender names, raw Lark or Codex IDs, raw local paths, environment variable values, API keys, and other secrets. Identifiers such as install, conversation, thread, turn, sender, message, and Codex binary are salted and hashed locally before upload.
|
|
363
|
+
|
|
364
|
+
Telemetry may include:
|
|
365
|
+
|
|
366
|
+
- install and launch lifecycle status, startup duration, and managed service setup state;
|
|
367
|
+
- runtime health signals such as heartbeat, uptime, queue and active-turn counts, memory usage, and Lark/Codex readiness;
|
|
368
|
+
- message routing metadata such as conversation type, message or action type, route kind, queue depth, and resource counts;
|
|
369
|
+
- turn metadata such as status, type, model, reasoning effort, token counts, duration, generated image count, and error code/category when a turn fails;
|
|
370
|
+
- environment metadata such as Twinny, Codex, Node, OS version/platform/arch, Lark brand, and profile count.
|
|
371
|
+
|
|
372
|
+
Telemetry failures are ignored by the product path and should not affect install, launch, message handling, or Codex turns.
|
|
373
|
+
|
|
374
|
+
Disable telemetry in `config.toml`:
|
|
375
|
+
|
|
376
|
+
```toml
|
|
377
|
+
[telemetry]
|
|
378
|
+
enabled = false
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
Or disable it for a process with an environment variable:
|
|
382
|
+
|
|
383
|
+
```sh
|
|
384
|
+
TWINNY_TELEMETRY_ENABLED=false codex-twinny-bridge start
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
## License
|
|
388
|
+
|
|
389
|
+
MIT
|