@effect/sql-sqlite-wasm 4.0.0-beta.98 → 4.0.0-rc.108

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.
Files changed (92) hide show
  1. package/AGENTS.md +381 -0
  2. package/CLAUDE.md +381 -0
  3. package/README.md +10 -3
  4. package/ai-docs/README.md +44 -0
  5. package/ai-docs/package.json +36 -0
  6. package/ai-docs/src/01_effect/01_basics/01_effect-gen.ts +30 -0
  7. package/ai-docs/src/01_effect/01_basics/02_effect-fn.ts +39 -0
  8. package/ai-docs/src/01_effect/01_basics/10_creating-effects.ts +74 -0
  9. package/ai-docs/src/01_effect/01_basics/index.md +5 -0
  10. package/ai-docs/src/01_effect/02_schema/10_schema-basics.ts +43 -0
  11. package/ai-docs/src/01_effect/02_schema/index.md +7 -0
  12. package/ai-docs/src/01_effect/03_services/01_service.ts +45 -0
  13. package/ai-docs/src/01_effect/03_services/10_reference.ts +10 -0
  14. package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +70 -0
  15. package/ai-docs/src/01_effect/03_services/20_layer-unwrap.ts +66 -0
  16. package/ai-docs/src/01_effect/03_services/index.md +5 -0
  17. package/ai-docs/src/01_effect/04_errors/01_error-handling.ts +30 -0
  18. package/ai-docs/src/01_effect/04_errors/10_catch-tags.ts +24 -0
  19. package/ai-docs/src/01_effect/04_errors/20_reason-errors.ts +64 -0
  20. package/ai-docs/src/01_effect/04_errors/index.md +1 -0
  21. package/ai-docs/src/01_effect/05_resources/10_acquire-release.ts +105 -0
  22. package/ai-docs/src/01_effect/05_resources/20_layer-side-effects.ts +31 -0
  23. package/ai-docs/src/01_effect/05_resources/30_layer-map.ts +86 -0
  24. package/ai-docs/src/01_effect/05_resources/index.md +3 -0
  25. package/ai-docs/src/01_effect/06_running/10_run-main.ts +30 -0
  26. package/ai-docs/src/01_effect/06_running/20_layer-launch.ts +27 -0
  27. package/ai-docs/src/01_effect/06_running/index.md +1 -0
  28. package/ai-docs/src/01_effect/07_pubsub/10_pubsub.ts +56 -0
  29. package/ai-docs/src/01_effect/07_pubsub/index.md +3 -0
  30. package/ai-docs/src/03_stream/10_creating-streams.ts +103 -0
  31. package/ai-docs/src/03_stream/20_consuming-streams.ts +137 -0
  32. package/ai-docs/src/03_stream/30_encoding.ts +165 -0
  33. package/ai-docs/src/03_stream/index.md +4 -0
  34. package/ai-docs/src/04_integration/10_managed-runtime.ts +129 -0
  35. package/ai-docs/src/04_integration/index.md +5 -0
  36. package/ai-docs/src/05_batching/10_request-resolver.ts +89 -0
  37. package/ai-docs/src/05_batching/index.md +3 -0
  38. package/ai-docs/src/06_schedule/10_schedules.ts +110 -0
  39. package/ai-docs/src/06_schedule/index.md +3 -0
  40. package/ai-docs/src/07_datetime/10_creating-and-formatting.ts +30 -0
  41. package/ai-docs/src/07_datetime/20_time-zones.ts +44 -0
  42. package/ai-docs/src/07_datetime/index.md +5 -0
  43. package/ai-docs/src/08_observability/10_logging.ts +66 -0
  44. package/ai-docs/src/08_observability/20_otlp-tracing.ts +95 -0
  45. package/ai-docs/src/08_observability/index.md +7 -0
  46. package/ai-docs/src/09_testing/10_effect-tests.ts +55 -0
  47. package/ai-docs/src/09_testing/20_layer-tests.ts +138 -0
  48. package/ai-docs/src/09_testing/index.md +1 -0
  49. package/ai-docs/src/10_predicate/01_basics.ts +14 -0
  50. package/ai-docs/src/10_predicate/index.md +9 -0
  51. package/ai-docs/src/50_http-client/10_basics.ts +102 -0
  52. package/ai-docs/src/50_http-client/index.md +3 -0
  53. package/ai-docs/src/51_http-server/10_basics.ts +116 -0
  54. package/ai-docs/src/51_http-server/fixtures/api/Api.ts +14 -0
  55. package/ai-docs/src/51_http-server/fixtures/api/Authorization.ts +36 -0
  56. package/ai-docs/src/51_http-server/fixtures/api/System.ts +10 -0
  57. package/ai-docs/src/51_http-server/fixtures/api/Users.ts +91 -0
  58. package/ai-docs/src/51_http-server/fixtures/domain/User.ts +12 -0
  59. package/ai-docs/src/51_http-server/fixtures/domain/UserErrors.ts +22 -0
  60. package/ai-docs/src/51_http-server/fixtures/server/Authorization.ts +36 -0
  61. package/ai-docs/src/51_http-server/fixtures/server/Users/http.ts +71 -0
  62. package/ai-docs/src/51_http-server/fixtures/server/Users.ts +62 -0
  63. package/ai-docs/src/51_http-server/index.md +3 -0
  64. package/ai-docs/src/60_child-process/10_working-with-child-processes.ts +117 -0
  65. package/ai-docs/src/60_child-process/index.md +3 -0
  66. package/ai-docs/src/70_cli/10_basics.ts +136 -0
  67. package/ai-docs/src/70_cli/index.md +5 -0
  68. package/ai-docs/src/71_ai/10_language-model.ts +156 -0
  69. package/ai-docs/src/71_ai/20_tools.ts +226 -0
  70. package/ai-docs/src/71_ai/30_chat.ts +158 -0
  71. package/ai-docs/src/71_ai/fixtures/domain/LaunchPlan.ts +9 -0
  72. package/ai-docs/src/71_ai/index.md +5 -0
  73. package/ai-docs/src/80_cluster/10_entities.ts +97 -0
  74. package/ai-docs/src/80_cluster/index.md +4 -0
  75. package/ai-docs/src/index.md +10 -0
  76. package/ai-docs/tsconfig.json +24 -0
  77. package/dist/OpfsWorker.d.ts +1 -1
  78. package/dist/OpfsWorker.d.ts.map +1 -1
  79. package/dist/OpfsWorker.js +2 -2
  80. package/dist/OpfsWorker.js.map +1 -1
  81. package/dist/SqliteClient.d.ts +2 -2
  82. package/dist/SqliteClient.d.ts.map +1 -1
  83. package/dist/SqliteClient.js +15 -6
  84. package/dist/SqliteClient.js.map +1 -1
  85. package/dist/SqliteMigrator.d.ts +2 -2
  86. package/dist/SqliteMigrator.js +2 -2
  87. package/dist/SqliteMigrator.js.map +1 -1
  88. package/dist/index.js.map +1 -1
  89. package/package.json +12 -10
  90. package/src/OpfsWorker.ts +5 -2
  91. package/src/SqliteClient.ts +16 -8
  92. package/src/SqliteMigrator.ts +2 -2
