@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,1183 @@
|
|
|
1
|
+
import {
|
|
2
|
+
StorageService_exports,
|
|
3
|
+
key,
|
|
4
|
+
withDefault
|
|
5
|
+
} from "./chunk-XEVFBI6S.mjs";
|
|
6
|
+
import {
|
|
7
|
+
FunctionError,
|
|
8
|
+
FunctionNotFoundError,
|
|
9
|
+
FunctionsAiMemoizationMissError,
|
|
10
|
+
FunctionsAiUpstreamError,
|
|
11
|
+
InvalidOperationInputError,
|
|
12
|
+
InvalidOperationOutputError,
|
|
13
|
+
InvokerNotInitializedError,
|
|
14
|
+
NoHandlerError,
|
|
15
|
+
OperationHandlerProvider,
|
|
16
|
+
OperationHandlerSet_exports,
|
|
17
|
+
ServiceNotAvailableError,
|
|
18
|
+
TriggerStateNotFoundError,
|
|
19
|
+
getHandler,
|
|
20
|
+
getHandlerByKey
|
|
21
|
+
} from "./chunk-Z3Y7FQGN.mjs";
|
|
22
|
+
import {
|
|
23
|
+
Operation_exports,
|
|
24
|
+
PersistentOperation,
|
|
25
|
+
deserialize,
|
|
26
|
+
invoke,
|
|
27
|
+
isIdempotent
|
|
28
|
+
} from "./chunk-QZS4G6PE.mjs";
|
|
29
|
+
import {
|
|
30
|
+
__export
|
|
31
|
+
} from "./chunk-J5LGTIGS.mjs";
|
|
32
|
+
|
|
33
|
+
// src/Blueprint.ts
|
|
34
|
+
var Blueprint_exports = {};
|
|
35
|
+
__export(Blueprint_exports, {
|
|
36
|
+
Blueprint: () => Blueprint,
|
|
37
|
+
Blueprint_v0_1_0: () => Blueprint_v0_1_0,
|
|
38
|
+
NotFoundError: () => NotFoundError,
|
|
39
|
+
getKey: () => getKey,
|
|
40
|
+
getVersion: () => getVersion,
|
|
41
|
+
make: () => make2,
|
|
42
|
+
migrations: () => migrations,
|
|
43
|
+
registryURI: () => registryURI,
|
|
44
|
+
resolve: () => resolve,
|
|
45
|
+
toolDefinitions: () => toolDefinitions,
|
|
46
|
+
upsert: () => upsert
|
|
47
|
+
});
|
|
48
|
+
import * as Effect2 from "effect/Effect";
|
|
49
|
+
import * as Schema3 from "effect/Schema";
|
|
50
|
+
import { ToolId } from "@dxos/ai";
|
|
51
|
+
import { DXN as DXN2, Annotation, Database as Database2, Filter as Filter2, Migration, Obj, Registry as Registry2, Type, URI } from "@dxos/echo";
|
|
52
|
+
import { BaseError } from "@dxos/errors";
|
|
53
|
+
|
|
54
|
+
// src/McpServer.ts
|
|
55
|
+
var McpServer_exports = {};
|
|
56
|
+
__export(McpServer_exports, {
|
|
57
|
+
McpServer: () => McpServer
|
|
58
|
+
});
|
|
59
|
+
import * as Schema from "effect/Schema";
|
|
60
|
+
var McpServer = Schema.Struct({
|
|
61
|
+
name: Schema.String.pipe(Schema.optional).annotations({
|
|
62
|
+
description: "Human-readable name of the MCP server"
|
|
63
|
+
}),
|
|
64
|
+
url: Schema.String.annotations({
|
|
65
|
+
description: "URL of the MCP server"
|
|
66
|
+
}),
|
|
67
|
+
/**
|
|
68
|
+
* Transport protocol. Prefer `'http'` (Streamable HTTP) for new servers; `'sse'` is
|
|
69
|
+
* kept for compatibility with servers that haven't migrated and is deprecated per
|
|
70
|
+
* the MCP SDK. Clients support both during the migration period.
|
|
71
|
+
*/
|
|
72
|
+
protocol: Schema.Union(Schema.Literal("http"), Schema.Literal("sse")).annotations({
|
|
73
|
+
description: 'Transport protocol of the MCP server (prefer "http"; "sse" deprecated)'
|
|
74
|
+
}),
|
|
75
|
+
/**
|
|
76
|
+
* Optional API key sent with requests.
|
|
77
|
+
* Persisted in plaintext when stored on a space-replicated ECHO object — see the
|
|
78
|
+
* `@dxos/assistant-toolkit` `McpServer` type for security implications.
|
|
79
|
+
*/
|
|
80
|
+
apiKey: Schema.optional(Schema.String).annotations({
|
|
81
|
+
description: "Optional API key sent with requests"
|
|
82
|
+
})
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// src/Template.ts
|
|
86
|
+
var Template_exports = {};
|
|
87
|
+
__export(Template_exports, {
|
|
88
|
+
Input: () => Input,
|
|
89
|
+
InputKind: () => InputKind,
|
|
90
|
+
Template: () => Template,
|
|
91
|
+
make: () => make,
|
|
92
|
+
process: () => process,
|
|
93
|
+
processTemplate: () => processTemplate
|
|
94
|
+
});
|
|
95
|
+
import * as Effect from "effect/Effect";
|
|
96
|
+
import * as Schema2 from "effect/Schema";
|
|
97
|
+
import { Database, DXN, Filter, Ref, Registry } from "@dxos/echo";
|
|
98
|
+
import { assertArgument, invariant } from "@dxos/invariant";
|
|
99
|
+
import { log } from "@dxos/log";
|
|
100
|
+
import { Text } from "@dxos/schema";
|
|
101
|
+
import Handlebars from "@dxos/vendor-kbn-handlebars";
|
|
102
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/core/compute/compute/src/Template.ts";
|
|
103
|
+
var InputKind = Schema2.Literal("value", "operation");
|
|
104
|
+
var Input = Schema2.Struct({
|
|
105
|
+
name: Schema2.String,
|
|
106
|
+
kind: InputKind,
|
|
107
|
+
default: Schema2.optional(Schema2.Any),
|
|
108
|
+
/**
|
|
109
|
+
* Operation key invoked when `kind === 'operation'`. The referenced operation must accept void input —
|
|
110
|
+
* template inputs have no mechanism for passing arguments.
|
|
111
|
+
*/
|
|
112
|
+
operation: Schema2.optional(Schema2.String)
|
|
113
|
+
});
|
|
114
|
+
var Template = Schema2.Struct({
|
|
115
|
+
source: Ref.Ref(Text.Text).annotations({
|
|
116
|
+
description: "Markdown + Handlebars template."
|
|
117
|
+
}),
|
|
118
|
+
/**
|
|
119
|
+
* NOTE: We use an array rather than map so that updating variable names in the template doesn't disconnect existing inputs.
|
|
120
|
+
*/
|
|
121
|
+
inputs: Schema2.optional(Schema2.Array(Input))
|
|
122
|
+
});
|
|
123
|
+
var make = ({ id, source, inputs = [] } = {}) => ({
|
|
124
|
+
source: Ref.make(Text.make({
|
|
125
|
+
id,
|
|
126
|
+
content: source
|
|
127
|
+
})),
|
|
128
|
+
inputs
|
|
129
|
+
});
|
|
130
|
+
var process = (source, variables = {}) => {
|
|
131
|
+
assertArgument(typeof source === "string", "source");
|
|
132
|
+
let section = 0;
|
|
133
|
+
const handlebars = Handlebars.create();
|
|
134
|
+
handlebars.registerHelper("section", () => String(++section));
|
|
135
|
+
const template = handlebars.compileAST(source.trim());
|
|
136
|
+
const output = template(variables);
|
|
137
|
+
return output.trim().replace(/(\n\s*){3,}/g, "\n\n");
|
|
138
|
+
};
|
|
139
|
+
var processTemplate = (template) => Effect.gen(function* () {
|
|
140
|
+
const entries = yield* Effect.forEach(template.inputs ?? [], (input) => Effect.gen(function* () {
|
|
141
|
+
switch (input.kind) {
|
|
142
|
+
case "value": {
|
|
143
|
+
return [
|
|
144
|
+
input.name,
|
|
145
|
+
input.default
|
|
146
|
+
];
|
|
147
|
+
}
|
|
148
|
+
case "operation": {
|
|
149
|
+
invariant(input.operation, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 69, S: this, A: ["input.operation", ""] });
|
|
150
|
+
const key2 = DXN.isDXN(input.operation) ? input.operation : `dxn:${input.operation}`;
|
|
151
|
+
const results = yield* Registry.runQuery(Filter.and(Filter.type(PersistentOperation), Filter.key(key2)));
|
|
152
|
+
if (results.length === 0) {
|
|
153
|
+
return yield* Effect.fail(new FunctionNotFoundError(input.operation));
|
|
154
|
+
}
|
|
155
|
+
const fn = deserialize(results[0]);
|
|
156
|
+
const result = yield* invoke(fn, void 0).pipe(Effect.orDie);
|
|
157
|
+
return [
|
|
158
|
+
input.name,
|
|
159
|
+
result
|
|
160
|
+
];
|
|
161
|
+
}
|
|
162
|
+
default: {
|
|
163
|
+
return yield* Effect.dieMessage(`Unsupported input kind: ${input.kind}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}));
|
|
167
|
+
const variables = Object.fromEntries(entries);
|
|
168
|
+
log("processTemplate", {
|
|
169
|
+
variables
|
|
170
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 91, S: this });
|
|
171
|
+
return process((yield* Database.load(template.source)).content, variables);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
// src/Blueprint.ts
|
|
175
|
+
var Blueprint = Schema3.Struct({
|
|
176
|
+
/**
|
|
177
|
+
* Human-readable name of the blueprint.
|
|
178
|
+
*/
|
|
179
|
+
name: Schema3.String.annotations({
|
|
180
|
+
description: "Human-readable name of the blueprint"
|
|
181
|
+
}),
|
|
182
|
+
/**
|
|
183
|
+
* Description of the blueprint's purpose and functionality.
|
|
184
|
+
*/
|
|
185
|
+
description: Schema3.optional(Schema3.String).annotations({
|
|
186
|
+
description: "Description of the blueprint's purpose and functionality"
|
|
187
|
+
}),
|
|
188
|
+
/**
|
|
189
|
+
* Instructions that guide the AI assistant's behavior and responses.
|
|
190
|
+
* These are system prompts or guidelines that the AI should follow.
|
|
191
|
+
*/
|
|
192
|
+
instructions: Template.annotations({
|
|
193
|
+
description: "Instructions that guide the AI assistant's behavior and responses"
|
|
194
|
+
}),
|
|
195
|
+
/**
|
|
196
|
+
* Array of tools that the AI assistant can use when this blueprint is active.
|
|
197
|
+
*/
|
|
198
|
+
tools: Schema3.Array(ToolId).annotations({
|
|
199
|
+
description: "Array of tools that the AI assistant can use when this blueprint is active"
|
|
200
|
+
}),
|
|
201
|
+
/**
|
|
202
|
+
* Whether an agent is allowed to auto-enable this blueprint in a conversation.
|
|
203
|
+
*/
|
|
204
|
+
agentCanEnable: Schema3.optional(Schema3.Boolean).annotations({
|
|
205
|
+
description: "Whether an agent is allowed to auto-enable this blueprint in a conversation."
|
|
206
|
+
}),
|
|
207
|
+
/**
|
|
208
|
+
* Array of MCP servers that the AI assistant can use when this blueprint is active.
|
|
209
|
+
*/
|
|
210
|
+
mcpServers: Schema3.optional(Schema3.Array(McpServer))
|
|
211
|
+
}).pipe(Annotation.LabelAnnotation.set([
|
|
212
|
+
"name"
|
|
213
|
+
]), Annotation.IconAnnotation.set({
|
|
214
|
+
icon: "ph--blueprint--regular",
|
|
215
|
+
hue: "sky"
|
|
216
|
+
}), Type.makeObject(DXN2.make("org.dxos.type.blueprint", "0.2.0")));
|
|
217
|
+
var make2 = ({ key: key2, version, tools = [], instructions = make(), ...props }) => Obj.make(Blueprint, {
|
|
218
|
+
[Obj.Meta]: {
|
|
219
|
+
key: key2,
|
|
220
|
+
version
|
|
221
|
+
},
|
|
222
|
+
tools,
|
|
223
|
+
instructions,
|
|
224
|
+
...props
|
|
225
|
+
});
|
|
226
|
+
var getKey = (blueprint) => {
|
|
227
|
+
const key2 = Obj.getMeta(blueprint).key;
|
|
228
|
+
if (key2 === void 0) {
|
|
229
|
+
throw new Error("Blueprint is missing the meta key.");
|
|
230
|
+
}
|
|
231
|
+
return key2;
|
|
232
|
+
};
|
|
233
|
+
var getVersion = (blueprint) => Obj.getMeta(blueprint).version;
|
|
234
|
+
var toolDefinitions = ({ tools = [], operations = [] }) => [
|
|
235
|
+
...operations.map((op) => ToolId.make(DXN2.getName(op.meta.key))),
|
|
236
|
+
...tools.map((tool) => ToolId.make(tool))
|
|
237
|
+
];
|
|
238
|
+
var registryURI = (key2) => DXN2.tryMake(`dxn:${key2}`) ?? URI.make(key2);
|
|
239
|
+
var resolve = (key2) => Effect2.gen(function* () {
|
|
240
|
+
const results = yield* Registry2.runQuery(Filter2.and(Filter2.type(Blueprint), Filter2.key(key2)));
|
|
241
|
+
const blueprint = results[0];
|
|
242
|
+
if (!blueprint) {
|
|
243
|
+
return yield* Effect2.fail(new NotFoundError({
|
|
244
|
+
context: {
|
|
245
|
+
key: key2
|
|
246
|
+
}
|
|
247
|
+
}));
|
|
248
|
+
}
|
|
249
|
+
return blueprint;
|
|
250
|
+
});
|
|
251
|
+
var upsert = (key2) => Effect2.gen(function* () {
|
|
252
|
+
const local = yield* Database2.query(Filter2.and(Filter2.type(Blueprint), Filter2.key(key2))).run;
|
|
253
|
+
if (local.length > 0) {
|
|
254
|
+
return local[0];
|
|
255
|
+
}
|
|
256
|
+
return yield* Database2.add(Obj.clone(yield* resolve(key2), {
|
|
257
|
+
deep: true
|
|
258
|
+
}));
|
|
259
|
+
});
|
|
260
|
+
var NotFoundError = class extends BaseError.extend("BlueprintNotFound", "Blueprint not found") {
|
|
261
|
+
};
|
|
262
|
+
var Blueprint_v0_1_0 = Schema3.Struct({
|
|
263
|
+
/**
|
|
264
|
+
* Global registry ID.
|
|
265
|
+
* NOTE: The `key` property refers to the original registry entry.
|
|
266
|
+
*/
|
|
267
|
+
key: Schema3.String.annotations({
|
|
268
|
+
description: "Unique registration key for the blueprint"
|
|
269
|
+
}),
|
|
270
|
+
name: Schema3.String.annotations({
|
|
271
|
+
description: "Human-readable name of the blueprint"
|
|
272
|
+
}),
|
|
273
|
+
description: Schema3.optional(Schema3.String),
|
|
274
|
+
instructions: Template,
|
|
275
|
+
tools: Schema3.Array(ToolId),
|
|
276
|
+
agentCanEnable: Schema3.optional(Schema3.Boolean),
|
|
277
|
+
mcpServers: Schema3.optional(Schema3.Array(McpServer))
|
|
278
|
+
}).pipe(Type.makeObject(DXN2.make("org.dxos.type.blueprint", "0.1.0")));
|
|
279
|
+
var _migration = Migration.define({
|
|
280
|
+
from: Blueprint_v0_1_0,
|
|
281
|
+
to: Blueprint,
|
|
282
|
+
transform: async (from) => ({
|
|
283
|
+
[Obj.Meta]: {
|
|
284
|
+
key: from.key,
|
|
285
|
+
version: "0.1.0"
|
|
286
|
+
},
|
|
287
|
+
name: from.name,
|
|
288
|
+
description: from.description,
|
|
289
|
+
instructions: from.instructions,
|
|
290
|
+
tools: from.tools,
|
|
291
|
+
agentCanEnable: from.agentCanEnable,
|
|
292
|
+
mcpServers: from.mcpServers
|
|
293
|
+
})
|
|
294
|
+
});
|
|
295
|
+
var migrations = [
|
|
296
|
+
_migration
|
|
297
|
+
];
|
|
298
|
+
|
|
299
|
+
// src/Credential.ts
|
|
300
|
+
var Credential_exports = {};
|
|
301
|
+
__export(Credential_exports, {
|
|
302
|
+
CredentialsService: () => CredentialsService
|
|
303
|
+
});
|
|
304
|
+
import * as Context from "effect/Context";
|
|
305
|
+
import * as Effect3 from "effect/Effect";
|
|
306
|
+
import * as Redacted from "effect/Redacted";
|
|
307
|
+
var CredentialsService = class _CredentialsService extends Context.Tag("@dxos/functions/CredentialsService")() {
|
|
308
|
+
static getCredential = (query) => Effect3.gen(function* () {
|
|
309
|
+
const credentials = yield* _CredentialsService;
|
|
310
|
+
return yield* Effect3.promise(() => credentials.getCredential(query));
|
|
311
|
+
});
|
|
312
|
+
static getApiKey = (query) => Effect3.gen(function* () {
|
|
313
|
+
const credential = yield* _CredentialsService.getCredential(query);
|
|
314
|
+
if (!credential.apiKey) {
|
|
315
|
+
throw new Error(`API key not found for service: ${query.service}`);
|
|
316
|
+
}
|
|
317
|
+
return Redacted.make(credential.apiKey);
|
|
318
|
+
});
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
// src/Header.ts
|
|
322
|
+
var Header_exports = {};
|
|
323
|
+
__export(Header_exports, {
|
|
324
|
+
byokLayer: () => byokLayer
|
|
325
|
+
});
|
|
326
|
+
import * as HttpClient from "@effect/platform/HttpClient";
|
|
327
|
+
import * as HttpClientRequest from "@effect/platform/HttpClientRequest";
|
|
328
|
+
import * as Effect4 from "effect/Effect";
|
|
329
|
+
import * as Layer from "effect/Layer";
|
|
330
|
+
import { BYOK_HEADER } from "@dxos/protocols";
|
|
331
|
+
var byokLayer = (providerHost) => Layer.effect(HttpClient.HttpClient, Effect4.gen(function* () {
|
|
332
|
+
const client = yield* HttpClient.HttpClient;
|
|
333
|
+
const credentials = yield* CredentialsService;
|
|
334
|
+
return HttpClient.mapRequestEffect(client, (request) => Effect4.gen(function* () {
|
|
335
|
+
const matches = yield* Effect4.tryPromise(() => credentials.queryCredentials({
|
|
336
|
+
service: providerHost
|
|
337
|
+
})).pipe(Effect4.orElseSucceed(() => []));
|
|
338
|
+
const apiKey = matches.find((credential) => credential.apiKey)?.apiKey;
|
|
339
|
+
return apiKey ? HttpClientRequest.setHeader(request, BYOK_HEADER, apiKey) : request;
|
|
340
|
+
}));
|
|
341
|
+
}));
|
|
342
|
+
|
|
343
|
+
// src/LayerSpec.ts
|
|
344
|
+
var LayerSpec_exports = {};
|
|
345
|
+
__export(LayerSpec_exports, {
|
|
346
|
+
TypeId: () => TypeId,
|
|
347
|
+
make: () => make4
|
|
348
|
+
});
|
|
349
|
+
var TypeId = "~@dxos/functions/LayerSpec";
|
|
350
|
+
var make4 = (opts, make11) => {
|
|
351
|
+
return {
|
|
352
|
+
[TypeId]: TypeId,
|
|
353
|
+
affinity: opts.affinity,
|
|
354
|
+
requires: opts.requires,
|
|
355
|
+
provides: opts.provides,
|
|
356
|
+
make: make11
|
|
357
|
+
};
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
// src/OperationRegistry.ts
|
|
361
|
+
var OperationRegistry_exports = {};
|
|
362
|
+
__export(OperationRegistry_exports, {
|
|
363
|
+
Service: () => Service,
|
|
364
|
+
layer: () => layer,
|
|
365
|
+
resolve: () => resolve2
|
|
366
|
+
});
|
|
367
|
+
import * as Context2 from "effect/Context";
|
|
368
|
+
import * as Effect5 from "effect/Effect";
|
|
369
|
+
import * as Layer2 from "effect/Layer";
|
|
370
|
+
import { Database as Database3, Filter as Filter3, Query } from "@dxos/echo";
|
|
371
|
+
var Service = class extends Context2.Tag("@dxos/operation/OperationRegistry")() {
|
|
372
|
+
};
|
|
373
|
+
var resolve2 = Effect5.serviceFunctionEffect(Service, (service) => service.resolve);
|
|
374
|
+
var layer = Layer2.effect(Service, Effect5.gen(function* () {
|
|
375
|
+
const database = yield* Database3.Service;
|
|
376
|
+
const handlerSet = yield* OperationHandlerProvider;
|
|
377
|
+
return {
|
|
378
|
+
resolve: (key2) => Database3.query(Query.select(Filter3.and(Filter3.type(PersistentOperation), Filter3.key(key2)))).first.pipe(Effect5.flatten, Effect5.map(deserialize), Effect5.catchTag("NoSuchElementException", () => getHandlerByKey(handlerSet, key2)), Effect5.option).pipe(Effect5.provideService(Database3.Service, database))
|
|
379
|
+
};
|
|
380
|
+
}));
|
|
381
|
+
|
|
382
|
+
// src/Process.ts
|
|
383
|
+
var Process_exports = {};
|
|
384
|
+
__export(Process_exports, {
|
|
385
|
+
ExitedEvent: () => ExitedEvent,
|
|
386
|
+
ID: () => ID,
|
|
387
|
+
ProcessMonitorService: () => ProcessMonitorService,
|
|
388
|
+
ProcessTypeId: () => ProcessTypeId,
|
|
389
|
+
SpawnedEvent: () => SpawnedEvent,
|
|
390
|
+
State: () => State,
|
|
391
|
+
fromOperation: () => fromOperation,
|
|
392
|
+
isProcess: () => isProcess,
|
|
393
|
+
make: () => make5,
|
|
394
|
+
prettyProcessTree: () => prettyProcessTree
|
|
395
|
+
});
|
|
396
|
+
import * as Context4 from "effect/Context";
|
|
397
|
+
import * as Effect7 from "effect/Effect";
|
|
398
|
+
import * as Schema5 from "effect/Schema";
|
|
399
|
+
import { assertArgument as assertArgument2 } from "@dxos/invariant";
|
|
400
|
+
import { DXN as DXN4 } from "@dxos/keys";
|
|
401
|
+
import { log as log3 } from "@dxos/log";
|
|
402
|
+
|
|
403
|
+
// src/Trace.ts
|
|
404
|
+
var Trace_exports = {};
|
|
405
|
+
__export(Trace_exports, {
|
|
406
|
+
CommonRuntimeName: () => CommonRuntimeName,
|
|
407
|
+
Event: () => Event,
|
|
408
|
+
EventType: () => EventType,
|
|
409
|
+
Message: () => Message,
|
|
410
|
+
MessageData: () => MessageData,
|
|
411
|
+
Meta: () => Meta,
|
|
412
|
+
OperationEnd: () => OperationEnd,
|
|
413
|
+
OperationInput: () => OperationInput,
|
|
414
|
+
OperationOutput: () => OperationOutput,
|
|
415
|
+
OperationStart: () => OperationStart,
|
|
416
|
+
RuntimeName: () => RuntimeName,
|
|
417
|
+
StatusUpdate: () => StatusUpdate,
|
|
418
|
+
TraceService: () => TraceService,
|
|
419
|
+
TraceSink: () => TraceSink,
|
|
420
|
+
emitStatus: () => emitStatus,
|
|
421
|
+
flatten: () => flatten2,
|
|
422
|
+
isEdgeRuntime: () => isEdgeRuntime,
|
|
423
|
+
isOfType: () => isOfType,
|
|
424
|
+
layerConsole: () => layerConsole,
|
|
425
|
+
layerNoop: () => layerNoop,
|
|
426
|
+
mergeSinks: () => mergeSinks,
|
|
427
|
+
noopSink: () => noopSink,
|
|
428
|
+
noopWriter: () => noopWriter,
|
|
429
|
+
testTraceService: () => testTraceService,
|
|
430
|
+
write: () => write,
|
|
431
|
+
writerLayerNoop: () => writerLayerNoop
|
|
432
|
+
});
|
|
433
|
+
import * as Context3 from "effect/Context";
|
|
434
|
+
import * as Effect6 from "effect/Effect";
|
|
435
|
+
import * as Layer3 from "effect/Layer";
|
|
436
|
+
import * as Schema4 from "effect/Schema";
|
|
437
|
+
import { DXN as DXN3, Annotation as Annotation2, Obj as Obj2, Type as Type2 } from "@dxos/echo";
|
|
438
|
+
import { log as log2 } from "@dxos/log";
|
|
439
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/core/compute/compute/src/Trace.ts";
|
|
440
|
+
var TraceService = class extends Context3.Tag("@dxos/functions/TraceService")() {
|
|
441
|
+
};
|
|
442
|
+
function write(eventType, payload) {
|
|
443
|
+
return Effect6.gen(function* () {
|
|
444
|
+
log2("trace write", {
|
|
445
|
+
key: eventType.key,
|
|
446
|
+
isEphemeral: eventType.isEphemeral
|
|
447
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 20, S: this });
|
|
448
|
+
const writer = yield* TraceService;
|
|
449
|
+
writer.write(eventType, payload);
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
var EventType = (key2, opts) => {
|
|
453
|
+
return {
|
|
454
|
+
key: key2,
|
|
455
|
+
schema: opts.schema,
|
|
456
|
+
isEphemeral: opts.isEphemeral
|
|
457
|
+
};
|
|
458
|
+
};
|
|
459
|
+
var Event = Schema4.Struct({
|
|
460
|
+
timestamp: Schema4.Number,
|
|
461
|
+
type: Schema4.String,
|
|
462
|
+
data: Schema4.Unknown
|
|
463
|
+
});
|
|
464
|
+
var isOfType = (eventType, event) => {
|
|
465
|
+
return event.type === eventType.key;
|
|
466
|
+
};
|
|
467
|
+
var RuntimeName = Schema4.String.pipe(Schema4.brand("@dxos/compute/Trace/RuntimeName"));
|
|
468
|
+
var CommonRuntimeName = {
|
|
469
|
+
/**
|
|
470
|
+
* Web app / CLI / Desktop app / Mobile app.
|
|
471
|
+
*/
|
|
472
|
+
local: RuntimeName.make("local"),
|
|
473
|
+
edgeIntrinsic: RuntimeName.make("edge-intrinsic"),
|
|
474
|
+
edgeWorkerLoader: RuntimeName.make("edge-worker-loader"),
|
|
475
|
+
edgeWorkerForPlatforms: RuntimeName.make("edge-worker-for-platforms")
|
|
476
|
+
};
|
|
477
|
+
var Meta = Schema4.Struct({
|
|
478
|
+
pid: Schema4.optional(Schema4.String),
|
|
479
|
+
parentPid: Schema4.optional(Schema4.String),
|
|
480
|
+
processName: Schema4.optional(Schema4.String),
|
|
481
|
+
/**
|
|
482
|
+
* Space the message was produced in.
|
|
483
|
+
* Stored as a string to avoid circular dependency on `@dxos/keys`.
|
|
484
|
+
*/
|
|
485
|
+
space: Schema4.optional(Schema4.String),
|
|
486
|
+
/**
|
|
487
|
+
* ID of the conversation feed object if present.
|
|
488
|
+
*/
|
|
489
|
+
conversationId: Schema4.optional(Obj2.ID),
|
|
490
|
+
/**
|
|
491
|
+
* ID of the trigger object if invocation resulted from a trigger.
|
|
492
|
+
*/
|
|
493
|
+
triggerId: Schema4.optional(Obj2.ID),
|
|
494
|
+
/**
|
|
495
|
+
* ID of the tool call that created the current process.
|
|
496
|
+
*/
|
|
497
|
+
toolCallId: Schema4.optional(Schema4.String),
|
|
498
|
+
/**
|
|
499
|
+
* Extensible name informing which runtime executed the code that produced the event.
|
|
500
|
+
*/
|
|
501
|
+
runtimeName: Schema4.optional(RuntimeName)
|
|
502
|
+
});
|
|
503
|
+
var isEdgeRuntime = (name) => name === CommonRuntimeName.edgeIntrinsic || name === CommonRuntimeName.edgeWorkerLoader || name === CommonRuntimeName.edgeWorkerForPlatforms;
|
|
504
|
+
var MessageData = Schema4.Struct({
|
|
505
|
+
meta: Meta,
|
|
506
|
+
isEphemeral: Schema4.Boolean,
|
|
507
|
+
events: Schema4.Array(Event)
|
|
508
|
+
});
|
|
509
|
+
var Message = MessageData.pipe(Annotation2.IconAnnotation.set({
|
|
510
|
+
icon: "ph--note--regular",
|
|
511
|
+
hue: "rose"
|
|
512
|
+
}), Annotation2.HiddenAnnotation.set(true), Type2.makeObject(DXN3.make("org.dxos.type.traceMessage", "0.1.0")));
|
|
513
|
+
var flatten2 = (message) => {
|
|
514
|
+
return message.events.map((event) => ({
|
|
515
|
+
...event,
|
|
516
|
+
meta: message.meta,
|
|
517
|
+
isEphemeral: message.isEphemeral
|
|
518
|
+
}));
|
|
519
|
+
};
|
|
520
|
+
var TraceSink = class extends Context3.Tag("@dxos/functions/TraceSink")() {
|
|
521
|
+
};
|
|
522
|
+
var noopWriter = {
|
|
523
|
+
write: () => {
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
var writerLayerNoop = Layer3.succeed(TraceService, noopWriter);
|
|
527
|
+
var noopSink = {
|
|
528
|
+
write: () => {
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
var layerNoop = Layer3.succeed(TraceSink, noopSink);
|
|
532
|
+
var layerConsole = Layer3.succeed(TraceSink, {
|
|
533
|
+
write: (message) => {
|
|
534
|
+
console.log(message);
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
var mergeSinks = (sinks) => {
|
|
538
|
+
if (sinks.length === 0) {
|
|
539
|
+
return noopSink;
|
|
540
|
+
}
|
|
541
|
+
return {
|
|
542
|
+
write: (message) => {
|
|
543
|
+
for (const sink of sinks) {
|
|
544
|
+
try {
|
|
545
|
+
sink.write(message);
|
|
546
|
+
} catch (err) {
|
|
547
|
+
console.error("[trace] sink.write threw", err);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
};
|
|
553
|
+
var testTraceService = (opts = {}) => Layer3.effect(TraceService, Effect6.gen(function* () {
|
|
554
|
+
const sink = yield* TraceSink;
|
|
555
|
+
const clock = opts.clock ?? Date.now;
|
|
556
|
+
return {
|
|
557
|
+
write: (event, data) => {
|
|
558
|
+
sink.write(Obj2.make(Message, {
|
|
559
|
+
meta: opts.meta ?? {},
|
|
560
|
+
isEphemeral: event.isEphemeral,
|
|
561
|
+
events: [
|
|
562
|
+
{
|
|
563
|
+
type: event.key,
|
|
564
|
+
timestamp: clock(),
|
|
565
|
+
data
|
|
566
|
+
}
|
|
567
|
+
]
|
|
568
|
+
}));
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
}));
|
|
572
|
+
var OperationStart = EventType("operation.start", {
|
|
573
|
+
schema: Schema4.Struct({
|
|
574
|
+
/** Operation key. */
|
|
575
|
+
key: Schema4.String,
|
|
576
|
+
/** Human-readable operation name. */
|
|
577
|
+
name: Schema4.optional(Schema4.String),
|
|
578
|
+
/** Phosphor icon identifier in `ph--<name>--<variant>` format. */
|
|
579
|
+
icon: Schema4.optional(Schema4.String)
|
|
580
|
+
}),
|
|
581
|
+
isEphemeral: false
|
|
582
|
+
});
|
|
583
|
+
var OperationEnd = EventType("operation.end", {
|
|
584
|
+
schema: Schema4.Struct({
|
|
585
|
+
/** Operation key. */
|
|
586
|
+
key: Schema4.String,
|
|
587
|
+
/** Human-readable operation name. */
|
|
588
|
+
name: Schema4.optional(Schema4.String),
|
|
589
|
+
/** Phosphor icon identifier in `ph--<name>--<variant>` format. */
|
|
590
|
+
icon: Schema4.optional(Schema4.String),
|
|
591
|
+
/** Outcome of the operation. */
|
|
592
|
+
outcome: Schema4.Literal("success", "failure"),
|
|
593
|
+
/** Error message if the operation failed. */
|
|
594
|
+
error: Schema4.optional(Schema4.String)
|
|
595
|
+
}),
|
|
596
|
+
isEphemeral: false
|
|
597
|
+
});
|
|
598
|
+
var OperationInput = EventType("operation.input", {
|
|
599
|
+
schema: Schema4.Struct({
|
|
600
|
+
/** Operation key. */
|
|
601
|
+
key: Schema4.String,
|
|
602
|
+
/** Human-readable operation name. */
|
|
603
|
+
name: Schema4.optional(Schema4.String),
|
|
604
|
+
/** Raw operation input. Shape determined by the operation definition. */
|
|
605
|
+
input: Schema4.Unknown
|
|
606
|
+
}),
|
|
607
|
+
isEphemeral: true
|
|
608
|
+
});
|
|
609
|
+
var OperationOutput = EventType("operation.output", {
|
|
610
|
+
schema: Schema4.Struct({
|
|
611
|
+
/** Operation key. */
|
|
612
|
+
key: Schema4.String,
|
|
613
|
+
/** Human-readable operation name. */
|
|
614
|
+
name: Schema4.optional(Schema4.String),
|
|
615
|
+
/** Raw operation output. Shape determined by the operation definition. */
|
|
616
|
+
output: Schema4.Unknown
|
|
617
|
+
}),
|
|
618
|
+
isEphemeral: true
|
|
619
|
+
});
|
|
620
|
+
var StatusUpdate = EventType("status.update", {
|
|
621
|
+
schema: Schema4.Struct({
|
|
622
|
+
/** Human-readable status message. */
|
|
623
|
+
message: Schema4.String
|
|
624
|
+
}),
|
|
625
|
+
isEphemeral: true
|
|
626
|
+
});
|
|
627
|
+
var emitStatus = (message) => write(StatusUpdate, {
|
|
628
|
+
message
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
// src/Process.ts
|
|
632
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/core/compute/compute/src/Process.ts";
|
|
633
|
+
var ID = Schema5.String.pipe(Schema5.brand("ProcessId"));
|
|
634
|
+
var ProcessTypeId = "~@dxos/functions/Process";
|
|
635
|
+
var isProcess = (executable) => typeof executable === "object" && executable !== null && ProcessTypeId in executable;
|
|
636
|
+
var make5 = (opts, create) => {
|
|
637
|
+
assertArgument2(/^[a-z0-9]([a-z0-9.\-/]*[a-z0-9])?$/i.test(opts.key), "key", "Invalid key");
|
|
638
|
+
return {
|
|
639
|
+
[ProcessTypeId]: {},
|
|
640
|
+
...opts,
|
|
641
|
+
create: (ctx) => create(ctx).pipe(Effect7.map((partial) => ({
|
|
642
|
+
onSpawn: () => Effect7.void,
|
|
643
|
+
onInput: () => Effect7.void,
|
|
644
|
+
onAlarm: () => Effect7.void,
|
|
645
|
+
onChildEvent: () => Effect7.void,
|
|
646
|
+
...partial
|
|
647
|
+
})))
|
|
648
|
+
};
|
|
649
|
+
};
|
|
650
|
+
var OperationStartedKey = key(Schema5.parseJson(Schema5.Boolean), "operation/started").pipe(withDefault(() => false));
|
|
651
|
+
var fromOperation = (op, handler) => make5({
|
|
652
|
+
key: DXN4.getName(op.meta.key),
|
|
653
|
+
input: op.input,
|
|
654
|
+
output: op.output,
|
|
655
|
+
services: op.services
|
|
656
|
+
}, (ctx) => Effect7.gen(function* () {
|
|
657
|
+
const semaphore = yield* Effect7.makeSemaphore(1);
|
|
658
|
+
const idempotent = isIdempotent(op);
|
|
659
|
+
return {
|
|
660
|
+
onInput: (input) => Effect7.gen(function* () {
|
|
661
|
+
if (!idempotent) {
|
|
662
|
+
const started = yield* OperationStartedKey.get;
|
|
663
|
+
if (started) {
|
|
664
|
+
return yield* Effect7.die(new Error(`non-idempotent operation "${op.meta.key}" was interrupted; cannot retry safely`));
|
|
665
|
+
}
|
|
666
|
+
yield* OperationStartedKey.set(true);
|
|
667
|
+
}
|
|
668
|
+
log3("operation process invoking", {
|
|
669
|
+
key: op.meta.key,
|
|
670
|
+
name: op.meta.name
|
|
671
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 66, S: this });
|
|
672
|
+
yield* write(OperationStart, {
|
|
673
|
+
key: op.meta.key,
|
|
674
|
+
name: op.meta.name,
|
|
675
|
+
icon: op.meta.icon
|
|
676
|
+
});
|
|
677
|
+
yield* write(OperationInput, {
|
|
678
|
+
key: op.meta.key,
|
|
679
|
+
name: op.meta.name,
|
|
680
|
+
input
|
|
681
|
+
});
|
|
682
|
+
const opHandler = yield* getHandler(handler, op).pipe(Effect7.orDie);
|
|
683
|
+
const output = yield* opHandler.handler(input).pipe(Effect7.orDie, Effect7.withSpan(op.meta.key));
|
|
684
|
+
ctx.submitOutput(output);
|
|
685
|
+
ctx.succeed();
|
|
686
|
+
yield* write(OperationOutput, {
|
|
687
|
+
key: op.meta.key,
|
|
688
|
+
name: op.meta.name,
|
|
689
|
+
output
|
|
690
|
+
});
|
|
691
|
+
yield* write(OperationEnd, {
|
|
692
|
+
key: op.meta.key,
|
|
693
|
+
name: op.meta.name,
|
|
694
|
+
icon: op.meta.icon,
|
|
695
|
+
outcome: "success"
|
|
696
|
+
});
|
|
697
|
+
}).pipe(Effect7.catchAllDefect((defect) => Effect7.gen(function* () {
|
|
698
|
+
const errorMessage = defect instanceof Error ? defect.message : String(defect);
|
|
699
|
+
yield* write(OperationEnd, {
|
|
700
|
+
key: op.meta.key,
|
|
701
|
+
name: op.meta.name,
|
|
702
|
+
icon: op.meta.icon,
|
|
703
|
+
outcome: "failure",
|
|
704
|
+
error: errorMessage
|
|
705
|
+
});
|
|
706
|
+
return yield* Effect7.die(defect);
|
|
707
|
+
})), semaphore.withPermits(1))
|
|
708
|
+
};
|
|
709
|
+
}));
|
|
710
|
+
var State = /* @__PURE__ */ (function(State2) {
|
|
711
|
+
State2["RUNNING"] = "RUNNING";
|
|
712
|
+
State2["HYBERNATING"] = "HYBERNATING";
|
|
713
|
+
State2["IDLE"] = "IDLE";
|
|
714
|
+
State2["TERMINATING"] = "TERMINATING";
|
|
715
|
+
State2["TERMINATED"] = "TERMINATED";
|
|
716
|
+
State2["SUCCEEDED"] = "SUCCEEDED";
|
|
717
|
+
State2["FAILED"] = "FAILED";
|
|
718
|
+
return State2;
|
|
719
|
+
})({});
|
|
720
|
+
var ProcessMonitorService = class extends Context4.Tag("@dxos/functions/ProcessMonitorService")() {
|
|
721
|
+
};
|
|
722
|
+
var SpawnedEvent = EventType("process.spawned", {
|
|
723
|
+
schema: Schema5.Void,
|
|
724
|
+
isEphemeral: false
|
|
725
|
+
});
|
|
726
|
+
var ExitedEvent = EventType("process.exited", {
|
|
727
|
+
schema: Schema5.Struct({
|
|
728
|
+
outcome: Schema5.Literal("succeeded", "failed", "terminated")
|
|
729
|
+
}),
|
|
730
|
+
isEphemeral: false
|
|
731
|
+
});
|
|
732
|
+
var prettyProcessTree = (tree) => {
|
|
733
|
+
if (tree.length === 0) {
|
|
734
|
+
return "";
|
|
735
|
+
}
|
|
736
|
+
const pidSet = new Set(tree.map((node) => node.pid));
|
|
737
|
+
const childrenByParent = /* @__PURE__ */ new Map();
|
|
738
|
+
const roots = [];
|
|
739
|
+
for (const node of tree) {
|
|
740
|
+
const parent = node.parentPid;
|
|
741
|
+
if (parent === null || !pidSet.has(parent)) {
|
|
742
|
+
roots.push(node);
|
|
743
|
+
continue;
|
|
744
|
+
}
|
|
745
|
+
const key2 = String(parent);
|
|
746
|
+
const siblings = childrenByParent.get(key2) ?? [];
|
|
747
|
+
siblings.push(node);
|
|
748
|
+
childrenByParent.set(key2, siblings);
|
|
749
|
+
}
|
|
750
|
+
const byPid = (a, b) => String(a.pid).localeCompare(String(b.pid));
|
|
751
|
+
roots.sort(byPid);
|
|
752
|
+
for (const siblings of childrenByParent.values()) {
|
|
753
|
+
siblings.sort(byPid);
|
|
754
|
+
}
|
|
755
|
+
const formatLabel = (node) => {
|
|
756
|
+
const idShort = String(node.pid).slice(0, 6);
|
|
757
|
+
const parts = [
|
|
758
|
+
idShort,
|
|
759
|
+
node.state
|
|
760
|
+
];
|
|
761
|
+
if (node.params.name != null && node.params.name !== "") {
|
|
762
|
+
parts.push(node.params.name);
|
|
763
|
+
}
|
|
764
|
+
if (node.error != null) {
|
|
765
|
+
parts.push(`(${node.error})`);
|
|
766
|
+
}
|
|
767
|
+
const { inputCount, outputCount, wallTime } = node.metrics;
|
|
768
|
+
parts.push(`[in:${inputCount} out:${outputCount} wall:${Math.round(wallTime)}ms]`);
|
|
769
|
+
return parts.join(" ");
|
|
770
|
+
};
|
|
771
|
+
const lines = [];
|
|
772
|
+
const walk = (node, prefix, isLast, isRoot) => {
|
|
773
|
+
if (isRoot) {
|
|
774
|
+
lines.push(`- ${formatLabel(node)}`);
|
|
775
|
+
} else {
|
|
776
|
+
const branch = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
777
|
+
lines.push(`${prefix}${branch}${formatLabel(node)}`);
|
|
778
|
+
}
|
|
779
|
+
const children = childrenByParent.get(String(node.pid)) ?? [];
|
|
780
|
+
const nextPrefix = isRoot ? " " : `${prefix}${isLast ? " " : "\u2502 "}`;
|
|
781
|
+
children.forEach((child, index) => {
|
|
782
|
+
walk(child, nextPrefix, index === children.length - 1, false);
|
|
783
|
+
});
|
|
784
|
+
};
|
|
785
|
+
for (const root of roots) {
|
|
786
|
+
walk(root, "", true, true);
|
|
787
|
+
}
|
|
788
|
+
return lines.join("\n");
|
|
789
|
+
};
|
|
790
|
+
|
|
791
|
+
// src/Routine.ts
|
|
792
|
+
var Routine_exports = {};
|
|
793
|
+
__export(Routine_exports, {
|
|
794
|
+
Routine: () => Routine,
|
|
795
|
+
make: () => make6
|
|
796
|
+
});
|
|
797
|
+
import * as Schema6 from "effect/Schema";
|
|
798
|
+
import { DXN as DXN5, Annotation as Annotation3, JsonSchema, Obj as Obj3, Ref as Ref2, Type as Type3, Format } from "@dxos/echo";
|
|
799
|
+
import { Text as Text2 } from "@dxos/schema";
|
|
800
|
+
var Routine = Schema6.Struct({
|
|
801
|
+
name: Schema6.optional(Schema6.String),
|
|
802
|
+
description: Schema6.optional(Schema6.String),
|
|
803
|
+
input: JsonSchema.JsonSchema.pipe(Annotation3.FormInputAnnotation.set(false)).annotations({
|
|
804
|
+
description: "Input schema"
|
|
805
|
+
}),
|
|
806
|
+
output: JsonSchema.JsonSchema.pipe(Annotation3.FormInputAnnotation.set(false)).annotations({
|
|
807
|
+
description: "Output schema"
|
|
808
|
+
}),
|
|
809
|
+
instructions: Ref2.Ref(Text2.Text).pipe(Format.FormatAnnotation.set(Format.TypeFormat.Markdown), Schema6.annotations({
|
|
810
|
+
title: "Instructions",
|
|
811
|
+
description: "Agent instructions"
|
|
812
|
+
})),
|
|
813
|
+
blueprints: Schema6.Array(Ref2.Ref(Blueprint)),
|
|
814
|
+
context: Schema6.Array(Schema6.Any).pipe(Annotation3.FormInputAnnotation.set(false))
|
|
815
|
+
}).pipe(Annotation3.LabelAnnotation.set([
|
|
816
|
+
"name"
|
|
817
|
+
]), Annotation3.IconAnnotation.set({
|
|
818
|
+
icon: "ph--scroll--regular",
|
|
819
|
+
hue: "sky"
|
|
820
|
+
}), Type3.makeObject(DXN5.make("org.dxos.type.routine", "0.1.0")));
|
|
821
|
+
var make6 = ({ name, description, input, output, instructions, blueprints = [], context = [] }) => Obj3.make(Routine, {
|
|
822
|
+
name,
|
|
823
|
+
description,
|
|
824
|
+
input: JsonSchema.toJsonSchema(input ?? Schema6.Void),
|
|
825
|
+
output: JsonSchema.toJsonSchema(output ?? Schema6.Void),
|
|
826
|
+
instructions: Ref2.make(Text2.make({
|
|
827
|
+
content: instructions ?? ""
|
|
828
|
+
})),
|
|
829
|
+
blueprints,
|
|
830
|
+
context
|
|
831
|
+
});
|
|
832
|
+
|
|
833
|
+
// src/Script.ts
|
|
834
|
+
var Script_exports = {};
|
|
835
|
+
__export(Script_exports, {
|
|
836
|
+
Script: () => Script,
|
|
837
|
+
make: () => make7
|
|
838
|
+
});
|
|
839
|
+
import * as Schema7 from "effect/Schema";
|
|
840
|
+
import { DXN as DXN6, Annotation as Annotation4, Obj as Obj4, Ref as Ref3, Type as Type4 } from "@dxos/echo";
|
|
841
|
+
import { FormInputAnnotation } from "@dxos/echo/Annotation";
|
|
842
|
+
import { Text as Text3 } from "@dxos/schema";
|
|
843
|
+
var Script = Schema7.Struct({
|
|
844
|
+
name: Schema7.String.pipe(Schema7.optional),
|
|
845
|
+
description: Schema7.String.pipe(Schema7.optional),
|
|
846
|
+
// TODO(burdon): Change to hash of deployed content.
|
|
847
|
+
// Whether source has changed since last deploy.
|
|
848
|
+
changed: Schema7.Boolean.pipe(FormInputAnnotation.set(false), Schema7.optional),
|
|
849
|
+
source: Ref3.Ref(Text3.Text).pipe(FormInputAnnotation.set(false))
|
|
850
|
+
}).pipe(Annotation4.LabelAnnotation.set([
|
|
851
|
+
"name"
|
|
852
|
+
]), Annotation4.IconAnnotation.set({
|
|
853
|
+
icon: "ph--code--regular",
|
|
854
|
+
hue: "sky"
|
|
855
|
+
}), Type4.makeObject(DXN6.make("org.dxos.type.script", "0.1.0")));
|
|
856
|
+
var make7 = ({ source = "", ...props } = {}) => Obj4.make(Script, {
|
|
857
|
+
...props,
|
|
858
|
+
source: Ref3.make(Text3.make({
|
|
859
|
+
content: source
|
|
860
|
+
}))
|
|
861
|
+
});
|
|
862
|
+
|
|
863
|
+
// src/ServiceResolver.ts
|
|
864
|
+
var ServiceResolver_exports = {};
|
|
865
|
+
__export(ServiceResolver_exports, {
|
|
866
|
+
ServiceResolver: () => ServiceResolver,
|
|
867
|
+
compose: () => compose,
|
|
868
|
+
empty: () => empty2,
|
|
869
|
+
fromContext: () => fromContext,
|
|
870
|
+
fromRequirements: () => fromRequirements,
|
|
871
|
+
layerRequirements: () => layerRequirements,
|
|
872
|
+
make: () => make9,
|
|
873
|
+
provide: () => provide,
|
|
874
|
+
resolve: () => resolve3,
|
|
875
|
+
resolveAll: () => resolveAll,
|
|
876
|
+
succeed: () => succeed2
|
|
877
|
+
});
|
|
878
|
+
import * as Context5 from "effect/Context";
|
|
879
|
+
import * as Effect8 from "effect/Effect";
|
|
880
|
+
import * as Either from "effect/Either";
|
|
881
|
+
import * as Layer4 from "effect/Layer";
|
|
882
|
+
import * as Option from "effect/Option";
|
|
883
|
+
var ServiceResolverTypeId = "~@dxos/functions/ServiceResolver";
|
|
884
|
+
var ServiceResolver = Context5.GenericTag("@dxos/functions/ServiceResolver");
|
|
885
|
+
var resolve3 = Effect8.serviceFunctionEffect(ServiceResolver, (_) => _.resolve);
|
|
886
|
+
var resolveAll = (tags, context) => Effect8.gen(function* () {
|
|
887
|
+
const services = yield* Effect8.forEach(tags, (tag) => resolve3(tag, context).pipe(Effect8.map((service) => Context5.make(tag, service))));
|
|
888
|
+
return Context5.mergeAll(...services);
|
|
889
|
+
});
|
|
890
|
+
var succeed2 = (tag, getService) => {
|
|
891
|
+
return make9((tag1, context) => {
|
|
892
|
+
if (tag1.key !== tag.key) {
|
|
893
|
+
return Effect8.fail(new ServiceNotAvailableError(`Service not available: ${String(tag.key ?? tag)}`));
|
|
894
|
+
}
|
|
895
|
+
const service = getService(context);
|
|
896
|
+
return service;
|
|
897
|
+
});
|
|
898
|
+
};
|
|
899
|
+
var make9 = (resolveFn) => ({
|
|
900
|
+
[ServiceResolverTypeId]: ServiceResolverTypeId,
|
|
901
|
+
resolve: resolveFn
|
|
902
|
+
});
|
|
903
|
+
var fromContext = (ctx) => make9((tag, context) => Effect8.gen(function* () {
|
|
904
|
+
const service = Context5.getOption(ctx, tag);
|
|
905
|
+
if (Option.isNone(service)) {
|
|
906
|
+
return yield* Effect8.fail(new ServiceNotAvailableError(String(tag.key ?? tag)));
|
|
907
|
+
}
|
|
908
|
+
return service.value;
|
|
909
|
+
}));
|
|
910
|
+
var fromRequirements = (...tags) => Effect8.contextWith((parentCtx) => {
|
|
911
|
+
const available = new Set(tags.map((tag) => tag.key));
|
|
912
|
+
return make9((tag, context) => Effect8.gen(function* () {
|
|
913
|
+
let result = Context5.empty();
|
|
914
|
+
if (!available.has(tag.key)) {
|
|
915
|
+
return yield* Effect8.fail(new ServiceNotAvailableError(String(tag.key ?? tag)));
|
|
916
|
+
}
|
|
917
|
+
const service = Context5.getOption(parentCtx, tag);
|
|
918
|
+
if (Option.isNone(service)) {
|
|
919
|
+
return yield* Effect8.fail(new ServiceNotAvailableError(String(tag.key ?? tag)));
|
|
920
|
+
}
|
|
921
|
+
return service.value;
|
|
922
|
+
}));
|
|
923
|
+
});
|
|
924
|
+
var layerRequirements = (...tags) => Layer4.effect(ServiceResolver, fromRequirements(...tags));
|
|
925
|
+
var provide = (context, ...tags) => Layer4.scopedContext(resolveAll(tags, context));
|
|
926
|
+
var compose = (...resolvers) => make9((tag, context) => Effect8.gen(function* () {
|
|
927
|
+
for (const resolver of resolvers) {
|
|
928
|
+
const single = yield* resolver.resolve(tag, context).pipe(Effect8.either);
|
|
929
|
+
if (Either.isRight(single)) {
|
|
930
|
+
return single.right;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
return yield* Effect8.fail(new ServiceNotAvailableError(String(tag.key ?? tag)));
|
|
934
|
+
}));
|
|
935
|
+
var empty2 = make9((tag, context) => {
|
|
936
|
+
return Effect8.fail(new ServiceNotAvailableError(String(tag.key ?? tag)));
|
|
937
|
+
});
|
|
938
|
+
|
|
939
|
+
// src/Trigger.ts
|
|
940
|
+
var Trigger_exports = {};
|
|
941
|
+
__export(Trigger_exports, {
|
|
942
|
+
EmailSpec: () => EmailSpec,
|
|
943
|
+
FeedSpec: () => FeedSpec,
|
|
944
|
+
Kinds: () => Kinds,
|
|
945
|
+
Spec: () => Spec,
|
|
946
|
+
SubscriptionSpec: () => SubscriptionSpec,
|
|
947
|
+
TimerSpec: () => TimerSpec,
|
|
948
|
+
Trigger: () => Trigger,
|
|
949
|
+
WebhookSpec: () => WebhookSpec,
|
|
950
|
+
make: () => make10,
|
|
951
|
+
specEmail: () => specEmail,
|
|
952
|
+
specFeed: () => specFeed,
|
|
953
|
+
specSubscription: () => specSubscription,
|
|
954
|
+
specTimer: () => specTimer,
|
|
955
|
+
specWebhook: () => specWebhook
|
|
956
|
+
});
|
|
957
|
+
import * as Schema8 from "effect/Schema";
|
|
958
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
959
|
+
import { DXN as DXN7, Annotation as Annotation5, Feed, Obj as Obj5, QueryAST, Ref as Ref4, Type as Type5 } from "@dxos/echo";
|
|
960
|
+
import { HiddenAnnotation } from "@dxos/echo/Annotation";
|
|
961
|
+
import { OptionsAnnotationId } from "@dxos/echo/Format";
|
|
962
|
+
var Kinds = [
|
|
963
|
+
"email",
|
|
964
|
+
"feed",
|
|
965
|
+
"subscription",
|
|
966
|
+
"timer",
|
|
967
|
+
"webhook"
|
|
968
|
+
];
|
|
969
|
+
var kindLiteralAnnotations = {
|
|
970
|
+
title: "Kind"
|
|
971
|
+
};
|
|
972
|
+
var EmailSpec = Schema8.Struct({
|
|
973
|
+
kind: Schema8.Literal("email").annotations(kindLiteralAnnotations)
|
|
974
|
+
});
|
|
975
|
+
var specEmail = () => ({
|
|
976
|
+
kind: "email"
|
|
977
|
+
});
|
|
978
|
+
var FeedSpec = Schema8.Struct({
|
|
979
|
+
kind: Schema8.Literal("feed").annotations(kindLiteralAnnotations),
|
|
980
|
+
feed: Schema8.optional(Ref4.Ref(Feed.Feed).annotations({
|
|
981
|
+
title: "Feed"
|
|
982
|
+
}))
|
|
983
|
+
});
|
|
984
|
+
var specFeed = (feed) => ({
|
|
985
|
+
kind: "feed",
|
|
986
|
+
feed: Ref4.make(feed)
|
|
987
|
+
});
|
|
988
|
+
var SubscriptionSpec = Schema8.Struct({
|
|
989
|
+
kind: Schema8.Literal("subscription").annotations(kindLiteralAnnotations),
|
|
990
|
+
query: Schema8.Struct({
|
|
991
|
+
raw: Schema8.optional(Schema8.String.annotations({
|
|
992
|
+
title: "Query"
|
|
993
|
+
})),
|
|
994
|
+
ast: QueryAST.Query
|
|
995
|
+
}),
|
|
996
|
+
options: Schema8.optional(Schema8.Struct({
|
|
997
|
+
// Watch changes to object (not just creation).
|
|
998
|
+
deep: Schema8.optional(Schema8.Boolean.annotations({
|
|
999
|
+
title: "Nested"
|
|
1000
|
+
})),
|
|
1001
|
+
// Debounce changes (delay in ms).
|
|
1002
|
+
delay: Schema8.optional(Schema8.Number.annotations({
|
|
1003
|
+
title: "Delay"
|
|
1004
|
+
}))
|
|
1005
|
+
}).annotations({
|
|
1006
|
+
title: "Options"
|
|
1007
|
+
}))
|
|
1008
|
+
});
|
|
1009
|
+
var specSubscription = (query, options) => ({
|
|
1010
|
+
kind: "subscription",
|
|
1011
|
+
query: {
|
|
1012
|
+
ast: query.ast
|
|
1013
|
+
},
|
|
1014
|
+
options: options ? {
|
|
1015
|
+
deep: options.deep,
|
|
1016
|
+
delay: options.delay
|
|
1017
|
+
} : void 0
|
|
1018
|
+
});
|
|
1019
|
+
var TimerSpec = Schema8.Struct({
|
|
1020
|
+
kind: Schema8.Literal("timer").annotations(kindLiteralAnnotations),
|
|
1021
|
+
cron: Schema8.String.annotations({
|
|
1022
|
+
title: "Cron",
|
|
1023
|
+
[SchemaAST.ExamplesAnnotationId]: [
|
|
1024
|
+
"0 0 * * *"
|
|
1025
|
+
]
|
|
1026
|
+
})
|
|
1027
|
+
});
|
|
1028
|
+
var specTimer = (cron) => ({
|
|
1029
|
+
kind: "timer",
|
|
1030
|
+
cron
|
|
1031
|
+
});
|
|
1032
|
+
var WebhookSpec = Schema8.Struct({
|
|
1033
|
+
kind: Schema8.Literal("webhook").annotations(kindLiteralAnnotations),
|
|
1034
|
+
method: Schema8.optional(Schema8.String.annotations({
|
|
1035
|
+
title: "Method",
|
|
1036
|
+
[OptionsAnnotationId]: [
|
|
1037
|
+
"GET",
|
|
1038
|
+
"POST"
|
|
1039
|
+
]
|
|
1040
|
+
})),
|
|
1041
|
+
port: Schema8.optional(Schema8.Number.annotations({
|
|
1042
|
+
title: "Port"
|
|
1043
|
+
}))
|
|
1044
|
+
});
|
|
1045
|
+
var specWebhook = (opts) => ({
|
|
1046
|
+
kind: "webhook",
|
|
1047
|
+
method: opts?.method,
|
|
1048
|
+
port: opts?.port
|
|
1049
|
+
});
|
|
1050
|
+
var Spec = Schema8.Union(EmailSpec, FeedSpec, SubscriptionSpec, TimerSpec, WebhookSpec).annotations({
|
|
1051
|
+
title: "Trigger"
|
|
1052
|
+
});
|
|
1053
|
+
var TriggerSchema = Schema8.Struct({
|
|
1054
|
+
/**
|
|
1055
|
+
* Function or workflow to invoke.
|
|
1056
|
+
*/
|
|
1057
|
+
// TODO(dmaretskyi): Can be a Ref(FunctionType) or Ref(ComputeGraphType).
|
|
1058
|
+
function: Schema8.optional(Ref4.Ref(Obj5.Unknown).annotations({
|
|
1059
|
+
title: "Function"
|
|
1060
|
+
})),
|
|
1061
|
+
/**
|
|
1062
|
+
* Only used for workflowSchema.
|
|
1063
|
+
* Specifies the input node in the circuit.
|
|
1064
|
+
* @deprecated Remove and enforce a single input node in all compute graphSchema.
|
|
1065
|
+
*/
|
|
1066
|
+
inputNodeId: Schema8.optional(Schema8.String.annotations({
|
|
1067
|
+
title: "Input Node ID"
|
|
1068
|
+
})),
|
|
1069
|
+
// TODO(burdon): NO BOOLEAN PROPERTIES (enabld/disabled/paused, etc.)
|
|
1070
|
+
// Need lint rule; or agent rule to require PR review for "boolean" key word.
|
|
1071
|
+
enabled: Schema8.optional(Schema8.Boolean.annotations({
|
|
1072
|
+
title: "Enabled"
|
|
1073
|
+
})),
|
|
1074
|
+
spec: Schema8.optional(Spec),
|
|
1075
|
+
concurrency: Schema8.optional(Schema8.Number.annotations({
|
|
1076
|
+
title: "Concurrency",
|
|
1077
|
+
default: 1,
|
|
1078
|
+
description: "Maximum number of concurrent invocations of the trigger. For Feed triggers, this will process Feed items in parallel."
|
|
1079
|
+
})),
|
|
1080
|
+
/**
|
|
1081
|
+
* Passed as the input data to the function.
|
|
1082
|
+
* Must match the function's input schema.
|
|
1083
|
+
*
|
|
1084
|
+
* @example
|
|
1085
|
+
* {
|
|
1086
|
+
* item: '{{event.item}}',
|
|
1087
|
+
* instructions: 'Summarize and perform entity-extraction'
|
|
1088
|
+
* mailbox: { '/': 'echo://AAA/ZZZ' }
|
|
1089
|
+
* }
|
|
1090
|
+
*/
|
|
1091
|
+
input: Schema8.optional(Schema8.Record({
|
|
1092
|
+
key: Schema8.String,
|
|
1093
|
+
value: Schema8.Any
|
|
1094
|
+
}))
|
|
1095
|
+
}).pipe(Annotation5.IconAnnotation.set({
|
|
1096
|
+
icon: "ph--lightning--regular",
|
|
1097
|
+
hue: "yellow"
|
|
1098
|
+
}), HiddenAnnotation.set(true), Type5.makeObject(DXN7.make("org.dxos.type.trigger", "0.1.0")));
|
|
1099
|
+
var Trigger = TriggerSchema;
|
|
1100
|
+
var make10 = (props) => Obj5.make(Trigger, props);
|
|
1101
|
+
|
|
1102
|
+
// src/TriggerEvent.ts
|
|
1103
|
+
var TriggerEvent_exports = {};
|
|
1104
|
+
__export(TriggerEvent_exports, {
|
|
1105
|
+
EmailEvent: () => EmailEvent,
|
|
1106
|
+
FeedEvent: () => FeedEvent,
|
|
1107
|
+
SubscriptionEvent: () => SubscriptionEvent,
|
|
1108
|
+
TimerEvent: () => TimerEvent,
|
|
1109
|
+
TriggerEvent: () => TriggerEvent,
|
|
1110
|
+
WebhookEvent: () => WebhookEvent
|
|
1111
|
+
});
|
|
1112
|
+
import * as Schema9 from "effect/Schema";
|
|
1113
|
+
import { Feed as Feed2, Obj as Obj6, Ref as Ref5 } from "@dxos/echo";
|
|
1114
|
+
var EmailEvent = Schema9.Struct({
|
|
1115
|
+
from: Schema9.String,
|
|
1116
|
+
to: Schema9.String,
|
|
1117
|
+
subject: Schema9.String,
|
|
1118
|
+
created: Schema9.String,
|
|
1119
|
+
body: Schema9.String
|
|
1120
|
+
});
|
|
1121
|
+
var FeedEvent = Schema9.Struct({
|
|
1122
|
+
feed: Ref5.Ref(Feed2.Feed),
|
|
1123
|
+
item: Schema9.Any,
|
|
1124
|
+
cursor: Schema9.String
|
|
1125
|
+
});
|
|
1126
|
+
var SubscriptionEvent = Schema9.Struct({
|
|
1127
|
+
/**
|
|
1128
|
+
* Type of the mutation.
|
|
1129
|
+
*/
|
|
1130
|
+
// TODO(dmaretskyi): Specify enum.
|
|
1131
|
+
type: Schema9.String,
|
|
1132
|
+
/**
|
|
1133
|
+
* Reference to the object that was changed or created.
|
|
1134
|
+
*/
|
|
1135
|
+
subject: Ref5.Ref(Obj6.Unknown),
|
|
1136
|
+
/**
|
|
1137
|
+
* @deprecated
|
|
1138
|
+
*/
|
|
1139
|
+
changedObjectId: Schema9.optional(Schema9.String)
|
|
1140
|
+
});
|
|
1141
|
+
var TimerEvent = Schema9.Struct({
|
|
1142
|
+
tick: Schema9.Number
|
|
1143
|
+
});
|
|
1144
|
+
var WebhookEvent = Schema9.Struct({
|
|
1145
|
+
url: Schema9.String,
|
|
1146
|
+
method: Schema9.Literal("GET", "POST"),
|
|
1147
|
+
headers: Schema9.Record({
|
|
1148
|
+
key: Schema9.String,
|
|
1149
|
+
value: Schema9.String
|
|
1150
|
+
}),
|
|
1151
|
+
bodyText: Schema9.String
|
|
1152
|
+
});
|
|
1153
|
+
var TriggerEvent = Schema9.Union(EmailEvent, FeedEvent, SubscriptionEvent, TimerEvent, WebhookEvent);
|
|
1154
|
+
export {
|
|
1155
|
+
Blueprint_exports as Blueprint,
|
|
1156
|
+
Credential_exports as Credential,
|
|
1157
|
+
FunctionError,
|
|
1158
|
+
FunctionNotFoundError,
|
|
1159
|
+
FunctionsAiMemoizationMissError,
|
|
1160
|
+
FunctionsAiUpstreamError,
|
|
1161
|
+
Header_exports as Header,
|
|
1162
|
+
InvalidOperationInputError,
|
|
1163
|
+
InvalidOperationOutputError,
|
|
1164
|
+
InvokerNotInitializedError,
|
|
1165
|
+
LayerSpec_exports as LayerSpec,
|
|
1166
|
+
McpServer_exports as McpServer,
|
|
1167
|
+
NoHandlerError,
|
|
1168
|
+
Operation_exports as Operation,
|
|
1169
|
+
OperationHandlerSet_exports as OperationHandlerSet,
|
|
1170
|
+
OperationRegistry_exports as OperationRegistry,
|
|
1171
|
+
Process_exports as Process,
|
|
1172
|
+
Routine_exports as Routine,
|
|
1173
|
+
Script_exports as Script,
|
|
1174
|
+
ServiceNotAvailableError,
|
|
1175
|
+
ServiceResolver_exports as ServiceResolver,
|
|
1176
|
+
StorageService_exports as StorageService,
|
|
1177
|
+
Template_exports as Template,
|
|
1178
|
+
Trace_exports as Trace,
|
|
1179
|
+
Trigger_exports as Trigger,
|
|
1180
|
+
TriggerEvent_exports as TriggerEvent,
|
|
1181
|
+
TriggerStateNotFoundError
|
|
1182
|
+
};
|
|
1183
|
+
//# sourceMappingURL=index.mjs.map
|