@askdkc/dsh-cli 0.13.0 → 0.13.1
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/lib/types/dsh-adapter/channel/session-fork.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel/session-fork.js +2 -4
- package/lib/types/dsh-adapter/plugin.js +1 -15
- package/lib/types/sessionHistory.d.ts +2 -0
- package/lib/types/sessionHistory.d.ts.map +1 -1
- package/lib/types/sessionHistory.js +8 -0
- package/node_modules/@askdkc/dsh-auth/lib/opencode-adapter.js +11 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-fork.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/channel/session-fork.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAsB,MAAM,wBAAwB,CAAA;AAC7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAa,KAAK,OAAO,EAAqB,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"session-fork.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/channel/session-fork.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAsB,MAAM,wBAAwB,CAAA;AAC7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAa,KAAK,OAAO,EAAqB,MAAM,0BAA0B,CAAA;AAUrF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,KAAK,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,SAAS,GAAG,KAAK,GAAG,UAAU,GAAG,OAAO,GAAG,cAAc,CAAC,CAAA;AAE9F,8EAA8E;AAC9E,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE;IACJ,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAA;IACpC,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACjC,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAA;IAC9B,MAAM,IAAI,OAAO,CAAA;IACjB,oBAAoB,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,WAAW,CAAC;QAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC,CAAA;CACrH,SAEgB,OAAO,CAAC,OAAO,CAAC,CAiFlC"}
|
|
@@ -2,6 +2,7 @@ import { SessionId } from '@deepseek-ai/dsh-session';
|
|
|
2
2
|
import { randomUUID } from 'node:crypto';
|
|
3
3
|
import { t } from '../../i18n.js';
|
|
4
4
|
import { resolveDshProfileName } from '../../update.js';
|
|
5
|
+
import { resumeCommand } from '../../sessionHistory.js';
|
|
5
6
|
import { appendSessionTitle, liveSessionCreateOptions, sliceLiveSessionSeed } from '../compat/index.js';
|
|
6
7
|
import { composePreset, runningPresetOf } from '../presets.js';
|
|
7
8
|
import { attachSessionToWorkspace } from '../workspace.js';
|
|
@@ -98,10 +99,7 @@ export function createForkSessionAction(ctx, state, deps) {
|
|
|
98
99
|
reservation.abandon();
|
|
99
100
|
}
|
|
100
101
|
const profile = resolveDshProfileName();
|
|
101
|
-
const
|
|
102
|
-
const command = process.platform === 'win32'
|
|
103
|
-
? `dsh-tui --resume ${childId}`
|
|
104
|
-
: `DSH_TUI_RESUME_SESSION=${childId} ${boot}`;
|
|
102
|
+
const command = resumeCommand(profile, String(childId));
|
|
105
103
|
deps.notify(t('fork-done', { id: String(childId), command }), { timeoutMs: 8000 });
|
|
106
104
|
return true;
|
|
107
105
|
};
|
|
@@ -27,7 +27,7 @@ import { readEffortPref } from '../effortPrefs.js';
|
|
|
27
27
|
import { composePreset, filterMinimalPresetTools, resolvePersistedPreset, resolvePersistedRoute, runningPresetOf } from './presets.js';
|
|
28
28
|
import { registerBundledPresets } from './bundled-presets.js';
|
|
29
29
|
import { registerTuiSessionEventTypes, snapshotLiveSessionEvents } from './compat/index.js';
|
|
30
|
-
import { clearResumeTarget, resumeTargetFromArgv, writeResumeTarget } from '../sessionHistory.js';
|
|
30
|
+
import { clearResumeTarget, resumeCommand, resumeTargetFromArgv, writeResumeTarget } from '../sessionHistory.js';
|
|
31
31
|
import { readHomePrefs } from '../homePrefs.js';
|
|
32
32
|
import { resolveSessionCwd } from '../utils/workspaceRoot.js';
|
|
33
33
|
import { beginRestartAttempt, checkForTuiUpdate, installedTuiVersion, isBootDeadlockTarget, isStandaloneRuntime, isVersionNewer, logRestartEvent, resolveDshProfileName, resolveTuiUpdateTarget, restartTui, updateTuiAndRestart, writeHandoffNotice } from '../update.js';
|
|
@@ -1975,20 +1975,6 @@ export function handleStartupError(ctx, error) {
|
|
|
1975
1975
|
function disposeRootAndExit(ctx, code) {
|
|
1976
1976
|
disposeRootAndThen(ctx, () => process.exit(code), code);
|
|
1977
1977
|
}
|
|
1978
|
-
/**
|
|
1979
|
-
* The real way back into a session after the TUI process is gone. The
|
|
1980
|
-
* package ships no `dsh-tui` bin — resuming means feeding the session id
|
|
1981
|
-
* through `DSH_TUI_RESUME_SESSION` (what cordis.patch.yml's `sessionId`
|
|
1982
|
-
* reads) and
|
|
1983
|
-
* booting the same profile; on Windows the repo's dsh-tui.cmd wrapper
|
|
1984
|
-
* does this via --resume + ~/.dsh-tui/resume.txt.
|
|
1985
|
-
*/
|
|
1986
|
-
function resumeCommand(profile, sessionId) {
|
|
1987
|
-
const boot = profile === undefined ? 'dsh --config cordis.yml' : `dsh --profile ${profile}`;
|
|
1988
|
-
return process.platform === 'win32'
|
|
1989
|
-
? `dsh-tui --resume ${sessionId}`
|
|
1990
|
-
: `DSH_TUI_RESUME_SESSION=${sessionId} ${boot}`;
|
|
1991
|
-
}
|
|
1992
1978
|
/**
|
|
1993
1979
|
* Dispose the Cordis tree, then run a process-level handoff action. The
|
|
1994
1980
|
* fallback exit keeps the caller's intended code when disposal stalls — the
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** Render exit and fork guidance using the installed CLI for its own profile. */
|
|
2
|
+
export declare function resumeCommand(profile: string | undefined, sessionId: string, platform?: NodeJS.Platform): string;
|
|
1
3
|
/**
|
|
2
4
|
* Store the session to resume and report the launcher invocation.
|
|
3
5
|
* @param sessionId - Session id for `dsh-tui --resume` on the next launch.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessionHistory.d.ts","sourceRoot":"","sources":["../../src/sessionHistory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sessionHistory.d.ts","sourceRoot":"","sources":["../../src/sessionHistory.ts"],"names":[],"mappings":"AAoBA,iFAAiF;AACjF,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,kBAAmB,GAAG,MAAM,CAMjH;AAuBD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAGzD;AAED,qEAAqE;AACrE,wBAAgB,iBAAiB,IAAI,IAAI,CAMxC;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAOrD;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAehF;AAED;;;GAGG;AACH,wBAAgB,YAAY,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAyB/D;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAUpD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAYrD;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAiBxE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAQ7D;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAU9D"}
|
|
@@ -16,6 +16,14 @@ const RESUME_FILE = join(DIR, 'resume.txt');
|
|
|
16
16
|
const LAST_USED_FILE = join(DIR, 'last-used.json');
|
|
17
17
|
let lastUsedStamp;
|
|
18
18
|
let lastUsedCache;
|
|
19
|
+
/** Render exit and fork guidance using the installed CLI for its own profile. */
|
|
20
|
+
export function resumeCommand(profile, sessionId, platform = process.platform) {
|
|
21
|
+
const boot = profile === 'dsh-cli' ? 'dsh-cli'
|
|
22
|
+
: profile === undefined ? 'dsh --config cordis.yml' : `dsh --profile ${profile}`;
|
|
23
|
+
return platform === 'win32'
|
|
24
|
+
? `${boot} --resume ${sessionId}`
|
|
25
|
+
: `DSH_TUI_RESUME_SESSION=${sessionId} ${boot}`;
|
|
26
|
+
}
|
|
19
27
|
function lastUsedFileStamp() {
|
|
20
28
|
try {
|
|
21
29
|
const stats = statSync(LAST_USED_FILE);
|
|
@@ -158,13 +158,22 @@ export class OpenCodeAdapter extends LlmAdapter {
|
|
|
158
158
|
}
|
|
159
159
|
const input = part.usage.inputTokens;
|
|
160
160
|
const output = part.usage.outputTokens;
|
|
161
|
-
|
|
161
|
+
// DSH snapshots chunks losslessly: optional SDK values must be absent,
|
|
162
|
+
// not own properties containing undefined. Preserve reported zeroes.
|
|
163
|
+
yield { type: 'usage', usage: {
|
|
164
|
+
inputTokens: input.noCache ?? Math.max(0, (input.total ?? 0) - (input.cacheRead ?? 0) - (input.cacheWrite ?? 0)),
|
|
165
|
+
outputTokens: output.total ?? 0,
|
|
166
|
+
...(input.cacheRead !== undefined ? { cacheReadTokens: input.cacheRead } : {}),
|
|
167
|
+
...(input.cacheWrite !== undefined ? { cacheWriteTokens: input.cacheWrite } : {}),
|
|
168
|
+
...(output.reasoning !== undefined ? { reasoningTokens: output.reasoning } : {}),
|
|
169
|
+
...(input.total !== undefined && output.total !== undefined ? { totalTokens: input.total + output.total } : {}),
|
|
170
|
+
} };
|
|
162
171
|
if (!blocks.size)
|
|
163
172
|
throw new LlmError('OpenCode returned no content', 'EMPTY_RESPONSE');
|
|
164
173
|
const finish = part.finishReason.unified;
|
|
165
174
|
if (finish === 'error' || finish === 'content-filter' || finish === 'other')
|
|
166
175
|
throw new LlmError(`OpenCode generation ended: ${finish}`, 'PROVIDER_ERROR');
|
|
167
|
-
yield { type: 'finish', reason: { kind: finish === 'tool-calls' ? 'tool-calls' : finish === 'length' ? 'max-tokens' : 'stop' }, replayState: { response: { kind: 'dsh-opencode', version: 1, protocol: descriptor.protocol, provider: options.provider, model: descriptor.id, responseId }, blocks: [...blocks.values()].map(entry => ({ type: entry.block.type, ...(entry.providerOptions ? { providerOptions: entry.providerOptions } : {}) })) } };
|
|
176
|
+
yield { type: 'finish', reason: { kind: finish === 'tool-calls' ? 'tool-calls' : finish === 'length' ? 'max-tokens' : 'stop' }, replayState: { response: { kind: 'dsh-opencode', version: 1, protocol: descriptor.protocol, provider: options.provider, model: descriptor.id, ...(responseId !== undefined ? { responseId } : {}) }, blocks: [...blocks.values()].map(entry => ({ type: entry.block.type, ...(entry.providerOptions ? { providerOptions: entry.providerOptions } : {}) })) } };
|
|
168
177
|
return;
|
|
169
178
|
}
|
|
170
179
|
}
|