@nimbus-sh/worker 0.4.0 → 0.6.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.
Files changed (95) hide show
  1. package/README.md +46 -43
  2. package/dist/_shared/preview-host.d.ts +33 -2
  3. package/dist/_shared/preview-host.d.ts.map +1 -1
  4. package/dist/_shared/preview-host.js +73 -8
  5. package/dist/_shared/session-router.d.ts +43 -0
  6. package/dist/_shared/session-router.d.ts.map +1 -1
  7. package/dist/_shared/session-router.js +59 -12
  8. package/dist/facets/durable-images.d.ts +59 -0
  9. package/dist/facets/durable-images.d.ts.map +1 -0
  10. package/dist/facets/durable-images.js +94 -0
  11. package/dist/facets/durable-slots.d.ts +45 -0
  12. package/dist/facets/durable-slots.d.ts.map +1 -0
  13. package/dist/facets/durable-slots.js +95 -0
  14. package/dist/facets/esbuild-transform.d.ts +10 -0
  15. package/dist/facets/esbuild-transform.d.ts.map +1 -0
  16. package/dist/facets/esbuild-transform.js +36 -0
  17. package/dist/facets/manager.d.ts +244 -6
  18. package/dist/facets/manager.d.ts.map +1 -1
  19. package/dist/facets/manager.js +901 -117
  20. package/dist/facets/resident-identity.d.ts +23 -0
  21. package/dist/facets/resident-identity.d.ts.map +1 -0
  22. package/dist/facets/resident-identity.js +31 -0
  23. package/dist/git/commands.d.ts +22 -1
  24. package/dist/git/commands.d.ts.map +1 -1
  25. package/dist/git/commands.js +429 -425
  26. package/dist/git-bundle.generated.d.ts +2 -2
  27. package/dist/git-bundle.generated.d.ts.map +1 -1
  28. package/dist/git-bundle.generated.js +3 -3
  29. package/dist/index.d.ts +2 -1
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +2 -1
  32. package/dist/node-shims-artifact.generated.js +3 -3
  33. package/dist/router/index.d.ts.map +1 -1
  34. package/dist/router/index.js +97 -3
  35. package/dist/router/public-directory-do.d.ts +17 -0
  36. package/dist/router/public-directory-do.d.ts.map +1 -0
  37. package/dist/router/public-directory-do.js +16 -0
  38. package/dist/router/public-directory.d.ts +79 -0
  39. package/dist/router/public-directory.d.ts.map +1 -0
  40. package/dist/router/public-directory.js +122 -0
  41. package/dist/router/remote-api.d.ts +27 -1
  42. package/dist/router/remote-api.d.ts.map +1 -1
  43. package/dist/router/remote-api.js +48 -2
  44. package/dist/runtime/cpython-resident.d.ts.map +1 -1
  45. package/dist/runtime/cpython-resident.js +3 -1
  46. package/dist/runtime/node-shims.d.ts +4 -1
  47. package/dist/runtime/node-shims.d.ts.map +1 -1
  48. package/dist/runtime/node-shims.js +324 -6
  49. package/dist/runtime/package-manager.d.ts +44 -1
  50. package/dist/runtime/package-manager.d.ts.map +1 -1
  51. package/dist/runtime/package-manager.js +168 -3
  52. package/dist/runtime/ruby-resident.d.ts.map +1 -1
  53. package/dist/runtime/ruby-resident.js +2 -0
  54. package/dist/session/agent.d.ts +11 -0
  55. package/dist/session/agent.d.ts.map +1 -1
  56. package/dist/session/agent.js +28 -1
  57. package/dist/session/helpers.js +1 -1
  58. package/dist/session/init-phases.d.ts +17 -23
  59. package/dist/session/init-phases.d.ts.map +1 -1
  60. package/dist/session/init-phases.js +17 -41
  61. package/dist/session/init.d.ts.map +1 -1
  62. package/dist/session/init.js +28 -15
  63. package/dist/session/keys.d.ts +12 -0
  64. package/dist/session/keys.d.ts.map +1 -1
  65. package/dist/session/keys.js +12 -0
  66. package/dist/session/nimbus-session.d.ts +63 -5
  67. package/dist/session/nimbus-session.d.ts.map +1 -1
  68. package/dist/session/nimbus-session.js +131 -17
  69. package/dist/session/port-capability.d.ts +141 -8
  70. package/dist/session/port-capability.d.ts.map +1 -1
  71. package/dist/session/port-capability.js +265 -8
  72. package/dist/session/programmatic.d.ts +145 -3
  73. package/dist/session/programmatic.d.ts.map +1 -1
  74. package/dist/session/programmatic.js +434 -12
  75. package/dist/session/routes.d.ts +26 -0
  76. package/dist/session/routes.d.ts.map +1 -1
  77. package/dist/session/routes.js +117 -25
  78. package/dist/session/rpc.d.ts +24 -1
  79. package/dist/session/rpc.d.ts.map +1 -1
  80. package/dist/session/rpc.js +65 -98
  81. package/dist/session/shell-socket.d.ts +76 -0
  82. package/dist/session/shell-socket.d.ts.map +1 -0
  83. package/dist/session/shell-socket.js +172 -0
  84. package/dist/session/start-real-vite.js +1 -1
  85. package/dist/session/supervisor-op.d.ts +42 -0
  86. package/dist/session/supervisor-op.d.ts.map +1 -0
  87. package/dist/session/supervisor-op.js +96 -0
  88. package/dist/session/supervisor-rpc.d.ts +6 -10
  89. package/dist/session/supervisor-rpc.d.ts.map +1 -1
  90. package/dist/session/supervisor-rpc.js +91 -71
  91. package/dist/session/ws.d.ts.map +1 -1
  92. package/dist/session/ws.js +19 -4
  93. package/package.json +4 -4
  94. package/public/_assets/runtime/{node-shims-fea906843f6d594e.js → node-shims-9e1380d9ee430fcc.js} +320 -5
  95. package/public/s/index.html +101 -5