package/AGENTS.md ADDED
@@ -0,0 +1,381 @@
1
+ # Effect library documentation
2
+
3
+ This documentation covers the Effect library and its related packages.
4
+
5
+ When you need to find information about Effect, use this documentation and the
6
+ Effect source code available in your environment. Avoid unrelated copies of
7
+ Effect or external documentation, as they may be outdated or incorrect.
8
+
9
+ **Note**: The examples in this documentation contain comments for illustration
10
+ purposes. In practice, you would not include these comments in your code.
11
+
12
+ ## Writing `Effect` code
13
+
14
+ Prefer writing Effect code with `Effect.gen` & `Effect.fn("name")`. Then attach
15
+ additional behaviour with combinators. This style is more readable and easier to
16
+ maintain than using combinators alone.
17
+
18
+ ### Using Effect.gen
19
+
20
+ Use `Effect.gen` to write code in an imperative style similar to async await.
21
+ You can use `yield*` to access the result of an effect.
22
+
23
+ ```ts
24
+ import { Effect, Schema } from "effect"
25
+
26
+ Effect.gen(function*() {
27
+ yield* Effect.log("Starting the file processing...")
28
+ yield* Effect.log("Reading file...")
29
+
30
+ // Always return when raising an error, to ensure typescript understands that
31
+ // the function will not continue executing.
32
+ return yield* new FileProcessingError({ message: "Failed to read the file" })
33
+ }).pipe(
34
+ // Add additional functionality with .pipe
35
+ Effect.catch((error) => Effect.logError(`An error occurred: ${error}`)),
36
+ Effect.withSpan("fileProcessing", {
37
+ attributes: {
38
+ method: "Effect.gen"
39
+ }
40
+ })
41
+ )
42
+
43
+ // Use Schema.TaggedError to define a custom error
44
+ export class FileProcessingError extends Schema.TaggedError<FileProcessingError>()("FileProcessingError", {
45
+ message: Schema.String
46
+ }) {}
47
+ ```
48
+
49
+ ### Using Effect.fn
50
+
51
+ When writing functions that return an Effect, use `Effect.fn` to use the
52
+ generator syntax.
53
+
54
+ **Avoid creating functions that return an Effect.gen**, use `Effect.fn`
55
+ instead.
56
+
57
+ ```ts
58
+ import { Effect, Schema } from "effect"
59
+
60
+ // Pass a string to Effect.fn, which will improve stack traces and also
61
+ // attach a tracing span (using Effect.withSpan behind the scenes).
62
+ //
63
+ // The name string should match the function name.
64
+ //
65
+ export const effectFunction = Effect.fn("effectFunction")(
66
+ // You can use `Effect.fn.Return` to specify the return type of the function.
67
+ // It accepts the same type parameters as `Effect.Effect`.
68
+ function*(n: number): Effect.fn.Return<string, SomeError> {
69
+ yield* Effect.logInfo("Received number:", n)
70
+
71
+ // Always return when raising an error, to ensure typescript understands that
72
+ // the function will not continue executing.
73
+ return yield* new SomeError({ message: "Failed to read the file" })
74
+ },
75
+ // Add additional functionality by passing in additional arguments.
76
+ // **Do not** use .pipe with Effect.fn
77
+ Effect.catch((error) => Effect.logError(`An error occurred: ${error}`)),
78
+ Effect.annotateLogs({
79
+ method: "effectFunction"
80
+ })
81
+ )
82
+
83
+ // Use Schema.TaggedError to define a custom error
84
+ export class SomeError extends Schema.TaggedError<SomeError>()("SomeError", {
85
+ message: Schema.String
86
+ }) {}
87
+ ```
88
+
89
+ ### More examples
90
+
91
+ - **[Creating effects from common sources](./ai-docs/src/01_effect/01_basics/10_creating-effects.ts)**:
92
+ Learn how to create effects from various sources, including plain values,
93
+ synchronous code, Promise APIs, optional values, and callback-based APIs.
94
+
95
+ ## Defining schemas and domain models
96
+
97
+ All validation and domain modeling in Effect is done with `Schema`.
98
+
99
+ **AVOID using predicates or manual parsing**, instead use `Schema` to parse untrusted data and validate it.
100
+
101
+ For a comprehensive guide, see [SCHEMA.md](https://github.com/Effect-TS/effect/blob/main/packages/effect/SCHEMA.md). Make sure to read the guide in chunks, as it is a large document.
102
+
103
+ - **[Schema basics](./ai-docs/src/01_effect/02_schema/10_schema-basics.ts)**:
104
+ Define `Schema.Class`s, decode unknown input into typed values, and
105
+ encode typed values back into their external representation.
106
+
107
+ ## Writing Effect services
108
+
109
+ Effect services are the most common way to structure Effect code. Prefer using
110
+ services to encapsulate behaviour over other approaches, as it ensures that your
111
+ code is modular, testable, and maintainable.
112
+
113
+ ### Context.Service
114
+
115
+ The default way to define a service is to extend `Context.Service`,
116
+ passing in the service interface as a type parameter.
117
+
118
+ ```ts
119
+ // file: src/db/Database.ts
120
+ import { Context, Effect, Layer, Schema } from "effect"
121
+
122
+ // Pass in the service class name as the first type parameter, and the service
123
+ // interface as the second type parameter.
124
+ export class Database extends Context.Service<Database, {
125
+ query(sql: string): Effect.Effect<Array<unknown>, DatabaseError>
126
+ }>()(
127
+ // The string identifier for the service, which should include the package
128
+ // name and the subdirectory path to the service file.
129
+ "myapp/db/Database"
130
+ ) {
131
+ // Attach a static layer to the service, which will be used to provide an
132
+ // implementation of the service.
133
+ static readonly layer = Layer.effect(
134
+ Database,
135
+ Effect.gen(function*() {
136
+ // Define the service methods using Effect.fn
137
+ const query = Effect.fn("Database.query")(function*(sql: string) {
138
+ yield* Effect.log("Executing SQL query:", sql)
139
+ return [{ id: 1, name: "Alice" }, { id: 2, name: "Bob" }]
140
+ })
141
+
142
+ // Return an instance of the service using Database.of, passing in an
143
+ // object that implements the service interface.
144
+ return Database.of({
145
+ query
146
+ })
147
+ })
148
+ )
149
+ }
150
+
151
+ export class DatabaseError extends Schema.TaggedError<DatabaseError>()("DatabaseError", {
152
+ cause: Schema.Defect()
153
+ }) {}
154
+
155
+ // If you ever need to access the service type, use `Database["Service"]`
156
+ export type DatabaseService = Database["Service"]
157
+ ```
158
+
159
+ ### More examples
160
+
161
+ - **[Context.Reference](./ai-docs/src/01_effect/03_services/10_reference.ts)**: For defining configuration values, feature flags, or any other service that has a default value.
162
+ - **[Composing services with the Layer module](./ai-docs/src/01_effect/03_services/20_layer-composition.ts)**:
163
+ Build focused service layers, then compose them with `Layer.provide` and
164
+ `Layer.provideMerge` based on what services you want to expose.
165
+ - **[Creating Layers from configuration and/or Effects](./ai-docs/src/01_effect/03_services/20_layer-unwrap.ts)**: Build a layer dynamically from an Effect / Config with `Layer.unwrap`.
166
+
167
+ ## Error handling
168
+
169
+ ### Error handling basics
170
+
171
+ Defining custom errors and handling them with Effect.catch and Effect.catchTag.
172
+
173
+ ```ts
174
+ import { Effect, Schema } from "effect"
175
+
176
+ // Define custom errors using Schema.TaggedError
177
+ export class ParseError extends Schema.TaggedError<ParseError>()("ParseError", {
178
+ input: Schema.String,
179
+ message: Schema.String
180
+ }) {}
181
+
182
+ export class ReservedPortError extends Schema.TaggedError<ReservedPortError>()("ReservedPortError", {
183
+ port: Schema.Int
184
+ }) {}
185
+
186
+ declare const loadPort: (input: string) => Effect.Effect<number, ParseError | ReservedPortError>
187
+
188
+ export const recovered = loadPort("80").pipe(
189
+ // Catch multiple errors with Effect.catchTag, and return a default port number.
190
+ Effect.catchTag(["ParseError", "ReservedPortError"], (_) => Effect.succeed(3000))
191
+ )
192
+
193
+ export const withFinalFallback = loadPort("invalid").pipe(
194
+ // Catch a specific error with Effect.catchTag
195
+ Effect.catchTag("ReservedPortError", (_) => Effect.succeed(3000)),
196
+ // Catch all errors with Effect.catch
197
+ Effect.catch((_) => Effect.succeed(3000))
198
+ )
199
+ ```
200
+
201
+ ### More examples
202
+
203
+ - **[Catch multiple errors with Effect.catchTags](./ai-docs/src/01_effect/04_errors/10_catch-tags.ts)**: Use `Effect.catchTags` to handle several tagged errors in one place.
204
+ - **[Creating and handling errors with reasons](./ai-docs/src/01_effect/04_errors/20_reason-errors.ts)**:
205
+ Define a tagged error with a tagged `reason` field, then recover with
206
+ `Effect.catchReason`, `Effect.catchReasons`, or by unwrapping the reason into
207
+ the error channel with `Effect.unwrapReason`.
208
+
209
+ ## Managing resources and `Scope`s
210
+
211
+ Learn how to safely manage resources in Effect using `Scope`s and finalizers.
212
+
213
+ - **[Acquiring resources with Effect.acquireRelease](./ai-docs/src/01_effect/05_resources/10_acquire-release.ts)**:
214
+ Define a service that uses `Effect.acquireRelease` to manage the lifecycle of
215
+ a resource, ensuring that it is properly cleaned up when the service is no
216
+ longer needed.
217
+ - **[Creating Layers that run background tasks](./ai-docs/src/01_effect/05_resources/20_layer-side-effects.ts)**: Use Layer.effectDiscard to encapsulate background tasks without a service interface.
218
+ - **[Dynamic resources with LayerMap](./ai-docs/src/01_effect/05_resources/30_layer-map.ts)**:
219
+ Use `LayerMap.Service` to dynamically build and manage resources that are
220
+ keyed by some identifier, such as a tenant ID.
221
+
222
+ ## Running Effect programs
223
+
224
+ - **[Running effects with NodeRuntime and BunRuntime](./ai-docs/src/01_effect/06_running/10_run-main.ts)**: Use `NodeRuntime.runMain` to run an Effect program as your process entrypoint.
225
+ - **[Using Layer.launch as the application entry point](./ai-docs/src/01_effect/06_running/20_layer-launch.ts)**: Use `Layer.launch` to run a long-running Effect program as your process entrypoint.
226
+
227
+ ## Broadcasting messages with PubSub
228
+
229
+ Use `PubSub` when you need one producer to fan out messages to many consumers.
230
+
231
+ - **[Broadcasting domain events with PubSub](./ai-docs/src/01_effect/07_pubsub/10_pubsub.ts)**: Build an in-process event bus with `PubSub` and expose it as a service.
232
+
233
+ ## Working with Streams
234
+
235
+ Effect Streams represent effectful, pull-based sequences of values over time.
236
+ They let you model finite or infinite data sources.
237
+
238
+ - **[Creating streams from common data sources](./ai-docs/src/03_stream/10_creating-streams.ts)**:
239
+ Learn how to create streams from various data sources. Includes:
240
+
241
+ - `Stream.fromIterable` for arrays and other iterables
242
+ - `Stream.fromEffectSchedule` for polling effects
243
+ - `Stream.paginate` for paginated APIs
244
+ - `Stream.fromAsyncIterable` for async iterables
245
+ - `Stream.fromEventListener` for DOM events
246
+ - `Stream.callback` for any callback-based API
247
+ - `NodeStream.fromReadable` for Node.js readable streams
248
+ - **[Consuming and transforming streams](./ai-docs/src/03_stream/20_consuming-streams.ts)**: How to transform and consume streams using operators like `map`, `flatMap`, `filter`, `mapEffect`, and various `run*` methods.
249
+ - **[Decoding and encoding streams](./ai-docs/src/03_stream/30_encoding.ts)**:
250
+ Use `Stream.pipeThroughChannel` with the `Ndjson` & `Msgpack` modules to
251
+ decode and encode streams of structured data.
252
+
253
+ ## Integrating Effect into existing applications
254
+
255
+ `ManagedRuntime` bridges Effect programs with non-Effect code. Build one runtime
256
+ from your application Layer, then use it anywhere you need imperative execution,
257
+ like web handlers, framework hooks, worker queues, or legacy callback APIs.
258
+
259
+ - **[Using ManagedRuntime with Hono](./ai-docs/src/04_integration/10_managed-runtime.ts)**: Use `ManagedRuntime` to run Effect programs from external frameworks while keeping your domain logic in services and Layers.
260
+
261
+ ## Batching external requests
262
+
263
+ Learn how to batch multiple requests into fewer external calls.
264
+
265
+ - **[Batching requests with RequestResolver](./ai-docs/src/05_batching/10_request-resolver.ts)**: Define request types with `Request.Class`, resolve them in batches with `RequestResolver`.
266
+
267
+ ## Working with Schedules
268
+
269
+ Schedules define recurring patterns for retries, repeats and polling.
270
+
271
+ - **[Working with the Schedule module](./ai-docs/src/06_schedule/10_schedules.ts)**: Build schedules, compose them, and use them with `Effect.retry` and `Effect.repeat`.
272
+
273
+ ## Working with DateTime
274
+
275
+ When working with dates and time, use the `DateTime` module instead of `Date` and `Date.now`.
276
+
277
+ Use it when your Effect programs need testable current time, safe parsing, stable ISO formatting, time-zone conversion, or calendar arithmetic.
278
+
279
+ - **[Creating and formatting DateTime values](./ai-docs/src/07_datetime/10_creating-and-formatting.ts)**:
280
+ Parse incoming date values safely, use Clock-powered current time, and format
281
+ instants for API payloads or user-facing labels.
282
+ - **[Working with time zones](./ai-docs/src/07_datetime/20_time-zones.ts)**:
283
+ Attach IANA zones to instants, render zoned ISO strings, and provide a
284
+ CurrentTimeZone service for code that should use the workspace/user zone.
285
+
286
+ ## Observability
287
+
288
+ Effect has built-in support for structured logging, distributed tracing, and
289
+ metrics. For exporting telemetry, use the lightweight Otlp modules from
290
+ `effect/unstable/observability` in new projects, or use
291
+ `@effect/opentelemetry` NodeSdk when integrating with an existing OpenTelemetry
292
+ setup.
293
+
294
+ - **[Customizing logging](./ai-docs/src/08_observability/10_logging.ts)**: Configure loggers & log-level filtering for production applications.
295
+ - **[Setting up tracing with Otlp modules](./ai-docs/src/08_observability/20_otlp-tracing.ts)**: Configure Otlp tracing + log export with a reusable observability layer.
296
+
297
+ ## Testing Effect programs
298
+
299
+ - **[Writing Effect tests with @effect/vitest](./ai-docs/src/09_testing/10_effect-tests.ts)**: Using `it.effect` for Effect-based tests.
300
+ - **[Testing services with shared layers](./ai-docs/src/09_testing/20_layer-tests.ts)**: How to test Effect services that depend on other services.
301
+
302
+ ## Runtime type guards
303
+
304
+ The `Predicate` module contains small, reusable runtime checks.
305
+
306
+ **NEVER** write your own helper functions like `isRecord` or `isString`, instead
307
+ use the helpers from the `Predicate` module.
308
+
309
+ Predicates can be composed with apis such as `Predicate.and`,
310
+ `Predicate.or`, `Predicate.not`, and `Predicate.compose`.
311
+
312
+ ### Using the Predicate module
313
+
314
+
315
+
316
+ ```ts
317
+ import { Predicate } from "effect"
318
+
319
+ const thing: unknown = {
320
+ a: 1
321
+ }
322
+
323
+ if (Predicate.isObject(thing)) {
324
+ if (Predicate.isNumber(thing.a)) {
325
+ console.log("number", thing.a)
326
+ }
327
+ }
328
+ ```
329
+
330
+ ## Effect HttpClient
331
+
332
+ Build http clients with the `HttpClient` module.
333
+
334
+ - **[Getting started with HttpClient](./ai-docs/src/50_http-client/10_basics.ts)**: Define a service that uses the HttpClient module to fetch data from an external API
335
+
336
+ ## Building HttpApi servers
337
+
338
+ `HttpApi` gives you schema-first, type-safe HTTP APIs with runtime validation, typed clients, and OpenAPI docs from one definition.
339
+
340
+ - **[Getting started with HttpApi](./ai-docs/src/51_http-server/10_basics.ts)**:
341
+ Define a schema-first API, implement handlers, secure endpoints with
342
+ middleware, serve it over HTTP, and call it using a generated typed client.
343
+
344
+ ## Working with child processes
345
+
346
+ Use the `effect/unstable/process` modules to define child processes and run them with `ChildProcessSpawner`.
347
+
348
+ - **[Working with child processes](./ai-docs/src/60_child-process/10_working-with-child-processes.ts)**: This example shows how to collect process output, compose pipelines, and stream long-running command output.
349
+
350
+ ## Building CLI applications
351
+
352
+ Use the "effect/unstable/cli" modules to build CLI applications. These modules
353
+ provide utilities for parsing command-line arguments, handling user input, and
354
+ managing the flow of a CLI application.
355
+
356
+ - **[Getting started with Effect CLI modules](./ai-docs/src/70_cli/10_basics.ts)**:
357
+ Build a command-line app with typed arguments and flags, then wire subcommand
358
+ handlers into a single executable command.
359
+
360
+ ## Working with AI modules
361
+
362
+ Effect's AI modules provide a provider-agnostic interface for language models.
363
+ You can generate text, decode structured objects with `Schema` and stream partial
364
+ responses.
365
+
366
+ - **[Using LanguageModel for text, objects, and streams](./ai-docs/src/71_ai/10_language-model.ts)**:
367
+ Configure a provider once, then use `LanguageModel` for plain text
368
+ generation, schema-validated object generation, and streaming responses.
369
+ - **[Defining and using AI tools](./ai-docs/src/71_ai/20_tools.ts)**:
370
+ Define tools with schemas, group them into toolkits, implement handlers,
371
+ and pass them to `LanguageModel.generateText`.
372
+ - **[Stateful chat sessions](./ai-docs/src/71_ai/30_chat.ts)**:
373
+ The AI `Chat` module maintains conversation history automatically. Build
374
+ AI agents or chat assistants.
375
+
376
+ ## Building distributed applications with cluster
377
+
378
+ The cluster modules let you model stateful services as entities and distribute
379
+ them across multiple machines.
380
+
381
+ - **[Defining cluster entities](./ai-docs/src/80_cluster/10_entities.ts)**: Define distributed entity RPCs and run them in a cluster.