@astrale-os/adapter-cloudflare 0.1.2 → 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.
@@ -0,0 +1,27 @@
1
+ /**
2
+ * `astrale(envs)` — the Astrale-managed deployment adapter.
3
+ *
4
+ * Ships the domain THROUGH the platform instead of to the author's own cloud
5
+ * account: `deploy` builds the same single-module workerd bundle the Cloudflare
6
+ * adapter ships (shared codegen + `wrangler deploy --dry-run`), then publishes
7
+ * it via the admin domain's catalog — `DomainPublished.register` →
8
+ * `::release { bundleBase64 }` (the worker stages the bytes in the platform
9
+ * registry) → `::install { instanceId, source: { kind: 'package' } }`, which
10
+ * deploys it as a host-local Service next to the target instance and installs
11
+ * the domain on it. No Cloudflare account, no wrangler auth — the only
12
+ * credential is the author's Astrale identity, supplied by the `astrale` CLI
13
+ * session this adapter shells out to (the same trust source as
14
+ * `astrale instance install`).
15
+ *
16
+ * `watch` is identical to the Cloudflare adapter's local dev (wrangler dev on
17
+ * localhost) — managed deploys change WHERE the worker runs, not how you
18
+ * iterate locally.
19
+ *
20
+ * Current limits (v1): client/ SPA assets are not shipped (managed packages
21
+ * serve no `/ui` yet) and no runtime secrets reach the service — the bundle
22
+ * must be self-contained (its signing identity is baked in by the codegen).
23
+ */
24
+ import type { DomainAdapter } from '@astrale-os/devkit';
25
+ import type { AstraleParams } from './params';
26
+ export declare function astrale(envs: Record<string, AstraleParams>): DomainAdapter<AstraleParams>;
27
+ //# sourceMappingURL=astrale.d.ts.map
@@ -0,0 +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;AAU7C,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,aAAa,CAAC,aAAa,CAAC,CAiGzF"}
@@ -0,0 +1,167 @@
1
+ /**
2
+ * `astrale(envs)` — the Astrale-managed deployment adapter.
3
+ *
4
+ * Ships the domain THROUGH the platform instead of to the author's own cloud
5
+ * account: `deploy` builds the same single-module workerd bundle the Cloudflare
6
+ * adapter ships (shared codegen + `wrangler deploy --dry-run`), then publishes
7
+ * it via the admin domain's catalog — `DomainPublished.register` →
8
+ * `::release { bundleBase64 }` (the worker stages the bytes in the platform
9
+ * registry) → `::install { instanceId, source: { kind: 'package' } }`, which
10
+ * deploys it as a host-local Service next to the target instance and installs
11
+ * the domain on it. No Cloudflare account, no wrangler auth — the only
12
+ * credential is the author's Astrale identity, supplied by the `astrale` CLI
13
+ * session this adapter shells out to (the same trust source as
14
+ * `astrale instance install`).
15
+ *
16
+ * `watch` is identical to the Cloudflare adapter's local dev (wrangler dev on
17
+ * localhost) — managed deploys change WHERE the worker runs, not how you
18
+ * iterate locally.
19
+ *
20
+ * Current limits (v1): client/ SPA assets are not shipped (managed packages
21
+ * serve no `/ui` yet) and no runtime secrets reach the service — the bundle
22
+ * must be self-contained (its signing identity is baked in by the codegen).
23
+ */
24
+ import { defineAdapter } from '@astrale-os/devkit';
25
+ import { spawn } from 'node:child_process';
26
+ import { existsSync } from 'node:fs';
27
+ import { readFile } from 'node:fs/promises';
28
+ import { join } from 'node:path';
29
+ import { logTo, prepare } from './cloudflare';
30
+ import { runWranglerBundle, runWranglerDev } from './wrangler-cli';
31
+ const DEFAULT_PORT = 8787;
32
+ const DEFAULT_ADMIN_URL = 'https://admin.eu.astrale.ai/api';
33
+ const DEFAULT_REGION = 'eu';
34
+ const ADMIN_ORIGIN = 'admin.astrale.ai';
35
+ export function astrale(envs) {
36
+ return defineAdapter({
37
+ name: 'astrale',
38
+ envs,
39
+ // Local dev is unchanged: wrangler dev on localhost. Managed deploys change
40
+ // WHERE the worker ships, not the inner loop.
41
+ async watch(params, ctx) {
42
+ const { configPath } = await prepare({ ...(params.vars ? { vars: params.vars } : {}), port: params.port ?? DEFAULT_PORT }, ctx, 'dev');
43
+ const handle = await runWranglerDev({
44
+ projectDir: ctx.projectDir,
45
+ configPath,
46
+ port: params.port ?? DEFAULT_PORT,
47
+ remote: false,
48
+ onReload: ctx.onReload,
49
+ onLog: logTo(),
50
+ });
51
+ return { url: handle.url, stop: handle.stop };
52
+ },
53
+ async deploy(params, ctx) {
54
+ const log = logTo();
55
+ if (!params.instance) {
56
+ throw new Error(`astrale adapter: this env has no "instance" — managed deploys need the target ` +
57
+ `instance slug (e.g. prod: { instance: '<your-instance-slug>' }).`);
58
+ }
59
+ if (ctx.clientDir) {
60
+ log(`client/ detected — managed deploys do not ship SPA assets yet; ` +
61
+ `/ui will not serve on the managed service (functions/methods are unaffected).`);
62
+ }
63
+ // 1. Codegen + bundle: the exact worker module a Cloudflare deploy would
64
+ // ship, produced locally with `wrangler deploy --dry-run` (no auth).
65
+ // `clientDir` is stripped: managed packages don't ship SPA assets yet,
66
+ // and leaving it in would put a dangling `assets.directory` (the
67
+ // unbuilt dist-client) into the generated config.
68
+ const { clientDir: _omitted, ...bundleCtx } = ctx;
69
+ const { configPath } = await prepare({}, bundleCtx, 'dev');
70
+ const outDir = join(ctx.projectDir, '.astrale', 'dist-managed');
71
+ const bundlePath = await runWranglerBundle({
72
+ projectDir: ctx.projectDir,
73
+ configPath,
74
+ outDir,
75
+ onLog: log,
76
+ });
77
+ const bundle = await readFile(bundlePath);
78
+ // 2. Publish through the platform, authenticated by the author's astrale
79
+ // CLI session. The release payload rides STDIN — a bundle is megabytes
80
+ // of base64, far past argv limits.
81
+ const name = params.name ?? packageNameFor(ctx.domain.origin);
82
+ const adminUrl = params.adminUrl ?? DEFAULT_ADMIN_URL;
83
+ const version = `0.0.0-managed.${Date.now()}`;
84
+ log(`registering "${name}" (${ctx.domain.origin}) in the platform catalog…`);
85
+ await astraleCall(ctx.projectDir, params, adminUrl, {
86
+ path: `/${ADMIN_ORIGIN}/class.DomainPublished/register`,
87
+ data: { origin: ctx.domain.origin, name },
88
+ });
89
+ log(`publishing ${name}@${version} (${bundle.length} bytes)…`);
90
+ await astraleCall(ctx.projectDir, params, adminUrl, {
91
+ path: `/admin/domains/${name}::release`,
92
+ data: { version, bundleBase64: bundle.toString('base64'), makeCurrent: true },
93
+ viaStdin: true,
94
+ });
95
+ log(`installing on instance "${params.instance}"…`);
96
+ const installed = (await astraleCall(ctx.projectDir, params, adminUrl, {
97
+ path: `/admin/domains/${name}::install`,
98
+ data: { instanceId: params.instance, source: { kind: 'package' } },
99
+ }));
100
+ if (installed.error || installed.state !== 'installed') {
101
+ throw new Error(`managed install failed: state=${installed.state ?? '?'} error=${installed.error ?? '?'}`);
102
+ }
103
+ if (!installed.serviceSlug) {
104
+ throw new Error('managed install returned no serviceSlug — cannot derive the service URL');
105
+ }
106
+ const region = params.region ?? DEFAULT_REGION;
107
+ return { url: `https://${installed.serviceSlug}.svc.${region}.astrale.ai` };
108
+ },
109
+ secretsFile(params) {
110
+ return params.secrets;
111
+ },
112
+ });
113
+ }
114
+ /** Catalog package name from the origin: first DNS label (e.g. `my-notes.example.dev` → `my-notes`). */
115
+ function packageNameFor(origin) {
116
+ const label = origin.split('.')[0] ?? origin;
117
+ return label.toLowerCase().replace(/[^a-z0-9-]+/g, '-');
118
+ }
119
+ /**
120
+ * Invoke the user's `astrale` CLI for one platform call and parse its JSON
121
+ * output. The CLI owns identity (IdP session, audience scoping, delegation
122
+ * minting) — reimplementing that here would fork the trust path.
123
+ */
124
+ async function astraleCall(projectDir, params, adminUrl, call) {
125
+ const args = ['call', call.path, '--url', adminUrl, '--json'];
126
+ if (params.identity)
127
+ args.push('--as', params.identity);
128
+ const payload = JSON.stringify(call.data);
129
+ if (!call.viaStdin)
130
+ args.push('--data', payload);
131
+ const { code, out } = await new Promise((resolve, reject) => {
132
+ const child = spawn(astraleBin(projectDir), args, {
133
+ cwd: projectDir,
134
+ stdio: [call.viaStdin ? 'pipe' : 'ignore', 'pipe', 'pipe'],
135
+ });
136
+ let out = '';
137
+ child.stdout?.on('data', (b) => (out += b.toString()));
138
+ child.stderr?.on('data', (b) => (out += b.toString()));
139
+ child.on('exit', (c) => resolve({ code: c ?? 1, out }));
140
+ child.on('error', reject);
141
+ if (call.viaStdin) {
142
+ child.stdin?.write(payload);
143
+ child.stdin?.end();
144
+ }
145
+ });
146
+ if (code !== 0) {
147
+ throw new Error(`astrale call ${call.path} failed (exit ${code}): ${out.trim().slice(0, 500)}\n` +
148
+ `Is the astrale CLI installed and signed in? (astrale auth login)`);
149
+ }
150
+ try {
151
+ return JSON.parse(out);
152
+ }
153
+ catch {
154
+ throw new Error(`astrale call ${call.path}: could not parse CLI output: ${out.slice(0, 300)}`);
155
+ }
156
+ }
157
+ /** The user's astrale CLI: ~/.astrale/bin/astrale when present, else PATH. */
158
+ function astraleBin(_projectDir) {
159
+ const home = process.env.HOME;
160
+ if (home) {
161
+ const installed = join(home, '.astrale', 'bin', 'astrale');
162
+ if (existsSync(installed))
163
+ return installed;
164
+ }
165
+ return 'astrale';
166
+ }
167
+ //# sourceMappingURL=astrale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"astrale.js","sourceRoot":"","sources":["../src/astrale.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,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,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAElE,M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AC,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"}
@@ -8,8 +8,15 @@
8
8
  * `wrangler secret bulk`. Both `watch` and `deploy` return the URL the devkit
