@yitom/acp-client 0.1.11 → 0.1.13

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/sidecar.cjs CHANGED
@@ -36,7 +36,7 @@ var __toESM = (mod, isNodeMode, target) => {
36
36
  var readline2 = __toESM(require("node:readline"), 1);
37
37
 
38
38
  // src/version.ts
39
- var ACP_CLIENT_VERSION = "0.1.11";
39
+ var ACP_CLIENT_VERSION = "0.1.13";
40
40
  // src/contracts/index.ts
41
41
  function ok(value) {
42
42
  return { ok: true, value };
@@ -156,8 +156,8 @@ var BUILTIN_ACP_RUNTIMES = [
156
156
  {
157
157
  id: "deepseek",
158
158
  name: "DeepSeek",
159
- description: "通过 bunx 启动 @deepseek-ai/dsh(--profile acp);无 ACP 登录,靠 harness 自身凭证(DEEPSEEK_API_KEY / harness 配置);模型经 session 到达,无需额外动作",
160
- authHint: "无 ACP 登录,靠 harness 自身凭证(DEEPSEEK_API_KEY / harness 配置);未配置先导出 DEEPSEEK_API_KEY;模型经 session 到达,无需额外动作;若官方最新 dsh 存在坏依赖(如 rc.3 缺失),可设 DSH_PACKAGE pin 旧版",
159
+ description: "通过 dsh 启动 @deepseek-ai/dsh(--profile acp);无 ACP 登录,靠 harness 自身凭证(DEEPSEEK_API_KEY 或 $DSH_HOME/.credentials.yaml);模型经 session 到达(V4.1-Flash 的 id 是 deepseek-flash)",
160
+ authHint: "无 ACP 登录,靠 harness 自身凭证;先导出 DEEPSEEK_API_KEY 或在 dsh 里完成登录;稳定安装可设 DSH_BIN 指向 dsh 入口(bunx 临时目录被清理会让 profile 断链);pin 包版本用 DSH_PACKAGE(如 @deepseek-ai/dsh@0.2.1-rc.2)",
161
161
  command: "bunx",
162
162
  args: ["-y", `${DEEPSEEK_DSH_NPM_PACKAGE}@latest`, "--profile", "acp"],
163
163
  requiredEnvKeys: ["DEEPSEEK_API_KEY"]
@@ -197,17 +197,7 @@ var AGENT_METHODS = {
197
197
  session_fork: "session/fork",
198
198
  session_resume: "session/resume",
199
199
  session_close: "session/close",
200
- logout: "logout",
201
- nes_start: "nes/start",
202
- nes_suggest: "nes/suggest",
203
- nes_accept: "nes/accept",
204
- nes_reject: "nes/reject",
205
- nes_close: "nes/close",
206
- document_did_open: "document/didOpen",
207
- document_did_change: "document/didChange",
208
- document_did_close: "document/didClose",
209
- document_did_save: "document/didSave",
210
- document_did_focus: "document/didFocus"
200
+ logout: "logout"
211
201
  };
212
202
  var CLIENT_METHODS = {
213
203
  session_request_permission: "session/request_permission",
@@ -219,9 +209,7 @@ var CLIENT_METHODS = {
219
209
  terminal_release: "terminal/release",
220
210
  terminal_wait_for_exit: "terminal/wait_for_exit",
221
211
  terminal_kill: "terminal/kill",
222
- mcp_connect: "mcp/connect",
223
212
  mcp_message: "mcp/message",
224
- mcp_disconnect: "mcp/disconnect",
225
213
  elicitation_create: "elicitation/create",
226
214
  elicitation_complete: "elicitation/complete"
227
215
  };
@@ -1210,6 +1198,7 @@ var anyString = /^[\s\S]{0,}$/;
1210
1198
  var integer = /^-?\d+$/;
1211
1199
  var number = /^-?\d+(?:\.\d+)?$/;
1212
1200
  var boolean = /^(?:true|false)$/i;
1201
+ var _null = /^null$/i;
1213
1202
  var lowercase = /^[^A-Z]*$/;
1214
1203
  var uppercase = /^[^a-z]*$/;
1215
1204
 
@@ -2111,6 +2100,23 @@ var $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
2111
2100
  return payload;
2112
2101
  };
2113
2102
  });
2103
+ var $ZodNull = /* @__PURE__ */ $constructor("$ZodNull", (inst, def) => {
2104
+ $ZodType.init(inst, def);
2105
+ inst._zod.pattern = _null;
2106
+ inst._zod.values = new Set([null]);
2107
+ inst._zod.parse = (payload, _ctx) => {
2108
+ const input = payload.value;
2109
+ if (input === null)
2110
+ return payload;
2111
+ payload.issues.push({
2112
+ expected: "null",
2113
+ code: "invalid_type",
2114
+ input,
2115
+ inst
2116
+ });
2117
+ return payload;
2118
+ };
2119
+ });
2114
2120
  var $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
2115
2121
  $ZodType.init(inst, def);
2116
2122
  inst._zod.parse = (payload) => payload;
@@ -3055,6 +3061,9 @@ function handlePipeResult(left, next, ctx) {
3055
3061
  }
3056
3062
  return next._zod.run({ value: left.value, issues: left.issues }, ctx);
3057
3063
  }
3064
+ var $ZodPreprocess = /* @__PURE__ */ $constructor("$ZodPreprocess", (inst, def) => {
3065
+ $ZodPipe.init(inst, def);
3066
+ });
3058
3067
  var $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
3059
3068
  $ZodType.init(inst, def);
3060
3069
  defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
@@ -3809,6 +3818,12 @@ function _boolean(Class, params) {
3809
3818
  ...normalizeParams(params)
3810
3819
  });
3811
3820
  }
3821
+ function _null2(Class, params) {
3822
+ return new Class({
3823
+ type: "null",
3824
+ ...normalizeParams(params)
3825
+ });
3826
+ }
3812
3827
  function _unknown(Class) {
3813
3828
  return new Class({
3814
3829
  type: "unknown"
@@ -4694,6 +4709,15 @@ var numberProcessor = (schema, ctx, _json, params) => {
4694
4709
  var booleanProcessor = (_schema, _ctx, json, _params) => {
4695
4710
  json.type = "boolean";
4696
4711
  };
4712
+ var nullProcessor = (_schema, ctx, json, _params) => {
4713
+ if (ctx.target === "openapi-3.0") {
4714
+ json.type = "string";
4715
+ json.nullable = true;
4716
+ json.enum = [null];
4717
+ } else {
4718
+ json.type = "null";
4719
+ }
4720
+ };
4697
4721
  var neverProcessor = (_schema, _ctx, json, _params) => {
4698
4722
  json.not = {};
4699
4723
  };
@@ -5604,6 +5628,14 @@ var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
5604
5628
  function boolean2(params) {
5605
5629
  return _boolean(ZodBoolean, params);
5606
5630
  }
5631
+ var ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
5632
+ $ZodNull.init(inst, def);
5633
+ ZodType.init(inst, def);
5634
+ inst._zod.processJSONSchema = (ctx, json, params) => nullProcessor(inst, ctx, json, params);
5635
+ });
5636
+ function _null3(params) {
5637
+ return _null2(ZodNull, params);
5638
+ }
5607
5639
  var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
5608
5640
  $ZodUnknown.init(inst, def);
5609
5641
  ZodType.init(inst, def);
@@ -5704,6 +5736,14 @@ function object(shape, params) {
5704
5736
  };
5705
5737
  return new ZodObject(def);
5706
5738
  }
5739
+ function looseObject(shape, params) {
5740
+ return new ZodObject({
5741
+ type: "object",
5742
+ shape,
5743
+ catchall: unknown(),
5744
+ ...normalizeParams(params)
5745
+ });
5746
+ }
5707
5747
  var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
5708
5748
  $ZodUnion.init(inst, def);
5709
5749
  ZodType.init(inst, def);
@@ -5968,6 +6008,10 @@ function pipe(in_, out) {
5968
6008
  out
5969
6009
  });
5970
6010
  }
6011
+ var ZodPreprocess = /* @__PURE__ */ $constructor("ZodPreprocess", (inst, def) => {
6012
+ ZodPipe.init(inst, def);
6013
+ $ZodPreprocess.init(inst, def);
6014
+ });
5971
6015
  var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
5972
6016
  $ZodReadonly.init(inst, def);
5973
6017
  ZodType.init(inst, def);
@@ -5991,6 +6035,13 @@ function refine(fn, _params = {}) {
5991
6035
  function superRefine(fn, params) {
5992
6036
  return _superRefine(fn, params);
5993
6037
  }
6038
+ function preprocess(fn, schema) {
6039
+ return new ZodPreprocess({
6040
+ type: "pipe",
6041
+ in: transform(fn),
6042
+ out: schema
6043
+ });
6044
+ }
5994
6045
  // node_modules/@agentclientprotocol/sdk/dist/schema-deserialize.js
5995
6046
  var skippedItem = Symbol("skippedItem");
5996
6047
  function defaultOnError(schema, fallback) {
@@ -6050,6 +6101,21 @@ function preserveCustomPayload(schema, key, knownTags) {
6050
6101
  return output;
6051
6102
  });
6052
6103
  }
6104
+ function defaultOnErrorOptionalStringTag(schema, key) {
6105
+ return preprocess((value) => {
6106
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
6107
+ return value;
6108
+ }
6109
+ const record = value;
6110
+ const tag = record[key];
6111
+ if (tag === undefined || tag === null || typeof tag === "string") {
6112
+ return value;
6113
+ }
6114
+ const normalized = { ...record };
6115
+ delete normalized[key];
6116
+ return normalized;
6117
+ }, schema);
6118
+ }
6053
6119
  function vecSkipError(itemSchema) {
6054
6120
  return array(itemSchema.catch(skippedItem)).transform((items) => items.filter((item) => item !== skippedItem));
6055
6121
  }
@@ -6068,16 +6134,12 @@ var zWriteTextFileRequest = object({
6068
6134
  var zReadTextFileRequest = object({
6069
6135
  sessionId: zSessionId,
6070
6136
  path: string2(),
6071
- line: defaultOnError(int().gte(0).max(4294967295, {
6137
+ line: int().gte(0).max(4294967295, {
6072
6138
  error: "Invalid value: Expected uint32 to be <= 4294967295"
6073
- }).nullish(), () => {
6074
- return;
6075
- }),
6076
- limit: defaultOnError(int().gte(0).max(4294967295, {
6139
+ }).nullish(),
6140
+ limit: int().gte(0).max(4294967295, {
6077
6141
  error: "Invalid value: Expected uint32 to be <= 4294967295"
6078
- }).nullish(), () => {
6079
- return;
6080
- }),
6142
+ }).nullish(),
6081
6143
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6082
6144
  return;
6083
6145
  })
@@ -6328,14 +6390,10 @@ var zEnvVariable = object({
6328
6390
  var zCreateTerminalRequest = object({
6329
6391
  sessionId: zSessionId,
6330
6392
  command: string2(),
6331
- args: defaultOnError(vecSkipError(string2()).optional(), () => []),
6332
- env: defaultOnError(vecSkipError(zEnvVariable).optional(), () => []),
6333
- cwd: defaultOnError(string2().nullish(), () => {
6334
- return;
6335
- }),
6336
- outputByteLimit: defaultOnError(number2().nullish(), () => {
6337
- return;
6338
- }),
6393
+ args: array(string2()).optional(),
6394
+ env: array(zEnvVariable).optional(),
6395
+ cwd: string2().nullish(),
6396
+ outputByteLimit: number2().nullish(),
6339
6397
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6340
6398
  return;
6341
6399
  })
@@ -6561,27 +6619,16 @@ var zCreateElicitationRequest = preserveCustomPayload(intersection(union([
6561
6619
  })
6562
6620
  })), "mode", ["form", "url"]);
6563
6621
  var zMcpServerAcpId = string2();
6564
- var zConnectMcpRequest = object({
6565
- serverId: zMcpServerAcpId,
6566
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6567
- return;
6568
- })
6569
- });
6570
- var zMcpConnectionId = string2();
6622
+ var zMcpRequestId = string2();
6571
6623
  var zMessageMcpRequest = object({
6572
- connectionId: zMcpConnectionId,
6624
+ serverId: zMcpServerAcpId,
6625
+ requestId: zMcpRequestId,
6573
6626
  method: string2(),
6574
6627
  params: record(string2(), unknown()).nullish(),
6575
6628
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6576
6629
  return;
6577
6630
  })
6578
6631
  });
6579
- var zDisconnectMcpRequest = object({
6580
- connectionId: zMcpConnectionId,
6581
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6582
- return;
6583
- })
6584
- });
6585
6632
  var zExtRequest = unknown();
6586
6633
  var zAgentRequest = object({
6587
6634
  id: zRequestId,
@@ -6596,9 +6643,7 @@ var zAgentRequest = object({
6596
6643
  zWaitForTerminalExitRequest,
6597
6644
  zKillTerminalRequest,
6598
6645
  zCreateElicitationRequest,
6599
- zConnectMcpRequest,
6600
6646
  zMessageMcpRequest,
6601
- zDisconnectMcpRequest,
6602
6647
  zExtRequest
6603
6648
  ]).nullish()
6604
6649
  });
@@ -6634,204 +6679,86 @@ var zSessionAdditionalDirectoriesCapabilities = object({
6634
6679
  return;
6635
6680
  })
6636
6681
  });
6637
- var zSessionForkCapabilities = object({
6638
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6639
- return;
6640
- })
6641
- });
6642
- var zSessionResumeCapabilities = object({
6643
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6644
- return;
6645
- })
6646
- });
6647
- var zSessionCloseCapabilities = object({
6682
+ var zSessionSystemPromptOverrideCapabilities = object({
6648
6683
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6649
6684
  return;
6650
6685
  })
6651
6686
  });
