Commit Graph

7463 Commits

Author SHA1 Message Date
hanishkvc 6a8ced244c SimpleChatTC:Raise Error on Ai Chat server handshake NotOk resp 2025-12-04 19:41:39 +05:30
hanishkvc 91f39b7197 SimpleChatTC:Move chat server handshake to SimpleChat 2025-12-04 19:41:39 +05:30
hanishkvc 482517543b SimpleChatTC:Seperate out actual nw handshake - initial go
move the actual chat handshake with ai server into a seperate code
to an extent.

also initial anchor to trap handshake http error responses

Rather come to think of it, its better to move this into SimpleChat
class.

Use finally to ensure any needed cleanup for handle_user_submit
occurs within itself.
2025-12-04 19:41:39 +05:30
hanishkvc 8d7eece81c SimpleChatTC:ToolsWorker: Update note to flow with chat session id 2025-12-04 19:41:39 +05:30
hanishkvc 8ab8727f70 SimpleChatTC:DataStore: update readme 2025-12-04 19:41:39 +05:30
hanishkvc 5935ecceca 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
2025-12-04 19:41:39 +05:30
hanishkvc 57dd228512 SimpleChatTC:DataStore:List keys - the plumbing 2025-12-04 19:41:39 +05:30
hanishkvc 2d497069d2 SimpleChatTC:DataStore:list - web worker side logic
The basic skeleton added on the web worker side for listing keys.

TODO: Avoid duplication of similar code to an extent across some
of these db ops.
2025-12-04 19:41:39 +05:30
hanishkvc 7f8eb04875 SimpleChatTC:DataStore:Delete a record - the plumbing side 2025-12-04 19:41:39 +05:30
hanishkvc bd7f7cb72a SimpleChatTC:DataStore: Delete a record - the db web worker side 2025-12-04 19:41:39 +05:30
hanishkvc d80e438cfa SimpleChatTC:DataStore:Put, stringify undefined, readme
Update the descriptions of set and get to indicate the possible
corner cases or rather semantic in such situations.

Update the readme also a bit. The auto save and restore mentioned
has nothing to do with the new data store mechanism.
2025-12-04 19:41:39 +05:30
hanishkvc 2dad246d53 SimpleChatTC:DataStore: Dont ignore the error paths
And indexedDB add isnt the one to be happy with updating existing
key.
2025-12-04 19:41:39 +05:30
hanishkvc 4ad88f0da8 SimpleChatTC:DataStore:Eagerness to Wrong JSON conversions
In the eagerness of initial skeleton, had forgotten that the
root/generic tool call router takes care of parsing the json string
into a object, before calling the tool call, so no need to try
parse again. Fixed the same.

Hadnt converted the object based response from data store related
calls in the db web worker, into json string before passing to the
generic tool response callback, fixed the same.

- Rather the though of making the ChatMsgEx.createAllInOne handle
string or object set aside for now, to keep things simple and
consistant to the greatest extent possible across different flows.

And good news - flow is working atleast for the overall happy path
Need to check what corner cases are lurking like calling set on
same key more than once, seemed to have some flow oddity, which I
need to check later.

Also maybe change the field name to value from data in the response
to get, to match the field name convention of set. GPT-OSS is fine
with it. But worst case micro / nano / pico models may trip up, in
worst case, so better to keep things consistent.
2025-12-04 19:41:39 +05:30
hanishkvc 797b702251 SimpleChatTC:DataStore:FuncCallArgs: Any type not supported
So mention that may be ai can send complex objects in stringified
form. Rather once type of value is set to string, ai should normally
do it, but no harm is hinting.
2025-12-04 19:41:39 +05:30
hanishkvc b080ddf5c3 SimpleChatTC:DataStore: Remaining plumbing to try this
Update tooldb logic to match that needed for the db logic and its
web worker.

