naiad-cli 0.2.35 → 0.2.37
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.
|
@@ -7,6 +7,7 @@ export class SessionUploader {
|
|
|
7
7
|
sessionId;
|
|
8
8
|
sessionDir;
|
|
9
9
|
pollTimer = null;
|
|
10
|
+
finalized = false;
|
|
10
11
|
constructor(client, sessionId, sessionDir) {
|
|
11
12
|
this.client = client;
|
|
12
13
|
this.sessionId = sessionId;
|
|
@@ -23,6 +24,8 @@ export class SessionUploader {
|
|
|
23
24
|
await this.checkAndUpload();
|
|
24
25
|
}
|
|
25
26
|
async checkAndUpload() {
|
|
27
|
+
if (this.finalized)
|
|
28
|
+
return;
|
|
26
29
|
try {
|
|
27
30
|
const files = readdirSync(this.sessionDir).filter((f) => f.endsWith(".jsonl"));
|
|
28
31
|
for (const file of files) {
|
|
@@ -62,8 +65,18 @@ export class SessionUploader {
|
|
|
62
65
|
throw new Error(`Chunk upload failed: ${res.status}`);
|
|
63
66
|
}
|
|
64
67
|
}
|
|
65
|
-
// Finalize
|
|
66
|
-
|
|
68
|
+
// Finalize — treat 409 (chunk count mismatch from prior finalize) as already done
|
|
69
|
+
try {
|
|
70
|
+
await this.client.finalizeSession(this.sessionId, totalBytes, chunkCount, fileHash);
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
if (err.message?.includes("409")) {
|
|
74
|
+
this.finalized = true;
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
throw err;
|
|
78
|
+
}
|
|
79
|
+
this.finalized = true;
|
|
67
80
|
}
|
|
68
81
|
}
|
|
69
82
|
//# sourceMappingURL=session-upload.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-upload.js","sourceRoot":"","sources":["../../src/sync/session-upload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACzD,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,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;QACtF,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,IAAI,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBACjC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;gBACtB,OAAO;YACT,CAAC;YACD,MAAM,GAAG,CAAC;QACZ,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -326,6 +326,13 @@ export default function (pi: ExtensionAPI) {
|
|
|
326
326
|
body.reasoning_effort = effort;
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
+
// Combine caller abort signal with a 5-minute timeout to prevent infinite hangs
|
|
330
|
+
const timeoutMs = 5 * 60 * 1000;
|
|
331
|
+
const timeoutSignal = AbortSignal.timeout(timeoutMs);
|
|
332
|
+
const combinedSignal = options?.signal
|
|
333
|
+
? AbortSignal.any([options.signal, timeoutSignal])
|
|
334
|
+
: timeoutSignal;
|
|
335
|
+
|
|
329
336
|
const res = await fetch(`${inferenceUrl}/v1/chat/completions`, {
|
|
330
337
|
method: "POST",
|
|
331
338
|
headers: {
|
|
@@ -335,7 +342,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
335
342
|
"X-Naiad-Session-Id": sessionId,
|
|
336
343
|
},
|
|
337
344
|
body: JSON.stringify(body),
|
|
338
|
-
signal:
|
|
345
|
+
signal: combinedSignal,
|
|
339
346
|
});
|
|
340
347
|
|
|
341
348
|
if (!res.ok) {
|
|
@@ -875,7 +882,7 @@ When you're done, provide a clear, actionable summary the caller can act on.`;
|
|
|
875
882
|
|
|
876
883
|
// Set git identity and commit
|
|
877
884
|
execFileSync("git", ["config", "user.name", "naiad-bot"]);
|
|
878
|
-
execFileSync("git", ["config", "user.email", "bot@
|
|
885
|
+
execFileSync("git", ["config", "user.email", "266131081+naiad-bot@users.noreply.github.com"]);
|
|
879
886
|
execFileSync("git", ["commit", "-m", params.message]);
|
|
880
887
|
|
|
881
888
|
const headSha = execFileSync("git", ["rev-parse", "HEAD"]).toString().trim();
|
|
@@ -928,27 +935,33 @@ When you're done, provide a clear, actionable summary the caller can act on.`;
|
|
|
928
935
|
|
|
929
936
|
const basicAuth = Buffer.from(`x-access-token:${pushToken}`).toString("base64");
|
|
930
937
|
|
|
931
|
-
// Clean-room push
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
"
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
938
|
+
// Clean-room push — env vars (GIT_CONFIG_NOSYSTEM, GIT_CONFIG_GLOBAL,
|
|
939
|
+
// GIT_CONFIG) already neutralize system/global/local config includes.
|
|
940
|
+
try {
|
|
941
|
+
execFileSync(
|
|
942
|
+
"git",
|
|
943
|
+
[
|
|
944
|
+
"-c", "core.hooksPath=/dev/null",
|
|
945
|
+
"-c", "credential.helper=",
|
|
946
|
+
`-c`, `http.extraheader=Authorization: Basic ${basicAuth}`,
|
|
947
|
+
"push", pushUrl, `HEAD:refs/heads/${branch}`, "--no-force",
|
|
948
|
+
],
|
|
949
|
+
{
|
|
950
|
+
env: {
|
|
951
|
+
PATH: process.env.PATH,
|
|
952
|
+
HOME: process.env.HOME,
|
|
953
|
+
GIT_CONFIG_NOSYSTEM: "1",
|
|
954
|
+
GIT_CONFIG_GLOBAL: "/dev/null",
|
|
955
|
+
GIT_CONFIG: "/dev/null",
|
|
956
|
+
GIT_TERMINAL_PROMPT: "0",
|
|
957
|
+
},
|
|
949
958
|
},
|
|
950
|
-
|
|
951
|
-
)
|
|
959
|
+
);
|
|
960
|
+
} catch (pushErr: any) {
|
|
961
|
+
// Sanitize error — execFileSync includes the full command with credentials
|
|
962
|
+
const stderr = pushErr.stderr?.toString() || "";
|
|
963
|
+
throw new Error(`git push failed: ${stderr.replace(/Authorization:[^\s]*/g, "Authorization: [REDACTED]")}`);
|
|
964
|
+
}
|
|
952
965
|
|
|
953
966
|
// Post-push verification (defense-in-depth: server checks for merge commits)
|
|
954
967
|
const verifyResult = await callToolEndpoint("POST", "post-push-verify", {
|