@ycodium-ai/agent-dsh 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
@@ -32722,23 +32722,31 @@ function createAcpConnection(options) {
32722
32722
  function normalizeModelId(value) {
32723
32723
  return value?.trim() || void 0;
32724
32724
  }
32725
- function adoptReportedConfigOptions(state, configOptions) {
32725
+ function adoptReportedConfigOptions(state, configOptions, fromAgent = true) {
32726
32726
  const option = state.modelConfigId === void 0 ? void 0 : findConfigOptionEntry(configOptions, state.modelConfigId);
32727
32727
  const value = option?.["currentValue"];
32728
32728
  const reported = typeof value === "string" ? normalizeModelId(value) : void 0;
32729
32729
  if (reported === void 0) return { ...state, configOptions };
32730
32730
  const { modelUnconfirmed: _confirmed, ...known } = state;
32731
- return { ...known, configOptions, currentModelId: reported };
32731
+ const stillReported = fromAgent || state.currentModelReported === true && reported === state.currentModelId;
32732
+ const { currentModelReported: _stale, ...unreported } = known;
32733
+ return {
32734
+ ...stillReported ? known : unreported,
32735
+ configOptions,
32736
+ currentModelId: reported,
32737
+ ...stillReported ? { currentModelReported: true } : {}
32738
+ };
32732
32739
  }
32733
32740
  function forgetConfigOptionValue(state, configId) {
32734
32741
  const forgetsModel = configId === void 0 || configId === state.modelConfigId;
32742
+ const { currentModelReported: _forgottenReport, ...withoutReport } = state;
32735
32743
  const configOptions = configId !== void 0 && Array.isArray(state.configOptions) ? state.configOptions.map((option) => {
32736
32744
  if (!isRecord2(option) || option["id"] !== configId) return option;
32737
32745
  const { currentValue: _forgotten, ...rest } = option;
32738
32746
  return rest;
32739
32747
  }) : state.configOptions;
32740
32748
  return {
32741
- ...state,
32749
+ ...forgetsModel ? withoutReport : state,
32742
32750
  configOptions,
32743
32751
  ...forgetsModel ? { currentModelId: void 0, modelUnconfirmed: true } : {}
32744
32752
  };
@@ -32755,6 +32763,7 @@ function modelSelectionStateFromSetup(setup) {
32755
32763
  sessionModelsAdvertised: sessionModels !== void 0,
32756
32764
  modelConfigId,
32757
32765
  currentModelId,
32766
+ ...currentModelId === void 0 ? {} : { currentModelReported: true },
32758
32767
  advertisedModelValues: strategy === "config-option" ? modelConfigOption === void 0 ? [] : collectSessionConfigOptionValues(modelConfigOption) : collectSessionModelIds(sessionModels),
32759
32768
  configOptions: setup.configOptions,
32760
32769
  catalogSetup: setup
@@ -33542,14 +33551,28 @@ function createExecutorPrompt({
33542
33551
  }
33543
33552
  };
33544
33553
  const alignTurnOptions = async (input2, sessionId, generation, isStale, signal) => {
33554
+ const before = shared.modelSelectionState;
33545
33555
  const applied = await applyRequestedModel({
33546
- state: shared.modelSelectionState,
33556
+ state: before,
33547
33557
  acpSessionId: sessionId,
33548
33558
  requestedModelId: input2.requestedModelId,
33549
33559
  expectedGeneration: generation,
33550
33560
  signal
33551
33561
  });
33552
33562
  shared.modelSelectionState = applied;
33563
+ if (applied.currentModelId !== void 0 && (applied.currentModelId !== before.currentModelId || applied.currentModelReported !== before.currentModelReported)) {
33564
+ emit({
33565
+ type: "thread.metadata.updated",
33566
+ ...stamp(),
33567
+ provider: options.provider,
33568
+ threadId: options.threadId,
33569
+ ...shared.activeTurnId === void 0 ? {} : { turnId: shared.activeTurnId },
33570
+ payload: {
33571
+ model: applied.currentModelId,
33572
+ modelSource: applied.currentModelReported === true ? "reported" : "echo"
33573
+ }
33574
+ });
33575
+ }
33553
33576
  if (isStale()) return;
33554
33577
  const switched = applied.configOptions;
33555
33578
  let aligned;
@@ -33574,7 +33597,8 @@ function createExecutorPrompt({
33574
33597
  if (aligned.configOptions !== switched) {
33575
33598
  shared.modelSelectionState = adoptReportedConfigOptions(
33576
33599
  shared.modelSelectionState,
33577
- aligned.configOptions
33600
+ aligned.configOptions,
33601
+ false
33578
33602
  );
33579
33603
  }
33580
33604
  if (aligned.unsupportedEffort !== void 0) {
@@ -34495,18 +34519,20 @@ function createExecutorSession({
34495
34519
  const base = ours !== void 0 && ours.seq > issuedAt ? ours.configOptions : configOptions;
34496
34520
  return { configOptions: withConfigOptionValue(base, configId, value), reported: false };
34497
34521
  };
34498
- const writeConfigOption = async (...args) => (await writeConfigOptionReported(...args)).configOptions;
34499
34522
  const switchModel = async (input2) => {
34500
34523
  let configOptions = input2.state.configOptions;
34524
+ let fromAgent = true;
34501
34525
  const write = { option: "model", signal: input2.signal };
34502
34526
  if (input2.state.strategy === "config-option" && input2.state.modelConfigId !== void 0) {
34503
- configOptions = await writeConfigOption(
34527
+ const written = await writeConfigOptionReported(
34504
34528
  input2.sessionId,
34505
34529
  configOptions,
34506
34530
  input2.state.modelConfigId,
34507
34531
  input2.value,
34508
34532
  write
34509
34533
  );
34534
+ configOptions = written.configOptions;
34535
+ fromAgent = written.reported;
34510
34536
  } else {
34511
34537
  const before = shared.configOptionUpdates.get(input2.sessionId);
34512
34538
  const pending = connection.begin("session/set_model", {
@@ -34524,7 +34550,12 @@ function createExecutorSession({
34524
34550
  throw new AcpExecutorDisposedError();
34525
34551
  }
34526
34552
  const { modelUnconfirmed: _confirmed, ...known } = input2.state;
34527
- return adoptReportedConfigOptions({ ...known, currentModelId: input2.value }, configOptions);
34553
+ const { currentModelReported: _echoed, ...requested } = known;
34554
+ return adoptReportedConfigOptions(
34555
+ { ...requested, currentModelId: input2.value },
34556
+ configOptions,
34557
+ fromAgent
34558
+ );
34528
34559
  };
34529
34560
  const applyRequestedModel = async (input2) => {
34530
34561
  const requestedModelId = normalizeModelId(input2.requestedModelId) ?? "";
@@ -34668,7 +34699,8 @@ function createExecutorSession({
34668
34699
  });
34669
34700
  nextModelSelectionState = adoptReportedConfigOptions(
34670
34701
  nextModelSelectionState,
34671
- aligned.configOptions
34702
+ aligned.configOptions,
34703
+ false
34672
34704
  );
34673
34705
  if (aligned.unsupportedEffort !== void 0) {
34674
34706
  options.log?.info("requested effort is not offered by this model; using its default", {
@@ -34701,7 +34733,8 @@ function createExecutorSession({
34701
34733
  initializeResult: initialized,
34702
34734
  sessionSetupResult: setup,
34703
34735
  modelConfigId: extractModelConfigId(setup),
34704
- modelId: nextModelSelectionState.currentModelId
34736
+ modelId: nextModelSelectionState.currentModelId,
34737
+ modelReported: nextModelSelectionState.currentModelReported === true
34705
34738
  };
34706
34739
  shared.startResult = result;
34707
34740
  shared.status = "ready";
@@ -35659,6 +35692,9 @@ function createAcpExecutor(options) {
35659
35692
  get modelId() {
35660
35693
  return shared.modelSelectionState.currentModelId;
35661
35694
  },
35695
+ get modelReported() {
35696
+ return shared.modelSelectionState.currentModelReported === true;
35697
+ },
35662
35698
  get status() {
35663
35699
  return shared.status;
35664
35700
  },
@@ -36972,7 +37008,11 @@ var createDshInstance = (config2, host) => {
36972
37008
  createdAt,
36973
37009
  updatedAt: createdAt,
36974
37010
  resumeCursor,
36975
- ...started.modelId === void 0 ? {} : { model: started.modelId },
37011
+ ...started.modelId === void 0 ? {} : {
37012
+ model: started.modelId,
37013
+ // agent 在握手里报的才是读回的;切型号走 session/set_model 时回包不带型号,那只是请求值。
37014
+ modelSource: started.modelReported ? "reported" : "echo"
37015
+ },
36976
37016
  ...input2.bindingGeneration === void 0 ? {} : { bindingGeneration: input2.bindingGeneration }
36977
37017
  };
36978
37018
  registerSession(input2.threadId, {
@@ -37103,7 +37143,7 @@ var executors = [
37103
37143
  ];
37104
37144
  var index_default = definePlugin({
37105
37145
  id: "agent-dsh",
37106
- apiVersion: 51,
37146
+ apiVersion: 53,
37107
37147
  executors,
37108
37148
  activate(ctx) {
37109
37149
  ctx.log.info("dsh executor ready");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-dsh",
3
- "version": "0.2.3671",
3
+ "version": "0.2.3710",
4
4
  "description": "DeepSeek Harness executor: dsh CLI over Agent Client Protocol stdio.",
5
5
  "keywords": [
6
6
  "ycodium",
@@ -22,9 +22,9 @@
22
22
  "esbuild": "0.28.1",
23
23
  "vite-plus": "0.2.2",
24
24
  "yaml": "^2.9.0",
25
- "@ycodium-ai/plugin-api": "0.2.3671",
26
- "ycodium-executor-testing": "0.0.0",
27
- "ycodium-acp-executor": "0.2.3671"
25
+ "@ycodium-ai/plugin-api": "0.2.3710",
26
+ "ycodium-acp-executor": "0.2.3710",
27
+ "ycodium-executor-testing": "0.0.0"
28
28
  },
29
29
  "ycodium": {
30
30
  "plugin": "./dist/index.js",