liminal 0.16.0 → 0.17.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/CHANGELOG.md +6 -0
- package/Digest.ts +30 -0
- package/Envelope.ts +15 -47
- package/F/F.ts +1 -0
- package/L/L.ts +6 -7
- package/L/append.ts +4 -4
- package/L/assistant.ts +2 -2
- package/L/assistantSchema.ts +2 -2
- package/L/assistantStream.ts +2 -2
- package/L/branch.ts +4 -17
- package/L/clear.ts +4 -4
- package/L/disable.ts +2 -2
- package/L/enable.ts +2 -2
- package/L/events.ts +2 -2
- package/L/{userJson.ts → json.ts} +3 -5
- package/L/line.ts +22 -0
- package/L/{handle.ts → listen.ts} +2 -2
- package/L/messages.ts +2 -2
- package/L/prev.ts +4 -0
- package/L/provide.ts +10 -0
- package/L/{Self.ts → self.ts} +1 -1
- package/L/send.ts +56 -0
- package/L/system.ts +18 -7
- package/L/thread.ts +5 -17
- package/L/toolkit.ts +2 -2
- package/L/user.test.ts +4 -1
- package/L/user.ts +15 -5
- package/LEvent.ts +23 -13
- package/Thread.ts +19 -21
- package/dist/Digest.d.ts +17 -0
- package/dist/Digest.js +7 -0
- package/dist/Digest.js.map +1 -0
- package/dist/Envelope.d.ts +13 -15
- package/dist/Envelope.js +1 -29
- package/dist/Envelope.js.map +1 -1
- package/dist/F/F.d.ts +1 -0
- package/dist/F/F.js +2 -0
- package/dist/F/F.js.map +1 -0
- package/dist/L/L.d.ts +6 -7
- package/dist/L/L.js +6 -7
- package/dist/L/L.js.map +1 -1
- package/dist/L/append.js +4 -4
- package/dist/L/append.js.map +1 -1
- package/dist/L/assistant.js +2 -2
- package/dist/L/assistantSchema.js +2 -2
- package/dist/L/assistantStream.js +2 -2
- package/dist/L/branch.d.ts +1 -4
- package/dist/L/branch.js +4 -7
- package/dist/L/branch.js.map +1 -1
- package/dist/L/clear.js +4 -4
- package/dist/L/clear.js.map +1 -1
- package/dist/L/disable.js +2 -2
- package/dist/L/enable.js +2 -2
- package/dist/L/events.js +2 -2
- package/dist/L/{userJson.d.ts → json.d.ts} +1 -2
- package/dist/L/{userJson.js → json.js} +3 -4
- package/dist/L/json.js.map +1 -0
- package/dist/L/line.d.ts +5 -0
- package/dist/L/line.js +11 -0
- package/dist/L/line.js.map +1 -0
- package/dist/L/{handle.js → listen.js} +3 -3
- package/dist/L/{handle.js.map → listen.js.map} +1 -1
- package/dist/L/messages.js +2 -2
- package/dist/L/prev.d.ts +5 -0
- package/dist/L/prev.js +5 -0
- package/dist/L/prev.js.map +1 -0
- package/dist/L/provide.d.ts +3 -0
- package/dist/L/provide.js +4 -0
- package/dist/L/provide.js.map +1 -0
- package/dist/L/{Self.d.ts → self.d.ts} +1 -1
- package/dist/L/self.js +4 -0
- package/dist/L/self.js.map +1 -0
- package/dist/L/send.d.ts +6 -0
- package/dist/L/send.js +34 -0
- package/dist/L/send.js.map +1 -0
- package/dist/L/system.d.ts +3 -3
- package/dist/L/system.js +6 -4
- package/dist/L/system.js.map +1 -1
- package/dist/L/thread.d.ts +1 -4
- package/dist/L/thread.js +5 -7
- package/dist/L/thread.js.map +1 -1
- package/dist/L/toolkit.js +2 -2
- package/dist/L/user.d.ts +5 -3
- package/dist/L/user.js +3 -3
- package/dist/L/user.js.map +1 -1
- package/dist/L/user.test.js.map +1 -1
- package/dist/LEvent.d.ts +143 -15
- package/dist/LEvent.js +12 -9
- package/dist/LEvent.js.map +1 -1
- package/dist/Thread.d.ts +15 -18
- package/dist/Thread.js +7 -13
- package/dist/Thread.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/patterns/Route.js +2 -2
- package/dist/patterns/Route.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/util/Taggable.d.ts +5 -4
- package/dist/util/Taggable.js +11 -0
- package/dist/util/Taggable.js.map +1 -1
- package/dist/util/extract.d.ts +3 -0
- package/dist/util/extract.js +2 -0
- package/dist/util/extract.js.map +1 -0
- package/dist/util/messageCodec.d.ts +98 -0
- package/dist/util/messageCodec.js +5 -0
- package/dist/util/messageCodec.js.map +1 -0
- package/dist/util/raw.d.ts +6 -0
- package/dist/util/raw.js +5 -0
- package/dist/util/raw.js.map +1 -0
- package/index.ts +4 -2
- package/package.json +22 -10
- package/patterns/Route.ts +5 -1
- package/util/Taggable.ts +30 -11
- package/util/extract.ts +7 -0
- package/util/messageCodec.ts +5 -0
- package/util/raw.ts +27 -0
- package/L/fqn.ts +0 -9
- package/L/raw.ts +0 -30
- package/L/sequence.ts +0 -9
- package/L/to.ts +0 -4
- package/LPretty.ts +0 -41
- package/dist/L/Self.js +0 -4
- package/dist/L/Self.js.map +0 -1
- package/dist/L/fqn.d.ts +0 -3
- package/dist/L/fqn.js +0 -8
- package/dist/L/fqn.js.map +0 -1
- package/dist/L/raw.d.ts +0 -3
- package/dist/L/raw.js +0 -18
- package/dist/L/raw.js.map +0 -1
- package/dist/L/sequence.d.ts +0 -2
- package/dist/L/sequence.js +0 -5
- package/dist/L/sequence.js.map +0 -1
- package/dist/L/to.d.ts +0 -3
- package/dist/L/to.js +0 -3
- package/dist/L/to.js.map +0 -1
- package/dist/L/userJson.js.map +0 -1
- package/dist/LPretty.d.ts +0 -4
- package/dist/LPretty.js +0 -37
- package/dist/LPretty.js.map +0 -1
- package/dist/util/Sequencer.d.ts +0 -4
- package/dist/util/Sequencer.js +0 -2
- package/dist/util/Sequencer.js.map +0 -1
- package/util/Sequencer.ts +0 -13
- /package/dist/L/{handle.d.ts → listen.d.ts} +0 -0
package/Thread.ts
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import { Message } from "@effect/ai/AiInput"
|
|
2
|
+
import * as Brand from "effect/Brand"
|
|
2
3
|
import * as Effect from "effect/Effect"
|
|
3
4
|
import * as Option from "effect/Option"
|
|
4
|
-
import { type Pipeable, pipeArguments } from "effect/Pipeable"
|
|
5
5
|
import * as PubSub from "effect/PubSub"
|
|
6
6
|
import * as Schema from "effect/Schema"
|
|
7
7
|
import type { Mutable } from "effect/Types"
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { line } from "./L/line.ts"
|
|
9
|
+
import { self } from "./L/self.ts"
|
|
10
10
|
import type { LEvent } from "./LEvent.ts"
|
|
11
11
|
import type { NeverTool } from "./util/NeverTool.ts"
|
|
12
12
|
import { prefix } from "./util/prefix.ts"
|
|
13
|
-
import type { Sequencer } from "./util/Sequencer.ts"
|
|
14
13
|
|
|
15
|
-
export const
|
|
16
|
-
export
|
|
17
|
-
export
|
|
14
|
+
export const ThreadIdTypeId: unique symbol = Symbol.for(prefix("ThreadNameTypeId"))
|
|
15
|
+
export type ThreadId = string & Brand.Brand<typeof ThreadIdTypeId>
|
|
16
|
+
export const ThreadId: Schema.brand<typeof Schema.String, typeof ThreadIdTypeId> = Schema.String.pipe(
|
|
17
|
+
Schema.brand(ThreadIdTypeId),
|
|
18
|
+
)
|
|
18
19
|
|
|
19
20
|
export class ThreadState extends Schema.Class<ThreadState>(prefix("ThreadState"))({
|
|
20
|
-
/** The key with which the thread is referenced by others. */
|
|
21
|
-
fqn: Schema.Option(ThreadFqn),
|
|
22
21
|
/** The system prompt to be passed along to the model. */
|
|
23
22
|
system: Schema.Option(Schema.String),
|
|
24
23
|
/** The messages based off of which the model infers the next message. */
|
|
@@ -26,19 +25,20 @@ export class ThreadState extends Schema.Class<ThreadState>(prefix("ThreadState")
|
|
|
26
25
|
}) {
|
|
27
26
|
static default = (): ThreadState =>
|
|
28
27
|
ThreadState.make({
|
|
29
|
-
fqn: Option.none(),
|
|
30
28
|
system: Option.none(),
|
|
31
29
|
messages: [],
|
|
32
30
|
})
|
|
33
31
|
}
|
|
34
32
|
|
|
35
33
|
export interface ThreadInit {
|
|
34
|
+
/** The unique id of the thread. */
|
|
35
|
+
readonly id: ThreadId
|
|
36
36
|
/** The parent thread. */
|
|
37
|
-
parent: Option.Option<Thread>
|
|
37
|
+
readonly parent: Option.Option<Thread>
|
|
38
38
|
/** The pubsub with which thread-specific events are emitted. */
|
|
39
|
-
events: PubSub.PubSub<LEvent>
|
|
39
|
+
readonly events: PubSub.PubSub<LEvent>
|
|
40
40
|
/** The state of the current thread. */
|
|
41
|
-
state: Mutable<ThreadState>
|
|
41
|
+
readonly state: Mutable<ThreadState>
|
|
42
42
|
/** The tools to be made accessible to the model. */
|
|
43
43
|
tools: Option.Option<Set<NeverTool>>
|
|
44
44
|
}
|
|
@@ -46,24 +46,22 @@ export interface ThreadInit {
|
|
|
46
46
|
export const ThreadTypeId: unique symbol = Symbol.for(prefix("Thread"))
|
|
47
47
|
export type ThreadTypeId = typeof ThreadTypeId
|
|
48
48
|
|
|
49
|
-
interface ThreadMembers extends ThreadInit
|
|
49
|
+
interface ThreadMembers extends ThreadInit {
|
|
50
50
|
readonly [ThreadTypeId]: ThreadTypeId
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
/** A conversation isolate. */
|
|
54
|
-
export interface Thread extends
|
|
54
|
+
export interface Thread extends line<Thread>, ThreadMembers, Effect.Effect<ThreadId> {}
|
|
55
55
|
|
|
56
56
|
export const Thread = (init: ThreadInit): Thread => {
|
|
57
57
|
const members = {
|
|
58
58
|
[ThreadTypeId]: ThreadTypeId,
|
|
59
59
|
...init,
|
|
60
|
-
pipe() {
|
|
61
|
-
return pipeArguments(self, arguments)
|
|
62
|
-
},
|
|
63
60
|
} satisfies ThreadMembers
|
|
64
|
-
const
|
|
65
|
-
((...args) =>
|
|
61
|
+
const self_ = Object.assign(
|
|
62
|
+
((...args) => line(...args).pipe(Effect.provideService(self, self_))) satisfies line<Thread>,
|
|
63
|
+
Effect.succeed(init.id),
|
|
66
64
|
members,
|
|
67
65
|
) as Thread
|
|
68
|
-
return
|
|
66
|
+
return self_
|
|
69
67
|
}
|
package/dist/Digest.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Layer from "effect/Layer";
|
|
3
|
+
import * as Option from "effect/Option";
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
5
|
+
import type { Thread } from "./Thread.ts";
|
|
6
|
+
export declare const DigestTypeId: unique symbol;
|
|
7
|
+
export type DigestTypeId = typeof DigestTypeId;
|
|
8
|
+
export declare const Digest: <const K extends string, A = string, I = string>(key: K, schema?: Schema.Schema<A, I>) => <Self>() => DigestClass<K, A, I, Self>;
|
|
9
|
+
export interface DigestClass<K extends string, A, I, Self> extends Effect.Effect<A, never, Self> {
|
|
10
|
+
new (_: never): this;
|
|
11
|
+
readonly Type: A;
|
|
12
|
+
readonly Encoded: I;
|
|
13
|
+
readonly [DigestTypeId]: DigestTypeId;
|
|
14
|
+
readonly key: K;
|
|
15
|
+
readonly digest: Effect.Effect<void, never, Self>;
|
|
16
|
+
readonly layer: <E, R>(f: (state: Option.Option<A>, inbox: Thread) => Effect.Effect<A, E, R>) => Layer.Layer<Self, E, Exclude<R, Self | Thread>>;
|
|
17
|
+
}
|
package/dist/Digest.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Layer from "effect/Layer";
|
|
3
|
+
import * as Option from "effect/Option";
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
5
|
+
import { prefix } from "./util/prefix.js";
|
|
6
|
+
export const DigestTypeId = Symbol.for(prefix("Digest"));
|
|
7
|
+
//# sourceMappingURL=Digest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Digest.js","sourceRoot":"","sources":["../Digest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,MAAM,CAAC,MAAM,YAAY,GAAkB,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAA"}
|
package/dist/Envelope.d.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
export declare const Envelope: (headers: MessageHeaders) => Envelope;
|
|
1
|
+
import { Thread } from "./Thread.ts";
|
|
2
|
+
export type Envelope = ({
|
|
3
|
+
to: Array<Thread>;
|
|
4
|
+
cc?: never;
|
|
5
|
+
} | {
|
|
6
|
+
to?: never;
|
|
7
|
+
cc: Array<Thread>;
|
|
8
|
+
} | {
|
|
9
|
+
to: Array<Thread>;
|
|
10
|
+
cc: Array<Thread>;
|
|
11
|
+
}) & {
|
|
12
|
+
bcc?: Array<Thread>;
|
|
13
|
+
};
|
package/dist/Envelope.js
CHANGED
|
@@ -1,30 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as Effect from "effect/Effect";
|
|
3
|
-
import * as Option from "effect/Option";
|
|
4
|
-
import { append } from "./L/append.js";
|
|
5
|
-
import { raw } from "./L/raw.js";
|
|
6
|
-
import { Self } from "./L/Self.js";
|
|
7
|
-
import {} from "./util/Taggable.js";
|
|
8
|
-
// TODO: cc, bcc
|
|
9
|
-
export const Envelope = (headers) => Object.assign(Effect.fnUntraced(function* (a0, ...aRest) {
|
|
10
|
-
const { state: { fqn } } = yield* Self;
|
|
11
|
-
const name = Option.getOrElse(fqn, () => "anonymous-entity");
|
|
12
|
-
const text = yield* raw(a0, ...aRest);
|
|
13
|
-
if (!text)
|
|
14
|
-
return;
|
|
15
|
-
const { to, cc: _cc, bcc: _bcc } = headers;
|
|
16
|
-
for (const recipient of to) {
|
|
17
|
-
yield* append(AiInput.UserMessage.make({
|
|
18
|
-
parts: [
|
|
19
|
-
AiInput.TextPart.make({
|
|
20
|
-
text: `[FROM: ${name}]\n${text}`,
|
|
21
|
-
}),
|
|
22
|
-
],
|
|
23
|
-
})).pipe(Effect.provideService(Self, recipient));
|
|
24
|
-
}
|
|
25
|
-
}), {
|
|
26
|
-
headers,
|
|
27
|
-
cc: (...cc) => Envelope({ ...headers, cc }),
|
|
28
|
-
bcc: (...bcc) => Envelope({ ...headers, bcc }),
|
|
29
|
-
});
|
|
1
|
+
import { Thread } from "./Thread.js";
|
|
30
2
|
//# sourceMappingURL=Envelope.js.map
|
package/dist/Envelope.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Envelope.js","sourceRoot":"","sources":["../Envelope.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Envelope.js","sourceRoot":"","sources":["../Envelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA"}
|
package/dist/F/F.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../L/json.ts";
|
package/dist/F/F.js
ADDED
package/dist/F/F.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"F.js","sourceRoot":"","sources":["../../F/F.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}
|
package/dist/L/L.d.ts
CHANGED
|
@@ -7,15 +7,14 @@ export * from "./clear.ts";
|
|
|
7
7
|
export * from "./disable.ts";
|
|
8
8
|
export * from "./enable.ts";
|
|
9
9
|
export * from "./events.ts";
|
|
10
|
-
export * from "./
|
|
11
|
-
export * from "./
|
|
10
|
+
export * from "./line.ts";
|
|
11
|
+
export * from "./listen.ts";
|
|
12
12
|
export * from "./messages.ts";
|
|
13
|
-
export * from "./
|
|
14
|
-
export * from "./
|
|
15
|
-
export * from "./
|
|
13
|
+
export * from "./prev.ts";
|
|
14
|
+
export * from "./provide.ts";
|
|
15
|
+
export * from "./self.ts";
|
|
16
|
+
export * from "./send.ts";
|
|
16
17
|
export * from "./system.ts";
|
|
17
18
|
export * from "./thread.ts";
|
|
18
|
-
export * from "./to.ts";
|
|
19
19
|
export * from "./toolkit.ts";
|
|
20
20
|
export * from "./user.ts";
|
|
21
|
-
export * from "./userJson.ts";
|
package/dist/L/L.js
CHANGED
|
@@ -7,16 +7,15 @@ export * from "./clear.js";
|
|
|
7
7
|
export * from "./disable.js";
|
|
8
8
|
export * from "./enable.js";
|
|
9
9
|
export * from "./events.js";
|
|
10
|
-
export * from "./
|
|
11
|
-
export * from "./
|
|
10
|
+
export * from "./line.js";
|
|
11
|
+
export * from "./listen.js";
|
|
12
12
|
export * from "./messages.js";
|
|
13
|
-
export * from "./
|
|
14
|
-
export * from "./
|
|
15
|
-
export * from "./
|
|
13
|
+
export * from "./prev.js";
|
|
14
|
+
export * from "./provide.js";
|
|
15
|
+
export * from "./self.js";
|
|
16
|
+
export * from "./send.js";
|
|
16
17
|
export * from "./system.js";
|
|
17
18
|
export * from "./thread.js";
|
|
18
|
-
export * from "./to.js";
|
|
19
19
|
export * from "./toolkit.js";
|
|
20
20
|
export * from "./user.js";
|
|
21
|
-
export * from "./userJson.js";
|
|
22
21
|
//# sourceMappingURL=L.js.map
|
package/dist/L/L.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"L.js","sourceRoot":"","sources":["../../L/L.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,
|
|
1
|
+
{"version":3,"file":"L.js","sourceRoot":"","sources":["../../L/L.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA"}
|
package/dist/L/append.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { MessagesAppendedEvent } from "../LEvent.js";
|
|
3
|
+
import { self } from "./self.js";
|
|
4
4
|
/** Append messages to the thread. */
|
|
5
5
|
export const append = Effect.fnUntraced(function* (...messages) {
|
|
6
|
-
const { state, events } = yield*
|
|
6
|
+
const { state, events } = yield* self;
|
|
7
7
|
state.messages.push(...messages);
|
|
8
|
-
yield* events.publish(
|
|
8
|
+
yield* events.publish(MessagesAppendedEvent.make({ messages }));
|
|
9
9
|
});
|
|
10
10
|
//# sourceMappingURL=append.js.map
|
package/dist/L/append.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"append.js","sourceRoot":"","sources":["../../L/append.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"append.js","sourceRoot":"","sources":["../../L/append.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AAEpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,qCAAqC;AACrC,MAAM,CAAC,MAAM,MAAM,GAEuB,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAC,GAAG,QAAQ;IAC/E,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,IAAI,CAAA;IACrC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAA;IAChC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAA;AACjE,CAAC,CAAC,CAAA"}
|
package/dist/L/assistant.js
CHANGED
|
@@ -3,12 +3,12 @@ import { AiLanguageModel } from "@effect/ai/AiLanguageModel";
|
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
4
|
import * as Option from "effect/Option";
|
|
5
5
|
import { append } from "./append.js";
|
|
6
|
-
import {
|
|
6
|
+
import { self } from "./self.js";
|
|
7
7
|
import { toolkit } from "./toolkit.js";
|
|
8
8
|
/** Infer an assistant message and append it to the thread. */
|
|
9
9
|
export const assistant = Effect.gen(function* () {
|
|
10
10
|
const model = yield* AiLanguageModel;
|
|
11
|
-
const { state: { system, messages: prompt } } = yield*
|
|
11
|
+
const { state: { system, messages: prompt } } = yield* self;
|
|
12
12
|
let { text, results } = yield* model.generateText({
|
|
13
13
|
system: Option.getOrUndefined(system),
|
|
14
14
|
prompt,
|
|
@@ -6,11 +6,11 @@ import * as Schema from "effect/Schema";
|
|
|
6
6
|
import * as SchemaAST from "effect/SchemaAST";
|
|
7
7
|
import { encodeJsonc } from "../util/JsonValue.js";
|
|
8
8
|
import { append } from "./append.js";
|
|
9
|
-
import {
|
|
9
|
+
import { self } from "./self.js";
|
|
10
10
|
/** Infer a structured assistant message and append its JSON representation to the conversation. */
|
|
11
11
|
export const assistantSchema = Effect.fnUntraced(function* (schema) {
|
|
12
12
|
const model = yield* AiLanguageModel;
|
|
13
|
-
const { state: { system, messages } } = yield*
|
|
13
|
+
const { state: { system, messages } } = yield* self;
|
|
14
14
|
const isSchema = Schema.isSchema(schema);
|
|
15
15
|
const schema_ = isSchema ? schema : Schema.Struct(schema);
|
|
16
16
|
const isObject = !isSchema || isObjectSchema(SchemaAST.encodedAST(schema.ast));
|
|
@@ -2,12 +2,12 @@ import { AiLanguageModel } from "@effect/ai/AiLanguageModel";
|
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as Option from "effect/Option";
|
|
4
4
|
import * as Stream from "effect/Stream";
|
|
5
|
-
import {
|
|
5
|
+
import { self } from "./self.js";
|
|
6
6
|
import { toolkit } from "./toolkit.js";
|
|
7
7
|
/** Get a stream of an assistant message (does not append the message to the thread). */
|
|
8
8
|
export const assistantStream = Stream.unwrap(Effect.gen(function* () {
|
|
9
9
|
const model = yield* AiLanguageModel;
|
|
10
|
-
const { state: { system, messages: prompt } } = yield*
|
|
10
|
+
const { state: { system, messages: prompt } } = yield* self;
|
|
11
11
|
return model.streamText({
|
|
12
12
|
system: Option.getOrUndefined(system),
|
|
13
13
|
prompt,
|
package/dist/L/branch.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import { Thread } from "../Thread.ts";
|
|
3
|
-
|
|
4
|
-
export interface branch extends Sequencer<never, Thread>, Effect.Effect<Thread, never, Thread> {
|
|
5
|
-
}
|
|
6
|
-
export declare const branch: branch;
|
|
3
|
+
export declare const branch: Effect.Effect<Thread, never, Thread>;
|
package/dist/L/branch.js
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
|
-
import { flow } from "effect/Function";
|
|
3
2
|
import * as Option from "effect/Option";
|
|
4
3
|
import * as PubSub from "effect/PubSub";
|
|
5
4
|
import { Thread, ThreadState } from "../Thread.js";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const parent = yield* Self;
|
|
5
|
+
import { self } from "./self.js";
|
|
6
|
+
export const branch = Effect.gen(function* () {
|
|
7
|
+
const parent = yield* self;
|
|
10
8
|
return Thread({
|
|
9
|
+
id: parent.id,
|
|
11
10
|
parent: Option.some(parent),
|
|
12
11
|
events: yield* PubSub.unbounded(),
|
|
13
12
|
state: ThreadState.make({
|
|
14
|
-
fqn: parent.state.fqn,
|
|
15
13
|
system: parent.state.system,
|
|
16
14
|
messages: [...parent.state.messages ?? []],
|
|
17
15
|
}),
|
|
18
16
|
tools: parent.tools.pipe(Option.map((v) => new Set(v))),
|
|
19
17
|
});
|
|
20
18
|
});
|
|
21
|
-
export const branch = Object.assign(flow(sequence, Effect.provideServiceEffect(Self, branch_)), branch_);
|
|
22
19
|
//# sourceMappingURL=branch.js.map
|
package/dist/L/branch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branch.js","sourceRoot":"","sources":["../../L/branch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,
|
|
1
|
+
{"version":3,"file":"branch.js","sourceRoot":"","sources":["../../L/branch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,CAAC,MAAM,MAAM,GAAyC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAC9E,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,IAAI,CAAA;IAC1B,OAAO,MAAM,CAAC;QACZ,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;QAC3B,MAAM,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,SAAS,EAAU;QACzC,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC;YACtB,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM;YAC3B,QAAQ,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC;SAC3C,CAAC;QACF,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;KACxD,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/dist/L/clear.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { ThreadClearedEvent } from "../LEvent.js";
|
|
3
|
+
import { self } from "./self.js";
|
|
4
4
|
/** Clear the thread of messages. */
|
|
5
5
|
export const clear = Effect.gen(function* () {
|
|
6
|
-
const { state, events } = yield*
|
|
6
|
+
const { state, events } = yield* self;
|
|
7
7
|
const cleared = state.messages;
|
|
8
8
|
state.messages = [];
|
|
9
|
-
yield* events.publish(
|
|
9
|
+
yield* events.publish(ThreadClearedEvent.make({ cleared }));
|
|
10
10
|
return cleared;
|
|
11
11
|
});
|
|
12
12
|
//# sourceMappingURL=clear.js.map
|
package/dist/L/clear.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clear.js","sourceRoot":"","sources":["../../L/clear.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"clear.js","sourceRoot":"","sources":["../../L/clear.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEjD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,oCAAoC;AACpC,MAAM,CAAC,MAAM,KAAK,GAAiD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACrF,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,IAAI,CAAA;IACrC,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAA;IAC9B,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAA;IACnB,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;IAC3D,OAAO,OAAO,CAAA;AAChB,CAAC,CAAC,CAAA"}
|
package/dist/L/disable.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as AiTool from "@effect/ai/AiTool";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as Option from "effect/Option";
|
|
4
|
-
import {
|
|
5
|
-
export const disable = (tool) => Effect.map(
|
|
4
|
+
import { self } from "./self.js";
|
|
5
|
+
export const disable = (tool) => Effect.map(self, ({ tools }) => {
|
|
6
6
|
if (Option.isSome(tools)) {
|
|
7
7
|
tools.value.delete(tool);
|
|
8
8
|
}
|
package/dist/L/enable.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import * as Option from "effect/Option";
|
|
3
|
-
import {
|
|
4
|
-
export const enable = (tool) => Effect.map(
|
|
3
|
+
import { self } from "./self.js";
|
|
4
|
+
export const enable = (tool) => Effect.map(self, (thread) => {
|
|
5
5
|
const tool_ = tool;
|
|
6
6
|
Option.match(thread.tools, {
|
|
7
7
|
onSome: (value) => value.add(tool_),
|
package/dist/L/events.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import * as Stream from "effect/Stream";
|
|
3
|
-
import {
|
|
3
|
+
import { self } from "./self.js";
|
|
4
4
|
/** A stream of thread events. */
|
|
5
|
-
export const events =
|
|
5
|
+
export const events = self.pipe(Effect.map(({ events }) => Stream.fromPubSub(events)), Stream.unwrap);
|
|
6
6
|
//# sourceMappingURL=events.js.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import type * as Schema from "effect/Schema";
|
|
3
|
-
import type { Thread } from "../Thread.ts";
|
|
4
3
|
import { type JsonValue } from "../util/JsonValue.ts";
|
|
5
4
|
/** Stringify and append some JSON as a user message to the conversation. */
|
|
6
|
-
export declare const
|
|
5
|
+
export declare const json: <A, I extends JsonValue>(value: A, schema?: Schema.Schema<A, I>) => Effect.Effect<string>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import { encodeJsonc } from "../util/JsonValue.js";
|
|
3
|
-
import { user } from "./user.js";
|
|
4
3
|
/** Stringify and append some JSON as a user message to the conversation. */
|
|
5
|
-
export const
|
|
4
|
+
export const json = Effect.fnUntraced(function* (value, schema) {
|
|
6
5
|
const encoded = schema ? encodeJsonc(schema)(value) : JSON.stringify(value, null, 2);
|
|
7
|
-
return
|
|
6
|
+
return `\`\`\`json${schema ? "c" : ""}\n${encoded}\n\`\`\``;
|
|
8
7
|
});
|
|
9
|
-
//# sourceMappingURL=
|
|
8
|
+
//# sourceMappingURL=json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../L/json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,WAAW,EAAkB,MAAM,sBAAsB,CAAA;AAElE,4EAA4E;AAC5E,MAAM,CAAC,MAAM,IAAI,GAGY,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAC,KAAK,EAAE,MAAM;IACpE,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IACpF,OAAO,aAAa,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,UAAU,CAAA;AAC7D,CAAC,CAAC,CAAA"}
|
package/dist/L/line.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
export interface line<RIn = never, E = never, ROut = never> {
|
|
3
|
+
<Arg extends Array<Effect.All.EffectAny>>(...steps: Arg): Effect.Effect<Arg extends [] ? void : Arg extends [...infer _0, infer L extends Effect.All.EffectAny] ? Effect.Effect.Success<L> : never, Effect.Effect.Error<Arg[number]> | E, Exclude<Effect.Effect.Context<Arg[number]>, RIn> | ROut>;
|
|
4
|
+
}
|
|
5
|
+
export declare const line: line;
|
package/dist/L/line.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import { prev } from "./prev.js";
|
|
3
|
+
export const line = Effect.fnUntraced(function* (...steps) {
|
|
4
|
+
let acc;
|
|
5
|
+
while (steps.length) {
|
|
6
|
+
const current = steps.shift();
|
|
7
|
+
acc = yield* current.pipe(Effect.provideService(prev, acc));
|
|
8
|
+
}
|
|
9
|
+
return acc;
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=line.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line.js","sourceRoot":"","sources":["../../L/line.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAahC,MAAM,CAAC,MAAM,IAAI,GAAS,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAC,GAAG,KAAK;IAC5D,IAAI,GAAY,CAAA;IAChB,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;QACpB,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,EAAG,CAAA;QAC9B,GAAG,GAAG,KAAK,CAAC,CAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAwB,CAAA;IACrF,CAAC;IACD,OAAO,GAAY,CAAA;AACrB,CAAC,CAAC,CAAA"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import * as Scope from "effect/Scope";
|
|
3
3
|
import * as Stream from "effect/Stream";
|
|
4
|
-
import {
|
|
4
|
+
import { self } from "./self.js";
|
|
5
5
|
/** Attach an event handler to process thread events. */
|
|
6
6
|
export const listen = Effect.fnUntraced(function* (f) {
|
|
7
7
|
const latch = yield* Effect.makeLatch(false);
|
|
8
|
-
const { events } = yield*
|
|
8
|
+
const { events } = yield* self;
|
|
9
9
|
const dequeue = yield* events.subscribe;
|
|
10
10
|
const fiber = yield* latch.open.pipe(Effect.zipRight(Stream.fromQueue(dequeue).pipe(Stream.runForEach(f), Effect.fork)));
|
|
11
11
|
yield* latch.await;
|
|
12
12
|
return fiber;
|
|
13
13
|
});
|
|
14
|
-
//# sourceMappingURL=
|
|
14
|
+
//# sourceMappingURL=listen.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"listen.js","sourceRoot":"","sources":["../../L/listen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,wDAAwD;AACxD,MAAM,CAAC,MAAM,MAAM,GAE0D,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAC,CAAC;IACxG,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAC5C,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,IAAI,CAAA;IAC9B,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,SAAS,CAAA;IACvC,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAClC,MAAM,CAAC,QAAQ,CACb,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,CAC5B,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,EACpB,MAAM,CAAC,IAAI,CACZ,CACF,CACF,CAAA;IACD,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAA;IAClB,OAAO,KAAK,CAAA;AACd,CAAC,CAAC,CAAA"}
|
package/dist/L/messages.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
|
-
import {
|
|
2
|
+
import { self } from "./self.js";
|
|
3
3
|
/** Get a copy of the current list of messages. */
|
|
4
|
-
export const messages = Effect.map(
|
|
4
|
+
export const messages = Effect.map(self, ({ state: { messages: [...messages] } }) => messages);
|
|
5
5
|
//# sourceMappingURL=messages.js.map
|
package/dist/L/prev.d.ts
ADDED
package/dist/L/prev.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prev.js","sourceRoot":"","sources":["../../L/prev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE1C,MAAM,OAAO,IAAK,SAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAiB;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provide.js","sourceRoot":"","sources":["../../L/provide.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,MAAmC,EACnC,EAAE,CACJ,CACE,CAA4B,EACwB,EAAE,CAAC,MAAM,CAAC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA"}
|
package/dist/L/self.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self.js","sourceRoot":"","sources":["../../L/self.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE1C,MAAM,CAAC,MAAM,IAAI,GAAgC,OAAO,CAAC,UAAU,CAAS,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA"}
|
package/dist/L/send.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import type { Envelope } from "../Envelope.ts";
|
|
3
|
+
import type { Thread } from "../Thread.ts";
|
|
4
|
+
import type { ExtractE, ExtractR } from "../util/extract.ts";
|
|
5
|
+
import { type TaggableArg0, type TaggableArgRest } from "../util/Taggable.ts";
|
|
6
|
+
export declare const send: (envelope: Envelope) => <A0 extends TaggableArg0, ARest extends TaggableArgRest<A0>>(a0: A0, ...aRest: ARest) => Effect.Effect<void, ExtractE<A0 | ARest[number]>, Thread | ExtractR<A0 | ARest[number]>>;
|
package/dist/L/send.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as AiInput from "@effect/ai/AiInput";
|
|
2
|
+
import * as Array from "effect/Array";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import { raw } from "../util/raw.js";
|
|
5
|
+
import { normalize } from "../util/Taggable.js";
|
|
6
|
+
import { append } from "./append.js";
|
|
7
|
+
import { self } from "./self.js";
|
|
8
|
+
export const send = (envelope) => Effect.fnUntraced(function* (a0, ...aRest) {
|
|
9
|
+
const text = yield* normalize(a0, ...aRest);
|
|
10
|
+
if (!text)
|
|
11
|
+
return;
|
|
12
|
+
const { to, cc, bcc } = envelope;
|
|
13
|
+
const ccHeader = cc?.length
|
|
14
|
+
? yield* raw `; ${Effect.all(cc).pipe(Effect.map(Array.join(", ")))}`
|
|
15
|
+
: "";
|
|
16
|
+
const headers = raw `[FROM: ${self}${ccHeader}]`;
|
|
17
|
+
const knownRecipients = [...to ?? [], ...cc ?? []];
|
|
18
|
+
const program = append(AiInput.UserMessage.make({
|
|
19
|
+
parts: [
|
|
20
|
+
AiInput.TextPart.make({
|
|
21
|
+
text: `${headers}\n${text}`,
|
|
22
|
+
}),
|
|
23
|
+
],
|
|
24
|
+
}));
|
|
25
|
+
for (const recipient of knownRecipients) {
|
|
26
|
+
yield* program.pipe(Effect.provideService(self, recipient));
|
|
27
|
+
}
|
|
28
|
+
if (bcc?.length) {
|
|
29
|
+
for (const hiddenRecipient of bcc) {
|
|
30
|
+
yield* program.pipe(Effect.provideService(self, hiddenRecipient));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=send.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send.js","sourceRoot":"","sources":["../../L/send.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAC7C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAKvC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AACpC,OAAO,EAAE,SAAS,EAA2C,MAAM,qBAAqB,CAAA;AACxF,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,QAAkB,EAAE,EAAE,CACzC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAIzB,EAAM,EACN,GAAG,KAAY;IAYf,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,GAAG,KAAK,CAAC,CAAA;IAC3C,IAAI,CAAC,IAAI;QAAE,OAAM;IACjB,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,QAAQ,CAAA;IAChC,MAAM,QAAQ,GAAG,EAAE,EAAE,MAAM;QACzB,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAA,KAAK,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;QACpE,CAAC,CAAC,EAAE,CAAA;IACN,MAAM,OAAO,GAAG,GAAG,CAAA,UAAU,IAAI,GAAG,QAAQ,GAAG,CAAA;IAC/C,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAA;IAClD,MAAM,OAAO,GAAG,MAAM,CACpB,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC;QACvB,KAAK,EAAE;YACL,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;gBACpB,IAAI,EAAE,GAAG,OAAO,KAAK,IAAI,EAAE;aAC5B,CAAC;SACH;KACF,CAAC,CACH,CAAA;IACD,KAAK,MAAM,SAAS,IAAI,eAAe,EAAE,CAAC;QACxC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAA;IAC7D,CAAC;IACD,IAAI,GAAG,EAAE,MAAM,EAAE,CAAC;QAChB,KAAK,MAAM,eAAe,IAAI,GAAG,EAAE,CAAC;YAClC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC,CAAA;QACnE,CAAC;IACH,CAAC;AACH,CAAC,CAAC,CAAA"}
|