@dxos/functions 0.8.4-main.84f28bd → 0.8.4-main.937b3ca

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 (161) hide show
  1. package/dist/lib/browser/index.mjs +1100 -363
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +1100 -363
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/errors.d.ts +121 -0
  8. package/dist/types/src/errors.d.ts.map +1 -0
  9. package/dist/types/src/example/fib.d.ts +7 -0
  10. package/dist/types/src/example/fib.d.ts.map +1 -0
  11. package/dist/types/src/example/forex-effect.d.ts +3 -0
  12. package/dist/types/src/example/forex-effect.d.ts.map +1 -0
  13. package/dist/types/src/example/index.d.ts +12 -0
  14. package/dist/types/src/example/index.d.ts.map +1 -0
  15. package/dist/types/src/example/reply.d.ts +3 -0
  16. package/dist/types/src/example/reply.d.ts.map +1 -0
  17. package/dist/types/src/example/sleep.d.ts +5 -0
  18. package/dist/types/src/example/sleep.d.ts.map +1 -0
  19. package/dist/types/src/index.d.ts +5 -6
  20. package/dist/types/src/index.d.ts.map +1 -1
  21. package/dist/types/src/operation-compatibility.test.d.ts +2 -0
  22. package/dist/types/src/operation-compatibility.test.d.ts.map +1 -0
  23. package/dist/types/src/protocol/functions-ai-http-client.d.ts +12 -0
  24. package/dist/types/src/protocol/functions-ai-http-client.d.ts.map +1 -0
  25. package/dist/types/src/protocol/index.d.ts +2 -0
  26. package/dist/types/src/protocol/index.d.ts.map +1 -0
  27. package/dist/types/src/protocol/protocol.d.ts +7 -0
  28. package/dist/types/src/protocol/protocol.d.ts.map +1 -0
  29. package/dist/types/src/protocol/protocol.test.d.ts +2 -0
  30. package/dist/types/src/protocol/protocol.test.d.ts.map +1 -0
  31. package/dist/types/src/sdk.d.ts +114 -0
  32. package/dist/types/src/sdk.d.ts.map +1 -0
  33. package/dist/types/src/services/credentials.d.ts +23 -3
  34. package/dist/types/src/services/credentials.d.ts.map +1 -1
  35. package/dist/types/src/services/event-logger.d.ts +74 -30
  36. package/dist/types/src/services/event-logger.d.ts.map +1 -1
  37. package/dist/types/src/services/function-invocation-service.d.ts +16 -0
  38. package/dist/types/src/services/function-invocation-service.d.ts.map +1 -0
  39. package/dist/types/src/services/index.d.ts +5 -7
  40. package/dist/types/src/services/index.d.ts.map +1 -1
  41. package/dist/types/src/services/queues.d.ts +33 -4
  42. package/dist/types/src/services/queues.d.ts.map +1 -1
  43. package/dist/types/src/services/tracing.d.ts +78 -5
  44. package/dist/types/src/services/tracing.d.ts.map +1 -1
  45. package/dist/types/src/types/Function.d.ts +52 -0
  46. package/dist/types/src/types/Function.d.ts.map +1 -0
  47. package/dist/types/src/types/Script.d.ts +21 -0
  48. package/dist/types/src/types/Script.d.ts.map +1 -0
  49. package/dist/types/src/types/Trigger.d.ts +121 -0
  50. package/dist/types/src/types/Trigger.d.ts.map +1 -0
  51. package/dist/types/src/types/TriggerEvent.d.ts +74 -0
  52. package/dist/types/src/types/TriggerEvent.d.ts.map +1 -0
  53. package/dist/types/src/types/index.d.ts +6 -0
  54. package/dist/types/src/types/index.d.ts.map +1 -0
  55. package/dist/types/src/types/url.d.ts +13 -0
  56. package/dist/types/src/types/url.d.ts.map +1 -0
  57. package/dist/types/tsconfig.tsbuildinfo +1 -1
  58. package/package.json +26 -66
  59. package/src/errors.ts +21 -0
  60. package/src/example/fib.ts +32 -0
  61. package/src/example/forex-effect.ts +40 -0
  62. package/src/example/index.ts +13 -0
  63. package/src/example/reply.ts +21 -0
  64. package/src/example/sleep.ts +24 -0
  65. package/src/index.ts +5 -8
  66. package/src/operation-compatibility.test.ts +185 -0
  67. package/src/protocol/functions-ai-http-client.ts +67 -0
  68. package/src/{executor → protocol}/index.ts +1 -1
  69. package/src/protocol/protocol.test.ts +59 -0
  70. package/src/protocol/protocol.ts +262 -0
  71. package/src/sdk.ts +289 -0
  72. package/src/services/credentials.ts +108 -4
  73. package/src/services/event-logger.ts +77 -37
  74. package/src/services/function-invocation-service.ts +37 -0
  75. package/src/services/index.ts +5 -7
  76. package/src/services/queues.ts +48 -8
  77. package/src/services/tracing.ts +151 -11
  78. package/src/types/Function.ts +82 -0
  79. package/src/types/Script.ts +34 -0
  80. package/src/types/Trigger.ts +143 -0
  81. package/src/types/TriggerEvent.ts +68 -0
  82. package/src/types/index.ts +9 -0
  83. package/src/types/url.ts +32 -0
  84. package/dist/lib/browser/bundler/index.mjs +0 -247
  85. package/dist/lib/browser/bundler/index.mjs.map +0 -7
  86. package/dist/lib/browser/chunk-54U464M4.mjs +0 -360
  87. package/dist/lib/browser/chunk-54U464M4.mjs.map +0 -7
  88. package/dist/lib/browser/edge/index.mjs +0 -69
  89. package/dist/lib/browser/edge/index.mjs.map +0 -7
  90. package/dist/lib/browser/testing/index.mjs +0 -79
  91. package/dist/lib/browser/testing/index.mjs.map +0 -7
  92. package/dist/lib/node-esm/bundler/index.mjs +0 -249
  93. package/dist/lib/node-esm/bundler/index.mjs.map +0 -7
  94. package/dist/lib/node-esm/chunk-XDSX35BS.mjs +0 -362
  95. package/dist/lib/node-esm/chunk-XDSX35BS.mjs.map +0 -7
  96. package/dist/lib/node-esm/edge/index.mjs +0 -71
  97. package/dist/lib/node-esm/edge/index.mjs.map +0 -7
  98. package/dist/lib/node-esm/testing/index.mjs +0 -80
  99. package/dist/lib/node-esm/testing/index.mjs.map +0 -7
  100. package/dist/types/src/bundler/bundler.d.ts +0 -50
  101. package/dist/types/src/bundler/bundler.d.ts.map +0 -1
  102. package/dist/types/src/bundler/bundler.test.d.ts +0 -2
  103. package/dist/types/src/bundler/bundler.test.d.ts.map +0 -1
  104. package/dist/types/src/bundler/index.d.ts +0 -2
  105. package/dist/types/src/bundler/index.d.ts.map +0 -1
  106. package/dist/types/src/edge/functions.d.ts +0 -16
  107. package/dist/types/src/edge/functions.d.ts.map +0 -1
  108. package/dist/types/src/edge/index.d.ts +0 -2
  109. package/dist/types/src/edge/index.d.ts.map +0 -1
  110. package/dist/types/src/executor/executor.d.ts +0 -8
  111. package/dist/types/src/executor/executor.d.ts.map +0 -1
  112. package/dist/types/src/executor/index.d.ts +0 -2
  113. package/dist/types/src/executor/index.d.ts.map +0 -1
  114. package/dist/types/src/handler.d.ts +0 -61
  115. package/dist/types/src/handler.d.ts.map +0 -1
  116. package/dist/types/src/schema.d.ts +0 -38
  117. package/dist/types/src/schema.d.ts.map +0 -1
  118. package/dist/types/src/services/ai.d.ts +0 -12
  119. package/dist/types/src/services/ai.d.ts.map +0 -1
  120. package/dist/types/src/services/database.d.ts +0 -15
  121. package/dist/types/src/services/database.d.ts.map +0 -1
  122. package/dist/types/src/services/function-call-service.d.ts +0 -16
  123. package/dist/types/src/services/function-call-service.d.ts.map +0 -1
  124. package/dist/types/src/services/service-container.d.ts +0 -46
  125. package/dist/types/src/services/service-container.d.ts.map +0 -1
  126. package/dist/types/src/services/tool-resolver.d.ts +0 -14
  127. package/dist/types/src/services/tool-resolver.d.ts.map +0 -1
  128. package/dist/types/src/testing/index.d.ts +0 -2
  129. package/dist/types/src/testing/index.d.ts.map +0 -1
  130. package/dist/types/src/testing/logger.d.ts +0 -5
  131. package/dist/types/src/testing/logger.d.ts.map +0 -1
  132. package/dist/types/src/testing/services.d.ts +0 -71
  133. package/dist/types/src/testing/services.d.ts.map +0 -1
  134. package/dist/types/src/trace.d.ts +0 -124
  135. package/dist/types/src/trace.d.ts.map +0 -1
  136. package/dist/types/src/translations.d.ts +0 -12
  137. package/dist/types/src/translations.d.ts.map +0 -1
  138. package/dist/types/src/types.d.ts +0 -411
  139. package/dist/types/src/types.d.ts.map +0 -1
  140. package/dist/types/src/url.d.ts +0 -17
  141. package/dist/types/src/url.d.ts.map +0 -1
  142. package/src/bundler/bundler.test.ts +0 -59
  143. package/src/bundler/bundler.ts +0 -292
  144. package/src/bundler/index.ts +0 -5
  145. package/src/edge/functions.ts +0 -64
  146. package/src/edge/index.ts +0 -9
  147. package/src/executor/executor.ts +0 -54
  148. package/src/handler.ts +0 -113
  149. package/src/schema.ts +0 -57
  150. package/src/services/ai.ts +0 -32
  151. package/src/services/database.ts +0 -50
  152. package/src/services/function-call-service.ts +0 -64
  153. package/src/services/service-container.ts +0 -127
  154. package/src/services/tool-resolver.ts +0 -31
  155. package/src/testing/index.ts +0 -5
  156. package/src/testing/logger.ts +0 -16
  157. package/src/testing/services.ts +0 -174
  158. package/src/trace.ts +0 -180
  159. package/src/translations.ts +0 -20
  160. package/src/types.ts +0 -211
  161. package/src/url.ts +0 -52
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forex-effect.d.ts","sourceRoot":"","sources":["../../../../src/example/forex-effect.ts"],"names":[],"mappings":";AAeA,wBAwBG"}
@@ -0,0 +1,12 @@
1
+ export declare namespace Example {
2
+ const fib: import("..").FunctionDefinition<{
3
+ readonly iterations?: number | undefined;
4
+ }, {
5
+ readonly result: string;
6
+ }, import("..").FunctionServices>;
7
+ const reply: import("..").FunctionDefinition<any, any, import("..").FunctionServices>;
8
+ const sleep: import("..").FunctionDefinition<{
9
+ readonly duration?: number | undefined;
10
+ }, void, import("..").FunctionServices>;
11
+ }
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/example/index.ts"],"names":[],"mappings":"AAQA,yBAAiB,OAAO,CAAC;IAChB,MAAM,GAAG;;;;qCAAO,CAAC;IACjB,MAAM,KAAK,0EAAS,CAAC;IACrB,MAAM,KAAK;;2CAAS,CAAC;CAC7B"}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("..").FunctionDefinition<any, any, import("..").FunctionServices>;
2
+ export default _default;
3
+ //# sourceMappingURL=reply.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reply.d.ts","sourceRoot":"","sources":["../../../../src/example/reply.ts"],"names":[],"mappings":";AAUA,wBAUG"}
@@ -0,0 +1,5 @@
1
+ declare const _default: import("..").FunctionDefinition<{
2
+ readonly duration?: number | undefined;
3
+ }, void, import("..").FunctionServices>;
4
+ export default _default;
5
+ //# sourceMappingURL=sleep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../../../src/example/sleep.ts"],"names":[],"mappings":";;;AASA,wBAcG"}
@@ -1,8 +1,7 @@
1
- export * from './handler';
2
- export * from './schema';
3
- export * from './trace';
4
- export * from './types';
5
- export * from './url';
1
+ export * from './errors';
2
+ export * from './example';
3
+ export * from './sdk';
6
4
  export * from './services';
