@dbx-tools/appkit-lakebox 0.0.0-stage → 0.9.132

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 (55) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +197 -2
  3. package/index.ts +32 -0
  4. package/lib/index.d.ts +28 -0
  5. package/lib/index.js +26 -0
  6. package/lib/src/_package.d.ts +2 -0
  7. package/lib/src/_package.js +11 -0
  8. package/lib/src/_resource-registry.d.ts +41 -0
  9. package/lib/src/_resource-registry.js +128 -0
  10. package/lib/src/_service-snapshots.d.ts +55 -0
  11. package/lib/src/_service-snapshots.js +65 -0
  12. package/lib/src/config.d.ts +40 -0
  13. package/lib/src/config.js +86 -0
  14. package/lib/src/desktop.d.ts +6 -0
  15. package/lib/src/desktop.js +88 -0
  16. package/lib/src/metrics.d.ts +59 -0
  17. package/lib/src/metrics.js +151 -0
  18. package/lib/src/plugin.d.ts +259 -0
  19. package/lib/src/plugin.js +329 -0
  20. package/lib/src/routes.d.ts +75 -0
  21. package/lib/src/routes.js +441 -0
  22. package/lib/src/runtime.d.ts +154 -0
  23. package/lib/src/runtime.js +760 -0
  24. package/lib/src/services.d.ts +101 -0
  25. package/lib/src/services.js +188 -0
  26. package/lib/src/skills.d.ts +5 -0
  27. package/lib/src/skills.js +21 -0
  28. package/lib/src/user.d.ts +46 -0
  29. package/lib/src/user.js +76 -0
  30. package/lib/src/workspace.d.ts +43 -0
  31. package/lib/src/workspace.js +138 -0
  32. package/lib/tsconfig.tsbuildinfo +1 -0
  33. package/package.json +167 -4
  34. package/scripts/desktop-prerequisites.sh +66 -0
  35. package/scripts/desktop-session.sh +307 -0
  36. package/scripts/lakebox-admin.sh +234 -0
  37. package/scripts/lakebox-service.py +449 -0
  38. package/skills/html-page/SKILL.md +40 -0
  39. package/skills/jupyter-lab/SKILL.md +32 -0
  40. package/skills/lakebox-showcase/SKILL.md +66 -0
  41. package/skills/network-speed-test/SKILL.md +29 -0
  42. package/skills/realtime-whiteboard/SKILL.md +28 -0
  43. package/src/_package.ts +11 -0
  44. package/src/_resource-registry.ts +160 -0
  45. package/src/_service-snapshots.ts +84 -0
  46. package/src/config.ts +128 -0
  47. package/src/desktop.ts +97 -0
  48. package/src/metrics.ts +178 -0
  49. package/src/plugin.ts +446 -0
  50. package/src/routes.ts +524 -0
  51. package/src/runtime.ts +952 -0
  52. package/src/services.ts +239 -0
  53. package/src/skills.ts +23 -0
  54. package/src/user.ts +88 -0
  55. package/src/workspace.ts +185 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,198 @@
