@effect/ai 0.29.1 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/Response.ts CHANGED
@@ -26,11 +26,12 @@
26
26
  *
27
27
  * @since 1.0.0
28
28
  */
29
- import { ParseResult } from "effect"
30
29
  import type * as DateTime from "effect/DateTime"
31
30
  import * as Effect from "effect/Effect"
31
+ import type * as Either from "effect/Either"
32
32
  import { constFalse } from "effect/Function"
33
33
  import type * as Option from "effect/Option"
34
+ import * as ParseResult from "effect/ParseResult"
34
35
  import * as Predicate from "effect/Predicate"
35
36
  import * as Schema from "effect/Schema"
36
37
  import type * as Tool from "./Tool.js"
@@ -85,7 +86,7 @@ export type AnyPart =
85
86
  | ToolParamsDeltaPart
86
87
  | ToolParamsEndPart
87
88
  | ToolCallPart<any, any>
88
- | ToolResultPart<any, any>
89
+ | ToolResultPart<any, any, any>
89
90
  | FilePart
90
91
  | DocumentSourcePart
91
92
  | UrlSourcePart
@@ -202,10 +203,10 @@ export const AllParts = <T extends Toolkit.Any | Toolkit.WithHandler<any>>(
202
203
  toolkit: T
203
204
  ): Schema.Schema<AllParts<Toolkit.Tools<T>>, AllPartsEncoded> => {
204
205
  const toolCalls: Array<Schema.Schema<ToolCallPart<string, any>, ToolCallPartEncoded>> = []
205
- const toolCallResults: Array<Schema.Schema<ToolResultPart<string, any>, ToolResultPartEncoded>> = []
206
+ const toolCallResults: Array<Schema.Schema<ToolResultPart<string, any, any>, ToolResultPartEncoded>> = []
206
207
  for (const tool of Object.values(toolkit.tools as Record<string, Tool.Any>)) {
207
208
  toolCalls.push(ToolCallPart(tool.name, tool.parametersSchema as any))
208
- toolCallResults.push(ToolResultPart(tool.name, tool.successSchema))
209
+ toolCallResults.push(ToolResultPart(tool.name, tool.successSchema, tool.failureSchema))
209
210
  }
210
211
  return Schema.Union(
211
212
  TextPart,
@@ -283,10 +284,10 @@ export const Part = <T extends Toolkit.Any | Toolkit.WithHandler<any>>(
283
284
  toolkit: T
284
285
  ): Schema.Schema<Part<Toolkit.Tools<T>>, PartEncoded> => {
285
286
  const toolCalls: Array<Schema.Schema<ToolCallPart<string, any>, ToolCallPartEncoded>> = []
286
- const toolCallResults: Array<Schema.Schema<ToolResultPart<string, any>, ToolResultPartEncoded>> = []
287
+ const toolCallResults: Array<Schema.Schema<ToolResultPart<string, any, any>, ToolResultPartEncoded>> = []
287
288
  for (const tool of Object.values(toolkit.tools as Record<string, Tool.Any>)) {
288
289
  toolCalls.push(ToolCallPart(tool.name, tool.parametersSchema as any))
289
- toolCallResults.push(ToolResultPart(tool.name, tool.successSchema))
290
+ toolCallResults.push(ToolResultPart(tool.name, tool.successSchema, tool.failureSchema))
290
291
  }
291
292
  return Schema.Union(
292
293
  TextPart,
@@ -367,10 +368,10 @@ export const StreamPart = <T extends Toolkit.Any | Toolkit.WithHandler<any>>(
367
368
  toolkit: T
368
369
  ): Schema.Schema<StreamPart<Toolkit.Tools<T>>, StreamPartEncoded> => {
369
370
  const toolCalls: Array<Schema.Schema<ToolCallPart<string, any>, ToolCallPartEncoded>> = []
370
- const toolCallResults: Array<Schema.Schema<ToolResultPart<string, any>, ToolResultPartEncoded>> = []
371
+ const toolCallResults: Array<Schema.Schema<ToolResultPart<string, any, any>, ToolResultPartEncoded>> = []
371
372
  for (const tool of Object.values(toolkit.tools as Record<string, Tool.Any>)) {
372
373
  toolCalls.push(ToolCallPart(tool.name, tool.parametersSchema as any))
373
- toolCallResults.push(ToolResultPart(tool.name, tool.successSchema))
374
+ toolCallResults.push(ToolResultPart(tool.name, tool.successSchema, tool.failureSchema))
374
375
  }
375
376
  return Schema.Union(
376
377
  TextStartPart,
@@ -406,7 +407,8 @@ export const StreamPart = <T extends Toolkit.Any | Toolkit.WithHandler<any>>(
406
407
  * @category Utility Types
407
408
  */
408
409
  export type ToolCallParts<Tools extends Record<string, Tool.Any>> = {
409
- [Name in keyof Tools]: Name extends string ? ToolCallPart<Name, Tool.ParametersSchema<Tools[Name]>["fields"]>
410
+ [Name in keyof Tools]: Name extends string ?
411
+ ToolCallPart<Name, Schema.Struct.Type<Tool.ParametersSchema<Tools[Name]>["fields"]>>
410
412
  : never
411
413
  }[keyof Tools]
412
414
 
@@ -419,7 +421,11 @@ export type ToolCallParts<Tools extends Record<string, Tool.Any>> = {
419
421
  * @category Utility Types
420
422
  */
421
423
  export type ToolResultParts<Tools extends Record<string, Tool.Any>> = {
422
- [Name in keyof Tools]: Name extends string ? ToolResultPart<Name, Tool.Success<Tools[Name]>>
424
+ [Name in keyof Tools]: Name extends string ? ToolResultPart<
425
+ Name,
426
+ Tool.Success<Tools[Name]>,
427
+ Tool.Failure<Tools[Name]>
428
+ >
423
429
  : never
424
430
  }[keyof Tools]
425
431
 
@@ -542,6 +548,20 @@ export const makePart = <const Type extends AnyPart["type"]>(
542
548
  metadata: params.metadata ?? {}
543
549
  }) as any)
544
550
 
551
+ /**
552
+ * A utility type for specifying the parameters required to construct a
553
+ * specific response part.
554
+ *
555
+ * @since 1.0.0
556
+ * @category Utility Types
557
+ */
558
+ export type ConstructorParams<Part extends AnyPart> = Omit<Part, PartTypeId | "type" | "sourceType" | "metadata"> & {
559
+ /**
560
+ * Optional provider-specific metadata for this part.
561
+ */
562
+ readonly metadata?: Part["metadata"] | undefined
563
+ }
564
+
545
565
  // =============================================================================
546
566
  // Text Part
547
567
  // =============================================================================
@@ -605,6 +625,14 @@ export const TextPart: Schema.Schema<TextPart, TextPartEncoded> = Schema.Struct(
605
625
  Schema.annotations({ identifier: "TextPart" })
606
626
  )
607
627
 
628
+ /**
629
+ * Constructs a new text part.
630
+ *
631
+ * @since 1.0.0
632
+ * @category Constructors
633
+ */
634
+ export const textPart = (params: ConstructorParams<TextPart>): TextPart => makePart("text", params)
635
+
608
636
  // =============================================================================
609
637
  // Text Start Part
610
638
  // =============================================================================
@@ -661,6 +689,14 @@ export const TextStartPart: Schema.Schema<TextStartPart, TextStartPartEncoded> =
661
689
  Schema.annotations({ identifier: "TextStartPart" })
662
690
  )
663
691
 
692
+ /**
693
+ * Constructs a new text start part.
694
+ *
695
+ * @since 1.0.0
696
+ * @category Constructors
697
+ */
698
+ export const textStartPart = (params: ConstructorParams<TextStartPart>): TextStartPart => makePart("text-start", params)
699
+
664
700
  // =============================================================================
665
701
  // Text Delta Part
666
702
  // =============================================================================
@@ -725,6 +761,14 @@ export const TextDeltaPart: Schema.Schema<TextDeltaPart, TextDeltaPartEncoded> =
725
761
  Schema.annotations({ identifier: "TextDeltaPart" })
726
762
  )
727
763
 
764
+ /**
765
+ * Constructs a new text delta part.
766
+ *
767
+ * @since 1.0.0
768
+ * @category Constructors
769
+ */
770
+ export const textDeltaPart = (params: ConstructorParams<TextDeltaPart>): TextDeltaPart => makePart("text-delta", params)
771
+
728
772
  // =============================================================================
729
773
  // Text End Part
730
774
  // =============================================================================
@@ -781,6 +825,14 @@ export const TextEndPart: Schema.Schema<TextEndPart, TextEndPartEncoded> = Schem
781
825
  Schema.annotations({ identifier: "TextEndPart" })
782
826
  )
783
827
 
828
+ /**
829
+ * Constructs a new text end part.
830
+ *
831
+ * @since 1.0.0
832
+ * @category Constructors
833
+ */
834
+ export const textEndPart = (params: ConstructorParams<TextEndPart>): TextEndPart => makePart("text-end", params)
835
+
784
836
  // =============================================================================
785
837
  // Reasoning Part
786
838
  // =============================================================================
@@ -847,6 +899,14 @@ export const ReasoningPart: Schema.Schema<ReasoningPart, ReasoningPartEncoded> =
847
899
  Schema.annotations({ identifier: "ReasoningPart" })
848
900
  )
849
901
 
902
+ /**
903
+ * Constructs a new reasoning part.
904
+ *
905
+ * @since 1.0.0
906
+ * @category Constructors
907
+ */
908
+ export const reasoningPart = (params: ConstructorParams<ReasoningPart>): ReasoningPart => makePart("reasoning", params)
909
+
850
910
  // =============================================================================
851
911
  // Reasoning Start Part
852
912
  // =============================================================================
@@ -903,6 +963,15 @@ export const ReasoningStartPart: Schema.Schema<ReasoningStartPart, ReasoningStar
903
963
  Schema.annotations({ identifier: "ReasoningStartPart" })
904
964
  )
905
965
 
966
+ /**
967
+ * Constructs a new reasoning start part.
968
+ *
969
+ * @since 1.0.0
970
+ * @category Constructors
971
+ */
972
+ export const reasoningStartPart = (params: ConstructorParams<ReasoningStartPart>): ReasoningStartPart =>
973
+ makePart("reasoning-start", params)
974
+
906
975
  // =============================================================================
907
976
  // Reasoning Delta Part
908
977
  // =============================================================================
@@ -967,6 +1036,15 @@ export const ReasoningDeltaPart: Schema.Schema<ReasoningDeltaPart, ReasoningDelt
967
1036
  Schema.annotations({ identifier: "ReasoningDeltaPart" })
968
1037
  )
