@openapi-flow/langchain 0.0.0-stage → 0.3.0
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 +152 -2
- package/THIRD_PARTY_NOTICES.md +3 -0
- package/dist/arguments/analyze-api-input-answers.d.ts +3 -0
- package/dist/arguments/analyze-api-input-answers.js +87 -0
- package/dist/arguments/analyze-api-request-media-type.d.ts +4 -0
- package/dist/arguments/analyze-api-request-media-type.js +50 -0
- package/dist/arguments/extract-api-input-answers.d.ts +3 -0
- package/dist/arguments/extract-api-input-answers.js +4 -0
- package/dist/arguments/generate-api-arguments.d.ts +3 -0
- package/dist/arguments/generate-api-arguments.js +60 -0
- package/dist/arguments/select-api-request-media-type.d.ts +2 -0
- package/dist/arguments/select-api-request-media-type.js +10 -0
- package/dist/bindings/plan-api-bindings.d.ts +3 -0
- package/dist/bindings/plan-api-bindings.js +50 -0
- package/dist/draft/analyze-workflow-draft-edit.d.ts +4 -0
- package/dist/draft/analyze-workflow-draft-edit.js +84 -0
- package/dist/draft/generate-workflow-draft-api-call-arguments.d.ts +3 -0
- package/dist/draft/generate-workflow-draft-api-call-arguments.js +88 -0
- package/dist/draft/generate-workflow-draft-api-input-edits.d.ts +4 -0
- package/dist/draft/generate-workflow-draft-api-input-edits.js +58 -0
- package/dist/draft/generate-workflow-draft-native-node-addition.d.ts +4 -0
- package/dist/draft/generate-workflow-draft-native-node-addition.js +137 -0
- package/dist/draft/generate-workflow-draft-native-parameter-edits.d.ts +3 -0
- package/dist/draft/generate-workflow-draft-native-parameter-edits.js +71 -0
- package/dist/draft/plan-workflow-draft-api-binding-edit.d.ts +4 -0
- package/dist/draft/plan-workflow-draft-api-binding-edit.js +103 -0
- package/dist/draft/plan-workflow-draft-api-call-bindings.d.ts +3 -0
- package/dist/draft/plan-workflow-draft-api-call-bindings.js +114 -0
- package/dist/draft/plan-workflow-draft-clarification-scopes.d.ts +4 -0
- package/dist/draft/plan-workflow-draft-clarification-scopes.js +77 -0
- package/dist/draft/plan-workflow-draft-connection-edit.d.ts +4 -0
- package/dist/draft/plan-workflow-draft-connection-edit.js +79 -0
- package/dist/draft/plan-workflow-draft-native-dependencies.d.ts +4 -0
- package/dist/draft/plan-workflow-draft-native-dependencies.js +45 -0
- package/dist/draft/plan-workflow-draft-native-reference-repair.d.ts +4 -0
- package/dist/draft/plan-workflow-draft-native-reference-repair.js +68 -0
- package/dist/draft/resolve-workflow-draft-edit-proposal.d.ts +3 -0
- package/dist/draft/resolve-workflow-draft-edit-proposal.js +39 -0
- package/dist/draft/select-workflow-draft-api-binding-inputs.d.ts +4 -0
- package/dist/draft/select-workflow-draft-api-binding-inputs.js +83 -0
- package/dist/draft/select-workflow-draft-api-input-edit-targets.d.ts +4 -0
- package/dist/draft/select-workflow-draft-api-input-edit-targets.js +55 -0
- package/dist/draft/select-workflow-draft-native-node-parameter-ownership.d.ts +4 -0
- package/dist/draft/select-workflow-draft-native-node-parameter-ownership.js +81 -0
- package/dist/draft/select-workflow-draft-native-parameter-edit-targets.d.ts +3 -0
- package/dist/draft/select-workflow-draft-native-parameter-edit-targets.js +51 -0
- package/dist/draft/workflow-draft-api-binding-edit-planning-error.d.ts +5 -0
- package/dist/draft/workflow-draft-api-binding-edit-planning-error.js +10 -0
- package/dist/draft/workflow-draft-api-call-planning-error.d.ts +5 -0
- package/dist/draft/workflow-draft-api-call-planning-error.js +10 -0
- package/dist/draft/workflow-draft-api-input-edit-planning-error.d.ts +5 -0
- package/dist/draft/workflow-draft-api-input-edit-planning-error.js +10 -0
- package/dist/draft/workflow-draft-clarification-scope-planning-error.d.ts +5 -0
- package/dist/draft/workflow-draft-clarification-scope-planning-error.js +8 -0
- package/dist/draft/workflow-draft-connection-edit-planning-error.d.ts +5 -0
- package/dist/draft/workflow-draft-connection-edit-planning-error.js +10 -0
- package/dist/draft/workflow-draft-edit-planning-error.d.ts +5 -0
- package/dist/draft/workflow-draft-edit-planning-error.js +8 -0
- package/dist/draft/workflow-draft-native-node-addition-planning-error.d.ts +5 -0
- package/dist/draft/workflow-draft-native-node-addition-planning-error.js +10 -0
- package/dist/draft/workflow-draft-native-parameter-edit-planning-error.d.ts +5 -0
- package/dist/draft/workflow-draft-native-parameter-edit-planning-error.js +8 -0
- package/dist/draft/workflow-draft-native-reference-repair-planning-error.d.ts +5 -0
- package/dist/draft/workflow-draft-native-reference-repair-planning-error.js +8 -0
- package/dist/legacy/planning/operation-plan-inputs.d.ts +3 -0
- package/dist/legacy/planning/operation-plan-inputs.js +17 -0
- package/dist/legacy/planning/parse-structured-output.d.ts +2 -0
- package/dist/legacy/planning/parse-structured-output.js +9 -0
- package/dist/legacy/planning/propose-catalog-scenario.d.ts +3 -0
- package/dist/legacy/planning/propose-catalog-scenario.js +136 -0
- package/dist/legacy/planning/select-operation.d.ts +4 -0
- package/dist/legacy/planning/select-operation.js +43 -0
- package/dist/legacy/schemas/catalog-selection-schema.d.ts +19 -0
- package/dist/legacy/schemas/catalog-selection-schema.js +39 -0
- package/dist/legacy/schemas/catalog-step-schema.d.ts +16 -0
- package/dist/legacy/schemas/catalog-step-schema.js +39 -0
- package/dist/legacy/schemas/operation-selection-schema.d.ts +6 -0
- package/dist/legacy/schemas/operation-selection-schema.js +14 -0
- package/dist/legacy-api.d.ts +9 -0
- package/dist/legacy-api.js +7 -0
- package/dist/prompts/api-arguments-prompt.d.ts +1 -0
- package/dist/prompts/api-arguments-prompt.js +1 -0
- package/dist/prompts/api-bindings-prompt.d.ts +1 -0
- package/dist/prompts/api-bindings-prompt.js +13 -0
- package/dist/prompts/api-input-answers-prompt.d.ts +1 -0
- package/dist/prompts/api-input-answers-prompt.js +7 -0
- package/dist/prompts/api-request-media-type-prompt.d.ts +1 -0
- package/dist/prompts/api-request-media-type-prompt.js +1 -0
- package/dist/prompts/api-selection-analysis-prompt.d.ts +1 -0
- package/dist/prompts/api-selection-analysis-prompt.js +5 -0
- package/dist/prompts/api-selection-explanation-prompt.d.ts +1 -0
- package/dist/prompts/api-selection-explanation-prompt.js +1 -0
- package/dist/prompts/native-instance-dependencies-prompt.d.ts +1 -0
- package/dist/prompts/native-instance-dependencies-prompt.js +8 -0
- package/dist/prompts/native-node-planning-prompt.d.ts +3 -0
- package/dist/prompts/native-node-planning-prompt.js +22 -0
- package/dist/prompts/operation-selection-prompt.d.ts +1 -0
- package/dist/prompts/operation-selection-prompt.js +1 -0
- package/dist/prompts/reviewable-workflow-graph-prompt.d.ts +1 -0
- package/dist/prompts/reviewable-workflow-graph-prompt.js +7 -0
- package/dist/prompts/workflow-connections-prompt.d.ts +1 -0
- package/dist/prompts/workflow-connections-prompt.js +11 -0
- package/dist/prompts/workflow-draft-api-binding-edit-prompt.d.ts +1 -0
- package/dist/prompts/workflow-draft-api-binding-edit-prompt.js +9 -0
- package/dist/prompts/workflow-draft-api-call-planning-prompt.d.ts +3 -0
- package/dist/prompts/workflow-draft-api-call-planning-prompt.js +39 -0
- package/dist/prompts/workflow-draft-api-input-edit-prompt.d.ts +2 -0
- package/dist/prompts/workflow-draft-api-input-edit-prompt.js +14 -0
- package/dist/prompts/workflow-draft-clarification-scope-prompt.d.ts +1 -0
- package/dist/prompts/workflow-draft-clarification-scope-prompt.js +10 -0
- package/dist/prompts/workflow-draft-connection-edit-prompt.d.ts +1 -0
- package/dist/prompts/workflow-draft-connection-edit-prompt.js +7 -0
- package/dist/prompts/workflow-draft-edit-prompt.d.ts +1 -0
- package/dist/prompts/workflow-draft-edit-prompt.js +15 -0
- package/dist/prompts/workflow-draft-native-dependencies-prompt.d.ts +1 -0
- package/dist/prompts/workflow-draft-native-dependencies-prompt.js +5 -0
- package/dist/prompts/workflow-draft-native-node-addition-prompt.d.ts +2 -0
- package/dist/prompts/workflow-draft-native-node-addition-prompt.js +6 -0
- package/dist/prompts/workflow-draft-native-parameter-edit-prompt.d.ts +2 -0
- package/dist/prompts/workflow-draft-native-parameter-edit-prompt.js +2 -0
- package/dist/prompts/workflow-draft-native-reference-repair-prompt.d.ts +1 -0
- package/dist/prompts/workflow-draft-native-reference-repair-prompt.js +7 -0
- package/dist/prompts/workflow-graph-prompt.d.ts +1 -0
- package/dist/prompts/workflow-graph-prompt.js +15 -0
- package/dist/prompts/workflow-requirements-prompt.d.ts +1 -0
- package/dist/prompts/workflow-requirements-prompt.js +14 -0
- package/dist/prompts/workflow-review-suggestions-prompt.d.ts +1 -0
- package/dist/prompts/workflow-review-suggestions-prompt.js +4 -0
- package/dist/prompts/workflow-user-action-evidence-prompt.d.ts +1 -0
- package/dist/prompts/workflow-user-action-evidence-prompt.js +1 -0
- package/dist/public-api.d.ts +67 -0
- package/dist/public-api.js +46 -0
- package/dist/requirements/clarify-workflow-requirements.d.ts +4 -0
- package/dist/requirements/clarify-workflow-requirements.js +53 -0
- package/dist/requirements/resolve-workflow-requirements-evidence.d.ts +4 -0
- package/dist/requirements/resolve-workflow-requirements-evidence.js +58 -0
- package/dist/review/suggest-workflow-review-follow-ups.d.ts +4 -0
- package/dist/review/suggest-workflow-review-follow-ups.js +87 -0
- package/dist/review/workflow-review-suggestion-planning-error.d.ts +5 -0
- package/dist/review/workflow-review-suggestion-planning-error.js +8 -0
- package/dist/schemas/api-binding-plan-schema.d.ts +8 -0
- package/dist/schemas/api-binding-plan-schema.js +59 -0
- package/dist/schemas/api-input-answer-source-schema.d.ts +16 -0
- package/dist/schemas/api-input-answer-source-schema.js +28 -0
- package/dist/schemas/api-literal-generation-output-schema.d.ts +11 -0
- package/dist/schemas/api-literal-generation-output-schema.js +20 -0
- package/dist/schemas/api-request-media-type-schema.d.ts +6 -0
- package/dist/schemas/api-request-media-type-schema.js +23 -0
- package/dist/schemas/api-selection-analysis-schema.d.ts +41 -0
- package/dist/schemas/api-selection-analysis-schema.js +23 -0
- package/dist/schemas/api-selection-options-schema.d.ts +4 -0
- package/dist/schemas/api-selection-options-schema.js +4 -0
- package/dist/schemas/api-selection-schema.d.ts +25 -0
- package/dist/schemas/api-selection-schema.js +31 -0
- package/dist/schemas/create-workflow-message-evidence-selection-schema.d.ts +16 -0
- package/dist/schemas/create-workflow-message-evidence-selection-schema.js +22 -0
- package/dist/schemas/native-node-explanation-schema.d.ts +5 -0
- package/dist/schemas/native-node-explanation-schema.js +9 -0
- package/dist/schemas/native-node-parameter-contract.d.ts +3 -0
- package/dist/schemas/native-node-parameter-contract.js +30 -0
- package/dist/schemas/native-node-planning-contract.d.ts +3 -0
- package/dist/schemas/native-node-planning-contract.js +44 -0
- package/dist/schemas/request-media-selection-options-schema.d.ts +4 -0
- package/dist/schemas/request-media-selection-options-schema.js +4 -0
- package/dist/schemas/reviewable-workflow-graph-schema.d.ts +6 -0
- package/dist/schemas/reviewable-workflow-graph-schema.js +75 -0
- package/dist/schemas/serialize-structured-output-schema.d.ts +5 -0
- package/dist/schemas/serialize-structured-output-schema.js +10 -0
- package/dist/schemas/serialize-workflow-requirements-schema.d.ts +4 -0
- package/dist/schemas/serialize-workflow-requirements-schema.js +5 -0
- package/dist/schemas/with-api-selection-explanation.d.ts +10 -0
- package/dist/schemas/with-api-selection-explanation.js +15 -0
- package/dist/schemas/workflow-connection-explanation-schema.d.ts +5 -0
- package/dist/schemas/workflow-connection-explanation-schema.js +9 -0
- package/dist/schemas/workflow-draft-edit-schema.d.ts +3 -0
- package/dist/schemas/workflow-draft-edit-schema.js +17 -0
- package/dist/schemas/workflow-graph-explanation-schema.d.ts +5 -0
- package/dist/schemas/workflow-graph-explanation-schema.js +9 -0
- package/dist/schemas/workflow-graph-proposal-schema.d.ts +4 -0
- package/dist/schemas/workflow-graph-proposal-schema.js +45 -0
- package/dist/schemas/workflow-planning-evidence-schemas.d.ts +20 -0
- package/dist/schemas/workflow-planning-evidence-schemas.js +44 -0
- package/dist/schemas/workflow-requirements-schema.d.ts +3 -0
- package/dist/schemas/workflow-requirements-schema.js +6 -0
- package/dist/schemas/workflow-review-suggestions-schema.d.ts +4 -0
- package/dist/schemas/workflow-review-suggestions-schema.js +18 -0
- package/dist/selection/analyze-api-selection.d.ts +4 -0
- package/dist/selection/analyze-api-selection.js +117 -0
- package/dist/selection/resolve-api-selection-options.d.ts +3 -0
- package/dist/selection/resolve-api-selection-options.js +6 -0
- package/dist/selection/select-api-operations.d.ts +3 -0
- package/dist/selection/select-api-operations.js +84 -0
- package/dist/types/api-input-answers.d.ts +16 -0
- package/dist/types/api-input-answers.js +1 -0
- package/dist/types/api-selection-analysis.d.ts +3 -0
- package/dist/types/api-selection-analysis.js +1 -0
- package/dist/types/argument-generation.d.ts +13 -0
- package/dist/types/argument-generation.js +1 -0
- package/dist/types/binding-planning.d.ts +10 -0
- package/dist/types/binding-planning.js +1 -0
- package/dist/types/legacy/catalog-planning.d.ts +16 -0
- package/dist/types/legacy/catalog-planning.js +1 -0
- package/dist/types/legacy/planning.d.ts +5 -0
- package/dist/types/legacy/planning.js +1 -0
- package/dist/types/native-node-planning.d.ts +76 -0
- package/dist/types/native-node-planning.js +1 -0
- package/dist/types/operation-selection.d.ts +14 -0
- package/dist/types/operation-selection.js +1 -0
- package/dist/types/request-media-selection.d.ts +15 -0
- package/dist/types/request-media-selection.js +1 -0
- package/dist/types/reviewable-workflow-planning.d.ts +28 -0
- package/dist/types/reviewable-workflow-planning.js +1 -0
- package/dist/types/structured-output-schema.d.ts +3 -0
- package/dist/types/structured-output-schema.js +1 -0
- package/dist/types/workflow-clarification.d.ts +23 -0
- package/dist/types/workflow-clarification.js +1 -0
- package/dist/types/workflow-draft-api-binding-edit.d.ts +9 -0
- package/dist/types/workflow-draft-api-binding-edit.js +1 -0
- package/dist/types/workflow-draft-api-call-planning.d.ts +15 -0
- package/dist/types/workflow-draft-api-call-planning.js +1 -0
- package/dist/types/workflow-draft-api-input-edit.d.ts +13 -0
- package/dist/types/workflow-draft-api-input-edit.js +1 -0
- package/dist/types/workflow-draft-clarification.d.ts +9 -0
- package/dist/types/workflow-draft-clarification.js +1 -0
- package/dist/types/workflow-draft-connection-edit.d.ts +9 -0
- package/dist/types/workflow-draft-connection-edit.js +1 -0
- package/dist/types/workflow-draft-edit.d.ts +16 -0
- package/dist/types/workflow-draft-edit.js +1 -0
- package/dist/types/workflow-draft-native-node-addition.d.ts +18 -0
- package/dist/types/workflow-draft-native-node-addition.js +1 -0
- package/dist/types/workflow-draft-native-parameter-edit.d.ts +13 -0
- package/dist/types/workflow-draft-native-parameter-edit.js +1 -0
- package/dist/types/workflow-draft-native-reference-repair.d.ts +9 -0
- package/dist/types/workflow-draft-native-reference-repair.js +1 -0
- package/dist/types/workflow-message-evidence-selection.d.ts +6 -0
- package/dist/types/workflow-message-evidence-selection.js +1 -0
- package/dist/types/workflow-orchestration.d.ts +21 -0
- package/dist/types/workflow-orchestration.js +1 -0
- package/dist/types/workflow-planning.d.ts +35 -0
- package/dist/types/workflow-planning.js +1 -0
- package/dist/types/workflow-review-suggestions.d.ts +12 -0
- package/dist/types/workflow-review-suggestions.js +1 -0
- package/dist/workflow/complete-reviewable-workflow-graph-proposal.d.ts +4 -0
- package/dist/workflow/complete-reviewable-workflow-graph-proposal.js +13 -0
- package/dist/workflow/generate-native-node-parameters.d.ts +4 -0
- package/dist/workflow/generate-native-node-parameters.js +87 -0
- package/dist/workflow/native-node-planning-error.d.ts +5 -0
- package/dist/workflow/native-node-planning-error.js +10 -0
- package/dist/workflow/orchestrate-workflow.d.ts +4 -0
- package/dist/workflow/orchestrate-workflow.js +31 -0
- package/dist/workflow/plan-native-instance-dependencies.d.ts +4 -0
- package/dist/workflow/plan-native-instance-dependencies.js +45 -0
- package/dist/workflow/plan-native-nodes.d.ts +2 -0
- package/dist/workflow/plan-native-nodes.js +96 -0
- package/dist/workflow/plan-reviewable-workflow-graph.d.ts +3 -0
- package/dist/workflow/plan-reviewable-workflow-graph.js +70 -0
- package/dist/workflow/plan-workflow-connections.d.ts +3 -0
- package/dist/workflow/plan-workflow-connections.js +67 -0
- package/dist/workflow/plan-workflow-graph.d.ts +3 -0
- package/dist/workflow/plan-workflow-graph.js +80 -0
- package/dist/workflow/resolve-native-node-parameter-source.d.ts +4 -0
- package/dist/workflow/resolve-native-node-parameter-source.js +7 -0
- package/dist/workflow/resolve-native-node-planning-output.d.ts +3 -0
- package/dist/workflow/resolve-native-node-planning-output.js +33 -0
- package/dist/workflow/resolve-workflow-connection-output.d.ts +3 -0
- package/dist/workflow/resolve-workflow-connection-output.js +22 -0
- package/dist/workflow/resolve-workflow-graph-output.d.ts +5 -0
- package/dist/workflow/resolve-workflow-graph-output.js +69 -0
- package/dist/workflow/reviewable-workflow-graph-planning-error.d.ts +5 -0
- package/dist/workflow/reviewable-workflow-graph-planning-error.js +8 -0
- package/dist/workflow/select-native-node-instances.d.ts +4 -0
- package/dist/workflow/select-native-node-instances.js +57 -0
- package/dist/workflow/workflow-graph-planning-error.d.ts +5 -0
- package/dist/workflow/workflow-graph-planning-error.js +10 -0
- package/package.json +47 -4
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { HumanMessage, SystemMessage } from '@langchain/core/messages';
|
|
2
|
+
import { describeWorkflowDraftClarificationScopes, createWorkflowDraftClarificationScopeSchema, resolveWorkflowDraftClarificationScopes, } from '@openapi-flow/core';
|
|
3
|
+
import { workflowDraftClarificationScopePrompt } from '../prompts/workflow-draft-clarification-scope-prompt.js';
|
|
4
|
+
import { serializeStructuredOutputSchema } from '../schemas/serialize-structured-output-schema.js';
|
|
5
|
+
import { parseStructuredOutput } from '../legacy/planning/parse-structured-output.js';
|
|
6
|
+
import { WorkflowDraftClarificationScopePlanningError } from './workflow-draft-clarification-scope-planning-error.js';
|
|
7
|
+
import { createWorkflowMessageEvidenceSelectionSchema } from '../schemas/create-workflow-message-evidence-selection-schema.js';
|
|
8
|
+
/** One semantic scope choice. No calls when there are no requirements or only the workflow scope exists. */
|
|
9
|
+
export async function planWorkflowDraftClarificationScopes(input) {
|
|
10
|
+
const description = describeWorkflowDraftClarificationScopes(input);
|
|
11
|
+
if (!description.requirements.length ||
|
|
12
|
+
(!description.nodes.length &&
|
|
13
|
+
description.requirements.every((requirement) => requirement.origin?.kind !== 'clarification-question')))
|
|
14
|
+
return resolveWorkflowDraftClarificationScopes({
|
|
15
|
+
...input,
|
|
16
|
+
fingerprint: description.fingerprint,
|
|
17
|
+
proposal: {
|
|
18
|
+
scopes: Object.fromEntries(description.requirements.map((requirement) => [
|
|
19
|
+
requirement.id,
|
|
20
|
+
{
|
|
21
|
+
scope: { kind: 'workflow' },
|
|
22
|
+
...(description.includeExplanations
|
|
23
|
+
? {
|
|
24
|
+
explanation: {
|
|
25
|
+
reason: 'No workflow nodes are selected; workflow is the only available scope.',
|
|
26
|
+
evidence: description.messages.map((message) => ({
|
|
27
|
+
kind: 'message',
|
|
28
|
+
messageId: message.id,
|
|
29
|
+
quote: message.text,
|
|
30
|
+
})),
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
: {}),
|
|
34
|
+
},
|
|
35
|
+
])),
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
if (!input.model || typeof input.model.withStructuredOutput !== 'function')
|
|
39
|
+
throw new Error('planWorkflowDraftClarificationScopes.model must support structured output when multiple scopes exist');
|
|
40
|
+
const schema = createWorkflowDraftClarificationScopeSchema(input, createWorkflowMessageEvidenceSelectionSchema(description.messages));
|
|
41
|
+
const output = await input.model
|
|
42
|
+
.withStructuredOutput(serializeStructuredOutputSchema(schema, 'draft-2020-12', 'input'), {
|
|
43
|
+
name: 'scope_workflow_draft_clarification',
|
|
44
|
+
method: 'jsonSchema',
|
|
45
|
+
strict: true,
|
|
46
|
+
})
|
|
47
|
+
.invoke([
|
|
48
|
+
new SystemMessage(workflowDraftClarificationScopePrompt),
|
|
49
|
+
new HumanMessage(JSON.stringify({
|
|
50
|
+
requirements: description.requirements,
|
|
51
|
+
nodes: description.nodes,
|
|
52
|
+
messages: description.messages,
|
|
53
|
+
includeExplanations: description.includeExplanations,
|
|
54
|
+
})),
|
|
55
|
+
]);
|
|
56
|
+
let proposal;
|
|
57
|
+
try {
|
|
58
|
+
proposal = parseStructuredOutput(schema, output, 'workflow draft clarification scopes');
|
|
59
|
+
}
|
|
60
|
+
catch (cause) {
|
|
61
|
+
if (!(cause instanceof Error))
|
|
62
|
+
throw cause;
|
|
63
|
+
throw new WorkflowDraftClarificationScopePlanningError({ stage: 'scope-schema', output }, cause);
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
return resolveWorkflowDraftClarificationScopes({
|
|
67
|
+
...input,
|
|
68
|
+
fingerprint: description.fingerprint,
|
|
69
|
+
proposal,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
catch (cause) {
|
|
73
|
+
if (!(cause instanceof Error))
|
|
74
|
+
throw cause;
|
|
75
|
+
throw new WorkflowDraftClarificationScopePlanningError({ stage: 'scope-resolution', output }, cause);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WorkflowDraftConnectionEditResult } from '@openapi-flow/core';
|
|
2
|
+
import type { PlanWorkflowDraftConnectionEditInput } from '../types/workflow-draft-connection-edit.js';
|
|
3
|
+
/** One final topology delta call, after actual material/consumer decisions have resolved. */
|
|
4
|
+
export declare function planWorkflowDraftConnectionEdit(input: PlanWorkflowDraftConnectionEditInput): Promise<WorkflowDraftConnectionEditResult>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { HumanMessage, SystemMessage } from '@langchain/core/messages';
|
|
2
|
+
import { describeWorkflowDraftClarification, describeWorkflowDraftClarificationOwnership, describeWorkflowDraftConnectionEdit, createWorkflowDraftConnectionEditProposalSchema, resolveWorkflowDraftConnectionEdit, } from '@openapi-flow/core';
|
|
3
|
+
import { workflowDraftConnectionEditPrompt } from '../prompts/workflow-draft-connection-edit-prompt.js';
|
|
4
|
+
import { serializeStructuredOutputSchema } from '../schemas/serialize-structured-output-schema.js';
|
|
5
|
+
import { parseStructuredOutput } from '../legacy/planning/parse-structured-output.js';
|
|
6
|
+
import { WorkflowDraftConnectionEditPlanningError } from './workflow-draft-connection-edit-planning-error.js';
|
|
7
|
+
import { createWorkflowMessageEvidenceSelectionSchema } from '../schemas/create-workflow-message-evidence-selection-schema.js';
|
|
8
|
+
/** One final topology delta call, after actual material/consumer decisions have resolved. */
|
|
9
|
+
export async function planWorkflowDraftConnectionEdit(input) {
|
|
10
|
+
const context = describeWorkflowDraftConnectionEdit(input);
|
|
11
|
+
if (context.status !== 'ready')
|
|
12
|
+
return { status: context.status, description: context };
|
|
13
|
+
if (!input.model || typeof input.model.withStructuredOutput !== 'function')
|
|
14
|
+
throw new Error('planWorkflowDraftConnectionEdit.model must support structured output');
|
|
15
|
+
const schema = createWorkflowDraftConnectionEditProposalSchema(context, createWorkflowMessageEvidenceSelectionSchema(context.messages));
|
|
16
|
+
const output = await input.model
|
|
17
|
+
.withStructuredOutput(serializeStructuredOutputSchema(schema, 'draft-7', 'input'), {
|
|
18
|
+
name: 'plan_draft_connection_edit',
|
|
19
|
+
method: 'jsonSchema',
|
|
20
|
+
strict: true,
|
|
21
|
+
})
|
|
22
|
+
.invoke([
|
|
23
|
+
new SystemMessage(workflowDraftConnectionEditPrompt),
|
|
24
|
+
new HumanMessage(JSON.stringify({
|
|
25
|
+
clarification: describeWorkflowDraftClarification(input.context),
|
|
26
|
+
planningClarifications: describeWorkflowDraftClarificationOwnership({
|
|
27
|
+
...input,
|
|
28
|
+
stage: 'connections',
|
|
29
|
+
}),
|
|
30
|
+
instructions: context.steps.map((step) => ({
|
|
31
|
+
kind: step.decision.kind,
|
|
32
|
+
...('nodeId' in step.decision
|
|
33
|
+
? { nodeId: step.decision.nodeId }
|
|
34
|
+
: {}),
|
|
35
|
+
instruction: step.decision.instruction,
|
|
36
|
+
})),
|
|
37
|
+
affectedNodeIds: context.affectedNodeIds,
|
|
38
|
+
contracts: context.contracts,
|
|
39
|
+
existingEdges: context.existingEdges,
|
|
40
|
+
removedIncidentEdges: context.stage.nodeRemovalConnections.map((change) => change.edge),
|
|
41
|
+
apiInstances: context.apiInstances,
|
|
42
|
+
nativeNodes: context.stage.content.nativeNodes,
|
|
43
|
+
...(context.stage.content.gapNodes === undefined
|
|
44
|
+
? {}
|
|
45
|
+
: {
|
|
46
|
+
gapNodes: context.stage.content.gapNodes.map((gap) => ({
|
|
47
|
+
id: gap.id,
|
|
48
|
+
requestedBehavior: gap.requestedBehavior,
|
|
49
|
+
finding: gap.finding,
|
|
50
|
+
})),
|
|
51
|
+
}),
|
|
52
|
+
requirements: context.stage.content.requirements,
|
|
53
|
+
messages: context.messages,
|
|
54
|
+
backgroundMessages: context.backgroundMessages,
|
|
55
|
+
includeExplanations: context.includeExplanations,
|
|
56
|
+
})),
|
|
57
|
+
]);
|
|
58
|
+
let proposal;
|
|
59
|
+
try {
|
|
60
|
+
proposal = parseStructuredOutput(schema, output, 'draft connection edit');
|
|
61
|
+
}
|
|
62
|
+
catch (cause) {
|
|
63
|
+
if (!(cause instanceof Error))
|
|
64
|
+
throw cause;
|
|
65
|
+
throw new WorkflowDraftConnectionEditPlanningError({ stage: 'proposal-schema', output }, cause);
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
return resolveWorkflowDraftConnectionEdit({
|
|
69
|
+
...input,
|
|
70
|
+
fingerprint: context.fingerprint,
|
|
71
|
+
proposal,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
catch (cause) {
|
|
75
|
+
if (!(cause instanceof Error))
|
|
76
|
+
throw cause;
|
|
77
|
+
throw new WorkflowDraftConnectionEditPlanningError({ stage: 'proposal-validation', output }, cause);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WorkflowDraftNativeDependencies } from '@openapi-flow/core';
|
|
2
|
+
import type { PlanWorkflowDraftNativeDependenciesInput } from '../types/workflow-draft-native-node-addition.js';
|
|
3
|
+
/** Separate checkpointable choice stage. No model call when no producer choice exists. */
|
|
4
|
+
export declare function planWorkflowDraftNativeDependencies(input: PlanWorkflowDraftNativeDependenciesInput): Promise<WorkflowDraftNativeDependencies>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { HumanMessage, SystemMessage } from '@langchain/core/messages';
|
|
2
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
3
|
+
import { describeWorkflowDraftNativeDependencies, createWorkflowDraftNativeDependenciesSchema, resolveWorkflowDraftNativeDependencies, } from '@openapi-flow/core';
|
|
4
|
+
import { serializeStructuredOutputSchema } from '../schemas/serialize-structured-output-schema.js';
|
|
5
|
+
import { workflowDraftNativeDependenciesPrompt } from '../prompts/workflow-draft-native-dependencies-prompt.js';
|
|
6
|
+
import { WorkflowDraftNativeNodeAdditionPlanningError } from './workflow-draft-native-node-addition-planning-error.js';
|
|
7
|
+
/** Separate checkpointable choice stage. No model call when no producer choice exists. */
|
|
8
|
+
export async function planWorkflowDraftNativeDependencies(input) {
|
|
9
|
+
if (input.model !== undefined &&
|
|
10
|
+
(!input.model || typeof input.model.withStructuredOutput !== 'function'))
|
|
11
|
+
throw new Error('planWorkflowDraftNativeDependencies.model must support structured output when supplied');
|
|
12
|
+
const context = describeWorkflowDraftNativeDependencies(input);
|
|
13
|
+
if (Object.values(context.sourceCandidatesByNodeId).every((ids) => ids.length === 0))
|
|
14
|
+
return resolveWorkflowDraftNativeDependencies({
|
|
15
|
+
...input,
|
|
16
|
+
proposal: {
|
|
17
|
+
sourcesByNodeId: Object.fromEntries(context.roles.map((role) => [role.nodeId, { sourceNodeIds: [] }])),
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
if (!input.model || typeof input.model.withStructuredOutput !== 'function')
|
|
21
|
+
throw new Error('planWorkflowDraftNativeDependencies.model must support structured output for producer choices');
|
|
22
|
+
const output = await input.model
|
|
23
|
+
.withStructuredOutput(serializeStructuredOutputSchema(createWorkflowDraftNativeDependenciesSchema(input), 'draft-2020-12'), {
|
|
24
|
+
name: 'plan_draft_native_dependencies',
|
|
25
|
+
method: 'jsonSchema',
|
|
26
|
+
strict: true,
|
|
27
|
+
})
|
|
28
|
+
.invoke([
|
|
29
|
+
new SystemMessage(workflowDraftNativeDependenciesPrompt),
|
|
30
|
+
new HumanMessage(JSON.stringify(context)),
|
|
31
|
+
]);
|
|
32
|
+
try {
|
|
33
|
+
if (!isDeepStrictEqual(describeWorkflowDraftNativeDependencies(input), context))
|
|
34
|
+
throw new Error('Draft native producer source contracts changed during planning; no automatic rebase');
|
|
35
|
+
return resolveWorkflowDraftNativeDependencies({
|
|
36
|
+
...input,
|
|
37
|
+
proposal: output,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
catch (cause) {
|
|
41
|
+
if (!(cause instanceof Error))
|
|
42
|
+
throw cause;
|
|
43
|
+
throw new WorkflowDraftNativeNodeAdditionPlanningError({ stage: 'producer-dependencies', output }, cause);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WorkflowDraftNativeReferenceRepairResult } from '@openapi-flow/core';
|
|
2
|
+
import type { PlanWorkflowDraftNativeReferenceRepairInput } from '../types/workflow-draft-native-reference-repair.js';
|
|
3
|
+
/** One model call proposes only source choices for implementation-declared reference locations. */
|
|
4
|
+
export declare function planWorkflowDraftNativeReferenceRepair(input: PlanWorkflowDraftNativeReferenceRepairInput): Promise<WorkflowDraftNativeReferenceRepairResult>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { HumanMessage, SystemMessage } from '@langchain/core/messages';
|
|
2
|
+
import { describeWorkflowDraftClarification, describeWorkflowDraftNativeReferenceRepair, createWorkflowDraftNativeReferenceRepairSchema, resolveWorkflowDraftNativeReferenceRepair, } from '@openapi-flow/core';
|
|
3
|
+
import { workflowDraftNativeReferenceRepairPrompt } from '../prompts/workflow-draft-native-reference-repair-prompt.js';
|
|
4
|
+
import { serializeStructuredOutputSchema } from '../schemas/serialize-structured-output-schema.js';
|
|
5
|
+
import { parseStructuredOutput } from '../legacy/planning/parse-structured-output.js';
|
|
6
|
+
import { WorkflowDraftNativeReferenceRepairPlanningError } from './workflow-draft-native-reference-repair-planning-error.js';
|
|
7
|
+
/** One model call proposes only source choices for implementation-declared reference locations. */
|
|
8
|
+
export async function planWorkflowDraftNativeReferenceRepair(input) {
|
|
9
|
+
const context = describeWorkflowDraftNativeReferenceRepair(input);
|
|
10
|
+
if (!input.model || typeof input.model.withStructuredOutput !== 'function')
|
|
11
|
+
throw new Error('planWorkflowDraftNativeReferenceRepair.model must support structured output');
|
|
12
|
+
const schema = createWorkflowDraftNativeReferenceRepairSchema(context);
|
|
13
|
+
const output = await input.model
|
|
14
|
+
.withStructuredOutput(serializeStructuredOutputSchema(schema, 'draft-7'), {
|
|
15
|
+
name: 'plan_draft_native_reference_repair',
|
|
16
|
+
method: 'jsonSchema',
|
|
17
|
+
strict: true,
|
|
18
|
+
})
|
|
19
|
+
.invoke([
|
|
20
|
+
new SystemMessage(workflowDraftNativeReferenceRepairPrompt),
|
|
21
|
+
new HumanMessage(JSON.stringify({
|
|
22
|
+
clarification: describeWorkflowDraftClarification(input.context),
|
|
23
|
+
instructions: context.instructions,
|
|
24
|
+
target: { node: context.node, references: context.bindings },
|
|
25
|
+
sourceChanges: context.task.sourceNodeIds,
|
|
26
|
+
sourceCandidates: context.sources.values.map((source) => source.kind === 'native'
|
|
27
|
+
? source
|
|
28
|
+
: {
|
|
29
|
+
kind: source.kind,
|
|
30
|
+
nodeId: source.nodeId,
|
|
31
|
+
preparation: source.preparation,
|
|
32
|
+
operation: {
|
|
33
|
+
method: source.operation.method,
|
|
34
|
+
path: source.operation.path,
|
|
35
|
+
summary: source.operation.operation.summary,
|
|
36
|
+
description: source.operation.operation.description,
|
|
37
|
+
responses: source.operation.operation.responses,
|
|
38
|
+
},
|
|
39
|
+
responsePointerCatalog: source.responsePointerCatalog,
|
|
40
|
+
}),
|
|
41
|
+
exclusiveOutputSources: context.sources.exclusiveOutputs,
|
|
42
|
+
messages: context.messages,
|
|
43
|
+
backgroundMessages: context.backgroundMessages,
|
|
44
|
+
includeExplanations: context.includeExplanations,
|
|
45
|
+
})),
|
|
46
|
+
]);
|
|
47
|
+
let proposal;
|
|
48
|
+
try {
|
|
49
|
+
proposal = parseStructuredOutput(schema, output, 'draft native reference repair');
|
|
50
|
+
}
|
|
51
|
+
catch (cause) {
|
|
52
|
+
if (!(cause instanceof Error))
|
|
53
|
+
throw cause;
|
|
54
|
+
throw new WorkflowDraftNativeReferenceRepairPlanningError({ stage: 'proposal-schema', output }, cause);
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
return resolveWorkflowDraftNativeReferenceRepair({
|
|
58
|
+
...input,
|
|
59
|
+
fingerprint: context.fingerprint,
|
|
60
|
+
proposal,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
catch (cause) {
|
|
64
|
+
if (!(cause instanceof Error))
|
|
65
|
+
throw cause;
|
|
66
|
+
throw new WorkflowDraftNativeReferenceRepairPlanningError({ stage: 'proposal-validation', output }, cause);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { WorkflowDraftEditProposal } from '@openapi-flow/core';
|
|
2
|
+
import type { WorkflowDraftEditModelOutput, WorkflowDraftEditOperationCandidate } from '../types/workflow-draft-edit.js';
|
|
3
|
+
export declare function resolveWorkflowDraftEditProposal(proposed: WorkflowDraftEditModelOutput, candidates: WorkflowDraftEditOperationCandidate[]): WorkflowDraftEditProposal;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export function resolveWorkflowDraftEditProposal(proposed, candidates) {
|
|
2
|
+
function operation(candidateId) {
|
|
3
|
+
const candidate = candidates.find((candidate) => candidate.candidateId === candidateId);
|
|
4
|
+
if (!candidate)
|
|
5
|
+
throw new Error(`Unknown draft edit operation candidate ${candidateId}`);
|
|
6
|
+
return structuredClone(candidate.operation.key);
|
|
7
|
+
}
|
|
8
|
+
function evidence(item) {
|
|
9
|
+
return item.kind === 'oas'
|
|
10
|
+
? { kind: 'oas', operation: operation(item.candidateId), pointer: '' }
|
|
11
|
+
: structuredClone(item);
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
decisions: proposed.decisions.map((decision) => {
|
|
15
|
+
const { explanation, ...original } = decision;
|
|
16
|
+
const fields = explanation === undefined
|
|
17
|
+
? {}
|
|
18
|
+
: {
|
|
19
|
+
explanation: {
|
|
20
|
+
reason: explanation.reason,
|
|
21
|
+
evidence: explanation.evidence.map(evidence),
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
if (original.kind === 'report-capability-gap') {
|
|
25
|
+
const finding = original.finding;
|
|
26
|
+
return {
|
|
27
|
+
...original,
|
|
28
|
+
finding: finding.kind === 'api-contract-gap'
|
|
29
|
+
? { ...finding, operation: operation(finding.operation) }
|
|
30
|
+
: finding,
|
|
31
|
+
...fields,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return 'operation' in original
|
|
35
|
+
? { ...original, operation: operation(original.operation), ...fields }
|
|
36
|
+
: { ...original, ...fields };
|
|
37
|
+
}),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WorkflowDraftApiBindingIntent } from '@openapi-flow/core';
|
|
2
|
+
import type { SelectWorkflowDraftApiBindingInputsInput } from '../types/workflow-draft-api-call-planning.js';
|
|
3
|
+
/** Select dependency intent before exposing producer schemas or permitting binding questions. */
|
|
4
|
+
export declare function selectWorkflowDraftApiBindingInputs(input: SelectWorkflowDraftApiBindingInputsInput): Promise<WorkflowDraftApiBindingIntent>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
2
|
+
import { HumanMessage, SystemMessage } from '@langchain/core/messages';
|
|
3
|
+
import { describeWorkflowDraftApiBindingIntent, describeWorkflowDraftClarificationOwnership, createWorkflowDraftApiBindingIntentSchema, resolveWorkflowDraftApiBindingIntent, } from '@openapi-flow/core';
|
|
4
|
+
import { workflowDraftApiBindingIntentPrompt } from '../prompts/workflow-draft-api-call-planning-prompt.js';
|
|
5
|
+
import { serializeStructuredOutputSchema } from '../schemas/serialize-structured-output-schema.js';
|
|
6
|
+
import { parseStructuredOutput } from '../legacy/planning/parse-structured-output.js';
|
|
7
|
+
import { WorkflowDraftApiCallPlanningError } from './workflow-draft-api-call-planning-error.js';
|
|
8
|
+
/** Select dependency intent before exposing producer schemas or permitting binding questions. */
|
|
9
|
+
export async function selectWorkflowDraftApiBindingInputs(input) {
|
|
10
|
+
const description = describeWorkflowDraftApiBindingIntent(input);
|
|
11
|
+
const schema = createWorkflowDraftApiBindingIntentSchema(input);
|
|
12
|
+
const planningClarifications = describeWorkflowDraftClarificationOwnership({
|
|
13
|
+
...input,
|
|
14
|
+
stepId: input.stepId,
|
|
15
|
+
stage: 'api-bindings',
|
|
16
|
+
});
|
|
17
|
+
if (!description.hasRequestInputs ||
|
|
18
|
+
(!description.hasPotentialPredecessors && !planningClarifications.length))
|
|
19
|
+
return resolveWorkflowDraftApiBindingIntent({
|
|
20
|
+
...input,
|
|
21
|
+
fingerprint: description.fingerprint,
|
|
22
|
+
proposal: {
|
|
23
|
+
targets: [],
|
|
24
|
+
sourceMessageIds: description.messages.map((message) => message.id),
|
|
25
|
+
...(description.includeExplanations
|
|
26
|
+
? {
|
|
27
|
+
explanation: {
|
|
28
|
+
reason: !description.hasRequestInputs
|
|
29
|
+
? 'The selected OAS has no request fields for predecessor bindings.'
|
|
30
|
+
: 'There is no other selected instance or declared predecessor contract and no explicit binding concern. Missing literals remain the OAS argument stage responsibility.',
|
|
31
|
+
evidence: description.messages.map((message) => ({
|
|
32
|
+
kind: 'message',
|
|
33
|
+
messageId: message.id,
|
|
34
|
+
})),
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
: {}),
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
if (!input.model || typeof input.model.withStructuredOutput !== 'function')
|
|
41
|
+
throw new Error('selectWorkflowDraftApiBindingInputs.model must support structured output when dependency intent is unresolved');
|
|
42
|
+
const output = await input.model
|
|
43
|
+
.withStructuredOutput(serializeStructuredOutputSchema(schema, 'draft-2020-12'), {
|
|
44
|
+
name: 'select_draft_api_binding_inputs',
|
|
45
|
+
method: 'jsonSchema',
|
|
46
|
+
strict: true,
|
|
47
|
+
})
|
|
48
|
+
.invoke([
|
|
49
|
+
new SystemMessage(workflowDraftApiBindingIntentPrompt),
|
|
50
|
+
new HumanMessage(JSON.stringify({
|
|
51
|
+
instruction: description.instruction,
|
|
52
|
+
messages: description.messages,
|
|
53
|
+
backgroundMessages: description.backgroundMessages,
|
|
54
|
+
planningClarifications,
|
|
55
|
+
operation: {
|
|
56
|
+
key: description.operation.key,
|
|
57
|
+
method: description.operation.method,
|
|
58
|
+
path: description.operation.path,
|
|
59
|
+
summary: description.operation.operation.summary,
|
|
60
|
+
description: description.operation.operation.description,
|
|
61
|
+
parameters: description.operation.effective.parameters,
|
|
62
|
+
},
|
|
63
|
+
requestSchema: description.requestSchema,
|
|
64
|
+
requestMediaType: description.requestMediaType,
|
|
65
|
+
includeExplanations: description.includeExplanations,
|
|
66
|
+
})),
|
|
67
|
+
]);
|
|
68
|
+
try {
|
|
69
|
+
const proposal = parseStructuredOutput(schema, output, 'draft API binding input intent');
|
|
70
|
+
if (!isDeepStrictEqual(proposal, output))
|
|
71
|
+
throw new Error('API binding input intent output changed during validation');
|
|
72
|
+
return resolveWorkflowDraftApiBindingIntent({
|
|
73
|
+
...input,
|
|
74
|
+
fingerprint: description.fingerprint,
|
|
75
|
+
proposal,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
catch (cause) {
|
|
79
|
+
if (!(cause instanceof Error))
|
|
80
|
+
throw cause;
|
|
81
|
+
throw new WorkflowDraftApiCallPlanningError({ stage: 'binding-inputs', output }, cause);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WorkflowDraftApiInputEditContract } from '@openapi-flow/core';
|
|
2
|
+
import type { SelectWorkflowDraftApiInputEditTargetsInput } from '../types/workflow-draft-api-input-edit.js';
|
|
3
|
+
/** One bounded field-selection call; caller may review before value generation. */
|
|
4
|
+
export declare function selectWorkflowDraftApiInputEditTargets(input: SelectWorkflowDraftApiInputEditTargetsInput): Promise<WorkflowDraftApiInputEditContract>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { HumanMessage, SystemMessage } from '@langchain/core/messages';
|
|
2
|
+
import { describeWorkflowDraftClarification, describeWorkflowDraftClarificationOwnership, describeWorkflowDraftApiInputEdit, createWorkflowDraftApiInputEditProposalSchema, createWorkflowDraftApiInputEditContract, } from '@openapi-flow/core';
|
|
3
|
+
import { workflowDraftApiInputEditTargetsPrompt } from '../prompts/workflow-draft-api-input-edit-prompt.js';
|
|
4
|
+
import { WorkflowDraftApiInputEditPlanningError } from './workflow-draft-api-input-edit-planning-error.js';
|
|
5
|
+
import { parseStructuredOutput } from '../legacy/planning/parse-structured-output.js';
|
|
6
|
+
import { serializeStructuredOutputSchema } from '../schemas/serialize-structured-output-schema.js';
|
|
7
|
+
import { createWorkflowMessageEvidenceSelectionSchema } from '../schemas/create-workflow-message-evidence-selection-schema.js';
|
|
8
|
+
/** One bounded field-selection call; caller may review before value generation. */
|
|
9
|
+
export async function selectWorkflowDraftApiInputEditTargets(input) {
|
|
10
|
+
const described = describeWorkflowDraftApiInputEdit(input);
|
|
11
|
+
if (!input.model || typeof input.model.withStructuredOutput !== 'function')
|
|
12
|
+
throw new Error('selectWorkflowDraftApiInputEditTargets.model must support structured output');
|
|
13
|
+
const planId = input.plan.id;
|
|
14
|
+
const schema = createWorkflowDraftApiInputEditProposalSchema(input.requestMessageIds, described.includeExplanations, createWorkflowMessageEvidenceSelectionSchema(described.messages));
|
|
15
|
+
const output = await input.model
|
|
16
|
+
.withStructuredOutput(serializeStructuredOutputSchema(schema, 'draft-7', 'input'), {
|
|
17
|
+
name: 'select_draft_api_input_edit_targets',
|
|
18
|
+
method: 'jsonSchema',
|
|
19
|
+
strict: true,
|
|
20
|
+
})
|
|
21
|
+
.invoke([
|
|
22
|
+
new SystemMessage(workflowDraftApiInputEditTargetsPrompt),
|
|
23
|
+
new HumanMessage(JSON.stringify({
|
|
24
|
+
clarification: describeWorkflowDraftClarification(input.context),
|
|
25
|
+
planningClarifications: describeWorkflowDraftClarificationOwnership({
|
|
26
|
+
...input,
|
|
27
|
+
stepId: input.stepId,
|
|
28
|
+
stage: 'api-arguments',
|
|
29
|
+
}),
|
|
30
|
+
instruction: described.instruction,
|
|
31
|
+
values: described.call.values,
|
|
32
|
+
bindings: described.call.bindings,
|
|
33
|
+
requestSchema: described.requestSchema,
|
|
34
|
+
messages: described.messages,
|
|
35
|
+
includeExplanations: described.includeExplanations,
|
|
36
|
+
})),
|
|
37
|
+
]);
|
|
38
|
+
try {
|
|
39
|
+
const proposal = parseStructuredOutput(schema, output, 'draft API input edit targets');
|
|
40
|
+
const contract = createWorkflowDraftApiInputEditContract({
|
|
41
|
+
...input,
|
|
42
|
+
proposal,
|
|
43
|
+
});
|
|
44
|
+
if (input.plan.id !== planId ||
|
|
45
|
+
JSON.stringify(describeWorkflowDraftApiInputEdit(input)) !==
|
|
46
|
+
JSON.stringify(described))
|
|
47
|
+
throw new Error('Draft API input edit source changed during target selection; no automatic rebase');
|
|
48
|
+
return contract;
|
|
49
|
+
}
|
|
50
|
+
catch (cause) {
|
|
51
|
+
if (!(cause instanceof Error))
|
|
52
|
+
throw cause;
|
|
53
|
+
throw new WorkflowDraftApiInputEditPlanningError({ stage: 'targets', output }, cause);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WorkflowDraftNativeNodeParameterOwnershipResult } from '@openapi-flow/core';
|
|
2
|
+
import type { SelectWorkflowDraftNativeNodeParameterOwnershipInput } from '../types/workflow-draft-native-node-addition.js';
|
|
3
|
+
/** One separately checkpointable ownership choice; never a hidden value-generation call. */
|
|
4
|
+
export declare function selectWorkflowDraftNativeNodeParameterOwnership(input: SelectWorkflowDraftNativeNodeParameterOwnershipInput): Promise<WorkflowDraftNativeNodeParameterOwnershipResult>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { HumanMessage, SystemMessage } from '@langchain/core/messages';
|
|
2
|
+
import { describeWorkflowDraftNativeNodeAddition, createWorkflowDraftNativeNodeParameterOwnershipSchema, resolveWorkflowDraftNativeNodeParameterOwnership, describeWorkflowDraftClarification, describeWorkflowDraftClarificationOwnership, } from '@openapi-flow/core';
|
|
3
|
+
import { serializeStructuredOutputSchema } from '../schemas/serialize-structured-output-schema.js';
|
|
4
|
+
import { parseStructuredOutput } from '../legacy/planning/parse-structured-output.js';
|
|
5
|
+
import { workflowDraftNativeNodeParameterOwnershipPrompt } from '../prompts/workflow-draft-native-node-addition-prompt.js';
|
|
6
|
+
import { WorkflowDraftNativeNodeAdditionPlanningError } from './workflow-draft-native-node-addition-planning-error.js';
|
|
7
|
+
/** One separately checkpointable ownership choice; never a hidden value-generation call. */
|
|
8
|
+
export async function selectWorkflowDraftNativeNodeParameterOwnership(input) {
|
|
9
|
+
if (input.parameterOwnership !== undefined)
|
|
10
|
+
throw new Error('Native addition already has explicit ownership; remove it before selecting again');
|
|
11
|
+
const description = describeWorkflowDraftNativeNodeAddition(input);
|
|
12
|
+
if (!description.allowRuntimeParameters ||
|
|
13
|
+
!description.capability.supportsRuntimeParameters ||
|
|
14
|
+
description.parameterMode === 'fixed-empty')
|
|
15
|
+
return resolveWorkflowDraftNativeNodeParameterOwnership({
|
|
16
|
+
...input,
|
|
17
|
+
fingerprint: description.fingerprint,
|
|
18
|
+
proposal: {
|
|
19
|
+
decision: {
|
|
20
|
+
status: 'literal',
|
|
21
|
+
sourceMessageIds: description.messages.map((message) => message.id),
|
|
22
|
+
...(description.includeExplanations
|
|
23
|
+
? {
|
|
24
|
+
explanation: {
|
|
25
|
+
reason: 'The supplied policy and registered implementation require no runtime ownership choice.',
|
|
26
|
+
evidence: description.messages.map((message) => ({
|
|
27
|
+
kind: 'message',
|
|
28
|
+
messageId: message.id,
|
|
29
|
+
})),
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
: {}),
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
if (!input.model || typeof input.model.withStructuredOutput !== 'function')
|
|
37
|
+
throw new Error('selectWorkflowDraftNativeNodeParameterOwnership.model must support structured output when ownership is selectable');
|
|
38
|
+
const schema = createWorkflowDraftNativeNodeParameterOwnershipSchema(input);
|
|
39
|
+
const output = await input.model
|
|
40
|
+
.withStructuredOutput(serializeStructuredOutputSchema(schema, 'draft-2020-12'), {
|
|
41
|
+
name: 'select_draft_native_node_parameter_ownership',
|
|
42
|
+
method: 'jsonSchema',
|
|
43
|
+
strict: true,
|
|
44
|
+
})
|
|
45
|
+
.invoke([
|
|
46
|
+
new SystemMessage(workflowDraftNativeNodeParameterOwnershipPrompt),
|
|
47
|
+
new HumanMessage(JSON.stringify({
|
|
48
|
+
clarification: describeWorkflowDraftClarification(input.context),
|
|
49
|
+
planningClarifications: describeWorkflowDraftClarificationOwnership({
|
|
50
|
+
...input,
|
|
51
|
+
stepId: input.stepId,
|
|
52
|
+
stage: 'native-parameters',
|
|
53
|
+
}),
|
|
54
|
+
instruction: description.instruction,
|
|
55
|
+
...(description.sourceDependencies === undefined
|
|
56
|
+
? {}
|
|
57
|
+
: { sourceDependencies: description.sourceDependencies }),
|
|
58
|
+
capability: description.capability,
|
|
59
|
+
parametersSchema: description.parametersSchema,
|
|
60
|
+
messages: description.messages,
|
|
61
|
+
backgroundMessages: description.backgroundMessages,
|
|
62
|
+
sourceCandidates: description.sources.values.map((source) => ({
|
|
63
|
+
kind: source.kind,
|
|
64
|
+
nodeId: source.nodeId,
|
|
65
|
+
})),
|
|
66
|
+
includeExplanations: description.includeExplanations,
|
|
67
|
+
})),
|
|
68
|
+
]);
|
|
69
|
+
try {
|
|
70
|
+
return resolveWorkflowDraftNativeNodeParameterOwnership({
|
|
71
|
+
...input,
|
|
72
|
+
fingerprint: description.fingerprint,
|
|
73
|
+
proposal: parseStructuredOutput(schema, output, 'native addition parameter ownership'),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
catch (cause) {
|
|
77
|
+
if (!(cause instanceof Error))
|
|
78
|
+
throw cause;
|
|
79
|
+
throw new WorkflowDraftNativeNodeAdditionPlanningError({ stage: 'ownership', output }, cause);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { WorkflowDraftNativeParameterEditTargetsResult } from '@openapi-flow/core';
|
|
2
|
+
import type { SelectWorkflowDraftNativeParameterEditTargetsInput } from '../types/workflow-draft-native-parameter-edit.js';
|
|
3
|
+
export declare function selectWorkflowDraftNativeParameterEditTargets(input: SelectWorkflowDraftNativeParameterEditTargetsInput): Promise<WorkflowDraftNativeParameterEditTargetsResult>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { HumanMessage, SystemMessage } from '@langchain/core/messages';
|
|
2
|
+
import { describeWorkflowDraftClarification, describeWorkflowDraftClarificationOwnership, describeWorkflowDraftNativeParameterEdit, createWorkflowDraftNativeParameterEditProposalSchema, resolveWorkflowDraftNativeParameterEditTargets, } from '@openapi-flow/core';
|
|
3
|
+
import { workflowDraftNativeParameterEditTargetsPrompt } from '../prompts/workflow-draft-native-parameter-edit-prompt.js';
|
|
4
|
+
import { serializeStructuredOutputSchema } from '../schemas/serialize-structured-output-schema.js';
|
|
5
|
+
import { createWorkflowMessageEvidenceSelectionSchema } from '../schemas/create-workflow-message-evidence-selection-schema.js';
|
|
6
|
+
import { parseStructuredOutput } from '../legacy/planning/parse-structured-output.js';
|
|
7
|
+
import { WorkflowDraftNativeParameterEditPlanningError } from './workflow-draft-native-parameter-edit-planning-error.js';
|
|
8
|
+
export async function selectWorkflowDraftNativeParameterEditTargets(input) {
|
|
9
|
+
const context = describeWorkflowDraftNativeParameterEdit(input);
|
|
10
|
+
if (!input.model || typeof input.model.withStructuredOutput !== 'function')
|
|
11
|
+
throw new Error('selectWorkflowDraftNativeParameterEditTargets.model must support structured output');
|
|
12
|
+
const schema = createWorkflowDraftNativeParameterEditProposalSchema(context, createWorkflowMessageEvidenceSelectionSchema(context.messages));
|
|
13
|
+
const output = await input.model
|
|
14
|
+
.withStructuredOutput(serializeStructuredOutputSchema(schema, 'draft-7', 'input'), {
|
|
15
|
+
name: 'select_draft_native_parameter_edit_targets',
|
|
16
|
+
method: 'jsonSchema',
|
|
17
|
+
strict: true,
|
|
18
|
+
})
|
|
19
|
+
.invoke([
|
|
20
|
+
new SystemMessage(workflowDraftNativeParameterEditTargetsPrompt),
|
|
21
|
+
new HumanMessage(JSON.stringify({
|
|
22
|
+
clarification: describeWorkflowDraftClarification(input.context),
|
|
23
|
+
planningClarifications: describeWorkflowDraftClarificationOwnership({
|
|
24
|
+
...input,
|
|
25
|
+
stepId: input.stepId,
|
|
26
|
+
stage: 'native-parameters',
|
|
27
|
+
}),
|
|
28
|
+
instruction: context.instruction,
|
|
29
|
+
capability: context.capability,
|
|
30
|
+
parameters: context.node.parameters,
|
|
31
|
+
runtimeParameters: context.node.runtimeParameters,
|
|
32
|
+
parametersSchema: context.parametersSchema,
|
|
33
|
+
messages: context.messages,
|
|
34
|
+
backgroundMessages: context.backgroundMessages,
|
|
35
|
+
includeExplanations: context.includeExplanations,
|
|
36
|
+
})),
|
|
37
|
+
]);
|
|
38
|
+
try {
|
|
39
|
+
const proposal = parseStructuredOutput(schema, output, 'draft native parameter edit targets');
|
|
40
|
+
return resolveWorkflowDraftNativeParameterEditTargets({
|
|
41
|
+
...input,
|
|
42
|
+
fingerprint: context.fingerprint,
|
|
43
|
+
proposal,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
catch (cause) {
|
|
47
|
+
if (!(cause instanceof Error))
|
|
48
|
+
throw cause;
|
|
49
|
+
throw new WorkflowDraftNativeParameterEditPlanningError({ stage: 'targets', output }, cause);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { WorkflowDraftApiBindingEditPlanningFailure } from '../types/workflow-draft-api-binding-edit.js';
|
|
2
|
+
export declare class WorkflowDraftApiBindingEditPlanningError extends Error {
|
|
3
|
+
readonly failure: WorkflowDraftApiBindingEditPlanningFailure;
|
|
4
|
+
constructor(failure: WorkflowDraftApiBindingEditPlanningFailure, cause: Error);
|
|
5
|
+
}
|