orchestrated 0.1.11 → 0.1.13

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/index.d.ts CHANGED
@@ -969,16 +969,60 @@ declare interface ScorerMetadata {
969
969
  export declare type ScorerName = keyof typeof SCORERS;
970
970
 
971
971
  /**
972
- * Scorer reference definition (from definitions.json)
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)
973
975
  */
974
- declare type ScorerReferenceDefinition = {
975
- type: "internal";
976
- name: string;
977
- } | {
978
- type: "custom_scorer";
979
- slug: string;
980
- fingerprint?: string;
981
- };
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">]>;
982
1026
 
983
1027
  export declare class ScorerRegistry {
984
1028
  /**
@@ -1081,14 +1125,49 @@ declare const SerializableEvaluationSchema: z.ZodObject<{
1081
1125
  fingerprint: z.ZodString;
1082
1126
  }, z.core.$strip>>;
1083
1127
  }, z.core.$strip>>;
1084
- scores: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1128
+ scores: z.ZodArray<z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
1085
1129
  type: z.ZodLiteral<"internal">;
1086
1130
  name: z.ZodString;
1087
1131
  }, z.core.$strip>, z.ZodObject<{
1088
1132
  type: z.ZodLiteral<"custom_scorer">;
1089
1133
  slug: z.ZodString;
1090
1134
  fingerprint: z.ZodOptional<z.ZodString>;
1091
- }, z.core.$strip>], "type">>;
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">]>>;
1092
1171
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
1093
1172
  fingerprint: z.ZodOptional<z.ZodString>;
1094
1173
  options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
package/index.js CHANGED
@@ -88621,7 +88621,7 @@ function trackEvaluationPromise(promise3) {
88621
88621
  const registry2 = getRegistry2();
88622
88622
  registry2.pendingEvaluations.push(promise3);
88623
88623
  }
88624
- var BundleReferenceSchema, SerializableSchemaSchema, HandlerReferenceSchema, TaskReferenceSchema, ScorerReferenceSchema, SerializableDataSourceSchema, SerializableScorerBaseSchema, SerializableScorerDefinitionSchema, SerializableCustomScorerSchema, SerializableScorerSchema, SerializableEvaluationSchema;
88624
+ var BundleReferenceSchema, SerializableSchemaSchema, HandlerReferenceSchema, TaskReferenceSchema, ScorerReferenceSchema, SerializableDataSourceSchema, SerializableScorerBaseSchema, SerializableScorerDefinitionSchema, SerializableCustomScorerSchema, SerializableScorerSchema, ScorerReferenceOrDefinitionSchema, SerializableEvaluationSchema;
88625
88625
  var init_types4 = __esm(() => {
88626
88626
  init_zod();
88627
88627
  BundleReferenceSchema = exports_external.object({
@@ -88698,12 +88698,16 @@ var init_types4 = __esm(() => {
88698
88698
  SerializableScorerDefinitionSchema,
88699
88699
  SerializableCustomScorerSchema
88700
88700
  ]);
88701
+ ScorerReferenceOrDefinitionSchema = exports_external.union([
88702
+ ScorerReferenceSchema,
88703
+ SerializableScorerSchema
88704
+ ]);
88701
88705
  SerializableEvaluationSchema = exports_external.object({
88702
88706
  name: exports_external.string(),
88703
88707
  slug: exports_external.string(),
88704
88708
  data: SerializableDataSourceSchema,
88705
88709
  task: TaskReferenceSchema.optional(),
88706
- scores: exports_external.array(ScorerReferenceSchema).min(1),
88710
+ scores: exports_external.array(ScorerReferenceOrDefinitionSchema).min(1),
88707
88711
  metadata: exports_external.record(exports_external.string(), exports_external.any()).optional(),
88708
88712
  fingerprint: exports_external.string().optional(),
88709
88713
  options: exports_external.record(exports_external.string(), exports_external.any()).optional()
@@ -88807,15 +88811,53 @@ function createScorerWrapper(scorerDef, handlerFn) {
88807
88811
  });
88808
88812
  return scorerWrapper;
88809
88813
  }
88810
- async function resolveScorer(scorerRef) {
88814
+ async function resolveScorer(scorerRefOrDef) {
88811
88815
  try {
88812
- ScorerReferenceSchema.parse(scorerRef);
88816
+ ScorerReferenceOrDefinitionSchema.parse(scorerRefOrDef);
88813
88817
  } catch (error48) {
88814
88818
  if (error48 instanceof ZodError) {
88815
- throw new ValidationError("Invalid scorer reference", error48, "resolveScorer");
88819
+ throw new ValidationError("Invalid scorer reference or definition", error48, "resolveScorer");
88816
88820
  }
88817
88821
  throw error48;
88818
88822
  }
88823
+ const isFullDefinition = "name" in scorerRefOrDef && scorerRefOrDef.type !== "internal";
88824
+ if (isFullDefinition) {
88825
+ const scorerDef2 = scorerRefOrDef;
88826
+ if (scorerDef2.type === "prompt") {
88827
+ const schemaObj = JSON.parse(scorerDef2.schema.definition);
88828
+ const zodSchema = zodFromJSONSchema(schemaObj);
88829
+ return buildPromptScorer({
88830
+ name: scorerDef2.name,
88831
+ promptTemplate: scorerDef2.promptTemplate,
88832
+ choiceScores: scorerDef2.choiceScores,
88833
+ model: scorerDef2.model,
88834
+ useCoT: scorerDef2.useCoT,
88835
+ temperature: scorerDef2.temperature,
88836
+ parameters: zodSchema
88837
+ });
88838
+ }
88839
+ if (scorerDef2.type === "custom_scorer") {
88840
+ const handlerName2 = scorerDef2.handler.reference;
88841
+ const localHandler = getLocalHandler(handlerName2);
88842
+ if (localHandler) {
88843
+ console.log(`Found handler "${handlerName2}" in local registry`);
88844
+ return createScorerWrapper(scorerDef2, localHandler);
88845
+ }
88846
+ if (scorerDef2.handler.bundle) {
88847
+ console.log(`Downloading bundle for handler "${handlerName2}"`);
88848
+ const bundlePath2 = await downloadBundle(scorerDef2.handler.bundle.file, scorerDef2.handler.bundle.fingerprint);
88849
+ const handlers2 = await loadHandlers(bundlePath2);
88850
+ const handlerFn2 = handlers2[handlerName2]?.handler;
88851
+ if (!handlerFn2) {
88852
+ throw new Error(`Handler function not found in bundle: ${handlerName2}
88853
+ Available handlers: ${Object.keys(handlers2).join(", ")}`);
88854
+ }
88855
+ return createScorerWrapper(scorerDef2, handlerFn2);
88856
+ }
88857
+ throw new Error(`Handler "${handlerName2}" not found in local registry and no bundle specified`);
88858
+ }
88859
+ }
88860
+ const scorerRef = scorerRefOrDef;
88819
88861
  if (scorerRef.type === "internal") {
88820
88862
  throw new Error(`Internal scorer "${scorerRef.name}" should be resolved by the evaluator, not the resolver`);
88821
88863
  }
@@ -118434,7 +118476,7 @@ async function resolveEvaluatorDefinitions(name, evaluator) {
118434
118476
  }
118435
118477
  const resolvedScores = [];
118436
118478
  for (const scorer2 of evaluator.scores) {
118437
- if (typeof scorer2 === "object" && scorer2 !== null && "type" in scorer2 && (scorer2.type === "internal" || scorer2.type === "custom_scorer")) {
118479
+ if (typeof scorer2 === "object" && scorer2 !== null && "type" in scorer2 && (scorer2.type === "internal" || scorer2.type === "custom_scorer" || scorer2.type === "prompt")) {
118438
118480
  const scorerDef = scorer2;
118439
118481
  if (scorerDef.type === "internal") {
118440
118482
  resolvedScores.push(scorerDef.name);
@@ -118781,4 +118823,4 @@ export {
118781
118823
  Behavioral
118782
118824
  };
118783
118825
 
118784
- //# debugId=E27B15039D5A105264756E2164756E21
118826
+ //# debugId=E93BEB0C27F3EB7E64756E2164756E21