@dxos/functions 0.8.4-main.7ace549 → 0.8.4-main.8360d9e660

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 (59) hide show
  1. package/README.md +4 -6
  2. package/dist/lib/{browser → neutral}/index.mjs +327 -114
  3. package/dist/lib/neutral/index.mjs.map +7 -0
  4. package/dist/lib/neutral/meta.json +1 -0
  5. package/dist/types/src/errors.d.ts +24 -32
  6. package/dist/types/src/errors.d.ts.map +1 -1
  7. package/dist/types/src/example/index.d.ts +5 -5
  8. package/dist/types/src/example/index.d.ts.map +1 -1
  9. package/dist/types/src/operation-compatibility.test.d.ts +2 -0
  10. package/dist/types/src/operation-compatibility.test.d.ts.map +1 -0
  11. package/dist/types/src/protocol/functions-ai-http-client.d.ts +12 -0
  12. package/dist/types/src/protocol/functions-ai-http-client.d.ts.map +1 -0
  13. package/dist/types/src/protocol/protocol.d.ts.map +1 -1
  14. package/dist/types/src/sdk.d.ts +26 -9
  15. package/dist/types/src/sdk.d.ts.map +1 -1
  16. package/dist/types/src/services/credentials.d.ts +6 -4
  17. package/dist/types/src/services/credentials.d.ts.map +1 -1
  18. package/dist/types/src/services/event-logger.d.ts +25 -31
  19. package/dist/types/src/services/event-logger.d.ts.map +1 -1
  20. package/dist/types/src/services/function-invocation-service.d.ts +5 -0
  21. package/dist/types/src/services/function-invocation-service.d.ts.map +1 -1
  22. package/dist/types/src/services/index.d.ts +0 -1
  23. package/dist/types/src/services/index.d.ts.map +1 -1
  24. package/dist/types/src/services/tracing.d.ts +37 -3
  25. package/dist/types/src/services/tracing.d.ts.map +1 -1
  26. package/dist/types/src/types/Function.d.ts +34 -45
  27. package/dist/types/src/types/Function.d.ts.map +1 -1
  28. package/dist/types/src/types/Script.d.ts +8 -15
  29. package/dist/types/src/types/Script.d.ts.map +1 -1
  30. package/dist/types/src/types/Trigger.d.ts +59 -78
  31. package/dist/types/src/types/Trigger.d.ts.map +1 -1
  32. package/dist/types/src/types/TriggerEvent.d.ts +44 -12
  33. package/dist/types/src/types/TriggerEvent.d.ts.map +1 -1
  34. package/dist/types/src/types/url.d.ts +6 -5
  35. package/dist/types/src/types/url.d.ts.map +1 -1
  36. package/dist/types/tsconfig.tsbuildinfo +1 -1
  37. package/package.json +23 -18
  38. package/src/errors.ts +4 -4
  39. package/src/example/forex-effect.ts +1 -1
  40. package/src/example/index.ts +8 -8
  41. package/src/operation-compatibility.test.ts +185 -0
  42. package/src/protocol/functions-ai-http-client.ts +67 -0
  43. package/src/protocol/protocol.ts +117 -15
  44. package/src/sdk.ts +73 -16
  45. package/src/services/credentials.ts +31 -15
  46. package/src/services/event-logger.ts +2 -2
  47. package/src/services/function-invocation-service.ts +14 -0
  48. package/src/services/index.ts +0 -2
  49. package/src/services/tracing.ts +63 -4
  50. package/src/types/Function.ts +16 -13
  51. package/src/types/Script.ts +9 -4
  52. package/src/types/Trigger.ts +30 -16
  53. package/src/types/TriggerEvent.ts +29 -29
  54. package/src/types/url.ts +6 -5
  55. package/dist/lib/browser/index.mjs.map +0 -7
  56. package/dist/lib/browser/meta.json +0 -1
  57. package/dist/lib/node-esm/index.mjs +0 -1031
  58. package/dist/lib/node-esm/index.mjs.map +0 -7
  59. package/dist/lib/node-esm/meta.json +0 -1
