@dxos/compute 0.8.4-main.9be5663bfe → 0.8.4-main.abd8ff62ef

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 (157) hide show
  1. package/README.md +36 -1
  2. package/dist/lib/neutral/StorageService.mjs +22 -0
  3. package/dist/lib/neutral/StorageService.mjs.map +7 -0
  4. package/dist/lib/neutral/chunk-4N4JAXCP.mjs +17 -0
  5. package/dist/lib/neutral/chunk-4N4JAXCP.mjs.map +7 -0
  6. package/dist/lib/neutral/chunk-DDEBBRCI.mjs +62 -0
  7. package/dist/lib/neutral/chunk-DDEBBRCI.mjs.map +7 -0
  8. package/dist/lib/neutral/chunk-FEABF5XY.mjs +25 -0
  9. package/dist/lib/neutral/chunk-FEABF5XY.mjs.map +7 -0
  10. package/dist/lib/neutral/chunk-H6EHIVDN.mjs +21 -0
  11. package/dist/lib/neutral/chunk-H6EHIVDN.mjs.map +7 -0
  12. package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
  13. package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
  14. package/dist/lib/neutral/chunk-N462A6NO.mjs +138 -0
  15. package/dist/lib/neutral/chunk-N462A6NO.mjs.map +7 -0
  16. package/dist/lib/neutral/chunk-QPCDM7MF.mjs +179 -0
  17. package/dist/lib/neutral/chunk-QPCDM7MF.mjs.map +7 -0
  18. package/dist/lib/neutral/chunk-S24LL2D5.mjs +52 -0
  19. package/dist/lib/neutral/chunk-S24LL2D5.mjs.map +7 -0
  20. package/dist/lib/neutral/fib-HDHBZHPE.mjs +10 -0
  21. package/dist/lib/neutral/fib-HDHBZHPE.mjs.map +7 -0
  22. package/dist/lib/neutral/index.mjs +1030 -51
  23. package/dist/lib/neutral/index.mjs.map +4 -4
  24. package/dist/lib/neutral/meta.json +1 -1
  25. package/dist/lib/neutral/reply-XSQMXAPX.mjs +10 -0
  26. package/dist/lib/neutral/reply-XSQMXAPX.mjs.map +7 -0
  27. package/dist/lib/neutral/sleep-WHTJQ56P.mjs +10 -0
  28. package/dist/lib/neutral/sleep-WHTJQ56P.mjs.map +7 -0
  29. package/dist/lib/neutral/testing/index.mjs +27 -193
  30. package/dist/lib/neutral/testing/index.mjs.map +4 -4
  31. package/dist/types/src/Blueprint.d.ts +148 -0
  32. package/dist/types/src/Blueprint.d.ts.map +1 -0
  33. package/dist/types/src/Credential.d.ts +27 -0
  34. package/dist/types/src/Credential.d.ts.map +1 -0
  35. package/dist/types/src/Operation.d.ts +303 -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 +61 -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 +56 -0
  52. package/dist/types/src/Template.d.ts.map +1 -0
  53. package/dist/types/src/Trace.d.ts +174 -0
  54. package/dist/types/src/Trace.d.ts.map +1 -0
  55. package/dist/types/src/Trigger.d.ts +150 -0
  56. package/dist/types/src/Trigger.d.ts.map +1 -0
  57. package/dist/types/src/TriggerEvent.d.ts +75 -0
  58. package/dist/types/src/TriggerEvent.d.ts.map +1 -0
  59. package/dist/types/src/errors.d.ts +239 -0
  60. package/dist/types/src/errors.d.ts.map +1 -0
  61. package/dist/types/src/index.d.ts +15 -5
  62. package/dist/types/src/index.d.ts.map +1 -1
  63. package/dist/types/src/testing/definitions.d.ts +11 -0
  64. package/dist/types/src/testing/definitions.d.ts.map +1 -0
  65. package/dist/types/src/testing/fib.d.ts +8 -0
  66. package/dist/types/src/testing/fib.d.ts.map +1 -0
  67. package/dist/types/src/testing/index.d.ts +6 -4
  68. package/dist/types/src/testing/index.d.ts.map +1 -1
  69. package/dist/types/src/testing/reply.d.ts +4 -0
  70. package/dist/types/src/testing/reply.d.ts.map +1 -0
  71. package/dist/types/src/testing/sleep.d.ts +6 -0
  72. package/dist/types/src/testing/sleep.d.ts.map +1 -0
  73. package/dist/types/src/umbrella.test.d.ts +2 -0
  74. package/dist/types/src/umbrella.test.d.ts.map +1 -0
  75. package/dist/types/tsconfig.tsbuildinfo +1 -1
  76. package/package.json +20 -34
  77. package/src/Blueprint.ts +221 -0
  78. package/src/Credential.ts +51 -0
  79. package/src/Operation.ts +513 -0
  80. package/src/OperationHandlerSet.ts +132 -0
  81. package/src/OperationRegistry.ts +48 -0
  82. package/src/Process.ts +490 -0
  83. package/src/Routine.ts +84 -0
  84. package/src/Script.ts +38 -0
  85. package/src/ServiceResolver.ts +174 -0
  86. package/src/StorageService.ts +99 -0
  87. package/src/Template.ts +105 -0
  88. package/src/Trace.ts +231 -0
  89. package/src/Trigger.ts +207 -0
  90. package/src/TriggerEvent.ts +62 -0
  91. package/src/errors.ts +50 -0
  92. package/src/index.ts +16 -6
  93. package/src/testing/definitions.ts +49 -0
  94. package/src/testing/fib.ts +22 -0
  95. package/src/testing/index.ts +13 -5
  96. package/src/testing/reply.ts +18 -0
  97. package/src/testing/sleep.ts +16 -0
  98. package/src/umbrella.test.ts +51 -0
  99. package/dist/lib/neutral/chunk-36MMQLBR.mjs +0 -3104
  100. package/dist/lib/neutral/chunk-36MMQLBR.mjs.map +0 -7
  101. package/dist/types/src/compute-graph-registry.d.ts +0 -37
  102. package/dist/types/src/compute-graph-registry.d.ts.map +0 -1
  103. package/dist/types/src/compute-graph-registry.test.d.ts +0 -2
  104. package/dist/types/src/compute-graph-registry.test.d.ts.map +0 -1
  105. package/dist/types/src/compute-graph.d.ts +0 -67
  106. package/dist/types/src/compute-graph.d.ts.map +0 -1
  107. package/dist/types/src/compute-graph.test.d.ts +0 -2
  108. package/dist/types/src/compute-graph.test.d.ts.map +0 -1
  109. package/dist/types/src/compute-node.d.ts +0 -24
  110. package/dist/types/src/compute-node.d.ts.map +0 -1
  111. package/dist/types/src/functions/async-function.d.ts +0 -68
  112. package/dist/types/src/functions/async-function.d.ts.map +0 -1
  113. package/dist/types/src/functions/edge-function.d.ts +0 -20
  114. package/dist/types/src/functions/edge-function.d.ts.map +0 -1
  115. package/dist/types/src/functions/function-defs.d.ts +0 -11
  116. package/dist/types/src/functions/function-defs.d.ts.map +0 -1
  117. package/dist/types/src/functions/index.d.ts +0 -4
  118. package/dist/types/src/functions/index.d.ts.map +0 -1
  119. package/dist/types/src/hyperformula.test.d.ts +0 -2
  120. package/dist/types/src/hyperformula.test.d.ts.map +0 -1
  121. package/dist/types/src/testing/test-builder.d.ts +0 -15
  122. package/dist/types/src/testing/test-builder.d.ts.map +0 -1
  123. package/dist/types/src/testing/test-plugin.d.ts +0 -35
  124. package/dist/types/src/testing/test-plugin.d.ts.map +0 -1
  125. package/dist/types/src/testing/test-runtime.d.ts +0 -10
  126. package/dist/types/src/testing/test-runtime.d.ts.map +0 -1
  127. package/dist/types/src/testing/util.d.ts +0 -2
  128. package/dist/types/src/testing/util.d.ts.map +0 -1
  129. package/dist/types/src/types/hyperformula.d.ts +0 -8
  130. package/dist/types/src/types/hyperformula.d.ts.map +0 -1
  131. package/dist/types/src/types/index.d.ts +0 -3
  132. package/dist/types/src/types/index.d.ts.map +0 -1
  133. package/dist/types/src/types/types.d.ts +0 -20
  134. package/dist/types/src/types/types.d.ts.map +0 -1
  135. package/dist/types/src/types/types.test.d.ts +0 -2
  136. package/dist/types/src/types/types.test.d.ts.map +0 -1
  137. package/dist/types/src/util.d.ts +0 -2
  138. package/dist/types/src/util.d.ts.map +0 -1
  139. package/src/compute-graph-registry.test.ts +0 -167
  140. package/src/compute-graph-registry.ts +0 -97
  141. package/src/compute-graph.test.ts +0 -139
  142. package/src/compute-graph.ts +0 -266
  143. package/src/compute-node.ts +0 -59
  144. package/src/functions/async-function.ts +0 -184
  145. package/src/functions/edge-function.ts +0 -113
  146. package/src/functions/function-defs.ts +0 -2427
  147. package/src/functions/index.ts +0 -7
  148. package/src/hyperformula.test.ts +0 -14
  149. package/src/testing/test-builder.ts +0 -59
  150. package/src/testing/test-plugin.ts +0 -98
  151. package/src/testing/test-runtime.ts +0 -36
  152. package/src/testing/util.ts +0 -9
  153. package/src/types/hyperformula.ts +0 -19
  154. package/src/types/index.ts +0 -6
  155. package/src/types/types.test.ts +0 -91
  156. package/src/types/types.ts +0 -80
  157. package/src/util.ts +0 -8
