@nimbus-sh/worker 0.1.0 → 0.1.2
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/README.md +57 -13
- package/dist/_shared/session-id.d.ts +10 -8
- package/dist/_shared/session-id.d.ts.map +1 -1
- package/dist/_shared/session-id.js +13 -12
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +1 -1
- package/dist/auth/types.d.ts +2 -1
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/types.js +4 -1
- package/dist/git-bundle.generated.d.ts +3 -3
- package/dist/git-bundle.generated.d.ts.map +1 -1
- package/dist/git-bundle.generated.js +4 -4
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -10
- package/dist/loaders/generated-workers.d.ts +3 -3
- package/dist/loaders/generated-workers.d.ts.map +1 -1
- package/dist/loaders/generated-workers.js +7 -7
- package/dist/router/index.d.ts +12 -8
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +10 -6
- package/dist/router/remote-api.d.ts +44 -0
- package/dist/router/remote-api.d.ts.map +1 -0
- package/dist/router/remote-api.js +333 -0
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -17,16 +17,15 @@
|
|
|
17
17
|
* ID embedded in /s/<id>/* paths. URL → DO mapping is a stable
|
|
18
18
|
* contract delegated to {@link createNimbusHandler}.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* W6.5 registry-event sink installed at module-load time.
|
|
20
|
+
* Application embedders import this deploy-time surface through
|
|
21
|
+
* `@nimbus-sh/sdk/worker`. This implementation package keeps the
|
|
22
|
+
* runtime and generated assets in one place.
|
|
24
23
|
*/
|
|
25
24
|
import { NimbusSession, NimbusAssetsRPC, NimbusLoaderRPC, NimbusLoadedWorker, NimbusLoadedEntrypoint, NimbusDurableObjectNamespace, NimbusDOStub } from './session/nimbus-session.js';
|
|
26
25
|
import { SupervisorRPC } from './session/supervisor-rpc.js';
|
|
27
26
|
import { CirrusHmrRPC } from './facets/real-vite-hmr.js';
|
|
28
27
|
export { createNimbusHandler } from './router/index.js';
|
|
29
|
-
export type { NimbusHandler, NimbusHooks, NimbusHookContext, CustomRoutes, CreateNimbusHandlerOptions, AuthMode, NimbusAuthConfig, } from './router/index.js';
|
|
28
|
+
export type { NimbusHandler, NimbusHooks, NimbusHookContext, CustomRoutes, CreateNimbusHandlerOptions, AuthMode, NimbusAuthConfig, NimbusRemoteApiConfig, NimbusRuntimePolicy, NimbusSandboxProfile, NimbusSdkConfig, NimbusSdkRouterConfig, } from './router/index.js';
|
|
30
29
|
export { issueNimbusToken, verifyNimbusToken, NimbusAuthError, } from './auth/index.js';
|
|
31
30
|
export type { NimbusAuthEnv, NimbusTokenClaims, VerifiedNimbusToken, } from './auth/index.js';
|
|
32
31
|
export { NimbusSession, SupervisorRPC, NimbusAssetsRPC, NimbusLoaderRPC, NimbusLoadedWorker, NimbusLoadedEntrypoint, NimbusDurableObjectNamespace, NimbusDOStub, CirrusHmrRPC, };
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EACL,aAAa,EACb,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,4BAA4B,EAC5B,YAAY,EACb,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAUzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,YAAY,EACV,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,0BAA0B,EAC1B,QAAQ,EACR,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,GAChB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AAmBzB,OAAO,EACL,aAAa,EACb,aAAa,EACb,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,4BAA4B,EAC5B,YAAY,EACZ,YAAY,GACb,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,GAAG,CAEnC;;AAOD,wBAAqC"}
|
package/dist/index.js
CHANGED
|
@@ -17,10 +17,9 @@
|
|
|
17
17
|
* ID embedded in /s/<id>/* paths. URL → DO mapping is a stable
|
|
18
18
|
* contract delegated to {@link createNimbusHandler}.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* W6.5 registry-event sink installed at module-load time.
|
|
20
|
+
* Application embedders import this deploy-time surface through
|
|
21
|
+
* `@nimbus-sh/sdk/worker`. This implementation package keeps the
|
|
22
|
+
* runtime and generated assets in one place.
|
|
24
23
|
*/
|
|
25
24
|
import { NimbusSession, NimbusAssetsRPC, NimbusLoaderRPC, NimbusLoadedWorker, NimbusLoadedEntrypoint, NimbusDurableObjectNamespace, NimbusDOStub, } from './session/nimbus-session.js';
|
|
26
25
|
import { SupervisorRPC } from './session/supervisor-rpc.js';
|
|
@@ -28,16 +27,15 @@ import { CirrusHmrRPC } from './facets/real-vite-hmr.js';
|
|
|
28
27
|
import { createNimbusHandler } from './router/index.js';
|
|
29
28
|
import { getCtxExports as _getCtxExports } from './session/ctx-exports.js';
|
|
30
29
|
import { setRegistryEventSink } from './facets/wasm-swap-registry.js';
|
|
31
|
-
// Re-export the composable factory + companion types
|
|
32
|
-
//
|
|
33
|
-
// import { createNimbusHandler, NimbusSession } from '@nimbus-sh/worker';
|
|
30
|
+
// Re-export the composable factory + companion types. The SDK worker
|
|
31
|
+
// subpath re-exports these for application embedders:
|
|
32
|
+
// import { createNimbusHandler, NimbusSession } from '@nimbus-sh/sdk/worker';
|
|
34
33
|
// export { NimbusSession };
|
|
35
34
|
// export default createNimbusHandler();
|
|
36
35
|
export { createNimbusHandler } from './router/index.js';
|
|
37
36
|
// Auth surface — embedders need `issueNimbusToken` / `verifyNimbusToken`
|
|
38
|
-
// to mint tokens from custom routes.
|
|
39
|
-
//
|
|
40
|
-
// the dedicated auth subpath for non-Worker callers.
|
|
37
|
+
// to mint tokens from custom routes. `@nimbus-sh/sdk/token` re-exports
|
|
38
|
+
// from the dedicated auth subpath for application callers.
|
|
41
39
|
export { issueNimbusToken, verifyNimbusToken, NimbusAuthError, } from './auth/index.js';
|
|
42
40
|
// W6.5: install the default registry-event sink at module top so events
|
|
43
41
|
// emitted from any code path (supervisor BFS, facet drain, applyW6Registry)
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
* W7-frame symbols: encodeWriteBatchStream, decodeWriteBatchStream,
|
|
16
16
|
* W7_MAGIC, W7_TRAILER.
|
|
17
17
|
*
|
|
18
|
-
* Generated at: 2026-06-
|
|
19
|
-
* Tar size: 3.
|
|
20
|
-
* W7 size: 7.
|
|
18
|
+
* Generated at: 2026-06-04T22:29:13.391Z
|
|
19
|
+
* Tar size: 3.86 KiB
|
|
20
|
+
* W7 size: 7.78 KiB
|
|
21
21
|
*/
|
|
22
22
|
export declare const TAR_STREAM_PREAMBLE: string;
|
|
23
23
|
export declare const TAR_STREAM_PREAMBLE_SIZE: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generated-workers.d.ts","sourceRoot":"","sources":["../../src/loaders/generated-workers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,eAAO,MAAM,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"generated-workers.d.ts","sourceRoot":"","sources":["../../src/loaders/generated-workers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,eAAO,MAAM,mBAAmB,EAAE,MAAyhI,CAAC;AAE5jI,eAAO,MAAM,wBAAwB,EAAE,MAAa,CAAC;AAErD,eAAO,MAAM,iBAAiB,EAAE,MAA+jQ,CAAC;AAEhmQ,eAAO,MAAM,sBAAsB,EAAE,MAAa,CAAC"}
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
* W7-frame symbols: encodeWriteBatchStream, decodeWriteBatchStream,
|
|
16
16
|
* W7_MAGIC, W7_TRAILER.
|
|
17
17
|
*
|
|
18
|
-
* Generated at: 2026-06-
|
|
19
|
-
* Tar size: 3.
|
|
20
|
-
* W7 size: 7.
|
|
18
|
+
* Generated at: 2026-06-04T22:29:13.391Z
|
|
19
|
+
* Tar size: 3.86 KiB
|
|
20
|
+
* W7 size: 7.78 KiB
|
|
21
21
|
*/
|
|
22
|
-
export const TAR_STREAM_PREAMBLE = "// src/npm/tarball-stream.ts\nvar MAX_FILE_BYTES = 2e7;\nfunction parseTarHeader(block) {\n if (block[0] === 0) return null;\n let name = \"\";\n for (let i = 0; i < 100 && block[i] !== 0; i++) {\n name += String.fromCharCode(block[i]);\n }\n let prefix = \"\";\n for (let i = 345; i < 500 && block[i] !== 0; i++) {\n prefix += String.fromCharCode(block[i]);\n }\n if (prefix) name = prefix + \"/\" + name;\n name = name.replace(/^package\\//, \"\");\n let sizeStr = \"\";\n for (let i = 124; i < 136 && block[i] !== 0; i++) {\n sizeStr += String.fromCharCode(block[i]);\n }\n const size = parseInt(sizeStr.trim(), 8) || 0;\n const typeFlag = block[156];\n return { name, size, typeFlag };\n}\nasync function* readableStreamToAsyncIterable(rs) {\n const reader = rs.getReader();\n try {\n while (true) {\n const { value, done } = await reader.read();\n if (done) return;\n if (value && value.length > 0) yield value;\n }\n } finally {\n try {\n reader.releaseLock();\n } catch {\n }\n }\n}\nasync function* streamTarEntries(source, onSkip) {\n let carry = new Uint8Array(0);\n let state = { kind: \"header\" };\n function concat(a, b) {\n if (a.length === 0) return b;\n if (b.length === 0) return a;\n const out = new Uint8Array(a.length + b.length);\n out.set(a, 0);\n out.set(b, a.length);\n return out;\n }\n for await (const chunkRaw of source) {\n let buf = concat(carry, chunkRaw);\n let cursor = 0;\n while (true) {\n if (state.kind === \"header\") {\n if (buf.length - cursor < 512) break;\n const header = buf.subarray(cursor, cursor + 512);\n const parsed = parseTarHeader(header);\n cursor += 512;\n if (!parsed) return;\n const { name, size, typeFlag } = parsed;\n const pad = size === 0 ? 0 : (512 - size % 512) % 512;\n const isRegularFile = typeFlag === 48 || typeFlag === 0;\n if (size === 0) {\n if (isRegularFile && name) {\n yield { name, data: new Uint8Array(0) };\n }\n state = { kind: \"header\" };\n continue;\n }\n if (!isRegularFile || !name || size > MAX_FILE_BYTES) {\n if (onSkip) {\n const reason = !isRegularFile ? \"non-regular\" : !name ? \"no-name\" : \"too-large\";\n try {\n onSkip(name, size, reason);\n } catch {\n }\n }\n state = { kind: \"skip\", remaining: size + pad };\n continue;\n }\n state = {\n kind: \"file\",\n name,\n remaining: size,\n fileBuf: new Uint8Array(size),\n fileOffset: 0,\n pad,\n skip: false\n };\n continue;\n }\n if (state.kind === \"file\") {\n const avail2 = buf.length - cursor;\n if (avail2 === 0) break;\n if (state.remaining > 0) {\n const take2 = Math.min(state.remaining, avail2);\n state.fileBuf.set(buf.subarray(cursor, cursor + take2), state.fileOffset);\n state.fileOffset += take2;\n state.remaining -= take2;\n cursor += take2;\n if (state.remaining > 0) break;\n }\n if (state.pad > 0) {\n const avail22 = buf.length - cursor;\n if (avail22 === 0) break;\n const take2 = Math.min(state.pad, avail22);\n state.pad -= take2;\n cursor += take2;\n if (state.pad > 0) break;\n }\n yield { name: state.name, data: state.fileBuf };\n state = { kind: \"header\" };\n continue;\n }\n const avail = buf.length - cursor;\n if (avail === 0) break;\n const take = Math.min(state.remaining, avail);\n cursor += take;\n state.remaining -= take;\n if (state.remaining > 0) break;\n state = { kind: \"header\" };\n }\n if (cursor >= buf.length) {\n carry = new Uint8Array(0);\n } else if (cursor === 0) {\n carry = buf;\n } else {\n carry = buf.slice(cursor);\n }\n }\n}";
|
|
23
|
-
export const TAR_STREAM_PREAMBLE_SIZE =
|
|
24
|
-
export const W7_FRAME_PREAMBLE = "// src/_shared/w7-frame.ts\nvar W7_MAGIC = new Uint8Array([78, 87, 55, 1]);\nvar W7_TRAILER = new Uint8Array([78, 69, 78, 68]);\nvar ENCODER_QUEUE_HWM = 256 * 1024;\nvar ENCODER_EMIT_CAP = 64 * 1024;\nvar _peakInFlight = 0;\nvar _currentInFlight = 0;\nfunction _peakInFlightBytes() {\n return _peakInFlight;\n}\nfunction _resetPeakInFlightBytes() {\n _peakInFlight = 0;\n _currentInFlight = 0;\n}\nfunction _trackInFlightAdd(n) {\n _currentInFlight += n;\n if (_currentInFlight > _peakInFlight) _peakInFlight = _currentInFlight;\n}\nfunction _trackInFlightSub(n) {\n _currentInFlight -= n;\n if (_currentInFlight < 0) _currentInFlight = 0;\n}\nfunction encodeWriteBatchStream(payload) {\n const inodes = payload.inodes ?? [];\n const chunks = payload.chunks ?? [];\n const deletePaths = payload.deletePaths;\n let phase = 0;\n let chunkIdx = 0;\n const enc = new TextEncoder();\n const headerBytes = enc.encode(JSON.stringify({\n inodes,\n deletePaths,\n chunkCount: chunks.length\n }));\n const source = {\n type: \"bytes\",\n pull(controller) {\n try {\n if (phase === 0) {\n enqueue(controller, W7_MAGIC.slice());\n phase = 1;\n return;\n }\n if (phase === 1) {\n const hdr = new Uint8Array(4 + headerBytes.length);\n writeU32LE(hdr, 0, headerBytes.length);\n hdr.set(headerBytes, 4);\n enqueue(controller, hdr);\n phase = 2;\n return;\n }\n if (phase === 2) {\n if (chunkIdx >= chunks.length) {\n phase = 3;\n } else {\n const c = chunks[chunkIdx++];\n const pathBytes = enc.encode(c.path);\n const data = c.data instanceof Uint8Array ? c.data : new Uint8Array(c.data);\n const headerSize = 4 + pathBytes.length + 4 + 4;\n const headerOut = new Uint8Array(headerSize);\n let o = 0;\n writeU32LE(headerOut, o, pathBytes.length);\n o += 4;\n headerOut.set(pathBytes, o);\n o += pathBytes.length;\n writeU32LE(headerOut, o, c.chunkId);\n o += 4;\n writeU32LE(headerOut, o, data.length);\n o += 4;\n enqueue(controller, headerOut);\n if (data.length === 0) return;\n if (data.length <= ENCODER_EMIT_CAP) {\n enqueue(controller, data);\n } else {\n for (let i = 0; i < data.length; i += ENCODER_EMIT_CAP) {\n enqueue(controller, data.subarray(i, Math.min(i + ENCODER_EMIT_CAP, data.length)));\n }\n }\n return;\n }\n }\n if (phase === 3) {\n enqueue(controller, W7_TRAILER.slice());\n phase = 4;\n controller.close();\n return;\n }\n controller.close();\n } catch (e) {\n controller.error(e);\n }\n },\n cancel() {\n phase = 4;\n chunkIdx = chunks.length;\n }\n };\n return new ReadableStream(source, {\n // Byte streams (`type: 'bytes'`) MUST use the default byte-counted\n // strategy: highWaterMark is in bytes, size is implicit. Custom\n // `size` callbacks are forbidden — they throw at construction.\n highWaterMark: ENCODER_QUEUE_HWM\n });\n function enqueue(controller, bytes) {\n _trackInFlightAdd(bytes.byteLength);\n controller.enqueue(bytes);\n queueMicrotask(() => _trackInFlightSub(bytes.byteLength));\n }\n}\nasync function decodeWriteBatchStream(stream) {\n const reader = stream.getReader();\n const buf = new ByteBuffer(reader);\n const magic = await buf.readExact(4, \"magic\");\n if (!bytesEqual(magic, W7_MAGIC)) {\n try {\n reader.releaseLock();\n } catch {\n }\n throw new Error(`w7-frame: bad magic, expected NW7\\\\x01, got ${Array.from(magic).map((b) => b.toString(16)).join(\" \")}`);\n }\n const hdrLenBytes = await buf.readExact(4, \"header-length\");\n const hdrLen = readU32LE(hdrLenBytes, 0);\n if (hdrLen < 0 || hdrLen > 64 * 1024 * 1024) {\n throw new Error(`w7-frame: implausible header length ${hdrLen}`);\n }\n const hdrJson = await buf.readExact(hdrLen, \"header-json\");\n let header;\n try {\n header = JSON.parse(new TextDecoder().decode(hdrJson));\n } catch (e) {\n throw new Error(`w7-frame: header JSON parse failed: ${e?.message || e}`);\n }\n if (!header || !Array.isArray(header.inodes) || typeof header.chunkCount !== \"number\") {\n throw new Error(\"w7-frame: header missing required fields (inodes / chunkCount)\");\n }\n const chunkIter = {\n [Symbol.asyncIterator]() {\n let idx = 0;\n let exhausted = false;\n return {\n async next() {\n if (exhausted) return { value: void 0, done: true };\n if (idx >= header.chunkCount) {\n const trailer = await buf.readExact(4, \"trailer\");\n if (!bytesEqual(trailer, W7_TRAILER)) {\n throw new Error(\n `w7-frame: bad trailer, expected NEND, got ${Array.from(trailer).map((b) => String.fromCharCode(b)).join(\"\")}`\n );\n }\n try {\n reader.releaseLock();\n } catch {\n }\n exhausted = true;\n return { value: void 0, done: true };\n }\n const pathLenBytes = await buf.readExact(4, \"chunk-path-length\");\n const pathLen = readU32LE(pathLenBytes, 0);\n if (pathLen < 0 || pathLen > 64 * 1024) {\n throw new Error(`w7-frame: implausible path length ${pathLen} at chunk ${idx}`);\n }\n const pathBytes = await buf.readExact(pathLen, \"chunk-path\");\n const path = new TextDecoder().decode(pathBytes);\n const chunkIdBytes = await buf.readExact(4, \"chunk-id\");\n const chunkId = readU32LE(chunkIdBytes, 0);\n const dataLenBytes = await buf.readExact(4, \"chunk-data-length\");\n const dataLen = readU32LE(dataLenBytes, 0);\n if (dataLen < 0 || dataLen > 64 * 1024 * 1024) {\n throw new Error(`w7-frame: implausible data length ${dataLen} at chunk ${idx}`);\n }\n const data = await buf.readExact(dataLen, \"chunk-data\");\n idx++;\n return { value: { path, chunkId, data }, done: false };\n },\n async return() {\n exhausted = true;\n try {\n reader.releaseLock();\n } catch {\n }\n return { value: void 0, done: true };\n }\n };\n }\n };\n return {\n inodes: header.inodes,\n deletePaths: header.deletePaths,\n chunkIter\n };\n}\nfunction writeU32LE(out, off, n) {\n out[off] = n & 255;\n out[off + 1] = n >>> 8 & 255;\n out[off + 2] = n >>> 16 & 255;\n out[off + 3] = n >>> 24 & 255;\n}\nfunction readU32LE(buf, off) {\n return (buf[off] | buf[off + 1] << 8 | buf[off + 2] << 16 | buf[off + 3] << 24) >>> 0;\n}\nfunction bytesEqual(a, b) {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;\n return true;\n}\nvar ByteBuffer = class {\n constructor(reader) {\n this.reader = reader;\n }\n chunks = [];\n avail = 0;\n done = false;\n async readExact(n, label) {\n if (n === 0) return new Uint8Array(0);\n while (this.avail < n) {\n if (this.done) {\n throw new Error(\n `w7-frame: stream ended ${this.avail} bytes into expected ${n}-byte ${label}`\n );\n }\n const { value, done } = await this.reader.read();\n if (done) {\n this.done = true;\n } else if (value && value.length > 0) {\n this.chunks.push(value);\n this.avail += value.length;\n }\n }\n const out = new Uint8Array(n);\n let copied = 0;\n while (copied < n) {\n const head = this.chunks[0];\n const take = Math.min(head.length, n - copied);\n out.set(head.subarray(0, take), copied);\n copied += take;\n if (take === head.length) {\n this.chunks.shift();\n } else {\n this.chunks[0] = head.subarray(take);\n }\n }\n this.avail -= n;\n return out;\n }\n};";
|
|
25
|
-
export const W7_FRAME_PREAMBLE_SIZE =
|
|
22
|
+
export const TAR_STREAM_PREAMBLE = "// packages/worker/src/npm/tarball-stream.ts\nvar MAX_FILE_BYTES = 2e7;\nfunction parseTarHeader(block) {\n if (block[0] === 0) return null;\n let name = \"\";\n for (let i = 0; i < 100 && block[i] !== 0; i++) {\n name += String.fromCharCode(block[i]);\n }\n let prefix = \"\";\n for (let i = 345; i < 500 && block[i] !== 0; i++) {\n prefix += String.fromCharCode(block[i]);\n }\n if (prefix) name = prefix + \"/\" + name;\n name = name.replace(/^package\\//, \"\");\n let sizeStr = \"\";\n for (let i = 124; i < 136 && block[i] !== 0; i++) {\n sizeStr += String.fromCharCode(block[i]);\n }\n const size = parseInt(sizeStr.trim(), 8) || 0;\n const typeFlag = block[156];\n return { name, size, typeFlag };\n}\nasync function* readableStreamToAsyncIterable(rs) {\n const reader = rs.getReader();\n try {\n while (true) {\n const { value, done } = await reader.read();\n if (done) return;\n if (value && value.length > 0) yield value;\n }\n } finally {\n try {\n reader.releaseLock();\n } catch {\n }\n }\n}\nasync function* streamTarEntries(source, onSkip) {\n let carry = new Uint8Array(0);\n let state = { kind: \"header\" };\n function concat(a, b) {\n if (a.length === 0) return b;\n if (b.length === 0) return a;\n const out = new Uint8Array(a.length + b.length);\n out.set(a, 0);\n out.set(b, a.length);\n return out;\n }\n for await (const chunkRaw of source) {\n let buf = concat(carry, chunkRaw);\n let cursor = 0;\n while (true) {\n if (state.kind === \"header\") {\n if (buf.length - cursor < 512) break;\n const header = buf.subarray(cursor, cursor + 512);\n const parsed = parseTarHeader(header);\n cursor += 512;\n if (!parsed) return;\n const { name, size, typeFlag } = parsed;\n const pad = size === 0 ? 0 : (512 - size % 512) % 512;\n const isRegularFile = typeFlag === 48 || typeFlag === 0;\n if (size === 0) {\n if (isRegularFile && name) {\n yield { name, data: new Uint8Array(0) };\n }\n state = { kind: \"header\" };\n continue;\n }\n if (!isRegularFile || !name || size > MAX_FILE_BYTES) {\n if (onSkip) {\n const reason = !isRegularFile ? \"non-regular\" : !name ? \"no-name\" : \"too-large\";\n try {\n onSkip(name, size, reason);\n } catch {\n }\n }\n state = { kind: \"skip\", remaining: size + pad };\n continue;\n }\n state = {\n kind: \"file\",\n name,\n remaining: size,\n fileBuf: new Uint8Array(size),\n fileOffset: 0,\n pad,\n skip: false\n };\n continue;\n }\n if (state.kind === \"file\") {\n const avail2 = buf.length - cursor;\n if (avail2 === 0) break;\n if (state.remaining > 0) {\n const take2 = Math.min(state.remaining, avail2);\n state.fileBuf.set(buf.subarray(cursor, cursor + take2), state.fileOffset);\n state.fileOffset += take2;\n state.remaining -= take2;\n cursor += take2;\n if (state.remaining > 0) break;\n }\n if (state.pad > 0) {\n const avail22 = buf.length - cursor;\n if (avail22 === 0) break;\n const take2 = Math.min(state.pad, avail22);\n state.pad -= take2;\n cursor += take2;\n if (state.pad > 0) break;\n }\n yield { name: state.name, data: state.fileBuf };\n state = { kind: \"header\" };\n continue;\n }\n const avail = buf.length - cursor;\n if (avail === 0) break;\n const take = Math.min(state.remaining, avail);\n cursor += take;\n state.remaining -= take;\n if (state.remaining > 0) break;\n state = { kind: \"header\" };\n }\n if (cursor >= buf.length) {\n carry = new Uint8Array(0);\n } else if (cursor === 0) {\n carry = buf;\n } else {\n carry = buf.slice(cursor);\n }\n }\n}";
|
|
23
|
+
export const TAR_STREAM_PREAMBLE_SIZE = 3948;
|
|
24
|
+
export const W7_FRAME_PREAMBLE = "// packages/worker/src/_shared/w7-frame.ts\nvar W7_MAGIC = new Uint8Array([78, 87, 55, 1]);\nvar W7_TRAILER = new Uint8Array([78, 69, 78, 68]);\nvar ENCODER_QUEUE_HWM = 256 * 1024;\nvar ENCODER_EMIT_CAP = 64 * 1024;\nvar _peakInFlight = 0;\nvar _currentInFlight = 0;\nfunction _peakInFlightBytes() {\n return _peakInFlight;\n}\nfunction _resetPeakInFlightBytes() {\n _peakInFlight = 0;\n _currentInFlight = 0;\n}\nfunction _trackInFlightAdd(n) {\n _currentInFlight += n;\n if (_currentInFlight > _peakInFlight) _peakInFlight = _currentInFlight;\n}\nfunction _trackInFlightSub(n) {\n _currentInFlight -= n;\n if (_currentInFlight < 0) _currentInFlight = 0;\n}\nfunction encodeWriteBatchStream(payload) {\n const inodes = payload.inodes ?? [];\n const chunks = payload.chunks ?? [];\n const deletePaths = payload.deletePaths;\n let phase = 0;\n let chunkIdx = 0;\n const enc = new TextEncoder();\n const headerBytes = enc.encode(JSON.stringify({\n inodes,\n deletePaths,\n chunkCount: chunks.length\n }));\n const source = {\n type: \"bytes\",\n pull(controller) {\n try {\n if (phase === 0) {\n enqueue(controller, W7_MAGIC.slice());\n phase = 1;\n return;\n }\n if (phase === 1) {\n const hdr = new Uint8Array(4 + headerBytes.length);\n writeU32LE(hdr, 0, headerBytes.length);\n hdr.set(headerBytes, 4);\n enqueue(controller, hdr);\n phase = 2;\n return;\n }\n if (phase === 2) {\n if (chunkIdx >= chunks.length) {\n phase = 3;\n } else {\n const c = chunks[chunkIdx++];\n const pathBytes = enc.encode(c.path);\n const data = c.data instanceof Uint8Array ? c.data : new Uint8Array(c.data);\n const headerSize = 4 + pathBytes.length + 4 + 4;\n const headerOut = new Uint8Array(headerSize);\n let o = 0;\n writeU32LE(headerOut, o, pathBytes.length);\n o += 4;\n headerOut.set(pathBytes, o);\n o += pathBytes.length;\n writeU32LE(headerOut, o, c.chunkId);\n o += 4;\n writeU32LE(headerOut, o, data.length);\n o += 4;\n enqueue(controller, headerOut);\n if (data.length === 0) return;\n if (data.length <= ENCODER_EMIT_CAP) {\n enqueue(controller, data);\n } else {\n for (let i = 0; i < data.length; i += ENCODER_EMIT_CAP) {\n enqueue(controller, data.subarray(i, Math.min(i + ENCODER_EMIT_CAP, data.length)));\n }\n }\n return;\n }\n }\n if (phase === 3) {\n enqueue(controller, W7_TRAILER.slice());\n phase = 4;\n controller.close();\n return;\n }\n controller.close();\n } catch (e) {\n controller.error(e);\n }\n },\n cancel() {\n phase = 4;\n chunkIdx = chunks.length;\n }\n };\n return new ReadableStream(source, {\n // Byte streams (`type: 'bytes'`) MUST use the default byte-counted\n // strategy: highWaterMark is in bytes, size is implicit. Custom\n // `size` callbacks are forbidden — they throw at construction.\n highWaterMark: ENCODER_QUEUE_HWM\n });\n function enqueue(controller, bytes) {\n _trackInFlightAdd(bytes.byteLength);\n controller.enqueue(bytes);\n queueMicrotask(() => _trackInFlightSub(bytes.byteLength));\n }\n}\nasync function decodeWriteBatchStream(stream) {\n const reader = stream.getReader();\n const buf = new ByteBuffer(reader);\n const magic = await buf.readExact(4, \"magic\");\n if (!bytesEqual(magic, W7_MAGIC)) {\n try {\n reader.releaseLock();\n } catch {\n }\n throw new Error(`w7-frame: bad magic, expected NW7\\\\x01, got ${Array.from(magic).map((b) => b.toString(16)).join(\" \")}`);\n }\n const hdrLenBytes = await buf.readExact(4, \"header-length\");\n const hdrLen = readU32LE(hdrLenBytes, 0);\n if (hdrLen < 0 || hdrLen > 64 * 1024 * 1024) {\n throw new Error(`w7-frame: implausible header length ${hdrLen}`);\n }\n const hdrJson = await buf.readExact(hdrLen, \"header-json\");\n let header;\n try {\n header = JSON.parse(new TextDecoder().decode(hdrJson));\n } catch (e) {\n throw new Error(`w7-frame: header JSON parse failed: ${e?.message || e}`);\n }\n if (!header || !Array.isArray(header.inodes) || typeof header.chunkCount !== \"number\") {\n throw new Error(\"w7-frame: header missing required fields (inodes / chunkCount)\");\n }\n const chunkIter = {\n [Symbol.asyncIterator]() {\n let idx = 0;\n let exhausted = false;\n return {\n async next() {\n if (exhausted) return { value: void 0, done: true };\n if (idx >= header.chunkCount) {\n const trailer = await buf.readExact(4, \"trailer\");\n if (!bytesEqual(trailer, W7_TRAILER)) {\n throw new Error(\n `w7-frame: bad trailer, expected NEND, got ${Array.from(trailer).map((b) => String.fromCharCode(b)).join(\"\")}`\n );\n }\n try {\n reader.releaseLock();\n } catch {\n }\n exhausted = true;\n return { value: void 0, done: true };\n }\n const pathLenBytes = await buf.readExact(4, \"chunk-path-length\");\n const pathLen = readU32LE(pathLenBytes, 0);\n if (pathLen < 0 || pathLen > 64 * 1024) {\n throw new Error(`w7-frame: implausible path length ${pathLen} at chunk ${idx}`);\n }\n const pathBytes = await buf.readExact(pathLen, \"chunk-path\");\n const path = new TextDecoder().decode(pathBytes);\n const chunkIdBytes = await buf.readExact(4, \"chunk-id\");\n const chunkId = readU32LE(chunkIdBytes, 0);\n const dataLenBytes = await buf.readExact(4, \"chunk-data-length\");\n const dataLen = readU32LE(dataLenBytes, 0);\n if (dataLen < 0 || dataLen > 64 * 1024 * 1024) {\n throw new Error(`w7-frame: implausible data length ${dataLen} at chunk ${idx}`);\n }\n const data = await buf.readExact(dataLen, \"chunk-data\");\n idx++;\n return { value: { path, chunkId, data }, done: false };\n },\n async return() {\n exhausted = true;\n try {\n reader.releaseLock();\n } catch {\n }\n return { value: void 0, done: true };\n }\n };\n }\n };\n return {\n inodes: header.inodes,\n deletePaths: header.deletePaths,\n chunkIter\n };\n}\nfunction writeU32LE(out, off, n) {\n out[off] = n & 255;\n out[off + 1] = n >>> 8 & 255;\n out[off + 2] = n >>> 16 & 255;\n out[off + 3] = n >>> 24 & 255;\n}\nfunction readU32LE(buf, off) {\n return (buf[off] | buf[off + 1] << 8 | buf[off + 2] << 16 | buf[off + 3] << 24) >>> 0;\n}\nfunction bytesEqual(a, b) {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;\n return true;\n}\nvar ByteBuffer = class {\n constructor(reader) {\n this.reader = reader;\n }\n chunks = [];\n avail = 0;\n done = false;\n async readExact(n, label) {\n if (n === 0) return new Uint8Array(0);\n while (this.avail < n) {\n if (this.done) {\n throw new Error(\n `w7-frame: stream ended ${this.avail} bytes into expected ${n}-byte ${label}`\n );\n }\n const { value, done } = await this.reader.read();\n if (done) {\n this.done = true;\n } else if (value && value.length > 0) {\n this.chunks.push(value);\n this.avail += value.length;\n }\n }\n const out = new Uint8Array(n);\n let copied = 0;\n while (copied < n) {\n const head = this.chunks[0];\n const take = Math.min(head.length, n - copied);\n out.set(head.subarray(0, take), copied);\n copied += take;\n if (take === head.length) {\n this.chunks.shift();\n } else {\n this.chunks[0] = head.subarray(take);\n }\n }\n this.avail -= n;\n return out;\n }\n};";
|
|
25
|
+
export const W7_FRAME_PREAMBLE_SIZE = 7970;
|
package/dist/router/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* router/index.ts — `createNimbusHandler` factory.
|
|
3
3
|
*
|
|
4
|
-
* The Worker entry's `default { fetch }` is
|
|
5
|
-
* factory.
|
|
6
|
-
* `@nimbus-sh/worker`:
|
|
4
|
+
* The Worker entry's `default { fetch }` is a thin call into this
|
|
5
|
+
* factory. Application embedders get the composable surface via
|
|
6
|
+
* `@nimbus-sh/sdk/worker`:
|
|
7
7
|
*
|
|
8
|
-
* import { NimbusSession, createNimbusHandler } from '@nimbus-sh/worker';
|
|
8
|
+
* import { NimbusSession, createNimbusHandler } from '@nimbus-sh/sdk/worker';
|
|
9
9
|
* export { NimbusSession };
|
|
10
10
|
* export default createNimbusHandler({
|
|
11
11
|
* // Optional embedder hooks (all default no-op):
|
|
@@ -31,6 +31,8 @@
|
|
|
31
31
|
* - The default `createNimbusHandler()` (zero args) is the
|
|
32
32
|
* "ship-Nimbus-as-is" case — exactly what `apps/dogfood/` does.
|
|
33
33
|
*/
|
|
34
|
+
import { type NimbusSdkRouterConfig } from './remote-api.js';
|
|
35
|
+
export type { NimbusConfig as NimbusSdkConfig, NimbusRemoteApiConfig, NimbusRuntimePolicy, NimbusSandboxProfile, NimbusSdkRouterConfig, } from './remote-api.js';
|
|
34
36
|
/**
|
|
35
37
|
* Lifecycle event a hook receives. Hooks should treat this as read-only.
|
|
36
38
|
*/
|
|
@@ -50,8 +52,8 @@ export interface NimbusHookContext {
|
|
|
50
52
|
* NOT short-circuit the request.
|
|
51
53
|
*
|
|
52
54
|
* `onSessionStart` fires on the first WebSocket upgrade for a session
|
|
53
|
-
* (not on every HTTP API call). `onSessionEnd`
|
|
54
|
-
* session
|
|
55
|
+
* (not on every HTTP API call). `onSessionEnd` is reserved for future
|
|
56
|
+
* session lifecycle events.
|
|
55
57
|
*/
|
|
56
58
|
export interface NimbusHooks {
|
|
57
59
|
/**
|
|
@@ -110,6 +112,8 @@ export interface CreateNimbusHandlerOptions {
|
|
|
110
112
|
routes?: CustomRoutes;
|
|
111
113
|
/** Auth-mode selector. Default `'auto'`. */
|
|
112
114
|
auth?: NimbusAuthConfig;
|
|
115
|
+
/** Programmatic SDK HTTP surface. Disabled unless explicitly enabled. */
|
|
116
|
+
sdk?: NimbusSdkRouterConfig;
|
|
113
117
|
}
|
|
114
118
|
/**
|
|
115
119
|
* The shape every `default export` Workers handler must satisfy.
|
|
@@ -124,14 +128,14 @@ export interface NimbusHandler {
|
|
|
124
128
|
*
|
|
125
129
|
* @example minimal embedder
|
|
126
130
|
* ```ts
|
|
127
|
-
* import { NimbusSession, createNimbusHandler } from '@nimbus-sh/worker';
|
|
131
|
+
* import { NimbusSession, createNimbusHandler } from '@nimbus-sh/sdk/worker';
|
|
128
132
|
* export { NimbusSession };
|
|
129
133
|
* export default createNimbusHandler();
|
|
130
134
|
* ```
|
|
131
135
|
*
|
|
132
136
|
* @example embedder with auth + a custom route
|
|
133
137
|
* ```ts
|
|
134
|
-
* import { NimbusSession, createNimbusHandler } from '@nimbus-sh/worker';
|
|
138
|
+
* import { NimbusSession, createNimbusHandler } from '@nimbus-sh/sdk/worker';
|
|
135
139
|
* import { issueNimbusToken } from '@nimbus-sh/sdk/token';
|
|
136
140
|
*
|
|
137
141
|
* export { NimbusSession };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/router/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/router/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAqBH,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACV,YAAY,IAAI,eAAe,EAC/B,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AAEzB;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,oDAAoD;IACpD,aAAa,EAAE,MAAM,CAAC;IACtB,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,kFAAkF;IAClF,OAAO,EAAE,OAAO,CAAC;IACjB,oBAAoB;IACpB,GAAG,EAAE,GAAG,CAAC;CACV;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;;OAMG;IACH,cAAc,CAAC,CAAC,GAAG,EAAE,iBAAiB,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9D;;;OAGG;IACH,YAAY,CAAC,CAAC,GAAG,EAAE,iBAAiB,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7D;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAC;AAErD,0CAA0C;AAC1C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,CACzB,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,gBAAgB,KAClB,QAAQ,GAAG,IAAI,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;AAEhD,+CAA+C;AAC/C,MAAM,WAAW,0BAA0B;IACzC,oCAAoC;IACpC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,qDAAqD;IACrD,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,4CAA4C;IAC5C,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,yEAAyE;IACzE,GAAG,CAAC,EAAE,qBAAqB,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC7E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,0BAA+B,GACvC,aAAa,CAkHf"}
|
package/dist/router/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* router/index.ts — `createNimbusHandler` factory.
|
|
3
3
|
*
|
|
4
|
-
* The Worker entry's `default { fetch }` is
|
|
5
|
-
* factory.
|
|
6
|
-
* `@nimbus-sh/worker`:
|
|
4
|
+
* The Worker entry's `default { fetch }` is a thin call into this
|
|
5
|
+
* factory. Application embedders get the composable surface via
|
|
6
|
+
* `@nimbus-sh/sdk/worker`:
|
|
7
7
|
*
|
|
8
|
-
* import { NimbusSession, createNimbusHandler } from '@nimbus-sh/worker';
|
|
8
|
+
* import { NimbusSession, createNimbusHandler } from '@nimbus-sh/sdk/worker';
|
|
9
9
|
* export { NimbusSession };
|
|
10
10
|
* export default createNimbusHandler({
|
|
11
11
|
* // Optional embedder hooks (all default no-op):
|
|
@@ -35,20 +35,21 @@ import { generateSessionId, isValidSessionId, } from '../_shared/session-id.js';
|
|
|
35
35
|
import { parseSessionRoute, forwardToSession, renderInvalidSessionHtml, SESSION_ROUTE_PREFIX, LEGACY_PUBLIC_DO_SEGMENT, } from '../_shared/session-router.js';
|
|
36
36
|
import { verifyRequestToken, authErrorResponse, NimbusAuthError, NimbusTokenMalformedError, } from '../auth/index.js';
|
|
37
37
|
import { setCtxExports } from '../session/ctx-exports.js';
|
|
38
|
+
import { handleNimbusRemoteApi, } from './remote-api.js';
|
|
38
39
|
/**
|
|
39
40
|
* Build a Nimbus default-export handler. The returned object is exactly
|
|
40
41
|
* what `export default` expects in a Workers entry module.
|
|
41
42
|
*
|
|
42
43
|
* @example minimal embedder
|
|
43
44
|
* ```ts
|
|
44
|
-
* import { NimbusSession, createNimbusHandler } from '@nimbus-sh/worker';
|
|
45
|
+
* import { NimbusSession, createNimbusHandler } from '@nimbus-sh/sdk/worker';
|
|
45
46
|
* export { NimbusSession };
|
|
46
47
|
* export default createNimbusHandler();
|
|
47
48
|
* ```
|
|
48
49
|
*
|
|
49
50
|
* @example embedder with auth + a custom route
|
|
50
51
|
* ```ts
|
|
51
|
-
* import { NimbusSession, createNimbusHandler } from '@nimbus-sh/worker';
|
|
52
|
+
* import { NimbusSession, createNimbusHandler } from '@nimbus-sh/sdk/worker';
|
|
52
53
|
* import { issueNimbusToken } from '@nimbus-sh/sdk/token';
|
|
53
54
|
*
|
|
54
55
|
* export { NimbusSession };
|
|
@@ -94,6 +95,9 @@ export function createNimbusHandler(options = {}) {
|
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
const url = new URL(request.url);
|
|
98
|
+
const sdkResponse = await handleNimbusRemoteApi(request, env, options.sdk);
|
|
99
|
+
if (sdkResponse)
|
|
100
|
+
return sdkResponse;
|
|
97
101
|
// ── /new — spawn a fresh session and redirect ───────────────────
|
|
98
102
|
if (url.pathname === '/new') {
|
|
99
103
|
if (request.method !== 'POST' && request.method !== 'GET') {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export type NimbusRuntimeName = 'node' | 'bun' | 'npm' | 'git' | 'python' | 'ruby' | 'clang' | 'shell' | (string & {});
|
|
2
|
+
export interface NimbusRuntimePolicy {
|
|
3
|
+
preinstall?: string[];
|
|
4
|
+
onDemand?: boolean;
|
|
5
|
+
allow?: NimbusRuntimeName[];
|
|
6
|
+
}
|
|
7
|
+
export interface NimbusSandboxProfile {
|
|
8
|
+
root?: string;
|
|
9
|
+
runtimes?: NimbusRuntimePolicy;
|
|
10
|
+
tools?: {
|
|
11
|
+
namespace?: string;
|
|
12
|
+
kind?: string;
|
|
13
|
+
};
|
|
14
|
+
preview?: {
|
|
15
|
+
baseUrl?: string;
|
|
16
|
+
pathStyle?: boolean;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface NimbusConfig {
|
|
20
|
+
endpoint?: string;
|
|
21
|
+
sandboxes?: Record<string, NimbusSandboxProfile>;
|
|
22
|
+
}
|
|
23
|
+
export interface NimbusRemoteApiConfig {
|
|
24
|
+
/** Enable the remote programmatic sandbox API. */
|
|
25
|
+
enabled?: boolean;
|
|
26
|
+
/** Route prefix. Defaults to `/api/nimbus/v1`. */
|
|
27
|
+
basePath?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Permit unauthenticated remote calls when JWT_SECRET is absent. This is
|
|
30
|
+
* intended only for private development deployments.
|
|
31
|
+
*/
|
|
32
|
+
allowLegacy?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Required token scopes. Tokens without an explicit `scopes` claim keep the
|
|
35
|
+
* existing full-trust semantics.
|
|
36
|
+
*/
|
|
37
|
+
requiredScopes?: string[];
|
|
38
|
+
}
|
|
39
|
+
export interface NimbusSdkRouterConfig {
|
|
40
|
+
remote?: boolean | NimbusRemoteApiConfig;
|
|
41
|
+
config?: NimbusConfig;
|
|
42
|
+
}
|
|
43
|
+
export declare function handleNimbusRemoteApi(request: Request, env: any, sdk: NimbusSdkRouterConfig | undefined): Promise<Response | null>;
|
|
44
|
+
//# sourceMappingURL=remote-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-api.d.ts","sourceRoot":"","sources":["../../src/router/remote-api.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,iBAAiB,GACzB,MAAM,GACN,KAAK,GACL,KAAK,GACL,KAAK,GACL,QAAQ,GACR,MAAM,GACN,OAAO,GACP,OAAO,GACP,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,MAAM,WAAW,mBAAmB;IAClC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,KAAK,CAAC,EAAE;QACN,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IACF,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,OAAO,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;CAClD;AAED,MAAM,WAAW,qBAAqB;IACpC,kDAAkD;IAClD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,OAAO,GAAG,qBAAqB,CAAC;IACzC,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAqBD,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,qBAAqB,GAAG,SAAS,GACrC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CA8D1B"}
|