@yanlinglabs/winter-agent-sdk 0.0.34 → 0.0.36
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 +43 -4
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -630,6 +630,15 @@ function makeHookHandler(hooks, cwd, abortController) {
|
|
|
630
630
|
function isModelFamilyListing(payload) {
|
|
631
631
|
return typeof payload === "object" && payload !== null && Array.isArray(payload.families);
|
|
632
632
|
}
|
|
633
|
+
function abortedBeforeSpawn() {
|
|
634
|
+
return {
|
|
635
|
+
stdin: { write() {}, end() {} },
|
|
636
|
+
stdout: async function* () {}(),
|
|
637
|
+
kill() {},
|
|
638
|
+
exited: Promise.resolve({ code: null, signal: "SIGTERM" }),
|
|
639
|
+
pid: null
|
|
640
|
+
};
|
|
641
|
+
}
|
|
633
642
|
function query(args) {
|
|
634
643
|
const { prompt, options } = args;
|
|
635
644
|
if (options.canUseTool) {
|
|
@@ -735,8 +744,33 @@ function query(args) {
|
|
|
735
744
|
env: withTestKeychainRedirect(options.env) ?? process.env,
|
|
736
745
|
...options.abortController ? { signal: options.abortController.signal } : {}
|
|
737
746
|
};
|
|
738
|
-
const proc = (options.spawnClaudeCodeProcess ?? defaultSpawn)(spawnOptions);
|
|
747
|
+
const proc = options.abortController?.signal.aborted === true ? abortedBeforeSpawn() : (options.spawnClaudeCodeProcess ?? defaultSpawn)(spawnOptions);
|
|
739
748
|
const maxBufferSize = options.maxBufferSize ?? DEFAULT_MAX_BUFFER_SIZE;
|
|
749
|
+
let killRequested = false;
|
|
750
|
+
let spawnKillEscalation;
|
|
751
|
+
const killForAbort = () => {
|
|
752
|
+
if (killRequested)
|
|
753
|
+
return;
|
|
754
|
+
killRequested = true;
|
|
755
|
+
try {
|
|
756
|
+
proc.kill();
|
|
757
|
+
} catch {}
|
|
758
|
+
spawnKillEscalation = setTimeout(() => {
|
|
759
|
+
try {
|
|
760
|
+
proc.kill("SIGKILL");
|
|
761
|
+
} catch {}
|
|
762
|
+
}, KILL_GRACE_MS);
|
|
763
|
+
spawnKillEscalation.unref?.();
|
|
764
|
+
const clear = () => clearTimeout(spawnKillEscalation);
|
|
765
|
+
proc.exited.then(clear, clear);
|
|
766
|
+
};
|
|
767
|
+
let removeSpawnAbortListener = () => {};
|
|
768
|
+
if (options.abortController !== undefined && options.abortController.signal.aborted !== true) {
|
|
769
|
+
const signal = options.abortController.signal;
|
|
770
|
+
signal.addEventListener("abort", killForAbort, { once: true });
|
|
771
|
+
removeSpawnAbortListener = () => signal.removeEventListener("abort", killForAbort);
|
|
772
|
+
proc.exited.then(removeSpawnAbortListener, removeSpawnAbortListener);
|
|
773
|
+
}
|
|
740
774
|
const pendingHostRequests = new Map;
|
|
741
775
|
let generatorTerminated = false;
|
|
742
776
|
function sendControlRequest(subtype, payload) {
|
|
@@ -877,9 +911,15 @@ function query(args) {
|
|
|
877
911
|
if (aborted)
|
|
878
912
|
return;
|
|
879
913
|
aborted = true;
|
|
914
|
+
if (killRequested)
|
|
915
|
+
return;
|
|
916
|
+
killRequested = true;
|
|
880
917
|
proc.kill();
|
|
881
918
|
killTimer = setTimeout(() => proc.kill("SIGKILL"), KILL_GRACE_MS);
|
|
882
919
|
killTimer.unref?.();
|
|
920
|
+
const timer = killTimer;
|
|
921
|
+
const clear = () => clearTimeout(timer);
|
|
922
|
+
proc.exited.then(clear, clear);
|
|
883
923
|
};
|
|
884
924
|
options.abortController?.signal.addEventListener("abort", onAbort);
|
|
885
925
|
try {
|
|
@@ -979,8 +1019,7 @@ function query(args) {
|
|
|
979
1019
|
} finally {
|
|
980
1020
|
generatorTerminated = true;
|
|
981
1021
|
options.abortController?.signal.removeEventListener("abort", onAbort);
|
|
982
|
-
|
|
983
|
-
clearTimeout(killTimer);
|
|
1022
|
+
removeSpawnAbortListener();
|
|
984
1023
|
try {
|
|
985
1024
|
proc.stdin.end();
|
|
986
1025
|
} catch {}
|
|
@@ -1136,7 +1175,7 @@ function withTestKeychainRedirect(env) {
|
|
|
1136
1175
|
return { ...env, [TEST_KEYCHAIN_ENV]: redirect };
|
|
1137
1176
|
}
|
|
1138
1177
|
// src/version.ts
|
|
1139
|
-
var SDK_VERSION = "0.0.
|
|
1178
|
+
var SDK_VERSION = "0.0.36";
|
|
1140
1179
|
// src/paths/project-key.ts
|
|
1141
1180
|
var TRANSCRIPT_PROJECT_KEY_MAX_LENGTH = 64;
|
|
1142
1181
|
var VENDOR_PROJECT_KEY_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yanlinglabs/winter-agent-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.36",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -45,15 +45,15 @@
|
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@yanlinglabs/winter-provider-catalog": "0.0.
|
|
48
|
+
"@yanlinglabs/winter-provider-catalog": "0.0.36"
|
|
49
49
|
},
|
|
50
50
|
"optionalDependencies": {
|
|
51
|
-
"@yanlinglabs/winter-agent-sdk-darwin-arm64": "0.0.
|
|
51
|
+
"@yanlinglabs/winter-agent-sdk-darwin-arm64": "0.0.36"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/node": "^26.4.0",
|
|
55
|
-
"@yanlinglabs/winter-
|
|
56
|
-
"@yanlinglabs/winter-
|
|
55
|
+
"@yanlinglabs/winter-conformance": "0.0.36",
|
|
56
|
+
"@yanlinglabs/winter-agent-runtime": "0.0.36"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {}
|
|
59
59
|
}
|