@textui/chat 0.6.0

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 (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +76 -0
  3. package/dist/blocks.d.ts +75 -0
  4. package/dist/blocks.d.ts.map +1 -0
  5. package/dist/blocks.js +50 -0
  6. package/dist/bubble.d.ts +122 -0
  7. package/dist/bubble.d.ts.map +1 -0
  8. package/dist/bubble.js +108 -0
  9. package/dist/composer.d.ts +67 -0
  10. package/dist/composer.d.ts.map +1 -0
  11. package/dist/composer.js +194 -0
  12. package/dist/controls.d.ts +66 -0
  13. package/dist/controls.d.ts.map +1 -0
  14. package/dist/controls.js +77 -0
  15. package/dist/details.d.ts +66 -0
  16. package/dist/details.d.ts.map +1 -0
  17. package/dist/details.js +65 -0
  18. package/dist/diff.d.ts +45 -0
  19. package/dist/diff.d.ts.map +1 -0
  20. package/dist/diff.js +111 -0
  21. package/dist/filediff.d.ts +30 -0
  22. package/dist/filediff.d.ts.map +1 -0
  23. package/dist/filediff.js +24 -0
  24. package/dist/hitl.d.ts +85 -0
  25. package/dist/hitl.d.ts.map +1 -0
  26. package/dist/hitl.js +134 -0
  27. package/dist/icons.d.ts +14 -0
  28. package/dist/icons.d.ts.map +1 -0
  29. package/dist/icons.js +71 -0
  30. package/dist/index.d.ts +17 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +16 -0
  33. package/dist/measure.d.ts +14 -0
  34. package/dist/measure.d.ts.map +1 -0
  35. package/dist/measure.js +19 -0
  36. package/dist/picker.d.ts +43 -0
  37. package/dist/picker.d.ts.map +1 -0
  38. package/dist/picker.js +79 -0
  39. package/dist/sessionhead.d.ts +42 -0
  40. package/dist/sessionhead.d.ts.map +1 -0
  41. package/dist/sessionhead.js +58 -0
  42. package/dist/sessions.d.ts +35 -0
  43. package/dist/sessions.d.ts.map +1 -0
  44. package/dist/sessions.js +58 -0
  45. package/dist/toolcall.d.ts +28 -0
  46. package/dist/toolcall.d.ts.map +1 -0
  47. package/dist/toolcall.js +54 -0
  48. package/dist/transcript.d.ts +53 -0
  49. package/dist/transcript.d.ts.map +1 -0
  50. package/dist/transcript.js +67 -0
  51. package/dist/types.d.ts +176 -0
  52. package/dist/types.d.ts.map +1 -0
  53. package/dist/types.js +11 -0
  54. package/package.json +58 -0
  55. package/src/blocks.ts +73 -0
  56. package/src/bubble.tsx +266 -0
  57. package/src/composer.tsx +302 -0
  58. package/src/controls.tsx +222 -0
  59. package/src/details.tsx +162 -0
  60. package/src/diff.ts +132 -0
  61. package/src/filediff.tsx +118 -0
  62. package/src/hitl.tsx +392 -0
  63. package/src/icons.ts +109 -0
  64. package/src/index.ts +16 -0
  65. package/src/measure.ts +21 -0
  66. package/src/picker.ts +105 -0
  67. package/src/sessionhead.tsx +105 -0
  68. package/src/sessions.tsx +146 -0
  69. package/src/toolcall.tsx +136 -0
  70. package/src/transcript.tsx +221 -0
  71. package/src/types.ts +171 -0
package/src/types.ts ADDED
@@ -0,0 +1,171 @@
1
+ /**
2
+ * What the chat components are told, in the components' own words.
3
+ *
4
+ * These are view shapes, not a protocol. A client that speaks AHP, or
5
+ * anything else, maps its own records onto them and the components never
6
+ * learn where a session or a tool call came from. The field names follow the
7
+ * Agent Host Protocol's where one exists, so that mapping is a pick rather
8
+ * than a rename - but nothing here is imported from it, and nothing here
9
+ * says how a session is fetched.
10
+ */
11
+
12
+ export type ChatToolCallStatus =
13
+ | 'pending' | 'pending-confirmation' | 'running' | 'completed' | 'failed' | 'cancelled';
14
+
15
+ /** One tool call, flat: the fields that are not there yet are absent. */
16
+ export interface ChatToolCall {
17
+ id: string;
18
+ /** What the row calls it. */
19
+ name: string;
20
+ /**
21
+ * The tool's own id, where it differs from the display name.
22
+ *
23
+ * Hosts give many tools one display name - every subagent is "Explore" or
24
+ * "Plan" and the tool under all of them is `Task` - and a person searching
25
+ * the transcript for the one or the other should find the row either way.
26
+ */
27
+ toolName?: string;
28
+ status: ChatToolCallStatus;
29
+ /** The command. The only thing separating twenty identical rows. */
30
+ input?: string;
31
+ /** What it meant to do. Markdown. */
32
+ intention?: string;
33
+ /**
34
+ * What it is doing right now, while it runs.
35
+ *
36
+ * A line drawn on a running row and dropped when the row ends: a
37
+ * subagent's own summary of how far it has got, the last tool it reached
38
+ * for. Read only while `running`; a host that leaves it on a finished call
39
+ * is still describing a state the call is no longer in.
40
+ */
41
+ progress?: string;
42
+ /** What it did, past tense. */
43
+ outcome?: string;
44
+ /** What came back. */
45
+ output?: string;
46
+ exitCode?: number;
47
+ files?: string[];
48
+ /** Set while `pending-confirmation`. */
49
+ confirmationTitle?: string;
50
+ options?: { id: string; label: string }[];
51
+ }
52
+
53
+ export type ChatActivity = 'input' | 'running' | 'error' | 'idle';
54
+
55
+ /**
56
+ * A session's state, already decoded.
57
+ *
58
+ * The word, the colour and the glyph travel together because none of them is
59
+ * allowed to be the only carrier: a piped log keeps the word, a 16-colour
60
+ * terminal keeps the glyph, and a reader who cannot see the colour keeps both.
61
+ */
62
+ export interface ChatSessionStatus {
63
+ activity: ChatActivity;
64
+ archived: boolean;
65
+ read: boolean;
66
+ label: string;
67
+ tone: 'warning' | 'accent' | 'danger' | 'muted';
68
+ glyph: 'bulletHalf' | 'bulletFilled' | 'cross' | 'bulletHollow';
69
+ }
70
+
71
+ /** One row of the catalogue, and the head over a conversation. */
72
+ export interface ChatSession {
73
+ id: string;
74
+ title: string;
75
+ /** Which harness runs it. */
76
+ provider: string;
77
+ status: ChatSessionStatus;
78
+ createdAt: string;
79
+ modifiedAt: string;
80
+ workingDirectories: string[];
81
+ /** The project as the host names it, when it does. */
82
+ project?: string;
83
+ branch?: string;
84
+ /**
85
+ * The pull request the branch became, as the row says it: `#412 merged`.
86
+ *
87
+ * Already a label. Which host key holds the number and which the state is
88
+ * the client's to know; the row only has one line to say it on.
89
+ */
90
+ pullRequest?: string;
91
+ /** What the host says it is doing, in its own words. */
92
+ activity?: string;
93
+ /** Why it is here when nobody started it, as a phrase: "by an automation". */
94
+ origin?: string;
95
+ changes?: { files?: number; additions?: number; deletions?: number };
96
+ }
97
+
98
+ export type ChatQuestionKind =
99
+ | 'text' | 'number' | 'integer' | 'boolean' | 'single-select' | 'multi-select';
100
+
101
+ export interface ChatQuestion {
102
+ id: string;
103
+ kind: ChatQuestionKind;
104
+ message: string;
105
+ required?: boolean;
106
+ options?: { id: string; label: string }[];
107
+ /** Answering in words *instead of* choosing, not as a choice. */
108
+ allowFreeformInput?: boolean;
109
+ }
110
+
111
+ export type ChatAnswer =
112
+ | { kind: 'text'; value: string }
113
+ | { kind: 'number'; value: number }
114
+ | { kind: 'boolean'; value: boolean }
115
+ | { kind: 'selected'; value: string }
116
+ | { kind: 'selected-many'; value: string[] };
117
+
118
+ /** A yes or a no about a command, with named options where there are any. */
119
+ export interface ChatToolConfirmation {
120
+ kind: 'toolConfirmation';
121
+ id: string;
122
+ call: ChatToolCall;
123
+ }
124
+
125
+ /** A request in prose, with the questions under it. */
126
+ export interface ChatInputRequest {
127
+ kind: 'chatInput';
128
+ id: string;
129
+ message: string;
130
+ questions: ChatQuestion[];
131
+ }
132
+
133
+ export type ChatPendingInput = ChatToolConfirmation | ChatInputRequest;
134
+
135
+ /** One entry of the path menu under the composer. */
136
+ export interface ChatCompletion {
137
+ /** What to put in the draft. */
138
+ insertText: string;
139
+ /** Where the replaced fragment starts, as an offset into the draft. */
140
+ rangeStart: number;
141
+ /** Where it ends. */
142
+ rangeEnd: number;
143
+ /** What a person reads in the menu. */
144
+ label: string;
145
+ /** One line under it, when there is something worth reading. */
146
+ description?: string;
147
+ }
148
+
149
+ /** One entry of the slash menu. */
150
+ export interface ChatCommand {
151
+ id: string;
152
+ kind: 'client' | 'session';
153
+ title: string;
154
+ description?: string;
155
+ /** Where a session command came from: the plugin or directory. */
156
+ from?: string;
157
+ /**
158
+ * What goes after the name, written the way it would be typed.
159
+ *
160
+ * `/autocompact <tokens>` says more about the command than a sentence
161
+ * describing it, and it is the one thing a menu cannot show in a row: the
162
+ * row is the name.
163
+ */
164
+ hint?: string;
165
+ }
166
+
167
+ /** The row under the composer: gone to the host, or never going. */
168
+ export interface ChatSendStatus {
169
+ state: 'sending' | 'failed';
170
+ text: string;
171
+ }