@toddzheng024/dscode-bundle 0.7.12 → 0.7.14
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/THIRD_PARTY_NOTICES.md +3 -3
- package/cordis.patch.yml +6 -2
- package/package.json +7 -5
- package/plugins/code-review/index.mjs +5 -2
- package/plugins/compaction/threshold.mjs +12 -0
- package/plugins/credentials/index.mjs +13 -0
- package/plugins/grok/adapter.mjs +114 -0
- package/plugins/grok/auth.mjs +76 -0
- package/plugins/grok/billing.mjs +146 -0
- package/plugins/grok/index.mjs +118 -0
- package/plugins/grok/models.mjs +129 -0
- package/plugins/grok/status.mjs +28 -0
- package/plugins/grok/wire.mjs +268 -0
- package/plugins/i18n/messages.mjs +6 -6
- package/plugins/providers/catalog.mjs +2 -0
- package/plugins/session-metrics/view.mjs +34 -3
- package/vendor/compaction-basic/index.js +91 -1
- package/vendor/persistent/index.js +10 -9
- package/vendor/terminal/index.js +5 -0
- package/vendor/tui/lib/app.mjs +6711 -0
- package/vendor/tui/lib/approval.mjs +122 -0
- package/vendor/tui/lib/attachments.mjs +218 -0
- package/vendor/tui/lib/authorization-panel.mjs +242 -0
- package/vendor/tui/lib/authorization.mjs +111 -0
- package/vendor/tui/lib/commands.mjs +123 -0
- package/vendor/tui/lib/dscode/chat.mjs +84 -0
- package/vendor/tui/lib/dscode/flags.mjs +32 -0
- package/vendor/tui/lib/dscode/model-search.mjs +68 -0
- package/vendor/tui/lib/dscode/paste.mjs +87 -0
- package/vendor/tui/lib/dscode/telemetry.mjs +82 -0
- package/vendor/tui/lib/dscode/welcome.mjs +100 -0
- package/vendor/tui/lib/editor-keys.mjs +346 -0
- package/vendor/tui/lib/editor.mjs +50 -0
- package/vendor/tui/lib/fork.mjs +24 -0
- package/vendor/tui/lib/git-workflow.mjs +278 -0
- package/vendor/tui/{types/history.d.ts → lib/history.mjs} +69 -26
- package/vendor/tui/{types/i18n.d.ts → lib/i18n.mjs} +23 -15
- package/vendor/tui/lib/index.mjs +2200 -0
- package/vendor/tui/lib/input-split.mjs +170 -0
- package/vendor/tui/lib/internals.mjs +90 -0
- package/vendor/tui/lib/invariant.mjs +22 -0
- package/vendor/tui/lib/kernel-panels.mjs +1265 -0
- package/vendor/tui/lib/keyboard.mjs +283 -0
- package/vendor/tui/lib/language-panel.mjs +41 -0
- package/vendor/tui/lib/locales/en.mjs +495 -0
- package/vendor/tui/lib/locales/zh.mjs +495 -0
- package/vendor/tui/lib/mentions.mjs +150 -0
- package/vendor/tui/lib/model-capabilities.mjs +245 -0
- package/vendor/tui/lib/models.mjs +215 -0
- package/vendor/tui/{types/panel-accent.d.ts → lib/panel-accent.mjs} +11 -7
- package/vendor/tui/lib/permissions.mjs +45 -0
- package/vendor/tui/lib/plugin-inventory.mjs +27 -0
- package/vendor/tui/lib/presets.mjs +46 -0
- package/vendor/tui/lib/provider-settings.mjs +600 -0
- package/vendor/tui/lib/questions.mjs +116 -0
- package/vendor/tui/lib/rainbow.mjs +181 -0
- package/vendor/tui/lib/render/animations.mjs +665 -0
- package/vendor/tui/lib/render/editor.mjs +437 -0
- package/vendor/tui/lib/render/export.mjs +119 -0
- package/vendor/tui/lib/render/fuzzy.mjs +79 -0
- package/vendor/tui/lib/render/ime-cursor.mjs +135 -0
- package/vendor/tui/lib/render/inspector.mjs +93 -0
- package/vendor/tui/lib/render/lines.mjs +538 -0
- package/vendor/tui/lib/render/markdown.mjs +592 -0
- package/vendor/tui/lib/render/projection.mjs +1864 -0
- package/vendor/tui/lib/render/status.mjs +591 -0
- package/vendor/tui/lib/render/text.mjs +157 -0
- package/vendor/tui/lib/render/tool-detail.mjs +187 -0
- package/vendor/tui/lib/render/tool-preview.mjs +79 -0
- package/vendor/tui/lib/render/usage.mjs +336 -0
- package/vendor/tui/lib/render/width.mjs +191 -0
- package/vendor/tui/lib/session-directory.mjs +329 -0
- package/vendor/tui/lib/session-query.mjs +184 -0
- package/vendor/tui/lib/session-switch.mjs +51 -0
- package/vendor/tui/lib/settings-file.mjs +75 -0
- package/vendor/tui/lib/skills.mjs +119 -0
- package/vendor/tui/lib/startup.mjs +111 -0
- package/vendor/tui/lib/store.mjs +129 -0
- package/vendor/tui/lib/subagents.mjs +200 -0
- package/vendor/tui/lib/terminal-title.mjs +186 -0
- package/vendor/tui/lib/theme-panel.mjs +60 -0
- package/vendor/tui/lib/theme.mjs +379 -0
- package/vendor/tui/lib/update-panel.mjs +239 -0
- package/vendor/tui/lib/update.mjs +101 -0
- package/vendor/tui/lib/version.mjs +105 -0
- package/vendor/tui/lib/whale-glyph.mjs +20 -0
- package/vendor/tui/LICENSE +0 -21
- package/vendor/tui/devtools-CdTl3MNy.mjs +0 -3643
- package/vendor/tui/dscode-email/cli.mjs +0 -32
- package/vendor/tui/dscode-email/contacts.mjs +0 -36
- package/vendor/tui/dscode-email/gmail-oauth.mjs +0 -69
- package/vendor/tui/dscode-email/gmail-store.mjs +0 -2
- package/vendor/tui/dscode-email/gmail.mjs +0 -194
- package/vendor/tui/dscode-email/imap.mjs +0 -136
- package/vendor/tui/dscode-email/inbox.d.mts +0 -25
- package/vendor/tui/dscode-email/inbox.mjs +0 -76
- package/vendor/tui/dscode-email/smtp.mjs +0 -69
- package/vendor/tui/dscode-email/store.mjs +0 -32
- package/vendor/tui/dscode-providers/catalog.mjs +0 -136
- package/vendor/tui/dscode-providers/effort.mjs +0 -35
- package/vendor/tui/dscode-providers/openrouter-account.mjs +0 -171
- package/vendor/tui/index.mjs +0 -44441
- package/vendor/tui/invariant.mjs +0 -21
- package/vendor/tui/rolldown-runtime-CMFfr-1z.mjs +0 -26
- package/vendor/tui/session-query.mjs +0 -150
- package/vendor/tui/startup.mjs +0 -109
- package/vendor/tui/theme-7u5Qo3dF.mjs +0 -1265
- package/vendor/tui/types/app.d.ts +0 -348
- package/vendor/tui/types/approval.d.ts +0 -59
- package/vendor/tui/types/attachments.d.ts +0 -52
- package/vendor/tui/types/authorization-panel.d.ts +0 -22
- package/vendor/tui/types/authorization.d.ts +0 -36
- package/vendor/tui/types/commands.d.ts +0 -52
- package/vendor/tui/types/editor-keys.d.ts +0 -105
- package/vendor/tui/types/editor.d.ts +0 -6
- package/vendor/tui/types/fork.d.ts +0 -8
- package/vendor/tui/types/git-workflow.d.ts +0 -121
- package/vendor/tui/types/index.d.ts +0 -223
- package/vendor/tui/types/input-split.d.ts +0 -54
- package/vendor/tui/types/internals.d.ts +0 -26
- package/vendor/tui/types/invariant.d.ts +0 -15
- package/vendor/tui/types/kernel-panels.d.ts +0 -245
- package/vendor/tui/types/keyboard.d.ts +0 -80
- package/vendor/tui/types/language-panel.d.ts +0 -12
- package/vendor/tui/types/locales/en.d.ts +0 -450
- package/vendor/tui/types/locales/zh.d.ts +0 -9
- package/vendor/tui/types/mentions.d.ts +0 -85
- package/vendor/tui/types/model-capabilities.d.ts +0 -82
- package/vendor/tui/types/models.d.ts +0 -133
- package/vendor/tui/types/permissions.d.ts +0 -27
- package/vendor/tui/types/plugin-inventory.d.ts +0 -11
- package/vendor/tui/types/presets.d.ts +0 -22
- package/vendor/tui/types/provider-settings.d.ts +0 -239
- package/vendor/tui/types/questions.d.ts +0 -54
- package/vendor/tui/types/rainbow.d.ts +0 -69
- package/vendor/tui/types/render/animations.d.ts +0 -307
- package/vendor/tui/types/render/editor.d.ts +0 -163
- package/vendor/tui/types/render/export.d.ts +0 -9
- package/vendor/tui/types/render/fuzzy.d.ts +0 -21
- package/vendor/tui/types/render/ime-cursor.d.ts +0 -60
- package/vendor/tui/types/render/inspector.d.ts +0 -62
- package/vendor/tui/types/render/lines.d.ts +0 -86
- package/vendor/tui/types/render/markdown.d.ts +0 -29
- package/vendor/tui/types/render/projection.d.ts +0 -587
- package/vendor/tui/types/render/status.d.ts +0 -196
- package/vendor/tui/types/render/text.d.ts +0 -64
- package/vendor/tui/types/render/tool-detail.d.ts +0 -94
- package/vendor/tui/types/render/tool-preview.d.ts +0 -28
- package/vendor/tui/types/render/usage.d.ts +0 -113
- package/vendor/tui/types/render/width.d.ts +0 -29
- package/vendor/tui/types/session-directory.d.ts +0 -190
- package/vendor/tui/types/session-query.d.ts +0 -92
- package/vendor/tui/types/session-switch.d.ts +0 -17
- package/vendor/tui/types/settings-file.d.ts +0 -41
- package/vendor/tui/types/skills.d.ts +0 -47
- package/vendor/tui/types/startup.d.ts +0 -65
- package/vendor/tui/types/store.d.ts +0 -58
- package/vendor/tui/types/subagents.d.ts +0 -70
- package/vendor/tui/types/terminal-title.d.ts +0 -66
- package/vendor/tui/types/theme-panel.d.ts +0 -24
- package/vendor/tui/types/theme.d.ts +0 -434
- package/vendor/tui/types/update-panel.d.ts +0 -49
- package/vendor/tui/types/update.d.ts +0 -75
- package/vendor/tui/types/version.d.ts +0 -19
- package/vendor/tui/types/whale-glyph.d.ts +0 -6
- /package/vendor/tui/{dscode-clipboard-image → lib/dscode/clipboard-image}/clipboard-image.swift +0 -0
- /package/vendor/tui/{dscode-clipboard-image → lib/dscode/clipboard-image}/index.mjs +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
// dscode-compaction-prefetch-v1
|
|
1
2
|
// dscode-compaction-threshold-v1
|
|
2
|
-
import { pricedCompactionPolicy as dscodePricedCompactionPolicy } from "../../plugins/compaction/threshold.mjs";
|
|
3
|
+
import { prefetchThresholdTokens as dscodePrefetchThresholdTokens, pricedCompactionPolicy as dscodePricedCompactionPolicy } from "../../plugins/compaction/threshold.mjs";
|
|
3
4
|
import z from "@deepseek-ai/schemastery";
|
|
4
5
|
import { CompactionEngine, CompactionId, ManualCompactionError, compactCheckpointSource, toolPairingBalancedAfter, toolPairingBalancedBefore } from "@deepseek-ai/dsh-compaction";
|
|
5
6
|
import { BlockAssembler, CONTEXT_WINDOW_EXCEEDED_CODE, LlmError, contentHasImage, createUserMessage, errorChain } from "@deepseek-ai/dsh-llm";
|
|
@@ -900,6 +901,7 @@ var BasicCompactionEngine = class extends CompactionEngine {
|
|
|
900
901
|
const targetKey = `${target.provider}/${target.model}`;
|
|
901
902
|
if (context === void 0) throw new TargetPressureConfigError(targetKey, `compaction-basic: no context capacity for ${targetKey}; configure contextWindow on that adapter model`);
|
|
902
903
|
const spec = resolveCompactSpec(await dscodePricedCompactionPolicy(this.config, policy), context.contextWindow);
|
|
904
|
+
this.dscodePlanPrefetch(agent, measurement, spec, context.contextWindow, signal);
|
|
903
905
|
if (measurement.totalTokens < spec.thresholdTokens) return null;
|
|
904
906
|
if (prune !== void 0) {
|
|
905
907
|
prune.pruneSession(agent.session);
|
|
@@ -907,6 +909,12 @@ var BasicCompactionEngine = class extends CompactionEngine {
|
|
|
907
909
|
}
|
|
908
910
|
if (measurement.totalTokens < spec.thresholdTokens) return null;
|
|
909
911
|
let result = null;
|
|
912
|
+
const dscodePrefetched = await this.dscodeCommitPrefetch(agent);
|
|
913
|
+
if (dscodePrefetched !== null) {
|
|
914
|
+
result = dscodePrefetched;
|
|
915
|
+
measurement = meter.measure(agent.session);
|
|
916
|
+
if (measurement.totalTokens < spec.thresholdTokens) return result;
|
|
917
|
+
}
|
|
910
918
|
for (let attempt = 0; attempt <= spec.compactionRetries; attempt += 1) {
|
|
911
919
|
const range = selectCompactableRange(agent.session, measurement, spec.retainTokens);
|
|
912
920
|
if (range === null) {
|
|
@@ -971,6 +979,88 @@ var BasicCompactionEngine = class extends CompactionEngine {
|
|
|
971
979
|
throw new ManualCompactionError("busy", "manual compaction requires an idle agent with no waking queued work", { cause: error });
|
|
972
980
|
}
|
|
973
981
|
}
|
|
982
|
+
/** dscode: the one background prefetch this engine may hold per session. */
|
|
983
|
+
dscodePrefetch = /* @__PURE__ */ new WeakMap();
|
|
984
|
+
/**
|
|
985
|
+
* dscode: start one background summarization of the oldest compactable span once the
|
|
986
|
+
* measured pressure crosses the prefetch mark, one lead below the priced threshold.
|
|
987
|
+
* Nothing is appended and no compaction lock is taken, so an invalidated or cancelled
|
|
988
|
+
* prefetch costs only the summarization call.
|
|
989
|
+
* @param agent - agent whose pressure the caller just priced.
|
|
990
|
+
* @param measurement - the measurement the caller priced.
|
|
991
|
+
* @param spec - the caller's resolved spec for this route.
|
|
992
|
+
* @param contextWindow - the route's context window.
|
|
993
|
+
* @param signal - live turn signal forwarded to the summarizer.
|
|
994
|
+
*/
|
|
995
|
+
dscodePlanPrefetch(agent, measurement, spec, contextWindow, signal) {
|
|
996
|
+
const session = agent.session;
|
|
997
|
+
const existing = this.dscodePrefetch.get(session);
|
|
998
|
+
if (existing !== void 0) {
|
|
999
|
+
if (existing.failure === null) return;
|
|
1000
|
+
this.dscodePrefetch.delete(session);
|
|
1001
|
+
}
|
|
1002
|
+
if (measurement.totalTokens >= spec.thresholdTokens) return;
|
|
1003
|
+
if (measurement.totalTokens < dscodePrefetchThresholdTokens(spec.thresholdTokens, contextWindow)) return;
|
|
1004
|
+
if (inspectCompactionEntryState(session).unmatchedCompactionStart !== void 0) return;
|
|
1005
|
+
const range = selectCompactableRange(session, measurement, spec.retainTokens);
|
|
1006
|
+
if (range === null) return;
|
|
1007
|
+
let selection;
|
|
1008
|
+
try {
|
|
1009
|
+
selection = validateSurfaceRegion(session, range.start, range.end);
|
|
1010
|
+
} catch (error) {
|
|
1011
|
+
return;
|
|
1012
|
+
}
|
|
1013
|
+
const prefetch = { compactionId: CompactionId(randomUUID()), summarized: null, failure: null, wait: null };
|
|
1014
|
+
this.dscodePrefetch.set(session, prefetch);
|
|
1015
|
+
prefetch.wait = (async () => {
|
|
1016
|
+
try {
|
|
1017
|
+
prefetch.summarized = await summarizeCompaction(this.regionDependencies(), prepareCompaction(this.regionDependencies(), session, selection), agent, prefetch.compactionId, void 0, signal);
|
|
1018
|
+
} catch (error) {
|
|
1019
|
+
prefetch.failure = error;
|
|
1020
|
+
}
|
|
1021
|
+
})();
|
|
1022
|
+
}
|
|
1023
|
+
/**
|
|
1024
|
+
* dscode: commit the pending prefetch, or return null so the caller summarizes afresh.
|
|
1025
|
+
* A finished summary is validated before the durable marker opens; one still running
|
|
1026
|
+
* opens the marker first, so its wait carries the ordinary compaction indicator.
|
|
1027
|
+
* Commit replaces the prefetched span with its checkpoint and leaves everything
|
|
1028
|
+
* appended after it verbatim.
|
|
1029
|
+
* @param agent - agent whose pressure triggered the automatic compaction.
|
|
1030
|
+
* @returns the committed compaction result, or null when no prefetch was usable.
|
|
1031
|
+
*/
|
|
1032
|
+
async dscodeCommitPrefetch(agent) {
|
|
1033
|
+
const session = agent.session;
|
|
1034
|
+
const prefetch = this.dscodePrefetch.get(session);
|
|
1035
|
+
if (prefetch === void 0) return null;
|
|
1036
|
+
this.dscodePrefetch.delete(session);
|
|
1037
|
+
if (prefetch.failure !== null) return null;
|
|
1038
|
+
const dependencies = this.regionDependencies();
|
|
1039
|
+
if (prefetch.summarized !== null) try {
|
|
1040
|
+
assertSelectedSpanStable(dependencies, session, prefetch.summarized);
|
|
1041
|
+
} catch (error) {
|
|
1042
|
+
return null;
|
|
1043
|
+
}
|
|
1044
|
+
const openTurn = inspectCompactionEntryState(session).openTurn;
|
|
1045
|
+
const lifecycle = {
|
|
1046
|
+
compactionId: prefetch.compactionId,
|
|
1047
|
+
...openTurn === null ? {} : { turn: openTurn }
|
|
1048
|
+
};
|
|
1049
|
+
const startEvent = session.append("compaction/start", lifecycle);
|
|
1050
|
+
let closing = false;
|
|
1051
|
+
try {
|
|
1052
|
+
await prefetch.wait;
|
|
1053
|
+
if (prefetch.failure !== null) throw prefetch.failure;
|
|
1054
|
+
assertSelectedSpanStable(dependencies, session, prefetch.summarized);
|
|
1055
|
+
const pending = commitCompactionBody(session, startEvent, prefetch.summarized);
|
|
1056
|
+
closing = true;
|
|
1057
|
+
const endEvent = session.append("compaction/end", lifecycle);
|
|
1058
|
+
return completeCompaction(pending, endEvent);
|
|
1059
|
+
} catch (error) {
|
|
1060
|
+
if (!closing) session.append("compaction/end", { ...lifecycle, error: errorChain(error) });
|
|
1061
|
+
return null;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
974
1064
|
/** Bind the effective token meter and dynamically dispatched summarizer hook. */
|
|
975
1065
|
regionDependencies() {
|
|
976
1066
|
return {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// dscode-shell-capture-v1
|
|
1
2
|
// dscode-stdin-stall-v2
|
|
2
3
|
const STDIN_STALL_MS = 5000;
|
|
3
4
|
const STDIN_STALL_NOTE = "\n[Interrupted after 5s with no output: the command held the terminal without producing anything, and this tool cannot supply terminal input. Give it stdin (a heredoc, `< file` or `< /dev/null`) or use a non-interactive form.]";
|
|
@@ -174,7 +175,8 @@ function renderShellExitStatus(content, exitCode, signal) {
|
|
|
174
175
|
* @returns the complete model-facing result.
|
|
175
176
|
*/
|
|
176
177
|
async function respondToSessionExit(ctx, shells, owner, id, status, marker, fallback, fallbackTruncated, config) {
|
|
177
|
-
const
|
|
178
|
+
const window = ctx.terminals.read(owner, id, { capture: true });
|
|
179
|
+
const snapshot = window.text.length > 0 ? window : retainedScrollback(ctx, owner, id);
|
|
178
180
|
await shells.reset(owner, "persistent bash shell exited");
|
|
179
181
|
return [renderShellExitStatus(renderCaptured(partialOutput(snapshot, marker, fallback, fallbackTruncated), config.maxOutputChars), status.exitCode, status.signal), SHELL_RESET_MESSAGE].filter((part) => part.length > 0).join("\n");
|
|
180
182
|
}
|
|
@@ -272,6 +274,7 @@ async function executeCommand(ctx, shells, owner, command, config, upstream) {
|
|
|
272
274
|
try {
|
|
273
275
|
operation = ctx.terminals.startSend(owner, id, {
|
|
274
276
|
text: first ? wrapped : "",
|
|
277
|
+
capture: first,
|
|
275
278
|
submit: first,
|
|
276
279
|
signal: commandDeadline.signal
|
|
277
280
|
});
|
|
@@ -284,13 +287,11 @@ async function executeCommand(ctx, shells, owner, command, config, upstream) {
|
|
|
284
287
|
const incremental = operation.readOutput();
|
|
285
288
|
fallback = incremental.delta.length > 0 ? fallback + incremental.delta : result.viewport;
|
|
286
289
|
fallbackTruncated ||= incremental.truncated || result.truncated;
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
count: SCROLLBACK_PAGE_LINES
|
|
290
|
-
});
|
|
290
|
+
const captured = ctx.terminals.read(owner, id, { capture: true });
|
|
291
|
+
fallbackTruncated ||= captured.truncated;
|
|
291
292
|
const timedOut = timeoutOf(commandDeadline.signal, TIMEOUT_CODE);
|
|
292
293
|
if (timedOut !== void 0) {
|
|
293
|
-
const partial = renderCaptured(partialOutput(
|
|
294
|
+
const partial = renderCaptured(partialOutput(captured, marker, fallback, fallbackTruncated), config.maxOutputChars);
|
|
294
295
|
await shells.reset(owner, "persistent bash command timed out");
|
|
295
296
|
return [
|
|
296
297
|
`Your command timed out after ${Math.round(timedOut.timeoutMs / 1e3)} seconds or experienced an OOM error. Below is partial output:`,
|
|
@@ -302,12 +303,12 @@ async function executeCommand(ctx, shells, owner, command, config, upstream) {
|
|
|
302
303
|
await shells.reset(owner, "persistent bash command aborted");
|
|
303
304
|
commandDeadline.signal.throwIfAborted();
|
|
304
305
|
}
|
|
305
|
-
if (
|
|
306
|
-
const complete = commandOutput(
|
|
306
|
+
if (captured.text.includes(marker.end)) {
|
|
307
|
+
const complete = commandOutput(captured, marker);
|
|
307
308
|
if (complete !== void 0) return renderCaptured(complete, config.maxOutputChars) + (stdinStalled ? STDIN_STALL_NOTE : "");
|
|
308
309
|
}
|
|
309
310
|
if (result.sessionStatus.kind === "exited") return await respondToSessionExit(ctx, shells, owner, id, result.sessionStatus, marker, fallback, fallbackTruncated, config);
|
|
310
|
-
const partial = renderCaptured(partialOutput(
|
|
311
|
+
const partial = renderCaptured(partialOutput(captured, marker, fallback, fallbackTruncated), config.maxOutputChars);
|
|
311
312
|
if (result.waitReason === "stdin_read") stdinWaited = true;
|
|
312
313
|
if (result.waitReason === "stdin_read" && partial.length > 0) return partial;
|
|
313
314
|
if (stdinWaited && partial.length === 0 && !stdinStalled && Date.now() - startedAt >= STDIN_STALL_MS) {
|
package/vendor/terminal/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// dscode-shell-capture-v1
|
|
1
2
|
// dscode-no-history-expansion-v1
|
|
2
3
|
import { createRequire } from "node:module";
|
|
3
4
|
import { TerminalBackendCleanupError, TerminalError } from "@deepseek-ai/dsh-terminal";
|
|
@@ -254,6 +255,7 @@ function utf8Tail(text, maxBytes) {
|
|
|
254
255
|
truncated: true
|
|
255
256
|
};
|
|
256
257
|
}
|
|
258
|
+
const CAPTURE_MAX_BYTES = 4194304;
|
|
257
259
|
var BoundedTextBuffer = class {
|
|
258
260
|
maxBytes;
|
|
259
261
|
maxLines;
|
|
@@ -454,6 +456,7 @@ var LocalPtySession = class {
|
|
|
454
456
|
if (this.statusValue.kind === "exited") throw new Error("PTY session has exited");
|
|
455
457
|
if (this.active !== void 0) throw new TerminalError(`PTY session already has an active send${this.activeWrite !== void 0 ? " or draining provider write" : this.interrupting !== void 0 ? " or draining foreground interrupt" : ""}`, "SEND_ACTIVE");
|
|
456
458
|
if (request.signal?.aborted === true) throw new Error("PTY send aborted before write");
|
|
459
|
+
if (request.capture === true) this.capture = new BoundedTextBuffer(CAPTURE_MAX_BYTES);
|
|
457
460
|
const operation = new LocalSendOperation(this.config.maxReadBytes, Date.now(), () => {
|
|
458
461
|
this.interrupt(operation);
|
|
459
462
|
});
|
|
@@ -520,6 +523,7 @@ var LocalPtySession = class {
|
|
|
520
523
|
this.promptTail = "";
|
|
521
524
|
}
|
|
522
525
|
read(request) {
|
|
526
|
+
if (request.capture === true) return this.capture?.snapshot() ?? { text: "", truncated: false };
|
|
523
527
|
const snapshot = this.scrollback.snapshot();
|
|
524
528
|
const lines = snapshot.text.split("\n");
|
|
525
529
|
const totalLines = snapshot.text.length === 0 ? 0 : lines.length;
|
|
@@ -625,6 +629,7 @@ var LocalPtySession = class {
|
|
|
625
629
|
if (text.length === 0) return;
|
|
626
630
|
this.lastOutputAt = Date.now();
|
|
627
631
|
this.scrollback.append(text);
|
|
632
|
+
this.capture?.append(text);
|
|
628
633
|
this.active?.append(text);
|
|
629
634
|
}
|
|
630
635
|
schedulePoll(operation, delayMs = this.config.pollIntervalMs) {
|