@dxos/cli-util 0.9.1-main.c7dcc2e112 → 0.10.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.
@@ -221,7 +221,7 @@ var performRecoveryOAuthFlow = Effect3.fn(function* (params) {
221
221
  method: "POST",
222
222
  headers: {
223
223
  "Content-Type": "application/json",
224
- Origin: server.origin
224
+ "Origin": server.origin
225
225
  },
226
226
  body: JSON.stringify({
227
227
  provider: params.provider,
@@ -486,8 +486,7 @@ import * as Layer2 from "effect/Layer";
486
486
  import * as Option3 from "effect/Option";
487
487
  import { AppSpace } from "@dxos/app-toolkit";
488
488
  import { ClientService as ClientService2 } from "@dxos/client";
489
- import { Database, Feed } from "@dxos/echo";
490
- import { createFeedServiceLayer } from "@dxos/echo-client";
489
+ import { Database } from "@dxos/echo";
491
490
  import { BaseError } from "@dxos/errors";
492
491
  import { log as log2 } from "@dxos/log";
493
492
  import { EdgeReplicationSetting } from "@dxos/protocols/proto/dxos/echo/metadata";
@@ -536,14 +535,7 @@ var spaceLayer = (spaceId$, fallbackToPersonalSpace = false) => {
536
535
  db: space.db
537
536
  };
538
537
  }), (holder) => holder === NO_DB_STUB ? Effect5.void : Effect5.promise(() => holder.db.flush())));
539
- const feed = Layer2.unwrapEffect(Effect5.gen(function* () {
540
- const space = yield* getSpace2();
541
- if (!space) {
542
- return Feed.notAvailable;
543
- }
544
- return createFeedServiceLayer(space.internal.db);
545
- }));
546
- return Layer2.merge(db, feed);
538
+ return db;
547
539
  };
