@yitom/acp-client 0.1.10 → 0.1.12

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
@@ -162,17 +162,20 @@ function findBuiltinAcpRuntime(id) {
162
162
  return BUILTIN_ACP_RUNTIMES.find((item) => item.id === id);
163
163
  }
164
164
  // src/version.ts
165
- var ACP_CLIENT_VERSION = "0.1.10";
165
+ var ACP_CLIENT_VERSION = "0.1.12";
166
166
  // src/client/sdk-client.ts
167
167
  import { PassThrough, Readable, Writable } from "node:stream";
168
168
  import {
169
169
  client as createSdkClientApp,
170
- ndJsonStream
170
+ ndJsonStream,
171
+ methods
171
172
  } from "@agentclientprotocol/sdk";
172
173
  var ACP_SDK_REQUEST_TIMEOUT_MS = 120000;
173
174
  function createSdkStreamHandle(child) {
174
175
  const stdoutBridge = new PassThrough;
175
176
  const stdinBridge = new PassThrough;
177
+ stdoutBridge.on("error", () => {});
178
+ stdinBridge.on("error", () => {});
176
179
  child.stdout.pipe(stdoutBridge);
177
180
  stdinBridge.pipe(child.stdin, { end: false });
178
181
  const output = Writable.toWeb(stdinBridge);
@@ -200,11 +203,11 @@ function createSdkStreamHandle(child) {
200
203
  }
201
204
  };
202
205
  }
