@dxos/functions 0.8.4-main.e8ec1fe → 0.8.4-main.ef1bc66f44

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 (57) hide show
  1. package/dist/lib/{browser → neutral}/index.mjs +450 -148
  2. package/dist/lib/neutral/index.mjs.map +7 -0
  3. package/dist/lib/neutral/meta.json +1 -0
  4. package/dist/types/src/errors.d.ts +24 -32
  5. package/dist/types/src/errors.d.ts.map +1 -1
  6. package/dist/types/src/operation-compatibility.test.d.ts +2 -0
  7. package/dist/types/src/operation-compatibility.test.d.ts.map +1 -0
  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/protocol.d.ts.map +1 -1
  11. package/dist/types/src/sdk.d.ts +27 -2
  12. package/dist/types/src/sdk.d.ts.map +1 -1
  13. package/dist/types/src/services/credentials.d.ts +6 -4
  14. package/dist/types/src/services/credentials.d.ts.map +1 -1
  15. package/dist/types/src/services/event-logger.d.ts +25 -31
  16. package/dist/types/src/services/event-logger.d.ts.map +1 -1
  17. package/dist/types/src/services/function-invocation-service.d.ts +5 -0
  18. package/dist/types/src/services/function-invocation-service.d.ts.map +1 -1
  19. package/dist/types/src/services/index.d.ts +0 -1
  20. package/dist/types/src/services/index.d.ts.map +1 -1
  21. package/dist/types/src/services/queues.d.ts +4 -4
  22. package/dist/types/src/services/queues.d.ts.map +1 -1
  23. package/dist/types/src/services/tracing.d.ts +37 -3
  24. package/dist/types/src/services/tracing.d.ts.map +1 -1
  25. package/dist/types/src/types/Function.d.ts +40 -46
  26. package/dist/types/src/types/Function.d.ts.map +1 -1
  27. package/dist/types/src/types/Script.d.ts +9 -16
  28. package/dist/types/src/types/Script.d.ts.map +1 -1
  29. package/dist/types/src/types/Trigger.d.ts +58 -76
  30. package/dist/types/src/types/Trigger.d.ts.map +1 -1
  31. package/dist/types/src/types/TriggerEvent.d.ts +43 -13
  32. package/dist/types/src/types/TriggerEvent.d.ts.map +1 -1
  33. package/dist/types/src/types/url.d.ts +4 -3
  34. package/dist/types/src/types/url.d.ts.map +1 -1
  35. package/dist/types/tsconfig.tsbuildinfo +1 -1
  36. package/package.json +23 -17
  37. package/src/errors.ts +4 -4
  38. package/src/operation-compatibility.test.ts +185 -0
  39. package/src/protocol/functions-ai-http-client.ts +67 -0
  40. package/src/protocol/protocol.ts +184 -67
  41. package/src/sdk.ts +68 -5
  42. package/src/services/credentials.ts +31 -15
  43. package/src/services/event-logger.ts +2 -2
  44. package/src/services/function-invocation-service.ts +14 -0
  45. package/src/services/index.ts +0 -2
  46. package/src/services/queues.ts +5 -7
  47. package/src/services/tracing.ts +63 -4
  48. package/src/types/Function.ts +28 -8
  49. package/src/types/Script.ts +8 -7
  50. package/src/types/Trigger.ts +18 -14
  51. package/src/types/TriggerEvent.ts +29 -29
  52. package/src/types/url.ts +4 -3
  53. package/dist/lib/browser/index.mjs.map +0 -7
  54. package/dist/lib/browser/meta.json +0 -1
  55. package/dist/lib/node-esm/index.mjs +0 -928
  56. package/dist/lib/node-esm/index.mjs.map +0 -7
  57. package/dist/lib/node-esm/meta.json +0 -1
@@ -4,29 +4,28 @@
4
4
 
5
5
  import * as Schema from 'effect/Schema';
6
6
 
7
- import { DXN, Obj, Type } from '@dxos/echo';
7
+ import { DXN, Type } from '@dxos/echo';
8
8
 
9
- export type TriggerEvent = EmailEvent | QueueEvent | SubscriptionEvent | TimerEvent | WebhookEvent;
9
+ // TODO(wittjosiah): Review this type.
10
+ // - Should be discriminated union.
11
+ // - Should be more consistent (e.g. subject vs item).
12
+ // - Should re-use schemas if possible.
10
13
 
11
14
  // TODO(burdon): Reuse trigger schema from @dxos/functions (TriggerType).
12
- export const EmailEvent = Schema.mutable(
13
- Schema.Struct({
14
- from: Schema.String,
15
- to: Schema.String,
16
- subject: Schema.String,
17
- created: Schema.String,
18
- body: Schema.String,
19
- }),
20
- );
15
+ export const EmailEvent = Schema.Struct({
16
+ from: Schema.String,
17
+ to: Schema.String,
18
+ subject: Schema.String,
19
+ created: Schema.String,
20
+ body: Schema.String,
21
+ });
21
22
  export type EmailEvent = Schema.Schema.Type<typeof EmailEvent>;
22
23
 
23
- export const QueueEvent = Schema.mutable(
24
- Schema.Struct({
25
- queue: DXN.Schema,
26
- item: Schema.Any,
27
- cursor: Schema.String,
28
- }),
29
- );
24
+ export const QueueEvent = Schema.Struct({
25
+ queue: DXN.Schema,
26
+ item: Schema.Any,
27
+ cursor: Schema.String,
28
+ });
30
29
  export type QueueEvent = Schema.Schema.Type<typeof QueueEvent>;
31
30
 
32
31
  export const SubscriptionEvent = Schema.Struct({
@@ -39,24 +38,25 @@ export const SubscriptionEvent = Schema.Struct({
39
38
  /**
40
39
  * Reference to the object that was changed or created.
41
40
  */
42
- subject: Type.Ref(Obj.Any),
41
+ subject: Type.Ref(Type.Obj),
43
42
 
44
43
  /**
45
44
  * @deprecated
46
45
  */
47
46
  changedObjectId: Schema.optional(Schema.String),
48
- }).pipe(Schema.mutable);
47
+ });
49
48
  export type SubscriptionEvent = Schema.Schema.Type<typeof SubscriptionEvent>;