548
540
  var waitForSync = Effect5.fn(function* (space) {
549
541
  if (!isBun()) {
@@ -556,7 +548,7 @@ var waitForSync = Effect5.fn(function* (space) {
556
548
  yield* Effect5.promise(() => space.internal.syncToEdge({
557
549
  onProgress: (state) => log2.info("syncing", {
558
550
  state: state ?? "no connection to edge"
559
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 94, S: this })
551
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 86, S: this })
560
552
  }));
561
553
  yield* Console.log("Sync complete");
562
554
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/oauth/server.ts", "../../../src/util/platform.ts", "../../../src/oauth/recovery.ts", "../../../src/util/form-builder.ts", "../../../src/util/options.ts", "../../../src/util/printer.ts", "../../../src/util/runtime.ts", "../../../src/util/space.ts", "../../../src/util/space-format.ts", "../../../src/util/timeout.ts"],
4
- "sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as BunHttpServer from '@effect/platform-bun/BunHttpServer';\nimport * as HttpRouter from '@effect/platform/HttpRouter';\nimport * as HttpServer from '@effect/platform/HttpServer';\nimport * as HttpServerRequest from '@effect/platform/HttpServerRequest';\nimport * as HttpServerResponse from '@effect/platform/HttpServerResponse';\nimport * as Effect from 'effect/Effect';\nimport * as Exit from 'effect/Exit';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\nimport * as Ref from 'effect/Ref';\nimport * as Scope from 'effect/Scope';\nimport { getPort } from 'get-port-please';\n\nimport { openBrowser } from '../util/platform';\n\n/** Default timeout for a full OAuth browser round-trip. */\nexport const OAUTH_TIMEOUT_MS = 5 * 60 * 1000;\n\n/**\n * Relay page that performs a top-level redirect to Edge's `authUrl`. Edge finalizes the flow\n * by redirecting the browser back to this server's callback path (bsky.social nullifies\n * `window.opener`, so a popup + postMessage relay can't be used).\n */\nconst getRelayPageHtml = (authUrl: string) => `\n<!DOCTYPE html>\n<html>\n<head>\n <meta charset=\"UTF-8\">\n <script>\n window.location.href = '${authUrl.replace(/'/g, \"\\\\'\")}';\n </script>\n</head>\n<body></body>\n</html>\n`;\n\ntype CallbackOutcome = { success: true; params: Record<string, string> } | { success: false; reason: string };\n\n/**\n * A running local OAuth callback server.\n */\nexport type OAuthCallbackServer = {\n /** Port the server is listening on. */\n readonly port: number;\n /** Origin (e.g. `http://localhost:1234`) to advertise to Edge as the redirect target. */\n readonly origin: string;\n /** Opens `authUrl` in the browser via the local relay page. */\n readonly open: (authUrl: string) => Effect.Effect<void, Error>;\n /** Resolves with the captured callback query params, or fails on an `error` param / timeout. */\n readonly waitForResult: (timeoutMs?: number) => Effect.Effect<Record<string, string>, Error>;\n /** Stops the server. */\n readonly stop: () => Effect.Effect<void>;\n};\n\n/**\n * Starts a local Bun HTTP server that relays the browser to Edge's auth URL and captures Edge's\n * eventual top-level redirect back to `callbackPath`. Generic over the callback shape: all query\n * params are captured and returned; an `error` query param fails the wait.\n *\n * Used by both the integration-connect flow (`/redirect/oauth`) and the identity-recovery login\n * flow (`/redirect/oauth-recovery`).\n */\nexport const startOAuthCallbackServer = (callbackPath: `/${string}`): Effect.Effect<OAuthCallbackServer, Error> =>\n Effect.gen(function* () {\n const port = yield* Effect.promise(() => getPort({ random: true }));\n const origin = `http://localhost:${port}`;\n const received = yield* Ref.make(false);\n const outcome = yield* Ref.make<Option.Option<CallbackOutcome>>(Option.none());\n\n // req.url is only the path + query, so reconstruct a full URL to parse the query string.\n const parseUrl = (rawUrl: string) => new URL(rawUrl.startsWith('http') ? rawUrl : `http://localhost${rawUrl}`);\n\n const router = HttpRouter.empty.pipe(\n HttpRouter.get(\n '/oauth-relay',\n Effect.gen(function* () {\n const request = yield* HttpServerRequest.HttpServerRequest;\n const authUrl = parseUrl(request.url).searchParams.get('authUrl');\n if (!authUrl) {\n return yield* HttpServerResponse.text('Missing authUrl parameter', { status: 400 });\n }\n return yield* HttpServerResponse.text(getRelayPageHtml(authUrl), {\n headers: { 'Content-Type': 'text/html' },\n });\n }),\n ),\n HttpRouter.get(\n callbackPath,\n Effect.gen(function* () {\n if (Option.isSome(yield* Ref.get(outcome))) {\n return yield* HttpServerResponse.text('Already received.', { status: 400 });\n }\n\n const request = yield* HttpServerRequest.HttpServerRequest;\n const params = parseUrl(request.url).searchParams;\n const error = params.get('error');\n if (error) {\n yield* Ref.set(outcome, Option.some({ success: false, reason: error }));\n yield* Ref.set(received, true);\n return yield* HttpServerResponse.text(\n `<html><body><h1>Authentication failed</h1><p>${error}</p></body></html>`,\n { status: 400, headers: { 'Content-Type': 'text/html' } },\n );\n }\n\n const captured: Record<string, string> = {};\n for (const [key, value] of params.entries()) {\n captured[key] = value;\n }\n yield* Ref.set(outcome, Option.some({ success: true, params: captured }));\n yield* Ref.set(received, true);\n return yield* HttpServerResponse.text(\n '<html><body><h1>Authentication successful! You can close this window.</h1></body></html>',\n { headers: { 'Content-Type': 'text/html' } },\n );\n }),\n ),\n );\n\n const app = router.pipe(HttpServer.serve());\n const serverLayer = app.pipe(Layer.provide(BunHttpServer.layer({ port })));\n const scope = yield* Scope.make();\n yield* Layer.build(serverLayer).pipe(Scope.extend(scope));\n\n const waitForResult = (timeoutMs: number = OAUTH_TIMEOUT_MS) =>\n Effect.race(\n Effect.gen(function* () {\n while (true) {\n if (yield* Ref.get(received)) {\n break;\n }\n yield* Effect.sleep('500 millis');\n }\n const result = yield* Ref.get(outcome);\n return yield* Option.match(result, {\n onNone: () => Effect.fail(new Error('OAuth callback received but no result')),\n onSome: (value) =>\n value.success\n ? Effect.succeed(value.params)\n : Effect.fail(new Error(`OAuth flow failed: ${value.reason}`)),\n });\n }),\n Effect.sleep(`${timeoutMs} millis`).pipe(Effect.flatMap(() => Effect.fail(new Error('OAuth flow timed out')))),\n );\n\n return {\n port,\n origin,\n open: (authUrl: string) => openBrowser(`${origin}/oauth-relay?authUrl=${encodeURIComponent(authUrl)}`),\n waitForResult,\n stop: () => Scope.close(scope, Exit.void).pipe(Effect.catchAll(() => Effect.void)),\n } satisfies OAuthCallbackServer;\n });\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport { spawn } from 'node:child_process';\n\n/**\n * Copy text to the system clipboard.\n * Supports macOS (pbcopy), Windows (clip), and Linux (xclip/xsel).\n */\nexport const copyToClipboard = (text: string): Effect.Effect<void, Error> =>\n Effect.tryPromise({\n try: () => {\n return new Promise<void>((resolve, reject) => {\n const platform = process.platform;\n let command: string;\n let args: string[];\n\n if (platform === 'darwin') {\n command = 'pbcopy';\n args = [];\n } else if (platform === 'win32') {\n command = 'clip';\n args = [];\n } else {\n // Linux - try xclip or xsel\n command = 'xclip';\n args = ['-selection', 'clipboard'];\n }\n\n const proc = spawn(command, args);\n proc.stdin?.write(text);\n proc.stdin?.end();\n\n proc.on('close', (code) => {\n if (code === 0) {\n resolve();\n } else {\n // Try xsel as fallback on Linux\n if (platform === 'linux') {\n const proc2 = spawn('xsel', ['--clipboard', '--input']);\n proc2.stdin?.write(text);\n proc2.stdin?.end();\n proc2.on('close', (code2) => {\n if (code2 === 0) {\n resolve();\n } else {\n reject(new Error('Failed to copy to clipboard'));\n }\n });\n proc2.on('error', reject);\n } else {\n reject(new Error('Failed to copy to clipboard'));\n }\n }\n });\n\n proc.on('error', reject);\n });\n },\n catch: (error) => new Error(`Failed to copy to clipboard: ${error}`),\n });\n\n/**\n * Open a URL in the system's default browser.\n * Supports macOS (open), Windows (start), and Linux (xdg-open).\n */\nexport const openBrowser = (url: string): Effect.Effect<void, Error> =>\n Effect.tryPromise({\n try: () => {\n return new Promise<void>((resolve, reject) => {\n const platform = process.platform;\n let command: string;\n let args: string[];\n\n if (platform === 'darwin') {\n command = 'open';\n args = [url];\n } else if (platform === 'win32') {\n command = 'start';\n args = [url];\n } else {\n command = 'xdg-open';\n args = [url];\n }\n\n const proc = spawn(command, args);\n proc.on('close', (code) => {\n if (code === 0) {\n resolve();\n } else {\n reject(new Error('Failed to open browser'));\n }\n });\n proc.on('error', reject);\n });\n },\n catch: (error) => new Error(`Failed to open browser: ${error}`),\n });\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { EntityId, SpaceId } from '@dxos/keys';\n\nimport { OAUTH_TIMEOUT_MS, startOAuthCallbackServer } from './server';\n\n/** Path Edge redirects the browser to after a recovery/register OAuth round-trip. */\nconst RECOVERY_CALLBACK_PATH = '/redirect/oauth-recovery';\n\nexport type RecoveryOAuthParams = {\n /** Edge services base URL (from client config `runtime.services.edge.url`). */\n readonly edgeBaseUrl: string;\n /** OAuth provider id (e.g. `'atproto'`). */\n readonly provider: string;\n /** Requested scopes. */\n readonly scopes: readonly string[];\n /** atproto handle or DID — required so Edge can resolve the user's PDS / auth server. */\n readonly loginHint: string;\n};\n\ntype InitiateEnvelope = { success: boolean; data?: { authUrl?: string }; error?: { message?: string } };\n\n/**\n * Drives the gate's OAuth identity-recovery flow from a CLI: starts a local callback server, asks\n * Edge to begin a `recovery`-purpose OAuth flow (advertising the local server as the redirect\n * origin via the `Origin` header), opens the browser, and resolves with the one-time\n * `recoveryProof` Edge carries back in its redirect. The caller redeems the proof via\n * `client.halo.recoverIdentity({ recoveryProof })`.\n *\n * Recovery runs before any identity exists, so no auth header is sent — Edge resolves the user's\n * space / token server-side from the recovery binding, and the `spaceId` / `accessTokenId` in the\n * request are unused (random values satisfy request validation).\n */\nexport const performRecoveryOAuthFlow = Effect.fn(function* (params: RecoveryOAuthParams) {\n const server = yield* startOAuthCallbackServer(RECOVERY_CALLBACK_PATH);\n return yield* Effect.gen(function* () {\n const initiateUrl = new URL('/oauth/initiate', params.edgeBaseUrl).toString();\n const response = yield* Effect.tryPromise({\n try: () =>\n fetch(initiateUrl, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', Origin: server.origin },\n body: JSON.stringify({\n provider: params.provider,\n scopes: params.scopes,\n spaceId: SpaceId.random(),\n accessTokenId: EntityId.random(),\n purpose: 'recovery',\n loginHint: params.loginHint,\n }),\n }),\n catch: (error) =>\n new Error(`OAuth initiate request failed: ${error instanceof Error ? error.message : String(error)}`),\n });\n\n const envelope = yield* Effect.tryPromise({\n try: () => response.json() as Promise<InitiateEnvelope>,\n catch: (error) => new Error(`OAuth initiate response parse failed: ${String(error)}`),\n });\n if (!envelope.success || !envelope.data?.authUrl) {\n return yield* Effect.fail(new Error(`OAuth initiation failed: ${envelope.error?.message ?? 'unknown error'}`));\n }\n\n yield* server.open(envelope.data.authUrl);\n const callbackParams = yield* server.waitForResult(OAUTH_TIMEOUT_MS);\n const recoveryProof = callbackParams.recoveryProof;\n if (!recoveryProof) {\n return yield* Effect.fail(new Error('OAuth recovery completed but no recoveryProof was returned.'));\n }\n return { recoveryProof };\n }).pipe(Effect.ensuring(server.stop()));\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Ansi from '@effect/printer-ansi/Ansi';\nimport * as Doc from '@effect/printer/Doc';\nimport * as Option from 'effect/Option';\nimport * as Pipeable from 'effect/Pipeable';\n\nexport type FormBuilderOptions = {\n title?: string;\n prefix?: string;\n};\n\nexport interface FormBuilder extends Pipeable.Pipeable {\n readonly entries: ReadonlyArray<{ key: string; value: Doc.Doc<any>; isNested?: boolean }>;\n readonly title?: string;\n readonly prefix: string;\n}\n\nclass FormBuilderImpl implements FormBuilder {\n readonly entries: Array<{ key: string; value: Doc.Doc<any>; isNested?: boolean }> = [];\n readonly title?: string;\n readonly prefix: string;\n\n constructor(options: FormBuilderOptions = {}) {\n this.title = options.title;\n this.prefix = options.prefix ?? '- ';\n }\n\n pipe() {\n // eslint-disable-next-line prefer-rest-params\n return Pipeable.pipeArguments(this, arguments);\n }\n}\n\n/**\n * Creates a new FormBuilder instance.\n */\nexport const make = (props?: FormBuilderOptions): FormBuilder => new FormBuilderImpl(props);\n\n// Helper to calculate dimensions for formatting\nconst calculateDimensions = (entries: ReadonlyArray<{ key: string }>, prefix: string) => {\n const maxKeyLen = Math.max(0, ...entries.map((entry) => entry.key.length));\n const targetWidth = prefix.length + maxKeyLen + 2;\n return { maxKeyLen, targetWidth };\n};\n\n// Helper to build a formatted key line\nconst buildKeyLine = (prefix: string, key: string, targetWidth: number) => {\n // Use fill to pad the key to targetWidth.\n // Note: We don't add indentation here; indentation is handled by the parent container or nestImpl.\n return Doc.annotate(Doc.fill(targetWidth)(Doc.text(prefix + key + ': ')), Ansi.blackBright);\n};\n\n// Implementation helper\nconst setImpl = <T>(\n builder: FormBuilder,\n key: string,\n value: T,\n color?: Ansi.Ansi | ((value: T) => Ansi.Ansi),\n): FormBuilder => {\n if (value !== undefined) {\n let valueDoc: Doc.Doc<any>;\n if (typeof value === 'object' && value !== null) {\n // Assume it's a Doc.Doc\n valueDoc = value as unknown as Doc.Doc<any>;\n } else {\n valueDoc = Doc.text(String(value));\n }\n\n if (color) {\n const ansi = typeof color === 'function' ? color(value as T) : color;\n valueDoc = Doc.annotate(valueDoc, ansi);\n }\n\n (builder as FormBuilderImpl).entries.push({\n key,\n value: valueDoc,\n isNested: false,\n });\n }\n return builder;\n};\n\n/**\n * Adds a key-value pair to the form.\n */\nexport function set<T>(\n builder: FormBuilder,\n key: string,\n value: T,\n color?: Ansi.Ansi | ((value: T) => Ansi.Ansi),\n): FormBuilder;\nexport function set<T>(\n key: string,\n value: T,\n color?: Ansi.Ansi | ((value: T) => Ansi.Ansi),\n): (builder: FormBuilder) => FormBuilder;\nexport function set<T>(\n builderOrKey: FormBuilder | string,\n keyOrValue?: string | T,\n valueOrColor?: T | Ansi.Ansi | ((value: T) => Ansi.Ansi),\n color?: Ansi.Ansi | ((value: T) => Ansi.Ansi),\n): FormBuilder | ((builder: FormBuilder) => FormBuilder) {\n if (builderOrKey instanceof FormBuilderImpl) {\n // Direct: set(builder, key, value, color?)\n const builder = builderOrKey;\n const key = keyOrValue as string;\n const value = valueOrColor as T;\n return setImpl(builder, key, value, color);\n } else {\n // Curried: set(key, value, color?)\n const key = builderOrKey as string;\n const value = keyOrValue as T;\n const color = valueOrColor as Ansi.Ansi | ((value: T) => Ansi.Ansi) | undefined;\n return (builder: FormBuilder) => setImpl(builder, key, value, color);\n }\n}\n\n// Implementation helper\nconst nestImpl = (parent: FormBuilder, key: string, builder: FormBuilder): FormBuilder => {\n // Build nested entries without title, directly under the parent field name\n\n // Create a temporary builder without title to ignore it.\n const nestedBuilder: FormBuilder = {\n ...builder,\n title: undefined,\n entries: builder.entries,\n };\n\n // Build content.\n let valueDoc = build(nestedBuilder);\n\n // Indent the content by 2 spaces.\n // This ensures that when this doc is embedded in the parent, it is visually nested.\n valueDoc = Doc.indent(valueDoc, 2);\n\n (parent.entries as Array<{ key: string; value: Doc.Doc<any>; isNested?: boolean }>).push({\n key,\n value: valueDoc,\n isNested: true,\n });\n return parent;\n};\n\n/**\n * Nests another form builder under a key.\n */\nexport function nest(parent: FormBuilder, key: string, builder: FormBuilder): FormBuilder;\nexport function nest(key: string, builder: FormBuilder): (parent: FormBuilder) => FormBuilder;\nexport function nest(\n parentOrKey: FormBuilder | string,\n keyOrBuilder?: string | FormBuilder,\n builder?: FormBuilder,\n): FormBuilder | ((parent: FormBuilder) => FormBuilder) {\n if (parentOrKey instanceof FormBuilderImpl) {\n // Direct: nest(parent, key, builder)\n const parent = parentOrKey;\n const key = keyOrBuilder as string;\n return nestImpl(parent, key, builder!);\n } else {\n // Curried: nest(key, builder)\n const key = parentOrKey as string;\n const builder = keyOrBuilder as FormBuilder;\n return (parent: FormBuilder) => nestImpl(parent, key, builder);\n }\n}\n\n// Implementation helper\nconst optionImpl = <T>(\n builder: FormBuilder,\n key: string,\n value: Option.Option<T>,\n color?: Ansi.Ansi | ((value: T) => Ansi.Ansi),\n): FormBuilder => {\n if (Option.isSome(value)) {\n return setImpl(builder, key, value.value, color);\n }\n return builder;\n};\n\n/**\n * Adds an optional value if it exists.\n */\nexport function option<T>(\n builder: FormBuilder,\n key: string,\n value: Option.Option<T>,\n color?: Ansi.Ansi | ((value: T) => Ansi.Ansi),\n): FormBuilder;\nexport function option<T>(\n key: string,\n value: Option.Option<T>,\n color?: Ansi.Ansi | ((value: T) => Ansi.Ansi),\n): (builder: FormBuilder) => FormBuilder;\nexport function option<T>(\n builderOrKey: FormBuilder | string,\n keyOrValue?: string | Option.Option<T>,\n valueOrColor?: Option.Option<T> | Ansi.Ansi | ((value: T) => Ansi.Ansi),\n color?: Ansi.Ansi | ((value: T) => Ansi.Ansi),\n): FormBuilder | ((builder: FormBuilder) => FormBuilder) {\n if (builderOrKey instanceof FormBuilderImpl) {\n // Direct: option(builder, key, value, color?)\n const builder = builderOrKey;\n const key = keyOrValue as string;\n const value = valueOrColor as Option.Option<T>;\n return optionImpl(builder, key, value, color);\n } else {\n // Curried: option(key, value, color?)\n const key = builderOrKey as string;\n const value = keyOrValue as Option.Option<T>;\n const color = valueOrColor as Ansi.Ansi | ((value: T) => Ansi.Ansi) | undefined;\n return (builder: FormBuilder) => optionImpl(builder, key, value, color);\n }\n}\n\n// Implementation helper\nconst nestedOptionImpl = (builder: FormBuilder, key: string, value: Option.Option<FormBuilder>): FormBuilder => {\n if (Option.isSome(value)) {\n return nestImpl(builder, key, value.value);\n }\n return builder;\n};\n\n/**\n * Nests an optional form builder if it exists.\n */\nexport function nestedOption(builder: FormBuilder, key: string, value: Option.Option<FormBuilder>): FormBuilder;\nexport function nestedOption(key: string, value: Option.Option<FormBuilder>): (builder: FormBuilder) => FormBuilder;\nexport function nestedOption(\n builderOrKey: FormBuilder | string,\n keyOrValue?: string | Option.Option<FormBuilder>,\n value?: Option.Option<FormBuilder>,\n): FormBuilder | ((builder: FormBuilder) => FormBuilder) {\n if (builderOrKey instanceof FormBuilderImpl) {\n // Direct: nestedOption(builder, key, value)\n const builder = builderOrKey;\n const key = keyOrValue as string;\n return nestedOptionImpl(builder, key, value!);\n } else {\n // Curried: nestedOption(key, value)\n const key = builderOrKey as string;\n const value = keyOrValue as Option.Option<FormBuilder>;\n return (builder: FormBuilder) => nestedOptionImpl(builder, key, value);\n }\n}\n\n// Implementation helper\nconst whenImpl = (builder: FormBuilder, condition: any, ...ops: ((b: FormBuilder) => FormBuilder)[]): FormBuilder => {\n if (condition) {\n for (const op of ops) {\n op(builder);\n }\n }\n return builder;\n};\n\n/**\n * Conditionally executes operations.\n */\nexport function when(builder: FormBuilder, condition: any, ...ops: ((b: FormBuilder) => FormBuilder)[]): FormBuilder;\nexport function when(\n condition: any,\n ...ops: ((b: FormBuilder) => FormBuilder)[]\n): (builder: FormBuilder) => FormBuilder;\nexport function when(\n builderOrCondition: FormBuilder | any,\n conditionOrOp?: any | ((b: FormBuilder) => FormBuilder),\n ...ops: ((b: FormBuilder) => FormBuilder)[]\n): FormBuilder | ((builder: FormBuilder) => FormBuilder) {\n if (builderOrCondition instanceof FormBuilderImpl) {\n // Direct: when(builder, condition, ...ops)\n const builder = builderOrCondition;\n const condition = conditionOrOp;\n return whenImpl(builder, condition, ...ops);\n } else {\n // Curried: when(condition, ...ops)\n const condition = builderOrCondition;\n const allOps = [conditionOrOp, ...ops].filter(\n (op): op is (b: FormBuilder) => FormBuilder => typeof op === 'function',\n );\n return (builder: FormBuilder) => whenImpl(builder, condition, ...allOps);\n }\n}\n\n// Implementation helper\nconst eachImpl = <T>(\n builder: FormBuilder,\n items: T[],\n fn: (item: T) => (b: FormBuilder) => FormBuilder,\n): FormBuilder => {\n items.forEach((item) => fn(item)(builder));\n return builder;\n};\n\n/**\n * Iterates over an array of items.\n */\nexport function each<T>(\n builder: FormBuilder,\n items: T[],\n fn: (item: T) => (b: FormBuilder) => FormBuilder,\n): FormBuilder;\nexport function each<T>(\n items: T[],\n fn: (item: T) => (b: FormBuilder) => FormBuilder,\n): (builder: FormBuilder) => FormBuilder;\nexport function each<T>(\n builderOrItems: FormBuilder | T[],\n itemsOrFn?: T[] | ((item: T) => (b: FormBuilder) => FormBuilder),\n fn?: (item: T) => (b: FormBuilder) => FormBuilder,\n): FormBuilder | ((builder: FormBuilder) => FormBuilder) {\n if (builderOrItems instanceof FormBuilderImpl) {\n // Direct: each(builder, items, fn)\n const builder = builderOrItems;\n const items = itemsOrFn as T[];\n return eachImpl(builder, items, fn!);\n } else {\n // Curried: each(items, fn)\n const items = builderOrItems as T[];\n const fn = itemsOrFn as (item: T) => (b: FormBuilder) => FormBuilder;\n return (builder: FormBuilder) => eachImpl(builder, items, fn);\n }\n}\n\n/**\n * Builds the final document.\n */\nexport const build = (builder: FormBuilder): Doc.Doc<any> => {\n const { targetWidth } = calculateDimensions(builder.entries, builder.prefix);\n const entryLines: Doc.Doc<any>[] = [];\n\n builder.entries.forEach(({ key, value, isNested }) => {\n const keyLine = buildKeyLine(builder.prefix, key, targetWidth);\n if (isNested) {\n // Nested content should start on a new line.\n // value is already indented by nestImpl, so we just cat with hardLine.\n entryLines.push(Doc.hcat([keyLine, Doc.hardLine, value]));\n } else {\n // Single-line value, combine key and value.\n // If the value itself is multiline (e.g. from Doc.string with newlines, though Doc handles that specifically),\n // we might want layout flexibility.\n // For now, standard behavior:\n entryLines.push(Doc.hcat([keyLine, value]));\n }\n });\n\n const entriesDoc = Doc.vsep(entryLines);\n\n if (builder.title) {\n const titleDoc = Doc.hcat([Doc.annotate(Doc.text(builder.title), Ansi.combine(Ansi.bold, Ansi.cyan))]);\n // Join title and entries with a single line break, no extra spacing\n return Doc.cat(titleDoc, Doc.cat(Doc.line, entriesDoc));\n }\n\n return entriesDoc;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Options from '@effect/cli/Options';\n\nimport { Key } from '@dxos/echo';\n\n//\n// Common options.\n// NOTE: Sub-commands should Function.pipe(Options.optional) if required.\n//\n\nexport const Common = {\n functionId: Options.text('function-id').pipe(Options.withDescription('EDGE Function ID.')),\n spaceId: Options.text('space-id').pipe(Options.withSchema(Key.SpaceId), Options.withDescription('Space ID.')),\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as AnsiDoc from '@effect/printer-ansi/AnsiDoc';\nimport * as Doc from '@effect/printer/Doc';\n\n/**\n * Pretty print document.\n */\nexport const print = (doc: Doc.Doc<any>) => AnsiDoc.render(doc, { style: 'pretty' });\n\n/**\n * Pretty prints a list of documents with ANSI colors.\n */\nexport const printList = (items: Array<Doc.Doc<any>>) =>\n AnsiDoc.render(Doc.vsep(items.map((item) => Doc.cat(item, Doc.hardLine))), { style: 'pretty' });\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { ClientService } from '@dxos/client';\nimport { type Type } from '@dxos/echo';\n\n/** @deprecated Migrate to providing types via plugin capabilities. */\nexport const withTypes: (...types: Type.AnyEntity[]) => Effect.Effect<void, never, ClientService> = (...types) =>\n Effect.gen(function* () {\n const client = yield* ClientService;\n yield* Effect.promise(() => client.addTypes(types));\n });\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Console from 'effect/Console';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\n\nimport { AppSpace } from '@dxos/app-toolkit';\nimport { ClientService } from '@dxos/client';\nimport { type Space } from '@dxos/client/echo';\nimport { Database, Feed, type Key } from '@dxos/echo';\nimport { createFeedServiceLayer } from '@dxos/echo-client';\nimport { BaseError, type BaseErrorOptions } from '@dxos/errors';\nimport { log } from '@dxos/log';\nimport { EdgeReplicationSetting } from '@dxos/protocols/proto/dxos/echo/metadata';\nimport { isBun } from '@dxos/util';\n\nexport const getSpace = (spaceId: Key.SpaceId): Effect.Effect<Space, SpaceNotFoundError, ClientService> =>\n Effect.gen(function* () {\n const client = yield* ClientService;\n return yield* Option.fromNullable(client.spaces.get(spaceId));\n }).pipe(Effect.catchTag('NoSuchElementException', () => Effect.fail(new SpaceNotFoundError(spaceId))));\n\nexport const spaceIdWithDefault = (spaceId: Option.Option<Key.SpaceId>) =>\n Effect.gen(function* () {\n const client = yield* ClientService;\n return Option.getOrElse(spaceId, () => {\n const personal = AppSpace.getPersonalSpace(client);\n if (!personal) {\n throw new Error('No space ID provided and no personal space found.');\n }\n return personal.id;\n });\n });\n\n// TODO(wittjosiah): Factor out.\nexport const spaceLayer = (\n spaceId$: Option.Option<Key.SpaceId>,\n fallbackToPersonalSpace = false,\n): Layer.Layer<Database.Service | Feed.FeedService, never, ClientService> => {\n const getSpace = Effect.fn(function* () {\n const client = yield* ClientService;\n\n // Resolution order when fallbackToPersonalSpace is true:\n // 1. the explicit spaceId arg (if provided);\n // 2. the space tagged `org.dxos.space.personal`;\n // 3. the first available space.\n // This keeps profiles created outside composer-app (which is what creates\n // the personal-space tag on identity creation) usable — the alternative\n // is a \"Space not found\" throw deep inside CredentialsService.\n const resolveSpace = () => {\n if (!fallbackToPersonalSpace) {\n return spaceId$.pipe(Option.flatMap((id) => Option.fromNullable(client.spaces.get(id))));\n }\n return spaceId$.pipe(\n Option.flatMap((id) => Option.fromNullable(client.spaces.get(id))),\n Option.orElse(() => Option.fromNullable(AppSpace.getPersonalSpace(client))),\n Option.orElse(() => Option.fromNullable(client.spaces.get()[0])),\n );\n };\n\n const space = resolveSpace().pipe(Option.getOrUndefined);\n\n if (space) {\n yield* Effect.promise(() => space.waitUntilReady());\n }\n return space;\n });\n\n // When no space can be resolved we install a stub whose `db` getter throws\n // on access — preserves the existing semantics for commands that *do* need\n // a db — but the release callback must NOT touch `db` or it will throw\n // during teardown (e.g. after a command emits a friendly error and\n // returns early). A shared sentinel object short-circuits the release.\n const NO_DB_STUB = {\n get db(): Database.Database {\n throw new Error('Space not found');\n },\n };\n const db = Layer.scoped(\n Database.Service,\n Effect.acquireRelease(\n Effect.gen(function* () {\n const space = yield* getSpace();\n if (!space) {\n return NO_DB_STUB;\n }\n return { db: space.db };\n }),\n (holder) => (holder === NO_DB_STUB ? Effect.void : Effect.promise(() => holder.db.flush())),\n ),\n );\n\n const feed = Layer.unwrapEffect(\n Effect.gen(function* () {\n const space = yield* getSpace();\n if (!space) {\n return Feed.notAvailable;\n }\n return createFeedServiceLayer(space.internal.db);\n }),\n );\n\n return Layer.merge(db, feed);\n};\n\n// TODO(dmaretskyi): There a race condition with edge connection not showing up.\nexport const waitForSync = Effect.fn(function* (space: Space) {\n // TODO(wittjosiah): Find a better way to do this.\n if (!isBun()) {\n // Skipping sync to edge when not in bun env as this indicates running a test.\n return;\n }\n\n // TODO(wittjosiah): This should probably be prompted for.\n if (space.internal.data.edgeReplication !== EdgeReplicationSetting.ENABLED) {\n yield* Console.log('Edge replication is disabled, enabling...');\n yield* Effect.promise(() => space.internal.setEdgeReplicationPreference(EdgeReplicationSetting.ENABLED));\n }\n\n yield* Effect.promise(() =>\n space.internal.syncToEdge({\n onProgress: (state) => log.info('syncing', { state: state ?? 'no connection to edge' }),\n }),\n );\n yield* Console.log('Sync complete');\n});\n\nexport const flushAndSync = Effect.fn(function* (opts?: Database.FlushOptions) {\n yield* Database.flush(opts);\n const spaceId = yield* Database.spaceId;\n const space = yield* getSpace(spaceId);\n yield* waitForSync(space);\n});\n\n// TODO(burdon): Reconcile with @dxos/protocols\nexport class SpaceNotFoundError extends BaseError.extend('SpaceNotFoundError', 'Space not found') {\n constructor(spaceId: string, options?: Omit<BaseErrorOptions, 'context'>) {\n super({ context: { spaceId }, ...options });\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Duration from 'effect/Duration';\nimport * as Effect from 'effect/Effect';\n\nimport { type Space, SpaceState, type SpaceSyncState } from '@dxos/client/echo';\n\nimport * as FormBuilder from './form-builder';\n\nexport type FormatSpaceOptions = {\n verbose?: boolean;\n truncateKeys?: boolean;\n /**\n * If set, wait up to this many seconds for the space to reach\n * `SPACE_READY` before reading its fields. If unset, read whatever state\n * is available right now — much safer for `space list` etc., where a\n * single stuck space would otherwise hang the entire command.\n */\n waitSeconds?: number;\n};\n\nconst DEFAULT_OPTIONS: Required<FormatSpaceOptions> = {\n verbose: false,\n truncateKeys: false,\n waitSeconds: 0,\n};\n\n/**\n * Per-async-read internal timeout. Some `space.internal.*` getters do\n * filesystem / network IO and can themselves hang on a partially-loaded\n * space; cap each one so the command can never be held hostage by SDK\n * internals.\n */\nconst READ_TIMEOUT_SECONDS = 2;\n\nconst tryWithFallback = <T>(label: string, run: () => Promise<T>, fallback: T) =>\n Effect.tryPromise(run).pipe(\n Effect.timeoutFail({\n duration: Duration.seconds(READ_TIMEOUT_SECONDS),\n onTimeout: () => new Error(`${label} timed out`),\n }),\n Effect.catchAll(() => Effect.succeed(fallback)),\n );\n\nconst tryWithFallbackSync = <T>(read: () => T, fallback: T): T => {\n try {\n return read();\n } catch {\n return fallback;\n }\n};\n\n// TODO(wittjosiah): Use @effect/printer.\nexport const formatSpace = Effect.fn(function* (space: Space, options: FormatSpaceOptions = {}) {\n const { waitSeconds } = { ...DEFAULT_OPTIONS, ...options };\n\n // Opt-in wait. Defaults to NO wait so a single stuck space can't hang\n // an enumeration command (e.g. `dx space list`).\n if (waitSeconds > 0) {\n yield* Effect.tryPromise(() => space.waitUntilReady()).pipe(\n Effect.timeoutFail({\n duration: Duration.seconds(waitSeconds),\n onTimeout: () => new Error('waitUntilReady timed out'),\n }),\n Effect.catchAll(() => Effect.void),\n );\n }\n\n const state = tryWithFallbackSync(() => space.state.get(), SpaceState.SPACE_INITIALIZING);\n const ready = state === SpaceState.SPACE_READY;\n\n // TODO(burdon): Factor out.\n // TODO(burdon): Agent needs to restart before `ready` is available.\n const metrics = tryWithFallbackSync(\n () => space.internal.data.metrics,\n undefined as { open?: Date; ready?: Date } | undefined,\n );\n const startup = metrics?.open && metrics?.ready ? metrics.ready.getTime() - metrics.open.getTime() : undefined;\n\n // TODO(burdon): Get feeds from client-services if verbose (factor out from devtools/diagnostics).\n // const host = client.services.services.DevtoolsHost!;\n const pipeline = tryWithFallbackSync(() => space.internal.data.pipeline, undefined);\n const epoch = pipeline?.currentEpoch?.subject.assertion.number;\n\n // The sync-state read does IO; cap it so a stuck space can't hang the\n // command. Falls back to a \"no peers\" placeholder.\n const syncStateRaw = yield* tryWithFallback('getSyncState', () => space.internal.db.getSyncState(), {\n peers: {},\n } as SpaceSyncState);\n const syncState = aggregateSyncState(syncStateRaw);\n\n const name = ready ? tryWithFallbackSync(() => space.properties.name, undefined) : 'loading...';\n const members = tryWithFallbackSync(() => space.members.get().length, 0);\n const objects = tryWithFallbackSync(() => space.internal.db.getAllObjectIds().length, 0);\n const key = options.truncateKeys\n ? tryWithFallbackSync(() => space.key.truncate(), '')\n : tryWithFallbackSync(() => space.key.toHex(), '');\n\n return {\n id: space.id,\n state: SpaceState[state],\n name,\n\n members,\n objects,\n\n key,\n epoch,\n startup,\n automergeRoot: pipeline?.spaceRootUrl,\n // appliedEpoch,\n syncState: `${syncState.count} ${getSyncIndicator(syncState.up, syncState.down)} (${syncState.peers} peers)`,\n };\n});\n\nconst aggregateSyncState = (syncState: SpaceSyncState) => {\n const peers = Object.keys(syncState.peers ?? {}).length;\n const missingOnLocal = Math.max(...Object.values(syncState.peers ?? {}).map((peer) => peer.missingOnLocal), 0);\n const missingOnRemote = Math.max(...Object.values(syncState.peers ?? {}).map((peer) => peer.missingOnRemote), 0);\n const differentDocuments = Math.max(\n ...Object.values(syncState.peers ?? {}).map((peer) => peer.differentDocuments),\n 0,\n );\n\n return {\n count: missingOnLocal + missingOnRemote + differentDocuments,\n peers,\n up: missingOnRemote > 0 || differentDocuments > 0,\n down: missingOnLocal > 0 || differentDocuments > 0,\n };\n};\n\nconst getSyncIndicator = (up: boolean, down: boolean) => {\n if (up) {\n if (down) {\n return '⇅';\n } else {\n return '↑';\n }\n } else {\n if (down) {\n return '↓';\n } else {\n return '✓';\n }\n }\n};\n\nexport type FormattedSpace = {\n id: string;\n state: string;\n name: string | undefined;\n members: number;\n objects: number;\n key: string;\n epoch: any;\n startup: number | undefined;\n automergeRoot: string | undefined;\n syncState: string;\n};\n\n/**\n * Pretty prints a space with ANSI colors.\n */\nexport const printSpace = (spaceData: FormattedSpace) =>\n FormBuilder.make({ title: spaceData.name ?? spaceData.id }).pipe(\n FormBuilder.set('id', spaceData.id),\n FormBuilder.set('state', spaceData.state),\n FormBuilder.set('key', spaceData.key),\n FormBuilder.set('members', spaceData.members),\n FormBuilder.set('objects', spaceData.objects),\n FormBuilder.set('epoch', spaceData.epoch ?? '<none>'),\n FormBuilder.set('startup', spaceData.startup ? `${spaceData.startup}ms` : '<none>'),\n FormBuilder.set('syncState', spaceData.syncState),\n FormBuilder.set('automergeRoot', spaceData.automergeRoot ?? '<none>'),\n FormBuilder.build,\n );\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Cause from 'effect/Cause';\nimport * as Config from 'effect/Config';\nimport type * as ConfigError from 'effect/ConfigError';\nimport * as Duration from 'effect/Duration';\nimport * as Effect from 'effect/Effect';\nimport * as Option from 'effect/Option';\n\nexport const withTimeout: <A, E, R>(\n effect: Effect.Effect<A, E, R>,\n) => Effect.Effect<A, Cause.TimeoutException | ConfigError.ConfigError | E, R> = Effect.fnUntraced(function* (effect) {\n const timeout = yield* Config.integer('TIMEOUT').pipe(Config.option);\n const duration = timeout.pipe(\n Option.map(Duration.millis),\n Option.getOrElse(() => Duration.infinity),\n );\n return yield* effect.pipe(Effect.timeout(duration));\n});\n"],
5
- "mappings": ";;;;;;;AAIA,YAAYA,mBAAmB;AAC/B,YAAYC,gBAAgB;AAC5B,YAAYC,gBAAgB;AAC5B,YAAYC,uBAAuB;AACnC,YAAYC,wBAAwB;AACpC,YAAYC,aAAY;AACxB,YAAYC,UAAU;AACtB,YAAYC,WAAW;AACvB,YAAYC,YAAY;AACxB,YAAYC,SAAS;AACrB,YAAYC,WAAW;AACvB,SAASC,eAAe;;;ACXxB,YAAYC,YAAY;AACxB,SAASC,aAAa;AAMf,IAAMC,kBAAkB,CAACC,UACvBC,kBAAW;EAChBC,KAAK,MAAA;AACH,WAAO,IAAIC,QAAc,CAACC,SAASC,WAAAA;AACjC,YAAMC,WAAWC,QAAQD;AACzB,UAAIE;AACJ,UAAIC;AAEJ,UAAIH,aAAa,UAAU;AACzBE,kBAAU;AACVC,eAAO,CAAA;MACT,WAAWH,aAAa,SAAS;AAC/BE,kBAAU;AACVC,eAAO,CAAA;MACT,OAAO;AAELD,kBAAU;AACVC,eAAO;UAAC;UAAc;;MACxB;AAEA,YAAMC,OAAOZ,MAAMU,SAASC,IAAAA;AAC5BC,WAAKC,OAAOC,MAAMZ,KAAAA;AAClBU,WAAKC,OAAOE,IAAAA;AAEZH,WAAKI,GAAG,SAAS,CAACC,SAAAA;AAChB,YAAIA,SAAS,GAAG;AACdX,kBAAAA;QACF,OAAO;AAEL,cAAIE,aAAa,SAAS;AACxB,kBAAMU,QAAQ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N,QAAIC,MAAM;AACR,aAAO;IACT,OAAO;AACL,aAAO;IACT;EACF,OAAO;AACL,QAAIA,MAAM;AACR,aAAO;IACT,OAAO;AACL,aAAO;IACT;EACF;AACF;AAkBO,IAAMW,aAAa,CAACC,cACbC,MAAK;EAAEC,OAAOF,UAAU3B,QAAQ2B,UAAUlB;AAAG,CAAA,EAAGlD,KAC9CuE,KAAI,MAAMH,UAAUlB,EAAE,GACtBqB,KAAI,SAASH,UAAUpD,KAAK,GAC5BuD,KAAI,OAAOH,UAAUrB,GAAG,GACxBwB,KAAI,WAAWH,UAAUzB,OAAO,GAChC4B,KAAI,WAAWH,UAAUvB,OAAO,GAChC0B,KAAI,SAASH,UAAUtC,SAAS,QAAA,GAChCyC,KAAI,WAAWH,UAAU1C,UAAU,GAAG0C,UAAU1C,OAAO,OAAO,QAAA,GAC9D6C,KAAI,aAAaH,UAAU7B,SAAS,GACpCgC,KAAI,iBAAiBH,UAAUjB,iBAAiB,QAAA,GAChDqB,MAAK;;;AC5KrB,YAAYC,YAAY;AAExB,YAAYC,eAAc;AAC1B,YAAYC,aAAY;AACxB,YAAYC,aAAY;AAEjB,IAAMC,cAE2EC,mBAAW,WAAWC,QAAM;AAClH,QAAMC,WAAU,OAAcC,eAAQ,SAAA,EAAWC,KAAYC,aAAM;AACnE,QAAMC,WAAWJ,SAAQE,KAChBG,YAAaC,gBAAM,GACnBC,kBAAU,MAAeC,kBAAQ,CAAA;AAE1C,SAAO,OAAOT,OAAOG,KAAYF,gBAAQI,QAAAA,CAAAA;AAC3C,CAAA;",
6
- "names": ["BunHttpServer", "HttpRouter", "HttpServer", "HttpServerRequest", "HttpServerResponse", "Effect", "Exit", "Layer", "Option", "Ref", "Scope", "getPort", "Effect", "spawn", "copyToClipboard", "text", "tryPromise", "try", "Promise", "resolve", "reject", "platform", "process", "command", "args", "proc", "stdin", "write", "end", "on", "code", "proc2", "code2", "Error", "catch", "error", "openBrowser", "url", "OAUTH_TIMEOUT_MS", "getRelayPageHtml", "authUrl", "replace", "startOAuthCallbackServer", "callbackPath", "gen", "port", "promise", "getPort", "random", "origin", "received", "make", "outcome", "none", "parseUrl", "rawUrl", "URL", "startsWith", "router", "empty", "pipe", "get", "request", "HttpServerRequest", "url", "searchParams", "text", "status", "headers", "isSome", "params", "error", "set", "some", "success", "reason", "captured", "key", "value", "entries", "app", "serve", "serverLayer", "provide", "layer", "scope", "build", "extend", "waitForResult", "timeoutMs", "race", "sleep", "result", "match", "onNone", "fail", "Error", "onSome", "succeed", "flatMap", "open", "openBrowser", "encodeURIComponent", "stop", "close", "void", "catchAll", "Effect", "EntityId", "SpaceId", "RECOVERY_CALLBACK_PATH", "performRecoveryOAuthFlow", "fn", "params", "server", "startOAuthCallbackServer", "gen", "initiateUrl", "URL", "edgeBaseUrl", "toString", "response", "tryPromise", "try", "fetch", "method", "headers", "Origin", "origin", "body", "JSON", "stringify", "provider", "scopes", "spaceId", "SpaceId", "random", "accessTokenId", "EntityId", "purpose", "loginHint", "catch", "error", "Error", "message", "String", "envelope", "json", "success", "data", "authUrl", "fail", "open", "callbackParams", "waitForResult", "OAUTH_TIMEOUT_MS", "recoveryProof", "pipe", "ensuring", "stop", "build", "make", "set", "Ansi", "Doc", "Option", "Pipeable", "FormBuilderImpl", "entries", "title", "prefix", "options", "pipe", "pipeArguments", "arguments", "props", "calculateDimensions", "maxKeyLen", "Math", "max", "map", "entry", "key", "length", "targetWidth", "buildKeyLine", "annotate", "fill", "text", "blackBright", "setImpl", "builder", "value", "color", "undefined", "valueDoc", "String", "ansi", "push", "isNested", "builderOrKey", "keyOrValue", "valueOrColor", "nestImpl", "parent", "nestedBuilder", "indent", "nest", "parentOrKey", "keyOrBuilder", "optionImpl", "isSome", "option", "nestedOptionImpl", "nestedOption", "whenImpl", "condition", "ops", "op", "when", "builderOrCondition", "conditionOrOp", "allOps", "filter", "eachImpl", "items", "fn", "forEach", "item", "each", "builderOrItems", "itemsOrFn", "entryLines", "keyLine", "hcat", "hardLine", "entriesDoc", "vsep", "titleDoc", "combine", "bold", "cyan", "cat", "line", "Options", "Key", "Common", "functionId", "text", "pipe", "withDescription", "spaceId", "withSchema", "SpaceId", "AnsiDoc", "Doc", "print", "doc", "render", "style", "printList", "items", "vsep", "map", "item", "cat", "hardLine", "Effect", "ClientService", "withTypes", "types", "gen", "client", "promise", "addTypes", "Console", "Effect", "Layer", "Option", "AppSpace", "ClientService", "Database", "Feed", "createFeedServiceLayer", "BaseError", "log", "EdgeReplicationSetting", "isBun", "getSpace", "client", "get", "pipe", "catchTag", "spaceIdWithDefault", "spaceId", "personal", "Error", "spaceId$", "flatMap", "id", "fromNullable", "spaces", "space", "resolveSpace", "getOrUndefined", "waitUntilReady", "NO_DB_STUB", "holder", "notAvailable", "feed", "promise", "setEdgeReplicationPreference", "internal", "syncToEdge", "state", "flushAndSync", "waitForSync", "context", "options", "Duration", "Effect", "SpaceState", "DEFAULT_OPTIONS", "verbose", "truncateKeys", "waitSeconds", "READ_TIMEOUT_SECONDS", "tryWithFallback", "label", "run", "fallback", "tryPromise", "pipe", "timeoutFail", "duration", "seconds", "onTimeout", "Error", "catchAll", "succeed", "tryWithFallbackSync", "read", "formatSpace", "fn", "space", "options", "waitUntilReady", "void", "state", "get", "SpaceState", "SPACE_INITIALIZING", "ready", "SPACE_READY", "metrics", "internal", "data", "undefined", "startup", "open", "getTime", "pipeline", "epoch", "currentEpoch", "subject", "assertion", "number", "syncStateRaw", "db", "getSyncState", "peers", "syncState", "aggregateSyncState", "name", "properties", "members", "length", "objects", "getAllObjectIds", "key", "truncate", "toHex", "id", "automergeRoot", "spaceRootUrl", "count", "getSyncIndicator", "up", "down", "Object", "keys", "missingOnLocal", "Math", "max", "values", "map", "peer", "missingOnRemote", "differentDocuments", "printSpace", "spaceData", "make", "title", "set", "build", "Config", "Duration", "Effect", "Option", "withTimeout", "fnUntraced", "effect", "timeout", "integer", "pipe", "option", "duration", "map", "millis", "getOrElse", "infinity"]
4
+ "sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as BunHttpServer from '@effect/platform-bun/BunHttpServer';\nimport * as HttpRouter from '@effect/platform/HttpRouter';\nimport * as HttpServer from '@effect/platform/HttpServer';\nimport * as HttpServerRequest from '@effect/platform/HttpServerRequest';\nimport * as HttpServerResponse from '@effect/platform/HttpServerResponse';\nimport * as Effect from 'effect/Effect';\nimport * as Exit from 'effect/Exit';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\nimport * as Ref from 'effect/Ref';\nimport * as Scope from 'effect/Scope';\nimport { getPort } from 'get-port-please';\n\nimport { openBrowser } from '../util/platform';\n\n/** Default timeout for a full OAuth browser round-trip. */\nexport const OAUTH_TIMEOUT_MS = 5 * 60 * 1000;\n\n/**\n * Relay page that performs a top-level redirect to Edge's `authUrl`. Edge finalizes the flow\n * by redirecting the browser back to this server's callback path (bsky.social nullifies\n * `window.opener`, so a popup + postMessage relay can't be used).\n */\nconst getRelayPageHtml = (authUrl: string) => `\n<!DOCTYPE html>\n<html>\n<head>\n <meta charset=\"UTF-8\">\n <script>\n window.location.href = '${authUrl.replace(/'/g, \"\\\\'\")}';\n </script>\n</head>\n<body></body>\n</html>\n`;\n\ntype CallbackOutcome = { success: true; params: Record<string, string> } | { success: false; reason: string };\n\n/**\n * A running local OAuth callback server.\n */\nexport type OAuthCallbackServer = {\n /** Port the server is listening on. */\n readonly port: number;\n /** Origin (e.g. `http://localhost:1234`) to advertise to Edge as the redirect target. */\n readonly origin: string;\n /** Opens `authUrl` in the browser via the local relay page. */\n readonly open: (authUrl: string) => Effect.Effect<void, Error>;\n /** Resolves with the captured callback query params, or fails on an `error` param / timeout. */\n readonly waitForResult: (timeoutMs?: number) => Effect.Effect<Record<string, string>, Error>;\n /** Stops the server. */\n readonly stop: () => Effect.Effect<void>;\n};\n\n/**\n * Starts a local Bun HTTP server that relays the browser to Edge's auth URL and captures Edge's\n * eventual top-level redirect back to `callbackPath`. Generic over the callback shape: all query\n * params are captured and returned; an `error` query param fails the wait.\n *\n * Used by both the integration-connect flow (`/redirect/oauth`) and the identity-recovery login\n * flow (`/redirect/oauth-recovery`).\n */\nexport const startOAuthCallbackServer = (callbackPath: `/${string}`): Effect.Effect<OAuthCallbackServer, Error> =>\n Effect.gen(function* () {\n const port = yield* Effect.promise(() => getPort({ random: true }));\n const origin = `http://localhost:${port}`;\n const received = yield* Ref.make(false);\n const outcome = yield* Ref.make<Option.Option<CallbackOutcome>>(Option.none());\n\n // req.url is only the path + query, so reconstruct a full URL to parse the query string.\n const parseUrl = (rawUrl: string) => new URL(rawUrl.startsWith('http') ? rawUrl : `http://localhost${rawUrl}`);\n\n const router = HttpRouter.empty.pipe(\n HttpRouter.get(\n '/oauth-relay',\n Effect.gen(function* () {\n const request = yield* HttpServerRequest.HttpServerRequest;\n const authUrl = parseUrl(request.url).searchParams.get('authUrl');\n if (!authUrl) {\n return yield* HttpServerResponse.text('Missing authUrl parameter', { status: 400 });\n }\n return yield* HttpServerResponse.text(getRelayPageHtml(authUrl), {\n headers: { 'Content-Type': 'text/html' },\n });\n }),\n ),\n HttpRouter.get(\n callbackPath,\n Effect.gen(function* () {\n if (Option.isSome(yield* Ref.get(outcome))) {\n return yield* HttpServerResponse.text('Already received.', { status: 400 });\n }\n\n const request = yield* HttpServerRequest.HttpServerRequest;\n const params = parseUrl(request.url).searchParams;\n const error = params.get('error');\n if (error) {\n yield* Ref.set(outcome, Option.some({ success: false, reason: error }));\n yield* Ref.set(received, true);\n return yield* HttpServerResponse.text(\n `<html><body><h1>Authentication failed</h1><p>${error}</p></body></html>`,\n { status: 400, headers: { 'Content-Type': 'text/html' } },\n );\n }\n\n const captured: Record<string, string> = {};\n for (const [key, value] of params.entries()) {\n captured[key] = value;\n }\n yield* Ref.set(outcome, Option.some({ success: true, params: captured }));\n yield* Ref.set(received, true);\n return yield* HttpServerResponse.text(\n '<html><body><h1>Authentication successful! You can close this window.</h1></body></html>',\n { headers: { 'Content-Type': 'text/html' } },\n );\n }),\n ),\n );\n\n const app = router.pipe(HttpServer.serve());\n const serverLayer = app.pipe(Layer.provide(BunHttpServer.layer({ port })));\n const scope = yield* Scope.make();\n yield* Layer.build(serverLayer).pipe(Scope.extend(scope));\n\n const waitForResult = (timeoutMs: number = OAUTH_TIMEOUT_MS) =>\n Effect.race(\n Effect.gen(function* () {\n while (true) {\n if (yield* Ref.get(received)) {\n break;\n }\n yield* Effect.sleep('500 millis');\n }\n const result = yield* Ref.get(outcome);\n return yield* Option.match(result, {\n onNone: () => Effect.fail(new Error('OAuth callback received but no result')),\n onSome: (value) =>\n value.success\n ? Effect.succeed(value.params)\n : Effect.fail(new Error(`OAuth flow failed: ${value.reason}`)),\n });\n }),\n Effect.sleep(`${timeoutMs} millis`).pipe(Effect.flatMap(() => Effect.fail(new Error('OAuth flow timed out')))),\n );\n\n return {\n port,\n origin,\n open: (authUrl: string) => openBrowser(`${origin}/oauth-relay?authUrl=${encodeURIComponent(authUrl)}`),\n waitForResult,\n stop: () => Scope.close(scope, Exit.void).pipe(Effect.catchAll(() => Effect.void)),\n } satisfies OAuthCallbackServer;\n });\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport { spawn } from 'node:child_process';\n\n/**\n * Copy text to the system clipboard.\n * Supports macOS (pbcopy), Windows (clip), and Linux (xclip/xsel).\n */\nexport const copyToClipboard = (text: string): Effect.Effect<void, Error> =>\n Effect.tryPromise({\n try: () => {\n return new Promise<void>((resolve, reject) => {\n const platform = process.platform;\n let command: string;\n let args: string[];\n\n if (platform === 'darwin') {\n command = 'pbcopy';\n args = [];\n } else if (platform === 'win32') {\n command = 'clip';\n args = [];\n } else {\n // Linux - try xclip or xsel\n command = 'xclip';\n args = ['-selection', 'clipboard'];\n }\n\n const proc = spawn(command, args);\n proc.stdin?.write(text);\n proc.stdin?.end();\n\n proc.on('close', (code) => {\n if (code === 0) {\n resolve();\n } else {\n // Try xsel as fallback on Linux\n if (platform === 'linux') {\n const proc2 = spawn('xsel', ['--clipboard', '--input']);\n proc2.stdin?.write(text);\n proc2.stdin?.end();\n proc2.on('close', (code2) => {\n if (code2 === 0) {\n resolve();\n } else {\n reject(new Error('Failed to copy to clipboard'));\n }\n });\n proc2.on('error', reject);\n } else {\n reject(new Error('Failed to copy to clipboard'));\n }\n }\n });\n\n proc.on('error', reject);\n });\n },\n catch: (error) => new Error(`Failed to copy to clipboard: ${error}`),\n });\n\n/**\n * Open a URL in the system's default browser.\n * Supports macOS (open), Windows (start), and Linux (xdg-open).\n */\nexport const openBrowser = (url: string): Effect.Effect<void, Error> =>\n Effect.tryPromise({\n try: () => {\n return new Promise<void>((resolve, reject) => {\n const platform = process.platform;\n let command: string;\n let args: string[];\n\n if (platform === 'darwin') {\n command = 'open';\n args = [url];\n } else if (platform === 'win32') {\n command = 'start';\n args = [url];\n } else {\n command = 'xdg-open';\n args = [url];\n }\n\n const proc = spawn(command, args);\n proc.on('close', (code) => {\n if (code === 0) {\n resolve();\n } else {\n reject(new Error('Failed to open browser'));\n }\n });\n proc.on('error', reject);\n });\n },\n catch: (error) => new Error(`Failed to open browser: ${error}`),\n });\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { EntityId, SpaceId } from '@dxos/keys';\n\nimport { OAUTH_TIMEOUT_MS, startOAuthCallbackServer } from './server';\n\n/** Path Edge redirects the browser to after a recovery/register OAuth round-trip. */\nconst RECOVERY_CALLBACK_PATH = '/redirect/oauth-recovery';\n\nexport type RecoveryOAuthParams = {\n /** Edge services base URL (from client config `runtime.services.edge.url`). */\n readonly edgeBaseUrl: string;\n /** OAuth provider id (e.g. `'atproto'`). */\n readonly provider: string;\n /** Requested scopes. */\n readonly scopes: readonly string[];\n /** atproto handle or DID — required so Edge can resolve the user's PDS / auth server. */\n readonly loginHint: string;\n};\n\ntype InitiateEnvelope = { success: boolean; data?: { authUrl?: string }; error?: { message?: string } };\n\n/**\n * Drives the gate's OAuth identity-recovery flow from a CLI: starts a local callback server, asks\n * Edge to begin a `recovery`-purpose OAuth flow (advertising the local server as the redirect\n * origin via the `Origin` header), opens the browser, and resolves with the one-time\n * `recoveryProof` Edge carries back in its redirect. The caller redeems the proof via\n * `client.halo.recoverIdentity({ recoveryProof })`.\n *\n * Recovery runs before any identity exists, so no auth header is sent — Edge resolves the user's\n * space / token server-side from the recovery binding, and the `spaceId` / `accessTokenId` in the\n * request are unused (random values satisfy request validation).\n */\nexport const performRecoveryOAuthFlow = Effect.fn(function* (params: RecoveryOAuthParams) {\n const server = yield* startOAuthCallbackServer(RECOVERY_CALLBACK_PATH);\n return yield* Effect.gen(function* () {\n const initiateUrl = new URL('/oauth/initiate', params.edgeBaseUrl).toString();\n const response = yield* Effect.tryPromise({\n try: () =>\n fetch(initiateUrl, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', 'Origin': server.origin },\n body: JSON.stringify({\n provider: params.provider,\n scopes: params.scopes,\n spaceId: SpaceId.random(),\n accessTokenId: EntityId.random(),\n purpose: 'recovery',\n loginHint: params.loginHint,\n }),\n }),\n catch: (error) =>\n new Error(`OAuth initiate request failed: ${error instanceof Error ? error.message : String(error)}`),\n });\n\n const envelope = yield* Effect.tryPromise({\n try: () => response.json() as Promise<InitiateEnvelope>,\n catch: (error) => new Error(`OAuth initiate response parse failed: ${String(error)}`),\n });\n if (!envelope.success || !envelope.data?.authUrl) {\n return yield* Effect.fail(new Error(`OAuth initiation failed: ${envelope.error?.message ?? 'unknown error'}`));\n }\n\n yield* server.open(envelope.data.authUrl);\n const callbackParams = yield* server.waitForResult(OAUTH_TIMEOUT_MS);\n const recoveryProof = callbackParams.recoveryProof;\n if (!recoveryProof) {\n return yield* Effect.fail(new Error('OAuth recovery completed but no recoveryProof was returned.'));\n }\n return { recoveryProof };\n }).pipe(Effect.ensuring(server.stop()));\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Ansi from '@effect/printer-ansi/Ansi';\nimport * as Doc from '@effect/printer/Doc';\nimport * as Option from 'effect/Option';\nimport * as Pipeable from 'effect/Pipeable';\n\nexport type FormBuilderOptions = {\n title?: string;\n prefix?: string;\n};\n\nexport interface FormBuilder extends Pipeable.Pipeable {\n readonly entries: ReadonlyArray<{ key: string; value: Doc.Doc<any>; isNested?: boolean }>;\n readonly title?: string;\n readonly prefix: string;\n}\n\nclass FormBuilderImpl implements FormBuilder {\n readonly entries: Array<{ key: string; value: Doc.Doc<any>; isNested?: boolean }> = [];\n readonly title?: string;\n readonly prefix: string;\n\n constructor(options: FormBuilderOptions = {}) {\n this.title = options.title;\n this.prefix = options.prefix ?? '- ';\n }\n\n pipe() {\n // eslint-disable-next-line prefer-rest-params\n return Pipeable.pipeArguments(this, arguments);\n }\n}\n\n/**\n * Creates a new FormBuilder instance.\n */\nexport const make = (props?: FormBuilderOptions): FormBuilder => new FormBuilderImpl(props);\n\n// Helper to calculate dimensions for formatting\nconst calculateDimensions = (entries: ReadonlyArray<{ key: string }>, prefix: string) => {\n const maxKeyLen = Math.max(0, ...entries.map((entry) => entry.key.length));\n const targetWidth = prefix.length + maxKeyLen + 2;\n return { maxKeyLen, targetWidth };\n};\n\n// Helper to build a formatted key line\nconst buildKeyLine = (prefix: string, key: string, targetWidth: number) => {\n // Use fill to pad the key to targetWidth.\n // Note: We don't add indentation here; indentation is handled by the parent container or nestImpl.\n return Doc.annotate(Doc.fill(targetWidth)(Doc.text(prefix + key + ': ')), Ansi.blackBright);\n};\n\n// Implementation helper\nconst setImpl = <T>(\n builder: FormBuilder,\n key: string,\n value: T,\n color?: Ansi.Ansi | ((value: T) => Ansi.Ansi),\n): FormBuilder => {\n if (value !== undefined) {\n let valueDoc: Doc.Doc<any>;\n if (typeof value === 'object' && value !== null) {\n // Assume it's a Doc.Doc\n valueDoc = value as unknown as Doc.Doc<any>;\n } else {\n valueDoc = Doc.text(String(value));\n }\n\n if (color) {\n const ansi = typeof color === 'function' ? color(value as T) : color;\n valueDoc = Doc.annotate(valueDoc, ansi);\n }\n\n (builder as FormBuilderImpl).entries.push({\n key,\n value: valueDoc,\n isNested: false,\n });\n }\n return builder;\n};\n\n/**\n * Adds a key-value pair to the form.\n */\nexport function set<T>(\n builder: FormBuilder,\n key: string,\n value: T,\n color?: Ansi.Ansi | ((value: T) => Ansi.Ansi),\n): FormBuilder;\nexport function set<T>(\n key: string,\n value: T,\n color?: Ansi.Ansi | ((value: T) => Ansi.Ansi),\n): (builder: FormBuilder) => FormBuilder;\nexport function set<T>(\n builderOrKey: FormBuilder | string,\n keyOrValue?: string | T,\n valueOrColor?: T | Ansi.Ansi | ((value: T) => Ansi.Ansi),\n color?: Ansi.Ansi | ((value: T) => Ansi.Ansi),\n): FormBuilder | ((builder: FormBuilder) => FormBuilder) {\n if (builderOrKey instanceof FormBuilderImpl) {\n // Direct: set(builder, key, value, color?)\n const builder = builderOrKey;\n const key = keyOrValue as string;\n const value = valueOrColor as T;\n return setImpl(builder, key, value, color);\n } else {\n // Curried: set(key, value, color?)\n const key = builderOrKey as string;\n const value = keyOrValue as T;\n const color = valueOrColor as Ansi.Ansi | ((value: T) => Ansi.Ansi) | undefined;\n return (builder: FormBuilder) => setImpl(builder, key, value, color);\n }\n}\n\n// Implementation helper\nconst nestImpl = (parent: FormBuilder, key: string, builder: FormBuilder): FormBuilder => {\n // Build nested entries without title, directly under the parent field name\n\n // Create a temporary builder without title to ignore it.\n const nestedBuilder: FormBuilder = {\n ...builder,\n title: undefined,\n entries: builder.entries,\n };\n\n // Build content.\n let valueDoc = build(nestedBuilder);\n\n // Indent the content by 2 spaces.\n // This ensures that when this doc is embedded in the parent, it is visually nested.\n valueDoc = Doc.indent(valueDoc, 2);\n\n (parent.entries as Array<{ key: string; value: Doc.Doc<any>; isNested?: boolean }>).push({\n key,\n value: valueDoc,\n isNested: true,\n });\n return parent;\n};\n\n/**\n * Nests another form builder under a key.\n */\nexport function nest(parent: FormBuilder, key: string, builder: FormBuilder): FormBuilder;\nexport function nest(key: string, builder: FormBuilder): (parent: FormBuilder) => FormBuilder;\nexport function nest(\n parentOrKey: FormBuilder | string,\n keyOrBuilder?: string | FormBuilder,\n builder?: FormBuilder,\n): FormBuilder | ((parent: FormBuilder) => FormBuilder) {\n if (parentOrKey instanceof FormBuilderImpl) {\n // Direct: nest(parent, key, builder)\n const parent = parentOrKey;\n const key = keyOrBuilder as string;\n return nestImpl(parent, key, builder!);\n } else {\n // Curried: nest(key, builder)\n const key = parentOrKey as string;\n const builder = keyOrBuilder as FormBuilder;\n return (parent: FormBuilder) => nestImpl(parent, key, builder);\n }\n}\n\n// Implementation helper\nconst optionImpl = <T>(\n builder: FormBuilder,\n key: string,\n value: Option.Option<T>,\n color?: Ansi.Ansi | ((value: T) => Ansi.Ansi),\n): FormBuilder => {\n if (Option.isSome(value)) {\n return setImpl(builder, key, value.value, color);\n }\n return builder;\n};\n\n/**\n * Adds an optional value if it exists.\n */\nexport function option<T>(\n builder: FormBuilder,\n key: string,\n value: Option.Option<T>,\n color?: Ansi.Ansi | ((value: T) => Ansi.Ansi),\n): FormBuilder;\nexport function option<T>(\n key: string,\n value: Option.Option<T>,\n color?: Ansi.Ansi | ((value: T) => Ansi.Ansi),\n): (builder: FormBuilder) => FormBuilder;\nexport function option<T>(\n builderOrKey: FormBuilder | string,\n keyOrValue?: string | Option.Option<T>,\n valueOrColor?: Option.Option<T> | Ansi.Ansi | ((value: T) => Ansi.Ansi),\n color?: Ansi.Ansi | ((value: T) => Ansi.Ansi),\n): FormBuilder | ((builder: FormBuilder) => FormBuilder) {\n if (builderOrKey instanceof FormBuilderImpl) {\n // Direct: option(builder, key, value, color?)\n const builder = builderOrKey;\n const key = keyOrValue as string;\n const value = valueOrColor as Option.Option<T>;\n return optionImpl(builder, key, value, color);\n } else {\n // Curried: option(key, value, color?)\n const key = builderOrKey as string;\n const value = keyOrValue as Option.Option<T>;\n const color = valueOrColor as Ansi.Ansi | ((value: T) => Ansi.Ansi) | undefined;\n return (builder: FormBuilder) => optionImpl(builder, key, value, color);\n }\n}\n\n// Implementation helper\nconst nestedOptionImpl = (builder: FormBuilder, key: string, value: Option.Option<FormBuilder>): FormBuilder => {\n if (Option.isSome(value)) {\n return nestImpl(builder, key, value.value);\n }\n return builder;\n};\n\n/**\n * Nests an optional form builder if it exists.\n */\nexport function nestedOption(builder: FormBuilder, key: string, value: Option.Option<FormBuilder>): FormBuilder;\nexport function nestedOption(key: string, value: Option.Option<FormBuilder>): (builder: FormBuilder) => FormBuilder;\nexport function nestedOption(\n builderOrKey: FormBuilder | string,\n keyOrValue?: string | Option.Option<FormBuilder>,\n value?: Option.Option<FormBuilder>,\n): FormBuilder | ((builder: FormBuilder) => FormBuilder) {\n if (builderOrKey instanceof FormBuilderImpl) {\n // Direct: nestedOption(builder, key, value)\n const builder = builderOrKey;\n const key = keyOrValue as string;\n return nestedOptionImpl(builder, key, value!);\n } else {\n // Curried: nestedOption(key, value)\n const key = builderOrKey as string;\n const value = keyOrValue as Option.Option<FormBuilder>;\n return (builder: FormBuilder) => nestedOptionImpl(builder, key, value);\n }\n}\n\n// Implementation helper\nconst whenImpl = (builder: FormBuilder, condition: any, ...ops: ((b: FormBuilder) => FormBuilder)[]): FormBuilder => {\n if (condition) {\n for (const op of ops) {\n op(builder);\n }\n }\n return builder;\n};\n\n/**\n * Conditionally executes operations.\n */\nexport function when(builder: FormBuilder, condition: any, ...ops: ((b: FormBuilder) => FormBuilder)[]): FormBuilder;\nexport function when(\n condition: any,\n ...ops: ((b: FormBuilder) => FormBuilder)[]\n): (builder: FormBuilder) => FormBuilder;\nexport function when(\n builderOrCondition: FormBuilder | any,\n conditionOrOp?: any | ((b: FormBuilder) => FormBuilder),\n ...ops: ((b: FormBuilder) => FormBuilder)[]\n): FormBuilder | ((builder: FormBuilder) => FormBuilder) {\n if (builderOrCondition instanceof FormBuilderImpl) {\n // Direct: when(builder, condition, ...ops)\n const builder = builderOrCondition;\n const condition = conditionOrOp;\n return whenImpl(builder, condition, ...ops);\n } else {\n // Curried: when(condition, ...ops)\n const condition = builderOrCondition;\n const allOps = [conditionOrOp, ...ops].filter(\n (op): op is (b: FormBuilder) => FormBuilder => typeof op === 'function',\n );\n return (builder: FormBuilder) => whenImpl(builder, condition, ...allOps);\n }\n}\n\n// Implementation helper\nconst eachImpl = <T>(\n builder: FormBuilder,\n items: T[],\n fn: (item: T) => (b: FormBuilder) => FormBuilder,\n): FormBuilder => {\n items.forEach((item) => fn(item)(builder));\n return builder;\n};\n\n/**\n * Iterates over an array of items.\n */\nexport function each<T>(\n builder: FormBuilder,\n items: T[],\n fn: (item: T) => (b: FormBuilder) => FormBuilder,\n): FormBuilder;\nexport function each<T>(\n items: T[],\n fn: (item: T) => (b: FormBuilder) => FormBuilder,\n): (builder: FormBuilder) => FormBuilder;\nexport function each<T>(\n builderOrItems: FormBuilder | T[],\n itemsOrFn?: T[] | ((item: T) => (b: FormBuilder) => FormBuilder),\n fn?: (item: T) => (b: FormBuilder) => FormBuilder,\n): FormBuilder | ((builder: FormBuilder) => FormBuilder) {\n if (builderOrItems instanceof FormBuilderImpl) {\n // Direct: each(builder, items, fn)\n const builder = builderOrItems;\n const items = itemsOrFn as T[];\n return eachImpl(builder, items, fn!);\n } else {\n // Curried: each(items, fn)\n const items = builderOrItems as T[];\n const fn = itemsOrFn as (item: T) => (b: FormBuilder) => FormBuilder;\n return (builder: FormBuilder) => eachImpl(builder, items, fn);\n }\n}\n\n/**\n * Builds the final document.\n */\nexport const build = (builder: FormBuilder): Doc.Doc<any> => {\n const { targetWidth } = calculateDimensions(builder.entries, builder.prefix);\n const entryLines: Doc.Doc<any>[] = [];\n\n builder.entries.forEach(({ key, value, isNested }) => {\n const keyLine = buildKeyLine(builder.prefix, key, targetWidth);\n if (isNested) {\n // Nested content should start on a new line.\n // value is already indented by nestImpl, so we just cat with hardLine.\n entryLines.push(Doc.hcat([keyLine, Doc.hardLine, value]));\n } else {\n // Single-line value, combine key and value.\n // If the value itself is multiline (e.g. from Doc.string with newlines, though Doc handles that specifically),\n // we might want layout flexibility.\n // For now, standard behavior:\n entryLines.push(Doc.hcat([keyLine, value]));\n }\n });\n\n const entriesDoc = Doc.vsep(entryLines);\n\n if (builder.title) {\n const titleDoc = Doc.hcat([Doc.annotate(Doc.text(builder.title), Ansi.combine(Ansi.bold, Ansi.cyan))]);\n // Join title and entries with a single line break, no extra spacing\n return Doc.cat(titleDoc, Doc.cat(Doc.line, entriesDoc));\n }\n\n return entriesDoc;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Options from '@effect/cli/Options';\n\nimport { Key } from '@dxos/echo';\n\n//\n// Common options.\n// NOTE: Sub-commands should Function.pipe(Options.optional) if required.\n//\n\nexport const Common = {\n functionId: Options.text('function-id').pipe(Options.withDescription('EDGE Function ID.')),\n spaceId: Options.text('space-id').pipe(Options.withSchema(Key.SpaceId), Options.withDescription('Space ID.')),\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as AnsiDoc from '@effect/printer-ansi/AnsiDoc';\nimport * as Doc from '@effect/printer/Doc';\n\n/**\n * Pretty print document.\n */\nexport const print = (doc: Doc.Doc<any>) => AnsiDoc.render(doc, { style: 'pretty' });\n\n/**\n * Pretty prints a list of documents with ANSI colors.\n */\nexport const printList = (items: Array<Doc.Doc<any>>) =>\n AnsiDoc.render(Doc.vsep(items.map((item) => Doc.cat(item, Doc.hardLine))), { style: 'pretty' });\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { ClientService } from '@dxos/client';\nimport { type Type } from '@dxos/echo';\n\n/** @deprecated Migrate to providing types via plugin capabilities. */\nexport const withTypes: (...types: Type.AnyEntity[]) => Effect.Effect<void, never, ClientService> = (...types) =>\n Effect.gen(function* () {\n const client = yield* ClientService;\n yield* Effect.promise(() => client.addTypes(types));\n });\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Console from 'effect/Console';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\n\nimport { AppSpace } from '@dxos/app-toolkit';\nimport { ClientService } from '@dxos/client';\nimport { type Space } from '@dxos/client/echo';\nimport { Database, type Key } from '@dxos/echo';\nimport { BaseError, type BaseErrorOptions } from '@dxos/errors';\nimport { log } from '@dxos/log';\nimport { EdgeReplicationSetting } from '@dxos/protocols/proto/dxos/echo/metadata';\nimport { isBun } from '@dxos/util';\n\nexport const getSpace = (spaceId: Key.SpaceId): Effect.Effect<Space, SpaceNotFoundError, ClientService> =>\n Effect.gen(function* () {\n const client = yield* ClientService;\n return yield* Option.fromNullable(client.spaces.get(spaceId));\n }).pipe(Effect.catchTag('NoSuchElementException', () => Effect.fail(new SpaceNotFoundError(spaceId))));\n\nexport const spaceIdWithDefault = (spaceId: Option.Option<Key.SpaceId>) =>\n Effect.gen(function* () {\n const client = yield* ClientService;\n return Option.getOrElse(spaceId, () => {\n const personal = AppSpace.getPersonalSpace(client);\n if (!personal) {\n throw new Error('No space ID provided and no personal space found.');\n }\n return personal.id;\n });\n });\n\n// TODO(wittjosiah): Factor out.\nexport const spaceLayer = (\n spaceId$: Option.Option<Key.SpaceId>,\n fallbackToPersonalSpace = false,\n): Layer.Layer<Database.Service, never, ClientService> => {\n const getSpace = Effect.fn(function* () {\n const client = yield* ClientService;\n\n // Resolution order when fallbackToPersonalSpace is true:\n // 1. the explicit spaceId arg (if provided);\n // 2. the space tagged `org.dxos.space.personal`;\n // 3. the first available space.\n // This keeps profiles created outside composer-app (which is what creates\n // the personal-space tag on identity creation) usable — the alternative\n // is a \"Space not found\" throw deep inside CredentialsService.\n const resolveSpace = () => {\n if (!fallbackToPersonalSpace) {\n return spaceId$.pipe(Option.flatMap((id) => Option.fromNullable(client.spaces.get(id))));\n }\n return spaceId$.pipe(\n Option.flatMap((id) => Option.fromNullable(client.spaces.get(id))),\n Option.orElse(() => Option.fromNullable(AppSpace.getPersonalSpace(client))),\n Option.orElse(() => Option.fromNullable(client.spaces.get()[0])),\n );\n };\n\n const space = resolveSpace().pipe(Option.getOrUndefined);\n\n if (space) {\n yield* Effect.promise(() => space.waitUntilReady());\n }\n return space;\n });\n\n // When no space can be resolved we install a stub whose `db` getter throws\n // on access — preserves the existing semantics for commands that *do* need\n // a db — but the release callback must NOT touch `db` or it will throw\n // during teardown (e.g. after a command emits a friendly error and\n // returns early). A shared sentinel object short-circuits the release.\n const NO_DB_STUB = {\n get db(): Database.Database {\n throw new Error('Space not found');\n },\n };\n const db = Layer.scoped(\n Database.Service,\n Effect.acquireRelease(\n Effect.gen(function* () {\n const space = yield* getSpace();\n if (!space) {\n return NO_DB_STUB;\n }\n return { db: space.db };\n }),\n (holder) => (holder === NO_DB_STUB ? Effect.void : Effect.promise(() => holder.db.flush())),\n ),\n );\n\n return db;\n};\n\n// TODO(dmaretskyi): There a race condition with edge connection not showing up.\nexport const waitForSync = Effect.fn(function* (space: Space) {\n // TODO(wittjosiah): Find a better way to do this.\n if (!isBun()) {\n // Skipping sync to edge when not in bun env as this indicates running a test.\n return;\n }\n\n // TODO(wittjosiah): This should probably be prompted for.\n if (space.internal.data.edgeReplication !== EdgeReplicationSetting.ENABLED) {\n yield* Console.log('Edge replication is disabled, enabling...');\n yield* Effect.promise(() => space.internal.setEdgeReplicationPreference(EdgeReplicationSetting.ENABLED));\n }\n\n yield* Effect.promise(() =>\n space.internal.syncToEdge({\n onProgress: (state) => log.info('syncing', { state: state ?? 'no connection to edge' }),\n }),\n );\n yield* Console.log('Sync complete');\n});\n\nexport const flushAndSync = Effect.fn(function* (opts?: Database.FlushOptions) {\n yield* Database.flush(opts);\n const spaceId = yield* Database.spaceId;\n const space = yield* getSpace(spaceId);\n yield* waitForSync(space);\n});\n\n// TODO(burdon): Reconcile with @dxos/protocols\nexport class SpaceNotFoundError extends BaseError.extend('SpaceNotFoundError', 'Space not found') {\n constructor(spaceId: string, options?: Omit<BaseErrorOptions, 'context'>) {\n super({ context: { spaceId }, ...options });\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Duration from 'effect/Duration';\nimport * as Effect from 'effect/Effect';\n\nimport { type Space, SpaceState, type SpaceSyncState } from '@dxos/client/echo';\n\nimport * as FormBuilder from './form-builder';\n\nexport type FormatSpaceOptions = {\n verbose?: boolean;\n truncateKeys?: boolean;\n /**\n * If set, wait up to this many seconds for the space to reach\n * `SPACE_READY` before reading its fields. If unset, read whatever state\n * is available right now — much safer for `space list` etc., where a\n * single stuck space would otherwise hang the entire command.\n */\n waitSeconds?: number;\n};\n\nconst DEFAULT_OPTIONS: Required<FormatSpaceOptions> = {\n verbose: false,\n truncateKeys: false,\n waitSeconds: 0,\n};\n\n/**\n * Per-async-read internal timeout. Some `space.internal.*` getters do\n * filesystem / network IO and can themselves hang on a partially-loaded\n * space; cap each one so the command can never be held hostage by SDK\n * internals.\n */\nconst READ_TIMEOUT_SECONDS = 2;\n\nconst tryWithFallback = <T>(label: string, run: () => Promise<T>, fallback: T) =>\n Effect.tryPromise(run).pipe(\n Effect.timeoutFail({\n duration: Duration.seconds(READ_TIMEOUT_SECONDS),\n onTimeout: () => new Error(`${label} timed out`),\n }),\n Effect.catchAll(() => Effect.succeed(fallback)),\n );\n\nconst tryWithFallbackSync = <T>(read: () => T, fallback: T): T => {\n try {\n return read();\n } catch {\n return fallback;\n }\n};\n\n// TODO(wittjosiah): Use @effect/printer.\nexport const formatSpace = Effect.fn(function* (space: Space, options: FormatSpaceOptions = {}) {\n const { waitSeconds } = { ...DEFAULT_OPTIONS, ...options };\n\n // Opt-in wait. Defaults to NO wait so a single stuck space can't hang\n // an enumeration command (e.g. `dx space list`).\n if (waitSeconds > 0) {\n yield* Effect.tryPromise(() => space.waitUntilReady()).pipe(\n Effect.timeoutFail({\n duration: Duration.seconds(waitSeconds),\n onTimeout: () => new Error('waitUntilReady timed out'),\n }),\n Effect.catchAll(() => Effect.void),\n );\n }\n\n const state = tryWithFallbackSync(() => space.state.get(), SpaceState.SPACE_INITIALIZING);\n const ready = state === SpaceState.SPACE_READY;\n\n // TODO(burdon): Factor out.\n // TODO(burdon): Agent needs to restart before `ready` is available.\n const metrics = tryWithFallbackSync(\n () => space.internal.data.metrics,\n undefined as { open?: Date; ready?: Date } | undefined,\n );\n const startup = metrics?.open && metrics?.ready ? metrics.ready.getTime() - metrics.open.getTime() : undefined;\n\n // TODO(burdon): Get feeds from client-services if verbose (factor out from devtools/diagnostics).\n // const host = client.services.services.DevtoolsHost!;\n const pipeline = tryWithFallbackSync(() => space.internal.data.pipeline, undefined);\n const epoch = pipeline?.currentEpoch?.subject.assertion.number;\n\n // The sync-state read does IO; cap it so a stuck space can't hang the\n // command. Falls back to a \"no peers\" placeholder.\n const syncStateRaw = yield* tryWithFallback('getSyncState', () => space.internal.db.getSyncState(), {\n peers: {},\n } as SpaceSyncState);\n const syncState = aggregateSyncState(syncStateRaw);\n\n const name = ready ? tryWithFallbackSync(() => space.properties.name, undefined) : 'loading...';\n const members = tryWithFallbackSync(() => space.members.get().length, 0);\n const objects = tryWithFallbackSync(() => space.internal.db.getAllObjectIds().length, 0);\n const key = options.truncateKeys\n ? tryWithFallbackSync(() => space.key.truncate(), '')\n : tryWithFallbackSync(() => space.key.toHex(), '');\n\n return {\n id: space.id,\n state: SpaceState[state],\n name,\n\n members,\n objects,\n\n key,\n epoch,\n startup,\n automergeRoot: pipeline?.spaceRootUrl,\n // appliedEpoch,\n syncState: `${syncState.count} ${getSyncIndicator(syncState.up, syncState.down)} (${syncState.peers} peers)`,\n };\n});\n\nconst aggregateSyncState = (syncState: SpaceSyncState) => {\n const peers = Object.keys(syncState.peers ?? {}).length;\n const missingOnLocal = Math.max(...Object.values(syncState.peers ?? {}).map((peer) => peer.missingOnLocal), 0);\n const missingOnRemote = Math.max(...Object.values(syncState.peers ?? {}).map((peer) => peer.missingOnRemote), 0);\n const differentDocuments = Math.max(\n ...Object.values(syncState.peers ?? {}).map((peer) => peer.differentDocuments),\n 0,\n );\n\n return {\n count: missingOnLocal + missingOnRemote + differentDocuments,\n peers,\n up: missingOnRemote > 0 || differentDocuments > 0,\n down: missingOnLocal > 0 || differentDocuments > 0,\n };\n};\n\nconst getSyncIndicator = (up: boolean, down: boolean) => {\n if (up) {\n if (down) {\n return '⇅';\n } else {\n return '↑';\n }\n } else {\n if (down) {\n return '↓';\n } else {\n return '✓';\n }\n }\n};\n\nexport type FormattedSpace = {\n id: string;\n state: string;\n name: string | undefined;\n members: number;\n objects: number;\n key: string;\n epoch: any;\n startup: number | undefined;\n automergeRoot: string | undefined;\n syncState: string;\n};\n\n/**\n * Pretty prints a space with ANSI colors.\n */\nexport const printSpace = (spaceData: FormattedSpace) =>\n FormBuilder.make({ title: spaceData.name ?? spaceData.id }).pipe(\n FormBuilder.set('id', spaceData.id),\n FormBuilder.set('state', spaceData.state),\n FormBuilder.set('key', spaceData.key),\n FormBuilder.set('members', spaceData.members),\n FormBuilder.set('objects', spaceData.objects),\n FormBuilder.set('epoch', spaceData.epoch ?? '<none>'),\n FormBuilder.set('startup', spaceData.startup ? `${spaceData.startup}ms` : '<none>'),\n FormBuilder.set('syncState', spaceData.syncState),\n FormBuilder.set('automergeRoot', spaceData.automergeRoot ?? '<none>'),\n FormBuilder.build,\n );\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Cause from 'effect/Cause';\nimport * as Config from 'effect/Config';\nimport type * as ConfigError from 'effect/ConfigError';\nimport * as Duration from 'effect/Duration';\nimport * as Effect from 'effect/Effect';\nimport * as Option from 'effect/Option';\n\nexport const withTimeout: <A, E, R>(\n effect: Effect.Effect<A, E, R>,\n) => Effect.Effect<A, Cause.TimeoutException | ConfigError.ConfigError | E, R> = Effect.fnUntraced(function* (effect) {\n const timeout = yield* Config.integer('TIMEOUT').pipe(Config.option);\n const duration = timeout.pipe(\n Option.map(Duration.millis),\n Option.getOrElse(() => Duration.infinity),\n );\n return yield* effect.pipe(Effect.timeout(duration));\n});\n"],
5
+ "mappings": ";;;;;;;AAIA,YAAYA,mBAAmB;AAC/B,YAAYC,gBAAgB;AAC5B,YAAYC,gBAAgB;AAC5B,YAAYC,uBAAuB;AACnC,YAAYC,wBAAwB;AACp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EjB,IAAMC,cAE2EC,mBAAW,WAAWC,QAAM;AAClH,QAAMC,WAAU,OAAcC,eAAQ,SAAA,EAAWC,KAAYC,aAAM;AACnE,QAAMC,WAAWJ,SAAQE,KAChBG,YAAaC,gBAAM,GACnBC,kBAAU,MAAeC,kBAAQ,CAAA;AAE1C,SAAO,OAAOT,OAAOG,KAAYF,gBAAQI,QAAAA,CAAAA;AAC3C,CAAA;",
6
+ "names": ["BunHttpServer", "HttpRouter", "HttpServer", "HttpServerRequest", "HttpServerResponse", "Effect", "Exit", "Layer", "Option", "Ref", "Scope", "getPort", "Effect", "spawn", "copyToClipboard", "text", "tryPromise", "try", "Promise", "resolve", "reject", "platform", "process", "command", "args", "proc", "stdin", "write", "end", "on", "code", "proc2", "code2", "Error", "catch", "error", "openBrowser", "url", "OAUTH_TIMEOUT_MS", "getRelayPageHtml", "authUrl", "replace", "startOAuthCallbackServer", "callbackPath", "gen", "port", "promise", "getPort", "random", "origin", "received", "make", "outcome", "none", "parseUrl", "rawUrl", "URL", "startsWith", "router", "empty", "pipe", "get", "request", "HttpServerRequest", "url", "searchParams", "text", "status", "headers", "isSome", "params", "error", "set", "some", "success", "reason", "captured", "key", "value", "entries", "app", "serve", "serverLayer", "provide", "layer", "scope", "build", "extend", "waitForResult", "timeoutMs", "race", "sleep", "result", "match", "onNone", "fail", "Error", "onSome", "succeed", "flatMap", "open", "openBrowser", "encodeURIComponent", "stop", "close", "void", "catchAll", "Effect", "EntityId", "SpaceId", "RECOVERY_CALLBACK_PATH", "performRecoveryOAuthFlow", "fn", "params", "server", "startOAuthCallbackServer", "gen", "initiateUrl", "URL", "edgeBaseUrl", "toString", "response", "tryPromise", "try", "fetch", "method", "headers", "origin", "body", "JSON", "stringify", "provider", "scopes", "spaceId", "SpaceId", "random", "accessTokenId", "EntityId", "purpose", "loginHint", "catch", "error", "Error", "message", "String", "envelope", "json", "success", "data", "authUrl", "fail", "open", "callbackParams", "waitForResult", "OAUTH_TIMEOUT_MS", "recoveryProof", "pipe", "ensuring", "stop", "build", "make", "set", "Ansi", "Doc", "Option", "Pipeable", "FormBuilderImpl", "entries", "title", "prefix", "options", "pipe", "pipeArguments", "arguments", "props", "calculateDimensions", "maxKeyLen", "Math", "max", "map", "entry", "key", "length", "targetWidth", "buildKeyLine", "annotate", "fill", "text", "blackBright", "setImpl", "builder", "value", "color", "undefined", "valueDoc", "String", "ansi", "push", "isNested", "builderOrKey", "keyOrValue", "valueOrColor", "nestImpl", "parent", "nestedBuilder", "indent", "nest", "parentOrKey", "keyOrBuilder", "optionImpl", "isSome", "option", "nestedOptionImpl", "nestedOption", "whenImpl", "condition", "ops", "op", "when", "builderOrCondition", "conditionOrOp", "allOps", "filter", "eachImpl", "items", "fn", "forEach", "item", "each", "builderOrItems", "itemsOrFn", "entryLines", "keyLine", "hcat", "hardLine", "entriesDoc", "vsep", "titleDoc", "combine", "bold", "cyan", "cat", "line", "Options", "Key", "Common", "functionId", "text", "pipe", "withDescription", "spaceId", "withSchema", "SpaceId", "AnsiDoc", "Doc", "print", "doc", "render", "style", "printList", "items", "vsep", "map", "item", "cat", "hardLine", "Effect", "ClientService", "withTypes", "types", "gen", "client", "promise", "addTypes", "Console", "Effect", "Layer", "Option", "AppSpace", "ClientService", "Database", "BaseError", "log", "EdgeReplicationSetting", "isBun", "getSpace", "client", "get", "pipe", "catchTag", "spaceIdWithDefault", "spaceId", "personal", "Error", "spaceId$", "flatMap", "id", "fromNullable", "spaces", "space", "resolveSpace", "getOrUndefined", "waitUntilReady", "NO_DB_STUB", "holder", "promise", "setEdgeReplicationPreference", "internal", "syncToEdge", "state", "flushAndSync", "waitForSync", "context", "options", "Duration", "Effect", "SpaceState", "DEFAULT_OPTIONS", "verbose", "truncateKeys", "waitSeconds", "READ_TIMEOUT_SECONDS", "tryWithFallback", "label", "run", "fallback", "tryPromise", "pipe", "timeoutFail", "duration", "seconds", "onTimeout", "Error", "catchAll", "succeed", "tryWithFallbackSync", "read", "formatSpace", "fn", "space", "options", "waitUntilReady", "void", "state", "get", "SpaceState", "SPACE_INITIALIZING", "ready", "SPACE_READY", "metrics", "internal", "data", "undefined", "startup", "open", "getTime", "pipeline", "epoch", "currentEpoch", "subject", "assertion", "number", "syncStateRaw", "db", "getSyncState", "peers", "syncState", "aggregateSyncState", "name", "properties", "members", "length", "objects", "getAllObjectIds", "key", "truncate", "toHex", "id", "automergeRoot", "spaceRootUrl", "count", "getSyncIndicator", "up", "down", "Object", "keys", "missingOnLocal", "Math", "max", "values", "map", "peer", "missingOnRemote", "differentDocuments", "printSpace", "spaceData", "make", "title", "set", "build", "Config", "Duration", "Effect", "Option", "withTimeout", "fnUntraced", "effect", "timeout", "integer", "pipe", "option", "duration", "map", "millis", "getOrElse", "infinity"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"src/util/platform.ts":{"bytes":10187,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true}],"format":"esm"},"src/oauth/server.ts":{"bytes":19994,"imports":[{"path":"@effect/platform-bun/BunHttpServer","kind":"import-statement","external":true},{"path":"@effect/platform/HttpRouter","kind":"import-statement","external":true},{"path":"@effect/platform/HttpServer","kind":"import-statement","external":true},{"path":"@effect/platform/HttpServerRequest","kind":"import-statement","external":true},{"path":"@effect/platform/HttpServerResponse","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Exit","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Ref","kind":"import-statement","external":true},{"path":"effect/Scope","kind":"import-statement","external":true},{"path":"get-port-please","kind":"import-statement","external":true},{"path":"src/util/platform.ts","kind":"import-statement","original":"../util/platform"}],"format":"esm"},"src/oauth/recovery.ts":{"bytes":10184,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"src/oauth/server.ts","kind":"import-statement","original":"./server"}],"format":"esm"},"src/oauth/index.ts":{"bytes":458,"imports":[{"path":"src/oauth/server.ts","kind":"import-statement","original":"./server"},{"path":"src/oauth/recovery.ts","kind":"import-statement","original":"./recovery"}],"format":"esm"},"src/services/command-config.ts":{"bytes":2476,"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true}],"format":"esm"},"src/services/index.ts":{"bytes":394,"imports":[{"path":"src/services/command-config.ts","kind":"import-statement","original":"./command-config"}],"format":"esm"},"src/util/form-builder.ts":{"bytes":31705,"imports":[{"path":"@effect/printer-ansi/Ansi","kind":"import-statement","external":true},{"path":"@effect/printer/Doc","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Pipeable","kind":"import-statement","external":true}],"format":"esm"},"src/util/options.ts":{"bytes":1802,"imports":[{"path":"@effect/cli/Options","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true}],"format":"esm"},"src/util/printer.ts":{"bytes":1861,"imports":[{"path":"@effect/printer-ansi/AnsiDoc","kind":"import-statement","external":true},{"path":"@effect/printer/Doc","kind":"import-statement","external":true}],"format":"esm"},"src/util/runtime.ts":{"bytes":1612,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true}],"format":"esm"},"src/util/space.ts":{"bytes":17825,"imports":[{"path":"effect/Console","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"@dxos/app-toolkit","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-client","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto/dxos/echo/metadata","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/util/space-format.ts":{"bytes":19288,"imports":[{"path":"effect/Duration","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"src/util/form-builder.ts","kind":"import-statement","original":"./form-builder"}],"format":"esm"},"src/util/timeout.ts":{"bytes":2449,"imports":[{"path":"effect/Config","kind":"import-statement","external":true},{"path":"effect/Duration","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true}],"format":"esm"},"src/util/index.ts":{"bytes":1072,"imports":[{"path":"src/util/form-builder.ts","kind":"import-statement","original":"./form-builder"},{"path":"src/util/options.ts","kind":"import-statement","original":"./options"},{"path":"src/util/platform.ts","kind":"import-statement","original":"./platform"},{"path":"src/util/printer.ts","kind":"import-statement","original":"./printer"},{"path":"src/util/runtime.ts","kind":"import-statement","original":"./runtime"},{"path":"src/util/space.ts","kind":"import-statement","original":"./space"},{"path":"src/util/space-format.ts","kind":"import-statement","original":"./space-format"},{"path":"src/util/timeout.ts","kind":"import-statement","original":"./timeout"}],"format":"esm"},"src/index.ts":{"bytes":537,"imports":[{"path":"src/oauth/index.ts","kind":"import-statement","original":"./oauth"},{"path":"src/services/index.ts","kind":"import-statement","original":"./services"},{"path":"src/util/index.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"src/testing/test-console.ts":{"bytes":7664,"imports":[{"path":"effect/Console","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"node:util","kind":"import-statement","external":true}],"format":"esm"},"src/testing/test-layer.ts":{"bytes":1932,"imports":[{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"src/services/index.ts","kind":"import-statement","original":"../services"},{"path":"src/testing/test-console.ts","kind":"import-statement","original":"./test-console"}],"format":"esm"},"src/testing/index.ts":{"bytes":482,"imports":[{"path":"src/testing/test-console.ts","kind":"import-statement","original":"./test-console"},{"path":"src/testing/test-layer.ts","kind":"import-statement","original":"./test-layer"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":59148},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-N5LOOWPE.mjs","kind":"import-statement"},{"path":"@effect/platform-bun/BunHttpServer","kind":"import-statement","external":true},{"path":"@effect/platform/HttpRouter","kind":"import-statement","external":true},{"path":"@effect/platform/HttpServer","kind":"import-statement","external":true},{"path":"@effect/platform/HttpServerRequest","kind":"import-statement","external":true},{"path":"@effect/platform/HttpServerResponse","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Exit","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Ref","kind":"import-statement","external":true},{"path":"effect/Scope","kind":"import-statement","external":true},{"path":"get-port-please","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@effect/printer-ansi/Ansi","kind":"import-statement","external":true},{"path":"@effect/printer/Doc","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Pipeable","kind":"import-statement","external":true},{"path":"@effect/cli/Options","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@effect/printer-ansi/AnsiDoc","kind":"import-statement","external":true},{"path":"@effect/printer/Doc","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"effect/Console","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"@dxos/app-toolkit","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-client","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto/dxos/echo/metadata","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"effect/Duration","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"effect/Config","kind":"import-statement","external":true},{"path":"effect/Duration","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true}],"exports":["CommandConfig","Common","FormBuilder","OAUTH_TIMEOUT_MS","SpaceNotFoundError","copyToClipboard","flushAndSync","formatSpace","getSpace","openBrowser","performRecoveryOAuthFlow","print","printList","printSpace","spaceIdWithDefault","spaceLayer","startOAuthCallbackServer","waitForSync","withTimeout","withTypes"],"entryPoint":"src/index.ts","inputs":{"src/oauth/server.ts":{"bytesInOutput":4111},"src/util/platform.ts":{"bytesInOutput":2302},"src/oauth/recovery.ts":{"bytesInOutput":1804},"src/index.ts":{"bytesInOutput":0},"src/util/form-builder.ts":{"bytesInOutput":5599},"src/util/index.ts":{"bytesInOutput":0},"src/util/options.ts":{"bytesInOutput":306},"src/util/printer.ts":{"bytesInOutput":296},"src/util/runtime.ts":{"bytesInOutput":244},"src/util/space.ts":{"bytesInOutput":3733},"src/util/space-format.ts":{"bytesInOutput":3775},"src/util/timeout.ts":{"bytesInOutput":472}},"bytes":23479},"dist/lib/node-esm/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5091},"dist/lib/node-esm/testing/index.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-N5LOOWPE.mjs","kind":"import-statement"},{"path":"effect/Console","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"node:util","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true}],"exports":["TestConsole","TestLayer"],"entryPoint":"src/testing/index.ts","inputs":{"src/testing/test-console.ts":{"bytesInOutput":1754},"src/testing/index.ts":{"bytesInOutput":0},"src/testing/test-layer.ts":{"bytesInOutput":332}},"bytes":2371},"dist/lib/node-esm/chunk-N5LOOWPE.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1399},"dist/lib/node-esm/chunk-N5LOOWPE.mjs":{"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true}],"exports":["CommandConfig","__export"],"inputs":{"src/services/command-config.ts":{"bytesInOutput":506}},"bytes":885}}}
1
+ {"inputs":{"src/util/platform.ts":{"bytes":10187,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true}],"format":"esm"},"src/oauth/server.ts":{"bytes":19994,"imports":[{"path":"@effect/platform-bun/BunHttpServer","kind":"import-statement","external":true},{"path":"@effect/platform/HttpRouter","kind":"import-statement","external":true},{"path":"@effect/platform/HttpServer","kind":"import-statement","external":true},{"path":"@effect/platform/HttpServerRequest","kind":"import-statement","external":true},{"path":"@effect/platform/HttpServerResponse","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Exit","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Ref","kind":"import-statement","external":true},{"path":"effect/Scope","kind":"import-statement","external":true},{"path":"get-port-please","kind":"import-statement","external":true},{"path":"src/util/platform.ts","kind":"import-statement","original":"../util/platform"}],"format":"esm"},"src/oauth/recovery.ts":{"bytes":10174,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"src/oauth/server.ts","kind":"import-statement","original":"./server"}],"format":"esm"},"src/oauth/index.ts":{"bytes":458,"imports":[{"path":"src/oauth/server.ts","kind":"import-statement","original":"./server"},{"path":"src/oauth/recovery.ts","kind":"import-statement","original":"./recovery"}],"format":"esm"},"src/services/command-config.ts":{"bytes":2476,"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true}],"format":"esm"},"src/services/index.ts":{"bytes":394,"imports":[{"path":"src/services/command-config.ts","kind":"import-statement","original":"./command-config"}],"format":"esm"},"src/util/form-builder.ts":{"bytes":31705,"imports":[{"path":"@effect/printer-ansi/Ansi","kind":"import-statement","external":true},{"path":"@effect/printer/Doc","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Pipeable","kind":"import-statement","external":true}],"format":"esm"},"src/util/options.ts":{"bytes":1802,"imports":[{"path":"@effect/cli/Options","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true}],"format":"esm"},"src/util/printer.ts":{"bytes":1861,"imports":[{"path":"@effect/printer-ansi/AnsiDoc","kind":"import-statement","external":true},{"path":"@effect/printer/Doc","kind":"import-statement","external":true}],"format":"esm"},"src/util/runtime.ts":{"bytes":1612,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true}],"format":"esm"},"src/util/space.ts":{"bytes":16593,"imports":[{"path":"effect/Console","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"@dxos/app-toolkit","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto/dxos/echo/metadata","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/util/space-format.ts":{"bytes":19288,"imports":[{"path":"effect/Duration","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"src/util/form-builder.ts","kind":"import-statement","original":"./form-builder"}],"format":"esm"},"src/util/timeout.ts":{"bytes":2449,"imports":[{"path":"effect/Config","kind":"import-statement","external":true},{"path":"effect/Duration","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true}],"format":"esm"},"src/util/index.ts":{"bytes":1072,"imports":[{"path":"src/util/form-builder.ts","kind":"import-statement","original":"./form-builder"},{"path":"src/util/options.ts","kind":"import-statement","original":"./options"},{"path":"src/util/platform.ts","kind":"import-statement","original":"./platform"},{"path":"src/util/printer.ts","kind":"import-statement","original":"./printer"},{"path":"src/util/runtime.ts","kind":"import-statement","original":"./runtime"},{"path":"src/util/space.ts","kind":"import-statement","original":"./space"},{"path":"src/util/space-format.ts","kind":"import-statement","original":"./space-format"},{"path":"src/util/timeout.ts","kind":"import-statement","original":"./timeout"}],"format":"esm"},"src/index.ts":{"bytes":537,"imports":[{"path":"src/oauth/index.ts","kind":"import-statement","original":"./oauth"},{"path":"src/services/index.ts","kind":"import-statement","original":"./services"},{"path":"src/util/index.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"src/testing/test-console.ts":{"bytes":7664,"imports":[{"path":"effect/Console","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"node:util","kind":"import-statement","external":true}],"format":"esm"},"src/testing/test-layer.ts":{"bytes":1932,"imports":[{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"src/services/index.ts","kind":"import-statement","original":"../services"},{"path":"src/testing/test-console.ts","kind":"import-statement","original":"./test-console"}],"format":"esm"},"src/testing/index.ts":{"bytes":482,"imports":[{"path":"src/testing/test-console.ts","kind":"import-statement","original":"./test-console"},{"path":"src/testing/test-layer.ts","kind":"import-statement","original":"./test-layer"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":58537},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-N5LOOWPE.mjs","kind":"import-statement"},{"path":"@effect/platform-bun/BunHttpServer","kind":"import-statement","external":true},{"path":"@effect/platform/HttpRouter","kind":"import-statement","external":true},{"path":"@effect/platform/HttpServer","kind":"import-statement","external":true},{"path":"@effect/platform/HttpServerRequest","kind":"import-statement","external":true},{"path":"@effect/platform/HttpServerResponse","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Exit","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Ref","kind":"import-statement","external":true},{"path":"effect/Scope","kind":"import-statement","external":true},{"path":"get-port-please","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@effect/printer-ansi/Ansi","kind":"import-statement","external":true},{"path":"@effect/printer/Doc","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Pipeable","kind":"import-statement","external":true},{"path":"@effect/cli/Options","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@effect/printer-ansi/AnsiDoc","kind":"import-statement","external":true},{"path":"@effect/printer/Doc","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"effect/Console","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"@dxos/app-toolkit","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto/dxos/echo/metadata","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"effect/Duration","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"effect/Config","kind":"import-statement","external":true},{"path":"effect/Duration","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true}],"exports":["CommandConfig","Common","FormBuilder","OAUTH_TIMEOUT_MS","SpaceNotFoundError","copyToClipboard","flushAndSync","formatSpace","getSpace","openBrowser","performRecoveryOAuthFlow","print","printList","printSpace","spaceIdWithDefault","spaceLayer","startOAuthCallbackServer","waitForSync","withTimeout","withTypes"],"entryPoint":"src/index.ts","inputs":{"src/oauth/server.ts":{"bytesInOutput":4111},"src/util/platform.ts":{"bytesInOutput":2302},"src/oauth/recovery.ts":{"bytesInOutput":1806},"src/index.ts":{"bytesInOutput":0},"src/util/form-builder.ts":{"bytesInOutput":5599},"src/util/index.ts":{"bytesInOutput":0},"src/util/options.ts":{"bytesInOutput":306},"src/util/printer.ts":{"bytesInOutput":296},"src/util/runtime.ts":{"bytesInOutput":244},"src/util/space.ts":{"bytesInOutput":3430},"src/util/space-format.ts":{"bytesInOutput":3775},"src/util/timeout.ts":{"bytesInOutput":472}},"bytes":23178},"dist/lib/node-esm/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5091},"dist/lib/node-esm/testing/index.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-N5LOOWPE.mjs","kind":"import-statement"},{"path":"effect/Console","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"node:util","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true}],"exports":["TestConsole","TestLayer"],"entryPoint":"src/testing/index.ts","inputs":{"src/testing/test-console.ts":{"bytesInOutput":1754},"src/testing/index.ts":{"bytesInOutput":0},"src/testing/test-layer.ts":{"bytesInOutput":332}},"bytes":2371},"dist/lib/node-esm/chunk-N5LOOWPE.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":1399},"dist/lib/node-esm/chunk-N5LOOWPE.mjs":{"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true}],"exports":["CommandConfig","__export"],"inputs":{"src/services/command-config.ts":{"bytesInOutput":506}},"bytes":885}}}
@@ -3,11 +3,11 @@ import * as Layer from 'effect/Layer';
3
3
  import * as Option from 'effect/Option';
