@dxos/functions 0.8.2-main.fbd8ed0 → 0.8.2-staging.42af850

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 (55) hide show
  1. package/dist/lib/browser/bundler/index.mjs.map +3 -3
  2. package/dist/lib/browser/index.mjs +175 -32
  3. package/dist/lib/browser/index.mjs.map +4 -4
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/node/bundler/index.cjs.map +3 -3
  6. package/dist/lib/node/index.cjs +167 -30
  7. package/dist/lib/node/index.cjs.map +4 -4
  8. package/dist/lib/node/meta.json +1 -1
  9. package/dist/lib/node-esm/bundler/index.mjs.map +3 -3
  10. package/dist/lib/node-esm/index.mjs +175 -32
  11. package/dist/lib/node-esm/index.mjs.map +4 -4
  12. package/dist/lib/node-esm/meta.json +1 -1
  13. package/dist/types/src/bundler/bundler.d.ts.map +1 -1
  14. package/dist/types/src/executor/executor.d.ts +8 -0
  15. package/dist/types/src/executor/executor.d.ts.map +1 -0
  16. package/dist/types/src/executor/index.d.ts +2 -0
  17. package/dist/types/src/executor/index.d.ts.map +1 -0
  18. package/dist/types/src/handler.d.ts +7 -3
  19. package/dist/types/src/handler.d.ts.map +1 -1
  20. package/dist/types/src/index.d.ts +2 -0
  21. package/dist/types/src/index.d.ts.map +1 -1
  22. package/dist/types/src/schema.d.ts.map +1 -1
  23. package/dist/types/src/services/ai.d.ts +9 -0
  24. package/dist/types/src/services/ai.d.ts.map +1 -0
  25. package/dist/types/src/services/credentials.d.ts +30 -0
  26. package/dist/types/src/services/credentials.d.ts.map +1 -0
  27. package/dist/types/src/services/database.d.ts +9 -0
  28. package/dist/types/src/services/database.d.ts.map +1 -0
  29. package/dist/types/src/services/index.d.ts +7 -0
  30. package/dist/types/src/services/index.d.ts.map +1 -0
  31. package/dist/types/src/services/queues.d.ts +10 -0
  32. package/dist/types/src/services/queues.d.ts.map +1 -0
  33. package/dist/types/src/services/service-container.d.ts +25 -0
  34. package/dist/types/src/services/service-container.d.ts.map +1 -0
  35. package/dist/types/src/services/tracing.d.ts +15 -0
  36. package/dist/types/src/services/tracing.d.ts.map +1 -0
  37. package/dist/types/src/trace.d.ts +9 -8
  38. package/dist/types/src/trace.d.ts.map +1 -1
  39. package/dist/types/src/types.d.ts.map +1 -1
  40. package/package.json +20 -20
  41. package/src/bundler/bundler.ts +7 -1
  42. package/src/executor/executor.ts +47 -0
  43. package/src/executor/index.ts +5 -0
  44. package/src/handler.ts +8 -3
  45. package/src/index.ts +4 -0
  46. package/src/schema.ts +8 -9
  47. package/src/services/ai.ts +15 -0
  48. package/src/services/credentials.ts +55 -0
  49. package/src/services/database.ts +14 -0
  50. package/src/services/index.ts +10 -0
  51. package/src/services/queues.ts +16 -0
  52. package/src/services/service-container.ts +58 -0
  53. package/src/services/tracing.ts +27 -0
  54. package/src/trace.ts +4 -4
  55. package/src/types.ts +17 -16