969
1038
 
1039
+ /**
1040
+ * Constructs a new reasoning delta part.
1041
+ *
1042
+ * @since 1.0.0
1043
+ * @category Constructors
1044
+ */
1045
+ export const reasoningDeltaPart = (params: ConstructorParams<ReasoningDeltaPart>): ReasoningDeltaPart =>
1046
+ makePart("reasoning-delta", params)
1047
+
970
1048
  // =============================================================================
971
1049
  // Reasoning End Part
972
1050
  // =============================================================================
@@ -1023,6 +1101,15 @@ export const ReasoningEndPart: Schema.Schema<ReasoningEndPart, ReasoningEndPartE
1023
1101
  Schema.annotations({ identifier: "ReasoningEndPart" })
1024
1102
  )
1025
1103
 
1104
+ /**
1105
+ * Constructs a new reasoning end part.
1106
+ *
1107
+ * @since 1.0.0
1108
+ * @category Constructors
1109
+ */
1110
+ export const reasoningEndPart = (params: ConstructorParams<ReasoningEndPart>): ReasoningEndPart =>
1111
+ makePart("reasoning-end", params)
1112
+
1026
1113
  // =============================================================================
1027
1114
  // Tool Params Start Part
1028
1115
  // =============================================================================
@@ -1119,6 +1206,15 @@ export const ToolParamsStartPart: Schema.Schema<ToolParamsStartPart, ToolParamsS
1119
1206
  Schema.annotations({ identifier: "ToolParamsStartPart" })
