@almadar/shell-node 0.0.0-stage → 1.0.0

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,130 @@
1
+ import { ServiceCallContext, SecretPortsOptions } from '@almadar/shell-runtime';
2
+ import { OrbitalSchema, EntityRow, EventPayload, UserContext, EmittedEvent, TransitionRejection, InboundDelivery, InboundAnswer } from '@almadar/core';
3
+
4
+ /**
5
+ * The slice of a workspace the program host drives: write a file into it and snapshot it.
6
+ * `@almadar/runtime` implements it over `std-workspace` on the kernel.
7
+ */
8
+ interface WorkspacePort {
9
+ /** The workspace's absolute directory. */
10
+ readonly workDir: string;
11
+ writeFile(relPath: string, content: string): Promise<void>;
12
+ snapshot(reason: string): Promise<{
13
+ oid: string;
14
+ } | null>;
15
+ listSnapshots(opts?: {
16
+ limit?: number;
17
+ }): Promise<Array<{
18
+ id: string;
19
+ timestamp: number;
20
+ reason: string;
21
+ }>>;
22
+ }
23
+ /**
24
+ * Where a host keeps its workspaces, and how it opens the one a call names as
25
+ * the calling principal (it owns access). A workspace lives at
26
+ * `<root>/<owner>/<session>` (`owner` = {@link workspaceOwnerSegment} of the principal).
27
+ */
28
+ interface WorkspaceHost {
29
+ readonly root: string;
30
+ open(workspace: string, context: ServiceCallContext): Promise<WorkspacePort>;
31
+ }
32
+ /** Install the host's workspaces; called once at boot. */
33
+ declare function installWorkspaceHost(host: WorkspaceHost): void;
34
+ /** Testing/reset hook. */
35
+ declare function uninstallWorkspaceHost(): void;
36
+ /** The installed workspace host, or null on a host that keeps none. */
37
+ declare function installedWorkspaceHost(): WorkspaceHost | null;
38
+ /**
39
+ * A principal's workspace directory name: letters, digits and `-` kept, every
40
+ * other UTF-8 byte (including `_`) written as `_` plus two hex digits. One
41
+ * path segment per principal, reversible, so no two principals share one.
42
+ * The same encoding `std-workspace` gives its owner and workspace directories.
43
+ */
44
+ declare function workspaceOwnerSegment(principal: string): string;
45
+
46
+ interface KernelProgramOptions {
47
+ /** Which kernel runs the program: the WebAssembly module (default; the only one in a browser) or the native add-on. The host's ports are the same for both. */
48
+ engine?: 'wasm' | 'native';
49
+ /** The native kernel add-on (`kernel.node`); absent, `resolveNativeAddon(options.languageFrom)`. Used only by `engine: 'native'`. */
50
+ nativeAddon?: string;
51
+ /** The directory of the built `@almadar/kernel` package (the one holding `pkg/`); absent, `resolveKernelDir()`. */
52
+ kernelDir?: string;
53
+ /** Where the installed `@almadar/core` and `@almadar/std` are found, node-style. */
54
+ languageFrom: string;
55
+ /** Overrides of the secret store and the CSPRNG. */
56
+ secretPorts?: Pick<SecretPortsOptions, 'secrets' | 'random'>;
57
+ /** Rows the program's in-memory store starts with, by entity name (a catalog the host already holds). */
58
+ seed?: Record<string, EntityRow[]>;
59
+ /** Answer the program's `os` effects with the Node host (its grants are the program's own); absent, every `os` ask is denied. */
60
+ os?: boolean;
61
+ }
62
+ interface ProgramRun {
63
+ success: boolean;
64
+ /** Every event the dispatch emitted, in order: the program's `-> external` results among them. */
65
+ emits: EmittedEvent[];
66
+ /** Why a transition or one of its effects did not run (an `effect-failed` carries the error); empty when all ran. */
67
+ rejections: TransitionRejection[];
68
+ error?: string;
69
+ }
70
+ /** The payload of the first emit named `event`, read through `read`; `undefined` when the run emitted none. */
71
+ declare function emitPayload<T>(run: ProgramRun, event: string, read: (payload: EventPayload) => T): T | undefined;
72
+ /**
73
+ * `orb resolve`: the program with every `uses` flattened, as the kernel engine takes it. `orb` is the binary to run,
74
+ * by default the one `resolveOrbBinary` picks.
75
+ */
76
+ declare function resolveProgramFile(path: string, cwd?: string, orb?: string): Promise<OrbitalSchema>;
77
+ declare class KernelProgram {
78
+ private readonly engine;
79
+ private readonly os;
80
+ private readonly schema;
81
+ private readonly secretPorts;
82
+ private readonly persistence;
83
+ private constructor();
84
+ static open(schema: OrbitalSchema, options: KernelProgramOptions): Promise<KernelProgram>;
85
+ /** Fire `event` at the orbital as `user` (the program's `@user`), wait for its whole cascade (every secret ask included), and return what it emitted. */
86
+ dispatch(orbital: string, event: string, payload?: EventPayload, targetTrait?: string, user?: UserContext): Promise<ProgramRun>;
87
+ /** Fire `trait`'s tick `name` once, as a host timer would; the kernel evaluates the tick's guard and effects. */
88
+ tick(orbital: string, trait: string, name: string): Promise<ProgramRun>;
89
+ /** Deliver an `/api/hooks/<name>` request to the program and return the answer it gave (EXEC-INBOUND-1). */
90
+ deliverInbound(name: string, delivery: InboundDelivery): Promise<InboundAnswer>;
91
+ /** The rows the host's in-memory store holds for `entity` (empty when the native kernel keeps its own `store`). */
92
+ rows(entity: string): Promise<EntityRow[]>;
93
+ close(): void;
94
+ }
95
+
96
+ /** Workspaces kept in a bucket through `std-storage` over SigV4 (Google Cloud Storage's S3 interoperability endpoint with HMAC keys). */
97
+ interface KernelWorkspaceBucket {
98
+ /** The bucket name. */
99
+ name: string;
100
+ /** The S3-compatible origin; `https://storage.googleapis.com` for Google Cloud Storage. */
101
+ endpoint: string;
102
+ /** The signing region; `auto` for Google Cloud Storage. */
103
+ region: string;
104
+ /** The name of the credential (an environment variable) holding the HMAC access key id. */
105
+ accessKeyId: string;
106
+ /** The name of the credential (an environment variable) holding the HMAC secret. */
107
+ secretAccessKey: string;
108
+ }
109
+ /** The bucket a host's environment names: `ALMADAR_WORKSPACE_BUCKET` on Google Cloud Storage, keyed by the two HMAC credentials; absent, the project's disk. */
110
+ declare function workspaceBucketFromEnv(env: Record<string, string | undefined>): KernelWorkspaceBucket | undefined;
111
+ interface KernelWorkspaceHostOptions {
112
+ /** Keep the workspaces in this bucket (the project's `workspaces/` directory is then a cache); absent, on the project's disk. */
113
+ bucket?: KernelWorkspaceBucket;
114
+ /** The project the program host runs `orb` in; workspaces live under its `workspaces/` directory. */
115
+ projectRoot: string;
116
+ /** The `orb` binary that resolves the generated program; absent, the host's default resolution. */
117
+ orb?: string;
118
+ /** How the kernel is loaded; the `os` answerer is always on. */
119
+ kernel?: Omit<KernelProgramOptions, 'os' | 'languageFrom'>;
120
+ }
121
+ /** Where a project keeps its workspaces. */
122
+ declare function workspacesRoot(projectRoot: string): string;
123
+ /**
124
+ * The workspace host over `std-workspace`: one kernel program for the host, opened on first use, one request at a time.
125
+ * Each call runs as the calling principal (`@user.id`), which the atom turns into the owner directory.
126
+ */
127
+ declare function kernelWorkspaceHost(options: KernelWorkspaceHostOptions): WorkspaceHost;
128
+
129
+ export { KernelProgram as K, emitPayload as e, installedWorkspaceHost as f, workspaceOwnerSegment as g, workspacesRoot as h, installWorkspaceHost as i, kernelWorkspaceHost as k, resolveProgramFile as r, uninstallWorkspaceHost as u, workspaceBucketFromEnv as w };
130
+ export type { ProgramRun as P, WorkspaceHost as W, KernelProgramOptions as a, KernelWorkspaceBucket as b, KernelWorkspaceHostOptions as c, WorkspacePort as d };
@@ -0,0 +1,3 @@
1
+ export { b as KernelWorkspaceBucket, c as KernelWorkspaceHostOptions, k as kernelWorkspaceHost, w as workspaceBucketFromEnv, h as workspacesRoot } from './kernel-workspace-host-cT9JGJur.js';
2
+ import '@almadar/shell-runtime';
3
+ import '@almadar/core';
@@ -0,0 +1,4 @@
1
+ export { kernelWorkspaceHost, workspaceBucketFromEnv, workspacesRoot } from './chunk-YLFK5OJN.js';
2
+ import './chunk-VQVAHUAX.js';
3
+ import './chunk-EEYGL7AB.js';
4
+ import './chunk-BWMLDDCL.js';
@@ -0,0 +1,2 @@
1
+ export { behaviorCatalog, behaviorCatalogSync, behaviorDependencies, behaviorDescribe, behaviorResolve, behaviorSource, programCompose, programEval, programOsGrants, programPrint, programProve, programRead, programResolve, programResolveSchema, programStep, programValidate, runProgramEffect, workspaceAccessError } from './chunk-7QE32QQR.js';
2
+ export { installWorkspaceHost, installedWorkspaceHost, uninstallWorkspaceHost, workspaceOwnerSegment } from './chunk-BWMLDDCL.js';
package/package.json CHANGED
@@ -1,6 +1,67 @@
1
1
  {
2
2
  "name": "@almadar/shell-node",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.0",
4
+ "orbRelease": {
5
+ "severity": "normal"
6
+ },
7
+ "description": "Almadar TS shell node runtime pack: the Node os/* and program/* host of the kernel (os families, KernelProgram, workspace, program host).",
8
+ "license": "BUSL-1.1",
9
+ "type": "module",
10
+ "main": "./dist/index.js",
11
+ "module": "./dist/index.js",
12
+ "types": "./dist/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ },
18
+ "./OrbitalServerRuntime": {
19
+ "types": "./dist/OrbitalServerRuntime.d.ts",
20
+ "import": "./dist/OrbitalServerRuntime.js"
21
+ },
22
+ "./kernelWorkspace": {
23
+ "types": "./dist/kernelWorkspace.d.ts",
24
+ "import": "./dist/kernelWorkspace.js"
25
+ },
26
+ "./createProgramHandlers": {
27
+ "types": "./dist/createProgramHandlers.d.ts",
28
+ "import": "./dist/createProgramHandlers.js"
29
+ }
30
+ },
31
+ "files": [
32
+ "dist"
33
+ ],
34
+ "sideEffects": false,
35
+ "publishConfig": {
36
+ "registry": "https://registry.npmjs.org",
37
+ "access": "public"
38
+ },
39
+ "dependencies": {
40
+ "@almadar/core": "^11.1.0",
41
+ "@almadar/kernel": "^19.0.1",
42
+ "@almadar/logger": "^2.1.0",
43
+ "zod": "^4.6.7",
44
+ "@almadar/std": "^17.0.0",
45
+ "@almadar/shell-runtime": "^1.0.0"
46
+ },
47
+ "devDependencies": {
48
+ "@types/node": "^20.0.0",
49
+ "tsup": "^9.0.0",
50
+ "typescript": "npm:@typescript/typescript6@^6.0.2",
51
+ "vitest": "^4.1.12"
52
+ },
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "https://github.com/almadar-io/orbital-shell-typescript.git",
56
+ "directory": "hosts/node"
57
+ },
58
+ "engines": {
59
+ "node": ">=22.19.0"
60
+ },
61
+ "scripts": {
62
+ "prebuild": "rm -rf dist",
63
+ "build": "tsup",
64
+ "typecheck": "tsc --noEmit",
65
+ "test": "vitest --run"
66
+ }
6
67
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.