effect 4.0.0-beta.30 → 4.0.0-beta.31
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 +2 -2
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js.map +1 -1
- package/dist/Cron.js +3 -3
- package/dist/Cron.js.map +1 -1
- package/dist/DateTime.d.ts +33 -77
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +1 -1
- package/dist/DateTime.js.map +1 -1
- package/dist/Duration.d.ts +29 -1
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +77 -48
- package/dist/Duration.js.map +1 -1
- package/dist/Layer.d.ts +97 -2
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +8 -2
- package/dist/Layer.js.map +1 -1
- package/dist/Schema.d.ts +2316 -114
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +1331 -67
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +2 -2
- package/dist/SchemaAST.js +2 -2
- package/dist/SchemaRepresentation.d.ts +2 -2
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/internal/dateTime.js +57 -50
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +1 -1
- package/dist/internal/effect.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +3 -4
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +30 -16
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +10 -87
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/cli/Completions.d.ts +16 -0
- package/dist/unstable/cli/Completions.d.ts.map +1 -0
- package/dist/unstable/cli/Completions.js +23 -0
- package/dist/unstable/cli/Completions.js.map +1 -0
- package/dist/unstable/cli/GlobalFlag.d.ts.map +1 -1
- package/dist/unstable/cli/GlobalFlag.js +4 -4
- package/dist/unstable/cli/GlobalFlag.js.map +1 -1
- package/dist/unstable/cli/index.d.ts +4 -0
- package/dist/unstable/cli/index.d.ts.map +1 -1
- package/dist/unstable/cli/index.js +4 -0
- package/dist/unstable/cli/index.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/DeliverAt.js +1 -1
- package/dist/unstable/cluster/DeliverAt.js.map +1 -1
- package/dist/unstable/encoding/Ndjson.d.ts +8 -8
- package/dist/unstable/encoding/Ndjson.d.ts.map +1 -1
- package/dist/unstable/encoding/Ndjson.js.map +1 -1
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +2 -2
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistable.js +1 -1
- package/dist/unstable/persistence/Persistable.js.map +1 -1
- package/dist/unstable/rpc/RpcGroup.d.ts +1 -3
- package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Channel.ts +3 -3
- package/src/Cron.ts +3 -3
- package/src/DateTime.ts +35 -77
- package/src/Duration.ts +78 -23
- package/src/Layer.ts +123 -19
- package/src/Schema.ts +2317 -115
- package/src/SchemaAST.ts +2 -2
- package/src/SchemaRepresentation.ts +2 -2
- package/src/internal/dateTime.ts +60 -51
- package/src/internal/effect.ts +1 -1
- package/src/unstable/ai/Chat.ts +11 -13
- package/src/unstable/ai/LanguageModel.ts +148 -97
- package/src/unstable/cli/Completions.ts +36 -0
- package/src/unstable/cli/GlobalFlag.ts +4 -5
- package/src/unstable/cli/index.ts +5 -0
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +1 -1
- package/src/unstable/cluster/DeliverAt.ts +1 -1
- package/src/unstable/encoding/Ndjson.ts +17 -17
- package/src/unstable/http/HttpClientResponse.ts +2 -2
- package/src/unstable/http/HttpIncomingMessage.ts +1 -1
- package/src/unstable/http/HttpServerRequest.ts +4 -4
- package/src/unstable/http/HttpServerResponse.ts +2 -2
- package/src/unstable/httpapi/HttpApiBuilder.ts +4 -4
- package/src/unstable/persistence/Persistable.ts +1 -1
- package/src/unstable/rpc/RpcGroup.ts +3 -3
- package/dist/unstable/cli/internal/completions/Completions.d.ts +0 -2
- package/dist/unstable/cli/internal/completions/Completions.d.ts.map +0 -1
- package/dist/unstable/cli/internal/completions/Completions.js +0 -23
- package/dist/unstable/cli/internal/completions/Completions.js.map +0 -1
- package/src/unstable/cli/internal/completions/Completions.ts +0 -31
|
@@ -205,15 +205,7 @@ export interface GenerateTextOptions<Tools extends Record<string, Tool.Any>> {
|
|
|
205
205
|
* A toolkit containing both the tools and the tool call handler to use to
|
|
206
206
|
* augment text generation.
|
|
207
207
|
*/
|
|
208
|
-
readonly toolkit?:
|
|
209
|
-
| Toolkit.WithHandler<Tools>
|
|
210
|
-
| Effect.Yieldable<
|
|
211
|
-
Toolkit.Toolkit<Tools>,
|
|
212
|
-
Toolkit.WithHandler<Tools>,
|
|
213
|
-
never,
|
|
214
|
-
any
|
|
215
|
-
>
|
|
216
|
-
| undefined
|
|
208
|
+
readonly toolkit?: ToolkitOption<Tools> | undefined
|
|
217
209
|
|
|
218
210
|
/**
|
|
219
211
|
* The tool choice mode for the language model.
|
|
@@ -467,6 +459,89 @@ export class GenerateObjectResponse<
|
|
|
467
459
|
// Utility Types
|
|
468
460
|
// =============================================================================
|
|
469
461
|
|
|
462
|
+
/**
|
|
463
|
+
* The supported toolkit option shapes for language model operations.
|
|
464
|
+
*
|
|
465
|
+
* @since 4.0.0
|
|
466
|
+
* @category utility types
|
|
467
|
+
*/
|
|
468
|
+
export type ToolkitOption<
|
|
469
|
+
Tools extends Record<string, Tool.Any>,
|
|
470
|
+
E = never,
|
|
471
|
+
R = any
|
|
472
|
+
> = Tools extends any ? (
|
|
473
|
+
| Toolkit.WithHandler<Tools>
|
|
474
|
+
| Effect.Yieldable<
|
|
475
|
+
Toolkit.Toolkit<Tools>,
|
|
476
|
+
Toolkit.WithHandler<Tools>,
|
|
477
|
+
E,
|
|
478
|
+
R
|
|
479
|
+
>
|
|
480
|
+
)
|
|
481
|
+
: never
|
|
482
|
+
|
|
483
|
+
type ExtractToolsFromToolkitOption<ToolkitValue> = ToolkitValue extends Toolkit.WithHandler<infer Tools> ? Tools
|
|
484
|
+
: ToolkitValue extends Effect.Yieldable<
|
|
485
|
+
Toolkit.Toolkit<infer Tools>,
|
|
486
|
+
Toolkit.WithHandler<infer _Tools>,
|
|
487
|
+
infer _E,
|
|
488
|
+
infer _R
|
|
489
|
+
> ? Tools
|
|
490
|
+
: never
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Utility type that extracts the toolset from LanguageModel options.
|
|
494
|
+
*
|
|
495
|
+
* @since 4.0.0
|
|
496
|
+
* @category utility types
|
|
497
|
+
*/
|
|
498
|
+
export type ExtractTools<Options> = Options extends {
|
|
499
|
+
readonly toolkit: infer ToolkitValue
|
|
500
|
+
} ? ExtractToolsFromToolkitOption<Exclude<ToolkitValue, undefined>>
|
|
501
|
+
: {}
|
|
502
|
+
|
|
503
|
+
type ExtractErrorFromToolkitOption<ToolkitValue, DisableToolCallResolution extends boolean> = ToolkitValue extends
|
|
504
|
+
Toolkit.WithHandler<infer Tools> ?
|
|
505
|
+
| AiError.AiError
|
|
506
|
+
| (DisableToolCallResolution extends true ? never : Tool.HandlerError<Tools[keyof Tools]>)
|
|
507
|
+
: ToolkitValue extends Effect.Yieldable<
|
|
508
|
+
Toolkit.Toolkit<infer Tools>,
|
|
509
|
+
Toolkit.WithHandler<infer _Tools>,
|
|
510
|
+
infer E,
|
|
511
|
+
infer _R
|
|
512
|
+
> ? AiError.AiError | E | (DisableToolCallResolution extends true ? never : Tool.HandlerError<Tools[keyof Tools]>)
|
|
513
|
+
: AiError.AiError
|
|
514
|
+
|
|
515
|
+
type ExtractServicesFromToolkitOption<ToolkitValue> = ToolkitValue extends Toolkit.WithHandler<infer Tools> ?
|
|
516
|
+
| Tool.HandlerServices<Tools[keyof Tools]>
|
|
517
|
+
| Tool.ResultDecodingServices<Tools[keyof Tools]>
|
|
518
|
+
: ToolkitValue extends Effect.Yieldable<
|
|
519
|
+
Toolkit.Toolkit<infer Tools>,
|
|
520
|
+
Toolkit.WithHandler<infer _Tools>,
|
|
521
|
+
infer _E,
|
|
522
|
+
infer R
|
|
523
|
+
> ?
|
|
524
|
+
| Tool.HandlerServices<Tools[keyof Tools]>
|
|
525
|
+
| Tool.ResultDecodingServices<Tools[keyof Tools]>
|
|
526
|
+
| R
|
|
527
|
+
: never
|
|
528
|
+
|
|
529
|
+
type ExtractToolkitResolutionError<ToolkitValue> = ToolkitValue extends Effect.Yieldable<
|
|
530
|
+
Toolkit.Toolkit<infer _Tools>,
|
|
531
|
+
Toolkit.WithHandler<infer _Tools>,
|
|
532
|
+
infer E,
|
|
533
|
+
infer _R
|
|
534
|
+
> ? E
|
|
535
|
+
: never
|
|
536
|
+
|
|
537
|
+
type ExtractToolkitResolutionServices<ToolkitValue> = ToolkitValue extends Effect.Yieldable<
|
|
538
|
+
Toolkit.Toolkit<infer _Tools>,
|
|
539
|
+
Toolkit.WithHandler<infer _Tools>,
|
|
540
|
+
infer _E,
|
|
541
|
+
infer R
|
|
542
|
+
> ? R
|
|
543
|
+
: never
|
|
544
|
+
|
|
470
545
|
/**
|
|
471
546
|
* Utility type that extracts the error type from LanguageModel options.
|
|
472
547
|
*
|
|
@@ -477,29 +552,15 @@ export class GenerateObjectResponse<
|
|
|
477
552
|
* @category utility types
|
|
478
553
|
*/
|
|
479
554
|
export type ExtractError<Options> = Options extends {
|
|
480
|
-
readonly toolkit: Toolkit.WithHandler<infer _Tools>
|
|
481
555
|
readonly disableToolCallResolution: true
|
|
482
|
-
|
|
556
|
+
readonly toolkit: infer ToolkitValue
|
|
557
|
+
} ? ExtractErrorFromToolkitOption<Exclude<ToolkitValue, undefined>, true>
|
|
483
558
|
: Options extends {
|
|
484
|
-
readonly toolkit:
|
|
485
|
-
|
|
486
|
-
Toolkit.WithHandler<infer _Tools>,
|
|
487
|
-
infer _E,
|
|
488
|
-
infer _R
|
|
489
|
-
>
|
|
490
|
-
readonly disableToolCallResolution: true
|
|
491
|
-
} ? AiError.AiError | _E
|
|
559
|
+
readonly toolkit: infer ToolkitValue
|
|
560
|
+
} ? ExtractErrorFromToolkitOption<Exclude<ToolkitValue, undefined>, false>
|
|
492
561
|
: Options extends {
|
|
493
|
-
readonly
|
|
494
|
-
} ? AiError.AiError
|
|
495
|
-
: Options extends {
|
|
496
|
-
readonly toolkit: Effect.Yieldable<
|
|
497
|
-
Toolkit.Toolkit<infer _Tools>,
|
|
498
|
-
Toolkit.WithHandler<infer _Tools>,
|
|
499
|
-
infer _E,
|
|
500
|
-
infer _R
|
|
501
|
-
>
|
|
502
|
-
} ? AiError.AiError | Tool.HandlerError<_Tools[keyof _Tools]> | _E
|
|
562
|
+
readonly disableToolCallResolution: true
|
|
563
|
+
} ? AiError.AiError
|
|
503
564
|
: AiError.AiError
|
|
504
565
|
|
|
505
566
|
/**
|
|
@@ -514,27 +575,8 @@ export type ExtractServices<Options> = Options extends {
|
|
|
514
575
|
readonly disableToolCallResolution: true
|
|
515
576
|
} ? never
|
|
516
577
|
: Options extends {
|
|
517
|
-
readonly toolkit:
|
|
518
|
-
}
|
|
519
|
-
// Required for tool call execution
|
|
520
|
-
?
|
|
521
|
-
| Tool.ResultEncodingServices<_Tools[keyof _Tools]>
|
|
522
|
-
// Required for decoding large language model responses
|
|
523
|
-
| Tool.ResultDecodingServices<_Tools[keyof _Tools]>
|
|
524
|
-
: Options extends {
|
|
525
|
-
readonly toolkit: Effect.Yieldable<
|
|
526
|
-
Toolkit.Toolkit<infer _Tools>,
|
|
527
|
-
Toolkit.WithHandler<infer _Tools>,
|
|
528
|
-
infer _E,
|
|
529
|
-
infer _R
|
|
530
|
-
>
|
|
531
|
-
}
|
|
532
|
-
// Required for tool call execution
|
|
533
|
-
?
|
|
534
|
-
| Tool.ResultEncodingServices<_Tools[keyof _Tools]>
|
|
535
|
-
// Required for decoding large language model responses
|
|
536
|
-
| Tool.ResultDecodingServices<_Tools[keyof _Tools]>
|
|
537
|
-
| _R
|
|
578
|
+
readonly toolkit: infer Toolkit
|
|
579
|
+
} ? ExtractServicesFromToolkitOption<Exclude<Toolkit, undefined>>
|
|
538
580
|
: never
|
|
539
581
|
|
|
540
582
|
// =============================================================================
|
|
@@ -1031,21 +1073,11 @@ export const make: (params: {
|
|
|
1031
1073
|
AiError.AiError | Schema.SchemaError,
|
|
1032
1074
|
IdGenerator
|
|
1033
1075
|
>,
|
|
1034
|
-
Options extends {
|
|
1035
|
-
|
|
1036
|
-
Toolkit.WithHandler<Tools>,
|
|
1037
|
-
infer _E,
|
|
1038
|
-
infer _R
|
|
1039
|
-
>
|
|
1040
|
-
} ? _E
|
|
1076
|
+
Options extends { readonly toolkit: infer ToolkitValue } ?
|
|
1077
|
+
ExtractToolkitResolutionError<Exclude<ToolkitValue, undefined>>
|
|
1041
1078
|
: never,
|
|
1042
|
-
Options extends {
|
|
1043
|
-
|
|
1044
|
-
Toolkit.WithHandler<Tools>,
|
|
1045
|
-
infer _E,
|
|
1046
|
-
infer _R
|
|
1047
|
-
>
|
|
1048
|
-
} ? _R
|
|
1079
|
+
Options extends { readonly toolkit: infer ToolkitValue } ?
|
|
1080
|
+
ExtractToolkitResolutionServices<Exclude<ToolkitValue, undefined>>
|
|
1049
1081
|
: never
|
|
1050
1082
|
> = Effect.fnUntraced(function*<
|
|
1051
1083
|
Tools extends Record<string, Tool.Any>,
|
|
@@ -1090,9 +1122,7 @@ export const make: (params: {
|
|
|
1090
1122
|
}
|
|
1091
1123
|
|
|
1092
1124
|
// If there is a toolkit resolve and apply it to the provider options
|
|
1093
|
-
const toolkit =
|
|
1094
|
-
? yield* options.toolkit
|
|
1095
|
-
: options.toolkit
|
|
1125
|
+
const toolkit = yield* resolveToolkit<Tools, any, any>(options.toolkit)
|
|
1096
1126
|
|
|
1097
1127
|
// If the toolkit is empty, return immediately
|
|
1098
1128
|
if (Object.values(toolkit.tools).length === 0) {
|
|
@@ -1335,20 +1365,27 @@ export const make: (params: {
|
|
|
1335
1365
|
* @since 4.0.0
|
|
1336
1366
|
* @category text generation
|
|
1337
1367
|
*/
|
|
1338
|
-
export
|
|
1339
|
-
Options extends NoExcessProperties<GenerateTextOptions<any>, Options
|
|
1340
|
-
Tools extends Record<string, Tool.Any> = {}
|
|
1368
|
+
export function generateText<
|
|
1369
|
+
Options extends NoExcessProperties<GenerateTextOptions<any>, Options>
|
|
1341
1370
|
>(
|
|
1342
|
-
options: Options & GenerateTextOptions<
|
|
1371
|
+
options: Options & GenerateTextOptions<ExtractTools<Options>>
|
|
1343
1372
|
): Effect.Effect<
|
|
1344
|
-
GenerateTextResponse<
|
|
1373
|
+
GenerateTextResponse<ExtractTools<Options>>,
|
|
1345
1374
|
ExtractError<Options>,
|
|
1346
1375
|
LanguageModel | ExtractServices<Options>
|
|
1347
|
-
>
|
|
1348
|
-
|
|
1376
|
+
>
|
|
1377
|
+
export function generateText(
|
|
1378
|
+
options: GenerateTextOptions<any>
|
|
1379
|
+
): Effect.Effect<
|
|
1380
|
+
GenerateTextResponse<any>,
|
|
1381
|
+
AiError.AiError,
|
|
1382
|
+
LanguageModel
|
|
1383
|
+
> {
|
|
1384
|
+
return Effect.flatMap(
|
|
1349
1385
|
Effect.service(LanguageModel),
|
|
1350
|
-
(model) => model.generateText(options)
|
|
1386
|
+
(model) => model.generateText(options as any)
|
|
1351
1387
|
)
|
|
1388
|
+
}
|
|
1352
1389
|
|
|
1353
1390
|
/**
|
|
1354
1391
|
* Generate a structured object from a schema using a language model.
|
|
@@ -1382,25 +1419,32 @@ export const generateText = <
|
|
|
1382
1419
|
* @since 4.0.0
|
|
1383
1420
|
* @category object generation
|
|
1384
1421
|
*/
|
|
1385
|
-
export
|
|
1422
|
+
export function generateObject<
|
|
1386
1423
|
ObjectEncoded extends Record<string, any>,
|
|
1387
1424
|
StructuredOutputSchema extends Schema.Encoder<ObjectEncoded, unknown>,
|
|
1388
1425
|
Options extends NoExcessProperties<
|
|
1389
1426
|
GenerateObjectOptions<any, StructuredOutputSchema>,
|
|
1390
1427
|
Options
|
|
1391
|
-
|
|
1392
|
-
Tools extends Record<string, Tool.Any> = {}
|
|
1428
|
+
>
|
|
1393
1429
|
>(
|
|
1394
|
-
options: Options & GenerateObjectOptions<
|
|
1430
|
+
options: Options & GenerateObjectOptions<ExtractTools<Options>, StructuredOutputSchema>
|
|
1395
1431
|
): Effect.Effect<
|
|
1396
|
-
GenerateObjectResponse<
|
|
1432
|
+
GenerateObjectResponse<ExtractTools<Options>, StructuredOutputSchema["Type"]>,
|
|
1397
1433
|
ExtractError<Options>,
|
|
1398
1434
|
ExtractServices<Options> | StructuredOutputSchema["DecodingServices"] | LanguageModel
|
|
1399
|
-
>
|
|
1400
|
-
|
|
1435
|
+
>
|
|
1436
|
+
export function generateObject(
|
|
1437
|
+
options: GenerateObjectOptions<any, Schema.Top>
|
|
1438
|
+
): Effect.Effect<
|
|
1439
|
+
GenerateObjectResponse<any, any>,
|
|
1440
|
+
AiError.AiError,
|
|
1441
|
+
LanguageModel
|
|
1442
|
+
> {
|
|
1443
|
+
return Effect.flatMap(
|
|
1401
1444
|
Effect.service(LanguageModel),
|
|
1402
|
-
(model) => model.generateObject(options)
|
|
1403
|
-
)
|
|
1445
|
+
(model) => model.generateObject(options as any)
|
|
1446
|
+
) as any
|
|
1447
|
+
}
|
|
1404
1448
|
|
|
1405
1449
|
/**
|
|
1406
1450
|
* Generate text using a language model with streaming output.
|
|
@@ -1426,20 +1470,27 @@ export const generateObject = <
|
|
|
1426
1470
|
* @since 4.0.0
|
|
1427
1471
|
* @category text generation
|
|
1428
1472
|
*/
|
|
1429
|
-
export
|
|
1430
|
-
Options extends NoExcessProperties<GenerateTextOptions<any>, Options
|
|
1431
|
-
Tools extends Record<string, Tool.Any> = {}
|
|
1473
|
+
export function streamText<
|
|
1474
|
+
Options extends NoExcessProperties<GenerateTextOptions<any>, Options>
|
|
1432
1475
|
>(
|
|
1433
|
-
options: Options & GenerateTextOptions<
|
|
1476
|
+
options: Options & GenerateTextOptions<ExtractTools<Options>>
|
|
1434
1477
|
): Stream.Stream<
|
|
1435
|
-
Response.StreamPart<
|
|
1478
|
+
Response.StreamPart<ExtractTools<Options>>,
|
|
1436
1479
|
ExtractError<Options>,
|
|
1437
1480
|
ExtractServices<Options> | LanguageModel
|
|
1438
|
-
>
|
|
1439
|
-
|
|
1481
|
+
>
|
|
1482
|
+
export function streamText(
|
|
1483
|
+
options: GenerateTextOptions<any>
|
|
1484
|
+
): Stream.Stream<
|
|
1485
|
+
Response.StreamPart<any>,
|
|
1486
|
+
AiError.AiError,
|
|
1487
|
+
LanguageModel
|
|
1488
|
+
> {
|
|
1489
|
+
return Stream.unwrap(Effect.map(
|
|
1440
1490
|
Effect.service(LanguageModel),
|
|
1441
|
-
(model) => model.streamText(options)
|
|
1442
|
-
))
|
|
1491
|
+
(model) => model.streamText(options as any)
|
|
1492
|
+
)) as any
|
|
1493
|
+
}
|
|
1443
1494
|
|
|
1444
1495
|
// =============================================================================
|
|
1445
1496
|
// Tool Approval Helpers
|
|
@@ -1816,11 +1867,11 @@ const resolveToolCalls = <Tools extends Record<string, Tool.Any>>(
|
|
|
1816
1867
|
// =============================================================================
|
|
1817
1868
|
|
|
1818
1869
|
const resolveToolkit = <Tools extends Record<string, Tool.Any>, E, R>(
|
|
1819
|
-
toolkit:
|
|
1820
|
-
| Toolkit.WithHandler<Tools>
|
|
1821
|
-
| Effect.Yieldable<Toolkit.Toolkit<any>, Toolkit.WithHandler<Tools>, E, R>
|
|
1870
|
+
toolkit: ToolkitOption<Tools, E, R>
|
|
1822
1871
|
): Effect.Effect<Toolkit.WithHandler<Tools>, E, R> =>
|
|
1823
|
-
"asEffect" in toolkit
|
|
1872
|
+
("asEffect" in toolkit
|
|
1873
|
+
? toolkit.asEffect()
|
|
1874
|
+
: Effect.succeed(toolkit as unknown as Toolkit.WithHandler<Tools>)) as any
|
|
1824
1875
|
|
|
1825
1876
|
/** @internal */
|
|
1826
1877
|
export const getObjectName = <StructuredOutputSchema extends Schema.Top>(
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since 4.0.0
|
|
3
|
+
*/
|
|
4
|
+
import * as Bash from "./internal/completions/bash.ts"
|
|
5
|
+
import type * as CommandDescriptor from "./internal/completions/CommandDescriptor.ts"
|
|
6
|
+
import * as Fish from "./internal/completions/fish.ts"
|
|
7
|
+
import * as Zsh from "./internal/completions/zsh.ts"
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Shell type used to generate completion scripts.
|
|
11
|
+
*
|
|
12
|
+
* @since 4.0.0
|
|
13
|
+
* @category models
|
|
14
|
+
*/
|
|
15
|
+
export type Shell = "bash" | "zsh" | "fish"
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Generates a shell completion script for a command descriptor.
|
|
19
|
+
*
|
|
20
|
+
* @since 4.0.0
|
|
21
|
+
* @category constructors
|
|
22
|
+
*/
|
|
23
|
+
export const generate = (
|
|
24
|
+
executableName: string,
|
|
25
|
+
shell: Shell,
|
|
26
|
+
descriptor: CommandDescriptor.CommandDescriptor
|
|
27
|
+
): string => {
|
|
28
|
+
switch (shell) {
|
|
29
|
+
case "bash":
|
|
30
|
+
return Bash.generate(executableName, descriptor)
|
|
31
|
+
case "zsh":
|
|
32
|
+
return Zsh.generate(executableName, descriptor)
|
|
33
|
+
case "fish":
|
|
34
|
+
return Fish.generate(executableName, descriptor)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -9,7 +9,10 @@ import * as Option from "../../Option.ts"
|
|
|
9
9
|
import * as ServiceMap from "../../ServiceMap.ts"
|
|
10
10
|
import * as CliOutput from "./CliOutput.ts"
|
|
11
11
|
import type * as Command from "./Command.ts"
|
|
12
|
+
import * as Completions_ from "./Completions.ts"
|
|
12
13
|
import * as Flag from "./Flag.ts"
|
|
14
|
+
import * as CommandDescriptor from "./internal/completions/CommandDescriptor.ts"
|
|
15
|
+
import * as HelpInternal from "./internal/help.ts"
|
|
13
16
|
|
|
14
17
|
/* ========================================================================== */
|
|
15
18
|
/* Types */
|
|
@@ -124,10 +127,6 @@ let settingIdCounter = 0
|
|
|
124
127
|
/* Built-in Flag References */
|
|
125
128
|
/* ========================================================================== */
|
|
126
129
|
|
|
127
|
-
import * as CommandDescriptor from "./internal/completions/CommandDescriptor.ts"
|
|
128
|
-
import * as CompletionsInternal from "./internal/completions/Completions.ts"
|
|
129
|
-
import * as HelpInternal from "./internal/help.ts"
|
|
130
|
-
|
|
131
130
|
/**
|
|
132
131
|
* The `--help` / `-h` global flag.
|
|
133
132
|
* Shows help documentation for the command.
|
|
@@ -185,7 +184,7 @@ export const Completions: Action<Option.Option<"bash" | "zsh" | "fish">> = actio
|
|
|
185
184
|
if (Option.isNone(shell)) return
|
|
186
185
|
const descriptor = CommandDescriptor.fromCommand(command)
|
|
187
186
|
yield* Console.log(
|
|
188
|
-
|
|
187
|
+
Completions_.generate(command.name, shell.value, descriptor)
|
|
189
188
|
)
|
|
190
189
|
})
|
|
191
190
|
})
|
|
@@ -374,7 +374,7 @@ export const make = Effect.gen(function*() {
|
|
|
374
374
|
id: ""
|
|
375
375
|
})
|
|
376
376
|
if (!reply) return undefined
|
|
377
|
-
const exit = yield* (Schema.
|
|
377
|
+
const exit = yield* (Schema.decodeUnknownEffect(exitSchema)(reply.exit) as Effect.Effect<
|
|
378
378
|
Exit.Exit<any, any>,
|
|
379
379
|
Schema.SchemaError
|
|
380
380
|
>)
|
|
@@ -30,7 +30,7 @@ export const isDeliverAt = (self: unknown): self is DeliverAt => hasProperty(sel
|
|
|
30
30
|
*/
|
|
31
31
|
export const toMillis = (self: unknown): number | null => {
|
|
32
32
|
if (isDeliverAt(self)) {
|
|
33
|
-
return self[symbol]().
|
|
33
|
+
return self[symbol]().epochMilliseconds
|
|
34
34
|
}
|
|
35
35
|
return null
|
|
36
36
|
}
|
|
@@ -61,13 +61,13 @@ export const encodeString = <IE = never, Done = unknown>(): Channel.Channel<
|
|
|
61
61
|
* @category constructors
|
|
62
62
|
*/
|
|
63
63
|
export const encode = <IE = never, Done = unknown>(): Channel.Channel<
|
|
64
|
-
Arr.NonEmptyReadonlyArray<Uint8Array
|
|
64
|
+
Arr.NonEmptyReadonlyArray<Uint8Array>,
|
|
65
65
|
IE | NdjsonError,
|
|
66
66
|
Done,
|
|
67
67
|
Arr.NonEmptyReadonlyArray<unknown>,
|
|
68
68
|
IE,
|
|
69
69
|
Done
|
|
70
|
-
> => Channel.map(encodeString(), Arr.map((_) => encoder.encode(_)
|
|
70
|
+
> => Channel.map(encodeString(), Arr.map((_) => encoder.encode(_)))
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* @since 4.0.0
|
|
@@ -77,7 +77,7 @@ export const encodeSchema = <S extends Schema.Top>(
|
|
|
77
77
|
schema: S
|
|
78
78
|
) =>
|
|
79
79
|
<IE = never, Done = unknown>(): Channel.Channel<
|
|
80
|
-
Arr.NonEmptyReadonlyArray<Uint8Array
|
|
80
|
+
Arr.NonEmptyReadonlyArray<Uint8Array>,
|
|
81
81
|
NdjsonError | Schema.SchemaError | IE,
|
|
82
82
|
Done,
|
|
83
83
|
Arr.NonEmptyReadonlyArray<S["Type"]>,
|
|
@@ -141,7 +141,7 @@ export const decode = <IE = never, Done = unknown>(options?: {
|
|
|
141
141
|
Arr.NonEmptyReadonlyArray<unknown>,
|
|
142
142
|
IE | NdjsonError,
|
|
143
143
|
Done,
|
|
144
|
-
Arr.NonEmptyReadonlyArray<Uint8Array
|
|
144
|
+
Arr.NonEmptyReadonlyArray<Uint8Array>,
|
|
145
145
|
IE,
|
|
146
146
|
Done
|
|
147
147
|
> => {
|
|
@@ -161,7 +161,7 @@ export const decodeSchema = <S extends Schema.Top>(
|
|
|
161
161
|
Arr.NonEmptyReadonlyArray<S["Type"]>,
|
|
162
162
|
Schema.SchemaError | NdjsonError | IE,
|
|
163
163
|
Done,
|
|
164
|
-
Arr.NonEmptyReadonlyArray<Uint8Array
|
|
164
|
+
Arr.NonEmptyReadonlyArray<Uint8Array>,
|
|
165
165
|
IE,
|
|
166
166
|
Done,
|
|
167
167
|
S["DecodingServices"]
|
|
@@ -201,10 +201,10 @@ export const duplex: {
|
|
|
201
201
|
}
|
|
202
202
|
): <R, IE, OE, OutDone, InDone>(
|
|
203
203
|
self: Channel.Channel<
|
|
204
|
-
Arr.NonEmptyReadonlyArray<Uint8Array
|
|
204
|
+
Arr.NonEmptyReadonlyArray<Uint8Array>,
|
|
205
205
|
OE,
|
|
206
206
|
OutDone,
|
|
207
|
-
Arr.NonEmptyReadonlyArray<Uint8Array
|
|
207
|
+
Arr.NonEmptyReadonlyArray<Uint8Array>,
|
|
208
208
|
IE | NdjsonError,
|
|
209
209
|
InDone,
|
|
210
210
|
R
|
|
@@ -224,10 +224,10 @@ export const duplex: {
|
|
|
224
224
|
*/
|
|
225
225
|
<R, IE, OE, OutDone, InDone>(
|
|
226
226
|
self: Channel.Channel<
|
|
227
|
-
Arr.NonEmptyReadonlyArray<Uint8Array
|
|
227
|
+
Arr.NonEmptyReadonlyArray<Uint8Array>,
|
|
228
228
|
OE,
|
|
229
229
|
OutDone,
|
|
230
|
-
Arr.NonEmptyReadonlyArray<Uint8Array
|
|
230
|
+
Arr.NonEmptyReadonlyArray<Uint8Array>,
|
|
231
231
|
IE | NdjsonError,
|
|
232
232
|
InDone,
|
|
233
233
|
R
|
|
@@ -246,10 +246,10 @@ export const duplex: {
|
|
|
246
246
|
>
|
|
247
247
|
} = dual((args) => Channel.isChannel(args[0]), <R, IE, OE, OutDone, InDone>(
|
|
248
248
|
self: Channel.Channel<
|
|
249
|
-
Arr.NonEmptyReadonlyArray<Uint8Array
|
|
249
|
+
Arr.NonEmptyReadonlyArray<Uint8Array>,
|
|
250
250
|
OE,
|
|
251
251
|
OutDone,
|
|
252
|
-
Arr.NonEmptyReadonlyArray<Uint8Array
|
|
252
|
+
Arr.NonEmptyReadonlyArray<Uint8Array>,
|
|
253
253
|
IE | NdjsonError,
|
|
254
254
|
InDone,
|
|
255
255
|
R
|
|
@@ -373,10 +373,10 @@ export const duplexSchema: {
|
|
|
373
373
|
}
|
|
374
374
|
): <OutErr, OutDone, InErr, InDone, R>(
|
|
375
375
|
self: Channel.Channel<
|
|
376
|
-
Arr.NonEmptyReadonlyArray<Uint8Array
|
|
376
|
+
Arr.NonEmptyReadonlyArray<Uint8Array>,
|
|
377
377
|
OutErr,
|
|
378
378
|
OutDone,
|
|
379
|
-
Arr.NonEmptyReadonlyArray<Uint8Array
|
|
379
|
+
Arr.NonEmptyReadonlyArray<Uint8Array>,
|
|
380
380
|
NdjsonError | Schema.SchemaError | InErr,
|
|
381
381
|
InDone,
|
|
382
382
|
R
|
|
@@ -396,10 +396,10 @@ export const duplexSchema: {
|
|
|
396
396
|
*/
|
|
397
397
|
<Out extends Schema.Top, In extends Schema.Top, OutErr, OutDone, InErr, InDone, R>(
|
|
398
398
|
self: Channel.Channel<
|
|
399
|
-
Arr.NonEmptyReadonlyArray<Uint8Array
|
|
399
|
+
Arr.NonEmptyReadonlyArray<Uint8Array>,
|
|
400
400
|
OutErr,
|
|
401
401
|
OutDone,
|
|
402
|
-
Arr.NonEmptyReadonlyArray<Uint8Array
|
|
402
|
+
Arr.NonEmptyReadonlyArray<Uint8Array>,
|
|
403
403
|
NdjsonError | Schema.SchemaError | InErr,
|
|
404
404
|
InDone,
|
|
405
405
|
R
|
|
@@ -420,10 +420,10 @@ export const duplexSchema: {
|
|
|
420
420
|
>
|
|
421
421
|
} = dual(2, <Out extends Schema.Top, In extends Schema.Top, OutErr, OutDone, InErr, InDone, R>(
|
|
422
422
|
self: Channel.Channel<
|
|
423
|
-
Arr.NonEmptyReadonlyArray<Uint8Array
|
|
423
|
+
Arr.NonEmptyReadonlyArray<Uint8Array>,
|
|
424
424
|
OutErr,
|
|
425
425
|
OutDone,
|
|
426
|
-
Arr.NonEmptyReadonlyArray<Uint8Array
|
|
426
|
+
Arr.NonEmptyReadonlyArray<Uint8Array>,
|
|
427
427
|
NdjsonError | Schema.SchemaError | InErr,
|
|
428
428
|
InDone,
|
|
429
429
|
R
|
|
@@ -298,10 +298,10 @@ class WebHttpClientResponse extends Inspectable.Class implements HttpClientRespo
|
|
|
298
298
|
)
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
-
get json(): Effect.Effect<
|
|
301
|
+
get json(): Effect.Effect<Schema.Json, Error.HttpClientError> {
|
|
302
302
|
return Effect.flatMap(this.text, (text) =>
|
|
303
303
|
Effect.try({
|
|
304
|
-
try: () => text === "" ? null : JSON.parse(text)
|
|
304
|
+
try: () => text === "" ? null : JSON.parse(text),
|
|
305
305
|
catch: (cause) =>
|
|
306
306
|
new Error.HttpClientError({
|
|
307
307
|
reason: new Error.DecodeError({
|
|
@@ -33,7 +33,7 @@ export interface HttpIncomingMessage<E = unknown> extends Inspectable.Inspectabl
|
|
|
33
33
|
readonly [TypeId]: typeof TypeId
|
|
34
34
|
readonly headers: Headers.Headers
|
|
35
35
|
readonly remoteAddress: string | undefined
|
|
36
|
-
readonly json: Effect.Effect<
|
|
36
|
+
readonly json: Effect.Effect<Schema.Json, E>
|
|
37
37
|
readonly text: Effect.Effect<string, E>
|
|
38
38
|
readonly urlParamsBody: Effect.Effect<UrlParams.UrlParams, E>
|
|
39
39
|
readonly arrayBuffer: Effect.Effect<ArrayBuffer, E>
|
|
@@ -444,10 +444,10 @@ class ServerRequestImpl extends Inspectable.Class implements HttpServerRequest {
|
|
|
444
444
|
return this.textEffect
|
|
445
445
|
}
|
|
446
446
|
|
|
447
|
-
get json(): Effect.Effect<
|
|
447
|
+
get json(): Effect.Effect<Schema.Json, HttpServerError> {
|
|
448
448
|
return Effect.flatMap(this.text, (text) =>
|
|
449
449
|
Effect.try({
|
|
450
|
-
try: () => JSON.parse(text) as
|
|
450
|
+
try: () => JSON.parse(text) as Schema.Json,
|
|
451
451
|
catch: (cause) =>
|
|
452
452
|
new HttpServerError({
|
|
453
453
|
reason: new RequestParseError({
|
|
@@ -664,10 +664,10 @@ class ClientRequestImpl extends Inspectable.Class implements HttpServerRequest {
|
|
|
664
664
|
return Effect.map(this.bytes, (bytes) => textDecoder.decode(bytes))
|
|
665
665
|
}
|
|
666
666
|
|
|
667
|
-
get json(): Effect.Effect<
|
|
667
|
+
get json(): Effect.Effect<Schema.Json, HttpServerError> {
|
|
668
668
|
return Effect.flatMap(this.text, (text) =>
|
|
669
669
|
Effect.try({
|
|
670
|
-
try: () => text === "" ? null : JSON.parse(text)
|
|
670
|
+
try: () => text === "" ? null : JSON.parse(text),
|
|
671
671
|
catch: (cause) => requestParseError(this, undefined, cause)
|
|
672
672
|
}))
|
|
673
673
|
}
|
|
@@ -1015,10 +1015,10 @@ class ServerHttpClientResponse extends Inspectable.Class implements HttpClientRe
|
|
|
1015
1015
|
}
|
|
1016
1016
|
}
|
|
1017
1017
|
|
|
1018
|
-
get json(): Effect.Effect<
|
|
1018
|
+
get json(): Effect.Effect<Schema.Json, HttpClientError.HttpClientError> {
|
|
1019
1019
|
return Effect.flatMap(this.text, (text) =>
|
|
1020
1020
|
Effect.try({
|
|
1021
|
-
try: () => text === "" ? null : JSON.parse(text)
|
|
1021
|
+
try: () => text === "" ? null : JSON.parse(text),
|
|
1022
1022
|
catch: (cause) =>
|
|
1023
1023
|
new HttpClientError.HttpClientError({
|
|
1024
1024
|
reason: new HttpClientError.DecodeError({
|
|
@@ -166,11 +166,11 @@ export interface Handlers<
|
|
|
166
166
|
| R
|
|
167
167
|
| HttpApiEndpoint.MiddlewareWithName<Endpoints, Name>
|
|
168
168
|
| HttpApiEndpoint.MiddlewareServicesWithName<Endpoints, Name>
|
|
169
|
-
| HttpApiEndpoint.ExcludeProvidedWithName<
|
|
169
|
+
| (HttpApiEndpoint.ExcludeProvidedWithName<
|
|
170
170
|
Endpoints,
|
|
171
171
|
Name,
|
|
172
172
|
R1 | HttpApiEndpoint.ServerServicesWithName<Endpoints, Name>
|
|
173
|
-
|
|
173
|
+
> extends infer _R ? _R extends never ? never : HttpRouter.Request<"Requires", _R> : never),
|
|
174
174
|
HttpApiEndpoint.ExcludeName<Endpoints, Name>
|
|
175
175
|
>
|
|
176
176
|
|
|
@@ -186,11 +186,11 @@ export interface Handlers<
|
|
|
186
186
|
| R
|
|
187
187
|
| HttpApiEndpoint.MiddlewareWithName<Endpoints, Name>
|
|
188
188
|
| HttpApiEndpoint.MiddlewareServicesWithName<Endpoints, Name>
|
|
189
|
-
| HttpApiEndpoint.ExcludeProvidedWithName<
|
|
189
|
+
| (HttpApiEndpoint.ExcludeProvidedWithName<
|
|
190
190
|
Endpoints,
|
|
191
191
|
Name,
|
|
192
192
|
R1 | HttpApiEndpoint.ServerServicesWithName<Endpoints, Name>
|
|
193
|
-
|
|
193
|
+
> extends infer _R ? _R extends never ? never : HttpRouter.Request<"Requires", _R> : never),
|
|
194
194
|
HttpApiEndpoint.ExcludeName<Endpoints, Name>
|
|
195
195
|
>
|
|
196
196
|
}
|
|
@@ -194,5 +194,5 @@ export const deserializeExit = <A extends Schema.Top, E extends Schema.Top>(
|
|
|
194
194
|
A["DecodingServices"] | E["DecodingServices"]
|
|
195
195
|
> => {
|
|
196
196
|
const schema = Schema.toCodecJson(exitSchema(self))
|
|
197
|
-
return Schema.
|
|
197
|
+
return Schema.decodeUnknownEffect(schema)(encoded)
|
|
198
198
|
}
|