@vibe-lark/larkpal 0.1.27 → 0.1.28
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/README.md +333 -0
- package/package.json +4 -1
- package/dist/cli.mjs +0 -85
- package/dist/interactive-init-dZe9f9Ne.mjs +0 -292
- package/dist/lark-cli-provider-CR0eLl0q.mjs +0 -551
- package/dist/lark-logger-D7_pEVQc.mjs +0 -143
- package/dist/main.mjs +0 -13216
- package/dist/rolldown-runtime-wcPFST8Q.mjs +0 -13
- package/dist/tool-registry-consumer-DrklfqGF.mjs +0 -286
package/README.md
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
# LarkPal 外部接入规范
|
|
2
|
+
|
|
3
|
+
本文档描述外部业务方接入 LarkPal 平台时需遵循的协议和配置规范。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 目录
|
|
8
|
+
|
|
9
|
+
1. [环境变量配置](#环境变量配置)
|
|
10
|
+
2. [Agent Completion API(作为 AI 能力消费方)](#agent-completion-api)
|
|
11
|
+
3. [Chat 流式对话 API(多端 Agent Chat)](#chat-流式对话-api)
|
|
12
|
+
4. [RuntimeAdapter 接口(自定义 AI 引擎)](#runtimeadapter-接口)
|
|
13
|
+
5. [MCP 扩展配置(仅 CC 模式)](#mcp-扩展配置)
|
|
14
|
+
6. [网关路由总览](#网关路由总览)
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 环境变量配置
|
|
19
|
+
|
|
20
|
+
### 必填
|
|
21
|
+
|
|
22
|
+
| 变量名 | 用途 | 示例 |
|
|
23
|
+
|--------|------|------|
|
|
24
|
+
| `LARK_APP_ID` | 飞书应用 App ID | `cli_xxx` |
|
|
25
|
+
| `LARK_APP_SECRET` | 飞书应用 App Secret | - |
|
|
26
|
+
| `ANTHROPIC_API_KEY` | Anthropic API Key(CC Runtime 需要) | `sk-ant-xxx` |
|
|
27
|
+
|
|
28
|
+
### 可选
|
|
29
|
+
|
|
30
|
+
| 变量名 | 用途 | 默认值 |
|
|
31
|
+
|--------|------|--------|
|
|
32
|
+
| `LARKPAL_RUNTIME` | 切换 RuntimeAdapter 实现 | `claude-code` |
|
|
33
|
+
| `CLAUDE_MODEL` | 指定 LLM 模型名 | CC 默认模型 |
|
|
34
|
+
| `LARKPAL_WORKSPACE` | 工作目录根路径 | `~/.larkpal/workspace` |
|
|
35
|
+
| `LARKPAL_GATEWAY_HOST` | 网关监听地址 | `localhost` |
|
|
36
|
+
| `LARKPAL_EXTERNAL_URL` | 外部可访问的网关 URL | - |
|
|
37
|
+
| `LARKPAL_PUBLIC_URL` | OAuth 回调公开 URL | `http://localhost:3000` |
|
|
38
|
+
| `LARKPAL_API_SECRET` | Agent Completion API 鉴权密钥 | `dev-internal-secret` |
|
|
39
|
+
| `LARKPAL_COMPLETION_CWD` | Agent Completion 工作目录 | `/tmp/larkpal-completion` |
|
|
40
|
+
| `LARKPAL_CC_IDLE_TIMEOUT` | CC 进程空闲超时(秒) | `0`(永不超时) |
|
|
41
|
+
| `LARKPAL_ENCRYPTION_KEY` | 用户凭证加密密钥(32字节 hex) | 未设置(明文,仅限开发) |
|
|
42
|
+
| `LARKPAL_PLUGINS` | 声明式加载的插件列表 | 空 |
|
|
43
|
+
| `LARKPAL_CHAT_JWT_SECRET` | Chat API JWT 签名密钥 | fallback 到 `LARKPAL_API_SECRET` |
|
|
44
|
+
|
|
45
|
+
### larkpal-agent Runtime 专用(LARKPAL_RUNTIME=larkpal-agent 时必填)
|
|
46
|
+
|
|
47
|
+
| 变量名 | 用途 | 示例 |
|
|
48
|
+
|--------|------|------|
|
|
49
|
+
| `LARKPAL_AGENT_LLM_BASE_URL` | 火山方舟 LLM 端点 | `https://ark.cn-beijing.volces.com/api/v3` |
|
|
50
|
+
| `LARKPAL_AGENT_LLM_API_KEY` | 火山方舟 API Key | - |
|
|
51
|
+
| `LARKPAL_AGENT_LLM_MODEL` | 模型 endpoint ID | `ep-20250327140538-xxxxx` |
|
|
52
|
+
| `LARKPAL_AGENT_MAX_TURNS` | Agent 最大对话轮数(可选) | `25` |
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Agent Completion API
|
|
57
|
+
|
|
58
|
+
外部业务方作为 AI 能力消费方,调用 LarkPal 的通用 AI 补全接口。
|
|
59
|
+
|
|
60
|
+
### 请求
|
|
61
|
+
|
|
62
|
+
```http
|
|
63
|
+
POST /api/agent/completion
|
|
64
|
+
Content-Type: application/json
|
|
65
|
+
X-Internal-Secret: {LARKPAL_API_SECRET}
|
|
66
|
+
X-Callback-Url: https://your-server/callback (可选,有则为异步模式)
|
|
67
|
+
|
|
68
|
+
{
|
|
69
|
+
"taskId": "your-unique-task-id",
|
|
70
|
+
"task": "extract", // 可选,仅日志用
|
|
71
|
+
"prompt": "请分析以下文档...",
|
|
72
|
+
"files": [ // 可选,附件
|
|
73
|
+
{ "name": "doc.txt", "contentBase64": "..." }
|
|
74
|
+
],
|
|
75
|
+
"options": {
|
|
76
|
+
"maxTurns": 10, // 可选
|
|
77
|
+
"resultFileName": "output.json" // 可选,优先读取 CC 写入的此文件
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 同步模式响应
|
|
83
|
+
|
|
84
|
+
无 `X-Callback-Url` 时,等待执行完成后返回:
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
{ "code": 0, "mode": "sync", "result": "分析结果..." }
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 异步模式
|
|
91
|
+
|
|
92
|
+
有 `X-Callback-Url` 时,立即返回:
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{ "code": 0, "mode": "async", "message": "accepted" }
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
完成后 POST 回调到你的 URL:
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{ "taskId": "xxx", "status": "success", "result": "..." }
|
|
102
|
+
// 或
|
|
103
|
+
{ "taskId": "xxx", "status": "failed", "error": "timeout" }
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Chat 流式对话 API
|
|
109
|
+
|
|
110
|
+
为外部客户端(Web、移动端、桌面端等)提供流式 Agent Chat 能力,支持多会话管理和多端消息同步。
|
|
111
|
+
|
|
112
|
+
### 鉴权流程
|
|
113
|
+
|
|
114
|
+
1. 客户端通过飞书 OAuth 获取用户身份
|
|
115
|
+
2. 调用 LarkPal 签发 JWT:
|
|
116
|
+
|
|
117
|
+
```http
|
|
118
|
+
POST /api/chat/auth
|
|
119
|
+
X-Internal-Secret: {LARKPAL_API_SECRET}
|
|
120
|
+
Content-Type: application/json
|
|
121
|
+
|
|
122
|
+
{ "tenantKey": "xxx", "userId": "user_xxx", "openId": "ou_xxx" }
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
响应:
|
|
126
|
+
```json
|
|
127
|
+
{ "token": "eyJ...", "expiresAt": 1234567890 }
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
3. 后续所有 Chat API 请求携带:`Authorization: Bearer {token}`
|
|
131
|
+
|
|
132
|
+
### 会话管理
|
|
133
|
+
|
|
134
|
+
**列出会话**
|
|
135
|
+
```http
|
|
136
|
+
GET /api/chat/sessions
|
|
137
|
+
Authorization: Bearer {token}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**创建会话**
|
|
141
|
+
```http
|
|
142
|
+
POST /api/chat/sessions
|
|
143
|
+
Authorization: Bearer {token}
|
|
144
|
+
Content-Type: application/json
|
|
145
|
+
|
|
146
|
+
{ "title": "知识库诊断" }
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**删除会话**
|
|
150
|
+
```http
|
|
151
|
+
DELETE /api/chat/sessions/{sessionId}
|
|
152
|
+
Authorization: Bearer {token}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### 流式对话(SSE)
|
|
156
|
+
|
|
157
|
+
```http
|
|
158
|
+
POST /api/chat/stream
|
|
159
|
+
Authorization: Bearer {token}
|
|
160
|
+
Content-Type: application/json
|
|
161
|
+
Accept: text/event-stream
|
|
162
|
+
|
|
163
|
+
{
|
|
164
|
+
"session_id": "可选,不传则自动创建",
|
|
165
|
+
"prompt": "帮我诊断知识库质量",
|
|
166
|
+
"options": { "maxTurns": 10 }
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**SSE 事件流**:
|
|
171
|
+
|
|
172
|
+
| 事件 | 说明 | data 示例 |
|
|
173
|
+
|------|------|-----------|
|
|
174
|
+
| `text-delta` | AI 回复文本增量 | `{"text": "好的"}` |
|
|
175
|
+
| `thinking-delta` | AI 思考过程增量 | `{"text": "我需要先..."}` |
|
|
176
|
+
| `tool-use-start` | 开始调用工具 | `{"toolName": "list-spaces", "input": {...}}` |
|
|
177
|
+
| `tool-result` | 工具调用结果 | `{"toolUseId": "xxx"}` |
|
|
178
|
+
| `tool-progress` | 工具执行进度 | `{"toolName": "xxx", "elapsedSeconds": 5}` |
|
|
179
|
+
| `turn-end` | 单轮结束 | `{"stopReason": "end_turn"}` |
|
|
180
|
+
| `done` | 对话完成 | `{"sessionId": "xxx", "durationMs": 3200}` |
|
|
181
|
+
| `error` | 错误 | `{"message": "..."}` |
|
|
182
|
+
|
|
183
|
+
### 历史消息
|
|
184
|
+
|
|
185
|
+
```http
|
|
186
|
+
GET /api/chat/history?session_id={id}&cursor={msgId}&limit=50
|
|
187
|
+
Authorization: Bearer {token}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
返回该会话的完整消息历史(含飞书端和客户端两侧的消息)。
|
|
191
|
+
|
|
192
|
+
### 多端同步说明
|
|
193
|
+
|
|
194
|
+
- 消息 `channel` 字段标识来源通道:如 `'feishu-bot'`(飞书机器人端)、`'web'`(Web 客户端)、`'mobile'`(移动端)等
|
|
195
|
+
- 客户端始终能看到完整对话(含飞书端触发的消息)
|
|
196
|
+
- 飞书端仅显示飞书端的消息(受限于飞书 API,无法向 bot 会话注入外部消息)
|
|
197
|
+
- 用户通过 `openId` 关联,同一用户在不同端共享会话列表
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## RuntimeAdapter 接口
|
|
202
|
+
|
|
203
|
+
自定义 AI 引擎需实现以下接口:
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
interface RuntimeAdapter {
|
|
207
|
+
readonly name: string;
|
|
208
|
+
|
|
209
|
+
// 执行 prompt,通过 callbacks 流式返回结果
|
|
210
|
+
executePrompt(config: RuntimeStartConfig, callbacks: RuntimeStreamCallbacks): Promise<void>;
|
|
211
|
+
|
|
212
|
+
// 停止指定会话
|
|
213
|
+
stopProcess(sessionId: string): Promise<void>;
|
|
214
|
+
|
|
215
|
+
// 停止所有会话
|
|
216
|
+
stopAll(): Promise<void>;
|
|
217
|
+
|
|
218
|
+
// 查询会话进程信息
|
|
219
|
+
getProcessInfo(sessionId: string): RuntimeProcessInfo | undefined;
|
|
220
|
+
getAllProcessInfo(): RuntimeProcessInfo[];
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### RuntimeStartConfig
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
interface RuntimeStartConfig {
|
|
228
|
+
sessionId: string;
|
|
229
|
+
cwd: string;
|
|
230
|
+
prompt: string | CCContentBlock[];
|
|
231
|
+
maxTurns?: number;
|
|
232
|
+
maxBudgetUsd?: number;
|
|
233
|
+
model?: string;
|
|
234
|
+
userContext?: UserContext;
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### RuntimeStreamCallbacks
|
|
239
|
+
|
|
240
|
+
```typescript
|
|
241
|
+
interface RuntimeStreamCallbacks {
|
|
242
|
+
onTextDelta?: (text: string) => void;
|
|
243
|
+
onThinkingDelta?: (text: string) => void;
|
|
244
|
+
onToolUseStart?: (toolName: string, toolInput: unknown) => void;
|
|
245
|
+
onToolResult?: (toolUseId: string) => void;
|
|
246
|
+
onToolProgress?: (toolName: string, elapsedSeconds: number) => void;
|
|
247
|
+
onTurnEnd?: (stopReason: string) => void;
|
|
248
|
+
onResult?: (result: RuntimeResultMessage) => void;
|
|
249
|
+
onError?: (error: Error) => void;
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### 切换 Runtime
|
|
254
|
+
|
|
255
|
+
通过环境变量切换:
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
LARKPAL_RUNTIME=claude-code # 默认,使用 Claude Code 子进程
|
|
259
|
+
LARKPAL_RUNTIME=larkpal-agent # 使用 larkpal-agent 引擎(火山方舟 LLM)
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
使用 `larkpal-agent` 时的完整配置示例:
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
LARKPAL_RUNTIME=larkpal-agent
|
|
266
|
+
LARKPAL_AGENT_LLM_BASE_URL=https://ark.cn-beijing.volces.com/api/v3
|
|
267
|
+
LARKPAL_AGENT_LLM_API_KEY=your-api-key
|
|
268
|
+
LARKPAL_AGENT_LLM_MODEL=ep-20250327140538-xxxxx
|
|
269
|
+
LARKPAL_AGENT_MAX_TURNS=25
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
**工具发现**:由 larkpal-agent 自身的 MCP Client 负责。larkpal-agent 启动时自动连接配置的 MCP Server,发现并注册外部工具。larkpal 平台层不涉及工具层。
|
|
273
|
+
|
|
274
|
+
**systemPrompt 来源**:读取 `~/.claude/CLAUDE.md` 文件内容。可通过修改此文件自定义 Agent 人设。
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## MCP 扩展配置(仅 CC 模式)
|
|
279
|
+
|
|
280
|
+
LarkPal 在 CC 模式下作为 MCP Client 代理层,支持双层 MCP Server 配置合并。larkpal-agent 模式下工具发现由 Agent 自身 MCP Client 负责。
|
|
281
|
+
|
|
282
|
+
| 层级 | 路径 | 说明 |
|
|
283
|
+
|------|------|------|
|
|
284
|
+
| 全局 | `~/.claude/mcp-servers.json` | 所有用户共享的 MCP Server |
|
|
285
|
+
| 用户私有 | `{workspace}/users/{userId}/mcp-servers.json` | 用户自定义(优先级更高) |
|
|
286
|
+
|
|
287
|
+
配置格式:
|
|
288
|
+
|
|
289
|
+
```json
|
|
290
|
+
{
|
|
291
|
+
"mcpServers": {
|
|
292
|
+
"my-server": {
|
|
293
|
+
"command": "npx",
|
|
294
|
+
"args": ["-y", "my-mcp-server"],
|
|
295
|
+
"env": { "API_KEY": "xxx" }
|
|
296
|
+
},
|
|
297
|
+
"remote-server": {
|
|
298
|
+
"url": "http://localhost:8080/mcp/sse"
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
合并规则:用户配置同名 key 覆盖全局配置。
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## 网关路由总览
|
|
309
|
+
|
|
310
|
+
| 路由 | 方法 | 功能 |
|
|
311
|
+
|------|------|------|
|
|
312
|
+
| `/api/agent/completion` | POST | 通用 AI 补全(外部主接入点) |
|
|
313
|
+
| `/api/chat/auth` | POST | 签发 Chat JWT |
|
|
314
|
+
| `/api/chat/stream` | POST | SSE 流式对话 |
|
|
315
|
+
| `/api/chat/sessions` | GET/POST | 会话列表 / 创建会话 |
|
|
316
|
+
| `/api/chat/sessions/:id` | DELETE | 删除会话 |
|
|
317
|
+
| `/api/chat/history` | GET | 会话历史消息 |
|
|
318
|
+
| `/api/execute` | POST | 单次执行(飞书会话绑定) |
|
|
319
|
+
| `/api/execute/batch` | POST | 批量执行 |
|
|
320
|
+
| `/api/execute/:taskId` | GET | 查询任务状态 |
|
|
321
|
+
| `/api/execute/:taskId/cancel` | POST | 取消任务 |
|
|
322
|
+
| `/api/skills/*` | - | 技能管理 |
|
|
323
|
+
| `/api/scheduled-tasks` | - | 定时任务 CRUD |
|
|
324
|
+
| `/hooks/*` | POST | 飞书事件 Hook 接收 |
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## 安全注意事项
|
|
329
|
+
|
|
330
|
+
1. `LARK_APP_SECRET` 启动后从 `process.env` 中删除,防止子进程继承
|
|
331
|
+
2. `ANTHROPIC_API_KEY` 保留(CC 子进程需要),但通过 `settings.json` deny 规则禁止 CC 通过 shell 读取
|
|
332
|
+
3. `LARKPAL_API_SECRET` 用于 Agent Completion API 鉴权,生产环境务必设置强密钥
|
|
333
|
+
4. 用户凭证加密需设置 `LARKPAL_ENCRYPTION_KEY`(32 字节 hex/base64),否则明文存储
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibe-lark/larkpal",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.28",
|
|
4
4
|
"description": "LarkPal - Lark/Feishu bot service",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/main.mjs",
|
|
@@ -45,6 +45,9 @@
|
|
|
45
45
|
"uuid": "^11.1.0",
|
|
46
46
|
"zod": "^4.3.6"
|
|
47
47
|
},
|
|
48
|
+
"optionalDependencies": {
|
|
49
|
+
"@vibe-lark/larkpal-agent": "^0.1.0"
|
|
50
|
+
},
|
|
48
51
|
"devDependencies": {
|
|
49
52
|
"@eslint/js": "^10.0.1",
|
|
50
53
|
"@types/express": "^5.0.2",
|
package/dist/cli.mjs
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
import { dirname, join } from "node:path";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
//#region src/cli.ts
|
|
5
|
-
/**
|
|
6
|
-
* LarkPal CLI 入口 — 子命令路由
|
|
7
|
-
*
|
|
8
|
-
* 用法:
|
|
9
|
-
* larkpal 启动服务(凭证未配置时自动进入初始化流程)
|
|
10
|
-
* larkpal init 交互式初始化向导
|
|
11
|
-
* larkpal --help 显示帮助信息
|
|
12
|
-
* larkpal --version 显示版本号
|
|
13
|
-
*
|
|
14
|
-
* 不依赖 commander / yargs 等外部包,仅使用 process.argv 解析。
|
|
15
|
-
*/
|
|
16
|
-
const CYAN = "\x1B[36m";
|
|
17
|
-
const DIM = "\x1B[2m";
|
|
18
|
-
const BOLD = "\x1B[1m";
|
|
19
|
-
const YELLOW = "\x1B[33m";
|
|
20
|
-
const RESET = "\x1B[0m";
|
|
21
|
-
function getVersion() {
|
|
22
|
-
try {
|
|
23
|
-
const pkgPath = join(dirname(fileURLToPath(import.meta.url)), "..", "package.json");
|
|
24
|
-
return JSON.parse(readFileSync(pkgPath, "utf-8")).version ?? "unknown";
|
|
25
|
-
} catch {
|
|
26
|
-
return "unknown";
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function printHelp() {
|
|
30
|
-
const version = getVersion();
|
|
31
|
-
console.log(`
|
|
32
|
-
${BOLD}LarkPal${RESET} ${DIM}v${version}${RESET} — 飞书 AI Bot 服务
|
|
33
|
-
|
|
34
|
-
${BOLD}用法:${RESET}
|
|
35
|
-
larkpal 启动服务
|
|
36
|
-
larkpal init 交互式初始化向导
|
|
37
|
-
larkpal --help 显示帮助信息
|
|
38
|
-
larkpal --version 显示版本号
|
|
39
|
-
|
|
40
|
-
${BOLD}环境变量:${RESET}
|
|
41
|
-
LARK_APP_ID 飞书应用 App ID(可选,覆盖 lark-cli 配置)
|
|
42
|
-
LARK_APP_SECRET 飞书应用 App Secret(可选,覆盖 lark-cli 配置)
|
|
43
|
-
LARKPAL_WORKSPACE 工作目录根路径(默认 /workspace)
|
|
44
|
-
CLAUDE_MODEL Claude 模型名称(如 ark-code-latest)
|
|
45
|
-
|
|
46
|
-
${DIM}首次使用?运行 ${CYAN}larkpal init${DIM} 开始配置。${RESET}
|
|
47
|
-
`);
|
|
48
|
-
}
|
|
49
|
-
async function cli() {
|
|
50
|
-
const command = process.argv.slice(2)[0];
|
|
51
|
-
if (command === "--version" || command === "-v") {
|
|
52
|
-
console.log(getVersion());
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (command === "--help" || command === "-h") {
|
|
56
|
-
printHelp();
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
if (command === "init") {
|
|
60
|
-
const { runInteractiveInit } = await import("./interactive-init-dZe9f9Ne.mjs");
|
|
61
|
-
const exitCode = await runInteractiveInit();
|
|
62
|
-
process.exit(exitCode);
|
|
63
|
-
}
|
|
64
|
-
if (command && !command.startsWith("-")) {
|
|
65
|
-
console.log(`${YELLOW}未知命令: ${command}${RESET}\n`);
|
|
66
|
-
printHelp();
|
|
67
|
-
process.exit(1);
|
|
68
|
-
}
|
|
69
|
-
const { LarkCliCredentialProvider } = await import("./lark-cli-provider-CR0eLl0q.mjs").then((n) => n.n);
|
|
70
|
-
if (!LarkCliCredentialProvider.isConfigured()) {
|
|
71
|
-
console.log(`\n${YELLOW}⚠️ 飞书应用凭证未配置${RESET}\n`);
|
|
72
|
-
console.log(` LarkPal 需要飞书应用凭证才能启动。正在进入初始化向导...\n`);
|
|
73
|
-
const { runInteractiveInit } = await import("./interactive-init-dZe9f9Ne.mjs");
|
|
74
|
-
const exitCode = await runInteractiveInit();
|
|
75
|
-
if (exitCode !== 0) process.exit(exitCode);
|
|
76
|
-
console.log(`${DIM}凭证配置完成,正在启动服务...${RESET}\n`);
|
|
77
|
-
}
|
|
78
|
-
await import("./main.mjs");
|
|
79
|
-
}
|
|
80
|
-
cli().catch((err) => {
|
|
81
|
-
console.error("LarkPal CLI 启动失败:", err);
|
|
82
|
-
process.exit(1);
|
|
83
|
-
});
|
|
84
|
-
//#endregion
|
|
85
|
-
export {};
|