@@ -6,7 +6,7 @@ var __export = (target, all) => {
6
6
 
7
7
  // src/errors.ts
8
8
  import { BaseError } from "@dxos/errors";
9
- var ServiceNotAvailableError = class extends BaseError.extend("SERVICE_NOT_AVAILABLE", "Service not available") {
9
+ var ServiceNotAvailableError = class extends BaseError.extend("ServiceNotAvailable", "Service not available") {
10
10
  constructor(service, options) {
11
11
  super({
12
12
  context: {
@@ -16,7 +16,7 @@ var ServiceNotAvailableError = class extends BaseError.extend("SERVICE_NOT_AVAIL
16
16
  });
17
17
  }
18
18
  };
19
- var FunctionNotFoundError = class extends BaseError.extend("FUNCTION_NOT_FOUND", "Function not found") {
19
+ var FunctionNotFoundError = class extends BaseError.extend("FunctionNotFound", "Function not found") {
20
20
  constructor(functionKey, options) {
21
21
  super({
22
22
  context: {
@@ -26,9 +26,9 @@ var FunctionNotFoundError = class extends BaseError.extend("FUNCTION_NOT_FOUND",
26
26
  });
27
27
  }
28
28
  };
29
- var FunctionError = class extends BaseError.extend("FUNCTION_ERROR", "Function invocation error") {
29
+ var FunctionError = class extends BaseError.extend("FunctionError", "Function invocation error") {
30
30
  };
31
- var TriggerStateNotFoundError = class extends BaseError.extend("TRIGGER_STATE_NOT_FOUND", "Trigger state not found") {
31
+ var TriggerStateNotFoundError = class extends BaseError.extend("TriggerStateNotFound", "Trigger state not found") {
32
32
  };
33
33
 
34
34
  // src/example/fib.ts
@@ -38,8 +38,9 @@ import * as Schema6 from "effect/Schema";
38
38
  // src/sdk.ts
39
39
  import * as Effect from "effect/Effect";
40
40
  import * as Schema5 from "effect/Schema";
41
- import { Obj as Obj5, Type as Type5 } from "@dxos/echo";
41
+ import { JsonSchema as JsonSchema2, Obj as Obj5 } from "@dxos/echo";
42
42
  import { assertArgument, failedInvariant } from "@dxos/invariant";
43
+ import { Operation } from "@dxos/operation";
43
44
 
44
45
  // src/types/Function.ts
45
46
  var Function_exports = {};
@@ -49,7 +50,7 @@ __export(Function_exports, {
49
50
  setFrom: () => setFrom
50
51
  });
51
52
  import * as Schema2 from "effect/Schema";
52
- import { Annotation as Annotation2, JsonSchema, Obj as Obj2, Type as Type2 } from "@dxos/echo";
53
+ import { Annotation as Annotation2, JsonSchema, Obj as Obj2, Ref as Ref2, Type as Type2 } from "@dxos/echo";
53
54
  import { SystemTypeAnnotation } from "@dxos/echo/internal";
54
55
 
55
56
  // src/types/Script.ts
@@ -68,13 +69,16 @@ var Script = Schema.Struct({
68
69
  // TODO(burdon): Change to hash of deployed content.
69
70
  // Whether source has changed since last deploy.
70
71
  changed: Schema.Boolean.pipe(FormInputAnnotation.set(false), Schema.optional),
71
- source: Type.Ref(Text.Text).pipe(FormInputAnnotation.set(false))
72
- }).pipe(Type.Obj({
73
- typename: "dxos.org/type/Script",
72
+ source: Ref.Ref(Text.Text).pipe(FormInputAnnotation.set(false))
73
+ }).pipe(Type.object({
74
+ typename: "org.dxos.type.script",
74
75
  version: "0.1.0"
75
76
  }), Annotation.LabelAnnotation.set([
76
77
  "name"
77
- ]));
78
+ ]), Annotation.IconAnnotation.set({
79
+ icon: "ph--code--regular",
80
+ hue: "sky"
81
+ }));
78
82
  var make = ({ source = "", ...props } = {}) => Obj.make(Script, {
79
83
  ...props,
80
84
  source: Ref.make(Text.make(source))
@@ -101,7 +105,7 @@ var Function = Schema2.Struct({
101
105
  updated: Schema2.optional(Schema2.String),
102
106
  // Reference to a source script if it exists within ECHO.
103
107
  // TODO(burdon): Don't ref ScriptType directly (core).
104
- source: Schema2.optional(Type2.Ref(Script)),
108
+ source: Schema2.optional(Ref2.Ref(Script)),
105
109
  inputSchema: Schema2.optional(JsonSchema.JsonSchema),
106
110
  outputSchema: Schema2.optional(JsonSchema.JsonSchema),
107
111
  /**
@@ -111,22 +115,27 @@ var Function = Schema2.Struct({
111
115
  services: Schema2.optional(Schema2.Array(Schema2.String)),
112
116
  // Local binding to a function name.
113
117
  binding: Schema2.optional(Schema2.String)
114
- }).pipe(Type2.Obj({
115
- typename: "dxos.org/type/Function",
118
+ }).pipe(Type2.object({
119
+ typename: "org.dxos.type.function",
116
120
  version: "0.1.0"
117
121
  }), Annotation2.LabelAnnotation.set([
118
122
  "name"
119
- ]), SystemTypeAnnotation.set(true));
123
+ ]), Annotation2.IconAnnotation.set({
124
+ icon: "ph--function--regular",
125
+ hue: "blue"
126
+ }), SystemTypeAnnotation.set(true));
120
127
  var make2 = (props) => Obj2.make(Function, props);
121
128
  var setFrom = (target, source) => {
122
- target.key = source.key ?? target.key;
123
- target.name = source.name ?? target.name;
124
- target.version = source.version;
125
- target.description = source.description;
126
- target.updated = source.updated;
127
- target.inputSchema = source.inputSchema ? JSON.parse(JSON.stringify(source.inputSchema)) : void 0;
128
- target.outputSchema = source.outputSchema ? JSON.parse(JSON.stringify(source.outputSchema)) : void 0;
129
- Obj2.getMeta(target).keys = JSON.parse(JSON.stringify(Obj2.getMeta(source).keys));
129
+ Obj2.change(target, (t) => {
130
+ t.key = source.key ?? target.key;
131
+ t.name = source.name ?? target.name;
132
+ t.version = source.version;
133
+ t.description = source.description;
134
+ t.updated = source.updated;
135
+ t.inputSchema = source.inputSchema ? JSON.parse(JSON.stringify(source.inputSchema)) : void 0;
136
+ t.outputSchema = source.outputSchema ? JSON.parse(JSON.stringify(source.outputSchema)) : void 0;
137
+ Obj2.getMeta(t).keys = JSON.parse(JSON.stringify(Obj2.getMeta(source).keys));
138
+ });
130
139
  };
131
140
 
132
141
  // src/types/Trigger.ts
@@ -144,9 +153,10 @@ __export(Trigger_exports, {
144
153
  });
145
154
  import * as Schema3 from "effect/Schema";
146
155
  import * as SchemaAST from "effect/SchemaAST";
147
- import { Obj as Obj3, QueryAST, Type as Type3 } from "@dxos/echo";
156
+ import { Annotation as Annotation3, Obj as Obj3, QueryAST, Ref as Ref3, Type as Type3 } from "@dxos/echo";
148
157
  import { OptionsAnnotationId, SystemTypeAnnotation as SystemTypeAnnotation2 } from "@dxos/echo/internal";
149
158
  import { DXN } from "@dxos/keys";
159
+ import { Expando } from "@dxos/schema";
150
160
  var Kinds = [
151
161
  "email",
152
162
  "queue",
@@ -159,12 +169,12 @@ var kindLiteralAnnotations = {
159
169
  };
160
170
  var EmailSpec = Schema3.Struct({
161
171
  kind: Schema3.Literal("email").annotations(kindLiteralAnnotations)
162
- }).pipe(Schema3.mutable);
172
+ });
163
173
  var QueueSpec = Schema3.Struct({
164
174
  kind: Schema3.Literal("queue").annotations(kindLiteralAnnotations),
165
175
  // TODO(dmaretskyi): Change to a reference.
166
176
  queue: DXN.Schema
167
- }).pipe(Schema3.mutable);
177
+ });
168
178
  var SubscriptionSpec = Schema3.Struct({
169
179
  kind: Schema3.Literal("subscription").annotations(kindLiteralAnnotations),
170
180
  query: Schema3.Struct({
@@ -172,7 +182,7 @@ var SubscriptionSpec = Schema3.Struct({
172
182
  title: "Query"
173
183
  })),
174
184
  ast: QueryAST.Query
175
- }).pipe(Schema3.mutable),
185
+ }),
176
186
  options: Schema3.optional(Schema3.Struct({
177
187
  // Watch changes to object (not just creation).
178
188
  deep: Schema3.optional(Schema3.Boolean.annotations({
@@ -185,7 +195,7 @@ var SubscriptionSpec = Schema3.Struct({
185
195
  }).annotations({
186
196
  title: "Options"
187
197
  }))
188
- }).pipe(Schema3.mutable);
198
+ });
189
199
  var TimerSpec = Schema3.Struct({
190
200
  kind: Schema3.Literal("timer").annotations(kindLiteralAnnotations),
191
201
  cron: Schema3.String.annotations({
@@ -194,7 +204,7 @@ var TimerSpec = Schema3.Struct({
194
204
  "0 0 * * *"
195
205
  ]
196
206
  })
197
- }).pipe(Schema3.mutable);
207
+ });
198
208
  var WebhookSpec = Schema3.Struct({
199
209
  kind: Schema3.Literal("webhook").annotations(kindLiteralAnnotations),
200
210
  method: Schema3.optional(Schema3.String.annotations({
@@ -207,16 +217,16 @@ var WebhookSpec = Schema3.Struct({
207
217
  port: Schema3.optional(Schema3.Number.annotations({
208
218
  title: "Port"
209
219
  }))
210
- }).pipe(Schema3.mutable);
220
+ });
211
221
  var Spec = Schema3.Union(EmailSpec, QueueSpec, SubscriptionSpec, TimerSpec, WebhookSpec).annotations({
212
222
  title: "Trigger"
213
223
  });
214
- var Trigger_ = Schema3.Struct({
224
+ var TriggerSchema = Schema3.Struct({
215
225
  /**
216
226
  * Function or workflow to invoke.
217
227
  */
218
228
  // TODO(dmaretskyi): Can be a Ref(FunctionType) or Ref(ComputeGraphType).
219
- function: Schema3.optional(Type3.Ref(Type3.Expando).annotations({
229
+ function: Schema3.optional(Ref3.Ref(Expando.Expando).annotations({
220
230
  title: "Function"
221
231
  })),
222
232
  /**
@@ -227,30 +237,40 @@ var Trigger_ = Schema3.Struct({
227
237
  inputNodeId: Schema3.optional(Schema3.String.annotations({
228
238
  title: "Input Node ID"
229
239
  })),
240
+ // TODO(burdon): NO BOOLEAN PROPERTIES (enabld/disabled/paused, etc.)
241
+ // Need lint rule; or agent rule to require PR review for "boolean" key word.
230
242
  enabled: Schema3.optional(Schema3.Boolean.annotations({
231
243
  title: "Enabled"
232
244
  })),
233
245
  spec: Schema3.optional(Spec),
246
+ concurrency: Schema3.optional(Schema3.Number.annotations({
247
+ title: "Concurrency",
248
+ default: 1,
249
+ description: "Maximum number of concurrent invocations of the trigger. For queue triggers, this will process queue items in parallel."
250
+ })),
234
251
  /**
235
252
  * Passed as the input data to the function.
236
253
  * Must match the function's input schema.
237
254
  *
238
255
  * @example
239
256
  * {
240
- * item: '{{$.trigger.event}}',
257
+ * item: '{{event.item}}',
241
258
  * instructions: 'Summarize and perform entity-extraction'
242
259
  * mailbox: { '/': 'dxn:echo:AAA:ZZZ' }
243
260
  * }
244
261
  */
245
- input: Schema3.optional(Schema3.mutable(Schema3.Record({
262
+ input: Schema3.optional(Schema3.Record({
246
263
  key: Schema3.String,
247
264
  value: Schema3.Any
248
- })))
249
- }).pipe(Type3.Obj({
250
- typename: "dxos.org/type/Trigger",
265
+ }))
266
+ }).pipe(Type3.object({
267
+ typename: "org.dxos.type.trigger",
251
268
  version: "0.1.0"
269
+ }), Annotation3.IconAnnotation.set({
270
+ icon: "ph--lightning--regular",
271
+ hue: "yellow"
252
272
  }), SystemTypeAnnotation2.set(true));
253
- var Trigger = Trigger_;
273
+ var Trigger = TriggerSchema;
254
274
  var make3 = (props) => Obj3.make(Trigger, props);
255
275
 
256
276
  // src/types/TriggerEvent.ts
@@ -260,22 +280,23 @@ __export(TriggerEvent_exports, {
260
280
  QueueEvent: () => QueueEvent,
261
281
  SubscriptionEvent: () => SubscriptionEvent,
262
282
  TimerEvent: () => TimerEvent,
283
+ TriggerEvent: () => TriggerEvent,
263
284
  WebhookEvent: () => WebhookEvent
264
285
  });
265
286
  import * as Schema4 from "effect/Schema";
266
- import { DXN as DXN2, Obj as Obj4, Type as Type4 } from "@dxos/echo";
267
- var EmailEvent = Schema4.mutable(Schema4.Struct({
287
+ import { DXN as DXN2, Obj as Obj4, Ref as Ref4 } from "@dxos/echo";
288
+ var EmailEvent = Schema4.Struct({
268
289
  from: Schema4.String,
269
290
  to: Schema4.String,
270
291
  subject: Schema4.String,
271
292
  created: Schema4.String,
272
293
  body: Schema4.String
273
- }));
274
- var QueueEvent = Schema4.mutable(Schema4.Struct({
294
+ });
295
+ var QueueEvent = Schema4.Struct({
275
296
  queue: DXN2.Schema,
276
297
  item: Schema4.Any,
277
298
  cursor: Schema4.String
278
- }));
299
+ });
279
300
  var SubscriptionEvent = Schema4.Struct({
280
301
  /**
281
302
  * Type of the mutation.
@@ -285,16 +306,16 @@ var SubscriptionEvent = Schema4.Struct({
285
306
  /**
286
307
  * Reference to the object that was changed or created.
287
308
  */
288
- subject: Type4.Ref(Obj4.Any),
309
+ subject: Ref4.Ref(Obj4.Unknown),
289
310
  /**
290
311
  * @deprecated
291
312
  */
292
313
  changedObjectId: Schema4.optional(Schema4.String)
293
- }).pipe(Schema4.mutable);
294
- var TimerEvent = Schema4.mutable(Schema4.Struct({
314
+ });
315
+ var TimerEvent = Schema4.Struct({
295
316
  tick: Schema4.Number
296
- }));
297
- var WebhookEvent = Schema4.mutable(Schema4.Struct({
317
+ });
318
+ var WebhookEvent = Schema4.Struct({
298
319
  url: Schema4.String,
299
320
  method: Schema4.Literal("GET", "POST"),
300
321
  headers: Schema4.Record({
@@ -302,11 +323,12 @@ var WebhookEvent = Schema4.mutable(Schema4.Struct({
302
323
  value: Schema4.String
303
324
  }),
304
325
  bodyText: Schema4.String
305
- }));
326
+ });
327
+ var TriggerEvent = Schema4.Union(EmailEvent, QueueEvent, SubscriptionEvent, TimerEvent, WebhookEvent);
306
328
 
307
329
  // src/types/url.ts
308
- var FUNCTIONS_META_KEY = "dxos.org/service/function";
309
- var FUNCTIONS_PRESET_META_KEY = "dxos.org/service/function-preset";
330
+ var FUNCTIONS_META_KEY = "org.dxos.service.function";
331
+ var FUNCTIONS_PRESET_META_KEY = "org.dxos.service.function-preset";
310
332
  var getUserFunctionIdInMetadata = (meta) => {
311
333
  return meta.keys.find((key) => key.source === FUNCTIONS_META_KEY)?.id;
312
334
  };
@@ -325,7 +347,7 @@ var setUserFunctionIdInMetadata = (meta, functionId) => {
325
347
  };
326
348
 
327
349
  // src/sdk.ts
328
- var typeId = Symbol.for("@dxos/functions/FunctionDefinition");
350
+ var typeId = /* @__PURE__ */ Symbol.for("@dxos/functions/FunctionDefinition");
329
351
  var defineFunction = ({ key, name, description, inputSchema, outputSchema = Schema5.Any, handler, types, services }) => {
330
352
  if (!Schema5.isSchema(inputSchema)) {
331
353
  throw new Error("Input schema must be a valid schema");
@@ -376,14 +398,43 @@ var getServiceKeys = (services) => {
376
398
  if (typeof tag.key === "string") {
377
399
  return tag.key;
378
400
  }
379
- console.log(tag);
380
401
  failedInvariant();
381
402
  });
382
403
  };
404
+ var toOperation = (functionDef) => {
405
+ const op = Operation.make({
406
+ schema: {
407
+ input: functionDef.inputSchema,
408
+ output: functionDef.outputSchema ?? Schema5.Any
409
+ },
410
+ meta: {
411
+ key: functionDef.key,
412
+ name: functionDef.name,
413
+ description: functionDef.description
414
+ }
415
+ });
416
+ const operationHandler = (input) => {
417
+ const result = functionDef.handler({
418
+ context: {},
419
+ data: input
420
+ });
421
+ if (Effect.isEffect(result)) {
422
+ return result;
423
+ }
424
+ if (result instanceof Promise) {
425
+ return Effect.tryPromise(() => result);
426
+ }
427
+ return Effect.succeed(result);
428
+ };
429
+ return {
430
+ ...op,
431
+ handler: operationHandler
432
+ };
433
+ };
383
434
  var FunctionDefinition = {
384
435
  make: defineFunction,
385
436
  isFunction: (value2) => {
386
- return typeof value2 === "object" && value2 !== null && Symbol.for("@dxos/functions/FunctionDefinition") in value2;
437
+ return typeof value2 === "object" && value2 !== null && /* @__PURE__ */ Symbol.for("@dxos/functions/FunctionDefinition") in value2;
387
438
  },
388
439
  serialize: (functionDef) => {
389
440
  assertArgument(FunctionDefinition.isFunction(functionDef), "functionDef");
@@ -392,7 +443,8 @@ var FunctionDefinition = {
392
443
  deserialize: (functionObj) => {
393
444
  assertArgument(Obj5.instanceOf(Function_exports.Function, functionObj), "functionObj");
394
445
  return deserializeFunction(functionObj);
395
- }
446
+ },
447
+ toOperation
396
448
  };
397
449
  var serializeFunction = (functionDef) => {
398
450
  const fn4 = Function_exports.make({
@@ -400,12 +452,12 @@ var serializeFunction = (functionDef) => {
400
452
  name: functionDef.name,
401
453
  version: "0.1.0",
402
454
  description: functionDef.description,
403
- inputSchema: Type5.toJsonSchema(functionDef.inputSchema),
404
- outputSchema: !functionDef.outputSchema ? void 0 : Type5.toJsonSchema(functionDef.outputSchema),
455
+ inputSchema: JsonSchema2.toJsonSchema(functionDef.inputSchema),
456
+ outputSchema: !functionDef.outputSchema ? void 0 : JsonSchema2.toJsonSchema(functionDef.outputSchema),
405
457
  services: functionDef.services
406
458
  });
407
459
  if (functionDef.meta?.deployedFunctionId) {
408
- setUserFunctionIdInMetadata(Obj5.getMeta(fn4), functionDef.meta.deployedFunctionId);
460
+ Obj5.change(fn4, (fn5) => setUserFunctionIdInMetadata(Obj5.getMeta(fn5), functionDef.meta.deployedFunctionId));
409
461
  }
410
462
  return fn4;
411
463
  };
@@ -416,8 +468,8 @@ var deserializeFunction = (functionObj) => {
416
468
  key: functionObj.key ?? functionObj.name,
417
469
  name: functionObj.name,
418
470
  description: functionObj.description,
419
- inputSchema: !functionObj.inputSchema ? Schema5.Unknown : Type5.toEffectSchema(functionObj.inputSchema),
420
- outputSchema: !functionObj.outputSchema ? void 0 : Type5.toEffectSchema(functionObj.outputSchema),
471
+ inputSchema: !functionObj.inputSchema ? Schema5.Unknown : JsonSchema2.toEffectSchema(functionObj.inputSchema),
472
+ outputSchema: !functionObj.outputSchema ? void 0 : JsonSchema2.toEffectSchema(functionObj.outputSchema),
421
473
  // TODO(dmaretskyi): This should throw error.
422
474
  handler: () => {
423
475
  },
@@ -494,15 +546,11 @@ var sleep_default = defineFunction({
494
546
  });
495
547
 
496
548
  // src/example/index.ts
497
- (function(Example2) {
498
- Example2.fib = fib_default;
499
- Example2.reply = reply_default;
500
- Example2.sleep = sleep_default;
501
- })(Example || (Example = {}));
502
- var Example;
503
-
504
- // src/services/index.ts
505
- import { DatabaseService as DatabaseService2 } from "@dxos/echo-db";
549
+ var ExampleFunctions = {
550
+ Fibonacci: fib_default,
551
+ Reply: reply_default,
552
+ Sleep: sleep_default
553
+ };
506
554
 
507
555
  // src/services/credentials.ts
508
556
  import * as HttpClient from "@effect/platform/HttpClient";
@@ -512,7 +560,7 @@ import * as Effect5 from "effect/Effect";
512
560
  import * as Layer from "effect/Layer";
513
561
  import * as Redacted from "effect/Redacted";
514
562
  import { Query } from "@dxos/echo";
515
- import { DatabaseService } from "@dxos/echo-db";
563
+ import { Database } from "@dxos/echo";
516
564
  import { AccessToken } from "@dxos/types";
517
565
  var CredentialsService = class _CredentialsService extends Context.Tag("@dxos/functions/CredentialsService")() {
518
566
  static getCredential = (query) => Effect5.gen(function* () {
@@ -536,14 +584,23 @@ var CredentialsService = class _CredentialsService extends Context.Tag("@dxos/fu
536
584
  }));
537
585
  return new ConfiguredCredentialsService(serviceCredentials);
538
586
  }));
539
- static layerFromDatabase = () => Layer.effect(_CredentialsService, Effect5.gen(function* () {
540
- const dbService = yield* DatabaseService;
587
+ static layerFromDatabase = ({ caching = false } = {}) => Layer.effect(_CredentialsService, Effect5.gen(function* () {
588
+ const dbService = yield* Database.Service;
589
+ const cache = /* @__PURE__ */ new Map();
541
590
  const queryCredentials = async (query) => {
542
- const { objects: accessTokens } = await dbService.db.query(Query.type(AccessToken.AccessToken)).run();
543
- return accessTokens.filter((accessToken) => accessToken.source === query.service).map((accessToken) => ({
591
+ const cacheKey = JSON.stringify(query);
592
+ if (caching && cache.has(cacheKey)) {
593
+ return cache.get(cacheKey);
594
+ }
595
+ const accessTokens = await dbService.db.query(Query.type(AccessToken.AccessToken)).run();
596
+ const credentials = accessTokens.filter((accessToken) => accessToken.source === query.service).map((accessToken) => ({
544
597
  service: accessToken.source,
545
598
  apiKey: accessToken.token
546
599
  }));
600
+ if (caching) {
601
+ cache.set(cacheKey, credentials);
602
+ }
603
+ return credentials;
547
604
  };
548
605
  return {
549
606
  getCredential: async (query) => {
@@ -579,18 +636,17 @@ var ConfiguredCredentialsService = class {
579
636
  return credential;
580
637
  }
581
638
  };
582
- var withAuthorization = (query, kind) => HttpClient.mapRequestEffect(Effect5.fnUntraced(function* (request) {
583
- const key = yield* CredentialsService.getApiKey(query).pipe(Effect5.map(Redacted.value));
584
- const authorization = kind ? `${kind} ${key}` : key;
639
+ var withAuthorization = (token, kind) => HttpClient.mapRequest((request) => {
640
+ const authorization = kind ? `${kind} ${token}` : token;
585
641
  return HttpClientRequest.setHeader(request, "Authorization", authorization);
586
- }));
642
+ });
587
643
 
588
644
  // src/services/event-logger.ts
589
645
  import * as Context3 from "effect/Context";
590
646
  import * as Effect7 from "effect/Effect";
591
647
  import * as Layer3 from "effect/Layer";
592
648
  import * as Schema9 from "effect/Schema";
593
- import { Obj as Obj7, Type as Type6 } from "@dxos/echo";
649
+ import { Obj as Obj7, Type as Type4 } from "@dxos/echo";
594
650
  import { invariant } from "@dxos/invariant";
595
651
  import { LogLevel, log as log2 } from "@dxos/log";
596
652
 
@@ -600,12 +656,19 @@ import * as Effect6 from "effect/Effect";
600
656
  import * as Layer2 from "effect/Layer";
601
657
  import { AgentStatus } from "@dxos/ai";
602
658
  import { Obj as Obj6 } from "@dxos/echo";
659
+ import { ObjectId } from "@dxos/keys";
603
660
  import { Message } from "@dxos/types";
604
661
  var TracingService = class _TracingService extends Context2.Tag("@dxos/functions/TracingService")() {
605
662
  static noop = {
606
663
  getTraceContext: () => ({}),
607
664
  write: () => {
608
- }
665
+ },
666
+ traceInvocationStart: () => Effect6.sync(() => ({
667
+ invocationId: ObjectId.random(),
668
+ invocationTraceQueue: void 0
669
+ })),
670
+ traceInvocationEnd: () => Effect6.sync(() => {
671
+ })
609
672
  };
610
673
  static layerNoop = Layer2.succeed(_TracingService, _TracingService.noop);
611
674
  /**
@@ -615,11 +678,22 @@ var TracingService = class _TracingService extends Context2.Tag("@dxos/functions
615
678
  const tracing = yield* _TracingService;
616
679
  const context = mapContext(tracing.getTraceContext());
617
680
  return {
618
- write: (event) => tracing.write(event),
619
- getTraceContext: () => context
681
+ write: (event, context2) => tracing.write(event, context2),
682
+ getTraceContext: () => context,
683
+ traceInvocationStart: () => Effect6.die("Tracing invocation inside another invocation is not supported."),
684
+ traceInvocationEnd: () => Effect6.die("Tracing invocation inside another invocation is not supported.")
620
685
  };
621
686
  }));
622
687
  /**
688
+ * Create sublayer to trace an invocation.
689
+ * @param data
690
+ * @returns
691
+ */
692
+ static layerInvocation = (data) => _TracingService.layerSubframe((context) => ({
693
+ ...context,
694
+ currentInvocation: data
695
+ }));
696
+ /**
623
697
  * Emit the current human-readable execution status.
624
698
  */
625
699
  static emitStatus = Effect6.fnUntraced(function* (data) {
@@ -629,7 +703,7 @@ var TracingService = class _TracingService extends Context2.Tag("@dxos/functions
629
703
  toolCallId: tracing.getTraceContext().toolCallId,
630
704
  created: (/* @__PURE__ */ new Date()).toISOString(),
631
705
  ...data
632
- }));
706
+ }), tracing.getTraceContext());
633
707
  });
634
708
  static emitConverationMessage = Effect6.fnUntraced(function* (data) {
635
709
  const tracing = yield* _TracingService;
@@ -640,7 +714,7 @@ var TracingService = class _TracingService extends Context2.Tag("@dxos/functions
640
714
  [MESSAGE_PROPERTY_TOOL_CALL_ID]: tracing.getTraceContext().toolCallId,
641
715
  ...data.properties
642
716
  }
643
- }));
717
+ }), tracing.getTraceContext());
644
718
  });
645
719
  };
646
720
  var MESSAGE_PROPERTY_TOOL_CALL_ID = "toolCallId";
@@ -678,8 +752,8 @@ var ComputeEventPayload = Schema9.Union(Schema9.Struct({
678
752
  }));
679
753
  var ComputeEvent = Schema9.Struct({
680
754
  payload: ComputeEventPayload
681
- }).pipe(Type6.Obj({
682
- typename: "dxos.org/type/ComputeEvent",
755
+ }).pipe(Type4.object({
756
+ typename: "org.dxos.type.compute-event",
683
757
  version: "0.1.0"
684
758
  }));
685
759
  var ComputeEventLogger = class _ComputeEventLogger extends Context3.Tag("@dxos/functions/ComputeEventLogger")() {
@@ -697,7 +771,7 @@ var ComputeEventLogger = class _ComputeEventLogger extends Context3.Tag("@dxos/f
697
771
  log: (event) => {
698
772
  tracing.write(Obj7.make(ComputeEvent, {
699
773
  payload: event
700
- }));
774
+ }), tracing.getTraceContext());
701
775
  },
702
776
  nodeId: void 0
703
777
  };
@@ -753,16 +827,22 @@ var createEventLogger = (level, message = "event") => {
753
827
  // src/services/function-invocation-service.ts
754
828
  import * as Context4 from "effect/Context";
755
829
  import * as Effect8 from "effect/Effect";
830
+ import * as Layer4 from "effect/Layer";
756
831
  var FunctionInvocationService = class _FunctionInvocationService extends Context4.Tag("@dxos/functions/FunctionInvocationService")() {
832
+ static layerNotAvailable = Layer4.succeed(_FunctionInvocationService, {
833
+ invokeFunction: () => Effect8.die("FunctionInvocationService is not avaialble."),
834
+ resolveFunction: () => Effect8.die("FunctionInvocationService is not available.")
835
+ });
757
836
  static invokeFunction = (functionDef, input) => Effect8.serviceFunctionEffect(_FunctionInvocationService, (service) => service.invokeFunction)(functionDef, input);
837
+ static resolveFunction = (key) => Effect8.serviceFunctionEffect(_FunctionInvocationService, (service) => service.resolveFunction)(key);
758
838
  };
759
839
 
760
840
  // src/services/queues.ts
761
841
  import * as Context5 from "effect/Context";
762
842
  import * as Effect9 from "effect/Effect";
763
- import * as Layer4 from "effect/Layer";
843
+ import * as Layer5 from "effect/Layer";
764
844
  var QueueService = class _QueueService extends Context5.Tag("@dxos/functions/QueueService")() {
765
- static notAvailable = Layer4.succeed(_QueueService, {
845
+ static notAvailable = Layer5.succeed(_QueueService, {
766
846
  queues: {
767
847
  get(_dxn) {
768
848
  throw new Error("Queues not available");
@@ -779,7 +859,7 @@ var QueueService = class _QueueService extends Context5.Tag("@dxos/functions/Que
779
859
  queue
780
860
  };
781
861
  };
782
- static layer = (queues, queue) => Layer4.succeed(_QueueService, _QueueService.make(queues, queue));
862
+ static layer = (queues, queue) => Layer5.succeed(_QueueService, _QueueService.make(queues, queue));
783
863
  /**
784
864
  * Gets a queue by its DXN.
785
865
  */
@@ -791,22 +871,83 @@ var QueueService = class _QueueService extends Context5.Tag("@dxos/functions/Que
791
871
  static append = (queue, objects) => Effect9.promise(() => queue.append(objects));
792
872
  };
793
873
  var ContextQueueService = class _ContextQueueService extends Context5.Tag("@dxos/functions/ContextQueueService")() {
794
- static layer = (queue) => Layer4.succeed(_ContextQueueService, {
874
+ static layer = (queue) => Layer5.succeed(_ContextQueueService, {
795
875
  queue
796
876
  });
797
877
  };
798
878
 
799
879
  // src/protocol/protocol.ts
800
- import * as Effect10 from "effect/Effect";
801
- import * as Layer5 from "effect/Layer";
880
+ import * as AnthropicClient from "@effect/ai-anthropic/AnthropicClient";
881
+ import * as Effect11 from "effect/Effect";
882
+ import * as Layer7 from "effect/Layer";
802
883
  import * as Schema10 from "effect/Schema";
803
884
  import * as SchemaAST2 from "effect/SchemaAST";
804
- import { AiService } from "@dxos/ai";
885
+ import { AiModelResolver, AiService } from "@dxos/ai";
886
+ import { AnthropicResolver } from "@dxos/ai/resolvers";
805
887
  import { LifecycleState, Resource } from "@dxos/context";
806
- import { Type as Type7 } from "@dxos/echo";
807
- import { EchoClient } from "@dxos/echo-db";
888
+ import { Database as Database2, Feed, JsonSchema as JsonSchema3, Ref as Ref5 } from "@dxos/echo";
889
+ import { refFromEncodedReference } from "@dxos/echo/internal";
890
+ import { EchoClient, createFeedServiceLayer } from "@dxos/echo-db";
891
+ import { runAndForwardErrors } from "@dxos/effect";
808
892
  import { assertState, failedInvariant as failedInvariant2, invariant as invariant2 } from "@dxos/invariant";
809
893
  import { PublicKey } from "@dxos/keys";
894
+
895
+ // src/protocol/functions-ai-http-client.ts
896
+ import * as Headers from "@effect/platform/Headers";
897
+ import * as HttpClient2 from "@effect/platform/HttpClient";
898
+ import * as HttpClientError from "@effect/platform/HttpClientError";
899
+ import * as HttpClientResponse from "@effect/platform/HttpClientResponse";
900
+ import * as Effect10 from "effect/Effect";
901
+ import * as FiberRef from "effect/FiberRef";
902
+ import * as Layer6 from "effect/Layer";
903
+ import * as Stream from "effect/Stream";
904
+ import { log as log3 } from "@dxos/log";
905
+ import { ErrorCodec } from "@dxos/protocols";
906
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/core/functions/src/protocol/functions-ai-http-client.ts";
907
+ var requestInitTagKey = "@effect/platform/FetchHttpClient/FetchOptions";
908
+ var FunctionsAiHttpClient = class _FunctionsAiHttpClient {
909
+ static make = (service) => HttpClient2.make((request, url, signal, fiber) => {
910
+ const context = fiber.getFiberRef(FiberRef.currentContext);
911
+ const options = context.unsafeMap.get(requestInitTagKey) ?? {};
912
+ const headers = options.headers ? Headers.merge(Headers.fromInput(options.headers), request.headers) : request.headers;
913
+ const send = (body) => Effect10.tryPromise({
914
+ try: () => service.fetch(new Request(url, {
915
+ ...options,
916
+ method: request.method,
917
+ headers,
918
+ body
919
+ })),
920
+ catch: (cause) => {
921
+ log3.error("Failed to fetch", {
922
+ errorSerialized: ErrorCodec.encode(cause)
923
+ }, {
924
+ F: __dxlog_file2,
925
+ L: 43,
926
+ S: this,
927
+ C: (f, a) => f(...a)
928
+ });
929
+ return new HttpClientError.RequestError({
930
+ request,
931
+ reason: "Transport",
932
+ cause
933
+ });
934
+ }
935
+ }).pipe(Effect10.map((response) => HttpClientResponse.fromWeb(request, response)));
936
+ switch (request.body._tag) {
937
+ case "Raw":
938
+ case "Uint8Array":
939
+ return send(request.body.body);
940
+ case "FormData":
941
+ return send(request.body.formData);
942
+ case "Stream":
943
+ return Stream.toReadableStreamEffect(request.body.stream).pipe(Effect10.flatMap(send));
944
+ }
945
+ return send(void 0);
946
+ });
947
+ static layer = (service) => Layer6.succeed(HttpClient2.HttpClient, _FunctionsAiHttpClient.make(service));
948
+ };
949
+
950
+ // src/protocol/protocol.ts
810
951
  function _ts_add_disposable_resource(env, value2, async) {
811
952
  if (value2 !== null && value2 !== void 0) {
812
953
  if (typeof value2 !== "object" && typeof value2 !== "function") throw new TypeError("Object expected.");
@@ -872,7 +1013,7 @@ function _ts_dispose_resources(env) {
872
1013
  return next();
873
1014
  })(env);
874
1015
  }
875
- var __dxlog_file2 = "/__w/dxos/dxos/packages/core/functions/src/protocol/protocol.ts";
1016
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/core/functions/src/protocol/protocol.ts";
876
1017
  var wrapFunctionHandler = (func) => {
877
1018
  if (!FunctionDefinition.isFunction(func)) {
878
1019
  throw new TypeError("Invalid function definition");
@@ -882,12 +1023,12 @@ var wrapFunctionHandler = (func) => {
882
1023
  key: func.key,
883
1024
  name: func.name,
884
1025
  description: func.description,
885
- inputSchema: Type7.toJsonSchema(func.inputSchema),
886
- outputSchema: func.outputSchema === void 0 ? void 0 : Type7.toJsonSchema(func.outputSchema),
1026
+ inputSchema: JsonSchema3.toJsonSchema(func.inputSchema),
1027
+ outputSchema: func.outputSchema === void 0 ? void 0 : JsonSchema3.toJsonSchema(func.outputSchema),
887
1028
  services: func.services
888
1029
  },
889
1030
  handler: async ({ data, context }) => {
890
- if ((func.services.includes(DatabaseService2.key) || func.services.includes(QueueService.key)) && (!context.services.dataService || !context.services.queryService)) {
1031
+ if ((func.services.includes(Database2.Service.key) || func.services.includes(QueueService.key) || func.services.includes(Feed.Service.key)) && (!context.services.dataService || !context.services.queryService)) {
891
1032
  throw new FunctionError({
892
1033
  message: "Services not provided: dataService, queryService"
893
1034
  });
@@ -912,23 +1053,24 @@ var wrapFunctionHandler = (func) => {
912
1053
  const funcContext = _ts_add_disposable_resource(env, await new FunctionContext(context).open(), true);
913
1054
  if (func.types.length > 0) {
914
1055
  invariant2(funcContext.db, "Database is required for functions with types", {
915
- F: __dxlog_file2,
916
- L: 63,
1056
+ F: __dxlog_file3,
1057
+ L: 70,
917
1058
  S: void 0,
918
1059
  A: [
919
1060
  "funcContext.db",
920
1061
  "'Database is required for functions with types'"
921
1062
  ]
922
1063
  });
923
- funcContext.db.graph.schemaRegistry.addSchema(func.types);
1064
+ await funcContext.db.graph.schemaRegistry.register(func.types);
924
1065
  }
1066
+ const dataWithDecodedRefs = funcContext.db && !SchemaAST2.isAnyKeyword(func.inputSchema.ast) ? decodeRefsFromSchema(func.inputSchema.ast, data, funcContext.db) : data;
925
1067
  let result = await func.handler({
926
1068
  // TODO(dmaretskyi): Fix the types.
927
1069
  context,
928
- data
1070
+ data: dataWithDecodedRefs
929
1071
  });
930
- if (Effect10.isEffect(result)) {
931
- result = await Effect10.runPromise(result.pipe(Effect10.orDie, Effect10.provide(funcContext.createLayer())));
1072
+ if (Effect11.isEffect(result)) {
1073
+ result = await runAndForwardErrors(result.pipe(Effect11.orDie, Effect11.provide(funcContext.createLayer())));
932
1074
  }
933
1075
  if (func.outputSchema && !SchemaAST2.isAnyKeyword(func.outputSchema.ast)) {
934
1076
  Schema10.validateSync(func.outputSchema)(result);
@@ -968,7 +1110,8 @@ var FunctionContext = class extends Resource {
968
1110
  this.db = this.client && this.context.spaceId ? this.client.constructDatabase({
969
1111
  spaceId: this.context.spaceId ?? failedInvariant2(),
970
1112
  spaceKey: PublicKey.fromHex(this.context.spaceKey ?? failedInvariant2("spaceKey missing in context")),
971
- reactiveSchemaQuery: false
1113
+ reactiveSchemaQuery: false,
1114
+ preloadSchemaOnOpen: false
972
1115
  }) : void 0;
973
1116
  await this.db?.setSpaceRoot(this.context.spaceRootUrl ?? failedInvariant2("spaceRootUrl missing in context"));
974
1117
  await this.db?.open();
@@ -980,18 +1123,88 @@ var FunctionContext = class extends Resource {
980
1123
  }
981
1124
  createLayer() {
982
1125
  assertState(this._lifecycleState === LifecycleState.OPEN, "FunctionContext is not open");
983
- const dbLayer = this.db ? DatabaseService2.layer(this.db) : DatabaseService2.notAvailable;
1126
+ const dbLayer = this.db ? Database2.layer(this.db) : Database2.notAvailable;
984
1127
  const queuesLayer = this.queues ? QueueService.layer(this.queues) : QueueService.notAvailable;
985
- const credentials = dbLayer ? CredentialsService.layerFromDatabase().pipe(Layer5.provide(dbLayer)) : CredentialsService.configuredLayer([]);
1128
+ const feedLayer = this.queues ? createFeedServiceLayer(this.queues) : Feed.notAvailable;
1129
+ const credentials = dbLayer ? CredentialsService.layerFromDatabase({
1130
+ caching: true
1131
+ }).pipe(Layer7.provide(dbLayer)) : CredentialsService.configuredLayer([]);
986
1132
  const functionInvocationService = MockedFunctionInvocationService;
987
- const aiService = AiService.notAvailable;
988
1133
  const tracing = TracingService.layerNoop;
989
- return Layer5.mergeAll(dbLayer, queuesLayer, credentials, functionInvocationService, aiService, tracing);
1134
+ const aiLayer = this.context.services.functionsAiService ? AiModelResolver.AiModelResolver.buildAiService.pipe(Layer7.provide(AnthropicResolver.make().pipe(Layer7.provide(AnthropicClient.layer({
1135
+ // Note: It doesn't matter what is base url here, it will be proxied to ai gateway in edge.
1136
+ apiUrl: "http://internal/provider/anthropic"
1137
+ }).pipe(Layer7.provide(FunctionsAiHttpClient.layer(this.context.services.functionsAiService))))))) : AiService.notAvailable;
1138
+ return Layer7.mergeAll(dbLayer, queuesLayer, feedLayer, credentials, functionInvocationService, aiLayer, tracing);
990
1139
  }
991
1140
  };
992
- var MockedFunctionInvocationService = Layer5.succeed(FunctionInvocationService, {
993
- invokeFunction: () => Effect10.die("Calling functions from functions is not implemented yet.")
1141
+ var MockedFunctionInvocationService = Layer7.succeed(FunctionInvocationService, {
1142
+ invokeFunction: () => Effect11.die("Calling functions from functions is not implemented yet."),
1143
+ resolveFunction: () => Effect11.die("Not implemented.")
994
1144
  });
1145
+ var decodeRefsFromSchema = (ast, value2, db) => {
1146
+ if (value2 == null) {
1147
+ return value2;
1148
+ }
1149
+ const encoded = SchemaAST2.encodedBoundAST(ast);
1150
+ if (Ref5.isRefType(encoded)) {
1151
+ if (Ref5.isRef(value2)) {
1152
+ return value2;
1153
+ }
1154
+ if (typeof value2 === "object" && value2 !== null && typeof value2["/"] === "string") {
1155
+ const resolver = db.graph.createRefResolver({
1156
+ context: {
1157
+ space: db.spaceId
1158
+ }
1159
+ });
1160
+ return refFromEncodedReference(value2, resolver);
1161
+ }
1162
+ return value2;
1163
+ }
1164
+ switch (encoded._tag) {
1165
+ case "TypeLiteral": {
1166
+ if (typeof value2 !== "object" || value2 === null || Array.isArray(value2)) {
1167
+ return value2;
1168
+ }
1169
+ const result = {
1170
+ ...value2
1171
+ };
1172
+ for (const prop of SchemaAST2.getPropertySignatures(encoded)) {
1173
+ const key = prop.name.toString();
1174
+ if (key in result) {
1175
+ result[key] = decodeRefsFromSchema(prop.type, result[key], db);
1176
+ }
1177
+ }
1178
+ return result;
1179
+ }
1180
+ case "TupleType": {
1181
+ if (!Array.isArray(value2)) {
1182
+ return value2;
1183
+ }
1184
+ if (encoded.elements.length === 0 && encoded.rest.length === 1) {
1185
+ const elementType = encoded.rest[0].type;
1186
+ return value2.map((item) => decodeRefsFromSchema(elementType, item, db));
1187
+ }
1188
+ return value2;
1189
+ }
1190
+ case "Union": {
1191
+ const nonUndefined = encoded.types.filter((t) => !SchemaAST2.isUndefinedKeyword(t));
1192
+ if (nonUndefined.length === 1) {
1193
+ return decodeRefsFromSchema(nonUndefined[0], value2, db);
1194
+ }
1195
+ return value2;
1196
+ }
1197
+ case "Suspend": {
1198
+ return decodeRefsFromSchema(encoded.f(), value2, db);
1199
+ }
1200
+ case "Refinement": {
1201
+ return decodeRefsFromSchema(encoded.from, value2, db);
1202
+ }
1203
+ default: {
1204
+ return value2;
1205
+ }
1206
+ }
1207
+ };
995
1208
  export {
996
1209
  ComputeEvent,
997
1210
  ComputeEventLogger,
@@ -999,8 +1212,7 @@ export {
999
1212
  ConfiguredCredentialsService,
1000
1213
  ContextQueueService,
1001
1214
  CredentialsService,
1002
- DatabaseService2 as DatabaseService,
1003
- Example,
1215
+ ExampleFunctions,
1004
1216
  FUNCTIONS_META_KEY,
1005
1217
  FUNCTIONS_PRESET_META_KEY,
1006
1218
  Function_exports as Function,
@@ -1024,6 +1236,7 @@ export {
1024
1236
  logCustomEvent,
1025
1237
  serializeFunction,
1026
1238
  setUserFunctionIdInMetadata,
1239
+ toOperation,
1027
1240
  withAuthorization,
1028
1241
  wrapFunctionHandler
1029
1242
  };