@dxos/functions 0.8.3 → 0.8.4-main.1068cf700f

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 (172) hide show
  1. package/dist/lib/neutral/index.mjs +1229 -0
  2. package/dist/lib/neutral/index.mjs.map +7 -0
  3. package/dist/lib/neutral/meta.json +1 -0
  4. package/dist/types/src/errors.d.ts +121 -0
  5. package/dist/types/src/errors.d.ts.map +1 -0
  6. package/dist/types/src/example/fib.d.ts +7 -0
  7. package/dist/types/src/example/fib.d.ts.map +1 -0
  8. package/dist/types/src/example/forex-effect.d.ts +3 -0
  9. package/dist/types/src/example/forex-effect.d.ts.map +1 -0
  10. package/dist/types/src/example/index.d.ts +12 -0
  11. package/dist/types/src/example/index.d.ts.map +1 -0
  12. package/dist/types/src/example/reply.d.ts +3 -0
  13. package/dist/types/src/example/reply.d.ts.map +1 -0
  14. package/dist/types/src/example/sleep.d.ts +5 -0
  15. package/dist/types/src/example/sleep.d.ts.map +1 -0
  16. package/dist/types/src/index.d.ts +5 -6
  17. package/dist/types/src/index.d.ts.map +1 -1
  18. package/dist/types/src/operation-compatibility.test.d.ts +2 -0
  19. package/dist/types/src/operation-compatibility.test.d.ts.map +1 -0
  20. package/dist/types/src/protocol/functions-ai-http-client.d.ts +12 -0
  21. package/dist/types/src/protocol/functions-ai-http-client.d.ts.map +1 -0
  22. package/dist/types/src/protocol/index.d.ts +2 -0
  23. package/dist/types/src/protocol/index.d.ts.map +1 -0
  24. package/dist/types/src/protocol/protocol.d.ts +7 -0
  25. package/dist/types/src/protocol/protocol.d.ts.map +1 -0
  26. package/dist/types/src/protocol/protocol.test.d.ts +2 -0
  27. package/dist/types/src/protocol/protocol.test.d.ts.map +1 -0
  28. package/dist/types/src/sdk.d.ts +114 -0
  29. package/dist/types/src/sdk.d.ts.map +1 -0
  30. package/dist/types/src/services/credentials.d.ts +24 -4
  31. package/dist/types/src/services/credentials.d.ts.map +1 -1
  32. package/dist/types/src/services/event-logger.d.ts +74 -30
  33. package/dist/types/src/services/event-logger.d.ts.map +1 -1
  34. package/dist/types/src/services/function-invocation-service.d.ts +16 -0
  35. package/dist/types/src/services/function-invocation-service.d.ts.map +1 -0
  36. package/dist/types/src/services/index.d.ts +5 -6
  37. package/dist/types/src/services/index.d.ts.map +1 -1
  38. package/dist/types/src/services/queues.d.ts +35 -6
  39. package/dist/types/src/services/queues.d.ts.map +1 -1
  40. package/dist/types/src/services/tracing.d.ts +78 -5
  41. package/dist/types/src/services/tracing.d.ts.map +1 -1
  42. package/dist/types/src/types/Function.d.ts +52 -0
  43. package/dist/types/src/types/Function.d.ts.map +1 -0
  44. package/dist/types/src/types/Script.d.ts +21 -0
  45. package/dist/types/src/types/Script.d.ts.map +1 -0
  46. package/dist/types/src/types/Trigger.d.ts +121 -0
  47. package/dist/types/src/types/Trigger.d.ts.map +1 -0
  48. package/dist/types/src/types/TriggerEvent.d.ts +74 -0
  49. package/dist/types/src/types/TriggerEvent.d.ts.map +1 -0
  50. package/dist/types/src/types/index.d.ts +6 -0
  51. package/dist/types/src/types/index.d.ts.map +1 -0
  52. package/dist/types/src/types/url.d.ts +13 -0
  53. package/dist/types/src/types/url.d.ts.map +1 -0
  54. package/dist/types/tsconfig.tsbuildinfo +1 -1
  55. package/package.json +27 -65
  56. package/src/errors.ts +21 -0
  57. package/src/example/fib.ts +32 -0
  58. package/src/example/forex-effect.ts +40 -0
  59. package/src/example/index.ts +13 -0
  60. package/src/example/reply.ts +21 -0
  61. package/src/example/sleep.ts +24 -0
  62. package/src/index.ts +5 -8
  63. package/src/operation-compatibility.test.ts +185 -0
  64. package/src/protocol/functions-ai-http-client.ts +67 -0
  65. package/src/{executor → protocol}/index.ts +1 -1
  66. package/src/protocol/protocol.test.ts +59 -0
  67. package/src/protocol/protocol.ts +262 -0
  68. package/src/sdk.ts +289 -0
  69. package/src/services/credentials.ts +109 -5
  70. package/src/services/event-logger.ts +77 -37
  71. package/src/services/function-invocation-service.ts +37 -0
  72. package/src/services/index.ts +5 -6
  73. package/src/services/queues.ts +56 -11
  74. package/src/services/tracing.ts +151 -11
  75. package/src/types/Function.ts +82 -0
  76. package/src/types/Script.ts +34 -0
  77. package/src/types/Trigger.ts +143 -0
  78. package/src/types/TriggerEvent.ts +62 -0
  79. package/src/types/index.ts +9 -0
  80. package/src/types/url.ts +32 -0
  81. package/dist/lib/browser/bundler/index.mjs +0 -236
  82. package/dist/lib/browser/bundler/index.mjs.map +0 -7
  83. package/dist/lib/browser/chunk-WEFZUEL2.mjs +0 -300
  84. package/dist/lib/browser/chunk-WEFZUEL2.mjs.map +0 -7
  85. package/dist/lib/browser/edge/index.mjs +0 -69
  86. package/dist/lib/browser/edge/index.mjs.map +0 -7
  87. package/dist/lib/browser/index.mjs +0 -486
  88. package/dist/lib/browser/index.mjs.map +0 -7
  89. package/dist/lib/browser/meta.json +0 -1
  90. package/dist/lib/browser/testing/index.mjs +0 -28
  91. package/dist/lib/browser/testing/index.mjs.map +0 -7
  92. package/dist/lib/node/bundler/index.cjs +0 -260
  93. package/dist/lib/node/bundler/index.cjs.map +0 -7
  94. package/dist/lib/node/chunk-IJAE7FZK.cjs +0 -320
  95. package/dist/lib/node/chunk-IJAE7FZK.cjs.map +0 -7
  96. package/dist/lib/node/edge/index.cjs +0 -94
  97. package/dist/lib/node/edge/index.cjs.map +0 -7
  98. package/dist/lib/node/index.cjs +0 -522
  99. package/dist/lib/node/index.cjs.map +0 -7
  100. package/dist/lib/node/meta.json +0 -1
  101. package/dist/lib/node/testing/index.cjs +0 -43
  102. package/dist/lib/node/testing/index.cjs.map +0 -7
  103. package/dist/lib/node-esm/bundler/index.mjs +0 -238
  104. package/dist/lib/node-esm/bundler/index.mjs.map +0 -7
  105. package/dist/lib/node-esm/chunk-LIYPMWNQ.mjs +0 -302
  106. package/dist/lib/node-esm/chunk-LIYPMWNQ.mjs.map +0 -7
  107. package/dist/lib/node-esm/edge/index.mjs +0 -71
  108. package/dist/lib/node-esm/edge/index.mjs.map +0 -7
  109. package/dist/lib/node-esm/index.mjs +0 -487
  110. package/dist/lib/node-esm/index.mjs.map +0 -7
  111. package/dist/lib/node-esm/meta.json +0 -1
  112. package/dist/lib/node-esm/testing/index.mjs +0 -29
  113. package/dist/lib/node-esm/testing/index.mjs.map +0 -7
  114. package/dist/types/src/bundler/bundler.d.ts +0 -51
  115. package/dist/types/src/bundler/bundler.d.ts.map +0 -1
  116. package/dist/types/src/bundler/bundler.test.d.ts +0 -2
  117. package/dist/types/src/bundler/bundler.test.d.ts.map +0 -1
  118. package/dist/types/src/bundler/index.d.ts +0 -2
  119. package/dist/types/src/bundler/index.d.ts.map +0 -1
  120. package/dist/types/src/edge/functions.d.ts +0 -16
  121. package/dist/types/src/edge/functions.d.ts.map +0 -1
  122. package/dist/types/src/edge/index.d.ts +0 -2
  123. package/dist/types/src/edge/index.d.ts.map +0 -1
  124. package/dist/types/src/executor/executor.d.ts +0 -8
  125. package/dist/types/src/executor/executor.d.ts.map +0 -1
  126. package/dist/types/src/executor/index.d.ts +0 -2
  127. package/dist/types/src/executor/index.d.ts.map +0 -1
  128. package/dist/types/src/handler.d.ts +0 -64
  129. package/dist/types/src/handler.d.ts.map +0 -1
  130. package/dist/types/src/schema.d.ts +0 -38
  131. package/dist/types/src/schema.d.ts.map +0 -1
  132. package/dist/types/src/services/ai.d.ts +0 -12
  133. package/dist/types/src/services/ai.d.ts.map +0 -1
  134. package/dist/types/src/services/database.d.ts +0 -11
  135. package/dist/types/src/services/database.d.ts.map +0 -1
  136. package/dist/types/src/services/function-call-service.d.ts +0 -16
  137. package/dist/types/src/services/function-call-service.d.ts.map +0 -1
  138. package/dist/types/src/services/service-container.d.ts +0 -44
  139. package/dist/types/src/services/service-container.d.ts.map +0 -1
  140. package/dist/types/src/testing/index.d.ts +0 -2
  141. package/dist/types/src/testing/index.d.ts.map +0 -1
  142. package/dist/types/src/testing/logger.d.ts +0 -5
  143. package/dist/types/src/testing/logger.d.ts.map +0 -1
  144. package/dist/types/src/testing/services.d.ts +0 -13
  145. package/dist/types/src/testing/services.d.ts.map +0 -1
  146. package/dist/types/src/trace.d.ts +0 -124
  147. package/dist/types/src/trace.d.ts.map +0 -1
  148. package/dist/types/src/translations.d.ts +0 -12
  149. package/dist/types/src/translations.d.ts.map +0 -1
  150. package/dist/types/src/types.d.ts +0 -411
  151. package/dist/types/src/types.d.ts.map +0 -1
  152. package/dist/types/src/url.d.ts +0 -17
  153. package/dist/types/src/url.d.ts.map +0 -1
  154. package/src/bundler/bundler.test.ts +0 -59
  155. package/src/bundler/bundler.ts +0 -270
  156. package/src/bundler/index.ts +0 -5
  157. package/src/edge/functions.ts +0 -64
  158. package/src/edge/index.ts +0 -9
  159. package/src/executor/executor.ts +0 -47
  160. package/src/handler.ts +0 -113
  161. package/src/schema.ts +0 -57
  162. package/src/services/ai.ts +0 -32
  163. package/src/services/database.ts +0 -28
  164. package/src/services/function-call-service.ts +0 -64
  165. package/src/services/service-container.ts +0 -109
  166. package/src/testing/index.ts +0 -5
  167. package/src/testing/logger.ts +0 -16
  168. package/src/testing/services.ts +0 -32
  169. package/src/trace.ts +0 -180
  170. package/src/translations.ts +0 -20
  171. package/src/types.ts +0 -211
  172. package/src/url.ts +0 -52
