@townco/ui 0.1.14 → 0.1.16
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/dist/core/hooks/index.d.ts +1 -0
- package/dist/core/hooks/index.js +1 -0
- package/dist/core/hooks/use-chat-messages.d.ts +50 -11
- package/dist/core/hooks/use-chat-session.d.ts +5 -5
- package/dist/core/hooks/use-tool-calls.d.ts +52 -0
- package/dist/core/hooks/use-tool-calls.js +61 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core/lib/logger.d.ts +24 -0
- package/dist/core/lib/logger.js +108 -0
- package/dist/core/schemas/chat.d.ts +166 -83
- package/dist/core/schemas/chat.js +27 -27
- package/dist/core/schemas/index.d.ts +1 -0
- package/dist/core/schemas/index.js +1 -0
- package/dist/core/schemas/tool-call.d.ts +174 -0
- package/dist/core/schemas/tool-call.js +130 -0
- package/dist/core/store/chat-store.d.ts +28 -28
- package/dist/core/store/chat-store.js +123 -59
- package/dist/gui/components/ChatLayout.js +11 -10
- package/dist/gui/components/MessageContent.js +4 -1
- package/dist/gui/components/ToolCall.d.ts +8 -0
- package/dist/gui/components/ToolCall.js +100 -0
- package/dist/gui/components/ToolCallList.d.ts +9 -0
- package/dist/gui/components/ToolCallList.js +22 -0
- package/dist/gui/components/index.d.ts +2 -0
- package/dist/gui/components/index.js +2 -0
- package/dist/gui/components/resizable.d.ts +7 -0
- package/dist/gui/components/resizable.js +7 -0
- package/dist/sdk/schemas/session.d.ts +390 -220
- package/dist/sdk/schemas/session.js +74 -29
- package/dist/sdk/transports/http.js +705 -472
- package/dist/sdk/transports/stdio.js +187 -32
- package/dist/tui/components/ChatView.js +19 -51
- package/dist/tui/components/MessageList.d.ts +2 -4
- package/dist/tui/components/MessageList.js +13 -37
- package/dist/tui/components/ToolCall.d.ts +9 -0
- package/dist/tui/components/ToolCall.js +41 -0
- package/dist/tui/components/ToolCallList.d.ts +8 -0
- package/dist/tui/components/ToolCallList.js +17 -0
- package/dist/tui/components/index.d.ts +2 -0
- package/dist/tui/components/index.js +2 -0
- package/package.json +4 -2
|
@@ -1,54 +1,99 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { ToolCallSchema, ToolCallUpdateSchema, } from "../../core/schemas/tool-call.js";
|
|
2
3
|
import { Message } from "./message.js";
|
|
3
4
|
/**
|
|
4
5
|
* Session status
|
|
5
6
|
*/
|
|
6
7
|
export const SessionStatus = z.enum([
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
"idle",
|
|
9
|
+
"connecting",
|
|
10
|
+
"connected",
|
|
11
|
+
"active",
|
|
12
|
+
"streaming",
|
|
13
|
+
"error",
|
|
14
|
+
"disconnected",
|
|
14
15
|
]);
|
|
15
16
|
/**
|
|
16
17
|
* Session configuration
|
|
17
18
|
*/
|
|
18
19
|
export const SessionConfig = z.object({
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
agentPath: z.string(),
|
|
21
|
+
agentArgs: z.array(z.string()).optional(),
|
|
22
|
+
environment: z.record(z.string(), z.string()).optional(),
|
|
23
|
+
workingDirectory: z.string().optional(),
|
|
24
|
+
timeout: z.number().optional(),
|
|
24
25
|
});
|
|
25
26
|
/**
|
|
26
27
|
* Session metadata
|
|
27
28
|
*/
|
|
28
29
|
export const SessionMetadata = z.object({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
agentName: z.string().optional(),
|
|
31
|
+
agentVersion: z.string().optional(),
|
|
32
|
+
capabilities: z.array(z.string()).optional(),
|
|
33
|
+
startedAt: z.iso.datetime(),
|
|
34
|
+
lastActivityAt: z.iso.datetime().optional(),
|
|
34
35
|
});
|
|
35
36
|
/**
|
|
36
37
|
* Session schema
|
|
37
38
|
*/
|
|
38
39
|
export const Session = z.object({
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
id: z.string(),
|
|
41
|
+
status: SessionStatus,
|
|
42
|
+
config: SessionConfig,
|
|
43
|
+
metadata: SessionMetadata.optional(),
|
|
44
|
+
messages: z.array(Message),
|
|
45
|
+
error: z.string().optional(),
|
|
45
46
|
});
|
|
46
47
|
/**
|
|
47
|
-
* Session update event
|
|
48
|
+
* Session update event (base type)
|
|
48
49
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
const BaseSessionUpdate = z.object({
|
|
51
|
+
sessionId: z.string(),
|
|
52
|
+
status: SessionStatus.optional(),
|
|
53
|
+
message: Message.optional(),
|
|
54
|
+
error: z.string().optional(),
|
|
54
55
|
});
|
|
56
|
+
/**
|
|
57
|
+
* Session update with tool call (sessionUpdate: "tool_call")
|
|
58
|
+
*/
|
|
59
|
+
const ToolCallSessionUpdate = BaseSessionUpdate.extend({
|
|
60
|
+
type: z.literal("tool_call"),
|
|
61
|
+
toolCall: ToolCallSchema,
|
|
62
|
+
messageId: z.string().optional(),
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
* Session update with tool call update (sessionUpdate: "tool_call_update")
|
|
66
|
+
*/
|
|
67
|
+
const ToolCallUpdateSessionUpdate = BaseSessionUpdate.extend({
|
|
68
|
+
type: z.literal("tool_call_update"),
|
|
69
|
+
toolCallUpdate: ToolCallUpdateSchema,
|
|
70
|
+
messageId: z.string().optional(),
|
|
71
|
+
});
|
|
72
|
+
/**
|
|
73
|
+
* Session update with tool output (sessionUpdate: "tool_output")
|
|
74
|
+
* Sent separately from tool_call_update to avoid PostgreSQL NOTIFY size limits
|
|
75
|
+
*/
|
|
76
|
+
const ToolOutputSessionUpdate = BaseSessionUpdate.extend({
|
|
77
|
+
type: z.literal("tool_output"),
|
|
78
|
+
toolOutput: z.object({
|
|
79
|
+
id: z.string(),
|
|
80
|
+
content: z.array(z.any()).optional(), // ToolCallContentBlock[] but use any to avoid circular import
|
|
81
|
+
rawOutput: z.record(z.string(), z.unknown()).optional(),
|
|
82
|
+
}),
|
|
83
|
+
messageId: z.string().optional(),
|
|
84
|
+
});
|
|
85
|
+
/**
|
|
86
|
+
* Generic session update
|
|
87
|
+
*/
|
|
88
|
+
const GenericSessionUpdate = BaseSessionUpdate.extend({
|
|
89
|
+
type: z.literal("generic").optional(),
|
|
90
|
+
});
|
|
91
|
+
/**
|
|
92
|
+
* Session update event (union type)
|
|
93
|
+
*/
|
|
94
|
+
export const SessionUpdate = z.union([
|
|
95
|
+
ToolCallSessionUpdate,
|
|
96
|
+
ToolCallUpdateSessionUpdate,
|
|
97
|
+
ToolOutputSessionUpdate,
|
|
98
|
+
GenericSessionUpdate,
|
|
99
|
+
]);
|