@ycodium-ai/agent-dsh 0.2.2988 → 0.2.2990

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 +27 -18
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -30890,6 +30890,12 @@ var AcpExecutorDisposedError = class extends AcpExecutorError {
30890
30890
  this.name = "AcpExecutorDisposedError";
30891
30891
  }
30892
30892
  };
30893
+ var AcpExecutorTurnEndedError = class extends AcpExecutorError {
30894
+ constructor(message = "The target turn has ended. The message was not sent.") {
30895
+ super("provider-rejected", message);
30896
+ this.name = "AcpExecutorTurnEndedError";
30897
+ }
30898
+ };
30893
30899
  var AcpExecutorNotStartedError = class extends AcpExecutorError {
30894
30900
  constructor(message = "ACP session has not been started") {
30895
30901
  super("not-started", message);
@@ -31655,6 +31661,12 @@ function asTrimmedString(value) {
31655
31661
  const trimmed = value.trim();
31656
31662
  return trimmed.length > 0 ? trimmed : void 0;
31657
31663
  }
31664
+ var selectPromptTurnId = (input2, activeTurnId, freshTurnId) => {
31665
+ const target = input2.expectedActiveTurnId;
31666
+ if (target === void 0) return input2.turnId ?? activeTurnId ?? freshTurnId();
31667
+ if (activeTurnId !== target) throw new AcpExecutorTurnEndedError();
31668
+ return target;
31669
+ };
31658
31670
 
31659
31671
  // ../../packages/ycodium-acp-executor/src/tool-presentation.ts
31660
31672
  function normalizeCommandValue(value) {
@@ -33749,7 +33761,7 @@ function createAcpExecutor(options) {
33749
33761
  await threadMutex.acquire();
33750
33762
  try {
33751
33763
  failIfDisposed();
33752
- turnId = input2.turnId ?? (promptsInFlight > 0 ? activeTurnId : void 0) ?? randomId();
33764
+ turnId = selectPromptTurnId(input2, promptsInFlight > 0 ? activeTurnId : void 0, randomId);
33753
33765
  promptsInFlight += 1;
33754
33766
  activeTurnId = turnId;
33755
33767
  status = "running";
@@ -33771,20 +33783,20 @@ function createAcpExecutor(options) {
33771
33783
  let response;
33772
33784
  try {
33773
33785
  failIfDisposed();
33774
- if (interruptedTurnIds.has(turnId)) {
33786
+ const queuedTurnId = turnId;
33787
+ const isStale = () => interruptedTurnIds.has(queuedTurnId) || input2.expectedActiveTurnId !== void 0 && activeTurnId !== queuedTurnId;
33788
+ if (!isStale()) {
33789
+ modelSelectionState = await applyRequestedModel({
33790
+ state: modelSelectionState,
33791
+ acpSessionId: started.sessionId,
33792
+ requestedModelId: input2.requestedModelId,
33793
+ expectedGeneration: started.generation
33794
+ });
33795
+ }
33796
+ if (isStale()) {
33775
33797
  settle2({ turnId, stopReason: "cancelled", state: "cancelled" });
33776
- return {
33777
- threadId: options.threadId,
33778
- turnId,
33779
- stopReason: "cancelled"
33780
- };
33798
+ return { threadId: options.threadId, turnId, stopReason: "cancelled" };
33781
33799
  }
33782
- modelSelectionState = await applyRequestedModel({
33783
- state: modelSelectionState,
33784
- acpSessionId: started.sessionId,
33785
- requestedModelId: input2.requestedModelId,
33786
- expectedGeneration: started.generation
33787
- });
33788
33800
  closeActiveAssistantSegment(turnId);
33789
33801
  let written = false;
33790
33802
  try {
@@ -33914,10 +33926,7 @@ function createAcpExecutor(options) {
33914
33926
  provider: options.provider,
33915
33927
  threadId: options.threadId,
33916
33928
  turnId: targetTurnId,
33917
- payload: {
33918
- state: "cancelled",
33919
- stopReason: "cancelled"
33920
- }
33929
+ payload: { state: "cancelled", stopReason: "cancelled" }
33921
33930
  });
33922
33931
  interruptedTurnIds.delete(targetTurnId);
33923
33932
  }
@@ -35131,7 +35140,7 @@ var createDshInstance = (config2, host) => {
35131
35140
  const requestedModelId = modelIdFromSelection(input2.modelSelection);
35132
35141
  const turn = await dispatchAcpPrompt(booked.executor, {
35133
35142
  text: input2.input ?? "",
35134
- ...input2.expectedTurnId === void 0 ? {} : { turnId: input2.expectedTurnId },
35143
+ expectedActiveTurnId: input2.expectedTurnId,
35135
35144
  ...requestedModelId === void 0 ? {} : { requestedModelId }
35136
35145
  });
35137
35146
  booked.turns.push({ id: turn.turnId, items: [] });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-dsh",
3
- "version": "0.2.2988",
3
+ "version": "0.2.2990",
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-acp-executor": "0.2.2988",
25
+ "@ycodium-ai/plugin-api": "0.2.2990",
26
26
  "ycodium-executor-testing": "0.0.0",
27
- "@ycodium-ai/plugin-api": "0.2.2988"
27
+ "ycodium-acp-executor": "0.2.2990"
28
28
  },
29
29
  "ycodium": {
30
30
  "plugin": "./dist/index.js",