@exellix/ai-tasks 8.6.1 → 8.6.3

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 (48) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/compile/compileTaskConfiguration.d.ts.map +1 -1
  3. package/dist/compile/compileTaskConfiguration.js +13 -0
  4. package/dist/compile/compileTaskConfiguration.js.map +1 -1
  5. package/dist/core/task-sdk.d.ts.map +1 -1
  6. package/dist/core/task-sdk.js +6 -1
  7. package/dist/core/task-sdk.js.map +1 -1
  8. package/dist/errors/runTaskModelResolutionError.d.ts +1 -1
  9. package/dist/errors/runTaskModelResolutionError.d.ts.map +1 -1
  10. package/dist/errors/runTaskModelResolutionError.js +24 -3
  11. package/dist/errors/runTaskModelResolutionError.js.map +1 -1
  12. package/dist/index.d.ts +1 -1
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +1 -1
  15. package/dist/index.js.map +1 -1
  16. package/dist/invocation/resolveProfileInvocationRouting.d.ts.map +1 -1
  17. package/dist/invocation/resolveProfileInvocationRouting.js +6 -6
  18. package/dist/invocation/resolveProfileInvocationRouting.js.map +1 -1
  19. package/dist/observability/classifyRunTaskFailure.d.ts +1 -1
  20. package/dist/observability/classifyRunTaskFailure.d.ts.map +1 -1
  21. package/dist/observability/classifyRunTaskFailure.js.map +1 -1
  22. package/dist/strategies/direct-execution-strategy.d.ts.map +1 -1
  23. package/dist/strategies/direct-execution-strategy.js +3 -16
  24. package/dist/strategies/direct-execution-strategy.js.map +1 -1
  25. package/dist/utils/aiProfileModelFormat.d.ts +21 -4
  26. package/dist/utils/aiProfileModelFormat.d.ts.map +1 -1
  27. package/dist/utils/aiProfileModelFormat.js +73 -28
  28. package/dist/utils/aiProfileModelFormat.js.map +1 -1
  29. package/dist/utils/prepareMainSkillModelConfigForInvoke.d.ts +14 -0
  30. package/dist/utils/prepareMainSkillModelConfigForInvoke.d.ts.map +1 -0
  31. package/dist/utils/prepareMainSkillModelConfigForInvoke.js +108 -0
  32. package/dist/utils/prepareMainSkillModelConfigForInvoke.js.map +1 -0
  33. package/dist/utils/resolveAiProfileModel.d.ts +2 -2
  34. package/dist/utils/resolveAiProfileModel.d.ts.map +1 -1
  35. package/dist/utils/resolveAiProfileModel.js +19 -15
  36. package/dist/utils/resolveAiProfileModel.js.map +1 -1
  37. package/dist/utils/resolveRunTaskModelReferences.d.ts +2 -2
  38. package/dist/utils/resolveRunTaskModelReferences.d.ts.map +1 -1
  39. package/dist/utils/resolveRunTaskModelReferences.js +120 -178
  40. package/dist/utils/resolveRunTaskModelReferences.js.map +1 -1
  41. package/dist/utils/routeModelConfigSlots.d.ts +3 -1
  42. package/dist/utils/routeModelConfigSlots.d.ts.map +1 -1
  43. package/dist/utils/routeModelConfigSlots.js +2 -1
  44. package/dist/utils/routeModelConfigSlots.js.map +1 -1
  45. package/dist/validation/helpers.d.ts.map +1 -1
  46. package/dist/validation/helpers.js +37 -7
  47. package/dist/validation/helpers.js.map +1 -1
  48. package/package.json +3 -4
