orchestrated 0.1.10 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/index.d.ts +227 -264
  2. package/index.js +619 -28294
  3. package/index.js.map +14 -476
  4. package/package.json +7 -1
package/index.d.ts CHANGED
@@ -13,7 +13,7 @@ import { ClientOptions } from 'openai';
13
13
  import { default as default_2 } from 'openai';
14
14
  import type { Metadata } from 'openai/resources';
15
15
  import OpenAI from 'openai';
16
- import type { z } from 'zod';
16
+ import { z } from 'zod';
17
17
 
18
18
  /**
19
19
  * Async task function type
@@ -180,16 +180,6 @@ export declare const Behavioral: ((args: unknown) => Promise<Score>) & {
180
180
  definition?: SerializableScorerDefinition;
181
181
  };
182
182
 
183
- /**
184
- * Bundle reference with fingerprint
185
- */
186
- declare interface BundleReference {
187
- /** S3 URI to the bundle file (e.g., s3://bucket/fingerprint/handlers.bundle.js) */
188
- file: string;
189
- /** Bundle fingerprint from Bun's build output */
190
- fingerprint: string;
191
- }
192
-
193
183
  /**
194
184
  * Clear all tracked evaluations (for testing)
195
185
  */
@@ -270,6 +260,11 @@ declare type DataSourceDefinition = {
270
260
  method: "GET" | "POST";
271
261
  };
272
262
  options: Record<string, any>;
263
+ /**
264
+ * JSON Schema describing the arguments this dataset accepts
265
+ * Generated from the Zod schema for the dataset options
266
+ */
267
+ args?: Record<string, any>;
273
268
  };
