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