vmlive 1.0.20 → 1.0.22
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 +1 -1
- package/src/cli.js +17 -17
- package/src/string-shim.js +34 -35
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -508,7 +508,7 @@ const runDev = async () => {
|
|
|
508
508
|
|
|
509
509
|
config.functions.forEach(fn => {
|
|
510
510
|
const relativeTarget = `./${fn.name}-out.mjs`;
|
|
511
|
-
fs.writeFileSync(path.join(WORK_DIR, `${fn.name}-shim.mjs`), generateShim(relativeTarget, workspaceId, projectId, fn.name));
|
|
511
|
+
fs.writeFileSync(path.join(WORK_DIR, `${fn.name}-shim.mjs`), generateShim(relativeTarget, workspaceId, projectId, fn.name, jwtToken));
|
|
512
512
|
});
|
|
513
513
|
|
|
514
514
|
await mf.setOptions({
|
|
@@ -767,17 +767,17 @@ const runDb = async () => {
|
|
|
767
767
|
|
|
768
768
|
if (envArg === 'local') {
|
|
769
769
|
console.log('\x1b[90mSyncing Local V8 Emulator D1...\x1b[0m');
|
|
770
|
-
const mf = new Emulator({
|
|
770
|
+
const mf = new Emulator({
|
|
771
771
|
modules: true,
|
|
772
|
-
script: 'export default { fetch: () => new Response("ok") }',
|
|
773
|
-
d1Databases: ["DB"]
|
|
772
|
+
script: 'export default { fetch: () => new Response("ok") }',
|
|
773
|
+
d1Databases: ["DB"]
|
|
774
774
|
});
|
|
775
775
|
try {
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
} catch
|
|
780
|
-
|
|
776
|
+
const db = await mf.getD1Database("DB");
|
|
777
|
+
await db.exec(combinedSql);
|
|
778
|
+
console.log('\x1b[32m✔ Local Database push successful.\x1b[0m');
|
|
779
|
+
} catch(e) {
|
|
780
|
+
console.error('\n\x1b[31m❌ Local execute failed:\x1b[0m', e.message);
|
|
781
781
|
}
|
|
782
782
|
await mf.dispose();
|
|
783
783
|
} else {
|
|
@@ -795,18 +795,18 @@ const runDb = async () => {
|
|
|
795
795
|
|
|
796
796
|
const { projectId } = vmConf;
|
|
797
797
|
console.log(`\x1b[90mSyncing Cloudflare Edge D1 [${projectId}]...\x1b[0m`);
|
|
798
|
-
|
|
798
|
+
|
|
799
799
|
try {
|
|
800
800
|
const res = await fetch(`${GATEKEEPER_URL}/api/projects/${projectId}/database/migrate`, {
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
801
|
+
method: 'POST',
|
|
802
|
+
headers: { 'Authorization': `Bearer ${jwtToken}`, 'Content-Type': 'application/json' },
|
|
803
|
+
body: JSON.stringify({ sql: combinedSql })
|
|
804
804
|
});
|
|
805
|
-
|
|
805
|
+
|
|
806
806
|
if (res.ok) {
|
|
807
|
-
|
|
807
|
+
console.log('\n\x1b[32m✔ Cloudflare D1 Remote Pipeline successfully upgraded.\x1b[0m');
|
|
808
808
|
} else {
|
|
809
|
-
|
|
809
|
+
console.error('\n\x1b[31m❌ Remote Migration Error:\x1b[0m', res.status, await res.text());
|
|
810
810
|
}
|
|
811
811
|
} catch (err) {
|
|
812
812
|
console.error('\n\x1b[31m❌ Network Failure:\x1b[0m', err.message);
|
|
@@ -842,7 +842,7 @@ const main = async () => {
|
|
|
842
842
|
console.log(' \x1b[32mlogin\x1b[0m Authenticate your local environment securely via Stripe/OAuth');
|
|
843
843
|
console.log(' \x1b[32mdeploy\x1b[0m Upload your footprint to the vm.live edge platform');
|
|
844
844
|
console.log(' \x1b[32mdb\x1b[0m Manage Cloudflare D1 schema migrations (`db push local|remote`)');
|
|
845
|
-
console.log(' \x1b[32mllm\x1b[0m Download the official AI
|
|
845
|
+
console.log(' \x1b[32mllm\x1b[0m Download the official AI Context Rules for agentic workflows');
|
|
846
846
|
console.log(' \x1b[32mupdate\x1b[0m Upgrade this CLI engine to the latest published version');
|
|
847
847
|
console.log(' \x1b[32mwhich\x1b[0m Display the currently active CLI version');
|
|
848
848
|
console.log('');
|
package/src/string-shim.js
CHANGED
|
@@ -109,42 +109,41 @@ export default {
|
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
-
const createRpcProxy = (serviceName) =>
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const req = new Request(\`https://rpc.vm.codes/.internal/rpc/\${serviceName.toLowerCase()}/\${method}\`, {
|
|
127
|
-
method: "POST",
|
|
128
|
-
headers: {
|
|
129
|
-
"Authorization": "Bearer ${jwtToken || 'local'}",
|
|
130
|
-
"Content-Type": contentType,
|
|
131
|
-
"x-workspace-id": "${workspaceId}",
|
|
132
|
-
"x-project-id": "${projectId}"
|
|
133
|
-
},
|
|
134
|
-
body
|
|
135
|
-
});
|
|
136
|
-
const res = await fetch(req);
|
|
137
|
-
if (!res.ok) throw new Error(\`vm.live RPC Error: \${await res.text()}\`);
|
|
138
|
-
|
|
139
|
-
const isStream = res.headers.get("Content-Type") === "text/event-stream";
|
|
140
|
-
if (isStream) return res.body;
|
|
112
|
+
const createRpcProxy = (serviceName) => {
|
|
113
|
+
return new Proxy({}, {
|
|
114
|
+
get: (target, method) => {
|
|
115
|
+
return async (...args) => {
|
|
116
|
+
let body = null;
|
|
117
|
+
let contentType = "application/json";
|
|
118
|
+
if (serviceName === "AI" && method === "transcribe") {
|
|
119
|
+
body = args[0];
|
|
120
|
+
contentType = "application/octet-stream";
|
|
121
|
+
} else {
|
|
122
|
+
body = JSON.stringify({ args });
|
|
123
|
+
}
|
|
141
124
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
125
|
+
const req = new Request(\`https://rpc.vm.codes/.internal/rpc/\${serviceName.toLowerCase()}/\${method}\`, {
|
|
126
|
+
method: "POST",
|
|
127
|
+
headers: {
|
|
128
|
+
${jwtToken ? `"Authorization": "Bearer ${jwtToken}",` : ''}
|
|
129
|
+
"Content-Type": contentType,
|
|
130
|
+
"x-workspace-id": "${workspaceId}",
|
|
131
|
+
"x-project-id": "${projectId}"
|
|
132
|
+
},
|
|
133
|
+
body
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const res = await fetch(req);
|
|
137
|
+
if (!res.ok) throw new Error(\`vm.live RPC Error: \${await res.text()}\`);
|
|
138
|
+
|
|
139
|
+
if (res.headers.get("Content-Type")?.includes("text/event-stream")) {
|
|
140
|
+
return res.body;
|
|
141
|
+
}
|
|
142
|
+
return await res.json();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
};
|
|
148
147
|
|
|
149
148
|
const AI = createRpcProxy("AI");
|
|
150
149
|
|