@@ -11,20 +11,212 @@
11
11
  * back. Everything else is the security half of the same rule: a capability
12
12
  * names ONE registration, so any other registration on that port retires the
13
13
  * durable copy. Only a deliberate restore extends a capability's life, which
14
- * is why `clearPortCapability` sits next to every `portRegistry.register` and
14
+ * is why `clearPortCapability` sits next to every `portRegistry.register`,
15
15
  * `restorePortCapability` sits only at the two places a dev server is
16
- * deliberately brought back.
16
+ * deliberately brought back, and `restoreReservedPortCapability` sits only
17
+ * on the durable spawn's re-adopt path, gated on the stored reservation's
18
+ * owner.
19
+ *
20
+ * The same per-port record also carries a RESERVATION: an owner may hold a
21
+ * port with no capability yet, so a durable application keeps its port across
22
+ * instances whether or not it is currently exposed. Clearing a capability
23
+ * keeps the owner's reservation; only `releasePortReservation` ends it.
17
24
  */
18
25
  import { z } from 'zod/v4';
19
26
  import { PORT_CAPABILITY_KEY_PREFIX } from './keys.js';
20
27
  /** The shape `createPortCapability` mints: 12 random bytes, hex. */
21
28
  const PortCapabilitySchema = z.string().regex(/^[a-f0-9]{24}$/);
