feishu-codex-connector 0.1.6

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.
@@ -0,0 +1,92 @@
1
+ # Command Completion Spec
2
+
3
+ ## Decisions
4
+
5
+ - `workspace` means a local working directory.
6
+ - `session` means a Codex thread for a Feishu/Lark scope in a workspace under a compatible policy.
7
+ - Do not add a `project` concept.
8
+ - Do not force one group to bind permanently to one workspace.
9
+ - Do not add Codex project import in this milestone.
10
+ - Use `/new group [name]` for new Feishu/Lark group creation.
11
+
12
+ ## CLI Commands
13
+
14
+ ### Service lifecycle
15
+
16
+ `feishu-codex start|stop|restart|status|unregister --profile <name>` must manage a real OS service where supported:
17
+
18
+ - macOS: launchd user agent.
19
+ - Linux: systemd user unit.
20
+ - Windows: Task Scheduler.
21
+
22
+ `status` must report whether the service definition exists and whether the service is currently running.
23
+
24
+ ### Process management
25
+
26
+ `feishu-codex ps` must list registered runtime processes after pruning dead PIDs.
27
+
28
+ `feishu-codex kill <id|pid>` must send SIGTERM to a registered process, or a numeric PID when it is registered.
29
+
30
+ ## Chat Commands
31
+
32
+ ### Sessions
33
+
34
+ - `/new` and `/reset` clear the current scope session and stop any active run.
35
+ - `/resume` lists recent compatible sessions for the current scope and workspace.
36
+ - `/resume use <nonce>` restores the selected session when the nonce is valid.
37
+
38
+ ### Group creation
39
+
40
+ - `/new group [name]` creates a new Feishu/Lark group chat through the bot account.
41
+ - The new group inherits the source scope workspace when one is configured.
42
+ - The bridge sends a welcome message in the new group and an acknowledgement in the source chat.
43
+
44
+ ### Workspaces
45
+
46
+ - `/cd <path>` switches the current scope to an absolute workspace path.
47
+ - `/ws save <name>` saves the current scope workspace as an alias.
48
+ - `/ws add <name> <path>` saves a specific absolute path as an alias.
49
+ - `/ws use <name>` switches to a saved alias.
50
+ - `/ws remove <name>` removes a saved alias.
51
+
52
+ ### Configuration
53
+
54
+ - `/config` returns an interactive configuration card.
55
+ - `/config show` returns a read-only configuration summary.
56
+ - `/config submit` applies a card form submission after admin re-authorization.
57
+
58
+ ### Timeout
59
+
60
+ - `/timeout <minutes|off|default>` changes the current scope idle timeout.
61
+ - Global default timeout belongs in `/config`.
62
+ - `/new` clears the current scope override by clearing the session record.
63
+
64
+ ### Access control
65
+
66
+ - `/invite group` only works in group or topic scopes.
67
+ - `/invite user @name` and `/invite admin @name` require at least one real user mention.
68
+ - `/invite all group` lists bot-joined chats through the channel gateway and adds them to `allowedChats`.
69
+ - `/remove user @name`, `/remove admin @name`, and `/remove group` mirror invite validation.
70
+
71
+ ### Diagnostics
72
+
73
+ - `/doctor` returns a concise low-sensitive status.
74
+ - `/doctor detail` returns expanded diagnostics.
75
+ - `feishu-codex doctor --json` returns machine-readable diagnostics.
76
+
77
+ ## Callback Security
78
+
79
+ All state-changing command-card buttons must include a signed callback token with:
80
+
81
+ - command
82
+ - scope
83
+ - chat
84
+ - operator
85
+ - TTL
86
+ - nonce
87
+
88
+ The runtime must verify the token and re-run access control before executing the command.
89
+
90
+ ## Real E2E Checks
91
+
92
+ Document comments and generic file attachments require real Feishu/Lark tests after permissions are granted. The code path must reject missing permissions clearly and the docs must include a repeatable checklist.
@@ -0,0 +1,104 @@
1
+ # Feature Parity Specification
2
+
3
+ This document specifies the connector features needed to align the Codex-only connector with the core user-facing behavior of `lark-coding-agent-bridge` while keeping this repository's smaller architecture.
4
+
5
+ ## 1. Streaming Run Cards
6
+
7
+ The bridge must send one run card per Codex turn and update that same card for text, tool calls, usage, terminal state, and stop actions.
8
+
9
+ Required behavior:
10
+
11
+ - The initial card is created before or immediately after the Codex run starts.
12
+ - Text deltas append to the current output.
13
+ - Tool start/end events render as distinct tool blocks.
14
+ - Repeated updates are throttled to avoid Feishu/Lark rate limits.
15
+ - Terminal events flush immediately.
16
+ - The Stop button is signed, scoped to the active run, and replay protected.
17
+ - Card rendering must cap per-tool and full-card content to avoid platform size errors.
18
+ - The final card must not leave an older `Codex running` card behind.
19
+
20
+ Acceptance criteria:
21
+
22
+ - A fast run produces one sent card and subsequent updates patch that card.
23
+ - A run with text and tools shows both.
24
+ - Stop only affects the matching scope/run.
25
+
26
+ ## 2. Document Comment Runs
27
+
28
+ The bridge must handle Feishu/Lark cloud document comment mentions as independent Codex sessions.
29
+
30
+ Required behavior:
31
+
32
+ - Subscribe to and normalize comment events from the long-connection channel.
33
+ - Ignore comment events where the bot was not mentioned.
34
+ - Support `doc`, `docx`, `sheet`, and generic file comments first.
35
+ - Fetch the comment thread context, including the triggering reply text, quote text when available, and whole-document vs inline-comment flag.
36
+ - Use a stable comment-thread scope so every document comment thread has its own Codex thread.
37
+ - Run Codex with the same workspace and policy machinery used by IM messages.
38
+ - Reply to the same comment thread with plain text.
39
+ - Do not ask Codex to call comment APIs itself; the bridge owns comment replies.
40
+
41
+ Acceptance criteria:
42
+
43
+ - A normalized comment mention starts a Codex run using a `comment:*` scope.
44
+ - The final reply is posted as a plain comment reply.
45
+ - The comment scope can resume its previous Codex thread when policy/workspace match.
46
+
47
+ ## 3. Short-Window Message Batching
48
+
49
+ The bridge must merge messages sent close together in the same scope before creating a Codex turn.
50
+
51
+ Required behavior:
52
+
53
+ - Non-command messages enter a per-scope pending queue.
54
+ - The queue flushes after a quiet window, defaulting to the profile `preferences.debounceMs`.
55
+ - While a scope has an active run, ordinary messages accumulate but do not start a new run.
56
+ - When the active run finishes, queued messages wait for a fresh quiet window and then run as a combined prompt.
57
+ - Commands bypass the queue.
58
+ - Commands that change session/workspace state cancel pending ordinary messages for that scope.
59
+
60
+ Acceptance criteria:
61
+
62
+ - Two quick messages in one scope produce one Codex run.
63
+ - Messages sent during a run merge into the next run.
64
+ - `/cd`, `/ws use`, `/new`, `/reset`, and `/stop` are handled immediately.
65
+
66
+ ## 4. Image And File Attachments
67
+
68
+ The bridge must download user-sent Feishu/Lark image and file resources into a profile-local media cache and pass accepted attachments to Codex.
69
+
70
+ Required behavior:
71
+
72
+ - Normalize resources from incoming SDK messages.
73
+ - Download message resources with the message-resource API, not the bot-upload file API.
74
+ - Store downloads under `~/.feishu-codex/profiles/<profile>/media`.
75
+ - Use content hashes for dedupe and stable local paths.
76
+ - Apply attachment policy for max count, total bytes, image bytes, and file bytes.
77
+ - Pass accepted image paths to Codex `imagePaths`.
78
+ - Describe accepted file paths in the structured prompt so Codex can read them locally.
79
+ - Skip or reject unsupported kinds with a user-visible policy note when required.
80
+
81
+ Acceptance criteria:
82
+
83
+ - Image messages produce accepted image attachments and run input image paths.
84
+ - File messages produce local cached paths in the prompt.
85
+ - Rejected required attachments reject the run before Codex starts.
86
+
87
+ ## 5. Interactive Command Cards
88
+
89
+ The bridge must return clickable cards for high-frequency commands.
90
+
91
+ Required behavior:
92
+
93
+ - `/help` returns a card with shortcut buttons for status, workspace list, and new session.
94
+ - `/status` returns a card with profile, scope, workspace, session, queue, auth, and permission details plus useful action buttons.
95
+ - `/ws list` returns a card showing current workspace and saved aliases.
96
+ - Workspace rows include buttons for `ws.use` and `ws.remove`.
97
+ - Card action payloads dispatch through the same command router as slash commands.
98
+ - Card actions must resolve the correct chat/topic scope and enforce access checks.
99
+
100
+ Acceptance criteria:
101
+
102
+ - Clicking `/ws list` "use" switches the workspace for the same scope.
103
+ - Clicking `/status` "new session" resets the same scope.
104
+ - Unauthorized users cannot execute admin card actions.
@@ -0,0 +1,24 @@
1
+ # Feishu/Lark App Permission Matrix
2
+
3
+ V1 uses a personal local runtime and the Feishu/Lark long-connection channel. Exact scope names vary between Feishu and Lark tenants, but the app needs the following capability groups enabled before production use.
4
+
5
+ | Capability | Required for | Notes |
6
+ |---|---|---|
7
+ | IM message receive | Private, group, and topic input | Required for ordinary Codex tasks and slash commands. |
8
+ | IM message send/reply/update | Rich run cards, markdown fallback, status/help replies | Card update permission is needed for streaming run cards. |
9
+ | Card callbacks | Stop button and interactive configuration/status cards | Callback payloads are signed and nonce-protected by the bridge. |
10
+ | Mention metadata | Group mention policy and `/invite user @name` parsing | Mention-all must not count as a bot trigger. |
11
+ | Chat metadata | Group/topic scope resolution and diagnostics | Used to distinguish private, group, and topic contexts. |
12
+ | Chat create/member management | `/new group [name]` and `/invite all group` discovery | Requires the app to create group chats and invite the requesting user. |
13
+ | File/media download | Image and file attachments | Attachment policy enforces count, size, and MIME limits before Codex sees files. |
14
+ | Document comment read/reply | Document comment mention flow | Replies should be plain text by default. |
15
+ | Bot info / app owner lookup | Owner/admin access control and `/status` | If owner refresh fails, access must not widen. |
16
+ | Optional contact lookup | Human-readable diagnostics and invite resolution | Never required for raw Codex execution. |
17
+
18
+ Security defaults:
19
+
20
+ - Owner-only use is the default.
21
+ - Groups require a real bot mention by default.
22
+ - `bot-only` Feishu/Lark CLI identity is the default.
23
+ - `user-default` CLI identity is denied in group chats unless the owner explicitly enables it.
24
+ - Codex sandbox permissions are controlled by the profile permissions, regardless of Codex auth mode.