@dxos/config 0.16.0 → 0.17.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.
@@ -22,7 +22,6 @@ export * from "#plugin";
22
22
  var EdgeServiceName = Object.freeze({
23
23
  Calls: "calls",
24
24
  Image: "image",
25
- Transcription: "transcription",
26
25
  VideoTranscription: "video-transcription",
27
26
  Discord: "discord",
28
27
  CorsProxy: "cors-proxy",
@@ -49,8 +48,6 @@ var EDGE_URLS = Object.freeze({
49
48
  *
50
49
  * The entries that are not simply `/<name>`:
51
50
  *
52
- * - `transcription` is the ASR endpoint (`POST /transcribe`), which calls-service serves — the same
53
- * worker `calls` reaches, which is why it has always been configured to the same host.
54
51
  * - `video-transcription` is the separate transcription-service (`GET /video`), whose prefix is the
55
52
  * worker's own name.
56
53
  * - `introspect` carries the `/mcp` path because the value IS the MCP server URL a client connects to.
@@ -58,7 +55,6 @@ var EDGE_URLS = Object.freeze({
58
55
  var EDGE_SERVICE_PATHS = Object.freeze({
59
56
  [EdgeServiceName.Calls]: "/calls",
60
57
  [EdgeServiceName.Image]: "/image",
61
- [EdgeServiceName.Transcription]: "/calls",
62
58
  [EdgeServiceName.VideoTranscription]: "/transcription",
63
59
  [EdgeServiceName.Discord]: "/discord",
64
60
  [EdgeServiceName.CorsProxy]: "/cors-proxy",
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/edge-services.ts","../../src/config-service.ts","../../src/telemetry.ts","../../src/preset.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport { type Config } from './config.ts';\n\n/**\n * Canonical names for EDGE (Cloudflare Worker) services.\n * Used as keys into `runtime.services.edgeServices` and into the path table below.\n */\nexport const EdgeServiceName = Object.freeze({\n Calls: 'calls',\n Image: 'image',\n Transcription: 'transcription',\n VideoTranscription: 'video-transcription',\n Discord: 'discord',\n CorsProxy: 'cors-proxy',\n Introspect: 'introspect',\n Sandbox: 'sandbox',\n} as const);\n\nexport type EdgeServiceName = (typeof EdgeServiceName)[keyof typeof EdgeServiceName];\n\n/**\n * The EDGE entrypoint per environment. `local` is `moon run edge:dev`, and `main.dxos.network`\n * remains an alias of `preview` for clients in the field.\n */\nexport const EDGE_URLS = Object.freeze({\n local: 'http://localhost:8787',\n dev: 'https://dev.dxos.network',\n preview: 'https://preview.dxos.network',\n production: 'https://dxos.network',\n} as const);\n\n/**\n * The path each service answers on beneath the EDGE entrypoint.\n *\n * EDGE is the front door for every service, and each owns exactly one prefix on it, so a client needs\n * one base URL per environment rather than a hostname per service — a hostname per service has to be\n * redeployed every time one of them moves, a prefix table does not. See\n * `edge/docs/design/system/http-route-migration.md`.\n *\n * The entries that are not simply `/<name>`:\n *\n * - `transcription` is the ASR endpoint (`POST /transcribe`), which calls-service serves — the same\n * worker `calls` reaches, which is why it has always been configured to the same host.\n * - `video-transcription` is the separate transcription-service (`GET /video`), whose prefix is the\n * worker's own name.\n * - `introspect` carries the `/mcp` path because the value IS the MCP server URL a client connects to.\n */\nconst EDGE_SERVICE_PATHS: Record<EdgeServiceName, string> = Object.freeze({\n [EdgeServiceName.Calls]: '/calls',\n [EdgeServiceName.Image]: '/image',\n [EdgeServiceName.Transcription]: '/calls',\n [EdgeServiceName.VideoTranscription]: '/transcription',\n [EdgeServiceName.Discord]: '/discord',\n [EdgeServiceName.CorsProxy]: '/cors-proxy',\n [EdgeServiceName.Introspect]: '/introspect/mcp',\n [EdgeServiceName.Sandbox]: '/sandbox',\n});\n\n/** Join a service path onto a base URL, tolerating a trailing slash on the base (`dx.yml` has one). */\nconst joinEdgePath = (baseUrl: string, path: string): string => `${baseUrl.replace(/\\/+$/, '')}${path}`;\n\n/**\n * Resolve an EDGE service endpoint, `undefined` when nothing is configured — absence still means the\n * feature is unavailable, so an unconfigured client reaches no network at all.\n *\n * Two sources, in order:\n *\n * 1. An explicit `runtime.services.edgeServices` entry. The last match wins, since proto cannot enforce\n * uniqueness on a repeated field. This is the override — a local worker, a one-off host.\n * 2. `runtime.services.edge.url` plus the service's path. This is the normal case: configuring the EDGE\n * entrypoint configures every service behind it, and no service endpoint can drift to a different\n * environment than the client's own.\n */\nexport const getEdgeServiceEndpoint = (config: Config, name: EdgeServiceName): string | undefined => {\n const configured = config.values.runtime?.services?.edgeServices?.findLast(\n (service) => service.name === name,\n )?.endpoint;\n if (configured) {\n return configured;\n }\n const edgeUrl = config.values.runtime?.services?.edge?.url;\n return edgeUrl ? joinEdgePath(edgeUrl, EDGE_SERVICE_PATHS[name]) : undefined;\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as FileSystem from 'effect/FileSystem';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\nimport { dirname } from 'node:path';\n\nimport { DEFAULT_HUB_URL, DX_CONFIG, DX_DATA, getProfileConfigPath, getProfilePath } from '@dxos/client-protocol';\nimport { invariant } from '@dxos/invariant';\n\nimport { Config } from './config.ts';\nimport { EDGE_URLS } from './edge-services.ts';\nimport { type ConfigInit } from './types.ts';\n\nexport const memoryConfig = new Config({\n runtime: {\n client: {\n edgeFeatures: {\n subductionReplicator: true,\n feedReplicator: true,\n signaling: true,\n agents: true,\n },\n },\n },\n});\n\n/**\n * Endpoints the CLI writes into a profile when it creates one, kept out of\n * {@link profileBuiltinDefaults} so the user can see and change what their CLI talks to.\n */\nexport const defaultProfileEndpoints = new Config({\n runtime: {\n services: {\n hub: {\n url: DEFAULT_HUB_URL,\n },\n edge: {\n url: `${EDGE_URLS.production}/`,\n },\n iceProviders: [\n {\n urls: `${EDGE_URLS.production}/ice`,\n },\n ],\n ipfs: {\n server: 'https://api.ipfs.dxos.network/api/v0',\n gateway: 'https://gateway.ipfs.dxos.network/ipfs',\n },\n },\n },\n});\n\n/** Aligns a fresh monorepo CLI profile with the backend Composer's local dev server talks to. */\nexport const localDevConfig = new Config(\n { runtime: { services: { edge: { url: EDGE_URLS.preview } } } },\n defaultProfileEndpoints.values,\n);\n\nexport class ConfigService extends Context.Service<ConfigService, Config>()('ConfigService') {\n static load = (args: { config: Option.Option<string>; profile: string }) => {\n const defaultConfigPath = getProfileConfigPath(DX_CONFIG, args.profile);\n return Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n // Loaded on demand: this node-side profile loader is exported from the browser barrel,\n // and the yaml parser must not ride the app's static boot graph.\n const Yaml = yield* Effect.promise(() => import('yaml'));\n const configPath = Option.getOrElse(args.config, () => defaultConfigPath);\n const configContent = yield* fs.readFileString(configPath);\n const configValues = Yaml.parse(configContent);\n return withProfileDefaults(configValues, args.profile);\n }).pipe(\n // If the config file doesn't exist, create it. v4 folds v3's `SystemError` and `BadArgument`\n // into one `PlatformError` tag; only the former was ever recovered here.\n Effect.catchTag('PlatformError', (error) =>\n error.reason._tag === 'BadArgument'\n ? Effect.fail(error)\n : Effect.gen(function* () {\n const Yaml = yield* Effect.promise(() => import('yaml'));\n // First run materializes only the endpoints — features and storage keep coming from\n // profileBuiltinDefaults so they track the code, while what the CLI talks to is stated\n // in the file the user owns.\n const useLocalDev = process.env.DX_LOCAL_DEV !== undefined && process.env.DX_LOCAL_DEV !== '0';\n const configValues = (useLocalDev ? localDevConfig : defaultProfileEndpoints).values;\n const fs = yield* FileSystem.FileSystem;\n const pathToCreate = Option.getOrElse(args.config, () => defaultConfigPath);\n yield* fs.makeDirectory(dirname(pathToCreate), { recursive: true });\n yield* fs.writeFileString(pathToCreate, Yaml.stringify(configValues));\n return withProfileDefaults(configValues, args.profile);\n }),\n ),\n );\n };\n}\n\nexport const layerMemory = Layer.effect(ConfigService, Effect.succeed(memoryConfig));\n\nexport const fromConfig = (config: Config) => Layer.succeed(ConfigService, config);\n\n/**\n * Both load branches (existing file, first-run write) must layer env, file, and builtins in the same\n * order, or a freshly created profile would come up without storage or the hub.\n */\nconst withProfileDefaults = (configValues: ConfigInit, profile: string) =>\n ConfigService.of(new Config(processEnvDefaults(), configValues, profileBuiltinDefaults(profile).values));\n\n/**\n * `DX_*` process env projected onto `runtime.app.env`, mirroring what the bundler config plugin does\n * for browser builds — without it those keys are unreachable on node, where nothing bundles the app.\n * Takes precedence over the profile config file, so `DX_HUB_URL=… dx …` overrides for one command.\n */\nconst processEnvDefaults = (): ConfigInit => {\n const env: Record<string, string> = {};\n for (const [key, value] of Object.entries(process.env)) {\n if (key.startsWith('DX_') && value !== undefined) {\n env[key] = value;\n }\n }\n return Object.keys(env).length > 0 ? { runtime: { app: { env } } } : {};\n};\n\n/**\n * Default config for a profile.\n * Always merged with the default config.\n */\nconst profileBuiltinDefaults = (profile: string) => {\n invariant(!profile.endsWith('.yml'));\n\n return new Config({\n runtime: {\n // Kept as a load-time default, not written per profile: profiles created before the endpoints\n // moved into the file have no `hub` key, and without this every `dx hub` command breaks on upgrade.\n services: {\n hub: {\n url: DEFAULT_HUB_URL,\n },\n },\n client: {\n edgeFeatures: {\n subductionReplicator: true,\n feedReplicator: true,\n signaling: true,\n agents: true,\n },\n storage: {\n persistent: true,\n dataRoot: getProfilePath(DX_DATA, profile),\n },\n },\n },\n });\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { isNode } from '@dxos/util';\n\nimport { type Config, getEnvString } from './config.ts';\n\n/**\n * Resolves the telemetry tag used as the `X-DXOS-Client-Tag` header on edge\n * requests AND as the `ctx.tag` attribute / resource on observability traces.\n *\n * Keeping a single resolver ensures the same tag identifies a session across\n * edge and telemetry tiers. Precedence:\n *\n * 1. `config.runtime.app.env.DX_TELEMETRY_TAG` — the explicit, deterministic\n * path. Populated from `.env`/build-time by the app's config loaders.\n * 2. `process.env.DX_TELEMETRY_TAG` — Node-only, for dev/CI convenience.\n *\n * Returns `undefined` when unset; callers should no-op on undefined rather\n * than stamping empty strings.\n */\nexport const resolveTelemetryTag = (config?: Config): string | undefined => {\n return getEnvString(config, 'DX_TELEMETRY_TAG') ?? (isNode() ? process.env.DX_TELEMETRY_TAG : undefined);\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Match from 'effect/Match';\n\nimport { Config } from './config.ts';\nimport { EDGE_URLS } from './edge-services.ts';\n\nexport type ConfigPresetOptions = {\n /**\n * Edge service.\n * @default preview\n */\n edge?: 'local' | 'dev' | 'preview' | 'main' | 'production';\n\n /**\n * Sandbox service. Only `local` sets anything: every deployed sandbox-service is reached as\n * `<edge>/sandbox`, so `edge` above already configures it.\n */\n sandbox?: 'local' | 'dev' | 'main' | 'production';\n};\n\nconst edgeUrl = (edge: NonNullable<ConfigPresetOptions['edge']>) =>\n Match.value(edge).pipe(\n Match.when('local', () => 'http://localhost:8787'),\n Match.when('dev', () => EDGE_URLS.dev),\n // Preserve `main` as a deprecated alias for existing profiles.\n Match.when('preview', () => EDGE_URLS.preview),\n Match.when('main', () => EDGE_URLS.preview),\n Match.when('production', () => EDGE_URLS.production),\n Match.exhaustive,\n );\n\n// `undefined` for every deployed environment: `runtime.services.sandbox.url` is the override for a\n// worker that is NOT behind EDGE, and leaving it unset is what makes the client derive `<edge>/sandbox`.\nconst sandboxUrl = (sandbox: NonNullable<ConfigPresetOptions['sandbox']>): string | undefined =>\n Match.value(sandbox).pipe(\n Match.when('local', () => 'http://localhost:8792'),\n Match.orElse(() => undefined),\n );\n\nexport const configPreset = ({ edge = 'preview', sandbox }: ConfigPresetOptions = {}) => {\n const sandboxOverride = sandbox && sandboxUrl(sandbox);\n return new Config({\n version: 1,\n runtime: {\n client: {\n edgeFeatures: {\n signaling: true,\n subductionReplicator: true,\n feedReplicator: true,\n },\n },\n services: {\n edge: {\n url: edgeUrl(edge),\n },\n ...(sandboxOverride ? { sandbox: { url: sandboxOverride } } : {}),\n },\n },\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAUA,IAAa,kBAAkB,OAAO,OAAO;CAC3C,OAAO;CACP,OAAO;CACP,eAAe;CACf,oBAAoB;CACpB,SAAS;CACT,WAAW;CACX,YAAY;CACZ,SAAS;AACX,CAAU;;;;;AAQV,IAAa,YAAY,OAA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ACvF,MAAM,kBAAkB,WAAW,WAAW,OAAO;CACrD,OAAO,IAAI,OAAO;EAChB,SAAS;EACT,SAAS;GACP,QAAQ,EACN,cAAc;IACZ,WAAW;IACX,sBAAsB;IACtB,gBAAgB;GAClB,EACF;GACA,UAAU;IACR,MAAM,EACJ,KAAK,QAAQ,IAAI,EACnB;IACA,GAAI,kBAAkB,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,IAAI,CAAC;GACjE;EACF;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/edge-services.ts","../../src/config-service.ts","../../src/telemetry.ts","../../src/preset.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport { type Config } from './config.ts';\n\n/**\n * Canonical names for EDGE (Cloudflare Worker) services.\n * Used as keys into `runtime.services.edgeServices` and into the path table below.\n */\nexport const EdgeServiceName = Object.freeze({\n Calls: 'calls',\n Image: 'image',\n VideoTranscription: 'video-transcription',\n Discord: 'discord',\n CorsProxy: 'cors-proxy',\n Introspect: 'introspect',\n Sandbox: 'sandbox',\n} as const);\n\nexport type EdgeServiceName = (typeof EdgeServiceName)[keyof typeof EdgeServiceName];\n\n/**\n * The EDGE entrypoint per environment. `local` is `moon run edge:dev`, and `main.dxos.network`\n * remains an alias of `preview` for clients in the field.\n */\nexport const EDGE_URLS = Object.freeze({\n local: 'http://localhost:8787',\n dev: 'https://dev.dxos.network',\n preview: 'https://preview.dxos.network',\n production: 'https://dxos.network',\n} as const);\n\n/**\n * The path each service answers on beneath the EDGE entrypoint.\n *\n * EDGE is the front door for every service, and each owns exactly one prefix on it, so a client needs\n * one base URL per environment rather than a hostname per service — a hostname per service has to be\n * redeployed every time one of them moves, a prefix table does not. See\n * `edge/docs/design/system/http-route-migration.md`.\n *\n * The entries that are not simply `/<name>`:\n *\n * - `video-transcription` is the separate transcription-service (`GET /video`), whose prefix is the\n * worker's own name.\n * - `introspect` carries the `/mcp` path because the value IS the MCP server URL a client connects to.\n */\nconst EDGE_SERVICE_PATHS: Record<EdgeServiceName, string> = Object.freeze({\n [EdgeServiceName.Calls]: '/calls',\n [EdgeServiceName.Image]: '/image',\n [EdgeServiceName.VideoTranscription]: '/transcription',\n [EdgeServiceName.Discord]: '/discord',\n [EdgeServiceName.CorsProxy]: '/cors-proxy',\n [EdgeServiceName.Introspect]: '/introspect/mcp',\n [EdgeServiceName.Sandbox]: '/sandbox',\n});\n\n/** Join a service path onto a base URL, tolerating a trailing slash on the base (`dx.yml` has one). */\nconst joinEdgePath = (baseUrl: string, path: string): string => `${baseUrl.replace(/\\/+$/, '')}${path}`;\n\n/**\n * Resolve an EDGE service endpoint, `undefined` when nothing is configured — absence still means the\n * feature is unavailable, so an unconfigured client reaches no network at all.\n *\n * Two sources, in order:\n *\n * 1. An explicit `runtime.services.edgeServices` entry. The last match wins, since proto cannot enforce\n * uniqueness on a repeated field. This is the override — a local worker, a one-off host.\n * 2. `runtime.services.edge.url` plus the service's path. This is the normal case: configuring the EDGE\n * entrypoint configures every service behind it, and no service endpoint can drift to a different\n * environment than the client's own.\n */\nexport const getEdgeServiceEndpoint = (config: Config, name: EdgeServiceName): string | undefined => {\n const configured = config.values.runtime?.services?.edgeServices?.findLast(\n (service) => service.name === name,\n )?.endpoint;\n if (configured) {\n return configured;\n }\n const edgeUrl = config.values.runtime?.services?.edge?.url;\n return edgeUrl ? joinEdgePath(edgeUrl, EDGE_SERVICE_PATHS[name]) : undefined;\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as FileSystem from 'effect/FileSystem';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\nimport { dirname } from 'node:path';\n\nimport { DEFAULT_HUB_URL, DX_CONFIG, DX_DATA, getProfileConfigPath, getProfilePath } from '@dxos/client-protocol';\nimport { invariant } from '@dxos/invariant';\n\nimport { Config } from './config.ts';\nimport { EDGE_URLS } from './edge-services.ts';\nimport { type ConfigInit } from './types.ts';\n\nexport const memoryConfig = new Config({\n runtime: {\n client: {\n edgeFeatures: {\n subductionReplicator: true,\n feedReplicator: true,\n signaling: true,\n agents: true,\n },\n },\n },\n});\n\n/**\n * Endpoints the CLI writes into a profile when it creates one, kept out of\n * {@link profileBuiltinDefaults} so the user can see and change what their CLI talks to.\n */\nexport const defaultProfileEndpoints = new Config({\n runtime: {\n services: {\n hub: {\n url: DEFAULT_HUB_URL,\n },\n edge: {\n url: `${EDGE_URLS.production}/`,\n },\n iceProviders: [\n {\n urls: `${EDGE_URLS.production}/ice`,\n },\n ],\n ipfs: {\n server: 'https://api.ipfs.dxos.network/api/v0',\n gateway: 'https://gateway.ipfs.dxos.network/ipfs',\n },\n },\n },\n});\n\n/** Aligns a fresh monorepo CLI profile with the backend Composer's local dev server talks to. */\nexport const localDevConfig = new Config(\n { runtime: { services: { edge: { url: EDGE_URLS.preview } } } },\n defaultProfileEndpoints.values,\n);\n\nexport class ConfigService extends Context.Service<ConfigService, Config>()('ConfigService') {\n static load = (args: { config: Option.Option<string>; profile: string }) => {\n const defaultConfigPath = getProfileConfigPath(DX_CONFIG, args.profile);\n return Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n // Loaded on demand: this node-side profile loader is exported from the browser barrel,\n // and the yaml parser must not ride the app's static boot graph.\n const Yaml = yield* Effect.promise(() => import('yaml'));\n const configPath = Option.getOrElse(args.config, () => defaultConfigPath);\n const configContent = yield* fs.readFileString(configPath);\n const configValues = Yaml.parse(configContent);\n return withProfileDefaults(configValues, args.profile);\n }).pipe(\n // If the config file doesn't exist, create it. v4 folds v3's `SystemError` and `BadArgument`\n // into one `PlatformError` tag; only the former was ever recovered here.\n Effect.catchTag('PlatformError', (error) =>\n error.reason._tag === 'BadArgument'\n ? Effect.fail(error)\n : Effect.gen(function* () {\n const Yaml = yield* Effect.promise(() => import('yaml'));\n // First run materializes only the endpoints — features and storage keep coming from\n // profileBuiltinDefaults so they track the code, while what the CLI talks to is stated\n // in the file the user owns.\n const useLocalDev = process.env.DX_LOCAL_DEV !== undefined && process.env.DX_LOCAL_DEV !== '0';\n const configValues = (useLocalDev ? localDevConfig : defaultProfileEndpoints).values;\n const fs = yield* FileSystem.FileSystem;\n const pathToCreate = Option.getOrElse(args.config, () => defaultConfigPath);\n yield* fs.makeDirectory(dirname(pathToCreate), { recursive: true });\n yield* fs.writeFileString(pathToCreate, Yaml.stringify(configValues));\n return withProfileDefaults(configValues, args.profile);\n }),\n ),\n );\n };\n}\n\nexport const layerMemory = Layer.effect(ConfigService, Effect.succeed(memoryConfig));\n\nexport const fromConfig = (config: Config) => Layer.succeed(ConfigService, config);\n\n/**\n * Both load branches (existing file, first-run write) must layer env, file, and builtins in the same\n * order, or a freshly created profile would come up without storage or the hub.\n */\nconst withProfileDefaults = (configValues: ConfigInit, profile: string) =>\n ConfigService.of(new Config(processEnvDefaults(), configValues, profileBuiltinDefaults(profile).values));\n\n/**\n * `DX_*` process env projected onto `runtime.app.env`, mirroring what the bundler config plugin does\n * for browser builds — without it those keys are unreachable on node, where nothing bundles the app.\n * Takes precedence over the profile config file, so `DX_HUB_URL=… dx …` overrides for one command.\n */\nconst processEnvDefaults = (): ConfigInit => {\n const env: Record<string, string> = {};\n for (const [key, value] of Object.entries(process.env)) {\n if (key.startsWith('DX_') && value !== undefined) {\n env[key] = value;\n }\n }\n return Object.keys(env).length > 0 ? { runtime: { app: { env } } } : {};\n};\n\n/**\n * Default config for a profile.\n * Always merged with the default config.\n */\nconst profileBuiltinDefaults = (profile: string) => {\n invariant(!profile.endsWith('.yml'));\n\n return new Config({\n runtime: {\n // Kept as a load-time default, not written per profile: profiles created before the endpoints\n // moved into the file have no `hub` key, and without this every `dx hub` command breaks on upgrade.\n services: {\n hub: {\n url: DEFAULT_HUB_URL,\n },\n },\n client: {\n edgeFeatures: {\n subductionReplicator: true,\n feedReplicator: true,\n signaling: true,\n agents: true,\n },\n storage: {\n persistent: true,\n dataRoot: getProfilePath(DX_DATA, profile),\n },\n },\n },\n });\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { isNode } from '@dxos/util';\n\nimport { type Config, getEnvString } from './config.ts';\n\n/**\n * Resolves the telemetry tag used as the `X-DXOS-Client-Tag` header on edge\n * requests AND as the `ctx.tag` attribute / resource on observability traces.\n *\n * Keeping a single resolver ensures the same tag identifies a session across\n * edge and telemetry tiers. Precedence:\n *\n * 1. `config.runtime.app.env.DX_TELEMETRY_TAG` — the explicit, deterministic\n * path. Populated from `.env`/build-time by the app's config loaders.\n * 2. `process.env.DX_TELEMETRY_TAG` — Node-only, for dev/CI convenience.\n *\n * Returns `undefined` when unset; callers should no-op on undefined rather\n * than stamping empty strings.\n */\nexport const resolveTelemetryTag = (config?: Config): string | undefined => {\n return getEnvString(config, 'DX_TELEMETRY_TAG') ?? (isNode() ? process.env.DX_TELEMETRY_TAG : undefined);\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Match from 'effect/Match';\n\nimport { Config } from './config.ts';\nimport { EDGE_URLS } from './edge-services.ts';\n\nexport type ConfigPresetOptions = {\n /**\n * Edge service.\n * @default preview\n */\n edge?: 'local' | 'dev' | 'preview' | 'main' | 'production';\n\n /**\n * Sandbox service. Only `local` sets anything: every deployed sandbox-service is reached as\n * `<edge>/sandbox`, so `edge` above already configures it.\n */\n sandbox?: 'local' | 'dev' | 'main' | 'production';\n};\n\nconst edgeUrl = (edge: NonNullable<ConfigPresetOptions['edge']>) =>\n Match.value(edge).pipe(\n Match.when('local', () => 'http://localhost:8787'),\n Match.when('dev', () => EDGE_URLS.dev),\n // Preserve `main` as a deprecated alias for existing profiles.\n Match.when('preview', () => EDGE_URLS.preview),\n Match.when('main', () => EDGE_URLS.preview),\n Match.when('production', () => EDGE_URLS.production),\n Match.exhaustive,\n );\n\n// `undefined` for every deployed environment: `runtime.services.sandbox.url` is the override for a\n// worker that is NOT behind EDGE, and leaving it unset is what makes the client derive `<edge>/sandbox`.\nconst sandboxUrl = (sandbox: NonNullable<ConfigPresetOptions['sandbox']>): string | undefined =>\n Match.value(sandbox).pipe(\n Match.when('local', () => 'http://localhost:8792'),\n Match.orElse(() => undefined),\n );\n\nexport const configPreset = ({ edge = 'preview', sandbox }: ConfigPresetOptions = {}) => {\n const sandboxOverride = sandbox && sandboxUrl(sandbox);\n return new Config({\n version: 1,\n runtime: {\n client: {\n edgeFeatures: {\n signaling: true,\n subductionReplicator: true,\n feedReplicator: true,\n },\n },\n services: {\n edge: {\n url: edgeUrl(edge),\n },\n ...(sandboxOverride ? { sandbox: { url: sandboxOverride } } : {}),\n },\n },\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAUA,IAAa,kBAAkB,OAAO,OAAO;CAC3C,OAAO;CACP,OAAO;CACP,oBAAoB;CACpB,SAAS;CACT,WAAW;CACX,YAAY;CACZ,SAAS;AACX,CAAU;;;;;AAQV,IAAa,YAAY,OAAO,OAAO;CACrC,OAAO;CACP,KAAK;CACL,SAAS;CACT,YAAY;AACd,CAAU;;;;;;;;;;;;;;;AAgBV,IAAM,qBAAsD,OAAO,OAAO;EACvE,gBAAgB,QAAQ;EACxB,gBAAgB,QAAQ;EACxB,gBAAgB,qBAAqB;EACrC,gBAAgB,UAAU;EAC1B,gBAAgB,YAAY;EAC5B,gBAAgB,aAAa;EAC7B,gBAAgB,UAAU;AAC7B,CAAC;;AAGD,IAAM,gBAAgB,SAAiB,SAAyB,GAAG,QAAQ,QAAQ,QAAQ,EAAE,IAAI;;;;;;;;;;;;;AAcjG,IAAa,0BAA0B,QAAgB,SAA8C;CACnG,MAAM,aAAa,OAAO,OAAO,SAAS,UAAU,cAAc,UAC/D,YAAY,QAAQ,SAAS,IAChC,CAAC,EAAE;CACH,IAAI,YACF,OAAO;CAET,MAAM,UAAU,OAAO,OAAO,SAAS,UAAU,MAAM;CACvD,OAAO,UAAU,aAAa,SAAS,mBAAmB,KAAK,IAAI,KAAA;AACrE;;;;AC/DA,IAAa,eAAe,IAAI,OAAO,EACrC,SAAS,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AwC;CAC1E,OAAO,aAAa,QAAQ,kBAAkB,MAAM,OAAO,IAAI,QAAQ,IAAI,mBAAmB,KAAA;AAChG;;;ACDA,IAAM,WAAW,SACf,MAAM,MAAM,IAAI,CAAC,CAAC,KAChB,MAAM,KAAK,eAAe,uBAAuB,GACjD,MAAM,KAAK,aAAa,UAAU,GAAG,GAErC,MAAM,KAAK,iBAAiB,UAAU,OAAO,GAC7C,MAAM,KAAK,cAAc,UAAU,OAAO,GAC1C,MAAM,KAAK,oBAAoB,UAAU,UAAU,GACnD,MAAM,UACR;AAIF,IAAM,cAAc,YAClB,MAAM,MAAM,OAAO,CAAC,CAAC,KACnB,MAAM,KAAK,eAAe,uBAAuB,GACjD,MAAM,aAAa,KAAA,CAAS,CAC9B;AAEF,IAAa,gBAAgB,EAAE,OAAO,WAAW,YAAiC,CAAC,MAAM;CACvF,MAAM,kBAAkB,WAAW,WAAW,OAAO;CACrD,OAAO,IAAI,OAAO;EAChB,SAAS;EACT,SAAS;GACP,QAAQ,EACN,cAAc;IACZ,WAAW;IACX,sBAAsB;IACtB,gBAAgB;GAClB,EACF;GACA,UAAU;IACR,MAAM,EACJ,KAAK,QAAQ,IAAI,EACnB;IACA,GAAI,kBAAkB,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,IAAI,CAAC;GACjE;EACF;CACF,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"rollup-plugin.mjs","names":[],"sources":["../../../src/plugin/rollup-plugin.ts"],"sourcesContent":["//\n// Copyright 2022 DXOS.org\n//\n\nimport { type Plugin } from 'rollup';\n\nimport { definitions } from './definitions.ts';\nimport { type ConfigPluginOpts } from './types.ts';\n\nexport const ConfigPlugin = (options: ConfigPluginOpts = {}): Plugin => {\n const contents = Object.entries(definitions({ ...options, mode: process.env.NODE_ENV }))\n .map(([key, value]) => `globalThis.${key} = ${JSON.stringify(value)};`)\n .join('\\n');\n\n return {\n name: 'dxos-config',\n banner: contents,\n };\n};\n"],"mappings":";;AASA,IAAa,gBAAgB,UAA4B,CAAC,MAAc;CAKtE,OAAO;EACL,MAAM;EACN,QANe,OAAO,QAAQ,YAAY;GAAE,GAAG;GAAS,MAAA,QAAA,IAAA;EAA2B,CAAC,CAAC,CAAA,CACpF,KAAK,CAAC,KAAK,WAAW,cAAc,IAAI,KAAK,KAAK,UAAU,KAAK,EAAE,EAAE,CAAA,CACrE,KAAK,IAIE;CACV;AACF"}
1
+ {"version":3,"file":"rollup-plugin.mjs","names":[],"sources":["../../../src/plugin/rollup-plugin.ts"],"sourcesContent":["//\n// Copyright 2022 DXOS.org\n//\n\nimport { type Plugin } from 'rollup';\n\nimport { definitions } from './definitions.ts';\nimport { type ConfigPluginOpts } from './types.ts';\n\nexport const ConfigPlugin = (options: ConfigPluginOpts = {}): Plugin => {\n const contents = Object.entries(definitions({ ...options, mode: process.env.NODE_ENV }))\n .map(([key, value]) => `globalThis.${key} = ${JSON.stringify(value)};`)\n .join('\\n');\n\n return {\n name: 'dxos-config',\n banner: contents,\n };\n};\n"],"mappings":";;AASA,IAAa,gBAAgB,UAA4B,CAAC,MAAc;CAKtE,OAAO;EACL,MAAM;EACN,QANe,OAAO,QAAQ,YAAY;GAAE,GAAG;GAAS,MAAA,QAAA,IAAA;EAA2B,CAAC,CAAC,CAAC,CACrF,KAAK,CAAC,KAAK,WAAW,cAAc,IAAI,KAAK,KAAK,UAAU,KAAK,EAAE,EAAE,CAAC,CACtE,KAAK,IAIE;CACV;AACF"}
@@ -6,7 +6,6 @@ import { type Config } from './config.ts';
6
6
  export declare const EdgeServiceName: Readonly<{
7
7
  readonly Calls: 'calls';
8
8
  readonly Image: 'image';
9
- readonly Transcription: 'transcription';
10
9
  readonly VideoTranscription: 'video-transcription';
11
10
  readonly Discord: 'discord';
12
11
  readonly CorsProxy: 'cors-proxy';
@@ -1 +1 @@
1
- {"version":3,"file":"edge-services.d.ts","sourceRoot":"","sources":["../../../src/edge-services.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;GAGG;AACH,eAAO,MAAM,eAAe;oBACnB,OAAO;oBACP,OAAO;4BACC,eAAe;iCACV,qBAAqB;sBAChC,SAAS;wBACP,YAAY;yBACX,YAAY;sBACf,SAAS;EACT,CAAC;AAEZ,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAErF;;;GAGG;AACH,eAAO,MAAM,SAAS;oBACb,uBAAuB;kBACzB,0BAA0B;sBACtB,8BAA8B;yBAC3B,sBAAsB;EACzB,CAAC;AAgCZ;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,WAAY,MAAM,QAAQ,eAAe,KAAG,MAAM,GAAG,SASvF,CAAC"}
1
+ {"version":3,"file":"edge-services.d.ts","sourceRoot":"","sources":["../../../src/edge-services.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;GAGG;AACH,eAAO,MAAM,eAAe;oBACnB,OAAO;oBACP,OAAO;iCACM,qBAAqB;sBAChC,SAAS;wBACP,YAAY;yBACX,YAAY;sBACf,SAAS;EACT,CAAC;AAEZ,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAErF;;;GAGG;AACH,eAAO,MAAM,SAAS;oBACb,uBAAuB;kBACzB,0BAA0B;sBACtB,8BAA8B;yBAC3B,sBAAsB;EACzB,CAAC;AA6BZ;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,WAAY,MAAM,QAAQ,eAAe,KAAG,MAAM,GAAG,SASvF,CAAC"}