6652
- var zSessionCapabilities = object({
6653
- list: defaultOnError(zSessionListCapabilities.nullish(), () => {
6654
- return;
6655
- }),
6656
- delete: defaultOnError(zSessionDeleteCapabilities.nullish(), () => {
6657
- return;
6658
- }),
6659
- additionalDirectories: defaultOnError(zSessionAdditionalDirectoriesCapabilities.nullish(), () => {
6660
- return;
6661
- }),
6662
- fork: defaultOnError(zSessionForkCapabilities.nullish(), () => {
6663
- return;
6664
- }),
6665
- resume: defaultOnError(zSessionResumeCapabilities.nullish(), () => {
6666
- return;
6667
- }),
6668
- close: defaultOnError(zSessionCloseCapabilities.nullish(), () => {
6687
+ var zSessionSystemPromptModeCapabilities = object({
6688
+ override: defaultOnError(zSessionSystemPromptOverrideCapabilities.nullish(), () => {
6669
6689
  return;
6670
6690
  }),
6671
6691
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6672
6692
  return;
6673
6693
  })
6674
6694
  });
6675
- var zLogoutCapabilities = object({
6676
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6677
- return;
6678
- })
6679
- });
6680
- var zAgentAuthCapabilities = object({
6681
- logout: defaultOnError(zLogoutCapabilities.nullish(), () => {
6695
+ var zSessionSystemPromptCapabilities = object({
6696
+ mode: defaultOnError(zSessionSystemPromptModeCapabilities.nullish(), () => {
6682
6697
  return;
6683
6698
  }),
6684
6699
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6685
6700
  return;
6686
6701
  })
6687
6702
  });
6688
- var zProvidersCapabilities = object({
6689
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6690
- return;
6691
- })
6692
- });
6693
- var zNesDocumentDidOpenCapabilities = object({
6694
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6695
- return;
6696
- })
6697
- });
6698
- var zTextDocumentSyncKind = union([
6699
- literal("full"),
6700
- literal("incremental")
6701
- ]);
6702
- var zNesDocumentDidChangeCapabilities = object({
6703
- syncKind: zTextDocumentSyncKind,
6704
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6705
- return;
6706
- })
6707
- });
6708
- var zNesDocumentDidCloseCapabilities = object({
6703
+ var zSessionForkCapabilities = object({
6709
6704
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6710
6705
  return;
6711
6706
  })
6712
6707
  });
6713
- var zNesDocumentDidSaveCapabilities = object({
6708
+ var zSessionResumeCapabilities = object({
6714
6709
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6715
6710
  return;
6716
6711
  })
6717
6712
  });
6718
- var zNesDocumentDidFocusCapabilities = object({
6713
+ var zSessionCloseCapabilities = object({
6719
6714
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6720
6715
  return;
6721
6716
  })
6722
6717
  });
6723
- var zNesDocumentEventCapabilities = object({
6724
- didOpen: defaultOnError(zNesDocumentDidOpenCapabilities.nullish(), () => {
6725
- return;
6726
- }),
6727
- didChange: defaultOnError(zNesDocumentDidChangeCapabilities.nullish(), () => {
6728
- return;
6729
- }),
6730
- didClose: defaultOnError(zNesDocumentDidCloseCapabilities.nullish(), () => {
6718
+ var zSessionCapabilities = object({
6719
+ list: defaultOnError(zSessionListCapabilities.nullish(), () => {
6731
6720
  return;
6732
6721
  }),
6733
- didSave: defaultOnError(zNesDocumentDidSaveCapabilities.nullish(), () => {
6722
+ delete: defaultOnError(zSessionDeleteCapabilities.nullish(), () => {
6734
6723
  return;
6735
6724
  }),
6736
- didFocus: defaultOnError(zNesDocumentDidFocusCapabilities.nullish(), () => {
6725
+ additionalDirectories: defaultOnError(zSessionAdditionalDirectoriesCapabilities.nullish(), () => {
6737
6726
  return;
6738
6727
  }),
6739
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6740
- return;
6741
- })
6742
- });
6743
- var zNesEventCapabilities = object({
6744
- document: defaultOnError(zNesDocumentEventCapabilities.nullish(), () => {
6728
+ systemPrompt: defaultOnError(zSessionSystemPromptCapabilities.nullish(), () => {
6745
6729
  return;
6746
6730
  }),
6747
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6748
- return;
6749
- })
6750
- });
6751
- var zNesRecentFilesCapabilities = object({
6752
- maxCount: defaultOnError(int().gte(0).max(4294967295, {
6753
- error: "Invalid value: Expected uint32 to be <= 4294967295"
6754
- }).nullish(), () => {
6731
+ fork: defaultOnError(zSessionForkCapabilities.nullish(), () => {
6755
6732
  return;
6756
6733
  }),
6757
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6758
- return;
6759
- })
6760
- });
6761
- var zNesRelatedSnippetsCapabilities = object({
6762
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6763
- return;
6764
- })
6765
- });
6766
- var zNesEditHistoryCapabilities = object({
6767
- maxCount: defaultOnError(int().gte(0).max(4294967295, {
6768
- error: "Invalid value: Expected uint32 to be <= 4294967295"
6769
- }).nullish(), () => {
6734
+ resume: defaultOnError(zSessionResumeCapabilities.nullish(), () => {
6770
6735
  return;
6771
6736
  }),
6772
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6773
- return;
6774
- })
6775
- });
6776
- var zNesUserActionsCapabilities = object({
6777
- maxCount: defaultOnError(int().gte(0).max(4294967295, {
6778
- error: "Invalid value: Expected uint32 to be <= 4294967295"
6779
- }).nullish(), () => {
6737
+ close: defaultOnError(zSessionCloseCapabilities.nullish(), () => {
6780
6738
  return;
6781
6739
  }),
6782
6740
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6783
6741
  return;
6784
6742
  })
6785
6743
  });
6786
- var zNesOpenFilesCapabilities = object({
6787
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6788
- return;
6789
- })
6790
- });
6791
- var zNesDiagnosticsCapabilities = object({
6744
+ var zLogoutCapabilities = object({
6792
6745
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6793
6746
  return;
6794
6747
  })
6795
6748
  });
6796
- var zNesContextCapabilities = object({
6797
- recentFiles: defaultOnError(zNesRecentFilesCapabilities.nullish(), () => {
6798
- return;
6799
- }),
6800
- relatedSnippets: defaultOnError(zNesRelatedSnippetsCapabilities.nullish(), () => {
6801
- return;
6802
- }),
6803
- editHistory: defaultOnError(zNesEditHistoryCapabilities.nullish(), () => {
6804
- return;
6805
- }),
6806
- userActions: defaultOnError(zNesUserActionsCapabilities.nullish(), () => {
6807
- return;
6808
- }),
6809
- openFiles: defaultOnError(zNesOpenFilesCapabilities.nullish(), () => {
6810
- return;
6811
- }),
6812
- diagnostics: defaultOnError(zNesDiagnosticsCapabilities.nullish(), () => {
6749
+ var zAgentAuthCapabilities = object({
6750
+ logout: defaultOnError(zLogoutCapabilities.nullish(), () => {
6813
6751
  return;
6814
6752
  }),
6815
6753
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6816
6754
  return;
6817
6755
  })
6818
6756
  });
6819
- var zNesCapabilities = object({
6820
- events: defaultOnError(zNesEventCapabilities.nullish(), () => {
6821
- return;
6822
- }),
6823
- context: defaultOnError(zNesContextCapabilities.nullish(), () => {
6824
- return;
6825
- }),
6757
+ var zProvidersCapabilities = object({
6826
6758
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6827
6759
  return;
6828
6760
  })
6829
6761
  });
6830
- var zPositionEncodingKind = union([
6831
- literal("utf-16"),
6832
- literal("utf-32"),
6833
- literal("utf-8")
6834
- ]);
6835
6762
  var zAgentCapabilities = object({
6836
6763
  loadSession: defaultOnError(boolean2().optional().default(false), () => false),
6837
6764
  promptCapabilities: defaultOnError(zPromptCapabilities.optional().default({
@@ -6857,12 +6784,6 @@ var zAgentCapabilities = object({
6857
6784
  providers: defaultOnError(zProvidersCapabilities.nullish(), () => {
6858
6785
  return;
6859
6786
  }),
6860
- nes: defaultOnError(zNesCapabilities.nullish(), () => {
6861
- return;
6862
- }),
6863
- positionEncoding: defaultOnError(zPositionEncodingKind.nullish(), () => {
6864
- return;
6865
- }),
6866
6787
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6867
6788
  return;
6868
6789
  })
@@ -6874,10 +6795,8 @@ var zAuthMethodTerminal = object({
6874
6795
  description: defaultOnError(string2().nullish(), () => {
6875
6796
  return;
6876
6797
  }),
6877
- args: defaultOnError(vecSkipError(string2()).optional(), () => []),
6878
- env: defaultOnError(record(string2(), string2()).optional(), () => {
6879
- return;
6880
- }),
6798
+ args: array(string2()).optional(),
6799
+ env: record(string2(), string2()).optional(),
6881
6800
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
6882
6801
  return;
6883
6802
  })
@@ -7198,103 +7117,7 @@ var zPromptResponse = object({
7198
7117
  return;
7199
7118
  })
7200
7119
  });
7201
- var zStartNesResponse = object({
7202
- sessionId: zSessionId,
7203
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7204
- return;
7205
- })
7206
- });
7207
- var zNesSuggestionId = string2();
7208
- var zPosition = object({
7209
- line: int().gte(0).max(4294967295, {
7210
- error: "Invalid value: Expected uint32 to be <= 4294967295"
7211
- }),
7212
- character: int().gte(0).max(4294967295, {
7213
- error: "Invalid value: Expected uint32 to be <= 4294967295"
7214
- }),
7215
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7216
- return;
7217
- })
7218
- });
7219
- var zRange = object({
7220
- start: zPosition,
7221
- end: zPosition,
7222
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7223
- return;
7224
- })
7225
- });
7226
- var zNesTextEdit = object({
7227
- range: zRange,
7228
- newText: string2(),
7229
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7230
- return;
7231
- })
7232
- });
7233
- var zNesEditSuggestion = object({
7234
- id: zNesSuggestionId,
7235
- uri: string2(),
7236
- edits: array(zNesTextEdit),
7237
- cursorPosition: defaultOnError(zPosition.nullish(), () => {
7238
- return;
7239
- }),
7240
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7241
- return;
7242
- })
7243
- });
7244
- var zNesJumpSuggestion = object({
7245
- id: zNesSuggestionId,
7246
- uri: string2(),
7247
- position: zPosition,
7248
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7249
- return;
7250
- })
7251
- });
7252
- var zNesRenameSuggestion = object({
7253
- id: zNesSuggestionId,
7254
- uri: string2(),
7255
- position: zPosition,
7256
- newName: string2(),
7257
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7258
- return;
7259
- })
7260
- });
7261
- var zNesSearchAndReplaceSuggestion = object({
7262
- id: zNesSuggestionId,
7263
- uri: string2(),
7264
- search: string2(),
7265
- replace: string2(),
7266
- isRegex: boolean2().nullish(),
7267
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7268
- return;
7269
- })
7270
- });
7271
- var zNesSuggestion = union([
7272
- zNesEditSuggestion.and(object({
7273
- kind: literal("edit")
7274
- })),
7275
- zNesJumpSuggestion.and(object({
7276
- kind: literal("jump")
7277
- })),
7278
- zNesRenameSuggestion.and(object({
7279
- kind: literal("rename")
7280
- })),
7281
- zNesSearchAndReplaceSuggestion.and(object({
7282
- kind: literal("searchAndReplace")
7283
- }))
7284
- ]);
7285
- var zSuggestNesResponse = object({
7286
- suggestions: array(zNesSuggestion),
7287
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7288
- return;
7289
- })
7290
- });
7291
- var zCloseNesResponse = object({
7292
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7293
- return;
7294
- })
7295
- });
7296
7120
  var zExtResponse = unknown();
7297
- var zMessageMcpResponse = unknown();
7298
7121
  var zErrorCode = union([
7299
7122
  literal(-32700),
7300
7123
  literal(-32600),
@@ -7337,11 +7160,7 @@ var zAgentResponse = union([
7337
7160
  zSetSessionModeResponse,
7338
7161
  zSetSessionConfigOptionResponse,
7339
7162
  zPromptResponse,
7340
- zStartNesResponse,
7341
- zSuggestNesResponse,
7342
- zCloseNesResponse,
7343
- zExtResponse,
7344
- zMessageMcpResponse
7163
+ zExtResponse
7345
7164
  ])
7346
7165
  }),
7347
7166
  object({
@@ -7559,20 +7378,166 @@ var zCompactionSummaryChunk = object({
7559
7378
  return;
7560
7379
  })
7561
7380
  });