9
9
  * prints and `astrale instance install <url>` consumes.
10
10
  */
11
- import type { DomainAdapter } from '@astrale-os/devkit';
11
+ import type { DeployCtx, DomainAdapter, WatchCtx } from '@astrale-os/devkit';
12
12
  import type { CloudflareParams } from './params';
13
13
  export declare function cloudflare(envs: Record<string, CloudflareParams>): DomainAdapter<CloudflareParams>;
14
+ export declare function prepare(params: CloudflareParams, ctx: WatchCtx | DeployCtx, mode: 'dev' | 'deploy'): Promise<{
15
+ configPath: string;
16
+ fallbackConfigPath?: string;
17
+ port: number;
18
+ workerName: string;
19
+ }>;
14
20
  export declare function workerName(params: CloudflareParams, origin: string): string;
21
+ export declare function logTo(): (line: string) => void;
15
22
  //# sourceMappingURL=cloudflare.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cloudflare.d.ts","sourceRoot":"","sources":["../src/cloudflare.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAa,aAAa,EAAY,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,CAsDjC;AAsHD,wBAAgB,UAAU,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAsB3E"}
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,CAsDjC;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,CA0EhG;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"}
@@ -68,7 +68,7 @@ export function cloudflare(envs) {
68
68
  });
69
69
  }
70
70
  // ── codegen orchestration ──────────────────────────────────────────────────
