@dxos/compute 0.9.1-main.c7dcc2e112 → 0.9.1-staging.ee54ba693a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/README.md +4 -4
  2. package/dist/lib/neutral/AgentService.mjs +12 -0
  3. package/dist/lib/neutral/StorageService.mjs +3 -3
  4. package/dist/lib/neutral/{chunk-AFBNVFAY.mjs → chunk-2ZN64ZS7.mjs} +3 -3
  5. package/dist/lib/neutral/{chunk-JAU4E4EK.mjs → chunk-5VAXF6AH.mjs} +2 -2
  6. package/dist/lib/neutral/{chunk-QZS4G6PE.mjs → chunk-EVROJER7.mjs} +70 -25
  7. package/dist/lib/neutral/chunk-EVROJER7.mjs.map +7 -0
  8. package/dist/lib/neutral/{chunk-XEVFBI6S.mjs → chunk-PF7XP7XP.mjs} +13 -13
  9. package/dist/lib/neutral/{chunk-XEVFBI6S.mjs.map → chunk-PF7XP7XP.mjs.map} +3 -3
  10. package/dist/lib/neutral/{chunk-MEPE4HHX.mjs → chunk-SJ37RWHU.mjs} +3 -3
  11. package/dist/lib/neutral/chunk-VSAZPWSJ.mjs +25 -0
  12. package/dist/lib/neutral/chunk-VSAZPWSJ.mjs.map +7 -0
  13. package/dist/lib/neutral/{chunk-2B2KSJT6.mjs → chunk-WEO4FCQY.mjs} +3 -3
  14. package/dist/lib/neutral/fib-5XIYECL5.mjs +10 -0
  15. package/dist/lib/neutral/index.mjs +448 -399
  16. package/dist/lib/neutral/index.mjs.map +4 -4
  17. package/dist/lib/neutral/meta.json +1 -1
  18. package/dist/lib/neutral/reply-GCBRCUVM.mjs +10 -0
  19. package/dist/lib/neutral/sleep-XR6CL6W3.mjs +10 -0
  20. package/dist/lib/neutral/sleep-XR6CL6W3.mjs.map +7 -0
  21. package/dist/lib/neutral/testing/index.mjs +6 -6
  22. package/dist/types/src/AgentService.d.ts +71 -0
  23. package/dist/types/src/AgentService.d.ts.map +1 -0
  24. package/dist/types/src/Credential.d.ts +2 -0
  25. package/dist/types/src/Credential.d.ts.map +1 -1
  26. package/dist/types/src/Instructions.d.ts +33 -0
  27. package/dist/types/src/Instructions.d.ts.map +1 -0
  28. package/dist/types/src/McpServer.d.ts +1 -1
  29. package/dist/types/src/Operation.d.ts +92 -27
  30. package/dist/types/src/Operation.d.ts.map +1 -1
  31. package/dist/types/src/Operation.test.d.ts +2 -0
  32. package/dist/types/src/Operation.test.d.ts.map +1 -0
  33. package/dist/types/src/Process.d.ts +55 -21
  34. package/dist/types/src/Process.d.ts.map +1 -1
  35. package/dist/types/src/Runnable.d.ts +4 -0
  36. package/dist/types/src/Runnable.d.ts.map +1 -0
  37. package/dist/types/src/Script.d.ts +9 -11
  38. package/dist/types/src/Script.d.ts.map +1 -1
  39. package/dist/types/src/ServiceResolver.d.ts +1 -1
  40. package/dist/types/src/Skill.d.ts +157 -0
  41. package/dist/types/src/Skill.d.ts.map +1 -0
  42. package/dist/types/src/StorageService.d.ts +8 -8
  43. package/dist/types/src/StorageService.d.ts.map +1 -1
  44. package/dist/types/src/Template.d.ts +2 -4
  45. package/dist/types/src/Template.d.ts.map +1 -1
  46. package/dist/types/src/Trace.d.ts +16 -14
  47. package/dist/types/src/Trace.d.ts.map +1 -1
  48. package/dist/types/src/Trigger.d.ts +26 -61
  49. package/dist/types/src/Trigger.d.ts.map +1 -1
  50. package/dist/types/src/TriggerEvent.d.ts +3 -11
  51. package/dist/types/src/TriggerEvent.d.ts.map +1 -1
  52. package/dist/types/src/index.d.ts +5 -3
  53. package/dist/types/src/index.d.ts.map +1 -1
  54. package/dist/types/tsconfig.tsbuildinfo +1 -1
  55. package/package.json +21 -15
  56. package/src/AgentService.ts +90 -0
  57. package/src/Credential.ts +3 -0
  58. package/src/Instructions.ts +73 -0
  59. package/src/McpServer.ts +1 -1
  60. package/src/Operation.test.ts +39 -0
  61. package/src/Operation.ts +130 -54
  62. package/src/Process.ts +96 -26
  63. package/src/Runnable.ts +12 -0
  64. package/src/Script.ts +14 -14
  65. package/src/ServiceResolver.ts +1 -1
  66. package/src/Skill.ts +218 -0
  67. package/src/StorageService.ts +15 -12
  68. package/src/Template.ts +2 -1
  69. package/src/Trace.ts +13 -11
  70. package/src/Trigger.ts +57 -52
  71. package/src/index.ts +5 -3
  72. package/src/umbrella.test.ts +8 -6
  73. package/dist/lib/neutral/chunk-QZS4G6PE.mjs.map +0 -7
  74. package/dist/lib/neutral/fib-HBDUGQW7.mjs +0 -10
  75. package/dist/lib/neutral/reply-RJIAJ6FV.mjs +0 -10
  76. package/dist/lib/neutral/sleep-3T2CZ7RE.mjs +0 -10
  77. package/dist/types/src/Blueprint.d.ts +0 -182
  78. package/dist/types/src/Blueprint.d.ts.map +0 -1
  79. package/dist/types/src/Routine.d.ts +0 -54
  80. package/dist/types/src/Routine.d.ts.map +0 -1
  81. package/src/Blueprint.ts +0 -224
  82. package/src/Routine.ts +0 -69
  83. /package/dist/lib/neutral/{fib-HBDUGQW7.mjs.map → AgentService.mjs.map} +0 -0
  84. /package/dist/lib/neutral/{chunk-AFBNVFAY.mjs.map → chunk-2ZN64ZS7.mjs.map} +0 -0
  85. /package/dist/lib/neutral/{chunk-JAU4E4EK.mjs.map → chunk-5VAXF6AH.mjs.map} +0 -0
  86. /package/dist/lib/neutral/{chunk-MEPE4HHX.mjs.map → chunk-SJ37RWHU.mjs.map} +0 -0
  87. /package/dist/lib/neutral/{chunk-2B2KSJT6.mjs.map → chunk-WEO4FCQY.mjs.map} +0 -0
  88. /package/dist/lib/neutral/{reply-RJIAJ6FV.mjs.map → fib-5XIYECL5.mjs.map} +0 -0
  89. /package/dist/lib/neutral/{sleep-3T2CZ7RE.mjs.map → reply-GCBRCUVM.mjs.map} +0 -0
