@dxos/functions 0.8.4-main.b97322e → 0.8.4-main.bcb3aa67d6

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 (191) hide show
  1. package/README.md +4 -6
  2. package/dist/lib/neutral/Trace.mjs +34 -0
  3. package/dist/lib/neutral/Trace.mjs.map +7 -0
  4. package/dist/lib/neutral/chunk-BHLSCAA2.mjs +123 -0
  5. package/dist/lib/neutral/chunk-BHLSCAA2.mjs.map +7 -0
  6. package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
  7. package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
  8. package/dist/lib/neutral/chunk-Z2XDJJVH.mjs +49 -0
  9. package/dist/lib/neutral/chunk-Z2XDJJVH.mjs.map +7 -0
  10. package/dist/lib/neutral/fib-S6PPI4UW.mjs +23 -0
  11. package/dist/lib/neutral/fib-S6PPI4UW.mjs.map +7 -0
  12. package/dist/lib/neutral/index.mjs +1245 -0
  13. package/dist/lib/neutral/index.mjs.map +7 -0
  14. package/dist/lib/neutral/meta.json +1 -0
  15. package/dist/lib/neutral/reply-TOHXEG7V.mjs +19 -0
  16. package/dist/lib/neutral/reply-TOHXEG7V.mjs.map +7 -0
  17. package/dist/lib/neutral/sleep-QPSZDPEH.mjs +15 -0
  18. package/dist/lib/neutral/sleep-QPSZDPEH.mjs.map +7 -0
  19. package/dist/types/src/Trace.d.ts +135 -0
  20. package/dist/types/src/Trace.d.ts.map +1 -0
  21. package/dist/types/src/errors.d.ts +91 -38
  22. package/dist/types/src/errors.d.ts.map +1 -1
  23. package/dist/types/src/example/definitions.d.ts +11 -0
  24. package/dist/types/src/example/definitions.d.ts.map +1 -0
  25. package/dist/types/src/example/fib.d.ts +8 -0
  26. package/dist/types/src/example/fib.d.ts.map +1 -0
  27. package/dist/types/src/example/forex-effect.d.ts +3 -0
  28. package/dist/types/src/example/forex-effect.d.ts.map +1 -0
  29. package/dist/types/src/example/index.d.ts +4 -0
  30. package/dist/types/src/example/index.d.ts.map +1 -0
  31. package/dist/types/src/example/reply.d.ts +4 -0
  32. package/dist/types/src/example/reply.d.ts.map +1 -0
  33. package/dist/types/src/example/sleep.d.ts +6 -0
  34. package/dist/types/src/example/sleep.d.ts.map +1 -0
  35. package/dist/types/src/index.d.ts +9 -7
  36. package/dist/types/src/index.d.ts.map +1 -1
  37. package/dist/types/src/process/Process.d.ts +247 -0
  38. package/dist/types/src/process/Process.d.ts.map +1 -0
  39. package/dist/types/src/process/ServiceResolver.d.ts +74 -0
  40. package/dist/types/src/process/ServiceResolver.d.ts.map +1 -0
  41. package/dist/types/src/process/StorageService.d.ts +58 -0
  42. package/dist/types/src/process/StorageService.d.ts.map +1 -0
  43. package/dist/types/src/protocol/functions-ai-http-client.d.ts +12 -0
  44. package/dist/types/src/protocol/functions-ai-http-client.d.ts.map +1 -0
  45. package/dist/types/src/protocol/index.d.ts +2 -0
  46. package/dist/types/src/protocol/index.d.ts.map +1 -0
  47. package/dist/types/src/protocol/protocol.d.ts +7 -0
  48. package/dist/types/src/protocol/protocol.d.ts.map +1 -0
  49. package/dist/types/src/protocol/protocol.test.d.ts +2 -0
  50. package/dist/types/src/protocol/protocol.test.d.ts.map +1 -0
  51. package/dist/types/src/sdk.d.ts +14 -0
  52. package/dist/types/src/sdk.d.ts.map +1 -0
  53. package/dist/types/src/services/credentials.d.ts +22 -3
  54. package/dist/types/src/services/credentials.d.ts.map +1 -1
  55. package/dist/types/src/services/event-logger.d.ts +74 -30
  56. package/dist/types/src/services/event-logger.d.ts.map +1 -1
  57. package/dist/types/src/services/function-invocation-service.d.ts +17 -0
  58. package/dist/types/src/services/function-invocation-service.d.ts.map +1 -0
  59. package/dist/types/src/services/index.d.ts +5 -5
  60. package/dist/types/src/services/index.d.ts.map +1 -1
  61. package/dist/types/src/services/queues.d.ts +26 -7
  62. package/dist/types/src/services/queues.d.ts.map +1 -1
  63. package/dist/types/src/services/tracing.d.ts +93 -7
  64. package/dist/types/src/services/tracing.d.ts.map +1 -1
  65. package/dist/types/src/types/Script.d.ts +22 -0
  66. package/dist/types/src/types/Script.d.ts.map +1 -0
  67. package/dist/types/src/types/Trigger.d.ts +120 -0
  68. package/dist/types/src/types/Trigger.d.ts.map +1 -0
  69. package/dist/types/src/types/TriggerEvent.d.ts +75 -0
  70. package/dist/types/src/types/TriggerEvent.d.ts.map +1 -0
  71. package/dist/types/src/types/index.d.ts +5 -0
  72. package/dist/types/src/types/index.d.ts.map +1 -0
  73. package/dist/types/src/types/url.d.ts +13 -0
  74. package/dist/types/src/types/url.d.ts.map +1 -0
  75. package/dist/types/tsconfig.tsbuildinfo +1 -1
  76. package/package.json +32 -69
  77. package/src/Trace.ts +162 -0
  78. package/src/errors.ts +13 -5
  79. package/src/example/definitions.ts +48 -0
  80. package/src/example/fib.ts +22 -0
  81. package/src/example/forex-effect.ts +40 -0
  82. package/src/example/index.ts +12 -0
  83. package/src/example/reply.ts +18 -0
  84. package/src/example/sleep.ts +15 -0
  85. package/src/index.ts +9 -9
  86. package/src/process/Process.ts +457 -0
  87. package/src/process/ServiceResolver.ts +173 -0
  88. package/src/process/StorageService.ts +99 -0
  89. package/src/protocol/functions-ai-http-client.ts +67 -0
  90. package/src/{executor → protocol}/index.ts +1 -1
  91. package/src/protocol/protocol.test.ts +59 -0
  92. package/src/protocol/protocol.ts +268 -0
  93. package/src/sdk.ts +39 -0
  94. package/src/services/credentials.ts +101 -3
  95. package/src/services/event-logger.ts +77 -37
  96. package/src/services/function-invocation-service.ts +38 -0
  97. package/src/services/index.ts +5 -5
  98. package/src/services/queues.ts +46 -11
  99. package/src/services/tracing.ts +172 -14
  100. package/src/types/Script.ts +38 -0
  101. package/src/types/Trigger.ts +154 -0
  102. package/src/types/TriggerEvent.ts +62 -0
  103. package/src/types/index.ts +8 -0
  104. package/src/types/url.ts +32 -0
  105. package/dist/lib/browser/bundler/index.mjs +0 -247
  106. package/dist/lib/browser/bundler/index.mjs.map +0 -7
  107. package/dist/lib/browser/chunk-3NGCSUEW.mjs +0 -328
  108. package/dist/lib/browser/chunk-3NGCSUEW.mjs.map +0 -7
  109. package/dist/lib/browser/edge/index.mjs +0 -69
  110. package/dist/lib/browser/edge/index.mjs.map +0 -7
  111. package/dist/lib/browser/index.mjs +0 -503
  112. package/dist/lib/browser/index.mjs.map +0 -7
  113. package/dist/lib/browser/meta.json +0 -1
  114. package/dist/lib/browser/testing/index.mjs +0 -91
  115. package/dist/lib/browser/testing/index.mjs.map +0 -7
  116. package/dist/lib/node-esm/bundler/index.mjs +0 -249
  117. package/dist/lib/node-esm/bundler/index.mjs.map +0 -7
  118. package/dist/lib/node-esm/chunk-FJ2MU7TL.mjs +0 -330
  119. package/dist/lib/node-esm/chunk-FJ2MU7TL.mjs.map +0 -7
  120. package/dist/lib/node-esm/edge/index.mjs +0 -71
  121. package/dist/lib/node-esm/edge/index.mjs.map +0 -7
  122. package/dist/lib/node-esm/index.mjs +0 -504
  123. package/dist/lib/node-esm/index.mjs.map +0 -7
  124. package/dist/lib/node-esm/meta.json +0 -1
  125. package/dist/lib/node-esm/testing/index.mjs +0 -92
  126. package/dist/lib/node-esm/testing/index.mjs.map +0 -7
  127. package/dist/types/src/bundler/bundler.d.ts +0 -50
  128. package/dist/types/src/bundler/bundler.d.ts.map +0 -1
  129. package/dist/types/src/bundler/bundler.test.d.ts +0 -2
  130. package/dist/types/src/bundler/bundler.test.d.ts.map +0 -1
  131. package/dist/types/src/bundler/index.d.ts +0 -2
  132. package/dist/types/src/bundler/index.d.ts.map +0 -1
  133. package/dist/types/src/edge/functions.d.ts +0 -16
  134. package/dist/types/src/edge/functions.d.ts.map +0 -1
  135. package/dist/types/src/edge/index.d.ts +0 -2
  136. package/dist/types/src/edge/index.d.ts.map +0 -1
  137. package/dist/types/src/executor/executor.d.ts +0 -8
  138. package/dist/types/src/executor/executor.d.ts.map +0 -1
  139. package/dist/types/src/executor/index.d.ts +0 -2
  140. package/dist/types/src/executor/index.d.ts.map +0 -1
  141. package/dist/types/src/handler.d.ts +0 -62
  142. package/dist/types/src/handler.d.ts.map +0 -1
  143. package/dist/types/src/schema.d.ts +0 -38
  144. package/dist/types/src/schema.d.ts.map +0 -1
  145. package/dist/types/src/services/database.d.ts +0 -29
  146. package/dist/types/src/services/database.d.ts.map +0 -1
  147. package/dist/types/src/services/function-call-service.d.ts +0 -16
  148. package/dist/types/src/services/function-call-service.d.ts.map +0 -1
  149. package/dist/types/src/services/service-container.d.ts +0 -56
  150. package/dist/types/src/services/service-container.d.ts.map +0 -1
  151. package/dist/types/src/services/service-registry.d.ts +0 -29
  152. package/dist/types/src/services/service-registry.d.ts.map +0 -1
  153. package/dist/types/src/services/service-registry.test.d.ts +0 -2
  154. package/dist/types/src/services/service-registry.test.d.ts.map +0 -1
  155. package/dist/types/src/testing/index.d.ts +0 -3
  156. package/dist/types/src/testing/index.d.ts.map +0 -1
  157. package/dist/types/src/testing/layer.d.ts +0 -10
  158. package/dist/types/src/testing/layer.d.ts.map +0 -1
  159. package/dist/types/src/testing/logger.d.ts +0 -5
  160. package/dist/types/src/testing/logger.d.ts.map +0 -1
  161. package/dist/types/src/testing/services.d.ts +0 -70
  162. package/dist/types/src/testing/services.d.ts.map +0 -1
  163. package/dist/types/src/trace.d.ts +0 -124
  164. package/dist/types/src/trace.d.ts.map +0 -1
  165. package/dist/types/src/translations.d.ts +0 -12
  166. package/dist/types/src/translations.d.ts.map +0 -1
  167. package/dist/types/src/types.d.ts +0 -411
  168. package/dist/types/src/types.d.ts.map +0 -1
  169. package/dist/types/src/url.d.ts +0 -17
  170. package/dist/types/src/url.d.ts.map +0 -1
  171. package/src/bundler/bundler.test.ts +0 -59
  172. package/src/bundler/bundler.ts +0 -292
  173. package/src/bundler/index.ts +0 -5
  174. package/src/edge/functions.ts +0 -64
  175. package/src/edge/index.ts +0 -9
  176. package/src/executor/executor.ts +0 -54
  177. package/src/handler.ts +0 -120
  178. package/src/schema.ts +0 -57
  179. package/src/services/database.ts +0 -70
  180. package/src/services/function-call-service.ts +0 -64
  181. package/src/services/service-container.ts +0 -113
  182. package/src/services/service-registry.test.ts +0 -42
  183. package/src/services/service-registry.ts +0 -56
  184. package/src/testing/index.ts +0 -6
  185. package/src/testing/layer.ts +0 -31
  186. package/src/testing/logger.ts +0 -16
  187. package/src/testing/services.ts +0 -168
  188. package/src/trace.ts +0 -180
  189. package/src/translations.ts +0 -20
  190. package/src/types.ts +0 -211
  191. package/src/url.ts +0 -52
