opencode-acp 1.18.1-pr.403.160 → 1.18.1-pr.406.161
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 +85 -43
- package/dist/index.js.map +1 -1
- package/dist/lib/bili-proxy.d.ts +35 -0
- package/dist/lib/bili-proxy.d.ts.map +1 -1
- package/dist/lib/compress/types.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":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAgCzD,QAAA,MAAM,MAAM,EAAE,MA+OK,CAAA;AAEnB,eAAe,MAAM,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -2137,8 +2137,54 @@ Using previous/default values`
|
|
|
2137
2137
|
// lib/compress/range.ts
|
|
2138
2138
|
import { tool as tool2 } from "@opencode-ai/plugin";
|
|
2139
2139
|
|
|
2140
|
+
// lib/bili-proxy.ts
|
|
2141
|
+
var BILI_PROXY_MARKER = "/bili/";
|
|
2142
|
+
function extractBaseURL(entry) {
|
|
2143
|
+
if (!entry || typeof entry !== "object") return void 0;
|
|
2144
|
+
const record = entry;
|
|
2145
|
+
const options = record.options;
|
|
2146
|
+
if (options && typeof options === "object") {
|
|
2147
|
+
const optionBaseURL = options.baseURL;
|
|
2148
|
+
if (typeof optionBaseURL === "string" && optionBaseURL.length > 0) {
|
|
2149
|
+
return optionBaseURL;
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
const topLevelBaseURL = record.baseURL;
|
|
2153
|
+
if (typeof topLevelBaseURL === "string" && topLevelBaseURL.length > 0) {
|
|
2154
|
+
return topLevelBaseURL;
|
|
2155
|
+
}
|
|
2156
|
+
return void 0;
|
|
2157
|
+
}
|
|
2158
|
+
function findBiliProxyProviders(provider) {
|
|
2159
|
+
if (!provider || typeof provider !== "object") return [];
|
|
2160
|
+
const matches = [];
|
|
2161
|
+
for (const [name, entry] of Object.entries(provider)) {
|
|
2162
|
+
const baseURL = extractBaseURL(entry);
|
|
2163
|
+
if (baseURL !== void 0 && baseURL.includes(BILI_PROXY_MARKER)) {
|
|
2164
|
+
matches.push({ provider: name, baseURL });
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
return matches;
|
|
2168
|
+
}
|
|
2169
|
+
var BILI_PROXY_ENV_VAR = "BILLION_CONTEXT_PROXY";
|
|
2170
|
+
var BILI_NATIVE_ENV_VAR = "BILLION_CONTEXT_NATIVE";
|
|
2171
|
+
function detectBiliEnvYield(env = process.env) {
|
|
2172
|
+
if (env[BILI_PROXY_ENV_VAR]) return "launcher";
|
|
2173
|
+
if (env[BILI_NATIVE_ENV_VAR]) return "native";
|
|
2174
|
+
return null;
|
|
2175
|
+
}
|
|
2176
|
+
function describeBiliEnvYield(source) {
|
|
2177
|
+
return source === "native" ? "BILLION_CONTEXT_NATIVE set (billion-context native mode)" : "BILLION_CONTEXT_PROXY set (billion-context launcher mode)";
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2140
2180
|
// lib/compress/types.ts
|
|
2141
2181
|
function resolveToolContext(factoryCtx, sessionID) {
|
|
2182
|
+
const biliYield = detectBiliEnvYield();
|
|
2183
|
+
if (biliYield !== null) {
|
|
2184
|
+
throw new Error(
|
|
2185
|
+
`ACP is disabled in this process \u2014 ${describeBiliEnvYield(biliYield)}. billion-context owns context compression; do not call ACP tools again.`
|
|
2186
|
+
);
|
|
2187
|
+
}
|
|
2142
2188
|
const state = factoryCtx.registry.get(sessionID);
|
|
2143
2189
|
if (!state) {
|
|
2144
2190
|
throw new Error(
|
|
@@ -10544,7 +10590,7 @@ import { writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
|
10544
10590
|
import { join as join4 } from "path";
|
|
10545
10591
|
import { existsSync as existsSync4 } from "fs";
|
|
10546
10592
|
import { homedir as homedir3 } from "os";
|
|
10547
|
-
var LOG_VERSION = true ? "1.18.1-pr.
|
|
10593
|
+
var LOG_VERSION = true ? "1.18.1-pr.406.161" : "dev";
|
|
10548
10594
|
var LEVEL_RANK = {
|
|
10549
10595
|
debug: 10,
|
|
10550
10596
|
info: 20,
|
|
@@ -12984,36 +13030,6 @@ function configureClientAuth(client) {
|
|
|
12984
13030
|
return client;
|
|
12985
13031
|
}
|
|
12986
13032
|
|
|
12987
|
-
// lib/bili-proxy.ts
|
|
12988
|
-
var BILI_PROXY_MARKER = "/bili/";
|
|
12989
|
-
function extractBaseURL(entry) {
|
|
12990
|
-
if (!entry || typeof entry !== "object") return void 0;
|
|
12991
|
-
const record = entry;
|
|
12992
|
-
const options = record.options;
|
|
12993
|
-
if (options && typeof options === "object") {
|
|
12994
|
-
const optionBaseURL = options.baseURL;
|
|
12995
|
-
if (typeof optionBaseURL === "string" && optionBaseURL.length > 0) {
|
|
12996
|
-
return optionBaseURL;
|
|
12997
|
-
}
|
|
12998
|
-
}
|
|
12999
|
-
const topLevelBaseURL = record.baseURL;
|
|
13000
|
-
if (typeof topLevelBaseURL === "string" && topLevelBaseURL.length > 0) {
|
|
13001
|
-
return topLevelBaseURL;
|
|
13002
|
-
}
|
|
13003
|
-
return void 0;
|
|
13004
|
-
}
|
|
13005
|
-
function findBiliProxyProviders(provider) {
|
|
13006
|
-
if (!provider || typeof provider !== "object") return [];
|
|
13007
|
-
const matches = [];
|
|
13008
|
-
for (const [name, entry] of Object.entries(provider)) {
|
|
13009
|
-
const baseURL = extractBaseURL(entry);
|
|
13010
|
-
if (baseURL !== void 0 && baseURL.includes(BILI_PROXY_MARKER)) {
|
|
13011
|
-
matches.push({ provider: name, baseURL });
|
|
13012
|
-
}
|
|
13013
|
-
}
|
|
13014
|
-
return matches;
|
|
13015
|
-
}
|
|
13016
|
-
|
|
13017
13033
|
// lib/update.ts
|
|
13018
13034
|
import { readFile as readFile2, rm } from "fs/promises";
|
|
13019
13035
|
import { basename, dirname as dirname4, join as join7 } from "path";
|
|
@@ -13220,15 +13236,16 @@ var server = (async (ctx) => {
|
|
|
13220
13236
|
if (!config.enabled) {
|
|
13221
13237
|
return {};
|
|
13222
13238
|
}
|
|
13223
|
-
|
|
13239
|
+
const setupBiliYield = detectBiliEnvYield();
|
|
13240
|
+
if (setupBiliYield) {
|
|
13224
13241
|
console.log(
|
|
13225
|
-
|
|
13242
|
+
`[opencode-acp] disabled: ${describeBiliEnvYield(setupBiliYield)} detected \u2014 billion-context handles compression`
|
|
13226
13243
|
);
|
|
13227
13244
|
return {};
|
|
13228
13245
|
}
|
|
13229
13246
|
const logger = new Logger(config.debug, config.debug ? "debug" : config.logLevel);
|
|
13230
13247
|
logger.info("ACP plugin initialized", {
|
|
13231
|
-
version: true ? "1.18.1-pr.
|
|
13248
|
+
version: true ? "1.18.1-pr.406.161" : "dev",
|
|
13232
13249
|
workspace: ctx.directory,
|
|
13233
13250
|
logLevel: logger.level,
|
|
13234
13251
|
debug: config.debug,
|
|
@@ -13278,7 +13295,23 @@ var server = (async (ctx) => {
|
|
|
13278
13295
|
prompts
|
|
13279
13296
|
};
|
|
13280
13297
|
let disabledByBiliProxy = false;
|
|
13281
|
-
|
|
13298
|
+
let announcedEnvYieldSource;
|
|
13299
|
+
const noteEnvYield = (source) => {
|
|
13300
|
+
if (source === null || announcedEnvYieldSource === source) return;
|
|
13301
|
+
announcedEnvYieldSource = source;
|
|
13302
|
+
console.log(
|
|
13303
|
+
`[opencode-acp] disabled: ${source} detected \u2014 billion-context handles compression`
|
|
13304
|
+
);
|
|
13305
|
+
};
|
|
13306
|
+
const guard = (fn) => (...args) => {
|
|
13307
|
+
if (disabledByBiliProxy) return Promise.resolve();
|
|
13308
|
+
const envYield = detectBiliEnvYield();
|
|
13309
|
+
if (envYield !== null) {
|
|
13310
|
+
noteEnvYield(describeBiliEnvYield(envYield));
|
|
13311
|
+
return Promise.resolve();
|
|
13312
|
+
}
|
|
13313
|
+
return fn(...args);
|
|
13314
|
+
};
|
|
13282
13315
|
return {
|
|
13283
13316
|
"experimental.chat.system.transform": guard(
|
|
13284
13317
|
createSystemPromptHandler(registry4, logger, config, prompts)
|
|
@@ -13315,14 +13348,9 @@ var server = (async (ctx) => {
|
|
|
13315
13348
|
}
|
|
13316
13349
|
},
|
|
13317
13350
|
config: async (opencodeConfig) => {
|
|
13318
|
-
const
|
|
13319
|
-
|
|
13320
|
-
|
|
13321
|
-
console.log(
|
|
13322
|
-
"[opencode-acp] disabled: /bili/ proxy detected in provider baseURL (" + biliMatches.map((m) => m.provider).join(", ") + ") \u2014 proxy handles compression"
|
|
13323
|
-
);
|
|
13324
|
-
const permission = opencodeConfig.permission ?? {};
|
|
13325
|
-
opencodeConfig.permission = {
|
|
13351
|
+
const denyAcpTools = (opencodeConfig2) => {
|
|
13352
|
+
const permission = opencodeConfig2.permission ?? {};
|
|
13353
|
+
opencodeConfig2.permission = {
|
|
13326
13354
|
...permission,
|
|
13327
13355
|
compress: "deny",
|
|
13328
13356
|
decompress: "deny",
|
|
@@ -13330,6 +13358,20 @@ var server = (async (ctx) => {
|
|
|
13330
13358
|
acp_status: "deny",
|
|
13331
13359
|
acp_context_recap: "deny"
|
|
13332
13360
|
};
|
|
13361
|
+
};
|
|
13362
|
+
const envYield = detectBiliEnvYield();
|
|
13363
|
+
if (envYield !== null) {
|
|
13364
|
+
noteEnvYield(describeBiliEnvYield(envYield));
|
|
13365
|
+
denyAcpTools(opencodeConfig);
|
|
13366
|
+
return;
|
|
13367
|
+
}
|
|
13368
|
+
const biliMatches = findBiliProxyProviders(opencodeConfig.provider);
|
|
13369
|
+
disabledByBiliProxy = biliMatches.length > 0;
|
|
13370
|
+
if (biliMatches.length > 0) {
|
|
13371
|
+
console.log(
|
|
13372
|
+
"[opencode-acp] disabled: /bili/ proxy detected in provider baseURL (" + biliMatches.map((m) => m.provider).join(", ") + ") \u2014 proxy handles compression"
|
|
13373
|
+
);
|
|
13374
|
+
denyAcpTools(opencodeConfig);
|
|
13333
13375
|
return;
|
|
13334
13376
|
}
|
|
13335
13377
|
if (config.compress.permission !== "deny" && compressDisabledByOpencode(opencodeConfig.permission)) {
|