1120
1207
  )
1121
1208
 
1209
+ /**
1210
+ * Constructs a new tool params start part.
1211
+ *
1212
+ * @since 1.0.0
1213
+ * @category Constructors
1214
+ */
1215
+ export const toolParamsStartPart = (params: ConstructorParams<ToolParamsStartPart>): ToolParamsStartPart =>
1216
+ makePart("tool-params-start", params)
1217
+
1122
1218
  // =============================================================================
1123
1219
  // Tool Params Delta Part
1124
1220
  // =============================================================================
@@ -1185,6 +1281,15 @@ export const ToolParamsDeltaPart: Schema.Schema<ToolParamsDeltaPart, ToolParamsD
1185
1281
  Schema.annotations({ identifier: "ToolParamsDeltaPart" })
1186
1282
  )
1187
1283
 
1284
+ /**
1285
+ * Constructs a new tool params delta part.
1286
+ *
1287
+ * @since 1.0.0
1288
+ * @category Constructors
1289
+ */
1290
+ export const toolParamsDeltaPart = (params: ConstructorParams<ToolParamsDeltaPart>): ToolParamsDeltaPart =>
1291
+ makePart("tool-params-delta", params)
1292
+
1188
1293
  // =============================================================================
1189
1294
  // Tool Params End Part