@@ -0,0 +1,108 @@
1
+ import { throwRunTaskModelResolutionError } from "../errors/runTaskModelResolutionError.js";
2
+ import { detectOpenRouterApiKeyPresent, readPreferOpenRouterFromEnv } from "../invocation/preferOpenRouterPolicy.js";
3
+ import { buildAiSkillsModelConfigForMain, isRecord } from "../types/model-config.js";
4
+ import { requireSkillModelReference } from "./aiProfileModelFormat.js";
5
+ import { resolveModelReference } from "./resolveAiProfileModel.js";
6
+ function throwSlotValidationError(slotPath, offendingValue, slot, message, skillKey) {
7
+ throwRunTaskModelResolutionError({
8
+ code: "MODEL_CONFIG_PROFILE_CHOICE_REQUIRED",
9
+ skillKey,
10
+ invocationPhase: "model-resolution",
11
+ diagnostics: { slotPath, offendingValue, slot },
12
+ }, message);
13
+ }
14
+ /**
15
+ * Map MAIN {@link RunTaskRequest.modelConfig} slots to the ai-skills invoke shape
16
+ * `{ model, provider?, ...tuning }`. Resolves profile/choice aliases to concrete gateway wire ids once.
17
+ */
18
+ export async function prepareMainSkillModelConfigForInvoke(modelConfig, llmCall, options) {
19
+ if (!isRecord(modelConfig)) {
20
+ throwRunTaskModelResolutionError({
21
+ code: "MAIN_SKILL_WIRE_MODEL_MISSING",
22
+ skillKey: options?.skillKey,
23
+ invocationPhase: "model-resolution",
24
+ diagnostics: { slotPath: "modelConfig" },
25
+ }, "runTask requires modelConfig with preActionModel, skillModel, and postActionModel before MAIN invoke.");
26
+ }
27
+ const skillSlot = modelConfig.skillModel;
28
+ if (typeof skillSlot === "string" && skillSlot.trim()) {
29
+ try {
30
+ requireSkillModelReference(skillSlot, "modelConfig.skillModel");
31
+ }
32
+ catch (err) {
33
+ throwSlotValidationError("modelConfig.skillModel", skillSlot, "skillModel", err instanceof Error ? err.message : String(err), options?.skillKey);
34
+ }
35
+ }
36
+ if (llmCall?.model) {
37
+ try {
38
+ requireSkillModelReference(llmCall.model, "llmCall.model");
39
+ }
40
+ catch (err) {
41
+ throwSlotValidationError("llmCall.model", llmCall.model, "llmCall.model", err instanceof Error ? err.message : String(err), options?.skillKey);
42
+ }
43
+ }
44
+ let overlayed;
45
+ try {
46
+ overlayed = buildAiSkillsModelConfigForMain(modelConfig, llmCall);
47
+ }
48
+ catch (err) {
49
+ throwRunTaskModelResolutionError({
50
+ code: "MAIN_SKILL_WIRE_MODEL_MISSING",
51
+ skillKey: options?.skillKey,
52
+ invocationPhase: "model-resolution",
53
+ diagnostics: {
54
+ slotPath: "modelConfig.skillModel",
55
+ offendingValue: typeof skillSlot === "string" ? skillSlot : undefined,
56
+ slot: "skillModel",
57
+ },
58
+ }, err instanceof Error ? err.message : String(err));
59
+ }
60
+ const modelRef = (typeof overlayed.model === "string" ? overlayed.model.trim() : "") ||
61
+ (typeof overlayed.modelId === "string" ? overlayed.modelId.trim() : "");
62
+ if (!modelRef) {
63
+ throwRunTaskModelResolutionError({
64
+ code: "MAIN_SKILL_WIRE_MODEL_MISSING",
65
+ skillKey: options?.skillKey,
66
+ invocationPhase: "model-resolution",
67
+ diagnostics: {
68
+ slotPath: "modelConfig.skillModel",
69
+ offendingValue: typeof skillSlot === "string" ? skillSlot : undefined,
70
+ slot: "skillModel",
71
+ },
72
+ }, "MAIN skill invoke requires modelConfig.model (profile/choice or concrete provider id).");
73
+ }
74
+ let resolvedWire;
75
+ try {
76
+ const wire = await resolveModelReference(modelRef, {
77
+ preferOpenRouter: options?.preferOpenRouter ?? readPreferOpenRouterFromEnv(),
78
+ openrouterApiKeyPresent: options?.openrouterApiKeyPresent ?? detectOpenRouterApiKeyPresent(),
79
+ });
80
+ if (!wire?.trim()) {
81
+ throw new Error(`Model reference "${modelRef}" did not resolve to a concrete gateway wire model id.`);
82
+ }
83
+ resolvedWire = wire.trim();
84
+ }
85
+ catch (err) {
86
+ throwRunTaskModelResolutionError({
87
+ code: "MAIN_SKILL_MODEL_RESOLUTION_FAILED",
88
+ skillKey: options?.skillKey,
89
+ invocationPhase: "model-resolution",
90
+ diagnostics: {
91
+ slotPath: "modelConfig.skillModel",
92
+ offendingValue: modelRef,
93
+ slot: "skillModel",
94
+ },
95
+ }, err instanceof Error ? err.message : String(err));
96
+ }
97
+ const result = {
98
+ ...overlayed,
99
+ model: resolvedWire,
100
+ };
101
+ delete result.modelId;
102
+ return result;
103
+ }
104
+ /** Fail-fast preflight: same checks as {@link prepareMainSkillModelConfigForInvoke} without returning the overlay. */
105
+ export async function assertMainSkillModelConfigReadyForInvoke(modelConfig, llmCall, options) {
106
+ await prepareMainSkillModelConfigForInvoke(modelConfig, llmCall, options);
107
+ }
108
+ //# sourceMappingURL=prepareMainSkillModelConfigForInvoke.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepareMainSkillModelConfigForInvoke.js","sourceRoot":"","sources":["../../src/utils/prepareMainSkillModelConfigForInvoke.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,0CAA0C,CAAC;AAC5F,OAAO,EAAE,6BAA6B,EAAE,2BAA2B,EAAE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AA4B;QACtC,GAAG,SAAS;QACZ,KAAK,EAAE,YAAY;KACpB,CAAC;IACF,OAAO,MAAM,CAAC,OAAO,CAAC;IACtB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,sHAAsH;AACtH,MAAM,CAAC,KAAK,UAAU,wCAAwC,CAC5D,WAAoB,EACpB,OAAuB,EACvB,OAA4C;IAE5C,MAAM,oCAAoC,CAAC,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC5E,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { ProfileCatalogLane, RegistrySourceMode } from "@x12i/ai-profiles";
2
- export { formatResolvedProfileModelId, isResolvableModelAlias, normalizeXynthesisModelAlias, toStrictAiProfileResolveInput, } from "./aiProfileModelFormat.js";
2
+ export { formatResolvedProfileModelId, isResolvableModelAlias, isStrictProfileChoiceKey, normalizeXynthesisModelAlias, requireSkillModelReference, requireStrictProfileChoiceKey, requireXynthesisModelReference, toStrictAiProfileResolveInput, } from "./aiProfileModelFormat.js";
3
3
  /** @deprecated Prefer {@link isResolvableModelAlias}. Kept for tests and call sites expecting the old name. */
