liminal 0.15.0 → 0.16.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/Envelope.ts +48 -0
- package/{L.ts → L/L.ts} +7 -1
- package/L/Self.ts +5 -0
- package/L/append.ts +14 -0
- package/{assistant.ts → L/assistant.ts} +10 -9
- package/{assistantSchema.ts → L/assistantSchema.ts} +8 -7
- package/{assistantStream.ts → L/assistantStream.ts} +8 -11
- package/L/branch.ts +33 -0
- package/L/clear.ts +14 -0
- package/L/disable.ts +13 -0
- package/L/enable.ts +24 -0
- package/L/events.ts +11 -0
- package/L/fqn.ts +9 -0
- package/{handle.ts → L/handle.ts} +6 -5
- package/L/messages.ts +10 -0
- package/L/raw.ts +30 -0
- package/{sequence.ts → L/sequence.ts} +2 -2
- package/L/system.ts +14 -0
- package/L/thread.ts +28 -0
- package/L/to.ts +4 -0
- package/L/toolkit.ts +14 -0
- package/{user.test.ts → L/user.test.ts} +2 -2
- package/{user.ts → L/user.ts} +5 -4
- package/{userJson.ts → L/userJson.ts} +4 -4
- package/LEvent.ts +2 -2
- package/Thread.ts +69 -0
- package/dist/Envelope.d.ts +15 -0
- package/dist/Envelope.js +30 -0
- package/dist/Envelope.js.map +1 -0
- package/dist/{L.d.ts → L/L.d.ts} +7 -1
- package/dist/{L.js → L/L.js} +7 -1
- package/dist/L/L.js.map +1 -0
- package/dist/L/Self.d.ts +3 -0
- package/dist/L/Self.js +4 -0
- package/dist/L/Self.js.map +1 -0
- package/dist/{append.d.ts → L/append.d.ts} +3 -3
- package/dist/L/append.js +10 -0
- package/dist/L/append.js.map +1 -0
- package/dist/{assistant.d.ts → L/assistant.d.ts} +3 -3
- package/dist/{assistant.js → L/assistant.js} +8 -8
- package/dist/L/assistant.js.map +1 -0
- package/dist/{assistantSchema.d.ts → L/assistantSchema.d.ts} +4 -4
- package/dist/{assistantSchema.js → L/assistantSchema.js} +5 -5
- package/dist/L/assistantSchema.js.map +1 -0
- package/dist/{assistantStream.d.ts → L/assistantStream.d.ts} +3 -3
- package/dist/{assistantStream.js → L/assistantStream.js} +6 -6
- package/dist/L/assistantStream.js.map +1 -0
- package/dist/L/branch.d.ts +6 -0
- package/dist/L/branch.js +22 -0
- package/dist/L/branch.js.map +1 -0
- package/dist/{clear.d.ts → L/clear.d.ts} +3 -3
- package/dist/L/clear.js +12 -0
- package/dist/L/clear.js.map +1 -0
- package/dist/{disable.d.ts → L/disable.d.ts} +2 -2
- package/dist/L/disable.js +10 -0
- package/dist/L/disable.js.map +1 -0
- package/dist/{enable.d.ts → L/enable.d.ts} +2 -2
- package/dist/L/enable.js +13 -0
- package/dist/L/enable.js.map +1 -0
- package/dist/L/events.d.ts +5 -0
- package/dist/L/events.js +6 -0
- package/dist/L/events.js.map +1 -0
- package/dist/L/fqn.d.ts +3 -0
- package/dist/L/fqn.js +8 -0
- package/dist/L/fqn.js.map +1 -0
- package/dist/{handle.d.ts → L/handle.d.ts} +4 -4
- package/dist/{handle.js → L/handle.js} +3 -3
- package/dist/L/handle.js.map +1 -0
- package/dist/{messages.d.ts → L/messages.d.ts} +2 -2
- package/dist/L/messages.js +5 -0
- package/dist/L/messages.js.map +1 -0
- package/dist/L/raw.d.ts +3 -0
- package/dist/L/raw.js +18 -0
- package/dist/L/raw.js.map +1 -0
- package/dist/L/sequence.d.ts +2 -0
- package/dist/L/sequence.js.map +1 -0
- package/dist/L/system.d.ts +5 -0
- package/dist/L/system.js +12 -0
- package/dist/L/system.js.map +1 -0
- package/dist/L/thread.d.ts +6 -0
- package/dist/L/thread.js +17 -0
- package/dist/L/thread.js.map +1 -0
- package/dist/L/to.d.ts +3 -0
- package/dist/L/to.js +3 -0
- package/dist/L/to.js.map +1 -0
- package/dist/L/toolkit.d.ts +4 -0
- package/dist/L/toolkit.js +9 -0
- package/dist/L/toolkit.js.map +1 -0
- package/dist/L/user.d.ts +4 -0
- package/dist/{user.js → L/user.js} +2 -2
- package/dist/L/user.js.map +1 -0
- package/dist/L/user.test.js.map +1 -0
- package/dist/{userJson.d.ts → L/userJson.d.ts} +3 -3
- package/dist/{userJson.js → L/userJson.js} +2 -2
- package/dist/L/userJson.js.map +1 -0
- package/dist/LEvent.d.ts +2 -2
- package/dist/LEvent.js +2 -2
- package/dist/LEvent.js.map +1 -1
- package/dist/Thread.d.ts +55 -0
- package/dist/Thread.js +38 -0
- package/dist/Thread.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/patterns/Debate.d.ts +1 -0
- package/dist/patterns/Debate.js +3 -0
- package/dist/patterns/Debate.js.map +1 -0
- package/dist/patterns/Model.d.ts +6 -0
- package/dist/patterns/{coalesce_models.js → Model.js} +5 -6
- package/dist/patterns/Model.js.map +1 -0
- package/dist/patterns/Route.d.ts +3 -0
- package/dist/patterns/Route.js +14 -0
- package/dist/patterns/Route.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/util/JsonValue.js.map +1 -1
- package/dist/util/NeverTool.d.ts +3 -0
- package/dist/util/NeverTool.js +3 -0
- package/dist/util/NeverTool.js.map +1 -0
- package/dist/util/Sequencer.d.ts +4 -0
- package/dist/util/Sequencer.js +2 -0
- package/dist/util/Sequencer.js.map +1 -0
- package/dist/util/Taggable.d.ts +0 -1
- package/dist/util/Taggable.js +0 -16
- package/dist/util/Taggable.js.map +1 -1
- package/dist/util/{fixRaw.js → normalizeRaw.js} +1 -1
- package/dist/util/normalizeRaw.js.map +1 -0
- package/dist/util/prefix.d.ts +1 -0
- package/dist/util/prefix.js +2 -0
- package/dist/util/prefix.js.map +1 -0
- package/index.ts +3 -2
- package/package.json +4 -3
- package/patterns/Debate.ts +2 -0
- package/patterns/{coalesce_models.ts → Model.ts} +6 -7
- package/patterns/{match_gist.ts → Route.ts} +7 -9
- package/util/JsonValue.ts +2 -2
- package/util/NeverTool.ts +10 -0
- package/util/Sequencer.ts +13 -0
- package/util/Taggable.ts +0 -26
- package/util/prefix.ts +1 -0
- package/Strand.ts +0 -49
- package/append.ts +0 -13
- package/branch.ts +0 -26
- package/clear.ts +0 -15
- package/disable.ts +0 -8
- package/dist/L.js.map +0 -1
- package/dist/Strand.d.ts +0 -36
- package/dist/Strand.js +0 -18
- package/dist/Strand.js.map +0 -1
- package/dist/append.js +0 -10
- package/dist/append.js.map +0 -1
- package/dist/assistant.js.map +0 -1
- package/dist/assistantSchema.js.map +0 -1
- package/dist/assistantStream.js.map +0 -1
- package/dist/branch.d.ts +0 -4
- package/dist/branch.js +0 -18
- package/dist/branch.js.map +0 -1
- package/dist/clear.js +0 -14
- package/dist/clear.js.map +0 -1
- package/dist/disable.js +0 -7
- package/dist/disable.js.map +0 -1
- package/dist/enable.js +0 -6
- package/dist/enable.js.map +0 -1
- package/dist/events.d.ts +0 -5
- package/dist/events.js +0 -6
- package/dist/events.js.map +0 -1
- package/dist/handle.js.map +0 -1
- package/dist/messages.js +0 -5
- package/dist/messages.js.map +0 -1
- package/dist/patterns/coalesce_models.d.ts +0 -6
- package/dist/patterns/coalesce_models.js.map +0 -1
- package/dist/patterns/match_gist.d.ts +0 -3
- package/dist/patterns/match_gist.js +0 -16
- package/dist/patterns/match_gist.js.map +0 -1
- package/dist/sequence.d.ts +0 -2
- package/dist/sequence.js.map +0 -1
- package/dist/strand_.d.ts +0 -4
- package/dist/strand_.js +0 -8
- package/dist/strand_.js.map +0 -1
- package/dist/system.d.ts +0 -5
- package/dist/system.js +0 -12
- package/dist/system.js.map +0 -1
- package/dist/user.d.ts +0 -4
- package/dist/user.js.map +0 -1
- package/dist/user.test.js.map +0 -1
- package/dist/userJson.js.map +0 -1
- package/dist/util/Sequence.d.ts +0 -2
- package/dist/util/Sequence.js +0 -2
- package/dist/util/Sequence.js.map +0 -1
- package/dist/util/fixRaw.js.map +0 -1
- package/enable.ts +0 -15
- package/events.ts +0 -10
- package/messages.ts +0 -9
- package/strand_.ts +0 -11
- package/system.ts +0 -12
- package/util/Sequence.ts +0 -11
- /package/dist/{sequence.js → L/sequence.js} +0 -0
- /package/dist/{user.test.d.ts → L/user.test.d.ts} +0 -0
- /package/dist/util/{fixRaw.d.ts → normalizeRaw.d.ts} +0 -0
- /package/util/{fixRaw.ts → normalizeRaw.ts} +0 -0
package/dist/Envelope.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as AiInput from "@effect/ai/AiInput";
|
|
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
|
+
});
|
|
30
|
+
//# sourceMappingURL=Envelope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Envelope.js","sourceRoot":"","sources":["../Envelope.ts"],"names":[],"mappings":"AAAA,OA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AC,CAAA;IAClD,CAAC;AACH,CAAC,CAAyC,EAC1C;IACE,OAAO;IACP,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,OAAO,EAAE,EAAE,EAAE,CAAC;IAC3C,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE,CAAC;CACrB,CAC5B,CAAA"}
|
package/dist/{L.d.ts → L/L.d.ts}
RENAMED
|
@@ -4,12 +4,18 @@ export * from "./assistantSchema.ts";
|
|
|
4
4
|
export * from "./assistantStream.ts";
|
|
5
5
|
export * from "./branch.ts";
|
|
6
6
|
export * from "./clear.ts";
|
|
7
|
+
export * from "./disable.ts";
|
|
7
8
|
export * from "./enable.ts";
|
|
8
9
|
export * from "./events.ts";
|
|
10
|
+
export * from "./fqn.ts";
|
|
9
11
|
export * from "./handle.ts";
|
|
10
12
|
export * from "./messages.ts";
|
|
13
|
+
export * from "./raw.ts";
|
|
14
|
+
export * from "./Self.ts";
|
|
11
15
|
export * from "./sequence.ts";
|
|
12
|
-
export * from "./strand_.ts";
|
|
13
16
|
export * from "./system.ts";
|
|
17
|
+
export * from "./thread.ts";
|
|
18
|
+
export * from "./to.ts";
|
|
19
|
+
export * from "./toolkit.ts";
|
|
14
20
|
export * from "./user.ts";
|
|
15
21
|
export * from "./userJson.ts";
|
package/dist/{L.js → L/L.js}
RENAMED
|
@@ -4,13 +4,19 @@ export * from "./assistantSchema.js";
|
|
|
4
4
|
export * from "./assistantStream.js";
|
|
5
5
|
export * from "./branch.js";
|
|
6
6
|
export * from "./clear.js";
|
|
7
|
+
export * from "./disable.js";
|
|
7
8
|
export * from "./enable.js";
|
|
8
9
|
export * from "./events.js";
|
|
10
|
+
export * from "./fqn.js";
|
|
9
11
|
export * from "./handle.js";
|
|
10
12
|
export * from "./messages.js";
|
|
13
|
+
export * from "./raw.js";
|
|
14
|
+
export * from "./Self.js";
|
|
11
15
|
export * from "./sequence.js";
|
|
12
|
-
export * from "./strand_.js";
|
|
13
16
|
export * from "./system.js";
|
|
17
|
+
export * from "./thread.js";
|
|
18
|
+
export * from "./to.js";
|
|
19
|
+
export * from "./toolkit.js";
|
|
14
20
|
export * from "./user.js";
|
|
15
21
|
export * from "./userJson.js";
|
|
16
22
|
//# sourceMappingURL=L.js.map
|
package/dist/L/L.js.map
ADDED
|
@@ -0,0 +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,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA"}
|
package/dist/L/Self.d.ts
ADDED
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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Message } from "@effect/ai/AiInput";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
|
-
import {
|
|
4
|
-
/** Append messages to the
|
|
5
|
-
export declare const append: (...messages: Array<Message>) => Effect.Effect<void, never,
|
|
3
|
+
import type { Thread } from "../Thread.ts";
|
|
4
|
+
/** Append messages to the thread. */
|
|
5
|
+
export declare const append: (...messages: Array<Message>) => Effect.Effect<void, never, Thread>;
|
package/dist/L/append.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import { MessagesAppended } from "../LEvent.js";
|
|
3
|
+
import { Self } from "./Self.js";
|
|
4
|
+
/** Append messages to the thread. */
|
|
5
|
+
export const append = Effect.fnUntraced(function* (...messages) {
|
|
6
|
+
const { state, events } = yield* Self;
|
|
7
|
+
state.messages.push(...messages);
|
|
8
|
+
yield* events.publish(MessagesAppended.make({ messages }));
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=append.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"append.js","sourceRoot":"","sources":["../../L/append.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE/C,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,gBAAgB,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAA;AAC5D,CAAC,CAAC,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AiError } from "@effect/ai/AiError";
|
|
2
2
|
import { AiLanguageModel } from "@effect/ai/AiLanguageModel";
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
|
-
import {
|
|
5
|
-
/** Infer an assistant message and append it to the
|
|
6
|
-
export declare const assistant: Effect.Effect<string, AiError, AiLanguageModel |
|
|
4
|
+
import type { Thread } from "../Thread.ts";
|
|
5
|
+
/** Infer an assistant message and append it to the thread. */
|
|
6
|
+
export declare const assistant: Effect.Effect<string, AiError, AiLanguageModel | Thread>;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { AssistantMessage, TextPart } from "@effect/ai/AiInput";
|
|
2
2
|
import { AiLanguageModel } from "@effect/ai/AiLanguageModel";
|
|
3
|
-
import * as AiToolkit from "@effect/ai/AiToolkit";
|
|
4
3
|
import * as Effect from "effect/Effect";
|
|
5
4
|
import * as Option from "effect/Option";
|
|
6
5
|
import { append } from "./append.js";
|
|
7
|
-
import {
|
|
8
|
-
|
|
6
|
+
import { Self } from "./Self.js";
|
|
7
|
+
import { toolkit } from "./toolkit.js";
|
|
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 { system, messages
|
|
11
|
+
const { state: { system, messages: prompt } } = yield* Self;
|
|
12
12
|
let { text, results } = yield* model.generateText({
|
|
13
13
|
system: Option.getOrUndefined(system),
|
|
14
|
-
prompt
|
|
15
|
-
toolkit
|
|
14
|
+
prompt,
|
|
15
|
+
toolkit,
|
|
16
16
|
});
|
|
17
17
|
// TODO: this shouldn't be necessary. Bug in Effect AI?
|
|
18
18
|
if (!text.trim()) {
|
|
19
19
|
text = results.values().next().value?.result;
|
|
20
20
|
}
|
|
21
|
-
yield* append(
|
|
22
|
-
parts: [
|
|
21
|
+
yield* append(AssistantMessage.make({
|
|
22
|
+
parts: [TextPart.make({ text })],
|
|
23
23
|
}));
|
|
24
24
|
return text;
|
|
25
25
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant.js","sourceRoot":"","sources":["../../L/assistant.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,SAAS,GAA6D,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACrG,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,eAAe,CAAA;IACpC,MAAM,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,GAAG,KAAK,CAAC,CAAC,IAAI,CAAA;IAC3D,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC;QAChD,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC;QACrC,MAAM;QACN,OAAO;KACR,CAAC,CAAA;IACF,uDAAuD;IACvD,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QACjB,IAAI,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,MAAyB,CAAA;IACjE,CAAC;IACD,KAAK,CAAC,CAAC,MAAM,CACX,gBAAgB,CAAC,IAAI,CAAC;QACpB,KAAK,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;KACjC,CAAC,CACH,CAAA;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAC,CAAA"}
|
|
@@ -2,12 +2,12 @@ import type { AiError } from "@effect/ai/AiError";
|
|
|
2
2
|
import { AiLanguageModel } from "@effect/ai/AiLanguageModel";
|
|
3
3
|
import * as Effect from "effect/Effect";
|
|
4
4
|
import * as Schema from "effect/Schema";
|
|
5
|
-
import {
|
|
6
|
-
import { type JsonValue } from "
|
|
5
|
+
import type { Thread } from "../Thread.ts";
|
|
6
|
+
import { type JsonValue } from "../util/JsonValue.ts";
|
|
7
7
|
/** Infer a structured assistant message and append its JSON representation to the conversation. */
|
|
8
8
|
export declare const assistantSchema: {
|
|
9
9
|
<F extends Record<string, Schema.Schema.AnyNoContext>>(fields: F): Effect.Effect<{
|
|
10
10
|
[K in keyof F]: Schema.Schema.Type<F[K]>;
|
|
11
|
-
}, AiError, AiLanguageModel |
|
|
12
|
-
<O, I extends JsonValue>(schema: Schema.Schema<O, I, never>): Effect.Effect<O, AiError, AiLanguageModel |
|
|
11
|
+
}, AiError, AiLanguageModel | Thread>;
|
|
12
|
+
<O, I extends JsonValue>(schema: Schema.Schema<O, I, never>): Effect.Effect<O, AiError, AiLanguageModel | Thread>;
|
|
13
13
|
};
|
|
@@ -4,13 +4,13 @@ import * as Effect from "effect/Effect";
|
|
|
4
4
|
import * as Option from "effect/Option";
|
|
5
5
|
import * as Schema from "effect/Schema";
|
|
6
6
|
import * as SchemaAST from "effect/SchemaAST";
|
|
7
|
+
import { encodeJsonc } from "../util/JsonValue.js";
|
|
7
8
|
import { append } from "./append.js";
|
|
8
|
-
import {
|
|
9
|
-
import { encodeJsonc } from "./util/JsonValue.js";
|
|
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 { 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));
|
|
@@ -20,9 +20,9 @@ export const assistantSchema = Effect.fnUntraced(function* (schema) {
|
|
|
20
20
|
schema: wrapped,
|
|
21
21
|
prompt: messages,
|
|
22
22
|
}).pipe(Effect.map(({ value }) => isObject ? value : value["inner"]));
|
|
23
|
-
yield* append(
|
|
23
|
+
yield* append(AssistantMessage.make({
|
|
24
24
|
parts: [
|
|
25
|
-
|
|
25
|
+
TextPart.make({
|
|
26
26
|
text: yield* encodeJsonc(schema_)(value),
|
|
27
27
|
}),
|
|
28
28
|
],
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistantSchema.js","sourceRoot":"","sources":["../../L/assistantSchema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAE7C,OAAO,EAAE,WAAW,EAAkB,MAAM,sBAAsB,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,mGAAmG;AACnG,MAAM,CAAC,MAAM,eAAe,GAOxB,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAC,MAAM;IACpC,MAAM,KAAK,GA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G,CAAC,GAAkB,EAAW,EAAE;IACrD,QAAQ,GAAG,CAAC,IAAI,EAAE,CAAC;QACjB,KAAK,aAAa,CAAC,CAAC,CAAC;YACnB,OAAO,IAAI,CAAA;QACb,CAAC;QACD,KAAK,YAAY,CAAC;QAClB,KAAK,gBAAgB,CAAC,CAAC,CAAC;YACtB,OAAO,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACjC,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA"}
|
|
@@ -2,6 +2,6 @@ import type { AiError } from "@effect/ai/AiError";
|
|
|
2
2
|
import { AiLanguageModel } from "@effect/ai/AiLanguageModel";
|
|
3
3
|
import type { AiResponse } from "@effect/ai/AiResponse";
|
|
4
4
|
import * as Stream from "effect/Stream";
|
|
5
|
-
import {
|
|
6
|
-
/** Get a
|
|
7
|
-
export declare const assistantStream: Stream.Stream<AiResponse, AiError, AiLanguageModel |
|
|
5
|
+
import type { Thread } from "../Thread.ts";
|
|
6
|
+
/** Get a stream of an assistant message (does not append the message to the thread). */
|
|
7
|
+
export declare const assistantStream: Stream.Stream<AiResponse, AiError, AiLanguageModel | Thread>;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { AiLanguageModel } from "@effect/ai/AiLanguageModel";
|
|
2
|
-
import * as AiToolkit from "@effect/ai/AiToolkit";
|
|
3
2
|
import * as Effect from "effect/Effect";
|
|
4
3
|
import * as Option from "effect/Option";
|
|
5
4
|
import * as Stream from "effect/Stream";
|
|
6
|
-
import {
|
|
7
|
-
|
|
5
|
+
import { Self } from "./Self.js";
|
|
6
|
+
import { toolkit } from "./toolkit.js";
|
|
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 { system, messages
|
|
10
|
+
const { state: { system, messages: prompt } } = yield* Self;
|
|
11
11
|
return model.streamText({
|
|
12
12
|
system: Option.getOrUndefined(system),
|
|
13
|
-
prompt
|
|
14
|
-
toolkit
|
|
13
|
+
prompt,
|
|
14
|
+
toolkit,
|
|
15
15
|
});
|
|
16
16
|
}));
|
|
17
17
|
//# sourceMappingURL=assistantStream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistantStream.js","sourceRoot":"","sources":["../../L/assistantStream.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAE5D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,wFAAwF;AACxF,MAAM,CAAC,MAAM,eAAe,GAAiE,MAAM,CAAC,MAAM,CACxG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,eAAe,CAAA;IACpC,MAAM,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,GAAG,KAAK,CAAC,CAAC,IAAI,CAAA;IAC3D,OAAO,KAAK,CAAC,UAAU,CAAC;QACtB,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC;QACrC,MAAM;QACN,OAAO;KACR,CAAC,CAAA;AACJ,CAAC,CAAC,CACH,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import { Thread } from "../Thread.ts";
|
|
3
|
+
import type { Sequencer } from "../util/Sequencer.ts";
|
|
4
|
+
export interface branch extends Sequencer<never, Thread>, Effect.Effect<Thread, never, Thread> {
|
|
5
|
+
}
|
|
6
|
+
export declare const branch: branch;
|
package/dist/L/branch.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import { flow } from "effect/Function";
|
|
3
|
+
import * as Option from "effect/Option";
|
|
4
|
+
import * as PubSub from "effect/PubSub";
|
|
5
|
+
import { Thread, ThreadState } from "../Thread.js";
|
|
6
|
+
import { Self } from "./Self.js";
|
|
7
|
+
import { sequence } from "./sequence.js";
|
|
8
|
+
const branch_ = Effect.gen(function* () {
|
|
9
|
+
const parent = yield* Self;
|
|
10
|
+
return Thread({
|
|
11
|
+
parent: Option.some(parent),
|
|
12
|
+
events: yield* PubSub.unbounded(),
|
|
13
|
+
state: ThreadState.make({
|
|
14
|
+
fqn: parent.state.fqn,
|
|
15
|
+
system: parent.state.system,
|
|
16
|
+
messages: [...parent.state.messages ?? []],
|
|
17
|
+
}),
|
|
18
|
+
tools: parent.tools.pipe(Option.map((v) => new Set(v))),
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
export const branch = Object.assign(flow(sequence, Effect.provideServiceEffect(Self, branch_)), branch_);
|
|
22
|
+
//# sourceMappingURL=branch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branch.js","sourceRoot":"","sources":["../../L/branch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAElD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAIxC,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClC,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,IAAI,CAAA;IAC1B,OAAO,MAAM,CAAC;QACZ,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,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG;YACrB,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;AAEF,MAAM,CAAC,MAAM,MAAM,GAAW,MAAM,CAAC,MAAM,CACzC,IAAI,CACF,QAAQ,EACR,MAAM,CAAC,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,CAC3C,EACD,OAAO,CACR,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Message } from "@effect/ai/AiInput";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
|
-
import {
|
|
4
|
-
/** Clear the
|
|
5
|
-
export declare const clear: Effect.Effect<Array<Message>, never,
|
|
3
|
+
import type { Thread } from "../Thread.ts";
|
|
4
|
+
/** Clear the thread of messages. */
|
|
5
|
+
export declare const clear: Effect.Effect<Array<Message>, never, Thread>;
|
package/dist/L/clear.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import { MessagesCleared } from "../LEvent.js";
|
|
3
|
+
import { Self } from "./Self.js";
|
|
4
|
+
/** Clear the thread of messages. */
|
|
5
|
+
export const clear = Effect.gen(function* () {
|
|
6
|
+
const { state, events } = yield* Self;
|
|
7
|
+
const cleared = state.messages;
|
|
8
|
+
state.messages = [];
|
|
9
|
+
yield* events.publish(MessagesCleared.make({ cleared }));
|
|
10
|
+
return cleared;
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=clear.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clear.js","sourceRoot":"","sources":["../../L/clear.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C,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,eAAe,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;IACxD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAC,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as AiTool from "@effect/ai/AiTool";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
|
-
import {
|
|
4
|
-
export declare const disable: (tool: AiTool.Any) => Effect.Effect<void, never,
|
|
3
|
+
import type { Thread } from "../Thread.ts";
|
|
4
|
+
export declare const disable: (tool: AiTool.Any) => Effect.Effect<void, never, Thread>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as AiTool from "@effect/ai/AiTool";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Option from "effect/Option";
|
|
4
|
+
import { Self } from "./Self.js";
|
|
5
|
+
export const disable = (tool) => Effect.map(Self, ({ tools }) => {
|
|
6
|
+
if (Option.isSome(tools)) {
|
|
7
|
+
tools.value.delete(tool);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=disable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disable.js","sourceRoot":"","sources":["../../L/disable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAgB,EAAsC,EAAE,CAC9E,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC7B,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAiB,CAAC,CAAA;IACvC,CAAC;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AiTool, AnyStructSchema, Handler } from "@effect/ai/AiTool";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import type { Schema } from "effect/Schema";
|
|
4
|
-
import {
|
|
5
|
-
export declare const enable: <K extends string, E extends Schema.All, R>(
|
|
4
|
+
import type { Thread } from "../Thread.ts";
|
|
5
|
+
export declare const enable: <K extends string, E extends Schema.All, R>(tool: AiTool<K, AnyStructSchema, Schema.Any, E, R>) => Effect.Effect<void, E, Handler<K> | Thread | R>;
|
package/dist/L/enable.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Option from "effect/Option";
|
|
3
|
+
import { Self } from "./Self.js";
|
|
4
|
+
export const enable = (tool) => Effect.map(Self, (thread) => {
|
|
5
|
+
const tool_ = tool;
|
|
6
|
+
Option.match(thread.tools, {
|
|
7
|
+
onSome: (value) => value.add(tool_),
|
|
8
|
+
onNone: () => {
|
|
9
|
+
thread.tools = Option.some(new Set([tool_]));
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=enable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enable.js","sourceRoot":"","sources":["../../L/enable.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAIvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,CAAC,MAAM,MAAM,GAAG,CAKpB,IAAkD,EACD,EAAE,CACnD,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE;IAC1B,MAAM,KAAK,GAAc,IAAa,CAAA;IACtC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE;QACzB,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC;QACnC,MAAM,EAAE,GAAG,EAAE;YACX,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAC9C,CAAC;KACF,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/dist/L/events.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Stream from "effect/Stream";
|
|
3
|
+
import { Self } from "./Self.js";
|
|
4
|
+
/** A stream of thread events. */
|
|
5
|
+
export const events = Self.pipe(Effect.map(({ events }) => Stream.fromPubSub(events)), Stream.unwrap);
|
|
6
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../L/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,iCAAiC;AACjC,MAAM,CAAC,MAAM,MAAM,GAAyC,IAAI,CAAC,IAAI,CACnE,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EACrD,MAAM,CAAC,MAAM,CACd,CAAA"}
|
package/dist/L/fqn.d.ts
ADDED
package/dist/L/fqn.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Option from "effect/Option";
|
|
3
|
+
import { ThreadFqn } from "../Thread.js";
|
|
4
|
+
import { Self } from "./Self.js";
|
|
5
|
+
export const fqn = (id) => Effect.map(Self, (thread) => {
|
|
6
|
+
thread.state.fqn = Option.some(ThreadFqn.make(id));
|
|
7
|
+
});
|
|
8
|
+
//# sourceMappingURL=fqn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fqn.js","sourceRoot":"","sources":["../../L/fqn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAe,SAAS,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,EAAU,EAAsC,EAAE,CACpE,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE;IAC1B,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;AACpD,CAAC,CAAC,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import type { RuntimeFiber } from "effect/Fiber";
|
|
3
3
|
import * as Scope from "effect/Scope";
|
|
4
|
-
import type { LEvent } from "
|
|
5
|
-
import {
|
|
6
|
-
/** Attach an event handler to process
|
|
7
|
-
export declare const listen: <A, E, R>(f: (event: LEvent) => Effect.Effect<A, E, R>) => Effect.Effect<RuntimeFiber<void, E>, never,
|
|
4
|
+
import type { LEvent } from "../LEvent.ts";
|
|
5
|
+
import type { Thread } from "../Thread.ts";
|
|
6
|
+
/** Attach an event handler to process thread events. */
|
|
7
|
+
export declare const listen: <A, E, R>(f: (event: LEvent) => Effect.Effect<A, E, R>) => Effect.Effect<RuntimeFiber<void, E>, never, Thread | R | Scope.Scope>;
|
|
@@ -1,11 +1,11 @@
|
|
|
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 {
|
|
5
|
-
/** Attach an event handler to process
|
|
4
|
+
import { Self } from "./Self.js";
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle.js","sourceRoot":"","sources":["../../L/handle.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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Message } from "@effect/ai/AiInput";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
|
-
import {
|
|
3
|
+
import type { Thread } from "../Thread.ts";
|
|
4
4
|
/** Get a copy of the current list of messages. */
|
|
5
|
-
export declare const messages: Effect.Effect<Array<Message>, never,
|
|
5
|
+
export declare const messages: Effect.Effect<Array<Message>, never, Thread>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../L/messages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,kDAAkD;AAClD,MAAM,CAAC,MAAM,QAAQ,GAAiD,MAAM,CAAC,GAAG,CAC9E,IAAI,EACJ,CAAC,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,QAAQ,CACrD,CAAA"}
|
package/dist/L/raw.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import type { TaggableArg0 } from "../util/Taggable.ts";
|
|
3
|
+
export declare const raw: <A0 extends TaggableArg0 | Effect.Effect<string | undefined, any, any>, L extends Array<unknown>>(a0: A0, ...aRest: L) => Effect.Effect<string | (undefined extends A0 ? undefined : never)>;
|
package/dist/L/raw.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import { normalizeRaw } from "../util/normalizeRaw.js";
|
|
3
|
+
export const raw = Effect.fnUntraced(function* (a0, ...aRest) {
|
|
4
|
+
const a0_ = Effect.isEffect(a0)
|
|
5
|
+
? yield* a0
|
|
6
|
+
: a0;
|
|
7
|
+
if (!a0_)
|
|
8
|
+
return undefined;
|
|
9
|
+
const aRest_ = yield* Effect.all(aRest.map((v) => Effect.isEffect(v)
|
|
10
|
+
? v
|
|
11
|
+
: Effect.succeed(v)));
|
|
12
|
+
return typeof a0_ === "string"
|
|
13
|
+
? aRest_.length === 0
|
|
14
|
+
? a0_
|
|
15
|
+
: [a0_, ...aRest_].join("")
|
|
16
|
+
: normalizeRaw(a0_, aRest_);
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=raw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raw.js","sourceRoot":"","sources":["../../L/raw.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eA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AAE,EAAE,CAAC,CAAC,CAAC,GAAG,EAAG,CAAU,CACnD,CAAA"}
|
package/dist/L/system.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Option from "effect/Option";
|
|
3
|
+
import { raw } from "./raw.js";
|
|
4
|
+
import { Self } from "./Self.js";
|
|
5
|
+
/** Set the thread's system instruction. */
|
|
6
|
+
export const system = Effect.fnUntraced(function* (a0, ...aRest) {
|
|
7
|
+
const { state } = yield* Self;
|
|
8
|
+
const { system } = state;
|
|
9
|
+
state.system = a0 ? Option.some(yield* raw(a0, ...aRest)) : Option.none();
|
|
10
|
+
return system;
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=system.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.js","sourceRoot":"","sources":["../../L/system.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,2CAA2C;AAC3C,MAAM,CAAC,MAAM,MAAM,GAAmD,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAC,EAAE,EAAE,GAAG,KAAK;IAC5G,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,CAAC,IAAI,CAAA;IAC7B,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAA;IACxB,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAA;IACzE,OAAO,MAAM,CAAA;AACf,CAAC,CAAC,CAAA"}
|
package/dist/L/thread.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import { flow } from "effect/Function";
|
|
3
|
+
import * as Option from "effect/Option";
|
|
4
|
+
import * as PubSub from "effect/PubSub";
|
|
5
|
+
import { Thread, ThreadState } from "../Thread.js";
|
|
6
|
+
import { Self } from "./Self.js";
|
|
7
|
+
import { sequence } from "./sequence.js";
|
|
8
|
+
const thread_ = Effect.gen(function* () {
|
|
9
|
+
return Thread({
|
|
10
|
+
parent: yield* Effect.serviceOption(Self),
|
|
11
|
+
events: yield* PubSub.unbounded(),
|
|
12
|
+
state: ThreadState.default(),
|
|
13
|
+
tools: Option.none(),
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
export const thread = Object.assign(flow(sequence, Effect.provideServiceEffect(Self, thread_)), thread_);
|
|
17
|
+
//# sourceMappingURL=thread.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thread.js","sourceRoot":"","sources":["../../L/thread.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAElD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAIxC,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClC,OAAO,MAAM,CAAC;QACZ,MAAM,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC;QACzC,MAAM,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,SAAS,EAAU;QACzC,KAAK,EAAE,WAAW,CAAC,OAAO,EAAE;QAC5B,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE;KACrB,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,MAAM,GAAW,MAAM,CAAC,MAAM,CACzC,IAAI,CACF,QAAQ,EACR,MAAM,CAAC,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,CAC3C,EACD,OAAO,CACR,CAAA"}
|
package/dist/L/to.d.ts
ADDED
package/dist/L/to.js
ADDED
package/dist/L/to.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to.js","sourceRoot":"","sources":["../../L/to.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAGzC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,EAAiB,EAAY,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as AiToolkit from "@effect/ai/AiToolkit";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import type { NeverTool } from "../util/NeverTool.ts";
|
|
4
|
+
export declare const toolkit: Effect.Effect<AiToolkit.ToHandler<NeverTool>, never, import("../Thread.ts").Thread | import("@effect/ai/AiTool").Handler<string>>;
|