1190
1295
  // =============================================================================
@@ -1242,6 +1347,15 @@ export const ToolParamsEndPart: Schema.Schema<ToolParamsEndPart, ToolParamsEndPa
1242
1347
  Schema.annotations({ identifier: "ToolParamsEndPart" })
1243
1348
  )
1244
1349
 
1350
+ /**
1351
+ * Constructs a new tool params end part.
1352
+ *
1353
+ * @since 1.0.0
1354
+ * @category Constructors
1355
+ */
1356
+ export const toolParamsEndPart = (params: ConstructorParams<ToolParamsEndPart>): ToolParamsEndPart =>
1357
+ makePart("tool-params-end", params)
1358
+
1245
1359
  // =============================================================================
1246
1360
  // Tool Call Part
1247
1361
  // =============================================================================
@@ -1276,9 +1390,7 @@ export const ToolParamsEndPart: Schema.Schema<ToolParamsEndPart, ToolParamsEndPa
1276
1390
  * @since 1.0.0
1277
1391
  * @category Models
1278
1392
  */
1279
- export interface ToolCallPart<Name extends string, Params extends Schema.Struct.Fields>
1280
- extends BasePart<"tool-call", ToolCallPartMetadata>
1281
- {
1393
+ export interface ToolCallPart<Name extends string, Params> extends BasePart<"tool-call", ToolCallPartMetadata> {
1282
1394
  /**
1283
1395
  * Unique identifier for this tool call.
1284
1396
  */
@@ -1291,7 +1403,7 @@ export interface ToolCallPart<Name extends string, Params extends Schema.Struct.
1291
1403
  /**
1292
1404
  * Parameters to pass to the tool.
1293
1405
  */
1294
- readonly params: Schema.Struct.Type<Params>
1406
+ readonly params: Params
1295
1407
  /**
1296
1408
  * Optional provider-specific name for the tool, which can be useful when the
1297
1409
  * name of the tool in the `Toolkit` and the name of the tool used by the
@@ -1380,6 +1492,16 @@ export const ToolCallPart = <const Name extends string, Params extends Schema.St
1380
1492
  Schema.annotations({ identifier: "ToolCallPart" })
1381
1493
  ) as any
1382
1494
 
1495
+ /**
1496
+ * Constructs a new tool call part.
1497
+ *
1498
+ * @since 1.0.0
1499
+ * @category Constructors
1500
+ */
1501
+ export const toolCallPart = <const Name extends string, Params>(
1502
+ params: ConstructorParams<ToolCallPart<Name, Params>>
1503
+ ): ToolCallPart<Name, Params> => makePart("tool-call", params)
1504
+
1383
1505
  // =============================================================================
1384
1506
  // Tool Call Result Part
1385
1507
  // =============================================================================
@@ -1389,6 +1511,7 @@ export const ToolCallPart = <const Name extends string, Params extends Schema.St
1389
1511
  *
1390
1512
  * @example
1391
1513
  * ```ts
1514
+ * import { Either } from "effect"
1392
1515
  * import { Response } from "@effect/ai"
1393
1516
  *
1394
1517
  * interface WeatherData {
@@ -1399,31 +1522,34 @@ export const ToolCallPart = <const Name extends string, Params extends Schema.St
1399
1522
  *
1400
1523
  * const toolResultPart: Response.ToolResultPart<
1401
1524
  * "get_weather",
1402
- * WeatherData
1403
- * > = Response.makePart("tool-result", {
1525
+ * WeatherData,
1526
+ * never
1527
+ * > = Response.toolResultPart({
1404
1528
  * id: "call_123",
1405
1529
  * name: "get_weather",
1406
- * result: {
1530
+ * result: Either.right({
1407
1531
  * temperature: 22,
1408
1532
  * condition: "sunny",
1409
1533
  * humidity: 65
1410
- * },
1534
+ * }),
1411
1535
  * encodedResult: {
1412
- * temperature: 22,
1413
- * condition: "sunny",
1414
- * humidity: 65
1536
+ * _tag: "Right",
1537
+ * right: {
1538
+ * temperature: 22,
1539
+ * condition: "sunny",
1540
+ * humidity: 65
1541
+ * }
1415
1542
  * },
1416
1543
  * providerExecuted: false
1417
1544
  * })
1418
1545
  * ```
1419
1546
  *
1420
- * @template Name - String literal type for the tool name
1421
- * @template Result - Type of the tool result
1422
- *
1423
1547
  * @since 1.0.0
1424
1548
  * @category Models
1425
1549
  */
1426
- export interface ToolResultPart<Name extends string, Result> extends BasePart<"tool-result", ToolResultPartMetadata> {
1550
+ export interface ToolResultPart<Name extends string, Success, Failure>
1551
+ extends BasePart<"tool-result", ToolResultPartMetadata>
1552
+ {
1427
1553
  /**
1428
1554
  * Unique identifier matching the original tool call.
1429
1555
  */
@@ -1436,11 +1562,11 @@ export interface ToolResultPart<Name extends string, Result> extends BasePart<"t
1436
1562
  /**
1437
1563
  * The decoded result returned by the tool execution.
1438
1564
  */
1439
- readonly result: Result
1565
+ readonly result: Either.Either<Success, Failure>
1440
1566
  /**
1441
1567
  * The encoded result for serialization purposes.
1442
1568
  */
1443
- readonly encodedResult: unknown
1569
+ readonly encodedResult: Schema.EitherEncoded<unknown, unknown>
1444
1570
  /**
1445
1571
  * Optional provider-specific name for the tool, which can be useful when the
1446
1572
  * name of the tool in the `Toolkit` and the name of the tool used by the
@@ -1475,7 +1601,7 @@ export interface ToolResultPartEncoded extends BasePartEncoded<"tool-result", To
1475
1601
  /**
1476
1602
  * The result returned by the tool execution.
1477
1603
  */
1478
- readonly result: unknown
1604
+ readonly result: Schema.EitherEncoded<unknown, unknown>
1479
1605
  /**
1480
1606
  * Optional provider-specific name for the tool, which can be useful when the
1481
1607
  * name of the tool in the `Toolkit` and the name of the tool used by the
@@ -1506,19 +1632,22 @@ export interface ToolResultPartMetadata extends ProviderMetadata {}
1506
1632
  * @since 1.0.0
1507
1633
  * @category Schemas
1508
1634
  */
1509
- export const ToolResultPart = <const Name extends string, Result extends Schema.Schema.Any>(
1510
- /**
1511
- * Name of the tool.
1512
- */
1635
+ export const ToolResultPart = <
1636
+ const Name extends string,
1637
+ Success extends Schema.Schema.Any,
1638
+ Failure extends Schema.Schema.All
1639
+ >(
1513
1640
  name: Name,
1514
- /**
1515
- * Schema for the tool result.
1516
- */
1517
- result: Result
1641
+ success: Success,
1642
+ failure: Failure
1518
1643
  ): Schema.Schema<
1519
- ToolResultPart<Name, Schema.Schema.Type<Result>>,
1644
+ ToolResultPart<Name, Schema.Schema.Type<Success>, Schema.Schema.Type<Failure>>,
1520
1645
  ToolResultPartEncoded
1521
1646
  > => {
1647
+ const ResultSchema = Schema.Either({
1648
+ left: failure,
1649
+ right: success
1650
+ })
1522
1651
  const Base = Schema.Struct({
1523
1652
  id: Schema.String,
1524
1653
  type: Schema.Literal("tool-result"),
@@ -1527,7 +1656,7 @@ export const ToolResultPart = <const Name extends string, Result extends Schema.
1527
1656
  const Encoded = Schema.Struct({
1528
1657
  ...Base.fields,
1529
1658
  name: Schema.String,
1530
- result: Schema.encodedSchema(result),
1659
+ result: Schema.encodedSchema(ResultSchema),
1531
1660
  providerExecuted: Schema.optional(Schema.Boolean),
1532
1661
  metadata: Schema.optional(ProviderMetadata)
1533
1662
  })
@@ -1535,33 +1664,33 @@ export const ToolResultPart = <const Name extends string, Result extends Schema.
1535
1664
  ...Base.fields,
1536
1665
  [PartTypeId]: Schema.Literal(PartTypeId),
1537
1666
  name: Schema.Literal(name),
1538
- result: Schema.typeSchema(result),
1539
- encodedResult: Schema.encodedSchema(result),
1667
+ result: Schema.typeSchema(ResultSchema),
1668
+ encodedResult: Schema.encodedSchema(ResultSchema),
1540
1669
  providerExecuted: Schema.Boolean,
1541
1670
  metadata: ProviderMetadata
1542
1671
  })
1543
- const decodeParams = ParseResult.decode<any, any, never>(result as any)
1544
- const encodeParams = ParseResult.encode<any, any, never>(result as any)
1672
+ const decodeResult = ParseResult.decode<any, any, never>(ResultSchema as any)
1673
+ const encodeResult = ParseResult.encode<any, any, never>(ResultSchema as any)
1545
1674
  return Schema.transformOrFail(
1546
1675
  Encoded,
1547
1676
  Decoded,
1548
1677
  {
1549
1678
  strict: true,
1550
1679
  decode: Effect.fnUntraced(function*(encoded) {
1551
- const decoded = yield* decodeParams(encoded.result)
1680
+ const decoded = yield* decodeResult(encoded.result)
1552
1681
  const providerExecuted = encoded.providerExecuted ?? false
1553
1682
  return {
1554
1683
  ...encoded,
1555
1684
  [PartTypeId]: PartTypeId,
1556
1685
  name: encoded.name as Name,
1557
1686
  result: decoded,
1558
- encodedResult: encoded.result,
1687
+ encodedResult: encoded.result as any,
1559
1688
  metadata: encoded.metadata ?? {},
1560
1689
  providerExecuted
1561
1690
  } as const
1562
1691
  }),
1563
1692
  encode: Effect.fnUntraced(function*(decoded) {
1564
- const encoded = yield* encodeParams(decoded.result)
1693
+ const encoded = yield* encodeResult(decoded.result)
1565
1694
  return {
1566
1695
  id: decoded.id,
1567
1696
  type: decoded.type,
@@ -1573,9 +1702,19 @@ export const ToolResultPart = <const Name extends string, Result extends Schema.
1573
1702
  }
1574
1703
  })
1575
1704
  }
1576
- ).annotations({ identifier: `ToolResultPart(${name})` })
1705
+ ).annotations({ identifier: `ToolResultPart(${name})` }) as any
1577
1706
  }
1578
1707
 
1708
+ /**
1709
+ * Constructs a new tool result part.
1710
+ *
1711
+ * @since 1.0.0
1712
+ * @category Constructors
1713
+ */
1714
+ export const toolResultPart = <const Name extends string, Success, Failure>(
1715
+ params: ConstructorParams<ToolResultPart<Name, Success, Failure>>
1716
+ ): ToolResultPart<Name, Success, Failure> => makePart("tool-result", params)
1717
+
1579
1718
  // =============================================================================
1580
1719
  // File Part
1581
1720
  // =============================================================================
@@ -1651,6 +1790,14 @@ export const FilePart: Schema.Schema<FilePart, FilePartEncoded> = Schema.Struct(
1651
1790
  Schema.annotations({ identifier: "FilePart" })
1652
1791
  )
1653
1792
 
1793
+ /**
1794
+ * Constructs a new file part.
1795
+ *
1796
+ * @since 1.0.0
1797
+ * @category Constructors
1798
+ */
1799
+ export const filePart = (params: ConstructorParams<FilePart>): FilePart => makePart("file", params)
1800
+
1654
1801
  // =============================================================================
1655
1802
  // Document Source Part
1656
1803
  // =============================================================================
@@ -1743,6 +1890,15 @@ export const DocumentSourcePart: Schema.Schema<DocumentSourcePart, DocumentSourc
1743
1890
  Schema.annotations({ identifier: "DocumentSourcePart" })
1744
1891
  )
1745
1892
 
1893
+ /**
1894
+ * Constructs a new document source part.
1895
+ *
1896
+ * @since 1.0.0
1897
+ * @category Constructors
1898
+ */
1899
+ export const documentSourcePart = (params: ConstructorParams<DocumentSourcePart>): DocumentSourcePart =>
1900
+ makePart("source", { ...params, sourceType: "document" }) as any
1901
+
1746
1902
  // =============================================================================
1747
1903
  // Url Source Part
1748
1904
  // =============================================================================
@@ -1826,6 +1982,15 @@ export const UrlSourcePart: Schema.Schema<UrlSourcePart, UrlSourcePartEncoded> =
1826
1982
  Schema.annotations({ identifier: "UrlSourcePart" })
1827
1983
  )
1828
1984
 
1985
+ /**
1986
+ * Constructs a new URL source part.
1987
+ *
1988
+ * @since 1.0.0
1989
+ * @category Constructors
1990
+ */
1991
+ export const urlSourcePart = (params: ConstructorParams<UrlSourcePart>): UrlSourcePart =>
1992
+ makePart("source", { ...params, sourceType: "url" }) as any
1993
+
1829
1994
  // =============================================================================
1830
1995
  // Response Metadata Part
1831
1996
  // =============================================================================
@@ -1912,6 +2077,15 @@ export const ResponseMetadataPart: Schema.Schema<ResponseMetadataPart, ResponseM
1912
2077
  Schema.annotations({ identifier: "ResponseMetadataPart" })
1913
2078
  )
1914
2079
 
2080
+ /**
2081
+ * Constructs a new response metadata part.
2082
+ *
2083
+ * @since 1.0.0
2084
+ * @category Constructors
2085
+ */
2086
+ export const responseMetadataPart = (params: ConstructorParams<ResponseMetadataPart>): ResponseMetadataPart =>
2087
+ makePart("response-metadata", params)
2088
+
1915
2089
  // =============================================================================
1916
2090
  // Finish Part
1917
2091
  // =============================================================================
@@ -2070,6 +2244,14 @@ export const FinishPart: Schema.Schema<FinishPart, FinishPartEncoded> = Schema.S
2070
2244
  Schema.annotations({ identifier: "FinishPart" })
2071
2245
  )
2072
2246
 
2247
+ /**
2248
+ * Constructs a new finish part.
2249
+ *
2250
+ * @since 1.0.0
2251
+ * @category Constructors
2252
+ */
2253
+ export const finishPart = (params: ConstructorParams<FinishPart>): FinishPart => makePart("finish", params)
2254
+
2073
2255
  // =============================================================================
2074
2256
  // Error Part
2075
2257
  // =============================================================================
@@ -2126,3 +2308,11 @@ export const ErrorPart: Schema.Schema<ErrorPart, ErrorPartEncoded> = Schema.Stru
2126
2308
  Schema.attachPropertySignature(PartTypeId, PartTypeId),
2127
2309
  Schema.annotations({ identifier: "ErrorPart" })
2128
2310
  )
2311
+
2312
+ /**
2313
+ * Constructs a new error part.
2314
+ *
2315
+ * @since 1.0.0
2316
+ * @category Constructors
2317
+ */
2318
+ export const errorPart = (params: ConstructorParams<ErrorPart>): ErrorPart => makePart("error", params)