4
4
  export declare function isAliasLikeModelValue(value: string): boolean;
5
5
  export type ResolveModelReferenceOptions = {
@@ -14,7 +14,7 @@ export type ResolveModelReferenceOptions = {
14
14
  };
15
15
  /**
16
16
  * Resolve a model reference for `@exellix/ai-skills` MAIN: pass through concrete ids and
17
- * unrecognized strings; map known ai-profiles aliases to concrete provider/model ids.
17
+ * map known ai-profiles aliases to concrete provider/model ids via ai-skills.
18
18
  */
19
19
  export declare function resolveModelReference(value: string | undefined, options?: ResolveModelReferenceOptions): Promise<string | undefined>;
20
20
  export type ResolveModelReferenceForXynthesisOptions = {
@@ -1 +1 @@
1
- {"version":3,"file":"resolveAiProfileModel.d.ts","sourceRoot":"","sources":["../../src/utils/resolveAiProfileModel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;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B,MAAM,2BAA2B,CAAC;AAEnC,+GAA+G;AAC/G,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED,MAAM,MAAM,4BAA4B,GAAG;IACzC,2FAA2F;IAC3F,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,0CAA0C;IAC1C,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,OAAO,CAAC,EAAE,4BAA4B,GACrC,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAW7B;AAED,MAAM,MAAM,wCAAwC,GAAG;IACrD,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,wBAAsB,iCAAiC,CACrD,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,OAAO,CAAC,EAAE,wCAAwC,GACjD,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAkC7B"}
@@ -1,16 +1,15 @@
1
- import { resolveProfileInvocationRouting } from "../invocation/resolveProfileInvocationRouting.js";
2
- import { resolvePreferOpenRouterPolicy } from "../invocation/preferOpenRouterPolicy.js";
1
+ import { resolveSkillProfileToWireModel } from "@exellix/ai-skills";
3
2
  import { formatXynthesisConcreteModelRejectedMessage, throwRunTaskModelResolutionError, } from "../errors/runTaskModelResolutionError.js";
4
- import { isResolvableModelAlias, normalizeXynthesisModelAlias, toStrictAiProfileResolveInput, } from "./aiProfileModelFormat.js";
3
+ import { isResolvableModelAlias, normalizeXynthesisModelAlias, requireXynthesisModelReference, } from "./aiProfileModelFormat.js";
5
4
  import { isConcreteModelId } from "./concreteModelId.js";
6
- export { formatResolvedProfileModelId, isResolvableModelAlias, normalizeXynthesisModelAlias, toStrictAiProfileResolveInput, } from "./aiProfileModelFormat.js";
5
+ export { formatResolvedProfileModelId, isResolvableModelAlias, isStrictProfileChoiceKey, normalizeXynthesisModelAlias, requireSkillModelReference, requireStrictProfileChoiceKey, requireXynthesisModelReference, toStrictAiProfileResolveInput, } from "./aiProfileModelFormat.js";
7
6
  /** @deprecated Prefer {@link isResolvableModelAlias}. Kept for tests and call sites expecting the old name. */
8
7
  export function isAliasLikeModelValue(value) {
9
8
  return isResolvableModelAlias(value);
10
9
  }
11
10
  /**
12
11
  * Resolve a model reference for `@exellix/ai-skills` MAIN: pass through concrete ids and
13
- * unrecognized strings; map known ai-profiles aliases to concrete provider/model ids.
12
+ * map known ai-profiles aliases to concrete provider/model ids via ai-skills.
14
13
  */
15
14
  export async function resolveModelReference(value, options) {
16
15
  if (value === undefined)
@@ -18,20 +17,12 @@ export async function resolveModelReference(value, options) {
18
17
  const trimmed = value.trim();
19
18
  if (!trimmed)
20
19
  return undefined;
21
- if (isConcreteModelId(trimmed))
22
- return trimmed;
23
- const { effectiveUseOpenRouter } = resolvePreferOpenRouterPolicy({
20
+ return resolveSkillProfileToWireModel(trimmed, {
24
21
  preferOpenRouter: options?.preferOpenRouter ?? options?.useOpenRouter,
25
22
  openrouterApiKeyPresent: options?.openrouterApiKeyPresent,
26
- });
27
- const resolved = await resolveProfileInvocationRouting(trimmed, {
28
- phaseKind: "skill",
29
- effectiveUseOpenRouter,
30
- openrouterApiKeyPresent: options?.openrouterApiKeyPresent,
31
23
  source: options?.source,
32
24
  catalogLane: options?.catalogLane,
33
25
  });
34
- return resolved.modelId;
35
26
  }
36
27
  /**
37
28
  * Resolve a model reference for `@exellix/xynthesis` ≥4.0 (`executeXynthesisAction`):
@@ -54,6 +45,19 @@ export async function resolveModelReferenceForXynthesis(value, options) {
54
45
  },
55
46
  }, formatXynthesisConcreteModelRejectedMessage(normalized, options?.slotPath));
56
47
  }
57
- return toStrictAiProfileResolveInput(normalized);
48
+ try {
49
+ return requireXynthesisModelReference(normalized, options?.slotPath ?? "model");
50
+ }
51
+ catch (err) {
52
+ throwRunTaskModelResolutionError({
53
+ code: "MODEL_CONFIG_PROFILE_CHOICE_REQUIRED",
54
+ skillKey: options?.skillKey,
55
+ invocationPhase: "model-resolution",
56
+ diagnostics: {
57
+ slotPath: options?.slotPath,
58
+ offendingValue: normalized,
59
+ },
60
+ }, err instanceof Error ? err.message : String(err));
61
+ }
58
62
  }
59
63
  //# sourceMappingURL=resolveAiProfileModel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolveAiProfileModel.js","sourceRoot":"","sources":["../../src/utils/resolveAiProfileModel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,+BAA+B,EAAE,MAAM,kDAAkD,CAAC;AACnG,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AACxF,OAAO,EACL,2CAA2C,EAC3C,gCAAgC,GACjC,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAEL,sBAAsB,EACtB,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,EACtB,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,2BAA2B,CAAC;AAEnC,+GAA+G;AAC/G,MAAM,UAAU,qBAAqB,CAAC,KAAa;IACjD,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC;AACvC,CAAC;AAaD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,KAAyB,EACzB,OAAsC;IAEtC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,IAA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B,CAAC,KAAK,CAAC,CAAC;IACvD,IAAI,CAAC,UAAU;QAAE,OAAO,SAAS,CAAC;IAClC,IAAI,iBAAiB,CAAC,UAAU,CAAC,EAAE,CAAC;QAClC,gCAAgC,CAC9B;YACE,IAAI,EAAE,mCAAmC;YACzC,QAAQ,EAAE,OAAO,EAAE,QAAQ;YAC3B,eAAe,EAAE,kBAAkB;YACnC,WAAW,EAAE;gBACX,QAAQ,EAAE,OAAO,EAAE,QAAQ;gBAC3B,cAAc,EAAE,UAAU;aAC3B;SACF,EACD,2CAA2C,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,CAC3E,CAAC;IACJ,CAAC;IACD,IAAI,CAAC;QACH,OAAO,8BAA8B,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,IAAI,OAAO,CAAC,CAAC;IAClF,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,gCAAgC,CAC9B;YACE,IAAI,EAAE,sCAAsC;YAC5C,QAAQ,EAAE,OAAO,EAAE,QAAQ;YAC3B,eAAe,EAAE,kBAAkB;YACnC,WAAW,EAAE;gBACX,QAAQ,EAAE,OAAO,EAAE,QAAQ;gBAC3B,cAAc,EAAE,UAAU;aAC3B;SACF,EACD,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CACjD,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import type { RunTaskRequest } from "../types/task-types.js";
2
2
  /**
3
- * Resolve ai-profiles aliases on a {@link RunTaskRequest} before validation/execution.
4
- * skillModel / MAIN llmCall.model concrete provider ids; preActionModel / postActionModel → ai-profiles aliases only.
3
+ * Validate ai-profiles profile/choice keys on a {@link RunTaskRequest} before execution.
4
+ * Does not rewrite or normalize slot values faulty input is rejected.
5
5
  */
6
6
  export declare function resolveRunTaskModelReferences(request: RunTaskRequest): Promise<RunTaskRequest>;
7
7
  //# sourceMappingURL=resolveRunTaskModelReferences.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolveRunTaskModelReferences.d.ts","sourceRoot":"","sources":["../../src/utils/resolveRunTaskModelReferences.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AA6Q7D;;;GAGG;AACH,wBAAsB,6BAA6B,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CA4CpG"}
1
+ {"version":3,"file":"resolveRunTaskModelReferences.d.ts","sourceRoot":"","sources":["../../src/utils/resolveRunTaskModelReferences.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAiO7D;;;GAGG;AACH,wBAAsB,6BAA6B,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAyBpG"}
@@ -1,242 +1,184 @@
1
1
  import { isRecord } from "../types/model-config.js";
2
- import { formatXynthesisAliasResolutionFailedMessage, isRunTaskModelResolutionError, throwRunTaskModelResolutionError, } from "../errors/runTaskModelResolutionError.js";
3
- import { normalizeXynthesisModelAlias, resolveModelReference, resolveModelReferenceForXynthesis, } from "./resolveAiProfileModel.js";
4
- async function resolveLlmCallModel(llmCall, target, slotPath, ctx) {
2
+ import { throwRunTaskModelResolutionError, } from "../errors/runTaskModelResolutionError.js";
3
+ import { requireSkillModelReference, requireXynthesisModelReference, } from "./aiProfileModelFormat.js";
4
+ import { resolveModelReferenceForXynthesis } from "./resolveAiProfileModel.js";
5
+ function assertXynthesisModelSlot(value, slotPath, ctx) {
6
+ try {
7
+ requireXynthesisModelReference(value, slotPath);
8
+ }
9
+ catch (err) {
10
+ throwRunTaskModelResolutionError({
11
+ code: "MODEL_CONFIG_PROFILE_CHOICE_REQUIRED",
12
+ skillKey: ctx?.skillKey,
13
+ invocationPhase: "model-resolution",
14
+ diagnostics: { slotPath, offendingValue: value },
15
+ }, err instanceof Error ? err.message : String(err));
16
+ }
17
+ }
18
+ function assertSkillModelSlot(value, slotPath, ctx) {
19
+ try {
20
+ requireSkillModelReference(value, slotPath);
21
+ }
22
+ catch (err) {
23
+ throwRunTaskModelResolutionError({
24
+ code: "MODEL_CONFIG_PROFILE_CHOICE_REQUIRED",
25
+ skillKey: ctx?.skillKey,
26
+ invocationPhase: "model-resolution",
27
+ diagnostics: {
28
+ slotPath,
29
+ offendingValue: value,
30
+ slot: slotPath.endsWith("skillModel") ? "skillModel" : undefined,
31
+ },
32
+ }, err instanceof Error ? err.message : String(err));
33
+ }
34
+ }
35
+ async function validateLlmCallModel(llmCall, target, slotPath, ctx) {
5
36
  if (!llmCall?.model)
6
37
  return llmCall;
7
- const model = target === "xynthesis"
8
- ? await resolveModelReferenceForXynthesis(llmCall.model, {
38
+ if (target === "xynthesis") {
39
+ await resolveModelReferenceForXynthesis(llmCall.model, {
9
40
  slotPath,
10
41
  skillKey: ctx?.skillKey,
11
- })
12
- : await resolveModelReference(llmCall.model);
13
- if (model === llmCall.model)
14
- return llmCall;
15
- return { ...llmCall, model };
42
+ });
43
+ }
44
+ else {
45
+ assertSkillModelSlot(llmCall.model, slotPath, ctx);
46
+ }
47
+ return llmCall;
16
48
  }
17
- async function resolveModelConfigRecord(modelConfig, options) {
49
+ async function validateModelConfigRecord(modelConfig, options) {
18
50
  if (!modelConfig)
19
51
  return modelConfig;
20
- let changed = false;
21
- const out = { ...modelConfig };
22
52
  const basePath = options?.basePath ?? "modelConfig";
23
- if (out.xynthesisModel !== undefined) {
53
+ if (modelConfig.xynthesisModel !== undefined) {
24
54
  throw new Error("modelConfig.xynthesisModel is not accepted; use preActionModel and postActionModel.");
25
55
  }
26
56
  for (const key of ["preActionModel", "postActionModel", "skillModel", "model"]) {
27
- const v = out[key];
57
+ const v = modelConfig[key];
28
58
  if (typeof v !== "string" || !v.trim())
29
59
  continue;
30
60
  const slotPath = `${basePath}.${key}`;
31
61
  if (key === "preActionModel" ||
32
62
  key === "postActionModel" ||
33
63
  (options?.xynthesisOnly && key === "model")) {
34
- const normalized = normalizeXynthesisModelAlias(v);
35
- const resolved = await resolveXynthesisSlot(normalized, slotPath, key, options?.ctx);
36
- const next = resolved ?? normalized;
37
- if (next !== v) {
38
- out[key] = next;
39
- changed = true;
40
- }
64
+ assertXynthesisModelSlot(v, slotPath, options?.ctx);
41
65
  continue;
42
66
  }
43
67
  if (key === "skillModel" || key === "model") {
44
- try {
45
- const resolved = await resolveModelReference(v);
46
- if (resolved && resolved !== v) {
47
- out[key] = resolved;
48
- changed = true;
49
- }
50
- }
51
- catch (err) {
52
- if (isRunTaskModelResolutionError(err))
53
- throw err;
54
- if (/unknown model profile/i.test(err instanceof Error ? err.message : String(err))) {
55
- throwRunTaskModelResolutionError({
56
- code: "XYNTHESIS_ALIAS_RESOLUTION_FAILED",
57
- skillKey: options?.ctx?.skillKey,
58
- invocationPhase: "model-resolution",
59
- diagnostics: { slotPath, offendingValue: v, slot: key === "skillModel" ? "skillModel" : undefined },
60
- }, formatXynthesisAliasResolutionFailedMessage(v, slotPath));
61
- }
62
- throw err;
63
- }
68
+ assertSkillModelSlot(v, slotPath, options?.ctx);
64
69
  }
65
70
  }
66
- return changed ? out : modelConfig;
71
+ return modelConfig;
67
72
  }
68
- async function resolveXynthesisSlot(normalized, slotPath, slot, ctx) {
69
- try {
70
- return await resolveModelReferenceForXynthesis(normalized, {
71
- slotPath,
73
+ async function validateAuditLlmCall(llmCall, basePath, ctx) {
74
+ if (!llmCall)
75
+ return llmCall;
76
+ if (llmCall.audit?.model) {
77
+ await resolveModelReferenceForXynthesis(llmCall.audit.model, {
78
+ slotPath: `${basePath}.audit`,
72
79
  skillKey: ctx?.skillKey,
73
80
  });
74
81
  }
75
- catch (err) {
76
- if (isRunTaskModelResolutionError(err))
77
- throw err;
78
- if (/unknown model profile/i.test(err instanceof Error ? err.message : String(err))) {
79
- throwRunTaskModelResolutionError({
80
- code: "XYNTHESIS_ALIAS_RESOLUTION_FAILED",
81
- skillKey: ctx?.skillKey,
82
- invocationPhase: "model-resolution",
83
- diagnostics: {
84
- slotPath,
85
- offendingValue: normalized,
86
- slot: slot === "model" ? undefined : slot,
87
- },
88
- }, formatXynthesisAliasResolutionFailedMessage(normalized, slotPath));
89
- }
90
- throw err;
82
+ if (llmCall.synthesis?.model) {
83
+ await resolveModelReferenceForXynthesis(llmCall.synthesis.model, {
84
+ slotPath: `${basePath}.synthesis`,
85
+ skillKey: ctx?.skillKey,
86
+ });
91
87
  }
88
+ return llmCall;
92
89
  }
93
- async function resolveAuditLlmCall(llmCall, basePath, ctx) {
94
- if (!llmCall)
95
- return llmCall;
96
- const audit = await resolveLlmCallModel(llmCall.audit, "xynthesis", `${basePath}.audit`, ctx);
97
- const synthesis = await resolveLlmCallModel(llmCall.synthesis, "xynthesis", `${basePath}.synthesis`, ctx);
98
- if (audit === llmCall.audit && synthesis === llmCall.synthesis)
99
- return llmCall;
100
- return { audit, synthesis };
101
- }
102
- async function resolveSynthesisConfig(config, basePath, ctx) {
103
- const llmCall = await resolveLlmCallModel(config.llmCall, "xynthesis", `${basePath}.llmCall`, ctx);
104
- const modelConfig = isRecord(config.modelConfig)
105
- ? await resolveModelConfigRecord(config.modelConfig, {
90
+ async function validateSynthesisConfig(config, basePath, ctx) {
91
+ if (config.llmCall?.model) {
92
+ await resolveModelReferenceForXynthesis(config.llmCall.model, {
93
+ slotPath: `${basePath}.llmCall`,
94
+ skillKey: ctx?.skillKey,
95
+ });
96
+ }
97
+ if (isRecord(config.modelConfig)) {
98
+ await validateModelConfigRecord(config.modelConfig, {
106
99
  xynthesisOnly: true,
107
100
  basePath: `${basePath}.modelConfig`,
108
101
  ctx,
109
- })
110
- : config.modelConfig;
111
- if (llmCall === config.llmCall && modelConfig === config.modelConfig)
112
- return config;
113
- return {
114
- ...config,
115
- ...(llmCall ? { llmCall } : {}),
116
- ...(modelConfig ? { modelConfig: modelConfig } : {}),
117
- };
102
+ });
103
+ }
104
+ return config;
118
105
  }
119
- async function resolveAuditConfig(config, basePath, ctx) {
120
- const llmCall = await resolveAuditLlmCall(config.llmCall, `${basePath}.llmCall`, ctx);
121
- const auditModelConfig = isRecord(config.auditModelConfig)
122
- ? await resolveModelConfigRecord(config.auditModelConfig, {
106
+ async function validateAuditConfig(config, basePath, ctx) {
107
+ await validateAuditLlmCall(config.llmCall, `${basePath}.llmCall`, ctx);
108
+ if (isRecord(config.auditModelConfig)) {
109
+ await validateModelConfigRecord(config.auditModelConfig, {
123
110
  basePath: `${basePath}.auditModelConfig`,
124
111
  ctx,
125
- })
126
- : config.auditModelConfig;
127
- const synthesisModelConfig = isRecord(config.synthesisModelConfig)
128
- ? await resolveModelConfigRecord(config.synthesisModelConfig, {
112
+ });
113
+ }
114
+ if (isRecord(config.synthesisModelConfig)) {
115
+ await validateModelConfigRecord(config.synthesisModelConfig, {
129
116
  basePath: `${basePath}.synthesisModelConfig`,
130
117
  ctx,
131
- })
132
- : config.synthesisModelConfig;
133
- if (llmCall === config.llmCall &&
134
- auditModelConfig === config.auditModelConfig &&
135
- synthesisModelConfig === config.synthesisModelConfig) {
136
- return config;
137
- }
138
- return {
139
- ...config,
140
- ...(llmCall ? { llmCall } : {}),
141
- ...(auditModelConfig ? { auditModelConfig: auditModelConfig } : {}),
142
- ...(synthesisModelConfig
143
- ? { synthesisModelConfig: synthesisModelConfig }
144
- : {}),
145
- };
118
+ });
119
+ }
120
+ return config;
146
121
  }
147
- async function resolvePolishConfig(config, basePath, ctx) {
148
- const llmCall = await resolveLlmCallModel(config.llmCall, "xynthesis", `${basePath}.llmCall`, ctx);
149
- const modelConfig = isRecord(config.modelConfig)
150
- ? await resolveModelConfigRecord(config.modelConfig, {
122
+ async function validatePolishConfig(config, basePath, ctx) {
123
+ if (config.llmCall?.model) {
124
+ await resolveModelReferenceForXynthesis(config.llmCall.model, {
125
+ slotPath: `${basePath}.llmCall`,
126
+ skillKey: ctx?.skillKey,
127
+ });
128
+ }
129
+ if (isRecord(config.modelConfig)) {
130
+ await validateModelConfigRecord(config.modelConfig, {
151
131
  basePath: `${basePath}.modelConfig`,
152
132
  ctx,
153
- })
154
- : config.modelConfig;
155
- if (llmCall === config.llmCall && modelConfig === config.modelConfig)
156
- return config;
157
- return {
158
- ...config,
159
- ...(llmCall ? { llmCall } : {}),
160
- ...(modelConfig ? { modelConfig: modelConfig } : {}),
161
- };
133
+ });
134
+ }
135
+ return config;
162
136
  }
163
- async function resolveExecutionStep(step, stepIndex, ctx) {
137
+ async function validateExecutionStep(step, stepIndex, ctx) {
164
138
  if (!step.config || typeof step.config !== "object")
165
139
  return step;
166
140
  const cfg = step.config;
167
141
  const basePath = `executionPipeline[${stepIndex}].config`;
168
142
  if (step.type === "synthesized-context") {
169
- const resolved = await resolveSynthesisConfig(cfg, basePath, ctx);
170
- if (resolved === cfg)
171
- return step;
172
- return { ...step, config: resolved };
143
+ await validateSynthesisConfig(cfg, basePath, ctx);
144
+ return step;
173
145
  }
174
146
  if (step.phase === "post") {
175
147
  if (step.type === "audit") {
176
- const resolved = await resolveAuditConfig(cfg, basePath, ctx);
177
- if (resolved === cfg)
178
- return step;
179
- return { ...step, config: resolved };
148
+ await validateAuditConfig(cfg, basePath, ctx);
149
+ return step;
180
150
  }
181
151
  if (step.type === "polish") {
182
- const resolved = await resolvePolishConfig(cfg, basePath, ctx);
183
- if (resolved === cfg)
184
- return step;
185
- return { ...step, config: resolved };
152
+ await validatePolishConfig(cfg, basePath, ctx);
153
+ return step;
186
154
  }
187
155
  }
188
- const modelConfig = isRecord(cfg.modelConfig)
189
- ? await resolveModelConfigRecord(cfg.modelConfig, { basePath: `${basePath}.modelConfig`, ctx })
190
- : cfg.modelConfig;
191
- const llmCall = isRecord(cfg.llmCall)
192
- ? await resolveLlmCallModel(cfg.llmCall, "xynthesis", `${basePath}.llmCall`, ctx)
193
- : undefined;
194
- if (modelConfig === cfg.modelConfig && llmCall === cfg.llmCall)
195
- return step;
196
- return {
197
- ...step,
198
- config: {
199
- ...cfg,
200
- ...(modelConfig ? { modelConfig } : {}),
201
- ...(llmCall ? { llmCall } : {}),
202
- },
203
- };
156
+ if (isRecord(cfg.modelConfig)) {
157
+ await validateModelConfigRecord(cfg.modelConfig, { basePath: `${basePath}.modelConfig`, ctx });
158
+ }
159
+ if (isRecord(cfg.llmCall) && typeof cfg.llmCall.model === "string") {
160
+ await validateLlmCallModel(cfg.llmCall, "xynthesis", `${basePath}.llmCall`, ctx);
161
+ }
162
+ return step;
204
163
  }
205
164
  /**
206
- * Resolve ai-profiles aliases on a {@link RunTaskRequest} before validation/execution.
207
- * skillModel / MAIN llmCall.model concrete provider ids; preActionModel / postActionModel → ai-profiles aliases only.
165
+ * Validate ai-profiles profile/choice keys on a {@link RunTaskRequest} before execution.
166
+ * Does not rewrite or normalize slot values faulty input is rejected.
208
167
  */
209
168
  export async function resolveRunTaskModelReferences(request) {
210
- let changed = false;
211
- const next = { ...request };
212
169
  const ctx = { skillKey: request.skillKey };
213
- if (isRecord(next.modelConfig)) {
214
- const modelConfig = await resolveModelConfigRecord(next.modelConfig, { basePath: "modelConfig", ctx });
215
- if (modelConfig !== next.modelConfig) {
216
- next.modelConfig = modelConfig;
217
- changed = true;
218
- }
219
- }
220
- const llmCall = await resolveLlmCallModel(next.llmCall, "skill", "llmCall", ctx);
221
- if (llmCall !== next.llmCall) {
222
- next.llmCall = llmCall;
223
- changed = true;
170
+ if (isRecord(request.modelConfig)) {
171
+ await validateModelConfigRecord(request.modelConfig, { basePath: "modelConfig", ctx });
224
172
  }
225
- if (next.aiScopingOptions?.llmCall?.model) {
226
- const scopingLlmCall = await resolveLlmCallModel(next.aiScopingOptions.llmCall, "xynthesis", "aiScopingOptions.llmCall", ctx);
227
- if (scopingLlmCall !== next.aiScopingOptions.llmCall) {
228
- next.aiScopingOptions = { ...next.aiScopingOptions, llmCall: scopingLlmCall };
229
- changed = true;
230
- }
173
+ await validateLlmCallModel(request.llmCall, "skill", "llmCall", ctx);
174
+ if (request.aiScopingOptions?.llmCall?.model) {
175
+ await validateLlmCallModel(request.aiScopingOptions.llmCall, "xynthesis", "aiScopingOptions.llmCall", ctx);
231
176
  }
232
- if (Array.isArray(next.executionPipeline) && next.executionPipeline.length > 0) {
233
- const pipeline = await Promise.all(next.executionPipeline.map((step, i) => resolveExecutionStep(step, i, ctx)));
234
- const pipelineChanged = pipeline.some((step, i) => step !== next.executionPipeline[i]);
235
- if (pipelineChanged) {
236
- next.executionPipeline = pipeline;
237
- changed = true;
177
+ if (Array.isArray(request.executionPipeline) && request.executionPipeline.length > 0) {
178
+ for (let i = 0; i < request.executionPipeline.length; i++) {
179
+ await validateExecutionStep(request.executionPipeline[i], i, ctx);
238
180
  }
239
181
  }
240
- return changed ? next : request;
182
+ return request;
241
183
  }
242
184
  //# sourceMappingURL=resolveRunTaskModelReferences.js.map