@qoder-ai/qoder-agent-sdk 1.0.6 → 1.0.7
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/package.json +2 -2
- package/scripts/postinstall.cjs +62 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qoder-ai/qoder-agent-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "TypeScript SDK for building Qoder-powered coding agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -112,6 +112,6 @@
|
|
|
112
112
|
"typescript": "^5.7.0",
|
|
113
113
|
"zod": "^4.0.0"
|
|
114
114
|
},
|
|
115
|
-
"qoderCliVersion": "1.0.
|
|
115
|
+
"qoderCliVersion": "1.0.26",
|
|
116
116
|
"license": "SEE LICENSE IN LICENSE"
|
|
117
117
|
}
|
package/scripts/postinstall.cjs
CHANGED
|
@@ -31,6 +31,13 @@ const CN_PROD_DOWNLOAD_BASE_URL =
|
|
|
31
31
|
const CN_DEV_DOWNLOAD_BASE_URL =
|
|
32
32
|
'https://static.qoder.com.cn/qoder-cli-cn/dev/releases';
|
|
33
33
|
const LOG_PREFIX = '[@qoder-ai/qoder-agent-sdk]';
|
|
34
|
+
const WORKER_RUNTIME_ENTRY_NAMES = [
|
|
35
|
+
'qoder-worker-runtime.obf.mjs',
|
|
36
|
+
'qoder-worker-runtime.mjs',
|
|
37
|
+
];
|
|
38
|
+
const REQUIRED_WORKER_RUNTIME_ASSETS = [
|
|
39
|
+
path.join('vendor', 'ripgrep', 'x64-win32', 'rg.exe'),
|
|
40
|
+
];
|
|
34
41
|
|
|
35
42
|
function isTruthy(value) {
|
|
36
43
|
return value === '1' || value === 'true';
|
|
@@ -294,14 +301,21 @@ function getBundledCliPath() {
|
|
|
294
301
|
return path.join(getBundledDir(), cliName);
|
|
295
302
|
}
|
|
296
303
|
|
|
304
|
+
function getPackagedWorkerRuntimeDir() {
|
|
305
|
+
return path.join(__dirname, '..', 'dist', '_worker');
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function getPackagedWorkerRuntimePaths() {
|
|
309
|
+
const workerDir = getPackagedWorkerRuntimeDir();
|
|
310
|
+
return [
|
|
311
|
+
path.join(workerDir, 'qoder-worker-runtime.obf.mjs'),
|
|
312
|
+
path.join(workerDir, 'qoder-worker-runtime.mjs'),
|
|
313
|
+
];
|
|
314
|
+
}
|
|
315
|
+
|
|
297
316
|
function getPackagedWorkerRuntimePath() {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
'..',
|
|
301
|
-
'dist',
|
|
302
|
-
'_worker',
|
|
303
|
-
'qoder-worker-runtime.obf.mjs',
|
|
304
|
-
);
|
|
317
|
+
const paths = getPackagedWorkerRuntimePaths();
|
|
318
|
+
return paths.find((candidate) => fs.existsSync(candidate)) ?? paths[0];
|
|
305
319
|
}
|
|
306
320
|
|
|
307
321
|
function getPackagedWorkerRuntimeInfoPath() {
|
|
@@ -309,7 +323,9 @@ function getPackagedWorkerRuntimeInfoPath() {
|
|
|
309
323
|
}
|
|
310
324
|
|
|
311
325
|
function hasPackagedWorkerRuntime() {
|
|
312
|
-
return
|
|
326
|
+
return getPackagedWorkerRuntimePaths().some((candidate) =>
|
|
327
|
+
fs.existsSync(candidate),
|
|
328
|
+
);
|
|
313
329
|
}
|
|
314
330
|
|
|
315
331
|
function readPackagedWorkerRuntimeInfo() {
|
|
@@ -673,9 +689,7 @@ function findWorkerRuntimeRoot(dir) {
|
|
|
673
689
|
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
674
690
|
const hasWorkerRuntime = entries.some(
|
|
675
691
|
(entry) =>
|
|
676
|
-
entry.isFile() &&
|
|
677
|
-
(entry.name === 'qoder-worker-runtime.obf.mjs' ||
|
|
678
|
-
entry.name === 'qoder-worker-runtime.mjs'),
|
|
692
|
+
entry.isFile() && WORKER_RUNTIME_ENTRY_NAMES.includes(entry.name),
|
|
679
693
|
);
|
|
680
694
|
if (hasWorkerRuntime) return dir;
|
|
681
695
|
|
|
@@ -687,6 +701,38 @@ function findWorkerRuntimeRoot(dir) {
|
|
|
687
701
|
return null;
|
|
688
702
|
}
|
|
689
703
|
|
|
704
|
+
function getWorkerRuntimeEntryPath(runtimeDir) {
|
|
705
|
+
for (const entryName of WORKER_RUNTIME_ENTRY_NAMES) {
|
|
706
|
+
const runtimePath = path.join(runtimeDir, entryName);
|
|
707
|
+
if (fs.existsSync(runtimePath)) return runtimePath;
|
|
708
|
+
}
|
|
709
|
+
return path.join(runtimeDir, WORKER_RUNTIME_ENTRY_NAMES[0]);
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
function assertWorkerRuntimeComplete(runtimeDir, sourceDescription) {
|
|
713
|
+
const runtimePath = getWorkerRuntimeEntryPath(runtimeDir);
|
|
714
|
+
if (!fs.existsSync(runtimePath)) {
|
|
715
|
+
throw new Error(
|
|
716
|
+
`Worker runtime entry missing in ${sourceDescription}: ${runtimePath}`,
|
|
717
|
+
);
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
const missingAssets = REQUIRED_WORKER_RUNTIME_ASSETS.filter(
|
|
721
|
+
(assetPath) => !fs.existsSync(path.join(runtimeDir, assetPath)),
|
|
722
|
+
);
|
|
723
|
+
if (missingAssets.length > 0) {
|
|
724
|
+
throw new Error(
|
|
725
|
+
[
|
|
726
|
+
`Worker runtime source is incomplete: ${sourceDescription}`,
|
|
727
|
+
`Missing required runtime asset(s): ${missingAssets.join(', ')}`,
|
|
728
|
+
'Expected a full qoder-worker-runtime archive containing the runtime entry and sidecar assets.',
|
|
729
|
+
].join('\n'),
|
|
730
|
+
);
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
return runtimePath;
|
|
734
|
+
}
|
|
735
|
+
|
|
690
736
|
function installExtractedWorkerRuntime(extractDir, workerDir) {
|
|
691
737
|
const contentRoot = findWorkerRuntimeRoot(extractDir);
|
|
692
738
|
if (!contentRoot) {
|
|
@@ -694,21 +740,12 @@ function installExtractedWorkerRuntime(extractDir, workerDir) {
|
|
|
694
740
|
'Worker runtime not found in extracted archive. Expected qoder-worker-runtime.obf.mjs or qoder-worker-runtime.mjs.',
|
|
695
741
|
);
|
|
696
742
|
}
|
|
743
|
+
assertWorkerRuntimeComplete(contentRoot, contentRoot);
|
|
697
744
|
|
|
698
745
|
fs.rmSync(workerDir, { recursive: true, force: true });
|
|
699
746
|
copyDirContents(contentRoot, workerDir);
|
|
700
747
|
|
|
701
|
-
const
|
|
702
|
-
workerDir,
|
|
703
|
-
'qoder-worker-runtime.obf.mjs',
|
|
704
|
-
);
|
|
705
|
-
const plainRuntime = path.join(workerDir, 'qoder-worker-runtime.mjs');
|
|
706
|
-
const runtimePath = fs.existsSync(obfuscatedRuntime)
|
|
707
|
-
? obfuscatedRuntime
|
|
708
|
-
: plainRuntime;
|
|
709
|
-
if (!fs.existsSync(runtimePath)) {
|
|
710
|
-
throw new Error(`Worker runtime copy failed: ${runtimePath}`);
|
|
711
|
-
}
|
|
748
|
+
const runtimePath = assertWorkerRuntimeComplete(workerDir, workerDir);
|
|
712
749
|
|
|
713
750
|
const files = fs.readdirSync(workerDir);
|
|
714
751
|
console.log(
|
|
@@ -733,7 +770,7 @@ async function installWorkerRuntimeFromDownload() {
|
|
|
733
770
|
await extractArchive(archivePath, extractDir);
|
|
734
771
|
return installExtractedWorkerRuntime(
|
|
735
772
|
extractDir,
|
|
736
|
-
|
|
773
|
+
getPackagedWorkerRuntimeDir(),
|
|
737
774
|
);
|
|
738
775
|
} finally {
|
|
739
776
|
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
@@ -823,8 +860,10 @@ module.exports = {
|
|
|
823
860
|
getDownloadUrl,
|
|
824
861
|
getManifestWorkerRuntimeDownloadUrl,
|
|
825
862
|
getManifestWorkerRuntimeSha256,
|
|
863
|
+
getPackagedWorkerRuntimeDir,
|
|
826
864
|
getPackagedWorkerRuntimeInfoPath,
|
|
827
865
|
getPackagedWorkerRuntimePath,
|
|
866
|
+
getPackagedWorkerRuntimePaths,
|
|
828
867
|
getRuntimeManifestPath,
|
|
829
868
|
getPlatformTarget,
|
|
830
869
|
getDefaultRuntimeTransport,
|