7
- export * from './executor';
5
+ export * from './types';
6
+ export * from './protocol';
8
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=operation-compatibility.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-compatibility.test.d.ts","sourceRoot":"","sources":["../../../src/operation-compatibility.test.ts"],"names":[],"mappings":""}
@@ -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;AAItC,OAAO,EAAE,KAAK,eAAe,EAAc,MAAM,iBAAiB,CAAC;AACnE;;GAEG;AACH,eAAO,MAAM,iBAAiB,kDAAkD,CAAC;AAEjF,qBAAa,qBAAqB;IAChC,MAAM,CAAC,IAAI,GAAI,SAAS,eAAe,CAAC,kBAAkB,2BAyCrD;IAEL,MAAM,CAAC,KAAK,GAAI,SAAS,eAAe,CAAC,kBAAkB,sDACiB;CAC7E"}
@@ -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,7 @@
1
+ import { type FunctionProtocol } from '@dxos/protocols';
2
+ import { FunctionDefinition } from '../sdk';
3
+ /**
4
+ * Wraps a function handler made with `defineFunction` to a protocol that the functions-runtime expects.
5
+ */
6
+ export declare const wrapFunctionHandler: (func: FunctionDefinition) => FunctionProtocol.Func;
7
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../../src/protocol/protocol.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGxD,OAAO,EAAE,kBAAkB,EAAyB,MAAM,QAAQ,CAAC;AAKnE;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,kBAAkB,KAAG,gBAAgB,CAAC,IAwE/E,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,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,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAO,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EACL,KAAK,kBAAkB,EACv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AG;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
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,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,MAAM,CAAC;IAGhB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;;IAKE;;OAEG;sBACe,CAAC,KAAK,EAAE,eAAe,KAAK,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAE1E;;;OAGG;mBACY,CAAC,KAAK,EAAE,eAAe,KAAK,OAAO,CAAC,iBAAiB,CAAC;;AAZzE,qBAAa,kBAAmB,SAAQ,uBAcrC;CAAG;AAEN,qBAAa,4BAA6B,YAAW,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC;IAC9E,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAAX,WAAW,GAAE,iBAAiB,EAAO;IAElE,cAAc,CAAC,WAAW,EAAE,iBAA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C,CAO3G;IAEL,MAAM,CAAC,eAAe,GAAI,aAAa,iBAAiB,EAAE,mDACyB;IAEnF,MAAM,CAAC,WAAW,GAChB,aAAa;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;KAClD,EAAE,sFAgBD;IAEJ,MAAM,CAAC,iBAAiB,GAAI,cAAqB;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAO,8DA0CvE;CACL;AAED,qBAAa,4BAA6B,YAAW,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC;IAC9E,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAAX,WAAW,GAAE,iBAAiB,EAAO;IAElE,cAAc,CAAC,WAAW,EAAE,iBAAiB,EAAE,GAAG,4BAA4B;IAKxE,gBAAgB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAItE,aAAa,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAQxE;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,EAAE,OAAO,QAAQ,GAAG,OAAO,uFAItE,CAAC"}
@@ -1,37 +1,81 @@
1
- import { Effect, Context } from 'effect';
1
+ import * as Context from 'effect/Context';
2
+ import * as Effect from 'effect/Effect';
3
+ 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 type: "compute-input";
49
+ readonly value: any;
50
+ readonly nodeId: string;
51
+ readonly property: string;
52
+ } | {
53
+ readonly type: "compute-output";
54
+ readonly value: any;
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,MAAM,QAAQ,CAAC;AAGzC,OAAO,EAAO,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,MAAM,YAAY,GACpB;IACE,IAAI,EAAE,eAAe,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC7B,GACD;IACE,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GA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MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAO,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAO,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,eAAO,MAAM,mBAAmB;;;IAI5B;;OAEG;;;;;IAMH;;OAEG;;;;;;;;;;;;;;;;IAoBN,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEjF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;wBAEyD,CAAC;;kBAOjE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI;qBAAmB,MAAM,GAAG,SAAS;;AAL3F;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,uBAGrC;IACD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAGlD;IAEF;;OAEG;IACH,MAAM,CAAC,gBAAgB,yDAWrB;CACH;AAED,eAAO,MAAM,cAAc,GAAI,MAAM,GAAG,mDAWpC,CAAC;AAEL,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAAE,CAAC,EAAE,CAAC,OAAK,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,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,10 +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';
9
- export * from './tool-resolver';
4
+ export { createEventLogger, createDefectLogger } from './event-logger';
5
+ export * from './function-invocation-service';
6
+ export * from './queues';
7
+ export * from './tracing';
10
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;AACxC,cAAc,iBAAiB,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';
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';
2
5
  import type { Queue, QueueAPI, QueueFactory } from '@dxos/echo-db';
3
- declare const QueueService_base: Context.TagClass<QueueService, "QueueService", {
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
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,QAAQ,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;;IAK/D;;OAEG;qBACc,QAAQ;IAEzB;;OAEG;2BAEoB,KAAK,GAAG,SAAS;;AAZ5C,qBAAa,YAAa,SAAQ,iBAc/B;IACD,MAAM,CAAC,YAAY,0CAUhB;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,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzC,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,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,EAC1D,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,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,UAAU;QACzE,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,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,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