@dxos/plugin-debug 0.8.4-main.1f223c7 → 0.8.4-main.2244d791bb

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 (120) hide show
  1. package/dist/lib/browser/DebugGraph-6VMEOKEV.mjs +15 -0
  2. package/dist/lib/browser/DebugGraph-6VMEOKEV.mjs.map +7 -0
  3. package/dist/lib/browser/DevtoolsOverviewContainer-2C6XMJ3L.mjs +19 -0
  4. package/dist/lib/browser/DevtoolsOverviewContainer-2C6XMJ3L.mjs.map +7 -0
  5. package/dist/lib/browser/{SpaceGenerator-SRCIEELZ.mjs → SpaceGenerator-B4A7J26E.mjs} +312 -261
  6. package/dist/lib/browser/SpaceGenerator-B4A7J26E.mjs.map +7 -0
  7. package/dist/lib/browser/app-graph-builder-DEBTVBQG.mjs +599 -0
  8. package/dist/lib/browser/app-graph-builder-DEBTVBQG.mjs.map +7 -0
  9. package/dist/lib/browser/{chunk-AJA6RYN3.mjs → chunk-4UFQXPP7.mjs} +12 -2
  10. package/dist/lib/browser/chunk-4UFQXPP7.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-A5H5GRV6.mjs +20 -0
  12. package/dist/lib/browser/chunk-A5H5GRV6.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +36 -43
  14. package/dist/lib/browser/index.mjs.map +4 -4
  15. package/dist/lib/browser/meta.json +1 -1
  16. package/dist/lib/browser/react-context-I3USIAF6.mjs +17 -0
  17. package/dist/lib/browser/react-context-I3USIAF6.mjs.map +7 -0
  18. package/dist/lib/browser/react-surface-ADOU5663.mjs +758 -0
  19. package/dist/lib/browser/react-surface-ADOU5663.mjs.map +7 -0
  20. package/dist/lib/browser/settings-SLTQJJNF.mjs +32 -0
  21. package/dist/lib/browser/settings-SLTQJJNF.mjs.map +7 -0
  22. package/dist/types/src/DebugPlugin.d.ts +2 -1
  23. package/dist/types/src/DebugPlugin.d.ts.map +1 -1
  24. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
  25. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
  26. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
  27. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
  28. package/dist/types/src/capabilities/index.d.ts +4 -8
  29. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  30. package/dist/types/src/capabilities/react-context/index.d.ts +7 -0
  31. package/dist/types/src/capabilities/react-context/index.d.ts.map +1 -0
  32. package/dist/types/src/capabilities/react-context/react-context.d.ts +10 -0
  33. package/dist/types/src/capabilities/react-context/react-context.d.ts.map +1 -0
  34. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  35. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  36. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  37. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  38. package/dist/types/src/capabilities/settings/index.d.ts +3 -0
  39. package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
  40. package/dist/types/src/capabilities/settings/settings.d.ts +6 -0
  41. package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
  42. package/dist/types/src/components/DebugGraph.d.ts +5 -4
  43. package/dist/types/src/components/DebugGraph.d.ts.map +1 -1
  44. package/dist/types/src/components/DebugObjectPanel.d.ts +1 -1
  45. package/dist/types/src/components/DebugObjectPanel.d.ts.map +1 -1
  46. package/dist/types/src/components/DebugSettings.d.ts +4 -2
  47. package/dist/types/src/components/DebugSettings.d.ts.map +1 -1
  48. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts +5 -5
  49. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
  50. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts +2 -2
  51. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +1 -1
  52. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts +0 -1
  53. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts.map +1 -1
  54. package/dist/types/src/components/SpaceGenerator/presets.d.ts +2 -5
  55. package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -1
  56. package/dist/types/src/components/Wireframe.d.ts +2 -2
  57. package/dist/types/src/components/Wireframe.d.ts.map +1 -1
  58. package/dist/types/src/components/index.d.ts +4 -4
  59. package/dist/types/src/components/index.d.ts.map +1 -1
  60. package/dist/types/src/meta.d.ts +2 -3
  61. package/dist/types/src/meta.d.ts.map +1 -1
  62. package/dist/types/src/translations.d.ts +1 -1
  63. package/dist/types/src/types.d.ts +6 -1
  64. package/dist/types/src/types.d.ts.map +1 -1
  65. package/dist/types/tsconfig.tsbuildinfo +1 -1
  66. package/package.json +78 -71
  67. package/src/DebugPlugin.tsx +18 -33
  68. package/src/capabilities/app-graph-builder/app-graph-builder.ts +421 -0
  69. package/src/capabilities/app-graph-builder/index.ts +7 -0
  70. package/src/capabilities/index.ts +4 -6
  71. package/src/capabilities/react-context/index.ts +7 -0
  72. package/src/capabilities/react-context/react-context.tsx +20 -0
  73. package/src/capabilities/react-surface/index.ts +7 -0
  74. package/src/capabilities/react-surface/react-surface.tsx +411 -0
  75. package/src/capabilities/settings/index.ts +7 -0
  76. package/src/capabilities/settings/settings.ts +31 -0
  77. package/src/components/DebugGraph.tsx +4 -3
  78. package/src/components/DebugObjectPanel.tsx +6 -9
  79. package/src/components/DebugSettings.tsx +61 -35
  80. package/src/components/DebugStatus.tsx +2 -2
  81. package/src/components/DevtoolsOverviewContainer.tsx +2 -2
  82. package/src/components/SpaceGenerator/ObjectGenerator.tsx +26 -33
  83. package/src/components/SpaceGenerator/SchemaTable.tsx +2 -2
  84. package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +10 -10
  85. package/src/components/SpaceGenerator/SpaceGenerator.tsx +35 -31
  86. package/src/components/SpaceGenerator/draw-util.ts +2 -2
  87. package/src/components/SpaceGenerator/presets.ts +264 -89
  88. package/src/components/Wireframe.tsx +4 -5
  89. package/src/components/index.ts +4 -1
  90. package/src/meta.ts +8 -7
  91. package/src/translations.ts +1 -1
  92. package/src/types.ts +9 -1
  93. package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs +0 -20
  94. package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs.map +0 -7
  95. package/dist/lib/browser/DevtoolsOverviewContainer-EPD6EWT5.mjs +0 -25
  96. package/dist/lib/browser/DevtoolsOverviewContainer-EPD6EWT5.mjs.map +0 -7
  97. package/dist/lib/browser/SpaceGenerator-SRCIEELZ.mjs.map +0 -7
  98. package/dist/lib/browser/app-graph-builder-JTIEFOWZ.mjs +0 -587
  99. package/dist/lib/browser/app-graph-builder-JTIEFOWZ.mjs.map +0 -7
  100. package/dist/lib/browser/chunk-5XPIRNQS.mjs +0 -18
  101. package/dist/lib/browser/chunk-5XPIRNQS.mjs.map +0 -7
  102. package/dist/lib/browser/chunk-AJA6RYN3.mjs.map +0 -7
  103. package/dist/lib/browser/react-context-NVAGLAJD.mjs +0 -16
  104. package/dist/lib/browser/react-context-NVAGLAJD.mjs.map +0 -7
  105. package/dist/lib/browser/react-surface-HQPOGG33.mjs +0 -773
  106. package/dist/lib/browser/react-surface-HQPOGG33.mjs.map +0 -7
  107. package/dist/lib/browser/settings-LSSWLM5I.mjs +0 -22
  108. package/dist/lib/browser/settings-LSSWLM5I.mjs.map +0 -7
  109. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  110. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  111. package/dist/types/src/capabilities/react-context.d.ts +0 -8
  112. package/dist/types/src/capabilities/react-context.d.ts.map +0 -1
  113. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  114. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  115. package/dist/types/src/capabilities/settings.d.ts +0 -4
  116. package/dist/types/src/capabilities/settings.d.ts.map +0 -1
  117. package/src/capabilities/app-graph-builder.ts +0 -430
  118. package/src/capabilities/react-context.tsx +0 -16
  119. package/src/capabilities/react-surface.tsx +0 -398
  120. package/src/capabilities/settings.ts +0 -19
