@ycodium-ai/agent-fake 0.2.2800 → 0.2.2834
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 +15 -13
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -346,7 +346,7 @@ var createFakeInstance = (config, host) => {
|
|
|
346
346
|
const streamOptions = parseStreamOptions(config);
|
|
347
347
|
const pendingDecisions = /* @__PURE__ */ new Map();
|
|
348
348
|
let seq = 0;
|
|
349
|
-
|
|
349
|
+
const inflight = /* @__PURE__ */ new Map();
|
|
350
350
|
let disposed = false;
|
|
351
351
|
const nextId = (prefix) => `${prefix}-fake-${++seq}-${NodeCrypto.randomUUID()}`;
|
|
352
352
|
const now = () => (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -383,7 +383,9 @@ var createFakeInstance = (config, host) => {
|
|
|
383
383
|
errorMessage === void 0 ? { state } : { state, errorMessage },
|
|
384
384
|
{ turnId }
|
|
385
385
|
);
|
|
386
|
-
inflight
|
|
386
|
+
if (inflight.get(booked.session.threadId)?.turnId === turnId) {
|
|
387
|
+
inflight.delete(booked.session.threadId);
|
|
388
|
+
}
|
|
387
389
|
};
|
|
388
390
|
const runMcpSendScript = async (booked, input) => {
|
|
389
391
|
let args;
|
|
@@ -631,13 +633,13 @@ var createFakeInstance = (config, host) => {
|
|
|
631
633
|
sendTurn: async (input, signal) => {
|
|
632
634
|
if (disposed) throw new Error("instance disposed");
|
|
633
635
|
const booked = requireThread(input.threadId);
|
|
634
|
-
if (inflight
|
|
636
|
+
if (inflight.has(input.threadId)) throw new Error("turn already in flight");
|
|
635
637
|
const turnId = input.expectedTurnId ?? nextId("turn");
|
|
636
638
|
const turnAbort = new AbortController();
|
|
637
639
|
const abortTurn = () => turnAbort.abort();
|
|
638
640
|
if (signal?.aborted === true) abortTurn();
|
|
639
641
|
signal?.addEventListener("abort", abortTurn);
|
|
640
|
-
inflight
|
|
642
|
+
inflight.set(input.threadId, { turnId, abort: abortTurn });
|
|
641
643
|
booked.session = {
|
|
642
644
|
...booked.session,
|
|
643
645
|
status: "running",
|
|
@@ -649,7 +651,7 @@ var createFakeInstance = (config, host) => {
|
|
|
649
651
|
const run = () => runScriptedTurn(booked, input.threadId, turnId, turnAbort.signal, input.input);
|
|
650
652
|
const settle = () => {
|
|
651
653
|
signal?.removeEventListener("abort", abortTurn);
|
|
652
|
-
if (inflight?.turnId === turnId) inflight
|
|
654
|
+
if (inflight.get(input.threadId)?.turnId === turnId) inflight.delete(input.threadId);
|
|
653
655
|
};
|
|
654
656
|
if (script === "approval-tool" || script === "stream" || script === "mcp-send") {
|
|
655
657
|
signal?.removeEventListener("abort", abortTurn);
|
|
@@ -664,11 +666,11 @@ var createFakeInstance = (config, host) => {
|
|
|
664
666
|
}
|
|
665
667
|
},
|
|
666
668
|
interruptTurn: async (threadId, turnId) => {
|
|
667
|
-
|
|
668
|
-
if (
|
|
669
|
-
if (turnId !== void 0 &&
|
|
670
|
-
host.log.info("interrupt turn", { threadId, turnId:
|
|
671
|
-
|
|
669
|
+
const running = inflight.get(threadId);
|
|
670
|
+
if (running === void 0) return;
|
|
671
|
+
if (turnId !== void 0 && running.turnId !== turnId) return;
|
|
672
|
+
host.log.info("interrupt turn", { threadId, turnId: running.turnId });
|
|
673
|
+
running.abort();
|
|
672
674
|
},
|
|
673
675
|
respondToRequest: async (threadId, requestId, decision) => {
|
|
674
676
|
host.log.info("respondToRequest", { threadId, requestId, decision });
|
|
@@ -682,7 +684,7 @@ var createFakeInstance = (config, host) => {
|
|
|
682
684
|
host.log.info("respondToUserInput ignored");
|
|
683
685
|
},
|
|
684
686
|
stopSession: async (threadId) => {
|
|
685
|
-
|
|
687
|
+
inflight.get(threadId)?.abort();
|
|
686
688
|
threads.delete(threadId);
|
|
687
689
|
},
|
|
688
690
|
readThread: async (threadId) => {
|
|
@@ -693,8 +695,8 @@ var createFakeInstance = (config, host) => {
|
|
|
693
695
|
usage: createFakeUsage({ instanceId: host.instanceId, script: parseUsageScript(config) }),
|
|
694
696
|
dispose: async () => {
|
|
695
697
|
disposed = true;
|
|
696
|
-
inflight
|
|
697
|
-
inflight
|
|
698
|
+
for (const running of inflight.values()) running.abort();
|
|
699
|
+
inflight.clear();
|
|
698
700
|
for (const settle of pendingDecisions.values()) settle("cancel");
|
|
699
701
|
pendingDecisions.clear();
|
|
700
702
|
threads.clear();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ycodium-ai/agent-fake",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2834",
|
|
4
4
|
"description": "Minimal fake executor for plugin authors and host orchestration tests.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ycodium",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"@types/node": "24.12.4",
|
|
22
22
|
"esbuild": "0.28.1",
|
|
23
23
|
"vite-plus": "0.2.2",
|
|
24
|
-
"ycodium-
|
|
25
|
-
"
|
|
24
|
+
"@ycodium-ai/plugin-api": "0.2.2834",
|
|
25
|
+
"ycodium-executor-testing": "0.0.0"
|
|
26
26
|
},
|
|
27
27
|
"ycodium": {
|
|
28
28
|
"plugin": "./dist/index.js",
|