@@ -1,55 +1,1034 @@
1
1
  import {
2
- AsyncFunctionPlugin,
3
- ComputeGraph,
4
- ComputeGraphRegistry,
5
- ComputeNode,
6
- DetailedCellError,
7
- EDGE_FUNCTION_NAME,
8
- EdgeFunctionPlugin,
9
- EdgeFunctionPluginTranslations,
10
- ExportedCellChange,
11
- FunctionContext,
12
- RANGE_NOTATION,
13
- addressFromA1Notation,
14
- addressToA1Notation,
15
- cellEquals,
16
- columnLetter,
17
- createSheetName,
18
- defaultFunctionContextOptions,
19
- defaultFunctions,
20
- defaultOptions,
21
- defaultPlugins,
22
- inRange,
23
- isFormula,
24
- parseSheetName,
25
- rangeFromA1Notation,
26
- rangeToA1Notation
27
- } from "./chunk-36MMQLBR.mjs";
2
+ StorageService_exports
3
+ } from "./chunk-DDEBBRCI.mjs";
4
+ import {
5
+ FunctionError,
6
+ FunctionNotFoundError,
7
+ InvalidOperationInputError,
8
+ InvalidOperationOutputError,
9
+ InvokerNotInitializedError,
10
+ NoHandlerError,
11
+ OperationHandlerProvider,
12
+ OperationHandlerSet_exports,
13
+ ServiceNotAvailableError,
14
+ TriggerStateNotFoundError,
15
+ getHandler,
16
+ getHandlerByKey
17
+ } from "./chunk-N462A6NO.mjs";
18
+ import {
19
+ Operation_exports,
20
+ PersistentOperation,
21
+ deserialize,
22
+ invoke
23
+ } from "./chunk-QPCDM7MF.mjs";
24
+ import {
25
+ __export
26
+ } from "./chunk-J5LGTIGS.mjs";
27
+
28
+ // src/Blueprint.ts
29
+ var Blueprint_exports = {};
30
+ __export(Blueprint_exports, {
31
+ Blueprint: () => Blueprint,
32
+ McpServer: () => McpServer,
33
+ NotFoundError: () => NotFoundError,
34
+ Registry: () => Registry,
35
+ RegistryService: () => RegistryService,
36
+ make: () => make2,
37
+ resolve: () => resolve2,
38
+ toolDefinitions: () => toolDefinitions,
39
+ upsert: () => upsert
40
+ });
41
+ import * as Context2 from "effect/Context";
42
+ import * as Effect3 from "effect/Effect";
43
+ import * as Schema2 from "effect/Schema";
44
+ import { ToolId } from "@dxos/ai";
45
+ import { Annotation, Database as Database3, Filter, Obj, Type } from "@dxos/echo";
46
+ import { BaseError } from "@dxos/errors";
47
+ import { log as log2 } from "@dxos/log";
48
+
49
+ // src/Template.ts
50
+ var Template_exports = {};
51
+ __export(Template_exports, {
52
+ Input: () => Input,
53
+ InputKind: () => InputKind,
54
+ Template: () => Template,
55
+ make: () => make,
56
+ process: () => process,
57
+ processTemplate: () => processTemplate
58
+ });
59
+ import * as Effect2 from "effect/Effect";
60
+ import * as Record from "effect/Record";
61
+ import * as Schema from "effect/Schema";
62
+ import handlebars from "handlebars";
63
+ import { Database as Database2, Ref } from "@dxos/echo";
64
+ import { invariant } from "@dxos/invariant";
65
+ import { log } from "@dxos/log";
66
+ import { Text } from "@dxos/schema";
67
+
68
+ // src/OperationRegistry.ts
69
+ var OperationRegistry_exports = {};
70
+ __export(OperationRegistry_exports, {
71
+ Service: () => Service,
72
+ layer: () => layer,
73
+ resolve: () => resolve
74
+ });
75
+ import * as Context from "effect/Context";
76
+ import * as Effect from "effect/Effect";
77
+ import * as Layer from "effect/Layer";
78
+ import { Database, Query } from "@dxos/echo";
79
+ var Service = class extends Context.Tag("@dxos/operation/OperationRegistry")() {
80
+ };
81
+ var resolve = Effect.serviceFunctionEffect(Service, (service) => service.resolve);
82
+ var layer = Layer.effect(Service, Effect.gen(function* () {
83
+ const database = yield* Database.Service;
84
+ const handlerSet = yield* OperationHandlerProvider;
85
+ return {
86
+ resolve: (key) => Database.runQueryFirst(Query.type(PersistentOperation, {
87
+ key
88
+ })).pipe(Effect.flatten, Effect.map(deserialize), Effect.catchTag("NoSuchElementException", () => getHandlerByKey(handlerSet, key)), Effect.option).pipe(Effect.provideService(Database.Service, database))
89
+ };
90
+ }));
91
+
92
+ // src/Template.ts
93
+ var __dxlog_file = "/__w/dxos/dxos/packages/core/compute/src/Template.ts";
94
+ var InputKind = Schema.Literal("value", "pass-through", "retriever", "function", "query", "resolver", "context", "schema");
95
+ var Input = Schema.Struct({
96
+ name: Schema.String,
97
+ kind: Schema.optional(InputKind),
98
+ default: Schema.optional(Schema.Any),
99
+ /**
100
+ * Function to call if the kind is 'function'.
101
+ */
102
+ function: Schema.optional(Schema.String)
103
+ });
104
+ var Template = Schema.Struct({
105
+ source: Ref.Ref(Text.Text).annotations({
106
+ description: "Handlebars template source"
107
+ }),
108
+ inputs: Schema.optional(Schema.Array(Input))
109
+ });
110
+ var make = ({ id, source, inputs = [] } = {}) => ({
111
+ source: Ref.make(Text.make({
112
+ id,
113
+ content: source
114
+ })),
115
+ inputs
116
+ });
117
+ var process = (source, variables = {}) => {
118
+ invariant(typeof source === "string", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 47, S: void 0, A: ["typeof source === 'string'", ""] });
119
+ let section = 0;
120
+ handlebars.registerHelper("section", () => String(++section));
121
+ const template = handlebars.compile(source.trim());
122
+ const output = template(variables);
123
+ return output.trim().replace(/(\n\s*){3,}/g, "\n\n");
124
+ };
125
+ var processTemplate = (template) => Effect2.gen(function* () {
126
+ const variables = yield* Effect2.forEach(template.inputs ?? [], (input) => Effect2.gen(function* () {
127
+ if (input.kind === "function") {
128
+ const fn = yield* resolve(input.function).pipe(Effect2.flatten, Effect2.catchTag("NoSuchElementException", () => Effect2.fail(new FunctionNotFoundError(input.function))));
129
+ const result = yield* invoke(fn, {}).pipe(Effect2.orDie);
130
+ return [
131
+ input.name,
132
+ result
133
+ ];
134
+ } else {
135
+ return yield* Effect2.dieMessage(`Unsupported input kind: ${input.kind}`);
136
+ }
137
+ })).pipe(Effect2.map(Record.fromEntries));
138
+ log("processTemplate", {
139
+ variables
140
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 67, S: this });
141
+ return process((yield* Database2.load(template.source)).content, variables);
142
+ });
143
+
144
+ // src/Blueprint.ts
145
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/core/compute/src/Blueprint.ts";
146
+ var McpServer = Schema2.Struct({
147
+ /**
148
+ * URL of the MCP server.
149
+ */
150
+ url: Schema2.String.annotations({
151
+ description: "URL of the MCP server"
152
+ }),
153
+ protocol: Schema2.Union(Schema2.Literal("sse"), Schema2.Literal("http")).annotations({
154
+ description: "Protocol of the MCP server"
155
+ })
156
+ });
157
+ var Blueprint = Schema2.Struct({
158
+ /**
159
+ * Global registry ID.
160
+ * NOTE: The `key` property refers to the original registry entry.
161
+ */
162
+ // TODO(burdon): Create Format type for DXN-like ids, such as this and schema type.
163
+ key: Schema2.String.annotations({
164
+ description: "Unique registration key for the blueprint"
165
+ }),
166
+ /**
167
+ * Human-readable name of the blueprint.
168
+ */
169
+ name: Schema2.String.annotations({
170
+ description: "Human-readable name of the blueprint"
171
+ }),
172
+ /**
173
+ * Description of the blueprint's purpose and functionality.
174
+ */
175
+ description: Schema2.optional(Schema2.String).annotations({
176
+ description: "Description of the blueprint's purpose and functionality"
177
+ }),
178
+ /**
179
+ * Instructions that guide the AI assistant's behavior and responses.
180
+ * These are system prompts or guidelines that the AI should follow.
181
+ */
182
+ instructions: Template.annotations({
183
+ description: "Instructions that guide the AI assistant's behavior and responses"
184
+ }),
185
+ /**
186
+ * Array of tools that the AI assistant can use when this blueprint is active.
187
+ */
188
+ tools: Schema2.Array(ToolId).annotations({
189
+ description: "Array of tools that the AI assistant can use when this blueprint is active"
190
+ }),
191
+ /**
192
+ * Whether an agent is allowed to auto-enable this blueprint in a conversation.
193
+ */
194
+ agentCanEnable: Schema2.optional(Schema2.Boolean).annotations({
195
+ description: "Whether an agent is allowed to auto-enable this blueprint in a conversation."
196
+ }),
197
+ /**
198
+ * Array of MCP servers that the AI assistant can use when this blueprint is active.
199
+ */
200
+ mcpServers: Schema2.optional(Schema2.Array(McpServer))
201
+ }).pipe(Type.object({
202
+ // TODO(burdon): Is this a DXN? Need to create a Format type for these IDs.
203
+ typename: "org.dxos.type.blueprint",
204
+ version: "0.1.0"
205
+ }), Annotation.LabelAnnotation.set([
206
+ "name"
207
+ ]), Annotation.IconAnnotation.set({
208
+ icon: "ph--blueprint--regular",
209
+ hue: "sky"
210
+ }));
211
+ var make2 = ({ tools = [], instructions = make(), ...props }) => Obj.make(Blueprint, {
212
+ tools,
213
+ instructions,
214
+ ...props
215
+ });
216
+ var toolDefinitions = ({ tools = [], operations = [] }) => [
217
+ ...operations.map((op) => ToolId.make(op.meta.key)),
218
+ ...tools.map((tool) => ToolId.make(tool))
219
+ ];
220
+ var Registry = class {
221
+ _blueprints = [];
222
+ constructor(blueprints) {
223
+ const seen = /* @__PURE__ */ new Set();
224
+ blueprints.forEach((blueprint) => {
225
+ if (seen.has(blueprint.key)) {
226
+ log2.warn("duplicate blueprint", {
227
+ key: blueprint.key
228
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 99, S: this });
229
+ } else {
230
+ seen.add(blueprint.key);
231
+ this._blueprints.push(blueprint);
232
+ }
233
+ });
234
+ this._blueprints.sort(({ name: a }, { name: b }) => a.localeCompare(b));
235
+ }
236
+ get blueprints() {
237
+ return this._blueprints;
238
+ }
239
+ getByKey(key) {
240
+ return this._blueprints.find((blueprint) => blueprint.key === key);
241
+ }
242
+ query() {
243
+ return this._blueprints;
244
+ }
245
+ updateBlueprints() {
246
+ return Effect3.gen(this, function* () {
247
+ const blueprints = yield* Database3.runQuery(Filter.type(Blueprint));
248
+ for (const blueprint of blueprints) {
249
+ const registryBlueprint = this.getByKey(blueprint.key);
250
+ if (!registryBlueprint) {
251
+ continue;
252
+ }
253
+ const source = Obj.clone(registryBlueprint, {
254
+ deep: true
255
+ });
256
+ Obj.update(blueprint, (blueprint2) => {
257
+ void Obj.updateFrom(blueprint2, source);
258
+ });
259
+ }
260
+ }).pipe(Effect3.orDie);
261
+ }
262
+ };
263
+ var RegistryService = class extends Context2.Tag("@dxos/blueprints/RegistryService")() {
264
+ };
265
+ var resolve2 = (key) => Effect3.gen(function* () {
266
+ const registry = yield* RegistryService;
267
+ const blueprint = registry.getByKey(key);
268
+ if (!blueprint) {
269
+ return yield* Effect3.fail(new NotFoundError({
270
+ context: {
271
+ key
272
+ }
273
+ }));
274
+ }
275
+ return blueprint;
276
+ });
277
+ var upsert = (key) => Effect3.gen(function* () {
278
+ const local = yield* Database3.runQuery(Filter.type(Blueprint, {
279
+ key
280
+ }));
281
+ if (local.length > 0) {
282
+ return local[0];
283
+ }
284
+ return yield* Database3.add(Obj.clone(yield* resolve2(key), {
285
+ deep: true
286
+ }));
287
+ });
288
+ var NotFoundError = class extends BaseError.extend("BlueprintNotFound", "Blueprint not found") {
289
+ };
290
+
291
+ // src/Credential.ts
292
+ var Credential_exports = {};
293
+ __export(Credential_exports, {
294
+ CredentialsService: () => CredentialsService
295
+ });
296
+ import * as Context3 from "effect/Context";
297
+ import * as Effect4 from "effect/Effect";
298
+ import * as Redacted from "effect/Redacted";
299
+ var CredentialsService = class _CredentialsService extends Context3.Tag("@dxos/functions/CredentialsService")() {
300
+ static getCredential = (query) => Effect4.gen(function* () {
301
+ const credentials = yield* _CredentialsService;
302
+ return yield* Effect4.promise(() => credentials.getCredential(query));
303
+ });
304
+ static getApiKey = (query) => Effect4.gen(function* () {
305
+ const credential = yield* _CredentialsService.getCredential(query);
306
+ if (!credential.apiKey) {
307
+ throw new Error(`API key not found for service: ${query.service}`);
308
+ }
309
+ return Redacted.make(credential.apiKey);
310
+ });
311
+ };
312
+
313
+ // src/Process.ts
314
+ var Process_exports = {};
315
+ __export(Process_exports, {
316
+ ExitedEvent: () => ExitedEvent,
317
+ ID: () => ID,
318
+ ProcessMonitorService: () => ProcessMonitorService,
319
+ ProcessTypeId: () => ProcessTypeId,
320
+ SpawnedEvent: () => SpawnedEvent,
321
+ State: () => State,
322
+ fromOperation: () => fromOperation,
323
+ isProcess: () => isProcess,
324
+ make: () => make4,
325
+ prettyProcessTree: () => prettyProcessTree
326
+ });
327
+ import * as Context5 from "effect/Context";
328
+ import * as Effect6 from "effect/Effect";
329
+ import * as Schema4 from "effect/Schema";
330
+ import { assertArgument } from "@dxos/invariant";
331
+ import { log as log4 } from "@dxos/log";
332
+
333
+ // src/Trace.ts
334
+ var Trace_exports = {};
335
+ __export(Trace_exports, {
336
+ Event: () => Event,
337
+ EventType: () => EventType,
338
+ Message: () => Message,
339
+ MessageData: () => MessageData,
340
+ Meta: () => Meta,
341
+ OperationEnd: () => OperationEnd,
342
+ OperationStart: () => OperationStart,
343
+ StatusUpdate: () => StatusUpdate,
344
+ TraceService: () => TraceService,
345
+ TraceSink: () => TraceSink,
346
+ emitStatus: () => emitStatus,
347
+ isOfType: () => isOfType,
348
+ layerConsole: () => layerConsole,
349
+ layerNoop: () => layerNoop,
350
+ noopWriter: () => noopWriter,
351
+ testTraceService: () => testTraceService,
352
+ write: () => write,
353
+ writerLayerNoop: () => writerLayerNoop
354
+ });
355
+ import * as Context4 from "effect/Context";
356
+ import * as Effect5 from "effect/Effect";
357
+ import * as Layer2 from "effect/Layer";
358
+ import * as Schema3 from "effect/Schema";
359
+ import { Annotation as Annotation2, Obj as Obj2, Type as Type2 } from "@dxos/echo";
360
+ import { log as log3 } from "@dxos/log";
361
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/core/compute/src/Trace.ts";
362
+ var TraceService = class extends Context4.Tag("@dxos/functions/TraceService")() {
363
+ };
364
+ function write(eventType, payload) {
365
+ return Effect5.gen(function* () {
366
+ log3("trace write", {
367
+ key: eventType.key,
368
+ isEphemeral: eventType.isEphemeral
369
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 20, S: this });
370
+ const writer = yield* TraceService;
371
+ writer.write(eventType, payload);
372
+ });
373
+ }
374
+ var EventType = (key, opts) => {
375
+ return {
376
+ key,
377
+ schema: opts.schema,
378
+ isEphemeral: opts.isEphemeral
379
+ };
380
+ };
381
+ var Event = Schema3.Struct({
382
+ timestamp: Schema3.Number,
383
+ type: Schema3.String,
384
+ data: Schema3.Unknown
385
+ });
386
+ var isOfType = (eventType, event) => {
387
+ return event.type === eventType.key;
388
+ };
389
+ var Meta = Schema3.Struct({
390
+ pid: Schema3.optional(Schema3.String),
391
+ parentPid: Schema3.optional(Schema3.String),
392
+ processName: Schema3.optional(Schema3.String),
393
+ /**
394
+ * ID of the conversation feed object if present.
395
+ */
396
+ conversationId: Schema3.optional(Obj2.ID),
397
+ /**
398
+ * ID of the trigger object if invocation resulted from a trigger.
399
+ */
400
+ triggerId: Schema3.optional(Obj2.ID),
401
+ /**
402
+ * ID of the tool call that created the current process.
403
+ */
404
+ toolCallId: Schema3.optional(Schema3.String)
405
+ });
406
+ var MessageData = Schema3.Struct({
407
+ meta: Meta,
408
+ isEphemeral: Schema3.Boolean,
409
+ events: Schema3.Array(Event)
410
+ });
411
+ var Message = MessageData.pipe(Type2.object({
412
+ typename: "org.dxos.type.traceMessage",
413
+ version: "0.1.0"
414
+ }), Annotation2.IconAnnotation.set({
415
+ icon: "ph--note--regular",
416
+ hue: "rose"
417
+ }));
418
+ var TraceSink = class extends Context4.Tag("@dxos/functions/TraceSink")() {
419
+ };
420
+ var noopWriter = {
421
+ write: () => {
422
+ }
423
+ };
424
+ var writerLayerNoop = Layer2.succeed(TraceService, noopWriter);
425
+ var layerNoop = Layer2.succeed(TraceSink, {
426
+ write: () => {
427
+ }
428
+ });
429
+ var layerConsole = Layer2.succeed(TraceSink, {
430
+ write: (message) => {
431
+ console.log(message);
432
+ }
433
+ });
434
+ var testTraceService = (opts = {}) => Layer2.effect(TraceService, Effect5.gen(function* () {
435
+ const sink = yield* TraceSink;
436
+ return {
437
+ write: (event, data) => {
438
+ sink.write(Obj2.make(Message, {
439
+ meta: opts.meta ?? {},
440
+ isEphemeral: event.isEphemeral,
441
+ events: [
442
+ {
443
+ type: event.key,
444
+ timestamp: Date.now(),
445
+ data
446
+ }
447
+ ]
448
+ }));
449
+ }
450
+ };
451
+ }));
452
+ var OperationStart = EventType("operation.start", {
453
+ schema: Schema3.Struct({
454
+ /** Operation key. */
455
+ key: Schema3.String,
456
+ /** Human-readable operation name. */
457
+ name: Schema3.optional(Schema3.String)
458
+ }),
459
+ isEphemeral: false
460
+ });
461
+ var OperationEnd = EventType("operation.end", {
462
+ schema: Schema3.Struct({
463
+ /** Operation key. */
464
+ key: Schema3.String,
465
+ /** Human-readable operation name. */
466
+ name: Schema3.optional(Schema3.String),
467
+ /** Outcome of the operation. */
468
+ outcome: Schema3.Literal("success", "failure"),
469
+ /** Error message if the operation failed. */
470
+ error: Schema3.optional(Schema3.String)
471
+ }),
472
+ isEphemeral: false
473
+ });
474
+ var StatusUpdate = EventType("status.update", {
475
+ schema: Schema3.Struct({
476
+ /** Human-readable status message. */
477
+ message: Schema3.String
478
+ }),
479
+ isEphemeral: true
480
+ });
481
+ var emitStatus = (message) => write(StatusUpdate, {
482
+ message
483
+ });
484
+
485
+ // src/Process.ts
486
+ var __dxlog_file4 = "/__w/dxos/dxos/packages/core/compute/src/Process.ts";
487
+ var ID = Schema4.String.pipe(Schema4.brand("ProcessId"));
488
+ var ProcessTypeId = "~@dxos/functions/Process";
489
+ var isProcess = (executable) => typeof executable === "object" && executable !== null && ProcessTypeId in executable;
490
+ var make4 = (opts, create) => {
491
+ assertArgument(/^[a-z0-9]([a-z0-9.\-/]*[a-z0-9])?$/i.test(opts.key), "key", "Invalid key");
492
+ return {
493
+ [ProcessTypeId]: {},
494
+ ...opts,
495
+ create: (ctx) => create(ctx).pipe(Effect6.map((partial) => ({
496
+ onSpawn: () => Effect6.void,
497
+ onInput: () => Effect6.void,
498
+ onAlarm: () => Effect6.void,
499
+ onChildEvent: () => Effect6.void,
500
+ ...partial
501
+ })))
502
+ };
503
+ };
504
+ var fromOperation = (op, handler) => make4({
505
+ key: op.meta.key,
506
+ input: op.input,
507
+ output: op.output,
508
+ services: op.services
509
+ }, (ctx) => Effect6.gen(function* () {
510
+ const semaphore = yield* Effect6.makeSemaphore(1);
511
+ return {
512
+ onInput: (input) => Effect6.gen(function* () {
513
+ log4("operation process invoking", {
514
+ key: op.meta.key,
515
+ name: op.meta.name
516
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 45, S: this });
517
+ yield* write(OperationStart, {
518
+ key: op.meta.key,
519
+ name: op.meta.name
520
+ });
521
+ const opHandler = yield* getHandler(handler, op).pipe(Effect6.orDie);
522
+ const output = yield* opHandler.handler(input).pipe(Effect6.orDie, Effect6.withSpan(op.meta.key));
523
+ ctx.submitOutput(output);
524
+ ctx.succeed();
525
+ yield* write(OperationEnd, {
526
+ key: op.meta.key,
527
+ name: op.meta.name,
528
+ outcome: "success"
529
+ });
530
+ }).pipe(Effect6.catchAllDefect((defect) => Effect6.gen(function* () {
531
+ const errorMessage = defect instanceof Error ? defect.message : String(defect);
532
+ yield* write(OperationEnd, {
533
+ key: op.meta.key,
534
+ name: op.meta.name,
535
+ outcome: "failure",
536
+ error: errorMessage
537
+ });
538
+ return yield* Effect6.die(defect);
539
+ })), semaphore.withPermits(1))
540
+ };
541
+ }));
542
+ var State = /* @__PURE__ */ (function(State2) {
543
+ State2["RUNNING"] = "RUNNING";
544
+ State2["HYBERNATING"] = "HYBERNATING";
545
+ State2["IDLE"] = "IDLE";
546
+ State2["TERMINATING"] = "TERMINATING";
547
+ State2["TERMINATED"] = "TERMINATED";
548
+ State2["SUCCEEDED"] = "SUCCEEDED";
549
+ State2["FAILED"] = "FAILED";
550
+ return State2;
551
+ })({});
552
+ var ProcessMonitorService = class extends Context5.Tag("@dxos/functions/ProcessMonitorService")() {
553
+ };
554
+ var SpawnedEvent = EventType("process.spawned", {
555
+ schema: Schema4.Void,
556
+ isEphemeral: false
557
+ });
558
+ var ExitedEvent = EventType("process.exited", {
559
+ schema: Schema4.Struct({
560
+ outcome: Schema4.Literal("succeeded", "failed", "terminated")
561
+ }),
562
+ isEphemeral: false
563
+ });
564
+ var prettyProcessTree = (tree) => {
565
+ if (tree.length === 0) {
566
+ return "";
567
+ }
568
+ const pidSet = new Set(tree.map((node) => node.pid));
569
+ const childrenByParent = /* @__PURE__ */ new Map();
570
+ const roots = [];
571
+ for (const node of tree) {
572
+ const parent = node.parentPid;
573
+ if (parent === null || !pidSet.has(parent)) {
574
+ roots.push(node);
575
+ continue;
576
+ }
577
+ const key = String(parent);
578
+ const siblings = childrenByParent.get(key) ?? [];
579
+ siblings.push(node);
580
+ childrenByParent.set(key, siblings);
581
+ }
582
+ const byPid = (a, b) => String(a.pid).localeCompare(String(b.pid));
583
+ roots.sort(byPid);
584
+ for (const siblings of childrenByParent.values()) {
585
+ siblings.sort(byPid);
586
+ }
587
+ const formatLabel = (node) => {
588
+ const idShort = String(node.pid).slice(0, 6);
589
+ const parts = [
590
+ idShort,
591
+ node.state
592
+ ];
593
+ if (node.params.name != null && node.params.name !== "") {
594
+ parts.push(node.params.name);
595
+ }
596
+ if (node.error != null) {
597
+ parts.push(`(${node.error})`);
598
+ }
599
+ const { inputCount, outputCount, wallTime } = node.metrics;
600
+ parts.push(`[in:${inputCount} out:${outputCount} wall:${Math.round(wallTime)}ms]`);
601
+ return parts.join(" ");
602
+ };
603
+ const lines = [];
604
+ const walk = (node, prefix, isLast, isRoot) => {
605
+ if (isRoot) {
606
+ lines.push(`- ${formatLabel(node)}`);
607
+ } else {
608
+ const branch = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
609
+ lines.push(`${prefix}${branch}${formatLabel(node)}`);
610
+ }
611
+ const children = childrenByParent.get(String(node.pid)) ?? [];
612
+ const nextPrefix = isRoot ? " " : `${prefix}${isLast ? " " : "\u2502 "}`;
613
+ children.forEach((child, index) => {
614
+ walk(child, nextPrefix, index === children.length - 1, false);
615
+ });
616
+ };
617
+ for (const root of roots) {
618
+ walk(root, "", true, true);
619
+ }
620
+ return lines.join("\n");
621
+ };
622
+
623
+ // src/Routine.ts
624
+ var Routine_exports = {};
625
+ __export(Routine_exports, {
626
+ Routine: () => Routine,
627
+ make: () => make5
628
+ });
629
+ import * as Schema5 from "effect/Schema";
630
+ import { Annotation as Annotation3, JsonSchema, Obj as Obj3, Ref as Ref2, Type as Type3 } from "@dxos/echo";
631
+ var Routine = Schema5.Struct({
632
+ /**
633
+ * Name of the routine.
634
+ */
635
+ name: Schema5.optional(Schema5.String),
636
+ /**
637
+ * Description of the routine's purpose and functionality.
638
+ * Allows AI agents to execute routines automatically as tools.
639
+ */
640
+ description: Schema5.optional(Schema5.String),
641
+ /**
642
+ * Input schema of the routine.
643
+ */
644
+ input: JsonSchema.JsonSchema.pipe(Annotation3.FormInputAnnotation.set(false)),
645
+ /**
646
+ * Output schema of the routine.
647
+ */
648
+ output: JsonSchema.JsonSchema.pipe(Annotation3.FormInputAnnotation.set(false)),
649
+ /**
650
+ * Natural language instructions for the routine.
651
+ * These should provide concrete course of action for the AI to follow.
652
+ */
653
+ instructions: Template.pipe(Annotation3.FormInputAnnotation.set(false)),
654
+ /**
655
+ * Blueprints that the routine may utilize.
656
+ */
657
+ blueprints: Schema5.Array(Ref2.Ref(Blueprint)),
658
+ /**
659
+ * Additional context that the routine may utilize.
660
+ */
661
+ context: Schema5.Array(Schema5.Any).pipe(Annotation3.FormInputAnnotation.set(false))
662
+ }).pipe(Type3.object({
663
+ typename: "org.dxos.type.routine",
664
+ version: "0.1.0"
665
+ }), Annotation3.LabelAnnotation.set([
666
+ "name"
667
+ ]), Annotation3.IconAnnotation.set({
668
+ icon: "ph--scroll--regular",
669
+ hue: "sky"
670
+ }));
671
+ var make5 = (params) => Obj3.make(Routine, {
672
+ name: params.name,
673
+ description: params.description,
674
+ input: JsonSchema.toJsonSchema(params.input ?? Schema5.Void),
675
+ output: JsonSchema.toJsonSchema(params.output ?? Schema5.Void),
676
+ instructions: make({
677
+ source: params.instructions
678
+ }),
679
+ blueprints: params.blueprints ?? [],
680
+ context: params.context ?? []
681
+ });
682
+
683
+ // src/Script.ts
684
+ var Script_exports = {};
685
+ __export(Script_exports, {
686
+ Script: () => Script,
687
+ make: () => make6
688
+ });
689
+ import * as Schema6 from "effect/Schema";
690
+ import { Annotation as Annotation4, Obj as Obj4, Ref as Ref3, Type as Type4 } from "@dxos/echo";
691
+ import { FormInputAnnotation } from "@dxos/echo/internal";
692
+ import { Text as Text2 } from "@dxos/schema";
693
+ var Script = Schema6.Struct({
694
+ name: Schema6.String.pipe(Schema6.optional),
695
+ description: Schema6.String.pipe(Schema6.optional),
696
+ // TODO(burdon): Change to hash of deployed content.
697
+ // Whether source has changed since last deploy.
698
+ changed: Schema6.Boolean.pipe(FormInputAnnotation.set(false), Schema6.optional),
699
+ source: Ref3.Ref(Text2.Text).pipe(FormInputAnnotation.set(false))
700
+ }).pipe(Type4.object({
701
+ typename: "org.dxos.type.script",
702
+ version: "0.1.0"
703
+ }), Annotation4.LabelAnnotation.set([
704
+ "name"
705
+ ]), Annotation4.IconAnnotation.set({
706
+ icon: "ph--code--regular",
707
+ hue: "sky"
708
+ }));
709
+ var make6 = ({ source = "", ...props } = {}) => Obj4.make(Script, {
710
+ ...props,
711
+ source: Ref3.make(Text2.make({
712
+ content: source
713
+ }))
714
+ });
715
+
716
+ // src/ServiceResolver.ts
717
+ var ServiceResolver_exports = {};
718
+ __export(ServiceResolver_exports, {
719
+ ServiceResolver: () => ServiceResolver,
720
+ compose: () => compose,
721
+ empty: () => empty2,
722
+ fromContext: () => fromContext,
723
+ fromRequirements: () => fromRequirements,
724
+ layerRequirements: () => layerRequirements,
725
+ make: () => make8,
726
+ resolve: () => resolve3,
727
+ resolveAll: () => resolveAll,
728
+ succeed: () => succeed2
729
+ });
730
+ import * as Context6 from "effect/Context";
731
+ import * as Effect7 from "effect/Effect";
732
+ import * as Either from "effect/Either";
733
+ import * as Layer3 from "effect/Layer";
734
+ import * as Option from "effect/Option";
735
+ var ServiceResolverTypeId = "~@dxos/functions/ServiceResolver";
736
+ var ServiceResolver = Context6.GenericTag("@dxos/functions/ServiceResolver");
737
+ var resolve3 = Effect7.serviceFunctionEffect(ServiceResolver, (_) => _.resolve);
738
+ var resolveAll = (tags, context) => Effect7.gen(function* () {
739
+ const services = yield* Effect7.forEach(tags, (tag) => resolve3(tag, context).pipe(Effect7.map((service) => Context6.make(tag, service))));
740
+ return Context6.mergeAll(...services);
741
+ });
742
+ var succeed2 = (tag, getService) => {
743
+ return make8((tag1, context) => {
744
+ if (tag1.key !== tag.key) {
745
+ return Effect7.fail(new ServiceNotAvailableError(`Service not available: ${String(tag.key ?? tag)}`));
746
+ }
747
+ const service = getService(context);
748
+ return service;
749
+ });
750
+ };
751
+ var make8 = (resolveFn) => ({
752
+ [ServiceResolverTypeId]: ServiceResolverTypeId,
753
+ resolve: resolveFn
754
+ });
755
+ var fromContext = (ctx) => make8((tag, context) => Effect7.gen(function* () {
756
+ const service = Context6.getOption(ctx, tag);
757
+ if (Option.isNone(service)) {
758
+ return yield* Effect7.fail(new ServiceNotAvailableError(String(tag.key ?? tag)));
759
+ }
760
+ return service.value;
761
+ }));
762
+ var fromRequirements = (...tags) => Effect7.contextWith((parentCtx) => {
763
+ const available = new Set(tags.map((tag) => tag.key));
764
+ return make8((tag, context) => Effect7.gen(function* () {
765
+ let result = Context6.empty();
766
+ if (!available.has(tag.key)) {
767
+ return yield* Effect7.fail(new ServiceNotAvailableError(String(tag.key ?? tag)));
768
+ }
769
+ const service = Context6.getOption(parentCtx, tag);
770
+ if (Option.isNone(service)) {
771
+ return yield* Effect7.fail(new ServiceNotAvailableError(String(tag.key ?? tag)));
772
+ }
773
+ return service.value;
774
+ }));
775
+ });
776
+ var layerRequirements = (...tags) => Layer3.effect(ServiceResolver, fromRequirements(...tags));
777
+ var compose = (...resolvers) => make8((tag, context) => Effect7.gen(function* () {
778
+ for (const resolver of resolvers) {
779
+ const single = yield* resolver.resolve(tag, context).pipe(Effect7.either);
780
+ if (Either.isRight(single)) {
781
+ return single.right;
782
+ }
783
+ }
784
+ return yield* Effect7.fail(new ServiceNotAvailableError(String(tag.key ?? tag)));
785
+ }));
786
+ var empty2 = make8((tag, context) => {
787
+ return Effect7.fail(new ServiceNotAvailableError(String(tag.key ?? tag)));
788
+ });
789
+
790
+ // src/Trigger.ts
791
+ var Trigger_exports = {};
792
+ __export(Trigger_exports, {
793
+ EmailSpec: () => EmailSpec,
794
+ Kinds: () => Kinds,
795
+ QueueSpec: () => QueueSpec,
796
+ Spec: () => Spec,
797
+ SubscriptionSpec: () => SubscriptionSpec,
798
+ TimerSpec: () => TimerSpec,
799
+ Trigger: () => Trigger,
800
+ WebhookSpec: () => WebhookSpec,
801
+ make: () => make9,
802
+ specEmail: () => specEmail,
803
+ specFeed: () => specFeed,
804
+ specQueue: () => specQueue,
805
+ specSubscription: () => specSubscription,
806
+ specTimer: () => specTimer,
807
+ specWebhook: () => specWebhook
808
+ });
809
+ import * as Schema7 from "effect/Schema";
810
+ import * as SchemaAST from "effect/SchemaAST";
811
+ import { Annotation as Annotation5, Feed, Obj as Obj5, QueryAST, Ref as Ref4, Type as Type5 } from "@dxos/echo";
812
+ import { OptionsAnnotationId, SystemTypeAnnotation } from "@dxos/echo/internal";
813
+ import { failedInvariant } from "@dxos/invariant";
814
+ import { DXN } from "@dxos/keys";
815
+ var Kinds = [
816
+ "email",
817
+ "queue",
818
+ "subscription",
819
+ "timer",
820
+ "webhook"
821
+ ];
822
+ var kindLiteralAnnotations = {
823
+ title: "Kind"
824
+ };
825
+ var EmailSpec = Schema7.Struct({
826
+ kind: Schema7.Literal("email").annotations(kindLiteralAnnotations)
827
+ });
828
+ var specEmail = () => ({
829
+ kind: "email"
830
+ });
831
+ var QueueSpec = Schema7.Struct({
832
+ kind: Schema7.Literal("queue").annotations(kindLiteralAnnotations),
833
+ // TODO(dmaretskyi): Rename to `feed` and change to a reference.
834
+ queue: DXN.Schema
835
+ });
836
+ var specQueue = (queueDxn) => ({
837
+ kind: "queue",
838
+ queue: queueDxn
839
+ });
840
+ var specFeed = (feed) => specQueue(Feed.getQueueDxn(feed)?.toString() ?? failedInvariant(new Error("Could not extract DXN from feed")));
841
+ var SubscriptionSpec = Schema7.Struct({
842
+ kind: Schema7.Literal("subscription").annotations(kindLiteralAnnotations),
843
+ query: Schema7.Struct({
844
+ raw: Schema7.optional(Schema7.String.annotations({
845
+ title: "Query"
846
+ })),
847
+ ast: QueryAST.Query
848
+ }),
849
+ options: Schema7.optional(Schema7.Struct({
850
+ // Watch changes to object (not just creation).
851
+ deep: Schema7.optional(Schema7.Boolean.annotations({
852
+ title: "Nested"
853
+ })),
854
+ // Debounce changes (delay in ms).
855
+ delay: Schema7.optional(Schema7.Number.annotations({
856
+ title: "Delay"
857
+ }))
858
+ }).annotations({
859
+ title: "Options"
860
+ }))
861
+ });
862
+ var specSubscription = (query, options) => ({
863
+ kind: "subscription",
864
+ query: {
865
+ ast: query.ast
866
+ },
867
+ options: options ? {
868
+ deep: options.deep,
869
+ delay: options.delay
870
+ } : void 0
871
+ });
872
+ var TimerSpec = Schema7.Struct({
873
+ kind: Schema7.Literal("timer").annotations(kindLiteralAnnotations),
874
+ cron: Schema7.String.annotations({
875
+ title: "Cron",
876
+ [SchemaAST.ExamplesAnnotationId]: [
877
+ "0 0 * * *"
878
+ ]
879
+ })
880
+ });
881
+ var specTimer = (cron) => ({
882
+ kind: "timer",
883
+ cron
884
+ });
885
+ var WebhookSpec = Schema7.Struct({
886
+ kind: Schema7.Literal("webhook").annotations(kindLiteralAnnotations),
887
+ method: Schema7.optional(Schema7.String.annotations({
888
+ title: "Method",
889
+ [OptionsAnnotationId]: [
890
+ "GET",
891
+ "POST"
892
+ ]
893
+ })),
894
+ port: Schema7.optional(Schema7.Number.annotations({
895
+ title: "Port"
896
+ }))
897
+ });
898
+ var specWebhook = (opts) => ({
899
+ kind: "webhook",
900
+ method: opts?.method,
901
+ port: opts?.port
902
+ });
903
+ var Spec = Schema7.Union(EmailSpec, QueueSpec, SubscriptionSpec, TimerSpec, WebhookSpec).annotations({
904
+ title: "Trigger"
905
+ });
906
+ var TriggerSchema = Schema7.Struct({
907
+ /**
908
+ * Function or workflow to invoke.
909
+ */
910
+ // TODO(dmaretskyi): Can be a Ref(FunctionType) or Ref(ComputeGraphType).
911
+ function: Schema7.optional(Ref4.Ref(Obj5.Unknown).annotations({
912
+ title: "Function"
913
+ })),
914
+ /**
915
+ * Only used for workflowSchema.
916
+ * Specifies the input node in the circuit.
917
+ * @deprecated Remove and enforce a single input node in all compute graphSchema.
918
+ */
919
+ inputNodeId: Schema7.optional(Schema7.String.annotations({
920
+ title: "Input Node ID"
921
+ })),
922
+ // TODO(burdon): NO BOOLEAN PROPERTIES (enabld/disabled/paused, etc.)
923
+ // Need lint rule; or agent rule to require PR review for "boolean" key word.
924
+ enabled: Schema7.optional(Schema7.Boolean.annotations({
925
+ title: "Enabled"
926
+ })),
927
+ spec: Schema7.optional(Spec),
928
+ concurrency: Schema7.optional(Schema7.Number.annotations({
929
+ title: "Concurrency",
930
+ default: 1,
931
+ description: "Maximum number of concurrent invocations of the trigger. For Feed triggers, this will process Feed items in parallel."
932
+ })),
933
+ /**
934
+ * Passed as the input data to the function.
935
+ * Must match the function's input schema.
936
+ *
937
+ * @example
938
+ * {
939
+ * item: '{{event.item}}',
940
+ * instructions: 'Summarize and perform entity-extraction'
941
+ * mailbox: { '/': 'dxn:echo:AAA:ZZZ' }
942
+ * }
943
+ */
944
+ input: Schema7.optional(Schema7.Record({
945
+ key: Schema7.String,
946
+ value: Schema7.Any
947
+ }))
948
+ }).pipe(Type5.object({
949
+ typename: "org.dxos.type.trigger",
950
+ version: "0.1.0"
951
+ }), Annotation5.IconAnnotation.set({
952
+ icon: "ph--lightning--regular",
953
+ hue: "yellow"
954
+ }), SystemTypeAnnotation.set(true));
955
+ var Trigger = TriggerSchema;
956
+ var make9 = (props) => Obj5.make(Trigger, props);
957
+
958
+ // src/TriggerEvent.ts
959
+ var TriggerEvent_exports = {};
960
+ __export(TriggerEvent_exports, {
961
+ EmailEvent: () => EmailEvent,
962
+ QueueEvent: () => QueueEvent,
963
+ SubscriptionEvent: () => SubscriptionEvent,
964
+ TimerEvent: () => TimerEvent,
965
+ TriggerEvent: () => TriggerEvent,
966
+ WebhookEvent: () => WebhookEvent
967
+ });
968
+ import * as Schema8 from "effect/Schema";
969
+ import { DXN as DXN2, Obj as Obj6, Ref as Ref5 } from "@dxos/echo";
970
+ var EmailEvent = Schema8.Struct({
971
+ from: Schema8.String,
972
+ to: Schema8.String,
973
+ subject: Schema8.String,
974
+ created: Schema8.String,
975
+ body: Schema8.String
976
+ });
977
+ var QueueEvent = Schema8.Struct({
978
+ queue: DXN2.Schema,
979
+ item: Schema8.Any,
980
+ cursor: Schema8.String
981
+ });
982
+ var SubscriptionEvent = Schema8.Struct({
983
+ /**
984
+ * Type of the mutation.
985
+ */
986
+ // TODO(dmaretskyi): Specify enum.
987
+ type: Schema8.String,
988
+ /**
989
+ * Reference to the object that was changed or created.
990
+ */
991
+ subject: Ref5.Ref(Obj6.Unknown),
992
+ /**
993
+ * @deprecated
994
+ */
995
+ changedObjectId: Schema8.optional(Schema8.String)
996
+ });
997
+ var TimerEvent = Schema8.Struct({
998
+ tick: Schema8.Number
999
+ });
1000
+ var WebhookEvent = Schema8.Struct({
1001
+ url: Schema8.String,
1002
+ method: Schema8.Literal("GET", "POST"),
1003
+ headers: Schema8.Record({
1004
+ key: Schema8.String,
1005
+ value: Schema8.String
1006
+ }),
1007
+ bodyText: Schema8.String
1008
+ });
1009
+ var TriggerEvent = Schema8.Union(EmailEvent, QueueEvent, SubscriptionEvent, TimerEvent, WebhookEvent);
28
1010
  export {
29
- AsyncFunctionPlugin,
30
- ComputeGraph,
31
- ComputeGraphRegistry,
32
- ComputeNode,
33
- DetailedCellError,
34
- EDGE_FUNCTION_NAME,
35
- EdgeFunctionPlugin,
36
- EdgeFunctionPluginTranslations,
37
- ExportedCellChange,
38
- FunctionContext,
39
- RANGE_NOTATION,
40
- addressFromA1Notation,
41
- addressToA1Notation,
42
- cellEquals,
43
- columnLetter,
44
- createSheetName,
45
- defaultFunctionContextOptions,
46
- defaultFunctions,
47
- defaultOptions,
48
- defaultPlugins,
49
- inRange,
50
- isFormula,
51
- parseSheetName,
52
- rangeFromA1Notation,
53
- rangeToA1Notation
1011
+ Blueprint_exports as Blueprint,
1012
+ Credential_exports as Credential,
1013
+ FunctionError,
1014
+ FunctionNotFoundError,
1015
+ InvalidOperationInputError,
1016
+ InvalidOperationOutputError,
1017
+ InvokerNotInitializedError,
1018
+ NoHandlerError,
1019
+ Operation_exports as Operation,
1020
+ OperationHandlerSet_exports as OperationHandlerSet,
1021
+ OperationRegistry_exports as OperationRegistry,
1022
+ Process_exports as Process,
1023
+ Routine_exports as Routine,
1024
+ Script_exports as Script,
1025
+ ServiceNotAvailableError,
1026
+ ServiceResolver_exports as ServiceResolver,
1027
+ StorageService_exports as StorageService,
1028
+ Template_exports as Template,
1029
+ Trace_exports as Trace,
1030
+ Trigger_exports as Trigger,
1031
+ TriggerEvent_exports as TriggerEvent,
1032
+ TriggerStateNotFoundError
54
1033
  };
55
1034
  //# sourceMappingURL=index.mjs.map