opencode-acp 1.14.19-pr.311.23 → 1.14.19-pr.313.25

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/README.md CHANGED
@@ -284,7 +284,8 @@ Each level overrides the previous, so project settings take priority over global
284
284
  // Automatically update npm-installed ACP when a newer npm latest is available.
285
285
  // Version-locked plugin specs are not updated.
286
286
  "autoUpdate": true,
287
- // Enable debug logging to ~/.config/opencode/logs/acp/
287
+ // Enable INFO/DEBUG logging + per-request snapshots to ~/.config/opencode/logs/acp/
288
+ // (WARN/ERROR are always logged to daily/<date>.log)
288
289
  "debug": false,
289
290
  // Notification display: "off", "minimal", or "detailed"
290
291
  "pruneNotification": "off",
package/README.zh-CN.md CHANGED
@@ -239,7 +239,8 @@ ACP 使用自己的配置文件,按以下顺序搜索:
239
239
  // Automatically update npm-installed ACP when a newer npm latest is available.
240
240
  // Version-locked plugin specs are not updated.
241
241
  "autoUpdate": true,
242
- // Enable debug logging to ~/.config/opencode/logs/acp/
242
+ // Enable INFO/DEBUG logging + per-request snapshots to ~/.config/opencode/logs/acp/
243
+ // (WARN/ERROR are always logged to daily/<date>.log)
243
244
  "debug": false,
244
245
  // Notification display: "off", "minimal", or "detailed"
245
246
  "pruneNotification": "detailed",
package/dist/index.js CHANGED
@@ -2084,6 +2084,18 @@ import { homedir as homedir2 } from "os";
2084
2084
  import { join as join2 } from "path";
2085
2085
 
2086
2086
  // lib/state/utils.ts
2087
+ function syncModelIdentity(state, providerID, modelID) {
2088
+ if (providerID === void 0 || modelID === void 0) {
2089
+ return false;
2090
+ }
2091
+ if (state.modelProviderID === providerID && state.modelID === modelID) {
2092
+ return false;
2093
+ }
2094
+ state.modelContextLimit = void 0;
2095
+ state.modelProviderID = providerID;
2096
+ state.modelID = modelID;
2097
+ return true;
2098
+ }
2087
2099
  var isMessageCompacted = (state, msg) => {
2088
2100
  if (!isMessageWithInfo(msg)) {
2089
2101
  return false;
@@ -2418,7 +2430,9 @@ async function saveSessionState(sessionState, logger, sessionName) {
2418
2430
  nextRef: sessionState.messageIds.nextRef
2419
2431
  },
2420
2432
  lastCompaction: sessionState.lastCompaction,
2421
- modelContextLimit: sessionState.modelContextLimit
2433
+ modelContextLimit: sessionState.modelContextLimit,
2434
+ modelProviderID: sessionState.modelProviderID,
2435
+ modelID: sessionState.modelID
2422
2436
  };
2423
2437
  await writePersistedSessionState(sessionState.sessionId, state, logger);
2424
2438
  }
@@ -4228,6 +4242,8 @@ function createSessionState() {
4228
4242
  lastCompaction: 0,
4229
4243
  currentTurn: 0,
4230
4244
  modelContextLimit: void 0,
4245
+ modelProviderID: void 0,
4246
+ modelID: void 0,
4231
4247
  systemPromptTokens: void 0,
4232
4248
  qualityGateRetryPending: false
4233
4249
  };
@@ -4267,6 +4283,8 @@ function resetSessionState(state) {
4267
4283
  state.lastCompaction = 0;
4268
4284
  state.currentTurn = 0;
4269
4285
  state.modelContextLimit = void 0;
4286
+ state.modelProviderID = void 0;
4287
+ state.modelID = void 0;
4270
4288
  state.systemPromptTokens = void 0;
4271
4289
  state.qualityGateRetryPending = false;
4272
4290
  }
