@ashx-j/lunr 0.2.19 → 0.2.20
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/CHANGELOG.md +23 -0
- package/README.md +2 -2
- package/dist/builtin-extensions/index.d.ts.map +1 -1
- package/dist/builtin-extensions/index.js +0 -2
- package/dist/builtin-extensions/index.js.map +1 -1
- package/dist/builtin-extensions/pi-intercom/broker/spawn.d.ts +6 -4
- package/dist/builtin-extensions/pi-intercom/broker/spawn.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-intercom/broker/spawn.js +93 -49
- package/dist/builtin-extensions/pi-intercom/broker/spawn.js.map +1 -1
- package/dist/builtin-extensions/pi-intercom/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-intercom/index.js +351 -351
- package/dist/builtin-extensions/pi-intercom/index.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts +2 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js +80 -43
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts +18 -8
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js +36 -11
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts +4 -3
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js +21 -12
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts +7 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js +225 -15
- package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.d.ts +29 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.js +179 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.d.ts +89 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.js +541 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts +9 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js +34 -9
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.js +1 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.d.ts +2 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.js +35 -8
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js +3 -3
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.d.ts +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.js +54 -38
- package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts +3 -6
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js +64 -5
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js +21 -8
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +62 -16
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.d.ts +2 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.js +75 -18
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.d.ts +13 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js +67 -11
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js +5 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js +13 -3
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.d.ts +3 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.js +68 -11
- package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/formatters.d.ts +12 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/formatters.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/formatters.js +21 -2
- package/dist/builtin-extensions/pi-subagents/src/shared/formatters.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts +16 -4
- package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/types.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/types.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts +2 -0
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js +24 -6
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts +44 -4
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js +227 -133
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.d.ts +2 -13
- package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.js +5 -91
- package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.js.map +1 -1
- package/dist/core/permissions.d.ts +1 -0
- package/dist/core/permissions.d.ts.map +1 -1
- package/dist/core/permissions.js +8 -4
- package/dist/core/permissions.js.map +1 -1
- package/dist/core/plan-mode.d.ts.map +1 -1
- package/dist/core/plan-mode.js +0 -5
- package/dist/core/plan-mode.js.map +1 -1
- package/dist/core/runtime-bridges.d.ts.map +1 -1
- package/dist/core/runtime-bridges.js +0 -2
- package/dist/core/runtime-bridges.js.map +1 -1
- package/dist/core/subagent-cancellation.d.ts +21 -0
- package/dist/core/subagent-cancellation.d.ts.map +1 -0
- package/dist/core/subagent-cancellation.js +53 -0
- package/dist/core/subagent-cancellation.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +12 -18
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +12 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +29 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/node-runtime/{agent-session-services-35WNVGMR.js → agent-session-services-75JKASCW.js} +3 -3
- package/dist/node-runtime/{builtin-extensions-322XDDEM.js → builtin-extensions-X4JMM4ZS.js} +2 -2
- package/dist/node-runtime/{chunk-XATUM2HK.js → chunk-25I2BHAA.js} +1 -1
- package/dist/node-runtime/{chunk-MCUNIRD5.js → chunk-46ECNOLF.js} +477 -246
- package/dist/node-runtime/{chunk-J26TSGDL.js → chunk-6N22HULO.js} +8 -5
- package/dist/node-runtime/{chunk-TFBIJTM3.js → chunk-AL2FMKKM.js} +7 -7
- package/dist/node-runtime/chunk-AOFXZQKA.js +24 -0
- package/dist/node-runtime/chunk-BBUVIEZB.js +51 -0
- package/dist/node-runtime/{chunk-ZRCBN365.js → chunk-ELWEXVO5.js} +7 -7
- package/dist/node-runtime/{chunk-ATGA2WLC.js → chunk-JYNNB7DU.js} +397 -34
- package/dist/node-runtime/{chunk-4FX25LWP.js → chunk-K3646JTM.js} +16 -117
- package/dist/node-runtime/{chunk-PNJSG3IZ.js → chunk-LTYWTR3V.js} +1 -369
- package/dist/node-runtime/{chunk-TXHKBRHZ.js → chunk-QKFMBRAL.js} +45 -31
- package/dist/node-runtime/{command-DWUM5X3U.js → command-RBTRL55A.js} +1 -1
- package/dist/node-runtime/{gateway-UZXMFGWY.js → gateway-L4ANRTVE.js} +2 -2
- package/dist/node-runtime/index.js +9 -8
- package/dist/node-runtime/{interactive-mode-QT5IKGQ5.js → interactive-mode-HPUNH7SV.js} +5 -4
- package/dist/node-runtime/{lunr-cron-QPBTKBGI.js → lunr-cron-NNYTWTGF.js} +2 -2
- package/dist/node-runtime/main.js +7 -7
- package/dist/node-runtime/{pi-intercom-EEMBGQID.js → pi-intercom-DDQMRNPJ.js} +96 -76
- package/dist/node-runtime/{pi-subagents-7YJ3I4VE.js → pi-subagents-T5WMMLBB.js} +1040 -318
- package/dist/node-runtime/rpc-entry.js +7 -7
- package/dist/node-runtime/{runtime-bridges-3RKBDLNA.js → runtime-bridges-NJQERQ72.js} +2 -4
- package/dist/node-runtime/{subagent-executor-5Q5A4HJ2.js → subagent-executor-SRFC26SJ.js} +168 -249
- package/docs/features.md +17 -3
- package/docs/keybindings.md +3 -1
- package/docs/settings.md +1 -1
- package/package.json +4 -4
- package/dist/builtin-extensions/lunr-settings-tools.d.ts +0 -4
- package/dist/builtin-extensions/lunr-settings-tools.d.ts.map +0 -1
- package/dist/builtin-extensions/lunr-settings-tools.js +0 -120
- package/dist/builtin-extensions/lunr-settings-tools.js.map +0 -1
- package/dist/core/settings-tools-bridge.d.ts +0 -35
- package/dist/core/settings-tools-bridge.d.ts.map +0 -1
- package/dist/core/settings-tools-bridge.js +0 -56
- package/dist/core/settings-tools-bridge.js.map +0 -1
- package/dist/node-runtime/chunk-3NMWLTPV.js +0 -64
|
@@ -53,12 +53,11 @@ import {
|
|
|
53
53
|
convertToLlm
|
|
54
54
|
} from "./chunk-FVDOXRUD.js";
|
|
55
55
|
import {
|
|
56
|
-
clearPlanUsageCache
|
|
57
|
-
|
|
58
|
-
} from "./chunk-PNJSG3IZ.js";
|
|
56
|
+
clearPlanUsageCache
|
|
57
|
+
} from "./chunk-LTYWTR3V.js";
|
|
59
58
|
import {
|
|
60
59
|
gateToolCall
|
|
61
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-6N22HULO.js";
|
|
62
61
|
import {
|
|
63
62
|
isUserInstructionsPath,
|
|
64
63
|
loadSelectedUserInstructions
|
|
@@ -75,6 +74,7 @@ import {
|
|
|
75
74
|
theme
|
|
76
75
|
} from "./chunk-RNBHABBA.js";
|
|
77
76
|
import {
|
|
77
|
+
CONFIG_DIR_NAME,
|
|
78
78
|
VERSION,
|
|
79
79
|
getAgentDir,
|
|
80
80
|
getDocsPath,
|
|
@@ -89,7 +89,7 @@ import {
|
|
|
89
89
|
} from "./chunk-BRJX2PRC.js";
|
|
90
90
|
|
|
91
91
|
// packages/coding-agent/dist/core/agent-session-services.js
|
|
92
|
-
import { join as
|
|
92
|
+
import { join as join14 } from "node:path";
|
|
93
93
|
|
|
94
94
|
// packages/coding-agent/dist/core/model-runtime.js
|
|
95
95
|
import { dirname as dirname5, join as join7 } from "node:path";
|
|
@@ -2891,23 +2891,23 @@ async function refreshModelCandidatesForInit(runtime) {
|
|
|
2891
2891
|
}
|
|
2892
2892
|
|
|
2893
2893
|
// packages/coding-agent/dist/core/sdk.js
|
|
2894
|
-
import { join as
|
|
2894
|
+
import { join as join13 } from "node:path";
|
|
2895
2895
|
import { Agent } from "@ashx-j/lunr-agent";
|
|
2896
2896
|
import { clampThinkingLevel as clampThinkingLevel2 } from "@ashx-j/lunr-ai";
|
|
2897
2897
|
|
|
2898
2898
|
// packages/coding-agent/dist/core/agent-session.js
|
|
2899
|
-
import { existsSync as
|
|
2900
|
-
import { basename, dirname as
|
|
2899
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync6, readFileSync as readFileSync6, writeFileSync as writeFileSync6 } from "node:fs";
|
|
2900
|
+
import { basename, dirname as dirname7, join as join11, resolve as resolve2 } from "node:path";
|
|
2901
2901
|
import { clampThinkingLevel, cleanupSessionResources, getSupportedThinkingLevels, isContextOverflow, isRetryableAssistantError, modelsAreEqual, resetApiProviders, streamSimple } from "@ashx-j/lunr-ai/compat";
|
|
2902
2902
|
|
|
2903
2903
|
// packages/coding-agent/dist/utils/sleep.js
|
|
2904
2904
|
function sleep(ms, signal) {
|
|
2905
|
-
return new Promise((
|
|
2905
|
+
return new Promise((resolve4, reject) => {
|
|
2906
2906
|
if (signal?.aborted) {
|
|
2907
2907
|
reject(new Error("Aborted"));
|
|
2908
2908
|
return;
|
|
2909
2909
|
}
|
|
2910
|
-
let timeout = setTimeout(
|
|
2910
|
+
let timeout = setTimeout(resolve4, ms);
|
|
2911
2911
|
signal?.addEventListener("abort", () => {
|
|
2912
2912
|
clearTimeout(timeout), reject(new Error("Aborted"));
|
|
2913
2913
|
});
|
|
@@ -3085,6 +3085,357 @@ var ModelRegistry = class {
|
|
|
3085
3085
|
}
|
|
3086
3086
|
};
|
|
3087
3087
|
|
|
3088
|
+
// packages/coding-agent/dist/core/rollback.js
|
|
3089
|
+
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
3090
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
3091
|
+
import { cpSync, existsSync as existsSync5, mkdirSync as mkdirSync5, readdirSync, readFileSync as readFileSync5, renameSync as renameSync4, rmSync, unlinkSync as unlinkSync4, writeFileSync as writeFileSync5 } from "node:fs";
|
|
3092
|
+
import { homedir as homedir2 } from "node:os";
|
|
3093
|
+
import { dirname as dirname6, join as join10, normalize, resolve } from "node:path";
|
|
3094
|
+
var ROLLBACK_BASE = join10(homedir2(), ".lunr", "rollback"), contexts = /* @__PURE__ */ new Map(), lastSessionId, globalSettingsManager, warningHandler;
|
|
3095
|
+
function setRollbackWarningHandler(handler) {
|
|
3096
|
+
warningHandler = handler;
|
|
3097
|
+
}
|
|
3098
|
+
function createContext(sessionId) {
|
|
3099
|
+
return {
|
|
3100
|
+
sessionId,
|
|
3101
|
+
settingsManager: globalSettingsManager,
|
|
3102
|
+
sessionForceEnabled: !1,
|
|
3103
|
+
turns: [],
|
|
3104
|
+
currentTurnIndex: -1,
|
|
3105
|
+
repoWarningShown: !1,
|
|
3106
|
+
externalModWarningShown: !1
|
|
3107
|
+
};
|
|
3108
|
+
}
|
|
3109
|
+
function getContext(sessionId) {
|
|
3110
|
+
let sid = sessionId ?? lastSessionId ?? "default", ctx = contexts.get(sid);
|
|
3111
|
+
return ctx || (ctx = createContext(sid), contexts.set(sid, ctx)), ctx;
|
|
3112
|
+
}
|
|
3113
|
+
function initRollback(sm, sid) {
|
|
3114
|
+
globalSettingsManager = sm, lastSessionId = sid, contexts.set(sid, createContext(sid));
|
|
3115
|
+
let ctx = contexts.get(sid);
|
|
3116
|
+
ctx.settingsManager = sm, loadPersistedTurns(ctx);
|
|
3117
|
+
}
|
|
3118
|
+
function isRollbackEnabled(sessionId) {
|
|
3119
|
+
let ctx = getContext(sessionId);
|
|
3120
|
+
return (ctx.settingsManager?.getRollbackEnabled() ?? !1) || ctx.sessionForceEnabled;
|
|
3121
|
+
}
|
|
3122
|
+
function isRollbackSessionForceEnabled(sessionId) {
|
|
3123
|
+
return getContext(sessionId).sessionForceEnabled;
|
|
3124
|
+
}
|
|
3125
|
+
function enableRollbackForSession(sessionId) {
|
|
3126
|
+
getContext(sessionId).sessionForceEnabled = !0;
|
|
3127
|
+
}
|
|
3128
|
+
function disableRollbackForSession(sessionId) {
|
|
3129
|
+
getContext(sessionId).sessionForceEnabled = !1;
|
|
3130
|
+
}
|
|
3131
|
+
function pruneTurns(ctx) {
|
|
3132
|
+
let maxTurns = ctx.settingsManager?.getRollbackTurns() ?? 2;
|
|
3133
|
+
for (; ctx.turns.length > maxTurns; ) {
|
|
3134
|
+
let old = ctx.turns.shift();
|
|
3135
|
+
old && cleanupTurnFiles(ctx, old);
|
|
3136
|
+
}
|
|
3137
|
+
}
|
|
3138
|
+
function beginTurn(cwd, sessionId) {
|
|
3139
|
+
let ctx = getContext(sessionId);
|
|
3140
|
+
if (!isRollbackEnabled(ctx.sessionId))
|
|
3141
|
+
return;
|
|
3142
|
+
cwd && (ctx.lastCwd = cwd), ctx.currentTurnIndex++;
|
|
3143
|
+
let turn = { turnIndex: ctx.currentTurnIndex, cwd, files: /* @__PURE__ */ new Map() };
|
|
3144
|
+
ctx.turns.push(turn), pruneTurns(ctx), cwd && ctx.settingsManager?.getRollbackScope() === "tree" && captureTreeBaseline(ctx, cwd);
|
|
3145
|
+
}
|
|
3146
|
+
function rollbackSnapshotBeforeWrite(absPath, sessionId) {
|
|
3147
|
+
let ctx = getContext(sessionId);
|
|
3148
|
+
if (!isRollbackEnabled(ctx.sessionId))
|
|
3149
|
+
return;
|
|
3150
|
+
(ctx.currentTurnIndex < 0 || ctx.turns.length === 0) && beginTurn(ctx.lastCwd, ctx.sessionId);
|
|
3151
|
+
let turn = ctx.turns[ctx.turns.length - 1];
|
|
3152
|
+
if (turn && !turn.files.has(absPath))
|
|
3153
|
+
try {
|
|
3154
|
+
let existed = existsSync5(absPath), content;
|
|
3155
|
+
existed && (content = readFileSync5(absPath)), turn.files.set(absPath, {
|
|
3156
|
+
existed,
|
|
3157
|
+
content,
|
|
3158
|
+
createdByTool: !0
|
|
3159
|
+
}), persistSnapshot(ctx, turn, absPath);
|
|
3160
|
+
} catch {
|
|
3161
|
+
}
|
|
3162
|
+
}
|
|
3163
|
+
function captureTreeBaseline(ctx, cwd) {
|
|
3164
|
+
let turn = ctx.turns[ctx.turns.length - 1];
|
|
3165
|
+
if (!turn)
|
|
3166
|
+
return;
|
|
3167
|
+
let entries = gitPorcelain(ctx, cwd);
|
|
3168
|
+
if (entries)
|
|
3169
|
+
for (let { path } of entries) {
|
|
3170
|
+
if (!path)
|
|
3171
|
+
continue;
|
|
3172
|
+
let abs = join10(cwd, path);
|
|
3173
|
+
if (!turn.files.has(abs))
|
|
3174
|
+
try {
|
|
3175
|
+
let existed = existsSync5(abs);
|
|
3176
|
+
turn.files.set(abs, {
|
|
3177
|
+
existed,
|
|
3178
|
+
content: existed ? readFileSync5(abs) : void 0,
|
|
3179
|
+
createdByTool: !1
|
|
3180
|
+
}), persistSnapshot(ctx, turn, abs);
|
|
3181
|
+
} catch {
|
|
3182
|
+
}
|
|
3183
|
+
}
|
|
3184
|
+
}
|
|
3185
|
+
function captureTreeChanges(cwd, sessionId) {
|
|
3186
|
+
let ctx = getContext(sessionId);
|
|
3187
|
+
if (!isRollbackEnabled(ctx.sessionId) || ctx.settingsManager?.getRollbackScope() !== "tree" || ctx.currentTurnIndex < 0 || ctx.turns.length === 0)
|
|
3188
|
+
return;
|
|
3189
|
+
let turn = ctx.turns[ctx.turns.length - 1];
|
|
3190
|
+
if (!turn)
|
|
3191
|
+
return;
|
|
3192
|
+
let entries = gitPorcelain(ctx, cwd);
|
|
3193
|
+
if (entries)
|
|
3194
|
+
for (let { status, path, source } of entries) {
|
|
3195
|
+
if (!path)
|
|
3196
|
+
continue;
|
|
3197
|
+
let abs = join10(cwd, path);
|
|
3198
|
+
if (!turn.files.has(abs))
|
|
3199
|
+
try {
|
|
3200
|
+
if (status === "??" || status.includes("R")) {
|
|
3201
|
+
if (turn.files.set(abs, { existed: !1, createdByTool: !1 }), persistSnapshot(ctx, turn, abs), status.includes("R") && source) {
|
|
3202
|
+
let sourceAbs = join10(cwd, source);
|
|
3203
|
+
if (!turn.files.has(sourceAbs)) {
|
|
3204
|
+
let headSrc = spawnSync2("git", ["show", `HEAD:${source}`], {
|
|
3205
|
+
cwd,
|
|
3206
|
+
timeout: 5e3,
|
|
3207
|
+
maxBuffer: 33554432
|
|
3208
|
+
});
|
|
3209
|
+
!headSrc.error && headSrc.status === 0 && headSrc.stdout && (turn.files.set(sourceAbs, {
|
|
3210
|
+
existed: !0,
|
|
3211
|
+
content: headSrc.stdout,
|
|
3212
|
+
createdByTool: !1
|
|
3213
|
+
}), persistSnapshot(ctx, turn, sourceAbs));
|
|
3214
|
+
}
|
|
3215
|
+
}
|
|
3216
|
+
} else {
|
|
3217
|
+
let head = spawnSync2("git", ["show", `HEAD:${path}`], {
|
|
3218
|
+
cwd,
|
|
3219
|
+
timeout: 5e3,
|
|
3220
|
+
maxBuffer: 33554432
|
|
3221
|
+
});
|
|
3222
|
+
if (head.error || head.status !== 0 || !head.stdout)
|
|
3223
|
+
continue;
|
|
3224
|
+
turn.files.set(abs, {
|
|
3225
|
+
existed: !0,
|
|
3226
|
+
content: head.stdout,
|
|
3227
|
+
createdByTool: !1
|
|
3228
|
+
}), persistSnapshot(ctx, turn, abs);
|
|
3229
|
+
}
|
|
3230
|
+
} catch {
|
|
3231
|
+
}
|
|
3232
|
+
}
|
|
3233
|
+
}
|
|
3234
|
+
function gitPorcelain(ctx, cwd) {
|
|
3235
|
+
try {
|
|
3236
|
+
let result = spawnSync2("git", ["status", "--porcelain", "-z"], { cwd, encoding: "utf8", timeout: 5e3 });
|
|
3237
|
+
if (result.error || result.status !== 0) {
|
|
3238
|
+
warnOnce(ctx, "Rollback tree scope: not a git repository (or git failed) \u2014 bash side-effects won't be captured.");
|
|
3239
|
+
return;
|
|
3240
|
+
}
|
|
3241
|
+
let fields = (result.stdout ?? "").split("\0").filter((f) => f.length > 0), entries = [];
|
|
3242
|
+
for (let i = 0; i < fields.length; i++) {
|
|
3243
|
+
let field = fields[i], status = field.slice(0, 2), path = field.slice(3), source;
|
|
3244
|
+
(status.includes("R") || status.includes("C")) && (source = fields[i + 1], i++), entries.push({ status, path, source });
|
|
3245
|
+
}
|
|
3246
|
+
return entries;
|
|
3247
|
+
} catch {
|
|
3248
|
+
warnOnce(ctx, "Rollback tree scope: not a git repository (or git failed) \u2014 bash side-effects won't be captured.");
|
|
3249
|
+
return;
|
|
3250
|
+
}
|
|
3251
|
+
}
|
|
3252
|
+
function warnOnce(ctx, message) {
|
|
3253
|
+
if (!ctx.repoWarningShown) {
|
|
3254
|
+
ctx.repoWarningShown = !0;
|
|
3255
|
+
try {
|
|
3256
|
+
warningHandler?.(message);
|
|
3257
|
+
} catch {
|
|
3258
|
+
}
|
|
3259
|
+
}
|
|
3260
|
+
}
|
|
3261
|
+
function persistSnapshot(ctx, turn, absPath) {
|
|
3262
|
+
try {
|
|
3263
|
+
let snap = turn.files.get(absPath);
|
|
3264
|
+
if (!snap)
|
|
3265
|
+
return;
|
|
3266
|
+
let turnDir = getTurnDir(ctx, turn.turnIndex);
|
|
3267
|
+
mkdirSync5(turnDir, { recursive: !0 });
|
|
3268
|
+
let manifestPath = join10(turnDir, "manifest.json"), manifest = readManifest(manifestPath), entry = { existed: snap.existed, createdByTool: snap.createdByTool };
|
|
3269
|
+
if (snap.content) {
|
|
3270
|
+
let snapFile = snapFileName(absPath);
|
|
3271
|
+
writeFileSync5(join10(turnDir, snapFile), snap.content), entry.snapFile = snapFile;
|
|
3272
|
+
}
|
|
3273
|
+
manifest.files[absPath] = entry, turn.cwd && (manifest.cwd = turn.cwd), writeFileSync5(manifestPath, JSON.stringify(manifest, null, 2));
|
|
3274
|
+
} catch {
|
|
3275
|
+
}
|
|
3276
|
+
}
|
|
3277
|
+
function readManifest(path) {
|
|
3278
|
+
if (!existsSync5(path))
|
|
3279
|
+
return { files: {} };
|
|
3280
|
+
try {
|
|
3281
|
+
let parsed = JSON.parse(readFileSync5(path, "utf-8"));
|
|
3282
|
+
if (parsed && typeof parsed == "object" && !Array.isArray(parsed)) {
|
|
3283
|
+
let files = parsed.files;
|
|
3284
|
+
return {
|
|
3285
|
+
cwd: typeof parsed.cwd == "string" ? parsed.cwd : void 0,
|
|
3286
|
+
files: files && typeof files == "object" && !Array.isArray(files) ? files : {}
|
|
3287
|
+
};
|
|
3288
|
+
}
|
|
3289
|
+
return { files: {} };
|
|
3290
|
+
} catch {
|
|
3291
|
+
return { files: {} };
|
|
3292
|
+
}
|
|
3293
|
+
}
|
|
3294
|
+
function loadPersistedTurns(ctx) {
|
|
3295
|
+
try {
|
|
3296
|
+
let sessionDir = join10(ROLLBACK_BASE, ctx.sessionId);
|
|
3297
|
+
if (!existsSync5(sessionDir))
|
|
3298
|
+
return;
|
|
3299
|
+
let loaded = [];
|
|
3300
|
+
for (let dirName of readdirSync(sessionDir)) {
|
|
3301
|
+
let match = /^turn-(\d+)$/.exec(dirName);
|
|
3302
|
+
if (!match)
|
|
3303
|
+
continue;
|
|
3304
|
+
let turnIndex = Number(match[1]), turnDir = join10(sessionDir, dirName), manifest = readManifest(join10(turnDir, "manifest.json")), files = /* @__PURE__ */ new Map();
|
|
3305
|
+
for (let [absPath, meta] of Object.entries(manifest.files)) {
|
|
3306
|
+
let content;
|
|
3307
|
+
if (meta.snapFile)
|
|
3308
|
+
try {
|
|
3309
|
+
content = readFileSync5(join10(turnDir, meta.snapFile));
|
|
3310
|
+
} catch {
|
|
3311
|
+
content = void 0;
|
|
3312
|
+
}
|
|
3313
|
+
files.set(absPath, { existed: meta.existed, content, createdByTool: meta.createdByTool });
|
|
3314
|
+
}
|
|
3315
|
+
loaded.push({ turnIndex, cwd: manifest.cwd, files });
|
|
3316
|
+
}
|
|
3317
|
+
loaded.sort((a, b) => a.turnIndex - b.turnIndex), ctx.turns = loaded, ctx.currentTurnIndex = loaded.length > 0 ? loaded[loaded.length - 1].turnIndex : -1, pruneTurns(ctx);
|
|
3318
|
+
} catch {
|
|
3319
|
+
}
|
|
3320
|
+
}
|
|
3321
|
+
function getTurnDir(ctx, turnIndex) {
|
|
3322
|
+
return join10(ROLLBACK_BASE, ctx.sessionId, `turn-${turnIndex}`);
|
|
3323
|
+
}
|
|
3324
|
+
function cleanupTurnFiles(ctx, turn) {
|
|
3325
|
+
try {
|
|
3326
|
+
let dir = getTurnDir(ctx, turn.turnIndex);
|
|
3327
|
+
existsSync5(dir) && rmSync(dir, { recursive: !0, force: !0 });
|
|
3328
|
+
} catch {
|
|
3329
|
+
}
|
|
3330
|
+
}
|
|
3331
|
+
function isPathUnderRoot(absPath, root) {
|
|
3332
|
+
let normRoot = normalize(root).replace(/\\$/g, ""), normPath = normalize(absPath).replace(/\\$/g, "");
|
|
3333
|
+
return process.platform === "win32" && (normRoot = normRoot.toLowerCase(), normPath = normPath.toLowerCase()), normPath === normRoot || normPath.startsWith(`${normRoot}/`) || normPath.startsWith(`${normRoot}\\`);
|
|
3334
|
+
}
|
|
3335
|
+
function isWithinAllowedRoots(absPath, turn) {
|
|
3336
|
+
return turn.cwd ? [
|
|
3337
|
+
ROLLBACK_BASE,
|
|
3338
|
+
join10(homedir2(), CONFIG_DIR_NAME),
|
|
3339
|
+
// lunr: agent settings / cron jobs.json live under the config dir
|
|
3340
|
+
// lunr: simple-memory lives next to the lunr agent dir (~/.lunr/simple-memory)
|
|
3341
|
+
join10(dirname6(getAgentDir()), "simple-memory"),
|
|
3342
|
+
resolve(turn.cwd)
|
|
3343
|
+
].some((root) => isPathUnderRoot(absPath, root)) : !0;
|
|
3344
|
+
}
|
|
3345
|
+
function warnExternalModification(ctx, message) {
|
|
3346
|
+
if (!(ctx.externalModWarningShown || !warningHandler)) {
|
|
3347
|
+
ctx.externalModWarningShown = !0;
|
|
3348
|
+
try {
|
|
3349
|
+
warningHandler(message);
|
|
3350
|
+
} catch {
|
|
3351
|
+
}
|
|
3352
|
+
}
|
|
3353
|
+
}
|
|
3354
|
+
function peekRollbackTurnsConsumed(sessionId) {
|
|
3355
|
+
let ctx = getContext(sessionId);
|
|
3356
|
+
if (!isRollbackEnabled(ctx.sessionId) || ctx.turns.length === 0)
|
|
3357
|
+
return 0;
|
|
3358
|
+
let consumed = 0;
|
|
3359
|
+
for (let i = ctx.turns.length - 1; i >= 0 && (consumed++, !(ctx.turns[i].files.size > 0)); i--)
|
|
3360
|
+
;
|
|
3361
|
+
return consumed;
|
|
3362
|
+
}
|
|
3363
|
+
function rollbackLastTurn(sessionId) {
|
|
3364
|
+
let ctx = getContext(sessionId), empty = { restored: [], deleted: [], turnsConsumed: 0 };
|
|
3365
|
+
if (!isRollbackEnabled(ctx.sessionId))
|
|
3366
|
+
return empty;
|
|
3367
|
+
let turnsConsumed = 0;
|
|
3368
|
+
for (; ctx.turns.length > 0 && ctx.turns[ctx.turns.length - 1].files.size === 0; ) {
|
|
3369
|
+
let skipped = ctx.turns.pop();
|
|
3370
|
+
skipped && (cleanupTurnFiles(ctx, skipped), turnsConsumed++);
|
|
3371
|
+
}
|
|
3372
|
+
if (ctx.turns.length === 0)
|
|
3373
|
+
return empty;
|
|
3374
|
+
turnsConsumed++;
|
|
3375
|
+
let turn = ctx.turns[ctx.turns.length - 1], capture = ctx.settingsManager?.getRollbackCapture() ?? "copies", restored = [], deleted = [];
|
|
3376
|
+
for (let [absPath, snap] of turn.files)
|
|
3377
|
+
try {
|
|
3378
|
+
if (!isWithinAllowedRoots(absPath, turn)) {
|
|
3379
|
+
warnExternalModification(ctx, `Rollback skipped ${absPath}: outside the session working directory or lunR config dir.`);
|
|
3380
|
+
continue;
|
|
3381
|
+
}
|
|
3382
|
+
if (snap.existed && snap.content) {
|
|
3383
|
+
if (!snap.createdByTool && existsSync5(absPath) && readFileSync5(absPath).equals(snap.content))
|
|
3384
|
+
continue;
|
|
3385
|
+
mkdirSync5(dirname6(absPath), { recursive: !0 }), writeFileSync5(absPath, snap.content), restored.push(absPath);
|
|
3386
|
+
} else snap.existed || (snap.createdByTool || capture === "hybrid" || capture === "shadow-git") && existsSync5(absPath) && (unlinkSync4(absPath), deleted.push(absPath));
|
|
3387
|
+
} catch {
|
|
3388
|
+
}
|
|
3389
|
+
return cleanupTurnFiles(ctx, turn), ctx.turns.pop(), { restored, deleted, turnsConsumed };
|
|
3390
|
+
}
|
|
3391
|
+
function migrateRollbackSession(oldSessionId, newSessionId) {
|
|
3392
|
+
if (oldSessionId === newSessionId)
|
|
3393
|
+
return;
|
|
3394
|
+
let ctx = contexts.get(oldSessionId);
|
|
3395
|
+
ctx && (contexts.delete(oldSessionId), ctx.sessionId = newSessionId, contexts.set(newSessionId, ctx));
|
|
3396
|
+
try {
|
|
3397
|
+
let oldDir = join10(ROLLBACK_BASE, oldSessionId), newDir = join10(ROLLBACK_BASE, newSessionId);
|
|
3398
|
+
if (existsSync5(oldDir)) {
|
|
3399
|
+
existsSync5(newDir) && rmSync(newDir, { recursive: !0, force: !0 });
|
|
3400
|
+
try {
|
|
3401
|
+
renameSync4(oldDir, newDir);
|
|
3402
|
+
} catch {
|
|
3403
|
+
cpSync(oldDir, newDir, { recursive: !0 }), rmSync(oldDir, { recursive: !0, force: !0 });
|
|
3404
|
+
}
|
|
3405
|
+
}
|
|
3406
|
+
} catch {
|
|
3407
|
+
}
|
|
3408
|
+
}
|
|
3409
|
+
function clearRollback(sessionId) {
|
|
3410
|
+
if (sessionId === void 0) {
|
|
3411
|
+
for (let ctx2 of contexts.values()) {
|
|
3412
|
+
for (let turn of ctx2.turns)
|
|
3413
|
+
cleanupTurnFiles(ctx2, turn);
|
|
3414
|
+
try {
|
|
3415
|
+
let sessionDir = join10(ROLLBACK_BASE, ctx2.sessionId);
|
|
3416
|
+
existsSync5(sessionDir) && rmSync(sessionDir, { recursive: !0, force: !0 });
|
|
3417
|
+
} catch {
|
|
3418
|
+
}
|
|
3419
|
+
}
|
|
3420
|
+
contexts.clear();
|
|
3421
|
+
return;
|
|
3422
|
+
}
|
|
3423
|
+
let ctx = contexts.get(sessionId);
|
|
3424
|
+
if (ctx) {
|
|
3425
|
+
for (let turn of ctx.turns)
|
|
3426
|
+
cleanupTurnFiles(ctx, turn);
|
|
3427
|
+
try {
|
|
3428
|
+
let sessionDir = join10(ROLLBACK_BASE, sessionId);
|
|
3429
|
+
existsSync5(sessionDir) && rmSync(sessionDir, { recursive: !0, force: !0 });
|
|
3430
|
+
} catch {
|
|
3431
|
+
}
|
|
3432
|
+
contexts.delete(sessionId);
|
|
3433
|
+
}
|
|
3434
|
+
}
|
|
3435
|
+
function snapFileName(absPath) {
|
|
3436
|
+
return `${createHash3("sha1").update(absPath).digest("hex")}.snap`;
|
|
3437
|
+
}
|
|
3438
|
+
|
|
3088
3439
|
// packages/coding-agent/dist/core/system-prompt.js
|
|
3089
3440
|
function buildSystemPrompt(options) {
|
|
3090
3441
|
let { customPrompt, modelSlug, selectedTools, appendSystemPrompt, cwd, contextFiles: providedContextFiles, skills: providedSkills } = options, promptCwd = cwd.replace(/\\/g, "/"), appendSection = appendSystemPrompt ? `
|
|
@@ -3315,14 +3666,14 @@ var THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"
|
|
|
3315
3666
|
if (permBlock)
|
|
3316
3667
|
return { block: !0, reason: permBlock.reason };
|
|
3317
3668
|
try {
|
|
3318
|
-
let toolName = toolCall.name, argPath = args && typeof args == "object" && "path" in args ?
|
|
3669
|
+
let toolName = toolCall.name, argPath = args && typeof args == "object" && "path" in args ? resolve2(this._cwd, String(args.path)) : void 0, pathsToSnapshot = [];
|
|
3319
3670
|
if (toolName === "edit" || toolName === "write")
|
|
3320
3671
|
argPath && pathsToSnapshot.push(argPath);
|
|
3321
3672
|
else if (toolName === "memory_add" || toolName === "memory_remove")
|
|
3322
|
-
pathsToSnapshot.push(
|
|
3673
|
+
pathsToSnapshot.push(join11(dirname7(getAgentDir()), "simple-memory", "memory.md"));
|
|
3323
3674
|
else if (toolName === "cron" && args && typeof args == "object") {
|
|
3324
3675
|
let action = String(args.action ?? "");
|
|
3325
|
-
(action === "create" || action === "update" || action === "remove") && pathsToSnapshot.push(
|
|
3676
|
+
(action === "create" || action === "update" || action === "remove") && pathsToSnapshot.push(join11(getAgentDir(), "cron", "jobs.json"));
|
|
3326
3677
|
}
|
|
3327
3678
|
for (let p of pathsToSnapshot)
|
|
3328
3679
|
rollbackSnapshotBeforeWrite(p, this.sessionId);
|
|
@@ -3404,15 +3755,15 @@ var THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"
|
|
|
3404
3755
|
});
|
|
3405
3756
|
}
|
|
3406
3757
|
_getIdleWaitPromise() {
|
|
3407
|
-
return this._idleWaitPromise || (this._idleWaitPromise = new Promise((
|
|
3408
|
-
this._resolveIdleWait =
|
|
3758
|
+
return this._idleWaitPromise || (this._idleWaitPromise = new Promise((resolve4) => {
|
|
3759
|
+
this._resolveIdleWait = resolve4;
|
|
3409
3760
|
})), this._idleWaitPromise;
|
|
3410
3761
|
}
|
|
3411
3762
|
_resolveIdleWaitIfIdle() {
|
|
3412
3763
|
if (this._isAgentRunActive || !this._resolveIdleWait)
|
|
3413
3764
|
return;
|
|
3414
|
-
let
|
|
3415
|
-
this._idleWaitPromise = void 0, this._resolveIdleWait = void 0,
|
|
3765
|
+
let resolve4 = this._resolveIdleWait;
|
|
3766
|
+
this._idleWaitPromise = void 0, this._resolveIdleWait = void 0, resolve4();
|
|
3416
3767
|
}
|
|
3417
3768
|
async _emitAgentSettled() {
|
|
3418
3769
|
this._isAgentRunActive = !1;
|
|
@@ -3892,7 +4243,7 @@ ${this._systemPromptAppend}` : prompt;
|
|
|
3892
4243
|
if (!skill)
|
|
3893
4244
|
return text;
|
|
3894
4245
|
try {
|
|
3895
|
-
let content =
|
|
4246
|
+
let content = readFileSync6(skill.filePath, "utf-8"), body = stripFrontmatter(content).trim(), skillBlock = `<skill name="${skill.name}" location="${skill.filePath}">
|
|
3896
4247
|
References are relative to ${skill.baseDir}.
|
|
3897
4248
|
|
|
3898
4249
|
${body}
|
|
@@ -4526,7 +4877,7 @@ ${args}` : skillBlock;
|
|
|
4526
4877
|
}
|
|
4527
4878
|
buildExtensionResourcePaths(entries) {
|
|
4528
4879
|
return entries.map((entry) => {
|
|
4529
|
-
let source = this.getExtensionSourceLabel(entry.extensionPath), baseDir = entry.extensionPath.startsWith("<") ? void 0 :
|
|
4880
|
+
let source = this.getExtensionSourceLabel(entry.extensionPath), baseDir = entry.extensionPath.startsWith("<") ? void 0 : dirname7(entry.extensionPath);
|
|
4530
4881
|
return {
|
|
4531
4882
|
path: entry.path,
|
|
4532
4883
|
metadata: {
|
|
@@ -5108,8 +5459,8 @@ ${command}` : command;
|
|
|
5108
5459
|
* @returns The resolved output file path.
|
|
5109
5460
|
*/
|
|
5110
5461
|
exportToJsonl(outputPath) {
|
|
5111
|
-
let filePath = resolvePath(outputPath ?? `session-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.jsonl`, process.cwd()), dir =
|
|
5112
|
-
|
|
5462
|
+
let filePath = resolvePath(outputPath ?? `session-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.jsonl`, process.cwd()), dir = dirname7(filePath);
|
|
5463
|
+
existsSync6(dir) || mkdirSync6(dir, { recursive: !0 });
|
|
5113
5464
|
let header = {
|
|
5114
5465
|
type: "session",
|
|
5115
5466
|
version: CURRENT_SESSION_VERSION,
|
|
@@ -5121,7 +5472,7 @@ ${command}` : command;
|
|
|
5121
5472
|
let linear = { ...entry, parentId: prevId };
|
|
5122
5473
|
lines.push(JSON.stringify(linear)), prevId = entry.id;
|
|
5123
5474
|
}
|
|
5124
|
-
return
|
|
5475
|
+
return writeFileSync6(filePath, `${lines.join(`
|
|
5125
5476
|
`)}
|
|
5126
5477
|
`), filePath;
|
|
5127
5478
|
}
|
|
@@ -5191,17 +5542,17 @@ function mergeProviderAttributionHeaders(model, _settingsManager, sessionId, ...
|
|
|
5191
5542
|
}
|
|
5192
5543
|
|
|
5193
5544
|
// packages/coding-agent/dist/core/agent-session-runtime.js
|
|
5194
|
-
import { copyFileSync, existsSync as
|
|
5195
|
-
import { basename as basename2, join as
|
|
5545
|
+
import { copyFileSync, existsSync as existsSync8, mkdirSync as mkdirSync7 } from "node:fs";
|
|
5546
|
+
import { basename as basename2, join as join12, resolve as resolve3 } from "node:path";
|
|
5196
5547
|
|
|
5197
5548
|
// packages/coding-agent/dist/core/session-cwd.js
|
|
5198
|
-
import { existsSync as
|
|
5549
|
+
import { existsSync as existsSync7 } from "node:fs";
|
|
5199
5550
|
function getMissingSessionCwdIssue(sessionManager, fallbackCwd) {
|
|
5200
5551
|
let sessionFile = sessionManager.getSessionFile();
|
|
5201
5552
|
if (!sessionFile)
|
|
5202
5553
|
return;
|
|
5203
5554
|
let sessionCwd = sessionManager.getCwd();
|
|
5204
|
-
if (!(!sessionCwd ||
|
|
5555
|
+
if (!(!sessionCwd || existsSync7(sessionCwd)))
|
|
5205
5556
|
return {
|
|
5206
5557
|
sessionFile,
|
|
5207
5558
|
sessionCwd,
|
|
@@ -5367,7 +5718,7 @@ var AgentSessionRuntime = class {
|
|
|
5367
5718
|
sessionStartEvent: { type: "session_start", reason: "fork", previousSessionFile }
|
|
5368
5719
|
})), await this.finishSessionReplacement(options?.withSession), { cancelled: !1, selectedText };
|
|
5369
5720
|
}
|
|
5370
|
-
if (!
|
|
5721
|
+
if (!existsSync8(currentSessionFile))
|
|
5371
5722
|
throw new Error("This session has not been saved yet. Wait for the first assistant response before cloning or forking it.");
|
|
5372
5723
|
let sessionManager2 = SessionManager.open(currentSessionFile, sessionDir);
|
|
5373
5724
|
if (!sessionManager2.createBranchedSession(targetLeafId))
|
|
@@ -5396,15 +5747,15 @@ var AgentSessionRuntime = class {
|
|
|
5396
5747
|
*/
|
|
5397
5748
|
async importFromJsonl(inputPath, cwdOverride) {
|
|
5398
5749
|
let resolvedPath = resolvePath(inputPath);
|
|
5399
|
-
if (!
|
|
5750
|
+
if (!existsSync8(resolvedPath))
|
|
5400
5751
|
throw new SessionImportFileNotFoundError(resolvedPath);
|
|
5401
5752
|
let sessionDir = this.session.sessionManager.getSessionDir();
|
|
5402
|
-
|
|
5403
|
-
let destinationPath =
|
|
5753
|
+
existsSync8(sessionDir) || mkdirSync7(sessionDir, { recursive: !0 });
|
|
5754
|
+
let destinationPath = join12(sessionDir, basename2(resolvedPath)), beforeResult = await this.emitBeforeSwitch("resume", destinationPath);
|
|
5404
5755
|
if (beforeResult.cancelled)
|
|
5405
5756
|
return beforeResult;
|
|
5406
5757
|
let previousSessionFile = this.session.sessionFile;
|
|
5407
|
-
|
|
5758
|
+
resolve3(destinationPath) !== resolvedPath && copyFileSync(resolvedPath, destinationPath);
|
|
5408
5759
|
let sessionManager = SessionManager.open(destinationPath, sessionDir, cwdOverride);
|
|
5409
5760
|
return assertSessionCwdExists(sessionManager, this.cwd), await this.teardownCurrent("resume", sessionManager.getSessionFile()), this.apply(await this.createRuntime({
|
|
5410
5761
|
cwd: sessionManager.getCwd(),
|
|
@@ -5431,7 +5782,7 @@ function getDefaultAgentDir() {
|
|
|
5431
5782
|
return getAgentDir();
|
|
5432
5783
|
}
|
|
5433
5784
|
async function createAgentSession(options = {}) {
|
|
5434
|
-
let cwd = resolvePath(options.cwd ?? options.sessionManager?.getCwd() ?? process.cwd()), agentDir = options.agentDir ? resolvePath(options.agentDir) : getDefaultAgentDir(), resourceLoader = options.resourceLoader, authPath = options.agentDir ?
|
|
5785
|
+
let cwd = resolvePath(options.cwd ?? options.sessionManager?.getCwd() ?? process.cwd()), agentDir = options.agentDir ? resolvePath(options.agentDir) : getDefaultAgentDir(), resourceLoader = options.resourceLoader, authPath = options.agentDir ? join13(agentDir, "auth.json") : void 0, modelsPath = options.agentDir ? join13(agentDir, "models.json") : void 0, modelRuntime = options.modelRuntime ?? await ModelRuntime.create({ authPath, modelsPath }), settingsManager = options.settingsManager ?? SettingsManager.create(cwd, agentDir), sessionManager = options.sessionManager ?? SessionManager.create(cwd, getDefaultSessionDir(cwd, agentDir));
|
|
5435
5786
|
resourceLoader || (resourceLoader = new DefaultResourceLoader({ cwd, agentDir, settingsManager }), await resourceLoader.reload(), time("resourceLoader.reload"));
|
|
5436
5787
|
let existingSession = sessionManager.buildSessionContext(), hasExistingSession = existingSession.messages.length > 0, hasThinkingEntry = sessionManager.getBranch().some((entry) => entry.type === "thinking_level_change"), model = options.model, modelFallbackMessage;
|
|
5437
5788
|
if (!model && hasExistingSession && existingSession.model) {
|
|
@@ -5570,8 +5921,8 @@ function applyExtensionFlagValues(resourceLoader, extensionFlagValues) {
|
|
|
5570
5921
|
}
|
|
5571
5922
|
async function createAgentSessionServices(options) {
|
|
5572
5923
|
let cwd = resolvePath(options.cwd), agentDir = options.agentDir ? resolvePath(options.agentDir) : getAgentDir(), modelRuntime = options.modelRuntime ?? await ModelRuntime.create({
|
|
5573
|
-
authPath:
|
|
5574
|
-
modelsPath:
|
|
5924
|
+
authPath: join14(agentDir, "auth.json"),
|
|
5925
|
+
modelsPath: join14(agentDir, "models.json")
|
|
5575
5926
|
});
|
|
5576
5927
|
time("ModelRuntime.create");
|
|
5577
5928
|
let settingsManager = options.settingsManager ?? SettingsManager.create(cwd, agentDir), resourceLoader = new DefaultResourceLoader({
|
|
@@ -5632,6 +5983,18 @@ export {
|
|
|
5632
5983
|
wrapRegisteredTool,
|
|
5633
5984
|
wrapRegisteredTools,
|
|
5634
5985
|
ModelRegistry,
|
|
5986
|
+
setRollbackWarningHandler,
|
|
5987
|
+
initRollback,
|
|
5988
|
+
isRollbackEnabled,
|
|
5989
|
+
isRollbackSessionForceEnabled,
|
|
5990
|
+
enableRollbackForSession,
|
|
5991
|
+
disableRollbackForSession,
|
|
5992
|
+
beginTurn,
|
|
5993
|
+
captureTreeChanges,
|
|
5994
|
+
peekRollbackTurnsConsumed,
|
|
5995
|
+
rollbackLastTurn,
|
|
5996
|
+
migrateRollbackSession,
|
|
5997
|
+
clearRollback,
|
|
5635
5998
|
parseSkillBlock,
|
|
5636
5999
|
AgentSession,
|
|
5637
6000
|
getMissingSessionCwdIssue,
|