@astrale-os/adapter-astrale 0.5.0-beta.162 → 0.5.0-beta.164

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.
Files changed (58) hide show
  1. package/README.md +74 -36
  2. package/dist/adapter.d.ts +6 -7
  3. package/dist/adapter.js +15 -27
  4. package/dist/admit.d.ts +14 -0
  5. package/dist/admit.js +78 -0
  6. package/dist/cli/commands/call.d.ts +9 -3
  7. package/dist/cli/commands/call.js +15 -6
  8. package/dist/cli/commands/version.d.ts +7 -1
  9. package/dist/cli/commands/version.js +7 -1
  10. package/dist/cli/json.d.ts +0 -1
  11. package/dist/cli/json.js +0 -11
  12. package/dist/configure.d.ts +14 -0
  13. package/dist/configure.js +42 -0
  14. package/dist/deploy/deploy-release.d.ts +34 -0
  15. package/dist/deploy/deploy-release.js +152 -0
  16. package/dist/deploy/list.d.ts +22 -0
  17. package/dist/deploy/list.js +85 -0
  18. package/dist/deploy/readiness.d.ts +16 -4
  19. package/dist/deploy/readiness.js +17 -6
  20. package/dist/index.d.ts +15 -19
  21. package/dist/index.js +15 -19
  22. package/dist/params.d.ts +23 -30
  23. package/dist/services/api.d.ts +114 -0
  24. package/dist/services/api.js +32 -0
  25. package/dist/services/request.d.ts +23 -0
  26. package/dist/services/request.js +70 -0
  27. package/dist/services/response.d.ts +24 -0
  28. package/dist/services/response.js +225 -0
  29. package/package.json +3 -3
  30. package/template/astrale.config.ts +20 -13
  31. package/dist/cli/commands/install-domain.d.ts +0 -10
  32. package/dist/cli/commands/install-domain.js +0 -29
  33. package/dist/cli/commands/introspect.d.ts +0 -8
  34. package/dist/cli/commands/introspect.js +0 -27
  35. package/dist/deploy/deploy.d.ts +0 -22
  36. package/dist/deploy/deploy.js +0 -178
  37. package/dist/deploy/ensure-services.d.ts +0 -23
  38. package/dist/deploy/ensure-services.js +0 -54
  39. package/dist/deploy/progress.d.ts +0 -7
  40. package/dist/deploy/progress.js +0 -17
  41. package/dist/deploy/service/display-name.d.ts +0 -1
  42. package/dist/deploy/service/display-name.js +0 -6
  43. package/dist/deploy/service/method.d.ts +0 -1
  44. package/dist/deploy/service/method.js +0 -3
  45. package/dist/deploy/service/request.d.ts +0 -49
  46. package/dist/deploy/service/request.js +0 -67
  47. package/dist/deploy/service/response.d.ts +0 -5
  48. package/dist/deploy/service/response.js +0 -54
  49. package/dist/deploy/service/service-key.d.ts +0 -1
  50. package/dist/deploy/service/service-key.js +0 -14
  51. package/dist/prepare/parameters.d.ts +0 -8
  52. package/dist/prepare/parameters.js +0 -13
  53. package/dist/prepare/prepare.d.ts +0 -3
  54. package/dist/prepare/prepare.js +0 -5
  55. /package/dist/{deploy/service → services}/base64.d.ts +0 -0
  56. /package/dist/{deploy/service → services}/base64.js +0 -0
  57. /package/dist/{deploy/service → services}/content.d.ts +0 -0
  58. /package/dist/{deploy/service → services}/content.js +0 -0
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # `@astrale-os/adapter-astrale`
2
2
 
3
- Managed Astrale platform deployment adapter for Astrale Domains.
3
+ Managed Astrale platform deployment adapter for Astrale Domains: every deploy is an immutable
4
+ deployment hosted by Admin's Services.
4
5
 
5
6
  During the SDK beta program, install the beta package set explicitly:
6
7
 
@@ -15,43 +16,88 @@ export default defineProject({
15
16
  domain,
16
17
  environments: {
17
18
  development: {
18
- deployment: astrale({ instance: 'customer-development', secrets: '.env.dev' }),
19
+ deployment: astrale({ secrets: '.env.dev' }),
20
+ },
21
+ production: {
22
+ deployment: astrale({ organization: '<Identity id>', secrets: '.env.production' }),
19
23
  },
20
24
  },
21
25
  })