@@ -4342,6 +4360,12 @@ async function ensureSessionInitialized(client, state, sessionId, logger, messag
4342
4360
  if (typeof persisted.modelContextLimit === "number" && persisted.modelContextLimit > 0) {
4343
4361
  state.modelContextLimit = persisted.modelContextLimit;
4344
4362
  }
4363
+ if (typeof persisted.modelProviderID === "string") {
4364
+ state.modelProviderID = persisted.modelProviderID;
4365
+ }
4366
+ if (typeof persisted.modelID === "string") {
4367
+ state.modelID = persisted.modelID;
4368
+ }
4345
4369
  const applied = applyPendingCompressionDurations(state);
4346
4370
  if (applied > 0) {
4347
4371
  await saveSessionState(state, logger);
@@ -8949,7 +8973,7 @@ import { writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
8949
8973
  import { join as join3 } from "path";
8950
8974
  import { existsSync as existsSync3 } from "fs";
8951
8975
  import { homedir as homedir3 } from "os";
8952
- var LOG_VERSION = true ? "1.14.19-pr.311.23" : "dev";
8976
+ var LOG_VERSION = true ? "1.14.19-pr.313.25" : "dev";
8953
8977
  var Logger = class {
8954
8978
  logDir;
8955
8979
  enabled;
@@ -10045,6 +10069,7 @@ function applyMessageFilters(messages, config, logger, ctx) {
10045
10069
  }
10046
10070
  const result = { partsFiltered: 0, partsDropped: 0, partsModified: 0 };
10047
10071
  const total = messages.length;
10072
+ const warnedFilters = /* @__PURE__ */ new Set();
10048
10073
  const buildCtx = (text, role, i) => ({
10049
10074
  text,
10050
10075
  role,
@@ -10100,11 +10125,14 @@ function applyMessageFilters(messages, config, logger, ctx) {
10100
10125
  try {
10101
10126
  decision = filter.filter(filterCtx);
10102
10127
  } catch (err) {
10103
- logger.warn("Message filter threw error", {
10104
- filter: filter.name,
10105
- error: err instanceof Error ? err.message : String(err),
10106
- messageIndex: i
10107
- });
10128
+ if (!warnedFilters.has(filter.name)) {
10129
+ warnedFilters.add(filter.name);
10130
+ logger.warn("Message filter threw error", {
10131
+ filter: filter.name,
10132
+ error: err instanceof Error ? err.message : String(err),
10133
+ messageIndex: i
10134
+ });
10135
+ }
10108
10136
  continue;
10109
10137
  }
10110
10138
  if (decision.action === "keep") continue;
@@ -10515,6 +10543,8 @@ function createSystemPromptHandler(registry4, logger, config, prompts) {
10515
10543
  const state = input.sessionID ? registry4.get(input.sessionID) : void 0;
10516
10544
  if (state && input.model?.limit?.context) {
10517
10545
  state.modelContextLimit = input.model.limit.context;
10546
+ state.modelProviderID = input.model.providerID;
10547
+ state.modelID = input.model.id;
10518
10548
  }
10519
10549
  if (!state || state.isSubAgent && !config.allowSubAgents) {
10520
10550
  return;
@@ -10568,6 +10598,21 @@ function createChatMessageTransformHandler(client, registry4, logger, config, pr
10568
10598
  config
10569
10599
  );
10570
10600
  await updatePerTurnState(state, logger, messages);
10601
+ const { providerId, modelId } = getModelInfo(messages);
10602
+ const prevIdentity = state.modelID;
10603
+ const prevModel = prevIdentity ? `${state.modelProviderID}/${prevIdentity}` : void 0;
10604
+ if (syncModelIdentity(state, providerId, modelId)) {
10605
+ const target = `${providerId}/${modelId}`;
10606
+ if (prevIdentity) {
10607
+ logger.debug(
10608
+ `Model switch detected (${prevModel} \u2192 ${target}); invalidated stale modelContextLimit`
10609
+ );
10610
+ } else {
10611
+ logger.debug(
10612
+ `Model identity established (${target}); limit awaits system.transform`
10613
+ );
10614
+ }
10615
+ }
10571
10616
  }
10572
10617
  syncCompressPermissionState(state, config, hostPermissions, output.messages);
10573
10618
  if (state.isSubAgent && !config.allowSubAgents) {