liminal 0.6.0 → 0.8.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/index.ts CHANGED
@@ -1,4 +1,2 @@
1
- export * from "./Context.ts"
2
1
  export * as L from "./L.ts"
3
- export * from "./LEvent.ts"
4
- export * from "./strand.ts"
2
+ export * as Strand from "./Strand.ts"
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.6.0",
6
+ "version": "0.8.0",
7
7
  "license": "Apache-2.0",
8
8
  "repository": {
9
9
  "type": "git",
@@ -13,10 +13,12 @@
13
13
  "type": "module",
14
14
  "description": "Primitives for composing conversation trees with language models and TypeScript iterators.",
15
15
  "exports": {
16
- ".": "./dist/index.js"
16
+ ".": "./dist/index.js",
17
+ "./L": "./dist/L.js",
18
+ "./Strand": "./dist/Strand.js"
17
19
  },
18
20
  "peerDependencies": {
19
- "@effect/ai": "^0.18.2",
20
- "effect": "^3.16.3"
21
+ "@effect/ai": "^0.18.16",
22
+ "effect": "^3.17.2"
21
23
  }
22
24
  }
package/Context.ts DELETED
@@ -1,13 +0,0 @@
1
- import type { AiInput, AiToolkit } from "@effect/ai"
2
- import { Context, Effect, Ref } from "effect"
3
- import { LEvent } from "./LEvent.ts"
4
-
5
- export class MessagesRef extends Context.Tag("liminal/Messages")<MessagesRef, Ref.Ref<Array<AiInput.Message>>>() {}
6
-
7
- export class System extends Context.Tag("liminal/System")<System, string | undefined>() {}
8
-
9
- export class Handler
10
- extends Context.Tag("liminal/Handler")<Handler, ((event: LEvent) => Effect.Effect<any, any, any>) | undefined>()
11
- {}
12
-
13
- export class Toolkit extends Context.Tag("liminal/Tools")<Toolkit, AiToolkit.AiToolkit<any> | undefined>() {}
package/LEvent.ts DELETED
@@ -1,28 +0,0 @@
1
- import { AiInput, AiResponse } from "@effect/ai"
2
- import { Schema } from "effect"
3
-
4
- export const LEventId = Symbol.for("liminal/LEvent")
5
- export type LEventId = typeof LEventId
6
-
7
- export class MessageAppended extends Schema.Class<MessageAppended>("liminal/MessageAppended")({
8
- message: AiInput.Message,
9
- }) {
10
- readonly [LEventId]: LEventId = LEventId
11
- }
12
-
13
- export class InferenceRequested extends Schema.Class<InferenceRequested>("liminal/InferenceRequested")({}) {
14
- readonly [LEventId]: LEventId = LEventId
15
- }
16
-
17
- export class Inferred extends Schema.Class<Inferred>("liminal/Inferred")({
18
- response: AiResponse.AiResponse,
19
- }) {
20
- readonly [LEventId]: LEventId = LEventId
21
- }
22
-
23
- export type LEvent = typeof LEvent.Type
24
- export const LEvent: Schema.Union<[
25
- typeof MessageAppended,
26
- typeof InferenceRequested,
27
- typeof Inferred,
28
- ]> = Schema.Union(MessageAppended, InferenceRequested, Inferred)
package/_emit.ts DELETED
@@ -1,16 +0,0 @@
1
- import { Effect, Option } from "effect"
2
- import { Handler } from "./Context.ts"
3
- import { LEvent } from "./LEvent.ts"
4
-
5
- export const _emit = Effect.fn(function*(event: typeof LEvent.Type) {
6
- const handlerOption = yield* Effect.serviceOption(Handler)
7
- yield* Option.match(handlerOption, {
8
- *onSome(handler) {
9
- const effect = handler?.(event)
10
- if (effect) {
11
- yield* effect as Effect.Effect<void>
12
- }
13
- },
14
- *onNone() {},
15
- })
16
- })
package/assistant.ts DELETED
@@ -1,53 +0,0 @@
1
- import { AiInput, AiLanguageModel } from "@effect/ai"
2
- import type { AiError } from "@effect/ai/AiError"
3
- import { Effect, Option, Ref, type Schema } from "effect"
4
- import { _emit } from "./_emit.ts"
5
- import { Handler, MessagesRef, System, Toolkit } from "./Context.ts"
6
- import { InferenceRequested, Inferred } from "./LEvent.ts"
7
-
8
- export const assistant: {
9
- (): Effect.Effect<string, AiError, AiLanguageModel.AiLanguageModel | MessagesRef | System | Handler>
10
- <O, I>(
11
- schema: Schema.Schema<O, I, never>,
12
- ): Effect.Effect<O, AiError, AiLanguageModel.AiLanguageModel | MessagesRef | System | Handler>
13
- } = Effect.fn(function*(schema?: Schema.Schema<any>) {
14
- yield* _emit(new InferenceRequested())
15
- const model = yield* AiLanguageModel.AiLanguageModel
16
- const messagesRef = yield* MessagesRef
17
- const toolkitOption = yield* Effect.serviceOption(Toolkit)
18
- const prompt = yield* Ref.get(messagesRef)
19
- const system = yield* System
20
- if (schema) {
21
- const response = yield* model.generateObject({
22
- system,
23
- schema,
24
- prompt,
25
- })
26
- yield* _emit(new Inferred({ response }))
27
- const { value, text } = response
28
- yield* appendMessage(text)
29
- return value
30
- }
31
- const response = yield* model.generateText({
32
- system,
33
- prompt,
34
- ...Option.isSome(toolkitOption)
35
- ? toolkitOption.value
36
- ? { toolkit: toolkitOption.value }
37
- : {}
38
- : {},
39
- })
40
- yield* _emit(new Inferred({ response }))
41
- const { text } = response
42
- yield* appendMessage(text)
43
- return text
44
-
45
- function* appendMessage(text: string) {
46
- yield* Ref.update(messagesRef, (prev) => [
47
- ...prev,
48
- new AiInput.AssistantMessage({
49
- parts: [new AiInput.TextPart({ text })],
50
- }),
51
- ])
52
- }
53
- })
package/dist/Context.d.ts DELETED
@@ -1,16 +0,0 @@
1
- import type { AiInput, AiToolkit } from "@effect/ai";
2
- import { Context, Effect, Ref } from "effect";
3
- import { LEvent } from "./LEvent.ts";
4
- declare const MessagesRef_base: Context.TagClass<MessagesRef, "liminal/Messages", Ref.Ref<(AiInput.UserMessage | AiInput.AssistantMessage | AiInput.ToolMessage)[]>>;
5
- export declare class MessagesRef extends MessagesRef_base {
6
- }
7
- declare const System_base: Context.TagClass<System, "liminal/System", string | undefined>;
8
- export declare class System extends System_base {
9
- }
10
- declare const Handler_base: Context.TagClass<Handler, "liminal/Handler", ((event: LEvent) => Effect.Effect<any, any, any>) | undefined>;
11
- export declare class Handler extends Handler_base {
12
- }
13
- declare const Toolkit_base: Context.TagClass<Toolkit, "liminal/Tools", AiToolkit.AiToolkit<any> | undefined>;
14
- export declare class Toolkit extends Toolkit_base {
15
- }
16
- export {};
package/dist/Context.js DELETED
@@ -1,11 +0,0 @@
1
- import { Context, Effect, Ref } from "effect";
2
- import { LEvent } from "./LEvent.js";
3
- export class MessagesRef extends Context.Tag("liminal/Messages")() {
4
- }
5
- export class System extends Context.Tag("liminal/System")() {
6
- }
7
- export class Handler extends Context.Tag("liminal/Handler")() {
8
- }
9
- export class Toolkit extends Context.Tag("liminal/Tools")() {
10
- }
11
- //# sourceMappingURL=Context.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Context.js","sourceRoot":"","sources":["../Context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,MAAM,OAAO,WAAY,SAAQ,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,EAAgD;CAAG;AAEnH,MAAM,OAAO,MAAO,SAAQ,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAA8B;CAAG;AAE1F,MAAM,OAAO,OACX,SAAQ,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAA0E;CAChH;AAEF,MAAM,OAAO,OAAQ,SAAQ,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,EAAiD;CAAG"}
package/dist/LEvent.d.ts DELETED
@@ -1,35 +0,0 @@
1
- import { AiInput, AiResponse } from "@effect/ai";
2
- import { Schema } from "effect";
3
- export declare const LEventId: unique symbol;
4
- export type LEventId = typeof LEventId;
5
- declare const MessageAppended_base: Schema.Class<MessageAppended, {
6
- message: Schema.Union<[typeof AiInput.UserMessage, typeof AiInput.AssistantMessage, typeof AiInput.ToolMessage]>;
7
- }, Schema.Struct.Encoded<{
8
- message: Schema.Union<[typeof AiInput.UserMessage, typeof AiInput.AssistantMessage, typeof AiInput.ToolMessage]>;
9
- }>, never, {
10
- readonly message: AiInput.UserMessage | AiInput.AssistantMessage | AiInput.ToolMessage;
11
- }, {}, {}>;
12
- export declare class MessageAppended extends MessageAppended_base {
13
- readonly [LEventId]: LEventId;
14
- }
15
- declare const InferenceRequested_base: Schema.Class<InferenceRequested, {}, Schema.Struct.Encoded<{}>, never, unknown, {}, {}>;
16
- export declare class InferenceRequested extends InferenceRequested_base {
17
- readonly [LEventId]: LEventId;
18
- }
19
- declare const Inferred_base: Schema.Class<Inferred, {
20
- response: typeof AiResponse.AiResponse;
21
- }, Schema.Struct.Encoded<{
22
- response: typeof AiResponse.AiResponse;
23
- }>, never, {
24
- readonly response: AiResponse.AiResponse;
25
- }, {}, {}>;
26
- export declare class Inferred extends Inferred_base {
27
- readonly [LEventId]: LEventId;
28
- }
29
- export type LEvent = typeof LEvent.Type;
30
- export declare const LEvent: Schema.Union<[
31
- typeof MessageAppended,
32
- typeof InferenceRequested,
33
- typeof Inferred
34
- ]>;
35
- export {};
package/dist/LEvent.js DELETED
@@ -1,18 +0,0 @@
1
- import { AiInput, AiResponse } from "@effect/ai";
2
- import { Schema } from "effect";
3
- export const LEventId = Symbol.for("liminal/LEvent");
4
- export class MessageAppended extends Schema.Class("liminal/MessageAppended")({
5
- message: AiInput.Message,
6
- }) {
7
- [LEventId] = LEventId;
8
- }
9
- export class InferenceRequested extends Schema.Class("liminal/InferenceRequested")({}) {
10
- [LEventId] = LEventId;
11
- }
12
- export class Inferred extends Schema.Class("liminal/Inferred")({
13
- response: AiResponse.AiResponse,
14
- }) {
15
- [LEventId] = LEventId;
16
- }
17
- export const LEvent = Schema.Union(MessageAppended, InferenceRequested, Inferred);
18
- //# sourceMappingURL=LEvent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LEvent.js","sourceRoot":"","sources":["../LEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;AAGpD,MAAM,OAAO,eAAgB,SAAQ,MAAM,CAAC,KAAK,CAAkB,yBAAyB,CAAC,CAAC;IAC5F,OAAO,EAAE,OAAO,CAAC,OAAO;CACzB,CAAC;IACS,CAAC,QAAQ,CAAC,GAAa,QAAQ,CAAA;CACzC;AAED,MAAM,OAAO,kBAAmB,SAAQ,MAAM,CAAC,KAAK,CAAqB,4BAA4B,CAAC,CAAC,EAAE,CAAC;IAC/F,CAAC,QAAQ,CAAC,GAAa,QAAQ,CAAA;CACzC;AAED,MAAM,OAAO,QAAS,SAAQ,MAAM,CAAC,KAAK,CAAW,kBAAkB,CAAC,CAAC;IACvE,QAAQ,EAAE,UAAU,CAAC,UAAU;CAChC,CAAC;IACS,CAAC,QAAQ,CAAC,GAAa,QAAQ,CAAA;CACzC;AAGD,MAAM,CAAC,MAAM,MAAM,GAId,MAAM,CAAC,KAAK,CAAC,eAAe,EAAE,kBAAkB,EAAE,QAAQ,CAAC,CAAA"}
package/dist/_emit.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { Effect } from "effect";
2
- export declare const _emit: (event: import("./LEvent.ts").MessageAppended | import("./LEvent.ts").InferenceRequested | import("./LEvent.ts").Inferred) => Effect.Effect<void, never, never>;
package/dist/_emit.js DELETED
@@ -1,16 +0,0 @@
1
- import { Effect, Option } from "effect";
2
- import { Handler } from "./Context.js";
3
- import { LEvent } from "./LEvent.js";
4
- export const _emit = Effect.fn(function* (event) {
5
- const handlerOption = yield* Effect.serviceOption(Handler);
6
- yield* Option.match(handlerOption, {
7
- *onSome(handler) {
8
- const effect = handler?.(event);
9
- if (effect) {
10
- yield* effect;
11
- }
12
- },
13
- *onNone() { },
14
- });
15
- });
16
- //# sourceMappingURL=_emit.js.map
package/dist/_emit.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"_emit.js","sourceRoot":"","sources":["../_emit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAC,KAAyB;IAChE,MAAM,aAAa,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;IAC1D,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE;QACjC,CAAC,MAAM,CAAC,OAAO;YACb,MAAM,MAAM,GAAG,OAAO,EAAE,CAAC,KAAK,CAAC,CAAA;YAC/B,IAAI,MAAM,EAAE,CAAC;gBACX,KAAK,CAAC,CAAC,MAA6B,CAAA;YACtC,CAAC;QACH,CAAC;QACD,CAAC,MAAM,KAAI,CAAC;KACb,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -1,8 +0,0 @@
1
- import { AiLanguageModel } from "@effect/ai";
2
- import type { AiError } from "@effect/ai/AiError";
3
- import { Effect, type Schema } from "effect";
4
- import { Handler, MessagesRef, System } from "./Context.ts";
5
- export declare const assistant: {
6
- (): Effect.Effect<string, AiError, AiLanguageModel.AiLanguageModel | MessagesRef | System | Handler>;
7
- <O, I>(schema: Schema.Schema<O, I, never>): Effect.Effect<O, AiError, AiLanguageModel.AiLanguageModel | MessagesRef | System | Handler>;
8
- };
package/dist/assistant.js DELETED
@@ -1,46 +0,0 @@
1
- import { AiInput, AiLanguageModel } from "@effect/ai";
2
- import { Effect, Option, Ref } from "effect";
3
- import { _emit } from "./_emit.js";
4
- import { Handler, MessagesRef, System, Toolkit } from "./Context.js";
5
- import { InferenceRequested, Inferred } from "./LEvent.js";
6
- export const assistant = Effect.fn(function* (schema) {
7
- yield* _emit(new InferenceRequested());
8
- const model = yield* AiLanguageModel.AiLanguageModel;
9
- const messagesRef = yield* MessagesRef;
10
- const toolkitOption = yield* Effect.serviceOption(Toolkit);
11
- const prompt = yield* Ref.get(messagesRef);
12
- const system = yield* System;
13
- if (schema) {
14
- const response = yield* model.generateObject({
15
- system,
16
- schema,
17
- prompt,
18
- });
19
- yield* _emit(new Inferred({ response }));
20
- const { value, text } = response;
21
- yield* appendMessage(text);
22
- return value;
23
- }
24
- const response = yield* model.generateText({
25
- system,
26
- prompt,
27
- ...Option.isSome(toolkitOption)
28
- ? toolkitOption.value
29
- ? { toolkit: toolkitOption.value }
30
- : {}
31
- : {},
32
- });
33
- yield* _emit(new Inferred({ response }));
34
- const { text } = response;
35
- yield* appendMessage(text);
36
- return text;
37
- function* appendMessage(text) {
38
- yield* Ref.update(messagesRef, (prev) => [
39
- ...prev,
40
- new AiInput.AssistantMessage({
41
- parts: [new AiInput.TextPart({ text })],
42
- }),
43
- ]);
44
- }
45
- });
46
- //# sourceMappingURL=assistant.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"assistant.js","sourceRoot":"","sources":["../assistant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAe,MAAM,QAAQ,CAAA;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE1D,MAAM,CAAC,MAAM,SAAS,GAKlB,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAC,MAA2B;IACjD,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,kBAAkB,EAAE,CAAC,CAAA;IACtC,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,eAAe,CAAC,eAAe,CAAA;IACpD,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,WAAW,CAAA;IACtC,MAAM,aAAa,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;IAC1D,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;IAC1C,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,CAAA;IAC5B,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC;YAC3C,MAAM;YACN,MAAM;YACN,MAAM;SACP,CAAC,CAAA;QACF,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAA;QACxC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAA;QAChC,KAAK,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;QAC1B,OAAO,KAAK,CAAA;IACd,CAAC;IACD,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC;QACzC,MAAM;QACN,MAAM;QACN,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC;YAC7B,CAAC,CAAC,aAAa,CAAC,KAAK;gBACnB,CAAC,CAAC,EAAE,OAAO,EAAE,aAAa,CAAC,KAAK,EAAE;gBAClC,CAAC,CAAC,EAAE;YACN,CAAC,CAAC,EAAE;KACP,CAAC,CAAA;IACF,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAA;IACxC,MAAM,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAA;IACzB,KAAK,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;IAC1B,OAAO,IAAI,CAAA;IAEX,QAAQ,CAAC,CAAC,aAAa,CAAC,IAAY;QAClC,KAAK,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC;YACvC,GAAG,IAAI;YACP,IAAI,OAAO,CAAC,gBAAgB,CAAC;gBAC3B,KAAK,EAAE,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;aACxC,CAAC;SACH,CAAC,CAAA;IACJ,CAAC;AACH,CAAC,CAAC,CAAA"}
@@ -1,4 +0,0 @@
1
- import type { AiInput } from "@effect/ai";
2
- import { Effect } from "effect";
3
- import { MessagesRef } from "./Context.ts";
4
- export declare const messages: Effect.Effect<Array<AiInput.Message>, never, MessagesRef>;
package/dist/messages.js DELETED
@@ -1,4 +0,0 @@
1
- import { Effect, Ref } from "effect";
2
- import { MessagesRef } from "./Context.js";
3
- export const messages = Effect.flatMap(MessagesRef, Ref.get);
4
- //# sourceMappingURL=messages.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"messages.js","sourceRoot":"","sources":["../messages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE1C,MAAM,CAAC,MAAM,QAAQ,GAA8D,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC,GAAG,CAAC,CAAA"}
package/dist/set.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import type { AiInput } from "@effect/ai";
2
- import { Effect } from "effect";
3
- import { MessagesRef } from "./Context.ts";
4
- export declare const set: (messages: Iterable<AiInput.UserMessage | AiInput.AssistantMessage | AiInput.ToolMessage>) => Effect.Effect<(AiInput.UserMessage | AiInput.AssistantMessage | AiInput.ToolMessage)[], never, MessagesRef>;
package/dist/set.js DELETED
@@ -1,9 +0,0 @@
1
- import { Effect, Ref } from "effect";
2
- import { MessagesRef } from "./Context.js";
3
- export const set = Effect.fn(function* (messages) {
4
- const messagesRef = yield* MessagesRef;
5
- const previous = yield* Ref.get(messagesRef);
6
- yield* Ref.set(messagesRef, [...messages]);
7
- return previous;
8
- });
9
- //# sourceMappingURL=set.js.map
package/dist/set.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"set.js","sourceRoot":"","sources":["../set.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE1C,MAAM,CAAC,MAAM,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAC,QAAmC;IACxE,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,WAAW,CAAA;IACtC,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;IAC5C,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAA;IAC1C,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAC,CAAA"}
package/dist/strand.d.ts DELETED
@@ -1,16 +0,0 @@
1
- import type { AiInput, AiTool, AiToolkit } from "@effect/ai";
2
- import { Effect } from "effect";
3
- import { Handler, MessagesRef, System } from "./Context.ts";
4
- import { LEvent } from "./LEvent.ts";
5
- export interface StrandOptions<E, R, in out T extends AiTool.Any> {
6
- /** The system prompt. */
7
- system?: string | undefined;
8
- /** The initial list of AI input messages. */
9
- messages?: Iterable<AiInput.Message> | undefined;
10
- /** The liminal event handler. */
11
- handler?: ((event: LEvent) => Effect.Effect<any, E, R>) | undefined;
12
- /** The tools to use for by strand. */
13
- tools?: AiToolkit.AiToolkit<T> | undefined;
14
- }
15
- /** Create an isolated clone of the current conversation to provide for an effect. */
16
- export declare const strand: <HE = never, HR = never, T extends AiTool.Any = never>(options?: StrandOptions<HE, HR, T>) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E | HE, Exclude<R, MessagesRef | System | Handler> | T>;
package/dist/strand.js DELETED
@@ -1,16 +0,0 @@
1
- import { Effect, Option, Ref } from "effect";
2
- import { Handler, MessagesRef, System, Toolkit } from "./Context.js";
3
- import { LEvent } from "./LEvent.js";
4
- /** Create an isolated clone of the current conversation to provide for an effect. */
5
- export const strand = (options) => (effect) => Effect.gen(function* () {
6
- const messagesRef = options?.messages
7
- ? Ref.unsafeMake([...options.messages])
8
- : yield* Option.match(yield* Effect.serviceOption(MessagesRef), {
9
- *onSome(ref) {
10
- return Ref.unsafeMake([...yield* Ref.get(ref)]);
11
- },
12
- onNone: () => Ref.make([]),
13
- });
14
- return yield* (effect.pipe(Effect.provideService(MessagesRef, messagesRef), Effect.provideService(System, options?.system), Effect.provideService(Handler, options?.handler), Effect.provideService(Toolkit, options?.tools)));
15
- }); // TODO
16
- //# sourceMappingURL=strand.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"strand.js","sourceRoot":"","sources":["../strand.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAapC,qFAAqF;AACrF,MAAM,CAAC,MAAM,MAAM,GAI6D,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CACtG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,WAAW,GAAG,OAAO,EAAE,QAAQ;QACnC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE;YAC9D,CAAC,MAAM,CAAC,GAAG;gBACT,OAAO,GAAG,CAAC,UAAU,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;YACjD,CAAC;YACD,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAA4B,CAAC;SACrD,CAAC,CAAA;IACJ,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CACxB,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,WAAW,CAAC,EAC/C,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,EAC9C,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAChD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAC/C,CAAC,CAAA;AACJ,CAAC,CAAU,CAAA,CAAC,OAAO"}
package/dist/user.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import { Effect } from "effect";
2
- import { Handler, MessagesRef } from "./Context.ts";
3
- export declare const user: {
4
- (template: TemplateStringsArray, ...substitutions: Array<unknown>): Effect.Effect<void, never, MessagesRef | Handler>;
5
- (message: string): Effect.Effect<void, never, MessagesRef | Handler>;
6
- };
package/dist/user.js DELETED
@@ -1,18 +0,0 @@
1
- import { AiInput } from "@effect/ai";
2
- import { Effect, Ref } from "effect";
3
- import { _emit } from "./_emit.js";
4
- import { Handler, MessagesRef } from "./Context.js";
5
- import { MessageAppended } from "./LEvent.js";
6
- import { isTemplateStringsArray } from "./util/isTemplateStringsArray.js";
7
- export const user = Effect.fn(function* (e0, ...eRest) {
8
- const message = new AiInput.UserMessage({
9
- parts: [
10
- new AiInput.TextPart({
11
- text: isTemplateStringsArray(e0) ? String.raw({ raw: e0 }, ...eRest) : e0,
12
- }),
13
- ],
14
- });
15
- yield* _emit(new MessageAppended({ message }));
16
- yield* Ref.update(yield* MessagesRef, (messages) => [...messages, message]);
17
- });
18
- //# sourceMappingURL=user.js.map
package/dist/user.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"user.js","sourceRoot":"","sources":["../user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAA;AAEzE,MAAM,CAAC,MAAM,IAAI,GAMb,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAC,EAAE,EAAE,GAAG,KAAK;IAClC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC;QACtC,KAAK,EAAE;YACL,IAAI,OAAO,CAAC,QAAQ,CAAC;gBACnB,IAAI,EAAE,sBAAsB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;aAC1E,CAAC;SACH;KACF,CAAC,CAAA;IACF,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,eAAe,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;IAC9C,KAAK,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,GAAG,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAA;AAC7E,CAAC,CAAU,CAAA"}
package/messages.ts DELETED
@@ -1,5 +0,0 @@
1
- import type { AiInput } from "@effect/ai"
2
- import { Effect, Ref } from "effect"
3
- import { MessagesRef } from "./Context.ts"
4
-
5
- export const messages: Effect.Effect<Array<AiInput.Message>, never, MessagesRef> = Effect.flatMap(MessagesRef, Ref.get)
package/set.ts DELETED
@@ -1,10 +0,0 @@
1
- import type { AiInput } from "@effect/ai"
2
- import { Effect, Ref } from "effect"
3
- import { MessagesRef } from "./Context.ts"
4
-
5
- export const set = Effect.fn(function*(messages: Iterable<AiInput.Message>) {
6
- const messagesRef = yield* MessagesRef
7
- const previous = yield* Ref.get(messagesRef)
8
- yield* Ref.set(messagesRef, [...messages])
9
- return previous
10
- })
package/strand.ts DELETED
@@ -1,38 +0,0 @@
1
- import type { AiInput, AiTool, AiToolkit } from "@effect/ai"
2
- import { Effect, Option, Ref } from "effect"
3
- import { Handler, MessagesRef, System, Toolkit } from "./Context.ts"
4
- import { LEvent } from "./LEvent.ts"
5
-
6
- export interface StrandOptions<E, R, in out T extends AiTool.Any> {
7
- /** The system prompt. */
8
- system?: string | undefined
9
- /** The initial list of AI input messages. */
10
- messages?: Iterable<AiInput.Message> | undefined
11
- /** The liminal event handler. */
12
- handler?: ((event: LEvent) => Effect.Effect<any, E, R>) | undefined
13
- /** The tools to use for by strand. */
14
- tools?: AiToolkit.AiToolkit<T> | undefined
15
- }
16
-
17
- /** Create an isolated clone of the current conversation to provide for an effect. */
18
- export const strand: <HE = never, HR = never, T extends AiTool.Any = never>(
19
- options?: StrandOptions<HE, HR, T>,
20
- ) => <A, E, R>(
21
- effect: Effect.Effect<A, E, R>,
22
- ) => Effect.Effect<A, E | HE, Exclude<R, MessagesRef | System | Handler> | T> = (options) => (effect) =>
23
- Effect.gen(function*() {
24
- const messagesRef = options?.messages
25
- ? Ref.unsafeMake([...options.messages])
26
- : yield* Option.match(yield* Effect.serviceOption(MessagesRef), {
27
- *onSome(ref) {
28
- return Ref.unsafeMake([...yield* Ref.get(ref)])
29
- },
30
- onNone: () => Ref.make([] as Array<AiInput.Message>),
31
- })
32
- return yield* (effect.pipe(
33
- Effect.provideService(MessagesRef, messagesRef),
34
- Effect.provideService(System, options?.system),
35
- Effect.provideService(Handler, options?.handler),
36
- Effect.provideService(Toolkit, options?.tools),
37
- ))
38
- }) as never // TODO
package/user.ts DELETED
@@ -1,24 +0,0 @@
1
- import { AiInput } from "@effect/ai"
2
- import { Effect, Ref } from "effect"
3
- import { _emit } from "./_emit.ts"
4
- import { Handler, MessagesRef } from "./Context.ts"
5
- import { MessageAppended } from "./LEvent.ts"
6
- import { isTemplateStringsArray } from "./util/isTemplateStringsArray.ts"
7
-
8
- export const user: {
9
- (
10
- template: TemplateStringsArray,
11
- ...substitutions: Array<unknown>
12
- ): Effect.Effect<void, never, MessagesRef | Handler>
13
- (message: string): Effect.Effect<void, never, MessagesRef | Handler>
14
- } = Effect.fn(function*(e0, ...eRest) {
15
- const message = new AiInput.UserMessage({
16
- parts: [
17
- new AiInput.TextPart({
18
- text: isTemplateStringsArray(e0) ? String.raw({ raw: e0 }, ...eRest) : e0,
19
- }),
20
- ],
21
- })
22
- yield* _emit(new MessageAppended({ message }))
23
- yield* Ref.update(yield* MessagesRef, (messages) => [...messages, message])
24
- }) as never