22
26
  ```
23
27
 
24
- The adapter deploys through the Services Domain on the instance `astrale({ instance })` names; an
25
- Environment without one is refused. A deploy never installs the Domain: install the URL
26
- `astrale-domain deploy <environment>` prints with
27
- `astrale domain install <url> --direct -i <instance>`. The deploy itself still calls those Services
28
- through the instance's Kernel, and installs the Services Domain on the instance when it is missing.
29
- A Project Environment that still declares `installation` is refused before any effect, naming
30
- those two commands.
28
+ `astrale-domain deploy <environment>` builds the release locally and makes one immutable
29
+ deployment of it on Admin's Services: its own Worker script at its own URL,
30
+ `https://<line>-<content>.<routingDomain>`. The line comes from the Domain's origin and the
31
+ Environment name, and is opaque (a fingerprint). The content covers the build and the frozen
32
+ configuration (variables, execution settings, durable options, the Workers runtime and the names of
33
+ the declared secrets, never their values), so one URL serves one release and a changed variable gives another
34
+ URL. The commit the deploy runs from is recorded but never part of the label: the same release
35
+ deployed from a later commit, or from a dirty or clean working tree, reuses its deployment, whose
36
+ record keeps the commit of the deploy that created it. Each deployment is its own issuer, with a signing
37
+ key Services generates for it: there is no key file to keep or distribute. Deploying a new release
38
+ leaves earlier deployments served at their own URLs.
39
+
40
+ `organization` names the Identity on the Admin instance (a User, or a Shell Group whose members and
41
+ CI act for it through `extends_with`) that holds the Environment's deployment line. Services
42
+ registers the line to it on the first deploy and refuses the line to anyone else. Every
43
+ Environment but `development` must name one; a `development` Environment without one deploys on a
44
+ line of the deploying identity. `admin` names the Admin bookmark of the astrale CLI to deploy
45
+ through; by default the CLI's configured Admin target.
46
+
47
+ `durable` declares what a Domain serving durable Workflows tells the workflow engine (run
48
+ retention, retry before pausing, the deadline of each Step). The options are frozen into the
49
+ deployment's configuration (`settings.durableOptions`), so another value is another deployment,
50
+ and a durable run stays on the deployment that started it. A hosted deployment binds no service,
51
+ no dispatch namespace and no router.
52
+
53
+ The adapter calls Admin's Services with `astrale call --admin` (astrale CLI 1.0.0-beta.126 or
54
+ newer): `CloudflareDeployment.hosting` to read the routing domain, then
55
+ `CloudflareDeployment.deploy`, a non-durable Action, with the request on stdin; `list` calls
56
+ `CloudflareDeployment.list`, then `CloudflareDeployment.lastCalls`. It never calls an
57
+ instance and never installs the Domain: install the URL the deploy prints with
58
+ `astrale domain install <url> --direct -i <instance>`.
31
59
 
32
- `astrale-domain dev <environment>` and `astrale-domain deploy <environment>` use the same remote
33
- provider path. The adapter starts no local Worker, Vite server, or tunnel. Stopping a watcher retains
34
- the remote Service, stable issuer, and secrets.
60
+ Secrets come from the file `secrets` names. A new deployment binds the file's current values. A
61
+ redeploy of the same release (same label) reuses its deployment and rewrites that deployment's
62
+ secrets in place when they changed (`Secrets: updated`); the new values are served once
63
+ propagated, which is eventually consistent (about 4 s). No other deployment's secrets are ever
64
+ written. A secret name added or removed changes the configuration, so it is a new deployment. To
65
+ rotate a secret of one deployment without redeploying, call its `setSecret` Method on Admin's
66
+ Services with the call target `astrale-domain list --json` gives that deployment:
67
+ `astrale call "<callTarget.path>.method.setSecret" --admin -d @file` (`--admin=<callTarget.admin>`
68
+ when it names a bookmark).
35
69
 
36
- This instance mode replaces one stable Service in place, so the SDK deploys it in legacy direct mode
37
- and warns that it is deprecated. It is replaced by immutable deployments once this adapter
38
- implements `deployRelease`; `instance` and `signingIdentity` are deprecated, and refused from then
39
- on. New Projects scaffolded from this template carry both until then.
70
+ `astrale-domain list [--environment <name>] [--json]` lists, Environment by Environment, the
71
+ deployments Services keeps on the lines the caller holds or acts for (`CloudflareDeployment.list`,
72
+ which changes nothing): each one's release, its name computed from its record
73
+ (`1.4.2 + 7 commits · a1b2c3d · staging`), its state, last call and expiry, its URL, and its call
74
+ target, `@<id>::services.astrale.ai:class.CloudflareDeployment` on the Admin instance.
40
75
 