71
- async function prepare(params, ctx, mode) {
71
+ export async function prepare(params, ctx, mode) {
72
72
  const astraleDir = join(ctx.projectDir, '.astrale');
73
73
  await mkdir(astraleDir, { recursive: true });
74
74
  await ensureIdentity(astraleDir, ctx.domain.origin);
@@ -180,7 +180,7 @@ export function workerName(params, origin) {
180
180
  .slice(0, 54)
181
181
  .replace(/^-+|-+$/g, '');
182
182
  }
183
- function logTo() {
183
+ export function logTo() {
184
184
  return (line) => process.stderr.write(`\x1b[2m ${line}\x1b[0m\n`);
185
185
  }
186
186
  //# sourceMappingURL=cloudflare.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cloudflare.js","sourceRoot":"","sources":["../src/cloudflare.ts"],"names":[],"mappings":"AA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IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACpC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;YAC7E,MAAM,IAAI,KAAK,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/index.d.ts CHANGED
@@ -12,6 +12,7 @@
12
12
  * `dev` runs `wrangler dev` locally; an env with no `route` ships to
13
13
  * `*.workers.dev`; an env with a `route` ships to that custom domain.
14
14
  */
15
+ export { astrale } from './astrale';
15
16
  export { cloudflare } from './cloudflare';
16
- export type { CloudflareParams } from './params';
17
+ export type { AstraleParams, CloudflareParams } from './params';
17
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA"}
package/dist/index.js CHANGED
@@ -12,5 +12,6 @@
12
12
  * `dev` runs `wrangler dev` locally; an env with no `route` ships to
13
13
  * `*.workers.dev`; an env with a `route` ships to that custom domain.
14
14
  */
15
+ export { astrale } from './astrale';
15
16
  export { cloudflare } from './cloudflare';
16
17
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA"}
package/dist/params.d.ts CHANGED
@@ -47,4 +47,27 @@ export interface CloudflareParams {
47
47
  */
48
48
  wrangler?: Record<string, unknown>;
49
49
  }
50
+ /** Params for the Astrale-managed adapter (`astrale(envs)`). */
51
+ export interface AstraleParams {
52
+ /**
53
+ * Target instance slug the domain installs onto (e.g. `'bryan-e2e5'`).
54
+ * Required for `deploy` (managed publish + install); ignored by `watch`
55
+ * (local dev) — so dev-only envs may omit it.
56
+ */
57
+ instance?: string;
58
+ /** Catalog package name. Default: the origin's first DNS label. */
59
+ name?: string;
60
+ /** Admin kernel URL the publish calls target. Default the platform admin. */
61
+ adminUrl?: string;
62
+ /** Routing region of the `.svc` service URL. Default `'eu'`. */
63
+ region?: string;
64
+ /** CLI identity (`--as`) for the publish calls. Default: the CLI's active identity. */
65
+ identity?: string;
66
+ /** Gitignored secrets file — injected ONLY into local `watch` (managed services receive no secrets yet). */
67
+ secrets?: string;
68
+ /** Local dev port for `wrangler dev`. Default 8787. */
69
+ port?: number;
70
+ /** Extra plain vars for local `watch`. */
71
+ vars?: Record<string, string>;
72
+ }
50
73
  //# sourceMappingURL=params.d.ts.map
@@ -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"}
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,CAAA;IACjB,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,uFAAuF;IACvF,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,4GAA4G;IAC5G,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC9B"}
@@ -60,4 +60,15 @@ export declare function bulkPutSecrets(args: {
60
60
  secrets: Record<string, string>;
61
61
  onLog?: (line: string) => void;
62
62
  }): Promise<void>;
63
+ /**
64
+ * Build the single-module worker bundle WITHOUT deploying — `wrangler deploy
65
+ * --dry-run --outdir` (no Cloudflare auth required). Returns the path of the
66
+ * bundled .js module (the managed adapter publishes its bytes).
67
+ */
68
+ export declare function runWranglerBundle(args: {
69
+ projectDir: string;
70
+ configPath: string;
71
+ outDir: string;
72
+ onLog?: (line: string) => void;
73
+ }): Promise<string>;
63
74
  //# sourceMappingURL=wrangler-cli.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wrangler-cli.d.ts","sourceRoot":"","sources":["../src/wrangler-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAkBH,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACtB;AAED,wBAAsB,cAAc,CAAC,IAAI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AAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,EACtE,IAAI,EAAE,UAAU,GACf,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAwBvC;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAO9E;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAC/B,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBhB;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"}
@@ -7,7 +7,7 @@
7
7
  * falling back to `npx wrangler`.
8
8
  */
9
9
  import { spawn } from 'node:child_process';
10
- import { existsSync } from 'node:fs';
10
+ import { existsSync, readdirSync } from 'node:fs';
11
11
  import { mkdtemp, rm, writeFile } from 'node:fs/promises';
12
12
  import { tmpdir } from 'node:os';
13
13
  import { join } from 'node:path';
@@ -182,4 +182,20 @@ async function stopChild(child) {
182
182
  }, 4000).unref?.();
183
183
  });
184
184
  }
185
+ /**
186
+ * Build the single-module worker bundle WITHOUT deploying — `wrangler deploy
187
+ * --dry-run --outdir` (no Cloudflare auth required). Returns the path of the
188
+ * bundled .js module (the managed adapter publishes its bytes).
189
+ */
190
+ export async function runWranglerBundle(args) {
191
+ const { cmd, prefix } = wranglerCommand(args.projectDir);
192
+ const { code, out } = await runCapture(cmd, [...prefix, 'deploy', '--dry-run', '--outdir', args.outDir, '--config', args.configPath], args.projectDir, args.onLog);
193
+ if (code !== 0)
194
+ throw new Error(`wrangler bundle failed (exit ${code}): ${out.slice(-400)}`);
195
+ const js = readdirSync(args.outDir).filter((f) => f.endsWith('.js'));
196
+ if (js.length === 0)
197
+ throw new Error(`wrangler bundle produced no .js in ${args.outDir}`);
198
+ const preferred = js.find((f) => f.startsWith('worker')) ?? js[0];
199
+ return join(args.outDir, preferred);
200
+ }
185
201
  //# sourceMappingURL=wrangler-cli.js.map
