Skip to content

Commit eafbcb4

Browse files
committed
SimpleChatTC:DataStore:Cleanup:Msg, duplicate on routing side
Avoid the duplicate plumbing code and use a common ops plumbing helper. Remove args[key] oversight from DataStoreList msg on webworkr
1 parent 8186d8c commit eafbcb4

File tree

2 files changed

+8
-47
lines changed

2 files changed

+8
-47
lines changed

tools/server/public_simplechat/tooldb.mjs

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,6 @@ let dsget_meta = {
2828
}
2929

3030

31-
/**
32-
* Implementation of the data store get logic. Minimal skeleton for now.
33-
* NOTE: Has access to the javascript web worker environment and can mess with it and beyond
34-
* @param {string} chatid
35-
* @param {string} toolcallid
36-
* @param {string} toolname
37-
* @param {any} obj
38-
*/
39-
function dsget_run(chatid, toolcallid, toolname, obj) {
40-
gToolsDBWorker.postMessage({ cid: chatid, tcid: toolcallid, name: toolname, args: obj})
41-
}
42-
43-
4431
let dsset_meta = {
4532
"type": "function",
4633
"function": {
@@ -64,19 +51,6 @@ let dsset_meta = {
6451
}
6552

6653

67-
/**
68-
* Implementation of the data store set logic. Minimal skeleton for now.
69-
* NOTE: Has access to the javascript web worker environment and can mess with it and beyond
70-
* @param {string} chatid
71-
* @param {string} toolcallid
72-
* @param {string} toolname
73-
* @param {any} obj
74-
*/
75-
function dsset_run(chatid, toolcallid, toolname, obj) {
76-
gToolsDBWorker.postMessage({ cid: chatid, tcid: toolcallid, name: toolname, args: obj})
77-
}
78-
79-
8054
let dsdel_meta = {
8155
"type": "function",
8256
"function": {
@@ -96,19 +70,6 @@ let dsdel_meta = {
9670
}
9771

9872

99-
/**
100-
* Implementation of the data store delete logic. Minimal skeleton for now.
101-
* NOTE: Has access to the javascript web worker environment and can mess with it and beyond
102-
* @param {string} chatid
103-
* @param {string} toolcallid
104-
* @param {string} toolname
105-
* @param {any} obj
106-
*/
107-
function dsdel_run(chatid, toolcallid, toolname, obj) {
108-
gToolsDBWorker.postMessage({ cid: chatid, tcid: toolcallid, name: toolname, args: obj})
109-
}
110-
111-
11273
let dslist_meta = {
11374
"type": "function",
11475
"function": {
@@ -124,14 +85,14 @@ let dslist_meta = {
12485

12586

12687
/**
127-
* Implementation of the data store list logic. Minimal skeleton for now.
88+
* Implementation of the minimal needed plumbing for data store related ops triggering.
12889
* NOTE: Has access to the javascript web worker environment and can mess with it and beyond
12990
* @param {string} chatid
13091
* @param {string} toolcallid
13192
* @param {string} toolname
13293
* @param {any} obj
13394
*/
134-
function dslist_run(chatid, toolcallid, toolname, obj) {
95+
function dsops_run(chatid, toolcallid, toolname, obj) {
13596
gToolsDBWorker.postMessage({ cid: chatid, tcid: toolcallid, name: toolname, args: obj})
13697
}
13798

@@ -142,22 +103,22 @@ function dslist_run(chatid, toolcallid, toolname, obj) {
142103
*/
143104
export let tc_switch = {
144105
"data_store_get": {
145-
"handler": dsget_run,
106+
"handler": dsops_run,
146107
"meta": dsget_meta,
147108
"result": ""
148109
},
149110
"data_store_set": {
150-
"handler": dsset_run,
111+
"handler": dsops_run,
151112
"meta": dsset_meta,
152113
"result": ""
153114
},
154115
"data_store_delete": {
155-
"handler": dsdel_run,
116+
"handler": dsops_run,
156117
"meta": dsdel_meta,
157118
"result": ""
158119
},
159120
"data_store_list": {
160-
"handler": dslist_run,
121+
"handler": dsops_run,
161122
"meta": dslist_meta,
162123
"result": ""
163124
},

tools/server/public_simplechat/toolsdbworker.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ self.onmessage = async function (ev) {
5353
cid: ev.data.cid,
5454
tcid: ev.data.tcid,
5555
name: ev.data.name,
56-
data: { 'status': 'ok', 'data': reqList.result, 'msg': `DataStoreList:Ok:${args['key']}:${reqList.result}`}
56+
data: { 'status': 'ok', 'data': reqList.result, 'msg': `DataStoreList:Ok:${reqList.result}`}
5757
});
5858
}
5959
reqList.onerror = (evList) => {
@@ -62,7 +62,7 @@ self.onmessage = async function (ev) {
6262
cid: ev.data.cid,
6363
tcid: ev.data.tcid,
6464
name: ev.data.name,
65-
data: { 'status': 'error', 'msg': `DataStoreList:Err:${args['key']}:${reqList.error}`}
65+
data: { 'status': 'error', 'msg': `DataStoreList:Err:${reqList.error}`}
6666
});
6767
}
6868
break;

0 commit comments

Comments
 (0)