274
269
  } | {
275
270
  type: "static";
@@ -694,17 +689,6 @@ export declare function getRunningEvaluationCount(): number;
694
689
  */
695
690
  export declare function getState(): Readonly<EvalState>;
696
691
 
697
- /**
698
- * Reference to a custom handler function stored in globalThis.handlers
699
- */
700
- declare interface HandlerReference {
701
- type: "custom_function";
702
- /** Handler name (derived from scorer name, e.g., "ExecutionHandler") */
703
- reference: string;
704
- /** Bundle reference with fingerprint */
705
- bundle?: BundleReference;
706
- }
707
-
708
692
  /**
709
693
  * Defines High-Resolution Time.
710
694
  *
@@ -719,32 +703,6 @@ declare interface HandlerReference {
719
703
  */
720
704
  declare type HrTime = [number, number];
721
705
 
722
- /**
723
- * API Gateway data source configuration
724
- */
725
- declare interface HTTPDataSourceOptions {
726
- /**
727
- * Base URL of the API Gateway endpoint
728
- * @example "https://abc123.execute-api.ap-southeast-2.amazonaws.com/prod"
729
- */
730
- baseUrl: string;
731
- /**
732
- * Cognito access token for Bearer authentication
733
- * If not provided, will use state.accessToken (from ORCHESTRATED_ACCESS_TOKEN environment variable)
734
- */
735
- accessToken?: string;
736
- /**
737
- * API Key for API Key authentication
738
- * Use this instead of accessToken for programmatic access
739
- */
740
- apiKey?: string;
741
- /**
742
- * Request timeout in milliseconds
743
- * @default 30000
744
- */
745
- timeout?: number;
746
- }
747
-
748
706
  /**
749
707
  * Initialize global state with optional overrides
750
708
  *
@@ -786,48 +744,26 @@ export declare function initState(partial?: PartialEvalState, skipAuth?: boolean
786
744
  * });
787
745
  * ```
788
746
  */
789
- export declare function interactions(options?: Partial<Omit<InteractionsDatasetOptions, "baseUrl">>): DataSourceDefinition;
747
+ export declare function interactions(options?: Partial<InteractionsDatasetOptions>): DataSourceDefinition;
790
748
 
791
749
  /**
792
- * Options for fetching the interactions dataset
750
+ * TypeScript type inferred from Zod schema
793
751
  */
794
- export declare interface InteractionsDatasetOptions extends HTTPDataSourceOptions {
795
- /**
796
- * Tenant ID to filter interactions
797
- */
798
- tenantId: string;
799
- /**
800
- * Service name to filter interactions
801
- */
802
- serviceName: string;
803
- /**
804
- * Environment to filter interactions
805
- * @example "production", "staging", "development"
806
- */
807
- environment: string;
808
- /**
809
- * Optional group name for organizing datasets in the same namespace
810
- * If not provided, defaults to "interactions"
811
- * This is used to build the source_type namespace (e.g., "live.interactions")
812
- * @example "sessions", "user-queries"
813
- */
814
- group_name?: string;
815
- /**
816
- * Optional month filter (date string)
817
- * @example "01/2026"
818
- */
819
- month?: string;
820
- /**
821
- * Optional period filter (date string)
822
- * @example "01/01/2026"
823
- */
824
- startDate?: string;
825
- /**
826
- * Optional period filter (date string)
827
- * @example "01/01/2026"
828
- */
829
- endDate?: string;
830
- }
752
+ export declare type InteractionsDatasetOptions = z.infer<typeof InteractionsDatasetOptionsSchema>;
753
+
754
+ /**
755
+ * Zod schema for interactions dataset options
756
+ */
757
+ declare const InteractionsDatasetOptionsSchema: z.ZodObject<{
758
+ tenantId: z.ZodString;
759
+ serviceName: z.ZodString;
760
+ environment: z.ZodString;
761
+ group_name: z.ZodOptional<z.ZodString>;
762
+ month: z.ZodOptional<z.ZodString>;
763
+ startDate: z.ZodOptional<z.ZodString>;
764
+ endDate: z.ZodOptional<z.ZodString>;
765
+ timeout: z.ZodOptional<z.ZodNumber>;
766
+ }, z.core.$strip>;
831
767
 
832
768
  export declare const iso: {
833
769
  writeln: (text: string) => void;
@@ -1033,28 +969,60 @@ declare interface ScorerMetadata {
1033
969
  export declare type ScorerName = keyof typeof SCORERS;
1034
970
 
1035
971
  /**
1036
- * Reference to a scorer in evaluation definitions
1037
- */
1038
- declare type ScorerReference = {
1039
- type: "internal";
1040
- name: string;
1041
- } | {
1042
- type: "custom_scorer";
1043
- slug: string;
1044
- fingerprint?: string;
1045
- };
1046
-
1047
- /**
1048
- * Scorer reference definition (from definitions.json)
1049
- */
1050
- declare type ScorerReferenceDefinition = {
1051
- type: "internal";
1052
- name: string;
1053
- } | {
1054
- type: "custom_scorer";
1055
- slug: string;
1056
- fingerprint?: string;
1057
- };
972
+ * Scorer reference or full definition
973
+ * Can be either a reference (internal or custom_scorer by slug/fingerprint)
974
+ * or a complete definition (prompt or custom_scorer with all fields)
975
+ */
976
+ declare type ScorerReferenceDefinition = ScorerReferenceOrDefinition;
977
+
978
+ declare type ScorerReferenceOrDefinition = z.infer<typeof ScorerReferenceOrDefinitionSchema>;
979
+
980
+ /**
981
+ * Union schema for scorer references or full definitions
982
+ */
983
+ declare const ScorerReferenceOrDefinitionSchema: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
984
+ type: z.ZodLiteral<"internal">;
985
+ name: z.ZodString;
986
+ }, z.core.$strip>, z.ZodObject<{
987
+ type: z.ZodLiteral<"custom_scorer">;
988
+ slug: z.ZodString;
989
+ fingerprint: z.ZodOptional<z.ZodString>;
990
+ }, z.core.$strip>], "type">, z.ZodDiscriminatedUnion<[z.ZodObject<{
991
+ name: z.ZodString;
992
+ slug: z.ZodOptional<z.ZodString>;
993
+ description: z.ZodOptional<z.ZodString>;
994
+ schema: z.ZodObject<{
995
+ type: z.ZodLiteral<"zod">;
996
+ definition: z.ZodString;
997
+ }, z.core.$strip>;
998
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
999
+ fingerprint: z.ZodOptional<z.ZodString>;
1000
+ type: z.ZodLiteral<"prompt">;
1001
+ promptTemplate: z.ZodString;
1002
+ choiceScores: z.ZodRecord<z.ZodString, z.ZodNumber>;
1003
+ model: z.ZodOptional<z.ZodString>;
1004
+ useCoT: z.ZodOptional<z.ZodBoolean>;
1005
+ temperature: z.ZodOptional<z.ZodNumber>;
1006
+ }, z.core.$strip>, z.ZodObject<{
1007
+ name: z.ZodString;
1008
+ slug: z.ZodOptional<z.ZodString>;
1009
+ description: z.ZodOptional<z.ZodString>;
1010
+ schema: z.ZodObject<{
1011
+ type: z.ZodLiteral<"zod">;
1012
+ definition: z.ZodString;
1013
+ }, z.core.$strip>;
1014
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1015
+ fingerprint: z.ZodOptional<z.ZodString>;
1016
+ type: z.ZodLiteral<"custom_scorer">;
1017
+ handler: z.ZodObject<{
1018
+ type: z.ZodLiteral<"custom_function">;
1019
+ reference: z.ZodString;
1020
+ bundle: z.ZodOptional<z.ZodObject<{
1021
+ file: z.ZodString;
1022
+ fingerprint: z.ZodString;
1023
+ }, z.core.$strip>>;
1024
+ }, z.core.$strip>;
1025
+ }, z.core.$strip>], "type">]>;
1058
1026
 
