@ycodium-ai/agent-acp 0.2.3671 → 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
@@ -25276,23 +25276,31 @@ function createAcpConnection(options) {
25276
25276
  function normalizeModelId(value) {
25277
25277
  return value?.trim() || void 0;
25278
25278
  }
25279
- function adoptReportedConfigOptions(state, configOptions) {
25279
+ function adoptReportedConfigOptions(state, configOptions, fromAgent = true) {
25280
25280
  const option = state.modelConfigId === void 0 ? void 0 : findConfigOptionEntry(configOptions, state.modelConfigId);
25281
25281
  const value = option?.["currentValue"];
25282
25282
  const reported = typeof value === "string" ? normalizeModelId(value) : void 0;
25283
25283
  if (reported === void 0) return { ...state, configOptions };
25284
25284
  const { modelUnconfirmed: _confirmed, ...known } = state;
25285
- return { ...known, configOptions, currentModelId: reported };
25285
+ const stillReported = fromAgent || state.currentModelReported === true && reported === state.currentModelId;
25286
+ const { currentModelReported: _stale, ...unreported } = known;
25287
+ return {
25288
+ ...stillReported ? known : unreported,
25289
+ configOptions,
25290
+ currentModelId: reported,
25291
+ ...stillReported ? { currentModelReported: true } : {}
25292
+ };
25286
25293
  }
25287
25294
  function forgetConfigOptionValue(state, configId) {
25288
25295
  const forgetsModel = configId === void 0 || configId === state.modelConfigId;
25296
+ const { currentModelReported: _forgottenReport, ...withoutReport } = state;
25289
25297
  const configOptions = configId !== void 0 && Array.isArray(state.configOptions) ? state.configOptions.map((option) => {
25290
25298
  if (!isRecord2(option) || option["id"] !== configId) return option;
25291
25299
  const { currentValue: _forgotten, ...rest } = option;
25292
25300
  return rest;
25293
25301
  }) : state.configOptions;
25294
25302
  return {
25295
- ...state,
25303
+ ...forgetsModel ? withoutReport : state,
25296
25304
  configOptions,
25297
25305
  ...forgetsModel ? { currentModelId: void 0, modelUnconfirmed: true } : {}
25298
25306
  };
@@ -25309,6 +25317,7 @@ function modelSelectionStateFromSetup(setup) {
25309
25317
  sessionModelsAdvertised: sessionModels !== void 0,
25310
25318
  modelConfigId,
25311
25319
  currentModelId,
25320
+ ...currentModelId === void 0 ? {} : { currentModelReported: true },
25312
25321
  advertisedModelValues: strategy === "config-option" ? modelConfigOption === void 0 ? [] : collectSessionConfigOptionValues(modelConfigOption) : collectSessionModelIds(sessionModels),
25313
25322
  configOptions: setup.configOptions,
25314
25323
  catalogSetup: setup
@@ -26096,14 +26105,28 @@ function createExecutorPrompt({
26096
26105
  }
26097
26106
  };
26098
26107
  const alignTurnOptions = async (input2, sessionId, generation, isStale, signal) => {
26108
+ const before = shared.modelSelectionState;
26099
26109
  const applied = await applyRequestedModel({
26100
- state: shared.modelSelectionState,
26110
+ state: before,
26101
26111
  acpSessionId: sessionId,
26102
26112
  requestedModelId: input2.requestedModelId,
26103
26113
  expectedGeneration: generation,
26104
26114
  signal
26105
26115
  });
26106
26116
  shared.modelSelectionState = applied;
26117
+ if (applied.currentModelId !== void 0 && (applied.currentModelId !== before.currentModelId || applied.currentModelReported !== before.currentModelReported)) {
26118
+ emit({
26119
+ type: "thread.metadata.updated",
26120
+ ...stamp(),
26121
+ provider: options.provider,
26122
+ threadId: options.threadId,
26123
+ ...shared.activeTurnId === void 0 ? {} : { turnId: shared.activeTurnId },
26124
+ payload: {
26125
+ model: applied.currentModelId,
26126
+ modelSource: applied.currentModelReported === true ? "reported" : "echo"
26127
+ }
26128
+ });
26129
+ }
26107
26130
  if (isStale()) return;
26108
26131
  const switched = applied.configOptions;
26109
26132
  let aligned;
@@ -26128,7 +26151,8 @@ function createExecutorPrompt({
26128
26151
  if (aligned.configOptions !== switched) {
26129
26152
  shared.modelSelectionState = adoptReportedConfigOptions(
26130
26153
  shared.modelSelectionState,
26131
- aligned.configOptions
26154
+ aligned.configOptions,
26155
+ false
26132
26156
  );
26133
26157
  }
26134
26158
  if (aligned.unsupportedEffort !== void 0) {
@@ -27102,18 +27126,20 @@ function createExecutorSession({
27102
27126
  const base = ours !== void 0 && ours.seq > issuedAt ? ours.configOptions : configOptions;
27103
27127
  return { configOptions: withConfigOptionValue(base, configId, value), reported: false };
27104
27128
  };
27105
- const writeConfigOption = async (...args) => (await writeConfigOptionReported(...args)).configOptions;
27106
27129
  const switchModel = async (input2) => {
27107
27130
  let configOptions = input2.state.configOptions;
27131
+ let fromAgent = true;
27108
27132
  const write = { option: "model", signal: input2.signal };
27109
27133
  if (input2.state.strategy === "config-option" && input2.state.modelConfigId !== void 0) {
27110
- configOptions = await writeConfigOption(
27134
+ const written = await writeConfigOptionReported(
27111
27135
  input2.sessionId,
27112
27136
  configOptions,
27113
27137
  input2.state.modelConfigId,
27114
27138
  input2.value,
27115
27139
  write
27116
27140
  );
27141
+ configOptions = written.configOptions;
27142
+ fromAgent = written.reported;
27117
27143
  } else {
27118
27144
  const before = shared.configOptionUpdates.get(input2.sessionId);
27119
27145
  const pending = connection.begin("session/set_model", {
@@ -27131,7 +27157,12 @@ function createExecutorSession({
27131
27157
  throw new AcpExecutorDisposedError();
27132
27158
  }
27133
27159
  const { modelUnconfirmed: _confirmed, ...known } = input2.state;
27134
- return adoptReportedConfigOptions({ ...known, currentModelId: input2.value }, configOptions);
27160
+ const { currentModelReported: _echoed, ...requested } = known;
27161
+ return adoptReportedConfigOptions(
27162
+ { ...requested, currentModelId: input2.value },
27163
+ configOptions,
27164
+ fromAgent
27165
+ );
27135
27166
  };
27136
27167
  const applyRequestedModel = async (input2) => {
27137
27168
  const requestedModelId = normalizeModelId(input2.requestedModelId) ?? "";
@@ -27275,7 +27306,8 @@ function createExecutorSession({
27275
27306
  });
27276
27307
  nextModelSelectionState = adoptReportedConfigOptions(
27277
27308
  nextModelSelectionState,
27278
- aligned.configOptions
27309
+ aligned.configOptions,
27310
+ false
27279
27311
  );
27280
27312
  if (aligned.unsupportedEffort !== void 0) {
27281
27313
  options.log?.info("requested effort is not offered by this model; using its default", {
@@ -27308,7 +27340,8 @@ function createExecutorSession({
27308
27340
  initializeResult: initialized,
27309
27341
  sessionSetupResult: setup,
27310
27342
  modelConfigId: extractModelConfigId(setup),
27311
- modelId: nextModelSelectionState.currentModelId
27343
+ modelId: nextModelSelectionState.currentModelId,
27344
+ modelReported: nextModelSelectionState.currentModelReported === true
27312
27345
  };
27313
27346
  shared.startResult = result;
27314
27347
  shared.status = "ready";
@@ -28266,6 +28299,9 @@ function createAcpExecutor(options) {
28266
28299
  get modelId() {
28267
28300
  return shared.modelSelectionState.currentModelId;
28268
28301
  },
28302
+ get modelReported() {
28303
+ return shared.modelSelectionState.currentModelReported === true;
28304
+ },
28269
28305
  get status() {
28270
28306
  return shared.status;
28271
28307
  },
@@ -29164,7 +29200,11 @@ var createAcpInstance = (config2, host) => {
29164
29200
  createdAt,
29165
29201
  updatedAt: createdAt,
29166
29202
  resumeCursor,
29167
- ...started.modelId === void 0 ? {} : { model: started.modelId },
29203
+ ...started.modelId === void 0 ? {} : {
29204
+ model: started.modelId,
29205
+ // agent 在握手里报的才是读回的;切型号走 session/set_model 时回包不带型号,那只是请求值。
29206
+ modelSource: started.modelReported ? "reported" : "echo"
29207
+ },
29168
29208
  ...input2.bindingGeneration === void 0 ? {} : { bindingGeneration: input2.bindingGeneration }
29169
29209
  };
29170
29210
  registerSession(input2.threadId, {
@@ -29290,7 +29330,7 @@ var executors = [
29290
29330
  ];
29291
29331
  var index_default = definePlugin({
29292
29332
  id: "agent-acp",
29293
- apiVersion: 51,
29333
+ apiVersion: 53,
29294
29334
  executors,
29295
29335
  activate(ctx) {
29296
29336
  ctx.log.info("generic ACP executor ready");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-acp",
3
- "version": "0.2.3671",
3
+ "version": "0.2.3710",
4
4
  "description": "Generic ACP executor: user-supplied CLI 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.3671",
25
- "ycodium-acp-executor": "0.2.3671",
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",