scream-code 0.13.2 → 0.13.4

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.
@@ -4,8 +4,8 @@ import { dirname as __cjsShimDirname } from 'node:path';
4
4
  const __filename = __cjsShimFileURLToPath(import.meta.url);
5
5
  const __dirname = __cjsShimDirname(__filename);
6
6
  import "./suppress-sqlite-warning-C2VB0doZ.mjs";
7
- import { $ as toTerminalHyperlink, $t as stringValue, A as highlightLines, An as DEFAULT_CATALOG_URL, At as ENABLE_TERMINAL_THEME_REPORTING, B as AssistantMessageComponent, Bn as isScreamError, Bt as isBusy, C as UserMessageComponent, Cn as getInputHistoryFile, Ct as contrastTextHex, D as ToolCallComponent, Dn as CLI_UI_MODE, Dt as DISABLE_TERMINAL_FOCUS_REPORTING, E as toggleEmptySessionHint, En as CLI_COMMAND_NAME, Et as parseOsc11BackgroundTheme, F as getSharedSpeedTracker, Fn as resolveScreamHome, Ft as QUERY_TERMINAL_THEME, G as resetBreathingClock, Gt as printableChar, H as WelcomeComponent, Hn as ErrorCodes, Ht as FooterComponent, I as SkillActivationComponent, In as MemoryMemoStore, It as TERMINAL_FOCUS_IN, Jt as argsRecord, K as clearGoalState, Kt as STATUS_BULLET, L as ReadGroupComponent, Ln as flushDiagnosticLogs, Lt as TERMINAL_FOCUS_OUT, M as CachedContainer, Mn as saveCatalogCache, Mt as OSC11_RESPONSE, N as ThinkingComponent, Nn as ScreamHarness, Nt as OSC11_RESPONSE_PREFIX, O as renderDiffLines, On as CLI_USER_AGENT_PRODUCT, Ot as DISABLE_TERMINAL_THEME_REPORTING, P as estimateTokens, Pt as OSC11_RESPONSE_PREFIX_NO_ESC, Qt as serializeToolResultOutput, R as parseReadGroupOutput, Rn as log, Rt as TERMINAL_THEME_DARK, Sn as getDataDir, St as createThemeStyles, T as isTurnElapsedEnabled, Tn as detectInstallSource, Tt as detectTerminalTheme, U as BREATHE_CYCLE_MS, Un as SCREAM_ERROR_INFO, V as AgentGroupComponent, Vn as isOrphanedToolCallError, Vt as isStreaming, W as getBreathingFrame, Xt as isTodoItemShape, Yt as formatErrorMessage, Zt as parseStreamingArgs, _ as readUpdateCache, _n as TuiConfigParseError, an as TIP_ROTATION_INTERVAL_MS, at as handleFusionPlanCommand, bn as saveTuiConfig, bt as createEditorTheme, c as isPlanExpandable, cn as getLlmNotSetMessage, dn as BUILTIN_SLASH_COMMANDS, en as truncateErrorMessage, et as changeThinkingLevel, fn as sortSlashCommands, g as refreshUpdateCache, gn as PULSE_WAVE_FRAMES, gt as clearInfoPanelState, h as selectUpdateTarget, hn as PIXEL_PULSE_FRAMES, ht as supportsBalance, i as buildRoleAdditionalText, in as SESSION_TIPS, j as langFromPath, jn as fetchCatalog, jt as OSC11_QUERY, k as renderDiffLinesClustered, kn as PRODUCT_NAME, kt as ENABLE_TERMINAL_FOCUS_REPORTING, l as MoonLoader, ln as getNoActiveSessionMessage, mn as setExperimentalFlags, mt as refreshProviderBalance, n as clearEvalPanelState, nn as EXIT_CONFIRM_WINDOW_MS, o as disposeChildren, on as getCtrlCHint, pn as isExperimentalFlagEnabled, q as refineGoal, qt as appendStreamingArgsPreview, r as openUrl, rn as MAIN_AGENT_ID, s as hasDispose, sn as getCtrlDHint, st as handlePlanCommand, t as dispatchInput, tn as EMPTY_SESSION_HINT_URL, tt as getModelCycleLevel, u as formatMemoryMemoForInjection, un as buildSkillSlashCommands, v as appendJsonlLine, vn as TuiLikePreferencesSchema, w as isEmptySessionHintDismissed, wn as getLogDir, wt as getColorPalette, x as getDaemonInstructions, xn as detectShellEnvironment, xt as createMarkdownTheme, y as readJsonlFile, yn as loadTuiConfig, yt as resolveThemeSync, z as BackgroundAgentStatusComponent, zn as resolveGlobalLogPath, zt as TERMINAL_THEME_LIGHT } from "./dispatch-DKaEvjOY.mjs";
8
- import { a as setLocale, o as t } from "./text-input-dialog-D9R3KY7O.mjs";
7
+ import { $ as toTerminalHyperlink, $t as parseStreamingArgs, A as highlightLines, An as CLI_USER_AGENT_PRODUCT, At as ENABLE_TERMINAL_THEME_REPORTING, B as AssistantMessageComponent, Bn as log, Bt as isBusy, C as UserMessageComponent, Cn as detectShellEnvironment, Ct as contrastTextHex, D as ToolCallComponent, Dn as detectInstallSource, Dt as DISABLE_TERMINAL_FOCUS_REPORTING, E as toggleEmptySessionHint, En as getLogDir, Et as parseOsc11BackgroundTheme, F as getSharedSpeedTracker, Fn as ScreamHarness, Ft as QUERY_TERMINAL_THEME, G as resetBreathingClock, Gn as SCREAM_ERROR_INFO, H as WelcomeComponent, Hn as isScreamError, Ht as FooterComponent, I as SkillActivationComponent, It as TERMINAL_FOCUS_IN, Jt as STATUS_BULLET, K as clearGoalState, L as ReadGroupComponent, Ln as resolveScreamHome, Lt as TERMINAL_FOCUS_OUT, M as CachedContainer, Mn as DEFAULT_CATALOG_URL, Mt as OSC11_RESPONSE, N as ThinkingComponent, Nn as fetchCatalog, Nt as OSC11_RESPONSE_PREFIX, O as renderDiffLines, On as CLI_COMMAND_NAME, Ot as DISABLE_TERMINAL_THEME_REPORTING, P as estimateTokens, Pn as saveCatalogCache, Pt as OSC11_RESPONSE_PREFIX_NO_ESC, Qt as isTodoItemShape, R as parseReadGroupOutput, Rn as MemoryMemoStore, Rt as TERMINAL_THEME_DARK, Sn as saveTuiConfig, St as createThemeStyles, T as isTurnElapsedEnabled, Tn as getInputHistoryFile, Tt as detectTerminalTheme, U as BREATHE_CYCLE_MS, Un as isOrphanedToolCallError, V as AgentGroupComponent, Vn as resolveGlobalLogPath, Vt as isStreaming, W as getBreathingFrame, Wn as ErrorCodes, Xt as argsRecord, Yt as appendStreamingArgsPreview, Zt as formatErrorMessage, _ as readUpdateCache, _n as PIXEL_PULSE_FRAMES, an as MAIN_AGENT_ID, at as handleFusionPlanCommand, bn as TuiLikePreferencesSchema, bt as createEditorTheme, c as isPlanExpandable, cn as getCtrlCHint, dn as getNoActiveSessionMessage, en as serializeToolResultOutput, et as changeThinkingLevel, fn as buildSkillSlashCommands, g as refreshUpdateCache, gn as setExperimentalFlags, gt as clearInfoPanelState, h as selectUpdateTarget, hn as isExperimentalFlagEnabled, ht as supportsBalance, i as buildRoleAdditionalText, in as EXIT_CONFIRM_WINDOW_MS, j as langFromPath, jn as PRODUCT_NAME, jt as OSC11_QUERY, k as renderDiffLinesClustered, kn as CLI_UI_MODE, kt as ENABLE_TERMINAL_FOCUS_REPORTING, l as MoonLoader, ln as getCtrlDHint, mn as sortSlashCommands, mt as refreshProviderBalance, n as clearEvalPanelState, nn as truncateErrorMessage, o as disposeChildren, on as SESSION_TIPS, pn as BUILTIN_SLASH_COMMANDS, q as refineGoal, qt as printableChar, r as openUrl, rn as EMPTY_SESSION_HINT_URL, s as hasDispose, sn as TIP_ROTATION_INTERVAL_MS, st as handlePlanCommand, t as dispatchInput, tn as stringValue, tt as getModelCycleLevel, u as formatMemoryMemoForInjection, un as getLlmNotSetMessage, v as appendJsonlLine, vn as PULSE_WAVE_FRAMES, w as isEmptySessionHintDismissed, wn as getDataDir, wt as getColorPalette, x as getDaemonInstructions, xn as loadTuiConfig, xt as createMarkdownTheme, y as readJsonlFile, yn as TuiConfigParseError, yt as resolveThemeSync, z as BackgroundAgentStatusComponent, zn as flushDiagnosticLogs, zt as TERMINAL_THEME_LIGHT } from "./dispatch-Dk8_Wqp6.mjs";
8
+ import { a as setLocale, o as t } from "./text-input-dialog-ClcJf9pu.mjs";
9
9
  import { createRequire } from "node:module";