4
4
  import { ClientService } from '@dxos/client';
5
5
  import { type Space } from '@dxos/client/echo';
6
- import { Database, Feed, type Key } from '@dxos/echo';
6
+ import { Database, type Key } from '@dxos/echo';
7
7
  import { BaseError, type BaseErrorOptions } from '@dxos/errors';
8
8
  export declare const getSpace: (spaceId: Key.SpaceId) => Effect.Effect<Space, SpaceNotFoundError, ClientService>;
9
9
  export declare const spaceIdWithDefault: (spaceId: Option.Option<Key.SpaceId>) => Effect.Effect<Key.SpaceId, never, ClientService>;
10
- export declare const spaceLayer: (spaceId$: Option.Option<Key.SpaceId>, fallbackToPersonalSpace?: boolean) => Layer.Layer<Database.Service | Feed.FeedService, never, ClientService>;
10
+ export declare const spaceLayer: (spaceId$: Option.Option<Key.SpaceId>, fallbackToPersonalSpace?: boolean) => Layer.Layer<Database.Service, never, ClientService>;
11
11
  export declare const waitForSync: (space: Space) => Effect.Effect<void, never, never>;
12
12
  export declare const flushAndSync: (opts?: Database.FlushOptions | undefined) => Effect.Effect<void, SpaceNotFoundError, ClientService | Database.Service>;
13
13
  declare const SpaceNotFoundError_base: {
@@ -1 +1 @@
1
- {"version":3,"file":"space.d.ts","sourceRoot":"","sources":["../../../../src/util/space.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAKhE,eAAO,MAAM,QAAQ,YAAa,GAAG,CAAC,OAAO,KAAG,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,kBAAkB,EAAE,aAAa,CAIE,CAAC;AAEzG,eAAO,MAAM,kBAAkB,YAAa,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,qDAUlE,CAAC;AAGL,eAAO,MAAM,UAAU,aACX,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,wCAEnC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,aAAa,CAiEvE,CAAC;AAGF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