@dxos/plugin-debug 0.10.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PLUGIN.mdl +12 -325
- package/README.md +4 -14
- package/dist/lib/DebugPlugin.mjs +29 -0
- package/dist/lib/DebugPlugin.mjs.map +1 -0
- package/dist/lib/DebugPlugin.node.mjs +10 -0
- package/dist/lib/DebugPlugin.node.mjs.map +1 -0
- package/dist/lib/DebugPlugin.workerd.mjs +8 -0
- package/dist/lib/DebugPlugin.workerd.mjs.map +1 -0
- package/dist/lib/capabilities.mjs +11 -0
- package/dist/lib/capabilities.mjs.map +1 -0
- package/dist/lib/chunk-DebugObjectPanel.mjs +58 -0
- package/dist/lib/chunk-DebugObjectPanel.mjs.map +1 -0
- package/dist/lib/chunk-DebugSettings.mjs +237 -0
- package/dist/lib/chunk-DebugSettings.mjs.map +1 -0
- package/dist/lib/chunk-DebugSpaceObjectsPanel.mjs +39 -0
- package/dist/lib/chunk-DebugSpaceObjectsPanel.mjs.map +1 -0
- package/dist/lib/chunk-DebugStatus.mjs +117 -0
- package/dist/lib/chunk-DebugStatus.mjs.map +1 -0
- package/dist/lib/chunk-LogStatus.mjs +44 -0
- package/dist/lib/chunk-LogStatus.mjs.map +1 -0
- package/dist/lib/chunk-SpaceGenerator.mjs +208 -0
- package/dist/lib/chunk-SpaceGenerator.mjs.map +1 -0
- package/dist/lib/chunk-StatsPanel.mjs +58 -0
- package/dist/lib/chunk-StatsPanel.mjs.map +1 -0
- package/dist/lib/chunk-Wireframe.mjs +60 -0
- package/dist/lib/chunk-Wireframe.mjs.map +1 -0
- package/dist/lib/chunk-app-graph-builder.mjs +76 -0
- package/dist/lib/chunk-app-graph-builder.mjs.map +1 -0
- package/dist/lib/chunk-log-recording.mjs +17 -0
- package/dist/lib/chunk-log-recording.mjs.map +1 -0
- package/dist/lib/chunk-meta.mjs +36 -0
- package/dist/lib/chunk-meta.mjs.map +1 -0
- package/dist/lib/chunk-react-surface.mjs +193 -0
- package/dist/lib/chunk-react-surface.mjs.map +1 -0
- package/dist/lib/chunk-settings.mjs +23 -0
- package/dist/lib/chunk-settings.mjs.map +1 -0
- package/dist/lib/chunk-stats-panel.mjs +56 -0
- package/dist/lib/chunk-stats-panel.mjs.map +1 -0
- package/dist/lib/chunk-types.mjs +60 -0
- package/dist/lib/chunk-types.mjs.map +1 -0
- package/dist/lib/components.mjs +763 -0
- package/dist/lib/components.mjs.map +1 -0
- package/dist/lib/containers.mjs +14 -0
- package/dist/lib/containers.mjs.map +1 -0
- package/dist/lib/index.mjs +3 -0
- package/dist/lib/meta.mjs +2 -0
- package/dist/lib/plugin.mjs +8 -0
- package/dist/lib/plugin.mjs.map +1 -0
- package/dist/lib/translations.mjs +38 -0
- package/dist/lib/translations.mjs.map +1 -0
- package/dist/lib/types.mjs +2 -0
- package/dist/types/src/DebugPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/DebugSurfaces.d.ts +25 -0
- package/dist/types/src/capabilities/DebugSurfaces.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
- package/dist/types/src/capabilities/index.d.ts +4 -1
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/log-recording.d.ts +10 -0
- package/dist/types/src/capabilities/log-recording.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts +1 -1
- package/dist/types/src/capabilities/stats-panel.d.ts +16 -0
- package/dist/types/src/capabilities/stats-panel.d.ts.map +1 -0
- package/dist/types/src/components/SchemaTable/SchemaTable.d.ts +4 -3
- package/dist/types/src/components/SchemaTable/SchemaTable.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
- package/dist/types/src/containers/DebugObjectPanel/DebugObjectPanel.d.ts +4 -1
- package/dist/types/src/containers/DebugObjectPanel/DebugObjectPanel.d.ts.map +1 -1
- package/dist/types/src/containers/DebugSettings/DebugSettings.d.ts +4 -1
- package/dist/types/src/containers/DebugSettings/DebugSettings.d.ts.map +1 -1
- package/dist/types/src/containers/DebugSettings/DebugSettings.stories.d.ts +30 -58
- package/dist/types/src/containers/DebugSettings/DebugSettings.stories.d.ts.map +1 -1
- package/dist/types/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.d.ts +4 -1
- package/dist/types/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.d.ts.map +1 -1
- package/dist/types/src/containers/DebugStatus/DebugStatus.d.ts +4 -1
- package/dist/types/src/containers/DebugStatus/DebugStatus.d.ts.map +1 -1
- package/dist/types/src/containers/LogStatus/LogStatus.d.ts +6 -0
- package/dist/types/src/containers/LogStatus/LogStatus.d.ts.map +1 -0
- package/dist/types/src/containers/LogStatus/index.d.ts +2 -0
- package/dist/types/src/containers/LogStatus/index.d.ts.map +1 -0
- package/dist/types/src/containers/SpaceGenerator/SpaceGenerator.d.ts +1 -1
- package/dist/types/src/containers/SpaceGenerator/SpaceGenerator.d.ts.map +1 -1
- package/dist/types/src/containers/StatsPanel/StatsPanel.d.ts +6 -0
- package/dist/types/src/containers/StatsPanel/StatsPanel.d.ts.map +1 -0
- package/dist/types/src/containers/StatsPanel/index.d.ts +2 -0
- package/dist/types/src/containers/StatsPanel/index.d.ts.map +1 -0
- package/dist/types/src/containers/Wireframe/Wireframe.d.ts +4 -1
- package/dist/types/src/containers/Wireframe/Wireframe.d.ts.map +1 -1
- package/dist/types/src/containers/index.d.ts +4 -6
- package/dist/types/src/containers/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +26 -57
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/DebugNodes.d.ts +7 -0
- package/dist/types/src/types/DebugNodes.d.ts.map +1 -0
- package/dist/types/src/types/DebugSurface.d.ts +8 -0
- package/dist/types/src/types/DebugSurface.d.ts.map +1 -0
- package/dist/types/src/types/debug.d.ts +3 -1
- package/dist/types/src/types/debug.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +2 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dx.config.ts +8 -13
- package/package.json +61 -63
- package/src/DebugPlugin.node.ts +1 -1
- package/src/DebugPlugin.tsx +10 -27
- package/src/DebugPlugin.workerd.ts +1 -1
- package/src/capabilities/DebugSurfaces.tsx +146 -0
- package/src/capabilities/app-graph-builder.ts +39 -373
- package/src/capabilities/index.ts +3 -2
- package/src/capabilities/log-recording.ts +20 -0
- package/src/capabilities/react-surface.ts +123 -0
- package/src/capabilities/stats-panel.ts +74 -0
- package/src/components/SchemaTable/SchemaTable.tsx +6 -5
- package/src/components/SpaceGenerator/ObjectGenerator.tsx +9 -3
- package/src/components/SpaceGenerator/presets.ts +2 -2
- package/src/components/index.ts +1 -1
- package/src/containers/DebugObjectPanel/DebugObjectPanel.tsx +20 -20
- package/src/containers/DebugSettings/DebugSettings.tsx +4 -3
- package/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.tsx +4 -2
- package/src/containers/DebugStatus/DebugStatus.tsx +2 -0
- package/src/containers/LogStatus/LogStatus.tsx +51 -0
- package/src/containers/LogStatus/index.ts +5 -0
- package/src/containers/SpaceGenerator/SpaceGenerator.tsx +108 -10
- package/src/containers/StatsPanel/StatsPanel.tsx +74 -0
- package/src/containers/StatsPanel/index.ts +5 -0
- package/src/containers/Wireframe/Wireframe.tsx +2 -0
- package/src/containers/index.ts +9 -7
- package/src/index.ts +1 -1
- package/src/meta.ts +1 -1
- package/src/plugin.ts +1 -1
- package/src/translations.ts +8 -52
- package/src/types/DebugNodes.ts +18 -0
- package/src/types/DebugSurface.ts +16 -0
- package/src/types/debug.ts +3 -1
- package/src/types/index.ts +3 -3
- package/dist/lib/neutral/DebugGraph-G4FWS57E.mjs +0 -15
- package/dist/lib/neutral/DebugGraph-G4FWS57E.mjs.map +0 -7
- package/dist/lib/neutral/DebugObjectPanel-QSGQJ3LM.mjs +0 -61
- package/dist/lib/neutral/DebugObjectPanel-QSGQJ3LM.mjs.map +0 -7
- package/dist/lib/neutral/DebugPlugin.mjs +0 -59
- package/dist/lib/neutral/DebugPlugin.mjs.map +0 -7
- package/dist/lib/neutral/DebugPlugin.node.mjs +0 -18
- package/dist/lib/neutral/DebugPlugin.node.mjs.map +0 -7
- package/dist/lib/neutral/DebugPlugin.workerd.mjs +0 -12
- package/dist/lib/neutral/DebugPlugin.workerd.mjs.map +0 -7
- package/dist/lib/neutral/DebugSettings-Q3WUL6YQ.mjs +0 -229
- package/dist/lib/neutral/DebugSettings-Q3WUL6YQ.mjs.map +0 -7
- package/dist/lib/neutral/DebugSpaceObjectsPanel-AXFZWEIM.mjs +0 -36
- package/dist/lib/neutral/DebugSpaceObjectsPanel-AXFZWEIM.mjs.map +0 -7
- package/dist/lib/neutral/DebugStatus-H2BAHN26.mjs +0 -122
- package/dist/lib/neutral/DebugStatus-H2BAHN26.mjs.map +0 -7
- package/dist/lib/neutral/DevtoolsOverviewContainer-DWQHTK7D.mjs +0 -24
- package/dist/lib/neutral/DevtoolsOverviewContainer-DWQHTK7D.mjs.map +0 -7
- package/dist/lib/neutral/GithubPanel-4CSJRVKE.mjs +0 -177
- package/dist/lib/neutral/GithubPanel-4CSJRVKE.mjs.map +0 -7
- package/dist/lib/neutral/RegistryPanel-64GIYJHN.mjs +0 -161
- package/dist/lib/neutral/RegistryPanel-64GIYJHN.mjs.map +0 -7
- package/dist/lib/neutral/SpaceGenerator-Y35G6DRV.mjs +0 -146
- package/dist/lib/neutral/SpaceGenerator-Y35G6DRV.mjs.map +0 -7
- package/dist/lib/neutral/Wireframe-WD7S2AUU.mjs +0 -52
- package/dist/lib/neutral/Wireframe-WD7S2AUU.mjs.map +0 -7
- package/dist/lib/neutral/app-graph-builder-UKG4WVYK.mjs +0 -619
- package/dist/lib/neutral/app-graph-builder-UKG4WVYK.mjs.map +0 -7
- package/dist/lib/neutral/capabilities/index.mjs +0 -15
- package/dist/lib/neutral/capabilities/index.mjs.map +0 -7
- package/dist/lib/neutral/chunk-72QXLYMI.mjs +0 -118
- package/dist/lib/neutral/chunk-72QXLYMI.mjs.map +0 -7
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +0 -10
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +0 -7
- package/dist/lib/neutral/chunk-R5C4CKOF.mjs +0 -54
- package/dist/lib/neutral/chunk-R5C4CKOF.mjs.map +0 -7
- package/dist/lib/neutral/components/index.mjs +0 -961
- package/dist/lib/neutral/components/index.mjs.map +0 -7
- package/dist/lib/neutral/containers/index.mjs +0 -27
- package/dist/lib/neutral/containers/index.mjs.map +0 -7
- package/dist/lib/neutral/index.mjs +0 -20
- package/dist/lib/neutral/index.mjs.map +0 -7
- package/dist/lib/neutral/meta.json +0 -1
- package/dist/lib/neutral/meta.mjs +0 -8
- package/dist/lib/neutral/meta.mjs.map +0 -7
- package/dist/lib/neutral/plugin.mjs +0 -12
- package/dist/lib/neutral/plugin.mjs.map +0 -7
- package/dist/lib/neutral/react-context-UJURDOO6.mjs +0 -17
- package/dist/lib/neutral/react-context-UJURDOO6.mjs.map +0 -7
- package/dist/lib/neutral/react-surface-URESE7J4.mjs +0 -484
- package/dist/lib/neutral/react-surface-URESE7J4.mjs.map +0 -7
- package/dist/lib/neutral/settings-5I2674B6.mjs +0 -28
- package/dist/lib/neutral/settings-5I2674B6.mjs.map +0 -7
- package/dist/lib/neutral/translations.mjs +0 -91
- package/dist/lib/neutral/translations.mjs.map +0 -7
- package/dist/lib/neutral/types/index.mjs +0 -16
- package/dist/lib/neutral/types/index.mjs.map +0 -7
- package/dist/types/src/DebugPlugin.test.d.ts +0 -2
- package/dist/types/src/DebugPlugin.test.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-context.d.ts +0 -5
- package/dist/types/src/capabilities/react-context.d.ts.map +0 -1
- package/dist/types/src/containers/DebugGraph/DebugGraph.d.ts +0 -8
- package/dist/types/src/containers/DebugGraph/DebugGraph.d.ts.map +0 -1
- package/dist/types/src/containers/DebugGraph/index.d.ts +0 -2
- package/dist/types/src/containers/DebugGraph/index.d.ts.map +0 -1
- package/dist/types/src/containers/DevtoolsOverviewContainer/DevtoolsOverviewContainer.d.ts +0 -3
- package/dist/types/src/containers/DevtoolsOverviewContainer/DevtoolsOverviewContainer.d.ts.map +0 -1
- package/dist/types/src/containers/DevtoolsOverviewContainer/index.d.ts +0 -2
- package/dist/types/src/containers/DevtoolsOverviewContainer/index.d.ts.map +0 -1
- package/dist/types/src/containers/GithubPanel/GithubComponent.d.ts +0 -15
- package/dist/types/src/containers/GithubPanel/GithubComponent.d.ts.map +0 -1
- package/dist/types/src/containers/GithubPanel/GithubComponent.stories.d.ts +0 -106
- package/dist/types/src/containers/GithubPanel/GithubComponent.stories.d.ts.map +0 -1
- package/dist/types/src/containers/GithubPanel/GithubPanel.d.ts +0 -3
- package/dist/types/src/containers/GithubPanel/GithubPanel.d.ts.map +0 -1
- package/dist/types/src/containers/GithubPanel/index.d.ts +0 -2
- package/dist/types/src/containers/GithubPanel/index.d.ts.map +0 -1
- package/dist/types/src/containers/RegistryPanel/RegistryPanel.d.ts +0 -3
- package/dist/types/src/containers/RegistryPanel/RegistryPanel.d.ts.map +0 -1
- package/dist/types/src/containers/RegistryPanel/index.d.ts +0 -2
- package/dist/types/src/containers/RegistryPanel/index.d.ts.map +0 -1
- package/dist/types/src/types/Devtools.d.ts +0 -57
- package/dist/types/src/types/Devtools.d.ts.map +0 -1
- package/dist/types/src/types/surface.d.ts +0 -4
- package/dist/types/src/types/surface.d.ts.map +0 -1
- package/src/DebugPlugin.test.ts +0 -29
- package/src/capabilities/react-context.tsx +0 -25
- package/src/capabilities/react-surface.tsx +0 -504
- package/src/containers/DebugGraph/DebugGraph.tsx +0 -14
- package/src/containers/DebugGraph/index.ts +0 -5
- package/src/containers/DevtoolsOverviewContainer/DevtoolsOverviewContainer.tsx +0 -27
- package/src/containers/DevtoolsOverviewContainer/index.ts +0 -5
- package/src/containers/GithubPanel/GithubComponent.stories.tsx +0 -38
- package/src/containers/GithubPanel/GithubComponent.tsx +0 -192
- package/src/containers/GithubPanel/GithubPanel.tsx +0 -17
- package/src/containers/GithubPanel/index.ts +0 -5
- package/src/containers/RegistryPanel/RegistryPanel.tsx +0 -150
- package/src/containers/RegistryPanel/index.ts +0 -5
- package/src/types/Devtools.ts +0 -73
- package/src/types/surface.ts +0 -10
|
@@ -1,961 +0,0 @@
|
|
|
1
|
-
import "../chunk-J5LGTIGS.mjs";
|
|
2
|
-
|
|
3
|
-
// src/components/SchemaTable/SchemaTable.tsx
|
|
4
|
-
import React from "react";
|
|
5
|
-
import { IconButton } from "@dxos/react-ui";
|
|
6
|
-
var SchemaTable = ({ types, objects = {}, label, onClick }) => {
|
|
7
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
8
|
-
className: "grid grid-cols-[1fr_80px_40px] gap-1 overflow-none"
|
|
9
|
-
}, /* @__PURE__ */ React.createElement("h2", {
|
|
10
|
-
className: "p-2"
|
|
11
|
-
}, label), types.map((type) => /* @__PURE__ */ React.createElement("div", {
|
|
12
|
-
key: type.typename,
|
|
13
|
-
className: "grid grid-cols-subgrid col-span-3 items-center"
|
|
14
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
15
|
-
className: "px-2 text-sm font-mono text-subdued"
|
|
16
|
-
}, type.typename), /* @__PURE__ */ React.createElement("div", {
|
|
17
|
-
className: "px-2 text-right font-mono"
|
|
18
|
-
}, objects[type.typename] ?? 0), /* @__PURE__ */ React.createElement(IconButton, {
|
|
19
|
-
variant: "ghost",
|
|
20
|
-
icon: "ph--plus--regular",
|
|
21
|
-
iconOnly: true,
|
|
22
|
-
label: "Create data",
|
|
23
|
-
onClick: () => onClick(type.typename)
|
|
24
|
-
}))));
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// src/components/SpaceGenerator/presets.ts
|
|
28
|
-
import * as Schema from "effect/Schema";
|
|
29
|
-
import { RunInstructions, WebSearchSkill } from "@dxos/assistant-toolkit";
|
|
30
|
-
import { Instructions, Operation, Trigger } from "@dxos/compute";
|
|
31
|
-
import { NODE_INPUT } from "@dxos/conductor";
|
|
32
|
-
import { Feed, Filter, JsonSchema, Key, Obj, Query, Ref, Scope, Tag } from "@dxos/echo";
|
|
33
|
-
import { invariant } from "@dxos/invariant";
|
|
34
|
-
import { DXN, EID } from "@dxos/keys";
|
|
35
|
-
import { InboxOperation } from "@dxos/plugin-inbox";
|
|
36
|
-
import { Mailbox } from "@dxos/plugin-inbox";
|
|
37
|
-
import { Markdown } from "@dxos/plugin-markdown";
|
|
38
|
-
import { createAppend, createChat, createComputeGraph, createConstant, createFeed, createFunction, createGpt, createRandom, createSurface, createTemplate, createText, createTrigger } from "@dxos/react-ui-canvas-compute";
|
|
39
|
-
import { CanvasBoard, CanvasGraphModel, pointMultiply, pointsToRect, rectToPoints } from "@dxos/react-ui-canvas-editor";
|
|
40
|
-
import { ViewModel } from "@dxos/schema";
|
|
41
|
-
import { Message, Organization, Person, Pipeline } from "@dxos/types";
|
|
42
|
-
import { range, trim } from "@dxos/util";
|
|
43
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-debug/src/components/SpaceGenerator/presets.ts";
|
|
44
|
-
var PresetName = /* @__PURE__ */ (function(PresetName2) {
|
|
45
|
-
PresetName2["DXOS_TEAM"] = "dxos-team";
|
|
46
|
-
PresetName2["ORG_RESEARCH_PROJECT"] = "org-research-project";
|
|
47
|
-
PresetName2["GPT_QUEUE"] = "webhook-gpt-queue";
|
|
48
|
-
PresetName2["CHAT_GPT"] = "chat-gpt-text";
|
|
49
|
-
PresetName2["OBJECT_CHANGE_QUEUE"] = "objectChange-queue";
|
|
50
|
-
PresetName2["TIMER_TICK_QUEUE"] = "timerTick-queue";
|
|
51
|
-
PresetName2["FOREX_FUNCTION_CALL"] = "forex-function-call";
|
|
52
|
-
PresetName2["DISCORD_MESSAGES"] = "discord-messages";
|
|
53
|
-
return PresetName2;
|
|
54
|
-
})({});
|
|
55
|
-
var generator = () => ({
|
|
56
|
-
schemas: [
|
|
57
|
-
CanvasBoard.CanvasBoard,
|
|
58
|
-
Trigger.Trigger
|
|
59
|
-
],
|
|
60
|
-
types: Object.values(PresetName).map((name) => ({
|
|
61
|
-
typename: name
|
|
62
|
-
})),
|
|
63
|
-
items: [
|
|
64
|
-
[
|
|
65
|
-
"dxos-team",
|
|
66
|
-
async (space, n, cb) => {
|
|
67
|
-
const objects = range(n, () => {
|
|
68
|
-
const org = space.db.add(Obj.make(Organization.Organization, {
|
|
69
|
-
name: "DXOS",
|
|
70
|
-
website: "https://dxos.org"
|
|
71
|
-
}));
|
|
72
|
-
const doc = space.db.add(Markdown.make({
|
|
73
|
-
name: "DXOS Research",
|
|
74
|
-
content: "DXOS builds Composer, an open-source AI-powered malleable application."
|
|
75
|
-
}));
|
|
76
|
-
const tag = space.db.add(Tag.make({
|
|
77
|
-
label: "Investor"
|
|
78
|
-
}));
|
|
79
|
-
const tagRef = Ref.make(tag);
|
|
80
|
-
Obj.update(doc, (doc2) => {
|
|
81
|
-
Obj.getMeta(doc2).tags = [
|
|
82
|
-
tagRef
|
|
83
|
-
];
|
|
84
|
-
});
|
|
85
|
-
space.db.add(Obj.make(Person.Person, {
|
|
86
|
-
[Obj.Meta]: {
|
|
87
|
-
tags: [
|
|
88
|
-
tagRef
|
|
89
|
-
]
|
|
90
|
-
},
|
|
91
|
-
fullName: "Rich",
|
|
92
|
-
organization: Ref.make(org)
|
|
93
|
-
}));
|
|
94
|
-
space.db.add(Obj.make(Person.Person, {
|
|
95
|
-
fullName: "Josiah",
|
|
96
|
-
organization: Ref.make(org)
|
|
97
|
-
}));
|
|
98
|
-
space.db.add(Obj.make(Person.Person, {
|
|
99
|
-
fullName: "Dima",
|
|
100
|
-
organization: Ref.make(org)
|
|
101
|
-
}));
|
|
102
|
-
space.db.add(Obj.make(Person.Person, {
|
|
103
|
-
fullName: "Mykola",
|
|
104
|
-
organization: Ref.make(org)
|
|
105
|
-
}));
|
|
106
|
-
return doc;
|
|
107
|
-
});
|
|
108
|
-
cb?.(objects);
|
|
109
|
-
return objects;
|
|
110
|
-
}
|
|
111
|
-
],
|
|
112
|
-
[
|
|
113
|
-
"org-research-project",
|
|
114
|
-
async (space, n, cb) => {
|
|
115
|
-
const mailboxes = await space.db.query(Filter.type(Mailbox.Mailbox)).run();
|
|
116
|
-
const mailbox = mailboxes[0];
|
|
117
|
-
invariant(mailbox, "Mailbox not found", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 101, S: void 0, A: ["mailbox", "'Mailbox not found'"] });
|
|
118
|
-
const mailboxFeed = await mailbox.feed?.tryLoad();
|
|
119
|
-
invariant(mailboxFeed, "Mailbox missing feed reference", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 103, S: void 0, A: ["mailboxFeed", "'Mailbox missing feed reference'"] });
|
|
120
|
-
const queueDxn = Feed.getQueueUri(mailboxFeed);
|
|
121
|
-
invariant(queueDxn, "Mailbox feed missing queue DXN key", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 105, S: void 0, A: ["queueDxn", "'Mailbox feed missing queue DXN key'"] });
|
|
122
|
-
const tag = await space.db.query(Filter.type(Tag.Tag, {
|
|
123
|
-
label: "Investor"
|
|
124
|
-
})).first();
|
|
125
|
-
const tagUri = Obj.getURI(tag);
|
|
126
|
-
const objects = range(n, () => {
|
|
127
|
-
const contactsQuery = Query.select(Filter.type(Person.Person)).select(Filter.tag(tagUri));
|
|
128
|
-
const organizationsQuery = Query.select(Filter.type(Organization.Organization)).select(Filter.tag(tagUri));
|
|
129
|
-
const notesQuery = Query.select(Filter.type(Markdown.Document)).select(Filter.tag(tagUri));
|
|
130
|
-
space.db.add(Trigger.make({
|
|
131
|
-
enabled: true,
|
|
132
|
-
spec: Trigger.specTimer("* * * * *"),
|
|
133
|
-
runnable: Ref.make(Operation.serialize(InboxOperation.GoogleMailSync)),
|
|
134
|
-
input: {
|
|
135
|
-
mailbox: Ref.make(mailbox)
|
|
136
|
-
}
|
|
137
|
-
}));
|
|
138
|
-
const researchPrompt = space.db.add(Instructions.make({
|
|
139
|
-
name: "Research",
|
|
140
|
-
description: "Research organization",
|
|
141
|
-
// TODO(dmaretskyi): This mocks research (returns pre-baked result), the actual research might take compute minutes.
|
|
142
|
-
// Remove the mock prompt to do the actual research.
|
|
143
|
-
text: trim`
|
|
144
|
-
Research the organization provided as input.
|
|
145
|
-
Create a research note for it at the end.
|
|
146
|
-
NOTE: Do mocked reseach (set mockSearch to true).
|
|
147
|
-
`,
|
|
148
|
-
skills: [
|
|
149
|
-
Ref.make(WebSearchSkill.make())
|
|
150
|
-
]
|
|
151
|
-
}));
|
|
152
|
-
space.db.add(Trigger.make({
|
|
153
|
-
enabled: true,
|
|
154
|
-
spec: Trigger.specSubscription(organizationsQuery),
|
|
155
|
-
runnable: Ref.make(Operation.serialize(RunInstructions)),
|
|
156
|
-
input: {
|
|
157
|
-
instructions: Ref.make(researchPrompt),
|
|
158
|
-
input: "{{event.subject}}"
|
|
159
|
-
}
|
|
160
|
-
}));
|
|
161
|
-
const mailboxView = ViewModel.make({
|
|
162
|
-
query: Query.select(Filter.type(Message.Message, {
|
|
163
|
-
properties: {
|
|
164
|
-
labels: Filter.contains("investor")
|
|
165
|
-
}
|
|
166
|
-
})).from(Scope.feed(Obj.getURI(mailboxFeed))),
|
|
167
|
-
jsonSchema: JsonSchema.toJsonSchema(Message.Message)
|
|
168
|
-
});
|
|
169
|
-
const contactsView = ViewModel.make({
|
|
170
|
-
query: contactsQuery,
|
|
171
|
-
jsonSchema: JsonSchema.toJsonSchema(Person.Person)
|
|
172
|
-
});
|
|
173
|
-
const organizationsView = ViewModel.make({
|
|
174
|
-
query: organizationsQuery,
|
|
175
|
-
jsonSchema: JsonSchema.toJsonSchema(Organization.Organization)
|
|
176
|
-
});
|
|
177
|
-
const notesView = ViewModel.make({
|
|
178
|
-
query: notesQuery,
|
|
179
|
-
jsonSchema: JsonSchema.toJsonSchema(Markdown.Document)
|
|
180
|
-
});
|
|
181
|
-
return space.db.add(Pipeline.make({
|
|
182
|
-
name: "Investor Research",
|
|
183
|
-
columns: [
|
|
184
|
-
{
|
|
185
|
-
name: "Mailbox",
|
|
186
|
-
view: Ref.make(mailboxView),
|
|
187
|
-
order: []
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
name: "Contacts",
|
|
191
|
-
view: Ref.make(contactsView),
|
|
192
|
-
order: []
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
name: "Organizations",
|
|
196
|
-
view: Ref.make(organizationsView),
|
|
197
|
-
order: []
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
name: "Notes",
|
|
201
|
-
view: Ref.make(notesView),
|
|
202
|
-
order: []
|
|
203
|
-
}
|
|
204
|
-
]
|
|
205
|
-
}));
|
|
206
|
-
});
|
|
207
|
-
cb?.(objects.flat());
|
|
208
|
-
return objects.flat();
|
|
209
|
-
}
|
|
210
|
-
],
|
|
211
|
-
[
|
|
212
|
-
"webhook-gpt-queue",
|
|
213
|
-
async (space, n, cb) => {
|
|
214
|
-
const objects = range(n, () => {
|
|
215
|
-
const canvasModel = CanvasGraphModel.create();
|
|
216
|
-
let functionTrigger;
|
|
217
|
-
canvasModel.builder.call((builder) => {
|
|
218
|
-
const gpt = canvasModel.createNode(createGpt(position({
|
|
219
|
-
x: 0,
|
|
220
|
-
y: -14
|
|
221
|
-
})));
|
|
222
|
-
const triggerShape = createTrigger({
|
|
223
|
-
spaceId: space.id,
|
|
224
|
-
triggerKind: "webhook",
|
|
225
|
-
...position({
|
|
226
|
-
x: -18,
|
|
227
|
-
y: -2
|
|
228
|
-
})
|
|
229
|
-
});
|
|
230
|
-
const trigger = canvasModel.createNode(triggerShape);
|
|
231
|
-
const text = canvasModel.createNode(createText(position({
|
|
232
|
-
x: 19,
|
|
233
|
-
y: 3,
|
|
234
|
-
width: 10,
|
|
235
|
-
height: 10
|
|
236
|
-
})));
|
|
237
|
-
const { queueId } = setupQueue(space, canvasModel);
|
|
238
|
-
const append = canvasModel.createNode(createAppend(position({
|
|
239
|
-
x: 10,
|
|
240
|
-
y: 6
|
|
241
|
-
})));
|
|
242
|
-
builder.createEdge({
|
|
243
|
-
source: trigger.id,
|
|
244
|
-
target: gpt.id,
|
|
245
|
-
input: "prompt",
|
|
246
|
-
output: "bodyText"
|
|
247
|
-
}).createEdge({
|
|
248
|
-
source: gpt.id,
|
|
249
|
-
target: text.id,
|
|
250
|
-
output: "text"
|
|
251
|
-
}).createEdge({
|
|
252
|
-
source: queueId.id,
|
|
253
|
-
target: append.id,
|
|
254
|
-
input: "id"
|
|
255
|
-
}).createEdge({
|
|
256
|
-
source: gpt.id,
|
|
257
|
-
target: append.id,
|
|
258
|
-
output: "messages",
|
|
259
|
-
input: "items"
|
|
260
|
-
});
|
|
261
|
-
functionTrigger = triggerShape.functionTrigger.target;
|
|
262
|
-
});
|
|
263
|
-
const computeModel = createComputeGraph(canvasModel);
|
|
264
|
-
attachTrigger(functionTrigger, computeModel);
|
|
265
|
-
return addToSpace("webhook-gpt-queue", space, canvasModel, computeModel);
|
|
266
|
-
});
|
|
267
|
-
cb?.(objects);
|
|
268
|
-
return objects;
|
|
269
|
-
}
|
|
270
|
-
],
|
|
271
|
-
[
|
|
272
|
-
"objectChange-queue",
|
|
273
|
-
async (space, n, cb) => {
|
|
274
|
-
const objects = range(n, () => {
|
|
275
|
-
const { canvasModel, computeModel } = createQueueSinkPreset(space, "subscription", (triggerSpec) => triggerSpec.query = {
|
|
276
|
-
ast: Query.select(Filter.type(DXN.make("org.dxos.type.chess"))).ast
|
|
277
|
-
}, "type");
|
|
278
|
-
return addToSpace("objectChange-queue", space, canvasModel, computeModel);
|
|
279
|
-
});
|
|
280
|
-
cb?.(objects);
|
|
281
|
-
return objects;
|
|
282
|
-
}
|
|
283
|
-
],
|
|
284
|
-
[
|
|
285
|
-
"timerTick-queue",
|
|
286
|
-
async (space, n, cb) => {
|
|
287
|
-
const objects = range(n, () => {
|
|
288
|
-
const { canvasModel, computeModel } = createQueueSinkPreset(space, "timer", (triggerSpec) => triggerSpec.cron = "*/5 * * * * *", "result");
|
|
289
|
-
return addToSpace("timerTick-queue", space, canvasModel, computeModel);
|
|
290
|
-
});
|
|
291
|
-
cb?.(objects);
|
|
292
|
-
return objects;
|
|
293
|
-
}
|
|
294
|
-
],
|
|
295
|
-
// TODO(wittjosiah): Remove?
|
|
296
|
-
// [
|
|
297
|
-
// PresetName.EMAIL_TABLE,
|
|
298
|
-
// async (space, n, cb) => {
|
|
299
|
-
// const objects = range(n, () => {
|
|
300
|
-
// const canvasModel = CanvasGraphModel.create<ComputeShape>();
|
|
301
|
-
// const results = space.db.query(Filter.type(TableType)).runSync();
|
|
302
|
-
// const emailTable = results.find((r) => r.object?.view?.target?.query?.typename?.endsWith('Email'));
|
|
303
|
-
// invariant(emailTable, 'Email table not found.');
|
|
304
|
-
// const template = canvasModel.createNode(
|
|
305
|
-
// createTemplate({
|
|
306
|
-
// valueType: 'object',
|
|
307
|
-
// ...rawPosition({ centerX: -80, centerY: -64, width: 320, height: 320 }),
|
|
308
|
-
// }),
|
|
309
|
-
// );
|
|
310
|
-
// const templateContent = ['{'];
|
|
311
|
-
// let functionTrigger: FunctionTrigger | undefined;
|
|
312
|
-
// canvasModel.builder.call((builder) => {
|
|
313
|
-
// const triggerShape = createTrigger({
|
|
314
|
-
// spaceId: space.id,
|
|
315
|
-
// triggerKind: 'email',
|
|
316
|
-
// ...position({ x: -18, y: -2 }),
|
|
317
|
-
// });
|
|
318
|
-
// const trigger = canvasModel.createNode(triggerShape);
|
|
319
|
-
// const tableId = canvasModel.createNode(
|
|
320
|
-
// createConstant({
|
|
321
|
-
// value: DXN.fromLocalObjectId(emailTable.id).toString(),
|
|
322
|
-
// ...position({ x: -18, y: 5, width: 8, height: 6 }),
|
|
323
|
-
// }),
|
|
324
|
-
// );
|
|
325
|
-
// const appendToTable = canvasModel.createNode(createAppend(position({ x: 10, y: 6 })));
|
|
326
|
-
// const properties = SchemaAST.getPropertySignatures(EmailTriggerOutput.ast);
|
|
327
|
-
// for (let i = 0; i < properties.length; i++) {
|
|
328
|
-
// const propName = properties[i].name.toString();
|
|
329
|
-
// builder.createEdge({ source: trigger.id, target: template.id, input: propName, output: propName });
|
|
330
|
-
// templateContent.push(` "${propName}": "{{${propName}}}"` + (i === properties.length - 1 ? '' : ','));
|
|
331
|
-
// }
|
|
332
|
-
// templateContent.push('}');
|
|
333
|
-
// builder
|
|
334
|
-
// .createEdge({ source: tableId.id, target: appendToTable.id, input: 'id' })
|
|
335
|
-
// .createEdge({ source: template.id, target: appendToTable.id, input: 'items' });
|
|
336
|
-
// functionTrigger = triggerShape.functionTrigger!.target!;
|
|
337
|
-
// });
|
|
338
|
-
// const computeModel = createComputeGraph(canvasModel);
|
|
339
|
-
// const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
340
|
-
// invariant(templateComputeNode, 'Template compute node was not created.');
|
|
341
|
-
// templateComputeNode.value = templateContent.join('\n');
|
|
342
|
-
// templateComputeNode.inputSchema = JsonSchema.toJsonSchema(EmailTriggerOutput);
|
|
343
|
-
// attachTrigger(functionTrigger, computeModel);
|
|
344
|
-
// return addToSpace(PresetName.EMAIL_TABLE, space, canvasModel, computeModel);
|
|
345
|
-
// });
|
|
346
|
-
// cb?.(objects);
|
|
347
|
-
// return objects;
|
|
348
|
-
// },
|
|
349
|
-
// ],
|
|
350
|
-
[
|
|
351
|
-
"chat-gpt-text",
|
|
352
|
-
async (space, n, cb) => {
|
|
353
|
-
const objects = range(n, () => {
|
|
354
|
-
const canvasModel = CanvasGraphModel.create();
|
|
355
|
-
canvasModel.builder.call((builder) => {
|
|
356
|
-
const gpt = canvasModel.createNode(createGpt(position({
|
|
357
|
-
x: 0,
|
|
358
|
-
y: -14
|
|
359
|
-
})));
|
|
360
|
-
const chat = canvasModel.createNode(createChat(position({
|
|
361
|
-
x: -18,
|
|
362
|
-
y: -2
|
|
363
|
-
})));
|
|
364
|
-
const text = canvasModel.createNode(createText(position({
|
|
365
|
-
x: 19,
|
|
366
|
-
y: 3,
|
|
367
|
-
width: 10,
|
|
368
|
-
height: 10
|
|
369
|
-
})));
|
|
370
|
-
const { queueId } = setupQueue(space, canvasModel);
|
|
371
|
-
const append = canvasModel.createNode(createAppend(position({
|
|
372
|
-
x: 10,
|
|
373
|
-
y: 6
|
|
374
|
-
})));
|
|
375
|
-
builder.createEdge({
|
|
376
|
-
source: chat.id,
|
|
377
|
-
target: gpt.id,
|
|
378
|
-
input: "prompt"
|
|
379
|
-
}).createEdge({
|
|
380
|
-
source: gpt.id,
|
|
381
|
-
target: text.id,
|
|
382
|
-
output: "text"
|
|
383
|
-
}).createEdge({
|
|
384
|
-
source: queueId.id,
|
|
385
|
-
target: append.id,
|
|
386
|
-
input: "id"
|
|
387
|
-
}).createEdge({
|
|
388
|
-
source: gpt.id,
|
|
389
|
-
target: append.id,
|
|
390
|
-
output: "messages",
|
|
391
|
-
input: "items"
|
|
392
|
-
});
|
|
393
|
-
});
|
|
394
|
-
const computeModel = createComputeGraph(canvasModel);
|
|
395
|
-
return addToSpace("chat-gpt-text", space, canvasModel, computeModel);
|
|
396
|
-
});
|
|
397
|
-
cb?.(objects);
|
|
398
|
-
return objects;
|
|
399
|
-
}
|
|
400
|
-
],
|
|
401
|
-
// TODO(wittjosiah): Remove?
|
|
402
|
-
// [
|
|
403
|
-
// PresetName.EMAIL_WITH_SUMMARY,
|
|
404
|
-
// async (space, n, cb) => {
|
|
405
|
-
// const objects = range(n, () => {
|
|
406
|
-
// const canvasModel = CanvasGraphModel.create<ComputeShape>();
|
|
407
|
-
// const results = space.db.query(Filter.type(TableType)).runSync();
|
|
408
|
-
// const emailTable = results.find((r) => r.object?.view?.target?.query?.typename?.endsWith('Email'));
|
|
409
|
-
// invariant(emailTable, 'Email table not found.');
|
|
410
|
-
// const template = canvasModel.createNode(
|
|
411
|
-
// createTemplate({
|
|
412
|
-
// valueType: 'object',
|
|
413
|
-
// ...rawPosition({ centerX: 192, centerY: -176, width: 320, height: 320 }),
|
|
414
|
-
// }),
|
|
415
|
-
// );
|
|
416
|
-
// const templateContent = ['{'];
|
|
417
|
-
// let functionTrigger: FunctionTrigger | undefined;
|
|
418
|
-
// canvasModel.builder.call((builder) => {
|
|
419
|
-
// const gpt = canvasModel.createNode(
|
|
420
|
-
// createGpt(rawPosition({ centerX: -400, centerY: -112, width: 256, height: 202 })),
|
|
421
|
-
// );
|
|
422
|
-
// const systemPrompt = canvasModel.createNode(
|
|
423
|
-
// createConstant({
|
|
424
|
-
// value: "use one word to describe content category. don't write anything else",
|
|
425
|
-
// ...rawPosition({ centerX: -800, centerY: -160, width: 192, height: 128 }),
|
|
426
|
-
// }),
|
|
427
|
-
// );
|
|
428
|
-
// const triggerShape = createTrigger({
|
|
429
|
-
// spaceId: space.id,
|
|
430
|
-
// triggerKind: 'email',
|
|
431
|
-
// ...rawPosition({ centerX: -736, centerY: -384, width: 182, height: 192 }),
|
|
432
|
-
// });
|
|
433
|
-
// const trigger = canvasModel.createNode(triggerShape);
|
|
434
|
-
// const { queueId } = setupQueue(space, canvasModel, {
|
|
435
|
-
// idPosition: { centerX: -720, centerY: 224, width: 192, height: 256 },
|
|
436
|
-
// queuePosition: { centerX: -144, centerY: 416, width: 320, height: 448 },
|
|
437
|
-
// });
|
|
438
|
-
// const appendToQueue = canvasModel.createNode(
|
|
439
|
-
// createAppend(rawPosition({ centerX: -80, centerY: 96, width: 122, height: 128 })),
|
|
440
|
-
// );
|
|
441
|
-
// const tableId = canvasModel.createNode(
|
|
442
|
-
// createConstant({
|
|
443
|
-
// value: DXN.fromLocalObjectId(emailTable.id).toString(),
|
|
444
|
-
// ...rawPosition({ centerX: -112, centerY: -544, width: 192, height: 256 }),
|
|
445
|
-
// }),
|
|
446
|
-
// );
|
|
447
|
-
// const appendToTable = canvasModel.createNode(
|
|
448
|
-
// createAppend(rawPosition({ centerX: 560, centerY: -416, width: 128, height: 122 })),
|
|
449
|
-
// );
|
|
450
|
-
// templateContent.push(' "category": "{{text}}",');
|
|
451
|
-
// builder.createEdge({ source: gpt.id, target: template.id, input: 'text', output: 'text' });
|
|
452
|
-
// const properties = SchemaAST.getPropertySignatures(EmailTriggerOutput.ast);
|
|
453
|
-
// for (let i = 0; i < properties.length; i++) {
|
|
454
|
-
// const propName = properties[i].name.toString();
|
|
455
|
-
// builder.createEdge({ source: trigger.id, target: template.id, input: propName, output: propName });
|
|
456
|
-
// templateContent.push(` "${propName}": "{{${propName}}}"` + (i === properties.length - 1 ? '' : ','));
|
|
457
|
-
// }
|
|
458
|
-
// templateContent.push('}');
|
|
459
|
-
// builder
|
|
460
|
-
// .createEdge({ source: tableId.id, target: appendToTable.id, input: 'id' })
|
|
461
|
-
// .createEdge({ source: queueId.id, target: appendToQueue.id, input: 'id' })
|
|
462
|
-
// .createEdge({ source: gpt.id, target: appendToQueue.id, output: 'messages', input: 'items' })
|
|
463
|
-
// .createEdge({ source: systemPrompt.id, target: gpt.id, input: 'systemPrompt' })
|
|
464
|
-
// .createEdge({ source: trigger.id, target: gpt.id, input: 'prompt', output: 'body' })
|
|
465
|
-
// .createEdge({ source: template.id, target: appendToTable.id, input: 'items' });
|
|
466
|
-
// functionTrigger = triggerShape.functionTrigger!.target!;
|
|
467
|
-
// });
|
|
468
|
-
// const computeModel = createComputeGraph(canvasModel);
|
|
469
|
-
// const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
470
|
-
// invariant(templateComputeNode, 'Template compute node was not created.');
|
|
471
|
-
// templateComputeNode.value = templateContent.join('\n');
|
|
472
|
-
// const extendedSchema = Schema.extend(EmailTriggerOutput, Schema.Struct({ text: Schema.String }));
|
|
473
|
-
// templateComputeNode.inputSchema = JsonSchema.toJsonSchema(extendedSchema);
|
|
474
|
-
// attachTrigger(functionTrigger, computeModel);
|
|
475
|
-
// return addToSpace(PresetName.EMAIL_WITH_SUMMARY, space, canvasModel, computeModel);
|
|
476
|
-
// });
|
|
477
|
-
// cb?.(objects);
|
|
478
|
-
// return objects;
|
|
479
|
-
// },
|
|
480
|
-
// ],
|
|
481
|
-
[
|
|
482
|
-
"forex-function-call",
|
|
483
|
-
async (space, n, cb) => {
|
|
484
|
-
const objects = range(n, () => {
|
|
485
|
-
const canvasModel = CanvasGraphModel.create();
|
|
486
|
-
canvasModel.builder.call((builder) => {
|
|
487
|
-
const sourceCurrency = canvasModel.createNode(createConstant({
|
|
488
|
-
value: "USD",
|
|
489
|
-
...position({
|
|
490
|
-
x: -10,
|
|
491
|
-
y: -5
|
|
492
|
-
})
|
|
493
|
-
}));
|
|
494
|
-
const targetCurrency = canvasModel.createNode(createConstant({
|
|
495
|
-
value: "EUR",
|
|
496
|
-
...position({
|
|
497
|
-
x: -10,
|
|
498
|
-
y: 5
|
|
499
|
-
})
|
|
500
|
-
}));
|
|
501
|
-
const converter = canvasModel.createNode(createFunction(position({
|
|
502
|
-
x: 0,
|
|
503
|
-
y: 0
|
|
504
|
-
})));
|
|
505
|
-
const view = canvasModel.createNode(createSurface(position({
|
|
506
|
-
x: 12,
|
|
507
|
-
y: 0
|
|
508
|
-
})));
|
|
509
|
-
builder.createEdge({
|
|
510
|
-
source: sourceCurrency.id,
|
|
511
|
-
target: converter.id,
|
|
512
|
-
input: "from"
|
|
513
|
-
}).createEdge({
|
|
514
|
-
source: targetCurrency.id,
|
|
515
|
-
target: converter.id,
|
|
516
|
-
input: "to"
|
|
517
|
-
}).createEdge({
|
|
518
|
-
source: converter.id,
|
|
519
|
-
target: view.id,
|
|
520
|
-
output: "rate"
|
|
521
|
-
});
|
|
522
|
-
});
|
|
523
|
-
const computeModel = createComputeGraph(canvasModel);
|
|
524
|
-
return addToSpace("forex-function-call", space, canvasModel, computeModel);
|
|
525
|
-
});
|
|
526
|
-
cb?.(objects);
|
|
527
|
-
return objects;
|
|
528
|
-
}
|
|
529
|
-
],
|
|
530
|
-
[
|
|
531
|
-
"discord-messages",
|
|
532
|
-
async (space, n, cb) => {
|
|
533
|
-
const objects = range(n, () => {
|
|
534
|
-
const canvasModel = CanvasGraphModel.create();
|
|
535
|
-
let functionTrigger;
|
|
536
|
-
canvasModel.builder.call((builder) => {
|
|
537
|
-
const triggerShape = createTrigger({
|
|
538
|
-
spaceId: space.id,
|
|
539
|
-
triggerKind: "timer",
|
|
540
|
-
...position({
|
|
541
|
-
x: -10,
|
|
542
|
-
y: -5
|
|
543
|
-
})
|
|
544
|
-
});
|
|
545
|
-
const trigger = canvasModel.createNode(triggerShape);
|
|
546
|
-
const channelId = canvasModel.createNode(createConstant({
|
|
547
|
-
value: "1088569858767212554",
|
|
548
|
-
...position({
|
|
549
|
-
x: -10,
|
|
550
|
-
y: 0
|
|
551
|
-
})
|
|
552
|
-
}));
|
|
553
|
-
const queueId = canvasModel.createNode(createConstant({
|
|
554
|
-
value: EID.make({
|
|
555
|
-
spaceId: space.id,
|
|
556
|
-
entityId: Key.EntityId.random()
|
|
557
|
-
}),
|
|
558
|
-
...position({
|
|
559
|
-
x: -10,
|
|
560
|
-
y: 5
|
|
561
|
-
})
|
|
562
|
-
}));
|
|
563
|
-
const converter = canvasModel.createNode(createFunction(position({
|
|
564
|
-
x: 0,
|
|
565
|
-
y: 0
|
|
566
|
-
})));
|
|
567
|
-
const view = canvasModel.createNode(createText(position({
|
|
568
|
-
x: 12,
|
|
569
|
-
y: 0
|
|
570
|
-
})));
|
|
571
|
-
const queue = canvasModel.createNode(createFeed(position({
|
|
572
|
-
x: 0,
|
|
573
|
-
y: 12
|
|
574
|
-
})));
|
|
575
|
-
builder.createEdge({
|
|
576
|
-
source: trigger.id,
|
|
577
|
-
target: converter.id,
|
|
578
|
-
input: "tick"
|
|
579
|
-
}).createEdge({
|
|
580
|
-
source: channelId.id,
|
|
581
|
-
target: converter.id,
|
|
582
|
-
input: "channelId"
|
|
583
|
-
}).createEdge({
|
|
584
|
-
source: queueId.id,
|
|
585
|
-
target: converter.id,
|
|
586
|
-
input: "queueId"
|
|
587
|
-
}).createEdge({
|
|
588
|
-
source: converter.id,
|
|
589
|
-
target: view.id,
|
|
590
|
-
output: "newMessages"
|
|
591
|
-
}).createEdge({
|
|
592
|
-
source: queueId.id,
|
|
593
|
-
target: queue.id,
|
|
594
|
-
input: "input"
|
|
595
|
-
});
|
|
596
|
-
functionTrigger = triggerShape.functionTrigger.target;
|
|
597
|
-
});
|
|
598
|
-
const computeModel = createComputeGraph(canvasModel);
|
|
599
|
-
attachTrigger(functionTrigger, computeModel);
|
|
600
|
-
return addToSpace("discord-messages", space, canvasModel, computeModel);
|
|
601
|
-
});
|
|
602
|
-
cb?.(objects);
|
|
603
|
-
return objects;
|
|
604
|
-
}
|
|
605
|
-
]
|
|
606
|
-
]
|
|
607
|
-
});
|
|
608
|
-
var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) => {
|
|
609
|
-
const canvasModel = CanvasGraphModel.create();
|
|
610
|
-
const template = canvasModel.createNode(createTemplate({
|
|
611
|
-
valueType: "object",
|
|
612
|
-
...rawPosition({
|
|
613
|
-
centerX: -64,
|
|
614
|
-
centerY: -79,
|
|
615
|
-
width: 320,
|
|
616
|
-
height: 320
|
|
617
|
-
})
|
|
618
|
-
}));
|
|
619
|
-
let functionTrigger;
|
|
620
|
-
canvasModel.builder.call((builder) => {
|
|
621
|
-
const triggerShape = createTrigger({
|
|
622
|
-
spaceId: space.id,
|
|
623
|
-
triggerKind,
|
|
624
|
-
...rawPosition({
|
|
625
|
-
centerX: -578,
|
|
626
|
-
centerY: -187,
|
|
627
|
-
height: 320,
|
|
628
|
-
width: 320
|
|
629
|
-
})
|
|
630
|
-
});
|
|
631
|
-
const trigger = canvasModel.createNode(triggerShape);
|
|
632
|
-
const { queueId } = setupQueue(space, canvasModel, {
|
|
633
|
-
queuePosition: {
|
|
634
|
-
centerX: -80,
|
|
635
|
-
centerY: 378,
|
|
636
|
-
width: 320,
|
|
637
|
-
height: 448
|
|
638
|
-
}
|
|
639
|
-
});
|
|
640
|
-
const append = canvasModel.createNode(createAppend(rawPosition({
|
|
641
|
-
centerX: 320,
|
|
642
|
-
centerY: 192,
|
|
643
|
-
width: 128,
|
|
644
|
-
height: 122
|
|
645
|
-
})));
|
|
646
|
-
const random2 = canvasModel.createNode(createRandom(rawPosition({
|
|
647
|
-
centerX: -509,
|
|
648
|
-
centerY: -30,
|
|
649
|
-
width: 64,
|
|
650
|
-
height: 64
|
|
651
|
-
})));
|
|
652
|
-
builder.createEdge({
|
|
653
|
-
source: queueId.id,
|
|
654
|
-
target: append.id,
|
|
655
|
-
input: "id"
|
|
656
|
-
}).createEdge({
|
|
657
|
-
source: template.id,
|
|
658
|
-
target: append.id,
|
|
659
|
-
input: "items"
|
|
660
|
-
}).createEdge({
|
|
661
|
-
source: trigger.id,
|
|
662
|
-
target: template.id,
|
|
663
|
-
output: triggerOutputName,
|
|
664
|
-
input: "type"
|
|
665
|
-
}).createEdge({
|
|
666
|
-
source: random2.id,
|
|
667
|
-
target: template.id,
|
|
668
|
-
input: "changeId"
|
|
669
|
-
});
|
|
670
|
-
functionTrigger = triggerShape.functionTrigger.target;
|
|
671
|
-
const triggerSpec = functionTrigger.spec;
|
|
672
|
-
invariant(triggerSpec && triggerSpec.kind === triggerKind, "No trigger spec.", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 657, S: void 0, A: ["triggerSpec && triggerSpec.kind === triggerKind", "'No trigger spec.'"] });
|
|
673
|
-
Obj.update(functionTrigger, (functionTrigger2) => {
|
|
674
|
-
initSpec(functionTrigger2.spec);
|
|
675
|
-
});
|
|
676
|
-
});
|
|
677
|
-
const computeModel = createComputeGraph(canvasModel);
|
|
678
|
-
const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
679
|
-
invariant(templateComputeNode, "Template compute node was not created.", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 664, S: void 0, A: ["templateComputeNode", "'Template compute node was not created.'"] });
|
|
680
|
-
templateComputeNode.value = [
|
|
681
|
-
"{",
|
|
682
|
-
' "@type": "{{type}}",',
|
|
683
|
-
' "id": "@{{changeId}}"',
|
|
684
|
-
"}"
|
|
685
|
-
].join("\n");
|
|
686
|
-
templateComputeNode.inputSchema = JsonSchema.toJsonSchema(Schema.Struct({
|
|
687
|
-
type: Schema.String,
|
|
688
|
-
changeId: Schema.String
|
|
689
|
-
}));
|
|
690
|
-
attachTrigger(functionTrigger, computeModel);
|
|
691
|
-
return {
|
|
692
|
-
canvasModel,
|
|
693
|
-
computeModel
|
|
694
|
-
};
|
|
695
|
-
};
|
|
696
|
-
var addToSpace = (name, space, canvas, compute) => {
|
|
697
|
-
return space.db.add(Obj.make(CanvasBoard.CanvasBoard, {
|
|
698
|
-
name,
|
|
699
|
-
computeGraph: Ref.make(compute.root),
|
|
700
|
-
layout: canvas.graph
|
|
701
|
-
}));
|
|
702
|
-
};
|
|
703
|
-
var setupQueue = (space, canvasModel, args) => {
|
|
704
|
-
const queueId = canvasModel.createNode(createConstant({
|
|
705
|
-
value: EID.make({
|
|
706
|
-
spaceId: space.id,
|
|
707
|
-
entityId: Key.EntityId.random()
|
|
708
|
-
}),
|
|
709
|
-
...args?.idPosition ? rawPosition(args.idPosition) : position({
|
|
710
|
-
x: -18,
|
|
711
|
-
y: 5,
|
|
712
|
-
width: 8,
|
|
713
|
-
height: 6
|
|
714
|
-
})
|
|
715
|
-
}));
|
|
716
|
-
const queue = canvasModel.createNode(createFeed(args?.queuePosition ? rawPosition(args.queuePosition) : position({
|
|
717
|
-
x: -3,
|
|
718
|
-
y: 3,
|
|
719
|
-
width: 14,
|
|
720
|
-
height: 10
|
|
721
|
-
})));
|
|
722
|
-
canvasModel.createEdge({
|
|
723
|
-
source: queueId.id,
|
|
724
|
-
target: queue.id
|
|
725
|
-
});
|
|
726
|
-
return {
|
|
727
|
-
queue,
|
|
728
|
-
queueId
|
|
729
|
-
};
|
|
730
|
-
};
|
|
731
|
-
var attachTrigger = (functionTrigger, computeModel) => {
|
|
732
|
-
invariant(functionTrigger, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 718, S: void 0, A: ["functionTrigger", ""] });
|
|
733
|
-
const inputNode = computeModel.nodes.find((node) => node.type === NODE_INPUT);
|
|
734
|
-
Obj.update(functionTrigger, (functionTrigger2) => {
|
|
735
|
-
functionTrigger2.runnable = Ref.make(computeModel.root);
|
|
736
|
-
functionTrigger2.inputNodeId = inputNode.id;
|
|
737
|
-
});
|
|
738
|
-
};
|
|
739
|
-
var rawPosition = (args) => {
|
|
740
|
-
return {
|
|
741
|
-
center: {
|
|
742
|
-
x: args.centerX,
|
|
743
|
-
y: args.centerY
|
|
744
|
-
},
|
|
745
|
-
size: {
|
|
746
|
-
width: args.width,
|
|
747
|
-
height: args.height
|
|
748
|
-
}
|
|
749
|
-
};
|
|
750
|
-
};
|
|
751
|
-
var position = (rect) => {
|
|
752
|
-
const snap = 32;
|
|
753
|
-
const [center, size] = rectToPoints({
|
|
754
|
-
width: 0,
|
|
755
|
-
height: 0,
|
|
756
|
-
...rect
|
|
757
|
-
});
|
|
758
|
-
const { x, y, width, height } = pointsToRect([
|
|
759
|
-
pointMultiply(center, snap),
|
|
760
|
-
pointMultiply(size, snap)
|
|
761
|
-
]);
|
|
762
|
-
if (width && height) {
|
|
763
|
-
return {
|
|
764
|
-
center: {
|
|
765
|
-
x,
|
|
766
|
-
y
|
|
767
|
-
},
|
|
768
|
-
size: width && height ? {
|
|
769
|
-
width,
|
|
770
|
-
height
|
|
771
|
-
} : void 0
|
|
772
|
-
};
|
|
773
|
-
} else {
|
|
774
|
-
return {
|
|
775
|
-
center: {
|
|
776
|
-
x,
|
|
777
|
-
y
|
|
778
|
-
}
|
|
779
|
-
};
|
|
780
|
-
}
|
|
781
|
-
};
|
|
782
|
-
|
|
783
|
-
// src/components/SpaceGenerator/ObjectGenerator.tsx
|
|
784
|
-
import { addressToA1Notation } from "@dxos/compute-hyperformula";
|
|
785
|
-
import { ComputeGraph, ComputeGraphModel, DEFAULT_OUTPUT, NODE_INPUT as NODE_INPUT2, NODE_OUTPUT } from "@dxos/conductor";
|
|
786
|
-
import { EID as EID2, Filter as Filter2, Key as Key2, Type, View } from "@dxos/echo";
|
|
787
|
-
import { Markdown as Markdown2 } from "@dxos/plugin-markdown";
|
|
788
|
-
import { Sheet } from "@dxos/plugin-sheet";
|
|
789
|
-
import { Sketch } from "@dxos/plugin-sketch";
|
|
790
|
-
import { SpaceOperation } from "@dxos/plugin-space";
|
|
791
|
-
import { random } from "@dxos/random";
|
|
792
|
-
import { getTypeURIFromQuery } from "@dxos/schema";
|
|
793
|
-
import { createAsyncGenerator } from "@dxos/schema/testing";
|
|
794
|
-
import { range as range2 } from "@dxos/util";
|
|
795
|
-
var generator2 = random;
|
|
796
|
-
var findViewByTypeUri = async (views, typeUri) => {
|
|
797
|
-
return views.find((view) => getTypeURIFromQuery(view.query.ast) === typeUri);
|
|
798
|
-
};
|
|
799
|
-
var createGenerator = (client, invokePromise, schema) => {
|
|
800
|
-
return async (space, n) => {
|
|
801
|
-
const typename = Type.getTypename(schema);
|
|
802
|
-
const views = await space.db.query(Filter2.type(View.View)).run();
|
|
803
|
-
const view = await findViewByTypeUri(views, Type.getURI(schema));
|
|
804
|
-
const staticSchema = client ? client.graph.registry.list().filter(Type.isType).find((s) => Type.getTypename(s) === typename) : void 0;
|
|
805
|
-
if (!view && !staticSchema) {
|
|
806
|
-
await invokePromise(SpaceOperation.AddType, {
|
|
807
|
-
db: space.db,
|
|
808
|
-
type: schema,
|
|
809
|
-
show: false
|
|
810
|
-
});
|
|
811
|
-
}
|
|
812
|
-
const generate = createAsyncGenerator(generator2, schema, {
|
|
813
|
-
db: space.db
|
|
814
|
-
});
|
|
815
|
-
return generate.createObjects(n);
|
|
816
|
-
};
|
|
817
|
-
};
|
|
818
|
-
var staticGenerators = /* @__PURE__ */ new Map([
|
|
819
|
-
[
|
|
820
|
-
Type.getTypename(Markdown2.Document),
|
|
821
|
-
async (space, n, cb) => {
|
|
822
|
-
const objects = range2(n).map(() => {
|
|
823
|
-
return space.db.add(Markdown2.make({
|
|
824
|
-
name: random.commerce.productName(),
|
|
825
|
-
content: random.lorem.sentences(5)
|
|
826
|
-
}));
|
|
827
|
-
});
|
|
828
|
-
cb?.(objects);
|
|
829
|
-
return objects;
|
|
830
|
-
}
|
|
831
|
-
],
|
|
832
|
-
[
|
|
833
|
-
Type.getTypename(Sketch.Sketch),
|
|
834
|
-
async (space, n, cb) => {
|
|
835
|
-
const objects = range2(n).map(() => {
|
|
836
|
-
const obj = space.db.add(Sketch.make({
|
|
837
|
-
name: random.commerce.productName()
|
|
838
|
-
}));
|
|
839
|
-
return obj;
|
|
840
|
-
});
|
|
841
|
-
cb?.(objects);
|
|
842
|
-
return objects;
|
|
843
|
-
}
|
|
844
|
-
],
|
|
845
|
-
// TODO(burdon): Create unit tests.
|
|
846
|
-
[
|
|
847
|
-
Type.getTypename(Sheet.Sheet),
|
|
848
|
-
async (space, n, cb) => {
|
|
849
|
-
const objects = range2(n).map(() => {
|
|
850
|
-
const cells = {};
|
|
851
|
-
const year = (/* @__PURE__ */ new Date()).getFullYear();
|
|
852
|
-
const cols = 4;
|
|
853
|
-
const rows = 16;
|
|
854
|
-
for (let col = 1; col <= cols; col++) {
|
|
855
|
-
for (let row = 1; row <= rows; row++) {
|
|
856
|
-
const cell = addressToA1Notation({
|
|
857
|
-
col,
|
|
858
|
-
row
|
|
859
|
-
});
|
|
860
|
-
if (row === 1) {
|
|
861
|
-
cells[cell] = {
|
|
862
|
-
value: `${year} Q${col}`
|
|
863
|
-
};
|
|
864
|
-
} else if (row === rows) {
|
|
865
|
-
const from = addressToA1Notation({
|
|
866
|
-
col,
|
|
867
|
-
row: 2
|
|
868
|
-
});
|
|
869
|
-
const to = addressToA1Notation({
|
|
870
|
-
col,
|
|
871
|
-
row: rows - 1
|
|
872
|
-
});
|
|
873
|
-
cells[cell] = {
|
|
874
|
-
value: `=SUM(${from}:${to})`
|
|
875
|
-
};
|
|
876
|
-
} else if (row > 2 && row < rows - 1) {
|
|
877
|
-
cells[cell] = {
|
|
878
|
-
value: Math.floor(Math.random() * 1e4)
|
|
879
|
-
};
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
return space.db.add(Sheet.make({
|
|
884
|
-
name: random.commerce.productName(),
|
|
885
|
-
cells
|
|
886
|
-
}));
|
|
887
|
-
});
|
|
888
|
-
cb?.(objects);
|
|
889
|
-
return objects;
|
|
890
|
-
}
|
|
891
|
-
],
|
|
892
|
-
[
|
|
893
|
-
Type.getTypename(ComputeGraph),
|
|
894
|
-
async (space, n, cb) => {
|
|
895
|
-
const objects = range2(n, () => {
|
|
896
|
-
const model = ComputeGraphModel.create();
|
|
897
|
-
model.builder.createNode({
|
|
898
|
-
id: "gpt-INPUT",
|
|
899
|
-
type: NODE_INPUT2
|
|
900
|
-
}).createNode({
|
|
901
|
-
id: "gpt-GPT",
|
|
902
|
-
type: "gpt"
|
|
903
|
-
}).createNode({
|
|
904
|
-
id: "gpt-QUEUE_ID",
|
|
905
|
-
type: "constant",
|
|
906
|
-
value: EID2.make({
|
|
907
|
-
spaceId: space.id,
|
|
908
|
-
entityId: Key2.EntityId.random()
|
|
909
|
-
})
|
|
910
|
-
}).createNode({
|
|
911
|
-
id: "gpt-APPEND",
|
|
912
|
-
type: "append"
|
|
913
|
-
}).createNode({
|
|
914
|
-
id: "gpt-OUTPUT",
|
|
915
|
-
type: NODE_OUTPUT
|
|
916
|
-
}).createEdge({
|
|
917
|
-
node: "gpt-INPUT",
|
|
918
|
-
property: "prompt"
|
|
919
|
-
}, {
|
|
920
|
-
node: "gpt-GPT",
|
|
921
|
-
property: "prompt"
|
|
922
|
-
}).createEdge({
|
|
923
|
-
node: "gpt-GPT",
|
|
924
|
-
property: "text"
|
|
925
|
-
}, {
|
|
926
|
-
node: "gpt-OUTPUT",
|
|
927
|
-
property: "text"
|
|
928
|
-
}).createEdge({
|
|
929
|
-
node: "gpt-QUEUE_ID",
|
|
930
|
-
property: DEFAULT_OUTPUT
|
|
931
|
-
}, {
|
|
932
|
-
node: "gpt-APPEND",
|
|
933
|
-
property: "id"
|
|
934
|
-
}).createEdge({
|
|
935
|
-
node: "gpt-GPT",
|
|
936
|
-
property: "messages"
|
|
937
|
-
}, {
|
|
938
|
-
node: "gpt-APPEND",
|
|
939
|
-
property: "items"
|
|
940
|
-
}).createEdge({
|
|
941
|
-
node: "gpt-QUEUE_ID",
|
|
942
|
-
property: DEFAULT_OUTPUT
|
|
943
|
-
}, {
|
|
944
|
-
node: "gpt-OUTPUT",
|
|
945
|
-
property: "queue"
|
|
946
|
-
});
|
|
947
|
-
return space.db.add(model.root);
|
|
948
|
-
});
|
|
949
|
-
cb?.(objects);
|
|
950
|
-
return objects;
|
|
951
|
-
}
|
|
952
|
-
]
|
|
953
|
-
]);
|
|
954
|
-
export {
|
|
955
|
-
PresetName,
|
|
956
|
-
SchemaTable,
|
|
957
|
-
createGenerator,
|
|
958
|
-
generator,
|
|
959
|
-
staticGenerators
|
|
960
|
-
};
|
|
961
|
-
//# sourceMappingURL=index.mjs.map
|