41
- The adapter sends provider-neutral deployment material: Services receives no Schema revision,
42
- Publication identity, issuer, or callable inventory. It admits exact Services evidence, assembles
43
- the expected Release from the local Build, and verifies the live Publication before returning.
44
- Public HTTPS readiness is cancellable and bounded to ten minutes, allowing a new managed
45
- hostname's certificate to propagate. It returns immediately once verification succeeds;
46
- certificate verification is never disabled. A timeout retains the provider deployment so
47
- retrying the same Environment reuses its Service rather than allocating another hostname.
48
- For a bundled frontend, readiness also verifies the exact browser-file generation on its View
49
- routes. A frontend-only change does not need a Schema revision or Kernel reinstall. HTML responses
50
- are not cached, so a refreshed View cannot reuse a browser-cached document naming retired assets.
51
- Provider deletion and consumer installation remain independent lifecycle operations.
76
+ Services records a deployment's last call, and a preview's expiry, only when it activates it and at
77
+ each expiry pass. The listing therefore also reads `CloudflareDeployment.lastCalls` for the active
78
+ deployments, at most 100 labels per call: the last call shown is the later of the one the dispatcher
79
+ counted and the one Services recorded, and a preview expires 30 days after its activation or that
80
+ call, whichever is later. An Environment whose last calls cannot be read is not listed, rather than
81
+ listed with a stale last call. Admin's Services fails its whole `list` on a stored deployment record
82
+ its own SDK no longer admits (until the Services follow-up SV4b); the listing tolerates a record only
83
+ this SDK refuses.
84
+
85
+ The deploy is ready once the deployment URL serves exactly the sealed release: its `release.json`
86
+ (release digest and build digest), its Bundle and its issuer documents. Readiness is cancellable
87
+ and bounded to two minutes; certificate verification is never disabled. Services refusals are
88
+ reported with their reason (`line-owned-elsewhere`, `deployment-conflict`, ...). A validation or
89
+ ownership refusal changes nothing. `service-unavailable` waited on, or lost to, another operation on
90
+ the deployment and may follow effects: a creation that lost its lease after uploading, or an
91
+ in-place secret rewrite that wrote part of the values. Rerunning the same deploy converges on the
92
+ same deployment.
93
+
94
+ The removed instance mode (`instance`, `serviceKey`, `name`, `signingIdentity`) is refused with the
95
+ configuration to write instead. A Project Environment that declares `installation` is refused before
96
+ any effect, naming the commands that replace it. `astrale-domain dev` serves only legacy direct-mode
97
+ Environments: iterate with `astrale-domain deploy development`, then install the URL it prints.
52
98
 
53
99
  The managed Worker is the one `@astrale-os/adapter-cloudflare` builds: it owns frontend response
54
- headers and routing, and it is the only server-side code. Preparation therefore refuses a built
100
+ headers and routing, and it is the only server-side code. Bundling therefore refuses a built
55
101
  frontend whose root contains `_headers`, `_redirects`, or `.assetsignore`, in any letter case,
56
102
  before anything is uploaded: Services would serve them as public files, whereas a direct Cloudflare
57
103
  deployment would apply them as Workers Static Assets configuration. It likewise refuses a root name