1059
1027
  export declare class ScorerRegistry {
1060
1028
  /**
@@ -1094,113 +1062,139 @@ declare type ScoreWithArgs = Score & {
1094
1062
  args?: Record<string, any>;
1095
1063
  };
1096
1064
 
1097
- /**
1098
- * Serializable custom scorer with handler function
1099
- */
1100
- export declare interface SerializableCustomScorer extends SerializableScorerBase {
1101
- /** Type of scorer */
1102
- type: "custom_scorer";
1103
- /** Reference to the custom handler function */
1104
- handler: HandlerReference;
1105
- }
1106
-
1107
- /**
1108
- * Serializable data source configuration
1109
- */
1110
- declare type SerializableDataSource = {
1111
- /** Dataset type - references a named dataset */
1112
- type: "dataset";
1113
- /** Dataset configuration */
1114
- config: {
1115
- /** Dataset name (e.g., "orchestrated.dataset.interactions") */
1116
- name: string;
1117
- /** HTTP endpoint configuration */
1118
- source: {
1119
- baseUrl: string;
1120
- path: string;
1121
- method: "GET" | "POST";
1122
- };
1123
- /** Dataset options */
1124
- options: Record<string, any>;
1125
- };
1126
- } | {
1127
- /** Static type - inline or executed data */
1128
- type: "static";
1129
- /** Static data array */
1130
- data: unknown[];
1131
- };
1132
-
1133
- /**
1134
- * Serializable evaluation definition
1135
- */
1136
- export declare interface SerializableEvaluation {
1137
- /** Evaluation name */
1138
- name: string;
1139
- /** URL-safe identifier */
1140
- slug: string;
1141
- /** Data source configuration */
1142
- data: SerializableDataSource;
1143
- /** Optional task reference */
1144
- task?: TaskReference;
1145
- /** Scorer references */
1146
- scores: ScorerReference[];
1147
- /** Optional metadata */
1148
- metadata?: Record<string, any>;
1149
- /** SHA256 fingerprint of the evaluation definition */
1150
- fingerprint?: string;
1151
- /** Evaluation options (including __schedule) */
1152
- options?: {
1153
- __schedule?: string;
1154
- [key: string]: any;
1155
- };
1156
- }
1157
-
1158
- /**
1159
- * Serializable representation of a Zod schema
1160
- * For now, we store the schema as a string that can be re-parsed
1161
- */
1162
- declare interface SerializableSchema {
1163
- /** Type of schema (for future extensibility) */
1164
- type: "zod";
1165
- /** Schema definition (stringified or encoded) */
1166
- definition: string;
1167
- }
1168
-
1169
- /**
1170
- * Base fields for all serializable scorers
1171
- */
1172
- declare interface SerializableScorerBase {
1173
- /** Scorer name */
1174
- name: string;
1175
- /** URL-safe identifier */
1176
- slug?: string;
1177
- /** Human-readable description */
1178
- description?: string;
1179
- /** Serialized schema */
1180
- schema: SerializableSchema;
1181
- /** Optional metadata (e.g., thresholds, config) */
1182
- metadata?: Record<string, any>;
1183
- /** SHA256 fingerprint of the scorer definition */
1184
- fingerprint?: string;
1185
- }
1186
-
1187
- /**
1188
- * Serializable scorer definition created via createTypedScorer
1189
- */
1190
- export declare interface SerializableScorerDefinition extends SerializableScorerBase {
1191
- /** Type of scorer */
1192
- type: "prompt";
1193
- /** LLM prompt template */
1194
- promptTemplate: string;
1195
- /** Choice to score mapping */
1196
- choiceScores: Record<string, number>;
1197
- /** Model to use (default: gpt-4o) */
1198
- model?: string;
1199
- /** Use Chain of Thought */
1200
- useCoT?: boolean;
1201
- /** Temperature for LLM */
1202
- temperature?: number;
1203
- }
1065
+ export declare type SerializableCustomScorer = z.infer<typeof SerializableCustomScorerSchema>;
1066
+
1067
+ /**
1068
+ * Custom scorer with handler schema
1069
+ */
1070
+ declare const SerializableCustomScorerSchema: z.ZodObject<{
1071
+ name: z.ZodString;
1072
+ slug: z.ZodOptional<z.ZodString>;
1073
+ description: z.ZodOptional<z.ZodString>;
1074
+ schema: z.ZodObject<{
1075
+ type: z.ZodLiteral<"zod">;
1076
+ definition: z.ZodString;
1077
+ }, z.core.$strip>;
1078
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1079
+ fingerprint: z.ZodOptional<z.ZodString>;
1080
+ type: z.ZodLiteral<"custom_scorer">;
1081
+ handler: z.ZodObject<{
1082
+ type: z.ZodLiteral<"custom_function">;
1083
+ reference: z.ZodString;
1084
+ bundle: z.ZodOptional<z.ZodObject<{
1085
+ file: z.ZodString;
1086
+ fingerprint: z.ZodString;
1087
+ }, z.core.$strip>>;
1088
+ }, z.core.$strip>;
1089
+ }, z.core.$strip>;
1090
+
1091
+ export declare type SerializableEvaluation = z.infer<typeof SerializableEvaluationSchema>;
1092
+
1093
+ /**
1094
+ * Serializable evaluation schema
1095
+ */
1096
+ declare const SerializableEvaluationSchema: z.ZodObject<{
1097
+ name: z.ZodString;
1098
+ slug: z.ZodString;
1099
+ data: z.ZodDiscriminatedUnion<[z.ZodObject<{
1100
+ type: z.ZodLiteral<"dataset">;
1101
+ config: z.ZodObject<{
1102
+ name: z.ZodString;
1103
+ source: z.ZodObject<{
1104
+ baseUrl: z.ZodString;
1105
+ path: z.ZodString;
1106
+ method: z.ZodEnum<{
1107
+ POST: "POST";
1108
+ GET: "GET";
1109
+ }>;
1110
+ }, z.core.$strip>;
1111
+ options: z.ZodRecord<z.ZodString, z.ZodAny>;
1112
+ group_name: z.ZodOptional<z.ZodString>;
1113
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1114
+ }, z.core.$strip>;
1115
+ }, z.core.$strip>, z.ZodObject<{
1116
+ type: z.ZodLiteral<"static">;
1117
+ data: z.ZodArray<z.ZodAny>;
1118
+ group_name: z.ZodOptional<z.ZodString>;
1119
+ }, z.core.$strip>], "type">;
1120
+ task: z.ZodOptional<z.ZodObject<{
1121
+ type: z.ZodLiteral<"custom_function">;
1122
+ reference: z.ZodString;
1123
+ bundle: z.ZodOptional<z.ZodObject<{
1124
+ file: z.ZodString;
1125
+ fingerprint: z.ZodString;
1126
+ }, z.core.$strip>>;
1127
+ }, z.core.$strip>>;
1128
+ scores: z.ZodArray<z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
1129
+ type: z.ZodLiteral<"internal">;
1130
+ name: z.ZodString;
1131
+ }, z.core.$strip>, z.ZodObject<{
1132
+ type: z.ZodLiteral<"custom_scorer">;
1133
+ slug: z.ZodString;
1134
+ fingerprint: z.ZodOptional<z.ZodString>;
1135
+ }, z.core.$strip>], "type">, z.ZodDiscriminatedUnion<[z.ZodObject<{
1136
+ name: z.ZodString;
1137
+ slug: z.ZodOptional<z.ZodString>;
1138
+ description: z.ZodOptional<z.ZodString>;
1139
+ schema: z.ZodObject<{
1140
+ type: z.ZodLiteral<"zod">;
1141
+ definition: z.ZodString;
1142
+ }, z.core.$strip>;
1143
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1144
+ fingerprint: z.ZodOptional<z.ZodString>;
1145
+ type: z.ZodLiteral<"prompt">;
1146
+ promptTemplate: z.ZodString;
1147
+ choiceScores: z.ZodRecord<z.ZodString, z.ZodNumber>;
1148
+ model: z.ZodOptional<z.ZodString>;
1149
+ useCoT: z.ZodOptional<z.ZodBoolean>;
1150
+ temperature: z.ZodOptional<z.ZodNumber>;
1151
+ }, z.core.$strip>, z.ZodObject<{
1152
+ name: z.ZodString;
1153
+ slug: z.ZodOptional<z.ZodString>;
1154
+ description: z.ZodOptional<z.ZodString>;
1155
+ schema: z.ZodObject<{
1156
+ type: z.ZodLiteral<"zod">;
1157
+ definition: z.ZodString;
1158
+ }, z.core.$strip>;
1159
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1160
+ fingerprint: z.ZodOptional<z.ZodString>;
1161
+ type: z.ZodLiteral<"custom_scorer">;
1162
+ handler: z.ZodObject<{
1163
+ type: z.ZodLiteral<"custom_function">;
1164
+ reference: z.ZodString;
1165
+ bundle: z.ZodOptional<z.ZodObject<{
1166
+ file: z.ZodString;
1167
+ fingerprint: z.ZodString;
1168
+ }, z.core.$strip>>;
1169
+ }, z.core.$strip>;
1170
+ }, z.core.$strip>], "type">]>>;
1171
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1172
+ fingerprint: z.ZodOptional<z.ZodString>;
1173
+ options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1174
+ }, z.core.$strip>;
1175
+
1176
+ export declare type SerializableScorerDefinition = z.infer<typeof SerializableScorerDefinitionSchema>;
1177
+
1178
+ /**
1179
+ * Prompt scorer definition schema
1180
+ */
1181
+ declare const SerializableScorerDefinitionSchema: z.ZodObject<{
1182
+ name: z.ZodString;
1183
+ slug: z.ZodOptional<z.ZodString>;
1184
+ description: z.ZodOptional<z.ZodString>;
1185
+ schema: z.ZodObject<{
1186
+ type: z.ZodLiteral<"zod">;
1187
+ definition: z.ZodString;
1188
+ }, z.core.$strip>;
1189
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1190
+ fingerprint: z.ZodOptional<z.ZodString>;
1191
+ type: z.ZodLiteral<"prompt">;
1192
+ promptTemplate: z.ZodString;
1193
+ choiceScores: z.ZodRecord<z.ZodString, z.ZodNumber>;
1194
+ model: z.ZodOptional<z.ZodString>;
1195
+ useCoT: z.ZodOptional<z.ZodBoolean>;
1196
+ temperature: z.ZodOptional<z.ZodNumber>;
1197
+ }, z.core.$strip>;
1204
1198
 
