@dxos/config 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/config",
3
- "version": "0.9.1-main.c7dcc2e112",
3
+ "version": "0.10.0",
4
4
  "description": "Config utilities",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -77,20 +77,20 @@
77
77
  "src"
78
78
  ],
79
79
  "dependencies": {
80
- "@effect/platform": "0.96.1",
81
- "effect": "3.21.3",
80
+ "@effect/platform": "0.96.2",
81
+ "effect": "3.21.4",
82
82
  "localforage": "^1.10.0",
83
83
  "lodash.defaultsdeep": "^4.6.1",
84
84
  "lodash.ismatch": "^4.4.0",
85
85
  "pkg-up": "^3.1.0",
86
86
  "yaml": "^2.8.2",
87
- "@dxos/client-protocol": "0.9.1-main.c7dcc2e112",
88
- "@dxos/invariant": "0.9.1-main.c7dcc2e112",
89
- "@dxos/log": "0.9.1-main.c7dcc2e112",
90
- "@dxos/protocols": "0.9.1-main.c7dcc2e112",
91
- "@dxos/tracing": "0.9.1-main.c7dcc2e112",
92
- "@dxos/node-std": "0.9.1-main.c7dcc2e112",
93
- "@dxos/util": "0.9.1-main.c7dcc2e112"
87
+ "@dxos/client-protocol": "0.10.0",
88
+ "@dxos/invariant": "0.10.0",
89
+ "@dxos/log": "0.10.0",
90
+ "@dxos/node-std": "0.10.0",
91
+ "@dxos/protocols": "0.10.0",
92
+ "@dxos/util": "0.10.0",
93
+ "@dxos/tracing": "0.10.0"
94
94
  },
