@dxos/compute 0.8.4-main.dedc0f3 → 0.8.4-main.dfabb4ec29

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.
Files changed (167) hide show
  1. package/README.md +36 -1
  2. package/dist/lib/neutral/StorageService.mjs +22 -0
  3. package/dist/lib/neutral/chunk-CXDV2FPU.mjs +53 -0
  4. package/dist/lib/neutral/chunk-CXDV2FPU.mjs.map +7 -0
  5. package/dist/lib/neutral/chunk-EG7VLX2F.mjs +25 -0
  6. package/dist/lib/neutral/chunk-EG7VLX2F.mjs.map +7 -0
  7. package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
  8. package/dist/lib/neutral/chunk-JTZYM2QW.mjs +144 -0
  9. package/dist/lib/neutral/chunk-JTZYM2QW.mjs.map +7 -0
  10. package/dist/lib/neutral/chunk-OA7JMLJK.mjs +17 -0
  11. package/dist/lib/neutral/chunk-OA7JMLJK.mjs.map +7 -0
  12. package/dist/lib/neutral/chunk-VIRNEVFD.mjs +199 -0
  13. package/dist/lib/neutral/chunk-VIRNEVFD.mjs.map +7 -0
  14. package/dist/lib/neutral/chunk-XEVFBI6S.mjs +62 -0
  15. package/dist/lib/neutral/chunk-XEVFBI6S.mjs.map +7 -0
  16. package/dist/lib/neutral/chunk-YEDUHFRC.mjs +21 -0
  17. package/dist/lib/neutral/chunk-YEDUHFRC.mjs.map +7 -0
  18. package/dist/lib/neutral/fib-WSN4EY7R.mjs +10 -0
  19. package/dist/lib/neutral/fib-WSN4EY7R.mjs.map +7 -0
  20. package/dist/lib/neutral/index.mjs +1073 -0
  21. package/dist/lib/neutral/index.mjs.map +7 -0
  22. package/dist/lib/neutral/meta.json +1 -0
  23. package/dist/lib/neutral/reply-XRLTFNDF.mjs +10 -0
  24. package/dist/lib/neutral/reply-XRLTFNDF.mjs.map +7 -0
  25. package/dist/lib/neutral/sleep-7O76LQCA.mjs +10 -0
  26. package/dist/lib/neutral/sleep-7O76LQCA.mjs.map +7 -0
  27. package/dist/lib/neutral/testing/index.mjs +32 -0
  28. package/dist/lib/neutral/testing/index.mjs.map +7 -0
  29. package/dist/types/src/Blueprint.d.ts +140 -0
  30. package/dist/types/src/Blueprint.d.ts.map +1 -0
  31. package/dist/types/src/Credential.d.ts +27 -0
  32. package/dist/types/src/Credential.d.ts.map +1 -0
  33. package/dist/types/src/McpServer.d.ts +27 -0
  34. package/dist/types/src/McpServer.d.ts.map +1 -0
  35. package/dist/types/src/Operation.d.ts +309 -0
  36. package/dist/types/src/Operation.d.ts.map +1 -0
  37. package/dist/types/src/OperationHandlerSet.d.ts +60 -0
  38. package/dist/types/src/OperationHandlerSet.d.ts.map +1 -0
  39. package/dist/types/src/OperationRegistry.d.ts +23 -0
  40. package/dist/types/src/OperationRegistry.d.ts.map +1 -0
  41. package/dist/types/src/Process.d.ts +247 -0
  42. package/dist/types/src/Process.d.ts.map +1 -0
  43. package/dist/types/src/Routine.d.ts +63 -0
  44. package/dist/types/src/Routine.d.ts.map +1 -0
  45. package/dist/types/src/Script.d.ts +22 -0
  46. package/dist/types/src/Script.d.ts.map +1 -0
  47. package/dist/types/src/ServiceResolver.d.ts +74 -0
  48. package/dist/types/src/ServiceResolver.d.ts.map +1 -0
  49. package/dist/types/src/StorageService.d.ts +58 -0
  50. package/dist/types/src/StorageService.d.ts.map +1 -0
  51. package/dist/types/src/Template.d.ts +62 -0
  52. package/dist/types/src/Template.d.ts.map +1 -0
  53. package/dist/types/src/Template.test.d.ts +2 -0
  54. package/dist/types/src/Template.test.d.ts.map +1 -0
  55. package/dist/types/src/Trace.d.ts +174 -0
  56. package/dist/types/src/Trace.d.ts.map +1 -0
  57. package/dist/types/src/Trigger.d.ts +150 -0
  58. package/dist/types/src/Trigger.d.ts.map +1 -0
  59. package/dist/types/src/TriggerEvent.d.ts +75 -0
  60. package/dist/types/src/TriggerEvent.d.ts.map +1 -0
  61. package/dist/types/src/errors.d.ts +308 -0
  62. package/dist/types/src/errors.d.ts.map +1 -0
  63. package/dist/types/src/index.d.ts +16 -5
  64. package/dist/types/src/index.d.ts.map +1 -1
  65. package/dist/types/src/testing/definitions.d.ts +11 -0
  66. package/dist/types/src/testing/definitions.d.ts.map +1 -0
  67. package/dist/types/src/testing/fib.d.ts +8 -0
  68. package/dist/types/src/testing/fib.d.ts.map +1 -0
  69. package/dist/types/src/testing/index.d.ts +6 -3
  70. package/dist/types/src/testing/index.d.ts.map +1 -1
  71. package/dist/types/src/testing/reply.d.ts +4 -0
  72. package/dist/types/src/testing/reply.d.ts.map +1 -0
  73. package/dist/types/src/testing/sleep.d.ts +6 -0
  74. package/dist/types/src/testing/sleep.d.ts.map +1 -0
  75. package/dist/types/src/umbrella.test.d.ts +2 -0
  76. package/dist/types/src/umbrella.test.d.ts.map +1 -0
  77. package/dist/types/tsconfig.tsbuildinfo +1 -1
  78. package/package.json +27 -39
  79. package/src/Blueprint.ts +207 -0
  80. package/src/Credential.ts +53 -0
  81. package/src/McpServer.ts +44 -0
  82. package/src/Operation.ts +533 -0
  83. package/src/OperationHandlerSet.ts +134 -0
  84. package/src/OperationRegistry.ts +50 -0
  85. package/src/Process.ts +490 -0
  86. package/src/Routine.ts +88 -0
  87. package/src/Script.ts +40 -0
  88. package/src/ServiceResolver.ts +174 -0
  89. package/src/StorageService.ts +101 -0
  90. package/src/Template.test.ts +151 -0
  91. package/src/Template.ts +122 -0
  92. package/src/Trace.ts +231 -0
  93. package/src/Trigger.ts +209 -0
  94. package/src/TriggerEvent.ts +64 -0
  95. package/src/errors.ts +71 -0
  96. package/src/index.ts +17 -32
  97. package/src/testing/definitions.ts +49 -0
  98. package/src/testing/fib.ts +22 -0
  99. package/src/testing/index.ts +13 -4
  100. package/src/testing/reply.ts +18 -0
  101. package/src/testing/sleep.ts +16 -0
  102. package/src/umbrella.test.ts +51 -0
  103. package/dist/lib/browser/chunk-XQYPCRZP.mjs +0 -3140
  104. package/dist/lib/browser/chunk-XQYPCRZP.mjs.map +0 -7
  105. package/dist/lib/browser/index.mjs +0 -55
  106. package/dist/lib/browser/meta.json +0 -1
  107. package/dist/lib/browser/testing/index.mjs +0 -186
  108. package/dist/lib/browser/testing/index.mjs.map +0 -7
  109. package/dist/lib/node-esm/chunk-2XWWSGAU.mjs +0 -3142
  110. package/dist/lib/node-esm/chunk-2XWWSGAU.mjs.map +0 -7
  111. package/dist/lib/node-esm/index.mjs +0 -56
  112. package/dist/lib/node-esm/meta.json +0 -1
  113. package/dist/lib/node-esm/testing/index.mjs +0 -187
  114. package/dist/lib/node-esm/testing/index.mjs.map +0 -7
  115. package/dist/types/src/compute-graph-registry.d.ts +0 -32
  116. package/dist/types/src/compute-graph-registry.d.ts.map +0 -1
  117. package/dist/types/src/compute-graph.d.ts +0 -64
  118. package/dist/types/src/compute-graph.d.ts.map +0 -1
  119. package/dist/types/src/compute-graph.test.d.ts +0 -2
  120. package/dist/types/src/compute-graph.test.d.ts.map +0 -1
  121. package/dist/types/src/compute-node.d.ts +0 -24
  122. package/dist/types/src/compute-node.d.ts.map +0 -1
  123. package/dist/types/src/functions/async-function.d.ts +0 -66
  124. package/dist/types/src/functions/async-function.d.ts.map +0 -1
  125. package/dist/types/src/functions/edge-function.d.ts +0 -20
  126. package/dist/types/src/functions/edge-function.d.ts.map +0 -1
  127. package/dist/types/src/functions/function-defs.d.ts +0 -11
  128. package/dist/types/src/functions/function-defs.d.ts.map +0 -1
  129. package/dist/types/src/functions/index.d.ts +0 -4
  130. package/dist/types/src/functions/index.d.ts.map +0 -1
  131. package/dist/types/src/hyperformula.test.d.ts +0 -2
  132. package/dist/types/src/hyperformula.test.d.ts.map +0 -1
  133. package/dist/types/src/testing/test-builder.d.ts +0 -15
  134. package/dist/types/src/testing/test-builder.d.ts.map +0 -1
  135. package/dist/types/src/testing/test-plugin.d.ts +0 -35
  136. package/dist/types/src/testing/test-plugin.d.ts.map +0 -1
  137. package/dist/types/src/testing/util.d.ts +0 -2
  138. package/dist/types/src/testing/util.d.ts.map +0 -1
  139. package/dist/types/src/types/hyperformula.d.ts +0 -8
  140. package/dist/types/src/types/hyperformula.d.ts.map +0 -1
  141. package/dist/types/src/types/index.d.ts +0 -3
  142. package/dist/types/src/types/index.d.ts.map +0 -1
  143. package/dist/types/src/types/types.d.ts +0 -20
  144. package/dist/types/src/types/types.d.ts.map +0 -1
  145. package/dist/types/src/types/types.test.d.ts +0 -2
  146. package/dist/types/src/types/types.test.d.ts.map +0 -1
  147. package/dist/types/src/util.d.ts +0 -2
  148. package/dist/types/src/util.d.ts.map +0 -1
  149. package/src/compute-graph-registry.ts +0 -88
  150. package/src/compute-graph.test.ts +0 -88
  151. package/src/compute-graph.ts +0 -258
  152. package/src/compute-node.ts +0 -59
  153. package/src/functions/async-function.ts +0 -183
  154. package/src/functions/edge-function.ts +0 -111
  155. package/src/functions/function-defs.ts +0 -2427
  156. package/src/functions/index.ts +0 -7
  157. package/src/hyperformula.test.ts +0 -14
  158. package/src/testing/test-builder.ts +0 -54
  159. package/src/testing/test-plugin.ts +0 -98
  160. package/src/testing/util.ts +0 -9
  161. package/src/types/hyperformula.ts +0 -19
  162. package/src/types/index.ts +0 -6
  163. package/src/types/types.test.ts +0 -91
  164. package/src/types/types.ts +0 -80
  165. package/src/util.ts +0 -8
  166. /package/dist/lib/{browser/index.mjs.map → neutral/StorageService.mjs.map} +0 -0
  167. /package/dist/lib/{node-esm/index.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
package/package.json CHANGED
@@ -1,69 +1,57 @@
1
1
  {
2
2
  "name": "@dxos/compute",
3
- "version": "0.8.4-main.dedc0f3",
4
- "description": "Low-level compute API",
3
+ "version": "0.8.4-main.dfabb4ec29",
4
+ "description": "Umbrella package for AI-aware DXOS compute primitives.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dxos/dxos"
10
+ },
7
11
  "license": "MIT",
8
12
  "author": "DXOS.org",
9
- "sideEffects": true,
13
+ "sideEffects": false,
10
14
  "type": "module",
11
15
  "exports": {
12
16
  ".": {
13
17
  "source": "./src/index.ts",
14
18
  "types": "./dist/types/src/index.d.ts",
15
- "browser": "./dist/lib/browser/index.mjs",
16
- "node": "./dist/lib/node-esm/index.mjs"
19
+ "default": "./dist/lib/neutral/index.mjs"
20
+ },
21
+ "./StorageService": {
22
+ "source": "./src/StorageService.ts",
23
+ "types": "./dist/types/src/StorageService.d.ts",
24
+ "default": "./dist/lib/neutral/StorageService.mjs"
17
25
  },
18
26
  "./testing": {
19
27
  "source": "./src/testing/index.ts",
20
28
  "types": "./dist/types/src/testing/index.d.ts",
21
- "browser": "./dist/lib/browser/testing/index.mjs",
22
- "node": "./dist/lib/node-esm/testing/index.mjs"
29
+ "default": "./dist/lib/neutral/testing/index.mjs"
23
30
  }
24
31
  },
25
32
  "types": "dist/types/src/index.d.ts",
26
- "typesVersions": {
27
- "*": {
28
- "testing": [
29
- "dist/types/src/testing/index.d.ts"
30
- ]
31
- }
32
- },
33
33
  "files": [
34
34
  "dist",
35
35
  "src"
36
36
  ],
37
37
  "dependencies": {
38
- "@preact/signals-core": "^1.9.0",
39
- "effect": "3.17.7",
40
- "lodash.defaultsdeep": "^4.6.1",
41
- "@dxos/async": "0.8.4-main.dedc0f3",
42
- "@dxos/client": "0.8.4-main.dedc0f3",
43
- "@dxos/echo": "0.8.4-main.dedc0f3",
44
- "@dxos/context": "0.8.4-main.dedc0f3",
45
- "@dxos/echo-schema": "0.8.4-main.dedc0f3",
46
- "@dxos/echo-db": "0.8.4-main.dedc0f3",
47
- "@dxos/functions": "0.8.4-main.dedc0f3",
48
- "@dxos/invariant": "0.8.4-main.dedc0f3",
49
- "@dxos/log": "0.8.4-main.dedc0f3",
50
- "@dxos/live-object": "0.8.4-main.dedc0f3",
51
- "@dxos/schema": "0.8.4-main.dedc0f3",
52
- "@dxos/protocols": "0.8.4-main.dedc0f3",
53
- "@dxos/util": "0.8.4-main.dedc0f3",
54
- "@dxos/vendor-hyperformula": "0.8.4-main.dedc0f3",
55
- "@dxos/keys": "0.8.4-main.dedc0f3",
56
- "@dxos/debug": "0.8.4-main.dedc0f3"
38
+ "@effect-atom/atom": "^0.5.1",
39
+ "@dxos/errors": "0.8.4-main.dfabb4ec29",
40
+ "@dxos/ai": "0.8.4-main.dfabb4ec29",
41
+ "@dxos/echo": "0.8.4-main.dfabb4ec29",
42
+ "@dxos/invariant": "0.8.4-main.dfabb4ec29",
43
+ "@dxos/keys": "0.8.4-main.dfabb4ec29",
44
+ "@dxos/log": "0.8.4-main.dfabb4ec29",
45
+ "@dxos/protocols": "0.8.4-main.dfabb4ec29",
46
+ "@dxos/schema": "0.8.4-main.dfabb4ec29",
47
+ "@dxos/vendor-kbn-handlebars": "0.8.4-main.dfabb4ec29"
57
48
  },
58
49
  "devDependencies": {
59
- "@tldraw/indices": "^2.0.0-alpha.14",
60
- "@types/lodash.defaultsdeep": "^4.6.6",
61
- "@dxos/echo-db": "0.8.4-main.dedc0f3",
62
- "@dxos/echo-schema": "0.8.4-main.dedc0f3",
63
- "@dxos/random": "0.8.4-main.dedc0f3"
50
+ "effect": "3.20.0",
51
+ "vitest": "4.1.5"
64
52
  },
65
53
  "peerDependencies": {
66
- "effect": "^3.13.3"
54
+ "effect": "3.20.0"
67
55
  },
68
56
  "publishConfig": {
69
57
  "access": "public"
@@ -0,0 +1,207 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ // @import-as-namespace
6
+
7
+ import * as Context from 'effect/Context';
8
+ import * as Effect from 'effect/Effect';
9
+ import * as Schema from 'effect/Schema';
10
+
11
+ import { ToolId } from '@dxos/ai';
12
+ import { Annotation, Database, Filter, Obj, Type } from '@dxos/echo';
13
+ import { BaseError } from '@dxos/errors';
14
+ import { log } from '@dxos/log';
15
+
16
+ import * as McpServer from './McpServer';
17
+ import * as Operation from './Operation';
18
+ import * as Template from './Template';
19
+
20
+ /**
21
+ * Blueprint schema defines the structure for AI assistant blueprints.
22
+ * Blueprints contain instructions, tools, and artifacts that guide the AI's behavior.
23
+ * Blueprints may use tools to create and read artifacts, which are managed by the assistant.
24
+ */
25
+ // TODO(burdon): Rename Skill?
26
+ export const Blueprint = Schema.Struct({
27
+ /**
28
+ * Global registry ID.
29
+ * NOTE: The `key` property refers to the original registry entry.
30
+ */
31
+ // TODO(burdon): Create Format type for DXN-like ids, such as this and schema type.
32
+ key: Schema.String.annotations({
33
+ description: 'Unique registration key for the blueprint',
34
+ }),
35
+
36
+ /**
37
+ * Human-readable name of the blueprint.
38
+ */
39
+ name: Schema.String.annotations({
40
+ description: 'Human-readable name of the blueprint',
41
+ }),
42
+
43
+ /**
44
+ * Description of the blueprint's purpose and functionality.
45
+ */
46
+ description: Schema.optional(Schema.String).annotations({
47
+ description: "Description of the blueprint's purpose and functionality",
48
+ }),
49
+
50
+ /**
51
+ * Instructions that guide the AI assistant's behavior and responses.
52
+ * These are system prompts or guidelines that the AI should follow.
53
+ */
54
+ instructions: Template.Template.annotations({
55
+ description: "Instructions that guide the AI assistant's behavior and responses",
56
+ }),
57
+
58
+ /**
59
+ * Array of tools that the AI assistant can use when this blueprint is active.
60
+ */
61
+ tools: Schema.Array(ToolId).annotations({
62
+ description: 'Array of tools that the AI assistant can use when this blueprint is active',
63
+ }),
64
+
65
+ /**
66
+ * Whether an agent is allowed to auto-enable this blueprint in a conversation.
67
+ */
68
+ agentCanEnable: Schema.optional(Schema.Boolean).annotations({
69
+ description: 'Whether an agent is allowed to auto-enable this blueprint in a conversation.',
70
+ }),
71
+
72
+ /**
73
+ * Array of MCP servers that the AI assistant can use when this blueprint is active.
74
+ */
75
+ mcpServers: Schema.optional(Schema.Array(McpServer.McpServer)),
76
+ }).pipe(
77
+ Type.object({
78
+ typename: 'org.dxos.type.blueprint',
79
+ version: '0.1.0',
80
+ }),
81
+ Annotation.LabelAnnotation.set(['name']),
82
+ Annotation.IconAnnotation.set({
83
+ icon: 'ph--blueprint--regular',
84
+ hue: 'sky',
85
+ }),
86
+ );
87
+
88
+ /**
89
+ * TypeScript type for Blueprint.
90
+ */
91
+ export interface Blueprint extends Schema.Schema.Type<typeof Blueprint> {}
92
+
93
+ type MakeProps = Pick<Blueprint, 'key' | 'name'> & Partial<Blueprint>;
94
+
95
+ /**
96
+ * Create a new Blueprint.
97
+ */
98
+ export const make = ({ tools = [], instructions = Template.make(), ...props }: MakeProps) =>
99
+ Obj.make(Blueprint, {
100
+ tools,
101
+ instructions,
102
+ ...props,
103
+ });
104
+
105
+ /**
106
+ * Util to create tool definitions for a blueprint.
107
+ */
108
+ export const toolDefinitions = ({
109
+ tools = [],
110
+ operations = [],
111
+ }: {
112
+ tools?: string[];
113
+ operations?: Operation.Definition.Any[];
114
+ }) => [...operations.map((op) => ToolId.make(op.meta.key)), ...tools.map((tool) => ToolId.make(tool))];
115
+
116
+ /**
117
+ * Factory for the blueprints.
118
+ */
119
+ export type Definition = {
120
+ key: string;
121
+ make: () => Blueprint;
122
+ };
123
+
124
+ //
125
+ // Registry
126
+ //
127
+
128
+ /**
129
+ * Blueprint registry.
130
+ */
131
+ export class Registry {
132
+ private readonly _blueprints: Blueprint[] = [];
133
+
134
+ constructor(blueprints: Blueprint[]) {
135
+ const seen = new Set<string>();
136
+ blueprints.forEach((blueprint) => {
137
+ if (seen.has(blueprint.key)) {
138
+ log.warn('duplicate blueprint', { key: blueprint.key });
139
+ } else {
140
+ seen.add(blueprint.key);
141
+ this._blueprints.push(blueprint);
142
+ }
143
+ });
144
+
145
+ this._blueprints.sort(({ name: a }, { name: b }) => a.localeCompare(b));
146
+ }
147
+
148
+ get blueprints(): Blueprint[] {
149
+ return this._blueprints;
150
+ }
151
+
152
+ getByKey(key: string): Blueprint | undefined {
153
+ return this._blueprints.find((blueprint) => blueprint.key === key);
154
+ }
155
+
156
+ query(): Blueprint[] {
157
+ return this._blueprints;
158
+ }
159
+
160
+ updateBlueprints(): Effect.Effect<void, never, Database.Service> {
161
+ return Effect.gen(this, function* () {
162
+ const blueprints = yield* Database.runQuery(Filter.type(Blueprint));
163
+ for (const blueprint of blueprints) {
164
+ const registryBlueprint = this.getByKey(blueprint.key);
165
+ if (!registryBlueprint) {
166
+ continue;
167
+ }
168
+ const source = Obj.clone(registryBlueprint, { deep: true });
169
+ Obj.update(blueprint, (blueprint) => {
170
+ void Obj.updateFrom(blueprint, source);
171
+ });
172
+ }
173
+ }).pipe(Effect.orDie);
174
+ }
175
+ }
176
+
177
+ export class RegistryService extends Context.Tag('@dxos/blueprints/RegistryService')<RegistryService, Registry>() {}
178
+
179
+ /**
180
+ * Resolves a blueprint from the registry.
181
+ * Does not check the local database for the blueprint.
182
+ */
183
+ export const resolve = (key: string): Effect.Effect<Blueprint, NotFoundError, RegistryService> =>
184
+ Effect.gen(function* () {
185
+ const registry = yield* RegistryService;
186
+ const blueprint = registry.getByKey(key);
187
+ if (!blueprint) {
188
+ return yield* Effect.fail(new NotFoundError({ context: { key } }));
189
+ }
190
+ return blueprint;
191
+ });
192
+
193
+ /**
194
+ * Upserts a blueprint into the database.
195
+ * If the blueprint already exists in the database, local blueprint is returned.
196
+ * Otherwise, it will be added.
197
+ */
198
+ export const upsert = (key: string): Effect.Effect<Blueprint, NotFoundError, RegistryService | Database.Service> =>
199
+ Effect.gen(function* () {
200
+ const local = yield* Database.runQuery(Filter.type(Blueprint, { key }));
201
+ if (local.length > 0) {
202
+ return local[0];
203
+ }
204
+ return yield* Database.add(Obj.clone(yield* resolve(key), { deep: true }));
205
+ });
206
+
207
+ export class NotFoundError extends BaseError.extend('BlueprintNotFound', 'Blueprint not found') {}
@@ -0,0 +1,53 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ // @import-as-namespace
6
+
7
+ import * as Context from 'effect/Context';
8
+ import * as Effect from 'effect/Effect';
9
+ import * as Redacted from 'effect/Redacted';
10
+
11
+ export type CredentialQuery = {
12
+ service?: string;
13
+ };
14
+
15
+ // TODO(dmaretskyi): Unify with other apis.
16
+ // packages/sdk/schema/src/common/access-token.ts
17
+ export type ServiceCredential = {
18
+ service: string;
19
+
20
+ // TODO(dmaretskyi): Build out.
21
+ apiKey?: string;
22
+ };
23
+
24
+ export class CredentialsService extends Context.Tag('@dxos/functions/CredentialsService')<
25
+ CredentialsService,
26
+ {
27
+ /**
28
+ * Query all.
29
+ */
30
+ queryCredentials: (query: CredentialQuery) => Promise<ServiceCredential[]>;
31
+
32
+ /**
33
+ * Get a single credential.
34
+ * @throws {Error} If no credential is found.
35
+ */
36
+ getCredential: (query: CredentialQuery) => Promise<ServiceCredential>;
37
+ }
38
+ >() {
39
+ static getCredential = (query: CredentialQuery): Effect.Effect<ServiceCredential, never, CredentialsService> =>
40
+ Effect.gen(function* () {
41
+ const credentials = yield* CredentialsService;
42
+ return yield* Effect.promise(() => credentials.getCredential(query));
43
+ });
44
+
45
+ static getApiKey = (query: CredentialQuery): Effect.Effect<Redacted.Redacted<string>, never, CredentialsService> =>
46
+ Effect.gen(function* () {
47
+ const credential = yield* CredentialsService.getCredential(query);
48
+ if (!credential.apiKey) {
49
+ throw new Error(`API key not found for service: ${query.service}`);
50
+ }
51
+ return Redacted.make(credential.apiKey);
52
+ });
53
+ }
@@ -0,0 +1,44 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ // @import-as-namespace
6
+
7
+ import * as Schema from 'effect/Schema';
8
+
9
+ /**
10
+ * MCP server connection spec — the minimal fields needed to dial an MCP server.
11
+ *
12
+ * Used as a value type embedded in blueprints and passed to runtime session connect logic.
13
+ * The user-facing ECHO object (`@dxos/assistant-toolkit` `McpServer`) composes this struct
14
+ * and adds instance-level fields (`name`, `enabled`) and ECHO annotations.
15
+ */
16
+ export const McpServer = Schema.Struct({
17
+ name: Schema.String.pipe(Schema.optional).annotations({
18
+ description: 'Human-readable name of the MCP server',
19
+ }),
20
+
21
+ url: Schema.String.annotations({
22
+ description: 'URL of the MCP server',
23
+ }),
24
+
25
+ /**
26
+ * Transport protocol. Prefer `'http'` (Streamable HTTP) for new servers; `'sse'` is
27
+ * kept for compatibility with servers that haven't migrated and is deprecated per
28
+ * the MCP SDK. Clients support both during the migration period.
29
+ */
30
+ protocol: Schema.Union(Schema.Literal('http'), Schema.Literal('sse')).annotations({
31
+ description: 'Transport protocol of the MCP server (prefer "http"; "sse" deprecated)',
32
+ }),
33
+
34
+ /**
35
+ * Optional API key sent with requests.
36
+ * Persisted in plaintext when stored on a space-replicated ECHO object — see the
37
+ * `@dxos/assistant-toolkit` `McpServer` type for security implications.
38
+ */
39
+ apiKey: Schema.optional(Schema.String).annotations({
40
+ description: 'Optional API key sent with requests',
41
+ }),
42
+ });
43
+
44
+ export interface McpServer extends Schema.Schema.Type<typeof McpServer> {}