@lakitu/sdk 0.1.66 → 0.1.68
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/convex/sandbox/http.ts
CHANGED
|
@@ -11,23 +11,22 @@ import { httpAction } from "./_generated/server";
|
|
|
11
11
|
const http = httpRouter();
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Sandbox metrics endpoint - returns sandbox health and resource usage.
|
|
15
15
|
* Used by pool health checks and Claude Code observability.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
17
|
+
* Note: /metrics is reserved by Convex backend for Prometheus metrics.
|
|
18
|
+
* Use /sandbox-metrics to avoid collision.
|
|
19
|
+
*
|
|
20
|
+
* GET /sandbox-metrics
|
|
18
21
|
*
|
|
19
22
|
* Response:
|
|
20
23
|
* {
|
|
21
24
|
* status: string,
|
|
22
25
|
* timestamp: number
|
|
23
26
|
* }
|
|
24
|
-
*
|
|
25
|
-
* Note: Full system metrics (CPU, memory) would require Node.js APIs
|
|
26
|
-
* which aren't available in the Convex V8 runtime. For detailed metrics,
|
|
27
|
-
* use the sandbox's HTTP server or E2B's metrics API instead.
|
|
28
27
|
*/
|
|
29
28
|
http.route({
|
|
30
|
-
path: "/metrics",
|
|
29
|
+
path: "/sandbox-metrics",
|
|
31
30
|
method: "GET",
|
|
32
31
|
handler: httpAction(async () => {
|
|
33
32
|
// Convex V8 runtime doesn't have access to Node.js APIs like 'os'
|
|
@@ -54,10 +53,10 @@ http.route({
|
|
|
54
53
|
* Health check endpoint - simple ping for pool management.
|
|
55
54
|
* Used by E2B pool to verify sandbox is responsive.
|
|
56
55
|
*
|
|
57
|
-
* GET /health
|
|
56
|
+
* GET /sandbox-health
|
|
58
57
|
*/
|
|
59
58
|
http.route({
|
|
60
|
-
path: "/health",
|
|
59
|
+
path: "/sandbox-health",
|
|
61
60
|
method: "GET",
|
|
62
61
|
handler: httpAction(async () => {
|
|
63
62
|
return new Response(JSON.stringify({ status: "ok", timestamp: Date.now() }), {
|
|
@@ -71,13 +70,13 @@ http.route({
|
|
|
71
70
|
* Version endpoint - returns SDK version for debugging.
|
|
72
71
|
* Used by pool health checks.
|
|
73
72
|
*
|
|
74
|
-
* GET /version
|
|
73
|
+
* GET /sandbox-version
|
|
75
74
|
*
|
|
76
75
|
* Note: Version is hardcoded since Convex V8 runtime doesn't have
|
|
77
76
|
* access to Node.js fs APIs. Update this when publishing new versions.
|
|
78
77
|
*/
|
|
79
78
|
http.route({
|
|
80
|
-
path: "/version",
|
|
79
|
+
path: "/sandbox-version",
|
|
81
80
|
method: "GET",
|
|
82
81
|
handler: httpAction(async () => {
|
|
83
82
|
// Convex V8 runtime can't read files directly
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../cli/commands/build.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,UAAU,YAAY;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../cli/commands/build.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAaH,UAAU,YAAY;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAuPD,wBAAsB,KAAK,CAAC,OAAO,EAAE,YAAY,iBAgBhD"}
|
|
@@ -108,15 +108,41 @@ async function buildCustom(apiKey, baseId) {
|
|
|
108
108
|
${PACKAGE_ROOT}/ ${join(buildDir, "lakitu")}/`, {
|
|
109
109
|
stdio: "pipe",
|
|
110
110
|
});
|
|
111
|
-
// Copy user's project KSAs
|
|
111
|
+
// Copy user's project KSAs (recursively to support subdirectories)
|
|
112
112
|
const userKsaDir = join(process.cwd(), "lakitu");
|
|
113
113
|
if (existsSync(userKsaDir)) {
|
|
114
114
|
console.log(" Copying project KSAs from lakitu/...");
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
115
|
+
// Count all .ts files recursively
|
|
116
|
+
const countTsFiles = (dir) => {
|
|
117
|
+
let count = 0;
|
|
118
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
119
|
+
const fullPath = join(dir, entry.name);
|
|
120
|
+
if (entry.isDirectory() && !entry.name.startsWith('.') && entry.name !== 'node_modules') {
|
|
121
|
+
count += countTsFiles(fullPath);
|
|
122
|
+
}
|
|
123
|
+
else if (entry.isFile() && entry.name.endsWith('.ts')) {
|
|
124
|
+
count++;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return count;
|
|
128
|
+
};
|
|
129
|
+
// Copy directory structure recursively
|
|
130
|
+
const copyTsFilesRecursive = (srcDir, destDir) => {
|
|
131
|
+
mkdirSync(destDir, { recursive: true });
|
|
132
|
+
for (const entry of readdirSync(srcDir, { withFileTypes: true })) {
|
|
133
|
+
const srcPath = join(srcDir, entry.name);
|
|
134
|
+
const destPath = join(destDir, entry.name);
|
|
135
|
+
if (entry.isDirectory() && !entry.name.startsWith('.') && entry.name !== 'node_modules') {
|
|
136
|
+
copyTsFilesRecursive(srcPath, destPath);
|
|
137
|
+
}
|
|
138
|
+
else if (entry.isFile() && entry.name.endsWith('.ts')) {
|
|
139
|
+
cpSync(srcPath, destPath);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
const ksaCount = countTsFiles(userKsaDir);
|
|
144
|
+
copyTsFilesRecursive(userKsaDir, join(buildDir, "lakitu/ksa"));
|
|
145
|
+
console.log(` ✓ Copied ${ksaCount} project KSAs (including subdirectories)`);
|
|
120
146
|
}
|
|
121
147
|
// Copy start script
|
|
122
148
|
cpSync(join(PACKAGE_ROOT, "template/e2b/start.sh"), join(buildDir, "start.sh"));
|
package/package.json
CHANGED
package/template/build.ts
CHANGED
|
@@ -76,7 +76,7 @@ function generatePipInstall(packages: string[]): string {
|
|
|
76
76
|
*/
|
|
77
77
|
function generateNpmInstall(packages: string[]): string {
|
|
78
78
|
if (packages.length === 0) return "";
|
|
79
|
-
return `npm install -g ${packages.join(" ")}`;
|
|
79
|
+
return `sudo npm install -g ${packages.join(" ")}`;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
async function getApiKey(): Promise<string> {
|