lark-remote 0.1.6 → 0.1.8
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 +51 -1
- package/README.en.md +9 -1
- package/README.md +14 -2
- package/dist/bridge/approval-coordinator.d.ts +71 -34
- package/dist/bridge/approval-coordinator.js +225 -41
- package/dist/bridge/inbound-media.d.ts +62 -0
- package/dist/bridge/inbound-media.js +282 -0
- package/dist/bridge/index.d.ts +97 -13
- package/dist/bridge/index.js +227 -87
- package/dist/bridge/queue-manager.d.ts +2 -1
- package/dist/bridge/queue-manager.js +1 -0
- package/dist/card/approval-render.js +294 -36
- package/dist/card/bash-card-session.d.ts +2 -24
- package/dist/card/bash-card-session.js +6 -73
- package/dist/card/bash-renderer.js +2 -3
- package/dist/card/card-budget.js +29 -75
- package/dist/card/card-session.d.ts +48 -0
- package/dist/card/card-session.js +86 -0
- package/dist/card/card-shared.d.ts +7 -16
- package/dist/card/card-shared.js +7 -30
- package/dist/card/run-card-session.d.ts +2 -55
- package/dist/card/run-card-session.js +6 -104
- package/dist/card/run-renderer.d.ts +7 -0
- package/dist/card/run-renderer.js +116 -238
- package/dist/card/run-state.d.ts +13 -0
- package/dist/card/run-state.js +25 -16
- package/dist/card/text-truncate.d.ts +13 -12
- package/dist/card/text-truncate.js +13 -63
- package/dist/common/fs.d.ts +8 -0
- package/dist/common/fs.js +17 -0
- package/dist/common/guards.d.ts +0 -20
- package/dist/common/guards.js +0 -43
- package/dist/common/sleep.d.ts +2 -0
- package/dist/common/sleep.js +5 -0
- package/dist/common/truncate.d.ts +39 -0
- package/dist/common/truncate.js +92 -0
- package/dist/config/codex-config.d.ts +1 -1
- package/dist/config/codex-config.js +1 -1
- package/dist/config/index.d.ts +112 -24
- package/dist/config/index.js +139 -37
- package/dist/connector/index.d.ts +69 -2
- package/dist/connector/index.js +107 -1
- package/dist/index.js +150 -118
- package/dist/instance-lock.js +4 -12
- package/dist/order/alias-resolve.d.ts +13 -0
- package/dist/order/alias-resolve.js +22 -0
- package/dist/order/alias-store.d.ts +38 -0
- package/dist/order/alias-store.js +106 -0
- package/dist/persistence/atomic-write.d.ts +8 -2
- package/dist/persistence/atomic-write.js +23 -7
- package/dist/restart.js +2 -1
- package/dist/router/card-action-payload.d.ts +30 -0
- package/dist/router/card-action-payload.js +39 -0
- package/dist/router/card-helpers.d.ts +63 -0
- package/dist/router/card-helpers.js +146 -0
- package/dist/router/config/claude.js +30 -1
- package/dist/router/config/codex.js +29 -50
- package/dist/router/config/common/model-patch.d.ts +22 -0
- package/dist/router/config/common/model-patch.js +26 -0
- package/dist/router/config/common/render.js +5 -4
- package/dist/router/config/dsh.d.ts +51 -0
- package/dist/router/config/dsh.js +179 -0
- package/dist/router/config/index.d.ts +12 -0
- package/dist/router/config/index.js +28 -1
- package/dist/router/config/kimi.d.ts +4 -1
- package/dist/router/config/kimi.js +27 -0
- package/dist/router/config/opencode.js +18 -5
- package/dist/router/config/pi.js +4 -5
- package/dist/router/config/types.d.ts +17 -2
- package/dist/router/index.d.ts +76 -22
- package/dist/router/index.js +479 -548
- package/dist/router/utils.d.ts +2 -0
- package/dist/router/utils.js +16 -2
- package/dist/runner/agent-choices-common.d.ts +16 -0
- package/dist/runner/agent-choices-common.js +34 -0
- package/dist/runner/claude/runner.d.ts +47 -10
- package/dist/runner/claude/runner.js +117 -46
- package/dist/runner/claude/session.d.ts +166 -0
- package/dist/runner/claude/session.js +768 -0
- package/dist/runner/codex/app-server/protocol-types.d.ts +66 -39
- package/dist/runner/codex/app-server/protocol-types.js +2 -13
- package/dist/runner/codex/app-server/runner.d.ts +52 -59
- package/dist/runner/codex/app-server/runner.js +216 -338
- package/dist/runner/codex/app-server/translator.d.ts +8 -21
- package/dist/runner/codex/app-server/translator.js +45 -18
- package/dist/runner/codex/index.d.ts +0 -2
- package/dist/runner/codex/index.js +0 -2
- package/dist/runner/common/acp/protocol-helpers.d.ts +14 -0
- package/dist/runner/common/acp/protocol-helpers.js +21 -0
- package/dist/runner/common/acp/protocol-types.d.ts +271 -0
- package/dist/runner/common/acp/protocol-types.js +77 -0
- package/dist/runner/common/connection-based-runner.d.ts +111 -0
- package/dist/runner/common/connection-based-runner.js +261 -0
- package/dist/runner/{codex/app-server → common/jsonrpc}/client.d.ts +14 -7
- package/dist/runner/{codex/app-server → common/jsonrpc}/client.js +27 -18
- package/dist/runner/common/jsonrpc/connection-manager.d.ts +125 -0
- package/dist/runner/{codex/app-server → common/jsonrpc}/connection-manager.js +63 -28
- package/dist/runner/{codex/app-server → common/jsonrpc}/transport.d.ts +5 -4
- package/dist/runner/{codex/app-server → common/jsonrpc}/transport.js +18 -19
- package/dist/runner/common/jsonrpc/types.d.ts +32 -0
- package/dist/runner/common/jsonrpc/types.js +9 -0
- package/dist/runner/common/process-stopper.d.ts +2 -1
- package/dist/runner/common/process-stopper.js +1 -0
- package/dist/runner/common/runner-utils.d.ts +6 -13
- package/dist/runner/common/runner-utils.js +6 -47
- package/dist/runner/common/spawning-runner.d.ts +24 -70
- package/dist/runner/common/spawning-runner.js +98 -152
- package/dist/runner/dsh/client.d.ts +95 -0
- package/dist/runner/dsh/client.js +418 -0
- package/dist/runner/dsh/fake-dsh-server.d.ts +60 -0
- package/dist/runner/dsh/fake-dsh-server.js +156 -0
- package/dist/runner/dsh/index.d.ts +3 -0
- package/dist/runner/dsh/index.js +4 -0
- package/dist/runner/dsh/runner.d.ts +57 -0
- package/dist/runner/dsh/runner.js +191 -0
- package/dist/runner/dsh/translator.d.ts +28 -0
- package/dist/runner/dsh/translator.js +98 -0
- package/dist/runner/dsh/types.d.ts +155 -0
- package/dist/runner/dsh/types.js +14 -0
- package/dist/runner/index.d.ts +5 -4
- package/dist/runner/index.js +5 -4
- package/dist/runner/kimi/acp/runner.d.ts +106 -0
- package/dist/runner/kimi/acp/runner.js +516 -0
- package/dist/runner/kimi/acp/translator.d.ts +138 -0
- package/dist/runner/kimi/acp/translator.js +441 -0
- package/dist/runner/kimi/index.d.ts +1 -1
- package/dist/runner/kimi/index.js +1 -1
- package/dist/runner/opencode/acp/index.d.ts +1 -0
- package/dist/runner/opencode/acp/index.js +2 -0
- package/dist/runner/opencode/acp/runner.d.ts +121 -0
- package/dist/runner/opencode/acp/runner.js +429 -0
- package/dist/runner/opencode/acp/translator.d.ts +119 -0
- package/dist/runner/opencode/acp/translator.js +345 -0
- package/dist/runner/opencode/index.d.ts +1 -1
- package/dist/runner/opencode/index.js +1 -1
- package/dist/runner/pi/index.d.ts +1 -1
- package/dist/runner/pi/index.js +1 -1
- package/dist/runner/pi/rpc/client.d.ts +52 -0
- package/dist/runner/pi/rpc/client.js +114 -0
- package/dist/runner/pi/rpc/index.d.ts +4 -0
- package/dist/runner/pi/rpc/index.js +4 -0
- package/dist/runner/pi/rpc/protocol-types.d.ts +127 -0
- package/dist/runner/pi/rpc/protocol-types.js +21 -0
- package/dist/runner/pi/rpc/runner.d.ts +74 -0
- package/dist/runner/pi/rpc/runner.js +190 -0
- package/dist/runner/pi/rpc/translator.d.ts +55 -0
- package/dist/runner/pi/rpc/translator.js +258 -0
- package/dist/runner/probe.js +6 -1
- package/dist/runner/question-common.d.ts +26 -0
- package/dist/runner/question-common.js +42 -0
- package/dist/runner/registry.d.ts +7 -8
- package/dist/runner/registry.js +3 -4
- package/dist/runner/resolve-agent-choices.js +18 -59
- package/dist/runner/sync-agent-choices.js +16 -67
- package/dist/runner/types.d.ts +97 -14
- package/dist/session/claude/session-index.js +2 -3
- package/dist/session/claude/session-reader.js +3 -6
- package/dist/session/claude/sessions.js +43 -28
- package/dist/session/codex/rollout-reader.d.ts +2 -2
- package/dist/session/codex/rollout-reader.js +14 -17
- package/dist/session/codex/sessions.d.ts +1 -1
- package/dist/session/codex/sessions.js +2 -2
- package/dist/session/common/content-blocks.d.ts +7 -0
- package/dist/session/common/content-blocks.js +13 -9
- package/dist/session/common/jsonl.d.ts +8 -25
- package/dist/session/common/jsonl.js +126 -261
- package/dist/session/common/pagination.d.ts +28 -0
- package/dist/session/common/pagination.js +33 -0
- package/dist/session/dsh/index.d.ts +1 -0
- package/dist/session/dsh/index.js +2 -0
- package/dist/session/dsh/sessions.d.ts +39 -0
- package/dist/session/dsh/sessions.js +237 -0
- package/dist/session/index.d.ts +1 -0
- package/dist/session/index.js +1 -0
- package/dist/session/kimi/sessions.d.ts +34 -1
- package/dist/session/kimi/sessions.js +208 -98
- package/dist/session/opencode/sessions.d.ts +17 -3
- package/dist/session/opencode/sessions.js +29 -29
- package/dist/session/pi/sessions.d.ts +5 -1
- package/dist/session/pi/sessions.js +12 -16
- package/dist/session/session-store.d.ts +11 -1
- package/dist/session/session-store.js +75 -178
- package/dist/update/index.d.ts +2 -2
- package/dist/update/index.js +2 -2
- package/dist/update/install.d.ts +20 -2
- package/dist/update/install.js +51 -7
- package/dist/workspace/index.d.ts +4 -0
- package/dist/workspace/index.js +8 -1
- package/package.json +2 -1
- package/dist/runner/codex/app-server/connection-manager.d.ts +0 -56
- package/dist/runner/codex/argv.d.ts +0 -33
- package/dist/runner/codex/argv.js +0 -40
- package/dist/runner/codex/factory.d.ts +0 -29
- package/dist/runner/codex/factory.js +0 -39
- package/dist/runner/codex/jsonl.d.ts +0 -37
- package/dist/runner/codex/jsonl.js +0 -221
- package/dist/runner/codex/runner.d.ts +0 -66
- package/dist/runner/codex/runner.js +0 -129
- package/dist/runner/common/exec-translator.d.ts +0 -73
- package/dist/runner/common/exec-translator.js +0 -105
- package/dist/runner/kimi/jsonl.d.ts +0 -28
- package/dist/runner/kimi/jsonl.js +0 -143
- package/dist/runner/kimi/runner.d.ts +0 -49
- package/dist/runner/kimi/runner.js +0 -105
- package/dist/runner/opencode/argv.d.ts +0 -32
- package/dist/runner/opencode/argv.js +0 -35
- package/dist/runner/opencode/jsonl.d.ts +0 -68
- package/dist/runner/opencode/jsonl.js +0 -295
- package/dist/runner/opencode/runner.d.ts +0 -61
- package/dist/runner/opencode/runner.js +0 -93
- package/dist/runner/pi/jsonl.d.ts +0 -128
- package/dist/runner/pi/jsonl.js +0 -249
- package/dist/runner/pi/runner.d.ts +0 -36
- package/dist/runner/pi/runner.js +0 -76
- package/dist/session/common/catch-up.d.ts +0 -12
- package/dist/session/common/catch-up.js +0 -31
|
@@ -11,12 +11,13 @@
|
|
|
11
11
|
* ```
|
|
12
12
|
*
|
|
13
13
|
* Note: This handles the **rollout file format** (historical logging), NOT the
|
|
14
|
-
* `codex exec --json` stdout format
|
|
15
|
-
* (see design doc appendix B vs C).
|
|
14
|
+
* `codex exec --json` stdout format(已随 exec 模式移除)。
|
|
16
15
|
*/
|
|
17
16
|
import fs from 'node:fs';
|
|
18
17
|
import path from 'node:path';
|
|
19
18
|
import { readJsonlLines, findJsonlLine } from '../common/jsonl.js';
|
|
19
|
+
import { STALE_MS } from '../common/constants.js';
|
|
20
|
+
import { paginate, capEvents } from '../common/pagination.js';
|
|
20
21
|
import { getLogger } from '../../logger/index.js';
|
|
21
22
|
import { isRecord, stringValue } from '../../common/guards.js';
|
|
22
23
|
import { resolveCodexHome } from '../../config/codex-config.js';
|
|
@@ -243,8 +244,6 @@ export function readCodexRollout(filePath) {
|
|
|
243
244
|
*/
|
|
244
245
|
export function listCodexRollouts(opts = {}) {
|
|
245
246
|
const codexHome = resolveCodexHome(opts.codexHome);
|
|
246
|
-
const limit = opts.limit ?? 20;
|
|
247
|
-
const offset = Math.max(0, opts.offset ?? 0);
|
|
248
247
|
const filterCwd = opts.cwd;
|
|
249
248
|
// Full index: every rollout file's session_meta + mtime, no early break.
|
|
250
249
|
const index = getSessionIndex(codexHome);
|
|
@@ -263,8 +262,7 @@ export function listCodexRollouts(opts = {}) {
|
|
|
263
262
|
// Same-mtime ties use filePath as a deterministic secondary key so index
|
|
264
263
|
// rebuilds / walk order changes never reorder the page.
|
|
265
264
|
matched.sort((a, b) => b.mtimeMs - a.mtimeMs || a.filePath.localeCompare(b.filePath));
|
|
266
|
-
const total = matched.
|
|
267
|
-
const page = matched.slice(offset, offset + limit);
|
|
265
|
+
const { items: page, total } = paginate(matched, { limit: opts.limit, offset: opts.offset });
|
|
268
266
|
// Full-parse only the page being returned (summary/usage).
|
|
269
267
|
const entries = [];
|
|
270
268
|
for (const item of page) {
|
|
@@ -317,22 +315,14 @@ export function readCodexSessionContent(sessionId, opts = {}) {
|
|
|
317
315
|
}
|
|
318
316
|
// Apply maxEvents cap: keep the LAST N events (most recent).
|
|
319
317
|
// See function docstring for rationale.
|
|
320
|
-
|
|
321
|
-
// full-array trap (no caller passes 0 today, but the contract must hold).
|
|
322
|
-
const events = opts.maxEvents !== undefined && opts.maxEvents > 0 && rollout.events.length > opts.maxEvents
|
|
323
|
-
? rollout.events.slice(-opts.maxEvents)
|
|
324
|
-
: opts.maxEvents !== undefined && opts.maxEvents <= 0
|
|
325
|
-
? []
|
|
326
|
-
: rollout.events;
|
|
318
|
+
const events = capEvents(rollout.events, opts.maxEvents);
|
|
327
319
|
return {
|
|
328
320
|
events,
|
|
329
321
|
// displayTitle = LAST real user message (matches the
|
|
330
322
|
// "最近输入" label). recap is undefined: codex has no
|
|
331
323
|
// compact-summary concept, so never fake one from a user
|
|
332
324
|
// message (was: firstUserMessage = injected project rules).
|
|
333
|
-
displayTitle: rollout.lastRealUserMessage
|
|
334
|
-
? rollout.lastRealUserMessage.slice(0, 50)
|
|
335
|
-
: undefined,
|
|
325
|
+
displayTitle: rollout.lastRealUserMessage || undefined,
|
|
336
326
|
recap: undefined,
|
|
337
327
|
usage: rollout.usage,
|
|
338
328
|
};
|
|
@@ -347,7 +337,9 @@ export function readCodexSessionContent(sessionId, opts = {}) {
|
|
|
347
337
|
*/
|
|
348
338
|
export function isCodexSessionActive(sessionId, opts = {}) {
|
|
349
339
|
const codexHome = resolveCodexHome(opts.codexHome);
|
|
350
|
-
|
|
340
|
+
// Unify with the other readers' 1-hour stale window (claude/pi/opencode/kimi
|
|
341
|
+
// all use STALE_MS). Previously codex used a divergent 10-minute default.
|
|
342
|
+
const threshold = opts.activeThresholdMs ?? STALE_MS;
|
|
351
343
|
// P2-4: Use session index for direct file lookup + mtime check
|
|
352
344
|
let index = getSessionIndex(codexHome);
|
|
353
345
|
let entry = index.get(sessionId);
|
|
@@ -366,6 +358,11 @@ export function isCodexSessionActive(sessionId, opts = {}) {
|
|
|
366
358
|
if (entry.isSubagent) {
|
|
367
359
|
return false;
|
|
368
360
|
}
|
|
361
|
+
// Cwd guard: when a cwd is provided, the session's working directory must
|
|
362
|
+
// match (align with claude/pi/opencode which validate cwd).
|
|
363
|
+
if (opts.cwd && entry.cwd !== opts.cwd) {
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
369
366
|
// Re-stat to get fresh mtime (index may be up to INDEX_TTL_MS stale)
|
|
370
367
|
try {
|
|
371
368
|
const stat = fs.statSync(entry.filePath);
|
|
@@ -16,6 +16,6 @@ export declare class CodexSessionReader implements AgentSessionReader {
|
|
|
16
16
|
readSessionContent(sessionId: string, cwd: string, opts?: {
|
|
17
17
|
maxEvents?: number;
|
|
18
18
|
}): SessionContent;
|
|
19
|
-
isSessionActive(sessionId: string,
|
|
19
|
+
isSessionActive(sessionId: string, cwd: string): boolean;
|
|
20
20
|
}
|
|
21
21
|
export {};
|
|
@@ -34,8 +34,8 @@ export class CodexSessionReader {
|
|
|
34
34
|
cwd,
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
isSessionActive(sessionId,
|
|
38
|
-
return isCodexSessionActive(sessionId, { codexHome: this.codexHome });
|
|
37
|
+
isSessionActive(sessionId, cwd) {
|
|
38
|
+
return isCodexSessionActive(sessionId, { codexHome: this.codexHome, cwd });
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
//# sourceMappingURL=sessions.js.map
|
|
@@ -10,6 +10,13 @@ interface ContentBlock {
|
|
|
10
10
|
type: 'text' | 'thinking' | 'tool_use' | 'tool_result';
|
|
11
11
|
content: string;
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Truncate a serialized tool-input string to 200 chars, collapsing newlines.
|
|
15
|
+
* Shared by content-block extraction and standalone wire-event readers (kimi
|
|
16
|
+
* tool.call) so the resume card never exceeds its 28KB budget on pathological
|
|
17
|
+
* args (e.g. whole-file writes / long prompts).
|
|
18
|
+
*/
|
|
19
|
+
export declare function truncateToolInput(inputStr: string): string;
|
|
13
20
|
/** Maps agent-specific field names to the generic extraction logic. */
|
|
14
21
|
export interface ContentBlockMapping {
|
|
15
22
|
/** The `type` value that identifies a tool-use block (e.g. 'tool_use' or 'toolCall'). */
|
|
@@ -5,6 +5,17 @@
|
|
|
5
5
|
* tool_result blocks. The {@link ContentBlockMapping} type captures those
|
|
6
6
|
* differences so a single implementation can serve all readers.
|
|
7
7
|
*/
|
|
8
|
+
/**
|
|
9
|
+
* Truncate a serialized tool-input string to 200 chars, collapsing newlines.
|
|
10
|
+
* Shared by content-block extraction and standalone wire-event readers (kimi
|
|
11
|
+
* tool.call) so the resume card never exceeds its 28KB budget on pathological
|
|
12
|
+
* args (e.g. whole-file writes / long prompts).
|
|
13
|
+
*/
|
|
14
|
+
export function truncateToolInput(inputStr) {
|
|
15
|
+
if (inputStr.length <= 200)
|
|
16
|
+
return inputStr;
|
|
17
|
+
return inputStr.replace(/\n/g, ' ').slice(0, 197) + '...';
|
|
18
|
+
}
|
|
8
19
|
/**
|
|
9
20
|
* Extract content blocks from a message content array.
|
|
10
21
|
*
|
|
@@ -34,16 +45,9 @@ export function extractContentBlocks(content, mapping) {
|
|
|
34
45
|
// tool_use block (parameterized type name + input field)
|
|
35
46
|
if (p.type === mapping.toolUseType && typeof p.name === 'string') {
|
|
36
47
|
const rawInput = p[mapping.toolInputField] ?? {};
|
|
37
|
-
const inputStr = JSON.stringify(rawInput, null, 2);
|
|
48
|
+
const inputStr = truncateToolInput(JSON.stringify(rawInput, null, 2));
|
|
38
49
|
const label = `🔧 ${p.name}`;
|
|
39
|
-
|
|
40
|
-
if (inputStr.length > 200) {
|
|
41
|
-
body = inputStr.replace(/\n/g, ' ').slice(0, 197) + '...';
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
body = inputStr;
|
|
45
|
-
}
|
|
46
|
-
blocks.push({ type: 'tool_use', content: `${label}: ${body}` });
|
|
50
|
+
blocks.push({ type: 'tool_use', content: `${label}: ${inputStr}` });
|
|
47
51
|
}
|
|
48
52
|
// tool_result block (parameterized type name + error field)
|
|
49
53
|
if (p.type === mapping.toolResultType) {
|
|
@@ -18,14 +18,7 @@ export declare function readLastJsonlLine(filePath: string): string | null;
|
|
|
18
18
|
* Read the last N non-empty lines from a JSONL file using streaming reads.
|
|
19
19
|
*
|
|
20
20
|
* Unlike `readJsonlLines` (which materializes the entire file into a `string[]`),
|
|
21
|
-
* this only retains the last `n` lines — memory is O(n), not O(whole file).
|
|
22
|
-
* file is still read front-to-back in chunks (no reverse seek), but earlier
|
|
23
|
-
* lines are discarded as soon as the buffer exceeds `n`, so a multi-MB file
|
|
24
|
-
* costs only ~`n` line strings of resident memory.
|
|
25
|
-
*
|
|
26
|
-
* Used by tail-only read paths (P2-5) such as `isSessionActive`, which only
|
|
27
|
-
* need to inspect the file's tail (e.g. the last ~20 loop events) but were
|
|
28
|
-
* previously full-slurping the whole wire log.
|
|
21
|
+
* this only retains the last `n` lines — memory is O(n), not O(whole file).
|
|
29
22
|
*
|
|
30
23
|
* @param filePath Absolute path to a `.jsonl` file.
|
|
31
24
|
* @param n Maximum number of trailing non-empty lines to retain.
|
|
@@ -37,32 +30,23 @@ export declare function readLastNJsonlLines(filePath: string, n: number): string
|
|
|
37
30
|
* Stream-scan a JSONL file once, invoking `onLine` for each non-empty line
|
|
38
31
|
* with the line's raw string and its **starting byte offset** within the file.
|
|
39
32
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* only the tail from that offset via `readJsonlLinesFromOffset` (P2-5
|
|
44
|
-
* byte-offset two-pass: full-file scalar scan without materializing a
|
|
45
|
-
* `string[]`, then tail-only re-parse for events).
|
|
33
|
+
* Memory is O(chunk), not O(whole file). The callback receives the byte offset
|
|
34
|
+
* so callers can record where a line of interest begins, then re-read only the
|
|
35
|
+
* tail from that offset via `readJsonlLinesFromOffset`.
|
|
46
36
|
*
|
|
47
37
|
* @param filePath Absolute path to a `.jsonl` file.
|
|
48
|
-
* @param onLine Called for each non-empty line with `(line, offset)
|
|
49
|
-
* `offset` is the byte offset of the line's first character.
|
|
38
|
+
* @param onLine Called for each non-empty line with `(line, offset)`.
|
|
50
39
|
* @returns `true` if the file was opened and scanned, `false` on open error.
|
|
51
40
|
*/
|
|
52
41
|
export declare function scanJsonlLines(filePath: string, onLine: (line: string, offset: number) => void): boolean;
|
|
53
42
|
/**
|
|
54
43
|
* Read all non-empty lines starting from a byte `offset` in a JSONL file.
|
|
55
44
|
*
|
|
56
|
-
* Companion to `scanJsonlLines` for the
|
|
57
|
-
* pass 1 records the offset where the tail begins (e.g. the byte right after
|
|
58
|
-
* the last user message); pass 2 seeks there and reads/parses only the tail,
|
|
59
|
-
* so raw line-string memory is O(tail) instead of O(whole file).
|
|
45
|
+
* Companion to `scanJsonlLines` for the byte-offset two-pass pattern.
|
|
60
46
|
*
|
|
61
47
|
* @param filePath Absolute path to a `.jsonl` file.
|
|
62
48
|
* @param offset Byte offset to seek to before reading. **Must fall on a line
|
|
63
|
-
* boundary
|
|
64
|
-
* user message as recorded by `scanJsonlLines`); a mid-line
|
|
65
|
-
* offset will include a leading partial line.
|
|
49
|
+
* boundary**; a mid-line offset will include a leading partial line.
|
|
66
50
|
* @returns Array of raw line strings from `offset` to EOF (empty lines
|
|
67
51
|
* excluded). Empty array on open/seek error or `offset` past EOF.
|
|
68
52
|
*/
|
|
@@ -71,7 +55,6 @@ export declare function readJsonlLinesFromOffset(filePath: string, offset: numbe
|
|
|
71
55
|
* Read all non-empty lines from a JSONL file using streaming reads.
|
|
72
56
|
*
|
|
73
57
|
* @param filePath Absolute path to a `.jsonl` file.
|
|
74
|
-
* @param chunkSize Buffer size for each `fs.readSync` call (default 65536).
|
|
75
58
|
* @returns Array of raw line strings (empty lines excluded).
|
|
76
59
|
*/
|
|
77
|
-
export declare function readJsonlLines(filePath: string
|
|
60
|
+
export declare function readJsonlLines(filePath: string): string[];
|