@dxos/compute 0.9.1-main.c7dcc2e112 → 0.9.1-staging.ee54ba693a
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/README.md +4 -4
- package/dist/lib/neutral/AgentService.mjs +12 -0
- package/dist/lib/neutral/StorageService.mjs +3 -3
- package/dist/lib/neutral/{chunk-AFBNVFAY.mjs → chunk-2ZN64ZS7.mjs} +3 -3
- package/dist/lib/neutral/{chunk-JAU4E4EK.mjs → chunk-5VAXF6AH.mjs} +2 -2
- package/dist/lib/neutral/{chunk-QZS4G6PE.mjs → chunk-EVROJER7.mjs} +70 -25
- package/dist/lib/neutral/chunk-EVROJER7.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-XEVFBI6S.mjs → chunk-PF7XP7XP.mjs} +13 -13
- package/dist/lib/neutral/{chunk-XEVFBI6S.mjs.map → chunk-PF7XP7XP.mjs.map} +3 -3
- package/dist/lib/neutral/{chunk-MEPE4HHX.mjs → chunk-SJ37RWHU.mjs} +3 -3
- package/dist/lib/neutral/chunk-VSAZPWSJ.mjs +25 -0
- package/dist/lib/neutral/chunk-VSAZPWSJ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-2B2KSJT6.mjs → chunk-WEO4FCQY.mjs} +3 -3
- package/dist/lib/neutral/fib-5XIYECL5.mjs +10 -0
- package/dist/lib/neutral/index.mjs +448 -399
- package/dist/lib/neutral/index.mjs.map +4 -4
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/reply-GCBRCUVM.mjs +10 -0
- package/dist/lib/neutral/sleep-XR6CL6W3.mjs +10 -0
- package/dist/lib/neutral/sleep-XR6CL6W3.mjs.map +7 -0
- package/dist/lib/neutral/testing/index.mjs +6 -6
- package/dist/types/src/AgentService.d.ts +71 -0
- package/dist/types/src/AgentService.d.ts.map +1 -0
- package/dist/types/src/Credential.d.ts +2 -0
- package/dist/types/src/Credential.d.ts.map +1 -1
- package/dist/types/src/Instructions.d.ts +33 -0
- package/dist/types/src/Instructions.d.ts.map +1 -0
- package/dist/types/src/McpServer.d.ts +1 -1
- package/dist/types/src/Operation.d.ts +92 -27
- package/dist/types/src/Operation.d.ts.map +1 -1
- package/dist/types/src/Operation.test.d.ts +2 -0
- package/dist/types/src/Operation.test.d.ts.map +1 -0
- package/dist/types/src/Process.d.ts +55 -21
- package/dist/types/src/Process.d.ts.map +1 -1
- package/dist/types/src/Runnable.d.ts +4 -0
- package/dist/types/src/Runnable.d.ts.map +1 -0
- package/dist/types/src/Script.d.ts +9 -11
- package/dist/types/src/Script.d.ts.map +1 -1
- package/dist/types/src/ServiceResolver.d.ts +1 -1
- package/dist/types/src/Skill.d.ts +157 -0
- package/dist/types/src/Skill.d.ts.map +1 -0
- package/dist/types/src/StorageService.d.ts +8 -8
- package/dist/types/src/StorageService.d.ts.map +1 -1
- package/dist/types/src/Template.d.ts +2 -4
- package/dist/types/src/Template.d.ts.map +1 -1
- package/dist/types/src/Trace.d.ts +16 -14
- package/dist/types/src/Trace.d.ts.map +1 -1
- package/dist/types/src/Trigger.d.ts +26 -61
- package/dist/types/src/Trigger.d.ts.map +1 -1
- package/dist/types/src/TriggerEvent.d.ts +3 -11
- package/dist/types/src/TriggerEvent.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +5 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -15
- package/src/AgentService.ts +90 -0
- package/src/Credential.ts +3 -0
- package/src/Instructions.ts +73 -0
- package/src/McpServer.ts +1 -1
- package/src/Operation.test.ts +39 -0
- package/src/Operation.ts +130 -54
- package/src/Process.ts +96 -26
- package/src/Runnable.ts +12 -0
- package/src/Script.ts +14 -14
- package/src/ServiceResolver.ts +1 -1
- package/src/Skill.ts +218 -0
- package/src/StorageService.ts +15 -12
- package/src/Template.ts +2 -1
- package/src/Trace.ts +13 -11
- package/src/Trigger.ts +57 -52
- package/src/index.ts +5 -3
- package/src/umbrella.test.ts +8 -6
- package/dist/lib/neutral/chunk-QZS4G6PE.mjs.map +0 -7
- package/dist/lib/neutral/fib-HBDUGQW7.mjs +0 -10
- package/dist/lib/neutral/reply-RJIAJ6FV.mjs +0 -10
- package/dist/lib/neutral/sleep-3T2CZ7RE.mjs +0 -10
- package/dist/types/src/Blueprint.d.ts +0 -182
- package/dist/types/src/Blueprint.d.ts.map +0 -1
- package/dist/types/src/Routine.d.ts +0 -54
- package/dist/types/src/Routine.d.ts.map +0 -1
- package/src/Blueprint.ts +0 -224
- package/src/Routine.ts +0 -69
- /package/dist/lib/neutral/{fib-HBDUGQW7.mjs.map → AgentService.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-AFBNVFAY.mjs.map → chunk-2ZN64ZS7.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-JAU4E4EK.mjs.map → chunk-5VAXF6AH.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-MEPE4HHX.mjs.map → chunk-SJ37RWHU.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-2B2KSJT6.mjs.map → chunk-WEO4FCQY.mjs.map} +0 -0
- /package/dist/lib/neutral/{reply-RJIAJ6FV.mjs.map → fib-5XIYECL5.mjs.map} +0 -0
- /package/dist/lib/neutral/{sleep-3T2CZ7RE.mjs.map → reply-GCBRCUVM.mjs.map} +0 -0
package/README.md
CHANGED
|
@@ -9,9 +9,9 @@ source packages. Namespaces preserve their nesting — there is no extra wrappin
|
|
|
9
9
|
or unwrapping:
|
|
10
10
|
|
|
11
11
|
```ts
|
|
12
|
-
import {
|
|
12
|
+
import { Skill, Operation, Instructions, Process, Script, Trace, Trigger } from '@dxos/compute';
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Skill.make({ /* ... */ });
|
|
15
15
|
Operation.lazy(() => /* ... */);
|
|
16
16
|
Trace.write(Trace.OperationStart, { /* ... */ });
|
|
17
17
|
```
|
|
@@ -21,7 +21,7 @@ This single surface subsumes:
|
|
|
21
21
|
| Re-exported from | Includes |
|
|
22
22
|
| ------------------ | --------------------------------------------------------------- |
|
|
23
23
|
| `@dxos/operation` | `Operation`, `OperationInvoker`, `OperationHandlerSet`, `OperationRegistry`, errors |
|
|
24
|
-
| `@dxos/
|
|
24
|
+
| `@dxos/compute` | `Skill`, `Instructions`, `Template` |
|
|
25
25
|
| `@dxos/functions` | `Process`, `Trigger`, `TriggerEvent`, `Script`, `Trace`, `ServiceResolver`, `StorageService`, `CredentialsService`, `ExampleHandlers`, services, errors, sdk |
|
|
26
26
|
|
|
27
27
|
The HyperFormula-based compute graph that previously lived here moved to
|
|
@@ -32,7 +32,7 @@ The HyperFormula-based compute graph that previously lived here moved to
|
|
|
32
32
|
- Stage 1 (current): re-exports — consumers depend only on `@dxos/compute`
|
|
33
33
|
while the source packages stay in place.
|
|
34
34
|
- Stage 2: migrate source into `@dxos/compute` and remove
|
|
35
|
-
`@dxos/operation
|
|
35
|
+
`@dxos/operation` and `@dxos/functions`.
|
|
36
36
|
- A companion `@dxos/compute-runtime-local` package will host the local
|
|
37
37
|
implementations of the services defined here (currently in
|
|
38
38
|
`@dxos/functions-runtime`).
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
StorageService,
|
|
3
|
+
cell,
|
|
3
4
|
clear,
|
|
4
5
|
deleteKey,
|
|
5
6
|
get,
|
|
6
|
-
key,
|
|
7
7
|
list,
|
|
8
8
|
set,
|
|
9
9
|
withDefault
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-PF7XP7XP.mjs";
|
|
11
11
|
import "./chunk-J5LGTIGS.mjs";
|
|
12
12
|
export {
|
|
13
13
|
StorageService,
|
|
14
|
+
cell,
|
|
14
15
|
clear,
|
|
15
16
|
deleteKey,
|
|
16
17
|
get,
|
|
17
|
-
key,
|
|
18
18
|
list,
|
|
19
19
|
set,
|
|
20
20
|
withDefault
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Fibonacci
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5VAXF6AH.mjs";
|
|
4
4
|
import {
|
|
5
5
|
withHandler
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-EVROJER7.mjs";
|
|
7
7
|
|
|
8
8
|
// src/testing/fib.ts
|
|
9
9
|
import * as Effect from "effect/Effect";
|
|
@@ -22,4 +22,4 @@ var fib_default = Fibonacci.pipe(withHandler(Effect.fn(function* ({ iterations =
|
|
|
22
22
|
export {
|
|
23
23
|
fib_default
|
|
24
24
|
};
|
|
25
|
-
//# sourceMappingURL=chunk-
|
|
25
|
+
//# sourceMappingURL=chunk-2ZN64ZS7.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
make
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EVROJER7.mjs";
|
|
4
4
|
|
|
5
5
|
// src/testing/definitions.ts
|
|
6
6
|
import * as Schema from "effect/Schema";
|
|
@@ -50,4 +50,4 @@ export {
|
|
|
50
50
|
Reply,
|
|
51
51
|
Sleep
|
|
52
52
|
};
|
|
53
|
-
//# sourceMappingURL=chunk-
|
|
53
|
+
//# sourceMappingURL=chunk-5VAXF6AH.mjs.map
|
|
@@ -7,9 +7,14 @@ var Operation_exports = {};
|
|
|
7
7
|
__export(Operation_exports, {
|
|
8
8
|
DefinitionTypeId: () => DefinitionTypeId,
|
|
9
9
|
IdempotentAnnotation: () => IdempotentAnnotation,
|
|
10
|
+
Label: () => Label,
|
|
11
|
+
NotifyOptions: () => NotifyOptions,
|
|
12
|
+
NotifyOptionsAnnotation: () => NotifyOptionsAnnotation,
|
|
10
13
|
PersistentOperation: () => PersistentOperation,
|
|
11
14
|
PersistentOperation_v0_1_0: () => PersistentOperation_v0_1_0,
|
|
12
15
|
Service: () => Service,
|
|
16
|
+
VisibleAnnotation: () => VisibleAnnotation,
|
|
17
|
+
annotate: () => annotate,
|
|
13
18
|
deserialize: () => deserialize,
|
|
14
19
|
getKey: () => getKey,
|
|
15
20
|
getVersion: () => getVersion,
|
|
@@ -17,12 +22,14 @@ __export(Operation_exports, {
|
|
|
17
22
|
isIdempotent: () => isIdempotent,
|
|
18
23
|
isOperationDefinition: () => isOperationDefinition,
|
|
19
24
|
isOperationWithHandler: () => isOperationWithHandler,
|
|
25
|
+
isVisible: () => isVisible,
|
|
20
26
|
make: () => make,
|
|
21
27
|
migrations: () => migrations,
|
|
22
28
|
opaqueHandler: () => opaqueHandler,
|
|
23
29
|
schedule: () => schedule,
|
|
24
30
|
serialize: () => serialize,
|
|
25
31
|
setFrom: () => setFrom,
|
|
32
|
+
visible: () => visible,
|
|
26
33
|
withHandler: () => withHandler,
|
|
27
34
|
withInvocationOptions: () => withInvocationOptions
|
|
28
35
|
});
|
|
@@ -31,8 +38,9 @@ import * as Effect from "effect/Effect";
|
|
|
31
38
|
import * as Layer from "effect/Layer";
|
|
32
39
|
import * as Option from "effect/Option";
|
|
33
40
|
import * as Pipeable from "effect/Pipeable";
|
|
41
|
+
import * as Schema from "effect/Schema";
|
|
34
42
|
import * as Schema$ from "effect/Schema";
|
|
35
|
-
import {
|
|
43
|
+
import { Annotation, DXN, JsonSchema, Migration, Obj, Ref, Type } from "@dxos/echo";
|
|
36
44
|
var DefinitionTypeId = "~@dxos/operation/OperationDefinition";
|
|
37
45
|
var isOperationDefinition = (value) => {
|
|
38
46
|
return typeof value === "object" && value !== null && DefinitionTypeId in value;
|
|
@@ -67,12 +75,12 @@ var withHandler = (opOrHandler, handler) => {
|
|
|
67
75
|
};
|
|
68
76
|
};
|
|
69
77
|
var opaqueHandler = (handler) => handler;
|
|
70
|
-
var PersistentOperation = Schema$.Struct({
|
|
78
|
+
var PersistentOperation = class extends Type.makeObject(DXN.make("org.dxos.type.function", "0.2.0"))(Schema$.Struct({
|
|
71
79
|
name: Schema$.NonEmptyString,
|
|
72
80
|
description: Schema$.optional(Schema$.String),
|
|
73
81
|
/**
|
|
74
|
-
|
|
75
|
-
|
|
82
|
+
* ISO date string of the last deployment.
|
|
83
|
+
*/
|
|
76
84
|
updated: Schema$.optional(Schema$.String),
|
|
77
85
|
// Reference to a source script if it exists within ECHO.
|
|
78
86
|
// TODO(burdon): Don't ref ScriptType directly (core).
|
|
@@ -80,30 +88,24 @@ var PersistentOperation = Schema$.Struct({
|
|
|
80
88
|
inputSchema: Schema$.optional(JsonSchema.JsonSchema),
|
|
81
89
|
outputSchema: Schema$.optional(JsonSchema.JsonSchema),
|
|
82
90
|
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
91
|
+
* List of required services.
|
|
92
|
+
* Match the Context.Tag keys of the FunctionServices variants.
|
|
93
|
+
*/
|
|
86
94
|
services: Schema$.optional(Schema$.Array(Schema$.String)),
|
|
87
95
|
// Local binding to a function name.
|
|
88
96
|
// TODO(dmaretskyi): Add this field to Operation.Definition.
|
|
89
97
|
binding: Schema$.optional(Schema$.String),
|
|
90
98
|
/**
|
|
91
|
-
|
|
92
|
-
|
|
99
|
+
* Phosphor icon identifier in `ph--<name>--<variant>` format (e.g. `ph--file-text--regular`).
|
|
100
|
+
*/
|
|
93
101
|
icon: Schema$.optional(Schema$.String)
|
|
94
|
-
}).pipe(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}),
|
|
102
|
-
Annotation.HiddenAnnotation.set(true),
|
|
103
|
-
// TODO(dmaretskyi): Keep typename as 'org.dxos.type.function' (not 'operation') to maintain
|
|
104
|
-
// backward compatibility with existing data and avoid requiring data migration.
|
|
105
|
-
Type.makeObject(DXN.make("org.dxos.type.function", "0.2.0"))
|
|
106
|
-
);
|
|
102
|
+
}).pipe(Annotation.LabelAnnotation.set([
|
|
103
|
+
"name"
|
|
104
|
+
]), Annotation.IconAnnotation.set({
|
|
105
|
+
icon: "ph--function--regular",
|
|
106
|
+
hue: "blue"
|
|
107
|
+
}), Annotation.HiddenAnnotation.set(true))) {
|
|
108
|
+
};
|
|
107
109
|
var FUNCTION_META_KEY = "org.dxos.service.function";
|
|
108
110
|
var getKey = (record) => Obj.getMeta(record).key;
|
|
109
111
|
var getVersion = (record) => Obj.getMeta(record).version;
|
|
@@ -168,11 +170,52 @@ var setFrom = (target, source) => {
|
|
|
168
170
|
targetMeta.annotations = sourceMeta.annotations ?? targetMeta.annotations;
|
|
169
171
|
});
|
|
170
172
|
};
|
|
173
|
+
var Label = Schema.Union(
|
|
174
|
+
Schema.String,
|
|
175
|
+
// `Schema.mutable` mirrors the app-level `Label` (whose tuple is mutable), so decoded values are
|
|
176
|
+
// assignable to UI toast `title`/`label` slots without a readonly-vs-mutable tuple mismatch.
|
|
177
|
+
Schema.mutable(Schema.Tuple(Schema.String, Schema.mutable(Schema.Struct({
|
|
178
|
+
ns: Schema.String,
|
|
179
|
+
count: Schema.optional(Schema.Number),
|
|
180
|
+
defaultValue: Schema.optional(Schema.String)
|
|
181
|
+
}))))
|
|
182
|
+
);
|
|
183
|
+
var NotifyOptions = Schema.Struct({
|
|
184
|
+
/** Shown when the invocation starts. */
|
|
185
|
+
start: Schema.optional(Label),
|
|
186
|
+
/** Shown when the invocation succeeds. */
|
|
187
|
+
success: Schema.optional(Label),
|
|
188
|
+
/** Shown when the invocation fails. */
|
|
189
|
+
error: Schema.optional(Label)
|
|
190
|
+
});
|
|
191
|
+
var NotifyOptionsAnnotation = Annotation.make({
|
|
192
|
+
id: "org.dxos.operation.notify-options",
|
|
193
|
+
schema: NotifyOptions
|
|
194
|
+
});
|
|
171
195
|
var IdempotentAnnotation = Annotation.make({
|
|
172
196
|
id: "org.dxos.operation.idempotent",
|
|
173
197
|
schema: Schema$.Boolean
|
|
174
198
|
});
|
|
175
199
|
var isIdempotent = (op) => op.meta.annotations ? Option.getOrElse(Annotation.getDictionary(op.meta.annotations, IdempotentAnnotation), () => false) : false;
|
|
200
|
+
var annotate = (annotation, value) => (op) => {
|
|
201
|
+
const annotations = {
|
|
202
|
+
...op.meta.annotations ?? {}
|
|
203
|
+
};
|
|
204
|
+
Annotation.setDictionary(annotations, annotation, value);
|
|
205
|
+
return {
|
|
206
|
+
...op,
|
|
207
|
+
meta: {
|
|
208
|
+
...op.meta,
|
|
209
|
+
annotations
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
var VisibleAnnotation = Annotation.make({
|
|
214
|
+
id: "org.dxos.operation.visible",
|
|
215
|
+
schema: Schema$.Boolean
|
|
216
|
+
});
|
|
217
|
+
var visible = annotate(VisibleAnnotation, true);
|
|
218
|
+
var isVisible = (op) => Option.getOrElse(Annotation.get(op, VisibleAnnotation), () => false);
|
|
176
219
|
var Service = class extends Context.Tag("@dxos/operation/Service")() {
|
|
177
220
|
};
|
|
178
221
|
var invoke = (op, ...args) => Effect.flatMap(Service, (ops) => ops.invoke(op, ...args)).pipe(Effect.withSpan("Operation.invoke"));
|
|
@@ -194,7 +237,7 @@ var withInvocationOptions = (options) => Layer.effect(Service, Effect.gen(functi
|
|
|
194
237
|
})
|
|
195
238
|
});
|
|
196
239
|
}));
|
|
197
|
-
var PersistentOperation_v0_1_0 = Schema$.Struct({
|
|
240
|
+
var PersistentOperation_v0_1_0 = class extends Type.makeObject(DXN.make("org.dxos.type.function", "0.1.0"))(Schema$.Struct({
|
|
198
241
|
key: Schema$.optional(Schema$.String),
|
|
199
242
|
name: Schema$.NonEmptyString,
|
|
200
243
|
version: Schema$.String,
|
|
@@ -205,7 +248,8 @@ var PersistentOperation_v0_1_0 = Schema$.Struct({
|
|
|
205
248
|
outputSchema: Schema$.optional(JsonSchema.JsonSchema),
|
|
206
249
|
services: Schema$.optional(Schema$.Array(Schema$.String)),
|
|
207
250
|
binding: Schema$.optional(Schema$.String)
|
|
208
|
-
})
|
|
251
|
+
})) {
|
|
252
|
+
};
|
|
209
253
|
var _migration = Migration.define({
|
|
210
254
|
from: PersistentOperation_v0_1_0,
|
|
211
255
|
to: PersistentOperation,
|
|
@@ -233,8 +277,9 @@ export {
|
|
|
233
277
|
withHandler,
|
|
234
278
|
PersistentOperation,
|
|
235
279
|
deserialize,
|
|
280
|
+
NotifyOptions,
|
|
236
281
|
isIdempotent,
|
|
237
282
|
invoke,
|
|
238
283
|
Operation_exports
|
|
239
284
|
};
|
|
240
|
-
//# sourceMappingURL=chunk-
|
|
285
|
+
//# sourceMappingURL=chunk-EVROJER7.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/Operation.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\nimport * as Pipeable from 'effect/Pipeable';\nimport * as Schema from 'effect/Schema';\nimport * as Schema$ from 'effect/Schema';\nimport type * as Types from 'effect/Types';\n\nimport { Annotation, DXN, JsonSchema, type Key, Migration, Obj, Ref, Type } from '@dxos/echo';\nimport type { URI } from '@dxos/keys';\n\nimport type { NoHandlerError } from './errors';\nimport type { Operation } from './index';\n\n/**\n * Schema type that accepts any Encoded form but requires no Context.\n * This allows ECHO object schemas where Type !== Encoded due to [KindId] symbol.\n */\ntype Schema<T> = Schema$.Schema<T, any, never>;\n\nexport const DefinitionTypeId = '~@dxos/operation/OperationDefinition' as const;\nexport type DefinitionTypeId = typeof DefinitionTypeId;\n\n/**\n * Serializable definition of an Operation.\n * Contains schema and metadata, but no runtime logic.\n */\nexport interface Definition<I, O, S = any> extends Pipeable.Pipeable, Definition.Variance<I, O, S> {\n /**\n * Input schema for the operation.\n */\n readonly input: Schema<I>;\n /**\n * Output schema for the operation.\n */\n readonly output: Schema<O>;\n\n readonly meta: {\n readonly key: DXN.DXN;\n readonly name?: string;\n readonly version?: string;\n readonly description?: string;\n /**\n * Phosphor icon identifier in `ph--<name>--<variant>` format (e.g. `ph--file-text--regular`).\n */\n readonly icon?: string;\n /**\n * Deployment ID for remote invocation.\n * Assigned by the EDGE function service when deployed.\n */\n readonly deployedId?: string;\n\n /**\n * Dictionary of annotations for the operation.\n */\n // TODO(dmaretskyi): Make required, but this complicates `make` to fill in defaults.\n readonly annotations?: Annotation.Dictionary;\n\n /**\n * When true, this operation is not serialized into the hypergraph registry.\n * Use for UI-only operations that should not be discoverable by the AI agent.\n */\n readonly skipRegistry?: boolean;\n };\n\n /**\n * Execution mode for the operation.\n * - 'sync': Operation completes synchronously (fast, UI-blocking acceptable).\n * - 'async': Operation may take time (should not block UI).\n */\n readonly executionMode: 'sync' | 'async';\n\n /**\n * ECHO types the operation uses.\n * Ensures types are available when the operation is executed remotely.\n */\n readonly types: readonly Type.AnyEntity[];\n\n /**\n * Effect services required by this operation.\n * These services will be automatically provided to the handler at invocation time.\n */\n readonly services: readonly Context.Tag<any, any>[];\n}\n\n/**\n * Namespace for OperationDefinition helper types.\n */\nexport declare namespace Definition {\n export interface Variance<I, O, S> {\n [DefinitionTypeId]: {\n readonly _Input: Types.Contravariant<I>;\n readonly _Output: Types.Covariant<O>;\n readonly _Services: Types.Covariant<S>;\n };\n }\n\n /**\n * Any operation definition, regardless of input/output types.\n */\n export type Any = Definition<any, any, any>;\n\n /**\n * Extract the input type from an operation definition.\n */\n export type Input<T extends Any> = T extends Variance<infer I, infer _O, infer _S> ? I : never;\n\n /**\n * Extract the output type from an operation definition.\n */\n export type Output<T extends Any> = T extends Variance<infer _I, infer O, infer _S> ? O : never;\n\n /**\n * Extract the service identifier types from an operation's services array.\n * Returns `never` if the operation has no services declared.\n */\n export type Services<T extends Any> = T extends Variance<infer _I, infer _O, infer S> ? S : never;\n\n export type HandlerType<T extends Any> =\n T extends Variance<infer I, infer O, infer S> ? Handler<I, O, any, S> : never;\n}\n\n/**\n * Runtime handler for an Operation.\n */\nexport type Handler<I, O, E = Error, R = never> = (input: I) => Effect.Effect<O, E, R>;\n\nexport type WithHandler<T extends Definition.Any> = T & {\n handler: Definition.HandlerType<T>;\n};\n\n/**\n * Checks if a value is an operation definition.\n */\nexport const isOperationDefinition = (value: unknown): value is Definition.Any => {\n return typeof value === 'object' && value !== null && DefinitionTypeId in value;\n};\n\n/**\n * Checks if a value is an operation with a handler.\n */\nexport const isOperationWithHandler = (value: unknown): value is WithHandler<Definition.Any> => {\n return isOperationDefinition(value) && 'handler' in value;\n};\n\n/**\n * Props for creating an Operation definition.\n * Derived from OperationDefinition with executionMode made optional (defaults to 'async').\n */\nexport type Props<I, O> = Omit<Definition<I, O>, DefinitionTypeId | 'pipe' | 'executionMode' | 'types' | 'services'> & {\n readonly executionMode?: 'sync' | 'async';\n readonly types?: Definition<I, O>['types'];\n readonly services?: Definition<I, O>['services'];\n};\n\n/**\n * Creates a new Operation definition.\n * Applies default executionMode of 'async' if not specified.\n * The returned type preserves the literal types of props (including services).\n */\nexport const make = <const P extends Types.NoExcessProperties<Props<any, any>, P>>(\n props: P,\n): Definition<\n Schema$.Schema.Type<P['input']>,\n Schema$.Schema.Type<P['output']>,\n Context.Tag.Identifier<NonNullable<P['services']>[number]>\n> => {\n return {\n [DefinitionTypeId]: {},\n ...props,\n executionMode: props.executionMode ?? 'async',\n types: props.types ?? [],\n services: props.services ?? [],\n pipe() {\n // eslint-disable-next-line prefer-rest-params\n return Pipeable.pipeArguments(this, arguments);\n },\n } as any;\n};\n\n/**\n * Attaches a handler to an Operation definition.\n * The handler may use any services declared in the operation, plus Operation.Service (always available).\n * Dual API: can be called directly or used in a pipe.\n *\n * @example\n * ```ts\n * const MyOp = Operation.make({\n * input: Schema.Void,\n * output: Schema.Void,\n * meta: { key: 'my-op' },\n * services: [DatabaseService],\n * });\n *\n * // Direct call - handler can use DatabaseService\n * const op = Operation.withHandler(MyOp, (input) =>\n * Effect.gen(function* () {\n * const db = yield* DatabaseService;\n * return {};\n * }),\n * );\n *\n * // Piped call\n * const op = MyOp.pipe(Operation.withHandler((input) => Effect.succeed({})));\n * ```\n */\nexport const withHandler: {\n <Def extends Definition<any, any>, E = never>(\n handler: Handler<Definition.Input<Def>, Definition.Output<Def>, E, Definition.Services<Def> | Service>,\n ): (op: Def) => WithHandler<Def>;\n <Def extends Definition<any, any>, E = never>(\n op: Def,\n handler: Handler<Definition.Input<Def>, Definition.Output<Def>, E, Definition.Services<Def> | Service>,\n ): WithHandler<Def>;\n} = <Def extends Definition<any, any>, E = never>(\n opOrHandler: Def | Handler<Definition.Input<Def>, Definition.Output<Def>, E, Definition.Services<Def> | Service>,\n handler?: Handler<Definition.Input<Def>, Definition.Output<Def>, E, Definition.Services<Def> | Service>,\n): WithHandler<Def> => {\n // If called with just handler (piped usage).\n if (handler === undefined) {\n const handlerFn = opOrHandler as Handler<\n Definition.Input<Def>,\n Definition.Output<Def>,\n E,\n Definition.Services<Def> | Service\n >;\n return ((op: Def) => ({\n ...op,\n handler: handlerFn,\n })) as any;\n }\n\n // If called with both op and handler (direct usage).\n const op = opOrHandler as Def;\n return {\n ...op,\n handler,\n } as any;\n};\n\n/**\n * Helper to make the handler type opaque.\n * Workaround for TypeScript's inability to infer the handler type from the operation definition:\n * ```\n * error TS2742: The inferred type of 'default' cannot be named without a reference.\n * ```\n *\n * Most of the time the exact handler type is not needed.\n *\n * @example\n * ```ts\n * const MyOp = Operation.make({\n * input: Schema.Void,\n * output: Schema.Void,\n * meta: { key: 'my-op' },\n * services: [DatabaseService],\n * });\n *\n * export default MyOp.pipe(\n * Operation.withHandler(\n * Effect.fn(function* (input) {\n * return { result: 'ok' };\n * }),\n * ),\n * Operation.opaqueHandler,\n * );\n * ```\n */\nexport const opaqueHandler = <T extends Operation.Definition.Any>(\n handler: Operation.WithHandler<T>,\n): Operation.WithHandler<Operation.Definition.Any> => handler;\n\n//\n// Invocation Interfaces\n//\n\n/**\n * Local invocation of an operation.\n */\nexport type Invoke = <I, O, E>(op: Definition<I, O>, input: I) => Effect.Effect<O, E>;\n\n/**\n * Remote invocation of an operation.\n */\nexport type InvokeRemote = <I, O, E>(\n op: Definition<I, O>,\n input: I,\n options?: { timeout?: number },\n) => Effect.Effect<O, E>;\n\n/**\n * Database record of an operation.\n * The registry `key` and `version` live in the object meta — access via\n * `Obj.getMeta(record).key` and `Obj.getMeta(record).version`.\n */\n// TODO(dmaretskyi): Keep typename as 'org.dxos.type.function' (not 'operation') to maintain\n// backward compatibility with existing data and avoid requiring data migration.\nexport class PersistentOperation extends Type.makeObject<PersistentOperation>(\n DXN.make('org.dxos.type.function', '0.2.0'),\n)(\n Schema$.Struct({\n name: Schema$.NonEmptyString,\n\n description: Schema$.optional(Schema$.String),\n\n /**\n * ISO date string of the last deployment.\n */\n updated: Schema$.optional(Schema$.String),\n\n // Reference to a source script if it exists within ECHO.\n // TODO(burdon): Don't ref ScriptType directly (core).\n source: Schema$.optional(Ref.Ref(Obj.Unknown)),\n\n inputSchema: Schema$.optional(JsonSchema.JsonSchema),\n outputSchema: Schema$.optional(JsonSchema.JsonSchema),\n\n /**\n * List of required services.\n * Match the Context.Tag keys of the FunctionServices variants.\n */\n services: Schema$.optional(Schema$.Array(Schema$.String)),\n\n // Local binding to a function name.\n // TODO(dmaretskyi): Add this field to Operation.Definition.\n binding: Schema$.optional(Schema$.String),\n\n /**\n * Phosphor icon identifier in `ph--<name>--<variant>` format (e.g. `ph--file-text--regular`).\n */\n icon: Schema$.optional(Schema$.String),\n }).pipe(\n Annotation.LabelAnnotation.set(['name']),\n Annotation.IconAnnotation.set({ icon: 'ph--function--regular', hue: 'blue' }),\n Annotation.HiddenAnnotation.set(true),\n ),\n) {}\n\nconst FUNCTION_META_KEY = 'org.dxos.service.function';\n\n/**\n * Get the registry key for a persistent operation record (from the object meta).\n */\nexport const getKey = (record: PersistentOperation): string | undefined => Obj.getMeta(record).key;\n\n/**\n * Get the registry version for a persistent operation record (from the object meta).\n */\nexport const getVersion = (record: PersistentOperation): string | undefined => Obj.getMeta(record).version;\n\n/**\n * Serialize an operation definition to a persistent operation record.\n */\nexport const serialize = (operation: Definition.Any): PersistentOperation => {\n return Obj.make(PersistentOperation, {\n [Obj.Meta]: {\n key: operation.meta.key,\n version: operation.meta.version ?? '0.0.0',\n keys: operation.meta.deployedId ? [{ source: FUNCTION_META_KEY, id: operation.meta.deployedId }] : [],\n annotations: operation.meta.annotations,\n },\n name: operation.meta.name ?? '',\n description: operation.meta.description,\n icon: operation.meta.icon,\n updated: undefined,\n source: undefined,\n inputSchema: JsonSchema.toJsonSchema(operation.input),\n outputSchema: JsonSchema.toJsonSchema(operation.output),\n services: operation.services.map((service) => service.key),\n });\n};\n\n/**\n * Deserialize a persistent operation record to an operation definition.\n */\nexport const deserialize = (record: PersistentOperation): Definition.Any => {\n const meta = Obj.getMeta(record);\n // Extract deployed function ID from ECHO meta keys (matches FUNCTIONS_META_KEY in @dxos/functions).\n const deployedId = meta.keys.find((key) => key.source === FUNCTION_META_KEY)?.id;\n return make({\n input: record.inputSchema ? JsonSchema.toEffectSchema(record.inputSchema) : Schema$.Unknown,\n output: record.outputSchema ? JsonSchema.toEffectSchema(record.outputSchema) : Schema$.Unknown,\n services: record.services?.map((service) => Context.GenericTag(service)) ?? [],\n executionMode: 'async',\n types: [],\n meta: {\n key: DXN.tryMake(meta.key ?? record.name) ?? DXN.make(meta.key ?? record.name),\n name: record.name,\n version: meta.version ?? '0.0.0',\n description: record.description,\n icon: record.icon,\n deployedId,\n annotations: meta.annotations ?? {},\n },\n });\n};\n\n/**\n * Update properties on the target operation record from the source operation record.\n */\nexport const setFrom = (target: PersistentOperation, source: PersistentOperation) => {\n Obj.update(target, (target) => {\n target.name = source.name ?? target.name;\n target.description = source.description;\n target.icon = source.icon;\n target.updated = source.updated;\n // TODO(dmaretskyi): A workaround for an ECHO bug.\n target.inputSchema = source.inputSchema ? JSON.parse(JSON.stringify(source.inputSchema)) : undefined;\n target.outputSchema = source.outputSchema ? JSON.parse(JSON.stringify(source.outputSchema)) : undefined;\n const sourceMeta = Obj.getMeta(source);\n const targetMeta = Obj.getMeta(target);\n targetMeta.key = sourceMeta.key ?? targetMeta.key;\n targetMeta.version = sourceMeta.version;\n // Only overwrite foreign keys when the source actually carries them; otherwise we'd wipe\n // bindings (e.g. the deployedId set by `deserialize`) on records produced by `serialize`.\n if (sourceMeta.keys.length > 0) {\n targetMeta.keys = JSON.parse(JSON.stringify(sourceMeta.keys));\n }\n targetMeta.annotations = sourceMeta.annotations ?? targetMeta.annotations;\n });\n};\n\n/**\n * Translatable label — a plain string or an i18next-style `[key, options]` tuple.\n * Defined locally to avoid a core dependency on UI translation packages; structurally compatible with\n * the app-level `Label` type so values flow into UI toasts unchanged.\n */\nexport const Label = Schema.Union(\n Schema.String,\n // `Schema.mutable` mirrors the app-level `Label` (whose tuple is mutable), so decoded values are\n // assignable to UI toast `title`/`label` slots without a readonly-vs-mutable tuple mismatch.\n Schema.mutable(\n Schema.Tuple(\n Schema.String,\n Schema.mutable(\n Schema.Struct({\n ns: Schema.String,\n count: Schema.optional(Schema.Number),\n defaultValue: Schema.optional(Schema.String),\n }),\n ),\n ),\n ),\n);\nexport type Label = Schema.Schema.Type<typeof Label>;\n\n/**\n * Per-phase user notification messages for an invocation.\n * A phase is notified to the user iff its message is provided; messages are translatable {@link Label}s.\n */\nexport const NotifyOptions = Schema.Struct({\n /** Shown when the invocation starts. */\n start: Schema.optional(Label),\n /** Shown when the invocation succeeds. */\n success: Schema.optional(Label),\n /** Shown when the invocation fails. */\n error: Schema.optional(Label),\n});\nexport type NotifyOptions = Schema.Schema.Type<typeof NotifyOptions>;\n\n/**\n * Annotation that configures the process to notify the user at the given invocation phases.\n */\nexport const NotifyOptionsAnnotation = Annotation.make({\n id: 'org.dxos.operation.notify-options',\n schema: NotifyOptions,\n});\n\n/**\n * Options for operation invocation.\n */\nexport interface InvokeOptions {\n /**\n * Space ID to provide database context for the handler.\n */\n spaceId?: Key.SpaceId;\n /**\n * Request user-facing notifications at the given invocation phases.\n */\n notify?: NotifyOptions;\n /**\n * URI of the conversation feed (queue) — today always an EID, but typed as\n * `URI.URI` to accommodate future entity-kind extensions. Narrow with `EID.parse`\n * at the point of use.\n * Passed to the process environment so nested operations can resolve HarnessService and related services.\n */\n conversation?: URI.URI;\n /**\n * Optional process-runtime tracing metadata (consumed by `@dxos/functions-runtime` when wired).\n */\n tracing?: unknown;\n}\n\n/**\n * Annotation that marks an operation as idempotent — safe to retry even if a previous execution\n * was interrupted mid-handler. When absent the operation is treated as non-idempotent, and the\n * process runtime will fail (rather than re-run) any handler that was interrupted.\n */\nexport const IdempotentAnnotation = Annotation.make({\n id: 'org.dxos.operation.idempotent',\n schema: Schema$.Boolean,\n});\n\n/**\n * Returns true when the operation is explicitly annotated as idempotent.\n */\nexport const isIdempotent = (op: Definition.Any): boolean =>\n op.meta.annotations\n ? Option.getOrElse(Annotation.getDictionary(op.meta.annotations, IdempotentAnnotation), () => false)\n : false;\n\n/**\n * Attaches an annotation to an operation definition, returning a new definition.\n * Combinators never mutate their input — operation definitions are module-level singletons\n * shared across handler sets, skills, and the registry, so a fresh value keeps the\n * annotated definition distinct from any other reference to the original.\n *\n * Type-preserving: an annotation does not change the operation's input/output/service types, so the\n * returned definition keeps `Def` (preserving `withHandler` inference and downstream usage).\n */\nexport const annotate =\n <T>(annotation: Annotation.Annotation<T>, value: T) =>\n <Def extends Definition.Any>(op: Def): Def => {\n const annotations = { ...(op.meta.annotations ?? {}) };\n Annotation.setDictionary(annotations, annotation, value);\n // The spread reconstructs the same shape with only `meta.annotations` changed; the checker can't\n // track the branded variance symbol through the untyped dictionary mutation, so reassert `Def`.\n return { ...op, meta: { ...op.meta, annotations } } as Def;\n };\n\n/**\n * Marks an operation as visible on user-facing operation surfaces (trigger/automation pickers,\n * manual invocation). Absent ⇒ internal: invoked programmatically by plugins and hidden from pickers.\n *\n * Polarity is inverted from the schema-level `HiddenAnnotation` (default visible): operations are\n * hidden by default, since most are internal plugin machinery and only a minority are user-facing.\n */\nexport const VisibleAnnotation = Annotation.make({\n id: 'org.dxos.operation.visible',\n schema: Schema$.Boolean,\n});\n\n/**\n * Pipeable combinator that marks an operation visible. Apply at the definition site:\n * `Operation.make({ ... }).pipe(Operation.visible)`.\n */\nexport const visible = annotate(VisibleAnnotation, true);\n\n/**\n * Returns true when an operation is annotated as visible on user-facing surfaces (trigger/automation\n * pickers, manual invocation). Reads from the persisted operation — the form every consumer holds.\n */\nexport const isVisible = (op: PersistentOperation): boolean =>\n Option.getOrElse(Annotation.get(op, VisibleAnnotation), () => false);\n\n/**\n * Operation service interface - provides unified access to operation invocation and scheduling.\n * This service is automatically provided to operation handlers.\n */\nexport interface OperationService {\n /**\n * Invoke an operation as an Effect.\n * Returns an Effect that resolves to the operation output.\n */\n invoke: <I, O>(\n op: Operation.Definition<I, O>,\n ...args: void extends I ? [input?: I, options?: InvokeOptions] : [input: I, options?: InvokeOptions]\n ) => Effect.Effect<O, NoHandlerError>;\n\n /**\n * Schedule an operation to run as a followup.\n * The followup is tracked and won't be cancelled when the parent operation completes.\n * Returns an Effect that completes immediately after scheduling.\n */\n schedule: <I, O>(\n op: Operation.Definition<I, O>,\n ...args: void extends I ? [input?: I, options?: InvokeOptions] : [input: I, options?: InvokeOptions]\n ) => Effect.Effect<void>;\n\n /**\n * Invoke an operation and return a Promise.\n * Useful for async contexts where Effect is not available.\n */\n invokePromise: <I, O>(\n op: Operation.Definition<I, O>,\n ...args: void extends I ? [input?: I, options?: InvokeOptions] : [input: I, options?: InvokeOptions]\n ) => Promise<{ data?: O; error?: Error }>;\n}\n\n/**\n * Context tag for the Operation service.\n * Operation handlers can yield this to invoke other operations or schedule followups.\n *\n * @example\n * ```ts\n * const handler = (input) => Effect.gen(function* () {\n * // Schedule a followup (fire and forget)\n * yield* Operation.schedule(AnalyticsOperation, { event: 'completed' });\n *\n * // Invoke another operation\n * return yield* Operation.invoke(OtherOperation, { data: input.data });\n * });\n * ```\n */\n// TODO(dmaretskyi): Rename Operation.Invoker\nexport class Service extends Context.Tag('@dxos/operation/Service')<Service, OperationService>() {}\n\n//\n// Namespace functions - ergonomic access to Operation.Service methods.\n//\n\n/**\n * Invoke an operation as an Effect.\n * Yields the Operation.Service internally.\n *\n * @example\n * ```ts\n * yield* Operation.invoke(MyOperation, { data: 'test' });\n * ```\n */\nexport const invoke = <I, O>(\n op: Operation.Definition<I, O>,\n ...args: void extends I ? [input?: I, options?: InvokeOptions] : [input: I, options?: InvokeOptions]\n): Effect.Effect<O, NoHandlerError, Service> =>\n Effect.flatMap(Service, (ops) => ops.invoke(op, ...(args as [I, InvokeOptions?]))).pipe(\n Effect.withSpan('Operation.invoke'),\n );\n\n/**\n * Schedule an operation to run as a followup.\n * Yields the Operation.Service internally.\n *\n * @example\n * ```ts\n * yield* Operation.schedule(AnalyticsOperation, { event: 'completed' });\n * yield* Operation.schedule(VoidOperation); // input optional when void\n * ```\n */\nexport const schedule = <I, O>(\n op: Operation.Definition<I, O>,\n ...args: void extends I ? [input?: I, options?: InvokeOptions] : [input: I, options?: InvokeOptions]\n): Effect.Effect<void, never, Service> =>\n Effect.flatMap(Service, (ops) => ops.schedule(op, ...(args as [I, InvokeOptions?]))).pipe(\n Effect.withSpan('Operation.schedule'),\n );\n\n/**\n * Provides additional invocation options to all invocations.\n */\nexport const withInvocationOptions = (options: InvokeOptions): Layer.Layer<Service, never, Service> =>\n Layer.effect(\n Service,\n Effect.gen(function* () {\n const service = yield* Service;\n return Service.of({\n invoke: ((op: Operation.Definition.Any, input: any, invocationOptions: InvokeOptions) =>\n service.invoke(op, input, { ...options, ...invocationOptions })) as any,\n invokePromise: ((op: Operation.Definition.Any, input: any, invocationOptions: InvokeOptions) =>\n service.invokePromise(op, input, { ...options, ...invocationOptions })) as any,\n schedule: ((op: Operation.Definition.Any, input: any, invocationOptions: InvokeOptions) =>\n service.schedule(op, input, { ...options, ...invocationOptions })) as any,\n });\n }),\n );\n\n//\n// Legacy schemas and migrations.\n//\n\n/**\n * Persistent operation schema v0.1.0 — `key` and `version` are stored as data properties.\n * @deprecated Use {@link PersistentOperation} (v0.2.0) instead; the `key` and `version` now live in the object meta.\n */\nexport class PersistentOperation_v0_1_0 extends Type.makeObject<PersistentOperation_v0_1_0>(\n DXN.make('org.dxos.type.function', '0.1.0'),\n)(\n Schema$.Struct({\n key: Schema$.optional(Schema$.String),\n name: Schema$.NonEmptyString,\n version: Schema$.String,\n description: Schema$.optional(Schema$.String),\n updated: Schema$.optional(Schema$.String),\n source: Schema$.optional(Ref.Ref(Obj.Unknown)),\n inputSchema: Schema$.optional(JsonSchema.JsonSchema),\n outputSchema: Schema$.optional(JsonSchema.JsonSchema),\n services: Schema$.optional(Schema$.Array(Schema$.String)),\n binding: Schema$.optional(Schema$.String),\n }),\n) {}\n\n/**\n * Migration from {@link PersistentOperation_v0_1_0} (v0.1.0) to {@link PersistentOperation} (v0.2.0).\n * Moves `key` and `version` from the data section into the object meta.\n */\nconst _migration = Migration.define({\n from: PersistentOperation_v0_1_0,\n to: PersistentOperation,\n transform: async (from) => ({\n [Obj.Meta]: { key: from.key, version: from.version },\n name: from.name,\n description: from.description,\n updated: from.updated,\n source: from.source as any,\n inputSchema: from.inputSchema,\n outputSchema: from.outputSchema,\n services: from.services,\n binding: from.binding,\n }),\n});\n\n/**\n * Schema migrations exported by this module.\n * Exported as an array for extensibility — append future versions here.\n */\nexport const migrations = [_migration];\n"],
|
|
5
|
+
"mappings": ";;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,YAAYA,aAAa;AACzB,YAAYC,YAAY;AACxB,YAAYC,WAAW;AACvB,YAAYC,YAAY;AACxB,YAAYC,cAAc;AAC1B,YAAYC,YAAY;AACxB,YAAYC,aAAa;AAGzB,SAASC,YAAYC,KAAKC,YAAsBC,WAAWC,KAAKC,KAAKC,YAAY;AAY1E,IAAMC,mBAAmB;AAkHzB,IAAMC,wBAAwB,CAACC,UAAAA;AACpC,SAAO,OAAOA,UAAU,YAAYA,UAAU,QAAQF,oBAAoBE;AAC5E;AAKO,IAAMC,yBAAyB,CAACD,UAAAA;AACrC,SAAOD,sBAAsBC,KAAAA,KAAU,aAAaA;AACtD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IACXE,aAAa8F,KAAK9F;IAClBG,SAAS2F,KAAK3F;IACdC,QAAQ0F,KAAK1F;IACbE,aAAawF,KAAKxF;IAClBC,cAAcuF,KAAKvF;IACnBvB,UAAU8G,KAAK9G;IACfyB,SAASqF,KAAKrF;EAChB;AACF,CAAA;AAMO,IAAMwF,aAAa;EAACL;;",
|
|
6
|
+
"names": ["Context", "Effect", "Layer", "Option", "Pipeable", "Schema", "Schema$", "Annotation", "DXN", "JsonSchema", "Migration", "Obj", "Ref", "Type", "DefinitionTypeId", "isOperationDefinition", "value", "isOperationWithHandler", "make", "props", "executionMode", "types", "services", "pipe", "pipeArguments", "arguments", "withHandler", "opOrHandler", "handler", "undefined", "handlerFn", "op", "opaqueHandler", "PersistentOperation", "makeObject", "Struct", "name", "NonEmptyString", "description", "optional", "String", "updated", "source", "Unknown", "inputSchema", "outputSchema", "Array", "binding", "icon", "LabelAnnotation", "set", "IconAnnotation", "hue", "HiddenAnnotation", "FUNCTION_META_KEY", "getKey", "record", "getMeta", "key", "getVersion", "version", "serialize", "operation", "Meta", "meta", "keys", "deployedId", "id", "annotations", "toJsonSchema", "input", "output", "map", "service", "deserialize", "find", "toEffectSchema", "GenericTag", "tryMake", "setFrom", "target", "update", "JSON", "parse", "stringify", "sourceMeta", "targetMeta", "length", "Label", "Union", "mutable", "Tuple", "ns", "count", "Number", "defaultValue", "NotifyOptions", "start", "success", "error", "NotifyOptionsAnnotation", "schema", "IdempotentAnnotation", "Boolean", "isIdempotent", "getOrElse", "getDictionary", "annotate", "annotation", "setDictionary", "VisibleAnnotation", "visible", "isVisible", "get", "Service", "Tag", "invoke", "args", "flatMap", "ops", "withSpan", "schedule", "withInvocationOptions", "options", "effect", "gen", "of", "invocationOptions", "invokePromise", "PersistentOperation_v0_1_0", "_migration", "define", "from", "to", "transform", "migrations"]
|
|
7
|
+
}
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
var StorageService_exports = {};
|
|
7
7
|
__export(StorageService_exports, {
|
|
8
8
|
StorageService: () => StorageService,
|
|
9
|
+
cell: () => cell,
|
|
9
10
|
clear: () => clear,
|
|
10
11
|
deleteKey: () => deleteKey,
|
|
11
12
|
get: () => get,
|
|
12
|
-
key: () => key,
|
|
13
13
|
list: () => list,
|
|
14
14
|
set: () => set,
|
|
15
15
|
withDefault: () => withDefault
|
|
@@ -25,23 +25,23 @@ var set = Effect.serviceFunctionEffect(StorageService, (_) => _.set);
|
|
|
25
25
|
var deleteKey = Effect.serviceFunctionEffect(StorageService, (_) => _.delete);
|
|
26
26
|
var list = Effect.serviceFunctionEffect(StorageService, (_) => _.list);
|
|
27
27
|
var clear = Effect.serviceFunctionEffect(StorageService, (_) => _.clear);
|
|
28
|
-
var
|
|
28
|
+
var cell = (schema, key) => {
|
|
29
29
|
return {
|
|
30
|
-
key
|
|
31
|
-
get: get(schema,
|
|
32
|
-
set: (value) => set(schema,
|
|
33
|
-
delete: () => deleteKey(
|
|
30
|
+
key,
|
|
31
|
+
get: get(schema, key),
|
|
32
|
+
set: (value) => set(schema, key, value),
|
|
33
|
+
delete: () => deleteKey(key),
|
|
34
34
|
pipe(...args) {
|
|
35
35
|
return Pipeable.pipeArguments(this, arguments);
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
|
-
var withDefault = (getDefault) => (
|
|
39
|
+
var withDefault = (getDefault) => (cell2) => {
|
|
40
40
|
return {
|
|
41
|
-
key:
|
|
42
|
-
get:
|
|
43
|
-
set: (value) =>
|
|
44
|
-
delete: () =>
|
|
41
|
+
key: cell2.key,
|
|
42
|
+
get: cell2.get.pipe(Effect.map(Option.getOrElse(() => getDefault()))),
|
|
43
|
+
set: (value) => cell2.set(value),
|
|
44
|
+
delete: () => cell2.delete(),
|
|
45
45
|
pipe(...args) {
|
|
46
46
|
return Pipeable.pipeArguments(this, arguments);
|
|
47
47
|
}
|
|
@@ -55,8 +55,8 @@ export {
|
|
|
55
55
|
deleteKey,
|
|
56
56
|
list,
|
|
57
57
|
clear,
|
|
58
|
-
|
|
58
|
+
cell,
|
|
59
59
|
withDefault,
|
|
60
60
|
StorageService_exports
|
|
61
61
|
};
|
|
62
|
-
//# sourceMappingURL=chunk-
|
|
62
|
+
//# sourceMappingURL=chunk-PF7XP7XP.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/StorageService.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Option from 'effect/Option';\nimport * as Pipeable from 'effect/Pipeable';\nimport * as Schema from 'effect/Schema';\n\nexport interface Service {\n /** Read a value by key. Returns `None` if key does not exist. */\n get<S extends Schema.Schema<any, string, any>>(\n schema: S,\n key: string,\n ): Effect.Effect<Option.Option<Schema.Schema.Type<S>>, never, Schema.Schema.Context<S>>;\n\n /** Write a value for the given key. */\n set<S extends Schema.Schema<any, string, any>>(\n schema: S,\n key: string,\n value: Schema.Schema.Type<S>,\n ): Effect.Effect<void, never, Schema.Schema.Context<S>>;\n\n /** Remove a key. */\n delete(key: string): Effect.Effect<void>;\n\n /** List all keys, optionally filtered by prefix. */\n list(prefix?: string): Effect.Effect<readonly string[]>;\n\n /** Remove all keys managed by this scoped store. */\n clear(): Effect.Effect<void>;\n}\n\n/**\n * Scoped key-value storage service for processes.\n * Each process receives its own namespaced instance via the process manager.\n * Construct a live implementation with `StorageService.layer` from `@dxos/functions-runtime`.\n */\nexport class StorageService extends Context.Tag('@dxos/functions/StorageService')<StorageService, Service>() {}\n\nexport const get = Effect.serviceFunctionEffect(StorageService, (_) => _.get);\nexport const set = Effect.serviceFunctionEffect(StorageService, (_) => _.set);\nexport const deleteKey = Effect.serviceFunctionEffect(StorageService, (_) => _.delete);\nexport const list = Effect.serviceFunctionEffect(StorageService, (_) => _.list);\nexport const clear = Effect.serviceFunctionEffect(StorageService, (_) => _.clear);\n\n/**\n * Typed
|
|
5
|
-
"mappings": ";;;;;AAAA;;;;;;;;;;;AAMA,YAAYA,aAAa;AACzB,YAAYC,YAAY;AACxB,YAAYC,YAAY;AACxB,YAAYC,cAAc;AAgCnB,IAAMC,iBAAN,cAAqCC,YAAI,gCAAA,EAAA,EAAA;AAA8D;AAEvG,IAAMC,MAAaC,6BAAsBH,gBAAgB,CAACI,MAAMA,EAAEF,GAAG;AACrE,IAAMG,MAAaF,6BAAsBH,gBAAgB,CAACI,MAAMA,EAAEC,GAAG;AACrE,IAAMC,YAAmBH,6BAAsBH,gBAAgB,CAACI,MAAMA,EAAEG,MAAM;AAC9E,IAAMC,OAAcL,6BAAsBH,gBAAgB,CAACI,MAAMA,EAAEI,IAAI;AACvE,IAAMC,QAAeN,6BAAsBH,gBAAgB,CAACI,MAAMA,EAAEK,KAAK;AAgBzE,IAAMC,
|
|
6
|
-
"names": ["Context", "Effect", "Option", "Pipeable", "StorageService", "Tag", "get", "serviceFunctionEffect", "_", "set", "deleteKey", "delete", "list", "clear", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Option from 'effect/Option';\nimport * as Pipeable from 'effect/Pipeable';\nimport * as Schema from 'effect/Schema';\n\nexport interface Service {\n /** Read a value by key. Returns `None` if key does not exist. */\n get<S extends Schema.Schema<any, string, any>>(\n schema: S,\n key: string,\n ): Effect.Effect<Option.Option<Schema.Schema.Type<S>>, never, Schema.Schema.Context<S>>;\n\n /** Write a value for the given key. */\n set<S extends Schema.Schema<any, string, any>>(\n schema: S,\n key: string,\n value: Schema.Schema.Type<S>,\n ): Effect.Effect<void, never, Schema.Schema.Context<S>>;\n\n /** Remove a key. */\n delete(key: string): Effect.Effect<void>;\n\n /** List all keys, optionally filtered by prefix. */\n list(prefix?: string): Effect.Effect<readonly string[]>;\n\n /** Remove all keys managed by this scoped store. */\n clear(): Effect.Effect<void>;\n}\n\n/**\n * Scoped key-value storage service for processes.\n * Each process receives its own namespaced instance via the process manager.\n * Construct a live implementation with `StorageService.layer` from `@dxos/functions-runtime`.\n */\nexport class StorageService extends Context.Tag('@dxos/functions/StorageService')<StorageService, Service>() {}\n\nexport const get = Effect.serviceFunctionEffect(StorageService, (_) => _.get);\nexport const set = Effect.serviceFunctionEffect(StorageService, (_) => _.set);\nexport const deleteKey = Effect.serviceFunctionEffect(StorageService, (_) => _.delete);\nexport const list = Effect.serviceFunctionEffect(StorageService, (_) => _.list);\nexport const clear = Effect.serviceFunctionEffect(StorageService, (_) => _.clear);\n\n/**\n * Typed cell in a storage service.\n */\nexport interface Cell<T> extends Pipeable.Pipeable {\n readonly key: string;\n\n get: Effect.Effect<Option.Option<T>, never, StorageService>;\n set(value: T): Effect.Effect<void, never, StorageService>;\n delete(): Effect.Effect<void, never, StorageService>;\n}\n\n/**\n * Create a typed cell in a storage service.\n */\nexport const cell = <S extends Schema.Schema<any, string, any>>(\n schema: S,\n key: string,\n): Cell<Schema.Schema.Type<S>> => {\n return {\n key,\n get: get(schema, key),\n set: (value: Schema.Schema.Type<S>) => set(schema, key, value),\n delete: () => deleteKey(key),\n pipe(...args: any) {\n return Pipeable.pipeArguments(this, arguments);\n },\n };\n};\n\n/**\n * Typed cell in a storage service with a default value.\n */\nexport interface CellWithDefault<T, U> extends Pipeable.Pipeable {\n readonly key: string;\n get: Effect.Effect<T | U, never, StorageService>;\n set(value: U): Effect.Effect<void, never, StorageService>;\n delete(): Effect.Effect<void, never, StorageService>;\n}\n\n/**\n * Assign a default value to a cell if it is not present.\n */\nexport const withDefault =\n <T>(getDefault: () => NoInfer<T>) =>\n (cell: Cell<T>): CellWithDefault<T, T> => {\n return {\n key: cell.key,\n get: cell.get.pipe(Effect.map(Option.getOrElse(() => getDefault()))),\n set: (value) => cell.set(value),\n delete: () => cell.delete(),\n pipe(...args: any) {\n return Pipeable.pipeArguments(this, arguments);\n },\n };\n };\n"],
|
|
5
|
+
"mappings": ";;;;;AAAA;;;;;;;;;;;AAMA,YAAYA,aAAa;AACzB,YAAYC,YAAY;AACxB,YAAYC,YAAY;AACxB,YAAYC,cAAc;AAgCnB,IAAMC,iBAAN,cAAqCC,YAAI,gCAAA,EAAA,EAAA;AAA8D;AAEvG,IAAMC,MAAaC,6BAAsBH,gBAAgB,CAACI,MAAMA,EAAEF,GAAG;AACrE,IAAMG,MAAaF,6BAAsBH,gBAAgB,CAACI,MAAMA,EAAEC,GAAG;AACrE,IAAMC,YAAmBH,6BAAsBH,gBAAgB,CAACI,MAAMA,EAAEG,MAAM;AAC9E,IAAMC,OAAcL,6BAAsBH,gBAAgB,CAACI,MAAMA,EAAEI,IAAI;AACvE,IAAMC,QAAeN,6BAAsBH,gBAAgB,CAACI,MAAMA,EAAEK,KAAK;AAgBzE,IAAMC,OAAO,CAClBC,QACAC,QAAAA;AAEA,SAAO;IACLA;IACAV,KAAKA,IAAIS,QAAQC,GAAAA;IACjBP,KAAK,CAACQ,UAAiCR,IAAIM,QAAQC,KAAKC,KAAAA;IACxDN,QAAQ,MAAMD,UAAUM,GAAAA;IACxBE,QAAQC,MAAS;AACf,aAAgBC,uBAAc,MAAMC,SAAAA;IACtC;EACF;AACF;AAeO,IAAMC,cACX,CAAIC,eACJ,CAACT,UAAAA;AACC,SAAO;IACLE,KAAKF,MAAKE;IACVV,KAAKQ,MAAKR,IAAIY,KAAYM,WAAWC,iBAAU,MAAMF,WAAAA,CAAAA,CAAAA,CAAAA;IACrDd,KAAK,CAACQ,UAAUH,MAAKL,IAAIQ,KAAAA;IACzBN,QAAQ,MAAMG,MAAKH,OAAM;IACzBO,QAAQC,MAAS;AACf,aAAgBC,uBAAc,MAAMC,SAAAA;IACtC;EACF;AACF;",
|
|
6
|
+
"names": ["Context", "Effect", "Option", "Pipeable", "StorageService", "Tag", "get", "serviceFunctionEffect", "_", "set", "deleteKey", "delete", "list", "clear", "cell", "schema", "key", "value", "pipe", "args", "pipeArguments", "arguments", "withDefault", "getDefault", "map", "getOrElse"]
|
|
7
7
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Reply
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5VAXF6AH.mjs";
|
|
4
4
|
import {
|
|
5
5
|
withHandler
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-EVROJER7.mjs";
|
|
7
7
|
|
|
8
8
|
// src/testing/reply.ts
|
|
9
9
|
import * as Console from "effect/Console";
|
|
@@ -18,4 +18,4 @@ var reply_default = Reply.pipe(withHandler(Effect.fn(function* (input) {
|
|
|
18
18
|
export {
|
|
19
19
|
reply_default
|
|
20
20
|
};
|
|
21
|
-
//# sourceMappingURL=chunk-
|
|
21
|
+
//# sourceMappingURL=chunk-SJ37RWHU.mjs.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./chunk-J5LGTIGS.mjs";
|
|
4
|
+
|
|
5
|
+
// src/AgentService.ts
|
|
6
|
+
var AgentService_exports = {};
|
|
7
|
+
__export(AgentService_exports, {
|
|
8
|
+
AgentService: () => AgentService,
|
|
9
|
+
getSession: () => getSession,
|
|
10
|
+
hydrate: () => hydrate
|
|
11
|
+
});
|
|
12
|
+
import * as Context from "effect/Context";
|
|
13
|
+
import * as Effect from "effect/Effect";
|
|
14
|
+
var AgentService = class extends Context.Tag("@dxos/functions-runtime/AgentService")() {
|
|
15
|
+
};
|
|
16
|
+
var getSession = Effect.serviceFunctionEffect(AgentService, (service) => service.getSession);
|
|
17
|
+
var hydrate = Effect.serviceFunctionEffect(AgentService, (service) => service.hydrate);
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
AgentService,
|
|
21
|
+
getSession,
|
|
22
|
+
hydrate,
|
|
23
|
+
AgentService_exports
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=chunk-VSAZPWSJ.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/AgentService.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport type * as Stream from 'effect/Stream';\n\nimport type { Database, Feed, Obj, Ref } from '@dxos/echo';\nimport { DXN } from '@dxos/keys';\n\nimport type * as Trace from './Trace';\n\n/**\n * Service interface for the agent session manager.\n * Implementation lives in @dxos/functions-runtime.\n */\nexport interface Service {\n /**\n * Gets or creates a session for a feed.\n */\n getSession: (feed: Feed.Feed, options?: GetSessionOptions) => Effect.Effect<Session>;\n\n /**\n * Hydrates agent processes persisted by a previous session.\n * Each record is rehydrated with a fresh process built from the layer options.\n */\n hydrate: () => Effect.Effect<void>;\n}\n\nexport class AgentService extends Context.Tag('@dxos/functions-runtime/AgentService')<AgentService, Service>() {}\n\n/**\n * Handle to an agent session.\n */\nexport interface Session {\n /**\n * The feed that the session is associated with.\n */\n readonly feed: Feed.Feed;\n\n /**\n * Gets the context objects from the agent.\n */\n getContext: () => Effect.Effect<Ref.Ref<Obj.Unknown>[], never, Database.Service>;\n\n /**\n * Adds context objects to the agent.\n */\n addContext: (context: Ref.Ref<Obj.Unknown>[]) => Effect.Effect<void, never, Database.Service>;\n\n /**\n * Submits a prompt to the agent.\n */\n submitPrompt: (prompt: string) => Effect.Effect<void>;\n\n /**\n * Wait until agent has completed its work.\n */\n waitForCompletion: () => Effect.Effect<void>;\n\n /**\n * Terminates the agent process and clears its durable storage.\n */\n terminate: () => Effect.Effect<void>;\n\n /**\n * Subscribe to ephemeral trace events (e.g., streaming partial messages).\n * Replays buffered events, then streams new ones until the process ends.\n *\n * When forking a collector from a short-lived parent (e.g. `useEffect` +\n * `runPromise(Effect.forEach(subscribe))`), use {@link Effect.forkDaemon} so the\n * stream survives after the parent scope closes; interrupt it on dispose.\n */\n subscribeEphemeral: () => Stream.Stream<Trace.Message>;\n}\n\nexport const getSession = Effect.serviceFunctionEffect(AgentService, (service) => service.getSession);\n\nexport const hydrate = Effect.serviceFunctionEffect(AgentService, (service) => service.hydrate);\n\nexport interface GetSessionOptions {\n readonly model?: DXN.DXN;\n // The catalog's shared model ids are served by several providers, so the provider must accompany\n // the model into the agent process — the id alone does not identify a resolver.\n readonly provider?: DXN.DXN;\n readonly systemPrompt?: string;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;AAAA;;;;;;AAMA,YAAYA,aAAa;AACzB,YAAYC,YAAY;AAyBjB,IAAMC,eAAN,cAAmCC,YAAI,sCAAA,EAAA,EAAA;AAAkE;AA+CzG,IAAMC,aAAoBC,6BAAsBH,cAAc,CAACI,YAAYA,QAAQF,UAAU;AAE7F,IAAMG,UAAiBF,6BAAsBH,cAAc,CAACI,YAAYA,QAAQC,OAAO;",
|
|
6
|
+
"names": ["Context", "Effect", "AgentService", "Tag", "getSession", "serviceFunctionEffect", "service", "hydrate"]
|
|
7
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Sleep
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5VAXF6AH.mjs";
|
|
4
4
|
import {
|
|
5
5
|
withHandler
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-EVROJER7.mjs";
|
|
7
7
|
|
|
8
8
|
// src/testing/sleep.ts
|
|
9
9
|
import * as Effect from "effect/Effect";
|
|
@@ -14,4 +14,4 @@ var sleep_default = Sleep.pipe(withHandler(Effect.fn(function* ({ duration = 1e5
|
|
|
14
14
|
export {
|
|
15
15
|
sleep_default
|
|
16
16
|
};
|
|
17
|
-
//# sourceMappingURL=chunk-
|
|
17
|
+
//# sourceMappingURL=chunk-WEO4FCQY.mjs.map
|