@dxos/functions 0.8.4-main.ae835ea → 0.8.4-main.bc2380dfbc

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 (197) hide show
  1. package/LICENSE +102 -5
  2. package/README.md +5 -7
  3. package/dist/lib/neutral/index.mjs +599 -0
  4. package/dist/lib/neutral/index.mjs.map +7 -0
  5. package/dist/lib/neutral/meta.json +1 -0
  6. package/dist/types/src/index.d.ts +2 -7
  7. package/dist/types/src/index.d.ts.map +1 -1
  8. package/dist/types/src/protocol/functions-ai-http-client.d.ts +12 -0
  9. package/dist/types/src/protocol/functions-ai-http-client.d.ts.map +1 -0
  10. package/dist/types/src/protocol/functions-ai-http-client.test.d.ts +2 -0
  11. package/dist/types/src/protocol/functions-ai-http-client.test.d.ts.map +1 -0
  12. package/dist/types/src/protocol/index.d.ts +2 -0
  13. package/dist/types/src/protocol/index.d.ts.map +1 -0
  14. package/dist/types/src/protocol/protocol.d.ts +24 -0
  15. package/dist/types/src/protocol/protocol.d.ts.map +1 -0
  16. package/dist/types/src/protocol/protocol.test.d.ts +2 -0
  17. package/dist/types/src/protocol/protocol.test.d.ts.map +1 -0
  18. package/dist/types/src/sdk.d.ts +10 -0
  19. package/dist/types/src/sdk.d.ts.map +1 -0
  20. package/dist/types/src/services/credentials.d.ts +17 -38
  21. package/dist/types/src/services/credentials.d.ts.map +1 -1
  22. package/dist/types/src/services/function-invocation-service.d.ts +6 -19
  23. package/dist/types/src/services/function-invocation-service.d.ts.map +1 -1
  24. package/dist/types/src/services/index.d.ts +1 -6
  25. package/dist/types/src/services/index.d.ts.map +1 -1
  26. package/dist/types/src/services/queues.d.ts +1 -46
  27. package/dist/types/src/services/queues.d.ts.map +1 -1
  28. package/dist/types/src/services/tracing.d.ts +2 -56
  29. package/dist/types/src/services/tracing.d.ts.map +1 -1
  30. package/dist/types/src/types/index.d.ts +1 -4
  31. package/dist/types/src/types/index.d.ts.map +1 -1
  32. package/dist/types/src/types/url.d.ts +13 -0
  33. package/dist/types/src/types/url.d.ts.map +1 -0
  34. package/dist/types/tsconfig.tsbuildinfo +1 -1
  35. package/package.json +26 -61
  36. package/src/index.ts +2 -7
  37. package/src/protocol/functions-ai-http-client.test.ts +105 -0
  38. package/src/protocol/functions-ai-http-client.ts +141 -0
  39. package/src/{executor → protocol}/index.ts +1 -1
  40. package/src/protocol/protocol.test.ts +58 -0
  41. package/src/protocol/protocol.ts +452 -0
  42. package/src/sdk.ts +31 -0
  43. package/src/services/credentials.ts +81 -110
  44. package/src/services/function-invocation-service.ts +19 -70
  45. package/src/services/index.ts +1 -6
  46. package/src/services/queues.ts +1 -80
  47. package/src/services/tracing.ts +1 -136
  48. package/src/types/index.ts +1 -4
  49. package/src/types/url.ts +32 -0
  50. package/dist/lib/browser/bundler/index.mjs +0 -256
  51. package/dist/lib/browser/bundler/index.mjs.map +0 -7
  52. package/dist/lib/browser/chunk-J5LGTIGS.mjs +0 -10
  53. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +0 -7
  54. package/dist/lib/browser/chunk-M6EXIREF.mjs +0 -610
  55. package/dist/lib/browser/chunk-M6EXIREF.mjs.map +0 -7
  56. package/dist/lib/browser/edge/index.mjs +0 -83
  57. package/dist/lib/browser/edge/index.mjs.map +0 -7
  58. package/dist/lib/browser/index.mjs +0 -1346
  59. package/dist/lib/browser/index.mjs.map +0 -7
  60. package/dist/lib/browser/meta.json +0 -1
  61. package/dist/lib/browser/testing/index.mjs +0 -131
  62. package/dist/lib/browser/testing/index.mjs.map +0 -7
  63. package/dist/lib/node-esm/bundler/index.mjs +0 -257
  64. package/dist/lib/node-esm/bundler/index.mjs.map +0 -7
  65. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
  66. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +0 -7
  67. package/dist/lib/node-esm/chunk-P3IATZMZ.mjs +0 -612
  68. package/dist/lib/node-esm/chunk-P3IATZMZ.mjs.map +0 -7
  69. package/dist/lib/node-esm/edge/index.mjs +0 -84
  70. package/dist/lib/node-esm/edge/index.mjs.map +0 -7
  71. package/dist/lib/node-esm/index.mjs +0 -1347
  72. package/dist/lib/node-esm/index.mjs.map +0 -7
  73. package/dist/lib/node-esm/meta.json +0 -1
  74. package/dist/lib/node-esm/testing/index.mjs +0 -132
  75. package/dist/lib/node-esm/testing/index.mjs.map +0 -7
  76. package/dist/types/src/bundler/bundler.d.ts +0 -49
  77. package/dist/types/src/bundler/bundler.d.ts.map +0 -1
  78. package/dist/types/src/bundler/bundler.test.d.ts +0 -2
  79. package/dist/types/src/bundler/bundler.test.d.ts.map +0 -1
  80. package/dist/types/src/bundler/index.d.ts +0 -2
  81. package/dist/types/src/bundler/index.d.ts.map +0 -1
  82. package/dist/types/src/e2e/deploy.test.d.ts +0 -2
  83. package/dist/types/src/e2e/deploy.test.d.ts.map +0 -1
  84. package/dist/types/src/edge/functions.d.ts +0 -17
  85. package/dist/types/src/edge/functions.d.ts.map +0 -1
  86. package/dist/types/src/edge/index.d.ts +0 -2
  87. package/dist/types/src/edge/index.d.ts.map +0 -1
  88. package/dist/types/src/errors.d.ts +0 -137
  89. package/dist/types/src/errors.d.ts.map +0 -1
  90. package/dist/types/src/example/fib.d.ts +0 -7
  91. package/dist/types/src/example/fib.d.ts.map +0 -1
  92. package/dist/types/src/example/forex-effect.d.ts +0 -3
  93. package/dist/types/src/example/forex-effect.d.ts.map +0 -1
  94. package/dist/types/src/example/index.d.ts +0 -12
  95. package/dist/types/src/example/index.d.ts.map +0 -1
  96. package/dist/types/src/example/reply.d.ts +0 -3
  97. package/dist/types/src/example/reply.d.ts.map +0 -1
  98. package/dist/types/src/example/sleep.d.ts +0 -5
  99. package/dist/types/src/example/sleep.d.ts.map +0 -1
  100. package/dist/types/src/executor/executor.d.ts +0 -14
  101. package/dist/types/src/executor/executor.d.ts.map +0 -1
  102. package/dist/types/src/executor/index.d.ts +0 -2
  103. package/dist/types/src/executor/index.d.ts.map +0 -1
  104. package/dist/types/src/handler.d.ts +0 -102
  105. package/dist/types/src/handler.d.ts.map +0 -1
  106. package/dist/types/src/services/database.d.ts +0 -67
  107. package/dist/types/src/services/database.d.ts.map +0 -1
  108. package/dist/types/src/services/event-logger.d.ts +0 -75
  109. package/dist/types/src/services/event-logger.d.ts.map +0 -1
  110. package/dist/types/src/services/function-invocation-service.test.d.ts +0 -2
  111. package/dist/types/src/services/function-invocation-service.test.d.ts.map +0 -1
  112. package/dist/types/src/services/local-function-execution.d.ts +0 -34
  113. package/dist/types/src/services/local-function-execution.d.ts.map +0 -1
  114. package/dist/types/src/services/remote-function-execution-service.d.ts +0 -22
  115. package/dist/types/src/services/remote-function-execution-service.d.ts.map +0 -1
  116. package/dist/types/src/services/service-container.d.ts +0 -57
  117. package/dist/types/src/services/service-container.d.ts.map +0 -1
  118. package/dist/types/src/services/service-registry.d.ts +0 -31
  119. package/dist/types/src/services/service-registry.d.ts.map +0 -1
  120. package/dist/types/src/services/service-registry.test.d.ts +0 -2
  121. package/dist/types/src/services/service-registry.test.d.ts.map +0 -1
  122. package/dist/types/src/testing/index.d.ts +0 -3
  123. package/dist/types/src/testing/index.d.ts.map +0 -1
  124. package/dist/types/src/testing/layer.d.ts +0 -18
  125. package/dist/types/src/testing/layer.d.ts.map +0 -1
  126. package/dist/types/src/testing/logger.d.ts +0 -5
  127. package/dist/types/src/testing/logger.d.ts.map +0 -1
  128. package/dist/types/src/testing/persist-database.test.d.ts +0 -2
  129. package/dist/types/src/testing/persist-database.test.d.ts.map +0 -1
  130. package/dist/types/src/testing/services.d.ts +0 -59
  131. package/dist/types/src/testing/services.d.ts.map +0 -1
  132. package/dist/types/src/trace.d.ts +0 -122
  133. package/dist/types/src/trace.d.ts.map +0 -1
  134. package/dist/types/src/translations.d.ts +0 -12
  135. package/dist/types/src/translations.d.ts.map +0 -1
  136. package/dist/types/src/triggers/index.d.ts +0 -4
  137. package/dist/types/src/triggers/index.d.ts.map +0 -1
  138. package/dist/types/src/triggers/input-builder.d.ts +0 -3
  139. package/dist/types/src/triggers/input-builder.d.ts.map +0 -1
  140. package/dist/types/src/triggers/invocation-tracer.d.ts +0 -37
  141. package/dist/types/src/triggers/invocation-tracer.d.ts.map +0 -1
  142. package/dist/types/src/triggers/trigger-dispatcher.d.ts +0 -78
  143. package/dist/types/src/triggers/trigger-dispatcher.d.ts.map +0 -1
  144. package/dist/types/src/triggers/trigger-dispatcher.test.d.ts +0 -2
  145. package/dist/types/src/triggers/trigger-dispatcher.test.d.ts.map +0 -1
  146. package/dist/types/src/triggers/trigger-state-store.d.ts +0 -28
  147. package/dist/types/src/triggers/trigger-state-store.d.ts.map +0 -1
  148. package/dist/types/src/types/Function.d.ts +0 -47
  149. package/dist/types/src/types/Function.d.ts.map +0 -1
  150. package/dist/types/src/types/Script.d.ts +0 -28
  151. package/dist/types/src/types/Script.d.ts.map +0 -1
  152. package/dist/types/src/types/Trigger.d.ts +0 -139
  153. package/dist/types/src/types/Trigger.d.ts.map +0 -1
  154. package/dist/types/src/types/TriggerEvent.d.ts +0 -44
  155. package/dist/types/src/types/TriggerEvent.d.ts.map +0 -1
  156. package/dist/types/src/url.d.ts +0 -21
  157. package/dist/types/src/url.d.ts.map +0 -1
  158. package/src/bundler/bundler.test.ts +0 -58
  159. package/src/bundler/bundler.ts +0 -295
  160. package/src/bundler/index.ts +0 -5
  161. package/src/e2e/deploy.test.ts +0 -69
  162. package/src/edge/functions.ts +0 -67
  163. package/src/edge/index.ts +0 -9
  164. package/src/errors.ts +0 -21
  165. package/src/example/fib.ts +0 -32
  166. package/src/example/forex-effect.ts +0 -40
  167. package/src/example/index.ts +0 -13
  168. package/src/example/reply.ts +0 -21
  169. package/src/example/sleep.ts +0 -24
  170. package/src/executor/executor.ts +0 -58
  171. package/src/handler.ts +0 -226
  172. package/src/services/database.ts +0 -175
  173. package/src/services/event-logger.ts +0 -121
  174. package/src/services/function-invocation-service.test.ts +0 -81
  175. package/src/services/local-function-execution.ts +0 -153
  176. package/src/services/remote-function-execution-service.ts +0 -63
  177. package/src/services/service-container.ts +0 -115
  178. package/src/services/service-registry.test.ts +0 -45
  179. package/src/services/service-registry.ts +0 -63
  180. package/src/testing/index.ts +0 -6
  181. package/src/testing/layer.ts +0 -114
  182. package/src/testing/logger.ts +0 -17
  183. package/src/testing/persist-database.test.ts +0 -87
  184. package/src/testing/services.ts +0 -115
  185. package/src/trace.ts +0 -178
  186. package/src/translations.ts +0 -20
  187. package/src/triggers/index.ts +0 -7
  188. package/src/triggers/input-builder.ts +0 -35
  189. package/src/triggers/invocation-tracer.ts +0 -101
  190. package/src/triggers/trigger-dispatcher.test.ts +0 -664
  191. package/src/triggers/trigger-dispatcher.ts +0 -521
  192. package/src/triggers/trigger-state-store.ts +0 -61
  193. package/src/types/Function.ts +0 -51
  194. package/src/types/Script.ts +0 -33
  195. package/src/types/Trigger.ts +0 -139
  196. package/src/types/TriggerEvent.ts +0 -62
  197. package/src/url.ts +0 -55
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/example/fib.ts", "../../../src/handler.ts", "../../../src/types/Function.ts", "../../../src/types/Script.ts", "../../../src/types/Trigger.ts", "../../../src/types/TriggerEvent.ts", "../../../src/example/reply.ts", "../../../src/example/sleep.ts", "../../../src/example/index.ts", "../../../src/executor/executor.ts", "../../../src/services/function-invocation-service.ts", "../../../src/services/local-function-execution.ts", "../../../src/trace.ts", "../../../src/triggers/invocation-tracer.ts", "../../../src/triggers/trigger-dispatcher.ts", "../../../src/triggers/input-builder.ts", "../../../src/triggers/trigger-state-store.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { defineFunction } from '../handler';\n\nexport default defineFunction({\n key: 'example.org/function/fib',\n name: 'Fibonacci',\n description: 'Function that calculates a Fibonacci number',\n inputSchema: Schema.Struct({\n iterations: Schema.optional(Schema.Number).annotations({\n description: 'Number of iterations',\n default: 100_000,\n }),\n }),\n outputSchema: Schema.Struct({\n result: Schema.String,\n }),\n handler: Effect.fn(function* ({ data: { iterations = 100_000 } }) {\n let a = 0n;\n let b = 1n;\n for (let i = 0; i < iterations; i++) {\n a += b;\n b = a - b;\n }\n return { result: a.toString() };\n }),\n});\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { Obj, Type } from '@dxos/echo';\nimport { type HasId } from '@dxos/echo/internal';\nimport { type EchoDatabase } from '@dxos/echo-db';\nimport { assertArgument } from '@dxos/invariant';\nimport { type DXN, type SpaceId } from '@dxos/keys';\nimport { type QueryResult } from '@dxos/protocols';\n\nimport { type Services } from './services';\nimport { Function } from './types';\nimport { getUserFunctionIdInMetadata, setUserFunctionIdInMetadata } from './url';\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, Services>;\n\n/**\n * Function context.\n */\nexport interface FunctionContext {\n /**\n * Space from which the function was invoked.\n */\n space: SpaceAPI | undefined;\n\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\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 get db(): EchoDatabase;\n\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\nconst typeId = Symbol.for('@dxos/functions/FunctionDefinition');\n\nexport type FunctionDefinition<T = any, O = any> = {\n [typeId]: true;\n key: string;\n name: string;\n description?: string;\n inputSchema: Schema.Schema<T, any>;\n outputSchema?: Schema.Schema<O, any>;\n handler: FunctionHandler<T, O>;\n meta?: {\n /**\n * Tools that are projected from functions have this annotation.\n *\n * deployedFunctionId:\n * - Backend deployment ID assigned by the EDGE function service (typically a UUID).\n * - Used for remote invocation via `FunctionInvocationService` → `RemoteFunctionExecutionService`.\n * - Persisted on the corresponding ECHO `Function.Function` object's metadata under the\n * `FUNCTIONS_META_KEY` and retrieved with `getUserFunctionIdInMetadata`.\n */\n deployedFunctionId?: string;\n };\n};\n\nexport type FunctionProps<T, O> = {\n key: string;\n name: string;\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): Output type doesn't get typechecked.\nexport const defineFunction: {\n <I, O>(params: FunctionProps<I, O>): FunctionDefinition<I, O>;\n} = ({ key, name, description, inputSchema, outputSchema = Schema.Any, handler }) => {\n if (!Schema.isSchema(inputSchema)) {\n throw new Error('Input schema must be a valid schema');\n }\n if (typeof handler !== 'function') {\n throw new Error('Handler must be a function');\n }\n\n // Captures the function definition location.\n const limit = Error.stackTraceLimit;\n Error.stackTraceLimit = 2;\n const traceError = new Error();\n Error.stackTraceLimit = limit;\n let cache: false | string = false;\n const captureStackTrace = () => {\n if (cache !== false) {\n return cache;\n }\n if (traceError.stack !== undefined) {\n const stack = traceError.stack.split('\\n');\n if (stack[2] !== undefined) {\n cache = stack[2].trim();\n return cache;\n }\n }\n };\n\n const handlerWithSpan = (...args: any[]) => {\n const result = (handler as any)(...args);\n if (Effect.isEffect(result)) {\n return Effect.withSpan(result, `${key ?? name}`, {\n captureStackTrace,\n });\n }\n return result;\n };\n\n return {\n [typeId]: true,\n key,\n name,\n description,\n inputSchema,\n outputSchema,\n handler: handlerWithSpan,\n } satisfies FunctionDefinition.Any;\n};\n\nexport const FunctionDefinition = {\n make: defineFunction,\n isFunction: (value: unknown): value is FunctionDefinition.Any => {\n return typeof value === 'object' && value !== null && Symbol.for('@dxos/functions/FunctionDefinition') in value;\n },\n serialize: (functionDef: FunctionDefinition.Any): Function.Function => {\n assertArgument(FunctionDefinition.isFunction(functionDef), 'functionDef');\n return serializeFunction(functionDef);\n },\n deserialize: (functionObj: Function.Function): FunctionDefinition.Any => {\n assertArgument(Obj.instanceOf(Function.Function, functionObj), 'functionObj');\n return deserializeFunction(functionObj);\n },\n};\nexport declare namespace FunctionDefinition {\n export type Any = FunctionDefinition<any, any>;\n export type Input<T extends FunctionDefinition> = T extends FunctionDefinition<infer I, any> ? I : never;\n export type Output<T extends FunctionDefinition> = T extends FunctionDefinition<any, infer O> ? O : never;\n}\n\nexport const serializeFunction = (functionDef: FunctionDefinition<any, any>): Function.Function => {\n const fn = Function.make({\n key: functionDef.key,\n name: functionDef.name,\n version: '0.1.0',\n description: functionDef.description,\n inputSchema: Type.toJsonSchema(functionDef.inputSchema),\n outputSchema: !functionDef.outputSchema ? undefined : Type.toJsonSchema(functionDef.outputSchema),\n });\n if (functionDef.meta?.deployedFunctionId) {\n setUserFunctionIdInMetadata(Obj.getMeta(fn), functionDef.meta.deployedFunctionId);\n }\n return fn;\n};\n\nexport const deserializeFunction = (functionObj: Function.Function): FunctionDefinition<unknown, unknown> => {\n return {\n [typeId]: true,\n // TODO(dmaretskyi): Fix key.\n key: functionObj.key ?? functionObj.name,\n name: functionObj.name,\n description: functionObj.description,\n inputSchema: !functionObj.inputSchema ? Schema.Unknown : Type.toEffectSchema(functionObj.inputSchema),\n outputSchema: !functionObj.outputSchema ? undefined : Type.toEffectSchema(functionObj.outputSchema),\n // TODO(dmaretskyi): This should throw error.\n handler: () => {},\n meta: {\n deployedFunctionId: getUserFunctionIdInMetadata(Obj.getMeta(functionObj)),\n },\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Obj, Type } from '@dxos/echo';\nimport { JsonSchemaType, LabelAnnotation, Ref } from '@dxos/echo/internal';\n\nimport { Script } from './Script';\n\n/**\n * Function deployment.\n */\nexport const Function = Schema.Struct({\n /**\n * Global registry ID.\n * NOTE: The `key` property refers to the original registry entry.\n */\n // TODO(burdon): Create Format type for DXN-like ids, such as this and schema type.\n // TODO(dmaretskyi): Consider making it part of ECHO meta.\n // TODO(dmaretskyi): Make required.\n key: Schema.optional(Schema.String).annotations({\n description: 'Unique registration key for the blueprint',\n }),\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(Script)),\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}).pipe(\n Type.Obj({\n typename: 'dxos.org/type/Function',\n version: '0.1.0',\n }),\n LabelAnnotation.set(['name']),\n);\nexport interface Function extends Schema.Schema.Type<typeof Function> {}\n\nexport const make = (props: Obj.MakeProps<typeof Function>) => Obj.make(Function, props);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Obj, Ref, Type } from '@dxos/echo';\nimport { FormAnnotation, LabelAnnotation } from '@dxos/echo/internal';\nimport { DataType } from '@dxos/schema';\n\n/**\n * Source script.\n */\nexport const Script = Schema.Struct({\n name: Schema.String.pipe(Schema.optional),\n description: Schema.String.pipe(Schema.optional),\n // TODO(burdon): Change to hash of deployed content.\n // Whether source has changed since last deploy.\n changed: Schema.Boolean.pipe(FormAnnotation.set(false), Schema.optional),\n source: Type.Ref(DataType.Text).pipe(FormAnnotation.set(false)),\n}).pipe(\n Type.Obj({\n typename: 'dxos.org/type/Script',\n version: '0.1.0',\n }),\n LabelAnnotation.set(['name']),\n);\nexport interface Script extends Schema.Schema.Type<typeof Script> {}\n\ntype Props = Omit<Obj.MakeProps<typeof Script>, 'source'> & { source?: string };\n\nexport const make = ({ source = '', ...props }: Props = {}) =>\n Obj.make(Script, { ...props, source: Ref.make(DataType.makeText(source)) });\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { Obj, QueryAST, Type } from '@dxos/echo';\nimport { Expando, OptionsAnnotationId, Ref } from '@dxos/echo/internal';\nimport { DXN } from '@dxos/keys';\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 const Kinds = ['email', 'queue', 'subscription', 'timer', 'webhook'] as const;\nexport type Kind = (typeof Kinds)[number];\n\nconst kindLiteralAnnotations = { title: 'Kind' };\n\nexport const EmailSpec = Schema.Struct({\n kind: Schema.Literal('email').annotations(kindLiteralAnnotations),\n}).pipe(Schema.mutable);\nexport type EmailSpec = Schema.Schema.Type<typeof EmailSpec>;\n\nexport const QueueSpec = Schema.Struct({\n kind: Schema.Literal('queue').annotations(kindLiteralAnnotations),\n\n // TODO(dmaretskyi): Change to a reference.\n queue: DXN.Schema,\n}).pipe(Schema.mutable);\nexport type QueueSpec = Schema.Schema.Type<typeof QueueSpec>;\n\n/**\n * Subscription.\n */\nexport const SubscriptionSpec = Schema.Struct({\n kind: Schema.Literal('subscription').annotations(kindLiteralAnnotations),\n query: Schema.Struct({\n raw: Schema.optional(Schema.String.annotations({ title: 'Query' })),\n ast: QueryAST.Query,\n }).pipe(Schema.mutable),\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 SubscriptionSpec = Schema.Schema.Type<typeof SubscriptionSpec>;\n\n/**\n * Cron timer.\n */\nexport const TimerSpec = Schema.Struct({\n kind: Schema.Literal('timer').annotations(kindLiteralAnnotations),\n cron: Schema.String.annotations({\n title: 'Cron',\n [SchemaAST.ExamplesAnnotationId]: ['0 0 * * *'],\n }),\n}).pipe(Schema.mutable);\nexport type TimerSpec = Schema.Schema.Type<typeof TimerSpec>;\n\n/**\n * Webhook.\n */\nexport const WebhookSpec = Schema.Struct({\n kind: Schema.Literal('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 WebhookSpec = Schema.Schema.Type<typeof WebhookSpec>;\n\n/**\n * Trigger schema.\n */\nexport const Spec = Schema.Union(EmailSpec, QueueSpec, SubscriptionSpec, TimerSpec, WebhookSpec).annotations({\n title: 'Trigger',\n});\nexport type Spec = Schema.Schema.Type<typeof Spec>;\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 */\nconst Trigger_ = 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(Spec),\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}).pipe(\n Type.Obj({\n typename: 'dxos.org/type/Trigger',\n version: '0.1.0',\n }),\n);\nexport interface Trigger extends Schema.Schema.Type<typeof Trigger_> {}\nexport interface TriggerEncoded extends Schema.Schema.Encoded<typeof Trigger_> {}\nexport const Trigger: Schema.Schema<Trigger, TriggerEncoded> = Trigger_;\n\nexport const make = (props: Obj.MakeProps<typeof Trigger>) => Obj.make(Trigger, props);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { DXN, Obj, Type } from '@dxos/echo';\n\nexport type TriggerEvent = EmailEvent | QueueEvent | SubscriptionEvent | TimerEvent | WebhookEvent;\n\n// TODO(burdon): Reuse trigger schema from @dxos/functions (TriggerType).\nexport const EmailEvent = 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 EmailEvent = Schema.Schema.Type<typeof EmailEvent>;\n\nexport const QueueEvent = Schema.mutable(\n Schema.Struct({\n queue: DXN.Schema,\n item: Schema.Any,\n cursor: Schema.String,\n }),\n);\nexport type QueueEvent = Schema.Schema.Type<typeof QueueEvent>;\n\nexport const SubscriptionEvent = Schema.Struct({\n /**\n * Type of the mutation.\n */\n // TODO(dmaretskyi): Specify enum.\n type: Schema.String,\n\n /**\n * Reference to the object that was changed or created.\n */\n subject: Type.Ref(Obj.Any),\n\n /**\n * @deprecated\n */\n changedObjectId: Schema.optional(Schema.String),\n}).pipe(Schema.mutable);\nexport type SubscriptionEvent = Schema.Schema.Type<typeof SubscriptionEvent>;\n\nexport const TimerEvent = Schema.mutable(Schema.Struct({ tick: Schema.Number }));\nexport type TimerEvent = Schema.Schema.Type<typeof TimerEvent>;\n\nexport const WebhookEvent = 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 WebhookEvent = Schema.Schema.Type<typeof WebhookEvent>;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Console from 'effect/Console';\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { defineFunction } from '../handler';\n\nexport default defineFunction({\n key: 'example.org/function/reply',\n name: 'Reply',\n description: 'Function that echoes the input',\n inputSchema: Schema.Any,\n outputSchema: Schema.Any,\n handler: Effect.fn(function* ({ data }) {\n yield* Console.log('reply', { data });\n return data;\n }),\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { defineFunction } from '../handler';\n\nexport default defineFunction({\n key: 'example.org/function/sleep',\n name: 'Sleep',\n description: 'Function that sleeps for a given amount of time',\n inputSchema: Schema.Struct({\n duration: Schema.optional(Schema.Number).annotations({\n description: 'Milliseconds to sleep',\n default: 100_000,\n }),\n }),\n outputSchema: Schema.Void,\n handler: Effect.fn(function* ({ data: { duration = 100_000 } }) {\n yield* Effect.sleep(duration);\n }),\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { default as fib$ } from './fib';\nimport { default as reply$ } from './reply';\nimport { default as sleep$ } from './sleep';\n\nexport namespace Example {\n export const fib = fib$;\n export const reply = reply$;\n export const sleep = sleep$;\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { type SpaceId } from '@dxos/client/echo';\nimport { runAndForwardErrors } from '@dxos/effect';\n\nimport type { FunctionContext, FunctionDefinition } from '../handler';\nimport type { ServiceContainer, Services } from '../services';\n\n/**\n * @deprecated Use `FunctionInvocationService`\n */\nexport class FunctionExecutor {\n constructor(private readonly _services: ServiceContainer) {}\n\n /**\n * Invoke function.\n */\n // TODO(dmaretskyi): Invocation context: queue, space, etc...\n async invoke<F extends FunctionDefinition<any, any>>(\n functionDef: 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 = functionDef.inputSchema.pipe(Schema.asserts);\n (assertInput as any)(input);\n\n const context: FunctionContext = {\n space: undefined,\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 };\n\n const result = functionDef.handler({ context, data: input });\n\n let data: unknown;\n if (Effect.isEffect(result)) {\n data = await (result as Effect.Effect<unknown, unknown, Services>).pipe(\n Effect.provide(this._services.createLayer()),\n runAndForwardErrors,\n );\n } else {\n data = await result;\n }\n\n // Assert output matches schema\n const assertOutput = functionDef.outputSchema?.pipe(Schema.asserts);\n (assertOutput as any)(data);\n\n return data as any;\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\n\nimport { AiService } from '@dxos/ai';\n\nimport { type FunctionDefinition } from '../handler';\n\nimport { CredentialsService } from './credentials';\nimport { DatabaseService } from './database';\nimport {\n FunctionImplementationResolver,\n type InvocationServices,\n LocalFunctionExecutionService,\n} from './local-function-execution';\nimport { QueueService } from './queues';\nimport { RemoteFunctionExecutionService } from './remote-function-execution-service';\n\nexport class FunctionInvocationService extends Context.Tag('@dxos/functions/FunctionInvocationService')<\n FunctionInvocationService,\n {\n invokeFunction<I, O>(functionDef: FunctionDefinition<I, O>, input: I): Effect.Effect<O, never, InvocationServices>;\n }\n>() {\n static invokeFunction = Effect.serviceFunctionEffect(FunctionInvocationService, (_) => _.invokeFunction);\n\n static layer = Layer.effect(\n FunctionInvocationService,\n Effect.gen(function* () {\n const localExecutioner = yield* LocalFunctionExecutionService;\n const remoteExecutioner = yield* RemoteFunctionExecutionService;\n\n return {\n invokeFunction: <I, O>(\n functionDef: FunctionDefinition<I, O>,\n input: I,\n ): Effect.Effect<O, never, InvocationServices> =>\n Effect.gen(function* () {\n if (functionDef.meta?.deployedFunctionId) {\n return yield* remoteExecutioner.callFunction<I, O>(functionDef.meta.deployedFunctionId, input);\n }\n\n return yield* localExecutioner.invokeFunction(functionDef, input);\n }),\n } satisfies Context.Tag.Service<FunctionInvocationService>;\n }),\n );\n\n // TODO(dmaretskyi): Don't provide `FunctionImplementationResolver`.\n static layerTest = ({\n functions = [],\n }: {\n functions?: readonly FunctionDefinition<any, any>[];\n } = {}): Layer.Layer<\n FunctionInvocationService,\n never,\n AiService.AiService | CredentialsService | DatabaseService | QueueService\n > =>\n FunctionInvocationService.layer.pipe(\n Layer.provide(LocalFunctionExecutionService.layerLive),\n Layer.provide(FunctionImplementationResolver.layerTest({ functions })),\n Layer.provide(RemoteFunctionExecutionService.layerMock),\n );\n\n // TODO(dmaretskyi): This shouldn't default to all services being not available.\n // TODO(dmaretskyi): Don't provide `FunctionImplementationResolver`.\n /**\n * @deprecated Use {@link layerTest} instead.\n */\n static layerTestMocked = ({\n functions,\n }: {\n functions?: readonly FunctionDefinition<any, any>[];\n }): Layer.Layer<FunctionInvocationService> =>\n FunctionInvocationService.layerTest({ functions }).pipe(\n Layer.provide(AiService.notAvailable),\n Layer.provide(CredentialsService.configuredLayer([])),\n Layer.provide(DatabaseService.notAvailable),\n Layer.provide(QueueService.notAvailable),\n );\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Schema from 'effect/Schema';\n\nimport { AiService } from '@dxos/ai';\nimport { todo } from '@dxos/debug';\nimport { log } from '@dxos/log';\n\nimport { FunctionError, FunctionNotFoundError } from '../errors';\nimport type { FunctionContext, FunctionDefinition } from '../handler';\n\nimport { CredentialsService } from './credentials';\nimport { DatabaseService } from './database';\nimport { type ComputeEventLogger } from './event-logger';\nimport { QueueService } from './queues';\nimport { RemoteFunctionExecutionService } from './remote-function-execution-service';\nimport { type Services } from './service-container';\nimport { type TracingService } from './tracing';\n\n/**\n * Services that are provided at the function call site.\n */\nexport type InvocationServices = TracingService | ComputeEventLogger;\n\nexport class LocalFunctionExecutionService extends Context.Tag('@dxos/functions/LocalFunctionExecutionService')<\n LocalFunctionExecutionService,\n {\n // TODO(dmaretskyi): This should take function id instead of the definition object.\n // TODO(dmaretskyi): Services should be satisfied from environment rather then bubbled up.\n invokeFunction<I, O>(functionDef: FunctionDefinition<I, O>, input: I): Effect.Effect<O, never, InvocationServices>;\n }\n>() {\n static layerLive = Layer.effect(\n LocalFunctionExecutionService,\n Effect.gen(function* () {\n // TODO(dmaretskyi): Use `yield* Effect.context()`;\n const resolver = yield* FunctionImplementationResolver;\n const ai = yield* AiService.AiService;\n const credentials = yield* CredentialsService;\n const database = yield* DatabaseService;\n const queues = yield* QueueService;\n // TODO(mykola): Delete, should not be required for local execution.\n const functionCallService = yield* RemoteFunctionExecutionService;\n return {\n // TODO(dmaretskyi): Better error types.\n invokeFunction: <I, O>(\n functionDef: FunctionDefinition<I, O>,\n input: I,\n ): Effect.Effect<O, never, InvocationServices> =>\n Effect.gen(function* () {\n const resolved = yield* resolver.resolveFunctionImplementation(functionDef).pipe(Effect.orDie);\n const output = yield* invokeFunction(resolved, input);\n return output as O;\n }).pipe(\n Effect.provideService(AiService.AiService, ai),\n Effect.provideService(CredentialsService, credentials),\n Effect.provideService(DatabaseService, database),\n Effect.provideService(QueueService, queues),\n Effect.provideService(RemoteFunctionExecutionService, functionCallService),\n ),\n };\n }),\n );\n\n static invokeFunction: <F extends FunctionDefinition.Any>(\n functionDef: F,\n input: FunctionDefinition.Input<F>,\n ) => Effect.Effect<FunctionDefinition.Output<F>, never, Services | LocalFunctionExecutionService> =\n Effect.serviceFunctionEffect(LocalFunctionExecutionService, (_) => _.invokeFunction as any);\n}\n\nconst invokeFunction = (\n functionDef: FunctionDefinition<any, any>,\n input: any,\n): Effect.Effect<unknown, never, Services> =>\n Effect.gen(function* () {\n // Assert input matches schema.\n try {\n const assertInput = functionDef.inputSchema.pipe(Schema.asserts);\n (assertInput as any)(input);\n } catch (e) {\n throw new FunctionError({ message: 'Invalid function input', context: { name: functionDef.name }, cause: e });\n }\n\n const context: FunctionContext = {\n space: undefined,\n getService: () => todo(),\n getSpace: async (_spaceId: any) => {\n throw new Error('Not available. Use the database service instead.');\n },\n };\n\n log.info('invoking function', { name: functionDef.name, input });\n\n // TODO(dmaretskyi): This should be delegated to a function invoker service.\n const data = yield* Effect.gen(function* () {\n const result = functionDef.handler({ context, data: input });\n if (Effect.isEffect(result)) {\n return yield* (result as Effect.Effect<unknown, unknown, Services>).pipe(Effect.orDie);\n } else if (\n typeof result === 'object' &&\n result !== null &&\n 'then' in result &&\n typeof result.then === 'function'\n ) {\n return yield* Effect.promise(() => result);\n } else {\n return result;\n }\n }).pipe(\n Effect.orDie,\n Effect.catchAllDefect((defect) =>\n Effect.die(new FunctionError({ context: { name: functionDef.name }, cause: defect })),\n ),\n );\n\n log.info('completed', { function: functionDef.name, input, data });\n\n // Assert output matches schema.\n try {\n const assertOutput = functionDef.outputSchema?.pipe(Schema.asserts);\n (assertOutput as any)(data);\n } catch (e) {\n throw new FunctionError({ message: 'Invalid function output', context: { name: functionDef.name }, cause: e });\n }\n\n return data;\n }).pipe(Effect.withSpan('invokeFunction', { attributes: { name: functionDef.name } }));\n\nexport class FunctionImplementationResolver extends Context.Tag('@dxos/functions/FunctionImplementationResolver')<\n FunctionImplementationResolver,\n {\n resolveFunctionImplementation<I, O>(\n functionDef: FunctionDefinition<I, O>,\n ): Effect.Effect<FunctionDefinition<I, O>, FunctionNotFoundError>;\n }\n>() {\n static layerTest = ({ functions }: { functions: readonly FunctionDefinition<any, any>[] }) =>\n Layer.succeed(FunctionImplementationResolver, {\n resolveFunctionImplementation: <I, O>(functionDef: FunctionDefinition<I, O>) => {\n const resolved = functions.find((f) => f.key === functionDef.key);\n if (!resolved) {\n return Effect.fail(new FunctionNotFoundError(functionDef.name));\n }\n return Effect.succeed(resolved);\n },\n });\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { type Ref, Type } from '@dxos/echo';\nimport { ObjectId } from '@dxos/echo/internal';\nimport { Queue } from '@dxos/echo-db';\nimport { log } from '@dxos/log';\n\nimport { Trigger } 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 timestamp: 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 timestamp: 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: Schema.optional(Type.Ref(Queue)),\n /**\n * DXN of the invoked function/workflow.\n */\n invocationTarget: Schema.optional(Type.Ref(Type.Expando)),\n /**\n * Present for automatic invocations.\n */\n trigger: Schema.optional(Type.Ref(Trigger.Trigger)),\n}).pipe(Type.Obj({ 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 timestamp: Schema.Number,\n outcome: Schema.Enums(InvocationOutcome),\n exception: Schema.optional(TraceEventException),\n}).pipe(Type.Obj({ 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 timestamp: 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 /** Time when the event was persisted. */\n ingestionTimestamp: Schema.Number,\n logs: Schema.Array(TraceEventLog),\n exceptions: Schema.Array(TraceEventException),\n}).pipe(Type.Obj({ typename: 'dxos.org/type/TraceEvent', version: '0.1.0' }));\n\nexport type TraceEvent = Schema.Schema.Type<typeof TraceEvent>;\n\n/**\n * InvocationTrace event format.\n * This is the combined format of InvocationTraceStartEvent and InvocationTraceEndEvents for UI consumption.\n */\nexport type InvocationSpan = {\n id: string;\n timestamp: number;\n duration: number;\n outcome: InvocationOutcome;\n input: object;\n invocationTraceQueue?: Ref.Ref<Queue>;\n invocationTarget?: Ref.Ref<Type.Expando>;\n trigger?: Ref.Ref<Trigger.Trigger>;\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 timestamp: start.timestamp,\n duration: isInProgress ? now - start.timestamp : end!.timestamp - start.timestamp,\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 2025 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\n\nimport { Obj, Ref } from '@dxos/echo';\nimport { type Queue } from '@dxos/echo-db';\nimport { DXN, ObjectId } from '@dxos/keys';\n\nimport { QueueService } from '../services';\nimport {\n InvocationOutcome,\n InvocationTraceEndEvent,\n InvocationTraceEventType,\n InvocationTraceStartEvent,\n} from '../trace';\nimport type { Trigger } from '../types';\n\nexport type FunctionInvocationPayload = {\n data?: any;\n inputNodeId?: string;\n trigger?: {\n id: string;\n kind: Trigger.Kind;\n };\n};\n\nexport type TraceData = {\n invocationId: ObjectId;\n invocationTraceQueue: Queue;\n};\n\nexport class InvocationTracer extends Context.Tag('@dxos/functions/InvocationTracer')<\n InvocationTracer,\n {\n traceInvocationStart({\n payload,\n target,\n }: {\n payload: FunctionInvocationPayload;\n target?: DXN;\n }): Effect.Effect<TraceData, never, QueueService>;\n\n traceInvocationEnd({ trace, exception }: { trace: TraceData; exception?: any }): Effect.Effect<void>;\n }\n>() {\n static layerLive = (opts: { invocationTraceQueue: Queue }) =>\n Layer.effect(\n InvocationTracer,\n Effect.gen(function* () {\n return {\n traceInvocationStart: Effect.fn('traceInvocationStart')(function* ({ payload, target }) {\n const invocationId = ObjectId.random();\n const invocationTraceQueue = yield* QueueService.createQueue({ subspaceTag: 'trace' });\n const now = Date.now();\n const traceEvent = Obj.make(InvocationTraceStartEvent, {\n type: InvocationTraceEventType.START,\n invocationId,\n timestamp: now,\n // TODO(dmaretskyi): Not json-stringifying this makes ECHO fail when one ECHO object becomes embedded in another ECHO object.\n input: JSON.parse(JSON.stringify(payload.data ?? {})),\n invocationTraceQueue: Ref.fromDXN(invocationTraceQueue.dxn),\n invocationTarget: target ? Ref.fromDXN(target) : undefined,\n trigger: payload.trigger ? Ref.fromDXN(DXN.fromLocalObjectId(payload.trigger.id)) : undefined,\n });\n yield* QueueService.append(opts.invocationTraceQueue, [traceEvent]);\n\n return { invocationId, invocationTraceQueue };\n }),\n traceInvocationEnd: Effect.fn('traceInvocationEnd')(function* ({ trace, exception }) {\n const now = Date.now();\n const traceEvent = Obj.make(InvocationTraceEndEvent, {\n type: InvocationTraceEventType.END,\n invocationId: trace.invocationId,\n timestamp: now,\n outcome: exception ? InvocationOutcome.FAILURE : InvocationOutcome.SUCCESS,\n exception: exception\n ? {\n name: exception.constructor.name,\n timestamp: now,\n message: exception?.message ?? 'Unknown error',\n stack: exception?.stack,\n }\n : undefined,\n });\n yield* QueueService.append(opts.invocationTraceQueue, [traceEvent]);\n }),\n };\n }),\n );\n\n static layerTest = Layer.unwrapEffect(\n Effect.gen(function* () {\n const queue = yield* QueueService.createQueue({ subspaceTag: 'trace' });\n return InvocationTracer.layerLive({ invocationTraceQueue: queue });\n }),\n );\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Cause from 'effect/Cause';\nimport * as Context from 'effect/Context';\nimport * as Cron from 'effect/Cron';\nimport * as Duration from 'effect/Duration';\nimport * as Effect from 'effect/Effect';\nimport * as Either from 'effect/Either';\nimport * as Exit from 'effect/Exit';\nimport * as Fiber from 'effect/Fiber';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\nimport * as Record from 'effect/Record';\nimport * as Schedule from 'effect/Schedule';\n\nimport { DXN, Filter, Obj, Query } from '@dxos/echo';\nimport { causeToError } from '@dxos/effect';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\nimport { KEY_QUEUE_POSITION } from '@dxos/protocols';\n\nimport { deserializeFunction } from '../handler';\nimport {\n ComputeEventLogger,\n DatabaseService,\n FunctionInvocationService,\n QueueService,\n TracingService,\n} from '../services';\nimport { Function, Trigger, type TriggerEvent } from '../types';\n\nimport { createInvocationPayload } from './input-builder';\nimport { InvocationTracer } from './invocation-tracer';\nimport { type TriggerState, TriggerStateStore } from './trigger-state-store';\n\nexport type TimeControl = 'natural' | 'manual';\n\nexport interface TriggerDispatcherOptions {\n /**\n * Time control mode.\n * - 'natural': Use real time.\n * - 'manual': Use internal clock for testing.\n */\n timeControl: TimeControl;\n\n /**\n * Starting time for manual time control mode.\n * @default current time\n */\n startingTime?: Date;\n\n /**\n * Poll interval for cron triggers in 'natural' time control mode.\n * @default 1 second\n */\n livePollInterval?: Duration.Duration;\n}\n\nexport interface InvokeTriggerOptions {\n trigger: Trigger.Trigger;\n event: TriggerEvent.TriggerEvent;\n}\nexport interface TriggerExecutionResult {\n triggerId: string;\n result: Exit.Exit<unknown>;\n}\n\n/**\n * Cront trigger runtime state.\n */\ninterface ScheduledTrigger {\n trigger: Trigger.Trigger;\n cron: Cron.Cron;\n nextExecution: Date;\n}\n\n// TODO(dmaretskyi): Refactor service management.\ntype TriggerDispatcherServices =\n | FunctionInvocationService\n // TODO(dmaretskyi): Move those into layer deps.\n | TriggerStateStore\n | InvocationTracer\n | QueueService\n | DatabaseService;\n\nexport class TriggerDispatcher extends Context.Tag('@dxos/functions/TriggerDispatcher')<\n TriggerDispatcher,\n {\n readonly timeControl: TimeControl;\n\n get running(): boolean;\n\n /**\n * Start the trigger dispatcher.\n * Will automatically invoke triggers.\n */\n start(): Effect.Effect<void, never, TriggerDispatcherServices>;\n\n /**\n * Stop the trigger dispatcher.\n */\n stop(): Effect.Effect<void>;\n\n /**\n * Refresh triggers.\n */\n refreshTriggers(): Effect.Effect<void, never, DatabaseService>;\n\n /**\n * Manually invoke a specific trigger.\n */\n invokeTrigger(\n options: InvokeTriggerOptions,\n ): Effect.Effect<TriggerExecutionResult, never, TriggerDispatcherServices>;\n\n /**\n * Invoke all scheduled triggers who are due.\n */\n invokeScheduledTriggers(opts?: {\n kinds?: Trigger.Kind[];\n }): Effect.Effect<TriggerExecutionResult[], never, TriggerDispatcherServices>;\n\n /**\n * Advance the internal clock (manual time control only).\n * Note: Does not invoke triggers.\n */\n advanceTime(duration: Duration.Duration): Effect.Effect<void>;\n\n /**\n * Get current time based on time control mode.\n */\n getCurrentTime(): Date;\n }\n>() {\n static layer = (options: Omit<TriggerDispatcherOptions, 'database'>) =>\n Layer.effect(\n TriggerDispatcher,\n Effect.gen(function* () {\n return new TriggerDispatcherImpl(options);\n }),\n );\n}\n\nclass TriggerDispatcherImpl implements Context.Tag.Service<TriggerDispatcher> {\n readonly livePollInterval: Duration.Duration;\n readonly timeControl: TimeControl;\n\n private _running = false;\n private _internalTime: Date;\n private _timerFiber: Fiber.Fiber<void, void> | undefined;\n private _scheduledTriggers = new Map<string, ScheduledTrigger>();\n\n constructor(options: TriggerDispatcherOptions) {\n this.timeControl = options.timeControl;\n this.livePollInterval = options.livePollInterval ?? Duration.seconds(1);\n this._internalTime = options.startingTime ?? new Date();\n }\n\n get running(): boolean {\n return this._running;\n }\n\n start = (): Effect.Effect<void, never, TriggerDispatcherServices> =>\n Effect.gen(this, function* () {\n if (this._running) {\n return;\n }\n\n this._running = true;\n\n // Start natural time processing if enabled\n if (this.timeControl === 'natural') {\n this._timerFiber = yield* this._startNaturalTimeProcessing().pipe(\n Effect.tapErrorCause((cause) => {\n const error = causeToError(cause);\n log.error('trigger dispatcher error', { error });\n this._running = false;\n return Effect.void;\n }),\n Effect.forkDaemon,\n );\n } else {\n return yield* Effect.dieMessage('TriggerDispatcher started in manual time control mode');\n }\n\n log.info('TriggerDispatcher started', { timeControl: this.timeControl });\n });\n\n stop = (): Effect.Effect<void> =>\n Effect.gen(this, function* () {\n if (!this._running) {\n return;\n }\n\n this._running = false;\n\n // Stop timer processing\n if (this._timerFiber) {\n yield* Fiber.interrupt(this._timerFiber);\n this._timerFiber = undefined;\n }\n\n // Clear scheduled triggers\n this._scheduledTriggers.clear();\n\n log.info('TriggerDispatcher stopped');\n });\n\n invokeTrigger = (\n options: InvokeTriggerOptions,\n ): Effect.Effect<TriggerExecutionResult, never, TriggerDispatcherServices> =>\n Effect.gen(this, function* () {\n const { trigger, event } = options;\n log.info('running trigger', { triggerId: trigger.id, spec: trigger.spec, event });\n\n const tracer = yield* InvocationTracer;\n const trace = yield* tracer.traceInvocationStart({\n target: trigger.function?.dxn,\n payload: {\n trigger: {\n id: trigger.id,\n // TODO(dmaretskyi): Is `spec` always there>\n kind: trigger.spec!.kind,\n },\n data: event,\n },\n });\n\n // Sandboxed section.\n const result = yield* Effect.gen(this, function* () {\n if (!trigger.enabled) {\n return yield* Effect.dieMessage('Attempting to invoke disabled trigger');\n }\n\n if (!trigger.function) {\n return yield* Effect.dieMessage('Trigger has no function reference');\n }\n\n // Resolve the function\n const serialiedFunction = yield* DatabaseService.load(trigger.function!).pipe(Effect.orDie);\n invariant(Obj.instanceOf(Function.Function, serialiedFunction));\n const functionDef = deserializeFunction(serialiedFunction);\n\n // Prepare input data\n const inputData = this._prepareInputData(trigger, event);\n\n // Invoke the function\n return yield* FunctionInvocationService.invokeFunction(functionDef, inputData).pipe(\n Effect.provide(\n ComputeEventLogger.layerFromTracing.pipe(\n Layer.provideMerge(TracingService.layerQueue(trace.invocationTraceQueue)),\n ),\n ),\n );\n }).pipe(Effect.exit);\n\n const triggerExecutionResult: TriggerExecutionResult = {\n triggerId: trigger.id,\n result,\n };\n if (Exit.isSuccess(result)) {\n log.info('trigger execution success', {\n triggerId: trigger.id,\n });\n } else {\n log.error('trigger execution failure', {\n error: causeToError(result.cause),\n });\n }\n yield* tracer.traceInvocationEnd({\n trace,\n // TODO(dmaretskyi): Might miss errors.\n exception: Exit.isFailure(result) ? Cause.prettyErrors(result.cause)[0] : undefined,\n });\n return triggerExecutionResult;\n });\n\n invokeScheduledTriggers = ({ kinds = ['timer', 'queue', 'subscription'] } = {}): Effect.Effect<\n TriggerExecutionResult[],\n never,\n TriggerDispatcherServices\n > =>\n Effect.gen(this, function* () {\n const invocations: TriggerExecutionResult[] = [];\n for (const kind of kinds) {\n switch (kind) {\n case 'timer':\n {\n yield* this.refreshTriggers();\n const now = this.getCurrentTime();\n const triggersToInvoke: Trigger.Trigger[] = [];\n\n for (const [triggerId, scheduledTrigger] of this._scheduledTriggers.entries()) {\n if (scheduledTrigger.nextExecution <= now) {\n triggersToInvoke.push(scheduledTrigger.trigger);\n\n // Update next execution time using Effect's Cron\n scheduledTrigger.nextExecution = Cron.next(scheduledTrigger.cron, now);\n }\n }\n\n // Invoke all due triggers\n invocations.push(\n ...(yield* Effect.forEach(\n triggersToInvoke,\n (trigger) =>\n this.invokeTrigger({\n trigger,\n event: { tick: now.getTime() } satisfies TriggerEvent.TimerEvent,\n }),\n { concurrency: 1 },\n )),\n );\n }\n break;\n case 'queue': {\n const triggers = yield* this._fetchTriggers();\n for (const trigger of triggers) {\n const spec = trigger.spec;\n if (spec?.kind !== 'queue') {\n continue;\n }\n const cursor = Obj.getKeys(trigger, KEY_QUEUE_CURSOR).at(0)?.id;\n const queue = yield* QueueService.getQueue(DXN.parse(spec.queue));\n\n // TODO(dmaretskyi): Include cursor & limit in the query.\n const objects = yield* Effect.promise(() => queue.queryObjects());\n for (const object of objects) {\n const objectPos = Obj.getKeys(object, KEY_QUEUE_POSITION).at(0)?.id;\n // TODO(dmaretskyi): Extract methods for managing queue position.\n if (!objectPos || (cursor && parseInt(cursor) >= parseInt(objectPos))) {\n continue;\n }\n\n invocations.push(\n yield* this.invokeTrigger({\n trigger,\n event: {\n queue: spec.queue,\n item: object,\n cursor: objectPos,\n } satisfies TriggerEvent.QueueEvent,\n }),\n );\n\n // Update trigger cursor.\n Obj.deleteKeys(trigger, KEY_QUEUE_CURSOR);\n Obj.getMeta(trigger).keys.push({ source: KEY_QUEUE_CURSOR, id: objectPos });\n yield* DatabaseService.flush();\n\n // We only invoke one trigger for each queue at a time.\n break;\n }\n }\n break;\n }\n case 'subscription': {\n const triggers = yield* this._fetchTriggers();\n for (const trigger of triggers) {\n const spec = Obj.getSnapshot(trigger).spec;\n if (spec?.kind !== 'subscription') {\n continue;\n }\n\n const { objects } = yield* DatabaseService.runQuery(Query.fromAst(spec.query.ast));\n\n const state: TriggerState = yield* TriggerStateStore.getState(trigger.id).pipe(\n Effect.catchTag('TRIGGER_STATE_NOT_FOUND', () =>\n Effect.succeed({\n version: '1',\n triggerId: trigger.id,\n state: {\n _tag: 'subscription',\n processedVersions: {} as Record<string, string>,\n },\n } satisfies TriggerState),\n ),\n );\n invariant(state.state?._tag === 'subscription');\n\n let updated = false;\n for (const object of objects) {\n const existingVersion = Record.get(state.state.processedVersions, object.id).pipe(\n Option.map(Obj.decodeVersion),\n );\n const currentVersion = Obj.version(object);\n const run =\n Option.isNone(existingVersion) ||\n Obj.compareVersions(currentVersion, existingVersion.value) === 'different';\n\n if (!run) {\n continue;\n }\n\n const { db } = yield* DatabaseService;\n invocations.push(\n yield* this.invokeTrigger({\n trigger,\n event: {\n // TODO(dmaretskyi): Change type not supported.\n type: 'unknown',\n\n subject: db.ref(Obj.getDXN(object)),\n\n changedObjectId: object.id,\n } satisfies TriggerEvent.SubscriptionEvent,\n }),\n );\n (state.state.processedVersions as any)[object.id] = Obj.encodeVersion(currentVersion);\n updated = true;\n }\n\n if (updated) {\n yield* TriggerStateStore.saveState(state);\n }\n }\n break;\n }\n default: {\n return yield* Effect.dieMessage(`Unknown trigger kind: ${kind}`);\n }\n }\n }\n return invocations;\n });\n\n advanceTime = (duration: Duration.Duration): Effect.Effect<void> =>\n Effect.gen(this, function* () {\n if (this.timeControl !== 'manual') {\n return yield* Effect.dieMessage('advanceTime can only be used in manual time control mode');\n }\n\n const millis = Duration.toMillis(duration);\n this._internalTime = new Date(this._internalTime.getTime() + millis);\n\n log('Advanced internal time', {\n newTime: this._internalTime,\n advancedBy: Duration.format(duration),\n });\n }).pipe(Effect.orDie);\n\n getCurrentTime = (): Date => {\n if (this.timeControl === 'natural') {\n return new Date();\n } else {\n return new Date(this._internalTime);\n }\n };\n\n refreshTriggers = (): Effect.Effect<void, never, DatabaseService> =>\n Effect.gen(this, function* () {\n const triggers = yield* this._fetchTriggers();\n const currentTriggerIds = new Set(triggers.map((t) => t.id));\n\n // Remove triggers that are no longer present\n for (const triggerId of this._scheduledTriggers.keys()) {\n if (!currentTriggerIds.has(triggerId)) {\n this._scheduledTriggers.delete(triggerId);\n }\n }\n\n // Add or update triggers\n for (const trigger of triggers) {\n if (trigger.spec?.kind === 'timer' && trigger.enabled) {\n const timerSpec = trigger.spec as Trigger.TimerSpec;\n\n // Parse cron expression using Effect's Cron module\n const cronEither = Cron.parse(timerSpec.cron);\n\n if (Either.isRight(cronEither)) {\n const cron = cronEither.right;\n const existing = this._scheduledTriggers.get(trigger.id);\n const now = this.getCurrentTime();\n const nextExecution = existing?.nextExecution ?? Cron.next(cron, now);\n\n log('Updated scheduled trigger', {\n triggerId: trigger.id,\n cron: timerSpec.cron,\n nextExecution,\n now,\n });\n this._scheduledTriggers.set(trigger.id, {\n trigger,\n cron,\n nextExecution,\n });\n } else {\n log.error('Invalid cron expression', {\n triggerId: trigger.id,\n cron: timerSpec.cron,\n error: cronEither.left.message,\n });\n }\n }\n }\n\n log('Updated scheduled triggers', { count: this._scheduledTriggers.size });\n }).pipe(Effect.withSpan('TriggerDispatcher.refreshTriggers'));\n\n private _fetchTriggers = () =>\n Effect.gen(this, function* () {\n const { objects } = yield* DatabaseService.runQuery(Filter.type(Trigger.Trigger));\n return objects;\n }).pipe(Effect.withSpan('TriggerDispatcher.fetchTriggers'));\n\n private _startNaturalTimeProcessing = (): Effect.Effect<void, never, TriggerDispatcherServices> =>\n Effect.gen(this, function* () {\n yield* this.invokeScheduledTriggers();\n }).pipe(Effect.repeat(Schedule.fixed(this.livePollInterval)), Effect.asVoid);\n\n private _prepareInputData = (trigger: Trigger.Trigger, event: TriggerEvent.TriggerEvent): any => {\n return createInvocationPayload(trigger, event);\n };\n}\n\n/**\n * Key for the current queue cursor for queue triggers.\n */\nconst KEY_QUEUE_CURSOR = 'dxos.org/key/local-trigger-dispatcher/queue-cursor';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Trigger, type TriggerEvent } from '../types';\n\nexport const createInvocationPayload = (trigger: Trigger.Trigger, event: TriggerEvent.TriggerEvent): any => {\n if (!trigger.input) {\n return event;\n }\n\n const payload: any = {};\n for (const [key, value] of Object.entries(trigger.input)) {\n if (typeof value !== 'string' || !(value.startsWith('{{') && value.endsWith('}}'))) {\n payload[key] = value;\n continue;\n }\n\n const propertyPath = value.slice(2, -2);\n let valueSubstitution: any = propertyPath.startsWith('trigger.')\n ? trigger\n : propertyPath.startsWith('event.')\n ? event\n : undefined;\n\n for (const pathSegment of propertyPath.split('.').slice(1)) {\n if (valueSubstitution && typeof valueSubstitution === 'object') {\n valueSubstitution = valueSubstitution[pathSegment];\n }\n }\n\n payload[key] = valueSubstitution;\n }\n return payload;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as KeyValueStore from '@effect/platform/KeyValueStore';\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\n\nimport { ObjectId } from '@dxos/keys';\n\nimport { TriggerStateNotFoundError } from '../errors';\n\nexport const TriggerState = Schema.Struct({\n version: Schema.Literal('1'),\n triggerId: Schema.String,\n state: Schema.optional(\n Schema.Union(\n Schema.TaggedStruct('subscription', {\n processedVersions: Schema.Record({ key: ObjectId, value: Schema.String }),\n }),\n ),\n ),\n});\nexport interface TriggerState extends Schema.Schema.Type<typeof TriggerState> {}\n\nexport class TriggerStateStore extends Context.Tag('@dxos/functions/TriggerStateStore')<\n TriggerStateStore,\n {\n getState(triggerId: ObjectId): Effect.Effect<TriggerState, TriggerStateNotFoundError>;\n saveState(state: TriggerState): Effect.Effect<void>;\n }\n>() {\n static getState = Effect.serviceFunctionEffect(TriggerStateStore, (_) => _.getState);\n static saveState = Effect.serviceFunctionEffect(TriggerStateStore, (_) => _.saveState);\n\n static layerKv = Layer.effect(\n TriggerStateStore,\n Effect.gen(function* () {\n const kv = yield* KeyValueStore.KeyValueStore;\n const schemaStore = kv.forSchema(Schema.parseJson(TriggerState));\n const store: Context.Tag.Service<TriggerStateStore> = {\n getState: Effect.fn('TriggerStateStore.getState')(function* (triggerId: ObjectId) {\n const valueOption = yield* schemaStore.get(triggerId).pipe(Effect.orDie);\n if (Option.isNone(valueOption)) {\n return yield* Effect.fail(new TriggerStateNotFoundError());\n }\n return valueOption.value;\n }),\n saveState: Effect.fn('TriggerStateStore.saveState')(function* (state: TriggerState) {\n yield* schemaStore.set(state.triggerId, state).pipe(Effect.orDie);\n }),\n };\n return store;\n }),\n );\n\n static layerMemory = TriggerStateStore.layerKv.pipe(Layer.provide(KeyValueStore.layerMemory));\n}\n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EAAE;AACvD,gBAAM8C,MAAM,KAAKC,eAAc;AAC/B,gBAAMI,gBAAgBgF,UAAUhF,iBAAsBE,UAAKC,MAAMR,GAAAA;AAEjE3D,UAAAA,KAAI,6BAA6B;YAC/BY,WAAWF,QAAQG;YACnBsD,MAAMyE,UAAUzE;YAChBH;YACAL;UACF,GAAA;;;;;;AACA,eAAKxE,mBAAmB8J,IAAIvI,QAAQG,IAAI;YACtCH;YACAyD;YACAH;UACF,CAAA;QACF,OAAO;AACLhE,UAAAA,KAAIF,MAAM,2BAA2B;YACnCc,WAAWF,QAAQG;YACnBsD,MAAMyE,UAAUzE;YAChBrE,OAAO+I,WAAWK,KAAKC;UACzB,GAAA;;;;;;QACF;MACF;IACF;AAEAnJ,IAAAA,KAAI,8BAA8B;MAAEoJ,OAAO,KAAKjK,mBAAmBkK;IAAK,GAAA;;;;;;EAC1E,CAAA,EAAG1J,KAAY2J,kBAAS,mCAAA,CAAA;EAElB7E,iBAAiB,MAChB7F,aAAI,MAAM,aAAA;AACf,UAAM,EAAEuG,QAAO,IAAK,OAAOvD,gBAAgBqE,SAASsD,OAAO9B,KAAK+B,gBAAQA,OAAO,CAAA;AAC/E,WAAOrE;EACT,CAAA,EAAGxF,KAAY2J,kBAAS,iCAAA,CAAA;EAElB5J,8BAA8B,MAC7Bd,aAAI,MAAM,aAAA;AACf,WAAO,KAAK2E,wBAAuB;EACrC,CAAA,EAAG5D,KAAY8J,gBAAgBC,eAAM,KAAK5K,gBAAgB,CAAA,GAAW6K,eAAM;EAErErH,oBAAoB,CAAC5B,SAA0BC,UAAAA;AACrD,WAAOiJ,wBAAwBlJ,SAASC,KAAAA;EAC1C;AACF;AAKA,IAAMiE,mBAAmB;",
6
- "names": ["Effect", "Schema", "Effect", "Schema", "Obj", "Type", "assertArgument", "make", "Schema", "Obj", "Type", "JsonSchemaType", "LabelAnnotation", "Ref", "Schema", "Obj", "Ref", "Type", "FormAnnotation", "LabelAnnotation", "DataType", "Script", "Struct", "name", "String", "pipe", "optional", "description", "changed", "Boolean", "FormAnnotation", "set", "source", "Type", "Ref", "DataType", "Text", "Obj", "typename", "version", "LabelAnnotation", "make", "props", "makeText", "Function", "Struct", "key", "optional", "String", "annotations", "description", "name", "NonEmptyString", "version", "source", "Ref", "Script", "inputSchema", "JsonSchemaType", "outputSchema", "binding", "pipe", "Type", "Obj", "typename", "LabelAnnotation", "set", "make", "props", "make", "Schema", "SchemaAST", "Obj", "QueryAST", "Type", "Expando", "OptionsAnnotationId", "Ref", "DXN", "Kinds", "kindLiteralAnnotations", "title", "EmailSpec", "Struct", "kind", "Literal", "annotations", "pipe", "mutable", "QueueSpec", "queue", "DXN", "Schema", "SubscriptionSpec", "query", "raw", "optional", "String", "ast", "QueryAST", "Query", "options", "deep", "Boolean", "delay", "Number", "TimerSpec", "cron", "ExamplesAnnotationId", "WebhookSpec", "method", "OptionsAnnotationId", "port", "Spec", "Union", "Trigger_", "function", "Ref", "Expando", "inputNodeId", "enabled", "spec", "input", "Record", "key", "value", "Any", "Type", "Obj", "typename", "version", "Trigger", "make", "props", "Schema", "DXN", "Obj", "Type", "EmailEvent", "mutable", "Struct", "from", "String", "to", "subject", "created", "body", "QueueEvent", "queue", "DXN", "Schema", "item", "Any", "cursor", "SubscriptionEvent", "type", "Type", "Ref", "Obj", "changedObjectId", "optional", "pipe", "TimerEvent", "tick", "Number", "WebhookEvent", "url", "method", "Literal", "headers", "Record", "key", "value", "bodyText", "typeId", "Symbol", "for", "defineFunction", "key", "name", "description", "inputSchema", "outputSchema", "Any", "handler", "isSchema", "Error", "limit", "stackTraceLimit", "traceError", "cache", "captureStackTrace", "stack", "undefined", "split", "trim", "handlerWithSpan", "args", "result", "isEffect", "withSpan", "FunctionDefinition", "make", "isFunction", "value", "serialize", "functionDef", "assertArgument", "serializeFunction", "deserialize", "functionObj", "Obj", "instanceOf", "Function", "deserializeFunction", "fn", "version", "Type", "toJsonSchema", "meta", "deployedFunctionId", "setUserFunctionIdInMetadata", "getMeta", "Unknown", "toEffectSchema", "getUserFunctionIdInMetadata", "defineFunction", "key", "name", "description", "inputSchema", "Struct", "iterations", "optional", "Number", "annotations", "default", "outputSchema", "result", "String", "handler", "fn", "data", "a", "b", "i", "toString", "Console", "Effect", "Schema", "defineFunction", "key", "name", "description", "inputSchema", "Any", "outputSchema", "handler", "fn", "data", "log", "Effect", "Schema", "defineFunction", "key", "name", "description", "inputSchema", "Struct", "duration", "optional", "Number", "annotations", "default", "outputSchema", "Void", "handler", "fn", "data", "sleep", "Example", "fib", "fib$", "reply", "reply$", "sleep", "sleep$", "Effect", "Schema", "runAndForwardErrors", "FunctionExecutor", "_services", "invoke", "functionDef", "input", "assertInput", "inputSchema", "pipe", "asserts", "context", "space", "undefined", "getService", "bind", "getSpace", "_spaceId", "Error", "result", "handler", "data", "isEffect", "provide", "createLayer", "runAndForwardErrors", "assertOutput", "outputSchema", "Context", "Effect", "Layer", "AiService", "Context", "Effect", "Layer", "Schema", "AiService", "todo", "log", "LocalFunctionExecutionService", "Tag", "layerLive", "effect", "gen", "resolver", "FunctionImplementationResolver", "ai", "AiService", "credentials", "CredentialsService", "database", "DatabaseService", "queues", "QueueService", "functionCallService", "RemoteFunctionExecutionService", "invokeFunction", "functionDef", "input", "resolved", "resolveFunctionImplementation", "pipe", "orDie", "output", "provideService", "serviceFunctionEffect", "_", "assertInput", "inputSchema", "asserts", "e", "FunctionError", "message", "context", "name", "cause", "space", "undefined", "getService", "todo", "getSpace", "_spaceId", "Error", "log", "info", "data", "result", "handler", "isEffect", "then", "promise", "catchAllDefect", "defect", "die", "function", "assertOutput", "outputSchema", "withSpan", "attributes", "layerTest", "functions", "succeed", "find", "f", "key", "fail", "FunctionNotFoundError", "FunctionInvocationService", "Tag", "invokeFunction", "serviceFunctionEffect", "_", "layer", "effect", "gen", "localExecutioner", "LocalFunctionExecutionService", "remoteExecutioner", "RemoteFunctionExecutionService", "functionDef", "input", "meta", "deployedFunctionId", "callFunction", "layerTest", "functions", "pipe", "provide", "layerLive", "FunctionImplementationResolver", "layerMock", "layerTestMocked", "AiService", "notAvailable", "CredentialsService", "configuredLayer", "DatabaseService", "QueueService", "Schema", "Type", "ObjectId", "Queue", "log", "InvocationOutcome", "InvocationTraceEventType", "TraceEventException", "Struct", "timestamp", "Number", "message", "String", "name", "stack", "optional", "InvocationTraceStartEvent", "id", "ObjectId", "type", "Literal", "invocationId", "input", "Object", "invocationTraceQueue", "Type", "Ref", "Queue", "invocationTarget", "Expando", "trigger", "Trigger", "pipe", "Obj", "typename", "version", "InvocationTraceEndEvent", "outcome", "Enums", "exception", "TraceEventLog", "level", "context", "TraceEvent", "truncated", "Boolean", "ingestionTimestamp", "logs", "Array", "exceptions", "createInvocationSpans", "items", "eventsByInvocationId", "Map", "event", "entry", "get", "start", "undefined", "end", "set", "now", "Date", "result", "entries", "log", "warn", "isInProgress", "push", "duration", "Context", "Effect", "Layer", "Obj", "Ref", "DXN", "ObjectId", "InvocationTracer", "Tag", "layerLive", "opts", "effect", "gen", "traceInvocationStart", "fn", "payload", "target", "invocationId", "ObjectId", "random", "invocationTraceQueue", "QueueService", "createQueue", "subspaceTag", "now", "Date", "traceEvent", "Obj", "make", "InvocationTraceStartEvent", "type", "InvocationTraceEventType", "START", "timestamp", "input", "JSON", "parse", "stringify", "data", "Ref", "fromDXN", "dxn", "invocationTarget", "undefined", "trigger", "DXN", "fromLocalObjectId", "id", "append", "traceInvocationEnd", "trace", "exception", "InvocationTraceEndEvent", "END", "outcome", "InvocationOutcome", "FAILURE", "SUCCESS", "name", "message", "stack", "layerTest", "unwrapEffect", "queue", "Cause", "Context", "Cron", "Duration", "Effect", "Either", "Exit", "Fiber", "Layer", "Option", "Record", "Schedule", "DXN", "Filter", "Obj", "Query", "causeToError", "invariant", "log", "KEY_QUEUE_POSITION", "createInvocationPayload", "trigger", "event", "input", "payload", "key", "value", "Object", "entries", "startsWith", "endsWith", "propertyPath", "slice", "valueSubstitution", "undefined", "pathSegment", "split", "KeyValueStore", "Context", "Effect", "Layer", "Option", "Schema", "ObjectId", "TriggerState", "Struct", "version", "Literal", "triggerId", "String", "state", "optional", "Union", "TaggedStruct", "processedVersions", "Record", "key", "ObjectId", "value", "TriggerStateStore", "Tag", "getState", "serviceFunctionEffect", "_", "saveState", "layerKv", "effect", "gen", "kv", "KeyValueStore", "schemaStore", "forSchema", "parseJson", "store", "fn", "valueOption", "get", "pipe", "orDie", "isNone", "fail", "TriggerStateNotFoundError", "set", "layerMemory", "provide", "TriggerDispatcher", "Tag", "layer", "options", "effect", "gen", "TriggerDispatcherImpl", "livePollInterval", "timeControl", "_running", "_internalTime", "_timerFiber", "_scheduledTriggers", "Map", "seconds", "startingTime", "Date", "running", "start", "_startNaturalTimeProcessing", "pipe", "tapErrorCause", "cause", "error", "causeToError", "log", "void", "forkDaemon", "dieMessage", "info", "stop", "interrupt", "undefined", "clear", "invokeTrigger", "trigger", "event", "triggerId", "id", "spec", "tracer", "InvocationTracer", "trace", "traceInvocationStart", "target", "function", "dxn", "payload", "kind", "data", "result", "enabled", "serialiedFunction", "DatabaseService", "load", "orDie", "invariant", "Obj", "instanceOf", "Function", "functionDef", "deserializeFunction", "inputData", "_prepareInputData", "FunctionInvocationService", "invokeFunction", "provide", "ComputeEventLogger", "layerFromTracing", "provideMerge", "TracingService", "layerQueue", "invocationTraceQueue", "exit", "triggerExecutionResult", "isSuccess", "traceInvocationEnd", "exception", "isFailure", "prettyErrors", "invokeScheduledTriggers", "kinds", "invocations", "refreshTriggers", "now", "getCurrentTime", "triggersToInvoke", "scheduledTrigger", "entries", "nextExecution", "push", "next", "cron", "forEach", "tick", "getTime", "concurrency", "triggers", "_fetchTriggers", "cursor", "getKeys", "KEY_QUEUE_CURSOR", "at", "queue", "QueueService", "getQueue", "DXN", "parse", "objects", "promise", "queryObjects", "object", "objectPos", "KEY_QUEUE_POSITION", "parseInt", "item", "deleteKeys", "getMeta", "keys", "source", "flush", "getSnapshot", "runQuery", "Query", "fromAst", "query", "ast", "state", "TriggerStateStore", "getState", "catchTag", "succeed", "version", "_tag", "processedVersions", "updated", "existingVersion", "get", "map", "decodeVersion", "currentVersion", "run", "isNone", "compareVersions", "value", "db", "type", "subject", "ref", "getDXN", "changedObjectId", "encodeVersion", "saveState", "advanceTime", "duration", "millis", "toMillis", "newTime", "advancedBy", "format", "currentTriggerIds", "Set", "t", "has", "delete", "timerSpec", "cronEither", "isRight", "right", "existing", "set", "left", "message", "count", "size", "withSpan", "Filter", "Trigger", "repeat", "fixed", "asVoid", "createInvocationPayload"]
7
- }
@@ -1 +0,0 @@
1
- {"inputs":{"src/bundler/bundler.ts":{"bytes":33602,"imports":[{"path":"@effect/platform/FetchHttpClient","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClient","kind":"import-statement","external":true},{"path":"effect/Duration","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Schedule","kind":"import-statement","external":true},{"path":"esbuild-wasm","kind":"import-statement","external":true},{"path":"@dxos/crypto","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"src/bundler/index.ts":{"bytes":457,"imports":[{"path":"src/bundler/bundler.ts","kind":"import-statement","original":"./bundler"}],"format":"esm"},"src/edge/functions.ts":{"bytes":6996,"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"},"src/edge/index.ts":{"bytes":864,"imports":[{"path":"src/edge/functions.ts","kind":"import-statement","original":"./functions"}],"format":"esm"},"src/errors.ts":{"bytes":3093,"imports":[{"path":"@dxos/errors","kind":"import-statement","external":true}],"format":"esm"},"src/types/Script.ts":{"bytes":3979,"imports":[{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true}],"format":"esm"},"src/types/Function.ts":{"bytes":5121,"imports":[{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"src/types/Script.ts","kind":"import-statement","original":"./Script"}],"format":"esm"},"src/types/Trigger.ts":{"bytes":14603,"imports":[{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"effect/SchemaAST","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true}],"format":"esm"},"src/types/TriggerEvent.ts":{"bytes":5563,"imports":[{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true}],"format":"esm"},"src/types/index.ts":{"bytes":986,"imports":[{"path":"src/types/Function.ts","kind":"import-statement","original":"./Function"},{"path":"src/types/Script.ts","kind":"import-statement","original":"./Script"},{"path":"src/types/Trigger.ts","kind":"import-statement","original":"./Trigger"},{"path":"src/types/TriggerEvent.ts","kind":"import-statement","original":"./TriggerEvent"}],"format":"esm"},"src/url.ts":{"bytes":5801,"imports":[],"format":"esm"},"src/handler.ts":{"bytes":18152,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"src/types/index.ts","kind":"import-statement","original":"./types"},{"path":"src/url.ts","kind":"import-statement","original":"./url"}],"format":"esm"},"src/example/fib.ts":{"bytes":3255,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"src/handler.ts","kind":"import-statement","original":"../handler"}],"format":"esm"},"src/example/reply.ts":{"bytes":2144,"imports":[{"path":"effect/Console","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"src/handler.ts","kind":"import-statement","original":"../handler"}],"format":"esm"},"src/example/sleep.ts":{"bytes":2587,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"src/handler.ts","kind":"import-statement","original":"../handler"}],"format":"esm"},"src/example/index.ts":{"bytes":1301,"imports":[{"path":"src/example/fib.ts","kind":"import-statement","original":"./fib"},{"path":"src/example/reply.ts","kind":"import-statement","original":"./reply"},{"path":"src/example/sleep.ts","kind":"import-statement","original":"./sleep"}],"format":"esm"},"src/executor/executor.ts":{"bytes":5580,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true}],"format":"esm"},"src/executor/index.ts":{"bytes":459,"imports":[{"path":"src/executor/executor.ts","kind":"import-statement","original":"./executor"}],"format":"esm"},"src/services/database.ts":{"bytes":16197,"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true}],"format":"esm"},"src/services/credentials.ts":{"bytes":15206,"imports":[{"path":"@effect/platform/HttpClient","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClientRequest","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Redacted","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"src/services/database.ts","kind":"import-statement","original":"./database"}],"format":"esm"},"src/services/tracing.ts":{"bytes":12471,"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true}],"format":"esm"},"src/services/event-logger.ts":{"bytes":11913,"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"src/services/tracing.ts","kind":"import-statement","original":"./tracing"}],"format":"esm"},"src/services/queues.ts":{"bytes":6500,"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true}],"format":"esm"},"src/services/remote-function-execution-service.ts":{"bytes":7226,"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"src/errors.ts","kind":"import-statement","original":"../errors"},{"path":"src/url.ts","kind":"import-statement","original":"../url"}],"format":"esm"},"src/services/local-function-execution.ts":{"bytes":18674,"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"src/errors.ts","kind":"import-statement","original":"../errors"},{"path":"src/services/credentials.ts","kind":"import-statement","original":"./credentials"},{"path":"src/services/database.ts","kind":"import-statement","original":"./database"},{"path":"src/services/queues.ts","kind":"import-statement","original":"./queues"},{"path":"src/services/remote-function-execution-service.ts","kind":"import-statement","original":"./remote-function-execution-service"}],"format":"esm"},"src/services/function-invocation-service.ts":{"bytes":9129,"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"src/services/credentials.ts","kind":"import-statement","original":"./credentials"},{"path":"src/services/database.ts","kind":"import-statement","original":"./database"},{"path":"src/services/local-function-execution.ts","kind":"import-statement","original":"./local-function-execution"},{"path":"src/services/queues.ts","kind":"import-statement","original":"./queues"},{"path":"src/services/remote-function-execution-service.ts","kind":"import-statement","original":"./remote-function-execution-service"}],"format":"esm"},"src/services/service-container.ts":{"bytes":12222,"imports":[{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"src/services/credentials.ts","kind":"import-statement","original":"./credentials"},{"path":"src/services/database.ts","kind":"import-statement","original":"./database"},{"path":"src/services/event-logger.ts","kind":"import-statement","original":"./event-logger"},{"path":"src/services/queues.ts","kind":"import-statement","original":"./queues"},{"path":"src/services/remote-function-execution-service.ts","kind":"import-statement","original":"./remote-function-execution-service"},{"path":"src/services/tracing.ts","kind":"import-statement","original":"./tracing"}],"format":"esm"},"src/services/index.ts":{"bytes":1352,"imports":[{"path":"src/services/credentials.ts","kind":"import-statement","original":"./credentials"},{"path":"src/services/database.ts","kind":"import-statement","original":"./database"},{"path":"src/services/event-logger.ts","kind":"import-statement","original":"./event-logger"},{"path":"src/services/function-invocation-service.ts","kind":"import-statement","original":"./function-invocation-service"},{"path":"src/services/local-function-execution.ts","kind":"import-statement","original":"./local-function-execution"},{"path":"src/services/queues.ts","kind":"import-statement","original":"./queues"},{"path":"src/services/service-container.ts","kind":"import-statement","original":"./service-container"},{"path":"src/services/tracing.ts","kind":"import-statement","original":"./tracing"},{"path":"src/services/remote-function-execution-service.ts","kind":"import-statement","original":"./remote-function-execution-service"}],"format":"esm"},"src/trace.ts":{"bytes":16925,"imports":[{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"src/types/index.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"src/triggers/invocation-tracer.ts":{"bytes":11644,"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"src/services/index.ts","kind":"import-statement","original":"../services"},{"path":"src/trace.ts","kind":"import-statement","original":"../trace"}],"format":"esm"},"src/triggers/input-builder.ts":{"bytes":3621,"imports":[],"format":"esm"},"src/triggers/trigger-state-store.ts":{"bytes":7628,"imports":[{"path":"@effect/platform/KeyValueStore","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"src/errors.ts","kind":"import-statement","original":"../errors"}],"format":"esm"},"src/triggers/trigger-dispatcher.ts":{"bytes":57232,"imports":[{"path":"effect/Cause","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Cron","kind":"import-statement","external":true},{"path":"effect/Duration","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Either","kind":"import-statement","external":true},{"path":"effect/Exit","kind":"import-statement","external":true},{"path":"effect/Fiber","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Record","kind":"import-statement","external":true},{"path":"effect/Schedule","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"src/handler.ts","kind":"import-statement","original":"../handler"},{"path":"src/services/index.ts","kind":"import-statement","original":"../services"},{"path":"src/types/index.ts","kind":"import-statement","original":"../types"},{"path":"src/triggers/input-builder.ts","kind":"import-statement","original":"./input-builder"},{"path":"src/triggers/invocation-tracer.ts","kind":"import-statement","original":"./invocation-tracer"},{"path":"src/triggers/trigger-state-store.ts","kind":"import-statement","original":"./trigger-state-store"}],"format":"esm"},"src/triggers/index.ts":{"bytes":713,"imports":[{"path":"src/triggers/invocation-tracer.ts","kind":"import-statement","original":"./invocation-tracer"},{"path":"src/triggers/trigger-dispatcher.ts","kind":"import-statement","original":"./trigger-dispatcher"},{"path":"src/triggers/trigger-state-store.ts","kind":"import-statement","original":"./trigger-state-store"}],"format":"esm"},"src/index.ts":{"bytes":1119,"imports":[{"path":"src/errors.ts","kind":"import-statement","original":"./errors"},{"path":"src/example/index.ts","kind":"import-statement","original":"./example"},{"path":"src/executor/index.ts","kind":"import-statement","original":"./executor"},{"path":"src/handler.ts","kind":"import-statement","original":"./handler"},{"path":"src/services/index.ts","kind":"import-statement","original":"./services"},{"path":"src/trace.ts","kind":"import-statement","original":"./trace"},{"path":"src/triggers/index.ts","kind":"import-statement","original":"./triggers"},{"path":"src/types/index.ts","kind":"import-statement","original":"./types"},{"path":"src/url.ts","kind":"import-statement","original":"./url"}],"format":"esm"},"src/testing/logger.ts":{"bytes":1695,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"src/services/index.ts","kind":"import-statement","original":"../services"}],"format":"esm"},"src/testing/services.ts":{"bytes":6657,"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"src/services/index.ts","kind":"import-statement","original":"../services"},{"path":"src/testing/logger.ts","kind":"import-statement","original":"./logger"}],"format":"esm"},"src/testing/layer.ts":{"bytes":14046,"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"@dxos/echo-db/testing","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/kv-store/testing","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"src/services/index.ts","kind":"import-statement","original":"../services"}],"format":"esm"},"src/testing/index.ts":{"bytes":539,"imports":[{"path":"src/testing/services.ts","kind":"import-statement","original":"./services"},{"path":"src/testing/layer.ts","kind":"import-statement","original":"./layer"}],"format":"esm"}},"outputs":{"dist/lib/browser/bundler/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":16163},"dist/lib/browser/bundler/index.mjs":{"imports":[{"path":"dist/lib/browser/chunk-J5LGTIGS.mjs","kind":"import-statement"},{"path":"@effect/platform/FetchHttpClient","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClient","kind":"import-statement","external":true},{"path":"effect/Duration","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Schedule","kind":"import-statement","external":true},{"path":"esbuild-wasm","kind":"import-statement","external":true},{"path":"@dxos/crypto","kind":"import-statement","external":true},{"path":"@dxos/effect","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":"src/bundler/index.ts","inputs":{"src/bundler/bundler.ts":{"bytesInOutput":7975},"src/bundler/index.ts":{"bytesInOutput":0}},"bytes":8112},"dist/lib/browser/edge/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3513},"dist/lib/browser/edge/index.mjs":{"imports":[{"path":"dist/lib/browser/chunk-J5LGTIGS.mjs","kind":"import-statement"},{"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":"src/edge/index.ts","inputs":{"src/edge/functions.ts":{"bytesInOutput":1853},"src/edge/index.ts":{"bytesInOutput":0}},"bytes":2023},"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93569},"dist/lib/browser/index.mjs":{"imports":[{"path":"dist/lib/browser/chunk-M6EXIREF.mjs","kind":"import-statement"},{"path":"dist/lib/browser/chunk-J5LGTIGS.mjs","kind":"import-statement"},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"effect/SchemaAST","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"effect/Console","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo/internal","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"effect/Cause","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Cron","kind":"import-statement","external":true},{"path":"effect/Duration","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Either","kind":"import-statement","external":true},{"path":"effect/Exit","kind":"import-statement","external":true},{"path":"effect/Fiber","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Record","kind":"import-statement","external":true},{"path":"effect/Schedule","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@effect/platform/KeyValueStore","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true}],"exports":["ComputeEvent","ComputeEventLogger","ComputeEventPayload","ConfiguredCredentialsService","ContextQueueService","CredentialsService","DatabaseService","Example","FUNCTIONS_META_KEY","FUNCTIONS_PRESET_META_KEY","Function","FunctionDefinition","FunctionError","FunctionExecutor","FunctionImplementationResolver","FunctionInvocationService","FunctionNotFoundError","InvocationOutcome","InvocationTraceEndEvent","InvocationTraceEventType","InvocationTraceStartEvent","InvocationTracer","LocalFunctionExecutionService","MESSAGE_PROPERTY_TOOL_CALL_ID","QueueService","RemoteFunctionExecutionService","SERVICE_TAGS","Script","ServiceContainer","ServiceNotAvailableError","TraceEvent","TraceEventException","TraceEventLog","TracingService","Trigger","TriggerDispatcher","TriggerEvent","TriggerState","TriggerStateNotFoundError","TriggerStateStore","createDefectLogger","createEventLogger","createInvocationSpans","defineFunction","deserializeFunction","getInvocationUrl","getUserFunctionIdInMetadata","logCustomEvent","serializeFunction","setUserFunctionIdInMetadata","withAuthorization"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0},"src/example/fib.ts":{"bytesInOutput":708},"src/handler.ts":{"bytesInOutput":3055},"src/types/Function.ts":{"bytesInOutput":1407},"src/types/Script.ts":{"bytesInOutput":913},"src/types/index.ts":{"bytesInOutput":0},"src/types/Trigger.ts":{"bytesInOutput":3602},"src/types/TriggerEvent.ts":{"bytesInOutput":1314},"src/example/reply.ts":{"bytesInOutput":448},"src/example/sleep.ts":{"bytesInOutput":550},"src/example/index.ts":{"bytesInOutput":164},"src/executor/executor.ts":{"bytesInOutput":1110},"src/services/function-invocation-service.ts":{"bytesInOutput":1856},"src/services/local-function-execution.ts":{"bytesInOutput":4052},"src/trace.ts":{"bytesInOutput":4328},"src/triggers/invocation-tracer.ts":{"bytesInOutput":2558},"src/triggers/trigger-dispatcher.ts":{"bytesInOutput":13120},"src/triggers/input-builder.ts":{"bytesInOutput":770},"src/triggers/trigger-state-store.ts":{"bytesInOutput":1765}},"bytes":44342},"dist/lib/browser/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":11761},"dist/lib/browser/testing/index.mjs":{"imports":[{"path":"dist/lib/browser/chunk-M6EXIREF.mjs","kind":"import-statement"},{"path":"dist/lib/browser/chunk-J5LGTIGS.mjs","kind":"import-statement"},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"@dxos/echo-db/testing","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/kv-store/testing","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["TestDatabaseLayer","createTestServices","testStoragePath"],"entryPoint":"src/testing/index.ts","inputs":{"src/testing/services.ts":{"bytesInOutput":904},"src/testing/logger.ts":{"bytesInOutput":209},"src/testing/index.ts":{"bytesInOutput":0},"src/testing/layer.ts":{"bytesInOutput":2955}},"bytes":4463},"dist/lib/browser/chunk-M6EXIREF.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":46990},"dist/lib/browser/chunk-M6EXIREF.mjs":{"imports":[{"path":"@dxos/errors","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClient","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClientRequest","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Redacted","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["ComputeEvent","ComputeEventLogger","ComputeEventPayload","ConfiguredCredentialsService","ContextQueueService","CredentialsService","DatabaseService","FUNCTIONS_META_KEY","FUNCTIONS_PRESET_META_KEY","FunctionError","FunctionNotFoundError","MESSAGE_PROPERTY_TOOL_CALL_ID","QueueService","RemoteFunctionExecutionService","SERVICE_TAGS","ServiceContainer","ServiceNotAvailableError","TracingService","TriggerStateNotFoundError","createDefectLogger","createEventLogger","getInvocationUrl","getUserFunctionIdInMetadata","logCustomEvent","setUserFunctionIdInMetadata","withAuthorization"],"inputs":{"src/errors.ts":{"bytesInOutput":744},"src/url.ts":{"bytesInOutput":1077},"src/services/database.ts":{"bytesInOutput":3611},"src/services/credentials.ts":{"bytesInOutput":3354},"src/services/tracing.ts":{"bytesInOutput":2769},"src/services/event-logger.ts":{"bytesInOutput":2891},"src/services/queues.ts":{"bytesInOutput":1233},"src/services/remote-function-execution-service.ts":{"bytesInOutput":1619},"src/services/service-container.ts":{"bytesInOutput":2474}},"bytes":20709},"dist/lib/browser/chunk-J5LGTIGS.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/browser/chunk-J5LGTIGS.mjs":{"imports":[],"exports":["__export"],"inputs":{},"bytes":235}}}
@@ -1,131 +0,0 @@
1
- import {
2
- ConfiguredCredentialsService,
3
- DatabaseService,
4
- QueueService,
5
- ServiceContainer,
6
- createEventLogger
7
- } from "../chunk-M6EXIREF.mjs";
8
- import "../chunk-J5LGTIGS.mjs";
9
-
10
- // src/testing/services.ts
11
- import { assertArgument } from "@dxos/invariant";
12
-
13
- // src/testing/logger.ts
14
- import * as Effect from "effect/Effect";
15
- import { LogLevel } from "@dxos/log";
16
- var noopLogger = {
17
- log: () => Effect.succeed(void 0),
18
- nodeId: void 0
19
- };
20
- var consoleLogger = createEventLogger(LogLevel.INFO);
21
-
22
- // src/testing/services.ts
23
- var createTestServices = ({ ai, credentials, db, logging, queues, space, tracing } = {}) => {
24
- assertArgument(!(!!space && (!!db || !!queues)), "space", "space can be provided only if db and queues are not");
25
- return new ServiceContainer().setServices({
26
- // ai: createAiService(ai),
27
- credentials: createCredentialsService(credentials),
28
- database: space || db ? DatabaseService.make(space?.db || db) : void 0,
29
- eventLogger: logging?.logger ?? logging?.enabled ? consoleLogger : noopLogger,
30
- queues: space || queues ? QueueService.make(space?.queues || queues, void 0) : void 0,
31
- tracing: tracing?.service
32
- });
33
- };
34
- var createCredentialsService = (credentials) => {
35
- if (credentials?.services) {
36
- return new ConfiguredCredentialsService(credentials.services);
37
- }
38
- if (credentials?.service) {
39
- return credentials.service;
40
- }
41
- };
42
-
43
- // src/testing/layer.ts
44
- import * as Context from "effect/Context";
45
- import * as Effect2 from "effect/Effect";
46
- import * as Layer from "effect/Layer";
47
- import { EchoTestBuilder } from "@dxos/echo-db/testing";
48
- import { acquireReleaseResource } from "@dxos/effect";
49
- import { PublicKey } from "@dxos/keys";
50
- import { createTestLevel } from "@dxos/kv-store/testing";
51
- import { log } from "@dxos/log";
52
- var __dxlog_file = "/__w/dxos/dxos/packages/core/functions/src/testing/layer.ts";
53
- var testBuilder = acquireReleaseResource(() => new EchoTestBuilder());
54
- var testStoragePath = ({ name = PublicKey.random().toHex() }) => {
55
- return `/tmp/dxos-${name}`;
56
- };
57
- var TestDatabaseLayer = ({ indexing, types, spaceKey, storagePath, onInit } = {}) => Layer.scopedContext(Effect2.gen(function* () {
58
- const builder = yield* testBuilder;
59
- let kv;
60
- if (storagePath) {
61
- kv = createTestLevel(storagePath);
62
- yield* Effect2.promise(() => kv.open());
63
- }
64
- const peer = yield* Effect2.promise(() => builder.createPeer({
65
- indexing,
66
- types,
67
- kv
68
- }));
69
- let db;
70
- let queues;
71
- if (storagePath) {
72
- const testMetadata = yield* Effect2.promise(async () => {
73
- try {
74
- return await kv.get("test-metadata", {
75
- valueEncoding: "json"
76
- });
77
- } catch (e) {
78
- if (e.code === "LEVEL_NOT_FOUND") {
79
- return void 0;
80
- }
81
- throw e;
82
- }
83
- });
84
- log("starting persistant test db", {
85
- storagePath,
86
- testMetadata
87
- }, {
88
- F: __dxlog_file,
89
- L: 63,
90
- S: this,
91
- C: (f, a) => f(...a)
92
- });
93
- if (!testMetadata) {
94
- const key = spaceKey ?? PublicKey.random();
95
- db = yield* Effect2.promise(() => peer.createDatabase(key));
96
- queues = peer.client.constructQueueFactory(db.spaceId);
97
- yield* Effect2.promise(() => kv.put("test-metadata", {
98
- key: key.toHex(),
99
- rootUrl: db.rootUrl
100
- }, {
101
- valueEncoding: "json"
102
- }));
103
- if (onInit) {
104
- yield* onInit().pipe(Effect2.provideService(DatabaseService, DatabaseService.make(db)), Effect2.provideService(QueueService, QueueService.make(queues, void 0)));
105
- }
106
- } else {
107
- const key = PublicKey.from(testMetadata.key);
108
- const rootUrl = testMetadata.rootUrl;
109
- db = yield* Effect2.promise(() => peer.openDatabase(key, rootUrl));
110
- queues = peer.client.constructQueueFactory(db.spaceId);
111
- }
112
- } else {
113
- db = yield* Effect2.promise(() => peer.createDatabase(spaceKey));
114
- queues = peer.client.constructQueueFactory(db.spaceId);
115
- if (onInit) {
116
- yield* onInit().pipe(Effect2.provideService(DatabaseService, DatabaseService.make(db)), Effect2.provideService(QueueService, QueueService.make(queues, void 0)));
117
- }
118
- }
119
- yield* Effect2.addFinalizer(() => Effect2.promise(async () => {
120
- if (kv) {
121
- await kv.close();
122
- }
123
- }));
124
- return Context.mergeAll(Context.make(DatabaseService, DatabaseService.make(db)), Context.make(QueueService, QueueService.make(queues, void 0)));
125
- }));
126
- export {
127
- TestDatabaseLayer,
128
- createTestServices,
129
- testStoragePath
130
- };
131
- //# sourceMappingURL=index.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/testing/services.ts", "../../../../src/testing/logger.ts", "../../../../src/testing/layer.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Context from 'effect/Context';\n\nimport type { Space } from '@dxos/client/echo';\nimport type { EchoDatabase, QueueFactory } from '@dxos/echo-db';\nimport { assertArgument } from '@dxos/invariant';\n\nimport {\n type ComputeEventLogger,\n ConfiguredCredentialsService,\n type CredentialsService,\n DatabaseService,\n QueueService,\n ServiceContainer,\n type ServiceCredential,\n type TracingService,\n} from '../services';\n\nimport { consoleLogger, noopLogger } from './logger';\n\n// TODO(burdon): Factor out.\nexport type OneOf<T> = {\n [K in keyof T]: { [P in K]: T[P] } & { [P in Exclude<keyof T, K>]?: never };\n}[keyof T];\n\nexport type AiServiceProvider = 'dev' | 'edge' | 'ollama' | 'lmstudio';\n\nexport type TestServiceOptions = {\n /**\n * AI service configuration.\n */\n ai?: any;\n\n /**\n * Credentials service configuration.\n */\n credentials?: OneOf<{\n /**\n * Predefined credentials list.\n */\n services?: ServiceCredential[];\n\n /**\n * Custom credentials service.\n */\n service?: Context.Tag.Service<CredentialsService>;\n }>;\n\n /**\n * Database configuration.\n */\n db?: EchoDatabase;\n\n /**\n * Gets database and queue services from the space.\n * Exclusive with: `db`, `queues`\n */\n space?: Space;\n\n /**\n * Logging configuration.\n */\n logging?: {\n enabled?: boolean;\n logger?: Context.Tag.Service<ComputeEventLogger>;\n };\n\n /**\n * Queue service configuration.\n */\n queues?: QueueFactory;\n\n tracing?: {\n service?: Context.Tag.Service<TracingService>;\n };\n};\n\n/**\n * @deprecated\n */\nexport const createTestServices = ({\n ai,\n credentials,\n db,\n logging,\n queues,\n space,\n tracing,\n}: TestServiceOptions = {}): ServiceContainer => {\n assertArgument(!(!!space && (!!db || !!queues)), 'space', 'space can be provided only if db and queues are not');\n\n return new ServiceContainer().setServices({\n // ai: createAiService(ai),\n credentials: createCredentialsService(credentials),\n database: space || db ? DatabaseService.make(space?.db || db!) : undefined,\n eventLogger: (logging?.logger ?? logging?.enabled) ? consoleLogger : noopLogger,\n queues: space || queues ? QueueService.make(space?.queues || queues!, undefined) : undefined,\n tracing: tracing?.service,\n });\n};\n\nconst createCredentialsService = (\n credentials: TestServiceOptions['credentials'] | undefined,\n): Context.Tag.Service<CredentialsService> | undefined => {\n if (credentials?.services) {\n return new ConfiguredCredentialsService(credentials.services);\n }\n\n if (credentials?.service) {\n return credentials.service;\n }\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\n\nimport { LogLevel } from '@dxos/log';\n\nimport { type ComputeEventLogger, createEventLogger } from '../services';\n\nexport const noopLogger: Context.Tag.Service<ComputeEventLogger> = {\n log: () => Effect.succeed(undefined),\n nodeId: undefined,\n};\n\nexport const consoleLogger: Context.Tag.Service<ComputeEventLogger> = createEventLogger(LogLevel.INFO);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport type * as Schema from 'effect/Schema';\n\nimport type { EchoDatabaseImpl, QueueFactory } from '@dxos/echo-db';\nimport { EchoTestBuilder } from '@dxos/echo-db/testing';\nimport type { EchoHostIndexingConfig } from '@dxos/echo-pipeline';\nimport { acquireReleaseResource } from '@dxos/effect';\nimport { PublicKey } from '@dxos/keys';\nimport type { LevelDB } from '@dxos/kv-store';\nimport { createTestLevel } from '@dxos/kv-store/testing';\nimport { log } from '@dxos/log';\n\nimport { DatabaseService, QueueService } from '../services';\n\nconst testBuilder = acquireReleaseResource(() => new EchoTestBuilder());\n\nexport const testStoragePath = ({ name = PublicKey.random().toHex() }: { name?: string }) => {\n return `/tmp/dxos-${name}`;\n};\n\nexport type TestDatabaseOptions = {\n indexing?: Partial<EchoHostIndexingConfig>;\n types?: Schema.Schema.AnyNoContext[];\n spaceKey?: PublicKey;\n storagePath?: string;\n onInit?: () => Effect.Effect<void, never, DatabaseService | QueueService>;\n};\n\nexport const TestDatabaseLayer = ({ indexing, types, spaceKey, storagePath, onInit }: TestDatabaseOptions = {}) =>\n Layer.scopedContext(\n Effect.gen(function* () {\n const builder = yield* testBuilder;\n\n let kv: LevelDB | undefined;\n if (storagePath) {\n kv = createTestLevel(storagePath);\n yield* Effect.promise(() => kv!.open());\n // const keyCount = yield* Effect.promise(async () => (await kv!.iterator({ values: false }).all()).length);\n // log.info('opened test db', { storagePath, keyCount });\n }\n const peer = yield* Effect.promise(() => builder.createPeer({ indexing, types, kv }));\n\n let db: EchoDatabaseImpl | undefined;\n let queues: QueueFactory | undefined;\n\n if (storagePath) {\n const testMetadata = yield* Effect.promise(async () => {\n try {\n return await kv!.get('test-metadata', { valueEncoding: 'json' });\n } catch (e) {\n if ((e as any).code === 'LEVEL_NOT_FOUND') {\n return undefined;\n }\n throw e;\n }\n });\n log('starting persistant test db', { storagePath, testMetadata });\n if (!testMetadata) {\n const key = spaceKey ?? PublicKey.random();\n db = yield* Effect.promise(() => peer.createDatabase(key));\n queues = peer.client.constructQueueFactory(db.spaceId);\n\n yield* Effect.promise(() =>\n kv!.put('test-metadata', { key: key.toHex(), rootUrl: db!.rootUrl }, { valueEncoding: 'json' }),\n );\n\n if (onInit) {\n yield* onInit().pipe(\n Effect.provideService(DatabaseService, DatabaseService.make(db)),\n Effect.provideService(QueueService, QueueService.make(queues, undefined)),\n );\n }\n } else {\n const key = PublicKey.from((testMetadata as any).key);\n const rootUrl = (testMetadata as any).rootUrl;\n db = yield* Effect.promise(() => peer.openDatabase(key, rootUrl));\n queues = peer.client.constructQueueFactory(db.spaceId);\n }\n } else {\n db = yield* Effect.promise(() => peer.createDatabase(spaceKey));\n queues = peer.client.constructQueueFactory(db.spaceId);\n if (onInit) {\n yield* onInit().pipe(\n Effect.provideService(DatabaseService, DatabaseService.make(db)),\n Effect.provideService(QueueService, QueueService.make(queues, undefined)),\n );\n }\n }\n\n yield* Effect.addFinalizer(() =>\n Effect.promise(async () => {\n if (kv) {\n // {\n // const keyCount = (await kv.iterator({ values: false }).all()).length;\n // log.info('closing persistant test db', { storagePath, keyCount });\n // }\n\n await kv.close();\n }\n }),\n );\n\n return Context.mergeAll(\n Context.make(DatabaseService, DatabaseService.make(db)),\n Context.make(QueueService, QueueService.make(queues, undefined)),\n );\n }),\n );\n"],
5
- "mappings": ";;;;;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M,UAAWb,aAAqBa;AACtCf,WAAK,OAAcJ,gBAAQ,MAAME,KAAKwB,aAAab,KAAKM,OAAAA,CAAAA;AACxDd,eAASH,KAAKa,OAAOC,sBAAsBZ,GAAGa,OAAO;IACvD;EACF,OAAO;AACLb,SAAK,OAAcJ,gBAAQ,MAAME,KAAKY,eAAetB,QAAAA,CAAAA;AACrDa,aAASH,KAAKa,OAAOC,sBAAsBZ,GAAGa,OAAO;AACrD,QAAIvB,QAAQ;AACV,aAAOA,OAAAA,EAAS0B,KACPC,uBAAeC,iBAAiBA,gBAAgBC,KAAKnB,EAAAA,CAAAA,GACrDiB,uBAAeG,cAAcA,aAAaD,KAAKlB,QAAQM,MAAAA,CAAAA,CAAAA;IAElE;EACF;AAEA,SAAcgB,qBAAa,MAClB3B,gBAAQ,YAAA;AACb,QAAIF,IAAI;AAMN,YAAMA,GAAG8B,MAAK;IAChB;EACF,CAAA,CAAA;AAGF,SAAeC,iBACLN,aAAKD,iBAAiBA,gBAAgBC,KAAKnB,EAAAA,CAAAA,GAC3CmB,aAAKC,cAAcA,aAAaD,KAAKlB,QAAQM,MAAAA,CAAAA,CAAAA;AAEzD,CAAA,CAAA;",
6
- "names": ["assertArgument", "Effect", "LogLevel", "noopLogger", "log", "succeed", "undefined", "nodeId", "consoleLogger", "createEventLogger", "LogLevel", "INFO", "createTestServices", "ai", "credentials", "db", "logging", "queues", "space", "tracing", "assertArgument", "ServiceContainer", "setServices", "createCredentialsService", "database", "DatabaseService", "make", "undefined", "eventLogger", "logger", "enabled", "consoleLogger", "noopLogger", "QueueService", "service", "services", "ConfiguredCredentialsService", "Context", "Effect", "Layer", "EchoTestBuilder", "acquireReleaseResource", "PublicKey", "createTestLevel", "log", "testBuilder", "acquireReleaseResource", "EchoTestBuilder", "testStoragePath", "name", "PublicKey", "random", "toHex", "TestDatabaseLayer", "indexing", "types", "spaceKey", "storagePath", "onInit", "scopedContext", "gen", "builder", "kv", "createTestLevel", "promise", "open", "peer", "createPeer", "db", "queues", "testMetadata", "get", "valueEncoding", "e", "code", "undefined", "log", "key", "createDatabase", "client", "constructQueueFactory", "spaceId", "put", "rootUrl", "pipe", "provideService", "DatabaseService", "make", "QueueService", "from", "openDatabase", "addFinalizer", "close", "mergeAll"]
7
- }