@@ -1,8 +1,11 @@
1
+ import {
2
+ AgentService_exports
3
+ } from "./chunk-VSAZPWSJ.mjs";
1
4
  import {
2
5
  StorageService_exports,
3
- key,
6
+ cell,
4
7
  withDefault
5
- } from "./chunk-XEVFBI6S.mjs";
8
+ } from "./chunk-PF7XP7XP.mjs";
6
9
  import {
7
10
  FunctionError,
8
11
  FunctionNotFoundError,
@@ -20,35 +23,36 @@ import {
20
23
  getHandlerByKey
21
24
  } from "./chunk-Z3Y7FQGN.mjs";
22
25
  import {
26
+ NotifyOptions,
23
27
  Operation_exports,
24
28
  PersistentOperation,
25
29
  deserialize,
26
30
  invoke,
27
31
  isIdempotent
28
- } from "./chunk-QZS4G6PE.mjs";
32
+ } from "./chunk-EVROJER7.mjs";
29
33
  import {
30
34
  __export
31
35
  } from "./chunk-J5LGTIGS.mjs";
32
36
 
33
- // src/Blueprint.ts
34
- var Blueprint_exports = {};
35
- __export(Blueprint_exports, {
36
- Blueprint: () => Blueprint,
37
- Blueprint_v0_1_0: () => Blueprint_v0_1_0,
37
+ // src/Skill.ts
38
+ var Skill_exports = {};
39
+ __export(Skill_exports, {
40
+ Hook: () => Hook,
41
+ HookSpec: () => HookSpec,
38
42
  NotFoundError: () => NotFoundError,
43
+ Skill: () => Skill,
39
44
  getKey: () => getKey,
40
45
  getVersion: () => getVersion,
41
- make: () => make2,
42
- migrations: () => migrations,
46
+ make: () => make3,
43
47
  registryURI: () => registryURI,
44
48
  resolve: () => resolve,
45
49
  toolDefinitions: () => toolDefinitions,
46
50
  upsert: () => upsert
47
51
  });
48
52
  import * as Effect2 from "effect/Effect";
49
- import * as Schema3 from "effect/Schema";
53
+ import * as Schema4 from "effect/Schema";
50
54
  import { ToolId } from "@dxos/ai";
51
- import { DXN as DXN2, Annotation, Database as Database2, Filter as Filter2, Migration, Obj, Registry as Registry2, Type, URI } from "@dxos/echo";
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";
52
56
  import { BaseError } from "@dxos/errors";
53
57
 
54
58
  // src/McpServer.ts
@@ -147,8 +151,8 @@ var processTemplate = (template) => Effect.gen(function* () {
147
151
  }
148
152
  case "operation": {
149
153
  invariant(input.operation, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 69, S: this, A: ["input.operation", ""] });
150
- const key2 = DXN.isDXN(input.operation) ? input.operation : `dxn:${input.operation}`;
151
- const results = yield* Registry.runQuery(Filter.and(Filter.type(PersistentOperation), Filter.key(key2)));
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)));
152
156
  if (results.length === 0) {
153
157
  return yield* Effect.fail(new FunctionNotFoundError(input.operation));
154
158
  }
@@ -171,130 +175,292 @@ var processTemplate = (template) => Effect.gen(function* () {
171
175
  return process((yield* Database.load(template.source)).content, variables);
172
176
  });
173
177
 
