effect 4.0.0-beta.19 → 4.0.0-beta.20
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/Channel.d.ts +6 -6
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js.map +1 -1
- package/dist/Config.d.ts +5 -6
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +3 -3
- package/dist/Config.js.map +1 -1
- package/dist/Effect.d.ts +22 -22
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +3 -3
- package/dist/Effect.js.map +1 -1
- package/dist/ErrorReporter.js +2 -2
- package/dist/ErrorReporter.js.map +1 -1
- package/dist/Layer.d.ts +9 -9
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js.map +1 -1
- package/dist/Schedule.d.ts +14 -6
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +25 -9
- package/dist/Schedule.js.map +1 -1
- package/dist/Schema.d.ts +21 -0
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js.map +1 -1
- package/dist/ServiceMap.d.ts +39 -30
- package/dist/ServiceMap.d.ts.map +1 -1
- package/dist/ServiceMap.js +3 -3
- package/dist/ServiceMap.js.map +1 -1
- package/dist/Sink.d.ts +2 -2
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js.map +1 -1
- package/dist/Stream.d.ts +6 -6
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/effect.js +2 -2
- package/dist/internal/effect.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +2 -2
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +90 -10
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.js +11 -12
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/Model.d.ts +25 -7
- package/dist/unstable/ai/Model.d.ts.map +1 -1
- package/dist/unstable/ai/Model.js +22 -6
- package/dist/unstable/ai/Model.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +3 -3
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/index.d.ts +1 -1
- package/dist/unstable/ai/index.js +1 -1
- package/dist/unstable/cli/Command.d.ts +6 -6
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts +2 -2
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts +2 -2
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js +20 -20
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/httpapi/HttpApi.d.ts +3 -3
- package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +7 -2
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +3 -3
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.d.ts +3 -3
- package/dist/unstable/httpapi/HttpApiGroup.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +4 -4
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.d.ts +2 -2
- package/dist/unstable/httpapi/HttpApiSecurity.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/process/ChildProcess.d.ts +3 -126
- package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcess.js +1 -65
- package/dist/unstable/process/ChildProcess.js.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.d.ts +39 -7
- package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js +21 -1
- package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +1 -1
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcGroup.d.ts +2 -2
- package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcGroup.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts +3 -3
- package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
- package/dist/unstable/sql/SqlClient.d.ts +1 -1
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +1 -1
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Channel.ts +9 -9
- package/src/Config.ts +9 -9
- package/src/Effect.ts +24 -32
- package/src/ErrorReporter.ts +2 -2
- package/src/Layer.ts +11 -15
- package/src/Schedule.ts +35 -19
- package/src/Schema.ts +21 -0
- package/src/ServiceMap.ts +47 -38
- package/src/Sink.ts +3 -3
- package/src/Stream.ts +9 -9
- package/src/index.ts +1 -1
- package/src/internal/effect.ts +24 -24
- package/src/testing/TestSchema.ts +2 -2
- package/src/unstable/ai/AiError.ts +95 -42
- package/src/unstable/ai/Model.ts +40 -9
- package/src/unstable/ai/Tool.ts +4 -4
- package/src/unstable/ai/index.ts +1 -1
- package/src/unstable/cli/Command.ts +9 -12
- package/src/unstable/cli/internal/command.ts +2 -2
- package/src/unstable/cluster/Entity.ts +4 -4
- package/src/unstable/cluster/ShardingConfig.ts +20 -20
- package/src/unstable/httpapi/HttpApi.ts +5 -5
- package/src/unstable/httpapi/HttpApiBuilder.ts +2 -2
- package/src/unstable/httpapi/HttpApiClient.ts +11 -3
- package/src/unstable/httpapi/HttpApiEndpoint.ts +7 -7
- package/src/unstable/httpapi/HttpApiGroup.ts +6 -6
- package/src/unstable/httpapi/HttpApiMiddleware.ts +4 -4
- package/src/unstable/httpapi/HttpApiSecurity.ts +3 -3
- package/src/unstable/httpapi/OpenApi.ts +2 -2
- package/src/unstable/process/ChildProcess.ts +4 -206
- package/src/unstable/process/ChildProcessSpawner.ts +69 -14
- package/src/unstable/rpc/Rpc.ts +2 -2
- package/src/unstable/rpc/RpcGroup.ts +4 -4
- package/src/unstable/rpc/RpcMiddleware.ts +3 -3
- package/src/unstable/sql/SqlClient.ts +1 -1
- package/src/unstable/workflow/Workflow.ts +1 -1
|
@@ -89,8 +89,11 @@ import { HttpRequestDetails, HttpResponseDetails } from "./Response.ts"
|
|
|
89
89
|
|
|
90
90
|
const ReasonTypeId = "~effect/unstable/ai/AiError/Reason" as const
|
|
91
91
|
|
|
92
|
-
const
|
|
93
|
-
|
|
92
|
+
const providerMetadataWithDefaults = <Metadata extends ProviderMetadata>() =>
|
|
93
|
+
(ProviderMetadata as unknown as typeof ProviderMetadata & Schema.Schema<Metadata>).pipe(
|
|
94
|
+
Schema.withConstructorDefault(() => Option.some({} as Metadata)),
|
|
95
|
+
Schema.withDecodingDefault(() => ({} as Metadata))
|
|
96
|
+
)
|
|
94
97
|
|
|
95
98
|
const redactHeaders = (headers: Record<string, string>): Record<string, string> => {
|
|
96
99
|
const redacted = redact(headers) as Record<string, string | Redacted.Redacted>
|
|
@@ -258,6 +261,86 @@ export const ProviderMetadata: Schema.$Record<
|
|
|
258
261
|
*/
|
|
259
262
|
export type ProviderMetadata = typeof ProviderMetadata.Type
|
|
260
263
|
|
|
264
|
+
/**
|
|
265
|
+
* Provider-specific metadata attached to `RateLimitError`.
|
|
266
|
+
*
|
|
267
|
+
* @since 1.0.0
|
|
268
|
+
* @category provider options
|
|
269
|
+
*/
|
|
270
|
+
export interface RateLimitErrorMetadata extends ProviderMetadata {}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Provider-specific metadata attached to `QuotaExhaustedError`.
|
|
274
|
+
*
|
|
275
|
+
* @since 1.0.0
|
|
276
|
+
* @category provider options
|
|
277
|
+
*/
|
|
278
|
+
export interface QuotaExhaustedErrorMetadata extends ProviderMetadata {}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Provider-specific metadata attached to `AuthenticationError`.
|
|
282
|
+
*
|
|
283
|
+
* @since 1.0.0
|
|
284
|
+
* @category provider options
|
|
285
|
+
*/
|
|
286
|
+
export interface AuthenticationErrorMetadata extends ProviderMetadata {}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Provider-specific metadata attached to `ContentPolicyError`.
|
|
290
|
+
*
|
|
291
|
+
* @since 1.0.0
|
|
292
|
+
* @category provider options
|
|
293
|
+
*/
|
|
294
|
+
export interface ContentPolicyErrorMetadata extends ProviderMetadata {}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Provider-specific metadata attached to `InvalidRequestError`.
|
|
298
|
+
*
|
|
299
|
+
* @since 1.0.0
|
|
300
|
+
* @category provider options
|
|
301
|
+
*/
|
|
302
|
+
export interface InvalidRequestErrorMetadata extends ProviderMetadata {}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Provider-specific metadata attached to `InternalProviderError`.
|
|
306
|
+
*
|
|
307
|
+
* @since 1.0.0
|
|
308
|
+
* @category provider options
|
|
309
|
+
*/
|
|
310
|
+
export interface InternalProviderErrorMetadata extends ProviderMetadata {}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Provider-specific metadata attached to `InvalidOutputError`.
|
|
314
|
+
*
|
|
315
|
+
* @since 1.0.0
|
|
316
|
+
* @category provider options
|
|
317
|
+
*/
|
|
318
|
+
export interface InvalidOutputErrorMetadata extends ProviderMetadata {}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Provider-specific metadata attached to `StructuredOutputError`.
|
|
322
|
+
*
|
|
323
|
+
* @since 1.0.0
|
|
324
|
+
* @category provider options
|
|
325
|
+
*/
|
|
326
|
+
export interface StructuredOutputErrorMetadata extends ProviderMetadata {}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Provider-specific metadata attached to `UnsupportedSchemaError`.
|
|
330
|
+
*
|
|
331
|
+
* @since 1.0.0
|
|
332
|
+
* @category provider options
|
|
333
|
+
*/
|
|
334
|
+
export interface UnsupportedSchemaErrorMetadata extends ProviderMetadata {}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Provider-specific metadata attached to `UnknownError`.
|
|
338
|
+
*
|
|
339
|
+
* @since 1.0.0
|
|
340
|
+
* @category provider options
|
|
341
|
+
*/
|
|
342
|
+
export interface UnknownErrorMetadata extends ProviderMetadata {}
|
|
343
|
+
|
|
261
344
|
/**
|
|
262
345
|
* Token usage information from AI operations.
|
|
263
346
|
*
|
|
@@ -313,10 +396,7 @@ export class RateLimitError extends Schema.ErrorClass<RateLimitError>(
|
|
|
313
396
|
)({
|
|
314
397
|
_tag: Schema.tag("RateLimitError"),
|
|
315
398
|
retryAfter: Schema.optional(Schema.Duration),
|
|
316
|
-
metadata:
|
|
317
|
-
Schema.withConstructorDefault(constEmptyObjectOption),
|
|
318
|
-
Schema.withDecodingDefault(constEmptyObject)
|
|
319
|
-
),
|
|
399
|
+
metadata: providerMetadataWithDefaults<RateLimitErrorMetadata>(),
|
|
320
400
|
http: Schema.optional(HttpContext)
|
|
321
401
|
}) {
|
|
322
402
|
/**
|
|
@@ -364,10 +444,7 @@ export class QuotaExhaustedError extends Schema.ErrorClass<QuotaExhaustedError>(
|
|
|
364
444
|
)({
|
|
365
445
|
_tag: Schema.tag("QuotaExhaustedError"),
|
|
366
446
|
resetAt: Schema.optional(Schema.DateTimeUtc),
|
|
367
|
-
metadata:
|
|
368
|
-
Schema.withConstructorDefault(constEmptyObjectOption),
|
|
369
|
-
Schema.withDecodingDefault(constEmptyObject)
|
|
370
|
-
),
|
|
447
|
+
metadata: providerMetadataWithDefaults<QuotaExhaustedErrorMetadata>(),
|
|
371
448
|
http: Schema.optional(HttpContext)
|
|
372
449
|
}) {
|
|
373
450
|
/**
|
|
@@ -417,10 +494,7 @@ export class AuthenticationError extends Schema.ErrorClass<AuthenticationError>(
|
|
|
417
494
|
)({
|
|
418
495
|
_tag: Schema.tag("AuthenticationError"),
|
|
419
496
|
kind: Schema.Literals(["InvalidKey", "ExpiredKey", "MissingKey", "InsufficientPermissions", "Unknown"]),
|
|
420
|
-
metadata:
|
|
421
|
-
Schema.withConstructorDefault(constEmptyObjectOption),
|
|
422
|
-
Schema.withDecodingDefault(constEmptyObject)
|
|
423
|
-
),
|
|
497
|
+
metadata: providerMetadataWithDefaults<AuthenticationErrorMetadata>(),
|
|
424
498
|
http: Schema.optional(HttpContext)
|
|
425
499
|
}) {
|
|
426
500
|
/**
|
|
@@ -475,10 +549,7 @@ export class ContentPolicyError extends Schema.ErrorClass<ContentPolicyError>(
|
|
|
475
549
|
)({
|
|
476
550
|
_tag: Schema.tag("ContentPolicyError"),
|
|
477
551
|
description: Schema.String,
|
|
478
|
-
metadata:
|
|
479
|
-
Schema.withConstructorDefault(constEmptyObjectOption),
|
|
480
|
-
Schema.withDecodingDefault(constEmptyObject)
|
|
481
|
-
),
|
|
552
|
+
metadata: providerMetadataWithDefaults<ContentPolicyErrorMetadata>(),
|
|
482
553
|
http: Schema.optional(HttpContext)
|
|
483
554
|
}) {
|
|
484
555
|
/**
|
|
@@ -530,10 +601,7 @@ export class InvalidRequestError extends Schema.ErrorClass<InvalidRequestError>(
|
|
|
530
601
|
parameter: Schema.optional(Schema.String),
|
|
531
602
|
constraint: Schema.optional(Schema.String),
|
|
532
603
|
description: Schema.optional(Schema.String),
|
|
533
|
-
metadata:
|
|
534
|
-
Schema.withConstructorDefault(constEmptyObjectOption),
|
|
535
|
-
Schema.withDecodingDefault(constEmptyObject)
|
|
536
|
-
),
|
|
604
|
+
metadata: providerMetadataWithDefaults<InvalidRequestErrorMetadata>(),
|
|
537
605
|
http: Schema.optional(HttpContext)
|
|
538
606
|
}) {
|
|
539
607
|
/**
|
|
@@ -585,10 +653,7 @@ export class InternalProviderError extends Schema.ErrorClass<InternalProviderErr
|
|
|
585
653
|
)({
|
|
586
654
|
_tag: Schema.tag("InternalProviderError"),
|
|
587
655
|
description: Schema.String,
|
|
588
|
-
metadata:
|
|
589
|
-
Schema.withConstructorDefault(constEmptyObjectOption),
|
|
590
|
-
Schema.withDecodingDefault(constEmptyObject)
|
|
591
|
-
),
|
|
656
|
+
metadata: providerMetadataWithDefaults<InternalProviderErrorMetadata>(),
|
|
592
657
|
http: Schema.optional(HttpContext)
|
|
593
658
|
}) {
|
|
594
659
|
/**
|
|
@@ -636,10 +701,7 @@ export class InvalidOutputError extends Schema.ErrorClass<InvalidOutputError>(
|
|
|
636
701
|
)({
|
|
637
702
|
_tag: Schema.tag("InvalidOutputError"),
|
|
638
703
|
description: Schema.String,
|
|
639
|
-
metadata:
|
|
640
|
-
Schema.withConstructorDefault(constEmptyObjectOption),
|
|
641
|
-
Schema.withDecodingDefault(constEmptyObject)
|
|
642
|
-
),
|
|
704
|
+
metadata: providerMetadataWithDefaults<InvalidOutputErrorMetadata>(),
|
|
643
705
|
usage: Schema.optional(UsageInfo)
|
|
644
706
|
}) {
|
|
645
707
|
/**
|
|
@@ -710,10 +772,7 @@ export class StructuredOutputError extends Schema.ErrorClass<StructuredOutputErr
|
|
|
710
772
|
)({
|
|
711
773
|
_tag: Schema.tag("StructuredOutputError"),
|
|
712
774
|
description: Schema.String,
|
|
713
|
-
metadata:
|
|
714
|
-
Schema.withConstructorDefault(constEmptyObjectOption),
|
|
715
|
-
Schema.withDecodingDefault(constEmptyObject)
|
|
716
|
-
),
|
|
775
|
+
metadata: providerMetadataWithDefaults<StructuredOutputErrorMetadata>(),
|
|
717
776
|
usage: Schema.optional(UsageInfo)
|
|
718
777
|
}) {
|
|
719
778
|
/**
|
|
@@ -785,10 +844,7 @@ export class UnsupportedSchemaError extends Schema.ErrorClass<UnsupportedSchemaE
|
|
|
785
844
|
)({
|
|
786
845
|
_tag: Schema.tag("UnsupportedSchemaError"),
|
|
787
846
|
description: Schema.String,
|
|
788
|
-
metadata:
|
|
789
|
-
Schema.withConstructorDefault(constEmptyObjectOption),
|
|
790
|
-
Schema.withDecodingDefault(constEmptyObject)
|
|
791
|
-
)
|
|
847
|
+
metadata: providerMetadataWithDefaults<UnsupportedSchemaErrorMetadata>()
|
|
792
848
|
}) {
|
|
793
849
|
/**
|
|
794
850
|
* @since 1.0.0
|
|
@@ -835,10 +891,7 @@ export class UnknownError extends Schema.ErrorClass<UnknownError>(
|
|
|
835
891
|
)({
|
|
836
892
|
_tag: Schema.tag("UnknownError"),
|
|
837
893
|
description: Schema.optional(Schema.String),
|
|
838
|
-
metadata:
|
|
839
|
-
Schema.withConstructorDefault(constEmptyObjectOption),
|
|
840
|
-
Schema.withDecodingDefault(constEmptyObject)
|
|
841
|
-
),
|
|
894
|
+
metadata: providerMetadataWithDefaults<UnknownErrorMetadata>(),
|
|
842
895
|
http: Schema.optional(HttpContext)
|
|
843
896
|
}) {
|
|
844
897
|
/**
|
package/src/unstable/ai/Model.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* declare const myAnthropicLayer: Layer.Layer<LanguageModel.LanguageModel>
|
|
16
16
|
*
|
|
17
|
-
* const anthropicModel = Model.make("anthropic", myAnthropicLayer)
|
|
17
|
+
* const anthropicModel = Model.make("anthropic", "claude-3-5-haiku", myAnthropicLayer)
|
|
18
18
|
*
|
|
19
19
|
* const program = Effect.gen(function*() {
|
|
20
20
|
* const response = yield* LanguageModel.generateText({
|
|
@@ -55,8 +55,13 @@ const TypeId = "~effect/ai/Model" as const
|
|
|
55
55
|
*/
|
|
56
56
|
export interface Model<in out Provider, in out Provides, in out Requires>
|
|
57
57
|
extends
|
|
58
|
-
Layer.Layer<Provides | ProviderName, never, Requires>,
|
|
59
|
-
Effect.Yieldable<
|
|
58
|
+
Layer.Layer<Provides | ProviderName | ModelName, never, Requires>,
|
|
59
|
+
Effect.Yieldable<
|
|
60
|
+
Model<Provider, Provides, Requires>,
|
|
61
|
+
Layer.Layer<Provides | ProviderName | ModelName>,
|
|
62
|
+
never,
|
|
63
|
+
Requires
|
|
64
|
+
>
|
|
60
65
|
{
|
|
61
66
|
readonly [TypeId]: typeof TypeId
|
|
62
67
|
/**
|
|
@@ -79,6 +84,20 @@ export class ProviderName extends ServiceMap.Service<ProviderName, string>()(
|
|
|
79
84
|
"effect/unstable/ai/Model/ProviderName"
|
|
80
85
|
) {}
|
|
81
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Service tag that provides the current large language model name.
|
|
89
|
+
*
|
|
90
|
+
* This tag is automatically provided by Model instances and can be used to
|
|
91
|
+
* access the name of the model that is currently in use within a given Effect
|
|
92
|
+
* program.
|
|
93
|
+
*
|
|
94
|
+
* @since 4.0.0
|
|
95
|
+
* @category services
|
|
96
|
+
*/
|
|
97
|
+
export class ModelName extends ServiceMap.Service<ModelName, string>()(
|
|
98
|
+
"effect/unstable/ai/Model/ModelName"
|
|
99
|
+
) {}
|
|
100
|
+
|
|
82
101
|
const Proto = {
|
|
83
102
|
...YieldableProto,
|
|
84
103
|
...PipeInspectableProto,
|
|
@@ -112,11 +131,12 @@ const Proto = {
|
|
|
112
131
|
*
|
|
113
132
|
* declare const bedrockLayer: Layer.Layer<LanguageModel.LanguageModel>
|
|
114
133
|
*
|
|
115
|
-
* // Model automatically provides ProviderName
|
|
134
|
+
* // Model automatically provides ProviderName and ModelName services
|
|
116
135
|
* const checkProviderAndGenerate = Effect.gen(function*() {
|
|
117
136
|
* const provider = yield* Model.ProviderName
|
|
137
|
+
* const modelName = yield* Model.ModelName
|
|
118
138
|
*
|
|
119
|
-
* console.log(`Generating with: ${provider}`)
|
|
139
|
+
* console.log(`Generating with: ${provider}/${modelName}`)
|
|
120
140
|
*
|
|
121
141
|
* return yield* LanguageModel.generateText({
|
|
122
142
|
* prompt: `Hello from ${provider}!`
|
|
@@ -124,19 +144,23 @@ const Proto = {
|
|
|
124
144
|
* })
|
|
125
145
|
*
|
|
126
146
|
* const program = checkProviderAndGenerate.pipe(
|
|
127
|
-
* Effect.provide(Model.make("amazon-bedrock", bedrockLayer))
|
|
147
|
+
* Effect.provide(Model.make("amazon-bedrock", "claude-3-5-haiku", bedrockLayer))
|
|
128
148
|
* )
|
|
129
|
-
* // Will log: "Generating with: amazon-bedrock"
|
|
149
|
+
* // Will log: "Generating with: amazon-bedrock/claude-3-5-haiku"
|
|
130
150
|
* ```
|
|
131
151
|
*
|
|
132
152
|
* @since 4.0.0
|
|
133
153
|
* @category constructors
|
|
134
154
|
*/
|
|
135
|
-
export const make = <const Provider extends string, Provides, Requires>(
|
|
155
|
+
export const make = <const Provider extends string, const Name extends string, Provides, Requires>(
|
|
136
156
|
/**
|
|
137
157
|
* Provider identifier (e.g., "openai", "anthropic", "amazon-bedrock").
|
|
138
158
|
*/
|
|
139
159
|
provider: Provider,
|
|
160
|
+
/**
|
|
161
|
+
* Model identifier (e.g., "gpt-5", "claude-3-5-haiku").
|
|
162
|
+
*/
|
|
163
|
+
modelName: Name,
|
|
140
164
|
/**
|
|
141
165
|
* Layer that provides the AI services for this provider.
|
|
142
166
|
*/
|
|
@@ -145,5 +169,12 @@ export const make = <const Provider extends string, Provides, Requires>(
|
|
|
145
169
|
Object.assign(
|
|
146
170
|
Object.create(Proto),
|
|
147
171
|
{ provider },
|
|
148
|
-
Layer.merge(
|
|
172
|
+
Layer.merge(
|
|
173
|
+
layer,
|
|
174
|
+
Layer.succeedServices(
|
|
175
|
+
ProviderName.serviceMap(provider).pipe(
|
|
176
|
+
ServiceMap.add(ModelName, modelName)
|
|
177
|
+
)
|
|
178
|
+
)
|
|
179
|
+
)
|
|
149
180
|
)
|
package/src/unstable/ai/Tool.ts
CHANGED
|
@@ -257,7 +257,7 @@ export interface Tool<
|
|
|
257
257
|
* instead of being provided when creating the tool call handler layer.
|
|
258
258
|
*/
|
|
259
259
|
addDependency<Identifier, Service>(
|
|
260
|
-
tag: ServiceMap.
|
|
260
|
+
tag: ServiceMap.Key<Identifier, Service>
|
|
261
261
|
): Tool<Name, Config, Identifier | Requirements>
|
|
262
262
|
|
|
263
263
|
/**
|
|
@@ -311,7 +311,7 @@ export interface Tool<
|
|
|
311
311
|
/**
|
|
312
312
|
* Add an annotation to the tool.
|
|
313
313
|
*/
|
|
314
|
-
annotate<I, S>(tag: ServiceMap.
|
|
314
|
+
annotate<I, S>(tag: ServiceMap.Key<I, S>, value: S): Tool<Name, Config, Requirements>
|
|
315
315
|
|
|
316
316
|
/**
|
|
317
317
|
* Add many annotations to the tool.
|
|
@@ -1006,7 +1006,7 @@ const Proto = {
|
|
|
1006
1006
|
setFailure(this: Any, failureSchema: Schema.Top) {
|
|
1007
1007
|
return userDefinedProto({ ...this, failureSchema })
|
|
1008
1008
|
},
|
|
1009
|
-
annotate<I, S>(this: Any, tag: ServiceMap.
|
|
1009
|
+
annotate<I, S>(this: Any, tag: ServiceMap.Key<I, S>, value: S) {
|
|
1010
1010
|
return userDefinedProto({
|
|
1011
1011
|
...this,
|
|
1012
1012
|
annotations: ServiceMap.add(this.annotations, tag, value)
|
|
@@ -1150,7 +1150,7 @@ export const make = <
|
|
|
1150
1150
|
Success extends Schema.Top = typeof Schema.Void,
|
|
1151
1151
|
Failure extends Schema.Top = typeof Schema.Never,
|
|
1152
1152
|
Mode extends FailureMode | undefined = undefined,
|
|
1153
|
-
Dependencies extends Array<ServiceMap.
|
|
1153
|
+
Dependencies extends Array<ServiceMap.Key<any, any> | ServiceMap.Key<never, any>> = []
|
|
1154
1154
|
>(name: Name, options?: {
|
|
1155
1155
|
/**
|
|
1156
1156
|
* An optional description explaining what the tool does.
|
package/src/unstable/ai/index.ts
CHANGED
|
@@ -280,7 +280,7 @@ export * as McpServer from "./McpServer.ts"
|
|
|
280
280
|
*
|
|
281
281
|
* declare const myAnthropicLayer: Layer.Layer<LanguageModel.LanguageModel>
|
|
282
282
|
*
|
|
283
|
-
* const anthropicModel = Model.make("anthropic", myAnthropicLayer)
|
|
283
|
+
* const anthropicModel = Model.make("anthropic", "claude-3-5-haiku", myAnthropicLayer)
|
|
284
284
|
*
|
|
285
285
|
* const program = Effect.gen(function*() {
|
|
286
286
|
* const response = yield* LanguageModel.generateText({
|
|
@@ -1177,7 +1177,7 @@ export const annotate: {
|
|
|
1177
1177
|
* @since 4.0.0
|
|
1178
1178
|
* @category combinators
|
|
1179
1179
|
*/
|
|
1180
|
-
<I, S>(service: ServiceMap.
|
|
1180
|
+
<I, S>(service: ServiceMap.Key<I, S>, value: NoInfer<S>): <Name extends string, Input, E, R>(
|
|
1181
1181
|
self: Command<Name, Input, E, R>
|
|
1182
1182
|
) => Command<Name, Input, E, R>
|
|
1183
1183
|
/**
|
|
@@ -1188,12 +1188,12 @@ export const annotate: {
|
|
|
1188
1188
|
*/
|
|
1189
1189
|
<Name extends string, Input, E, R, I, S>(
|
|
1190
1190
|
self: Command<Name, Input, E, R>,
|
|
1191
|
-
service: ServiceMap.
|
|
1191
|
+
service: ServiceMap.Key<I, S>,
|
|
1192
1192
|
value: NoInfer<S>
|
|
1193
1193
|
): Command<Name, Input, E, R>
|
|
1194
1194
|
} = dual(3, <Name extends string, Input, E, R, I, S>(
|
|
1195
1195
|
self: Command<Name, Input, E, R>,
|
|
1196
|
-
service: ServiceMap.
|
|
1196
|
+
service: ServiceMap.Key<I, S>,
|
|
1197
1197
|
value: NoInfer<S>
|
|
1198
1198
|
) => {
|
|
1199
1199
|
const impl = toImpl(self)
|
|
@@ -1466,10 +1466,7 @@ export const provideSync: {
|
|
|
1466
1466
|
* @since 4.0.0
|
|
1467
1467
|
* @category providing services
|
|
1468
1468
|
*/
|
|
1469
|
-
<I, S, Input>(
|
|
1470
|
-
service: ServiceMap.Service<I, S>,
|
|
1471
|
-
implementation: S | ((input: Input) => S)
|
|
1472
|
-
): <const Name extends string, E, R>(
|
|
1469
|
+
<I, S, Input>(service: ServiceMap.Key<I, S>, implementation: S | ((input: Input) => S)): <const Name extends string, E, R>(
|
|
1473
1470
|
self: Command<Name, Input, E, R>
|
|
1474
1471
|
) => Command<Name, Input, E, Exclude<R, I>>
|
|
1475
1472
|
/**
|
|
@@ -1481,12 +1478,12 @@ export const provideSync: {
|
|
|
1481
1478
|
*/
|
|
1482
1479
|
<const Name extends string, Input, E, R, I, S>(
|
|
1483
1480
|
self: Command<Name, Input, E, R>,
|
|
1484
|
-
service: ServiceMap.
|
|
1481
|
+
service: ServiceMap.Key<I, S>,
|
|
1485
1482
|
implementation: S | ((input: Input) => S)
|
|
1486
1483
|
): Command<Name, Input, E, Exclude<R, I>>
|
|
1487
1484
|
} = dual(3, <const Name extends string, Input, E, R, I, S>(
|
|
1488
1485
|
self: Command<Name, Input, E, R>,
|
|
1489
|
-
service: ServiceMap.
|
|
1486
|
+
service: ServiceMap.Key<I, S>,
|
|
1490
1487
|
implementation: S | ((input: Input) => S)
|
|
1491
1488
|
) =>
|
|
1492
1489
|
mapHandler(self, (handler, input) =>
|
|
@@ -1512,7 +1509,7 @@ export const provideEffect: {
|
|
|
1512
1509
|
* @category providing services
|
|
1513
1510
|
*/
|
|
1514
1511
|
<I, S, Input, R2, E2>(
|
|
1515
|
-
service: ServiceMap.
|
|
1512
|
+
service: ServiceMap.Key<I, S>,
|
|
1516
1513
|
effect: Effect.Effect<S, E2, R2> | ((input: Input) => Effect.Effect<S, E2, R2>)
|
|
1517
1514
|
): <const Name extends string, E, R>(
|
|
1518
1515
|
self: Command<Name, Input, E, R>
|
|
@@ -1526,12 +1523,12 @@ export const provideEffect: {
|
|
|
1526
1523
|
*/
|
|
1527
1524
|
<const Name extends string, Input, E, R, I, S, R2, E2>(
|
|
1528
1525
|
self: Command<Name, Input, E, R>,
|
|
1529
|
-
service: ServiceMap.
|
|
1526
|
+
service: ServiceMap.Key<I, S>,
|
|
1530
1527
|
effect: Effect.Effect<S, E2, R2> | ((input: Input) => Effect.Effect<S, E2, R2>)
|
|
1531
1528
|
): Command<Name, Input, E | E2, Exclude<R, I> | R2>
|
|
1532
1529
|
} = dual(3, <const Name extends string, Input, E, R, I, S, R2, E2>(
|
|
1533
1530
|
self: Command<Name, Input, E, R>,
|
|
1534
|
-
service: ServiceMap.
|
|
1531
|
+
service: ServiceMap.Key<I, S>,
|
|
1535
1532
|
effect: Effect.Effect<S, E2, R2> | ((input: Input) => Effect.Effect<S, E2, R2>)
|
|
1536
1533
|
) =>
|
|
1537
1534
|
mapHandler(
|
|
@@ -35,7 +35,7 @@ interface SubcommandGroup {
|
|
|
35
35
|
*/
|
|
36
36
|
export interface CommandInternal<Name extends string, Input, E, R> extends Command<Name, Input, E, R> {
|
|
37
37
|
readonly config: ConfigInternal
|
|
38
|
-
readonly service: ServiceMap.
|
|
38
|
+
readonly service: ServiceMap.Key<CommandContext<Name>, Input>
|
|
39
39
|
readonly annotations: ServiceMap.ServiceMap<never>
|
|
40
40
|
readonly globalFlags: ReadonlyArray<GlobalFlag.GlobalFlag<any>>
|
|
41
41
|
readonly parse: (input: ParsedTokens) => Effect.Effect<Input, CliError.CliError, Environment>
|
|
@@ -88,7 +88,7 @@ export const Proto = {
|
|
|
88
88
|
export const makeCommand = <const Name extends string, Input, E, R>(options: {
|
|
89
89
|
readonly name: Name
|
|
90
90
|
readonly config: ConfigInternal
|
|
91
|
-
readonly service?: ServiceMap.
|
|
91
|
+
readonly service?: ServiceMap.Key<CommandContext<Name>, Input> | undefined
|
|
92
92
|
readonly annotations?: ServiceMap.ServiceMap<never> | undefined
|
|
93
93
|
readonly globalFlags?: ReadonlyArray<GlobalFlag.GlobalFlag<any>> | undefined
|
|
94
94
|
readonly description?: string | undefined
|
|
@@ -75,12 +75,12 @@ export interface Entity<
|
|
|
75
75
|
/**
|
|
76
76
|
* Annotate the entity with a value.
|
|
77
77
|
*/
|
|
78
|
-
annotate<I, S>(key: ServiceMap.
|
|
78
|
+
annotate<I, S>(key: ServiceMap.Key<I, S>, value: S): Entity<Type, Rpcs>
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* Annotate the Rpc's above this point with a value.
|
|
82
82
|
*/
|
|
83
|
-
annotateRpcs<I, S>(key: ServiceMap.
|
|
83
|
+
annotateRpcs<I, S>(key: ServiceMap.Key<I, S>, value: S): Entity<Type, Rpcs>
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
86
|
* Annotate the entity with the given annotations.
|
|
@@ -207,10 +207,10 @@ const Proto = {
|
|
|
207
207
|
[Equal.symbol](this: Entity<string, any>, that: Equal.Equal): boolean {
|
|
208
208
|
return isEntity(that) && this.type === that.type
|
|
209
209
|
},
|
|
210
|
-
annotate<I, S>(this: Entity<string, any>, key: ServiceMap.
|
|
210
|
+
annotate<I, S>(this: Entity<string, any>, key: ServiceMap.Key<I, S>, value: S) {
|
|
211
211
|
return fromRpcGroup(this.type, this.protocol.annotate(key, value))
|
|
212
212
|
},
|
|
213
|
-
annotateRpcs<I, S>(this: Entity<string, any>, key: ServiceMap.
|
|
213
|
+
annotateRpcs<I, S>(this: Entity<string, any>, key: ServiceMap.Key<I, S>, value: S) {
|
|
214
214
|
return fromRpcGroup(this.type, this.protocol.annotateRpcs(key, value))
|
|
215
215
|
},
|
|
216
216
|
annotateMerge<S>(this: Entity<string, any>, annotations: ServiceMap.ServiceMap<S>) {
|
|
@@ -170,11 +170,11 @@ export const layerDefaults: Layer.Layer<ShardingConfig> = layer()
|
|
|
170
170
|
export const config: Config.Config<ShardingConfig["Service"]> = Config.all({
|
|
171
171
|
runnerAddress: Config.all({
|
|
172
172
|
host: Config.string("host").pipe(
|
|
173
|
-
Config.withDefault(
|
|
173
|
+
Config.withDefault(defaultRunnerAddress.host)
|
|
174
174
|
// Config.withDescription("The hostname or IP address of the runner.")
|
|
175
175
|
),
|
|
176
176
|
port: Config.int("port").pipe(
|
|
177
|
-
Config.withDefault(
|
|
177
|
+
Config.withDefault(defaultRunnerAddress.port)
|
|
178
178
|
// Config.withDescription("The port used for inter-runner communication.")
|
|
179
179
|
)
|
|
180
180
|
}).pipe(Config.map((options) => RunnerAddress.makeUnsafe(options)), Config.option, Config.map(Option.getOrUndefined)),
|
|
@@ -182,79 +182,79 @@ export const config: Config.Config<ShardingConfig["Service"]> = Config.all({
|
|
|
182
182
|
host: Config.string("listenHost"),
|
|
183
183
|
// Config.withDescription("The host to listen on.")
|
|
184
184
|
port: Config.int("listenPort").pipe(
|
|
185
|
-
Config.withDefault(
|
|
185
|
+
Config.withDefault(defaultRunnerAddress.port)
|
|
186
186
|
// Config.withDescription("The port to listen on.")
|
|
187
187
|
)
|
|
188
188
|
}).pipe(Config.map((options) => RunnerAddress.makeUnsafe(options)), Config.option, Config.map(Option.getOrUndefined)),
|
|
189
189
|
runnerShardWeight: Config.int("runnerShardWeight").pipe(
|
|
190
|
-
Config.withDefault(
|
|
190
|
+
Config.withDefault(defaults.runnerShardWeight)
|
|
191
191
|
// Config.withDescription("A number that determines how many shards this runner will be assigned relative to other runners.")
|
|
192
192
|
),
|
|
193
193
|
shardGroups: Config.schema(Schema.Array(Schema.String), "shardGroups").pipe(
|
|
194
|
-
Config.withDefault(
|
|
194
|
+
Config.withDefault(["default"])
|
|
195
195
|
// Config.withDescription("The shard groups that are assigned to this runner.")
|
|
196
196
|
),
|
|
197
197
|
shardsPerGroup: Config.int("shardsPerGroup").pipe(
|
|
198
|
-
Config.withDefault(
|
|
198
|
+
Config.withDefault(defaults.shardsPerGroup)
|
|
199
199
|
// Config.withDescription("The number of shards to allocate per shard group.")
|
|
200
200
|
),
|
|
201
201
|
shardLockRefreshInterval: Config.duration("shardLockRefreshInterval").pipe(
|
|
202
|
-
Config.withDefault(
|
|
202
|
+
Config.withDefault(defaults.shardLockRefreshInterval)
|
|
203
203
|
// Config.withDescription("Shard lock refresh interval.")
|
|
204
204
|
),
|
|
205
205
|
shardLockExpiration: Config.duration("shardLockExpiration").pipe(
|
|
206
|
-
Config.withDefault(
|
|
206
|
+
Config.withDefault(defaults.shardLockExpiration)
|
|
207
207
|
// Config.withDescription("Shard lock expiration duration.")
|
|
208
208
|
),
|
|
209
209
|
shardLockDisableAdvisory: Config.boolean("shardLockDisableAdvisory").pipe(
|
|
210
|
-
Config.withDefault(
|
|
210
|
+
Config.withDefault(defaults.shardLockDisableAdvisory)
|
|
211
211
|
// Config.withDescription("Disable the use of advisory locks for shard locking.")
|
|
212
212
|
),
|
|
213
213
|
preemptiveShutdown: Config.boolean("preemptiveShutdown").pipe(
|
|
214
|
-
Config.withDefault(
|
|
214
|
+
Config.withDefault(defaults.preemptiveShutdown)
|
|
215
215
|
// Config.withDescription("Start shutting down as soon as an Entity has started shutting down.")
|
|
216
216
|
),
|
|
217
217
|
entityMailboxCapacity: Config.int("entityMailboxCapacity").pipe(
|
|
218
|
-
Config.withDefault(
|
|
218
|
+
Config.withDefault(defaults.entityMailboxCapacity)
|
|
219
219
|
// Config.withDescription("The default capacity of the mailbox for entities.")
|
|
220
220
|
),
|
|
221
221
|
entityMaxIdleTime: Config.duration("entityMaxIdleTime").pipe(
|
|
222
|
-
Config.withDefault(
|
|
222
|
+
Config.withDefault(defaults.entityMaxIdleTime)
|
|
223
223
|
// Config.withDescription(
|
|
224
224
|
// "The maximum duration of inactivity (i.e. without receiving a message) after which an entity will be interrupted."
|
|
225
225
|
// )
|
|
226
226
|
),
|
|
227
227
|
entityRegistrationTimeout: Config.duration("entityRegistrationTimeout").pipe(
|
|
228
|
-
Config.withDefault(
|
|
228
|
+
Config.withDefault(defaults.entityRegistrationTimeout)
|
|
229
229
|
// Config.withDescription("If an entity does not register itself within this time after a message is sent to it, the message will be marked as failed.")
|
|
230
230
|
),
|
|
231
231
|
entityTerminationTimeout: Config.duration("entityTerminationTimeout").pipe(
|
|
232
|
-
Config.withDefault(
|
|
232
|
+
Config.withDefault(defaults.entityTerminationTimeout)
|
|
233
233
|
// Config.withDescription("The maximum duration of time to wait for an entity to terminate.")
|
|
234
234
|
),
|
|
235
235
|
entityMessagePollInterval: Config.duration("entityMessagePollInterval").pipe(
|
|
236
|
-
Config.withDefault(
|
|
236
|
+
Config.withDefault(defaults.entityMessagePollInterval)
|
|
237
237
|
// Config.withDescription("The interval at which to poll for unprocessed messages from storage.")
|
|
238
238
|
),
|
|
239
239
|
entityReplyPollInterval: Config.duration("entityReplyPollInterval").pipe(
|
|
240
|
-
Config.withDefault(
|
|
240
|
+
Config.withDefault(defaults.entityReplyPollInterval)
|
|
241
241
|
// Config.withDescription("The interval at which to poll for client replies from storage.")
|
|
242
242
|
),
|
|
243
243
|
sendRetryInterval: Config.duration("sendRetryInterval").pipe(
|
|
244
|
-
Config.withDefault(
|
|
244
|
+
Config.withDefault(defaults.sendRetryInterval)
|
|
245
245
|
// Config.withDescription("The interval to retry a send if EntityNotManagedByRunner is returned.")
|
|
246
246
|
),
|
|
247
247
|
refreshAssignmentsInterval: Config.duration("refreshAssignmentsInterval").pipe(
|
|
248
|
-
Config.withDefault(
|
|
248
|
+
Config.withDefault(defaults.refreshAssignmentsInterval)
|
|
249
249
|
// Config.withDescription("The interval at which to refresh shard assignments.")
|
|
250
250
|
),
|
|
251
251
|
runnerHealthCheckInterval: Config.duration("runnerHealthCheckInterval").pipe(
|
|
252
|
-
Config.withDefault(
|
|
252
|
+
Config.withDefault(defaults.runnerHealthCheckInterval)
|
|
253
253
|
// Config.withDescription("The interval at which to check for unhealthy runners and report them.")
|
|
254
254
|
),
|
|
255
255
|
// unhealthyRunnerReportInterval: Config.duration("unhealthyRunnerReportInterval").pipe(
|
|
256
256
|
simulateRemoteSerialization: Config.boolean("simulateRemoteSerialization").pipe(
|
|
257
|
-
Config.withDefault(
|
|
257
|
+
Config.withDefault(defaults.simulateRemoteSerialization)
|
|
258
258
|
// Config.withDescription("Simulate serialization and deserialization to remote runners for local entities.")
|
|
259
259
|
)
|
|
260
260
|
})
|
|
@@ -67,13 +67,13 @@ export interface HttpApi<
|
|
|
67
67
|
* api is called.
|
|
68
68
|
*/
|
|
69
69
|
middleware<I extends HttpApiMiddleware.AnyId, S>(
|
|
70
|
-
middleware: ServiceMap.
|
|
70
|
+
middleware: ServiceMap.Key<I, S>
|
|
71
71
|
): HttpApi<Id, HttpApiGroup.AddMiddleware<Groups, I>>
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* Annotate the `HttpApi`.
|
|
75
75
|
*/
|
|
76
|
-
annotate<I, S>(tag: ServiceMap.
|
|
76
|
+
annotate<I, S>(tag: ServiceMap.Key<I, S>, value: S): HttpApi<Id, Groups>
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
79
|
* Annotate the `HttpApi` with a ServiceMap.
|
|
@@ -137,14 +137,14 @@ const Proto = {
|
|
|
137
137
|
annotations: this.annotations
|
|
138
138
|
})
|
|
139
139
|
},
|
|
140
|
-
middleware(this: AnyWithProps, tag: HttpApiMiddleware.
|
|
140
|
+
middleware(this: AnyWithProps, tag: HttpApiMiddleware.AnyService) {
|
|
141
141
|
return makeProto({
|
|
142
142
|
identifier: this.identifier,
|
|
143
143
|
groups: Record.map(this.groups, (group) => group.middleware(tag as any)),
|
|
144
144
|
annotations: this.annotations
|
|
145
145
|
})
|
|
146
146
|
},
|
|
147
|
-
annotate(this: AnyWithProps, key: ServiceMap.
|
|
147
|
+
annotate(this: AnyWithProps, key: ServiceMap.Key<any, any>, value: any) {
|
|
148
148
|
return makeProto({
|
|
149
149
|
identifier: this.identifier,
|
|
150
150
|
groups: this.groups,
|
|
@@ -212,7 +212,7 @@ export const reflect = <Id extends string, Groups extends HttpApiGroup.Any>(
|
|
|
212
212
|
readonly group: HttpApiGroup.AnyWithProps
|
|
213
213
|
readonly endpoint: HttpApiEndpoint.AnyWithProps
|
|
214
214
|
readonly mergedAnnotations: ServiceMap.ServiceMap<never>
|
|
215
|
-
readonly middleware: ReadonlySet<HttpApiMiddleware.
|
|
215
|
+
readonly middleware: ReadonlySet<HttpApiMiddleware.AnyService>
|
|
216
216
|
readonly successes: ReadonlyMap<number, readonly [Schema.Top, ...Array<Schema.Top>]>
|
|
217
217
|
readonly errors: ReadonlyMap<number, readonly [Schema.Top, ...Array<Schema.Top>]>
|
|
218
218
|
}) => void
|
|
@@ -641,7 +641,7 @@ const applyMiddleware = <A extends Effect.Effect<any, any, any>>(
|
|
|
641
641
|
) => {
|
|
642
642
|
const options = { group, endpoint }
|
|
643
643
|
for (const key_ of endpoint.middlewares) {
|
|
644
|
-
const key = key_ as any as HttpApiMiddleware.
|
|
644
|
+
const key = key_ as any as HttpApiMiddleware.AnyService
|
|
645
645
|
const service = services.mapUnsafe.get(key_.key) as HttpApiMiddleware.HttpApiMiddleware<any, any, any>
|
|
646
646
|
const apply = HttpApiMiddleware.isSecurity(key)
|
|
647
647
|
? makeSecurityMiddleware(key, service as any)
|
|
@@ -657,7 +657,7 @@ const securityMiddlewareCache = new WeakMap<
|
|
|
657
657
|
>()
|
|
658
658
|
|
|
659
659
|
const makeSecurityMiddleware = (
|
|
660
|
-
key: HttpApiMiddleware.
|
|
660
|
+
key: HttpApiMiddleware.AnyServiceSecurity,
|
|
661
661
|
service: HttpApiMiddleware.HttpApiMiddlewareSecurity<any, any, any, any>
|
|
662
662
|
): (effect: Effect.Effect<any, any, any>, options: any) => Effect.Effect<any, any, any> => {
|
|
663
663
|
if (securityMiddlewareCache.has(key)) {
|