@ycodium-ai/agent-kimi 0.2.3681 → 0.2.3710

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.
Files changed (2) hide show
  1. package/dist/index.js +52 -12
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -25316,23 +25316,31 @@ function createAcpConnection(options) {
25316
25316
  function normalizeModelId(value) {
25317
25317
  return value?.trim() || void 0;
25318
25318
  }
25319
- function adoptReportedConfigOptions(state, configOptions) {
25319
+ function adoptReportedConfigOptions(state, configOptions, fromAgent = true) {
25320
25320
  const option = state.modelConfigId === void 0 ? void 0 : findConfigOptionEntry(configOptions, state.modelConfigId);
25321
25321
  const value = option?.["currentValue"];
25322
25322
  const reported = typeof value === "string" ? normalizeModelId(value) : void 0;
25323
25323
  if (reported === void 0) return { ...state, configOptions };
25324
25324
  const { modelUnconfirmed: _confirmed, ...known } = state;
25325
- return { ...known, configOptions, currentModelId: reported };
25325
+ const stillReported = fromAgent || state.currentModelReported === true && reported === state.currentModelId;
25326
+ const { currentModelReported: _stale, ...unreported } = known;
25327
+ return {
25328
+ ...stillReported ? known : unreported,
25329
+ configOptions,
25330
+ currentModelId: reported,
25331
+ ...stillReported ? { currentModelReported: true } : {}
25332
+ };
25326
25333
  }
25327
25334
  function forgetConfigOptionValue(state, configId) {
25328
25335
  const forgetsModel = configId === void 0 || configId === state.modelConfigId;
25336
+ const { currentModelReported: _forgottenReport, ...withoutReport } = state;
25329
25337
  const configOptions = configId !== void 0 && Array.isArray(state.configOptions) ? state.configOptions.map((option) => {
25330
25338
  if (!isRecord2(option) || option["id"] !== configId) return option;
25331
25339
  const { currentValue: _forgotten, ...rest } = option;
25332
25340
  return rest;
25333
25341
  }) : state.configOptions;
25334
25342
  return {
25335
- ...state,
25343
+ ...forgetsModel ? withoutReport : state,
25336
25344
  configOptions,
25337
25345
  ...forgetsModel ? { currentModelId: void 0, modelUnconfirmed: true } : {}
25338
25346
  };
@@ -25349,6 +25357,7 @@ function modelSelectionStateFromSetup(setup) {
25349
25357
  sessionModelsAdvertised: sessionModels !== void 0,
25350
25358
  modelConfigId,
25351
25359
  currentModelId,
25360
+ ...currentModelId === void 0 ? {} : { currentModelReported: true },
25352
25361
  advertisedModelValues: strategy === "config-option" ? modelConfigOption === void 0 ? [] : collectSessionConfigOptionValues(modelConfigOption) : collectSessionModelIds(sessionModels),
25353
25362
  configOptions: setup.configOptions,
25354
25363
  catalogSetup: setup
@@ -26136,14 +26145,28 @@ function createExecutorPrompt({
26136
26145
  }
26137
26146
  };
26138
26147
  const alignTurnOptions = async (input2, sessionId, generation, isStale, signal) => {
26148
+ const before = shared.modelSelectionState;
26139
26149
  const applied = await applyRequestedModel({
26140
- state: shared.modelSelectionState,
26150
+ state: before,
26141
26151
  acpSessionId: sessionId,
26142
26152
  requestedModelId: input2.requestedModelId,
26143
26153
  expectedGeneration: generation,
26144
26154
  signal
26145
26155
  });
26146
26156
  shared.modelSelectionState = applied;
26157
+ if (applied.currentModelId !== void 0 && (applied.currentModelId !== before.currentModelId || applied.currentModelReported !== before.currentModelReported)) {
26158
+ emit({
26159
+ type: "thread.metadata.updated",
26160
+ ...stamp(),
26161
+ provider: options.provider,
26162
+ threadId: options.threadId,
26163
+ ...shared.activeTurnId === void 0 ? {} : { turnId: shared.activeTurnId },
26164
+ payload: {
26165
+ model: applied.currentModelId,
26166
+ modelSource: applied.currentModelReported === true ? "reported" : "echo"
26167
+ }
26168
+ });
26169
+ }
26147
26170
  if (isStale()) return;
26148
26171
  const switched = applied.configOptions;
26149
26172
  let aligned;
@@ -26168,7 +26191,8 @@ function createExecutorPrompt({
26168
26191
  if (aligned.configOptions !== switched) {
26169
26192
  shared.modelSelectionState = adoptReportedConfigOptions(
26170
26193
  shared.modelSelectionState,
26171
- aligned.configOptions
26194
+ aligned.configOptions,
26195
+ false
26172
26196
  );
26173
26197
  }
26174
26198
  if (aligned.unsupportedEffort !== void 0) {
@@ -27107,18 +27131,20 @@ function createExecutorSession({
27107
27131
  const base = ours !== void 0 && ours.seq > issuedAt ? ours.configOptions : configOptions;
27108
27132
  return { configOptions: withConfigOptionValue(base, configId, value), reported: false };
27109
27133
  };
27110
- const writeConfigOption = async (...args) => (await writeConfigOptionReported(...args)).configOptions;
27111
27134
  const switchModel = async (input2) => {
27112
27135
  let configOptions = input2.state.configOptions;
27136
+ let fromAgent = true;
27113
27137
  const write = { option: "model", signal: input2.signal };
27114
27138
  if (input2.state.strategy === "config-option" && input2.state.modelConfigId !== void 0) {
27115
- configOptions = await writeConfigOption(
27139
+ const written = await writeConfigOptionReported(
27116
27140
  input2.sessionId,
27117
27141
  configOptions,
27118
27142
  input2.state.modelConfigId,
27119
27143
  input2.value,
27120
27144
  write
27121
27145
  );
27146
+ configOptions = written.configOptions;
27147
+ fromAgent = written.reported;
27122
27148
  } else {
27123
27149
  const before = shared.configOptionUpdates.get(input2.sessionId);
27124
27150
  const pending = connection.begin("session/set_model", {
@@ -27136,7 +27162,12 @@ function createExecutorSession({
27136
27162
  throw new AcpExecutorDisposedError();
27137
27163
  }
27138
27164
  const { modelUnconfirmed: _confirmed, ...known } = input2.state;
27139
- return adoptReportedConfigOptions({ ...known, currentModelId: input2.value }, configOptions);
27165
+ const { currentModelReported: _echoed, ...requested } = known;
27166
+ return adoptReportedConfigOptions(
27167
+ { ...requested, currentModelId: input2.value },
27168
+ configOptions,
27169
+ fromAgent
27170
+ );
27140
27171
  };
27141
27172
  const applyRequestedModel = async (input2) => {
27142
27173
  const requestedModelId = normalizeModelId(input2.requestedModelId) ?? "";
@@ -27280,7 +27311,8 @@ function createExecutorSession({
27280
27311
  });
27281
27312
  nextModelSelectionState = adoptReportedConfigOptions(
27282
27313
  nextModelSelectionState,
27283
- aligned.configOptions
27314
+ aligned.configOptions,
27315
+ false
27284
27316
  );
27285
27317
  if (aligned.unsupportedEffort !== void 0) {
27286
27318
  options.log?.info("requested effort is not offered by this model; using its default", {
@@ -27313,7 +27345,8 @@ function createExecutorSession({
27313
27345
  initializeResult: initialized,
27314
27346
  sessionSetupResult: setup,
27315
27347
  modelConfigId: extractModelConfigId(setup),
27316
- modelId: nextModelSelectionState.currentModelId
27348
+ modelId: nextModelSelectionState.currentModelId,
27349
+ modelReported: nextModelSelectionState.currentModelReported === true
27317
27350
  };
27318
27351
  shared.startResult = result;
27319
27352
  shared.status = "ready";
@@ -28271,6 +28304,9 @@ function createAcpExecutor(options) {
28271
28304
  get modelId() {
28272
28305
  return shared.modelSelectionState.currentModelId;
28273
28306
  },
28307
+ get modelReported() {
28308
+ return shared.modelSelectionState.currentModelReported === true;
28309
+ },
28274
28310
  get status() {
28275
28311
  return shared.status;
28276
28312
  },
@@ -29735,7 +29771,11 @@ var createKimiInstance = (config2, host) => {
29735
29771
  createdAt,
29736
29772
  updatedAt: createdAt,
29737
29773
  resumeCursor,
29738
- ...started.modelId === void 0 ? {} : { model: started.modelId },
29774
+ ...started.modelId === void 0 ? {} : {
29775
+ model: started.modelId,
29776
+ // agent 在握手里报的才是读回的;切型号走 session/set_model 时回包不带型号,那只是请求值。
29777
+ modelSource: started.modelReported ? "reported" : "echo"
29778
+ },
29739
29779
  ...input2.bindingGeneration === void 0 ? {} : { bindingGeneration: input2.bindingGeneration }
29740
29780
  };
29741
29781
  registerSession(input2.threadId, {
@@ -29880,7 +29920,7 @@ var executors = [
29880
29920
  ];
29881
29921
  var index_default = definePlugin({
29882
29922
  id: "agent-kimi",
29883
- apiVersion: 52,
29923
+ apiVersion: 53,
29884
29924
  executors,
29885
29925
  activate(ctx) {
29886
29926
  ctx.log.info("Kimi Code executor ready");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-kimi",
3
- "version": "0.2.3681",
3
+ "version": "0.2.3710",
4
4
  "description": "Kimi Code executor: runs `kimi acp` over Agent Client Protocol stdio.",
5
5
  "keywords": [
6
6
  "ycodium",
@@ -21,9 +21,9 @@
21
21
  "@types/node": "24.12.4",
22
22
  "esbuild": "0.28.1",
23
23
  "vite-plus": "0.2.2",
24
- "@ycodium-ai/plugin-api": "0.2.3681",
25
- "ycodium-acp-executor": "0.2.3681",
26
- "ycodium-executor-testing": "0.0.0"
24
+ "@ycodium-ai/plugin-api": "0.2.3710",
25
+ "ycodium-executor-testing": "0.0.0",
26
+ "ycodium-acp-executor": "0.2.3710"
27
27
  },
28
28
  "ycodium": {
29
29
  "plugin": "./dist/index.js",