1205
1199
  /**
1206
1200
  * Creates a dataset definition for the sessions dataset
@@ -1222,48 +1216,26 @@ export declare interface SerializableScorerDefinition extends SerializableScorer
1222
1216
  * });
1223
1217
  * ```
1224
1218
  */
1225
- export declare function sessions(options?: Partial<Omit<SessionsDatasetOptions, "baseUrl">>): DataSourceDefinition;
1219
+ export declare function sessions(options?: Partial<SessionsDatasetOptions>): DataSourceDefinition;
1226
1220
 
1227
1221
  /**
1228
- * Options for fetching the sessions dataset
1222
+ * TypeScript type inferred from Zod schema
1229
1223
  */
1230
- export declare interface SessionsDatasetOptions extends HTTPDataSourceOptions {
1231
- /**
1232
- * Tenant ID to filter sessions
1233
- */
1234
- tenantId: string;
1235
- /**
1236
- * Service name to filter sessions
1237
- */
1238
- serviceName: string;
1239
- /**
1240
- * Environment to filter sessions
1241
- * @example "production", "staging", "development"
1242
- */
1243
- environment: string;
1244
- /**
1245
- * Optional group name for organizing datasets in the same namespace
1246
- * If not provided, defaults to "sessions"
1247
- * This is used to build the source_type namespace (e.g., "live.sessions")
1248
- * @example "user-sessions", "support-sessions"
1249
- */
1250
- group_name?: string;
1251
- /**
1252
- * Optional month filter (date string)
1253
- * @example "01/2026"
1254
- */
1255
- month?: string;
1256
- /**
1257
- * Optional period filter (date string)
1258
- * @example "01/01/2026"
1259
- */
1260
- startDate?: string;
1261
- /**
1262
- * Optional period filter (date string)
1263
- * @example "01/01/2026"
1264
- */
1265
- endDate?: string;
1266
- }
1224
+ export declare type SessionsDatasetOptions = z.infer<typeof SessionsDatasetOptionsSchema>;
1225
+
1226
+ /**
1227
+ * Zod schema for sessions dataset options
1228
+ */
1229
+ declare const SessionsDatasetOptionsSchema: z.ZodObject<{
1230
+ tenantId: z.ZodString;
1231
+ serviceName: z.ZodString;
1232
+ environment: z.ZodString;
1233
+ group_name: z.ZodOptional<z.ZodString>;
1234
+ month: z.ZodOptional<z.ZodString>;
1235
+ startDate: z.ZodOptional<z.ZodString>;
1236
+ endDate: z.ZodOptional<z.ZodString>;
1237
+ timeout: z.ZodOptional<z.ZodNumber>;
1238
+ }, z.core.$strip>;
1267
1239
 
1268
1240
  /**
1269
1241
  * An interface that represents a span. A span represents a single operation
@@ -1489,15 +1461,6 @@ declare type TaskContext<Expected, Ctx extends BaseCtx = BaseCtx> = {
1489
1461
  */
1490
1462
  export declare type TaskFunction<Input, Output, Expected, Ctx extends BaseCtx = BaseCtx> = SyncTaskFunction<Input, Output, Expected, Ctx> | AsyncTaskFunction<Input, Output, Expected, Ctx>;
1491
1463
 
1492
- /**
1493
- * Reference to a task handler function
1494
- */
1495
- declare interface TaskReference {
1496
- type: "custom_function";
1497
- reference: string;
1498
- bundle?: BundleReference;
1499
- }
1500
-
1501
1464
  /**
1502
1465
  * Task reference definition (from definitions.json)
1503
1466
  */