@batonfx/foldkit 0.4.3 → 0.4.4
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/chat.d.ts +11 -8
- package/dist/chat.js +8 -7
- package/dist/connection.d.ts +1 -1
- package/dist/connection.js +4 -4
- package/package.json +3 -3
package/dist/chat.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ declare const ToolEntryFields: {
|
|
|
35
35
|
progress: Schema.$Array<Schema.String>;
|
|
36
36
|
};
|
|
37
37
|
declare const RunningFields: {
|
|
38
|
-
turn: Schema.
|
|
38
|
+
turn: Schema.Finite;
|
|
39
39
|
};
|
|
40
40
|
declare const AwaitingApprovalFields: {
|
|
41
41
|
token: Schema.String;
|
|
@@ -49,7 +49,7 @@ declare const ReceivedAgentFields: {
|
|
|
49
49
|
incoming: Schema.Schema<Incoming>;
|
|
50
50
|
};
|
|
51
51
|
declare const ModelStreaming: Schema.Struct<{
|
|
52
|
-
readonly turn: Schema.
|
|
52
|
+
readonly turn: Schema.Finite;
|
|
53
53
|
readonly text: Schema.String;
|
|
54
54
|
readonly reasoning: Schema.String;
|
|
55
55
|
}>;
|
|
@@ -239,30 +239,33 @@ export declare const toolStatusOf: (entry: typeof ToolEntry.Type) => ToolStatus;
|
|
|
239
239
|
/** @experimental */
|
|
240
240
|
export declare const conversationItems: (model: Model) => ReadonlyArray<ConversationItem>;
|
|
241
241
|
/** @experimental */
|
|
242
|
-
export declare const update:
|
|
242
|
+
export declare const update: {
|
|
243
|
+
(message: Message): (model: Model) => readonly [Model, ReadonlyArray<ChatCommand>, Option.Option<OutMessage>];
|
|
244
|
+
(model: Model, message: Message): readonly [Model, ReadonlyArray<ChatCommand>, Option.Option<OutMessage>];
|
|
245
|
+
};
|
|
243
246
|
/** @experimental */
|
|
244
247
|
export declare const subscriptions: {
|
|
245
248
|
readonly agentFrames: {
|
|
246
249
|
readonly dependenciesSchema: Schema.Schema<Schema.Struct.ReadonlySide<{
|
|
247
250
|
readonly sessionId: Schema.NullOr<Schema.String>;
|
|
248
|
-
readonly afterSeq: Schema.
|
|
251
|
+
readonly afterSeq: Schema.Finite;
|
|
249
252
|
}, "Type">> & {
|
|
250
253
|
readonly fields: Schema.Struct.Fields;
|
|
251
254
|
};
|
|
252
255
|
readonly modelToDependencies: (model: Model) => Schema.Struct.ReadonlySide<{
|
|
253
256
|
readonly sessionId: Schema.NullOr<Schema.String>;
|
|
254
|
-
readonly afterSeq: Schema.
|
|
257
|
+
readonly afterSeq: Schema.Finite;
|
|
255
258
|
}, "Type">;
|
|
256
259
|
readonly keepAliveEquivalence: Equivalence.Equivalence<Schema.Struct.ReadonlySide<{
|
|
257
260
|
readonly sessionId: Schema.NullOr<Schema.String>;
|
|
258
|
-
readonly afterSeq: Schema.
|
|
261
|
+
readonly afterSeq: Schema.Finite;
|
|
259
262
|
}, "Type">>;
|
|
260
263
|
readonly dependenciesToStream: (dependencies: Schema.Struct.ReadonlySide<{
|
|
261
264
|
readonly sessionId: Schema.NullOr<Schema.String>;
|
|
262
|
-
readonly afterSeq: Schema.
|
|
265
|
+
readonly afterSeq: Schema.Finite;
|
|
263
266
|
}, "Type">, readDependencies: () => Schema.Struct.ReadonlySide<{
|
|
264
267
|
readonly sessionId: Schema.NullOr<Schema.String>;
|
|
265
|
-
readonly afterSeq: Schema.
|
|
268
|
+
readonly afterSeq: Schema.Finite;
|
|
266
269
|
}, "Type">) => Stream.Stream<Message, never, AgentConnection>;
|
|
267
270
|
} & {
|
|
268
271
|
readonly __subscription: never;
|
package/dist/chat.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Cause, Equivalence, Effect, Option, Schema, Stream } from "effect";
|
|
2
|
+
import { dual } from "effect/Function";
|
|
2
3
|
import { Prompt } from "effect/unstable/ai";
|
|
3
4
|
import { define } from "foldkit/command";
|
|
4
5
|
import { m } from "foldkit/message";
|
|
@@ -21,7 +22,7 @@ const ToolEntryFields = {
|
|
|
21
22
|
outcome: Schema.suspend(() => ToolOutcome),
|
|
22
23
|
progress: Schema.Array(Schema.String),
|
|
23
24
|
};
|
|
24
|
-
const RunningFields = { turn: Schema.
|
|
25
|
+
const RunningFields = { turn: Schema.Finite };
|
|
25
26
|
const AwaitingApprovalFields = {
|
|
26
27
|
token: Schema.String,
|
|
27
28
|
toolName: Schema.String,
|
|
@@ -30,7 +31,7 @@ const AwaitingApprovalFields = {
|
|
|
30
31
|
const ClickedDenyFields = { reason: Schema.NullOr(Schema.String) };
|
|
31
32
|
const ReceivedAgentFields = { incoming: Incoming };
|
|
32
33
|
const ModelStreaming = Schema.Struct({
|
|
33
|
-
turn: Schema.
|
|
34
|
+
turn: Schema.Finite,
|
|
34
35
|
text: Schema.String,
|
|
35
36
|
reasoning: Schema.String,
|
|
36
37
|
});
|
|
@@ -63,7 +64,7 @@ export const RunState = Schema.Union([Idle, Running, AwaitingApproval, Failed]);
|
|
|
63
64
|
export const Model = Schema.Struct({
|
|
64
65
|
sessionId: Schema.NullOr(Schema.String),
|
|
65
66
|
connection: ModelConnection,
|
|
66
|
-
lastSeq: Schema.
|
|
67
|
+
lastSeq: Schema.Finite,
|
|
67
68
|
run: RunState,
|
|
68
69
|
entries: Schema.Array(ChatEntry),
|
|
69
70
|
streaming: Schema.NullOr(ModelStreaming),
|
|
@@ -173,7 +174,7 @@ export const initialModel = (sessionId = null) => ({
|
|
|
173
174
|
streaming: null,
|
|
174
175
|
draft: "",
|
|
175
176
|
});
|
|
176
|
-
const commandFailed = (error) => FailedAgentCommand({ reason: error
|
|
177
|
+
const commandFailed = (error) => FailedAgentCommand({ reason: Schema.is(SendFailed)(error) ? error.reason : String(error) });
|
|
177
178
|
const catchCommandFailure = (effect) => effect.pipe(Effect.catchCause((cause) => Effect.succeed(commandFailed(Cause.squash(cause)))));
|
|
178
179
|
/** @experimental */
|
|
179
180
|
export const SendUserMessage = define("SendUserMessage", { sessionId: Schema.String, text: Schema.String }, SentUserMessage, FailedAgentCommand)(({ sessionId, text }) => AgentConnection.use((connection) => catchCommandFailure(connection.send({ _tag: "SendMessage", sessionId, prompt: text }).pipe(Effect.as(SentUserMessage())))));
|
|
@@ -495,7 +496,7 @@ const isServerFrame = (incoming) => incoming._tag === "Event" ||
|
|
|
495
496
|
incoming._tag === "Snapshot" ||
|
|
496
497
|
incoming._tag === "SessionStatus";
|
|
497
498
|
/** @experimental */
|
|
498
|
-
export const update = (model, message) => {
|
|
499
|
+
export const update = dual(2, (model, message) => {
|
|
499
500
|
switch (message._tag) {
|
|
500
501
|
case "ReceivedAgent":
|
|
501
502
|
if (isServerFrame(message.incoming)) {
|
|
@@ -585,10 +586,10 @@ export const update = (model, message) => {
|
|
|
585
586
|
case "CancelledRun":
|
|
586
587
|
return [model, [], Option.none()];
|
|
587
588
|
}
|
|
588
|
-
};
|
|
589
|
+
});
|
|
589
590
|
/** @experimental */
|
|
590
591
|
export const subscriptions = make()((entry) => ({
|
|
591
|
-
agentFrames: entry({ sessionId: Schema.NullOr(Schema.String), afterSeq: Schema.
|
|
592
|
+
agentFrames: entry({ sessionId: Schema.NullOr(Schema.String), afterSeq: Schema.Finite }, {
|
|
592
593
|
modelToDependencies: (model) => ({ sessionId: model.sessionId, afterSeq: model.lastSeq }),
|
|
593
594
|
keepAliveEquivalence: Equivalence.make((left, right) => left.sessionId === right.sessionId),
|
|
594
595
|
dependenciesToStream: ({ sessionId }, readDependencies) => {
|
package/dist/connection.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export interface Interface {
|
|
|
28
28
|
}) => Stream.Stream<Incoming, never>;
|
|
29
29
|
readonly send: (frame: Wire.ClientFrameType) => Effect.Effect<void, SendFailed>;
|
|
30
30
|
}
|
|
31
|
-
declare const AgentConnection_base: Context.ServiceClass<AgentConnection, "@batonfx/foldkit/AgentConnection", Interface>;
|
|
31
|
+
declare const AgentConnection_base: Context.ServiceClass<AgentConnection, "@batonfx/foldkit/connection/AgentConnection", Interface>;
|
|
32
32
|
/** @experimental */
|
|
33
33
|
export declare class AgentConnection extends AgentConnection_base {
|
|
34
34
|
}
|
package/dist/connection.js
CHANGED
|
@@ -21,10 +21,10 @@ export class SendFailed extends Schema.TaggedErrorClass()("@batonfx/foldkit/Send
|
|
|
21
21
|
}) {
|
|
22
22
|
}
|
|
23
23
|
/** @experimental */
|
|
24
|
-
export class AgentConnection extends Context.Service()("@batonfx/foldkit/AgentConnection") {
|
|
24
|
+
export class AgentConnection extends Context.Service()("@batonfx/foldkit/connection/AgentConnection") {
|
|
25
25
|
}
|
|
26
26
|
const reasonFrom = (error) => {
|
|
27
|
-
if (
|
|
27
|
+
if (Schema.is(SendFailed)(error))
|
|
28
28
|
return error.reason;
|
|
29
29
|
if (error instanceof Error)
|
|
30
30
|
return error.message;
|
|
@@ -61,10 +61,10 @@ export const layerWebSocket = (options) => Layer.effect(AgentConnection, Effect.
|
|
|
61
61
|
return statuses.pipe(Stream.merge(frames));
|
|
62
62
|
})),
|
|
63
63
|
send: (frame) => Ref.get(active).pipe(Effect.flatMap(Option.match({
|
|
64
|
-
onNone: () => Effect.fail(
|
|
64
|
+
onNone: () => Effect.fail(SendFailed.make({ reason: "No active agent connection" })),
|
|
65
65
|
onSome: ({ connection }) => connection
|
|
66
66
|
.send(frame)
|
|
67
|
-
.pipe(Effect.mapError((error) =>
|
|
67
|
+
.pipe(Effect.mapError((error) => SendFailed.make({ reason: reasonFrom(error) }))),
|
|
68
68
|
}))),
|
|
69
69
|
});
|
|
70
70
|
})).pipe(Layer.provide(Client.layerWebSocket));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@batonfx/foldkit",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.4",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"typecheck": "bun tsc --noEmit"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@batonfx/transport": "0.4.
|
|
20
|
+
"@batonfx/transport": "0.4.4"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"effect": ">=4.0.0-beta.88 <4.0.1",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@types/bun": "1.3.13",
|
|
29
29
|
"effect": "4.0.0-beta.93",
|
|
30
30
|
"foldkit": "0.122.0",
|
|
31
|
-
"typescript": "
|
|
31
|
+
"typescript": "7.0.2",
|
|
32
32
|
"vitest": "4.0.16"
|
|
33
33
|
},
|
|
34
34
|
"description": "FoldKit adapter for Baton transport sessions and chat UI",
|