@@ -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,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEjE,SAAS,eAAe,CAAC,UAAkB;IACzC,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,UAAU,CAAC,CAAA;IAClE,IAAI,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAA;IACxD,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,CAAA;AACtD,C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A;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.2",
3
+ "version": "0.1.4",
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.2"
31
+ "@astrale-os/devkit": "^0.1.3"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@astrale-os/ox": ">=0.1.0 <1.0.0",
package/src/astrale.ts ADDED
@@ -0,0 +1,200 @@
1
+ /**
2
+ * `astrale(envs)` — the Astrale-managed deployment adapter.
3
+ *
4
+ * Ships the domain THROUGH the platform instead of to the author's own cloud
5
+ * account: `deploy` builds the same single-module workerd bundle the Cloudflare
6
+ * adapter ships (shared codegen + `wrangler deploy --dry-run`), then publishes
7
+ * it via the admin domain's catalog — `DomainPublished.register` →
8
+ * `::release { bundleBase64 }` (the worker stages the bytes in the platform
9
+ * registry) → `::install { instanceId, source: { kind: 'package' } }`, which
10
+ * deploys it as a host-local Service next to the target instance and installs
11
+ * the domain on it. No Cloudflare account, no wrangler auth — the only
12
+ * credential is the author's Astrale identity, supplied by the `astrale` CLI
13
+ * session this adapter shells out to (the same trust source as
14
+ * `astrale instance install`).
15
+ *
16
+ * `watch` is identical to the Cloudflare adapter's local dev (wrangler dev on
17
+ * localhost) — managed deploys change WHERE the worker runs, not how you
18
+ * iterate locally.
19
+ *
20
+ * Current limits (v1): client/ SPA assets are not shipped (managed packages
21
+ * serve no `/ui` yet) and no runtime secrets reach the service — the bundle
22
+ * must be self-contained (its signing identity is baked in by the codegen).
23
+ */
24
+
25
+ import type { DomainAdapter } from '@astrale-os/devkit'
26
+
27
+ import { defineAdapter } from '@astrale-os/devkit'
28
+ import { spawn } from 'node:child_process'
29
+ import { existsSync } from 'node:fs'
30
+ import { readFile } from 'node:fs/promises'
31
+ import { join } from 'node:path'
32
+
33
+ import type { AstraleParams } from './params'
34
+
35
+ import { logTo, prepare } from './cloudflare'
36
+ import { runWranglerBundle, runWranglerDev } from './wrangler-cli'
37
+
38
+ const DEFAULT_PORT = 8787
39
+ const DEFAULT_ADMIN_URL = 'https://admin.eu.astrale.ai/api'
40
+ const DEFAULT_REGION = 'eu'
41
+ const ADMIN_ORIGIN = 'admin.astrale.ai'
42
+
43
+ export function astrale(envs: Record<string, AstraleParams>): DomainAdapter<AstraleParams> {
44
+ return defineAdapter<AstraleParams>({
45
+ name: 'astrale',
46
+ envs,
47
+
48
+ // Local dev is unchanged: wrangler dev on localhost. Managed deploys change
49
+ // WHERE the worker ships, not the inner loop.
50
+ async watch(params, ctx) {
51
+ const { configPath } = await prepare(
52
+ { ...(params.vars ? { vars: params.vars } : {}), port: params.port ?? DEFAULT_PORT },
53
+ ctx,
54
+ 'dev',
55
+ )
56
+ const handle = await runWranglerDev({
57
+ projectDir: ctx.projectDir,
58
+ configPath,
59
+ port: params.port ?? DEFAULT_PORT,
60
+ remote: false,
61
+ onReload: ctx.onReload,
62
+ onLog: logTo(),
63
+ })
64
+ return { url: handle.url, stop: handle.stop }
65
+ },
66
+
67
+ async deploy(params, ctx) {
68
+ const log = logTo()
69
+ if (!params.instance) {
70
+ throw new Error(
71
+ `astrale adapter: this env has no "instance" — managed deploys need the target ` +
72
+ `instance slug (e.g. prod: { instance: '<your-instance-slug>' }).`,
73
+ )
74
+ }
75
+ if (ctx.clientDir) {
76
+ log(
77
+ `client/ detected — managed deploys do not ship SPA assets yet; ` +
78
+ `/ui will not serve on the managed service (functions/methods are unaffected).`,
79
+ )
80
+ }
81
+
82
+ // 1. Codegen + bundle: the exact worker module a Cloudflare deploy would
83
+ // ship, produced locally with `wrangler deploy --dry-run` (no auth).
84
+ // `clientDir` is stripped: managed packages don't ship SPA assets yet,
85
+ // and leaving it in would put a dangling `assets.directory` (the
86
+ // unbuilt dist-client) into the generated config.
87
+ const { clientDir: _omitted, ...bundleCtx } = ctx
88
+ const { configPath } = await prepare({}, bundleCtx, 'dev')
89
+ const outDir = join(ctx.projectDir, '.astrale', 'dist-managed')
90
+ const bundlePath = await runWranglerBundle({
91
+ projectDir: ctx.projectDir,
92
+ configPath,
93
+ outDir,
94
+ onLog: log,
95
+ })
96
+ const bundle = await readFile(bundlePath)
97
+
98
+ // 2. Publish through the platform, authenticated by the author's astrale
99
+ // CLI session. The release payload rides STDIN — a bundle is megabytes
100
+ // of base64, far past argv limits.
101
+ const name = params.name ?? packageNameFor(ctx.domain.origin)
102
+ const adminUrl = params.adminUrl ?? DEFAULT_ADMIN_URL
103
+ const version = `0.0.0-managed.${Date.now()}`
104
+
105
+ log(`registering "${name}" (${ctx.domain.origin}) in the platform catalog…`)
106
+ await astraleCall(ctx.projectDir, params, adminUrl, {
107
+ path: `/${ADMIN_ORIGIN}/class.DomainPublished/register`,
108
+ data: { origin: ctx.domain.origin, name },
109
+ })
110
+
111
+ log(`publishing ${name}@${version} (${bundle.length} bytes)…`)
112
+ await astraleCall(ctx.projectDir, params, adminUrl, {
113
+ path: `/admin/domains/${name}::release`,
114
+ data: { version, bundleBase64: bundle.toString('base64'), makeCurrent: true },
115
+ viaStdin: true,
116
+ })
117
+
118
+ log(`installing on instance "${params.instance}"…`)
119
+ const installed = (await astraleCall(ctx.projectDir, params, adminUrl, {
120
+ path: `/admin/domains/${name}::install`,
121
+ data: { instanceId: params.instance, source: { kind: 'package' } },
122
+ })) as { serviceSlug?: string; state?: string; error?: string | null }
123
+
124
+ if (installed.error || installed.state !== 'installed') {
125
+ throw new Error(
126
+ `managed install failed: state=${installed.state ?? '?'} error=${installed.error ?? '?'}`,
127
+ )
128
+ }
129
+ if (!installed.serviceSlug) {
130
+ throw new Error('managed install returned no serviceSlug — cannot derive the service URL')
131
+ }
132
+ const region = params.region ?? DEFAULT_REGION
133
+ return { url: `https://${installed.serviceSlug}.svc.${region}.astrale.ai` }
134
+ },
135
+
136
+ secretsFile(params) {
137
+ return params.secrets
138
+ },
139
+ })
140
+ }
141
+
142
+ /** Catalog package name from the origin: first DNS label (e.g. `my-notes.example.dev` → `my-notes`). */
143
+ function packageNameFor(origin: string): string {
144
+ const label = origin.split('.')[0] ?? origin
145
+ return label.toLowerCase().replace(/[^a-z0-9-]+/g, '-')
146
+ }
147
+
148
+ /**
149
+ * Invoke the user's `astrale` CLI for one platform call and parse its JSON
150
+ * output. The CLI owns identity (IdP session, audience scoping, delegation
151
+ * minting) — reimplementing that here would fork the trust path.
152
+ */
153
+ async function astraleCall(
154
+ projectDir: string,
155
+ params: AstraleParams,
156
+ adminUrl: string,
157
+ call: { path: string; data: unknown; viaStdin?: boolean },
158
+ ): Promise<unknown> {
159
+ const args = ['call', call.path, '--url', adminUrl, '--json']
160
+ if (params.identity) args.push('--as', params.identity)
161
+ const payload = JSON.stringify(call.data)
162
+ if (!call.viaStdin) args.push('--data', payload)
163
+
164
+ const { code, out } = await new Promise<{ code: number; out: string }>((resolve, reject) => {
165
+ const child = spawn(astraleBin(projectDir), args, {
166
+ cwd: projectDir,
167
+ stdio: [call.viaStdin ? 'pipe' : 'ignore', 'pipe', 'pipe'],
168
+ })
169
+ let out = ''
170
+ child.stdout?.on('data', (b: Buffer) => (out += b.toString()))
171
+ child.stderr?.on('data', (b: Buffer) => (out += b.toString()))
172
+ child.on('exit', (c) => resolve({ code: c ?? 1, out }))
173
+ child.on('error', reject)
174
+ if (call.viaStdin) {
175
+ child.stdin?.write(payload)
176
+ child.stdin?.end()
177
+ }
178
+ })
179
+ if (code !== 0) {
180
+ throw new Error(
181
+ `astrale call ${call.path} failed (exit ${code}): ${out.trim().slice(0, 500)}\n` +
182
+ `Is the astrale CLI installed and signed in? (astrale auth login)`,
183
+ )
184
+ }
185
+ try {
186
+ return JSON.parse(out)
187
+ } catch {
188
+ throw new Error(`astrale call ${call.path}: could not parse CLI output: ${out.slice(0, 300)}`)
189
+ }
190
+ }
191
+
192
+ /** The user's astrale CLI: ~/.astrale/bin/astrale when present, else PATH. */
193
+ function astraleBin(_projectDir: string): string {
194
+ const home = process.env.HOME
195
+ if (home) {
196
+ const installed = join(home, '.astrale', 'bin', 'astrale')
197
+ if (existsSync(installed)) return installed
198
+ }
199
+ return 'astrale'
200
+ }
package/src/cloudflare.ts CHANGED
@@ -85,7 +85,7 @@ export function cloudflare(
85
85
 
86
86
  // ── codegen orchestration ──────────────────────────────────────────────────
87
87
 
88
- async function prepare(
88
+ export async function prepare(
89
89
  params: CloudflareParams,
90
90
  ctx: WatchCtx | DeployCtx,
91
91
  mode: 'dev' | 'deploy',
@@ -223,6 +223,6 @@ export function workerName(params: CloudflareParams, origin: string): string {
223
223
  .replace(/^-+|-+$/g, '')
224
224
  }
225
225
 
226
- function logTo(): (line: string) => void {
226
+ export function logTo(): (line: string) => void {
227
227
  return (line: string) => process.stderr.write(`\x1b[2m ${line}\x1b[0m\n`)
228
228
  }
package/src/index.ts CHANGED
@@ -13,5 +13,6 @@
13
13
  * `*.workers.dev`; an env with a `route` ships to that custom domain.
14
14
  */
15
15
 
16
+ export { astrale } from './astrale'
16
17
  export { cloudflare } from './cloudflare'
17
- export type { CloudflareParams } from './params'
18
+ export type { AstraleParams, CloudflareParams } from './params'
package/src/params.ts CHANGED
@@ -47,3 +47,27 @@ export interface CloudflareParams {
47
47
  */
48
48
  wrangler?: Record<string, unknown>
49
49
  }
50
+
51
+ /** Params for the Astrale-managed adapter (`astrale(envs)`). */
52
+ export interface AstraleParams {
53
+ /**
54
+ * Target instance slug the domain installs onto (e.g. `'bryan-e2e5'`).
55
+ * Required for `deploy` (managed publish + install); ignored by `watch`
56
+ * (local dev) — so dev-only envs may omit it.
57
+ */
58
+ instance?: string
59
+ /** Catalog package name. Default: the origin's first DNS label. */
60
+ name?: string
61
+ /** Admin kernel URL the publish calls target. Default the platform admin. */
62
+ adminUrl?: string
63
+ /** Routing region of the `.svc` service URL. Default `'eu'`. */
64
+ region?: string
65
+ /** CLI identity (`--as`) for the publish calls. Default: the CLI's active identity. */
66
+ identity?: string
67
+ /** Gitignored secrets file — injected ONLY into local `watch` (managed services receive no secrets yet). */
68
+ secrets?: string
69
+ /** Local dev port for `wrangler dev`. Default 8787. */
70
+ port?: number
71
+ /** Extra plain vars for local `watch`. */
72
+ vars?: Record<string, string>
73
+ }
@@ -10,7 +10,7 @@
10
10
  import type { ChildProcess } from 'node:child_process'
11
11
 
12
12
  import { spawn } from 'node:child_process'
13
- import { existsSync } from 'node:fs'
13
+ import { existsSync, readdirSync } from 'node:fs'
14
14
  import { mkdtemp, rm, writeFile } from 'node:fs/promises'
15
15
  import { tmpdir } from 'node:os'
16
16
  import { join } from 'node:path'
@@ -238,3 +238,28 @@ async function stopChild(child: ChildProcess): Promise<void> {
238
238
  }, 4000).unref?.()
239
239
  })
240
240
  }