@@ -59,11 +105,3 @@ starting with `_worker.js`, in that exact case, such as a Cloudflare Pages `_wor
59
105
  directory: Services would publish that possible server-side code, whereas Wrangler refuses to
60
106
  upload it. Vite copies its public directory (`public/` by default) to that root, so remove or
61
107
  rename them there. The same names below the root remain ordinary files.
62
-
63
- Services is also the cross-machine serialization boundary for one managed Service. Its graph
64
- operation receipt admits one deployment at a time, and provider promotion is conditional on the
65
- observed Cloudflare digest. The SDK separately locks the Project Environment inside one checkout;
66
- that local lease is not the distributed safety mechanism.
67
-
68
- The private `--credential-file` flag of `astrale-domain dev` authenticates the adapter's provider
69
- calls without placing the credential in Project configuration.
package/dist/adapter.d.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  import type { Deployment } from '@astrale-os/sdk/deployment';
2
- import type { ArtifactSource, LegacyAdapter, PrepareContext } from '@astrale-os/sdk/deployment/adapter';
3
- import type { AstraleDeployDependencies } from './deploy/deploy.js';
2
+ import type { Adapter } from '@astrale-os/sdk/deployment/adapter';
3
+ import type { AstraleDependencies } from './deploy/deploy-release.js';
4
4
  import type { AstraleParams } from './params.js';
5
- export interface AstraleDependencies extends AstraleDeployDependencies {
6
- prepare(parameters: AstraleParams, context: PrepareContext): Promise<ArtifactSource>;
7
- }
8
- export declare function astrale(parameters?: AstraleParams): Deployment<AstraleParams, LegacyAdapter<AstraleParams>>;
9
- export declare function astraleWithDependencies(parameters: AstraleParams, dependencies: AstraleDependencies): Deployment<AstraleParams, LegacyAdapter<AstraleParams>>;
5
+ export type { AstraleDependencies } from './deploy/deploy-release.js';
6
+ /** Deploy one Project Environment as immutable deployments on Admin's Services. */
7
+ export declare function astrale(parameters?: AstraleParams): Deployment<AstraleParams, Adapter<AstraleParams>>;
8
+ export declare function astraleWithDependencies(parameters: AstraleParams, dependencies: AstraleDependencies): Deployment<AstraleParams, Adapter<AstraleParams>>;
package/dist/adapter.js CHANGED
@@ -1,33 +1,23 @@
1
- import { cloudflareWorkerBundler, verifyWorkerFrontend } from '@astrale-os/adapter-cloudflare/build';
2
- import { signingIdentity } from '@astrale-os/adapter-cloudflare/identity';
1
+ import { cloudflareWorkerBundler } from '@astrale-os/adapter-cloudflare/build';
3
2
  import { defineAdapter, defineDeployment } from '@astrale-os/sdk/deployment/adapter';
4
- import { verifyReadiness } from '@astrale-os/sdk/deployment/verify';
5
3
  import { createRequire } from 'node:module';
6
- import { callAstrale } from './cli/commands/call.js';
7
- import { installDomain } from './cli/commands/install-domain.js';
8
- import { introspectDomain } from './cli/commands/introspect.js';
4
+ import { admitAstraleParameters } from './admit.js';
5
+ import { callAdmin } from './cli/commands/call.js';
9
6
  import { requireCliVersion } from './cli/commands/version.js';
10
7
  import { resolveCliExecutable } from './cli/executable.js';
11
- import { deployAstrale } from './deploy/deploy.js';
12
- import { ensureServices } from './deploy/ensure-services.js';
8
+ import { configureAstrale } from './configure.js';
9
+ import { deployAstraleRelease, placeAstrale } from './deploy/deploy-release.js';
10
+ import { listAstraleDeployments } from './deploy/list.js';
13
11
  import { waitForReadiness } from './deploy/readiness.js';
14
- import { prepareAstrale } from './prepare/prepare.js';
15
12
  const packageVersion = createRequire(import.meta.url)('../package.json')
16
13
  .version;
14
+ /** Deploy one Project Environment as immutable deployments on Admin's Services. */
17
15
  export function astrale(parameters = {}) {
18
16
  return astraleWithDependencies(parameters, {
19
- prepare: prepareAstrale,
20
- ensureServices,
21
- callAstrale,
22
- introspectDomain,
23
- installDomain,
24
- requireCliVersion,
25
17
  resolveCliExecutable,
26
- waitForReadiness: (release, signal, worker) => waitForReadiness(release, signal, async (release, options) => {
27
- await verifyReadiness(release, options);
28
- await verifyWorkerFrontend(release, worker, options);
29
- }),
30
- signingIdentity,
18
+ requireCliVersion,
19
+ callAdmin,
20
+ waitForReadiness: (release, signal) => waitForReadiness(release, signal),
31
21
  });
32
22
  }
33
23
  export function astraleWithDependencies(parameters, dependencies) {
@@ -36,13 +26,11 @@ export function astraleWithDependencies(parameters, dependencies) {
36
26
  version: packageVersion,
37
27
  // Services hosts the same generated Worker: both adapters share one build.
38
28
  bundler: cloudflareWorkerBundler,
39
- admit(parameters, context) {
40
- if (parameters.instance === undefined) {
41
- throw new TypeError(`Astrale Environment ${context.environment} requires astrale({ instance }): the instance whose Services hosts its deployment.`);
42
- }
43
- },
44
- prepare: dependencies.prepare,
45
- deploy: (parameters, context) => deployAstrale(parameters, context, dependencies),
29
+ admit: admitAstraleParameters,
30
+ configure: configureAstrale,
31
+ placement: (parameters, context) => placeAstrale(parameters, context, dependencies),
32
+ deployRelease: (parameters, context) => deployAstraleRelease(parameters, context, dependencies),
33
+ list: (parameters, context) => listAstraleDeployments(parameters, context, dependencies),
46
34
  secretsFile: (parameters) => parameters.secrets,
47
35
  });
48
36
  return defineDeployment(adapter, parameters);
@@ -0,0 +1,14 @@
1
+ import type { AdapterEnvironmentContext } from '@astrale-os/sdk/deployment/adapter';
2
+ import type { AstraleParams } from './params.js';
3
+ /** The one Environment that deploys on a line of the deploying identity without naming one (AM-7). */
4
+ export declare const DEVELOPMENT = "development";
5
+ /**
6
+ * Refuse, when the Project loads, an Environment this adapter cannot deploy: an unknown or removed
7
+ * parameter, an Environment other than `development` that names no organisation, or a malformed
8
+ * organisation or Admin bookmark.
9
+ *
10
+ * An Environment of the removed instance mode (`instance`, `signingIdentity`) is left to the deploy
11
+ * mode selection, which refuses it when it deploys with the configuration to write instead; loading
12
+ * it to build or test it has no effect.
13
+ */
14
+ export declare function admitAstraleParameters(parameters: AstraleParams, context: AdapterEnvironmentContext): void;
package/dist/admit.js ADDED
@@ -0,0 +1,78 @@
1
+ /** The parameters an Environment of this adapter declares. */
2
+ const PARAMETERS = Object.freeze([
3
+ 'organization',
4
+ 'admin',
5
+ 'secrets',
6
+ 'vars',
7
+ 'maximumRequestBytes',
8
+ 'tokenExchange',
9
+ 'durable',
10
+ ]);
11
+ /**
12
+ * The parameters of the removed instance mode. `astrale-domain deploy` refuses them before any
13
+ * effect, with the configuration to write instead (CT33, AM-72).
14
+ */
15
+ const INSTANCE_MODE = Object.freeze(['instance', 'signingIdentity']);
16
+ /** The parameters that named the stable Service of the removed instance mode. */
17
+ const INSTANCE_SERVICE = Object.freeze(['serviceKey', 'name']);
18
+ /** The one Environment that deploys on a line of the deploying identity without naming one (AM-7). */
19
+ export const DEVELOPMENT = 'development';
20
+ /** The longest organisation Identity id or Admin bookmark name an Environment may name. */
21
+ const MAXIMUM_NAME_LENGTH = 256;
22
+ /**
23
+ * Refuse, when the Project loads, an Environment this adapter cannot deploy: an unknown or removed
24
+ * parameter, an Environment other than `development` that names no organisation, or a malformed
25
+ * organisation or Admin bookmark.
26
+ *
27
+ * An Environment of the removed instance mode (`instance`, `signingIdentity`) is left to the deploy
28
+ * mode selection, which refuses it when it deploys with the configuration to write instead; loading
29
+ * it to build or test it has no effect.
30
+ */
31
+ export function admitAstraleParameters(parameters, context) {
32
+ const values = parameters;
33
+ // A parameter is declared when its value is not `undefined`, as optional parameters read.
34
+ const declared = Reflect.ownKeys(values).filter((key) => values[key] !== undefined);
35
+ const environment = `Astrale Environment ${context.environment}`;
36
+ if (declared.some((key) => isOneOf(key, INSTANCE_MODE)))
37
+ return;
38
+ const service = declared.filter((key) => isOneOf(key, INSTANCE_SERVICE));
39
+ if (service.length > 0) {
40
+ throw new TypeError(`${environment} declares ${names(service)}, which named the stable Service of the removed ` +
41
+ `instance mode. Remove ${service.length === 1 ? 'it' : 'them'}: each immutable ` +
42
+ 'deployment is named by its own label.');
43
+ }
44
+ const unknown = declared.filter((key) => !isOneOf(key, PARAMETERS));
45
+ if (unknown.length > 0) {
46
+ throw new TypeError(`${environment} declares unknown parameters ${names(unknown)}.`);
47
+ }
48
+ if (parameters.organization === undefined) {
49
+ if (context.environment !== DEVELOPMENT) {
50
+ throw new TypeError(`${environment} requires astrale({ organization }): the Identity on the Admin instance ` +
51
+ `that holds its deployment line. Only ${DEVELOPMENT} deploys on a line of the ` +
52
+ 'deploying identity without naming one.');
53
+ }
54
+ }
55
+ else if (!stable(parameters.organization, MAXIMUM_NAME_LENGTH)) {
56
+ throw new TypeError(`${environment} names an invalid organization: an Identity id on the Admin instance, at ` +
57
+ `most ${MAXIMUM_NAME_LENGTH} characters, without whitespace.`);
58
+ }
59
+ if (parameters.admin !== undefined &&
60
+ (!stable(parameters.admin, MAXIMUM_NAME_LENGTH) ||
61
+ parameters.admin.startsWith('-') ||
62
+ parameters.admin.includes('='))) {
63
+ throw new TypeError(`${environment} names an invalid admin: the name of an Admin bookmark of the astrale CLI.`);
64
+ }
65
+ }
66
+ /** A non-empty single token: no whitespace or control character, within `maximum` characters. */
67
+ function stable(value, maximum) {
68
+ return (typeof value === 'string' &&
69
+ value.length > 0 &&
70
+ value.length <= maximum &&
71
+ !/[\s\p{Cc}]/u.test(value));
72
+ }
73
+ function isOneOf(key, list) {
74
+ return typeof key === 'string' && list.includes(key);
75
+ }
76
+ function names(keys) {
77
+ return keys.map((key) => `\`${String(key)}\``).join(', ');
78
+ }
@@ -1,9 +1,15 @@
1
- export declare function callAstrale(input: {
1
+ /**
2
+ * Call one Domain Method on Admin's Kernel with `astrale call --admin` (CT21) and decode its JSON
3
+ * result. The input goes through stdin (`-d -`), never argv, since it can hold the Environment's
4
+ * secrets; `--admin=<bookmark>` keeps a bookmark from being read as a param.
5
+ */
6
+ export declare function callAdmin(input: {
2
7
  readonly executable: string;
3
8
  readonly projectDir: string;
4
- readonly instance: string;
9
+ /** The Admin bookmark; the CLI's configured Admin target when absent. */
10
+ readonly admin?: string;
5
11
  readonly path: string;
6
- readonly identity: readonly string[];
12
+ readonly authority: readonly string[];
7
13
  readonly data: unknown;
8
14
  readonly signal: AbortSignal;
9
15
  }): Promise<unknown>;
@@ -1,7 +1,15 @@
1
1
  import { CliProcessError } from '../error.js';
2
2
  import { decodeJson } from '../json.js';
3
3
  import { runCliProcess } from '../process.js';
4
- export async function callAstrale(input) {
4
+ /** How long a call to Admin's Services may take, and the CLI process around it. */
5
+ const CALL_TIMEOUT_MS = 240_000;
6
+ const PROCESS_TIMEOUT_MS = 250_000;
7
+ /**
8
+ * Call one Domain Method on Admin's Kernel with `astrale call --admin` (CT21) and decode its JSON
9
+ * result. The input goes through stdin (`-d -`), never argv, since it can hold the Environment's
10
+ * secrets; `--admin=<bookmark>` keeps a bookmark from being read as a param.
11
+ */
12
+ export async function callAdmin(input) {
5
13
  const result = await runCliProcess({
6
14
  executable: input.executable,
7
15
  projectDir: input.projectDir,
@@ -10,16 +18,17 @@ export async function callAstrale(input) {
10
18
  '--no-prompt',
11
19
  'call',
12
20
  input.path,
13
- '-i',
14
- input.instance,
21
+ input.admin === undefined ? '--admin' : `--admin=${input.admin}`,
15
22
  '--json',
16
23
  '--timeout',
17
- '240000',
18
- ...input.identity,
24
+ String(CALL_TIMEOUT_MS),
25
+ ...input.authority,
26
+ '-d',
27
+ '-',
19
28
  ],
20
29
  stdin: JSON.stringify(input.data),
21
30
  signal: input.signal,
22
- timeoutMs: 250_000,
31
+ timeoutMs: PROCESS_TIMEOUT_MS,
23
32
  });
24
33
  if (!result.ok)
25
34
  throw new CliProcessError('command', `call ${input.path}`, result.failure);
@@ -1,4 +1,10 @@
1
- export declare const MINIMUM_ASTRALE_CLI_VERSION = "1.0.0-beta.48";
1
+ /**
2
+ * The first astrale CLI release whose `call` runs on the Admin kernel (`--admin`) and reads its
3
+ * input from stdin with `-d -` (CT21, cli#579), built on an SDK that reads an R1 Kernel's Schema
4
+ * introspection (cli#581): every deploy reaches Admin's Services that way. cli 1.0.0-beta.125
5
+ * carries neither.
6
+ */
7
+ export declare const MINIMUM_ASTRALE_CLI_VERSION = "1.0.0-beta.126";
2
8
  export declare function requireCliVersion(input: {
3
9
  readonly executable: string;
4
10
  readonly projectDir: string;
@@ -1,6 +1,12 @@
1
1
  import { CliProcessError } from '../error.js';
2
2
  import { runCliProcess } from '../process.js';
3
- export const MINIMUM_ASTRALE_CLI_VERSION = '1.0.0-beta.48';
3
+ /**
4
+ * The first astrale CLI release whose `call` runs on the Admin kernel (`--admin`) and reads its
5
+ * input from stdin with `-d -` (CT21, cli#579), built on an SDK that reads an R1 Kernel's Schema
6
+ * introspection (cli#581): every deploy reaches Admin's Services that way. cli 1.0.0-beta.125
7
+ * carries neither.
8
+ */
9
+ export const MINIMUM_ASTRALE_CLI_VERSION = '1.0.0-beta.126';
4
10
  export async function requireCliVersion(input) {
5
11
  const result = await runCliProcess({
6
12
  executable: input.executable,
@@ -1,3 +1,2 @@
1
1
  export declare function decodeJson(input: string, label: string): unknown;
2
2
  export declare function decodeFailure(input: string): Readonly<Record<string, unknown>>;
3
- export declare function isDomainNotInstalledFailure(input: Readonly<Record<string, unknown>>): boolean;
package/dist/cli/json.js CHANGED
@@ -24,17 +24,6 @@ export function decodeFailure(input) {
24
24
  ...(reason === undefined ? {} : { reason }),
25
25
  });
26
26
  }
27
- export function isDomainNotInstalledFailure(input) {
28
- if (input.error === 'DOMAIN_NOT_INSTALLED')
29
- return true;
30
- if (input.error !== 'RESPONSE_ERROR')
31
- return false;
32
- const reason = input.reason;
33
- return (reason !== null &&
34
- typeof reason === 'object' &&
35
- !Array.isArray(reason) &&
36
- reason.code === 'SCHEMA_NOT_FOUND');
37
- }
38
27
  function failureReason(input) {
39
28
  if (input === undefined)
40
29
  return undefined;
@@ -0,0 +1,14 @@
1
+ import type { ConfigureContext } from '@astrale-os/sdk/deployment/adapter';
2
+ import type { FrozenConfigurationV1 } from '@astrale-os/sdk/deployment/address';
3
+ import type { AstraleParams } from './params.js';
4
+ /**
5
+ * What one deployment of this Environment freezes beside its build: the author's variables, the
6
+ * execution settings the generated Worker runs under, defaults resolved, its durable options when
7
+ * the Environment declares them (AM-175), the Workers runtime every generated Worker runs on, and
8
+ * the names of the Environment's secrets. A deployment on Admin's Services binds no service, no
9
+ * dispatch namespace and no router (AM-174): it reaches its Kernel through its public issuer.
10
+ *
11
+ * Pure: the same parameters and secret names give the same configuration, so the same release
12
+ * gives the same deployment address on every run.
13
+ */
14
+ export declare function configureAstrale(parameters: AstraleParams, context: ConfigureContext): FrozenConfigurationV1;
@@ -0,0 +1,42 @@
1
+ import { GENERATED_WORKER_RUNTIME, isAdapterVar, workerSettings, } from '@astrale-os/adapter-cloudflare/build';
2
+ import { frozenConfiguration } from '@astrale-os/sdk/deployment/address';
3
+ /**
4
+ * What one deployment of this Environment freezes beside its build: the author's variables, the
5
+ * execution settings the generated Worker runs under, defaults resolved, its durable options when
6
+ * the Environment declares them (AM-175), the Workers runtime every generated Worker runs on, and
7
+ * the names of the Environment's secrets. A deployment on Admin's Services binds no service, no
8
+ * dispatch namespace and no router (AM-174): it reaches its Kernel through its public issuer.
9
+ *
10
+ * Pure: the same parameters and secret names give the same configuration, so the same release
11
+ * gives the same deployment address on every run.
12
+ */
13
+ export function configureAstrale(parameters, context) {
14
+ const vars = parameters.vars ?? {};
15
+ const owned = [...Object.keys(vars), ...context.secrets].filter(isAdapterVar);
16
+ if (owned.length > 0) {
17
+ throw new TypeError(`Astrale Environment ${context.environment} binds ${owned.join(', ')}, which the deployment ` +
18
+ 'binds itself; rename the variable or secret.');
19
+ }
20
+ const settings = workerSettings({
21
+ ...(parameters.maximumRequestBytes === undefined
22
+ ? {}
23
+ : { maximumRequestBytes: parameters.maximumRequestBytes }),
24
+ ...(parameters.tokenExchange === undefined ? {} : { tokenExchange: parameters.tokenExchange }),
25
+ ...(parameters.durable === undefined ? {} : { durable: parameters.durable }),
26
+ });
27
+ return frozenConfiguration({
28
+ vars,
29
+ settings: {
30
+ maximumRequestBytes: settings.maximumRequestBytes,
31
+ invocationTimeoutMs: settings.invocationTimeoutMs,
32
+ tokenExchange: settings.tokenExchange,
33
+ ...(settings.durableOptions === undefined ? {} : { durableOptions: settings.durableOptions }),
34
+ },
35
+ runtime: {
36
+ compatibilityDate: GENERATED_WORKER_RUNTIME.compatibilityDate,
37
+ compatibilityFlags: GENERATED_WORKER_RUNTIME.compatibilityFlags,
38
+ },
39
+ bindings: { services: [], dispatchNamespaces: [], secrets: context.secrets },
40
+ router: false,
41
+ });
42
+ }
@@ -0,0 +1,34 @@
1
+ import type { Placement, PlacementContext, ReleaseDeployContext, ReleaseDeployResult } from '@astrale-os/sdk/deployment/adapter';
2
+ import type { Release } from '@astrale-os/sdk/deployment/release';
3
+ import type { callAdmin } from '../cli/commands/call.js';
4
+ import type { requireCliVersion } from '../cli/commands/version.js';
5
+ import type { resolveCliExecutable } from '../cli/executable.js';
6
+ import type { AstraleParams } from '../params.js';
7
+ /** The effects this adapter has, replaceable in tests. */
8
+ export interface AstraleDependencies {
9
+ readonly resolveCliExecutable: typeof resolveCliExecutable;
10
+ readonly requireCliVersion: typeof requireCliVersion;
11
+ readonly callAdmin: typeof callAdmin;
12
+ /** Wait until the deployment serves its sealed release at its URL. */
13
+ readonly waitForReadiness: (release: Release, signal: AbortSignal) => Promise<void>;
14
+ }
15
+ /**
16
+ * Where Admin's Services places this Environment's deployments: under the routing domain its
17
+ * `hosting` answers, on an opaque line. Lines of this adapter are tenant lines: the readable form
18
+ * is the platform organisation's, whose Domains deploy into the platform namespace instead (D12).
19
+ * Reading `hosting` changes nothing at the host.
20
+ */
21
+ export declare function placeAstrale(parameters: AstraleParams, context: PlacementContext, dependencies: AstraleDependencies): Promise<Placement>;
22
+ /**
23
+ * Create, or reuse, the immutable deployment of one sealed release on Admin's Services.
24
+ *
25
+ * One non-durable `CloudflareDeployment.deploy` call carries the release's address, its record,
26
+ * its Worker upload and the Environment's current secrets, which are never journaled. A new
27
+ * deployment binds those secrets and a key Services generates for it; a deployment of the same
28
+ * release (same label) is reused and has its own declared secrets rewritten in place when they
29
+ * changed. No other deployment is ever written (AM-4'). The deployment is then ready once its URL
30
+ * serves exactly the sealed release.
31
+ */
32
+ export declare function deployAstraleRelease(parameters: AstraleParams, context: ReleaseDeployContext, dependencies: AstraleDependencies): Promise<ReleaseDeployResult>;
33
+ /** Resolve the astrale CLI once per operation and require the release that serves `call --admin`. */
34
+ export declare function requireAstraleCli(projectDir: string, signal: AbortSignal, dependencies: AstraleDependencies): Promise<string>;