insta 0.0.83 → 0.1.1
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/README.md +28 -29
- package/dist/agent.js +2 -2
- package/dist/api.js +19 -4
- package/dist/build-logs.js +1 -1
- package/dist/commands/agent-policy.js +1 -1
- package/dist/commands/auth.js +32 -18
- package/dist/commands/billing.js +5 -5
- package/dist/commands/compute.js +83 -41
- package/dist/commands/db-query.js +18 -14
- package/dist/commands/deploy.js +1 -1
- package/dist/commands/domain.js +105 -3
- package/dist/commands/env.js +1 -1
- package/dist/commands/managed-db.js +34 -0
- package/dist/commands/mcp.js +2 -2
- package/dist/commands/metrics.js +6 -5
- package/dist/commands/observe.js +2 -2
- package/dist/commands/{db.js → postgres.js} +32 -32
- package/dist/commands/regions.js +1 -1
- package/dist/commands/services.js +31 -70
- package/dist/commands/setup.js +8 -7
- package/dist/commands/storage.js +17 -2
- package/dist/commands/template.js +4 -4
- package/dist/commands/upgrade.js +20 -8
- package/dist/config.js +49 -31
- package/dist/deploy-archive.js +2 -2
- package/dist/ensure-skills.js +1 -1
- package/dist/index.js +241 -161
- package/dist/observe/hook.js +1 -1
- package/dist/observe/install.js +1 -1
- package/dist/resolve-service.js +4 -4
- package/dist/telemetry.js +8 -8
- package/dist/util.js +9 -6
- package/package.json +1 -1
package/dist/config.js
CHANGED
|
@@ -19,42 +19,60 @@ const LINK_PLANE_FILE = 'link-plane.json';
|
|
|
19
19
|
// The cloud API default. Only affects fresh installs: a persisted apiUrl (from a prior login) or
|
|
20
20
|
// INSTA_API_URL wins below.
|
|
21
21
|
const DEFAULT_API = ENVS[DEFAULT_ENV].api;
|
|
22
|
+
// The runtime `--api-url` flag, set by index.ts's preAction hook before any action loads config.
|
|
23
|
+
// Process-local, never persisted: a debugging override must not rewrite the machine's login.
|
|
24
|
+
let cliApiUrlOverride;
|
|
25
|
+
export function setApiUrlOverride(url) {
|
|
26
|
+
cliApiUrlOverride = url;
|
|
27
|
+
}
|
|
28
|
+
/** Which control plane this process talks to, and which stored session (if any) may travel with
|
|
29
|
+
* it. Pure: `parsed` is the persisted file (null when absent or unreadable), `env` the process
|
|
30
|
+
* environment, `cliOverride` the runtime flag. Precedence, most explicit first:
|
|
31
|
+
* 1. --api-url (runtime flag) — this invocation only.
|
|
32
|
+
* 2. INSTA_API_URL — a literal URL. Overrides the persisted apiUrl, not just the default,
|
|
33
|
+
* otherwise the env var is silently ignored as soon as any login has written a config file.
|
|
34
|
+
* It also outranks INSTA_ENV: a hand-written URL is the more specific instruction, and it
|
|
35
|
+
* is the only way to reach a host no environment name covers (insta-oss, a preview).
|
|
36
|
+
* 3. INSTA_ENV — a named environment (see env.ts), resolved to its api host.
|
|
37
|
+
* 4. the persisted apiUrl, written by `insta login --env|--api-url` or `insta env use`.
|
|
38
|
+
* 5. DEFAULT_API.
|
|
39
|
+
*
|
|
40
|
+
* An override that points at a DIFFERENT deployment than the stored session was minted for must
|
|
41
|
+
* not carry that session along. `env use` already drops it on an explicit switch; without this,
|
|
42
|
+
* `INSTA_ENV=staging insta …` on a prod-logged-in machine sends prod's bearer to staging and then
|
|
43
|
+
* — on the 401 — POSTs prod's REFRESH token to staging's /auth/refresh (api.ts), which is the
|
|
44
|
+
* cross-deployment credential leak env.ts's header calls out as never allowed. In-memory only:
|
|
45
|
+
* the file keeps the real login, so unsetting the override restores it. A custom host (insta-oss,
|
|
46
|
+
* a preview) is treated the same way — its session is equally foreign. */
|
|
47
|
+
export function pickApiUrl(parsed, env, cliOverride) {
|
|
48
|
+
// `env` is the environment this call is deciding for, so an ABSENT property means unset — not
|
|
49
|
+
// "ask the real process". envFromEnvVar defaults its parameter to process.env.INSTA_ENV, so
|
|
50
|
+
// passing it `env.INSTA_ENV` unguarded made a caller handing in `{}` (every test, and any future
|
|
51
|
+
// caller with a synthetic environment) silently read the ambient one instead.
|
|
52
|
+
const named = env.INSTA_ENV === undefined ? null : envFromEnvVar(env.INSTA_ENV);
|
|
53
|
+
const override = cliOverride ?? env.INSTA_API_URL ?? (named ? ENVS[named].api : undefined);
|
|
54
|
+
if (!parsed)
|
|
55
|
+
return { apiUrl: override ?? DEFAULT_API };
|
|
56
|
+
const persisted = parsed.apiUrl ?? DEFAULT_API;
|
|
57
|
+
if (override && normalizeUrl(override) !== normalizeUrl(persisted)) {
|
|
58
|
+
const scrubbed = { ...parsed, apiUrl: override };
|
|
59
|
+
delete scrubbed.accessToken;
|
|
60
|
+
delete scrubbed.refreshToken;
|
|
61
|
+
delete scrubbed.user;
|
|
62
|
+
delete scrubbed.agentCredential;
|
|
63
|
+
return scrubbed;
|
|
64
|
+
}
|
|
65
|
+
return { ...parsed, apiUrl: override ?? persisted };
|
|
66
|
+
}
|
|
22
67
|
export async function readGlobal() {
|
|
23
|
-
|
|
24
|
-
// 1. INSTA_API_URL — a literal URL. Overrides the persisted apiUrl, not just the default,
|
|
25
|
-
// otherwise the env var is silently ignored as soon as any login has written a config file.
|
|
26
|
-
// It also outranks INSTA_ENV: a hand-written URL is the more specific instruction, and it
|
|
27
|
-
// is the only way to reach a host no environment name covers (insta-oss, a preview).
|
|
28
|
-
// 2. INSTA_ENV — a named environment (see env.ts), resolved to its api host.
|
|
29
|
-
// 3. the persisted apiUrl, written by `insta login --env|--api-url` or `insta env use`.
|
|
30
|
-
// 4. DEFAULT_API.
|
|
31
|
-
const envApi = process.env.INSTA_API_URL;
|
|
32
|
-
const named = envFromEnvVar();
|
|
33
|
-
const override = envApi ?? (named ? ENVS[named].api : undefined);
|
|
68
|
+
let parsed;
|
|
34
69
|
try {
|
|
35
|
-
|
|
36
|
-
const persisted = parsed.apiUrl ?? DEFAULT_API;
|
|
37
|
-
// An override that points at a DIFFERENT deployment than the stored session was minted for
|
|
38
|
-
// must not carry that session along. `env use` already drops it on an explicit switch; without
|
|
39
|
-
// this, `INSTA_ENV=staging insta …` on a prod-logged-in machine sends prod's bearer to staging
|
|
40
|
-
// and then — on the 401 — POSTs prod's REFRESH token to staging's /auth/refresh (api.ts), which
|
|
41
|
-
// is the cross-deployment credential leak env.ts's header calls out as never allowed.
|
|
42
|
-
//
|
|
43
|
-
// In-memory only: the file keeps the real login, so unsetting the override restores it. A
|
|
44
|
-
// custom host (insta-oss, a preview) is treated the same way — its session is equally foreign.
|
|
45
|
-
if (override && normalizeUrl(override) !== normalizeUrl(persisted)) {
|
|
46
|
-
const scrubbed = { ...parsed, apiUrl: override };
|
|
47
|
-
delete scrubbed.accessToken;
|
|
48
|
-
delete scrubbed.refreshToken;
|
|
49
|
-
delete scrubbed.user;
|
|
50
|
-
delete scrubbed.agentCredential;
|
|
51
|
-
return scrubbed;
|
|
52
|
-
}
|
|
53
|
-
return { ...parsed, apiUrl: override ?? persisted };
|
|
70
|
+
parsed = JSON.parse(await readFile(GLOBAL_FILE, 'utf8'));
|
|
54
71
|
}
|
|
55
72
|
catch {
|
|
56
|
-
|
|
73
|
+
parsed = null;
|
|
57
74
|
}
|
|
75
|
+
return pickApiUrl(parsed, process.env, cliApiUrlOverride);
|
|
58
76
|
}
|
|
59
77
|
/** The environment the CLI is currently pointed at, plus everything derived from it. `env` is null
|
|
60
78
|
* when apiUrl is a custom host (insta-oss, a preview deployment) — deliberate, and left alone.
|
package/dist/deploy-archive.js
CHANGED
|
@@ -80,7 +80,7 @@ export async function deployArchive(api, projectId, ref, branch, opts, now = Dat
|
|
|
80
80
|
const operationId = started.body?.operationId;
|
|
81
81
|
if (typeof operationId !== 'string' || !operationId)
|
|
82
82
|
throw new Error('the platform accepted the deploy but returned no operation id — re-run the deploy');
|
|
83
|
-
log(`build logs: insta build
|
|
83
|
+
log(`build logs: insta build logs ${operationId}`);
|
|
84
84
|
if (started.body?.resumed === true)
|
|
85
85
|
log('resuming the deploy this archive already started');
|
|
86
86
|
const deadline = now() + DEPLOY_DEADLINE_MS;
|
|
@@ -93,7 +93,7 @@ export async function deployArchive(api, projectId, ref, branch, opts, now = Dat
|
|
|
93
93
|
}
|
|
94
94
|
})().catch(() => {
|
|
95
95
|
if (!logController.signal.aborted)
|
|
96
|
-
log(`Could not follow build logs. Retry with: insta build
|
|
96
|
+
log(`Could not follow build logs. Retry with: insta build logs ${operationId}`);
|
|
97
97
|
}) : undefined;
|
|
98
98
|
let last = '';
|
|
99
99
|
try {
|
package/dist/ensure-skills.js
CHANGED
|
@@ -27,7 +27,7 @@ const GITIGNORE_COMMENT = '# InstaCloud: agent skills installed by `npx skills a
|
|
|
27
27
|
// existing AI_AGENT (e.g. running inside another agent) rather than clobbering it.
|
|
28
28
|
const defaultRunner = (cmdIn, argsIn, inherit = false) => new Promise((resolve) => {
|
|
29
29
|
// resolveSpawnable: on Windows `npx` is a .cmd shim spawn() refuses without a shell —
|
|
30
|
-
// re-enter npm's CLI script via node instead (same treatment as `insta setup
|
|
30
|
+
// re-enter npm's CLI script via node instead (same treatment as `insta agent setup`).
|
|
31
31
|
const { cmd, args } = resolveSpawnable(cmdIn, argsIn);
|
|
32
32
|
const env = { ...process.env, AI_AGENT: process.env.AI_AGENT || 'insta' };
|
|
33
33
|
// npx exports its flags as npm_config_* to children; npm_config_package would pin the inner
|