@@ -1,68 +1,121 @@
1
- import { BaseError } from '@dxos/errors';
1
+ import { BaseError, type BaseErrorOptions } from '@dxos/errors';
2
2
  declare const ServiceNotAvailableError_base: {
3
- new (message: string, options?: import("@dxos/errors").BaseErrorOptions): {
4
- "__#1@#code": "SERVICE_NOT_AVAILABLE";
5
- "__#1@#context": Record<string, unknown>;
6
- readonly name: "SERVICE_NOT_AVAILABLE";
7
- readonly code: "SERVICE_NOT_AVAILABLE";
8
- readonly _tag: "SERVICE_NOT_AVAILABLE";
9
- readonly context: Record<string, unknown>;
10
- message: string;
3
+ new (options?: BaseErrorOptions): {
4
+ name: "ServiceNotAvailable";
5
+ context: Record<string, unknown>;
6
+ readonly message: string;
7
+ readonly _tag: "ServiceNotAvailable";
11
8
  stack?: string;
12
9
  cause?: unknown;
13
10
  };
14
- code: "SERVICE_NOT_AVAILABLE";
11
+ name: "ServiceNotAvailable";
15
12
  is(error: unknown): error is BaseError;
16
- wrap(message: string, options?: Omit<import("@dxos/errors").BaseErrorOptions, "cause">): (error: unknown) => {
17
- "__#1@#code": "SERVICE_NOT_AVAILABLE";
18
- "__#1@#context": Record<string, unknown>;
19
- readonly name: "SERVICE_NOT_AVAILABLE";
20
- readonly code: "SERVICE_NOT_AVAILABLE";
21
- readonly _tag: "SERVICE_NOT_AVAILABLE";
22
- readonly context: Record<string, unknown>;
23
- message: string;
13
+ wrap(options?: Omit<BaseErrorOptions, "cause"> & {
14
+ ifTypeDiffers?: boolean;
15
+ }): (error: unknown) => {
16
+ name: "ServiceNotAvailable";
17
+ context: Record<string, unknown>;
18
+ readonly message: string;
19
+ readonly _tag: "ServiceNotAvailable";
24
20
  stack?: string;
25
21
  cause?: unknown;
26
22
  };
27
- extend<Code extends string>(code: Code): any;
23
+ extend<Name extends string = string>(name: Name, message?: string): any;
24
+ isError(error: unknown): error is Error;
28
25
  captureStackTrace(targetObject: object, constructorOpt?: Function): void;
29
26
  prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
30
27
  stackTraceLimit: number;
31
28
  };
32
29
  export declare class ServiceNotAvailableError extends ServiceNotAvailableError_base {
33
- constructor(serviceName: string);
30
+ constructor(service: string, options?: Omit<BaseErrorOptions, 'context'>);
31
+ }
32
+ declare const FunctionNotFoundError_base: {
33
+ new (options?: BaseErrorOptions): {
34
+ name: "FunctionNotFound";
35
+ context: Record<string, unknown>;
36
+ readonly message: string;
37
+ readonly _tag: "FunctionNotFound";
38
+ stack?: string;
39
+ cause?: unknown;
40
+ };
41
+ name: "FunctionNotFound";
42
+ is(error: unknown): error is BaseError;
43
+ wrap(options?: Omit<BaseErrorOptions, "cause"> & {
44
+ ifTypeDiffers?: boolean;
45
+ }): (error: unknown) => {
46
+ name: "FunctionNotFound";
47
+ context: Record<string, unknown>;
48
+ readonly message: string;
49
+ readonly _tag: "FunctionNotFound";
50
+ stack?: string;
51
+ cause?: unknown;
52
+ };
53
+ extend<Name extends string = string>(name: Name, message?: string): any;
54
+ isError(error: unknown): error is Error;
55
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
56
+ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
57
+ stackTraceLimit: number;
58
+ };
59
+ export declare class FunctionNotFoundError extends FunctionNotFoundError_base {
60
+ constructor(functionKey: string, options?: Omit<BaseErrorOptions, 'context'>);
34
61
  }
35
62
  declare const FunctionError_base: {
36
- new (message: string, options?: import("@dxos/errors").BaseErrorOptions): {
37
- "__#1@#code": "FUNCTION_ERROR";
38
- "__#1@#context": Record<string, unknown>;
39
- readonly name: "FUNCTION_ERROR";
40
- readonly code: "FUNCTION_ERROR";
41
- readonly _tag: "FUNCTION_ERROR";
42
- readonly context: Record<string, unknown>;
43
- message: string;
63
+ new (options?: BaseErrorOptions): {
64
+ name: "FunctionError";
65
+ context: Record<string, unknown>;
66
+ readonly message: string;
67
+ readonly _tag: "FunctionError";
44
68
  stack?: string;
45
69
  cause?: unknown;
46
70
  };
47
- code: "FUNCTION_ERROR";
71
+ name: "FunctionError";
48
72
  is(error: unknown): error is BaseError;
49
- wrap(message: string, options?: Omit<import("@dxos/errors").BaseErrorOptions, "cause">): (error: unknown) => {
50
- "__#1@#code": "FUNCTION_ERROR";
51
- "__#1@#context": Record<string, unknown>;
52
- readonly name: "FUNCTION_ERROR";
53
- readonly code: "FUNCTION_ERROR";
54
- readonly _tag: "FUNCTION_ERROR";
55
- readonly context: Record<string, unknown>;
56
- message: string;
73
+ wrap(options?: Omit<BaseErrorOptions, "cause"> & {
74
+ ifTypeDiffers?: boolean;
75
+ }): (error: unknown) => {
76
+ name: "FunctionError";
77
+ context: Record<string, unknown>;
78
+ readonly message: string;
79
+ readonly _tag: "FunctionError";
57
80
  stack?: string;
58
81
  cause?: unknown;
59
82
  };
60
- extend<Code extends string>(code: Code): any;
83
+ extend<Name extends string = string>(name: Name, message?: string): any;
84
+ isError(error: unknown): error is Error;
61
85
  captureStackTrace(targetObject: object, constructorOpt?: Function): void;
62
86
  prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
63
87
  stackTraceLimit: number;
64
88
  };
65
89
  export declare class FunctionError extends FunctionError_base {
66
90
  }
91
+ declare const TriggerStateNotFoundError_base: {
92
+ new (options?: BaseErrorOptions): {
93
+ name: "TriggerStateNotFound";
94
+ context: Record<string, unknown>;
95
+ readonly message: string;
96
+ readonly _tag: "TriggerStateNotFound";
97
+ stack?: string;
98
+ cause?: unknown;
99
+ };
100
+ name: "TriggerStateNotFound";
101
+ is(error: unknown): error is BaseError;
102
+ wrap(options?: Omit<BaseErrorOptions, "cause"> & {
103
+ ifTypeDiffers?: boolean;
104
+ }): (error: unknown) => {
105
+ name: "TriggerStateNotFound";
106
+ context: Record<string, unknown>;
107
+ readonly message: string;
108
+ readonly _tag: "TriggerStateNotFound";
109
+ stack?: string;
110
+ cause?: unknown;
111
+ };
112
+ extend<Name extends string = string>(name: Name, message?: string): any;
113
+ isError(error: unknown): error is Error;
114
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
115
+ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
116
+ stackTraceLimit: number;
117
+ };
118
+ export declare class TriggerStateNotFoundError extends TriggerStateNotFoundError_base {
119
+ }
67
120
  export {};
68
121
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/errors.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzC,qBAAa,wBAAyB,SAAQ,6BAAyC;gBACzE,WAAW,EAAE,MAAM;CAGhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAED,qBAAa,aAAc,SAAQ,kBAAkC;CAAG"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/errors.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;;;;;;;;;;;;;qBAiB8L,CAAC;;;;;;;;;;;;;;;AAf/P,qBAAa,wBAAyB,SAAQ,6BAAgE;gBAChG,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC;CAGzE;;;;;;;;;;;;;qBAW6P,CAAC;;;;;;;;;;;;;;;AAT/P,qBAAa,qBAAsB,SAAQ,0BAA0D;gBACvF,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC;CAG7E;;;;;;;;;;;;;qBAK6P,CAAC;;;;;;;;;;;;;;;AAH/P,qBAAa,aAAc,SAAQ,kBAA8D;CAAG;;;;;;;;;;;;;qBAG0J,CAAC;;;;;;;;;;;;;;;AAD/P,qBAAa,yBAA0B,SAAQ,8BAAmE;CAAG"}
@@ -0,0 +1,11 @@
1
+ import { Operation } from '@dxos/operation';
2
+ export declare const Fibonacci: Operation.Definition<{
3
+ readonly iterations?: number | undefined;
4
+ }, {
5
+ readonly result: string;
6
+ }, never>;
7
+ export declare const Reply: Operation.Definition<any, any, never>;
8
+ export declare const Sleep: Operation.Definition<{
9
+ readonly duration?: number | undefined;
10
+ }, void, never>;
11
+ //# sourceMappingURL=definitions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../../../src/example/definitions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,eAAO,MAAM,SAAS;;;;SAepB,CAAC;AAEH,eAAO,MAAM,KAAK,uCAQhB,CAAC;AAEH,eAAO,MAAM,KAAK;;eAahB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { Operation } from '@dxos/operation';
2
+ declare const _default: Operation.WithHandler<Operation.Definition<{
3
+ readonly iterations?: number | undefined;
4
+ }, {
5
+ readonly result: string;
6
+ }, never>>;
7
+ export default _default;
8
+ //# sourceMappingURL=fib.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fib.d.ts","sourceRoot":"","sources":["../../../../src/example/fib.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;;;;;;AAG5C,wBAYE"}
@@ -0,0 +1,3 @@
1
+ declare const _default: any;
2
+ export default _default;
3
+ //# sourceMappingURL=forex-effect.d.ts.map
@@ -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,4 @@
1
+ import { OperationHandlerSet } from '@dxos/operation';
2
+ export * from './definitions';
3
+ export declare const ExampleHandlers: OperationHandlerSet.OperationHandlerSet;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/example/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,cAAc,eAAe,CAAC;AAE9B,eAAO,MAAM,eAAe,yCAI3B,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Operation } from '@dxos/operation';
2
+ declare const _default: Operation.WithHandler<Operation.Definition<any, any, never>>;
3
+ export default _default;
4
+ //# sourceMappingURL=reply.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reply.d.ts","sourceRoot":"","sources":["../../../../src/example/reply.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;;AAG5C,wBAOE"}
@@ -0,0 +1,6 @@
1
+ import { Operation } from '@dxos/operation';
2
+ declare const _default: Operation.WithHandler<Operation.Definition<{
3
+ readonly duration?: number | undefined;
4
+ }, void, never>>;
5
+ export default _default;
6
+ //# sourceMappingURL=sleep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../../../src/example/sleep.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;;;;AAE5C,wBAME"}
@@ -1,9 +1,11 @@
1
- export * from './handler';
2
- export * from './schema';
3
- export * from './trace';
4
- export * from './types';
5
- export * from './url';
6
- export * from './services';
7
- export * from './executor';
8
1
  export * from './errors';
2
+ export * from './example';
3
+ export * as Process from './process/Process';
4
+ export * as ServiceResolver from './process/ServiceResolver';
5
+ export * from './process/StorageService';
6
+ export * from './sdk';
7
+ export * from './services';
8
+ export * from './types';
9
+ export * from './protocol';
10
+ export * as Trace from './Trace';
9
11
  //# 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;AAC3B,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,eAAe,MAAM,2BAA2B,CAAC;AAC7D,cAAc,0BAA0B,CAAC;AACzC,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC"}
@@ -0,0 +1,247 @@
1
+ import * as Scope from 'effect/Scope';
2
+ import * as Effect from 'effect/Effect';
3
+ import * as Schema from 'effect/Schema';
4
+ import type * as Exit from 'effect/Exit';
5
+ import * as Context from 'effect/Context';
6
+ import type * as Types from 'effect/Types';
7
+ import { Operation, OperationHandlerSet } from '@dxos/operation';
8
+ import type { TracingService } from '../services/tracing';
9
+ import * as Option from 'effect/Option';
10
+ import type { Atom } from '@effect-atom/atom';
11
+ import type { ObjectId } from '@dxos/protocols';
12
+ import * as Trace from '../Trace';
13
+ /** Opaque process id (arbitrary string). */
14
+ export declare const ID: Schema.brand<typeof Schema.String, "ProcessId">;
15
+ export type ID = Schema.Schema.Type<typeof ID>;
16
+ /**
17
+ * A running process callbacks.
18
+ *
19
+ * Process lifecycle: Initial -> Running <-> Suspended -> Terminated.
20
+ *
21
+ * - onSpawn -> called once when the process is spawned.
22
+ * - onInput -> called for every input submitted to the process.
23
+ * - onAlarm -> called for processes scheduling alarms.
24
+ * - onChildEvent -> called when child process produces output or exits.
25
+ */
26
+ export interface Callbacks<I, O, R> {
27
+ /**
28
+ * Called when the process is spawned.
29
+ * Not called for processes that are resumed from a previously suspended state.
30
+ *
31
+ * @returns A signal indicating to the runtime whether the process is finished, or should be resumed later.
32
+ * @throws Throwing in the handler will terminate the process with an error.
33
+ *
34
+ * Note: This function should aim to complete in under 5 seconds to avoid exceeding limits in serverless environments.
35
+ */
36
+ onSpawn(): Effect.Effect<void, never, R | BaseServices>;
37
+ /**
38
+ * Called when there's input available to process.
39
+ *
40
+ * The function can be called in parallel.
41
+ *
42
+ * @returns A signal indicating to the runtime whether the process is finished, or should be resumed later.
43
+ * @throws Throwing in the handler will terminate the process with an error.
44
+ *
45
+ * Note: This function should aim to complete in under 5 seconds to avoid exceeding limits in serverless environments.
46
+ */
47
+ onInput(input: I): Effect.Effect<void, never, R | BaseServices>;
48
+ /**
49
+ * Called when the process's alarm is triggered.
50
+ *
51
+ * @throws Throwing in the handler will terminate the process with an error.
52
+ */
53
+ onAlarm(): Effect.Effect<void, never, R | BaseServices>;
54
+ /**
55
+ * Called when the process's child process produces output or exits.
56
+ *
57
+ * This allows the parent process to hibernate while a long-running child process is running.
58
+ */
59
+ onChildEvent(event: ChildEvent<unknown>): Effect.Effect<void, never, R | BaseServices>;
60
+ }
61
+ /**
62
+ * Services that are always available to all processes.
63
+ */
64
+ export type BaseServices = TracingService | Trace.TraceService;
65
+ export type ChildEvent<T> = {
66
+ readonly _tag: 'output';
67
+ readonly pid: ID;
68
+ readonly data: T;
69
+ } | {
70
+ readonly _tag: 'exited';
71
+ readonly pid: ID;
72
+ readonly result: Exit.Exit<void>;
73
+ };
74
+ export interface ProcessContext<I, O> {
75
+ readonly id: ID;
76
+ /**
77
+ * Parameters assigned during process creation.
78
+ */
79
+ readonly params: Params;
80
+ /**
81
+ * Complete this process with sucessful result.
82
+ * No additional events will be pushed to the process.
83
+ */
84
+ succeed(): void;
85
+ /**
86
+ * Complete this process with an error.
87
+ * No additional events will be pushed to the process.
88
+ */
89
+ fail(error: Error): void;
90
+ /**
91
+ * Submit output of the process.
92
+ */
93
+ submitOutput(output: O): void;
94
+ /**
95
+ * Set an alarm for the process to be woken up later.
96
+ *
97
+ * @param timeout - Optional timeout in milliseconds. If not provided, the process is woken up as soon as possible.
98
+ */
99
+ setAlarm(timeout?: number): void;
100
+ }
101
+ /**
102
+ * Generic parameters for a all processes.
103
+ */
104
+ export interface Params {
105
+ /**
106
+ * Process name for debugging purposes.
107
+ */
108
+ readonly name: string | null;
109
+ /**
110
+ * Target object that this process is assigned to.
111
+ */
112
+ readonly target: ObjectId | null;
113
+ }
114
+ export declare const ProcessTypeId: "~@dxos/functions/Process";
115
+ export type ProcessTypeId = typeof ProcessTypeId;
116
+ /**
117
+ * A process (factory).
118
+ * Can be instantiated mutlitple times to produce new runtime instance with separate state and callbacks.
119
+ * `create` is used to instantiate a new process.
120
+ * Can store runtime state in scope of `create` function.
121
+ */
122
+ export interface Process<I, O, R> extends Process.Variance<I, O, R> {
123
+ /**
124
+ * Unique identifier for the executable in the reverse DNS format.
125
+ */
126
+ readonly key: string;
127
+ /**
128
+ * Human-readable label from {@link MakeExecutableOpts.name} when provided.
129
+ */
130
+ readonly name?: string;
131
+ readonly services: readonly Context.Tag<any, any>[];
132
+ /**
133
+ * Create a new instance of the process.
134
+ */
135
+ create(ctx: ProcessContext<I, O>): Effect.Effect<Callbacks<I, O, R>, never, R | BaseServices | Scope.Scope>;
136
+ }
137
+ export declare const isProcess: (executable: unknown) => executable is Process.Any;
138
+ export declare namespace Process {
139
+ interface Variance<I, O, R> {
140
+ readonly [ProcessTypeId]: {
141
+ readonly _Input: Types.Contravariant<I>;
142
+ readonly _Output: Types.Covariant<O>;
143
+ readonly _Requirements: Types.Covariant<R>;
144
+ };
145
+ }
146
+ type Any = Process<any, any, never>;
147
+ }
148
+ export interface MakeProcessOpts {
149
+ /**
150
+ * Unique identifier for the process in the reverse DNS format.
151
+ */
152
+ readonly key: string;
153
+ readonly input: Schema.Schema.AnyNoContext;
154
+ readonly output: Schema.Schema.AnyNoContext;
155
+ readonly services: readonly Context.Tag<any, any>[];
156
+ }
157
+ export declare const make: <const Opts extends Types.NoExcessProperties<MakeProcessOpts, Opts>>(opts: Opts, create: (ctx: ProcessContext<Schema.Schema.Type<Opts["input"]>, Schema.Schema.Type<Opts["output"]>>) => Effect.Effect<Partial<Callbacks<Schema.Schema.Type<Opts["input"]>, Schema.Schema.Type<Opts["output"]>, Context.Tag.Identifier<NonNullable<Opts["services"]>[number]>>>, never, Context.Tag.Identifier<NonNullable<Opts["services"]>[number]> | BaseServices | Scope.Scope>) => Process<Schema.Schema.Type<Opts["input"]>, Schema.Schema.Type<Opts["output"]>, Context.Tag.Identifier<NonNullable<Opts["services"]>[number]>>;
158
+ export declare const fromOperation: <const Op extends Operation.Definition.Any>(op: Op, handler: OperationHandlerSet.OperationHandlerSet) => Process<Operation.Definition.Input<Op>, Operation.Definition.Output<Op>, Operation.Definition.Services<Op>>;
159
+ /**
160
+ * Runtime state of a process.
161
+ */
162
+ export declare enum State {
163
+ RUNNING = "RUNNING",
164
+ HYBERNATING = "HYBERNATING",
165
+ IDLE = "IDLE",
166
+ TERMINATING = "TERMINATING",
167
+ TERMINATED = "TERMINATED",
168
+ SUCCEEDED = "SUCCEEDED",
169
+ FAILED = "FAILED"
170
+ }
171
+ /**
172
+ * Read-only view of a process tree
173
+ */
174
+ export interface Monitor {
175
+ /**
176
+ * Get the current state of the process tree.
177
+ */
178
+ processTree: Effect.Effect<readonly Info[]>;
179
+ /**
180
+ * Atom for the process tree.
181
+ */
182
+ processTreeAtom: Atom.Atom<readonly Info[]>;
183
+ }
184
+ declare const ProcessMonitorService_base: Context.TagClass<ProcessMonitorService, "@dxos/functions/ProcessMonitorService", Monitor>;
185
+ export declare class ProcessMonitorService extends ProcessMonitorService_base {
186
+ }
187
+ export interface Info {
188
+ readonly pid: ID;
189
+ readonly parentPid: ID | null;
190
+ /**
191
+ * Key of the process.
192
+ *
193
+ * NOTE: There might be multiple running processes with the same key.
194
+ */
195
+ readonly key: string;
196
+ /**
197
+ * Parameters of the process.
198
+ */
199
+ readonly params: Params;
200
+ /**
201
+ * State of the process.
202
+ */
203
+ readonly state: State;
204
+ /**
205
+ * Error of the process.
206
+ * Only for process in FAILED state.
207
+ */
208
+ readonly error: string | null;
209
+ /**
210
+ * UNIX timestamp in milliseconds.
211
+ */
212
+ readonly startedAt: number;
213
+ /**
214
+ * UNIX timestamp in milliseconds.
215
+ */
216
+ readonly completedAt: Option.Option<number>;
217
+ readonly metrics: {
218
+ /**
219
+ * Total wall time of all handler invocations of the process in milliseconds.
220
+ */
221
+ readonly wallTime: number;
222
+ /**
223
+ * Total number of inputs submitted to the process.
224
+ */
225
+ readonly inputCount: number;
226
+ /**
227
+ * Total number of outputs submitted to the process.
228
+ */
229
+ readonly outputCount: number;
230
+ };
231
+ }
232
+ /**
233
+ * New process is spawned.
234
+ */
235
+ export declare const SpawnedEvent: Trace.EventType<void>;
236
+ /**
237
+ * Process has reached a terminal state.
238
+ */
239
+ export declare const ExitedEvent: Trace.EventType<{
240
+ readonly outcome: "succeeded" | "failed" | "terminated";
241
+ }>;
242
+ /**
243
+ * Renders spawned processes as a forest: top-level rows use "- ", nested rows use ├── / └── / │.
244
+ */
245
+ export declare const prettyProcessTree: (tree: readonly Info[]) => string;
246
+ export {};
247
+ //# sourceMappingURL=Process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Process.d.ts","sourceRoot":"","sources":["../../../../src/process/Process.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe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AAC;IAE5C,QAAQ,CAAC,OAAO,EAAE;QAChB;;WAEG;QACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAE1B;;WAEG;QACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;QAE5B;;WAEG;QACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;KAC9B,CAAC;CACH;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,uBAGvB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,WAAW;;EAKtB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,SAAS,IAAI,EAAE,KAAG,MA+DzD,CAAC"}
@@ -0,0 +1,74 @@
1
+ import * as Context from 'effect/Context';
2
+ import * as Effect from 'effect/Effect';
3
+ import * as Layer from 'effect/Layer';
4
+ import type { DXN, SpaceId } from '@dxos/keys';
5
+ import { ServiceNotAvailableError } from '../errors';
6
+ import * as Process from './Process';
7
+ import * as Scope from 'effect/Scope';
8
+ declare const ServiceResolverTypeId: "~@dxos/functions/ServiceResolver";
9
+ type ServiceResolverTypeId = typeof ServiceResolverTypeId;
10
+ export interface ServiceResolver {
11
+ readonly [ServiceResolverTypeId]: ServiceResolverTypeId;
12
+ /**
13
+ * Resolve a set of services identified by their tags.
14
+ * Returns a Context containing all requested services, or fails with ServiceNotAvailableError.
15
+ */
16
+ resolve<Tag extends Context.Tag<any, any>>(tag: Tag, context: ResolutionContext): Effect.Effect<Context.Tag.Service<Tag>, ServiceNotAvailableError, Scope.Scope>;
17
+ }
18
+ /**
19
+ * Tag for the ServiceResolver service.
20
+ */
21
+ export declare const ServiceResolver: Context.Tag<ServiceResolver, ServiceResolver>;
22
+ export declare const resolve: <Tag extends Context.Tag<any, any>>(tag: Tag, context: ResolutionContext) => Effect.Effect<Context.Tag.Service<Tag>, ServiceNotAvailableError, Scope.Scope | ServiceResolver>;
23
+ export declare const resolveAll: <const Tags extends readonly Context.Tag<any, any>[]>(tags: Tags, context: ResolutionContext) => Effect.Effect<Context.Context<Tags[number]>, ServiceNotAvailableError, Scope.Scope | ServiceResolver>;
24
+ /**
25
+ * Provides context for service resolution.
26
+ */
27
+ export interface ResolutionContext {
28
+ /**
29
+ * Under which identity the process is running.
30
+ */
31
+ readonly identity?: string;
32
+ /**
33
+ * Under which space the process is running.
34
+ */
35
+ readonly space?: SpaceId;
36
+ /**
37
+ * DXN of the conversation feed the process is running in.
38
+ */
39
+ readonly conversation?: DXN.String;
40
+ /**
41
+ * Under which process the process is running.
42
+ */
43
+ readonly process?: Process.ID;
44
+ }
45
+ export declare const succeed: <I, S>(tag: Context.Tag<I, S>, getService: (context: ResolutionContext) => Effect.Effect<S, ServiceNotAvailableError, Scope.Scope>) => ServiceResolver;
46
+ /**
47
+ * Create a ServiceResolver from a custom resolution function.
48
+ */
49
+ export declare const make: (resolveFn: <I, S>(tag: Context.Tag<I, S>, context: ResolutionContext) => Effect.Effect<S, ServiceNotAvailableError, Scope.Scope>) => ServiceResolver;
50
+ /**
51
+ * Create a ServiceResolver backed by a static Context.
52
+ * Tags present in the context are resolved; missing tags fail with ServiceNotAvailableError.
53
+ */
54
+ export declare const fromContext: (ctx: Context.Context<any>) => ServiceResolver;
55
+ /**
56
+ * Create a ServiceResolver that resolves tags from the current Effect context.
57
+ * Only the specified tags are available; requests for other tags fail.
58
+ */
59
+ export declare const fromRequirements: <const Tags extends readonly Context.Tag<any, any>[]>(...tags: Tags) => Effect.Effect<ServiceResolver, never, Context.Tag.Identifier<Tags[number]>>;
60
+ /**
61
+ * Like {@link fromRequirements} but returns a Layer that provides ServiceResolver.
62
+ */
63
+ export declare const layerRequirements: <const Tags extends readonly Context.Tag<any, any>[]>(...tags: Tags) => Layer.Layer<ServiceResolver, never, Context.Tag.Identifier<Tags[number]>>;
64
+ /**
65
+ * Compose multiple resolvers left to right. Earlier resolvers take precedence:
66
+ * the first resolver that can satisfy a tag wins.
67
+ */
68
+ export declare const compose: (...resolvers: readonly ServiceResolver[]) => ServiceResolver;
69
+ /**
70
+ * An empty resolver that fails for any requested service.
71
+ */
72
+ export declare const empty: ServiceResolver;
73
+ export {};
74
+ //# sourceMappingURL=ServiceResolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ServiceResolver.d.ts","sourceRoot":"","sources":["../../../../src/process/ServiceResolver.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,QAAA,MAAM,qBAAqB,EAAG,kCAA2C,CAAC;AAC1E,KAAK,qBAAqB,GAAG,OAAO,qBAAqB,CAAC;AAE1D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,CAAC,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;IAExD;;;OAGG;IACH,OAAO,CAAC,GAAG,SAAS,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,EACvC,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,iBAAiB,GACzB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,wBAAwB,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;CACnF;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,+CAAyE,CAAC;AAEtG,eAAO,MAAM,OAAO,GAXV,GAAG,SAAS,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,2IAW2C,CAAC;AAEvF,eAAO,MAAM,UAAU,GAAI,KAAK,CAAC,IAAI,SAAS,SAAS,OAAO,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