liminal 0.6.0 → 0.7.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/dist/user.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { Effect } from "effect";
2
- import { Handler, MessagesRef } from "./Context.ts";
1
+ import * as Effect from "effect/Effect";
2
+ import { MessagesRef } from "./Context.ts";
3
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>;
4
+ (template: TemplateStringsArray, ...substitutions: Array<unknown>): Effect.Effect<void, never, MessagesRef>;
5
+ (message: string): Effect.Effect<void, never, MessagesRef>;
6
6
  };
package/dist/user.js CHANGED
@@ -1,8 +1,7 @@
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";
1
+ import * as AiInput from "@effect/ai/AiInput";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Ref from "effect/Ref";
4
+ import { MessagesRef } from "./Context.js";
6
5
  import { isTemplateStringsArray } from "./util/isTemplateStringsArray.js";
7
6
  export const user = Effect.fn(function* (e0, ...eRest) {
8
7
  const message = new AiInput.UserMessage({
@@ -12,7 +11,6 @@ export const user = Effect.fn(function* (e0, ...eRest) {
12
11
  }),
13
12
  ],
14
13
  });
15
- yield* _emit(new MessageAppended({ message }));
16
14
  yield* Ref.update(yield* MessagesRef, (messages) => [...messages, message]);
17
15
  });
18
16
  //# sourceMappingURL=user.js.map
package/dist/user.js.map CHANGED
@@ -1 +1 @@
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,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Mb,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,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/index.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from "./Context.ts"
2
2
  export * as L from "./L.ts"
3
- export * from "./LEvent.ts"
4
3
  export * from "./strand.ts"
package/messages.ts CHANGED
@@ -1,5 +1,6 @@
1
- import type { AiInput } from "@effect/ai"
2
- import { Effect, Ref } from "effect"
1
+ import type { Message } from "@effect/ai/AiInput"
2
+ import * as Effect from "effect/Effect"
3
+ import * as Ref from "effect/Ref"
3
4
  import { MessagesRef } from "./Context.ts"
4
5
 
5
- export const messages: Effect.Effect<Array<AiInput.Message>, never, MessagesRef> = Effect.flatMap(MessagesRef, Ref.get)
6
+ export const messages: Effect.Effect<Array<Message>, never, MessagesRef> = Effect.flatMap(MessagesRef, Ref.get)
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.7.0",
7
7
  "license": "Apache-2.0",
8
8
  "repository": {
9
9
  "type": "git",
package/set.ts CHANGED
@@ -1,8 +1,9 @@
1
- import type { AiInput } from "@effect/ai"
2
- import { Effect, Ref } from "effect"
1
+ import { Message } from "@effect/ai/AiInput"
2
+ import * as Effect from "effect/Effect"
3
+ import * as Ref from "effect/Ref"
3
4
  import { MessagesRef } from "./Context.ts"
4
5
 
5
- export const set = Effect.fn(function*(messages: Iterable<AiInput.Message>) {
6
+ export const set = Effect.fn(function*(messages: Iterable<Message>) {
6
7
  const messagesRef = yield* MessagesRef
7
8
  const previous = yield* Ref.get(messagesRef)
8
9
  yield* Ref.set(messagesRef, [...messages])
package/strand.ts CHANGED
@@ -1,25 +1,26 @@
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"
1
+ import * as AiInput from "@effect/ai/AiInput"
2
+ import * as AiTool from "@effect/ai/AiTool"
3
+ import type * as AiToolkit from "@effect/ai/AiToolkit"
4
+ import * as Effect from "effect/Effect"
5
+ import * as Option from "effect/Option"
6
+ import * as Ref from "effect/Ref"
7
+ import { MessagesRef, System, Toolkit } from "./Context.ts"
5
8
 
6
- export interface StrandOptions<E, R, in out T extends AiTool.Any> {
9
+ export interface StrandOptions<in out Tool extends AiTool.Any> {
7
10
  /** The system prompt. */
8
11
  system?: string | undefined
9
12
  /** The initial list of AI input messages. */
10
13
  messages?: Iterable<AiInput.Message> | undefined
11
- /** The liminal event handler. */
12
- handler?: ((event: LEvent) => Effect.Effect<any, E, R>) | undefined
13
14
  /** The tools to use for by strand. */
14
- tools?: AiToolkit.AiToolkit<T> | undefined
15
+ toolkit?: AiToolkit.AiToolkit<Tool> | undefined
15
16
  }
16
17
 
17
18
  /** 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>,
19
+ export const strand: <HE = never, T extends AiTool.Any = never>(
20
+ options?: StrandOptions<T>,
20
21
  ) => <A, E, R>(
21
22
  effect: Effect.Effect<A, E, R>,
22
- ) => Effect.Effect<A, E | HE, Exclude<R, MessagesRef | System | Handler> | T> = (options) => (effect) =>
23
+ ) => Effect.Effect<A, E | HE, Exclude<R, MessagesRef | System> | T> = (options) => (effect) =>
23
24
  Effect.gen(function*() {
24
25
  const messagesRef = options?.messages
25
26
  ? Ref.unsafeMake([...options.messages])
@@ -32,7 +33,6 @@ export const strand: <HE = never, HR = never, T extends AiTool.Any = never>(
32
33
  return yield* (effect.pipe(
33
34
  Effect.provideService(MessagesRef, messagesRef),
34
35
  Effect.provideService(System, options?.system),
35
- Effect.provideService(Handler, options?.handler),
36
- Effect.provideService(Toolkit, options?.tools),
36
+ Effect.provideService(Toolkit, options?.toolkit),
37
37
  ))
38
- }) as never // TODO
38
+ }) as never
package/user.ts CHANGED
@@ -1,16 +1,15 @@
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"
1
+ import * as AiInput from "@effect/ai/AiInput"
2
+ import * as Effect from "effect/Effect"
3
+ import * as Ref from "effect/Ref"
4
+ import { MessagesRef } from "./Context.ts"
6
5
  import { isTemplateStringsArray } from "./util/isTemplateStringsArray.ts"
7
6
 
8
7
  export const user: {
9
8
  (
10
9
  template: TemplateStringsArray,
11
10
  ...substitutions: Array<unknown>
12
- ): Effect.Effect<void, never, MessagesRef | Handler>
13
- (message: string): Effect.Effect<void, never, MessagesRef | Handler>
11
+ ): Effect.Effect<void, never, MessagesRef>
12
+ (message: string): Effect.Effect<void, never, MessagesRef>
14
13
  } = Effect.fn(function*(e0, ...eRest) {
15
14
  const message = new AiInput.UserMessage({
16
15
  parts: [
@@ -19,6 +18,5 @@ export const user: {
19
18
  }),
20
19
  ],
21
20
  })
22
- yield* _emit(new MessageAppended({ message }))
23
21
  yield* Ref.update(yield* MessagesRef, (messages) => [...messages, message])
24
22
  }) as never
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/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"}