@@ -1,53 +1,53 @@
1
1
  // src/components/SpaceGenerator/SpaceGenerator.tsx
2
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
3
2
  import React2, { useCallback, useMemo, useState } from "react";
4
- import { useIntentDispatcher } from "@dxos/app-framework";
3
+ import { useOperationInvoker } from "@dxos/app-framework/ui";
5
4
  import { ComputeGraph as ComputeGraph2 } from "@dxos/conductor";
6
- import { Filter as Filter3 } from "@dxos/echo";
5
+ import { Filter as Filter3, Obj as Obj2 } from "@dxos/echo";
7
6
  import { Markdown as Markdown3 } from "@dxos/plugin-markdown/types";
8
- import { SheetType as SheetType2 } from "@dxos/plugin-sheet/types";
9
- import { DiagramType as DiagramType2 } from "@dxos/plugin-sketch/types";
7
+ import { Sheet as Sheet2 } from "@dxos/plugin-sheet/types";
8
+ import { Diagram as Diagram2 } from "@dxos/plugin-sketch/types";
10
9
  import { useClient } from "@dxos/react-client";
11
- import { getTypename } from "@dxos/react-client/echo";
12
- import { IconButton as IconButton2, Input, Toolbar, useAsyncEffect } from "@dxos/react-ui";
10
+ import { IconButton as IconButton2, Input, Layout, ScrollArea, Toolbar, useAsyncEffect } from "@dxos/react-ui";
13
11
  import { SyntaxHighlighter } from "@dxos/react-ui-syntax-highlighter";
14
- import { DataType as DataType3 } from "@dxos/schema";
12
+ import { Organization as Organization2, Person as Person2, Task } from "@dxos/types";
15
13
  import { jsonKeyReplacer, sortKeys } from "@dxos/util";
16
14
 
17
15
  // src/components/SpaceGenerator/ObjectGenerator.tsx
18
- import { createIntent } from "@dxos/app-framework";
19
16
  import { addressToA1Notation } from "@dxos/compute";
20
17
  import { ComputeGraph, ComputeGraphModel, DEFAULT_OUTPUT, NODE_INPUT, NODE_OUTPUT } from "@dxos/conductor";
21
- import { DXN, Filter, Key, Obj, Ref, Type } from "@dxos/echo";
18
+ import { DXN, Filter, Key } from "@dxos/echo";
22
19
  import { Markdown } from "@dxos/plugin-markdown/types";
23
- import { createSheet } from "@dxos/plugin-sheet/types";
24
- import { SheetType } from "@dxos/plugin-sheet/types";
25
- import { CanvasType, DiagramType } from "@dxos/plugin-sketch/types";
26
- import { SpaceAction } from "@dxos/plugin-space/types";
20
+ import { Sheet } from "@dxos/plugin-sheet/types";
21
+ import { Diagram } from "@dxos/plugin-sketch/types";
22
+ import { SpaceOperation } from "@dxos/plugin-space/types";
27
23
  import { faker } from "@dxos/random";
