feat(watch,server): thread events over t3 websocket to the gateway hook, t3_answer for pending questions
This commit is contained in:
@@ -18,6 +18,9 @@ DESCRIPTOR = "/.well-known/t3/environment"
|
||||
SHELL = "/api/orchestration/shell"
|
||||
THREADS = "/api/orchestration/threads"
|
||||
DISPATCH = "/api/orchestration/dispatch"
|
||||
WS_TICKET = "/api/auth/websocket-ticket"
|
||||
WS_PATH = "/ws"
|
||||
SUBSCRIBE_SHELL = "orchestration.subscribeShell"
|
||||
|
||||
RUNTIME_MODE = "full-access"
|
||||
INTERACTION_MODE = "default"
|
||||
@@ -101,6 +104,19 @@ def turn_interrupt(thread_id: str, turn_id: str | None = None) -> dict[str, Any]
|
||||
return command
|
||||
|
||||
|
||||
def user_input_respond(
|
||||
thread_id: str, request_id: str, answers: dict[str, Any]
|
||||
) -> dict[str, Any]:
|
||||
return {
|
||||
"type": "thread.user-input.respond",
|
||||
"commandId": new_id(),
|
||||
"threadId": thread_id,
|
||||
"requestId": request_id,
|
||||
"answers": answers,
|
||||
"createdAt": now_iso(),
|
||||
}
|
||||
|
||||
|
||||
class T3Client:
|
||||
def __init__(
|
||||
self,
|
||||
@@ -142,6 +158,11 @@ class T3Client:
|
||||
async def dispatch(self, command: dict[str, Any]) -> dict[str, Any]:
|
||||
return self._json(await self._http.post(DISPATCH, json=command))
|
||||
|
||||
async def ws_url(self) -> str:
|
||||
ticket = self._json(await self._http.post(WS_TICKET))["ticket"]
|
||||
scheme = "wss" if self.url.startswith("https") else "ws"
|
||||
return f"{scheme}://{self.url.split('://', 1)[1]}{WS_PATH}?wsTicket={ticket}"
|
||||
|
||||
@staticmethod
|
||||
def _json(response: httpx.Response) -> dict[str, Any]:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user