@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.
Files changed (42) hide show
  1. package/dist/core/hooks/index.d.ts +1 -0
  2. package/dist/core/hooks/index.js +1 -0
  3. package/dist/core/hooks/use-chat-messages.d.ts +50 -11
  4. package/dist/core/hooks/use-chat-session.d.ts +5 -5
  5. package/dist/core/hooks/use-tool-calls.d.ts +52 -0
  6. package/dist/core/hooks/use-tool-calls.js +61 -0
  7. package/dist/core/index.d.ts +1 -0
  8. package/dist/core/index.js +1 -0
  9. package/dist/core/lib/logger.d.ts +24 -0
  10. package/dist/core/lib/logger.js +108 -0
  11. package/dist/core/schemas/chat.d.ts +166 -83
  12. package/dist/core/schemas/chat.js +27 -27
  13. package/dist/core/schemas/index.d.ts +1 -0
  14. package/dist/core/schemas/index.js +1 -0
  15. package/dist/core/schemas/tool-call.d.ts +174 -0
  16. package/dist/core/schemas/tool-call.js +130 -0
  17. package/dist/core/store/chat-store.d.ts +28 -28
  18. package/dist/core/store/chat-store.js +123 -59
  19. package/dist/gui/components/ChatLayout.js +11 -10
  20. package/dist/gui/components/MessageContent.js +4 -1
  21. package/dist/gui/components/ToolCall.d.ts +8 -0
  22. package/dist/gui/components/ToolCall.js +100 -0
  23. package/dist/gui/components/ToolCallList.d.ts +9 -0
  24. package/dist/gui/components/ToolCallList.js +22 -0
  25. package/dist/gui/components/index.d.ts +2 -0
  26. package/dist/gui/components/index.js +2 -0
  27. package/dist/gui/components/resizable.d.ts +7 -0
  28. package/dist/gui/components/resizable.js +7 -0
  29. package/dist/sdk/schemas/session.d.ts +390 -220
  30. package/dist/sdk/schemas/session.js +74 -29
  31. package/dist/sdk/transports/http.js +705 -472
  32. package/dist/sdk/transports/stdio.js +187 -32
  33. package/dist/tui/components/ChatView.js +19 -51
  34. package/dist/tui/components/MessageList.d.ts +2 -4
  35. package/dist/tui/components/MessageList.js +13 -37
  36. package/dist/tui/components/ToolCall.d.ts +9 -0
  37. package/dist/tui/components/ToolCall.js +41 -0
  38. package/dist/tui/components/ToolCallList.d.ts +8 -0
  39. package/dist/tui/components/ToolCallList.js +17 -0
  40. package/dist/tui/components/index.d.ts +2 -0
  41. package/dist/tui/components/index.js +2 -0
  42. 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
- "idle",
8
- "connecting",
9
- "connected",
10
- "active",
11
- "streaming",
12
- "error",
13
- "disconnected",
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
- agentPath: z.string(),
20
- agentArgs: z.array(z.string()).optional(),
21
- environment: z.record(z.string(), z.string()).optional(),
22
- workingDirectory: z.string().optional(),
23
- timeout: z.number().optional(),
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
- agentName: z.string().optional(),
30
- agentVersion: z.string().optional(),
31
- capabilities: z.array(z.string()).optional(),
32
- startedAt: z.iso.datetime(),
33
- lastActivityAt: z.iso.datetime().optional(),
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
- id: z.string(),
40
- status: SessionStatus,
41
- config: SessionConfig,
42
- metadata: SessionMetadata.optional(),
43
- messages: z.array(Message),
44
- error: z.string().optional(),
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
- export const SessionUpdate = z.object({
50
- sessionId: z.string(),
51
- status: SessionStatus.optional(),
52
- message: Message.optional(),
53
- error: z.string().optional(),
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
+ ]);