203
- function connectSdkClient(child, configure, runtimeId) {
206
+ function connectSdkClient(child, configure, runtimeId, options = {}) {
204
207
  if (runtimeId && true) {
205
208
  console.info(`[acp:sdk] connect runtime=${runtimeId} pid=${child.pid ?? "?"}`);
206
209
  }
207
- const app = createSdkClientApp({ name: "inkdown" });
210
+ const app = createSdkClientApp({ name: options.name ?? "inkdown" });
208
211
  configure(app);
209
212
  const streamHandle = createSdkStreamHandle(child);
210
213
  const connection = app.connect(streamHandle.stream);
@@ -234,7 +237,7 @@ async function closeAcpSessions(agent, sessionIds, timeoutMs = 2000) {
234
237
  const failed = [];
235
238
  await Promise.all([...new Set(sessionIds)].map(async (sessionId) => {
236
239
  try {
237
- await sdkRequest(agent, "session/close", { sessionId }, timeoutMs);
240
+ await sdkRequest(agent, methods.agent.session.close, { sessionId }, timeoutMs);
238
241
  } catch {
239
242
  failed.push(sessionId);
240
243
  }
@@ -724,7 +727,7 @@ class QuotaCache {
724
727
 
725
728
  // src/client/acp-client.ts
726
729
  import {
727
- methods as methods2
730
+ methods as methods4
728
731
  } from "@agentclientprotocol/sdk";
729
732
 
730
733
  // src/runtimes/codex/quota.ts
@@ -1316,7 +1319,7 @@ import { promisify } from "node:util";
1316
1319
  var APP_RESOURCE_CAPABILITIES = {
1317
1320
  "codex-acp": { entry: "CODEX_CONFIG", strategy: "native-overlay", configHome: "CODEX_HOME" },
1318
1321
  opencode: { entry: "OPENCODE_CONFIG_CONTENT", strategy: "native-overlay", configHome: "OPENCODE_CONFIG_DIR" },
1319
- "opencode-v2": { entry: null, strategy: "compatibility", configHome: null },
1322
+ "opencode-v2": { entry: "OPENCODE_CONFIG_CONTENT (questions only)", strategy: "compatibility", configHome: null },
1320
1323
  claude: { entry: "_meta.systemPrompt + _meta.claudeCode.options.plugins", strategy: "native-session", configHome: "CLAUDE_CONFIG_DIR" },
1321
1324
  gemini: { entry: null, strategy: "compatibility", configHome: "GEMINI_CLI_HOME" },
1322
1325
  copilot: { entry: null, strategy: "compatibility", configHome: "COPILOT_HOME", candidateEntry: "COPILOT_CUSTOM_INSTRUCTIONS_DIRS" },
@@ -1354,18 +1357,49 @@ function mergeOpenCodeAppConfig(raw, directory) {
1354
1357
  skills: { ...skills, paths: [...new Set([...skills.paths ?? [], join8(directory, "skills")])] }
1355
1358
  });
1356
1359
  }
1360
+ function resolveOpenCodeQuestionMode(version) {
1361
+ const normalized = version.trim().replace(/^opencode\s+v?/i, "");
1362
+ return ["1.18.35", "2.0.6"].includes(normalized) ? "fallback" : "unverified";
1363
+ }
1364
+ function mergeOpenCodeQuestionConfig(raw) {
1365
+ const value = raw?.trim() ? JSON.parse(raw) : {};
1366
+ if (!value || typeof value !== "object" || Array.isArray(value))
1367
+ throw new Error("invalid-opencode-config");
1368
+ const config = value;
1369
+ const permission = config.permission;
1370
+ if (permission !== undefined && (typeof permission !== "string" || !["allow", "ask", "deny"].includes(permission)) && (!permission || typeof permission !== "object" || Array.isArray(permission)))
1371
+ throw new Error("invalid-opencode-permission");
1372
+ const rules = typeof permission === "string" ? { "*": permission } : permission ?? {};
1373
+ return JSON.stringify({ ...config, permission: { ...rules, question: "deny" } });
1374
+ }
1357
1375
  async function prepareOpenCodeResources(input) {
1358
1376
  const prep = prepareCompatibilityResources(input.directory, "native-entry-not-verified");
1359
- if (!input.command || !readAppRulesText(input.directory))
1377
+ prep.report.openCodeQuestions = { mode: "unverified", configuration: "unchanged", reason: "version-not-verified" };
1378
+ if (!input.command)
1360
1379
  return prep;
1361
1380
  try {
1362
1381
  const { stdout } = await promisify(execFile)(input.command, ["--version"], { env: input.env, timeout: 8000, windowsHide: true });
1363
- if (stdout.trim() !== "1.18.35")
1382
+ const version = stdout.trim().replace(/^opencode\s+v?/i, "");
1383
+ if (resolveOpenCodeQuestionMode(version) !== "fallback") {
1384
+ prep.report.openCodeQuestions.version = version;
1364
1385
  return prep;
1365
- const json = mergeOpenCodeAppConfig(input.env?.OPENCODE_CONFIG_CONTENT, input.directory);
1366
- return { env: { OPENCODE_CONFIG_CONTENT: json }, report: { ...prep.report, rulesPrepared: true, reason: undefined } };
1386
+ }
1387
+ let json = mergeOpenCodeQuestionConfig(input.env?.OPENCODE_CONFIG_CONTENT);
1388
+ const hasRules = version === "1.18.35" && !!readAppRulesText(input.directory);
1389
+ if (hasRules)
1390
+ json = mergeOpenCodeAppConfig(json, input.directory);
1391
+ return { env: { OPENCODE_CONFIG_CONTENT: json }, report: {
1392
+ ...prep.report,
1393
+ rulesPrepared: hasRules,
1394
+ reason: hasRules ? undefined : version === "2.0.6" ? "native-entry-not-verified" : "missing-app-rules",
1395
+ openCodeQuestions: { version, mode: "fallback", configuration: "prepared", reason: "acp-question-not-forwarded" }
1396
+ } };
1367
1397
  } catch {
1368
- return { ...prep, report: { ...prep.report, reason: "native-config-prepare-failed" } };
1398
+ return { ...prep, report: {
1399
+ ...prep.report,
1400
+ reason: "native-config-prepare-failed",
1401
+ openCodeQuestions: { mode: "unverified", configuration: "unchanged", reason: "prepare-failed" }
1402
+ } };
1369
1403
  }
1370
1404
  }
1371
1405
  function prepareClaudeResources(directory) {
@@ -1961,7 +1995,7 @@ var opencodeAdapter = {
1961
1995
  // src/runtimes/opencode-v2/index.ts
1962
1996
  var opencodeV2Adapter = {
1963
1997
  id: "opencode-v2",
1964
- prepareAppResources: async ({ directory }) => prepareCompatibilityResources(directory, "native-config-entry-not-verified"),
1998
+ prepareAppResources: prepareOpenCodeResources,
1965
1999
  probeAuth: () => probeOpencodeAuth(),
1966
2000
  orderAuthMethods: (methods) => methods,
1967
2001
  canSkipInteractiveAuth: () => false,
@@ -2614,7 +2648,7 @@ var agyAdapter = {
2614
2648
  return { ...prep, env: { AGY_ACP_RESOURCES_DIR: directory }, report: { ...prep.report, rulesPrepared: prep.report.rulesChars > 0 } };
2615
2649
  },
2616
2650
  appResourceSessionMeta: (directory) => ({ appResources: { directory } }),
2617
- supportedBridgeVersions: ["0.1.24", "0.1.25"],
2651
+ supportedBridgeVersions: ["0.1.24", "0.1.25", "0.1.26"],
2618
2652
  probeAuth: () => probeAgyAuth(),
2619
2653
  probeQuota: (options) => probeAgyQuota(options),
2620
2654
  orderAuthMethods: (methods) => methods,
@@ -2854,7 +2888,7 @@ function tryReuseLiveAcpProcess(runtimeId, query = {}) {
2854
2888
  }
2855
2889
 
2856
2890
  // src/client/client-handlers.ts
2857
- import { methods, RequestError } from "@agentclientprotocol/sdk";
2891
+ import { methods as methods2, RequestError } from "@agentclientprotocol/sdk";
2858
2892
 
2859
2893
  // src/client/acp-fs.ts
2860
2894
  import { access, readFile as readFile4, writeFile as writeFile4 } from "node:fs/promises";
@@ -2912,7 +2946,7 @@ function toServerError(error, fallback) {
2912
2946
  return new RequestError(-32000, error instanceof Error ? error.message : fallback);
2913
2947
  }
2914
2948
  function registerAcpClientHandlers(app, deps) {
2915
- app.onRequest(methods.client.session.requestPermission, async (ctx) => {
2949
+ app.onRequest(methods2.client.session.requestPermission, async (ctx) => {
2916
2950
  const params = ctx.params;
2917
2951
  const toolCall = params.toolCall;
2918
2952
  const toolHint = toolCall && typeof toolCall === "object" ? {
@@ -2937,7 +2971,7 @@ function registerAcpClientHandlers(app, deps) {
2937
2971
  return { outcome: { outcome: "cancelled" } };
2938
2972
  }
2939
2973
  });
2940
- app.onRequest(methods.client.fs.readTextFile, async (ctx) => {
2974
+ app.onRequest(methods2.client.fs.readTextFile, async (ctx) => {
2941
2975
  const workspaceRoot = deps.getWorkspaceRoot();
2942
2976
  const filePath = ctx.params.path;
2943
2977
  if (!workspaceRoot || !filePath) {
@@ -2972,7 +3006,7 @@ function registerAcpClientHandlers(app, deps) {
2972
3006
  throw toServerError(error, "读取文件失败");
2973
3007
  }
2974
3008
  });
2975
- app.onRequest(methods.client.fs.writeTextFile, async (ctx) => {
3009
+ app.onRequest(methods2.client.fs.writeTextFile, async (ctx) => {
2976
3010
  const workspaceRoot = deps.getWorkspaceRoot();
2977
3011
  const filePath = ctx.params.path;
2978
3012
  const content = ctx.params.content;
@@ -2989,7 +3023,7 @@ function registerAcpClientHandlers(app, deps) {
2989
3023
  throw toServerError(error, "写入文件失败");
2990
3024
  }
2991
3025
  });
2992
- app.onRequest(methods.client.terminal.create, async (ctx) => {
3026
+ app.onRequest(methods2.client.terminal.create, async (ctx) => {
2993
3027
  const workspaceRoot = deps.getWorkspaceRoot();
2994
3028
  const sessionId = ctx.params.sessionId;
2995
3029
  const command = ctx.params.command;
@@ -3010,7 +3044,7 @@ function registerAcpClientHandlers(app, deps) {
3010
3044
  throw toServerError(error, "创建终端失败");
3011
3045
  }
3012
3046
  });
3013
- app.onRequest(methods.client.terminal.output, async (ctx) => {
3047
+ app.onRequest(methods2.client.terminal.output, async (ctx) => {
3014
3048
  const terminalId = ctx.params.terminalId;
3015
3049
  if (!terminalId) {
3016
3050
  throw toInvalidParams("terminal/output 需要 terminalId");
@@ -3021,7 +3055,7 @@ function registerAcpClientHandlers(app, deps) {
3021
3055
  throw toServerError(error, "读取终端输出失败");
3022
3056
  }
3023
3057
  });
3024
- app.onRequest(methods.client.terminal.waitForExit, async (ctx) => {
3058
+ app.onRequest(methods2.client.terminal.waitForExit, async (ctx) => {
3025
3059
  const terminalId = ctx.params.terminalId;
3026
3060
  if (!terminalId) {
3027
3061
  throw toInvalidParams("terminal/wait_for_exit 需要 terminalId");
@@ -3032,7 +3066,7 @@ function registerAcpClientHandlers(app, deps) {
3032
3066
  throw toServerError(error, "等待终端退出失败");
3033
3067
  }
3034
3068
  });
3035
- app.onRequest(methods.client.terminal.kill, async (ctx) => {
3069
+ app.onRequest(methods2.client.terminal.kill, async (ctx) => {
3036
3070
  const terminalId = ctx.params.terminalId;
3037
3071
  if (!terminalId) {
3038
3072
  throw toInvalidParams("terminal/kill 需要 terminalId");
@@ -3043,7 +3077,7 @@ function registerAcpClientHandlers(app, deps) {
3043
3077
  throw toServerError(error, "终止终端失败");
3044
3078
  }
3045
3079
  });
3046
- app.onRequest(methods.client.terminal.release, async (ctx) => {
3080
+ app.onRequest(methods2.client.terminal.release, async (ctx) => {
3047
3081
  const terminalId = ctx.params.terminalId;
3048
3082
  if (!terminalId) {
3049
3083
  throw toInvalidParams("terminal/release 需要 terminalId");
@@ -3054,7 +3088,7 @@ function registerAcpClientHandlers(app, deps) {
3054
3088
  throw toServerError(error, "释放终端失败");
3055
3089
  }
3056
3090
  });
3057
- app.onNotification(methods.client.session.update, async (ctx) => {
3091
+ app.onNotification(methods2.client.session.update, async (ctx) => {
3058
3092
  deps.onSessionUpdate({
3059
3093
  sessionId: ctx.params.sessionId,
3060
3094
  update: ctx.params.update
@@ -3093,7 +3127,7 @@ function pickAllowOptionId(params) {
3093
3127
  }
3094
3128
 
3095
3129
  // src/client/session-open.ts
3096
- import { RequestError as RequestError2 } from "@agentclientprotocol/sdk";
3130
+ import { RequestError as RequestError2, methods as methods3 } from "@agentclientprotocol/sdk";
3097
3131
 
3098
3132
  // src/session/config-options.ts
3099
3133
  function coerceOptionValue(raw) {
@@ -3239,6 +3273,9 @@ function mergeTopLevelModelsIntoConfigOptions(configOptionsRaw, response) {
3239
3273
  }
3240
3274
 
3241
3275
  // src/client/session-open.ts
3276
+ function isAuthenticationRequired(message) {
3277
+ return !/\bmcp\b/i.test(message) && /authentication required|not authenticated|please (?:log|sign) in|需要认证|尚未认证/i.test(message);
3278
+ }
3242
3279
  function errorMessage(error) {
3243
3280
  return error instanceof Error ? error.message : String(error);
3244
3281
  }
@@ -3258,29 +3295,30 @@ function isTransientAcpTransportError(error) {
3258
3295
  return /ACP connection closed|connection closed|closed|abort|超时|timeout|timed out|econnreset|epipe|stdio|stream/i.test(message);
3259
3296
  }
3260
3297
  async function restoreOrCreateAcpSession(input) {
3261
- const resumeId = input.resumeSessionId?.trim() || null;
3262
- const restoreAttempts = [];
3263
3298
  let mcpServersAccepted = (input.mcpServers ?? []).length > 0;
3264
3299
  let nativeSessionAccepted = false;
3300
+ let recoveredToolOutputs;
3265
3301
  const request = async (method, params) => {
3266
- if (!input.sessionMeta)
3267
- return input.request(method, params);
3268
- try {
3269
- const result = await input.request(method, { ...params, _meta: input.sessionMeta });
3270
- nativeSessionAccepted = true;
3271
- return result;
3272
- } catch (error) {
3273
- const rejected = error instanceof RequestError2 && error.code === -32602 || /native.*meta.*reject|unsupported.*(meta|systemPrompt)|unknown.*(meta|systemPrompt)/i.test(errorMessage(error));
3274
- if (!rejected || isTransientAcpTransportError(error))
3275
- throw error;
3276
- log("warn", "native resource options failed; retry without extension");
3277
- const result = await input.request(method, params);
3278
- nativeSessionAccepted = false;
3279
- return result;
3280
- }
3302
+ const opened = await requestSessionWithResources(input.request, method, params, input.sessionMeta);
3303
+ nativeSessionAccepted = opened.nativeSessionAccepted;
3304
+ const meta = opened.result._meta;
3305
+ const outputs = meta?.toolOutputRecovery?.outputs;
3306
+ let total = 0;
3307
+ recoveredToolOutputs = Array.isArray(outputs) ? outputs.slice(0, 20).filter((row) => {
3308
+ if (!row || typeof row.toolCallId !== "string" || row.toolCallId.length > 120 || typeof row.text !== "string")
3309
+ return false;
3310
+ const bytes = Buffer.byteLength(row.text);
3311
+ if (bytes > 128 * 1024 || total + bytes > 256 * 1024)
3312
+ return false;
3313
+ total += bytes;
3314
+ return true;
3315
+ }) : undefined;
3316
+ return opened.result;
3281
3317
  };
3318
+ const resumeId = input.resumeSessionId?.trim() || null;
3319
+ const restoreAttempts = [];
3282
3320
  const delayMs = input.retryDelayMs ?? 250;
3283
- const log = input.log ?? ((level, message, data) => {
3321
+ const outputLog = input.log ?? ((level, message, data) => {
3284
3322
  if (level === "info" && false)
3285
3323
  ;
3286
3324
  const line = `[acp] ${message}`;
@@ -3289,6 +3327,7 @@ async function restoreOrCreateAcpSession(input) {
3289
3327
  else
3290
3328
  console.info(line, data ?? "");
3291
3329
  });
3330
+ const log = outputLog;
3292
3331
  const tryRestoreMethod = async (method, rpcMethod) => {
3293
3332
  const maxTries = 2;
3294
3333
  let lastError = "";
@@ -3339,19 +3378,17 @@ async function restoreOrCreateAcpSession(input) {
3339
3378
  mcpServers: input.mcpServers ?? []
3340
3379
  };
3341
3380
  try {
3342
- return await request("session/new", baseParams);
3381
+ return await request(methods3.agent.session.new, baseParams);
3343
3382
  } catch (firstError) {
3344
3383
  if ((input.mcpServers ?? []).length === 0)
3345
3384
  throw firstError;
3346
- log("warn", "session/new failed, retry without mcpServers", {
3385
+ log("warn", input.preserveMcpOnRetry ? "session/new failed, retry with mcpServers" : "session/new failed, retry without mcpServers", {
3347
3386
  error: errorMessage(firstError)
3348
3387
  });
3349
3388
  try {
3350
- const result = await request("session/new", {
3351
- cwd: input.cwd,
3352
- mcpServers: []
3353
- });
3354
- mcpServersAccepted = false;
3389
+ const retryServers = input.preserveMcpOnRetry ? input.mcpServers ?? [] : [];
3390
+ const result = await request(methods3.agent.session.new, { cwd: input.cwd, mcpServers: retryServers });
3391
+ mcpServersAccepted = retryServers.length > 0;
3355
3392
  return result;
3356
3393
  } catch {
3357
3394
  throw firstError;
@@ -3360,16 +3397,17 @@ async function restoreOrCreateAcpSession(input) {
3360
3397
  };
3361
3398
  const withModelsFallback = (result) => mergeTopLevelModelsIntoConfigOptions(result.configOptions, result);
3362
3399
  if (resumeId && input.resumeSupported) {
3363
- const resumed = await tryRestoreMethod("resume", "session/resume");
3400
+ const resumed = await tryRestoreMethod("resume", methods3.agent.session.resume);
3364
3401
  if (resumed) {
3365
3402
  const id = typeof resumed.sessionId === "string" ? resumed.sessionId : resumeId;
3366
3403
  return {
3367
3404
  sessionId: id,
3405
+ mcpServersAccepted,
3406
+ recoveredToolOutputs,
3407
+ nativeSessionAccepted,
3368
3408
  configOptions: withModelsFallback(resumed),
3369
3409
  restoreMethod: "resume",
3370
3410
  sessionRestored: true,
3371
- mcpServersAccepted,
3372
- nativeSessionAccepted,
3373
3411
  requestedSessionId: resumeId,
3374
3412
  restoreAttempts
3375
3413
  };
@@ -3380,16 +3418,17 @@ async function restoreOrCreateAcpSession(input) {
3380
3418
  if (resumeId && input.loadSupported) {
3381
3419
  input.onSuppressUpdates?.(true);
3382
3420
  try {
3383
- const loaded = await tryRestoreMethod("load", "session/load");
3421
+ const loaded = await tryRestoreMethod("load", methods3.agent.session.load);
3384
3422
  if (loaded) {
3385
3423
  const id = typeof loaded.sessionId === "string" ? loaded.sessionId : resumeId;
3386
3424
  return {
3387
3425
  sessionId: id,
3426
+ mcpServersAccepted,
3427
+ recoveredToolOutputs,
3428
+ nativeSessionAccepted,
3388
3429
  configOptions: withModelsFallback(loaded),
3389
3430
  restoreMethod: "load",
3390
3431
  sessionRestored: true,
3391
- mcpServersAccepted,
3392
- nativeSessionAccepted,
3393
3432
  requestedSessionId: resumeId,
3394
3433
  restoreAttempts
3395
3434
  };
@@ -3408,15 +3447,27 @@ async function restoreOrCreateAcpSession(input) {
3408
3447
  }
3409
3448
  return {
3410
3449
  sessionId: newSessionId,
3450
+ mcpServersAccepted,
3451
+ nativeSessionAccepted,
3411
3452
  configOptions: withModelsFallback(sessionResult),
3412
3453
  restoreMethod: "new",
3413
3454
  sessionRestored: false,
3414
- mcpServersAccepted,
3415
- nativeSessionAccepted,
3416
3455
  requestedSessionId: resumeId ?? undefined,
3417
3456
  restoreAttempts
3418
3457
  };
3419
3458
  }
3459
+ async function requestSessionWithResources(request, method, params, sessionMeta) {
3460
+ if (!sessionMeta)
3461
+ return { result: await request(method, params), nativeSessionAccepted: false };
3462
+ try {
3463
+ return { result: await request(method, { ...params, _meta: sessionMeta }), nativeSessionAccepted: true };
3464
+ } catch (error) {
3465
+ const rejected = error instanceof RequestError2 && error.code === -32602 || /native.*meta.*reject|unsupported.*(meta|systemPrompt)|unknown.*(meta|systemPrompt)/i.test(errorMessage(error));
3466
+ if (!rejected || isTransientAcpTransportError(error))
3467
+ throw error;
3468
+ return { result: await request(method, params), nativeSessionAccepted: false };
3469
+ }
3470
+ }
3420
3471
 
3421
3472
  // src/client/acp-terminal.ts
3422
3473
  import { spawn as spawn3 } from "node:child_process";
@@ -3760,7 +3811,7 @@ var NATIVE_ELIGIBLE_BRIDGE_VERSIONS = {
3760
3811
  "codex-acp": ["2.2.2"],
3761
3812
  opencode: ["1.18.35"],
3762
3813
  claude: ["0.91.0"],
3763
- agy: ["0.1.24", "0.1.25"]
3814
+ agy: ["0.1.24", "0.1.25", "0.1.26"]
3764
3815
  };
3765
3816
  function resolveRuntimeEligibility(runtimeId) {
3766
3817
  const id = (runtimeId ?? "").trim();
@@ -3959,6 +4010,13 @@ class AcpClient {
3959
4010
  }
3960
4011
  this.sessionConfig = profile;
3961
4012
  resourceEnv = this.sessionConfig.env;
4013
+ const interactions = ["opencode", "opencode-v2"].includes(this.runtimeInfo.id) && this.adapter.prepareAppResources ? await this.adapter.prepareAppResources({
4014
+ directory: this.resourcesDir,
4015
+ command: effectiveRuntime.command,
4016
+ workspaceRoot: this.workspaceRoot,
4017
+ env: { ...process.env, ...spawnEnv.env, ...resourceEnv }
4018
+ }) : undefined;
4019
+ Object.assign(resourceEnv, interactions?.env);
3962
4020
  const load = readAppResourcesDir(this.resourcesDir);
3963
4021
  this.resourcePrep = { profileTag: null, report: {
3964
4022
  rulesApplied: false,
@@ -3967,6 +4025,7 @@ class AcpClient {
3967
4025
  rulesChars: load.rules?.chars ?? 0,
3968
4026
  profileDigest: digestAppResources(load),
3969
4027
  skillsFound: load.skills.map((s) => s.name),
4028
+ openCodeQuestions: interactions?.report.openCodeQuestions,
3970
4029
  configurationScope: "session",
3971
4030
  configurationDirectory: this.sessionConfig.directory,
3972
4031
  configurationRulesFile: this.sessionConfig.rulesFile,
@@ -4086,7 +4145,7 @@ class AcpClient {
4086
4145
  this.sdkApp = app;
4087
4146
  this.sdkConnection = connection;
4088
4147
  this.streamHandle = streamHandle;
4089
- const initResp = await sdkRequest(connection.agent, methods2.agent.initialize, {
4148
+ const initResp = await sdkRequest(connection.agent, methods4.agent.initialize, {
4090
4149
  protocolVersion: 1,
4091
4150
  clientInfo: this.clientInfo,
4092
4151
  clientCapabilities: {
@@ -4230,7 +4289,7 @@ class AcpClient {
4230
4289
  }
4231
4290
  const compat = this.buildCompatPrepend(sessionId);
4232
4291
  const blocks = compat ? [{ type: "text", text: compat }, ...prompt] : prompt;
4233
- const response = await sdkRequest(this.sdkConnection.agent, methods2.agent.session.prompt, {
4292
+ const response = await sdkRequest(this.sdkConnection.agent, methods4.agent.session.prompt, {
4234
4293
  sessionId,
4235
4294
  prompt: blocks
4236
4295
  }, options?.timeoutMs);
@@ -4279,7 +4338,7 @@ class AcpClient {
4279
4338
  return err({ code: "ACP_NOT_CONNECTED", message: "尚未连接到 Agent 服务端" });
4280
4339
  }
4281
4340
  try {
4282
- const response = await sdkRequest(this.sdkConnection.agent, methods2.agent.session.setConfigOption, {
4341
+ const response = await sdkRequest(this.sdkConnection.agent, methods4.agent.session.setConfigOption, {
4283
4342
  sessionId,
4284
4343
  configId,
4285
4344
  value
@@ -5323,6 +5382,7 @@ export {
5323
5382
  handleInkdownMcpRpc,
5324
5383
  isAbsolutePathLike,
5325
5384
  isAppError,
5385
+ isAuthenticationRequired,
5326
5386
  isBinaryDocumentPath,
5327
5387
  isCancelled,
5328
5388
  isCodexPreflightRuntime,
@@ -5340,6 +5400,7 @@ export {
5340
5400
  mergeCodexConfigJson,
5341
5401
  mergeConfigTomlPreserving,
5342
5402
  mergeOpenCodeAppConfig,
5403
+ mergeOpenCodeQuestionConfig,
5343
5404
  mergeTopLevelModelsIntoConfigOptions,
5344
5405
  ok,
5345
5406
  opencodeAdapter,
@@ -5376,6 +5437,7 @@ export {
5376
5437
  readAppRulesText,
5377
5438
  readStoredAcpProvider,
5378
5439
  registerAcpClientHandlers,
5440
+ requestSessionWithResources,
5379
5441
  resolveClaudeHome,
5380
5442
  resolveCodexHome,
5381
5443
  resolveCopilotHome,
@@ -5386,6 +5448,7 @@ export {
5386
5448
  resolveDeepseekSpawnBlocker,
5387
5449
  resolveDeepseekSpawnCommand,
5388
5450
  resolveGeminiHome,
5451
+ resolveOpenCodeQuestionMode,
5389
5452
  resolveOpencodeAuthCandidates,
5390
5453
  resolveOpencodeAuthFile,
5391
5454
  resolveOpencodeAuthPath,
@@ -55,6 +55,13 @@ export declare function digestAppResources(load: AppResourceLoad): string | null
55
55
  /** 读取常驻规则正文(适配器合并配置用;正文不出本作用域,只传摘要与长度)。 */
56
56
  export declare function readAppRulesText(directory: string): string | null;
57
57
  export interface AppResourceReport {
58
+ /** Prepared process overlay, not proof of runtime loading or UI MCP availability. */
59
+ openCodeQuestions?: {
60
+ version?: string;
61
+ mode: 'fallback' | 'unverified';
62
+ configuration: 'prepared' | 'unchanged';
63
+ reason: string;
64
+ };
58
65
  /** Child-only isolated config roots; existence is not proof the runtime loaded rules. */
59
66
  configurationScope?: 'session';
60
67
  configurationDirectory?: string;
@@ -12,7 +12,7 @@ export declare const APP_RESOURCE_CAPABILITIES: {
12
12
  readonly configHome: 'OPENCODE_CONFIG_DIR';
13
13
  };
14
14
  readonly 'opencode-v2': {
15
- readonly entry: null;
15
+ readonly entry: 'OPENCODE_CONFIG_CONTENT (questions only)';
16
16
  readonly strategy: 'compatibility';
17
17
  readonly configHome: null;
18
18
  };
@@ -50,6 +50,11 @@ export declare const APP_RESOURCE_CAPABILITIES: {
50
50
  };
51
51
  export declare function prepareCompatibilityResources(directory: string, reason: string): AppResourcePrep;
52
52
  export declare function mergeOpenCodeAppConfig(raw: string | undefined, directory: string): string;
53
+ /** Verified: 1.18.35 acp/event.ts omits questions; the 2.0.6 Windows ACP
54
+ * dispatcher cancels form.created. Neither implies native resource loading. */
55
+ export declare function resolveOpenCodeQuestionMode(version: string): 'fallback' | 'unverified';
56
+ /** Child-only overlay; preserve unrelated permissions, providers and authentication. */
57
+ export declare function mergeOpenCodeQuestionConfig(raw: string | undefined): string;
53
58
  export declare function prepareOpenCodeResources(input: {
54
59
  directory: string;
55
60
  env?: NodeJS.ProcessEnv;