opencode-acp 1.18.1-pr.403.160 → 1.18.1-pr.406.162

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AA4BjD,QAAA,MAAM,MAAM,EAAE,MAwMK,CAAA;AAEnB,eAAe,MAAM,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,qBAAqB,CAAA;AA6BzD,QAAA,MAAM,MAAM,EAAE,MA8OK,CAAA;AAEnB,eAAe,MAAM,CAAA"}
package/dist/index.js CHANGED
@@ -2137,8 +2137,57 @@ 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
+ function biliYieldLogMessage(source) {
2180
+ return source === "native" ? "[opencode-acp] disabled: BILLION_CONTEXT_NATIVE detected \u2014 billion-context native mode handles compression" : "[opencode-acp] disabled: BILLION_CONTEXT_PROXY detected \u2014 proxy handles compression";
2181
+ }
2182
+
2140
2183
  // lib/compress/types.ts
2141
2184
  function resolveToolContext(factoryCtx, sessionID) {
2185
+ const biliYield = detectBiliEnvYield();
2186
+ if (biliYield !== null) {
2187
+ throw new Error(
2188
+ `ACP is disabled in this process \u2014 ${describeBiliEnvYield(biliYield)}. billion-context owns context compression; do not call ACP tools again.`
2189
+ );
2190
+ }
2142
2191
  const state = factoryCtx.registry.get(sessionID);
2143
2192
  if (!state) {
2144
2193
  throw new Error(
@@ -10544,7 +10593,7 @@ import { writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
10544
10593
  import { join as join4 } from "path";
10545
10594
  import { existsSync as existsSync4 } from "fs";
10546
10595
  import { homedir as homedir3 } from "os";
10547
- var LOG_VERSION = true ? "1.18.1-pr.403.160" : "dev";
10596
+ var LOG_VERSION = true ? "1.18.1-pr.406.162" : "dev";
10548
10597
  var LEVEL_RANK = {
10549
10598
  debug: 10,
10550
10599
  info: 20,
@@ -12984,36 +13033,6 @@ function configureClientAuth(client) {
12984
13033
  return client;
12985
13034
  }
12986
13035
 
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
13036
  // lib/update.ts
13018
13037
  import { readFile as readFile2, rm } from "fs/promises";
13019
13038
  import { basename, dirname as dirname4, join as join7 } from "path";
@@ -13220,15 +13239,14 @@ var server = (async (ctx) => {
13220
13239
  if (!config.enabled) {
13221
13240
  return {};
13222
13241
  }
13223
- if (process.env.BILLION_CONTEXT_PROXY) {
13224
- console.log(
13225
- "[opencode-acp] disabled: BILLION_CONTEXT_PROXY detected \u2014 proxy handles compression"
13226
- );
13242
+ const setupBiliYield = detectBiliEnvYield();
13243
+ if (setupBiliYield) {
13244
+ console.log(biliYieldLogMessage(setupBiliYield));
13227
13245
  return {};
13228
13246
  }
13229
13247
  const logger = new Logger(config.debug, config.debug ? "debug" : config.logLevel);
13230
13248
  logger.info("ACP plugin initialized", {
13231
- version: true ? "1.18.1-pr.403.160" : "dev",
13249
+ version: true ? "1.18.1-pr.406.162" : "dev",
13232
13250
  workspace: ctx.directory,
13233
13251
  logLevel: logger.level,
13234
13252
  debug: config.debug,
@@ -13278,7 +13296,21 @@ var server = (async (ctx) => {
13278
13296
  prompts
13279
13297
  };
13280
13298
  let disabledByBiliProxy = false;
13281
- const guard = (fn) => (...args) => disabledByBiliProxy ? Promise.resolve() : fn(...args);
13299
+ let announcedEnvYieldSource;
13300
+ const noteEnvYield = (source) => {
13301
+ if (source === null || announcedEnvYieldSource === source) return;
13302
+ announcedEnvYieldSource = source;
13303
+ console.log(biliYieldLogMessage(source));
13304
+ };
13305
+ const guard = (fn) => (...args) => {
13306
+ if (disabledByBiliProxy) return Promise.resolve();
13307
+ const envYield = detectBiliEnvYield();
13308
+ if (envYield !== null) {
13309
+ noteEnvYield(envYield);
13310
+ return Promise.resolve();
13311
+ }
13312
+ return fn(...args);
13313
+ };
13282
13314
  return {
13283
13315
  "experimental.chat.system.transform": guard(
13284
13316
  createSystemPromptHandler(registry4, logger, config, prompts)
@@ -13315,14 +13347,9 @@ var server = (async (ctx) => {
13315
13347
  }
13316
13348
  },
13317
13349
  config: async (opencodeConfig) => {
13318
- const biliMatches = findBiliProxyProviders(opencodeConfig.provider);
13319
- disabledByBiliProxy = biliMatches.length > 0;
13320
- if (biliMatches.length > 0) {
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 = {
13350
+ const denyAcpTools = (opencodeConfig2) => {
13351
+ const permission = opencodeConfig2.permission ?? {};
13352
+ opencodeConfig2.permission = {
13326
13353
  ...permission,
13327
13354
  compress: "deny",
13328
13355
  decompress: "deny",
@@ -13330,6 +13357,20 @@ var server = (async (ctx) => {
13330
13357
  acp_status: "deny",
13331
13358
  acp_context_recap: "deny"
13332
13359
  };
13360
+ };
13361
+ const biliMatches = findBiliProxyProviders(opencodeConfig.provider);
13362
+ disabledByBiliProxy = biliMatches.length > 0;
13363
+ const envYield = detectBiliEnvYield();
13364
+ if (envYield !== null) {
13365
+ noteEnvYield(envYield);
13366
+ denyAcpTools(opencodeConfig);
13367
+ return;
13368
+ }
13369
+ if (biliMatches.length > 0) {
13370
+ console.log(
13371
+ "[opencode-acp] disabled: /bili/ proxy detected in provider baseURL (" + biliMatches.map((m) => m.provider).join(", ") + ") \u2014 proxy handles compression"
13372
+ );
13373
+ denyAcpTools(opencodeConfig);
13333
13374
  return;
13334
13375
  }
13335
13376
  if (config.compress.permission !== "deny" && compressDisabledByOpencode(opencodeConfig.permission)) {