Bring in the remaining aspects of db helpers into tools flow.
2025-12-04 19:41:39 +05:30
hanishkvc 2f58542713 SimpleChatTC:DataStore: Duplicate tooljs to tooldb initial skel 2025-12-04 19:41:39 +05:30
hanishkvc aedffe1df0 SimpleChatTC:DataStore: Initial skeleton of a Db WebWorker
Create the DB store

Try Get and Set operations

The post back to main thread done from asynchronous paths.

NOTE: given that it has been ages since indexed db was used,
so this is a logical implementation by refering to mdn as needed.
2025-12-04 19:41:39 +05:30
hanishkvc 4f857575f5 SimpleChatTC:UICleanup:ShowMessage: Update readme 2025-12-04 19:41:39 +05:30
hanishkvc 9e9016f7fe SimpleChatTC:UICleanup: WordBreaks, Print avoid side vertical
Define rules to ensure that chat message contents wrap so as to
avoid overflowing beyond the size of the screen being viewed.

The style used for chat message role to be placed with vertical
oriented text adjacent to the actual message content on the side
seems to be creating issue with blank pages in some browsers,
so avoid that styling when one is printing.
2025-12-04 19:41:39 +05:30
hanishkvc f3593a9611 SimpleChatTC:ShowMessage:Show any number of toolcalls
Also make reasoning easily identifiable in the chat
2025-12-04 19:41:39 +05:30
hanishkvc 41ef449db1 SimpleChatTC:ShowMessage: Seperate out the content parts 2025-12-04 19:41:39 +05:30
hanishkvc ae9f7971a5 SimpleChatTC:CSS: Instead of hardcoded btn minwidth use padding 2025-12-04 19:41:39 +05:30
hanishkvc 2f07288e40 SimpleChatTC:ShowMessage: containers, role, contents
Seperate out the message ui block into a container containing
a role block and contents container block.

This will allow themeing of these seperately, if required.
As part of same, currently the role has been put to the side
of the message with vertical text flow.
2025-12-04 19:41:39 +05:30
hanishkvc a4f247d730 SimpleChatTC:Cleanup:Move showing message into ShowMessage 2025-12-04 19:41:39 +05:30
hanishkvc 59effa6ea8 SimpleChatTC:Cleanup: tool resp xml, some allowed domains
Add a newline between name and content in the xml representation
of the tool response, so that it is more easy to distinguish things

Add github, linkedin and apnews domains to allowed.domains for
simpleproxy.py
2025-12-04 19:41:39 +05:30
hanishkvc cf06c8682b SimpleChatTC:Reasoning+: Update readme wrt reasoning, flow cleanup
Also cleanup the minimal based showing of chat messages a bit

And add github.com to allowed list
2025-12-04 19:41:39 +05:30
hanishkvc 937aa57528 SimpleChatTC:MultiChatUI:ChatShow cleanup of Initial skeleton
Fix up the initial skeleton / logic as needed.

Remember that we are working with potentially a subset of chat
messages from the session, given the sliding window logic of
context managing on client ui side, so fix up the logic to use
the right subset of messages array and not the global xchat
when deciding whether a message is the last or last but one,
which need special handling wrt Assistant (with toolcall) and
Tool (ie response) messages.

Moving tool call ui setup as well as tool call response got ui
setup into ChatShow of MultiChatUI ensures that switching between
chat sessions handle the ui wrt tool call triggering ui and tool
call response submission related ui as needed properly.

Rather even loading a previously auto saved chat session if it had
tool call or tool call response to be handled, the chat ui will be
setup as needed to continue that session properly.
2025-12-04 19:41:39 +05:30
hanishkvc 2cc10f6705 SimpleChatTC:MultiChatUI.ChatShow: Mov SimpleChat.Show in -initial
Also take care of updating the toolcall ui if needed from within
this.
2025-12-04 19:41:39 +05:30
hanishkvc 62bce9ebfb SimpleChatTC:Show: Cleanup
Update existing flow so that next Tool Role message is handled
directly from within
2025-12-04 19:41:39 +05:30
hanishkvc aa17edfa78 SimpleChatTC:SimpleProxy: Include some news sites in allowed domains 2025-12-04 19:41:39 +05:30
hanishkvc 47d9550131 SimpleChatTC:Reasoning: Cleanup the initial go
Rather simplify and make the content_equiv provide a relatively
simple and neat representation of the reasoning with content and
toolcall as the cases may be.