7562
- var zSessionUpdate = union([
7563
- zContentChunk.and(object({
7564
- sessionUpdate: literal("user_message_chunk")
7565
- })),
7566
- zContentChunk.and(object({
7567
- sessionUpdate: literal("agent_message_chunk")
7568
- })),
7569
- zContentChunk.and(object({
7570
- sessionUpdate: literal("agent_thought_chunk")
7571
- })),
7572
- zToolCall.and(object({
7573
- sessionUpdate: literal("tool_call")
7574
- })),
7575
- zToolCallUpdate.and(object({
7381
+ var zSessionCancelCapabilities = object({
7382
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7383
+ return;
7384
+ })
7385
+ });
7386
+ var zSubagentSessionCapabilities = object({
7387
+ cancel: defaultOnError(zSessionCancelCapabilities.nullish(), () => {
7388
+ return;
7389
+ }),
7390
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7391
+ return;
7392
+ })
7393
+ });
7394
+ var zRunningStateUpdate = object({
7395
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7396
+ return;
7397
+ })
7398
+ });
7399
+ var zErrorStopReason = object({
7400
+ error: defaultOnError(zError.nullish(), () => {
7401
+ return;
7402
+ })
7403
+ });
7404
+ var zIdleStateUpdate = defaultOnErrorOptionalStringTag(preserveCustomPayload(intersection(union([
7405
+ object({
7406
+ stopReason: literal("end_turn")
7407
+ }),
7408
+ object({
7409
+ stopReason: literal("max_tokens")
7410
+ }),
7411
+ object({
7412
+ stopReason: literal("max_turn_requests")
7413
+ }),
7414
+ object({
7415
+ stopReason: literal("refusal")
7416
+ }),
7417
+ object({
7418
+ stopReason: literal("cancelled")
7419
+ }),
7420
+ zErrorStopReason.and(object({
7421
+ stopReason: literal("error")
7422
+ })),
7423
+ excludeKnownTags(object({
7424
+ stopReason: string2()
7425
+ }), "stopReason", [
7426
+ "cancelled",
7427
+ "end_turn",
7428
+ "error",
7429
+ "max_tokens",
7430
+ "max_turn_requests",
7431
+ "refusal"
7432
+ ]),
7433
+ object({
7434
+ stopReason: _null3().optional()
7435
+ })
7436
+ ]), object({
7437
+ usage: defaultOnError(zUsage.nullish(), () => {
7438
+ return;
7439
+ }),
7440
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7441
+ return;
7442
+ }),
7443
+ stopReason: defaultOnError(string2().nullish(), () => {
7444
+ return;
7445
+ })
7446
+ })), "stopReason", [
7447
+ "cancelled",
7448
+ "end_turn",
7449
+ "error",
7450
+ "max_tokens",
7451
+ "max_turn_requests",
7452
+ "refusal"
7453
+ ]), "stopReason");
7454
+ var zRequiresActionStateUpdate = object({
7455
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7456
+ return;
7457
+ })
7458
+ });
7459
+ var zUnknownStateUpdate = object({
7460
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7461
+ return;
7462
+ })
7463
+ });
7464
+ var zStateUpdate = preserveCustomPayload(union([
7465
+ zRunningStateUpdate.and(object({
7466
+ state: literal("running")
7467
+ })),
7468
+ zIdleStateUpdate.and(object({
7469
+ state: literal("idle")
7470
+ })),
7471
+ zRequiresActionStateUpdate.and(object({
7472
+ state: literal("requires_action")
7473
+ })),
7474
+ zUnknownStateUpdate.and(object({
7475
+ state: literal("unknown")
7476
+ })),
7477
+ excludeKnownTags(object({
7478
+ state: string2()
7479
+ }), "state", ["idle", "requires_action", "running", "unknown"])
7480
+ ]), "state", ["idle", "requires_action", "running", "unknown"]);
7481
+ var zSubagentUpdate = object({
7482
+ sessionId: zSessionId,
7483
+ title: defaultOnError(string2().nullish(), () => {
7484
+ return;
7485
+ }),
7486
+ description: defaultOnError(string2().nullish(), () => {
7487
+ return;
7488
+ }),
7489
+ capabilities: defaultOnError(zSubagentSessionCapabilities.nullish(), () => {
7490
+ return;
7491
+ }),
7492
+ state: defaultOnError(zStateUpdate.nullish(), () => {
7493
+ return;
7494
+ }),
7495
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7496
+ return;
7497
+ })
7498
+ });
7499
+ var zSessionMessage = object({
7500
+ messageId: zMessageId,
7501
+ senderSessionId: defaultOnError(zSessionId.nullish(), () => {
7502
+ return;
7503
+ }),
7504
+ recipientSessionId: defaultOnError(zSessionId.nullish(), () => {
7505
+ return;
7506
+ }),
7507
+ content: defaultOnError(vecSkipError(zContentBlock).nullish(), () => {
7508
+ return;
7509
+ }),
7510
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7511
+ return;
7512
+ })
7513
+ });
7514
+ var zSessionMessageChunk = object({
7515
+ messageId: zMessageId,
7516
+ senderSessionId: defaultOnError(zSessionId.nullish(), () => {
7517
+ return;
7518
+ }),
7519
+ recipientSessionId: defaultOnError(zSessionId.nullish(), () => {
7520
+ return;
7521
+ }),
7522
+ content: zContentBlock,
7523
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7524
+ return;
7525
+ })
7526
+ });
7527
+ var zSessionUpdate = union([
7528
+ zContentChunk.and(object({
7529
+ sessionUpdate: literal("user_message_chunk")
7530
+ })),
7531
+ zContentChunk.and(object({
7532
+ sessionUpdate: literal("agent_message_chunk")
7533
+ })),
7534
+ zContentChunk.and(object({
7535
+ sessionUpdate: literal("agent_thought_chunk")
7536
+ })),
7537
+ zToolCall.and(object({
7538
+ sessionUpdate: literal("tool_call")
7539
+ })),
7540
+ zToolCallUpdate.and(object({
7576
7541
  sessionUpdate: literal("tool_call_update")
7577
7542
  })),
7578
7543
  zPlan.and(object({
@@ -7607,6 +7572,15 @@ var zSessionUpdate = union([
7607
7572
  })),
7608
7573
  zCompactionSummaryChunk.and(object({
7609
7574
  sessionUpdate: literal("compaction_summary_chunk")
7575
+ })),
7576
+ zSubagentUpdate.and(object({
7577
+ sessionUpdate: literal("subagent_update")
7578
+ })),
7579
+ zSessionMessage.and(object({
7580
+ sessionUpdate: literal("session_message")
7581
+ })),
7582
+ zSessionMessageChunk.and(object({
7583
+ sessionUpdate: literal("session_message_chunk")
7610
7584
  }))
7611
7585
  ]);
7612
7586
  var zSessionNotification = object({
@@ -7622,23 +7596,12 @@ var zCompleteElicitationNotification = object({
7622
7596
  return;
7623
7597
  })
7624
7598
  });
7625
- var zMessageMcpNotification = object({
7626
- connectionId: zMcpConnectionId,
7627
- method: string2(),
7628
- params: defaultOnError(record(string2(), unknown()).nullish(), () => {
7629
- return;
7630
- }),
7631
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7632
- return;
7633
- })
7634
- });
7635
7599
  var zExtNotification = unknown();
7636
7600
  var zAgentNotification = object({
7637
7601
  method: string2(),
7638
7602
  params: union([
7639
7603
  zSessionNotification,
7640
7604
  zCompleteElicitationNotification,
7641
- zMessageMcpNotification,
7642
7605
  zExtNotification
7643
7606
  ]).nullish()
7644
7607
  });
@@ -7678,6 +7641,11 @@ var zClientSessionCapabilities = object({
7678
7641
  return;
7679
7642
  })
7680
7643
  });
7644
+ var zSubagentCapabilities = object({
7645
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7646
+ return;
7647
+ })
7648
+ });
7681
7649
  var zPlanCapabilities = object({
7682
7650
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7683
7651
  return;
@@ -7710,41 +7678,15 @@ var zElicitationCapabilities = object({
7710
7678
  return;
7711
7679
  })
7712
7680
  });
7713
- var zNesJumpCapabilities = object({
7714
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7715
- return;
7716
- })
7717
- });
7718
- var zNesRenameCapabilities = object({
7719
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7720
- return;
7721
- })
7722
- });
7723
- var zNesSearchAndReplaceCapabilities = object({
7724
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7725
- return;
7726
- })
7727
- });
7728
- var zClientNesCapabilities = object({
7729
- jump: defaultOnError(zNesJumpCapabilities.nullish(), () => {
7730
- return;
7731
- }),
7732
- rename: defaultOnError(zNesRenameCapabilities.nullish(), () => {
7733
- return;
7734
- }),
7735
- searchAndReplace: defaultOnError(zNesSearchAndReplaceCapabilities.nullish(), () => {
7736
- return;
7737
- }),
7738
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7739
- return;
7740
- })
7741
- });
7742
7681
  var zClientCapabilities = object({
7743
7682
  fs: defaultOnError(zFileSystemCapabilities.optional().default({ readTextFile: false, writeTextFile: false }), () => ({ readTextFile: false, writeTextFile: false })),
7744
7683
  terminal: defaultOnError(boolean2().optional().default(false), () => false),
7745
7684
  session: defaultOnError(zClientSessionCapabilities.nullish(), () => {
7746
7685
  return;
7747
7686
  }),
7687
+ subagents: defaultOnError(zSubagentCapabilities.nullish(), () => {
7688
+ return;
7689
+ }),
7748
7690
  plan: defaultOnError(zPlanCapabilities.nullish(), () => {
7749
7691
  return;
7750
7692
  }),
@@ -7752,10 +7694,6 @@ var zClientCapabilities = object({
7752
7694
  elicitation: defaultOnError(zElicitationCapabilities.nullish(), () => {
7753
7695
  return;
7754
7696
  }),
7755
- nes: defaultOnError(zClientNesCapabilities.nullish(), () => {
7756
- return;
7757
- }),
7758
- positionEncodings: defaultOnError(vecSkipError(zPositionEncodingKind).optional(), () => []),
7759
7697
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7760
7698
  return;
7761
7699
  })
@@ -7860,19 +7798,33 @@ var zMcpServer = union([
7860
7798
  })),
7861
7799
  zMcpServerStdio
7862
7800
  ]);
7801
+ var zSystemPromptMode = union([
7802
+ literal("append"),
7803
+ literal("override"),
7804
+ string2()
7805
+ ]);
7806
+ var zSystemPrompt = object({
7807
+ mode: zSystemPromptMode,
7808
+ content: array(zContentBlock),
7809
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7810
+ return;
7811
+ })
7812
+ });
7863
7813
  var zNewSessionRequest = object({
7864
7814
  cwd: string2(),
7865
- additionalDirectories: defaultOnError(vecSkipError(string2()).optional(), () => []),
7866
- mcpServers: requiredDefaultOnError(vecSkipError(zMcpServer), () => []),
7815
+ additionalDirectories: array(string2()).optional(),
7816
+ mcpServers: array(zMcpServer),
7817
+ systemPrompt: zSystemPrompt.nullish(),
7867
7818
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7868
7819
  return;
7869
7820
  })
7870
7821
  });
7871
7822
  var zLoadSessionRequest = object({
7872
- mcpServers: requiredDefaultOnError(vecSkipError(zMcpServer), () => []),
7823
+ mcpServers: array(zMcpServer),
7873
7824
  cwd: string2(),
7874
- additionalDirectories: defaultOnError(vecSkipError(string2()).optional(), () => []),
7825
+ additionalDirectories: array(string2()).optional(),
7875
7826
  sessionId: zSessionId,
7827
+ systemPrompt: zSystemPrompt.nullish(),
7876
7828
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7877
7829
  return;
7878
7830
  })
@@ -7893,8 +7845,9 @@ var zDeleteSessionRequest = object({
7893
7845
  var zForkSessionRequest = object({
7894
7846
  sessionId: zSessionId,
7895
7847
  cwd: string2(),
7896
- additionalDirectories: defaultOnError(vecSkipError(string2()).optional(), () => []),
7897
- mcpServers: defaultOnError(vecSkipError(zMcpServer).optional(), () => []),
7848
+ additionalDirectories: array(string2()).optional(),
7849
+ mcpServers: array(zMcpServer).optional(),
7850
+ systemPrompt: zSystemPrompt.nullish(),
7898
7851
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7899
7852
  return;
7900
7853
  })
@@ -7902,8 +7855,9 @@ var zForkSessionRequest = object({
7902
7855
  var zResumeSessionRequest = object({
7903
7856
  sessionId: zSessionId,
7904
7857
  cwd: string2(),
7905
- additionalDirectories: defaultOnError(vecSkipError(string2()).optional(), () => []),
7906
- mcpServers: defaultOnError(vecSkipError(zMcpServer).optional(), () => []),
7858
+ additionalDirectories: array(string2()).optional(),
7859
+ mcpServers: array(zMcpServer).optional(),
7860
+ systemPrompt: zSystemPrompt.nullish(),
7907
7861
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7908
7862
  return;
7909
7863
  })
@@ -7943,138 +7897,6 @@ var zPromptRequest = object({
7943
7897
  return;
7944
7898
  })
7945
7899
  });
7946
- var zWorkspaceFolder = object({
7947
- uri: string2(),
7948
- name: string2(),
7949
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7950
- return;
7951
- })
7952
- });
7953
- var zNesRepository = object({
7954
- name: string2(),
7955
- owner: string2(),
7956
- remoteUrl: string2(),
7957
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7958
- return;
7959
- })
7960
- });
7961
- var zStartNesRequest = object({
7962
- workspaceUri: defaultOnError(string2().nullish(), () => {
7963
- return;
7964
- }),
7965
- workspaceFolders: array(zWorkspaceFolder).nullish(),
7966
- repository: defaultOnError(zNesRepository.nullish(), () => {
7967
- return;
7968
- }),
7969
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7970
- return;
7971
- })
7972
- });
7973
- var zNesTriggerKind = union([
7974
- literal("automatic"),
7975
- literal("diagnostic"),
7976
- literal("manual")
7977
- ]);
7978
- var zNesRecentFile = object({
7979
- uri: string2(),
7980
- languageId: string2(),
7981
- text: string2(),
7982
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7983
- return;
7984
- })
7985
- });
7986
- var zNesExcerpt = object({
7987
- startLine: int().gte(0).max(4294967295, {
7988
- error: "Invalid value: Expected uint32 to be <= 4294967295"
7989
- }),
7990
- endLine: int().gte(0).max(4294967295, {
7991
- error: "Invalid value: Expected uint32 to be <= 4294967295"
7992
- }),
7993
- text: string2(),
7994
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
7995
- return;
7996
- })
7997
- });
7998
- var zNesRelatedSnippet = object({
7999
- uri: string2(),
8000
- excerpts: array(zNesExcerpt),
8001
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
8002
- return;
8003
- })
8004
- });
8005
- var zNesEditHistoryEntry = object({
8006
- uri: string2(),
8007
- diff: string2(),
8008
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
8009
- return;
8010
- })
8011
- });
8012
- var zNesUserAction = object({
8013
- action: string2(),
8014
- uri: string2(),
8015
- position: zPosition,
8016
- timestampMs: number2(),
8017
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
8018
- return;
8019
- })
8020
- });
8021
- var zNesOpenFile = object({
8022
- uri: string2(),
8023
- languageId: string2(),
8024
- visibleRange: defaultOnError(zRange.nullish(), () => {
8025
- return;
8026
- }),
8027
- lastFocusedMs: defaultOnError(number2().nullish(), () => {
8028
- return;
8029
- }),
8030
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
8031
- return;
8032
- })
8033
- });
8034
- var zNesDiagnosticSeverity = union([
8035
- literal("error"),
8036
- literal("warning"),
8037
- literal("information"),
8038
- literal("hint")
8039
- ]);
8040
- var zNesDiagnostic = object({
8041
- uri: string2(),
8042
- range: zRange,
8043
- severity: zNesDiagnosticSeverity,
8044
- message: string2(),
8045
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
8046
- return;
8047
- })
8048
- });
8049
- var zNesSuggestContext = object({
8050
- recentFiles: array(zNesRecentFile).nullish(),
8051
- relatedSnippets: array(zNesRelatedSnippet).nullish(),
8052
- editHistory: array(zNesEditHistoryEntry).nullish(),
8053
- userActions: array(zNesUserAction).nullish(),
8054
- openFiles: array(zNesOpenFile).nullish(),
8055
- diagnostics: array(zNesDiagnostic).nullish(),
8056
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
8057
- return;
8058
- })
8059
- });
8060
- var zSuggestNesRequest = object({
8061
- sessionId: zSessionId,
8062
- uri: string2(),
8063
- version: number2(),
8064
- position: zPosition,
8065
- selection: zRange.nullish(),
8066
- triggerKind: zNesTriggerKind,
8067
- context: zNesSuggestContext.nullish(),
8068
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
8069
- return;
8070
- })
8071
- });
8072
- var zCloseNesRequest = object({
8073
- sessionId: zSessionId,
8074
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
8075
- return;
8076
- })
8077
- });
8078
7900
  var zClientRequest = object({
8079
7901
  id: zRequestId,
8080
7902
  method: string2(),
@@ -8095,10 +7917,6 @@ var zClientRequest = object({
8095
7917
  zSetSessionModeRequest,
8096
7918
  zSetSessionConfigOptionRequest,
8097
7919
  zPromptRequest,
8098
- zStartNesRequest,
8099
- zSuggestNesRequest,
8100
- zCloseNesRequest,
8101
- zMessageMcpRequest,
8102
7920
  zExtRequest
8103
7921
  ]).nullish()
8104
7922
  });
