@uns-kit/assistant-workflow 2.0.72
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/LICENSE +21 -0
- package/README.md +37 -0
- package/dist/clarification-policy.d.ts +64 -0
- package/dist/clarification-policy.d.ts.map +1 -0
- package/dist/clarification-policy.js +174 -0
- package/dist/clarification-policy.js.map +1 -0
- package/dist/decision.d.ts +37 -0
- package/dist/decision.d.ts.map +1 -0
- package/dist/decision.js +100 -0
- package/dist/decision.js.map +1 -0
- package/dist/definition-catalog-replay.d.ts +25 -0
- package/dist/definition-catalog-replay.d.ts.map +1 -0
- package/dist/definition-catalog-replay.js +54 -0
- package/dist/definition-catalog-replay.js.map +1 -0
- package/dist/definition-catalog.d.ts +45 -0
- package/dist/definition-catalog.d.ts.map +1 -0
- package/dist/definition-catalog.js +97 -0
- package/dist/definition-catalog.js.map +1 -0
- package/dist/definition-diagnostics.d.ts +17 -0
- package/dist/definition-diagnostics.d.ts.map +1 -0
- package/dist/definition-diagnostics.js +353 -0
- package/dist/definition-diagnostics.js.map +1 -0
- package/dist/definition-diff.d.ts +51 -0
- package/dist/definition-diff.d.ts.map +1 -0
- package/dist/definition-diff.js +172 -0
- package/dist/definition-diff.js.map +1 -0
- package/dist/definition-json.d.ts +53 -0
- package/dist/definition-json.d.ts.map +1 -0
- package/dist/definition-json.js +186 -0
- package/dist/definition-json.js.map +1 -0
- package/dist/definition-manifest.d.ts +41 -0
- package/dist/definition-manifest.d.ts.map +1 -0
- package/dist/definition-manifest.js +119 -0
- package/dist/definition-manifest.js.map +1 -0
- package/dist/definition-package-execution-json.d.ts +64 -0
- package/dist/definition-package-execution-json.d.ts.map +1 -0
- package/dist/definition-package-execution-json.js +245 -0
- package/dist/definition-package-execution-json.js.map +1 -0
- package/dist/definition-package-execution-replay.d.ts +14 -0
- package/dist/definition-package-execution-replay.d.ts.map +1 -0
- package/dist/definition-package-execution-replay.js +47 -0
- package/dist/definition-package-execution-replay.js.map +1 -0
- package/dist/definition-package-executor.d.ts +52 -0
- package/dist/definition-package-executor.d.ts.map +1 -0
- package/dist/definition-package-executor.js +70 -0
- package/dist/definition-package-executor.js.map +1 -0
- package/dist/definition-package-loader.d.ts +36 -0
- package/dist/definition-package-loader.d.ts.map +1 -0
- package/dist/definition-package-loader.js +56 -0
- package/dist/definition-package-loader.js.map +1 -0
- package/dist/definition-package-replay.d.ts +28 -0
- package/dist/definition-package-replay.d.ts.map +1 -0
- package/dist/definition-package-replay.js +74 -0
- package/dist/definition-package-replay.js.map +1 -0
- package/dist/definition-package-resolver.d.ts +31 -0
- package/dist/definition-package-resolver.d.ts.map +1 -0
- package/dist/definition-package-resolver.js +60 -0
- package/dist/definition-package-resolver.js.map +1 -0
- package/dist/definition-package-review.d.ts +29 -0
- package/dist/definition-package-review.d.ts.map +1 -0
- package/dist/definition-package-review.js +74 -0
- package/dist/definition-package-review.js.map +1 -0
- package/dist/definition-package-run-report.d.ts +25 -0
- package/dist/definition-package-run-report.d.ts.map +1 -0
- package/dist/definition-package-run-report.js +37 -0
- package/dist/definition-package-run-report.js.map +1 -0
- package/dist/definition-package-run.d.ts +20 -0
- package/dist/definition-package-run.d.ts.map +1 -0
- package/dist/definition-package-run.js +41 -0
- package/dist/definition-package-run.js.map +1 -0
- package/dist/definition-package-selection.d.ts +29 -0
- package/dist/definition-package-selection.d.ts.map +1 -0
- package/dist/definition-package-selection.js +68 -0
- package/dist/definition-package-selection.js.map +1 -0
- package/dist/definition-package-smoke.d.ts +74 -0
- package/dist/definition-package-smoke.d.ts.map +1 -0
- package/dist/definition-package-smoke.js +184 -0
- package/dist/definition-package-smoke.js.map +1 -0
- package/dist/definition-package.d.ts +36 -0
- package/dist/definition-package.d.ts.map +1 -0
- package/dist/definition-package.js +114 -0
- package/dist/definition-package.js.map +1 -0
- package/dist/definition-tuning-approval.d.ts +39 -0
- package/dist/definition-tuning-approval.d.ts.map +1 -0
- package/dist/definition-tuning-approval.js +207 -0
- package/dist/definition-tuning-approval.js.map +1 -0
- package/dist/definition-tuning-json.d.ts +58 -0
- package/dist/definition-tuning-json.d.ts.map +1 -0
- package/dist/definition-tuning-json.js +276 -0
- package/dist/definition-tuning-json.js.map +1 -0
- package/dist/definition-tuning-promotion.d.ts +120 -0
- package/dist/definition-tuning-promotion.d.ts.map +1 -0
- package/dist/definition-tuning-promotion.js +460 -0
- package/dist/definition-tuning-promotion.js.map +1 -0
- package/dist/definition-tuning-replay.d.ts +14 -0
- package/dist/definition-tuning-replay.d.ts.map +1 -0
- package/dist/definition-tuning-replay.js +50 -0
- package/dist/definition-tuning-replay.js.map +1 -0
- package/dist/definition-tuning-review-artifact.d.ts +56 -0
- package/dist/definition-tuning-review-artifact.d.ts.map +1 -0
- package/dist/definition-tuning-review-artifact.js +302 -0
- package/dist/definition-tuning-review-artifact.js.map +1 -0
- package/dist/definition-tuning-review.d.ts +59 -0
- package/dist/definition-tuning-review.d.ts.map +1 -0
- package/dist/definition-tuning-review.js +213 -0
- package/dist/definition-tuning-review.js.map +1 -0
- package/dist/definition-tuning-source-patch.d.ts +43 -0
- package/dist/definition-tuning-source-patch.d.ts.map +1 -0
- package/dist/definition-tuning-source-patch.js +214 -0
- package/dist/definition-tuning-source-patch.js.map +1 -0
- package/dist/definition-tuning.d.ts +73 -0
- package/dist/definition-tuning.d.ts.map +1 -0
- package/dist/definition-tuning.js +426 -0
- package/dist/definition-tuning.js.map +1 -0
- package/dist/definition.d.ts +189 -0
- package/dist/definition.d.ts.map +1 -0
- package/dist/definition.js +494 -0
- package/dist/definition.js.map +1 -0
- package/dist/direct-route-invocation.d.ts +132 -0
- package/dist/direct-route-invocation.d.ts.map +1 -0
- package/dist/direct-route-invocation.js +325 -0
- package/dist/direct-route-invocation.js.map +1 -0
- package/dist/direct-route-policy.d.ts +25 -0
- package/dist/direct-route-policy.d.ts.map +1 -0
- package/dist/direct-route-policy.js +106 -0
- package/dist/direct-route-policy.js.map +1 -0
- package/dist/eval-case.d.ts +85 -0
- package/dist/eval-case.d.ts.map +1 -0
- package/dist/eval-case.js +366 -0
- package/dist/eval-case.js.map +1 -0
- package/dist/eval-replay.d.ts +18 -0
- package/dist/eval-replay.d.ts.map +1 -0
- package/dist/eval-replay.js +41 -0
- package/dist/eval-replay.js.map +1 -0
- package/dist/eval-result.d.ts +46 -0
- package/dist/eval-result.d.ts.map +1 -0
- package/dist/eval-result.js +183 -0
- package/dist/eval-result.js.map +1 -0
- package/dist/eval-runner.d.ts +30 -0
- package/dist/eval-runner.d.ts.map +1 -0
- package/dist/eval-runner.js +57 -0
- package/dist/eval-runner.js.map +1 -0
- package/dist/eval-suite.d.ts +43 -0
- package/dist/eval-suite.d.ts.map +1 -0
- package/dist/eval-suite.js +101 -0
- package/dist/eval-suite.js.map +1 -0
- package/dist/execution-plan.d.ts +43 -0
- package/dist/execution-plan.d.ts.map +1 -0
- package/dist/execution-plan.js +187 -0
- package/dist/execution-plan.js.map +1 -0
- package/dist/hosted-tool-policy.d.ts +70 -0
- package/dist/hosted-tool-policy.d.ts.map +1 -0
- package/dist/hosted-tool-policy.js +228 -0
- package/dist/hosted-tool-policy.js.map +1 -0
- package/dist/index.d.ts +73 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/memory-policy.d.ts +55 -0
- package/dist/memory-policy.d.ts.map +1 -0
- package/dist/memory-policy.js +187 -0
- package/dist/memory-policy.js.map +1 -0
- package/dist/memory-updates.d.ts +39 -0
- package/dist/memory-updates.d.ts.map +1 -0
- package/dist/memory-updates.js +110 -0
- package/dist/memory-updates.js.map +1 -0
- package/dist/outcome-trace.d.ts +79 -0
- package/dist/outcome-trace.d.ts.map +1 -0
- package/dist/outcome-trace.js +117 -0
- package/dist/outcome-trace.js.map +1 -0
- package/dist/outcome.d.ts +97 -0
- package/dist/outcome.d.ts.map +1 -0
- package/dist/outcome.js +160 -0
- package/dist/outcome.js.map +1 -0
- package/dist/planner-compiler.d.ts +14 -0
- package/dist/planner-compiler.d.ts.map +1 -0
- package/dist/planner-compiler.js +26 -0
- package/dist/planner-compiler.js.map +1 -0
- package/dist/planning.d.ts +36 -0
- package/dist/planning.d.ts.map +1 -0
- package/dist/planning.js +141 -0
- package/dist/planning.js.map +1 -0
- package/dist/policy-resolution.d.ts +10 -0
- package/dist/policy-resolution.d.ts.map +1 -0
- package/dist/policy-resolution.js +30 -0
- package/dist/policy-resolution.js.map +1 -0
- package/dist/run-evaluation.d.ts +29 -0
- package/dist/run-evaluation.d.ts.map +1 -0
- package/dist/run-evaluation.js +128 -0
- package/dist/run-evaluation.js.map +1 -0
- package/dist/run-parity.d.ts +24 -0
- package/dist/run-parity.d.ts.map +1 -0
- package/dist/run-parity.js +36 -0
- package/dist/run-parity.js.map +1 -0
- package/dist/run-report-batch.d.ts +150 -0
- package/dist/run-report-batch.d.ts.map +1 -0
- package/dist/run-report-batch.js +391 -0
- package/dist/run-report-batch.js.map +1 -0
- package/dist/run-report-json.d.ts +76 -0
- package/dist/run-report-json.d.ts.map +1 -0
- package/dist/run-report-json.js +451 -0
- package/dist/run-report-json.js.map +1 -0
- package/dist/run-report.d.ts +22 -0
- package/dist/run-report.d.ts.map +1 -0
- package/dist/run-report.js +46 -0
- package/dist/run-report.js.map +1 -0
- package/dist/run.d.ts +20 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +36 -0
- package/dist/run.js.map +1 -0
- package/dist/tool-bindings.d.ts +42 -0
- package/dist/tool-bindings.d.ts.map +1 -0
- package/dist/tool-bindings.js +124 -0
- package/dist/tool-bindings.js.map +1 -0
- package/dist/tool-capabilities.d.ts +37 -0
- package/dist/tool-capabilities.d.ts.map +1 -0
- package/dist/tool-capabilities.js +91 -0
- package/dist/tool-capabilities.js.map +1 -0
- package/dist/tool-executor.d.ts +63 -0
- package/dist/tool-executor.d.ts.map +1 -0
- package/dist/tool-executor.js +176 -0
- package/dist/tool-executor.js.map +1 -0
- package/dist/tool-fixtures.d.ts +18 -0
- package/dist/tool-fixtures.d.ts.map +1 -0
- package/dist/tool-fixtures.js +52 -0
- package/dist/tool-fixtures.js.map +1 -0
- package/dist/tool-invocations.d.ts +31 -0
- package/dist/tool-invocations.d.ts.map +1 -0
- package/dist/tool-invocations.js +79 -0
- package/dist/tool-invocations.js.map +1 -0
- package/dist/tool-provider-executors.d.ts +43 -0
- package/dist/tool-provider-executors.d.ts.map +1 -0
- package/dist/tool-provider-executors.js +59 -0
- package/dist/tool-provider-executors.js.map +1 -0
- package/dist/tool-result-cache.d.ts +37 -0
- package/dist/tool-result-cache.d.ts.map +1 -0
- package/dist/tool-result-cache.js +173 -0
- package/dist/tool-result-cache.js.map +1 -0
- package/dist/tool-results.d.ts +41 -0
- package/dist/tool-results.d.ts.map +1 -0
- package/dist/tool-results.js +137 -0
- package/dist/tool-results.js.map +1 -0
- package/dist/tool-runtime.d.ts +46 -0
- package/dist/tool-runtime.d.ts.map +1 -0
- package/dist/tool-runtime.js +163 -0
- package/dist/tool-runtime.js.map +1 -0
- package/dist/tool-selection-evaluation.d.ts +214 -0
- package/dist/tool-selection-evaluation.d.ts.map +1 -0
- package/dist/tool-selection-evaluation.js +773 -0
- package/dist/tool-selection-evaluation.js.map +1 -0
- package/dist/tool-selection-json.d.ts +71 -0
- package/dist/tool-selection-json.d.ts.map +1 -0
- package/dist/tool-selection-json.js +284 -0
- package/dist/tool-selection-json.js.map +1 -0
- package/dist/tool-selection-policy.d.ts +81 -0
- package/dist/tool-selection-policy.d.ts.map +1 -0
- package/dist/tool-selection-policy.js +376 -0
- package/dist/tool-selection-policy.js.map +1 -0
- package/dist/tool-selection-replay.d.ts +26 -0
- package/dist/tool-selection-replay.d.ts.map +1 -0
- package/dist/tool-selection-replay.js +88 -0
- package/dist/tool-selection-replay.js.map +1 -0
- package/dist/tool-selection-rules.d.ts +46 -0
- package/dist/tool-selection-rules.d.ts.map +1 -0
- package/dist/tool-selection-rules.js +183 -0
- package/dist/tool-selection-rules.js.map +1 -0
- package/dist/tool-selection-trace-export.d.ts +37 -0
- package/dist/tool-selection-trace-export.d.ts.map +1 -0
- package/dist/tool-selection-trace-export.js +324 -0
- package/dist/tool-selection-trace-export.js.map +1 -0
- package/dist/trace-events.d.ts +14 -0
- package/dist/trace-events.d.ts.map +1 -0
- package/dist/trace-events.js +65 -0
- package/dist/trace-events.js.map +1 -0
- package/dist/trace-payload.d.ts +24 -0
- package/dist/trace-payload.d.ts.map +1 -0
- package/dist/trace-payload.js +113 -0
- package/dist/trace-payload.js.map +1 -0
- package/dist/trace-replay.d.ts +276 -0
- package/dist/trace-replay.d.ts.map +1 -0
- package/dist/trace-replay.js +685 -0
- package/dist/trace-replay.js.map +1 -0
- package/dist/trace-report.d.ts +320 -0
- package/dist/trace-report.d.ts.map +1 -0
- package/dist/trace-report.js +1394 -0
- package/dist/trace-report.js.map +1 -0
- package/dist/trace-stages.d.ts +70 -0
- package/dist/trace-stages.d.ts.map +1 -0
- package/dist/trace-stages.js +103 -0
- package/dist/trace-stages.js.map +1 -0
- package/dist/value-readers.d.ts +20 -0
- package/dist/value-readers.d.ts.map +1 -0
- package/dist/value-readers.js +82 -0
- package/dist/value-readers.js.map +1 -0
- package/package.json +341 -0
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
export function defineAssistantWorkflow(definition) {
|
|
2
|
+
assertWorkflowHeader(definition);
|
|
3
|
+
assertUniqueVocabulary("intent", definition.intents);
|
|
4
|
+
assertUniqueVocabulary("subintent", definition.subintents ?? []);
|
|
5
|
+
assertUniqueVocabulary("presentation", definition.presentations ?? []);
|
|
6
|
+
assertUniqueVocabulary("derived transform", definition.derivedTransforms ?? []);
|
|
7
|
+
assertUniqueToolCapabilities(definition.tools ?? []);
|
|
8
|
+
assertUniqueToolBindings(definition.toolBindings ?? []);
|
|
9
|
+
assertUniqueDirectRoutes(definition.directRoutes ?? []);
|
|
10
|
+
assertUniqueMemorySlots(definition.memorySlots ?? []);
|
|
11
|
+
assertUniquePlanningSteps(definition.planningSteps ?? []);
|
|
12
|
+
assertUniqueClarificationRules(definition.clarificationRules ?? []);
|
|
13
|
+
assertIntentReferences(definition);
|
|
14
|
+
return definition;
|
|
15
|
+
}
|
|
16
|
+
export function normalizeAssistantWorkflowId(value) {
|
|
17
|
+
if (typeof value !== "string")
|
|
18
|
+
return null;
|
|
19
|
+
const normalized = value.trim().toLowerCase();
|
|
20
|
+
return normalized.length ? normalized : null;
|
|
21
|
+
}
|
|
22
|
+
export function getAssistantWorkflowIntentIds(workflow) {
|
|
23
|
+
return workflow.intents.map((intent) => intent.id);
|
|
24
|
+
}
|
|
25
|
+
export function getAssistantWorkflowSubintentIds(workflow) {
|
|
26
|
+
return (workflow.subintents ?? []).map((subintent) => subintent.id);
|
|
27
|
+
}
|
|
28
|
+
export function getAssistantWorkflowPresentationIds(workflow) {
|
|
29
|
+
return (workflow.presentations ?? []).map((presentation) => presentation.id);
|
|
30
|
+
}
|
|
31
|
+
export function getAssistantWorkflowDerivedTransformIds(workflow) {
|
|
32
|
+
return (workflow.derivedTransforms ?? []).map((transform) => transform.id);
|
|
33
|
+
}
|
|
34
|
+
export function findAssistantWorkflowIntent(workflow, intentId) {
|
|
35
|
+
const normalized = normalizeAssistantWorkflowId(intentId);
|
|
36
|
+
if (!normalized)
|
|
37
|
+
return null;
|
|
38
|
+
return workflow.intents.find((intent) => intent.id === normalized) ?? null;
|
|
39
|
+
}
|
|
40
|
+
export function getAssistantWorkflowToolHints(workflow, intentId, availableToolNames) {
|
|
41
|
+
const intent = findAssistantWorkflowIntent(workflow, intentId);
|
|
42
|
+
if (!intent)
|
|
43
|
+
return [];
|
|
44
|
+
return filterWorkflowToolNames(intent.toolHints ?? [], availableToolNames);
|
|
45
|
+
}
|
|
46
|
+
export function getAssistantWorkflowRequiredToolHints(workflow, intentId, availableToolNames) {
|
|
47
|
+
const intent = findAssistantWorkflowIntent(workflow, intentId);
|
|
48
|
+
if (!intent)
|
|
49
|
+
return [];
|
|
50
|
+
return filterWorkflowToolNames(intent.requiredToolHints ?? [], availableToolNames);
|
|
51
|
+
}
|
|
52
|
+
export function formatAssistantWorkflowVocabulary(items, options = {}) {
|
|
53
|
+
const includeDescriptions = options.includeDescriptions ?? true;
|
|
54
|
+
return items
|
|
55
|
+
.map((item) => {
|
|
56
|
+
const id = item.id.trim();
|
|
57
|
+
const description = item.description.trim();
|
|
58
|
+
return includeDescriptions && description.length ? `${id} = ${description}` : id;
|
|
59
|
+
})
|
|
60
|
+
.filter((entry) => entry.length > 0)
|
|
61
|
+
.join("; ");
|
|
62
|
+
}
|
|
63
|
+
export function buildAssistantWorkflowPromptFacts(workflow) {
|
|
64
|
+
return {
|
|
65
|
+
intents: formatAssistantWorkflowVocabulary(workflow.intents),
|
|
66
|
+
subintents: formatAssistantWorkflowVocabulary(workflow.subintents ?? []),
|
|
67
|
+
presentations: formatAssistantWorkflowVocabulary(workflow.presentations ?? [], { includeDescriptions: false }),
|
|
68
|
+
derivedTransforms: formatAssistantWorkflowVocabulary(workflow.derivedTransforms ?? [], { includeDescriptions: false }),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function assertWorkflowHeader(workflow) {
|
|
72
|
+
if (!workflow.id.trim().length) {
|
|
73
|
+
throw new Error("Assistant workflow id is required.");
|
|
74
|
+
}
|
|
75
|
+
if (!Number.isInteger(workflow.version) || workflow.version < 1) {
|
|
76
|
+
throw new Error("Assistant workflow version must be a positive integer.");
|
|
77
|
+
}
|
|
78
|
+
if (!workflow.intents.length) {
|
|
79
|
+
throw new Error("Assistant workflow must define at least one intent.");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function assertUniqueVocabulary(kind, items) {
|
|
83
|
+
const seen = new Set();
|
|
84
|
+
for (const item of items) {
|
|
85
|
+
const normalized = normalizeAssistantWorkflowId(item.id);
|
|
86
|
+
if (!normalized) {
|
|
87
|
+
throw new Error(`Assistant workflow ${kind} id is required.`);
|
|
88
|
+
}
|
|
89
|
+
if (normalized !== item.id) {
|
|
90
|
+
throw new Error(`Assistant workflow ${kind} id must already be normalized: ${item.id}.`);
|
|
91
|
+
}
|
|
92
|
+
if (seen.has(normalized)) {
|
|
93
|
+
throw new Error(`Duplicate assistant workflow ${kind} id: ${normalized}.`);
|
|
94
|
+
}
|
|
95
|
+
seen.add(normalized);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function assertIntentReferences(workflow) {
|
|
99
|
+
const toolCapabilities = new Map((workflow.tools ?? []).map((tool) => [tool.name, tool]));
|
|
100
|
+
const presentationIds = new Set((workflow.presentations ?? []).map((presentation) => presentation.id));
|
|
101
|
+
const toolNames = new Set(toolCapabilities.keys());
|
|
102
|
+
const directRouteIds = new Set((workflow.directRoutes ?? []).map((route) => route.id));
|
|
103
|
+
const memorySlotIds = new Set((workflow.memorySlots ?? []).map((slot) => slot.id));
|
|
104
|
+
const planningStepIds = new Set((workflow.planningSteps ?? []).map((step) => step.id));
|
|
105
|
+
const clarificationRuleIds = new Set((workflow.clarificationRules ?? []).map((rule) => rule.id));
|
|
106
|
+
const subintentIds = new Set((workflow.subintents ?? []).map((subintent) => subintent.id));
|
|
107
|
+
for (const binding of workflow.toolBindings ?? []) {
|
|
108
|
+
const capability = toolCapabilities.get(binding.name);
|
|
109
|
+
if (toolCapabilities.size > 0 && !capability) {
|
|
110
|
+
throw new Error(`Assistant workflow tool binding references unknown tool capability: ${binding.name}.`);
|
|
111
|
+
}
|
|
112
|
+
if (capability && capability.provider !== binding.provider) {
|
|
113
|
+
throw new Error(`Assistant workflow tool binding ${binding.name} provider ${binding.provider} does not match capability provider ${capability.provider}.`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
for (const step of workflow.planningSteps ?? []) {
|
|
117
|
+
for (const toolName of [...(step.toolHints ?? []), ...(step.requiredToolHints ?? [])]) {
|
|
118
|
+
if (toolNames.size > 0 && !toolNames.has(toolName)) {
|
|
119
|
+
throw new Error(`Assistant workflow planning step ${step.id} references unknown tool capability: ${toolName}.`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
for (const slotId of [...(step.readsMemory ?? []), ...(step.writesMemory ?? [])]) {
|
|
123
|
+
if (memorySlotIds.size > 0 && !memorySlotIds.has(slotId)) {
|
|
124
|
+
throw new Error(`Assistant workflow planning step ${step.id} references unknown memory slot: ${slotId}.`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
for (const rule of workflow.clarificationRules ?? []) {
|
|
129
|
+
for (const slotId of [...(rule.readsMemory ?? []), ...(rule.writesMemory ?? [])]) {
|
|
130
|
+
if (memorySlotIds.size > 0 && !memorySlotIds.has(slotId)) {
|
|
131
|
+
throw new Error(`Assistant workflow clarification rule ${rule.id} references unknown memory slot: ${slotId}.`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
for (const route of workflow.directRoutes ?? []) {
|
|
136
|
+
for (const toolName of route.requiredToolHints ?? []) {
|
|
137
|
+
if (toolNames.size > 0 && !toolNames.has(toolName)) {
|
|
138
|
+
throw new Error(`Assistant workflow direct route ${route.id} references unknown tool capability: ${toolName}.`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
for (const intent of workflow.intents) {
|
|
143
|
+
assertUniqueToolSelectionProfiles(intent);
|
|
144
|
+
assertUniquePlanningStepProfiles(intent);
|
|
145
|
+
if (intent.defaultPresentation && !presentationIds.has(intent.defaultPresentation)) {
|
|
146
|
+
throw new Error(`Assistant workflow intent ${intent.id} references unknown presentation: ${intent.defaultPresentation}.`);
|
|
147
|
+
}
|
|
148
|
+
for (const toolName of [...(intent.toolHints ?? []), ...(intent.requiredToolHints ?? [])]) {
|
|
149
|
+
if (toolNames.size > 0 && !toolNames.has(toolName)) {
|
|
150
|
+
throw new Error(`Assistant workflow intent ${intent.id} references unknown tool capability: ${toolName}.`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
for (const [profileIndex, profile] of (intent.toolSelectionProfiles ?? []).entries()) {
|
|
154
|
+
assertToolSelectionProfileCondition(intent.id, profile, toolNames);
|
|
155
|
+
for (const toolName of profile.toolHints) {
|
|
156
|
+
if (toolNames.size > 0 && !toolNames.has(toolName)) {
|
|
157
|
+
throw new Error(`Assistant workflow intent ${intent.id} tool selection profile ${profile.id} references unknown tool capability: ${toolName}.`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (!profile.toolHints.length) {
|
|
161
|
+
throw new Error(`Assistant workflow intent ${intent.id} tool selection profile ${profileIndex} must define at least one tool hint.`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
for (const [profileIndex, profile] of (intent.planningStepProfiles ?? []).entries()) {
|
|
165
|
+
assertPlanningStepProfileCondition(intent.id, profile);
|
|
166
|
+
if (!profile.planningSteps.length) {
|
|
167
|
+
throw new Error(`Assistant workflow intent ${intent.id} planning step profile ${profileIndex} must define at least one planning step.`);
|
|
168
|
+
}
|
|
169
|
+
for (const stepId of profile.planningSteps) {
|
|
170
|
+
if (planningStepIds.size > 0 && !planningStepIds.has(stepId)) {
|
|
171
|
+
throw new Error(`Assistant workflow intent ${intent.id} planning step profile ${profile.id} references unknown planning step: ${stepId}.`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
for (const toolName of profile.condition?.requiredTools ?? []) {
|
|
175
|
+
if (toolNames.size > 0 && !toolNames.has(toolName)) {
|
|
176
|
+
throw new Error(`Assistant workflow intent ${intent.id} planning step profile ${profile.id} references unknown required tool: ${toolName}.`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const condition = profile.condition;
|
|
180
|
+
if (condition?.subintent && subintentIds.size > 0 && !subintentIds.has(condition.subintent)) {
|
|
181
|
+
throw new Error(`Assistant workflow intent ${intent.id} planning step profile ${profile.id} references unknown subintent: ${condition.subintent}.`);
|
|
182
|
+
}
|
|
183
|
+
if (condition?.presentation && presentationIds.size > 0 && !presentationIds.has(condition.presentation)) {
|
|
184
|
+
throw new Error(`Assistant workflow intent ${intent.id} planning step profile ${profile.id} references unknown presentation: ${condition.presentation}.`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
for (const slotId of [
|
|
188
|
+
...(intent.memoryPolicy?.read ?? []),
|
|
189
|
+
...(intent.memoryPolicy?.write ?? []),
|
|
190
|
+
...(intent.memoryPolicy?.inject ?? []),
|
|
191
|
+
]) {
|
|
192
|
+
if (memorySlotIds.size > 0 && !memorySlotIds.has(slotId)) {
|
|
193
|
+
throw new Error(`Assistant workflow intent ${intent.id} references unknown memory slot: ${slotId}.`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
for (const routeId of intent.directRoutes ?? []) {
|
|
197
|
+
if (directRouteIds.size > 0 && !directRouteIds.has(routeId)) {
|
|
198
|
+
throw new Error(`Assistant workflow intent ${intent.id} references unknown direct route: ${routeId}.`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
for (const stepId of intent.planningSteps ?? []) {
|
|
202
|
+
if (planningStepIds.size > 0 && !planningStepIds.has(stepId)) {
|
|
203
|
+
throw new Error(`Assistant workflow intent ${intent.id} references unknown planning step: ${stepId}.`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
for (const ruleId of intent.clarificationRules ?? []) {
|
|
207
|
+
if (clarificationRuleIds.size > 0 && !clarificationRuleIds.has(ruleId)) {
|
|
208
|
+
throw new Error(`Assistant workflow intent ${intent.id} references unknown clarification rule: ${ruleId}.`);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function assertUniqueDirectRoutes(routes) {
|
|
214
|
+
assertUniqueVocabulary("direct route", routes);
|
|
215
|
+
for (const route of routes) {
|
|
216
|
+
if (route.outcomeRoute !== undefined && !normalizeAssistantWorkflowId(route.outcomeRoute)) {
|
|
217
|
+
throw new Error(`Assistant workflow direct route ${route.id} outcomeRoute must be non-empty when provided.`);
|
|
218
|
+
}
|
|
219
|
+
if (route.outcomeRoute !== undefined && normalizeAssistantWorkflowId(route.outcomeRoute) !== route.outcomeRoute) {
|
|
220
|
+
throw new Error(`Assistant workflow direct route ${route.id} outcomeRoute must already be normalized: ${route.outcomeRoute}.`);
|
|
221
|
+
}
|
|
222
|
+
assertUniqueVocabulary(`direct route ${route.id} strategy`, route.strategies ?? []);
|
|
223
|
+
for (const strategy of route.strategies ?? []) {
|
|
224
|
+
if (strategy.id !== normalizeAssistantWorkflowId(strategy.id)) {
|
|
225
|
+
throw new Error(`Assistant workflow direct route ${route.id} strategy id must already be normalized: ${strategy.id}.`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
function assertUniqueToolSelectionProfiles(intent) {
|
|
231
|
+
const seen = new Set();
|
|
232
|
+
for (const profile of intent.toolSelectionProfiles ?? []) {
|
|
233
|
+
const normalized = normalizeAssistantWorkflowId(profile.id);
|
|
234
|
+
if (!normalized) {
|
|
235
|
+
throw new Error(`Assistant workflow intent ${intent.id} tool selection profile id is required.`);
|
|
236
|
+
}
|
|
237
|
+
if (normalized !== profile.id) {
|
|
238
|
+
throw new Error(`Assistant workflow intent ${intent.id} tool selection profile id must already be normalized: ${profile.id}.`);
|
|
239
|
+
}
|
|
240
|
+
if (seen.has(normalized)) {
|
|
241
|
+
throw new Error(`Duplicate assistant workflow intent ${intent.id} tool selection profile: ${normalized}.`);
|
|
242
|
+
}
|
|
243
|
+
seen.add(normalized);
|
|
244
|
+
if (!profile.description.trim().length) {
|
|
245
|
+
throw new Error(`Assistant workflow intent ${intent.id} tool selection profile ${normalized} description is required.`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
function assertUniquePlanningStepProfiles(intent) {
|
|
250
|
+
const seen = new Set();
|
|
251
|
+
for (const profile of intent.planningStepProfiles ?? []) {
|
|
252
|
+
const normalized = normalizeAssistantWorkflowId(profile.id);
|
|
253
|
+
if (!normalized) {
|
|
254
|
+
throw new Error(`Assistant workflow intent ${intent.id} planning step profile id is required.`);
|
|
255
|
+
}
|
|
256
|
+
if (normalized !== profile.id) {
|
|
257
|
+
throw new Error(`Assistant workflow intent ${intent.id} planning step profile id must already be normalized: ${profile.id}.`);
|
|
258
|
+
}
|
|
259
|
+
if (seen.has(normalized)) {
|
|
260
|
+
throw new Error(`Duplicate assistant workflow intent ${intent.id} planning step profile: ${normalized}.`);
|
|
261
|
+
}
|
|
262
|
+
seen.add(normalized);
|
|
263
|
+
if (!profile.description.trim().length) {
|
|
264
|
+
throw new Error(`Assistant workflow intent ${intent.id} planning step profile ${normalized} description is required.`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
function assertToolSelectionProfileCondition(intentId, profile, knownToolNames) {
|
|
269
|
+
const { minHop, maxHop, selectedReason, minAttributeCount, maxAttributeCount, requiredClassifierTools, } = profile.condition ?? {};
|
|
270
|
+
if (profile.toolExclusions !== undefined) {
|
|
271
|
+
const normalizedExcludedTools = profile.toolExclusions
|
|
272
|
+
.filter((toolName) => typeof toolName === "string")
|
|
273
|
+
.map((toolName) => toolName.trim())
|
|
274
|
+
.filter((toolName) => toolName.length > 0);
|
|
275
|
+
if (!normalizedExcludedTools.length) {
|
|
276
|
+
throw new Error(`Assistant workflow intent ${intentId} tool selection profile ${profile.id} toolExclusions must contain at least one tool.`);
|
|
277
|
+
}
|
|
278
|
+
const profileToolHints = new Set(profile.toolHints.map((toolName) => toolName.trim()));
|
|
279
|
+
for (const toolName of normalizedExcludedTools) {
|
|
280
|
+
if (!knownToolNames.has(toolName)) {
|
|
281
|
+
throw new Error(`Assistant workflow intent ${intentId} tool selection profile ${profile.id} references unknown excluded tool capability: ${toolName}.`);
|
|
282
|
+
}
|
|
283
|
+
if (profileToolHints.has(toolName)) {
|
|
284
|
+
throw new Error(`Assistant workflow intent ${intentId} tool selection profile ${profile.id} must not both hint and exclude tool capability: ${toolName}.`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
if (minHop !== undefined && (!Number.isInteger(minHop) || minHop < 0)) {
|
|
289
|
+
throw new Error(`Assistant workflow intent ${intentId} tool selection profile ${profile.id} minHop must be a non-negative integer.`);
|
|
290
|
+
}
|
|
291
|
+
if (maxHop !== undefined && (!Number.isInteger(maxHop) || maxHop < 0)) {
|
|
292
|
+
throw new Error(`Assistant workflow intent ${intentId} tool selection profile ${profile.id} maxHop must be a non-negative integer.`);
|
|
293
|
+
}
|
|
294
|
+
if (minHop !== undefined && maxHop !== undefined && minHop > maxHop) {
|
|
295
|
+
throw new Error(`Assistant workflow intent ${intentId} tool selection profile ${profile.id} minHop must not exceed maxHop.`);
|
|
296
|
+
}
|
|
297
|
+
if (minAttributeCount !== undefined && (!Number.isInteger(minAttributeCount) || minAttributeCount < 0)) {
|
|
298
|
+
throw new Error(`Assistant workflow intent ${intentId} tool selection profile ${profile.id} minAttributeCount must be a non-negative integer.`);
|
|
299
|
+
}
|
|
300
|
+
if (maxAttributeCount !== undefined && (!Number.isInteger(maxAttributeCount) || maxAttributeCount < 0)) {
|
|
301
|
+
throw new Error(`Assistant workflow intent ${intentId} tool selection profile ${profile.id} maxAttributeCount must be a non-negative integer.`);
|
|
302
|
+
}
|
|
303
|
+
if (minAttributeCount !== undefined &&
|
|
304
|
+
maxAttributeCount !== undefined &&
|
|
305
|
+
minAttributeCount > maxAttributeCount) {
|
|
306
|
+
throw new Error(`Assistant workflow intent ${intentId} tool selection profile ${profile.id} minAttributeCount must not exceed maxAttributeCount.`);
|
|
307
|
+
}
|
|
308
|
+
if (requiredClassifierTools !== undefined) {
|
|
309
|
+
const normalizedRequiredTools = requiredClassifierTools
|
|
310
|
+
.filter((toolName) => typeof toolName === "string")
|
|
311
|
+
.map((toolName) => toolName.trim())
|
|
312
|
+
.filter((toolName) => toolName.length > 0);
|
|
313
|
+
if (!normalizedRequiredTools.length) {
|
|
314
|
+
throw new Error(`Assistant workflow intent ${intentId} tool selection profile ${profile.id} requiredClassifierTools must contain at least one tool.`);
|
|
315
|
+
}
|
|
316
|
+
for (const toolName of normalizedRequiredTools) {
|
|
317
|
+
if (!knownToolNames.has(toolName)) {
|
|
318
|
+
throw new Error(`Assistant workflow intent ${intentId} tool selection profile ${profile.id} references unknown classifier tool capability: ${toolName}.`);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (selectedReason !== undefined && !selectedReason.trim().length) {
|
|
323
|
+
throw new Error(`Assistant workflow intent ${intentId} tool selection profile ${profile.id} selectedReason must not be empty.`);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
function assertPlanningStepProfileCondition(intentId, profile) {
|
|
327
|
+
const { minConfidence, maxConfidence, subintent, presentation, timeWindowHint, requiredTools } = profile.condition ?? {};
|
|
328
|
+
if (minConfidence !== undefined && (!Number.isFinite(minConfidence) || minConfidence < 0 || minConfidence > 1)) {
|
|
329
|
+
throw new Error(`Assistant workflow intent ${intentId} planning step profile ${profile.id} minConfidence must be between 0 and 1.`);
|
|
330
|
+
}
|
|
331
|
+
if (maxConfidence !== undefined && (!Number.isFinite(maxConfidence) || maxConfidence < 0 || maxConfidence > 1)) {
|
|
332
|
+
throw new Error(`Assistant workflow intent ${intentId} planning step profile ${profile.id} maxConfidence must be between 0 and 1.`);
|
|
333
|
+
}
|
|
334
|
+
if (minConfidence !== undefined && maxConfidence !== undefined && minConfidence > maxConfidence) {
|
|
335
|
+
throw new Error(`Assistant workflow intent ${intentId} planning step profile ${profile.id} minConfidence must not exceed maxConfidence.`);
|
|
336
|
+
}
|
|
337
|
+
if (subintent !== undefined && !subintent.trim().length) {
|
|
338
|
+
throw new Error(`Assistant workflow intent ${intentId} planning step profile ${profile.id} subintent must not be empty.`);
|
|
339
|
+
}
|
|
340
|
+
if (presentation !== undefined && !presentation.trim().length) {
|
|
341
|
+
throw new Error(`Assistant workflow intent ${intentId} planning step profile ${profile.id} presentation must not be empty.`);
|
|
342
|
+
}
|
|
343
|
+
if (timeWindowHint !== undefined && !timeWindowHint.trim().length) {
|
|
344
|
+
throw new Error(`Assistant workflow intent ${intentId} planning step profile ${profile.id} timeWindowHint must not be empty.`);
|
|
345
|
+
}
|
|
346
|
+
if (requiredTools !== undefined && requiredTools.length === 0) {
|
|
347
|
+
throw new Error(`Assistant workflow intent ${intentId} planning step profile ${profile.id} requiredTools must not be empty.`);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
function assertUniqueClarificationRules(rules) {
|
|
351
|
+
const seen = new Set();
|
|
352
|
+
for (const rule of rules) {
|
|
353
|
+
const normalized = normalizeAssistantWorkflowId(rule.id);
|
|
354
|
+
if (!normalized) {
|
|
355
|
+
throw new Error("Assistant workflow clarification rule id is required.");
|
|
356
|
+
}
|
|
357
|
+
if (normalized !== rule.id) {
|
|
358
|
+
throw new Error(`Assistant workflow clarification rule id must already be normalized: ${rule.id}.`);
|
|
359
|
+
}
|
|
360
|
+
if (seen.has(normalized)) {
|
|
361
|
+
throw new Error(`Duplicate assistant workflow clarification rule: ${normalized}.`);
|
|
362
|
+
}
|
|
363
|
+
seen.add(normalized);
|
|
364
|
+
if (!rule.description.trim().length) {
|
|
365
|
+
throw new Error(`Assistant workflow clarification rule ${normalized} description is required.`);
|
|
366
|
+
}
|
|
367
|
+
if (rule.condition === "low_confidence" &&
|
|
368
|
+
rule.confidenceBelow !== undefined &&
|
|
369
|
+
(!Number.isFinite(rule.confidenceBelow) || rule.confidenceBelow < 0 || rule.confidenceBelow > 1)) {
|
|
370
|
+
throw new Error(`Assistant workflow clarification rule ${normalized} confidenceBelow must be between 0 and 1.`);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
function assertUniquePlanningSteps(steps) {
|
|
375
|
+
const seen = new Set();
|
|
376
|
+
for (const step of steps) {
|
|
377
|
+
const normalized = normalizeAssistantWorkflowId(step.id);
|
|
378
|
+
if (!normalized) {
|
|
379
|
+
throw new Error("Assistant workflow planning step id is required.");
|
|
380
|
+
}
|
|
381
|
+
if (normalized !== step.id) {
|
|
382
|
+
throw new Error(`Assistant workflow planning step id must already be normalized: ${step.id}.`);
|
|
383
|
+
}
|
|
384
|
+
if (seen.has(normalized)) {
|
|
385
|
+
throw new Error(`Duplicate assistant workflow planning step: ${normalized}.`);
|
|
386
|
+
}
|
|
387
|
+
seen.add(normalized);
|
|
388
|
+
if (!step.description.trim().length) {
|
|
389
|
+
throw new Error(`Assistant workflow planning step ${normalized} description is required.`);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
function assertUniqueMemorySlots(slots) {
|
|
394
|
+
const seen = new Set();
|
|
395
|
+
for (const slot of slots) {
|
|
396
|
+
const normalized = normalizeAssistantWorkflowId(slot.id);
|
|
397
|
+
if (!normalized) {
|
|
398
|
+
throw new Error("Assistant workflow memory slot id is required.");
|
|
399
|
+
}
|
|
400
|
+
if (normalized !== slot.id) {
|
|
401
|
+
throw new Error(`Assistant workflow memory slot id must already be normalized: ${slot.id}.`);
|
|
402
|
+
}
|
|
403
|
+
if (seen.has(normalized)) {
|
|
404
|
+
throw new Error(`Duplicate assistant workflow memory slot: ${normalized}.`);
|
|
405
|
+
}
|
|
406
|
+
seen.add(normalized);
|
|
407
|
+
if (!slot.description.trim().length) {
|
|
408
|
+
throw new Error(`Assistant workflow memory slot ${normalized} description is required.`);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
function assertUniqueToolCapabilities(tools) {
|
|
413
|
+
const seen = new Set();
|
|
414
|
+
for (const tool of tools) {
|
|
415
|
+
const normalized = normalizeAssistantWorkflowId(tool.name);
|
|
416
|
+
if (!normalized) {
|
|
417
|
+
throw new Error("Assistant workflow tool capability name is required.");
|
|
418
|
+
}
|
|
419
|
+
if (normalized !== tool.name) {
|
|
420
|
+
throw new Error(`Assistant workflow tool capability name must already be normalized: ${tool.name}.`);
|
|
421
|
+
}
|
|
422
|
+
if (seen.has(normalized)) {
|
|
423
|
+
throw new Error(`Duplicate assistant workflow tool capability: ${normalized}.`);
|
|
424
|
+
}
|
|
425
|
+
seen.add(normalized);
|
|
426
|
+
if (!tool.outputKinds.length) {
|
|
427
|
+
throw new Error(`Assistant workflow tool capability ${normalized} must define at least one output kind.`);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
function assertUniqueToolBindings(bindings) {
|
|
432
|
+
const seen = new Set();
|
|
433
|
+
for (const binding of bindings) {
|
|
434
|
+
const normalized = normalizeAssistantWorkflowId(binding.name);
|
|
435
|
+
if (!normalized) {
|
|
436
|
+
throw new Error("Assistant workflow tool binding name is required.");
|
|
437
|
+
}
|
|
438
|
+
if (normalized !== binding.name) {
|
|
439
|
+
throw new Error(`Assistant workflow tool binding name must already be normalized: ${binding.name}.`);
|
|
440
|
+
}
|
|
441
|
+
if (seen.has(normalized)) {
|
|
442
|
+
throw new Error(`Duplicate assistant workflow tool binding: ${normalized}.`);
|
|
443
|
+
}
|
|
444
|
+
seen.add(normalized);
|
|
445
|
+
assertToolBindingTarget(binding);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
function assertToolBindingTarget(binding) {
|
|
449
|
+
switch (binding.provider) {
|
|
450
|
+
case "local-function":
|
|
451
|
+
assertNonEmptyBindingField(binding.name, "handlerId", binding.handlerId);
|
|
452
|
+
return;
|
|
453
|
+
case "http":
|
|
454
|
+
assertNonEmptyBindingField(binding.name, "path", binding.path);
|
|
455
|
+
if (binding.method !== undefined && binding.method !== binding.method.toUpperCase()) {
|
|
456
|
+
throw new Error(`Assistant workflow tool binding ${binding.name} HTTP method must be uppercase.`);
|
|
457
|
+
}
|
|
458
|
+
return;
|
|
459
|
+
case "openai-hosted":
|
|
460
|
+
assertNonEmptyBindingField(binding.name, "hostedToolType", binding.hostedToolType);
|
|
461
|
+
return;
|
|
462
|
+
case "mcp":
|
|
463
|
+
assertNonEmptyBindingField(binding.name, "serverId", binding.serverId);
|
|
464
|
+
assertNonEmptyBindingField(binding.name, "toolName", binding.toolName);
|
|
465
|
+
return;
|
|
466
|
+
case "repl":
|
|
467
|
+
assertNonEmptyBindingField(binding.name, "runtimeId", binding.runtimeId);
|
|
468
|
+
if (!binding.functionName?.trim().length && !binding.commandTemplate?.trim().length) {
|
|
469
|
+
throw new Error(`Assistant workflow tool binding ${binding.name} must define functionName or commandTemplate.`);
|
|
470
|
+
}
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
function assertNonEmptyBindingField(toolName, fieldName, value) {
|
|
475
|
+
if (!value.trim().length) {
|
|
476
|
+
throw new Error(`Assistant workflow tool binding ${toolName} ${fieldName} is required.`);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
function filterWorkflowToolNames(rawTools, availableToolNames) {
|
|
480
|
+
const availableSet = availableToolNames ? new Set(availableToolNames) : null;
|
|
481
|
+
const out = [];
|
|
482
|
+
const seen = new Set();
|
|
483
|
+
for (const rawTool of rawTools) {
|
|
484
|
+
const tool = rawTool.trim();
|
|
485
|
+
if (!tool.length || seen.has(tool))
|
|
486
|
+
continue;
|
|
487
|
+
if (availableSet && !availableSet.has(tool))
|
|
488
|
+
continue;
|
|
489
|
+
seen.add(tool);
|
|
490
|
+
out.push(tool);
|
|
491
|
+
}
|
|
492
|
+
return out;
|
|
493
|
+
}
|
|
494
|
+
//# sourceMappingURL=definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AA2RA,MAAM,UAAU,uBAAuB,CAMrC,UAA8F;IAE9F,oBAAoB,CAAC,UAAU,CAAC,CAAC;IACjC,sBAAsB,CAAC,QAAQ,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IACrD,sBAAsB,CAAC,WAAW,EAAE,UAAU,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;IACjE,sBAAsB,CAAC,cAAc,EAAE,UAAU,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;IACvE,sB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ACpF,MAAM,IAAI,KAAK,CACb,mCAAmC,OAAO,CAAC,IAAI,+CAA+C,CAC/F,CAAC;YACJ,CAAC;YACD,OAAO;IACX,CAAC;AACH,CAAC;AAED,SAAS,0BAA0B,CAAC,QAAgB,EAAE,SAAiB,EAAE,KAAa;IACpF,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,mCAAmC,QAAQ,IAAI,SAAS,eAAe,CAAC,CAAC;IAC3F,CAAC;AACH,CAAC;AAED,SAAS,uBAAuB,CAC9B,QAA2B,EAC3B,kBAAsC;IAEtC,MAAM,YAAY,GAAG,kBAAkB,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7E,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAC5B,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,SAAS;QAC7C,IAAI,YAAY,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,SAAS;QACtD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACf,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["export type AssistantWorkflowExecutionBias = \"allow-shortcuts\" | \"llm-first\";\n\nexport type AssistantWorkflowFirstHopToolPolicy = \"auto\" | \"require-tool\";\n\nexport type AssistantWorkflowOptionalToolSelectionMode =\n | \"classifier-confirmed\"\n | \"workflow-suggested\";\n\nexport type AssistantWorkflowToolSelectionProfileCondition = {\n minHop?: number;\n maxHop?: number;\n selectedReason?: string;\n resolvedScope?: boolean;\n minAttributeCount?: number;\n maxAttributeCount?: number;\n requiredClassifierTools?: readonly string[];\n};\n\nexport type AssistantWorkflowToolSelectionProfile = AssistantWorkflowVocabularyItem & {\n toolHints: readonly string[];\n toolExclusions?: readonly string[];\n condition?: AssistantWorkflowToolSelectionProfileCondition;\n optionalToolSelectionMode?: AssistantWorkflowOptionalToolSelectionMode;\n};\n\nexport type AssistantWorkflowMemoryUse =\n | \"thread-profile-read\"\n | \"thread-profile-write\"\n | \"thread-profile-inject\";\n\nexport type AssistantWorkflowMemoryStorage =\n | \"thread-profile\"\n | \"thread-state\"\n | \"turn\";\n\nexport type AssistantWorkflowMemoryOperation = \"read\" | \"write\" | \"inject\";\n\nexport type AssistantWorkflowMemorySlotDefinition = {\n id: string;\n description: string;\n storage: AssistantWorkflowMemoryStorage;\n profileField?: string;\n maxChars?: number;\n};\n\nexport type AssistantWorkflowMemoryPolicy = {\n read?: readonly string[];\n write?: readonly string[];\n inject?: readonly string[];\n};\n\nexport type AssistantWorkflowPlanningStepKind =\n | \"classify\"\n | \"resolve\"\n | \"retrieve\"\n | \"fetch\"\n | \"derive\"\n | \"build_artifact\"\n | \"ask_clarification\"\n | \"synthesize\"\n | \"generate\";\n\nexport type AssistantWorkflowPlanningStepDefinition = AssistantWorkflowVocabularyItem & {\n kind: AssistantWorkflowPlanningStepKind;\n toolHints?: readonly string[];\n requiredToolHints?: readonly string[];\n readsMemory?: readonly string[];\n writesMemory?: readonly string[];\n optional?: boolean;\n};\n\nexport type AssistantWorkflowPlanningStepProfileCondition = {\n subintent?: string;\n presentation?: string;\n timeWindowHint?: string;\n minConfidence?: number;\n maxConfidence?: number;\n requiredTools?: readonly string[];\n};\n\nexport type AssistantWorkflowPlanningStepProfile = AssistantWorkflowVocabularyItem & {\n planningSteps: readonly string[];\n condition?: AssistantWorkflowPlanningStepProfileCondition;\n};\n\nexport type AssistantWorkflowEntityKind =\n | \"container\"\n | \"attribute\"\n | \"full_topic_path\"\n | \"time_window\";\n\nexport type AssistantWorkflowClarificationCondition =\n | \"low_confidence\"\n | \"missing_required_entity\"\n | \"multiple_entity_candidates\"\n | \"resolver_candidates_ambiguous\"\n | \"fallback_intent\";\n\nexport type AssistantWorkflowClarificationQuestionStyle =\n | \"confirm_intent\"\n | \"choose_entity\"\n | \"ask_scope\"\n | \"ask_next_step\";\n\nexport type AssistantWorkflowClarificationRuleDefinition = AssistantWorkflowVocabularyItem & {\n condition: AssistantWorkflowClarificationCondition;\n questionStyle: AssistantWorkflowClarificationQuestionStyle;\n priority?: number;\n blocksExecution?: boolean;\n /** A host-provided resolved scope satisfies this rule without model-text inference. */\n satisfiedByResolvedScope?: boolean;\n confidenceBelow?: number;\n requiredEntityKinds?: readonly AssistantWorkflowEntityKind[];\n readsMemory?: readonly string[];\n writesMemory?: readonly string[];\n};\n\nexport type AssistantWorkflowToolProvider =\n | \"local-function\"\n | \"http\"\n | \"openai-hosted\"\n | \"mcp\"\n | \"repl\";\n\nexport type AssistantWorkflowToolEffect = \"read\" | \"compute\" | \"write\";\n\nexport type AssistantWorkflowToolSideEffectRisk = \"low\" | \"medium\" | \"high\";\n\nexport type AssistantWorkflowToolCacheability =\n | \"cacheable\"\n | \"request-scoped\"\n | \"not-cacheable\";\n\nexport type AssistantWorkflowToolRetryClass = \"safe\" | \"bounded\" | \"never\";\n\nexport type AssistantWorkflowToolOutputKind =\n | \"catalog\"\n | \"resolver\"\n | \"data\"\n | \"table\"\n | \"chart\"\n | \"link\"\n | \"artifact\"\n | \"evidence\"\n | \"schema\"\n | \"time\"\n | \"text\";\n\nexport type AssistantWorkflowToolContextRequirement =\n | \"auth\"\n | \"topic-scope\"\n | \"document-scope\"\n | \"confirmed-path\"\n | \"dashboard-id\"\n | \"schema-key\";\n\nexport type AssistantWorkflowDirectRouteEffect = \"read\" | \"compute\" | \"write\";\n\nexport type AssistantWorkflowDirectRouteStrategyDefinition = AssistantWorkflowVocabularyItem & {\n requiredToolHints?: readonly string[];\n};\n\nexport type AssistantWorkflowDirectRouteDefinition = AssistantWorkflowVocabularyItem & {\n effect: AssistantWorkflowDirectRouteEffect;\n outcomeRoute?: string;\n requiredToolHints?: readonly string[];\n strategies?: readonly AssistantWorkflowDirectRouteStrategyDefinition[];\n requiresConfirmation?: boolean;\n};\n\nexport type AssistantWorkflowHttpMethod = \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n\nexport type AssistantWorkflowVocabularyItem<TId extends string = string> = {\n id: TId;\n description: string;\n};\n\nexport type AssistantWorkflowToolCapabilityDefinition = {\n name: string;\n provider: AssistantWorkflowToolProvider;\n effect: AssistantWorkflowToolEffect;\n sideEffectRisk: AssistantWorkflowToolSideEffectRisk;\n cacheability: AssistantWorkflowToolCacheability;\n retryClass: AssistantWorkflowToolRetryClass;\n outputKinds: readonly AssistantWorkflowToolOutputKind[];\n requiredContext?: readonly AssistantWorkflowToolContextRequirement[];\n requiresConfirmation?: boolean;\n};\n\nexport type AssistantWorkflowLocalFunctionToolBinding = {\n name: string;\n provider: \"local-function\";\n handlerId: string;\n};\n\nexport type AssistantWorkflowHttpToolBinding = {\n name: string;\n provider: \"http\";\n method?: AssistantWorkflowHttpMethod;\n path: string;\n baseUrlRef?: string;\n operationId?: string;\n};\n\nexport type AssistantWorkflowOpenAIHostedToolBinding = {\n name: string;\n provider: \"openai-hosted\";\n hostedToolType: string;\n toolName?: string;\n};\n\nexport type AssistantWorkflowMcpToolBinding = {\n name: string;\n provider: \"mcp\";\n serverId: string;\n toolName: string;\n};\n\nexport type AssistantWorkflowReplToolBinding = {\n name: string;\n provider: \"repl\";\n runtimeId: string;\n functionName?: string;\n commandTemplate?: string;\n allowFilesystem?: boolean;\n allowNetwork?: boolean;\n};\n\nexport type AssistantWorkflowToolBindingDefinition =\n | AssistantWorkflowLocalFunctionToolBinding\n | AssistantWorkflowHttpToolBinding\n | AssistantWorkflowOpenAIHostedToolBinding\n | AssistantWorkflowMcpToolBinding\n | AssistantWorkflowReplToolBinding;\n\nexport type AssistantWorkflowIntentDefinition<\n TIntent extends string = string,\n TPresentation extends string = string,\n> = AssistantWorkflowVocabularyItem<TIntent> & {\n defaultPresentation?: TPresentation | null;\n executionBias?: AssistantWorkflowExecutionBias | null;\n firstHopToolPolicy?: AssistantWorkflowFirstHopToolPolicy | null;\n optionalToolSelectionMode?: AssistantWorkflowOptionalToolSelectionMode;\n toolHints?: readonly string[];\n requiredToolHints?: readonly string[];\n toolSelectionProfiles?: readonly AssistantWorkflowToolSelectionProfile[];\n planningStepProfiles?: readonly AssistantWorkflowPlanningStepProfile[];\n memoryUse?: readonly AssistantWorkflowMemoryUse[];\n memoryPolicy?: AssistantWorkflowMemoryPolicy;\n directRoutes?: readonly string[];\n planningSteps?: readonly string[];\n clarificationRules?: readonly string[];\n plannerInstructions?: readonly string[];\n};\n\nexport type AssistantWorkflowDefinition<\n TIntent extends string = string,\n TSubintent extends string = string,\n TPresentation extends string = string,\n TDerivedTransform extends string = string,\n> = {\n id: string;\n version: number;\n description?: string;\n intents: readonly AssistantWorkflowIntentDefinition<TIntent, TPresentation>[];\n tools?: readonly AssistantWorkflowToolCapabilityDefinition[];\n toolBindings?: readonly AssistantWorkflowToolBindingDefinition[];\n directRoutes?: readonly AssistantWorkflowDirectRouteDefinition[];\n memorySlots?: readonly AssistantWorkflowMemorySlotDefinition[];\n planningSteps?: readonly AssistantWorkflowPlanningStepDefinition[];\n clarificationRules?: readonly AssistantWorkflowClarificationRuleDefinition[];\n subintents?: readonly AssistantWorkflowVocabularyItem<TSubintent>[];\n presentations?: readonly AssistantWorkflowVocabularyItem<TPresentation>[];\n derivedTransforms?: readonly AssistantWorkflowVocabularyItem<TDerivedTransform>[];\n};\n\nexport type AssistantWorkflowPromptFacts = {\n intents: string;\n subintents: string;\n presentations: string;\n derivedTransforms: string;\n};\n\nexport function defineAssistantWorkflow<\n TIntent extends string,\n TSubintent extends string = never,\n TPresentation extends string = never,\n TDerivedTransform extends string = never,\n>(\n definition: AssistantWorkflowDefinition<TIntent, TSubintent, TPresentation, TDerivedTransform>,\n): AssistantWorkflowDefinition<TIntent, TSubintent, TPresentation, TDerivedTransform> {\n assertWorkflowHeader(definition);\n assertUniqueVocabulary(\"intent\", definition.intents);\n assertUniqueVocabulary(\"subintent\", definition.subintents ?? []);\n assertUniqueVocabulary(\"presentation\", definition.presentations ?? []);\n assertUniqueVocabulary(\"derived transform\", definition.derivedTransforms ?? []);\n assertUniqueToolCapabilities(definition.tools ?? []);\n assertUniqueToolBindings(definition.toolBindings ?? []);\n assertUniqueDirectRoutes(definition.directRoutes ?? []);\n assertUniqueMemorySlots(definition.memorySlots ?? []);\n assertUniquePlanningSteps(definition.planningSteps ?? []);\n assertUniqueClarificationRules(definition.clarificationRules ?? []);\n assertIntentReferences(definition);\n return definition;\n}\n\nexport function normalizeAssistantWorkflowId(value: unknown): string | null {\n if (typeof value !== \"string\") return null;\n const normalized = value.trim().toLowerCase();\n return normalized.length ? normalized : null;\n}\n\nexport function getAssistantWorkflowIntentIds<TIntent extends string>(\n workflow: AssistantWorkflowDefinition<TIntent, string, string, string>,\n): readonly TIntent[] {\n return workflow.intents.map((intent) => intent.id);\n}\n\nexport function getAssistantWorkflowSubintentIds<TSubintent extends string>(\n workflow: AssistantWorkflowDefinition<string, TSubintent, string, string>,\n): readonly TSubintent[] {\n return (workflow.subintents ?? []).map((subintent) => subintent.id);\n}\n\nexport function getAssistantWorkflowPresentationIds<TPresentation extends string>(\n workflow: AssistantWorkflowDefinition<string, string, TPresentation, string>,\n): readonly TPresentation[] {\n return (workflow.presentations ?? []).map((presentation) => presentation.id);\n}\n\nexport function getAssistantWorkflowDerivedTransformIds<TDerivedTransform extends string>(\n workflow: AssistantWorkflowDefinition<string, string, string, TDerivedTransform>,\n): readonly TDerivedTransform[] {\n return (workflow.derivedTransforms ?? []).map((transform) => transform.id);\n}\n\nexport function findAssistantWorkflowIntent<TIntent extends string, TPresentation extends string>(\n workflow: AssistantWorkflowDefinition<TIntent, string, TPresentation, string>,\n intentId: unknown,\n): AssistantWorkflowIntentDefinition<TIntent, TPresentation> | null {\n const normalized = normalizeAssistantWorkflowId(intentId);\n if (!normalized) return null;\n return workflow.intents.find((intent) => intent.id === normalized) ?? null;\n}\n\nexport function getAssistantWorkflowToolHints(\n workflow: AssistantWorkflowDefinition<string, string, string, string>,\n intentId: unknown,\n availableToolNames?: readonly string[],\n): string[] {\n const intent = findAssistantWorkflowIntent(workflow, intentId);\n if (!intent) return [];\n return filterWorkflowToolNames(intent.toolHints ?? [], availableToolNames);\n}\n\nexport function getAssistantWorkflowRequiredToolHints(\n workflow: AssistantWorkflowDefinition<string, string, string, string>,\n intentId: unknown,\n availableToolNames?: readonly string[],\n): string[] {\n const intent = findAssistantWorkflowIntent(workflow, intentId);\n if (!intent) return [];\n return filterWorkflowToolNames(intent.requiredToolHints ?? [], availableToolNames);\n}\n\nexport function formatAssistantWorkflowVocabulary(\n items: readonly AssistantWorkflowVocabularyItem[],\n options: { includeDescriptions?: boolean } = {},\n): string {\n const includeDescriptions = options.includeDescriptions ?? true;\n return items\n .map((item) => {\n const id = item.id.trim();\n const description = item.description.trim();\n return includeDescriptions && description.length ? `${id} = ${description}` : id;\n })\n .filter((entry) => entry.length > 0)\n .join(\"; \");\n}\n\nexport function buildAssistantWorkflowPromptFacts(\n workflow: AssistantWorkflowDefinition<string, string, string, string>,\n): AssistantWorkflowPromptFacts {\n return {\n intents: formatAssistantWorkflowVocabulary(workflow.intents),\n subintents: formatAssistantWorkflowVocabulary(workflow.subintents ?? []),\n presentations: formatAssistantWorkflowVocabulary(workflow.presentations ?? [], { includeDescriptions: false }),\n derivedTransforms: formatAssistantWorkflowVocabulary(workflow.derivedTransforms ?? [], { includeDescriptions: false }),\n };\n}\n\nfunction assertWorkflowHeader(workflow: AssistantWorkflowDefinition<string, string, string, string>): void {\n if (!workflow.id.trim().length) {\n throw new Error(\"Assistant workflow id is required.\");\n }\n if (!Number.isInteger(workflow.version) || workflow.version < 1) {\n throw new Error(\"Assistant workflow version must be a positive integer.\");\n }\n if (!workflow.intents.length) {\n throw new Error(\"Assistant workflow must define at least one intent.\");\n }\n}\n\nfunction assertUniqueVocabulary(\n kind: string,\n items: readonly AssistantWorkflowVocabularyItem[],\n): void {\n const seen = new Set<string>();\n for (const item of items) {\n const normalized = normalizeAssistantWorkflowId(item.id);\n if (!normalized) {\n throw new Error(`Assistant workflow ${kind} id is required.`);\n }\n if (normalized !== item.id) {\n throw new Error(`Assistant workflow ${kind} id must already be normalized: ${item.id}.`);\n }\n if (seen.has(normalized)) {\n throw new Error(`Duplicate assistant workflow ${kind} id: ${normalized}.`);\n }\n seen.add(normalized);\n }\n}\n\nfunction assertIntentReferences(\n workflow: AssistantWorkflowDefinition<string, string, string, string>,\n): void {\n const toolCapabilities = new Map((workflow.tools ?? []).map((tool) => [tool.name, tool] as const));\n const presentationIds = new Set((workflow.presentations ?? []).map((presentation) => presentation.id));\n const toolNames = new Set(toolCapabilities.keys());\n const directRouteIds = new Set((workflow.directRoutes ?? []).map((route) => route.id));\n const memorySlotIds = new Set((workflow.memorySlots ?? []).map((slot) => slot.id));\n const planningStepIds = new Set((workflow.planningSteps ?? []).map((step) => step.id));\n const clarificationRuleIds = new Set((workflow.clarificationRules ?? []).map((rule) => rule.id));\n const subintentIds = new Set((workflow.subintents ?? []).map((subintent) => subintent.id));\n for (const binding of workflow.toolBindings ?? []) {\n const capability = toolCapabilities.get(binding.name);\n if (toolCapabilities.size > 0 && !capability) {\n throw new Error(`Assistant workflow tool binding references unknown tool capability: ${binding.name}.`);\n }\n if (capability && capability.provider !== binding.provider) {\n throw new Error(\n `Assistant workflow tool binding ${binding.name} provider ${binding.provider} does not match capability provider ${capability.provider}.`,\n );\n }\n }\n for (const step of workflow.planningSteps ?? []) {\n for (const toolName of [...(step.toolHints ?? []), ...(step.requiredToolHints ?? [])]) {\n if (toolNames.size > 0 && !toolNames.has(toolName)) {\n throw new Error(\n `Assistant workflow planning step ${step.id} references unknown tool capability: ${toolName}.`,\n );\n }\n }\n for (const slotId of [...(step.readsMemory ?? []), ...(step.writesMemory ?? [])]) {\n if (memorySlotIds.size > 0 && !memorySlotIds.has(slotId)) {\n throw new Error(\n `Assistant workflow planning step ${step.id} references unknown memory slot: ${slotId}.`,\n );\n }\n }\n }\n for (const rule of workflow.clarificationRules ?? []) {\n for (const slotId of [...(rule.readsMemory ?? []), ...(rule.writesMemory ?? [])]) {\n if (memorySlotIds.size > 0 && !memorySlotIds.has(slotId)) {\n throw new Error(\n `Assistant workflow clarification rule ${rule.id} references unknown memory slot: ${slotId}.`,\n );\n }\n }\n }\n for (const route of workflow.directRoutes ?? []) {\n for (const toolName of route.requiredToolHints ?? []) {\n if (toolNames.size > 0 && !toolNames.has(toolName)) {\n throw new Error(\n `Assistant workflow direct route ${route.id} references unknown tool capability: ${toolName}.`,\n );\n }\n }\n }\n for (const intent of workflow.intents) {\n assertUniqueToolSelectionProfiles(intent);\n assertUniquePlanningStepProfiles(intent);\n if (intent.defaultPresentation && !presentationIds.has(intent.defaultPresentation)) {\n throw new Error(\n `Assistant workflow intent ${intent.id} references unknown presentation: ${intent.defaultPresentation}.`,\n );\n }\n for (const toolName of [...(intent.toolHints ?? []), ...(intent.requiredToolHints ?? [])]) {\n if (toolNames.size > 0 && !toolNames.has(toolName)) {\n throw new Error(\n `Assistant workflow intent ${intent.id} references unknown tool capability: ${toolName}.`,\n );\n }\n }\n for (const [profileIndex, profile] of (intent.toolSelectionProfiles ?? []).entries()) {\n assertToolSelectionProfileCondition(intent.id, profile, toolNames);\n for (const toolName of profile.toolHints) {\n if (toolNames.size > 0 && !toolNames.has(toolName)) {\n throw new Error(\n `Assistant workflow intent ${intent.id} tool selection profile ${profile.id} references unknown tool capability: ${toolName}.`,\n );\n }\n }\n if (!profile.toolHints.length) {\n throw new Error(\n `Assistant workflow intent ${intent.id} tool selection profile ${profileIndex} must define at least one tool hint.`,\n );\n }\n }\n for (const [profileIndex, profile] of (intent.planningStepProfiles ?? []).entries()) {\n assertPlanningStepProfileCondition(intent.id, profile);\n if (!profile.planningSteps.length) {\n throw new Error(\n `Assistant workflow intent ${intent.id} planning step profile ${profileIndex} must define at least one planning step.`,\n );\n }\n for (const stepId of profile.planningSteps) {\n if (planningStepIds.size > 0 && !planningStepIds.has(stepId)) {\n throw new Error(\n `Assistant workflow intent ${intent.id} planning step profile ${profile.id} references unknown planning step: ${stepId}.`,\n );\n }\n }\n for (const toolName of profile.condition?.requiredTools ?? []) {\n if (toolNames.size > 0 && !toolNames.has(toolName)) {\n throw new Error(\n `Assistant workflow intent ${intent.id} planning step profile ${profile.id} references unknown required tool: ${toolName}.`,\n );\n }\n }\n const condition = profile.condition;\n if (condition?.subintent && subintentIds.size > 0 && !subintentIds.has(condition.subintent)) {\n throw new Error(\n `Assistant workflow intent ${intent.id} planning step profile ${profile.id} references unknown subintent: ${condition.subintent}.`,\n );\n }\n if (condition?.presentation && presentationIds.size > 0 && !presentationIds.has(condition.presentation)) {\n throw new Error(\n `Assistant workflow intent ${intent.id} planning step profile ${profile.id} references unknown presentation: ${condition.presentation}.`,\n );\n }\n }\n for (const slotId of [\n ...(intent.memoryPolicy?.read ?? []),\n ...(intent.memoryPolicy?.write ?? []),\n ...(intent.memoryPolicy?.inject ?? []),\n ]) {\n if (memorySlotIds.size > 0 && !memorySlotIds.has(slotId)) {\n throw new Error(\n `Assistant workflow intent ${intent.id} references unknown memory slot: ${slotId}.`,\n );\n }\n }\n for (const routeId of intent.directRoutes ?? []) {\n if (directRouteIds.size > 0 && !directRouteIds.has(routeId)) {\n throw new Error(\n `Assistant workflow intent ${intent.id} references unknown direct route: ${routeId}.`,\n );\n }\n }\n for (const stepId of intent.planningSteps ?? []) {\n if (planningStepIds.size > 0 && !planningStepIds.has(stepId)) {\n throw new Error(\n `Assistant workflow intent ${intent.id} references unknown planning step: ${stepId}.`,\n );\n }\n }\n for (const ruleId of intent.clarificationRules ?? []) {\n if (clarificationRuleIds.size > 0 && !clarificationRuleIds.has(ruleId)) {\n throw new Error(\n `Assistant workflow intent ${intent.id} references unknown clarification rule: ${ruleId}.`,\n );\n }\n }\n }\n}\n\nfunction assertUniqueDirectRoutes(routes: readonly AssistantWorkflowDirectRouteDefinition[]): void {\n assertUniqueVocabulary(\"direct route\", routes);\n for (const route of routes) {\n if (route.outcomeRoute !== undefined && !normalizeAssistantWorkflowId(route.outcomeRoute)) {\n throw new Error(`Assistant workflow direct route ${route.id} outcomeRoute must be non-empty when provided.`);\n }\n if (route.outcomeRoute !== undefined && normalizeAssistantWorkflowId(route.outcomeRoute) !== route.outcomeRoute) {\n throw new Error(\n `Assistant workflow direct route ${route.id} outcomeRoute must already be normalized: ${route.outcomeRoute}.`,\n );\n }\n assertUniqueVocabulary(`direct route ${route.id} strategy`, route.strategies ?? []);\n for (const strategy of route.strategies ?? []) {\n if (strategy.id !== normalizeAssistantWorkflowId(strategy.id)) {\n throw new Error(\n `Assistant workflow direct route ${route.id} strategy id must already be normalized: ${strategy.id}.`,\n );\n }\n }\n }\n}\n\nfunction assertUniqueToolSelectionProfiles(intent: AssistantWorkflowIntentDefinition): void {\n const seen = new Set<string>();\n for (const profile of intent.toolSelectionProfiles ?? []) {\n const normalized = normalizeAssistantWorkflowId(profile.id);\n if (!normalized) {\n throw new Error(`Assistant workflow intent ${intent.id} tool selection profile id is required.`);\n }\n if (normalized !== profile.id) {\n throw new Error(\n `Assistant workflow intent ${intent.id} tool selection profile id must already be normalized: ${profile.id}.`,\n );\n }\n if (seen.has(normalized)) {\n throw new Error(`Duplicate assistant workflow intent ${intent.id} tool selection profile: ${normalized}.`);\n }\n seen.add(normalized);\n if (!profile.description.trim().length) {\n throw new Error(`Assistant workflow intent ${intent.id} tool selection profile ${normalized} description is required.`);\n }\n }\n}\n\nfunction assertUniquePlanningStepProfiles(intent: AssistantWorkflowIntentDefinition): void {\n const seen = new Set<string>();\n for (const profile of intent.planningStepProfiles ?? []) {\n const normalized = normalizeAssistantWorkflowId(profile.id);\n if (!normalized) {\n throw new Error(`Assistant workflow intent ${intent.id} planning step profile id is required.`);\n }\n if (normalized !== profile.id) {\n throw new Error(\n `Assistant workflow intent ${intent.id} planning step profile id must already be normalized: ${profile.id}.`,\n );\n }\n if (seen.has(normalized)) {\n throw new Error(`Duplicate assistant workflow intent ${intent.id} planning step profile: ${normalized}.`);\n }\n seen.add(normalized);\n if (!profile.description.trim().length) {\n throw new Error(`Assistant workflow intent ${intent.id} planning step profile ${normalized} description is required.`);\n }\n }\n}\n\nfunction assertToolSelectionProfileCondition(\n intentId: string,\n profile: AssistantWorkflowToolSelectionProfile,\n knownToolNames: ReadonlySet<string>,\n): void {\n const {\n minHop,\n maxHop,\n selectedReason,\n minAttributeCount,\n maxAttributeCount,\n requiredClassifierTools,\n } = profile.condition ?? {};\n if (profile.toolExclusions !== undefined) {\n const normalizedExcludedTools = profile.toolExclusions\n .filter((toolName): toolName is string => typeof toolName === \"string\")\n .map((toolName) => toolName.trim())\n .filter((toolName) => toolName.length > 0);\n if (!normalizedExcludedTools.length) {\n throw new Error(\n `Assistant workflow intent ${intentId} tool selection profile ${profile.id} toolExclusions must contain at least one tool.`,\n );\n }\n const profileToolHints = new Set(profile.toolHints.map((toolName) => toolName.trim()));\n for (const toolName of normalizedExcludedTools) {\n if (!knownToolNames.has(toolName)) {\n throw new Error(\n `Assistant workflow intent ${intentId} tool selection profile ${profile.id} references unknown excluded tool capability: ${toolName}.`,\n );\n }\n if (profileToolHints.has(toolName)) {\n throw new Error(\n `Assistant workflow intent ${intentId} tool selection profile ${profile.id} must not both hint and exclude tool capability: ${toolName}.`,\n );\n }\n }\n }\n if (minHop !== undefined && (!Number.isInteger(minHop) || minHop < 0)) {\n throw new Error(\n `Assistant workflow intent ${intentId} tool selection profile ${profile.id} minHop must be a non-negative integer.`,\n );\n }\n if (maxHop !== undefined && (!Number.isInteger(maxHop) || maxHop < 0)) {\n throw new Error(\n `Assistant workflow intent ${intentId} tool selection profile ${profile.id} maxHop must be a non-negative integer.`,\n );\n }\n if (minHop !== undefined && maxHop !== undefined && minHop > maxHop) {\n throw new Error(\n `Assistant workflow intent ${intentId} tool selection profile ${profile.id} minHop must not exceed maxHop.`,\n );\n }\n if (minAttributeCount !== undefined && (!Number.isInteger(minAttributeCount) || minAttributeCount < 0)) {\n throw new Error(\n `Assistant workflow intent ${intentId} tool selection profile ${profile.id} minAttributeCount must be a non-negative integer.`,\n );\n }\n if (maxAttributeCount !== undefined && (!Number.isInteger(maxAttributeCount) || maxAttributeCount < 0)) {\n throw new Error(\n `Assistant workflow intent ${intentId} tool selection profile ${profile.id} maxAttributeCount must be a non-negative integer.`,\n );\n }\n if (\n minAttributeCount !== undefined &&\n maxAttributeCount !== undefined &&\n minAttributeCount > maxAttributeCount\n ) {\n throw new Error(\n `Assistant workflow intent ${intentId} tool selection profile ${profile.id} minAttributeCount must not exceed maxAttributeCount.`,\n );\n }\n if (requiredClassifierTools !== undefined) {\n const normalizedRequiredTools = requiredClassifierTools\n .filter((toolName): toolName is string => typeof toolName === \"string\")\n .map((toolName) => toolName.trim())\n .filter((toolName) => toolName.length > 0);\n if (!normalizedRequiredTools.length) {\n throw new Error(\n `Assistant workflow intent ${intentId} tool selection profile ${profile.id} requiredClassifierTools must contain at least one tool.`,\n );\n }\n for (const toolName of normalizedRequiredTools) {\n if (!knownToolNames.has(toolName)) {\n throw new Error(\n `Assistant workflow intent ${intentId} tool selection profile ${profile.id} references unknown classifier tool capability: ${toolName}.`,\n );\n }\n }\n }\n if (selectedReason !== undefined && !selectedReason.trim().length) {\n throw new Error(\n `Assistant workflow intent ${intentId} tool selection profile ${profile.id} selectedReason must not be empty.`,\n );\n }\n}\n\nfunction assertPlanningStepProfileCondition(\n intentId: string,\n profile: AssistantWorkflowPlanningStepProfile,\n): void {\n const { minConfidence, maxConfidence, subintent, presentation, timeWindowHint, requiredTools } = profile.condition ?? {};\n if (minConfidence !== undefined && (!Number.isFinite(minConfidence) || minConfidence < 0 || minConfidence > 1)) {\n throw new Error(\n `Assistant workflow intent ${intentId} planning step profile ${profile.id} minConfidence must be between 0 and 1.`,\n );\n }\n if (maxConfidence !== undefined && (!Number.isFinite(maxConfidence) || maxConfidence < 0 || maxConfidence > 1)) {\n throw new Error(\n `Assistant workflow intent ${intentId} planning step profile ${profile.id} maxConfidence must be between 0 and 1.`,\n );\n }\n if (minConfidence !== undefined && maxConfidence !== undefined && minConfidence > maxConfidence) {\n throw new Error(\n `Assistant workflow intent ${intentId} planning step profile ${profile.id} minConfidence must not exceed maxConfidence.`,\n );\n }\n if (subintent !== undefined && !subintent.trim().length) {\n throw new Error(\n `Assistant workflow intent ${intentId} planning step profile ${profile.id} subintent must not be empty.`,\n );\n }\n if (presentation !== undefined && !presentation.trim().length) {\n throw new Error(\n `Assistant workflow intent ${intentId} planning step profile ${profile.id} presentation must not be empty.`,\n );\n }\n if (timeWindowHint !== undefined && !timeWindowHint.trim().length) {\n throw new Error(\n `Assistant workflow intent ${intentId} planning step profile ${profile.id} timeWindowHint must not be empty.`,\n );\n }\n if (requiredTools !== undefined && requiredTools.length === 0) {\n throw new Error(\n `Assistant workflow intent ${intentId} planning step profile ${profile.id} requiredTools must not be empty.`,\n );\n }\n}\n\nfunction assertUniqueClarificationRules(\n rules: readonly AssistantWorkflowClarificationRuleDefinition[],\n): void {\n const seen = new Set<string>();\n for (const rule of rules) {\n const normalized = normalizeAssistantWorkflowId(rule.id);\n if (!normalized) {\n throw new Error(\"Assistant workflow clarification rule id is required.\");\n }\n if (normalized !== rule.id) {\n throw new Error(`Assistant workflow clarification rule id must already be normalized: ${rule.id}.`);\n }\n if (seen.has(normalized)) {\n throw new Error(`Duplicate assistant workflow clarification rule: ${normalized}.`);\n }\n seen.add(normalized);\n if (!rule.description.trim().length) {\n throw new Error(`Assistant workflow clarification rule ${normalized} description is required.`);\n }\n if (\n rule.condition === \"low_confidence\" &&\n rule.confidenceBelow !== undefined &&\n (!Number.isFinite(rule.confidenceBelow) || rule.confidenceBelow < 0 || rule.confidenceBelow > 1)\n ) {\n throw new Error(`Assistant workflow clarification rule ${normalized} confidenceBelow must be between 0 and 1.`);\n }\n }\n}\n\nfunction assertUniquePlanningSteps(\n steps: readonly AssistantWorkflowPlanningStepDefinition[],\n): void {\n const seen = new Set<string>();\n for (const step of steps) {\n const normalized = normalizeAssistantWorkflowId(step.id);\n if (!normalized) {\n throw new Error(\"Assistant workflow planning step id is required.\");\n }\n if (normalized !== step.id) {\n throw new Error(`Assistant workflow planning step id must already be normalized: ${step.id}.`);\n }\n if (seen.has(normalized)) {\n throw new Error(`Duplicate assistant workflow planning step: ${normalized}.`);\n }\n seen.add(normalized);\n if (!step.description.trim().length) {\n throw new Error(`Assistant workflow planning step ${normalized} description is required.`);\n }\n }\n}\n\nfunction assertUniqueMemorySlots(\n slots: readonly AssistantWorkflowMemorySlotDefinition[],\n): void {\n const seen = new Set<string>();\n for (const slot of slots) {\n const normalized = normalizeAssistantWorkflowId(slot.id);\n if (!normalized) {\n throw new Error(\"Assistant workflow memory slot id is required.\");\n }\n if (normalized !== slot.id) {\n throw new Error(`Assistant workflow memory slot id must already be normalized: ${slot.id}.`);\n }\n if (seen.has(normalized)) {\n throw new Error(`Duplicate assistant workflow memory slot: ${normalized}.`);\n }\n seen.add(normalized);\n if (!slot.description.trim().length) {\n throw new Error(`Assistant workflow memory slot ${normalized} description is required.`);\n }\n }\n}\n\nfunction assertUniqueToolCapabilities(\n tools: readonly AssistantWorkflowToolCapabilityDefinition[],\n): void {\n const seen = new Set<string>();\n for (const tool of tools) {\n const normalized = normalizeAssistantWorkflowId(tool.name);\n if (!normalized) {\n throw new Error(\"Assistant workflow tool capability name is required.\");\n }\n if (normalized !== tool.name) {\n throw new Error(`Assistant workflow tool capability name must already be normalized: ${tool.name}.`);\n }\n if (seen.has(normalized)) {\n throw new Error(`Duplicate assistant workflow tool capability: ${normalized}.`);\n }\n seen.add(normalized);\n if (!tool.outputKinds.length) {\n throw new Error(`Assistant workflow tool capability ${normalized} must define at least one output kind.`);\n }\n }\n}\n\nfunction assertUniqueToolBindings(\n bindings: readonly AssistantWorkflowToolBindingDefinition[],\n): void {\n const seen = new Set<string>();\n for (const binding of bindings) {\n const normalized = normalizeAssistantWorkflowId(binding.name);\n if (!normalized) {\n throw new Error(\"Assistant workflow tool binding name is required.\");\n }\n if (normalized !== binding.name) {\n throw new Error(`Assistant workflow tool binding name must already be normalized: ${binding.name}.`);\n }\n if (seen.has(normalized)) {\n throw new Error(`Duplicate assistant workflow tool binding: ${normalized}.`);\n }\n seen.add(normalized);\n assertToolBindingTarget(binding);\n }\n}\n\nfunction assertToolBindingTarget(binding: AssistantWorkflowToolBindingDefinition): void {\n switch (binding.provider) {\n case \"local-function\":\n assertNonEmptyBindingField(binding.name, \"handlerId\", binding.handlerId);\n return;\n case \"http\":\n assertNonEmptyBindingField(binding.name, \"path\", binding.path);\n if (binding.method !== undefined && binding.method !== binding.method.toUpperCase()) {\n throw new Error(`Assistant workflow tool binding ${binding.name} HTTP method must be uppercase.`);\n }\n return;\n case \"openai-hosted\":\n assertNonEmptyBindingField(binding.name, \"hostedToolType\", binding.hostedToolType);\n return;\n case \"mcp\":\n assertNonEmptyBindingField(binding.name, \"serverId\", binding.serverId);\n assertNonEmptyBindingField(binding.name, \"toolName\", binding.toolName);\n return;\n case \"repl\":\n assertNonEmptyBindingField(binding.name, \"runtimeId\", binding.runtimeId);\n if (!binding.functionName?.trim().length && !binding.commandTemplate?.trim().length) {\n throw new Error(\n `Assistant workflow tool binding ${binding.name} must define functionName or commandTemplate.`,\n );\n }\n return;\n }\n}\n\nfunction assertNonEmptyBindingField(toolName: string, fieldName: string, value: string): void {\n if (!value.trim().length) {\n throw new Error(`Assistant workflow tool binding ${toolName} ${fieldName} is required.`);\n }\n}\n\nfunction filterWorkflowToolNames(\n rawTools: readonly string[],\n availableToolNames?: readonly string[],\n): string[] {\n const availableSet = availableToolNames ? new Set(availableToolNames) : null;\n const out: string[] = [];\n const seen = new Set<string>();\n for (const rawTool of rawTools) {\n const tool = rawTool.trim();\n if (!tool.length || seen.has(tool)) continue;\n if (availableSet && !availableSet.has(tool)) continue;\n seen.add(tool);\n out.push(tool);\n }\n return out;\n}\n"]}
|