174
- // src/Blueprint.ts
175
- var Blueprint = Schema3.Struct({
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({
176
342
  /**
177
- * Human-readable name of the blueprint.
178
- */
179
- name: Schema3.String.annotations({
180
- description: "Human-readable name of the blueprint"
343
+ * Human-readable name of the skill.
344
+ */
345
+ name: Schema4.String.annotations({
346
+ description: "Human-readable name of the skill"
181
347
  }),
182
348
  /**
183
- * Description of the blueprint's purpose and functionality.
184
- */
185
- description: Schema3.optional(Schema3.String).annotations({
186
- description: "Description of the blueprint's purpose and functionality"
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"
187
353
  }),
188
354
  /**
189
- * Instructions that guide the AI assistant's behavior and responses.
190
- * These are system prompts or guidelines that the AI should follow.
191
- */
355
+ * Instructions that guide the AI assistant's behavior and responses.
356
+ * These are system prompts or guidelines that the AI should follow.
357
+ */
192
358
  instructions: Template.annotations({
193
359
  description: "Instructions that guide the AI assistant's behavior and responses"
194
360
  }),
195
361
  /**
196
- * Array of tools that the AI assistant can use when this blueprint is active.
197
- */
198
- tools: Schema3.Array(ToolId).annotations({
199
- description: "Array of tools that the AI assistant can use when this blueprint is active"
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"
200
366
  }),
201
367
  /**
202
- * Whether an agent is allowed to auto-enable this blueprint in a conversation.
203
- */
204
- agentCanEnable: Schema3.optional(Schema3.Boolean).annotations({
205
- description: "Whether an agent is allowed to auto-enable this blueprint in a conversation."
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."
206
372
  }),
207
373
  /**
208
- * Array of MCP servers that the AI assistant can use when this blueprint is active.
209
- */
210
- mcpServers: Schema3.optional(Schema3.Array(McpServer))
211
- }).pipe(Annotation.LabelAnnotation.set([
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([
212
382
  "name"
213
- ]), Annotation.IconAnnotation.set({
383
+ ]), Annotation2.IconAnnotation.set({
214
384
  icon: "ph--blueprint--regular",
215
385
  hue: "sky"
216
- }), Type.makeObject(DXN2.make("org.dxos.type.blueprint", "0.2.0")));
217
- var make2 = ({ key: key2, version, tools = [], instructions = make(), ...props }) => Obj.make(Blueprint, {
218
- [Obj.Meta]: {
219
- key: key2,
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,
220
422
  version
221
423
  },
222
424
  tools,
223
425
  instructions,
224
426
  ...props
225
427
  });
226
- var getKey = (blueprint) => {
227
- const key2 = Obj.getMeta(blueprint).key;
228
- if (key2 === void 0) {
229
- throw new Error("Blueprint is missing the meta key.");
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.");
230
432
  }
231
- return key2;
433
+ return key;
232
434
  };
233
- var getVersion = (blueprint) => Obj.getMeta(blueprint).version;
435
+ var getVersion = (skill) => Obj2.getMeta(skill).version;
234
436
  var toolDefinitions = ({ tools = [], operations = [] }) => [
235
- ...operations.map((op) => ToolId.make(DXN2.getName(op.meta.key))),
437
+ ...operations.map((op) => ToolId.make(DXN3.getName(op.meta.key))),
236
438
  ...tools.map((tool) => ToolId.make(tool))
237
439
  ];
238
- var registryURI = (key2) => DXN2.tryMake(`dxn:${key2}`) ?? URI.make(key2);
239
- var resolve = (key2) => Effect2.gen(function* () {
240
- const results = yield* Registry2.runQuery(Filter2.and(Filter2.type(Blueprint), Filter2.key(key2)));
241
- const blueprint = results[0];
242
- if (!blueprint) {
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) {
243
445
  return yield* Effect2.fail(new NotFoundError({
244
446
  context: {
245
- key: key2
447
+ key
246
448
  }
247
449
  }));
248
450
  }
249
- return blueprint;
451
+ return skill;
250
452
  });
251
- var upsert = (key2) => Effect2.gen(function* () {
252
- const local = yield* Database2.query(Filter2.and(Filter2.type(Blueprint), Filter2.key(key2))).run;
453
+ var upsert = (key) => Effect2.gen(function* () {
454
+ const local = yield* Database2.query(Filter2.and(Filter2.type(Skill), Filter2.key(key))).run;
253
455
  if (local.length > 0) {
254
456
  return local[0];
255
457
  }
256
- return yield* Database2.add(Obj.clone(yield* resolve(key2), {
257
- deep: true
458
+ return yield* Database2.add(Obj2.clone(yield* resolve(key), {
459
+ deep: "all"
258
460
  }));
259
461
  });
260
- var NotFoundError = class extends BaseError.extend("BlueprintNotFound", "Blueprint not found") {
462
+ var NotFoundError = class extends BaseError.extend("SkillNotFound", "Skill not found") {
261
463
  };
262
- var Blueprint_v0_1_0 = Schema3.Struct({
263
- /**
264
- * Global registry ID.
265
- * NOTE: The `key` property refers to the original registry entry.
266
- */
267
- key: Schema3.String.annotations({
268
- description: "Unique registration key for the blueprint"
269
- }),
270
- name: Schema3.String.annotations({
271
- description: "Human-readable name of the blueprint"
272
- }),
273
- description: Schema3.optional(Schema3.String),
274
- instructions: Template,
275
- tools: Schema3.Array(ToolId),
276
- agentCanEnable: Schema3.optional(Schema3.Boolean),
277
- mcpServers: Schema3.optional(Schema3.Array(McpServer))
278
- }).pipe(Type.makeObject(DXN2.make("org.dxos.type.blueprint", "0.1.0")));
279
- var _migration = Migration.define({
280
- from: Blueprint_v0_1_0,
281
- to: Blueprint,
282
- transform: async (from) => ({
283
- [Obj.Meta]: {
284
- key: from.key,
285
- version: "0.1.0"
286
- },
287
- name: from.name,
288
- description: from.description,
289
- instructions: from.instructions,
290
- tools: from.tools,
291
- agentCanEnable: from.agentCanEnable,
292
- mcpServers: from.mcpServers
293
- })
294
- });
295
- var migrations = [
296
- _migration
297
- ];
298
464
 
299
465
  // src/Credential.ts
300
466
  var Credential_exports = {};
@@ -340,20 +506,75 @@ var byokLayer = (providerHost) => Layer.effect(HttpClient.HttpClient, Effect4.ge
340
506
  }));
341
507
  }));
342
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
+
343
564
  // src/LayerSpec.ts
344
565
  var LayerSpec_exports = {};
345
566
  __export(LayerSpec_exports, {
346
567
  TypeId: () => TypeId,
347
- make: () => make4
568
+ make: () => make6
348
569
  });
349
570
  var TypeId = "~@dxos/functions/LayerSpec";
350
- var make4 = (opts, make11) => {
571
+ var make6 = (opts, make12) => {
351
572
  return {
352
573
  [TypeId]: TypeId,
353
574
  affinity: opts.affinity,
354
575
  requires: opts.requires,
355
576
  provides: opts.provides,
356
- make: make11
577
+ make: make12
357
578
  };
358
579
  };
359
580
 
@@ -375,7 +596,7 @@ var layer = Layer2.effect(Service, Effect5.gen(function* () {
375
596
  const database = yield* Database3.Service;
376
597
  const handlerSet = yield* OperationHandlerProvider;
377
598
  return {
378
- resolve: (key2) => Database3.query(Query.select(Filter3.and(Filter3.type(PersistentOperation), Filter3.key(key2)))).first.pipe(Effect5.flatten, Effect5.map(deserialize), Effect5.catchTag("NoSuchElementException", () => getHandlerByKey(handlerSet, key2)), Effect5.option).pipe(Effect5.provideService(Database3.Service, database))
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))
379
600
  };
380
601
  }));
381
602
 
@@ -383,21 +604,26 @@ var layer = Layer2.effect(Service, Effect5.gen(function* () {
383
604
  var Process_exports = {};
384
605
  __export(Process_exports, {
385
606
  ExitedEvent: () => ExitedEvent,
607
+ HarnessHostAnnotation: () => HarnessHostAnnotation,
386
608
  ID: () => ID,
609
+ NotifyAnnotation: () => NotifyAnnotation,
387
610
  ProcessMonitorService: () => ProcessMonitorService,
388
611
  ProcessTypeId: () => ProcessTypeId,
389
612
  SpawnedEvent: () => SpawnedEvent,
390
613
  State: () => State,
614
+ TargetAnnotation: () => TargetAnnotation,
391
615
  fromOperation: () => fromOperation,
392
616
  isProcess: () => isProcess,
393
- make: () => make5,
617
+ make: () => make8,
394
618
  prettyProcessTree: () => prettyProcessTree
395
619
  });
620
+ import * as RpcGroup from "@effect/rpc/RpcGroup";
396
621
  import * as Context4 from "effect/Context";
397
622
  import * as Effect7 from "effect/Effect";
398
- import * as Schema5 from "effect/Schema";
623
+ import * as Schema7 from "effect/Schema";
624
+ import { Annotation as Annotation5 } from "@dxos/echo";
399
625
  import { assertArgument as assertArgument2 } from "@dxos/invariant";
400
- import { DXN as DXN4 } from "@dxos/keys";
626
+ import { DXN as DXN6, URI as URI2 } from "@dxos/keys";
401
627
  import { log as log3 } from "@dxos/log";
402
628
 
403
629
  // src/Trace.ts
@@ -433,8 +659,8 @@ __export(Trace_exports, {
433
659
  import * as Context3 from "effect/Context";
434
660
  import * as Effect6 from "effect/Effect";
435
661
  import * as Layer3 from "effect/Layer";
436
- import * as Schema4 from "effect/Schema";
437
- import { DXN as DXN3, Annotation as Annotation2, Obj as Obj2, Type as Type2 } from "@dxos/echo";
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";
438
664
  import { log as log2 } from "@dxos/log";
439
665
  var __dxlog_file2 = "/__w/dxos/dxos/packages/core/compute/compute/src/Trace.ts";
440
666
  var TraceService = class extends Context3.Tag("@dxos/functions/TraceService")() {
@@ -444,27 +670,27 @@ function write(eventType, payload) {
444
670
  log2("trace write", {
445
671
  key: eventType.key,
446
672
  isEphemeral: eventType.isEphemeral
447
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 20, S: this });
673
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 21, S: this });
448
674
  const writer = yield* TraceService;
449
675
  writer.write(eventType, payload);
450
676
  });
451
677
  }
452
- var EventType = (key2, opts) => {
678
+ var EventType = (key, opts) => {
453
679
  return {
454
- key: key2,
680
+ key,
455
681
  schema: opts.schema,
456
682
  isEphemeral: opts.isEphemeral
457
683
  };
458
684
  };
459
- var Event = Schema4.Struct({
460
- timestamp: Schema4.Number,
461
- type: Schema4.String,
462
- data: Schema4.Unknown
685
+ var Event = Schema6.Struct({
686
+ timestamp: Schema6.Number,
687
+ type: Schema6.String,
688
+ data: Schema6.Unknown
463
689
  });
464
690
  var isOfType = (eventType, event) => {
465
691
  return event.type === eventType.key;
466
692
  };
467
- var RuntimeName = Schema4.String.pipe(Schema4.brand("@dxos/compute/Trace/RuntimeName"));
693
+ var RuntimeName = Schema6.String.pipe(Schema6.brand("@dxos/compute/Trace/RuntimeName"));
468
694
  var CommonRuntimeName = {
469
695
  /**
470
696
  * Web app / CLI / Desktop app / Mobile app.
@@ -474,42 +700,43 @@ var CommonRuntimeName = {
474
700
  edgeWorkerLoader: RuntimeName.make("edge-worker-loader"),
475
701
  edgeWorkerForPlatforms: RuntimeName.make("edge-worker-for-platforms")
476
702
  };
477
- var Meta = Schema4.Struct({
478
- pid: Schema4.optional(Schema4.String),
479
- parentPid: Schema4.optional(Schema4.String),
480
- processName: Schema4.optional(Schema4.String),
703
+ var Meta = Schema6.Struct({
704
+ pid: Schema6.optional(Schema6.String),
705
+ parentPid: Schema6.optional(Schema6.String),
706
+ processName: Schema6.optional(Schema6.String),
481
707
  /**
482
708
  * Space the message was produced in.
483
709
  * Stored as a string to avoid circular dependency on `@dxos/keys`.
484
710
  */
485
- space: Schema4.optional(Schema4.String),
711
+ space: Schema6.optional(Schema6.String),
486
712
  /**
487
- * ID of the conversation feed object if present.
713
+ * Ref to the conversation feed object if present.
488
714
  */
489
- conversationId: Schema4.optional(Obj2.ID),
715
+ conversation: Ref5.Ref(Obj4.Unknown).pipe(Schema6.optional),
490
716
  /**
491
- * ID of the trigger object if invocation resulted from a trigger.
717
+ * Ref to the trigger object if invocation resulted from a trigger.
492
718
  */
493
- triggerId: Schema4.optional(Obj2.ID),
719
+ trigger: Ref5.Ref(Trigger).pipe(Schema6.optional),
494
720
  /**
495
721
  * ID of the tool call that created the current process.
496
722
  */
497
- toolCallId: Schema4.optional(Schema4.String),
723
+ toolCallId: Schema6.optional(Schema6.String),
498
724
  /**
499
725
  * Extensible name informing which runtime executed the code that produced the event.
500
726
  */
501
- runtimeName: Schema4.optional(RuntimeName)
727
+ runtimeName: Schema6.optional(RuntimeName)
502
728
  });
503
729
  var isEdgeRuntime = (name) => name === CommonRuntimeName.edgeIntrinsic || name === CommonRuntimeName.edgeWorkerLoader || name === CommonRuntimeName.edgeWorkerForPlatforms;
504
- var MessageData = Schema4.Struct({
730
+ var MessageData = Schema6.Struct({
505
731
  meta: Meta,
506
- isEphemeral: Schema4.Boolean,
507
- events: Schema4.Array(Event)
732
+ isEphemeral: Schema6.Boolean,
733
+ events: Schema6.Array(Event)
508
734
  });
509
- var Message = MessageData.pipe(Annotation2.IconAnnotation.set({
735
+ var Message = class extends Type4.makeObject(DXN5.make("org.dxos.type.traceMessage", "0.1.0"))(MessageData.pipe(Annotation4.IconAnnotation.set({
510
736
  icon: "ph--note--regular",
511
737
  hue: "rose"
512
- }), Annotation2.HiddenAnnotation.set(true), Type2.makeObject(DXN3.make("org.dxos.type.traceMessage", "0.1.0")));
738
+ }), Annotation4.HiddenAnnotation.set(true))) {
739
+ };
513
740
  var flatten2 = (message) => {
514
741
  return message.events.map((event) => ({
515
742
  ...event,
@@ -555,7 +782,7 @@ var testTraceService = (opts = {}) => Layer3.effect(TraceService, Effect6.gen(fu
555
782
  const clock = opts.clock ?? Date.now;
556
783
  return {
557
784
  write: (event, data) => {
558
- sink.write(Obj2.make(Message, {
785
+ sink.write(Obj4.make(Message, {
559
786
  meta: opts.meta ?? {},
560
787
  isEphemeral: event.isEphemeral,
561
788
  events: [
@@ -570,57 +797,57 @@ var testTraceService = (opts = {}) => Layer3.effect(TraceService, Effect6.gen(fu
570
797
  };
571
798
  }));
572
799
  var OperationStart = EventType("operation.start", {
573
- schema: Schema4.Struct({
800
+ schema: Schema6.Struct({
574
801
  /** Operation key. */
575
- key: Schema4.String,
802
+ key: Schema6.String,
576
803
  /** Human-readable operation name. */
577
- name: Schema4.optional(Schema4.String),
804
+ name: Schema6.optional(Schema6.String),
578
805
  /** Phosphor icon identifier in `ph--<name>--<variant>` format. */
579
- icon: Schema4.optional(Schema4.String)
806
+ icon: Schema6.optional(Schema6.String)
580
807
  }),
581
808
  isEphemeral: false
582
809
  });
583
810
  var OperationEnd = EventType("operation.end", {
584
- schema: Schema4.Struct({
811
+ schema: Schema6.Struct({
585
812
  /** Operation key. */
586
- key: Schema4.String,
813
+ key: Schema6.String,
587
814
  /** Human-readable operation name. */
588
- name: Schema4.optional(Schema4.String),
815
+ name: Schema6.optional(Schema6.String),
589
816
  /** Phosphor icon identifier in `ph--<name>--<variant>` format. */
590
- icon: Schema4.optional(Schema4.String),
817
+ icon: Schema6.optional(Schema6.String),
591
818
  /** Outcome of the operation. */
592
- outcome: Schema4.Literal("success", "failure"),
819
+ outcome: Schema6.Literal("success", "failure"),
593
820
  /** Error message if the operation failed. */
594
- error: Schema4.optional(Schema4.String)
821
+ error: Schema6.optional(Schema6.String)
595
822
  }),
596
823
  isEphemeral: false
597
824
  });
598
825
  var OperationInput = EventType("operation.input", {
599
- schema: Schema4.Struct({
826
+ schema: Schema6.Struct({
600
827
  /** Operation key. */
601
- key: Schema4.String,
828
+ key: Schema6.String,
602
829
  /** Human-readable operation name. */
603
- name: Schema4.optional(Schema4.String),
830
+ name: Schema6.optional(Schema6.String),
604
831
  /** Raw operation input. Shape determined by the operation definition. */
605
- input: Schema4.Unknown
832
+ input: Schema6.Unknown
606
833
  }),
607
834
  isEphemeral: true
608
835
  });
609
836
  var OperationOutput = EventType("operation.output", {
610
- schema: Schema4.Struct({
837
+ schema: Schema6.Struct({
611
838
  /** Operation key. */
612
- key: Schema4.String,
839
+ key: Schema6.String,
613
840
  /** Human-readable operation name. */
614
- name: Schema4.optional(Schema4.String),
841
+ name: Schema6.optional(Schema6.String),
615
842
  /** Raw operation output. Shape determined by the operation definition. */
616
- output: Schema4.Unknown
843
+ output: Schema6.Unknown
617
844
  }),
618
845
  isEphemeral: true
619
846
  });
620
847
  var StatusUpdate = EventType("status.update", {
621
- schema: Schema4.Struct({
848
+ schema: Schema6.Struct({
622
849
  /** Human-readable status message. */
623
- message: Schema4.String
850
+ message: Schema6.String
624
851
  }),
625
852
  isEphemeral: true
626
853
  });
@@ -630,26 +857,50 @@ var emitStatus = (message) => write(StatusUpdate, {
630
857
 
631
858
  // src/Process.ts
632
859
  var __dxlog_file3 = "/__w/dxos/dxos/packages/core/compute/compute/src/Process.ts";
633
- var ID = Schema5.String.pipe(Schema5.brand("ProcessId"));
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
+ });
634
873
  var ProcessTypeId = "~@dxos/functions/Process";
635
874
  var isProcess = (executable) => typeof executable === "object" && executable !== null && ProcessTypeId in executable;
636
- var make5 = (opts, create) => {
875
+ var make8 = (opts, create) => {
637
876
  assertArgument2(/^[a-z0-9]([a-z0-9.\-/]*[a-z0-9])?$/i.test(opts.key), "key", "Invalid key");
638
877
  return {
639
878
  [ProcessTypeId]: {},
640
879
  ...opts,
880
+ rpcs: opts.rpcs ?? RpcGroup.make(),
641
881
  create: (ctx) => create(ctx).pipe(Effect7.map((partial) => ({
642
882
  onSpawn: () => Effect7.void,
643
883
  onInput: () => Effect7.void,
644
884
  onAlarm: () => Effect7.void,
645
885
  onChildEvent: () => Effect7.void,
646
- ...partial
886
+ ...partial,
887
+ rpcHandlers: sanitizeRpcs(opts.rpcs, partial.rpcHandlers)
647
888
  })))
648
889
  };
649
890
  };
650
- var OperationStartedKey = key(Schema5.parseJson(Schema5.Boolean), "operation/started").pipe(withDefault(() => false));
651
- var fromOperation = (op, handler) => make5({
652
- key: DXN4.getName(op.meta.key),
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),
653
904
  input: op.input,
654
905
  output: op.output,
655
906
  services: op.services
@@ -659,16 +910,16 @@ var fromOperation = (op, handler) => make5({
659
910
  return {
660
911
  onInput: (input) => Effect7.gen(function* () {
661
912
  if (!idempotent) {
662
- const started = yield* OperationStartedKey.get;
913
+ const started = yield* OperationStartedCell.get;
663
914
  if (started) {
664
915
  return yield* Effect7.die(new Error(`non-idempotent operation "${op.meta.key}" was interrupted; cannot retry safely`));
665
916
  }
666
- yield* OperationStartedKey.set(true);
917
+ yield* OperationStartedCell.set(true);
667
918
  }
668
919
  log3("operation process invoking", {
669
920
  key: op.meta.key,
670
921
  name: op.meta.name
671
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 66, S: this });
922
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 104, S: this });
672
923
  yield* write(OperationStart, {
673
924
  key: op.meta.key,
674
925
  name: op.meta.name,
@@ -720,12 +971,12 @@ var State = /* @__PURE__ */ (function(State2) {
720
971
  var ProcessMonitorService = class extends Context4.Tag("@dxos/functions/ProcessMonitorService")() {
721
972
  };
722
973
  var SpawnedEvent = EventType("process.spawned", {
723
- schema: Schema5.Void,
974
+ schema: Schema7.Void,
724
975
  isEphemeral: false
725
976
  });
726
977
  var ExitedEvent = EventType("process.exited", {
727
- schema: Schema5.Struct({
728
- outcome: Schema5.Literal("succeeded", "failed", "terminated")
978
+ schema: Schema7.Struct({
979
+ outcome: Schema7.Literal("succeeded", "failed", "terminated")
729
980
  }),
730
981
  isEphemeral: false
731
982
  });
@@ -742,10 +993,10 @@ var prettyProcessTree = (tree) => {
742
993
  roots.push(node);
743
994
  continue;
744
995
  }
745
- const key2 = String(parent);
746
- const siblings = childrenByParent.get(key2) ?? [];
996
+ const key = String(parent);
997
+ const siblings = childrenByParent.get(key) ?? [];
747
998
  siblings.push(node);
748
- childrenByParent.set(key2, siblings);
999
+ childrenByParent.set(key, siblings);
749
1000
  }
750
1001
  const byPid = (a, b) => String(a.pid).localeCompare(String(b.pid));
751
1002
  roots.sort(byPid);
@@ -788,74 +1039,33 @@ var prettyProcessTree = (tree) => {
788
1039
  return lines.join("\n");
789
1040
  };
790
1041
 
791
- // src/Routine.ts
792
- var Routine_exports = {};
793
- __export(Routine_exports, {
794
- Routine: () => Routine,
795
- make: () => make6
796
- });
797
- import * as Schema6 from "effect/Schema";
798
- import { DXN as DXN5, Annotation as Annotation3, JsonSchema, Obj as Obj3, Ref as Ref2, Type as Type3, Format } from "@dxos/echo";
799
- import { Text as Text2 } from "@dxos/schema";
800
- var Routine = Schema6.Struct({
801
- name: Schema6.optional(Schema6.String),
802
- description: Schema6.optional(Schema6.String),
803
- input: JsonSchema.JsonSchema.pipe(Annotation3.FormInputAnnotation.set(false)).annotations({
804
- description: "Input schema"
805
- }),
806
- output: JsonSchema.JsonSchema.pipe(Annotation3.FormInputAnnotation.set(false)).annotations({
807
- description: "Output schema"
808
- }),
809
- instructions: Ref2.Ref(Text2.Text).pipe(Annotation3.FormInputAnnotation.set(false), Format.FormatAnnotation.set(Format.TypeFormat.Markdown), Schema6.annotations({
810
- title: "Instructions",
811
- description: "Agent instructions"
812
- })),
813
- blueprints: Schema6.Array(Ref2.Ref(Blueprint)),
814
- context: Schema6.Array(Schema6.Any).pipe(Annotation3.FormInputAnnotation.set(false))
815
- }).pipe(Annotation3.LabelAnnotation.set([
816
- "name"
817
- ]), Annotation3.IconAnnotation.set({
818
- icon: "ph--scroll--regular",
819
- hue: "sky"
820
- }), Type3.makeObject(DXN5.make("org.dxos.type.routine", "0.1.0")));
821
- var make6 = ({ name, description, input, output, instructions, blueprints = [], context = [] }) => Obj3.make(Routine, {
822
- name,
823
- description,
824
- input: JsonSchema.toJsonSchema(input ?? Schema6.Void),
825
- output: JsonSchema.toJsonSchema(output ?? Schema6.Void),
826
- instructions: Ref2.make(Text2.make({
827
- content: instructions ?? ""
828
- })),
829
- blueprints,
830
- context
831
- });
832
-
833
1042
  // src/Script.ts
834
1043
  var Script_exports = {};
835
1044
  __export(Script_exports, {
836
1045
  Script: () => Script,
837
- make: () => make7
1046
+ make: () => make9
838
1047
  });
839
- import * as Schema7 from "effect/Schema";
840
- import { DXN as DXN6, Annotation as Annotation4, Obj as Obj4, Ref as Ref3, Type as Type4 } from "@dxos/echo";
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";
841
1050
  import { FormInputAnnotation } from "@dxos/echo/Annotation";
842
1051
  import { Text as Text3 } from "@dxos/schema";
843
- var Script = Schema7.Struct({
844
- name: Schema7.String.pipe(Schema7.optional),
845
- description: Schema7.String.pipe(Schema7.optional),
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),
846
1055
  // TODO(burdon): Change to hash of deployed content.
847
1056
  // Whether source has changed since last deploy.
848
- changed: Schema7.Boolean.pipe(FormInputAnnotation.set(false), Schema7.optional),
849
- source: Ref3.Ref(Text3.Text).pipe(FormInputAnnotation.set(false))
850
- }).pipe(Annotation4.LabelAnnotation.set([
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([
851
1060
  "name"
852
- ]), Annotation4.IconAnnotation.set({
1061
+ ]), Annotation6.IconAnnotation.set({
853
1062
  icon: "ph--code--regular",
854
1063
  hue: "sky"
855
- }), Type4.makeObject(DXN6.make("org.dxos.type.script", "0.1.0")));
856
- var make7 = ({ source = "", ...props } = {}) => Obj4.make(Script, {
1064
+ }))) {
1065
+ };
1066
+ var make9 = ({ source = "", ...props } = {}) => Obj5.make(Script, {
857
1067
  ...props,
858
- source: Ref3.make(Text3.make({
1068
+ source: Ref6.make(Text3.make({
859
1069
  content: source
860
1070
  }))
861
1071
  });
@@ -865,11 +1075,11 @@ var ServiceResolver_exports = {};
865
1075
  __export(ServiceResolver_exports, {
866
1076
  ServiceResolver: () => ServiceResolver,
867
1077
  compose: () => compose,
868
- empty: () => empty2,
1078
+ empty: () => empty3,
869
1079
  fromContext: () => fromContext,
870
1080
  fromRequirements: () => fromRequirements,
871
1081
  layerRequirements: () => layerRequirements,
872
- make: () => make9,
1082
+ make: () => make11,
873
1083
  provide: () => provide,
874
1084
  resolve: () => resolve3,
875
1085
  resolveAll: () => resolveAll,
@@ -888,7 +1098,7 @@ var resolveAll = (tags, context) => Effect8.gen(function* () {
888
1098
  return Context5.mergeAll(...services);
889
1099
  });
890
1100
  var succeed2 = (tag, getService) => {
891
- return make9((tag1, context) => {
1101
+ return make11((tag1, context) => {
892
1102
  if (tag1.key !== tag.key) {
893
1103
  return Effect8.fail(new ServiceNotAvailableError(`Service not available: ${String(tag.key ?? tag)}`));
894
1104
  }
@@ -896,11 +1106,11 @@ var succeed2 = (tag, getService) => {
896
1106
  return service;
897
1107
  });
898
1108
  };
899
- var make9 = (resolveFn) => ({
1109
+ var make11 = (resolveFn) => ({
900
1110
  [ServiceResolverTypeId]: ServiceResolverTypeId,
901
1111
  resolve: resolveFn
902
1112
  });
903
- var fromContext = (ctx) => make9((tag, context) => Effect8.gen(function* () {
1113
+ var fromContext = (ctx) => make11((tag, context) => Effect8.gen(function* () {
904
1114
  const service = Context5.getOption(ctx, tag);
905
1115
  if (Option.isNone(service)) {
906
1116
  return yield* Effect8.fail(new ServiceNotAvailableError(String(tag.key ?? tag)));
@@ -909,7 +1119,7 @@ var fromContext = (ctx) => make9((tag, context) => Effect8.gen(function* () {
909
1119
  }));
910
1120
  var fromRequirements = (...tags) => Effect8.contextWith((parentCtx) => {
911
1121
  const available = new Set(tags.map((tag) => tag.key));
912
- return make9((tag, context) => Effect8.gen(function* () {
1122
+ return make11((tag, context) => Effect8.gen(function* () {
913
1123
  let result = Context5.empty();
914
1124
  if (!available.has(tag.key)) {
915
1125
  return yield* Effect8.fail(new ServiceNotAvailableError(String(tag.key ?? tag)));
@@ -923,7 +1133,7 @@ var fromRequirements = (...tags) => Effect8.contextWith((parentCtx) => {
923
1133
  });
924
1134
  var layerRequirements = (...tags) => Layer4.effect(ServiceResolver, fromRequirements(...tags));
925
1135
  var provide = (context, ...tags) => Layer4.scopedContext(resolveAll(tags, context));
926
- var compose = (...resolvers) => make9((tag, context) => Effect8.gen(function* () {
1136
+ var compose = (...resolvers) => make11((tag, context) => Effect8.gen(function* () {
927
1137
  for (const resolver of resolvers) {
928
1138
  const single = yield* resolver.resolve(tag, context).pipe(Effect8.either);
929
1139
  if (Either.isRight(single)) {
@@ -932,173 +1142,10 @@ var compose = (...resolvers) => make9((tag, context) => Effect8.gen(function* ()
932
1142
  }
933
1143
  return yield* Effect8.fail(new ServiceNotAvailableError(String(tag.key ?? tag)));
934
1144
  }));
935
- var empty2 = make9((tag, context) => {
1145
+ var empty3 = make11((tag, context) => {
936
1146
  return Effect8.fail(new ServiceNotAvailableError(String(tag.key ?? tag)));
937
1147
  });
938
1148
 
939
- // src/Trigger.ts
940
- var Trigger_exports = {};
941
- __export(Trigger_exports, {
942
- EmailSpec: () => EmailSpec,
943
- FeedSpec: () => FeedSpec,
944
- Kinds: () => Kinds,
945
- Spec: () => Spec,
946
- SubscriptionSpec: () => SubscriptionSpec,
947
- TimerSpec: () => TimerSpec,
948
- Trigger: () => Trigger,
949
- WebhookSpec: () => WebhookSpec,
950
- make: () => make10,
951
- specEmail: () => specEmail,
952
- specFeed: () => specFeed,
953
- specSubscription: () => specSubscription,
954
- specTimer: () => specTimer,
955
- specWebhook: () => specWebhook
956
- });
957
- import * as Schema8 from "effect/Schema";
958
- import * as SchemaAST from "effect/SchemaAST";
959
- import { DXN as DXN7, Annotation as Annotation5, Feed, Obj as Obj5, QueryAST, Ref as Ref4, Type as Type5 } from "@dxos/echo";
960
- import { HiddenAnnotation } from "@dxos/echo/Annotation";
961
- import { OptionsAnnotationId } from "@dxos/echo/Format";
962
- var Kinds = [
963
- "email",
964
- "feed",
965
- "subscription",
966
- "timer",
967
- "webhook"
968
- ];
969
- var kindLiteralAnnotations = {
970
- title: "Kind"
971
- };
972
- var EmailSpec = Schema8.Struct({
973
- kind: Schema8.Literal("email").annotations(kindLiteralAnnotations)
974
- });
975
- var specEmail = () => ({
976
- kind: "email"
977
- });
978
- var FeedSpec = Schema8.Struct({
979
- kind: Schema8.Literal("feed").annotations(kindLiteralAnnotations),
980
- feed: Schema8.optional(Ref4.Ref(Feed.Feed).annotations({
981
- title: "Feed"
982
- }))
983
- });
984
- var specFeed = (feed) => ({
985
- kind: "feed",
986
- feed: Ref4.make(feed)
987
- });
988
- var SubscriptionSpec = Schema8.Struct({
989
- kind: Schema8.Literal("subscription").annotations(kindLiteralAnnotations),
990
- query: Schema8.Struct({
991
- raw: Schema8.optional(Schema8.String.annotations({
992
- title: "Query"
993
- })),
994
- ast: QueryAST.Query
995
- }),
996
- options: Schema8.optional(Schema8.Struct({
997
- // Watch changes to object (not just creation).
998
- deep: Schema8.optional(Schema8.Boolean.annotations({
999
- title: "Nested"
1000
- })),
1001
- // Debounce changes (delay in ms).
1002
- delay: Schema8.optional(Schema8.Number.annotations({
1003
- title: "Delay"
1004
- }))
1005
- }).annotations({
1006
- title: "Options"
1007
- }))
1008
- });
1009
- var specSubscription = (query, options) => ({
1010
- kind: "subscription",
1011
- query: {
1012
- ast: query.ast
1013
- },
1014
- options: options ? {
1015
- deep: options.deep,
1016
- delay: options.delay
1017
- } : void 0
1018
- });
1019
- var TimerSpec = Schema8.Struct({
1020
- kind: Schema8.Literal("timer").annotations(kindLiteralAnnotations),
1021
- cron: Schema8.String.annotations({
1022
- title: "Cron",
1023
- [SchemaAST.ExamplesAnnotationId]: [
1024
- "0 0 * * *"
1025
- ]
1026
- })
1027
- });
1028
- var specTimer = (cron) => ({
1029
- kind: "timer",
1030
- cron
1031
- });
1032
- var WebhookSpec = Schema8.Struct({
1033
- kind: Schema8.Literal("webhook").annotations(kindLiteralAnnotations),
1034
- method: Schema8.optional(Schema8.String.annotations({
1035
- title: "Method",
1036
- [OptionsAnnotationId]: [
1037
- "GET",
1038
- "POST"
1039
- ]
1040
- })),
1041
- port: Schema8.optional(Schema8.Number.annotations({
1042
- title: "Port"
1043
- }))
1044
- });
1045
- var specWebhook = (opts) => ({
1046
- kind: "webhook",
1047
- method: opts?.method,
1048
- port: opts?.port
1049
- });
1050
- var Spec = Schema8.Union(EmailSpec, FeedSpec, SubscriptionSpec, TimerSpec, WebhookSpec).annotations({
1051
- title: "Trigger"
1052
- });
1053
- var TriggerSchema = Schema8.Struct({
1054
- /**
1055
- * Function or workflow to invoke.
1056
- */
1057
- // TODO(dmaretskyi): Can be a Ref(FunctionType) or Ref(ComputeGraphType).
1058
- function: Schema8.optional(Ref4.Ref(Obj5.Unknown).annotations({
1059
- title: "Function"
1060
- })),
1061
- /**
1062
- * Only used for workflowSchema.
1063
- * Specifies the input node in the circuit.
1064
- * @deprecated Remove and enforce a single input node in all compute graphSchema.
1065
- */
1066
- inputNodeId: Schema8.optional(Schema8.String.annotations({
1067
- title: "Input Node ID"
1068
- })),
1069
- // TODO(burdon): NO BOOLEAN PROPERTIES (enabld/disabled/paused, etc.)
1070
- // Need lint rule; or agent rule to require PR review for "boolean" key word.
1071
- enabled: Schema8.optional(Schema8.Boolean.annotations({
1072
- title: "Enabled"
1073
- })),
1074
- spec: Schema8.optional(Spec),
1075
- concurrency: Schema8.optional(Schema8.Number.annotations({
1076
- title: "Concurrency",
1077
- default: 1,
1078
- description: "Maximum number of concurrent invocations of the trigger. For Feed triggers, this will process Feed items in parallel."
1079
- })),
1080
- /**
1081
- * Passed as the input data to the function.
1082
- * Must match the function's input schema.
1083
- *
1084
- * @example
1085
- * {
1086
- * item: '{{event.item}}',
1087
- * instructions: 'Summarize and perform entity-extraction'
1088
- * mailbox: { '/': 'echo://AAA/ZZZ' }
1089
- * }
1090
- */
1091
- input: Schema8.optional(Schema8.Record({
1092
- key: Schema8.String,
1093
- value: Schema8.Any
1094
- }))
1095
- }).pipe(Annotation5.IconAnnotation.set({
1096
- icon: "ph--lightning--regular",
1097
- hue: "yellow"
1098
- }), HiddenAnnotation.set(true), Type5.makeObject(DXN7.make("org.dxos.type.trigger", "0.1.0")));
1099
- var Trigger = TriggerSchema;
1100
- var make10 = (props) => Obj5.make(Trigger, props);
1101
-
1102
1149
  // src/TriggerEvent.ts
1103
1150
  var TriggerEvent_exports = {};
1104
1151
  __export(TriggerEvent_exports, {
@@ -1110,7 +1157,7 @@ __export(TriggerEvent_exports, {
1110
1157
  WebhookEvent: () => WebhookEvent
1111
1158
  });
1112
1159
  import * as Schema9 from "effect/Schema";
1113
- import { Feed as Feed2, Obj as Obj6, Ref as Ref5 } from "@dxos/echo";
1160
+ import { Feed as Feed2, Obj as Obj6, Ref as Ref7 } from "@dxos/echo";
1114
1161
  var EmailEvent = Schema9.Struct({
1115
1162
  from: Schema9.String,
1116
1163
  to: Schema9.String,
@@ -1119,7 +1166,7 @@ var EmailEvent = Schema9.Struct({
1119
1166
  body: Schema9.String
1120
1167
  });
1121
1168
  var FeedEvent = Schema9.Struct({
1122
- feed: Ref5.Ref(Feed2.Feed),
1169
+ feed: Ref7.Ref(Feed2.Feed),
1123
1170
  item: Schema9.Any,
1124
1171
  cursor: Schema9.String
1125
1172
  });
@@ -1132,7 +1179,7 @@ var SubscriptionEvent = Schema9.Struct({
1132
1179
  /**
1133
1180
  * Reference to the object that was changed or created.
1134
1181
  */
1135
- subject: Ref5.Ref(Obj6.Unknown),
1182
+ subject: Ref7.Ref(Obj6.Unknown),
1136
1183
  /**
1137
1184
  * @deprecated
1138
1185
  */
@@ -1152,13 +1199,14 @@ var WebhookEvent = Schema9.Struct({
1152
1199
  });
1153
1200
  var TriggerEvent = Schema9.Union(EmailEvent, FeedEvent, SubscriptionEvent, TimerEvent, WebhookEvent);
1154
1201
  export {
1155
- Blueprint_exports as Blueprint,
1202
+ AgentService_exports as AgentService,
1156
1203
  Credential_exports as Credential,
1157
1204
  FunctionError,
1158
1205
  FunctionNotFoundError,
1159
1206
  FunctionsAiMemoizationMissError,
1160
1207
  FunctionsAiUpstreamError,
1161
1208
  Header_exports as Header,
1209
+ Instructions_exports as Instructions,
1162
1210
  InvalidOperationInputError,
1163
1211
  InvalidOperationOutputError,
1164
1212
  InvokerNotInitializedError,
@@ -1169,10 +1217,11 @@ export {
1169
1217
  OperationHandlerSet_exports as OperationHandlerSet,
1170
1218
  OperationRegistry_exports as OperationRegistry,
1171
1219
  Process_exports as Process,
1172
- Routine_exports as Routine,
1220
+ Runnable_exports as Runnable,
1173
1221
  Script_exports as Script,
1174
1222
  ServiceNotAvailableError,
1175
1223
  ServiceResolver_exports as ServiceResolver,
1224
+ Skill_exports as Skill,
1176
1225
  StorageService_exports as StorageService,
1177
1226
  Template_exports as Template,
1178
1227
  Trace_exports as Trace,