@aiwayds/dsh-tui-pi 2.12.0 → 2.13.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.
- package/README.md +4 -4
- package/README.zh-CN.md +1 -1
- package/lib/history.js +2 -2
- package/lib/history.js.map +1 -1
- package/lib/index.js +17 -8
- package/lib/index.js.map +1 -1
- package/lib/live-widgets.d.ts +25 -9
- package/lib/live-widgets.js +81 -29
- package/lib/live-widgets.js.map +1 -1
- package/lib/log-repair.d.ts +10 -13
- package/lib/log-repair.js +11 -26
- package/lib/log-repair.js.map +1 -1
- package/lib/messages.d.ts +11 -1
- package/lib/messages.js +18 -4
- package/lib/messages.js.map +1 -1
- package/lib/retention.d.ts +10 -4
- package/lib/retention.js +15 -4
- package/lib/retention.js.map +1 -1
- package/lib/session-dir.d.ts +26 -0
- package/lib/session-dir.js +53 -0
- package/lib/session-dir.js.map +1 -0
- package/lib/session.d.ts +37 -44
- package/lib/session.js +167 -232
- package/lib/session.js.map +1 -1
- package/lib/sessions.d.ts +51 -4
- package/lib/sessions.js +45 -3
- package/lib/sessions.js.map +1 -1
- package/package.json +5 -5
- package/lib/writer-lock.d.ts +0 -70
- package/lib/writer-lock.js +0 -206
- package/lib/writer-lock.js.map +0 -1
package/lib/retention.js
CHANGED
|
@@ -148,11 +148,22 @@ export function sessionStoreRoot() {
|
|
|
148
148
|
return join(dshHome(), 'sessions');
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
151
|
-
* Physical log file names the jsonl backend writes
|
|
152
|
-
*
|
|
153
|
-
* (
|
|
151
|
+
* Physical log file names the jsonl backend writes, across format
|
|
152
|
+
* generations: the host names the artifact after its format generation
|
|
153
|
+
* (`session.v<NNN>.jsonl` since the V3 format, `session.jsonl` for the
|
|
154
|
+
* legacy V0 era) plus the compression suffix. Walks that pick ONE file
|
|
155
|
+
* prefer the CURRENT generation over a preserved legacy one — keep the v3
|
|
156
|
+
* names LAST so `locateSessionLog`'s `.slice().reverse()` tries them
|
|
157
|
+
* first. Single source of truth for every walk of the store — the /resume
|
|
158
|
+
* mtime walk (src/sessions.ts) imports this; two private copies already
|
|
159
|
+
* drifted once.
|
|
154
160
|
*/
|
|
155
|
-
export const SESSION_LOG_FILE_NAMES = [
|
|
161
|
+
export const SESSION_LOG_FILE_NAMES = [
|
|
162
|
+
'session.jsonl',
|
|
163
|
+
'session.jsonl.zstd',
|
|
164
|
+
'session.v3.jsonl',
|
|
165
|
+
'session.v3.jsonl.zstd',
|
|
166
|
+
];
|
|
156
167
|
/**
|
|
157
168
|
* Walk `<root>/<project>/<sessionId>/` and stat each session's log. Only
|
|
158
169
|
* DIRECTORIES at the session level are visited: a flat file at the bucket
|
package/lib/retention.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retention.js","sourceRoot":"","sources":["../src/retention.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAyB/C,iDAAiD;AACjD,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAA;AAEtC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAA;AAEvC,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AAC9B,MAAM,MAAM,GAAG,EAAE,GAAG,OAAO,CAAA;AAE3B;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAA;AAE1C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,qBAAqB,GAAG,wBAAwB,GAAG,OAAO,CAAA;AA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CAAC,8BAA8B,MAAM,CAAC,OAAO,YAAY,MAAM,CAAC,MAAM,EAAE;QACzE,CAAC,CAAC,8BAA8B,MAAM,CAAC,OAAO,EAAE,CAAC,CAAA;AACrD,CAAC;AAED,0EAA0E;AAC1E,2EAA2E;AAC3E,yEAAyE;AACzE,qDAAqD;AACrD,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAA;AAEtE;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,OAA6B,EAAE;IAC3E,MAAM,KAAK,GAAG,UAAqC,CAAA;IACnD,IAAI,KAAK,CAAC,iBAAiB,CAAC,KAAK,IAAI;QAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAA;IACvE,KAAK,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAA;IAC/B,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAA;AAClC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session storage directory derivation — where the jsonl backend groups a
|
|
3
|
+
* cwd's sessions, used to LOCATE persisted logs (read-only remote view,
|
|
4
|
+
* corrupt-log repair) without resuming the session.
|
|
5
|
+
*
|
|
6
|
+
* `projectDirectoryFor` is a byte-identical port of upstream `projectKey()`
|
|
7
|
+
* in @deepseek-ai/dsh-session-persistence-jsonl. The derived session dir
|
|
8
|
+
* additionally relies on upstream's `encodeSegment(sessionId)` being the
|
|
9
|
+
* IDENTITY for dsh ids — true while ids are UUIDs (safe charset ⊇ UUID
|
|
10
|
+
* charset). If upstream ever introduces non-UUID ids, port encodeSegment
|
|
11
|
+
* too or derivations land beside decoy paths; update only in lockstep with
|
|
12
|
+
* upstream either way.
|
|
13
|
+
*
|
|
14
|
+
* (Through 0.1.2 this module also vendored the cross-process pid-file
|
|
15
|
+
* writer lock; 0.1.5's host-native `SessionWriteLease` kernel lock on the
|
|
16
|
+
* same directories took that job over and the vendored copy was deleted —
|
|
17
|
+
* see the 0.1.5 migration notes.)
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Project-directory name under which the jsonl backend groups a cwd's
|
|
21
|
+
* sessions — byte-identical port of upstream `projectKey()` in
|
|
22
|
+
* @deepseek-ai/dsh-session-persistence-jsonl.
|
|
23
|
+
*/
|
|
24
|
+
export declare function projectKeyFor(cwd: string): string;
|
|
25
|
+
/** The jsonl backend's directory for one session: `<root>/<projectKey>/<id>`. */
|
|
26
|
+
export declare function sessionDirFor(root: string, cwd: string, sessionId: string): string;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session storage directory derivation — where the jsonl backend groups a
|
|
3
|
+
* cwd's sessions, used to LOCATE persisted logs (read-only remote view,
|
|
4
|
+
* corrupt-log repair) without resuming the session.
|
|
5
|
+
*
|
|
6
|
+
* `projectDirectoryFor` is a byte-identical port of upstream `projectKey()`
|
|
7
|
+
* in @deepseek-ai/dsh-session-persistence-jsonl. The derived session dir
|
|
8
|
+
* additionally relies on upstream's `encodeSegment(sessionId)` being the
|
|
9
|
+
* IDENTITY for dsh ids — true while ids are UUIDs (safe charset ⊇ UUID
|
|
10
|
+
* charset). If upstream ever introduces non-UUID ids, port encodeSegment
|
|
11
|
+
* too or derivations land beside decoy paths; update only in lockstep with
|
|
12
|
+
* upstream either way.
|
|
13
|
+
*
|
|
14
|
+
* (Through 0.1.2 this module also vendored the cross-process pid-file
|
|
15
|
+
* writer lock; 0.1.5's host-native `SessionWriteLease` kernel lock on the
|
|
16
|
+
* same directories took that job over and the vendored copy was deleted —
|
|
17
|
+
* see the 0.1.5 migration notes.)
|
|
18
|
+
*/
|
|
19
|
+
import { join } from 'node:path';
|
|
20
|
+
/**
|
|
21
|
+
* Project-directory name under which the jsonl backend groups a cwd's
|
|
22
|
+
* sessions — byte-identical port of upstream `projectKey()` in
|
|
23
|
+
* @deepseek-ai/dsh-session-persistence-jsonl.
|
|
24
|
+
*/
|
|
25
|
+
export function projectKeyFor(cwd) {
|
|
26
|
+
if (cwd.length === 0)
|
|
27
|
+
throw new Error('cannot encode an empty project path');
|
|
28
|
+
let readable = '';
|
|
29
|
+
let separatorRun = false;
|
|
30
|
+
for (let i = 0; i < cwd.length; i++) {
|
|
31
|
+
const code = cwd.charCodeAt(i);
|
|
32
|
+
const ch = String.fromCharCode(code);
|
|
33
|
+
if (ch === '/' || ch === '\\' || ch === ':') {
|
|
34
|
+
if (!separatorRun)
|
|
35
|
+
readable += '-';
|
|
36
|
+
separatorRun = true;
|
|
37
|
+
}
|
|
38
|
+
else if (ch !== '~' && /^[A-Za-z0-9._-]$/.test(ch)) {
|
|
39
|
+
readable += ch;
|
|
40
|
+
separatorRun = false;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
readable += `~${code.toString(16).toUpperCase().padStart(4, '0')}`;
|
|
44
|
+
separatorRun = false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return `--${(readable.replace(/^-+/, '') || 'root').slice(0, 251)}--`;
|
|
48
|
+
}
|
|
49
|
+
/** The jsonl backend's directory for one session: `<root>/<projectKey>/<id>`. */
|
|
50
|
+
export function sessionDirFor(root, cwd, sessionId) {
|
|
51
|
+
return join(root, projectKeyFor(cwd), sessionId);
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=session-dir.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-dir.js","sourceRoot":"","sources":["../src/session-dir.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;IAC5E,IAAI,QAAQ,GAAG,EAAE,CAAA;IACj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@deepseek-ai/cordis';
|
|
13
13
|
import type { Agent, AgentHandle, ModelSelection } from '@deepseek-ai/dsh-agent';
|
|
14
|
+
import { type StreamChunk } from '@deepseek-ai/dsh-llm';
|
|
14
15
|
import { SessionId, type SessionEvent } from '@deepseek-ai/dsh-session';
|
|
15
16
|
import type { AgentView } from './dsh-events.ts';
|
|
16
17
|
import type { PendingPromptView } from './steer-flow.ts';
|
|
17
18
|
export interface BridgeCallbacks {
|
|
18
19
|
/** One session-log event for the bridge's session, in log order. */
|
|
19
20
|
onEvent(event: SessionEvent): void;
|
|
21
|
+
/**
|
|
22
|
+
* One live streaming delta of the bridge's session, delivered as an
|
|
23
|
+
* `agent/assistant-stream` chunk frame (dsh 0.1.5-rc.1 moved the deltas off
|
|
24
|
+
* the `session/event` firehose; the log only records settlements). The
|
|
25
|
+
* turn/step come from the attempt's start frame. Drives the transcript's
|
|
26
|
+
* typewriter and the think/tool phase machine between settlements.
|
|
27
|
+
*/
|
|
28
|
+
onStreamDelta?(turn: number, step: number, chunk: StreamChunk): void;
|
|
20
29
|
/** Whole-agent lifecycle transition. */
|
|
21
30
|
onStatus(status: 'idle' | 'running'): void;
|
|
22
31
|
/**
|
|
@@ -74,12 +83,6 @@ export declare class DshSessionBridge {
|
|
|
74
83
|
private resuming;
|
|
75
84
|
/** Target id of the in-flight resume — see `resume()`/`getResumingSessionId()`. */
|
|
76
85
|
private resumeTargetId;
|
|
77
|
-
/**
|
|
78
|
-
* Session dirs whose cross-process writer lock THIS bridge established via
|
|
79
|
-
* a cold arm. Release is bound to the owning handle's disposal
|
|
80
|
-
* (`ownWithLock`), so the set itself only tracks double-release safety.
|
|
81
|
-
*/
|
|
82
|
-
private readonly heldLockDirs;
|
|
83
86
|
/** Active cross-process read-only view (see watchRemote). */
|
|
84
87
|
private remoteTail;
|
|
85
88
|
/** Session watched read-only right now. */
|
|
@@ -88,12 +91,8 @@ export declare class DshSessionBridge {
|
|
|
88
91
|
private readonly remoteFollowups;
|
|
89
92
|
private promotingRemote;
|
|
90
93
|
private promoteTimer;
|
|
91
|
-
private idleReleaseTimer;
|
|
92
|
-
/** Writer lock taken for the CURRENTLY bound local agent (see drive arms). */
|
|
93
|
-
private driveLock;
|
|
94
94
|
/** Test seam + tuning for the watcher (interval/decoder injection). */
|
|
95
95
|
private readonly remoteTailOptions;
|
|
96
|
-
private readonly idleReleaseDelayMs;
|
|
97
96
|
private readonly promoteIntervalMs;
|
|
98
97
|
/** Serializes watch-lifecycle ops against the promotion poll. */
|
|
99
98
|
private opChain;
|
|
@@ -193,12 +192,17 @@ export declare class DshSessionBridge {
|
|
|
193
192
|
private readonly trackedSessions;
|
|
194
193
|
/** `${runId}:${seq}` → childId, for `tool-workflow/agent-end` pairing. */
|
|
195
194
|
private readonly runSeqToChild;
|
|
195
|
+
/**
|
|
196
|
+
* Session id → the open attempt's turn/step, pinned by `agent/assistant-stream`
|
|
197
|
+
* start frames so chunk frames (which carry no turn/step) can drive the same
|
|
198
|
+
* fold paths the old firehose `assistant/chunk` events did. Cleared on end.
|
|
199
|
+
*/
|
|
200
|
+
private readonly openAttempts;
|
|
196
201
|
constructor(ctx: Context, callbacks: BridgeCallbacks, options?: {
|
|
197
202
|
remoteTailOptions?: {
|
|
198
203
|
intervalMs?: number;
|
|
199
204
|
decode?(file: string): Promise<string>;
|
|
200
205
|
};
|
|
201
|
-
idleReleaseDelayMs?: number;
|
|
202
206
|
promoteIntervalMs?: number;
|
|
203
207
|
});
|
|
204
208
|
/** Whether a `reconcileLiveWithProjection` pass is already in flight. */
|
|
@@ -288,18 +292,11 @@ export declare class DshSessionBridge {
|
|
|
288
292
|
private watchRemoteInner;
|
|
289
293
|
private stopRemoteWatch;
|
|
290
294
|
/**
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
*/
|
|
297
|
-
private scheduleIdleRelease;
|
|
298
|
-
/**
|
|
299
|
-
* Promote poll tick: viewer + queued follow-ups + watched driver idle →
|
|
300
|
-
* race for the writer lock; winning hands to onRemotePromotable (UI
|
|
301
|
-
* rebuild via resume + queue drain), losing retries next tick. All async
|
|
302
|
-
* sequencing stays in THIS loop — never inside event callbacks.
|
|
295
|
+
* Promote poll tick: viewer + queued follow-ups + watched driver gone →
|
|
296
|
+
* attempt the takeover (onRemotePromotable rebuilds the UI via resume +
|
|
297
|
+
* queue drain); an owned session still refuses the resume and we retry
|
|
298
|
+
* next tick. All async sequencing stays in THIS loop — never inside
|
|
299
|
+
* event callbacks.
|
|
303
300
|
*/
|
|
304
301
|
private maybePromoteRemote;
|
|
305
302
|
private maybePromoteRemoteInner;
|
|
@@ -394,24 +391,6 @@ export declare class DshSessionBridge {
|
|
|
394
391
|
* (fail-open, never locks a decoy), never breaks the resume.
|
|
395
392
|
*/
|
|
396
393
|
private headerCwdOf;
|
|
397
|
-
/**
|
|
398
|
-
* Single-writer guard for COLD arms (create / cold resume) only — the
|
|
399
|
-
* adopt arm above shares the live instance in-process and must stay
|
|
400
|
-
* lock-free. Locks sit beside the jsonl log so every process that could
|
|
401
|
-
* append to it competes on one file; a live foreign holder throws
|
|
402
|
-
* WriterLockedError (surfaces as "Cannot resume <id>: session is locked
|
|
403
|
-
* by a live process …"). `knownCwd` skips the header scan for creations,
|
|
404
|
-
* which always target process.cwd().
|
|
405
|
-
*/
|
|
406
|
-
private acquireSessionLock;
|
|
407
|
-
/** Undo a guard whose arm then failed — transient errors must not pin the session. */
|
|
408
|
-
private releaseColdLock;
|
|
409
|
-
/**
|
|
410
|
-
* Bind lock release to an owned handle's disposal — every teardown path
|
|
411
|
-
* already goes through handle.dispose(), so this is the single choke
|
|
412
|
-
* point; switching away or exiting releases what we established.
|
|
413
|
-
*/
|
|
414
|
-
private ownWithLock;
|
|
415
394
|
/**
|
|
416
395
|
* Tear down the current live binding — the shared prelude of every session
|
|
417
396
|
* switch (resume, fork): stop the remote watch, dispose the handle, clear
|
|
@@ -457,13 +436,27 @@ export declare class DshSessionBridge {
|
|
|
457
436
|
* Replay a persisted session log into the transcript and stats — the second
|
|
458
437
|
* half of a resume (call after `resume()`). Stats are rebuilt from zero so
|
|
459
438
|
* the footer reflects the resumed session only; replaying the same log
|
|
460
|
-
* twice is idempotent.
|
|
461
|
-
* `assistant/message`
|
|
462
|
-
*
|
|
439
|
+
* twice is idempotent. V3 logs carry no streaming chunks at all — the
|
|
440
|
+
* finalized `assistant/message` holds the full text (and its embedded
|
|
441
|
+
* stream, which replay never needs).
|
|
463
442
|
*/
|
|
464
443
|
replay(events: readonly SessionEvent[]): void;
|
|
465
444
|
/** Update incremental stats from one event — one pass over the event only. */
|
|
466
445
|
private applyEvent;
|
|
446
|
+
/**
|
|
447
|
+
* One `agent/assistant-stream` frame of any session in the process (dsh
|
|
448
|
+
* 0.1.5-rc.1 moved the live deltas off the firehose). Chunk frames carry no
|
|
449
|
+
* turn/step — the attempt's start frame pinned them in {@link openAttempts}.
|
|
450
|
+
*/
|
|
451
|
+
private onStreamFrame;
|
|
452
|
+
/**
|
|
453
|
+
* Fold one streaming delta of a tracked CHILD into the live row: the
|
|
454
|
+
* content tail (text AND reasoning — never a tool name, always the child's
|
|
455
|
+
* own output) and the pending-occupancy estimate. The assembled
|
|
456
|
+
* `assistant/message` later replaces the tail with the authoritative last
|
|
457
|
+
* line and resets the estimate against real usage.
|
|
458
|
+
*/
|
|
459
|
+
private foldChildStreamDelta;
|
|
467
460
|
/**
|
|
468
461
|
* The current context-occupancy estimate: the latest assistant/message's
|
|
469
462
|
* billed input (uncached + cache read + cache write) and output, plus the
|