@astrale-os/adapter-cloudflare 0.1.5 → 0.1.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/dist/astrale.d.ts +3 -3
- package/dist/astrale.d.ts.map +1 -1
- package/dist/astrale.js +29 -9
- package/dist/astrale.js.map +1 -1
- package/dist/cloudflare.d.ts.map +1 -1
- package/dist/cloudflare.js +13 -2
- package/dist/cloudflare.js.map +1 -1
- package/dist/params.d.ts +18 -0
- package/dist/params.d.ts.map +1 -1
- package/dist/wrangler-cli.d.ts +4 -0
- package/dist/wrangler-cli.d.ts.map +1 -1
- package/dist/wrangler-cli.js +53 -3
- package/dist/wrangler-cli.js.map +1 -1
- package/package.json +2 -2
- package/src/astrale.ts +30 -9
- package/src/cloudflare.ts +14 -2
- package/src/params.ts +18 -0
- package/src/wrangler-cli.ts +62 -3
- package/template/.agents/skills/astrale-cli/SKILL.md +444 -0
- package/template/.agents/skills/astrale-domain/SKILL.md +25 -3
- package/template/env.ts +5 -1
- package/template/package.json +3 -3
package/dist/astrale.d.ts
CHANGED
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
* localhost) — managed deploys change WHERE the worker runs, not how you
|
|
18
18
|
* iterate locally.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* Managed deploys ship the client SPA (served under `/ui` by the box) and
|
|
21
|
+
* runtime secrets (dotenv map on the install call, encrypted at rest
|
|
22
|
+
* platform-side; platform-managed env keys always win precedence).
|
|
23
23
|
*/
|
|
24
24
|
import type { DomainAdapter } from '@astrale-os/devkit';
|
|
25
25
|
import type { AstraleParams } from './params';
|
package/dist/astrale.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"astrale.d.ts","sourceRoot":"","sources":["../src/astrale.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAQvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAY7C,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,aAAa,CAAC,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"astrale.d.ts","sourceRoot":"","sources":["../src/astrale.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAQvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAY7C,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,aAAa,CAAC,aAAa,CAAC,CAoIzF"}
|
package/dist/astrale.js
CHANGED
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
* localhost) — managed deploys change WHERE the worker runs, not how you
|
|
18
18
|
* iterate locally.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* Managed deploys ship the client SPA (served under `/ui` by the box) and
|
|
21
|
+
* runtime secrets (dotenv map on the install call, encrypted at rest
|
|
22
|
+
* platform-side; platform-managed env keys always win precedence).
|
|
23
23
|
*/
|
|
24
24
|
import { defineAdapter, loadDotenvFile } from '@astrale-os/devkit';
|
|
25
25
|
import { spawn } from 'node:child_process';
|
|
@@ -41,16 +41,22 @@ export function astrale(envs) {
|
|
|
41
41
|
// Local dev is unchanged: wrangler dev on localhost. Managed deploys change
|
|
42
42
|
// WHERE the worker ships, not the inner loop.
|
|
43
43
|
async watch(params, ctx) {
|
|
44
|
-
const { configPath } = await prepare({
|
|
44
|
+
const { configPath } = await prepare({
|
|
45
|
+
...(params.vars ? { vars: params.vars } : {}),
|
|
46
|
+
...(params.host ? { host: params.host } : {}),
|
|
47
|
+
port: params.port ?? DEFAULT_PORT,
|
|
48
|
+
}, ctx, 'dev');
|
|
45
49
|
const handle = await runWranglerDev({
|
|
46
50
|
projectDir: ctx.projectDir,
|
|
47
51
|
configPath,
|
|
48
52
|
port: params.port ?? DEFAULT_PORT,
|
|
49
53
|
remote: false,
|
|
54
|
+
autoPickPort: params.port === undefined,
|
|
55
|
+
...(params.host ? { ip: '0.0.0.0' } : {}),
|
|
50
56
|
onReload: ctx.onReload,
|
|
51
57
|
onLog: logTo(),
|
|
52
58
|
});
|
|
53
|
-
return { url: handle.url, stop: handle.stop };
|
|
59
|
+
return { url: params.host ?? handle.url, stop: handle.stop };
|
|
54
60
|
},
|
|
55
61
|
async deploy(params, ctx) {
|
|
56
62
|
const log = logTo();
|
|
@@ -129,7 +135,14 @@ export function astrale(envs) {
|
|
|
129
135
|
throw new Error('managed install returned no serviceSlug — cannot derive the service URL');
|
|
130
136
|
}
|
|
131
137
|
const region = params.region ?? DEFAULT_REGION;
|
|
132
|
-
|
|
138
|
+
const url = `https://${installed.serviceSlug}.svc.${region}.astrale.ai`;
|
|
139
|
+
return {
|
|
140
|
+
url,
|
|
141
|
+
// Managed deploys already installed on the instance — override the
|
|
142
|
+
// devkit's default "install on an instance" footer with the truth.
|
|
143
|
+
nextSteps: ` installed on "${params.instance}" — call it:\n` +
|
|
144
|
+
` astrale call "/${ctx.domain.origin}/..." -i ${params.instance}`,
|
|
145
|
+
};
|
|
133
146
|
},
|
|
134
147
|
secretsFile(params) {
|
|
135
148
|
return params.secrets;
|
|
@@ -147,7 +160,11 @@ function packageNameFor(origin) {
|
|
|
147
160
|
* minting) — reimplementing that here would fork the trust path.
|
|
148
161
|
*/
|
|
149
162
|
async function astraleCall(projectDir, params, adminUrl, call) {
|
|
150
|
-
|
|
163
|
+
// Saga-sized timeout: a COLD managed install (fresh service on the host)
|
|
164
|
+
// runs runtime staging + serve probes and regularly exceeds the CLI's 30s
|
|
165
|
+
// default — which doesn't just fail the client, it can kill the saga
|
|
166
|
+
// mid-flight. Same budget as `astrale instance create`.
|
|
167
|
+
const args = ['call', call.path, '--url', adminUrl, '--json', '--timeout', '240000'];
|
|
151
168
|
if (params.identity)
|
|
152
169
|
args.push('--as', params.identity);
|
|
153
170
|
const payload = JSON.stringify(call.data);
|
|
@@ -169,8 +186,11 @@ async function astraleCall(projectDir, params, adminUrl, call) {
|
|
|
169
186
|
}
|
|
170
187
|
});
|
|
171
188
|
if (code !== 0) {
|
|
172
|
-
|
|
173
|
-
|
|
189
|
+
// Only suggest re-login for AUTH-shaped failures — a timeout or audience
|
|
190
|
+
// error pointed at "auth login" sends users chasing the wrong fix.
|
|
191
|
+
const authShaped = /AUTH_ERROR|expired|not signed in|credential/i.test(out);
|
|
192
|
+
throw new Error(`astrale call ${call.path} failed (exit ${code}): ${out.trim().slice(0, 500)}` +
|
|
193
|
+
(authShaped ? `\nIs the astrale CLI installed and signed in? (astrale auth login)` : ''));
|
|
174
194
|
}
|
|
175
195
|
try {
|
|
176
196
|
return JSON.parse(out);
|
package/dist/astrale.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"astrale.js","sourceRoot":"","sources":["../src/astrale.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAIhC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,iBAAiB,EAAE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,CAAC,CAAA;IAChG,CAAC;AACH,CAAC;AAED,8EAA8E;AAC9E,SAAS,UAAU,CAAC,WAAmB;IACrC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA;IAC7B,IAAI,IAAI,EAAE,CAAC;QACT,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,CAAA;QAC1D,IAAI,UAAU,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAA;IAC7C,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
package/dist/cloudflare.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudflare.d.ts","sourceRoot":"","sources":["../src/cloudflare.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAM5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAUhD,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,GACrC,aAAa,CAAC,gBAAgB,CAAC,
|
|
1
|
+
{"version":3,"file":"cloudflare.d.ts","sourceRoot":"","sources":["../src/cloudflare.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAM5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAUhD,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,GACrC,aAAa,CAAC,gBAAgB,CAAC,CA0DjC;AAID,wBAAsB,OAAO,CAC3B,MAAM,EAAE,gBAAgB,EACxB,GAAG,EAAE,QAAQ,GAAG,SAAS,EACzB,IAAI,EAAE,KAAK,GAAG,QAAQ,GACrB,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAkFhG;AAoCD,wBAAgB,UAAU,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAsB3E;AAED,wBAAgB,KAAK,IAAI,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAE9C"}
|
package/dist/cloudflare.js
CHANGED
|
@@ -30,10 +30,14 @@ export function cloudflare(envs) {
|
|
|
30
30
|
configPath,
|
|
31
31
|
port,
|
|
32
32
|
remote: Boolean(params.remote),
|
|
33
|
+
autoPickPort: params.port === undefined,
|
|
34
|
+
...(params.host ? { ip: '0.0.0.0' } : {}),
|
|
33
35
|
onReload: ctx.onReload,
|
|
34
36
|
onLog: logTo(),
|
|
35
37
|
});
|
|
36
|
-
|
|
38
|
+
// With --host the actionable URL is the PUBLIC one (the tunnel/proxy
|
|
39
|
+
// front), not the local bind — print and spec-stamp that.
|
|
40
|
+
return { url: params.host ?? handle.url, stop: handle.stop };
|
|
37
41
|
},
|
|
38
42
|
async deploy(params, ctx) {
|
|
39
43
|
const { configPath, fallbackConfigPath, workerName: name, } = await prepare(params, ctx, 'deploy');
|
|
@@ -94,7 +98,14 @@ export async function prepare(params, ctx, mode) {
|
|
|
94
98
|
// hostnames. Dev + workers.dev-only deploys are single-host, so the worker
|
|
95
99
|
// falls back to the per-request Host (always the canonical URL there).
|
|
96
100
|
// An explicit `vars.WORKER_URL` (e.g. a tunnel/proxy front) wins.
|
|
97
|
-
|
|
101
|
+
// Dev behind a tunnel/proxy (`--host`) pins WORKER_URL the same way a routed
|
|
102
|
+
// deploy does — the per-request Host there is the proxy's INTERNAL hostname
|
|
103
|
+
// and would corrupt the worker's `iss`.
|
|
104
|
+
const workerUrl = mode === 'deploy' && params.route
|
|
105
|
+
? `https://${params.route}`
|
|
106
|
+
: mode === 'dev' && params.host
|
|
107
|
+
? params.host
|
|
108
|
+
: undefined;
|
|
98
109
|
// Dev injects secrets as local vars (the gitignored .astrale config never
|
|
99
110
|
// ships); deploy keeps secrets out of the config and pushes them encrypted.
|
|
100
111
|
const vars = {
|
package/dist/cloudflare.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudflare.js","sourceRoot":"","sources":["../src/cloudflare.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACjE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAIhC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAElF,MAAM,YAAY,GAAG,IAAI,CAAA;AAEzB,MAAM,UAAU,UAAU,CACxB,IAAsC;IAEtC,OAAO,aAAa,CAAmB;QACrC,IAAI,EAAE,YAAY;QAClB,IAAI;QAEJ,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG;YACrB,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;YAC9D,IAAI,GAAG,CAAC,SAAS;gBAAE,MAAM,WAAW,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,CA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,CACb,+CAA+C,MAAM,CAAC,UAAU,yBAAyB;gBACvF,yFAAyF;gBACzF,kCAAkC,CACrC,CAAA;QACH,CAAC;QACD,OAAO,MAAM,CAAC,UAAU,CAAA;IAC1B,CAAC;IACD,gFAAgF;IAChF,gFAAgF;IAChF,gCAAgC;IAChC,OAAO,MAAM;SACV,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;SACZ,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;AAC5B,CAAC;AAED,MAAM,UAAU,KAAK;IACnB,OAAO,CAAC,IAAY,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,IAAI,WAAW,CAAC,CAAA;AAC5E,CAAC"}
|
package/dist/params.d.ts
CHANGED
|
@@ -21,6 +21,15 @@ export interface CloudflareParams {
|
|
|
21
21
|
secrets?: string;
|
|
22
22
|
/** Local dev port for `wrangler dev`. Default 8787. */
|
|
23
23
|
port?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Public URL the dev server is reached through (tunnel / sandbox preview /
|
|
26
|
+
* reverse proxy), e.g. `'https://my-box.preview.dev'`. Sets BOTH effects an
|
|
27
|
+
* off-localhost dev needs: wrangler binds 0.0.0.0 (reachable from outside)
|
|
28
|
+
* and `WORKER_URL` is pinned to this URL so the worker's per-request-Host
|
|
29
|
+
* identity (`iss`) doesn't drift to the proxy's internal hostname.
|
|
30
|
+
* Usually injected by `pnpm dev --host <url>` rather than written here.
|
|
31
|
+
*/
|
|
32
|
+
host?: string;
|
|
24
33
|
/** Override the Worker name. Default: derived from the domain origin. */
|
|
25
34
|
workerName?: string;
|
|
26
35
|
/** Run `wrangler dev --remote` (edge isolate) instead of local workerd. */
|
|
@@ -67,6 +76,15 @@ export interface AstraleParams {
|
|
|
67
76
|
secrets?: string;
|
|
68
77
|
/** Local dev port for `wrangler dev`. Default 8787. */
|
|
69
78
|
port?: number;
|
|
79
|
+
/**
|
|
80
|
+
* Public URL the dev server is reached through (tunnel / sandbox preview /
|
|
81
|
+
* reverse proxy), e.g. `'https://my-box.preview.dev'`. Sets BOTH effects an
|
|
82
|
+
* off-localhost dev needs: wrangler binds 0.0.0.0 (reachable from outside)
|
|
83
|
+
* and `WORKER_URL` is pinned to this URL so the worker's per-request-Host
|
|
84
|
+
* identity (`iss`) doesn't drift to the proxy's internal hostname.
|
|
85
|
+
* Usually injected by `pnpm dev --host <url>` rather than written here.
|
|
86
|
+
*/
|
|
87
|
+
host?: string;
|
|
70
88
|
/** Extra plain vars for local `watch`. */
|
|
71
89
|
vars?: Record<string, string>;
|
|
72
90
|
}
|
package/dist/params.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../src/params.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,8DAA8D;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7B;;;;;;;;;;;;;;;;;OAiBG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACnC;AAED,gEAAgE;AAChE,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,mEAAmE;IACnE,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAA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AAC,EAAE,MAAM,CAAA;IAChB,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC9B"}
|
package/dist/wrangler-cli.d.ts
CHANGED
|
@@ -15,6 +15,10 @@ export declare function runWranglerDev(args: {
|
|
|
15
15
|
configPath: string;
|
|
16
16
|
port: number;
|
|
17
17
|
remote: boolean;
|
|
18
|
+
/** Bind address — '0.0.0.0' for tunneled/proxied dev (`--host`). Default loopback. */
|
|
19
|
+
ip?: string;
|
|
20
|
+
/** When the port was NOT explicitly chosen, dodge a taken one automatically. */
|
|
21
|
+
autoPickPort?: boolean;
|
|
18
22
|
onReload: () => void;
|
|
19
23
|
onLog?: (line: string) => void;
|
|
20
24
|
}): Promise<DevHandle>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrangler-cli.d.ts","sourceRoot":"","sources":["../src/wrangler-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"wrangler-cli.d.ts","sourceRoot":"","sources":["../src/wrangler-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAmBH,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACtB;AA8BD,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,OAAO,CAAA;IACf,sFAAsF;IACtF,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,gFAAgF;IAChF,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,QAAQ,EAAE,MAAM,IAAI,CAAA;IACp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hB;AAyCD;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAC/B,GAAG,OAAO,CAAC,MAAM,CAAC,CAalB"}
|
package/dist/wrangler-cli.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { spawn } from 'node:child_process';
|
|
10
10
|
import { existsSync, readdirSync } from 'node:fs';
|
|
11
11
|
import { mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
12
|
+
import { createServer } from 'node:net';
|
|
12
13
|
import { tmpdir } from 'node:os';
|
|
13
14
|
import { join } from 'node:path';
|
|
14
15
|
import { parseDeployUrl, parseDevReadyUrl } from './parse-output';
|
|
@@ -18,8 +19,40 @@ function wranglerCommand(projectDir) {
|
|
|
18
19
|
return { cmd: local, prefix: [] };
|
|
19
20
|
return { cmd: 'npx', prefix: ['--yes', 'wrangler'] };
|
|
20
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* True when `port` is free on `host`. A taken port previously made `wrangler
|
|
24
|
+
* dev` either die ("Address already in use") or — worse — a FIRST probe hit a
|
|
25
|
+
* DIFFERENT project's dev server on the same port (observed in agent runs:
|
|
26
|
+
* every reader of the docs converges on 8787/8899).
|
|
27
|
+
*/
|
|
28
|
+
function portFree(port, host) {
|
|
29
|
+
return new Promise((resolve) => {
|
|
30
|
+
const srv = createServer();
|
|
31
|
+
srv.once('error', () => resolve(false));
|
|
32
|
+
srv.once('listening', () => srv.close(() => resolve(true)));
|
|
33
|
+
srv.listen(port, host);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/** An OS-assigned free port. */
|
|
37
|
+
function ephemeralPort(host) {
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
const srv = createServer();
|
|
40
|
+
srv.once('error', reject);
|
|
41
|
+
srv.listen(0, host, () => {
|
|
42
|
+
const addr = srv.address();
|
|
43
|
+
const port = typeof addr === 'object' && addr ? addr.port : 0;
|
|
44
|
+
srv.close(() => resolve(port));
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
21
48
|
export async function runWranglerDev(args) {
|
|
22
49
|
const { cmd, prefix } = wranglerCommand(args.projectDir);
|
|
50
|
+
const bindHost = args.ip ?? '127.0.0.1';
|
|
51
|
+
if (args.autoPickPort && !(await portFree(args.port, bindHost))) {
|
|
52
|
+
const picked = await ephemeralPort(bindHost);
|
|
53
|
+
args.onLog?.(`port ${args.port} is taken — using ${picked} instead (pass --port to pin one)`);
|
|
54
|
+
args = { ...args, port: picked };
|
|
55
|
+
}
|
|
23
56
|
const wranglerArgs = [
|
|
24
57
|
...prefix,
|
|
25
58
|
'dev',
|
|
@@ -30,7 +63,7 @@ export async function runWranglerDev(args) {
|
|
|
30
63
|
'--local-protocol',
|
|
31
64
|
'http',
|
|
32
65
|
'--ip',
|
|
33
|
-
'127.0.0.1',
|
|
66
|
+
args.ip ?? '127.0.0.1',
|
|
34
67
|
...(args.remote ? ['--remote'] : []),
|
|
35
68
|
];
|
|
36
69
|
const child = spawn(cmd, wranglerArgs, {
|
|
@@ -39,7 +72,12 @@ export async function runWranglerDev(args) {
|
|
|
39
72
|
env: { ...process.env, WRANGLER_SEND_METRICS: 'false' },
|
|
40
73
|
});
|
|
41
74
|
const fallbackUrl = `http://localhost:${args.port}`;
|
|
75
|
+
// (args.port may have been re-picked above — everything below reads args.port)
|
|
42
76
|
let resolved = false;
|
|
77
|
+
// Wrangler's watch mode STAYS ALIVE on a build failure (listener up, worker
|
|
78
|
+
// never answers) — the classic silent hang. Track build errors so the
|
|
79
|
+
// safety net can fail LOUD instead of resolving a dead URL.
|
|
80
|
+
let buildErrorTail = '';
|
|
43
81
|
const url = await new Promise((resolve, reject) => {
|
|
44
82
|
const onData = (buf) => {
|
|
45
83
|
const text = buf.toString();
|
|
@@ -47,6 +85,9 @@ export async function runWranglerDev(args) {
|
|
|
47
85
|
if (line.trim())
|
|
48
86
|
args.onLog?.(line);
|
|
49
87
|
}
|
|
88
|
+
if (/✘ \[ERROR\]|Build failed|Could not resolve "/.test(text)) {
|
|
89
|
+
buildErrorTail = (buildErrorTail + text).slice(-2000);
|
|
90
|
+
}
|
|
50
91
|
if (!resolved) {
|
|
51
92
|
const ready = parseDevReadyUrl(text, args.port);
|
|
52
93
|
if (ready) {
|
|
@@ -73,11 +114,20 @@ export async function runWranglerDev(args) {
|
|
|
73
114
|
}
|
|
74
115
|
});
|
|
75
116
|
// Safety net: if we never matched a URL but the process is alive, assume the
|
|
76
|
-
// conventional localhost URL after a grace period
|
|
117
|
+
// conventional localhost URL after a grace period — UNLESS the build
|
|
118
|
+
// failed, in which case a listener may be up but the worker will never
|
|
119
|
+
// answer: fail loud with the build output instead of handing back a dead
|
|
120
|
+
// URL.
|
|
77
121
|
setTimeout(() => {
|
|
78
122
|
if (!resolved && child.exitCode === null) {
|
|
79
123
|
resolved = true;
|
|
80
|
-
|
|
124
|
+
if (buildErrorTail) {
|
|
125
|
+
void stopChild(child);
|
|
126
|
+
reject(new Error(`worker build failed — the dev server would hang silently.\n${buildErrorTail}`));
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
resolve(fallbackUrl);
|
|
130
|
+
}
|
|
81
131
|
}
|
|
82
132
|
}, 15_000).unref?.();
|
|
83
133
|
});
|
package/dist/wrangler-cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrangler-cli.js","sourceRoot":"","sources":["../src/wrangler-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,SAA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IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,EACxF,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,KAAK,CACX,CAAA;IACD,IAAI,IAAI,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,IAAI,MAAM,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAC5F,MAAM,EAAE,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA;IACpE,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,sCAAsC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;IACzF,MAAM,SAAS,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAE,CAAA;IAClE,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;AACrC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrale-os/adapter-cloudflare",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Deploy an Astrale domain as a standalone Cloudflare Worker",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adapter",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"jose": "^6.1.3",
|
|
31
|
-
"@astrale-os/devkit": "^0.1.
|
|
31
|
+
"@astrale-os/devkit": "^0.1.5"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@astrale-os/ox": ">=0.1.0 <1.0.0",
|
package/src/astrale.ts
CHANGED
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
* localhost) — managed deploys change WHERE the worker runs, not how you
|
|
18
18
|
* iterate locally.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* Managed deploys ship the client SPA (served under `/ui` by the box) and
|
|
21
|
+
* runtime secrets (dotenv map on the install call, encrypted at rest
|
|
22
|
+
* platform-side; platform-managed env keys always win precedence).
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import type { DomainAdapter } from '@astrale-os/devkit'
|
|
@@ -51,7 +51,11 @@ export function astrale(envs: Record<string, AstraleParams>): DomainAdapter<Astr
|
|
|
51
51
|
// WHERE the worker ships, not the inner loop.
|
|
52
52
|
async watch(params, ctx) {
|
|
53
53
|
const { configPath } = await prepare(
|
|
54
|
-
{
|
|
54
|
+
{
|
|
55
|
+
...(params.vars ? { vars: params.vars } : {}),
|
|
56
|
+
...(params.host ? { host: params.host } : {}),
|
|
57
|
+
port: params.port ?? DEFAULT_PORT,
|
|
58
|
+
},
|
|
55
59
|
ctx,
|
|
56
60
|
'dev',
|
|
57
61
|
)
|
|
@@ -60,10 +64,12 @@ export function astrale(envs: Record<string, AstraleParams>): DomainAdapter<Astr
|
|
|
60
64
|
configPath,
|
|
61
65
|
port: params.port ?? DEFAULT_PORT,
|
|
62
66
|
remote: false,
|
|
67
|
+
autoPickPort: params.port === undefined,
|
|
68
|
+
...(params.host ? { ip: '0.0.0.0' } : {}),
|
|
63
69
|
onReload: ctx.onReload,
|
|
64
70
|
onLog: logTo(),
|
|
65
71
|
})
|
|
66
|
-
return { url: handle.url, stop: handle.stop }
|
|
72
|
+
return { url: params.host ?? handle.url, stop: handle.stop }
|
|
67
73
|
},
|
|
68
74
|
|
|
69
75
|
async deploy(params, ctx) {
|
|
@@ -153,7 +159,15 @@ export function astrale(envs: Record<string, AstraleParams>): DomainAdapter<Astr
|
|
|
153
159
|
throw new Error('managed install returned no serviceSlug — cannot derive the service URL')
|
|
154
160
|
}
|
|
155
161
|
const region = params.region ?? DEFAULT_REGION
|
|
156
|
-
|
|
162
|
+
const url = `https://${installed.serviceSlug}.svc.${region}.astrale.ai`
|
|
163
|
+
return {
|
|
164
|
+
url,
|
|
165
|
+
// Managed deploys already installed on the instance — override the
|
|
166
|
+
// devkit's default "install on an instance" footer with the truth.
|
|
167
|
+
nextSteps:
|
|
168
|
+
` installed on "${params.instance}" — call it:\n` +
|
|
169
|
+
` astrale call "/${ctx.domain.origin}/..." -i ${params.instance}`,
|
|
170
|
+
}
|
|
157
171
|
},
|
|
158
172
|
|
|
159
173
|
secretsFile(params) {
|
|
@@ -179,7 +193,11 @@ async function astraleCall(
|
|
|
179
193
|
adminUrl: string,
|
|
180
194
|
call: { path: string; data: unknown; viaStdin?: boolean },
|
|
181
195
|
): Promise<unknown> {
|
|
182
|
-
|
|
196
|
+
// Saga-sized timeout: a COLD managed install (fresh service on the host)
|
|
197
|
+
// runs runtime staging + serve probes and regularly exceeds the CLI's 30s
|
|
198
|
+
// default — which doesn't just fail the client, it can kill the saga
|
|
199
|
+
// mid-flight. Same budget as `astrale instance create`.
|
|
200
|
+
const args = ['call', call.path, '--url', adminUrl, '--json', '--timeout', '240000']
|
|
183
201
|
if (params.identity) args.push('--as', params.identity)
|
|
184
202
|
const payload = JSON.stringify(call.data)
|
|
185
203
|
if (!call.viaStdin) args.push('--data', payload)
|
|
@@ -200,9 +218,12 @@ async function astraleCall(
|
|
|
200
218
|
}
|
|
201
219
|
})
|
|
202
220
|
if (code !== 0) {
|
|
221
|
+
// Only suggest re-login for AUTH-shaped failures — a timeout or audience
|
|
222
|
+
// error pointed at "auth login" sends users chasing the wrong fix.
|
|
223
|
+
const authShaped = /AUTH_ERROR|expired|not signed in|credential/i.test(out)
|
|
203
224
|
throw new Error(
|
|
204
|
-
`astrale call ${call.path} failed (exit ${code}): ${out.trim().slice(0, 500)}
|
|
205
|
-
|
|
225
|
+
`astrale call ${call.path} failed (exit ${code}): ${out.trim().slice(0, 500)}` +
|
|
226
|
+
(authShaped ? `\nIs the astrale CLI installed and signed in? (astrale auth login)` : ''),
|
|
206
227
|
)
|
|
207
228
|
}
|
|
208
229
|
try {
|
package/src/cloudflare.ts
CHANGED
|
@@ -40,10 +40,14 @@ export function cloudflare(
|
|
|
40
40
|
configPath,
|
|
41
41
|
port,
|
|
42
42
|
remote: Boolean(params.remote),
|
|
43
|
+
autoPickPort: params.port === undefined,
|
|
44
|
+
...(params.host ? { ip: '0.0.0.0' } : {}),
|
|
43
45
|
onReload: ctx.onReload,
|
|
44
46
|
onLog: logTo(),
|
|
45
47
|
})
|
|
46
|
-
|
|
48
|
+
// With --host the actionable URL is the PUBLIC one (the tunnel/proxy
|
|
49
|
+
// front), not the local bind — print and spec-stamp that.
|
|
50
|
+
return { url: params.host ?? handle.url, stop: handle.stop }
|
|
47
51
|
},
|
|
48
52
|
|
|
49
53
|
async deploy(params, ctx) {
|
|
@@ -121,7 +125,15 @@ export async function prepare(
|
|
|
121
125
|
// hostnames. Dev + workers.dev-only deploys are single-host, so the worker
|
|
122
126
|
// falls back to the per-request Host (always the canonical URL there).
|
|
123
127
|
// An explicit `vars.WORKER_URL` (e.g. a tunnel/proxy front) wins.
|
|
124
|
-
|
|
128
|
+
// Dev behind a tunnel/proxy (`--host`) pins WORKER_URL the same way a routed
|
|
129
|
+
// deploy does — the per-request Host there is the proxy's INTERNAL hostname
|
|
130
|
+
// and would corrupt the worker's `iss`.
|
|
131
|
+
const workerUrl =
|
|
132
|
+
mode === 'deploy' && params.route
|
|
133
|
+
? `https://${params.route}`
|
|
134
|
+
: mode === 'dev' && params.host
|
|
135
|
+
? params.host
|
|
136
|
+
: undefined
|
|
125
137
|
|
|
126
138
|
// Dev injects secrets as local vars (the gitignored .astrale config never
|
|
127
139
|
// ships); deploy keeps secrets out of the config and pushes them encrypted.
|
package/src/params.ts
CHANGED
|
@@ -21,6 +21,15 @@ export interface CloudflareParams {
|
|
|
21
21
|
secrets?: string
|
|
22
22
|
/** Local dev port for `wrangler dev`. Default 8787. */
|
|
23
23
|
port?: number
|
|
24
|
+
/**
|
|
25
|
+
* Public URL the dev server is reached through (tunnel / sandbox preview /
|
|
26
|
+
* reverse proxy), e.g. `'https://my-box.preview.dev'`. Sets BOTH effects an
|
|
27
|
+
* off-localhost dev needs: wrangler binds 0.0.0.0 (reachable from outside)
|
|
28
|
+
* and `WORKER_URL` is pinned to this URL so the worker's per-request-Host
|
|
29
|
+
* identity (`iss`) doesn't drift to the proxy's internal hostname.
|
|
30
|
+
* Usually injected by `pnpm dev --host <url>` rather than written here.
|
|
31
|
+
*/
|
|
32
|
+
host?: string
|
|
24
33
|
/** Override the Worker name. Default: derived from the domain origin. */
|
|
25
34
|
workerName?: string
|
|
26
35
|
/** Run `wrangler dev --remote` (edge isolate) instead of local workerd. */
|
|
@@ -68,6 +77,15 @@ export interface AstraleParams {
|
|
|
68
77
|
secrets?: string
|
|
69
78
|
/** Local dev port for `wrangler dev`. Default 8787. */
|
|
70
79
|
port?: number
|
|
80
|
+
/**
|
|
81
|
+
* Public URL the dev server is reached through (tunnel / sandbox preview /
|
|
82
|
+
* reverse proxy), e.g. `'https://my-box.preview.dev'`. Sets BOTH effects an
|
|
83
|
+
* off-localhost dev needs: wrangler binds 0.0.0.0 (reachable from outside)
|
|
84
|
+
* and `WORKER_URL` is pinned to this URL so the worker's per-request-Host
|
|
85
|
+
* identity (`iss`) doesn't drift to the proxy's internal hostname.
|
|
86
|
+
* Usually injected by `pnpm dev --host <url>` rather than written here.
|
|
87
|
+
*/
|
|
88
|
+
host?: string
|
|
71
89
|
/** Extra plain vars for local `watch`. */
|
|
72
90
|
vars?: Record<string, string>
|
|
73
91
|
}
|
package/src/wrangler-cli.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { ChildProcess } from 'node:child_process'
|
|
|
12
12
|
import { spawn } from 'node:child_process'
|
|
13
13
|
import { existsSync, readdirSync } from 'node:fs'
|
|
14
14
|
import { mkdtemp, rm, writeFile } from 'node:fs/promises'
|
|
15
|
+
import { createServer } from 'node:net'
|
|
15
16
|
import { tmpdir } from 'node:os'
|
|
16
17
|
import { join } from 'node:path'
|
|
17
18
|
|
|
@@ -28,15 +29,53 @@ export interface DevHandle {
|
|
|
28
29
|
stop(): Promise<void>
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
/**
|
|
33
|
+
* True when `port` is free on `host`. A taken port previously made `wrangler
|
|
34
|
+
* dev` either die ("Address already in use") or — worse — a FIRST probe hit a
|
|
35
|
+
* DIFFERENT project's dev server on the same port (observed in agent runs:
|
|
36
|
+
* every reader of the docs converges on 8787/8899).
|
|
37
|
+
*/
|
|
38
|
+
function portFree(port: number, host: string): Promise<boolean> {
|
|
39
|
+
return new Promise((resolve) => {
|
|
40
|
+
const srv = createServer()
|
|
41
|
+
srv.once('error', () => resolve(false))
|
|
42
|
+
srv.once('listening', () => srv.close(() => resolve(true)))
|
|
43
|
+
srv.listen(port, host)
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** An OS-assigned free port. */
|
|
48
|
+
function ephemeralPort(host: string): Promise<number> {
|
|
49
|
+
return new Promise((resolve, reject) => {
|
|
50
|
+
const srv = createServer()
|
|
51
|
+
srv.once('error', reject)
|
|
52
|
+
srv.listen(0, host, () => {
|
|
53
|
+
const addr = srv.address()
|
|
54
|
+
const port = typeof addr === 'object' && addr ? addr.port : 0
|
|
55
|
+
srv.close(() => resolve(port))
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
|
|
31
60
|
export async function runWranglerDev(args: {
|
|
32
61
|
projectDir: string
|
|
33
62
|
configPath: string
|
|
34
63
|
port: number
|
|
35
64
|
remote: boolean
|
|
65
|
+
/** Bind address — '0.0.0.0' for tunneled/proxied dev (`--host`). Default loopback. */
|
|
66
|
+
ip?: string
|
|
67
|
+
/** When the port was NOT explicitly chosen, dodge a taken one automatically. */
|
|
68
|
+
autoPickPort?: boolean
|
|
36
69
|
onReload: () => void
|
|
37
70
|
onLog?: (line: string) => void
|
|
38
71
|
}): Promise<DevHandle> {
|
|
39
72
|
const { cmd, prefix } = wranglerCommand(args.projectDir)
|
|
73
|
+
const bindHost = args.ip ?? '127.0.0.1'
|
|
74
|
+
if (args.autoPickPort && !(await portFree(args.port, bindHost))) {
|
|
75
|
+
const picked = await ephemeralPort(bindHost)
|
|
76
|
+
args.onLog?.(`port ${args.port} is taken — using ${picked} instead (pass --port to pin one)`)
|
|
77
|
+
args = { ...args, port: picked }
|
|
78
|
+
}
|
|
40
79
|
const wranglerArgs = [
|
|
41
80
|
...prefix,
|
|
42
81
|
'dev',
|
|
@@ -47,7 +86,7 @@ export async function runWranglerDev(args: {
|
|
|
47
86
|
'--local-protocol',
|
|
48
87
|
'http',
|
|
49
88
|
'--ip',
|
|
50
|
-
'127.0.0.1',
|
|
89
|
+
args.ip ?? '127.0.0.1',
|
|
51
90
|
...(args.remote ? ['--remote'] : []),
|
|
52
91
|
]
|
|
53
92
|
|
|
@@ -58,7 +97,12 @@ export async function runWranglerDev(args: {
|
|
|
58
97
|
})
|
|
59
98
|
|
|
60
99
|
const fallbackUrl = `http://localhost:${args.port}`
|
|
100
|
+
// (args.port may have been re-picked above — everything below reads args.port)
|
|
61
101
|
let resolved = false
|
|
102
|
+
// Wrangler's watch mode STAYS ALIVE on a build failure (listener up, worker
|
|
103
|
+
// never answers) — the classic silent hang. Track build errors so the
|
|
104
|
+
// safety net can fail LOUD instead of resolving a dead URL.
|
|
105
|
+
let buildErrorTail = ''
|
|
62
106
|
|
|
63
107
|
const url = await new Promise<string>((resolve, reject) => {
|
|
64
108
|
const onData = (buf: Buffer) => {
|
|
@@ -66,6 +110,9 @@ export async function runWranglerDev(args: {
|
|
|
66
110
|
for (const line of text.split('\n')) {
|
|
67
111
|
if (line.trim()) args.onLog?.(line)
|
|
68
112
|
}
|
|
113
|
+
if (/✘ \[ERROR\]|Build failed|Could not resolve "/.test(text)) {
|
|
114
|
+
buildErrorTail = (buildErrorTail + text).slice(-2000)
|
|
115
|
+
}
|
|
69
116
|
if (!resolved) {
|
|
70
117
|
const ready = parseDevReadyUrl(text, args.port)
|
|
71
118
|
if (ready) {
|
|
@@ -91,11 +138,23 @@ export async function runWranglerDev(args: {
|
|
|
91
138
|
}
|
|
92
139
|
})
|
|
93
140
|
// Safety net: if we never matched a URL but the process is alive, assume the
|
|
94
|
-
// conventional localhost URL after a grace period
|
|
141
|
+
// conventional localhost URL after a grace period — UNLESS the build
|
|
142
|
+
// failed, in which case a listener may be up but the worker will never
|
|
143
|
+
// answer: fail loud with the build output instead of handing back a dead
|
|
144
|
+
// URL.
|
|
95
145
|
setTimeout(() => {
|
|
96
146
|
if (!resolved && child.exitCode === null) {
|
|
97
147
|
resolved = true
|
|
98
|
-
|
|
148
|
+
if (buildErrorTail) {
|
|
149
|
+
void stopChild(child)
|
|
150
|
+
reject(
|
|
151
|
+
new Error(
|
|
152
|
+
`worker build failed — the dev server would hang silently.\n${buildErrorTail}`,
|
|
153
|
+
),
|
|
154
|
+
)
|
|
155
|
+
} else {
|
|
156
|
+
resolve(fallbackUrl)
|
|
157
|
+
}
|
|
99
158
|
}
|
|
100
159
|
}, 15_000).unref?.()
|
|
101
160
|
})
|
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: astrale-cli
|
|
3
|
+
description: Reference for the Astrale CLI (binary `astrale`, package `@astrale-os/astrale`) - CLI setup, command composition, graph exploration and querying, kernel calls, instance bookmarks and admin-provisioned instances, identity management, delegation tokens, browser sessions, output behavior, debugging, and local storage.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Astrale CLI
|
|
7
|
+
|
|
8
|
+
`astrale` is the CLI for connecting to Astrale kernels. It authenticates,
|
|
9
|
+
selects an instance, calls kernel operations, inspects graph nodes, mints
|
|
10
|
+
delegation tokens, and prepares authenticated browser sessions for agents.
|
|
11
|
+
|
|
12
|
+
The command surface lives in the code. Use `astrale --help` and
|
|
13
|
+
`astrale <cmd> --help` as the source of truth for commands, flags, defaults,
|
|
14
|
+
and examples. This skill should only hold cross-cutting model details and
|
|
15
|
+
common recipes that help compose those commands correctly.
|
|
16
|
+
|
|
17
|
+
- Binary: `astrale`
|
|
18
|
+
- npm package: `@astrale-os/astrale`
|
|
19
|
+
- Runtime: Bun
|
|
20
|
+
- Framework: Commander.js
|
|
21
|
+
- Dev entrypoint: `bun cli/bin/astrale.ts <command>`
|
|
22
|
+
|
|
23
|
+
## Command Surface
|
|
24
|
+
|
|
25
|
+
Current top-level commands:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
astrale whoami
|
|
29
|
+
astrale use <name>
|
|
30
|
+
astrale update
|
|
31
|
+
astrale call <path> [params...]
|
|
32
|
+
astrale token
|
|
33
|
+
astrale get <path>
|
|
34
|
+
astrale ls [path]
|
|
35
|
+
astrale describe <path>
|
|
36
|
+
astrale query <cypher>
|
|
37
|
+
astrale logs <service>
|
|
38
|
+
astrale status
|
|
39
|
+
astrale browser
|
|
40
|
+
astrale instance ...
|
|
41
|
+
astrale admin ...
|
|
42
|
+
astrale identity ...
|
|
43
|
+
astrale auth ...
|
|
44
|
+
astrale idp ...
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Command groups:
|
|
48
|
+
|
|
49
|
+
| Group | Commands |
|
|
50
|
+
|---|---|
|
|
51
|
+
| Kernel | `call`, `token`, `get`, `ls`, `describe`, `query`, `logs` |
|
|
52
|
+
| Context | `status`, `whoami`, `use` |
|
|
53
|
+
| Management | `admin`, `instance`, `identity`, `auth`, `idp`, `update` |
|
|
54
|
+
| Agent | `browser` |
|
|
55
|
+
|
|
56
|
+
Shared kernel options are merged onto kernel-touching commands at registration
|
|
57
|
+
time: `--format`, `--json`, `--raw`, `--url`, `-i/--instance`, `--timeout`,
|
|
58
|
+
`--as`, `--creds`, and `--debug`. Check `astrale <cmd> --help` before relying
|
|
59
|
+
on an option for a specific command.
|
|
60
|
+
|
|
61
|
+
## Path Syntax
|
|
62
|
+
|
|
63
|
+
Clients address graph entities and operations with Paths.
|
|
64
|
+
|
|
65
|
+
| Form | Grammar | Use when |
|
|
66
|
+
|---|---|---|
|
|
67
|
+
| Absolute path | `/domain`, `/domain/class.Name`, `/domain/interface.Name` | Domain, Class namespace, or Interface namespace |
|
|
68
|
+
| Static method | `/:domain:class.Name:method` or `/domain/class.Name/method` | Class-level or interface-level operation |
|
|
69
|
+
| Instance method | `<nodePath>::method` or `@id::method` | Operation on a node instance |
|
|
70
|
+
| Id reference | `@nodeId` | Reference a node by UID |
|
|
71
|
+
| Self reference | `@self` | CLI-side shorthand for the active caller node |
|
|
72
|
+
|
|
73
|
+
Load-bearing rules:
|
|
74
|
+
|
|
75
|
+
- Keep the `class.` or `interface.` prefix in namespace segments:
|
|
76
|
+
`/:host.astrale.ai:class.KernelInstance:list`, not
|
|
77
|
+
`/:host.astrale.ai:KernelInstance:list`.
|
|
78
|
+
- Static methods declared on an Interface are reached through the declaring
|
|
79
|
+
interface namespace, not through a concrete Class namespace.
|
|
80
|
+
- Instance dispatch uses double colon `::`; single colon is for domain-path
|
|
81
|
+
static method syntax.
|
|
82
|
+
- Prefer the domain-path form `/:domain:class.Name:method` for static calls
|
|
83
|
+
when possible. It resolves by domain membership rather than tree layout.
|
|
84
|
+
- `@<id>` takes a graph node UUID only — `@<slug>` is NOT_FOUND. And a
|
|
85
|
+
permission error naming a node that "should exist" often means the node
|
|
86
|
+
does NOT exist (missing targets surface as permission denied, not
|
|
87
|
+
NOT_FOUND) — verify with `astrale get <path>` before chasing grants.
|
|
88
|
+
|
|
89
|
+
Examples:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
astrale call /:blog.acme.com:class.Author:list
|
|
93
|
+
astrale call /:blog.acme.com:interface.NoteOps:createNote title=Hello
|
|
94
|
+
astrale call /blog.acme.com/alice::deactivate
|
|
95
|
+
astrale call @f00d...::deactivate
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### @self
|
|
99
|
+
|
|
100
|
+
`@self` is a CLI-side literal expanded before a call is signed and sent. It
|
|
101
|
+
resolves to the active identity's registered node id on the target instance.
|
|
102
|
+
The kernel receives the concrete `@<nodeId>` value.
|
|
103
|
+
|
|
104
|
+
Supported positions:
|
|
105
|
+
|
|
106
|
+
- Path head: `@self`, `@self::method`, `@self/child`
|
|
107
|
+
- Param value head: `key=@self`, `key=@self::method`
|
|
108
|
+
|
|
109
|
+
Not expanded:
|
|
110
|
+
|
|
111
|
+
- `--url`
|
|
112
|
+
- `--data`
|
|
113
|
+
- stdin JSON
|
|
114
|
+
- substrings such as `prefix@self`
|
|
115
|
+
- comma lists such as `@self,@other`
|
|
116
|
+
|
|
117
|
+
For JSON payloads, resolve manually before building the payload.
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
astrale describe @self
|
|
121
|
+
astrale call @self::deactivate
|
|
122
|
+
astrale call /:d:class.X:m owner=@self
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
If `@self` expands to a deleted or stale id, refresh the registration with
|
|
126
|
+
`astrale identity register <name> -i <instance>`.
|
|
127
|
+
|
|
128
|
+
For IdP-backed identities (`astrale auth login`), `@self` just works: on the
|
|
129
|
+
first use against an instance the CLI does ONE kernel `whoami` round-trip,
|
|
130
|
+
caches the node id as a registration, and expands locally afterwards. If that
|
|
131
|
+
lookup fails (offline, expired session), the error carries the manual recipe:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
astrale call "/:kernel.astrale.ai:interface.Identity:whoami" --json # → { id }
|
|
135
|
+
astrale describe @<that-id>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Instances
|
|
139
|
+
|
|
140
|
+
`astrale instance` manages admin-provisioned instances and local bookmarks.
|
|
141
|
+
|
|
142
|
+
Use:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
astrale instance create my-app
|
|
146
|
+
astrale instance status my-app
|
|
147
|
+
astrale instance use my-app
|
|
148
|
+
astrale instance active
|
|
149
|
+
astrale instance bookmark staging --url https://kernel.example.com
|
|
150
|
+
astrale instance forget staging
|
|
151
|
+
astrale instance install https://domain.example.com
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Important distinctions:
|
|
155
|
+
|
|
156
|
+
- `instance use` changes the active target instance.
|
|
157
|
+
- `instance active` shows the active target instance.
|
|
158
|
+
- `instance bookmark` records an existing remote kernel URL locally.
|
|
159
|
+
- `instance forget` removes a local bookmark only.
|
|
160
|
+
- `instance delete` is destructive for admin-managed instances.
|
|
161
|
+
- In scripts, prefer explicit `-i <instance>` over relying on ambient active
|
|
162
|
+
instance state.
|
|
163
|
+
|
|
164
|
+
## Domain Dev Workflow
|
|
165
|
+
|
|
166
|
+
**The `astrale` CLI is connect-only — it does not build, run, or deploy
|
|
167
|
+
domains.** There is no `astrale domain …` command group. Domain development
|
|
168
|
+
lives in two separate tools:
|
|
169
|
+
|
|
170
|
+
- **`create-astrale-domain`** scaffolds a new standalone domain project
|
|
171
|
+
(`pnpm create astrale-domain <slug>`), writing an `astrale.config.ts`.
|
|
172
|
+
- **`astrale-domain`** (the `@astrale-os/devkit` bin, behind the project's
|
|
173
|
+
`pnpm dev` / `pnpm prod` scripts) runs `dev | prod | deploy <env> | build`.
|
|
174
|
+
|
|
175
|
+
Domains are **installed by URL**, never from a file: run or deploy the domain
|
|
176
|
+
worker, then `astrale instance install <url> -i <slug>` — the kernel fetches a
|
|
177
|
+
signed install bundle from the running worker. There is no committed
|
|
178
|
+
`spec.json` and no `astrale domain install`; install lives under the
|
|
179
|
+
`instance` group because it operates on an instance graph.
|
|
180
|
+
|
|
181
|
+
With the **managed (`astrale`) adapter**, `pnpm prod` publishes the bundle
|
|
182
|
+
through the platform AND installs it on the configured instance in one step —
|
|
183
|
+
no manual `instance install`. The service serves at
|
|
184
|
+
`https://<name>-<hash>.svc.<region>.astrale.ai` (the CLI session is the auth).
|
|
185
|
+
|
|
186
|
+
For authoring domains end-to-end (schema, handlers, external APIs, deploys),
|
|
187
|
+
load the **astrale-domain** skill; for graph-level schema surgery on a live
|
|
188
|
+
kernel, **astrale-live-domain-edit**.
|
|
189
|
+
|
|
190
|
+
## Auth And Credentials
|
|
191
|
+
|
|
192
|
+
Keep the auth model simple:
|
|
193
|
+
|
|
194
|
+
- `astrale auth login` authenticates with an IdP and stores an IdP-backed local
|
|
195
|
+
identity/session.
|
|
196
|
+
- `astrale identity create <name>` creates a local key-backed identity.
|
|
197
|
+
- `astrale identity register <name> -i <instance>` registers that identity with
|
|
198
|
+
a target instance.
|
|
199
|
+
- `astrale use <name>` switches the active identity or active instance when the
|
|
200
|
+
name is unambiguous. Use `--identity` or `--instance` when it is ambiguous.
|
|
201
|
+
- `--as <identity>` makes a kernel command call as that identity.
|
|
202
|
+
- `--creds <token>` sends an already minted credential and skips normal signing.
|
|
203
|
+
|
|
204
|
+
Useful checks:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
astrale status
|
|
208
|
+
astrale whoami
|
|
209
|
+
astrale auth status
|
|
210
|
+
astrale identity list
|
|
211
|
+
astrale identity whoami
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
`astrale auth token --raw` prints a cached IdP provider token for shell use.
|
|
215
|
+
That is different from `astrale token`, which mints a delegation token for
|
|
216
|
+
kernel/worker calls.
|
|
217
|
+
|
|
218
|
+
### Session lifetime and refresh
|
|
219
|
+
|
|
220
|
+
IdP sessions refresh themselves: every kernel command silently exchanges the
|
|
221
|
+
refresh token when the cached access token is stale, and concurrent `astrale`
|
|
222
|
+
processes serialize that exchange on a per-identity file lock (refresh tokens
|
|
223
|
+
are single-use — the lock is what makes parallel agent-driven commands safe).
|
|
224
|
+
One `astrale auth login` should therefore last until the IdP itself ends the
|
|
225
|
+
session. Access tokens are also cached **per audience**, so alternating
|
|
226
|
+
commands between instances does not burn a refresh per flip.
|
|
227
|
+
|
|
228
|
+
Refresh failures come in two distinct flavors — read the error before
|
|
229
|
+
re-authenticating:
|
|
230
|
+
|
|
231
|
+
- "could not be refreshed … run: astrale auth login" — the grant is dead
|
|
232
|
+
(IdP session ended, idle/absolute timeout, logout elsewhere). Re-login is
|
|
233
|
+
the only fix.
|
|
234
|
+
- "Could not reach the IdP … retry the command" — transient network/IdP
|
|
235
|
+
outage. The cached session is still valid; do NOT re-login, just retry.
|
|
236
|
+
|
|
237
|
+
### Agent auth
|
|
238
|
+
|
|
239
|
+
An agent driving the CLI needs no special flow: it shares `~/.astrale`, so one
|
|
240
|
+
human `astrale auth login` is enough and every subsequent command (including
|
|
241
|
+
parallel ones) self-refreshes. For fully headless setups with no human login,
|
|
242
|
+
use a key-backed identity — `astrale identity create <name>` then
|
|
243
|
+
`astrale identity register <name> -i <instance>` — which signs locally and
|
|
244
|
+
never expires; or hand the agent a TTL-bound delegation token minted with
|
|
245
|
+
`astrale token` and passed via `--creds`.
|
|
246
|
+
|
|
247
|
+
## Delegation Tokens
|
|
248
|
+
|
|
249
|
+
`astrale token` mints a delegation token for the active instance and identity.
|
|
250
|
+
Use it when another process, script, or worker needs to call with delegated
|
|
251
|
+
authority.
|
|
252
|
+
|
|
253
|
+
Common flow:
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
export TOKEN=$(astrale token --audience dist.astrale.ai --raw)
|
|
257
|
+
astrale call /:dist.astrale.ai:class.Domain:install \
|
|
258
|
+
--url https://dist.astrale.ai \
|
|
259
|
+
--creds "$TOKEN" \
|
|
260
|
+
-d '{"name":"alice"}'
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Notes:
|
|
264
|
+
|
|
265
|
+
- Default TTL is 3600 seconds.
|
|
266
|
+
- `--audience <aud>` should match the receiving service or worker expectation.
|
|
267
|
+
- `--for <identity>` is an alias for `--as <identity>`.
|
|
268
|
+
- Use `--raw` when assigning the token to an environment variable.
|
|
269
|
+
- Use `--json` when a machine should parse token metadata.
|
|
270
|
+
|
|
271
|
+
## Graph Exploration
|
|
272
|
+
|
|
273
|
+
Use these commands for graph inspection:
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
astrale ls /
|
|
277
|
+
astrale get /some/path
|
|
278
|
+
astrale describe /some/path
|
|
279
|
+
astrale query 'MATCH (n) RETURN n LIMIT 5'
|
|
280
|
+
astrale call <path> --describe
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Gotchas:
|
|
284
|
+
|
|
285
|
+
- `query` is read-only; the kernel rejects write keywords such as `CREATE`,
|
|
286
|
+
`DELETE`, `SET`, `MERGE`, `REMOVE`, and `DETACH`.
|
|
287
|
+
- `describe` can return large properties such as serialized schemas. Pipe to
|
|
288
|
+
`jq` or use command-specific flags when available.
|
|
289
|
+
- `ls` has list-specific output controls such as `-q/--quiet`, `--count`, and
|
|
290
|
+
`-l/--long`; check `astrale ls --help`.
|
|
291
|
+
- For operation schemas, prefer `astrale call <path> --describe` before
|
|
292
|
+
executing a call you are unsure about.
|
|
293
|
+
- **`class.<Name>` materializes as a `Folder` node** (kind `Folder`, name
|
|
294
|
+
prefixed `class.`) whose children are the class's callable Functions. There
|
|
295
|
+
is no `Class` node at that tree position — the Class definition lives inside
|
|
296
|
+
the Domain's serialized `schema` prop. So `--filter Class` returns zero; use
|
|
297
|
+
`--filter Folder`, or descend into `class.<X>` and filter on `Function`.
|
|
298
|
+
|
|
299
|
+
## Output / TTY Behavior
|
|
300
|
+
|
|
301
|
+
Output is selected from stdout shape and flags:
|
|
302
|
+
|
|
303
|
+
- TTY default: human-readable output, usually YAML for objects and tables for
|
|
304
|
+
lists.
|
|
305
|
+
- Pipe, redirect, `--json`, or `--raw`: machine-oriented output.
|
|
306
|
+
- `--json`: always valid JSON for tools like `jq`.
|
|
307
|
+
- `--raw`: unwrap scalars for shell assignment and write raw bytes for binary
|
|
308
|
+
responses.
|
|
309
|
+
- `--format yaml|json`: explicit structured output where supported.
|
|
310
|
+
- `call --output <file>` writes binary/raw output to a file.
|
|
311
|
+
- Piped stdin is read by `astrale call`; stdin on a TTY is ignored.
|
|
312
|
+
- `--data` takes precedence over stdin and `key=value` params.
|
|
313
|
+
- `key=value` values are auto-coerced: `true`/`false`/`null`, numeric strings
|
|
314
|
+
→ numbers, `{…}`/`[…]` → parsed JSON; everything else stays a string. To
|
|
315
|
+
force a digits-only STRING (or pass nested values), use `--data`.
|
|
316
|
+
- **Big payloads go through stdin** — argv caps around 128 KB, so multi-MB
|
|
317
|
+
JSON (e.g. a base64 bundle) must be piped:
|
|
318
|
+
`echo "$PAYLOAD_JSON" | astrale call <path> --json`.
|
|
319
|
+
|
|
320
|
+
Examples:
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
astrale ls / --json | jq .
|
|
324
|
+
TOKEN=$(astrale token --audience dist.astrale.ai --raw)
|
|
325
|
+
astrale call /:d:class.Asset:render id=123 --output asset.png
|
|
326
|
+
astrale call /:d:class.X:m -d '{"name":"alice"}'
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
## Driving The GUI
|
|
330
|
+
|
|
331
|
+
Use `astrale browser` to prepare an authenticated GUI browser session that an
|
|
332
|
+
agent can drive with `agent-browser`.
|
|
333
|
+
|
|
334
|
+
Install once:
|
|
335
|
+
|
|
336
|
+
```bash
|
|
337
|
+
npm install -g agent-browser && agent-browser install
|
|
338
|
+
npx skills add vercel-labs/agent-browser
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
Connect and verify:
|
|
342
|
+
|
|
343
|
+
```bash
|
|
344
|
+
astrale browser
|
|
345
|
+
astrale browser --check
|
|
346
|
+
astrale browser --login
|
|
347
|
+
astrale browser --cdp 9222
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
After `astrale browser` connects, it prints the exact `agent-browser --profile`
|
|
351
|
+
command to use. Driving the page is agent-browser's job:
|
|
352
|
+
|
|
353
|
+
```bash
|
|
354
|
+
agent-browser --profile <dir> snapshot
|
|
355
|
+
agent-browser --profile <dir> open <url>
|
|
356
|
+
agent-browser --profile <dir> click @e3
|
|
357
|
+
agent-browser --profile <dir> eval '<js>'
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
The GUI session uses an httpOnly cookie. There is no token-injection shortcut;
|
|
361
|
+
the persistent browser profile is the session boundary.
|
|
362
|
+
|
|
363
|
+
## Debugging And Common Errors
|
|
364
|
+
|
|
365
|
+
Start with local context:
|
|
366
|
+
|
|
367
|
+
```bash
|
|
368
|
+
astrale status
|
|
369
|
+
astrale admin status
|
|
370
|
+
astrale instance active
|
|
371
|
+
astrale auth status
|
|
372
|
+
astrale whoami
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
Use diagnostics:
|
|
376
|
+
|
|
377
|
+
- Add `--debug` to kernel commands for full error diagnostics — including
|
|
378
|
+
the server-side cause chain (`data.cause`), which shows the ROOT failure
|
|
379
|
+
inside wrapped errors (e.g. what actually failed under a
|
|
380
|
+
`Delegation mint failed` or `KERNEL_ERROR`).
|
|
381
|
+
- Use global `--log-level debug` for verbose CLI logging.
|
|
382
|
+
- Use global `--log-format json` when an agent or script should parse logs.
|
|
383
|
+
- Use `--json` or `--raw` for structured command output.
|
|
384
|
+
- Use `--ci` and `--no-prompt` in non-interactive automation.
|
|
385
|
+
- Use `--timeout <ms>` when a kernel call is valid but slow.
|
|
386
|
+
- Use `astrale logs <service-slug> [--tail N]` to tail a MANAGED SERVICE's
|
|
387
|
+
runtime logs — console output, 5xx accesses, and uncaught exception stacks
|
|
388
|
+
(the readable side of `internal error; reference = …` responses). The slug
|
|
389
|
+
is the first label of the service's `…svc.<region>.astrale.ai` URL (also
|
|
390
|
+
accepts the full URL). In-memory, last ~500 lines, resets on runtime
|
|
391
|
+
restart; services deployed before log capture need one redeploy.
|
|
392
|
+
|
|
393
|
+
Common error classes and first checks:
|
|
394
|
+
|
|
395
|
+
| Error shape | First check |
|
|
396
|
+
|---|---|
|
|
397
|
+
| Connection error | `astrale status`; verify the instance URL and network path |
|
|
398
|
+
| Authentication error | `astrale auth status`, `astrale whoami`, active identity |
|
|
399
|
+
| Permission denied | Does the named node actually exist (`astrale get`)? Then active identity and target operation permissions |
|
|
400
|
+
| Not found | Path spelling, active instance, installed domain |
|
|
401
|
+
| Validation error | `astrale call <path> --describe` |
|
|
402
|
+
| Timeout | Target availability and `--timeout <ms>` |
|
|
403
|
+
|
|
404
|
+
If a command fails only in a script, compare TTY vs non-TTY behavior and pass
|
|
405
|
+
explicit `--json`, `--raw`, `-i <instance>`, and `--as <identity>` as needed.
|
|
406
|
+
|
|
407
|
+
## Storage
|
|
408
|
+
|
|
409
|
+
CLI state lives under `ASTRALE_HOME` when set, otherwise `~/.astrale`.
|
|
410
|
+
|
|
411
|
+
Core paths:
|
|
412
|
+
|
|
413
|
+
```text
|
|
414
|
+
~/.astrale/
|
|
415
|
+
config.json CLI and admin config
|
|
416
|
+
install.json Script-install metadata for `astrale update`
|
|
417
|
+
instances.json Active instance and local instance records
|
|
418
|
+
identities.json Active identity and identity metadata
|
|
419
|
+
idps/ IdP provider metadata
|
|
420
|
+
idp-sessions/ Cached IdP sessions
|
|
421
|
+
keys/ Local identity keypairs
|
|
422
|
+
data/ Local data directory used by local adapters
|
|
423
|
+
browser.json Last connected GUI browser session
|
|
424
|
+
browser/<host>/ Persistent browser profile for GUI auth
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
Optional overrides:
|
|
428
|
+
|
|
429
|
+
- `ASTRALE_HOME`: root for CLI state.
|
|
430
|
+
- `ASTRALE_KEYS_DIR`: keypair directory.
|
|
431
|
+
- `ASTRALE_DATA_DIR`: data directory.
|
|
432
|
+
|
|
433
|
+
Keep storage references centralized in this section. Other sections should
|
|
434
|
+
describe behavior, not repeat file locations.
|
|
435
|
+
|
|
436
|
+
## Source Map
|
|
437
|
+
|
|
438
|
+
- Entry: `cli/bin/astrale.ts`
|
|
439
|
+
- Program and help wiring: `cli/src/program.ts`
|
|
440
|
+
- Command registration helpers: `cli/src/registry.ts`, `cli/src/command.ts`
|
|
441
|
+
- Commands: `cli/src/commands/`
|
|
442
|
+
- Shared output, auth, browser, paths, and local helpers: `cli/src/lib/`
|
|
443
|
+
- Kernel command plumbing and error formatting: `cli/src/kernel/`
|
|
444
|
+
- Tests for help and command behavior: `cli/src/commands/__tests__/`
|
|
@@ -22,7 +22,12 @@ an RPC layer; you declare a contract and implement handlers.
|
|
|
22
22
|
npx -y create-astrale-domain@latest my-domain --yes # scaffold
|
|
23
23
|
cd my-domain && pnpm install
|
|
24
24
|
pnpm dev # local wrangler dev (prints a URL; install it on an instance to test)
|
|
25
|
-
|
|
25
|
+
# port 8787 taken? dev AUTO-PICKS a free one and prints it —
|
|
26
|
+
# always trust the printed URL, and `curl <url>/meta` must name
|
|
27
|
+
# YOUR domain (an orphan wrangler answers on stolen ports).
|
|
28
|
+
pnpm dev --port 8899 # pin a port explicitly (disables auto-pick)
|
|
29
|
+
pnpm dev --host https://my-box.preview.dev # dev behind a tunnel/sandbox preview:
|
|
30
|
+
# binds 0.0.0.0 + pins WORKER_URL so iss doesn't drift
|
|
26
31
|
pnpm prod # deploy + (astrale adapter) auto-install on your instance
|
|
27
32
|
```
|
|
28
33
|
|
|
@@ -222,6 +227,21 @@ VERIFY THE UPSTREAM SIGNATURE FIRST, then act as yourself. Needs
|
|
|
222
227
|
granted exactly what it writes (e.g. EDIT on the target folder + USE on
|
|
223
228
|
createNode + USE on the class — narrow, never root).
|
|
224
229
|
|
|
230
|
+
**A PUBLIC view that reads the graph** (e.g. a server-rendered list page):
|
|
231
|
+
the render ctx exposes `ctx.selfKernel()` (sdk ≥0.1.5) — a session as THE
|
|
232
|
+
VIEW'S OWN identity. Read with it directly in `render`, template to HTML:
|
|
233
|
+
`const k = await ctx.selfKernel(); const rows = await k.call('/messages::listChildren', {})`.
|
|
234
|
+
Grant the view's function identity the READ-side minimum in your seed:
|
|
235
|
+
READ on the folder (+ USE on the methods it calls, e.g. listChildren).
|
|
236
|
+
Needs `deps.INSTANCE_KERNEL_URL` (managed deploys set it). Public-input
|
|
237
|
+
hygiene: HTML-escape every stored string at render. (Prefer `selfKernel`
|
|
238
|
+
over the `SELF` service binding for graph reads — `SELF` exists on both
|
|
239
|
+
cloudflare and current managed runtimes, but it costs an extra HTTP hop and
|
|
240
|
+
older hosts omit it.)
|
|
241
|
+
|
|
242
|
+
**Calling a remote function over raw HTTP**: the response wraps your return
|
|
243
|
+
value in an envelope — `{ result: <your value> }` (errors: `{ error }`).
|
|
244
|
+
|
|
225
245
|
**Webhook idempotency** (senders retry — design for replays): derive a
|
|
226
246
|
DETERMINISTIC node path from the sender's id (`/contacts/lead-<externalId>`),
|
|
227
247
|
and make that key BOTH the existence check AND the write target. The classic
|
|
@@ -297,6 +317,7 @@ directly — useful for recovery and inspection:
|
|
|
297
317
|
|
|
298
318
|
| Symptom | Likely cause |
|
|
299
319
|
|---|---|
|
|
320
|
+
| any managed-service 500 — `{"error":{"code":5000,"message":"internal error; reference = …"}}` | `astrale logs <service-slug>` tails the service's runtime buffer (console output, 5xx accesses, uncaught exception stacks) — the slug is the first label of the `…svc.<region>.astrale.ai` URL `pnpm prod` printed. Services deployed before log capture need one redeploy first. |
|
|
300
321
|
| `Permission denied: EDIT on /x (param-target)` | `/x` doesn't exist — seed the parent |
|
|
301
322
|
| `method "x" not found … call it as "/:o:class.C/x"` | instance form used for a static method |
|
|
302
323
|
| `Delegation mint failed for <url>` | check `--debug` cause chain; worker→worker call machinery |
|
|
@@ -311,8 +332,9 @@ directly — useful for recovery and inspection:
|
|
|
311
332
|
| deploy: `Export named 'X' not found` from an @astrale-os module | a transitive dep resolved below its REAL floor — `pnpm add @astrale-os/<pkg>@<needed>` then `pnpm dedupe` |
|
|
312
333
|
|
|
313
334
|
Use `astrale call <path> --describe` for any callable's schema, `--debug` for
|
|
314
|
-
the full error chain,
|
|
315
|
-
(domainName, schemaHash)
|
|
335
|
+
the full error chain, `curl <worker>/meta` for what a worker serves
|
|
336
|
+
(domainName, schemaHash), and `astrale logs <service-slug> [--tail N]` for a
|
|
337
|
+
managed service's runtime logs.
|
|
316
338
|
|
|
317
339
|
## Related skills
|
|
318
340
|
- **astrale-cli** — every CLI command (auth, instances, calls, install).
|
package/template/env.ts
CHANGED
|
@@ -10,7 +10,11 @@ export interface Env {
|
|
|
10
10
|
WORKER_URL?: string
|
|
11
11
|
/** Workers Assets binding (serves the client SPA under /ui/*), when present. */
|
|
12
12
|
ASSETS?: { fetch(request: Request): Promise<Response> }
|
|
13
|
-
/** Self service binding (autobinding — a handler calling its own domain).
|
|
13
|
+
/** Self service binding (autobinding — a handler calling its own domain).
|
|
14
|
+
* Present on Cloudflare deploys AND on current managed runtimes (the host
|
|
15
|
+
* binds every service to itself). Optional — hosts predating log/SELF
|
|
16
|
+
* support omit it; for graph reads from views/functions prefer
|
|
17
|
+
* `ctx.selfKernel()`. */
|
|
14
18
|
SELF?: { fetch(request: Request): Promise<Response> }
|
|
15
19
|
/** Dev-only: forward /ui/* to a running Vite dev server. */
|
|
16
20
|
VIEW_DEV_URL?: string
|
package/template/package.json
CHANGED
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
"typecheck": "tsgo --noEmit"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@astrale-os/adapter-cloudflare": ">=0.1.
|
|
18
|
-
"@astrale-os/devkit": ">=0.1.
|
|
17
|
+
"@astrale-os/adapter-cloudflare": ">=0.1.7 <1.0.0",
|
|
18
|
+
"@astrale-os/devkit": ">=0.1.5 <1.0.0",
|
|
19
19
|
"@astrale-os/kernel-core": ">=0.4.3 <1.0.0",
|
|
20
20
|
"@astrale-os/kernel-dsl": ">=0.1.2 <1.0.0",
|
|
21
|
-
"@astrale-os/sdk": ">=0.1.
|
|
21
|
+
"@astrale-os/sdk": ">=0.1.5 <1.0.0",
|
|
22
22
|
"@hono/node-server": "^1.19.0",
|
|
23
23
|
"zod": "^4.3.6"
|
|
24
24
|
},
|