{
  "version": 3,
  "sources": ["../../../src/index.ts", "../../../src/config-service.ts", "../../../src/edge-services.ts", "../../../src/telemetry.ts", "../../../src/preset.ts"],
  "sourcesContent": ["//\n// Copyright 2021 DXOS.org\n//\n\n// TODO(burdon): Why is this exported? (Rename).\nexport * as defs from '@dxos/protocols/proto/dxos/config';\n\nexport { type Config as ConfigProto } from '@dxos/protocols/proto/dxos/config';\n\nexport * from './config';\nexport * from './config-service';\nexport * from './edge-services';\nexport * from '#loaders';\nexport * from '#savers';\nexport * from '#plugin';\nexport * from './telemetry';\nexport * from './types';\nexport * from './preset';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as FileSystem from '@effect/platform/FileSystem';\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\nimport { dirname } from 'node:path';\nimport * as Yaml from 'yaml';\n\nimport { DX_CONFIG, DX_DATA, getProfileConfigPath, getProfilePath } from '@dxos/client-protocol';\nimport { invariant } from '@dxos/invariant';\n\nimport { Config } from './config';\n\nexport const memoryConfig = new Config({\n  runtime: {\n    client: {\n      edgeFeatures: {\n        echoReplicator: true,\n        feedReplicator: true,\n        signaling: true,\n        agents: true,\n      },\n    },\n  },\n});\n\nexport const defaultConfig = new Config({\n  runtime: {\n    client: {\n      edgeFeatures: {\n        echoReplicator: true,\n        feedReplicator: true,\n        signaling: true,\n        agents: true,\n      },\n      storage: {\n        persistent: true,\n      },\n    },\n    services: {\n      edge: {\n        url: 'wss://edge-production.dxos.workers.dev/',\n      },\n      iceProviders: [\n        {\n          urls: 'https://edge-production.dxos.workers.dev/ice',\n        },\n      ],\n      ai: {\n        server: 'https://ai-service.dxos.workers.dev',\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\nexport class ConfigService extends Context.Tag('ConfigService')<ConfigService, Config>() {\n  static layerMemory = Layer.effect(ConfigService, Effect.succeed(memoryConfig));\n\n  static fromConfig = (config: Config) => Layer.succeed(ConfigService, config);\n\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      const configPath = Option.getOrElse(args.config, () => defaultConfigPath);\n      const configContent = yield* fs.readFileString(configPath);\n      const configValues = Yaml.parse(configContent);\n      return ConfigService.of(new Config(configValues, profileBuiltinDefaults(args.profile).values));\n    }).pipe(\n      // If the config file doesn't exist, create it.\n      Effect.catchTag('SystemError', () =>\n        Effect.gen(function* () {\n          const configValues = defaultConfig.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 ConfigService.of(new Config(configValues));\n        }),\n      ),\n    );\n  };\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      client: {\n        edgeFeatures: {\n          echoReplicator: 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 { type Config } from './config';\n\n/**\n * Canonical names for EDGE (Cloudflare Worker) services.\n * Used as keys into `runtime.services.edgeServices` and {@link EDGE_SERVICE_DEFAULTS}.\n */\nexport const EdgeServiceName = Object.freeze({\n  Calls: 'calls',\n  Image: 'image',\n  Transcription: 'transcription',\n  Discord: 'discord',\n  CorsProxy: 'cors-proxy',\n  ApiProxy: 'api-proxy',\n  Introspect: 'introspect',\n  ChatAgent: 'chat-agent',\n} as const);\n\nexport type EdgeServiceName = (typeof EdgeServiceName)[keyof typeof EdgeServiceName];\n\n/**\n * Canonical dev/test default endpoints for EDGE services.\n * Single source of truth for the URLs previously hard-coded across plugins.\n * Production values are supplied per-app via `dx.yml` (`runtime.services.edgeServices`).\n */\nexport const EDGE_SERVICE_DEFAULTS: Readonly<Record<EdgeServiceName, string>> = Object.freeze({\n  [EdgeServiceName.Calls]: 'https://calls-service.dxos.workers.dev',\n  [EdgeServiceName.Image]: 'https://image-service-main.dxos.workers.dev',\n  [EdgeServiceName.Transcription]: 'https://calls-service.dxos.workers.dev',\n  [EdgeServiceName.Discord]: 'https://discord-service.dxos.workers.dev',\n  [EdgeServiceName.CorsProxy]: 'https://cors-proxy.dxos.workers.dev',\n  [EdgeServiceName.ApiProxy]: 'https://api-proxy.dxos.workers.dev',\n  [EdgeServiceName.Introspect]: 'https://introspect-service-labs.dxos.workers.dev/mcp',\n  [EdgeServiceName.ChatAgent]: 'wss://chat-agent-labs.dxos.workers.dev',\n});\n\n/**\n * Resolve the endpoint for an EDGE service.\n * Prefers the matching `runtime.services.edgeServices` entry, falling back to the canonical\n * {@link EDGE_SERVICE_DEFAULTS} entry.\n * `name` is expected to be unique; on duplicates the last entry wins so a later override is\n * not silently shadowed by an earlier one (proto cannot enforce uniqueness on a repeated field).\n */\nexport const getEdgeServiceEndpoint = (config: Config, name: EdgeServiceName): string =>\n  config.values.runtime?.services?.edgeServices?.findLast((service) => service.name === name)?.endpoint ??\n  EDGE_SERVICE_DEFAULTS[name];\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { isNode } from '@dxos/util';\n\nimport { type Config } from './config';\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 config?.get('runtime.app.env.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';\n\nexport type ConfigPresetOptions = {\n  /**\n   * Edge service.\n   * @default main\n   */\n  edge?: 'local' | 'dev' | 'main' | 'production';\n\n  /**\n   * Sandbox service (standalone worker; API at /api/sandbox).\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', () => 'https://edge.dxos.workers.dev'),\n    Match.when('main', () => 'https://edge-main.dxos.workers.dev'),\n    Match.when('production', () => 'https://edge-production.dxos.workers.dev'),\n    Match.exhaustive,\n  );\n\n// TODO(burdon): Hosted environments share a single worker until per-env deployments exist.\nconst sandboxUrl = (sandbox: NonNullable<ConfigPresetOptions['sandbox']>) =>\n  Match.value(sandbox).pipe(\n    Match.when('local', () => 'http://localhost:8792'),\n    Match.when('dev', () => 'https://sandbox-service.dxos.workers.dev'),\n    Match.when('main', () => 'https://sandbox-service.dxos.workers.dev'),\n    Match.when('production', () => 'https://sandbox-service.dxos.workers.dev'),\n    Match.exhaustive,\n  );\n\nexport const configPreset = ({ edge = 'main', sandbox }: ConfigPresetOptions = {}) =>\n  new Config({\n    version: 1,\n    runtime: {\n      client: {\n        edgeFeatures: {\n          signaling: true,\n          echoReplicator: true,\n          feedReplicator: true,\n        },\n      },\n      services: {\n        edge: {\n          url: edgeUrl(edge),\n        },\n        ...(sandbox ? { sandbox: { url: sandboxUrl(sandbox) } } : {}),\n      },\n    },\n  });\n"],
  "m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,cAAc;AACd,cAAc;;;AGVd,SAASQ,cAAc;AAkBhB,IAAMC,sBAAsB,CAACC,WAAAA;AAClC,SAAOA,QAAQC,IAAI,kCAAA,MAAwCH,OAAAA,IAAWI,QAAQC,IAAIC,mBAAmBC;AACvG;;;ACpBA,YAAYC,WAAW;AAiBvB,IAAMC,UAAU,CAACC,SACTC,YAAMD,IAAAA,EAAME,KACVC,WAAK,SAAS,MAAM,uBAAA,GACpBA,WAAK,OAAO,MAAM,+BAAA,GAClBA,WAAK,QAAQ,MAAM,oCAAA,GACnBA,WAAK,cAAc,MAAM,0CAAA,GACzBC,gBAAU;AAIpB,IAAMC,aAAa,CAACC,YACZL,YAAMK,OAAAA,EAASJ,KACbC,WAAK,SAAS,MAAM,uBAAA,GACpBA,WAAK,OAAO,MAAM,0CAAA,GAClBA,WAAK,QAAQ,MAAM,0CAAA,GACnBA,WAAK,cAAc,MAAM,0CAAA,GACzBC,gBAAU;AAGb,IAAMG,eAAe,CAAC,EAAEP,OAAO,QAAQM,QAAO,IAA0B,CAAC,MAC9E,IAAIE,OAAO;EACTC,SAAS;EACTC,SAAS;IACPC,QAAQ;MACNC,cAAc;QACZC,WAAW;QACXC,gBAAgB;QAChBC,gBAAgB;MAClB;IACF;IACAC,UAAU;MACRhB,MAAM;QACJiB,KAAKlB,QAAQC,IAAAA;MACf;MACA,GAAIM,UAAU;QAAEA,SAAS;UAAEW,KAAKZ,WAAWC,OAAAA;QAAS;MAAE,IAAI,CAAC;IAC7D;EACF;AACF,CAAA;",
  "names": ["defs", "FileSystem", "Context", "Effect", "Layer", "Option", "dirname", "Yaml", "DX_CONFIG", "DX_DATA", "getProfileConfigPath", "getProfilePath", "invariant", "memoryConfig", "client", "edgeFeatures", "echoReplicator", "feedReplicator", "signaling", "agents", "storage", "services", "url", "iceProviders", "ipfs", "gateway", "fromConfig", "succeed", "ConfigService", "config", "load", "args", "defaultConfigPath", "getProfileConfigPath", "DX_CONFIG", "Effect", "FileSystem", "configPath", "getOrElse", "configContent", "fs", "configValues", "parse", "of", "Config", "profileBuiltinDefaults", "pipe", "catchTag", "pathToCreate", "Option", "makeDirectory", "dirname", "recursive", "writeFileString", "runtime", "dataRoot", "EdgeServiceName", "Object", "freeze", "Calls", "Image", "Transcription", "Discord", "CorsProxy", "ApiProxy", "Introspect", "ChatAgent", "EDGE_SERVICE_DEFAULTS", "getEdgeServiceEndpoint", "config", "name", "values", "runtime", "services", "edgeServices", "findLast", "service", "endpoint", "isNode", "resolveTelemetryTag", "config", "get", "process", "env", "DX_TELEMETRY_TAG", "undefined", "Match", "edgeUrl", "edge", "value", "pipe", "when", "exhaustive", "sandboxUrl", "sandbox", "configPreset", "Config", "version", "runtime", "client", "edgeFeatures", "signaling", "echoReplicator", "feedReplicator", "services", "url"]
}
