@openapi-flow/langchain 0.2.0 → 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/README.md +121 -1
- 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.js +43 -28
- package/dist/arguments/select-api-request-media-type.js +8 -37
- package/dist/bindings/plan-api-bindings.js +30 -23
- 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/prompts/api-arguments-prompt.d.ts +1 -1
- package/dist/prompts/api-arguments-prompt.js +1 -1
- package/dist/prompts/api-bindings-prompt.d.ts +1 -1
- package/dist/prompts/api-bindings-prompt.js +1 -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 -1
- package/dist/prompts/api-request-media-type-prompt.js +1 -1
- 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 -1
- package/dist/prompts/native-node-planning-prompt.js +14 -1
- package/dist/prompts/reviewable-workflow-graph-prompt.d.ts +1 -1
- package/dist/prompts/workflow-connections-prompt.d.ts +1 -1
- package/dist/prompts/workflow-connections-prompt.js +3 -1
- 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 -1
- package/dist/prompts/workflow-graph-prompt.js +2 -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 +47 -0
- package/dist/public-api.js +34 -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 +7 -2
- package/dist/schemas/api-binding-plan-schema.js +11 -1
- 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 +5 -2
- package/dist/schemas/api-request-media-type-schema.js +14 -2
- 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 +14 -1
- package/dist/schemas/api-selection-schema.js +6 -5
- 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 +4 -2
- package/dist/schemas/reviewable-workflow-graph-schema.js +13 -1
- 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 +2 -2
- package/dist/schemas/workflow-graph-proposal-schema.js +14 -7
- 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 +1 -1
- package/dist/selection/select-api-operations.js +39 -6
- 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 +11 -5
- package/dist/types/binding-planning.d.ts +7 -5
- package/dist/types/native-node-planning.d.ts +67 -16
- package/dist/types/operation-selection.d.ts +5 -1
- package/dist/types/request-media-selection.d.ts +7 -2
- package/dist/types/reviewable-workflow-planning.d.ts +11 -2
- 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 +13 -15
- package/dist/types/workflow-planning.d.ts +19 -7
- package/dist/types/workflow-review-suggestions.d.ts +12 -0
- package/dist/types/workflow-review-suggestions.js +1 -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/orchestrate-workflow.js +2 -2
- 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.js +63 -66
- package/dist/workflow/plan-reviewable-workflow-graph.js +33 -64
- package/dist/workflow/plan-workflow-connections.js +35 -30
- package/dist/workflow/plan-workflow-graph.js +45 -64
- 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/select-native-node-instances.d.ts +4 -0
- package/dist/workflow/select-native-node-instances.js +57 -0
- package/package.json +7 -4
- package/dist/schemas/native-node-plan-schema.d.ts +0 -4
- package/dist/schemas/native-node-plan-schema.js +0 -26
- package/dist/workflow/assemble-native-node-materials.d.ts +0 -3
- package/dist/workflow/assemble-native-node-materials.js +0 -8
- package/dist/workflow/create-prepared-native-node-materials.d.ts +0 -4
- package/dist/workflow/create-prepared-native-node-materials.js +0 -15
- package/dist/workflow/prepare-workflow-connection-materials.d.ts +0 -3
- package/dist/workflow/prepare-workflow-connection-materials.js +0 -66
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createApiInputSourceSelectionSchema } from '@openapi-flow/core';
|
|
3
|
+
export const apiInputAnswerExplanationOptionsSchema = z.strictObject({
|
|
4
|
+
includeExplanations: z.boolean().optional(),
|
|
5
|
+
});
|
|
6
|
+
/** Values and unanswered IDs are deliberately not model-owned output fields. */
|
|
7
|
+
export function createApiInputAnswerSourceSchema(requirements, catalog, includeExplanations = false) {
|
|
8
|
+
const ids = requirements.map((item) => item.id);
|
|
9
|
+
if (!ids.length || new Set(ids).size !== ids.length)
|
|
10
|
+
throw new Error('Answer source schema requires distinct pending requirements');
|
|
11
|
+
const reason = z
|
|
12
|
+
.string()
|
|
13
|
+
.min(1)
|
|
14
|
+
.describe("A brief user-facing reason in the user's language, grounded only in this reply and the supplied pending questions. Instruction/schema language does not set the user's language. Never translate input values, identifiers or original source spans. Not a hidden reasoning trace or a claim that code validation passed.");
|
|
15
|
+
const answer = z.strictObject({
|
|
16
|
+
requirementId: z
|
|
17
|
+
.enum(ids)
|
|
18
|
+
.describe('The offered pending question answered by this exact source span.'),
|
|
19
|
+
source: createApiInputSourceSelectionSchema(catalog),
|
|
20
|
+
...(includeExplanations ? { reason } : {}),
|
|
21
|
+
});
|
|
22
|
+
return z.strictObject({
|
|
23
|
+
answers: z
|
|
24
|
+
.array(answer)
|
|
25
|
+
.describe('Select each answered pending question at most once. Return [] when the reply gives no complete requested value. Do not return a value field or fabricate missing inputs.'),
|
|
26
|
+
...(includeExplanations ? { reason } : {}),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ApiArgumentGenerationContract } from '@openapi-flow/core';
|
|
3
|
+
import type { ApiLiteralGenerationOutputSchema } from '../types/argument-generation.js';
|
|
4
|
+
export declare const apiLiteralGenerationOptionsSchema: z.ZodObject<{
|
|
5
|
+
includeExplanations: z.ZodOptional<z.ZodBoolean>;
|
|
6
|
+
}, z.core.$strict>;
|
|
7
|
+
export declare const apiLiteralGenerationReasonSchema: z.ZodObject<{
|
|
8
|
+
reason: z.ZodString;
|
|
9
|
+
}, z.core.$strict>;
|
|
10
|
+
/** The core values schema is unchanged; only optional human-readable attribution is added. */
|
|
11
|
+
export declare function createApiLiteralGenerationOutputSchema(contract: ApiArgumentGenerationContract, includeExplanations: boolean): ApiLiteralGenerationOutputSchema;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const apiLiteralGenerationOptionsSchema = z.strictObject({
|
|
3
|
+
includeExplanations: z.boolean().optional(),
|
|
4
|
+
});
|
|
5
|
+
export const apiLiteralGenerationReasonSchema = z.strictObject({
|
|
6
|
+
reason: z
|
|
7
|
+
.string()
|
|
8
|
+
.min(1)
|
|
9
|
+
.refine((value) => value.trim().length > 0)
|
|
10
|
+
.describe('Brief user-facing reason in the scenario language for these proposed literals or their deliberate omission. It applies only to values in this proposal, not confirmed inputs or preceding-node bindings. Code attaches the original scenario, optional call role and the actual projected literal input contract. Do not generate evidence, source quotes, OAS schemas, metadata, missing-input reports or private chain-of-thought.'),
|
|
11
|
+
});
|
|
12
|
+
/** The core values schema is unchanged; only optional human-readable attribution is added. */
|
|
13
|
+
export function createApiLiteralGenerationOutputSchema(contract, includeExplanations) {
|
|
14
|
+
z.boolean().parse(includeExplanations);
|
|
15
|
+
return includeExplanations && contract.hasLiteralInputs
|
|
16
|
+
? contract.schema.extend({
|
|
17
|
+
explanation: apiLiteralGenerationReasonSchema,
|
|
18
|
+
})
|
|
19
|
+
: contract.schema;
|
|
20
|
+
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
export declare function createApiRequestMediaTypeSchema(mediaTypes: string[], includeExplanations?: boolean): z.ZodObject<{
|
|
3
|
+
requestMediaType: z.ZodNullable<z.ZodEnum<{
|
|
4
|
+
[x: string]: string;
|
|
5
|
+
}>>;
|
|
6
|
+
}, z.core.$strict>;
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export function createApiRequestMediaTypeSchema(mediaTypes) {
|
|
2
|
+
export function createApiRequestMediaTypeSchema(mediaTypes, includeExplanations = false) {
|
|
3
|
+
z.boolean().parse(includeExplanations);
|
|
3
4
|
if (mediaTypes.length < 2)
|
|
4
5
|
throw new Error('request media selection requires multiple declared media types');
|
|
5
|
-
|
|
6
|
+
const schema = z.strictObject({
|
|
6
7
|
requestMediaType: z
|
|
7
8
|
.enum(mediaTypes)
|
|
8
9
|
.nullable()
|
|
9
10
|
.describe('Exact OAS requestBody.content key matching an explicitly requested format, or null when the scenario leaves the format unspecified or ambiguous so code can apply the documented default. This is the request Content-Type, not the response format.'),
|
|
10
11
|
});
|
|
12
|
+
return includeExplanations
|
|
13
|
+
? schema.extend({
|
|
14
|
+
explanation: z.strictObject({
|
|
15
|
+
reason: z
|
|
16
|
+
.string()
|
|
17
|
+
.min(1)
|
|
18
|
+
.refine((value) => value.trim().length > 0)
|
|
19
|
+
.describe('Short user-facing reason in the scenario language for the explicit format match, or for returning null because the format is unspecified/ambiguous. Explain the assessment only; code chooses any documented default and attaches the exact scenario and OAS requestBody. Do not generate quotations, source identities, expected responses or private chain-of-thought.'),
|
|
20
|
+
}),
|
|
21
|
+
})
|
|
22
|
+
: schema;
|
|
11
23
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare function createApiSelectionAnalysisSchema(candidateIds: string[], includeExplanations?: boolean): z.ZodObject<{
|
|
3
|
+
operations: z.ZodArray<z.ZodObject<{
|
|
4
|
+
candidateId: z.ZodEnum<{
|
|
5
|
+
[x: string]: string;
|
|
6
|
+
}>;
|
|
7
|
+
purpose: z.ZodString;
|
|
8
|
+
}, z.core.$strict> | z.ZodObject<{
|
|
9
|
+
candidateId: z.ZodEnum<{
|
|
10
|
+
[x: string]: string;
|
|
11
|
+
}>;
|
|
12
|
+
purpose: z.ZodString;
|
|
13
|
+
explanation: z.ZodObject<{
|
|
14
|
+
reason: z.ZodString;
|
|
15
|
+
}, z.core.$strict>;
|
|
16
|
+
}, z.core.$strict>>;
|
|
17
|
+
gaps: z.ZodArray<z.ZodObject<{
|
|
18
|
+
description: z.ZodString;
|
|
19
|
+
}, z.core.$strict> | z.ZodObject<{
|
|
20
|
+
description: z.ZodString;
|
|
21
|
+
explanation: z.ZodObject<{
|
|
22
|
+
reason: z.ZodString;
|
|
23
|
+
}, z.core.$strict>;
|
|
24
|
+
}, z.core.$strict>>;
|
|
25
|
+
questions: z.ZodArray<z.ZodObject<{
|
|
26
|
+
message: z.ZodString;
|
|
27
|
+
purpose: z.ZodString;
|
|
28
|
+
candidateIds: z.ZodArray<z.ZodEnum<{
|
|
29
|
+
[x: string]: string;
|
|
30
|
+
}>>;
|
|
31
|
+
}, z.core.$strict> | z.ZodObject<{
|
|
32
|
+
message: z.ZodString;
|
|
33
|
+
purpose: z.ZodString;
|
|
34
|
+
candidateIds: z.ZodArray<z.ZodEnum<{
|
|
35
|
+
[x: string]: string;
|
|
36
|
+
}>>;
|
|
37
|
+
explanation: z.ZodObject<{
|
|
38
|
+
reason: z.ZodString;
|
|
39
|
+
}, z.core.$strict>;
|
|
40
|
+
}, z.core.$strict>>;
|
|
41
|
+
}, z.core.$strict>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createApiSelectionSchema } from './api-selection-schema.js';
|
|
3
|
+
import { withApiSelectionExplanation } from './with-api-selection-explanation.js';
|
|
4
|
+
export function createApiSelectionAnalysisSchema(candidateIds, includeExplanations = false) {
|
|
5
|
+
return createApiSelectionSchema(candidateIds, includeExplanations).extend({
|
|
6
|
+
questions: z
|
|
7
|
+
.array(withApiSelectionExplanation(z.strictObject({
|
|
8
|
+
message: z
|
|
9
|
+
.string()
|
|
10
|
+
.min(1)
|
|
11
|
+
.describe('Ask only a consequential unresolved API-role choice. Do not ask for request values before reading full contracts.'),
|
|
12
|
+
purpose: z
|
|
13
|
+
.string()
|
|
14
|
+
.min(1)
|
|
15
|
+
.describe('The one user-requested role that will be fulfilled by exactly one offered candidate.'),
|
|
16
|
+
candidateIds: z
|
|
17
|
+
.array(z.enum(candidateIds))
|
|
18
|
+
.min(2)
|
|
19
|
+
.describe('Distinct supplied alternatives for this role, not API calls that should all run.'),
|
|
20
|
+
}), includeExplanations))
|
|
21
|
+
.describe('Empty when the requested API scope is clear. Multiple available APIs alone is not ambiguity. Never expand a short request into unrelated actions.'),
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export declare function createApiSelectionSchema(candidateIds: string[]): z.ZodObject<{
|
|
2
|
+
export declare function createApiSelectionSchema(candidateIds: string[], includeExplanations?: boolean): z.ZodObject<{
|
|
3
3
|
operations: z.ZodArray<z.ZodObject<{
|
|
4
4
|
candidateId: z.ZodEnum<{
|
|
5
5
|
[x: string]: string;
|
|
6
6
|
}>;
|
|
7
7
|
purpose: z.ZodString;
|
|
8
|
+
}, z.core.$strict> | z.ZodObject<{
|
|
9
|
+
candidateId: z.ZodEnum<{
|
|
10
|
+
[x: string]: string;
|
|
11
|
+
}>;
|
|
12
|
+
purpose: z.ZodString;
|
|
13
|
+
explanation: z.ZodObject<{
|
|
14
|
+
reason: z.ZodString;
|
|
15
|
+
}, z.core.$strict>;
|
|
8
16
|
}, z.core.$strict>>;
|
|
9
17
|
gaps: z.ZodArray<z.ZodObject<{
|
|
10
18
|
description: z.ZodString;
|
|
19
|
+
}, z.core.$strict> | z.ZodObject<{
|
|
20
|
+
description: z.ZodString;
|
|
21
|
+
explanation: z.ZodObject<{
|
|
22
|
+
reason: z.ZodString;
|
|
23
|
+
}, z.core.$strict>;
|
|
11
24
|
}, z.core.$strict>>;
|
|
12
25
|
}, z.core.$strict>;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
|
|
2
|
+
import { withApiSelectionExplanation } from './with-api-selection-explanation.js';
|
|
3
|
+
export function createApiSelectionSchema(candidateIds, includeExplanations = false) {
|
|
3
4
|
if (candidateIds.length === 0)
|
|
4
5
|
throw new Error('operations must contain candidates for model selection');
|
|
5
6
|
return z
|
|
6
7
|
.object({
|
|
7
8
|
operations: z
|
|
8
|
-
.array(z
|
|
9
|
+
.array(withApiSelectionExplanation(z
|
|
9
10
|
.object({
|
|
10
11
|
candidateId: z
|
|
11
12
|
.enum(candidateIds)
|
|
@@ -15,16 +16,16 @@ export function createApiSelectionSchema(candidateIds) {
|
|
|
15
16
|
.min(1)
|
|
16
17
|
.describe('The scenario role of this one API call instance. Describe separate required calls separately; this is not an execution order.'),
|
|
17
18
|
})
|
|
18
|
-
.strict())
|
|
19
|
+
.strict(), includeExplanations))
|
|
19
20
|
.describe('One entry per required API call instance, not a deduplicated API catalog. Repeat a candidateId only when the scenario requires separate calls to that API.'),
|
|
20
|
-
gaps: z.array(z
|
|
21
|
+
gaps: z.array(withApiSelectionExplanation(z
|
|
21
22
|
.object({
|
|
22
23
|
description: z
|
|
23
24
|
.string()
|
|
24
25
|
.min(1)
|
|
25
26
|
.describe('Required API capability that no supplied discovery candidate matches. Do not judge missing parameters, response fields or security without a full contract.'),
|
|
26
27
|
})
|
|
27
|
-
.strict()),
|
|
28
|
+
.strict(), includeExplanations)),
|
|
28
29
|
})
|
|
29
30
|
.strict();
|
|
30
31
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { WorkflowSourceMessage } from '@openapi-flow/core';
|
|
3
|
+
/** Resolve only an explicitly selected current source ID, from a captured immutable snapshot. */
|
|
4
|
+
export declare function createWorkflowMessageEvidenceSelectionSchema(supplied: WorkflowSourceMessage[]): z.ZodPipe<z.ZodObject<{
|
|
5
|
+
kind: z.ZodLiteral<"message">;
|
|
6
|
+
messageId: z.ZodEnum<{
|
|
7
|
+
[x: string]: string;
|
|
8
|
+
}>;
|
|
9
|
+
}, z.core.$strict>, z.ZodTransform<{
|
|
10
|
+
quote: string;
|
|
11
|
+
kind: "message";
|
|
12
|
+
messageId: string;
|
|
13
|
+
}, {
|
|
14
|
+
kind: "message";
|
|
15
|
+
messageId: string;
|
|
16
|
+
}>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Resolve only an explicitly selected current source ID, from a captured immutable snapshot. */
|
|
3
|
+
export function createWorkflowMessageEvidenceSelectionSchema(supplied) {
|
|
4
|
+
const messages = z
|
|
5
|
+
.array(z.strictObject({ id: z.string().min(1), text: z.string().min(1) }))
|
|
6
|
+
.min(1)
|
|
7
|
+
.refine((items) => new Set(items.map((item) => item.id)).size === items.length)
|
|
8
|
+
.parse(supplied);
|
|
9
|
+
return z
|
|
10
|
+
.strictObject({
|
|
11
|
+
kind: z.literal('message'),
|
|
12
|
+
messageId: z
|
|
13
|
+
.enum(messages.map((message) => message.id))
|
|
14
|
+
.describe('Select a supplied message ID only. Code attaches its unchanged original text; never generate a quote.'),
|
|
15
|
+
})
|
|
16
|
+
.transform((selection) => {
|
|
17
|
+
const message = messages.find((item) => item.id === selection.messageId);
|
|
18
|
+
if (!message)
|
|
19
|
+
throw new Error(`Message evidence selection references unavailable source ${selection.messageId}`);
|
|
20
|
+
return { ...selection, quote: message.text };
|
|
21
|
+
});
|
|
22
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const nativeNodeExplanationOptionsSchema = z.strictObject({
|
|
3
|
+
includeExplanations: z.boolean().optional(),
|
|
4
|
+
});
|
|
5
|
+
export const nativeNodePlanningReasonSchema = z
|
|
6
|
+
.string()
|
|
7
|
+
.min(1)
|
|
8
|
+
.refine((value) => value.trim().length > 0)
|
|
9
|
+
.describe('Brief user-facing reason in the scenario language for this proposed native instance and its requested parameter values, or for adding no new instance. Explain the proposal, not private chain-of-thought. Code attaches the actual supplied scenario, API roles, prepared nodes and capability schemas. Never generate evidence, ports, output schemas, source quotes, slot IDs or n8n JSON.');
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { WorkflowCapability } from '@openapi-flow/core';
|
|
2
|
+
import type { NativeNodeParameterContract } from '../types/native-node-planning.js';
|
|
3
|
+
export declare function createNativeNodeParameterContract(capability: WorkflowCapability, allowRuntimeParameters: boolean): NativeNodeParameterContract;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createNativePlanningCapabilityMaterial } from '@openapi-flow/core';
|
|
3
|
+
export function createNativeNodeParameterContract(capability, allowRuntimeParameters) {
|
|
4
|
+
const identity = {
|
|
5
|
+
id: z
|
|
6
|
+
.string()
|
|
7
|
+
.min(1)
|
|
8
|
+
.describe('Unique native instance ID, distinct from every supplied API, prepared native and gap ID.'),
|
|
9
|
+
capability: z.literal(capability.name).describe(capability.description),
|
|
10
|
+
};
|
|
11
|
+
const schemas = [];
|
|
12
|
+
const material = createNativePlanningCapabilityMaterial(capability, allowRuntimeParameters);
|
|
13
|
+
if (allowRuntimeParameters && capability.supportsRuntimeParameters === true) {
|
|
14
|
+
schemas.push(z.strictObject({
|
|
15
|
+
...identity,
|
|
16
|
+
parameterSource: z
|
|
17
|
+
.literal('literal')
|
|
18
|
+
.describe('Choose only actual values supplied in the scenario, never placeholders or invented defaults.'),
|
|
19
|
+
parameters: capability.parametersSchema,
|
|
20
|
+
}), z.strictObject({
|
|
21
|
+
...identity,
|
|
22
|
+
parameterSource: z
|
|
23
|
+
.literal('workflow-input')
|
|
24
|
+
.describe('Choose when actual complete parameter values must be supplied at execution and this capability has runtime-independent ports, references and output schema. Never generate any parameters, placeholders or runtime flags here. Code derives the empty parameter object, runtime flag, slot ID and original schema.'),
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
else
|
|
28
|
+
schemas.push(z.strictObject({ ...identity, parameters: capability.parametersSchema }));
|
|
29
|
+
return { schemas, material };
|
|
30
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { WorkflowCapability } from '@openapi-flow/core';
|
|
2
|
+
import type { NativeNodePlanningContract } from '../types/native-node-planning.js';
|
|
3
|
+
export declare function createNativeNodePlanningContract(capabilities: WorkflowCapability[], allowRuntimeParameters?: boolean, includeExplanations?: boolean): NativeNodePlanningContract;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createNativeNodeParameterContract } from './native-node-parameter-contract.js';
|
|
3
|
+
import { nativeNodePlanningReasonSchema } from './native-node-explanation-schema.js';
|
|
4
|
+
export function createNativeNodePlanningContract(capabilities, allowRuntimeParameters = false, includeExplanations = false) {
|
|
5
|
+
if (!capabilities.length)
|
|
6
|
+
throw new Error('native planning schema requires supplied capabilities');
|
|
7
|
+
const contracts = capabilities.map((capability) => createNativeNodeParameterContract(capability, allowRuntimeParameters));
|
|
8
|
+
const nodes = contracts.flatMap((contract) => contract.schemas);
|
|
9
|
+
const nodeSchema = z.union([nodes[0], ...nodes.slice(1)]);
|
|
10
|
+
const gaps = z
|
|
11
|
+
.array(z.strictObject({
|
|
12
|
+
description: nativeNodePlanningReasonSchema.describe('Describe a requested native behavior that cannot be represented and the missing capability or contract. Never a reminder to generate API requests, bindings or connections later.'),
|
|
13
|
+
}))
|
|
14
|
+
.describe('Blocking unmet native behavior only. Return [] when requested native behavior is representable. Selected OAS API calls are implemented separately; their bindings, request arguments and connections belong to later stages, not these gaps. Never invent missing data or substitute a capability.');
|
|
15
|
+
const schema = includeExplanations
|
|
16
|
+
? z.strictObject({
|
|
17
|
+
decision: z.union([
|
|
18
|
+
z.strictObject({
|
|
19
|
+
additions: z
|
|
20
|
+
.array(z.strictObject({
|
|
21
|
+
node: nodeSchema,
|
|
22
|
+
reason: nativeNodePlanningReasonSchema,
|
|
23
|
+
}))
|
|
24
|
+
.min(1)
|
|
25
|
+
.describe('Only NEW native instances required by the scenario. Code extracts node data and keeps the reason outside executable parameters.'),
|
|
26
|
+
gaps,
|
|
27
|
+
}),
|
|
28
|
+
z.strictObject({
|
|
29
|
+
noAdditionalNodesReason: nativeNodePlanningReasonSchema.describe('Why no NEW native instance is proposed, including when prepared nodes suffice or only unmet native requirements remain. Do not repeat supplied nodes or generate a fixed empty node array.'),
|
|
30
|
+
gaps,
|
|
31
|
+
}),
|
|
32
|
+
]),
|
|
33
|
+
})
|
|
34
|
+
: z.strictObject({
|
|
35
|
+
nativeNodes: z
|
|
36
|
+
.array(nodeSchema)
|
|
37
|
+
.describe('Only new instances required by the scenario, with values following the supplied implementation schema. No ports, output schemas, code or n8n JSON.'),
|
|
38
|
+
gaps,
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
schema,
|
|
42
|
+
capabilities: contracts.map((contract) => contract.material),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { WorkflowCapability } from '@openapi-flow/core';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
3
|
+
import type { WorkflowConnectionPlanningOutput } from '../types/workflow-orchestration.js';
|
|
4
|
+
import type { ReviewableWorkflowGraphModelOutput } from '../types/reviewable-workflow-planning.js';
|
|
5
|
+
import type { WorkflowGraphExplanationMode } from '../types/workflow-planning.js';
|
|
6
|
+
export declare function createReviewableWorkflowGraphSchema(capabilities: WorkflowCapability[], readyCallIds: string[], explanationMode?: WorkflowGraphExplanationMode): z.ZodType<WorkflowConnectionPlanningOutput | ReviewableWorkflowGraphModelOutput>;
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
|
|
2
|
+
import { workflowConnectionReasonSchema } from './workflow-connection-explanation-schema.js';
|
|
3
|
+
import { workflowGraphReasonSchema } from './workflow-graph-explanation-schema.js';
|
|
4
|
+
export function createReviewableWorkflowGraphSchema(capabilities, readyCallIds, explanationMode = 'none') {
|
|
5
|
+
const includeExplanations = explanationMode !== 'none';
|
|
6
|
+
const reasonSchema = explanationMode === 'graph'
|
|
7
|
+
? workflowGraphReasonSchema
|
|
8
|
+
: workflowConnectionReasonSchema;
|
|
3
9
|
const natives = capabilities.map((capability) => z.strictObject({
|
|
10
|
+
...(explanationMode === 'graph'
|
|
11
|
+
? { reason: workflowGraphReasonSchema }
|
|
12
|
+
: {}),
|
|
4
13
|
id: z
|
|
5
14
|
.string()
|
|
6
15
|
.min(1)
|
|
@@ -16,6 +25,7 @@ export function createReviewableWorkflowGraphSchema(capabilities, readyCallIds)
|
|
|
16
25
|
const blockedCalls = readyCallIds.length === 0
|
|
17
26
|
? undefined
|
|
18
27
|
: z.array(z.strictObject({
|
|
28
|
+
...(includeExplanations ? { reason: reasonSchema } : {}),
|
|
19
29
|
callId: z
|
|
20
30
|
.enum(readyCallIds)
|
|
21
31
|
.describe('A supplied ready call that must instead be a failing placeholder because a scenario dependency remains unresolved. Do not repeat already blocked calls.'),
|
|
@@ -25,8 +35,10 @@ export function createReviewableWorkflowGraphSchema(capabilities, readyCallIds)
|
|
|
25
35
|
.describe('IDs of supplied or additional gaps that prevent this API call. Never fabricate a response binding.'),
|
|
26
36
|
}));
|
|
27
37
|
const base = z.strictObject({
|
|
38
|
+
...(includeExplanations ? { reason: reasonSchema } : {}),
|
|
28
39
|
edges: z
|
|
29
40
|
.array(z.strictObject({
|
|
41
|
+
...(includeExplanations ? { reason: reasonSchema } : {}),
|
|
30
42
|
from: z
|
|
31
43
|
.string()
|
|
32
44
|
.min(1)
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { JsonObject } from '@openapi-flow/core';
|
|
3
|
+
import type { StructuredOutputSchemaDialect, StructuredOutputSchemaDirection, StructuredOutputSchemaReuse } from '../types/structured-output-schema.js';
|
|
4
|
+
/** Send JSON data, not Zod's non-enumerable Standard Schema re-serialization hook. */
|
|
5
|
+
export declare function serializeStructuredOutputSchema(schema: z.ZodType, target: StructuredOutputSchemaDialect, io?: StructuredOutputSchemaDirection, reused?: StructuredOutputSchemaReuse): JsonObject;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Send JSON data, not Zod's non-enumerable Standard Schema re-serialization hook. */
|
|
3
|
+
export function serializeStructuredOutputSchema(schema, target, io = 'output', reused = 'inline') {
|
|
4
|
+
return JSON.parse(JSON.stringify(z.toJSONSchema(schema, {
|
|
5
|
+
target,
|
|
6
|
+
io,
|
|
7
|
+
reused,
|
|
8
|
+
cycles: 'ref',
|
|
9
|
+
})));
|
|
10
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { WorkflowRequirementsModelOutput } from '../types/workflow-clarification.js';
|
|
3
|
+
/** Own wire serialization; retain descriptions and avoid framework ref/title rewrites. */
|
|
4
|
+
export declare function serializeWorkflowRequirementsSchema(schema: z.ZodType<WorkflowRequirementsModelOutput>): import("@openapi-flow/core").JsonObject;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { serializeStructuredOutputSchema } from './serialize-structured-output-schema.js';
|
|
2
|
+
/** Own wire serialization; retain descriptions and avoid framework ref/title rewrites. */
|
|
3
|
+
export function serializeWorkflowRequirementsSchema(schema) {
|
|
4
|
+
return serializeStructuredOutputSchema(schema, 'draft-7', 'input', 'ref');
|
|
5
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare function withApiSelectionExplanation<Shape extends z.ZodRawShape>(schema: z.ZodObject<Shape, z.core.$strict>, includeExplanations: boolean): z.ZodObject<Shape, z.core.$strict> | z.ZodObject<(keyof Shape & "explanation" extends never ? Shape & {
|
|
3
|
+
explanation: z.ZodObject<{
|
|
4
|
+
reason: z.ZodString;
|
|
5
|
+
}, z.core.$strict>;
|
|
6
|
+
} : { [K in keyof Shape as K extends "explanation" ? never : K]: Shape[K]; } & {
|
|
7
|
+
explanation: z.ZodObject<{
|
|
8
|
+
reason: z.ZodString;
|
|
9
|
+
}, z.core.$strict>;
|
|
10
|
+
}) extends infer T ? { [k in keyof T]: T[k]; } : never, z.core.$strict>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export function withApiSelectionExplanation(schema, includeExplanations) {
|
|
3
|
+
z.boolean().parse(includeExplanations);
|
|
4
|
+
return includeExplanations
|
|
5
|
+
? schema.extend({
|
|
6
|
+
explanation: z.strictObject({
|
|
7
|
+
reason: z
|
|
8
|
+
.string()
|
|
9
|
+
.min(1)
|
|
10
|
+
.refine((value) => value.trim().length > 0)
|
|
11
|
+
.describe('Short user-facing reason in the scenario language for this selection, missing capability or consequential API choice. Use only the supplied scenario and discovery metadata; code attaches those unchanged sources. Do not claim request, response or security contract validation, or expose private chain-of-thought.'),
|
|
12
|
+
}),
|
|
13
|
+
})
|
|
14
|
+
: schema;
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const workflowConnectionExplanationOptionsSchema = z.strictObject({
|
|
3
|
+
includeExplanations: z.boolean().optional(),
|
|
4
|
+
});
|
|
5
|
+
export const workflowConnectionReasonSchema = z
|
|
6
|
+
.string()
|
|
7
|
+
.min(1)
|
|
8
|
+
.refine((value) => value.trim().length > 0)
|
|
9
|
+
.describe('Brief user-facing reason in the scenario language for this graph strategy, new edge or newly blocked call. Use only supplied roles, immutable node parameters, actual ports, declared dependencies and gaps. Explain no-new-edge/independent-root decisions in the top-level reason. Code retains original source contracts and derives starts and verification. Never generate evidence, quoted source copies or private chain-of-thought.');
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ResolvedWorkflowDraftEditOptions, WorkflowDraftEditContextDescription } from '@openapi-flow/core';
|
|
3
|
+
export declare function createWorkflowDraftEditSchema(context: WorkflowDraftEditContextDescription, options: ResolvedWorkflowDraftEditOptions, candidateIds: string[]): z.ZodType<import("@openapi-flow/core").WorkflowDraftEditProposal<string, import("../types/workflow-clarification.js").ProposedWorkflowPlanningEvidence>, unknown, z.core.$ZodTypeInternals<import("@openapi-flow/core").WorkflowDraftEditProposal<string, import("../types/workflow-clarification.js").ProposedWorkflowPlanningEvidence>, unknown>>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createWorkflowDraftEditProposalSchema } from '@openapi-flow/core';
|
|
3
|
+
import { createWorkflowPlanningEvidenceSchemas } from './workflow-planning-evidence-schemas.js';
|
|
4
|
+
export function createWorkflowDraftEditSchema(context, options, candidateIds) {
|
|
5
|
+
const evidence = createWorkflowPlanningEvidenceSchemas(context.planning, candidateIds, context.requestMessageIds);
|
|
6
|
+
return createWorkflowDraftEditProposalSchema(options, {
|
|
7
|
+
...(candidateIds.length ? { operationSchema: z.enum(candidateIds) } : {}),
|
|
8
|
+
apiNodeIds: context.draft.apiCalls.map((call) => call.id),
|
|
9
|
+
nativeNodeIds: context.draft.nativeNodes.map((node) => node.id),
|
|
10
|
+
gapNodeIds: context.draft.gapNodes?.map((node) => node.id),
|
|
11
|
+
capabilityNames: context.planning.capabilities.map((capability) => capability.name),
|
|
12
|
+
requirementIds: context.draft.requirements.map((requirement) => requirement.id),
|
|
13
|
+
removedRequirementIds: context.removedRequirements.map((requirement) => requirement.id),
|
|
14
|
+
messageSchema: evidence.message,
|
|
15
|
+
evidenceSchema: evidence.evidence,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const workflowGraphExplanationOptionsSchema = z.strictObject({
|
|
3
|
+
includeExplanations: z.boolean().optional(),
|
|
4
|
+
});
|
|
5
|
+
export const workflowGraphReasonSchema = z
|
|
6
|
+
.string()
|
|
7
|
+
.min(1)
|
|
8
|
+
.refine((value) => value.trim().length > 0)
|
|
9
|
+
.describe('Brief user-facing reason in the scenario language for this graph strategy, NEW native instance, edge or newly blocked call. Use only the scenario, supplied API roles/contracts, prepared instances and offered native schemas. Explain no new native nodes or independent roots in the overall reason. Code preserves source evidence and derives ports, starts and validation. Do not generate source copies, evidence, quotes or private chain-of-thought.');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { WorkflowCapability } from '@openapi-flow/core';
|
|
3
|
-
import type {
|
|
4
|
-
export declare function createWorkflowGraphProposalSchema(capabilities: WorkflowCapability[]): z.ZodType<
|
|
3
|
+
import type { WorkflowGraphModelOutput } from '../types/workflow-planning.js';
|
|
4
|
+
export declare function createWorkflowGraphProposalSchema(capabilities: WorkflowCapability[], includeExplanations?: boolean): z.ZodType<WorkflowGraphModelOutput>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
throw new Error('capabilities must contain a native node definition');
|
|
2
|
+
import { workflowGraphReasonSchema } from './workflow-graph-explanation-schema.js';
|
|
3
|
+
export function createWorkflowGraphProposalSchema(capabilities, includeExplanations = false) {
|
|
5
4
|
const nativeSchemas = capabilities.map((capability) => z.strictObject({
|
|
5
|
+
...(includeExplanations ? { reason: workflowGraphReasonSchema } : {}),
|
|
6
6
|
id: z
|
|
7
7
|
.string()
|
|
8
8
|
.min(1)
|
|
@@ -10,12 +10,11 @@ export function createWorkflowGraphProposalSchema(capabilities) {
|
|
|
10
10
|
capability: z.literal(capability.name).describe(capability.description),
|
|
11
11
|
parameters: capability.parametersSchema,
|
|
12
12
|
}));
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
.array(z.union([nativeSchemas[0], ...nativeSchemas.slice(1)]))
|
|
16
|
-
.describe('NEW native nodes only. Existing preparedNativeNodes and API materials are already present. Never repeat their IDs or parameters. Return [] when no new native node is needed.'),
|
|
13
|
+
const base = z.strictObject({
|
|
14
|
+
...(includeExplanations ? { reason: workflowGraphReasonSchema } : {}),
|
|
17
15
|
edges: z
|
|
18
16
|
.array(z.strictObject({
|
|
17
|
+
...(includeExplanations ? { reason: workflowGraphReasonSchema } : {}),
|
|
19
18
|
from: z
|
|
20
19
|
.string()
|
|
21
20
|
.min(1)
|
|
@@ -35,4 +34,12 @@ export function createWorkflowGraphProposalSchema(capabilities) {
|
|
|
35
34
|
.array(z.strictObject({ description: z.string().min(1) }))
|
|
36
35
|
.describe('Only explicitly requested requirements that cannot be met. Do not invent a success/end/display requirement; a terminal node completes normally. Never invent a capability, API, or executable code.'),
|
|
37
36
|
});
|
|
37
|
+
if (!nativeSchemas.length)
|
|
38
|
+
return base;
|
|
39
|
+
return z.strictObject({
|
|
40
|
+
additionalNativeNodes: z
|
|
41
|
+
.array(z.union([nativeSchemas[0], ...nativeSchemas.slice(1)]))
|
|
42
|
+
.describe('NEW native nodes only. Existing preparedNativeNodes and API materials are already present. Never repeat their IDs or parameters. Return [] when no new native node is needed.'),
|
|
43
|
+
...base.shape,
|
|
44
|
+
});
|
|
38
45
|
}
|