codelark 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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +193 -0
  3. package/SECURITY.md +34 -0
  4. package/SKILL.md +67 -0
  5. package/agents/openai.yaml +4 -0
  6. package/dist/cli.mjs +8794 -0
  7. package/dist/daemon.mjs +47172 -0
  8. package/dist/ui-server.mjs +22165 -0
  9. package/package.json +73 -0
  10. package/schemas/config.v1.schema.json +259 -0
  11. package/schemas/data/audit.v1.schema.json +44 -0
  12. package/schemas/data/auto-tasks.v1.schema.json +94 -0
  13. package/schemas/data/channel-chats.v1.schema.json +159 -0
  14. package/schemas/data/channel-default-targets.v1.schema.json +43 -0
  15. package/schemas/data/messages.v1.schema.json +23 -0
  16. package/schemas/data/number-map.v1.schema.json +9 -0
  17. package/schemas/data/permissions.v1.schema.json +35 -0
  18. package/schemas/data/sessions.v1.schema.json +330 -0
  19. package/schemas/data/string-map.v1.schema.json +9 -0
  20. package/schemas/manifest.json +121 -0
  21. package/scripts/analyze-bridge-log.js +838 -0
  22. package/scripts/build-preflight.d.ts +21 -0
  23. package/scripts/build-preflight.js +70 -0
  24. package/scripts/build.js +53 -0
  25. package/scripts/check-npm-pack.js +46 -0
  26. package/scripts/daemon.ps1 +16 -0
  27. package/scripts/daemon.sh +206 -0
  28. package/scripts/doctor.ps1 +27 -0
  29. package/scripts/doctor.sh +185 -0
  30. package/scripts/hot-update-bridge.sh +298 -0
  31. package/scripts/install-codex-skills.sh +127 -0
  32. package/scripts/install-codex.sh +10 -0
  33. package/scripts/migrate-bindings-to-channel-chats.js +228 -0
  34. package/scripts/patch-codex-sdk-windows-hide.js +96 -0
  35. package/scripts/real-feishu-e2e.ts +5804 -0
  36. package/scripts/run-tests.js +83 -0
  37. package/scripts/setup-wizard-real-e2e.ts +195 -0
  38. package/scripts/supervisor-linux.sh +49 -0
  39. package/scripts/supervisor-macos.sh +167 -0
  40. package/scripts/supervisor-windows.ps1 +481 -0
  41. package/skills/codelark/SKILL.md +67 -0
  42. package/skills/codelark-auto/SKILL.md +80 -0
  43. package/skills/codelark-question/SKILL.md +54 -0
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "codelark",
3
+ "version": "0.1.0",
4
+ "description": "Installable CodeLark bridge with local setup UI and background service",
5
+ "license": "MIT",
6
+ "homepage": "https://github.com/huiyeruzhou/codelark#readme",
7
+ "bugs": {
8
+ "url": "https://github.com/huiyeruzhou/codelark/issues"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/huiyeruzhou/codelark.git"
13
+ },
14
+ "type": "module",
15
+ "files": [
16
+ "dist/",
17
+ "agents/",
18
+ "schemas/",
19
+ "skills/",
20
+ "scripts/",
21
+ "SKILL.md",
22
+ "LICENSE",
23
+ "README.md",
24
+ "SECURITY.md"
25
+ ],
26
+ "bin": {
27
+ "codelark": "dist/cli.mjs"
28
+ },
29
+ "scripts": {
30
+ "postinstall": "node scripts/patch-codex-sdk-windows-hide.js",
31
+ "build": "node scripts/build.js",
32
+ "typecheck": "tsc --noEmit",
33
+ "dev": "tsx src/entrypoints/daemon.ts",
34
+ "dev:ui": "tsx src/operator-ui/server.ts",
35
+ "docs:dev": "vitepress dev docs --host 127.0.0.1",
36
+ "docs:build": "vitepress build docs",
37
+ "docs:preview": "vitepress preview docs --host 127.0.0.1",
38
+ "logs:analyze": "node scripts/analyze-bridge-log.js",
39
+ "real:setup-wizard:e2e": "tsx scripts/setup-wizard-real-e2e.ts",
40
+ "real:feishu:e2e": "tsx scripts/real-feishu-e2e.ts",
41
+ "run": "node dist/cli.mjs run",
42
+ "test": "node scripts/run-tests.js",
43
+ "pack:check": "node scripts/check-npm-pack.js",
44
+ "prepublishOnly": "npm run typecheck && npm test && npm run docs:build && npm run build && npm run pack:check"
45
+ },
46
+ "dependencies": {
47
+ "@anthropic-ai/claude-agent-sdk": "^0.3.160",
48
+ "@clack/prompts": "^1.5.1",
49
+ "@homebridge/node-pty-prebuilt-multiarch": "^0.13.1",
50
+ "@larksuite/cli": "^1.0.45",
51
+ "@larksuiteoapi/node-sdk": "^1.66.1",
52
+ "@openai/codex-sdk": "^0.130.0",
53
+ "https-proxy-agent": "^9.0.0",
54
+ "markdown-it": "^14.1.1",
55
+ "pino": "^10.3.1",
56
+ "qrcode": "^1.5.4",
57
+ "ws": "^8.18.0"
58
+ },
59
+ "devDependencies": {
60
+ "@types/markdown-it": "^14.1.2",
61
+ "@types/node": "^24.12.4",
62
+ "@types/ws": "^8.5.0",
63
+ "esbuild": "^0.25.0",
64
+ "mermaid": "^11.15.0",
65
+ "tsx": "^4.21.0",
66
+ "typescript": "^5",
67
+ "vite": "^5.4.21",
68
+ "vitepress": "^1.6.4"
69
+ },
70
+ "engines": {
71
+ "node": ">=24"
72
+ }
73
+ }
@@ -0,0 +1,259 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://codelark.local/schemas/config.v1.schema.json",
4
+ "title": "CodeLark config.json",
5
+ "description": "Structured runtime and channel configuration stored at ~/.codelark/config.json.",
6
+ "type": "object",
7
+ "required": ["schemaVersion", "runtime", "channels"],
8
+ "properties": {
9
+ "schemaVersion": {
10
+ "const": 1
11
+ },
12
+ "runtime": {
13
+ "$ref": "#/$defs/runtime"
14
+ },
15
+ "channels": {
16
+ "type": "array",
17
+ "items": {
18
+ "$ref": "#/$defs/channelInstance"
19
+ }
20
+ }
21
+ },
22
+ "allOf": [
23
+ {
24
+ "$ref": "#/$defs/noRetiredThreadIdentityFields"
25
+ }
26
+ ],
27
+ "additionalProperties": true,
28
+ "$defs": {
29
+ "runtime": {
30
+ "type": "object",
31
+ "required": ["provider"],
32
+ "properties": {
33
+ "provider": {
34
+ "const": "codex"
35
+ },
36
+ "codex": {
37
+ "$ref": "#/$defs/codexRuntimeDefaults"
38
+ },
39
+ "claude": {
40
+ "$ref": "#/$defs/claudeRuntimeDefaults"
41
+ },
42
+ "bridgeControl": {
43
+ "$ref": "#/$defs/bridgeControlConfig"
44
+ },
45
+ "bridge": {
46
+ "$ref": "#/$defs/globalBridgeConfig"
47
+ }
48
+ },
49
+ "allOf": [
50
+ {
51
+ "$ref": "#/$defs/noRetiredThreadIdentityFields"
52
+ }
53
+ ],
54
+ "additionalProperties": true
55
+ },
56
+ "codexRuntimeDefaults": {
57
+ "type": "object",
58
+ "properties": {
59
+ "defaultModel": {
60
+ "type": "string"
61
+ },
62
+ "defaultMode": {
63
+ "enum": ["normal", "yolo"]
64
+ },
65
+ "skipGitRepoCheck": {
66
+ "type": "boolean"
67
+ },
68
+ "sandboxMode": {
69
+ "enum": ["read-only", "workspace-write", "danger-full-access"]
70
+ },
71
+ "networkAccess": {
72
+ "type": "boolean"
73
+ },
74
+ "reasoningEffort": {
75
+ "enum": ["minimal", "low", "medium", "high", "xhigh"]
76
+ }
77
+ },
78
+ "allOf": [
79
+ {
80
+ "$ref": "#/$defs/noRetiredThreadIdentityFields"
81
+ }
82
+ ],
83
+ "additionalProperties": true
84
+ },
85
+ "claudeRuntimeDefaults": {
86
+ "type": "object",
87
+ "properties": {
88
+ "provider": {
89
+ "enum": ["pty", "sdk"]
90
+ },
91
+ "executable": {
92
+ "enum": ["claude", "ccr"]
93
+ },
94
+ "defaultModel": {
95
+ "type": "string"
96
+ },
97
+ "permissionMode": {
98
+ "enum": ["default", "acceptEdits", "bypassPermissions", "plan"]
99
+ },
100
+ "idleTimeoutMinutes": {
101
+ "type": "integer",
102
+ "minimum": 0
103
+ }
104
+ },
105
+ "allOf": [
106
+ {
107
+ "$ref": "#/$defs/noRetiredThreadIdentityFields"
108
+ }
109
+ ],
110
+ "additionalProperties": true
111
+ },
112
+ "bridgeControlConfig": {
113
+ "type": "object",
114
+ "properties": {
115
+ "defaultCodexProvider": {
116
+ "enum": ["sdk", "pty", "tmux"]
117
+ }
118
+ },
119
+ "allOf": [
120
+ {
121
+ "$ref": "#/$defs/noRetiredThreadIdentityFields"
122
+ }
123
+ ],
124
+ "additionalProperties": true
125
+ },
126
+ "globalBridgeConfig": {
127
+ "type": "object",
128
+ "properties": {
129
+ "defaultWorkspaceRoot": {
130
+ "type": "string"
131
+ },
132
+ "historyMessageLimit": {
133
+ "type": "integer",
134
+ "minimum": 1
135
+ },
136
+ "streamStatusIdleStartSeconds": {
137
+ "type": "integer",
138
+ "minimum": 1
139
+ },
140
+ "streamStatusCheckIntervalSeconds": {
141
+ "type": "integer",
142
+ "minimum": 1
143
+ },
144
+ "uiAllowLan": {
145
+ "type": "boolean"
146
+ },
147
+ "uiAccessToken": {
148
+ "type": "string"
149
+ }
150
+ },
151
+ "allOf": [
152
+ {
153
+ "$ref": "#/$defs/noRetiredThreadIdentityFields"
154
+ }
155
+ ],
156
+ "additionalProperties": true
157
+ },
158
+ "channelInstance": {
159
+ "type": "object",
160
+ "required": ["id", "alias", "provider", "enabled", "createdAt", "updatedAt", "config"],
161
+ "properties": {
162
+ "id": {
163
+ "type": "string",
164
+ "minLength": 1
165
+ },
166
+ "alias": {
167
+ "type": "string",
168
+ "minLength": 1
169
+ },
170
+ "provider": {
171
+ "enum": ["feishu"]
172
+ },
173
+ "enabled": {
174
+ "type": "boolean"
175
+ },
176
+ "createdAt": {
177
+ "type": "string"
178
+ },
179
+ "updatedAt": {
180
+ "type": "string"
181
+ },
182
+ "config": {
183
+ "$ref": "#/$defs/feishuChannelConfig"
184
+ }
185
+ },
186
+ "allOf": [
187
+ {
188
+ "$ref": "#/$defs/noRetiredThreadIdentityFields"
189
+ }
190
+ ],
191
+ "additionalProperties": true
192
+ },
193
+ "feishuChannelConfig": {
194
+ "type": "object",
195
+ "properties": {
196
+ "appId": {
197
+ "type": "string"
198
+ },
199
+ "appSecret": {
200
+ "type": "string"
201
+ },
202
+ "site": {
203
+ "enum": ["feishu", "lark"]
204
+ },
205
+ "allowedUsers": {
206
+ "type": "array",
207
+ "items": {
208
+ "type": "string"
209
+ }
210
+ },
211
+ "streamingEnabled": {
212
+ "type": "boolean"
213
+ },
214
+ "feedbackMarkdownEnabled": {
215
+ "type": "boolean"
216
+ },
217
+ "requireMention": {
218
+ "type": "boolean"
219
+ }
220
+ },
221
+ "allOf": [
222
+ {
223
+ "$ref": "#/$defs/noRetiredThreadIdentityFields"
224
+ }
225
+ ],
226
+ "additionalProperties": true
227
+ },
228
+ "noRetiredThreadIdentityFields": {
229
+ "not": {
230
+ "anyOf": [
231
+ {
232
+ "required": ["sdk_session_id"]
233
+ },
234
+ {
235
+ "required": ["sdkSessionId"]
236
+ },
237
+ {
238
+ "required": ["desktop_thread_id"]
239
+ },
240
+ {
241
+ "required": ["desktopThreadId"]
242
+ },
243
+ {
244
+ "required": ["thread_origin"]
245
+ },
246
+ {
247
+ "required": ["threadOrigin"]
248
+ },
249
+ {
250
+ "required": ["thread_id"]
251
+ },
252
+ {
253
+ "required": ["threadId"]
254
+ }
255
+ ]
256
+ }
257
+ }
258
+ }
259
+ }
@@ -0,0 +1,44 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://codelark.local/schemas/data/audit.v1.schema.json",
4
+ "title": "CodeLark audit log entry array",
5
+ "description": "Audit log entry shape. Current runtime appends entries to data/audit.jsonl and still reads legacy data/audit.json arrays.",
6
+ "type": "array",
7
+ "items": {
8
+ "type": "object",
9
+ "required": ["id", "createdAt", "channelType", "chatId", "direction", "messageId", "summary"],
10
+ "properties": {
11
+ "id": {
12
+ "type": "string",
13
+ "minLength": 1
14
+ },
15
+ "createdAt": {
16
+ "type": "string"
17
+ },
18
+ "channelType": {
19
+ "type": "string",
20
+ "minLength": 1
21
+ },
22
+ "channelProvider": {
23
+ "type": "string"
24
+ },
25
+ "channelAlias": {
26
+ "type": "string"
27
+ },
28
+ "chatId": {
29
+ "type": "string",
30
+ "minLength": 1
31
+ },
32
+ "direction": {
33
+ "enum": ["inbound", "outbound"]
34
+ },
35
+ "messageId": {
36
+ "type": "string"
37
+ },
38
+ "summary": {
39
+ "type": "string"
40
+ }
41
+ },
42
+ "additionalProperties": true
43
+ }
44
+ }
@@ -0,0 +1,94 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://codelark.local/schemas/data/auto-tasks.v1.schema.json",
4
+ "title": "CodeLark data/auto-tasks.json",
5
+ "description": "Map of auto task id to /auto automation task records.",
6
+ "type": "object",
7
+ "additionalProperties": {
8
+ "$ref": "#/$defs/autoTask"
9
+ },
10
+ "$defs": {
11
+ "autoTask": {
12
+ "type": "object",
13
+ "required": [
14
+ "id",
15
+ "bridgeSessionId",
16
+ "channelType",
17
+ "chatId",
18
+ "createdAt",
19
+ "updatedAt",
20
+ "triggeredCount",
21
+ "times",
22
+ "status"
23
+ ],
24
+ "properties": {
25
+ "id": {
26
+ "type": "string",
27
+ "minLength": 1
28
+ },
29
+ "kind": {
30
+ "enum": ["script", "interval"]
31
+ },
32
+ "bridgeSessionId": {
33
+ "type": "string",
34
+ "minLength": 1
35
+ },
36
+ "channelType": {
37
+ "type": "string",
38
+ "minLength": 1
39
+ },
40
+ "channelProvider": {
41
+ "type": "string"
42
+ },
43
+ "channelAlias": {
44
+ "type": "string"
45
+ },
46
+ "chatId": {
47
+ "type": "string",
48
+ "minLength": 1
49
+ },
50
+ "chatUserId": {
51
+ "type": "string"
52
+ },
53
+ "chatDisplayName": {
54
+ "type": "string"
55
+ },
56
+ "scriptPath": {
57
+ "type": "string",
58
+ "minLength": 0
59
+ },
60
+ "prompt": {
61
+ "type": "string"
62
+ },
63
+ "intervalSeconds": {
64
+ "type": "integer",
65
+ "minimum": 1
66
+ },
67
+ "createdAt": {
68
+ "type": "string"
69
+ },
70
+ "updatedAt": {
71
+ "type": "string"
72
+ },
73
+ "triggeredCount": {
74
+ "type": "integer",
75
+ "minimum": 0
76
+ },
77
+ "lastTriggeredAt": {
78
+ "type": "string"
79
+ },
80
+ "times": {
81
+ "type": "integer",
82
+ "minimum": 0
83
+ },
84
+ "status": {
85
+ "enum": ["running", "completed", "failed"]
86
+ },
87
+ "lastError": {
88
+ "type": "string"
89
+ }
90
+ },
91
+ "additionalProperties": true
92
+ }
93
+ }
94
+ }
@@ -0,0 +1,159 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://codelark.local/schemas/data/channel-chats.v1.schema.json",
4
+ "title": "CodeLark data/channel-chats.json",
5
+ "description": "Map of channel chat binding id to one ChannelChat record. Each channel/chat pair has at most one record.",
6
+ "type": "object",
7
+ "additionalProperties": {
8
+ "$ref": "#/$defs/channelChat"
9
+ },
10
+ "$defs": {
11
+ "channelChat": {
12
+ "type": "object",
13
+ "required": [
14
+ "id",
15
+ "channelType",
16
+ "chatId",
17
+ "bridgeSessionId",
18
+ "createdAt",
19
+ "updatedAt"
20
+ ],
21
+ "properties": {
22
+ "id": {
23
+ "type": "string",
24
+ "minLength": 1
25
+ },
26
+ "channelType": {
27
+ "type": "string",
28
+ "minLength": 1
29
+ },
30
+ "channelProvider": {
31
+ "type": "string"
32
+ },
33
+ "channelAlias": {
34
+ "type": "string"
35
+ },
36
+ "chatId": {
37
+ "type": "string",
38
+ "minLength": 1
39
+ },
40
+ "chatKind": {
41
+ "enum": ["p2p", "group"]
42
+ },
43
+ "chatUserId": {
44
+ "type": "string"
45
+ },
46
+ "bridgeSessionId": {
47
+ "type": "string",
48
+ "minLength": 1
49
+ },
50
+ "runtimeBridgeSessionIds": {
51
+ "type": "object",
52
+ "properties": {
53
+ "codex": {
54
+ "type": "string",
55
+ "minLength": 1
56
+ },
57
+ "claude": {
58
+ "type": "string",
59
+ "minLength": 1
60
+ }
61
+ },
62
+ "additionalProperties": false
63
+ },
64
+ "cloudDocumentChat": {
65
+ "type": "object",
66
+ "required": ["provider", "fileToken", "fileType"],
67
+ "properties": {
68
+ "provider": {
69
+ "const": "feishu"
70
+ },
71
+ "fileToken": {
72
+ "type": "string",
73
+ "minLength": 1
74
+ },
75
+ "fileType": {
76
+ "enum": ["doc", "docx", "sheet", "file"]
77
+ }
78
+ },
79
+ "additionalProperties": false
80
+ },
81
+ "createdAt": {
82
+ "type": "string"
83
+ },
84
+ "updatedAt": {
85
+ "type": "string"
86
+ },
87
+ "lastActivityAt": {
88
+ "type": "string"
89
+ }
90
+ },
91
+ "allOf": [
92
+ {
93
+ "$ref": "#/$defs/noLegacyBindingRuntimeFields"
94
+ }
95
+ ],
96
+ "additionalProperties": false
97
+ },
98
+ "noLegacyBindingRuntimeFields": {
99
+ "not": {
100
+ "anyOf": [
101
+ {
102
+ "required": ["active"]
103
+ },
104
+ {
105
+ "required": ["chatDisplayName"]
106
+ },
107
+ {
108
+ "required": ["workingDirectory"]
109
+ },
110
+ {
111
+ "required": ["model"]
112
+ },
113
+ {
114
+ "required": ["mode"]
115
+ },
116
+ {
117
+ "required": ["codex_thread_id"]
118
+ },
119
+ {
120
+ "required": ["codexThreadId"]
121
+ },
122
+ {
123
+ "required": ["sdk_session_id"]
124
+ },
125
+ {
126
+ "required": ["sdkSessionId"]
127
+ },
128
+ {
129
+ "required": ["desktop_thread_id"]
130
+ },
131
+ {
132
+ "required": ["desktopThreadId"]
133
+ },
134
+ {
135
+ "required": ["thread_origin"]
136
+ },
137
+ {
138
+ "required": ["threadOrigin"]
139
+ },
140
+ {
141
+ "required": ["thread_id"]
142
+ },
143
+ {
144
+ "required": ["threadId"]
145
+ },
146
+ {
147
+ "required": ["codepilotSessionId"]
148
+ },
149
+ {
150
+ "required": ["codepilot_session_id"]
151
+ },
152
+ {
153
+ "required": ["bridge_session_id"]
154
+ }
155
+ ]
156
+ }
157
+ }
158
+ }
159
+ }
@@ -0,0 +1,43 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://codelark.local/schemas/data/channel-default-targets.v1.schema.json",
4
+ "title": "CodeLark data/channel-default-targets.json",
5
+ "description": "Map of channel instance id to one-shot default bridge session records.",
6
+ "type": "object",
7
+ "additionalProperties": {
8
+ "$ref": "#/$defs/channelDefaultTarget"
9
+ },
10
+ "$defs": {
11
+ "channelDefaultTarget": {
12
+ "type": "object",
13
+ "required": ["id", "channelType", "bridgeSessionId", "createdAt", "updatedAt"],
14
+ "properties": {
15
+ "id": {
16
+ "type": "string",
17
+ "minLength": 1
18
+ },
19
+ "channelType": {
20
+ "type": "string",
21
+ "minLength": 1
22
+ },
23
+ "channelProvider": {
24
+ "type": "string"
25
+ },
26
+ "channelAlias": {
27
+ "type": "string"
28
+ },
29
+ "bridgeSessionId": {
30
+ "type": "string",
31
+ "minLength": 1
32
+ },
33
+ "createdAt": {
34
+ "type": "string"
35
+ },
36
+ "updatedAt": {
37
+ "type": "string"
38
+ }
39
+ },
40
+ "additionalProperties": false
41
+ }
42
+ }
43
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://codelark.local/schemas/data/messages.v1.schema.json",
4
+ "title": "CodeLark data/messages/*.json",
5
+ "description": "Per-session bridge message history arrays.",
6
+ "type": "array",
7
+ "items": {
8
+ "type": "object",
9
+ "required": ["role", "content"],
10
+ "properties": {
11
+ "role": {
12
+ "type": "string"
13
+ },
14
+ "content": {
15
+ "type": "string"
16
+ },
17
+ "timestamp": {
18
+ "type": "string"
19
+ }
20
+ },
21
+ "additionalProperties": true
22
+ }
23
+ }