1
- # Temporary Holding Version
1
+ # @dbx-tools/appkit-lakebox
2
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.
3
+ Give each authenticated Databricks App user a persistent Linux home, terminal,
4
+ desktop, OCI image services, agent tools, and machine metrics in one shared
5
+ Databricks Lakebox.
6
+
7
+ ## Register the plugin
8
+
9
+ ```ts
10
+ import { createApp, lakebase, server } from "@databricks/appkit";
11
+ import { lakebox, LakeboxRuntime } from "@dbx-tools/appkit-lakebox";
12
+ import { resolveLakeboxPluginConfig } from "@dbx-tools/appkit-lakebox/config";
13
+
14
+ const runtime = new LakeboxRuntime(resolveLakeboxPluginConfig({ idleTimeoutSeconds: 1_800 }));
15
+
16
+ await createApp({
17
+ plugins: [server(), lakebase(), lakebox({ runtime })],
18
+ });
19
+ ```
20
+
21
+ Lakebase persists the Databricks-assigned Lakebox ID, serializes first creation
22
+ across app replicas, and retains the last observed service definitions while
23
+ the machine is stopped. Register AppKit's `lakebase()` plugin before users
24
+ access Lakebox routes.
25
+
26
+ ## Connect Mastra to the same runtime
27
+
28
+ Pass the same `LakeboxRuntime` to the AppKit plugin and Mastra sandbox. This
29
+ keeps commands, services, routes, metrics, and user accounts on the same
30
+ Lakebox:
31
+
32
+ ```ts
33
+ import { createApp, lakebase, server } from "@databricks/appkit";
34
+ import { lakebox, LakeboxRuntime } from "@dbx-tools/appkit-lakebox";
35
+ import { resolveLakeboxPluginConfig } from "@dbx-tools/appkit-lakebox/config";
36
+ import { lakeboxSkillMounts } from "@dbx-tools/appkit-lakebox/skills";
37
+ import { lakeboxWorkspaceSandbox } from "@dbx-tools/appkit-lakebox/workspace";
38
+ import { agents, mastra } from "@dbx-tools/appkit-mastra";
39
+
40
+ const runtime = new LakeboxRuntime(resolveLakeboxPluginConfig());
41
+ const analyst = agents.createAgent({
42
+ name: "Analyst",
43
+ instructions: "Use the workspace when the task requires files or commands.",
44
+ });
45
+
46
+ await createApp({
47
+ plugins: [
48
+ server(),
49
+ lakebase(),
50
+ lakebox({ runtime }),
51
+ mastra({
52
+ agents: { analyst },
53
+ sandbox: lakeboxWorkspaceSandbox(runtime),
54
+ localSkillMounts: lakeboxSkillMounts(),
55
+ }),
56
+ ],
57
+ });
58
+ ```
59
+
60
+ The sandbox resolves the authenticated Mastra user for each request. It doesn't
61
+ create compute during agent registration. The first command or service starts
62
+ the Lakebox when `auto` is enabled.
63
+
64
+ ## Render the Lakebox UI
65
+
66
+ Register the backend plugin, then render the React package in the same
67
+ application:
68
+
69
+ ```tsx
70
+ import { LakeboxIndicator, LakeboxPanel } from "@dbx-tools/ui-lakebox/react";
71
+
72
+ export function LakeboxPage() {
73
+ return (
74
+ <>
75
+ <LakeboxIndicator />
76
+ <LakeboxPanel />
77
+ </>
78
+ );
79
+ }
80
+ ```
81
+
82
+ Import the package stylesheet after your AppKit UI theme:
83
+
84
+ ```css
85
+ @import "@dbx-tools/ui-lakebox/styles.css";
86
+ ```
87
+
88
+ The components read the API base path from the plugin's published client
89
+ configuration. You don't need to copy route strings or pass Databricks
90
+ credentials to the browser.
91
+
92
+ ## Create a service
93
+
94
+ Agents call `create_lakebox_service`. REST clients send
95
+ `POST /api/lakebox/services`:
96
+
97
+ ```json
98
+ {
99
+ "name": "hello",
100
+ "image": "docker.io/library/python:3.12-alpine",
101
+ "command": ["sh", "-lc", "python -m http.server \"$SERVICE_PORT\" --bind 127.0.0.1"],
102
+ "mounts": [{ "source": "data", "target": "/data" }]
103
+ }
104
+ ```
105
+
106
+ The call returns after the service listens. The runtime injects
107
+ `SERVICE_NAME`, `SERVICE_PATH`, `SERVICE_PORT`, and `PORT`. Routed services
108
+ must listen on `127.0.0.1:$SERVICE_PORT`. Mount sources are relative to the
109
+ user's home.
110
+
111
+ This is a constrained container API, not the Docker CLI. There is no daemon,
112
+ port publishing, privileged mode, device access, or bridge network. A Lakebox
113
+ stop and start restarts services from their saved definitions. Process memory
114
+ does not resume.
115
+
116
+ ## Use the agent tools
117
+
118
+ | Tool | Effect |
119
+ | ----------------------------------------------- | -------------------------------------------------------------------------------------- |
120
+ | `get_lakebox` | Returns status, the current user's account, and services without creating the Lakebox. |
121
+ | `execute_lakebox_command` | Run a command as the user's account. |
122
+ | `list_lakebox_services` | List the user's services. |
123
+ | `create_lakebox_service` | Create or replace an image service and wait until ready. |
124
+ | `start_lakebox_service`, `stop_lakebox_service` | Start or stop a saved service, `terminal`, or `desktop`. |
125
+ | `remove_lakebox_service` | Delete a saved service. Requires approval. |
126
+ | `get_lakebox_service_logs` | Read a bounded service log. |
127
+
128
+ The plugin creates or starts the Lakebox for commands and service mutations
129
+ when `auto` is enabled. Listing and status operations don't create it.
130
+
131
+ ## Understand the lifecycle
132
+
133
+ The app service principal owns Lakebox lifecycle calls. An on-behalf-of user
134
+ identity selects that user's Linux account and authorizes routes, but it never
135
+ creates, starts, stops, or deletes the Databricks resource.
136
+
137
+ Lifecycle behavior is:
138
+
139
+ 1. The first explicit start, command, service mutation, or routed request
140
+ creates the app's Lakebox when none exists.
141
+ 2. The runtime starts the Lakebox and restores saved service definitions.
142
+ 3. Each authenticated identity maps to a locked non-sudo account with a
143
+ persistent home and private service ports.
144
+ 4. The Databricks platform stops the Lakebox after the configured idle period.
145
+ 5. A later request starts it again. User files and saved service definitions
146
+ persist, but process memory doesn't.
147
+
148
+ `runtime.stop()` stops the shared Lakebox for every user. `runtime.delete()`
149
+ permanently deletes the Lakebox and every user's files. Normal AppKit shutdown
150
+ closes SSH sessions and forwarding bridges but leaves idle shutdown to the
151
+ platform.
152
+
153
+ ## Configuration
154
+
155
+ | Option | Default | Description |
156
+ | ------------------------ | -------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
157
+ | `application` | `DBX_TOOLS_LAKEBOX_APPLICATION`, `DATABRICKS_APP_NAME`, or the project directory | Stable key for the persisted Lakebox resource ID. |
158
+ | `idleTimeoutSeconds` | `3600` | Platform idle timeout, 60 to 86400 seconds. |
159
+ | `auto` | `true` | Create or start the Lakebox on demand. |
160
+ | `routePrefix` | `/lakebox` | AppKit root for service routes. |
161
+ | `metricsIntervalSeconds` | `5` | Sample interval while a client watches metrics. |
162
+ | `sshTransport` | `auto` | `auto`, `openssh`, or `ssh2`. |
163
+ | `ssh2Patch` | `auto` | Apply the ssh2 missing-exec-reply workaround only in development, always, or never. |
164
+ | `gatewayPort` | `2222` | Lakebox SSH gateway port. |
165
+ | `connectTimeoutMs` | `30000` | SSH connection timeout. |
166
+ | `commandTimeoutMs` | `120000` | Default command timeout. |
167
+ | `keyDirectory` | `~/.dbx-tools/lakebox` | Optional server-side SSH key and known-host storage root. |
168
+
169
+ ## Interactive testing
170
+
171
+ `test/cli.ts` runs the real runtime against a workspace profile as any user:
172
+
173
+ ```bash
174
+ bun packages/js/node/appkit-lakebox/test/cli.ts --profile <profile> --user a@example.com status
175
+ bun packages/js/node/appkit-lakebox/test/cli.ts --profile <profile> --user b@example.com exec id
176
+ bunx tsx packages/js/node/appkit-lakebox/test/cli.ts --profile <profile> --user a@example.com serve
177
+ ```
178
+
179
+ `serve` starts that user's terminal and desktop and proxies their routes on
180
+ [http://127.0.0.1:8787](http://127.0.0.1:8787).
181
+
182
+ Pass a configured profile explicitly. In this harness, the profile identity
183
+ stands in for the app service principal.
184
+
185
+ ## Understand security and runtime limits
186
+
187
+ - Each app has at most one managed Lakebox. Users share the machine but not
188
+ Linux accounts, homes, or service ports.
189
+ - Commands and services don't receive Databricks environment variables,
190
+ forwarded credentials, cookies, or SSH agent access.
191
+ - Service routes fail closed when a non-loopback request has no authenticated
192
+ identity.
193
+ - Image services run with private PID, IPC, mount, and user namespaces. They
194
+ share host networking and must bind only to the injected loopback port.
195
+ - Metrics cover machine CPU, memory, persistent storage, and network counters.
196
+ They don't expose process data and are sampled only while a client watches.
197
+ - Lakebase is required for app resource identity, replica convergence, and
198
+ last-known service definitions.
package/index.ts ADDED
@@ -0,0 +1,32 @@
1
+ // GENERATED by projen watch - DO NOT EDIT.
2
+ // Regenerated from the exporting modules in ./src.
3
+ // Hand edits are overwritten on the next watch; this file is read-only.
4
+
5
+ export const PACKAGE_IDENTIFIER = "@dbx-tools/appkit-lakebox";
6
+ export const PACKAGE_VERSION = "0.9.132";
7
+ export * as config from "./src/config.ts";
8
+ export * as desktop from "./src/desktop.ts";
9
+ export * as metrics from "./src/metrics.ts";
10
+ export * as plugin from "./src/plugin.ts";
11
+ export * as routes from "./src/routes.ts";
12
+ export * as runtime from "./src/runtime.ts";
13
+ export * as services from "./src/services.ts";
14
+ export * as skills from "./src/skills.ts";
15
+ export * as user from "./src/user.ts";
16
+ export * as workspace from "./src/workspace.ts";
17
+ export { LakeboxPluginConfigSchema } from "./src/config.ts";
18
+ export type { SerializableLakeboxPluginConfig, ResolvedLakeboxPluginConfig, LakeboxPluginConfig } from "./src/config.ts";
19
+ export { desktopHtmlHead } from "./src/desktop.ts";
20
+ export { LakeboxMetrics } from "./src/metrics.ts";
21
+ export type { LakeboxCounters, LakeboxMetricsEvents } from "./src/metrics.ts";
22
+ export { AppKitLakeboxPlugin, lakebox } from "./src/plugin.ts";
23
+ export { LakeboxRouteRegistry } from "./src/routes.ts";
24
+ export type { LakeboxRouteResolution, LakeboxRouteResolver } from "./src/routes.ts";
25
+ export { LakeboxRuntime } from "./src/runtime.ts";
26
+ export type { LakeboxIdentityResolver, LakeboxLegacyPool } from "./src/runtime.ts";
27
+ export { LakeboxControllerDefinitionSchema, LakeboxControllerServiceSchema } from "./src/services.ts";
28
+ export type { LakeboxControllerDefinition, LakeboxControllerService, LakeboxServiceRoute } from "./src/services.ts";
29
+ export { LAKEBOX_SKILLS_MOUNT } from "./src/skills.ts";
30
+ export { LAKEBOX_AGENT_USER, LAKEBOX_AGENT_HOME, LAKEBOX_STATE_ROOT, LAKEBOX_USERS_ROOT, LAKEBOX_RUNTIME_ROOT, LAKEBOX_RUN_ROOT, LAKEBOX_UID_MIN, LAKEBOX_UID_COUNT, LAKEBOX_PORT_MIN, LAKEBOX_PORT_COUNT } from "./src/user.ts";
31
+ export { LakeboxWorkspaceSandbox } from "./src/workspace.ts";
32
+ export type { LakeboxWorkspaceSandboxOptions } from "./src/workspace.ts";
package/lib/index.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ export declare const PACKAGE_IDENTIFIER = "@dbx-tools/appkit-lakebox";
2
+ export declare const PACKAGE_VERSION = "0.9.132";
3
+ export * as config from "./src/config.ts";
4
+ export * as desktop from "./src/desktop.ts";
5
+ export * as metrics from "./src/metrics.ts";
6
+ export * as plugin from "./src/plugin.ts";
7
+ export * as routes from "./src/routes.ts";
8
+ export * as runtime from "./src/runtime.ts";
9
+ export * as services from "./src/services.ts";
10
+ export * as skills from "./src/skills.ts";
11
+ export * as user from "./src/user.ts";
12
+ export * as workspace from "./src/workspace.ts";
13
+ export { LakeboxPluginConfigSchema } from "./src/config.ts";
14
+ export type { SerializableLakeboxPluginConfig, ResolvedLakeboxPluginConfig, LakeboxPluginConfig } from "./src/config.ts";
15
+ export { desktopHtmlHead } from "./src/desktop.ts";
16
+ export { LakeboxMetrics } from "./src/metrics.ts";
17
+ export type { LakeboxCounters, LakeboxMetricsEvents } from "./src/metrics.ts";
18
+ export { AppKitLakeboxPlugin, lakebox } from "./src/plugin.ts";
19
+ export { LakeboxRouteRegistry } from "./src/routes.ts";
20
+ export type { LakeboxRouteResolution, LakeboxRouteResolver } from "./src/routes.ts";
21
+ export { LakeboxRuntime } from "./src/runtime.ts";
22
+ export type { LakeboxIdentityResolver, LakeboxLegacyPool } from "./src/runtime.ts";
23
+ export { LakeboxControllerDefinitionSchema, LakeboxControllerServiceSchema } from "./src/services.ts";
24
+ export type { LakeboxControllerDefinition, LakeboxControllerService, LakeboxServiceRoute } from "./src/services.ts";
25
+ export { LAKEBOX_SKILLS_MOUNT } from "./src/skills.ts";
26
+ export { LAKEBOX_AGENT_USER, LAKEBOX_AGENT_HOME, LAKEBOX_STATE_ROOT, LAKEBOX_USERS_ROOT, LAKEBOX_RUNTIME_ROOT, LAKEBOX_RUN_ROOT, LAKEBOX_UID_MIN, LAKEBOX_UID_COUNT, LAKEBOX_PORT_MIN, LAKEBOX_PORT_COUNT } from "./src/user.ts";
27
+ export { LakeboxWorkspaceSandbox } from "./src/workspace.ts";
28
+ export type { LakeboxWorkspaceSandboxOptions } from "./src/workspace.ts";
package/lib/index.js ADDED
@@ -0,0 +1,26 @@
1
+ // GENERATED by projen watch - DO NOT EDIT.
2
+ // Regenerated from the exporting modules in ./src.
3
+ // Hand edits are overwritten on the next watch; this file is read-only.
4
+ export const PACKAGE_IDENTIFIER = "@dbx-tools/appkit-lakebox";
5
+ export const PACKAGE_VERSION = "0.9.132";
6
+ export * as config from "./src/config.js";
7
+ export * as desktop from "./src/desktop.js";
8
+ export * as metrics from "./src/metrics.js";
9
+ export * as plugin from "./src/plugin.js";
10
+ export * as routes from "./src/routes.js";
11
+ export * as runtime from "./src/runtime.js";
12
+ export * as services from "./src/services.js";
13
+ export * as skills from "./src/skills.js";
14
+ export * as user from "./src/user.js";
15
+ export * as workspace from "./src/workspace.js";
16
+ export { LakeboxPluginConfigSchema } from "./src/config.js";
17
+ export { desktopHtmlHead } from "./src/desktop.js";
18
+ export { LakeboxMetrics } from "./src/metrics.js";
19
+ export { AppKitLakeboxPlugin, lakebox } from "./src/plugin.js";
20
+ export { LakeboxRouteRegistry } from "./src/routes.js";
21
+ export { LakeboxRuntime } from "./src/runtime.js";
22
+ export { LakeboxControllerDefinitionSchema, LakeboxControllerServiceSchema } from "./src/services.js";
23
+ export { LAKEBOX_SKILLS_MOUNT } from "./src/skills.js";
24
+ export { LAKEBOX_AGENT_USER, LAKEBOX_AGENT_HOME, LAKEBOX_STATE_ROOT, LAKEBOX_USERS_ROOT, LAKEBOX_RUNTIME_ROOT, LAKEBOX_RUN_ROOT, LAKEBOX_UID_MIN, LAKEBOX_UID_COUNT, LAKEBOX_PORT_MIN, LAKEBOX_PORT_COUNT } from "./src/user.js";
25
+ export { LakeboxWorkspaceSandbox } from "./src/workspace.js";
26
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSwyQ0FBMkM7QUFDM0MsbURBQW1EO0FBQ25ELHdFQUF3RTtBQUV4RSxNQUFNLENBQUMsTUFBTSxrQkFBa0IsR0FBRywyQkFBMkIsQ0FBQztBQUM5RCxNQUFNLENBQUMsTUFBTSxlQUFlLEdBQUcsU0FBUyxDQUFDO0FBQ3pDLE9BQU8sS0FBSyxNQUFNLE1BQU0saUJBQWlCLENBQUM7QUFDMUMsT0FBTyxLQUFLLE9BQU8sTUFBTSxrQkFBa0IsQ0FBQztBQUM1QyxPQUFPLEtBQUssT0FBTyxNQUFNLGtCQUFrQixDQUFDO0FBQzVDLE9BQU8sS0FBSyxNQUFNLE1BQU0saUJBQWlCLENBQUM7QUFDMUMsT0FBTyxLQUFLLE1BQU0sTUFBTSxpQkFBaUIsQ0FBQztBQUMxQyxPQUFPLEtBQUssT0FBTyxNQUFNLGtCQUFrQixDQUFDO0FBQzVDLE9BQU8sS0FBSyxRQUFRLE1BQU0sbUJBQW1CLENBQUM7QUFDOUMsT0FB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2VzLnRzXCI7XG5leHBvcnQgeyBMQUtFQk9YX1NLSUxMU19NT1VOVCB9IGZyb20gXCIuL3NyYy9za2lsbHMudHNcIjtcbmV4cG9ydCB7IExBS0VCT1hfQUdFTlRfVVNFUiwgTEFLRUJPWF9BR0VOVF9IT01FLCBMQUtFQk9YX1NUQVRFX1JPT1QsIExBS0VCT1hfVVNFUlNfUk9PVCwgTEFLRUJPWF9SVU5USU1FX1JPT1QsIExBS0VCT1hfUlVOX1JPT1QsIExBS0VCT1hfVUlEX01JTiwgTEFLRUJPWF9VSURfQ09VTlQsIExBS0VCT1hfUE9SVF9NSU4sIExBS0VCT1hfUE9SVF9DT1VOVCB9IGZyb20gXCIuL3NyYy91c2VyLnRzXCI7XG5leHBvcnQgeyBMYWtlYm94V29ya3NwYWNlU2FuZGJveCB9IGZyb20gXCIuL3NyYy93b3Jrc3BhY2UudHNcIjtcbmV4cG9ydCB0eXBlIHsgTGFrZWJveFdvcmtzcGFjZVNhbmRib3hPcHRpb25zIH0gZnJvbSBcIi4vc3JjL3dvcmtzcGFjZS50c1wiO1xuIl19
@@ -0,0 +1,2 @@
1
+ /** Read one source or packaged resource from the appkit-lakebox package root. */
2
+ export declare function readPackageResource(...segments: string[]): string;
@@ -0,0 +1,11 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { basename, dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ /** Read one source or packaged resource from the appkit-lakebox package root. */
5
+ export function readPackageResource(...segments) {
6
+ const moduleDirectory = dirname(fileURLToPath(import.meta.url));
7
+ const parent = dirname(moduleDirectory);
8
+ const packageRoot = basename(parent) === "lib" ? dirname(parent) : parent;
9
+ return readFileSync(join(packageRoot, ...segments), "utf8");
10
+ }
11
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiX3BhY2thZ2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvX3BhY2thZ2UudHMiXS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9vdC4gKi9cbmV4cG9ydCBmdW5jdGlvbiByZWFkUGFja2FnZVJlc291cmNlKC4uLnNlZ21lbnRzOiBzdHJpbmdbXSk6IHN0cmluZyB7XG4gIGNvbnN0IG1vZHVsZURpcmVjdG9yeSA9IGRpcm5hbWUoZmlsZVVSTFRvUGF0aChpbXBvcnQubWV0YS51cmwpKTtcbiAgY29uc3QgcGFyZW50ID0gZGlybmFtZShtb2R1bGVEaXJlY3RvcnkpO1xuICBjb25zdCBwYWNrYWdlUm9vdCA9IGJhc2VuYW1lKHBhcmVudCkgPT09IFwibGliXCIgPyBkaXJuYW1lKHBhcmVudCkgOiBwYXJlbnQ7XG4gIHJldHVybiByZWFkRmlsZVN5bmMoam9pbihwYWNrYWdlUm9vdCwgLi4uc2VnbWVudHMpLCBcInV0ZjhcIik7XG59XG4iXX0=
@@ -0,0 +1,41 @@
1
+ import { type LakeboxEntry } from "@dbx-tools/lakebox/rest";
2
+ import { type PgPoolLike } from "@dbx-tools/postgres";
3
+ interface ResourceCache {
4
+ generateKey(parts: (string | number | object)[], userKey: string): string;
5
+ get<T>(key: string): Promise<T | null>;
6
+ set<T>(key: string, value: T, options?: {
7
+ ttl?: number;
8
+ }): Promise<void>;
9
+ delete(key: string): Promise<void>;
10
+ }
11
+ /** Lakebox client capabilities required by the persistent resource registry. */
12
+ export interface LakeboxResourceClient {
13
+ workspaceScope(): Promise<string>;
14
+ list(signal?: AbortSignal): Promise<LakeboxEntry[]>;
15
+ get(id: string, signal?: AbortSignal): Promise<LakeboxEntry>;
16
+ create(signal?: AbortSignal): Promise<LakeboxEntry>;
17
+ delete(id: string, signal?: AbortSignal): Promise<void>;
18
+ }
19
+ /**
20
+ * Persists the Databricks-assigned Lakebox ID and serializes first creation
21
+ * across app replicas with the Lakebase service-principal pool.
22
+ */
23
+ export declare class LakeboxResourceRegistry {
24
+ private readonly application;
25
+ private readonly pool?;
26
+ private readonly cache;
27
+ private readonly pending;
28
+ private readonly legacyChecked;
29
+ constructor(application: string, pool?: PgPoolLike | undefined, cache?: () => ResourceCache);
30
+ /** Resolves the current app Lakebox without creating one. */
31
+ read(client: LakeboxResourceClient, signal?: AbortSignal): Promise<LakeboxEntry | undefined>;
32
+ /** Returns the current app Lakebox or creates one with a Databricks-assigned name. */
33
+ getOrCreate(client: LakeboxResourceClient, signal?: AbortSignal): Promise<LakeboxEntry>;
34
+ /** Clears the persisted pointer after the managed Lakebox is deleted. */
35
+ clear(client: LakeboxResourceClient): Promise<void>;
36
+ private resolve;
37
+ private write;
38
+ private key;
39
+ private withLock;
40
+ }
41
+ export {};