Also remove the partial new para that I had introduced in the
initial go for reasoning.
2025-12-04 19:41:39 +05:30
hanishkvc dbb5512b20 SimpleChatTC:Reasoning: Initial Go 2025-12-04 19:41:39 +05:30
hanishkvc 25df32b553 SimpleChatTC:ChatSessionID: Get all handlers to account for chatid
This should ensure that tool call responses can be mapped back to
the chat session for which it was triggered.
2025-12-04 19:41:39 +05:30
hanishkvc 734beb08f5 SimpleChatTC:ChatSessionID through the tool call cycle
Pass chatId to tool call, and use chatId in got tool call resp,
to decide as to to which chat session the async tool call resp
belongs and inturn if auto submit timer should be started if auto
is enabled.
2025-12-04 19:41:39 +05:30
hanishkvc 13d312fe0d SimpleChatTC:ToolTemp: Ensure add removes non promoted ToolTemp 2025-12-04 19:41:39 +05:30
hanishkvc 4eb3322017 SimpleChatTC:ToolCallErrPath:ToolTemp and MultiChatUIChatShow
Update the immidiate tool call triggering failure and tool call
response timeout paths to use the new ToolTemp and MultiChatUI
based chat show logics.

Actual tool call itself generating errors, is already handled
in the previous commit changes.
2025-12-04 19:41:39 +05:30
hanishkvc e79faebde1 SimpleChatTC:ToolTemp and ChatShow
Add a new role ToolTemp, which is used to maintain any tool call
response on the client ui side, without submitting it to the server
ie till user or auto submit triggers the submitting of that tool
call response.

When ever a tool call response is got, create a ToolTemp role based
message in the corresponding chat session. And dont directly update
the user query input area, rather leave it to the updated simplechat
show and the new multichatui chat_show helper and inturn whether the
current chat session active in ui is same as the one for which the
tool call response has been recieved.

TODO: Currently the response message is added to the current
active chat session, but this needs to be changed by tracking
chatId/session through the full tool call cycle and then adding
the tool call response in the related chat session, and inturn
updating or not the ui based on whether that chat session is
still the active chat session in ui or not, given that tool call
gets handled in a asynchronous way.

Now when that tool call response is submitted, promote the equiv
tool temp role based message that should be in the session's chat
history as the last message into becoming a normal tool response
message.

SimpleChat.show has been updated to take care of showing any
ToolTemp role message in the user query input area.

A newer chat_show helper added to MultiChatUI, that takes care of
calling SimpleChat.show, provided the chat_show is being requested
for the currently active in ui, chat session. As well as to take
care of passing both the ChatDiv and elInUser. Converts users of
SimpleChat.show to use MultiChatUI.chat_show
2025-12-04 19:41:39 +05:30
hanishkvc 84403973cd SimpleChatTC:SimpleProxy: once in a bluemoon transformed bearer
instead of using the shared bearer token as is, hash it with
current year and use the hash.

keep /aum path out of auth check.

in future bearer token could be transformed more often, as well as
with additional nounce/dynamic token from server got during initial
/aum handshake as also running counter and so ...

NOTE: All these circus not good enough, given that currently the
simpleproxy.py handshakes work over http. However these skeletons
put in place, for future, if needed.