@@ -0,0 +1,114 @@
1
+ import type * as Context from 'effect/Context';
2
+ import * as Effect from 'effect/Effect';
3
+ import * as Schema from 'effect/Schema';
4
+ import { type AiService } from '@dxos/ai';
5
+ import { Type } from '@dxos/echo';
6
+ import { type Database } from '@dxos/echo';
7
+ import { Operation } from '@dxos/operation';
8
+ import { type CredentialsService, type FunctionInvocationService, type QueueService, type TracingService } from './services';
9
+ import { Function } from './types';
10
+ /**
11
+ * Services that are provided at the function call site by the caller.
12
+ */
13
+ export type InvocationServices = TracingService;
14
+ /**
15
+ * Services that are available to invoked functions.
16
+ */
17
+ export type FunctionServices = InvocationServices | AiService.AiService | CredentialsService | Database.Service | QueueService | FunctionInvocationService;
18
+ /**
19
+ * Function handler.
20
+ */
21
+ export type FunctionHandler<TData = {}, TOutput = any, S extends FunctionServices = FunctionServices> = (params: {
22
+ /**
23
+ * Context available to the function.
24
+ */
25
+ context: FunctionContext;
26
+ /**
27
+ * Data passed as the input to the function.
28
+ * Must match the function's input schema.
29
+ * This will be the payload from the trigger or other data passed into the function in a workflow.
30
+ */
31
+ data: TData;
32
+ }) => TOutput | Promise<TOutput> | Effect.Effect<TOutput, any, S>;
33
+ /**
34
+ * Function context.
35
+ */
36
+ export interface FunctionContext {
37
+ }
38
+ declare const typeId: unique symbol;
39
+ export type FunctionDefinition<T = any, O = any, S extends FunctionServices = FunctionServices> = {
40
+ [typeId]: true;
41
+ key: string;
42
+ name: string;
43
+ description?: string;
44
+ inputSchema: Schema.Schema<T, any>;
45
+ outputSchema?: Schema.Schema<O, any>;
46
+ /**
47
+ * List of types the function uses.
48
+ * This is used to ensure that the types are available when the function is executed.
49
+ */
50
+ types: readonly Type.Entity.Any[];
51
+ /**
52
+ * Keys of the required services.
53
+ */
54
+ services: readonly string[];
55
+ handler: FunctionHandler<T, O, S>;
56
+ meta?: {
57
+ /**
58
+ * Tools that are projected from functions have this annotation.
59
+ *
60
+ * deployedFunctionId:
61
+ * - Backend deployment ID assigned by the EDGE function service (typically a UUID).
62
+ * - Used for remote invocation via `FunctionInvocationService` → `RemoteFunctionExecutionService`.
63
+ * - Persisted on the corresponding ECHO `Function.Function` object's metadata under the
64
+ * `FUNCTIONS_META_KEY` and retrieved with `getUserFunctionIdInMetadata`.
65
+ */
66
+ deployedFunctionId?: string;
67
+ };
68
+ };
69
+ export declare namespace FunctionDefinition {
70
+ type Any = FunctionDefinition<any, any, any>;
71
+ type Input<T extends Any> = T extends FunctionDefinition<infer I, infer _O, infer _S> ? I : never;
72
+ type Output<T extends Any> = T extends FunctionDefinition<infer _I, infer O, infer _S> ? O : never;
73
+ type Services<T extends Any> = T extends FunctionDefinition<infer _I, infer _O, infer S> ? S : never;
74
+ }
75
+ export type FunctionProps<T, O> = {
76
+ key: string;
77
+ name: string;
78
+ description?: string;
79
+ inputSchema: Schema.Schema<T, any>;
80
+ outputSchema?: Schema.Schema<O, any>;
81
+ /**
82
+ * List of types the function uses.
83
+ * This is used to ensure that the types are available when the function is executed.
84
+ */
85
+ types?: readonly Type.Entity.Any[];
86
+ services?: readonly Context.Tag<any, any>[];
87
+ handler: FunctionHandler<T, O, FunctionServices>;
88
+ };
89
+ export declare const defineFunction: {
90
+ <I, O>(params: FunctionProps<I, O>): FunctionDefinition<I, O, FunctionServices>;
91
+ };
92
+ /**
93
+ * Converts a FunctionDefinition to an OperationDefinition with handler.
94
+ * The function handler is adapted to the OperationHandler format.
95
+ *
96
+ * Note: FunctionDefinition stores service keys as strings, not Tag types,
97
+ * so we can't use Operation.withHandler's type inference here.
98
+ */
99
+ export declare const toOperation: <T, O, S extends FunctionServices = FunctionServices>(functionDef: FunctionDefinition<T, O, S>) => Operation.Definition<T, O> & {
100
+ handler: Operation.Handler<T, O, any, S>;
101
+ };
102
+ export declare const FunctionDefinition: {
103
+ make: <I, O>(params: FunctionProps<I, O>) => FunctionDefinition<I, O, FunctionServices>;
104
+ isFunction: (value: unknown) => value is FunctionDefinition.Any;
105
+ serialize: (functionDef: FunctionDefinition.Any) => Function.Function;
106
+ deserialize: (functionObj: Function.Function) => FunctionDefinition.Any;
107
+ toOperation: <T, O, S extends FunctionServices = FunctionServices>(functionDef: FunctionDefinition<T, O, S>) => Operation.Definition<T, O> & {
108
+ handler: Operation.Handler<T, O, any, S>;
109
+ };
110
+ };
111
+ export declare const serializeFunction: (functionDef: FunctionDefinition.Any) => Function.Function;
112
+ export declare const deserializeFunction: (functionObj: Function.Function) => FunctionDefinition<unknown, unknown>;
113
+ export {};
114
+ //# sourceMappingURL=sdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/sdk.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC/C,OA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AO,KAAG,KAAK,IAAI,kBAAkB,CAAC,GAAG;6BAGpC,kBAAkB,CAAC,GAAG,KAAG,QAAQ,CAAC,QAAQ;+BAIxC,QAAQ,CAAC,QAAQ,KAAG,kBAAkB,CAAC,GAAG;kBAlD3C,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,gBAAgB,kCAC7C,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KACvC,SAAS,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;QAAE,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;KAAE;CAqD3E,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,aAAa,kBAAkB,CAAC,GAAG,KAAG,QAAQ,CAAC,QAchF,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,aAAa,QAAQ,CAAC,QAAQ,KAAG,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAiBvG,CAAC"}
@@ -1,12 +1,18 @@
1
- import { Context } from 'effect';
2
- type CredentialQuery = {
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 Effect from 'effect/Effect';
5
+ import * as Layer from 'effect/Layer';
6
+ import * as Redacted from 'effect/Redacted';
7
+ import { Database } from '@dxos/echo';
8
+ export type CredentialQuery = {
3
9
  service?: string;
4
10
  };
5
- type ServiceCredential = {
11
+ export type ServiceCredential = {
6
12
  service: string;
7
13
  apiKey?: string;
8
14
  };
9
- declare const CredentialsService_base: Context.TagClass<CredentialsService, "CredentialsService", {
15
+ declare const CredentialsService_base: Context.TagClass<CredentialsService, "@dxos/functions/CredentialsService", {
10
16
  /**
11
17
  * Query all.
12
18
  */
@@ -18,6 +24,16 @@ declare const CredentialsService_base: Context.TagClass<CredentialsService, "Cre
18
24
  getCredential: (query: CredentialQuery) => Promise<ServiceCredential>;
19
25
  }>;
20
26
  export declare class CredentialsService extends CredentialsService_base {
27
+ static getCredential: (query: CredentialQuery) => Effect.Effect<ServiceCredential, never, CredentialsService>;
28
+ static getApiKey: (query: CredentialQuery) => Effect.Effect<Redacted.Redacted<string>, never, CredentialsService>;
29
+ static configuredLayer: (credentials: ServiceCredential[]) => Layer.Layer<CredentialsService, never, never>;
30
+ static layerConfig: (credentials: {
31
+ service: string;
32
+ apiKey: Config.Config<Redacted.Redacted<string>>;
33
+ }[]) => Layer.Layer<CredentialsService, import("effect/ConfigError").ConfigError, never>;
34
+ static layerFromDatabase: ({ caching }?: {
35
+ caching?: boolean;
36
+ }) => Layer.Layer<CredentialsService, never, Database.Service>;
21
37
  }
22
38
  export declare class ConfiguredCredentialsService implements Context.Tag.Service<CredentialsService> {
23
39
  private readonly credentials;
@@ -26,5 +42,9 @@ export declare class ConfiguredCredentialsService implements Context.Tag.Service
26
42
  queryCredentials(query: CredentialQuery): Promise<ServiceCredential[]>;
27
43
  getCredential(query: CredentialQuery): Promise<ServiceCredential>;
28
44
  }
45
+ /**
46
+ * Maps the request to include the given token in the Authorization header.
47
+ */
48
+ export declare const withAuthorization: (token: string, kind?: "Bearer" | "Basic") => <E, R>(self: HttpClient.HttpClient.With<E, R>) => HttpClient.HttpClient.With<E, R>;
29
49
  export {};
30
50
  //# sourceMappingURL=credentials.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../../../src/services/credentials.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,KAAK,eAAe,GAAG;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAIF,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAGhB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;;IAKE;;OAEG;sBACe,CAAC,KAAK,EAAE,eAAe,KAAK,OAAO,CAAC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+ import * as Layer from 'effect/Layer';
4
+ import * as Schema from 'effect/Schema';
5
+ import { Type } from '@dxos/echo';
2
6
  import { LogLevel } from '@dxos/log';
3
- export type ComputeEvent = {
4
- type: 'begin-compute';
5
- nodeId: string;
6
- inputs: Record<string, any>;
7
- } | {
8
- type: 'end-compute';
9
- nodeId: string;
10
- outputs: Record<string, any>;
11
- } | {
12
- type: 'compute-input';
13
- nodeId: string;
14
- property: string;
15
- value: any;
16
- } | {
17
- type: 'compute-output';
18
- nodeId: string;
19
- property: string;
20
- value: any;
21
- } | {
22
- type: 'custom';
23
- nodeId: string;
24
- event: any;
25
- };
26
- declare const EventLogger_base: Context.TagClass<EventLogger, "EventLogger", {
27
- readonly log: (event: ComputeEvent) => void;
7
+ import { TracingService } from './tracing';
8
+ export declare const ComputeEventPayload: Schema.Union<[Schema.Struct<{
9
+ type: Schema.Literal<["begin-compute"]>;
10
+ nodeId: typeof Schema.String;
11
+ /**
12
+ * Names of the inputs begin computed.
13
+ */
14
+ inputs: Schema.Array$<typeof Schema.String>;
15
+ }>, Schema.Struct<{
16
+ type: Schema.Literal<["end-compute"]>;
17
+ nodeId: typeof Schema.String;
18
+ /**
19
+ * Names of the outputs computed.
20
+ */
21
+ outputs: Schema.Array$<typeof Schema.String>;
22
+ }>, Schema.Struct<{
23
+ type: Schema.Literal<["compute-input"]>;
24
+ nodeId: typeof Schema.String;
25
+ property: typeof Schema.String;
26
+ value: typeof Schema.Any;
27
+ }>, Schema.Struct<{
28
+ type: Schema.Literal<["compute-output"]>;
29
+ nodeId: typeof Schema.String;
30
+ property: typeof Schema.String;
31
+ value: typeof Schema.Any;
32
+ }>, Schema.Struct<{
33
+ type: Schema.Literal<["custom"]>;
34
+ nodeId: typeof Schema.String;
35
+ event: typeof Schema.Any;
36
+ }>]>;
37
+ export type ComputeEventPayload = Schema.Schema.Type<typeof ComputeEventPayload>;
38
+ export declare const ComputeEvent: Type.Obj<{
39
+ readonly payload: {
40
+ readonly type: "begin-compute";
41
+ readonly nodeId: string;
42
+ readonly inputs: readonly string[];
43
+ } | {
44
+ readonly type: "end-compute";
45
+ readonly nodeId: string;
46
+ readonly outputs: readonly string[];
47
+ } | {
48
+ readonly value: any;
49
+ readonly type: "compute-input";
50
+ readonly nodeId: string;
51
+ readonly property: string;
52
+ } | {
53
+ readonly value: any;
54
+ readonly type: "compute-output";
55
+ readonly nodeId: string;
56
+ readonly property: string;
57
+ } | {
58
+ readonly type: "custom";
59
+ readonly nodeId: string;
60
+ readonly event: any;
61
+ };
62
+ }, Schema.Struct.Fields>;
63
+ declare const ComputeEventLogger_base: Context.TagClass<ComputeEventLogger, "@dxos/functions/ComputeEventLogger", {
64
+ readonly log: (event: ComputeEventPayload) => void;
28
65
  readonly nodeId: string | undefined;
29
66
  }>;
30
- export declare class EventLogger extends EventLogger_base {
31
- static noop: Context.Tag.Service<EventLogger>;
67
+ /**
68
+ * Logs event for the compute workflows.
69
+ */
70
+ export declare class ComputeEventLogger extends ComputeEventLogger_base {
71
+ static noop: Context.Tag.Service<ComputeEventLogger>;
72
+ /**
73
+ * Implements ComputeEventLogger using TracingService.
74
+ */
75
+ static layerFromTracing: Layer.Layer<ComputeEventLogger, never, TracingService>;
32
76
  }
33
- export declare const logCustomEvent: (data: any) => Effect.Effect<void, never, EventLogger>;
77
+ export declare const logCustomEvent: (data: any) => Effect.Effect<void, never, ComputeEventLogger>;
34
78
  export declare const createDefectLogger: <A, E, R>() => ((self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>);
35
- export declare const createEventLogger: (level: LogLevel, message?: string) => Context.Tag.Service<EventLogger>;
79
+ export declare const createEventLogger: (level: LogLevel, message?: string) => Context.Tag.Service<ComputeEventLogger>;
36
80
  export {};
37
81
  //# sourceMappingURL=event-logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"event-logger.d.ts","sourceRoot":"","sources":["../../../../src/services/event-logger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MA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AAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAMrG,CAAC;AAEJ,eAAO,MAAM,iBAAiB,GAC5B,OAAO,QAAQ,EACf,UAAS,MAAgB,KACxB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAiBxC,CAAC"}
@@ -0,0 +1,16 @@
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 } from '../errors';
5
+ import { type FunctionDefinition, type InvocationServices } from '../sdk';
6
+ declare const FunctionInvocationService_base: Context.TagClass<FunctionInvocationService, "@dxos/functions/FunctionInvocationService", {
7
+ invokeFunction<I, O>(functionDef: FunctionDefinition<I, O, any>, input: I): Effect.Effect<O, never, InvocationServices>;
8
+ resolveFunction(key: string): Effect.Effect<FunctionDefinition.Any, FunctionNotFoundError>;
9
+ }>;
10
+ export declare class FunctionInvocationService extends FunctionInvocationService_base {
11
+ static layerNotAvailable: Layer.Layer<FunctionInvocationService, never, never>;
12
+ static invokeFunction: <I, O>(functionDef: FunctionDefinition<I, O, any>, input: I) => Effect.Effect<O, never, FunctionInvocationService | InvocationServices>;
13
+ static resolveFunction: (key: string) => Effect.Effect<FunctionDefinition.Any, FunctionNotFoundError, FunctionInvocationService>;
14
+ }
15
+ export {};
16
+ //# 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,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,kBAAkB,EAAE,MAAM,QAAQ,CAAC;;mBAKvD,CAAC,EAAE,CAAC,eACJ,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,SACnC,CAAC,GACP,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,kBAAkB,CAAC;yBAEzB,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,qBAAqB,CAAC;;AAR9F,qBAAa,yBAA0B,SAAQ,8BAU5C;IACD,MAAM,CAAC,iBAAiB,uDAGrB;IAEH,MAAM,CAAC,cAAc,GAAI,CAAC,EAAE,CAAC,EAC3B,aAAa,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAC1C,OAAO,CAAC,KACP,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,yBAAyB,GAAG,kBAAkB,CAAC,CACyC;IAEnH,MAAM,CAAC,eAAe,GACpB,KAAK,MAAM,KACV,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,qBAAqB,EAAE,yBAAyB,CAAC,CACW;CACtG"}
@@ -1,9 +1,8 @@
1
- export * from './ai';
2
- export * from './database';
3
- export * from './queues';
4
- export * from './service-container';
5
1
  export * from './credentials';
6
- export * from './tracing';
2
+ export { ConfiguredCredentialsService, type ServiceCredential } from './credentials';
7
3
  export * from './event-logger';
8
- export * from './function-call-service';
4
+ export { createEventLogger, createDefectLogger } from './event-logger';
5
+ export * from './function-invocation-service';
6
+ export * from './queues';
7
+ export * from './tracing';
9
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/index.ts"],"names":[],"mappings":"AAIA,cAAc,MAAM,CAAC;AACrB,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,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/index.ts"],"names":[],"mappings":"AAIA,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,4BAA4B,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACrF,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACvE,cAAc,+BAA+B,CAAC;AAC9C,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
@@ -1,18 +1,47 @@
1
- import { Context, Layer } from 'effect';
2
- import type { Queue, QueueFactory } from '@dxos/echo-db';
3
- declare const QueueService_base: Context.TagClass<QueueService, "QueueService", {
1
+ import * as Context from 'effect/Context';
2
+ import * as Effect from 'effect/Effect';
3
+ import * as Layer from 'effect/Layer';
4
+ import type { Entity } from '@dxos/echo';
5
+ import type { Queue, QueueAPI, QueueFactory } from '@dxos/echo-db';
6
+ import type { DXN, QueueSubspaceTag } from '@dxos/keys';
7
+ declare const QueueService_base: Context.TagClass<QueueService, "@dxos/functions/QueueService", {
4
8
  /**
5
9
  * API to access the queues.
6
10
  */
7
- readonly queues: QueueFactory;
11
+ readonly queues: QueueAPI;
8
12
  /**
9
13
  * The queue that is used to store the context of the current research.
14
+ * @deprecated Use `ContextQueueService` instead.
10
15
  */
11
- readonly contextQueue: Queue | undefined;
16
+ readonly queue: Queue | undefined;
12
17
  }>;
18
+ /**
19
+ * Gives access to all queues.
20
+ */
13
21
  export declare class QueueService extends QueueService_base {
14
22
  static notAvailable: Layer.Layer<QueueService, never, never>;
15
- static make: (queues: QueueFactory, contextQueue: Queue | undefined) => Context.Tag.Service<QueueService>;
23
+ static make: (queues: QueueFactory, queue?: Queue) => Context.Tag.Service<QueueService>;
24
+ static layer: (queues: QueueFactory, queue?: Queue) => Layer.Layer<QueueService>;
25
+ /**
26
+ * Gets a queue by its DXN.
27
+ */
28
+ static getQueue: <T extends Entity.Unknown = Entity.Unknown>(dxn: DXN) => Effect.Effect<Queue<T>, never, QueueService>;
29
+ /**
30
+ * Creates a new queue.
31
+ */
32
+ static createQueue: <T extends Entity.Unknown = Entity.Unknown>(options?: {
33
+ subspaceTag?: QueueSubspaceTag;
34
+ }) => Effect.Effect<Queue<T>, never, QueueService>;
35
+ static append: <T extends Entity.Unknown = Entity.Unknown>(queue: Queue<T>, objects: T[]) => Effect.Effect<void>;
36
+ }
37
+ declare const ContextQueueService_base: Context.TagClass<ContextQueueService, "@dxos/functions/ContextQueueService", {
38
+ readonly queue: Queue;
39
+ }>;
40
+ /**
41
+ * Gives access to a specific queue passed as a context.
42
+ */
43
+ export declare class ContextQueueService extends ContextQueueService_base {
44
+ static layer: (queue: Queue) => Layer.Layer<ContextQueueService, never, never>;
16
45
  }
17
46
  export {};
18
47
  //# 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,KAAK,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;;IAKrD;;OAEG;qBACc,YAAY;IAE7B;;OAEG;2BAEoB,KAAK,GAAG,SAAS;;AAZ5C,qBAAa,YAAa,SAAQ,iBAc/B;IACD,MAAM,CAAC,YAAY,0CAKhB;IAEH,MAAM,CAAC,IAAI,GAAI,QAAQ,YAAY,EAAE,cAAc,KAAK,GAAG,SAAS,KAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,CAKtG;CACH"}
1
+ {"version":3,"file":"queues.d.ts","sourceRoot":"","sources":["../../../../src/services/queues.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,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SAAS,CAAC,EAAE,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CACjE;CAC/C;;oBAQmB,KAAK;;AANzB;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,wBAKtC;IACD,MAAM,CAAC,KAAK,GAAI,OAAO,KAAK,oDAAmD;CAChF"}
@@ -1,15 +1,88 @@
1
- import { Context } from 'effect';
2
- import type { AnyEchoObject } from '@dxos/echo-schema';
3
- declare const TracingService_base: Context.TagClass<TracingService, "TracingService", {
1
+ import * as Context from 'effect/Context';
2
+ import * as Effect from 'effect/Effect';
3
+ import * as Layer from 'effect/Layer';
4
+ import { AgentStatus } from '@dxos/ai';
5
+ import { type DXN, Obj } from '@dxos/echo';
6
+ import { ObjectId } from '@dxos/keys';
7
+ import { Message } from '@dxos/types';
8
+ import type { Trigger } from '../types';
9
+ declare const TracingService_base: Context.TagClass<TracingService, "@dxos/functions/TracingService", {
10
+ /**
11
+ * Gets the parent message ID.
12
+ */
13
+ getTraceContext: () => TracingService.TraceContext;
4
14
  /**
5
15
  * Write an event to the tracing queue.
6
16
  * @param event - The event to write. Must be an a typed object.
7
17
  */
8
- write(event: AnyEchoObject): void;
18
+ write: (event: Obj.Unknown, traceContext: TracingService.TraceContext) => void;
19
+ traceInvocationStart({ payload, target, }: {
20
+ payload: TracingService.FunctionInvocationPayload;
21
+ target?: DXN;
22
+ }): Effect.Effect<TracingService.InvocationTraceData>;
23
+ traceInvocationEnd({ trace, exception, }: {
24
+ trace: TracingService.InvocationTraceData;
25
+ exception?: any;
26
+ }): Effect.Effect<void>;
9
27
  }>;
28
+ /**
29
+ * Provides a way for compute primitives (functions, workflows, tools)
30
+ * to emit an execution trace as a series of structured ECHO objects.
31
+ */
10
32
  export declare class TracingService extends TracingService_base {
11
33
  static noop: Context.Tag.Service<TracingService>;
12
- static console: Context.Tag.Service<TracingService>;
34
+ static layerNoop: Layer.Layer<TracingService>;
35
+ /**
36
+ * Creates a TracingService layer that emits events to the parent tracing service.
37
+ */
38
+ static layerSubframe: (mapContext: (currentContext: TracingService.TraceContext) => TracingService.TraceContext) => Layer.Layer<TracingService, never, TracingService>;
39
+ /**
40
+ * Create sublayer to trace an invocation.
41
+ * @param data
42
+ * @returns
43
+ */
44
+ static layerInvocation: (data: TracingService.InvocationTraceData) => Layer.Layer<TracingService, never, TracingService>;
45
+ /**
46
+ * Emit the current human-readable execution status.
47
+ */
48
+ static emitStatus: (data: Omit<Obj.MakeProps<typeof AgentStatus>, 'created'>) => Effect.Effect<void, never, TracingService>;
49
+ static emitConverationMessage: (data: Obj.MakeProps<typeof Message.Message>) => Effect.Effect<void, never, TracingService>;
50
+ }
51
+ export declare namespace TracingService {
52
+ interface TraceContext {
53
+ currentInvocation?: InvocationTraceData;
54
+ /**
55
+ * If this thread sprung from a tool call, this is the ID of the message containing the tool call.
56
+ */
57
+ parentMessage?: ObjectId;
58
+ /**
59
+ * If the current thread is a byproduct of a tool call, this is the ID of the tool call.
60
+ */
61
+ toolCallId?: string;
62
+ debugInfo?: unknown;
63
+ }
64
+ /**
65
+ * Trace data for a function/trigger invocation.
66
+ */
67
+ interface InvocationTraceData {
68
+ invocationId: ObjectId;
69
+ invocationTraceQueue?: DXN.String;
70
+ }
71
+ /**
72
+ * Payload for a function/trigger invocation.
73
+ */
74
+ interface FunctionInvocationPayload {
75
+ data?: any;
76
+ inputNodeId?: string;
77
+ trigger?: {
78
+ id: string;
79
+ kind: Trigger.Kind;
80
+ };
81
+ }
13
82
  }
83
+ /**
84
+ * Goes into {@link Message['properties']}
85
+ */
86
+ export declare const MESSAGE_PROPERTY_TOOL_CALL_ID: "toolCallId";
14
87
  export {};
15
88
  //# sourceMappingURL=tracing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../../../../src/services/tracing.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mB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,EAAE,MAAM,CAAC;YACX,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC;SACpB,CAAC;KACH;CACF;AAED;;GAEG;AACH,eAAO,MAAM,6BAA6B,EAAG,YAAqB,CAAC"}
@@ -0,0 +1,52 @@
1
+ import * as Schema from 'effect/Schema';
2
+ import { Obj, Type } from '@dxos/echo';
3
+ /**
4
+ * Function deployment.
5
+ */
6
+ export declare const Function: Type.Obj<{
7
+ readonly version: string;
8
+ readonly source?: import("@dxos/echo/internal").Ref<import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & {
9
+ readonly source: import("@dxos/echo/internal").Ref<import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & {
10
+ readonly content: string;
11
+ }>;
12
+ readonly description?: string | undefined;
13
+ readonly name?: string | undefined;
14
+ readonly changed?: boolean | undefined;
15
+ }> | undefined;
16
+ readonly description?: string | undefined;
17
+ readonly name: string;
18
+ readonly key?: string | undefined;
19
+ readonly updated?: string | undefined;
20
+ readonly inputSchema?: import("@dxos/echo/internal").JsonSchemaType | undefined;
21
+ readonly outputSchema?: import("@dxos/echo/internal").JsonSchemaType | undefined;
22
+ readonly services?: readonly string[] | undefined;
23
+ readonly binding?: string | undefined;
24
+ }, Schema.Struct.Fields>;
25
+ export interface Function extends Schema.Schema.Type<typeof Function> {
26
+ }
27
+ export declare const make: (props: Obj.MakeProps<typeof Function>) => Obj.Obj<import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & {
28
+ readonly version: string;
29
+ readonly source?: import("@dxos/echo/internal").Ref<import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & {
30
+ readonly source: import("@dxos/echo/internal").Ref<import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & {
31
+ readonly content: string;
32
+ }>;
33
+ readonly description?: string | undefined;
34
+ readonly name?: string | undefined;
35
+ readonly changed?: boolean | undefined;
36
+ }> | undefined;
37
+ readonly description?: string | undefined;
38
+ readonly name: string;
39
+ readonly key?: string | undefined;
40
+ readonly updated?: string | undefined;
41
+ readonly inputSchema?: import("@dxos/echo/internal").JsonSchemaType | undefined;
42
+ readonly outputSchema?: import("@dxos/echo/internal").JsonSchemaType | undefined;
43
+ readonly services?: readonly string[] | undefined;
44
+ readonly binding?: string | undefined;
45
+ }>;
46
+ /**
47
+ * Copies properties from source to target.
48
+ * @param target - Target object to copy properties to.
49
+ * @param source - Source object to copy properties from.
50
+ */
51
+ export declare const setFrom: (target: Function, source: Function) => void;
52
+ //# sourceMappingURL=Function.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Function.d.ts","sourceRoot":"","sources":["../../../../src/types/Function.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAA0B,GAAG,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAK/D;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;wBA4CpB,CAAC;AAEF,MAAM,WAAW,QAAS,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,QAAQ,CAAC;CAAG;AAExE,eAAO,MAAM,IAAI,GAAI,OAAO,GAAG,CAAC,SAAS,CAAC,OAAO,QAAQ,CAAC;;;;;;;;;;;;;;;;;;EAA8B,CAAC;AAEzF;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,QAAQ,QAAQ,EAAE,QAAQ,QAAQ,SAYzD,CAAC"}
@@ -0,0 +1,21 @@
1
+ import * as Schema from 'effect/Schema';
2
+ import { Obj, Type } from '@dxos/echo';
3
+ /**
4
+ * Source script.
5
+ */
6
+ export declare const Script: Type.Obj<{
7
+ readonly source: import("@dxos/echo/internal").Ref<import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & {
8
+ readonly content: string;
9
+ }>;
10
+ readonly description?: string | undefined;
11
+ readonly name?: string | undefined;
12
+ readonly changed?: boolean | undefined;
13
+ }, Schema.Struct.Fields>;
14
+ export interface Script extends Schema.Schema.Type<typeof Script> {
15
+ }
16
+ type Props = Omit<Obj.MakeProps<typeof Script>, 'source'> & {
17
+ source?: string;
18
+ };
19
+ export declare const make: ({ source, ...props }?: Props) => Script;
20
+ export {};
21
+ //# sourceMappingURL=Script.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Script.d.ts","sourceRoot":"","sources":["../../../../src/types/Script.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAc,GAAG,EAAO,IAAI,EAAE,MAAM,YAAY,CAAC;AAIxD;;GAEG;AACH,eAAO,MAAM,MAAM;;;;;;;wBAalB,CAAC;AAEF,MAAM,WAAW,MAAO,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,MAAM,CAAC;CAAG;AAEpE,KAAK,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,MAAM,CAAC,EAAE,QAAQ,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhF,eAAO,MAAM,IAAI,GAAI,uBAA2B,KAAU,KAAG,MACQ,CAAC"}