22
- function key(port) {
29
+ /** 'scoped' is the default: capability-checked but never the public bearer. */
30
+ const PortVisibilitySchema = z.enum(['scoped', 'public']);
31
+ /**
32
+ * The optional name alias a reservation may carry: one DNS label, so it can
33
+ * stand where the port stands in a preview host (`<name>--<sid>`). Never
34
+ * purely numeric — a numeric middle label IS a port. No `--`: that is the
35
+ * host-label separator. No 24 lowercase hex: that is ambiguous with a
36
+ * capability label, so parsing could mistake a name for a bearer.
37
+ */
38
+ export const APP_NAME_RE = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/;
39
+ export function isValidAppName(name) {
40
+ return APP_NAME_RE.test(name) && !name.includes('--')
41
+ && !/^\d+$/.test(name) && !/^[a-f0-9]{24}$/.test(name);
42
+ }
43
+ const AppNameSchema = z.string().refine(isValidAppName, 'app name must be a DNS label: no --, not numeric, not 24 lowercase hex');
44
+ export const PortRecordSchema = z.object({
45
+ kind: z.enum(['explicit', 'derived']).default('explicit'),
46
+ capability: PortCapabilitySchema.nullable(),
47
+ owner: z.string().nullable(),
48
+ visibility: PortVisibilitySchema.optional(),
49
+ name: AppNameSchema.optional(),
50
+ });
51
+ const RESERVATION_FIRST_PORT = 20000;
52
+ const RESERVATION_LAST_PORT = 65535;
53
+ export function portRecordKey(port) {
23
54
  return `${PORT_CAPABILITY_KEY_PREFIX}${Number(port)}`;
24
55
  }
56
+ function conflict(detail) {
57
+ return new Error(`port reservation conflict: ${detail}`);
58
+ }
59
+ /** Read the raw per-port record: a reservation, an exposure, or nothing. */
60
+ export async function readPortReservation(ctx, port) {
61
+ const stored = PortRecordSchema.safeParse(await ctx.storage.get(portRecordKey(port)));
62
+ if (!stored.success)
63
+ return null;
64
+ return { ...stored.data, visibility: stored.data.visibility ?? 'scoped' };
65
+ }
66
+ /** Read retained exposure metadata without starting a session or restoring a listener. */
67
+ export async function readPortExposure(ctx, port) {
68
+ const stored = await readPortReservation(ctx, port);
69
+ return stored !== null && stored.capability !== null
70
+ ? {
71
+ capability: stored.capability, owner: stored.owner, visibility: stored.visibility,
72
+ ...(stored.name !== undefined ? { name: stored.name } : {}),
73
+ }
74
+ : null;
75
+ }
76
+ /** Every stored port record, keyed by port — the scan `apps.list` and the name lookups read. */
77
+ export async function listPortReservations(ctx) {
78
+ const rows = await ctx.storage.list({ prefix: PORT_CAPABILITY_KEY_PREFIX });
79
+ const out = new Map();
80
+ for (const [key, value] of rows) {
81
+ const port = Number(key.slice(PORT_CAPABILITY_KEY_PREFIX.length));
82
+ const parsed = PortRecordSchema.safeParse(value);
83
+ if (!Number.isInteger(port) || !parsed.success)
84
+ continue;
85
+ out.set(port, { ...parsed.data, visibility: parsed.data.visibility ?? 'scoped' });
86
+ }
87
+ return out;
88
+ }
89
+ /** The port a name alias resolves to inside this session, or null. */
90
+ export async function readPortReservationByName(ctx, name) {
91
+ if (!isValidAppName(name))
92
+ return null;
93
+ for (const [port, reservation] of await listPortReservations(ctx)) {
94
+ if (reservation.name === name)
95
+ return { port, reservation };
96
+ }
97
+ return null;
98
+ }
99
+ /** The port an owner holds, or null when the owner has no reservation. */
100
+ export async function readPortReservationByOwner(ctx, owner) {
101
+ for (const [port, reservation] of await listPortReservations(ctx)) {
102
+ if (reservation.owner === owner)
103
+ return { port, reservation };
104
+ }
105
+ return null;
106
+ }
107
+ /**
108
+ * Hold a port for `owner` across instances. The owner's existing port is
109
+ * answered again; otherwise the preferred port is claimed, or the lowest
110
+ * free one. A preferred port that another record or a live listener holds
111
+ * is refused, never silently moved.
112
+ *
113
+ * `capability`/`visibility` give the embedder-durable path its URL material
114
+ * up front: a reservation can carry the capability the application will
115
+ * re-adopt when it binds, and the visibility the public bearer form is
116
+ * gated on. An existing reservation for the same owner is answered again,
117
+ * upgraded in place when the caller supplies values it lacks — an existing
118
+ * capability is never rotated, a URL already handed out stays good.
119
+ */
120
+ export async function reservePort(ctx, input) {
121
+ if (input.name !== undefined && !isValidAppName(input.name)) {
122
+ throw conflict(`'${input.name}' is not a valid app name (one DNS label, not numeric, not 24 hex)`);
123
+ }
124
+ const claim = async (txn) => {
125
+ const records = await txn.list({ prefix: PORT_CAPABILITY_KEY_PREFIX });
126
+ const taken = new Set(input.occupiedPorts);
127
+ const unowned = new Map();
128
+ let held = null;
129
+ for (const [storedKey, value] of records) {
130
+ const port = Number(storedKey.slice(PORT_CAPABILITY_KEY_PREFIX.length));
131
+ if (!Number.isInteger(port))
132
+ continue;
133
+ const parsed = PortRecordSchema.safeParse(value);
134
+ // listPorts may already have persisted the live capability without an
135
+ // owner. That is an exposure to adopt, not somebody else's reservation.
136
+ if (parsed.success && parsed.data.owner === null)
137
+ unowned.set(port, parsed.data);
138
+ else
139
+ taken.add(port);
140
+ if (!parsed.success)
141
+ continue;
142
+ if (parsed.data.owner === input.owner) {
143
+ held = { port, stored: parsed.data };
144
+ }
145
+ else if (input.name !== undefined && parsed.data.name === input.name
146
+ && !(parsed.data.owner === null && port === input.preferredPort)) {
147
+ throw conflict(`name '${input.name}' is already taken by another app on port ${port}`);
148
+ }
149
+ }
150
+ const preferred = input.preferredPort;
151
+ if (held !== null) {
152
+ if (preferred !== undefined && preferred !== held.port) {
153
+ throw conflict(`owner already holds port ${held.port}, cannot reserve ${preferred}`);
154
+ }
155
+ // Upgrade in place: adopt a caller-supplied capability the row lacks,
156
+ // apply the caller's visibility and/or name — never rotate an existing
157
+ // capability.
158
+ const stored = held.stored;
159
+ const capability = stored?.capability ?? input.capability ?? null;
160
+ const visibility = input.visibility ?? stored?.visibility ?? 'scoped';
161
+ const name = input.name ?? stored?.name;
162
+ if (stored === null || capability !== stored.capability
163
+ || visibility !== (stored.visibility ?? 'scoped') || name !== stored.name) {
164
+ await txn.put(portRecordKey(held.port), {
165
+ owner: input.owner, kind: stored?.kind ?? input.kind ?? 'explicit', capability, visibility, ...(name !== undefined ? { name } : {}),
166
+ });
167
+ }
168
+ return held.port;
169
+ }
170
+ let port;
171
+ if (preferred !== undefined) {
172
+ if (!Number.isInteger(preferred) || preferred < 1 || preferred > RESERVATION_LAST_PORT) {
173
+ throw conflict(`port ${preferred} is outside 1..${RESERVATION_LAST_PORT}`);
174
+ }
175
+ if (taken.has(preferred))
176
+ throw conflict(`port ${preferred} is held by another owner or listener`);
177
+ port = preferred;
178
+ }
179
+ else {
180
+ port = RESERVATION_FIRST_PORT;
181
+ while (port <= RESERVATION_LAST_PORT && taken.has(port))
182
+ port += 1;
183
+ if (port > RESERVATION_LAST_PORT)
184
+ throw conflict('no free port left to reserve');
185
+ }
186
+ const exposure = unowned.get(port);
187
+ const name = input.name ?? exposure?.name;
188
+ await txn.put(portRecordKey(port), {
189
+ owner: input.owner,
190
+ kind: input.kind ?? 'explicit',
191
+ capability: exposure?.capability ?? input.capability ?? null,
192
+ visibility: input.visibility ?? exposure?.visibility ?? 'scoped',
193
+ ...(name !== undefined ? { name } : {}),
194
+ });
195
+ return port;
196
+ };
197
+ return ctx.storage.transaction(claim);
198
+ }
199
+ /** End an owner's hold on a port. Another owner's record is left alone and refused. */
200
+ export async function releasePortReservation(ctx, input) {
201
+ // The read, the owner check and the delete are one transaction: a concurrent
202
+ // claim or a foreign release cannot interleave between them.
203
+ return ctx.storage.transaction(async (txn) => {
204
+ const stored = await readPortReservation({ storage: txn }, input.port);
205
+ if (stored === null)
206
+ return false;
207
+ if (stored.owner !== input.owner)
208
+ throw conflict(`port ${input.port} is held by another owner`);
209
+ await txn.delete(portRecordKey(input.port));
210
+ return true;
211
+ });
212
+ }
25
213
  export async function readPortCapability(self, port) {
26
- const stored = PortCapabilitySchema.safeParse(await self.ctx.storage.get(key(port)));
27
- return stored.success ? stored.data : null;
214
+ // The stored record is the only source of truth: a capability belongs to
215
+ // whoever is registered on the port, and its owner field is preserved by
216
+ // persist, never consulted as a gate. Durable ownership rides the
217
+ // reservation's own restore path (restoreReservedPortCapability).
218
+ const stored = await readPortExposure(self.ctx, port);
219
+ return stored?.capability ?? null;
28
220
  }
29
221
  /**
30
222
  * Re-adopt the persisted capability into whatever the registry holds now.
@@ -36,14 +228,79 @@ export async function restorePortCapability(self, port) {
36
228
  return null;
37
229
  return self.portRegistry.restoreCapability(Number(port), stored) ? stored : null;
38
230
  }
231
+ /**
232
+ * Re-adopt the persisted capability ONLY for the owner the stored record
233
+ * names. The durable re-drive calls this with its own owner: the reservation
234
+ * is the same source of truth the preflight reads, so a release or a foreign
235
+ * claim mid-boot cannot smuggle an exposure across.
236
+ */
237
+ export async function restoreReservedPortCapability(self, port, owner) {
238
+ const stored = await readPortReservation(self.ctx, port);
239
+ if (stored === null || stored.owner !== owner || stored.capability === null)
240
+ return null;
241
+ return self.portRegistry.restoreCapability(Number(port), stored.capability) ? stored.capability : null;
242
+ }
39
243
  export async function persistPortCapability(self, port, capability) {
40
- await self.ctx.storage.put(key(port), PortCapabilitySchema.parse(capability));
244
+ // Read-modify-write inside the reservation's own transaction, and the stored
245
+ // record is the ONLY source of truth for owner: an SDK ports.list()/expose
246
+ // on a durable application's port must not rewrite the row it is reporting
247
+ // on, or the next durable preflight sees a reservation nobody owns.
248
+ await self.ctx.storage.transaction(async (txn) => {
249
+ const stored = await txn.get(portRecordKey(port));
250
+ const parsed = PortRecordSchema.safeParse(stored);
251
+ await txn.put(portRecordKey(port), {
252
+ capability: PortCapabilitySchema.parse(capability),
253
+ owner: parsed.success ? parsed.data.owner : null,
254
+ kind: parsed.success ? parsed.data.kind : 'explicit',
255
+ ...(parsed.success && parsed.data.visibility !== undefined
256
+ ? { visibility: parsed.data.visibility }
257
+ : {}),
258
+ ...(parsed.success && parsed.data.name !== undefined
259
+ ? { name: parsed.data.name }
260
+ : {}),
261
+ });
262
+ });
263
+ }
264
+ /**
265
+ * Replace the port's capability with a freshly minted one, in place: owner,
266
+ * visibility and name stay, every URL built on the old value stops
267
+ * resolving. Answers the new capability, or null when no record exists —
268
+ * there is nothing to rotate on a port nobody has reserved or exposed.
269
+ */
270
+ export async function rotatePortCapability(self, port, capability) {
271
+ const rotated = await self.ctx.storage.transaction(async (txn) => {
272
+ const parsed = PortRecordSchema.safeParse(await txn.get(portRecordKey(port)));
273
+ if (!parsed.success)
274
+ return null;
275
+ await txn.put(portRecordKey(port), {
276
+ ...parsed.data,
277
+ capability: PortCapabilitySchema.parse(capability),
278
+ });
279
+ return capability;
280
+ });
281
+ // Registry adoption belongs to the caller, after a fresh serving-owner
282
+ // check: the storage await above may have allowed a new listener to bind.
283
+ return rotated;
41
284
  }
42
285
  /**
43
286
  * Retire the durable capability for a port. Called before every registration
44
287
  * that is not a restore, so a token handed out for the previous occupant of a
45
- * port cannot reach the next one.
288
+ * port cannot reach the next one. An owner's reservation survives it.
46
289
  */
47
290
  export async function clearPortCapability(self, port) {
48
- await self.ctx.storage.delete(key(port));
291
+ await self.ctx.storage.transaction(async (txn) => {
292
+ const stored = PortRecordSchema.safeParse(await txn.get(portRecordKey(port)));
293
+ const record = stored.success ? stored.data : null;
294
+ if (record !== null && record.owner !== null) {
295
+ await txn.put(portRecordKey(port), {
296
+ owner: record.owner,
297
+ kind: record.kind,
298
+ capability: null,
299
+ ...(record.visibility !== undefined ? { visibility: record.visibility } : {}),
300
+ ...(record.name !== undefined ? { name: record.name } : {}),
301
+ });
302
+ return;
303
+ }
304
+ await txn.delete(portRecordKey(port));
305
+ });
49
306
  }
@@ -13,6 +13,8 @@ import { PortRegistry } from '@nimbus-sh/core/runtime/port-registry.js';
13
13
  import type { RuntimeCatalogEnv } from '../runtime/runtime-catalog.js';
14
14
  import type { SqliteVFS } from '@nimbus-sh/core/vfs/sqlite-vfs.js';
15
15
  import { type VfsCred } from '@nimbus-sh/core/runtime/os-contracts.js';
16
+ import { type PortVisibility } from './port-capability.js';
17
+ import type { ResidentAppSummary, ResidentIdentity, ResidentRestartPolicy } from '../facets/manager.js';
16
18
  export interface ProgrammaticShell {
17
19
  env?: Record<string, string>;
18
20
  getEnv(): Record<string, string>;
@@ -32,20 +34,38 @@ interface ProgrammaticShellExecuteOptions {
32
34
  commandContext?: Record<string, unknown>;
33
35
  }
34
36
  interface ProgrammaticContext {
37
+ /** The session DO's own id — the public-directory binding reads its name. */
38
+ id?: {
39
+ name?: unknown;
40
+ };
35
41
  getWebSockets?(tag?: string): WebSocket[];
36
42
  /** Holds a background process's work open for the life of the process. */
37
43
  waitUntil?(promise: Promise<unknown>): void;
38
44
  storage: {
39
45
  get(key: string): Promise<unknown>;
46
+ put(key: string, value: unknown): Promise<void>;
40
47
  delete(key: string): Promise<void>;
41
48
  deleteAll(): Promise<void>;
42
49
  deleteAlarm(): Promise<void>;
43
- put(key: string, value: unknown): Promise<void>;
50
+ list<T = unknown>(options: {
51
+ prefix: string;
52
+ }): Promise<Map<string, T>>;
53
+ transaction<T>(body: (txn: {
54
+ get(key: string): Promise<unknown>;
55
+ put(key: string, value: unknown): Promise<void>;
56
+ delete(key: string): Promise<unknown>;
57
+ list<T2 = unknown>(options: {
58
+ prefix: string;
59
+ }): Promise<Map<string, T2>>;
60
+ }) => Promise<T>): Promise<T>;
44
61
  };
45
62
  }
46
63
  interface ProgrammaticFacetManager {
47
64
  kill(pid: number): boolean;
48
65
  hasResidentProcess(pid: number): boolean;
66
+ removeDurableApp(owner: string): Promise<boolean>;
67
+ residentIdentity(pid: number): Promise<ResidentIdentity | null>;
68
+ listResidentApps(): Promise<ResidentAppSummary[]>;
49
69
  }
50
70
  interface ProgrammaticViteServer {
51
71
  isRunning: boolean;
@@ -85,9 +105,13 @@ export interface ProgrammaticHost {
85
105
  nimbusWrangler?: unknown;
86
106
  npmInstaller?: unknown;
87
107
  fetchProxyEntrypoint?: unknown;
88
- runtimeFsBridges?: Map<number, unknown> | null;
108
+ _supervisorOps?: {
109
+ forget(pid: number): void;
110
+ } | null;
89
111
  sessionBasePath?: string;
90
112
  sessionBasePathHydrated?: boolean;
113
+ /** The origin the session was last reached at — what a path-form URL is built on. */
114
+ sessionOrigin?: string;
91
115
  wranglerAliasBannerShown?: boolean;
92
116
  _b4Phase?: string | null;
93
117
  _w9PersistWired?: boolean;
@@ -120,6 +144,13 @@ export interface ProgrammaticExecOptions extends ProgrammaticReadyOptions {
120
144
  shellId?: string;
121
145
  /** @internal Initial cwd for a shellId with no durable state yet. */
122
146
  shellRoot?: string;
147
+ /**
148
+ * What to do when the started process exits on its own with a non-zero
149
+ * code: 'never' (the default) leaves it stopped; 'on-failure' restarts it
150
+ * under the restart budget with backoff. A platform reset re-drives it
151
+ * either way. Carried to the launch as `$NIMBUS_RESTART`.
152
+ */
153
+ restart?: ResidentRestartPolicy;
123
154
  }
124
155
  /**
125
156
  * A second Shell over the session's own kernel, filesystem and command
@@ -249,17 +280,128 @@ export declare function rpcProcessLogs(self: ProgrammaticHost, pid: number, opti
249
280
  exit: import("@nimbus-sh/core/runtime/process-logs.js").ProcessExitInfo | null;
250
281
  }>;
251
282
  export declare function rpcListPorts(self: ProgrammaticHost): Promise<SerializedPort[]>;
252
- export declare function rpcExposePort(self: ProgrammaticHost, port: number): Promise<{
283
+ /** What `apps.expose` / `apps.rotateLink` answer: the application's address, as the caller can reach it. */
284
+ export interface ExposedAppResult {
285
+ owner: string;
286
+ name: string | null;
287
+ port: number;
288
+ pid: number | null;
289
+ capability: string | null;
290
+ visibility: PortVisibility;
291
+ /** Built from the deployment's preview suffix or the session's last-seen origin; null when neither is known. */
292
+ url: string | null;
293
+ }
294
+ export interface ListedApp extends ResidentAppSummary {
295
+ url: string | null;
296
+ }
297
+ /** An app target as every app verb takes it: a port, a pid, or a name/owner. */
298
+ export type AppTarget = number | string | {
299
+ port: number;
300
+ } | {
301
+ pid: number;
302
+ } | {
303
+ name: string;
304
+ } | {
305
+ owner: string;
306
+ };
307
+ /**
308
+ * Browser-facing URL for an application, built inside the session: the
309
+ * host form when the deployment carries a preview suffix (name first, port
310
+ * otherwise; the public bearer form when public and a capability exists),
311
+ * else the path form on the origin the session was last reached at. Null
312
+ * when the session has never been reached over HTTP and has no suffix —
313
+ * an embedder builds its own from the port and capability in that case.
314
+ */
315
+ export declare function appUrl(self: ProgrammaticHost, app: {
316
+ port: number;
317
+ name?: string | null;
318
+ capability?: string | null;
319
+ visibility?: PortVisibility;
320
+ }): string | null;
321
+ /**
322
+ * The port-centric surface, kept for every caller that has a port and
323
+ * nothing else — a dev server or a process outside the
324
+ * resident lifecycle. When the port's occupant carries an identity the
325
+ * exposure is the same lazy reservation `apps.expose` makes; when it does
326
+ * not, this compatibility path writes the row port-only, as before. One implementation:
327
+ * `applyExposure` below.
328
+ */
329
+ export declare function rpcExposePort(self: ProgrammaticHost, port: number, options?: {
330
+ visibility?: 'scoped' | 'public';
331
+ name?: string;
332
+ }): Promise<{
253
333
  port: number;
254
334
  listening: boolean;
255
335
  pid: number | null;
256
336
  registeredAt: number | null;
257
337
  capability: string | null;
338
+ visibility: "scoped" | "public";
339
+ owner: string | null;
340
+ name: string | null;
341
+ }>;
342
+ /**
343
+ * The identity-centric surface: the target names a running application —
344
+ * by port, by pid, or by name — and the exposure is what makes it durable
345
+ * under its identity: the port is reserved for the owner lazily, the
346
+ * capability minted when public and bound in the directory, the name
347
+ * stored on the reservation. Returns the address the caller can reach.
348
+ */
349
+ export declare function rpcExposeApp(self: ProgrammaticHost, target: AppTarget, options?: {
350
+ visibility?: 'scoped' | 'public';
351
+ name?: string;
352
+ }): Promise<ExposedAppResult>;
353
+ /**
354
+ * Mint a new capability for the application and rebind the directory:
355
+ * every URL built on the old one stops resolving. The registry adopts the
356
+ * new value at once if the port is live, so the new URL answers without
357
+ * waiting for a restore.
358
+ */
359
+ export declare function rpcRotateLink(self: ProgrammaticHost, target: AppTarget): Promise<ExposedAppResult>;
360
+ /** Every stamped identity, with the URL each is reachable at. */
361
+ export declare function rpcListApps(self: ProgrammaticHost): Promise<ListedApp[]>;
362
+ /**
363
+ * End an application: kill its live pids, release the reservation, purge
364
+ * its journal rows, free the durable slot and its storage, unbind the
365
+ * directory — `removeDurableApp`, addressed by any target.
366
+ */
367
+ export declare function rpcRemoveApp(self: ProgrammaticHost, target: AppTarget): Promise<{
368
+ owner: string;
369
+ removed: boolean;
370
+ port: number | null;
371
+ }>;
372
+ /**
373
+ * The embedder's durable-application seam: reserve (or re-answer) the port
374
+ * `owner` holds, minting the capability the application's public URL is
375
+ * built on — minted HERE, stored on the reservation, so a URL handed out
376
+ * before the application has ever booted is the one its eventual binding
377
+ * re-adopts, and the one a reset re-adopts again. Answers the port, the
378
+ * capability, and the record's visibility.
379
+ */
380
+ export declare function rpcEnsureDurableApp(self: ProgrammaticHost, input: {
381
+ owner: string;
382
+ preferredPort?: number;
383
+ visibility?: 'scoped' | 'public';
384
+ }): Promise<{
385
+ port: number;
386
+ capability: string | null;
387
+ visibility: 'scoped' | 'public';
258
388
  }>;
259
389
  export declare function rpcUnexposePort(self: ProgrammaticHost, port: number): Promise<{
260
390
  port: number;
261
391
  ok: boolean;
262
392
  }>;
393
+ /**
394
+ * End a durable application's contract. The reservation's port is read first
395
+ * so the caller learns which durable address was released; the manager then
396
+ * kills every launch the owner claims, purges its journal rows, releases the
397
+ * port, and frees the durable slot. `removed` is false only when no durable
398
+ * application held that owner at all.
399
+ */
400
+ export declare function rpcRemoveDurableApp(self: ProgrammaticHost, owner: string): Promise<{
401
+ owner: string;
402
+ removed: boolean;
403
+ port: number | null;
404
+ }>;
263
405
  /**
264
406
  * Route an embedder request that carries a port capability. The embedder has
265
407
  * authenticated the capability at its edge and stripped its own credentials,
@@ -1 +1 @@
1
- {"version":3,"file":"programmatic.d.ts","sourceRoot":"","sources":["../../src/session/programmatic.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,+CAA+C,CAAC;AAEvD,OAAO,KAAK,EAAY,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAC/F,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACxF,OAAO,EAAE,wBAAwB,EAAE,MAAM,uDAAuD,CAAC;AACjG,OAAO,EAAE,YAAY,EAAkB,MAAM,0CAA0C,CAAC;AACxF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,KAAK,EAAmB,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAA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