TODO: There is a once in a bluemoon race when the year transitions
between client generating the request and server handling the req.
But other wise year transitions dont matter bcas client always
creates fresh token, and server checks for year change to genrate
fresh token if required.
2025-12-04 19:41:39 +05:30
hanishkvc 0552ff9098 SimpleChatTC:SimpleProxy:ClientUI: Send Authorization bearer
User can configure the bearer token to send
2025-12-04 19:41:39 +05:30
hanishkvc 044d1cf535 SimpleChatTC:tools.proxyUrl: rename to just proxyUrl
Next will be adding a proxyAuth field also to tools.
2025-12-04 19:41:39 +05:30
hanishkvc 6d08cda9c8 SimpleChatTC:SimpleProxy: Check for bearer authorization
As noted in the comments in code, this is a very insecure flow
for now.
2025-12-04 19:41:39 +05:30
hanishkvc 3f1fd289eb SimpleChatTC:SimpleProxy:BearerInsecure a needed config
Add a config entry called bearer.insecure which will contain a
token used for bearer auth of http requests

Make bearer.insecure and allowed.domains as needed configs, and
exit program if they arent got through cmdline or config file.
2025-12-04 19:41:39 +05:30
hanishkvc 0caa2e8101 SimpleChatTC:SimpleProxy: Prg Parameters handling cleanup - next
Ensure load_config gets called on encountering --config in cmdline,
so that the user has control over whether cmdline or config file
will decide the final value of any given parameter.

Ensure that str type values in cmdline are picked up directly, without
running them through ast.literal_eval, bcas otherwise one will have to
ensure throught the cmdline arg mechanism that string quote is retained
for literal_eval

Have the """ function note/description below def line immidiately
so that it is interpreted as a function description.
2025-12-04 19:41:39 +05:30
hanishkvc f221a2c356 SimpleChatTC:SimpleProxy:LoadConfig ProcessArgs cleanup - initial
Now both follow a similar mechanism and do the following

* exit on finding any issue, so that things are in a known
  state from usage perspective, without any confusion/overlook

* check if the cmdlineArgCmd/configCmd being processed is a known
  one or not.

* check value of the cmd is of the expected type

* have a generic flow which can accomodate more cmds in future
  in a simple way
2025-12-04 19:41:39 +05:30
hanishkvc a1b33ecd1c SimpleChatTC:ToolCallResponseTimeout: Allow end user to control
Moved it into Me->tools, so that end user can modify the same as
required from the settings ui.

TODO: Currently, if tc response is got after a tool call timed out
and user submitted default timed out error response, the delayed
actual response when it is got may overwrite any new content in
user query box, this needs to be tackled.
2025-12-04 19:41:39 +05:30
hanishkvc 252fb91e95 SimpleChatTC:WebSearchPlus: Update readme, Wikipedia in allowed
If using wikipedia or so, remember to have sufficient context window
in general wrt the ai engine as well as wrt the handshake / chat
end point.
2025-12-04 19:41:39 +05:30
hanishkvc 221b5a9228 SimpleChatTC:ToolCallWeby: Cleanup the toolweb module flow
Avoid code duplication, by creating helpers for setup and toolcall.

Also send indication of the path that will be used, when checking
for simpleproxy.py server to be running at runtime setup.
2025-12-04 19:41:39 +05:30
hanishkvc de6f370d3b SimpleChatTC:ToolCall:SearchWebText using UrlText
Initial go at implementing a web search tool call, which uses the
existing UrlText support of the bundled simpleproxy.py.

It allows user to control the search engine to use, by allowing
them to set the search engine url template.

The logic comes with search engine url template strings for
duckduckgo, brave, bing and google. With duckduckgo set by default.
2025-12-04 19:41:39 +05:30
hanishkvc 978ee3db1e SimpleChatTC:ToolCalling:Seprat out JSWebWorker and ProxyBasedWeb
Remove the unneed (belonging to the other file) stuff from tooljs
and toolweb files.

Update tools manager to make use of the new toolweb module
2025-12-04 19:41:39 +05:30
hanishkvc d00e5b341a SimpleChatTC:Duplicate tooljs.mjs to toolweb.mjs
So as to split browser js webworker based tool calls from web
related tool calls.
2025-12-04 19:41:39 +05:30