28
- import { DataType, typenameFromQuery } from "@dxos/schema";
24
+ import { View, getTypenameFromQuery } from "@dxos/schema";
29
25
  import { createAsyncGenerator } from "@dxos/schema/testing";
30
26
  import { range } from "@dxos/util";
31
27
  var generator = faker;
32
28
  var findViewByTypename = async (views, typename) => {
33
- return views.find((view) => typenameFromQuery(view.query) === typename);
29
+ return views.find((view) => getTypenameFromQuery(view.query.ast) === typename);
34
30
  };
35
- var createGenerator = (client, dispatch, schema) => {
31
+ var createGenerator = (client, invokePromise, schema) => {
36
32
  return async (space, n) => {
37
33
  const typename = schema.typename;
38
- const { objects: views } = await space.db.query(Filter.type(DataType.View)).run();
34
+ const views = await space.db.query(Filter.type(View.View)).run();
39
35
  const view = await findViewByTypename(views, typename);
40
- const staticSchema = client?.graph.schemaRegistry.schemas.find((schema2) => Type.getTypename(schema2) === typename);
36
+ const staticSchema = client?.graph.schemaRegistry.query({
37
+ typename
38
+ }).runSync()[0];
41
39
  if (!view && !staticSchema) {
42
- await dispatch(createIntent(SpaceAction.AddSchema, {
43
- space,
44
- schema
45
- }));
40
+ await invokePromise(SpaceOperation.AddSchema, {
41
+ db: space.db,
42
+ schema,
43
+ show: false
44
+ });
46
45
  } else if (!view && staticSchema) {
47
- await dispatch(createIntent(SpaceAction.UseStaticSchema, {
48
- space,
49
- typename
50
- }));
46
+ await invokePromise(SpaceOperation.UseStaticSchema, {
47
+ db: space.db,
48
+ typename,
49
+ show: false
50
+ });
51
51
  }
52
52
  const generate = createAsyncGenerator(generator, schema, {
53
53
  db: space.db
@@ -60,7 +60,7 @@ var staticGenerators = /* @__PURE__ */ new Map([
60
60
  Markdown.Document.typename,
61
61
  async (space, n, cb) => {
62
62
  const objects = range(n).map(() => {
63
- return space.db.add(Markdown.makeDocument({
63
+ return space.db.add(Markdown.make({
64
64
  name: faker.commerce.productName(),
65
65
  content: faker.lorem.sentences(5)
66
66
  }));
@@ -70,14 +70,11 @@ var staticGenerators = /* @__PURE__ */ new Map([
70
70
  }
71
71
  ],
72
72
  [
73
- DiagramType.typename,
73
+ Diagram.Diagram.typename,
74
74
  async (space, n, cb) => {
75
75
  const objects = range(n).map(() => {
76
- const obj = space.db.add(Obj.make(DiagramType, {
77
- name: faker.commerce.productName(),
78
- canvas: Ref.make(Obj.make(CanvasType, {
79
- content: {}
80
- }))
76
+ const obj = space.db.add(Diagram.make({
77
+ name: faker.commerce.productName()
81
78
  }));
82
79
  return obj;
83
80
  });
@@ -87,7 +84,7 @@ var staticGenerators = /* @__PURE__ */ new Map([
87
84
  ],
88
85
  // TODO(burdon): Create unit tests.
89
86
  [
90
- SheetType.typename,
87
+ Sheet.Sheet.typename,
91
88
  async (space, n, cb) => {
92
89
  const objects = range(n).map(() => {
93
90
  const cells = {};
@@ -123,7 +120,7 @@ var staticGenerators = /* @__PURE__ */ new Map([
123
120
  }
124
121
  }
125
122
  }
126
- return space.db.add(createSheet({
123
+ return space.db.add(Sheet.make({
127
124
  name: faker.commerce.productName(),
128
125
  cells
129
126
  }));
@@ -197,34 +194,37 @@ var staticGenerators = /* @__PURE__ */ new Map([
197
194
  ]);
198
195
 
199
196
  // src/components/SpaceGenerator/presets.ts
200
- import { Schema } from "effect";
201
- import { ResearchOn, research } from "@dxos/assistant-testing";
197
+ import * as Schema from "effect/Schema";
198
+ import { AgentFunctions, EntityExtractionFunctions, ResearchBlueprint } from "@dxos/assistant-toolkit";
199
+ import { Prompt } from "@dxos/blueprints";
202
200
  import { NODE_INPUT as NODE_INPUT2 } from "@dxos/conductor";
203
- import { DXN as DXN2, Filter as Filter2, Key as Key2, Obj as Obj2, Query, Ref as Ref2, Relation, Type as Type2 } from "@dxos/echo";
204
- import { FunctionTrigger, serializeFunction } from "@dxos/functions";
201
+ import { DXN as DXN2, Filter as Filter2, Key as Key2, Obj, Query, Ref, Tag, Type } from "@dxos/echo";
202
+ import { Trigger, serializeFunction } from "@dxos/functions";
205
203
  import { invariant } from "@dxos/invariant";
204
+ import { GmailFunctions } from "@dxos/plugin-inbox";
206
205
  import { Mailbox } from "@dxos/plugin-inbox/types";
207
206
  import { Markdown as Markdown2 } from "@dxos/plugin-markdown/types";
208
207
  import { createAppend, createChat, createComputeGraph, createConstant, createFunction, createGpt, createQueue, createRandom, createSurface, createTemplate, createText, createTrigger } from "@dxos/react-ui-canvas-compute";
209
- import { CanvasBoardType, CanvasGraphModel, pointMultiply, pointsToRect, rectToPoints } from "@dxos/react-ui-canvas-editor";
210
- import { DataType as DataType2, createView } from "@dxos/schema";
211
- import { range as range2 } from "@dxos/util";
208
+ import { CanvasBoard, CanvasGraphModel, pointMultiply, pointsToRect, rectToPoints } from "@dxos/react-ui-canvas-editor";
209
+ import { View as View2 } from "@dxos/schema";
210
+ import { Message, Organization, Person, Pipeline } from "@dxos/types";
211
+ import { range as range2, trim } from "@dxos/util";
212
212
  var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-debug/src/components/SpaceGenerator/presets.ts";
213
- var PresetName = /* @__PURE__ */ function(PresetName2) {
213
+ var PresetName = /* @__PURE__ */ (function(PresetName2) {
214
214
  PresetName2["DXOS_TEAM"] = "dxos-team";
215
215
  PresetName2["ORG_RESEARCH_PROJECT"] = "org-research-project";
216
216
  PresetName2["GPT_QUEUE"] = "webhook-gpt-queue";
217
217
  PresetName2["CHAT_GPT"] = "chat-gpt-text";
218
218
  PresetName2["OBJECT_CHANGE_QUEUE"] = "objectChange-queue";
219
- PresetName2["FOREX_FUNCTION_CALL"] = "forex-function-call";
220
219
  PresetName2["TIMER_TICK_QUEUE"] = "timerTick-queue";
220
+ PresetName2["FOREX_FUNCTION_CALL"] = "forex-function-call";
221
221
  PresetName2["DISCORD_MESSAGES"] = "discord-messages";
222
222
  return PresetName2;
223
- }({});
223
+ })({});
224
224
  var generator2 = () => ({
225
225
  schemas: [
226
- CanvasBoardType,
227
- FunctionTrigger
226
+ CanvasBoard.CanvasBoard,
227
+ Trigger.Trigger
228
228
  ],
229
229
  types: Object.values(PresetName).map((name) => ({
230
230
  typename: name
@@ -234,39 +234,42 @@ var generator2 = () => ({
234
234
  "dxos-team",
235
235
  async (space, n, cb) => {
236
236
  const objects = range2(n, () => {
237
- const org = space.db.add(Obj2.make(DataType2.Organization, {
237
+ const org = space.db.add(Obj.make(Organization.Organization, {
238
238
  name: "DXOS",
239
239
  website: "https://dxos.org"
240
240
  }));
241
- const doc = space.db.add(Markdown2.makeDocument({
241
+ const doc = space.db.add(Markdown2.make({
242
242
  name: "DXOS Research",
243
243
  content: "DXOS builds Composer, an open-source AI-powered malleable application."
244
244
  }));
245
- space.db.add(Relation.make(ResearchOn, {
246
- [Relation.Source]: doc,
247
- [Relation.Target]: org,
248
- completedAt: (/* @__PURE__ */ new Date()).toISOString()
245
+ const tag = space.db.add(Tag.make({
246
+ label: "Investor"
249
247
  }));
250
- space.db.add(Obj2.make(DataType2.Person, {
248
+ const tagDxn = Obj.getDXN(tag).toString();
249
+ Obj.change(doc, (d) => {
250
+ Obj.getMeta(d).tags = [
251
+ tagDxn
252
+ ];
253
+ });
254
+ space.db.add(Obj.make(Person.Person, {
251
255
  fullName: "Rich",
252
- jobTitle: "investor",
253
- organization: Ref2.make(org)
256
+ organization: Ref.make(org)
257
+ }, {
258
+ tags: [
259
+ tagDxn
260
+ ]
254
261
  }));
255
- space.db.add(Obj2.make(DataType2.Person, {
262
+ space.db.add(Obj.make(Person.Person, {
256
263
  fullName: "Josiah",
257
- organization: Ref2.make(org)
264
+ organization: Ref.make(org)
258
265
  }));
259
- space.db.add(Obj2.make(DataType2.Person, {
266
+ space.db.add(Obj.make(Person.Person, {
260
267
  fullName: "Dima",
261
- organization: Ref2.make(org)
268
+ organization: Ref.make(org)
262
269
  }));
263
- space.db.add(Obj2.make(DataType2.Person, {
270
+ space.db.add(Obj.make(Person.Person, {
264
271
  fullName: "Mykola",
265
- organization: Ref2.make(org)
266
- }));
267
- space.db.add(Obj2.make(DataType2.Person, {
268
- fullName: "Will",
269
- organization: Ref2.make(org)
272
+ organization: Ref.make(org)
270
273
  }));
271
274
  return doc;
272
275
  });
@@ -278,24 +281,71 @@ var generator2 = () => ({
278
281
  "org-research-project",
279
282
  async (space, n, cb) => {
280
283
  const mailbox = await space.db.query(Filter2.type(Mailbox.Mailbox)).first();
284
+ const tag = await space.db.query(Filter2.type(Tag.Tag, {
285
+ label: "Investor"
286
+ })).first();
287
+ const tagDxn = Obj.getDXN(tag).toString();
281
288
  const objects = range2(n, () => {
282
- const contactsQuery = Query.select(Filter2.type(DataType2.Person, {
283
- jobTitle: "investor"
289
+ const contactsQuery = Query.select(Filter2.type(Person.Person)).select(Filter2.tag(tagDxn));
290
+ const organizationsQuery = Query.select(Filter2.type(Organization.Organization)).select(Filter2.tag(tagDxn));
291
+ const notesQuery = Query.select(Filter2.type(Markdown2.Document)).select(Filter2.tag(tagDxn));
292
+ space.db.add(Trigger.make({
293
+ enabled: true,
294
+ spec: {
295
+ kind: "timer",
296
+ cron: "* * * * *"
297
+ },
298
+ function: Ref.make(serializeFunction(GmailFunctions.Sync)),
299
+ input: {
300
+ mailbox: Ref.make(mailbox)
301
+ }
284
302
  }));
285
- const organizationsQuery = contactsQuery.reference("organization");
286
- const notesQuery = organizationsQuery.targetOf(ResearchOn).source();
287
- const researchTrigger = Obj2.make(FunctionTrigger, {
288
- function: Ref2.make(serializeFunction(research)),
303
+ space.db.add(Trigger.make({
304
+ enabled: true,
305
+ // TODO(wittjosiah): Queue trigger doesn't support matching query of the column.
306
+ spec: {
307
+ kind: "queue",
308
+ queue: mailbox.queue.dxn.toString()
309
+ },
310
+ function: Ref.make(serializeFunction(EntityExtractionFunctions.Extract)),
311
+ input: {
312
+ source: "{{event.item}}"
313
+ }
314
+ }));
315
+ const researchPrompt = space.db.add(Prompt.make({
316
+ name: "Research",
317
+ description: "Research organization",
318
+ input: Schema.Struct({
319
+ org: Schema.Any
320
+ }),
321
+ output: Schema.Any,
322
+ // TODO(dmaretskyi): This mocks research (returns pre-baked result), the actual research might take compute minutes.
323
+ // Remove the mock prompt to do the actual research.
324
+ instructions: trim`
325
+ Research the organization provided as input.
326
+ Create a research note for it at the end.
327
+ NOTE: Do mocked reseach (set mockSearch to true).
328
+ `,
329
+ blueprints: [
330
+ Ref.make(ResearchBlueprint.make())
331
+ ]
332
+ }));
333
+ space.db.add(Trigger.make({
334
+ enabled: true,
289
335
  spec: {
290
336
  kind: "subscription",
291
- query: organizationsQuery.ast
337
+ query: {
338
+ ast: organizationsQuery.ast
339
+ }
292
340
  },
293
- enabled: true
294
- });
295
- space.db.add(researchTrigger);
296
- const mailboxView = createView({
297
- name: "Mailbox",
298
- query: Query.select(Filter2.type(DataType2.Message, {
341
+ function: Ref.make(serializeFunction(AgentFunctions.Prompt)),
342
+ input: {
343
+ prompt: Ref.make(researchPrompt),
344
+ input: "{{event.subject}}"
345
+ }
346
+ }));
347
+ const mailboxView = View2.make({
348
+ query: Query.select(Filter2.type(Message.Message, {
299
349
  properties: {
300
350
  labels: Filter2.contains("investor")
301
351
  }
@@ -304,43 +354,44 @@ var generator2 = () => ({
304
354
  mailbox.queue.dxn.toString()
305
355
  ]
306
356
  }),
307
- jsonSchema: Type2.toJsonSchema(DataType2.Message),
308
- presentation: Obj2.make(DataType2.Collection, {
309
- objects: []
310
- })
357
+ jsonSchema: Type.toJsonSchema(Message.Message)
311
358
  });
312
- const contactsView = createView({
313
- name: "Contacts",
359
+ const contactsView = View2.make({
314
360
  query: contactsQuery,
315
- jsonSchema: Type2.toJsonSchema(DataType2.Person),
316
- presentation: Obj2.make(DataType2.Collection, {
317
- objects: []
318
- })
361
+ jsonSchema: Type.toJsonSchema(Person.Person)
319
362
  });
320
- const organizationsView = createView({
321
- name: "Organizations",
363
+ const organizationsView = View2.make({
322
364
  query: organizationsQuery,
323
- jsonSchema: Type2.toJsonSchema(DataType2.Organization),
324
- presentation: Obj2.make(DataType2.Collection, {
325
- objects: []
326
- })
365
+ jsonSchema: Type.toJsonSchema(Organization.Organization)
327
366
  });
328
- const notesView = createView({
329
- name: "Notes",
367
+ const notesView = View2.make({
330
368
  query: notesQuery,
331
- jsonSchema: Type2.toJsonSchema(Markdown2.Document),
332
- presentation: Obj2.make(DataType2.Collection, {
333
- objects: []
334
- })
369
+ jsonSchema: Type.toJsonSchema(Markdown2.Document)
335
370
  });
336
- return space.db.add(DataType2.makeProject({
371
+ return space.db.add(Pipeline.make({
337
372
  name: "Investor Research",
338
- collections: [
339
- mailboxView,
340
- contactsView,
341
- organizationsView,
342
- notesView
343
- ].map((view) => Ref2.make(view))
373
+ columns: [
374
+ {
375
+ name: "Mailbox",
376
+ view: Ref.make(mailboxView),
377
+ order: []
378
+ },
379
+ {
380
+ name: "Contacts",
381
+ view: Ref.make(contactsView),
382
+ order: []
383
+ },
384
+ {
385
+ name: "Organizations",
386
+ view: Ref.make(organizationsView),
387
+ order: []
388
+ },
389
+ {
390
+ name: "Notes",
391
+ view: Ref.make(notesView),
392
+ order: []
393
+ }
394
+ ]
344
395
  }));
345
396
  });
346
397
  cb?.(objects.flat());
@@ -411,7 +462,9 @@ var generator2 = () => ({
411
462
  "objectChange-queue",
412
463
  async (space, n, cb) => {
413
464
  const objects = range2(n, () => {
414
- const { canvasModel, computeModel } = createQueueSinkPreset(space, "subscription", (triggerSpec) => triggerSpec.query = Query.select(Filter2.typename("dxos.org/type/Chess")).ast, "type");
465
+ const { canvasModel, computeModel } = createQueueSinkPreset(space, "subscription", (triggerSpec) => triggerSpec.query = {
466
+ ast: Query.select(Filter2.typename("dxos.org/type/Chess")).ast
467
+ }, "type");
415
468
  return addToSpace("objectChange-queue", space, canvasModel, computeModel);
416
469
  });
417
470
  cb?.(objects);
@@ -809,20 +862,22 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
809
862
  const triggerSpec = functionTrigger.spec;
810
863
  invariant(triggerSpec && triggerSpec.kind === triggerKind, "No trigger spec.", {
811
864
  F: __dxlog_file,
812
- L: 597,
865
+ L: 756,
813
866
  S: void 0,
814
867
  A: [
815
868
  "triggerSpec && triggerSpec.kind === triggerKind",
816
869
  "'No trigger spec.'"
817
870
  ]
818
871
  });
819
- initSpec(triggerSpec);
872
+ Obj.change(functionTrigger, (ft) => {
873
+ initSpec(ft.spec);
874
+ });
820
875
  });
821
876
  const computeModel = createComputeGraph(canvasModel);
822
877
  const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
823
878
  invariant(templateComputeNode, "Template compute node was not created.", {
824
879
  F: __dxlog_file,
825
- L: 604,
880
+ L: 765,
826
881
  S: void 0,
827
882
  A: [
828
883
  "templateComputeNode",
@@ -835,7 +890,7 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
835
890
  ' "id": "@{{changeId}}"',
836
891
  "}"
837
892
  ].join("\n");
838
- templateComputeNode.inputSchema = Type2.toJsonSchema(Schema.Struct({
893
+ templateComputeNode.inputSchema = Type.toJsonSchema(Schema.Struct({
839
894
  type: Schema.String,
840
895
  changeId: Schema.String
841
896
  }));
@@ -846,9 +901,9 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
846
901
  };
847
902
  };
848
903
  var addToSpace = (name, space, canvas, compute) => {
849
- return space.db.add(Obj2.make(CanvasBoardType, {
904
+ return space.db.add(Obj.make(CanvasBoard.CanvasBoard, {
850
905
  name,
851
- computeGraph: Ref2.make(compute.root),
906
+ computeGraph: Ref.make(compute.root),
852
907
  layout: canvas.graph
853
908
  }));
854
909
  };
@@ -884,16 +939,18 @@ var setupQueue = (space, canvasModel, args) => {
884
939
  var attachTrigger = (functionTrigger, computeModel) => {
885
940
  invariant(functionTrigger, void 0, {
886
941
  F: __dxlog_file,
887
- L: 643,
942
+ L: 805,
888
943
  S: void 0,
889
944
  A: [
890
945
  "functionTrigger",
891
946
  ""
892
947
  ]
893
948
  });
894
- functionTrigger.function = Ref2.make(computeModel.root);
895
949
  const inputNode = computeModel.nodes.find((node) => node.type === NODE_INPUT2);
896
- functionTrigger.inputNodeId = inputNode.id;
950
+ Obj.change(functionTrigger, (t) => {
951
+ t.function = Ref.make(computeModel.root);
952
+ t.inputNodeId = inputNode.id;
953
+ });
897
954
  };
898
955
  var rawPosition = (args) => {
899
956
  return {
@@ -940,157 +997,151 @@ var position = (rect) => {
940
997
  };
941
998
 
942
999
  // src/components/SpaceGenerator/SchemaTable.tsx
943
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
944
1000
  import React from "react";
945
1001
  import { IconButton } from "@dxos/react-ui";
946
1002
  var SchemaTable = ({ types, objects = {}, label, onClick }) => {
947
- var _effect = _useSignals();
948
- try {
949
- return /* @__PURE__ */ React.createElement("div", {
950
- className: "grid grid-cols-[1fr_80px_40px] gap-1 overflow-none"
951
- }, /* @__PURE__ */ React.createElement("h2", {
952
- className: "p-2"
953
- }, label), types.map((type) => /* @__PURE__ */ React.createElement("div", {
954
- key: type.typename,
955
- className: "grid grid-cols-subgrid col-span-3 items-center"
956
- }, /* @__PURE__ */ React.createElement("div", {
957
- className: "px-2 text-sm font-mono text-subdued"
958
- }, type.typename), /* @__PURE__ */ React.createElement("div", {
959
- className: "px-2 text-right font-mono"
960
- }, objects[type.typename] ?? 0), /* @__PURE__ */ React.createElement(IconButton, {
961
- variant: "ghost",
962
- icon: "ph--plus--regular",
963
- iconOnly: true,
964
- label: "Create data",
965
- onClick: () => onClick(type.typename)
966
- }))));
967
- } finally {
968
- _effect.f();
969
- }
1003
+ return /* @__PURE__ */ React.createElement("div", {
1004
+ className: "grid grid-cols-[1fr_80px_40px] gap-1 overflow-none"
1005
+ }, /* @__PURE__ */ React.createElement("h2", {
1006
+ className: "p-2"
1007
+ }, label), types.map((type) => /* @__PURE__ */ React.createElement("div", {
1008
+ key: type.typename,
1009
+ className: "grid grid-cols-subgrid col-span-3 items-center"
1010
+ }, /* @__PURE__ */ React.createElement("div", {
1011
+ className: "pli-2 text-sm font-mono text-subdued"
1012
+ }, type.typename), /* @__PURE__ */ React.createElement("div", {
1013
+ className: "pli-2 text-right font-mono"
1014
+ }, objects[type.typename] ?? 0), /* @__PURE__ */ React.createElement(IconButton, {
1015
+ variant: "ghost",
1016
+ icon: "ph--plus--regular",
1017
+ iconOnly: true,
1018
+ label: "Create data",
1019
+ onClick: () => onClick(type.typename)
1020
+ }))));
970
1021
  };
971
1022
 
972
1023
  // src/components/SpaceGenerator/SpaceGenerator.tsx
973
1024
  var SpaceGenerator = ({ space, onCreateObjects }) => {
974
- var _effect = _useSignals2();
975
- try {
976
- const { dispatchPromise: dispatch } = useIntentDispatcher();
977
- const client = useClient();
978
- const staticTypes = [
979
- Markdown3.Document,
980
- DiagramType2,
981
- SheetType2,
982
- ComputeGraph2
983
- ];
984
- const recordTypes = [
985
- DataType3.Organization,
986
- DataType3.Person,
987
- DataType3.Task
988
- ];
989
- const [count, setCount] = useState(1);
990
- const [info, setInfo] = useState({});
991
- const presets = useMemo(() => generator2(), []);
992
- const typeMap = useMemo(() => {
993
- client.addTypes([
994
- ...staticTypes,
995
- ...recordTypes,
996
- ...presets.schemas
997
- ]);
998
- const recordGenerators = new Map(recordTypes.map((type) => [
999
- type.typename,
1000
- createGenerator(client, dispatch, type)
1001
- ]));
1002
- return new Map([
1003
- ...staticGenerators,
1004
- ...presets.items,
1005
- ...recordGenerators
1006
- ]);
1007
- }, [
1008
- client,
1009
- recordTypes
1025
+ const { invokePromise } = useOperationInvoker();
1026
+ const client = useClient();
1027
+ const staticTypes = [
1028
+ Markdown3.Document,
1029
+ Diagram2.Diagram,
1030
+ Sheet2.Sheet,
1031
+ ComputeGraph2
1032
+ ];
1033
+ const recordTypes = [
1034
+ Organization2.Organization,
1035
+ Person2.Person,
1036
+ Task.Task
1037
+ ];
1038
+ const [count, setCount] = useState(1);
1039
+ const [info, setInfo] = useState({});
1040
+ const presets = useMemo(() => generator2(), []);
1041
+ useAsyncEffect(async () => {
1042
+ await client.addTypes([
1043
+ ...staticTypes,
1044
+ ...recordTypes,
1045
+ ...presets.schemas
1010
1046
  ]);
1011
- const updateInfo = async () => {
1012
- const echoSchema = await space.db.schemaRegistry.query().run();
1013
- const staticSchema = space.db.graph.schemaRegistry.schemas;
1014
- const { objects } = await space.db.query(Filter3.everything()).run();
1015
- const objectMap = sortKeys(objects.reduce((map, obj) => {
1016
- const type = getTypename(obj);
1017
- if (type) {
1018
- const count2 = map[type] ?? 0;
1019
- map[type] = count2 + 1;
1020
- }
1021
- return map;
1022
- }, {}));
1023
- setInfo({
1024
- schema: {
1025
- static: staticSchema.length,
1026
- mutable: echoSchema.length
1027
- },
1028
- objects: objectMap
1029
- });
1030
- };
1031
- useAsyncEffect(updateInfo, [
1032
- space
1047
+ }, [
1048
+ client
1049
+ ]);
1050
+ const typeMap = useMemo(() => {
1051
+ const recordGenerators = new Map(recordTypes.map((type) => [
1052
+ type.typename,
1053
+ createGenerator(client, invokePromise, type)
1054
+ ]));
1055
+ return new Map([
1056
+ ...staticGenerators,
1057
+ ...presets.items,
1058
+ ...recordGenerators
1033
1059
  ]);
1034
- const handleCreateData = useCallback(async (typename) => {
1035
- const constructor = typeMap.get(typename);
1036
- if (constructor) {
1037
- await constructor(space, count, onCreateObjects);
1038
- await updateInfo();
1060
+ }, [
1061
+ client,
1062
+ recordTypes,
1063
+ invokePromise
1064
+ ]);
1065
+ const updateInfo = async () => {
1066
+ const echoSchema = await space.db.schemaRegistry.query().run();
1067
+ const staticSchema = await space.db.graph.schemaRegistry.query().run();
1068
+ const objects = await space.db.query(Filter3.everything()).run();
1069
+ const objectMap = sortKeys(objects.reduce((map, obj) => {
1070
+ const type = Obj2.getTypename(obj);
1071
+ if (type) {
1072
+ const count2 = map[type] ?? 0;
1073
+ map[type] = count2 + 1;
1039
1074
  }
1040
- }, [
1041
- typeMap,
1042
- count
1043
- ]);
1044
- return /* @__PURE__ */ React2.createElement("div", {
1045
- role: "none",
1046
- className: "flex flex-col grow overflow-hidden"
1047
- }, /* @__PURE__ */ React2.createElement(Toolbar.Root, {
1048
- classNames: "border-be border-subduedSeparator"
1049
- }, /* @__PURE__ */ React2.createElement(IconButton2, {
1050
- icon: "ph--arrow-clockwise--regular",
1051
- iconOnly: true,
1052
- label: "Refresh",
1053
- onClick: updateInfo
1054
- }), /* @__PURE__ */ React2.createElement(Toolbar.Separator, {
1055
- variant: "gap"
1056
- }), /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
1057
- type: "number",
1058
- min: 1,
1059
- max: 100,
1060
- placeholder: "Count",
1061
- classNames: "!w-[4rem] !text-right",
1062
- size: 8,
1063
- value: count,
1064
- onChange: (ev) => setCount(parseInt(ev.target.value))
1065
- }))), /* @__PURE__ */ React2.createElement("div", {
1066
- className: "flex flex-col overflow-y-auto divide-y divide-separator"
1067
- }, /* @__PURE__ */ React2.createElement(SchemaTable, {
1068
- types: staticTypes,
1069
- objects: info.objects,
1070
- label: "Static Types",
1071
- onClick: handleCreateData
1072
- }), /* @__PURE__ */ React2.createElement(SchemaTable, {
1073
- types: recordTypes,
1074
- objects: info.objects,
1075
- label: "Record Types",
1076
- onClick: handleCreateData
1077
- }), /* @__PURE__ */ React2.createElement(SchemaTable, {
1078
- types: presets.types,
1079
- objects: info.objects,
1080
- label: "Presets",
1081
- onClick: handleCreateData
1082
- }), /* @__PURE__ */ React2.createElement("div", null, /* @__PURE__ */ React2.createElement(SyntaxHighlighter, {
1083
- language: "json",
1084
- classNames: "text-xs"
1085
- }, JSON.stringify({
1086
- space,
1087
- ...info
1088
- }, jsonKeyReplacer({
1089
- truncate: true
1090
- }), 2)))));
1091
- } finally {
1092
- _effect.f();
1093
- }
1075
+ return map;
1076
+ }, {}));
1077
+ setInfo({
1078
+ schema: {
1079
+ static: staticSchema.length,
1080
+ mutable: echoSchema.length
1081
+ },
1082
+ objects: objectMap
1083
+ });
1084
+ };
1085
+ useAsyncEffect(updateInfo, [
1086
+ space
1087
+ ]);
1088
+ const handleCreateData = useCallback(async (typename) => {
1089
+ const constructor = typeMap.get(typename);
1090
+ if (constructor) {
1091
+ await constructor(space, count, onCreateObjects);
1092
+ await updateInfo();
1093
+ }
1094
+ }, [
1095
+ typeMap,
1096
+ count
1097
+ ]);
1098
+ return /* @__PURE__ */ React2.createElement(Layout.Main, {
1099
+ toolbar: true
1100
+ }, /* @__PURE__ */ React2.createElement(Toolbar.Root, null, /* @__PURE__ */ React2.createElement(IconButton2, {
1101
+ icon: "ph--arrow-clockwise--regular",
1102
+ iconOnly: true,
1103
+ label: "Refresh",
1104
+ onClick: updateInfo
1105
+ }), /* @__PURE__ */ React2.createElement(Toolbar.Separator, {
1106
+ variant: "gap"
1107
+ }), /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
1108
+ type: "number",
1109
+ placeholder: "Count",
1110
+ classNames: "is-[4rem] text-right",
1111
+ min: 1,
1112
+ max: 100,
1113
+ size: 8,
1114
+ value: count,
1115
+ onChange: (event) => setCount(parseInt(event.target.value))
1116
+ }))), /* @__PURE__ */ React2.createElement(ScrollArea.Root, {
1117
+ thin: true,
1118
+ orientation: "vertical"
1119
+ }, /* @__PURE__ */ React2.createElement(ScrollArea.Viewport, {
1120
+ classNames: "gap-4 divide-y divide-subduedSeparator"
1121
+ }, /* @__PURE__ */ React2.createElement(SchemaTable, {
1122
+ types: staticTypes,
1123
+ objects: info.objects,
1124
+ label: "Static Types",
1125
+ onClick: handleCreateData
1126
+ }), /* @__PURE__ */ React2.createElement(SchemaTable, {
1127
+ types: recordTypes,
1128
+ objects: info.objects,
1129
+ label: "Record Types",
1130
+ onClick: handleCreateData
1131
+ }), /* @__PURE__ */ React2.createElement(SchemaTable, {
1132
+ types: presets.types,
1133
+ objects: info.objects,
1134
+ label: "Presets",
1135
+ onClick: handleCreateData
1136
+ }), /* @__PURE__ */ React2.createElement(SyntaxHighlighter, {
1137
+ language: "json",
1138
+ classNames: "text-xs"
1139
+ }, JSON.stringify({
1140
+ space,
1141
+ ...info
1142
+ }, jsonKeyReplacer({
1143
+ truncate: true
1144
+ }), 2)))));
1094
1145
  };
1095
1146
 
1096
1147
  // src/components/SpaceGenerator/index.ts
@@ -1098,4 +1149,4 @@ var SpaceGenerator_default = SpaceGenerator;
1098
1149
  export {
1099
1150
  SpaceGenerator_default as default
1100
1151
  };
1101
- //# sourceMappingURL=SpaceGenerator-SRCIEELZ.mjs.map
1152
+ //# sourceMappingURL=SpaceGenerator-B4A7J26E.mjs.map