@batonfx/foldkit 0.4.0 → 0.4.1

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/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # `@batonfx/foldkit`
2
+
3
+ FoldKit adapter for Baton transport sessions and chat UI.
4
+
5
+ See the [Baton documentation](https://github.com/In-Time-Tec/batonfx#readme) for installation, examples, and API guidance.
package/dist/chat.d.ts ADDED
@@ -0,0 +1,271 @@
1
+ import { Equivalence, Effect, Option, Schema, Stream } from "effect";
2
+ import { type Command } from "foldkit/command";
3
+ import type { CallableTaggedStruct } from "foldkit/schema";
4
+ import { AgentConnection, Incoming } from "./connection.js";
5
+ declare const CompletedFields: {
6
+ isFailure: Schema.Boolean;
7
+ result: Schema.Unknown;
8
+ };
9
+ declare const UserEntryFields: {
10
+ text: Schema.String;
11
+ };
12
+ declare const AssistantEntryFields: {
13
+ text: Schema.String;
14
+ reasoning: Schema.NullOr<Schema.String>;
15
+ };
16
+ declare const RunCompletedFields: {
17
+ text: Schema.String;
18
+ };
19
+ declare const StringReasonFields: {
20
+ reason: Schema.String;
21
+ };
22
+ declare const OpenedSessionFields: {
23
+ sessionId: Schema.String;
24
+ };
25
+ /** @experimental */
26
+ export declare const ToolPendingPhase: Schema.Literals<readonly ["called", "executing"]>;
27
+ /** @experimental */
28
+ export type ToolPendingPhase = typeof ToolPendingPhase.Type;
29
+ declare const ToolEntryFields: {
30
+ callId: Schema.String;
31
+ name: Schema.String;
32
+ params: Schema.Unknown;
33
+ phase: Schema.Literals<readonly ["called", "executing"]>;
34
+ outcome: Schema.suspend<Schema.Schema<ToolOutcome>>;
35
+ progress: Schema.$Array<Schema.String>;
36
+ };
37
+ declare const RunningFields: {
38
+ turn: Schema.Number;
39
+ };
40
+ declare const AwaitingApprovalFields: {
41
+ token: Schema.String;
42
+ toolName: Schema.String;
43
+ params: Schema.Unknown;
44
+ };
45
+ declare const ClickedDenyFields: {
46
+ reason: Schema.NullOr<Schema.String>;
47
+ };
48
+ declare const ReceivedAgentFields: {
49
+ incoming: Schema.Schema<Incoming>;
50
+ };
51
+ declare const ModelStreaming: Schema.Struct<{
52
+ readonly turn: Schema.Number;
53
+ readonly text: Schema.String;
54
+ readonly reasoning: Schema.String;
55
+ }>;
56
+ declare const ModelConnection: Schema.Literals<readonly ["disconnected", "connecting", "open", "reconnecting"]>;
57
+ declare const Pending: CallableTaggedStruct<"Pending", {}>;
58
+ declare const Completed: CallableTaggedStruct<"Completed", typeof CompletedFields>;
59
+ /** @experimental */
60
+ export type ToolOutcome = typeof Pending.Type | typeof Completed.Type;
61
+ /** @experimental */
62
+ export declare const ToolOutcome: Schema.Schema<ToolOutcome>;
63
+ /** @experimental */
64
+ export declare const UserEntry: CallableTaggedStruct<"UserEntry", typeof UserEntryFields>;
65
+ /** @experimental */
66
+ export declare const AssistantEntry: CallableTaggedStruct<"AssistantEntry", typeof AssistantEntryFields>;
67
+ /** @experimental */
68
+ export declare const ToolEntry: CallableTaggedStruct<"ToolEntry", typeof ToolEntryFields>;
69
+ /** @experimental */
70
+ export type ChatEntry = typeof UserEntry.Type | typeof AssistantEntry.Type | typeof ToolEntry.Type;
71
+ /** @experimental */
72
+ export declare const ChatEntry: Schema.Schema<ChatEntry>;
73
+ /** @experimental */
74
+ export declare const Idle: CallableTaggedStruct<"Idle", {}>;
75
+ /** @experimental */
76
+ export declare const Running: CallableTaggedStruct<"Running", typeof RunningFields>;
77
+ /** @experimental */
78
+ export declare const AwaitingApproval: CallableTaggedStruct<"AwaitingApproval", typeof AwaitingApprovalFields>;
79
+ /** @experimental */
80
+ export declare const Failed: CallableTaggedStruct<"Failed", {
81
+ message: typeof Schema.String;
82
+ }>;
83
+ /** @experimental */
84
+ export type RunState = typeof Idle.Type | typeof Running.Type | typeof AwaitingApproval.Type | typeof Failed.Type;
85
+ /** @experimental */
86
+ export declare const RunState: Schema.Schema<RunState>;
87
+ /** @experimental */
88
+ export interface Model {
89
+ readonly sessionId: string | null;
90
+ readonly connection: typeof ModelConnection.Type;
91
+ readonly lastSeq: number;
92
+ readonly run: RunState;
93
+ readonly entries: ReadonlyArray<ChatEntry>;
94
+ readonly streaming: typeof ModelStreaming.Type | null;
95
+ readonly draft: string;
96
+ }
97
+ /** @experimental */
98
+ export declare const Model: Schema.Schema<Model>;
99
+ /** @experimental */
100
+ export declare const ReceivedAgent: CallableTaggedStruct<"ReceivedAgent", typeof ReceivedAgentFields>;
101
+ /** @experimental */
102
+ export declare const OpenedSession: CallableTaggedStruct<"OpenedSession", typeof OpenedSessionFields>;
103
+ /** @experimental */
104
+ export declare const ChangedDraft: CallableTaggedStruct<"ChangedDraft", typeof UserEntryFields>;
105
+ /** @experimental */
106
+ export declare const SubmittedMessage: CallableTaggedStruct<"SubmittedMessage", {}>;
107
+ /** @experimental */
108
+ export declare const ClickedCancel: CallableTaggedStruct<"ClickedCancel", {}>;
109
+ /** @experimental */
110
+ export declare const ClickedApprove: CallableTaggedStruct<"ClickedApprove", {}>;
111
+ /** @experimental */
112
+ export declare const ClickedDeny: CallableTaggedStruct<"ClickedDeny", typeof ClickedDenyFields>;
113
+ /** @experimental */
114
+ export declare const SentUserMessage: CallableTaggedStruct<"SentUserMessage", {}>;
115
+ /** @experimental */
116
+ export declare const ResolvedApproval: CallableTaggedStruct<"ResolvedApproval", {}>;
117
+ /** @experimental */
118
+ export declare const CancelledRun: CallableTaggedStruct<"CancelledRun", {}>;
119
+ /** @experimental */
120
+ export declare const FailedAgentCommand: CallableTaggedStruct<"FailedAgentCommand", typeof StringReasonFields>;
121
+ /** @experimental */
122
+ export type Message = typeof ReceivedAgent.Type | typeof OpenedSession.Type | typeof ChangedDraft.Type | typeof SubmittedMessage.Type | typeof ClickedCancel.Type | typeof ClickedApprove.Type | typeof ClickedDeny.Type | typeof SentUserMessage.Type | typeof ResolvedApproval.Type | typeof CancelledRun.Type | typeof FailedAgentCommand.Type;
123
+ /** @experimental */
124
+ export declare const Message: Schema.Schema<Message>;
125
+ /** @experimental */
126
+ export declare const RunCompleted: CallableTaggedStruct<"RunCompleted", typeof RunCompletedFields>;
127
+ /** @experimental */
128
+ export declare const ApprovalRequired: CallableTaggedStruct<"ApprovalRequired", {}>;
129
+ /** @experimental */
130
+ export declare const RunFailed: CallableTaggedStruct<"RunFailed", {
131
+ message: typeof Schema.String;
132
+ }>;
133
+ /** @experimental */
134
+ export type OutMessage = typeof RunCompleted.Type | typeof ApprovalRequired.Type | typeof RunFailed.Type;
135
+ /** @experimental */
136
+ export declare const OutMessage: Schema.Schema<OutMessage>;
137
+ /** @experimental */
138
+ export declare const MessageAlign: Schema.Literals<readonly ["start", "end"]>;
139
+ /** @experimental */
140
+ export type MessageAlign = typeof MessageAlign.Type;
141
+ /** @experimental */
142
+ export declare const PromptInputStatus: Schema.Literals<readonly ["idle", "submitted", "streaming", "error"]>;
143
+ /** @experimental */
144
+ export type PromptInputStatus = typeof PromptInputStatus.Type;
145
+ /** @experimental */
146
+ export declare const ToolStatus: Schema.Literals<readonly ["input-streaming", "input-available", "output-available", "output-error"]>;
147
+ /** @experimental */
148
+ export type ToolStatus = typeof ToolStatus.Type;
149
+ /** @experimental */
150
+ export declare const UserConversationItem: CallableTaggedStruct<"UserConversationItem", {
151
+ key: typeof Schema.String;
152
+ align: typeof MessageAlign;
153
+ entry: typeof UserEntry;
154
+ }>;
155
+ /** @experimental */
156
+ export declare const AssistantConversationItem: CallableTaggedStruct<"AssistantConversationItem", {
157
+ key: typeof Schema.String;
158
+ align: typeof MessageAlign;
159
+ entry: typeof AssistantEntry;
160
+ }>;
161
+ /** @experimental */
162
+ export declare const ToolConversationItem: CallableTaggedStruct<"ToolConversationItem", {
163
+ key: typeof Schema.String;
164
+ align: typeof MessageAlign;
165
+ entry: typeof ToolEntry;
166
+ status: typeof ToolStatus;
167
+ input: typeof Schema.String;
168
+ }>;
169
+ /** @experimental */
170
+ export declare const StreamingConversationItem: CallableTaggedStruct<"StreamingConversationItem", {
171
+ key: typeof Schema.String;
172
+ align: typeof MessageAlign;
173
+ text: typeof Schema.String;
174
+ reasoning: typeof Schema.String;
175
+ isStreaming: typeof Schema.Boolean;
176
+ }>;
177
+ /** @experimental */
178
+ export declare const WaitingConversationItem: CallableTaggedStruct<"WaitingConversationItem", {
179
+ key: typeof Schema.String;
180
+ align: typeof MessageAlign;
181
+ }>;
182
+ /** @experimental */
183
+ export declare const ApprovalConversationItem: CallableTaggedStruct<"ApprovalConversationItem", {
184
+ key: typeof Schema.String;
185
+ align: typeof MessageAlign;
186
+ token: typeof Schema.String;
187
+ toolName: typeof Schema.String;
188
+ params: typeof Schema.Unknown;
189
+ }>;
190
+ /** @experimental */
191
+ export declare const FailureConversationItem: CallableTaggedStruct<"FailureConversationItem", {
192
+ key: typeof Schema.String;
193
+ align: typeof MessageAlign;
194
+ message: typeof Schema.String;
195
+ }>;
196
+ /** @experimental */
197
+ export type ConversationItem = typeof UserConversationItem.Type | typeof AssistantConversationItem.Type | typeof ToolConversationItem.Type | typeof StreamingConversationItem.Type | typeof WaitingConversationItem.Type | typeof ApprovalConversationItem.Type | typeof FailureConversationItem.Type;
198
+ /** @experimental */
199
+ export declare const ConversationItem: Schema.Schema<ConversationItem>;
200
+ /** @experimental */
201
+ export type ChatCommand = Command<Message, any, AgentConnection>;
202
+ /** @experimental */
203
+ export declare const initialModel: (sessionId?: string | null) => Model;
204
+ /** @experimental */
205
+ export declare const SendUserMessage: import("foldkit/command").CommandDefinitionWithArgs<"SendUserMessage", {
206
+ sessionId: Schema.String;
207
+ text: Schema.String;
208
+ }, Effect.Effect<Schema.Struct.ReadonlySide<{
209
+ readonly _tag: Schema.tag<"FailedAgentCommand">;
210
+ reason: Schema.String;
211
+ }, "Type"> | {
212
+ readonly _tag: "SentUserMessage";
213
+ }, never, AgentConnection>>;
214
+ /** @experimental */
215
+ export declare const ResolveApproval: import("foldkit/command").CommandDefinitionWithArgs<"ResolveApproval", {
216
+ sessionId: Schema.String;
217
+ token: Schema.String;
218
+ approved: Schema.Boolean;
219
+ reason: Schema.NullOr<Schema.String>;
220
+ }, Effect.Effect<Schema.Struct.ReadonlySide<{
221
+ readonly _tag: Schema.tag<"FailedAgentCommand">;
222
+ reason: Schema.String;
223
+ }, "Type"> | {
224
+ readonly _tag: "ResolvedApproval";
225
+ }, never, AgentConnection>>;
226
+ /** @experimental */
227
+ export declare const CancelRun: import("foldkit/command").CommandDefinitionWithArgs<"CancelRun", {
228
+ sessionId: Schema.String;
229
+ }, Effect.Effect<Schema.Struct.ReadonlySide<{
230
+ readonly _tag: Schema.tag<"FailedAgentCommand">;
231
+ reason: Schema.String;
232
+ }, "Type"> | {
233
+ readonly _tag: "CancelledRun";
234
+ }, never, AgentConnection>>;
235
+ /** @experimental */
236
+ export declare const promptInputStatusOf: (run: RunState) => PromptInputStatus;
237
+ /** @experimental */
238
+ export declare const toolStatusOf: (entry: typeof ToolEntry.Type) => ToolStatus;
239
+ /** @experimental */
240
+ export declare const conversationItems: (model: Model) => ReadonlyArray<ConversationItem>;
241
+ /** @experimental */
242
+ export declare const update: (model: Model, message: Message) => readonly [Model, ReadonlyArray<ChatCommand>, Option.Option<OutMessage>];
243
+ /** @experimental */
244
+ export declare const subscriptions: {
245
+ readonly agentFrames: {
246
+ readonly dependenciesSchema: Schema.Schema<Schema.Struct.ReadonlySide<{
247
+ readonly sessionId: Schema.NullOr<Schema.String>;
248
+ readonly afterSeq: Schema.Number;
249
+ }, "Type">> & {
250
+ readonly fields: Schema.Struct.Fields;
251
+ };
252
+ readonly modelToDependencies: (model: Model) => Schema.Struct.ReadonlySide<{
253
+ readonly sessionId: Schema.NullOr<Schema.String>;
254
+ readonly afterSeq: Schema.Number;
255
+ }, "Type">;
256
+ readonly keepAliveEquivalence: Equivalence.Equivalence<Schema.Struct.ReadonlySide<{
257
+ readonly sessionId: Schema.NullOr<Schema.String>;
258
+ readonly afterSeq: Schema.Number;
259
+ }, "Type">>;
260
+ readonly dependenciesToStream: (dependencies: Schema.Struct.ReadonlySide<{
261
+ readonly sessionId: Schema.NullOr<Schema.String>;
262
+ readonly afterSeq: Schema.Number;
263
+ }, "Type">, readDependencies: () => Schema.Struct.ReadonlySide<{
264
+ readonly sessionId: Schema.NullOr<Schema.String>;
265
+ readonly afterSeq: Schema.Number;
266
+ }, "Type">) => Stream.Stream<Message, never, AgentConnection>;
267
+ } & {
268
+ readonly __subscription: never;
269
+ };
270
+ };
271
+ export {};