Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

0.0.67 #181

Merged
merged 256 commits into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
256 commits
Select commit Hold shift + click to select a range
1ea6ed8
Change sharedb tsconfig
michaelsharpe Apr 7, 2022
45c63a3
Add empty thoth interface for sharedb
michaelsharpe Apr 7, 2022
86a7c76
Merge branch 'main' into 0.0.67
michaelsharpe Apr 7, 2022
2453376
commit yarn lock
HaruHunab1320 Apr 7, 2022
2bce41a
fix state ordering bug
HaruHunab1320 Apr 7, 2022
25054a3
fix deployment url
HaruHunab1320 Apr 7, 2022
98670b8
pass state into process code
HaruHunab1320 Apr 7, 2022
5d92434
pass state into function and extract into result
HaruHunab1320 Apr 7, 2022
700da8d
if state exists in the return, update game state
HaruHunab1320 Apr 7, 2022
a0e3102
add state to processCode argument on engine context
HaruHunab1320 Apr 7, 2022
f6a786f
add any for return type on process code
HaruHunab1320 Apr 7, 2022
4ce8944
add state to processCode arguyments in editor context interface
HaruHunab1320 Apr 7, 2022
d6f558e
add any to processCode return type in editor context interface
HaruHunab1320 Apr 7, 2022
2e4ae89
destructure GetCurrentGameState and updateCurrentGameState from thoth
HaruHunab1320 Apr 7, 2022
a490a26
capture current state in const
HaruHunab1320 Apr 7, 2022
1bac5c8
pass in state to process code
HaruHunab1320 Apr 7, 2022
42d88e8
if state returned from code component, update the gamestate
HaruHunab1320 Apr 7, 2022
3008a88
update default code in code component to include state
HaruHunab1320 Apr 7, 2022
26f19de
removed assigning redundent type
HaruHunab1320 Apr 8, 2022
0342c5e
convert socket generator from js to ts
HaruHunab1320 Apr 8, 2022
1fed510
add isOutput to new socket boolean evaluation
HaruHunab1320 Apr 8, 2022
74ff679
stop trimming results of generations
nickwalton Apr 10, 2022
631c6a9
added new models to the generator and made jumbo the default
nickwalton Apr 10, 2022
ca272c4
revert change that prevented state manager from saving
nickwalton Apr 10, 2022
5ec791b
added vanilla neox and removed vanilla davinci as an option
nickwalton Apr 10, 2022
872e76b
remove some text trimming
nickwalton Apr 10, 2022
cb21878
import files internally rather than weirds npm package self reference
michaelsharpe Apr 11, 2022
ab7b417
Update sharedb tsconfig
michaelsharpe Apr 11, 2022
dd0b648
Add enki completion to stubbed thoth interface for sharedb
michaelsharpe Apr 11, 2022
88bc410
Update dependencies of sharedb
michaelsharpe Apr 11, 2022
bca5b86
Update yarn lock
michaelsharpe Apr 11, 2022
ac7564e
Small update to sharedb file
michaelsharpe Apr 11, 2022
3b17d97
Merge branch '0.0.67' of github.com:latitudegames/thoth into 0.0.67
michaelsharpe Apr 11, 2022
dda0545
add trigger to utputs in state write
HaruHunab1320 Apr 12, 2022
29b5a59
rename dataInput to socketInput
HaruHunab1320 Apr 12, 2022
698bf37
add socket trigger output
HaruHunab1320 Apr 12, 2022
86deaf7
attatch the output socket to the node
HaruHunab1320 Apr 12, 2022
d6c2c85
can now select models from database in thoth
nickwalton Apr 12, 2022
f6856df
Add docs to root
michaelsharpe Apr 12, 2022
c183cdb
Merge branch '0.0.67' of github.com:latitudegames/thoth into 0.0.67
michaelsharpe Apr 12, 2022
2b811dc
make generator display its
nickwalton Apr 13, 2022
24eddfa
add output on spell
nickwalton Apr 13, 2022
180b692
Send testing message over websocket
michaelsharpe Apr 13, 2022
07aab76
Export chain helper from server index
michaelsharpe Apr 13, 2022
f6289d0
Add ran spells and check to spell runnner
michaelsharpe Apr 13, 2022
bf33407
Merge branch '0.0.67' of github.com:latitudegames/thoth into 0.0.67
michaelsharpe Apr 13, 2022
fc154b7
Format inputs into proper shape for processing rete graph inputs in s…
michaelsharpe Apr 13, 2022
31aa9e6
Add better typing to module class
michaelsharpe Apr 13, 2022
efff114
fix typo in foreach
HaruHunab1320 Apr 13, 2022
b516cad
fix typo in Input.ts
HaruHunab1320 Apr 13, 2022
b2be8dd
Harder typing on module read function
michaelsharpe Apr 14, 2022
ede87bf
Fix module manager type errors
michaelsharpe Apr 14, 2022
a3d58d4
Fix run chain type errors
michaelsharpe Apr 14, 2022
c7e77e9
Fix socket updating on subspell component adds that arent io
michaelsharpe Apr 14, 2022
edad398
Fix subspell deleting parent connections bug
michaelsharpe Apr 14, 2022
f34d43b
Fix bug where existing sockets were still being added again
michaelsharpe Apr 14, 2022
74954b1
Default name for output components
michaelsharpe Apr 14, 2022
b96614c
Add a node counter to the thoth component class
michaelsharpe Apr 14, 2022
e02d51d
Add default name to inputs
michaelsharpe Apr 14, 2022
b0a3325
Add default name to outputs
michaelsharpe Apr 14, 2022
5469017
Add default name to trigger ins
michaelsharpe Apr 14, 2022
39b7aaf
Add default name to trigger outs
michaelsharpe Apr 14, 2022
80d2ef4
Port in echo component
michaelsharpe Apr 14, 2022
085766a
Move alert message component
michaelsharpe Apr 14, 2022
7069a90
Fix path resolution in components
michaelsharpe Apr 14, 2022
1494138
Add echo component to components dict
michaelsharpe Apr 14, 2022
3c7ae73
Add comments to spell runner
michaelsharpe Apr 14, 2022
90da8da
Export thoth component class type
michaelsharpe Apr 14, 2022
5dd380b
Add engine process class function to spell runner
michaelsharpe Apr 14, 2022
7d5c3a6
Await engine processing when loading spell
michaelsharpe Apr 14, 2022
8aa8b44
Remove console log
michaelsharpe Apr 14, 2022
8f2cf23
Clear spell ran cache on hitting an infinite loop.
michaelsharpe Apr 14, 2022
86e7906
Set ran spells to an empty array
michaelsharpe Apr 14, 2022
5b787f0
Add comments to getters
michaelsharpe Apr 14, 2022
5614316
Push subspell into cache at start of run component
michaelsharpe Apr 14, 2022
878a4e9
Drop try catch for running component so parent caller can handle it b…
michaelsharpe Apr 14, 2022
1f0f80c
Switch input default name to use node id
michaelsharpe Apr 14, 2022
dd8df5d
Switch output to use node id
michaelsharpe Apr 14, 2022
b5b3688
Switch trigger in to use node id
michaelsharpe Apr 14, 2022
14b2d06
Switch to node id for trigger out default
michaelsharpe Apr 14, 2022
63700ab
Dont increment node count in IO components
michaelsharpe Apr 14, 2022
c5981e3
Remove node count property from thoth component class
michaelsharpe Apr 14, 2022
86f5200
fix generator issue
nickwalton Apr 15, 2022
232f15a
increase the debounce
nickwalton Apr 15, 2022
71b5a9c
Merge branch '0.0.67' of github.com:latitudegames/thoth into 0.0.67
HaruHunab1320 Apr 16, 2022
75e01ce
commit yarn lock
HaruHunab1320 Apr 16, 2022
43c2a34
update port to run on 3003
HaruHunab1320 Apr 18, 2022
a3d030a
autoformat sidebar
HaruHunab1320 Apr 18, 2022
605825c
stub back propagation
HaruHunab1320 Apr 18, 2022
efd20eb
stub few shots
HaruHunab1320 Apr 18, 2022
d0bde72
stub flow based programming
HaruHunab1320 Apr 18, 2022
50233e5
stub logic flow
HaruHunab1320 Apr 18, 2022
69b5979
stub nodes
HaruHunab1320 Apr 18, 2022
6188b0a
strub trigger control flow
HaruHunab1320 Apr 18, 2022
492122f
add gettings started catagory
HaruHunab1320 Apr 18, 2022
26f8f76
stub calling a spell
HaruHunab1320 Apr 18, 2022
5305b4a
stub component selector
HaruHunab1320 Apr 18, 2022
5173a94
stub connecting your first component
HaruHunab1320 Apr 18, 2022
cbc53d9
stub console
HaruHunab1320 Apr 18, 2022
00c9e17
stub deploy a spell
HaruHunab1320 Apr 18, 2022
c411120
stub first few shot
HaruHunab1320 Apr 18, 2022
0933142
stub help
HaruHunab1320 Apr 18, 2022
cd12631
stub layout
HaruHunab1320 Apr 18, 2022
83557ef
stub making a spell
HaruHunab1320 Apr 18, 2022
6f63ff3
stub spell composer
HaruHunab1320 Apr 18, 2022
7e7aa38
stub state manager
HaruHunab1320 Apr 18, 2022
8c5f9ea
stub text editor
HaruHunab1320 Apr 18, 2022
08bb165
stub ui overview
HaruHunab1320 Apr 18, 2022
99e21c5
stub working with state
HaruHunab1320 Apr 18, 2022
b2e5659
add templates section
HaruHunab1320 Apr 18, 2022
fe3e0da
add architecture overview
HaruHunab1320 Apr 18, 2022
03841d2
stub architecture
HaruHunab1320 Apr 18, 2022
8ddf25b
stub contexts page
HaruHunab1320 Apr 18, 2022
7e5bffd
stub inspector controls
HaruHunab1320 Apr 18, 2022
4484fcb
stub layouts
HaruHunab1320 Apr 18, 2022
4a113e1
stub operational transforms
HaruHunab1320 Apr 18, 2022
4c5d289
stub plugins
HaruHunab1320 Apr 18, 2022
89ff822
stub pubsub
HaruHunab1320 Apr 18, 2022
b7be62e
stub rete editor
HaruHunab1320 Apr 18, 2022
7dbfd7e
stub state
HaruHunab1320 Apr 18, 2022
0304be8
stub thoth interface
HaruHunab1320 Apr 18, 2022
bf34900
stub workspace and tabs
HaruHunab1320 Apr 18, 2022
01c1ada
add package overview catagory
HaruHunab1320 Apr 18, 2022
802addf
stub stargate design system
HaruHunab1320 Apr 18, 2022
98d739e
stub thoth client core
HaruHunab1320 Apr 18, 2022
72f0fdd
stub thotht client
HaruHunab1320 Apr 18, 2022
29ebbd4
stub thoth core
HaruHunab1320 Apr 18, 2022
ffab680
thoth server core
HaruHunab1320 Apr 18, 2022
3e396da
stub thoth server
HaruHunab1320 Apr 18, 2022
0e7a3c7
Update docusaurus github link in config
michaelsharpe Apr 19, 2022
8c7651d
Padd node to editor trigger in on inspector change
michaelsharpe Apr 19, 2022
9bba8a2
Dont use socket name when updating sockets
michaelsharpe Apr 19, 2022
eee0231
Change docusaurus port running
michaelsharpe Apr 19, 2022
0210599
Update back propagation sidebar position
michaelsharpe Apr 19, 2022
f66d1b8
Update fewshot sidebar position
michaelsharpe Apr 19, 2022
17d290d
Update flow based programming sidebar position
michaelsharpe Apr 19, 2022
e365d03
Update logic flow sidebar position
michaelsharpe Apr 19, 2022
3deb8f8
Update nodes sidebar position
michaelsharpe Apr 19, 2022
fd2dd0b
Update trigger control flow sidebar position
michaelsharpe Apr 19, 2022
707c54c
Add user interface category
michaelsharpe Apr 19, 2022
2896976
Update position of templates category
michaelsharpe Apr 19, 2022
ffc2915
Move ui overview to its own category
michaelsharpe Apr 19, 2022
205e814
Move pages into UI overview
michaelsharpe Apr 19, 2022
8f57b2d
Move spell composer doc into ui folder
michaelsharpe Apr 19, 2022
69e7720
Add sidebar position for calling a spell
michaelsharpe Apr 19, 2022
062ef35
Add sidebar position for connecting components
michaelsharpe Apr 19, 2022
b1e96b2
Add sidebar position for deploying a spell
michaelsharpe Apr 19, 2022
dc480cd
Add sidebar position for fierst fewshot
michaelsharpe Apr 19, 2022
c6d3c8e
Add sidebar position for making a spell
michaelsharpe Apr 19, 2022
c5eda70
Add sidebar position for working with state
michaelsharpe Apr 19, 2022
ef13015
Add getting started category for developers
michaelsharpe Apr 19, 2022
4164adf
Update developer architecture overview position
michaelsharpe Apr 19, 2022
0adab97
Update package overview position
michaelsharpe Apr 19, 2022
01b6c23
Add installing thoth page stub for developers
michaelsharpe Apr 19, 2022
e2e08c9
Add concepts overview page
michaelsharpe Apr 19, 2022
1462a91
Add creator welcome page
michaelsharpe Apr 19, 2022
b4ccce0
Add menu links to conepts and creators
michaelsharpe Apr 19, 2022
a70e6ad
Add intro page to developer getting started
michaelsharpe Apr 19, 2022
d56057f
Add menu option for developers
michaelsharpe Apr 19, 2022
eb41e01
Add sidebar position for component selector
michaelsharpe Apr 19, 2022
fc12a43
Add sidebar position for console
michaelsharpe Apr 19, 2022
f37f28c
Add sidebar position for spell composer
michaelsharpe Apr 19, 2022
11519cd
Add sidebar position for layout
michaelsharpe Apr 19, 2022
f8f8184
Add sidebar position for state manager
michaelsharpe Apr 19, 2022
452d760
Add sidebar position for text editor
michaelsharpe Apr 19, 2022
d4a3c26
Add sidebar position for help page
michaelsharpe Apr 19, 2022
2d16dad
add image assets for apikey
HaruHunab1320 Apr 19, 2022
3febaab
add user icon image for api key
HaruHunab1320 Apr 19, 2022
8b25ad4
moved docs structure up one level
HaruHunab1320 Apr 19, 2022
96b32b6
add createApiKey section
HaruHunab1320 Apr 19, 2022
68e2bc4
add destroy apikey section
HaruHunab1320 Apr 19, 2022
2dca0a5
Merge branch '0.0.67' of github.com:latitudegames/thoth into 0.0.67
HaruHunab1320 Apr 19, 2022
b33c05f
remove duplicated files from merge
HaruHunab1320 Apr 19, 2022
2cc32b8
fix merge issues
HaruHunab1320 Apr 19, 2022
2d92721
Pass state in to run spell mutation
michaelsharpe Apr 19, 2022
488d3e4
Pass in state when callign run spell inside spell worker
michaelsharpe Apr 19, 2022
384455c
Add set current game state to thoth interface provider
michaelsharpe Apr 19, 2022
4c4f8ec
Add set current game state to engine context type
michaelsharpe Apr 19, 2022
3aaefb4
Add set current tgame state to stubbed share DB context
michaelsharpe Apr 19, 2022
15a6d8d
add image assets for docs
HaruHunab1320 Apr 20, 2022
b1ca916
add sidebar position to create api key page
HaruHunab1320 Apr 20, 2022
9dd419d
add sidebar position for destroy api key page
HaruHunab1320 Apr 20, 2022
c3ecded
add post request docs
HaruHunab1320 Apr 20, 2022
97f902a
add testing with postman docs
HaruHunab1320 Apr 20, 2022
b52d63e
add using api key docs
HaruHunab1320 Apr 20, 2022
471f04b
Merge branch '0.0.67' of github.com:latitudegames/thoth into 0.0.67
HaruHunab1320 Apr 20, 2022
8a3cf0f
remove currentModel nuill check preventing creating new window
HaruHunab1320 Apr 20, 2022
0bb3cee
add run event to pubsub provider
HaruHunab1320 Apr 20, 2022
b395811
uncomment publish in debug console
HaruHunab1320 Apr 20, 2022
4dd1f27
destructure run from events
HaruHunab1320 Apr 20, 2022
ca0fd3d
create a run helper
HaruHunab1320 Apr 20, 2022
a9d18d3
add the run command to the console
HaruHunab1320 Apr 20, 2022
50dd64d
add run to pubsub events
HaruHunab1320 Apr 20, 2022
d1a9422
destructure run from events
HaruHunab1320 Apr 20, 2022
5db9ad5
create onRun helper
HaruHunab1320 Apr 20, 2022
798a283
add onRun to editor context
HaruHunab1320 Apr 20, 2022
9bf771e
add process to onRun
HaruHunab1320 Apr 21, 2022
0f3296b
update on run arg type
HaruHunab1320 Apr 21, 2022
b114f46
create a runSubscriptionMap
HaruHunab1320 Apr 21, 2022
71f2a92
add subscribe to run function
HaruHunab1320 Apr 21, 2022
33b3091
pass in runSubscriptionMap to destroyed
HaruHunab1320 Apr 21, 2022
503bf1f
add delete for runSubscriptionMap to builder
HaruHunab1320 Apr 21, 2022
b765bc8
subscribe to run in builder
HaruHunab1320 Apr 21, 2022
b51e0ba
import switchControl
HaruHunab1320 Apr 21, 2022
3637178
add toggleDefault switchc ontrol to trigger node
HaruHunab1320 Apr 21, 2022
d950a79
add toggleDefault to the component
HaruHunab1320 Apr 21, 2022
b2bcf5f
add handleDefaultTrigger to the inspector
HaruHunab1320 Apr 21, 2022
747a665
pass in the update to the handleDefaultTrigger
HaruHunab1320 Apr 21, 2022
430a977
pass in a value to the subscribeToRun function
HaruHunab1320 Apr 21, 2022
ff65816
pass the value into task.run
HaruHunab1320 Apr 21, 2022
8c16ea1
add value to run function
HaruHunab1320 Apr 21, 2022
cb2479a
add value to terminal run command
HaruHunab1320 Apr 21, 2022
f65af5b
Move debugger plugin
michaelsharpe Apr 21, 2022
9418e1b
Add catch to reformat spell results
michaelsharpe Apr 21, 2022
dd1243c
Add use socket name to socket type
michaelsharpe Apr 21, 2022
0434fa9
Update helperas to to use HoFs
michaelsharpe Apr 21, 2022
9c3211e
Started work on socket manager
michaelsharpe Apr 21, 2022
1b1fa8b
clean up module plugin socket stuff
michaelsharpe Apr 21, 2022
594236e
Format outputs on the way out
michaelsharpe Apr 21, 2022
957e83f
Clean up socket constructor in inspector plugin
michaelsharpe Apr 21, 2022
9b4012f
Merge branch '0.0.67' of github.com:latitudegames/thoth into 0.0.67
michaelsharpe Apr 21, 2022
a4a82de
Strip out state socket for now from spell component.
michaelsharpe Apr 21, 2022
b27918f
update onRun to handle default
HaruHunab1320 Apr 21, 2022
9e77840
update onRun argument type to accept a string or a node
HaruHunab1320 Apr 21, 2022
5f092a4
change run to trigger in pubsub provider
HaruHunab1320 Apr 21, 2022
0bfb58d
change destructuring of run to trigger due to name change
HaruHunab1320 Apr 21, 2022
1a68a05
change onRun to onTrigger
HaruHunab1320 Apr 21, 2022
d1b3479
subscribe to TRIGGER instead of RUN
HaruHunab1320 Apr 21, 2022
6ac20d9
change name on public interface from onRun to onTrigger
HaruHunab1320 Apr 21, 2022
9fa00bb
destructure TRIGGER instead of RUN from events
HaruHunab1320 Apr 21, 2022
67175ac
change helper name from run to trigger
HaruHunab1320 Apr 21, 2022
513ece1
change run command to trigger in console
HaruHunab1320 Apr 21, 2022
d85f4ea
change onRun to onTrigger in editor context
HaruHunab1320 Apr 21, 2022
89fa9c4
change runSubscriptionMap to triggerSubscriptionMap
HaruHunab1320 Apr 21, 2022
bfcefd6
change subscribeToRun to subscribeToTrigger
HaruHunab1320 Apr 21, 2022
48ac865
destructure onTrigger from editor
HaruHunab1320 Apr 21, 2022
518e99e
define a callback helper
HaruHunab1320 Apr 21, 2022
c1e1fb5
set nup the onTriggers subscriptions in the map
HaruHunab1320 Apr 21, 2022
e8721aa
add the delete logic for the trigger subscriptions in the destroy block
HaruHunab1320 Apr 21, 2022
b0d5460
add the delete logic for the trigger subscriptions in the builder
HaruHunab1320 Apr 21, 2022
f6a5c6d
add the call to the subscribeToTrigger inside the trigger in
HaruHunab1320 Apr 21, 2022
0a24b31
Merge branch '0.0.67' of github.com:latitudegames/thoth into 0.0.67
HaruHunab1320 Apr 21, 2022
2a484e8
strip out value from trigger command
HaruHunab1320 Apr 22, 2022
6004635
strip out value from trigger helper
HaruHunab1320 Apr 22, 2022
9b89cf7
Fix multiple write state issue
michaelsharpe Apr 25, 2022
f9bd833
Merge pull request #182 from latitudegames/main
nickwalton Apr 26, 2022
821799f
Turn dev off for spell component
michaelsharpe Apr 28, 2022
11071b8
Fix state read issues
michaelsharpe Apr 29, 2022
c1c6d2a
Disable comments and selection area
michaelsharpe Apr 29, 2022
8836560
Fix event on errors
michaelsharpe Apr 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:3001",
"url": "http://localhost:3003",
"sourceMap": true,
"webRoot": "${workspaceFolder}/client",
"trace": true,
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ In the project directory, you can run:
### `yarn start`