@@ -18,9 +18,14 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var node_exports = {};
20
20
  __export(node_exports, {
21
+ AiService: () => AiService,
22
+ ConfiguredCredentialsService: () => ConfiguredCredentialsService,
23
+ CredentialsService: () => CredentialsService,
24
+ DatabaseService: () => DatabaseService,
21
25
  EmailTriggerOutput: () => EmailTriggerOutput,
22
26
  FUNCTIONS_PRESET_META_KEY: () => FUNCTIONS_PRESET_META_KEY,
23
27
  FUNCTION_TYPES: () => FUNCTION_TYPES,
28
+ FunctionExecutor: () => FunctionExecutor,
24
29
  FunctionManifestSchema: () => FunctionManifestSchema,
25
30
  FunctionTrigger: () => FunctionTrigger,
26
31
  FunctionTriggerSchema: () => FunctionTriggerSchema,
@@ -30,12 +35,15 @@ __export(node_exports, {
30
35
  InvocationTraceEventType: () => InvocationTraceEventType,
31
36
  InvocationTraceStartEvent: () => InvocationTraceStartEvent,
32
37
  QueueTriggerOutput: () => QueueTriggerOutput,
38
+ QueuesService: () => QueuesService,
33
39
  ScriptType: () => ScriptType,
40
+ ServiceContainer: () => ServiceContainer,
34
41
  SubscriptionTriggerOutput: () => SubscriptionTriggerOutput,
35
42
  TimerTriggerOutput: () => TimerTriggerOutput,
36
43
  TraceEvent: () => TraceEvent,
37
44
  TraceEventException: () => TraceEventException,
38
45
  TraceEventLog: () => TraceEventLog,
46
+ TracingService: () => TracingService,
39
47
  TriggerKind: () => TriggerKind,
40
48
  TriggerSchema: () => TriggerSchema,
41
49
  WebhookTriggerOutput: () => WebhookTriggerOutput,
@@ -52,10 +60,18 @@ var import_effect2 = require("effect");
52
60
  var import_echo_schema = require("@dxos/echo-schema");
53
61
  var import_schema = require("@dxos/schema");
54
62
  var import_effect3 = require("effect");
63
+ var import_echo_db = require("@dxos/echo-db");
55
64
  var import_echo_schema2 = require("@dxos/echo-schema");
56
65
  var import_log = require("@dxos/log");
57
66
  var import_effect4 = require("effect");
58
67
  var import_echo_schema3 = require("@dxos/echo-schema");
68
+ var import_keys = require("@dxos/keys");
69
+ var import_effect5 = require("effect");
70
+ var import_effect6 = require("effect");
71
+ var import_effect7 = require("effect");
72
+ var import_effect8 = require("effect");
73
+ var import_effect9 = require("effect");
74
+ var import_effect10 = require("effect");
59
75
  var defineFunction = (params) => {
60
76
  if (!import_effect.Schema.isSchema(params.inputSchema)) {
61
77
  throw new Error("Input schema must be a valid schema");
@@ -77,12 +93,12 @@ var ScriptType = import_effect2.Schema.Struct({
77
93
  // Whether source has changed since last deploy.
78
94
  changed: import_effect2.Schema.optional(import_effect2.Schema.Boolean),
79
95
  source: (0, import_echo_schema.Ref)(import_schema.DataType.Text)
80
- }).annotations({
81
- [import_echo_schema.LabelAnnotationId]: "name"
82
96
  }).pipe((0, import_echo_schema.EchoObject)({
83
97
  typename: "dxos.org/type/Script",
84
98
  version: "0.1.0"
85
- }));
99
+ }), import_echo_schema.LabelAnnotation.set([
100
+ "name"
101
+ ]));
86
102
  var FunctionType = class extends (0, import_echo_schema.TypedObject)({
87
103
  typename: "dxos.org/type/Function",
88
104
  version: "0.1.0"
@@ -100,21 +116,21 @@ var FunctionType = class extends (0, import_echo_schema.TypedObject)({
100
116
  binding: import_effect2.Schema.optional(import_effect2.Schema.String)
101
117
  }) {
102
118
  };
103
- var TriggerKind;
104
- (function(TriggerKind2) {
119
+ var TriggerKind = /* @__PURE__ */ function(TriggerKind2) {
105
120
  TriggerKind2["Timer"] = "timer";
106
121
  TriggerKind2["Webhook"] = "webhook";
107
122
  TriggerKind2["Subscription"] = "subscription";
108
123
  TriggerKind2["Email"] = "email";
109
124
  TriggerKind2["Queue"] = "queue";
110
- })(TriggerKind || (TriggerKind = {}));
125
+ return TriggerKind2;
126
+ }({});
111
127
  var kindLiteralAnnotations = {
112
- [import_effect4.SchemaAST.TitleAnnotationId]: "Kind"
128
+ title: "Kind"
113
129
  };
114
130
  var TimerTriggerSchema = import_effect4.Schema.Struct({
115
131
  kind: import_effect4.Schema.Literal("timer").annotations(kindLiteralAnnotations),
116
132
  cron: import_effect4.Schema.String.annotations({
117
- [import_effect4.SchemaAST.TitleAnnotationId]: "Cron",
133
+ title: "Cron",
118
134
  [import_effect4.SchemaAST.ExamplesAnnotationId]: [
119
135
  "0 0 * * *"
120
136
  ]
@@ -125,31 +141,31 @@ var EmailTriggerSchema = import_effect4.Schema.Struct({
125
141
  }).pipe(import_effect4.Schema.mutable);
126
142
  var QueueTriggerSchema = import_effect4.Schema.Struct({
127
143
  kind: import_effect4.Schema.Literal("queue").annotations(kindLiteralAnnotations),
128
- queue: import_echo_schema3.DXN
144
+ queue: import_keys.DXN.Schema
129
145
  }).pipe(import_effect4.Schema.mutable);
130
146
  var WebhookTriggerSchema = import_effect4.Schema.Struct({
131
147
  kind: import_effect4.Schema.Literal("webhook").annotations(kindLiteralAnnotations),
132
148
  method: import_effect4.Schema.optional(import_effect4.Schema.String.annotations({
133
- [import_effect4.SchemaAST.TitleAnnotationId]: "Method",
149
+ title: "Method",
134
150
  [import_echo_schema3.OptionsAnnotationId]: [
135
151
  "GET",
136
152
  "POST"
137
153
  ]
138
154
  })),
139
155
  port: import_effect4.Schema.optional(import_effect4.Schema.Number.annotations({
140
- [import_effect4.SchemaAST.TitleAnnotationId]: "Port"
156
+ title: "Port"
141
157
  }))
142
158
  }).pipe(import_effect4.Schema.mutable);
143
159
  var QuerySchema = import_effect4.Schema.Struct({
144
160
  type: import_effect4.Schema.optional(import_effect4.Schema.String.annotations({
145
- [import_effect4.SchemaAST.TitleAnnotationId]: "Type"
161
+ title: "Type"
146
162
  })),
147
163
  props: import_effect4.Schema.optional(import_effect4.Schema.Record({
148
164
  key: import_effect4.Schema.String,
149
165
  value: import_effect4.Schema.Any
150
166
  }))
151
167
  }).annotations({
152
- [import_effect4.SchemaAST.TitleAnnotationId]: "Query"
168
+ title: "Query"
153
169
  });
154
170
  var SubscriptionTriggerSchema = import_effect4.Schema.Struct({
155
171
  kind: import_effect4.Schema.Literal("subscription").annotations(kindLiteralAnnotations),
@@ -158,18 +174,18 @@ var SubscriptionTriggerSchema = import_effect4.Schema.Struct({
158
174
  options: import_effect4.Schema.optional(import_effect4.Schema.Struct({
159
175
  // Watch changes to object (not just creation).
160
176
  deep: import_effect4.Schema.optional(import_effect4.Schema.Boolean.annotations({
161
- [import_effect4.SchemaAST.TitleAnnotationId]: "Nested"
177
+ title: "Nested"
162
178
  })),
163
179
  // Debounce changes (delay in ms).
164
180
  delay: import_effect4.Schema.optional(import_effect4.Schema.Number.annotations({
165
- [import_effect4.SchemaAST.TitleAnnotationId]: "Delay"
181
+ title: "Delay"
166
182
  }))
167
183
  }).annotations({
168
- [import_effect4.SchemaAST.TitleAnnotationId]: "Options"
184
+ title: "Options"
169
185
  }))
170
186
  }).pipe(import_effect4.Schema.mutable);
171
187
  var TriggerSchema = import_effect4.Schema.Union(TimerTriggerSchema, WebhookTriggerSchema, SubscriptionTriggerSchema, EmailTriggerSchema, QueueTriggerSchema).annotations({
172
- [import_effect4.SchemaAST.TitleAnnotationId]: "Trigger"
188
+ title: "Trigger"
173
189
  });
174
190
  var EmailTriggerOutput = import_effect4.Schema.mutable(import_effect4.Schema.Struct({
175
191
  from: import_effect4.Schema.String,
@@ -188,7 +204,7 @@ var WebhookTriggerOutput = import_effect4.Schema.mutable(import_effect4.Schema.S
188
204
  bodyText: import_effect4.Schema.String
189
205
  }));
190
206
  var QueueTriggerOutput = import_effect4.Schema.mutable(import_effect4.Schema.Struct({
191
- queue: import_echo_schema3.DXN,
207
+ queue: import_keys.DXN.Schema,
192
208
  item: import_effect4.Schema.Any,
193
209
  cursor: import_effect4.Schema.String
194
210
  }));
@@ -205,7 +221,7 @@ var FunctionTriggerSchema = import_effect4.Schema.Struct({
205
221
  */
206
222
  // TODO(dmaretskyi): Can be a Ref(FunctionType) or Ref(ComputeGraphType).
207
223
  function: import_effect4.Schema.optional((0, import_echo_schema3.Ref)(import_echo_schema3.Expando).annotations({
208
- [import_effect4.SchemaAST.TitleAnnotationId]: "Function"
224
+ title: "Function"
209
225
  })),
210
226
  /**
211
227
  * Only used for workflowSchema.
@@ -213,10 +229,10 @@ var FunctionTriggerSchema = import_effect4.Schema.Struct({
213
229
  * @deprecated Remove and enforce a single input node in all compute graphSchema.
214
230
  */
215
231
  inputNodeId: import_effect4.Schema.optional(import_effect4.Schema.String.annotations({
216
- [import_effect4.SchemaAST.TitleAnnotationId]: "Input Node ID"
232
+ title: "Input Node ID"
217
233
  })),
218
234
  enabled: import_effect4.Schema.optional(import_effect4.Schema.Boolean.annotations({
219
- [import_effect4.SchemaAST.TitleAnnotationId]: "Enabled"
235
+ title: "Enabled"
220
236
  })),
221
237
  spec: import_effect4.Schema.optional(TriggerSchema),
222
238
  /**
@@ -249,17 +265,17 @@ var FUNCTION_TYPES = [
249
265
  FunctionTrigger
250
266
  ];
251
267
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/functions/src/trace.ts";
252
- var InvocationOutcome;
253
- (function(InvocationOutcome2) {
268
+ var InvocationOutcome = /* @__PURE__ */ function(InvocationOutcome2) {
254
269
  InvocationOutcome2["SUCCESS"] = "success";
255
270
  InvocationOutcome2["FAILURE"] = "failure";
256
271
  InvocationOutcome2["PENDING"] = "pending";
257
- })(InvocationOutcome || (InvocationOutcome = {}));
258
- var InvocationTraceEventType;
259
- (function(InvocationTraceEventType2) {
272
+ return InvocationOutcome2;
273
+ }({});
274
+ var InvocationTraceEventType = /* @__PURE__ */ function(InvocationTraceEventType2) {
260
275
  InvocationTraceEventType2["START"] = "start";
261
276
  InvocationTraceEventType2["END"] = "end";
262
- })(InvocationTraceEventType || (InvocationTraceEventType = {}));
277
+ return InvocationTraceEventType2;
278
+ }({});
263
279
  var TraceEventException = import_effect3.Schema.Struct({
264
280
  timestampMs: import_effect3.Schema.Number,
265
281
  message: import_effect3.Schema.String,
@@ -286,10 +302,9 @@ var InvocationTraceStartEvent = import_effect3.Schema.Struct({
286
302
  // TODO(burdon): Input schema?
287
303
  input: import_effect3.Schema.Object,
288
304
  /**
289
- * Queue DXN for function/workflow invocation events.
305
+ * Queue for function/workflow invocation events.
290
306
  */
291
- // TODO(burdon): Need reference type for queue. vs. string?
292
- invocationTraceQueue: (0, import_echo_schema2.Ref)(import_echo_schema2.Expando),
307
+ invocationTraceQueue: (0, import_echo_schema2.Ref)(import_echo_db.Queue),
293
308
  /**
294
309
  * DXN of the invoked function/workflow.
295
310
  */
@@ -425,11 +440,130 @@ var getInvocationUrl = (functionUrl, edgeUrl, options = {}) => {
425
440
  url.protocol = isSecure(url.protocol) ? "https" : "http";
426
441
  return url.toString();
427
442
  };
443
+ var AiService = class extends import_effect5.Context.Tag("AiService")() {
444
+ };
445
+ var DatabaseService = class extends import_effect6.Context.Tag("DatabaseService")() {
446
+ };
447
+ var QueuesService = class extends import_effect7.Context.Tag("QueuesService")() {
448
+ };
449
+ var CredentialsService = class extends import_effect8.Context.Tag("CredentialsService")() {
450
+ };
451
+ var ConfiguredCredentialsService = class {
452
+ constructor(credentials = []) {
453
+ this.credentials = credentials;
454
+ }
455
+ addCredentials(credentials) {
456
+ this.credentials.push(...credentials);
457
+ return this;
458
+ }
459
+ async queryCredentials(query) {
460
+ return this.credentials.filter((credential) => credential.service === query.service);
461
+ }
462
+ async getCredential(query) {
463
+ const credential = this.credentials.find((credential2) => credential2.service === query.service);
464
+ if (!credential) {
465
+ throw new Error(`Credential not found for service: ${query.service}`);
466
+ }
467
+ return credential;
468
+ }
469
+ };
470
+ var TracingService = class extends import_effect9.Context.Tag("TracingService")() {
471
+ static {
472
+ this.noop = {
473
+ write: () => {
474
+ }
475
+ };
476
+ }
477
+ static {
478
+ this.console = {
479
+ write: (event) => {
480
+ console.log(event);
481
+ }
482
+ };
483
+ }
484
+ };
485
+ var SERVICE_MAPPING = {
486
+ [DatabaseService.key]: "database",
487
+ [AiService.key]: "ai",
488
+ [QueuesService.key]: "queues",
489
+ [CredentialsService.key]: "credentials",
490
+ [TracingService.key]: "tracing"
491
+ };
492
+ var DEFAULT_SERVICES = {
493
+ tracing: TracingService.noop
494
+ };
495
+ var ServiceContainer = class _ServiceContainer {
496
+ constructor() {
497
+ this._services = {
498
+ ...DEFAULT_SERVICES
499
+ };
500
+ }
501
+ /**
502
+ * Set services.
503
+ * @param services - Services to set.
504
+ * @returns The container instance.
505
+ */
506
+ setServices(services) {
507
+ this._services = {
508
+ ...this._services,
509
+ ...services
510
+ };
511
+ return this;
512
+ }
513
+ getService(tag) {
514
+ const serviceKey = SERVICE_MAPPING[tag.key];
515
+ const service = serviceKey != null ? this._services[serviceKey] : void 0;
516
+ if (!service) {
517
+ throw new Error(`Service not available: ${tag.key}`);
518
+ }
519
+ return service;
520
+ }
521
+ clone() {
522
+ return new _ServiceContainer().setServices({
523
+ ...this._services
524
+ });
525
+ }
526
+ };
527
+ var FunctionExecutor = class {
528
+ constructor(_services) {
529
+ this._services = _services;
530
+ }
531
+ // TODO(dmaretskyi): Invocation context: queue, space, etc...
532
+ async invoke(fnDef, input) {
533
+ const assertInput = fnDef.inputSchema.pipe(import_effect10.Schema.asserts);
534
+ assertInput(input);
535
+ const context = {
536
+ getService: this._services.getService.bind(this._services),
537
+ getSpace: async (_spaceId) => {
538
+ throw new Error("Not available. Use the database service instead.");
539
+ },
540
+ space: void 0,
541
+ get ai() {
542
+ throw new Error("Not available. Use the ai service instead.");
543
+ }
544
+ };
545
+ const result = await fnDef.handler({
546
+ context,
547
+ data: input
548
+ });
549
+ const assertOutput = fnDef.outputSchema?.pipe(import_effect10.Schema.asserts);
550
+ assertOutput(result);
551
+ if (import_effect10.Effect.isEffect(result)) {
552
+ return import_effect10.Effect.runPromise(result);
553
+ }
554
+ return result;
555
+ }
556
+ };
428
557
  // Annotate the CommonJS export names for ESM import in node:
429
558
  0 && (module.exports = {
559
+ AiService,
560
+ ConfiguredCredentialsService,
561
+ CredentialsService,
562
+ DatabaseService,
430
563
  EmailTriggerOutput,
431
564
  FUNCTIONS_PRESET_META_KEY,
432
565
  FUNCTION_TYPES,
566
+ FunctionExecutor,
433
567
  FunctionManifestSchema,
434
568
  FunctionTrigger,
435
569
  FunctionTriggerSchema,
@@ -439,12 +573,15 @@ var getInvocationUrl = (functionUrl, edgeUrl, options = {}) => {
439
573
  InvocationTraceEventType,
440
574
  InvocationTraceStartEvent,
441
575
  QueueTriggerOutput,
576
+ QueuesService,
442
577
  ScriptType,
578
+ ServiceContainer,
443
579
  SubscriptionTriggerOutput,
444
580
  TimerTriggerOutput,
445
581
  TraceEvent,
446
582
  TraceEventException,
447
583
  TraceEventLog,
584
+ TracingService,
448
585
  TriggerKind,
449
586
  TriggerSchema,
450
587
  WebhookTriggerOutput,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/handler.ts", "../../../src/schema.ts", "../../../src/trace.ts", "../../../src/types.ts", "../../../src/url.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Schema } from 'effect';\nimport { type Effect } from 'effect';\n\nimport { type AIServiceClient } from '@dxos/assistant';\n// import { type Space } from '@dxos/client/echo';\nimport type { CoreDatabase, EchoDatabase } from '@dxos/echo-db';\nimport { type HasId } from '@dxos/echo-schema';\nimport { type SpaceId, type DXN } from '@dxos/keys';\nimport { type QueryResult } from '@dxos/protocols';\n\n// TODO(burdon): Model after http request. Ref Lambda/OpenFaaS.\n// https://docs.aws.amazon.com/lambda/latest/dg/typescript-handler.html\n// https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml/#functions\n// https://www.npmjs.com/package/aws-lambda\n\n/**\n * Function handler.\n */\nexport type FunctionHandler<TData = {}, TOutput = any> = (params: {\n /**\n * Services and context available to the function.\n */\n context: FunctionContext;\n\n /**\n * Data passed as the input to the function.\n * Must match the function's input schema.\n * This will be the payload from the trigger or other data passed into the function in a workflow.\n */\n data: TData;\n}) => TOutput | Promise<TOutput> | Effect.Effect<TOutput, any>;\n\n/**\n * Function context.\n */\nexport interface FunctionContext {\n getSpace: (spaceId: SpaceId) => Promise<SpaceAPI>;\n\n /**\n * Space from which the function was invoked.\n */\n space: SpaceAPI | undefined;\n\n ai: AIServiceClient;\n}\n\nexport interface FunctionContextAi {\n // TODO(dmaretskyi): Refer to cloudflare AI docs for more comprehensive typedefs.\n run(model: string, inputs: any, options?: any): Promise<any>;\n}\n\n//\n// API.\n//\n\n// TODO(dmaretskyi): Temporary API to get the queues working.\n// TODO(dmaretskyi): To be replaced with integrating queues into echo.\nexport interface QueuesAPI {\n queryQueue(queue: DXN, options?: {}): Promise<QueryResult>;\n insertIntoQueue(queue: DXN, objects: HasId[]): Promise<void>;\n}\n\n/**\n * Space interface available to functions.\n */\nexport interface SpaceAPI {\n get id(): SpaceId;\n /**\n * @deprecated\n */\n get crud(): CoreDatabase;\n get db(): EchoDatabase;\n // TODO(dmaretskyi): Align with echo api --- queues.get(id).append(items);\n get queues(): QueuesAPI;\n}\n\n// TODO(wittjosiah): Queues are incompatible.\nconst __assertFunctionSpaceIsCompatibleWithTheClientSpace = () => {\n // const _: SpaceAPI = {} as Space;\n};\n\nexport type FunctionDefinition<T = {}, O = any> = {\n description?: string;\n inputSchema: Schema.Schema<T, any>;\n outputSchema?: Schema.Schema<O, any>;\n handler: FunctionHandler<T, O>;\n};\n\n// TODO(dmaretskyi): Bind input type to function handler.\nexport const defineFunction = <T, O>(params: FunctionDefinition<T, O>): FunctionDefinition<T, O> => {\n if (!Schema.isSchema(params.inputSchema)) {\n throw new Error('Input schema must be a valid schema');\n }\n if (typeof params.handler !== 'function') {\n throw new Error('Handler must be a function');\n }\n\n return {\n description: params.description,\n inputSchema: params.inputSchema,\n outputSchema: params.outputSchema ?? Schema.Any,\n handler: params.handler,\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { EchoObject, JsonSchemaType, LabelAnnotationId, Ref, TypedObject } from '@dxos/echo-schema';\nimport { DataType } from '@dxos/schema';\n\n/**\n * Source script.\n */\nexport const ScriptType = Schema.Struct({\n name: Schema.optional(Schema.String),\n description: Schema.optional(Schema.String),\n // TODO(burdon): Change to hash of deployed content.\n // Whether source has changed since last deploy.\n changed: Schema.optional(Schema.Boolean),\n source: Ref(DataType.Text),\n})\n .annotations({ [LabelAnnotationId]: 'name' })\n .pipe(\n EchoObject({\n typename: 'dxos.org/type/Script',\n version: '0.1.0',\n }),\n );\n\nexport type ScriptType = Schema.Schema.Type<typeof ScriptType>;\n\n/**\n * Function deployment.\n */\nexport class FunctionType extends TypedObject({\n typename: 'dxos.org/type/Function',\n version: '0.1.0',\n})({\n // TODO(burdon): Rename to id/uri?\n name: Schema.NonEmptyString,\n version: Schema.String,\n\n description: Schema.optional(Schema.String),\n\n // Reference to a source script if it exists within ECHO.\n // TODO(burdon): Don't ref ScriptType directly (core).\n source: Schema.optional(Ref(ScriptType)),\n\n inputSchema: Schema.optional(JsonSchemaType),\n outputSchema: Schema.optional(JsonSchemaType),\n\n // Local binding to a function name.\n binding: Schema.optional(Schema.String),\n}) {}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { EchoObject, Expando, ObjectId, Ref } from '@dxos/echo-schema';\nimport { log } from '@dxos/log';\n\nimport { FunctionTrigger, type FunctionTriggerType } from './types';\n\nexport enum InvocationOutcome {\n SUCCESS = 'success',\n FAILURE = 'failure',\n PENDING = 'pending',\n}\n\n// TODO(burdon): Convert to extensible discriminated union of EDGE events.\nexport enum InvocationTraceEventType {\n START = 'start',\n END = 'end',\n}\n\nexport const TraceEventException = Schema.Struct({\n timestampMs: Schema.Number,\n message: Schema.String,\n name: Schema.String,\n stack: Schema.optional(Schema.String),\n});\nexport type TraceEventException = Schema.Schema.Type<typeof TraceEventException>;\n\nexport const InvocationTraceStartEvent = Schema.Struct({\n /**\n * Queue message id.\n */\n id: ObjectId,\n type: Schema.Literal(InvocationTraceEventType.START),\n /**\n * Invocation id, the same for invocation start and end events.\n */\n invocationId: ObjectId,\n /**\n * Event generation time.\n */\n timestampMs: Schema.Number,\n /**\n * Data passed to function / workflow as an argument.\n */\n // TODO(burdon): Input schema?\n input: Schema.Object,\n /**\n * Queue DXN for function/workflow invocation events.\n */\n // TODO(burdon): Need reference type for queue. vs. string?\n invocationTraceQueue: Ref(Expando),\n /**\n * DXN of the invoked function/workflow.\n */\n invocationTarget: Ref(Expando),\n /**\n * Present for automatic invocations.\n */\n trigger: Schema.optional(Ref(FunctionTrigger)),\n}).pipe(EchoObject({ typename: 'dxos.org/type/InvocationTraceStart', version: '0.1.0' }));\n\nexport type InvocationTraceStartEvent = Schema.Schema.Type<typeof InvocationTraceStartEvent>;\n\nexport const InvocationTraceEndEvent = Schema.Struct({\n /**\n * Trace event id.\n */\n id: ObjectId,\n type: Schema.Literal(InvocationTraceEventType.END),\n /**\n * Invocation id, will be the same for invocation start and end.\n */\n invocationId: ObjectId,\n /**\n * Event generation time.\n */\n // TODO(burdon): Remove ms suffix.\n timestampMs: Schema.Number,\n outcome: Schema.Enums(InvocationOutcome),\n exception: Schema.optional(TraceEventException),\n}).pipe(EchoObject({ typename: 'dxos.org/type/InvocationTraceEnd', version: '0.1.0' }));\n\nexport type InvocationTraceEndEvent = Schema.Schema.Type<typeof InvocationTraceEndEvent>;\n\nexport type InvocationTraceEvent = InvocationTraceStartEvent | InvocationTraceEndEvent;\n\nexport const TraceEventLog = Schema.Struct({\n timestampMs: Schema.Number,\n level: Schema.String,\n message: Schema.String,\n context: Schema.optional(Schema.Object),\n});\n\nexport const TraceEvent = Schema.Struct({\n id: ObjectId,\n // TODO(burdon): Need enum/numeric result (not string).\n outcome: Schema.String,\n truncated: Schema.Boolean,\n /**\n * Time when the event was persisted.\n */\n ingestionTimestampMs: Schema.Number,\n logs: Schema.Array(TraceEventLog),\n exceptions: Schema.Array(TraceEventException),\n}).pipe(EchoObject({ typename: 'dxos.org/type/TraceEvent', version: '0.1.0' }));\n\nexport type TraceEvent = Schema.Schema.Type<typeof TraceEvent>;\n\n/**\n * Deprecated InvocationTrace event format.\n * @deprecated\n */\n// TODO(burdon): Remove.\nexport type InvocationSpan = {\n id: string;\n timestampMs: number;\n outcome: InvocationOutcome;\n input: object;\n durationMs: number;\n invocationTraceQueue: Ref<Expando>;\n invocationTarget: Ref<Expando>;\n trigger?: Ref<FunctionTriggerType>;\n exception?: TraceEventException;\n};\n\nexport const createInvocationSpans = (items?: InvocationTraceEvent[]): InvocationSpan[] => {\n if (!items) {\n return [];\n }\n\n const eventsByInvocationId = new Map<string, { start?: InvocationTraceStartEvent; end?: InvocationTraceEndEvent }>();\n for (const event of items) {\n if (!('invocationId' in event)) {\n // Skip legacy format entries.\n continue;\n }\n\n const invocationId = event.invocationId;\n const entry = eventsByInvocationId.get(invocationId) || { start: undefined, end: undefined };\n if (event.type === InvocationTraceEventType.START) {\n entry.start = event as InvocationTraceStartEvent;\n } else if (event.type === InvocationTraceEventType.END) {\n entry.end = event as InvocationTraceEndEvent;\n }\n\n eventsByInvocationId.set(invocationId, entry);\n }\n\n const now = Date.now();\n const result: InvocationSpan[] = [];\n\n // Create spans for each invocation\n for (const [invocationId, { start, end }] of eventsByInvocationId.entries()) {\n if (!start) {\n // No start event, can't create a meaningful span\n log.warn('found end event without matching start', { invocationId });\n continue;\n }\n\n const isInProgress = end === undefined;\n\n result.push({\n id: invocationId,\n timestampMs: start.timestampMs,\n durationMs: isInProgress ? now - start.timestampMs : end!.timestampMs - start.timestampMs,\n outcome: end?.outcome ?? InvocationOutcome.PENDING,\n exception: end?.exception,\n input: start.input,\n invocationTraceQueue: start.invocationTraceQueue,\n invocationTarget: start.invocationTarget,\n trigger: start.trigger,\n });\n }\n\n return result;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { Schema, SchemaAST } from 'effect';\n\nimport { Expando, OptionsAnnotationId, TypedObject, DXN, Ref, RawObject } from '@dxos/echo-schema';\n\nimport { FunctionType } from './schema';\n\n/**\n * Type discriminator for TriggerType.\n * Every spec has a type field of type TriggerKind that we can use to understand which type we're working with.\n * https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions\n */\nexport enum TriggerKind {\n Timer = 'timer',\n Webhook = 'webhook',\n Subscription = 'subscription',\n Email = 'email',\n Queue = 'queue',\n}\n\nconst kindLiteralAnnotations = { [SchemaAST.TitleAnnotationId]: 'Kind' };\n\n/**\n * Cron timer.\n */\nconst TimerTriggerSchema = Schema.Struct({\n kind: Schema.Literal(TriggerKind.Timer).annotations(kindLiteralAnnotations),\n cron: Schema.String.annotations({\n [SchemaAST.TitleAnnotationId]: 'Cron',\n [SchemaAST.ExamplesAnnotationId]: ['0 0 * * *'],\n }),\n}).pipe(Schema.mutable);\nexport type TimerTrigger = Schema.Schema.Type<typeof TimerTriggerSchema>;\n\nconst EmailTriggerSchema = Schema.Struct({\n kind: Schema.Literal(TriggerKind.Email).annotations(kindLiteralAnnotations),\n}).pipe(Schema.mutable);\nexport type EmailTrigger = Schema.Schema.Type<typeof EmailTriggerSchema>;\n\nconst QueueTriggerSchema = Schema.Struct({\n kind: Schema.Literal(TriggerKind.Queue).annotations(kindLiteralAnnotations),\n queue: DXN,\n}).pipe(Schema.mutable);\nexport type QueueTrigger = Schema.Schema.Type<typeof QueueTriggerSchema>;\n\n/**\n * Webhook.\n */\nconst WebhookTriggerSchema = Schema.Struct({\n kind: Schema.Literal(TriggerKind.Webhook).annotations(kindLiteralAnnotations),\n method: Schema.optional(\n Schema.String.annotations({\n [SchemaAST.TitleAnnotationId]: 'Method',\n [OptionsAnnotationId]: ['GET', 'POST'],\n }),\n ),\n port: Schema.optional(\n Schema.Number.annotations({\n [SchemaAST.TitleAnnotationId]: 'Port',\n }),\n ),\n}).pipe(Schema.mutable);\nexport type WebhookTrigger = Schema.Schema.Type<typeof WebhookTriggerSchema>;\n\n// TODO(burdon): Use ECHO definition (from https://github.com/dxos/dxos/pull/8233).\nconst QuerySchema = Schema.Struct({\n type: Schema.optional(Schema.String.annotations({ [SchemaAST.TitleAnnotationId]: 'Type' })),\n props: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),\n}).annotations({ [SchemaAST.TitleAnnotationId]: 'Query' });\n\n/**\n * Subscription.\n */\nconst SubscriptionTriggerSchema = Schema.Struct({\n kind: Schema.Literal(TriggerKind.Subscription).annotations(kindLiteralAnnotations),\n // TODO(burdon): Define query DSL (from ECHO). Reconcile with Table.Query.\n filter: QuerySchema,\n options: Schema.optional(\n Schema.Struct({\n // Watch changes to object (not just creation).\n deep: Schema.optional(Schema.Boolean.annotations({ [SchemaAST.TitleAnnotationId]: 'Nested' })),\n // Debounce changes (delay in ms).\n delay: Schema.optional(Schema.Number.annotations({ [SchemaAST.TitleAnnotationId]: 'Delay' })),\n }).annotations({ [SchemaAST.TitleAnnotationId]: 'Options' }),\n ),\n}).pipe(Schema.mutable);\nexport type SubscriptionTrigger = Schema.Schema.Type<typeof SubscriptionTriggerSchema>;\n\n/**\n * Trigger schema (discriminated union).\n */\nexport const TriggerSchema = Schema.Union(\n TimerTriggerSchema,\n WebhookTriggerSchema,\n SubscriptionTriggerSchema,\n EmailTriggerSchema,\n QueueTriggerSchema,\n).annotations({\n [SchemaAST.TitleAnnotationId]: 'Trigger',\n});\nexport type TriggerType = Schema.Schema.Type<typeof TriggerSchema>;\n\nexport type EventType =\n | EmailTriggerOutput\n | WebhookTriggerOutput\n | QueueTriggerOutput\n | SubscriptionTriggerOutput\n | TimerTriggerOutput;\n\n// TODO(burdon): Reuse trigger schema from @dxos/functions (TriggerType).\nexport const EmailTriggerOutput = Schema.mutable(\n Schema.Struct({\n from: Schema.String,\n to: Schema.String,\n subject: Schema.String,\n created: Schema.String,\n body: Schema.String,\n }),\n);\nexport type EmailTriggerOutput = Schema.Schema.Type<typeof EmailTriggerOutput>;\n\nexport const WebhookTriggerOutput = Schema.mutable(\n Schema.Struct({\n url: Schema.String,\n method: Schema.Literal('GET', 'POST'),\n headers: Schema.Record({ key: Schema.String, value: Schema.String }),\n bodyText: Schema.String,\n }),\n);\nexport type WebhookTriggerOutput = Schema.Schema.Type<typeof WebhookTriggerOutput>;\n\nexport const QueueTriggerOutput = Schema.mutable(\n Schema.Struct({\n queue: DXN,\n item: Schema.Any,\n cursor: Schema.String,\n }),\n);\nexport type QueueTriggerOutput = Schema.Schema.Type<typeof QueueTriggerOutput>;\n\nexport const SubscriptionTriggerOutput = Schema.mutable(\n Schema.Struct({ type: Schema.String, changedObjectId: Schema.String }),\n);\nexport type SubscriptionTriggerOutput = Schema.Schema.Type<typeof SubscriptionTriggerOutput>;\n\nexport const TimerTriggerOutput = Schema.mutable(Schema.Struct({ tick: Schema.Number }));\nexport type TimerTriggerOutput = Schema.Schema.Type<typeof TimerTriggerOutput>;\n\n/**\n * Function trigger.\n * Function is invoked with the `payload` passed as input data.\n * The event that triggers the function is available in the function context.\n */\nexport const FunctionTriggerSchema = Schema.Struct({\n /**\n * Function or workflow to invoke.\n */\n // TODO(dmaretskyi): Can be a Ref(FunctionType) or Ref(ComputeGraphType).\n function: Schema.optional(Ref(Expando).annotations({ [SchemaAST.TitleAnnotationId]: 'Function' })),\n\n /**\n * Only used for workflowSchema.\n * Specifies the input node in the circuit.\n * @deprecated Remove and enforce a single input node in all compute graphSchema.\n */\n inputNodeId: Schema.optional(Schema.String.annotations({ [SchemaAST.TitleAnnotationId]: 'Input Node ID' })),\n\n enabled: Schema.optional(Schema.Boolean.annotations({ [SchemaAST.TitleAnnotationId]: 'Enabled' })),\n\n spec: Schema.optional(TriggerSchema),\n\n /**\n * Passed as the input data to the function.\n * Must match the function's input schema.\n *\n * @example\n * {\n * item: '{{$.trigger.event}}',\n * instructions: 'Summarize and perform entity-extraction'\n * mailbox: { '/': 'dxn:echo:AAA:ZZZ' }\n * }\n */\n input: Schema.optional(Schema.mutable(Schema.Record({ key: Schema.String, value: Schema.Any }))),\n});\n\nexport type FunctionTriggerType = Schema.Schema.Type<typeof FunctionTriggerSchema>;\n\n/**\n * Function trigger.\n */\nexport class FunctionTrigger extends TypedObject({\n typename: 'dxos.org/type/FunctionTrigger',\n version: '0.2.0',\n})(FunctionTriggerSchema.fields) {}\n\n// TODO(wittjosiah): Remove?\n\n/**\n * Function manifest file.\n */\nexport const FunctionManifestSchema = Schema.Struct({\n functions: Schema.optional(Schema.mutable(Schema.Array(RawObject(FunctionType)))),\n triggers: Schema.optional(Schema.mutable(Schema.Array(RawObject(FunctionTrigger)))),\n});\nexport type FunctionManifest = Schema.Schema.Type<typeof FunctionManifestSchema>;\n\nexport const FUNCTION_TYPES = [FunctionType, FunctionTrigger];\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ObjectMeta } from '@dxos/echo-schema';\nimport { type SpaceId } from '@dxos/keys';\n\n// TODO: use URL scheme for source?\nconst FUNCTIONS_META_KEY = 'dxos.org/service/function';\n\nexport const FUNCTIONS_PRESET_META_KEY = 'dxos.org/service/function-preset';\n\nconst isSecure = (protocol: string) => {\n return protocol === 'https:' || protocol === 'wss:';\n};\n\nexport const getUserFunctionUrlInMetadata = (meta: ObjectMeta) => {\n return meta.keys.find((key) => key.source === FUNCTIONS_META_KEY)?.id;\n};\n\nexport const setUserFunctionUrlInMetadata = (meta: ObjectMeta, functionUrl: string) => {\n const key = meta.keys.find((key) => key.source === FUNCTIONS_META_KEY);\n if (key) {\n if (key.id !== functionUrl) {\n throw new Error('Metadata mismatch');\n }\n } else {\n meta.keys.push({ source: FUNCTIONS_META_KEY, id: functionUrl });\n }\n};\n\n/**\n * NOTE: functionId is backend ID, not ECHO object id.\n */\nexport const makeFunctionUrl = (fn: { functionId: string }) => `/${fn.functionId}`;\n\nexport const getInvocationUrl = (functionUrl: string, edgeUrl: string, options: InvocationOptions = {}) => {\n const baseUrl = new URL('functions/', edgeUrl);\n\n // Leading slashes cause the URL to be treated as an absolute path.\n const relativeUrl = functionUrl.replace(/^\\//, '');\n const url = new URL(`./${relativeUrl}`, baseUrl.toString());\n options.spaceId && url.searchParams.set('spaceId', options.spaceId);\n options.subjectId && url.searchParams.set('subjectId', options.subjectId);\n url.protocol = isSecure(url.protocol) ? 'https' : 'http';\n return url.toString();\n};\n\nexport type InvocationOptions = {\n spaceId?: SpaceId;\n subjectId?: string;\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,oBAAuB;ACAvB,IAAAA,iBAAuB;AAEvB,yBAAgF;AAChF,oBAAyB;ACHzB,IAAAA,iBAAuB;AAEvB,IAAAC,sBAAmD;AACnD,iBAAoB;ACHpB,IAAAD,iBAAkC;AAElC,IAAAC,sBAA+E;AHuFxE,IAAMC,iBAAiB,CAAOC,WAAAA;AACnC,MAAI,CAACC,qBAAOC,SAASF,OAAOG,WAAW,GAAG;AACxC,UAAM,IAAIC,MAAM,qCAAA;EAClB;AACA,MAAI,OAAOJ,OAAOK,YAAY,YAAY;AACxC,UAAM,IAAID,MAAM,4BAAA;EAClB;AAEA,SAAO;IACLE,aAAaN,OAAOM;IACpBH,aAAaH,OAAOG;IACpBI,cAAcP,OAAOO,gBAAgBN,qBAAOO;IAC5CH,SAASL,OAAOK;EAClB;AACF;AC/FO,IAAMI,aAAaR,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,mBAAmB,CAACJ,aAAqBK,SAAiBjG,UAA6B,CAAC,MAAC;AACpG,QAAMkG,UAAU,IAAIC,IAAI,cAAcF,OAAAA;AAGtC,QAAMG,cAAcR,YAAYS,QAAQ,OAAO,EAAA;AAC/C,QAAMzF,MAAM,IAAIuF,IAAI,KAAKC,WAAAA,IAAeF,QAAQI,SAAQ,CAAA;AACxDtG,UAAQuG,WAAW3F,IAAI4F,aAAa/B,IAAI,WAAWzE,QAAQuG,OAAO;AAClEvG,UAAQyG,aAAa7F,IAAI4F,aAAa/B,IAAI,aAAazE,QAAQyG,SAAS;AACxE7F,MAAI0E,WAAWD,SAASzE,IAAI0E,QAAQ,IAAI,UAAU;AAClD,SAAO1E,IAAI0F,SAAQ;AACrB;",
6
- "names": ["import_effect", "import_echo_schema", "defineFunction", "params", "Schema", "isSchema", "inputSchema", "Error", "handler", "description", "outputSchema", "Any", "ScriptType", "Struct", "name", "optional", "String", "changed", "Boolean", "source", "Ref", "DataType", "Text", "annotations", "LabelAnnotationId", "pipe", "EchoObject", "typename", "version", "FunctionType", "TypedObject", "NonEmptyString", "JsonSchemaType", "binding", "TriggerKind", "kindLiteralAnnotations", "SchemaAST", "TitleAnnotationId", "TimerTriggerSchema", "kind", "Literal", "cron", "ExamplesAnnotationId", "mutable", "EmailTriggerSchema", "QueueTriggerSchema", "queue", "DXN", "WebhookTriggerSchema", "method", "OptionsAnnotationId", "port", "Number", "QuerySchema", "type", "props", "Record", "key", "value", "SubscriptionTriggerSchema", "filter", "options", "deep", "delay", "TriggerSchema", "Union", "EmailTriggerOutput", "from", "to", "subject", "created", "body", "WebhookTriggerOutput", "url", "headers", "bodyText", "QueueTriggerOutput", "item", "cursor", "SubscriptionTriggerOutput", "changedObjectId", "TimerTriggerOutput", "tick", "FunctionTriggerSchema", "function", "Expando", "inputNodeId", "enabled", "spec", "input", "FunctionTrigger", "fields", "FunctionManifestSchema", "functions", "Array", "RawObject", "triggers", "FUNCTION_TYPES", "InvocationOutcome", "InvocationTraceEventType", "TraceEventException", "timestampMs", "message", "stack", "InvocationTraceStartEvent", "id", "ObjectId", "invocationId", "Object", "invocationTraceQueue", "invocationTarget", "trigger", "InvocationTraceEndEvent", "outcome", "Enums", "exception", "TraceEventLog", "level", "context", "TraceEvent", "truncated", "ingestionTimestampMs", "logs", "exceptions", "createInvocationSpans", "items", "eventsByInvocationId", "Map", "event", "entry", "get", "start", "undefined", "end", "set", "now", "Date", "result", "entries", "log", "warn", "isInProgress", "push", "durationMs", "FUNCTIONS_META_KEY", "FUNCTIONS_PRESET_META_KEY", "isSecure", "protocol", "getUserFunctionUrlInMetadata", "meta", "keys", "find", "setUserFunctionUrlInMetadata", "functionUrl", "makeFunctionUrl", "fn", "functionId", "getInvocationUrl", "edgeUrl", "baseUrl", "URL", "relativeUrl", "replace", "toString", "spaceId", "searchParams", "subjectId"]
3
+ "sources": ["../../../src/handler.ts", "../../../src/schema.ts", "../../../src/trace.ts", "../../../src/types.ts", "../../../src/url.ts", "../../../src/services/ai.ts", "../../../src/services/database.ts", "../../../src/services/queues.ts", "../../../src/services/credentials.ts", "../../../src/services/tracing.ts", "../../../src/services/service-container.ts", "../../../src/executor/executor.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Schema, type Context, type Effect } from 'effect';\n\nimport { type AIServiceClient } from '@dxos/ai';\n// import { type Space } from '@dxos/client/echo';\nimport type { CoreDatabase, EchoDatabase } from '@dxos/echo-db';\nimport { type HasId } from '@dxos/echo-schema';\nimport { type SpaceId, type DXN } from '@dxos/keys';\nimport { type QueryResult } from '@dxos/protocols';\n\n// TODO(burdon): Model after http request. Ref Lambda/OpenFaaS.\n// https://docs.aws.amazon.com/lambda/latest/dg/typescript-handler.html\n// https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml/#functions\n// https://www.npmjs.com/package/aws-lambda\n\n/**\n * Function handler.\n */\nexport type FunctionHandler<TData = {}, TOutput = any> = (params: {\n /**\n * Services and context available to the function.\n */\n context: FunctionContext;\n\n /**\n * Data passed as the input to the function.\n * Must match the function's input schema.\n * This will be the payload from the trigger or other data passed into the function in a workflow.\n */\n data: TData;\n}) => TOutput | Promise<TOutput> | Effect.Effect<TOutput, any>;\n\n/**\n * Function context.\n */\nexport interface FunctionContext {\n /**\n * Resolves a service available to the function.\n * @throws if the service is not available.\n */\n getService: <T extends Context.Tag<any, any>>(tag: T) => Context.Tag.Service<T>;\n\n getSpace: (spaceId: SpaceId) => Promise<SpaceAPI>;\n\n /**\n * Space from which the function was invoked.\n */\n space: SpaceAPI | undefined;\n\n ai: AIServiceClient;\n}\n\nexport interface FunctionContextAi {\n // TODO(dmaretskyi): Refer to cloudflare AI docs for more comprehensive typedefs.\n run(model: string, inputs: any, options?: any): Promise<any>;\n}\n\n//\n// API.\n//\n\n// TODO(dmaretskyi): Temporary API to get the queues working.\n// TODO(dmaretskyi): To be replaced with integrating queues into echo.\nexport interface QueuesAPI {\n queryQueue(queue: DXN, options?: {}): Promise<QueryResult>;\n insertIntoQueue(queue: DXN, objects: HasId[]): Promise<void>;\n}\n\n/**\n * Space interface available to functions.\n */\nexport interface SpaceAPI {\n get id(): SpaceId;\n /**\n * @deprecated\n */\n get crud(): CoreDatabase;\n get db(): EchoDatabase;\n // TODO(dmaretskyi): Align with echo api --- queues.get(id).append(items);\n get queues(): QueuesAPI;\n}\n\n// TODO(wittjosiah): Queues are incompatible.\nconst __assertFunctionSpaceIsCompatibleWithTheClientSpace = () => {\n // const _: SpaceAPI = {} as Space;\n};\n\nexport type FunctionDefinition<T = {}, O = any> = {\n description?: string;\n inputSchema: Schema.Schema<T, any>;\n outputSchema?: Schema.Schema<O, any>;\n handler: FunctionHandler<T, O>;\n};\n\n// TODO(dmaretskyi): Bind input type to function handler.\nexport const defineFunction = <T, O>(params: FunctionDefinition<T, O>): FunctionDefinition<T, O> => {\n if (!Schema.isSchema(params.inputSchema)) {\n throw new Error('Input schema must be a valid schema');\n }\n if (typeof params.handler !== 'function') {\n throw new Error('Handler must be a function');\n }\n\n return {\n description: params.description,\n inputSchema: params.inputSchema,\n outputSchema: params.outputSchema ?? Schema.Any,\n handler: params.handler,\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { EchoObject, JsonSchemaType, LabelAnnotation, Ref, TypedObject } from '@dxos/echo-schema';\nimport { DataType } from '@dxos/schema';\n\n/**\n * Source script.\n */\nexport const ScriptType = Schema.Struct({\n name: Schema.optional(Schema.String),\n description: Schema.optional(Schema.String),\n // TODO(burdon): Change to hash of deployed content.\n // Whether source has changed since last deploy.\n changed: Schema.optional(Schema.Boolean),\n source: Ref(DataType.Text),\n}).pipe(\n EchoObject({\n typename: 'dxos.org/type/Script',\n version: '0.1.0',\n }),\n LabelAnnotation.set(['name']),\n);\n\nexport type ScriptType = Schema.Schema.Type<typeof ScriptType>;\n\n/**\n * Function deployment.\n */\nexport class FunctionType extends TypedObject({\n typename: 'dxos.org/type/Function',\n version: '0.1.0',\n})({\n // TODO(burdon): Rename to id/uri?\n name: Schema.NonEmptyString,\n version: Schema.String,\n\n description: Schema.optional(Schema.String),\n\n // Reference to a source script if it exists within ECHO.\n // TODO(burdon): Don't ref ScriptType directly (core).\n source: Schema.optional(Ref(ScriptType)),\n\n inputSchema: Schema.optional(JsonSchemaType),\n outputSchema: Schema.optional(JsonSchemaType),\n\n // Local binding to a function name.\n binding: Schema.optional(Schema.String),\n}) {}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { Queue } from '@dxos/echo-db';\nimport { EchoObject, Expando, ObjectId, Ref } from '@dxos/echo-schema';\nimport { log } from '@dxos/log';\n\nimport { FunctionTrigger, type FunctionTriggerType } from './types';\n\nexport enum InvocationOutcome {\n SUCCESS = 'success',\n FAILURE = 'failure',\n PENDING = 'pending',\n}\n\n// TODO(burdon): Convert to extensible discriminated union of EDGE events.\nexport enum InvocationTraceEventType {\n START = 'start',\n END = 'end',\n}\n\nexport const TraceEventException = Schema.Struct({\n timestampMs: Schema.Number,\n message: Schema.String,\n name: Schema.String,\n stack: Schema.optional(Schema.String),\n});\nexport type TraceEventException = Schema.Schema.Type<typeof TraceEventException>;\n\nexport const InvocationTraceStartEvent = Schema.Struct({\n /**\n * Queue message id.\n */\n id: ObjectId,\n type: Schema.Literal(InvocationTraceEventType.START),\n /**\n * Invocation id, the same for invocation start and end events.\n */\n invocationId: ObjectId,\n /**\n * Event generation time.\n */\n timestampMs: Schema.Number,\n /**\n * Data passed to function / workflow as an argument.\n */\n // TODO(burdon): Input schema?\n input: Schema.Object,\n /**\n * Queue for function/workflow invocation events.\n */\n invocationTraceQueue: Ref(Queue),\n /**\n * DXN of the invoked function/workflow.\n */\n invocationTarget: Ref(Expando),\n /**\n * Present for automatic invocations.\n */\n trigger: Schema.optional(Ref(FunctionTrigger)),\n}).pipe(EchoObject({ typename: 'dxos.org/type/InvocationTraceStart', version: '0.1.0' }));\n\nexport type InvocationTraceStartEvent = Schema.Schema.Type<typeof InvocationTraceStartEvent>;\n\nexport const InvocationTraceEndEvent = Schema.Struct({\n /**\n * Trace event id.\n */\n id: ObjectId,\n type: Schema.Literal(InvocationTraceEventType.END),\n /**\n * Invocation id, will be the same for invocation start and end.\n */\n invocationId: ObjectId,\n /**\n * Event generation time.\n */\n // TODO(burdon): Remove ms suffix.\n timestampMs: Schema.Number,\n outcome: Schema.Enums(InvocationOutcome),\n exception: Schema.optional(TraceEventException),\n}).pipe(EchoObject({ typename: 'dxos.org/type/InvocationTraceEnd', version: '0.1.0' }));\n\nexport type InvocationTraceEndEvent = Schema.Schema.Type<typeof InvocationTraceEndEvent>;\n\nexport type InvocationTraceEvent = InvocationTraceStartEvent | InvocationTraceEndEvent;\n\nexport const TraceEventLog = Schema.Struct({\n timestampMs: Schema.Number,\n level: Schema.String,\n message: Schema.String,\n context: Schema.optional(Schema.Object),\n});\n\nexport const TraceEvent = Schema.Struct({\n id: ObjectId,\n // TODO(burdon): Need enum/numeric result (not string).\n outcome: Schema.String,\n truncated: Schema.Boolean,\n /**\n * Time when the event was persisted.\n */\n ingestionTimestampMs: Schema.Number,\n logs: Schema.Array(TraceEventLog),\n exceptions: Schema.Array(TraceEventException),\n}).pipe(EchoObject({ typename: 'dxos.org/type/TraceEvent', version: '0.1.0' }));\n\nexport type TraceEvent = Schema.Schema.Type<typeof TraceEvent>;\n\n/**\n * Deprecated InvocationTrace event format.\n * @deprecated\n */\n// TODO(burdon): Remove.\nexport type InvocationSpan = {\n id: string;\n timestampMs: number;\n outcome: InvocationOutcome;\n input: object;\n durationMs: number;\n invocationTraceQueue: Ref<Queue>;\n invocationTarget: Ref<Expando>;\n trigger?: Ref<FunctionTriggerType>;\n exception?: TraceEventException;\n};\n\nexport const createInvocationSpans = (items?: InvocationTraceEvent[]): InvocationSpan[] => {\n if (!items) {\n return [];\n }\n\n const eventsByInvocationId = new Map<string, { start?: InvocationTraceStartEvent; end?: InvocationTraceEndEvent }>();\n for (const event of items) {\n if (!('invocationId' in event)) {\n // Skip legacy format entries.\n continue;\n }\n\n const invocationId = event.invocationId;\n const entry = eventsByInvocationId.get(invocationId) || { start: undefined, end: undefined };\n if (event.type === InvocationTraceEventType.START) {\n entry.start = event as InvocationTraceStartEvent;\n } else if (event.type === InvocationTraceEventType.END) {\n entry.end = event as InvocationTraceEndEvent;\n }\n\n eventsByInvocationId.set(invocationId, entry);\n }\n\n const now = Date.now();\n const result: InvocationSpan[] = [];\n\n // Create spans for each invocation\n for (const [invocationId, { start, end }] of eventsByInvocationId.entries()) {\n if (!start) {\n // No start event, can't create a meaningful span\n log.warn('found end event without matching start', { invocationId });\n continue;\n }\n\n const isInProgress = end === undefined;\n\n result.push({\n id: invocationId,\n timestampMs: start.timestampMs,\n durationMs: isInProgress ? now - start.timestampMs : end!.timestampMs - start.timestampMs,\n outcome: end?.outcome ?? InvocationOutcome.PENDING,\n exception: end?.exception,\n input: start.input,\n invocationTraceQueue: start.invocationTraceQueue,\n invocationTarget: start.invocationTarget,\n trigger: start.trigger,\n });\n }\n\n return result;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { Schema, SchemaAST } from 'effect';\n\nimport { Expando, OptionsAnnotationId, TypedObject, Ref, RawObject } from '@dxos/echo-schema';\nimport { DXN } from '@dxos/keys';\n\nimport { FunctionType } from './schema';\n\n/**\n * Type discriminator for TriggerType.\n * Every spec has a type field of type TriggerKind that we can use to understand which type we're working with.\n * https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions\n */\nexport enum TriggerKind {\n Timer = 'timer',\n Webhook = 'webhook',\n Subscription = 'subscription',\n Email = 'email',\n Queue = 'queue',\n}\n\nconst kindLiteralAnnotations = { title: 'Kind' };\n\n/**\n * Cron timer.\n */\nconst TimerTriggerSchema = Schema.Struct({\n kind: Schema.Literal(TriggerKind.Timer).annotations(kindLiteralAnnotations),\n cron: Schema.String.annotations({\n title: 'Cron',\n [SchemaAST.ExamplesAnnotationId]: ['0 0 * * *'],\n }),\n}).pipe(Schema.mutable);\nexport type TimerTrigger = Schema.Schema.Type<typeof TimerTriggerSchema>;\n\nconst EmailTriggerSchema = Schema.Struct({\n kind: Schema.Literal(TriggerKind.Email).annotations(kindLiteralAnnotations),\n}).pipe(Schema.mutable);\nexport type EmailTrigger = Schema.Schema.Type<typeof EmailTriggerSchema>;\n\nconst QueueTriggerSchema = Schema.Struct({\n kind: Schema.Literal(TriggerKind.Queue).annotations(kindLiteralAnnotations),\n queue: DXN.Schema,\n}).pipe(Schema.mutable);\nexport type QueueTrigger = Schema.Schema.Type<typeof QueueTriggerSchema>;\n\n/**\n * Webhook.\n */\nconst WebhookTriggerSchema = Schema.Struct({\n kind: Schema.Literal(TriggerKind.Webhook).annotations(kindLiteralAnnotations),\n method: Schema.optional(\n Schema.String.annotations({\n title: 'Method',\n [OptionsAnnotationId]: ['GET', 'POST'],\n }),\n ),\n port: Schema.optional(\n Schema.Number.annotations({\n title: 'Port',\n }),\n ),\n}).pipe(Schema.mutable);\nexport type WebhookTrigger = Schema.Schema.Type<typeof WebhookTriggerSchema>;\n\n// TODO(burdon): Use ECHO definition (from https://github.com/dxos/dxos/pull/8233).\nconst QuerySchema = Schema.Struct({\n type: Schema.optional(Schema.String.annotations({ title: 'Type' })),\n props: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),\n}).annotations({ title: 'Query' });\n\n/**\n * Subscription.\n */\nconst SubscriptionTriggerSchema = Schema.Struct({\n kind: Schema.Literal(TriggerKind.Subscription).annotations(kindLiteralAnnotations),\n // TODO(burdon): Define query DSL (from ECHO). Reconcile with Table.Query.\n filter: QuerySchema,\n options: Schema.optional(\n Schema.Struct({\n // Watch changes to object (not just creation).\n deep: Schema.optional(Schema.Boolean.annotations({ title: 'Nested' })),\n // Debounce changes (delay in ms).\n delay: Schema.optional(Schema.Number.annotations({ title: 'Delay' })),\n }).annotations({ title: 'Options' }),\n ),\n}).pipe(Schema.mutable);\nexport type SubscriptionTrigger = Schema.Schema.Type<typeof SubscriptionTriggerSchema>;\n\n/**\n * Trigger schema (discriminated union).\n */\nexport const TriggerSchema = Schema.Union(\n TimerTriggerSchema,\n WebhookTriggerSchema,\n SubscriptionTriggerSchema,\n EmailTriggerSchema,\n QueueTriggerSchema,\n).annotations({\n title: 'Trigger',\n});\nexport type TriggerType = Schema.Schema.Type<typeof TriggerSchema>;\n\nexport type EventType =\n | EmailTriggerOutput\n | WebhookTriggerOutput\n | QueueTriggerOutput\n | SubscriptionTriggerOutput\n | TimerTriggerOutput;\n\n// TODO(burdon): Reuse trigger schema from @dxos/functions (TriggerType).\nexport const EmailTriggerOutput = Schema.mutable(\n Schema.Struct({\n from: Schema.String,\n to: Schema.String,\n subject: Schema.String,\n created: Schema.String,\n body: Schema.String,\n }),\n);\nexport type EmailTriggerOutput = Schema.Schema.Type<typeof EmailTriggerOutput>;\n\nexport const WebhookTriggerOutput = Schema.mutable(\n Schema.Struct({\n url: Schema.String,\n method: Schema.Literal('GET', 'POST'),\n headers: Schema.Record({ key: Schema.String, value: Schema.String }),\n bodyText: Schema.String,\n }),\n);\nexport type WebhookTriggerOutput = Schema.Schema.Type<typeof WebhookTriggerOutput>;\n\nexport const QueueTriggerOutput = Schema.mutable(\n Schema.Struct({\n queue: DXN.Schema,\n item: Schema.Any,\n cursor: Schema.String,\n }),\n);\nexport type QueueTriggerOutput = Schema.Schema.Type<typeof QueueTriggerOutput>;\n\nexport const SubscriptionTriggerOutput = Schema.mutable(\n Schema.Struct({ type: Schema.String, changedObjectId: Schema.String }),\n);\nexport type SubscriptionTriggerOutput = Schema.Schema.Type<typeof SubscriptionTriggerOutput>;\n\nexport const TimerTriggerOutput = Schema.mutable(Schema.Struct({ tick: Schema.Number }));\nexport type TimerTriggerOutput = Schema.Schema.Type<typeof TimerTriggerOutput>;\n\n/**\n * Function trigger.\n * Function is invoked with the `payload` passed as input data.\n * The event that triggers the function is available in the function context.\n */\nexport const FunctionTriggerSchema = Schema.Struct({\n /**\n * Function or workflow to invoke.\n */\n // TODO(dmaretskyi): Can be a Ref(FunctionType) or Ref(ComputeGraphType).\n function: Schema.optional(Ref(Expando).annotations({ title: 'Function' })),\n\n /**\n * Only used for workflowSchema.\n * Specifies the input node in the circuit.\n * @deprecated Remove and enforce a single input node in all compute graphSchema.\n */\n inputNodeId: Schema.optional(Schema.String.annotations({ title: 'Input Node ID' })),\n\n enabled: Schema.optional(Schema.Boolean.annotations({ title: 'Enabled' })),\n\n spec: Schema.optional(TriggerSchema),\n\n /**\n * Passed as the input data to the function.\n * Must match the function's input schema.\n *\n * @example\n * {\n * item: '{{$.trigger.event}}',\n * instructions: 'Summarize and perform entity-extraction'\n * mailbox: { '/': 'dxn:echo:AAA:ZZZ' }\n * }\n */\n input: Schema.optional(Schema.mutable(Schema.Record({ key: Schema.String, value: Schema.Any }))),\n});\n\nexport type FunctionTriggerType = Schema.Schema.Type<typeof FunctionTriggerSchema>;\n\n/**\n * Function trigger.\n */\nexport class FunctionTrigger extends TypedObject({\n typename: 'dxos.org/type/FunctionTrigger',\n version: '0.2.0',\n})(FunctionTriggerSchema.fields) {}\n\n// TODO(wittjosiah): Remove?\n\n/**\n * Function manifest file.\n */\nexport const FunctionManifestSchema = Schema.Struct({\n functions: Schema.optional(Schema.mutable(Schema.Array(RawObject(FunctionType)))),\n triggers: Schema.optional(Schema.mutable(Schema.Array(RawObject(FunctionTrigger)))),\n});\nexport type FunctionManifest = Schema.Schema.Type<typeof FunctionManifestSchema>;\n\nexport const FUNCTION_TYPES = [FunctionType, FunctionTrigger];\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ObjectMeta } from '@dxos/echo-schema';\nimport { type SpaceId } from '@dxos/keys';\n\n// TODO: use URL scheme for source?\nconst FUNCTIONS_META_KEY = 'dxos.org/service/function';\n\nexport const FUNCTIONS_PRESET_META_KEY = 'dxos.org/service/function-preset';\n\nconst isSecure = (protocol: string) => {\n return protocol === 'https:' || protocol === 'wss:';\n};\n\nexport const getUserFunctionUrlInMetadata = (meta: ObjectMeta) => {\n return meta.keys.find((key) => key.source === FUNCTIONS_META_KEY)?.id;\n};\n\nexport const setUserFunctionUrlInMetadata = (meta: ObjectMeta, functionUrl: string) => {\n const key = meta.keys.find((key) => key.source === FUNCTIONS_META_KEY);\n if (key) {\n if (key.id !== functionUrl) {\n throw new Error('Metadata mismatch');\n }\n } else {\n meta.keys.push({ source: FUNCTIONS_META_KEY, id: functionUrl });\n }\n};\n\n/**\n * NOTE: functionId is backend ID, not ECHO object id.\n */\nexport const makeFunctionUrl = (fn: { functionId: string }) => `/${fn.functionId}`;\n\nexport const getInvocationUrl = (functionUrl: string, edgeUrl: string, options: InvocationOptions = {}) => {\n const baseUrl = new URL('functions/', edgeUrl);\n\n // Leading slashes cause the URL to be treated as an absolute path.\n const relativeUrl = functionUrl.replace(/^\\//, '');\n const url = new URL(`./${relativeUrl}`, baseUrl.toString());\n options.spaceId && url.searchParams.set('spaceId', options.spaceId);\n options.subjectId && url.searchParams.set('subjectId', options.subjectId);\n url.protocol = isSecure(url.protocol) ? 'https' : 'http';\n return url.toString();\n};\n\nexport type InvocationOptions = {\n spaceId?: SpaceId;\n subjectId?: string;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Context } from 'effect';\n\nimport type { AIServiceClient } from '@dxos/ai';\n\n// TODO(burdon): Move to @dxos/ai.\nexport class AiService extends Context.Tag('AiService')<\n AiService,\n {\n readonly client: AIServiceClient;\n }\n>() {}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Context } from 'effect';\n\nimport type { EchoDatabase } from '@dxos/echo-db';\n\nexport class DatabaseService extends Context.Tag('DatabaseService')<\n DatabaseService,\n {\n readonly db: EchoDatabase;\n }\n>() {}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Context } from 'effect';\n\nimport type { Queue, QueueFactory } from '@dxos/echo-db';\n\nexport class QueuesService extends Context.Tag('QueuesService')<\n QueuesService,\n {\n readonly contextQueue: Queue | undefined;\n\n readonly queues: QueueFactory;\n }\n>() {}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Context } from 'effect';\n\ntype CredentialQuery = {\n service?: string;\n};\n\n// TODO(dmaretskyi): Unify with other apis.\n// packages/sdk/schema/src/common/access-token.ts\ntype ServiceCredential = {\n service: string;\n\n // TODO(dmaretskyi): Build out.\n apiKey?: string;\n};\n\nexport class CredentialsService extends Context.Tag('CredentialsService')<\n CredentialsService,\n {\n /**\n * Query all.\n */\n queryCredentials: (query: CredentialQuery) => Promise<ServiceCredential[]>;\n\n /**\n * Get a single credential.\n * @throws {Error} If no credential is found.\n */\n getCredential: (query: CredentialQuery) => Promise<ServiceCredential>;\n }\n>() {}\n\nexport class ConfiguredCredentialsService implements Context.Tag.Service<CredentialsService> {\n constructor(private readonly credentials: ServiceCredential[] = []) {}\n\n addCredentials(credentials: ServiceCredential[]): ConfiguredCredentialsService {\n this.credentials.push(...credentials);\n return this;\n }\n\n async queryCredentials(query: CredentialQuery): Promise<ServiceCredential[]> {\n return this.credentials.filter((credential) => credential.service === query.service);\n }\n\n async getCredential(query: CredentialQuery): Promise<ServiceCredential> {\n const credential = this.credentials.find((credential) => credential.service === query.service);\n if (!credential) {\n throw new Error(`Credential not found for service: ${query.service}`);\n }\n return credential;\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Context } from 'effect';\n\nimport type { AnyEchoObject } from '@dxos/echo-schema';\n\nexport class TracingService extends Context.Tag('TracingService')<\n TracingService,\n {\n /**\n * Write an event to the tracing queue.\n * @param event - The event to write. Must be an a typed object.\n */\n write(event: AnyEchoObject): void;\n }\n>() {\n static noop: Context.Tag.Service<TracingService> = { write: () => {} };\n\n static console: Context.Tag.Service<TracingService> = {\n write: (event) => {\n // eslint-disable-next-line no-console\n console.log(event);\n },\n };\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Context } from 'effect';\n\nimport { AiService } from './ai';\nimport { CredentialsService } from './credentials';\nimport { DatabaseService } from './database';\nimport { QueuesService } from './queues';\nimport { TracingService } from './tracing';\n\nexport interface Services {\n database: Context.Tag.Service<DatabaseService>;\n ai: Context.Tag.Service<AiService>;\n queues: Context.Tag.Service<QueuesService>;\n credentials: Context.Tag.Service<CredentialsService>;\n tracing: Context.Tag.Service<TracingService>;\n}\n\nconst SERVICE_MAPPING: Record<string, keyof Services> = {\n [DatabaseService.key]: 'database',\n [AiService.key]: 'ai',\n [QueuesService.key]: 'queues',\n [CredentialsService.key]: 'credentials',\n [TracingService.key]: 'tracing',\n};\n\nconst DEFAULT_SERVICES: Partial<Services> = {\n tracing: TracingService.noop,\n};\n\nexport class ServiceContainer {\n private _services: Partial<Services> = { ...DEFAULT_SERVICES };\n\n /**\n * Set services.\n * @param services - Services to set.\n * @returns The container instance.\n */\n setServices(services: Partial<Services>): this {\n this._services = { ...this._services, ...services };\n return this;\n }\n\n getService<T extends Context.Tag<any, any>>(tag: T): Context.Tag.Service<T> {\n const serviceKey = SERVICE_MAPPING[tag.key];\n const service = serviceKey != null ? this._services[serviceKey] : undefined;\n if (!service) {\n throw new Error(`Service not available: ${tag.key}`);\n }\n return service as Context.Tag.Service<T>;\n }\n\n clone(): ServiceContainer {\n return new ServiceContainer().setServices({ ...this._services });\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Effect, Schema } from 'effect';\n\nimport type { SpaceId } from '@dxos/client/echo';\n\nimport type { FunctionContext, FunctionDefinition } from '../handler';\nimport type { ServiceContainer } from '../services';\n\nexport class FunctionExecutor {\n constructor(private readonly _services: ServiceContainer) {}\n\n // TODO(dmaretskyi): Invocation context: queue, space, etc...\n async invoke<F extends FunctionDefinition<any, any>>(\n fnDef: F,\n input: F extends FunctionDefinition<infer I, infer _O> ? I : never,\n ): Promise<F extends FunctionDefinition<infer _I, infer O> ? O : never> {\n // Assert input matches schema\n const assertInput = fnDef.inputSchema.pipe(Schema.asserts);\n (assertInput as any)(input);\n\n const context: FunctionContext = {\n getService: this._services.getService.bind(this._services),\n getSpace: async (_spaceId: SpaceId) => {\n throw new Error('Not available. Use the database service instead.');\n },\n space: undefined,\n get ai(): never {\n throw new Error('Not available. Use the ai service instead.');\n },\n };\n\n const result = await fnDef.handler({ context, data: input });\n\n // Assert output matches schema\n const assertOutput = fnDef.outputSchema?.pipe(Schema.asserts);\n (assertOutput as any)(result);\n\n if (Effect.isEffect(result)) {\n return Effect.runPromise(result as any);\n }\n\n return result as any;\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,oBAAkD;ACAlD,IAAAA,iBAAuB;AAEvB,yBAA8E;AAC9E,oBAAyB;ACHzB,IAAAA,iBAAuB;AAEvB,qBAAsB;AACtB,IAAAC,sBAAmD;AACnD,iBAAoB;ACJpB,IAAAD,iBAAkC;AAElC,IAAAC,sBAA0E;AAC1E,kBAAoB;AEHpB,IAAAD,iBAAwB;ACAxB,IAAAA,iBAAwB;ACAxB,IAAAA,iBAAwB;ACAxB,IAAAA,i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ACJC,OACA7G,OACsE;AAEtE,UAAM8G,cAAcD,MAAMjM,YAAYiB,KAAKnB,gBAAAA,OAAOqM,OAAO;AACxDD,gBAAoB9G,KAAAA;AAErB,UAAM8B,UAA2B;MAC/ByE,YAAY,KAAKH,UAAUG,WAAWS,KAAK,KAAKZ,SAAS;MACzDa,UAAU,OAAOC,aAAAA;AACf,cAAM,IAAIrM,MAAM,kDAAA;MAClB;MACAsM,OAAOvE;MACP,IAAIwE,KAAY;AACd,cAAM,IAAIvM,MAAM,4CAAA;MAClB;IACF;AAEA,UAAMmI,SAAS,MAAM6D,MAAM/L,QAAQ;MAAEgH;MAASuF,MAAMrH;IAAM,CAAA;AAG1D,UAAMsH,eAAeT,MAAM7L,cAAca,KAAKnB,gBAAAA,OAAOqM,OAAO;AAC3DO,iBAAqBtE,MAAAA;AAEtB,QAAIuE,uBAAOC,SAASxE,MAAAA,GAAS;AAC3B,aAAOuE,uBAAOE,WAAWzE,MAAAA;IAC3B;AAEA,WAAOA;EACT;AACF;",
6
+ "names": ["import_effect", "import_echo_schema", "defineFunction", "params", "Schema", "isSchema", "inputSchema", "Error", "handler", "description", "outputSchema", "Any", "ScriptType", "Struct", "name", "optional", "String", "changed", "Boolean", "source", "Ref", "DataType", "Text", "pipe", "EchoObject", "typename", "version", "LabelAnnotation", "set", "FunctionType", "TypedObject", "NonEmptyString", "JsonSchemaType", "binding", "TriggerKind", "kindLiteralAnnotations", "title", "TimerTriggerSchema", "kind", "Literal", "annotations", "cron", "SchemaAST", "ExamplesAnnotationId", "mutable", "EmailTriggerSchema", "QueueTriggerSchema", "queue", "DXN", "WebhookTriggerSchema", "method", "OptionsAnnotationId", "port", "Number", "QuerySchema", "type", "props", "Record", "key", "value", "SubscriptionTriggerSchema", "filter", "options", "deep", "delay", "TriggerSchema", "Union", "EmailTriggerOutput", "from", "to", "subject", "created", "body", "WebhookTriggerOutput", "url", "headers", "bodyText", "QueueTriggerOutput", "item", "cursor", "SubscriptionTriggerOutput", "changedObjectId", "TimerTriggerOutput", "tick", "FunctionTriggerSchema", "function", "Expando", "inputNodeId", "enabled", "spec", "input", "FunctionTrigger", "fields", "FunctionManifestSchema", "functions", "Array", "RawObject", "triggers", "FUNCTION_TYPES", "InvocationOutcome", "InvocationTraceEventType", "TraceEventException", "timestampMs", "message", "stack", "InvocationTraceStartEvent", "id", "ObjectId", "invocationId", "Object", "invocationTraceQueue", "Queue", "invocationTarget", "trigger", "InvocationTraceEndEvent", "outcome", "Enums", "exception", "TraceEventLog", "level", "context", "TraceEvent", "truncated", "ingestionTimestampMs", "logs", "exceptions", "createInvocationSpans", "items", "eventsByInvocationId", "Map", "event", "entry", "get", "start", "undefined", "end", "now", "Date", "result", "entries", "log", "warn", "isInProgress", "push", "durationMs", "FUNCTIONS_META_KEY", "FUNCTIONS_PRESET_META_KEY", "isSecure", "protocol", "getUserFunctionUrlInMetadata", "meta", "keys", "find", "setUserFunctionUrlInMetadata", "functionUrl", "makeFunctionUrl", "fn", "functionId", "getInvocationUrl", "edgeUrl", "baseUrl", "URL", "relativeUrl", "replace", "toString", "spaceId", "searchParams", "subjectId", "AiService", "Context", "Tag", "DatabaseService", "QueuesService", "CredentialsService", "ConfiguredCredentialsService", "credentials", "addCredentials", "queryCredentials", "query", "credential", "service", "getCredential", "TracingService", "noop", "write", "console", "SERVICE_MAPPING", "DEFAULT_SERVICES", "tracing", "ServiceContainer", "_services", "setServices", "services", "getService", "tag", "serviceKey", "clone", "FunctionExecutor", "invoke", "fnDef", "assertInput", "asserts", "bind", "getSpace", "_spaceId", "space", "ai", "data", "assertOutput", "Effect", "isEffect", "runPromise"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/core/functions/src/bundler/bundler.ts":{"bytes":30383,"imports":[{"path":"esbuild-wasm","kind":"import-statement","external":true},{"path":"@dxos/crypto","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/bundler/index.ts":{"bytes":502,"imports":[{"path":"packages/core/functions/src/bundler/bundler.ts","kind":"import-statement","original":"./bundler"}],"format":"esm"},"packages/core/functions/src/edge/functions.ts":{"bytes":6737,"imports":[{"path":"@dxos/client/edge","kind":"import-statement","external":true},{"path":"@dxos/edge-client","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/edge/index.ts":{"bytes":909,"imports":[{"path":"packages/core/functions/src/edge/functions.ts","kind":"import-statement","original":"./functions"}],"format":"esm"},"packages/core/functions/src/handler.ts":{"bytes":6118,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/schema.ts":{"bytes":5170,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/types.ts":{"bytes":22432,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"packages/core/functions/src/schema.ts","kind":"import-statement","original":"./schema"}],"format":"esm"},"packages/core/functions/src/trace.ts":{"bytes":16775,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/core/functions/src/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/core/functions/src/url.ts":{"bytes":6090,"imports":[],"format":"esm"},"packages/core/functions/src/index.ts":{"bytes":821,"imports":[{"path":"packages/core/functions/src/handler.ts","kind":"import-statement","original":"./handler"},{"path":"packages/core/functions/src/schema.ts","kind":"import-statement","original":"./schema"},{"path":"packages/core/functions/src/trace.ts","kind":"import-statement","original":"./trace"},{"path":"packages/core/functions/src/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/core/functions/src/url.ts","kind":"import-statement","original":"./url"}],"format":"esm"}},"outputs":{"packages/core/functions/dist/lib/node/bundler/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":14434},"packages/core/functions/dist/lib/node/bundler/index.cjs":{"imports":[{"path":"esbuild-wasm","kind":"import-statement","external":true},{"path":"@dxos/crypto","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["Bundler","initializeBundler"],"entryPoint":"packages/core/functions/src/bundler/index.ts","inputs":{"packages/core/functions/src/bundler/bundler.ts":{"bytesInOutput":7125},"packages/core/functions/src/bundler/index.ts":{"bytesInOutput":0}},"bytes":7253},"packages/core/functions/dist/lib/node/edge/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3361},"packages/core/functions/dist/lib/node/edge/index.cjs":{"imports":[{"path":"@dxos/client/edge","kind":"import-statement","external":true},{"path":"@dxos/edge-client","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["incrementSemverPatch","publicKeyToDid","uploadWorkerFunction"],"entryPoint":"packages/core/functions/src/edge/index.ts","inputs":{"packages/core/functions/src/edge/functions.ts":{"bytesInOutput":1692},"packages/core/functions/src/edge/index.ts":{"bytesInOutput":0}},"bytes":1853},"packages/core/functions/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":29618},"packages/core/functions/dist/lib/node/index.cjs":{"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"exports":["EmailTriggerOutput","FUNCTIONS_PRESET_META_KEY","FUNCTION_TYPES","FunctionManifestSchema","FunctionTrigger","FunctionTriggerSchema","FunctionType","InvocationOutcome","InvocationTraceEndEvent","InvocationTraceEventType","InvocationTraceStartEvent","QueueTriggerOutput","ScriptType","SubscriptionTriggerOutput","TimerTriggerOutput","TraceEvent","TraceEventException","TraceEventLog","TriggerKind","TriggerSchema","WebhookTriggerOutput","createInvocationSpans","defineFunction","getInvocationUrl","getUserFunctionUrlInMetadata","makeFunctionUrl","setUserFunctionUrlInMetadata"],"entryPoint":"packages/core/functions/src/index.ts","inputs":{"packages/core/functions/src/handler.ts":{"bytesInOutput":453},"packages/core/functions/src/index.ts":{"bytesInOutput":0},"packages/core/functions/src/schema.ts":{"bytesInOutput":1226},"packages/core/functions/src/trace.ts":{"bytesInOutput":4316},"packages/core/functions/src/types.ts":{"bytesInOutput":5011},"packages/core/functions/src/url.ts":{"bytesInOutput":1189}},"bytes":13090}}}
1
+ {"inputs":{"packages/core/functions/src/bundler/bundler.ts":{"bytes":30207,"imports":[{"path":"esbuild-wasm","kind":"import-statement","external":true},{"path":"@dxos/crypto","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/bundler/index.ts":{"bytes":470,"imports":[{"path":"packages/core/functions/src/bundler/bundler.ts","kind":"import-statement","original":"./bundler"}],"format":"esm"},"packages/core/functions/src/edge/functions.ts":{"bytes":6609,"imports":[{"path":"@dxos/client/edge","kind":"import-statement","external":true},{"path":"@dxos/edge-client","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/edge/index.ts":{"bytes":877,"imports":[{"path":"packages/core/functions/src/edge/functions.ts","kind":"import-statement","original":"./functions"}],"format":"esm"},"packages/core/functions/src/handler.ts":{"bytes":6306,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/schema.ts":{"bytes":5008,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/types.ts":{"bytes":21482,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"packages/core/functions/src/schema.ts","kind":"import-statement","original":"./schema"}],"format":"esm"},"packages/core/functions/src/trace.ts":{"bytes":16661,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/core/functions/src/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/core/functions/src/url.ts":{"bytes":6002,"imports":[],"format":"esm"},"packages/core/functions/src/services/ai.ts":{"bytes":1000,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/services/database.ts":{"bytes":951,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/services/queues.ts":{"bytes":1013,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/services/credentials.ts":{"bytes":4258,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/services/tracing.ts":{"bytes":1894,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/services/service-container.ts":{"bytes":5446,"imports":[{"path":"packages/core/functions/src/services/ai.ts","kind":"import-statement","original":"./ai"},{"path":"packages/core/functions/src/services/credentials.ts","kind":"import-statement","original":"./credentials"},{"path":"packages/core/functions/src/services/database.ts","kind":"import-statement","original":"./database"},{"path":"packages/core/functions/src/services/queues.ts","kind":"import-statement","original":"./queues"},{"path":"packages/core/functions/src/services/tracing.ts","kind":"import-statement","original":"./tracing"}],"format":"esm"},"packages/core/functions/src/services/index.ts":{"bytes":927,"imports":[{"path":"packages/core/functions/src/services/ai.ts","kind":"import-statement","original":"./ai"},{"path":"packages/core/functions/src/services/database.ts","kind":"import-statement","original":"./database"},{"path":"packages/core/functions/src/services/queues.ts","kind":"import-statement","original":"./queues"},{"path":"packages/core/functions/src/services/service-container.ts","kind":"import-statement","original":"./service-container"},{"path":"packages/core/functions/src/services/credentials.ts","kind":"import-statement","original":"./credentials"},{"path":"packages/core/functions/src/services/tracing.ts","kind":"import-statement","original":"./tracing"}],"format":"esm"},"packages/core/functions/src/executor/executor.ts":{"bytes":4794,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/executor/index.ts":{"bytes":472,"imports":[{"path":"packages/core/functions/src/executor/executor.ts","kind":"import-statement","original":"./executor"}],"format":"esm"},"packages/core/functions/src/index.ts":{"bytes":1022,"imports":[{"path":"packages/core/functions/src/handler.ts","kind":"import-statement","original":"./handler"},{"path":"packages/core/functions/src/schema.ts","kind":"import-statement","original":"./schema"},{"path":"packages/core/functions/src/trace.ts","kind":"import-statement","original":"./trace"},{"path":"packages/core/functions/src/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/core/functions/src/url.ts","kind":"import-statement","original":"./url"},{"path":"packages/core/functions/src/services/index.ts","kind":"import-statement","original":"./services"},{"path":"packages/core/functions/src/executor/index.ts","kind":"import-statement","original":"./executor"}],"format":"esm"}},"outputs":{"packages/core/functions/dist/lib/node/bundler/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":14572},"packages/core/functions/dist/lib/node/bundler/index.cjs":{"imports":[{"path":"esbuild-wasm","kind":"import-statement","external":true},{"path":"@dxos/crypto","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["Bundler","initializeBundler"],"entryPoint":"packages/core/functions/src/bundler/index.ts","inputs":{"packages/core/functions/src/bundler/bundler.ts":{"bytesInOutput":7125},"packages/core/functions/src/bundler/index.ts":{"bytesInOutput":0}},"bytes":7253},"packages/core/functions/dist/lib/node/edge/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3361},"packages/core/functions/dist/lib/node/edge/index.cjs":{"imports":[{"path":"@dxos/client/edge","kind":"import-statement","external":true},{"path":"@dxos/edge-client","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["incrementSemverPatch","publicKeyToDid","uploadWorkerFunction"],"entryPoint":"packages/core/functions/src/edge/index.ts","inputs":{"packages/core/functions/src/edge/functions.ts":{"bytesInOutput":1692},"packages/core/functions/src/edge/index.ts":{"bytesInOutput":0}},"bytes":1853},"packages/core/functions/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":39161},"packages/core/functions/dist/lib/node/index.cjs":{"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true}],"exports":["AiService","ConfiguredCredentialsService","CredentialsService","DatabaseService","EmailTriggerOutput","FUNCTIONS_PRESET_META_KEY","FUNCTION_TYPES","FunctionExecutor","FunctionManifestSchema","FunctionTrigger","FunctionTriggerSchema","FunctionType","InvocationOutcome","InvocationTraceEndEvent","InvocationTraceEventType","InvocationTraceStartEvent","QueueTriggerOutput","QueuesService","ScriptType","ServiceContainer","SubscriptionTriggerOutput","TimerTriggerOutput","TraceEvent","TraceEventException","TraceEventLog","TracingService","TriggerKind","TriggerSchema","WebhookTriggerOutput","createInvocationSpans","defineFunction","getInvocationUrl","getUserFunctionUrlInMetadata","makeFunctionUrl","setUserFunctionUrlInMetadata"],"entryPoint":"packages/core/functions/src/index.ts","inputs":{"packages/core/functions/src/handler.ts":{"bytesInOutput":453},"packages/core/functions/src/index.ts":{"bytesInOutput":0},"packages/core/functions/src/schema.ts":{"bytesInOutput":1212},"packages/core/functions/src/trace.ts":{"bytesInOutput":4282},"packages/core/functions/src/types.ts":{"bytesInOutput":4749},"packages/core/functions/src/url.ts":{"bytesInOutput":1189},"packages/core/functions/src/services/ai.ts":{"bytesInOutput":96},"packages/core/functions/src/services/index.ts":{"bytesInOutput":0},"packages/core/functions/src/services/database.ts":{"bytesInOutput":121},"packages/core/functions/src/services/queues.ts":{"bytesInOutput":117},"packages/core/functions/src/services/credentials.ts":{"bytesInOutput":737},"packages/core/functions/src/services/tracing.ts":{"bytesInOutput":293},"packages/core/functions/src/services/service-container.ts":{"bytesInOutput":967},"packages/core/functions/src/executor/executor.ts":{"bytesInOutput":949},"packages/core/functions/src/executor/index.ts":{"bytesInOutput":0}},"bytes":16595}}}