svamp-cli 0.2.337 → 0.2.339
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/dist/{adminCommands-i7zkVIFU.mjs → adminCommands-DcQ5lITm.mjs} +1 -1
- package/dist/{agentCommands-DmRCmbeU.mjs → agentCommands-CIQbCUsB.mjs} +5 -5
- package/dist/{auth-CXJGid9o.mjs → auth-DnuRbHcY.mjs} +1 -1
- package/dist/{cli-v0NMiesq.mjs → cli-0XZc7Ipp.mjs} +77 -77
- package/dist/cli.mjs +2 -2
- package/dist/{commands-B8KlOrBS.mjs → commands-Asb5UuqP.mjs} +3 -3
- package/dist/{commands-BRI0wxnE.mjs → commands-BTsPRj_f.mjs} +2 -2
- package/dist/{commands-BeSB75OM.mjs → commands-CPDM2cME.mjs} +3 -3
- package/dist/{commands-Dw_oiiqX.mjs → commands-CoImSc7s.mjs} +1 -1
- package/dist/{commands-DWNYEYRO.mjs → commands-CtESzbEq.mjs} +1 -1
- package/dist/{commands-dYyv0P82.mjs → commands-D9F9hBSH.mjs} +11 -11
- package/dist/{commands-DZF_q6a0.mjs → commands-Di4iZP_7.mjs} +2 -2
- package/dist/{commands-Bn-JAlUf.mjs → commands-agsjZBUF.mjs} +3 -3
- package/dist/{fleet-Dion32w1.mjs → fleet-BNqZ6y4s.mjs} +1 -1
- package/dist/{headlessCli-bB0pjxSC.mjs → headlessCli-DHCSiiY3.mjs} +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{notifyCommands-BVESEkQL.mjs → notifyCommands-B2tk-J7f.mjs} +1 -1
- package/dist/{package-DBcAF326.mjs → package-BRx_LBwR.mjs} +1 -1
- package/dist/{rpc-BSWkkPHd.mjs → rpc--XZCm0p-.mjs} +1 -1
- package/dist/{rpc-Cj31v2sm.mjs → rpc-BPHQnoTZ.mjs} +1 -1
- package/dist/{run-C6gfyMsM.mjs → run-D0SYcbE5.mjs} +1 -1
- package/dist/{run-bo0i02Dy.mjs → run-UbzzPQPz.mjs} +37 -235
- package/dist/{scheduler-DkfqQjih.mjs → scheduler-CF01et7j.mjs} +1 -1
- package/dist/{serveCommands-D2sKo0xC.mjs → serveCommands-BaA1B60R.mjs} +10 -10
- package/dist/{sideband-D5Kan4J1.mjs → sideband-D-n2JZSB.mjs} +1 -1
- package/package.json +1 -1
|
@@ -8509,7 +8509,7 @@ QUESTION: ${params.question || "Summarize this concisely."}` }
|
|
|
8509
8509
|
}
|
|
8510
8510
|
const deps = buildSessionDeps(rpc, { cwd, ownerEmail: owner });
|
|
8511
8511
|
const sender = { name: context?.user?.email || context?.user?.id || "user", kind: "user", verified: true };
|
|
8512
|
-
const { toolsForRole } = await import('./sideband-
|
|
8512
|
+
const { toolsForRole } = await import('./sideband-D-n2JZSB.mjs');
|
|
8513
8513
|
const r2 = await runWiseAgent({ message: params.message, sender, config: { tools: toolsForRole(role2) }, deps, transport, model: resolved.model });
|
|
8514
8514
|
return fmt(r2);
|
|
8515
8515
|
}
|
|
@@ -8641,7 +8641,7 @@ QUESTION: ${params.question || "Summarize this concisely."}` }
|
|
|
8641
8641
|
return { ok: false, call_id: callId, status: "busy", error: "channel is busy (too many concurrent requests) \u2014 retry shortly" };
|
|
8642
8642
|
}
|
|
8643
8643
|
const rendered = renderMessage(c, { sender: r.sender, body: { message: kwargs.message }, callId });
|
|
8644
|
-
const { queryCore } = await import('./commands-
|
|
8644
|
+
const { queryCore } = await import('./commands-CoImSc7s.mjs');
|
|
8645
8645
|
const timeout = c.reply?.timeout_sec || 120;
|
|
8646
8646
|
let result;
|
|
8647
8647
|
let thrownSessionId;
|
|
@@ -18559,7 +18559,7 @@ You share this machine and project folder with other agent sessions (same user,
|
|
|
18559
18559
|
}
|
|
18560
18560
|
|
|
18561
18561
|
const STANDARD_WINDOWS = [2e5, 1e6];
|
|
18562
|
-
const DEFAULT_MAX_CONTEXT_WINDOW =
|
|
18562
|
+
const DEFAULT_MAX_CONTEXT_WINDOW = 0;
|
|
18563
18563
|
function resolveMaxContextWindow(env = process.env) {
|
|
18564
18564
|
const raw = (env.SVAMP_MAX_CONTEXT_WINDOW ?? "").trim().toLowerCase();
|
|
18565
18565
|
if (!raw) return DEFAULT_MAX_CONTEXT_WINDOW;
|
|
@@ -18584,6 +18584,18 @@ function computeObservedContext(usage) {
|
|
|
18584
18584
|
if (!usage) return 0;
|
|
18585
18585
|
return (usage.input_tokens || 0) + (usage.cache_creation_input_tokens || 0) + (usage.cache_read_input_tokens || 0);
|
|
18586
18586
|
}
|
|
18587
|
+
function peakRequestUsage(usages) {
|
|
18588
|
+
let best;
|
|
18589
|
+
let bestTokens = 0;
|
|
18590
|
+
for (const u of usages) {
|
|
18591
|
+
const n = computeObservedContext(u);
|
|
18592
|
+
if (n > bestTokens) {
|
|
18593
|
+
bestTokens = n;
|
|
18594
|
+
best = u ?? void 0;
|
|
18595
|
+
}
|
|
18596
|
+
}
|
|
18597
|
+
return bestTokens > 0 ? best : void 0;
|
|
18598
|
+
}
|
|
18587
18599
|
function inferWindowFromModelName(model) {
|
|
18588
18600
|
if (!model) return 0;
|
|
18589
18601
|
if (/\[1m\]/i.test(model)) return 1e6;
|
|
@@ -18640,49 +18652,11 @@ function resolveContextWindow(opts) {
|
|
|
18640
18652
|
return candidate;
|
|
18641
18653
|
}
|
|
18642
18654
|
|
|
18643
|
-
const DEFAULT_AUTO_COMPACT_RATIO = 0.85;
|
|
18644
|
-
const MIN_WINDOW_FOR_BACKSTOP = 5e4;
|
|
18645
|
-
const MIN_RATIO = 0.5;
|
|
18646
|
-
const MAX_RATIO = 0.97;
|
|
18647
18655
|
function resolveAutoCompactEnabled(env = process.env) {
|
|
18648
18656
|
const v = (env.SVAMP_AUTO_COMPACT ?? "").trim().toLowerCase();
|
|
18649
18657
|
if (v === "0" || v === "false" || v === "off" || v === "no") return false;
|
|
18650
18658
|
return true;
|
|
18651
18659
|
}
|
|
18652
|
-
function resolveAutoCompactRatio(env = process.env) {
|
|
18653
|
-
const raw = (env.SVAMP_AUTO_COMPACT_RATIO ?? "").trim();
|
|
18654
|
-
if (!raw) return DEFAULT_AUTO_COMPACT_RATIO;
|
|
18655
|
-
const n = Number(raw);
|
|
18656
|
-
if (!Number.isFinite(n)) return DEFAULT_AUTO_COMPACT_RATIO;
|
|
18657
|
-
if (n < MIN_RATIO) return MIN_RATIO;
|
|
18658
|
-
if (n > MAX_RATIO) return MAX_RATIO;
|
|
18659
|
-
return n;
|
|
18660
|
-
}
|
|
18661
|
-
function decideProactiveCompaction(opts) {
|
|
18662
|
-
const { observed, window, ratio, enabled } = opts;
|
|
18663
|
-
const pct = window > 0 ? observed / window : 0;
|
|
18664
|
-
if (!enabled) return { shouldCompact: false, window, pct, reason: "disabled" };
|
|
18665
|
-
if (!(window >= MIN_WINDOW_FOR_BACKSTOP)) return { shouldCompact: false, window, pct, reason: "window-too-small" };
|
|
18666
|
-
if (!(observed > 0)) return { shouldCompact: false, window, pct, reason: "no-observed" };
|
|
18667
|
-
if (pct >= ratio) return { shouldCompact: true, window, pct, reason: "threshold" };
|
|
18668
|
-
return { shouldCompact: false, window, pct, reason: "below-threshold" };
|
|
18669
|
-
}
|
|
18670
|
-
function shouldPreTurnCompact(input) {
|
|
18671
|
-
if (!input.enabled || input.disabled) return false;
|
|
18672
|
-
if (input.incomingIsCompact) return false;
|
|
18673
|
-
return decideProactiveCompaction({
|
|
18674
|
-
observed: input.observed,
|
|
18675
|
-
window: input.window,
|
|
18676
|
-
ratio: input.ratio,
|
|
18677
|
-
enabled: input.enabled
|
|
18678
|
-
}).shouldCompact;
|
|
18679
|
-
}
|
|
18680
|
-
function fmtK(n) {
|
|
18681
|
-
return `${Math.round((n || 0) / 1e3)}K`;
|
|
18682
|
-
}
|
|
18683
|
-
function describeAutoCompact(observed, window, pct) {
|
|
18684
|
-
return `Context at ${Math.round(pct * 100)}% of the ${fmtK(window)} window (${fmtK(observed)} tokens) \u2014 compacting automatically to stay under the model's limit.`;
|
|
18685
|
-
}
|
|
18686
18660
|
function isContextTooLongError(text) {
|
|
18687
18661
|
if (!text) return false;
|
|
18688
18662
|
const t = text.toLowerCase();
|
|
@@ -18700,67 +18674,11 @@ function isAutocompactThrashError(text) {
|
|
|
18700
18674
|
if (t.includes("reading in smaller chunks") && t.includes("context")) return true;
|
|
18701
18675
|
return false;
|
|
18702
18676
|
}
|
|
18703
|
-
function shouldEvaluateProactiveCompaction(state) {
|
|
18704
|
-
if (!state.enabled) return false;
|
|
18705
|
-
if (state.disabled) return false;
|
|
18706
|
-
if (state.turnErrored) return false;
|
|
18707
|
-
if (state.compactPending) return false;
|
|
18708
|
-
if (state.justCompacted) return false;
|
|
18709
|
-
return true;
|
|
18710
|
-
}
|
|
18711
|
-
function compactSupportedFromSlashCommands(slashCommands) {
|
|
18712
|
-
if (!Array.isArray(slashCommands) || slashCommands.length === 0) return void 0;
|
|
18713
|
-
return slashCommands.some(
|
|
18714
|
-
(c) => typeof c === "string" && c.trim().replace(/^\//, "").toLowerCase() === "compact"
|
|
18715
|
-
);
|
|
18716
|
-
}
|
|
18717
|
-
const DEFAULT_COMPACT_NO_BOUNDARY_STRIKES = 3;
|
|
18718
|
-
function decideCompactUnsupported(input) {
|
|
18719
|
-
const prior = Math.max(0, input.priorStrikes || 0);
|
|
18720
|
-
const limit = Math.max(1, input.maxStrikes);
|
|
18721
|
-
if (input.turnErrored) {
|
|
18722
|
-
return { disable: false, warnUnsupported: false, strikes: prior, reason: "errored-turn" };
|
|
18723
|
-
}
|
|
18724
|
-
if (!input.wasAutoInjected) {
|
|
18725
|
-
return {
|
|
18726
|
-
disable: false,
|
|
18727
|
-
warnUnsupported: input.compactSupported === false,
|
|
18728
|
-
strikes: prior,
|
|
18729
|
-
reason: "user-typed"
|
|
18730
|
-
};
|
|
18731
|
-
}
|
|
18732
|
-
if (input.compactSupported === false) {
|
|
18733
|
-
return { disable: true, warnUnsupported: true, strikes: prior + 1, reason: "unsupported" };
|
|
18734
|
-
}
|
|
18735
|
-
const strikes = prior + 1;
|
|
18736
|
-
if (strikes >= limit) {
|
|
18737
|
-
return { disable: true, warnUnsupported: false, strikes, reason: "strikes-exhausted" };
|
|
18738
|
-
}
|
|
18739
|
-
return { disable: false, warnUnsupported: false, strikes, reason: "strike" };
|
|
18740
|
-
}
|
|
18741
|
-
function describeNoBoundary(strikes, limit) {
|
|
18742
|
-
return `Automatic compaction ran but reported no compaction boundary (attempt ${strikes} of ${limit}) \u2014 usually because there was nothing left to compact. Keeping automatic compaction enabled.`;
|
|
18743
|
-
}
|
|
18744
18677
|
function shouldAccountLoopTurn(state) {
|
|
18745
18678
|
if (state.justCompacted) return false;
|
|
18746
18679
|
if (state.compactPending) return false;
|
|
18747
18680
|
return true;
|
|
18748
18681
|
}
|
|
18749
|
-
function shouldPersistObservedContext(state) {
|
|
18750
|
-
if (state.justCompacted) return false;
|
|
18751
|
-
if (state.compactPending) return false;
|
|
18752
|
-
if (state.turnErrored) return false;
|
|
18753
|
-
return true;
|
|
18754
|
-
}
|
|
18755
|
-
function postCompactionObservedContext(compactMetadata) {
|
|
18756
|
-
const md = compactMetadata;
|
|
18757
|
-
if (!md || typeof md !== "object") return 0;
|
|
18758
|
-
for (const key of ["post_tokens", "postTokens", "post_token_count", "tokens_after", "after_tokens"]) {
|
|
18759
|
-
const v = md[key];
|
|
18760
|
-
if (typeof v === "number" && Number.isFinite(v) && v > 0) return Math.floor(v);
|
|
18761
|
-
}
|
|
18762
|
-
return 0;
|
|
18763
|
-
}
|
|
18764
18682
|
|
|
18765
18683
|
function fmtTokens(n) {
|
|
18766
18684
|
return Math.max(0, Math.round(n)).toLocaleString("en-US");
|
|
@@ -18787,10 +18705,6 @@ function describeCompaction(meta) {
|
|
|
18787
18705
|
}
|
|
18788
18706
|
return `Context compacted (${trigger}).`;
|
|
18789
18707
|
}
|
|
18790
|
-
function compactUnsupportedWarning(version) {
|
|
18791
|
-
const v = "";
|
|
18792
|
-
return `\u26A0\uFE0F /compact did not run${v} \u2014 Claude Code forwarded it as a normal message, so nothing was compacted. In-session /compact needs a newer Claude Code (>= 2.1.205). Ask the machine owner to upgrade (e.g. \`svamp fleet upgrade-claude\`), then try again.`;
|
|
18793
|
-
}
|
|
18794
18708
|
|
|
18795
18709
|
function shouldRunZombieProbe(args) {
|
|
18796
18710
|
return args.hasActiveSessions && !args.inGrace && args.consecutiveHeartbeatFailures === 0 && args.inboundSilenceMs > args.thresholdMs;
|
|
@@ -20892,7 +20806,7 @@ async function startDaemon(options) {
|
|
|
20892
20806
|
try {
|
|
20893
20807
|
const dir = loadSessionIndex()[sessionId]?.directory;
|
|
20894
20808
|
if (!dir) return;
|
|
20895
|
-
const { reconcileServiceLinks } = await import('./agentCommands-
|
|
20809
|
+
const { reconcileServiceLinks } = await import('./agentCommands-CIQbCUsB.mjs');
|
|
20896
20810
|
const configPath = getSvampConfigPath(dir, sessionId);
|
|
20897
20811
|
const config = readSvampConfig(configPath);
|
|
20898
20812
|
const entries = Array.from(urls.entries());
|
|
@@ -20914,7 +20828,7 @@ async function startDaemon(options) {
|
|
|
20914
20828
|
try {
|
|
20915
20829
|
const dir = loadSessionIndex()[sessionId]?.directory;
|
|
20916
20830
|
if (!dir) return;
|
|
20917
|
-
const { reconcileServiceLinks } = await import('./agentCommands-
|
|
20831
|
+
const { reconcileServiceLinks } = await import('./agentCommands-CIQbCUsB.mjs');
|
|
20918
20832
|
const configPath = getSvampConfigPath(dir, sessionId);
|
|
20919
20833
|
const config = readSvampConfig(configPath);
|
|
20920
20834
|
const incoming = [{
|
|
@@ -20935,7 +20849,7 @@ async function startDaemon(options) {
|
|
|
20935
20849
|
try {
|
|
20936
20850
|
const dir = loadSessionIndex()[sessionId]?.directory;
|
|
20937
20851
|
if (!dir) return;
|
|
20938
|
-
const { dropServiceLinks } = await import('./agentCommands-
|
|
20852
|
+
const { dropServiceLinks } = await import('./agentCommands-CIQbCUsB.mjs');
|
|
20939
20853
|
const configPath = getSvampConfigPath(dir, sessionId);
|
|
20940
20854
|
const config = readSvampConfig(configPath);
|
|
20941
20855
|
if (dropServiceLinks(config, "serve", mountName)) {
|
|
@@ -20951,7 +20865,7 @@ async function startDaemon(options) {
|
|
|
20951
20865
|
try {
|
|
20952
20866
|
const dir = loadSessionIndex()[sessionId]?.directory;
|
|
20953
20867
|
if (!dir) return;
|
|
20954
|
-
const { dropServiceLinks } = await import('./agentCommands-
|
|
20868
|
+
const { dropServiceLinks } = await import('./agentCommands-CIQbCUsB.mjs');
|
|
20955
20869
|
const configPath = getSvampConfigPath(dir, sessionId);
|
|
20956
20870
|
const config = readSvampConfig(configPath);
|
|
20957
20871
|
if (dropServiceLinks(config, "tunnel", tunnelName)) {
|
|
@@ -20968,7 +20882,7 @@ async function startDaemon(options) {
|
|
|
20968
20882
|
let managedLinkSessionsSeeded = false;
|
|
20969
20883
|
async function reconcileAllServiceLinks() {
|
|
20970
20884
|
try {
|
|
20971
|
-
const { reconcileServiceLinksExact, hasManagedServiceLink } = await import('./agentCommands-
|
|
20885
|
+
const { reconcileServiceLinksExact, hasManagedServiceLink } = await import('./agentCommands-CIQbCUsB.mjs');
|
|
20972
20886
|
const desiredBySession = /* @__PURE__ */ new Map();
|
|
20973
20887
|
const push = (sessionId, entry) => {
|
|
20974
20888
|
if (!sessionId || !entry.url) return;
|
|
@@ -22013,15 +21927,11 @@ ${parts.join("\n")}`);
|
|
|
22013
21927
|
let overloadBailedThisTurn = false;
|
|
22014
21928
|
let pendingCompactTurn = false;
|
|
22015
21929
|
const autoCompactEnabled = resolveAutoCompactEnabled();
|
|
22016
|
-
const autoCompactRatio = resolveAutoCompactRatio();
|
|
22017
21930
|
const maxContextWindow = resolveMaxContextWindow();
|
|
22018
|
-
let autoCompactWasAutoInjected = false;
|
|
22019
|
-
let autoCompactDisabled = false;
|
|
22020
21931
|
let autoCompactRecoveryTried = false;
|
|
22021
21932
|
let justCompactedTurn = false;
|
|
22022
21933
|
let compactTurnLatch = false;
|
|
22023
|
-
let
|
|
22024
|
-
let compactSupported = void 0;
|
|
21934
|
+
let turnRequestUsages = [];
|
|
22025
21935
|
let noIsolationWarned = false;
|
|
22026
21936
|
const RATELIMIT_CFG = getRateLimitRetryConfig();
|
|
22027
21937
|
let currentTurnMessage;
|
|
@@ -22356,6 +22266,7 @@ ${parts.join("\n")}`);
|
|
|
22356
22266
|
if (typeof assistantModel === "string" && assistantModel.length > 0) {
|
|
22357
22267
|
lastMainModel = assistantModel;
|
|
22358
22268
|
}
|
|
22269
|
+
if (msg.message?.usage) turnRequestUsages.push(msg.message.usage);
|
|
22359
22270
|
}
|
|
22360
22271
|
const assistantContent = msg.type === "assistant" ? msg.message?.content ?? msg.content : void 0;
|
|
22361
22272
|
if (Array.isArray(assistantContent)) {
|
|
@@ -22385,7 +22296,7 @@ ${parts.join("\n")}`);
|
|
|
22385
22296
|
} else if (isRetryableRateLimit(resultText, msg.api_error_status) && scheduleRateLimitRetry2()) {
|
|
22386
22297
|
rateLimitRetryScheduled = true;
|
|
22387
22298
|
lastErrorMessagePushed = true;
|
|
22388
|
-
} else if (isContextTooLongError(resultText) && autoCompactEnabled && !
|
|
22299
|
+
} else if (isContextTooLongError(resultText) && autoCompactEnabled && !autoCompactRecoveryTried) {
|
|
22389
22300
|
autoCompactRecoveryTried = true;
|
|
22390
22301
|
logger.log(`[Session ${sessionId}] Context-overflow 400 \u2014 injecting one automatic /compact recovery`);
|
|
22391
22302
|
sessionService.pushMessage(
|
|
@@ -22465,32 +22376,7 @@ ${parts.join("\n")}`);
|
|
|
22465
22376
|
}
|
|
22466
22377
|
if (pendingCompactTurn) {
|
|
22467
22378
|
pendingCompactTurn = false;
|
|
22468
|
-
|
|
22469
|
-
autoCompactWasAutoInjected = false;
|
|
22470
|
-
const d = decideCompactUnsupported({
|
|
22471
|
-
wasAutoInjected: wasAuto,
|
|
22472
|
-
turnErrored: !!msg.is_error,
|
|
22473
|
-
compactSupported,
|
|
22474
|
-
priorStrikes: compactNoBoundaryStrikes,
|
|
22475
|
-
maxStrikes: DEFAULT_COMPACT_NO_BOUNDARY_STRIKES
|
|
22476
|
-
});
|
|
22477
|
-
compactNoBoundaryStrikes = d.strikes;
|
|
22478
|
-
if (d.disable) {
|
|
22479
|
-
autoCompactDisabled = true;
|
|
22480
|
-
logger.log(`[Session ${sessionId}] Disabling the auto-compaction backstop for this session (${d.reason})`);
|
|
22481
|
-
}
|
|
22482
|
-
logger.log(`[Session ${sessionId}] /compact produced no compaction boundary (reason=${d.reason}, strikes=${d.strikes}, supported=${String(compactSupported)}, errored=${!!msg.is_error})`);
|
|
22483
|
-
if (d.warnUnsupported) {
|
|
22484
|
-
sessionService.pushMessage(
|
|
22485
|
-
{ type: "message", message: compactUnsupportedWarning(), level: "warning" },
|
|
22486
|
-
"event"
|
|
22487
|
-
);
|
|
22488
|
-
} else if (wasAuto && d.reason !== "errored-turn") {
|
|
22489
|
-
sessionService.pushMessage(
|
|
22490
|
-
{ type: "message", message: describeNoBoundary(d.strikes, DEFAULT_COMPACT_NO_BOUNDARY_STRIKES), level: "warning" },
|
|
22491
|
-
"event"
|
|
22492
|
-
);
|
|
22493
|
-
}
|
|
22379
|
+
logger.log(`[Session ${sessionId}] /compact produced no compaction boundary (errored=${!!msg.is_error})`);
|
|
22494
22380
|
}
|
|
22495
22381
|
if (!msg.is_error) {
|
|
22496
22382
|
resetRateLimitStreak();
|
|
@@ -22505,24 +22391,17 @@ ${parts.join("\n")}`);
|
|
|
22505
22391
|
}
|
|
22506
22392
|
signalProcessing(false);
|
|
22507
22393
|
sessionWasProcessing = false;
|
|
22394
|
+
const peakUsage = peakRequestUsage(turnRequestUsages) ?? msg.usage;
|
|
22508
22395
|
const resolvedWindow = applyMaxContextWindow(resolveContextWindow({
|
|
22509
22396
|
modelUsage: msg.modelUsage,
|
|
22510
|
-
usage:
|
|
22397
|
+
usage: peakUsage,
|
|
22511
22398
|
mainModel: lastMainModel,
|
|
22512
22399
|
currentWindow: sessionMetadata.contextWindow
|
|
22513
22400
|
}), maxContextWindow);
|
|
22514
|
-
|
|
22515
|
-
const mayPersistObserved = shouldPersistObservedContext({
|
|
22516
|
-
justCompacted: justCompactedTurn,
|
|
22517
|
-
compactPending: compactTurnLatch,
|
|
22518
|
-
turnErrored: !!msg.is_error
|
|
22519
|
-
});
|
|
22520
|
-
const persistObserved = mayPersistObserved && observedThisTurn > 0 && observedThisTurn !== sessionMetadata.observedContext;
|
|
22521
|
-
if (resolvedWindow > 0 && resolvedWindow !== sessionMetadata.contextWindow || persistObserved) {
|
|
22401
|
+
if (resolvedWindow > 0 && resolvedWindow !== sessionMetadata.contextWindow) {
|
|
22522
22402
|
sessionMetadata = {
|
|
22523
22403
|
...sessionMetadata,
|
|
22524
|
-
|
|
22525
|
-
...persistObserved ? { observedContext: observedThisTurn } : {}
|
|
22404
|
+
contextWindow: resolvedWindow
|
|
22526
22405
|
};
|
|
22527
22406
|
sessionService.updateMetadata(sessionMetadata);
|
|
22528
22407
|
}
|
|
@@ -22596,44 +22475,8 @@ ${parts.join("\n")}`);
|
|
|
22596
22475
|
logger.log(`[Session ${sessionId}] ${taskInfo}`);
|
|
22597
22476
|
sessionService.pushMessage({ type: "session_event", message: taskInfo }, "session");
|
|
22598
22477
|
}
|
|
22599
|
-
const mayEvaluateLayer1 = shouldEvaluateProactiveCompaction({
|
|
22600
|
-
justCompacted: justCompactedTurn,
|
|
22601
|
-
compactPending: pendingCompactTurn,
|
|
22602
|
-
turnErrored: !!msg.is_error,
|
|
22603
|
-
disabled: autoCompactDisabled,
|
|
22604
|
-
enabled: autoCompactEnabled
|
|
22605
|
-
});
|
|
22606
22478
|
justCompactedTurn = false;
|
|
22607
22479
|
compactTurnLatch = false;
|
|
22608
|
-
if (mayEvaluateLayer1) {
|
|
22609
|
-
try {
|
|
22610
|
-
const observed = computeObservedContext(msg.usage);
|
|
22611
|
-
const decision = decideProactiveCompaction({
|
|
22612
|
-
observed,
|
|
22613
|
-
window: resolvedWindow > 0 ? resolvedWindow : sessionMetadata.contextWindow || 0,
|
|
22614
|
-
ratio: autoCompactRatio,
|
|
22615
|
-
enabled: autoCompactEnabled
|
|
22616
|
-
});
|
|
22617
|
-
if (decision.shouldCompact) {
|
|
22618
|
-
logger.log(`[Session ${sessionId}] Auto-compaction backstop firing at ${Math.round(decision.pct * 100)}% of ${decision.window} window (${observed} tokens) \u2014 injecting /compact`);
|
|
22619
|
-
sessionService.pushMessage(
|
|
22620
|
-
{ type: "message", message: describeAutoCompact(observed, decision.window, decision.pct), level: "warning" },
|
|
22621
|
-
"event"
|
|
22622
|
-
);
|
|
22623
|
-
const existingQueue = sessionMetadata.messageQueue || [];
|
|
22624
|
-
sessionMetadata = {
|
|
22625
|
-
...sessionMetadata,
|
|
22626
|
-
messageQueue: [
|
|
22627
|
-
{ id: randomUUID(), text: "/compact", displayText: "\u{1F5DC}\uFE0F Auto-compacting context", createdAt: Date.now(), alreadyStored: true, autoCompact: true },
|
|
22628
|
-
...existingQueue
|
|
22629
|
-
]
|
|
22630
|
-
};
|
|
22631
|
-
sessionService.updateMetadata(sessionMetadata);
|
|
22632
|
-
}
|
|
22633
|
-
} catch (e) {
|
|
22634
|
-
logger.log(`[Session ${sessionId}] Auto-compaction backstop check failed: ${e?.message}`);
|
|
22635
|
-
}
|
|
22636
|
-
}
|
|
22637
22480
|
const queueLen = sessionMetadata.messageQueue?.length ?? 0;
|
|
22638
22481
|
if (queueLen > 0 && claudeResumeId && !trackedSession.stopped) {
|
|
22639
22482
|
setTimeout(() => processMessageQueueRef?.(), 200);
|
|
@@ -22662,6 +22505,7 @@ ${parts.join("\n")}`);
|
|
|
22662
22505
|
} else if (msg.type === "system" && msg.subtype === "init") {
|
|
22663
22506
|
consecutiveOverloadRetries = 0;
|
|
22664
22507
|
overloadBailedThisTurn = false;
|
|
22508
|
+
turnRequestUsages = [];
|
|
22665
22509
|
if (!userMessagePending) {
|
|
22666
22510
|
turnInitiatedByUser = false;
|
|
22667
22511
|
logger.log(`[Session ${sessionId}] SDK-initiated turn (likely stale task_notification)`);
|
|
@@ -22669,7 +22513,6 @@ ${parts.join("\n")}`);
|
|
|
22669
22513
|
userMessagePending = false;
|
|
22670
22514
|
if (msg.slash_commands && Array.isArray(msg.slash_commands)) {
|
|
22671
22515
|
sessionMetadata = { ...sessionMetadata, slashCommands: msg.slash_commands };
|
|
22672
|
-
compactSupported = compactSupportedFromSlashCommands(msg.slash_commands);
|
|
22673
22516
|
}
|
|
22674
22517
|
if (typeof msg.model === "string" && msg.model.length > 0) {
|
|
22675
22518
|
lastMainModel = msg.model;
|
|
@@ -22721,19 +22564,9 @@ ${parts.join("\n")}`);
|
|
|
22721
22564
|
sessionService.pushMessage(msg, "session");
|
|
22722
22565
|
} else if (msg.type === "system" && msg.subtype === "compact_boundary") {
|
|
22723
22566
|
pendingCompactTurn = false;
|
|
22724
|
-
autoCompactWasAutoInjected = false;
|
|
22725
22567
|
autoCompactRecoveryTried = false;
|
|
22726
22568
|
justCompactedTurn = true;
|
|
22727
22569
|
compactTurnLatch = true;
|
|
22728
|
-
compactNoBoundaryStrikes = 0;
|
|
22729
|
-
try {
|
|
22730
|
-
const postObserved = postCompactionObservedContext(msg.compact_metadata);
|
|
22731
|
-
if (sessionMetadata.observedContext !== postObserved) {
|
|
22732
|
-
sessionMetadata = { ...sessionMetadata, observedContext: postObserved };
|
|
22733
|
-
sessionService.updateMetadata(sessionMetadata);
|
|
22734
|
-
}
|
|
22735
|
-
} catch {
|
|
22736
|
-
}
|
|
22737
22570
|
const compactLine = describeCompaction(msg.compact_metadata);
|
|
22738
22571
|
logger.log(`[Session ${sessionId}] ${compactLine}`);
|
|
22739
22572
|
sessionService.pushMessage(
|
|
@@ -23164,39 +22997,9 @@ ${capturedError}${buildClaudeErrorHint(capturedError)}`;
|
|
|
23164
22997
|
pendingCompactTurn = isCompactCommand(text);
|
|
23165
22998
|
if (pendingCompactTurn) compactTurnLatch = true;
|
|
23166
22999
|
if (!claudeProcess || claudeProcess.exitCode !== null) {
|
|
23167
|
-
|
|
23168
|
-
|
|
23169
|
-
|
|
23170
|
-
observed: preTurnObserved,
|
|
23171
|
-
window: preTurnWindow,
|
|
23172
|
-
ratio: autoCompactRatio,
|
|
23173
|
-
enabled: autoCompactEnabled,
|
|
23174
|
-
disabled: autoCompactDisabled,
|
|
23175
|
-
incomingIsCompact: isCompactCommand(text)
|
|
23176
|
-
})) {
|
|
23177
|
-
const pct = preTurnWindow > 0 ? preTurnObserved / preTurnWindow : 0;
|
|
23178
|
-
logger.log(`[Session ${sessionId}] Pre-turn auto-compaction: persisted observed ${preTurnObserved} tokens at ${Math.round(pct * 100)}% of ${preTurnWindow} window \u2014 compacting before delivering message`);
|
|
23179
|
-
sessionService.pushMessage(
|
|
23180
|
-
{ type: "message", message: describeAutoCompact(preTurnObserved, preTurnWindow, pct), level: "warning" },
|
|
23181
|
-
"event"
|
|
23182
|
-
);
|
|
23183
|
-
const existingQueue = sessionMetadata.messageQueue || [];
|
|
23184
|
-
sessionMetadata = {
|
|
23185
|
-
...sessionMetadata,
|
|
23186
|
-
messageQueue: [...existingQueue, { id: randomUUID(), text, createdAt: Date.now(), alreadyStored: true }]
|
|
23187
|
-
};
|
|
23188
|
-
sessionService.updateMetadata(sessionMetadata);
|
|
23189
|
-
pendingCompactTurn = true;
|
|
23190
|
-
compactTurnLatch = true;
|
|
23191
|
-
autoCompactWasAutoInjected = true;
|
|
23192
|
-
spawnClaude("/compact", msgMeta);
|
|
23193
|
-
signalProcessing(true);
|
|
23194
|
-
sessionWasProcessing = true;
|
|
23195
|
-
} else {
|
|
23196
|
-
spawnClaude(text, msgMeta);
|
|
23197
|
-
signalProcessing(true);
|
|
23198
|
-
sessionWasProcessing = true;
|
|
23199
|
-
}
|
|
23000
|
+
spawnClaude(text, msgMeta);
|
|
23001
|
+
signalProcessing(true);
|
|
23002
|
+
sessionWasProcessing = true;
|
|
23200
23003
|
} else if (writeUserFrameToClaude(text)) {
|
|
23201
23004
|
signalProcessing(true);
|
|
23202
23005
|
sessionWasProcessing = true;
|
|
@@ -23581,11 +23384,11 @@ ${capturedError}${buildClaudeErrorHint(capturedError)}`;
|
|
|
23581
23384
|
});
|
|
23582
23385
|
},
|
|
23583
23386
|
onIssue: async (params) => {
|
|
23584
|
-
const { issueRpc } = await import('./rpc-
|
|
23387
|
+
const { issueRpc } = await import('./rpc-BPHQnoTZ.mjs');
|
|
23585
23388
|
return issueRpc(params?.cwd || directory, params || {}, { notifySession: notifyIssueOwner, rekickLoopOwner });
|
|
23586
23389
|
},
|
|
23587
23390
|
onWorkflow: async (params) => {
|
|
23588
|
-
const { workflowRpc } = await import('./rpc
|
|
23391
|
+
const { workflowRpc } = await import('./rpc--XZCm0p-.mjs');
|
|
23589
23392
|
return workflowRpc(params?.cwd || directory, params || {});
|
|
23590
23393
|
},
|
|
23591
23394
|
onRipgrep: async (args, cwd) => {
|
|
@@ -23726,7 +23529,6 @@ ${capturedError}${buildClaudeErrorHint(capturedError)}`;
|
|
|
23726
23529
|
currentTurnMessage = next.text;
|
|
23727
23530
|
pendingCompactTurn = isCompactCommand(next.text);
|
|
23728
23531
|
if (pendingCompactTurn) compactTurnLatch = true;
|
|
23729
|
-
autoCompactWasAutoInjected = pendingCompactTurn && !!next.autoCompact;
|
|
23730
23532
|
resetRateLimitStreak();
|
|
23731
23533
|
if (rateLimitRetryTimer) {
|
|
23732
23534
|
clearTimeout(rateLimitRetryTimer);
|
|
@@ -24309,11 +24111,11 @@ ${capturedError}${buildClaudeErrorHint(capturedError)}`;
|
|
|
24309
24111
|
});
|
|
24310
24112
|
},
|
|
24311
24113
|
onIssue: async (params) => {
|
|
24312
|
-
const { issueRpc } = await import('./rpc-
|
|
24114
|
+
const { issueRpc } = await import('./rpc-BPHQnoTZ.mjs');
|
|
24313
24115
|
return issueRpc(params?.cwd || directory, params || {}, { notifySession: notifyIssueOwner, rekickLoopOwner });
|
|
24314
24116
|
},
|
|
24315
24117
|
onWorkflow: async (params) => {
|
|
24316
|
-
const { workflowRpc } = await import('./rpc
|
|
24118
|
+
const { workflowRpc } = await import('./rpc--XZCm0p-.mjs');
|
|
24317
24119
|
return workflowRpc(params?.cwd || directory, params || {});
|
|
24318
24120
|
},
|
|
24319
24121
|
onRipgrep: async (args, cwd) => {
|
|
@@ -25668,7 +25470,7 @@ ${oracle.output.trim().slice(0, 500)}`, "\u{1F501} Continuing loop");
|
|
|
25668
25470
|
const PING_TIMEOUT_MS = 15e3;
|
|
25669
25471
|
const POST_RECONNECT_GRACE_MS = 2e4;
|
|
25670
25472
|
const RECONNECT_JITTER_MS = 2500;
|
|
25671
|
-
const { WorkflowScheduler } = await import('./scheduler-
|
|
25473
|
+
const { WorkflowScheduler } = await import('./scheduler-CF01et7j.mjs');
|
|
25672
25474
|
const workflowProjectRoots = () => {
|
|
25673
25475
|
const dirs = /* @__PURE__ */ new Set();
|
|
25674
25476
|
for (const s of pidToTrackedSession.values()) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as resolveProjectRoot, E as listWorkflows, F as isWorkflowEnabled, G as workflowSchedules, H as inZone, x as runWorkflow, I as cronMatches } from './run-
|
|
1
|
+
import { f as resolveProjectRoot, E as listWorkflows, F as isWorkflowEnabled, G as workflowSchedules, H as inZone, x as runWorkflow, I as cronMatches } from './run-UbzzPQPz.mjs';
|
|
2
2
|
import 'os';
|
|
3
3
|
import 'fs/promises';
|
|
4
4
|
import 'fs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as path from 'path';
|
|
2
|
-
import { w as wantsHelp } from './cli-
|
|
3
|
-
import './run-
|
|
2
|
+
import { w as wantsHelp } from './cli-0XZc7Ipp.mjs';
|
|
3
|
+
import './run-UbzzPQPz.mjs';
|
|
4
4
|
import 'os';
|
|
5
5
|
import 'fs/promises';
|
|
6
6
|
import 'fs';
|
|
@@ -77,7 +77,7 @@ async function handleServeCommand() {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
async function serveAdd(args, machineId) {
|
|
80
|
-
const { connectAndGetMachine } = await import('./commands-
|
|
80
|
+
const { connectAndGetMachine } = await import('./commands-CoImSc7s.mjs');
|
|
81
81
|
const pos = positionalArgs(args);
|
|
82
82
|
const name = pos[0];
|
|
83
83
|
if (!name) {
|
|
@@ -110,7 +110,7 @@ async function serveAdd(args, machineId) {
|
|
|
110
110
|
}
|
|
111
111
|
if (sessionId && result?.url) {
|
|
112
112
|
try {
|
|
113
|
-
const { autoAddSessionLink } = await import('./agentCommands-
|
|
113
|
+
const { autoAddSessionLink } = await import('./agentCommands-CIQbCUsB.mjs');
|
|
114
114
|
autoAddSessionLink(String(result.url), name, void 0, { kind: "serve", name });
|
|
115
115
|
} catch {
|
|
116
116
|
}
|
|
@@ -124,7 +124,7 @@ async function serveAdd(args, machineId) {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
async function serveApply(args, machineId) {
|
|
127
|
-
const { connectAndGetMachine } = await import('./commands-
|
|
127
|
+
const { connectAndGetMachine } = await import('./commands-CoImSc7s.mjs');
|
|
128
128
|
const fs = await import('fs');
|
|
129
129
|
const yaml = await import('yaml');
|
|
130
130
|
const file = positionalArgs(args)[0];
|
|
@@ -209,7 +209,7 @@ async function serveApply(args, machineId) {
|
|
|
209
209
|
console.log(`URL: ${result.url}`);
|
|
210
210
|
if (params.sessionId && result?.url) {
|
|
211
211
|
try {
|
|
212
|
-
const { autoAddSessionLink } = await import('./agentCommands-
|
|
212
|
+
const { autoAddSessionLink } = await import('./agentCommands-CIQbCUsB.mjs');
|
|
213
213
|
const prevSession = process.env.SVAMP_SESSION_ID;
|
|
214
214
|
process.env.SVAMP_SESSION_ID = String(params.sessionId);
|
|
215
215
|
try {
|
|
@@ -230,7 +230,7 @@ async function serveApply(args, machineId) {
|
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
async function serveRemove(args, machineId) {
|
|
233
|
-
const { connectAndGetMachine } = await import('./commands-
|
|
233
|
+
const { connectAndGetMachine } = await import('./commands-CoImSc7s.mjs');
|
|
234
234
|
const pos = positionalArgs(args);
|
|
235
235
|
const name = pos[0];
|
|
236
236
|
if (!name) {
|
|
@@ -240,7 +240,7 @@ async function serveRemove(args, machineId) {
|
|
|
240
240
|
const { machine, server } = await connectAndGetMachine(machineId);
|
|
241
241
|
try {
|
|
242
242
|
await machine.serveRemove({ name });
|
|
243
|
-
const { removeSessionLinkByService } = await import('./agentCommands-
|
|
243
|
+
const { removeSessionLinkByService } = await import('./agentCommands-CIQbCUsB.mjs');
|
|
244
244
|
removeSessionLinkByService("serve", name);
|
|
245
245
|
console.log(`Mount '${name}' removed.`);
|
|
246
246
|
} catch (err) {
|
|
@@ -252,7 +252,7 @@ async function serveRemove(args, machineId) {
|
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
async function serveList(args, machineId) {
|
|
255
|
-
const { connectAndGetMachine } = await import('./commands-
|
|
255
|
+
const { connectAndGetMachine } = await import('./commands-CoImSc7s.mjs');
|
|
256
256
|
const all = hasFlag(args, "--all", "-a");
|
|
257
257
|
const json = hasFlag(args, "--json");
|
|
258
258
|
const sessionId = getFlag(args, "--session");
|
|
@@ -286,7 +286,7 @@ async function serveList(args, machineId) {
|
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
async function serveInfo(machineId) {
|
|
289
|
-
const { connectAndGetMachine } = await import('./commands-
|
|
289
|
+
const { connectAndGetMachine } = await import('./commands-CoImSc7s.mjs');
|
|
290
290
|
const { machine, server } = await connectAndGetMachine(machineId);
|
|
291
291
|
try {
|
|
292
292
|
const info = await machine.serveInfo();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as READ_ONLY_TOOLS, P as loadMachineContext, Q as buildMachineInstructions, T as machineToolsForRole, U as buildMachineTools } from './run-
|
|
1
|
+
import { R as READ_ONLY_TOOLS, P as loadMachineContext, Q as buildMachineInstructions, T as machineToolsForRole, U as buildMachineTools } from './run-UbzzPQPz.mjs';
|
|
2
2
|
import 'node:child_process';
|
|
3
3
|
import 'os';
|
|
4
4
|
import 'fs/promises';
|