lark-remote 0.1.12 → 0.1.13
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/CHANGELOG.md +12 -0
- package/dist/bridge/inbound-media.d.ts +0 -3
- package/dist/bridge/inbound-media.js +0 -1
- package/dist/bridge/index.d.ts +7 -0
- package/dist/bridge/index.js +79 -70
- package/dist/card/card-shared.d.ts +1 -4
- package/dist/card/card-shared.js +2 -4
- package/dist/common/truncate.d.ts +0 -6
- package/dist/common/truncate.js +1 -1
- package/dist/common/ttl-cache.d.ts +24 -0
- package/dist/common/ttl-cache.js +53 -0
- package/dist/config/codex-config.js +12 -11
- package/dist/config/index.d.ts +0 -3
- package/dist/config/index.js +0 -5
- package/dist/config/kimi-config.d.ts +1 -1
- package/dist/config/kimi-config.js +1 -1
- package/dist/config/opencode-config.d.ts +1 -1
- package/dist/config/opencode-config.js +3 -8
- package/dist/router/index.d.ts +7 -0
- package/dist/router/index.js +217 -279
- package/dist/runner/claude/session.d.ts +0 -3
- package/dist/runner/claude/session.js +0 -5
- package/dist/runner/codex/app-server/runner.d.ts +1 -16
- package/dist/runner/codex/app-server/runner.js +2 -2
- package/dist/runner/common/acp/protocol-helpers.d.ts +31 -0
- package/dist/runner/common/acp/protocol-helpers.js +48 -0
- package/dist/runner/common/connection-based-runner.d.ts +0 -2
- package/dist/runner/common/connection-based-runner.js +1 -1
- package/dist/runner/dsh/index.d.ts +0 -2
- package/dist/runner/dsh/index.js +0 -2
- package/dist/runner/dsh/runner.d.ts +0 -2
- package/dist/runner/dsh/runner.js +1 -1
- package/dist/runner/kimi/acp/runner.d.ts +18 -11
- package/dist/runner/kimi/acp/runner.js +95 -87
- package/dist/runner/kimi/acp/translator.d.ts +0 -1
- package/dist/runner/kimi/acp/translator.js +5 -13
- package/dist/runner/opencode/acp/runner.js +2 -42
- package/dist/runner/opencode/acp/translator.d.ts +0 -1
- package/dist/runner/opencode/acp/translator.js +3 -13
- package/dist/runner/pi/rpc/index.d.ts +0 -2
- package/dist/runner/pi/rpc/index.js +0 -2
- package/dist/runner/resolve-agent-choices.js +6 -2
- package/dist/runner/sync-agent-choices.js +1 -1
- package/dist/session/claude/session-index.js +3 -1
- package/dist/session/claude/sessions.js +3 -7
- package/dist/session/codex/rollout-reader.d.ts +0 -14
- package/dist/session/codex/rollout-reader.js +3 -7
- package/dist/session/common/pagination.d.ts +0 -2
- package/dist/session/common/pagination.js +1 -1
- package/dist/session/common/recency.d.ts +7 -0
- package/dist/session/common/recency.js +10 -0
- package/dist/session/common/usage-accumulator.d.ts +14 -0
- package/dist/session/common/usage-accumulator.js +15 -0
- package/dist/session/dsh/sessions.js +9 -6
- package/dist/session/kimi/sessions.d.ts +18 -4
- package/dist/session/kimi/sessions.js +49 -30
- package/dist/session/opencode/sessions.d.ts +2 -14
- package/dist/session/opencode/sessions.js +9 -7
- package/dist/session/pi/sessions.js +10 -22
- package/dist/update/index.d.ts +2 -2
- package/dist/update/index.js +1 -1
- package/package.json +1 -2
|
@@ -22,17 +22,19 @@ import { truncateUtf8, TOOL_RESULT_MAX_BYTES } from '../../common/truncate.js';
|
|
|
22
22
|
import { getLogger } from '../../logger/index.js';
|
|
23
23
|
import { STALE_MS } from '../common/constants.js';
|
|
24
24
|
import { paginate, capEvents } from '../common/pagination.js';
|
|
25
|
+
import { sortByRecencyDesc } from '../common/recency.js';
|
|
26
|
+
import { TtlCache } from '../../common/ttl-cache.js';
|
|
25
27
|
export class OpencodeSessionReader {
|
|
26
28
|
binary;
|
|
27
29
|
cacheTtlMs;
|
|
28
30
|
/** Optional raw-export capture override (testing / alt transport). */
|
|
29
31
|
captureExportOverride;
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
listCache = new Map();
|
|
32
|
+
/** cwd → 列表缓存(TTL 由 cacheTtlMs 决定)。 */
|
|
33
|
+
listCache;
|
|
33
34
|
constructor(opts = {}) {
|
|
34
35
|
this.binary = 'opencode';
|
|
35
36
|
this.cacheTtlMs = opts.cacheTtlMs ?? 10_000;
|
|
37
|
+
this.listCache = new TtlCache(this.cacheTtlMs);
|
|
36
38
|
this.captureExportOverride = opts.captureExport;
|
|
37
39
|
}
|
|
38
40
|
/**
|
|
@@ -47,7 +49,7 @@ export class OpencodeSessionReader {
|
|
|
47
49
|
const filtered = entries.filter((e) => e.directory === realCwd);
|
|
48
50
|
// Sort by updated descending; same-updated ties use id as a deterministic
|
|
49
51
|
// secondary key so CLI/list-cache rebuilds never reorder the page.
|
|
50
|
-
filtered
|
|
52
|
+
sortByRecencyDesc(filtered, (s) => s.updated, (s) => s.id);
|
|
51
53
|
// Compute total over the full sorted set, then paginate.
|
|
52
54
|
const { items, total } = paginate(filtered, opts ?? {});
|
|
53
55
|
return {
|
|
@@ -302,8 +304,8 @@ export class OpencodeSessionReader {
|
|
|
302
304
|
fetchSessionList(cwd) {
|
|
303
305
|
const realCwd = this.realpath(cwd);
|
|
304
306
|
const cached = this.listCache.get(realCwd);
|
|
305
|
-
if (cached
|
|
306
|
-
return cached
|
|
307
|
+
if (cached) {
|
|
308
|
+
return cached;
|
|
307
309
|
}
|
|
308
310
|
try {
|
|
309
311
|
// Pass cwd to execFileSync so opencode CLI returns sessions for the correct directory
|
|
@@ -322,7 +324,7 @@ export class OpencodeSessionReader {
|
|
|
322
324
|
}
|
|
323
325
|
const data = JSON.parse(output);
|
|
324
326
|
// Update cache keyed by cwd
|
|
325
|
-
this.listCache.set(realCwd,
|
|
327
|
+
this.listCache.set(realCwd, data);
|
|
326
328
|
return data;
|
|
327
329
|
}
|
|
328
330
|
catch (err) {
|
|
@@ -3,9 +3,11 @@ import path from 'node:path';
|
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
import { findJsonlLine, scanJsonlLines, readJsonlLinesFromOffset } from '../common/jsonl.js';
|
|
5
5
|
import { extractContentBlocks } from '../common/content-blocks.js';
|
|
6
|
-
import { UsageAccumulator } from '../common/usage-accumulator.js';
|
|
6
|
+
import { UsageAccumulator, contextWindowOccupancy, cumulativeUsageFields, } from '../common/usage-accumulator.js';
|
|
7
7
|
import { STALE_MS } from '../common/constants.js';
|
|
8
8
|
import { capEvents, paginate } from '../common/pagination.js';
|
|
9
|
+
import { sortByRecencyDesc } from '../common/recency.js';
|
|
10
|
+
import { TtlCache } from '../../common/ttl-cache.js';
|
|
9
11
|
function defaultPiDir() {
|
|
10
12
|
return path.join(os.homedir(), '.pi', 'agent');
|
|
11
13
|
}
|
|
@@ -19,10 +21,7 @@ function projectDirForCwd(cwd, sessionsDir) {
|
|
|
19
21
|
* P1-19: TTL cache for pi directory scans (mirror codex getSessionIndex's
|
|
20
22
|
* 5s TTL). Repeated /resume pages re-scan the whole sessions dir per call.
|
|
21
23
|
*/
|
|
22
|
-
const
|
|
23
|
-
/** Upper bound on cached listings; FIFO eviction past this. */
|
|
24
|
-
const PI_LIST_MAX_ENTRIES = 32;
|
|
25
|
-
const piListCache = new Map();
|
|
24
|
+
const piListCache = new TtlCache(5_000, 32);
|
|
26
25
|
/** Pi-specific field-name mapping for content block extraction. */
|
|
27
26
|
export const PI_MAPPING = {
|
|
28
27
|
toolUseType: 'toolCall',
|
|
@@ -207,21 +206,16 @@ function buildPiUsage(acc) {
|
|
|
207
206
|
return undefined;
|
|
208
207
|
}
|
|
209
208
|
const l = acc.last;
|
|
210
|
-
const contextLength = l.input + l.cacheRead + l.cacheCreation;
|
|
211
209
|
return {
|
|
212
210
|
inputTokens: l.input,
|
|
213
211
|
outputTokens: l.output,
|
|
214
|
-
contextLength,
|
|
212
|
+
contextLength: contextWindowOccupancy(l),
|
|
215
213
|
compactCount: acc.compactCount > 0 ? acc.compactCount : undefined,
|
|
216
214
|
cacheReadTokens: l.cacheRead > 0 ? l.cacheRead : 0,
|
|
217
215
|
cacheCreationTokens: l.cacheCreation > 0 ? l.cacheCreation : 0,
|
|
218
216
|
totalTokens: l.total > 0 ? l.total : undefined,
|
|
219
217
|
// Cumulative (session-wide): sum of ALL runs in the jsonl file.
|
|
220
|
-
|
|
221
|
-
cumulativeInputTokens: t.input,
|
|
222
|
-
cumulativeOutputTokens: t.output,
|
|
223
|
-
cumulativeCacheReadTokens: t.cacheRead,
|
|
224
|
-
cumulativeCacheCreationTokens: t.cacheCreation,
|
|
218
|
+
...cumulativeUsageFields(t),
|
|
225
219
|
};
|
|
226
220
|
}
|
|
227
221
|
/**
|
|
@@ -346,8 +340,8 @@ export class PiSessionReader {
|
|
|
346
340
|
listSessionsByScan(cwd) {
|
|
347
341
|
const cacheKey = `${this.sessionsDir}\u0000${cwd}`;
|
|
348
342
|
const cached = piListCache.get(cacheKey);
|
|
349
|
-
if (cached
|
|
350
|
-
return cached
|
|
343
|
+
if (cached) {
|
|
344
|
+
return cached;
|
|
351
345
|
}
|
|
352
346
|
const dir = projectDirForCwd(cwd, this.sessionsDir);
|
|
353
347
|
let files;
|
|
@@ -381,14 +375,8 @@ export class PiSessionReader {
|
|
|
381
375
|
}
|
|
382
376
|
}
|
|
383
377
|
// Same-mtime ties: secondary key keeps the full order deterministic.
|
|
384
|
-
sessions
|
|
385
|
-
piListCache.set(cacheKey,
|
|
386
|
-
// Bound the cache (map iteration order = insertion order).
|
|
387
|
-
if (piListCache.size > PI_LIST_MAX_ENTRIES) {
|
|
388
|
-
const oldest = piListCache.keys().next().value;
|
|
389
|
-
if (oldest !== undefined)
|
|
390
|
-
piListCache.delete(oldest);
|
|
391
|
-
}
|
|
378
|
+
sortByRecencyDesc(sessions, (s) => s.mtime, (s) => s.sessionId);
|
|
379
|
+
piListCache.set(cacheKey, sessions);
|
|
392
380
|
return sessions;
|
|
393
381
|
}
|
|
394
382
|
}
|
package/dist/update/index.d.ts
CHANGED
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* package installation (detect package manager + global install),
|
|
6
6
|
* and the combined workflow for the /update command and --update CLI flag.
|
|
7
7
|
*/
|
|
8
|
-
export { isNewer, checkLatestVersion, type VersionCheckResult
|
|
9
|
-
export { runInstallLatest, type
|
|
8
|
+
export { isNewer, checkLatestVersion, type VersionCheckResult } from './version-check.js';
|
|
9
|
+
export { runInstallLatest, type InstallResult } from './install.js';
|
|
10
10
|
export { formatUpdateHint } from './startup-hint.js';
|
package/dist/update/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* package installation (detect package manager + global install),
|
|
6
6
|
* and the combined workflow for the /update command and --update CLI flag.
|
|
7
7
|
*/
|
|
8
|
-
export { isNewer, checkLatestVersion
|
|
8
|
+
export { isNewer, checkLatestVersion } from './version-check.js';
|
|
9
9
|
export { runInstallLatest } from './install.js';
|
|
10
10
|
export { formatUpdateHint } from './startup-hint.js';
|
|
11
11
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lark-remote",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "Feishu (Lark) private-chat bridge to local coding agents — Claude Code / Codex / opencode / pi / kimi, with live-streaming CardKit 2.0 cards",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -101,7 +101,6 @@
|
|
|
101
101
|
},
|
|
102
102
|
"devDependencies": {
|
|
103
103
|
"@eslint/js": "^10.0.1",
|
|
104
|
-
"@types/form-data": "^2.5.2",
|
|
105
104
|
"@types/node": "^26.1.2",
|
|
106
105
|
"@types/qrcode-terminal": "^0.12.2",
|
|
107
106
|
"@vitest/coverage-v8": "4.1.10",
|