50
49
 
51
- export const TimerEvent = Schema.mutable(Schema.Struct({ tick: Schema.Number }));
50
+ export const TimerEvent = Schema.Struct({ tick: Schema.Number });
52
51
  export type TimerEvent = Schema.Schema.Type<typeof TimerEvent>;
53
52
 
54
- export const WebhookEvent = Schema.mutable(
55
- Schema.Struct({
56
- url: Schema.String,
57
- method: Schema.Literal('GET', 'POST'),
58
- headers: Schema.Record({ key: Schema.String, value: Schema.String }),
59
- bodyText: Schema.String,
60
- }),
61
- );
53
+ export const WebhookEvent = Schema.Struct({
54
+ url: Schema.String,
55
+ method: Schema.Literal('GET', 'POST'),
56
+ headers: Schema.Record({ key: Schema.String, value: Schema.String }),
57
+ bodyText: Schema.String,
58
+ });
62
59
  export type WebhookEvent = Schema.Schema.Type<typeof WebhookEvent>;
60
+
61
+ export const TriggerEvent = Schema.Union(EmailEvent, QueueEvent, SubscriptionEvent, TimerEvent, WebhookEvent);
62
+ export type TriggerEvent = Schema.Schema.Type<typeof TriggerEvent>;
package/src/types/url.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { type ObjectMeta } from '@dxos/echo/internal';
5
+ import { type Obj } from '@dxos/echo';
6
6
 
7
7
  // TODO: use URL scheme for source?
8
8
  export const FUNCTIONS_META_KEY = 'dxos.org/service/function';
@@ -12,14 +12,15 @@ export const FUNCTIONS_PRESET_META_KEY = 'dxos.org/service/function-preset';
12
12
  /**
13
13
  * NOTE: functionId is backend ID, not ECHO object id.
14
14
  */
