@dxos/functions 0.8.3 → 0.8.4-main.84f28bd
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.
- package/dist/lib/browser/bundler/index.mjs +21 -10
- package/dist/lib/browser/bundler/index.mjs.map +3 -3
- package/dist/lib/browser/{chunk-WEFZUEL2.mjs → chunk-54U464M4.mjs} +79 -19
- package/dist/lib/browser/chunk-54U464M4.mjs.map +7 -0
- package/dist/lib/browser/edge/index.mjs +2 -2
- package/dist/lib/browser/index.mjs +20 -14
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +58 -7
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/bundler/index.mjs +21 -10
- package/dist/lib/node-esm/bundler/index.mjs.map +3 -3
- package/dist/lib/node-esm/{chunk-LIYPMWNQ.mjs → chunk-XDSX35BS.mjs} +79 -19
- package/dist/lib/node-esm/chunk-XDSX35BS.mjs.map +7 -0
- package/dist/lib/node-esm/edge/index.mjs +2 -2
- package/dist/lib/node-esm/index.mjs +20 -14
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +58 -7
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/types/src/bundler/bundler.d.ts +1 -2
- package/dist/types/src/bundler/bundler.d.ts.map +1 -1
- package/dist/types/src/executor/executor.d.ts.map +1 -1
- package/dist/types/src/handler.d.ts +3 -6
- package/dist/types/src/handler.d.ts.map +1 -1
- package/dist/types/src/schema.d.ts +3 -3
- package/dist/types/src/services/credentials.d.ts +1 -1
- package/dist/types/src/services/credentials.d.ts.map +1 -1
- package/dist/types/src/services/database.d.ts +5 -1
- package/dist/types/src/services/database.d.ts.map +1 -1
- package/dist/types/src/services/index.d.ts +1 -0
- package/dist/types/src/services/index.d.ts.map +1 -1
- package/dist/types/src/services/queues.d.ts +2 -2
- package/dist/types/src/services/queues.d.ts.map +1 -1
- package/dist/types/src/services/service-container.d.ts +3 -1
- package/dist/types/src/services/service-container.d.ts.map +1 -1
- package/dist/types/src/services/tool-resolver.d.ts +14 -0
- package/dist/types/src/services/tool-resolver.d.ts.map +1 -0
- package/dist/types/src/testing/services.d.ts +67 -9
- package/dist/types/src/testing/services.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +9 -9
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +29 -26
- package/src/bundler/bundler.test.ts +1 -1
- package/src/bundler/bundler.ts +26 -4
- package/src/executor/executor.ts +15 -8
- package/src/handler.ts +6 -6
- package/src/services/credentials.ts +1 -1
- package/src/services/database.ts +23 -1
- package/src/services/index.ts +1 -0
- package/src/services/queues.ts +9 -4
- package/src/services/service-container.ts +21 -3
- package/src/services/tool-resolver.ts +31 -0
- package/src/testing/services.ts +156 -14
- package/src/translations.ts +4 -4
- package/dist/lib/browser/chunk-WEFZUEL2.mjs.map +0 -7
- package/dist/lib/node/bundler/index.cjs +0 -260
- package/dist/lib/node/bundler/index.cjs.map +0 -7
- package/dist/lib/node/chunk-IJAE7FZK.cjs +0 -320
- package/dist/lib/node/chunk-IJAE7FZK.cjs.map +0 -7
- package/dist/lib/node/edge/index.cjs +0 -94
- package/dist/lib/node/edge/index.cjs.map +0 -7
- package/dist/lib/node/index.cjs +0 -522
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node/testing/index.cjs +0 -43
- package/dist/lib/node/testing/index.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-LIYPMWNQ.mjs.map +0 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/handler.ts", "../../../src/schema.ts", "../../../src/trace.ts", "../../../src/types.ts", "../../../src/url.ts", "../../../src/executor/executor.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Schema, type Context, type Effect } from 'effect';\n\nimport { type AiServiceClient } from '@dxos/ai';\n// import { type Space } from '@dxos/client/echo';\nimport type { CoreDatabase, EchoDatabase } from '@dxos/echo-db';\nimport { type HasId } from '@dxos/echo-schema';\nimport { type SpaceId, type DXN } from '@dxos/keys';\nimport { type QueryResult } from '@dxos/protocols';\n\n// TODO(burdon): Model after http request. Ref Lambda/OpenFaaS.\n// https://docs.aws.amazon.com/lambda/latest/dg/typescript-handler.html\n// https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml/#functions\n// https://www.npmjs.com/package/aws-lambda\n\n/**\n * Function handler.\n */\nexport type FunctionHandler<TData = {}, TOutput = any> = (params: {\n /**\n * Services and context available to the function.\n */\n context: FunctionContext;\n\n /**\n * Data passed as the input to the function.\n * Must match the function's input schema.\n * This will be the payload from the trigger or other data passed into the function in a workflow.\n */\n data: TData;\n}) => TOutput | Promise<TOutput> | Effect.Effect<TOutput, any>;\n\n/**\n * Function context.\n */\nexport interface FunctionContext {\n /**\n * Resolves a service available to the function.\n * @throws if the service is not available.\n */\n getService: <T extends Context.Tag<any, any>>(tag: T) => Context.Tag.Service<T>;\n\n getSpace: (spaceId: SpaceId) => Promise<SpaceAPI>;\n\n /**\n * Space from which the function was invoked.\n */\n space: SpaceAPI | undefined;\n\n ai: AiServiceClient;\n}\n\nexport interface FunctionContextAi {\n // TODO(dmaretskyi): Refer to cloudflare AI docs for more comprehensive typedefs.\n run(model: string, inputs: any, options?: any): Promise<any>;\n}\n\n//\n// API.\n//\n\n// TODO(dmaretskyi): Temporary API to get the queues working.\n// TODO(dmaretskyi): To be replaced with integrating queues into echo.\nexport interface QueuesAPI {\n queryQueue(queue: DXN, options?: {}): Promise<QueryResult>;\n insertIntoQueue(queue: DXN, objects: HasId[]): Promise<void>;\n}\n\n/**\n * Space interface available to functions.\n */\nexport interface SpaceAPI {\n get id(): SpaceId;\n /**\n * @deprecated\n */\n get crud(): CoreDatabase;\n get db(): EchoDatabase;\n // TODO(dmaretskyi): Align with echo api --- queues.get(id).append(items);\n get queues(): QueuesAPI;\n}\n\n// TODO(wittjosiah): Queues are incompatible.\nconst __assertFunctionSpaceIsCompatibleWithTheClientSpace = () => {\n // const _: SpaceAPI = {} as Space;\n};\n\nexport type FunctionDefinition<T = {}, O = any> = {\n description?: string;\n inputSchema: Schema.Schema<T, any>;\n outputSchema?: Schema.Schema<O, any>;\n handler: FunctionHandler<T, O>;\n};\n\n// TODO(dmaretskyi): Bind input type to function handler.\nexport const defineFunction = <T, O>(params: FunctionDefinition<T, O>): FunctionDefinition<T, O> => {\n if (!Schema.isSchema(params.inputSchema)) {\n throw new Error('Input schema must be a valid schema');\n }\n if (typeof params.handler !== 'function') {\n throw new Error('Handler must be a function');\n }\n\n return {\n description: params.description,\n inputSchema: params.inputSchema,\n outputSchema: params.outputSchema ?? Schema.Any,\n handler: params.handler,\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { Type } from '@dxos/echo';\nimport { JsonSchemaType, LabelAnnotation, Ref } from '@dxos/echo-schema';\nimport { DataType } from '@dxos/schema';\n\n/**\n * Source script.\n */\nexport const ScriptType = Schema.Struct({\n name: Schema.optional(Schema.String),\n description: Schema.optional(Schema.String),\n // TODO(burdon): Change to hash of deployed content.\n // Whether source has changed since last deploy.\n changed: Schema.optional(Schema.Boolean),\n source: Ref(DataType.Text),\n}).pipe(\n Type.Obj({\n typename: 'dxos.org/type/Script',\n version: '0.1.0',\n }),\n LabelAnnotation.set(['name']),\n);\n\nexport interface ScriptType extends Schema.Schema.Type<typeof ScriptType> {}\n\n/**\n * Function deployment.\n */\nexport const FunctionType = Schema.Struct({\n // TODO(burdon): Rename to id/uri?\n name: Schema.NonEmptyString,\n version: Schema.String,\n\n description: Schema.optional(Schema.String),\n\n // Reference to a source script if it exists within ECHO.\n // TODO(burdon): Don't ref ScriptType directly (core).\n source: Schema.optional(Ref(ScriptType)),\n\n inputSchema: Schema.optional(JsonSchemaType),\n outputSchema: Schema.optional(JsonSchemaType),\n\n // Local binding to a function name.\n binding: Schema.optional(Schema.String),\n}).pipe(\n Type.Obj({\n typename: 'dxos.org/type/Function',\n version: '0.1.0',\n }),\n LabelAnnotation.set(['name']),\n);\nexport interface FunctionType extends Schema.Schema.Type<typeof FunctionType> {}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { Type, type Ref } from '@dxos/echo';\nimport { Queue } from '@dxos/echo-db';\nimport { ObjectId } from '@dxos/echo-schema';\nimport { log } from '@dxos/log';\n\nimport { FunctionTrigger, type FunctionTriggerType } from './types';\n\nexport enum InvocationOutcome {\n SUCCESS = 'success',\n FAILURE = 'failure',\n PENDING = 'pending',\n}\n\n// TODO(burdon): Convert to extensible discriminated union of EDGE events.\nexport enum InvocationTraceEventType {\n START = 'start',\n END = 'end',\n}\n\nexport const TraceEventException = Schema.Struct({\n timestampMs: Schema.Number,\n message: Schema.String,\n name: Schema.String,\n stack: Schema.optional(Schema.String),\n});\nexport type TraceEventException = Schema.Schema.Type<typeof TraceEventException>;\n\nexport const InvocationTraceStartEvent = Schema.Struct({\n /**\n * Queue message id.\n */\n id: ObjectId,\n type: Schema.Literal(InvocationTraceEventType.START),\n /**\n * Invocation id, the same for invocation start and end events.\n */\n invocationId: ObjectId,\n /**\n * Event generation time.\n */\n timestampMs: Schema.Number,\n /**\n * Data passed to function / workflow as an argument.\n */\n // TODO(burdon): Input schema?\n input: Schema.Object,\n /**\n * Queue for function/workflow invocation events.\n */\n invocationTraceQueue: Type.Ref(Queue),\n /**\n * DXN of the invoked function/workflow.\n */\n invocationTarget: Type.Ref(Type.Expando),\n /**\n * Present for automatic invocations.\n */\n trigger: Schema.optional(Type.Ref(FunctionTrigger)),\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 timestampMs: 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 timestampMs: Schema.Number,\n level: Schema.String,\n message: Schema.String,\n context: Schema.optional(Schema.Object),\n});\n\nexport const TraceEvent = Schema.Struct({\n id: ObjectId,\n // TODO(burdon): Need enum/numeric result (not string).\n outcome: Schema.String,\n truncated: Schema.Boolean,\n /**\n * Time when the event was persisted.\n */\n ingestionTimestampMs: Schema.Number,\n logs: Schema.Array(TraceEventLog),\n exceptions: Schema.Array(TraceEventException),\n}).pipe(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 timestampMs: number;\n outcome: InvocationOutcome;\n input: object;\n durationMs: number;\n invocationTraceQueue: Ref.Ref<Queue>;\n invocationTarget: Ref.Ref<Type.Expando>;\n trigger?: Ref.Ref<FunctionTriggerType>;\n exception?: TraceEventException;\n};\n\nexport const createInvocationSpans = (items?: InvocationTraceEvent[]): InvocationSpan[] => {\n if (!items) {\n return [];\n }\n\n const eventsByInvocationId = new Map<string, { start?: InvocationTraceStartEvent; end?: InvocationTraceEndEvent }>();\n for (const event of items) {\n if (!('invocationId' in event)) {\n // Skip legacy format entries.\n continue;\n }\n\n const invocationId = event.invocationId;\n const entry = eventsByInvocationId.get(invocationId) || { start: undefined, end: undefined };\n if (event.type === InvocationTraceEventType.START) {\n entry.start = event as InvocationTraceStartEvent;\n } else if (event.type === InvocationTraceEventType.END) {\n entry.end = event as InvocationTraceEndEvent;\n }\n\n eventsByInvocationId.set(invocationId, entry);\n }\n\n const now = Date.now();\n const result: InvocationSpan[] = [];\n\n // Create spans for each invocation\n for (const [invocationId, { start, end }] of eventsByInvocationId.entries()) {\n if (!start) {\n // No start event, can't create a meaningful span\n log.warn('found end event without matching start', { invocationId });\n continue;\n }\n\n const isInProgress = end === undefined;\n\n result.push({\n id: invocationId,\n timestampMs: start.timestampMs,\n durationMs: isInProgress ? now - start.timestampMs : end!.timestampMs - start.timestampMs,\n outcome: end?.outcome ?? InvocationOutcome.PENDING,\n exception: end?.exception,\n input: start.input,\n invocationTraceQueue: start.invocationTraceQueue,\n invocationTarget: start.invocationTarget,\n trigger: start.trigger,\n });\n }\n\n return result;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { Schema, SchemaAST } from 'effect';\n\nimport { Expando, OptionsAnnotationId, TypedObject, Ref, RawObject } from '@dxos/echo-schema';\nimport { DXN } from '@dxos/keys';\n\nimport { FunctionType } from './schema';\n\n/**\n * Type discriminator for TriggerType.\n * Every spec has a type field of type TriggerKind that we can use to understand which type we're working with.\n * https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions\n */\nexport enum TriggerKind {\n Timer = 'timer',\n Webhook = 'webhook',\n Subscription = 'subscription',\n Email = 'email',\n Queue = 'queue',\n}\n\nconst kindLiteralAnnotations = { title: 'Kind' };\n\n/**\n * Cron timer.\n */\nconst TimerTriggerSchema = Schema.Struct({\n kind: Schema.Literal(TriggerKind.Timer).annotations(kindLiteralAnnotations),\n cron: Schema.String.annotations({\n title: 'Cron',\n [SchemaAST.ExamplesAnnotationId]: ['0 0 * * *'],\n }),\n}).pipe(Schema.mutable);\nexport type TimerTrigger = Schema.Schema.Type<typeof TimerTriggerSchema>;\n\nconst EmailTriggerSchema = Schema.Struct({\n kind: Schema.Literal(TriggerKind.Email).annotations(kindLiteralAnnotations),\n}).pipe(Schema.mutable);\nexport type EmailTrigger = Schema.Schema.Type<typeof EmailTriggerSchema>;\n\nconst QueueTriggerSchema = Schema.Struct({\n kind: Schema.Literal(TriggerKind.Queue).annotations(kindLiteralAnnotations),\n queue: DXN.Schema,\n}).pipe(Schema.mutable);\nexport type QueueTrigger = Schema.Schema.Type<typeof QueueTriggerSchema>;\n\n/**\n * Webhook.\n */\nconst WebhookTriggerSchema = Schema.Struct({\n kind: Schema.Literal(TriggerKind.Webhook).annotations(kindLiteralAnnotations),\n method: Schema.optional(\n Schema.String.annotations({\n title: 'Method',\n [OptionsAnnotationId]: ['GET', 'POST'],\n }),\n ),\n port: Schema.optional(\n Schema.Number.annotations({\n title: 'Port',\n }),\n ),\n}).pipe(Schema.mutable);\nexport type WebhookTrigger = Schema.Schema.Type<typeof WebhookTriggerSchema>;\n\n// TODO(burdon): Use ECHO definition (from https://github.com/dxos/dxos/pull/8233).\nconst QuerySchema = Schema.Struct({\n type: Schema.optional(Schema.String.annotations({ title: 'Type' })),\n props: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),\n}).annotations({ title: 'Query' });\n\n/**\n * Subscription.\n */\nconst SubscriptionTriggerSchema = Schema.Struct({\n kind: Schema.Literal(TriggerKind.Subscription).annotations(kindLiteralAnnotations),\n // TODO(burdon): Define query DSL (from ECHO). Reconcile with Table.Query.\n filter: QuerySchema,\n options: Schema.optional(\n Schema.Struct({\n // Watch changes to object (not just creation).\n deep: Schema.optional(Schema.Boolean.annotations({ title: 'Nested' })),\n // Debounce changes (delay in ms).\n delay: Schema.optional(Schema.Number.annotations({ title: 'Delay' })),\n }).annotations({ title: 'Options' }),\n ),\n}).pipe(Schema.mutable);\nexport type SubscriptionTrigger = Schema.Schema.Type<typeof SubscriptionTriggerSchema>;\n\n/**\n * Trigger schema (discriminated union).\n */\nexport const TriggerSchema = Schema.Union(\n TimerTriggerSchema,\n WebhookTriggerSchema,\n SubscriptionTriggerSchema,\n EmailTriggerSchema,\n QueueTriggerSchema,\n).annotations({\n title: 'Trigger',\n});\nexport type TriggerType = Schema.Schema.Type<typeof TriggerSchema>;\n\nexport type EventType =\n | EmailTriggerOutput\n | WebhookTriggerOutput\n | QueueTriggerOutput\n | SubscriptionTriggerOutput\n | TimerTriggerOutput;\n\n// TODO(burdon): Reuse trigger schema from @dxos/functions (TriggerType).\nexport const EmailTriggerOutput = Schema.mutable(\n Schema.Struct({\n from: Schema.String,\n to: Schema.String,\n subject: Schema.String,\n created: Schema.String,\n body: Schema.String,\n }),\n);\nexport type EmailTriggerOutput = Schema.Schema.Type<typeof EmailTriggerOutput>;\n\nexport const WebhookTriggerOutput = Schema.mutable(\n Schema.Struct({\n url: Schema.String,\n method: Schema.Literal('GET', 'POST'),\n headers: Schema.Record({ key: Schema.String, value: Schema.String }),\n bodyText: Schema.String,\n }),\n);\nexport type WebhookTriggerOutput = Schema.Schema.Type<typeof WebhookTriggerOutput>;\n\nexport const QueueTriggerOutput = Schema.mutable(\n Schema.Struct({\n queue: DXN.Schema,\n item: Schema.Any,\n cursor: Schema.String,\n }),\n);\nexport type QueueTriggerOutput = Schema.Schema.Type<typeof QueueTriggerOutput>;\n\nexport const SubscriptionTriggerOutput = Schema.mutable(\n Schema.Struct({ type: Schema.String, changedObjectId: Schema.String }),\n);\nexport type SubscriptionTriggerOutput = Schema.Schema.Type<typeof SubscriptionTriggerOutput>;\n\nexport const TimerTriggerOutput = Schema.mutable(Schema.Struct({ tick: Schema.Number }));\nexport type TimerTriggerOutput = Schema.Schema.Type<typeof TimerTriggerOutput>;\n\n/**\n * Function trigger.\n * Function is invoked with the `payload` passed as input data.\n * The event that triggers the function is available in the function context.\n */\nexport const FunctionTriggerSchema = Schema.Struct({\n /**\n * Function or workflow to invoke.\n */\n // TODO(dmaretskyi): Can be a Ref(FunctionType) or Ref(ComputeGraphType).\n function: Schema.optional(Ref(Expando).annotations({ title: 'Function' })),\n\n /**\n * Only used for workflowSchema.\n * Specifies the input node in the circuit.\n * @deprecated Remove and enforce a single input node in all compute graphSchema.\n */\n inputNodeId: Schema.optional(Schema.String.annotations({ title: 'Input Node ID' })),\n\n enabled: Schema.optional(Schema.Boolean.annotations({ title: 'Enabled' })),\n\n spec: Schema.optional(TriggerSchema),\n\n /**\n * Passed as the input data to the function.\n * Must match the function's input schema.\n *\n * @example\n * {\n * item: '{{$.trigger.event}}',\n * instructions: 'Summarize and perform entity-extraction'\n * mailbox: { '/': 'dxn:echo:AAA:ZZZ' }\n * }\n */\n input: Schema.optional(Schema.mutable(Schema.Record({ key: Schema.String, value: Schema.Any }))),\n});\n\nexport type FunctionTriggerType = Schema.Schema.Type<typeof FunctionTriggerSchema>;\n\n/**\n * Function trigger.\n */\nexport class FunctionTrigger extends TypedObject({\n typename: 'dxos.org/type/FunctionTrigger',\n version: '0.2.0',\n})(FunctionTriggerSchema.fields) {}\n\n// TODO(wittjosiah): Remove?\n\n/**\n * Function manifest file.\n */\nexport const FunctionManifestSchema = Schema.Struct({\n functions: Schema.optional(Schema.mutable(Schema.Array(RawObject(FunctionType)))),\n triggers: Schema.optional(Schema.mutable(Schema.Array(RawObject(FunctionTrigger)))),\n});\nexport type FunctionManifest = Schema.Schema.Type<typeof FunctionManifestSchema>;\n\nexport const FUNCTION_TYPES = [FunctionType, FunctionTrigger];\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ObjectMeta } from '@dxos/echo-schema';\nimport { type SpaceId } from '@dxos/keys';\n\n// TODO: use URL scheme for source?\nconst FUNCTIONS_META_KEY = 'dxos.org/service/function';\n\nexport const FUNCTIONS_PRESET_META_KEY = 'dxos.org/service/function-preset';\n\nconst isSecure = (protocol: string) => {\n return protocol === 'https:' || protocol === 'wss:';\n};\n\nexport const getUserFunctionUrlInMetadata = (meta: ObjectMeta) => {\n return meta.keys.find((key) => key.source === FUNCTIONS_META_KEY)?.id;\n};\n\nexport const setUserFunctionUrlInMetadata = (meta: ObjectMeta, functionUrl: string) => {\n const key = meta.keys.find((key) => key.source === FUNCTIONS_META_KEY);\n if (key) {\n if (key.id !== functionUrl) {\n throw new Error('Metadata mismatch');\n }\n } else {\n meta.keys.push({ source: FUNCTIONS_META_KEY, id: functionUrl });\n }\n};\n\n/**\n * NOTE: functionId is backend ID, not ECHO object id.\n */\nexport const makeFunctionUrl = (fn: { functionId: string }) => `/${fn.functionId}`;\n\nexport const getInvocationUrl = (functionUrl: string, edgeUrl: string, options: InvocationOptions = {}) => {\n const baseUrl = new URL('functions/', edgeUrl);\n\n // Leading slashes cause the URL to be treated as an absolute path.\n const relativeUrl = functionUrl.replace(/^\\//, '');\n const url = new URL(`./${relativeUrl}`, baseUrl.toString());\n options.spaceId && url.searchParams.set('spaceId', options.spaceId);\n options.subjectId && url.searchParams.set('subjectId', options.subjectId);\n url.protocol = isSecure(url.protocol) ? 'https' : 'http';\n return url.toString();\n};\n\nexport type InvocationOptions = {\n spaceId?: SpaceId;\n subjectId?: string;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Effect, Schema } from 'effect';\n\nimport type { SpaceId } from '@dxos/client/echo';\n\nimport type { FunctionContext, FunctionDefinition } from '../handler';\nimport type { ServiceContainer } from '../services';\n\nexport class FunctionExecutor {\n constructor(private readonly _services: ServiceContainer) {}\n\n // TODO(dmaretskyi): Invocation context: queue, space, etc...\n async invoke<F extends FunctionDefinition<any, any>>(\n fnDef: F,\n input: F extends FunctionDefinition<infer I, infer _O> ? I : never,\n ): Promise<F extends FunctionDefinition<infer _I, infer O> ? O : never> {\n // Assert input matches schema\n const assertInput = fnDef.inputSchema.pipe(Schema.asserts);\n (assertInput as any)(input);\n\n const context: FunctionContext = {\n getService: this._services.getService.bind(this._services),\n getSpace: async (_spaceId: SpaceId) => {\n throw new Error('Not available. Use the database service instead.');\n },\n space: undefined,\n get ai(): never {\n throw new Error('Not available. Use the ai service instead.');\n },\n };\n\n const result = await fnDef.handler({ context, data: input });\n\n // Assert output matches schema\n const assertOutput = fnDef.outputSchema?.pipe(Schema.asserts);\n (assertOutput as any)(result);\n\n if (Effect.isEffect(result)) {\n return Effect.runPromise(result as any);\n }\n\n return result as any;\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["Schema", "defineFunction", "params", "Schema", "isSchema", "inputSchema", "Error", "handler", "description", "outputSchema", "Any", "Schema", "Type", "JsonSchemaType", "LabelAnnotation", "Ref", "DataType", "ScriptType", "Schema", "Struct", "name", "optional", "String", "description", "changed", "Boolean", "source", "Ref", "DataType", "Text", "pipe", "Type", "Obj", "typename", "version", "LabelAnnotation", "set", "FunctionType", "NonEmptyString", "inputSchema", "JsonSchemaType", "outputSchema", "binding", "Schema", "Type", "Queue", "ObjectId", "log", "Schema", "SchemaAST", "Expando", "OptionsAnnotationId", "TypedObject", "Ref", "RawObject", "DXN", "TriggerKind", "kindLiteralAnnotations", "title", "TimerTriggerSchema", "Schema", "Struct", "kind", "Literal", "annotations", "cron", "String", "SchemaAST", "ExamplesAnnotationId", "pipe", "mutable", "EmailTriggerSchema", "QueueTriggerSchema", "queue", "DXN", "WebhookTriggerSchema", "method", "optional", "OptionsAnnotationId", "port", "Number", "QuerySchema", "type", "props", "Record", "key", "value", "Any", "SubscriptionTriggerSchema", "filter", "options", "deep", "Boolean", "delay", "TriggerSchema", "Union", "EmailTriggerOutput", "from", "to", "subject", "created", "body", "WebhookTriggerOutput", "url", "headers", "bodyText", "QueueTriggerOutput", "item", "cursor", "SubscriptionTriggerOutput", "changedObjectId", "TimerTriggerOutput", "tick", "FunctionTriggerSchema", "function", "Ref", "Expando", "inputNodeId", "enabled", "spec", "input", "FunctionTrigger", "TypedObject", "typename", "version", "fields", "FunctionManifestSchema", "functions", "Array", "RawObject", "FunctionType", "triggers", "FUNCTION_TYPES", "InvocationOutcome", "InvocationTraceEventType", "TraceEventException", "Schema", "Struct", "timestampMs", "Number", "message", "String", "name", "stack", "optional", "InvocationTraceStartEvent", "id", "ObjectId", "type", "Literal", "invocationId", "input", "Object", "invocationTraceQueue", "Type", "Ref", "Queue", "invocationTarget", "Expando", "trigger", "FunctionTrigger", "pipe", "Obj", "typename", "version", "InvocationTraceEndEvent", "outcome", "Enums", "exception", "TraceEventLog", "level", "context", "TraceEvent", "truncated", "Boolean", "ingestionTimestampMs", "logs", "Array", "exceptions", "createInvocationSpans", "items", "eventsByInvocationId", "Map", "event", "entry", "get", "start", "undefined", "end", "set", "now", "Date", "result", "entries", "log", "warn", "isInProgress", "push", "durationMs", "FUNCTIONS_META_KEY", "FUNCTIONS_PRESET_META_KEY", "isSecure", "protocol", "getUserFunctionUrlInMetadata", "meta", "keys", "find", "key", "source", "id", "setUserFunctionUrlInMetadata", "functionUrl", "Error", "push", "makeFunctionUrl", "fn", "functionId", "getInvocationUrl", "edgeUrl", "options", "baseUrl", "URL", "relativeUrl", "replace", "url", "toString", "spaceId", "searchParams", "set", "subjectId", "Effect", "Schema", "FunctionExecutor", "_services", "invoke", "fnDef", "input", "assertInput", "inputSchema", "pipe", "Schema", "asserts", "context", "getService", "bind", "getSpace", "_spaceId", "Error", "space", "undefined", "ai", "result", "handler", "data", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Schema, type Context, type Effect } from 'effect';\n\nimport { type AiServiceClient } from '@dxos/ai';\n// import { type Space } from '@dxos/client/echo';\nimport type { EchoDatabase } from '@dxos/echo-db';\nimport { type HasId } from '@dxos/echo-schema';\nimport { type SpaceId, type DXN } from '@dxos/keys';\nimport { type QueryResult } from '@dxos/protocols';\n\nimport type { Services } from './services';\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 * Resolves a service available to the function.\n * @throws if the service is not available.\n */\n getService: <T extends Context.Tag<any, any>>(tag: T) => Context.Tag.Service<T>;\n\n getSpace: (spaceId: SpaceId) => Promise<SpaceAPI>;\n\n /**\n * Space from which the function was invoked.\n */\n space: SpaceAPI | undefined;\n\n ai: AiServiceClient;\n}\n\nexport interface FunctionContextAi {\n // TODO(dmaretskyi): Refer to cloudflare AI docs for more comprehensive typedefs.\n run(model: string, inputs: any, options?: any): Promise<any>;\n}\n\n//\n// API.\n//\n\n// TODO(dmaretskyi): Temporary API to get the queues working.\n// TODO(dmaretskyi): To be replaced with integrating queues into echo.\nexport interface QueuesAPI {\n queryQueue(queue: DXN, options?: {}): Promise<QueryResult>;\n insertIntoQueue(queue: DXN, objects: HasId[]): Promise<void>;\n}\n\n/**\n * Space interface available to functions.\n */\nexport interface SpaceAPI {\n get id(): SpaceId;\n\n 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\nexport type FunctionDefinition<T = {}, O = any> = {\n description?: string;\n inputSchema: Schema.Schema<T, any>;\n outputSchema?: Schema.Schema<O, any>;\n handler: FunctionHandler<T, O>;\n};\n\n// TODO(dmaretskyi): Bind input type to function handler.\nexport const defineFunction = <T, O>(params: FunctionDefinition<T, O>): FunctionDefinition<T, O> => {\n if (!Schema.isSchema(params.inputSchema)) {\n throw new Error('Input schema must be a valid schema');\n }\n if (typeof params.handler !== 'function') {\n throw new Error('Handler must be a function');\n }\n\n return {\n description: params.description,\n inputSchema: params.inputSchema,\n outputSchema: params.outputSchema ?? Schema.Any,\n handler: params.handler,\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { Type } from '@dxos/echo';\nimport { JsonSchemaType, LabelAnnotation, Ref } from '@dxos/echo-schema';\nimport { DataType } from '@dxos/schema';\n\n/**\n * Source script.\n */\nexport const ScriptType = Schema.Struct({\n name: Schema.optional(Schema.String),\n description: Schema.optional(Schema.String),\n // TODO(burdon): Change to hash of deployed content.\n // Whether source has changed since last deploy.\n changed: Schema.optional(Schema.Boolean),\n source: Ref(DataType.Text),\n}).pipe(\n Type.Obj({\n typename: 'dxos.org/type/Script',\n version: '0.1.0',\n }),\n LabelAnnotation.set(['name']),\n);\n\nexport interface ScriptType extends Schema.Schema.Type<typeof ScriptType> {}\n\n/**\n * Function deployment.\n */\nexport const FunctionType = Schema.Struct({\n // TODO(burdon): Rename to id/uri?\n name: Schema.NonEmptyString,\n version: Schema.String,\n\n description: Schema.optional(Schema.String),\n\n // Reference to a source script if it exists within ECHO.\n // TODO(burdon): Don't ref ScriptType directly (core).\n source: Schema.optional(Ref(ScriptType)),\n\n inputSchema: Schema.optional(JsonSchemaType),\n outputSchema: Schema.optional(JsonSchemaType),\n\n // Local binding to a function name.\n binding: Schema.optional(Schema.String),\n}).pipe(\n Type.Obj({\n typename: 'dxos.org/type/Function',\n version: '0.1.0',\n }),\n LabelAnnotation.set(['name']),\n);\nexport interface FunctionType extends Schema.Schema.Type<typeof FunctionType> {}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { Type, type Ref } from '@dxos/echo';\nimport { Queue } from '@dxos/echo-db';\nimport { ObjectId } from '@dxos/echo-schema';\nimport { log } from '@dxos/log';\n\nimport { FunctionTrigger, type FunctionTriggerType } from './types';\n\nexport enum InvocationOutcome {\n SUCCESS = 'success',\n FAILURE = 'failure',\n PENDING = 'pending',\n}\n\n// TODO(burdon): Convert to extensible discriminated union of EDGE events.\nexport enum InvocationTraceEventType {\n START = 'start',\n END = 'end',\n}\n\nexport const TraceEventException = Schema.Struct({\n timestampMs: Schema.Number,\n message: Schema.String,\n name: Schema.String,\n stack: Schema.optional(Schema.String),\n});\nexport type TraceEventException = Schema.Schema.Type<typeof TraceEventException>;\n\nexport const InvocationTraceStartEvent = Schema.Struct({\n /**\n * Queue message id.\n */\n id: ObjectId,\n type: Schema.Literal(InvocationTraceEventType.START),\n /**\n * Invocation id, the same for invocation start and end events.\n */\n invocationId: ObjectId,\n /**\n * Event generation time.\n */\n timestampMs: Schema.Number,\n /**\n * Data passed to function / workflow as an argument.\n */\n // TODO(burdon): Input schema?\n input: Schema.Object,\n /**\n * Queue for function/workflow invocation events.\n */\n invocationTraceQueue: Type.Ref(Queue),\n /**\n * DXN of the invoked function/workflow.\n */\n invocationTarget: Type.Ref(Type.Expando),\n /**\n * Present for automatic invocations.\n */\n trigger: Schema.optional(Type.Ref(FunctionTrigger)),\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 timestampMs: 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 timestampMs: Schema.Number,\n level: Schema.String,\n message: Schema.String,\n context: Schema.optional(Schema.Object),\n});\n\nexport const TraceEvent = Schema.Struct({\n id: ObjectId,\n // TODO(burdon): Need enum/numeric result (not string).\n outcome: Schema.String,\n truncated: Schema.Boolean,\n /**\n * Time when the event was persisted.\n */\n ingestionTimestampMs: Schema.Number,\n logs: Schema.Array(TraceEventLog),\n exceptions: Schema.Array(TraceEventException),\n}).pipe(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 timestampMs: number;\n outcome: InvocationOutcome;\n input: object;\n durationMs: number;\n invocationTraceQueue: Ref.Ref<Queue>;\n invocationTarget: Ref.Ref<Type.Expando>;\n trigger?: Ref.Ref<FunctionTriggerType>;\n exception?: TraceEventException;\n};\n\nexport const createInvocationSpans = (items?: InvocationTraceEvent[]): InvocationSpan[] => {\n if (!items) {\n return [];\n }\n\n const eventsByInvocationId = new Map<string, { start?: InvocationTraceStartEvent; end?: InvocationTraceEndEvent }>();\n for (const event of items) {\n if (!('invocationId' in event)) {\n // Skip legacy format entries.\n continue;\n }\n\n const invocationId = event.invocationId;\n const entry = eventsByInvocationId.get(invocationId) || { start: undefined, end: undefined };\n if (event.type === InvocationTraceEventType.START) {\n entry.start = event as InvocationTraceStartEvent;\n } else if (event.type === InvocationTraceEventType.END) {\n entry.end = event as InvocationTraceEndEvent;\n }\n\n eventsByInvocationId.set(invocationId, entry);\n }\n\n const now = Date.now();\n const result: InvocationSpan[] = [];\n\n // Create spans for each invocation\n for (const [invocationId, { start, end }] of eventsByInvocationId.entries()) {\n if (!start) {\n // No start event, can't create a meaningful span\n log.warn('found end event without matching start', { invocationId });\n continue;\n }\n\n const isInProgress = end === undefined;\n\n result.push({\n id: invocationId,\n timestampMs: start.timestampMs,\n durationMs: isInProgress ? now - start.timestampMs : end!.timestampMs - start.timestampMs,\n outcome: end?.outcome ?? InvocationOutcome.PENDING,\n exception: end?.exception,\n input: start.input,\n invocationTraceQueue: start.invocationTraceQueue,\n invocationTarget: start.invocationTarget,\n trigger: start.trigger,\n });\n }\n\n return result;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { Schema, SchemaAST } from 'effect';\n\nimport { Expando, OptionsAnnotationId, TypedObject, Ref, RawObject } from '@dxos/echo-schema';\nimport { DXN } from '@dxos/keys';\n\nimport { FunctionType } from './schema';\n\n/**\n * Type discriminator for TriggerType.\n * Every spec has a type field of type TriggerKind that we can use to understand which type we're working with.\n * https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions\n */\nexport enum TriggerKind {\n Timer = 'timer',\n Webhook = 'webhook',\n Subscription = 'subscription',\n Email = 'email',\n Queue = 'queue',\n}\n\nconst kindLiteralAnnotations = { title: 'Kind' };\n\n/**\n * Cron timer.\n */\nconst TimerTriggerSchema = Schema.Struct({\n kind: Schema.Literal(TriggerKind.Timer).annotations(kindLiteralAnnotations),\n cron: Schema.String.annotations({\n title: 'Cron',\n [SchemaAST.ExamplesAnnotationId]: ['0 0 * * *'],\n }),\n}).pipe(Schema.mutable);\nexport type TimerTrigger = Schema.Schema.Type<typeof TimerTriggerSchema>;\n\nconst EmailTriggerSchema = Schema.Struct({\n kind: Schema.Literal(TriggerKind.Email).annotations(kindLiteralAnnotations),\n}).pipe(Schema.mutable);\nexport type EmailTrigger = Schema.Schema.Type<typeof EmailTriggerSchema>;\n\nconst QueueTriggerSchema = Schema.Struct({\n kind: Schema.Literal(TriggerKind.Queue).annotations(kindLiteralAnnotations),\n queue: DXN.Schema,\n}).pipe(Schema.mutable);\nexport type QueueTrigger = Schema.Schema.Type<typeof QueueTriggerSchema>;\n\n/**\n * Webhook.\n */\nconst WebhookTriggerSchema = Schema.Struct({\n kind: Schema.Literal(TriggerKind.Webhook).annotations(kindLiteralAnnotations),\n method: Schema.optional(\n Schema.String.annotations({\n title: 'Method',\n [OptionsAnnotationId]: ['GET', 'POST'],\n }),\n ),\n port: Schema.optional(\n Schema.Number.annotations({\n title: 'Port',\n }),\n ),\n}).pipe(Schema.mutable);\nexport type WebhookTrigger = Schema.Schema.Type<typeof WebhookTriggerSchema>;\n\n// TODO(burdon): Use ECHO definition (from https://github.com/dxos/dxos/pull/8233).\nconst QuerySchema = Schema.Struct({\n type: Schema.optional(Schema.String.annotations({ title: 'Type' })),\n props: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),\n}).annotations({ title: 'Query' });\n\n/**\n * Subscription.\n */\nconst SubscriptionTriggerSchema = Schema.Struct({\n kind: Schema.Literal(TriggerKind.Subscription).annotations(kindLiteralAnnotations),\n // TODO(burdon): Define query DSL (from ECHO). Reconcile with Table.Query.\n filter: QuerySchema,\n options: Schema.optional(\n Schema.Struct({\n // Watch changes to object (not just creation).\n deep: Schema.optional(Schema.Boolean.annotations({ title: 'Nested' })),\n // Debounce changes (delay in ms).\n delay: Schema.optional(Schema.Number.annotations({ title: 'Delay' })),\n }).annotations({ title: 'Options' }),\n ),\n}).pipe(Schema.mutable);\nexport type SubscriptionTrigger = Schema.Schema.Type<typeof SubscriptionTriggerSchema>;\n\n/**\n * Trigger schema (discriminated union).\n */\nexport const TriggerSchema = Schema.Union(\n TimerTriggerSchema,\n WebhookTriggerSchema,\n SubscriptionTriggerSchema,\n EmailTriggerSchema,\n QueueTriggerSchema,\n).annotations({\n title: 'Trigger',\n});\nexport type TriggerType = Schema.Schema.Type<typeof TriggerSchema>;\n\nexport type EventType =\n | EmailTriggerOutput\n | WebhookTriggerOutput\n | QueueTriggerOutput\n | SubscriptionTriggerOutput\n | TimerTriggerOutput;\n\n// TODO(burdon): Reuse trigger schema from @dxos/functions (TriggerType).\nexport const EmailTriggerOutput = Schema.mutable(\n Schema.Struct({\n from: Schema.String,\n to: Schema.String,\n subject: Schema.String,\n created: Schema.String,\n body: Schema.String,\n }),\n);\nexport type EmailTriggerOutput = Schema.Schema.Type<typeof EmailTriggerOutput>;\n\nexport const WebhookTriggerOutput = Schema.mutable(\n Schema.Struct({\n url: Schema.String,\n method: Schema.Literal('GET', 'POST'),\n headers: Schema.Record({ key: Schema.String, value: Schema.String }),\n bodyText: Schema.String,\n }),\n);\nexport type WebhookTriggerOutput = Schema.Schema.Type<typeof WebhookTriggerOutput>;\n\nexport const QueueTriggerOutput = Schema.mutable(\n Schema.Struct({\n queue: DXN.Schema,\n item: Schema.Any,\n cursor: Schema.String,\n }),\n);\nexport type QueueTriggerOutput = Schema.Schema.Type<typeof QueueTriggerOutput>;\n\nexport const SubscriptionTriggerOutput = Schema.mutable(\n Schema.Struct({ type: Schema.String, changedObjectId: Schema.String }),\n);\nexport type SubscriptionTriggerOutput = Schema.Schema.Type<typeof SubscriptionTriggerOutput>;\n\nexport const TimerTriggerOutput = Schema.mutable(Schema.Struct({ tick: Schema.Number }));\nexport type TimerTriggerOutput = Schema.Schema.Type<typeof TimerTriggerOutput>;\n\n/**\n * Function trigger.\n * Function is invoked with the `payload` passed as input data.\n * The event that triggers the function is available in the function context.\n */\nexport const FunctionTriggerSchema = Schema.Struct({\n /**\n * Function or workflow to invoke.\n */\n // TODO(dmaretskyi): Can be a Ref(FunctionType) or Ref(ComputeGraphType).\n function: Schema.optional(Ref(Expando).annotations({ title: 'Function' })),\n\n /**\n * Only used for workflowSchema.\n * Specifies the input node in the circuit.\n * @deprecated Remove and enforce a single input node in all compute graphSchema.\n */\n inputNodeId: Schema.optional(Schema.String.annotations({ title: 'Input Node ID' })),\n\n enabled: Schema.optional(Schema.Boolean.annotations({ title: 'Enabled' })),\n\n spec: Schema.optional(TriggerSchema),\n\n /**\n * Passed as the input data to the function.\n * Must match the function's input schema.\n *\n * @example\n * {\n * item: '{{$.trigger.event}}',\n * instructions: 'Summarize and perform entity-extraction'\n * mailbox: { '/': 'dxn:echo:AAA:ZZZ' }\n * }\n */\n input: Schema.optional(Schema.mutable(Schema.Record({ key: Schema.String, value: Schema.Any }))),\n});\n\nexport type FunctionTriggerType = Schema.Schema.Type<typeof FunctionTriggerSchema>;\n\n/**\n * Function trigger.\n */\nexport class FunctionTrigger extends TypedObject({\n typename: 'dxos.org/type/FunctionTrigger',\n version: '0.2.0',\n})(FunctionTriggerSchema.fields) {}\n\n// TODO(wittjosiah): Remove?\n\n/**\n * Function manifest file.\n */\nexport const FunctionManifestSchema = Schema.Struct({\n functions: Schema.optional(Schema.mutable(Schema.Array(RawObject(FunctionType)))),\n triggers: Schema.optional(Schema.mutable(Schema.Array(RawObject(FunctionTrigger)))),\n});\nexport type FunctionManifest = Schema.Schema.Type<typeof FunctionManifestSchema>;\n\nexport const FUNCTION_TYPES = [FunctionType, FunctionTrigger];\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ObjectMeta } from '@dxos/echo-schema';\nimport { type SpaceId } from '@dxos/keys';\n\n// TODO: use URL scheme for source?\nconst FUNCTIONS_META_KEY = 'dxos.org/service/function';\n\nexport const FUNCTIONS_PRESET_META_KEY = 'dxos.org/service/function-preset';\n\nconst isSecure = (protocol: string) => {\n return protocol === 'https:' || protocol === 'wss:';\n};\n\nexport const getUserFunctionUrlInMetadata = (meta: ObjectMeta) => {\n return meta.keys.find((key) => key.source === FUNCTIONS_META_KEY)?.id;\n};\n\nexport const setUserFunctionUrlInMetadata = (meta: ObjectMeta, functionUrl: string) => {\n const key = meta.keys.find((key) => key.source === FUNCTIONS_META_KEY);\n if (key) {\n if (key.id !== functionUrl) {\n throw new Error('Metadata mismatch');\n }\n } else {\n meta.keys.push({ source: FUNCTIONS_META_KEY, id: functionUrl });\n }\n};\n\n/**\n * NOTE: functionId is backend ID, not ECHO object id.\n */\nexport const makeFunctionUrl = (fn: { functionId: string }) => `/${fn.functionId}`;\n\nexport const getInvocationUrl = (functionUrl: string, edgeUrl: string, options: InvocationOptions = {}) => {\n const baseUrl = new URL('functions/', edgeUrl);\n\n // Leading slashes cause the URL to be treated as an absolute path.\n const relativeUrl = functionUrl.replace(/^\\//, '');\n const url = new URL(`./${relativeUrl}`, baseUrl.toString());\n options.spaceId && url.searchParams.set('spaceId', options.spaceId);\n options.subjectId && url.searchParams.set('subjectId', options.subjectId);\n url.protocol = isSecure(url.protocol) ? 'https' : 'http';\n return url.toString();\n};\n\nexport type InvocationOptions = {\n spaceId?: SpaceId;\n subjectId?: string;\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Effect, Schema } from 'effect';\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\nexport class FunctionExecutor {\n constructor(private readonly _services: ServiceContainer) {}\n\n // TODO(dmaretskyi): Invocation context: queue, space, etc...\n async invoke<F extends FunctionDefinition<any, any>>(\n fnDef: F,\n input: F extends FunctionDefinition<infer I, infer _O> ? I : never,\n ): Promise<F extends FunctionDefinition<infer _I, infer O> ? O : never> {\n // Assert input matches schema\n const assertInput = fnDef.inputSchema.pipe(Schema.asserts);\n (assertInput as any)(input);\n\n const context: FunctionContext = {\n getService: this._services.getService.bind(this._services),\n getSpace: async (_spaceId: SpaceId) => {\n throw new Error('Not available. Use the database service instead.');\n },\n space: undefined,\n get ai(): never {\n throw new Error('Not available. Use the ai service instead.');\n },\n };\n\n const result = fnDef.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 = fnDef.outputSchema?.pipe(Schema.asserts);\n (assertOutput as any)(data);\n\n return data as any;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;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ACAC,OACsE;AAEtE,UAAMC,cAAcF,MAAMG,YAAYC,KAAKC,QAAOC,OAAO;AACxDJ,gBAAoBD,KAAAA;AAErB,UAAMM,UAA2B;MAC/BC,YAAY,KAAKV,UAAUU,WAAWC,KAAK,KAAKX,SAAS;MACzDY,UAAU,OAAOC,aAAAA;AACf,cAAM,IAAIC,MAAM,kDAAA;MAClB;MACAC,OAAOC;MACP,IAAIC,KAAY;AACd,cAAM,IAAIH,MAAM,4CAAA;MAClB;IACF;AAEA,UAAMI,SAAShB,MAAMiB,QAAQ;MAAEV;MAASW,MAAMjB;IAAM,CAAA;AAEpD,QAAIiB;AACJ,QAAIC,OAAOC,SAASJ,MAAAA,GAAS;AAC3BE,aAAO,MAAOF,OAAqDZ,KACjEe,OAAOE,QAAQ,KAAKvB,UAAUwB,YAAW,CAAA,GACzCC,mBAAAA;IAEJ,OAAO;AACLL,aAAO,MAAMF;IACf;AAGA,UAAMQ,eAAexB,MAAMyB,cAAcrB,KAAKC,QAAOC,OAAO;AAC3DkB,iBAAqBN,IAAAA;AAEtB,WAAOA;EACT;AACF;",
|
|
6
|
+
"names": ["Schema", "defineFunction", "params", "Schema", "isSchema", "inputSchema", "Error", "handler", "description", "outputSchema", "Any", "Schema", "Type", "JsonSchemaType", "LabelAnnotation", "Ref", "DataType", "ScriptType", "Schema", "Struct", "name", "optional", "String", "description", "changed", "Boolean", "source", "Ref", "DataType", "Text", "pipe", "Type", "Obj", "typename", "version", "LabelAnnotation", "set", "FunctionType", "NonEmptyString", "inputSchema", "JsonSchemaType", "outputSchema", "binding", "Schema", "Type", "Queue", "ObjectId", "log", "Schema", "SchemaAST", "Expando", "OptionsAnnotationId", "TypedObject", "Ref", "RawObject", "DXN", "TriggerKind", "kindLiteralAnnotations", "title", "TimerTriggerSchema", "Schema", "Struct", "kind", "Literal", "annotations", "cron", "String", "SchemaAST", "ExamplesAnnotationId", "pipe", "mutable", "EmailTriggerSchema", "QueueTriggerSchema", "queue", "DXN", "WebhookTriggerSchema", "method", "optional", "OptionsAnnotationId", "port", "Number", "QuerySchema", "type", "props", "Record", "key", "value", "Any", "SubscriptionTriggerSchema", "filter", "options", "deep", "Boolean", "delay", "TriggerSchema", "Union", "EmailTriggerOutput", "from", "to", "subject", "created", "body", "WebhookTriggerOutput", "url", "headers", "bodyText", "QueueTriggerOutput", "item", "cursor", "SubscriptionTriggerOutput", "changedObjectId", "TimerTriggerOutput", "tick", "FunctionTriggerSchema", "function", "Ref", "Expando", "inputNodeId", "enabled", "spec", "input", "FunctionTrigger", "TypedObject", "typename", "version", "fields", "FunctionManifestSchema", "functions", "Array", "RawObject", "FunctionType", "triggers", "FUNCTION_TYPES", "InvocationOutcome", "InvocationTraceEventType", "TraceEventException", "Schema", "Struct", "timestampMs", "Number", "message", "String", "name", "stack", "optional", "InvocationTraceStartEvent", "id", "ObjectId", "type", "Literal", "invocationId", "input", "Object", "invocationTraceQueue", "Type", "Ref", "Queue", "invocationTarget", "Expando", "trigger", "FunctionTrigger", "pipe", "Obj", "typename", "version", "InvocationTraceEndEvent", "outcome", "Enums", "exception", "TraceEventLog", "level", "context", "TraceEvent", "truncated", "Boolean", "ingestionTimestampMs", "logs", "Array", "exceptions", "createInvocationSpans", "items", "eventsByInvocationId", "Map", "event", "entry", "get", "start", "undefined", "end", "set", "now", "Date", "result", "entries", "log", "warn", "isInProgress", "push", "durationMs", "FUNCTIONS_META_KEY", "FUNCTIONS_PRESET_META_KEY", "isSecure", "protocol", "getUserFunctionUrlInMetadata", "meta", "keys", "find", "key", "source", "id", "setUserFunctionUrlInMetadata", "functionUrl", "Error", "push", "makeFunctionUrl", "fn", "functionId", "getInvocationUrl", "edgeUrl", "options", "baseUrl", "URL", "relativeUrl", "replace", "url", "toString", "spaceId", "searchParams", "set", "subjectId", "Effect", "Schema", "runAndForwardErrors", "FunctionExecutor", "_services", "invoke", "fnDef", "input", "assertInput", "inputSchema", "pipe", "Schema", "asserts", "context", "getService", "bind", "getSpace", "_spaceId", "Error", "space", "undefined", "ai", "result", "handler", "data", "Effect", "isEffect", "provide", "createLayer", "runAndForwardErrors", "assertOutput", "outputSchema"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/core/functions/src/bundler/bundler.ts":{"bytes":30207,"imports":[{"path":"esbuild-wasm","kind":"import-statement","external":true},{"path":"@dxos/crypto","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/bundler/index.ts":{"bytes":470,"imports":[{"path":"packages/core/functions/src/bundler/bundler.ts","kind":"import-statement","original":"./bundler"}],"format":"esm"},"packages/core/functions/src/edge/functions.ts":{"bytes":6609,"imports":[{"path":"@dxos/client/edge","kind":"import-statement","external":true},{"path":"@dxos/edge-client","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/edge/index.ts":{"bytes":877,"imports":[{"path":"packages/core/functions/src/edge/functions.ts","kind":"import-statement","original":"./functions"}],"format":"esm"},"packages/core/functions/src/handler.ts":{"bytes":6306,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/schema.ts":{"bytes":5377,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/types.ts":{"bytes":21482,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"packages/core/functions/src/schema.ts","kind":"import-statement","original":"./schema"}],"format":"esm"},"packages/core/functions/src/trace.ts":{"bytes":16924,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/core/functions/src/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/core/functions/src/url.ts":{"bytes":6002,"imports":[],"format":"esm"},"packages/core/functions/src/services/ai.ts":{"bytes":2435,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/services/database.ts":{"bytes":1984,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/services/queues.ts":{"bytes":2458,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/services/credentials.ts":{"bytes":4258,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/services/event-logger.ts":{"bytes":6510,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/services/function-call-service.ts":{"bytes":7080,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/services/tracing.ts":{"bytes":1894,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/services/service-container.ts":{"bytes":11424,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"packages/core/functions/src/services/ai.ts","kind":"import-statement","original":"./ai"},{"path":"packages/core/functions/src/services/credentials.ts","kind":"import-statement","original":"./credentials"},{"path":"packages/core/functions/src/services/database.ts","kind":"import-statement","original":"./database"},{"path":"packages/core/functions/src/services/event-logger.ts","kind":"import-statement","original":"./event-logger"},{"path":"packages/core/functions/src/services/function-call-service.ts","kind":"import-statement","original":"./function-call-service"},{"path":"packages/core/functions/src/services/queues.ts","kind":"import-statement","original":"./queues"},{"path":"packages/core/functions/src/services/tracing.ts","kind":"import-statement","original":"./tracing"}],"format":"esm"},"packages/core/functions/src/services/index.ts":{"bytes":1148,"imports":[{"path":"packages/core/functions/src/services/ai.ts","kind":"import-statement","original":"./ai"},{"path":"packages/core/functions/src/services/database.ts","kind":"import-statement","original":"./database"},{"path":"packages/core/functions/src/services/queues.ts","kind":"import-statement","original":"./queues"},{"path":"packages/core/functions/src/services/service-container.ts","kind":"import-statement","original":"./service-container"},{"path":"packages/core/functions/src/services/credentials.ts","kind":"import-statement","original":"./credentials"},{"path":"packages/core/functions/src/services/tracing.ts","kind":"import-statement","original":"./tracing"},{"path":"packages/core/functions/src/services/event-logger.ts","kind":"import-statement","original":"./event-logger"},{"path":"packages/core/functions/src/services/function-call-service.ts","kind":"import-statement","original":"./function-call-service"}],"format":"esm"},"packages/core/functions/src/executor/executor.ts":{"bytes":4794,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/executor/index.ts":{"bytes":472,"imports":[{"path":"packages/core/functions/src/executor/executor.ts","kind":"import-statement","original":"./executor"}],"format":"esm"},"packages/core/functions/src/index.ts":{"bytes":1022,"imports":[{"path":"packages/core/functions/src/handler.ts","kind":"import-statement","original":"./handler"},{"path":"packages/core/functions/src/schema.ts","kind":"import-statement","original":"./schema"},{"path":"packages/core/functions/src/trace.ts","kind":"import-statement","original":"./trace"},{"path":"packages/core/functions/src/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/core/functions/src/url.ts","kind":"import-statement","original":"./url"},{"path":"packages/core/functions/src/services/index.ts","kind":"import-statement","original":"./services"},{"path":"packages/core/functions/src/executor/index.ts","kind":"import-statement","original":"./executor"}],"format":"esm"},"packages/core/functions/src/testing/logger.ts":{"bytes":1620,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"packages/core/functions/src/services/index.ts","kind":"import-statement","original":"../services"}],"format":"esm"},"packages/core/functions/src/testing/services.ts":{"bytes":2917,"imports":[{"path":"packages/core/functions/src/testing/logger.ts","kind":"import-statement","original":"./logger"},{"path":"packages/core/functions/src/services/index.ts","kind":"import-statement","original":"../services"}],"format":"esm"},"packages/core/functions/src/testing/index.ts":{"bytes":471,"imports":[{"path":"packages/core/functions/src/testing/services.ts","kind":"import-statement","original":"./services"}],"format":"esm"}},"outputs":{"packages/core/functions/dist/lib/browser/bundler/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":14572},"packages/core/functions/dist/lib/browser/bundler/index.mjs":{"imports":[{"path":"esbuild-wasm","kind":"import-statement","external":true},{"path":"@dxos/crypto","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["Bundler","initializeBundler"],"entryPoint":"packages/core/functions/src/bundler/index.ts","inputs":{"packages/core/functions/src/bundler/bundler.ts":{"bytesInOutput":7125},"packages/core/functions/src/bundler/index.ts":{"bytesInOutput":0}},"bytes":7253},"packages/core/functions/dist/lib/browser/edge/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3361},"packages/core/functions/dist/lib/browser/edge/index.mjs":{"imports":[{"path":"@dxos/client/edge","kind":"import-statement","external":true},{"path":"@dxos/edge-client","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["incrementSemverPatch","publicKeyToDid","uploadWorkerFunction"],"entryPoint":"packages/core/functions/src/edge/index.ts","inputs":{"packages/core/functions/src/edge/functions.ts":{"bytesInOutput":1692},"packages/core/functions/src/edge/index.ts":{"bytesInOutput":0}},"bytes":1853},"packages/core/functions/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":32025},"packages/core/functions/dist/lib/browser/index.mjs":{"imports":[{"path":"packages/core/functions/dist/lib/browser/chunk-WEFZUEL2.mjs","kind":"import-statement"},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true}],"exports":["AiService","ConfiguredCredentialsService","CredentialsService","DatabaseService","EmailTriggerOutput","EventLogger","FUNCTIONS_PRESET_META_KEY","FUNCTION_TYPES","FunctionCallService","FunctionExecutor","FunctionManifestSchema","FunctionTrigger","FunctionTriggerSchema","FunctionType","InvocationOutcome","InvocationTraceEndEvent","InvocationTraceEventType","InvocationTraceStartEvent","QueueService","QueueTriggerOutput","SERVICE_TAGS","ScriptType","ServiceContainer","SubscriptionTriggerOutput","TimerTriggerOutput","TraceEvent","TraceEventException","TraceEventLog","TracingService","TriggerKind","TriggerSchema","WebhookTriggerOutput","createDefectLogger","createEventLogger","createInvocationSpans","defineFunction","getInvocationUrl","getUserFunctionUrlInMetadata","logCustomEvent","makeFunctionUrl","setUserFunctionUrlInMetadata"],"entryPoint":"packages/core/functions/src/index.ts","inputs":{"packages/core/functions/src/handler.ts":{"bytesInOutput":453},"packages/core/functions/src/index.ts":{"bytesInOutput":0},"packages/core/functions/src/schema.ts":{"bytesInOutput":1255},"packages/core/functions/src/trace.ts":{"bytesInOutput":4279},"packages/core/functions/src/types.ts":{"bytesInOutput":4732},"packages/core/functions/src/url.ts":{"bytesInOutput":1189},"packages/core/functions/src/executor/executor.ts":{"bytesInOutput":949},"packages/core/functions/src/executor/index.ts":{"bytesInOutput":0}},"bytes":14375},"packages/core/functions/dist/lib/browser/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":2357},"packages/core/functions/dist/lib/browser/testing/index.mjs":{"imports":[{"path":"packages/core/functions/dist/lib/browser/chunk-WEFZUEL2.mjs","kind":"import-statement"},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["createTestServices"],"entryPoint":"packages/core/functions/src/testing/index.ts","inputs":{"packages/core/functions/src/testing/logger.ts":{"bytesInOutput":201},"packages/core/functions/src/testing/services.ts":{"bytesInOutput":348},"packages/core/functions/src/testing/index.ts":{"bytesInOutput":0}},"bytes":829},"packages/core/functions/dist/lib/browser/chunk-WEFZUEL2.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":19927},"packages/core/functions/dist/lib/browser/chunk-WEFZUEL2.mjs":{"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true}],"exports":["AiService","ConfiguredCredentialsService","CredentialsService","DatabaseService","EventLogger","FunctionCallService","QueueService","SERVICE_TAGS","ServiceContainer","TracingService","createDefectLogger","createEventLogger","logCustomEvent"],"inputs":{"packages/core/functions/src/services/ai.ts":{"bytesInOutput":504},"packages/core/functions/src/services/database.ts":{"bytesInOutput":435},"packages/core/functions/src/services/queues.ts":{"bytesInOutput":458},"packages/core/functions/src/services/credentials.ts":{"bytesInOutput":737},"packages/core/functions/src/services/event-logger.ts":{"bytesInOutput":1424},"packages/core/functions/src/services/function-call-service.ts":{"bytesInOutput":1522},"packages/core/functions/src/services/tracing.ts":{"bytesInOutput":293},"packages/core/functions/src/services/service-container.ts":{"bytesInOutput":2392},"packages/core/functions/src/services/index.ts":{"bytesInOutput":0}},"bytes":8519}}}
|
|
1
|
+
{"inputs":{"src/bundler/bundler.ts":{"bytes":32934,"imports":[{"path":"@effect/platform","kind":"import-statement","external":true},{"path":"effect","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":6596,"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/handler.ts":{"bytes":6273,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"src/schema.ts":{"bytes":5364,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true}],"format":"esm"},"src/types.ts":{"bytes":21469,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"src/schema.ts","kind":"import-statement","original":"./schema"}],"format":"esm"},"src/trace.ts":{"bytes":16911,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"src/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"src/url.ts":{"bytes":5989,"imports":[],"format":"esm"},"src/services/ai.ts":{"bytes":2422,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"src/services/database.ts":{"bytes":4341,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"src/services/queues.ts":{"bytes":2801,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"src/services/credentials.ts":{"bytes":4253,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"src/services/event-logger.ts":{"bytes":6497,"imports":[{"path":"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/services/function-call-service.ts":{"bytes":7067,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"src/services/tool-resolver.ts":{"bytes":2065,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"src/services/tracing.ts":{"bytes":1881,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"src/services/service-container.ts":{"bytes":12392,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"src/services/ai.ts","kind":"import-statement","original":"./ai"},{"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-call-service.ts","kind":"import-statement","original":"./function-call-service"},{"path":"src/services/queues.ts","kind":"import-statement","original":"./queues"},{"path":"src/services/tool-resolver.ts","kind":"import-statement","original":"./tool-resolver"},{"path":"src/services/tracing.ts","kind":"import-statement","original":"./tracing"}],"format":"esm"},"src/services/index.ts":{"bytes":1236,"imports":[{"path":"src/services/ai.ts","kind":"import-statement","original":"./ai"},{"path":"src/services/database.ts","kind":"import-statement","original":"./database"},{"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/credentials.ts","kind":"import-statement","original":"./credentials"},{"path":"src/services/tracing.ts","kind":"import-statement","original":"./tracing"},{"path":"src/services/event-logger.ts","kind":"import-statement","original":"./event-logger"},{"path":"src/services/function-call-service.ts","kind":"import-statement","original":"./function-call-service"},{"path":"src/services/tool-resolver.ts","kind":"import-statement","original":"./tool-resolver"}],"format":"esm"},"src/executor/executor.ts":{"bytes":5494,"imports":[{"path":"effect","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/index.ts":{"bytes":1009,"imports":[{"path":"src/handler.ts","kind":"import-statement","original":"./handler"},{"path":"src/schema.ts","kind":"import-statement","original":"./schema"},{"path":"src/trace.ts","kind":"import-statement","original":"./trace"},{"path":"src/types.ts","kind":"import-statement","original":"./types"},{"path":"src/url.ts","kind":"import-statement","original":"./url"},{"path":"src/services/index.ts","kind":"import-statement","original":"./services"},{"path":"src/executor/index.ts","kind":"import-statement","original":"./executor"}],"format":"esm"},"src/testing/logger.ts":{"bytes":1607,"imports":[{"path":"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":11700,"imports":[{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/ai/testing","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"src/testing/logger.ts","kind":"import-statement","original":"./logger"},{"path":"src/services/index.ts","kind":"import-statement","original":"../services"}],"format":"esm"},"src/testing/index.ts":{"bytes":458,"imports":[{"path":"src/testing/services.ts","kind":"import-statement","original":"./services"}],"format":"esm"}},"outputs":{"dist/lib/browser/bundler/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":16045},"dist/lib/browser/bundler/index.mjs":{"imports":[{"path":"@effect/platform","kind":"import-statement","external":true},{"path":"effect","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":7755},"src/bundler/index.ts":{"bytesInOutput":0}},"bytes":7859},"dist/lib/browser/edge/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3361},"dist/lib/browser/edge/index.mjs":{"imports":[{"path":"@dxos/client/edge","kind":"import-statement","external":true},{"path":"@dxos/edge-client","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["incrementSemverPatch","publicKeyToDid","uploadWorkerFunction"],"entryPoint":"src/edge/index.ts","inputs":{"src/edge/functions.ts":{"bytesInOutput":1679},"src/edge/index.ts":{"bytesInOutput":0}},"bytes":1816},"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":32419},"dist/lib/browser/index.mjs":{"imports":[{"path":"dist/lib/browser/chunk-54U464M4.mjs","kind":"import-statement"},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true}],"exports":["AiService","ConfiguredCredentialsService","CredentialsService","DatabaseService","EmailTriggerOutput","EventLogger","FUNCTIONS_PRESET_META_KEY","FUNCTION_TYPES","FunctionCallService","FunctionExecutor","FunctionManifestSchema","FunctionTrigger","FunctionTriggerSchema","FunctionType","InvocationOutcome","InvocationTraceEndEvent","InvocationTraceEventType","InvocationTraceStartEvent","QueueService","QueueTriggerOutput","SERVICE_TAGS","ScriptType","ServiceContainer","SubscriptionTriggerOutput","TimerTriggerOutput","ToolResolverService","TraceEvent","TraceEventException","TraceEventLog","TracingService","TriggerKind","TriggerSchema","WebhookTriggerOutput","createDefectLogger","createEventLogger","createInvocationSpans","defineFunction","getInvocationUrl","getUserFunctionUrlInMetadata","logCustomEvent","makeFunctionUrl","setUserFunctionUrlInMetadata"],"entryPoint":"src/index.ts","inputs":{"src/handler.ts":{"bytesInOutput":453},"src/index.ts":{"bytesInOutput":0},"src/schema.ts":{"bytesInOutput":1255},"src/trace.ts":{"bytesInOutput":4266},"src/types.ts":{"bytesInOutput":4732},"src/url.ts":{"bytesInOutput":1189},"src/executor/executor.ts":{"bytesInOutput":1104},"src/executor/index.ts":{"bytesInOutput":0}},"bytes":14395},"dist/lib/browser/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":7518},"dist/lib/browser/testing/index.mjs":{"imports":[{"path":"dist/lib/browser/chunk-54U464M4.mjs","kind":"import-statement"},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/ai/testing","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["createTestServices"],"entryPoint":"src/testing/index.ts","inputs":{"src/testing/services.ts":{"bytesInOutput":2001},"src/testing/logger.ts":{"bytesInOutput":201},"src/testing/index.ts":{"bytesInOutput":0}},"bytes":2536},"dist/lib/browser/chunk-54U464M4.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":23039},"dist/lib/browser/chunk-54U464M4.mjs":{"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true}],"exports":["AiService","ConfiguredCredentialsService","CredentialsService","DatabaseService","EventLogger","FunctionCallService","QueueService","SERVICE_TAGS","ServiceContainer","ToolResolverService","TracingService","createDefectLogger","createEventLogger","logCustomEvent"],"inputs":{"src/services/ai.ts":{"bytesInOutput":504},"src/services/database.ts":{"bytesInOutput":960},"src/services/queues.ts":{"bytesInOutput":565},"src/services/credentials.ts":{"bytesInOutput":737},"src/services/event-logger.ts":{"bytesInOutput":1425},"src/services/function-call-service.ts":{"bytesInOutput":1522},"src/services/tool-resolver.ts":{"bytesInOutput":411},"src/services/tracing.ts":{"bytesInOutput":293},"src/services/service-container.ts":{"bytesInOutput":2641},"src/services/index.ts":{"bytesInOutput":0}},"bytes":9677}}}
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AiService,
|
|
3
|
+
ConfiguredCredentialsService,
|
|
4
|
+
DatabaseService,
|
|
3
5
|
QueueService,
|
|
4
6
|
ServiceContainer,
|
|
7
|
+
ToolResolverService,
|
|
5
8
|
createEventLogger
|
|
6
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-54U464M4.mjs";
|
|
7
10
|
|
|
8
|
-
//
|
|
11
|
+
// src/testing/services.ts
|
|
12
|
+
import { EdgeAiServiceClient, ToolRegistry } from "@dxos/ai";
|
|
13
|
+
import { AI_SERVICE_ENDPOINT, createTestAiServiceClient } from "@dxos/ai/testing";
|
|
14
|
+
import { assertArgument } from "@dxos/invariant";
|
|
15
|
+
|
|
16
|
+
// src/testing/logger.ts
|
|
9
17
|
import { Effect } from "effect";
|
|
10
18
|
import { LogLevel } from "@dxos/log";
|
|
11
19
|
var noopLogger = {
|
|
@@ -14,14 +22,57 @@ var noopLogger = {
|
|
|
14
22
|
};
|
|
15
23
|
var consoleLogger = createEventLogger(LogLevel.INFO);
|
|
16
24
|
|
|
17
|
-
//
|
|
18
|
-
var createTestServices = ({ ai,
|
|
25
|
+
// src/testing/services.ts
|
|
26
|
+
var createTestServices = ({ ai, credentials, db, logging, queues, space, tracing, toolResolver } = {}) => {
|
|
27
|
+
assertArgument(!(!!space && (!!db || !!queues)), "space can be provided only if db and queues are not");
|
|
19
28
|
return new ServiceContainer().setServices({
|
|
20
|
-
ai:
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
ai: createAiService(ai),
|
|
30
|
+
credentials: createCredentialsService(credentials),
|
|
31
|
+
database: space || db ? DatabaseService.make(space?.db || db) : void 0,
|
|
32
|
+
eventLogger: logging?.logger ?? logging?.enabled ? consoleLogger : noopLogger,
|
|
33
|
+
queues: space || queues ? QueueService.make(space?.queues || queues, void 0) : void 0,
|
|
34
|
+
tracing: tracing?.service,
|
|
35
|
+
toolResolver: toolResolver ?? ToolResolverService.make(new ToolRegistry([]))
|
|
23
36
|
});
|
|
24
37
|
};
|
|
38
|
+
var createAiService = (ai) => {
|
|
39
|
+
if (ai?.client != null) {
|
|
40
|
+
return AiService.make(ai.client);
|
|
41
|
+
}
|
|
42
|
+
if (ai?.endpoint != null) {
|
|
43
|
+
return AiService.make(new EdgeAiServiceClient({
|
|
44
|
+
endpoint: ai.endpoint
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
switch (ai?.provider) {
|
|
48
|
+
case "dev":
|
|
49
|
+
return AiService.make(new EdgeAiServiceClient({
|
|
50
|
+
endpoint: AI_SERVICE_ENDPOINT.LOCAL,
|
|
51
|
+
defaultGenerationOptions: {
|
|
52
|
+
model: "@anthropic/claude-3-5-sonnet-20241022"
|
|
53
|
+
}
|
|
54
|
+
}));
|
|
55
|
+
case "edge":
|
|
56
|
+
return AiService.make(new EdgeAiServiceClient({
|
|
57
|
+
endpoint: AI_SERVICE_ENDPOINT.REMOTE,
|
|
58
|
+
defaultGenerationOptions: {
|
|
59
|
+
model: "@anthropic/claude-3-5-sonnet-20241022"
|
|
60
|
+
}
|
|
61
|
+
}));
|
|
62
|
+
case "ollama":
|
|
63
|
+
return AiService.make(createTestAiServiceClient());
|
|
64
|
+
case "lmstudio":
|
|
65
|
+
throw new Error("LMStudio is not supported");
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
var createCredentialsService = (credentials) => {
|
|
69
|
+
if (credentials?.services) {
|
|
70
|
+
return new ConfiguredCredentialsService(credentials.services);
|
|
71
|
+
}
|
|
72
|
+
if (credentials?.service) {
|
|
73
|
+
return credentials.service;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
25
76
|
export {
|
|
26
77
|
createTestServices
|
|
27
78
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/testing/
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport {
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["Effect", "LogLevel", "noopLogger", "log", "Effect", "succeed", "undefined", "nodeId", "consoleLogger", "createEventLogger", "LogLevel", "INFO", "createTestServices", "ai", "
|
|
3
|
+
"sources": ["../../../../src/testing/services.ts", "../../../../src/testing/logger.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Context } from 'effect';\n\nimport { type AiServiceEdgeClientOptions, EdgeAiServiceClient, type AiServiceClient, ToolRegistry } from '@dxos/ai';\nimport { AI_SERVICE_ENDPOINT, createTestAiServiceClient } from '@dxos/ai/testing';\nimport type { Space } from '@dxos/client/echo';\nimport type { EchoDatabase, QueueFactory } from '@dxos/echo-db';\nimport { assertArgument } from '@dxos/invariant';\n\nimport { consoleLogger, noopLogger } from './logger';\nimport {\n AiService,\n ConfiguredCredentialsService,\n type CredentialsService,\n DatabaseService,\n type EventLogger,\n QueueService,\n ServiceContainer,\n type ServiceCredential,\n ToolResolverService,\n type TracingService,\n} from '../services';\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?: OneOf<{\n /**\n * Custom AI service client.\n */\n client?: AiServiceClient;\n\n /**\n * Edge AI service at specified endpoint.\n */\n endpoint?: AiServiceEdgeClientOptions['endpoint'];\n\n /**\n * Predefined AI service configuration.\n */\n // TODO(burdon): 'dev' and 'edge' are redundant with providing an endpoint.\n provider?: AiServiceProvider;\n }>;\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<EventLogger>;\n };\n\n /**\n * Queue service configuration.\n */\n queues?: QueueFactory;\n\n tracing?: {\n service?: Context.Tag.Service<TracingService>;\n };\n\n toolResolver?: Context.Tag.Service<ToolResolverService>;\n};\n\nexport const createTestServices = ({\n ai,\n credentials,\n db,\n logging,\n queues,\n space,\n tracing,\n toolResolver,\n}: TestServiceOptions = {}): ServiceContainer => {\n assertArgument(!(!!space && (!!db || !!queues)), '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 toolResolver: toolResolver ?? ToolResolverService.make(new ToolRegistry([])),\n });\n};\n\n// TODO(burdon): Enable model configuration.\nconst createAiService = (ai: TestServiceOptions['ai']): Context.Tag.Service<AiService> | undefined => {\n if (ai?.client != null) {\n return AiService.make(ai.client);\n }\n\n if (ai?.endpoint != null) {\n return AiService.make(new EdgeAiServiceClient({ endpoint: ai.endpoint }));\n }\n\n switch (ai?.provider) {\n case 'dev':\n return AiService.make(\n new EdgeAiServiceClient({\n endpoint: AI_SERVICE_ENDPOINT.LOCAL,\n defaultGenerationOptions: {\n model: '@anthropic/claude-3-5-sonnet-20241022',\n },\n }),\n );\n\n case 'edge':\n return AiService.make(\n new EdgeAiServiceClient({\n endpoint: AI_SERVICE_ENDPOINT.REMOTE,\n defaultGenerationOptions: {\n model: '@anthropic/claude-3-5-sonnet-20241022',\n },\n }),\n );\n\n case 'ollama':\n return AiService.make(createTestAiServiceClient());\n\n case 'lmstudio':\n throw new Error('LMStudio is not supported');\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 { Effect, type Context } from 'effect';\n\nimport { LogLevel } from '@dxos/log';\n\nimport { type EventLogger, createEventLogger } from '../services';\n\nexport const noopLogger: Context.Tag.Service<EventLogger> = {\n log: () => Effect.succeed(undefined),\n nodeId: undefined,\n};\n\nexport const consoleLogger: Context.Tag.Service<EventLogger> = createEventLogger(LogLevel.INFO);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAMA,SAA0CA,qBAA2CC,oBAAoB;AACzG,SAASC,qBAAqBC,iCAAiC;AAG/D,SAASC,sBAAs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AoB;QACtBD,UAAUG,oBAAoBI;QAC9BF,0BAA0B;UACxBC,OAAO;QACT;MACF,CAAA,CAAA;IAGJ,KAAK;AACH,aAAOP,UAAUZ,KAAKqB,0BAAAA,CAAAA;IAExB,KAAK;AACH,YAAM,IAAIC,MAAM,2BAAA;EACpB;AACF;AAEA,IAAMzB,2BAA2B,CAC/BX,gBAAAA;AAEA,MAAIA,aAAaqC,UAAU;AACzB,WAAO,IAAIC,6BAA6BtC,YAAYqC,QAAQ;EAC9D;AAEA,MAAIrC,aAAasB,SAAS;AACxB,WAAOtB,YAAYsB;EACrB;AACF;",
|
|
6
|
+
"names": ["EdgeAiServiceClient", "ToolRegistry", "AI_SERVICE_ENDPOINT", "createTestAiServiceClient", "assertArgument", "Effect", "LogLevel", "noopLogger", "log", "Effect", "succeed", "undefined", "nodeId", "consoleLogger", "createEventLogger", "LogLevel", "INFO", "createTestServices", "ai", "credentials", "db", "logging", "queues", "space", "tracing", "toolResolver", "assertArgument", "ServiceContainer", "setServices", "createAiService", "createCredentialsService", "database", "DatabaseService", "make", "undefined", "eventLogger", "logger", "enabled", "consoleLogger", "noopLogger", "QueueService", "service", "ToolResolverService", "ToolRegistry", "client", "AiService", "endpoint", "EdgeAiServiceClient", "provider", "AI_SERVICE_ENDPOINT", "LOCAL", "defaultGenerationOptions", "model", "REMOTE", "createTestAiServiceClient", "Error", "services", "ConfiguredCredentialsService"]
|
|
7
7
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// src/bundler/bundler.ts
|
|
4
|
+
import { FetchHttpClient, HttpClient } from "@effect/platform";
|
|
5
|
+
import { Duration, Effect, pipe, Schedule } from "effect";
|
|
4
6
|
import { build, initialize } from "esbuild-wasm";
|
|
5
7
|
import { subtleCrypto } from "@dxos/crypto";
|
|
8
|
+
import { runAndForwardErrors } from "@dxos/effect";
|
|
6
9
|
import { invariant } from "@dxos/invariant";
|
|
7
10
|
import { log } from "@dxos/log";
|
|
8
|
-
var __dxlog_file = "/
|
|
11
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/core/functions/src/bundler/bundler.ts";
|
|
9
12
|
var initialized;
|
|
10
13
|
var initializeBundler = async (options) => {
|
|
11
14
|
await (initialized ??= initialize({
|
|
@@ -28,7 +31,7 @@ var Bundler = class {
|
|
|
28
31
|
if (this._options.platform === "browser") {
|
|
29
32
|
invariant(initialized, "Compiler not initialized.", {
|
|
30
33
|
F: __dxlog_file,
|
|
31
|
-
L:
|
|
34
|
+
L: 73,
|
|
32
35
|
S: this,
|
|
33
36
|
A: [
|
|
34
37
|
"initialized",
|
|
@@ -122,7 +125,7 @@ var Bundler = class {
|
|
|
122
125
|
});
|
|
123
126
|
log("compile complete", result.metafile, {
|
|
124
127
|
F: __dxlog_file,
|
|
125
|
-
L:
|
|
128
|
+
L: 137,
|
|
126
129
|
S: this,
|
|
127
130
|
C: (f, a) => f(...a)
|
|
128
131
|
});
|
|
@@ -140,7 +143,7 @@ var Bundler = class {
|
|
|
140
143
|
analyzeImports(result) {
|
|
141
144
|
invariant(result.outputFiles, void 0, {
|
|
142
145
|
F: __dxlog_file,
|
|
143
|
-
L:
|
|
146
|
+
L: 150,
|
|
144
147
|
S: this,
|
|
145
148
|
A: [
|
|
146
149
|
"result.outputFiles",
|
|
@@ -203,6 +206,8 @@ var analyzeSourceFileImports = (code) => {
|
|
|
203
206
|
};
|
|
204
207
|
});
|
|
205
208
|
};
|
|
209
|
+
var MAX_RETRIES = 5;
|
|
210
|
+
var INITIAL_DELAY = 1e3;
|
|
206
211
|
var httpPlugin = {
|
|
207
212
|
name: "http",
|
|
208
213
|
setup: (build2) => {
|
|
@@ -223,11 +228,17 @@ var httpPlugin = {
|
|
|
223
228
|
filter: /.*/,
|
|
224
229
|
namespace: "http-url"
|
|
225
230
|
}, async (args) => {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
+
return Effect.gen(function* () {
|
|
232
|
+
const response = yield* HttpClient.get(args.path);
|
|
233
|
+
if (response.status !== 200) {
|
|
234
|
+
throw new Error(`failed to fetch: ${response.status}`);
|
|
235
|
+
}
|
|
236
|
+
const text = yield* response.text;
|
|
237
|
+
return {
|
|
238
|
+
contents: text,
|
|
239
|
+
loader: "jsx"
|
|
240
|
+
};
|
|
241
|
+
}).pipe(Effect.retry(pipe(Schedule.exponential(Duration.millis(INITIAL_DELAY)), Schedule.jittered, Schedule.intersect(Schedule.recurs(MAX_RETRIES - 1)))), Effect.provide(FetchHttpClient.layer), runAndForwardErrors);
|
|
231
242
|
});
|
|
232
243
|
}
|
|
233
244
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/bundler/bundler.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport {
|
|
5
|
-
"mappings": ";;;
|
|
6
|
-
"names": ["build", "initialize", "subtleCrypto", "invariant", "log", "initialized", "initializeBundler", "options", "wasmURL", "wasmUrl", "Bundler", "_options", "bundle", "path", "source", "sandboxedModules", "providedModules", "createResult", "result", "timestamp", "Date", "now", "sourceHash", "Buffer", "from", "digest", "undefined", "platform", "imports", "analyzeSourceFileImports", "conditions", "metafile", "write", "entryPoints", "format", "plugins", "name", "setup", "onResolve", "filter", "external", "split", "namespace", "onLoad", "contents", "loader", "module", "RegExp", "namedImports", "find", "entry", "moduleIdentifier", "join", "JSON", "stringify", "httpPlugin", "analyzeImports", "outputFiles", "text", "err", "error", "parsedImports", "allMatches", "IMPORT_REGEX", "Object", "values", "outputs", "map", "parsedImport", "capture", "NAMED_IMPORTS_REGEX", "lastIndex", "namedImportsMatch", "exec", "forEach", "importName", "push", "trim", "moduleUrl", "defaultImport", "code", "defaultImportName", "wildcardImportName", "quotes", "regex", "str", "match", "matches", "slice", "args", "URL", "importer", "toString", "response", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { FetchHttpClient, HttpClient } from '@effect/platform';\nimport { Duration, Effect, pipe, Schedule } from 'effect';\nimport { type BuildOptions, type Loader, build, initialize, type BuildResult, type Plugin } from 'esbuild-wasm';\n\nimport { subtleCrypto } from '@dxos/crypto';\nimport { runAndForwardErrors } from '@dxos/effect';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\n\nexport type Import = {\n moduleUrl: string;\n defaultImport: boolean;\n namedImports: string[];\n};\n\nexport type BundleOptions = {\n /**\n * Path to the source file on the local file system.\n * If provided, the path will be used instead of the `source` code.\n */\n path?: string;\n\n /**\n * Source code to bundle.\n * Required if `path` is not provided.\n */\n source?: string;\n};\n\nexport type BundleResult = {\n timestamp: number;\n sourceHash?: Buffer;\n imports?: Import[];\n bundle?: string;\n error?: any;\n};\n\nexport type BundlerOptions = {\n platform: BuildOptions['platform'];\n sandboxedModules: string[];\n remoteModules: Record<string, string>;\n};\n\nlet initialized: Promise<void>;\nexport const initializeBundler = async (options: { wasmUrl: string }) => {\n await (initialized ??= initialize({\n wasmURL: options.wasmUrl,\n }));\n};\n\n/**\n * ESBuild bundler.\n */\nexport class Bundler {\n constructor(private readonly _options: BundlerOptions) {}\n\n async bundle({ path, source }: BundleOptions): Promise<BundleResult> {\n const { sandboxedModules: providedModules, ...options } = this._options;\n\n const createResult = async (result?: Partial<BundleResult>) => {\n return {\n timestamp: Date.now(),\n sourceHash: source ? Buffer.from(await subtleCrypto.digest('SHA-256', Buffer.from(source))) : undefined,\n ...result,\n };\n };\n\n if (this._options.platform === 'browser') {\n invariant(initialized, 'Compiler not initialized.');\n await initialized;\n }\n\n const imports = source ? analyzeSourceFileImports(source) : [];\n\n // https://esbuild.github.io/api/#build\n try {\n const result = await build({\n platform: options.platform,\n conditions: ['workerd', 'browser'],\n metafile: true,\n write: false,\n entryPoints: [path ?? 'memory:main.tsx'],\n bundle: true,\n format: 'esm',\n plugins: [\n {\n name: 'memory',\n setup: (build) => {\n build.onResolve({ filter: /^\\.\\/runtime\\.js$/ }, ({ path }) => {\n return { path, external: true };\n });\n\n build.onResolve({ filter: /^dxos:functions$/ }, ({ path }) => {\n return { path: './runtime.js', external: true };\n });\n\n build.onResolve({ filter: /^memory:/ }, ({ path }) => {\n return { path: path.split(':')[1], namespace: 'memory' };\n });\n\n build.onLoad({ filter: /.*/, namespace: 'memory' }, ({ path }) => {\n if (path === 'main.tsx') {\n return {\n contents: source,\n loader: 'tsx',\n };\n }\n });\n\n for (const module of providedModules) {\n build.onResolve({ filter: new RegExp(`^${module}$`) }, ({ path }) => {\n return { path, namespace: 'injected-module' };\n });\n }\n\n build.onLoad({ filter: /.*/, namespace: 'injected-module' }, ({ path }) => {\n const namedImports = imports.find((entry) => entry.moduleIdentifier === path)?.namedImports ?? [];\n return {\n contents: `\n const { ${namedImports.join(',')} } = window.__DXOS_SANDBOX_MODULES__[${JSON.stringify(path)}];\n export { ${namedImports.join(',')} };\n export default window.__DXOS_SANDBOX_MODULES__[${JSON.stringify(path)}].default;\n `,\n loader: 'tsx',\n };\n });\n },\n },\n httpPlugin,\n ],\n });\n\n log('compile complete', result.metafile);\n\n return await createResult({\n imports: this.analyzeImports(result),\n bundle: result.outputFiles![0].text,\n });\n } catch (err) {\n return await createResult({ error: err });\n }\n }\n\n // TODO(dmaretskyi): In the future we can replace the compiler with SWC with plugins running in WASM.\n analyzeImports(result: BuildResult): Import[] {\n invariant(result.outputFiles);\n\n // TODO(dmaretskyi): Support import aliases and wildcard imports.\n const parsedImports = allMatches(IMPORT_REGEX, result.outputFiles[0].text);\n return Object.values(result.metafile!.outputs)[0].imports.map((entry): Import => {\n const namedImports: string[] = [];\n\n const parsedImport = parsedImports.find((capture) => capture?.[4] === entry.path);\n if (parsedImport?.[2]) {\n NAMED_IMPORTS_REGEX.lastIndex = 0;\n const namedImportsMatch = NAMED_IMPORTS_REGEX.exec(parsedImport[2]);\n if (namedImportsMatch) {\n namedImportsMatch[1].split(',').forEach((importName) => {\n namedImports.push(importName.trim());\n });\n }\n }\n\n return {\n moduleUrl: entry.path,\n defaultImport: !!parsedImport?.[1],\n namedImports,\n };\n });\n }\n\n analyzeSourceFileImports(code: string): {\n defaultImportName: string;\n namedImports: string[];\n wildcardImportName: string;\n moduleIdentifier: string;\n quotes: string;\n }[] {\n // TODO(dmaretskyi): Support import aliases and wildcard imports.\n const parsedImports = allMatches(IMPORT_REGEX, code);\n return parsedImports.map((capture) => {\n return {\n defaultImportName: capture[1],\n namedImports: capture[2]?.split(',').map((importName) => importName.trim()),\n wildcardImportName: capture[3],\n moduleIdentifier: capture[4],\n quotes: capture[5],\n };\n });\n }\n}\n\n// https://regex101.com/r/FEN5ks/1\n// https://stackoverflow.com/a/73265022\n// $1 = default import name (can be non-existent)\n// $2 = destructured exports (can be non-existent)\n// $3 = wildcard import name (can be non-existent)\n// $4 = module identifier\n// $5 = quotes used (either ' or \")\nconst IMPORT_REGEX =\n /import(?:(?:(?:[ \\n\\t]+([^ *\\n\\t{},]+)[ \\n\\t]*(?:,|[ \\n\\t]+))?([ \\n\\t]*{(?:[ \\n\\t]*[^ \\n\\t\"'{}]+[ \\n\\t]*,?)+})?[ \\n\\t]*)|[ \\n\\t]*\\*[ \\n\\t]*as[ \\n\\t]+([^ \\n\\t{}]+)[ \\n\\t]+)from[ \\n\\t]*(?:['\"])([^'\"\\n]+)(['\"])/gm;\n\nconst NAMED_IMPORTS_REGEX = /[ \\n\\t]*{((?:[ \\n\\t]*[^ \\n\\t\"'{}]+[ \\n\\t]*,?)+)}[ \\n\\t]*/gm;\n\nconst allMatches = (regex: RegExp, str: string) => {\n regex.lastIndex = 0;\n\n let match;\n const matches = [];\n while ((match = regex.exec(str))) {\n matches.push(match);\n }\n\n return matches;\n};\n\ntype ParsedImport = {\n defaultImportName?: string;\n namedImports: string[];\n wildcardImportName?: string;\n moduleIdentifier: string;\n quotes: string;\n};\n\nconst analyzeSourceFileImports = (code: string): ParsedImport[] => {\n // TODO(dmaretskyi): Support import aliases and wildcard imports.\n const parsedImports = allMatches(IMPORT_REGEX, code);\n return parsedImports.map((capture) => {\n return {\n defaultImportName: capture[1],\n namedImports: capture[2]\n ?.trim()\n .slice(1, -1)\n .split(',')\n .map((importName) => importName.trim()),\n wildcardImportName: capture[3],\n moduleIdentifier: capture[4],\n quotes: capture[5],\n };\n });\n};\n\nconst MAX_RETRIES = 5;\nconst INITIAL_DELAY = 1_000;\n\nconst httpPlugin: Plugin = {\n name: 'http',\n setup: (build) => {\n // Intercept import paths starting with \"http:\" and \"https:\" so esbuild doesn't attempt to map them to a file system location.\n // Tag them with the \"http-url\" namespace to associate them with this plugin.\n build.onResolve({ filter: /^https?:\\/\\// }, (args) => ({\n path: args.path,\n namespace: 'http-url',\n }));\n\n // We also want to intercept all import paths inside downloaded files and resolve them against the original URL.\n // All of these files will be in the \"http-url\" namespace.\n // Make sure to keep the newly resolved URL in the \"http-url\" namespace so imports inside it will also be resolved as URLs recursively.\n build.onResolve({ filter: /.*/, namespace: 'http-url' }, (args) => ({\n path: new URL(args.path, args.importer).toString(),\n namespace: 'http-url',\n }));\n\n // When a URL is loaded, we want to actually download the content from the internet.\n // This has just enough logic to be able to handle the example import from unpkg.com but in reality this would probably need to be more complex.\n build.onLoad({ filter: /.*/, namespace: 'http-url' }, async (args) => {\n return Effect.gen(function* () {\n const response = yield* HttpClient.get(args.path);\n if (response.status !== 200) {\n throw new Error(`failed to fetch: ${response.status}`);\n }\n\n const text = yield* response.text;\n return { contents: text, loader: 'jsx' as Loader };\n }).pipe(\n Effect.retry(\n pipe(\n Schedule.exponential(Duration.millis(INITIAL_DELAY)),\n Schedule.jittered,\n Schedule.intersect(Schedule.recurs(MAX_RETRIES - 1)),\n ),\n ),\n Effect.provide(FetchHttpClient.layer),\n runAndForwardErrors,\n );\n });\n },\n};\n"],
|
|
5
|
+
"mappings": ";;;AAIA,SAASA,iBAAiBC,kBAAkB;AAC5C,SAASC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C3D,aAAO/F,OAAOmG,IAAI,aAAA;AAChB,cAAMC,WAAW,OAAOtG,WAAWuG,IAAIN,KAAK9E,IAAI;AAChD,YAAImF,SAASE,WAAW,KAAK;AAC3B,gBAAM,IAAIC,MAAM,oBAAoBH,SAASE,MAAM,EAAE;QACvD;AAEA,cAAMxC,OAAO,OAAOsC,SAAStC;AAC7B,eAAO;UAAEd,UAAUc;UAAMb,QAAQ;QAAgB;MACnD,CAAA,EAAGhD,KACDD,OAAOwG,MACLvG,KACEC,SAASuG,YAAY1G,SAAS2G,OAAOZ,aAAAA,CAAAA,GACrC5F,SAASyG,UACTzG,SAAS0G,UAAU1G,SAAS2G,OAAOhB,cAAc,CAAA,CAAA,CAAA,CAAA,GAGrD7F,OAAO8G,QAAQjH,gBAAgBkH,KAAK,GACpCzG,mBAAAA;IAEJ,CAAA;EACF;AACF;",
|
|
6
|
+
"names": ["FetchHttpClient", "HttpClient", "Duration", "Effect", "pipe", "Schedule", "build", "initialize", "subtleCrypto", "runAndForwardErrors", "invariant", "log", "initialized", "initializeBundler", "options", "wasmURL", "wasmUrl", "Bundler", "_options", "bundle", "path", "source", "sandboxedModules", "providedModules", "createResult", "result", "timestamp", "Date", "now", "sourceHash", "Buffer", "from", "digest", "undefined", "platform", "imports", "analyzeSourceFileImports", "conditions", "metafile", "write", "entryPoints", "format", "plugins", "name", "setup", "onResolve", "filter", "external", "split", "namespace", "onLoad", "contents", "loader", "module", "RegExp", "namedImports", "find", "entry", "moduleIdentifier", "join", "JSON", "stringify", "httpPlugin", "analyzeImports", "outputFiles", "text", "err", "error", "parsedImports", "allMatches", "IMPORT_REGEX", "Object", "values", "outputs", "map", "parsedImport", "capture", "NAMED_IMPORTS_REGEX", "lastIndex", "namedImportsMatch", "exec", "forEach", "importName", "push", "trim", "moduleUrl", "defaultImport", "code", "defaultImportName", "wildcardImportName", "quotes", "regex", "str", "match", "matches", "slice", "MAX_RETRIES", "INITIAL_DELAY", "args", "URL", "importer", "toString", "gen", "response", "get", "status", "Error", "retry", "exponential", "millis", "jittered", "intersect", "recurs", "provide", "layer"]
|
|
7
7
|
}
|