@assistant-ui/react-statewire 0.2.0 → 0.3.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.
package/src/types.ts CHANGED
@@ -36,8 +36,8 @@ export type AssistantMessage = {
36
36
  readonly parts: readonly TextPart[];
37
37
  };
38
38
 
39
- export type MessageAddCommand = {
40
- readonly type: "message/add";
39
+ export type AddMessageCommand = {
40
+ readonly type: "add-message";
41
41
  readonly message: UserMessage | AssistantMessage;
42
42
  readonly parentId: string | null;
43
43
  readonly sourceId: string | null;
@@ -49,8 +49,8 @@ export type MessageAddCommand = {
49
49
  readonly behavior?: "queue" | "steer";
50
50
  };
51
51
 
52
- export type ToolResultAddCommand = {
53
- readonly type: "tool-result/add";
52
+ export type AddToolResultCommand = {
53
+ readonly type: "add-tool-result";
54
54
  readonly toolCallId: string;
55
55
  readonly toolName: string;
56
56
  readonly result: ReadonlyJSONValue;
@@ -59,15 +59,147 @@ export type ToolResultAddCommand = {
59
59
  readonly modelContent?: readonly ToolModelContentPart[];
60
60
  };
61
61
 
62
+ export type FilePart = {
63
+ readonly type: "file";
64
+ readonly mediaType: string;
65
+ readonly url: string;
66
+ readonly filename?: string;
67
+ };
68
+
69
+ export type RunUserMessage = {
70
+ readonly id: string;
71
+ readonly role: "user";
72
+ readonly parts: readonly (TextPart | FilePart)[];
73
+ readonly metadata?: Record<string, unknown>;
74
+ };
75
+
76
+ /** Queue placement fields, flat on the command. Absent is load-bearing: it means default placement; `null` names a queue boundary. */
77
+ export type RunPlacement = {
78
+ readonly insertAfter?: string | null;
79
+ readonly insertBefore?: string | null;
80
+ };
81
+
82
+ export type RunEnqueueCommand = {
83
+ readonly type: "run/enqueue";
84
+ } & ({ readonly message: RunUserMessage } | { readonly messageId: string }) &
85
+ RunPlacement;
86
+
87
+ export type RunSteerCommand = {
88
+ readonly type: "run/steer";
89
+ } & ({ readonly message: RunUserMessage } | { readonly messageId: string }) &
90
+ RunPlacement;
91
+
92
+ export type RunDequeueCommand = {
93
+ readonly type: "run/dequeue";
94
+ readonly messageId: string;
95
+ };
96
+
97
+ export type RunEditCommand = {
98
+ readonly type: "run/edit";
99
+ readonly message: RunUserMessage;
100
+ readonly sourceId: string;
101
+ };
102
+
103
+ export type RunContinueCommand = {
104
+ readonly type: "run/continue";
105
+ };
106
+
107
+ export type ToolCallInputRequest = {
108
+ readonly type: "tool-call";
109
+ readonly id: string;
110
+ readonly toolCallId: string;
111
+ };
112
+
113
+ export type ToolApprovalInputRequest = {
114
+ readonly type: "tool-approval";
115
+ readonly id: string;
116
+ readonly toolCallId: string;
117
+ };
118
+
119
+ export type CustomInputRequest = {
120
+ readonly type: string;
121
+ readonly id: string;
122
+ readonly [key: string]: ReadonlyJSONValue | undefined;
123
+ };
124
+
125
+ /** A host request parking the run until answered; open union for custom types. */
126
+ export type InputRequest =
127
+ | ToolCallInputRequest
128
+ | ToolApprovalInputRequest
129
+ | CustomInputRequest;
130
+
131
+ export type ToolCallInputResponse = {
132
+ readonly output: ReadonlyJSONValue;
133
+ /** Default false; when true, `output` carries the error payload. */
134
+ readonly isError?: boolean;
135
+ readonly artifact?: ReadonlyJSONValue;
136
+ };
137
+
138
+ export type ToolApprovalInputResponse = {
139
+ readonly decision: "approve" | "reject" | "edit" | "respond";
140
+ readonly editedArgs?: ReadonlyJSONValue;
141
+ readonly message?: string;
142
+ };
143
+
144
+ export type InputResponse = ReadonlyJSONValue;
145
+
146
+ export type RunInputCommand = {
147
+ readonly type: "run/input";
148
+ readonly requestId: string;
149
+ readonly response: InputResponse;
150
+ };
151
+
152
+ /** An input request projected out of the host state with its response echo. */
153
+ export type InputRequestState = InputRequest & {
154
+ readonly response: InputResponse | null;
155
+ };
156
+
157
+ export type RunReloadCommand = {
158
+ readonly type: "run/reload";
159
+ readonly sourceId: string;
160
+ };
161
+
162
+ export type RunCommand =
163
+ | RunEnqueueCommand
164
+ | RunSteerCommand
165
+ | RunDequeueCommand
166
+ | RunEditCommand
167
+ | RunContinueCommand
168
+ | RunReloadCommand
169
+ | RunInputCommand;
170
+
62
171
  export type AssistantTransportCommand =
63
- | MessageAddCommand
64
- | ToolResultAddCommand
172
+ | AddMessageCommand
173
+ | AddToolResultCommand
174
+ | RunCommand
65
175
  | UserCommands;
66
176
 
177
+ /** A queued message projected out of the host state, wire shape. */
178
+ export type RunQueueItem = {
179
+ readonly id: string;
180
+ readonly parts: readonly (TextPart | FilePart)[];
181
+ };
182
+
67
183
  export type AssistantTransportState = {
68
184
  readonly messages: readonly ThreadMessage[];
69
185
  readonly state?: ReadonlyJSONValue;
70
186
  readonly isRunning: boolean;
187
+ /**
188
+ * The host's regular queue lane projected out of the state. Returning it
189
+ * (even empty) turns on the server-side queue: sends become `run/enqueue`
190
+ * / `run/steer` commands and item controls send the `run/*` queue
191
+ * commands. Presence must be stable across conversions and excludes the
192
+ * client-local `capabilities.queue` buffer.
193
+ */
194
+ readonly queue?: readonly RunQueueItem[];
195
+ /** The host's steer lane; requires `queue`. Absent means empty. */
196
+ readonly steerQueue?: readonly RunQueueItem[];
197
+ /**
198
+ * The host's parked input requests projected out of the state. Returning it
199
+ * (even empty) routes tool results and approvals with a matching pending
200
+ * request through `run/input`. Presence must be stable across conversions.
201
+ */
202
+ readonly inputRequests?: readonly InputRequestState[];
71
203
  };
72
204
 
73
205
  export type AssistantTransportConnectionMetadata = {
@@ -139,8 +271,11 @@ export type AssistantTransportOptions<T> = {
139
271
  /**
140
272
  * Buffer messages sent during a run in an in-memory queue and dispatch
141
273
  * them once the run settles. Steering interrupts the active run.
274
+ * Mutually exclusive with the converter's `queue` projection.
142
275
  */
143
276
  queue?: boolean | undefined;
277
+ /** The host supports `run/continue` (a continue affordance on aborted runs). */
278
+ continue?: boolean | undefined;
144
279
  }
145
280
  | undefined;
146
281
  adapters?: