@dxos/compute 0.8.4-main.e8ec1fe → 0.8.4-main.f466a3d56e

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 (180) hide show
  1. package/LICENSE +102 -5
  2. package/README.md +36 -1
  3. package/dist/lib/neutral/StorageService.mjs +22 -0
  4. package/dist/lib/neutral/chunk-AKVCVI6N.mjs +25 -0
  5. package/dist/lib/neutral/chunk-AKVCVI6N.mjs.map +7 -0
  6. package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
  7. package/dist/lib/neutral/chunk-LF2ANNYW.mjs +171 -0
  8. package/dist/lib/neutral/chunk-LF2ANNYW.mjs.map +7 -0
  9. package/dist/lib/neutral/chunk-LRCABAWU.mjs +17 -0
  10. package/dist/lib/neutral/chunk-LRCABAWU.mjs.map +7 -0
  11. package/dist/lib/neutral/chunk-RCLYF66G.mjs +21 -0
  12. package/dist/lib/neutral/chunk-RCLYF66G.mjs.map +7 -0
  13. package/dist/lib/neutral/chunk-SEBWOTOU.mjs +235 -0
  14. package/dist/lib/neutral/chunk-SEBWOTOU.mjs.map +7 -0
  15. package/dist/lib/neutral/chunk-VSICPGGY.mjs +53 -0
  16. package/dist/lib/neutral/chunk-VSICPGGY.mjs.map +7 -0
  17. package/dist/lib/neutral/chunk-XEVFBI6S.mjs +62 -0
  18. package/dist/lib/neutral/chunk-XEVFBI6S.mjs.map +7 -0
  19. package/dist/lib/neutral/fib-ZSJYREBW.mjs +10 -0
  20. package/dist/lib/neutral/fib-ZSJYREBW.mjs.map +7 -0
  21. package/dist/lib/neutral/index.mjs +1225 -0
  22. package/dist/lib/neutral/index.mjs.map +7 -0
  23. package/dist/lib/neutral/meta.json +1 -0
  24. package/dist/lib/neutral/reply-YH3BVOUT.mjs +10 -0
  25. package/dist/lib/neutral/reply-YH3BVOUT.mjs.map +7 -0
  26. package/dist/lib/neutral/sleep-TSPIQ5EY.mjs +10 -0
  27. package/dist/lib/neutral/sleep-TSPIQ5EY.mjs.map +7 -0
  28. package/dist/lib/neutral/testing/index.mjs +32 -0
  29. package/dist/lib/neutral/testing/index.mjs.map +7 -0
  30. package/dist/types/src/Blueprint.d.ts +192 -0
  31. package/dist/types/src/Blueprint.d.ts.map +1 -0
  32. package/dist/types/src/Credential.d.ts +27 -0
  33. package/dist/types/src/Credential.d.ts.map +1 -0
  34. package/dist/types/src/LayerSpec.d.ts +56 -0
  35. package/dist/types/src/LayerSpec.d.ts.map +1 -0
  36. package/dist/types/src/McpServer.d.ts +27 -0
  37. package/dist/types/src/McpServer.d.ts.map +1 -0
  38. package/dist/types/src/Operation.d.ts +340 -0
  39. package/dist/types/src/Operation.d.ts.map +1 -0
  40. package/dist/types/src/OperationHandlerSet.d.ts +67 -0
  41. package/dist/types/src/OperationHandlerSet.d.ts.map +1 -0
  42. package/dist/types/src/OperationHandlerSet.test.d.ts +2 -0
  43. package/dist/types/src/OperationHandlerSet.test.d.ts.map +1 -0
  44. package/dist/types/src/OperationRegistry.d.ts +23 -0
  45. package/dist/types/src/OperationRegistry.d.ts.map +1 -0
  46. package/dist/types/src/Process.d.ts +247 -0
  47. package/dist/types/src/Process.d.ts.map +1 -0
  48. package/dist/types/src/Routine.d.ts +63 -0
  49. package/dist/types/src/Routine.d.ts.map +1 -0
  50. package/dist/types/src/Script.d.ts +22 -0
  51. package/dist/types/src/Script.d.ts.map +1 -0
  52. package/dist/types/src/ServiceResolver.d.ts +89 -0
  53. package/dist/types/src/ServiceResolver.d.ts.map +1 -0
  54. package/dist/types/src/StorageService.d.ts +58 -0
  55. package/dist/types/src/StorageService.d.ts.map +1 -0
  56. package/dist/types/src/Template.d.ts +62 -0
  57. package/dist/types/src/Template.d.ts.map +1 -0
  58. package/dist/types/src/Template.test.d.ts +2 -0
  59. package/dist/types/src/Template.test.d.ts.map +1 -0
  60. package/dist/types/src/Trace.d.ts +268 -0
  61. package/dist/types/src/Trace.d.ts.map +1 -0
  62. package/dist/types/src/Trigger.d.ts +150 -0
  63. package/dist/types/src/Trigger.d.ts.map +1 -0
  64. package/dist/types/src/TriggerEvent.d.ts +75 -0
  65. package/dist/types/src/TriggerEvent.d.ts.map +1 -0
  66. package/dist/types/src/errors.d.ts +308 -0
  67. package/dist/types/src/errors.d.ts.map +1 -0
  68. package/dist/types/src/index.d.ts +17 -5
  69. package/dist/types/src/index.d.ts.map +1 -1
  70. package/dist/types/src/testing/definitions.d.ts +11 -0
  71. package/dist/types/src/testing/definitions.d.ts.map +1 -0
  72. package/dist/types/src/testing/fib.d.ts +8 -0
  73. package/dist/types/src/testing/fib.d.ts.map +1 -0
  74. package/dist/types/src/testing/index.d.ts +6 -4
  75. package/dist/types/src/testing/index.d.ts.map +1 -1
  76. package/dist/types/src/testing/reply.d.ts +4 -0
  77. package/dist/types/src/testing/reply.d.ts.map +1 -0
  78. package/dist/types/src/testing/sleep.d.ts +6 -0
  79. package/dist/types/src/testing/sleep.d.ts.map +1 -0
  80. package/dist/types/src/umbrella.test.d.ts +2 -0
  81. package/dist/types/src/umbrella.test.d.ts.map +1 -0
  82. package/dist/types/tsconfig.tsbuildinfo +1 -1
  83. package/package.json +29 -41
  84. package/src/Blueprint.ts +303 -0
  85. package/src/Credential.ts +53 -0
  86. package/src/LayerSpec.ts +91 -0
  87. package/src/McpServer.ts +44 -0
  88. package/src/Operation.ts +593 -0
  89. package/src/OperationHandlerSet.test.ts +92 -0
  90. package/src/OperationHandlerSet.ts +174 -0
  91. package/src/OperationRegistry.ts +50 -0
  92. package/src/Process.ts +504 -0
  93. package/src/Routine.ts +75 -0
  94. package/src/Script.ts +40 -0
  95. package/src/ServiceResolver.ts +194 -0
  96. package/src/StorageService.ts +101 -0
  97. package/src/Template.test.ts +151 -0
  98. package/src/Template.ts +122 -0
  99. package/src/Trace.ts +368 -0
  100. package/src/Trigger.ts +209 -0
  101. package/src/TriggerEvent.ts +64 -0
  102. package/src/errors.ts +71 -0
  103. package/src/index.ts +19 -6
  104. package/src/testing/definitions.ts +49 -0
  105. package/src/testing/fib.ts +22 -0
  106. package/src/testing/index.ts +13 -5
  107. package/src/testing/reply.ts +18 -0
  108. package/src/testing/sleep.ts +16 -0
  109. package/src/umbrella.test.ts +51 -0
  110. package/dist/lib/browser/chunk-CPBXT2HX.mjs +0 -3114
  111. package/dist/lib/browser/chunk-CPBXT2HX.mjs.map +0 -7
  112. package/dist/lib/browser/index.mjs +0 -55
  113. package/dist/lib/browser/meta.json +0 -1
  114. package/dist/lib/browser/testing/index.mjs +0 -197
  115. package/dist/lib/browser/testing/index.mjs.map +0 -7
  116. package/dist/lib/node-esm/chunk-D3RM3FQW.mjs +0 -3116
  117. package/dist/lib/node-esm/chunk-D3RM3FQW.mjs.map +0 -7
  118. package/dist/lib/node-esm/index.mjs +0 -56
  119. package/dist/lib/node-esm/meta.json +0 -1
  120. package/dist/lib/node-esm/testing/index.mjs +0 -198
  121. package/dist/lib/node-esm/testing/index.mjs.map +0 -7
  122. package/dist/types/src/compute-graph-registry.d.ts +0 -37
  123. package/dist/types/src/compute-graph-registry.d.ts.map +0 -1
  124. package/dist/types/src/compute-graph-registry.test.d.ts +0 -2
  125. package/dist/types/src/compute-graph-registry.test.d.ts.map +0 -1
  126. package/dist/types/src/compute-graph.d.ts +0 -67
  127. package/dist/types/src/compute-graph.d.ts.map +0 -1
  128. package/dist/types/src/compute-graph.test.d.ts +0 -2
  129. package/dist/types/src/compute-graph.test.d.ts.map +0 -1
  130. package/dist/types/src/compute-node.d.ts +0 -24
  131. package/dist/types/src/compute-node.d.ts.map +0 -1
  132. package/dist/types/src/functions/async-function.d.ts +0 -68
  133. package/dist/types/src/functions/async-function.d.ts.map +0 -1
  134. package/dist/types/src/functions/edge-function.d.ts +0 -20
  135. package/dist/types/src/functions/edge-function.d.ts.map +0 -1
  136. package/dist/types/src/functions/function-defs.d.ts +0 -11
  137. package/dist/types/src/functions/function-defs.d.ts.map +0 -1
  138. package/dist/types/src/functions/index.d.ts +0 -4
  139. package/dist/types/src/functions/index.d.ts.map +0 -1
  140. package/dist/types/src/hyperformula.test.d.ts +0 -2
  141. package/dist/types/src/hyperformula.test.d.ts.map +0 -1
  142. package/dist/types/src/testing/test-builder.d.ts +0 -15
  143. package/dist/types/src/testing/test-builder.d.ts.map +0 -1
  144. package/dist/types/src/testing/test-plugin.d.ts +0 -35
  145. package/dist/types/src/testing/test-plugin.d.ts.map +0 -1
  146. package/dist/types/src/testing/test-runtime.d.ts +0 -10
  147. package/dist/types/src/testing/test-runtime.d.ts.map +0 -1
  148. package/dist/types/src/testing/util.d.ts +0 -2
  149. package/dist/types/src/testing/util.d.ts.map +0 -1
  150. package/dist/types/src/types/hyperformula.d.ts +0 -8
  151. package/dist/types/src/types/hyperformula.d.ts.map +0 -1
  152. package/dist/types/src/types/index.d.ts +0 -3
  153. package/dist/types/src/types/index.d.ts.map +0 -1
  154. package/dist/types/src/types/types.d.ts +0 -20
  155. package/dist/types/src/types/types.d.ts.map +0 -1
  156. package/dist/types/src/types/types.test.d.ts +0 -2
  157. package/dist/types/src/types/types.test.d.ts.map +0 -1
  158. package/dist/types/src/util.d.ts +0 -2
  159. package/dist/types/src/util.d.ts.map +0 -1
  160. package/src/compute-graph-registry.test.ts +0 -154
  161. package/src/compute-graph-registry.ts +0 -97
  162. package/src/compute-graph.test.ts +0 -107
  163. package/src/compute-graph.ts +0 -270
  164. package/src/compute-node.ts +0 -59
  165. package/src/functions/async-function.ts +0 -184
  166. package/src/functions/edge-function.ts +0 -114
  167. package/src/functions/function-defs.ts +0 -2427
  168. package/src/functions/index.ts +0 -7
  169. package/src/hyperformula.test.ts +0 -14
  170. package/src/testing/test-builder.ts +0 -60
  171. package/src/testing/test-plugin.ts +0 -98
  172. package/src/testing/test-runtime.ts +0 -33
  173. package/src/testing/util.ts +0 -9
  174. package/src/types/hyperformula.ts +0 -19
  175. package/src/types/index.ts +0 -6
  176. package/src/types/types.test.ts +0 -91
  177. package/src/types/types.ts +0 -80
  178. package/src/util.ts +0 -8
  179. /package/dist/lib/{browser/index.mjs.map → neutral/StorageService.mjs.map} +0 -0
  180. /package/dist/lib/{node-esm/index.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
package/package.json CHANGED
@@ -1,70 +1,58 @@
1
1
  {
2
2
  "name": "@dxos/compute",
3
- "version": "0.8.4-main.e8ec1fe",
4
- "description": "Low-level compute API",
3
+ "version": "0.8.4-main.f466a3d56e",
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
- "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dxos/dxos"
10
+ },
11
+ "license": "FSL-1.1-Apache-2.0",
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.12.1",
39
- "effect": "3.18.3",
40
- "lodash.defaultsdeep": "^4.6.1",
41
- "@dxos/ai": "0.8.4-main.e8ec1fe",
42
- "@dxos/async": "0.8.4-main.e8ec1fe",
43
- "@dxos/debug": "0.8.4-main.e8ec1fe",
44
- "@dxos/echo": "0.8.4-main.e8ec1fe",
45
- "@dxos/functions": "0.8.4-main.e8ec1fe",
46
- "@dxos/client": "0.8.4-main.e8ec1fe",
47
- "@dxos/functions-runtime": "0.8.4-main.e8ec1fe",
48
- "@dxos/invariant": "0.8.4-main.e8ec1fe",
49
- "@dxos/keys": "0.8.4-main.e8ec1fe",
50
- "@dxos/log": "0.8.4-main.e8ec1fe",
51
- "@dxos/live-object": "0.8.4-main.e8ec1fe",
52
- "@dxos/plugin-automation": "0.8.4-main.e8ec1fe",
53
- "@dxos/context": "0.8.4-main.e8ec1fe",
54
- "@dxos/protocols": "0.8.4-main.e8ec1fe",
55
- "@dxos/schema": "0.8.4-main.e8ec1fe",
56
- "@dxos/vendor-hyperformula": "0.8.4-main.e8ec1fe",
57
- "@dxos/util": "0.8.4-main.e8ec1fe"
38
+ "@effect-atom/atom": "^0.5.1",
39
+ "@dxos/ai": "0.8.4-main.f466a3d56e",
40
+ "@dxos/errors": "0.8.4-main.f466a3d56e",
41
+ "@dxos/effect": "0.8.4-main.f466a3d56e",
42
+ "@dxos/invariant": "0.8.4-main.f466a3d56e",
43
+ "@dxos/echo": "0.8.4-main.f466a3d56e",
44
+ "@dxos/keys": "0.8.4-main.f466a3d56e",
45
+ "@dxos/log": "0.8.4-main.f466a3d56e",
46
+ "@dxos/protocols": "0.8.4-main.f466a3d56e",
47
+ "@dxos/vendor-kbn-handlebars": "0.8.4-main.f466a3d56e",
48
+ "@dxos/schema": "0.8.4-main.f466a3d56e"
58
49
  },
