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