lark-remote 0.1.1 → 0.1.3
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.en.md +2 -5
- package/README.md +1 -4
- package/dist/bridge/index.d.ts +1 -3
- package/dist/bridge/index.js +11 -12
- package/dist/card/card-budget.js +1 -2
- package/dist/card/card-shared.d.ts +8 -0
- package/dist/card/card-shared.js +14 -0
- package/dist/card/run-renderer.js +1 -0
- package/dist/card/run-state.d.ts +4 -0
- package/dist/config/codex-config.d.ts +3 -5
- package/dist/config/codex-config.js +7 -7
- package/dist/config/dir.d.ts +1 -0
- package/dist/config/dir.js +4 -0
- package/dist/config/index.d.ts +0 -10
- package/dist/config/index.js +0 -11
- package/dist/connector/index.js +28 -0
- package/dist/index.js +89 -41
- package/dist/router/config/codex.js +8 -12
- package/dist/router/index.d.ts +15 -2
- package/dist/router/index.js +314 -44
- package/dist/router/utils.d.ts +3 -0
- package/dist/router/utils.js +15 -3
- package/dist/runner/claude/runner.d.ts +0 -1
- package/dist/runner/claude/runner.js +1 -1
- package/dist/runner/codex/runner.d.ts +0 -2
- package/dist/runner/codex/runner.js +1 -1
- package/dist/runner/common/spawning-runner.d.ts +0 -1
- package/dist/runner/common/spawning-runner.js +2 -4
- package/dist/runner/kimi/runner.d.ts +0 -1
- package/dist/runner/kimi/runner.js +1 -1
- package/dist/runner/opencode/runner.d.ts +0 -2
- package/dist/runner/opencode/runner.js +1 -1
- package/dist/runner/pi/runner.d.ts +0 -1
- package/dist/runner/pi/runner.js +1 -1
- package/dist/runner/probe.d.ts +45 -0
- package/dist/runner/probe.js +87 -0
- package/dist/runner/types.d.ts +3 -0
- package/dist/session/claude/sessions.d.ts +8 -6
- package/dist/session/claude/sessions.js +178 -26
- package/dist/session/codex/rollout-reader.d.ts +1 -0
- package/dist/session/codex/rollout-reader.js +15 -0
- package/dist/session/codex/sessions.d.ts +1 -1
- package/dist/session/codex/sessions.js +2 -1
- package/dist/session/kimi/sessions.d.ts +3 -1
- package/dist/session/kimi/sessions.js +42 -6
- package/dist/session/opencode/sessions.d.ts +0 -2
- package/dist/session/opencode/sessions.js +1 -1
- package/dist/startup-contact.d.ts +4 -2
- package/dist/startup-contact.js +7 -4
- package/package.json +39 -4
package/README.en.md
CHANGED
|
@@ -64,7 +64,6 @@ feishu:
|
|
|
64
64
|
defaultAgent: claude
|
|
65
65
|
|
|
66
66
|
claude:
|
|
67
|
-
binary: claude
|
|
68
67
|
model: claude-opus-4-8
|
|
69
68
|
effort: medium # low | medium | high | xhigh | max
|
|
70
69
|
# permissionMode is hardcoded to bypassPermissions (inside the runner)
|
|
@@ -79,7 +78,7 @@ logging:
|
|
|
79
78
|
level: info # debug | info | warn | error
|
|
80
79
|
|
|
81
80
|
idle:
|
|
82
|
-
watchdogMinutes: 15 # 0 disables the idle
|
|
81
|
+
watchdogMinutes: 15 # 0 disables the idle timeout auto-stop
|
|
83
82
|
```
|
|
84
83
|
|
|
85
84
|
Override the config directory with `--config-dir <path>`; override the Claude settings path with `--settings <path>` or the `CLAUDE_SETTINGS_PATH` environment variable.
|
|
@@ -98,8 +97,6 @@ lark-remote --settings ~/.claude/settings.json # specify Claude settings file
|
|
|
98
97
|
|
|
99
98
|
The bridge prints nothing to the terminal after startup; logs go to `~/.lark-remote/logs/YYYY-MM-DD/lark-remote-<pid>.log` (rotated daily, one subdirectory per day). Only one `lark-remote` instance is allowed per `configDir` — a duplicate start fails with the existing pid. After connecting to Feishu, a startup notification (with start time and pid) is sent to the most recent private chat.
|
|
100
99
|
|
|
101
|
-
For automatic process restart, set up your own supervisor such as systemd, launchd, or pm2.
|
|
102
|
-
|
|
103
100
|
Each agent run creates one CardKit 2.0 card that updates in place with thinking, body text, and tool summaries in real time.
|
|
104
101
|
Timestamps are read from the JSONL and shown in local time as `YYYY-MM-DD HH:mm` for thinking, body, tool call/result, and session history events.
|
|
105
102
|
The card clearly shows completion, error, interruption, or idle timeout at the end; the in-card "⏹ Stop" button is equivalent to `/stop`.
|
|
@@ -152,7 +149,7 @@ Full docs under [`docs/`](docs/):
|
|
|
152
149
|
- Single-card streaming architecture and Feishu acceptance: [`docs/en/architecture/streaming-card.md`](docs/en/architecture/streaming-card.md)
|
|
153
150
|
- Template for adding a new agent: [`docs/en/guides/add-new-agent.md`](docs/en/guides/add-new-agent.md)
|
|
154
151
|
- Codex config card guide: [`docs/en/guides/codex-config.md`](docs/en/guides/codex-config.md)
|
|
155
|
-
- Feishu CardKit 2.0 component reference: [Feishu
|
|
152
|
+
- Feishu CardKit 2.0 component reference: [Official Feishu docs](https://open.feishu.cn/document/feishu-cards/card-json-v2-components/component-json-v2-overview)
|
|
156
153
|
- AI collaboration rules and red lines: [`CLAUDE.md`](CLAUDE.md)
|
|
157
154
|
|
|
158
155
|
> This package is a CLI tool only — no programmatic API is exposed.
|
package/README.md
CHANGED
|
@@ -64,7 +64,6 @@ feishu:
|
|
|
64
64
|
defaultAgent: claude
|
|
65
65
|
|
|
66
66
|
claude:
|
|
67
|
-
binary: claude
|
|
68
67
|
model: claude-opus-4-8
|
|
69
68
|
effort: medium # low | medium | high | xhigh | max
|
|
70
69
|
# permissionMode 硬编码为 bypassPermissions(runner 内部)
|
|
@@ -79,7 +78,7 @@ logging:
|
|
|
79
78
|
level: info # debug | info | warn | error
|
|
80
79
|
|
|
81
80
|
idle:
|
|
82
|
-
watchdogMinutes: 15 # 0
|
|
81
|
+
watchdogMinutes: 15 # 0 关闭空闲超时自动停止
|
|
83
82
|
```
|
|
84
83
|
|
|
85
84
|
配置目录可用 `--config-dir <path>` 覆盖;Claude settings 路径可用 `--settings <path>` 或 `CLAUDE_SETTINGS_PATH` 环境变量覆盖。
|
|
@@ -98,8 +97,6 @@ lark-remote --settings ~/.claude/settings.json # 指定 Claude 配置文件
|
|
|
98
97
|
|
|
99
98
|
bridge 启动后不在终端输出,运行日志写入 `~/.lark-remote/logs/YYYY-MM-DD/lark-remote-<pid>.log`(按日期轮转,每天一个子目录)。同一 `configDir` 只允许一个 `lark-remote` 实例,重复启动会直接报错并提示已有 pid。连接飞书成功后会向最近私聊用户发送启动通知,包含启动时间和进程号。
|
|
100
99
|
|
|
101
|
-
如需进程自动重启,可自行配置 systemd / launchd / pm2 等守护方案。
|
|
102
|
-
|
|
103
100
|
每次 agent 运行会创建一张 CardKit 2.0 卡片,并在原地实时更新 thinking、正文和工具摘要。
|
|
104
101
|
卡片会读取 JSONL 的 `timestamp`,以本地时间 `YYYY-MM-DD HH:mm` 显示 thinking、正文、tool call/result 和会话历史事件。
|
|
105
102
|
结束时卡片明确显示完成、出错、中断或空闲超时;运行中的「⏹ 终止」按钮与 `/stop` 等价。
|
package/dist/bridge/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AgentRunner } from '../runner/index.js';
|
|
2
2
|
import type { AgentRegistry } from '../runner/registry.js';
|
|
3
3
|
import type { SessionReaderRegistry, SessionStore } from '../session/index.js';
|
|
4
4
|
import type { AppConfig } from '../config/index.js';
|
|
@@ -51,7 +51,6 @@ export interface ActiveRunSnapshot {
|
|
|
51
51
|
cacheCreationTokens?: number;
|
|
52
52
|
}
|
|
53
53
|
interface BridgeDeps {
|
|
54
|
-
runner: Runner;
|
|
55
54
|
connector: BridgeChannel;
|
|
56
55
|
sessionStore: SessionStore;
|
|
57
56
|
config: AppConfig;
|
|
@@ -93,7 +92,6 @@ interface BridgeDeps {
|
|
|
93
92
|
* Runner/BridgeChannel seams.
|
|
94
93
|
*/
|
|
95
94
|
export declare class Bridge {
|
|
96
|
-
private runner;
|
|
97
95
|
private connector;
|
|
98
96
|
private sessionStore;
|
|
99
97
|
private config;
|
package/dist/bridge/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { BashCardSession, capBashOutput } from '../card/bash-card-session.js';
|
|
|
7
7
|
import { markdownDiv } from '../card/collapsible.js';
|
|
8
8
|
import { sessionEventPanel } from '../router/card-helpers.js';
|
|
9
9
|
import { formatUsageStats } from '../router/index.js';
|
|
10
|
-
import { agentDisplayName } from '../card/card-shared.js';
|
|
10
|
+
import { agentDisplayName, resumeUseButton } from '../card/card-shared.js';
|
|
11
11
|
import { enforceCardBudget } from '../card/card-budget.js';
|
|
12
12
|
import { normalizeResultUsage } from '../runner/common/usage.js';
|
|
13
13
|
import { BashProcessRunner } from '../runner/index.js';
|
|
@@ -58,7 +58,6 @@ function terminalReactionEmoji(terminal) {
|
|
|
58
58
|
* Runner/BridgeChannel seams.
|
|
59
59
|
*/
|
|
60
60
|
export class Bridge {
|
|
61
|
-
runner;
|
|
62
61
|
connector;
|
|
63
62
|
sessionStore;
|
|
64
63
|
config;
|
|
@@ -89,7 +88,6 @@ export class Bridge {
|
|
|
89
88
|
*/
|
|
90
89
|
activeBashRuns = new Map();
|
|
91
90
|
constructor(deps) {
|
|
92
|
-
this.runner = deps.runner;
|
|
93
91
|
this.connector = deps.connector;
|
|
94
92
|
this.sessionStore = deps.sessionStore;
|
|
95
93
|
this.config = deps.config;
|
|
@@ -654,6 +652,7 @@ export class Bridge {
|
|
|
654
652
|
// Final usage read from jsonl after the run completes. live stream-json does
|
|
655
653
|
// not emit compact_boundary, so the live contextLength is unreliable.
|
|
656
654
|
let finalContextLength;
|
|
655
|
+
let finalContextLimit;
|
|
657
656
|
let finalCompactCount;
|
|
658
657
|
let finalCacheReadTokens;
|
|
659
658
|
let finalCacheCreationTokens;
|
|
@@ -827,6 +826,7 @@ export class Bridge {
|
|
|
827
826
|
? undefined
|
|
828
827
|
: this.resolveFinalUsage(finalSessionId, cwd, agentKind);
|
|
829
828
|
finalContextLength = finalUsage?.contextLength ?? contextLength;
|
|
829
|
+
finalContextLimit = finalUsage?.contextLimit;
|
|
830
830
|
finalCompactCount = finalUsage?.compactCount;
|
|
831
831
|
finalCumulativeTotalTokens = finalUsage?.cumulativeTotalTokens;
|
|
832
832
|
finalCumulativeInputTokens = finalUsage?.cumulativeInputTokens;
|
|
@@ -860,7 +860,7 @@ export class Bridge {
|
|
|
860
860
|
finalCacheCreationTokens = finalUsage?.cacheCreationTokens ?? finalCacheCreationTokens;
|
|
861
861
|
finalTotalTokens = finalUsage?.totalTokens ?? finalTotalTokens;
|
|
862
862
|
}
|
|
863
|
-
getLogger().info(`[bridge] final usage runId=${runId} contextLength=${finalContextLength} compactCount=${finalCompactCount ?? 'undefined'} cacheRead=${finalCacheReadTokens ?? 'undefined'} cacheCreate=${finalCacheCreationTokens ?? 'undefined'}`);
|
|
863
|
+
getLogger().info(`[bridge] final usage runId=${runId} contextLength=${finalContextLength} contextLimit=${finalContextLimit ?? 'undefined'} compactCount=${finalCompactCount ?? 'undefined'} cacheRead=${finalCacheReadTokens ?? 'undefined'} cacheCreate=${finalCacheCreationTokens ?? 'undefined'}`);
|
|
864
864
|
// for-await 自然结束 = stream 关闭 = CLI 进程退出。
|
|
865
865
|
// 进程退出(for-await end)= 唯一终态触发源。
|
|
866
866
|
// 1) finalizing(result 已收到)-> 转 done/error + usage meta
|
|
@@ -873,6 +873,7 @@ export class Bridge {
|
|
|
873
873
|
resultSubtype: finalState.resultSubtype,
|
|
874
874
|
errorMsg: finalState.errorMsg,
|
|
875
875
|
contextLength: finalContextLength,
|
|
876
|
+
contextLimit: finalContextLimit,
|
|
876
877
|
compactCount: finalCompactCount,
|
|
877
878
|
cacheReadTokens: finalCacheReadTokens,
|
|
878
879
|
cacheCreationTokens: finalCacheCreationTokens,
|
|
@@ -889,6 +890,7 @@ export class Bridge {
|
|
|
889
890
|
else if (finalState.terminal === 'running') {
|
|
890
891
|
await cardSession.finish('error', {
|
|
891
892
|
contextLength: finalContextLength,
|
|
893
|
+
contextLimit: finalContextLimit,
|
|
892
894
|
compactCount: finalCompactCount,
|
|
893
895
|
cacheReadTokens: finalCacheReadTokens,
|
|
894
896
|
cacheCreationTokens: finalCacheCreationTokens,
|
|
@@ -908,6 +910,7 @@ export class Bridge {
|
|
|
908
910
|
// 仅补充 usage meta(finalizing 期间被 /stop 或 idle 超时也展示 token 统计)
|
|
909
911
|
await cardSession.finish(finalState.terminal, {
|
|
910
912
|
contextLength: finalContextLength,
|
|
913
|
+
contextLimit: finalContextLimit,
|
|
911
914
|
compactCount: finalCompactCount,
|
|
912
915
|
cacheReadTokens: finalCacheReadTokens,
|
|
913
916
|
cacheCreationTokens: finalCacheCreationTokens,
|
|
@@ -939,6 +942,7 @@ export class Bridge {
|
|
|
939
942
|
if (catchTerminal === 'running' || catchTerminal === 'finalizing') {
|
|
940
943
|
await cardSession.finish('error', {
|
|
941
944
|
contextLength: finalContextLength,
|
|
945
|
+
contextLimit: finalContextLimit,
|
|
942
946
|
compactCount: finalCompactCount,
|
|
943
947
|
cacheReadTokens: finalCacheReadTokens,
|
|
944
948
|
cacheCreationTokens: finalCacheCreationTokens,
|
|
@@ -956,6 +960,7 @@ export class Bridge {
|
|
|
956
960
|
if (sawResult) {
|
|
957
961
|
await cardSession.finish(catchTerminal, {
|
|
958
962
|
contextLength: finalContextLength,
|
|
963
|
+
contextLimit: finalContextLimit,
|
|
959
964
|
compactCount: finalCompactCount,
|
|
960
965
|
cacheReadTokens: finalCacheReadTokens,
|
|
961
966
|
cacheCreationTokens: finalCacheCreationTokens,
|
|
@@ -1050,6 +1055,7 @@ export class Bridge {
|
|
|
1050
1055
|
return content.usage
|
|
1051
1056
|
? {
|
|
1052
1057
|
contextLength: content.usage.contextLength,
|
|
1058
|
+
contextLimit: content.usage.contextLimit,
|
|
1053
1059
|
compactCount: content.usage.compactCount,
|
|
1054
1060
|
cacheReadTokens: content.usage.cacheReadTokens,
|
|
1055
1061
|
cacheCreationTokens: content.usage.cacheCreationTokens,
|
|
@@ -1104,14 +1110,7 @@ export class Bridge {
|
|
|
1104
1110
|
{
|
|
1105
1111
|
tag: 'column',
|
|
1106
1112
|
width: 'auto',
|
|
1107
|
-
elements: [
|
|
1108
|
-
{
|
|
1109
|
-
tag: 'button',
|
|
1110
|
-
text: { tag: 'plain_text', content: '🔁 切换到此会话' },
|
|
1111
|
-
type: 'primary',
|
|
1112
|
-
behaviors: [{ type: 'callback', value: { cmd: 'resume.use', sessionId } }],
|
|
1113
|
-
},
|
|
1114
|
-
],
|
|
1113
|
+
elements: [resumeUseButton(sessionId, agentKind)],
|
|
1115
1114
|
},
|
|
1116
1115
|
],
|
|
1117
1116
|
});
|
package/dist/card/card-budget.js
CHANGED
|
@@ -46,8 +46,7 @@ export function enforceCardBudget(card, opts = {}) {
|
|
|
46
46
|
* when table truncation alone doesn't bring the card under the byte limit.
|
|
47
47
|
*
|
|
48
48
|
* 裁剪判定是**结构化**的:所有 collapsible_panel 都是待裁剪对象,不看面板
|
|
49
|
-
* 标题文本。历史教训(2026-08-08
|
|
50
|
-
* docs/zh/architecture/resume-card-budget-failure-analysis.md):旧实现用
|
|
49
|
+
* 标题文本。历史教训(2026-08-08):旧实现用
|
|
51
50
|
* emoji 标题模式(🤖👤💭🔧🟢🔴)识别「会话事件面板」,但真实
|
|
52
51
|
* sessionEventPanel 产出的标题是裸英文 type 名(emoji 在事件正文而非标题),
|
|
53
52
|
* 导致裁剪阶段对真实 resume 卡零命中,任何 >28KB 的卡片无裁剪直通极端降级,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type AgentKind } from '../runner/index.js';
|
|
1
2
|
interface TruncateOptions {
|
|
2
3
|
suffix?: string;
|
|
3
4
|
normalizeWhitespace?: boolean;
|
|
@@ -25,4 +26,11 @@ export declare function stopButton(runId: string): object;
|
|
|
25
26
|
* Standardized: ✨ 新会话 + primary type
|
|
26
27
|
*/
|
|
27
28
|
export declare function newSessionButton(): object;
|
|
29
|
+
/**
|
|
30
|
+
* Create a CardKit 2.0 "resume session" button with behaviors callback.
|
|
31
|
+
* Carries both sessionId and agent so the handler routes to the correct
|
|
32
|
+
* agent's session reader (P2 fix: completion cards from non-default agents
|
|
33
|
+
* must carry agent to avoid wrong-reader fallback).
|
|
34
|
+
*/
|
|
35
|
+
export declare function resumeUseButton(sessionId: string, agent: AgentKind): object;
|
|
28
36
|
export {};
|
package/dist/card/card-shared.js
CHANGED
|
@@ -96,4 +96,18 @@ export function newSessionButton() {
|
|
|
96
96
|
behaviors: [{ type: 'callback', value: { cmd: 'new-session' } }],
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Create a CardKit 2.0 "resume session" button with behaviors callback.
|
|
101
|
+
* Carries both sessionId and agent so the handler routes to the correct
|
|
102
|
+
* agent's session reader (P2 fix: completion cards from non-default agents
|
|
103
|
+
* must carry agent to avoid wrong-reader fallback).
|
|
104
|
+
*/
|
|
105
|
+
export function resumeUseButton(sessionId, agent) {
|
|
106
|
+
return {
|
|
107
|
+
tag: 'button',
|
|
108
|
+
text: { tag: 'plain_text', content: '🔁 切换到此会话' },
|
|
109
|
+
type: 'primary',
|
|
110
|
+
behaviors: [{ type: 'callback', value: { cmd: 'resume.use', sessionId, agent } }],
|
|
111
|
+
};
|
|
112
|
+
}
|
|
99
113
|
//# sourceMappingURL=card-shared.js.map
|
|
@@ -776,6 +776,7 @@ function buildSummaryContent(state) {
|
|
|
776
776
|
const empty = !hasContent ? '\n\n(未返回内容)' : '';
|
|
777
777
|
const usageStatsStr = formatUsageStats({
|
|
778
778
|
contextLength: state.contextLength,
|
|
779
|
+
contextLimit: state.contextLimit,
|
|
779
780
|
compactCount: state.compactCount,
|
|
780
781
|
cacheReadTokens: state.cacheReadTokens,
|
|
781
782
|
cacheCreationTokens: state.cacheCreationTokens,
|
package/dist/card/run-state.d.ts
CHANGED
|
@@ -53,6 +53,8 @@ export interface RunState {
|
|
|
53
53
|
sessionId?: string;
|
|
54
54
|
resultSubtype?: 'success' | 'error';
|
|
55
55
|
contextLength?: number;
|
|
56
|
+
/** 当前模型 context window 上限(codex jsonl 提供);卡片据此渲染百分比。 */
|
|
57
|
+
contextLimit?: number;
|
|
56
58
|
errorMsg?: string;
|
|
57
59
|
idleTimeoutMinutes?: number;
|
|
58
60
|
compactCount?: number;
|
|
@@ -79,6 +81,8 @@ export interface RunState {
|
|
|
79
81
|
export interface FinishMeta {
|
|
80
82
|
resultSubtype?: 'success' | 'error';
|
|
81
83
|
contextLength?: number;
|
|
84
|
+
/** 当前模型 context window 上限;透传到 RunState 供 done 卡片显示百分比。 */
|
|
85
|
+
contextLimit?: number;
|
|
82
86
|
errorMsg?: string;
|
|
83
87
|
idleTimeoutMinutes?: number;
|
|
84
88
|
compactCount?: number;
|
|
@@ -76,7 +76,7 @@ export declare function parseCodexModelsOutput(stdout: string): BundledModelInfo
|
|
|
76
76
|
* (P3-4/P3-15/P3-5);成功结果 TTL 1h,失败/空结果短 TTL 负缓存;stat 异常时
|
|
77
77
|
* 指纹为空(P1-1/P3-10)。
|
|
78
78
|
*/
|
|
79
|
-
export declare function getCodexCatalogModels(
|
|
79
|
+
export declare function getCodexCatalogModels(codexHome?: string): BundledModelInfo[];
|
|
80
80
|
/**
|
|
81
81
|
* Test utility: clear the catalog cache. Tests that exercise the bundled
|
|
82
82
|
* command path (`--bundled`) directly use `invalidateCodexBundledTestCache`
|
|
@@ -88,18 +88,16 @@ export declare function invalidateCodexBundledCache(): void;
|
|
|
88
88
|
* @param codexHome 可选 codex 配置目录覆盖(与 loadCodexConfig 的 codexHome 对齐,
|
|
89
89
|
* 与 loadCodexConfig 的 codexHome 对齐);省略时走 $CODEX_HOME → ~/.codex。
|
|
90
90
|
*/
|
|
91
|
-
export declare function getReasoningEffortOptions(model: string,
|
|
91
|
+
export declare function getReasoningEffortOptions(model: string, codexHome?: string): readonly string[];
|
|
92
92
|
/**
|
|
93
93
|
* Get default reasoning effort for a model.
|
|
94
94
|
* 未声明/未知模型 → undefined(codex 语义:ModelPreset.default_reasoning_effort
|
|
95
95
|
* unwrap_or(ReasoningEffort::None),即不传 effort;P3-12)。
|
|
96
96
|
*/
|
|
97
|
-
export declare function getDefaultReasoningEffort(model: string,
|
|
97
|
+
export declare function getDefaultReasoningEffort(model: string, codexHome?: string): string | undefined;
|
|
98
98
|
interface LoadCodexConfigOpts {
|
|
99
99
|
/** Explicit codex home override. Default: $CODEX_HOME -> ~/.codex */
|
|
100
100
|
codexHome?: string;
|
|
101
|
-
/** codex binary path, for `debug models --bundled`. Default: 'codex' */
|
|
102
|
-
binary?: string;
|
|
103
101
|
}
|
|
104
102
|
/**
|
|
105
103
|
* Read codex config.toml, extract provider and model info
|
|
@@ -154,7 +154,8 @@ export function parseCodexModelsOutput(stdout) {
|
|
|
154
154
|
* (P3-4/P3-15/P3-5);成功结果 TTL 1h,失败/空结果短 TTL 负缓存;stat 异常时
|
|
155
155
|
* 指纹为空(P1-1/P3-10)。
|
|
156
156
|
*/
|
|
157
|
-
export function getCodexCatalogModels(
|
|
157
|
+
export function getCodexCatalogModels(codexHome) {
|
|
158
|
+
const binary = 'codex';
|
|
158
159
|
const home = resolveCodexHome(codexHome);
|
|
159
160
|
const catalogPath = readModelCatalogJsonPath(home);
|
|
160
161
|
const bundled = catalogPath === undefined || catalogPath === TOML_PARSE_FAILED_SENTINEL;
|
|
@@ -217,8 +218,8 @@ export function invalidateCodexBundledCache() {
|
|
|
217
218
|
* @param codexHome 可选 codex 配置目录覆盖(与 loadCodexConfig 的 codexHome 对齐,
|
|
218
219
|
* 与 loadCodexConfig 的 codexHome 对齐);省略时走 $CODEX_HOME → ~/.codex。
|
|
219
220
|
*/
|
|
220
|
-
export function getReasoningEffortOptions(model,
|
|
221
|
-
const models = getCodexCatalogModels(
|
|
221
|
+
export function getReasoningEffortOptions(model, codexHome) {
|
|
222
|
+
const models = getCodexCatalogModels(codexHome);
|
|
222
223
|
const found = models.find((m) => m.slug === model);
|
|
223
224
|
// 未命中(含未知模型,codex fallback 元数据 supported 为空)→ [],不虚构档位(P1)
|
|
224
225
|
return found?.supportedReasoningLevels ?? [];
|
|
@@ -228,8 +229,8 @@ export function getReasoningEffortOptions(model, binary = 'codex', codexHome) {
|
|
|
228
229
|
* 未声明/未知模型 → undefined(codex 语义:ModelPreset.default_reasoning_effort
|
|
229
230
|
* unwrap_or(ReasoningEffort::None),即不传 effort;P3-12)。
|
|
230
231
|
*/
|
|
231
|
-
export function getDefaultReasoningEffort(model,
|
|
232
|
-
const models = getCodexCatalogModels(
|
|
232
|
+
export function getDefaultReasoningEffort(model, codexHome) {
|
|
233
|
+
const models = getCodexCatalogModels(codexHome);
|
|
233
234
|
return models.find((m) => m.slug === model)?.defaultReasoningLevel;
|
|
234
235
|
}
|
|
235
236
|
/**
|
|
@@ -249,13 +250,12 @@ function extractCustomProvider(providers) {
|
|
|
249
250
|
* - anthropic: bundled models with 'claude-*' prefix
|
|
250
251
|
*/
|
|
251
252
|
export function loadCodexConfig(opts = {}) {
|
|
252
|
-
const binary = opts.binary ?? 'codex';
|
|
253
253
|
const codexHome = resolveCodexHome(opts.codexHome);
|
|
254
254
|
const configFile = path.join(codexHome, 'config.toml');
|
|
255
255
|
const catalogMode = isCodexCatalogMode(codexHome);
|
|
256
256
|
// 统一目录来源:catalog 模式 = 活动目录(model_catalog_json 整体替换内置目录);
|
|
257
257
|
// 否则 = bundled(与原行为一致)
|
|
258
|
-
const catalogSlugs = getCodexCatalogModels(
|
|
258
|
+
const catalogSlugs = getCodexCatalogModels(codexHome).map((m) => m.slug);
|
|
259
259
|
const allModels = catalogSlugs.length > 0 ? catalogSlugs : FALLBACK_MODELS;
|
|
260
260
|
const anthropicModels = allModels.filter((m) => m.startsWith('claude-'));
|
|
261
261
|
if (!fs.existsSync(configFile)) {
|
package/dist/config/dir.d.ts
CHANGED
package/dist/config/dir.js
CHANGED
|
@@ -49,6 +49,9 @@ export function parseCliArgs(args = process.argv.slice(2)) {
|
|
|
49
49
|
result.settings = args[++i];
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
+
else if (arg === '--dev') {
|
|
53
|
+
result.dev = true;
|
|
54
|
+
}
|
|
52
55
|
}
|
|
53
56
|
return result;
|
|
54
57
|
}
|
|
@@ -73,6 +76,7 @@ export function printHelp() {
|
|
|
73
76
|
'Options:',
|
|
74
77
|
' --config-dir <path> 自定义配置目录(默认 ~/.lark-remote,可用于同机多实例)',
|
|
75
78
|
' --settings <path> 指定 Claude 配置文件路径',
|
|
79
|
+
' --dev 开发模式:标记从源码 bun src/index.ts 启动(看门狗据此选择拉起方式)',
|
|
76
80
|
' -h, --help 显示本帮助信息',
|
|
77
81
|
' -v, --version 显示版本号',
|
|
78
82
|
];
|
package/dist/config/index.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ export declare const MODEL_ID_TO_ALIAS: Record<string, string>;
|
|
|
15
15
|
/** alias → model ID 反向映射。 */
|
|
16
16
|
export declare const MODEL_ALIAS_TO_ID: Record<string, string>;
|
|
17
17
|
declare const ClaudeConfigSchema: z.ZodObject<{
|
|
18
|
-
binary: z.ZodDefault<z.ZodString>;
|
|
19
18
|
model: z.ZodDefault<z.ZodString>;
|
|
20
19
|
effort: z.ZodDefault<z.ZodEnum<{
|
|
21
20
|
medium: "medium";
|
|
@@ -28,7 +27,6 @@ declare const ClaudeConfigSchema: z.ZodObject<{
|
|
|
28
27
|
}, z.core.$strip>;
|
|
29
28
|
/** Codex-specific configuration. */
|
|
30
29
|
export declare const CodexConfigSchema: z.ZodObject<{
|
|
31
|
-
binary: z.ZodDefault<z.ZodString>;
|
|
32
30
|
model: z.ZodOptional<z.ZodString>;
|
|
33
31
|
modelProvider: z.ZodOptional<z.ZodString>;
|
|
34
32
|
reasoningEffort: z.ZodOptional<z.ZodString>;
|
|
@@ -36,13 +34,11 @@ export declare const CodexConfigSchema: z.ZodObject<{
|
|
|
36
34
|
}, z.core.$strip>;
|
|
37
35
|
/** OpenCode-specific configuration (run mode: opencode run --format json --auto). */
|
|
38
36
|
declare const OpencodeConfigSchema: z.ZodObject<{
|
|
39
|
-
binary: z.ZodDefault<z.ZodString>;
|
|
40
37
|
providerID: z.ZodDefault<z.ZodString>;
|
|
41
38
|
modelID: z.ZodDefault<z.ZodString>;
|
|
42
39
|
}, z.core.$strip>;
|
|
43
40
|
/** Pi-specific configuration. pi is a spawn-per-message CLI like Claude. */
|
|
44
41
|
declare const PiConfigSchema: z.ZodObject<{
|
|
45
|
-
binary: z.ZodDefault<z.ZodString>;
|
|
46
42
|
provider: z.ZodDefault<z.ZodString>;
|
|
47
43
|
model: z.ZodDefault<z.ZodString>;
|
|
48
44
|
thinking: z.ZodDefault<z.ZodEnum<{
|
|
@@ -57,7 +53,6 @@ declare const PiConfigSchema: z.ZodObject<{
|
|
|
57
53
|
}, z.core.$strip>;
|
|
58
54
|
/** Kimi-specific configuration. kimi is a spawn-per-message CLI. */
|
|
59
55
|
declare const KimiConfigSchema: z.ZodObject<{
|
|
60
|
-
binary: z.ZodDefault<z.ZodString>;
|
|
61
56
|
model: z.ZodDefault<z.ZodString>;
|
|
62
57
|
thinkingEffort: z.ZodDefault<z.ZodEnum<{
|
|
63
58
|
max: "max";
|
|
@@ -71,7 +66,6 @@ export declare const AppConfigSchema: z.ZodObject<{
|
|
|
71
66
|
appSecret: z.ZodString;
|
|
72
67
|
}, z.core.$strip>;
|
|
73
68
|
claude: z.ZodDefault<z.ZodObject<{
|
|
74
|
-
binary: z.ZodDefault<z.ZodString>;
|
|
75
69
|
model: z.ZodDefault<z.ZodString>;
|
|
76
70
|
effort: z.ZodDefault<z.ZodEnum<{
|
|
77
71
|
medium: "medium";
|
|
@@ -84,19 +78,16 @@ export declare const AppConfigSchema: z.ZodObject<{
|
|
|
84
78
|
}, z.core.$strip>>;
|
|
85
79
|
agents: z.ZodOptional<z.ZodObject<{
|
|
86
80
|
codex: z.ZodOptional<z.ZodObject<{
|
|
87
|
-
binary: z.ZodDefault<z.ZodString>;
|
|
88
81
|
model: z.ZodOptional<z.ZodString>;
|
|
89
82
|
modelProvider: z.ZodOptional<z.ZodString>;
|
|
90
83
|
reasoningEffort: z.ZodOptional<z.ZodString>;
|
|
91
84
|
stopGraceMs: z.ZodDefault<z.ZodNumber>;
|
|
92
85
|
}, z.core.$strip>>;
|
|
93
86
|
opencode: z.ZodOptional<z.ZodObject<{
|
|
94
|
-
binary: z.ZodDefault<z.ZodString>;
|
|
95
87
|
providerID: z.ZodDefault<z.ZodString>;
|
|
96
88
|
modelID: z.ZodDefault<z.ZodString>;
|
|
97
89
|
}, z.core.$strip>>;
|
|
98
90
|
pi: z.ZodOptional<z.ZodObject<{
|
|
99
|
-
binary: z.ZodDefault<z.ZodString>;
|
|
100
91
|
provider: z.ZodDefault<z.ZodString>;
|
|
101
92
|
model: z.ZodDefault<z.ZodString>;
|
|
102
93
|
thinking: z.ZodDefault<z.ZodEnum<{
|
|
@@ -110,7 +101,6 @@ export declare const AppConfigSchema: z.ZodObject<{
|
|
|
110
101
|
tools: z.ZodDefault<z.ZodString>;
|
|
111
102
|
}, z.core.$strip>>;
|
|
112
103
|
kimi: z.ZodOptional<z.ZodObject<{
|
|
113
|
-
binary: z.ZodDefault<z.ZodString>;
|
|
114
104
|
model: z.ZodDefault<z.ZodString>;
|
|
115
105
|
thinkingEffort: z.ZodDefault<z.ZodEnum<{
|
|
116
106
|
max: "max";
|
package/dist/config/index.js
CHANGED
|
@@ -13,7 +13,6 @@ export const CLAUDE_EFFORTS = ['low', 'medium', 'high', 'xhigh', 'max'];
|
|
|
13
13
|
export const PI_THINKING_LEVELS = ['off', 'minimal', 'low', 'medium', 'high', 'xhigh'];
|
|
14
14
|
/** 默认值常量:schema 与 template 共享,避免双源不一致(G25 Magic Numbers)。 */
|
|
15
15
|
const DEFAULTS = {
|
|
16
|
-
CLAUDE_BINARY: 'claude',
|
|
17
16
|
CLAUDE_MODEL: 'claude-opus-4-8',
|
|
18
17
|
STOP_GRACE_MS: 5000,
|
|
19
18
|
IDLE_WATCHDOG_MINUTES: 15,
|
|
@@ -43,7 +42,6 @@ const FeishuConfigSchema = z.object({
|
|
|
43
42
|
appSecret: z.string().min(1),
|
|
44
43
|
});
|
|
45
44
|
const ClaudeConfigSchema = z.object({
|
|
46
|
-
binary: z.string().default(DEFAULTS.CLAUDE_BINARY),
|
|
47
45
|
model: z.string().default(DEFAULTS.CLAUDE_MODEL),
|
|
48
46
|
effort: z.enum(CLAUDE_EFFORTS).default('medium'),
|
|
49
47
|
// permissionMode 硬编码为 bypassPermissions(runner 内部),不通过 config 配置
|
|
@@ -51,8 +49,6 @@ const ClaudeConfigSchema = z.object({
|
|
|
51
49
|
});
|
|
52
50
|
/** Codex-specific configuration. */
|
|
53
51
|
export const CodexConfigSchema = z.object({
|
|
54
|
-
/** Path to codex binary. Default: 'codex' (in PATH). */
|
|
55
|
-
binary: z.string().default('codex'),
|
|
56
52
|
/** model to use. Undefined → codex reads from its config.toml. */
|
|
57
53
|
model: z.string().optional(),
|
|
58
54
|
/** model provider, e.g. 'volcengine-coding-plan'. Undefined → codex reads from its config.toml. */
|
|
@@ -70,8 +66,6 @@ export const CodexConfigSchema = z.object({
|
|
|
70
66
|
});
|
|
71
67
|
/** OpenCode-specific configuration (run mode: opencode run --format json --auto). */
|
|
72
68
|
const OpencodeConfigSchema = z.object({
|
|
73
|
-
/** Path to opencode binary. Default: 'opencode' (in PATH). */
|
|
74
|
-
binary: z.string().default('opencode'),
|
|
75
69
|
/** Provider ID for the LLM backend (e.g. 'anthropic'). */
|
|
76
70
|
providerID: z.string().default('anthropic'),
|
|
77
71
|
/** Model ID for the LLM backend (e.g. 'claude-sonnet-4-20250514'). */
|
|
@@ -79,8 +73,6 @@ const OpencodeConfigSchema = z.object({
|
|
|
79
73
|
});
|
|
80
74
|
/** Pi-specific configuration. pi is a spawn-per-message CLI like Claude. */
|
|
81
75
|
const PiConfigSchema = z.object({
|
|
82
|
-
/** Path to pi binary. Default: 'pi' (in PATH). */
|
|
83
|
-
binary: z.string().default('pi'),
|
|
84
76
|
/** LLM provider, e.g. 'Volcano', 'anthropic', 'openai'. */
|
|
85
77
|
provider: z.string().default('Volcano'),
|
|
86
78
|
/** Model ID or alias, e.g. 'glm-5.2'. */
|
|
@@ -92,8 +84,6 @@ const PiConfigSchema = z.object({
|
|
|
92
84
|
});
|
|
93
85
|
/** Kimi-specific configuration. kimi is a spawn-per-message CLI. */
|
|
94
86
|
const KimiConfigSchema = z.object({
|
|
95
|
-
/** Path to kimi binary. Default: 'kimi' (in PATH). */
|
|
96
|
-
binary: z.string().default('kimi'),
|
|
97
87
|
/** Model ID or alias, e.g. 'kimi-code/k3'. */
|
|
98
88
|
model: z.string().default('kimi-code/k3'),
|
|
99
89
|
/** Thinking effort: 'on', 'max'. */
|
|
@@ -169,7 +159,6 @@ const TEMPLATE = `feishu:
|
|
|
169
159
|
appSecret: ""
|
|
170
160
|
|
|
171
161
|
claude:
|
|
172
|
-
binary: ${DEFAULTS.CLAUDE_BINARY}
|
|
173
162
|
model: ${DEFAULTS.CLAUDE_MODEL}
|
|
174
163
|
effort: medium
|
|
175
164
|
stopGraceMs: ${DEFAULTS.STOP_GRACE_MS}
|
package/dist/connector/index.js
CHANGED
|
@@ -53,6 +53,14 @@ function shouldRetrySendError(err) {
|
|
|
53
53
|
return true;
|
|
54
54
|
return false;
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Safely extract the im.v1.message.patch service from a LarkChannel.
|
|
58
|
+
* Returns undefined when the channel mock omits rawClient (unit tests).
|
|
59
|
+
*/
|
|
60
|
+
function tryGetPatchService(channel) {
|
|
61
|
+
const c = channel.rawClient;
|
|
62
|
+
return c?.im?.v1?.message;
|
|
63
|
+
}
|
|
56
64
|
export class FeishuConnector {
|
|
57
65
|
channel;
|
|
58
66
|
onMessage;
|
|
@@ -81,6 +89,26 @@ export class FeishuConnector {
|
|
|
81
89
|
},
|
|
82
90
|
},
|
|
83
91
|
});
|
|
92
|
+
// 观测探针(2026-08-11 run 卡定格事故):飞书业务码错误以 HTTP 200 + {code!=0}
|
|
93
|
+
// 返回时,lark SDK 正常 resolve、@larksuite/channel 的 patchCard 丢弃返回值,
|
|
94
|
+
// 导致终态卡 patch 被业务层拒绝时全链路无日志无兜底。这里只观测不改行为——
|
|
95
|
+
// 不 throw、不重试,返回值原样透传。
|
|
96
|
+
// 详见 .adversarial-tdd/prompt-patchcard-business-code-observability.md
|
|
97
|
+
// Guard: unit-test mocks may omit rawClient; skip probe installation in that case.
|
|
98
|
+
const messageService = tryGetPatchService(this.channel);
|
|
99
|
+
if (messageService?.patch) {
|
|
100
|
+
const origPatch = messageService.patch.bind(messageService);
|
|
101
|
+
messageService.patch = (async (request, options) => {
|
|
102
|
+
const res = await origPatch(request, options);
|
|
103
|
+
if (typeof res?.code === 'number' && res.code !== 0) {
|
|
104
|
+
const content = request?.data?.content;
|
|
105
|
+
const bytes = typeof content === 'string' ? Buffer.byteLength(content, 'utf8') : undefined;
|
|
106
|
+
getLogger().warn(`[feishu] message.patch business error code=${res.code} msg=${String(res.msg)} ` +
|
|
107
|
+
`messageId=${String(request?.path?.message_id)} bytes=${bytes ?? 'unknown'}`);
|
|
108
|
+
}
|
|
109
|
+
return res;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
84
112
|
this.channel.on('message', (msg) => {
|
|
85
113
|
if (msg.chatType !== 'p2p')
|
|
86
114
|
return;
|