opencode-acp 1.14.19-pr.311.24 → 1.14.19-pr.314.26
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.d.ts.map +1 -1
- package/dist/index.js +67 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/hooks.d.ts +2 -0
- package/dist/lib/hooks.d.ts.map +1 -1
- package/dist/lib/state/state.d.ts +9 -0
- package/dist/lib/state/state.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AA2BjD,QAAA,MAAM,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AA2BjD,QAAA,MAAM,MAAM,EAAE,MAwHK,CAAA;AAEnB,eAAe,MAAM,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -4140,6 +4140,57 @@ var SessionStateRegistry = class {
|
|
|
4140
4140
|
startsByCallId: /* @__PURE__ */ new Map(),
|
|
4141
4141
|
pendingByCallId: /* @__PURE__ */ new Map()
|
|
4142
4142
|
};
|
|
4143
|
+
// [FIX #312] Catalog of per-model context limits, keyed `${providerID}/${modelID}`.
|
|
4144
|
+
// Within one LLM request the host fires experimental.chat.messages.transform
|
|
4145
|
+
// BEFORE experimental.chat.system.transform (sst/opencode: session/prompt.ts
|
|
4146
|
+
// triggers messages.transform, then llm/request.ts triggers system.transform
|
|
4147
|
+
// during handle.process). state.modelContextLimit is written only by the
|
|
4148
|
+
// system hook, so on the first request after a model switch every percentage
|
|
4149
|
+
// threshold (emergencyThresholdPercent, min/maxContextLimit "%", adaptive
|
|
4150
|
+
// nudge growth, GC tiers) is still computed against the PREVIOUS model's
|
|
4151
|
+
// limit. This catalog lets the messages hook reconcile against the model
|
|
4152
|
+
// named on the request's user message instead of waiting one turn.
|
|
4153
|
+
// Entries are recorded live by the system hook every request and seeded once
|
|
4154
|
+
// at plugin init from the host's /config/providers catalog.
|
|
4155
|
+
modelLimits = /* @__PURE__ */ new Map();
|
|
4156
|
+
recordModelLimit(providerId, modelId, limit) {
|
|
4157
|
+
if (!providerId || !modelId || typeof limit !== "number" || limit <= 0) return;
|
|
4158
|
+
this.modelLimits.set(`${providerId}/${modelId}`, limit);
|
|
4159
|
+
}
|
|
4160
|
+
resolveModelLimit(providerId, modelId) {
|
|
4161
|
+
if (!providerId || !modelId) return void 0;
|
|
4162
|
+
return this.modelLimits.get(`${providerId}/${modelId}`);
|
|
4163
|
+
}
|
|
4164
|
+
/**
|
|
4165
|
+
* Best-effort one-time seed from the host's provider catalog
|
|
4166
|
+
* (`client.config.providers()` → GET /config/providers). Never throws;
|
|
4167
|
+
* returns the number of model-limit entries recorded.
|
|
4168
|
+
*/
|
|
4169
|
+
async hydrateModelLimitsFromClient(client) {
|
|
4170
|
+
try {
|
|
4171
|
+
const config = client;
|
|
4172
|
+
const result = await config.config?.providers?.();
|
|
4173
|
+
const payload = result;
|
|
4174
|
+
const providers = payload?.data?.providers;
|
|
4175
|
+
if (!Array.isArray(providers)) return 0;
|
|
4176
|
+
let recorded = 0;
|
|
4177
|
+
for (const provider of providers) {
|
|
4178
|
+
const { id, models } = provider ?? {};
|
|
4179
|
+
if (typeof id !== "string" || !models) continue;
|
|
4180
|
+
for (const [modelId, model] of Object.entries(models)) {
|
|
4181
|
+
const limit = model?.limit;
|
|
4182
|
+
const context = limit?.context;
|
|
4183
|
+
if (typeof context === "number" && context > 0) {
|
|
4184
|
+
this.modelLimits.set(`${id}/${modelId}`, context);
|
|
4185
|
+
recorded++;
|
|
4186
|
+
}
|
|
4187
|
+
}
|
|
4188
|
+
}
|
|
4189
|
+
return recorded;
|
|
4190
|
+
} catch {
|
|
4191
|
+
return 0;
|
|
4192
|
+
}
|
|
4193
|
+
}
|
|
4143
4194
|
get(sessionId) {
|
|
4144
4195
|
return this.states.get(sessionId);
|
|
4145
4196
|
}
|
|
@@ -8949,7 +9000,7 @@ import { writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
|
8949
9000
|
import { join as join3 } from "path";
|
|
8950
9001
|
import { existsSync as existsSync3 } from "fs";
|
|
8951
9002
|
import { homedir as homedir3 } from "os";
|
|
8952
|
-
var LOG_VERSION = true ? "1.14.19-pr.
|
|
9003
|
+
var LOG_VERSION = true ? "1.14.19-pr.314.26" : "dev";
|
|
8953
9004
|
var Logger = class {
|
|
8954
9005
|
logDir;
|
|
8955
9006
|
enabled;
|
|
@@ -10516,6 +10567,11 @@ function isInternalAgentRequest(messages) {
|
|
|
10516
10567
|
}
|
|
10517
10568
|
function createSystemPromptHandler(registry4, logger, config, prompts) {
|
|
10518
10569
|
return async (input, output) => {
|
|
10570
|
+
registry4.recordModelLimit(
|
|
10571
|
+
input.model?.providerID,
|
|
10572
|
+
input.model?.id,
|
|
10573
|
+
input.model?.limit?.context
|
|
10574
|
+
);
|
|
10519
10575
|
const state = input.sessionID ? registry4.get(input.sessionID) : void 0;
|
|
10520
10576
|
if (state && input.model?.limit?.context) {
|
|
10521
10577
|
state.modelContextLimit = input.model.limit.context;
|
|
@@ -10571,6 +10627,14 @@ function createChatMessageTransformHandler(client, registry4, logger, config, pr
|
|
|
10571
10627
|
messages,
|
|
10572
10628
|
config
|
|
10573
10629
|
);
|
|
10630
|
+
const requestModel = lastUserMessage.info.model;
|
|
10631
|
+
const requestModelLimit = registry4.resolveModelLimit(
|
|
10632
|
+
requestModel?.providerID,
|
|
10633
|
+
requestModel?.modelID
|
|
10634
|
+
);
|
|
10635
|
+
if (requestModelLimit !== void 0) {
|
|
10636
|
+
state.modelContextLimit = requestModelLimit;
|
|
10637
|
+
}
|
|
10574
10638
|
await updatePerTurnState(state, logger, messages);
|
|
10575
10639
|
}
|
|
10576
10640
|
syncCompressPermissionState(state, config, hostPermissions, output.messages);
|
|
@@ -10956,6 +11020,8 @@ var server = (async (ctx) => {
|
|
|
10956
11020
|
if (isSecureMode()) {
|
|
10957
11021
|
configureClientAuth(ctx.client);
|
|
10958
11022
|
}
|
|
11023
|
+
registry4.hydrateModelLimitsFromClient(ctx.client).catch(() => {
|
|
11024
|
+
});
|
|
10959
11025
|
logger.info("DCP initialized");
|
|
10960
11026
|
startAutoUpdate(ctx, config.autoUpdate);
|
|
10961
11027
|
const compressToolContext = {
|