241
+
242
+ /**
243
+ * Build the single-module worker bundle WITHOUT deploying — `wrangler deploy
244
+ * --dry-run --outdir` (no Cloudflare auth required). Returns the path of the
245
+ * bundled .js module (the managed adapter publishes its bytes).
246
+ */
247
+ export async function runWranglerBundle(args: {
248
+ projectDir: string
249
+ configPath: string
250
+ outDir: string
251
+ onLog?: (line: string) => void
252
+ }): Promise<string> {
253
+ const { cmd, prefix } = wranglerCommand(args.projectDir)
254
+ const { code, out } = await runCapture(
255
+ cmd,
256
+ [...prefix, 'deploy', '--dry-run', '--outdir', args.outDir, '--config', args.configPath],
257
+ args.projectDir,
258
+ args.onLog,
259
+ )
260
+ if (code !== 0) throw new Error(`wrangler bundle failed (exit ${code}): ${out.slice(-400)}`)
261
+ const js = readdirSync(args.outDir).filter((f) => f.endsWith('.js'))
262
+ if (js.length === 0) throw new Error(`wrangler bundle produced no .js in ${args.outDir}`)
263
+ const preferred = js.find((f) => f.startsWith('worker')) ?? js[0]!
264
+ return join(args.outDir, preferred)
265
+ }
@@ -0,0 +1,303 @@
1
+ ---
2
+ name: Astrale Domain
3
+ description: Develop, deploy, and iterate an Astrale domain end-to-end — schema modeling (classes, interfaces, edges, methods), handler implementation, calling the kernel and other domains from handlers, integrating external APIs (the core use case — DI, secrets, idempotency, sagas), views, testing, and the deploy/install loop with the cloudflare or astrale adapter. Use whenever creating a domain, adding classes/methods/views, structuring external API calls, or debugging install/dispatch/permission errors. Pairs with the astrale-cli skill (CLI ops) — together they cover working an Astrale instance autonomously.
4
+ ---
5
+
6
+ # Astrale Domain — the authoring bible
7
+
8
+ An Astrale **domain** is a typed contract installed into a kernel's graph plus a
9
+ **worker you own** that executes it. The kernel stores the schema (classes,
10
+ edges, function contracts), enforces permissions, and routes calls; every
11
+ method body runs on YOUR worker (Cloudflare worker or Astrale-managed service).
12
+ The graph is the database AND the bus: domains read/write nodes+edges through
13
+ the kernel and call each other's functions through it.
14
+
15
+ **Mental model:** schema = what exists and what's callable · graph = state ·
16
+ worker = behavior · kernel = router + authorizer. You never run a database or
17
+ an RPC layer; you declare a contract and implement handlers.
18
+
19
+ ## 0 · Start
20
+
21
+ ```bash
22
+ npx -y create-astrale-domain@latest my-domain --yes # scaffold
23
+ cd my-domain && pnpm install
24
+ pnpm dev # local wrangler dev (prints a URL; install it on an instance to test)
25
+ pnpm prod # deploy + (astrale adapter) auto-install on your instance
26
+ ```
27
+
28
+ Project anatomy (the scaffold is the reference — read its comments):
29
+
30
+ ```
31
+ astrale.config.ts # THE manifest: schema + postInstall + adapter (where it ships)
32
+ schema/ # classes/interfaces/edges — the contract (zod props, fn signatures)
33
+ methods/ # handler logic (transport-agnostic fns) + thin wiring (index.ts)
34
+ services/ # RECOMMENDED: ports + factories for external APIs (see §4)
35
+ functions/ # standalone remote functions (webhook-shaped endpoints)
36
+ views/ # iframe-mountable UI declarations (defineView)
37
+ client/ # the SPA served under /ui (vite)
38
+ env.ts # typed worker env — config + secrets arrive here, as ctx.deps
39
+ ```
40
+
41
+ Iteration loop: edit → `pnpm prod` → call it. Managed redeploys keep the same
42
+ service URL and reinstall the contract; schema changes are merge/reconcile
43
+ (removed entries can leave old nodes behind — see the astrale-live-domain-edit
44
+ skill for graph-level cleanup).
45
+
46
+ ## 1 · Schema modeling
47
+
48
+ ```ts
49
+ import { KernelSchema, defineSchema, edgeClass, nodeClass, nodeInterface } from '@astrale-os/kernel-core'
50
+ import { fn } from '@astrale-os/kernel-dsl'
51
+ import { z } from 'zod'
52
+
53
+ export const ContactOps = nodeInterface({ // interface = shared contract
54
+ methods: { createContact: fn({ static: true, params: {...}, returns: ... }) },
55
+ })
56
+ export const Contact = nodeClass({
57
+ implements: [ContactOps, KernelSchema.interfaces.Container], // Container → can hold children
58
+ props: { email: z.string(), company: z.string().optional() },
59
+ methods: { assign: fn({ params: { project: z.string(), role: z.string() }, returns: ... }) },
60
+ })
61
+ export const works_on = edgeClass( // edges are CLASSES with PROPS
62
+ { as: 'contact', types: [Contact] },
63
+ { as: 'project', types: [Project] },
64
+ { props: { role: z.string() } },
65
+ )
66
+ export const schema = defineSchema('my-domain.example.dev', {
67
+ interfaces: { ContactOps },
68
+ classes: { Contact, Project, works_on }, // EDGE classes register under `classes` too
69
+ imports: [KernelSchema],
70
+ })
71
+ ```
72
+
73
+ Conventions and rules:
74
+ - Naming: classes/interfaces `PascalCase`, methods `camelCase`, **edges `snake_case`**.
75
+ - `static: true` = called on the class (`/origin/class.X/method`); otherwise
76
+ instance-dispatched (`/path/to/node::method`, handler gets `self`). Statics
77
+ work on classes AND interfaces, wired through the same `method()` /
78
+ `classMethods()` helpers (the scaffold's `seed` is a class-hosted static).
79
+ - Model relations as **edges with props** (not foreign-key strings): create via
80
+ `::link {edgeClass, target, props}`, walk via `::getLinks`. Prefer FLAT nodes
81
+ + edges for peer resources; use Folders (Container) only for list-able
82
+ hierarchies (`::listChildren` works on Folders).
83
+ - Props are zod; they land in the graph under QUALIFIED keys
84
+ (`origin:class.X.property.y`). Never hand-write key strings — derive them
85
+ from the compiled schema: `D.Contact.email.key`, `K.Named.name.key`.
86
+ - Known sharp edges: `::update` currently drops `z.enum()` props silently
87
+ (create is fine — track status as plain string if you must update it); edge
88
+ prop accessors exist at runtime but not in types yet (cast).
89
+
90
+ ## 2 · Handlers
91
+
92
+ Separate LOGIC from WIRING. Logic = plain async functions taking the kernel
93
+ client + ports + params (testable with fakes). Wiring = `method()` /
94
+ `classMethods()` / `interfaceMethods()` in `methods/index.ts`:
95
+
96
+ ```ts
97
+ const kickoff = method(schema, 'Project', 'kickoff', {
98
+ authorize: async () => undefined, // see §6 for real authorization
99
+ execute: ({ kernel, self, params, deps }) => {
100
+ if (!kernel) throw new Error('kickoff requires a kernel credential')
101
+ return kickoffLogic(kernel, createWeatherClient(deps), self.path.raw, params)
102
+ },
103
+ })
104
+ ```
105
+
106
+ Handler context: `kernel` (callback client bound to the composed credential —
107
+ caller's delegated authority ∪ this function's own), `self` (instance methods),
108
+ `params` (zod-validated), `deps` (your typed `Env`), `auth` (principal,
109
+ verified claims). Construct external clients from `deps` per request — NEVER
110
+ at module load (workers must be import-side-effect-free).
111
+
112
+ ## 3 · Talking to the kernel (and other domains)
113
+
114
+ Everything is `kernel.call(path, params)`. Addressing forms:
115
+
116
+ | Form | Example | Use |
117
+ |---|---|---|
118
+ | tree path + `::method` | `/projects/apollo::get` | instance dispatch on a node |
119
+ | static slash form | `/origin/class.X/method` | static class/interface methods |
120
+ | colon MethodPath | `/:origin:class.X:method` | canonical form; REQUIRED in postInstall |
121
+ | `@<uuid>::method` | `@4548…::get` | by graph id (NOT slugs/paths) |
122
+
123
+ Core ops from handlers (all proven patterns):
124
+
125
+ ```ts
126
+ await kernel.call(K.Node.createNode.path.method.raw, { class: D.Contact.path.class.raw, path, props })
127
+ await kernel.call(`${path}::update`, { props: { [D.Project.title.key]: 'New' } })
128
+ // Edge props use QUALIFIED keys; the edge-prop TYPE accessor is missing today — use this cast:
129
+ const ROLE_KEY = (D.works_on as unknown as { role: { key: string } }).role.key
130
+ await kernel.call(`${path}::link`, { edgeClass: D.works_on.path.class.raw, target, props: { [ROLE_KEY]: role } })
131
+ const links = await kernel.call(`${path}::getLinks`, {}) // filter by edge class
132
+ await kernel.call('/other.domain/class.Echo/echo', { message }) // ANOTHER domain's function
133
+ ```
134
+
135
+ - **Cross-function calls work** (same- or cross-domain): the kernel redirects
136
+ to the target worker and your worker mints a next-hop delegation as ITSELF —
137
+ the receiver sees your function as the caller, with the original caller's
138
+ authority threaded through the grant chain. Design service-to-service flows
139
+ on this; no direct HTTP between workers.
140
+ - Upsert idiom: try `createNode`, on path-conflict fall back to `::update`.
141
+ - A missing parent yields `Permission denied: EDIT on /<parent>` — read that
142
+ error as "does the parent exist?" first. Seed required folders in postInstall.
143
+
144
+ ## 4 · External APIs — the core pattern
145
+
146
+ Almost every real domain wraps an external API (payment, calendar, LLM
147
+ gateway, cloud provider). The shape (see admin/domain for the full-scale
148
+ example — Scaleway/WorkOS/KV):
149
+
150
+ 1. **Port** — a narrow interface declaring only what the logic needs
151
+ (`WeatherClient { forecast(city) }`). Logic depends on the port, never on
152
+ fetch/SDKs/env.
153
+ 2. **Factory** — `createXClient(env)` in `services/`: reads config + secrets
154
+ from `env`, validates LOUDLY (`if (!env.X_API_KEY) throw`), sets base URLs
155
+ (overridable so tests point at a stub), timeouts (`AbortSignal.timeout`),
156
+ and maps upstream failures to meaningful errors with the upstream detail in
157
+ `cause` (the kernel threads cause chains to callers).
158
+ 3. **Wiring** — the `execute` hook builds the client from `deps` per request
159
+ and passes it to the logic.
160
+
161
+ Secrets & config:
162
+ - Declare every var as a typed field on `Env` in `env.ts`. Secrets ship via
163
+ the adapter's `secrets: '.env.dev' / '.env.prod'` (cloudflare adapter) —
164
+ never committed, never defaulted. Fail fast for root-of-trust values; allow
165
+ multi-name fallbacks only for developer convenience, never silently in prod.
166
+ - The astrale (managed) adapter does NOT ship runtime secrets yet — key'd
167
+ upstream integrations currently need the cloudflare adapter or baked config.
168
+
169
+ Reliability rules (learned from the admin provisioning engine):
170
+ - **Order effects**: external call FIRST, graph write AFTER when possible — a
171
+ failed upstream then leaves nothing to clean up. When you must write first
172
+ (reservations), write an INTENT record (state: 'provisioning'), make the
173
+ external call idempotent (tags/external ids so re-entry ADOPTS instead of
174
+ duplicating), and compensate on failure.
175
+ - **Sagas for multi-step flows**: ordered phases; record state transitions on
176
+ nodes (`provisioning → ready | failed`); compensation runs best-effort in
177
+ reverse and NEVER throws (each step returns ok/skipped/error). Document
178
+ which phases are safe to re-enter.
179
+ - **Idempotency before mutation**: check existing state before writing; design
180
+ re-runs of any handler to converge, not duplicate (postInstall seeds
181
+ especially — they re-run on every reinstall).
182
+
183
+ Anti-patterns (all observed in production code — don't):
184
+ - constructing clients at module load, or monkey-patching `globalThis.fetch`;
185
+ - scattering kernel-error message matching — the kernel exposes no stable
186
+ error codes to handlers yet, so when you must match (the PATH_CONFLICT
187
+ upsert), isolate it in ONE helper (the scaffold's `isPathConflict`) and
188
+ treat it as tech debt;
189
+ - god persistence files — split graph CRUD by entity;
190
+ - leaving state fields mid-transition with no failure path (`'installing'`
191
+ forever after a crash);
192
+ - stringly-typed prop keys or class paths (always compiled accessors).
193
+
194
+ ## 5 · Views & standalone functions (webhooks)
195
+
196
+ - `defineView({ auth, mount: '/ui/contact', viewFor: selfOf(Contact) })` in
197
+ `views/` + register in `views/index.ts`. Installs a View node bound to your
198
+ worker URL; the GUI mounts it as an iframe for matching nodes. The client/
199
+ SPA serves the actual UI under `/ui/*` (cloudflare adapter ships it; the
200
+ managed adapter doesn't ship SPA assets yet).
201
+ - `functions/` declares standalone callables (`defineRemoteFunction`) not
202
+ attached to a class — each serves at `POST <worker>/functions/<slug>` and
203
+ materializes a Function node under `/<origin>/core/functions/`. This is the
204
+ INBOUND integration surface (webhooks).
205
+
206
+ **The webhook-that-writes pattern** (validated): keep `auth: 'required'` and
207
+ configure the external system's auth header with a minted delegation token —
208
+ `astrale token --audience <service url> --ttl <seconds> --raw` (use a
209
+ dedicated, attenuated identity: grant it only what the webhook needs).
210
+ For `auth: 'public'` upstreams that can't carry a header (HMAC-signature
211
+ webhooks, Stripe-style): `kernel` is null, but `ctx.selfKernel()` gives a
212
+ session authenticated as THE FUNCTION'S OWN identity (its grants only) —
213
+ VERIFY THE UPSTREAM SIGNATURE FIRST, then act as yourself. Needs
214
+ `deps.KERNEL_URL` (managed deploys set it) and the function identity granted
215
+ whatever it writes.
216
+
217
+ **Webhook idempotency** (senders retry — design for replays): derive a
218
+ DETERMINISTIC node path from the sender's id (`/contacts/lead-<externalId>`),
219
+ and make that key BOTH the existence check AND the write target. The classic
220
+ bug is checking one key and writing another (random-suffixed) — the replay
221
+ then duplicates. Custom `binding` supports REST-ish routes + header/body
222
+ capture when the sender's shape is fixed (see distribution's proxy functions).
223
+
224
+ ## 6 · Identity, auth, permissions
225
+
226
+ - Your worker IS an identity: at install, every callable gets `(iss = serving
227
+ URL, sub = function path)` stamped in the graph; the kernel verifies your
228
+ worker's signatures against your live JWKS. `astrale.config.ts` origin =
229
+ `schema.domain` (aliasing another origin triggers a DANGER prompt).
230
+ - Inbound calls carry a delegation of the caller; your handler's `kernel` acts
231
+ with `union(caller's delegated authority, your function's own grants)` —
232
+ attenuation is automatic (you can't exceed what the caller + you hold).
233
+ - `authorize` hook: return `undefined` to allow (relying on kernel-level
234
+ checks downstream), or assert claims/perms before `execute` runs.
235
+ - Permissions are bitmasks (READ/EDIT/USE/SHARE) on `has_perm` edges; grants
236
+ on a node cascade down the tree. Function identities get USE on
237
+ `mintDelegationCredential` at install (enables cross-function calls).
238
+
239
+ ## 7 · Deploy & install
240
+
241
+ Adapter choice in `astrale.config.ts`:
242
+ - `cloudflare({...})` — your CF account; `dev` (wrangler dev), `prod` (route or
243
+ workers.dev); ships secrets + SPA assets; extra bindings via a deep-merged
244
+ `wrangler` block.
245
+ - `astrale({ dev: {...}, prod: { instance: '<slug>' } })` — managed: publishes
246
+ the bundle THROUGH the platform and installs it as a host-local service next
247
+ to your instance (`https://<name>-<hash>.svc.<region>.astrale.ai`). No CF
248
+ account; auth = your `astrale auth login` session. v1 limits: no SPA assets,
249
+ no runtime secrets.
250
+
251
+ The first deploy generates `.astrale/identity.ts` — the domain's SIGNING
252
+ IDENTITY (its private key). Losing or regenerating it breaks reinstalls under
253
+ the same origin; back it up (or commit it knowingly for throwaway domains).
254
+
255
+ Dev-loop reality: `pnpm dev` serves on localhost — a REMOTE instance's kernel
256
+ cannot fetch its install bundle. Local URL installs only work against a kernel
257
+ that can reach you (local kernel, or a tunnel). Against a managed/remote
258
+ instance, iterate with `pnpm prod` (the managed loop is ~25s and keeps the
259
+ service URL stable).
260
+
261
+ `postInstall` runs after every install — MUST be a colon MethodPath
262
+ (`/:origin:class.X:seed`; tree paths are rejected) and MUST be idempotent
263
+ (catch path-conflicts). Seed folders, defaults, and demo data here.
264
+
265
+ Manual install of any served domain: `astrale instance install <url>`.
266
+
267
+ ## 8 · Testing
268
+
269
+ - **Logic**: unit-test with fake ports (the DI in §4 exists for this) and a
270
+ fake kernel — an in-memory `{ call(path, params) }` that records calls /
271
+ returns canned nodes. Assert call ORDER and failure paths (best-effort
272
+ flows: one failing step must not block the rest).
273
+ - **Wiring/contract**: typecheck is the contract test (`pnpm typecheck` /
274
+ `tsgo --noEmit`); the schema drives param validation at runtime.
275
+ - **Live smoke** (always finish with this): deploy, then drive the REAL surface
276
+ with the CLI — create a node, call an instance method, walk an edge, call a
277
+ cross-domain function. Fixture-green alone proves nothing about dispatch,
278
+ identity, or bindings.
279
+
280
+ ## 9 · Debugging quick table
281
+
282
+ | Symptom | Likely cause |
283
+ |---|---|
284
+ | `Permission denied: EDIT on /x (param-target)` | `/x` doesn't exist — seed the parent |
285
+ | `method "x" not found … call it as "/:o:class.C/x"` | instance form used for a static method |
286
+ | `Delegation mint failed for <url>` | check `--debug` cause chain; worker→worker call machinery |
287
+ | postInstall `not within origin` | tree path used — switch to `/:origin:class.X:method` |
288
+ | install: `missing remote binding` | a callable lacks `binding.remoteUrl` — build via the adapter, not hand-rolled specs |
289
+ | managed `/ui` 404 | managed adapter ships no SPA assets yet |
290
+ | `ERR_PNPM_IGNORED_BUILDS` / approve-builds on `pnpm run` | template's pnpm-workspace.yaml needs `ignoredBuiltDependencies` + `verifyDepsBeforeRun: false` (recent scaffolds have it) |
291
+ | stale/broken package versions on scaffold | clear pnpm metadata cache; check template floors are current |
292
+ | TS: "Types of property '__brand' are incompatible" in untouched files | TWO copies of kernel-core/dsl in the tree (mixed link:/registry/override resolution) — unify versions, then `pnpm dedupe` |
293
+ | 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` |
294
+
295
+ Use `astrale call <path> --describe` for any callable's schema, `--debug` for
296
+ the full error chain, and `curl <worker>/meta` for what a worker serves
297
+ (domainName, schemaHash).
298
+
299
+ ## Related skills
300
+ - **astrale-cli** — every CLI command (auth, instances, calls, install).
301
+ - **astrale-live-domain-edit** — graph-level schema surgery on a live kernel
302
+ (no worker changes): temp specs, reinstall semantics, minimum class/method
303
+ graph material.
@@ -1,7 +1,16 @@
1
1
  # astrale-domain
2
2
 
3
+
3
4
  A standalone [Astrale](https://astrale.ai) domain, deployed as a Cloudflare Worker.
4
5
 
6
+ ## For AI agents
7
+
8
+ The complete domain-authoring guide ships with this project at
9
+ `.agents/skills/astrale-domain/SKILL.md` — schema modeling, handlers, kernel
10
+ calls, external-API patterns (DI, secrets, idempotency), views, webhooks,
11
+ deploys. Load it before making changes. For CLI operations (auth, instances,
12
+ calls), use the `astrale-cli` skill.
13
+
5
14
  > **Requires [Bun](https://bun.sh)** — the `astrale-domain` CLI behind `pnpm dev`
6
15
  > / `pnpm prod` imports `astrale.config.ts` and your ★ files directly, so it
7
16
  > needs a TypeScript-native runtime.
@@ -11,6 +11,15 @@
11
11
  */
12
12
  import { cloudflare } from '@astrale-os/adapter-cloudflare'
13
13
  import { defineDomain } from '@astrale-os/devkit'
14
+ // No Cloudflare account? Swap the adapter for the Astrale-managed one — it
15
+ // publishes the same bundle THROUGH the platform and installs it on your
16
+ // instance as a managed service (auth = your `astrale auth login` session):
17
+ //
18
+ // import { astrale } from '@astrale-os/adapter-cloudflare'
19
+ // adapter: astrale({
20
+ // dev: { secrets: '.env.dev' }, // local wrangler dev, unchanged
21
+ // prod: { instance: '<your-instance-slug>' } // pnpm prod → managed deploy
22
+ // }),
14
23
 
15
24
  import { schema } from './schema'
16
25
 
@@ -2,6 +2,9 @@
2
2
  "name": "astrale-domain",
3
3
  "version": "0.1.0",
4
4
  "private": true,
5
+ "workspaces": [
6
+ "client"
7
+ ],
5
8
  "type": "module",
6
9
  "scripts": {
7
10
  "dev": "astrale-domain dev",
@@ -11,11 +14,12 @@
11
14
  "typecheck": "tsgo --noEmit"
12
15
  },
13
16
  "dependencies": {
14
- "@astrale-os/adapter-cloudflare": ">=0.1.0 <1.0.0",
15
- "@astrale-os/devkit": ">=0.1.0 <1.0.0",
16
- "@astrale-os/kernel-core": ">=0.3.0 <1.0.0",
17
- "@astrale-os/kernel-dsl": ">=0.1.0 <1.0.0",
18
- "@astrale-os/sdk": ">=0.1.0 <1.0.0",
17
+ "@astrale-os/adapter-cloudflare": ">=0.1.4 <1.0.0",
18
+ "@astrale-os/devkit": ">=0.1.3 <1.0.0",
19
+ "@astrale-os/kernel-core": ">=0.4.3 <1.0.0",
20
+ "@astrale-os/kernel-dsl": ">=0.1.2 <1.0.0",
21
+ "@astrale-os/sdk": ">=0.1.3 <1.0.0",
22
+ "@hono/node-server": "^1.19.0",
19
23
  "zod": "^4.3.6"
20
24
  },
21
25
  "devDependencies": {
@@ -26,5 +30,10 @@
26
30
  },
27
31
  "engines": {
28
32
  "node": ">=22"
29
- }
33
+ },
34
+ "trustedDependencies": [
35
+ "esbuild",
36
+ "sharp",
37
+ "workerd"
38
+ ]
30
39
  }
@@ -15,3 +15,26 @@ allowBuilds:
15
15
  esbuild: true
16
16
  sharp: true
17
17
  workerd: true
18
+ # Explicit `false` for the @astrale-os no-op preinstalls — without these,
19
+ # `pnpm add` of a new version re-prompts and writes placeholder entries here.
20
+ '@astrale-os/kernel-api': false
21
+ '@astrale-os/kernel-client': false
22
+ '@astrale-os/kernel-core': false
23
+ '@astrale-os/kernel-dsl': false
24
+ '@astrale-os/kernel-server': false
25
+ '@astrale-os/sdk': false
26
+
27
+ # @astrale-os packages ship a guarded no-op preinstall (a workspace-dev guard
28
+ # that exits instantly outside the monorepo); declare them intentionally
29
+ # ignored so pnpm's build gate stays quiet.
30
+ ignoredBuiltDependencies:
31
+ - '@astrale-os/kernel-api'
32
+ - '@astrale-os/kernel-client'
33
+ - '@astrale-os/kernel-core'
34
+ - '@astrale-os/kernel-dsl'
35
+ - '@astrale-os/kernel-server'
36
+ - '@astrale-os/sdk'
37
+
38
+ # pnpm v11 gates `pnpm run` on a deps-status check that misfires on the
39
+ # ignored preinstalls above.
40
+ verifyDepsBeforeRun: false