@dxos/functions 0.8.4-main.dedc0f3 → 0.8.4-main.dfabb4ec29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/README.md +4 -6
  2. package/dist/lib/neutral/index.mjs +593 -0
  3. package/dist/lib/neutral/index.mjs.map +7 -0
  4. package/dist/lib/neutral/meta.json +1 -0
  5. package/dist/types/src/index.d.ts +3 -9
  6. package/dist/types/src/index.d.ts.map +1 -1
  7. package/dist/types/src/protocol/functions-ai-http-client.d.ts +12 -0
  8. package/dist/types/src/protocol/functions-ai-http-client.d.ts.map +1 -0
  9. package/dist/types/src/protocol/functions-ai-http-client.test.d.ts +2 -0
  10. package/dist/types/src/protocol/functions-ai-http-client.test.d.ts.map +1 -0
  11. package/dist/types/src/protocol/index.d.ts +2 -0
  12. package/dist/types/src/protocol/index.d.ts.map +1 -0
  13. package/dist/types/src/protocol/protocol.d.ts +19 -0
  14. package/dist/types/src/protocol/protocol.d.ts.map +1 -0
  15. package/dist/types/src/protocol/protocol.test.d.ts +2 -0
  16. package/dist/types/src/protocol/protocol.test.d.ts.map +1 -0
  17. package/dist/types/src/sdk.d.ts +10 -0
  18. package/dist/types/src/sdk.d.ts.map +1 -0
  19. package/dist/types/src/services/credentials.d.ts +22 -39
  20. package/dist/types/src/services/credentials.d.ts.map +1 -1
  21. package/dist/types/src/services/function-invocation-service.d.ts +15 -0
  22. package/dist/types/src/services/function-invocation-service.d.ts.map +1 -0
  23. package/dist/types/src/services/index.d.ts +3 -7
  24. package/dist/types/src/services/index.d.ts.map +1 -1
  25. package/dist/types/src/services/queues.d.ts +1 -44
  26. package/dist/types/src/services/queues.d.ts.map +1 -1
  27. package/dist/types/src/services/tracing.d.ts +2 -54
  28. package/dist/types/src/services/tracing.d.ts.map +1 -1
  29. package/dist/types/src/types/index.d.ts +2 -0
  30. package/dist/types/src/types/index.d.ts.map +1 -0
  31. package/dist/types/src/types/url.d.ts +13 -0
  32. package/dist/types/src/types/url.d.ts.map +1 -0
  33. package/dist/types/tsconfig.tsbuildinfo +1 -1
  34. package/package.json +25 -72
  35. package/src/index.ts +3 -9
  36. package/src/protocol/functions-ai-http-client.test.ts +105 -0
  37. package/src/protocol/functions-ai-http-client.ts +141 -0
  38. package/src/{executor → protocol}/index.ts +1 -1
  39. package/src/protocol/protocol.test.ts +58 -0
  40. package/src/protocol/protocol.ts +428 -0
  41. package/src/sdk.ts +31 -0
  42. package/src/services/credentials.ts +90 -111
  43. package/src/services/function-invocation-service.ts +33 -0
  44. package/src/services/index.ts +3 -7
  45. package/src/services/queues.ts +1 -78
  46. package/src/services/tracing.ts +1 -133
  47. package/src/types/index.ts +5 -0
  48. package/src/types/url.ts +32 -0
  49. package/dist/lib/browser/bundler/index.mjs +0 -265
  50. package/dist/lib/browser/bundler/index.mjs.map +0 -7
  51. package/dist/lib/browser/chunk-ANP3DFCO.mjs +0 -623
  52. package/dist/lib/browser/chunk-ANP3DFCO.mjs.map +0 -7
  53. package/dist/lib/browser/chunk-J5LGTIGS.mjs +0 -10
  54. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +0 -7
  55. package/dist/lib/browser/edge/index.mjs +0 -83
  56. package/dist/lib/browser/edge/index.mjs.map +0 -7
  57. package/dist/lib/browser/index.mjs +0 -1265
  58. package/dist/lib/browser/index.mjs.map +0 -7
  59. package/dist/lib/browser/meta.json +0 -1
  60. package/dist/lib/browser/testing/index.mjs +0 -129
  61. package/dist/lib/browser/testing/index.mjs.map +0 -7
  62. package/dist/lib/node-esm/bundler/index.mjs +0 -266
  63. package/dist/lib/node-esm/bundler/index.mjs.map +0 -7
  64. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
  65. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +0 -7
  66. package/dist/lib/node-esm/chunk-MPKVY7ZR.mjs +0 -625
  67. package/dist/lib/node-esm/chunk-MPKVY7ZR.mjs.map +0 -7
  68. package/dist/lib/node-esm/edge/index.mjs +0 -84
  69. package/dist/lib/node-esm/edge/index.mjs.map +0 -7
  70. package/dist/lib/node-esm/index.mjs +0 -1266
  71. package/dist/lib/node-esm/index.mjs.map +0 -7
  72. package/dist/lib/node-esm/meta.json +0 -1
  73. package/dist/lib/node-esm/testing/index.mjs +0 -130
  74. package/dist/lib/node-esm/testing/index.mjs.map +0 -7
  75. package/dist/types/src/bundler/bundler.d.ts +0 -49
  76. package/dist/types/src/bundler/bundler.d.ts.map +0 -1
  77. package/dist/types/src/bundler/bundler.test.d.ts +0 -2
  78. package/dist/types/src/bundler/bundler.test.d.ts.map +0 -1
  79. package/dist/types/src/bundler/index.d.ts +0 -2
  80. package/dist/types/src/bundler/index.d.ts.map +0 -1
  81. package/dist/types/src/edge/functions.d.ts +0 -17
  82. package/dist/types/src/edge/functions.d.ts.map +0 -1
  83. package/dist/types/src/edge/index.d.ts +0 -2
  84. package/dist/types/src/edge/index.d.ts.map +0 -1
  85. package/dist/types/src/errors.d.ts +0 -137
  86. package/dist/types/src/errors.d.ts.map +0 -1
  87. package/dist/types/src/examples/fib.d.ts +0 -7
  88. package/dist/types/src/examples/fib.d.ts.map +0 -1
  89. package/dist/types/src/examples/index.d.ts +0 -4
  90. package/dist/types/src/examples/index.d.ts.map +0 -1
  91. package/dist/types/src/examples/reply.d.ts +0 -3
  92. package/dist/types/src/examples/reply.d.ts.map +0 -1
  93. package/dist/types/src/examples/sleep.d.ts +0 -5
  94. package/dist/types/src/examples/sleep.d.ts.map +0 -1
  95. package/dist/types/src/executor/executor.d.ts +0 -11
  96. package/dist/types/src/executor/executor.d.ts.map +0 -1
  97. package/dist/types/src/executor/index.d.ts +0 -2
  98. package/dist/types/src/executor/index.d.ts.map +0 -1
  99. package/dist/types/src/handler.d.ts +0 -94
  100. package/dist/types/src/handler.d.ts.map +0 -1
  101. package/dist/types/src/schema.d.ts +0 -43
  102. package/dist/types/src/schema.d.ts.map +0 -1
  103. package/dist/types/src/services/database.d.ts +0 -98
  104. package/dist/types/src/services/database.d.ts.map +0 -1
  105. package/dist/types/src/services/event-logger.d.ts +0 -72
  106. package/dist/types/src/services/event-logger.d.ts.map +0 -1
  107. package/dist/types/src/services/local-function-execution.d.ts +0 -25
  108. package/dist/types/src/services/local-function-execution.d.ts.map +0 -1
  109. package/dist/types/src/services/remote-function-execution-service.d.ts +0 -15
  110. package/dist/types/src/services/remote-function-execution-service.d.ts.map +0 -1
  111. package/dist/types/src/services/service-container.d.ts +0 -56
  112. package/dist/types/src/services/service-container.d.ts.map +0 -1
  113. package/dist/types/src/services/service-registry.d.ts +0 -29
  114. package/dist/types/src/services/service-registry.d.ts.map +0 -1
  115. package/dist/types/src/services/service-registry.test.d.ts +0 -2
  116. package/dist/types/src/services/service-registry.test.d.ts.map +0 -1
  117. package/dist/types/src/testing/index.d.ts +0 -3
  118. package/dist/types/src/testing/index.d.ts.map +0 -1
  119. package/dist/types/src/testing/layer.d.ts +0 -15
  120. package/dist/types/src/testing/layer.d.ts.map +0 -1
  121. package/dist/types/src/testing/logger.d.ts +0 -5
  122. package/dist/types/src/testing/logger.d.ts.map +0 -1
  123. package/dist/types/src/testing/persist-database.test.d.ts +0 -2
  124. package/dist/types/src/testing/persist-database.test.d.ts.map +0 -1
  125. package/dist/types/src/testing/services.d.ts +0 -59
  126. package/dist/types/src/testing/services.d.ts.map +0 -1
  127. package/dist/types/src/trace.d.ts +0 -122
  128. package/dist/types/src/trace.d.ts.map +0 -1
  129. package/dist/types/src/translations.d.ts +0 -12
  130. package/dist/types/src/translations.d.ts.map +0 -1
  131. package/dist/types/src/triggers/index.d.ts +0 -4
  132. package/dist/types/src/triggers/index.d.ts.map +0 -1
  133. package/dist/types/src/triggers/input-builder.d.ts +0 -3
  134. package/dist/types/src/triggers/input-builder.d.ts.map +0 -1
  135. package/dist/types/src/triggers/invocation-tracer.d.ts +0 -35
  136. package/dist/types/src/triggers/invocation-tracer.d.ts.map +0 -1
  137. package/dist/types/src/triggers/trigger-dispatcher.d.ts +0 -75
  138. package/dist/types/src/triggers/trigger-dispatcher.d.ts.map +0 -1
  139. package/dist/types/src/triggers/trigger-dispatcher.test.d.ts +0 -2
  140. package/dist/types/src/triggers/trigger-dispatcher.test.d.ts.map +0 -1
  141. package/dist/types/src/triggers/trigger-state-store.d.ts +0 -27
  142. package/dist/types/src/triggers/trigger-state-store.d.ts.map +0 -1
  143. package/dist/types/src/types.d.ts +0 -211
  144. package/dist/types/src/types.d.ts.map +0 -1
  145. package/dist/types/src/url.d.ts +0 -21
  146. package/dist/types/src/url.d.ts.map +0 -1
  147. package/src/bundler/bundler.test.ts +0 -58
  148. package/src/bundler/bundler.ts +0 -291
  149. package/src/bundler/index.ts +0 -5
  150. package/src/edge/functions.ts +0 -67
  151. package/src/edge/index.ts +0 -9
  152. package/src/errors.ts +0 -21
  153. package/src/examples/fib.ts +0 -30
  154. package/src/examples/index.ts +0 -7
  155. package/src/examples/reply.ts +0 -18
  156. package/src/examples/sleep.ts +0 -22
  157. package/src/executor/executor.ts +0 -54
  158. package/src/handler.ts +0 -201
  159. package/src/schema.ts +0 -68
  160. package/src/services/database.ts +0 -170
  161. package/src/services/event-logger.ts +0 -118
  162. package/src/services/local-function-execution.ts +0 -114
  163. package/src/services/remote-function-execution-service.ts +0 -46
  164. package/src/services/service-container.ts +0 -114
  165. package/src/services/service-registry.test.ts +0 -42
  166. package/src/services/service-registry.ts +0 -59
  167. package/src/testing/index.ts +0 -6
  168. package/src/testing/layer.ts +0 -111
  169. package/src/testing/logger.ts +0 -16
  170. package/src/testing/persist-database.test.ts +0 -87
  171. package/src/testing/services.ts +0 -115
  172. package/src/trace.ts +0 -178
  173. package/src/translations.ts +0 -20
  174. package/src/triggers/index.ts +0 -7
  175. package/src/triggers/input-builder.ts +0 -35
  176. package/src/triggers/invocation-tracer.ts +0 -99
  177. package/src/triggers/trigger-dispatcher.test.ts +0 -652
  178. package/src/triggers/trigger-dispatcher.ts +0 -512
  179. package/src/triggers/trigger-state-store.ts +0 -60
  180. package/src/types.ts +0 -200
  181. package/src/url.ts +0 -55
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/services/credentials.ts", "../../../src/services/function-invocation-service.ts", "../../../src/services/queues.ts", "../../../src/services/tracing.ts", "../../../src/types/url.ts", "../../../src/protocol/protocol.ts", "../../../src/protocol/functions-ai-http-client.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as HttpClient from '@effect/platform/HttpClient';\nimport * as HttpClientRequest from '@effect/platform/HttpClientRequest';\nimport type * as Config from 'effect/Config';\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Redacted from 'effect/Redacted';\n\nimport { Credential } from '@dxos/compute';\nimport { Query } from '@dxos/echo';\nimport { Database } from '@dxos/echo';\nimport { AccessToken } from '@dxos/types';\n\nexport class ConfiguredCredentialsService implements Context.Tag.Service<Credential.CredentialsService> {\n constructor(private readonly credentials: Credential.ServiceCredential[] = []) {}\n\n addCredentials(credentials: Credential.ServiceCredential[]): ConfiguredCredentialsService {\n this.credentials.push(...credentials);\n return this;\n }\n\n async queryCredentials(query: Credential.CredentialQuery): Promise<Credential.ServiceCredential[]> {\n return this.credentials.filter((credential) => credential.service === query.service);\n }\n\n async getCredential(query: Credential.CredentialQuery): Promise<Credential.ServiceCredential> {\n const credential = this.credentials.find((credential) => credential.service === query.service);\n if (!credential) {\n throw new Error(`Credential not found for service: ${query.service}`);\n }\n\n return credential;\n }\n}\n\n/**\n * Maps the request to include the given token in the Authorization header.\n */\nexport const withAuthorization = (token: string, kind?: 'Bearer' | 'Basic') =>\n HttpClient.mapRequest((request) => {\n const authorization = kind ? `${kind} ${token}` : token;\n return HttpClientRequest.setHeader(request, 'Authorization', authorization);\n });\n\nexport const configuredCredentialsLayer = (credentials: Credential.ServiceCredential[]) =>\n Layer.succeed(Credential.CredentialsService, new ConfiguredCredentialsService(credentials));\n\nexport const credentialsLayerConfig = (\n credentials: {\n service: string;\n apiKey: Config.Config<Redacted.Redacted<string>>;\n }[],\n) =>\n Layer.effect(\n Credential.CredentialsService,\n Effect.gen(function* () {\n const serviceCredentials = yield* Effect.forEach(credentials, ({ service, apiKey }) =>\n Effect.gen(function* () {\n return {\n service,\n apiKey: Redacted.value(yield* apiKey),\n };\n }),\n );\n\n return new ConfiguredCredentialsService(serviceCredentials);\n }),\n );\n\nexport const credentialsLayerFromDatabase = ({ caching = false }: { caching?: boolean } = {}) =>\n Layer.effect(\n Credential.CredentialsService,\n Effect.gen(function* () {\n const dbService = yield* Database.Service;\n const cache = new Map<string, Credential.ServiceCredential[]>();\n\n const queryCredentials = async (query: Credential.CredentialQuery): Promise<Credential.ServiceCredential[]> => {\n const cacheKey = JSON.stringify(query);\n if (caching && cache.has(cacheKey)) {\n return cache.get(cacheKey)!;\n }\n\n const accessTokens = await dbService.db.query(Query.type(AccessToken.AccessToken)).run();\n const credentials = accessTokens\n .filter((accessToken) => accessToken.source === query.service)\n .map((accessToken) => ({\n service: accessToken.source,\n apiKey: accessToken.token,\n }));\n\n if (caching) {\n cache.set(cacheKey, credentials);\n }\n\n return credentials;\n };\n\n return {\n getCredential: async (query) => {\n const credentials = await queryCredentials(query);\n if (credentials.length === 0) {\n throw new Error(`Credential not found for service: ${query.service}`);\n }\n\n return credentials[0];\n },\n queryCredentials: async (query) => {\n return queryCredentials(query);\n },\n };\n }),\n );\n", "//\n// Copyright 2025 DXOS.org\n//\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\n\nimport { type FunctionNotFoundError, Operation } from '@dxos/compute';\n\nexport class FunctionInvocationService extends Context.Tag('@dxos/functions/FunctionInvocationService')<\n FunctionInvocationService,\n {\n invokeFunction<I, O>(functionDef: Operation.Definition<I, O, any>, input: I): Effect.Effect<O>;\n\n resolveFunction(key: string): Effect.Effect<Operation.Definition.Any, FunctionNotFoundError>;\n }\n>() {\n static layerNotAvailable = Layer.succeed(FunctionInvocationService, {\n invokeFunction: () => Effect.die('FunctionInvocationService is not avaialble.'),\n resolveFunction: () => Effect.die('FunctionInvocationService is not available.'),\n });\n\n static invokeFunction = <I, O>(\n functionDef: Operation.Definition<I, O, any>,\n input: I,\n ): Effect.Effect<O, never, FunctionInvocationService> =>\n Effect.serviceFunctionEffect(FunctionInvocationService, (service) => service.invokeFunction)(functionDef, input);\n\n static resolveFunction = (\n key: string,\n ): Effect.Effect<Operation.Definition.Any, FunctionNotFoundError, FunctionInvocationService> =>\n Effect.serviceFunctionEffect(FunctionInvocationService, (service) => service.resolveFunction)(key);\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nexport { ContextQueueService, QueueService, feedServiceFromQueueServiceLayer } from '@dxos/echo-db';\n", "//\n// Copyright 2025 DXOS.org\n//\n\n/**\n * Goes into {@link Message['properties']}\n */\nexport const MESSAGE_PROPERTY_TOOL_CALL_ID = 'toolCallId' as const;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Obj } from '@dxos/echo';\n\n// TODO: use URL scheme for source?\nexport const FUNCTIONS_META_KEY = 'org.dxos.service.function';\n\nexport const FUNCTIONS_PRESET_META_KEY = 'org.dxos.service.function-preset';\n\n/**\n * NOTE: functionId is backend ID, not ECHO object id.\n */\nexport const getUserFunctionIdInMetadata = (meta: Obj.ReadonlyMeta) => {\n return meta.keys.find((key) => key.source === FUNCTIONS_META_KEY)?.id;\n};\n\n/**\n * NOTE: functionId is backend ID, not ECHO object id.\n * Must be called inside Obj.update() since it mutates the meta.\n */\nexport const setUserFunctionIdInMetadata = (meta: Obj.Meta, functionId: string) => {\n const key = meta.keys.find((key) => key.source === FUNCTIONS_META_KEY);\n if (key) {\n if (key.id !== functionId) {\n throw new Error('Metadata mismatch');\n }\n } else {\n meta.keys.push({ source: FUNCTIONS_META_KEY, id: functionId });\n }\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as AnthropicClient from '@effect/ai-anthropic/AnthropicClient';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { AiModelResolver, AiService, OpaqueToolkit } from '@dxos/ai';\nimport { AnthropicResolver } from '@dxos/ai/resolvers';\nimport {\n FunctionError,\n InvalidOperationInputError,\n InvalidOperationOutputError,\n Operation,\n OperationRegistry,\n Trace,\n} from '@dxos/compute';\nimport { LifecycleState, Resource } from '@dxos/context';\nimport { Database, Feed, JsonSchema, Ref, type Type } from '@dxos/echo';\nimport { createFeedServiceLayer, EchoClient, type EchoDatabaseImpl, type QueueFactory } from '@dxos/echo-db';\nimport { refFromEncodedReference } from '@dxos/echo/internal';\nimport { runAndForwardErrors } from '@dxos/effect';\nimport { assertState, failedInvariant, invariant } from '@dxos/invariant';\nimport { PublicKey, type SpaceId } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { EdgeFunctionEnv, ErrorCodec, type FunctionProtocol, type TraceProtocol } from '@dxos/protocols';\n\nimport { type FunctionServices } from '../sdk';\nimport {\n configuredCredentialsLayer,\n credentialsLayerFromDatabase,\n FunctionInvocationService,\n QueueService,\n} from '../services';\nimport { FunctionsAiHttpClient } from './functions-ai-http-client';\n\nexport interface FunctionWrappingOptions {\n /**\n * Additional types to register with the database.\n */\n types?: Type.AnyEntity[];\n\n /**\n * Toolkits to make available via the `OpaqueToolkitProvider`.\n */\n toolkits?: OpaqueToolkit.OpaqueToolkit[];\n}\n\n/**\n * Wraps a function handler made with `defineFunction` to a protocol that the functions-runtime expects.\n */\nexport const wrapFunctionHandler = (\n func: Operation.WithHandler<Operation.Definition.Any>,\n opts: FunctionWrappingOptions = {},\n): FunctionProtocol.Func => {\n if (!Operation.isOperationWithHandler(func)) {\n throw new TypeError('Expected operation with handler');\n }\n\n const serviceTags = func.services.map((service) => service.key);\n\n return {\n meta: {\n key: func.meta.key,\n name: func.meta.name,\n description: func.meta.description,\n inputSchema: JsonSchema.toJsonSchema(func.input),\n outputSchema: func.output === undefined ? undefined : JsonSchema.toJsonSchema(func.output),\n services: func.services.map((service) => service.key),\n },\n handler: async ({ data, context }) => {\n if (\n (serviceTags.includes(Database.Service.key) ||\n serviceTags.includes(QueueService.key) ||\n serviceTags.includes(Feed.FeedService.key)) &&\n (!context.services.dataService || !context.services.queryService)\n ) {\n throw new FunctionError({\n message: 'Services not provided: dataService, queryService',\n });\n }\n\n // eslint-disable-next-line no-useless-catch\n try {\n if (!SchemaAST.isAnyKeyword(func.input.ast)) {\n try {\n Schema.validateSync(func.input, { onExcessProperty: 'error' })(data);\n } catch (error: any) {\n throw new InvalidOperationInputError({\n message: `Operation input did not match schema (${func.meta.key}): ${error.message}`,\n cause: error,\n });\n }\n }\n\n await using funcContext = await new FunctionContext(context, opts).open();\n\n const types = [...(opts.types ?? []), ...(func.types ?? [])];\n if (types.length > 0) {\n invariant(funcContext.db, 'Database is required for functions with types');\n await funcContext.db.graph.schemaRegistry.register(types as Type.AnyEntity[]);\n }\n\n const dataWithDecodedRefs =\n funcContext.db && !SchemaAST.isAnyKeyword(func.input.ast)\n ? decodeRefsFromSchema(func.input.ast, data, funcContext.db)\n : data;\n\n let result: any = await func.handler(dataWithDecodedRefs);\n\n if (Effect.isEffect(result)) {\n result = await runAndForwardErrors(\n (result as Effect.Effect<unknown, unknown, FunctionServices>).pipe(\n Effect.orDie,\n Effect.provide(funcContext.createLayer()),\n ),\n );\n }\n\n if (func.output && !SchemaAST.isAnyKeyword(func.output.ast)) {\n try {\n Schema.validateSync(func.output, { onExcessProperty: 'error' })(result);\n } catch (error: any) {\n throw new InvalidOperationOutputError({\n message: `Operation output did not match schema (${func.meta.key}): ${error.message}`,\n cause: error,\n });\n }\n }\n\n return result;\n } catch (error) {\n // TODO(dmaretskyi): We might do error wrapping here and add extra context.\n throw error;\n }\n },\n };\n};\n\n/**\n * Container for services and context for a function.\n */\nclass FunctionContext extends Resource {\n readonly context: FunctionProtocol.Context;\n readonly client: EchoClient | undefined;\n db: EchoDatabaseImpl | undefined;\n queues: QueueFactory | undefined;\n readonly opts: FunctionWrappingOptions;\n\n constructor(context: FunctionProtocol.Context, opts: FunctionWrappingOptions) {\n super();\n this.context = context;\n this.opts = opts;\n if (context.services.dataService && context.services.queryService) {\n this.client = new EchoClient().connectToService({\n dataService: context.services.dataService,\n queryService: context.services.queryService,\n queueService: context.services.queueService,\n });\n }\n }\n\n override async _open() {\n await this.client?.open();\n this.db =\n this.client && this.context.spaceId\n ? this.client.constructDatabase({\n spaceId: this.context.spaceId ?? failedInvariant(),\n spaceKey: PublicKey.fromHex(this.context.spaceKey ?? failedInvariant('spaceKey missing in context')),\n reactiveSchemaQuery: false,\n preloadSchemaOnOpen: false,\n })\n : undefined;\n\n await this.db?.setSpaceRoot(this.context.spaceRootUrl ?? failedInvariant('spaceRootUrl missing in context'));\n await this.db?.open();\n this.queues =\n this.client && this.context.spaceId ? this.client.constructQueueFactory(this.context.spaceId) : undefined;\n }\n\n override async _close() {\n await this.db?.close();\n await this.client?.close();\n }\n\n createLayer(): Layer.Layer<FunctionServices> {\n assertState(this._lifecycleState === LifecycleState.OPEN, 'FunctionContext is not open');\n\n const dbLayer = this.db ? Database.layer(this.db) : Database.notAvailable;\n const queuesLayer = this.queues ? QueueService.layer(this.queues) : QueueService.notAvailable;\n const feedLayer = this.queues ? createFeedServiceLayer(this.queues) : Feed.notAvailable;\n const credentials = dbLayer\n ? credentialsLayerFromDatabase({ caching: true }).pipe(Layer.provide(dbLayer))\n : configuredCredentialsLayer([]);\n\n const aiLayer = this.context.services.functionsAiService\n ? InternalAiServiceLayer(this.context.services.functionsAiService)\n : AiService.notAvailable;\n\n const operationServiceLayer = this.context.services.functionsService\n ? makeOperationServiceLayer(this.context.services.functionsService)\n : unavailableOperationServiceLayer;\n\n const operationRegistryLayer = this.context.services.functionsService\n ? makeOperationRegistryLayer(this.context.services.functionsService, this.context.spaceId as SpaceId | undefined)\n : emptyOperationRegistryLayer;\n\n const traceWriterLayer = this.context.services.traceService\n ? makeTraceWriterLayer(this.context.services.traceService)\n : Trace.writerLayerNoop;\n\n log('Creating function context layer', {\n traceService: !!this.context.services.traceService,\n functionsService: !!this.context.services.functionsService,\n functionsAiService: !!this.context.services.functionsAiService,\n spaceId: this.context.spaceId,\n spaceRootUrl: this.context.spaceRootUrl,\n toolkits: this.opts.toolkits?.length ?? 0,\n types: this.opts.types?.length ?? 0,\n });\n\n return Layer.mergeAll(\n dbLayer,\n queuesLayer,\n feedLayer,\n credentials,\n operationServiceLayer,\n operationRegistryLayer,\n aiLayer,\n OpaqueToolkit.providerLayer(OpaqueToolkit.merge(...(this.opts.toolkits ?? []))),\n traceWriterLayer,\n\n // `FunctionInvocationService` is deprecated; new code should yield `Operation.Service`.\n // The cloudflare wrapper provides only the unavailable layer to satisfy the (still-present)\n // type union — handlers that yield it will die at invocation time.\n FunctionInvocationService.layerNotAvailable,\n );\n }\n}\n\n/**\n * Backs `Trace.TraceService` with the EDGE-provided `TraceService` so that operation\n * handlers can write trace events that are forwarded to the runtime's trace sink.\n */\nconst makeTraceWriterLayer = (traceService: TraceProtocol.TraceService): Layer.Layer<Trace.TraceService> =>\n Layer.succeed(Trace.TraceService, {\n write: (eventType, payload) => {\n log('Writing trace event', {\n eventType: eventType.key,\n });\n traceService.write([\n {\n key: eventType.key,\n isEphemeral: eventType.isEphemeral,\n data: payload,\n },\n ]);\n },\n });\n\n/**\n * AI service layer that proxies HTTP requests through the EDGE-provided `FunctionsAiService`.\n */\nconst InternalAiServiceLayer = (functionsAiService: EdgeFunctionEnv.FunctionsAiService) =>\n AiModelResolver.AiModelResolver.buildAiService.pipe(\n Layer.provide(\n AnthropicResolver.make().pipe(\n Layer.provide(\n AnthropicClient.layer({\n // Note: It doesn't matter what is base url here, it will be proxied to ai gateway in edge.\n apiUrl: 'http://internal/provider/anthropic',\n }).pipe(Layer.provide(FunctionsAiHttpClient.layer(functionsAiService))),\n ),\n ),\n ),\n );\n\n/**\n * Backs `Operation.Service` with the EDGE-provided `FunctionsService` so that operation\n * handlers can invoke other deployed operations remotely. The `deployedId` on the operation\n * definition is used as the routing key.\n */\nconst makeOperationServiceLayer = (\n functionsService: EdgeFunctionEnv.FunctionsService,\n): Layer.Layer<Operation.Service> => {\n const invokeRemote = async (\n op: Operation.Definition.Any,\n input: unknown,\n options?: Operation.InvokeOptions,\n ): Promise<{ data?: unknown; error?: Error }> => {\n invariant(op.meta.deployedId, `Operation '${op.meta.key}' has no deployedId; cannot invoke remotely.`);\n const result = await functionsService.invoke(op.meta.deployedId, input, {\n spaceId: options?.spaceId,\n });\n if (result._kind === 'success') {\n return { data: result.data };\n }\n return { error: ErrorCodec.decode(result.error) };\n };\n\n return Layer.succeed(Operation.Service, {\n invoke: ((op: Operation.Definition.Any, input: unknown, options?: Operation.InvokeOptions) =>\n Effect.tryPromise(() => invokeRemote(op, input, options)).pipe(\n Effect.orDie,\n Effect.flatMap((outcome) =>\n outcome.error ? Effect.die(outcome.error) : Effect.succeed(outcome.data as never),\n ),\n )) as Operation.OperationService['invoke'],\n schedule: ((op: Operation.Definition.Any, input: unknown) =>\n Effect.sync(() => {\n invariant(op.meta.deployedId, `Operation '${op.meta.key}' has no deployedId; cannot schedule remotely.`);\n // Fire and forget — schedule is intentionally non-awaiting.\n void functionsService.invoke(op.meta.deployedId, input).catch(() => {\n // Swallow errors — schedule is observability-only.\n });\n })) as Operation.OperationService['schedule'],\n invokePromise: ((op: Operation.Definition.Any, input: unknown, options?: Operation.InvokeOptions) =>\n invokeRemote(op, input, options).catch((error: unknown) => ({\n error: error instanceof Error ? error : new Error(String(error)),\n }))) as Operation.OperationService['invokePromise'],\n } satisfies Operation.OperationService);\n};\n\nconst unavailableOperationServiceLayer = Layer.succeed(Operation.Service, {\n invoke: () => Effect.die('Operation.Service is not available: missing functionsService in EDGE context.'),\n schedule: () => Effect.die('Operation.Service is not available: missing functionsService in EDGE context.'),\n invokePromise: async () => ({\n error: new Error('Operation.Service is not available: missing functionsService in EDGE context.'),\n }),\n} as Operation.OperationService);\n\n/**\n * Backs `OperationRegistry.Service` with the EDGE-provided `FunctionsService.query`. Returns\n * the first persistent operation matching the requested key, or `Option.none()` when not found.\n */\nconst makeOperationRegistryLayer = (\n functionsService: EdgeFunctionEnv.FunctionsService,\n spaceId: SpaceId | undefined,\n): Layer.Layer<OperationRegistry.Service> =>\n Layer.succeed(OperationRegistry.Service, {\n resolve: (key: string) =>\n Effect.gen(function* () {\n const records = yield* Effect.tryPromise(() => functionsService.query({ spaceId })).pipe(Effect.orDie);\n const match = (records as Operation.PersistentOperation[]).find((record) => record.key === key);\n return match ? Option.some(Operation.deserialize(match)) : Option.none();\n }),\n });\n\nconst emptyOperationRegistryLayer = Layer.succeed(OperationRegistry.Service, {\n resolve: () => Effect.succeed(Option.none()),\n});\n\nconst decodeRefsFromSchema = (ast: SchemaAST.AST, value: unknown, db: EchoDatabaseImpl): unknown => {\n if (value == null) {\n return value;\n }\n\n const encoded = SchemaAST.encodedBoundAST(ast);\n if (Ref.isRefType(encoded)) {\n if (Ref.isRef(value)) {\n return value;\n }\n\n if (typeof value === 'object' && value !== null && typeof (value as any)['/'] === 'string') {\n const resolver = db.graph.createRefResolver({ context: { space: db.spaceId } });\n return refFromEncodedReference(value as any, resolver);\n }\n\n return value;\n }\n\n switch (encoded._tag) {\n case 'TypeLiteral': {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return value;\n }\n const result: Record<string, unknown> = { ...(value as any) };\n for (const prop of SchemaAST.getPropertySignatures(encoded)) {\n const key = prop.name.toString();\n if (key in result) {\n result[key] = decodeRefsFromSchema(prop.type, (result as any)[key], db);\n }\n }\n return result;\n }\n\n case 'TupleType': {\n if (!Array.isArray(value)) {\n return value;\n }\n\n // For arrays, effect uses TupleType with empty elements and a single rest element.\n if (encoded.elements.length === 0 && encoded.rest.length === 1) {\n const elementType = encoded.rest[0].type;\n return (value as unknown[]).map((item) => decodeRefsFromSchema(elementType, item, db));\n }\n\n return value;\n }\n\n case 'Union': {\n // Optional values are represented as union with undefined.\n const nonUndefined = encoded.types.filter((t) => !SchemaAST.isUndefinedKeyword(t));\n if (nonUndefined.length === 1) {\n return decodeRefsFromSchema(nonUndefined[0], value, db);\n }\n\n // For other unions we can't safely pick a branch without validating.\n return value;\n }\n\n case 'Suspend': {\n return decodeRefsFromSchema(encoded.f(), value, db);\n }\n\n case 'Refinement': {\n return decodeRefsFromSchema(encoded.from, value, db);\n }\n\n default: {\n return value;\n }\n }\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Headers from '@effect/platform/Headers';\nimport * as HttpClient from '@effect/platform/HttpClient';\nimport * as HttpClientError from '@effect/platform/HttpClientError';\nimport * as HttpClientResponse from '@effect/platform/HttpClientResponse';\nimport * as Effect from 'effect/Effect';\nimport * as FiberRef from 'effect/FiberRef';\nimport * as Layer from 'effect/Layer';\nimport * as Stream from 'effect/Stream';\n\nimport { FunctionsAiMemoizationMissError, FunctionsAiUpstreamError } from '@dxos/compute';\nimport { log } from '@dxos/log';\nimport { type EdgeFunctionEnv, ErrorCodec } from '@dxos/protocols';\n\n/**\n * Copy pasted from https://github.com/Effect-TS/effect/blob/main/packages/platform/src/internal/fetchHttpClient.ts\n */\nexport const requestInitTagKey = '@effect/platform/FetchHttpClient/FetchOptions';\n\n/**\n * Shape of the JSON error envelope emitted by the upstream AI gateway (and by the memoization\n * layer that fronts it in test environments).\n *\n * @example\n * ```json\n * {\n * \"type\": \"error\",\n * \"error\": {\n * \"type\": \"memoization_miss\",\n * \"message\": \"No memoized Anthropic conversation found for ...\",\n * \"cacheKey\": \"114dae3db8fe60...\"\n * }\n * }\n * ```\n */\ntype UpstreamErrorEnvelope = {\n type?: string;\n error?: {\n type?: string;\n message?: string;\n cacheKey?: string;\n };\n};\n\nexport class FunctionsAiHttpClient {\n static make = (service: EdgeFunctionEnv.FunctionsAiService) =>\n HttpClient.make((request, url, signal, fiber) => {\n const context = fiber.getFiberRef(FiberRef.currentContext);\n const options: RequestInit = context.unsafeMap.get(requestInitTagKey) ?? {};\n const headers = options.headers\n ? Headers.merge(Headers.fromInput(options.headers), request.headers)\n : request.headers;\n\n const send = (body: BodyInit | undefined) =>\n Effect.tryPromise({\n try: () =>\n service.fetch(\n new Request(url, {\n ...options,\n method: request.method,\n headers,\n body,\n // Note: Don't pass signal - it can't be serialized through RPC\n }),\n ),\n catch: (cause) => {\n log.error('Failed to fetch', { errorSerialized: ErrorCodec.encode(cause as Error) });\n return new HttpClientError.RequestError({\n request,\n reason: 'Transport',\n cause,\n });\n },\n }).pipe(\n Effect.flatMap((response) =>\n // Inspect the body before handing the response to `@effect/ai` so that structured\n // upstream errors surface as typed defects (`FunctionsAiUpstreamError` and friends)\n // rather than as the generic `HttpResponseError` from `@effect/ai/AiError`.\n Effect.flatMap(\n Effect.promise(() => parseUpstreamError(response)),\n (typedError) =>\n typedError ? Effect.die(typedError) : Effect.succeed(HttpClientResponse.fromWeb(request, response)),\n ),\n ),\n );\n\n switch (request.body._tag) {\n case 'Raw':\n case 'Uint8Array':\n return send(request.body.body as any);\n case 'FormData':\n return send(request.body.formData);\n case 'Stream':\n return Stream.toReadableStreamEffect(request.body.stream).pipe(Effect.flatMap(send));\n }\n\n return send(undefined);\n });\n\n static layer = (service: EdgeFunctionEnv.FunctionsAiService) =>\n Layer.succeed(HttpClient.HttpClient, FunctionsAiHttpClient.make(service));\n}\n\n/**\n * Returns a typed error if the response is a non-2xx JSON payload matching\n * {@link UpstreamErrorEnvelope}; otherwise returns `undefined` and the response is forwarded\n * unchanged.\n */\nconst parseUpstreamError = async (response: Response): Promise<Error | undefined> => {\n if (response.ok) {\n return undefined;\n }\n const contentType = response.headers.get('content-type') ?? '';\n if (!contentType.toLowerCase().includes('application/json')) {\n return undefined;\n }\n let body: UpstreamErrorEnvelope;\n try {\n body = (await response.clone().json()) as UpstreamErrorEnvelope;\n } catch {\n return undefined;\n }\n if (!body || body.type !== 'error' || typeof body.error !== 'object' || body.error === null) {\n return undefined;\n }\n const inner = body.error;\n const message = inner.message ?? `Upstream AI service responded with HTTP ${response.status}`;\n if (inner.type === 'memoization_miss' && typeof inner.cacheKey === 'string') {\n return new FunctionsAiMemoizationMissError({\n message,\n context: { cacheKey: inner.cacheKey, status: response.status },\n });\n }\n return new FunctionsAiUpstreamError({\n message,\n context: { type: inner.type, status: response.status, ...(inner.cacheKey ? { cacheKey: inner.cacheKey } : {}) },\n });\n};\n"],
5
+ "mappings": ";AAIA,YAAYA,gBAAgB;AAC5B,YAAYC,uBAAuB;AAGnC,YAAYC,YAAY;AACxB,YAAYC,WAAW;AACvB,YAAYC,cAAc;AAE1B,SAASC,kBAAkB;AAC3B,SAASC,aAAa;AACtB,SAASC,gBAAgB;AACzB,SAASC,mBAAmB;AAErB,IAAMC,+BAAN,MAAMA;;EACX,YAA6BC,cAA8C,CAAA,GAAI;SAAlDA,cAAAA;EAAmD;EAEhFC,eAAeD,aAA2E;AACxF,SAAKA,YAAYE,KAAI,GAAIF,WAAAA;AACzB,WAAO;EACT;EAEA,MAAMG,iBAAiBC,OAA4E;AACjG,WAAO,KAAKJ,YAAYK,OAAO,CAACC,eAAeA,WAAWC,YAAYH,MAAMG,OAAO;EACrF;EAEA,MAAMC,cAAcJ,OAA0E;AAC5F,UAAME,aAAa,KAAKN,YAAYS,KAAK,CAACH,gBAAeA,YAAWC,YAAYH,MAAMG,OAAO;AAC7F,QAAI,CAACD,YAAY;AACf,YAAM,IAAII,MAAM,qCAAqCN,MAAMG,OAAO,EAAE;IACtE;AAEA,WAAOD;EACT;AACF;AAKO,IAAMK,oBAAoB,CAACC,OAAeC,SACpCC,sBAAW,CAACC,YAAAA;AACrB,QAAMC,gBAAgBH,OAAO,GAAGA,IAAAA,IAAQD,KAAAA,KAAUA;AAClD,SAAyBK,4BAAUF,SAAS,iBAAiBC,aAAAA;AAC/D,CAAA;AAEK,IAAME,6BAA6B,CAAClB,gBACnCmB,cAAQxB,WAAWyB,oBAAoB,IAAIrB,6BAA6BC,WAA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AA,GAAA,IAAA,qBAAA,KAAA,MAAA,OAAA,GAAA,GAAA,EAAA;QACF;MACA;AACF,aAAA;IAEA;SAAkB;UAEd,CAAA,MAAOP,QAAAA,MAAAA,GAAAA;AACT,eAAAA;MAEA;UAEE,QAAMQ,SAAAA,WAAsBC,KAAK,QAAO,KAAA,WAAA,GAAA;AACxC,cAAA,cAAiCC,QAASH,KAAAA,CAAAA,EAAAA;AAC5C,eAAAP,OAAA,IAAA,CAAA,SAAA,qBAAA,aAAA,MAAA,EAAA,CAAA;MAEA;AACF,aAAAA;IAEA;SAAc;AAGZ,YAAIW,eAAarC,QAAW,MAAG,OAAA,CAAA,MAAA,CAAA,6BAAA,CAAA,CAAA;UAC7B,aAAOiC,WAAAA,GAAAA;AACT,eAAA,qBAAA,aAAA,CAAA,GAAAP,QAAA,EAAA;MAEA;AAEF,aAAAA;IAEA;SAAgB;AAEhB,aAAA,qBAAA,QAAA,EAAA,GAAAA,QAAA,EAAA;IAEA;SAAmB;AAEnB,aAAA,qBAAA,QAAA,MAAAA,QAAA,EAAA;IAEA;;AAEA,aAAAA;IACF;EACF;;",
6
+ "names": ["HttpClient", "HttpClientRequest", "Effect", "Layer", "Redacted", "Credential", "Query", "Database", "AccessToken", "ConfiguredCredentialsService", "credentials", "addCredentials", "push", "queryCredentials", "query", "filter", "credential", "service", "getCredential", "find", "Error", "withAuthorization", "token", "kind", "mapRequest", "request", "authorization", "setHeader", "configuredCredentialsLayer", "succeed", "CredentialsService", "credentialsLayerConfig", "effect", "gen", "serviceCredentials", "forEach", "apiKey", "value", "credentialsLayerFromDatabase", "caching", "dbService", "Service", "cache", "Map", "cacheKey", "JSON", "stringify", "has", "get", "accessTokens", "db", "type", "run", "accessToken", "source", "map", "set", "length", "Context", "Effect", "Layer", "FunctionInvocationService", "Tag", "layerNotAvailable", "succeed", "invokeFunction", "die", "resolveFunction", "functionDef", "input", "serviceFunctionEffect", "service", "key", "ContextQueueService", "QueueService", "feedServiceFromQueueServiceLayer", "MESSAGE_PROPERTY_TOOL_CALL_ID", "FUNCTIONS_META_KEY", "FUNCTIONS_PRESET_META_KEY", "getUserFunctionIdInMetadata", "meta", "keys", "find", "key", "source", "id", "setUserFunctionIdInMetadata", "functionId", "Error", "push", "Effect", "Layer", "Option", "Schema", "SchemaAST", "AiModelResolver", "AiService", "AnthropicResolver", "FunctionError", "InvalidOperationInputError", "LifecycleState", "Database", "JsonSchema", "createFeedServiceLayer", "EchoClient", "refFromEncodedReference", "runAndForwardErrors", "assertState", "failedInvariant", "PublicKey", "log", "ErrorCodec", "configuredCredentialsLayer", "Headers", "HttpClient", "HttpClientError", "HttpClientResponse", "Effect", "FiberRef", "Layer", "Stream", "FunctionsAiMemoizationMissError", "FunctionsAiUpstreamError", "log", "ErrorCodec", "make", "getFiberRef", "options", "unsafeMap", "get", "requestInitTagKey", "headers", "merge", "fromInput", "send", "body", "tryPromise", "service", "Request", "method", "request", "cause", "errorSerialized", "RequestError", "reason", "formData", "toReadableStreamEffect", "undefined", "layer", "contentType", "inner", "message", "context", "status", "cacheKey", "__dxlog_file", "Operation", "isOperationWithHandler", "func", "TypeError", "meta", "key", "name", "description", "inputSchema", "JsonSchema", "outputSchema", "output", "undefined", "services", "service", "handler", "serviceTags", "includes", "Database", "FunctionError", "message", "Schema", "onExcessProperty", "data", "error", "InvalidOperationInputError", "cause", "types", "invariant", "funcContext", "graph", "result", "dataWithDecodedRefs", "Effect", "isEffect", "runAndForwardErrors", "InvalidOperationOutputError", "context", "client", "db", "queues", "opts", "connectToService", "dataService", "queryService", "queueService", "spaceId", "failedInvariant", "spaceKey", "PublicKey", "fromHex", "reactiveSchemaQuery", "preloadSchemaOnOpen", "open", "close", "createLayer", "assertState", "dbLayer", "layer", "queuesLayer", "QueueService", "feedLayer", "createFeedServiceLayer", "notAvailable", "credentials", "credentialsLayerFromDatabase", "caching", "pipe", "Layer", "aiLayer", "InternalAiServiceLayer", "operationServiceLayer", "functionsService", "makeOperationServiceLayer", "operationRegistryLayer", "makeOperationRegistryLayer", "traceWriterLayer", "traceService", "makeTraceWriterLayer", "Trace", "writerLayerNoop", "log", "functionsAiService", "spaceRootUrl", "toolkits", "length", "mergeAll", "write", "payload", "eventType", "isEphemeral", "invokeRemote", "input", "options", "deployedId", "op", "ErrorCodec", "schedule", "invokePromise", "Error", "String", "invoke", "die", "resolve", "records", "tryPromise", "match", "find", "some", "deserialize", "none", "value", "Ref", "encoded", "resolver", "createRefResolver", "space", "toString", "decodeRefsFromSchema", "elementType", "rest", "item", "nonUndefined"]
7
+ }
@@ -0,0 +1 @@
1
+ {"inputs":{"src/sdk.ts":{"bytes":2251,"imports":[],"format":"esm"},"src/services/credentials.ts":{"bytes":13050,"imports":[{"path":"@effect/platform/HttpClient","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClientRequest","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Redacted","kind":"import-statement","external":true},{"path":"@dxos/compute","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/types","kind":"import-statement","external":true}],"format":"esm"},"src/services/function-invocation-service.ts":{"bytes":3741,"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true}],"format":"esm"},"src/services/queues.ts":{"bytes":693,"imports":[{"path":"@dxos/echo-db","kind":"import-statement","external":true}],"format":"esm"},"src/services/tracing.ts":{"bytes":662,"imports":[],"format":"esm"},"src/services/index.ts":{"bytes":823,"imports":[{"path":"src/services/credentials.ts","kind":"import-statement","original":"./credentials"},{"path":"src/services/function-invocation-service.ts","kind":"import-statement","original":"./function-invocation-service"},{"path":"src/services/queues.ts","kind":"import-statement","original":"./queues"},{"path":"src/services/tracing.ts","kind":"import-statement","original":"./tracing"}],"format":"esm"},"src/types/url.ts":{"bytes":3289,"imports":[],"format":"esm"},"src/types/index.ts":{"bytes":363,"imports":[{"path":"src/types/url.ts","kind":"import-statement","original":"./url"}],"format":"esm"},"src/protocol/functions-ai-http-client.ts":{"bytes":15950,"imports":[{"path":"@effect/platform/Headers","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClient","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClientError","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClientResponse","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/FiberRef","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"@dxos/compute","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true}],"format":"esm"},"src/protocol/protocol.ts":{"bytes":57388,"imports":[{"path":"@effect/ai-anthropic/AnthropicClient","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"effect/SchemaAST","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/ai/resolvers","kind":"import-statement","external":true},{"path":"@dxos/compute","kind":"import-statement","external":true},{"path":"@dxos/context","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/internal","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"src/services/index.ts","kind":"import-statement","original":"../services"},{"path":"src/protocol/functions-ai-http-client.ts","kind":"import-statement","original":"./functions-ai-http-client"}],"format":"esm"},"src/protocol/index.ts":{"bytes":376,"imports":[{"path":"src/protocol/protocol.ts","kind":"import-statement","original":"./protocol"}],"format":"esm"},"src/index.ts":{"bytes":620,"imports":[{"path":"src/sdk.ts","kind":"import-statement","original":"./sdk"},{"path":"src/services/index.ts","kind":"import-statement","original":"./services"},{"path":"src/types/index.ts","kind":"import-statement","original":"./types"},{"path":"src/protocol/index.ts","kind":"import-statement","original":"./protocol"}],"format":"esm"}},"outputs":{"dist/lib/neutral/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":44305},"dist/lib/neutral/index.mjs":{"imports":[{"path":"@effect/platform/HttpClient","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClientRequest","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Redacted","kind":"import-statement","external":true},{"path":"@dxos/compute","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/echo","kind":"import-statement","external":true},{"path":"@dxos/types","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@effect/ai-anthropic/AnthropicClient","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"effect/SchemaAST","kind":"import-statement","external":true},{"path":"@dxos/ai","kind":"import-statement","external":true},{"path":"@dxos/ai/resolvers","kind":"import-statement","external":true},{"path":"@dxos/compute","kind":"import-statement","external":true},{"path":"@dxos/context","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/internal","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true},{"path":"@effect/platform/Headers","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClient","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClientError","kind":"import-statement","external":true},{"path":"@effect/platform/HttpClientResponse","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/FiberRef","kind":"import-statement","external":true},{"path":"effect/Layer","kind":"import-statement","external":true},{"path":"effect/Stream","kind":"import-statement","external":true},{"path":"@dxos/compute","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/protocols","kind":"import-statement","external":true}],"exports":["ConfiguredCredentialsService","ContextQueueService","FUNCTIONS_META_KEY","FUNCTIONS_PRESET_META_KEY","FunctionInvocationService","MESSAGE_PROPERTY_TOOL_CALL_ID","QueueService","configuredCredentialsLayer","credentialsLayerConfig","credentialsLayerFromDatabase","feedServiceFromQueueServiceLayer","getUserFunctionIdInMetadata","setUserFunctionIdInMetadata","withAuthorization","wrapFunctionHandler"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0},"src/services/credentials.ts":{"bytesInOutput":2936},"src/services/index.ts":{"bytesInOutput":0},"src/services/function-invocation-service.ts":{"bytesInOutput":818},"src/services/queues.ts":{"bytesInOutput":101},"src/services/tracing.ts":{"bytesInOutput":50},"src/types/url.ts":{"bytesInOutput":576},"src/protocol/protocol.ts":{"bytesInOutput":15346},"src/protocol/functions-ai-http-client.ts":{"bytesInOutput":3695}},"bytes":24240}}}
@@ -1,11 +1,5 @@
1
- export * from './errors';
2
- export * from './handler';
3
- export * from './schema';
4
- export * from './trace';
5
- export * from './types';
6
- export * from './url';
7
- export * from './triggers';
1
+ export * from './sdk';
8
2
  export * from './services';
9
- export * from './executor';
10
- export * as exampleFunctions from './examples';
3
+ export * from './types';
4
+ export * from './protocol';
11
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,OAAO,KAAK,gBAAgB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
@@ -0,0 +1,12 @@
1
+ import * as HttpClient from '@effect/platform/HttpClient';
2
+ import * as Layer from 'effect/Layer';
3
+ import { type EdgeFunctionEnv } from '@dxos/protocols';
4
+ /**
5
+ * Copy pasted from https://github.com/Effect-TS/effect/blob/main/packages/platform/src/internal/fetchHttpClient.ts
6
+ */
7
+ export declare const requestInitTagKey = "@effect/platform/FetchHttpClient/FetchOptions";
8
+ export declare class FunctionsAiHttpClient {
9
+ static make: (service: EdgeFunctionEnv.FunctionsAiService) => HttpClient.HttpClient;
10
+ static layer: (service: EdgeFunctionEnv.FunctionsAiService) => Layer.Layer<HttpClient.HttpClient, never, never>;
11
+ }
12
+ //# sourceMappingURL=functions-ai-http-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions-ai-http-client.d.ts","sourceRoot":"","sources":["../../../../src/protocol/functions-ai-http-client.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,UAAU,MAAM,6BAA6B,CAAC;AAK1D,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAKtC,OAAO,EAAE,KAAK,eAAe,EAAc,MAAM,iBAAiB,CAAC;AAEnE;;GAEG;AACH,eAAO,MAAM,iBAAiB,kDAAkD,CAAC;AA2BjF,qBAAa,qBAAqB;IAChC,MAAM,CAAC,IAAI,YAAa,eAAe,CAAC,kBAAkB,2BAoDrD;IAEL,MAAM,CAAC,KAAK,YAAa,eAAe,CAAC,kBAAkB,sDACiB;CAC7E"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=functions-ai-http-client.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions-ai-http-client.test.d.ts","sourceRoot":"","sources":["../../../../src/protocol/functions-ai-http-client.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export * from './protocol';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/protocol/index.ts"],"names":[],"mappings":"AAIA,cAAc,YAAY,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { OpaqueToolkit } from '@dxos/ai';
2
+ import { Operation } from '@dxos/compute';
3
+ import { type Type } from '@dxos/echo';
4
+ import { type FunctionProtocol } from '@dxos/protocols';
5
+ export interface FunctionWrappingOptions {
6
+ /**
7
+ * Additional types to register with the database.
8
+ */
9
+ types?: Type.AnyEntity[];
10
+ /**
11
+ * Toolkits to make available via the `OpaqueToolkitProvider`.
12
+ */
13
+ toolkits?: OpaqueToolkit.OpaqueToolkit[];
14
+ }
15
+ /**
16
+ * Wraps a function handler made with `defineFunction` to a protocol that the functions-runtime expects.
17
+ */
18
+ export declare const wrapFunctionHandler: (func: Operation.WithHandler<Operation.Definition.Any>, opts?: FunctionWrappingOptions) => FunctionProtocol.Func;
19
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../../src/protocol/protocol.ts"],"names":[],"mappings":"AAWA,OAAO,EAA8B,aAAa,EAAE,MAAM,UAAU,CAAC;AAErE,OAAO,EAIL,SAAS,EAGV,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAmC,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAOxE,OAAO,EAA+B,KAAK,gBAAgB,EAAsB,MAAM,iBAAiB,CAAC;AAWzG,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,KAAK,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,EAAE,aAAa,CAAC,aAAa,EAAE,CAAC;CAC1C;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,SACxB,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,SAC/C,uBAAuB,KAC5B,gBAAgB,CAAC,IAmFnB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=protocol.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.test.d.ts","sourceRoot":"","sources":["../../../../src/protocol/protocol.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import { type AiService } from '@dxos/ai';
2
+ import { type Credential, type Operation, type Trace } from '@dxos/compute';
3
+ import { type Database, type Feed } from '@dxos/echo';
4
+ import { type FunctionInvocationService, type QueueService } from './services';
5
+ /**
6
+ * Services that are available to invoked functions.
7
+ * @deprecated
8
+ */
9
+ export type FunctionServices = AiService.AiService | Credential.CredentialsService | Database.Service | QueueService | Feed.FeedService | Trace.TraceService | FunctionInvocationService | Operation.Service;
10
+ //# sourceMappingURL=sdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/sdk.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,KAAK,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAEtD,OAAO,EAAE,KAAK,yBAAyB,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAO/E;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GACxB,SAAS,CAAC,SAAS,GACnB,UAAU,CAAC,kBAAkB,GAC7B,QAAQ,CAAC,OAAO,GAEhB,YAAY,GACZ,IAAI,CAAC,WAAW,GAChB,KAAK,CAAC,YAAY,GAGlB,yBAAyB,GACzB,SAAS,CAAC,OAAO,CAAC"}
@@ -1,44 +1,27 @@
1
- import { HttpClient } from '@effect/platform';
2
- import { type Config, Context, Effect, Layer, Redacted } from 'effect';
3
- import { DatabaseService } from './database';
4
- export type CredentialQuery = {
5
- service?: string;
6
- };
7
- export type ServiceCredential = {
8
- service: string;
9
- apiKey?: string;
10
- };
11
- declare const CredentialsService_base: Context.TagClass<CredentialsService, "@dxos/functions/CredentialsService", {
12
- /**
13
- * Query all.
14
- */
15
- queryCredentials: (query: CredentialQuery) => Promise<ServiceCredential[]>;
16
- /**
17
- * Get a single credential.
18
- * @throws {Error} If no credential is found.
19
- */
20
- getCredential: (query: CredentialQuery) => Promise<ServiceCredential>;
21
- }>;
22
- export declare class CredentialsService extends CredentialsService_base {
23
- static getCredential: (query: CredentialQuery) => Effect.Effect<ServiceCredential, never, CredentialsService>;
24
- static getApiKey: (query: CredentialQuery) => Effect.Effect<Redacted.Redacted<string>, never, CredentialsService>;
25
- static configuredLayer: (credentials: ServiceCredential[]) => Layer.Layer<CredentialsService, never, never>;
26
- static layerConfig: (credentials: {
27
- service: string;
28
- apiKey: Config.Config<Redacted.Redacted<string>>;
29
- }[]) => Layer.Layer<CredentialsService, import("effect/ConfigError").ConfigError, never>;
30
- static layerFromDatabase: () => Layer.Layer<CredentialsService, never, DatabaseService>;
31
- }
32
- export declare class ConfiguredCredentialsService implements Context.Tag.Service<CredentialsService> {
1
+ import * as HttpClient from '@effect/platform/HttpClient';
2
+ import type * as Config from 'effect/Config';
3
+ import * as Context from 'effect/Context';
4
+ import * as Layer from 'effect/Layer';
5
+ import * as Redacted from 'effect/Redacted';
6
+ import { Credential } from '@dxos/compute';
7
+ import { Database } from '@dxos/echo';
8
+ export declare class ConfiguredCredentialsService implements Context.Tag.Service<Credential.CredentialsService> {
33
9
  private readonly credentials;
34
- constructor(credentials?: ServiceCredential[]);
35
- addCredentials(credentials: ServiceCredential[]): ConfiguredCredentialsService;
36
- queryCredentials(query: CredentialQuery): Promise<ServiceCredential[]>;
37
- getCredential(query: CredentialQuery): Promise<ServiceCredential>;
10
+ constructor(credentials?: Credential.ServiceCredential[]);
11
+ addCredentials(credentials: Credential.ServiceCredential[]): ConfiguredCredentialsService;
12
+ queryCredentials(query: Credential.CredentialQuery): Promise<Credential.ServiceCredential[]>;
13
+ getCredential(query: Credential.CredentialQuery): Promise<Credential.ServiceCredential>;
38
14
  }
39
15
  /**
40
- * Maps the request to include the API key from the credential.
16
+ * Maps the request to include the given token in the Authorization header.
41
17
  */
42
- export declare const withAuthorization: (query: CredentialQuery, kind?: "Bearer" | "Basic") => <E, R>(self: HttpClient.HttpClient.With<E, R>) => HttpClient.HttpClient.With<E, CredentialsService | R>;
43
- export {};
18
+ export declare const withAuthorization: (token: string, kind?: 'Bearer' | 'Basic') => <E, R>(self: HttpClient.HttpClient.With<E, R>) => HttpClient.HttpClient.With<E, R>;
19
+ export declare const configuredCredentialsLayer: (credentials: Credential.ServiceCredential[]) => Layer.Layer<Credential.CredentialsService, never, never>;
20
+ export declare const credentialsLayerConfig: (credentials: {
21
+ service: string;
22
+ apiKey: Config.Config<Redacted.Redacted<string>>;
23
+ }[]) => Layer.Layer<Credential.CredentialsService, import("effect/ConfigError").ConfigError, never>;
24
+ export declare const credentialsLayerFromDatabase: ({ caching }?: {
25
+ caching?: boolean;
26
+ }) => Layer.Layer<Credential.CredentialsService, never, Database.Service>;
44
27
  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CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAEjG;IAEK,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAO5F;CACF;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,UAAW,MAAM,SAAS,QAAQ,GAAG,OAAO,uFAItE,CAAC;AAEL,eAAO,MAAM,0BAA0B,gBAAiB,UAAU,CAAC,iBAAiB,EAAE,6DACO,CAAC;AAE9F,eAAO,MAAM,sBAAsB,gBACpB;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;CAClD,EAAE,gGAgBF,CAAC;AAEJ,eAAO,MAAM,4BAA4B,iBAAyB;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,wEA0CpF,CAAC"}
@@ -0,0 +1,15 @@
1
+ import * as Context from 'effect/Context';
2
+ import * as Effect from 'effect/Effect';
3
+ import * as Layer from 'effect/Layer';
4
+ import { type FunctionNotFoundError, Operation } from '@dxos/compute';
5
+ declare const FunctionInvocationService_base: Context.TagClass<FunctionInvocationService, "@dxos/functions/FunctionInvocationService", {
6
+ invokeFunction<I, O>(functionDef: Operation.Definition<I, O, any>, input: I): Effect.Effect<O>;
7
+ resolveFunction(key: string): Effect.Effect<Operation.Definition.Any, FunctionNotFoundError>;
8
+ }>;
9
+ export declare class FunctionInvocationService extends FunctionInvocationService_base {
10
+ static layerNotAvailable: Layer.Layer<FunctionInvocationService, never, never>;
11
+ static invokeFunction: <I, O>(functionDef: Operation.Definition<I, O, any>, input: I) => Effect.Effect<O, never, FunctionInvocationService>;
12
+ static resolveFunction: (key: string) => Effect.Effect<Operation.Definition.Any, FunctionNotFoundError, FunctionInvocationService>;
13
+ }
14
+ export {};
15
+ //# sourceMappingURL=function-invocation-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function-invocation-service.d.ts","sourceRoot":"","sources":["../../../../src/services/function-invocation-service.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,KAAK,qBAAqB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;;mBAKnD,CAAC,EAAE,CAAC,eAAe,SAAS,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;yBAEzE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,qBAAqB,CAAC;;AALhG,qBAAa,yBAA0B,SAAQ,8BAO5C;IACD,MAAM,CAAC,iBAAiB,uDAGrB;IAEH,MAAM,CAAC,cAAc,GAAI,CAAC,EAAE,CAAC,eACd,SAAS,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,SACrC,CAAC,KACP,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,yBAAyB,CAAC,CAC8D;IAEnH,MAAM,CAAC,eAAe,QACf,MAAM,KACV,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,qBAAqB,EAAE,yBAAyB,CAAC,CACS;CACtG"}
@@ -1,9 +1,5 @@
1
- export * from './database';
2
- export * from './queues';
3
- export * from './service-container';
4
1
  export * from './credentials';
5
- export * from './tracing';
6
- export * from './event-logger';
7
- export * from './remote-function-execution-service';
8
- export * from './local-function-execution';
2
+ export * from './function-invocation-service';
3
+ export * from './queues';
4
+ export { MESSAGE_PROPERTY_TOOL_CALL_ID } from './tracing';
9
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/index.ts"],"names":[],"mappings":"AAIA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qCAAqC,CAAC;AACpD,cAAc,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/index.ts"],"names":[],"mappings":"AAIA,cAAc,eAAe,CAAC;AAC9B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,6BAA6B,EAAE,MAAM,WAAW,CAAC"}
@@ -1,45 +1,2 @@
1
- import { Context, Effect, Layer } from 'effect';
2
- import type { Obj, Relation } from '@dxos/echo';
3
- import type { Queue, QueueAPI, QueueFactory } from '@dxos/echo-db';
4
- import type { DXN, QueueSubspaceTag } from '@dxos/keys';
5
- declare const QueueService_base: Context.TagClass<QueueService, "@dxos/functions/QueueService", {
6
- /**
7
- * API to access the queues.
8
- */
9
- readonly queues: QueueAPI;
10
- /**
11
- * The queue that is used to store the context of the current research.
12
- * @deprecated Use `ContextQueueService` instead.
13
- */
14
- readonly queue: Queue | undefined;
15
- }>;
16
- /**
17
- * Gives access to all queues.
18
- */
19
- export declare class QueueService extends QueueService_base {
20
- static notAvailable: Layer.Layer<QueueService, never, never>;
21
- static make: (queues: QueueFactory, queue?: Queue) => Context.Tag.Service<QueueService>;
22
- static layer: (queues: QueueFactory, queue?: Queue) => Layer.Layer<QueueService>;
23
- /**
24
- * Gets a queue by its DXN.
25
- */
26
- static getQueue: <T extends Obj.Any | Relation.Any = Obj.Any | Relation.Any>(dxn: DXN) => Effect.Effect<Queue<T>, never, QueueService>;
27
- /**
28
- * Creates a new queue.
29
- */
30
- static createQueue: <T extends Obj.Any | Relation.Any = Obj.Any | Relation.Any>(options?: {
31
- subspaceTag?: QueueSubspaceTag;
32
- }) => Effect.Effect<Queue<T>, never, QueueService>;
33
- static append: <T extends Obj.Any | Relation.Any = Obj.Any | Relation.Any>(queue: Queue<T>, objects: T[]) => Effect.Effect<void>;
34
- }
35
- declare const ContextQueueService_base: Context.TagClass<ContextQueueService, "@dxos/functions/ContextQueueService", {
36
- readonly queue: Queue;
37
- }>;
38
- /**
39
- * Gives access to a specific queue passed as a context.
40
- */
41
- export declare class ContextQueueService extends ContextQueueService_base {
42
- static layer: (queue: Queue) => Layer.Layer<ContextQueueService, never, never>;
43
- }
44
- export {};
1
+ export { ContextQueueService, QueueService, feedServiceFromQueueServiceLayer } from '@dxos/echo-db';
45
2
  //# sourceMappingURL=queues.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"queues.d.ts","sourceRoot":"","sources":["../../../../src/services/queues.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;;IAQpD;;OAEG;qBACc,QAAQ;IAEzB;;;OAGG;oBACa,KAAK,GAAG,SAAS;;AAfrC;;GAEG;AACH,qBAAa,YAAa,SAAQ,iBAc/B;IACD,MAAM,CAAC,YAAY,0CAUhB;IAEH,MAAM,CAAC,IAAI,GAAI,QAAQ,YAAY,EAAE,QAAQ,KAAK,KAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,CAKpF;IAEF,MAAM,CAAC,KAAK,GAAI,QAAQ,YAAY,EAAE,QAAQ,KAAK,KAAG,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,CACf;IAEhE;;OAEG;IACH,MAAM,CAAC,QAAQ,GAAI,CAAC,SAAS,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,EAC1E,KAAK,GAAG,KACP,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,CAAsE;IAErH;;OAEG;IACH,MAAM,CAAC,WAAW,GAAI,CAAC,SAAS,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,EAAE,UAAU;QACzF,WAAW,CAAC,EAAE,gBAAgB,CAAC;KAChC,KAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,CAC2B;IAE3E,MAAM,CAAC,MAAM,GAAI,CAAC,SAAS,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,EACxE,OAAO,KAAK,CAAC,CAAC,CAAC,EACf,SAAS,CAAC,EAAE,KACX,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAgD;CACvE;;oBAQmB,KAAK;;AANzB;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,wBAKtC;IACD,MAAM,CAAC,KAAK,GAAI,OAAO,KAAK,oDAAmD;CAChF"}
1
+ {"version":3,"file":"queues.d.ts","sourceRoot":"","sources":["../../../../src/services/queues.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,gCAAgC,EAAE,MAAM,eAAe,CAAC"}
@@ -1,57 +1,5 @@
1
- import { Context, Effect, Layer } from 'effect';
2
- import { AgentStatus } from '@dxos/ai';
3
- import { Obj } from '@dxos/echo';
4
- import type { Queue } from '@dxos/echo-db';
5
- import type { ObjectId } from '@dxos/echo-schema';
6
- import { DataType } from '@dxos/schema';
7
- declare const TracingService_base: Context.TagClass<TracingService, "@dxos/functions/TracingService", {
8
- /**
9
- * Gets the parent message ID.
10
- */
11
- getTraceContext: () => TracingService.TraceContext;
12
- /**
13
- * Write an event to the tracing queue.
14
- * @param event - The event to write. Must be an a typed object.
15
- */
16
- write: (event: Obj.Any) => void;
17
- }>;
18
1
  /**
19
- * Provides a way for compute primitives (functions, workflows, tools)
20
- * to emit an execution trace as a series of structured ECHO objects.
2
+ * Goes into {@link Message['properties']}
21
3
  */
22
- export declare class TracingService extends TracingService_base {
23
- static noop: Context.Tag.Service<TracingService>;
24
- static layerNoop: Layer.Layer<TracingService, never, never>;
25
- static console: Context.Tag.Service<TracingService>;
26
- static layerConsole: Layer.Layer<TracingService, never, never>;
27
- static layerLogInfo: () => Layer.Layer<TracingService, never, never>;
28
- /**
29
- * Creates a TracingService layer that emits events to the parent tracing service.
30
- */
31
- static layerSubframe: (mapContext: (currentContext: TracingService.TraceContext) => TracingService.TraceContext) => Layer.Layer<TracingService, never, TracingService>;
32
- static layerQueue: (queue: Queue) => Layer.Layer<TracingService, never, never>;
33
- /**
34
- * Emit the current human-readable execution status.
35
- */
36
- static emitStatus: (data: Obj.MakeProps<typeof AgentStatus>) => Effect.Effect<void, never, TracingService>;
37
- static emitConverationMessage: (data: Obj.MakeProps<typeof DataType.Message>) => Effect.Effect<void, never, TracingService>;
38
- }
39
- export declare namespace TracingService {
40
- interface TraceContext {
41
- /**
42
- * If this thread sprung from a tool call, this is the ID of the message containing the tool call.
43
- */
44
- parentMessage?: ObjectId;
45
- /**
46
- * If the current thread is a byproduct of a tool call, this is the ID of the tool call.
47
- */
48
- toolCallId?: string;
49
- debugInfo?: unknown;
50
- }
51
- }
52
- /**
53
- * Goes into {@link DataType.Message['properties']}
54
- */
55
- export declare const MESSAGE_PROPERTY_TOOL_CALL_ID: "toolCallId";
56
- export {};
4
+ export declare const MESSAGE_PROPERTY_TOOL_CALL_ID: 'toolCallId';
57
5
  //# sourceMappingURL=tracing.d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B,EAAE,CAC7B,IAAI,EAAE,GAAG,CAAC,SAAS,CAAC,OAAO,QAAQ,CAAC,OAAO,CAAC,KACzC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,cAAc,CAAC,CAY5C;CACJ;AAED,yBAAiB,cAAc,CAAC;IAC9B,UAAiB,YAAY;QAC3B;;WAEG;QACH,aAAa,CAAC,EAAE,QAAQ,CAAC;QAEzB;;WAEG;QACH,UAAU,CAAC,EAAE,MAAM,CAAC;QAEpB,SAAS,CAAC,EAAE,OAAO,CAAC;KACrB;CACF;AAED;;GAEG;AACH,eAAO,MAAM,6BAA6B,EAAG,YAAqB,CAAC"}
1
+ {"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../../../../src/services/tracing.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,eAAO,MAAM,6BAA6B,EAAG,YAAqB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './url';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAIA,cAAc,OAAO,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { type Obj } from '@dxos/echo';
2
+ export declare const FUNCTIONS_META_KEY = "org.dxos.service.function";
3
+ export declare const FUNCTIONS_PRESET_META_KEY = "org.dxos.service.function-preset";
4
+ /**
5
+ * NOTE: functionId is backend ID, not ECHO object id.
6
+ */
7
+ export declare const getUserFunctionIdInMetadata: (meta: Obj.ReadonlyMeta) => string | undefined;
8
+ /**
9
+ * NOTE: functionId is backend ID, not ECHO object id.
10
+ * Must be called inside Obj.update() since it mutates the meta.
11
+ */
12
+ export declare const setUserFunctionIdInMetadata: (meta: Obj.Meta, functionId: string) => void;
13
+ //# sourceMappingURL=url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../../src/types/url.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,YAAY,CAAC;AAGtC,eAAO,MAAM,kBAAkB,8BAA8B,CAAC;AAE9D,eAAO,MAAM,yBAAyB,qCAAqC,CAAC;AAE5E;;GAEG;AACH,eAAO,MAAM,2BAA2B,SAAU,GAAG,CAAC,YAAY,uBAEjE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,2BAA2B,SAAU,GAAG,CAAC,IAAI,cAAc,MAAM,SAS7E,CAAC"}