Runs @thoth/client in the development mode.\
Open [http://localhost:3001](http://localhost:3001) to view it in the browser.
Open [http://localhost:3003](http://localhost:3003) to view it in the browser.

### `yarn build`

Expand Down
3 changes: 2 additions & 1 deletion client/.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ EXTEND_ESLINT = true

REACT_APP_SITE_ROOT_URL_PROD=https://thoth.latitude.io

REACT_APP_SITE_ROOT_URL=http://localhost:3001
REACT_APP_SITE_ROOT_URL=http://localhost:3003
REACT_APP_LAPI_ROOT_URL=http://localhost:8000

REACT_APP_LAPI_ROOT_URL_PROD=https://api.latitude.io
Expand All @@ -15,3 +15,4 @@ REACT_APP_SITE_STAGING=https://62264f21c3a9860ad1e5bdd3--optimistic-turing-def91
REACT_APP_OAUTH_CLIENT_ID=a6b51c87-7565-42ab-a4b0-38a07f3b6c56

REACT_APP_SHAREDB=false
REACT_APP_WEBSOCKETS=false
2 changes: 1 addition & 1 deletion client/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ EXTEND_ESLINT = true

# This prod site root assumes the netlify build context $URL is available, replace for other hosts
REACT_APP_SITE_ROOT_URL_PROD=$URL
REACT_APP_SITE_ROOT_URL=http://localhost:3001
REACT_APP_SITE_ROOT_URL=http://localhost:3003
REACT_APP_LAPI_ROOT_URL=http://localhost:8000
REACT_APP_LAPI_ROOT_URL_PROD=https://api.latitude.io
REACT_APP_SITE_STAGING=https://62264f21c3a9860ad1e5bdd3--optimistic-turing-def916.netlify.app/
Expand Down
2 changes: 1 addition & 1 deletion client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ In the project directory, you can run:
### `yarn start`

Runs the app in the development mode.\
Open [http://localhost:3001](http://localhost:3001) to view it in the browser.
Open [http://localhost:3003](http://localhost:3003) to view it in the browser.

The page will reload if you make edits.\
You will also see any lint errors in the console.
Expand Down
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@callstack/async-storage": "^2.0.3",
"@emotion/react": "^11.8.2",
"@emotion/styled": "^11.8.1",
"@latitudegames/thoth-core": "^0.0.66",
"@latitudegames/thoth-core": "^0.0.67",
"@monaco-editor/react": "^4.2.1",
"@mui/icons-material": "^5.5.1",
"@mui/material": "^5.5.3",
Expand Down
1 change: 1 addition & 0 deletions client/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export const appRootUrl =

// coercing this into a boolean
export const sharedb = process.env.REACT_APP_SHAREDB === 'true'
export const websockets = process.env.REACT_APP_WEBSOCKETS === 'true'
export const websocketUrl = 'ws://localhost:8080'
2 changes: 2 additions & 0 deletions client/src/contexts/AppProviders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import AuthProvider from './AuthProvider'
import PubSubProvider from './PubSubProvider'
import SharedbProvider from './SharedbProvider'
import ToastProvider from './ToastProvider'
import WebSocketProvider from './WebSocketProvider'

declare module '@mui/styles/defaultTheme' {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
Expand All @@ -28,6 +29,7 @@ const providers = [
[ThemeProvider, { theme: darkTheme }],
ToastProvider,
AuthProvider,
WebSocketProvider,
SharedbProvider,
]

Expand Down
1 change: 1 addition & 0 deletions client/src/contexts/PubSubProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const events = {
UPDATE_SUBSPELL: 'updateSubspell',
DELETE_SUBSPELL: 'deleteSubspell',
$SUBSPELL_UPDATED: spellId => `subspellUpdated:${spellId}`,
$TRIGGER: (tabId, nodeId) => `triggerNode:${tabId}:${nodeId}`,
$PLAYTEST_INPUT: tabId => `playtestInput:${tabId}`,
$PLAYTEST_PRINT: tabId => `playtestPrint:${tabId}`,
$DEBUG_PRINT: tabId => `debugPrint:${tabId}`,
Expand Down
13 changes: 4 additions & 9 deletions client/src/contexts/SharedbProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
import { sharedb, websocketUrl } from '@/config'
import { sharedb } from '@/config'
import { useContext, createContext, useEffect, useState } from 'react'
import { Doc } from 'sharedb'

import ReconnectingWebSocket from 'reconnecting-websocket'
import client from 'sharedb/lib/client'
import { Socket } from 'sharedb/lib/sharedb'
import { Spell } from '@latitudegames/thoth-core/types'
import LoadingScreen from '@/components/LoadingScreen/LoadingScreen'
import { useWebSocket } from './WebSocketProvider'

const Connection = client.Connection

interface SharedbContext {
connection: client.Connection | null
socket: Socket | null
getSpellDoc: (spell: Spell) => Doc | null
}

const Context = createContext<SharedbContext>({
connection: null,
socket: null,
getSpellDoc: () => null,
})

Expand All @@ -28,14 +26,12 @@ export const docMap = new Map()

// Might want to namespace these
const SharedbProvider = ({ children }) => {
const [socket, setSocket] = useState<Socket | null>(null)
const { socket } = useWebSocket()
const [connection, setConnection] = useState<client.Connection | null>(null)

useEffect(() => {
const _socket = new ReconnectingWebSocket(websocketUrl)
const _connection = new Connection(_socket as Socket)
const _connection = new Connection(socket as Socket)
setConnection(_connection)
setSocket(_socket as Socket)
}, [])

const getSpellDoc = (spell: Spell) => {
Expand All @@ -61,7 +57,6 @@ const SharedbProvider = ({ children }) => {
}

const publicInterface: SharedbContext = {
socket,
connection,
getSpellDoc,
}
Expand Down
46 changes: 46 additions & 0 deletions client/src/contexts/WebSocketProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { websockets, websocketUrl } from '@/config'
import { useContext, createContext, useEffect, useState } from 'react'

import ReconnectingWebSocket from 'reconnecting-websocket'
import { Socket } from 'sharedb/lib/sharedb'
import LoadingScreen from '@/components/LoadingScreen/LoadingScreen'

interface SharedbContext {
socket: Socket | null
}

const Context = createContext<SharedbContext>({
socket: null,
})

export const useWebSocket = () => useContext(Context)

export const docMap = new Map()

// Might want to namespace these
const WebSocketProvider = ({ children }) => {
const [socket, setSocket] = useState<Socket | null>(null)

useEffect(() => {
const _socket = new ReconnectingWebSocket(websocketUrl)
setSocket(_socket as Socket)

_socket.send('testing')
}, [])

const publicInterface: SharedbContext = {
socket,
}

if (!socket) return <LoadingScreen />

return <Context.Provider value={publicInterface}>{children}</Context.Provider>
}

const ConditionalProvider = props => {
if (!websockets) return props.children

return <WebSocketProvider {...props} />
}

export default ConditionalProvider
18 changes: 17 additions & 1 deletion client/src/services/game-api/text.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
import { latitudeApiRootUrl } from '@/config'
import { getAuthHeader } from '../../contexts/AuthProvider'

export const getModels = async () => {
try {
const response = await fetch(latitudeApiRootUrl + '/text/models', {
method: 'GET',
headers: {
...(await getAuthHeader()),
},
})
const result = await response.json()
return result
} catch (err) {
// eslint-disable-next-line no-console
console.warn('fetch error', err)
}
}

export const completion = async body => {
try {
const response = await fetch(latitudeApiRootUrl + '/text/completions_v2', {
Expand All @@ -9,7 +25,7 @@ export const completion = async body => {
'Content-Type': 'application/json',
...(await getAuthHeader()),
},
body: JSON.stringify({ ...body, prompt: body.prompt.trimEnd() }),
body: JSON.stringify({ ...body, prompt: body.prompt }),
})
const result = await response.json()
return result.completions[0].text
Expand Down
8 changes: 6 additions & 2 deletions client/src/state/api/spells.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface RunSpell {
spellId: string
version?: string
inputs: Record<string, any>
state?: Record<string, any>
}

export const spellApi = rootApi.injectEndpoints({
Expand All @@ -61,10 +62,13 @@ export const spellApi = rootApi.injectEndpoints({
},
}),
runSpell: builder.mutation<Record<string, any>, RunSpell>({
query: ({ spellId, version = 'latest', inputs }) => ({
query: ({ spellId, version = 'latest', inputs, state = {} }) => ({
url: `game/chains/${spellId}/${version}`,
method: 'POST',
body: inputs,
body: {
...inputs,
state,
},
}),
}),
saveDiff: builder.mutation<void, Diff>({
Expand Down
4 changes: 2 additions & 2 deletions client/src/workspaces/contexts/LayoutProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const LayoutProvider = ({ children, tab }) => {
}

const createOrFocus = (componentName, title) => {
if (!currentModelRef.current || !currentModel) return
if (!currentModelRef.current) return

// We are here using a provate variable, so TS isnt picking it up
// @ts-expect-error
Expand All @@ -129,7 +129,7 @@ const LayoutProvider = ({ children, tab }) => {
)

// the nodeId is stored in the zeroth index of the find
if (component) currentModel.doAction(Actions.selectTab(component[0]))
if (component) currentModel?.doAction(Actions.selectTab(component[0]))
if (!component) addWindow(componentName, title)
}

Expand Down
45 changes: 39 additions & 6 deletions client/src/workspaces/contexts/ThothInterfaceProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,19 @@ const ThothInterfaceProvider = ({ children, tab }) => {
UPDATE_SUBSPELL,
$SUBSPELL_UPDATED,
$PROCESS,
$TRIGGER,
} = events

const onTrigger = (node, callback) => {
let isDefault = node === 'default' ? 'default' : null
return subscribe($TRIGGER(tab.id, isDefault ?? node.id), (event, data) => {
publish($PROCESS(tab.id))
// weird hack. This staggers the process slightly to allow the published event to finish before the callback runs.
// No super elegant, but we need a better more centralised way to run the engine than these callbacks.
setTimeout(() => callback(data), 0)
})
}

const onInspector = (node, callback) => {
return subscribe($NODE_SET(tab.id, node.id), (event, data) => {
callback(data)
Expand Down Expand Up @@ -132,7 +143,7 @@ const ThothInterfaceProvider = ({ children, tab }) => {
return result.data
}

const processCode = (code, inputs, data) => {
const processCode = (code, inputs, data, state) => {
const flattenedInputs = Object.entries(inputs as ThothWorkerInputs).reduce(
(acc, [key, value]) => {
acc[key as string] = value[0]
Expand All @@ -141,15 +152,19 @@ const ThothInterfaceProvider = ({ children, tab }) => {
{} as Record<string, any>
)
// eslint-disable-next-line no-new-func
return Function('"use strict";return (' + code + ')')()(
const result = new Function('"use strict";return (' + code + ')')()(
flattenedInputs,
data
data,
state
)
if (result.state) {
updateCurrentGameState(result.state)
}
return result
}

const runSpell = async (inputs, spellId) => {
console.log('RUN SPELL')
const response = await _runSpell({ inputs, spellId })
const runSpell = async (inputs, spellId, state) => {
const response = await _runSpell({ inputs, spellId, state })

if ('error' in response) {
throw new Error(`Error running spell ${spellId}`)
Expand All @@ -168,6 +183,16 @@ const ThothInterfaceProvider = ({ children, tab }) => {
return spellRef.current?.gameState ?? {}
}

const setCurrentGameState = newState => {
if (!spellRef.current) return

const update = {
gameState: newState,
}

publish($SAVE_SPELL_DIFF(tab.id), update)
}

const updateCurrentGameState = _update => {
if (!spellRef.current) return
const spell = spellRef.current
Expand All @@ -184,10 +209,17 @@ const ThothInterfaceProvider = ({ children, tab }) => {
},
}

// Temporarily update the spell refs game state to account for multiple state writes in a spell run
spellRef.current = {
...spell,
...update,
}

publish($SAVE_SPELL_DIFF(tab.id), update)
}

const publicInterface = {
onTrigger,
onInspector,
onAddModule,
onUpdateModule,
Expand All @@ -204,6 +236,7 @@ const ThothInterfaceProvider = ({ children, tab }) => {
huggingface,
readFromImageCache,
getCurrentGameState,
setCurrentGameState,
updateCurrentGameState,
processCode,
runSpell,
Expand Down
2 changes: 2 additions & 0 deletions client/src/workspaces/spells/DataControls/DataControls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import InputGenerator from './InputGenerator'
import LongText from './LongTextControl'
import OutputGenerator from './OutputGenerator'
import DropdownSelect from './DropdownSelect'
import ModelSelect from './ModelSelect'
import SocketGenerator from './SocketGenerator'
import PlaytestControl from './PlaytestControl'
import SwitchControl from './SwitchControl'
Expand All @@ -30,6 +31,7 @@ const controlMap = {
playtest: PlaytestControl,
switch: SwitchControl,
dropdownSelect: DropdownSelect,
modelSelect: ModelSelect,
}

const DataControls = ({
Expand Down
Loading