@dxos/compute 0.8.4-main.03d5cd7b56 → 0.8.4-main.05e74ebcff

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 (63) hide show
  1. package/LICENSE +102 -5
  2. package/dist/lib/neutral/{chunk-EG7VLX2F.mjs → chunk-AKVCVI6N.mjs} +3 -3
  3. package/dist/lib/neutral/{chunk-JTZYM2QW.mjs → chunk-LF2ANNYW.mjs} +29 -2
  4. package/dist/lib/neutral/chunk-LF2ANNYW.mjs.map +7 -0
  5. package/dist/lib/neutral/{chunk-OA7JMLJK.mjs → chunk-LRCABAWU.mjs} +3 -3
  6. package/dist/lib/neutral/{chunk-YEDUHFRC.mjs → chunk-RCLYF66G.mjs} +3 -3
  7. package/dist/lib/neutral/{chunk-VIRNEVFD.mjs → chunk-SEBWOTOU.mjs} +58 -22
  8. package/dist/lib/neutral/chunk-SEBWOTOU.mjs.map +7 -0
  9. package/dist/lib/neutral/{chunk-CXDV2FPU.mjs → chunk-VSICPGGY.mjs} +2 -2
  10. package/dist/lib/neutral/fib-ZSJYREBW.mjs +10 -0
  11. package/dist/lib/neutral/index.mjs +243 -91
  12. package/dist/lib/neutral/index.mjs.map +4 -4
  13. package/dist/lib/neutral/meta.json +1 -1
  14. package/dist/lib/neutral/reply-YH3BVOUT.mjs +10 -0
  15. package/dist/lib/neutral/sleep-TSPIQ5EY.mjs +10 -0
  16. package/dist/lib/neutral/testing/index.mjs +7 -7
  17. package/dist/types/src/Blueprint.d.ts +57 -5
  18. package/dist/types/src/Blueprint.d.ts.map +1 -1
  19. package/dist/types/src/LayerSpec.d.ts +56 -0
  20. package/dist/types/src/LayerSpec.d.ts.map +1 -0
  21. package/dist/types/src/Operation.d.ts +35 -4
  22. package/dist/types/src/Operation.d.ts.map +1 -1
  23. package/dist/types/src/OperationHandlerSet.d.ts +7 -0
  24. package/dist/types/src/OperationHandlerSet.d.ts.map +1 -1
  25. package/dist/types/src/OperationHandlerSet.test.d.ts +2 -0
  26. package/dist/types/src/OperationHandlerSet.test.d.ts.map +1 -0
  27. package/dist/types/src/OperationRegistry.d.ts.map +1 -1
  28. package/dist/types/src/Process.d.ts.map +1 -1
  29. package/dist/types/src/Routine.d.ts +5 -5
  30. package/dist/types/src/Routine.d.ts.map +1 -1
  31. package/dist/types/src/ServiceResolver.d.ts +15 -0
  32. package/dist/types/src/ServiceResolver.d.ts.map +1 -1
  33. package/dist/types/src/Trace.d.ts +94 -0
  34. package/dist/types/src/Trace.d.ts.map +1 -1
  35. package/dist/types/src/Trigger.d.ts +1 -1
  36. package/dist/types/src/index.d.ts +1 -0
  37. package/dist/types/src/index.d.ts.map +1 -1
  38. package/dist/types/tsconfig.tsbuildinfo +1 -1
  39. package/package.json +13 -12
  40. package/src/Blueprint.ts +116 -20
  41. package/src/LayerSpec.ts +91 -0
  42. package/src/Operation.ts +83 -23
  43. package/src/OperationHandlerSet.test.ts +92 -0
  44. package/src/OperationHandlerSet.ts +40 -0
  45. package/src/OperationRegistry.ts +2 -2
  46. package/src/Process.ts +14 -0
  47. package/src/Routine.ts +31 -44
  48. package/src/ServiceResolver.ts +20 -0
  49. package/src/Trace.ts +141 -4
  50. package/src/Trigger.ts +2 -2
  51. package/src/index.ts +1 -0
  52. package/dist/lib/neutral/chunk-JTZYM2QW.mjs.map +0 -7
  53. package/dist/lib/neutral/chunk-VIRNEVFD.mjs.map +0 -7
  54. package/dist/lib/neutral/fib-WSN4EY7R.mjs +0 -10
  55. package/dist/lib/neutral/reply-XRLTFNDF.mjs +0 -10
  56. package/dist/lib/neutral/sleep-7O76LQCA.mjs +0 -10
  57. /package/dist/lib/neutral/{chunk-EG7VLX2F.mjs.map → chunk-AKVCVI6N.mjs.map} +0 -0
  58. /package/dist/lib/neutral/{chunk-OA7JMLJK.mjs.map → chunk-LRCABAWU.mjs.map} +0 -0
  59. /package/dist/lib/neutral/{chunk-YEDUHFRC.mjs.map → chunk-RCLYF66G.mjs.map} +0 -0
  60. /package/dist/lib/neutral/{chunk-CXDV2FPU.mjs.map → chunk-VSICPGGY.mjs.map} +0 -0
  61. /package/dist/lib/neutral/{fib-WSN4EY7R.mjs.map → fib-ZSJYREBW.mjs.map} +0 -0
  62. /package/dist/lib/neutral/{reply-XRLTFNDF.mjs.map → reply-YH3BVOUT.mjs.map} +0 -0
  63. /package/dist/lib/neutral/{sleep-7O76LQCA.mjs.map → sleep-TSPIQ5EY.mjs.map} +0 -0