59
50
  "devDependencies": {
60
- "@tldraw/indices": "^2.0.0-alpha.14",
61
- "@types/lodash.defaultsdeep": "^4.6.6",
62
- "@dxos/echo": "0.8.4-main.e8ec1fe",
63
- "@dxos/echo-db": "0.8.4-main.e8ec1fe",
64
- "@dxos/random": "0.8.4-main.e8ec1fe"
51
+ "effect": "3.20.0",
52
+ "vitest": "4.1.6"
65
53
  },
66
54
  "peerDependencies": {
67
- "effect": "^3.13.3"
55
+ "effect": "3.20.0"
68
56
  },
69
57
  "publishConfig": {
70
58
  "access": "public"
@@ -0,0 +1,303 @@
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 Layer from 'effect/Layer';
10
+ import * as Schema from 'effect/Schema';
11
+
12
+ import { ToolId } from '@dxos/ai';
13
+ import { Annotation, Database, Filter, Migration, Obj, Type } from '@dxos/echo';
14
+ import { BaseError } from '@dxos/errors';
15
+ import { log } from '@dxos/log';
16
+
17
+ import * as McpServer from './McpServer';
18
+ import * as Operation from './Operation';
19
+ import * as Template from './Template';
20
+
21
+ /**
22
+ * Blueprint schema defines the structure for AI assistant blueprints.
23
+ * Blueprints contain instructions, tools, and artifacts that guide the AI's behavior.
24
+ * Blueprints may use tools to create and read artifacts, which are managed by the assistant.
25
+ *
26
+ * The registry `key` and `version` are stored in the object meta — access them via
27
+ * `Obj.getMeta(blueprint).key` and `Obj.getMeta(blueprint).version`.
28
+ */
29
+ // TODO(burdon): Rename Skill?
30
+ export const Blueprint = Schema.Struct({
31
+ /**
32
+ * Human-readable name of the blueprint.
33
+ */
34
+ name: Schema.String.annotations({
35
+ description: 'Human-readable name of the blueprint',
36
+ }),
37
+
38
+ /**
39
+ * Description of the blueprint's purpose and functionality.
40
+ */
41
+ description: Schema.optional(Schema.String).annotations({
42
+ description: "Description of the blueprint's purpose and functionality",
43
+ }),
44
+
45
+ /**
46
+ * Instructions that guide the AI assistant's behavior and responses.
47
+ * These are system prompts or guidelines that the AI should follow.
48
+ */
49
+ instructions: Template.Template.annotations({
50
+ description: "Instructions that guide the AI assistant's behavior and responses",
51
+ }),
52
+
53
+ /**
54
+ * Array of tools that the AI assistant can use when this blueprint is active.
55
+ */
56
+ tools: Schema.Array(ToolId).annotations({
57
+ description: 'Array of tools that the AI assistant can use when this blueprint is active',
58
+ }),
59
+
60
+ /**
61
+ * Whether an agent is allowed to auto-enable this blueprint in a conversation.
62
+ */
63
+ agentCanEnable: Schema.optional(Schema.Boolean).annotations({
64
+ description: 'Whether an agent is allowed to auto-enable this blueprint in a conversation.',
65
+ }),
66
+
67
+ /**
68
+ * Array of MCP servers that the AI assistant can use when this blueprint is active.
69
+ */
70
+ mcpServers: Schema.optional(Schema.Array(McpServer.McpServer)),
71
+ }).pipe(
72
+ Type.object({
73
+ typename: 'org.dxos.type.blueprint',
74
+ version: '0.2.0',
75
+ }),
76
+ Annotation.LabelAnnotation.set(['name']),
77
+ Annotation.IconAnnotation.set({
78
+ icon: 'ph--blueprint--regular',
79
+ hue: 'sky',
80
+ }),
81
+ );
82
+
83
+ /**
84
+ * TypeScript type for Blueprint.
85
+ */
86
+ export interface Blueprint extends Schema.Schema.Type<typeof Blueprint> {}
87
+
88
+ type MakeProps = { key: string; version?: string; name: string } & Partial<Blueprint>;
89
+
90
+ /**
91
+ * Create a new Blueprint.
92
+ * The `key` (and optional `version`) are stored in the object meta.
93
+ */
94
+ export const make = ({ key, version, tools = [], instructions = Template.make(), ...props }: MakeProps) =>
95
+ Obj.make(Blueprint, {
96
+ [Obj.Meta]: { key, version },
97
+ tools,
98
+ instructions,
99
+ ...props,
100
+ });
101
+
102
+ /**
103
+ * Get the registry key for a blueprint.
104
+ */
105
+ export const getKey = (blueprint: Blueprint): string => {
106
+ const key = Obj.getMeta(blueprint).key;
107
+ if (key === undefined) {
108
+ throw new Error('Blueprint is missing the meta key.');
109
+ }
110
+ return key;
111
+ };
112
+
113
+ /**
114
+ * Get the registry version for a blueprint, if any.
115
+ */
116
+ export const getVersion = (blueprint: Blueprint): string | undefined => Obj.getMeta(blueprint).version;
117
+
118
+ /**
119
+ * Util to create tool definitions for a blueprint.
120
+ */
121
+ export const toolDefinitions = ({
122
+ tools = [],
123
+ operations = [],
124
+ }: {
125
+ tools?: string[];
126
+ operations?: Operation.Definition.Any[];
127
+ }) => [...operations.map((op) => ToolId.make(op.meta.key)), ...tools.map((tool) => ToolId.make(tool))];
128
+
129
+ /**
130
+ * Factory for the blueprints.
131
+ */
132
+ export type Definition = {
133
+ key: string;
134
+ make: () => Blueprint;
135
+ };
136
+
137
+ //
138
+ // Registry
139
+ //
140
+
141
+ /**
142
+ * Blueprint registry.
143
+ */
144
+ export class Registry {
145
+ private readonly _blueprints: Blueprint[] = [];
146
+
147
+ constructor(blueprints: Blueprint[]) {
148
+ const seen = new Set<string>();
149
+ blueprints.forEach((blueprint) => {
150
+ const key = getKey(blueprint);
151
+ if (seen.has(key)) {
152
+ log.warn('duplicate blueprint', { key });
153
+ } else {
154
+ seen.add(key);
155
+ this._blueprints.push(blueprint);
156
+ }
157
+ });
158
+
159
+ this._blueprints.sort(({ name: a }, { name: b }) => a.localeCompare(b));
160
+ }
161
+
162
+ get blueprints(): Blueprint[] {
163
+ return this._blueprints;
164
+ }
165
+
166
+ getByKey(key: string): Blueprint | undefined {
167
+ return this._blueprints.find((blueprint) => Obj.getMeta(blueprint).key === key);
168
+ }
169
+
170
+ query(): Blueprint[] {
171
+ return this._blueprints;
172
+ }
173
+
174
+ updateBlueprints(): Effect.Effect<void, never, Database.Service> {
175
+ return Effect.gen(this, function* () {
176
+ const blueprints = yield* Database.runQuery(Filter.type(Blueprint));
177
+ for (const blueprint of blueprints) {
178
+ const blueprintKey = Obj.getMeta(blueprint).key;
179
+ if (!blueprintKey) {
180
+ continue;
181
+ }
182
+ const registryBlueprint = this.getByKey(blueprintKey);
183
+ if (!registryBlueprint) {
184
+ continue;
185
+ }
186
+ const source = Obj.clone(registryBlueprint, { deep: true });
187
+ Obj.update(blueprint, (blueprint) => {
188
+ void Obj.updateFrom(blueprint, source);
189
+ });
190
+ }
191
+ }).pipe(Effect.orDie);
192
+ }
193
+ }
194
+
195
+ export class RegistryService extends Context.Tag('@dxos/blueprints/RegistryService')<RegistryService, Registry>() {
196
+ static notAvailable = Layer.succeed(RegistryService, {
197
+ get blueprints(): Blueprint[] {
198
+ throw new Error('Blueprint registry not available');
199
+ },
200
+ getByKey(_key: string): Blueprint | undefined {
201
+ throw new Error('Blueprint registry not available');
202
+ },
203
+ query(): Blueprint[] {
204
+ throw new Error('Blueprint registry not available');
205
+ },
206
+ updateBlueprints() {
207
+ throw new Error('Blueprint registry not available');
208
+ },
209
+ } as unknown as Registry);
210
+ }
211
+
212
+ /**
213
+ * Resolves a blueprint from the registry.
214
+ * Does not check the local database for the blueprint.
215
+ */
216
+ export const resolve = (key: string): Effect.Effect<Blueprint, NotFoundError, RegistryService> =>
217
+ Effect.gen(function* () {
218
+ const registry = yield* RegistryService;
219
+ const blueprint = registry.getByKey(key);
220
+ if (!blueprint) {
221
+ return yield* Effect.fail(new NotFoundError({ context: { key } }));
222
+ }
223
+ return blueprint;
224
+ });
225
+
226
+ /**
227
+ * Upserts a blueprint into the database.
228
+ * If the blueprint already exists in the database, local blueprint is returned.
229
+ * Otherwise, it will be added.
230
+ */
231
+ export const upsert = (key: string): Effect.Effect<Blueprint, NotFoundError, RegistryService | Database.Service> =>
232
+ Effect.gen(function* () {
233
+ const local = yield* Database.runQuery(Filter.and(Filter.type(Blueprint), Filter.key(key)));
234
+ if (local.length > 0) {
235
+ return local[0];
236
+ }
237
+ return yield* Database.add(Obj.clone(yield* resolve(key), { deep: true }));
238
+ });
239
+
240
+ export class NotFoundError extends BaseError.extend('BlueprintNotFound', 'Blueprint not found') {}
241
+
242
+ //
243
+ // Legacy schemas and migrations.
244
+ //
245
+
246
+ /**
247
+ * Blueprint schema v0.1.0 — `key` is stored as a data property.
248
+ * @deprecated Use {@link Blueprint} (v0.2.0) instead; the `key` and `version` now live in the object meta.
249
+ */
250
+ export const Blueprint_v0_1_0 = Schema.Struct({
251
+ /**
252
+ * Global registry ID.
253
+ * NOTE: The `key` property refers to the original registry entry.
254
+ */
255
+ key: Schema.String.annotations({
256
+ description: 'Unique registration key for the blueprint',
257
+ }),
258
+
259
+ name: Schema.String.annotations({
260
+ description: 'Human-readable name of the blueprint',
261
+ }),
262
+
263
+ description: Schema.optional(Schema.String),
264
+
265
+ instructions: Template.Template,
266
+
267
+ tools: Schema.Array(ToolId),
268
+
269
+ agentCanEnable: Schema.optional(Schema.Boolean),
270
+
271
+ mcpServers: Schema.optional(Schema.Array(McpServer.McpServer)),
272
+ }).pipe(
273
+ Type.object({
274
+ typename: 'org.dxos.type.blueprint',
275
+ version: '0.1.0',
276
+ }),
277
+ );
278
+
279
+ export interface Blueprint_v0_1_0 extends Schema.Schema.Type<typeof Blueprint_v0_1_0> {}
280
+
281
+ /**
282
+ * Migration from {@link Blueprint_v0_1_0} (v0.1.0) to {@link Blueprint} (v0.2.0).
283
+ * Moves `key` from the data section into the object meta.
284
+ */
285
+ const _migration = Migration.define({
286
+ from: Blueprint_v0_1_0,
287
+ to: Blueprint,
288
+ transform: async (from) => ({
289
+ [Obj.Meta]: { key: from.key, version: '0.1.0' },
290
+ name: from.name,
291
+ description: from.description,
292
+ instructions: from.instructions,
293
+ tools: from.tools,
294
+ agentCanEnable: from.agentCanEnable,
295
+ mcpServers: from.mcpServers,
296
+ }),
297
+ });
298
+
299
+ /**
300
+ * Schema migrations exported by this module.
301
+ * Exported as an array for extensibility — append future versions here.
302
+ */
303
+ export const migrations = [_migration];
@@ -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,91 @@
1
+ //
2
+ // Copyright 2026 DXOS.org
3
+ //
4
+
5
+ import * as Context from 'effect/Context';
6
+ import * as Layer from 'effect/Layer';
7
+ import * as Types from 'effect/Types';
8
+
9
+ import { SpaceId, DXN } from '@dxos/keys';
10
+
11
+ import type * as Process from './Process';
12
+
13
+ // @import-as-namespace
14
+
15
+ export const TypeId = '~@dxos/functions/LayerSpec' as const;
16
+ export type TypeId = typeof TypeId;
17
+
18
+ /**
19
+ * Opaque layer with introspectable tags.
20
+ */
21
+ export interface LayerSpec {
22
+ readonly [TypeId]: TypeId;
23
+
24
+ readonly affinity: Affinity;
25
+ readonly requires: readonly Context.Tag<any, any>[];
26
+ readonly provides: readonly Context.Tag<any, any>[];
27
+
28
+ // opaque service creation function, layer provides the specified services and requires the specified requirements.
29
+ readonly make: (context: LayerContext) => Layer.Layer<unknown, never, unknown>;
30
+ }
31
+
32
+ /**
33
+ * Affinity defines the lifetime and scope of a service.
34
+ *
35
+ * - `application` - single service instance is available throughout the entire application.
36
+ * - `space` - service is instantiated per space.
37
+ * - `process` - separate service instance is created and destroyed for each process.
38
+ */
39
+ export type Affinity = 'application' | 'space' | 'process';
40
+
41
+ /**
42
+ * Provides context for service resolution.
43
+ */
44
+ // TODO(dmaretskyi): Consider making this type dependant on the specified service affinity.
45
+ export interface LayerContext {
46
+ /**
47
+ * Under which space the process is running.
48
+ * Space affinity and up only.
49
+ */
50
+ readonly space?: SpaceId;
51
+
52
+ /**
53
+ * DXN of the conversation feed the process is running in.
54
+ * Process affinity only.
55
+ */
56
+ readonly conversation?: DXN.String;
57
+
58
+ /**
59
+ * Under which process the process is running.
60
+ * Process affinity only.
61
+ */
62
+ readonly process?: Process.ID;
63
+ }
64
+
65
+ interface MakeOpts {
66
+ readonly affinity: Affinity;
67
+ readonly requires: readonly Context.Tag<any, any>[];
68
+ readonly provides: readonly Context.Tag<any, any>[];
69
+ }
70
+
71
+ /**
72
+ * Make a service.
73
+ */
74
+ export const make = <const Opts extends Types.NoExcessProperties<MakeOpts, Opts>>(
75
+ opts: Opts,
76
+ make: (
77
+ context: LayerContext,
78
+ ) => Layer.Layer<
79
+ Context.Tag.Identifier<Opts['provides'][number]>,
80
+ never,
81
+ Context.Tag.Identifier<Opts['requires'][number]>
82
+ >,
83
+ ): LayerSpec => {
84
+ return {
85
+ [TypeId]: TypeId,
86
+ affinity: opts.affinity,
87
+ requires: opts.requires,
88
+ provides: opts.provides,
89
+ make: make as any,
90
+ };
91
+ };
@@ -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> {}