@instafy/cli 0.1.3 → 0.1.4
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 +92 -55
- package/dist/org.js +3 -2
- package/dist/project.js +6 -4
- package/dist/runtime.js +21 -9
- package/dist/tunnel.js +5 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
1
|
+
import { Command, Option } from "commander";
|
|
2
2
|
import { pathToFileURL } from "node:url";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import kleur from "kleur";
|
|
@@ -8,18 +8,34 @@ import { runTunnelCommand } from "./tunnel.js";
|
|
|
8
8
|
export const program = new Command();
|
|
9
9
|
const require = createRequire(import.meta.url);
|
|
10
10
|
const pkg = require("../package.json");
|
|
11
|
+
function addServerUrlOptions(command) {
|
|
12
|
+
return command
|
|
13
|
+
.option("--server-url <url>", "Instafy server URL")
|
|
14
|
+
.addOption(new Option("--controller-url <url>").hideHelp());
|
|
15
|
+
}
|
|
16
|
+
function addAccessTokenOptions(command, description) {
|
|
17
|
+
return command
|
|
18
|
+
.option("--access-token <token>", description)
|
|
19
|
+
.addOption(new Option("--controller-access-token <token>").hideHelp());
|
|
20
|
+
}
|
|
21
|
+
function addServiceTokenOptions(command, description) {
|
|
22
|
+
return command
|
|
23
|
+
.option("--service-token <token>", description)
|
|
24
|
+
.addOption(new Option("--controller-token <token>").hideHelp());
|
|
25
|
+
}
|
|
11
26
|
program
|
|
12
27
|
.name("instafy")
|
|
13
|
-
.description("Instafy CLI —
|
|
28
|
+
.description("Instafy CLI — run your project locally and connect to Studio")
|
|
14
29
|
.version(pkg.version ?? "0.1.0");
|
|
15
|
-
program
|
|
30
|
+
const runtimeStartCommand = program
|
|
16
31
|
.command("runtime:start")
|
|
17
|
-
.description("Start a local
|
|
18
|
-
.option("--project <id>", "Project UUID")
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
32
|
+
.description("Start a local runtime for this project")
|
|
33
|
+
.option("--project <id>", "Project UUID");
|
|
34
|
+
addServerUrlOptions(runtimeStartCommand);
|
|
35
|
+
addServiceTokenOptions(runtimeStartCommand, "Instafy service token (advanced)");
|
|
36
|
+
addAccessTokenOptions(runtimeStartCommand, "Instafy access token (from Studio)");
|
|
37
|
+
runtimeStartCommand
|
|
38
|
+
.option("--supabase-access-token <token>", "Supabase session token (alternative to Studio token)")
|
|
23
39
|
.option("--supabase-access-token-file <path>", "File containing the Supabase session token")
|
|
24
40
|
.option("--runtime-token <token>", "Pre-minted runtime access token (bypasses agent key)")
|
|
25
41
|
.option("--codex-bin <path>", "Path to codex binary (fallback to PATH)")
|
|
@@ -27,19 +43,27 @@ program
|
|
|
27
43
|
.option("--workspace <path>", "Workspace directory (defaults to ./.instafy/workspace)")
|
|
28
44
|
.option("--origin-id <uuid>", "Origin ID to use (auto-generated if omitted)")
|
|
29
45
|
.option("--origin-endpoint <url>", "Explicit origin endpoint (skip tunnel setup when provided)")
|
|
30
|
-
.option("--origin-token <token>", "Runtime/origin access token for
|
|
31
|
-
.option("--runtime-id <uuid>", "Runtime ID to use (
|
|
32
|
-
.option("--runtime-lease-id <uuid>", "Runtime lease ID to use (
|
|
46
|
+
.option("--origin-token <token>", "Runtime/origin access token for Studio registration")
|
|
47
|
+
.option("--runtime-id <uuid>", "Runtime ID to use (advanced)")
|
|
48
|
+
.option("--runtime-lease-id <uuid>", "Runtime lease ID to use (advanced)")
|
|
33
49
|
.option("--display-name <name>", "Human-friendly runtime name")
|
|
34
50
|
.option("--provider <provider>", "Runtime provider label (default: self-hosted)")
|
|
35
51
|
.option("--bind-host <host>", "Origin bind host (default 127.0.0.1)")
|
|
36
52
|
.option("--bind-port <port>", "Origin bind port (default 54332)")
|
|
37
|
-
.option("--mount-
|
|
53
|
+
.option("--mount-project-files", "Mount project files from Instafy (SSHFS)")
|
|
54
|
+
.addOption(new Option("--mount-controller-fs").hideHelp())
|
|
38
55
|
.option("--detach", "Run runtime in background and exit immediately")
|
|
39
56
|
.option("--log-file <path>", "Write runtime stdout/stderr to a file (implied when detached)")
|
|
40
57
|
.action(async (opts) => {
|
|
41
58
|
try {
|
|
42
|
-
await runtimeStart(
|
|
59
|
+
await runtimeStart({
|
|
60
|
+
...opts,
|
|
61
|
+
controllerUrl: opts.serverUrl ?? opts.controllerUrl,
|
|
62
|
+
controllerToken: opts.serviceToken ?? opts.controllerToken,
|
|
63
|
+
controllerAccessToken: opts.accessToken ?? opts.controllerAccessToken,
|
|
64
|
+
mountProjectFiles: Boolean(opts.mountProjectFiles),
|
|
65
|
+
mountControllerFs: Boolean(opts.mountControllerFs),
|
|
66
|
+
});
|
|
43
67
|
}
|
|
44
68
|
catch (error) {
|
|
45
69
|
console.error(kleur.red(String(error)));
|
|
@@ -48,7 +72,7 @@ program
|
|
|
48
72
|
});
|
|
49
73
|
program
|
|
50
74
|
.command("runtime:status")
|
|
51
|
-
.description("Show runtime health
|
|
75
|
+
.description("Show runtime health")
|
|
52
76
|
.option("--json", "Output status as JSON")
|
|
53
77
|
.action(async (opts) => {
|
|
54
78
|
try {
|
|
@@ -61,7 +85,7 @@ program
|
|
|
61
85
|
});
|
|
62
86
|
program
|
|
63
87
|
.command("runtime:sshfs:check")
|
|
64
|
-
.description("
|
|
88
|
+
.description("Check SSHFS availability (needed for file mounts)")
|
|
65
89
|
.option("--sshfs-bin <path>", "sshfs binary (default: sshfs or SHARED_FS_BIN)")
|
|
66
90
|
.action(async (opts) => {
|
|
67
91
|
try {
|
|
@@ -87,12 +111,13 @@ program
|
|
|
87
111
|
process.exit(1);
|
|
88
112
|
}
|
|
89
113
|
});
|
|
90
|
-
program
|
|
114
|
+
const runtimeTokenCommand = program
|
|
91
115
|
.command("runtime:token")
|
|
92
|
-
.description("Mint a runtime access token
|
|
93
|
-
.requiredOption("--project <id>", "Project UUID")
|
|
94
|
-
|
|
95
|
-
|
|
116
|
+
.description("Mint a runtime access token")
|
|
117
|
+
.requiredOption("--project <id>", "Project UUID");
|
|
118
|
+
addServerUrlOptions(runtimeTokenCommand);
|
|
119
|
+
addAccessTokenOptions(runtimeTokenCommand, "Instafy access token (required)");
|
|
120
|
+
runtimeTokenCommand
|
|
96
121
|
.option("--runtime-id <uuid>", "Runtime ID to bind token to")
|
|
97
122
|
.option("--scope <scope...>", "Override scopes (default agent.* + origin.*)")
|
|
98
123
|
.option("--json", "Output token as JSON")
|
|
@@ -100,8 +125,8 @@ program
|
|
|
100
125
|
try {
|
|
101
126
|
await runtimeToken({
|
|
102
127
|
project: opts.project,
|
|
103
|
-
controllerUrl: opts.controllerUrl,
|
|
104
|
-
controllerAccessToken: opts.controllerAccessToken,
|
|
128
|
+
controllerUrl: opts.serverUrl ?? opts.controllerUrl,
|
|
129
|
+
controllerAccessToken: opts.accessToken ?? opts.controllerAccessToken,
|
|
105
130
|
runtimeId: opts.runtimeId,
|
|
106
131
|
scopes: opts.scope,
|
|
107
132
|
json: opts.json,
|
|
@@ -112,12 +137,13 @@ program
|
|
|
112
137
|
process.exit(1);
|
|
113
138
|
}
|
|
114
139
|
});
|
|
115
|
-
program
|
|
140
|
+
const projectInitCommand = program
|
|
116
141
|
.command("project:init")
|
|
117
|
-
.description("Create
|
|
118
|
-
.option("--path <dir>", "Directory where the manifest should be written (default: cwd)")
|
|
119
|
-
|
|
120
|
-
|
|
142
|
+
.description("Create an Instafy project and link this folder (.instafy/project.json)")
|
|
143
|
+
.option("--path <dir>", "Directory where the manifest should be written (default: cwd)");
|
|
144
|
+
addServerUrlOptions(projectInitCommand);
|
|
145
|
+
projectInitCommand
|
|
146
|
+
.option("--access-token <token>", "Instafy or Supabase access token")
|
|
121
147
|
.option("--project-type <type>", "Project type (customer|sandbox)")
|
|
122
148
|
.option("--org-id <uuid>", "Optional organization id")
|
|
123
149
|
.option("--org-name <name>", "Optional organization name")
|
|
@@ -128,7 +154,7 @@ program
|
|
|
128
154
|
try {
|
|
129
155
|
await projectInit({
|
|
130
156
|
path: opts.path,
|
|
131
|
-
controllerUrl: opts.controllerUrl,
|
|
157
|
+
controllerUrl: opts.serverUrl ?? opts.controllerUrl,
|
|
132
158
|
accessToken: opts.accessToken,
|
|
133
159
|
projectType: opts.projectType,
|
|
134
160
|
orgId: opts.orgId,
|
|
@@ -143,12 +169,13 @@ program
|
|
|
143
169
|
process.exit(1);
|
|
144
170
|
}
|
|
145
171
|
});
|
|
146
|
-
program
|
|
172
|
+
const tunnelCommand = program
|
|
147
173
|
.command("tunnel")
|
|
148
|
-
.description("
|
|
149
|
-
.option("--project <id>", "Project UUID (or set PROJECT_ID)")
|
|
150
|
-
|
|
151
|
-
|
|
174
|
+
.description("Create a shareable tunnel URL for a local port")
|
|
175
|
+
.option("--project <id>", "Project UUID (or set PROJECT_ID)");
|
|
176
|
+
addServerUrlOptions(tunnelCommand);
|
|
177
|
+
addServiceTokenOptions(tunnelCommand, "Instafy service token (advanced)");
|
|
178
|
+
tunnelCommand
|
|
152
179
|
.option("--port <port>", "Local port to expose (default 3000)")
|
|
153
180
|
.option("--rathole-bin <path>", "Path to rathole binary (or set RATHOLE_BIN)")
|
|
154
181
|
.action(async (opts) => {
|
|
@@ -156,8 +183,8 @@ program
|
|
|
156
183
|
const port = opts.port ? Number(opts.port) : undefined;
|
|
157
184
|
await runTunnelCommand({
|
|
158
185
|
project: opts.project,
|
|
159
|
-
controllerUrl: opts.controllerUrl,
|
|
160
|
-
controllerToken: opts.controllerToken,
|
|
186
|
+
controllerUrl: opts.serverUrl ?? opts.controllerUrl,
|
|
187
|
+
controllerToken: opts.serviceToken ?? opts.controllerToken,
|
|
161
188
|
port,
|
|
162
189
|
ratholeBin: opts.ratholeBin,
|
|
163
190
|
});
|
|
@@ -167,16 +194,17 @@ program
|
|
|
167
194
|
process.exit(1);
|
|
168
195
|
}
|
|
169
196
|
});
|
|
170
|
-
program
|
|
197
|
+
const orgListCommand = program
|
|
171
198
|
.command("org:list")
|
|
172
|
-
.description("List organizations
|
|
173
|
-
|
|
174
|
-
|
|
199
|
+
.description("List organizations for your account");
|
|
200
|
+
addServerUrlOptions(orgListCommand);
|
|
201
|
+
orgListCommand
|
|
202
|
+
.option("--access-token <token>", "Instafy or Supabase access token")
|
|
175
203
|
.option("--json", "Output JSON")
|
|
176
204
|
.action(async (opts) => {
|
|
177
205
|
try {
|
|
178
206
|
await (await import("./org.js")).listOrganizations({
|
|
179
|
-
controllerUrl: opts.controllerUrl,
|
|
207
|
+
controllerUrl: opts.serverUrl ?? opts.controllerUrl,
|
|
180
208
|
accessToken: opts.accessToken,
|
|
181
209
|
json: opts.json,
|
|
182
210
|
});
|
|
@@ -186,18 +214,19 @@ program
|
|
|
186
214
|
process.exit(1);
|
|
187
215
|
}
|
|
188
216
|
});
|
|
189
|
-
program
|
|
217
|
+
const projectListCommand = program
|
|
190
218
|
.command("project:list")
|
|
191
|
-
.description("List projects
|
|
192
|
-
.option("--
|
|
193
|
-
|
|
219
|
+
.description("List projects for your account")
|
|
220
|
+
.option("--access-token <token>", "Instafy or Supabase access token");
|
|
221
|
+
addServerUrlOptions(projectListCommand);
|
|
222
|
+
projectListCommand
|
|
194
223
|
.option("--org-id <uuid>", "Filter by organization id")
|
|
195
224
|
.option("--org-slug <slug>", "Filter by organization slug")
|
|
196
225
|
.option("--json", "Output JSON")
|
|
197
226
|
.action(async (opts) => {
|
|
198
227
|
try {
|
|
199
228
|
await (await import("./project.js")).listProjects({
|
|
200
|
-
controllerUrl: opts.controllerUrl,
|
|
229
|
+
controllerUrl: opts.serverUrl ?? opts.controllerUrl,
|
|
201
230
|
accessToken: opts.accessToken,
|
|
202
231
|
orgId: opts.orgId,
|
|
203
232
|
orgSlug: opts.orgSlug,
|
|
@@ -209,32 +238,40 @@ program
|
|
|
209
238
|
process.exit(1);
|
|
210
239
|
}
|
|
211
240
|
});
|
|
212
|
-
program
|
|
241
|
+
const workspaceMountCommand = program
|
|
213
242
|
.command("workspace:mount")
|
|
214
|
-
.description("Mount
|
|
243
|
+
.description("Mount project files into a local folder (SSHFS, shared storage)")
|
|
215
244
|
.requiredOption("--project <id>", "Project UUID")
|
|
216
|
-
.requiredOption("--path <dir>", "Local mount directory")
|
|
217
|
-
|
|
218
|
-
|
|
245
|
+
.requiredOption("--path <dir>", "Local mount directory");
|
|
246
|
+
addServerUrlOptions(workspaceMountCommand);
|
|
247
|
+
addAccessTokenOptions(workspaceMountCommand, "Instafy access token");
|
|
248
|
+
workspaceMountCommand
|
|
219
249
|
.option("--sshfs-bin <path>", "sshfs binary (default: sshfs or SHARED_FS_BIN)")
|
|
220
250
|
.option("--options <opts>", "Extra sshfs options")
|
|
221
251
|
.action(async (opts) => {
|
|
222
252
|
try {
|
|
223
|
-
const token = opts.
|
|
253
|
+
const token = opts.accessToken ??
|
|
254
|
+
opts.controllerAccessToken ??
|
|
255
|
+
process.env.INSTAFY_ACCESS_TOKEN ??
|
|
224
256
|
process.env.CONTROLLER_ACCESS_TOKEN ??
|
|
225
257
|
process.env.CONTROLLER_TOKEN;
|
|
226
258
|
if (!token) {
|
|
227
|
-
throw new Error("
|
|
259
|
+
throw new Error("Access token is required for workspace:mount.");
|
|
228
260
|
}
|
|
261
|
+
const serverUrl = opts.serverUrl ??
|
|
262
|
+
opts.controllerUrl ??
|
|
263
|
+
process.env.INSTAFY_SERVER_URL ??
|
|
264
|
+
process.env.CONTROLLER_BASE_URL ??
|
|
265
|
+
"http://127.0.0.1:8788";
|
|
229
266
|
const mountDir = await mountWorkspace({
|
|
230
267
|
project: opts.project,
|
|
231
|
-
controllerUrl:
|
|
268
|
+
controllerUrl: serverUrl,
|
|
232
269
|
controllerAccessToken: token,
|
|
233
270
|
mountPath: opts.path,
|
|
234
271
|
sshfsBin: opts.sshfsBin,
|
|
235
272
|
extraOptions: opts.options,
|
|
236
273
|
});
|
|
237
|
-
console.log(kleur.green(`Mounted
|
|
274
|
+
console.log(kleur.green(`Mounted project files to ${mountDir}`));
|
|
238
275
|
}
|
|
239
276
|
catch (error) {
|
|
240
277
|
console.error(kleur.red(String(error)));
|
package/dist/org.js
CHANGED
|
@@ -12,12 +12,13 @@ function normalizeToken(raw) {
|
|
|
12
12
|
return trimmed.length ? trimmed : null;
|
|
13
13
|
}
|
|
14
14
|
export async function listOrganizations(params) {
|
|
15
|
-
const controllerUrl = normalizeUrl(params.controllerUrl ?? process.env["CONTROLLER_BASE_URL"]);
|
|
15
|
+
const controllerUrl = normalizeUrl(params.controllerUrl ?? process.env["INSTAFY_SERVER_URL"] ?? process.env["CONTROLLER_BASE_URL"]);
|
|
16
16
|
const token = normalizeToken(params.accessToken) ??
|
|
17
|
+
normalizeToken(process.env["INSTAFY_ACCESS_TOKEN"]) ??
|
|
17
18
|
normalizeToken(process.env["CONTROLLER_ACCESS_TOKEN"]) ??
|
|
18
19
|
normalizeToken(process.env["SUPABASE_ACCESS_TOKEN"]);
|
|
19
20
|
if (!token) {
|
|
20
|
-
throw new Error("
|
|
21
|
+
throw new Error("Instafy or Supabase access token is required (--access-token, INSTAFY_ACCESS_TOKEN, or SUPABASE_ACCESS_TOKEN).");
|
|
21
22
|
}
|
|
22
23
|
const response = await fetch(`${controllerUrl}/orgs`, {
|
|
23
24
|
headers: { authorization: `Bearer ${token}` },
|
package/dist/project.js
CHANGED
|
@@ -73,12 +73,13 @@ async function resolveOrg(controllerUrl, token, options) {
|
|
|
73
73
|
return { orgId, orgName: json.org_name ?? null };
|
|
74
74
|
}
|
|
75
75
|
export async function listProjects(options) {
|
|
76
|
-
const controllerUrl = normalizeUrl(options.controllerUrl ?? process.env["CONTROLLER_BASE_URL"]);
|
|
76
|
+
const controllerUrl = normalizeUrl(options.controllerUrl ?? process.env["INSTAFY_SERVER_URL"] ?? process.env["CONTROLLER_BASE_URL"]);
|
|
77
77
|
const token = normalizeToken(options.accessToken) ??
|
|
78
|
+
normalizeToken(process.env["INSTAFY_ACCESS_TOKEN"]) ??
|
|
78
79
|
normalizeToken(process.env["CONTROLLER_ACCESS_TOKEN"]) ??
|
|
79
80
|
normalizeToken(process.env["SUPABASE_ACCESS_TOKEN"]);
|
|
80
81
|
if (!token) {
|
|
81
|
-
throw new Error("
|
|
82
|
+
throw new Error("Instafy or Supabase access token is required (--access-token, INSTAFY_ACCESS_TOKEN, or SUPABASE_ACCESS_TOKEN).");
|
|
82
83
|
}
|
|
83
84
|
const orgs = await fetchOrganizations(controllerUrl, token);
|
|
84
85
|
let targetOrgs = orgs;
|
|
@@ -123,12 +124,13 @@ export async function listProjects(options) {
|
|
|
123
124
|
}
|
|
124
125
|
export async function projectInit(options) {
|
|
125
126
|
const rootDir = path.resolve(options.path ?? process.cwd());
|
|
126
|
-
const controllerUrl = normalizeUrl(options.controllerUrl ?? process.env["CONTROLLER_BASE_URL"]);
|
|
127
|
+
const controllerUrl = normalizeUrl(options.controllerUrl ?? process.env["INSTAFY_SERVER_URL"] ?? process.env["CONTROLLER_BASE_URL"]);
|
|
127
128
|
const token = normalizeToken(options.accessToken) ??
|
|
129
|
+
normalizeToken(process.env["INSTAFY_ACCESS_TOKEN"]) ??
|
|
128
130
|
normalizeToken(process.env["CONTROLLER_ACCESS_TOKEN"]) ??
|
|
129
131
|
normalizeToken(process.env["SUPABASE_ACCESS_TOKEN"]);
|
|
130
132
|
if (!token) {
|
|
131
|
-
throw new Error("
|
|
133
|
+
throw new Error("Instafy or Supabase access token is required (--access-token, INSTAFY_ACCESS_TOKEN, or SUPABASE_ACCESS_TOKEN).");
|
|
132
134
|
}
|
|
133
135
|
const org = await resolveOrg(controllerUrl, token, options);
|
|
134
136
|
const body = {
|
package/dist/runtime.js
CHANGED
|
@@ -324,12 +324,12 @@ export async function mintRuntimeAccessToken(params) {
|
|
|
324
324
|
});
|
|
325
325
|
if (!response.ok) {
|
|
326
326
|
const text = await response.text().catch(() => "");
|
|
327
|
-
throw new Error(`
|
|
327
|
+
throw new Error(`Instafy server rejected runtime token request (${response.status} ${response.statusText}): ${text}`);
|
|
328
328
|
}
|
|
329
329
|
const payload = (await response.json());
|
|
330
330
|
const token = typeof payload.token === "string" ? payload.token.trim() : "";
|
|
331
331
|
if (!token) {
|
|
332
|
-
throw new Error("
|
|
332
|
+
throw new Error("Instafy server response missing token field while minting runtime token.");
|
|
333
333
|
}
|
|
334
334
|
return token;
|
|
335
335
|
}
|
|
@@ -360,12 +360,16 @@ export async function runtimeStart(options) {
|
|
|
360
360
|
env["SUPABASE_ACCESS_TOKEN"] = supabaseAccessToken;
|
|
361
361
|
}
|
|
362
362
|
let controllerAccessToken = normalizeToken(options.controllerAccessToken) ??
|
|
363
|
+
normalizeToken(env["INSTAFY_ACCESS_TOKEN"]) ??
|
|
363
364
|
normalizeToken(env["CONTROLLER_ACCESS_TOKEN"]) ??
|
|
364
365
|
supabaseAccessToken;
|
|
365
366
|
let runtimeAccessToken = normalizeToken(options.runtimeToken) ?? normalizeToken(env["RUNTIME_ACCESS_TOKEN"]);
|
|
366
|
-
const agentKey = options.controllerToken ??
|
|
367
|
+
const agentKey = options.controllerToken ??
|
|
368
|
+
env["INSTAFY_SERVICE_TOKEN"] ??
|
|
369
|
+
env["AGENT_LOGIN_KEY"] ??
|
|
370
|
+
env["AGENT_KEY"];
|
|
367
371
|
if (!agentKey && !controllerAccessToken && !runtimeAccessToken) {
|
|
368
|
-
throw new Error("Provide either --runtime-token/RUNTIME_ACCESS_TOKEN, --
|
|
372
|
+
throw new Error("Provide either --runtime-token/RUNTIME_ACCESS_TOKEN, --access-token/INSTAFY_ACCESS_TOKEN, --supabase-access-token/SUPABASE_ACCESS_TOKEN, or --service-token/INSTAFY_SERVICE_TOKEN (advanced).");
|
|
369
373
|
}
|
|
370
374
|
if (agentKey) {
|
|
371
375
|
env["AGENT_LOGIN_KEY"] = agentKey;
|
|
@@ -374,7 +378,10 @@ export async function runtimeStart(options) {
|
|
|
374
378
|
env["CONTROLLER_ACCESS_TOKEN"] = controllerAccessToken;
|
|
375
379
|
}
|
|
376
380
|
env["CONTROLLER_BASE_URL"] =
|
|
377
|
-
options.controllerUrl ??
|
|
381
|
+
options.controllerUrl ??
|
|
382
|
+
env["INSTAFY_SERVER_URL"] ??
|
|
383
|
+
env["CONTROLLER_BASE_URL"] ??
|
|
384
|
+
"http://127.0.0.1:8788";
|
|
378
385
|
if (!runtimeAccessToken && controllerAccessToken) {
|
|
379
386
|
runtimeAccessToken = await mintRuntimeAccessToken({
|
|
380
387
|
controllerUrl: env["CONTROLLER_BASE_URL"],
|
|
@@ -386,7 +393,8 @@ export async function runtimeStart(options) {
|
|
|
386
393
|
env["RUNTIME_ACCESS_TOKEN"] = runtimeAccessToken;
|
|
387
394
|
}
|
|
388
395
|
// Auto-fetch workspace mount token if requested
|
|
389
|
-
|
|
396
|
+
const shouldMountProjectFiles = Boolean(options.mountProjectFiles || options.mountControllerFs);
|
|
397
|
+
if (shouldMountProjectFiles && controllerAccessToken && env["CONTROLLER_BASE_URL"]) {
|
|
390
398
|
const token = await fetchWorkspaceMountToken({
|
|
391
399
|
controllerUrl: env["CONTROLLER_BASE_URL"],
|
|
392
400
|
controllerAccessToken,
|
|
@@ -616,7 +624,7 @@ export async function runtimeStatus(options) {
|
|
|
616
624
|
printStatus("Project:", state.projectId);
|
|
617
625
|
printStatus("Workspace:", state.workspace);
|
|
618
626
|
if (state.controllerUrl)
|
|
619
|
-
printStatus("
|
|
627
|
+
printStatus("Server:", state.controllerUrl);
|
|
620
628
|
if (state.originId)
|
|
621
629
|
printStatus("Origin:", state.originId);
|
|
622
630
|
if (state.runtimeId)
|
|
@@ -685,12 +693,16 @@ export async function runtimeStop(options) {
|
|
|
685
693
|
}
|
|
686
694
|
}
|
|
687
695
|
export async function runtimeToken(options) {
|
|
688
|
-
const controllerUrl = options.controllerUrl ??
|
|
696
|
+
const controllerUrl = options.controllerUrl ??
|
|
697
|
+
process.env["INSTAFY_SERVER_URL"] ??
|
|
698
|
+
process.env["CONTROLLER_BASE_URL"] ??
|
|
699
|
+
"http://127.0.0.1:8788";
|
|
689
700
|
const token = options.controllerAccessToken ??
|
|
701
|
+
process.env["INSTAFY_ACCESS_TOKEN"] ??
|
|
690
702
|
process.env["CONTROLLER_ACCESS_TOKEN"] ??
|
|
691
703
|
process.env["SUPABASE_ACCESS_TOKEN"];
|
|
692
704
|
if (!token) {
|
|
693
|
-
throw new Error("
|
|
705
|
+
throw new Error("Access token is required (--access-token, INSTAFY_ACCESS_TOKEN, or SUPABASE_ACCESS_TOKEN).");
|
|
694
706
|
}
|
|
695
707
|
const minted = await mintRuntimeAccessToken({
|
|
696
708
|
controllerUrl,
|
package/dist/tunnel.js
CHANGED
|
@@ -23,18 +23,21 @@ function resolveProject(opts) {
|
|
|
23
23
|
}
|
|
24
24
|
function resolveControllerUrl(opts) {
|
|
25
25
|
return (opts.controllerUrl?.trim() ||
|
|
26
|
+
readEnv("INSTAFY_SERVER_URL") ||
|
|
27
|
+
readEnv("INSTAFY_URL") ||
|
|
26
28
|
readEnv("CONTROLLER_URL") ||
|
|
27
29
|
readEnv("CONTROLLER_BASE_URL") ||
|
|
28
|
-
"http://
|
|
30
|
+
"http://127.0.0.1:8788");
|
|
29
31
|
}
|
|
30
32
|
function resolveControllerToken(opts) {
|
|
31
33
|
return (opts.controllerToken?.trim() ||
|
|
34
|
+
readEnv("INSTAFY_SERVICE_TOKEN") ||
|
|
32
35
|
readEnv("CONTROLLER_BEARER") ||
|
|
33
36
|
readEnv("SERVICE_ROLE_KEY") ||
|
|
34
37
|
readEnv("SUPABASE_SERVICE_ROLE_KEY") ||
|
|
35
38
|
readEnv("CONTROLLER_INTERNAL_TOKEN") ||
|
|
36
39
|
(() => {
|
|
37
|
-
throw new Error("
|
|
40
|
+
throw new Error("Service token is required (--service-token, INSTAFY_SERVICE_TOKEN, or SERVICE_ROLE_KEY).");
|
|
38
41
|
})());
|
|
39
42
|
}
|
|
40
43
|
function resolvePort(opts) {
|