@uns-kit/assistant-workflow 3.0.1 → 3.0.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.
- package/API_STABILITY.md +38 -0
- package/README.md +40 -0
- package/dist/definition-diagnostics.d.ts +1 -1
- package/dist/definition-diagnostics.d.ts.map +1 -1
- package/dist/definition-diagnostics.js +62 -0
- package/dist/definition-diagnostics.js.map +1 -1
- package/dist/definition-diff.d.ts +9 -0
- package/dist/definition-diff.d.ts.map +1 -1
- package/dist/definition-diff.js +39 -1
- package/dist/definition-diff.js.map +1 -1
- package/dist/definition.d.ts +5 -0
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +38 -0
- package/dist/definition.js.map +1 -1
- package/dist/execution-budget.d.ts +38 -0
- package/dist/execution-budget.d.ts.map +1 -0
- package/dist/execution-budget.js +65 -0
- package/dist/execution-budget.js.map +1 -0
- package/dist/execution-plan.d.ts +8 -0
- package/dist/execution-plan.d.ts.map +1 -1
- package/dist/execution-plan.js +47 -1
- package/dist/execution-plan.js.map +1 -1
- package/dist/execution-policy.d.ts +9 -0
- package/dist/execution-policy.d.ts.map +1 -0
- package/dist/execution-policy.js +21 -0
- package/dist/execution-policy.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/planning.d.ts +1 -0
- package/dist/planning.d.ts.map +1 -1
- package/dist/planning.js +1 -0
- package/dist/planning.js.map +1 -1
- package/dist/tool-executor.d.ts +7 -0
- package/dist/tool-executor.d.ts.map +1 -1
- package/dist/tool-executor.js +180 -55
- package/dist/tool-executor.js.map +1 -1
- package/dist/tool-invocations.d.ts +7 -0
- package/dist/tool-invocations.d.ts.map +1 -1
- package/dist/tool-invocations.js +43 -2
- package/dist/tool-invocations.js.map +1 -1
- package/package.json +11 -2
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export const ASSISTANT_WORKFLOW_EXECUTION_BUDGET_LIMITS = Object.freeze({
|
|
2
|
+
maxPlanningSteps: 32,
|
|
3
|
+
maxToolCalls: 16,
|
|
4
|
+
maxProviderCalls: 8,
|
|
5
|
+
maxDurationMs: 300_000,
|
|
6
|
+
maxEvidenceBytes: 1_000_000,
|
|
7
|
+
});
|
|
8
|
+
export function assertAssistantWorkflowExecutionBudget(budget) {
|
|
9
|
+
assertBudgetValue("maxPlanningSteps", budget.maxPlanningSteps, 1, ASSISTANT_WORKFLOW_EXECUTION_BUDGET_LIMITS.maxPlanningSteps);
|
|
10
|
+
assertBudgetValue("maxToolCalls", budget.maxToolCalls, 0, ASSISTANT_WORKFLOW_EXECUTION_BUDGET_LIMITS.maxToolCalls);
|
|
11
|
+
assertBudgetValue("maxProviderCalls", budget.maxProviderCalls, 0, ASSISTANT_WORKFLOW_EXECUTION_BUDGET_LIMITS.maxProviderCalls);
|
|
12
|
+
assertBudgetValue("maxDurationMs", budget.maxDurationMs, 1, ASSISTANT_WORKFLOW_EXECUTION_BUDGET_LIMITS.maxDurationMs);
|
|
13
|
+
assertBudgetValue("maxEvidenceBytes", budget.maxEvidenceBytes, 0, ASSISTANT_WORKFLOW_EXECUTION_BUDGET_LIMITS.maxEvidenceBytes);
|
|
14
|
+
}
|
|
15
|
+
export function buildAssistantWorkflowExecutionBudgetAssessment(budget, usage = {}) {
|
|
16
|
+
assertAssistantWorkflowExecutionBudget(budget);
|
|
17
|
+
const normalizedUsage = {
|
|
18
|
+
planningStepCount: normalizeUsageValue(usage.planningStepCount),
|
|
19
|
+
toolCallCount: normalizeUsageValue(usage.toolCallCount),
|
|
20
|
+
providerCallCount: normalizeUsageValue(usage.providerCallCount),
|
|
21
|
+
elapsedMs: normalizeUsageValue(usage.elapsedMs),
|
|
22
|
+
evidenceBytes: normalizeUsageValue(usage.evidenceBytes),
|
|
23
|
+
};
|
|
24
|
+
const violations = [
|
|
25
|
+
buildViolation("planning_steps_exceeded", normalizedUsage.planningStepCount, budget.maxPlanningSteps),
|
|
26
|
+
buildViolation("tool_calls_exceeded", normalizedUsage.toolCallCount, budget.maxToolCalls),
|
|
27
|
+
buildViolation("provider_calls_exceeded", normalizedUsage.providerCallCount, budget.maxProviderCalls),
|
|
28
|
+
buildViolation("duration_exceeded", normalizedUsage.elapsedMs, budget.maxDurationMs),
|
|
29
|
+
buildViolation("evidence_bytes_exceeded", normalizedUsage.evidenceBytes, budget.maxEvidenceBytes),
|
|
30
|
+
].filter((violation) => violation !== null);
|
|
31
|
+
return {
|
|
32
|
+
status: violations.length > 0 ? "blocked" : "within-budget",
|
|
33
|
+
budget: { ...budget },
|
|
34
|
+
usage: normalizedUsage,
|
|
35
|
+
violations,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export function buildAssistantWorkflowExecutionBudgetTracePayload(assessment) {
|
|
39
|
+
return {
|
|
40
|
+
status: assessment.status,
|
|
41
|
+
budget: assessment.budget,
|
|
42
|
+
usage: assessment.usage,
|
|
43
|
+
violations: assessment.violations.map((violation) => ({ ...violation })),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export function formatAssistantWorkflowExecutionBudgetViolation(violation) {
|
|
47
|
+
return `execution budget exceeded: ${violation.code} (${violation.actual} > ${violation.limit})`;
|
|
48
|
+
}
|
|
49
|
+
function assertBudgetValue(field, value, minimum, maximum) {
|
|
50
|
+
if (!Number.isInteger(value) || value < minimum || value > maximum) {
|
|
51
|
+
throw new Error(`Assistant workflow execution budget ${field} must be an integer between ${minimum} and ${maximum}.`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function normalizeUsageValue(value) {
|
|
55
|
+
if (value === undefined)
|
|
56
|
+
return 0;
|
|
57
|
+
if (!Number.isFinite(value) || value < 0) {
|
|
58
|
+
throw new Error("Assistant workflow execution budget usage values must be finite non-negative numbers.");
|
|
59
|
+
}
|
|
60
|
+
return Math.floor(value);
|
|
61
|
+
}
|
|
62
|
+
function buildViolation(code, actual, limit) {
|
|
63
|
+
return actual > limit ? { code, actual, limit } : null;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=execution-budget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-budget.js","sourceRoot":"","sources":["../src/execution-budget.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,0CAA0C,GAAG,MAAM,CAAC,MAAM,CAAC;IACtE,gBAAgB,EAAE,EAAE;IACpB,YAAY,EAAE,EAAE;IAChB,gBAAgB,EAAE,CAAC;IACnB,aAAa,EAAE,OAAO;IACtB,gBAAgB,EAAE,SAAS;CAC5B,CAAC,CAAC;AAsCH,MAAM,UAAU,sCAAsC,CACpD,MAAwC;IAExC,iBAAiB,CAAC,kBAAkB,EAAE,MAAM,CAAC,gBAAgB,EAAE,CAAC,EAAE,0CAA0C,CAAC,gBAAgB,CAAC,CAAC;IAC/H,iBAAiB,CAAC,cAAc,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC,EAAE,0CAA0C,CAAC,YAAY,CAAC,CAAC;IACnH,iBAAiB,CAAC,kBAAkB,EAAE,MAAM,CAAC,gBAAgB,EAAE,CAAC,EAAE,0CAA0C,CAAC,gBAAgB,CAAC,CAAC;IAC/H,iBAAiB,CAAC,eAAe,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC,EAAE,0CAA0C,CAAC,aAAa,CAAC,CAAC;IACtH,iBAAiB,CAAC,kBAAkB,EAAE,MAAM,CAAC,gBAAgB,EAAE,CAAC,EAAE,0CAA0C,CAAC,gBAAgB,CAAC,CAAC;AACjI,CAAC;AAED,MAAM,UAAU,+CAA+C,CAC7D,MAAwC,EACxC,QAAwD,EAAE;IAE1D,sCAAsC,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,eAAe,GAA0C;QAC7D,iBAAiB,EAAE,mBAAmB,CAAC,KAAK,CAAC,iBAAiB,CAAC;QAC/D,aAAa,EAAE,mBAAmB,CAAC,KAAK,CAAC,aAAa,CAAC;QACvD,iBAAiB,EAAE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CAA+C,CAC7D,SAAoD;IAEpD,OAAO,8BAA8B,SAAS,CAAC,IAAI,KAAK,SAAS,CAAC,MAAM,MAAM,SAAS,CAAC,KAAK,GAAG,CAAC;AACnG,CAAC;AAED,SAAS,iBAAiB,CACxB,KAA6C,EAC7C,KAAa,EACb,OAAe,EACf,OAAe;IAEf,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,OAAO,IAAI,KAAK,GAAG,OAAO,EAAE,CAAC;QACnE,MAAM,IAAI,KAAK,CACb,uCAAuC,KAAK,+BAA+B,OAAO,QAAQ,OAAO,GAAG,CACrG,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAyB;IACpD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,CAAC,CAAC;IAClC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,uFAAuF,CAAC,CAAC;IAC3G,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC;AAED,SAAS,cAAc,CACrB,IAAmD,EACnD,MAAc,EACd,KAAa;IAEb,OAAO,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACzD,CAAC","sourcesContent":["export const ASSISTANT_WORKFLOW_EXECUTION_BUDGET_LIMITS = Object.freeze({\n maxPlanningSteps: 32,\n maxToolCalls: 16,\n maxProviderCalls: 8,\n maxDurationMs: 300_000,\n maxEvidenceBytes: 1_000_000,\n});\n\nexport type AssistantWorkflowExecutionBudget = {\n maxPlanningSteps: number;\n maxToolCalls: number;\n maxProviderCalls: number;\n maxDurationMs: number;\n maxEvidenceBytes: number;\n};\n\nexport type AssistantWorkflowExecutionBudgetUsage = {\n planningStepCount: number;\n toolCallCount: number;\n providerCallCount: number;\n elapsedMs: number;\n evidenceBytes: number;\n};\n\nexport type AssistantWorkflowExecutionBudgetViolationCode =\n | \"planning_steps_exceeded\"\n | \"tool_calls_exceeded\"\n | \"provider_calls_exceeded\"\n | \"duration_exceeded\"\n | \"evidence_bytes_exceeded\";\n\nexport type AssistantWorkflowExecutionBudgetViolation = {\n code: AssistantWorkflowExecutionBudgetViolationCode;\n actual: number;\n limit: number;\n};\n\nexport type AssistantWorkflowExecutionBudgetAssessment = {\n status: \"within-budget\" | \"blocked\";\n budget: AssistantWorkflowExecutionBudget;\n usage: AssistantWorkflowExecutionBudgetUsage;\n violations: AssistantWorkflowExecutionBudgetViolation[];\n};\n\nexport function assertAssistantWorkflowExecutionBudget(\n budget: AssistantWorkflowExecutionBudget,\n): void {\n assertBudgetValue(\"maxPlanningSteps\", budget.maxPlanningSteps, 1, ASSISTANT_WORKFLOW_EXECUTION_BUDGET_LIMITS.maxPlanningSteps);\n assertBudgetValue(\"maxToolCalls\", budget.maxToolCalls, 0, ASSISTANT_WORKFLOW_EXECUTION_BUDGET_LIMITS.maxToolCalls);\n assertBudgetValue(\"maxProviderCalls\", budget.maxProviderCalls, 0, ASSISTANT_WORKFLOW_EXECUTION_BUDGET_LIMITS.maxProviderCalls);\n assertBudgetValue(\"maxDurationMs\", budget.maxDurationMs, 1, ASSISTANT_WORKFLOW_EXECUTION_BUDGET_LIMITS.maxDurationMs);\n assertBudgetValue(\"maxEvidenceBytes\", budget.maxEvidenceBytes, 0, ASSISTANT_WORKFLOW_EXECUTION_BUDGET_LIMITS.maxEvidenceBytes);\n}\n\nexport function buildAssistantWorkflowExecutionBudgetAssessment(\n budget: AssistantWorkflowExecutionBudget,\n usage: Partial<AssistantWorkflowExecutionBudgetUsage> = {},\n): AssistantWorkflowExecutionBudgetAssessment {\n assertAssistantWorkflowExecutionBudget(budget);\n const normalizedUsage: AssistantWorkflowExecutionBudgetUsage = {\n planningStepCount: normalizeUsageValue(usage.planningStepCount),\n toolCallCount: normalizeUsageValue(usage.toolCallCount),\n providerCallCount: normalizeUsageValue(usage.providerCallCount),\n elapsedMs: normalizeUsageValue(usage.elapsedMs),\n evidenceBytes: normalizeUsageValue(usage.evidenceBytes),\n };\n const violations = [\n buildViolation(\"planning_steps_exceeded\", normalizedUsage.planningStepCount, budget.maxPlanningSteps),\n buildViolation(\"tool_calls_exceeded\", normalizedUsage.toolCallCount, budget.maxToolCalls),\n buildViolation(\"provider_calls_exceeded\", normalizedUsage.providerCallCount, budget.maxProviderCalls),\n buildViolation(\"duration_exceeded\", normalizedUsage.elapsedMs, budget.maxDurationMs),\n buildViolation(\"evidence_bytes_exceeded\", normalizedUsage.evidenceBytes, budget.maxEvidenceBytes),\n ].filter((violation): violation is AssistantWorkflowExecutionBudgetViolation => violation !== null);\n\n return {\n status: violations.length > 0 ? \"blocked\" : \"within-budget\",\n budget: { ...budget },\n usage: normalizedUsage,\n violations,\n };\n}\n\nexport function buildAssistantWorkflowExecutionBudgetTracePayload(\n assessment: AssistantWorkflowExecutionBudgetAssessment,\n): Record<string, unknown> {\n return {\n status: assessment.status,\n budget: assessment.budget,\n usage: assessment.usage,\n violations: assessment.violations.map((violation) => ({ ...violation })),\n };\n}\n\nexport function formatAssistantWorkflowExecutionBudgetViolation(\n violation: AssistantWorkflowExecutionBudgetViolation,\n): string {\n return `execution budget exceeded: ${violation.code} (${violation.actual} > ${violation.limit})`;\n}\n\nfunction assertBudgetValue(\n field: keyof AssistantWorkflowExecutionBudget,\n value: number,\n minimum: number,\n maximum: number,\n): void {\n if (!Number.isInteger(value) || value < minimum || value > maximum) {\n throw new Error(\n `Assistant workflow execution budget ${field} must be an integer between ${minimum} and ${maximum}.`,\n );\n }\n}\n\nfunction normalizeUsageValue(value: number | undefined): number {\n if (value === undefined) return 0;\n if (!Number.isFinite(value) || value < 0) {\n throw new Error(\"Assistant workflow execution budget usage values must be finite non-negative numbers.\");\n }\n return Math.floor(value);\n}\n\nfunction buildViolation(\n code: AssistantWorkflowExecutionBudgetViolationCode,\n actual: number,\n limit: number,\n): AssistantWorkflowExecutionBudgetViolation | null {\n return actual > limit ? { code, actual, limit } : null;\n}\n"]}
|
package/dist/execution-plan.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import type { AssistantWorkflowDecision } from "./decision.js";
|
|
2
2
|
import { type AssistantWorkflowDefinition, type AssistantWorkflowPlanningStepKind, type AssistantWorkflowToolContextRequirement } from "./definition.js";
|
|
3
|
+
import { type AssistantWorkflowExecutionBudget, type AssistantWorkflowExecutionBudgetAssessment } from "./execution-budget.js";
|
|
4
|
+
import { type AssistantWorkflowExecutionPolicy } from "./execution-policy.js";
|
|
3
5
|
export type AssistantWorkflowExecutionPlanStatus = "ready" | "needs-clarification" | "blocked" | "partial";
|
|
4
6
|
export type AssistantWorkflowExecutionStepStatus = "ready" | "blocked" | "optional-skipped" | "partial";
|
|
5
7
|
export type AssistantWorkflowExecutionStep = {
|
|
6
8
|
id: string;
|
|
7
9
|
kind: AssistantWorkflowPlanningStepKind;
|
|
8
10
|
optional: boolean;
|
|
11
|
+
dependsOnStepIds: string[];
|
|
12
|
+
missingDependencyStepIds: string[];
|
|
13
|
+
outOfOrderDependencyStepIds: string[];
|
|
9
14
|
status: AssistantWorkflowExecutionStepStatus;
|
|
10
15
|
toolNames: string[];
|
|
11
16
|
requiredToolNames: string[];
|
|
@@ -34,6 +39,9 @@ export type AssistantWorkflowExecutionPlan = {
|
|
|
34
39
|
blockingReasons: string[];
|
|
35
40
|
warnings: string[];
|
|
36
41
|
executionHints: AssistantWorkflowDecision["plan"]["executionHints"];
|
|
42
|
+
executionBudget?: AssistantWorkflowExecutionBudget | null;
|
|
43
|
+
budgetAssessment?: AssistantWorkflowExecutionBudgetAssessment | null;
|
|
44
|
+
executionPolicy?: AssistantWorkflowExecutionPolicy;
|
|
37
45
|
};
|
|
38
46
|
export type AssistantWorkflowExecutionPlanOptions = {
|
|
39
47
|
availableContext?: readonly AssistantWorkflowToolContextRequirement[] | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-plan.d.ts","sourceRoot":"","sources":["../src/execution-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,iCAAiC,EACtC,KAAK,uCAAuC,EAC7C,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"execution-plan.d.ts","sourceRoot":"","sources":["../src/execution-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,iCAAiC,EACtC,KAAK,uCAAuC,EAC7C,MAAM,iBAAiB,CAAC;AAKzB,OAAO,EAIL,KAAK,gCAAgC,EACrC,KAAK,0CAA0C,EAChD,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,KAAK,gCAAgC,EACtC,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,oCAAoC,GAC5C,OAAO,GACP,qBAAqB,GACrB,SAAS,GACT,SAAS,CAAC;AAEd,MAAM,MAAM,oCAAoC,GAC5C,OAAO,GACP,SAAS,GACT,kBAAkB,GAClB,SAAS,CAAC;AAEd,MAAM,MAAM,8BAA8B,GAAG;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,iCAAiC,CAAC;IACxC,QAAQ,EAAE,OAAO,CAAC;IAClB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,wBAAwB,EAAE,MAAM,EAAE,CAAC;IACnC,2BAA2B,EAAE,MAAM,EAAE,CAAC;IACtC,MAAM,EAAE,oCAAoC,CAAC;IAC7C,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB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2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EACrE,QAAQ,EAAE,yBAAyB,EACnC,OAAO,GAAE,qCAA0C,GAClD,8BAA8B,CAkJhC;AAaD,wBAAgB,+CAA+C,CAC7D,IAAI,EAAE,8BAA8B,GACnC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAuBzB"}
|
package/dist/execution-plan.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { resolveAssistantWorkflowTools, } from "./tool-bindings.js";
|
|
2
|
+
import { buildAssistantWorkflowExecutionBudgetAssessment, buildAssistantWorkflowExecutionBudgetTracePayload, formatAssistantWorkflowExecutionBudgetViolation, } from "./execution-budget.js";
|
|
3
|
+
import { resolveAssistantWorkflowExecutionPolicy, } from "./execution-policy.js";
|
|
2
4
|
export function buildAssistantWorkflowExecutionPlan(workflow, decision, options = {}) {
|
|
3
5
|
const availableContext = options.availableContext ? new Set(options.availableContext) : null;
|
|
6
|
+
const selectedStepIds = new Set(decision.plan.steps.map((step) => step.id));
|
|
7
|
+
const seenStepIds = new Set();
|
|
4
8
|
const steps = decision.plan.steps.map((step) => {
|
|
9
|
+
const missingDependencyStepIds = step.dependsOnStepIds.filter((stepId) => !selectedStepIds.has(stepId));
|
|
10
|
+
const outOfOrderDependencyStepIds = step.dependsOnStepIds.filter((stepId) => selectedStepIds.has(stepId) && !seenStepIds.has(stepId));
|
|
5
11
|
const requiredToolNames = uniqueStrings(step.requiredToolHints);
|
|
6
12
|
const optionalToolNames = uniqueStrings(step.toolHints).filter((tool) => !requiredToolNames.includes(tool));
|
|
7
13
|
const toolNames = uniqueStrings([...requiredToolNames, ...optionalToolNames]);
|
|
@@ -15,17 +21,20 @@ export function buildAssistantWorkflowExecutionPlan(workflow, decision, options
|
|
|
15
21
|
const contextBlockingReasons = step.optional
|
|
16
22
|
? []
|
|
17
23
|
: buildContextBlockingReasons(step.id, requiredContextGaps);
|
|
24
|
+
const dependencyReasons = buildDependencyReasons(step.id, missingDependencyStepIds, outOfOrderDependencyStepIds);
|
|
18
25
|
const blockingReasons = step.optional
|
|
19
26
|
? []
|
|
20
27
|
: [
|
|
21
28
|
...buildToolBlockingReasons(step.id, requiredNonReady),
|
|
22
29
|
...contextBlockingReasons,
|
|
30
|
+
...dependencyReasons,
|
|
23
31
|
];
|
|
24
32
|
const warnings = [
|
|
25
33
|
...buildToolWarnings(step.id, step.optional ? requiredNonReady : []),
|
|
26
34
|
...buildToolWarnings(step.id, optionalNonReady),
|
|
27
35
|
...buildContextWarnings(step.id, step.optional ? requiredContextGaps : []),
|
|
28
36
|
...buildContextWarnings(step.id, optionalContextGaps),
|
|
37
|
+
...(step.optional ? dependencyReasons : []),
|
|
29
38
|
];
|
|
30
39
|
const status = step.optional && (requiredNonReady.length > 0 || requiredContextGaps.length > 0)
|
|
31
40
|
? "optional-skipped"
|
|
@@ -35,10 +44,13 @@ export function buildAssistantWorkflowExecutionPlan(workflow, decision, options
|
|
|
35
44
|
? "partial"
|
|
36
45
|
: "ready";
|
|
37
46
|
const allContextGaps = [...requiredContextGaps, ...optionalContextGaps];
|
|
38
|
-
|
|
47
|
+
const result = {
|
|
39
48
|
id: step.id,
|
|
40
49
|
kind: step.kind,
|
|
41
50
|
optional: step.optional,
|
|
51
|
+
dependsOnStepIds: [...step.dependsOnStepIds],
|
|
52
|
+
missingDependencyStepIds,
|
|
53
|
+
outOfOrderDependencyStepIds,
|
|
42
54
|
status,
|
|
43
55
|
toolNames,
|
|
44
56
|
requiredToolNames,
|
|
@@ -53,9 +65,18 @@ export function buildAssistantWorkflowExecutionPlan(workflow, decision, options
|
|
|
53
65
|
blockingReasons,
|
|
54
66
|
warnings,
|
|
55
67
|
};
|
|
68
|
+
seenStepIds.add(step.id);
|
|
69
|
+
return result;
|
|
56
70
|
});
|
|
57
71
|
const requiredResolution = resolveAssistantWorkflowTools(workflow, decision.requiredToolHints);
|
|
58
72
|
const requiredContextGaps = getContextGaps(requiredResolution.resolutions, availableContext);
|
|
73
|
+
const executionPolicy = resolveAssistantWorkflowExecutionPolicy(workflow.executionPolicy);
|
|
74
|
+
const budgetAssessment = workflow.executionBudget
|
|
75
|
+
? buildAssistantWorkflowExecutionBudgetAssessment(workflow.executionBudget, {
|
|
76
|
+
planningStepCount: steps.length,
|
|
77
|
+
toolCallCount: getMaximumPlannedToolCalls(workflow, steps, executionPolicy),
|
|
78
|
+
})
|
|
79
|
+
: null;
|
|
59
80
|
const blockingReasons = [
|
|
60
81
|
...decision.clarificationPolicy.blockingRuleIds.map((ruleId) => `clarification required: ${ruleId}`),
|
|
61
82
|
...decision.plan.missingPlanningSteps.map((stepId) => `missing planning step: ${stepId}`),
|
|
@@ -63,6 +84,7 @@ export function buildAssistantWorkflowExecutionPlan(workflow, decision, options
|
|
|
63
84
|
...buildToolBlockingReasons("workflow", requiredResolution.resolutions.filter((resolution) => resolution.status !== "ready")),
|
|
64
85
|
...buildContextBlockingReasons("workflow", requiredContextGaps),
|
|
65
86
|
...steps.flatMap((step) => step.blockingReasons),
|
|
87
|
+
...(budgetAssessment?.violations.map(formatAssistantWorkflowExecutionBudgetViolation) ?? []),
|
|
66
88
|
];
|
|
67
89
|
const warnings = uniqueStrings([
|
|
68
90
|
...decision.missingToolHints.map((toolName) => `optional tool is unavailable: ${toolName}`),
|
|
@@ -110,8 +132,17 @@ export function buildAssistantWorkflowExecutionPlan(workflow, decision, options
|
|
|
110
132
|
blockingReasons: uniqueStrings(blockingReasons),
|
|
111
133
|
warnings,
|
|
112
134
|
executionHints: decision.plan.executionHints,
|
|
135
|
+
executionBudget: workflow.executionBudget ? { ...workflow.executionBudget } : null,
|
|
136
|
+
budgetAssessment,
|
|
137
|
+
executionPolicy,
|
|
113
138
|
};
|
|
114
139
|
}
|
|
140
|
+
function buildDependencyReasons(stepId, missingDependencyStepIds, outOfOrderDependencyStepIds) {
|
|
141
|
+
return [
|
|
142
|
+
...missingDependencyStepIds.map((dependencyId) => `${stepId} missing dependency step: ${dependencyId}`),
|
|
143
|
+
...outOfOrderDependencyStepIds.map((dependencyId) => `${stepId} dependency must run first: ${dependencyId}`),
|
|
144
|
+
];
|
|
145
|
+
}
|
|
115
146
|
export function buildAssistantWorkflowExecutionPlanTracePayload(plan) {
|
|
116
147
|
return {
|
|
117
148
|
intent: plan.intent,
|
|
@@ -129,8 +160,23 @@ export function buildAssistantWorkflowExecutionPlanTracePayload(plan) {
|
|
|
129
160
|
blockingReasons: plan.blockingReasons,
|
|
130
161
|
warnings: plan.warnings,
|
|
131
162
|
executionHints: plan.executionHints,
|
|
163
|
+
executionBudget: plan.executionBudget ?? null,
|
|
164
|
+
budgetAssessment: plan.budgetAssessment
|
|
165
|
+
? buildAssistantWorkflowExecutionBudgetTracePayload(plan.budgetAssessment)
|
|
166
|
+
: null,
|
|
167
|
+
executionPolicy: plan.executionPolicy ?? resolveAssistantWorkflowExecutionPolicy(),
|
|
132
168
|
};
|
|
133
169
|
}
|
|
170
|
+
function getMaximumPlannedToolCalls(workflow, steps, policy) {
|
|
171
|
+
const capabilities = new Map((workflow.tools ?? []).map((tool) => [tool.name, tool]));
|
|
172
|
+
return steps
|
|
173
|
+
.filter((step) => step.status !== "blocked" && step.status !== "optional-skipped")
|
|
174
|
+
.flatMap((step) => step.readyToolNames)
|
|
175
|
+
.reduce((count, toolName) => {
|
|
176
|
+
const retryClass = capabilities.get(toolName)?.retryClass;
|
|
177
|
+
return count + (retryClass === "never" ? 1 : policy.maxAttemptsPerTool);
|
|
178
|
+
}, 0);
|
|
179
|
+
}
|
|
134
180
|
function buildToolBlockingReasons(stepId, resolutions) {
|
|
135
181
|
return resolutions.map((resolution) => `${stepId} required tool ${resolution.toolName} is ${resolution.status}`);
|
|
136
182
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-plan.js","sourceRoot":"","sources":["../src/execution-plan.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,6BAA6B,GAE9B,MAAM,oBAAoB,CAAC;AAqD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I,GAAG,IAAI,GAAG,EAA2C,CAAC;IAChE,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,SAAS;QAC9B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAChB,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import type { AssistantWorkflowDecision } from \"./decision.js\";\nimport {\n type AssistantWorkflowDefinition,\n type AssistantWorkflowPlanningStepKind,\n type AssistantWorkflowToolContextRequirement,\n} from \"./definition.js\";\nimport {\n resolveAssistantWorkflowTools,\n type AssistantWorkflowToolResolution,\n} from \"./tool-bindings.js\";\n\nexport type AssistantWorkflowExecutionPlanStatus =\n | \"ready\"\n | \"needs-clarification\"\n | \"blocked\"\n | \"partial\";\n\nexport type AssistantWorkflowExecutionStepStatus =\n | \"ready\"\n | \"blocked\"\n | \"optional-skipped\"\n | \"partial\";\n\nexport type AssistantWorkflowExecutionStep = {\n id: string;\n kind: AssistantWorkflowPlanningStepKind;\n optional: boolean;\n status: AssistantWorkflowExecutionStepStatus;\n toolNames: string[];\n requiredToolNames: string[];\n readyToolNames: string[];\n missingCapabilityNames: string[];\n missingBindingNames: string[];\n providerMismatchNames: string[];\n requiredContext: AssistantWorkflowToolContextRequirement[];\n missingContextRequirements: AssistantWorkflowToolContextRequirement[];\n blockingReasons: string[];\n warnings: string[];\n};\n\nexport type AssistantWorkflowExecutionPlan = {\n intent: string | null;\n status: AssistantWorkflowExecutionPlanStatus;\n steps: AssistantWorkflowExecutionStep[];\n readyToolNames: string[];\n requiredReadyToolNames: string[];\n missingCapabilityNames: string[];\n missingBindingNames: string[];\n providerMismatchNames: string[];\n requiredContext: AssistantWorkflowToolContextRequirement[];\n missingContextRequirements: AssistantWorkflowToolContextRequirement[];\n missingPlanningSteps: string[];\n clarificationRuleIds: string[];\n blockingReasons: string[];\n warnings: string[];\n executionHints: AssistantWorkflowDecision[\"plan\"][\"executionHints\"];\n};\n\nexport type AssistantWorkflowExecutionPlanOptions = {\n availableContext?: readonly AssistantWorkflowToolContextRequirement[] | null;\n};\n\nexport function buildAssistantWorkflowExecutionPlan(\n workflow: AssistantWorkflowDefinition<string, string, string, string>,\n decision: AssistantWorkflowDecision,\n options: AssistantWorkflowExecutionPlanOptions = {},\n): AssistantWorkflowExecutionPlan {\n const availableContext = options.availableContext ? new Set(options.availableContext) : null;\n const steps = decision.plan.steps.map((step) => {\n const requiredToolNames = uniqueStrings(step.requiredToolHints);\n const optionalToolNames = uniqueStrings(step.toolHints).filter((tool) => !requiredToolNames.includes(tool));\n const toolNames = uniqueStrings([...requiredToolNames, ...optionalToolNames]);\n const requiredResolution = resolveAssistantWorkflowTools(workflow, requiredToolNames);\n const optionalResolution = resolveAssistantWorkflowTools(workflow, optionalToolNames);\n const allResolutions = [...requiredResolution.resolutions, ...optionalResolution.resolutions];\n const requiredNonReady = requiredResolution.resolutions.filter((resolution) => resolution.status !== \"ready\");\n const optionalNonReady = optionalResolution.resolutions.filter((resolution) => resolution.status !== \"ready\");\n const requiredContextGaps = getContextGaps(requiredResolution.resolutions, availableContext);\n const optionalContextGaps = getContextGaps(optionalResolution.resolutions, availableContext);\n const contextBlockingReasons = step.optional\n ? []\n : buildContextBlockingReasons(step.id, requiredContextGaps);\n const blockingReasons = step.optional\n ? []\n : [\n ...buildToolBlockingReasons(step.id, requiredNonReady),\n ...contextBlockingReasons,\n ];\n const warnings = [\n ...buildToolWarnings(step.id, step.optional ? requiredNonReady : []),\n ...buildToolWarnings(step.id, optionalNonReady),\n ...buildContextWarnings(step.id, step.optional ? requiredContextGaps : []),\n ...buildContextWarnings(step.id, optionalContextGaps),\n ];\n const status: AssistantWorkflowExecutionStepStatus =\n step.optional && (requiredNonReady.length > 0 || requiredContextGaps.length > 0)\n ? \"optional-skipped\"\n : blockingReasons.length > 0\n ? \"blocked\"\n : optionalNonReady.length > 0 || optionalContextGaps.length > 0\n ? \"partial\"\n : \"ready\";\n const allContextGaps = [...requiredContextGaps, ...optionalContextGaps];\n\n return {\n id: step.id,\n kind: step.kind,\n optional: step.optional,\n status,\n toolNames,\n requiredToolNames,\n readyToolNames: uniqueStrings(allResolutions\n .filter((resolution) => resolution.status === \"ready\" && getMissingContextRequirements(resolution, availableContext).length === 0)\n .map((resolution) => resolution.toolName)),\n missingCapabilityNames: getResolutionNames(allResolutions, \"missing-capability\"),\n missingBindingNames: getResolutionNames(allResolutions, \"missing-binding\"),\n providerMismatchNames: getResolutionNames(allResolutions, \"provider-mismatch\"),\n requiredContext: uniqueContextRequirements(allResolutions.flatMap((resolution) => resolution.capability?.requiredContext ?? [])),\n missingContextRequirements: uniqueContextRequirements(allContextGaps.flatMap((gap) => gap.missingContextRequirements)),\n blockingReasons,\n warnings,\n };\n });\n\n const requiredResolution = resolveAssistantWorkflowTools(workflow, decision.requiredToolHints);\n const requiredContextGaps = getContextGaps(requiredResolution.resolutions, availableContext);\n const blockingReasons = [\n ...decision.clarificationPolicy.blockingRuleIds.map((ruleId) => `clarification required: ${ruleId}`),\n ...decision.plan.missingPlanningSteps.map((stepId) => `missing planning step: ${stepId}`),\n ...decision.missingRequiredToolHints.map((toolName) => `required tool is unavailable: ${toolName}`),\n ...buildToolBlockingReasons(\"workflow\", requiredResolution.resolutions.filter((resolution) => resolution.status !== \"ready\")),\n ...buildContextBlockingReasons(\"workflow\", requiredContextGaps),\n ...steps.flatMap((step) => step.blockingReasons),\n ];\n const warnings = uniqueStrings([\n ...decision.missingToolHints.map((toolName) => `optional tool is unavailable: ${toolName}`),\n ...steps.flatMap((step) => step.warnings),\n ]);\n const allStepTools = steps.flatMap((step) => step.toolNames);\n const allResolution = resolveAssistantWorkflowTools(workflow, allStepTools);\n const allContextGaps = getContextGaps(allResolution.resolutions, availableContext);\n const status: AssistantWorkflowExecutionPlanStatus =\n decision.clarificationPolicy.needsClarification\n ? \"needs-clarification\"\n : blockingReasons.length > 0\n ? \"blocked\"\n : warnings.length > 0 || steps.some((step) => step.status === \"partial\" || step.status === \"optional-skipped\")\n ? \"partial\"\n : \"ready\";\n\n return {\n intent: decision.intent,\n status,\n steps,\n readyToolNames: uniqueStrings(allResolution.resolutions\n .filter((resolution) => resolution.status === \"ready\" && getMissingContextRequirements(resolution, availableContext).length === 0)\n .map((resolution) => resolution.toolName)),\n requiredReadyToolNames: uniqueStrings(requiredResolution.resolutions\n .filter((resolution) => resolution.status === \"ready\" && getMissingContextRequirements(resolution, availableContext).length === 0)\n .map((resolution) => resolution.toolName)),\n missingCapabilityNames: uniqueStrings([\n ...allResolution.missingCapabilityNames,\n ...requiredResolution.missingCapabilityNames,\n ]),\n missingBindingNames: uniqueStrings([\n ...allResolution.missingBindingNames,\n ...requiredResolution.missingBindingNames,\n ]),\n providerMismatchNames: uniqueStrings([\n ...allResolution.providerMismatchNames,\n ...requiredResolution.providerMismatchNames,\n ]),\n requiredContext: uniqueContextRequirements(allResolution.resolutions.flatMap((resolution) => resolution.capability?.requiredContext ?? [])),\n missingContextRequirements: uniqueContextRequirements([\n ...allContextGaps.flatMap((gap) => gap.missingContextRequirements),\n ...requiredContextGaps.flatMap((gap) => gap.missingContextRequirements),\n ]),\n missingPlanningSteps: [...decision.plan.missingPlanningSteps],\n clarificationRuleIds: [...decision.clarificationPolicy.blockingRuleIds],\n blockingReasons: uniqueStrings(blockingReasons),\n warnings,\n executionHints: decision.plan.executionHints,\n };\n}\n\nexport function buildAssistantWorkflowExecutionPlanTracePayload(\n plan: AssistantWorkflowExecutionPlan,\n): Record<string, unknown> {\n return {\n intent: plan.intent,\n status: plan.status,\n steps: plan.steps,\n readyToolNames: plan.readyToolNames,\n requiredReadyToolNames: plan.requiredReadyToolNames,\n missingCapabilityNames: plan.missingCapabilityNames,\n missingBindingNames: plan.missingBindingNames,\n providerMismatchNames: plan.providerMismatchNames,\n requiredContext: plan.requiredContext,\n missingContextRequirements: plan.missingContextRequirements,\n missingPlanningSteps: plan.missingPlanningSteps,\n clarificationRuleIds: plan.clarificationRuleIds,\n blockingReasons: plan.blockingReasons,\n warnings: plan.warnings,\n executionHints: plan.executionHints,\n };\n}\n\nfunction buildToolBlockingReasons(stepId: string, resolutions: readonly AssistantWorkflowToolResolution[]): string[] {\n return resolutions.map((resolution) => `${stepId} required tool ${resolution.toolName} is ${resolution.status}`);\n}\n\nfunction buildToolWarnings(stepId: string, resolutions: readonly AssistantWorkflowToolResolution[]): string[] {\n return resolutions.map((resolution) => `${stepId} optional tool ${resolution.toolName} is ${resolution.status}`);\n}\n\ntype ToolContextGap = {\n toolName: string;\n missingContextRequirements: AssistantWorkflowToolContextRequirement[];\n};\n\nfunction getContextGaps(\n resolutions: readonly AssistantWorkflowToolResolution[],\n availableContext: ReadonlySet<AssistantWorkflowToolContextRequirement> | null,\n): ToolContextGap[] {\n return resolutions\n .map((resolution) => ({\n toolName: resolution.toolName,\n missingContextRequirements: getMissingContextRequirements(resolution, availableContext),\n }))\n .filter((gap) => gap.missingContextRequirements.length > 0);\n}\n\nfunction getMissingContextRequirements(\n resolution: AssistantWorkflowToolResolution,\n availableContext: ReadonlySet<AssistantWorkflowToolContextRequirement> | null,\n): AssistantWorkflowToolContextRequirement[] {\n if (!availableContext || resolution.status !== \"ready\") return [];\n return uniqueContextRequirements(resolution.capability?.requiredContext ?? [])\n .filter((requirement) => !availableContext.has(requirement));\n}\n\nfunction buildContextBlockingReasons(stepId: string, gaps: readonly ToolContextGap[]): string[] {\n return gaps.map((gap) =>\n `${stepId} required tool ${gap.toolName} missing context: ${gap.missingContextRequirements.join(\", \")}`,\n );\n}\n\nfunction buildContextWarnings(stepId: string, gaps: readonly ToolContextGap[]): string[] {\n return gaps.map((gap) =>\n `${stepId} optional tool ${gap.toolName} missing context: ${gap.missingContextRequirements.join(\", \")}`,\n );\n}\n\nfunction getResolutionNames(\n resolutions: readonly AssistantWorkflowToolResolution[],\n status: AssistantWorkflowToolResolution[\"status\"],\n): string[] {\n return uniqueStrings(\n resolutions\n .filter((resolution) => resolution.status === status)\n .map((resolution) => resolution.toolName),\n );\n}\n\nfunction uniqueStrings(values: readonly string[]): string[] {\n const out: string[] = [];\n const seen = new Set<string>();\n for (const value of values) {\n if (seen.has(value)) continue;\n seen.add(value);\n out.push(value);\n }\n return out;\n}\n\nfunction uniqueContextRequirements(\n values: readonly AssistantWorkflowToolContextRequirement[],\n): AssistantWorkflowToolContextRequirement[] {\n const out: AssistantWorkflowToolContextRequirement[] = [];\n const seen = new Set<AssistantWorkflowToolContextRequirement>();\n for (const value of values) {\n if (seen.has(value)) continue;\n seen.add(value);\n out.push(value);\n }\n return out;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"execution-plan.js","sourceRoot":"","sources":["../src/execution-plan.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,6BAA6B,GAE9B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,+CAA+C,EAC/C,iDAAiD,EACjD,+CAA+C,GAGhD,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,uCAAuC,GAExC,MAAM,uBAAuB,CAAC;AA2D/B,MAAM,UAAU,mCAAmC,CACjD,QAAqE,EACrE,QAAmC,EACnC,UAAiD,EAAE;IAEnD,MAAM,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7F,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5E,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IACtC,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC7C,MAAM,wBAAw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AC,KAAK,CAAC,CAAC;QAChB,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import type { AssistantWorkflowDecision } from \"./decision.js\";\nimport {\n type AssistantWorkflowDefinition,\n type AssistantWorkflowPlanningStepKind,\n type AssistantWorkflowToolContextRequirement,\n} from \"./definition.js\";\nimport {\n resolveAssistantWorkflowTools,\n type AssistantWorkflowToolResolution,\n} from \"./tool-bindings.js\";\nimport {\n buildAssistantWorkflowExecutionBudgetAssessment,\n buildAssistantWorkflowExecutionBudgetTracePayload,\n formatAssistantWorkflowExecutionBudgetViolation,\n type AssistantWorkflowExecutionBudget,\n type AssistantWorkflowExecutionBudgetAssessment,\n} from \"./execution-budget.js\";\nimport {\n resolveAssistantWorkflowExecutionPolicy,\n type AssistantWorkflowExecutionPolicy,\n} from \"./execution-policy.js\";\n\nexport type AssistantWorkflowExecutionPlanStatus =\n | \"ready\"\n | \"needs-clarification\"\n | \"blocked\"\n | \"partial\";\n\nexport type AssistantWorkflowExecutionStepStatus =\n | \"ready\"\n | \"blocked\"\n | \"optional-skipped\"\n | \"partial\";\n\nexport type AssistantWorkflowExecutionStep = {\n id: string;\n kind: AssistantWorkflowPlanningStepKind;\n optional: boolean;\n dependsOnStepIds: string[];\n missingDependencyStepIds: string[];\n outOfOrderDependencyStepIds: string[];\n status: AssistantWorkflowExecutionStepStatus;\n toolNames: string[];\n requiredToolNames: string[];\n readyToolNames: string[];\n missingCapabilityNames: string[];\n missingBindingNames: string[];\n providerMismatchNames: string[];\n requiredContext: AssistantWorkflowToolContextRequirement[];\n missingContextRequirements: AssistantWorkflowToolContextRequirement[];\n blockingReasons: string[];\n warnings: string[];\n};\n\nexport type AssistantWorkflowExecutionPlan = {\n intent: string | null;\n status: AssistantWorkflowExecutionPlanStatus;\n steps: AssistantWorkflowExecutionStep[];\n readyToolNames: string[];\n requiredReadyToolNames: string[];\n missingCapabilityNames: string[];\n missingBindingNames: string[];\n providerMismatchNames: string[];\n requiredContext: AssistantWorkflowToolContextRequirement[];\n missingContextRequirements: AssistantWorkflowToolContextRequirement[];\n missingPlanningSteps: string[];\n clarificationRuleIds: string[];\n blockingReasons: string[];\n warnings: string[];\n executionHints: AssistantWorkflowDecision[\"plan\"][\"executionHints\"];\n executionBudget?: AssistantWorkflowExecutionBudget | null;\n budgetAssessment?: AssistantWorkflowExecutionBudgetAssessment | null;\n executionPolicy?: AssistantWorkflowExecutionPolicy;\n};\n\nexport type AssistantWorkflowExecutionPlanOptions = {\n availableContext?: readonly AssistantWorkflowToolContextRequirement[] | null;\n};\n\nexport function buildAssistantWorkflowExecutionPlan(\n workflow: AssistantWorkflowDefinition<string, string, string, string>,\n decision: AssistantWorkflowDecision,\n options: AssistantWorkflowExecutionPlanOptions = {},\n): AssistantWorkflowExecutionPlan {\n const availableContext = options.availableContext ? new Set(options.availableContext) : null;\n const selectedStepIds = new Set(decision.plan.steps.map((step) => step.id));\n const seenStepIds = new Set<string>();\n const steps = decision.plan.steps.map((step) => {\n const missingDependencyStepIds = step.dependsOnStepIds.filter((stepId) => !selectedStepIds.has(stepId));\n const outOfOrderDependencyStepIds = step.dependsOnStepIds.filter(\n (stepId) => selectedStepIds.has(stepId) && !seenStepIds.has(stepId),\n );\n const requiredToolNames = uniqueStrings(step.requiredToolHints);\n const optionalToolNames = uniqueStrings(step.toolHints).filter((tool) => !requiredToolNames.includes(tool));\n const toolNames = uniqueStrings([...requiredToolNames, ...optionalToolNames]);\n const requiredResolution = resolveAssistantWorkflowTools(workflow, requiredToolNames);\n const optionalResolution = resolveAssistantWorkflowTools(workflow, optionalToolNames);\n const allResolutions = [...requiredResolution.resolutions, ...optionalResolution.resolutions];\n const requiredNonReady = requiredResolution.resolutions.filter((resolution) => resolution.status !== \"ready\");\n const optionalNonReady = optionalResolution.resolutions.filter((resolution) => resolution.status !== \"ready\");\n const requiredContextGaps = getContextGaps(requiredResolution.resolutions, availableContext);\n const optionalContextGaps = getContextGaps(optionalResolution.resolutions, availableContext);\n const contextBlockingReasons = step.optional\n ? []\n : buildContextBlockingReasons(step.id, requiredContextGaps);\n const dependencyReasons = buildDependencyReasons(\n step.id,\n missingDependencyStepIds,\n outOfOrderDependencyStepIds,\n );\n const blockingReasons = step.optional\n ? []\n : [\n ...buildToolBlockingReasons(step.id, requiredNonReady),\n ...contextBlockingReasons,\n ...dependencyReasons,\n ];\n const warnings = [\n ...buildToolWarnings(step.id, step.optional ? requiredNonReady : []),\n ...buildToolWarnings(step.id, optionalNonReady),\n ...buildContextWarnings(step.id, step.optional ? requiredContextGaps : []),\n ...buildContextWarnings(step.id, optionalContextGaps),\n ...(step.optional ? dependencyReasons : []),\n ];\n const status: AssistantWorkflowExecutionStepStatus =\n step.optional && (requiredNonReady.length > 0 || requiredContextGaps.length > 0)\n ? \"optional-skipped\"\n : blockingReasons.length > 0\n ? \"blocked\"\n : optionalNonReady.length > 0 || optionalContextGaps.length > 0\n ? \"partial\"\n : \"ready\";\n const allContextGaps = [...requiredContextGaps, ...optionalContextGaps];\n\n const result: AssistantWorkflowExecutionStep = {\n id: step.id,\n kind: step.kind,\n optional: step.optional,\n dependsOnStepIds: [...step.dependsOnStepIds],\n missingDependencyStepIds,\n outOfOrderDependencyStepIds,\n status,\n toolNames,\n requiredToolNames,\n readyToolNames: uniqueStrings(allResolutions\n .filter((resolution) => resolution.status === \"ready\" && getMissingContextRequirements(resolution, availableContext).length === 0)\n .map((resolution) => resolution.toolName)),\n missingCapabilityNames: getResolutionNames(allResolutions, \"missing-capability\"),\n missingBindingNames: getResolutionNames(allResolutions, \"missing-binding\"),\n providerMismatchNames: getResolutionNames(allResolutions, \"provider-mismatch\"),\n requiredContext: uniqueContextRequirements(allResolutions.flatMap((resolution) => resolution.capability?.requiredContext ?? [])),\n missingContextRequirements: uniqueContextRequirements(allContextGaps.flatMap((gap) => gap.missingContextRequirements)),\n blockingReasons,\n warnings,\n };\n seenStepIds.add(step.id);\n return result;\n });\n\n const requiredResolution = resolveAssistantWorkflowTools(workflow, decision.requiredToolHints);\n const requiredContextGaps = getContextGaps(requiredResolution.resolutions, availableContext);\n const executionPolicy = resolveAssistantWorkflowExecutionPolicy(workflow.executionPolicy);\n const budgetAssessment = workflow.executionBudget\n ? buildAssistantWorkflowExecutionBudgetAssessment(workflow.executionBudget, {\n planningStepCount: steps.length,\n toolCallCount: getMaximumPlannedToolCalls(workflow, steps, executionPolicy),\n })\n : null;\n const blockingReasons = [\n ...decision.clarificationPolicy.blockingRuleIds.map((ruleId) => `clarification required: ${ruleId}`),\n ...decision.plan.missingPlanningSteps.map((stepId) => `missing planning step: ${stepId}`),\n ...decision.missingRequiredToolHints.map((toolName) => `required tool is unavailable: ${toolName}`),\n ...buildToolBlockingReasons(\"workflow\", requiredResolution.resolutions.filter((resolution) => resolution.status !== \"ready\")),\n ...buildContextBlockingReasons(\"workflow\", requiredContextGaps),\n ...steps.flatMap((step) => step.blockingReasons),\n ...(budgetAssessment?.violations.map(formatAssistantWorkflowExecutionBudgetViolation) ?? []),\n ];\n const warnings = uniqueStrings([\n ...decision.missingToolHints.map((toolName) => `optional tool is unavailable: ${toolName}`),\n ...steps.flatMap((step) => step.warnings),\n ]);\n const allStepTools = steps.flatMap((step) => step.toolNames);\n const allResolution = resolveAssistantWorkflowTools(workflow, allStepTools);\n const allContextGaps = getContextGaps(allResolution.resolutions, availableContext);\n const status: AssistantWorkflowExecutionPlanStatus =\n decision.clarificationPolicy.needsClarification\n ? \"needs-clarification\"\n : blockingReasons.length > 0\n ? \"blocked\"\n : warnings.length > 0 || steps.some((step) => step.status === \"partial\" || step.status === \"optional-skipped\")\n ? \"partial\"\n : \"ready\";\n\n return {\n intent: decision.intent,\n status,\n steps,\n readyToolNames: uniqueStrings(allResolution.resolutions\n .filter((resolution) => resolution.status === \"ready\" && getMissingContextRequirements(resolution, availableContext).length === 0)\n .map((resolution) => resolution.toolName)),\n requiredReadyToolNames: uniqueStrings(requiredResolution.resolutions\n .filter((resolution) => resolution.status === \"ready\" && getMissingContextRequirements(resolution, availableContext).length === 0)\n .map((resolution) => resolution.toolName)),\n missingCapabilityNames: uniqueStrings([\n ...allResolution.missingCapabilityNames,\n ...requiredResolution.missingCapabilityNames,\n ]),\n missingBindingNames: uniqueStrings([\n ...allResolution.missingBindingNames,\n ...requiredResolution.missingBindingNames,\n ]),\n providerMismatchNames: uniqueStrings([\n ...allResolution.providerMismatchNames,\n ...requiredResolution.providerMismatchNames,\n ]),\n requiredContext: uniqueContextRequirements(allResolution.resolutions.flatMap((resolution) => resolution.capability?.requiredContext ?? [])),\n missingContextRequirements: uniqueContextRequirements([\n ...allContextGaps.flatMap((gap) => gap.missingContextRequirements),\n ...requiredContextGaps.flatMap((gap) => gap.missingContextRequirements),\n ]),\n missingPlanningSteps: [...decision.plan.missingPlanningSteps],\n clarificationRuleIds: [...decision.clarificationPolicy.blockingRuleIds],\n blockingReasons: uniqueStrings(blockingReasons),\n warnings,\n executionHints: decision.plan.executionHints,\n executionBudget: workflow.executionBudget ? { ...workflow.executionBudget } : null,\n budgetAssessment,\n executionPolicy,\n };\n}\n\nfunction buildDependencyReasons(\n stepId: string,\n missingDependencyStepIds: readonly string[],\n outOfOrderDependencyStepIds: readonly string[],\n): string[] {\n return [\n ...missingDependencyStepIds.map((dependencyId) => `${stepId} missing dependency step: ${dependencyId}`),\n ...outOfOrderDependencyStepIds.map((dependencyId) => `${stepId} dependency must run first: ${dependencyId}`),\n ];\n}\n\nexport function buildAssistantWorkflowExecutionPlanTracePayload(\n plan: AssistantWorkflowExecutionPlan,\n): Record<string, unknown> {\n return {\n intent: plan.intent,\n status: plan.status,\n steps: plan.steps,\n readyToolNames: plan.readyToolNames,\n requiredReadyToolNames: plan.requiredReadyToolNames,\n missingCapabilityNames: plan.missingCapabilityNames,\n missingBindingNames: plan.missingBindingNames,\n providerMismatchNames: plan.providerMismatchNames,\n requiredContext: plan.requiredContext,\n missingContextRequirements: plan.missingContextRequirements,\n missingPlanningSteps: plan.missingPlanningSteps,\n clarificationRuleIds: plan.clarificationRuleIds,\n blockingReasons: plan.blockingReasons,\n warnings: plan.warnings,\n executionHints: plan.executionHints,\n executionBudget: plan.executionBudget ?? null,\n budgetAssessment: plan.budgetAssessment\n ? buildAssistantWorkflowExecutionBudgetTracePayload(plan.budgetAssessment)\n : null,\n executionPolicy: plan.executionPolicy ?? resolveAssistantWorkflowExecutionPolicy(),\n };\n}\n\nfunction getMaximumPlannedToolCalls(\n workflow: AssistantWorkflowDefinition<string, string, string, string>,\n steps: readonly AssistantWorkflowExecutionStep[],\n policy: AssistantWorkflowExecutionPolicy,\n): number {\n const capabilities = new Map((workflow.tools ?? []).map((tool) => [tool.name, tool] as const));\n return steps\n .filter((step) => step.status !== \"blocked\" && step.status !== \"optional-skipped\")\n .flatMap((step) => step.readyToolNames)\n .reduce((count, toolName) => {\n const retryClass = capabilities.get(toolName)?.retryClass;\n return count + (retryClass === \"never\" ? 1 : policy.maxAttemptsPerTool);\n }, 0);\n}\n\nfunction buildToolBlockingReasons(stepId: string, resolutions: readonly AssistantWorkflowToolResolution[]): string[] {\n return resolutions.map((resolution) => `${stepId} required tool ${resolution.toolName} is ${resolution.status}`);\n}\n\nfunction buildToolWarnings(stepId: string, resolutions: readonly AssistantWorkflowToolResolution[]): string[] {\n return resolutions.map((resolution) => `${stepId} optional tool ${resolution.toolName} is ${resolution.status}`);\n}\n\ntype ToolContextGap = {\n toolName: string;\n missingContextRequirements: AssistantWorkflowToolContextRequirement[];\n};\n\nfunction getContextGaps(\n resolutions: readonly AssistantWorkflowToolResolution[],\n availableContext: ReadonlySet<AssistantWorkflowToolContextRequirement> | null,\n): ToolContextGap[] {\n return resolutions\n .map((resolution) => ({\n toolName: resolution.toolName,\n missingContextRequirements: getMissingContextRequirements(resolution, availableContext),\n }))\n .filter((gap) => gap.missingContextRequirements.length > 0);\n}\n\nfunction getMissingContextRequirements(\n resolution: AssistantWorkflowToolResolution,\n availableContext: ReadonlySet<AssistantWorkflowToolContextRequirement> | null,\n): AssistantWorkflowToolContextRequirement[] {\n if (!availableContext || resolution.status !== \"ready\") return [];\n return uniqueContextRequirements(resolution.capability?.requiredContext ?? [])\n .filter((requirement) => !availableContext.has(requirement));\n}\n\nfunction buildContextBlockingReasons(stepId: string, gaps: readonly ToolContextGap[]): string[] {\n return gaps.map((gap) =>\n `${stepId} required tool ${gap.toolName} missing context: ${gap.missingContextRequirements.join(\", \")}`,\n );\n}\n\nfunction buildContextWarnings(stepId: string, gaps: readonly ToolContextGap[]): string[] {\n return gaps.map((gap) =>\n `${stepId} optional tool ${gap.toolName} missing context: ${gap.missingContextRequirements.join(\", \")}`,\n );\n}\n\nfunction getResolutionNames(\n resolutions: readonly AssistantWorkflowToolResolution[],\n status: AssistantWorkflowToolResolution[\"status\"],\n): string[] {\n return uniqueStrings(\n resolutions\n .filter((resolution) => resolution.status === status)\n .map((resolution) => resolution.toolName),\n );\n}\n\nfunction uniqueStrings(values: readonly string[]): string[] {\n const out: string[] = [];\n const seen = new Set<string>();\n for (const value of values) {\n if (seen.has(value)) continue;\n seen.add(value);\n out.push(value);\n }\n return out;\n}\n\nfunction uniqueContextRequirements(\n values: readonly AssistantWorkflowToolContextRequirement[],\n): AssistantWorkflowToolContextRequirement[] {\n const out: AssistantWorkflowToolContextRequirement[] = [];\n const seen = new Set<AssistantWorkflowToolContextRequirement>();\n for (const value of values) {\n if (seen.has(value)) continue;\n seen.add(value);\n out.push(value);\n }\n return out;\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type AssistantWorkflowExecutionFailureMode = "fail-fast" | "continue-independent";
|
|
2
|
+
export type AssistantWorkflowExecutionPolicy = {
|
|
3
|
+
failureMode: AssistantWorkflowExecutionFailureMode;
|
|
4
|
+
maxAttemptsPerTool: 1 | 2 | 3;
|
|
5
|
+
};
|
|
6
|
+
export declare const DEFAULT_ASSISTANT_WORKFLOW_EXECUTION_POLICY: AssistantWorkflowExecutionPolicy;
|
|
7
|
+
export declare function assertAssistantWorkflowExecutionPolicy(policy: AssistantWorkflowExecutionPolicy): void;
|
|
8
|
+
export declare function resolveAssistantWorkflowExecutionPolicy(policy?: AssistantWorkflowExecutionPolicy | null): AssistantWorkflowExecutionPolicy;
|
|
9
|
+
//# sourceMappingURL=execution-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-policy.d.ts","sourceRoot":"","sources":["../src/execution-policy.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qCAAqC,GAC7C,WAAW,GACX,sBAAsB,CAAC;AAE3B,MAAM,MAAM,gCAAgC,GAAG;IAC7C,WAAW,EAAE,qCAAqC,CAAC;IACnD,kBAAkB,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CAC/B,CAAC;AAEF,eAAO,MAAM,2CAA2C,EAAE,gCAItD,CAAC;AAEL,wBAAgB,sCAAsC,CACpD,MAAM,EAAE,gCAAgC,GACvC,IAAI,CAWN;AAED,wBAAgB,uCAAuC,CACrD,MAAM,CAAC,EAAE,gCAAgC,GAAG,IAAI,GAC/C,gCAAgC,CAIlC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const DEFAULT_ASSISTANT_WORKFLOW_EXECUTION_POLICY = Object.freeze({
|
|
2
|
+
failureMode: "fail-fast",
|
|
3
|
+
maxAttemptsPerTool: 1,
|
|
4
|
+
});
|
|
5
|
+
export function assertAssistantWorkflowExecutionPolicy(policy) {
|
|
6
|
+
if (policy.failureMode !== "fail-fast" && policy.failureMode !== "continue-independent") {
|
|
7
|
+
throw new Error("Assistant workflow execution policy failureMode is invalid.");
|
|
8
|
+
}
|
|
9
|
+
if (policy.maxAttemptsPerTool !== 1 &&
|
|
10
|
+
policy.maxAttemptsPerTool !== 2 &&
|
|
11
|
+
policy.maxAttemptsPerTool !== 3) {
|
|
12
|
+
throw new Error("Assistant workflow execution policy maxAttemptsPerTool must be 1, 2, or 3.");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export function resolveAssistantWorkflowExecutionPolicy(policy) {
|
|
16
|
+
if (!policy)
|
|
17
|
+
return { ...DEFAULT_ASSISTANT_WORKFLOW_EXECUTION_POLICY };
|
|
18
|
+
assertAssistantWorkflowExecutionPolicy(policy);
|
|
19
|
+
return { ...policy };
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=execution-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-policy.js","sourceRoot":"","sources":["../src/execution-policy.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,2CAA2C,GACtD,MAAM,CAAC,MAAM,CAAC;IACZ,WAAW,EAAE,WAAW;IACxB,kBAAkB,EAAE,CAAC;CACtB,CAAC,CAAC;AAEL,MAAM,UAAU,sCAAsC,CACpD,MAAwC;IAExC,IAAI,MAAM,CAAC,WAAW,KAAK,WAAW,IAAI,MAAM,CAAC,WAAW,KAAK,sBAAsB,EAAE,CAAC;QACxF,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;IACjF,CAAC;IACD,IACE,MAAM,CAAC,kBAAkB,KAAK,CAAC;QAC/B,MAAM,CAAC,kBAAkB,KAAK,CAAC;QAC/B,MAAM,CAAC,kBAAkB,KAAK,CAAC,EAC/B,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,4EAA4E,CAAC,CAAC;IAChG,CAAC;AACH,CAAC;AAED,MAAM,UAAU,uCAAuC,CACrD,MAAgD;IAEhD,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,GAAG,2CAA2C,EAAE,CAAC;IACvE,sCAAsC,CAAC,MAAM,CAAC,CAAC;IAC/C,OAAO,EAAE,GAAG,MAAM,EAAE,CAAC;AACvB,CAAC","sourcesContent":["export type AssistantWorkflowExecutionFailureMode =\n | \"fail-fast\"\n | \"continue-independent\";\n\nexport type AssistantWorkflowExecutionPolicy = {\n failureMode: AssistantWorkflowExecutionFailureMode;\n maxAttemptsPerTool: 1 | 2 | 3;\n};\n\nexport const DEFAULT_ASSISTANT_WORKFLOW_EXECUTION_POLICY: AssistantWorkflowExecutionPolicy =\n Object.freeze({\n failureMode: \"fail-fast\",\n maxAttemptsPerTool: 1,\n });\n\nexport function assertAssistantWorkflowExecutionPolicy(\n policy: AssistantWorkflowExecutionPolicy,\n): void {\n if (policy.failureMode !== \"fail-fast\" && policy.failureMode !== \"continue-independent\") {\n throw new Error(\"Assistant workflow execution policy failureMode is invalid.\");\n }\n if (\n policy.maxAttemptsPerTool !== 1 &&\n policy.maxAttemptsPerTool !== 2 &&\n policy.maxAttemptsPerTool !== 3\n ) {\n throw new Error(\"Assistant workflow execution policy maxAttemptsPerTool must be 1, 2, or 3.\");\n }\n}\n\nexport function resolveAssistantWorkflowExecutionPolicy(\n policy?: AssistantWorkflowExecutionPolicy | null,\n): AssistantWorkflowExecutionPolicy {\n if (!policy) return { ...DEFAULT_ASSISTANT_WORKFLOW_EXECUTION_POLICY };\n assertAssistantWorkflowExecutionPolicy(policy);\n return { ...policy };\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -35,6 +35,8 @@ export * from "./eval-result.js";
|
|
|
35
35
|
export * from "./eval-runner.js";
|
|
36
36
|
export * from "./eval-suite.js";
|
|
37
37
|
export * from "./execution-plan.js";
|
|
38
|
+
export * from "./execution-budget.js";
|
|
39
|
+
export * from "./execution-policy.js";
|
|
38
40
|
export * from "./hosted-tool-policy.js";
|
|
39
41
|
export * from "./memory-policy.js";
|
|
40
42
|
export * from "./memory-updates.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cA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AClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -35,6 +35,8 @@ export * from "./eval-result.js";
|
|
|
35
35
|
export * from "./eval-runner.js";
|
|
36
36
|
export * from "./eval-suite.js";
|
|
37
37
|
export * from "./execution-plan.js";
|
|
38
|
+
export * from "./execution-budget.js";
|
|
39
|
+
export * from "./execution-policy.js";
|
|
38
40
|
export * from "./hosted-tool-policy.js";
|
|
39
41
|
export * from "./memory-policy.js";
|
|
40
42
|
export * from "./memory-updates.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kCAAkC,CAAC;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,0CAA0C,CAAC;AACzD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,iCAAiC,C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nC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./clarification-policy.js\";\nexport * from \"./decision.js\";\nexport * from \"./definition.js\";\nexport * from \"./definition-catalog.js\";\nexport * from \"./definition-catalog-replay.js\";\nexport * from \"./definition-diagnostics.js\";\nexport * from \"./definition-diff.js\";\nexport * from \"./definition-json.js\";\nexport * from \"./definition-manifest.js\";\nexport * from \"./definition-package.js\";\nexport * from \"./definition-package-executor.js\";\nexport * from \"./definition-package-execution-json.js\";\nexport * from \"./definition-package-execution-replay.js\";\nexport * from \"./definition-package-loader.js\";\nexport * from \"./definition-package-resolver.js\";\nexport * from \"./definition-package-review.js\";\nexport * from \"./definition-package-replay.js\";\nexport * from \"./definition-package-run.js\";\nexport * from \"./definition-package-run-report.js\";\nexport * from \"./definition-package-selection.js\";\nexport * from \"./definition-package-smoke.js\";\nexport * from \"./definition-tuning.js\";\nexport * from \"./definition-tuning-approval.js\";\nexport * from \"./definition-tuning-json.js\";\nexport * from \"./definition-tuning-promotion.js\";\nexport * from \"./definition-tuning-replay.js\";\nexport * from \"./definition-tuning-review.js\";\nexport * from \"./definition-tuning-review-artifact.js\";\nexport * from \"./definition-tuning-source-patch.js\";\nexport * from \"./direct-route-invocation.js\";\nexport * from \"./direct-route-policy.js\";\nexport * from \"./eval-case.js\";\nexport * from \"./eval-replay.js\";\nexport * from \"./eval-result.js\";\nexport * from \"./eval-runner.js\";\nexport * from \"./eval-suite.js\";\nexport * from \"./execution-plan.js\";\nexport * from \"./hosted-tool-policy.js\";\nexport * from \"./memory-policy.js\";\nexport * from \"./memory-updates.js\";\nexport * from \"./outcome.js\";\nexport * from \"./outcome-trace.js\";\nexport * from \"./policy-resolution.js\";\nexport * from \"./planner-compiler.js\";\nexport * from \"./planning.js\";\nexport * from \"./run.js\";\nexport * from \"./run-parity.js\";\nexport * from \"./run-evaluation.js\";\nexport * from \"./run-report.js\";\nexport * from \"./run-report-batch.js\";\nexport * from \"./run-report-json.js\";\nexport * from \"./tool-invocations.js\";\nexport * from \"./tool-handoffs.js\";\nexport * from \"./tool-provider-executors.js\";\nexport * from \"./tool-result-cache.js\";\nexport * from \"./tool-runtime.js\";\nexport * from \"./tool-selection-evaluation.js\";\nexport * from \"./tool-selection-json.js\";\nexport * from \"./tool-selection-policy.js\";\nexport * from \"./tool-selection-rules.js\";\nexport * from \"./tool-selection-replay.js\";\nexport * from \"./tool-selection-trace-export.js\";\nexport * from \"./tool-results.js\";\nexport * from \"./trace-events.js\";\nexport * from \"./trace-payload.js\";\nexport * from \"./trace-stages.js\";\nexport * from \"./trace-report.js\";\nexport * from \"./trace-replay.js\";\nexport * from \"./tool-bindings.js\";\nexport * from \"./tool-capabilities.js\";\nexport * from \"./tool-executor.js\";\nexport * from \"./tool-evidence.js\";\nexport * from \"./tool-fixtures.js\";\nexport * from \"./value-readers.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kCAAkC,CAAC;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,0CAA0C,CAAC;AACzD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC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,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./clarification-policy.js\";\nexport * from \"./decision.js\";\nexport * from \"./definition.js\";\nexport * from \"./definition-catalog.js\";\nexport * from \"./definition-catalog-replay.js\";\nexport * from \"./definition-diagnostics.js\";\nexport * from \"./definition-diff.js\";\nexport * from \"./definition-json.js\";\nexport * from \"./definition-manifest.js\";\nexport * from \"./definition-package.js\";\nexport * from \"./definition-package-executor.js\";\nexport * from \"./definition-package-execution-json.js\";\nexport * from \"./definition-package-execution-replay.js\";\nexport * from \"./definition-package-loader.js\";\nexport * from \"./definition-package-resolver.js\";\nexport * from \"./definition-package-review.js\";\nexport * from \"./definition-package-replay.js\";\nexport * from \"./definition-package-run.js\";\nexport * from \"./definition-package-run-report.js\";\nexport * from \"./definition-package-selection.js\";\nexport * from \"./definition-package-smoke.js\";\nexport * from \"./definition-tuning.js\";\nexport * from \"./definition-tuning-approval.js\";\nexport * from \"./definition-tuning-json.js\";\nexport * from \"./definition-tuning-promotion.js\";\nexport * from \"./definition-tuning-replay.js\";\nexport * from \"./definition-tuning-review.js\";\nexport * from \"./definition-tuning-review-artifact.js\";\nexport * from \"./definition-tuning-source-patch.js\";\nexport * from \"./direct-route-invocation.js\";\nexport * from \"./direct-route-policy.js\";\nexport * from \"./eval-case.js\";\nexport * from \"./eval-replay.js\";\nexport * from \"./eval-result.js\";\nexport * from \"./eval-runner.js\";\nexport * from \"./eval-suite.js\";\nexport * from \"./execution-plan.js\";\nexport * from \"./execution-budget.js\";\nexport * from \"./execution-policy.js\";\nexport * from \"./hosted-tool-policy.js\";\nexport * from \"./memory-policy.js\";\nexport * from \"./memory-updates.js\";\nexport * from \"./outcome.js\";\nexport * from \"./outcome-trace.js\";\nexport * from \"./policy-resolution.js\";\nexport * from \"./planner-compiler.js\";\nexport * from \"./planning.js\";\nexport * from \"./run.js\";\nexport * from \"./run-parity.js\";\nexport * from \"./run-evaluation.js\";\nexport * from \"./run-report.js\";\nexport * from \"./run-report-batch.js\";\nexport * from \"./run-report-json.js\";\nexport * from \"./tool-invocations.js\";\nexport * from \"./tool-handoffs.js\";\nexport * from \"./tool-provider-executors.js\";\nexport * from \"./tool-result-cache.js\";\nexport * from \"./tool-runtime.js\";\nexport * from \"./tool-selection-evaluation.js\";\nexport * from \"./tool-selection-json.js\";\nexport * from \"./tool-selection-policy.js\";\nexport * from \"./tool-selection-rules.js\";\nexport * from \"./tool-selection-replay.js\";\nexport * from \"./tool-selection-trace-export.js\";\nexport * from \"./tool-results.js\";\nexport * from \"./trace-events.js\";\nexport * from \"./trace-payload.js\";\nexport * from \"./trace-stages.js\";\nexport * from \"./trace-report.js\";\nexport * from \"./trace-replay.js\";\nexport * from \"./tool-bindings.js\";\nexport * from \"./tool-capabilities.js\";\nexport * from \"./tool-executor.js\";\nexport * from \"./tool-evidence.js\";\nexport * from \"./tool-fixtures.js\";\nexport * from \"./value-readers.js\";\n"]}
|
package/dist/planning.d.ts
CHANGED
package/dist/planning.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planning.d.ts","sourceRoot":"","sources":["../src/planning.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,2BAA2B,EAEhC,KAAK,uCAAuC,EAC5C,KAAK,iCAAiC,EACvC,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,8BAA8B,GAAG;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,iCAAiC,CAAC;IACxC,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,iBAAiB,EAAE,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,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IACzC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC;AAEF,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EACrE,MAAM,EAAE,OAAO,GACd,uCAAuC,GAAG,IAAI,CAIhD;AAED,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EACrE,QAAQ,EAAE,OAAO,EACjB,kBAAkB,GAAE,SAAS,MAAM,EAAO,EAC1C,OAAO,GAAE,4BAAiC,GACzC,qBAAqB,CAmEvB"}
|
package/dist/planning.js
CHANGED
|
@@ -48,6 +48,7 @@ export function buildAssistantWorkflowPlan(workflow, intentId, availableToolName
|
|
|
48
48
|
id: step.id,
|
|
49
49
|
kind: step.kind,
|
|
50
50
|
optional: step.optional === true,
|
|
51
|
+
dependsOnStepIds: uniqueStrings(step.dependsOn ?? []),
|
|
51
52
|
toolHints: filterToolNames(step.toolHints ?? [], availableSet),
|
|
52
53
|
requiredToolHints: filterToolNames(step.requiredToolHints ?? [], availableSet),
|
|
53
54
|
})),
|
package/dist/planning.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planning.js","sourceRoot":"","sources":["../src/planning.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,GAK7B,MAAM,iBAAiB,CAAC;AAsCzB,MAAM,UAAU,iCAAiC,CAC/C,QAAqE,EACrE,MAAe;IAEf,MAAM,UAAU,GAAG,4BAA4B,CAAC,MAAM,CAAC,CAAC;IACxD,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC;IAC7B,OAAO,CAAC,QAAQ,CA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AI,EAAE,CAAC;IACpD,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,CAAC;QAClE,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;IACpE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,eAAe,CAAC,QAA2B,EAAE,YAAiC;IACrF,IAAI,YAAY,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC5D,OAAO,aAAa,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AAC1E,CAAC;AAED,SAAS,aAAa,CAAC,MAAyB;IAC9C,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,UAAU,GAAG,4BAA4B,CAAC,KAAK,CAAC,CAAC;QACvD,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;YAAE,SAAS;QAClD,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACrB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import {\n findAssistantWorkflowIntent,\n normalizeAssistantWorkflowId,\n type AssistantWorkflowDefinition,\n type AssistantWorkflowPlanningStepProfile,\n type AssistantWorkflowPlanningStepDefinition,\n type AssistantWorkflowPlanningStepKind,\n} from \"./definition.js\";\n\nexport type AssistantWorkflowPlanStepTrace = {\n id: string;\n kind: AssistantWorkflowPlanningStepKind;\n optional: boolean;\n toolHints: string[];\n requiredToolHints: string[];\n};\n\nexport type AssistantWorkflowPlanExecutionHints = {\n needsClarification: boolean;\n needsSynthesis: boolean;\n producesArtifact: boolean;\n mayGenerate: boolean;\n};\n\nexport type AssistantWorkflowPlan = {\n stepIds: string[];\n steps: AssistantWorkflowPlanStepTrace[];\n activePlanningStepProfileIds: string[];\n profileStepIds: string[];\n toolHints: string[];\n requiredToolHints: string[];\n missingToolHints: string[];\n missingRequiredToolHints: string[];\n missingPlanningSteps: string[];\n executionHints: AssistantWorkflowPlanExecutionHints;\n};\n\nexport type AssistantWorkflowPlanContext = {\n subintent?: string | null;\n presentation?: string | null;\n timeWindowHint?: string | null;\n toolsToExpose?: readonly string[] | null;\n confidence?: number | null;\n};\n\nexport function findAssistantWorkflowPlanningStep(\n workflow: AssistantWorkflowDefinition<string, string, string, string>,\n stepId: unknown,\n): AssistantWorkflowPlanningStepDefinition | null {\n const normalized = normalizeAssistantWorkflowId(stepId);\n if (!normalized) return null;\n return (workflow.planningSteps ?? []).find((step) => step.id === normalized) ?? null;\n}\n\nexport function buildAssistantWorkflowPlan(\n workflow: AssistantWorkflowDefinition<string, string, string, string>,\n intentId: unknown,\n availableToolNames: readonly string[] = [],\n context: AssistantWorkflowPlanContext = {},\n): AssistantWorkflowPlan {\n const intent = findAssistantWorkflowIntent(workflow, intentId);\n const stepsById = new Map((workflow.planningSteps ?? []).map((step) => [step.id, step] as const));\n const availableSet = new Set(availableToolNames);\n const steps: AssistantWorkflowPlanningStepDefinition[] = [];\n const missingPlanningSteps: string[] = [];\n const activePlanningStepProfileIds: string[] = [];\n const profileStepIds: string[] = [];\n const seen = new Set<string>();\n const baseStepIds = [...(intent?.planningSteps ?? [])];\n const conditionalStepIds = collectProfilePlanningStepIds(\n intent?.planningStepProfiles ?? [],\n context,\n activePlanningStepProfileIds,\n );\n const orderedStepIds = insertConditionalStepsBeforeSynthesis(baseStepIds, conditionalStepIds, stepsById);\n\n for (const rawStepId of orderedStepIds) {\n const stepId = normalizeAssistantWorkflowId(rawStepId);\n if (!stepId || seen.has(stepId)) continue;\n seen.add(stepId);\n const step = stepsById.get(stepId);\n if (step) {\n steps.push(step);\n if (!profileStepIds.includes(stepId) && activePlanningStepProfileIds.length > 0) {\n const fromProfile = (intent?.planningStepProfiles ?? [])\n .filter((profile) => activePlanningStepProfileIds.includes(profile.id))\n .some((profile) => profile.planningSteps.includes(stepId));\n if (fromProfile && !baseStepIds.includes(stepId)) {\n profileStepIds.push(stepId);\n }\n }\n } else {\n missingPlanningSteps.push(stepId);\n }\n }\n\n const rawToolHints = uniqueStrings(steps.flatMap((step) => step.toolHints ?? []));\n const rawRequiredToolHints = uniqueStrings(steps.flatMap((step) => step.requiredToolHints ?? []));\n const toolHints = filterToolNames(rawToolHints, availableSet);\n const requiredToolHints = filterToolNames(rawRequiredToolHints, availableSet);\n\n return {\n stepIds: steps.map((step) => step.id),\n steps: steps.map((step) => ({\n id: step.id,\n kind: step.kind,\n optional: step.optional === true,\n toolHints: filterToolNames(step.toolHints ?? [], availableSet),\n requiredToolHints: filterToolNames(step.requiredToolHints ?? [], availableSet),\n })),\n activePlanningStepProfileIds,\n profileStepIds,\n toolHints,\n requiredToolHints,\n missingToolHints: availableSet.size === 0 ? [] : rawToolHints.filter((tool) => !availableSet.has(tool)),\n missingRequiredToolHints:\n availableSet.size === 0 ? [] : rawRequiredToolHints.filter((tool) => !availableSet.has(tool)),\n missingPlanningSteps,\n executionHints: {\n needsClarification: steps.some((step) => step.kind === \"ask_clarification\"),\n needsSynthesis: steps.some((step) => step.kind === \"synthesize\"),\n producesArtifact: steps.some((step) => step.kind === \"build_artifact\" || step.kind === \"generate\"),\n mayGenerate: steps.some((step) => step.kind === \"generate\"),\n },\n };\n}\n\nfunction insertConditionalStepsBeforeSynthesis(\n baseStepIds: readonly string[],\n conditionalStepIds: readonly string[],\n stepsById: ReadonlyMap<string, AssistantWorkflowPlanningStepDefinition>,\n): string[] {\n if (!conditionalStepIds.length) return [...baseStepIds];\n const insertIndex = baseStepIds.findIndex((rawStepId) => {\n const stepId = normalizeAssistantWorkflowId(rawStepId);\n const kind = stepId ? stepsById.get(stepId)?.kind : null;\n return kind === \"build_artifact\" || kind === \"generate\" || kind === \"synthesize\";\n });\n if (insertIndex < 0) return [...baseStepIds, ...conditionalStepIds];\n return [\n ...baseStepIds.slice(0, insertIndex),\n ...conditionalStepIds,\n ...baseStepIds.slice(insertIndex),\n ];\n}\n\nfunction collectProfilePlanningStepIds(\n profiles: readonly AssistantWorkflowPlanningStepProfile[],\n context: AssistantWorkflowPlanContext,\n activeProfileIds: string[],\n): string[] {\n const out: string[] = [];\n for (const profile of profiles) {\n if (!matchesPlanningStepProfile(profile, context)) continue;\n activeProfileIds.push(profile.id);\n out.push(...profile.planningSteps);\n }\n return out;\n}\n\nfunction matchesPlanningStepProfile(\n profile: AssistantWorkflowPlanningStepProfile,\n context: AssistantWorkflowPlanContext,\n): boolean {\n const condition = profile.condition;\n if (!condition) return true;\n if (condition.subintent !== undefined && normalizeAssistantWorkflowId(context.subintent) !== condition.subintent) {\n return false;\n }\n if (condition.presentation !== undefined && normalizeAssistantWorkflowId(context.presentation) !== condition.presentation) {\n return false;\n }\n if (condition.timeWindowHint !== undefined && normalizeAssistantWorkflowId(context.timeWindowHint) !== condition.timeWindowHint) {\n return false;\n }\n if (condition.minConfidence !== undefined) {\n if (typeof context.confidence !== \"number\" || context.confidence < condition.minConfidence) return false;\n }\n if (condition.maxConfidence !== undefined) {\n if (typeof context.confidence !== \"number\" || context.confidence > condition.maxConfidence) return false;\n }\n const requiredTools = condition.requiredTools ?? [];\n if (requiredTools.length > 0) {\n const tools = new Set(uniqueStrings(context.toolsToExpose ?? []));\n if (!requiredTools.every((tool) => tools.has(tool))) return false;\n }\n return true;\n}\n\nfunction filterToolNames(rawTools: readonly string[], availableSet: ReadonlySet<string>): string[] {\n if (availableSet.size === 0) return uniqueStrings(rawTools);\n return uniqueStrings(rawTools).filter((tool) => availableSet.has(tool));\n}\n\nfunction uniqueStrings(values: readonly string[]): string[] {\n const out: string[] = [];\n const seen = new Set<string>();\n for (const value of values) {\n const normalized = normalizeAssistantWorkflowId(value);\n if (!normalized || seen.has(normalized)) continue;\n seen.add(normalized);\n out.push(normalized);\n }\n return out;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"planning.js","sourceRoot":"","sources":["../src/planning.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,GAK7B,MAAM,iBAAiB,CAAC;AAuCzB,MAAM,UAAU,iCAAiC,CAC/C,QAAqE,EACrE,MAAe;IAEf,MAAM,UAAU,GAAG,4BAA4B,CAAC,MAAM,CAAC,CAAC;IACxD,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC;IAC7B,OAAO,CAAC,QAAQ,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,UAAU,CAAC,IAAI,IAAI,CAAC;AACvF,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,QAAqE,EACrE,QAAiB,EACjB,qBAAwC,EAAE,EAC1C,UAAwC,EAAE;IAE1C,MAAM,MAAM,GAAG,2BAA2B,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC/D,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAU,CAAC,CAAC,CAAC;IAClG,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,kBAAkB,CAAC,CAAC;IACjD,MAAM,KAAK,GAA8C,EAAE,CAAC;IAC5D,MAAM,oBAAoB,GAAa,EAAE,CAAC;I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AAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AAC1E,CAAC;AAED,SAAS,aAAa,CAAC,MAAyB;IAC9C,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,UAAU,GAAG,4BAA4B,CAAC,KAAK,CAAC,CAAC;QACvD,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;YAAE,SAAS;QAClD,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACrB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import {\n findAssistantWorkflowIntent,\n normalizeAssistantWorkflowId,\n type AssistantWorkflowDefinition,\n type AssistantWorkflowPlanningStepProfile,\n type AssistantWorkflowPlanningStepDefinition,\n type AssistantWorkflowPlanningStepKind,\n} from \"./definition.js\";\n\nexport type AssistantWorkflowPlanStepTrace = {\n id: string;\n kind: AssistantWorkflowPlanningStepKind;\n optional: boolean;\n dependsOnStepIds: string[];\n toolHints: string[];\n requiredToolHints: string[];\n};\n\nexport type AssistantWorkflowPlanExecutionHints = {\n needsClarification: boolean;\n needsSynthesis: boolean;\n producesArtifact: boolean;\n mayGenerate: boolean;\n};\n\nexport type AssistantWorkflowPlan = {\n stepIds: string[];\n steps: AssistantWorkflowPlanStepTrace[];\n activePlanningStepProfileIds: string[];\n profileStepIds: string[];\n toolHints: string[];\n requiredToolHints: string[];\n missingToolHints: string[];\n missingRequiredToolHints: string[];\n missingPlanningSteps: string[];\n executionHints: AssistantWorkflowPlanExecutionHints;\n};\n\nexport type AssistantWorkflowPlanContext = {\n subintent?: string | null;\n presentation?: string | null;\n timeWindowHint?: string | null;\n toolsToExpose?: readonly string[] | null;\n confidence?: number | null;\n};\n\nexport function findAssistantWorkflowPlanningStep(\n workflow: AssistantWorkflowDefinition<string, string, string, string>,\n stepId: unknown,\n): AssistantWorkflowPlanningStepDefinition | null {\n const normalized = normalizeAssistantWorkflowId(stepId);\n if (!normalized) return null;\n return (workflow.planningSteps ?? []).find((step) => step.id === normalized) ?? null;\n}\n\nexport function buildAssistantWorkflowPlan(\n workflow: AssistantWorkflowDefinition<string, string, string, string>,\n intentId: unknown,\n availableToolNames: readonly string[] = [],\n context: AssistantWorkflowPlanContext = {},\n): AssistantWorkflowPlan {\n const intent = findAssistantWorkflowIntent(workflow, intentId);\n const stepsById = new Map((workflow.planningSteps ?? []).map((step) => [step.id, step] as const));\n const availableSet = new Set(availableToolNames);\n const steps: AssistantWorkflowPlanningStepDefinition[] = [];\n const missingPlanningSteps: string[] = [];\n const activePlanningStepProfileIds: string[] = [];\n const profileStepIds: string[] = [];\n const seen = new Set<string>();\n const baseStepIds = [...(intent?.planningSteps ?? [])];\n const conditionalStepIds = collectProfilePlanningStepIds(\n intent?.planningStepProfiles ?? [],\n context,\n activePlanningStepProfileIds,\n );\n const orderedStepIds = insertConditionalStepsBeforeSynthesis(baseStepIds, conditionalStepIds, stepsById);\n\n for (const rawStepId of orderedStepIds) {\n const stepId = normalizeAssistantWorkflowId(rawStepId);\n if (!stepId || seen.has(stepId)) continue;\n seen.add(stepId);\n const step = stepsById.get(stepId);\n if (step) {\n steps.push(step);\n if (!profileStepIds.includes(stepId) && activePlanningStepProfileIds.length > 0) {\n const fromProfile = (intent?.planningStepProfiles ?? [])\n .filter((profile) => activePlanningStepProfileIds.includes(profile.id))\n .some((profile) => profile.planningSteps.includes(stepId));\n if (fromProfile && !baseStepIds.includes(stepId)) {\n profileStepIds.push(stepId);\n }\n }\n } else {\n missingPlanningSteps.push(stepId);\n }\n }\n\n const rawToolHints = uniqueStrings(steps.flatMap((step) => step.toolHints ?? []));\n const rawRequiredToolHints = uniqueStrings(steps.flatMap((step) => step.requiredToolHints ?? []));\n const toolHints = filterToolNames(rawToolHints, availableSet);\n const requiredToolHints = filterToolNames(rawRequiredToolHints, availableSet);\n\n return {\n stepIds: steps.map((step) => step.id),\n steps: steps.map((step) => ({\n id: step.id,\n kind: step.kind,\n optional: step.optional === true,\n dependsOnStepIds: uniqueStrings(step.dependsOn ?? []),\n toolHints: filterToolNames(step.toolHints ?? [], availableSet),\n requiredToolHints: filterToolNames(step.requiredToolHints ?? [], availableSet),\n })),\n activePlanningStepProfileIds,\n profileStepIds,\n toolHints,\n requiredToolHints,\n missingToolHints: availableSet.size === 0 ? [] : rawToolHints.filter((tool) => !availableSet.has(tool)),\n missingRequiredToolHints:\n availableSet.size === 0 ? [] : rawRequiredToolHints.filter((tool) => !availableSet.has(tool)),\n missingPlanningSteps,\n executionHints: {\n needsClarification: steps.some((step) => step.kind === \"ask_clarification\"),\n needsSynthesis: steps.some((step) => step.kind === \"synthesize\"),\n producesArtifact: steps.some((step) => step.kind === \"build_artifact\" || step.kind === \"generate\"),\n mayGenerate: steps.some((step) => step.kind === \"generate\"),\n },\n };\n}\n\nfunction insertConditionalStepsBeforeSynthesis(\n baseStepIds: readonly string[],\n conditionalStepIds: readonly string[],\n stepsById: ReadonlyMap<string, AssistantWorkflowPlanningStepDefinition>,\n): string[] {\n if (!conditionalStepIds.length) return [...baseStepIds];\n const insertIndex = baseStepIds.findIndex((rawStepId) => {\n const stepId = normalizeAssistantWorkflowId(rawStepId);\n const kind = stepId ? stepsById.get(stepId)?.kind : null;\n return kind === \"build_artifact\" || kind === \"generate\" || kind === \"synthesize\";\n });\n if (insertIndex < 0) return [...baseStepIds, ...conditionalStepIds];\n return [\n ...baseStepIds.slice(0, insertIndex),\n ...conditionalStepIds,\n ...baseStepIds.slice(insertIndex),\n ];\n}\n\nfunction collectProfilePlanningStepIds(\n profiles: readonly AssistantWorkflowPlanningStepProfile[],\n context: AssistantWorkflowPlanContext,\n activeProfileIds: string[],\n): string[] {\n const out: string[] = [];\n for (const profile of profiles) {\n if (!matchesPlanningStepProfile(profile, context)) continue;\n activeProfileIds.push(profile.id);\n out.push(...profile.planningSteps);\n }\n return out;\n}\n\nfunction matchesPlanningStepProfile(\n profile: AssistantWorkflowPlanningStepProfile,\n context: AssistantWorkflowPlanContext,\n): boolean {\n const condition = profile.condition;\n if (!condition) return true;\n if (condition.subintent !== undefined && normalizeAssistantWorkflowId(context.subintent) !== condition.subintent) {\n return false;\n }\n if (condition.presentation !== undefined && normalizeAssistantWorkflowId(context.presentation) !== condition.presentation) {\n return false;\n }\n if (condition.timeWindowHint !== undefined && normalizeAssistantWorkflowId(context.timeWindowHint) !== condition.timeWindowHint) {\n return false;\n }\n if (condition.minConfidence !== undefined) {\n if (typeof context.confidence !== \"number\" || context.confidence < condition.minConfidence) return false;\n }\n if (condition.maxConfidence !== undefined) {\n if (typeof context.confidence !== \"number\" || context.confidence > condition.maxConfidence) return false;\n }\n const requiredTools = condition.requiredTools ?? [];\n if (requiredTools.length > 0) {\n const tools = new Set(uniqueStrings(context.toolsToExpose ?? []));\n if (!requiredTools.every((tool) => tools.has(tool))) return false;\n }\n return true;\n}\n\nfunction filterToolNames(rawTools: readonly string[], availableSet: ReadonlySet<string>): string[] {\n if (availableSet.size === 0) return uniqueStrings(rawTools);\n return uniqueStrings(rawTools).filter((tool) => availableSet.has(tool));\n}\n\nfunction uniqueStrings(values: readonly string[]): string[] {\n const out: string[] = [];\n const seen = new Set<string>();\n for (const value of values) {\n const normalized = normalizeAssistantWorkflowId(value);\n if (!normalized || seen.has(normalized)) continue;\n seen.add(normalized);\n out.push(normalized);\n }\n return out;\n}\n"]}
|
package/dist/tool-executor.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { AssistantWorkflowToolBindingDefinition, AssistantWorkflowToolCapabilityDefinition, AssistantWorkflowToolProvider } from "./definition.js";
|
|
2
2
|
import type { AssistantWorkflowToolInvocation, AssistantWorkflowToolInvocationQueue } from "./tool-invocations.js";
|
|
3
|
+
import { type AssistantWorkflowExecutionBudget, type AssistantWorkflowExecutionBudgetAssessment } from "./execution-budget.js";
|
|
3
4
|
export type { AssistantWorkflowToolInvocation, AssistantWorkflowToolInvocationQueue, } from "./tool-invocations.js";
|
|
4
5
|
import { type AssistantWorkflowToolResult, type AssistantWorkflowToolResultSummary } from "./tool-results.js";
|
|
5
6
|
export type AssistantWorkflowToolExecutorContext = {
|
|
6
7
|
invocationIndex: number;
|
|
7
8
|
queueStatus: AssistantWorkflowToolInvocationQueue["status"];
|
|
8
9
|
args: AssistantWorkflowToolInvocationArgs;
|
|
10
|
+
attempt?: number;
|
|
11
|
+
maxAttempts?: number;
|
|
9
12
|
};
|
|
10
13
|
export type AssistantWorkflowToolInvocationArgs = Readonly<Record<string, unknown>>;
|
|
11
14
|
export type AssistantWorkflowToolInvocationArgsById = Readonly<Record<string, AssistantWorkflowToolInvocationArgs>>;
|
|
@@ -38,6 +41,8 @@ export type AssistantWorkflowToolExecutionEvent = {
|
|
|
38
41
|
durationMs: number | null;
|
|
39
42
|
errorMessage: string | null;
|
|
40
43
|
retryable: boolean | null;
|
|
44
|
+
attempt?: number;
|
|
45
|
+
maxAttempts?: number;
|
|
41
46
|
};
|
|
42
47
|
export type AssistantWorkflowToolExecutionOptions = {
|
|
43
48
|
continueOnError?: boolean;
|
|
@@ -45,11 +50,13 @@ export type AssistantWorkflowToolExecutionOptions = {
|
|
|
45
50
|
now?: () => number;
|
|
46
51
|
argsByInvocationId?: AssistantWorkflowToolInvocationArgsById;
|
|
47
52
|
onEvent?: (event: AssistantWorkflowToolExecutionEvent) => void;
|
|
53
|
+
executionBudget?: AssistantWorkflowExecutionBudget;
|
|
48
54
|
};
|
|
49
55
|
export type AssistantWorkflowToolExecutionReport = {
|
|
50
56
|
queue: AssistantWorkflowToolInvocationQueue;
|
|
51
57
|
results: AssistantWorkflowToolResult[];
|
|
52
58
|
summary: AssistantWorkflowToolResultSummary;
|
|
59
|
+
budgetAssessment?: AssistantWorkflowExecutionBudgetAssessment | null;
|
|
53
60
|
};
|
|
54
61
|
/**
|
|
55
62
|
* Adapts provider-specific integrations to the generic invocation executor.
|