opencode-acp 1.18.1-pr.409.170 → 1.18.1-pr.412.172
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/index.js
CHANGED
|
@@ -2904,12 +2904,24 @@ function drainSaveQueue(key) {
|
|
|
2904
2904
|
});
|
|
2905
2905
|
}
|
|
2906
2906
|
async function loadSessionState(sessionId, logger, storageDir) {
|
|
2907
|
+
const filePath = getSessionFilePath(sessionId, storageDir);
|
|
2908
|
+
let content;
|
|
2907
2909
|
try {
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
+
content = await fs.readFile(filePath, "utf-8");
|
|
2911
|
+
} catch (error) {
|
|
2912
|
+
if (error?.code === "ENOENT") {
|
|
2910
2913
|
return null;
|
|
2911
2914
|
}
|
|
2912
|
-
|
|
2915
|
+
if (error?.code === "EISDIR" || error?.code === "ENOTDIR") {
|
|
2916
|
+
logger.warn("Invalid session state file location, ignoring", {
|
|
2917
|
+
sessionId,
|
|
2918
|
+
error: error?.message
|
|
2919
|
+
});
|
|
2920
|
+
return null;
|
|
2921
|
+
}
|
|
2922
|
+
throw error;
|
|
2923
|
+
}
|
|
2924
|
+
try {
|
|
2913
2925
|
const state = JSON.parse(content);
|
|
2914
2926
|
const hasPruneMessages = state?.prune?.messages && typeof state.prune.messages === "object";
|
|
2915
2927
|
const hasNudgeFormat = state?.nudges && typeof state.nudges === "object";
|
|
@@ -4555,29 +4567,8 @@ function fingerprintMessage(message) {
|
|
|
4555
4567
|
});
|
|
4556
4568
|
return createHash("sha256").update(JSON.stringify({ role: message.info.role, parts })).digest("hex");
|
|
4557
4569
|
}
|
|
4558
|
-
function normalizeParentMessageIds(messageIds) {
|
|
4559
|
-
if (!messageIds) return void 0;
|
|
4560
|
-
const migrate = (ref) => {
|
|
4561
|
-
const parsed = parseMessageRef(ref);
|
|
4562
|
-
return parsed !== null ? formatMessageRef(parsed) : ref;
|
|
4563
|
-
};
|
|
4564
|
-
const byRawId = {};
|
|
4565
|
-
const byRef = {};
|
|
4566
|
-
for (const [rawId, ref] of Object.entries(messageIds.byRawId || {})) {
|
|
4567
|
-
const normalized = migrate(ref);
|
|
4568
|
-
byRawId[rawId] = normalized;
|
|
4569
|
-
byRef[normalized] = rawId;
|
|
4570
|
-
}
|
|
4571
|
-
for (const [ref, rawId] of Object.entries(messageIds.byRef || {})) {
|
|
4572
|
-
const normalized = migrate(ref);
|
|
4573
|
-
if (byRef[normalized] === void 0) {
|
|
4574
|
-
byRef[normalized] = rawId;
|
|
4575
|
-
}
|
|
4576
|
-
}
|
|
4577
|
-
return { byRef, byRawId, nextRef: messageIds.nextRef || 1 };
|
|
4578
|
-
}
|
|
4579
4570
|
function mapForkIds(state, parent, parentMessages, forkMessages) {
|
|
4580
|
-
const parentRefs =
|
|
4571
|
+
const parentRefs = parent.messageIds?.byRef;
|
|
4581
4572
|
if (!parentRefs) return null;
|
|
4582
4573
|
const parentById = new Map(parentMessages.map((message) => [message.info.id, message]));
|
|
4583
4574
|
const forkById = new Map(forkMessages.map((message) => [message.info.id, message]));
|
|
@@ -5044,6 +5035,22 @@ async function ensureSessionInitialized(client, state, sessionId, logger, messag
|
|
|
5044
5035
|
if (state.sessionId === sessionId) {
|
|
5045
5036
|
return;
|
|
5046
5037
|
}
|
|
5038
|
+
try {
|
|
5039
|
+
await runSessionInitialization(
|
|
5040
|
+
client,
|
|
5041
|
+
state,
|
|
5042
|
+
sessionId,
|
|
5043
|
+
logger,
|
|
5044
|
+
messages,
|
|
5045
|
+
config,
|
|
5046
|
+
projectDir
|
|
5047
|
+
);
|
|
5048
|
+
} catch (error) {
|
|
5049
|
+
state.sessionId = null;
|
|
5050
|
+
throw error;
|
|
5051
|
+
}
|
|
5052
|
+
}
|
|
5053
|
+
async function runSessionInitialization(client, state, sessionId, logger, messages, config, projectDir) {
|
|
5047
5054
|
resetSessionState(state);
|
|
5048
5055
|
state.sessionId = sessionId;
|
|
5049
5056
|
state.storageDir = config?.storagePath ? resolveStorageDir(config.storagePath, projectDir ?? cwd()) : void 0;
|
|
@@ -5066,10 +5073,7 @@ async function ensureSessionInitialized(client, state, sessionId, logger, messag
|
|
|
5066
5073
|
let restored = 0;
|
|
5067
5074
|
if (parentSessionId) {
|
|
5068
5075
|
try {
|
|
5069
|
-
|
|
5070
|
-
if (!parent && state.storageDir) {
|
|
5071
|
-
parent = await loadSessionState(parentSessionId, logger);
|
|
5072
|
-
}
|
|
5076
|
+
const parent = await loadSessionState(parentSessionId, logger);
|
|
5073
5077
|
const response = parent ? await client.session.messages({ path: { id: parentSessionId } }) : void 0;
|
|
5074
5078
|
const parentMessages = Array.isArray(response?.data) ? response.data : Array.isArray(response) ? response : [];
|
|
5075
5079
|
if (parent && parentMessages.length > 0) {
|
|
@@ -5150,14 +5154,6 @@ async function ensureSessionInitialized(client, state, sessionId, logger, messag
|
|
|
5150
5154
|
if (persistedAny._persistedLastCompaction !== void 0) {
|
|
5151
5155
|
state.lastCompaction = Math.max(state.lastCompaction, persistedAny._persistedLastCompaction);
|
|
5152
5156
|
}
|
|
5153
|
-
const persistedBoundary = typeof persistedAny._persistedLastCompaction === "number" ? persistedAny._persistedLastCompaction : 0;
|
|
5154
|
-
if (state.lastCompaction > persistedBoundary) {
|
|
5155
|
-
resetOnCompaction(state);
|
|
5156
|
-
logger.info("Restarted after native compaction - reset stale transient state", {
|
|
5157
|
-
timestamp: state.lastCompaction,
|
|
5158
|
-
persistedBoundary
|
|
5159
|
-
});
|
|
5160
|
-
}
|
|
5161
5157
|
if (typeof persisted.modelContextLimit === "number" && persisted.modelContextLimit > 0) {
|
|
5162
5158
|
state.modelContextLimit = persisted.modelContextLimit;
|
|
5163
5159
|
state.modelProviderID = persisted.modelProviderID;
|
|
@@ -10576,7 +10572,7 @@ import { writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
|
10576
10572
|
import { join as join4 } from "path";
|
|
10577
10573
|
import { existsSync as existsSync4 } from "fs";
|
|
10578
10574
|
import { homedir as homedir3 } from "os";
|
|
10579
|
-
var LOG_VERSION = true ? "1.18.1-pr.
|
|
10575
|
+
var LOG_VERSION = true ? "1.18.1-pr.412.172" : "dev";
|
|
10580
10576
|
var LEVEL_RANK = {
|
|
10581
10577
|
debug: 10,
|
|
10582
10578
|
info: 20,
|
|
@@ -13260,7 +13256,7 @@ var server = (async (ctx) => {
|
|
|
13260
13256
|
}
|
|
13261
13257
|
const logger = new Logger(config.debug, config.debug ? "debug" : config.logLevel);
|
|
13262
13258
|
logger.info("ACP plugin initialized", {
|
|
13263
|
-
version: true ? "1.18.1-pr.
|
|
13259
|
+
version: true ? "1.18.1-pr.412.172" : "dev",
|
|
13264
13260
|
workspace: ctx.directory,
|
|
13265
13261
|
logLevel: logger.level,
|
|
13266
13262
|
debug: config.debug,
|