@@ -16,13 +16,13 @@ import {
16
16
  TriggerStateNotFoundError,
17
17
  getHandler,
18
18
  getHandlerByKey
19
- } from "./chunk-JTZYM2QW.mjs";
19
+ } from "./chunk-LF2ANNYW.mjs";
20
20
  import {
21
21
  Operation_exports,
22
22
  PersistentOperation,
23
23
  deserialize,
24
24
  invoke
25
- } from "./chunk-VIRNEVFD.mjs";
25
+ } from "./chunk-SEBWOTOU.mjs";
26
26
  import {
27
27
  __export
28
28
  } from "./chunk-J5LGTIGS.mjs";
@@ -31,19 +31,24 @@ import {
31
31
  var Blueprint_exports = {};
32
32
  __export(Blueprint_exports, {
33
33
  Blueprint: () => Blueprint,
34
+ Blueprint_v0_1_0: () => Blueprint_v0_1_0,
34
35
  NotFoundError: () => NotFoundError,
35
36
  Registry: () => Registry,
36
37
  RegistryService: () => RegistryService,
38
+ getKey: () => getKey,
39
+ getVersion: () => getVersion,
37
40
  make: () => make2,
41
+ migrations: () => migrations,
38
42
  resolve: () => resolve2,
39
43
  toolDefinitions: () => toolDefinitions,
40
44
  upsert: () => upsert
41
45
  });
42
46
  import * as Context2 from "effect/Context";
43
47
  import * as Effect3 from "effect/Effect";
48
+ import * as Layer2 from "effect/Layer";
44
49
  import * as Schema3 from "effect/Schema";
45
50
  import { ToolId } from "@dxos/ai";
46
- import { Annotation, Database as Database3, Filter, Obj, Type } from "@dxos/echo";
51
+ import { Annotation, Database as Database3, Filter as Filter2, Migration, Obj, Type } from "@dxos/echo";
47
52
  import { BaseError } from "@dxos/errors";
48
53
  import { log as log2 } from "@dxos/log";
49
54
 
@@ -106,7 +111,7 @@ __export(OperationRegistry_exports, {
106
111
  import * as Context from "effect/Context";
107
112
  import * as Effect from "effect/Effect";
108
113
  import * as Layer from "effect/Layer";
109
- import { Database, Query } from "@dxos/echo";
114
+ import { Database, Filter, Query } from "@dxos/echo";
110
115
  var Service = class extends Context.Tag("@dxos/operation/OperationRegistry")() {
111
116
  };
112
117
  var resolve = Effect.serviceFunctionEffect(Service, (service) => service.resolve);
@@ -114,9 +119,7 @@ var layer = Layer.effect(Service, Effect.gen(function* () {
114
119
  const database = yield* Database.Service;
115
120
  const handlerSet = yield* OperationHandlerProvider;
116
121
  return {
117
- resolve: (key) => Database.runQueryFirst(Query.type(PersistentOperation, {
118
- key
119
- })).pipe(Effect.flatten, Effect.map(deserialize), Effect.catchTag("NoSuchElementException", () => getHandlerByKey(handlerSet, key)), Effect.option).pipe(Effect.provideService(Database.Service, database))
122
+ resolve: (key) => Database.runQueryFirst(Query.select(Filter.and(Filter.type(PersistentOperation), Filter.key(key)))).pipe(Effect.flatten, Effect.map(deserialize), Effect.catchTag("NoSuchElementException", () => getHandlerByKey(handlerSet, key)), Effect.option).pipe(Effect.provideService(Database.Service, database))
120
123
  };
121
124
  }));
122
125
 
@@ -191,14 +194,6 @@ var processTemplate = (template) => Effect2.gen(function* () {
191
194
  // src/Blueprint.ts
192
195
  var __dxlog_file2 = "/__w/dxos/dxos/packages/core/compute/compute/src/Blueprint.ts";
193
196
  var Blueprint = Schema3.Struct({
194
- /**
195
- * Global registry ID.
196
- * NOTE: The `key` property refers to the original registry entry.
197
- */
198
- // TODO(burdon): Create Format type for DXN-like ids, such as this and schema type.
199
- key: Schema3.String.annotations({
200
- description: "Unique registration key for the blueprint"
201
- }),
202
197
  /**
203
198
  * Human-readable name of the blueprint.
204
199
  */
@@ -236,18 +231,30 @@ var Blueprint = Schema3.Struct({
236
231
  mcpServers: Schema3.optional(Schema3.Array(McpServer))
237
232
  }).pipe(Type.object({
238
233
  typename: "org.dxos.type.blueprint",
239
- version: "0.1.0"
234
+ version: "0.2.0"
240
235
  }), Annotation.LabelAnnotation.set([
241
236
  "name"
242
237
  ]), Annotation.IconAnnotation.set({
243
238
  icon: "ph--blueprint--regular",
244
239
  hue: "sky"
245
240
  }));
246
- var make2 = ({ tools = [], instructions = make(), ...props }) => Obj.make(Blueprint, {
241
+ var make2 = ({ key, version, tools = [], instructions = make(), ...props }) => Obj.make(Blueprint, {
242
+ [Obj.Meta]: {
243
+ key,
244
+ version
245
+ },
247
246
  tools,
248
247
  instructions,
249
248
  ...props
250
249
  });
250
+ var getKey = (blueprint) => {
251
+ const key = Obj.getMeta(blueprint).key;
252
+ if (key === void 0) {
253
+ throw new Error("Blueprint is missing the meta key.");
254
+ }
255
+ return key;
256
+ };
257
+ var getVersion = (blueprint) => Obj.getMeta(blueprint).version;
251
258
  var toolDefinitions = ({ tools = [], operations = [] }) => [
252
259
  ...operations.map((op) => ToolId.make(op.meta.key)),
253
260
  ...tools.map((tool) => ToolId.make(tool))
@@ -257,12 +264,13 @@ var Registry = class {
257
264
  constructor(blueprints) {
258
265
  const seen = /* @__PURE__ */ new Set();
259
266
  blueprints.forEach((blueprint) => {
260
- if (seen.has(blueprint.key)) {
267
+ const key = getKey(blueprint);
268
+ if (seen.has(key)) {
261
269
  log2.warn("duplicate blueprint", {
262
- key: blueprint.key
263
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 89, S: this });
270
+ key
271
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 104, S: this });
264
272
  } else {
265
- seen.add(blueprint.key);
273
+ seen.add(key);
266
274
  this._blueprints.push(blueprint);
267
275
  }
268
276
  });
@@ -272,16 +280,20 @@ var Registry = class {
272
280
  return this._blueprints;
273
281
  }
274
282
  getByKey(key) {
275
- return this._blueprints.find((blueprint) => blueprint.key === key);
283
+ return this._blueprints.find((blueprint) => Obj.getMeta(blueprint).key === key);
276
284
  }
277
285
  query() {
278
286
  return this._blueprints;
279
287
  }
280
288
  updateBlueprints() {
281
289
  return Effect3.gen(this, function* () {
282
- const blueprints = yield* Database3.runQuery(Filter.type(Blueprint));
290
+ const blueprints = yield* Database3.runQuery(Filter2.type(Blueprint));
283
291
  for (const blueprint of blueprints) {
284
- const registryBlueprint = this.getByKey(blueprint.key);
292
+ const blueprintKey = Obj.getMeta(blueprint).key;
293
+ if (!blueprintKey) {
294
+ continue;
295
+ }
296
+ const registryBlueprint = this.getByKey(blueprintKey);
285
297
  if (!registryBlueprint) {
286
298
  continue;
287
299
  }
@@ -295,7 +307,21 @@ var Registry = class {
295
307
  }).pipe(Effect3.orDie);
296
308
  }
297
309
  };
298
- var RegistryService = class extends Context2.Tag("@dxos/blueprints/RegistryService")() {
310
+ var RegistryService = class _RegistryService extends Context2.Tag("@dxos/blueprints/RegistryService")() {
311
+ static notAvailable = Layer2.succeed(_RegistryService, {
312
+ get blueprints() {
313
+ throw new Error("Blueprint registry not available");
314
+ },
315
+ getByKey(_key) {
316
+ throw new Error("Blueprint registry not available");
317
+ },
318
+ query() {
319
+ throw new Error("Blueprint registry not available");
320
+ },
321
+ updateBlueprints() {
322
+ throw new Error("Blueprint registry not available");
323
+ }
324
+ });
299
325
  };
300
326
  var resolve2 = (key) => Effect3.gen(function* () {
301
327
  const registry = yield* RegistryService;
@@ -310,9 +336,7 @@ var resolve2 = (key) => Effect3.gen(function* () {
310
336
  return blueprint;
311
337
  });
312
338
  var upsert = (key) => Effect3.gen(function* () {
313
- const local = yield* Database3.runQuery(Filter.type(Blueprint, {
314
- key
315
- }));
339
+ const local = yield* Database3.runQuery(Filter2.and(Filter2.type(Blueprint), Filter2.key(key)));
316
340
  if (local.length > 0) {
317
341
  return local[0];
318
342
  }
@@ -322,6 +346,45 @@ var upsert = (key) => Effect3.gen(function* () {
322
346
  });
323
347
  var NotFoundError = class extends BaseError.extend("BlueprintNotFound", "Blueprint not found") {
324
348
  };
349
+ var Blueprint_v0_1_0 = Schema3.Struct({
350
+ /**
351
+ * Global registry ID.
352
+ * NOTE: The `key` property refers to the original registry entry.
353
+ */
354
+ key: Schema3.String.annotations({
355
+ description: "Unique registration key for the blueprint"
356
+ }),
357
+ name: Schema3.String.annotations({
358
+ description: "Human-readable name of the blueprint"
359
+ }),
360
+ description: Schema3.optional(Schema3.String),
361
+ instructions: Template,
362
+ tools: Schema3.Array(ToolId),
363
+ agentCanEnable: Schema3.optional(Schema3.Boolean),
364
+ mcpServers: Schema3.optional(Schema3.Array(McpServer))
365
+ }).pipe(Type.object({
366
+ typename: "org.dxos.type.blueprint",
367
+ version: "0.1.0"
368
+ }));
369
+ var _migration = Migration.define({
370
+ from: Blueprint_v0_1_0,
371
+ to: Blueprint,
372
+ transform: async (from) => ({
373
+ [Obj.Meta]: {
374
+ key: from.key,
375
+ version: "0.1.0"
376
+ },
377
+ name: from.name,
378
+ description: from.description,
379
+ instructions: from.instructions,
380
+ tools: from.tools,
381
+ agentCanEnable: from.agentCanEnable,
382
+ mcpServers: from.mcpServers
383
+ })
384
+ });
385
+ var migrations = [
386
+ _migration
387
+ ];
325
388
 
326
389
  // src/Credential.ts
327
390
  var Credential_exports = {};
@@ -345,6 +408,23 @@ var CredentialsService = class _CredentialsService extends Context3.Tag("@dxos/f
345
408
  });
346
409
  };
347
410
 
411
+ // src/LayerSpec.ts
412
+ var LayerSpec_exports = {};
413
+ __export(LayerSpec_exports, {
414
+ TypeId: () => TypeId,
415
+ make: () => make4
416
+ });
417
+ var TypeId = "~@dxos/functions/LayerSpec";
418
+ var make4 = (opts, make11) => {
419
+ return {
420
+ [TypeId]: TypeId,
421
+ affinity: opts.affinity,
422
+ requires: opts.requires,
423
+ provides: opts.provides,
424
+ make: make11
425
+ };
426
+ };
427
+
348
428
  // src/Process.ts
349
429
  var Process_exports = {};
350
430
  __export(Process_exports, {
@@ -356,7 +436,7 @@ __export(Process_exports, {
356
436
  State: () => State,
357
437
  fromOperation: () => fromOperation,
358
438
  isProcess: () => isProcess,
359
- make: () => make4,
439
+ make: () => make5,
360
440
  prettyProcessTree: () => prettyProcessTree
361
441
  });
362
442
  import * as Context5 from "effect/Context";
@@ -368,20 +448,28 @@ import { log as log4 } from "@dxos/log";
368
448
  // src/Trace.ts
369
449
  var Trace_exports = {};
370
450
  __export(Trace_exports, {
451
+ CommonRuntimeName: () => CommonRuntimeName,
371
452
  Event: () => Event,
372
453
  EventType: () => EventType,
373
454
  Message: () => Message,
374
455
  MessageData: () => MessageData,
375
456
  Meta: () => Meta,
376
457
  OperationEnd: () => OperationEnd,
458
+ OperationInput: () => OperationInput,
459
+ OperationOutput: () => OperationOutput,
377
460
  OperationStart: () => OperationStart,
461
+ RuntimeName: () => RuntimeName,
378
462
  StatusUpdate: () => StatusUpdate,
379
463
  TraceService: () => TraceService,
380
464
  TraceSink: () => TraceSink,
381
465
  emitStatus: () => emitStatus,
466
+ flatten: () => flatten3,
467
+ isEdgeRuntime: () => isEdgeRuntime,
382
468
  isOfType: () => isOfType,
383
469
  layerConsole: () => layerConsole,
384
470
  layerNoop: () => layerNoop,
471
+ mergeSinks: () => mergeSinks,
472
+ noopSink: () => noopSink,
385
473
  noopWriter: () => noopWriter,
386
474
  testTraceService: () => testTraceService,
387
475
  write: () => write,
@@ -389,7 +477,7 @@ __export(Trace_exports, {
389
477
  });
390
478
  import * as Context4 from "effect/Context";
391
479
  import * as Effect5 from "effect/Effect";
392
- import * as Layer2 from "effect/Layer";
480
+ import * as Layer3 from "effect/Layer";
393
481
  import * as Schema4 from "effect/Schema";
394
482
  import { Annotation as Annotation2, Obj as Obj2, Type as Type2 } from "@dxos/echo";
395
483
  import { log as log3 } from "@dxos/log";
@@ -421,11 +509,26 @@ var Event = Schema4.Struct({
421
509
  var isOfType = (eventType, event) => {
422
510
  return event.type === eventType.key;
423
511
  };
512
+ var RuntimeName = Schema4.String.pipe(Schema4.brand("@dxos/compute/Trace/RuntimeName"));
513
+ var CommonRuntimeName = {
514
+ /**
515
+ * Web app / CLI / Desktop app / Mobile app.
516
+ */
517
+ local: RuntimeName.make("local"),
518
+ edgeIntrinsic: RuntimeName.make("edge-intrinsic"),
519
+ edgeWorkerLoader: RuntimeName.make("edge-worker-loader"),
520
+ edgeWorkerForPlatforms: RuntimeName.make("edge-worker-for-platforms")
521
+ };
424
522
  var Meta = Schema4.Struct({
425
523
  pid: Schema4.optional(Schema4.String),
426
524
  parentPid: Schema4.optional(Schema4.String),
427
525
  processName: Schema4.optional(Schema4.String),
428
526
  /**
527
+ * Space the message was produced in.
528
+ * Stored as a string to avoid circular dependency on `@dxos/keys`.
529
+ */
530
+ space: Schema4.optional(Schema4.String),
531
+ /**
429
532
  * ID of the conversation feed object if present.
430
533
  */
431
534
  conversationId: Schema4.optional(Obj2.ID),
@@ -436,8 +539,13 @@ var Meta = Schema4.Struct({
436
539
  /**
437
540
  * ID of the tool call that created the current process.
438
541
  */
439
- toolCallId: Schema4.optional(Schema4.String)
542
+ toolCallId: Schema4.optional(Schema4.String),
543
+ /**
544
+ * Extensible name informing which runtime executed the code that produced the event.
545
+ */
546
+ runtimeName: Schema4.optional(RuntimeName)
440
547
  });
548
+ var isEdgeRuntime = (name) => name === CommonRuntimeName.edgeIntrinsic || name === CommonRuntimeName.edgeWorkerLoader || name === CommonRuntimeName.edgeWorkerForPlatforms;
441
549
  var MessageData = Schema4.Struct({
442
550
  meta: Meta,
443
551
  isEphemeral: Schema4.Boolean,
@@ -450,24 +558,49 @@ var Message = MessageData.pipe(Type2.object({
450
558
  icon: "ph--note--regular",
451
559
  hue: "rose"
452
560
  }));
561
+ var flatten3 = (message) => {
562
+ return message.events.map((event) => ({
563
+ ...event,
564
+ meta: message.meta,
565
+ isEphemeral: message.isEphemeral
566
+ }));
567
+ };
453
568
  var TraceSink = class extends Context4.Tag("@dxos/functions/TraceSink")() {
454
569
  };
455
570
  var noopWriter = {
456
571
  write: () => {
457
572
  }
458
573
  };
459
- var writerLayerNoop = Layer2.succeed(TraceService, noopWriter);
460
- var layerNoop = Layer2.succeed(TraceSink, {
574
+ var writerLayerNoop = Layer3.succeed(TraceService, noopWriter);
575
+ var noopSink = {
461
576
  write: () => {
462
577
  }
463
- });
464
- var layerConsole = Layer2.succeed(TraceSink, {
578
+ };
579
+ var layerNoop = Layer3.succeed(TraceSink, noopSink);
580
+ var layerConsole = Layer3.succeed(TraceSink, {
465
581
  write: (message) => {
466
582
  console.log(message);
467
583
  }
468
584
  });
469
- var testTraceService = (opts = {}) => Layer2.effect(TraceService, Effect5.gen(function* () {
585
+ var mergeSinks = (sinks) => {
586
+ if (sinks.length === 0) {
587
+ return noopSink;
588
+ }
589
+ return {
590
+ write: (message) => {
591
+ for (const sink of sinks) {
592
+ try {
593
+ sink.write(message);
594
+ } catch (err) {
595
+ console.error("[trace] sink.write threw", err);
596
+ }
597
+ }
598
+ }
599
+ };
600
+ };
601
+ var testTraceService = (opts = {}) => Layer3.effect(TraceService, Effect5.gen(function* () {
470
602
  const sink = yield* TraceSink;
603
+ const clock = opts.clock ?? Date.now;
471
604
  return {
472
605
  write: (event, data) => {
473
606
  sink.write(Obj2.make(Message, {
@@ -476,7 +609,7 @@ var testTraceService = (opts = {}) => Layer2.effect(TraceService, Effect5.gen(fu
476
609
  events: [
477
610
  {
478
611
  type: event.key,
479
- timestamp: Date.now(),
612
+ timestamp: clock(),
480
613
  data
481
614
  }
482
615
  ]
@@ -506,6 +639,28 @@ var OperationEnd = EventType("operation.end", {
506
639
  }),
507
640
  isEphemeral: false
508
641
  });
642
+ var OperationInput = EventType("operation.input", {
643
+ schema: Schema4.Struct({
644
+ /** Operation key. */
645
+ key: Schema4.String,
646
+ /** Human-readable operation name. */
647
+ name: Schema4.optional(Schema4.String),
648
+ /** Raw operation input. Shape determined by the operation definition. */
649
+ input: Schema4.Unknown
650
+ }),
651
+ isEphemeral: true
652
+ });
653
+ var OperationOutput = EventType("operation.output", {
654
+ schema: Schema4.Struct({
655
+ /** Operation key. */
656
+ key: Schema4.String,
657
+ /** Human-readable operation name. */
658
+ name: Schema4.optional(Schema4.String),
659
+ /** Raw operation output. Shape determined by the operation definition. */
660
+ output: Schema4.Unknown
661
+ }),
662
+ isEphemeral: true
663
+ });
509
664
  var StatusUpdate = EventType("status.update", {
510
665
  schema: Schema4.Struct({
511
666
  /** Human-readable status message. */
@@ -522,7 +677,7 @@ var __dxlog_file4 = "/__w/dxos/dxos/packages/core/compute/compute/src/Process.ts
522
677
  var ID = Schema5.String.pipe(Schema5.brand("ProcessId"));
523
678
  var ProcessTypeId = "~@dxos/functions/Process";
524
679
  var isProcess = (executable) => typeof executable === "object" && executable !== null && ProcessTypeId in executable;
525
- var make4 = (opts, create) => {
680
+ var make5 = (opts, create) => {
526
681
  assertArgument(/^[a-z0-9]([a-z0-9.\-/]*[a-z0-9])?$/i.test(opts.key), "key", "Invalid key");
527
682
  return {
528
683
  [ProcessTypeId]: {},
@@ -536,7 +691,7 @@ var make4 = (opts, create) => {
536
691
  })))
537
692
  };
538
693
  };
539
- var fromOperation = (op, handler) => make4({
694
+ var fromOperation = (op, handler) => make5({
540
695
  key: op.meta.key,
541
696
  input: op.input,
542
697
  output: op.output,
@@ -553,10 +708,20 @@ var fromOperation = (op, handler) => make4({
553
708
  key: op.meta.key,
554
709
  name: op.meta.name
555
710
  });
711
+ yield* write(OperationInput, {
712
+ key: op.meta.key,
713
+ name: op.meta.name,
714
+ input
715
+ });
556
716
  const opHandler = yield* getHandler(handler, op).pipe(Effect6.orDie);
557
717
  const output = yield* opHandler.handler(input).pipe(Effect6.orDie, Effect6.withSpan(op.meta.key));
558
718
  ctx.submitOutput(output);
559
719
  ctx.succeed();
720
+ yield* write(OperationOutput, {
721
+ key: op.meta.key,
722
+ name: op.meta.name,
723
+ output
724
+ });
560
725
  yield* write(OperationEnd, {
561
726
  key: op.meta.key,
562
727
  name: op.meta.name,
@@ -659,41 +824,25 @@ var prettyProcessTree = (tree) => {
659
824
  var Routine_exports = {};
660
825
  __export(Routine_exports, {
661
826
  Routine: () => Routine,
662
- make: () => make5
827
+ make: () => make6
663
828
  });
664
829
  import * as Schema6 from "effect/Schema";
665
830
  import { Annotation as Annotation3, JsonSchema, Obj as Obj3, Ref as Ref2, Type as Type3 } from "@dxos/echo";
666
831
  var Routine = Schema6.Struct({
667
- /**
668
- * Name of the routine.
669
- */
670
832
  name: Schema6.optional(Schema6.String),
671
- /**
672
- * Description of the routine's purpose and functionality.
673
- * Allows AI agents to execute routines automatically as tools.
674
- */
675
833
  description: Schema6.optional(Schema6.String),
676
- /**
677
- * Input schema of the routine.
678
- */
679
- input: JsonSchema.JsonSchema.pipe(Annotation3.FormInputAnnotation.set(false)),
680
- /**
681
- * Output schema of the routine.
682
- */
683
- output: JsonSchema.JsonSchema.pipe(Annotation3.FormInputAnnotation.set(false)),
684
- /**
685
- * Natural language instructions for the routine.
686
- * These should provide concrete course of action for the AI to follow.
687
- */
834
+ input: JsonSchema.JsonSchema.pipe(Annotation3.FormInputAnnotation.set(false)).annotations({
835
+ description: "Input schema"
836
+ }),
837
+ output: JsonSchema.JsonSchema.pipe(Annotation3.FormInputAnnotation.set(false)).annotations({
838
+ description: "Output schema"
839
+ }),
688
840
  // TODO(burdon): Form editor.
689
- instructions: Template.pipe(Annotation3.FormInputAnnotation.set(false)),
690
- /**
691
- * Blueprints that the routine may utilize.
692
- */
841
+ instructions: Template.pipe(Annotation3.FormInputAnnotation.set(false)).annotations({
842
+ description: "Agent instructions"
843
+ }),
693
844
  blueprints: Schema6.Array(Ref2.Ref(Blueprint)),
694
- /**
695
- * Additional context that the routine may utilize.
696
- */
845
+ // TODO(burdon): Change to map?
697
846
  context: Schema6.Array(Schema6.Any).pipe(Annotation3.FormInputAnnotation.set(false))
698
847
  }).pipe(Type3.object({
699
848
  typename: "org.dxos.type.routine",
@@ -704,23 +853,23 @@ var Routine = Schema6.Struct({
704
853
  icon: "ph--scroll--regular",
705
854
  hue: "sky"
706
855
  }));
707
- var make5 = (params) => Obj3.make(Routine, {
708
- name: params.name,
709
- description: params.description,
710
- input: JsonSchema.toJsonSchema(params.input ?? Schema6.Void),
711
- output: JsonSchema.toJsonSchema(params.output ?? Schema6.Void),
856
+ var make6 = ({ name, description, input, output, instructions, blueprints = [], context = [] }) => Obj3.make(Routine, {
857
+ name,
858
+ description,
859
+ input: JsonSchema.toJsonSchema(input ?? Schema6.Void),
860
+ output: JsonSchema.toJsonSchema(output ?? Schema6.Void),
712
861
  instructions: make({
713
- source: params.instructions
862
+ source: instructions
714
863
  }),
715
- blueprints: params.blueprints ?? [],
716
- context: params.context ?? []
864
+ blueprints,
865
+ context
717
866
  });
718
867
 
719
868
  // src/Script.ts
720
869
  var Script_exports = {};
721
870
  __export(Script_exports, {
722
871
  Script: () => Script,
723
- make: () => make6
872
+ make: () => make7
724
873
  });
725
874
  import * as Schema7 from "effect/Schema";
726
875
  import { Annotation as Annotation4, Obj as Obj4, Ref as Ref3, Type as Type4 } from "@dxos/echo";
@@ -742,7 +891,7 @@ var Script = Schema7.Struct({
742
891
  icon: "ph--code--regular",
743
892
  hue: "sky"
744
893
  }));
745
- var make6 = ({ source = "", ...props } = {}) => Obj4.make(Script, {
894
+ var make7 = ({ source = "", ...props } = {}) => Obj4.make(Script, {
746
895
  ...props,
747
896
  source: Ref3.make(Text2.make({
748
897
  content: source
@@ -758,15 +907,16 @@ __export(ServiceResolver_exports, {
758
907
  fromContext: () => fromContext,
759
908
  fromRequirements: () => fromRequirements,
760
909
  layerRequirements: () => layerRequirements,
761
- make: () => make8,
910
+ make: () => make9,
911
+ provide: () => provide,
762
912
  resolve: () => resolve3,
763
913
  resolveAll: () => resolveAll,
764
- succeed: () => succeed2
914
+ succeed: () => succeed3
765
915
  });
766
916
  import * as Context6 from "effect/Context";
767
917
  import * as Effect7 from "effect/Effect";
768
918
  import * as Either from "effect/Either";
769
- import * as Layer3 from "effect/Layer";
919
+ import * as Layer4 from "effect/Layer";
770
920
  import * as Option from "effect/Option";
771
921
  var ServiceResolverTypeId = "~@dxos/functions/ServiceResolver";
772
922
  var ServiceResolver = Context6.GenericTag("@dxos/functions/ServiceResolver");
@@ -775,8 +925,8 @@ var resolveAll = (tags, context) => Effect7.gen(function* () {
775
925
  const services = yield* Effect7.forEach(tags, (tag) => resolve3(tag, context).pipe(Effect7.map((service) => Context6.make(tag, service))));
776
926
  return Context6.mergeAll(...services);
777
927
  });
778
- var succeed2 = (tag, getService) => {
779
- return make8((tag1, context) => {
928
+ var succeed3 = (tag, getService) => {
929
+ return make9((tag1, context) => {
780
930
  if (tag1.key !== tag.key) {
781
931
  return Effect7.fail(new ServiceNotAvailableError(`Service not available: ${String(tag.key ?? tag)}`));
782
932
  }
@@ -784,11 +934,11 @@ var succeed2 = (tag, getService) => {
784
934
  return service;
785
935
  });
786
936
  };
787
- var make8 = (resolveFn) => ({
937
+ var make9 = (resolveFn) => ({
788
938
  [ServiceResolverTypeId]: ServiceResolverTypeId,
789
939
  resolve: resolveFn
790
940
  });
791
- var fromContext = (ctx) => make8((tag, context) => Effect7.gen(function* () {
941
+ var fromContext = (ctx) => make9((tag, context) => Effect7.gen(function* () {
792
942
  const service = Context6.getOption(ctx, tag);
793
943
  if (Option.isNone(service)) {
794
944
  return yield* Effect7.fail(new ServiceNotAvailableError(String(tag.key ?? tag)));
@@ -797,7 +947,7 @@ var fromContext = (ctx) => make8((tag, context) => Effect7.gen(function* () {
797
947
  }));
798
948
  var fromRequirements = (...tags) => Effect7.contextWith((parentCtx) => {
799
949
  const available = new Set(tags.map((tag) => tag.key));
800
- return make8((tag, context) => Effect7.gen(function* () {
950
+ return make9((tag, context) => Effect7.gen(function* () {
801
951
  let result = Context6.empty();
802
952
  if (!available.has(tag.key)) {
803
953
  return yield* Effect7.fail(new ServiceNotAvailableError(String(tag.key ?? tag)));
@@ -809,8 +959,9 @@ var fromRequirements = (...tags) => Effect7.contextWith((parentCtx) => {
809
959
  return service.value;
810
960
  }));
811
961
  });
812
- var layerRequirements = (...tags) => Layer3.effect(ServiceResolver, fromRequirements(...tags));
813
- var compose = (...resolvers) => make8((tag, context) => Effect7.gen(function* () {
962
+ var layerRequirements = (...tags) => Layer4.effect(ServiceResolver, fromRequirements(...tags));
963
+ var provide = (context, ...tags) => Layer4.scopedContext(resolveAll(tags, context));
964
+ var compose = (...resolvers) => make9((tag, context) => Effect7.gen(function* () {
814
965
  for (const resolver of resolvers) {
815
966
  const single = yield* resolver.resolve(tag, context).pipe(Effect7.either);
816
967
  if (Either.isRight(single)) {
@@ -819,7 +970,7 @@ var compose = (...resolvers) => make8((tag, context) => Effect7.gen(function* ()
819
970
  }
820
971
  return yield* Effect7.fail(new ServiceNotAvailableError(String(tag.key ?? tag)));
821
972
  }));
822
- var empty2 = make8((tag, context) => {
973
+ var empty2 = make9((tag, context) => {
823
974
  return Effect7.fail(new ServiceNotAvailableError(String(tag.key ?? tag)));
824
975
  });
825
976
 
@@ -834,7 +985,7 @@ __export(Trigger_exports, {
834
985
  TimerSpec: () => TimerSpec,
835
986
  Trigger: () => Trigger,
836
987
  WebhookSpec: () => WebhookSpec,
837
- make: () => make9,
988
+ make: () => make10,
838
989
  specEmail: () => specEmail,
839
990
  specFeed: () => specFeed,
840
991
  specQueue: () => specQueue,
@@ -869,9 +1020,9 @@ var QueueSpec = Schema8.Struct({
869
1020
  // TODO(dmaretskyi): Rename to `feed` and change to a reference.
870
1021
  queue: DXN.Schema
871
1022
  });
872
- var specQueue = (queueDxn) => ({
1023
+ var specQueue = (queueDXN) => ({
873
1024
  kind: "queue",
874
- queue: queueDxn
1025
+ queue: queueDXN
875
1026
  });
876
1027
  var specFeed = (feed) => specQueue(Feed.getQueueDxn(feed)?.toString() ?? failedInvariant(new Error("Could not extract DXN from feed")));
877
1028
  var SubscriptionSpec = Schema8.Struct({
@@ -989,7 +1140,7 @@ var TriggerSchema = Schema8.Struct({
989
1140
  hue: "yellow"
990
1141
  }), SystemTypeAnnotation.set(true));
991
1142
  var Trigger = TriggerSchema;
992
- var make9 = (props) => Obj5.make(Trigger, props);
1143
+ var make10 = (props) => Obj5.make(Trigger, props);
993
1144
 
994
1145
  // src/TriggerEvent.ts
995
1146
  var TriggerEvent_exports = {};
@@ -1053,6 +1204,7 @@ export {
1053
1204
  InvalidOperationInputError,
1054
1205
  InvalidOperationOutputError,
1055
1206
  InvokerNotInitializedError,
1207
+ LayerSpec_exports as LayerSpec,
1056
1208
  McpServer_exports as McpServer,
1057
1209
  NoHandlerError,
1058
1210
  Operation_exports as Operation,