@dxos/compute 0.8.4-main.fd6878d → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +102 -5
- package/README.md +36 -1
- package/dist/lib/neutral/StorageService.mjs +22 -0
- package/dist/lib/neutral/chunk-2B2KSJT6.mjs +17 -0
- package/dist/lib/neutral/chunk-2B2KSJT6.mjs.map +7 -0
- package/dist/lib/neutral/chunk-AFBNVFAY.mjs +25 -0
- package/dist/lib/neutral/chunk-AFBNVFAY.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-JAU4E4EK.mjs +53 -0
- package/dist/lib/neutral/chunk-JAU4E4EK.mjs.map +7 -0
- package/dist/lib/neutral/chunk-MEPE4HHX.mjs +21 -0
- package/dist/lib/neutral/chunk-MEPE4HHX.mjs.map +7 -0
- package/dist/lib/neutral/chunk-QZS4G6PE.mjs +240 -0
- package/dist/lib/neutral/chunk-QZS4G6PE.mjs.map +7 -0
- package/dist/lib/neutral/chunk-XEVFBI6S.mjs +62 -0
- package/dist/lib/neutral/chunk-XEVFBI6S.mjs.map +7 -0
- package/dist/lib/neutral/chunk-Z3Y7FQGN.mjs +174 -0
- package/dist/lib/neutral/chunk-Z3Y7FQGN.mjs.map +7 -0
- package/dist/lib/neutral/fib-HBDUGQW7.mjs +10 -0
- package/dist/lib/neutral/fib-HBDUGQW7.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +1183 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/reply-RJIAJ6FV.mjs +10 -0
- package/dist/lib/neutral/reply-RJIAJ6FV.mjs.map +7 -0
- package/dist/lib/neutral/sleep-3T2CZ7RE.mjs +10 -0
- package/dist/lib/neutral/sleep-3T2CZ7RE.mjs.map +7 -0
- package/dist/lib/neutral/testing/index.mjs +32 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/types/src/Blueprint.d.ts +182 -0
- package/dist/types/src/Blueprint.d.ts.map +1 -0
- package/dist/types/src/Credential.d.ts +27 -0
- package/dist/types/src/Credential.d.ts.map +1 -0
- package/dist/types/src/Header.d.ts +9 -0
- package/dist/types/src/Header.d.ts.map +1 -0
- package/dist/types/src/Header.test.d.ts +2 -0
- package/dist/types/src/Header.test.d.ts.map +1 -0
- package/dist/types/src/LayerSpec.d.ts +56 -0
- package/dist/types/src/LayerSpec.d.ts.map +1 -0
- package/dist/types/src/McpServer.d.ts +26 -0
- package/dist/types/src/McpServer.d.ts.map +1 -0
- package/dist/types/src/Operation.d.ts +385 -0
- package/dist/types/src/Operation.d.ts.map +1 -0
- package/dist/types/src/OperationHandlerSet.d.ts +69 -0
- package/dist/types/src/OperationHandlerSet.d.ts.map +1 -0
- package/dist/types/src/OperationHandlerSet.test.d.ts +2 -0
- package/dist/types/src/OperationHandlerSet.test.d.ts.map +1 -0
- package/dist/types/src/OperationRegistry.d.ts +23 -0
- package/dist/types/src/OperationRegistry.d.ts.map +1 -0
- package/dist/types/src/Process.d.ts +255 -0
- package/dist/types/src/Process.d.ts.map +1 -0
- package/dist/types/src/Routine.d.ts +54 -0
- package/dist/types/src/Routine.d.ts.map +1 -0
- package/dist/types/src/Script.d.ts +21 -0
- package/dist/types/src/Script.d.ts.map +1 -0
- package/dist/types/src/ServiceResolver.d.ts +92 -0
- package/dist/types/src/ServiceResolver.d.ts.map +1 -0
- package/dist/types/src/StorageService.d.ts +58 -0
- package/dist/types/src/StorageService.d.ts.map +1 -0
- package/dist/types/src/Template.d.ts +61 -0
- package/dist/types/src/Template.d.ts.map +1 -0
- package/dist/types/src/Template.test.d.ts +2 -0
- package/dist/types/src/Template.test.d.ts.map +1 -0
- package/dist/types/src/Trace.d.ts +266 -0
- package/dist/types/src/Trace.d.ts.map +1 -0
- package/dist/types/src/Trigger.d.ts +192 -0
- package/dist/types/src/Trigger.d.ts.map +1 -0
- package/dist/types/src/TriggerEvent.d.ts +83 -0
- package/dist/types/src/TriggerEvent.d.ts.map +1 -0
- package/dist/types/src/errors.d.ts +308 -0
- package/dist/types/src/errors.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +18 -5
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/testing/definitions.d.ts +11 -0
- package/dist/types/src/testing/definitions.d.ts.map +1 -0
- package/dist/types/src/testing/fib.d.ts +8 -0
- package/dist/types/src/testing/fib.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +6 -3
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/reply.d.ts +4 -0
- package/dist/types/src/testing/reply.d.ts.map +1 -0
- package/dist/types/src/testing/sleep.d.ts +6 -0
- package/dist/types/src/testing/sleep.d.ts.map +1 -0
- package/dist/types/src/umbrella.test.d.ts +2 -0
- package/dist/types/src/umbrella.test.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +31 -47
- package/src/Blueprint.ts +224 -0
- package/src/Credential.ts +53 -0
- package/src/Header.test.ts +132 -0
- package/src/Header.ts +38 -0
- package/src/LayerSpec.ts +91 -0
- package/src/McpServer.ts +44 -0
- package/src/Operation.ts +646 -0
- package/src/OperationHandlerSet.test.ts +97 -0
- package/src/OperationHandlerSet.ts +181 -0
- package/src/OperationRegistry.ts +50 -0
- package/src/Process.ts +541 -0
- package/src/Routine.ts +68 -0
- package/src/Script.ts +33 -0
- package/src/ServiceResolver.ts +200 -0
- package/src/StorageService.ts +101 -0
- package/src/Template.test.ts +164 -0
- package/src/Template.ts +125 -0
- package/src/Trace.ts +363 -0
- package/src/Trigger.ts +196 -0
- package/src/TriggerEvent.ts +64 -0
- package/src/errors.ts +71 -0
- package/src/index.ts +19 -32
- package/src/testing/definitions.ts +51 -0
- package/src/testing/fib.ts +22 -0
- package/src/testing/index.ts +13 -4
- package/src/testing/reply.ts +18 -0
- package/src/testing/sleep.ts +16 -0
- package/src/umbrella.test.ts +51 -0
- package/dist/lib/browser/chunk-X2FWMHD4.mjs +0 -3107
- package/dist/lib/browser/chunk-X2FWMHD4.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -55
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/testing/index.mjs +0 -176
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RP7HSSCA.mjs +0 -3109
- package/dist/lib/node-esm/chunk-RP7HSSCA.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -56
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/testing/index.mjs +0 -177
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/types/src/compute-graph-registry.d.ts +0 -34
- package/dist/types/src/compute-graph-registry.d.ts.map +0 -1
- package/dist/types/src/compute-graph.d.ts +0 -64
- package/dist/types/src/compute-graph.d.ts.map +0 -1
- package/dist/types/src/compute-graph.test.d.ts +0 -2
- package/dist/types/src/compute-graph.test.d.ts.map +0 -1
- package/dist/types/src/compute-node.d.ts +0 -25
- package/dist/types/src/compute-node.d.ts.map +0 -1
- package/dist/types/src/functions/async-function.d.ts +0 -66
- package/dist/types/src/functions/async-function.d.ts.map +0 -1
- package/dist/types/src/functions/edge-function.d.ts +0 -20
- package/dist/types/src/functions/edge-function.d.ts.map +0 -1
- package/dist/types/src/functions/function-defs.d.ts +0 -11
- package/dist/types/src/functions/function-defs.d.ts.map +0 -1
- package/dist/types/src/functions/index.d.ts +0 -4
- package/dist/types/src/functions/index.d.ts.map +0 -1
- package/dist/types/src/hyperformula.test.d.ts +0 -2
- package/dist/types/src/hyperformula.test.d.ts.map +0 -1
- package/dist/types/src/testing/test-builder.d.ts +0 -15
- package/dist/types/src/testing/test-builder.d.ts.map +0 -1
- package/dist/types/src/testing/test-plugin.d.ts +0 -36
- package/dist/types/src/testing/test-plugin.d.ts.map +0 -1
- package/dist/types/src/testing/util.d.ts +0 -2
- package/dist/types/src/testing/util.d.ts.map +0 -1
- package/dist/types/src/types/hyperformula.d.ts +0 -11
- package/dist/types/src/types/hyperformula.d.ts.map +0 -1
- package/dist/types/src/types/index.d.ts +0 -3
- package/dist/types/src/types/index.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts +0 -20
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/dist/types/src/types/types.test.d.ts +0 -2
- package/dist/types/src/types/types.test.d.ts.map +0 -1
- package/dist/types/src/util.d.ts +0 -2
- package/dist/types/src/util.d.ts.map +0 -1
- package/dist/vendor/hyperformula.mjs +0 -36400
- package/src/compute-graph-registry.ts +0 -91
- package/src/compute-graph.test.ts +0 -89
- package/src/compute-graph.ts +0 -260
- package/src/compute-node.ts +0 -62
- package/src/functions/async-function.ts +0 -179
- package/src/functions/edge-function.ts +0 -112
- package/src/functions/function-defs.ts +0 -2427
- package/src/functions/index.ts +0 -7
- package/src/hyperformula.test.ts +0 -14
- package/src/testing/test-builder.ts +0 -54
- package/src/testing/test-plugin.ts +0 -101
- package/src/testing/util.ts +0 -9
- package/src/types/hyperformula.ts +0 -19
- package/src/types/index.ts +0 -6
- package/src/types/types.test.ts +0 -91
- package/src/types/types.ts +0 -80
- package/src/util.ts +0 -8
- /package/dist/lib/{browser/index.mjs.map → neutral/StorageService.mjs.map} +0 -0
- /package/dist/lib/{node-esm/index.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as Context from 'effect/Context';
|
|
2
|
+
import * as Effect from 'effect/Effect';
|
|
3
|
+
import * as Layer from 'effect/Layer';
|
|
4
|
+
import * as Option from 'effect/Option';
|
|
5
|
+
import { Database } from '@dxos/echo';
|
|
6
|
+
import * as Operation from './Operation';
|
|
7
|
+
import * as OperationHandlerSet from './OperationHandlerSet';
|
|
8
|
+
export interface OperationRegistry {
|
|
9
|
+
/**
|
|
10
|
+
* Resolve an operation by key.
|
|
11
|
+
*/
|
|
12
|
+
resolve(key: string): Effect.Effect<Option.Option<Operation.Definition.Any>>;
|
|
13
|
+
}
|
|
14
|
+
declare const Service_base: Context.TagClass<Service, "@dxos/operation/OperationRegistry", OperationRegistry>;
|
|
15
|
+
export declare class Service extends Service_base {
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Resolve an operation by key.
|
|
19
|
+
*/
|
|
20
|
+
export declare const resolve: (key: string) => Effect.Effect<Option.Option<Operation.Definition.Any>, never, Service>;
|
|
21
|
+
export declare const layer: Layer.Layer<Service, never, Database.Service | OperationHandlerSet.OperationHandlerProvider>;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=OperationRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationRegistry.d.ts","sourceRoot":"","sources":["../../../src/OperationRegistry.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAiB,MAAM,YAAY,CAAC;AAErD,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,mBAAmB,MAAM,uBAAuB,CAAC;AAE7D,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;CAC9E;;AAED,qBAAa,OAAQ,SAAQ,YAA8E;CAAG;AAE9G;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,CACvC,CAAC;AAEtE,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,OAAO,GAAG,mBAAmB,CAAC,wBAAwB,CAkB5G,CAAC"}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import type { Atom } from '@effect-atom/atom';
|
|
2
|
+
import * as Context from 'effect/Context';
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
import type * as Exit from 'effect/Exit';
|
|
5
|
+
import * as Option from 'effect/Option';
|
|
6
|
+
import * as Schema from 'effect/Schema';
|
|
7
|
+
import * as Scope from 'effect/Scope';
|
|
8
|
+
import type * as Types from 'effect/Types';
|
|
9
|
+
import { type URI } from '@dxos/keys';
|
|
10
|
+
import * as Operation from './Operation';
|
|
11
|
+
import * as OperationHandlerSet from './OperationHandlerSet';
|
|
12
|
+
import * as StorageService from './StorageService';
|
|
13
|
+
import * as Trace from './Trace';
|
|
14
|
+
/** Opaque process id (arbitrary string). */
|
|
15
|
+
export declare const ID: Schema.brand<typeof Schema.String, "ProcessId">;
|
|
16
|
+
export type ID = Schema.Schema.Type<typeof ID>;
|
|
17
|
+
/**
|
|
18
|
+
* A running process callbacks.
|
|
19
|
+
*
|
|
20
|
+
* Process lifecycle: Initial -> Running <-> Suspended -> Terminated.
|
|
21
|
+
*
|
|
22
|
+
* - onSpawn -> called once when the process is spawned.
|
|
23
|
+
* - onInput -> called for every input submitted to the process.
|
|
24
|
+
* - onAlarm -> called for processes scheduling alarms.
|
|
25
|
+
* - onChildEvent -> called when child process produces output or exits.
|
|
26
|
+
*/
|
|
27
|
+
export interface Callbacks<I, O, R> {
|
|
28
|
+
/**
|
|
29
|
+
* Called when the process is spawned.
|
|
30
|
+
* Not called for processes that are resumed from a previously suspended state.
|
|
31
|
+
*
|
|
32
|
+
* @returns A signal indicating to the runtime whether the process is finished, or should be resumed later.
|
|
33
|
+
* @throws Throwing in the handler will terminate the process with an error.
|
|
34
|
+
*
|
|
35
|
+
* Note: This function should aim to complete in under 5 seconds to avoid exceeding limits in serverless environments.
|
|
36
|
+
*/
|
|
37
|
+
onSpawn(): Effect.Effect<void, never, R | BaseServices>;
|
|
38
|
+
/**
|
|
39
|
+
* Called when there's input available to process.
|
|
40
|
+
*
|
|
41
|
+
* The function can be called in parallel.
|
|
42
|
+
*
|
|
43
|
+
* @returns A signal indicating to the runtime whether the process is finished, or should be resumed later.
|
|
44
|
+
* @throws Throwing in the handler will terminate the process with an error.
|
|
45
|
+
*
|
|
46
|
+
* Note: This function should aim to complete in under 5 seconds to avoid exceeding limits in serverless environments.
|
|
47
|
+
*/
|
|
48
|
+
onInput(input: I): Effect.Effect<void, never, R | BaseServices>;
|
|
49
|
+
/**
|
|
50
|
+
* Called when the process's alarm is triggered.
|
|
51
|
+
*
|
|
52
|
+
* @throws Throwing in the handler will terminate the process with an error.
|
|
53
|
+
*/
|
|
54
|
+
onAlarm(): Effect.Effect<void, never, R | BaseServices>;
|
|
55
|
+
/**
|
|
56
|
+
* Called when the process's child process produces output or exits.
|
|
57
|
+
*
|
|
58
|
+
* This allows the parent process to hibernate while a long-running child process is running.
|
|
59
|
+
*/
|
|
60
|
+
onChildEvent(event: ChildEvent<unknown>): Effect.Effect<void, never, R | BaseServices>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Services that are always available to all processes.
|
|
64
|
+
* Provided unconditionally by the runtime, so handlers may use them without declaring them
|
|
65
|
+
* in {@link MakeProcessOpts.services}.
|
|
66
|
+
*/
|
|
67
|
+
export type BaseServices = Trace.TraceService | StorageService.StorageService;
|
|
68
|
+
export type ChildEvent<T> = {
|
|
69
|
+
readonly _tag: 'output';
|
|
70
|
+
readonly pid: ID;
|
|
71
|
+
readonly data: T;
|
|
72
|
+
} | {
|
|
73
|
+
readonly _tag: 'exited';
|
|
74
|
+
readonly pid: ID;
|
|
75
|
+
readonly result: Exit.Exit<void>;
|
|
76
|
+
};
|
|
77
|
+
export interface ProcessContext<I, O> {
|
|
78
|
+
readonly id: ID;
|
|
79
|
+
/**
|
|
80
|
+
* Parameters assigned during process creation.
|
|
81
|
+
*/
|
|
82
|
+
readonly params: Params;
|
|
83
|
+
/**
|
|
84
|
+
* Complete this process with sucessful result.
|
|
85
|
+
* No additional events will be pushed to the process.
|
|
86
|
+
*/
|
|
87
|
+
succeed(): void;
|
|
88
|
+
/**
|
|
89
|
+
* Complete this process with an error.
|
|
90
|
+
* No additional events will be pushed to the process.
|
|
91
|
+
*/
|
|
92
|
+
fail(error: Error): void;
|
|
93
|
+
/**
|
|
94
|
+
* Submit output of the process.
|
|
95
|
+
*/
|
|
96
|
+
submitOutput(output: O): void;
|
|
97
|
+
/**
|
|
98
|
+
* Set an alarm for the process to be woken up later.
|
|
99
|
+
*
|
|
100
|
+
* @param timeout - Optional timeout in milliseconds. If not provided, the process is woken up as soon as possible.
|
|
101
|
+
*/
|
|
102
|
+
setAlarm(timeout?: number): void;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Generic parameters for a all processes.
|
|
106
|
+
*/
|
|
107
|
+
export interface Params {
|
|
108
|
+
/**
|
|
109
|
+
* Process name for debugging purposes.
|
|
110
|
+
*/
|
|
111
|
+
readonly name: string | null;
|
|
112
|
+
/**
|
|
113
|
+
* URI of the target this process is assigned to.
|
|
114
|
+
*/
|
|
115
|
+
readonly target: URI.URI | null;
|
|
116
|
+
/**
|
|
117
|
+
* User-facing notifications requested for this process's lifecycle phases.
|
|
118
|
+
* Surfaced on {@link Info} so a notification tracker can subscribe to the process monitor.
|
|
119
|
+
*/
|
|
120
|
+
readonly notify?: Operation.NotifyOptions;
|
|
121
|
+
}
|
|
122
|
+
export declare const ProcessTypeId: '~@dxos/functions/Process';
|
|
123
|
+
export type ProcessTypeId = typeof ProcessTypeId;
|
|
124
|
+
/**
|
|
125
|
+
* A process (factory).
|
|
126
|
+
* Can be instantiated mutlitple times to produce new runtime instance with separate state and callbacks.
|
|
127
|
+
* `create` is used to instantiate a new process.
|
|
128
|
+
* Can store runtime state in scope of `create` function.
|
|
129
|
+
*/
|
|
130
|
+
export interface Process<I, O, R> extends Process.Variance<I, O, R> {
|
|
131
|
+
/**
|
|
132
|
+
* Unique identifier for the executable in the reverse DNS format.
|
|
133
|
+
*/
|
|
134
|
+
readonly key: string;
|
|
135
|
+
/**
|
|
136
|
+
* Human-readable label from {@link MakeExecutableOpts.name} when provided.
|
|
137
|
+
*/
|
|
138
|
+
readonly name?: string;
|
|
139
|
+
readonly services: readonly Context.Tag<any, any>[];
|
|
140
|
+
/**
|
|
141
|
+
* Create a new instance of the process.
|
|
142
|
+
*/
|
|
143
|
+
create(ctx: ProcessContext<I, O>): Effect.Effect<Callbacks<I, O, R>, never, R | BaseServices | Scope.Scope>;
|
|
144
|
+
}
|
|
145
|
+
export declare const isProcess: (executable: unknown) => executable is Process.Any;
|
|
146
|
+
export declare namespace Process {
|
|
147
|
+
interface Variance<I, O, R> {
|
|
148
|
+
readonly [ProcessTypeId]: {
|
|
149
|
+
readonly _Input: Types.Contravariant<I>;
|
|
150
|
+
readonly _Output: Types.Covariant<O>;
|
|
151
|
+
readonly _Requirements: Types.Covariant<R>;
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
type Any = Process<any, any, never>;
|
|
155
|
+
}
|
|
156
|
+
export interface MakeProcessOpts {
|
|
157
|
+
/**
|
|
158
|
+
* Unique identifier for the process in the reverse DNS format.
|
|
159
|
+
*/
|
|
160
|
+
readonly key: string;
|
|
161
|
+
readonly input: Schema.Schema.AnyNoContext;
|
|
162
|
+
readonly output: Schema.Schema.AnyNoContext;
|
|
163
|
+
readonly services: readonly Context.Tag<any, any>[];
|
|
164
|
+
}
|
|
165
|
+
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]>>;
|
|
166
|
+
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>>;
|
|
167
|
+
/**
|
|
168
|
+
* Runtime state of a process.
|
|
169
|
+
*/
|
|
170
|
+
export declare enum State {
|
|
171
|
+
RUNNING = "RUNNING",
|
|
172
|
+
HYBERNATING = "HYBERNATING",
|
|
173
|
+
IDLE = "IDLE",
|
|
174
|
+
TERMINATING = "TERMINATING",
|
|
175
|
+
TERMINATED = "TERMINATED",
|
|
176
|
+
SUCCEEDED = "SUCCEEDED",
|
|
177
|
+
FAILED = "FAILED"
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Read-only view of a process tree
|
|
181
|
+
*/
|
|
182
|
+
export interface Monitor {
|
|
183
|
+
/**
|
|
184
|
+
* Get the current state of the process tree.
|
|
185
|
+
*/
|
|
186
|
+
processTree: Effect.Effect<readonly Info[]>;
|
|
187
|
+
/**
|
|
188
|
+
* Atom for the process tree.
|
|
189
|
+
*/
|
|
190
|
+
processTreeAtom: Atom.Atom<readonly Info[]>;
|
|
191
|
+
}
|
|
192
|
+
declare const ProcessMonitorService_base: Context.TagClass<ProcessMonitorService, "@dxos/functions/ProcessMonitorService", Monitor>;
|
|
193
|
+
export declare class ProcessMonitorService extends ProcessMonitorService_base {
|
|
194
|
+
}
|
|
195
|
+
export interface Info {
|
|
196
|
+
readonly pid: ID;
|
|
197
|
+
readonly parentPid: ID | null;
|
|
198
|
+
/**
|
|
199
|
+
* Key of the process.
|
|
200
|
+
*
|
|
201
|
+
* NOTE: There might be multiple running processes with the same key.
|
|
202
|
+
*/
|
|
203
|
+
readonly key: string;
|
|
204
|
+
/**
|
|
205
|
+
* Parameters of the process.
|
|
206
|
+
*/
|
|
207
|
+
readonly params: Params;
|
|
208
|
+
/**
|
|
209
|
+
* State of the process.
|
|
210
|
+
*/
|
|
211
|
+
readonly state: State;
|
|
212
|
+
/**
|
|
213
|
+
* Error of the process.
|
|
214
|
+
* Only for process in FAILED state.
|
|
215
|
+
*/
|
|
216
|
+
readonly error: string | null;
|
|
217
|
+
/**
|
|
218
|
+
* UNIX timestamp in milliseconds.
|
|
219
|
+
*/
|
|
220
|
+
readonly startedAt: number;
|
|
221
|
+
/**
|
|
222
|
+
* UNIX timestamp in milliseconds.
|
|
223
|
+
*/
|
|
224
|
+
readonly completedAt: Option.Option<number>;
|
|
225
|
+
readonly metrics: {
|
|
226
|
+
/**
|
|
227
|
+
* Total wall time of all handler invocations of the process in milliseconds.
|
|
228
|
+
*/
|
|
229
|
+
readonly wallTime: number;
|
|
230
|
+
/**
|
|
231
|
+
* Total number of inputs submitted to the process.
|
|
232
|
+
*/
|
|
233
|
+
readonly inputCount: number;
|
|
234
|
+
/**
|
|
235
|
+
* Total number of outputs submitted to the process.
|
|
236
|
+
*/
|
|
237
|
+
readonly outputCount: number;
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* New process is spawned.
|
|
242
|
+
*/
|
|
243
|
+
export declare const SpawnedEvent: Trace.EventType<void>;
|
|
244
|
+
/**
|
|
245
|
+
* Process has reached a terminal state.
|
|
246
|
+
*/
|
|
247
|
+
export declare const ExitedEvent: Trace.EventType<{
|
|
248
|
+
readonly outcome: "failed" | "succeeded" | "terminated";
|
|
249
|
+
}>;
|
|
250
|
+
/**
|
|
251
|
+
* Renders spawned processes as a forest: top-level rows use "- ", nested rows use ├── / └── / │.
|
|
252
|
+
*/
|
|
253
|
+
export declare const prettyProcessTree: (tree: readonly Info[]) => string;
|
|
254
|
+
export {};
|
|
255
|
+
//# sourceMappingURL=Process.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Process.d.ts","sourceRoot":"","sources":["../../../src/Process.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,IAAI,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAG3C,OAAO,EAAO,KAAK,GAAG,EAAE,MAAM,YAAY,CAAC;AAG3C,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,mBAAmB,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAMjC,4CAA4C;AAC5C,eAAO,MAAM,EAAE,iDAAgD,CAAC;AAChE,MAAM,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;AAE/C;;;;;;;;;GASG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IAChC;;;;;;;;OAQG;IACH,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,YAAY,CAAC,CAAC;IAExD;;;;;;;;;OASG;IACH,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,YAAY,C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CAAC;IAErB;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAEtB;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;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,SAAU,SAAS,IAAI,EAAE,KAAG,MA+DzD,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as Schema from 'effect/Schema';
|
|
2
|
+
import { Obj, Ref, Type } from '@dxos/echo';
|
|
3
|
+
import * as Blueprint from './Blueprint';
|
|
4
|
+
/**
|
|
5
|
+
* Prompt-based operation.
|
|
6
|
+
* May reference blueprints and additional context.
|
|
7
|
+
*/
|
|
8
|
+
export declare const Routine: Type.Obj<{
|
|
9
|
+
readonly name?: string | undefined;
|
|
10
|
+
readonly description?: string | undefined;
|
|
11
|
+
readonly input: import("@dxos/echo/internal").JsonSchemaType;
|
|
12
|
+
readonly output: import("@dxos/echo/internal").JsonSchemaType;
|
|
13
|
+
readonly instructions: import("@dxos/echo/internal").Ref<{
|
|
14
|
+
readonly name?: string | undefined;
|
|
15
|
+
readonly content: string;
|
|
16
|
+
} & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>;
|
|
17
|
+
readonly blueprints: readonly import("@dxos/echo/internal").Ref<{
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly description?: string | undefined;
|
|
20
|
+
readonly instructions: {
|
|
21
|
+
readonly source: import("@dxos/echo/internal").Ref<{
|
|
22
|
+
readonly name?: string | undefined;
|
|
23
|
+
readonly content: string;
|
|
24
|
+
} & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>;
|
|
25
|
+
readonly inputs?: readonly {
|
|
26
|
+
readonly name: string;
|
|
27
|
+
readonly kind: "operation" | "value";
|
|
28
|
+
readonly default?: any;
|
|
29
|
+
readonly operation?: string | undefined;
|
|
30
|
+
}[] | undefined;
|
|
31
|
+
};
|
|
32
|
+
readonly tools: readonly (string & import("effect/Brand").Brand<"ToolId">)[];
|
|
33
|
+
readonly agentCanEnable?: boolean | undefined;
|
|
34
|
+
readonly mcpServers?: readonly {
|
|
35
|
+
readonly name?: string | undefined;
|
|
36
|
+
readonly url: string;
|
|
37
|
+
readonly protocol: "http" | "sse";
|
|
38
|
+
readonly apiKey?: string | undefined;
|
|
39
|
+
}[] | undefined;
|
|
40
|
+
} & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>[];
|
|
41
|
+
readonly context: readonly any[];
|
|
42
|
+
}, Schema.Struct.Fields>;
|
|
43
|
+
export type Routine = Type.InstanceType<typeof Routine>;
|
|
44
|
+
export type MakeProps = {
|
|
45
|
+
name?: string;
|
|
46
|
+
description?: string;
|
|
47
|
+
input?: Schema.Schema.AnyNoContext;
|
|
48
|
+
output?: Schema.Schema.AnyNoContext;
|
|
49
|
+
instructions?: string;
|
|
50
|
+
blueprints?: Ref.Ref<Blueprint.Blueprint>[];
|
|
51
|
+
context?: any[];
|
|
52
|
+
};
|
|
53
|
+
export declare const make: ({ name, description, input, output, instructions, blueprints, context, }: MakeProps) => Routine;
|
|
54
|
+
//# sourceMappingURL=Routine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Routine.d.ts","sourceRoot":"","sources":["../../../src/Routine.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAA+B,GAAG,EAAE,GAAG,EAAE,IAAI,EAAU,MAAM,YAAY,CAAC;AAGjF,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAEzC;;;GAGG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAmBnB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,OAAO,CAAC,CAAC;AAExD,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC;IAC5C,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,IAAI,6EAQd,SAAS,KAAG,OASX,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 name?: string | undefined;
|
|
8
|
+
readonly description?: string | undefined;
|
|
9
|
+
readonly changed?: boolean | undefined;
|
|
10
|
+
readonly source: import("@dxos/echo/internal").Ref<{
|
|
11
|
+
readonly name?: string | undefined;
|
|
12
|
+
readonly content: string;
|
|
13
|
+
} & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>;
|
|
14
|
+
}, Schema.Struct.Fields>;
|
|
15
|
+
export type Script = Type.InstanceType<typeof Script>;
|
|
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/Script.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAmB,GAAG,EAAO,IAAI,EAAE,MAAM,YAAY,CAAC;AAI7D;;GAEG;AACH,eAAO,MAAM,MAAM;;;;;;;;wBAWlB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC;AACtD,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,0BAA+B,KAAK,KAAQ,MACqB,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import * as Context from 'effect/Context';
|
|
2
|
+
import * as Effect from 'effect/Effect';
|
|
3
|
+
import * as Layer from 'effect/Layer';
|
|
4
|
+
import * as Scope from 'effect/Scope';
|
|
5
|
+
import type { SpaceId, URI } from '@dxos/keys';
|
|
6
|
+
import { ServiceNotAvailableError } from './errors';
|
|
7
|
+
import * as Process from './Process';
|
|
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: {
|
|
23
|
+
<Tag extends Context.Tag<any, any>>(tag: Tag, context: ResolutionContext): Effect.Effect<Context.Tag.Service<Tag>, ServiceNotAvailableError, Scope.Scope | ServiceResolver>;
|
|
24
|
+
};
|
|
25
|
+
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>;
|
|
26
|
+
/**
|
|
27
|
+
* Provides context for service resolution.
|
|
28
|
+
*/
|
|
29
|
+
export interface ResolutionContext {
|
|
30
|
+
/**
|
|
31
|
+
* Under which identity the process is running.
|
|
32
|
+
*/
|
|
33
|
+
readonly identity?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Under which space the process is running.
|
|
36
|
+
*/
|
|
37
|
+
readonly space?: SpaceId;
|
|
38
|
+
/**
|
|
39
|
+
* URI of the conversation feed the process is running in. Today always an EID;
|
|
40
|
+
* narrow with `EID.parse` at the point of use.
|
|
41
|
+
*/
|
|
42
|
+
readonly conversation?: URI.URI;
|
|
43
|
+
/**
|
|
44
|
+
* Under which process the process is running.
|
|
45
|
+
*/
|
|
46
|
+
readonly process?: Process.ID;
|
|
47
|
+
}
|
|
48
|
+
export declare const succeed: <I, S>(tag: Context.Tag<I, S>, getService: (context: ResolutionContext) => Effect.Effect<S, ServiceNotAvailableError, Scope.Scope>) => ServiceResolver;
|
|
49
|
+
/**
|
|
50
|
+
* Create a ServiceResolver from a custom resolution function.
|
|
51
|
+
*/
|
|
52
|
+
export declare const make: (resolveFn: <I, S>(tag: Context.Tag<I, S>, context: ResolutionContext) => Effect.Effect<S, ServiceNotAvailableError, Scope.Scope>) => ServiceResolver;
|
|
53
|
+
/**
|
|
54
|
+
* Create a ServiceResolver backed by a static Context.
|
|
55
|
+
* Tags present in the context are resolved; missing tags fail with ServiceNotAvailableError.
|
|
56
|
+
*/
|
|
57
|
+
export declare const fromContext: <Services>(ctx: Context.Context<Services>) => ServiceResolver;
|
|
58
|
+
/**
|
|
59
|
+
* Create a ServiceResolver that resolves tags from the current Effect context.
|
|
60
|
+
* Only the specified tags are available; requests for other tags fail.
|
|
61
|
+
*/
|
|
62
|
+
export declare const fromRequirements: <const Tags extends readonly Context.Tag<any, any>[]>(...tags: Tags) => Effect.Effect<ServiceResolver, never, Context.Tag.Identifier<Tags[number]>>;
|
|
63
|
+
/**
|
|
64
|
+
* Like {@link fromRequirements} but returns a Layer that provides ServiceResolver.
|
|
65
|
+
*/
|
|
66
|
+
export declare const layerRequirements: <const Tags extends readonly Context.Tag<any, any>[]>(...tags: Tags) => Layer.Layer<ServiceResolver, never, Context.Tag.Identifier<Tags[number]>>;
|
|
67
|
+
/**
|
|
68
|
+
* Build a {@link Layer} that materialises the requested services by calling
|
|
69
|
+
* {@link resolveAll} against the {@link ServiceResolver} currently in context.
|
|
70
|
+
*
|
|
71
|
+
* The returned layer manages its own {@link Scope.Scope} and requires only a
|
|
72
|
+
* {@link ServiceResolver} (typically supplied by the process-manager runtime).
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* processManagerRuntime.runPromise(
|
|
77
|
+
* myEffect.pipe(Effect.provide(ServiceResolver.provide({ space }, Database.Service, Feed.FeedService))),
|
|
78
|
+
* );
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare const provide: <const Tags extends readonly Context.Tag<any, any>[]>(context: ResolutionContext, ...tags: Tags) => Layer.Layer<Context.Tag.Identifier<Tags[number]>, ServiceNotAvailableError, ServiceResolver>;
|
|
82
|
+
/**
|
|
83
|
+
* Compose multiple resolvers left to right. Earlier resolvers take precedence:
|
|
84
|
+
* the first resolver that can satisfy a tag wins.
|
|
85
|
+
*/
|
|
86
|
+
export declare const compose: (...resolvers: readonly ServiceResolver[]) => ServiceResolver;
|
|
87
|
+
/**
|
|
88
|
+
* An empty resolver that fails for any requested service.
|
|
89
|
+
*/
|
|
90
|
+
export declare const empty: ServiceResolver;
|
|
91
|
+
export {};
|
|
92
|
+
//# sourceMappingURL=ServiceResolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServiceResolver.d.ts","sourceRoot":"","sources":["../../../src/ServiceResolver.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,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,CA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,IAAI,SAAS,SAAS,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,WAChE,iBAAiB,WACjB,IAAI,KACZ,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,wBAAwB,EAAE,eAAe,CAC9C,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,OAAO,iBAAkB,SAAS,eAAe,EAAE,KAAG,eAYhE,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,KAAK,EAAE,eAElB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as Context from 'effect/Context';
|
|
2
|
+
import * as Effect from 'effect/Effect';
|
|
3
|
+
import * as Option from 'effect/Option';
|
|
4
|
+
import * as Pipeable from 'effect/Pipeable';
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
export interface Service {
|
|
7
|
+
/** Read a value by key. Returns `None` if key does not exist. */
|
|
8
|
+
get<S extends Schema.Schema<any, string, any>>(schema: S, key: string): Effect.Effect<Option.Option<Schema.Schema.Type<S>>, never, Schema.Schema.Context<S>>;
|
|
9
|
+
/** Write a value for the given key. */
|
|
10
|
+
set<S extends Schema.Schema<any, string, any>>(schema: S, key: string, value: Schema.Schema.Type<S>): Effect.Effect<void, never, Schema.Schema.Context<S>>;
|
|
11
|
+
/** Remove a key. */
|
|
12
|
+
delete(key: string): Effect.Effect<void>;
|
|
13
|
+
/** List all keys, optionally filtered by prefix. */
|
|
14
|
+
list(prefix?: string): Effect.Effect<readonly string[]>;
|
|
15
|
+
/** Remove all keys managed by this scoped store. */
|
|
16
|
+
clear(): Effect.Effect<void>;
|
|
17
|
+
}
|
|
18
|
+
declare const StorageService_base: Context.TagClass<StorageService, "@dxos/functions/StorageService", Service>;
|
|
19
|
+
/**
|
|
20
|
+
* Scoped key-value storage service for processes.
|
|
21
|
+
* Each process receives its own namespaced instance via the process manager.
|
|
22
|
+
* Construct a live implementation with `StorageService.layer` from `@dxos/functions-runtime`.
|
|
23
|
+
*/
|
|
24
|
+
export declare class StorageService extends StorageService_base {
|
|
25
|
+
}
|
|
26
|
+
export declare const get: <S extends Schema.Schema<any, string, any>>(schema: S, key: string) => Effect.Effect<Option.Option<Schema.Schema.Type<S>>, never, StorageService | Schema.Schema.Context<S>>;
|
|
27
|
+
export declare const set: <S extends Schema.Schema<any, string, any>>(schema: S, key: string, value: Schema.Schema.Type<S>) => Effect.Effect<void, never, StorageService | Schema.Schema.Context<S>>;
|
|
28
|
+
export declare const deleteKey: (key: string) => Effect.Effect<void, never, StorageService>;
|
|
29
|
+
export declare const list: (prefix?: string | undefined) => Effect.Effect<readonly string[], never, StorageService>;
|
|
30
|
+
export declare const clear: () => Effect.Effect<void, never, StorageService>;
|
|
31
|
+
/**
|
|
32
|
+
* Typed key in a storage service.
|
|
33
|
+
*/
|
|
34
|
+
export interface Key<T> extends Pipeable.Pipeable {
|
|
35
|
+
readonly key: string;
|
|
36
|
+
get: Effect.Effect<Option.Option<T>, never, StorageService>;
|
|
37
|
+
set(value: T): Effect.Effect<void, never, StorageService>;
|
|
38
|
+
delete(): Effect.Effect<void, never, StorageService>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Create a typed key in a storage service.
|
|
42
|
+
*/
|
|
43
|
+
export declare const key: <S extends Schema.Schema<any, string, any>>(schema: S, key: string) => Key<Schema.Schema.Type<S>>;
|
|
44
|
+
/**
|
|
45
|
+
* Typed key in a storage service with a default value.
|
|
46
|
+
*/
|
|
47
|
+
export interface KeyWithDefault<T, U> extends Pipeable.Pipeable {
|
|
48
|
+
readonly key: string;
|
|
49
|
+
get: Effect.Effect<T | U, never, StorageService>;
|
|
50
|
+
set(value: U): Effect.Effect<void, never, StorageService>;
|
|
51
|
+
delete(): Effect.Effect<void, never, StorageService>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Assign a default value to a key if it is not present.
|
|
55
|
+
*/
|
|
56
|
+
export declare const withDefault: <T>(getDefault: () => NoInfer<T>) => (key: Key<T>) => KeyWithDefault<T, T>;
|
|
57
|
+
export {};
|
|
58
|
+
//# sourceMappingURL=StorageService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageService.d.ts","sourceRoot":"","sources":["../../../src/StorageService.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,MAAM,WAAW,OAAO;IACtB,iEAAiE;IACjE,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAC3C,MAAM,EAAE,CAAC,EACT,GAAG,EAAE,MAAM,GACV,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAExF,uCAAuC;IACvC,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAC3C,MAAM,EAAE,CAAC,EACT,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAC3B,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAExD,oBAAoB;IACpB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,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,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAUhH,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,QAAQ,CAAC,QAAQ;IAC7D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;IACjD,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;IAC1D,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;CACtD;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,GACrB,CAAC,cAAc,MAAM,OAAO,CAAC,CAAC,CAAC,WAC1B,GAAG,CAAC,CAAC,CAAC,KAAG,cAAc,CAAC,CAAC,EAAE,CAAC,CAUjC,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as Effect from 'effect/Effect';
|
|
2
|
+
import * as Schema from 'effect/Schema';
|
|
3
|
+
import { Registry } from '@dxos/echo';
|
|
4
|
+
import type { EntityNotFoundError } from '@dxos/echo/Err';
|
|
5
|
+
import { FunctionNotFoundError } from './errors';
|
|
6
|
+
import * as Operation from './Operation';
|
|
7
|
+
/**
|
|
8
|
+
* Template input kind determines how template variables are resolved.
|
|
9
|
+
*/
|
|
10
|
+
export declare const InputKind: Schema.Literal<["value", "operation"]>;
|
|
11
|
+
export type InputKind = Schema.Schema.Type<typeof InputKind>;
|
|
12
|
+
/**
|
|
13
|
+
* Template input variable.
|
|
14
|
+
* E.g., {{foo}}
|
|
15
|
+
*/
|
|
16
|
+
export declare const Input: Schema.Struct<{
|
|
17
|
+
name: typeof Schema.String;
|
|
18
|
+
kind: Schema.Literal<["value", "operation"]>;
|
|
19
|
+
default: Schema.optional<typeof Schema.Any>;
|
|
20
|
+
/**
|
|
21
|
+
* Operation key invoked when `kind === 'operation'`. The referenced operation must accept void input —
|
|
22
|
+
* template inputs have no mechanism for passing arguments.
|
|
23
|
+
*/
|
|
24
|
+
operation: Schema.optional<typeof Schema.String>;
|
|
25
|
+
}>;
|
|
26
|
+
export type Input = Schema.Schema.Type<typeof Input>;
|
|
27
|
+
/**
|
|
28
|
+
* Template type.
|
|
29
|
+
*/
|
|
30
|
+
export declare const Template: Schema.Struct<{
|
|
31
|
+
source: Schema.SchemaClass<import("@dxos/echo/internal").Ref<{
|
|
32
|
+
readonly name?: string | undefined;
|
|
33
|
+
readonly content: string;
|
|
34
|
+
} & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & import("@dxos/echo/Obj").Unknown>, import("@dxos/echo-protocol").EncodedReference, never>;
|
|
35
|
+
/**
|
|
36
|
+
* NOTE: We use an array rather than map so that updating variable names in the template doesn't disconnect existing inputs.
|
|
37
|
+
*/
|
|
38
|
+
inputs: Schema.optional<Schema.Array$<Schema.Struct<{
|
|
39
|
+
name: typeof Schema.String;
|
|
40
|
+
kind: Schema.Literal<["value", "operation"]>;
|
|
41
|
+
default: Schema.optional<typeof Schema.Any>;
|
|
42
|
+
/**
|
|
43
|
+
* Operation key invoked when `kind === 'operation'`. The referenced operation must accept void input —
|
|
44
|
+
* template inputs have no mechanism for passing arguments.
|
|
45
|
+
*/
|
|
46
|
+
operation: Schema.optional<typeof Schema.String>;
|
|
47
|
+
}>>>;
|
|
48
|
+
}>;
|
|
49
|
+
export type Template = Schema.Schema.Type<typeof Template>;
|
|
50
|
+
export type MakeProps = Partial<{
|
|
51
|
+
id: string;
|
|
52
|
+
source: string;
|
|
53
|
+
inputs: Input[];
|
|
54
|
+
}>;
|
|
55
|
+
export declare const make: ({ id, source, inputs }?: MakeProps) => Template;
|
|
56
|
+
/**
|
|
57
|
+
* Process Handlebars template.
|
|
58
|
+
*/
|
|
59
|
+
export declare const process: <Options extends {}>(source: string, variables?: Partial<Options>) => string;
|
|
60
|
+
export declare const processTemplate: (template: Template) => Effect.Effect<string, EntityNotFoundError | FunctionNotFoundError, Registry.Service | Operation.Service>;
|
|
61
|
+
//# sourceMappingURL=Template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Template.d.ts","sourceRoot":"","sources":["../../../src/Template.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAA8B,QAAQ,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAM1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAEzC;;GAEG;AACH,eAAO,MAAM,SAAS,wCASrB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,SAAS,CAAC,CAAC;AAE7D;;;GAGG;AACH,eAAO,MAAM,KAAK;;;;IAIhB;;;OAGG;;EAEH,CAAC;AAEH,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,KAAK,CAAC,CAAC;AAErD;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;;IAGnB;;OAEG;;;;;QAjBH;;;WAGG;;;EAgBH,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC3D,MAAM,MAAM,SAAS,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,KAAK,EAAE,CAAA;CAAE,CAAC,CAAC;AAEjF,eAAO,MA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