@nimbus-sh/worker 0.7.0 → 0.8.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.
- package/dist/facets/manager.d.ts.map +1 -1
- package/dist/facets/manager.js +16 -5
- package/dist/facets/real-vite-hmr.d.ts +3 -1
- package/dist/facets/real-vite-hmr.d.ts.map +1 -1
- package/dist/facets/real-vite-hmr.js +18 -8
- package/dist/facets/ws-terminal.d.ts +9 -31
- package/dist/facets/ws-terminal.d.ts.map +1 -1
- package/dist/facets/ws-terminal.js +58 -51
- package/dist/hosted/commands.d.ts +12 -0
- package/dist/hosted/commands.d.ts.map +1 -0
- package/dist/hosted/commands.js +1658 -0
- package/dist/hosted/runtime.d.ts +114 -0
- package/dist/hosted/runtime.d.ts.map +1 -0
- package/dist/hosted/runtime.js +288 -0
- package/dist/hosted/services.d.ts +40 -0
- package/dist/hosted/services.d.ts.map +1 -0
- package/dist/hosted/services.js +512 -0
- package/dist/runtime/bash-repl.d.ts +1 -1
- package/dist/runtime/bash-repl.d.ts.map +1 -1
- package/dist/runtime/bash-repl.js +38 -4
- package/dist/runtime/bun-runner.js +1 -1
- package/dist/runtime/node-runner.d.ts +1 -1
- package/dist/runtime/node-runner.d.ts.map +1 -1
- package/dist/runtime/node-runner.js +2 -2
- package/dist/runtime/opencode-facet-runner.js +14 -14
- package/dist/runtime/package-manager.d.ts +35 -122
- package/dist/runtime/package-manager.d.ts.map +1 -1
- package/dist/runtime/package-manager.js +61 -596
- package/dist/runtime/process-logs-api.d.ts +1 -1
- package/dist/runtime/process-logs-api.d.ts.map +1 -1
- package/dist/runtime/process-logs-api.js +1 -1
- package/dist/runtime/python-repl.d.ts +2 -1
- package/dist/runtime/python-repl.d.ts.map +1 -1
- package/dist/runtime/python-repl.js +82 -59
- package/dist/runtime/repl-session.d.ts +9 -47
- package/dist/runtime/repl-session.d.ts.map +1 -1
- package/dist/runtime/repl-session.js +105 -105
- package/dist/runtime/runtime-catalog.d.ts +13 -0
- package/dist/runtime/runtime-catalog.d.ts.map +1 -1
- package/dist/runtime/runtime-catalog.js +88 -0
- package/dist/session/agent.d.ts +1 -21
- package/dist/session/agent.d.ts.map +1 -1
- package/dist/session/ai.d.ts +5 -1
- package/dist/session/ai.d.ts.map +1 -1
- package/dist/session/ai.js +7 -0
- package/dist/session/hibernation.d.ts +2 -1
- package/dist/session/hibernation.d.ts.map +1 -1
- package/dist/session/hibernation.js +7 -4
- package/dist/session/init.d.ts +1 -36
- package/dist/session/init.d.ts.map +1 -1
- package/dist/session/init.js +17 -1773
- package/dist/session/loopback.d.ts +2 -29
- package/dist/session/loopback.d.ts.map +1 -1
- package/dist/session/loopback.js +3 -27
- package/dist/session/nimbus-session.d.ts +22 -13
- package/dist/session/nimbus-session.d.ts.map +1 -1
- package/dist/session/nimbus-session.js +67 -484
- package/dist/session/npm-install-port.d.ts +3 -1
- package/dist/session/npm-install-port.d.ts.map +1 -1
- package/dist/session/programmatic.d.ts +5 -38
- package/dist/session/programmatic.d.ts.map +1 -1
- package/dist/session/programmatic.js +16 -48
- package/dist/session/rpc.d.ts.map +1 -1
- package/dist/session/rpc.js +1 -2
- package/dist/session/supervisor-op.d.ts +2 -2
- package/dist/session/supervisor-op.d.ts.map +1 -1
- package/dist/session/supervisor-op.js +11 -3
- package/dist/workspace-host.d.ts +6 -0
- package/dist/workspace-host.d.ts.map +1 -0
- package/dist/workspace-host.js +5 -0
- package/dist/workspace.d.ts +2 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +1 -0
- package/package.json +16 -11
|
@@ -818,15 +818,15 @@ let __ntC = 0, __qmC = 0;
|
|
|
818
818
|
let __fetchC = 0;
|
|
819
819
|
// WebAssembly.Memory.grow probe: total grows / pages, last grower's stack.
|
|
820
820
|
let __wgC = 0, __wgP = 0, __wgLast = "";
|
|
821
|
-
const __queueRpcWrite = (method,
|
|
821
|
+
const __queueRpcWrite = (method, bytes) => {
|
|
822
822
|
if (!__supervisor) return;
|
|
823
|
-
__rpcQc += 1; __rpcQb +=
|
|
823
|
+
__rpcQc += 1; __rpcQb += bytes.byteLength;
|
|
824
824
|
const __task = __rpcWriteChain
|
|
825
|
-
.then(() => __supervisor[method](
|
|
825
|
+
.then(() => __supervisor[method](bytes))
|
|
826
826
|
.catch(() => {});
|
|
827
827
|
__rpcWriteChain = __task.then(() => {}, () => {});
|
|
828
828
|
__pendingWrites.add(__task);
|
|
829
|
-
const __len =
|
|
829
|
+
const __len = bytes.byteLength;
|
|
830
830
|
__task.finally(() => { __rpcSc += 1; __rpcSb += __len; __chainSettleAt = Date.now(); __pendingWrites.delete(__task); });
|
|
831
831
|
__ocFlowDiag();
|
|
832
832
|
};
|
|
@@ -860,30 +860,30 @@ if (__ocResident) {
|
|
|
860
860
|
// stream would grow without bound over a resident process's lifetime.
|
|
861
861
|
process.stdout.write = (d, enc, cb) => {
|
|
862
862
|
if (typeof enc === "function") cb = enc;
|
|
863
|
-
const
|
|
864
|
-
stdout = __ocTail(stdout,
|
|
865
|
-
__queueRpcWrite("stdout",
|
|
863
|
+
const b = __nimbusOutBytes(d, enc);
|
|
864
|
+
stdout = __ocTail(stdout, __nimbusOutText("stdout", b));
|
|
865
|
+
__queueRpcWrite("stdout", b);
|
|
866
866
|
if (typeof cb === "function") queueMicrotask(cb);
|
|
867
867
|
return true;
|
|
868
868
|
};
|
|
869
869
|
process.stderr.write = (d, enc, cb) => {
|
|
870
870
|
if (typeof enc === "function") cb = enc;
|
|
871
|
-
const
|
|
872
|
-
stderr = __ocTail(stderr,
|
|
873
|
-
__queueRpcWrite("stderr",
|
|
871
|
+
const b = __nimbusOutBytes(d, enc);
|
|
872
|
+
stderr = __ocTail(stderr, __nimbusOutText("stderr", b));
|
|
873
|
+
__queueRpcWrite("stderr", b);
|
|
874
874
|
if (typeof cb === "function") queueMicrotask(cb);
|
|
875
875
|
return true;
|
|
876
876
|
};
|
|
877
877
|
} else {
|
|
878
878
|
process.stdout.write = (d, enc, cb) => {
|
|
879
879
|
if (typeof enc === "function") cb = enc;
|
|
880
|
-
stdout +=
|
|
880
|
+
stdout += __nimbusOutText("stdout", __nimbusOutBytes(d, enc));
|
|
881
881
|
if (typeof cb === "function") queueMicrotask(cb);
|
|
882
882
|
return true;
|
|
883
883
|
};
|
|
884
884
|
process.stderr.write = (d, enc, cb) => {
|
|
885
885
|
if (typeof enc === "function") cb = enc;
|
|
886
|
-
stderr +=
|
|
886
|
+
stderr += __nimbusOutText("stderr", __nimbusOutBytes(d, enc));
|
|
887
887
|
if (typeof cb === "function") queueMicrotask(cb);
|
|
888
888
|
return true;
|
|
889
889
|
};
|
|
@@ -898,8 +898,8 @@ const __ocFmt = (...a) => a.map((x) => {
|
|
|
898
898
|
// event loop — the only channel that still reports from a CPU-bound spin.
|
|
899
899
|
const __realConsoleError = console.error.bind(console);
|
|
900
900
|
if (__ocResident) {
|
|
901
|
-
console.log = (...a) => { const s = __ocFmt(...a) + "\\n"; stdout = __ocTail(stdout, s); __queueRpcWrite("stdout", s); };
|
|
902
|
-
console.error = (...a) => { const s = __ocFmt(...a) + "\\n"; stderr = __ocTail(stderr, s); __queueRpcWrite("stderr", s); };
|
|
901
|
+
console.log = (...a) => { const s = __ocFmt(...a) + "\\n"; stdout = __ocTail(stdout, s); __queueRpcWrite("stdout", __nimbusOutEnc.encode(s)); };
|
|
902
|
+
console.error = (...a) => { const s = __ocFmt(...a) + "\\n"; stderr = __ocTail(stderr, s); __queueRpcWrite("stderr", __nimbusOutEnc.encode(s)); };
|
|
903
903
|
} else {
|
|
904
904
|
console.log = (...a) => { stdout += __ocFmt(...a) + "\\n"; };
|
|
905
905
|
console.error = (...a) => { stderr += __ocFmt(...a) + "\\n"; };
|
|
@@ -1,152 +1,65 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* package-manager.ts —
|
|
2
|
+
* package-manager.ts — the Worker's edge of runtime installation.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* The policy moved: installs, singleflight, bin registration and the `nimbus`
|
|
5
|
+
* verb itself live in `@nimbus-sh/core` (`runtime/runtime-manager.ts`,
|
|
6
|
+
* `runtime/nimbus-command.ts`) because a library workspace owns them too.
|
|
7
|
+
* What remains here is what only a Cloudflare host can answer:
|
|
5
8
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* nimbus install --reinstall <name> force refetch
|
|
11
|
-
* nimbus uninstall <name> remove installed runtime
|
|
12
|
-
*
|
|
13
|
-
* Per-user VFS layout:
|
|
14
|
-
*
|
|
15
|
-
* ~/.nimbus/runtimes/<name>/<version>/
|
|
16
|
-
* manifest.json
|
|
17
|
-
* bin/<entry>
|
|
18
|
-
* share/<name>/...
|
|
19
|
-
* LICENSE
|
|
20
|
-
*
|
|
21
|
-
* Survives DO eviction (SqliteFS-backed). Boot-time rehydration reads
|
|
22
|
-
* every `~/.nimbus/runtimes/STAR/STAR/manifest.json` and re-registers
|
|
23
|
-
* each `entrypoints[].binName` as a shell command pointing at the
|
|
24
|
-
* named runner factory.
|
|
25
|
-
*
|
|
26
|
-
* Errors throw and bubble up to the user as a single diagnostic line.
|
|
9
|
+
* - `runtimeCatalogSource(env)` — the R2-backed RuntimeSource (the digest
|
|
10
|
+
* chain stays in runtime-catalog.ts beside this file's fetchers);
|
|
11
|
+
* - the programmatic entry points the SDK surface calls;
|
|
12
|
+
* - the command-not-found hint resolver init.ts wires into exec dispatch.
|
|
27
13
|
*/
|
|
28
|
-
import { type RuntimeCatalogEnv } from './runtime-catalog.js';
|
|
29
|
-
import {
|
|
30
|
-
import type {
|
|
31
|
-
import {
|
|
32
|
-
import { type
|
|
33
|
-
import type {
|
|
34
|
-
|
|
35
|
-
export
|
|
36
|
-
args: string[];
|
|
37
|
-
env: Record<string, string>;
|
|
38
|
-
cwd: string;
|
|
39
|
-
stdout: {
|
|
40
|
-
write(s: string): void;
|
|
41
|
-
};
|
|
42
|
-
stderr: {
|
|
43
|
-
write(s: string): void;
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
export interface RuntimeWarmTarget {
|
|
47
|
-
name: string;
|
|
48
|
-
version: string;
|
|
49
|
-
root: string;
|
|
50
|
-
manifest: RuntimeManifest;
|
|
51
|
-
}
|
|
52
|
-
export type RuntimeWarmHook = (target: RuntimeWarmTarget, ctx: ShellCtx) => Promise<void>;
|
|
14
|
+
import { runtimeCatalogSource, type RuntimeCatalogEnv } from './runtime-catalog.js';
|
|
15
|
+
import type { CredentialedVfs } from '@nimbus-sh/core/vfs/sqlite-vfs.js';
|
|
16
|
+
import type { RuntimeManager } from '@nimbus-sh/core/runtime/runtime-manager.js';
|
|
17
|
+
import type { RuntimeAvailability } from '@nimbus-sh/core/runtime/runtime-package.js';
|
|
18
|
+
import { type RuntimeWarmHook } from '@nimbus-sh/core/runtime/nimbus-command.js';
|
|
19
|
+
import type { MinShellRegistry } from '@nimbus-sh/core/runtime/installed-runtimes.js';
|
|
20
|
+
export { runtimeCatalogSource };
|
|
21
|
+
export type { RuntimeWarmHook };
|
|
53
22
|
export interface RuntimeInstallSummary {
|
|
54
23
|
spec: string;
|
|
55
24
|
exitCode: number;
|
|
56
25
|
stdout: string;
|
|
57
26
|
stderr: string;
|
|
58
27
|
}
|
|
59
|
-
export interface RuntimeInstallTarget {
|
|
60
|
-
runtimeName: string;
|
|
61
|
-
versionOverride: string | null;
|
|
62
|
-
requestedName: string;
|
|
63
|
-
}
|
|
64
28
|
export interface RuntimeCommandHint {
|
|
65
29
|
command: string;
|
|
66
30
|
runtimeName: string;
|
|
67
31
|
installSpec: string;
|
|
68
32
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
version: string;
|
|
76
|
-
sizeBytes: number;
|
|
77
|
-
license: string;
|
|
78
|
-
}>;
|
|
79
|
-
}>>;
|
|
33
|
+
/**
|
|
34
|
+
* `nimbus install` without a shell: the same `runNimbusInstall` path the verb
|
|
35
|
+
* runs, with output captured instead of written to a terminal. Deps take the
|
|
36
|
+
* workspace's RuntimeManager — which already holds the source, the registry
|
|
37
|
+
* and the runner factories — rather than a catalog env.
|
|
38
|
+
*/
|
|
80
39
|
export declare function installRuntimeProgrammatic(deps: {
|
|
81
|
-
|
|
82
|
-
vfs: SqliteVFS;
|
|
40
|
+
runtimes: RuntimeManager;
|
|
83
41
|
registry: MinShellRegistry;
|
|
42
|
+
vfs: CredentialedVfs;
|
|
84
43
|
getHome(): string;
|
|
44
|
+
warmRuntime?: RuntimeWarmHook;
|
|
85
45
|
}, spec: string, opts?: {
|
|
86
46
|
force?: boolean;
|
|
87
47
|
}): Promise<RuntimeInstallSummary>;
|
|
88
48
|
export declare function ensureRuntimesProgrammatic(deps: {
|
|
89
|
-
|
|
90
|
-
vfs: SqliteVFS;
|
|
49
|
+
runtimes: RuntimeManager;
|
|
91
50
|
registry: MinShellRegistry;
|
|
51
|
+
vfs: CredentialedVfs;
|
|
92
52
|
getHome(): string;
|
|
53
|
+
warmRuntime?: RuntimeWarmHook;
|
|
93
54
|
}, specs: string[], opts?: {
|
|
94
55
|
force?: boolean;
|
|
95
56
|
}): Promise<RuntimeInstallSummary[]>;
|
|
57
|
+
export declare function listAvailableRuntimes(env: RuntimeCatalogEnv): Promise<RuntimeAvailability[]>;
|
|
96
58
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
|
|
101
|
-
export interface NimbusAppVerbs {
|
|
102
|
-
expose(target: number | string, options: {
|
|
103
|
-
visibility?: 'scoped' | 'public';
|
|
104
|
-
name?: string;
|
|
105
|
-
}): Promise<{
|
|
106
|
-
owner: string;
|
|
107
|
-
name: string | null;
|
|
108
|
-
port: number;
|
|
109
|
-
capability: string | null;
|
|
110
|
-
visibility: 'scoped' | 'public';
|
|
111
|
-
url: string | null;
|
|
112
|
-
}>;
|
|
113
|
-
list(): Promise<Array<{
|
|
114
|
-
owner: string;
|
|
115
|
-
name: string | null;
|
|
116
|
-
port: number | null;
|
|
117
|
-
pid: number | null;
|
|
118
|
-
status: string;
|
|
119
|
-
visibility: string;
|
|
120
|
-
restart: string;
|
|
121
|
-
diagnostic: string | null;
|
|
122
|
-
url: string | null;
|
|
123
|
-
}>>;
|
|
124
|
-
rotateLink(target: number | string): Promise<{
|
|
125
|
-
name: string | null;
|
|
126
|
-
port: number;
|
|
127
|
-
url: string | null;
|
|
128
|
-
capability: string | null;
|
|
129
|
-
}>;
|
|
130
|
-
remove(target: number | string): Promise<{
|
|
131
|
-
owner: string;
|
|
132
|
-
removed: boolean;
|
|
133
|
-
port: number | null;
|
|
134
|
-
}>;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Build the shell-command handler that implements `nimbus install …`,
|
|
138
|
-
* `nimbus uninstall …`, `nimbus expose …`, `nimbus app …` and
|
|
139
|
-
* `nimbus start …`. Registered under the name `nimbus`.
|
|
59
|
+
* Command-not-found hints, catalog-driven: a bare name the shell could not
|
|
60
|
+
* resolve is answered with the runtime that provides it, so `python3` hints
|
|
61
|
+
* at cpython and `wasm-ld` at clang. Loaded once and memoized; a fetch
|
|
62
|
+
* failure drops the memo so the next unknown command retries.
|
|
140
63
|
*/
|
|
141
|
-
export declare function
|
|
142
|
-
env: RuntimeCatalogEnv;
|
|
143
|
-
vfs: SqliteVFS;
|
|
144
|
-
registry: MinShellRegistry;
|
|
145
|
-
/** Returns `process.env.HOME` for the session. Computed by the
|
|
146
|
-
* caller (init.ts) from the shell env. */
|
|
147
|
-
getHome(): string;
|
|
148
|
-
warmRuntime?: RuntimeWarmHook;
|
|
149
|
-
/** The application verbs; absent on a host with no session (tests). */
|
|
150
|
-
apps?: NimbusAppVerbs;
|
|
151
|
-
}): (ctx: any) => Promise<number>;
|
|
64
|
+
export declare function createRuntimeCommandHintResolver(env: RuntimeCatalogEnv): (command: string) => Promise<RuntimeCommandHint | null>;
|
|
152
65
|
//# sourceMappingURL=package-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-manager.d.ts","sourceRoot":"","sources":["../../src/runtime/package-manager.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"package-manager.d.ts","sourceRoot":"","sources":["../../src/runtime/package-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAGL,oBAAoB,EACpB,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAEzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AACjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AACtF,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AAEtF,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAChC,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAAC,IAAI,EAAE;IACrD,QAAQ,EAAE,cAAc,CAAC;IACzB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,GAAG,EAAE,eAAe,CAAC;IACrB,OAAO,IAAI,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,OAAO,CAAC,qBAAqB,CAAC,CA6B/E;AAED,wBAAsB,0BAA0B,CAAC,IAAI,EAAE;IACrD,QAAQ,EAAE,cAAc,CAAC;IACzB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,GAAG,EAAE,eAAe,CAAC;IACrB,OAAO,IAAI,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAMpF;AAED,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAElG;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,iBAAiB,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAyChI"}
|