@@ -8213,134 +8031,69 @@ var zCreateElicitationResponse = preserveCustomPayload(intersection(union([
8213
8031
  return;
8214
8032
  })
8215
8033
  })), "action", ["accept", "cancel", "decline"]);
8216
- var zConnectMcpResponse = object({
8217
- connectionId: zMcpConnectionId,
8218
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
8219
- return;
8220
- })
8221
- });
8222
- var zDisconnectMcpResponse = object({
8223
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
8224
- return;
8225
- })
8226
- });
8227
- var zClientResponse = union([
8228
- object({
8229
- id: zRequestId,
8230
- result: union([
8231
- zWriteTextFileResponse,
8232
- zReadTextFileResponse,
8233
- zRequestPermissionResponse,
8234
- zCreateTerminalResponse,
8235
- zTerminalOutputResponse,
8236
- zReleaseTerminalResponse,
8237
- zWaitForTerminalExitResponse,
8238
- zKillTerminalResponse,
8239
- zCreateElicitationResponse,
8240
- zConnectMcpResponse,
8241
- zDisconnectMcpResponse,
8242
- zMessageMcpResponse,
8243
- zExtResponse
8244
- ])
8034
+ var zMcpError = looseObject({
8035
+ code: int().min(-2147483648, {
8036
+ error: "Invalid value: Expected int32 to be >= -2147483648"
8037
+ }).max(2147483647, {
8038
+ error: "Invalid value: Expected int32 to be <= 2147483647"
8245
8039
  }),
8246
- object({
8247
- id: zRequestId,
8248
- error: zError
8249
- })
8250
- ]);
8251
- var zCancelNotification = object({
8252
- sessionId: zSessionId,
8253
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
8254
- return;
8255
- })
8256
- });
8257
- var zDidOpenDocumentNotification = object({
8258
- sessionId: zSessionId,
8259
- uri: string2(),
8260
- languageId: string2(),
8261
- version: number2(),
8262
- text: string2(),
8263
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
8264
- return;
8265
- })
8266
- });
8267
- var zTextDocumentContentChangeEvent = object({
8268
- range: zRange.nullish(),
8269
- text: string2(),
8270
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
8271
- return;
8272
- })
8273
- });
8274
- var zDidChangeDocumentNotification = object({
8275
- sessionId: zSessionId,
8276
- uri: string2(),
8277
- version: number2(),
8278
- contentChanges: requiredDefaultOnError(vecSkipError(zTextDocumentContentChangeEvent), () => []),
8279
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
8280
- return;
8281
- })
8282
- });
8283
- var zDidCloseDocumentNotification = object({
8284
- sessionId: zSessionId,
8285
- uri: string2(),
8286
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
8287
- return;
8288
- })
8040
+ message: string2(),
8041
+ data: unknown().optional()
8289
8042
  });
8290
- var zDidSaveDocumentNotification = object({
8291
- sessionId: zSessionId,
8292
- uri: string2(),
8293
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
8294
- return;
8043
+ var zMessageMcpResponse = union([
8044
+ object({
8045
+ result: unknown(),
8046
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
8047
+ return;
8048
+ })
8049
+ }),
8050
+ object({
8051
+ error: zMcpError,
8052
+ _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
8053
+ return;
8054
+ })
8295
8055
  })
8296
- });
8297
- var zDidFocusDocumentNotification = object({
8298
- sessionId: zSessionId,
8299
- uri: string2(),
8300
- version: number2(),
8301
- position: zPosition,
8302
- visibleRange: zRange,
8303
- _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
8304
- return;
8056
+ ]);
8057
+ var zClientResponse = union([
8058
+ object({
8059
+ id: zRequestId,
8060
+ result: union([
8061
+ zWriteTextFileResponse,
8062
+ zReadTextFileResponse,
8063
+ zRequestPermissionResponse,
8064
+ zCreateTerminalResponse,
8065
+ zTerminalOutputResponse,
8066
+ zReleaseTerminalResponse,
8067
+ zWaitForTerminalExitResponse,
8068
+ zKillTerminalResponse,
8069
+ zCreateElicitationResponse,
8070
+ zMessageMcpResponse,
8071
+ zExtResponse
8072
+ ])
8073
+ }),
8074
+ object({
8075
+ id: zRequestId,
8076
+ error: zError
8305
8077
  })
8306
- });
8307
- var zAcceptNesNotification = object({
8078
+ ]);
8079
+ var zCancelNotification = object({
8308
8080
  sessionId: zSessionId,
8309
- id: zNesSuggestionId,
8310
8081
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
8311
8082
  return;
8312
8083
  })
8313
8084
  });