10
10
  import { randomUUID } from "node:crypto";
11
11
  import { access, mkdir, mkdtemp, readFile, readdir, realpath, rm, unlink, writeFile } from "node:fs/promises";
@@ -30,7 +30,7 @@ function optionalBuildString(value) {
30
30
  return typeof value === "string" && value.length > 0 ? value : void 0;
31
31
  }
32
32
  const SCREAM_BUILD_INFO = {
33
- version: optionalBuildString("0.13.2"),
33
+ version: optionalBuildString("0.13.4"),
34
34
  channel: optionalBuildString(""),
35
35
  commit: optionalBuildString(""),
36
36
  buildTarget: optionalBuildString("darwin-arm64")
@@ -2519,6 +2519,10 @@ var SessionEventHandler = class {
2519
2519
  this.host.streamingUI.flushNow();
2520
2520
  this.maybeShowDebugTiming(event);
2521
2521
  this.drainQueuedMessagesIntoSteer();
2522
+ if (event.usage !== void 0) {
2523
+ const prev = this.host.state.appState.sessionUsage;
2524
+ this.host.setAppState({ sessionUsage: prev === void 0 ? event.usage : addTokenUsage(prev, event.usage) });
2525
+ }
2522
2526
  if (event.finishReason !== "max_tokens") return;
2523
2527
  const title = this.host.streamingUI.markStepTruncated(String(event.turnId), event.step) > 0 ? t("handler.max_tokens_truncated") : t("handler.max_tokens_no_tool");
2524
2528
  const detail = this.isAnthropicSessionActive() ? t("handler.max_tokens_hint") : void 0;
@@ -6182,7 +6186,7 @@ function checkCcConnectActive() {
6182
6186
  }
6183
6187
  function pgrep(pattern) {
6184
6188
  return new Promise((resolve) => {
6185
- exec(`pgrep -f ${escapeShell(pattern)}`, { timeout: 3e3 }, (error, stdout) => {
6189
+ exec(`LC_ALL=C pgrep -f ${escapeShell(pattern.replace(/^([a-z])/, "[$1]"))}`, { timeout: 3e3 }, (error, stdout) => {
6186
6190
  if (error) {
6187
6191
  resolve(false);
6188
6192
  return;
@@ -6229,7 +6233,7 @@ function checkPm2() {
6229
6233
  /** Query process command lines via PowerShell Get-CimInstance. Returns undefined if unavailable. */
6230
6234
  function checkPowerShell() {
6231
6235
  return new Promise((resolve) => {
6232
- exec(`powershell -NoProfile -Command "Get-CimInstance Win32_Process | Where-Object { $_.CommandLine -like '*cc-connect*' } | Measure-Object | Select-Object -ExpandProperty Count"`, {
6236
+ exec(`powershell -NoProfile -Command "Get-CimInstance Win32_Process | Where-Object { $_.CommandLine -like '*cc-connect*' -and $_.Name -ne 'cmd.exe' -and $_.ProcessId -ne $PID } | Measure-Object | Select-Object -ExpandProperty Count"`, {
6233
6237
  timeout: 5e3,
6234
6238
  windowsHide: true
6235
6239
  }, (error, stdout) => {
@@ -7700,6 +7704,91 @@ const INITIAL_LIVE_PANE = {
7700
7704
  pendingQuestion: null
7701
7705
  };
7702
7706
  //#endregion
7707
+ //#region src/utils/clipboard/clipboard-text.ts
7708
+ /**
7709
+ * Write plain text to the system clipboard with platform-specific commands.
7710
+ *
7711
+ * scream-core's clipboard layer is read-only (clipboard-native / clipboard-image),
7712
+ * so the TUI's "copy selected text" needs its own writer. Used to back the
7713
+ * pi-tui `copySelection` hook — return true/false so the TUI can flash
7714
+ * "Copied!" or "Copy failed".
7715
+ *
7716
+ * Platform mapping:
7717
+ * macOS -> pbcopy
7718
+ * Windows-> powershell Set-Clipboard (base64 payload, avoids quoting issues)
7719
+ * Linux -> wl-copy (Wayland) / xclip -selection clipboard -i (X11)
7720
+ */
7721
+ var ClipboardTextError = class extends Error {
7722
+ constructor(message) {
7723
+ super(message);
7724
+ this.name = "ClipboardTextError";
7725
+ }
7726
+ };
7727
+ const defaultRunCommand = (command, args, input) => {
7728
+ const result = spawnSync(command, args, {
7729
+ input,
7730
+ encoding: "utf8",
7731
+ timeout: 3e3
7732
+ });
7733
+ if (result.status === 0) return { ok: true };
7734
+ return {
7735
+ ok: false,
7736
+ error: result.error?.message ?? result.stderr?.toString() ?? `exit ${result.status}`
7737
+ };
7738
+ };
7739
+ function detectPlatform() {
7740
+ if (process.platform === "darwin") return "macos";
7741
+ if (process.platform === "win32") return "windows";
7742
+ if (process.platform === "linux") return process.env["WAYLAND_DISPLAY"] ? "linux-wayland" : "linux-x11";
7743
+ return "unsupported";
7744
+ }
7745
+ /**
7746
+ * Write `text` to the system clipboard. Throws ClipboardTextError when the
7747
+ * platform is unsupported or the underlying command fails, so callers can
7748
+ * surface a "Copy failed" indicator.
7749
+ */
7750
+ async function writeTextClipboard(text, runCommand = defaultRunCommand) {
7751
+ const platform = detectPlatform();
7752
+ let command;
7753
+ let args;
7754
+ let input;
7755
+ switch (platform) {
7756
+ case "macos":
7757
+ command = "pbcopy";
7758
+ args = [];
7759
+ input = text;
7760
+ break;
7761
+ case "windows": {
7762
+ const base64 = Buffer.from(text, "utf8").toString("base64");
7763
+ command = "powershell";
7764
+ args = [
7765
+ "-NoProfile",
7766
+ "-Command",
7767
+ `[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${base64}')) | Set-Clipboard`
7768
+ ];
7769
+ input = "";
7770
+ break;
7771
+ }
7772
+ case "linux-wayland":
7773
+ command = "wl-copy";
7774
+ args = [];
7775
+ input = text;
7776
+ break;
7777
+ case "linux-x11":
7778
+ command = "xclip";
7779
+ args = [
7780
+ "-selection",
7781
+ "clipboard",
7782
+ "-i"
7783
+ ];
7784
+ input = text;
7785
+ break;
7786
+ default: throw new ClipboardTextError(`unsupported clipboard platform: ${process.platform}`);
7787
+ }
7788
+ const result = runCommand(command, args, input);
7789
+ if (!result.ok) throw new ClipboardTextError(`failed to copy to clipboard: ${command} ${result.error ?? "unknown error"}`);
7790
+ }
7791
+ //#endregion
7703
7792
  //#region src/tui/utils/render-batcher.ts
7704
7793
  function createRenderBatcher(doRender) {
7705
7794
  let scheduled = false;
@@ -8562,7 +8651,14 @@ function createTUIState(options) {
8562
8651
  const initialAppState = options.initialAppState;
8563
8652
  const theme = createScreamTUIThemeBundle(initialAppState.theme, options.resolvedTheme);
8564
8653
  const terminal = new ProcessTerminal();
8565
- const ui = new TuiAltScreen(terminal);
8654
+ const ui = new TuiAltScreen(terminal, void 0, void 0, { copySelection: async (text) => {
8655
+ try {
8656
+ await writeTextClipboard(text);
8657
+ return true;
8658
+ } catch {
8659
+ return false;
8660
+ }
8661
+ } });
8566
8662
  const uiAny = ui;
8567
8663
  const originalDoRender = uiAny["doRender"].bind(ui);
8568
8664
  let recovering = false;
@@ -9203,6 +9299,7 @@ var SessionManager$1 = class {
9203
9299
  contextTokens: status.contextTokens,
9204
9300
  maxContextTokens: status.maxContextTokens,
9205
9301
  contextUsage: status.contextUsage,
9302
+ ...status.usage?.turnTotal !== void 0 ? { sessionUsage: status.usage.turnTotal } : {},
9206
9303
  sessionTitle: session.summary?.title ?? null,
9207
9304
  goal: goal ? {
9208
9305
  objective: goal.objective,
@@ -11530,6 +11627,12 @@ function createInitialAppState(input) {
11530
11627
  contextUsage: 0,
11531
11628
  contextTokens: 0,
11532
11629
  maxContextTokens: 0,
11630
+ sessionUsage: {
11631
+ inputOther: 0,
11632
+ output: 0,
11633
+ inputCacheRead: 0,
11634
+ inputCacheCreation: 0
11635
+ },
11533
11636
  providerBalance: null,
11534
11637
  balanceUpdatedAt: 0,
11535
11638
  isCompacting: false,
@@ -11938,6 +12041,14 @@ var ScreamTUI = class {
11938
12041
  Object.assign(this.state.appState, patch);
11939
12042
  const planModeChanged = "planMode" in patch && prevPlanMode !== this.state.appState.planMode;
11940
12043
  const sessionChanged = "sessionId" in patch && this.state.appState.sessionId !== prevSessionId;
12044
+ if (sessionChanged) {
12045
+ if (!("sessionUsage" in patch)) this.state.appState.sessionUsage = {
12046
+ inputOther: 0,
12047
+ output: 0,
12048
+ inputCacheRead: 0,
12049
+ inputCacheCreation: 0
12050
+ };
12051
+ }
11941
12052
  if (planModeChanged || sessionChanged) {
11942
12053
  this.updateEditorBorderHighlight();
11943
12054
  this.state.planModeBanner.setPlanMode(this.state.appState.planMode ?? "off");
@@ -12039,7 +12150,7 @@ var ScreamTUI = class {
12039
12150
  const card = new OnboardingCardComponent({
12040
12151
  colors: this.state.theme.colors,
12041
12152
  onConfigure: () => {
12042
- import("./dispatch-6CtsO1av.mjs").then(({ handleConnectCommand }) => handleConnectCommand(this, "")).finally(() => {
12153
+ import("./dispatch-BKrBb5IE.mjs").then(({ handleConnectCommand }) => handleConnectCommand(this, "")).finally(() => {
12043
12154
  this.restoreEditor();
12044
12155
  });
12045
12156
  },
@@ -3,5 +3,5 @@ import { fileURLToPath as __cjsShimFileURLToPath } from 'node:url';
3
3
  import { dirname as __cjsShimDirname } from 'node:path';
4
4
  const __filename = __cjsShimFileURLToPath(import.meta.url);
5
5
  const __dirname = __cjsShimDirname(__filename);
6
- import { Ut as handleConnectCommand } from "./dispatch-DKaEvjOY.mjs";
6
+ import { Gt as handleConnectCommand } from "./dispatch-Dk8_Wqp6.mjs";
7
7
  export { handleConnectCommand };