@dbx-tools/appkit-lakebox 0.0.0-stage → 0.9.131
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/LICENSE +202 -0
- package/README.md +104 -2
- package/index.ts +32 -0
- package/lib/index.d.ts +28 -0
- package/lib/index.js +26 -0
- package/lib/src/_package.d.ts +2 -0
- package/lib/src/_package.js +11 -0
- package/lib/src/_resource-registry.d.ts +41 -0
- package/lib/src/_resource-registry.js +128 -0
- package/lib/src/_service-snapshots.d.ts +55 -0
- package/lib/src/_service-snapshots.js +65 -0
- package/lib/src/config.d.ts +40 -0
- package/lib/src/config.js +86 -0
- package/lib/src/desktop.d.ts +6 -0
- package/lib/src/desktop.js +88 -0
- package/lib/src/metrics.d.ts +59 -0
- package/lib/src/metrics.js +151 -0
- package/lib/src/plugin.d.ts +259 -0
- package/lib/src/plugin.js +329 -0
- package/lib/src/routes.d.ts +75 -0
- package/lib/src/routes.js +441 -0
- package/lib/src/runtime.d.ts +154 -0
- package/lib/src/runtime.js +760 -0
- package/lib/src/services.d.ts +101 -0
- package/lib/src/services.js +188 -0
- package/lib/src/skills.d.ts +5 -0
- package/lib/src/skills.js +21 -0
- package/lib/src/user.d.ts +46 -0
- package/lib/src/user.js +76 -0
- package/lib/src/workspace.d.ts +43 -0
- package/lib/src/workspace.js +138 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/package.json +167 -4
- package/scripts/desktop-prerequisites.sh +66 -0
- package/scripts/desktop-session.sh +307 -0
- package/scripts/lakebox-admin.sh +234 -0
- package/scripts/lakebox-service.py +449 -0
- package/skills/html-page/SKILL.md +40 -0
- package/skills/jupyter-lab/SKILL.md +32 -0
- package/skills/lakebox-showcase/SKILL.md +66 -0
- package/skills/network-speed-test/SKILL.md +29 -0
- package/skills/realtime-whiteboard/SKILL.md +28 -0
- package/src/_package.ts +11 -0
- package/src/_resource-registry.ts +160 -0
- package/src/_service-snapshots.ts +84 -0
- package/src/config.ts +128 -0
- package/src/desktop.ts +97 -0
- package/src/metrics.ts +178 -0
- package/src/plugin.ts +446 -0
- package/src/routes.ts +524 -0
- package/src/runtime.ts +952 -0
- package/src/services.ts +239 -0
- package/src/skills.ts +23 -0
- package/src/user.ts +88 -0
- package/src/workspace.ts +185 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type { IncomingHttpHeaders } from "node:http";
|
|
2
|
+
import { type LakeboxAuth } from "@dbx-tools/lakebox/rest";
|
|
3
|
+
import { SshCommand } from "@dbx-tools/lakebox/session";
|
|
4
|
+
import { type CreateLakeboxServiceRequest, type LakeboxCommandRequest, type LakeboxMetricsResponse, type LakeboxMetricsSnapshot, type LakeboxService, type LakeboxServiceLogsRequest, type LakeboxSummary, type LakeboxUser } from "@dbx-tools/shared-lakebox";
|
|
5
|
+
import { LakeboxResourceRegistry } from "./_resource-registry.ts";
|
|
6
|
+
import { LakeboxServiceSnapshots } from "./_service-snapshots.ts";
|
|
7
|
+
import type { ResolvedLakeboxPluginConfig } from "./config.ts";
|
|
8
|
+
import { LakeboxMetrics } from "./metrics.ts";
|
|
9
|
+
import { LakeboxRouteRegistry } from "./routes.ts";
|
|
10
|
+
/** Resolves the authenticated identity for raw request headers. */
|
|
11
|
+
export type LakeboxIdentityResolver = (headers: IncomingHttpHeaders) => string | undefined;
|
|
12
|
+
/** Minimal Lakebase pool used to drop legacy ownership schemas. */
|
|
13
|
+
export interface LakeboxLegacyPool {
|
|
14
|
+
query(sql: string, values?: unknown[]): Promise<{
|
|
15
|
+
rows: Array<Record<string, unknown>>;
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Owns the single lazily created Lakebox of one application.
|
|
20
|
+
*
|
|
21
|
+
* Every Databricks Lakebox REST call uses the app service principal supplied
|
|
22
|
+
* through {@link initialize}; request identity only selects the internal Linux
|
|
23
|
+
* account. Each authenticated identity maps through one FNV-1a hash to a locked
|
|
24
|
+
* account, persistent home, route segment, and service ports. Lifecycle and
|
|
25
|
+
* per-boot bootstrap are serialized in-process; the persistent resource
|
|
26
|
+
* registry serializes first creation across replicas.
|
|
27
|
+
*/
|
|
28
|
+
export declare class LakeboxRuntime {
|
|
29
|
+
readonly config: ResolvedLakeboxPluginConfig;
|
|
30
|
+
readonly routes: LakeboxRouteRegistry;
|
|
31
|
+
readonly metrics: LakeboxMetrics;
|
|
32
|
+
private readonly keys;
|
|
33
|
+
private readonly stopParentTerminationSignal;
|
|
34
|
+
private readonly shutdownController;
|
|
35
|
+
private api?;
|
|
36
|
+
private identity;
|
|
37
|
+
/** In-memory identities of routed users; never persisted. */
|
|
38
|
+
private readonly routedIdentities;
|
|
39
|
+
private cached?;
|
|
40
|
+
private boot?;
|
|
41
|
+
/** Last boot that completed runtime bootstrap and produced a metrics sample. */
|
|
42
|
+
private readyBootKey?;
|
|
43
|
+
private converging?;
|
|
44
|
+
private waking?;
|
|
45
|
+
private metricsLease?;
|
|
46
|
+
private idleTimer?;
|
|
47
|
+
private lastActivity;
|
|
48
|
+
private activeCommands;
|
|
49
|
+
/** Last service states per user hash, kept after an idle session release. */
|
|
50
|
+
private readonly lastServices;
|
|
51
|
+
private readonly lastServicesObservedAt;
|
|
52
|
+
private resourceRegistry?;
|
|
53
|
+
private serviceSnapshots?;
|
|
54
|
+
private closing?;
|
|
55
|
+
/** Creates a runtime from resolved plugin configuration. */
|
|
56
|
+
constructor(config: ResolvedLakeboxPluginConfig);
|
|
57
|
+
/**
|
|
58
|
+
* Supplies app service-principal credentials and the request identity
|
|
59
|
+
* resolver used by routes.
|
|
60
|
+
*/
|
|
61
|
+
initialize(auth: LakeboxAuth, identity?: LakeboxIdentityResolver, serviceSnapshots?: LakeboxServiceSnapshots, resourceRegistry?: LakeboxResourceRegistry): void;
|
|
62
|
+
/** Derives the Lakebox account for one authenticated identity. */
|
|
63
|
+
user(identity: string): LakeboxUser;
|
|
64
|
+
/** Summarizes the app Lakebox for one user without creating it. */
|
|
65
|
+
summary(identity: string, signal?: AbortSignal): Promise<LakeboxSummary>;
|
|
66
|
+
/** Creates the Lakebox when needed, starts it, and restores saved services. */
|
|
67
|
+
start(signal?: AbortSignal): Promise<void>;
|
|
68
|
+
/** Stops the shared Lakebox for every user. Files and saved services persist. */
|
|
69
|
+
stop(signal?: AbortSignal): Promise<void>;
|
|
70
|
+
/** Permanently deletes the managed Lakebox and every user's files. */
|
|
71
|
+
delete(signal?: AbortSignal): Promise<boolean>;
|
|
72
|
+
/**
|
|
73
|
+
* Runs one command as the user's account, creating or starting the Lakebox
|
|
74
|
+
* when `auto` is enabled.
|
|
75
|
+
*/
|
|
76
|
+
execute(identity: string, input: LakeboxCommandRequest, signal?: AbortSignal): SshCommand;
|
|
77
|
+
/** Lists the user's services, including idle built-ins. Never creates the Lakebox. */
|
|
78
|
+
listServices(identity: string, signal?: AbortSignal): Promise<LakeboxService[]>;
|
|
79
|
+
/** Creates or replaces one image service and waits until it is ready or failed. */
|
|
80
|
+
createService(identity: string, input: CreateLakeboxServiceRequest, signal?: AbortSignal): Promise<LakeboxService>;
|
|
81
|
+
/** Starts a saved service or a built-in and waits until it is ready or failed. */
|
|
82
|
+
startService(identity: string, name: string, signal?: AbortSignal): Promise<LakeboxService>;
|
|
83
|
+
/** Stops one running service without removing its definition. */
|
|
84
|
+
stopService(identity: string, name: string, signal?: AbortSignal): Promise<LakeboxService>;
|
|
85
|
+
/** Stops and deletes one saved service. Mounted home directories are preserved. */
|
|
86
|
+
removeService(identity: string, name: string, signal?: AbortSignal): Promise<boolean>;
|
|
87
|
+
/** Reads a bounded tail of one service log. */
|
|
88
|
+
serviceLogs(identity: string, input: LakeboxServiceLogsRequest, signal?: AbortSignal): Promise<{
|
|
89
|
+
log: string;
|
|
90
|
+
}>;
|
|
91
|
+
/**
|
|
92
|
+
* Returns recent metrics and keeps sampling for one lease interval. Sampling
|
|
93
|
+
* runs only while the Lakebox runs and a caller is watching, so metrics never
|
|
94
|
+
* keep an otherwise idle Lakebox awake.
|
|
95
|
+
*/
|
|
96
|
+
metricsResponse(signal?: AbortSignal): Promise<LakeboxMetricsResponse>;
|
|
97
|
+
/** Subscribes to metrics snapshots while the Lakebox runs. */
|
|
98
|
+
subscribeMetrics(listener: (snapshot: LakeboxMetricsSnapshot) => void): () => void;
|
|
99
|
+
/**
|
|
100
|
+
* Deletes legacy per-user Lakeboxes and drops legacy ownership schemas.
|
|
101
|
+
*
|
|
102
|
+
* There is no migration: the earlier one-machine-per-user model is removed.
|
|
103
|
+
* The managed app Lakebox and Lakeboxes with other names are never touched.
|
|
104
|
+
*/
|
|
105
|
+
cleanupLegacy(pool?: LakeboxLegacyPool, signal?: AbortSignal): Promise<void>;
|
|
106
|
+
/** Cancels in-flight work before teardown. */
|
|
107
|
+
abortActiveOperations(): void;
|
|
108
|
+
/** Closes routes, metrics, and the SSH session without changing the Lakebox. */
|
|
109
|
+
close(): Promise<void>;
|
|
110
|
+
private client;
|
|
111
|
+
private resources;
|
|
112
|
+
/** Returns the managed Lakebox entry, cached briefly to keep routes cheap. */
|
|
113
|
+
private entry;
|
|
114
|
+
private bootKey;
|
|
115
|
+
private productStatus;
|
|
116
|
+
/** Serializes create, start, connect, and bootstrap for the current boot. */
|
|
117
|
+
private ready;
|
|
118
|
+
private converge;
|
|
119
|
+
private connect;
|
|
120
|
+
/** Runs the fixed privileged bootstrap and returns the restored user hashes. */
|
|
121
|
+
private bootstrap;
|
|
122
|
+
private admin;
|
|
123
|
+
/** Marks activity, readies the current boot, and converges the user's account. */
|
|
124
|
+
private readyUser;
|
|
125
|
+
/** Creates or verifies the user's account once per boot. */
|
|
126
|
+
private convergeUser;
|
|
127
|
+
private restoreUser;
|
|
128
|
+
private controller;
|
|
129
|
+
private runService;
|
|
130
|
+
private refreshServices;
|
|
131
|
+
private cacheService;
|
|
132
|
+
private serviceListing;
|
|
133
|
+
private persistServiceSnapshot;
|
|
134
|
+
private withBuiltIns;
|
|
135
|
+
private idleServices;
|
|
136
|
+
/** Resolves one routed request, waking the Lakebox or service in the background. */
|
|
137
|
+
private resolveRoute;
|
|
138
|
+
private markUnavailable;
|
|
139
|
+
private wake;
|
|
140
|
+
private readMetrics;
|
|
141
|
+
private leaseMetrics;
|
|
142
|
+
/**
|
|
143
|
+
* Releases the SSH session after the idle timeout without commands, service
|
|
144
|
+
* operations, routed traffic, open streams, or metrics watchers. An open
|
|
145
|
+
* session counts as activity for the platform watchdog, so releasing it lets
|
|
146
|
+
* the platform stop the Lakebox after its own idle timeout. The next request
|
|
147
|
+
* reconnects.
|
|
148
|
+
*/
|
|
149
|
+
private watchIdle;
|
|
150
|
+
private touch;
|
|
151
|
+
private discardBoot;
|
|
152
|
+
}
|
|
153
|
+
/** Returns whether an error means the managed Lakebox no longer exists. */
|
|
154
|
+
export declare function isLakeboxMissing(error: unknown): boolean;
|