8314
- var zNesRejectReason = union([
8315
- literal("rejected"),
8316
- literal("ignored"),
8317
- literal("replaced"),
8318
- literal("cancelled")
8319
- ]);
8320
- var zRejectNesNotification = object({
8321
- sessionId: zSessionId,
8322
- id: zNesSuggestionId,
8323
- reason: defaultOnError(zNesRejectReason.nullish(), () => {
8324
- return;
8325
- }),
8085
+ var zMessageMcpNotification = object({
8086
+ serverId: zMcpServerAcpId,
8087
+ requestId: zMcpRequestId,
8088
+ method: string2(),
8089
+ params: record(string2(), unknown()).nullish(),
8326
8090
  _meta: defaultOnError(record(string2(), unknown()).nullish(), () => {
8327
8091
  return;
8328
8092
  })
8329
8093
  });
8330
8094
  var zClientNotification = object({
8331
8095
  method: string2(),
8332
- params: union([
8333
- zCancelNotification,
8334
- zDidOpenDocumentNotification,
8335
- zDidChangeDocumentNotification,
8336
- zDidCloseDocumentNotification,
8337
- zDidSaveDocumentNotification,
8338
- zDidFocusDocumentNotification,
8339
- zAcceptNesNotification,
8340
- zRejectNesNotification,
8341
- zMessageMcpNotification,
8342
- zExtNotification
8343
- ]).nullish()
8096
+ params: union([zCancelNotification, zMessageMcpNotification, zExtNotification]).nullish()
8344
8097
  });
8345
8098
  var zCancelRequestNotification = object({
8346
8099
  requestId: zRequestId,
@@ -9091,6 +8844,12 @@ class RequestError extends Error {
9091
8844
  static resourceNotFound(uri) {
9092
8845
  return new RequestError(-32002, `Resource not found${uri ? `: ${uri}` : ""}`, uri && { uri });
9093
8846
  }
8847
+ static unsupportedProtocolVersion(requested, supported) {
8848
+ return new RequestError(-32022, "Unsupported protocol version", {
8849
+ requested,
8850
+ supported: [...supported]
8851
+ });
8852
+ }
9094
8853
  toResult() {
9095
8854
  return {
9096
8855
  error: {
@@ -9344,6 +9103,27 @@ var zGuardElicitationPropertySchemaInteger = zIntegerPropertySchema.and(object({
9344
9103
  var zGuardElicitationPropertySchemaBoolean = zBooleanPropertySchema.and(object({ type: literal("boolean") }));
9345
9104
  var zGuardElicitationPropertySchemaArray = zMultiSelectPropertySchema.and(object({ type: literal("array") }));
9346
9105
  var zGuardMultiSelectItemsString = zStringMultiSelectItems.and(object({ type: literal("string") }));
9106
+ var zGuardStateUpdateRunning = zRunningStateUpdate.and(object({ state: literal("running") }));
9107
+ var zGuardStateUpdateIdle = zIdleStateUpdate.and(object({ usage: zUsage.nullish() })).and(object({ state: literal("idle") }));
9108
+ var zGuardStateUpdateRequiresAction = zRequiresActionStateUpdate.and(object({ state: literal("requires_action") }));
9109
+ var zGuardStateUpdateUnknown = zUnknownStateUpdate.and(object({ state: literal("unknown") }));
9110
+ var zGuardIdleStateUpdateEndTurn = object({
9111
+ stopReason: literal("end_turn")
9112
+ });
9113
+ var zGuardIdleStateUpdateMaxTokens = object({
9114
+ stopReason: literal("max_tokens")
9115
+ });
9116
+ var zGuardIdleStateUpdateMaxTurnRequests = object({
9117
+ stopReason: literal("max_turn_requests")
9118
+ });
9119
+ var zGuardIdleStateUpdateRefusal = object({
9120
+ stopReason: literal("refusal")
9121
+ });
9122
+ var zGuardIdleStateUpdateCancelled = object({
9123
+ stopReason: literal("cancelled")
9124
+ });
9125
+ var zGuardIdleStateUpdateError = zErrorStopReason.and(object({ error: zError.nullish() })).and(object({ stopReason: literal("error") }));
9126
+ var zGuardIdleStateUpdateNone = object({ stopReason: _null3().optional() });
9347
9127
  var zGuardCreateElicitationResponseAccept = zElicitationAcceptAction.and(object({ action: literal("accept") }));
9348
9128
  var zGuardCreateElicitationResponseDecline = object({
9349
9129
  action: literal("decline")
@@ -9397,20 +9177,6 @@ var methods = {
9397
9177
  setConfigOption: AGENT_METHODS.session_set_config_option,
9398
9178
  prompt: AGENT_METHODS.session_prompt,
9399
9179
  cancel: AGENT_METHODS.session_cancel
9400
- },
9401
- nes: {
9402
- start: AGENT_METHODS.nes_start,
9403
- suggest: AGENT_METHODS.nes_suggest,
9404
- accept: AGENT_METHODS.nes_accept,
9405
- reject: AGENT_METHODS.nes_reject,
9406
- close: AGENT_METHODS.nes_close
9407
- },
9408
- document: {
9409
- didOpen: AGENT_METHODS.document_did_open,
9410
- didChange: AGENT_METHODS.document_did_change,
9411
- didClose: AGENT_METHODS.document_did_close,
9412
- didSave: AGENT_METHODS.document_did_save,
9413
- didFocus: AGENT_METHODS.document_did_focus
9414
9180
  }
9415
9181
  },
9416
9182
  client: {
@@ -9779,7 +9545,11 @@ function parseParams(parser, params) {
9779
9545
  return parser.parse(params);
9780
9546
  }
9781
9547
  function requestSpec(method, params, mapResponse) {
9782
- return { method, params, mapResponse };
9548
+ return {
9549
+ method,
9550
+ params: (value) => parseParams(params, value ?? {}),
9551
+ mapResponse
9552
+ };
9783
9553
  }
9784
9554
  function notificationSpec(method, params) {
9785
9555
  return { method, params };
@@ -9816,20 +9586,10 @@ var agentRequestSpecs = {
9816
9586
  unstable_setProvider: requestSpec(AGENT_METHODS.providers_set, zSetProviderRequest, emptyObjectResponse),
9817
9587
  unstable_disableProvider: requestSpec(AGENT_METHODS.providers_disable, zDisableProviderRequest, emptyObjectResponse),
9818
9588
  logout: requestSpec(AGENT_METHODS.logout, zLogoutRequest, emptyObjectResponse),
9819
- prompt: requestSpec(AGENT_METHODS.session_prompt, zPromptRequest),
9820
- unstable_startNes: requestSpec(AGENT_METHODS.nes_start, zStartNesRequest),
9821
- unstable_suggestNes: requestSpec(AGENT_METHODS.nes_suggest, zSuggestNesRequest),
9822
- unstable_closeNes: requestSpec(AGENT_METHODS.nes_close, zCloseNesRequest, emptyObjectResponse)
9589
+ prompt: requestSpec(AGENT_METHODS.session_prompt, zPromptRequest)
9823
9590
  };
9824
9591
  var agentNotificationSpecs = {
9825
- cancel: notificationSpec(AGENT_METHODS.session_cancel, zCancelNotification),
9826
- unstable_didOpenDocument: notificationSpec(AGENT_METHODS.document_did_open, zDidOpenDocumentNotification),
9827
- unstable_didChangeDocument: notificationSpec(AGENT_METHODS.document_did_change, zDidChangeDocumentNotification),
9828
- unstable_didCloseDocument: notificationSpec(AGENT_METHODS.document_did_close, zDidCloseDocumentNotification),
9829
- unstable_didSaveDocument: notificationSpec(AGENT_METHODS.document_did_save, zDidSaveDocumentNotification),
9830
- unstable_didFocusDocument: notificationSpec(AGENT_METHODS.document_did_focus, zDidFocusDocumentNotification),
9831
- unstable_acceptNes: notificationSpec(AGENT_METHODS.nes_accept, zAcceptNesNotification),
9832
- unstable_rejectNes: notificationSpec(AGENT_METHODS.nes_reject, zRejectNesNotification)
9592
+ cancel: notificationSpec(AGENT_METHODS.session_cancel, zCancelNotification)
9833
9593
  };
9834
9594
  var clientRequestSpecs = {
9835
9595
  requestPermission: requestSpec(CLIENT_METHODS.session_request_permission, zRequestPermissionRequest),
@@ -10032,20 +9792,10 @@ var legacyAgentRequestMethods = new Set([
10032
9792
  AGENT_METHODS.session_fork,
10033
9793
  AGENT_METHODS.session_resume,
10034
9794
  AGENT_METHODS.session_close,
10035
- AGENT_METHODS.logout,
10036
- AGENT_METHODS.nes_start,
10037
- AGENT_METHODS.nes_suggest,
10038
- AGENT_METHODS.nes_close
9795
+ AGENT_METHODS.logout
10039
9796
  ]);
10040
9797
  var legacyAgentNotificationMethods = new Set([
10041
- AGENT_METHODS.session_cancel,
10042
- AGENT_METHODS.nes_accept,
10043
- AGENT_METHODS.nes_reject,
10044
- AGENT_METHODS.document_did_open,
10045
- AGENT_METHODS.document_did_change,
10046
- AGENT_METHODS.document_did_close,
10047
- AGENT_METHODS.document_did_save,
10048
- AGENT_METHODS.document_did_focus
9798
+ AGENT_METHODS.session_cancel
10049
9799
  ]);
10050
9800
  var legacyClientRequestMethods = new Set([
10051
9801
  CLIENT_METHODS.session_request_permission,
@@ -10068,6 +9818,8 @@ var ACP_SDK_REQUEST_TIMEOUT_MS = 120000;
10068
9818
  function createSdkStreamHandle(child) {
10069
9819
  const stdoutBridge = new import_node_stream.PassThrough;
10070
9820
  const stdinBridge = new import_node_stream.PassThrough;
9821
+ stdoutBridge.on("error", () => {});
9822
+ stdinBridge.on("error", () => {});
10071
9823
  child.stdout.pipe(stdoutBridge);
10072
9824
  stdinBridge.pipe(child.stdin, { end: false });
10073
9825
  const output = import_node_stream.Writable.toWeb(stdinBridge);
@@ -10095,11 +9847,11 @@ function createSdkStreamHandle(child) {
10095
9847
  }
10096
9848
  };
10097
9849
  }
10098
- function connectSdkClient(child, configure, runtimeId) {
9850
+ function connectSdkClient(child, configure, runtimeId, options = {}) {
10099
9851
  if (runtimeId && true) {
10100
9852
  console.info(`[acp:sdk] connect runtime=${runtimeId} pid=${child.pid ?? "?"}`);
10101
9853
  }
10102
- const app = client({ name: "inkdown" });
9854
+ const app = client({ name: options.name ?? "inkdown" });
10103
9855
  configure(app);
10104
9856
  const streamHandle = createSdkStreamHandle(child);
10105
9857
  const connection = app.connect(streamHandle.stream);
@@ -10129,7 +9881,7 @@ async function closeAcpSessions(agent, sessionIds, timeoutMs = 2000) {
10129
9881
  const failed = [];
10130
9882
  await Promise.all([...new Set(sessionIds)].map(async (sessionId) => {
10131
9883
  try {
10132
- await sdkRequest(agent, "session/close", { sessionId }, timeoutMs);
9884
+ await sdkRequest(agent, methods.agent.session.close, { sessionId }, timeoutMs);
10133
9885
  } catch {
10134
9886
  failed.push(sessionId);
10135
9887
  }
@@ -10565,11 +10317,24 @@ function parseRateLimitsFromStatusText(text, runtimeId = "unknown") {
10565
10317
  class QuotaCache {
10566
10318
  bySession = new Map;
10567
10319
  byRuntime = new Map;
10320
+ usageBySession = new Map;
10321
+ usageByRuntime = new Map;
10568
10322
  observe(params, defaultRuntimeId = "unknown") {
10569
10323
  if (!params || typeof params !== "object")
10570
10324
  return null;
10571
10325
  const p = params;
10572
10326
  const sessionId = typeof p.sessionId === "string" ? p.sessionId : undefined;
10327
+ if (p.update?.sessionUpdate === "usage_update") {
10328
+ const used = Number(p.update.used);
10329
+ const size = Number(p.update.size);
10330
+ if (Number.isFinite(used) && Number.isFinite(size) && size > 0) {
10331
+ const usage = { used, size, updatedAt: Date.now() };
10332
+ if (sessionId)
10333
+ this.usageBySession.set(sessionId, usage);
10334
+ this.usageByRuntime.set(defaultRuntimeId, usage);
10335
+ }
10336
+ return null;
10337
+ }
10573
10338
  let textToParse = "";
10574
10339
  if (p.update?.content && p.update.content.type === "text" && typeof p.update.content.text === "string") {
10575
10340
  textToParse = p.update.content.text;
@@ -10605,9 +10370,29 @@ class QuotaCache {
10605
10370
  }
10606
10371
  return;
10607
10372
  }
10373
+ applyContextUsage(quota, sessionId, runtimeId = "unknown") {
10374
+ const usage = (sessionId ? this.usageBySession.get(sessionId) : undefined) ?? this.usageByRuntime.get(runtimeId);
10375
+ if (!usage)
10376
+ return quota ?? null;
10377
+ const usedPercent = usage.size > 0 ? Math.min(100, Math.round(usage.used / usage.size * 100)) : 0;
10378
+ const window = {
10379
+ label: "Context",
10380
+ used: usage.used,
10381
+ total: usage.size,
10382
+ usedPercent,
10383
+ percentLeft: Math.max(0, 100 - usedPercent)
10384
+ };
10385
+ if (!quota) {
10386
+ return { runtimeId, primaryWindow: window, status: "ok", updatedAt: usage.updatedAt };
10387
+ }
10388
+ const rest = (quota.extraWindows ?? []).filter((item) => item.label !== "Context");
10389
+ return { ...quota, extraWindows: [window, ...rest] };
10390
+ }
10608
10391
  clear() {
10609
10392
  this.bySession.clear();
10610
10393
  this.byRuntime.clear();
10394
+ this.usageBySession.clear();
10395
+ this.usageByRuntime.clear();
10611
10396
  }
10612
10397
  }
10613
10398
 
@@ -11176,18 +10961,49 @@ function mergeOpenCodeAppConfig(raw, directory) {
11176
10961
  skills: { ...skills, paths: [...new Set([...skills.paths ?? [], import_node_path8.join(directory, "skills")])] }
11177
10962
  });
11178
10963
  }
10964
+ function resolveOpenCodeQuestionMode(version) {
10965
+ const normalized = version.trim().replace(/^opencode\s+v?/i, "");
10966
+ return ["1.18.35", "2.0.6"].includes(normalized) ? "fallback" : "unverified";
10967
+ }
10968
+ function mergeOpenCodeQuestionConfig(raw) {
10969
+ const value = raw?.trim() ? JSON.parse(raw) : {};
10970
+ if (!value || typeof value !== "object" || Array.isArray(value))
10971
+ throw new Error("invalid-opencode-config");
10972
+ const config = value;
10973
+ const permission = config.permission;
10974
+ if (permission !== undefined && (typeof permission !== "string" || !["allow", "ask", "deny"].includes(permission)) && (!permission || typeof permission !== "object" || Array.isArray(permission)))
10975
+ throw new Error("invalid-opencode-permission");
10976
+ const rules = typeof permission === "string" ? { "*": permission } : permission ?? {};
10977
+ return JSON.stringify({ ...config, permission: { ...rules, question: "deny" } });
10978
+ }
11179
10979
  async function prepareOpenCodeResources(input) {
11180
10980
  const prep = prepareCompatibilityResources(input.directory, "native-entry-not-verified");
11181
- if (!input.command || !readAppRulesText(input.directory))
10981
+ prep.report.openCodeQuestions = { mode: "unverified", configuration: "unchanged", reason: "version-not-verified" };
10982
+ if (!input.command)
11182
10983
  return prep;
11183
10984
  try {
11184
10985
  const { stdout } = await import_node_util.promisify(import_node_child_process2.execFile)(input.command, ["--version"], { env: input.env, timeout: 8000, windowsHide: true });
11185
- if (stdout.trim() !== "1.18.35")
10986
+ const version = stdout.trim().replace(/^opencode\s+v?/i, "");
10987
+ if (resolveOpenCodeQuestionMode(version) !== "fallback") {
10988
+ prep.report.openCodeQuestions.version = version;
11186
10989
  return prep;
11187
- const json = mergeOpenCodeAppConfig(input.env?.OPENCODE_CONFIG_CONTENT, input.directory);
11188
- return { env: { OPENCODE_CONFIG_CONTENT: json }, report: { ...prep.report, rulesPrepared: true, reason: undefined } };
10990
+ }
10991
+ let json = mergeOpenCodeQuestionConfig(input.env?.OPENCODE_CONFIG_CONTENT);
10992
+ const hasRules = version === "1.18.35" && !!readAppRulesText(input.directory);
10993
+ if (hasRules)
10994
+ json = mergeOpenCodeAppConfig(json, input.directory);
10995
+ return { env: { OPENCODE_CONFIG_CONTENT: json }, report: {
10996
+ ...prep.report,
10997
+ rulesPrepared: hasRules,
10998
+ reason: hasRules ? undefined : version === "2.0.6" ? "native-entry-not-verified" : "missing-app-rules",
10999
+ openCodeQuestions: { version, mode: "fallback", configuration: "prepared", reason: "acp-question-not-forwarded" }
11000
+ } };
11189
11001
  } catch {
11190
- return { ...prep, report: { ...prep.report, reason: "native-config-prepare-failed" } };
11002
+ return { ...prep, report: {
11003
+ ...prep.report,
11004
+ reason: "native-config-prepare-failed",
11005
+ openCodeQuestions: { mode: "unverified", configuration: "unchanged", reason: "prepare-failed" }
11006
+ } };
11191
11007
  }
11192
11008
  }
11193
11009
  function prepareClaudeResources(directory) {
@@ -11783,7 +11599,7 @@ var opencodeAdapter = {
11783
11599
  // src/runtimes/opencode-v2/index.ts
11784
11600
  var opencodeV2Adapter = {
11785
11601
  id: "opencode-v2",
11786
- prepareAppResources: async ({ directory }) => prepareCompatibilityResources(directory, "native-config-entry-not-verified"),
11602
+ prepareAppResources: prepareOpenCodeResources,
11787
11603
  probeAuth: () => probeOpencodeAuth(),
11788
11604
  orderAuthMethods: (methods) => methods,
11789
11605
  canSkipInteractiveAuth: () => false,
@@ -11991,14 +11807,326 @@ var cursorAdapter = {
11991
11807
  tryDirectSessionFirst: true
11992
11808
  };
11993
11809
 
11810
+ // src/runtimes/deepseek/index.ts
11811
+ var import_node_fs16 = require("node:fs");
11812
+
11813
+ // src/runtimes/deepseek/deepseek-provider.ts
11814
+ var import_node_fs14 = require("node:fs");
11815
+ var import_node_os11 = require("node:os");
11816
+ var import_node_path15 = require("node:path");
11817
+ var DEEPSEEK_OFFICIAL_BASE_URL = "https://api.deepseek.com/anthropic";
11818
+ function resolveDshHome(env = process.env) {
11819
+ const override = env.DSH_HOME?.trim();
11820
+ return override || import_node_path15.join(import_node_os11.homedir(), ".dsh");
11821
+ }
11822
+ function resolveDshCredentialsFile(env = process.env) {
11823
+ return import_node_path15.join(resolveDshHome(env), ".credentials.yaml");
11824
+ }
11825
+ function escapeRegExp(value) {
11826
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
11827
+ }
11828
+ function readHarnessCredential(name, env = process.env) {
11829
+ try {
11830
+ const text = import_node_fs14.readFileSync(resolveDshCredentialsFile(env), "utf8");
11831
+ const pattern = new RegExp(`^\\s+${escapeRegExp(name)}\\s*:\\s*(.+)$`);
11832
+ let inRefs = false;
11833
+ for (const line of text.split(/\r?\n/)) {
11834
+ if (/^refs\s*:/.test(line)) {
11835
+ inRefs = true;
11836
+ continue;
11837
+ }
11838
+ if (!inRefs)
11839
+ continue;
11840
+ if (/^\S/.test(line))
11841
+ break;
11842
+ const match = pattern.exec(line);
11843
+ if (match) {
11844
+ const value = match[1].trim().replace(/^['"]|['"]$/g, "");
11845
+ return value || null;
11846
+ }
11847
+ }
11848
+ return null;
11849
+ } catch {
11850
+ return null;
11851
+ }
11852
+ }
11853
+ function normalizeDeepseekBaseUrl(raw) {
11854
+ const trimmed = (raw ?? "").trim();
11855
+ if (!trimmed)
11856
+ return DEEPSEEK_OFFICIAL_BASE_URL;
11857
+ const withoutSlash = trimmed.replace(/\/+$/, "");
11858
+ try {
11859
+ const url = new URL(withoutSlash);
11860
+ if (url.host.toLowerCase() === "api.deepseek.com" && (url.pathname === "" || url.pathname === "/")) {
11861
+ return DEEPSEEK_OFFICIAL_BASE_URL;
11862
+ }
11863
+ return withoutSlash;
11864
+ } catch {
11865
+ return withoutSlash;
11866
+ }
11867
+ }
11868
+ function providerFilePath2(dir) {
11869
+ return import_node_path15.join(dir, "agent", "deepseek-provider.json");
11870
+ }
11871
+ function readStoredDeepseekProvider(dir = getDefaultAgentDataDir()) {
11872
+ const file = providerFilePath2(dir);
11873
+ if (!import_node_fs14.existsSync(file))
11874
+ return null;
11875
+ try {
11876
+ const raw = JSON.parse(import_node_fs14.readFileSync(file, "utf8"));
11877
+ if (typeof raw.baseUrl !== "string" || typeof raw.apiKey !== "string" || !raw.apiKey.trim()) {
11878
+ return null;
11879
+ }
11880
+ return { baseUrl: normalizeDeepseekBaseUrl(raw.baseUrl), apiKey: raw.apiKey };
11881
+ } catch {
11882
+ return null;
11883
+ }
11884
+ }
11885
+ function buildDeepseekProviderEnv(stored, currentEnv = process.env) {
11886
+ if (!stored)
11887
+ return {};
11888
+ const env = {};
11889
+ if (!currentEnv.DEEPSEEK_BASE_URL?.trim())
11890
+ env.DEEPSEEK_BASE_URL = stored.baseUrl;
11891
+ if (!currentEnv.DEEPSEEK_API_KEY?.trim())
11892
+ env.DEEPSEEK_API_KEY = stored.apiKey;
11893
+ return env;
11894
+ }
11895
+
11896
+ // src/runtimes/deepseek/dsh-acp-bootstrap.ts
11897
+ var import_node_fs15 = require("node:fs");
11898
+ var import_node_os12 = require("node:os");
11899
+ var import_node_path16 = require("node:path");
11900
+ var DSH_ACP_PINNED_VERSION = "0.2.1-rc.2";
11901
+ var DSH_ACP_DEFAULT_MODEL = "deepseek-flash";
11902
+ var DSH_ACP_DEFAULT_PROVIDER = "deepseek-official";
11903
+ function resolveDshRuntimeRoot(env = process.env) {
11904
+ const override = env.DSH_RUNTIME_DIR?.trim();
11905
+ if (override)
11906
+ return override;
11907
+ if (process.platform === "win32") {
11908
+ const localAppData = env.LOCALAPPDATA?.trim() || import_node_path16.join(import_node_os12.homedir(), "AppData", "Local");
11909
+ return import_node_path16.join(localAppData, "acp-dsh");
11910
+ }
11911
+ if (process.platform === "darwin") {
11912
+ return import_node_path16.join(import_node_os12.homedir(), "Library", "Application Support", "acp-dsh");
11913
+ }
11914
+ const dataHome = env.XDG_DATA_HOME?.trim() || import_node_path16.join(import_node_os12.homedir(), ".local", "share");
11915
+ return import_node_path16.join(dataHome, "acp-dsh");
11916
+ }
11917
+ function resolveManagedDshEntry(env = process.env, version = resolveManagedDshVersion(env)) {
11918
+ return import_node_path16.join(resolveDshRuntimeRoot(env), version, "node_modules", "@deepseek-ai", "dsh", "lib", "bin.js");
11919
+ }
11920
+ function parseVersion(value) {
11921
+ const match = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(value);
11922
+ if (!match)
11923
+ return null;
11924
+ return {
11925
+ nums: [Number(match[1]), Number(match[2]), Number(match[3])],
11926
+ pre: match[4] ? match[4].split(".") : []
11927
+ };
11928
+ }
11929
+ function compareDshVersions(a, b) {
11930
+ const left = parseVersion(a);
11931
+ const right = parseVersion(b);
11932
+ if (!left || !right)
11933
+ return a.localeCompare(b);
11934
+ for (let i = 0;i < 3; i += 1) {
11935
+ if (left.nums[i] !== right.nums[i])
11936
+ return left.nums[i] - right.nums[i];
11937
+ }
11938
+ if (left.pre.length === 0 && right.pre.length > 0)
11939
+ return 1;
11940
+ if (left.pre.length > 0 && right.pre.length === 0)
11941
+ return -1;
11942
+ for (let i = 0;i < Math.max(left.pre.length, right.pre.length); i += 1) {
11943
+ const x = left.pre[i];
11944
+ const y = right.pre[i];
11945
+ if (x === undefined)
11946
+ return -1;
11947
+ if (y === undefined)
11948
+ return 1;
11949
+ const nx = Number(x);
11950
+ const ny = Number(y);
11951
+ if (!Number.isNaN(nx) && !Number.isNaN(ny) && nx !== ny)
11952
+ return nx - ny;
11953
+ if (x !== y)
11954
+ return x < y ? -1 : 1;
11955
+ }
11956
+ return 0;
11957
+ }
11958
+ function hasManagedEntry(root, version) {
11959
+ return import_node_fs15.existsSync(import_node_path16.join(root, version, "node_modules", "@deepseek-ai", "dsh", "lib", "bin.js"));
11960
+ }
11961
+ function resolveManagedDshVersion(env = process.env) {
11962
+ const explicit = env.DSH_RUNTIME_VERSION?.trim();
11963
+ if (explicit)
11964
+ return explicit;
11965
+ const root = resolveDshRuntimeRoot(env);
11966
+ let best = null;
11967
+ try {
11968
+ for (const name of import_node_fs15.readdirSync(root)) {
11969
+ if (!parseVersion(name))
11970
+ continue;
11971
+ if (!hasManagedEntry(root, name))
11972
+ continue;
11973
+ if (best === null || compareDshVersions(name, best) > 0)
11974
+ best = name;
11975
+ }
11976
+ } catch {}
11977
+ return best ?? DSH_ACP_PINNED_VERSION;
11978
+ }
11979
+ function hasManagedDshRuntime(env = process.env) {
11980
+ return import_node_fs15.existsSync(resolveManagedDshEntry(env));
11981
+ }
11982
+ function safeId(raw, fallback) {
11983
+ const value = raw?.trim();
11984
+ return value && /^[A-Za-z0-9._-]+$/.test(value) ? value : fallback;
11985
+ }
11986
+ function resolveAcpModelOverride(env = process.env) {
11987
+ const flag = env.DSH_ACP_MODEL_PATCH?.trim().toLowerCase();
11988
+ if (flag === "off" || flag === "0" || flag === "false" || flag === "none")
11989
+ return null;
11990
+ return {
11991
+ provider: safeId(env.DSH_PROVIDER, DSH_ACP_DEFAULT_PROVIDER),
11992
+ model: safeId(env.DSH_MODEL, DSH_ACP_DEFAULT_MODEL)
11993
+ };
11994
+ }
11995
+ function buildAcpModelPatch(override) {
11996
+ return [
11997
+ "# 由 @yitom/acp-client 生成:修正 ACP 会话默认模型。",
11998
+ "# dsh-acp-app 自带补丁把 model 写死为 deepseek-v4-flash,该 id 不在 provider catalog 中;",
11999
+ "# V4.1-Flash 的 catalog id 是 deepseek-flash(桌面端 1017 只是 UI 徽标)。",
12000
+ "- id: acp",
12001
+ " name: '@deepseek-ai/dsh-acp'",
12002
+ " config:",
12003
+ ` provider: ${override.provider}`,
12004
+ ` model: ${override.model}`,
12005
+ ""
12006
+ ].join(`
12007
+ `);
12008
+ }
12009
+ var patchFileCache = new Map;
12010
+ function ensureAcpModelPatchFile(env = process.env) {
12011
+ const override = resolveAcpModelOverride(env);
12012
+ if (!override)
12013
+ return null;
12014
+ const key = `${override.provider}/${override.model}`;
12015
+ const cached = patchFileCache.get(key);
12016
+ if (cached !== undefined)
12017
+ return cached;
12018
+ try {
12019
+ const dir = import_node_path16.join(import_node_os12.tmpdir(), "acp-dsh-runtime");
12020
+ import_node_fs15.mkdirSync(dir, { recursive: true });
12021
+ const file = import_node_path16.join(dir, `acp-model-${override.provider}--${override.model}.patch.yml`);
12022
+ const body = buildAcpModelPatch(override);
12023
+ if (!import_node_fs15.existsSync(file) || import_node_fs15.readFileSync(file, "utf8") !== body) {
12024
+ import_node_fs15.writeFileSync(file, body, "utf8");
12025
+ }
12026
+ patchFileCache.set(key, file);
12027
+ return file;
12028
+ } catch {
12029
+ patchFileCache.set(key, null);
12030
+ return null;
12031
+ }
12032
+ }
12033
+
12034
+ // src/runtimes/deepseek/quota.ts
12035
+ var DEFAULT_TIMEOUT_MS = 4000;
12036
+ function resolveDeepseekQuotaKey(options = {}) {
12037
+ const env = options.env ?? process.env;
12038
+ const envKey = env.DEEPSEEK_API_KEY?.trim();
12039
+ if (envKey)
12040
+ return envKey;
12041
+ if (options.dataDir) {
12042
+ const stored = readStoredDeepseekProvider(options.dataDir);
12043
+ if (stored?.apiKey)
12044
+ return stored.apiKey;
12045
+ }
12046
+ return readHarnessCredential("DEEPSEEK_API_KEY", env);
12047
+ }
12048
+ function resolveDeepseekApiBase(options = {}) {
12049
+ const env = options.env ?? process.env;
12050
+ const raw = env.DEEPSEEK_BASE_URL?.trim() || (options.dataDir ? readStoredDeepseekProvider(options.dataDir)?.baseUrl : undefined) || DEEPSEEK_OFFICIAL_BASE_URL;
12051
+ const trimmed = raw.replace(/\/+$/, "").replace(/\/anthropic$/i, "");
12052
+ return trimmed || "https://api.deepseek.com";
12053
+ }
12054
+ function unauthorized(runtimeId, message) {
12055
+ return { runtimeId, provider: "DeepSeek", status: "unauthorized", message, updatedAt: Date.now() };
12056
+ }
12057
+ async function probeDeepseekQuota(options = {}) {
12058
+ const runtimeId = options.runtimeId ?? "deepseek";
12059
+ const apiKey = resolveDeepseekQuotaKey(options);
12060
+ if (!apiKey) {
12061
+ return unauthorized(runtimeId, "未配置 DEEPSEEK_API_KEY / 表单 Token,无法查询余额");
12062
+ }
12063
+ const doFetch = options.fetchImpl ?? fetch;
12064
+ try {
12065
+ const response = await doFetch(`${resolveDeepseekApiBase(options)}/user/balance`, {
12066
+ headers: { Authorization: `Bearer ${apiKey}`, Accept: "application/json" },
12067
+ signal: AbortSignal.timeout(options.timeoutMs ?? DEFAULT_TIMEOUT_MS)
12068
+ });
12069
+ if (response.status === 401 || response.status === 403) {
12070
+ return unauthorized(runtimeId, `余额查询被拒绝 (HTTP ${response.status})`);
12071
+ }
12072
+ if (!response.ok)
12073
+ return null;
12074
+ const data = await response.json();
12075
+ const infos = Array.isArray(data.balance_infos) ? data.balance_infos : [];
12076
+ const first = infos[0];
12077
+ const total = first ? Number(first.total_balance) : Number.NaN;
12078
+ const credits = first ? {
12079
+ balance: Number.isFinite(total) ? total : first.total_balance ?? "0",
12080
+ currency: first.currency
12081
+ } : undefined;
12082
+ const balanceText = infos.map((info) => `${info.total_balance ?? "0"} ${info.currency ?? ""}`.trim()).join(" / ");
12083
+ return {
12084
+ runtimeId,
12085
+ provider: "DeepSeek",
12086
+ account: { type: "apiKey", plan: "DeepSeek API" },
12087
+ credits,
12088
+ status: data.is_available === false ? "exhausted" : "ok",
12089
+ message: data.is_available === false ? "账户余额不足,API 暂不可用" : `可用余额 ${balanceText || "未知"}`,
12090
+ rawText: JSON.stringify(data),
12091
+ updatedAt: Date.now()
12092
+ };
12093
+ } catch {
12094
+ return null;
12095
+ }
12096
+ }
12097
+
11994
12098
  // src/runtimes/deepseek/index.ts
11995
12099
  function buildDeepseekMissingKeyMessage() {
11996
- return "未检测到 DEEPSEEK_API_KEY:请先在终端导出该变量(或完成 harness 自身登录)后再连接";
12100
+ return "未检测到 DEEPSEEK_API_KEY,也未在 harness 凭证库中找到登录记录:请先在终端导出该变量,或先在该 harness(dsh)里完成登录后再连接";
11997
12101
  }
11998
- function resolveDeepseekSpawnBlocker(env) {
12102
+ function hasDshCredentials(env) {
12103
+ try {
12104
+ const text = import_node_fs16.readFileSync(resolveDshCredentialsFile(env), "utf8");
12105
+ const match = /^records\s*:(.*)$/m.exec(text);
12106
+ if (!match)
12107
+ return false;
12108
+ if (/^\s*(\[\]|\{\}|null|~)\s*$/.test(match[1]))
12109
+ return false;
12110
+ for (const line of text.slice(match.index + match[0].length).split(/\r?\n/)) {
12111
+ if (!line.trim() || line.trim().startsWith("#"))
12112
+ continue;
12113
+ if (/^\s+\S/.test(line))
12114
+ return true;
12115
+ return false;
12116
+ }
12117
+ return false;
12118
+ } catch {
12119
+ return false;
12120
+ }
12121
+ }
12122
+ function resolveDeepseekSpawnBlocker(env, dataDir) {
11999
12123
  const source = env ?? process.env;
12000
12124
  if (source.DEEPSEEK_API_KEY?.trim())
12001
12125
  return null;
12126
+ if (dataDir && readStoredDeepseekProvider(dataDir))
12127
+ return null;
12128
+ if (hasDshCredentials(source))
12129
+ return null;
12002
12130
  return buildDeepseekMissingKeyMessage();
12003
12131
  }
12004
12132
  function resolveDeepseekPackage(env) {
@@ -12014,39 +12142,86 @@ function resolveDeepseekPackage(env) {
12014
12142
  }
12015
12143
  return raw;
12016
12144
  }
12145
+ var UNSAFE_BIN = /[\u0000-\u001f;&|$()`"'<>*?~#!]/;
12146
+ function resolveDeepseekBin(env) {
12147
+ const raw = (env ?? process.env).DSH_BIN?.trim();
12148
+ if (!raw)
12149
+ return null;
12150
+ if (UNSAFE_BIN.test(raw)) {
12151
+ if (true) {
12152
+ console.warn(`[acp:deepseek] 非法 DSH_BIN 回落包解析: ${raw}`);
12153
+ }
12154
+ return null;
12155
+ }
12156
+ return raw;
12157
+ }
12017
12158
  function resolveDeepseekSpawnCommand(env) {
12018
- const pkg = resolveDeepseekPackage(env);
12159
+ const source = env ?? process.env;
12160
+ const patchFile = ensureAcpModelPatchFile(source);
12161
+ const withPatch = (args) => patchFile ? [...args, "--patch", patchFile] : args;
12162
+ const bin = resolveDeepseekBin(source);
12163
+ if (bin) {
12164
+ const args = ["--profile", "acp"];
12165
+ if (/\.(c|m)?js$/i.test(bin))
12166
+ return { command: process.execPath, args: withPatch([bin, ...args]) };
12167
+ const looksAbsolute = /^([A-Za-z]:[\\/]|\\\\|\/)/.test(bin);
12168
+ if (/\.(cmd|bat)$/i.test(bin) && /\s/.test(bin)) {
12169
+ if (true) {
12170
+ console.warn(`[acp:deepseek] DSH_BIN 为含空格的批处理,回落包解析: ${bin}`);
12171
+ }
12172
+ } else if (!looksAbsolute || import_node_fs16.existsSync(bin)) {
12173
+ return { command: bin, args: withPatch(args) };
12174
+ } else if (true) {
12175
+ console.warn(`[acp:deepseek] DSH_BIN 不存在,回落包解析: ${bin}`);
12176
+ }
12177
+ }
12178
+ if (hasManagedDshRuntime(source)) {
12179
+ const entry = resolveManagedDshEntry(source);
12180
+ return { command: process.execPath, args: withPatch([entry, "--profile", "acp"]) };
12181
+ }
12182
+ const pkg = resolveDeepseekPackage(source);
12019
12183
  const spec = pkg === DEEPSEEK_DSH_NPM_PACKAGE ? `${pkg}@latest` : pkg;
12020
- return { command: "bunx", args: ["-y", spec, "--profile", "acp"] };
12184
+ return { command: "bunx", args: withPatch(["-y", spec, "--profile", "acp"]) };
12021
12185
  }
12022
- function probeDeepseekAuth() {
12023
- const hasApiKeyEnv = Boolean(process.env.DEEPSEEK_API_KEY?.trim());
12186
+ function probeDeepseekAuth(env, dataDir) {
12187
+ const source = env ?? process.env;
12188
+ const hasApiKeyEnv = Boolean(source.DEEPSEEK_API_KEY?.trim());
12189
+ const dshHome = resolveDshHome(source);
12190
+ const hasCredentialsFile = import_node_fs16.existsSync(resolveDshCredentialsFile(source));
12191
+ const hasCredentialRecords = hasDshCredentials(source);
12192
+ const hasStoredProvider = Boolean(dataDir && readStoredDeepseekProvider(dataDir));
12024
12193
  return {
12025
- codexHome: "",
12026
- hasCodexHome: false,
12027
- hasAuthFile: false,
12028
- hasApiKeyEnv,
12029
- looksLoggedIn: hasApiKeyEnv
12194
+ codexHome: dshHome,
12195
+ hasCodexHome: import_node_fs16.existsSync(dshHome),
12196
+ hasAuthFile: hasCredentialsFile,
12197
+ hasApiKeyEnv: hasApiKeyEnv || hasStoredProvider,
12198
+ looksLoggedIn: hasApiKeyEnv || hasStoredProvider || hasCredentialRecords
12030
12199
  };
12031
12200
  }
12032
12201
  var deepseekAdapter = {
12033
12202
  id: "deepseek",
12034
12203
  prepareAppResources: async ({ directory }) => prepareCompatibilityResources(directory, "native-config-entry-not-verified"),
12035
- probeAuth: () => probeDeepseekAuth(),
12204
+ probeAuth: (context) => probeDeepseekAuth(context?.env, context?.dataDir),
12036
12205
  resolveSpawnCommand: () => resolveDeepseekSpawnCommand(),
12037
- resolveSpawnBlocker: () => resolveDeepseekSpawnBlocker(),
12206
+ resolveSpawnBlocker: (context) => resolveDeepseekSpawnBlocker(context?.env, context?.dataDir),
12207
+ getProviderEnv: ({ dataDir, env }) => buildDeepseekProviderEnv(readStoredDeepseekProvider(dataDir), env),
12208
+ probeQuota: (options) => probeDeepseekQuota({
12209
+ runtimeId: "deepseek",
12210
+ dataDir: options?.dataDir,
12211
+ env: options?.env
12212
+ }),
12038
12213
  orderAuthMethods: (methods) => methods,
12039
12214
  canSkipInteractiveAuth: () => false
12040
12215
  };
12041
12216
 
12042
12217
  // src/runtimes/agy/quota.ts
12043
- var import_node_fs14 = require("node:fs");
12044
- var import_node_path15 = require("node:path");
12218
+ var import_node_fs17 = require("node:fs");
12219
+ var import_node_path17 = require("node:path");
12045
12220
  var import_node_child_process5 = require("node:child_process");
12046
12221
  var os2 = __toESM(require("node:os"), 1);
12047
12222
  function resolveGeminiHome2() {
12048
12223
  const home = process.env.USERPROFILE || process.env.HOME || "";
12049
- return import_node_path15.join(home, ".gemini");
12224
+ return import_node_path17.join(home, ".gemini");
12050
12225
  }
12051
12226
  function resolveAntigravityAccount() {
12052
12227
  if (process.env.GOOGLE_ACCOUNT?.trim()) {
@@ -12059,14 +12234,14 @@ function resolveAntigravityAccount() {
12059
12234
  }
12060
12235
  const home = process.env.USERPROFILE || process.env.HOME || os2.homedir() || "";
12061
12236
  const candidates = [
12062
- process.env.APPDATA ? import_node_path15.join(process.env.APPDATA, "Antigravity", "app_storage.json") : null,
12063
- import_node_path15.join(home, ".config", "Antigravity", "app_storage.json"),
12064
- import_node_path15.join(home, "Library", "Application Support", "Antigravity", "app_storage.json")
12237
+ process.env.APPDATA ? import_node_path17.join(process.env.APPDATA, "Antigravity", "app_storage.json") : null,
12238
+ import_node_path17.join(home, ".config", "Antigravity", "app_storage.json"),
12239
+ import_node_path17.join(home, "Library", "Application Support", "Antigravity", "app_storage.json")
12065
12240
  ].filter(Boolean);
12066
12241
  for (const file of candidates) {
12067
12242
  try {
12068
- if (import_node_fs14.existsSync(file)) {
12069
- const raw = import_node_fs14.readFileSync(file, "utf8");
12243
+ if (import_node_fs17.existsSync(file)) {
12244
+ const raw = import_node_fs17.readFileSync(file, "utf8");
12070
12245
  const json = JSON.parse(raw);
12071
12246
  const username = json["jetski.onboarding.lastLoginUsername"];
12072
12247
  if (username && typeof username === "string" && username.trim()) {
@@ -12087,30 +12262,30 @@ function resolveAntigravityAccount() {
12087
12262
  }
12088
12263
  function resolveAntigravityLanguageServer() {
12089
12264
  const home = process.env.USERPROFILE || process.env.HOME || os2.homedir() || "";
12090
- const appData = process.env.APPDATA || (process.platform === "win32" ? import_node_path15.join(home, "AppData", "Roaming") : "");
12265
+ const appData = process.env.APPDATA || (process.platform === "win32" ? import_node_path17.join(home, "AppData", "Roaming") : "");
12091
12266
  const baseDirs = [
12092
- appData ? import_node_path15.join(appData, "Antigravity IDE", "logs") : null,
12093
- appData ? import_node_path15.join(appData, "Antigravity", "logs") : null,
12094
- import_node_path15.join(home, ".config", "Antigravity IDE", "logs"),
12095
- import_node_path15.join(home, ".config", "Antigravity", "logs"),
12096
- import_node_path15.join(home, "Library", "Application Support", "Antigravity IDE", "logs"),
12097
- import_node_path15.join(home, "Library", "Application Support", "Antigravity", "logs")
12267
+ appData ? import_node_path17.join(appData, "Antigravity IDE", "logs") : null,
12268
+ appData ? import_node_path17.join(appData, "Antigravity", "logs") : null,
12269
+ import_node_path17.join(home, ".config", "Antigravity IDE", "logs"),
12270
+ import_node_path17.join(home, ".config", "Antigravity", "logs"),
12271
+ import_node_path17.join(home, "Library", "Application Support", "Antigravity IDE", "logs"),
12272
+ import_node_path17.join(home, "Library", "Application Support", "Antigravity", "logs")
12098
12273
  ].filter(Boolean);
12099
12274
  for (const base of baseDirs) {
12100
12275
  try {
12101
- if (!import_node_fs14.existsSync(base))
12276
+ if (!import_node_fs17.existsSync(base))
12102
12277
  continue;
12103
- const sessionDirs = import_node_fs14.readdirSync(base).map((d) => {
12278
+ const sessionDirs = import_node_fs17.readdirSync(base).map((d) => {
12104
12279
  try {
12105
- return { name: d, time: import_node_fs14.statSync(import_node_path15.join(base, d)).mtimeMs };
12280
+ return { name: d, time: import_node_fs17.statSync(import_node_path17.join(base, d)).mtimeMs };
12106
12281
  } catch {
12107
12282
  return null;
12108
12283
  }
12109
12284
  }).filter((d) => Boolean(d)).sort((a, b) => b.time - a.time);
12110
12285
  for (const s of sessionDirs) {
12111
- const logFile = import_node_path15.join(base, s.name, "ls-main.log");
12112
- if (import_node_fs14.existsSync(logFile)) {
12113
- const content = import_node_fs14.readFileSync(logFile, "utf8");
12286
+ const logFile = import_node_path17.join(base, s.name, "ls-main.log");
12287
+ if (import_node_fs17.existsSync(logFile)) {
12288
+ const content = import_node_fs17.readFileSync(logFile, "utf8");
12114
12289
  const csrfMatch = content.match(/--csrf_token\s+([a-f0-9\-]+)/);
12115
12290
  const portMatch = content.match(/LS started on port\s+(\d+)/) || content.match(/--https_server_port\s+(\d+)/);
12116
12291
  if (csrfMatch && portMatch) {
@@ -12267,7 +12442,7 @@ async function probeAgyQuota(options) {
12267
12442
  } catch {}
12268
12443
  }
12269
12444
  const geminiHome = resolveGeminiHome2();
12270
- const hasAgyDir = import_node_fs14.existsSync(import_node_path15.join(geminiHome, "antigravity")) || import_node_fs14.existsSync(import_node_path15.join(geminiHome, "antigravity-cli"));
12445
+ const hasAgyDir = import_node_fs17.existsSync(import_node_path17.join(geminiHome, "antigravity")) || import_node_fs17.existsSync(import_node_path17.join(geminiHome, "antigravity-cli"));
12271
12446
  const hasApiKey = Boolean(process.env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY);
12272
12447
  const isAvailable = hasAgyDir || hasApiKey || Boolean(acc.email || acc.name);
12273
12448
  if (!isAvailable) {
@@ -12548,17 +12723,17 @@ function tryReuseLiveAcpProcess(runtimeId, query = {}) {
12548
12723
 
12549
12724
  // src/client/acp-fs.ts
12550
12725
  var import_promises4 = require("node:fs/promises");
12551
- var import_node_path16 = require("node:path");
12726
+ var import_node_path18 = require("node:path");
12552
12727
  var import_promises5 = require("node:fs/promises");
12553
12728
  var MAX_READ_BYTES = 2 * 1024 * 1024;
12554
12729
  var BINARY_DOCUMENT_EXTENSIONS = new Set([".epub", ".mobi", ".azw", ".azw3", ".pdf"]);
12555
12730
  function isBinaryDocumentPath(filePath) {
12556
- return BINARY_DOCUMENT_EXTENSIONS.has(import_node_path16.extname(filePath).toLowerCase());
12731
+ return BINARY_DOCUMENT_EXTENSIONS.has(import_node_path18.extname(filePath).toLowerCase());
12557
12732
  }
12558
12733
  function assertPathInsideWorkspace(filePath, workspaceRoot) {
12559
- const root = import_node_path16.resolve(workspaceRoot);
12560
- const target = import_node_path16.resolve(filePath);
12561
- const rootWithSep = root.endsWith(import_node_path16.sep) ? root : root + import_node_path16.sep;
12734
+ const root = import_node_path18.resolve(workspaceRoot);
12735
+ const target = import_node_path18.resolve(filePath);
12736
+ const rootWithSep = root.endsWith(import_node_path18.sep) ? root : root + import_node_path18.sep;
12562
12737
  if (target !== root && !target.startsWith(rootWithSep)) {
12563
12738
  throw new Error(`路径不在工作区内: ${filePath}`);
12564
12739
  }
@@ -12589,7 +12764,7 @@ async function acpReadTextFile(params) {
12589
12764
  }
12590
12765
  async function acpWriteTextFile(params) {
12591
12766
  const abs = assertPathInsideWorkspace(params.path, params.workspaceRoot);
12592
- await import_promises5.mkdir(import_node_path16.dirname(abs), { recursive: true });
12767
+ await import_promises5.mkdir(import_node_path18.dirname(abs), { recursive: true });
12593
12768
  await import_promises4.writeFile(abs, params.content, "utf-8");
12594
12769
  return {};
12595
12770
  }
@@ -12760,6 +12935,16 @@ function coerceOptionValue(raw) {
12760
12935
  return String(raw);
12761
12936
  if (typeof raw === "boolean")
12762
12937
  return String(raw);
12938
+ if (raw !== null && typeof raw === "object") {
12939
+ if (!Array.isArray(raw) && Object.keys(raw).length === 0)
12940
+ return null;
12941
+ try {
12942
+ const encoded = JSON.stringify(raw);
12943
+ return encoded && encoded !== "null" ? encoded : null;
12944
+ } catch {
12945
+ return null;
12946
+ }
12947
+ }
12763
12948
  return null;
12764
12949
  }
12765
12950
  function coerceCurrentValue(raw) {
@@ -12769,8 +12954,41 @@ function coerceCurrentValue(raw) {
12769
12954
  return raw;
12770
12955
  if (typeof raw === "number" && Number.isFinite(raw))
12771
12956
  return String(raw);
12957
+ if (raw !== null && typeof raw === "object") {
12958
+ if (!Array.isArray(raw) && Object.keys(raw).length === 0)
12959
+ return;
12960
+ try {
12961
+ const encoded = JSON.stringify(raw);
12962
+ return encoded && encoded !== "null" ? encoded : undefined;
12963
+ } catch {
12964
+ return;
12965
+ }
12966
+ }
12772
12967
  return;
12773
12968
  }
12969
+ function collectOptionValues(rows, group, out) {
12970
+ for (const opt of rows) {
12971
+ if (!opt || typeof opt !== "object")
12972
+ continue;
12973
+ const o = opt;
12974
+ const nested = Array.isArray(o.options) ? o.options : null;
12975
+ const label = typeof o.group === "string" && o.group ? o.group : group;
12976
+ if (nested && nested.length > 0) {
12977
+ const fallbackName = typeof o.name === "string" && o.name ? o.name : undefined;
12978
+ collectOptionValues(nested, label ?? fallbackName, out);
12979
+ continue;
12980
+ }
12981
+ const value = coerceOptionValue(o.value) ?? coerceOptionValue(o.id);
12982
+ if (!value)
12983
+ continue;
12984
+ out.push({
12985
+ value,
12986
+ name: typeof o.name === "string" ? o.name : String(value),
12987
+ ...typeof o.description === "string" ? { description: o.description } : {},
12988
+ ...label ? { group: label } : {}
12989
+ });
12990
+ }
12991
+ }
12774
12992
  function parseAcpConfigOptions(raw) {
12775
12993
  if (!Array.isArray(raw))
12776
12994
  return [];
@@ -12785,21 +13003,8 @@ function parseAcpConfigOptions(raw) {
12785
13003
  const name = typeof row.name === "string" ? row.name : configId;
12786
13004
  const type = typeof row.type === "string" ? row.type : "select";
12787
13005
  const values = [];
12788
- if (Array.isArray(row.options)) {
12789
- for (const opt of row.options) {
12790
- if (!opt || typeof opt !== "object")
12791
- continue;
12792
- const o = opt;
12793
- const value = coerceOptionValue(o.value) ?? coerceOptionValue(o.id);
12794
- if (!value)
12795
- continue;
12796
- values.push({
12797
- value,
12798
- name: typeof o.name === "string" ? o.name : String(value),
12799
- description: typeof o.description === "string" ? o.description : undefined
12800
- });
12801
- }
12802
- }
13006
+ if (Array.isArray(row.options))
13007
+ collectOptionValues(row.options, undefined, values);
12803
13008
  options.push({
12804
13009
  configId,
12805
13010
  name,
@@ -12915,29 +13120,30 @@ function isTransientAcpTransportError(error) {
12915
13120
  return /ACP connection closed|connection closed|closed|abort|超时|timeout|timed out|econnreset|epipe|stdio|stream/i.test(message);
12916
13121
  }
12917
13122
  async function restoreOrCreateAcpSession(input) {
12918
- const resumeId = input.resumeSessionId?.trim() || null;
12919
- const restoreAttempts = [];
12920
13123
  let mcpServersAccepted = (input.mcpServers ?? []).length > 0;
12921
13124
  let nativeSessionAccepted = false;
13125
+ let recoveredToolOutputs;
12922
13126
  const request = async (method, params) => {
12923
- if (!input.sessionMeta)
12924
- return input.request(method, params);
12925
- try {
12926
- const result = await input.request(method, { ...params, _meta: input.sessionMeta });
12927
- nativeSessionAccepted = true;
12928
- return result;
12929
- } catch (error) {
12930
- const rejected = error instanceof RequestError && error.code === -32602 || /native.*meta.*reject|unsupported.*(meta|systemPrompt)|unknown.*(meta|systemPrompt)/i.test(errorMessage(error));
12931
- if (!rejected || isTransientAcpTransportError(error))
12932
- throw error;
12933
- log("warn", "native resource options failed; retry without extension");
12934
- const result = await input.request(method, params);
12935
- nativeSessionAccepted = false;
12936
- return result;
12937
- }
13127
+ const opened = await requestSessionWithResources(input.request, method, params, input.sessionMeta);
13128
+ nativeSessionAccepted = opened.nativeSessionAccepted;
13129
+ const meta = opened.result._meta;
13130
+ const outputs = meta?.toolOutputRecovery?.outputs;
13131
+ let total = 0;
13132
+ recoveredToolOutputs = Array.isArray(outputs) ? outputs.slice(0, 20).filter((row) => {
13133
+ if (!row || typeof row.toolCallId !== "string" || row.toolCallId.length > 120 || typeof row.text !== "string")
13134
+ return false;
13135
+ const bytes = Buffer.byteLength(row.text);
13136
+ if (bytes > 128 * 1024 || total + bytes > 256 * 1024)
13137
+ return false;
13138
+ total += bytes;
13139
+ return true;
13140
+ }) : undefined;
13141
+ return opened.result;
12938
13142
  };
13143
+ const resumeId = input.resumeSessionId?.trim() || null;
13144
+ const restoreAttempts = [];
12939
13145
  const delayMs = input.retryDelayMs ?? 250;
12940
- const log = input.log ?? ((level, message, data) => {
13146
+ const outputLog = input.log ?? ((level, message, data) => {
12941
13147
  if (level === "info" && false)
12942
13148
  ;
12943
13149
  const line = `[acp] ${message}`;
@@ -12946,6 +13152,7 @@ async function restoreOrCreateAcpSession(input) {
12946
13152
  else
12947
13153
  console.info(line, data ?? "");
12948
13154
  });
13155
+ const log = outputLog;
12949
13156
  const tryRestoreMethod = async (method, rpcMethod) => {
12950
13157
  const maxTries = 2;
12951
13158
  let lastError = "";
@@ -12996,19 +13203,17 @@ async function restoreOrCreateAcpSession(input) {
12996
13203
  mcpServers: input.mcpServers ?? []
12997
13204
  };
12998
13205
  try {
12999
- return await request("session/new", baseParams);
13206
+ return await request(methods.agent.session.new, baseParams);
13000
13207
  } catch (firstError) {
13001
13208
  if ((input.mcpServers ?? []).length === 0)
13002
13209
  throw firstError;
13003
- log("warn", "session/new failed, retry without mcpServers", {
13210
+ log("warn", input.preserveMcpOnRetry ? "session/new failed, retry with mcpServers" : "session/new failed, retry without mcpServers", {
13004
13211
  error: errorMessage(firstError)
13005
13212
  });
13006
13213
  try {
13007
- const result = await request("session/new", {
13008
- cwd: input.cwd,
13009
- mcpServers: []
13010
- });
13011
- mcpServersAccepted = false;
13214
+ const retryServers = input.preserveMcpOnRetry ? input.mcpServers ?? [] : [];
13215
+ const result = await request(methods.agent.session.new, { cwd: input.cwd, mcpServers: retryServers });
13216
+ mcpServersAccepted = retryServers.length > 0;
13012
13217
  return result;
13013
13218
  } catch {
13014
13219
  throw firstError;
@@ -13017,16 +13222,17 @@ async function restoreOrCreateAcpSession(input) {
13017
13222
  };
13018
13223
  const withModelsFallback = (result) => mergeTopLevelModelsIntoConfigOptions(result.configOptions, result);
13019
13224
  if (resumeId && input.resumeSupported) {
13020
- const resumed = await tryRestoreMethod("resume", "session/resume");
13225
+ const resumed = await tryRestoreMethod("resume", methods.agent.session.resume);
13021
13226
  if (resumed) {
13022
13227
  const id = typeof resumed.sessionId === "string" ? resumed.sessionId : resumeId;
13023
13228
  return {
13024
13229
  sessionId: id,
13230
+ mcpServersAccepted,
13231
+ recoveredToolOutputs,
13232
+ nativeSessionAccepted,
13025
13233
  configOptions: withModelsFallback(resumed),
13026
13234
  restoreMethod: "resume",
13027
13235
  sessionRestored: true,
13028
- mcpServersAccepted,
13029
- nativeSessionAccepted,
13030
13236
  requestedSessionId: resumeId,
13031
13237
  restoreAttempts
13032
13238
  };
@@ -13037,16 +13243,17 @@ async function restoreOrCreateAcpSession(input) {
13037
13243
  if (resumeId && input.loadSupported) {
13038
13244
  input.onSuppressUpdates?.(true);
13039
13245
  try {
13040
- const loaded = await tryRestoreMethod("load", "session/load");
13246
+ const loaded = await tryRestoreMethod("load", methods.agent.session.load);
13041
13247
  if (loaded) {
13042
13248
  const id = typeof loaded.sessionId === "string" ? loaded.sessionId : resumeId;
13043
13249
  return {
13044
13250
  sessionId: id,
13251
+ mcpServersAccepted,
13252
+ recoveredToolOutputs,
13253
+ nativeSessionAccepted,
13045
13254
  configOptions: withModelsFallback(loaded),
13046
13255
  restoreMethod: "load",
13047
13256
  sessionRestored: true,
13048
- mcpServersAccepted,
13049
- nativeSessionAccepted,
13050
13257
  requestedSessionId: resumeId,
13051
13258
  restoreAttempts
13052
13259
  };
@@ -13065,15 +13272,27 @@ async function restoreOrCreateAcpSession(input) {
13065
13272
  }
13066
13273
  return {
13067
13274
  sessionId: newSessionId,
13275
+ mcpServersAccepted,
13276
+ nativeSessionAccepted,
13068
13277
  configOptions: withModelsFallback(sessionResult),
13069
13278
  restoreMethod: "new",
13070
13279
  sessionRestored: false,
13071
- mcpServersAccepted,
13072
- nativeSessionAccepted,
13073
13280
  requestedSessionId: resumeId ?? undefined,
13074
13281
  restoreAttempts
13075
13282
  };
13076
13283
  }
13284
+ async function requestSessionWithResources(request, method, params, sessionMeta) {
13285
+ if (!sessionMeta)
13286
+ return { result: await request(method, params), nativeSessionAccepted: false };
13287
+ try {
13288
+ return { result: await request(method, { ...params, _meta: sessionMeta }), nativeSessionAccepted: true };
13289
+ } catch (error) {
13290
+ const rejected = error instanceof RequestError && error.code === -32602 || /native.*meta.*reject|unsupported.*(meta|systemPrompt)|unknown.*(meta|systemPrompt)/i.test(errorMessage(error));
13291
+ if (!rejected || isTransientAcpTransportError(error))
13292
+ throw error;
13293
+ return { result: await request(method, params), nativeSessionAccepted: false };
13294
+ }
13295
+ }
13077
13296
 
13078
13297
  // src/client/acp-terminal.ts
13079
13298
  var import_node_child_process7 = require("node:child_process");
@@ -13261,8 +13480,8 @@ class AcpTerminalManager {
13261
13480
 
13262
13481
  // src/client/acp-proxy-service.ts
13263
13482
  var import_promises6 = require("node:fs/promises");
13264
- var import_node_fs15 = require("node:fs");
13265
- var import_node_path17 = require("node:path");
13483
+ var import_node_fs18 = require("node:fs");
13484
+ var import_node_path19 = require("node:path");
13266
13485
  var DEFAULT_ACP_PROXY_SETTINGS = {
13267
13486
  enabled: false,
13268
13487
  host: "127.0.0.1",
@@ -13271,11 +13490,11 @@ var DEFAULT_ACP_PROXY_SETTINGS = {
13271
13490
  var PROXY_ENV_KEYS = ["HTTP_PROXY", "HTTPS_PROXY", "ALL_PROXY"];
13272
13491
  var LOWERCASE_PROXY_ENV_KEYS = ["http_proxy", "https_proxy", "all_proxy", "no_proxy"];
13273
13492
  function proxyFilePath(dir) {
13274
- return import_node_path17.join(dir, "agent", "proxy.json");
13493
+ return import_node_path19.join(dir, "agent", "proxy.json");
13275
13494
  }
13276
13495
  async function readAcpProxySettings(dir = getDefaultAgentDataDir()) {
13277
13496
  const file = proxyFilePath(dir);
13278
- if (!import_node_fs15.existsSync(file))
13497
+ if (!import_node_fs18.existsSync(file))
13279
13498
  return { ...DEFAULT_ACP_PROXY_SETTINGS };
13280
13499
  try {
13281
13500
  const raw = JSON.parse(await import_promises6.readFile(file, "utf8"));
@@ -13340,9 +13559,9 @@ function compatDeliveryKey(sessionId, generation, digest) {
13340
13559
  }
13341
13560
 
13342
13561
  // src/mcp/app-skills-mcp.ts
13343
- var import_node_path18 = require("node:path");
13562
+ var import_node_path20 = require("node:path");
13344
13563
  var import_node_url = require("node:url");
13345
- var import_node_fs16 = require("node:fs");
13564
+ var import_node_fs19 = require("node:fs");
13346
13565
  var APP_SKILLS_MCP_SERVER_NAME = "app-skills";
13347
13566
  var APP_SKILLS_TOOLS = [
13348
13567
  {
@@ -13378,11 +13597,11 @@ function buildAppSkillsMcpServer(directory, opts) {
13378
13597
  function resolveAppSkillsRunnerPath(fromFile) {
13379
13598
  const base = fromFile ?? import_node_url.fileURLToPath("file:///home/runner/work/acp-client/acp-client/src/mcp/app-skills-mcp.ts");
13380
13599
  const candidates = [
13381
- import_node_path18.join(import_node_path18.dirname(base), "app-skills-mcp-serve.cjs"),
13382
- import_node_path18.join(import_node_path18.dirname(base), "app-skills-mcp-serve.ts")
13600
+ import_node_path20.join(import_node_path20.dirname(base), "app-skills-mcp-serve.cjs"),
13601
+ import_node_path20.join(import_node_path20.dirname(base), "app-skills-mcp-serve.ts")
13383
13602
  ];
13384
13603
  for (const candidate of candidates) {
13385
- if (import_node_fs16.existsSync(candidate))
13604
+ if (import_node_fs19.existsSync(candidate))
13386
13605
  return candidate;
13387
13606
  }
13388
13607
  throw new Error(`技能 MCP 入口缺失(dist 未构建?): ${candidates[0]}`);
@@ -13541,7 +13760,10 @@ class AcpClient {
13541
13760
  const connectGen = this.connectionGen;
13542
13761
  try {
13543
13762
  this.setStatus("connecting");
13544
- const blocker = this.adapter.resolveSpawnBlocker?.();
13763
+ const blocker = this.adapter.resolveSpawnBlocker?.({
13764
+ env: { ...process.env, ...this.extraEnv },
13765
+ dataDir: this.dataDir
13766
+ });
13545
13767
  if (blocker) {
13546
13768
  this.setStatus("error", blocker);
13547
13769
  return err({ code: "ACP_SPAWN_ERROR", message: blocker });
@@ -13564,6 +13786,10 @@ class AcpClient {
13564
13786
  ...baseEnv,
13565
13787
  env: { ...baseEnv.env ?? {}, ...this.extraEnv ?? {} }
13566
13788
  };
13789
+ const providerEnv = this.adapter.getProviderEnv?.({
13790
+ dataDir: this.dataDir,
13791
+ env: { ...process.env, ...spawnEnv.env }
13792
+ }) ?? {};
13567
13793
  let resourceEnv = {};
13568
13794
  let profileTag = null;
13569
13795
  if (this.resourcesDir && this.configurationScope === "session") {
@@ -13574,6 +13800,13 @@ class AcpClient {
13574
13800
  }
13575
13801
  this.sessionConfig = profile;
13576
13802
  resourceEnv = this.sessionConfig.env;
13803
+ const interactions = ["opencode", "opencode-v2"].includes(this.runtimeInfo.id) && this.adapter.prepareAppResources ? await this.adapter.prepareAppResources({
13804
+ directory: this.resourcesDir,
13805
+ command: effectiveRuntime.command,
13806
+ workspaceRoot: this.workspaceRoot,
13807
+ env: { ...process.env, ...spawnEnv.env, ...resourceEnv }
13808
+ }) : undefined;
13809
+ Object.assign(resourceEnv, interactions?.env);
13577
13810
  const load = readAppResourcesDir(this.resourcesDir);
13578
13811
  this.resourcePrep = { profileTag: null, report: {
13579
13812
  rulesApplied: false,
@@ -13582,6 +13815,7 @@ class AcpClient {
13582
13815
  rulesChars: load.rules?.chars ?? 0,
13583
13816
  profileDigest: digestAppResources(load),
13584
13817
  skillsFound: load.skills.map((s) => s.name),
13818
+ openCodeQuestions: interactions?.report.openCodeQuestions,
13585
13819
  configurationScope: "session",
13586
13820
  configurationDirectory: this.sessionConfig.directory,
13587
13821
  configurationRulesFile: this.sessionConfig.rulesFile,
@@ -13630,7 +13864,7 @@ class AcpClient {
13630
13864
  reason: "runtime-not-supported"
13631
13865
  } } : null;
13632
13866
  }
13633
- const finalEnv = { ...spawnEnv.env, ...resourceEnv };
13867
+ const finalEnv = { ...spawnEnv.env, ...providerEnv, ...resourceEnv };
13634
13868
  await this.adapter.beforeSpawn?.();
13635
13869
  if (connectGen !== this.connectionGen || this.status !== "connecting")
13636
13870
  return err({ code: "CANCELLED", message: "连接已取消" });
@@ -13742,21 +13976,25 @@ class AcpClient {
13742
13976
  }
13743
13977
  }
13744
13978
  getCachedQuota(sessionId) {
13745
- return this.quotaCache.get(sessionId, this.runtimeInfo.id);
13979
+ return this.quotaCache.applyContextUsage(this.quotaCache.get(sessionId, this.runtimeInfo.id), sessionId, this.runtimeInfo.id) ?? undefined;
13746
13980
  }
13747
13981
  async getQuota(sessionId) {
13748
- const cached = this.getCachedQuota(sessionId);
13982
+ const cached = this.quotaCache.get(sessionId, this.runtimeInfo.id);
13749
13983
  if (cached && Date.now() - cached.updatedAt < 30000) {
13750
- return cached;
13984
+ return this.quotaCache.applyContextUsage(cached, sessionId, this.runtimeInfo.id);
13751
13985
  }
13752
13986
  if (this.adapter.probeQuota) {
13753
- const probed = await this.adapter.probeQuota({ sessionId });
13987
+ const probed = await this.adapter.probeQuota({
13988
+ sessionId,
13989
+ dataDir: this.dataDir,
13990
+ env: { ...process.env, ...this.extraEnv }
13991
+ });
13754
13992
  if (probed) {
13755
13993
  this.quotaCache.set(probed, sessionId);
13756
- return probed;
13994
+ return this.quotaCache.applyContextUsage(probed, sessionId, this.runtimeInfo.id);
13757
13995
  }
13758
13996
  }
13759
- return cached ?? null;
13997
+ return this.quotaCache.applyContextUsage(cached ?? null, sessionId, this.runtimeInfo.id);
13760
13998
  }
13761
13999
  getAvailableCommands(sessionId) {
13762
14000
  return this.commandsCache.get(sessionId);