@ycodium-ai/agent-dsh 0.2.3130 → 0.2.3158
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/index.js +269 -104
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -32333,7 +32333,10 @@ function createAcpConnection(options) {
|
|
|
32333
32333
|
}
|
|
32334
32334
|
pending.delete(key);
|
|
32335
32335
|
try {
|
|
32336
|
-
options.onResponse?.(
|
|
32336
|
+
options.onResponse?.(
|
|
32337
|
+
waiter,
|
|
32338
|
+
Object.hasOwn(message, "error") ? { error: message["error"] } : { result: message["result"] }
|
|
32339
|
+
);
|
|
32337
32340
|
} catch {
|
|
32338
32341
|
}
|
|
32339
32342
|
if (Object.hasOwn(message, "error")) {
|
|
@@ -32466,12 +32469,17 @@ function createAcpConnection(options) {
|
|
|
32466
32469
|
options.readable.on("end", onEnd);
|
|
32467
32470
|
options.readable.on("error", onError);
|
|
32468
32471
|
options.writable.once("error", onWritableError);
|
|
32469
|
-
const begin = (method, params) => {
|
|
32472
|
+
const begin = (method, params, promptId) => {
|
|
32470
32473
|
failIfClosed();
|
|
32471
32474
|
const id = nextRequestId;
|
|
32472
32475
|
nextRequestId += 1;
|
|
32473
32476
|
const { promise: promise2, resolve: resolve2, reject } = Promise.withResolvers();
|
|
32474
|
-
pending.set(String(id), {
|
|
32477
|
+
pending.set(String(id), {
|
|
32478
|
+
method,
|
|
32479
|
+
...promptId === void 0 ? {} : { promptId },
|
|
32480
|
+
resolve: resolve2,
|
|
32481
|
+
reject
|
|
32482
|
+
});
|
|
32475
32483
|
const message = params === void 0 ? { jsonrpc: "2.0", id, method } : { jsonrpc: "2.0", id, method, params };
|
|
32476
32484
|
const written = Promise.race([writeMessage(message), promise2]).then(
|
|
32477
32485
|
() => void 0,
|
|
@@ -32541,12 +32549,14 @@ function createExecutorLifecycle({
|
|
|
32541
32549
|
notifyPromptSettled,
|
|
32542
32550
|
eventStream,
|
|
32543
32551
|
onInputDead,
|
|
32544
|
-
shared
|
|
32552
|
+
shared,
|
|
32553
|
+
promptResults
|
|
32545
32554
|
}) {
|
|
32546
32555
|
const cancel = async (turnId) => {
|
|
32547
32556
|
failIfDisposed();
|
|
32548
32557
|
const started = requireStarted();
|
|
32549
32558
|
const targetTurnId = turnId ?? shared.activeTurnId;
|
|
32559
|
+
promptResults.stop(targetTurnId);
|
|
32550
32560
|
if (targetTurnId !== void 0) {
|
|
32551
32561
|
interruptedTurnIds.add(targetTurnId);
|
|
32552
32562
|
}
|
|
@@ -32557,6 +32567,9 @@ function createExecutorLifecycle({
|
|
|
32557
32567
|
if (shared.sessionId) {
|
|
32558
32568
|
await connection.notify("session/cancel", { sessionId: shared.sessionId });
|
|
32559
32569
|
}
|
|
32570
|
+
await promptResults.wait(targetTurnId);
|
|
32571
|
+
if (targetTurnId !== void 0 && shared.activeTurnId !== targetTurnId && !interruptedTurnIds.has(targetTurnId))
|
|
32572
|
+
return;
|
|
32560
32573
|
const settled = await waitForPromptIdle(cancelGraceMs);
|
|
32561
32574
|
if (!settled) {
|
|
32562
32575
|
throw new AcpExecutorCancelTimeoutError();
|
|
@@ -32577,6 +32590,7 @@ function createExecutorLifecycle({
|
|
|
32577
32590
|
payload: { state: "cancelled", stopReason: "cancelled" }
|
|
32578
32591
|
});
|
|
32579
32592
|
interruptedTurnIds.delete(targetTurnId);
|
|
32593
|
+
promptResults.forget(targetTurnId);
|
|
32580
32594
|
}
|
|
32581
32595
|
}
|
|
32582
32596
|
}
|
|
@@ -32651,33 +32665,39 @@ function createExecutorLifecycle({
|
|
|
32651
32665
|
if (!shared.disposed) emitSessionState("ready");
|
|
32652
32666
|
}
|
|
32653
32667
|
};
|
|
32654
|
-
|
|
32655
|
-
|
|
32656
|
-
|
|
32657
|
-
|
|
32668
|
+
let disposing;
|
|
32669
|
+
const dispose = () => {
|
|
32670
|
+
if (disposing) return disposing;
|
|
32671
|
+
shared.disposing = true;
|
|
32672
|
+
promptResults.stop();
|
|
32658
32673
|
settleAllApprovals("cancel");
|
|
32659
32674
|
settleAllUserInputs();
|
|
32660
32675
|
abortPendingSettlement("executor disposed");
|
|
32661
32676
|
notifyPromptSettled();
|
|
32662
32677
|
shared.abortLocalPrompt?.();
|
|
32663
|
-
|
|
32664
|
-
|
|
32665
|
-
|
|
32666
|
-
|
|
32667
|
-
|
|
32668
|
-
|
|
32669
|
-
|
|
32670
|
-
|
|
32671
|
-
|
|
32672
|
-
|
|
32673
|
-
|
|
32674
|
-
|
|
32675
|
-
|
|
32676
|
-
|
|
32677
|
-
|
|
32678
|
-
|
|
32679
|
-
|
|
32680
|
-
|
|
32678
|
+
disposing = (async () => {
|
|
32679
|
+
promptResults.finishUnreceived();
|
|
32680
|
+
await promptResults.wait();
|
|
32681
|
+
emit({
|
|
32682
|
+
type: "session.exited",
|
|
32683
|
+
...stamp(),
|
|
32684
|
+
provider: options.provider,
|
|
32685
|
+
threadId: options.threadId,
|
|
32686
|
+
payload: { reason: "disposed" }
|
|
32687
|
+
});
|
|
32688
|
+
shared.disposed = true;
|
|
32689
|
+
shared.generation += 1;
|
|
32690
|
+
shared.status = "disposed";
|
|
32691
|
+
eventStream.close();
|
|
32692
|
+
options.readable.off("end", onInputDead);
|
|
32693
|
+
options.readable.off("error", onInputDead);
|
|
32694
|
+
options.readable.pause();
|
|
32695
|
+
if (!shared.connectionClosed) {
|
|
32696
|
+
await connection.awaitInboundIdle().catch(() => void 0);
|
|
32697
|
+
await connection.close().catch(() => void 0);
|
|
32698
|
+
}
|
|
32699
|
+
})();
|
|
32700
|
+
return disposing;
|
|
32681
32701
|
};
|
|
32682
32702
|
return { cancel, compact, dispose };
|
|
32683
32703
|
}
|
|
@@ -32781,12 +32801,14 @@ function createExecutorPrompt({
|
|
|
32781
32801
|
promptMutex,
|
|
32782
32802
|
applyRequestedModel,
|
|
32783
32803
|
notifyPromptSettled,
|
|
32784
|
-
shared
|
|
32804
|
+
shared,
|
|
32805
|
+
promptResults
|
|
32785
32806
|
}) {
|
|
32786
32807
|
const settleTurn = (input2) => {
|
|
32787
|
-
if (!isLive(input2.expectedGeneration)) {
|
|
32808
|
+
if (!isLive(input2.expectedGeneration) || input2.record.finished) {
|
|
32788
32809
|
return false;
|
|
32789
32810
|
}
|
|
32811
|
+
promptResults.complete(input2.record);
|
|
32790
32812
|
if (!acpPromptSettlementBelongsToContext({
|
|
32791
32813
|
liveAcpSessionId: shared.sessionId ?? "",
|
|
32792
32814
|
expectedAcpSessionId: input2.expectedSessionId,
|
|
@@ -32803,6 +32825,7 @@ function createExecutorPrompt({
|
|
|
32803
32825
|
if (shared.status !== "disposed") {
|
|
32804
32826
|
shared.status = "ready";
|
|
32805
32827
|
}
|
|
32828
|
+
const interrupted = promptResults.hasInterrupted(input2.turnId);
|
|
32806
32829
|
emit({
|
|
32807
32830
|
type: "turn.completed",
|
|
32808
32831
|
...stamp(),
|
|
@@ -32810,30 +32833,44 @@ function createExecutorPrompt({
|
|
|
32810
32833
|
threadId: options.threadId,
|
|
32811
32834
|
turnId: input2.turnId,
|
|
32812
32835
|
payload: {
|
|
32813
|
-
state: input2.state,
|
|
32814
|
-
stopReason: input2.stopReason,
|
|
32836
|
+
state: interrupted ? "cancelled" : input2.state,
|
|
32837
|
+
stopReason: interrupted ? "cancelled" : input2.stopReason,
|
|
32815
32838
|
...input2.errorMessage === void 0 ? {} : { errorMessage: input2.errorMessage },
|
|
32816
32839
|
...input2.state === "failed" ? failureCategoryField(input2.failureCategory) : {}
|
|
32817
32840
|
}
|
|
32818
32841
|
});
|
|
32819
32842
|
interruptedTurnIds.delete(input2.turnId);
|
|
32843
|
+
promptResults.forget(input2.turnId);
|
|
32820
32844
|
return true;
|
|
32821
32845
|
};
|
|
32822
|
-
const sendPromptRpc = async (sessionId, promptParts, onWritten) => {
|
|
32846
|
+
const sendPromptRpc = async (sessionId, promptParts, onWritten, record2) => {
|
|
32823
32847
|
const settlementHooks = hooks.promptSettlement;
|
|
32824
32848
|
const promptKey = settlementHooks === void 0 ? void 0 : randomId();
|
|
32825
|
-
const pending = connection.begin(
|
|
32826
|
-
|
|
32827
|
-
|
|
32828
|
-
|
|
32829
|
-
|
|
32849
|
+
const pending = connection.begin(
|
|
32850
|
+
"session/prompt",
|
|
32851
|
+
{
|
|
32852
|
+
sessionId,
|
|
32853
|
+
prompt: promptParts,
|
|
32854
|
+
...settlementHooks !== void 0 && promptKey !== void 0 ? settlementHooks.requestFields(promptKey) : {}
|
|
32855
|
+
},
|
|
32856
|
+
record2?.promptId
|
|
32857
|
+
);
|
|
32830
32858
|
void pending.written.then(onWritten, () => void 0);
|
|
32831
32859
|
const promptRpc = pending.response;
|
|
32832
32860
|
if (settlementHooks === void 0 || promptKey === void 0) {
|
|
32833
32861
|
return await promptRpc;
|
|
32834
32862
|
} else {
|
|
32835
32863
|
const { promise: early, resolve: settleEarly } = Promise.withResolvers();
|
|
32836
|
-
shared.pendingSettlement = {
|
|
32864
|
+
shared.pendingSettlement = {
|
|
32865
|
+
promptKey,
|
|
32866
|
+
sessionId,
|
|
32867
|
+
settle: settleEarly,
|
|
32868
|
+
...record2 === void 0 ? {} : {
|
|
32869
|
+
onResponse: (response) => promptResults.receive(record2.promptId, response),
|
|
32870
|
+
onError: () => promptResults.reject(record2.promptId),
|
|
32871
|
+
hasResult: () => record2.response !== void 0
|
|
32872
|
+
}
|
|
32873
|
+
};
|
|
32837
32874
|
try {
|
|
32838
32875
|
const outcome = await Promise.race([
|
|
32839
32876
|
promptRpc.then((value) => {
|
|
@@ -32854,9 +32891,11 @@ function createExecutorPrompt({
|
|
|
32854
32891
|
const prompt = async (input2) => {
|
|
32855
32892
|
failIfDisposed();
|
|
32856
32893
|
const started = requireStarted();
|
|
32894
|
+
let record2;
|
|
32857
32895
|
const settle2 = (rest) => settleTurn({
|
|
32858
32896
|
expectedGeneration: started.generation,
|
|
32859
32897
|
expectedSessionId: started.sessionId,
|
|
32898
|
+
record: record2,
|
|
32860
32899
|
...rest
|
|
32861
32900
|
});
|
|
32862
32901
|
let turnId;
|
|
@@ -32869,6 +32908,17 @@ function createExecutorPrompt({
|
|
|
32869
32908
|
randomId
|
|
32870
32909
|
);
|
|
32871
32910
|
shared.promptsInFlight += 1;
|
|
32911
|
+
record2 = promptResults.add(
|
|
32912
|
+
{
|
|
32913
|
+
promptId: randomId(),
|
|
32914
|
+
sessionId: started.sessionId,
|
|
32915
|
+
generation: started.generation,
|
|
32916
|
+
turnId
|
|
32917
|
+
},
|
|
32918
|
+
() => {
|
|
32919
|
+
finishPrompt();
|
|
32920
|
+
}
|
|
32921
|
+
);
|
|
32872
32922
|
shared.activeTurnId = turnId;
|
|
32873
32923
|
shared.status = "running";
|
|
32874
32924
|
if (shared.promptsInFlight === 1) {
|
|
@@ -32885,6 +32935,42 @@ function createExecutorPrompt({
|
|
|
32885
32935
|
threadMutex.release();
|
|
32886
32936
|
}
|
|
32887
32937
|
const promptParts = input2.prompt ?? (input2.text !== void 0 ? [{ type: "text", text: input2.text }] : [{ type: "text", text: "" }]);
|
|
32938
|
+
let contextWindow;
|
|
32939
|
+
const finishPrompt = () => {
|
|
32940
|
+
if (!isLive(started.generation) || record2.finished) throw new AcpExecutorDisposedError();
|
|
32941
|
+
const response2 = record2.response;
|
|
32942
|
+
if (record2.interrupted || response2 === void 0) {
|
|
32943
|
+
settle2({ turnId, stopReason: "cancelled", state: "cancelled" });
|
|
32944
|
+
return { threadId: options.threadId, turnId, stopReason: "cancelled" };
|
|
32945
|
+
}
|
|
32946
|
+
const stopReason = hooks.completedStopReason?.(response2) ?? response2.stopReason;
|
|
32947
|
+
if (contextWindow !== void 0) {
|
|
32948
|
+
emit({
|
|
32949
|
+
type: "thread.token-usage.updated",
|
|
32950
|
+
...stamp(),
|
|
32951
|
+
provider: options.provider,
|
|
32952
|
+
threadId: options.threadId,
|
|
32953
|
+
turnId,
|
|
32954
|
+
payload: {
|
|
32955
|
+
usage: {
|
|
32956
|
+
usedTokens: contextWindow.usedTokens,
|
|
32957
|
+
...contextWindow.maxTokens === void 0 ? {} : { maxTokens: contextWindow.maxTokens }
|
|
32958
|
+
}
|
|
32959
|
+
}
|
|
32960
|
+
});
|
|
32961
|
+
}
|
|
32962
|
+
settle2({
|
|
32963
|
+
turnId,
|
|
32964
|
+
stopReason,
|
|
32965
|
+
state: response2.stopReason === "cancelled" ? "cancelled" : "completed"
|
|
32966
|
+
});
|
|
32967
|
+
return {
|
|
32968
|
+
threadId: options.threadId,
|
|
32969
|
+
turnId,
|
|
32970
|
+
stopReason,
|
|
32971
|
+
...response2.usage !== void 0 && response2.usage !== null ? { usage: response2.usage } : {}
|
|
32972
|
+
};
|
|
32973
|
+
};
|
|
32888
32974
|
await promptMutex.acquire();
|
|
32889
32975
|
let response;
|
|
32890
32976
|
try {
|
|
@@ -32899,6 +32985,7 @@ function createExecutorPrompt({
|
|
|
32899
32985
|
expectedGeneration: started.generation
|
|
32900
32986
|
});
|
|
32901
32987
|
}
|
|
32988
|
+
failIfDisposed();
|
|
32902
32989
|
if (isStale()) {
|
|
32903
32990
|
settle2({ turnId, stopReason: "cancelled", state: "cancelled" });
|
|
32904
32991
|
return { threadId: options.threadId, turnId, stopReason: "cancelled" };
|
|
@@ -32906,10 +32993,15 @@ function createExecutorPrompt({
|
|
|
32906
32993
|
closeActiveAssistantSegment(turnId);
|
|
32907
32994
|
let written = false;
|
|
32908
32995
|
try {
|
|
32909
|
-
response = await sendPromptRpc(
|
|
32910
|
-
|
|
32911
|
-
|
|
32912
|
-
|
|
32996
|
+
response = await sendPromptRpc(
|
|
32997
|
+
started.sessionId,
|
|
32998
|
+
promptParts,
|
|
32999
|
+
() => {
|
|
33000
|
+
written = true;
|
|
33001
|
+
input2.onDispatched?.(turnId);
|
|
33002
|
+
},
|
|
33003
|
+
record2
|
|
33004
|
+
);
|
|
32913
33005
|
} catch (error62) {
|
|
32914
33006
|
if (shared.disposed) {
|
|
32915
33007
|
throw new AcpExecutorDisposedError();
|
|
@@ -32948,8 +33040,7 @@ function createExecutorPrompt({
|
|
|
32948
33040
|
if (turnId === void 0) {
|
|
32949
33041
|
throw new AcpExecutorError("internal", "ACP prompt settled without a turn id");
|
|
32950
33042
|
}
|
|
32951
|
-
|
|
32952
|
-
let contextWindow;
|
|
33043
|
+
if (record2.finished) throw new AcpExecutorDisposedError();
|
|
32953
33044
|
if (hooks.readContextWindow !== void 0) {
|
|
32954
33045
|
try {
|
|
32955
33046
|
contextWindow = await hooks.readContextWindow({
|
|
@@ -32960,43 +33051,6 @@ function createExecutorPrompt({
|
|
|
32960
33051
|
contextWindow = void 0;
|
|
32961
33052
|
}
|
|
32962
33053
|
}
|
|
32963
|
-
const finishPrompt = () => {
|
|
32964
|
-
if (interruptedTurnIds.has(settledTurnId)) {
|
|
32965
|
-
settle2({ turnId: settledTurnId, stopReason: "cancelled", state: "cancelled" });
|
|
32966
|
-
return {
|
|
32967
|
-
threadId: options.threadId,
|
|
32968
|
-
turnId: settledTurnId,
|
|
32969
|
-
stopReason: "cancelled"
|
|
32970
|
-
};
|
|
32971
|
-
}
|
|
32972
|
-
const stopReason = hooks.completedStopReason?.(response) ?? response.stopReason;
|
|
32973
|
-
if (contextWindow !== void 0) {
|
|
32974
|
-
emit({
|
|
32975
|
-
type: "thread.token-usage.updated",
|
|
32976
|
-
...stamp(),
|
|
32977
|
-
provider: options.provider,
|
|
32978
|
-
threadId: options.threadId,
|
|
32979
|
-
turnId: settledTurnId,
|
|
32980
|
-
payload: {
|
|
32981
|
-
usage: {
|
|
32982
|
-
usedTokens: contextWindow.usedTokens,
|
|
32983
|
-
...contextWindow.maxTokens === void 0 ? {} : { maxTokens: contextWindow.maxTokens }
|
|
32984
|
-
}
|
|
32985
|
-
}
|
|
32986
|
-
});
|
|
32987
|
-
}
|
|
32988
|
-
settle2({
|
|
32989
|
-
turnId: settledTurnId,
|
|
32990
|
-
stopReason,
|
|
32991
|
-
state: response.stopReason === "cancelled" ? "cancelled" : "completed"
|
|
32992
|
-
});
|
|
32993
|
-
return {
|
|
32994
|
-
threadId: options.threadId,
|
|
32995
|
-
turnId: settledTurnId,
|
|
32996
|
-
stopReason,
|
|
32997
|
-
...response.usage !== void 0 && response.usage !== null ? { usage: response.usage } : {}
|
|
32998
|
-
};
|
|
32999
|
-
};
|
|
33000
33054
|
if (threadMutex.tryAcquire()) {
|
|
33001
33055
|
try {
|
|
33002
33056
|
return finishPrompt();
|
|
@@ -33014,6 +33068,91 @@ function createExecutorPrompt({
|
|
|
33014
33068
|
return { sendPromptRpc, prompt };
|
|
33015
33069
|
}
|
|
33016
33070
|
|
|
33071
|
+
// ../../packages/ycodium-acp-executor/src/executor/prompt-results.ts
|
|
33072
|
+
function createPromptResults({
|
|
33073
|
+
options,
|
|
33074
|
+
shared
|
|
33075
|
+
}) {
|
|
33076
|
+
const prompts = /* @__PURE__ */ new Map();
|
|
33077
|
+
const add = (identity, finish) => {
|
|
33078
|
+
const { promise: done, resolve: resolve2 } = Promise.withResolvers();
|
|
33079
|
+
const record2 = {
|
|
33080
|
+
...identity,
|
|
33081
|
+
finish,
|
|
33082
|
+
done,
|
|
33083
|
+
resolve: resolve2,
|
|
33084
|
+
rejected: false,
|
|
33085
|
+
interrupted: false,
|
|
33086
|
+
finished: false
|
|
33087
|
+
};
|
|
33088
|
+
prompts.set(record2.promptId, record2);
|
|
33089
|
+
return record2;
|
|
33090
|
+
};
|
|
33091
|
+
const receive = (promptId, response) => {
|
|
33092
|
+
const record2 = prompts.get(promptId);
|
|
33093
|
+
if (!record2 || record2.finished || record2.rejected || record2.response !== void 0) return;
|
|
33094
|
+
if (shared.disposed || shared.generation !== record2.generation || shared.sessionId !== record2.sessionId)
|
|
33095
|
+
return;
|
|
33096
|
+
record2.response = response;
|
|
33097
|
+
};
|
|
33098
|
+
const reject = (promptId) => {
|
|
33099
|
+
const record2 = prompts.get(promptId);
|
|
33100
|
+
if (record2 && record2.response === void 0) record2.rejected = true;
|
|
33101
|
+
};
|
|
33102
|
+
const stop = (turnId) => {
|
|
33103
|
+
for (const record2 of prompts.values()) {
|
|
33104
|
+
if (!record2.finished && (turnId === void 0 || record2.turnId === turnId) && record2.response === void 0) {
|
|
33105
|
+
record2.interrupted = true;
|
|
33106
|
+
}
|
|
33107
|
+
}
|
|
33108
|
+
};
|
|
33109
|
+
const complete = (record2) => {
|
|
33110
|
+
record2.finished = true;
|
|
33111
|
+
record2.resolve();
|
|
33112
|
+
};
|
|
33113
|
+
const hasInterrupted = (turnId) => [...prompts.values()].some((record2) => record2.turnId === turnId && record2.interrupted);
|
|
33114
|
+
const forget = (turnId) => {
|
|
33115
|
+
for (const [id, record2] of prompts) {
|
|
33116
|
+
if (record2.turnId === turnId) {
|
|
33117
|
+
complete(record2);
|
|
33118
|
+
prompts.delete(id);
|
|
33119
|
+
}
|
|
33120
|
+
}
|
|
33121
|
+
};
|
|
33122
|
+
const wait = async (turnId) => {
|
|
33123
|
+
const claimed = [...prompts.values()].filter(
|
|
33124
|
+
(record2) => !record2.finished && record2.response !== void 0 && (turnId === void 0 || record2.turnId === turnId)
|
|
33125
|
+
);
|
|
33126
|
+
if (claimed.length === 0) return;
|
|
33127
|
+
let timer;
|
|
33128
|
+
try {
|
|
33129
|
+
const drained = await Promise.race([
|
|
33130
|
+
Promise.all(claimed.map((record2) => record2.done)).then(() => true),
|
|
33131
|
+
new Promise((resolve2) => {
|
|
33132
|
+
timer = setTimeout(() => resolve2(false), options.resultDrainTimeoutMs ?? 2e3);
|
|
33133
|
+
})
|
|
33134
|
+
]);
|
|
33135
|
+
if (drained) return;
|
|
33136
|
+
options.log?.warn?.("ACP result settlement timed out", { threadId: options.threadId });
|
|
33137
|
+
for (const record2 of claimed) if (!record2.finished) record2.finish();
|
|
33138
|
+
} finally {
|
|
33139
|
+
clearTimeout(timer);
|
|
33140
|
+
}
|
|
33141
|
+
};
|
|
33142
|
+
const finishUnreceived = () => {
|
|
33143
|
+
const claimedTurns = new Set(
|
|
33144
|
+
[...prompts.values()].filter((record2) => !record2.finished && record2.response !== void 0).map((record2) => record2.turnId)
|
|
33145
|
+
);
|
|
33146
|
+
for (const record2 of prompts.values()) {
|
|
33147
|
+
if (!record2.finished && record2.response === void 0) {
|
|
33148
|
+
if (claimedTurns.has(record2.turnId)) record2.finish();
|
|
33149
|
+
else complete(record2);
|
|
33150
|
+
}
|
|
33151
|
+
}
|
|
33152
|
+
};
|
|
33153
|
+
return { add, receive, reject, stop, complete, hasInterrupted, forget, wait, finishUnreceived };
|
|
33154
|
+
}
|
|
33155
|
+
|
|
33017
33156
|
// ../../packages/ycodium-acp-executor/src/user-input-pending.ts
|
|
33018
33157
|
var userInputAnswerOptionId = (question, answers) => {
|
|
33019
33158
|
const answer = answers[question.id];
|
|
@@ -33320,7 +33459,7 @@ function createExecutorRuntime({
|
|
|
33320
33459
|
turnId: () => shared.activeTurnId
|
|
33321
33460
|
});
|
|
33322
33461
|
const failIfDisposed = () => {
|
|
33323
|
-
if (shared.disposed) {
|
|
33462
|
+
if (shared.disposed || shared.disposing) {
|
|
33324
33463
|
throw new AcpExecutorDisposedError();
|
|
33325
33464
|
}
|
|
33326
33465
|
};
|
|
@@ -33837,6 +33976,7 @@ function createExecutorSettlement({
|
|
|
33837
33976
|
const abortPendingSettlement = (reason, failureCategory) => {
|
|
33838
33977
|
const waiting = shared.pendingSettlement;
|
|
33839
33978
|
if (waiting === void 0) return;
|
|
33979
|
+
if (waiting.hasResult?.()) return;
|
|
33840
33980
|
shared.pendingSettlement = void 0;
|
|
33841
33981
|
waiting.settle({
|
|
33842
33982
|
error: withFailureCategory(
|
|
@@ -33858,6 +33998,7 @@ function createExecutorSettlement({
|
|
|
33858
33998
|
shared.pendingSettlement = void 0;
|
|
33859
33999
|
rememberSettledPromptKey(waiting.promptKey);
|
|
33860
34000
|
if (signal.outcome === "error") {
|
|
34001
|
+
waiting.onError?.();
|
|
33861
34002
|
waiting.settle({
|
|
33862
34003
|
error: withFailureCategory(
|
|
33863
34004
|
new AcpExecutorRequestError(
|
|
@@ -33868,8 +34009,10 @@ function createExecutorSettlement({
|
|
|
33868
34009
|
)
|
|
33869
34010
|
});
|
|
33870
34011
|
} else {
|
|
34012
|
+
const response = { stopReason: signal.stopReason ?? "end_turn" };
|
|
34013
|
+
waiting.onResponse?.(response);
|
|
33871
34014
|
waiting.settle({
|
|
33872
|
-
response
|
|
34015
|
+
response
|
|
33873
34016
|
});
|
|
33874
34017
|
}
|
|
33875
34018
|
return true;
|
|
@@ -34199,6 +34342,7 @@ function createAcpExecutor(options) {
|
|
|
34199
34342
|
const shared = {
|
|
34200
34343
|
generation: 0,
|
|
34201
34344
|
disposed: false,
|
|
34345
|
+
disposing: false,
|
|
34202
34346
|
status: "idle",
|
|
34203
34347
|
sessionId: void 0,
|
|
34204
34348
|
modelSelectionState: {
|
|
@@ -34286,6 +34430,7 @@ function createAcpExecutor(options) {
|
|
|
34286
34430
|
shared
|
|
34287
34431
|
});
|
|
34288
34432
|
const { rememberSettledPromptKey, abortPendingSettlement, settleFromNotification } = createExecutorSettlement({ hooks, shared });
|
|
34433
|
+
const promptResults = createPromptResults({ options, shared });
|
|
34289
34434
|
const connection = createAcpConnection({
|
|
34290
34435
|
readable: options.readable,
|
|
34291
34436
|
writable: options.writable,
|
|
@@ -34296,8 +34441,12 @@ function createAcpExecutor(options) {
|
|
|
34296
34441
|
});
|
|
34297
34442
|
},
|
|
34298
34443
|
// 窗口在应答帧到达的那一刻同步收掉:应答之后的通知是真输出,不能再丢。
|
|
34299
|
-
onResponse: (method) => {
|
|
34444
|
+
onResponse: ({ method, promptId }, outcome) => {
|
|
34300
34445
|
if (method === "session/load") shared.sessionLoadInFlight = false;
|
|
34446
|
+
if (promptId !== void 0) {
|
|
34447
|
+
if ("result" in outcome) promptResults.receive(promptId, outcome.result);
|
|
34448
|
+
else promptResults.reject(promptId);
|
|
34449
|
+
}
|
|
34301
34450
|
},
|
|
34302
34451
|
onNotification: (notification) => {
|
|
34303
34452
|
if (notification.method === "session/update") {
|
|
@@ -34362,6 +34511,7 @@ function createAcpExecutor(options) {
|
|
|
34362
34511
|
shared
|
|
34363
34512
|
});
|
|
34364
34513
|
const { sendPromptRpc, prompt } = createExecutorPrompt({
|
|
34514
|
+
promptResults,
|
|
34365
34515
|
isLive,
|
|
34366
34516
|
closeActiveAssistantSegment,
|
|
34367
34517
|
emit,
|
|
@@ -34381,6 +34531,7 @@ function createAcpExecutor(options) {
|
|
|
34381
34531
|
shared
|
|
34382
34532
|
});
|
|
34383
34533
|
const { cancel, compact, dispose } = createExecutorLifecycle({
|
|
34534
|
+
promptResults,
|
|
34384
34535
|
failIfDisposed,
|
|
34385
34536
|
requireStarted,
|
|
34386
34537
|
interruptedTurnIds,
|
|
@@ -34432,6 +34583,27 @@ function createAcpExecutor(options) {
|
|
|
34432
34583
|
};
|
|
34433
34584
|
}
|
|
34434
34585
|
|
|
34586
|
+
// ../../packages/ycodium-acp-executor/src/session-registry.ts
|
|
34587
|
+
function createAcpSessionRegistry(threads, stopBooked2) {
|
|
34588
|
+
const requireThread = (threadId) => {
|
|
34589
|
+
const booked = threads.get(threadId);
|
|
34590
|
+
if (!booked) throw new Error(`unknown thread ${threadId}`);
|
|
34591
|
+
if (booked.closing) throw new Error(`thread ${threadId} is closing`);
|
|
34592
|
+
return booked;
|
|
34593
|
+
};
|
|
34594
|
+
const stopSession = (threadId, booked = threads.get(threadId)) => {
|
|
34595
|
+
if (!booked) return Promise.resolve();
|
|
34596
|
+
booked.closing ??= Promise.resolve().then(() => stopBooked2(booked)).then(() => {
|
|
34597
|
+
if (threads.get(threadId) === booked) threads.delete(threadId);
|
|
34598
|
+
});
|
|
34599
|
+
return booked.closing;
|
|
34600
|
+
};
|
|
34601
|
+
const stopAll = () => Promise.all([...threads].map(([threadId, booked]) => stopSession(threadId, booked))).then(
|
|
34602
|
+
() => void 0
|
|
34603
|
+
);
|
|
34604
|
+
return { requireThread, stopSession, stopAll };
|
|
34605
|
+
}
|
|
34606
|
+
|
|
34435
34607
|
// ../../packages/ycodium-acp-executor/src/prompt-dispatch.ts
|
|
34436
34608
|
var dispatchAcpPrompt = (executor, input2) => {
|
|
34437
34609
|
const { promise: dispatched, resolve: resolve2 } = Promise.withResolvers();
|
|
@@ -35312,11 +35484,8 @@ var createDshInstance = (config2, host) => {
|
|
|
35312
35484
|
const threads = /* @__PURE__ */ new Map();
|
|
35313
35485
|
const skillOverlayChecks = /* @__PURE__ */ new Map();
|
|
35314
35486
|
let disposed = false;
|
|
35315
|
-
|
|
35316
|
-
|
|
35317
|
-
if (!booked) throw new Error(`unknown thread ${threadId}`);
|
|
35318
|
-
return booked;
|
|
35319
|
-
};
|
|
35487
|
+
let disposeTask;
|
|
35488
|
+
const { requireThread, stopSession, stopAll } = createAcpSessionRegistry(threads, stopBooked);
|
|
35320
35489
|
const instance = {
|
|
35321
35490
|
probe: async () => {
|
|
35322
35491
|
if (recipe.binaryPath.length === 0) {
|
|
@@ -35366,8 +35535,8 @@ var createDshInstance = (config2, host) => {
|
|
|
35366
35535
|
if (cwd.trim() === "") throw new Error("workspace path missing");
|
|
35367
35536
|
const existing = threads.get(input2.threadId);
|
|
35368
35537
|
if (existing !== void 0) {
|
|
35369
|
-
await
|
|
35370
|
-
|
|
35538
|
+
await stopSession(input2.threadId, existing);
|
|
35539
|
+
if (disposed) throw new Error("instance disposed");
|
|
35371
35540
|
throwIfStartAborted(signal);
|
|
35372
35541
|
}
|
|
35373
35542
|
const env = buildSpawnEnv(recipe, resolveHomePath(recipe.homePath), input2.nativeModeId);
|
|
@@ -35495,7 +35664,7 @@ var createDshInstance = (config2, host) => {
|
|
|
35495
35664
|
},
|
|
35496
35665
|
interruptTurn: async (threadId, turnId) => {
|
|
35497
35666
|
const booked = threads.get(threadId);
|
|
35498
|
-
if (booked === void 0) return;
|
|
35667
|
+
if (booked === void 0 || booked.closing) return;
|
|
35499
35668
|
host.log.info("interrupt turn", { threadId, turnId });
|
|
35500
35669
|
await booked.executor.cancel(turnId);
|
|
35501
35670
|
await yieldTick();
|
|
@@ -35529,12 +35698,7 @@ var createDshInstance = (config2, host) => {
|
|
|
35529
35698
|
updatedAt: nowIso()
|
|
35530
35699
|
};
|
|
35531
35700
|
},
|
|
35532
|
-
stopSession:
|
|
35533
|
-
const booked = threads.get(threadId);
|
|
35534
|
-
if (booked === void 0) return;
|
|
35535
|
-
threads.delete(threadId);
|
|
35536
|
-
await stopBooked(booked);
|
|
35537
|
-
},
|
|
35701
|
+
stopSession: (threadId) => stopSession(threadId),
|
|
35538
35702
|
readThread: async (threadId) => {
|
|
35539
35703
|
const booked = requireThread(threadId);
|
|
35540
35704
|
return { threadId, turns: booked.turns };
|
|
@@ -35548,13 +35712,14 @@ var createDshInstance = (config2, host) => {
|
|
|
35548
35712
|
fetch: host.fetch
|
|
35549
35713
|
}),
|
|
35550
35714
|
continuationKey: dshContinuationKey(recipe.homePath),
|
|
35551
|
-
dispose:
|
|
35552
|
-
if (
|
|
35715
|
+
dispose: () => {
|
|
35716
|
+
if (disposeTask) return disposeTask;
|
|
35553
35717
|
disposed = true;
|
|
35554
|
-
|
|
35555
|
-
|
|
35556
|
-
|
|
35557
|
-
|
|
35718
|
+
disposeTask = (async () => {
|
|
35719
|
+
await stopAll();
|
|
35720
|
+
events.close();
|
|
35721
|
+
})();
|
|
35722
|
+
return disposeTask;
|
|
35558
35723
|
}
|
|
35559
35724
|
};
|
|
35560
35725
|
return instance;
|
|
@@ -35572,7 +35737,7 @@ var executors = [
|
|
|
35572
35737
|
];
|
|
35573
35738
|
var index_default = definePlugin({
|
|
35574
35739
|
id: "agent-dsh",
|
|
35575
|
-
apiVersion:
|
|
35740
|
+
apiVersion: 15,
|
|
35576
35741
|
executors,
|
|
35577
35742
|
activate(ctx) {
|
|
35578
35743
|
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.
|
|
3
|
+
"version": "0.2.3158",
|
|
4
4
|
"description": "DeepSeek Harness executor: dsh CLI over Agent Client Protocol stdio.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ycodium",
|
|
@@ -22,8 +22,8 @@
|
|
|
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.
|
|
26
|
-
"ycodium-acp-executor": "0.2.
|
|
25
|
+
"@ycodium-ai/plugin-api": "0.2.3158",
|
|
26
|
+
"ycodium-acp-executor": "0.2.3158",
|
|
27
27
|
"ycodium-executor-testing": "0.0.0"
|
|
28
28
|
},
|
|
29
29
|
"ycodium": {
|