15
- export const getUserFunctionIdInMetadata = (meta: ObjectMeta) => {
15
+ export const getUserFunctionIdInMetadata = (meta: Obj.ReadonlyMeta) => {
16
16
  return meta.keys.find((key) => key.source === FUNCTIONS_META_KEY)?.id;
17
17
  };
18
18
 
19
19
  /**
20
20
  * NOTE: functionId is backend ID, not ECHO object id.
21
+ * Must be called inside Obj.changeMeta() since it mutates the meta.
21
22
  */
22
- export const setUserFunctionIdInMetadata = (meta: ObjectMeta, functionId: string) => {
23
+ export const setUserFunctionIdInMetadata = (meta: Obj.Meta, functionId: string) => {
23
24
  const key = meta.keys.find((key) => key.source === FUNCTIONS_META_KEY);
24
25
  if (key) {
25
26
  if (key.id !== functionId) {
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/errors.ts", "../../../src/example/fib.ts", "../../../src/sdk.ts", "../../../src/types/Function.ts", "../../../src/types/Script.ts", "../../../src/types/Trigger.ts", "../../../src/types/TriggerEvent.ts", "../../../src/types/url.ts", "../../../src/example/reply.ts", "../../../src/example/sleep.ts", "../../../src/example/index.ts", "../../../src/services/index.ts", "../../../src/services/credentials.ts", "../../../src/services/event-logger.ts", "../../../src/services/tracing.ts", "../../../src/services/function-invocation-service.ts", "../../../src/services/queues.ts", "../../../src/protocol/protocol.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { BaseError, type BaseErrorOptions } from '@dxos/errors';\n\nexport class ServiceNotAvailableError extends BaseError.extend('SERVICE_NOT_AVAILABLE', 'Service not available') {\n constructor(service: string, options?: Omit<BaseErrorOptions, 'context'>) {\n super({ context: { service }, ...options });\n }\n}\n\nexport class FunctionNotFoundError extends BaseError.extend('FUNCTION_NOT_FOUND', 'Function not found') {\n constructor(functionKey: string, options?: Omit<BaseErrorOptions, 'context'>) {\n super({ context: { function: functionKey }, ...options });\n }\n}\n\nexport class FunctionError extends BaseError.extend('FUNCTION_ERROR', 'Function invocation error') {}\n\nexport class TriggerStateNotFoundError extends BaseError.extend('TRIGGER_STATE_NOT_FOUND', 'Trigger state not found') {}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\n\nimport { defineFunction } from '../sdk';\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 { type AiService } from '@dxos/ai';\nimport { Obj, Type } from '@dxos/echo';\nimport { type DatabaseService } from '@dxos/echo-db';\nimport { assertArgument, failedInvariant } from '@dxos/invariant';\n\nimport {\n type CredentialsService,\n type FunctionInvocationService,\n type QueueService,\n type TracingService,\n} from './services';\nimport { Function } from './types';\nimport { getUserFunctionIdInMetadata, setUserFunctionIdInMetadata } from './types';\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 * Services that are provided at the function call site by the caller.\n */\nexport type InvocationServices = TracingService;\n\n/**\n * Services that are available to invoked functions.\n */\nexport type FunctionServices =\n | InvocationServices\n | AiService.AiService\n | CredentialsService\n | DatabaseService\n | QueueService\n | FunctionInvocationService;\n\n/**\n * Function handler.\n */\nexport type FunctionHandler<TData = {}, TOutput = any, S extends FunctionServices = FunctionServices> = (params: {\n /**\n * 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, S>;\n\n/**\n * Function context.\n */\nexport interface FunctionContext {\n // TODO(dmaretskyi): Consider what we should put into context.\n}\n\nconst typeId = Symbol.for('@dxos/functions/FunctionDefinition');\n\nexport type FunctionDefinition<T = any, O = any, S extends FunctionServices = FunctionServices> = {\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\n /**\n * Keys of the required services.\n */\n services: readonly string[];\n\n handler: FunctionHandler<T, O, S>;\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 declare namespace FunctionDefinition {\n export type Any = FunctionDefinition<any, any, any>;\n export type Input<T extends Any> = T extends FunctionDefinition<infer I, infer _O, infer _S> ? I : never;\n export type Output<T extends Any> = T extends FunctionDefinition<infer _I, infer O, infer _S> ? O : never;\n export type Services<T extends Any> = T extends FunctionDefinition<infer _I, infer _O, infer S> ? S : never;\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 // TODO(dmaretskyi): This currently doesn't cause a compile-time error if the handler requests a service that is not specified\n services?: readonly Context.Tag<any, any>[];\n\n handler: FunctionHandler<T, O, FunctionServices>;\n};\n\n// TODO(dmaretskyi): Output type doesn't get typechecked.\nexport const defineFunction: {\n <I, O>(params: FunctionProps<I, O>): FunctionDefinition<I, O, FunctionServices>;\n} = ({ key, name, description, inputSchema, outputSchema = Schema.Any, handler, services }) => {\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 services: !services ? [] : getServiceKeys(services),\n } satisfies FunctionDefinition.Any;\n};\n\nconst getServiceKeys = (services: readonly Context.Tag<any, any>[]) => {\n return services.map((tag: any) => {\n if (typeof tag.key === 'string') {\n return tag.key;\n }\n console.log(tag);\n failedInvariant();\n });\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};\n\nexport const serializeFunction = (functionDef: FunctionDefinition.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 services: functionDef.services,\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 services: functionObj.services ?? [],\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 /**\n * ISO date string of the last deployment.\n */\n updated: 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 /**\n * List of required services.\n * Match the Context.Tag keys of the FunctionServices variants.\n */\n services: Schema.optional(Schema.Array(Schema.String)),\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 { Text } 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(Text.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(Text.make(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 { type ObjectMeta } from '@dxos/echo/internal';\n\n// TODO: use URL scheme for source?\nexport const FUNCTIONS_META_KEY = 'dxos.org/service/function';\n\nexport const FUNCTIONS_PRESET_META_KEY = 'dxos.org/service/function-preset';\n\n/**\n * NOTE: functionId is backend ID, not ECHO object id.\n */\nexport const getUserFunctionIdInMetadata = (meta: ObjectMeta) => {\n return meta.keys.find((key) => key.source === FUNCTIONS_META_KEY)?.id;\n};\n\n/**\n * NOTE: functionId is backend ID, not ECHO object id.\n */\nexport const setUserFunctionIdInMetadata = (meta: ObjectMeta, functionId: string) => {\n const key = meta.keys.find((key) => key.source === FUNCTIONS_META_KEY);\n if (key) {\n if (key.id !== functionId) {\n throw new Error('Metadata mismatch');\n }\n } else {\n meta.keys.push({ source: FUNCTIONS_META_KEY, id: functionId });\n }\n};\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 '../sdk';\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 '../sdk';\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\nexport { DatabaseService } from '@dxos/echo-db';\n\nexport * from './credentials';\nexport { ConfiguredCredentialsService, type ServiceCredential } from './credentials';\nexport * from './event-logger';\nexport { createEventLogger, createDefectLogger } from './event-logger';\nexport * from './function-invocation-service';\nexport * from './queues';\nexport * from './tracing';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as HttpClient from '@effect/platform/HttpClient';\nimport * as HttpClientRequest from '@effect/platform/HttpClientRequest';\nimport type * as Config from 'effect/Config';\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Redacted from 'effect/Redacted';\n\nimport { Query } from '@dxos/echo';\nimport { DatabaseService } from '@dxos/echo-db';\nimport { AccessToken } from '@dxos/types';\n\nexport type CredentialQuery = {\n service?: string;\n};\n\n// TODO(dmaretskyi): Unify with other apis.\n// packages/sdk/schema/src/common/access-token.ts\nexport type ServiceCredential = {\n service: string;\n\n // TODO(dmaretskyi): Build out.\n apiKey?: string;\n};\n\nexport class CredentialsService extends Context.Tag('@dxos/functions/CredentialsService')<\n CredentialsService,\n {\n /**\n * Query all.\n */\n queryCredentials: (query: CredentialQuery) => Promise<ServiceCredential[]>;\n\n /**\n * Get a single credential.\n * @throws {Error} If no credential is found.\n */\n getCredential: (query: CredentialQuery) => Promise<ServiceCredential>;\n }\n>() {\n static getCredential = (query: CredentialQuery): Effect.Effect<ServiceCredential, never, CredentialsService> =>\n Effect.gen(function* () {\n const credentials = yield* CredentialsService;\n return yield* Effect.promise(() => credentials.getCredential(query));\n });\n\n static getApiKey = (query: CredentialQuery): Effect.Effect<Redacted.Redacted<string>, never, CredentialsService> =>\n Effect.gen(function* () {\n const credential = yield* CredentialsService.getCredential(query);\n if (!credential.apiKey) {\n throw new Error(`API key not found for service: ${query.service}`);\n }\n return Redacted.make(credential.apiKey);\n });\n\n static configuredLayer = (credentials: ServiceCredential[]) =>\n Layer.succeed(CredentialsService, new ConfiguredCredentialsService(credentials));\n\n static layerConfig = (credentials: { service: string; apiKey: Config.Config<Redacted.Redacted<string>> }[]) =>\n Layer.effect(\n CredentialsService,\n Effect.gen(function* () {\n const serviceCredentials = yield* Effect.forEach(credentials, ({ service, apiKey }) =>\n Effect.gen(function* () {\n return {\n service,\n apiKey: Redacted.value(yield* apiKey),\n };\n }),\n );\n\n return new ConfiguredCredentialsService(serviceCredentials);\n }),\n );\n\n static layerFromDatabase = () =>\n Layer.effect(\n CredentialsService,\n Effect.gen(function* () {\n const dbService = yield* DatabaseService;\n const queryCredentials = async (query: CredentialQuery): Promise<ServiceCredential[]> => {\n const { objects: accessTokens } = await dbService.db.query(Query.type(AccessToken.AccessToken)).run();\n return accessTokens\n .filter((accessToken) => accessToken.source === query.service)\n .map((accessToken) => ({\n service: accessToken.source,\n apiKey: accessToken.token,\n }));\n };\n return {\n getCredential: async (query) => {\n const credentials = await queryCredentials(query);\n if (credentials.length === 0) {\n throw new Error(`Credential not found for service: ${query.service}`);\n }\n\n return credentials[0];\n },\n queryCredentials: async (query) => {\n return queryCredentials(query);\n },\n };\n }),\n );\n}\n\nexport class ConfiguredCredentialsService implements Context.Tag.Service<CredentialsService> {\n constructor(private readonly credentials: ServiceCredential[] = []) {}\n\n addCredentials(credentials: ServiceCredential[]): ConfiguredCredentialsService {\n this.credentials.push(...credentials);\n return this;\n }\n\n async queryCredentials(query: CredentialQuery): Promise<ServiceCredential[]> {\n return this.credentials.filter((credential) => credential.service === query.service);\n }\n\n async getCredential(query: CredentialQuery): Promise<ServiceCredential> {\n const credential = this.credentials.find((credential) => credential.service === query.service);\n if (!credential) {\n throw new Error(`Credential not found for service: ${query.service}`);\n }\n\n return credential;\n }\n}\n\n/**\n * Maps the request to include the API key from the credential.\n */\nexport const withAuthorization = (query: CredentialQuery, kind?: 'Bearer' | 'Basic') =>\n HttpClient.mapRequestEffect(\n Effect.fnUntraced(function* (request) {\n const key = yield* CredentialsService.getApiKey(query).pipe(Effect.map(Redacted.value));\n const authorization = kind ? `${kind} ${key}` : key;\n return HttpClientRequest.setHeader(request, 'Authorization', authorization);\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 { Obj, Type } from '@dxos/echo';\nimport { invariant } from '@dxos/invariant';\nimport { LogLevel, log } from '@dxos/log';\n\nimport { TracingService } from './tracing';\n\nexport const ComputeEventPayload = Schema.Union(\n Schema.Struct({\n type: Schema.Literal('begin-compute'),\n nodeId: Schema.String,\n /**\n * Names of the inputs begin computed.\n */\n inputs: Schema.Array(Schema.String),\n }),\n Schema.Struct({\n type: Schema.Literal('end-compute'),\n nodeId: Schema.String,\n /**\n * Names of the outputs computed.\n */\n outputs: Schema.Array(Schema.String),\n }),\n Schema.Struct({\n type: Schema.Literal('compute-input'),\n nodeId: Schema.String,\n property: Schema.String,\n value: Schema.Any,\n }),\n Schema.Struct({\n type: Schema.Literal('compute-output'),\n nodeId: Schema.String,\n property: Schema.String,\n value: Schema.Any,\n }),\n Schema.Struct({\n type: Schema.Literal('custom'),\n nodeId: Schema.String,\n event: Schema.Any,\n }),\n);\nexport type ComputeEventPayload = Schema.Schema.Type<typeof ComputeEventPayload>;\n\nexport const ComputeEvent = Schema.Struct({\n payload: ComputeEventPayload,\n}).pipe(Type.Obj({ typename: 'dxos.org/type/ComputeEvent', version: '0.1.0' }));\n\n/**\n * Logs event for the compute workflows.\n */\nexport class ComputeEventLogger extends Context.Tag('@dxos/functions/ComputeEventLogger')<\n ComputeEventLogger,\n { readonly log: (event: ComputeEventPayload) => void; readonly nodeId: string | undefined }\n>() {\n static noop: Context.Tag.Service<ComputeEventLogger> = {\n log: () => {},\n nodeId: undefined,\n };\n\n /**\n * Implements ComputeEventLogger using TracingService.\n */\n static layerFromTracing = Layer.effect(\n ComputeEventLogger,\n Effect.gen(function* () {\n const tracing = yield* TracingService;\n return {\n log: (event: ComputeEventPayload) => {\n tracing.write(Obj.make(ComputeEvent, { payload: event }));\n },\n nodeId: undefined,\n };\n }),\n );\n}\n\nexport const logCustomEvent = (data: any) =>\n Effect.gen(function* () {\n const logger = yield* ComputeEventLogger;\n if (!logger.nodeId) {\n throw new Error('logCustomEvent must be called within a node compute function');\n }\n logger.log({\n type: 'custom',\n nodeId: logger.nodeId,\n event: data,\n });\n });\n\nexport const createDefectLogger = <A, E, R>(): ((self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>) =>\n Effect.catchAll((error) =>\n Effect.gen(function* () {\n log.error('unhandled effect error', { error });\n throw error;\n }),\n );\n\nexport const createEventLogger = (\n level: LogLevel,\n message: string = 'event',\n): Context.Tag.Service<ComputeEventLogger> => {\n const logFunction = (\n {\n [LogLevel.WARN]: log.warn,\n [LogLevel.VERBOSE]: log.verbose,\n [LogLevel.DEBUG]: log.debug,\n [LogLevel.INFO]: log.info,\n [LogLevel.ERROR]: log.error,\n } as any\n )[level];\n invariant(logFunction);\n return {\n log: (event: ComputeEventPayload) => {\n logFunction(message, event);\n },\n nodeId: undefined,\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';\n\nimport { AgentStatus } from '@dxos/ai';\nimport { Obj } from '@dxos/echo';\nimport type { ObjectId } from '@dxos/echo/internal';\nimport { Message } from '@dxos/types';\n\n/**\n * Provides a way for compute primitives (functions, workflows, tools)\n * to emit an execution trace as a series of structured ECHO objects.\n */\nexport class TracingService extends Context.Tag('@dxos/functions/TracingService')<\n TracingService,\n {\n /**\n * Gets the parent message ID.\n */\n getTraceContext: () => TracingService.TraceContext;\n\n /**\n * Write an event to the tracing queue.\n * @param event - The event to write. Must be an a typed object.\n */\n write: (event: Obj.Any) => void;\n }\n>() {\n static noop: Context.Tag.Service<TracingService> = {\n getTraceContext: () => ({}),\n write: () => {},\n };\n\n static layerNoop: Layer.Layer<TracingService> = Layer.succeed(TracingService, TracingService.noop);\n /**\n * Creates a TracingService layer that emits events to the parent tracing service.\n */\n static layerSubframe = (mapContext: (currentContext: TracingService.TraceContext) => TracingService.TraceContext) =>\n Layer.effect(\n TracingService,\n Effect.gen(function* () {\n const tracing = yield* TracingService;\n const context = mapContext(tracing.getTraceContext());\n return {\n write: (event) => tracing.write(event),\n getTraceContext: () => context,\n };\n }),\n );\n\n /**\n * Emit the current human-readable execution status.\n */\n static emitStatus: (\n data: Omit<Obj.MakeProps<typeof AgentStatus>, 'created'>,\n ) => Effect.Effect<void, never, TracingService> = Effect.fnUntraced(function* (data) {\n const tracing = yield* TracingService;\n tracing.write(\n Obj.make(AgentStatus, {\n parentMessage: tracing.getTraceContext().parentMessage,\n toolCallId: tracing.getTraceContext().toolCallId,\n created: new Date().toISOString(),\n ...data,\n }),\n );\n });\n\n static emitConverationMessage: (\n data: Obj.MakeProps<typeof Message.Message>,\n ) => Effect.Effect<void, never, TracingService> = Effect.fnUntraced(function* (data) {\n const tracing = yield* TracingService;\n tracing.write(\n Obj.make(Message.Message, {\n parentMessage: tracing.getTraceContext().parentMessage,\n ...data,\n properties: {\n [MESSAGE_PROPERTY_TOOL_CALL_ID]: tracing.getTraceContext().toolCallId,\n ...data.properties,\n },\n }),\n );\n });\n}\n\nexport namespace TracingService {\n export interface TraceContext {\n /**\n * If this thread sprung from a tool call, this is the ID of the message containing the tool call.\n */\n parentMessage?: ObjectId;\n\n /**\n * If the current thread is a byproduct of a tool call, this is the ID of the tool call.\n */\n toolCallId?: string;\n\n debugInfo?: unknown;\n }\n}\n\n/**\n * Goes into {@link Message['properties']}\n */\nexport const MESSAGE_PROPERTY_TOOL_CALL_ID = 'toolCallId' as const;\n", "//\n// Copyright 2025 DXOS.org\n//\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\n\nimport { type FunctionDefinition, type InvocationServices } from '../sdk';\n\nexport class FunctionInvocationService extends Context.Tag('@dxos/functions/FunctionInvocationService')<\n FunctionInvocationService,\n {\n invokeFunction<I, O>(\n functionDef: FunctionDefinition<I, O, any>,\n input: I,\n ): Effect.Effect<O, never, InvocationServices>;\n }\n>() {\n static invokeFunction = <I, O>(\n functionDef: FunctionDefinition<I, O, any>,\n input: I,\n ): Effect.Effect<O, never, FunctionInvocationService | InvocationServices> =>\n Effect.serviceFunctionEffect(FunctionInvocationService, (service) => service.invokeFunction)(functionDef, input);\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 type { Obj, Relation } from '@dxos/echo';\nimport type { Queue, QueueAPI, QueueFactory } from '@dxos/echo-db';\nimport type { DXN, QueueSubspaceTag } from '@dxos/keys';\n\n/**\n * Gives access to all queues.\n */\nexport class QueueService extends Context.Tag('@dxos/functions/QueueService')<\n QueueService,\n {\n /**\n * API to access the queues.\n */\n readonly queues: QueueAPI;\n\n /**\n * The queue that is used to store the context of the current research.\n * @deprecated Use `ContextQueueService` instead.\n */\n readonly queue: Queue | undefined;\n }\n>() {\n static notAvailable = Layer.succeed(QueueService, {\n queues: {\n get(_dxn) {\n throw new Error('Queues not available');\n },\n create() {\n throw new Error('Queues not available');\n },\n },\n queue: undefined,\n });\n\n static make = (queues: QueueFactory, queue?: Queue): Context.Tag.Service<QueueService> => {\n return {\n queues,\n queue,\n };\n };\n\n static layer = (queues: QueueFactory, queue?: Queue): Layer.Layer<QueueService> =>\n Layer.succeed(QueueService, QueueService.make(queues, queue));\n\n /**\n * Gets a queue by its DXN.\n */\n static getQueue = <T extends Obj.Any | Relation.Any = Obj.Any | Relation.Any>(\n dxn: DXN,\n ): Effect.Effect<Queue<T>, never, QueueService> => QueueService.pipe(Effect.map(({ queues }) => queues.get<T>(dxn)));\n\n /**\n * Creates a new queue.\n */\n static createQueue = <T extends Obj.Any | Relation.Any = Obj.Any | Relation.Any>(options?: {\n subspaceTag?: QueueSubspaceTag;\n }): Effect.Effect<Queue<T>, never, QueueService> =>\n QueueService.pipe(Effect.map(({ queues }) => queues.create<T>(options)));\n\n static append = <T extends Obj.Any | Relation.Any = Obj.Any | Relation.Any>(\n queue: Queue<T>,\n objects: T[],\n ): Effect.Effect<void> => Effect.promise(() => queue.append(objects));\n}\n\n/**\n * Gives access to a specific queue passed as a context.\n */\nexport class ContextQueueService extends Context.Tag('@dxos/functions/ContextQueueService')<\n ContextQueueService,\n {\n readonly queue: Queue;\n }\n>() {\n static layer = (queue: Queue) => Layer.succeed(ContextQueueService, { queue });\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { AiService } from '@dxos/ai';\nimport { Type } from '@dxos/echo';\nimport { EchoClient } from '@dxos/echo-db';\nimport { acquireReleaseResource } from '@dxos/effect';\nimport { failedInvariant, invariant } from '@dxos/invariant';\nimport { PublicKey } from '@dxos/keys';\nimport { type FunctionProtocol } from '@dxos/protocols';\n\nimport { FunctionError } from '../errors';\nimport { FunctionDefinition, type FunctionServices } from '../sdk';\nimport { CredentialsService, DatabaseService, FunctionInvocationService, TracingService } from '../services';\nimport { QueueService } from '../services';\n\n/**\n * Wraps a function handler made with `defineFunction` to a protocol that the functions-runtime expects.\n */\nexport const wrapFunctionHandler = (func: FunctionDefinition): FunctionProtocol.Func => {\n if (!FunctionDefinition.isFunction(func)) {\n throw new TypeError('Invalid function definition');\n }\n\n return {\n meta: {\n key: func.key,\n name: func.name,\n description: func.description,\n inputSchema: Type.toJsonSchema(func.inputSchema),\n outputSchema: func.outputSchema === undefined ? undefined : Type.toJsonSchema(func.outputSchema),\n services: func.services,\n },\n handler: async ({ data, context }) => {\n if (\n (func.services.includes(DatabaseService.key) || func.services.includes(QueueService.key)) &&\n (!context.services.dataService || !context.services.queryService)\n ) {\n throw new FunctionError({\n message: 'Services not provided: dataService, queryService',\n });\n }\n\n try {\n if (!SchemaAST.isAnyKeyword(func.inputSchema.ast)) {\n Schema.validateSync(func.inputSchema)(data);\n }\n\n let result = await func.handler({\n // TODO(dmaretskyi): Fix the types.\n context: context as any,\n data,\n });\n\n if (Effect.isEffect(result)) {\n result = await Effect.runPromise(\n (result as Effect.Effect<unknown, unknown, FunctionServices>).pipe(\n Effect.orDie,\n Effect.provide(createServiceLayer(context)),\n ),\n );\n }\n\n if (func.outputSchema && !SchemaAST.isAnyKeyword(func.outputSchema.ast)) {\n Schema.validateSync(func.outputSchema)(result);\n }\n\n return result;\n } catch (error) {\n if (FunctionError.is(error)) {\n throw error;\n } else {\n throw new FunctionError({\n cause: error,\n context: { func: func.key },\n });\n }\n }\n },\n };\n};\n\n/**\n * Creates a layer of services for the function.\n */\nconst createServiceLayer = (context: FunctionProtocol.Context): Layer.Layer<FunctionServices> => {\n return Layer.unwrapScoped(\n Effect.gen(function* () {\n let client: EchoClient | undefined;\n\n if (context.services.dataService && context.services.queryService) {\n client = yield* acquireReleaseResource(() => {\n invariant(context.services.dataService && context.services.queryService);\n // TODO(dmaretskyi): Queues service.\n return new EchoClient().connectToService({\n dataService: context.services.dataService,\n queryService: context.services.queryService,\n queueService: context.services.queueService,\n });\n });\n }\n\n const db =\n client && context.spaceId\n ? yield* acquireReleaseResource(() =>\n client.constructDatabase({\n spaceId: context.spaceId ?? failedInvariant(),\n spaceKey: PublicKey.fromHex(context.spaceKey ?? failedInvariant('spaceKey missing in context')),\n reactiveSchemaQuery: false,\n }),\n )\n : undefined;\n\n if (db) {\n console.log('Setting space root', context.spaceRootUrl);\n yield* Effect.promise(() =>\n db!.setSpaceRoot(context.spaceRootUrl ?? failedInvariant('spaceRootUrl missing in context')),\n );\n }\n\n const queues = client && context.spaceId ? client.constructQueueFactory(context.spaceId) : undefined;\n\n const dbLayer = db ? DatabaseService.layer(db) : DatabaseService.notAvailable;\n const queuesLayer = queues ? QueueService.layer(queues) : QueueService.notAvailable;\n const credentials = dbLayer\n ? CredentialsService.layerFromDatabase().pipe(Layer.provide(dbLayer))\n : CredentialsService.configuredLayer([]);\n const functionInvocationService = MockedFunctionInvocationService;\n const aiService = AiService.notAvailable;\n const tracing = TracingService.layerNoop;\n\n return Layer.mergeAll(dbLayer, queuesLayer, credentials, functionInvocationService, aiService, tracing);\n }),\n );\n};\n\nconst MockedFunctionInvocationService = Layer.succeed(FunctionInvocationService, {\n invokeFunction: () => Effect.die('Calling functions from functions is not implemented yet.'),\n});\n"],
5
- "mappings": ";;;;;;;AAIA,SAASA,iBAAwC;AAE1C,IAAMC,2BAAN,cAAuCC,UAAUC,OAAO,yBAAyB,uBAAA,EAAA;EACtF,YAAYC,SAAiBC,SAA6C;AACxE,UAAM;MAAEC,SAAS;QAAEF;MAAQ;MAAG,GAAGC;IAAQ,CAAA;EAC3C;AACF;AAEO,IAAME,wBAAN,cAAoCL,UAAUC,OAAO,sBAAsB,oBAAA,EAAA;EAChF,YAAYK,aAAqBH,SAA6C;AAC5E,UAAM;MAAEC,SAAS;QAAEG,UAAUD;MAAY;MAAG,GAAGH;IAAQ,CAAA;EACzD;AACF;AAEO,IAAMK,gBAAN,cAA4BR,UAAUC,OAAO,kBAAkB,2BAAA,EAAA;AAA8B;AAE7F,IAAMQ,4BAAN,cAAwCT,UAAUC,OAAO,2BAA2B,yBAAA,EAAA;AAA4B;;;AChBvH,YAAYS,aAAY;AACxB,YAAYC,aAAY;;;ACAxB,YAAYC,YAAY;AACxB,YAAYC,aAAY;AAGxB,SAASC,OAAAA,MAAKC,QAAAA,aAAY;AAE1B,SAASC,gBAAgBC,uBAAuB;;;ACXhD;;;cAAAC;;AAIA,YAAYC,aAAY;AAExB,SAASC,OAAAA,MAAKC,QAAAA,aAA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AaJ,QAAQH,SAASO;UAC9BC,cAAcL,QAAQH,SAASQ;UAC/BwB,cAAc7B,QAAQH,SAASgC;QACjC,CAAA;MACF,CAAA;IACF;AAEA,UAAMC,KACJN,UAAUxB,QAAQ+B,UACd,OAAON,uBAAuB,MAC5BD,OAAOQ,kBAAkB;MACvBD,SAAS/B,QAAQ+B,WAAWE,iBAAAA;MAC5BC,UAAUC,UAAUC,QAAQpC,QAAQkC,YAAYD,iBAAgB,6BAAA,CAAA;MAChEI,qBAAqB;IACvB,CAAA,CAAA,IAEFzC;AAEN,QAAIkC,IAAI;AACNQ,cAAQC,IAAI,sBAAsBvC,QAAQwC,YAAY;AACtD,aAAcC,iBAAQ,MACpBX,GAAIY,aAAa1C,QAAQwC,gBAAgBP,iBAAgB,iCAAA,CAAA,CAAA;IAE7D;AAEA,UAAMU,SAASnB,UAAUxB,QAAQ+B,UAAUP,OAAOoB,sBAAsB5C,QAAQ+B,OAAO,IAAInC;AAE3F,UAAMiD,UAAUf,KAAK5B,iBAAgB4C,MAAMhB,EAAAA,IAAM5B,iBAAgB6C;AACjE,UAAMC,cAAcL,SAASxC,aAAa2C,MAAMH,MAAAA,IAAUxC,aAAa4C;AACvE,UAAME,cAAcJ,UAChBK,mBAAmBC,kBAAiB,EAAGpC,KAAWE,eAAQ4B,OAAAA,CAAAA,IAC1DK,mBAAmBE,gBAAgB,CAAA,CAAE;AACzC,UAAMC,4BAA4BC;AAClC,UAAMC,YAAYC,UAAUT;AAC5B,UAAMU,UAAUC,eAAeC;AAE/B,WAAaC,gBAASf,SAASG,aAAaC,aAAaI,2BAA2BE,WAAWE,OAAAA;EACjG,CAAA,CAAA;AAEJ;AAEA,IAAMH,kCAAwCO,eAAQC,2BAA2B;EAC/EC,gBAAgB,MAAaC,aAAI,0DAAA;AACnC,CAAA;",
6
- "names": ["BaseError", "ServiceNotAvailableError", "BaseError", "extend", "service", "options", "context", "FunctionNotFoundError", "functionKey", "function", "FunctionError", "TriggerStateNotFoundError", "Effect", "Schema", "Effect", "Schema", "Obj", "Type", "assertArgument", "failedInvariant", "make", "Schema", "Obj", "Type", "JsonSchemaType", "LabelAnnotation", "Ref", "Schema", "Obj", "Ref", "Type", "FormAnnotation", "LabelAnnotation", "Text", "Script", "Struct", "name", "String", "pipe", "optional", "description", "changed", "Boolean", "FormAnnotation", "set", "source", "Type", "Ref", "Text", "Obj", "typename", "version", "LabelAnnotation", "make", "props", "Function", "Struct", "key", "optional", "String", "annotations", "description", "name", "NonEmptyString", "version", "updated", "source", "Ref", "Script", "inputSchema", "JsonSchemaType", "outputSchema", "services", "Array", "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", "FUNCTIONS_META_KEY", "FUNCTIONS_PRESET_META_KEY", "getUserFunctionIdInMetadata", "meta", "keys", "find", "key", "source", "id", "setUserFunctionIdInMetadata", "functionId", "Error", "push", "typeId", "Symbol", "for", "defineFunction", "key", "name", "description", "inputSchema", "outputSchema", "Any", "handler", "services", "isSchema", "Error", "limit", "stackTraceLimit", "traceError", "cache", "captureStackTrace", "stack", "undefined", "split", "trim", "handlerWithSpan", "args", "result", "isEffect", "withSpan", "getServiceKeys", "map", "tag", "console", "log", "failedInvariant", "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$", "DatabaseService", "HttpClient", "HttpClientRequest", "Context", "Effect", "Layer", "Redacted", "Query", "DatabaseService", "AccessToken", "CredentialsService", "Tag", "getCredential", "query", "gen", "credentials", "promise", "getApiKey", "credential", "apiKey", "Error", "service", "make", "configuredLayer", "succeed", "ConfiguredCredentialsService", "layerConfig", "effect", "serviceCredentials", "forEach", "value", "layerFromDatabase", "dbService", "DatabaseService", "queryCredentials", "objects", "accessTokens", "db", "Query", "type", "AccessToken", "run", "filter", "accessToken", "source", "map", "token", "length", "addCredentials", "push", "find", "withAuthorization", "kind", "mapRequestEffect", "fnUntraced", "request", "key", "pipe", "authorization", "setHeader", "Context", "Effect", "Layer", "Schema", "Obj", "Type", "invariant", "LogLevel", "log", "Context", "Effect", "Layer", "AgentStatus", "Obj", "Message", "TracingService", "Tag", "noop", "getTraceContext", "write", "layerNoop", "succeed", "layerSubframe", "mapContext", "effect", "gen", "tracing", "context", "event", "emitStatus", "fnUntraced", "data", "Obj", "make", "AgentStatus", "parentMessage", "toolCallId", "created", "Date", "toISOString", "emitConverationMessage", "Message", "properties", "MESSAGE_PROPERTY_TOOL_CALL_ID", "ComputeEventPayload", "Union", "Struct", "type", "Literal", "nodeId", "String", "inputs", "Array", "outputs", "property", "value", "Any", "event", "ComputeEvent", "payload", "pipe", "Type", "Obj", "typename", "version", "ComputeEventLogger", "Tag", "noop", "log", "undefined", "layerFromTracing", "effect", "gen", "tracing", "TracingService", "write", "make", "logCustomEvent", "data", "logger", "Error", "createDefectLogger", "catchAll", "error", "createEventLogger", "level", "message", "logFunction", "LogLevel", "WARN", "warn", "VERBOSE", "verbose", "DEBUG", "debug", "INFO", "info", "ERROR", "invariant", "Context", "Effect", "FunctionInvocationService", "Tag", "invokeFunction", "functionDef", "input", "serviceFunctionEffect", "service", "Context", "Effect", "Layer", "QueueService", "Tag", "notAvailable", "succeed", "queues", "get", "_dxn", "Error", "create", "queue", "undefined", "make", "layer", "getQueue", "dxn", "pipe", "map", "createQueue", "options", "append", "objects", "promise", "ContextQueueService", "Effect", "Layer", "Schema", "SchemaAST", "AiService", "Type", "EchoClient", "acquireReleaseResource", "failedInvariant", "invariant", "PublicKey", "wrapFunctionHandler", "func", "FunctionDefinition", "isFunction", "TypeError", "meta", "key", "name", "description", "inputSchema", "Type", "toJsonSchema", "outputSchema", "undefined", "services", "handler", "data", "context", "includes", "DatabaseService", "QueueService", "dataService", "queryService", "FunctionError", "message", "isAnyKeyword", "ast", "Schema", "validateSync", "result", "isEffect", "runPromise", "pipe", "orDie", "provide", "createServiceLayer", "error", "is", "cause", "unwrapScoped", "gen", "client", "acquireReleaseResource", "invariant", "EchoClient", "connectToService", "queueService", "db", "spaceId", "constructDatabase", "failedInvariant", "spaceKey", "PublicKey", "fromHex", "reactiveSchemaQuery", "console", "log", "spaceRootUrl", "promise", "setSpaceRoot", "queues", "constructQueueFactory", "dbLayer", "layer", "notAvailable", "queuesLayer", "credentials", "CredentialsService", "layerFromDatabase", "configuredLayer", "functionInvocationService", "MockedFunctionInvocationService", "aiService", "AiService", "tracing", "TracingService", "layerNoop", "mergeAll", "succeed", "FunctionInvocationService", "invokeFunction", "die"]
7
- }
@@ -1 +0,0 @@
1
- {"inputs":{"src/errors.ts":{"bytes":3093,"imports":[{"path":"@dxos/errors","kind":"import-statement","external":true}],"format":"esm"},"src/types/Script.ts":{"bytes":3911,"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":5969,"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/url.ts":{"bytes":3230,"imports":[],"format":"esm"},"src/types/index.ts":{"bytes":1061,"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"},{"path":"src/types/url.ts","kind":"import-statement","original":"./url"}],"format":"esm"},"src/sdk.ts":{"bytes":18832,"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/types/index.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"src/example/fib.ts":{"bytes":3247,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"src/sdk.ts","kind":"import-statement","original":"../sdk"}],"format":"esm"},"src/example/reply.ts":{"bytes":2136,"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/sdk.ts","kind":"import-statement","original":"../sdk"}],"format":"esm"},"src/example/sleep.ts":{"bytes":2579,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"src/sdk.ts","kind":"import-statement","original":"../sdk"}],"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/services/credentials.ts":{"bytes":15210,"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/echo-db","kind":"import-statement","external":true},{"path":"@dxos/types","kind":"import-statement","external":true}],"format":"esm"},"src/services/tracing.ts":{"bytes":8840,"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/types","kind":"import-statement","external":true}],"format":"esm"},"src/services/event-logger.ts":{"bytes":11905,"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/function-invocation-service.ts":{"bytes":2233,"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true}],"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/index.ts":{"bytes":1597,"imports":[{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"src/services/credentials.ts","kind":"import-statement","original":"./credentials"},{"path":"src/services/credentials.ts","kind":"import-statement","original":"./credentials"},{"path":"src/services/event-logger.ts","kind":"import-statement","original":"./event-logger"},{"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/queues.ts","kind":"import-statement","original":"./queues"},{"path":"src/services/tracing.ts","kind":"import-statement","original":"./tracing"}],"format":"esm"},"src/protocol/protocol.ts":{"bytes":18414,"imports":[{"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":"effect/SchemaAST","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"src/errors.ts","kind":"import-statement","original":"../errors"},{"path":"src/sdk.ts","kind":"import-statement","original":"../sdk"},{"path":"src/services/index.ts","kind":"import-statement","original":"../services"},{"path":"src/services/index.ts","kind":"import-statement","original":"../services"}],"format":"esm"},"src/protocol/index.ts":{"bytes":459,"imports":[{"path":"src/protocol/protocol.ts","kind":"import-statement","original":"./protocol"}],"format":"esm"},"src/index.ts":{"bytes":867,"imports":[{"path":"src/errors.ts","kind":"import-statement","original":"./errors"},{"path":"src/example/index.ts","kind":"import-statement","original":"./example"},{"path":"src/sdk.ts","kind":"import-statement","original":"./sdk"},{"path":"src/services/index.ts","kind":"import-statement","original":"./services"},{"path":"src/types/index.ts","kind":"import-statement","original":"./types"},{"path":"src/protocol/index.ts","kind":"import-statement","original":"./protocol"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":66248},"dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/errors","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/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":"@dxos/echo-db","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/echo-db","kind":"import-statement","external":true},{"path":"@dxos/types","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":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/types","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/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":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"effect/SchemaAST","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","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","FunctionInvocationService","FunctionNotFoundError","MESSAGE_PROPERTY_TOOL_CALL_ID","QueueService","Script","ServiceNotAvailableError","TracingService","Trigger","TriggerEvent","TriggerStateNotFoundError","createDefectLogger","createEventLogger","defineFunction","deserializeFunction","getUserFunctionIdInMetadata","logCustomEvent","serializeFunction","setUserFunctionIdInMetadata","withAuthorization","wrapFunctionHandler"],"entryPoint":"src/index.ts","inputs":{"src/errors.ts":{"bytesInOutput":744},"src/index.ts":{"bytesInOutput":0},"src/example/fib.ts":{"bytesInOutput":708},"src/sdk.ts":{"bytesInOutput":3412},"src/types/Function.ts":{"bytesInOutput":1675},"src/types/Script.ts":{"bytesInOutput":897},"src/types/index.ts":{"bytesInOutput":0},"src/types/Trigger.ts":{"bytesInOutput":3602},"src/types/TriggerEvent.ts":{"bytesInOutput":1314},"src/types/url.ts":{"bytesInOutput":576},"src/example/reply.ts":{"bytesInOutput":448},"src/example/sleep.ts":{"bytesInOutput":550},"src/example/index.ts":{"bytesInOutput":164},"src/services/index.ts":{"bytesInOutput":69},"src/services/credentials.ts":{"bytesInOutput":3402},"src/services/event-logger.ts":{"bytesInOutput":2934},"src/services/tracing.ts":{"bytesInOutput":1773},"src/services/function-invocation-service.ts":{"bytesInOutput":390},"src/services/queues.ts":{"bytesInOutput":1233},"src/protocol/protocol.ts":{"bytesInOutput":4446}},"bytes":29942}}}