95
95
  "devDependencies": {
96
96
  "@types/lodash.defaultsdeep": "^4.6.6",
@@ -0,0 +1,49 @@
1
+ //
2
+ // Copyright 2026 DXOS.org
3
+ //
4
+
5
+ import { type Config } from './config';
6
+
7
+ /**
8
+ * Canonical names for EDGE (Cloudflare Worker) services.
9
+ * Used as keys into `runtime.services.edgeServices` and {@link EDGE_SERVICE_DEFAULTS}.
10
+ */
11
+ export const EdgeServiceName = Object.freeze({
12
+ Calls: 'calls',
13
+ Image: 'image',
14
+ Transcription: 'transcription',
15
+ Discord: 'discord',
16
+ CorsProxy: 'cors-proxy',
17
+ ApiProxy: 'api-proxy',
18
+ Introspect: 'introspect',
19
+ ChatAgent: 'chat-agent',
20
+ } as const);
21
+
22
+ export type EdgeServiceName = (typeof EdgeServiceName)[keyof typeof EdgeServiceName];
23
+
24
+ /**
25
+ * Canonical dev/test default endpoints for EDGE services.
26
+ * Single source of truth for the URLs previously hard-coded across plugins.
27
+ * Production values are supplied per-app via `dx.yml` (`runtime.services.edgeServices`).
28
+ */
29
+ export const EDGE_SERVICE_DEFAULTS: Readonly<Record<EdgeServiceName, string>> = Object.freeze({
30
+ [EdgeServiceName.Calls]: 'https://calls-service.dxos.workers.dev',
31
+ [EdgeServiceName.Image]: 'https://image-service-main.dxos.workers.dev',
32
+ [EdgeServiceName.Transcription]: 'https://calls-service.dxos.workers.dev',
33
+ [EdgeServiceName.Discord]: 'https://discord-service.dxos.workers.dev',
34
+ [EdgeServiceName.CorsProxy]: 'https://cors-proxy.dxos.workers.dev',
35
+ [EdgeServiceName.ApiProxy]: 'https://api-proxy.dxos.workers.dev',
36
+ [EdgeServiceName.Introspect]: 'https://introspect-service-labs.dxos.workers.dev/mcp',
37
+ [EdgeServiceName.ChatAgent]: 'wss://chat-agent-labs.dxos.workers.dev',
38
+ });
39
+
40
+ /**
41
+ * Resolve the endpoint for an EDGE service.
42
+ * Prefers the matching `runtime.services.edgeServices` entry, falling back to the canonical
43
+ * {@link EDGE_SERVICE_DEFAULTS} entry.
44
+ * `name` is expected to be unique; on duplicates the last entry wins so a later override is
45
+ * not silently shadowed by an earlier one (proto cannot enforce uniqueness on a repeated field).
46
+ */
47
+ export const getEdgeServiceEndpoint = (config: Config, name: EdgeServiceName): string =>
48
+ config.values.runtime?.services?.edgeServices?.findLast((service) => service.name === name)?.endpoint ??
49
+ EDGE_SERVICE_DEFAULTS[name];
package/src/index.ts CHANGED
@@ -9,6 +9,7 @@ export { type Config as ConfigProto } from '@dxos/protocols/proto/dxos/config';
9
9
 
10
10
  export * from './config';
11
11
  export * from './config-service';
12
+ export * from './edge-services';
12
13
  export * from '#loaders';
13
14
  export * from '#savers';
14
15
  export * from '#plugin';
package/src/preset.ts CHANGED
@@ -12,9 +12,33 @@ export type ConfigPresetOptions = {
12
12
  * @default main
13
13
  */
14
14
  edge?: 'local' | 'dev' | 'main' | 'production';
15
+
16
+ /**
17
+ * Sandbox service (standalone worker; API at /api/sandbox).
18
+ */
19
+ sandbox?: 'local' | 'dev' | 'main' | 'production';
15
20
  };
16
21
 
17
- export const configPreset = ({ edge = 'main' }: ConfigPresetOptions = {}) =>
22
+ const edgeUrl = (edge: NonNullable<ConfigPresetOptions['edge']>) =>
23
+ Match.value(edge).pipe(
24
+ Match.when('local', () => 'http://localhost:8787'),
25
+ Match.when('dev', () => 'https://edge.dxos.workers.dev'),
26
+ Match.when('main', () => 'https://edge-main.dxos.workers.dev'),
27
+ Match.when('production', () => 'https://edge-production.dxos.workers.dev'),
28
+ Match.exhaustive,
29
+ );
30
+
31
+ // TODO(burdon): Hosted environments share a single worker until per-env deployments exist.
32
+ const sandboxUrl = (sandbox: NonNullable<ConfigPresetOptions['sandbox']>) =>
33
+ Match.value(sandbox).pipe(
34
+ Match.when('local', () => 'http://localhost:8792'),
35
+ Match.when('dev', () => 'https://sandbox-service.dxos.workers.dev'),
36
+ Match.when('main', () => 'https://sandbox-service.dxos.workers.dev'),
37
+ Match.when('production', () => 'https://sandbox-service.dxos.workers.dev'),
38
+ Match.exhaustive,
39
+ );
40
+
41
+ export const configPreset = ({ edge = 'main', sandbox }: ConfigPresetOptions = {}) =>
18
42
  new Config({
19
43
  version: 1,
20
44
  runtime: {
@@ -27,14 +51,9 @@ export const configPreset = ({ edge = 'main' }: ConfigPresetOptions = {}) =>
27
51
  },
28
52
  services: {
29
53
  edge: {
30
- url: Match.value(edge).pipe(
31
- Match.when('local', () => 'http://localhost:8787'),
32
- Match.when('dev', () => 'https://edge.dxos.workers.dev'),
33
- Match.when('main', () => 'https://edge-main.dxos.workers.dev'),
34
- Match.when('production', () => 'https://edge-production.dxos.workers.dev'),
35
- Match.exhaustive,
36
- ),
54
+ url: edgeUrl(edge),
37
55
  },
56
+ ...(sandbox ? { sandbox: { url: sandboxUrl(sandbox) } } : {}),
38
57
  },
39
58
  },
40
59
  });