@dxos/plugin-debug 0.8.4-main.1da679c → 0.8.4-main.21d9917

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-77PKFLYV.mjs +19 -0
  4. package/dist/lib/browser/DevtoolsOverviewContainer-77PKFLYV.mjs.map +7 -0
  5. package/dist/lib/browser/{SpaceGenerator-SB2YRVRT.mjs → SpaceGenerator-ZHVZWGM7.mjs} +287 -257
  6. package/dist/lib/browser/SpaceGenerator-ZHVZWGM7.mjs.map +7 -0
  7. package/dist/lib/browser/app-graph-builder-FBDRMMYF.mjs +597 -0
  8. package/dist/lib/browser/app-graph-builder-FBDRMMYF.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 +35 -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-FSWBT3MH.mjs +17 -0
  17. package/dist/lib/browser/react-context-FSWBT3MH.mjs.map +7 -0
  18. package/dist/lib/browser/react-surface-W62RJ32U.mjs +757 -0
  19. package/dist/lib/browser/react-surface-W62RJ32U.mjs.map +7 -0
  20. package/dist/lib/browser/settings-KA4GN73K.mjs +31 -0
  21. package/dist/lib/browser/settings-KA4GN73K.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 +5 -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 +77 -72
  67. package/src/DebugPlugin.tsx +17 -33
  68. package/src/capabilities/app-graph-builder/app-graph-builder.ts +419 -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 +409 -0
  75. package/src/capabilities/settings/index.ts +7 -0
  76. package/src/capabilities/settings/settings.ts +30 -0
  77. package/src/components/DebugGraph.tsx +4 -3
  78. package/src/components/DebugObjectPanel.tsx +6 -8
  79. package/src/components/DebugSettings.tsx +47 -21
  80. package/src/components/DebugStatus.tsx +2 -2
  81. package/src/components/DevtoolsOverviewContainer.tsx +1 -1
  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 +21 -16
  86. package/src/components/SpaceGenerator/draw-util.ts +2 -2
  87. package/src/components/SpaceGenerator/presets.ts +243 -86
  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-SB2YRVRT.mjs.map +0 -7
  98. package/dist/lib/browser/app-graph-builder-7ODCSP7R.mjs +0 -587
  99. package/dist/lib/browser/app-graph-builder-7ODCSP7R.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-Y537DXK5.mjs +0 -16
  104. package/dist/lib/browser/react-context-Y537DXK5.mjs.map +0 -7
  105. package/dist/lib/browser/react-surface-OP75RFNI.mjs +0 -773
  106. package/dist/lib/browser/react-surface-OP75RFNI.mjs.map +0 -7
  107. package/dist/lib/browser/settings-XAUQOU7I.mjs +0 -22
  108. package/dist/lib/browser/settings-XAUQOU7I.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/react";
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
10
  import { IconButton as IconButton2, Input, 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,19 +194,21 @@ var staticGenerators = /* @__PURE__ */ new Map([
197
194
  ]);
198
195
 
199
196
  // src/components/SpaceGenerator/presets.ts
200
- import { Schema } from "effect";
201
- import { RESEARCH_BLUEPRINT, ResearchOn, agent } from "@dxos/assistant-testing";
197
+ import * as Schema from "effect/Schema";
198
+ import { Agent, EntityExtraction, ResearchBlueprint } from "@dxos/assistant-toolkit";
202
199
  import { Prompt } from "@dxos/blueprints";
203
200
  import { NODE_INPUT as NODE_INPUT2 } from "@dxos/conductor";
204
- import { DXN as DXN2, Filter as Filter2, Key as Key2, Obj as Obj2, Query, Ref as Ref2, Relation, Type as Type2 } from "@dxos/echo";
205
- 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";
206
203
  import { invariant } from "@dxos/invariant";
204
+ import { gmail } from "@dxos/plugin-inbox";
207
205
  import { Mailbox } from "@dxos/plugin-inbox/types";
208
206
  import { Markdown as Markdown2 } from "@dxos/plugin-markdown/types";
209
207
  import { createAppend, createChat, createComputeGraph, createConstant, createFunction, createGpt, createQueue, createRandom, createSurface, createTemplate, createText, createTrigger } from "@dxos/react-ui-canvas-compute";
210
208
  import { CanvasBoardType, CanvasGraphModel, pointMultiply, pointsToRect, rectToPoints } from "@dxos/react-ui-canvas-editor";
211
- import { DataType as DataType2, createView } from "@dxos/schema";
212
- import { range as range2 } from "@dxos/util";
209
+ import { View as View2 } from "@dxos/schema";
210
+ import { Message, Organization, Person, Project } from "@dxos/types";
211
+ import { range as range2, trim } from "@dxos/util";
213
212
  var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-debug/src/components/SpaceGenerator/presets.ts";
214
213
  var PresetName = /* @__PURE__ */ (function(PresetName2) {
215
214
  PresetName2["DXOS_TEAM"] = "dxos-team";
@@ -217,15 +216,15 @@ var PresetName = /* @__PURE__ */ (function(PresetName2) {
217
216
  PresetName2["GPT_QUEUE"] = "webhook-gpt-queue";
218
217
  PresetName2["CHAT_GPT"] = "chat-gpt-text";
219
218
  PresetName2["OBJECT_CHANGE_QUEUE"] = "objectChange-queue";
220
- PresetName2["FOREX_FUNCTION_CALL"] = "forex-function-call";
221
219
  PresetName2["TIMER_TICK_QUEUE"] = "timerTick-queue";
220
+ PresetName2["FOREX_FUNCTION_CALL"] = "forex-function-call";
222
221
  PresetName2["DISCORD_MESSAGES"] = "discord-messages";
223
222
  return PresetName2;
224
223
  })({});
225
224
  var generator2 = () => ({
226
225
  schemas: [
227
226
  CanvasBoardType,
228
- FunctionTrigger
227
+ Trigger.Trigger
229
228
  ],
230
229
  types: Object.values(PresetName).map((name) => ({
231
230
  typename: name
@@ -235,39 +234,42 @@ var generator2 = () => ({
235
234
  "dxos-team",
236
235
  async (space, n, cb) => {
237
236
  const objects = range2(n, () => {
238
- const org = space.db.add(Obj2.make(DataType2.Organization, {
237
+ const org = space.db.add(Obj.make(Organization.Organization, {
239
238
  name: "DXOS",
240
239
  website: "https://dxos.org"
241
240
  }));
242
- const doc = space.db.add(Markdown2.makeDocument({
241
+ const doc = space.db.add(Markdown2.make({
243
242
  name: "DXOS Research",
244
243
  content: "DXOS builds Composer, an open-source AI-powered malleable application."
245
244
  }));
246
- space.db.add(Relation.make(ResearchOn, {
247
- [Relation.Source]: doc,
248
- [Relation.Target]: org,
249
- completedAt: (/* @__PURE__ */ new Date()).toISOString()
245
+ const tag = space.db.add(Tag.make({
246
+ label: "Investor"
250
247
  }));
251
- 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, {
252
255
  fullName: "Rich",
253
- jobTitle: "investor",
254
- organization: Ref2.make(org)
256
+ organization: Ref.make(org)
257
+ }, {
258
+ tags: [
259
+ tagDxn
260
+ ]
255
261
  }));
256
- space.db.add(Obj2.make(DataType2.Person, {
262
+ space.db.add(Obj.make(Person.Person, {
257
263
  fullName: "Josiah",
258
- organization: Ref2.make(org)
264
+ organization: Ref.make(org)
259
265
  }));
260
- space.db.add(Obj2.make(DataType2.Person, {
266
+ space.db.add(Obj.make(Person.Person, {
261
267
  fullName: "Dima",
262
- organization: Ref2.make(org)
268
+ organization: Ref.make(org)
263
269
  }));
264
- space.db.add(Obj2.make(DataType2.Person, {
270
+ space.db.add(Obj.make(Person.Person, {
265
271
  fullName: "Mykola",
266
- organization: Ref2.make(org)
267
- }));
268
- space.db.add(Obj2.make(DataType2.Person, {
269
- fullName: "Will",
270
- organization: Ref2.make(org)
272
+ organization: Ref.make(org)
271
273
  }));
272
274
  return doc;
273
275
  });
@@ -279,12 +281,37 @@ var generator2 = () => ({
279
281
  "org-research-project",
280
282
  async (space, n, cb) => {
281
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();
282
288
  const objects = range2(n, () => {
283
- const contactsQuery = Query.select(Filter2.type(DataType2.Person, {
284
- 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(gmail.sync)),
299
+ input: {
300
+ mailboxId: Obj.getDXN(mailbox).toString()
301
+ }
302
+ }));
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(EntityExtraction.extract)),
311
+ input: {
312
+ source: "{{event.item}}"
313
+ }
285
314
  }));
286
- const organizationsQuery = contactsQuery.reference("organization");
287
- const notesQuery = organizationsQuery.targetOf(ResearchOn).source();
288
315
  const researchPrompt = space.db.add(Prompt.make({
289
316
  name: "Research",
290
317
  description: "Research organization",
@@ -294,27 +321,31 @@ var generator2 = () => ({
294
321
  output: Schema.Any,
295
322
  // TODO(dmaretskyi): This mocks research (returns pre-baked result), the actual research might take compute minutes.
296
323
  // Remove the mock prompt to do the actual research.
297
- instructions: "Research the organization provided as input. Create a research note for it at the end. NOTE: Do mocked reseach (set mockSearch to true).",
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
+ `,
298
329
  blueprints: [
299
- Ref2.make(RESEARCH_BLUEPRINT)
330
+ Ref.make(ResearchBlueprint)
300
331
  ]
301
332
  }));
302
- const researchTrigger = Obj2.make(FunctionTrigger, {
333
+ space.db.add(Trigger.make({
303
334
  enabled: true,
304
335
  spec: {
305
336
  kind: "subscription",
306
- query: organizationsQuery.ast
337
+ query: {
338
+ ast: organizationsQuery.ast
339
+ }
307
340
  },
308
- function: Ref2.make(serializeFunction(agent)),
341
+ function: Ref.make(serializeFunction(Agent.prompt)),
309
342
  input: {
310
- prompt: Ref2.make(researchPrompt),
343
+ prompt: Ref.make(researchPrompt),
311
344
  input: "{{event.subject}}"
312
345
  }
313
- });
314
- space.db.add(researchTrigger);
315
- const mailboxView = createView({
316
- name: "Mailbox",
317
- query: Query.select(Filter2.type(DataType2.Message, {
346
+ }));
347
+ const mailboxView = View2.make({
348
+ query: Query.select(Filter2.type(Message.Message, {
318
349
  properties: {
319
350
  labels: Filter2.contains("investor")
320
351
  }
@@ -323,43 +354,44 @@ var generator2 = () => ({
323
354
  mailbox.queue.dxn.toString()
324
355
  ]
325
356
  }),
326
- jsonSchema: Type2.toJsonSchema(DataType2.Message),
327
- presentation: Obj2.make(DataType2.Collection, {
328
- objects: []
329
- })
357
+ jsonSchema: Type.toJsonSchema(Message.Message)
330
358
  });
331
- const contactsView = createView({
332
- name: "Contacts",
359
+ const contactsView = View2.make({
333
360
  query: contactsQuery,
334
- jsonSchema: Type2.toJsonSchema(DataType2.Person),
335
- presentation: Obj2.make(DataType2.Collection, {
336
- objects: []
337
- })
361
+ jsonSchema: Type.toJsonSchema(Person.Person)
338
362
  });
339
- const organizationsView = createView({
340
- name: "Organizations",
363
+ const organizationsView = View2.make({
341
364
  query: organizationsQuery,
342
- jsonSchema: Type2.toJsonSchema(DataType2.Organization),
343
- presentation: Obj2.make(DataType2.Collection, {
344
- objects: []
345
- })
365
+ jsonSchema: Type.toJsonSchema(Organization.Organization)
346
366
  });
347
- const notesView = createView({
348
- name: "Notes",
367
+ const notesView = View2.make({
349
368
  query: notesQuery,
350
- jsonSchema: Type2.toJsonSchema(Markdown2.Document),
351
- presentation: Obj2.make(DataType2.Collection, {
352
- objects: []
353
- })
369
+ jsonSchema: Type.toJsonSchema(Markdown2.Document)
354
370
  });
355
- return space.db.add(DataType2.makeProject({
371
+ return space.db.add(Project.make({
356
372
  name: "Investor Research",
357
- collections: [
358
- mailboxView,
359
- contactsView,
360
- organizationsView,
361
- notesView
362
- ].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
+ ]
363
395
  }));
364
396
  });
365
397
  cb?.(objects.flat());
@@ -430,7 +462,9 @@ var generator2 = () => ({
430
462
  "objectChange-queue",
431
463
  async (space, n, cb) => {
432
464
  const objects = range2(n, () => {
433
- 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");
434
468
  return addToSpace("objectChange-queue", space, canvasModel, computeModel);
435
469
  });
436
470
  cb?.(objects);
@@ -828,7 +862,7 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
828
862
  const triggerSpec = functionTrigger.spec;
829
863
  invariant(triggerSpec && triggerSpec.kind === triggerKind, "No trigger spec.", {
830
864
  F: __dxlog_file,
831
- L: 619,
865
+ L: 762,
832
866
  S: void 0,
833
867
  A: [
834
868
  "triggerSpec && triggerSpec.kind === triggerKind",
@@ -841,7 +875,7 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
841
875
  const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
842
876
  invariant(templateComputeNode, "Template compute node was not created.", {
843
877
  F: __dxlog_file,
844
- L: 626,
878
+ L: 769,
845
879
  S: void 0,
846
880
  A: [
847
881
  "templateComputeNode",
@@ -854,7 +888,7 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
854
888
  ' "id": "@{{changeId}}"',
855
889
  "}"
856
890
  ].join("\n");
857
- templateComputeNode.inputSchema = Type2.toJsonSchema(Schema.Struct({
891
+ templateComputeNode.inputSchema = Type.toJsonSchema(Schema.Struct({
858
892
  type: Schema.String,
859
893
  changeId: Schema.String
860
894
  }));
@@ -865,9 +899,9 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
865
899
  };
866
900
  };
867
901
  var addToSpace = (name, space, canvas, compute) => {
868
- return space.db.add(Obj2.make(CanvasBoardType, {
902
+ return space.db.add(Obj.make(CanvasBoardType, {
869
903
  name,
870
- computeGraph: Ref2.make(compute.root),
904
+ computeGraph: Ref.make(compute.root),
871
905
  layout: canvas.graph
872
906
  }));
873
907
  };
@@ -903,16 +937,18 @@ var setupQueue = (space, canvasModel, args) => {
903
937
  var attachTrigger = (functionTrigger, computeModel) => {
904
938
  invariant(functionTrigger, void 0, {
905
939
  F: __dxlog_file,
906
- L: 665,
940
+ L: 809,
907
941
  S: void 0,
908
942
  A: [
909
943
  "functionTrigger",
910
944
  ""
911
945
  ]
912
946
  });
913
- functionTrigger.function = Ref2.make(computeModel.root);
914
947
  const inputNode = computeModel.nodes.find((node) => node.type === NODE_INPUT2);
915
- functionTrigger.inputNodeId = inputNode.id;
948
+ Obj.change(functionTrigger, (t) => {
949
+ t.function = Ref.make(computeModel.root);
950
+ t.inputNodeId = inputNode.id;
951
+ });
916
952
  };
917
953
  var rawPosition = (args) => {
918
954
  return {
@@ -959,157 +995,151 @@ var position = (rect) => {
959
995
  };
960
996
 
961
997
  // src/components/SpaceGenerator/SchemaTable.tsx
962
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
963
998
  import React from "react";
964
999
  import { IconButton } from "@dxos/react-ui";
965
1000
  var SchemaTable = ({ types, objects = {}, label, onClick }) => {
966
- var _effect = _useSignals();
967
- try {
968
- return /* @__PURE__ */ React.createElement("div", {
969
- className: "grid grid-cols-[1fr_80px_40px] gap-1 overflow-none"
970
- }, /* @__PURE__ */ React.createElement("h2", {
971
- className: "p-2"
972
- }, label), types.map((type) => /* @__PURE__ */ React.createElement("div", {
973
- key: type.typename,
974
- className: "grid grid-cols-subgrid col-span-3 items-center"
975
- }, /* @__PURE__ */ React.createElement("div", {
976
- className: "px-2 text-sm font-mono text-subdued"
977
- }, type.typename), /* @__PURE__ */ React.createElement("div", {
978
- className: "px-2 text-right font-mono"
979
- }, objects[type.typename] ?? 0), /* @__PURE__ */ React.createElement(IconButton, {
980
- variant: "ghost",
981
- icon: "ph--plus--regular",
982
- iconOnly: true,
983
- label: "Create data",
984
- onClick: () => onClick(type.typename)
985
- }))));
986
- } finally {
987
- _effect.f();
988
- }
1001
+ return /* @__PURE__ */ React.createElement("div", {
1002
+ className: "grid grid-cols-[1fr_80px_40px] gap-1 overflow-none"
1003
+ }, /* @__PURE__ */ React.createElement("h2", {
1004
+ className: "p-2"
1005
+ }, label), types.map((type) => /* @__PURE__ */ React.createElement("div", {
1006
+ key: type.typename,
1007
+ className: "grid grid-cols-subgrid col-span-3 items-center"
1008
+ }, /* @__PURE__ */ React.createElement("div", {
1009
+ className: "pli-2 text-sm font-mono text-subdued"
1010
+ }, type.typename), /* @__PURE__ */ React.createElement("div", {
1011
+ className: "pli-2 text-right font-mono"
1012
+ }, objects[type.typename] ?? 0), /* @__PURE__ */ React.createElement(IconButton, {
1013
+ variant: "ghost",
1014
+ icon: "ph--plus--regular",
1015
+ iconOnly: true,
1016
+ label: "Create data",
1017
+ onClick: () => onClick(type.typename)
1018
+ }))));
989
1019
  };
990
1020
 
991
1021
  // src/components/SpaceGenerator/SpaceGenerator.tsx
992
1022
  var SpaceGenerator = ({ space, onCreateObjects }) => {
993
- var _effect = _useSignals2();
994
- try {
995
- const { dispatchPromise: dispatch } = useIntentDispatcher();
996
- const client = useClient();
997
- const staticTypes = [
998
- Markdown3.Document,
999
- DiagramType2,
1000
- SheetType2,
1001
- ComputeGraph2
1002
- ];
1003
- const recordTypes = [
1004
- DataType3.Organization,
1005
- DataType3.Person,
1006
- DataType3.Task
1007
- ];
1008
- const [count, setCount] = useState(1);
1009
- const [info, setInfo] = useState({});
1010
- const presets = useMemo(() => generator2(), []);
1011
- const typeMap = useMemo(() => {
1012
- client.addTypes([
1013
- ...staticTypes,
1014
- ...recordTypes,
1015
- ...presets.schemas
1016
- ]);
1017
- const recordGenerators = new Map(recordTypes.map((type) => [
1018
- type.typename,
1019
- createGenerator(client, dispatch, type)
1020
- ]));
1021
- return new Map([
1022
- ...staticGenerators,
1023
- ...presets.items,
1024
- ...recordGenerators
1025
- ]);
1026
- }, [
1027
- client,
1028
- recordTypes
1023
+ const { invokePromise } = useOperationInvoker();
1024
+ const client = useClient();
1025
+ const staticTypes = [
1026
+ Markdown3.Document,
1027
+ Diagram2.Diagram,
1028
+ Sheet2.Sheet,
1029
+ ComputeGraph2
1030
+ ];
1031
+ const recordTypes = [
1032
+ Organization2.Organization,
1033
+ Person2.Person,
1034
+ Task.Task
1035
+ ];
1036
+ const [count, setCount] = useState(1);
1037
+ const [info, setInfo] = useState({});
1038
+ const presets = useMemo(() => generator2(), []);
1039
+ useAsyncEffect(async () => {
1040
+ await client.addTypes([
1041
+ ...staticTypes,
1042
+ ...recordTypes,
1043
+ ...presets.schemas
1029
1044
  ]);
1030
- const updateInfo = async () => {
1031
- const echoSchema = await space.db.schemaRegistry.query().run();
1032
- const staticSchema = space.db.graph.schemaRegistry.schemas;
1033
- const { objects } = await space.db.query(Filter3.everything()).run();
1034
- const objectMap = sortKeys(objects.reduce((map, obj) => {
1035
- const type = getTypename(obj);
1036
- if (type) {
1037
- const count2 = map[type] ?? 0;
1038
- map[type] = count2 + 1;
1039
- }
1040
- return map;
1041
- }, {}));
1042
- setInfo({
1043
- schema: {
1044
- static: staticSchema.length,
1045
- mutable: echoSchema.length
1046
- },
1047
- objects: objectMap
1048
- });
1049
- };
1050
- useAsyncEffect(updateInfo, [
1051
- space
1045
+ }, [
1046
+ client
1047
+ ]);
1048
+ const typeMap = useMemo(() => {
1049
+ const recordGenerators = new Map(recordTypes.map((type) => [
1050
+ type.typename,
1051
+ createGenerator(client, invokePromise, type)
1052
+ ]));
1053
+ return new Map([
1054
+ ...staticGenerators,
1055
+ ...presets.items,
1056
+ ...recordGenerators
1052
1057
  ]);
1053
- const handleCreateData = useCallback(async (typename) => {
1054
- const constructor = typeMap.get(typename);
1055
- if (constructor) {
1056
- await constructor(space, count, onCreateObjects);
1057
- await updateInfo();
1058
+ }, [
1059
+ client,
1060
+ recordTypes,
1061
+ invokePromise
1062
+ ]);
1063
+ const updateInfo = async () => {
1064
+ const echoSchema = await space.db.schemaRegistry.query().run();
1065
+ const staticSchema = await space.db.graph.schemaRegistry.query().run();
1066
+ const objects = await space.db.query(Filter3.everything()).run();
1067
+ const objectMap = sortKeys(objects.reduce((map, obj) => {
1068
+ const type = Obj2.getTypename(obj);
1069
+ if (type) {
1070
+ const count2 = map[type] ?? 0;
1071
+ map[type] = count2 + 1;
1058
1072
  }
1059
- }, [
1060
- typeMap,
1061
- count
1062
- ]);
1063
- return /* @__PURE__ */ React2.createElement("div", {
1064
- role: "none",
1065
- className: "flex flex-col grow overflow-hidden"
1066
- }, /* @__PURE__ */ React2.createElement(Toolbar.Root, {
1067
- classNames: "border-be border-subduedSeparator"
1068
- }, /* @__PURE__ */ React2.createElement(IconButton2, {
1069
- icon: "ph--arrow-clockwise--regular",
1070
- iconOnly: true,
1071
- label: "Refresh",
1072
- onClick: updateInfo
1073
- }), /* @__PURE__ */ React2.createElement(Toolbar.Separator, {
1074
- variant: "gap"
1075
- }), /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
1076
- type: "number",
1077
- min: 1,
1078
- max: 100,
1079
- placeholder: "Count",
1080
- classNames: "!w-[4rem] !text-right",
1081
- size: 8,
1082
- value: count,
1083
- onChange: (ev) => setCount(parseInt(ev.target.value))
1084
- }))), /* @__PURE__ */ React2.createElement("div", {
1085
- className: "flex flex-col overflow-y-auto divide-y divide-separator"
1086
- }, /* @__PURE__ */ React2.createElement(SchemaTable, {
1087
- types: staticTypes,
1088
- objects: info.objects,
1089
- label: "Static Types",
1090
- onClick: handleCreateData
1091
- }), /* @__PURE__ */ React2.createElement(SchemaTable, {
1092
- types: recordTypes,
1093
- objects: info.objects,
1094
- label: "Record Types",
1095
- onClick: handleCreateData
1096
- }), /* @__PURE__ */ React2.createElement(SchemaTable, {
1097
- types: presets.types,
1098
- objects: info.objects,
1099
- label: "Presets",
1100
- onClick: handleCreateData
1101
- }), /* @__PURE__ */ React2.createElement("div", null, /* @__PURE__ */ React2.createElement(SyntaxHighlighter, {
1102
- language: "json",
1103
- classNames: "text-xs"
1104
- }, JSON.stringify({
1105
- space,
1106
- ...info
1107
- }, jsonKeyReplacer({
1108
- truncate: true
1109
- }), 2)))));
1110
- } finally {
1111
- _effect.f();
1112
- }
1073
+ return map;
1074
+ }, {}));
1075
+ setInfo({
1076
+ schema: {
1077
+ static: staticSchema.length,
1078
+ mutable: echoSchema.length
1079
+ },
1080
+ objects: objectMap
1081
+ });
1082
+ };
1083
+ useAsyncEffect(updateInfo, [
1084
+ space
1085
+ ]);
1086
+ const handleCreateData = useCallback(async (typename) => {
1087
+ const constructor = typeMap.get(typename);
1088
+ if (constructor) {
1089
+ await constructor(space, count, onCreateObjects);
1090
+ await updateInfo();
1091
+ }
1092
+ }, [
1093
+ typeMap,
1094
+ count
1095
+ ]);
1096
+ return /* @__PURE__ */ React2.createElement("div", {
1097
+ role: "none",
1098
+ className: "flex flex-col grow overflow-hidden"
1099
+ }, /* @__PURE__ */ React2.createElement(Toolbar.Root, {
1100
+ classNames: "border-be border-subduedSeparator"
1101
+ }, /* @__PURE__ */ React2.createElement(IconButton2, {
1102
+ icon: "ph--arrow-clockwise--regular",
1103
+ iconOnly: true,
1104
+ label: "Refresh",
1105
+ onClick: updateInfo
1106
+ }), /* @__PURE__ */ React2.createElement(Toolbar.Separator, {
1107
+ variant: "gap"
1108
+ }), /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
1109
+ type: "number",
1110
+ min: 1,
1111
+ max: 100,
1112
+ placeholder: "Count",
1113
+ classNames: "!w-[4rem] !text-right",
1114
+ size: 8,
1115
+ value: count,
1116
+ onChange: (ev) => setCount(parseInt(ev.target.value))
1117
+ }))), /* @__PURE__ */ React2.createElement("div", {
1118
+ className: "flex flex-col overflow-y-auto divide-y divide-separator"
1119
+ }, /* @__PURE__ */ React2.createElement(SchemaTable, {
1120
+ types: staticTypes,
1121
+ objects: info.objects,
1122
+ label: "Static Types",
1123
+ onClick: handleCreateData
1124
+ }), /* @__PURE__ */ React2.createElement(SchemaTable, {
1125
+ types: recordTypes,
1126
+ objects: info.objects,
1127
+ label: "Record Types",
1128
+ onClick: handleCreateData
1129
+ }), /* @__PURE__ */ React2.createElement(SchemaTable, {
1130
+ types: presets.types,
1131
+ objects: info.objects,
1132
+ label: "Presets",
1133
+ onClick: handleCreateData
1134
+ }), /* @__PURE__ */ React2.createElement("div", null, /* @__PURE__ */ React2.createElement(SyntaxHighlighter, {
1135
+ language: "json",
1136
+ classNames: "text-xs"
1137
+ }, JSON.stringify({
1138
+ space,
1139
+ ...info
1140
+ }, jsonKeyReplacer({
1141
+ truncate: true
1142
+ }), 2)))));
1113
1143
  };
1114
1144
 
1115
1145
  // src/components/SpaceGenerator/index.ts
@@ -1117,4 +1147,4 @@ var SpaceGenerator_default = SpaceGenerator;
1117
1147
  export {
1118
1148
  SpaceGenerator_default as default
1119
1149
  };
1120
- //# sourceMappingURL=SpaceGenerator-SB2YRVRT.mjs.map
1150
+ //# sourceMappingURL=SpaceGenerator-ZHVZWGM7.mjs.map