@effect-uai/core 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/README.md +30 -16
- package/dist/{AiError-eLV9t1lU.d.mts → AiError-DvhLIbmd.d.mts} +15 -4
- package/dist/{AiError-eLV9t1lU.d.mts.map → AiError-DvhLIbmd.d.mts.map} +1 -1
- package/dist/{Loop-B54AB1ME.d.mts → Loop-ChpaO-ya.d.mts} +2 -2
- package/dist/{Loop-B54AB1ME.d.mts.map → Loop-ChpaO-ya.d.mts.map} +1 -1
- package/dist/{Toolkit-DAjJ9Tvl.d.mts → Toolkit-tlL0F2YR.d.mts} +2 -2
- package/dist/{Toolkit-DAjJ9Tvl.d.mts.map → Toolkit-tlL0F2YR.d.mts.map} +1 -1
- package/dist/chunker/Chunker.d.mts +1 -1
- package/dist/domain/AiError.d.mts +2 -2
- package/dist/domain/AiError.mjs +9 -2
- package/dist/domain/AiError.mjs.map +1 -1
- package/dist/domain/Realtime.d.mts +616 -0
- package/dist/domain/Realtime.d.mts.map +1 -0
- package/dist/domain/Realtime.mjs +21 -0
- package/dist/domain/Realtime.mjs.map +1 -0
- package/dist/domain/Transcript.d.mts +17 -3
- package/dist/domain/Transcript.d.mts.map +1 -1
- package/dist/domain/Transcript.mjs +30 -1
- package/dist/domain/Transcript.mjs.map +1 -1
- package/dist/domain/Transcript.test.mjs +110 -0
- package/dist/domain/Transcript.test.mjs.map +1 -0
- package/dist/embedding-model/EmbeddingModel.d.mts +1 -1
- package/dist/image-generator/ImageGenerator.d.mts +1 -1
- package/dist/index.d.mts +8 -5
- package/dist/index.mjs +6 -3
- package/dist/job/Job.d.mts +1 -1
- package/dist/language-model/LanguageModel.d.mts +2 -2
- package/dist/loop/Loop.d.mts +1 -1
- package/dist/music-generator/MusicGenerator.d.mts +1 -1
- package/dist/realtime/RealtimeSession.d.mts +50 -0
- package/dist/realtime/RealtimeSession.d.mts.map +1 -0
- package/dist/realtime/RealtimeSession.mjs +45 -0
- package/dist/realtime/RealtimeSession.mjs.map +1 -0
- package/dist/realtime/RealtimeSession.test.d.mts +1 -0
- package/dist/realtime/RealtimeSession.test.mjs +95 -0
- package/dist/realtime/RealtimeSession.test.mjs.map +1 -0
- package/dist/reranker/Reranker.d.mts +1 -1
- package/dist/research/DeepResearch.d.mts +1 -1
- package/dist/retry/Retry.d.mts +1 -1
- package/dist/speech-synthesizer/SpeechSynthesizer.d.mts +1 -1
- package/dist/streaming/Settle.d.mts +45 -0
- package/dist/streaming/Settle.d.mts.map +1 -0
- package/dist/streaming/Settle.mjs +95 -0
- package/dist/streaming/Settle.mjs.map +1 -0
- package/dist/streaming/Settle.test.d.mts +1 -0
- package/dist/streaming/Settle.test.mjs +252 -0
- package/dist/streaming/Settle.test.mjs.map +1 -0
- package/dist/streaming/WebSocketSession.d.mts +36 -0
- package/dist/streaming/WebSocketSession.d.mts.map +1 -0
- package/dist/streaming/WebSocketSession.mjs +89 -0
- package/dist/streaming/WebSocketSession.mjs.map +1 -0
- package/dist/streaming/WebSocketSession.test.d.mts +1 -0
- package/dist/streaming/WebSocketSession.test.mjs +51 -0
- package/dist/streaming/WebSocketSession.test.mjs.map +1 -0
- package/dist/testing/FakeWebSocket.d.mts +25 -0
- package/dist/testing/FakeWebSocket.d.mts.map +1 -0
- package/dist/testing/FakeWebSocket.mjs +79 -0
- package/dist/testing/FakeWebSocket.mjs.map +1 -0
- package/dist/testing/MockRealtimeSession.d.mts +30 -0
- package/dist/testing/MockRealtimeSession.d.mts.map +1 -0
- package/dist/testing/MockRealtimeSession.mjs +52 -0
- package/dist/testing/MockRealtimeSession.mjs.map +1 -0
- package/dist/tool/Toolkit.d.mts +1 -1
- package/dist/transcriber/Transcriber.d.mts +1 -1
- package/dist/web-read/WebRead.d.mts +1 -1
- package/dist/web-read/WebReadTool.d.mts +1 -1
- package/dist/web-search/WebSearch.d.mts +1 -1
- package/dist/web-search/WebSearchTool.d.mts +1 -1
- package/package.json +24 -4
- package/src/domain/AiError.ts +11 -0
- package/src/domain/Realtime.ts +101 -0
- package/src/domain/Transcript.test.ts +98 -0
- package/src/domain/Transcript.ts +53 -1
- package/src/index.ts +4 -1
- package/src/realtime/RealtimeSession.test.ts +100 -0
- package/src/realtime/RealtimeSession.ts +77 -0
- package/src/streaming/Settle.test.ts +344 -0
- package/src/streaming/Settle.ts +196 -0
- package/src/streaming/WebSocketSession.test.ts +52 -0
- package/src/streaming/WebSocketSession.ts +132 -0
- package/src/testing/FakeWebSocket.ts +120 -0
- package/src/testing/MockRealtimeSession.ts +92 -0
- package/dist/inbox/Inbox.d.mts +0 -16
- package/dist/inbox/Inbox.d.mts.map +0 -1
- package/dist/inbox/Inbox.mjs +0 -28
- package/dist/inbox/Inbox.mjs.map +0 -1
- package/dist/inbox/Inbox.test.mjs +0 -42
- package/dist/inbox/Inbox.test.mjs.map +0 -1
- package/src/inbox/Inbox.test.ts +0 -52
- package/src/inbox/Inbox.ts +0 -33
- /package/dist/{inbox/Inbox.test.d.mts → domain/Transcript.test.d.mts} +0 -0
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { drainBurst } from "./Inbox.mjs";
|
|
2
|
-
import { o as describe } from "../utils-CiH_DjFW.mjs";
|
|
3
|
-
import { n as globalExpect } from "../test.DNmyFkvJ-YPzDR0Co.mjs";
|
|
4
|
-
import { t as it } from "../dist-nohcnkD6.mjs";
|
|
5
|
-
import { Effect, Fiber, Option, Queue } from "effect";
|
|
6
|
-
import { TestClock } from "effect/testing";
|
|
7
|
-
//#region src/inbox/Inbox.test.ts
|
|
8
|
-
describe("drainBurst", () => {
|
|
9
|
-
it.effect("resets the window on every arrival, so a burst outlives one settle", () => Effect.gen(function* () {
|
|
10
|
-
const queue = yield* Queue.unbounded();
|
|
11
|
-
const burst = yield* Effect.forkChild(drainBurst(queue, "1 second"));
|
|
12
|
-
yield* Queue.offer(queue, "a");
|
|
13
|
-
yield* TestClock.adjust("900 millis");
|
|
14
|
-
yield* Queue.offer(queue, "b");
|
|
15
|
-
yield* TestClock.adjust("900 millis");
|
|
16
|
-
globalExpect(burst.pollUnsafe()).toBeUndefined();
|
|
17
|
-
yield* TestClock.adjust("1 second");
|
|
18
|
-
globalExpect(yield* Fiber.join(burst)).toEqual(["a", "b"]);
|
|
19
|
-
}));
|
|
20
|
-
it.effect("waits for the first item without a deadline", () => Effect.gen(function* () {
|
|
21
|
-
const queue = yield* Queue.unbounded();
|
|
22
|
-
const burst = yield* Effect.forkChild(drainBurst(queue, "1 second"));
|
|
23
|
-
yield* TestClock.adjust("1 hour");
|
|
24
|
-
globalExpect(burst.pollUnsafe()).toBeUndefined();
|
|
25
|
-
yield* Queue.offer(queue, "late");
|
|
26
|
-
yield* TestClock.adjust("1 second");
|
|
27
|
-
globalExpect(yield* Fiber.join(burst)).toEqual(["late"]);
|
|
28
|
-
}));
|
|
29
|
-
it.effect("ends on the first quiet gap and leaves later items for the next drain", () => Effect.gen(function* () {
|
|
30
|
-
const queue = yield* Queue.unbounded();
|
|
31
|
-
const burst = yield* Effect.forkChild(drainBurst(queue, "1 second"));
|
|
32
|
-
yield* Queue.offer(queue, "first");
|
|
33
|
-
yield* TestClock.adjust("1 second");
|
|
34
|
-
globalExpect(yield* Fiber.join(burst)).toEqual(["first"]);
|
|
35
|
-
yield* Queue.offer(queue, "second");
|
|
36
|
-
globalExpect(yield* Queue.poll(queue)).toEqual(Option.some("second"));
|
|
37
|
-
}));
|
|
38
|
-
});
|
|
39
|
-
//#endregion
|
|
40
|
-
export {};
|
|
41
|
-
|
|
42
|
-
//# sourceMappingURL=Inbox.test.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Inbox.test.mjs","names":[],"sources":["../../src/inbox/Inbox.test.ts"],"sourcesContent":["import { describe, it } from \"@effect/vitest\"\nimport { Effect, Fiber, Option, Queue } from \"effect\"\nimport { TestClock } from \"effect/testing\"\nimport { expect } from \"vitest\"\nimport { drainBurst } from \"./Inbox.js\"\n\ndescribe(\"drainBurst\", () => {\n it.effect(\"resets the window on every arrival, so a burst outlives one settle\", () =>\n Effect.gen(function* () {\n const queue = yield* Queue.unbounded<string>()\n const burst = yield* Effect.forkChild(drainBurst(queue, \"1 second\"))\n\n yield* Queue.offer(queue, \"a\")\n yield* TestClock.adjust(\"900 millis\")\n yield* Queue.offer(queue, \"b\")\n yield* TestClock.adjust(\"900 millis\")\n // 1.8s elapsed, more than one settle, and the burst is still open.\n expect(burst.pollUnsafe()).toBeUndefined()\n\n yield* TestClock.adjust(\"1 second\")\n expect(yield* Fiber.join(burst)).toEqual([\"a\", \"b\"])\n }),\n )\n\n it.effect(\"waits for the first item without a deadline\", () =>\n Effect.gen(function* () {\n const queue = yield* Queue.unbounded<string>()\n const burst = yield* Effect.forkChild(drainBurst(queue, \"1 second\"))\n\n yield* TestClock.adjust(\"1 hour\")\n expect(burst.pollUnsafe()).toBeUndefined()\n\n yield* Queue.offer(queue, \"late\")\n yield* TestClock.adjust(\"1 second\")\n expect(yield* Fiber.join(burst)).toEqual([\"late\"])\n }),\n )\n\n it.effect(\"ends on the first quiet gap and leaves later items for the next drain\", () =>\n Effect.gen(function* () {\n const queue = yield* Queue.unbounded<string>()\n const burst = yield* Effect.forkChild(drainBurst(queue, \"1 second\"))\n\n yield* Queue.offer(queue, \"first\")\n yield* TestClock.adjust(\"1 second\")\n expect(yield* Fiber.join(burst)).toEqual([\"first\"])\n\n yield* Queue.offer(queue, \"second\")\n expect(yield* Queue.poll(queue)).toEqual(Option.some(\"second\"))\n }),\n )\n})\n"],"mappings":";;;;;;;AAMA,SAAS,oBAAoB;CAC3B,GAAG,OAAO,4EACR,OAAO,IAAI,aAAa;EACtB,MAAM,QAAQ,OAAO,MAAM,UAAkB;EAC7C,MAAM,QAAQ,OAAO,OAAO,UAAU,WAAW,OAAO,UAAU,CAAC;EAEnE,OAAO,MAAM,MAAM,OAAO,GAAG;EAC7B,OAAO,UAAU,OAAO,YAAY;EACpC,OAAO,MAAM,MAAM,OAAO,GAAG;EAC7B,OAAO,UAAU,OAAO,YAAY;EAEpC,aAAO,MAAM,WAAW,CAAC,CAAC,CAAC,cAAc;EAEzC,OAAO,UAAU,OAAO,UAAU;EAClC,aAAO,OAAO,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,GAAG,CAAC;CACrD,CAAC,CACH;CAEA,GAAG,OAAO,qDACR,OAAO,IAAI,aAAa;EACtB,MAAM,QAAQ,OAAO,MAAM,UAAkB;EAC7C,MAAM,QAAQ,OAAO,OAAO,UAAU,WAAW,OAAO,UAAU,CAAC;EAEnE,OAAO,UAAU,OAAO,QAAQ;EAChC,aAAO,MAAM,WAAW,CAAC,CAAC,CAAC,cAAc;EAEzC,OAAO,MAAM,MAAM,OAAO,MAAM;EAChC,OAAO,UAAU,OAAO,UAAU;EAClC,aAAO,OAAO,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;CACnD,CAAC,CACH;CAEA,GAAG,OAAO,+EACR,OAAO,IAAI,aAAa;EACtB,MAAM,QAAQ,OAAO,MAAM,UAAkB;EAC7C,MAAM,QAAQ,OAAO,OAAO,UAAU,WAAW,OAAO,UAAU,CAAC;EAEnE,OAAO,MAAM,MAAM,OAAO,OAAO;EACjC,OAAO,UAAU,OAAO,UAAU;EAClC,aAAO,OAAO,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;EAElD,OAAO,MAAM,MAAM,OAAO,QAAQ;EAClC,aAAO,OAAO,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,QAAQ,OAAO,KAAK,QAAQ,CAAC;CAChE,CAAC,CACH;AACF,CAAC"}
|
package/src/inbox/Inbox.test.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { describe, it } from "@effect/vitest"
|
|
2
|
-
import { Effect, Fiber, Option, Queue } from "effect"
|
|
3
|
-
import { TestClock } from "effect/testing"
|
|
4
|
-
import { expect } from "vitest"
|
|
5
|
-
import { drainBurst } from "./Inbox.js"
|
|
6
|
-
|
|
7
|
-
describe("drainBurst", () => {
|
|
8
|
-
it.effect("resets the window on every arrival, so a burst outlives one settle", () =>
|
|
9
|
-
Effect.gen(function* () {
|
|
10
|
-
const queue = yield* Queue.unbounded<string>()
|
|
11
|
-
const burst = yield* Effect.forkChild(drainBurst(queue, "1 second"))
|
|
12
|
-
|
|
13
|
-
yield* Queue.offer(queue, "a")
|
|
14
|
-
yield* TestClock.adjust("900 millis")
|
|
15
|
-
yield* Queue.offer(queue, "b")
|
|
16
|
-
yield* TestClock.adjust("900 millis")
|
|
17
|
-
// 1.8s elapsed, more than one settle, and the burst is still open.
|
|
18
|
-
expect(burst.pollUnsafe()).toBeUndefined()
|
|
19
|
-
|
|
20
|
-
yield* TestClock.adjust("1 second")
|
|
21
|
-
expect(yield* Fiber.join(burst)).toEqual(["a", "b"])
|
|
22
|
-
}),
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
it.effect("waits for the first item without a deadline", () =>
|
|
26
|
-
Effect.gen(function* () {
|
|
27
|
-
const queue = yield* Queue.unbounded<string>()
|
|
28
|
-
const burst = yield* Effect.forkChild(drainBurst(queue, "1 second"))
|
|
29
|
-
|
|
30
|
-
yield* TestClock.adjust("1 hour")
|
|
31
|
-
expect(burst.pollUnsafe()).toBeUndefined()
|
|
32
|
-
|
|
33
|
-
yield* Queue.offer(queue, "late")
|
|
34
|
-
yield* TestClock.adjust("1 second")
|
|
35
|
-
expect(yield* Fiber.join(burst)).toEqual(["late"])
|
|
36
|
-
}),
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
it.effect("ends on the first quiet gap and leaves later items for the next drain", () =>
|
|
40
|
-
Effect.gen(function* () {
|
|
41
|
-
const queue = yield* Queue.unbounded<string>()
|
|
42
|
-
const burst = yield* Effect.forkChild(drainBurst(queue, "1 second"))
|
|
43
|
-
|
|
44
|
-
yield* Queue.offer(queue, "first")
|
|
45
|
-
yield* TestClock.adjust("1 second")
|
|
46
|
-
expect(yield* Fiber.join(burst)).toEqual(["first"])
|
|
47
|
-
|
|
48
|
-
yield* Queue.offer(queue, "second")
|
|
49
|
-
expect(yield* Queue.poll(queue)).toEqual(Option.some("second"))
|
|
50
|
-
}),
|
|
51
|
-
)
|
|
52
|
-
})
|
package/src/inbox/Inbox.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Input a long-lived agent reads between turns. A chat user rarely sends one
|
|
3
|
-
* tidy message: they type three lines in a row, then go quiet. The loop wants
|
|
4
|
-
* that as one batch, taken at a clean turn boundary.
|
|
5
|
-
*/
|
|
6
|
-
import { Array as Arr, type Duration, Effect, Option, Queue } from "effect"
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Block for the first item, then keep taking while the next one lands within
|
|
10
|
-
* `settle` of the previous. The window resets on every arrival, so a burst
|
|
11
|
-
* becomes one batch and a lone message followed by silence returns at once.
|
|
12
|
-
*
|
|
13
|
-
* A take that loses to the window is interrupted before it removes anything,
|
|
14
|
-
* so late arrivals stay queued for the next drain.
|
|
15
|
-
*/
|
|
16
|
-
export const drainBurst = <A, E>(
|
|
17
|
-
queue: Queue.Dequeue<A, E>,
|
|
18
|
-
settle: Duration.Input,
|
|
19
|
-
): Effect.Effect<Arr.NonEmptyReadonlyArray<A>, E> => {
|
|
20
|
-
const settled = (
|
|
21
|
-
batch: Arr.NonEmptyReadonlyArray<A>,
|
|
22
|
-
): Effect.Effect<Arr.NonEmptyReadonlyArray<A>, E> =>
|
|
23
|
-
Queue.take(queue).pipe(
|
|
24
|
-
Effect.timeoutOption(settle),
|
|
25
|
-
Effect.flatMap(
|
|
26
|
-
Option.match({
|
|
27
|
-
onNone: () => Effect.succeed(batch),
|
|
28
|
-
onSome: (item) => settled(Arr.append(batch, item)),
|
|
29
|
-
}),
|
|
30
|
-
),
|
|
31
|
-
)
|
|
32
|
-
return Effect.flatMap(Queue.take(queue), (first) => settled([first]))
|
|
33
|
-
}
|
|
File without changes
|